Skip to content

Commit

Permalink
Merge pull request djpohly#230 from BenJarg/null-wlr_seat_get_keyboard
Browse files Browse the repository at this point in the history
Handle 'wlr_seat_get_keyboard' possibly returning null.
  • Loading branch information
sevz17 authored May 9, 2022
2 parents 3a4b7d1 + e0d310f commit 07d56c6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions dwl.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,11 @@ arrangelayers(Monitor *m)
layersurface->layer_surface->mapped) {
/* Deactivate the focused client. */
focusclient(NULL, 0);
wlr_seat_keyboard_notify_enter(seat, layersurface->layer_surface->surface,
kb->keycodes, kb->num_keycodes, &kb->modifiers);
if (kb)
wlr_seat_keyboard_notify_enter(seat, layersurface->layer_surface->surface,
kb->keycodes, kb->num_keycodes, &kb->modifiers);
else
wlr_seat_keyboard_notify_enter(seat, layersurface->layer_surface->surface, NULL, 0, NULL);
return;
}
}
Expand Down Expand Up @@ -641,7 +644,7 @@ buttonpress(struct wl_listener *listener, void *data)
focusclient(c, 1);

keyboard = wlr_seat_get_keyboard(seat);
mods = wlr_keyboard_get_modifiers(keyboard);
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
for (b = buttons; b < END(buttons); b++) {
if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
event->button == b->button && b->func) {
Expand Down Expand Up @@ -1146,8 +1149,11 @@ focusclient(Client *c, int lift)

/* Have a client, so focus its top-level wlr_surface */
kb = wlr_seat_get_keyboard(seat);
wlr_seat_keyboard_notify_enter(seat, client_surface(c),
kb->keycodes, kb->num_keycodes, &kb->modifiers);
if (kb)
wlr_seat_keyboard_notify_enter(seat, client_surface(c),
kb->keycodes, kb->num_keycodes, &kb->modifiers);
else
wlr_seat_keyboard_notify_enter(seat, client_surface(c), NULL, 0, NULL);

/* Activate the new client */
client_activate_surface(client_surface(c), 1);
Expand Down

0 comments on commit 07d56c6

Please sign in to comment.