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
@@ -765,6 +765,7 @@ int runContactsApp(int argc, char** argv) {
|
||||
};
|
||||
|
||||
auto showWindow = [&](const std::string& arg) {
|
||||
writeIntFile(activePidPath, static_cast<int>(::getpid()));
|
||||
closeOtherPlugins("contacts");
|
||||
bool themeChanged = theme.checkAndReload(
|
||||
dpy, screen, visual, cmap, layoutMain, layoutSmall, layoutIcon,
|
||||
@@ -784,13 +785,7 @@ int runContactsApp(int argc, char** argv) {
|
||||
if (!openNewMode && !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);
|
||||
bool reloaded = reloadContactsIfNeeded();
|
||||
if (openNewMode) {
|
||||
beginNewContact(prefill);
|
||||
@@ -804,8 +799,9 @@ int runContactsApp(int argc, char** argv) {
|
||||
render();
|
||||
}
|
||||
XFlush(dpy);
|
||||
writeIntFile(activePidPath, static_cast<int>(::getpid()));
|
||||
} else {
|
||||
XRaiseWindow(dpy, win);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
reloadContactsIfNeeded();
|
||||
if (openNewMode) {
|
||||
beginNewContact(prefill);
|
||||
@@ -914,9 +910,13 @@ int runContactsApp(int argc, char** argv) {
|
||||
render();
|
||||
int rc = 0;
|
||||
std::string out = runCaptureCmd(
|
||||
"doas /usr/libexec/msm-modem-uim-selection sim-contacts-import " +
|
||||
"doas -n /usr/libexec/msm-modem-uim-selection sim-contacts-import " +
|
||||
std::to_string(slotNum) + " 2>&1",
|
||||
&rc);
|
||||
if (visible) {
|
||||
XRaiseWindow(dpy, win);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
}
|
||||
if (out.rfind("ERROR:", 0) == 0) {
|
||||
std::string err = trimStr(out.substr(6));
|
||||
setStatus(err.empty() ? "SIM import failed" : err, true);
|
||||
@@ -975,9 +975,13 @@ int runContactsApp(int argc, char** argv) {
|
||||
render();
|
||||
int rc = 0;
|
||||
std::string out = runCaptureCmd(
|
||||
"doas /usr/libexec/msm-modem-uim-selection sim-contacts-export " +
|
||||
"doas -n /usr/libexec/msm-modem-uim-selection sim-contacts-export " +
|
||||
std::to_string(slotNum) + " " + shellQuote(srcFile) + " 2>&1",
|
||||
&rc);
|
||||
if (visible) {
|
||||
XRaiseWindow(dpy, win);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
}
|
||||
if (!tmpSingle.empty()) {
|
||||
::unlink(tmpSingle.c_str());
|
||||
}
|
||||
@@ -1015,7 +1019,11 @@ int runContactsApp(int argc, char** argv) {
|
||||
prevModeBeforeSim =
|
||||
(op == SimOp::ExportSingle) ? ViewMode::Detail : ViewMode::List;
|
||||
std::string st = runCaptureCmd(
|
||||
"doas /usr/libexec/msm-modem-uim-selection status 2>/dev/null");
|
||||
"doas -n /usr/libexec/msm-modem-uim-selection status 2>/dev/null");
|
||||
if (visible) {
|
||||
XRaiseWindow(dpy, win);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
}
|
||||
bool s1Present = false;
|
||||
bool s2Present = false;
|
||||
int gwSlot = 1;
|
||||
@@ -1203,6 +1211,15 @@ int runContactsApp(int argc, char** argv) {
|
||||
if (ev.xexpose.count == 0) {
|
||||
render();
|
||||
}
|
||||
} else if (ev.type == VisibilityNotify &&
|
||||
ev.xvisibility.state != VisibilityUnobscured) {
|
||||
if (isAnotherPluginActive("contacts")) {
|
||||
hideWindow(false);
|
||||
} else {
|
||||
XRaiseWindow(dpy, win);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
render();
|
||||
}
|
||||
} else if (ev.type == KeyRelease) {
|
||||
KeySym sym = XLookupKeysym(&ev.xkey, 0);
|
||||
if (ev.xkey.keycode == 19 || sym == XK_0) {
|
||||
|
||||
Reference in new issue
Block a user