From e24515bdf2f3eb084fca73c344e540ab27cb797e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Apr 09 2009 01:38:46 +0000 Subject: Support touchpads --- diff --git a/gnome-settings-daemon-2.26.0-support-touchpads.patch b/gnome-settings-daemon-2.26.0-support-touchpads.patch new file mode 100644 index 0000000..5679dd8 --- /dev/null +++ b/gnome-settings-daemon-2.26.0-support-touchpads.patch @@ -0,0 +1,451 @@ +diff -up /dev/null gnome-settings-daemon-2.26.0/data/desktop_gnome_peripherals_touchpad.schemas.in +--- /dev/null 2009-04-08 15:58:42.372260448 -0400 ++++ gnome-settings-daemon-2.26.0/data/desktop_gnome_peripherals_touchpad.schemas.in 2009-04-08 20:29:32.449768001 -0400 +@@ -0,0 +1,54 @@ ++ ++ ++ ++ ++ ++ /schemas/desktop/gnome/peripherals/touchpad/disable_while_typing ++ /desktop/gnome/peripherals/touchpad/disable_while_typing ++ gnome ++ bool ++ FALSE ++ ++ Disable touchpad while typing ++ Set this to TRUE if you have problems with accidentally hitting the touchpad while typing. ++ ++ ++ ++ ++ /schemas/desktop/gnome/peripherals/touchpad/tap_to_click ++ /desktop/gnome/peripherals/touchpad/tap_to_click ++ gnome ++ bool ++ FALSE ++ ++ Enable mouse clicks with touchpad ++ Set this to TRUE to be able to send mouse clicks by tapping on the touchpad. ++ ++ ++ ++ ++ /schemas/desktop/gnome/peripherals/touchpad/scroll_method ++ /desktop/gnome/peripherals/touchpad/scroll_method ++ gnome ++ int ++ 0 ++ ++ Select the touchpad scroll method ++ Select the touchpad scroll method. Supported values are: 0 - disabled, 1 - edge scrolling, 2 - two-finger scrolling ++ ++ ++ ++ ++ /schemas/desktop/gnome/peripherals/touchpad/horiz_scroll_enabled ++ /desktop/gnome/peripherals/touchpad/horiz_scroll_enabled ++ gnome ++ bool ++ FALSE ++ ++ Enable horizontal scrolling ++ Set this to TRUE to allow horizontal scrolling by the same method selected with the scroll_method key. ++ ++ ++ ++ ++ +diff -up gnome-settings-daemon-2.26.0/data/Makefile.am.support-touchpads gnome-settings-daemon-2.26.0/data/Makefile.am +--- gnome-settings-daemon-2.26.0/data/Makefile.am.support-touchpads 2009-02-16 11:34:08.000000000 -0500 ++++ gnome-settings-daemon-2.26.0/data/Makefile.am 2009-04-08 20:29:32.449768001 -0400 +@@ -10,6 +10,7 @@ schemas_in_files = \ + desktop_gnome_font_rendering.schemas.in \ + desktop_gnome_keybindings.schemas.in \ + apps_gnome_settings_daemon_xrandr.schemas.in \ ++ desktop_gnome_peripherals_touchpad.schemas.in \ + $(NULL) + + schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) +diff -up gnome-settings-daemon-2.26.0/plugins/mouse/gsd-mouse-manager.c.support-touchpads gnome-settings-daemon-2.26.0/plugins/mouse/gsd-mouse-manager.c +--- gnome-settings-daemon-2.26.0/plugins/mouse/gsd-mouse-manager.c.support-touchpads 2009-04-08 20:29:32.446745868 -0400 ++++ gnome-settings-daemon-2.26.0/plugins/mouse/gsd-mouse-manager.c 2009-04-08 21:23:16.465987950 -0400 +@@ -38,9 +38,11 @@ + #include + #include + #include ++#include + + #ifdef HAVE_X11_EXTENSIONS_XINPUT_H + #include ++#include + #endif + #include + #include +@@ -54,6 +56,7 @@ + + #define GCONF_MOUSE_DIR "/desktop/gnome/peripherals/mouse" + #define GCONF_MOUSE_A11Y_DIR "/desktop/gnome/accessibility/mouse" ++#define GCONF_TOUCHPAD_DIR "/desktop/gnome/peripherals/touchpad" + + #define KEY_LEFT_HANDED GCONF_MOUSE_DIR "/left_handed" + #define KEY_MOTION_ACCELERATION GCONF_MOUSE_DIR "/motion_acceleration" +@@ -61,13 +64,20 @@ + #define KEY_LOCATE_POINTER GCONF_MOUSE_DIR "/locate_pointer" + #define KEY_DWELL_ENABLE GCONF_MOUSE_A11Y_DIR "/dwell_enable" + #define KEY_DELAY_ENABLE GCONF_MOUSE_A11Y_DIR "/delay_enable" ++#define KEY_TOUCHPAD_DISABLE_W_TYPING GCONF_TOUCHPAD_DIR "/disable_while_typing" ++#define KEY_TAP_TO_CLICK GCONF_TOUCHPAD_DIR "/tap_to_click" ++#define KEY_SCROLL_METHOD GCONF_TOUCHPAD_DIR "/scroll_method" ++#define KEY_PAD_HORIZ_SCROLL GCONF_TOUCHPAD_DIR "/horiz_scroll_enabled" + + struct GsdMouseManagerPrivate + { + guint notify; + guint notify_a11y; ++ guint notify_touchpad; + + gboolean mousetweaks_daemon_running; ++ gboolean syndaemon_spawned; ++ GPid syndaemon_pid; + }; + + static void gsd_mouse_manager_class_init (GsdMouseManagerClass *klass); +@@ -261,6 +271,9 @@ set_xinput_devices_left_handed (gboolean + + device_info = XListInputDevices (GDK_DISPLAY (), &n_devices); + ++ if (device_info == NULL) ++ return; ++ + if (n_devices > 0) + buttons = g_new (guchar, buttons_capacity); + else +@@ -436,6 +449,256 @@ set_motion_threshold (GsdMouseManager *m + 0, 0, motion_threshold); + } + ++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(), XI_TOUCHPAD, False)) ++ return NULL; ++ ++ prop = XInternAtom(GDK_DISPLAY(), "Synaptics Off", False); ++ if (!prop) ++ return NULL; ++ ++ gdk_error_trap_push(); ++ device = XOpenDevice(GDK_DISPLAY(), deviceinfo.id); ++ if (gdk_error_trap_pop() || (device == NULL)) ++ return NULL; ++ ++ gdk_error_trap_push(); ++ if ((XGetDeviceProperty(GDK_DISPLAY(), 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(), device); ++ return NULL; ++} ++ ++static int ++set_disable_w_typing (GsdMouseManager *manager, gboolean state) ++{ ++ GError *error = NULL; ++ ++ if (state) { ++ char *args[4]; ++ ++ args[0] = "syndaemon"; ++ args[1] = "-i"; ++ args[2] = "0.5"; ++ args[3] = NULL; ++ ++ if (!g_find_program_in_path(args[0])) ++ return 0; ++ ++ g_spawn_async(g_get_home_dir(), args, NULL, ++ G_SPAWN_SEARCH_PATH, NULL, NULL, ++ &manager->priv->syndaemon_pid, &error); ++ ++ if (error) { ++ GConfClient *client; ++ client = gconf_client_get_default(); ++ gconf_client_set_bool(client, KEY_TOUCHPAD_DISABLE_W_TYPING, FALSE, NULL); ++ } ++ ++ manager->priv->syndaemon_spawned = (error == NULL); ++ ++ } else if (manager->priv->syndaemon_spawned) ++ { ++ kill(manager->priv->syndaemon_pid, SIGHUP); ++ g_spawn_close_pid(manager->priv->syndaemon_pid); ++ manager->priv->syndaemon_spawned = False; ++ } ++ ++ return 0; ++} ++ ++static int ++set_tap_to_click (gboolean state) ++{ ++ int numdevices, i, format, rc; ++ unsigned long nitems, bytes_after; ++ XDeviceInfo *devicelist = XListInputDevices (GDK_DISPLAY(), &numdevices); ++ XDevice * device; ++ unsigned char* data; ++ Atom prop, type; ++ ++ if (devicelist == NULL) ++ return 0; ++ ++ prop = XInternAtom(GDK_DISPLAY(), "Synaptics Tap Action", False); ++ ++ if (!prop) ++ return 0; ++ ++ for (i = 0; i < numdevices; i++) { ++ if ((device = device_is_touchpad(devicelist[i]))) { ++ gdk_error_trap_push(); ++ rc = XGetDeviceProperty(GDK_DISPLAY(), device, prop, 0, 2, ++ False, XA_INTEGER, &type, &format, &nitems, ++ &bytes_after, &data); ++ ++ if (rc == Success && type == XA_INTEGER && format == 8 && nitems >= 7) ++ { ++ /* Set RLM mapping for 1/2/3 fingers*/ ++ data[4] = (state) ? 1 : 0; ++ data[5] = (state) ? 3 : 0; ++ data[6] = (state) ? 2 : 0; ++ XChangeDeviceProperty(GDK_DISPLAY(), device, prop, XA_INTEGER, 8, ++ PropModeReplace, data, nitems); ++ } ++ ++ if (rc == Success) ++ XFree(data); ++ XCloseDevice (GDK_DISPLAY(), device); ++ if (gdk_error_trap_pop()) { ++ g_warning("Error in setting tap to click on \"%s\"", devicelist[i].name); ++ continue; ++ } ++ } ++ } ++ ++ XFreeDeviceList(devicelist); ++ return 0; ++} ++ ++static int ++set_horiz_scroll (gboolean state) ++{ ++ int numdevices, i, rc; ++ XDeviceInfo *devicelist = XListInputDevices (GDK_DISPLAY(), &numdevices); ++ XDevice *device; ++ Atom act_type, prop_edge, prop_twofinger; ++ int act_format; ++ unsigned long nitems, bytes_after; ++ unsigned char *data; ++ ++ if (devicelist == NULL) ++ return 0; ++ ++ prop_edge = XInternAtom(GDK_DISPLAY(), "Synaptics Edge Scrolling", False); ++ prop_twofinger = XInternAtom(GDK_DISPLAY(), "Synaptics Two-Finger Scrolling", False); ++ ++ if (!prop_edge || !prop_twofinger) ++ return 0; ++ ++ for (i = 0; i < numdevices; i++) { ++ if ((device = device_is_touchpad(devicelist[i]))) { ++ gdk_error_trap_push(); ++ rc = XGetDeviceProperty(GDK_DISPLAY(), device, ++ prop_edge, 0, 1, False, ++ XA_INTEGER, &act_type, &act_format, &nitems, ++ &bytes_after, &data); ++ if (rc == Success && act_type == XA_INTEGER && ++ act_format == 8 && nitems >= 2) { ++ data[1] = (state && data[0]); ++ XChangeDeviceProperty(GDK_DISPLAY(), device, ++ prop_edge, XA_INTEGER, 8, ++ PropModeReplace, data, nitems); ++ } ++ ++ XFree(data); ++ ++ rc = XGetDeviceProperty(GDK_DISPLAY(), device, ++ prop_twofinger, 0, 1, False, ++ XA_INTEGER, &act_type, &act_format, &nitems, ++ &bytes_after, &data); ++ if (rc == Success && act_type == XA_INTEGER && ++ act_format == 8 && nitems >= 2) { ++ data[1] = (state && data[0]); ++ XChangeDeviceProperty(GDK_DISPLAY(), device, ++ prop_twofinger, XA_INTEGER, 8, ++ PropModeReplace, data, nitems); ++ } ++ ++ XFree(data); ++ XCloseDevice (GDK_DISPLAY(), device); ++ if (gdk_error_trap_pop()) { ++ g_warning("Error in setting horiz scroll on \"%s\"", devicelist[i].name); ++ continue; ++ } ++ } ++ } ++ ++ XFreeDeviceList(devicelist); ++ return 0; ++} ++ ++ ++/** ++ * Scroll methods are: 0 - disabled, 1 - edge scrolling, 2 - twofinger ++ * scrolling ++ */ ++static int ++set_edge_scroll (int method) ++{ ++ int numdevices, i, rc; ++ XDeviceInfo *devicelist = XListInputDevices (GDK_DISPLAY(), &numdevices); ++ XDevice *device; ++ Atom act_type, prop_edge, prop_twofinger; ++ int act_format; ++ unsigned long nitems, bytes_after; ++ unsigned char *data; ++ ++ if (devicelist == NULL) ++ return 0; ++ ++ prop_edge = XInternAtom(GDK_DISPLAY(), "Synaptics Edge Scrolling", False); ++ prop_twofinger = XInternAtom(GDK_DISPLAY(), "Synaptics Two-Finger Scrolling", False); ++ ++ if (!prop_edge || !prop_twofinger) ++ return 0; ++ ++ for (i = 0; i < numdevices; i++) { ++ if ((device = device_is_touchpad(devicelist[i]))) { ++ gdk_error_trap_push(); ++ rc = XGetDeviceProperty(GDK_DISPLAY(), device, ++ prop_edge, 0, 1, False, ++ XA_INTEGER, &act_type, &act_format, &nitems, ++ &bytes_after, &data); ++ if (rc == Success && act_type == XA_INTEGER && ++ act_format == 8 && nitems >= 2) { ++ data[0] = (method == 1) ? 1 : 0; ++ XChangeDeviceProperty(GDK_DISPLAY(), device, ++ prop_edge, XA_INTEGER, 8, ++ PropModeReplace, data, nitems); ++ } ++ ++ XFree(data); ++ ++ rc = XGetDeviceProperty(GDK_DISPLAY(), device, ++ prop_twofinger, 0, 1, False, ++ XA_INTEGER, &act_type, &act_format, &nitems, ++ &bytes_after, &data); ++ if (rc == Success && act_type == XA_INTEGER && ++ act_format == 8 && nitems >= 2) { ++ data[0] = (method == 2) ? 1 : 0; ++ XChangeDeviceProperty(GDK_DISPLAY(), device, ++ prop_twofinger, XA_INTEGER, 8, ++ PropModeReplace, data, nitems); ++ } ++ ++ XFree(data); ++ XCloseDevice (GDK_DISPLAY(), device); ++ if (gdk_error_trap_pop()) { ++ g_warning("Error in setting edge scroll on \"%s\"", devicelist[i].name); ++ continue; ++ } ++ } ++ } ++ ++ XFreeDeviceList(devicelist); ++ return 0; ++} + + #define KEYBOARD_GROUP_SHIFT 13 + #define KEYBOARD_GROUP_MASK ((1 << 13) | (1 << 14)) +@@ -647,6 +910,11 @@ set_mouse_settings (GsdMouseManager *man + set_motion_acceleration (manager, gconf_client_get_float (client, KEY_MOTION_ACCELERATION , NULL)); + set_motion_threshold (manager, gconf_client_get_int (client, KEY_MOTION_THRESHOLD, NULL)); + ++ set_disable_w_typing (manager, gconf_client_get_bool (client, KEY_TOUCHPAD_DISABLE_W_TYPING, NULL)); ++ set_tap_to_click (gconf_client_get_bool (client, KEY_TAP_TO_CLICK, NULL)); ++ set_edge_scroll (gconf_client_get_int (client, KEY_SCROLL_METHOD, NULL)); ++ set_horiz_scroll (gconf_client_get_bool (client, KEY_PAD_HORIZ_SCROLL, NULL)); ++ + g_object_unref (client); + } + +@@ -668,6 +936,20 @@ mouse_callback (GConfClient *clie + if (entry->value->type == GCONF_VALUE_INT) { + set_motion_threshold (manager, gconf_value_get_int (entry->value)); + } ++ } else if (! strcmp (entry->key, KEY_TOUCHPAD_DISABLE_W_TYPING)) { ++ if (entry->value->type == GCONF_VALUE_BOOL) ++ set_disable_w_typing (manager, gconf_value_get_bool (entry->value)); ++ } else if (! strcmp (entry->key, KEY_TAP_TO_CLICK)) { ++ if (entry->value->type == GCONF_VALUE_BOOL) ++ set_tap_to_click (gconf_value_get_bool (entry->value)); ++ } else if (! strcmp (entry->key, KEY_SCROLL_METHOD)) { ++ if (entry->value->type == GCONF_VALUE_INT) { ++ set_edge_scroll (gconf_value_get_int (entry->value)); ++ set_horiz_scroll (gconf_client_get_bool (client, KEY_PAD_HORIZ_SCROLL, NULL)); ++ } ++ } else if (! strcmp (entry->key, KEY_PAD_HORIZ_SCROLL)) { ++ if (entry->value->type == GCONF_VALUE_BOOL) ++ set_horiz_scroll (gconf_value_get_bool (entry->value)); + } else if (! strcmp (entry->key, KEY_LOCATE_POINTER)) { + if (entry->value->type == GCONF_VALUE_BOOL) { + set_locate_pointer (manager, gconf_value_get_bool (entry->value)); +@@ -722,6 +1004,12 @@ gsd_mouse_manager_idle_cb (GsdMouseManag + client, + GCONF_MOUSE_A11Y_DIR, + (GConfClientNotifyFunc) mouse_callback); ++ manager->priv->notify_touchpad = ++ register_config_callback (manager, ++ client, ++ GCONF_TOUCHPAD_DIR, ++ (GConfClientNotifyFunc) mouse_callback); ++ manager->priv->syndaemon_spawned = False; + + #ifdef HAVE_X11_EXTENSIONS_XINPUT_H + set_devicepresence_handler (manager); +@@ -732,6 +1020,11 @@ gsd_mouse_manager_idle_cb (GsdMouseManag + gconf_client_get_bool (client, KEY_DWELL_ENABLE, NULL), + gconf_client_get_bool (client, KEY_DELAY_ENABLE, NULL)); + ++ set_disable_w_typing (manager, gconf_client_get_bool (client, KEY_TOUCHPAD_DISABLE_W_TYPING, NULL)); ++ set_tap_to_click (gconf_client_get_bool (client, KEY_TAP_TO_CLICK, NULL)); ++ set_edge_scroll (gconf_client_get_int (client, KEY_SCROLL_METHOD, NULL)); ++ set_horiz_scroll (gconf_client_get_bool (client, KEY_PAD_HORIZ_SCROLL, NULL)); ++ + g_object_unref (client); + + gnome_settings_profile_end (NULL); +@@ -774,6 +1067,12 @@ gsd_mouse_manager_stop (GsdMouseManager + p->notify_a11y = 0; + } + ++ if (p->notify_touchpad != 0) { ++ gconf_client_remove_dir (client, GCONF_TOUCHPAD_DIR, NULL); ++ gconf_client_notify_remove (client, p->notify_touchpad); ++ p->notify_touchpad = 0; ++ } ++ + g_object_unref (client); + + set_locate_pointer (manager, FALSE); diff --git a/gnome-settings-daemon.spec b/gnome-settings-daemon.spec index a7d8d7b..76898f3 100644 --- a/gnome-settings-daemon.spec +++ b/gnome-settings-daemon.spec @@ -1,6 +1,6 @@ Name: gnome-settings-daemon Version: 2.26.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: The daemon sharing settings from GNOME to GTK+/KDE applications Group: System Environment/Daemons @@ -35,8 +35,8 @@ BuildRequires: fontconfig-devel # http://bugzilla.redhat.com/474758 Patch10: gnome-settings-daemon-2.24.0-catch-deviceadded.patch -# http://bugzilla.redhat.com/324721 -#Patch11: gnome-settings-daemon-2.24.0-fix-touchpad.patch +# http://bugzilla.gnome.org/show_bug.cgi?id=578444 +Patch11: gnome-settings-daemon-2.26.0-support-touchpads.patch %description A daemon to share settings from GNOME to other applications. It also @@ -57,8 +57,7 @@ developing applications that use %{name}. %setup -q %patch10 -p1 -b .catch-deviceadded -# This one is buggy, stop using for now -#%patch11 -p1 -b .fix-touchpad +%patch11 -p1 -b .support-touchpads autoreconf -i -f @@ -98,6 +97,7 @@ gconftool-2 --makefile-install-rule \ %{_sysconfdir}/gconf/schemas/apps_gnome_settings_daemon_screensaver.schemas \ %{_sysconfdir}/gconf/schemas/desktop_gnome_font_rendering.schemas \ %{_sysconfdir}/gconf/schemas/gnome-settings-daemon.schemas \ + %{_sysconfdir}/gconf/schemas/desktop_gnome_peripherals_touchpad.schemas \ >& /dev/null || : touch %{_datadir}/icons/hicolor if [ -x /usr/bin/gtk-update-icon-cache ]; then @@ -107,6 +107,11 @@ fi %pre if [ "$1" -gt 1 ]; then export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` + if [ -f %{_sysconfdir}/gconf/schemas/desktop_gnome_peripherals_touchpad.schemas ] ; then + gconftool-2 --makefile-uninstall-rule \ + %{_sysconfdir}/gconf/schemas/desktop_gnome_peripherals_touchpad.schemas \ + >& /dev/null || : + fi if [ -f %{_sysconfdir}/gconf/schemas/apps_gnome_settings_daemon_default_editor.schemas ] ; then gconftool-2 --makefile-uninstall-rule \ %{_sysconfdir}/gconf/schemas/apps_gnome_settings_daemon_default_editor.schemas \ @@ -123,6 +128,11 @@ fi %preun if [ "$1" -eq 0 ]; then export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` + if [ -f %{_sysconfdir}/gconf/schemas/desktop_gnome_peripherals_touchpad.schemas ] ; then + gconftool-2 --makefile-uninstall-rule \ + %{_sysconfdir}/gconf/schemas/desktop_gnome_peripherals_touchpad.schemas \ + >& /dev/null || : + fi if [ -f %{_sysconfdir}/gconf/schemas/apps_gnome_settings_daemon_default_editor.schemas ] ; then gconftool-2 --makefile-uninstall-rule \ %{_sysconfdir}/gconf/schemas/apps_gnome_settings_daemon_default_editor.schemas \ @@ -160,6 +170,9 @@ fi %{_libdir}/pkgconfig/gnome-settings-daemon.pc %changelog +* Wed Apr 8 2009 Matthias Clasen - 2.26.0-2 +- Support touchpads + * Mon Mar 16 2009 Matthias Clasen - 2.26.0-1 - Update to 2.26.0