mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-03 07:15:29 -04:00
wayland: read XCURSOR_{THEME,SIZE} in reload_xcursor theme
This commit is contained in:
parent
71584aed38
commit
bf62519d83
3 changed files with 16 additions and 34 deletions
3
render.c
3
render.c
|
|
@ -1956,8 +1956,7 @@ render_xcursor_update(struct seat *seat)
|
||||||
seat->pointer.theme, seat->pointer.xcursor);
|
seat->pointer.theme, seat->pointer.xcursor);
|
||||||
|
|
||||||
if (seat->pointer.cursor == NULL) {
|
if (seat->pointer.cursor == NULL) {
|
||||||
LOG_ERR("%s: failed to load xcursor pointer '%s'",
|
LOG_ERR("failed to load xcursor pointer '%s'", seat->pointer.xcursor);
|
||||||
seat->pointer.theme_name, seat->pointer.xcursor);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
42
wayland.c
42
wayland.c
|
|
@ -96,7 +96,6 @@ seat_destroy(struct seat *seat)
|
||||||
if (seat->kbd.repeat.fd >= 0)
|
if (seat->kbd.repeat.fd >= 0)
|
||||||
fdm_del(seat->wayl->fdm, seat->kbd.repeat.fd);
|
fdm_del(seat->wayl->fdm, seat->kbd.repeat.fd);
|
||||||
|
|
||||||
free(seat->pointer.theme_name);
|
|
||||||
if (seat->pointer.theme != NULL)
|
if (seat->pointer.theme != NULL)
|
||||||
wl_cursor_theme_destroy(seat->pointer.theme);
|
wl_cursor_theme_destroy(seat->pointer.theme);
|
||||||
if (seat->pointer.surface != NULL)
|
if (seat->pointer.surface != NULL)
|
||||||
|
|
@ -718,8 +717,6 @@ handle_global(void *data, struct wl_registry *registry,
|
||||||
},
|
},
|
||||||
.pointer = {
|
.pointer = {
|
||||||
.surface = pointer_surf,
|
.surface = pointer_surf,
|
||||||
.size = wayl->xcursor_size,
|
|
||||||
.theme_name = wayl->xcursor_theme != NULL ? strdup(wayl->xcursor_theme) : NULL,
|
|
||||||
},
|
},
|
||||||
.data_device = data_device,
|
.data_device = data_device,
|
||||||
.primary_selection_device = primary_selection_device,
|
.primary_selection_device = primary_selection_device,
|
||||||
|
|
@ -926,23 +923,6 @@ wayl_init(const struct config *conf, struct fdm *fdm)
|
||||||
wayl->fdm = fdm;
|
wayl->fdm = fdm;
|
||||||
wayl->fd = -1;
|
wayl->fd = -1;
|
||||||
|
|
||||||
/* XCursor */
|
|
||||||
const char *xcursor_theme = getenv("XCURSOR_THEME");
|
|
||||||
if (xcursor_theme != NULL)
|
|
||||||
wayl->xcursor_theme = strdup(xcursor_theme);
|
|
||||||
wayl->xcursor_size = 24;
|
|
||||||
|
|
||||||
{
|
|
||||||
const char *env_cursor_size = getenv("XCURSOR_SIZE");
|
|
||||||
if (env_cursor_size != NULL) {
|
|
||||||
unsigned size;
|
|
||||||
if (sscanf(env_cursor_size, "%u", &size) == 1)
|
|
||||||
wayl->xcursor_size = size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_INFO("XCURSOR_THEME=%s, XCURSOR_SIZE=%u", wayl->xcursor_theme, wayl->xcursor_size);
|
|
||||||
|
|
||||||
if (!fdm_hook_add(fdm, &fdm_hook, wayl, FDM_HOOK_PRIORITY_LOW)) {
|
if (!fdm_hook_add(fdm, &fdm_hook, wayl, FDM_HOOK_PRIORITY_LOW)) {
|
||||||
LOG_ERR("failed to add FDM hook");
|
LOG_ERR("failed to add FDM hook");
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -1085,7 +1065,6 @@ wayl_destroy(struct wayland *wayl)
|
||||||
if (wayl->display != NULL)
|
if (wayl->display != NULL)
|
||||||
wl_display_disconnect(wayl->display);
|
wl_display_disconnect(wayl->display);
|
||||||
|
|
||||||
free(wayl->xcursor_theme);
|
|
||||||
free(wayl);
|
free(wayl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1223,9 +1202,6 @@ wayl_win_destroy(struct wl_window *win)
|
||||||
bool
|
bool
|
||||||
wayl_reload_xcursor_theme(struct seat *seat, int new_scale)
|
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) {
|
if (seat->pointer.theme != NULL && seat->pointer.scale == new_scale) {
|
||||||
/* We already have a theme loaded, and the scale hasn't changed */
|
/* We already have a theme loaded, and the scale hasn't changed */
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1238,11 +1214,23 @@ wayl_reload_xcursor_theme(struct seat *seat, int new_scale)
|
||||||
seat->pointer.cursor = NULL;
|
seat->pointer.cursor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DBG("reloading cursor theme: %s@%d",
|
const char *xcursor_theme = getenv("XCURSOR_THEME");
|
||||||
seat->pointer.theme_name, seat->pointer.size);
|
int xcursor_size = 24;
|
||||||
|
|
||||||
|
{
|
||||||
|
const char *env_cursor_size = getenv("XCURSOR_SIZE");
|
||||||
|
if (env_cursor_size != NULL) {
|
||||||
|
unsigned size;
|
||||||
|
if (sscanf(env_cursor_size, "%u", &size) == 1)
|
||||||
|
xcursor_size = size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO("cursor theme: %s, size: %u, scale: %d",
|
||||||
|
xcursor_theme, xcursor_size, new_scale);
|
||||||
|
|
||||||
seat->pointer.theme = wl_cursor_theme_load(
|
seat->pointer.theme = wl_cursor_theme_load(
|
||||||
seat->pointer.theme_name, seat->pointer.size * new_scale, seat->wayl->shm);
|
xcursor_theme, xcursor_size * new_scale, seat->wayl->shm);
|
||||||
|
|
||||||
if (seat->pointer.theme == NULL) {
|
if (seat->pointer.theme == NULL) {
|
||||||
LOG_ERR("failed to load cursor theme");
|
LOG_ERR("failed to load cursor theme");
|
||||||
|
|
|
||||||
|
|
@ -147,9 +147,7 @@ struct seat {
|
||||||
struct wl_surface *surface;
|
struct wl_surface *surface;
|
||||||
struct wl_cursor_theme *theme;
|
struct wl_cursor_theme *theme;
|
||||||
struct wl_cursor *cursor;
|
struct wl_cursor *cursor;
|
||||||
int size;
|
|
||||||
int scale;
|
int scale;
|
||||||
char *theme_name;
|
|
||||||
|
|
||||||
const char *xcursor;
|
const char *xcursor;
|
||||||
struct wl_callback *xcursor_callback;
|
struct wl_callback *xcursor_callback;
|
||||||
|
|
@ -318,9 +316,6 @@ struct wayland {
|
||||||
tll(struct seat) seats;
|
tll(struct seat) seats;
|
||||||
|
|
||||||
tll(struct terminal *) terms;
|
tll(struct terminal *) terms;
|
||||||
|
|
||||||
char *xcursor_theme;
|
|
||||||
unsigned xcursor_size;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wayland *wayl_init(const struct config *conf, struct fdm *fdm);
|
struct wayland *wayl_init(const struct config *conf, struct fdm *fdm);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue