summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2016-06-22 15:56:08 +0200
committerCarlos Garnacho <carlosg@gnome.org>2016-07-20 19:26:31 +0200
commite2b8b0bf67c3835795266434e87ed859aa2a97a6 (patch)
tree97f0598cc574a11fbca9259fd98050001552c1e6
parentec2ab05d8eb31726353b123fd200b166799e7ec7 (diff)
downloadmutter-e2b8b0bf67c3835795266434e87ed859aa2a97a6.tar.gz
wayland: Implement stylus button actions
Those just send different BTN_ keycodes.
-rw-r--r--src/wayland/meta-wayland-tablet-tool.c72
1 files changed, 58 insertions, 14 deletions
diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c
index 8e69f7974..905868666 100644
--- a/src/wayland/meta-wayland-tablet-tool.c
+++ b/src/wayland/meta-wayland-tablet-tool.c
@@ -36,9 +36,11 @@
#include "meta-wayland-tablet.h"
#include "meta-wayland-tablet-seat.h"
#include "meta-wayland-tablet-tool.h"
+#include "backends/meta-input-settings-private.h"
#ifdef HAVE_NATIVE_BACKEND
#include "backends/native/meta-backend-native.h"
+#include <linux/input-event-codes.h>
#endif
#define TABLET_AXIS_MAX 65535
@@ -651,6 +653,61 @@ broadcast_up (MetaWaylandTabletTool *tool,
}
}
+static guint32
+translate_button_action (MetaWaylandTabletTool *tool,
+ const ClutterEvent *event)
+{
+ MetaInputSettings *input_settings;
+ GDesktopStylusButtonAction action;
+
+ input_settings = meta_input_settings_get ();
+
+ if (input_settings)
+ {
+ ClutterInputDevice *device;
+
+ device = clutter_event_get_source_device (event);
+ action = meta_input_settings_get_stylus_button_action (input_settings,
+ tool->device_tool,
+ device,
+ event->button.button);
+ }
+ else
+ {
+ action = G_DESKTOP_STYLUS_BUTTON_ACTION_DEFAULT;
+ }
+
+ switch (action)
+ {
+ case G_DESKTOP_STYLUS_BUTTON_ACTION_MIDDLE:
+ return BTN_STYLUS;
+ case G_DESKTOP_STYLUS_BUTTON_ACTION_RIGHT:
+ return BTN_STYLUS2;
+ case G_DESKTOP_STYLUS_BUTTON_ACTION_BACK:
+ return BTN_BACK;
+ case G_DESKTOP_STYLUS_BUTTON_ACTION_FORWARD:
+ return BTN_FORWARD;
+ case G_DESKTOP_STYLUS_BUTTON_ACTION_DEFAULT:
+ default:
+ {
+#ifdef HAVE_NATIVE_BACKEND
+ MetaBackend *backend = meta_get_backend ();
+ if (META_IS_BACKEND_NATIVE (backend))
+ {
+ return clutter_evdev_event_get_event_code (event);
+ }
+ else
+#endif
+ {
+ /* We can't do much better here, there's several
+ * different BTN_ ranges to cover.
+ */
+ return event->button.button;
+ }
+ }
+ }
+}
+
static void
broadcast_button (MetaWaylandTabletTool *tool,
const ClutterEvent *event)
@@ -658,22 +715,9 @@ broadcast_button (MetaWaylandTabletTool *tool,
struct wl_resource *resource;
guint32 button;
+ button = translate_button_action (tool, event);
tool->button_serial = wl_display_next_serial (tool->seat->manager->wl_display);
-#ifdef HAVE_NATIVE_BACKEND
- MetaBackend *backend = meta_get_backend ();
- if (META_IS_BACKEND_NATIVE (backend))
- button = clutter_evdev_event_get_event_code (event);
- else
-#endif
- {
- /* We can't do much better here, there's several
- * different BTN_ ranges to cover.
- */
- button = event->button.button;
- }
-
-
wl_resource_for_each (resource, &tool->focus_resource_list)
{
zwp_tablet_tool_v2_send_button (resource, tool->button_serial, button,