Harden DWM plugins against X11 stacking/keyboard grab races and speed up QMI status
This commit is contained in:
@@ -576,6 +576,7 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
};
|
||||
|
||||
auto showWindow = [&]() {
|
||||
writeIntFile(activePidPath, static_cast<int>(::getpid()));
|
||||
closeOtherPlugins("ringtones");
|
||||
refreshData();
|
||||
for (size_t i = 0; i < tones.size(); ++i) {
|
||||
@@ -584,7 +585,6 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
writeIntFile(activePidPath, static_cast<int>(::getpid()));
|
||||
if (!visible) {
|
||||
visible = true;
|
||||
XMapRaised(dpy, win);
|
||||
@@ -592,14 +592,7 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
} else {
|
||||
XRaiseWindow(dpy, win);
|
||||
}
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
if (XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync,
|
||||
CurrentTime) == GrabSuccess) {
|
||||
break;
|
||||
}
|
||||
usleep(2000);
|
||||
}
|
||||
XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
startupIgnoreUntilMs = nowMs() + 180;
|
||||
initialSoftkeysReleased = (querySoftkeysDown(dpy) == 0);
|
||||
softkeyPending = 0;
|
||||
@@ -688,7 +681,13 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
render();
|
||||
} else if (ev.type == VisibilityNotify && visible &&
|
||||
ev.xvisibility.state != VisibilityUnobscured) {
|
||||
XRaiseWindow(dpy, win);
|
||||
if (isAnotherPluginActive("ringtones")) {
|
||||
hideWindow();
|
||||
} else {
|
||||
XRaiseWindow(dpy, win);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
render();
|
||||
}
|
||||
} else if (ev.type == KeyRelease) {
|
||||
if (!initialSoftkeysReleased && querySoftkeysDown(dpy) == 0) {
|
||||
initialSoftkeysReleased = true;
|
||||
|
||||
Reference in New Issue
Block a user