fix(xdrawer,dwm,dmenu): remove top bar gap and eliminate softkey menu latency

This commit is contained in:
Luxferre
2026-10-21 10:11:11 +03:00
parent 8045929c87
commit 7b7ae1dcc5
9 changed files with 124 additions and 63 deletions
+14 -13
View File
@@ -33,13 +33,12 @@ namespace {
constexpr int kScreenWidth = 240;
constexpr int kScreenHeight = 320;
constexpr int kTopBarHeight = 26;
constexpr int kTopBarHeight = 24;
constexpr int kWinX = 0;
constexpr int kWinY = kTopBarHeight;
constexpr int kWinWidth = kScreenWidth;
constexpr int kWinHeight = kScreenHeight - kTopBarHeight; // 294px (7 * 42px)
constexpr int kWinHeight = kScreenHeight - kTopBarHeight; // 296px flush below 24px dwm bar
constexpr int kRowCount = 7;
constexpr int kRowHeight = kWinHeight / kRowCount; // 42px per row
// Nerd Font PUA icons matching sxmo_hook_icons.sh & dwm ("Fira Code, DejaVuSansM Nerd Font")
constexpr const char* kIconSpeaker = "\xef\x80\xa8"; // U+F028 speaker
@@ -587,18 +586,20 @@ int main() {
XSetForeground(dpy, gc, 0x222222);
XFillRectangle(dpy, pix, gc, 0, 0, kWinWidth, kWinHeight);
// 7 Control rows (42px each, 7 * 42 = 294px exact)
// 7 Control rows filling the full 296px height flush from y=24 to y=320
const auto& items = controller.items();
for (size_t i = 0; i < items.size(); ++i) {
int ry = static_cast<int>(i) * kRowHeight;
int ry = static_cast<int>((i * kWinHeight) / kRowCount);
int nextRy = static_cast<int>(((i + 1) * kWinHeight) / kRowCount);
int rowH = nextRy - ry;
bool isSel = (i == selected);
XSetForeground(dpy, gc, isSel ? 0x005577 : ((i % 2 == 0) ? 0x282828 : 0x2e2e2e));
XFillRectangle(dpy, pix, gc, 0, ry, kWinWidth, kRowHeight);
XFillRectangle(dpy, pix, gc, 0, ry, kWinWidth, rowH);
if (isSel) {
XSetForeground(dpy, gc, 0xf4d03f);
XFillRectangle(dpy, pix, gc, 0, ry, 4, kRowHeight);
XFillRectangle(dpy, pix, gc, 0, ry, 4, rowH);
}
const ControlItem& it = items[i];
@@ -607,8 +608,8 @@ int main() {
// Icon column (x = 8..28) + Label column (x = 30..112 for sliders, 30..166 for toggles)
int labelMaxW = it.isSlider ? 82 : 136;
drawPango(layoutIcon, isSel ? &colYellow : &colLight, 8, ry, kRowHeight, rowIcon);
drawPango(layoutMain, isSel ? &colWhite : &colLight, 30, ry, kRowHeight,
drawPango(layoutIcon, isSel ? &colYellow : &colLight, 8, ry, rowH, rowIcon);
drawPango(layoutMain, isSel ? &colWhite : &colLight, 30, ry, rowH,
it.label, labelMaxW);
if (it.isSlider) {
@@ -627,7 +628,7 @@ int main() {
int barX = 114;
int barW = 78;
int barH = 12;
int barY = ry + (kRowHeight - barH) / 2;
int barY = ry + (rowH - barH) / 2;
XSetForeground(dpy, gc, 0x161616);
XFillRectangle(dpy, pix, gc, barX, barY, barW, barH);
@@ -650,16 +651,16 @@ int main() {
std::string pctStr(pctBuf);
int pw = pangoWidth(layoutSmall, pctStr);
drawPango(layoutSmall, isSel ? &colWhite : &colLight, kWinWidth - pw - 6,
ry, kRowHeight, pctStr);
ry, rowH, pctStr);
} else {
// Toggle switch icon + ON/OFF label (right-aligned within x = 160..234)
bool on = (it.value != 0);
std::string stStr = on ? "ON" : "OFF";
int stW = pangoWidth(layoutMain, stStr);
drawPango(layoutMain, on ? (isSel ? &colYellow : &colGreen) : &colMuted,
kWinWidth - stW - 8, ry, kRowHeight, stStr);
kWinWidth - stW - 8, ry, rowH, stStr);
drawPango(layoutIcon, on ? (isSel ? &colYellow : &colGreen) : &colMuted,
kWinWidth - stW - 30, ry, kRowHeight,
kWinWidth - stW - 30, ry, rowH,
on ? kIconToggleOn : kIconToggleOff);
}
}