add support for cursor themes

- uses environment variables SWAY_CURSOR_THEME and SWAY_CURSOR_SIZE
This commit is contained in:
Jiayi Zhao 2018-09-09 11:18:19 -04:00
parent f7568e26e9
commit cd14e1e64d
2 changed files with 14 additions and 3 deletions

View file

@ -507,11 +507,15 @@ void seat_remove_device(struct sway_seat *seat,
void seat_configure_xcursor(struct sway_seat *seat) { void seat_configure_xcursor(struct sway_seat *seat) {
// TODO configure theme and size // TODO configure theme and size
const char *cursor_theme = NULL; const char *cursor_theme = getenv("SWAY_CURSOR_THEME");
int cursor_size = atoi(getenv("SWAY_CURSOR_SIZE"));
if (cursor_size <= 0) {
cursor_size = 24;
}
if (!seat->cursor->xcursor_manager) { if (!seat->cursor->xcursor_manager) {
seat->cursor->xcursor_manager = seat->cursor->xcursor_manager =
wlr_xcursor_manager_create(cursor_theme, 24); wlr_xcursor_manager_create(cursor_theme, cursor_size);
if (sway_assert(seat->cursor->xcursor_manager, if (sway_assert(seat->cursor->xcursor_manager,
"Cannot create XCursor manager for theme %s", "Cannot create XCursor manager for theme %s",
cursor_theme)) { cursor_theme)) {

View file

@ -93,7 +93,13 @@ bool server_init(struct sway_server *server) {
server->xwayland_ready.notify = handle_xwayland_ready; server->xwayland_ready.notify = handle_xwayland_ready;
// TODO: configurable cursor theme and size // TODO: configurable cursor theme and size
server->xwayland.xcursor_manager = wlr_xcursor_manager_create(NULL, 24); char *cursor_theme = getenv("SWAY_CURSOR_THEME");
int cursor_size = atoi(getenv("SWAY_CURSOR_SIZE"));
if (cursor_size <= 0) {
cursor_size = 24;
}
server->xwayland.xcursor_manager = wlr_xcursor_manager_create(cursor_theme, cursor_size);
wlr_xcursor_manager_load(server->xwayland.xcursor_manager, 1); wlr_xcursor_manager_load(server->xwayland.xcursor_manager, 1);
struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor( struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor(
server->xwayland.xcursor_manager, "left_ptr", 1); server->xwayland.xcursor_manager, "left_ptr", 1);
@ -103,6 +109,7 @@ bool server_init(struct sway_server *server) {
image->width * 4, image->width, image->height, image->hotspot_x, image->width * 4, image->width, image->height, image->hotspot_x,
image->hotspot_y); image->hotspot_y);
} }
#endif #endif
server->server_decoration_manager = server->server_decoration_manager =