new function to notify keyboard enter

This commit is contained in:
Leonardo Hernández Hernández 2022-08-27 16:05:12 -05:00
parent b9295e8cee
commit d738573e22
Failed to generate hash of commit
2 changed files with 12 additions and 13 deletions

View file

@ -198,6 +198,16 @@ client_is_unmanaged(Client *c)
return 0; return 0;
} }
static inline void
client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb)
{
if (kb)
wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes,
kb->num_keycodes, &kb->modifiers);
else
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
}
static inline void static inline void
client_restack_surface(Client *c) client_restack_surface(Client *c)
{ {

15
dwl.c
View file

@ -590,7 +590,6 @@ arrangelayers(Monitor *m)
ZWLR_LAYER_SHELL_V1_LAYER_TOP, ZWLR_LAYER_SHELL_V1_LAYER_TOP,
}; };
LayerSurface *layersurface; LayerSurface *layersurface;
struct wlr_keyboard *kb = wlr_seat_get_keyboard(seat);
/* Arrange exclusive surfaces from top->bottom */ /* Arrange exclusive surfaces from top->bottom */
for (i = 3; i >= 0; i--) for (i = 3; i >= 0; i--)
@ -614,11 +613,7 @@ arrangelayers(Monitor *m)
/* Deactivate the focused client. */ /* Deactivate the focused client. */
focusclient(NULL, 0); focusclient(NULL, 0);
exclusive_focus = layersurface->layer_surface->surface; exclusive_focus = layersurface->layer_surface->surface;
if (kb) client_notify_enter(exclusive_focus, wlr_seat_get_keyboard(seat));
wlr_seat_keyboard_notify_enter(seat, exclusive_focus,
kb->keycodes, kb->num_keycodes, &kb->modifiers);
else
wlr_seat_keyboard_notify_enter(seat, exclusive_focus, NULL, 0, NULL);
return; return;
} }
} }
@ -1117,7 +1112,6 @@ void
focusclient(Client *c, int lift) focusclient(Client *c, int lift)
{ {
struct wlr_surface *old = seat->keyboard_state.focused_surface; struct wlr_surface *old = seat->keyboard_state.focused_surface;
struct wlr_keyboard *kb;
int i; int i;
/* Do not focus clients if a layer surface is focused */ /* Do not focus clients if a layer surface is focused */
if (exclusive_focus) if (exclusive_focus)
@ -1178,12 +1172,7 @@ 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); client_notify_enter(client_surface(c), wlr_seat_get_keyboard(seat));
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 */ /* Activate the new client */
client_activate_surface(client_surface(c), 1); client_activate_surface(client_surface(c), 1);