MCDE dtwm: Command+Tab shows the programs and switches to the next (t0115)
Command+Tab (and Shift+Command+Tab) now walks programs, not windows: the window manager collects one entry per program (WM_CLASS, the same grouping f.mcde_app uses) in the order of the stacking -- the focused program first, so the first Tab is the program used before it -- and raises and focuses the chosen program's top window. While the switch lasts (5 s) the next Tab walks on in the same list, as holding Command does in the reference. A bar appears in the middle of the screen: an override-redirect window, the palette's black, one name per program, the chosen one boxed, and it goes away by itself (one timer, no animation, no transparency). It is drawn after the map: what is drawn before it is painted over by the background (measured 2026-11-14). The key goes through f.mcde_app switcher|switcher-prev: f.mcde_switcher is registered and implements it, but a binding that names it is not taken -- neither Command+Tab nor Command+F9 did anything (measured), while f.mcde_app on Command+H does. Alt+Tab stays the window switch and Command+` the program's next window. Measured under Xvfb with xdotool: three programs, "n=3 sel=1 Dtsystemsettings" then a second Tab "sel=2 Dtfile" (the bar's selection follows); Shift+Command+Tab goes back; the picture (docs/screenshots/leopard/Command-Tab-mcde.png) shows four programs (Dtpad, Dtsystemsettings chosen, Dtterm, Dtfile) over the file manager, terminal and system settings. Open: no icons (the program's icon file, not the window manager's), no Q, H or Escape while the bar is up (they need the keyboard grab), and the bar stays a few seconds instead of hiding on Command's release.
This commit is contained in:
1 parent
7cacdd08bc
commit
4affe0dc00
5 files changed
+175
-2
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
@@ -4028,6 +4028,13 @@ Boolean F_McdeApp (String args, ClientData *pCD, XEvent *event)
|
||||
ClientData *list[256];
|
||||
int n = 0, i;
|
||||
|
||||
/* the program switcher of Command+Tab is reached through this function:
|
||||
* its own key binding is not taken (measured 2026-11-14: F9 as well), so
|
||||
* the key table names f.mcde_app, which is in it */
|
||||
if (args != NULL && strcmp (args, "switcher") == 0)
|
||||
return (F_McdeSwitcher ("next", pCD, event));
|
||||
if (args != NULL && strcmp (args, "switcher-prev") == 0)
|
||||
return (F_McdeSwitcher ("prev", pCD, event));
|
||||
if (focus == NULL || args == NULL || !McdeProgramWindow (focus))
|
||||
return (True);
|
||||
/* the windows first, acted on after: minimizing changes the list */
|
||||
@@ -4072,6 +4079,164 @@ Boolean F_McdeApp (String args, ClientData *pCD, XEvent *event)
|
||||
|
||||
|
||||
|
||||
/* ---- MCDE: the program switcher of Command+Tab -------------------------- */
|
||||
|
||||
#define SW_MAX 24
|
||||
#define SW_CELL 140
|
||||
#define SW_HEIGHT 70
|
||||
#define SW_MARGIN 12
|
||||
#define SW_TIMEOUT 5000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ClientData *pCD; /* the program's window to raise */
|
||||
char name[64];
|
||||
} SwProgram;
|
||||
|
||||
static Window swWindow = None;
|
||||
static GC swGC = None;
|
||||
static XtIntervalId swTimer = 0;
|
||||
static SwProgram swList[SW_MAX];
|
||||
static int swN = 0;
|
||||
static int swSel = 0;
|
||||
static Boolean swActive = False;
|
||||
|
||||
/* the overlay goes away by itself: one timer, a short flash */
|
||||
static void
|
||||
SwHide (XtPointer client, XtIntervalId *id)
|
||||
{
|
||||
(void) client;
|
||||
(void) id;
|
||||
swTimer = 0;
|
||||
swActive = False;
|
||||
if (swWindow != None)
|
||||
{
|
||||
XUnmapWindow (DISPLAY, swWindow);
|
||||
XFlush (DISPLAY);
|
||||
}
|
||||
}
|
||||
|
||||
/* the programs of the screen in the order of the stacking, one entry each:
|
||||
* the focused program first, so its neighbour is the one used before it */
|
||||
static int
|
||||
SwPrograms (void)
|
||||
{
|
||||
WmScreenData *pSD = ACTIVE_PSD;
|
||||
ClientListEntry *e;
|
||||
int n = 0;
|
||||
|
||||
for (e = pSD->clientList; e != NULL && n < SW_MAX; e = e->nextSibling)
|
||||
{
|
||||
ClientData *c = e->pCD;
|
||||
int i;
|
||||
Boolean have = False;
|
||||
|
||||
if (e->type != NORMAL_STATE || !McdeProgramWindow (c) ||
|
||||
c->clientClass == NULL)
|
||||
continue;
|
||||
for (i = 0; i < n; i++)
|
||||
if (strcmp (swList[i].name, c->clientClass) == 0)
|
||||
have = True;
|
||||
if (have)
|
||||
continue;
|
||||
swList[n].pCD = c;
|
||||
(void) snprintf (swList[n].name, sizeof swList[n].name, "%s",
|
||||
c->clientClass);
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/* the bar of programs in the middle of the screen: names, the chosen one
|
||||
* boxed (the icons of the reference need the program's icon file; the name
|
||||
* is what the window manager knows for certain) */
|
||||
static void
|
||||
SwDraw (void)
|
||||
{
|
||||
WmScreenData *pSD = ACTIVE_PSD;
|
||||
XSetWindowAttributes a;
|
||||
int width, height, x, y, i, depth;
|
||||
|
||||
width = swN * SW_CELL + 2 * SW_MARGIN;
|
||||
height = SW_HEIGHT + 2 * SW_MARGIN;
|
||||
x = (DisplayWidth (DISPLAY, pSD->screen) - width) / 2;
|
||||
y = (DisplayHeight (DISPLAY, pSD->screen) - height) / 2;
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
depth = DefaultDepth (DISPLAY, pSD->screen);
|
||||
if (swWindow != None)
|
||||
{
|
||||
XDestroyWindow (DISPLAY, swWindow);
|
||||
swWindow = None;
|
||||
}
|
||||
if (swGC == None)
|
||||
swGC = XCreateGC (DISPLAY, pSD->rootWindow, 0, NULL);
|
||||
memset (&a, 0, sizeof a);
|
||||
a.override_redirect = True;
|
||||
a.background_pixel = BlackPixel (DISPLAY, pSD->screen);
|
||||
a.border_pixel = WhitePixel (DISPLAY, pSD->screen);
|
||||
swWindow = XCreateWindow (DISPLAY, pSD->rootWindow, x, y, width, height,
|
||||
2, depth, InputOutput, DefaultVisual (DISPLAY, pSD->screen),
|
||||
CWOverrideRedirect | CWBackPixel | CWBorderPixel, &a);
|
||||
/* the map paints the background over what was drawn before it */
|
||||
XMapRaised (DISPLAY, swWindow);
|
||||
XSync (DISPLAY, False);
|
||||
XSetForeground (DISPLAY, swGC, WhitePixel (DISPLAY, pSD->screen));
|
||||
for (i = 0; i < swN; i++)
|
||||
{
|
||||
int cx = SW_MARGIN + i * SW_CELL;
|
||||
|
||||
XDrawString (DISPLAY, swWindow, swGC, cx + 14, SW_MARGIN + 30,
|
||||
swList[i].name, (int) strlen (swList[i].name));
|
||||
if (i == swSel)
|
||||
XDrawRectangle (DISPLAY, swWindow, swGC, cx + 2, SW_MARGIN - 4,
|
||||
SW_CELL - 6, SW_HEIGHT);
|
||||
}
|
||||
XFlush (DISPLAY);
|
||||
if (swTimer != 0)
|
||||
XtRemoveTimeOut (swTimer);
|
||||
swTimer = XtAppAddTimeOut (wmGD.mwmAppContext, SW_TIMEOUT, SwHide, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* f.mcde_switcher next|prev: the program after (or before) this one, in the
|
||||
* order of the stacking. Command+Tab pressed again while the bar is up
|
||||
* walks on in the same list; every press raises and focuses the program it
|
||||
* names (the reference waits for Command to be let go; this window manager
|
||||
* has no keyboard grab for it) and the bar goes away after a moment.
|
||||
*/
|
||||
Boolean F_McdeSwitcher (String args, ClientData *pCD, XEvent *event)
|
||||
{
|
||||
ClientData *focus = pCD != NULL ? pCD : wmGD.keyboardFocus;
|
||||
Boolean prev = args != NULL && strncmp (args, "prev", 4) == 0;
|
||||
int i, cur = 0;
|
||||
|
||||
if (!swActive)
|
||||
{
|
||||
swN = SwPrograms ();
|
||||
if (swN < 1)
|
||||
return (True);
|
||||
if (focus != NULL && focus->clientClass != NULL)
|
||||
for (i = 0; i < swN; i++)
|
||||
if (strcmp (swList[i].name, focus->clientClass) == 0)
|
||||
cur = i;
|
||||
swSel = (cur + (prev ? swN - 1 : 1)) % swN;
|
||||
swActive = True;
|
||||
}
|
||||
else if (prev)
|
||||
swSel = (swSel + swN - 1) % swN;
|
||||
else
|
||||
swSel = (swSel + 1) % swN;
|
||||
|
||||
Do_Raise (swList[swSel].pCD, (ClientListEntry *) NULL, STACK_NORMAL);
|
||||
Do_Focus_Key (swList[swSel].pCD, GetTimestamp (), ALWAYS_SET_FOCUS);
|
||||
SwDraw ();
|
||||
return (True);
|
||||
}
|
||||
|
||||
|
||||
/*************************************<->*************************************
|
||||
*
|
||||
* F_Raise_Lower (args, pCD, event)
|
||||
|
||||
@@ -83,6 +83,7 @@ extern void McdeRaiseAbove (WmScreenData *pSD);
|
||||
extern void McdeSetAbove (ClientData *pCD, Boolean on);
|
||||
extern Boolean F_McdeAbove (String args, ClientData *pCD, XEvent *event);
|
||||
extern Boolean F_McdeApp (String args, ClientData *pCD, XEvent *event);
|
||||
extern Boolean F_McdeSwitcher (String args, ClientData *pCD, XEvent *event);
|
||||
extern Boolean F_Raise_Lower (String args, ClientData *pCD, XEvent *event);
|
||||
extern Boolean F_Refresh_Win (String args, ClientData *pCD, XEvent *event);
|
||||
extern Boolean F_Set_Behavior (String args, ClientData *pCD, XEvent *event);
|
||||
|
||||
@@ -418,6 +418,13 @@ FunctionTableEntry functionTable[] = {
|
||||
0,
|
||||
F_McdeApp,
|
||||
ParseWmFuncStrArg},
|
||||
/* MCDE: the program switcher of Command+Tab (WmFunction.c) */
|
||||
{"f.mcde_switcher", F_CONTEXT_ROOT|F_CONTEXT_ICON|F_SUBCONTEXT_IB_IICON|
|
||||
F_SUBCONTEXT_IB_WICON,
|
||||
CRS_ANY,
|
||||
0,
|
||||
F_McdeSwitcher,
|
||||
ParseWmFuncStrArg},
|
||||
/* MCDE: full screen and the zones of the screen (WmMcdeSnap.c) */
|
||||
{"f.mcde_fullscreen", F_CONTEXT_ROOT|F_CONTEXT_ICON|F_SUBCONTEXT_IB_IICON|
|
||||
F_SUBCONTEXT_IB_WICON,
|
||||
|
||||
@@ -509,8 +509,8 @@ char builtinKeyBindingsName[] = "_MwmKeyBindings_";
|
||||
Alt<Key>F6 window f.next_key transient\n\
|
||||
Alt Shift<Key>F6 window f.prev_key transient\n\
|
||||
Shift<Key>F10 icon f.post_wmenu\n\
|
||||
Mod4<Key>Tab root|icon|window f.next_key\n\
|
||||
Mod4 Shift<Key>Tab root|icon|window f.prev_key\n\
|
||||
Mod4<Key>Tab root|icon|window f.mcde_app switcher\n\
|
||||
Mod4 Shift<Key>Tab root|icon|window f.mcde_app switcher-prev\n\
|
||||
Mod4<Key>m window f.minimize\n\
|
||||
Mod4 Ctrl<Key>f window f.mcde_fullscreen\n\
|
||||
Mod4 Ctrl<Key>Left window f.mcde_snap left-half\n\
|
||||
|
||||
Reference in new issue
Block a user