summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2024-02-13 01:12:24 -0500
committerDudemanguy <random342@airmail.cc>2024-02-17 16:09:41 +0000
commitb441a5dd1ff6de9dba5eedac6a014ca11d97d8f2 (patch)
treeb608e7158d6bb864fe01033e42a8209de88ccba9
parenta6ae2e7e602a634955c541b2d186c6dd23c1e9c3 (diff)
downloadmpv-b441a5dd1ff6de9dba5eedac6a014ca11d97d8f2.tar.bz2
mpv-b441a5dd1ff6de9dba5eedac6a014ca11d97d8f2.tar.xz
wayland_common: properly determine has_keyboard_input
Track has_keyboard_input per seat and consider mpv having keyboard input if at least one seat has keyboard input.
-rw-r--r--video/out/wayland_common.c18
-rw-r--r--video/out/wayland_common.h1
2 files changed, 14 insertions, 5 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 5a18e2d950..b478e1a24e 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -208,6 +208,7 @@ struct vo_wayland_seat {
double axis_value_horizontal;
int32_t axis_value120_horizontal;
bool axis_value120_scroll;
+ bool has_keyboard_input;
struct wl_list link;
};
@@ -533,7 +534,7 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *wl_keyboard,
{
struct vo_wayland_seat *s = data;
struct vo_wayland_state *wl = s->wl;
- wl->has_keyboard_input = true;
+ s->has_keyboard_input = true;
guess_focus(wl);
}
@@ -542,7 +543,7 @@ static void keyboard_handle_leave(void *data, struct wl_keyboard *wl_keyboard,
{
struct vo_wayland_seat *s = data;
struct vo_wayland_state *wl = s->wl;
- wl->has_keyboard_input = false;
+ s->has_keyboard_input = false;
s->keyboard_code = 0;
s->mpkey = 0;
s->mpmod = 0;
@@ -1776,8 +1777,17 @@ static void guess_focus(struct vo_wayland_state *wl)
{
// We can't actually know if the window is focused or not in wayland,
// so just guess it with some common sense. Obviously won't work if
- // the user has no keyboard.
- if ((!wl->focused && wl->activated && wl->has_keyboard_input) ||
+ // the user has no keyboard. We flag has_keyboard_input if
+ // at least one seat has it.
+ bool has_keyboard_input = false;
+ struct vo_wayland_seat *seat;
+ wl_list_for_each(seat, &wl->seat_list, link) {
+ if (seat->has_keyboard_input) {
+ has_keyboard_input = true;
+ }
+ }
+
+ if ((!wl->focused && wl->activated && has_keyboard_input) ||
(wl->focused && !wl->activated))
{
wl->focused = !wl->focused;
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index e5f676e399..befc7edc8b 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -74,7 +74,6 @@ struct vo_wayland_state {
bool configured;
bool focused;
bool frame_wait;
- bool has_keyboard_input;
bool hidden;
bool initial_size_hint;
bool locked_size;