From 642f40f285e83af702578b43c1adf195e33b93bf Mon Sep 17 00:00:00 2001 From: Abhinav Date: Tue, 10 Jun 2025 11:52:43 +0100 Subject: fix windows being mapped twice when you click a link it used to summon the window to your workspace but now it leaves everything be so you have to go there manually --- src/sxwm.c | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/sxwm.c b/src/sxwm.c index 5cc10dd..68008a2 100644 --- a/src/sxwm.c +++ b/src/sxwm.c @@ -744,25 +744,6 @@ void hdl_client_msg(XEvent *xev) } return; } - - if (xev->xclient.message_type == XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False)) { - Window target = xev->xclient.data.l[0]; - for (int ws = 0; ws < NUM_WORKSPACES; ws++) { - for (Client *c = workspaces[ws]; c; c = c->next) { - if (c->win == target) { - /* do NOT move to current ws */ - if (ws == current_ws) { - focused = c; - send_wm_take_focus(c->win); - XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); - XRaiseWindow(dpy, c->win); - update_borders(); - } - return; - } - } - } - } } void hdl_config_ntf(XEvent *xev) @@ -948,6 +929,30 @@ void hdl_map_req(XEvent *xev) return; } + /* check if this window is already managed on any workspace */ + for (int ws = 0; ws < NUM_WORKSPACES; ws++) { + for (Client *c = workspaces[ws]; c; c = c->next) { + if (c->win == w) { + if (ws == current_ws) { + if (!c->mapped) { + XMapWindow(dpy, w); + c->mapped = True; + } + if (user_config.new_win_focus) { + focused = c; + XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); + send_wm_take_focus(c->win); + if (user_config.warp_cursor) { + warp_cursor(c); + } + } + update_borders(); + } + return; + } + } + } + Atom type; int format; unsigned long nitems, after; @@ -1033,11 +1038,8 @@ void hdl_map_req(XEvent *xev) } XMapWindow(dpy, w); - for (Client *c = workspaces[current_ws]; c; c = c->next) { - if (c->win == w) { - c->mapped = True; - } - } + c->mapped = True; + if (user_config.new_win_focus) { focused = c; XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); -- cgit v1.2.3