[amiwm] add a new command action to rotate windows

This adds a command to iterate over the set of windows.  It's not
like alt-tab in ye olde windows world where you'd alt tab once to
switch between two windows, and then keep alt-tab'ing with alt down
to go through the window list.  For now it just literally iterates
through those windows.

This makes it a lot easier to work with a large number of open
windows without having to constantly use the mouse.
This commit is contained in:
Adrian Chadd
2022-02-13 19:57:24 -08:00
parent 72742103b5
commit e0c13213c5
7 changed files with 177 additions and 2 deletions

127
frame.c
View File

@@ -591,6 +591,133 @@ void raiselowerclient(Client *c, int place)
} else XRaiseWindow(dpy, c->parent);
}
extern void setfocus(Window);
extern Client *activeclient;
/*
* Lower the top most client.
*
* Update focus if required.
*/
void
lowertopmostclient(Scrn *scr)
{
Window r, p, *children;
unsigned int nchildren;
Client *c_top, *c_bot;
Window ws[2];
/* Query the list of windows under the active screen */
if (XQueryTree(dpy, scr->back, &r, &p, &children, &nchildren) == 0) {
fprintf(stderr, "%s: couldn't fetch the window list\n", __func__);
return;
}
/*
* Grab the top most client
*/
c_top = topmostmappedclient(children, nchildren);
if (c_top == NULL) {
fprintf(stderr, "%s: couldn't get the top most mapped client\n", __func__);
return;
}
/*
* And the bottom most client.
*/
c_bot = bottommostmappedclient(children, nchildren);
if (c_bot == NULL) {
fprintf(stderr, "%s: couldn't get the bottom most mapped client\n", __func__);
return;
}
/*
* If we're doing click-to-focus, mark the old top-most window
* as inactive; mark the new top-most window as active and has focus.
*/
if (prefs.focus == FOC_CLICKTOTYPE) {
c_top->active = False;
c_bot->active = True;
activeclient = c_bot;
redrawclient(c_bot);
redrawclient(c_top);
setfocus(c_bot->window);
}
/*
* Push this to the bottom of the stack.
*/
ws[0]=c_bot->parent;
ws[1]=c_top->parent;
XRestackWindows(dpy, ws, 2);
/*
* Free the children list.
*/
if (children)
XFree(children);
}
/*
* Raise the bottom most client.
*
* Update focus if required.
*/
void
raisebottommostclient(Scrn *scr)
{
Window r, p, *children;
unsigned int nchildren;
Client *c_top, *c_bot;
/* Query the list of windows under the active screen */
if (XQueryTree(dpy, scr->back, &r, &p, &children, &nchildren) == 0) {
fprintf(stderr, "%s: couldn't fetch the window list\n", __func__);
return;
}
/*
* Grab the top most client
*/
c_top = topmostmappedclient(children, nchildren);
if (c_top == NULL) {
fprintf(stderr, "%s: couldn't get the top most mapped client\n", __func__);
return;
}
/*
* And the bottom most client.
*/
c_bot = bottommostmappedclient(children, nchildren);
if (c_bot == NULL) {
fprintf(stderr, "%s: couldn't get the bottom most mapped client\n", __func__);
return;
}
/*
* If we're doing click-to-focus, mark the old top-most window
* as inactive; mark the new top-most window as active and has focus.
*/
if (prefs.focus == FOC_CLICKTOTYPE) {
c_top->active = False;
c_bot->active = True;
activeclient = c_bot;
redrawclient(c_bot);
redrawclient(c_top);
setfocus(c_bot->window);
}
/* Raise the selected window to the top */
XRaiseWindow(dpy, c_bot->parent);
/*
* Free the children list.
*/
if (children)
XFree(children);
}
void gadgetunclicked(Client *c, XEvent *e)
{
extern void adjusticon(Icon *);