| OLD | NEW |
| 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 Loading... |
| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point)); | 237 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point)); |
| 240 | 238 |
| 241 synthesize_mouse_move_ = false; | 239 synthesize_mouse_move_ = false; |
| 242 } | 240 } |
| 243 | 241 |
| 244 gfx::Point RootWindow::GetHostOrigin() const { | 242 gfx::Point RootWindow::GetHostOrigin() const { |
| 245 return host_->GetBounds().origin(); | 243 return host_->GetBounds().origin(); |
| 246 } | 244 } |
| 247 | 245 |
| 248 void RootWindow::SetCursor(gfx::NativeCursor cursor) { | 246 void RootWindow::SetCursor(gfx::NativeCursor cursor) { |
| 249 // If a drag is in progress, the DragDropClient should override the cursor. | |
| 250 client::DragDropClient* dnd_client = client::GetDragDropClient(this); | |
| 251 if (dnd_client && dnd_client->IsDragDropInProgress()) | |
| 252 cursor = dnd_client->GetDragCursor(); | |
| 253 | |
| 254 last_cursor_ = cursor; | 247 last_cursor_ = cursor; |
| 255 // A lot of code seems to depend on NULL cursors actually showing an arrow, | 248 // A lot of code seems to depend on NULL cursors actually showing an arrow, |
| 256 // so just pass everything along to the host. | 249 // so just pass everything along to the host. |
| 257 host_->SetCursor(cursor); | 250 host_->SetCursor(cursor); |
| 258 } | 251 } |
| 259 | 252 |
| 260 void RootWindow::ShowCursor(bool show) { | 253 void RootWindow::ShowCursor(bool show) { |
| 261 // Send entered / exited so that visual state can be updated to match | 254 // Send entered / exited so that visual state can be updated to match |
| 262 // cursor state. | 255 // cursor state. |
| 263 if (show != cursor_shown_) { | 256 if (show != cursor_shown_) { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } | 515 } |
| 523 | 516 |
| 524 void RootWindow::OnCompositingAborted(ui::Compositor*) { | 517 void RootWindow::OnCompositingAborted(ui::Compositor*) { |
| 525 } | 518 } |
| 526 | 519 |
| 527 //////////////////////////////////////////////////////////////////////////////// | 520 //////////////////////////////////////////////////////////////////////////////// |
| 528 // RootWindow, ui::LayerDelegate implementation: | 521 // RootWindow, ui::LayerDelegate implementation: |
| 529 | 522 |
| 530 void RootWindow::OnDeviceScaleFactorChanged( | 523 void RootWindow::OnDeviceScaleFactorChanged( |
| 531 float device_scale_factor) { | 524 float device_scale_factor) { |
| 532 if (cursor_shown_) | 525 const bool cursor_is_in_bounds = |
| 526 GetBoundsInScreen().Contains(Env::GetInstance()->last_mouse_location()); |
| 527 if (cursor_is_in_bounds && cursor_shown_) |
| 533 ShowCursor(false); | 528 ShowCursor(false); |
| 534 host_->OnDeviceScaleFactorChanged(device_scale_factor); | 529 host_->OnDeviceScaleFactorChanged(device_scale_factor); |
| 535 Window::OnDeviceScaleFactorChanged(device_scale_factor); | 530 Window::OnDeviceScaleFactorChanged(device_scale_factor); |
| 536 if (cursor_shown_) | 531 // Update the device scale factor of the cursor client only when the last |
| 532 // mouse location is on this root window. |
| 533 if (cursor_is_in_bounds) { |
| 534 client::CursorClient* cursor_client = client::GetCursorClient(this); |
| 535 if (cursor_client) |
| 536 cursor_client->SetDeviceScaleFactor(device_scale_factor); |
| 537 } |
| 538 if (cursor_is_in_bounds && cursor_shown_) |
| 537 ShowCursor(true); | 539 ShowCursor(true); |
| 538 } | 540 } |
| 539 | 541 |
| 540 //////////////////////////////////////////////////////////////////////////////// | 542 //////////////////////////////////////////////////////////////////////////////// |
| 541 // RootWindow, overridden from aura::Window: | 543 // RootWindow, overridden from aura::Window: |
| 542 | 544 |
| 543 bool RootWindow::CanFocus() const { | 545 bool RootWindow::CanFocus() const { |
| 544 return IsVisible(); | 546 return IsVisible(); |
| 545 } | 547 } |
| 546 | 548 |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 void RootWindow::UnlockCompositor() { | 1095 void RootWindow::UnlockCompositor() { |
| 1094 DCHECK(compositor_lock_); | 1096 DCHECK(compositor_lock_); |
| 1095 compositor_lock_ = NULL; | 1097 compositor_lock_ = NULL; |
| 1096 if (draw_on_compositor_unlock_) { | 1098 if (draw_on_compositor_unlock_) { |
| 1097 draw_on_compositor_unlock_ = false; | 1099 draw_on_compositor_unlock_ = false; |
| 1098 ScheduleDraw(); | 1100 ScheduleDraw(); |
| 1099 } | 1101 } |
| 1100 } | 1102 } |
| 1101 | 1103 |
| 1102 } // namespace aura | 1104 } // namespace aura |
| OLD | NEW |