Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 84ede15

Browse files
committed
tinywl: fix crash if there is no keyboard
To reproduce, run WLR_BACKENDS=headles tinywl -s foot
1 parent c8d97e2 commit 84ede15

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tinywl/tinywl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ struct tinywl_keyboard {
9494

9595
static void focus_view(struct tinywl_view *view, struct wlr_surface *surface) {
9696
/* Note: this function only deals with keyboard focus. */
97-
if (view == NULL) {
98-
return;
99-
}
10097
struct tinywl_server *server = view->server;
10198
struct wlr_seat *seat = server->seat;
99+
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
100+
if (view == NULL || keyboard == NULL) {
101+
return;
102+
}
102103
struct wlr_surface *prev_surface = seat->keyboard_state.focused_surface;
103104
if (prev_surface == surface) {
104105
/* Don't re-focus an already focused surface. */
@@ -114,7 +115,6 @@ static void focus_view(struct tinywl_view *view, struct wlr_surface *surface) {
114115
seat->keyboard_state.focused_surface);
115116
wlr_xdg_toplevel_set_activated(previous, false);
116117
}
117-
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
118118
/* Move the view to the front */
119119
wl_list_remove(&view->link);
120120
wl_list_insert(&server->views, &view->link);

0 commit comments

Comments
 (0)