mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-06-16 08:15:40 +02:00
bar: let backend check if xcursor should be updated or not
This allows the backend to support multi-seat "properly", by checking against the correct seat. Before this, when we used a single, global xcursor value, a seat whose pointer needed to be updated would not be updated.
This commit is contained in:
parent
5884e665a4
commit
f04b1e806c
4 changed files with 24 additions and 40 deletions
|
@ -72,6 +72,7 @@ struct seat {
|
|||
struct wl_surface *surface;
|
||||
struct wl_cursor_theme *theme;
|
||||
struct wl_cursor *cursor;
|
||||
const char *xcursor;
|
||||
int scale;
|
||||
} pointer;
|
||||
};
|
||||
|
@ -89,7 +90,6 @@ struct wayland_backend {
|
|||
|
||||
tll(struct seat) seats;
|
||||
struct seat *active_seat;
|
||||
const char *xcursor;
|
||||
|
||||
tll(struct monitor) monitors;
|
||||
const struct monitor *monitor;
|
||||
|
@ -178,28 +178,6 @@ update_cursor_surface(struct wayland_backend *backend, struct seat *seat)
|
|||
wl_display_flush(backend->display);
|
||||
}
|
||||
|
||||
static void
|
||||
set_cursor(struct bar *_bar, const char *_cursor)
|
||||
{
|
||||
struct private *bar = _bar->private;
|
||||
struct wayland_backend *backend = bar->backend.data;
|
||||
|
||||
const char *cursor = _cursor != NULL ? _cursor : backend->xcursor;
|
||||
if (cursor == NULL)
|
||||
return;
|
||||
|
||||
backend->xcursor = cursor;
|
||||
|
||||
struct seat *seat = backend->active_seat;
|
||||
if (seat == NULL || seat->pointer.theme == NULL)
|
||||
return;
|
||||
|
||||
seat->pointer.cursor = wl_cursor_theme_get_cursor(
|
||||
seat->pointer.theme, cursor);
|
||||
|
||||
update_cursor_surface(backend, seat);
|
||||
}
|
||||
|
||||
static void
|
||||
reload_cursor_theme(struct seat *seat, int new_scale)
|
||||
{
|
||||
|
@ -252,7 +230,6 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
|||
|
||||
backend->active_seat = seat;
|
||||
reload_cursor_theme(seat, backend->monitor->scale);
|
||||
set_cursor(backend->bar, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -981,9 +958,6 @@ cleanup(struct bar *_bar)
|
|||
if (backend->xdg_output_manager != NULL)
|
||||
zxdg_output_manager_v1_destroy(backend->xdg_output_manager);
|
||||
|
||||
/* TODO: move to bar */
|
||||
free(bar->cursor_name);
|
||||
|
||||
tll_foreach(backend->seats, it)
|
||||
seat_destroy(&it->item);
|
||||
tll_free(backend->seats);
|
||||
|
@ -1202,6 +1176,25 @@ refresh(const struct bar *_bar)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_cursor(struct bar *_bar, const char *cursor)
|
||||
{
|
||||
struct private *bar = _bar->private;
|
||||
struct wayland_backend *backend = bar->backend.data;
|
||||
|
||||
struct seat *seat = backend->active_seat;
|
||||
if (seat == NULL || seat->pointer.theme == NULL)
|
||||
return;
|
||||
|
||||
if (seat->pointer.xcursor != NULL && strcmp(seat->pointer.xcursor, cursor) == 0)
|
||||
return;
|
||||
|
||||
seat->pointer.cursor = wl_cursor_theme_get_cursor(
|
||||
seat->pointer.theme, cursor);
|
||||
|
||||
update_cursor_surface(backend, seat);
|
||||
}
|
||||
|
||||
const struct backend wayland_backend_iface = {
|
||||
.setup = &setup,
|
||||
.cleanup = &cleanup,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue