Phase 1: Alt+Tab switcher, dark GTK theme, alacritty terminal

- Alt+Tab now shows a centered visual switcher overlay with window cards;
  cycling with Tab, committing on Alt release, cancelling with Escape
- GTK3 and GTK2 themes rewritten in dark navy palette matching skywm/
  skydeskbar color constants (was an off-brand tan/BeOS palette)
- Add alacritty to ISO packages with pre-configured dark color scheme;
  update all menu Terminal entries to launch alacritty instead of xterm
- Add KeyReleaseMask to WM root event selection to detect Alt release

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 4.6 committed 2026-07-23 13:11:37 -04:00
1 parent e641720a3c
commit 9089c14a19
10 files changed
+378 -101

No files matched your search

+179
View File
@@ -0,0 +1,179 @@
#include "wm.h"
#define SWL_ITEM_W 130
#define SWL_ITEM_H 68
#define SWL_ICON_SZ 34
#define SWL_PAD 12
#define SWL_MAX_VIS 8
static void swl_populate(WM *wm) {
wm->swl_count = 0;
/* current focused window goes first */
if (wm->focused && !wm->focused->minimized) {
wm->swl_wins[0] = wm->focused->win;
strncpy(wm->swl_titles[0], wm->focused->title, 127);
wm->swl_titles[0][127] = '\0';
wm->swl_count = 1;
}
for (Client *c = wm->clients; c && wm->swl_count < 64; c = c->next) {
if (c->minimized) continue;
if (wm->focused && c == wm->focused) continue;
wm->swl_wins[wm->swl_count] = c->win;
strncpy(wm->swl_titles[wm->swl_count], c->title, 127);
wm->swl_titles[wm->swl_count][127] = '\0';
wm->swl_count++;
}
}
static int swl_vis(WM *wm) {
return wm->swl_count < SWL_MAX_VIS ? wm->swl_count : SWL_MAX_VIS;
}
/* Scroll window that keeps the selected item centered */
static int swl_view_start(WM *wm) {
int vis = swl_vis(wm);
if (wm->swl_count <= SWL_MAX_VIS) return 0;
int start = wm->swl_idx - vis / 2;
if (start < 0) start = 0;
if (start + vis > wm->swl_count) start = wm->swl_count - vis;
return start;
}
void switcher_draw(WM *wm) {
if (!wm->swl_visible || !wm->swl_win) return;
int vis = swl_vis(wm);
int vstart = swl_view_start(wm);
int tw = vis * SWL_ITEM_W + (vis + 1) * SWL_PAD;
int th = SWL_ITEM_H + SWL_PAD * 2;
XSetForeground(wm->dpy, wm->gc, color_alloc(wm, 0x141A28));
XFillRectangle(wm->dpy, wm->swl_win, wm->gc, 0, 0, tw, th);
XSetForeground(wm->dpy, wm->gc, color_alloc(wm, COLOR_BORDER_LIGHT));
XDrawRectangle(wm->dpy, wm->swl_win, wm->gc, 0, 0, tw - 1, th - 1);
XSetForeground(wm->dpy, wm->gc, color_alloc(wm, COLOR_BORDER_DARK));
XDrawRectangle(wm->dpy, wm->swl_win, wm->gc, 1, 1, tw - 3, th - 3);
XftDraw *xd = XftDrawCreate(wm->dpy, wm->swl_win, wm->visual, wm->cmap);
if (!xd) return;
for (int vi = 0; vi < vis; vi++) {
int i = vstart + vi;
int selected = (i == wm->swl_idx);
int ix = SWL_PAD + vi * (SWL_ITEM_W + SWL_PAD);
int iy = SWL_PAD;
unsigned long card_bg = color_alloc(wm, selected ? COLOR_TITLE_ACTIVE : 0x1C2338);
XSetForeground(wm->dpy, wm->gc, card_bg);
XFillRectangle(wm->dpy, wm->swl_win, wm->gc, ix, iy, SWL_ITEM_W, SWL_ITEM_H);
XSetForeground(wm->dpy, wm->gc,
color_alloc(wm, selected ? COLOR_BORDER_LIGHT : 0x242C3E));
XDrawRectangle(wm->dpy, wm->swl_win, wm->gc, ix, iy, SWL_ITEM_W - 1, SWL_ITEM_H - 1);
/* letter icon */
int icon_x = ix + (SWL_ITEM_W - SWL_ICON_SZ) / 2;
int icon_y = iy + 8;
XSetForeground(wm->dpy, wm->gc,
color_alloc(wm, selected ? 0x285898 : 0x182538));
XFillRectangle(wm->dpy, wm->swl_win, wm->gc, icon_x, icon_y, SWL_ICON_SZ, SWL_ICON_SZ);
char letter[2] = { wm->swl_titles[i][0] ? wm->swl_titles[i][0] : '?', '\0' };
if (letter[0] >= 'a' && letter[0] <= 'z') letter[0] -= 32;
XftColor icon_col;
xft_color(wm, selected ? COLOR_TITLE_TEXT_ACT : COLOR_TITLE_TEXT_INACT, &icon_col);
XGlyphInfo ext;
XftTextExtentsUtf8(wm->dpy, wm->font_title, (const FcChar8 *)letter, 1, &ext);
int lx = icon_x + (SWL_ICON_SZ - (int)ext.width) / 2;
int ly = icon_y + (SWL_ICON_SZ + (int)ext.height) / 2 - ext.y;
XftDrawStringUtf8(xd, &icon_col, wm->font_title, lx, ly, (const FcChar8 *)letter, 1);
XftColorFree(wm->dpy, wm->visual, wm->cmap, &icon_col);
/* title below icon */
const char *title = wm->swl_titles[i];
XftColor title_col;
xft_color(wm, selected ? COLOR_TITLE_TEXT_ACT : COLOR_TITLE_TEXT_INACT, &title_col);
XGlyphInfo text_ext;
XftTextExtentsUtf8(wm->dpy, wm->font_title,
(const FcChar8 *)title, strlen(title), &text_ext);
int tx = ix + (SWL_ITEM_W - (int)text_ext.width) / 2;
if (tx < ix + 4) tx = ix + 4;
int ty = icon_y + SWL_ICON_SZ + 4 + (int)text_ext.height - text_ext.y;
XRectangle clip = { (short)(ix + 2), (short)(icon_y + SWL_ICON_SZ + 4),
(unsigned short)(SWL_ITEM_W - 4), 14 };
XftDrawSetClipRectangles(xd, 0, 0, &clip, 1);
XftDrawStringUtf8(xd, &title_col, wm->font_title, tx, ty,
(const FcChar8 *)title, strlen(title));
XftDrawSetClip(xd, None);
XftColorFree(wm->dpy, wm->visual, wm->cmap, &title_col);
}
/* scroll arrows when more windows than fit */
if (wm->swl_count > SWL_MAX_VIS) {
XftColor arrow;
xft_color(wm, 0x5878A0, &arrow);
if (vstart > 0)
XftDrawStringUtf8(xd, &arrow, wm->font_title, 3, th / 2 + 4,
(const FcChar8 *)"\xe2\x97\x80", 3);
if (vstart + SWL_MAX_VIS < wm->swl_count)
XftDrawStringUtf8(xd, &arrow, wm->font_title, tw - 11, th / 2 + 4,
(const FcChar8 *)"\xe2\x96\xb6", 3);
XftColorFree(wm->dpy, wm->visual, wm->cmap, &arrow);
}
XftDrawDestroy(xd);
XFlush(wm->dpy);
}
void switcher_show(WM *wm) {
swl_populate(wm);
if (wm->swl_count < 2) return;
wm->swl_idx = 1;
wm->swl_visible = 1;
int vis = swl_vis(wm);
int tw = vis * SWL_ITEM_W + (vis + 1) * SWL_PAD;
int th = SWL_ITEM_H + SWL_PAD * 2;
int sw = DisplayWidth(wm->dpy, wm->screen);
int sh = DisplayHeight(wm->dpy, wm->screen);
XSetWindowAttributes swa;
swa.override_redirect = True;
swa.background_pixel = color_alloc(wm, 0x141A28);
swa.event_mask = ExposureMask;
wm->swl_win = XCreateWindow(
wm->dpy, wm->root,
(sw - tw) / 2, (sh - th) / 2, tw, th, 2,
CopyFromParent, InputOutput, CopyFromParent,
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa
);
XSetWindowBorder(wm->dpy, wm->swl_win, color_alloc(wm, COLOR_BORDER_LIGHT));
XMapRaised(wm->dpy, wm->swl_win);
switcher_draw(wm);
XGrabKeyboard(wm->dpy, wm->root, False, GrabModeAsync, GrabModeAsync, CurrentTime);
}
void switcher_next(WM *wm) {
if (!wm->swl_visible) return;
wm->swl_idx = (wm->swl_idx + 1) % wm->swl_count;
switcher_draw(wm);
}
void switcher_hide(WM *wm, int commit) {
if (!wm->swl_visible) return;
XUngrabKeyboard(wm->dpy, CurrentTime);
if (wm->swl_win) { XDestroyWindow(wm->dpy, wm->swl_win); wm->swl_win = 0; }
wm->swl_visible = 0;
if (commit && wm->swl_count > 0) {
Client *c = client_find_by_win(wm, wm->swl_wins[wm->swl_idx]);
if (c) {
if (c->minimized) client_restore(wm, c);
else client_focus(wm, c);
}
}
}