mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-08 10:06:22 -05: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
3
input.c
3
input.c
|
|
@ -846,6 +846,9 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
|||
LOG_DBG("pointer-enter: pointer=%p, serial=%u, surface = %p, new-moused = %p",
|
||||
wl_pointer, serial, surface, term);
|
||||
|
||||
/* Scale may have changed */
|
||||
wayl_reload_xcursor_theme(seat, term->scale);
|
||||
|
||||
seat->mouse_focus = term;
|
||||
|
||||
int x = wl_fixed_to_int(surface_x) * term->scale;
|
||||
|
|
|
|||
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
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ struct seat {
|
|||
struct wl_cursor_theme *theme;
|
||||
struct wl_cursor *cursor;
|
||||
int size;
|
||||
int scale;
|
||||
char *theme_name;
|
||||
const char *xcursor;
|
||||
|
||||
|
|
@ -329,3 +330,5 @@ void wayl_roundtrip(struct wayland *wayl);
|
|||
|
||||
struct wl_window *wayl_win_init(struct terminal *term);
|
||||
void wayl_win_destroy(struct wl_window *win);
|
||||
|
||||
bool wayl_reload_xcursor_theme(struct seat *seat, int new_scale);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue