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
+13 -8
View File
@@ -333,6 +333,7 @@ int calllog_run_main(int argc, char** argv) {
XSync(dpy, False);
auto showWindow = [&]() {
writeIntFile(activePidPath, static_cast<int>(::getpid()));
closeOtherPlugins("calllog");
bool themeChanged = theme.checkAndReload(
dpy, screen, visual, cmap, layoutMain, layoutSmall, layoutIcon,
@@ -348,13 +349,7 @@ int calllog_run_main(int argc, char** argv) {
if (!themeChanged) {
XCopyArea(dpy, pix, win, gc, 0, 0, kWinWidth, kWinHeight, 0, 0);
}
for (int i = 0; i < 20; ++i) {
if (XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync, CurrentTime) ==
GrabSuccess) {
break;
}
usleep(2000);
}
grabPluginKeyboard(dpy, win);
if (reloadLogsIfNeeded() || themeChanged || filterTab != 0 || selected != 0) {
filterTab = 0;
selected = 0;
@@ -362,8 +357,9 @@ int calllog_run_main(int argc, char** argv) {
render();
}
XFlush(dpy);
writeIntFile(activePidPath, static_cast<int>(::getpid()));
} else {
XRaiseWindow(dpy, win);
grabPluginKeyboard(dpy, win);
if (reloadLogsIfNeeded() || themeChanged) {
render();
}
@@ -444,6 +440,15 @@ int calllog_run_main(int argc, char** argv) {
if (ev.xexpose.count == 0) {
render();
}
} else if (ev.type == VisibilityNotify &&
ev.xvisibility.state != VisibilityUnobscured) {
if (isAnotherPluginActive("calllog")) {
hideWindow(false);
} else {
XRaiseWindow(dpy, win);
grabPluginKeyboard(dpy, win);
render();
}
} else if (ev.type == KeyRelease) {
KeySym sym = XLookupKeysym(&ev.xkey, 0);
if (sym == XK_Menu || sym == XF86XK_KbdLcdMenu1 ||