Skip to content

Commit

Permalink
swaybar: handle wayland-cursor failures
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mstoeckl authored and emersion committed Jul 8, 2023
1 parent 20ffe54 commit 92244c8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions swaybar/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,16 @@ void update_cursor(struct swaybar_seat *seat) {
int scale = pointer->current ? pointer->current->scale : 1;
pointer->cursor_theme = wl_cursor_theme_load(
cursor_theme, cursor_size * scale, seat->bar->shm);
if (!pointer->cursor_theme) {
sway_log(SWAY_ERROR, "Failed to load cursor theme");
return;
}
struct wl_cursor *cursor;
cursor = wl_cursor_theme_get_cursor(pointer->cursor_theme, "default");
if (!cursor) {
sway_log(SWAY_ERROR, "Failed to get default cursor from theme");
return;
}
pointer->cursor_image = cursor->images[0];
wl_surface_set_buffer_scale(pointer->cursor_surface, scale);
wl_surface_attach(pointer->cursor_surface,
Expand Down

0 comments on commit 92244c8

Please sign in to comment.