Merge pull request #230 from BenJarg/null-wlr_seat_get_keyboard

Handle 'wlr_seat_get_keyboard' possibly returning null.
This commit is contained in:
Sevz 2022-05-09 13:18:19 -05:00 committed by GitHub
commit 07d56c6d7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

8
dwl.c
View file

@ -600,8 +600,11 @@ arrangelayers(Monitor *m)
layersurface->layer_surface->mapped) { layersurface->layer_surface->mapped) {
/* Deactivate the focused client. */ /* Deactivate the focused client. */
focusclient(NULL, 0); focusclient(NULL, 0);
if (kb)
wlr_seat_keyboard_notify_enter(seat, layersurface->layer_surface->surface, wlr_seat_keyboard_notify_enter(seat, layersurface->layer_surface->surface,
kb->keycodes, kb->num_keycodes, &kb->modifiers); kb->keycodes, kb->num_keycodes, &kb->modifiers);
else
wlr_seat_keyboard_notify_enter(seat, layersurface->layer_surface->surface, NULL, 0, NULL);
return; return;
} }
} }
@ -641,7 +644,7 @@ buttonpress(struct wl_listener *listener, void *data)
focusclient(c, 1); focusclient(c, 1);
keyboard = wlr_seat_get_keyboard(seat); 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++) { for (b = buttons; b < END(buttons); b++) {
if (CLEANMASK(mods) == CLEANMASK(b->mod) && if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
event->button == b->button && b->func) { event->button == b->button && b->func) {
@ -1146,8 +1149,11 @@ focusclient(Client *c, int lift)
/* Have a client, so focus its top-level wlr_surface */ /* Have a client, so focus its top-level wlr_surface */
kb = wlr_seat_get_keyboard(seat); kb = wlr_seat_get_keyboard(seat);
if (kb)
wlr_seat_keyboard_notify_enter(seat, client_surface(c), wlr_seat_keyboard_notify_enter(seat, client_surface(c),
kb->keycodes, kb->num_keycodes, &kb->modifiers); kb->keycodes, kb->num_keycodes, &kb->modifiers);
else
wlr_seat_keyboard_notify_enter(seat, client_surface(c), NULL, 0, NULL);
/* Activate the new client */ /* Activate the new client */
client_activate_surface(client_surface(c), 1); client_activate_surface(client_surface(c), 1);