OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/aura/desktop.h" | 5 #include "ui/aura/desktop.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 | 93 |
94 void GetEventFiltersToNotify(Window* target, EventFilters* filters) { | 94 void GetEventFiltersToNotify(Window* target, EventFilters* filters) { |
95 Window* window = target->parent(); | 95 Window* window = target->parent(); |
96 while (window) { | 96 while (window) { |
97 if (window->event_filter()) | 97 if (window->event_filter()) |
98 filters->push_back(window->event_filter()); | 98 filters->push_back(window->event_filter()); |
99 window = window->parent(); | 99 window = window->parent(); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 // Returns true if |descendant| is a descendant of |ancestor|. | |
104 bool IsAncestor(Window* ancestor, Window* descendant) { | |
105 while (descendant && descendant != ancestor) | |
106 descendant = descendant->parent(); | |
107 return descendant == ancestor; | |
Ben Goodger (Google)
2011/11/28 17:50:19
Rather than defining this here, can you add a Cont
flackr
2011/11/28 20:36:35
Done.
| |
108 } | |
109 | |
103 } // namespace | 110 } // namespace |
104 | 111 |
105 Desktop* Desktop::instance_ = NULL; | 112 Desktop* Desktop::instance_ = NULL; |
106 bool Desktop::use_fullscreen_host_window_ = false; | 113 bool Desktop::use_fullscreen_host_window_ = false; |
107 | 114 |
108 //////////////////////////////////////////////////////////////////////////////// | 115 //////////////////////////////////////////////////////////////////////////////// |
109 // Desktop, public: | 116 // Desktop, public: |
110 | 117 |
111 // static | 118 // static |
112 Desktop* Desktop::GetInstance() { | 119 Desktop* Desktop::GetInstance() { |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 | 533 |
527 Desktop* Desktop::GetDesktop() { | 534 Desktop* Desktop::GetDesktop() { |
528 return this; | 535 return this; |
529 } | 536 } |
530 | 537 |
531 void Desktop::WindowDetachedFromDesktop(Window* detached) { | 538 void Desktop::WindowDetachedFromDesktop(Window* detached) { |
532 DCHECK(capture_window_ != this); | 539 DCHECK(capture_window_ != this); |
533 | 540 |
534 // If the ancestor of the capture window is detached, | 541 // If the ancestor of the capture window is detached, |
535 // release the capture. | 542 // release the capture. |
536 aura::Window* window = capture_window_; | 543 if (IsAncestor(detached, capture_window_) && capture_window_ != this) |
sky
2011/11/28 17:20:22
Is the capture_window_ condition necessary? Also,
flackr
2011/11/28 20:36:35
Oops, seems like I converted the old statement inc
| |
537 while (window && window != detached) | |
538 window = window->parent(); | |
539 if (window && window != this) | |
540 ReleaseCapture(capture_window_); | 544 ReleaseCapture(capture_window_); |
541 | 545 |
542 // If the ancestor of the capture window is detached, | 546 // If the ancestor of the focused window is detached, |
543 // release the focus. | 547 // release the focus. |
544 window = focused_window_; | 548 if (IsAncestor(detached, focused_window_)) |
545 while (window && window != detached) | |
546 window = window->parent(); | |
547 if (window) | |
548 SetFocusedWindow(NULL); | 549 SetFocusedWindow(NULL); |
550 | |
551 // If the ancestor of any event handler windows are detached, release the | |
552 // pointer to those windows. | |
553 if (IsAncestor(detached, mouse_pressed_handler_)) | |
554 mouse_pressed_handler_ = NULL; | |
555 if (IsAncestor(detached, mouse_moved_handler_)) | |
556 mouse_moved_handler_ = NULL; | |
557 if (IsAncestor(detached, touch_event_handler_)) | |
558 touch_event_handler_ = NULL; | |
549 } | 559 } |
550 | 560 |
551 void Desktop::OnLayerAnimationEnded( | 561 void Desktop::OnLayerAnimationEnded( |
552 const ui::LayerAnimationSequence* animation) { | 562 const ui::LayerAnimationSequence* animation) { |
553 OnHostResized(host_->GetSize()); | 563 OnHostResized(host_->GetSize()); |
554 } | 564 } |
555 | 565 |
556 void Desktop::OnLayerAnimationScheduled( | 566 void Desktop::OnLayerAnimationScheduled( |
557 const ui::LayerAnimationSequence* animation) { | 567 const ui::LayerAnimationSequence* animation) { |
558 } | 568 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { | 612 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { |
603 bounds.set_size(gfx::Size(parsed_width, parsed_height)); | 613 bounds.set_size(gfx::Size(parsed_width, parsed_height)); |
604 } else if (use_fullscreen_host_window_) { | 614 } else if (use_fullscreen_host_window_) { |
605 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize()); | 615 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize()); |
606 } | 616 } |
607 | 617 |
608 return bounds; | 618 return bounds; |
609 } | 619 } |
610 | 620 |
611 } // namespace aura | 621 } // namespace aura |
OLD | NEW |