diff options
author | monsta <[email protected]> | 2016-10-28 15:06:18 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2016-10-28 15:06:18 +0300 |
commit | da07ea0fba5d9e6e05911b3b61290171cfe04623 (patch) | |
tree | 6b710ec7b3a3a47fda7dad4bfa2916d625d39b09 /plugins/mouse | |
parent | 5ea8b63e92e23e1c6d167727a8c264d8c2cd5e14 (diff) | |
download | mate-settings-daemon-da07ea0fba5d9e6e05911b3b61290171cfe04623.tar.bz2 mate-settings-daemon-da07ea0fba5d9e6e05911b3b61290171cfe04623.tar.xz |
mouse: move enabling/disabling one touchpad to new function
Diffstat (limited to 'plugins/mouse')
-rw-r--r-- | plugins/mouse/msd-mouse-manager.c | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c index 27225f4..82b47ff 100644 --- a/plugins/mouse/msd-mouse-manager.c +++ b/plugins/mouse/msd-mouse-manager.c @@ -780,37 +780,48 @@ set_scrolling (GSettings *settings) } static void -set_touchpad_enabled (gboolean state) +set_touchpad_enabled (XDeviceInfo *device_info, + gboolean state) { - int numdevices, i; - XDeviceInfo *devicelist = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &numdevices); XDevice *device; Atom prop_enabled; - - if (devicelist == NULL) - return; + unsigned char data = state; prop_enabled = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Device Enabled", False); if (!prop_enabled) return; + device = device_is_touchpad (device_info); + if (device == NULL) { + return; + } + + gdk_error_trap_push (); + XChangeDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device, + prop_enabled, XA_INTEGER, 8, + PropModeReplace, &data, 1); + + XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device); + gdk_flush (); + if (gdk_error_trap_pop ()) { + g_warning ("Error %s device \"%s\"", + (state) ? "enabling" : "disabling", + device_info->name); + } +} + +static void +set_touchpad_enabled_all (gboolean state) +{ + int numdevices, i; + XDeviceInfo *devicelist = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &numdevices); + + if (devicelist == NULL) + return; + for (i = 0; i < numdevices; i++) { - if ((device = device_is_touchpad (&devicelist[i]))) { - unsigned char data = state; - gdk_error_trap_push (); - XChangeDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device, - prop_enabled, XA_INTEGER, 8, - PropModeReplace, &data, 1); - XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device); - gdk_flush (); - if (gdk_error_trap_pop ()) { - g_warning ("Error %s device \"%s\"", - (state) ? "enabling" : "disabling", - devicelist[i].name); - continue; - } - } + set_touchpad_enabled (&devicelist[i], state); } XFreeDeviceList (devicelist); @@ -922,7 +933,7 @@ set_mouse_settings (MsdMouseManager *manager) set_click_actions_all (manager); set_scrolling (manager->priv->settings_touchpad); set_natural_scroll_all (manager); - set_touchpad_enabled (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_ENABLED)); + set_touchpad_enabled_all (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_ENABLED)); } static void @@ -957,7 +968,7 @@ mouse_callback (GSettings *settings, } else if (g_strcmp0 (key, KEY_MOUSE_LOCATE_POINTER) == 0) { set_locate_pointer (manager, g_settings_get_boolean (settings, key)); } else if (g_strcmp0 (key, KEY_TOUCHPAD_ENABLED) == 0) { - set_touchpad_enabled (g_settings_get_boolean (settings, key)); + set_touchpad_enabled_all (g_settings_get_boolean (settings, key)); #if 0 /* FIXME need to fork (?) mousetweaks for this to work */ } else if (g_strcmp0 (key, KEY_MOUSE_A11Y_DWELL_ENABLE) == 0) { set_mousetweaks_daemon (manager, |