main: initialize scale to '1'

This ensures we always have a valid (but possibly incorrect) scaling
value. This allows us to simplify code that uses the scale - it
doesn't have to verify the scale if valid.

Furthermore, since render_resize() is the function that actually
updates term->scale, make sure to call it *before* updating the
cursor (otherwise, the cursor will use the old scaling value).
This commit is contained in:
Daniel Eklöf 2019-09-26 18:39:49 +02:00
parent 7323f18859
commit 2d6369482e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 7 additions and 22 deletions

View file

@ -931,18 +931,6 @@ render_reload_cursor_theme(struct terminal *term)
if (term->wl.pointer.size == 0)
return true;
int scale = -1;
tll_foreach(term->wl.on_outputs, it) {
if (it->item->scale > scale)
scale = it->item->scale;
}
if (scale == -1) {
/* Haven't 'entered' an output yet? */
LOG_WARN("unknown scale, using '1'");
scale = 1;
}
if (term->wl.pointer.theme != NULL) {
wl_cursor_theme_destroy(term->wl.pointer.theme);
term->wl.pointer.theme = NULL;
@ -953,7 +941,7 @@ render_reload_cursor_theme(struct terminal *term)
term->wl.pointer.theme_name, term->wl.pointer.size);
term->wl.pointer.theme = wl_cursor_theme_load(
term->wl.pointer.theme_name, term->wl.pointer.size * scale, term->wl.shm);
term->wl.pointer.theme_name, term->wl.pointer.size * term->scale, term->wl.shm);
if (term->wl.pointer.theme == NULL) {
LOG_ERR("failed to load cursor theme");
return false;