[mutter/gnome-3-16] input-settings-x11: check properties for correctness before changing them



commit 20b6004507d67f26101aa5e5e8c9112d226effba
Author: Peter Hutterer <peter hutterer who-t net>
Date:   Thu Jun 11 11:49:24 2015 +1000

    input-settings-x11: check properties for correctness before changing them
    
    Before submitting a new scroll mode, click method or sendevents mode check if
    the value is supported by the device. This avoids BadValue errors when setting
    two-finger scrolling on single-finger touchpad devices since we can't easily
    handle BadValue (see 9747277b)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750816
    
    Signed-off-by: Peter Hutterer <peter hutterer who-t net>

 src/backends/x11/meta-input-settings-x11.c |   49 ++++++++++++++++++++++++----
 1 files changed, 42 insertions(+), 7 deletions(-)
---
diff --git a/src/backends/x11/meta-input-settings-x11.c b/src/backends/x11/meta-input-settings-x11.c
index f683c47..2f4527d 100644
--- a/src/backends/x11/meta-input-settings-x11.c
+++ b/src/backends/x11/meta-input-settings-x11.c
@@ -100,6 +100,12 @@ meta_input_settings_x11_set_send_events (MetaInputSettings        *settings,
                                          GDesktopDeviceSendEvents  mode)
 {
   guchar values[2] = { 0 }; /* disabled, disabled-on-external-mouse */
+  guchar *available;
+
+  available = get_property (device, "libinput Send Events Modes Available",
+                            XA_INTEGER, 8, 2);
+  if (!available)
+    return;
 
   switch (mode)
     {
@@ -113,8 +119,14 @@ meta_input_settings_x11_set_send_events (MetaInputSettings        *settings,
       break;
     }
 
-  change_property (device, "libinput Send Events Mode Enabled",
-                   XA_INTEGER, 8, &values, 2);
+  if ((values[0] && !available[0]) || (values[1] && !available[1]))
+    g_warning ("Device '%s' does not support sendevents mode %d\n",
+               clutter_input_device_get_device_name (device), mode);
+  else
+    change_property (device, "libinput Send Events Mode Enabled",
+                     XA_INTEGER, 8, &values, 2);
+
+  meta_XFree (available);
 }
 
 static void
@@ -186,6 +198,12 @@ meta_input_settings_x11_set_scroll_method (MetaInputSettings            *setting
                                            GDesktopTouchpadScrollMethod  mode)
 {
   guchar values[3] = { 0 }; /* 2fg, edge, button. The last value is unused */
+  guchar *available;
+
+  available = get_property (device, "libinput Scroll Methods Available",
+                            XA_INTEGER, 8, 3);
+  if (!available)
+    return;
 
   switch (mode)
     {
@@ -201,8 +219,14 @@ meta_input_settings_x11_set_scroll_method (MetaInputSettings            *setting
       g_assert_not_reached ();
     }
 
-  change_property (device, "libinput Scroll Method Enabled",
-                   XA_INTEGER, 8, &values, 3);
+  if ((values[0] && !available[0]) || (values[1] && !available[1]))
+    g_warning ("Device '%s' does not support scroll mode %d\n",
+               clutter_input_device_get_device_name (device), mode);
+  else
+    change_property (device, "libinput Scroll Method Enabled",
+                     XA_INTEGER, 8, &values, 3);
+
+  meta_XFree (available);
 }
 
 static void
@@ -220,7 +244,12 @@ meta_input_settings_x11_set_click_method (MetaInputSettings           *settings,
                                           GDesktopTouchpadClickMethod  mode)
 {
   guchar values[2] = { 0 }; /* buttonareas, clickfinger */
-  guchar *defaults;
+  guchar *defaults, *available;
+
+  available = get_property (device, "libinput Click Methods Available",
+                            XA_INTEGER, 8, 2);
+  if (!available)
+    return;
 
   switch (mode)
     {
@@ -245,8 +274,14 @@ meta_input_settings_x11_set_click_method (MetaInputSettings           *settings,
       return;
   }
 
-  change_property (device, "libinput Click Method Enabled",
-                   XA_INTEGER, 8, &values, 2);
+  if ((values[0] && !available[0]) || (values[1] && !available[1]))
+    g_warning ("Device '%s' does not support click method %d\n",
+               clutter_input_device_get_device_name (device), mode);
+  else
+    change_property (device, "libinput Click Method Enabled",
+                     XA_INTEGER, 8, &values, 2);
+
+  meta_XFree(available);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]