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.
This commit is contained in:
Dudemanguy 2023-01-01 11:16:31 -06:00 committed by sfan5
parent 6076691b94
commit 5436852bf5
1 changed files with 4 additions and 3 deletions

View File

@ -1698,6 +1698,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 },
@ -1912,6 +1915,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),
@ -2284,9 +2288,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);