summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2021-08-07 22:05:05 -0500
committerDudemanguy <random342@airmail.cc>2021-08-08 03:42:26 +0000
commit8300830951e2b0b90b22fc7d33b7556ed05e139c (patch)
tree0d4969557a8cfebff8ae5264d3d0040873d910c5
parent84362e820e88dd7348b2fa35dd640288616c1fb5 (diff)
downloadmpv-8300830951e2b0b90b22fc7d33b7556ed05e139c.tar.bz2
mpv-8300830951e2b0b90b22fc7d33b7556ed05e139c.tar.xz
wayland: improve behavior with touch events
There's currently some touch related code in mpv wayland, but clearly nobody actually uses because it's a broken mess. Initially an attempt to distinguish between two finger touches and one finger touch was made, but there's not a good way to make this work. For whatever reason, initiating either xdg_toplevel_resize or xdg_toplevel_move blocks any other touch events from occurring (at least in plasma). Trying to call these functions anywhere else is not really useful since the serial will be invalid outside of the touch down events (well it would work in the touch up event but that's just silly). Anyways, let's just make this work sanely. Eliminate the touch entries variable completely because it's pointless. Only one finger event is ever considered at a time. Touches besides the initial one are all ignored. If a user touches and drags within the touch edge radius, then a resize event occurs. If the user touches and drags elsewhere on the window, a move event occurs. A single tap displays the osc (which is clickable if you tap again). A double tap toggles fullscreen. Additionally, the default touch edge radius of 64 pixels is way too big (at least I think so). Cut this in half to 32 which feels a lot better (on a pinephone using plasma mobile anyway).
-rw-r--r--DOCS/man/options.rst2
-rw-r--r--video/out/wayland_common.c27
-rw-r--r--video/out/wayland_common.h1
3 files changed, 10 insertions, 20 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index c08161f338..731d155390 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -5506,7 +5506,7 @@ The following video options are currently all specific to ``--vo=gpu`` and
there are no server side decorations from the compositor.
``--wayland-edge-pixels-touch=<value>``
- Defines the size of an edge border (default: 64) to initiate client side
+ Defines the size of an edge border (default: 32) to initiate client side
resizes events in the wayland contexts with touch events.
``--spirv-compiler=<compiler>``
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index d472a68ed3..8e03be84ab 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -115,7 +115,7 @@ const struct m_sub_options wayland_conf = {
.defaults = &(struct wayland_opts) {
.disable_vsync = false,
.edge_pixels_pointer = 10,
- .edge_pixels_touch = 64,
+ .edge_pixels_touch = 32,
},
};
@@ -283,33 +283,24 @@ 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, wl->opts->edge_pixels_touch, &edge)) {
- wl->touch_entries = 0;
- xdg_toplevel_resize(wl->xdg_toplevel, wl->seat, serial, edge);
- return;
- } else if (wl->touch_entries) {
- wl->touch_entries = 0;
- xdg_toplevel_move(wl->xdg_toplevel, wl->seat, serial);
- return;
- }
-
- wl->touch_entries = 1;
-
wl->mouse_x = wl_fixed_to_int(x_w) * wl->scaling;
wl->mouse_y = wl_fixed_to_int(y_w) * wl->scaling;
mp_input_set_mouse_pos(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y);
mp_input_put_key(wl->vo->input_ctx, MP_MBTN_LEFT | MP_KEY_STATE_DOWN);
+
+ enum xdg_toplevel_resize_edge edge;
+ if (check_for_resize(wl, x_w, y_w, wl->opts->edge_pixels_touch, &edge)) {
+ xdg_toplevel_resize(wl->xdg_toplevel, wl->seat, serial, edge);
+ } else {
+ xdg_toplevel_move(wl->xdg_toplevel, wl->seat, serial);
+ }
}
static void touch_handle_up(void *data, struct wl_touch *wl_touch,
uint32_t serial, uint32_t time, int32_t id)
{
struct vo_wayland_state *wl = data;
-
- wl->touch_entries = 0;
-
mp_input_put_key(wl->vo->input_ctx, MP_MBTN_LEFT | MP_KEY_STATE_UP);
}
@@ -1122,7 +1113,7 @@ end:
static int check_for_resize(struct vo_wayland_state *wl, wl_fixed_t x_w, wl_fixed_t y_w,
int edge_pixels, enum xdg_toplevel_resize_edge *edge)
{
- if (wl->touch_entries || wl->vo_opts->fullscreen || wl->vo_opts->window_maximized)
+ if (wl->vo_opts->fullscreen || wl->vo_opts->window_maximized)
return 0;
int pos[2] = { wl_fixed_to_double(x_w), wl_fixed_to_double(y_w) };
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index b77bab462b..f833a8a0de 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -70,7 +70,6 @@ struct vo_wayland_state {
int pending_vo_events;
int scaling;
int timeout_count;
- int touch_entries;
int wakeup_pipe[2];
/* idle-inhibit */