Merge lp:~gerardo-santana/gnome-settings-daemon/gnome-settings-daemon into lp:gnome-settings-daemon

Proposed by Gerardo Santana
Status: Needs review
Proposed branch: lp:~gerardo-santana/gnome-settings-daemon/gnome-settings-daemon
Merge into: lp:gnome-settings-daemon
Diff against target: 81 lines (+48/-0)
1 file modified
plugins/mouse/gsd-mouse-manager.c (+48/-0)
To merge this branch: bzr merge lp:~gerardo-santana/gnome-settings-daemon/gnome-settings-daemon
Reviewer Review Type Date Requested Status
Bastien Nocera Pending
Jorge Castro Pending
VCS imports Pending
Review via email: mp+109476@code.launchpad.net

Description of the change

Enablas natural scrolling by changing buttons mapping

To post a comment you must log in.
Revision history for this message
Gerardo Santana (gerardo-santana) wrote :
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. The issue you are reporting is an upstream one and it would be nice if somebody having it could send the bug to the developers of the software by following the instructions at https://wiki.ubuntu.com/Bugs/Upstream/GNOME. If you have done so, please tell us the number of the upstream bug (or the link), so we can add a bugwatch that will inform us about its status. Thanks in advance.

Unmerged revisions

3021. By Gerardo Santana

Enables natural scrolling

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/mouse/gsd-mouse-manager.c'
2--- plugins/mouse/gsd-mouse-manager.c 2012-05-25 17:47:26 +0000
3+++ plugins/mouse/gsd-mouse-manager.c 2012-06-09 05:12:19 +0000
4@@ -65,6 +65,7 @@
5 /* Touchpad settings */
6 #define KEY_TOUCHPAD_DISABLE_W_TYPING "disable-while-typing"
7 #define KEY_PAD_HORIZ_SCROLL "horiz-scroll-enabled"
8+#define KEY_PAD_NATURAL_SCROLL "natural-scroll-enabled"
9 #define KEY_SCROLL_METHOD "scroll-method"
10 #define KEY_TAP_TO_CLICK "tap-to-click"
11 #define KEY_TOUCHPAD_ENABLED "touchpad-enabled"
12@@ -723,6 +724,49 @@
13 }
14
15 static void
16+set_natural_scroll (GdkDevice *device,
17+ gboolean state)
18+{
19+ XDevice *xdevice;
20+ unsigned char *map;
21+
22+ xdevice = open_gdk_device (device);
23+ if (xdevice == NULL)
24+ return;
25+
26+ if (!device_is_touchpad (xdevice)) {
27+ XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
28+ return;
29+ }
30+
31+ g_debug ("setting natural scroll on %s", gdk_device_get_name (device));
32+
33+ gdk_error_trap_push ();
34+
35+ map = (unsigned char *) malloc(sizeof(unsigned char) * 7);
36+ XGetDeviceButtonMapping(GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice, map, 7);
37+
38+ if (state) {
39+ map[3] = 5;
40+ map[4] = 4;
41+ map[5] = 7;
42+ map[6] = 6;
43+ }
44+ else {
45+ map[3] = 4;
46+ map[4] = 5;
47+ map[5] = 6;
48+ map[6] = 7;
49+ }
50+ XSetDeviceButtonMapping(GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice, map, 7);
51+
52+ if (gdk_error_trap_pop ())
53+ g_warning ("Error in setting natural scroll on \"%s\"", gdk_device_get_name (device));
54+
55+ XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
56+}
57+
58+static void
59 set_edge_scroll (GdkDevice *device,
60 GsdTouchpadScrollMethod method)
61 {
62@@ -949,6 +993,7 @@
63 set_tap_to_click (device, g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TAP_TO_CLICK), touchpad_left_handed);
64 set_edge_scroll (device, g_settings_get_enum (manager->priv->touchpad_settings, KEY_SCROLL_METHOD));
65 set_horiz_scroll (device, g_settings_get_boolean (manager->priv->touchpad_settings, KEY_PAD_HORIZ_SCROLL));
66+ set_natural_scroll (device, g_settings_get_boolean (manager->priv->touchpad_settings, KEY_PAD_NATURAL_SCROLL));
67 if (g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TOUCHPAD_ENABLED) == FALSE)
68 set_touchpad_disabled (device);
69 }
70@@ -1019,8 +1064,11 @@
71 } else if (g_str_equal (key, KEY_SCROLL_METHOD)) {
72 set_edge_scroll (device, g_settings_get_enum (settings, key));
73 set_horiz_scroll (device, g_settings_get_boolean (settings, KEY_PAD_HORIZ_SCROLL));
74+ set_natural_scroll (device, g_settings_get_boolean (settings, KEY_PAD_NATURAL_SCROLL));
75 } else if (g_str_equal (key, KEY_PAD_HORIZ_SCROLL)) {
76 set_horiz_scroll (device, g_settings_get_boolean (settings, key));
77+ } else if (g_str_equal (key, KEY_PAD_NATURAL_SCROLL)) {
78+ set_natural_scroll (device, g_settings_get_boolean (settings, key));
79 } else if (g_str_equal (key, KEY_TOUCHPAD_ENABLED)) {
80 if (g_settings_get_boolean (settings, key) == FALSE)
81 set_touchpad_disabled (device);

Subscribers

People subscribed via source and target branches

to all changes: