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

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

Issue 11412315: Make the cursor have separate mode for disabled mouse events and invisible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win_aura Created 8 years 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/root_window_host.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/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 float GetDeviceScaleFactorFromDisplay(Window* window) { 61 float GetDeviceScaleFactorFromDisplay(Window* window) {
62 return gfx::Screen::GetScreenFor(window)-> 62 return gfx::Screen::GetScreenFor(window)->
63 GetDisplayNearestWindow(window).device_scale_factor(); 63 GetDisplayNearestWindow(window).device_scale_factor();
64 } 64 }
65 65
66 Window* ConsumerToWindow(ui::GestureConsumer* consumer) { 66 Window* ConsumerToWindow(ui::GestureConsumer* consumer) {
67 return consumer && !consumer->ignores_events() ? 67 return consumer && !consumer->ignores_events() ?
68 static_cast<Window*>(consumer) : NULL; 68 static_cast<Window*>(consumer) : NULL;
69 } 69 }
70 70
71 void SetLastMouseLocation(const Window* root_window, 71 void SetLastMouseLocation(const RootWindow* root_window,
72 const gfx::Point& location) { 72 const gfx::Point& location_in_root) {
73 Env::GetInstance()->SetLastMouseLocation(*root_window, location); 73 client::ScreenPositionClient* client =
74 client::GetScreenPositionClient(root_window);
75 if (client) {
76 gfx::Point location_in_screen = location_in_root;
77 client->ConvertPointToScreen(root_window, &location_in_screen);
78 Env::GetInstance()->set_last_mouse_location(location_in_screen);
79 } else {
80 Env::GetInstance()->set_last_mouse_location(location_in_root);
81 }
74 } 82 }
75 83
76 RootWindowHost* CreateHost(RootWindow* root_window, 84 RootWindowHost* CreateHost(RootWindow* root_window,
77 const RootWindow::CreateParams& params) { 85 const RootWindow::CreateParams& params) {
78 RootWindowHost* host = params.host ? 86 RootWindowHost* host = params.host ?
79 params.host : RootWindowHost::Create(params.initial_bounds); 87 params.host : RootWindowHost::Create(params.initial_bounds);
80 host->SetDelegate(root_window); 88 host->SetDelegate(root_window);
81 return host; 89 return host;
82 } 90 }
83 91
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 207 }
200 208
201 void RootWindow::SetCursor(gfx::NativeCursor cursor) { 209 void RootWindow::SetCursor(gfx::NativeCursor cursor) {
202 last_cursor_ = cursor; 210 last_cursor_ = cursor;
203 // A lot of code seems to depend on NULL cursors actually showing an arrow, 211 // A lot of code seems to depend on NULL cursors actually showing an arrow,
204 // so just pass everything along to the host. 212 // so just pass everything along to the host.
205 host_->SetCursor(cursor); 213 host_->SetCursor(cursor);
206 } 214 }
207 215
208 void RootWindow::OnCursorVisibilityChanged(bool show) { 216 void RootWindow::OnCursorVisibilityChanged(bool show) {
209 // Send entered / exited so that visual state can be updated to match
210 // cursor state.
211 Env::GetInstance()->SetCursorShown(show);
212 PostMouseMoveEventAfterWindowChange();
213 host_->OnCursorVisibilityChanged(show); 217 host_->OnCursorVisibilityChanged(show);
214 } 218 }
215 219
220 void RootWindow::OnMouseEventsEnableStateChanged(bool enabled) {
221 // Send entered / exited so that visual state can be updated to match
222 // mouse events state.
223 PostMouseMoveEventAfterWindowChange();
224 // TODO(mazda): Add code to disable mouse events when |enabled| == false.
225 }
226
216 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { 227 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) {
217 gfx::Point location = location_in_dip; 228 gfx::Point location = location_in_dip;
218 layer()->transform().TransformPoint(location); 229 layer()->transform().TransformPoint(location);
219 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location)); 230 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location));
220 SetLastMouseLocation(this, location_in_dip); 231 SetLastMouseLocation(this, location_in_dip);
221 client::CursorClient* cursor_client = client::GetCursorClient(this); 232 client::CursorClient* cursor_client = client::GetCursorClient(this);
222 if (cursor_client) 233 if (cursor_client)
223 cursor_client->SetDeviceScaleFactor(GetDeviceScaleFactor()); 234 cursor_client->SetDeviceScaleFactor(GetDeviceScaleFactor());
224 } 235 }
225 236
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 502
492 void RootWindow::OnDeviceScaleFactorChanged( 503 void RootWindow::OnDeviceScaleFactorChanged(
493 float device_scale_factor) { 504 float device_scale_factor) {
494 const bool cursor_is_in_bounds = 505 const bool cursor_is_in_bounds =
495 GetBoundsInScreen().Contains(Env::GetInstance()->last_mouse_location()); 506 GetBoundsInScreen().Contains(Env::GetInstance()->last_mouse_location());
496 bool cursor_visible = false; 507 bool cursor_visible = false;
497 client::CursorClient* cursor_client = client::GetCursorClient(this); 508 client::CursorClient* cursor_client = client::GetCursorClient(this);
498 if (cursor_is_in_bounds && cursor_client) { 509 if (cursor_is_in_bounds && cursor_client) {
499 cursor_visible = cursor_client->IsCursorVisible(); 510 cursor_visible = cursor_client->IsCursorVisible();
500 if (cursor_visible) 511 if (cursor_visible)
501 cursor_client->ShowCursor(false); 512 cursor_client->HideCursor();
502 } 513 }
503 host_->OnDeviceScaleFactorChanged(device_scale_factor); 514 host_->OnDeviceScaleFactorChanged(device_scale_factor);
504 Window::OnDeviceScaleFactorChanged(device_scale_factor); 515 Window::OnDeviceScaleFactorChanged(device_scale_factor);
505 // Update the device scale factor of the cursor client only when the last 516 // Update the device scale factor of the cursor client only when the last
506 // mouse location is on this root window. 517 // mouse location is on this root window.
507 if (cursor_is_in_bounds) { 518 if (cursor_is_in_bounds) {
508 if (cursor_client) 519 if (cursor_client)
509 cursor_client->SetDeviceScaleFactor(device_scale_factor); 520 cursor_client->SetDeviceScaleFactor(device_scale_factor);
510 } 521 }
511 if (cursor_is_in_bounds && cursor_client && cursor_visible) 522 if (cursor_is_in_bounds && cursor_client && cursor_visible)
512 cursor_client->ShowCursor(true); 523 cursor_client->ShowCursor();
513 } 524 }
514 525
515 //////////////////////////////////////////////////////////////////////////////// 526 ////////////////////////////////////////////////////////////////////////////////
516 // RootWindow, overridden from aura::Window: 527 // RootWindow, overridden from aura::Window:
517 528
518 bool RootWindow::CanFocus() const { 529 bool RootWindow::CanFocus() const {
519 return IsVisible(); 530 return IsVisible();
520 } 531 }
521 532
522 bool RootWindow::CanReceiveEvents() const { 533 bool RootWindow::CanReceiveEvents() const {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 572 }
562 573
563 void RootWindow::SetNativeCapture() { 574 void RootWindow::SetNativeCapture() {
564 host_->SetCapture(); 575 host_->SetCapture();
565 } 576 }
566 577
567 void RootWindow::ReleaseNativeCapture() { 578 void RootWindow::ReleaseNativeCapture() {
568 host_->ReleaseCapture(); 579 host_->ReleaseCapture();
569 } 580 }
570 581
571 gfx::Point RootWindow::QueryMouseLocationForTest() const { 582 bool RootWindow::QueryMouseLocationForTest(gfx::Point* point) const {
572 gfx::Point point; 583 return host_->QueryMouseLocation(point);
573 host_->QueryMouseLocation(&point);
574 return point;
575 } 584 }
576 585
577 //////////////////////////////////////////////////////////////////////////////// 586 ////////////////////////////////////////////////////////////////////////////////
578 // RootWindow, private: 587 // RootWindow, private:
579 588
580 void RootWindow::TransformEventForDeviceScaleFactor(ui::LocatedEvent* event) { 589 void RootWindow::TransformEventForDeviceScaleFactor(ui::LocatedEvent* event) {
581 float scale = ui::GetDeviceScaleFactor(layer()); 590 float scale = ui::GetDeviceScaleFactor(layer());
582 gfx::Transform transform; 591 gfx::Transform transform;
583 transform.Scale(scale, scale); 592 transform.Scale(scale, scale);
584 transform *= layer()->transform(); 593 transform *= layer()->transform();
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 ui::MouseEvent event(ui::ET_MOUSE_MOVED, 997 ui::MouseEvent event(ui::ET_MOUSE_MOVED,
989 orig_mouse_location, 998 orig_mouse_location,
990 orig_mouse_location, 999 orig_mouse_location,
991 ui::EF_IS_SYNTHESIZED); 1000 ui::EF_IS_SYNTHESIZED);
992 event.set_system_location(Env::GetInstance()->last_mouse_location()); 1001 event.set_system_location(Env::GetInstance()->last_mouse_location());
993 OnHostMouseEvent(&event); 1002 OnHostMouseEvent(&event);
994 #endif 1003 #endif
995 } 1004 }
996 1005
997 } // namespace aura 1006 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/root_window_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698