diff options
author | Rostislav Pehlivanov <atomnuker@gmail.com> | 2017-10-22 06:39:51 +0100 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2017-10-22 06:49:35 +0100 |
commit | f8aeda0da911851942efa22ac574f1196b4d96f0 (patch) | |
tree | e886bbe3377c1d8c062911c9b7975df4ced1d81f | |
parent | 78ef7fb766631df91b3f1b3392d9ce79d75ae811 (diff) | |
download | mpv-f8aeda0da911851942efa22ac574f1196b4d96f0.tar.bz2 mpv-f8aeda0da911851942efa22ac574f1196b4d96f0.tar.xz |
wayland_common: check monitor scale
Since we divide by it in a couple of places and compositors can be crazy,
its better to be safe than sorry.
Also checks cursor spawn durinig init (pointless since it does again on
cursor entry but its more correct).
-rw-r--r-- | video/out/wayland_common.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 0a7e6128d7..a0e734703b 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -68,7 +68,7 @@ static int spawn_cursor(struct vo_wayland_state *wl) return 0; } -static int set_cursor_visibility(struct vo_wayland_state *wl, int on) +static int set_cursor_visibility(struct vo_wayland_state *wl, bool on) { if (!wl->pointer) return VO_NOTAVAIL; @@ -100,7 +100,7 @@ static void pointer_handle_enter(void *data, struct wl_pointer *pointer, wl->pointer = pointer; wl->pointer_id = serial; - set_cursor_visibility(wl, 1); + set_cursor_visibility(wl, true); mp_input_put_key(wl->vo->input_ctx, MP_KEY_MOUSE_ENTER); } @@ -574,6 +574,10 @@ static void output_handle_scale(void* data, struct wl_output *wl_output, int32_t factor) { struct vo_wayland_output *output = data; + if (!factor) { + MP_ERR(output->wl, "Invalid output scale given by the compositor!\n"); + return; + } output->scale = factor; } @@ -790,6 +794,7 @@ static void registry_handle_add(void *data, struct wl_registry *reg, uint32_t id output->wl = wl; output->id = id; + output->scale = 1; output->output = wl_registry_bind(reg, id, &wl_output_interface, 2); wl_output_add_listener(output->output, &output_listener, output); @@ -1167,7 +1172,8 @@ int vo_wayland_reconfig(struct vo *vo) wl_surface_commit(wl->surface); wl->pending_vo_events |= VO_EVENT_RESIZE; if (!wl->configured) { - spawn_cursor(wl); + if (spawn_cursor(wl)) + return false; wl_display_roundtrip(wl->display); wl->configured = true; } |