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

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: address comments 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
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 179 }
172 180
173 void RootWindow::SetHostSize(const gfx::Size& size_in_pixel) { 181 void RootWindow::SetHostSize(const gfx::Size& size_in_pixel) {
174 DispatchHeldMouseMove(); 182 DispatchHeldMouseMove();
175 gfx::Rect bounds = host_->GetBounds(); 183 gfx::Rect bounds = host_->GetBounds();
176 bounds.set_size(size_in_pixel); 184 bounds.set_size(size_in_pixel);
177 host_->SetBounds(bounds); 185 host_->SetBounds(bounds);
178 186
179 // Requery the location to constrain it within the new root window size. 187 // Requery the location to constrain it within the new root window size.
180 gfx::Point point; 188 gfx::Point point;
181 if (host_->QueryMouseLocation(&point)) 189 if (host_->QueryMouseLocation(&point))
oshima 2012/12/06 18:55:46 I think QueryMouseLocation needs to fail if the mo
mazda 2012/12/07 20:50:51 Done. In order to get the cursor enabled state in
182 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point)); 190 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point));
183 191
184 synthesize_mouse_move_ = false; 192 synthesize_mouse_move_ = false;
185 } 193 }
186 194
187 gfx::Size RootWindow::GetHostSize() const { 195 gfx::Size RootWindow::GetHostSize() const {
188 return host_->GetBounds().size(); 196 return host_->GetBounds().size();
189 } 197 }
190 198
191 void RootWindow::SetHostBounds(const gfx::Rect& bounds_in_pixel) { 199 void RootWindow::SetHostBounds(const gfx::Rect& bounds_in_pixel) {
192 DispatchHeldMouseMove(); 200 DispatchHeldMouseMove();
193 host_->SetBounds(bounds_in_pixel); 201 host_->SetBounds(bounds_in_pixel);
194 synthesize_mouse_move_ = false; 202 synthesize_mouse_move_ = false;
195 } 203 }
196 204
197 gfx::Point RootWindow::GetHostOrigin() const { 205 gfx::Point RootWindow::GetHostOrigin() const {
198 return host_->GetBounds().origin(); 206 return host_->GetBounds().origin();
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::OnCursorEnableStateChanged(bool enabled) {
209 // Send entered / exited so that visual state can be updated to match 217 // Send entered / exited so that visual state can be updated to match
210 // cursor state. 218 // cursor state.
211 Env::GetInstance()->SetCursorShown(show);
212 PostMouseMoveEventAfterWindowChange(); 219 PostMouseMoveEventAfterWindowChange();
213 } 220 }
214 221
215 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { 222 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) {
216 gfx::Point location = location_in_dip; 223 gfx::Point location = location_in_dip;
217 layer()->transform().TransformPoint(location); 224 layer()->transform().TransformPoint(location);
218 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location)); 225 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location));
219 SetLastMouseLocation(this, location_in_dip); 226 SetLastMouseLocation(this, location_in_dip);
220 client::CursorClient* cursor_client = client::GetCursorClient(this); 227 client::CursorClient* cursor_client = client::GetCursorClient(this);
221 if (cursor_client) 228 if (cursor_client)
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 ui::MouseEvent event(ui::ET_MOUSE_MOVED, 1045 ui::MouseEvent event(ui::ET_MOUSE_MOVED,
1039 orig_mouse_location, 1046 orig_mouse_location,
1040 orig_mouse_location, 1047 orig_mouse_location,
1041 ui::EF_IS_SYNTHESIZED); 1048 ui::EF_IS_SYNTHESIZED);
1042 event.set_system_location(Env::GetInstance()->last_mouse_location()); 1049 event.set_system_location(Env::GetInstance()->last_mouse_location());
1043 OnHostMouseEvent(&event); 1050 OnHostMouseEvent(&event);
1044 #endif 1051 #endif
1045 } 1052 }
1046 1053
1047 } // namespace aura 1054 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698