diff options
author | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-17 21:53:12 +0000 |
---|---|---|
committer | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-17 21:53:12 +0000 |
commit | 5922cb23df5b69ece5fb4a022521a591cad21cf4 (patch) | |
tree | 15a5b67a1e93d377ab453f3f0c0706f6e7a5ea8c /ui/aura | |
parent | bc7bf1c4bb4d5807709c164e401a42855c153eb0 (diff) | |
download | chromium_src-5922cb23df5b69ece5fb4a022521a591cad21cf4.zip chromium_src-5922cb23df5b69ece5fb4a022521a591cad21cf4.tar.gz chromium_src-5922cb23df5b69ece5fb4a022521a591cad21cf4.tar.bz2 |
aura: Add method to the RootWindow to warp the mouse pointer.
BUG=102563
TEST=manually
Review URL: http://codereview.chromium.org/9179013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117967 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r-- | ui/aura/root_window.cc | 4 | ||||
-rw-r--r-- | ui/aura/root_window.h | 3 | ||||
-rw-r--r-- | ui/aura/root_window_host.h | 5 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.cc | 6 | ||||
-rw-r--r-- | ui/aura/root_window_host_win.cc | 6 | ||||
-rw-r--r-- | ui/aura/root_window_host_win.h | 3 |
6 files changed, 25 insertions, 2 deletions
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index c714b9b..6ce24d4 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -115,6 +115,10 @@ void RootWindow::ShowCursor(bool show) { host_->ShowCursor(show); } +void RootWindow::MoveCursorTo(const gfx::Point& location) { + host_->MoveCursorTo(location); +} + void RootWindow::Run() { ShowRootWindow(); MessageLoopForUI::current()->Run(); diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h index 030774ec9..b4dbd2e 100644 --- a/ui/aura/root_window.h +++ b/ui/aura/root_window.h @@ -77,6 +77,9 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, // Sets current cursor visibility to |show|. void ShowCursor(bool show); + // Moves the cursor to the specified location relative to the root window. + void MoveCursorTo(const gfx::Point& location); + // Shows the root window host and runs an event loop for it. void Run(); diff --git a/ui/aura/root_window_host.h b/ui/aura/root_window_host.h index 1c77565..83edcbd 100644 --- a/ui/aura/root_window_host.h +++ b/ui/aura/root_window_host.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -68,6 +68,9 @@ class RootWindowHost : public MessageLoop::Dispatcher { // method can be expensive. virtual gfx::Point QueryMouseLocation() = 0; + // Moves the cursor to the specified location relative to the root window. + virtual void MoveCursorTo(const gfx::Point& location) = 0; + // Posts |native_event| to the platform's event queue. virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0; }; diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc index 1556d90..8c3a7ec 100644 --- a/ui/aura/root_window_host_linux.cc +++ b/ui/aura/root_window_host_linux.cc @@ -296,6 +296,7 @@ class RootWindowHostLinux : public RootWindowHost, virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE; virtual void ShowCursor(bool show) OVERRIDE; virtual gfx::Point QueryMouseLocation() OVERRIDE; + virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; // MessageLoop::DestructionObserver Overrides. @@ -631,6 +632,11 @@ gfx::Point RootWindowHostLinux::QueryMouseLocation() { max(0, min(bounds_.height(), win_y_return))); } +void RootWindowHostLinux::MoveCursorTo(const gfx::Point& location) { + XWarpPointer(xdisplay_, None, xwindow_, 0, 0, 0, 0, location.x(), + location.y()); +} + void RootWindowHostLinux::PostNativeEvent( const base::NativeEvent& native_event) { DCHECK(xwindow_); diff --git a/ui/aura/root_window_host_win.cc b/ui/aura/root_window_host_win.cc index 0b8d28c..5e45760 100644 --- a/ui/aura/root_window_host_win.cc +++ b/ui/aura/root_window_host_win.cc @@ -236,6 +236,12 @@ gfx::Point RootWindowHostWin::QueryMouseLocation() { max(0, min(size.height(), static_cast<int>(pt.y)))); } +void RootWindowHostWin::MoveCursorTo(const gfx::Point& location) { + POINT pt; + ClientToScreen(hwnd(), &pt); + SetCursorPos(pt.x, pt.y); +} + void RootWindowHostWin::PostNativeEvent(const base::NativeEvent& native_event) { ::PostMessage( hwnd(), native_event.message, native_event.wParam, native_event.lParam); diff --git a/ui/aura/root_window_host_win.h b/ui/aura/root_window_host_win.h index ad9547f..239da9b 100644 --- a/ui/aura/root_window_host_win.h +++ b/ui/aura/root_window_host_win.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -31,6 +31,7 @@ class RootWindowHostWin : public RootWindowHost, public ui::WindowImpl { virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; virtual void ShowCursor(bool show) OVERRIDE; virtual gfx::Point QueryMouseLocation() OVERRIDE; + virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; private: |