Skip to content

Commit 08c010c

Browse files
committed
src/: main.sh, modules/flux_cursor_grab.c: Add delay before cursor grab to prevent failure in case window appears focused with mouse click.
1 parent 7d5dbea commit 08c010c

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/main.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ while read -r raw_event ||
404404

405405
# Print message about successful cursor grabbing if process still exists
406406
(
407-
sleep 0.1
407+
sleep 0.2
408408
if check_pid_existence "${background_focus_cursor_grab_map["$window_xid"]}"; then
409409
message --info "Cursor for window with XID $window_xid of process '$process_name' with PID $process_pid has been grabbed due to focus event."
410410
else

src/modules/flux_cursor_grab.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ int main(int argc, char *argv[]) {
5656
XUngrabPointer(display, CurrentTime);
5757
}
5858

59+
// Wait a bit to prevent failure in case window gets focus with mouse click
60+
usleep(100000);
61+
5962
// Attempt to grab cursor as that is daemonized process and I don't want hook another Bash instance for it to check exit code (which I won't get ever if no error occur)
6063
int grab_status = XGrabPointer(display, window, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
6164
GrabModeAsync, GrabModeAsync, window, None, CurrentTime);

0 commit comments

Comments
 (0)