remove selclient()
selclient() does not work well when dealing newly mapped
clients (specifically those mapped on invisible tags).
This fixes various bugs related to things not working because selclient() would
return NULL.
References: 94c8bd6048
This commit is contained in:
parent
686958a4cc
commit
dd9d8d543c
34
dwl.c
34
dwl.c
|
@ -280,7 +280,6 @@ static void rendermon(struct wl_listener *listener, void *data);
|
|||
static void requeststartdrag(struct wl_listener *listener, void *data);
|
||||
static void resize(Client *c, struct wlr_box geo, int interact);
|
||||
static void run(char *startup_cmd);
|
||||
static Client *selclient(void);
|
||||
static void setcursor(struct wl_listener *listener, void *data);
|
||||
static void setfloating(Client *c, int floating);
|
||||
static void setfullscreen(Client *c, int fullscreen);
|
||||
|
@ -1055,7 +1054,7 @@ destroydragicon(struct wl_listener *listener, void *data)
|
|||
struct wlr_drag_icon *icon = data;
|
||||
wlr_scene_node_destroy(icon->data);
|
||||
/* Focus enter isn't sent during drag, so refocus the focused node. */
|
||||
focusclient(selclient(), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
motionnotify(0);
|
||||
}
|
||||
|
||||
|
@ -1417,7 +1416,7 @@ keypressmod(struct wl_listener *listener, void *data)
|
|||
void
|
||||
killclient(const Arg *arg)
|
||||
{
|
||||
Client *sel = selclient();
|
||||
Client *sel = focustop(selmon);
|
||||
if (sel)
|
||||
client_send_close(sel);
|
||||
}
|
||||
|
@ -1940,15 +1939,6 @@ run(char *startup_cmd)
|
|||
wl_display_run(dpy);
|
||||
}
|
||||
|
||||
Client *
|
||||
selclient(void)
|
||||
{
|
||||
Client *c = wl_container_of(fstack.next, c, flink);
|
||||
if (wl_list_empty(&fstack) || !VISIBLEON(c, selmon))
|
||||
return NULL;
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
setcursor(struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
@ -2292,7 +2282,7 @@ startdrag(struct wl_listener *listener, void *data)
|
|||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
Client *sel = selclient();
|
||||
Client *sel = focustop(selmon);
|
||||
if (sel && arg->ui & TAGMASK) {
|
||||
sel->tags = arg->ui & TAGMASK;
|
||||
focusclient(focustop(selmon), 1);
|
||||
|
@ -2304,7 +2294,7 @@ tag(const Arg *arg)
|
|||
void
|
||||
tagmon(const Arg *arg)
|
||||
{
|
||||
Client *sel = selclient();
|
||||
Client *sel = focustop(selmon);
|
||||
if (sel)
|
||||
setmon(sel, dirtomon(arg->i), 0);
|
||||
}
|
||||
|
@ -2345,7 +2335,7 @@ tile(Monitor *m)
|
|||
void
|
||||
togglefloating(const Arg *arg)
|
||||
{
|
||||
Client *sel = selclient();
|
||||
Client *sel = focustop(selmon);
|
||||
/* return if fullscreen */
|
||||
if (sel && !sel->isfullscreen)
|
||||
setfloating(sel, !sel->isfloating);
|
||||
|
@ -2354,7 +2344,7 @@ togglefloating(const Arg *arg)
|
|||
void
|
||||
togglefullscreen(const Arg *arg)
|
||||
{
|
||||
Client *sel = selclient();
|
||||
Client *sel = focustop(selmon);
|
||||
if (sel)
|
||||
setfullscreen(sel, !sel->isfullscreen);
|
||||
}
|
||||
|
@ -2363,7 +2353,7 @@ void
|
|||
toggletag(const Arg *arg)
|
||||
{
|
||||
unsigned int newtags;
|
||||
Client *sel = selclient();
|
||||
Client *sel = focustop(selmon);
|
||||
if (!sel)
|
||||
return;
|
||||
newtags = sel->tags ^ (arg->ui & TAGMASK);
|
||||
|
@ -2409,7 +2399,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
|
|||
arrangelayers(layersurface->mon);
|
||||
if (layersurface->layer_surface->surface ==
|
||||
seat->keyboard_state.focused_surface)
|
||||
focusclient(selclient(), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
motionnotify(0);
|
||||
}
|
||||
|
||||
|
@ -2430,7 +2420,7 @@ unmapnotify(struct wl_listener *listener, void *data)
|
|||
if (c == exclusive_focus)
|
||||
exclusive_focus = NULL;
|
||||
if (client_surface(c) == seat->keyboard_state.focused_surface)
|
||||
focusclient(selclient(), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
} else {
|
||||
wl_list_remove(&c->link);
|
||||
setmon(c, NULL, 0);
|
||||
|
@ -2535,7 +2525,7 @@ urgent(struct wl_listener *listener, void *data)
|
|||
struct wlr_xdg_activation_v1_request_activate_event *event = data;
|
||||
Client *c = NULL;
|
||||
int type = toplevel_from_wlr_surface(event->surface, &c, NULL);
|
||||
if (type >= 0 && type != LayerShell && c != selclient()) {
|
||||
if (type >= 0 && type != LayerShell && c != focustop(selmon)) {
|
||||
c->isurgent = 1;
|
||||
printstatus();
|
||||
}
|
||||
|
@ -2605,7 +2595,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
|||
void
|
||||
zoom(const Arg *arg)
|
||||
{
|
||||
Client *c, *sel = selclient();
|
||||
Client *c, *sel = focustop(selmon);
|
||||
|
||||
if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
|
||||
return;
|
||||
|
@ -2699,7 +2689,7 @@ void
|
|||
sethints(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, set_hints);
|
||||
if (c != selclient()) {
|
||||
if (c != focustop(selmon)) {
|
||||
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
|
||||
printstatus();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue