replace shouldfocusclients with checking old

And don't activate clients while an overlay is focused.
This commit is contained in:
Guido Cella 2020-12-20 15:19:34 +01:00
parent 39946e07f2
commit a571ea465c

47
dwl.c
View file

@ -275,7 +275,6 @@ static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, unsigned int newtags);
static void setup(void);
static void sigchld(int unused);
static bool shouldfocusclients();
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
@ -1119,10 +1118,16 @@ focusclient(Client *c, bool lift)
struct wlr_surface *old = seat->keyboard_state.focused_surface;
/* Nothing else to do? */
if (c && WLR_SURFACE(c) == old)
return;
/* Put the new client atop the focus stack and select its monitor */
if (c) {
wl_list_remove(&c->flink);
wl_list_insert(&fstack, &c->flink);
selmon = c->mon;
}
/* Deactivate old client if focus is changing */
if (old && (!c || WLR_SURFACE(c) != old)) {
if (wlr_surface_is_xdg_surface(old))
@ -1133,9 +1138,23 @@ focusclient(Client *c, bool lift)
wlr_xwayland_surface_activate(
wlr_xwayland_surface_from_wlr_surface(old), false);
#endif
/* If an overlay is focused, don't focus or activate the client,
* but only update its position in fstack to render its border with focuscolor
* and focus it after the overlay is closed.
* It's probably pointless to check if old is a layer surface
* since it can't be anything else at this point. */
else if (wlr_surface_is_layer_surface(old)) {
struct wlr_layer_surface_v1 *wlr_layer_surface =
wlr_layer_surface_v1_from_wlr_surface(old);
if (wlr_layer_surface->mapped && (
wlr_layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP ||
wlr_layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY
))
return;
}
}
/* Update wlroots' keyboard focus */
if (!c) {
/* With no client, all we have left is to clear focus */
wlr_seat_keyboard_notify_clear_focus(seat);
@ -1144,15 +1163,9 @@ focusclient(Client *c, bool lift)
/* Have a client, so focus its top-level wlr_surface */
struct wlr_keyboard *kb = wlr_seat_get_keyboard(seat);
if (shouldfocusclients(c->mon))
wlr_seat_keyboard_notify_enter(seat, WLR_SURFACE(c),
kb->keycodes, kb->num_keycodes, &kb->modifiers);
/* Put the new client atop the focus stack and select its monitor */
wl_list_remove(&c->flink);
wl_list_insert(&fstack, &c->flink);
selmon = c->mon;
/* Activate the new client */
#ifdef XWAYLAND
if (c->type != XDGShell)
@ -2167,22 +2180,6 @@ sigchld(int unused)
;
}
bool
shouldfocusclients(Monitor *m)
{
LayerSurface *layersurface;
uint32_t layers_above_shell[] = {
ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY,
ZWLR_LAYER_SHELL_V1_LAYER_TOP,
};
for (size_t i = 0; i < LENGTH(layers_above_shell); ++i)
wl_list_for_each(layersurface, &m->layers[layers_above_shell[i]], link)
if (layersurface->layer_surface->current.keyboard_interactive &&
layersurface->layer_surface->mapped)
return false;
return true;
}
void
spawn(const Arg *arg)
{