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

Commit 6e49252

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

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tinywl/tinywl.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ static void focus_view(struct tinywl_view *view, struct wlr_surface *surface) {
114114
seat->keyboard_state.focused_surface);
115115
wlr_xdg_toplevel_set_activated(previous, false);
116116
}
117-
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
118117
/* Move the view to the front */
119118
wl_list_remove(&view->link);
120119
wl_list_insert(&server->views, &view->link);
@@ -125,8 +124,13 @@ static void focus_view(struct tinywl_view *view, struct wlr_surface *surface) {
125124
* track of this and automatically send key events to the appropriate
126125
* clients without additional work on your part.
127126
*/
128-
wlr_seat_keyboard_notify_enter(seat, view->xdg_surface->surface,
129-
keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers);
127+
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
128+
if (keyboard != NULL) {
129+
wlr_seat_keyboard_notify_enter(seat, view->xdg_surface->surface,
130+
keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers);
131+
} else {
132+
wlr_seat_keyboard_notify_enter(seat, surface, NULL, 0, NULL);
133+
}
130134
}
131135

132136
static void keyboard_handle_modifiers(

0 commit comments

Comments
 (0)