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

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

Issue 18043004: Set CrOS touchpad Tap Paused property to false during initialization (Closed) Base URL: https://chromium.googlesource.com/chromium/src@git-svn
Patch Set: Move ifdefs inside the implementation Created 7 years, 5 months 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
« no previous file with comments | « ui/aura/root_window_host_x11.h ('k') | no next file » | 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_host_x11.h" 5 #include "ui/aura/root_window_host_x11.h"
6 6
7 #include <strings.h> 7 #include <strings.h>
8 #include <X11/cursorfont.h> 8 #include <X11/cursorfont.h>
9 #include <X11/extensions/Xfixes.h> 9 #include <X11/extensions/Xfixes.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[0]); 763 XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[0]);
764 XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[1]); 764 XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[1]);
765 XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[2]); 765 XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[2]);
766 XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[3]); 766 XFixesDestroyPointerBarrier(xdisplay_, pointer_barriers_[3]);
767 pointer_barriers_.reset(); 767 pointer_barriers_.reset();
768 } 768 }
769 #endif 769 #endif
770 } 770 }
771 771
772 void RootWindowHostX11::OnCursorVisibilityChanged(bool show) { 772 void RootWindowHostX11::OnCursorVisibilityChanged(bool show) {
773 #if defined(OS_CHROMEOS) 773 SetCrOSTapPaused(!show);
774 // Temporarily pause tap-to-click when the cursor is hidden.
775 Atom prop = atom_cache_.GetAtom("Tap Paused");
776 unsigned char value = !show;
777 XIDeviceList dev_list =
778 ui::DeviceListCacheX::GetInstance()->GetXI2DeviceList(xdisplay_);
779
780 // Only slave pointer devices could possibly have tap-paused property.
781 for (int i = 0; i < dev_list.count; i++) {
782 if (dev_list[i].use == XISlavePointer) {
783 Atom old_type;
784 int old_format;
785 unsigned long old_nvalues, bytes;
786 unsigned char* data;
787 int result = XIGetProperty(xdisplay_, dev_list[i].deviceid, prop, 0, 0,
788 False, AnyPropertyType, &old_type, &old_format,
789 &old_nvalues, &bytes, &data);
790 if (result != Success)
791 continue;
792 XFree(data);
793 XIChangeProperty(xdisplay_, dev_list[i].deviceid, prop, XA_INTEGER, 8,
794 PropModeReplace, &value, 1);
795 }
796 }
797 #endif
798 } 774 }
799 775
800 void RootWindowHostX11::MoveCursorTo(const gfx::Point& location) { 776 void RootWindowHostX11::MoveCursorTo(const gfx::Point& location) {
801 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0, 777 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0,
802 bounds_.x() + location.x(), 778 bounds_.x() + location.x(),
803 bounds_.y() + location.y()); 779 bounds_.y() + location.y());
804 } 780 }
805 781
806 void RootWindowHostX11::SetFocusWhenShown(bool focus_when_shown) { 782 void RootWindowHostX11::SetFocusWhenShown(bool focus_when_shown) {
807 static const char* k_NET_WM_USER_TIME = "_NET_WM_USER_TIME"; 783 static const char* k_NET_WM_USER_TIME = "_NET_WM_USER_TIME";
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 void RootWindowHostX11::OnRootWindowInitialized(RootWindow* root_window) { 878 void RootWindowHostX11::OnRootWindowInitialized(RootWindow* root_window) {
903 // UpdateIsInternalDisplay relies on: 879 // UpdateIsInternalDisplay relies on:
904 // 1. delegate_ pointing to RootWindow - available after SetDelegate. 880 // 1. delegate_ pointing to RootWindow - available after SetDelegate.
905 // 2. RootWindow's kDisplayIdKey property set - available by the time 881 // 2. RootWindow's kDisplayIdKey property set - available by the time
906 // RootWindow::Init is called. 882 // RootWindow::Init is called.
907 // (set in DisplayManager::CreateRootWindowForDisplay) 883 // (set in DisplayManager::CreateRootWindowForDisplay)
908 // Ready when NotifyRootWindowInitialized is called from RootWindow::Init. 884 // Ready when NotifyRootWindowInitialized is called from RootWindow::Init.
909 if (!delegate_ || root_window != GetRootWindow()) 885 if (!delegate_ || root_window != GetRootWindow())
910 return; 886 return;
911 UpdateIsInternalDisplay(); 887 UpdateIsInternalDisplay();
888
889 // We have to enable Tap-to-click by default because the cursor is set to
890 // visible in Shell::InitRootWindowController.
891 SetCrOSTapPaused(false);
912 } 892 }
913 893
914 bool RootWindowHostX11::DispatchEventForRootWindow( 894 bool RootWindowHostX11::DispatchEventForRootWindow(
915 const base::NativeEvent& event) { 895 const base::NativeEvent& event) {
916 switch (event->type) { 896 switch (event->type) {
917 case ConfigureNotify: 897 case ConfigureNotify:
918 DCHECK_EQ(x_root_window_, event->xconfigure.event); 898 DCHECK_EQ(x_root_window_, event->xconfigure.event);
919 x_root_bounds_.SetRect(event->xconfigure.x, event->xconfigure.y, 899 x_root_bounds_.SetRect(event->xconfigure.x, event->xconfigure.y,
920 event->xconfigure.width, event->xconfigure.height); 900 event->xconfigure.width, event->xconfigure.height);
921 break; 901 break;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 return image.Pass(); 1062 return image.Pass();
1083 } 1063 }
1084 1064
1085 void RootWindowHostX11::UpdateIsInternalDisplay() { 1065 void RootWindowHostX11::UpdateIsInternalDisplay() {
1086 RootWindow* root_window = GetRootWindow(); 1066 RootWindow* root_window = GetRootWindow();
1087 gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); 1067 gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window);
1088 gfx::Display display = screen->GetDisplayNearestWindow(root_window); 1068 gfx::Display display = screen->GetDisplayNearestWindow(root_window);
1089 is_internal_display_ = display.IsInternal(); 1069 is_internal_display_ = display.IsInternal();
1090 } 1070 }
1091 1071
1072 void RootWindowHostX11::SetCrOSTapPaused(bool state) {
1073 #if defined(OS_CHROMEOS)
1074 // Temporarily pause tap-to-click when the cursor is hidden.
1075 Atom prop = atom_cache_.GetAtom("Tap Paused");
1076 unsigned char value = state;
1077 XIDeviceList dev_list =
1078 ui::DeviceListCacheX::GetInstance()->GetXI2DeviceList(xdisplay_);
1079
1080 // Only slave pointer devices could possibly have tap-paused property.
1081 for (int i = 0; i < dev_list.count; i++) {
1082 if (dev_list[i].use == XISlavePointer) {
1083 Atom old_type;
1084 int old_format;
1085 unsigned long old_nvalues, bytes;
1086 unsigned char* data;
1087 int result = XIGetProperty(xdisplay_, dev_list[i].deviceid, prop, 0, 0,
1088 False, AnyPropertyType, &old_type, &old_format,
1089 &old_nvalues, &bytes, &data);
1090 if (result != Success)
1091 continue;
1092 XFree(data);
1093 XIChangeProperty(xdisplay_, dev_list[i].deviceid, prop, XA_INTEGER, 8,
1094 PropModeReplace, &value, 1);
1095 }
1096 }
1097 #endif
1098 }
1099
1092 // static 1100 // static
1093 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { 1101 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
1094 return new RootWindowHostX11(bounds); 1102 return new RootWindowHostX11(bounds);
1095 } 1103 }
1096 1104
1097 // static 1105 // static
1098 gfx::Size RootWindowHost::GetNativeScreenSize() { 1106 gfx::Size RootWindowHost::GetNativeScreenSize() {
1099 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); 1107 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay();
1100 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 1108 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
1101 } 1109 }
1102 1110
1103 namespace test { 1111 namespace test {
1104 1112
1105 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { 1113 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) {
1106 default_override_redirect = override_redirect; 1114 default_override_redirect = override_redirect;
1107 } 1115 }
1108 1116
1109 } // namespace test 1117 } // namespace test
1110 } // namespace aura 1118 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window_host_x11.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698