[mutter] backends: Add API to trigger actions related to pad buttons
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] backends: Add API to trigger actions related to pad buttons
- Date: Fri, 22 Jul 2016 12:01:48 +0000 (UTC)
commit 8e6244238d4b67a6004d5f83dd6f6c85d4b80cbd
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jun 22 18:51:27 2016 +0200
backends: Add API to trigger actions related to pad buttons
It does nothing at the moment, but can be hooked into MetaWaylandTabletPad
now. For X11, we need to trigger these for the pad events we receive from
the passive pad button grabs.
src/backends/meta-input-settings-private.h | 9 +++
src/backends/meta-input-settings.c | 79 ++++++++++++++++++++++++++++
2 files changed, 88 insertions(+), 0 deletions(-)
---
diff --git a/src/backends/meta-input-settings-private.h b/src/backends/meta-input-settings-private.h
index a9d448e..e41918e 100644
--- a/src/backends/meta-input-settings-private.h
+++ b/src/backends/meta-input-settings-private.h
@@ -115,6 +115,15 @@ gdouble meta_input_settings_translate_tablet_tool_pressure (M
ClutterInputDevice
*current_tablet,
gdouble
pressure);
+gboolean meta_input_settings_is_pad_button_grabbed (MetaInputSettings *input_settings,
+ ClutterInputDevice *pad,
+ guint button);
+
+gboolean meta_input_settings_handle_pad_button (MetaInputSettings *input_settings,
+ ClutterInputDevice *pad,
+ gboolean is_press,
+ guint button);
+
#ifdef HAVE_LIBWACOM
WacomDevice * meta_input_settings_get_tablet_wacom_device (MetaInputSettings *settings,
ClutterInputDevice *device);
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index 30a391d..fd6ca67 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -1036,6 +1036,25 @@ lookup_tool_settings (ClutterInputDeviceTool *tool,
return tool_settings;
}
+static GSettings *
+lookup_pad_button_settings (ClutterInputDevice *device,
+ guint button)
+{
+ const gchar *vendor, *product;
+ GSettings *settings;
+ gchar *path;
+
+ vendor = clutter_input_device_get_vendor_id (device);
+ product = clutter_input_device_get_product_id (device);
+ path = g_strdup_printf ("/org/gnome/desktop/peripherals/tablets/%s:%s/button%c/",
+ vendor, product, 'A' + button);
+ settings = g_settings_new_with_path ("org.gnome.desktop.peripherals.tablet.pad-button",
+ path);
+ g_free (path);
+
+ return settings;
+}
+
static void
monitors_changed_cb (MetaMonitorManager *monitor_manager,
MetaInputSettings *input_settings)
@@ -1300,6 +1319,26 @@ meta_input_settings_get_stylus_button_action (MetaInputSettings *input_sett
return G_DESKTOP_STYLUS_BUTTON_ACTION_DEFAULT;
}
+static GDesktopPadButtonAction
+meta_input_settings_get_pad_button_action (MetaInputSettings *input_settings,
+ ClutterInputDevice *pad,
+ guint button)
+{
+ GDesktopPadButtonAction action;
+ GSettings *settings;
+
+ g_return_val_if_fail (META_IS_INPUT_SETTINGS (input_settings),
+ G_DESKTOP_PAD_BUTTON_ACTION_NONE);
+ g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (pad),
+ G_DESKTOP_PAD_BUTTON_ACTION_NONE);
+
+ settings = lookup_pad_button_settings (pad, button);
+ action = g_settings_get_enum (settings, "action");
+ g_object_unref (settings);
+
+ return action;
+}
+
#ifdef HAVE_LIBWACOM
WacomDevice *
meta_input_settings_get_tablet_wacom_device (MetaInputSettings *settings,
@@ -1362,3 +1401,43 @@ meta_input_settings_translate_tablet_tool_pressure (MetaInputSettings *inpu
tool_settings->curve[3]);
return pressure;
}
+
+gboolean
+meta_input_settings_is_pad_button_grabbed (MetaInputSettings *input_settings,
+ ClutterInputDevice *pad,
+ guint button)
+{
+ g_return_val_if_fail (META_IS_INPUT_SETTINGS (input_settings), FALSE);
+ g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (pad), FALSE);
+ g_return_val_if_fail (clutter_input_device_get_device_type (pad) ==
+ CLUTTER_PAD_DEVICE, FALSE);
+
+ return (meta_input_settings_get_pad_button_action (input_settings, pad, button) !=
+ G_DESKTOP_PAD_BUTTON_ACTION_NONE);
+}
+
+gboolean
+meta_input_settings_handle_pad_button (MetaInputSettings *input_settings,
+ ClutterInputDevice *pad,
+ gboolean is_press,
+ guint button)
+{
+ GDesktopPadButtonAction action;
+
+ g_return_val_if_fail (META_IS_INPUT_SETTINGS (input_settings), FALSE);
+ g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (pad), FALSE);
+ g_return_val_if_fail (clutter_input_device_get_device_type (pad) ==
+ CLUTTER_PAD_DEVICE, FALSE);
+
+ action = meta_input_settings_get_pad_button_action (input_settings, pad, button);
+
+ switch (action)
+ {
+ case G_DESKTOP_PAD_BUTTON_ACTION_SWITCH_MONITOR:
+ case G_DESKTOP_PAD_BUTTON_ACTION_KEYBINDING:
+ case G_DESKTOP_PAD_BUTTON_ACTION_HELP:
+ case G_DESKTOP_PAD_BUTTON_ACTION_NONE:
+ default:
+ return FALSE;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]