Harden DWM plugins against X11 stacking/keyboard grab races and speed up QMI status
This commit is contained in:
1 parent
b2216c186f
commit
e77be498bf
44 files changed
+432
-211
No files matched your search
@@ -926,6 +926,7 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
XSync(dpy, False);
|
||||
|
||||
auto showWindow = [&]() {
|
||||
writeIntFile(activePidPath, static_cast<int>(::getpid()));
|
||||
closeOtherPlugins("callscreen");
|
||||
wakeDisplayHardware(dpy);
|
||||
theme.checkAndReload(dpy, screen, visual, cmap, layoutMain, layoutSmall,
|
||||
@@ -942,17 +943,11 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
visible = true;
|
||||
XMapRaised(dpy, win);
|
||||
render();
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
if (XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync, CurrentTime) ==
|
||||
GrabSuccess) {
|
||||
break;
|
||||
}
|
||||
usleep(2000);
|
||||
}
|
||||
grabPluginKeyboard(dpy, win);
|
||||
XFlush(dpy);
|
||||
writeIntFile(activePidPath, static_cast<int>(::getpid()));
|
||||
} else {
|
||||
XMapRaised(dpy, win);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
render();
|
||||
}
|
||||
};
|
||||
@@ -1379,6 +1374,15 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
if (ev.xexpose.count == 0) {
|
||||
render();
|
||||
}
|
||||
} else if (ev.type == VisibilityNotify &&
|
||||
ev.xvisibility.state != VisibilityUnobscured) {
|
||||
if (isAnotherPluginActive("callscreen")) {
|
||||
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 ||
|
||||
|
||||
Reference in new issue
Block a user