summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
authorsheckylin@chromium.org <sheckylin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-08 03:39:41 +0000
committersheckylin@chromium.org <sheckylin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-08 03:39:41 +0000
commit726f07569f1cce45d08367f7365c5be0693a849e (patch)
treea40c35044f6058dfbc666ad7c92c3390e6316104 /ui/aura
parentea9d8f2728ab88307a58b8bb5e7b690a55f75862 (diff)
downloadchromium_src-726f07569f1cce45d08367f7365c5be0693a849e.zip
chromium_src-726f07569f1cce45d08367f7365c5be0693a849e.tar.gz
chromium_src-726f07569f1cce45d08367f7365c5be0693a849e.tar.bz2
Handling cursor visibility changing events for ChromeOS
The CL does 4 things: 1. A handler in RootWindowHost that will be called whenever cursor visibility is changed. 2. Temporarily pause trackpad tap-to-click feature when the cursor is hidden. 3. Add a cache class that caches X input device lists to minimize round-trip time to X server for device list queries. 4. Refactor around the places where XListInputDevices/XIQueryDevice queries are used. Contributed by sheckylin@chromium.org BUG=chromium:156697,chrome-os-partner:14085 TEST=Tested on link. "Tap paused" was successfully set when visibility changed. Change-Id: Ia5c62f821c80efc973e3b1ce54a467b674b466a4 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=171223 Reverted: https://codereview.chromium.org/11454002/ Review URL: https://chromiumcodereview.appspot.com/11316074 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/remote_root_window_host_win.cc4
-rw-r--r--ui/aura/remote_root_window_host_win.h1
-rw-r--r--ui/aura/root_window.cc1
-rw-r--r--ui/aura/root_window_host.h3
-rw-r--r--ui/aura/root_window_host_linux.cc32
-rw-r--r--ui/aura/root_window_host_linux.h1
-rw-r--r--ui/aura/root_window_host_win.cc4
-rw-r--r--ui/aura/root_window_host_win.h1
8 files changed, 47 insertions, 0 deletions
diff --git a/ui/aura/remote_root_window_host_win.cc b/ui/aura/remote_root_window_host_win.cc
index e3a75ca..051cdcd 100644
--- a/ui/aura/remote_root_window_host_win.cc
+++ b/ui/aura/remote_root_window_host_win.cc
@@ -158,6 +158,10 @@ bool RemoteRootWindowHostWin::GrabSnapshot(
void RemoteRootWindowHostWin::UnConfineCursor() {
}
+void RemoteRootWindowHostWin::OnCursorVisibilityChanged(bool show) {
+ NOTIMPLEMENTED();
+}
+
void RemoteRootWindowHostWin::MoveCursorTo(const gfx::Point& location) {
}
diff --git a/ui/aura/remote_root_window_host_win.h b/ui/aura/remote_root_window_host_win.h
index 2c9ef0b..d790015 100644
--- a/ui/aura/remote_root_window_host_win.h
+++ b/ui/aura/remote_root_window_host_win.h
@@ -82,6 +82,7 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost {
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual bool ConfineCursorToRootWindow() OVERRIDE;
virtual void UnConfineCursor() OVERRIDE;
+ virtual void OnCursorVisibilityChanged(bool show) OVERRIDE;
virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE;
virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 5c6f48d..6e11156 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -210,6 +210,7 @@ void RootWindow::OnCursorVisibilityChanged(bool show) {
// cursor state.
Env::GetInstance()->SetCursorShown(show);
PostMouseMoveEventAfterWindowChange();
+ host_->OnCursorVisibilityChanged(show);
}
void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) {
diff --git a/ui/aura/root_window_host.h b/ui/aura/root_window_host.h
index 0766a6a..168f2d6 100644
--- a/ui/aura/root_window_host.h
+++ b/ui/aura/root_window_host.h
@@ -83,6 +83,9 @@ class AURA_EXPORT RootWindowHost {
virtual bool ConfineCursorToRootWindow() = 0;
virtual void UnConfineCursor() = 0;
+ // Called when the cursor visibility has changed.
+ virtual void OnCursorVisibilityChanged(bool show) = 0;
+
// Moves the cursor to the specified location relative to the root window.
virtual void MoveCursorTo(const gfx::Point& location) = 0;
diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc
index ce51c6d..d7d1be2 100644
--- a/ui/aura/root_window_host_linux.cc
+++ b/ui/aura/root_window_host_linux.cc
@@ -35,6 +35,7 @@
#include "ui/base/touch/touch_factory.h"
#include "ui/base/ui_base_switches.h"
#include "ui/base/view_prop.h"
+#include "ui/base/x/device_list_cache_x.h"
#include "ui/base/x/valuators.h"
#include "ui/base/x/x11_util.h"
#include "ui/compositor/dip_util.h"
@@ -70,6 +71,9 @@ const char* kAtomsToCache[] = {
"_NET_WM_PING",
"_NET_WM_PID",
"WM_S0",
+#if defined(OS_CHROMEOS)
+ "Tap Paused", // Defined in the gestures library.
+#endif
NULL
};
@@ -607,6 +611,34 @@ void RootWindowHostLinux::UnConfineCursor() {
#endif
}
+void RootWindowHostLinux::OnCursorVisibilityChanged(bool show) {
+#if defined(OS_CHROMEOS)
+ // Temporarily pause tap-to-click when the cursor is hidden.
+ Atom prop = atom_cache_.GetAtom("Tap Paused");
+ unsigned char value = !show;
+ XIDeviceList dev_list =
+ ui::DeviceListCacheX::GetInstance()->GetXI2DeviceList(xdisplay_);
+
+ // Only slave pointer devices could possibly have tap-paused property.
+ for (int i = 0; i < dev_list.count; i++) {
+ if (dev_list[i].use == XISlavePointer) {
+ Atom old_type;
+ int old_format;
+ unsigned long old_nvalues, bytes;
+ unsigned char* data;
+ int result = XIGetProperty(xdisplay_, dev_list[i].deviceid, prop, 0, 0,
+ False, AnyPropertyType, &old_type, &old_format,
+ &old_nvalues, &bytes, &data);
+ if (result != Success)
+ continue;
+ XFree(data);
+ XIChangeProperty(xdisplay_, dev_list[i].deviceid, prop, XA_INTEGER, 8,
+ PropModeReplace, &value, 1);
+ }
+ }
+#endif
+}
+
void RootWindowHostLinux::MoveCursorTo(const gfx::Point& location) {
XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0,
bounds_.x() + location.x(),
diff --git a/ui/aura/root_window_host_linux.h b/ui/aura/root_window_host_linux.h
index 220ec7f..7e52e1f 100644
--- a/ui/aura/root_window_host_linux.h
+++ b/ui/aura/root_window_host_linux.h
@@ -52,6 +52,7 @@ class RootWindowHostLinux : public RootWindowHost,
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual bool ConfineCursorToRootWindow() OVERRIDE;
virtual void UnConfineCursor() OVERRIDE;
+ virtual void OnCursorVisibilityChanged(bool show) OVERRIDE;
virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE;
virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
diff --git a/ui/aura/root_window_host_win.cc b/ui/aura/root_window_host_win.cc
index 20faae6..789072c 100644
--- a/ui/aura/root_window_host_win.cc
+++ b/ui/aura/root_window_host_win.cc
@@ -212,6 +212,10 @@ void RootWindowHostWin::UnConfineCursor() {
ClipCursor(NULL);
}
+void RootWindowHostWin::OnCursorVisibilityChanged(bool show) {
+ NOTIMPLEMENTED();
+}
+
void RootWindowHostWin::MoveCursorTo(const gfx::Point& location) {
// Deliberately not implemented.
}
diff --git a/ui/aura/root_window_host_win.h b/ui/aura/root_window_host_win.h
index 5b1a368..d5319ad 100644
--- a/ui/aura/root_window_host_win.h
+++ b/ui/aura/root_window_host_win.h
@@ -32,6 +32,7 @@ class RootWindowHostWin : public RootWindowHost, public ui::WindowImpl {
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual bool ConfineCursorToRootWindow() OVERRIDE;
virtual void UnConfineCursor() OVERRIDE;
+ virtual void OnCursorVisibilityChanged(bool show) OVERRIDE;
virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE;
virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,