@@ -817,21 +817,27 @@ function wiggle(actor, params) {
817817/**
818818 * switchToGreeter:
819819 *
820- * Switches to the display manager's login greeter, allowing another user
821- * to log in without logging out the current user. Tries multiple display
822- * manager methods in order of preference.
820+ * Locks the screen and switches to the greeter, allowing another user
821+ * to log in without logging out the current user. If the screen is
822+ * already locked (e.g. called from the screensaver itself), switches
823+ * immediately.
823824 */
824825function switchToGreeter ( ) {
825- GLib . idle_add ( GLib . PRIORITY_DEFAULT , _doSwitchToGreeter ) ;
826- }
826+ let controller = Main . screensaverController ;
827827
828- function _doSwitchToGreeter ( ) {
829- // Check if user switching is locked down
830- if ( Main . lockdownSettings . get_boolean ( 'disable-user-switching' ) ) {
831- global . logWarning ( "User switching is locked down" ) ;
832- return GLib . SOURCE_REMOVE ;
828+ if ( controller . locked ) {
829+ GLib . idle_add ( GLib . PRIORITY_DEFAULT , _doSwitchToGreeter ) ;
830+ return ;
833831 }
834832
833+ controller . lockScreen ( false , ( wasLocked ) => {
834+ if ( ! wasLocked )
835+ return ;
836+ GLib . idle_add ( GLib . PRIORITY_DEFAULT , _doSwitchToGreeter ) ;
837+ } ) ;
838+ }
839+
840+ function _doSwitchToGreeter ( ) {
835841 if ( _processIsRunning ( 'gdm' ) ) {
836842 // Old GDM
837843 try {
0 commit comments