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
This commit is contained in:
Carlos Garnacho 2016-12-28 12:10:23 +01:00
parent ff453c1143
commit 7e3fbfbdd2
2 changed files with 45 additions and 0 deletions

View File

@ -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)

View File

@ -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);
}