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

Commit

Permalink
tinywl: fix crash if there is no keyboard
Browse files Browse the repository at this point in the history
To reproduce, run

WLR_BACKENDS=headles tinywl -s foot
  • Loading branch information
ifreund committed Aug 31, 2021
1 parent c8d97e2 commit 84ede15
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tinywl/tinywl.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ struct tinywl_keyboard {

static void focus_view(struct tinywl_view *view, struct wlr_surface *surface) {
/* Note: this function only deals with keyboard focus. */
if (view == NULL) {
return;
}
struct tinywl_server *server = view->server;
struct wlr_seat *seat = server->seat;
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
if (view == NULL || keyboard == NULL) {
return;
}
struct wlr_surface *prev_surface = seat->keyboard_state.focused_surface;
if (prev_surface == surface) {
/* Don't re-focus an already focused surface. */
Expand All @@ -114,7 +115,6 @@ static void focus_view(struct tinywl_view *view, struct wlr_surface *surface) {
seat->keyboard_state.focused_surface);
wlr_xdg_toplevel_set_activated(previous, false);
}
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
/* Move the view to the front */
wl_list_remove(&view->link);
wl_list_insert(&server->views, &view->link);
Expand Down

0 comments on commit 84ede15

Please sign in to comment.