[gnome-control-center] wacom: Update from gnome-settings-daemon
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] wacom: Update from gnome-settings-daemon
- Date: Thu, 20 Dec 2012 10:21:40 +0000 (UTC)
commit 7cac7eeb755d11c34481aea66682d0abeef524a2
Author: Bastien Nocera <hadess hadess net>
Date: Thu Dec 20 10:37:39 2012 +0100
wacom: Update from gnome-settings-daemon
panels/wacom/gsd-input-helper.c | 10 ++-
panels/wacom/gsd-input-helper.h | 1 +
panels/wacom/gsd-wacom-device.c | 188 +++++++++++++++++++++++++++++++++------
panels/wacom/gsd-wacom-device.h | 29 ++++++-
4 files changed, 195 insertions(+), 33 deletions(-)
---
diff --git a/panels/wacom/gsd-input-helper.c b/panels/wacom/gsd-input-helper.c
index cbf757d..b81189d 100644
--- a/panels/wacom/gsd-input-helper.c
+++ b/panels/wacom/gsd-input-helper.c
@@ -191,6 +191,13 @@ device_info_is_touchscreen (XDeviceInfo *device_info)
}
gboolean
+device_info_is_tablet (XDeviceInfo *device_info)
+{
+ /* Note that this doesn't match Wacom tablets */
+ return (device_info->type == XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XI_TABLET, False));
+}
+
+gboolean
device_info_is_mouse (XDeviceInfo *device_info)
{
return (device_info->type == XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XI_MOUSE, False));
@@ -507,7 +514,7 @@ run_custom_command (GdkDevice *device,
argv[2] = (char *) custom_command_to_string (command);
argv[3] = "-i";
argv[4] = g_strdup_printf ("%d", id);
- argv[5] = g_strdup_printf ("%s", gdk_device_get_name (device));
+ argv[5] = (char*) gdk_device_get_name (device);
argv[6] = NULL;
rc = g_spawn_sync (g_get_home_dir (), argv, NULL, G_SPAWN_SEARCH_PATH,
@@ -518,7 +525,6 @@ run_custom_command (GdkDevice *device,
g_free (argv[0]);
g_free (argv[4]);
- g_free (argv[5]);
return (exit_status == 1);
}
diff --git a/panels/wacom/gsd-input-helper.h b/panels/wacom/gsd-input-helper.h
index f86d2a4..b93b90c 100644
--- a/panels/wacom/gsd-input-helper.h
+++ b/panels/wacom/gsd-input-helper.h
@@ -61,6 +61,7 @@ gboolean device_is_touchpad (XDevice *xdevice);
gboolean device_info_is_touchpad (XDeviceInfo *device_info);
gboolean device_info_is_touchscreen (XDeviceInfo *device_info);
+gboolean device_info_is_tablet (XDeviceInfo *device_info);
gboolean device_info_is_mouse (XDeviceInfo *device_info);
gboolean device_info_is_trackball (XDeviceInfo *device_info);
diff --git a/panels/wacom/gsd-wacom-device.c b/panels/wacom/gsd-wacom-device.c
index 1a78530..28d6e4d 100644
--- a/panels/wacom/gsd-wacom-device.c
+++ b/panels/wacom/gsd-wacom-device.c
@@ -255,8 +255,10 @@ gsd_wacom_tablet_button_new (const char *name,
const char *id,
const char *settings_path,
GsdWacomTabletButtonType type,
+ GsdWacomTabletButtonPos pos,
int group_id,
- int idx)
+ int idx,
+ int status_led)
{
GsdWacomTabletButton *ret;
@@ -273,6 +275,8 @@ gsd_wacom_tablet_button_new (const char *name,
ret->group_id = group_id;
ret->idx = idx;
ret->type = type;
+ ret->pos = pos;
+ ret->status_led = status_led;
return ret;
}
@@ -328,9 +332,11 @@ struct GsdWacomDevicePrivate
char *path;
char *machine_id;
const char *icon_name;
+ char *layout_path;
char *tool_name;
gboolean reversible;
gboolean is_screen_tablet;
+ gboolean is_isd; /* integrated system device */
gboolean is_fallback;
GList *styli;
GsdWacomStylus *last_stylus;
@@ -775,12 +781,10 @@ find_output (GnomeRRScreen *rr_screen,
if (rr_output == NULL) {
if (gsd_wacom_device_is_screen_tablet (device)) {
rr_output = find_output_by_heuristic (rr_screen, device);
- if (rr_output == NULL) {
+ if (rr_output == NULL)
g_warning ("No fuzzy match based on heuristics was found.");
- } else {
+ else
g_warning ("Automatically mapping tablet to heuristically-found display.");
- set_display_by_output (device, rr_output);
- }
}
}
@@ -956,21 +960,78 @@ add_stylus_to_device (GsdWacomDevice *device,
}
int
-gsd_wacom_device_set_next_mode (GsdWacomDevice *device,
+gsd_wacom_device_get_num_modes (GsdWacomDevice *device,
int group_id)
{
- int current_idx;
int num_modes;
g_return_val_if_fail (GSD_IS_WACOM_DEVICE (device), -1);
+ num_modes = GPOINTER_TO_INT (g_hash_table_lookup (device->priv->num_modes, GINT_TO_POINTER(group_id)));
+
+ return num_modes;
+}
+
+int
+gsd_wacom_device_get_current_mode (GsdWacomDevice *device,
+ int group_id)
+{
+ int current_idx;
+
+ 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++;
+ return current_idx;
+}
+int
+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);
+
+ 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 = gsd_wacom_device_get_current_mode (device, group_id);
+ /* gsd_wacom_device_get_current_mode() returns -1 when the mode doesn't exist */
+ g_return_val_if_fail (current_idx > 0, -1);
+
+ current_idx++;
+ }
+
if (current_idx > num_modes)
current_idx = 1;
@@ -1015,9 +1076,11 @@ gsd_wacom_device_add_ring_modes (WacomDevice *wacom_device,
l = g_list_append (l, gsd_wacom_tablet_button_new (_("Left Ring"),
"left-ring-mode-1",
settings_path,
- WACOM_TABLET_BUTTON_TYPE_ELEVATOR,
+ WACOM_TABLET_BUTTON_TYPE_RING,
+ WACOM_TABLET_BUTTON_POS_LEFT,
group,
- 0));
+ 0,
+ GSD_WACOM_NO_LED));
} else {
for (i = 1; i <= num_modes; i++) {
name = g_strdup_printf (_("Left Ring Mode #%d"), i);
@@ -1025,9 +1088,11 @@ gsd_wacom_device_add_ring_modes (WacomDevice *wacom_device,
l = g_list_append (l, gsd_wacom_tablet_button_new (name,
id,
settings_path,
- WACOM_TABLET_BUTTON_TYPE_ELEVATOR,
+ WACOM_TABLET_BUTTON_TYPE_RING,
+ WACOM_TABLET_BUTTON_POS_LEFT,
group,
- i - 1));
+ i - 1,
+ GSD_WACOM_NO_LED));
g_free (name);
g_free (id);
}
@@ -1040,9 +1105,11 @@ gsd_wacom_device_add_ring_modes (WacomDevice *wacom_device,
l = g_list_append (l, gsd_wacom_tablet_button_new (_("Right Ring"),
"right-ring-mode-1",
settings_path,
- WACOM_TABLET_BUTTON_TYPE_ELEVATOR,
+ WACOM_TABLET_BUTTON_TYPE_RING,
+ WACOM_TABLET_BUTTON_POS_RIGHT,
group,
- 0));
+ 0,
+ GSD_WACOM_NO_LED));
} else {
for (i = 1; i <= num_modes; i++) {
name = g_strdup_printf (_("Right Ring Mode #%d"), i);
@@ -1050,9 +1117,11 @@ gsd_wacom_device_add_ring_modes (WacomDevice *wacom_device,
l = g_list_append (l, gsd_wacom_tablet_button_new (name,
id,
settings_path,
- WACOM_TABLET_BUTTON_TYPE_ELEVATOR,
+ WACOM_TABLET_BUTTON_TYPE_RING,
+ WACOM_TABLET_BUTTON_POS_RIGHT,
group,
- i - 1));
+ i - 1,
+ GSD_WACOM_NO_LED));
g_free (name);
g_free (id);
}
@@ -1087,9 +1156,11 @@ gsd_wacom_device_add_strip_modes (WacomDevice *wacom_device,
l = g_list_append (l, gsd_wacom_tablet_button_new (_("Left Touchstrip"),
"left-strip-mode-1",
settings_path,
- WACOM_TABLET_BUTTON_TYPE_ELEVATOR,
+ WACOM_TABLET_BUTTON_TYPE_STRIP,
+ WACOM_TABLET_BUTTON_POS_LEFT,
group,
- 0));
+ 0,
+ GSD_WACOM_NO_LED));
} else {
for (i = 1; i <= num_modes; i++) {
name = g_strdup_printf (_("Left Touchstrip Mode #%d"), i);
@@ -1097,9 +1168,11 @@ gsd_wacom_device_add_strip_modes (WacomDevice *wacom_device,
l = g_list_append (l, gsd_wacom_tablet_button_new (name,
id,
settings_path,
- WACOM_TABLET_BUTTON_TYPE_ELEVATOR,
+ WACOM_TABLET_BUTTON_TYPE_STRIP,
+ WACOM_TABLET_BUTTON_POS_LEFT,
group,
- i - 1));
+ i - 1,
+ GSD_WACOM_NO_LED));
g_free (name);
g_free (id);
}
@@ -1112,9 +1185,11 @@ gsd_wacom_device_add_strip_modes (WacomDevice *wacom_device,
l = g_list_append (l, gsd_wacom_tablet_button_new (_("Right Touchstrip"),
"right-strip-mode-1",
settings_path,
- WACOM_TABLET_BUTTON_TYPE_ELEVATOR,
+ WACOM_TABLET_BUTTON_TYPE_STRIP,
+ WACOM_TABLET_BUTTON_POS_RIGHT,
group,
- 0));
+ 0,
+ GSD_WACOM_NO_LED));
} else {
for (i = 1; i <= num_modes; i++) {
name = g_strdup_printf (_("Right Touchstrip Mode #%d"), i);
@@ -1122,9 +1197,11 @@ gsd_wacom_device_add_strip_modes (WacomDevice *wacom_device,
l = g_list_append (l, gsd_wacom_tablet_button_new (name,
id,
settings_path,
- WACOM_TABLET_BUTTON_TYPE_ELEVATOR,
+ WACOM_TABLET_BUTTON_TYPE_STRIP,
+ WACOM_TABLET_BUTTON_POS_RIGHT,
group,
- i - 1));
+ i - 1,
+ GSD_WACOM_NO_LED));
g_free (name);
g_free (id);
}
@@ -1155,6 +1232,23 @@ gsd_wacom_device_modeswitch_name (WacomButtonFlags flags,
return g_strdup_printf (_("Mode Switch #%d"), button_num);
}
+static GsdWacomTabletButtonType
+gsd_wacom_device_button_pos (WacomButtonFlags flags)
+{
+ if (flags & WACOM_BUTTON_POSITION_LEFT)
+ return WACOM_TABLET_BUTTON_POS_LEFT;
+ else if (flags & WACOM_BUTTON_POSITION_RIGHT)
+ return WACOM_TABLET_BUTTON_POS_RIGHT;
+ else if (flags & WACOM_BUTTON_POSITION_TOP)
+ return WACOM_TABLET_BUTTON_POS_TOP;
+ else if (flags & WACOM_BUTTON_POSITION_BOTTOM)
+ return WACOM_TABLET_BUTTON_POS_BOTTOM;
+
+ g_warning ("Unhandled button position");
+
+ return WACOM_TABLET_BUTTON_POS_UNDEF;
+}
+
static GList *
gsd_wacom_device_add_buttons_dir (WacomDevice *wacom_device,
const char *settings_path,
@@ -1181,7 +1275,14 @@ gsd_wacom_device_add_buttons_dir (WacomDevice *wacom_device,
name = g_strdup_printf (button_str, button_num++);
id = g_strdup_printf ("%s%c", button_str_id, i);
- l = g_list_append (l, gsd_wacom_tablet_button_new (name, id, settings_path, WACOM_TABLET_BUTTON_TYPE_NORMAL, flags_to_group (flags), -1));
+ l = g_list_append (l, gsd_wacom_tablet_button_new (name,
+ id,
+ settings_path,
+ WACOM_TABLET_BUTTON_TYPE_NORMAL,
+ gsd_wacom_device_button_pos (flags),
+ flags_to_group (flags),
+ -1,
+ GSD_WACOM_NO_LED));
g_free (name);
g_free (id);
}
@@ -1190,6 +1291,7 @@ gsd_wacom_device_add_buttons_dir (WacomDevice *wacom_device,
for (i = 'A'; i < 'A' + num_buttons; i++) {
WacomButtonFlags flags;
char *name, *id;
+ int status_led;
flags = libwacom_get_button_flag (wacom_device, i);
if (!(flags & direction))
@@ -1200,7 +1302,15 @@ gsd_wacom_device_add_buttons_dir (WacomDevice *wacom_device,
name = gsd_wacom_device_modeswitch_name (flags, button_num++);
id = g_strdup_printf ("%s%c", button_str_id, i);
- l = g_list_append (l, gsd_wacom_tablet_button_new (name, id, settings_path, WACOM_TABLET_BUTTON_TYPE_HARDCODED, flags_to_group (flags), -1));
+ status_led = libwacom_get_button_led_group (wacom_device, i);
+ l = g_list_append (l, gsd_wacom_tablet_button_new (name,
+ id,
+ settings_path,
+ WACOM_TABLET_BUTTON_TYPE_HARDCODED,
+ gsd_wacom_device_button_pos (flags),
+ flags_to_group (flags),
+ -1,
+ status_led));
g_free (name);
g_free (id);
}
@@ -1292,6 +1402,7 @@ gsd_wacom_device_update_from_db (GsdWacomDevice *device,
const char *identifier)
{
char *settings_path;
+ WacomIntegrationFlags integration_flags;
settings_path = g_strdup_printf (WACOM_DEVICE_CONFIG_BASE,
device->priv->machine_id,
@@ -1300,10 +1411,13 @@ gsd_wacom_device_update_from_db (GsdWacomDevice *device,
settings_path);
device->priv->name = g_strdup (libwacom_get_name (wacom_device));
+ device->priv->layout_path = g_strdup (libwacom_get_layout_filename (wacom_device));
device->priv->reversible = libwacom_is_reversible (wacom_device);
- device->priv->is_screen_tablet = libwacom_is_builtin (wacom_device);
+ integration_flags = libwacom_get_integration_flags (wacom_device);
+ device->priv->is_screen_tablet = (integration_flags & WACOM_DEVICE_INTEGRATED_DISPLAY);
+ device->priv->is_isd = (integration_flags & WACOM_DEVICE_INTEGRATED_SYSTEM);
if (device->priv->is_screen_tablet) {
- if (libwacom_get_class (wacom_device) == WCLASS_CINTIQ)
+ if (!device->priv->is_isd)
device->priv->icon_name = "wacom-tablet-cintiq";
else
device->priv->icon_name = "wacom-tablet-pc";
@@ -1547,6 +1661,8 @@ gsd_wacom_device_finalize (GObject *object)
p->num_modes = NULL;
}
+ g_clear_pointer (&p->layout_path, g_free);
+
gdk_window_remove_filter (NULL,
(GdkFilterFunc) filter_events,
device);
@@ -1596,6 +1712,14 @@ gsd_wacom_device_get_name (GsdWacomDevice *device)
}
const char *
+gsd_wacom_device_get_layout_path (GsdWacomDevice *device)
+{
+ g_return_val_if_fail (GSD_IS_WACOM_DEVICE (device), NULL);
+
+ return device->priv->layout_path;
+}
+
+const char *
gsd_wacom_device_get_path (GsdWacomDevice *device)
{
g_return_val_if_fail (GSD_IS_WACOM_DEVICE (device), NULL);
@@ -1636,6 +1760,14 @@ gsd_wacom_device_is_screen_tablet (GsdWacomDevice *device)
}
gboolean
+gsd_wacom_device_is_isd (GsdWacomDevice *device)
+{
+ g_return_val_if_fail (GSD_IS_WACOM_DEVICE (device), FALSE);
+
+ return device->priv->is_isd;
+}
+
+gboolean
gsd_wacom_device_is_fallback (GsdWacomDevice *device)
{
g_return_val_if_fail (GSD_IS_WACOM_DEVICE (device), FALSE);
diff --git a/panels/wacom/gsd-wacom-device.h b/panels/wacom/gsd-wacom-device.h
index 24e6e06..335945f 100644
--- a/panels/wacom/gsd-wacom-device.h
+++ b/panels/wacom/gsd-wacom-device.h
@@ -93,19 +93,36 @@ GsdWacomStylusType gsd_wacom_stylus_get_stylus_type (GsdWacomStylus *stylus);
/* Tablet Buttons */
typedef enum {
WACOM_TABLET_BUTTON_TYPE_NORMAL,
- WACOM_TABLET_BUTTON_TYPE_ELEVATOR,
+ WACOM_TABLET_BUTTON_TYPE_STRIP,
+ WACOM_TABLET_BUTTON_TYPE_RING,
WACOM_TABLET_BUTTON_TYPE_HARDCODED
} GsdWacomTabletButtonType;
+/*
+ * Positions of the buttons on the tablet in default right-handed mode
+ * (ie with no rotation applied).
+ */
+typedef enum {
+ WACOM_TABLET_BUTTON_POS_UNDEF = 0,
+ WACOM_TABLET_BUTTON_POS_LEFT,
+ WACOM_TABLET_BUTTON_POS_RIGHT,
+ WACOM_TABLET_BUTTON_POS_TOP,
+ WACOM_TABLET_BUTTON_POS_BOTTOM
+} GsdWacomTabletButtonPos;
+
#define MAX_GROUP_ID 4
+#define GSD_WACOM_NO_LED -1
+
typedef struct
{
char *name;
char *id;
GSettings *settings;
GsdWacomTabletButtonType type;
+ GsdWacomTabletButtonPos pos;
int group_id, idx;
+ int status_led;
} GsdWacomTabletButton;
void gsd_wacom_tablet_button_free (GsdWacomTabletButton *button);
@@ -137,11 +154,13 @@ GsdWacomRotation gsd_wacom_device_get_display_rotation (GsdWacomDevice *device);
GsdWacomDevice * gsd_wacom_device_new (GdkDevice *device);
GList * gsd_wacom_device_list_styli (GsdWacomDevice *device);
const char * gsd_wacom_device_get_name (GsdWacomDevice *device);
+const char * gsd_wacom_device_get_layout_path (GsdWacomDevice *device);
const char * gsd_wacom_device_get_path (GsdWacomDevice *device);
const char * gsd_wacom_device_get_icon_name (GsdWacomDevice *device);
const char * gsd_wacom_device_get_tool_name (GsdWacomDevice *device);
gboolean gsd_wacom_device_reversible (GsdWacomDevice *device);
gboolean gsd_wacom_device_is_screen_tablet (GsdWacomDevice *device);
+gboolean gsd_wacom_device_is_isd (GsdWacomDevice *device);
gboolean gsd_wacom_device_is_fallback (GsdWacomDevice *device);
gint gsd_wacom_device_get_num_strips (GsdWacomDevice *device);
gint gsd_wacom_device_get_num_rings (GsdWacomDevice *device);
@@ -158,8 +177,12 @@ 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_get_num_modes (GsdWacomDevice *device,
+ int group_id);
+int gsd_wacom_device_get_current_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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]