Wayland: Fix running background process via remote control not working when no OSWindow has focus

This commit is contained in:
Kovid Goyal 2024-05-17 13:56:46 +05:30
parent 2bfeb13628
commit b3cc5aed30
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 17 additions and 4 deletions

View file

@ -2431,7 +2431,8 @@ class Boss:
remote.close()
if is_wayland():
run_with_activation_token(doit)
if not run_with_activation_token(doit):
doit()
else:
doit()

View file

@ -1559,7 +1559,7 @@ def get_docs_ref_map() -> bytes: ...
def clearenv() -> None: ...
def set_clipboard_data_types(ct: int, mime_types: Tuple[str, ...]) -> None: ...
def get_clipboard_mime(ct: int, mime: Optional[str], callback: Callable[[bytes], None]) -> None: ...
def run_with_activation_token(func: Callable[[str], None]) -> None: ...
def run_with_activation_token(func: Callable[[str], None]) -> bool: ...
def make_x11_window_a_dock_window(x11_window_id: int, strut: Tuple[int, int, int, int, int, int, int, int, int, int, int, int]) -> None: ...
def unicode_database_version() -> Tuple[int, int, int]: ...
def wrapped_kitten_names() -> List[str]: ...

View file

@ -871,10 +871,22 @@ PYWRAP1(run_with_activation_token) {
OSWindow *os_window = global_state.os_windows + o;
if (os_window->is_focused) {
run_with_activation_token_in_os_window(os_window, args);
break;
Py_RETURN_TRUE;
}
}
Py_RETURN_NONE;
id_type os_window_id = last_focused_os_window_id();
if (!os_window_id) {
if (!global_state.num_os_windows) Py_RETURN_FALSE;
os_window_id = global_state.os_windows[0].id;
}
for (size_t o = 0; o < global_state.num_os_windows; o++) {
OSWindow *os_window = global_state.os_windows + o;
if (os_window->id == os_window_id) {
run_with_activation_token_in_os_window(os_window, args);
Py_RETURN_TRUE;
}
}
Py_RETURN_FALSE;
}
PYWRAP1(set_os_window_chrome) {