From f434ff15ec9e9845b8e660344bdc4057cc591964 Mon Sep 17 00:00:00 2001 From: "sheckylin@chromium.org" Date: Tue, 2 Jul 2013 06:51:26 +0000 Subject: [PATCH] Set CrOS touchpad Tap Paused property to false during initialization On CrOS We turn on/off the touchpad Tap-to-click (TTC) feature based on the cursor (mouse pointer) visibility change events. Thus, the two things gets out-of-sync if someone changes the cursor without sending such an event. The CL fix such a leak where we directly set the mouse cursor when initializing the root window controller in Shell. Contributed by sheckylin@chromium.org BUG=252364,244656 TEST=Tested on device. Change-Id: I71152517cdbc8b65ebb0613c073f51550e7759f0 Review URL: https://chromiumcodereview.appspot.com/18043004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209628 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/aura/root_window_host_x11.cc | 58 +++++++++++++++++++++++------------------ ui/aura/root_window_host_x11.h | 4 +++ 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/ui/aura/root_window_host_x11.cc b/ui/aura/root_window_host_x11.cc index 49b6d62ade70..1a0fc5c4c818 100644 --- a/ui/aura/root_window_host_x11.cc +++ b/ui/aura/root_window_host_x11.cc @@ -770,31 +770,7 @@ void RootWindowHostX11::UnConfineCursor() { } void RootWindowHostX11::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 + SetCrOSTapPaused(!show); } void RootWindowHostX11::MoveCursorTo(const gfx::Point& location) { @@ -909,6 +885,10 @@ void RootWindowHostX11::OnRootWindowInitialized(RootWindow* root_window) { if (!delegate_ || root_window != GetRootWindow()) return; UpdateIsInternalDisplay(); + + // We have to enable Tap-to-click by default because the cursor is set to + // visible in Shell::InitRootWindowController. + SetCrOSTapPaused(false); } bool RootWindowHostX11::DispatchEventForRootWindow( @@ -1089,6 +1069,34 @@ void RootWindowHostX11::UpdateIsInternalDisplay() { is_internal_display_ = display.IsInternal(); } +void RootWindowHostX11::SetCrOSTapPaused(bool state) { +#if defined(OS_CHROMEOS) + // Temporarily pause tap-to-click when the cursor is hidden. + Atom prop = atom_cache_.GetAtom("Tap Paused"); + unsigned char value = state; + 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 +} + // static RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { return new RootWindowHostX11(bounds); diff --git a/ui/aura/root_window_host_x11.h b/ui/aura/root_window_host_x11.h index c2ad5d4024ee..9a4b37707aa9 100644 --- a/ui/aura/root_window_host_x11.h +++ b/ui/aura/root_window_host_x11.h @@ -103,6 +103,10 @@ class RootWindowHostX11 : public RootWindowHost, // Update is_internal_display_ based on delegate_ state void UpdateIsInternalDisplay(); + // Set the CrOS touchpad "tap paused" property. It is used to temporarily + // turn off the Tap-to-click feature when the mouse pointer is invisible. + void SetCrOSTapPaused(bool state); + RootWindowHostDelegate* delegate_; // The display and the native X window hosting the root window. -- 2.11.4.GIT