tablet: Add binding to activate surfaces using the tablet tool
Based on patches from: Peter Hutterer <peter.hutterer@who-t.net> Lyude Paul <thatslyude@gmail.com> Bastian Farkas <bfarkas@de.adit-jv.com> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
This commit is contained in:
parent
017eac1a6b
commit
9eab270de5
desktop-shell
include/libweston
libweston
@ -3836,6 +3836,20 @@ touch_to_activate_binding(struct weston_touch *touch,
|
||||
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_activate_binding(struct weston_tablet_tool *tool,
|
||||
uint32_t button, void *data)
|
||||
{
|
||||
if (tool->grab != &tool->default_grab)
|
||||
return;
|
||||
if (tool->focus == NULL)
|
||||
return;
|
||||
|
||||
activate_binding(tool->seat, data, tool->focus,
|
||||
WESTON_ACTIVATE_FLAG_CLICKED |
|
||||
WESTON_ACTIVATE_FLAG_CONFIGURE);
|
||||
}
|
||||
|
||||
static void
|
||||
unfocus_all_seats(struct desktop_shell *shell)
|
||||
{
|
||||
@ -4939,6 +4953,8 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell)
|
||||
weston_compositor_add_touch_binding(ec, 0,
|
||||
touch_to_activate_binding,
|
||||
shell);
|
||||
weston_compositor_add_tablet_tool_binding(ec, BTN_TOUCH, 0,
|
||||
tablet_tool_activate_binding, shell);
|
||||
weston_compositor_add_key_binding(ec, KEY_BRIGHTNESSDOWN, 0,
|
||||
backlight_binding, ec);
|
||||
weston_compositor_add_key_binding(ec, KEY_BRIGHTNESSUP, 0,
|
||||
|
@ -1410,6 +1410,7 @@ struct weston_compositor {
|
||||
struct wl_list modifier_binding_list;
|
||||
struct wl_list button_binding_list;
|
||||
struct wl_list touch_binding_list;
|
||||
struct wl_list tablet_tool_binding_list;
|
||||
struct wl_list axis_binding_list;
|
||||
struct wl_list debug_binding_list;
|
||||
|
||||
@ -2089,6 +2090,16 @@ weston_compositor_add_touch_binding(struct weston_compositor *compositor,
|
||||
weston_touch_binding_handler_t binding,
|
||||
void *data);
|
||||
|
||||
typedef void (*weston_tablet_tool_binding_handler_t)(struct weston_tablet_tool *tool,
|
||||
uint32_t button,
|
||||
void *data);
|
||||
struct weston_binding *
|
||||
weston_compositor_add_tablet_tool_binding(struct weston_compositor *compositor,
|
||||
uint32_t button,
|
||||
enum weston_keyboard_modifier modifier,
|
||||
weston_tablet_tool_binding_handler_t binding,
|
||||
void *data);
|
||||
|
||||
typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
|
||||
const struct timespec *time,
|
||||
struct weston_pointer_axis_event *event,
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "libweston-internal.h"
|
||||
#include "shared/helpers.h"
|
||||
#include "shared/timespec-util.h"
|
||||
#include "tablet-unstable-v2-server-protocol.h"
|
||||
|
||||
struct weston_binding {
|
||||
uint32_t key;
|
||||
@ -137,6 +138,24 @@ weston_compositor_add_touch_binding(struct weston_compositor *compositor,
|
||||
return binding;
|
||||
}
|
||||
|
||||
WL_EXPORT struct weston_binding *
|
||||
weston_compositor_add_tablet_tool_binding(struct weston_compositor *compositor,
|
||||
uint32_t button, uint32_t modifier,
|
||||
weston_tablet_tool_binding_handler_t handler,
|
||||
void *data)
|
||||
{
|
||||
struct weston_binding *binding;
|
||||
|
||||
binding = weston_compositor_add_binding(compositor, 0, button, 0,
|
||||
modifier, handler, data);
|
||||
if (binding == NULL)
|
||||
return NULL;
|
||||
|
||||
wl_list_insert(compositor->tablet_tool_binding_list.prev, &binding->link);
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
WL_EXPORT struct weston_binding *
|
||||
weston_compositor_add_axis_binding(struct weston_compositor *compositor,
|
||||
uint32_t axis, uint32_t modifier,
|
||||
@ -395,6 +414,25 @@ weston_compositor_run_touch_binding(struct weston_compositor *compositor,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
weston_compositor_run_tablet_tool_binding(struct weston_compositor *compositor,
|
||||
struct weston_tablet_tool *tool,
|
||||
uint32_t button, uint32_t state_w)
|
||||
{
|
||||
enum zwp_tablet_tool_v2_button_state state = state_w;
|
||||
struct weston_binding *b;
|
||||
|
||||
if (state != ZWP_TABLET_TOOL_V2_BUTTON_STATE_PRESSED)
|
||||
return;
|
||||
|
||||
wl_list_for_each(b, &compositor->tablet_tool_binding_list, link) {
|
||||
if (b->modifier == tool->seat->modifier_state) {
|
||||
weston_tablet_tool_binding_handler_t handler = b->handler;
|
||||
handler(tool, button, b->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
weston_compositor_run_axis_binding(struct weston_compositor *compositor,
|
||||
struct weston_pointer *pointer,
|
||||
|
@ -8539,6 +8539,7 @@ weston_compositor_create(struct wl_display *display,
|
||||
wl_list_init(&ec->modifier_binding_list);
|
||||
wl_list_init(&ec->button_binding_list);
|
||||
wl_list_init(&ec->touch_binding_list);
|
||||
wl_list_init(&ec->tablet_tool_binding_list);
|
||||
wl_list_init(&ec->axis_binding_list);
|
||||
wl_list_init(&ec->debug_binding_list);
|
||||
wl_list_init(&ec->tablet_manager_resource_list);
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <linux/input.h>
|
||||
|
||||
#include "shared/helpers.h"
|
||||
#include "shared/os-compatibility.h"
|
||||
@ -3462,6 +3463,9 @@ notify_tablet_tool_button(struct weston_tablet_tool *tool,
|
||||
}
|
||||
|
||||
tool->grab_serial = wl_display_next_serial(compositor->wl_display);
|
||||
|
||||
weston_compositor_run_tablet_tool_binding(compositor, tool, button, state);
|
||||
|
||||
grab->interface->button(grab, time, button, state);
|
||||
}
|
||||
|
||||
@ -3478,6 +3482,8 @@ notify_tablet_tool_down(struct weston_tablet_tool *tool,
|
||||
tool->grab_serial = wl_display_get_serial(compositor->wl_display);
|
||||
tool->grab_pos = tool->pos;
|
||||
|
||||
weston_compositor_run_tablet_tool_binding(compositor, tool, BTN_TOUCH,
|
||||
ZWP_TABLET_TOOL_V2_BUTTON_STATE_PRESSED);
|
||||
grab->interface->down(grab, time);
|
||||
}
|
||||
|
||||
|
@ -224,6 +224,10 @@ weston_compositor_run_touch_binding(struct weston_compositor *compositor,
|
||||
const struct timespec *time,
|
||||
int touch_type);
|
||||
void
|
||||
weston_compositor_run_tablet_tool_binding(struct weston_compositor *compositor,
|
||||
struct weston_tablet_tool *tool,
|
||||
uint32_t button, uint32_t state_w);
|
||||
void
|
||||
weston_compositor_stack_plane(struct weston_compositor *ec,
|
||||
struct weston_plane *plane,
|
||||
struct weston_plane *above);
|
||||
|
Loading…
x
Reference in New Issue
Block a user