Preempt X11 keyboard grabs and window stacking when lockscreen is active
This commit is contained in:
1 parent
83dd79fe76
commit
f112b6ae72
78 files changed
+403
-53
No files matched your search
@@ -297,6 +297,15 @@ int engmenu_run_main(int argc, char** argv) {
|
||||
if (visible && ev.xexpose.count == 0) {
|
||||
render();
|
||||
}
|
||||
} else if (ev.type == VisibilityNotify && visible &&
|
||||
ev.xvisibility.state != VisibilityUnobscured) {
|
||||
if (isAnotherPluginActive("engmenu")) {
|
||||
closeWindow();
|
||||
} else {
|
||||
XRaiseWindow(dpy, win);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
render();
|
||||
}
|
||||
} else if (ev.type == KeyPress) {
|
||||
if (!visible) {
|
||||
continue;
|
||||
|
||||
@@ -420,7 +420,9 @@ int locker_run_main(int argc, char** argv) {
|
||||
}
|
||||
XRaiseWindow(dpy, win);
|
||||
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
|
||||
for (int attempt = 0; attempt < 5; ++attempt) {
|
||||
XFlush(dpy);
|
||||
grabHeld = false;
|
||||
for (int attempt = 0; attempt < 15; ++attempt) {
|
||||
if (XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync,
|
||||
CurrentTime) == GrabSuccess) {
|
||||
grabHeld = true;
|
||||
@@ -895,12 +897,19 @@ int locker_run_main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if (visible && !isScreenBlanked()) {
|
||||
render();
|
||||
if (visible) {
|
||||
if (!isCallActiveOrRingingFast() && !grabHeld) {
|
||||
grabLockerInput();
|
||||
}
|
||||
if (!isScreenBlanked()) {
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
int timeoutMs = -1;
|
||||
if (visible && !isScreenBlanked()) {
|
||||
if (visible && !isCallActiveOrRingingFast() && !grabHeld) {
|
||||
timeoutMs = 35;
|
||||
} else if (visible && !isScreenBlanked()) {
|
||||
int64_t now = nowMs();
|
||||
if (cooldownUntilMs > now) {
|
||||
timeoutMs = 250;
|
||||
|
||||
@@ -564,6 +564,15 @@ int passcode_run_main(int argc, char** argv) {
|
||||
if (visible && ev.xexpose.count == 0) {
|
||||
render();
|
||||
}
|
||||
} else if (ev.type == VisibilityNotify && visible &&
|
||||
ev.xvisibility.state != VisibilityUnobscured) {
|
||||
if (isAnotherPluginActive("passcode")) {
|
||||
closeWindow();
|
||||
} else {
|
||||
XRaiseWindow(dpy, win);
|
||||
grabPluginKeyboard(dpy, win);
|
||||
render();
|
||||
}
|
||||
} else if (ev.type == KeyPress) {
|
||||
if (!visible) {
|
||||
continue;
|
||||
|
||||
@@ -1893,6 +1893,10 @@ inline void closeOtherPlugins(const char* selfPluginName) {
|
||||
}
|
||||
|
||||
inline bool isAnotherPluginActive(const char* selfPluginName) {
|
||||
if ((!selfPluginName || std::strcmp(selfPluginName, "locker") != 0) &&
|
||||
::access("/tmp/bananarchy_screen_locked", F_OK) == 0) {
|
||||
return true;
|
||||
}
|
||||
struct PluginRef {
|
||||
const char* pidFile;
|
||||
const char* name;
|
||||
@@ -1939,6 +1943,12 @@ inline bool isAnotherPluginActive(const char* selfPluginName) {
|
||||
}
|
||||
|
||||
inline void grabPluginKeyboard(Display* dpy, Window win) {
|
||||
if (::access("/tmp/bananarchy_screen_locked", F_OK) == 0 &&
|
||||
!isCallActiveOrRingingFast()) {
|
||||
XUngrabKeyboard(dpy, CurrentTime);
|
||||
XFlush(dpy);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < 40; ++i) {
|
||||
if (XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync,
|
||||
CurrentTime) == GrabSuccess) {
|
||||
|
||||
@@ -1094,7 +1094,7 @@ int webarchy_run_main(int argc, char** argv) {
|
||||
|
||||
auto syncWebkitVisibility = [&]() {
|
||||
if (!br.initialized || br.webkitXid == None) return;
|
||||
if (visible && !anyModalOpen()) {
|
||||
if (visible && !anyModalOpen() && !isPhonePasscodeLocked()) {
|
||||
XMoveResizeWindow(neo.dpy, br.webkitXid, 0, 35, 240, 217);
|
||||
XMapRaised(neo.dpy, br.webkitXid);
|
||||
} else if (visible) {
|
||||
@@ -1358,6 +1358,7 @@ int webarchy_run_main(int argc, char** argv) {
|
||||
openWindow();
|
||||
}
|
||||
|
||||
bool mutedByLock = false;
|
||||
while (gRunning) {
|
||||
for (const std::string& cmd : readFifoLines(fifoFd)) {
|
||||
if (cmd == "NOP") continue;
|
||||
@@ -1407,6 +1408,23 @@ int webarchy_run_main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
if (isPhonePasscodeLocked()) {
|
||||
if (!mutedByLock) {
|
||||
mutedByLock = true;
|
||||
XUngrabKeyboard(neo.dpy, CurrentTime);
|
||||
XFlush(neo.dpy);
|
||||
if (br.initialized && br.webView) {
|
||||
webkit_web_view_set_is_muted(br.webView, TRUE);
|
||||
}
|
||||
syncWebkitVisibility();
|
||||
}
|
||||
} else if (mutedByLock) {
|
||||
mutedByLock = false;
|
||||
if (br.initialized && br.webView) {
|
||||
webkit_web_view_set_is_muted(br.webView, FALSE);
|
||||
}
|
||||
render();
|
||||
}
|
||||
neo.bindAsActiveContext();
|
||||
int ev = neoui_poll_event(0);
|
||||
while (ev != NEO_EV_NONE) {
|
||||
|
||||
Reference in new issue
Block a user