diff options
author | infirit <[email protected]> | 2014-12-13 15:30:40 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-12-13 18:32:16 +0100 |
commit | 420c17e9df0fe75f74b13f9d0caa91e764780c4b (patch) | |
tree | f2be9e365bcc05fac2923f23b04e0ea4891144b6 /plugins/mouse/msd-mouse-manager.c | |
parent | 5561f9707602bca1e768a58f9c2ff30d70586ead (diff) | |
download | mate-settings-daemon-420c17e9df0fe75f74b13f9d0caa91e764780c4b.tar.bz2 mate-settings-daemon-420c17e9df0fe75f74b13f9d0caa91e764780c4b.tar.xz |
mouse: Move "has touchpad" function to common
So it can be reused. This also fixes a memory leak in the function.
We were leaking the device list
Taken from GSD commit: f6dcba4e954f3e910854f3c92fb69b157683267d
From: Bastien Nocera <[email protected]>
Diffstat (limited to 'plugins/mouse/msd-mouse-manager.c')
-rw-r--r-- | plugins/mouse/msd-mouse-manager.c | 60 |
1 files changed, 1 insertions, 59 deletions
diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c index 5bce75b..f25bcb2 100644 --- a/plugins/mouse/msd-mouse-manager.c +++ b/plugins/mouse/msd-mouse-manager.c @@ -48,6 +48,7 @@ #include "mate-settings-profile.h" #include "msd-mouse-manager.h" +#include "msd-input-helper.h" #define MSD_MOUSE_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MSD_TYPE_MOUSE_MANAGER, MsdMouseManagerPrivate)) @@ -92,7 +93,6 @@ static void msd_mouse_manager_finalize (GObject *object); static void set_mouse_settings (MsdMouseManager *manager); #ifdef HAVE_X11_EXTENSIONS_XINPUT_H static int set_tap_to_click (gboolean state, gboolean left_handed); -static XDevice* device_is_touchpad (XDeviceInfo deviceinfo); #endif G_DEFINE_TYPE (MsdMouseManager, msd_mouse_manager, G_TYPE_OBJECT) @@ -570,64 +570,6 @@ set_middle_button (MsdMouseManager *manager, XFreeDeviceList (device_info); } -#ifdef HAVE_X11_EXTENSIONS_XINPUT_H -static XDevice* -device_is_touchpad (XDeviceInfo deviceinfo) -{ - XDevice *device; - Atom realtype, prop; - int realformat; - unsigned long nitems, bytes_after; - unsigned char *data; - - if (deviceinfo.type != XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XI_TOUCHPAD, False)) - return NULL; - - prop = XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "Synaptics Off", False); - if (!prop) - return NULL; - - gdk_error_trap_push (); - device = XOpenDevice (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), deviceinfo.id); - if (gdk_error_trap_pop () || (device == NULL)) - return NULL; - - gdk_error_trap_push (); - if ((XGetDeviceProperty (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), device, prop, 0, 1, False, - XA_INTEGER, &realtype, &realformat, &nitems, - &bytes_after, &data) == Success) && (realtype != None)) { - gdk_error_trap_pop (); - XFree (data); - return device; - } - gdk_error_trap_pop (); - - XCloseDevice (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), device); - return NULL; -} -#endif - -static gboolean -touchpad_is_present (void) -{ - gboolean touchpad_present = FALSE; - int numdevices, i; - XDeviceInfo *devicelist = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &numdevices); - XDevice *device; - - if (devicelist == NULL) - return 0; - - for (i = 0; i < numdevices; i++) { - if ((device = device_is_touchpad (devicelist[i]))) { - touchpad_present = TRUE; - break; - } - } - - return touchpad_present; -} - static int set_disable_w_typing (MsdMouseManager *manager, gboolean state) { |