shod

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 2552417666888d425498e8fa33eb45501b4bbf83
parent 3a304c975d3d02a9a7521b0238183908684aad1d
Author: Lucas de Sena <lucas@seninha.org>
Date:   Mon, 24 Apr 2023 13:21:59 -0300

dont raise on sloppy focus; add sloppy tile focus

fix #41

Diffstat:
Mconfig.c | 3++-
Mshod.1 | 6++++--
Mshod.c | 9++++++---
Mshod.h | 1+
Mxcontainer.c | 9++++++---
Mxevents.c | 27+++++++++++++++------------
6 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/config.c b/config.c @@ -10,7 +10,8 @@ struct Config config = { /* 0-or-1 flags */ .floatdialog = 0, /* set to 1 to use floating dialog windows */ - .sloppyfocus = 0, /* set to 1 to use sloppy focus */ + .sloppyfocus = 0, /* set to 1 to use sloppy container focus */ + .sloppytiles = 0, /* set to 1 to use sloppy window focus */ .honorconfig = 0, /* set to 1 to honor configure requests */ .disablealttab = 0, /* set to 1 to disable alt-tab */ .disablehidden = 0, /* set to 1 to disable notification of hidden window as minimized */ diff --git a/shod.1 b/shod.1 @@ -7,7 +7,7 @@ .Nd mouse-focused window manager .Sh SYNOPSIS .Nm shod -.Op Fl AcdhstW +.Op Fl AcdhSstW .Op Ar file .Pp .Nm shodc @@ -116,8 +116,10 @@ By default, windows whose containers are obscured by other containers are set as hidden (aka minimized). This default behavior emulates the way Plan9's rio lists obscured windows as hidden. With this option set, only manually minimized containers are set as hidden. +.It Fl S +Use sloppy focus rather than click-to-focus between windows in the same container. .It Fl s -Use sloppy focus rather than click-to-focus. +Use sloppy focus rather than click-to-focus between containers. .It Fl t Disable container cycling (aka .Dq "alt-tab" ) . diff --git a/shod.c b/shod.c @@ -34,7 +34,7 @@ struct Dock dock; static void usage(void) { - (void)fprintf(stderr, "usage: shod [-AcdhstW] [file]\n"); + (void)fprintf(stderr, "usage: shod [-AcdhSstW] [file]\n"); exit(1); } @@ -110,7 +110,7 @@ getoptions(int argc, char *argv[]) { int c; - while ((c = getopt(argc, argv, "AcdhstW")) != -1) { + while ((c = getopt(argc, argv, "AcdhSstW")) != -1) { switch (c) { case 'A' : config.altkeysym = XK_Alt_L; @@ -125,6 +125,9 @@ getoptions(int argc, char *argv[]) case 'h': config.disablehidden = 1; break; + case 'S': + config.sloppytiles = 1; + break; case 's': config.sloppyfocus = 1; break; @@ -391,7 +394,7 @@ main(int argc, char *argv[]) filename = getoptions(argc, argv); /* check sloppy focus */ - if (config.sloppyfocus) + if (config.sloppyfocus || config.sloppytiles) clientswa.event_mask |= EnterWindowMask; /* initialize queues */ diff --git a/shod.h b/shod.h @@ -663,6 +663,7 @@ struct Config { int floatdialog; /* whether -d is passed */ int honorconfig; /* whether -c is passed */ int sloppyfocus; /* whether -s is passed */ + int sloppytiles; /* whether -S is passed */ int ndesktops; /* number of desktops */ int notifgap; /* gap between notifications */ int dockwidth, dockspace; /* dock geometry */ diff --git a/xcontainer.c b/xcontainer.c @@ -675,12 +675,16 @@ containerminimize(struct Container *c, int minimize, int focus) if (focus) { if ((tofocus = getnextfocused(c->mon, c->desk)) != NULL) { tabfocus(tofocus->selcol->selrow->seltab, 0); + containerraise(c, c->isfullscreen, c->abovebelow); } else { tabfocus(NULL, 0); } } } else if (minimize != ADD && c->isminimized) { + (void)containersendtodesk(c, wm.selmon, wm.selmon->seldesk); + containermoveresize(c, 1); tabfocus(c->selcol->selrow->seltab, 0); + containerraise(c, c->isfullscreen, c->abovebelow); } } @@ -1490,6 +1494,7 @@ found: else rowcalctabs(row); tabfocus(det, 0); + containerraise(c, c->isfullscreen, c->abovebelow); XMapSubwindows(dpy, c->frame); /* no need to call shodgrouptab() and shodgroupcontainer(); tabfocus() already calls them */ ewmhsetdesktop(det->obj.win, c->desk); @@ -1674,10 +1679,7 @@ tabfocus(struct Tab *tab, int gotodesk) containeraddfocus(c); containerdecorate(c, NULL, NULL, 1, 0); c->isminimized = 0; - (void)containersendtodesk(c, wm.selmon, wm.selmon->seldesk); - containermoveresize(c, 1); containerhide(c, 0); - containerraise(c, c->isfullscreen, c->abovebelow); shodgrouptab(c); shodgroupcontainer(c); ewmhsetstate(c); @@ -1830,6 +1832,7 @@ containernewwithtab(struct Tab *tab, struct Monitor *mon, int desk, XRectangle r containerplace(c, mon, desk, (state & USERPLACED)); containermoveresize(c, 0); if (containerisvisible(c, wm.selmon, wm.selmon->seldesk)) { + containerraise(c, c->isfullscreen, c->abovebelow); containerhide(c, 0); tabfocus(tab, 0); } diff --git a/xevents.c b/xevents.c @@ -1498,6 +1498,7 @@ xeventclientmessage(XEvent *e) break; default: tabfocus(tab, 1); + containerraise(c, c->isfullscreen, c->abovebelow); break; } } else if (ev->message_type == atoms[_NET_CLOSE_WINDOW]) { @@ -1635,25 +1636,27 @@ xeventdestroynotify(XEvent *e) static void xevententernotify(XEvent *e) { + struct Tab *tab; struct Object *obj; - if (!config.sloppyfocus) + if (!config.sloppyfocus && !config.sloppytiles) return; while (XCheckTypedEvent(dpy, EnterNotify, e)) ; if ((obj = getmanaged(e->xcrossing.window)) == NULL) return; - switch (obj->type) { - case TYPE_MENU: - menufocus((struct Menu *)obj); - break; - case TYPE_DIALOG: - tabfocus(((struct Dialog *)obj)->tab, 1); - break; - case TYPE_NORMAL: - tabfocus((struct Tab *)obj, 1); - break; - } + if (obj->type == TYPE_DIALOG) + tab = ((struct Dialog *)obj)->tab; + else if (obj->type == TYPE_NORMAL) + tab = (struct Tab *)obj; + else return; + if (!config.sloppytiles && tab->row->col->c == wm.focused) + return; + if (!config.sloppyfocus && tab->row->col->c != wm.focused) + return; + if (config.sloppyfocus && tab->row->col->c != wm.focused) + tab = tab->row->col->c->selcol->selrow->seltab; + tabfocus(tab, 1); } /* handle focusin event */