Skip to content
Myr

render: make sure scale is updated on scale changes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Before this change, render_set_font() was only called when the *font* had been reloaded. With dpi-aware=yes, that doesn't happen on scale changes. This caused the cached scale value (in the renderer) to be wrong. This meant mouse selection didn't work correctly, since the logic that calculates which row the cursor is on depends on the *render's* scale value be correct. Another issue was that UI elements that _do_ depend on the scale factor also wasn't updated.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 179fbfd · Browse files · 4 files+47 added−39 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+47 added−39 removed

  • other:+47 added−39 removed

4 files+47 added−39 removed

modified:CHANGELOG.md+5 added
74 unmodified lines
75* Rounding of window size when fractional scaling is used.76* Dmenu mode failing with _"failed to read from stdin: Resource77 temporarily unavailable"_.78* First frame flickers when fractional scaling is used.79* Borders, padding etc not updated on scale changes when80 `dpi-aware=yes`. This mostly affected setups using fractional81 scaling, but all setups were affected in one way or another.82* Mouse selection not working correctly (wrong item selected) when83 `dpi-aware=yes` and desktop scaling was enabled.8485[348]: https://codeberg.org/dnkl/fuzzel/issues/34886[356]: https://codeberg.org/dnkl/fuzzel/issues/35687
651 unmodified lines
modified:render.c+5 added-5 removed
786 unmodified lines
787 render->subpixel = subpixel;788}789790bool791render_set_font(struct render *render, struct fcft_font *font,792 float scale, float dpi, bool size_font_by_dpi,793 int *new_width, int *new_height)791render_set_font_and_update_sizes(struct render *render, struct fcft_font *font,792 float scale, float dpi, bool size_font_by_dpi,793 int *new_width, int *new_height)794{795 if (font != NULL) {796 fcft_destroy(render->font);797 render->font = font;
25 unmodified lines
823 border_size + /* Top border */824 y_margin +825 row_height + /* The prompt */826 inner_pad + /* Padding between prompt and matches */827 render->conf->lines * row_height + /* Matches */827 render->conf->lines * row_height + /* Matches */828 y_margin +829 border_size; /* Bottom border */830831 const unsigned width =
52 unmodified lines
884 const int border_size = render->border_size;885 const int row_height = render->row_height;886 const int first_row = 1 * border_size + y_margin + row_height + inner_pad;887 const size_t match_count = matches_get_count(matches);888 const size_t last_row = first_row + match_count*row_height;888 const size_t last_row = first_row + match_count * row_height;889890 y = floor(scale * y);891892 size_t row = -1;
7 unmodified lines
modified:render.h+4 added-3 removed
13 unmodified lines
14struct render *render_init(const struct config *conf, mtx_t *icon_lock);15void render_destroy(struct render *render);1617void render_set_subpixel(struct render *render, enum fcft_subpixel subpixel);18bool render_set_font_and_update_sizes(18bool render_set_font(struct render *render, struct fcft_font *font,19 float scale, float dpi, bool size_font_by_dpi,20 int *new_width, int *new_height);19 struct render *render, struct fcft_font *font,20 float scale, float dpi, bool size_font_by_dpi,21 int *new_width, int *new_height);2223void render_background(const struct render *render, struct buffer *buf);2425void render_prompt(
12 unmodified lines
modified:wayland.c+33 added-31 removed
1037 unmodified lines
1038 return false;1039}10401041static void1042select_hovered_match(struct seat *seat, bool refresh_always)1043{1044 struct wayland *wayl = seat->wayl;1045 bool refresh = false;10461047 size_t hovered_row =1048 render_get_row_num(wayl->render,1049 seat->pointer.y,1050 wayl->matches);1051 1052 if (hovered_row != seat->pointer.hovered_row_idx) {1053 seat->pointer.hovered_row_idx = hovered_row;1054 refresh = matches_idx_select(wayl->matches,hovered_row);1055 }10561057 if (refresh_always || refresh) {1058 wayl_refresh(wayl);1059 }1060}10611062static void1063wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,1064 uint32_t serial, struct wl_surface *surface,1065 wl_fixed_t surface_x, wl_fixed_t surface_y)1066{1067 struct seat *seat = data;1068 seat->pointer.serial = serial;10691070 seat->pointer.x = wl_fixed_to_int(surface_x);1071 seat->pointer.y = wl_fixed_to_int(surface_y);10721073 if (!attempt_cursor_shape(seat->wayl, wl_pointer, serial)) {1074 reload_cursor_theme(seat, seat->wayl->scale);1075 update_cursor_surface(seat);1076 }10771078 select_hovered_match(seat, false);1079}10801081static void1082wl_pointer_leave(void *data, struct wl_pointer *wl_pointer,
3 unmodified lines
1086 seat->pointer.serial = serial;1087}10881089static void1064select_hovered_match(struct seat *seat, bool refresh_always)1065{1066 struct wayland *wayl = seat->wayl;1067 bool refresh = false;10681069 size_t hovered_row =1070 render_get_row_num(wayl->render,1071 seat->pointer.y,1072 wayl->matches);1073 1074 if (hovered_row != seat->pointer.hovered_row_idx) {1075 seat->pointer.hovered_row_idx = hovered_row;1076 refresh = matches_idx_select(wayl->matches,hovered_row);1077 }10781079 if (refresh_always || refresh) {1080 wayl_refresh(wayl);1081 }1082}10831084static void1090wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,1091 uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y)1092{1093 struct seat *seat = data;
271 unmodified lines
1365 free(names);13661367 if (font == NULL)1368 return false;13641365 bool ret = render_set_font(1366 wayl->render, font, new_scale, new_dpi,1367 wayl->font_is_sized_by_dpi, &wayl->width, &wayl->height);13681369 if (wayl->font_reloaded.cb != NULL)1370 wayl->font_reloaded.cb(wayl, font, wayl->font_reloaded.data);13711372 return ret;1369 }13701375 return true;1371 bool ret = render_set_font_and_update_sizes(1372 wayl->render, font, new_scale, new_dpi,1373 wayl->font_is_sized_by_dpi, &wayl->width, &wayl->height);13741375 if (wayl->font_reloaded.cb != NULL)1376 wayl->font_reloaded.cb(wayl, font, wayl->font_reloaded.data);13771378 return ret;1379}13801381static float1382wayl_ppi(const struct wayland *wayl)
1059 unmodified lines