Merge lp:~laney/unity-control-center/lp1132063 into lp:unity-control-center

Proposed by Iain Lane on 2014-10-08
Status: Work in progress
Proposed branch: lp:~laney/unity-control-center/lp1132063
Merge into: lp:unity-control-center
Diff against target: 94 lines (+44/-3)
1 file modified
panels/mouse/gsd-input-helper.c (+44/-3)
To merge this branch: bzr merge lp:~laney/unity-control-center/lp1132063
Reviewer Review Type Date Requested Status
Sebastien Bacher 2014-10-08 Needs Information on 2014-10-09
PS Jenkins bot (community) continuous-integration Approve on 2014-10-08
Review via email: mp+237636@code.launchpad.net

Commit message

Use XI2 to detect mice, in addition to the current XI method.

Description of the change

See the linked bug, there's problems detecting mice which means that the settings are sometimes hidden when they shouldn't be.

To post a comment you must log in.
Sebastien Bacher (seb128) wrote :

thanks, is that something upstream g-c-c is doing? if not should we upstream the change?

Sebastien Bacher (seb128) :
review: Needs Information
Iain Lane (laney) wrote :

On Thu, Oct 09, 2014 at 06:35:12AM -0000, Sebastien Bacher wrote:
> thanks, is that something upstream g-c-c is doing? if not should we upstream the change?

No, and yes probably, I wanted code review here first

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Sebastien Bacher (seb128) wrote :

The code by itself seems fine to me, I don't know enough xinput to have an opinion on whether that's the right way to check for the device/the most suited api. Not sure we have anyone in the team who does ... upstream might be better reviewer there?

Iain Lane (laney) wrote :

Ok

Iain Lane (laney) wrote :

If anyone has a non-multitouch trackpad, please check this. Mine has that and so I can't see if the mouse detection is buggy.

Sebastien Bacher (seb128) wrote :

iirc you started discussing that upstream, could you add the bugzilla reference here?

Iain Lane (laney) wrote :

https://bugzilla.gnome.org/show_bug.cgi?id=738220

On Fri, Dec 12, 2014 at 02:55:15PM -0000, Sebastien Bacher wrote:
> iirc you started discussing that upstream, could you add the bugzilla reference here?
> --
> https://code.launchpad.net/~laney/unity-control-center/lp1132063/+merge/237636
> You are the owner of lp:~laney/unity-control-center/lp1132063.
>

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Unmerged revisions

12792. By Iain Lane on 2014-10-08

mouse: Use XI2 to detect mice, in addition to the existing method

Sometimes, `xinput' reports output like the following

⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=9 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
    ↳ Power Button id=6 [slave keyboard (3)]
    ↳ Power Button id=7 [slave keyboard (3)]
    ↳ Logitech USB Receiver id=8 [slave keyboard (3)]

and g-c-c doesn't detect a mouse, which hides the settings.

We try to check for an XI2 XIMasterPointer device without an XITouchClass class
as a way of detcting mice-but-not-touchpads.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panels/mouse/gsd-input-helper.c'
2--- panels/mouse/gsd-input-helper.c 2012-08-20 17:33:28 +0000
3+++ panels/mouse/gsd-input-helper.c 2014-10-08 16:53:23 +0000
4@@ -33,6 +33,7 @@
5 #define KEY_HOTPLUG_COMMAND "hotplug-command"
6
7 typedef gboolean (* InfoIdentifyFunc) (XDeviceInfo *device_info);
8+typedef gboolean (* XI2IdentifyFunc) (XIDeviceInfo *device_info);
9 typedef gboolean (* DeviceIdentifyFunc) (XDevice *xdevice);
10
11 gboolean
12@@ -194,19 +195,57 @@
13 return (device_info->type == XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XI_MOUSE, False));
14 }
15
16+gboolean
17+xi_device_info_has_touch (XIDeviceInfo *xi_device_info)
18+{
19+ gboolean retval = FALSE;
20+ int i;
21+
22+ for (i = 0; i < xi_device_info->num_classes; i++)
23+ if (xi_device_info->classes[i]->type == XITouchClass) {
24+ retval = TRUE;
25+ break;
26+ }
27+
28+ return retval;
29+}
30+
31+gboolean
32+xi_device_info_is_mouse (XIDeviceInfo *xi_device_info)
33+{
34+ return (xi_device_info->use == XIMasterPointer &&
35+ !xi_device_info_has_touch(xi_device_info));
36+}
37+
38 static gboolean
39 device_type_is_present (InfoIdentifyFunc info_func,
40+ XI2IdentifyFunc xi2_info_func,
41 DeviceIdentifyFunc device_func)
42 {
43 XDeviceInfo *device_info;
44+ XIDeviceInfo *xi_device_info;
45 gint n_devices;
46 guint i;
47- gboolean retval;
48+ gboolean retval = FALSE;
49
50 if (supports_xinput_devices () == FALSE)
51 return TRUE;
52
53- retval = FALSE;
54+ if (xi2_info_func && supports_xinput2_devices(NULL)) {
55+ xi_device_info = XIQueryDevice(GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XIAllDevices,
56+ &n_devices);
57+
58+ for (i = 0; i < n_devices; i++) {
59+ retval = (xi2_info_func) (&xi_device_info[i]);
60+ if (retval)
61+ break;
62+ }
63+
64+ XIFreeDeviceInfo (xi_device_info);
65+
66+ if (retval)
67+ return retval;
68+ }
69
70 device_info = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &n_devices);
71 if (device_info == NULL)
72@@ -246,13 +285,14 @@
73 touchscreen_is_present (void)
74 {
75 return device_type_is_present (device_info_is_touchscreen,
76- NULL);
77+ NULL, NULL);
78 }
79
80 gboolean
81 touchpad_is_present (void)
82 {
83 return device_type_is_present (device_info_is_touchpad,
84+ NULL,
85 device_is_touchpad);
86 }
87
88@@ -260,6 +300,7 @@
89 mouse_is_present (void)
90 {
91 return device_type_is_present (device_info_is_mouse,
92+ xi_device_info_is_mouse,
93 NULL);
94 }
95

Subscribers

People subscribed via source and target branches