mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-01 07:15:32 -04:00
xcursor: trigger theme reload in pointer-enter event
Previously, we triggered a theme reload on output changes. This is completely wrong. We may get a new output with a scale different from the output the pointer is actually on. Now, we store the current scale along with the theme. We then trigger a call to reload the xcursor theme *every* time the pointer enters a surface. When it does, we use the current scale factor of the terminal that owns that surface. If the terminal covers multiple outputs, with different scale factors, we'll use the largest scale factor. This may not be 100% correct. But to fix that, we'd need to track which regions of a surface are mapped on which outputs. Too complicated I say.
This commit is contained in:
parent
5539af2597
commit
d377221e24
3 changed files with 17 additions and 9 deletions
20
wayland.c
20
wayland.c
|
|
@ -30,8 +30,6 @@
|
|||
#include "selection.h"
|
||||
#include "util.h"
|
||||
|
||||
static bool wayl_reload_cursor_theme(struct seat *seat, struct terminal *term);
|
||||
|
||||
static void
|
||||
csd_instantiate(struct wl_window *win)
|
||||
{
|
||||
|
|
@ -212,9 +210,6 @@ update_term_for_output_change(struct terminal *term)
|
|||
render_resize(term, term->width / term->scale, term->height / term->scale);
|
||||
term_font_dpi_changed(term);
|
||||
term_font_subpixel_changed(term);
|
||||
|
||||
tll_foreach(term->wl->seats, it)
|
||||
wayl_reload_cursor_theme(&it->item, term);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1197,13 +1192,19 @@ wayl_win_destroy(struct wl_window *win)
|
|||
free(win);
|
||||
}
|
||||
|
||||
static bool
|
||||
wayl_reload_cursor_theme(struct seat *seat, struct terminal *term)
|
||||
bool
|
||||
wayl_reload_xcursor_theme(struct seat *seat, int new_scale)
|
||||
{
|
||||
if (seat->pointer.size == 0)
|
||||
return true;
|
||||
|
||||
if (seat->pointer.theme != NULL && seat->pointer.scale == new_scale) {
|
||||
/* We already have a theme loaded, and the scale hasn't changed */
|
||||
return true;
|
||||
}
|
||||
|
||||
if (seat->pointer.theme != NULL) {
|
||||
assert(seat->pointer.scale != new_scale);
|
||||
wl_cursor_theme_destroy(seat->pointer.theme);
|
||||
seat->pointer.theme = NULL;
|
||||
seat->pointer.cursor = NULL;
|
||||
|
|
@ -1213,14 +1214,15 @@ wayl_reload_cursor_theme(struct seat *seat, struct terminal *term)
|
|||
seat->pointer.theme_name, seat->pointer.size);
|
||||
|
||||
seat->pointer.theme = wl_cursor_theme_load(
|
||||
seat->pointer.theme_name, seat->pointer.size * term->scale, seat->wayl->shm);
|
||||
seat->pointer.theme_name, seat->pointer.size * new_scale, seat->wayl->shm);
|
||||
|
||||
if (seat->pointer.theme == NULL) {
|
||||
LOG_ERR("failed to load cursor theme");
|
||||
return false;
|
||||
}
|
||||
|
||||
return render_xcursor_set(seat, term);
|
||||
seat->pointer.scale = new_scale;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue