[gnome-settings-daemon] wacom: multiple mode-switch buttons mode selection
- From: Olivier Fourdan <ofourdan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] wacom: multiple mode-switch buttons mode selection
- Date: Fri, 14 Dec 2012 14:05:19 +0000 (UTC)
commit 703e14902e2943d960582c2d3f751a1c13496d93
Author: Olivier Fourdan <ofourdan redhat com>
Date: Thu Dec 13 15:08:00 2012 +0100
wacom: multiple mode-switch buttons mode selection
The Cintiq 24HD has three modes per side, but also
3 different buttons to select modes. So you can go
from mode 1 to mode 3 without cycling through mode
2, you just hit the individual button.
Currently, when you hit any of the mode switch
buttons it just cycles through them like the other
tablets do.
To allow selecting a given mode, check if there are
multiple mode-switch buttons present on the device
and if so set the mode based on the index of that
button in the list of mode-switches.
https://bugzilla.gnome.org/show_bug.cgi?id=690157
plugins/wacom/gsd-wacom-device.c | 45 +++++++++++++++++++++++++++++++-----
plugins/wacom/gsd-wacom-device.h | 4 +-
plugins/wacom/gsd-wacom-manager.c | 2 +-
3 files changed, 41 insertions(+), 10 deletions(-)
---
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c
index ea16ed1..ef06e28 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -954,21 +954,52 @@ add_stylus_to_device (GsdWacomDevice *device,
}
int
-gsd_wacom_device_set_next_mode (GsdWacomDevice *device,
- int group_id)
+gsd_wacom_device_set_next_mode (GsdWacomDevice *device,
+ GsdWacomTabletButton *button)
{
+ GList *l;
int current_idx;
int num_modes;
+ int num_switches;
+ int group_id;
g_return_val_if_fail (GSD_IS_WACOM_DEVICE (device), -1);
- current_idx = GPOINTER_TO_INT (g_hash_table_lookup (device->priv->modes, GINT_TO_POINTER(group_id)));
- /* That means that the mode doesn't exist, see gsd_wacom_device_add_modes() */
- g_return_val_if_fail (current_idx != 0, -1);
-
- current_idx++;
+ group_id = button->group_id;
+ current_idx = 0;
+ num_switches = 0;
num_modes = GPOINTER_TO_INT (g_hash_table_lookup (device->priv->num_modes, GINT_TO_POINTER(group_id)));
+ /*
+ * Check if we have multiple mode-switch buttons for that
+ * group, and if so, compute the current index based on
+ * the position in the list...
+ */
+ for (l = device->priv->buttons; l != NULL; l = l->next) {
+ GsdWacomTabletButton *b = l->data;
+ if (b->type != WACOM_TABLET_BUTTON_TYPE_HARDCODED)
+ continue;
+ if (button->group_id == b->group_id)
+ num_switches++;
+ if (g_strcmp0 (button->id, b->id) == 0)
+ current_idx = num_switches;
+ }
+
+ /* We should at least have found the current mode-switch button...
+ * If not, then it means that the given button is not a valid
+ * mode-switch.
+ */
+ g_return_val_if_fail (num_switches != 0, -1);
+
+ /* Only one mode-switch? cycle through the modes */
+ if (num_switches == 1) {
+ current_idx = GPOINTER_TO_INT (g_hash_table_lookup (device->priv->modes, GINT_TO_POINTER(group_id)));
+ /* That means that the mode doesn't exist, see gsd_wacom_device_add_modes() */
+ g_return_val_if_fail (current_idx != 0, -1);
+
+ current_idx++;
+ }
+
if (current_idx > num_modes)
current_idx = 1;
diff --git a/plugins/wacom/gsd-wacom-device.h b/plugins/wacom/gsd-wacom-device.h
index 24e6e06..f24795b 100644
--- a/plugins/wacom/gsd-wacom-device.h
+++ b/plugins/wacom/gsd-wacom-device.h
@@ -158,8 +158,8 @@ GList * gsd_wacom_device_get_buttons (GsdWacomDevice *device);
GsdWacomTabletButton *gsd_wacom_device_get_button (GsdWacomDevice *device,
int button,
GtkDirectionType *dir);
-int gsd_wacom_device_set_next_mode (GsdWacomDevice *device,
- int group_id);
+int gsd_wacom_device_set_next_mode (GsdWacomDevice *device,
+ GsdWacomTabletButton *button);
GsdWacomRotation gsd_wacom_device_rotation_name_to_type (const char *rotation);
const char * gsd_wacom_device_rotation_type_to_name (GsdWacomRotation type);
diff --git a/plugins/wacom/gsd-wacom-manager.c b/plugins/wacom/gsd-wacom-manager.c
index 8890988..bcd14e2 100644
--- a/plugins/wacom/gsd-wacom-manager.c
+++ b/plugins/wacom/gsd-wacom-manager.c
@@ -1192,7 +1192,7 @@ filter_button_events (XEvent *xevent,
if (xiev->evtype == XI_ButtonRelease)
return GDK_FILTER_REMOVE;
- new_mode = gsd_wacom_device_set_next_mode (device, wbutton->group_id);
+ new_mode = gsd_wacom_device_set_next_mode (device, wbutton);
set_led (device, wbutton->group_id, new_mode);
return GDK_FILTER_REMOVE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]