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

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

Issue 10919135: Move ash specific cursor code to CursorManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests and rebase Created 8 years, 3 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
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/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "ui/aura/aura_switches.h" 15 #include "ui/aura/aura_switches.h"
16 #include "ui/aura/client/activation_client.h" 16 #include "ui/aura/client/activation_client.h"
17 #include "ui/aura/client/capture_client.h" 17 #include "ui/aura/client/capture_client.h"
18 #include "ui/aura/client/drag_drop_client.h" 18 #include "ui/aura/client/cursor_client.h"
19 #include "ui/aura/client/event_client.h" 19 #include "ui/aura/client/event_client.h"
20 #include "ui/aura/client/screen_position_client.h" 20 #include "ui/aura/client/screen_position_client.h"
21 #include "ui/aura/display_manager.h" 21 #include "ui/aura/display_manager.h"
22 #include "ui/aura/env.h" 22 #include "ui/aura/env.h"
23 #include "ui/aura/event_filter.h" 23 #include "ui/aura/event_filter.h"
24 #include "ui/aura/focus_manager.h" 24 #include "ui/aura/focus_manager.h"
25 #include "ui/aura/root_window_host.h" 25 #include "ui/aura/root_window_host.h"
26 #include "ui/aura/root_window_observer.h" 26 #include "ui/aura/root_window_observer.h"
27 #include "ui/aura/window.h" 27 #include "ui/aura/window.h"
28 #include "ui/aura/window_delegate.h" 28 #include "ui/aura/window_delegate.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 CancelLock(); 103 CancelLock();
104 } 104 }
105 105
106 void CompositorLock::CancelLock() { 106 void CompositorLock::CancelLock() {
107 if (!root_window_) 107 if (!root_window_)
108 return; 108 return;
109 root_window_->UnlockCompositor(); 109 root_window_->UnlockCompositor();
110 root_window_ = NULL; 110 root_window_ = NULL;
111 } 111 }
112 112
113 bool RootWindow::hide_host_cursor_ = false;
114
115 RootWindow::CreateParams::CreateParams(const gfx::Rect& a_initial_bounds) 113 RootWindow::CreateParams::CreateParams(const gfx::Rect& a_initial_bounds)
116 : initial_bounds(a_initial_bounds), 114 : initial_bounds(a_initial_bounds),
117 host(NULL) { 115 host(NULL) {
118 } 116 }
119 117
120 //////////////////////////////////////////////////////////////////////////////// 118 ////////////////////////////////////////////////////////////////////////////////
121 // RootWindow, public: 119 // RootWindow, public:
122 120
123 RootWindow::RootWindow(const CreateParams& params) 121 RootWindow::RootWindow(const CreateParams& params)
124 : Window(NULL), 122 : Window(NULL),
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point)); 231 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point));
234 232
235 synthesize_mouse_move_ = false; 233 synthesize_mouse_move_ = false;
236 } 234 }
237 235
238 gfx::Point RootWindow::GetHostOrigin() const { 236 gfx::Point RootWindow::GetHostOrigin() const {
239 return host_->GetBounds().origin(); 237 return host_->GetBounds().origin();
240 } 238 }
241 239
242 void RootWindow::SetCursor(gfx::NativeCursor cursor) { 240 void RootWindow::SetCursor(gfx::NativeCursor cursor) {
243 // If a drag is in progress, the DragDropClient should override the cursor.
244 client::DragDropClient* dnd_client = client::GetDragDropClient(this);
245 if (dnd_client && dnd_client->IsDragDropInProgress())
246 cursor = dnd_client->GetDragCursor();
247
248 last_cursor_ = cursor; 241 last_cursor_ = cursor;
249 // A lot of code seems to depend on NULL cursors actually showing an arrow, 242 // A lot of code seems to depend on NULL cursors actually showing an arrow,
250 // so just pass everything along to the host. 243 // so just pass everything along to the host.
251 host_->SetCursor(cursor); 244 host_->SetCursor(cursor);
252 } 245 }
253 246
254 void RootWindow::ShowCursor(bool show) { 247 void RootWindow::ShowCursor(bool show) {
255 // Send entered / exited so that visual state can be updated to match 248 // Send entered / exited so that visual state can be updated to match
256 // cursor state. 249 // cursor state.
257 if (show != cursor_shown_) { 250 if (show != cursor_shown_) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 } 509 }
517 510
518 void RootWindow::OnCompositingAborted(ui::Compositor*) { 511 void RootWindow::OnCompositingAborted(ui::Compositor*) {
519 } 512 }
520 513
521 //////////////////////////////////////////////////////////////////////////////// 514 ////////////////////////////////////////////////////////////////////////////////
522 // RootWindow, ui::LayerDelegate implementation: 515 // RootWindow, ui::LayerDelegate implementation:
523 516
524 void RootWindow::OnDeviceScaleFactorChanged( 517 void RootWindow::OnDeviceScaleFactorChanged(
525 float device_scale_factor) { 518 float device_scale_factor) {
526 if (cursor_shown_) 519 const bool cursor_is_in_bounds =
520 GetBoundsInScreen().Contains(Env::GetInstance()->last_mouse_location());
521 if (cursor_is_in_bounds && cursor_shown_)
527 ShowCursor(false); 522 ShowCursor(false);
528 host_->OnDeviceScaleFactorChanged(device_scale_factor); 523 host_->OnDeviceScaleFactorChanged(device_scale_factor);
529 Window::OnDeviceScaleFactorChanged(device_scale_factor); 524 Window::OnDeviceScaleFactorChanged(device_scale_factor);
530 if (cursor_shown_) 525 // Update the device scale factor of the cursor client only when the last
526 // mouse location is on this root window.
527 if (cursor_is_in_bounds) {
528 client::CursorClient* cursor_client = client::GetCursorClient(this);
529 if (cursor_client)
530 cursor_client->SetDeviceScaleFactor(device_scale_factor);
531 }
532 if (cursor_is_in_bounds && cursor_shown_)
531 ShowCursor(true); 533 ShowCursor(true);
532 } 534 }
533 535
534 //////////////////////////////////////////////////////////////////////////////// 536 ////////////////////////////////////////////////////////////////////////////////
535 // RootWindow, overridden from aura::Window: 537 // RootWindow, overridden from aura::Window:
536 538
537 bool RootWindow::CanFocus() const { 539 bool RootWindow::CanFocus() const {
538 return IsVisible(); 540 return IsVisible();
539 } 541 }
540 542
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 void RootWindow::UnlockCompositor() { 1089 void RootWindow::UnlockCompositor() {
1088 DCHECK(compositor_lock_); 1090 DCHECK(compositor_lock_);
1089 compositor_lock_ = NULL; 1091 compositor_lock_ = NULL;
1090 if (draw_on_compositor_unlock_) { 1092 if (draw_on_compositor_unlock_) {
1091 draw_on_compositor_unlock_ = false; 1093 draw_on_compositor_unlock_ = false;
1092 ScheduleDraw(); 1094 ScheduleDraw();
1093 } 1095 }
1094 } 1096 }
1095 1097
1096 } // namespace aura 1098 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698