summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-07-30 15:52:11 +0200
committerSimon Rettberg2019-07-30 15:52:11 +0200
commit70fe2325b1be6a7ad4c30b65fd3c0d1a6f620ae1 (patch)
tree19471e8219f982168cf80afcac826e194c8cd146
parentMerge branch 'master' into openslx (diff)
downloadxscreensaver-70fe2325b1be6a7ad4c30b65fd3c0d1a6f620ae1.tar.gz
xscreensaver-70fe2325b1be6a7ad4c30b65fd3c0d1a6f620ae1.tar.xz
xscreensaver-70fe2325b1be6a7ad4c30b65fd3c0d1a6f620ae1.zip
Flush X events before locking if we have an external ungrab command
The external ungrab command might have generated some synthetic keyboard or mouse events, which would in turn immediately disable the screen saver again if it gets activated (but not locked). This is supposed to help mitigate that case.
-rw-r--r--driver/timers.c13
-rw-r--r--driver/windows.c4
-rw-r--r--driver/xscreensaver.h1
3 files changed, 18 insertions, 0 deletions
diff --git a/driver/timers.c b/driver/timers.c
index fc8b47a..591b568 100644
--- a/driver/timers.c
+++ b/driver/timers.c
@@ -689,6 +689,19 @@ swallow_unlock_typeahead_events (saver_info *si, XEvent *e)
memset (buf, 0, sizeof(buf));
}
+void
+flush_events (saver_info *si)
+{
+ int i;
+ XEvent xe;
+ for (i = 0; i < 10; ++i) {
+ while (XtAppPending (si->app) != 0) {
+ XtAppNextEvent (si->app, &xe);
+ dispatch_event (si, &xe);
+ }
+ usleep(5000);
+ }
+}
/* methods of detecting idleness:
diff --git a/driver/windows.c b/driver/windows.c
index c54f15e..ceba8c8 100644
--- a/driver/windows.c
+++ b/driver/windows.c
@@ -337,6 +337,10 @@ grab_keyboard_and_mouse (saver_info *si, Window window, Cursor cursor,
{
snprintf (cmd, sizeof(cmd), "%s %s", euc, "post");
exec_and_wait (si, cmd);
+ if (ret) {
+ /* The external command might have generated some x/input events */
+ flush_events (si);
+ }
}
return ret;
}
diff --git a/driver/xscreensaver.h b/driver/xscreensaver.h
index c5b5644..2a3ae02 100644
--- a/driver/xscreensaver.h
+++ b/driver/xscreensaver.h
@@ -129,6 +129,7 @@ extern void activate_lock_timer (XtPointer si, XtIntervalId *id);
extern void reset_watchdog_timer (saver_info *si, Bool on_p);
extern void idle_timer (XtPointer si, XtIntervalId *id);
extern void de_race_timer (XtPointer si, XtIntervalId *id);
+void flush_events (saver_info *si);
extern void sleep_until_idle (saver_info *si, Bool until_idle_p);
extern void reset_timers (saver_info *si);
extern void schedule_wakeup_event (saver_info *si, Time when, Bool verbose_p);