Skip to content

Commit 92244c8

Browse files
mstoecklemersion
authored andcommitted
swaybar: handle wayland-cursor failures
Updating the cursor is not essential, so this change prints a warning when wl_cursor_theme_load or wl_cursor_theme_get_cursor fail instead of crashing or exiting.
1 parent 20ffe54 commit 92244c8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

swaybar/input.c

+8
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,16 @@ void update_cursor(struct swaybar_seat *seat) {
8181
int scale = pointer->current ? pointer->current->scale : 1;
8282
pointer->cursor_theme = wl_cursor_theme_load(
8383
cursor_theme, cursor_size * scale, seat->bar->shm);
84+
if (!pointer->cursor_theme) {
85+
sway_log(SWAY_ERROR, "Failed to load cursor theme");
86+
return;
87+
}
8488
struct wl_cursor *cursor;
8589
cursor = wl_cursor_theme_get_cursor(pointer->cursor_theme, "default");
90+
if (!cursor) {
91+
sway_log(SWAY_ERROR, "Failed to get default cursor from theme");
92+
return;
93+
}
8694
pointer->cursor_image = cursor->images[0];
8795
wl_surface_set_buffer_scale(pointer->cursor_surface, scale);
8896
wl_surface_attach(pointer->cursor_surface,

0 commit comments

Comments
 (0)