diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2010-05-30 22:01:38 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-05-30 22:02:53 +1000 |
commit | 3da1b0b7050a6723ccd9fbb34dbd3fc9fcdca125 (patch) | |
tree | 85ea0c083a264a8a14b82734500b670689c556d5 | |
parent | c086534fb663bba6d3453e7274241a5087075d6c (diff) |
wacom: support device mode switching.wacom
Pad's can't be switched to absolute mode, so only the other three devices
are handled.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | data/desktop_gnome_peripherals_wacom.schemas.in | 36 | ||||
-rw-r--r-- | plugins/wacom/gsd-wacom-manager.c | 67 |
2 files changed, 103 insertions, 0 deletions
diff --git a/data/desktop_gnome_peripherals_wacom.schemas.in b/data/desktop_gnome_peripherals_wacom.schemas.in index 9c847da..3c1e2a8 100644 --- a/data/desktop_gnome_peripherals_wacom.schemas.in +++ b/data/desktop_gnome_peripherals_wacom.schemas.in @@ -39,6 +39,42 @@ </schema> <schema> + <key>/schemas/desktop/gnome/peripherals/wacom/stylus/is_absolute</key> + <applyto>/desktop/gnome/peripherals/wacom/stylus/is_absolute</applyto> + <owner>gnome</owner> + <type>bool</type> + <default>1</default> + <locale name="C"> + <short>Wacom stylus absolute mode</short> + <long>Enable this to set the stylus to absolute mode.</long> + </locale> + </schema> + + <schema> + <key>/schemas/desktop/gnome/peripherals/wacom/eraser/is_absolute</key> + <applyto>/desktop/gnome/peripherals/wacom/eraser/is_absolute</applyto> + <owner>gnome</owner> + <type>bool</type> + <default>1</default> + <locale name="C"> + <short>Wacom eraser absolute mode</short> + <long>Enable this to set the eraser to absolute mode.</long> + </locale> + </schema> + + <schema> + <key>/schemas/desktop/gnome/peripherals/wacom/cursor/is_absolute</key> + <applyto>/desktop/gnome/peripherals/wacom/cursor/is_absolute</applyto> + <owner>gnome</owner> + <type>bool</type> + <default>1</default> + <locale name="C"> + <short>Wacom cursor absolute mode</short> + <long>Enable this to set the cursor to absolute mode.</long> + </locale> + </schema> + + <schema> <key>/schemas/desktop/gnome/peripherals/wacom/stylus/pressurecurve</key> <applyto>/desktop/gnome/peripherals/wacom/stylus/pressurecurve</applyto> <owner>gnome</owner> diff --git a/plugins/wacom/gsd-wacom-manager.c b/plugins/wacom/gsd-wacom-manager.c index 1c306fc..94335e1 100644 --- a/plugins/wacom/gsd-wacom-manager.c +++ b/plugins/wacom/gsd-wacom-manager.c @@ -73,6 +73,10 @@ #define KEY_STYLUS_PRESSURECURVE GCONF_STYLUS_DIR "/pressurecurve" #define KEY_ERASER_PRESSURECURVE GCONF_ERASER_DIR "/pressurecurve" +#define KEY_STYLUS_IS_ABSOLUTE GCONF_STYLUS_DIR "/is_absolute" +#define KEY_ERASER_IS_ABSOLUTE GCONF_ERASER_DIR "/is_absolute" +#define KEY_CURSOR_IS_ABSOLUTE GCONF_CURSOR_DIR "/is_absolute" + #define KEY_STYLUS_AREA GCONF_STYLUS_DIR "/area" #define KEY_ERASER_AREA GCONF_ERASER_DIR "/area" #define KEY_CURSOR_AREA GCONF_CURSOR_DIR "/area" @@ -542,6 +546,48 @@ pad_area (GsdWacomManager *manager, set_area (manager, list, "PAD"); } +struct absolute_data { + const char *device_type; + gboolean absolute; +}; + +static void +wacom_absolute_cb (XDeviceInfo *device_info, XDevice *device, void *userdata) +{ + struct absolute_data *data = userdata; + + if (device_info->type != XInternAtom (GDK_DISPLAY (), data->device_type, False)) + return; + + gdk_error_trap_push (); + XSetDeviceMode (GDK_DISPLAY (), device, data->absolute ? Absolute : Relative); + gdk_error_trap_pop (); +} + +static void +stylus_set_absolute (GsdWacomManager *manager, + gboolean is_absolute) +{ + struct absolute_data data = { "STYLUS", is_absolute }; + wacom_foreach_device (wacom_absolute_cb, &data ); +} + +static void +eraser_set_absolute (GsdWacomManager *manager, + gboolean is_absolute) +{ + struct absolute_data data = { "ERASER", is_absolute }; + wacom_foreach_device (wacom_absolute_cb, &data); +} + +static void +cursor_set_absolute (GsdWacomManager *manager, + gboolean is_absolute) +{ + struct absolute_data data = { "CURSOR", is_absolute }; + wacom_foreach_device (wacom_absolute_cb, &data); +} + struct buttonmap_data { const gchar *device_type; @@ -793,6 +839,15 @@ set_wacom_settings (GsdWacomManager *manager) eraser_pressurecurve (manager, gconf_client_get (client, KEY_ERASER_PRESSURECURVE, NULL)); + stylus_set_absolute (manager, + gconf_client_get_bool (client, KEY_STYLUS_IS_ABSOLUTE, NULL)); + eraser_set_absolute (manager, + gconf_client_get_bool (client, KEY_ERASER_IS_ABSOLUTE, NULL)); + cursor_set_absolute (manager, + gconf_client_get_bool (client, KEY_CURSOR_IS_ABSOLUTE, NULL)); + /* pad can't be set to absolute */ + + stylus_area (manager, gconf_client_get (client, KEY_STYLUS_AREA, NULL)); eraser_area (manager, @@ -837,6 +892,18 @@ wacom_callback (GConfClient *client, if (entry->value->type == GCONF_VALUE_LIST) { eraser_pressurecurve (manager, entry->value); } + } else if (! strcmp (entry->key, KEY_STYLUS_IS_ABSOLUTE)) { + if (entry->value->type == GCONF_VALUE_LIST) { + stylus_set_absolute (manager, gconf_value_get_bool (entry->value)); + } + } else if (! strcmp (entry->key, KEY_ERASER_IS_ABSOLUTE)) { + if (entry->value->type == GCONF_VALUE_LIST) { + eraser_set_absolute (manager, gconf_value_get_bool (entry->value)); + } + } else if (! strcmp (entry->key, KEY_CURSOR_IS_ABSOLUTE)) { + if (entry->value->type == GCONF_VALUE_LIST) { + cursor_set_absolute (manager, gconf_value_get_bool (entry->value)); + } } else if (! strcmp (entry->key, KEY_STYLUS_AREA)) { if (entry->value->type == GCONF_VALUE_LIST) { stylus_area (manager, entry->value); |