|| cme->data.l[2] == netatom[NetWMFullscreen])
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
|| (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
- } else if (cme->message_type == netatom[NetActiveWindow]) {
-// /* cme->data.l[0] == 2 means it came from an external pager/script like wmctrl */
- if (cme->data.l[0] == 2) {
- /* --- NATIVE TAG, MONITOR, AND MOUSE JUMP ON ACTIVATION --- */
- selmon = c->mon;
- if (!(c->tags & selmon->tagset[selmon->seltags])) {
- view(&(Arg){ .ui = c->tags });
- }
- focus(c);
- restack(selmon);
+ } else if (cme->message_type == netatom[NetActiveWindow]) {
+ /* cme->data.l[0] == 2 means it came from an external pager/script like wmctrl */
+ if (cme->data.l[0] == 2) {
+ /* --- SAFE CROSS-MONITOR ACTIVATION --- */
+ if (c->mon != selmon) {
+ unfocus(selmon->sel, 0);
+ selmon = c->mon;
+ }
+ if (!(c->tags & selmon->tagset[selmon->seltags])) {
+ view(&(Arg){ .ui = c->tags });
+ }
- /* Optional: Warp cursor to the center of the target monitor */
- XWarpPointer(dpy, None, root, 0, 0, 0, 0,
- selmon->wx + selmon->ww / 2,
- selmon->wy + selmon->wh / 2);
- /* ------------------------------------------------------- */
+ /* Warp pointer first to prevent focus-follows-mouse race conditions */
+ XWarpPointer(dpy, None, root, 0, 0, 0, 0,
+ selmon->wx + selmon->ww / 2,
+ selmon->wy + selmon->wh / 2);
- } else if (c != selmon->sel && !c->isurgent)
+ focus(c);
+ XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+ restack(selmon);
+ /* ------------------------------------- */
+ } else if (c != selmon->sel && !c->isurgent)
seturgent(c, 1);
}
}