diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-09-26 16:39:49 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-09-26 16:39:49 +0000 |
| commit | 2d6369482e231e8d2cdfbf567e4b651a4c71f763 (patch) | |
| tree | f68e923a58041654c5276234e091fde5e29e9890 /main.c | |
| parent | PKGBUILD: explicitly set --term=xterm (diff) | |
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).
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -138,9 +138,8 @@ output_scale(void *data, struct wl_output *wl_output, int32_t factor) struct monitor *mon = data; mon->scale = factor; - int old_scale = mon->term->scale >= 1 ? mon->term->scale : 1; + render_resize(mon->term, mon->term->width / mon->term->scale, mon->term->height / mon->term->scale); render_reload_cursor_theme(mon->term); - render_resize(mon->term, mon->term->width / old_scale, mon->term->height / old_scale); } static const struct wl_output_listener output_listener = { @@ -280,9 +279,8 @@ surface_enter(void *data, struct wl_surface *wl_surface, tll_push_back(term->wl.on_outputs, &it->item); /* Resize, since scale-to-use may have changed */ - int scale = term->scale >= 1 ? term->scale : 1; + render_resize(term, term->width / term->scale, term->height / term->scale); render_reload_cursor_theme(term); - render_resize(term, term->width / scale, term->height / scale); return; } } @@ -303,9 +301,8 @@ surface_leave(void *data, struct wl_surface *wl_surface, tll_remove(term->wl.on_outputs, it); /* Resize, since scale-to-use may have changed */ - int scale = term->scale >= 1 ? term->scale : 1; + render_resize(term, term->width / term->scale, term->height / term->scale); render_reload_cursor_theme(term); - render_resize(term, term->width / scale, term->height / scale); return; } @@ -502,6 +499,7 @@ main(int argc, char *const *argv) .keypad_keys_mode = KEYPAD_NUMERICAL, .auto_margin = true, .window_title_stack = tll_init(), + .scale = 1, .flash = { .fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC | TFD_NONBLOCK), }, |
