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).
This commit is contained in:
Rostislav Pehlivanov 2017-10-22 06:39:51 +01:00
parent 78ef7fb766
commit f8aeda0da9
1 changed files with 9 additions and 3 deletions

View File

@ -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;
}