From http://www.jwz.org/xscreensaver/xscreensaver-5.34.tar.gz
[xscreensaver] / driver / xscreensaver.c
index d7478378a3da5e7d561252724fc57c152a8f23cf..45f0f0c48330afda7192a3b02fc6aee26100f965 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-2014 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1991-2015 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -608,6 +608,16 @@ lock_initialization (saver_info *si, int *argc, char **argv)
         }
     }
 
+  /* Like MacOS, locking under Wayland's embedded X11 server does not work.
+     (X11 grabs don't work because the Wayland window manager lives at a
+     higher level than the X11 emulation layer.)
+   */
+  if (!si->locking_disabled_p && getenv ("WAYLAND_DISPLAY"))
+    {
+      si->locking_disabled_p = True;
+      si->nolock_reason = "Cannot lock securely under Wayland";
+    }
+
   if (si->prefs.debug_p)    /* But allow locking anyway in debug mode. */
     si->locking_disabled_p = False;
 
@@ -1265,6 +1275,12 @@ main_loop (saver_info *si)
                   "%s: unable to grab keyboard or mouse!  Blanking aborted.\n",
                        blurb());
 
+              /* Since we were unable to blank, clearly we're not locked,
+                 but we might have been prematurely marked as locked by
+                 the LOCK ClientMessage. */
+              if (si->locked_p)
+                set_locked_p (si, False);
+
               schedule_wakeup_event (si, retry, p->debug_p);
               continue;
             }
@@ -2053,7 +2069,16 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
                            : "locking.");
          sprintf (buf, "LOCK ClientMessage received; %s", response);
          clientmessage_response (si, window, False, buf, response);
+
+          /* Note that this leaves things in a slightly inconsistent state:
+             we are blanked but not locked.  And blanking might actually
+             fail if we can't get the grab. */
          set_locked_p (si, True);
+
+           /* Have to set the time or xscreensaver-command doesn't
+              report the LOCK state change. */
+           si->blank_time = time ((time_t *) 0);
+
          si->selection_mode = 0;
          si->demoing_p = False;