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
@@ -711,26 +711,19 @@ int runCameraApp(int argc, char** argv) {
|
||||
};
|
||||
|
||||
auto showWindow = [&](const std::string& argStr) {
|
||||
writeIntFile(activePidPath, static_cast<int>(::getpid()));
|
||||
closeOtherPlugins("camera");
|
||||
countdownActive = false;
|
||||
torchOn = getTorchState();
|
||||
torchRestoredOnClose = !torchOn;
|
||||
|
||||
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);
|
||||
@@ -822,6 +815,15 @@ int runCameraApp(int argc, char** argv) {
|
||||
|
||||
if (ev.type == Expose && ev.xexpose.count == 0) {
|
||||
drawUI();
|
||||
} else if (ev.type == VisibilityNotify &&
|
||||
ev.xvisibility.state != VisibilityUnobscured) {
|
||||
if (isAnotherPluginActive("camera")) {
|
||||
hideWindow();
|
||||
} else {
|
||||
XRaiseWindow(dpy, win);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
drawUI();
|
||||
}
|
||||
} else if (ev.type == KeyPress) {
|
||||
int64_t tNow = nowMs();
|
||||
unsigned int kc = ev.xkey.keycode;
|
||||
@@ -925,7 +927,9 @@ int runCameraApp(int argc, char** argv) {
|
||||
enterViewfinderMode();
|
||||
drawUI();
|
||||
} else {
|
||||
runAsyncArgv("feh", photos[selectedPhoto].fullPath.c_str());
|
||||
std::string path = photos[selectedPhoto].fullPath;
|
||||
hideWindow();
|
||||
runAsyncArgv("feh", path.c_str());
|
||||
}
|
||||
}
|
||||
} else if (mode == ViewMode::ConfirmDelete) {
|
||||
|
||||
Reference in new issue
Block a user