44
device_is_touchpad (XDeviceInfo deviceinfo)
47
device_is_touchpad (XDevice *xdevice)
47
49
Atom realtype, prop;
49
51
unsigned long nitems, bytes_after;
50
52
unsigned char *data;
52
if (deviceinfo.type != XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XI_TOUCHPAD, False))
55
* we don't check on the type being XI_TOUCHPAD, but having a "Synaptics Off"
56
* property should be enough */
55
58
prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Synaptics Off", False);
59
gdk_error_trap_push ();
60
device = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), deviceinfo.id);
61
if (gdk_error_trap_pop () || (device == NULL))
64
gdk_error_trap_push ();
65
if ((XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device, prop, 0, 1, False,
62
gdk_error_trap_push ();
63
if ((XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice, prop, 0, 1, False,
66
64
XA_INTEGER, &realtype, &realformat, &nitems,
67
65
&bytes_after, &data) == Success) && (realtype != None)) {
68
66
gdk_error_trap_pop_ignored ();
72
70
gdk_error_trap_pop_ignored ();
74
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
95
92
for (i = 0; i < n_devices; i++) {
98
device = device_is_touchpad (device_info[i]);
95
gdk_error_trap_push ();
96
device = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device_info[i].id);
97
if (gdk_error_trap_pop () || (device == NULL))
100
retval = device_is_touchpad (device);
102
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
106
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
104
if (device_info != NULL)
105
XFreeDeviceList (device_info);
108
XFreeDeviceList (device_info);
114
custom_command_to_string (CustomCommand command)
117
case COMMAND_DEVICE_ADDED:
119
case COMMAND_DEVICE_REMOVED:
121
case COMMAND_DEVICE_PRESENT:
124
g_assert_not_reached ();
128
/* Run a custom command on device presence events. Parameters passed into
129
* the custom command are:
130
* command -t [added|removed|present] -i <device ID> <device name>
131
* Type 'added' and 'removed' signal 'device added' and 'device removed',
132
* respectively. Type 'present' signals 'device present at
133
* gnome-settings-daemon init'.
135
* The script is expected to run synchronously, and an exit value
136
* of "1" means that no other settings will be applied to this
139
* More options may be added in the future.
141
* This function returns TRUE if we should not apply any more settings
145
run_custom_command (GdkDevice *device,
146
CustomCommand command)
155
settings = g_settings_new (INPUT_DEVICES_SCHEMA);
156
cmd = g_settings_get_string (settings, KEY_HOTPLUG_COMMAND);
157
g_object_unref (settings);
159
if (!cmd || cmd[0] == '\0') {
165
g_object_get (device, "device-id", &id, NULL);
168
argv[1] = g_strdup_printf ("-t %s", custom_command_to_string (command));
169
argv[2] = g_strdup_printf ("-i %d", id);
170
argv[3] = g_strdup_printf ("%s", gdk_device_get_name (device));
173
rc = g_spawn_sync (g_get_home_dir (), argv, NULL, G_SPAWN_SEARCH_PATH,
174
NULL, NULL, NULL, NULL, &exit_status, NULL);
177
g_warning ("Couldn't execute command '%s', verify that this is a valid command.", cmd);
183
return (exit_status == 0);