summaryrefslogtreecommitdiff
path: root/plugins/mouse
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-12-13 15:30:40 +0100
committerinfirit <[email protected]>2014-12-13 18:32:16 +0100
commit420c17e9df0fe75f74b13f9d0caa91e764780c4b (patch)
treef2be9e365bcc05fac2923f23b04e0ea4891144b6 /plugins/mouse
parent5561f9707602bca1e768a58f9c2ff30d70586ead (diff)
downloadmate-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')
-rw-r--r--plugins/mouse/Makefile.am8
-rw-r--r--plugins/mouse/msd-mouse-manager.c60
2 files changed, 6 insertions, 62 deletions
diff --git a/plugins/mouse/Makefile.am b/plugins/mouse/Makefile.am
index 8e1ab77..01a1f43 100644
--- a/plugins/mouse/Makefile.am
+++ b/plugins/mouse/Makefile.am
@@ -8,6 +8,7 @@ libmouse_la_SOURCES = \
libmouse_la_CPPFLAGS = \
-I$(top_srcdir)/mate-settings-daemon \
+ -I$(top_srcdir)/plugins/common/ \
-DMATE_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
-DLIBEXECDIR=\""$(libexecdir)"\" \
$(AM_CPPFLAGS)
@@ -19,9 +20,10 @@ libmouse_la_CFLAGS = \
libmouse_la_LDFLAGS = \
$(MSD_PLUGIN_LDFLAGS)
-libmouse_la_LIBADD = \
- $(SETTINGS_PLUGIN_LIBS) \
- $(X11_LIBS) \
+libmouse_la_LIBADD = \
+ $(top_builddir)/plugins/common/libcommon.la \
+ $(SETTINGS_PLUGIN_LIBS) \
+ $(X11_LIBS) \
$(XINPUT_LIBS)
plugin_in_files = mouse.mate-settings-plugin.in
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)
{