From 4bbb1ccfd75aa5f2a5d4674d86433d334b9f22c8 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Sun, 1 Jan 2023 11:16:31 -0600 Subject: wayland: initalize display_fd as -1 In the event of a failed wayland initalization, the display_fd is actually 0 instead of -1 which would correctly indicate it doesn't exist. Also move the fd check inside vo_wayland_dispatch_events since that function shouldn't ever do anything if we don't actually have a display fd. --- video/out/wayland_common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'video/out') diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 43e8967003..09a6bdde6e 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -1724,6 +1724,9 @@ static void window_move(struct vo_wayland_state *wl, uint32_t serial) static void vo_wayland_dispatch_events(struct vo_wayland_state *wl, int nfds, int timeout) { + if (wl->display_fd == -1) + return; + struct pollfd fds[2] = { {.fd = wl->display_fd, .events = POLLIN }, {.fd = wl->wakeup_pipe[0], .events = POLLIN }, @@ -1947,6 +1950,7 @@ int vo_wayland_init(struct vo *vo) .refresh_interval = 0, .scaling = 1, .wakeup_pipe = {-1, -1}, + .display_fd = -1, .dnd_fd = -1, .cursor_visible = true, .vo_opts_cache = m_config_cache_alloc(wl, vo->global, &vo_sub_opts), @@ -2346,9 +2350,6 @@ void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us) { struct vo_wayland_state *wl = vo->wl; - if (wl->display_fd == -1) - return; - int64_t wait_us = until_time_us - mp_time_us(); int timeout_ms = MPCLAMP((wait_us + 999) / 1000, 0, 10000); -- cgit v1.2.3