Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: ui/aura/root_window.cc

Issue 9701098: MultiMonitor support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang fix Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/single_monitor_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/root_window.h" 5 #include "ui/aura/root_window.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 case ui::ET_GESTURE_PINCH_END: 60 case ui::ET_GESTURE_PINCH_END:
61 case ui::ET_GESTURE_TAP: 61 case ui::ET_GESTURE_TAP:
62 return NULL; 62 return NULL;
63 default: 63 default:
64 return target; 64 return target;
65 } 65 }
66 } 66 }
67 67
68 } // namespace 68 } // namespace
69 69
70 RootWindow* RootWindow::instance_ = NULL;
71 bool RootWindow::use_fullscreen_host_window_ = false;
72 bool RootWindow::hide_host_cursor_ = false; 70 bool RootWindow::hide_host_cursor_ = false;
73 71
74 //////////////////////////////////////////////////////////////////////////////// 72 ////////////////////////////////////////////////////////////////////////////////
75 // RootWindow, public: 73 // RootWindow, public:
76 74
77 RootWindow::RootWindow() 75 RootWindow::RootWindow(const gfx::Rect& initial_bounds)
78 : Window(NULL), 76 : Window(NULL),
79 host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())), 77 host_(aura::RootWindowHost::Create(initial_bounds)),
80 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), 78 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)),
81 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), 79 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)),
82 mouse_button_flags_(0), 80 mouse_button_flags_(0),
83 last_cursor_(kCursorNull), 81 last_cursor_(kCursorNull),
84 cursor_shown_(true), 82 cursor_shown_(true),
85 capture_window_(NULL), 83 capture_window_(NULL),
86 mouse_pressed_handler_(NULL), 84 mouse_pressed_handler_(NULL),
87 mouse_moved_handler_(NULL), 85 mouse_moved_handler_(NULL),
88 focused_window_(NULL), 86 focused_window_(NULL),
89 touch_event_handler_(NULL), 87 touch_event_handler_(NULL),
90 gesture_handler_(NULL), 88 gesture_handler_(NULL),
91 ALLOW_THIS_IN_INITIALIZER_LIST( 89 ALLOW_THIS_IN_INITIALIZER_LIST(
92 gesture_recognizer_(GestureRecognizer::Create(this))), 90 gesture_recognizer_(GestureRecognizer::Create(this))),
93 synthesize_mouse_move_(false), 91 synthesize_mouse_move_(false),
94 waiting_on_compositing_end_(false), 92 waiting_on_compositing_end_(false),
95 draw_on_compositing_end_(false), 93 draw_on_compositing_end_(false),
96 defer_draw_scheduling_(false), 94 defer_draw_scheduling_(false),
97 mouse_move_hold_count_(0), 95 mouse_move_hold_count_(0),
98 should_hold_mouse_moves_(false), 96 should_hold_mouse_moves_(false),
99 release_mouse_moves_after_draw_(false) { 97 release_mouse_moves_after_draw_(false) {
100 SetName("RootWindow"); 98 SetName("RootWindow");
101 last_mouse_location_ = host_->QueryMouseLocation(); 99 last_mouse_location_ = host_->QueryMouseLocation();
102 100
103 should_hold_mouse_moves_ = !CommandLine::ForCurrentProcess()->HasSwitch( 101 should_hold_mouse_moves_ = !CommandLine::ForCurrentProcess()->HasSwitch(
104 switches::kAuraDisableHoldMouseMoves); 102 switches::kAuraDisableHoldMouseMoves);
105 103
106 ui::Compositor::Initialize(false);
107 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget(), 104 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget(),
108 host_->GetBounds().size())); 105 host_->GetBounds().size()));
109 DCHECK(compositor_.get()); 106 DCHECK(compositor_.get());
110 compositor_->AddObserver(this); 107 compositor_->AddObserver(this);
111 Init(); 108 Init();
112 } 109 }
113 110
114 RootWindow::~RootWindow() { 111 RootWindow::~RootWindow() {
115 compositor_->RemoveObserver(this); 112 compositor_->RemoveObserver(this);
116 // Make sure to destroy the compositor before terminating so that state is 113 // Make sure to destroy the compositor before terminating so that state is
117 // cleared and we don't hit asserts. 114 // cleared and we don't hit asserts.
118 compositor_.reset(); 115 compositor_.reset();
119 116
120 // Tear down in reverse. Frees any references held by the host. 117 // Tear down in reverse. Frees any references held by the host.
121 host_.reset(NULL); 118 host_.reset(NULL);
122 119
123 // An observer may have been added by an animation on the RootWindow. 120 // An observer may have been added by an animation on the RootWindow.
124 layer()->GetAnimator()->RemoveObserver(this); 121 layer()->GetAnimator()->RemoveObserver(this);
125 ui::Compositor::Terminate();
126 if (instance_ == this)
127 instance_ = NULL;
128 } 122 }
129 123
130 void RootWindow::ShowRootWindow() { 124 void RootWindow::ShowRootWindow() {
131 host_->Show(); 125 host_->Show();
132 } 126 }
133 127
134 void RootWindow::SetHostSize(const gfx::Size& size) { 128 void RootWindow::SetHostSize(const gfx::Size& size) {
135 DispatchHeldMouseMove(); 129 DispatchHeldMouseMove();
136 gfx::Rect bounds = host_->GetBounds(); 130 gfx::Rect bounds = host_->GetBounds();
137 bounds.set_size(size); 131 bounds.set_size(size);
138 host_->SetBounds(bounds); 132 host_->SetBounds(bounds);
139 // Requery the location to constrain it within the new root window size. 133 // Requery the location to constrain it within the new root window size.
140 last_mouse_location_ = host_->QueryMouseLocation(); 134 last_mouse_location_ = host_->QueryMouseLocation();
141 synthesize_mouse_move_ = false; 135 synthesize_mouse_move_ = false;
142 } 136 }
143 137
144 gfx::Size RootWindow::GetHostSize() const { 138 gfx::Size RootWindow::GetHostSize() const {
145 gfx::Rect rect(host_->GetBounds().size()); 139 gfx::Rect rect(host_->GetBounds().size());
146 layer()->transform().TransformRect(&rect); 140 layer()->transform().TransformRect(&rect);
147 return rect.size(); 141 return rect.size();
148 } 142 }
149 143
144 void RootWindow::SetHostBounds(const gfx::Rect& bounds) {
145 DispatchHeldMouseMove();
146 host_->SetBounds(bounds);
147 // Requery the location to constrain it within the new root window size.
148 last_mouse_location_ = host_->QueryMouseLocation();
149 synthesize_mouse_move_ = false;
150 }
151
150 void RootWindow::SetCursor(gfx::NativeCursor cursor) { 152 void RootWindow::SetCursor(gfx::NativeCursor cursor) {
151 last_cursor_ = cursor; 153 last_cursor_ = cursor;
152 // A lot of code seems to depend on NULL cursors actually showing an arrow, 154 // A lot of code seems to depend on NULL cursors actually showing an arrow,
153 // so just pass everything along to the host. 155 // so just pass everything along to the host.
154 host_->SetCursor(cursor); 156 host_->SetCursor(cursor);
155 } 157 }
156 158
157 void RootWindow::ShowCursor(bool show) { 159 void RootWindow::ShowCursor(bool show) {
158 cursor_shown_ = show; 160 cursor_shown_ = show;
159 host_->ShowCursor(show); 161 host_->ShowCursor(show);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 } 432 }
431 } 433 }
432 434
433 //////////////////////////////////////////////////////////////////////////////// 435 ////////////////////////////////////////////////////////////////////////////////
434 // RootWindow, Window overrides: 436 // RootWindow, Window overrides:
435 437
436 RootWindow* RootWindow::GetRootWindow() { 438 RootWindow* RootWindow::GetRootWindow() {
437 return this; 439 return this;
438 } 440 }
439 441
442 const RootWindow* RootWindow::GetRootWindow() const {
443 return this;
444 }
445
440 void RootWindow::SetTransform(const ui::Transform& transform) { 446 void RootWindow::SetTransform(const ui::Transform& transform) {
441 Window::SetTransform(transform); 447 Window::SetTransform(transform);
442 448
443 // If the layer is not animating, then we need to update the host size 449 // If the layer is not animating, then we need to update the host size
444 // immediately. 450 // immediately.
445 if (!layer()->GetAnimator()->is_animating()) 451 if (!layer()->GetAnimator()->is_animating())
446 OnHostResized(host_->GetBounds().size()); 452 OnHostResized(host_->GetBounds().size());
447 } 453 }
448 454
449 //////////////////////////////////////////////////////////////////////////////// 455 ////////////////////////////////////////////////////////////////////////////////
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 void RootWindow::DispatchHeldMouseMove() { 833 void RootWindow::DispatchHeldMouseMove() {
828 if (held_mouse_move_.get()) { 834 if (held_mouse_move_.get()) {
829 // If a mouse move has been synthesized, the target location is suspect, 835 // If a mouse move has been synthesized, the target location is suspect,
830 // so drop the held event. 836 // so drop the held event.
831 if (!synthesize_mouse_move_) 837 if (!synthesize_mouse_move_)
832 DispatchMouseEventImpl(held_mouse_move_.get()); 838 DispatchMouseEventImpl(held_mouse_move_.get());
833 held_mouse_move_.reset(); 839 held_mouse_move_.reset();
834 } 840 }
835 } 841 }
836 842
837 gfx::Rect RootWindow::GetInitialHostWindowBounds() const {
838 return Env::GetInstance()->monitor_manager()->
839 GetMonitorNearestWindow(this)->bounds();
840 }
841
842 void RootWindow::PostMouseMoveEventAfterWindowChange() { 843 void RootWindow::PostMouseMoveEventAfterWindowChange() {
843 if (synthesize_mouse_move_) 844 if (synthesize_mouse_move_)
844 return; 845 return;
845 synthesize_mouse_move_ = true; 846 synthesize_mouse_move_ = true;
846 MessageLoop::current()->PostTask( 847 MessageLoop::current()->PostTask(
847 FROM_HERE, 848 FROM_HERE,
848 base::Bind(&RootWindow::SynthesizeMouseMoveEvent, 849 base::Bind(&RootWindow::SynthesizeMouseMoveEvent,
849 event_factory_.GetWeakPtr())); 850 event_factory_.GetWeakPtr()));
850 } 851 }
851 852
(...skipping 10 matching lines...) Expand all
862 // is currently broken. See/ crbug.com/107931. 863 // is currently broken. See/ crbug.com/107931.
863 MouseEvent event(ui::ET_MOUSE_MOVED, 864 MouseEvent event(ui::ET_MOUSE_MOVED,
864 orig_mouse_location, 865 orig_mouse_location,
865 orig_mouse_location, 866 orig_mouse_location,
866 ui::EF_IS_SYNTHESIZED); 867 ui::EF_IS_SYNTHESIZED);
867 DispatchMouseEvent(&event); 868 DispatchMouseEvent(&event);
868 #endif 869 #endif
869 } 870 }
870 871
871 } // namespace aura 872 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/single_monitor_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698