From 5e3eb03ecfc604652705d56c778c08ccead9e64e Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Wed, 27 Nov 2019 07:36:35 +0800 Subject: wayland: make the edge grab zone width user configurable Rather than hard-coding the edge grab zone width, we can make it user configurable. It seems worthwhile to have separate configs for pointer and touch usage as the defaults should be different, and a user might have both input methods in use. --- video/out/wayland_common.c | 11 ++++++----- video/out/wayland_common.h | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index c9da326b5a..990a3c500f 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -47,18 +47,19 @@ const struct m_sub_options wayland_conf = { .opts = (const struct m_option[]) { OPT_INTRANGE("wayland-frame-wait-offset", frame_offset, 0, -500, 3000), OPT_FLAG("wayland-disable-vsync", disable_vsync, 0), + OPT_INTRANGE("wayland-edge-pixels-pointer", edge_pixels_pointer, 10, 0, INT_MAX), + OPT_INTRANGE("wayland-edge-pixels-touch", edge_pixels_touch, 64, 0, INT_MAX), {0}, }, .size = sizeof(struct wayland_opts), .defaults = &(struct wayland_opts) { .frame_offset = 1000, .disable_vsync = false, + .edge_pixels_pointer = 10, + .edge_pixels_touch = 64, }, }; -#define POINTER_EDGE_PIXELS 5 -#define TOUCH_EDGE_PIXELS 64 - static void xdg_wm_base_ping(void *data, struct xdg_wm_base *wm_base, uint32_t serial) { xdg_wm_base_pong(wm_base, serial); @@ -246,7 +247,7 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer, // Implement an edge resize zone if there are no decorations if (!wl->xdg_toplevel_decoration && check_for_resize(wl, wl->mouse_unscaled_x, wl->mouse_unscaled_y, - POINTER_EDGE_PIXELS, &edges)) + wl->opts->edge_pixels_pointer, &edges)) xdg_toplevel_resize(wl->xdg_toplevel, wl->seat, serial, edges); else window_move(wl, serial); @@ -291,7 +292,7 @@ static void touch_handle_down(void *data, struct wl_touch *wl_touch, struct vo_wayland_state *wl = data; enum xdg_toplevel_resize_edge edge; - if (check_for_resize(wl, x_w, y_w, TOUCH_EDGE_PIXELS, &edge)) { + if (check_for_resize(wl, x_w, y_w, wl->opts->edge_pixels_touch, &edge)) { wl->touch_entries = 0; xdg_toplevel_resize(wl->xdg_toplevel, wl->seat, serial, edge); return; diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h index 2ca7d86a96..567a38fd41 100644 --- a/video/out/wayland_common.h +++ b/video/out/wayland_common.h @@ -28,6 +28,8 @@ struct wayland_opts { int frame_offset; int disable_vsync; + int edge_pixels_pointer; + int edge_pixels_touch; }; struct vo_wayland_sync { -- cgit v1.2.3