Harden DWM plugins against X11 stacking/keyboard grab races and speed up QMI status

This commit is contained in:
Luxferre
2026-10-25 14:14:21 +02:00
parent b2216c186f
commit e77be498bf
44 changed files with 432 additions and 211 deletions
+11 -9
View File
@@ -871,24 +871,17 @@ int runThemesApp(int argc, char** argv) {
};
auto showWindow = [&](const std::string& argStr) {
writeIntFile(activePidPath, static_cast<int>(::getpid()));
closeOtherPlugins("themes");
mode = ViewMode::Browser;
refreshThemes(argStr);
writeIntFile(activePidPath, static_cast<int>(::getpid()));
if (!visible) {
visible = true;
XMapRaised(dpy, win);
for (int i = 0; i < 20; ++i) {
if (XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync,
CurrentTime) == GrabSuccess) {
break;
}
usleep(2000);
}
} else {
XRaiseWindow(dpy, win);
}
XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
grabPluginKeyboard(dpy, win);
openStartMs = nowMs();
startupIgnoreUntilMs = openStartMs + 180;
initialSoftkeysReleased = (querySoftkeysDown(dpy) == 0);
@@ -1132,6 +1125,15 @@ int runThemesApp(int argc, char** argv) {
if (ev.type == Expose && ev.xexpose.count == 0) {
drawUI();
} else if (ev.type == VisibilityNotify &&
ev.xvisibility.state != VisibilityUnobscured) {
if (isAnotherPluginActive("themes")) {
hideWindow();
} else {
XRaiseWindow(dpy, win);
grabPluginKeyboard(dpy, win);
drawUI();
}
} else if (ev.type == KeyPress) {
int64_t tNow = nowMs();
unsigned int kc = ev.xkey.keycode;