Harden DWM plugins against X11 stacking/keyboard grab races and speed up QMI status
This commit is contained in:
@@ -862,6 +862,7 @@ int runSmsApp(int argc, char** argv) {
|
||||
};
|
||||
|
||||
auto showWindow = [&](const std::string& argStr) {
|
||||
writeIntFile(activePidPath, static_cast<int>(::getpid()));
|
||||
closeOtherPlugins("sms");
|
||||
reloadAllData(true);
|
||||
lastTapDigit = -1;
|
||||
@@ -881,21 +882,13 @@ int runSmsApp(int argc, char** argv) {
|
||||
selectedThread = 0;
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -1117,6 +1110,15 @@ int runSmsApp(int argc, char** argv) {
|
||||
|
||||
if (ev.type == Expose && ev.xexpose.count == 0) {
|
||||
drawUI();
|
||||
} else if (ev.type == VisibilityNotify &&
|
||||
ev.xvisibility.state != VisibilityUnobscured) {
|
||||
if (isAnotherPluginActive("sms")) {
|
||||
hideWindow();
|
||||
} else {
|
||||
XRaiseWindow(dpy, win);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
drawUI();
|
||||
}
|
||||
} else if (ev.type == KeyRelease) {
|
||||
unsigned int kc = ev.xkey.keycode;
|
||||
KeySym sym = XLookupKeysym(&ev.xkey, 0);
|
||||
|
||||
Reference in New Issue
Block a user