From 7e3fbfbdd2a67a9b6e00031aa3098da6facb1291 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 28 Dec 2016 12:10:23 +0100 Subject: [PATCH] wayland: Notify tablet mode switches This will show a fancy OSD so the change is immediately visible. https://bugzilla.gnome.org/show_bug.cgi?id=771098 --- src/backends/meta-input-settings.c | 20 ++++++++++++++++++++ src/core/display.c | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c index 166e72897..bd3d84848 100644 --- a/src/backends/meta-input-settings.c +++ b/src/backends/meta-input-settings.c @@ -1692,8 +1692,28 @@ meta_input_settings_handle_pad_button (MetaInputSettings *input_settin pad = clutter_event_get_source_device ((ClutterEvent *) event); button = event->button; + mode = event->mode; + group = clutter_input_device_get_mode_switch_button_group (pad, button); is_press = event->type == CLUTTER_PAD_BUTTON_PRESS; + if (is_press && group >= 0) + { + guint n_modes = clutter_input_device_get_group_n_modes (pad, group); + const gchar *pretty_name = NULL; +#ifdef HAVE_LIBWACOM + MetaInputSettingsPrivate *priv; + DeviceMappingInfo *info; + + priv = meta_input_settings_get_instance_private (input_settings); + info = g_hash_table_lookup (priv->mappable_devices, pad); + + if (info && info->wacom_device) + pretty_name = libwacom_get_name (info->wacom_device); +#endif + meta_display_notify_pad_group_switch (meta_get_display (), pad, + pretty_name, group, mode, n_modes); + } + action = meta_input_settings_get_pad_button_action (input_settings, pad, button); switch (action) diff --git a/src/core/display.c b/src/core/display.c index 372457f32..080c3289e 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -3233,3 +3233,28 @@ meta_display_show_tablet_mapping_notification (MetaDisplay *display, meta_display_show_osd (display, lookup_tablet_monitor (display, pad), "input-tablet-symbolic", pretty_name); } + +void +meta_display_notify_pad_group_switch (MetaDisplay *display, + ClutterInputDevice *pad, + const gchar *pretty_name, + guint n_group, + guint n_mode, + guint n_modes) +{ + GString *message; + guint i; + + if (!pretty_name) + pretty_name = clutter_input_device_get_device_name (pad); + + message = g_string_new (pretty_name); + g_string_append_c (message, '\n'); + for (i = 0; i < n_modes; i++) + g_string_append (message, (i == n_mode) ? "⚫" : "⚪"); + + meta_display_show_osd (display, lookup_tablet_monitor (display, pad), + "input-tablet-symbolic", message->str); + + g_string_free (message, TRUE); +}