| 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" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // RootWindow, public: | 117 // RootWindow, public: |
| 118 | 118 |
| 119 RootWindow::RootWindow(const CreateParams& params) | 119 RootWindow::RootWindow(const CreateParams& params) |
| 120 : Window(NULL), | 120 : Window(NULL), |
| 121 ALLOW_THIS_IN_INITIALIZER_LIST(host_(CreateHost(this, params))), | 121 ALLOW_THIS_IN_INITIALIZER_LIST(host_(CreateHost(this, params))), |
| 122 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), | 122 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), |
| 123 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), | 123 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), |
| 124 mouse_button_flags_(0), | 124 mouse_button_flags_(0), |
| 125 touch_ids_down_(0), | 125 touch_ids_down_(0), |
| 126 last_cursor_(ui::kCursorNull), | 126 last_cursor_(ui::kCursorNull), |
| 127 // TODO(ivankr): this currently tracks the default state in | |
| 128 // RootWindowHostLinux. Other platforms do not implement ShowCursor(). | |
| 129 cursor_shown_(true), | |
| 130 mouse_pressed_handler_(NULL), | 127 mouse_pressed_handler_(NULL), |
| 131 mouse_moved_handler_(NULL), | 128 mouse_moved_handler_(NULL), |
| 132 mouse_event_dispatch_target_(NULL), | 129 mouse_event_dispatch_target_(NULL), |
| 133 event_dispatch_target_(NULL), | 130 event_dispatch_target_(NULL), |
| 134 focus_manager_(NULL), | 131 focus_manager_(NULL), |
| 135 ALLOW_THIS_IN_INITIALIZER_LIST( | 132 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 136 gesture_recognizer_(ui::GestureRecognizer::Create(this))), | 133 gesture_recognizer_(ui::GestureRecognizer::Create(this))), |
| 137 synthesize_mouse_move_(false), | 134 synthesize_mouse_move_(false), |
| 138 waiting_on_compositing_end_(false), | 135 waiting_on_compositing_end_(false), |
| 139 draw_on_compositing_end_(false), | 136 draw_on_compositing_end_(false), |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 return host_->GetBounds().origin(); | 239 return host_->GetBounds().origin(); |
| 243 } | 240 } |
| 244 | 241 |
| 245 void RootWindow::SetCursor(gfx::NativeCursor cursor) { | 242 void RootWindow::SetCursor(gfx::NativeCursor cursor) { |
| 246 last_cursor_ = cursor; | 243 last_cursor_ = cursor; |
| 247 // A lot of code seems to depend on NULL cursors actually showing an arrow, | 244 // A lot of code seems to depend on NULL cursors actually showing an arrow, |
| 248 // so just pass everything along to the host. | 245 // so just pass everything along to the host. |
| 249 host_->SetCursor(cursor); | 246 host_->SetCursor(cursor); |
| 250 } | 247 } |
| 251 | 248 |
| 252 void RootWindow::ShowCursor(bool show) { | 249 void RootWindow::OnCursorVisibilityChanged(bool show) { |
| 253 // Send entered / exited so that visual state can be updated to match | 250 // Send entered / exited so that visual state can be updated to match |
| 254 // cursor state. | 251 // cursor state. |
| 255 if (show != cursor_shown_) { | 252 Env::GetInstance()->SetCursorShown(show); |
| 256 cursor_shown_ = show; | 253 PostMouseMoveEventAfterWindowChange(); |
| 257 host_->ShowCursor(show); | |
| 258 Env::GetInstance()->SetCursorShown(show); | |
| 259 PostMouseMoveEventAfterWindowChange(); | |
| 260 } | |
| 261 } | 254 } |
| 262 | 255 |
| 263 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { | 256 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { |
| 264 gfx::Point location = location_in_dip; | 257 gfx::Point location = location_in_dip; |
| 265 layer()->transform().TransformPoint(location); | 258 layer()->transform().TransformPoint(location); |
| 266 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location)); | 259 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location)); |
| 267 SetLastMouseLocation(this, location_in_dip); | 260 SetLastMouseLocation(this, location_in_dip); |
| 268 } | 261 } |
| 269 | 262 |
| 270 bool RootWindow::ConfineCursorToWindow() { | 263 bool RootWindow::ConfineCursorToWindow() { |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 void RootWindow::OnCompositingAborted(ui::Compositor*) { | 516 void RootWindow::OnCompositingAborted(ui::Compositor*) { |
| 524 } | 517 } |
| 525 | 518 |
| 526 //////////////////////////////////////////////////////////////////////////////// | 519 //////////////////////////////////////////////////////////////////////////////// |
| 527 // RootWindow, ui::LayerDelegate implementation: | 520 // RootWindow, ui::LayerDelegate implementation: |
| 528 | 521 |
| 529 void RootWindow::OnDeviceScaleFactorChanged( | 522 void RootWindow::OnDeviceScaleFactorChanged( |
| 530 float device_scale_factor) { | 523 float device_scale_factor) { |
| 531 const bool cursor_is_in_bounds = | 524 const bool cursor_is_in_bounds = |
| 532 GetBoundsInScreen().Contains(Env::GetInstance()->last_mouse_location()); | 525 GetBoundsInScreen().Contains(Env::GetInstance()->last_mouse_location()); |
| 533 if (cursor_is_in_bounds && cursor_shown_) | 526 bool cursor_visible = false; |
| 534 ShowCursor(false); | 527 client::CursorClient* cursor_client = client::GetCursorClient(this); |
| 528 if (cursor_is_in_bounds && cursor_client) { |
| 529 cursor_visible = cursor_client->IsCursorVisible(); |
| 530 if (cursor_visible) |
| 531 cursor_client->ShowCursor(false); |
| 532 } |
| 535 host_->OnDeviceScaleFactorChanged(device_scale_factor); | 533 host_->OnDeviceScaleFactorChanged(device_scale_factor); |
| 536 Window::OnDeviceScaleFactorChanged(device_scale_factor); | 534 Window::OnDeviceScaleFactorChanged(device_scale_factor); |
| 537 // Update the device scale factor of the cursor client only when the last | 535 // Update the device scale factor of the cursor client only when the last |
| 538 // mouse location is on this root window. | 536 // mouse location is on this root window. |
| 539 if (cursor_is_in_bounds) { | 537 if (cursor_is_in_bounds) { |
| 540 client::CursorClient* cursor_client = client::GetCursorClient(this); | |
| 541 if (cursor_client) | 538 if (cursor_client) |
| 542 cursor_client->SetDeviceScaleFactor(device_scale_factor); | 539 cursor_client->SetDeviceScaleFactor(device_scale_factor); |
| 543 } | 540 } |
| 544 if (cursor_is_in_bounds && cursor_shown_) | 541 if (cursor_is_in_bounds && cursor_client && cursor_visible) |
| 545 ShowCursor(true); | 542 cursor_client->ShowCursor(true); |
| 546 } | 543 } |
| 547 | 544 |
| 548 //////////////////////////////////////////////////////////////////////////////// | 545 //////////////////////////////////////////////////////////////////////////////// |
| 549 // RootWindow, overridden from aura::Window: | 546 // RootWindow, overridden from aura::Window: |
| 550 | 547 |
| 551 bool RootWindow::CanFocus() const { | 548 bool RootWindow::CanFocus() const { |
| 552 return IsVisible(); | 549 return IsVisible(); |
| 553 } | 550 } |
| 554 | 551 |
| 555 bool RootWindow::CanReceiveEvents() const { | 552 bool RootWindow::CanReceiveEvents() const { |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 void RootWindow::UnlockCompositor() { | 1055 void RootWindow::UnlockCompositor() { |
| 1059 DCHECK(compositor_lock_); | 1056 DCHECK(compositor_lock_); |
| 1060 compositor_lock_ = NULL; | 1057 compositor_lock_ = NULL; |
| 1061 if (draw_on_compositor_unlock_) { | 1058 if (draw_on_compositor_unlock_) { |
| 1062 draw_on_compositor_unlock_ = false; | 1059 draw_on_compositor_unlock_ = false; |
| 1063 ScheduleDraw(); | 1060 ScheduleDraw(); |
| 1064 } | 1061 } |
| 1065 } | 1062 } |
| 1066 | 1063 |
| 1067 } // namespace aura | 1064 } // namespace aura |
| OLD | NEW |