After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 689106 - ScreenShield: try harder to become modal, and catch failures
ScreenShield: try harder to become modal, and catch failures
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: lock-screen
unspecified
Other All
: High critical
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
: 353437 687940 690195 690307 691094 692991 693546 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-11-26 19:22 UTC by Giovanni Campagna
Modified: 2014-08-20 19:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ScreenShield: try harder to become modal, and catch failures (3.78 KB, patch)
2012-11-26 19:23 UTC, Giovanni Campagna
none Details | Review
ScreenShield: try harder to become modal, and catch failures (3.70 KB, patch)
2012-11-26 19:32 UTC, Giovanni Campagna
reviewed Details | Review
ScreenShield: try harder to become modal, and catch failures (3.88 KB, patch)
2013-01-18 22:41 UTC, Giovanni Campagna
accepted-commit_now Details | Review
ScreenShield: try harder to become modal, and catch failures (3.89 KB, patch)
2013-02-10 20:23 UTC, Florian Müllner
accepted-commit_now Details | Review
Error after explicit lock from user menu (40.46 KB, image/png)
2013-02-10 20:26 UTC, Florian Müllner
  Details
Error after implicit lock on idle (42.27 KB, image/png)
2013-02-10 20:27 UTC, Florian Müllner
  Details
ScreenShield: try harder to become modal, and catch failures (3.78 KB, patch)
2013-02-13 16:48 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2012-11-26 19:22:57 UTC
Downstream report https://bugzilla.redhat.com/show_bug.cgi?id=878736
Comment 1 Giovanni Campagna 2012-11-26 19:23:01 UTC
Created attachment 229933 [details] [review]
ScreenShield: try harder to become modal, and catch failures

The screenshield was not checking the return value of pushModal(), meaning
that it believed it was fully locked when it was not. Later, calling
popModal() would fail, causing an exception and blocking the unlock.
Now we do nothing for user initiated actions, and fail with an explanatory
message at idle time.
Comment 2 Giovanni Campagna 2012-11-26 19:32:02 UTC
Created attachment 229937 [details] [review]
ScreenShield: try harder to become modal, and catch failures

The screenshield was not checking the return value of pushModal(), meaning
that it believed it was fully locked when it was not. Later, calling
popModal() would fail, causing an exception and blocking the unlock.
Now we do nothing for user initiated actions, and fail with an explanatory
message at idle time.

gnome 3-6 patch
Comment 3 Matthias Clasen 2012-11-26 22:27:38 UTC
Review of attachment 229937 [details] [review]:

::: js/ui/screenShield.js
@@ +584,3 @@
+            // screen, where we're not affected by grabs
+            Main.notifyError(_("Failed to activate screen lock"),
+                             _("The activation of the screen lock was blocked by an application that captured the pointer and the keyboard."));

Would probably be more correct to say the pointer _or_ the keyboard ?
Comment 4 Amit Shah 2012-11-29 14:46:36 UTC
If I'm reading the patch right, the screen will not be locked if the keyboard/mouse are 'stolen'.  And there's no re-try as well, if the focus couldn't be obtained.

If that's the case, this needs more work.  For example, this happens to me when using workrave, which prompts often for breaks, and steals keyboard/mouse focus so that the user is forced to take breaks.
Comment 5 Giovanni Campagna 2012-11-29 15:25:28 UTC
Sorry, but if the application does that it is broken, and it should be changed to steal focus and/or warp the mouse, not actively grab it.
There is no way in the X protocol to know when a grab is released, so we'd have to continuously poll until we obtain it.

Yes, X11 grab are broken, but there is little we can do about it. By the way, gnome-screensaver had the same problem: in place of grabs, it just refused to lock.
Comment 6 Amit Shah 2012-11-29 17:09:39 UTC
Hm, I didn't face this problem till 3.2 (didn't try 3.4) -- so looks like a regression from that POV.
Comment 7 Amit Shah 2012-11-29 17:12:38 UTC
I tried the patch (just patched /usr/share/gnome-shell/js/ui/screenShield.js in my Fedora install), and even when workrave isn't active the screen doesn't lock.  Any pointers?
Comment 8 Amit Shah 2012-11-30 06:12:24 UTC
Just now reproduced with workrave not running, and without the patch.  So it's not related to workrave.
Comment 9 Florian Müllner 2012-11-30 19:02:43 UTC
Review of attachment 229937 [details] [review]:

The code looks reasonable, but I'm unsure about the UI. Can you please run this by the designers?

::: js/ui/screenShield.js
@@ +451,3 @@
+
+        // We failed to get a pointer grab, it means that
+        // something else has it. Try with a keyboard grab only

Not sure about using a fallback here rather than failing directly

@@ +584,3 @@
+            // screen, where we're not affected by grabs
+            Main.notifyError(_("Failed to activate screen lock"),
+                             _("The activation of the screen lock was blocked by an application that captured the pointer and the keyboard."));

With the fallback, only a keyboard grab is relevant, otherwise what Matthias says.

Also I don't think using notifyError() is very useful here - this is triggered on idle, so the notification is almost certainly closed before the user has seen it.

@@ +884,3 @@
+        // No effect if we can't become modal
+        if (!this._becomeModal())
+            return;

Not sure silently ignoring a user request is a good idea.
Comment 10 Giovanni Campagna 2012-12-02 23:20:01 UTC
*** Bug 687940 has been marked as a duplicate of this bug. ***
Comment 11 Giovanni Campagna 2012-12-15 02:53:52 UTC
*** Bug 690195 has been marked as a duplicate of this bug. ***
Comment 12 Giovanni Campagna 2012-12-16 21:38:33 UTC
*** Bug 690307 has been marked as a duplicate of this bug. ***
Comment 13 Matthias Clasen 2013-01-11 19:45:52 UTC
> The code looks reasonable, but I'm unsure about the UI. Can you please run this
> by the designers?

What is the UI here ? Screenshot ?
Comment 14 Giovanni Campagna 2013-01-18 22:40:17 UTC
There is not much UI here, just a notification to be shown after coming back, explaining the issue.

Following Florian's suggestion, I also added another notification, for when the lock is requested manually.
Comment 15 Giovanni Campagna 2013-01-18 22:41:50 UTC
Created attachment 233805 [details] [review]
ScreenShield: try harder to become modal, and catch failures

The screenshield was not checking the return value of pushModal(), meaning
that it believed it was fully locked when it was not. Later, calling
popModal() would fail, causing an exception and blocking the unlock.
Now when we fail we include an explanatory message, pointing the user
to the actual cause of the issue.
Comment 16 drago01 2013-02-05 21:16:19 UTC
Review of attachment 233805 [details] [review]:

Makes sense.
Comment 17 Jasper St. Pierre (not reading bugmail) 2013-02-05 21:24:46 UTC
I'd still want a UI review for this.
Comment 18 Florian Müllner 2013-02-10 20:22:22 UTC
*** Bug 693546 has been marked as a duplicate of this bug. ***
Comment 19 Florian Müllner 2013-02-10 20:23:11 UTC
Created attachment 235645 [details] [review]
ScreenShield: try harder to become modal, and catch failures

Rebased to master
Comment 20 Florian Müllner 2013-02-10 20:26:48 UTC
Created attachment 235646 [details]
Error after explicit lock from user menu
Comment 21 Florian Müllner 2013-02-10 20:27:33 UTC
Created attachment 235647 [details]
Error after implicit lock on idle
Comment 22 Atri 2013-02-11 14:58:55 UTC
After applying the patch here
http://bugzilla-attachments.gnome.org/attachment.cgi?id=229937
it seems to block the screen locking and suspending by the user completely. Now after clicking on "Lock" from the user-menu, nothing happens. Any suggestions?

Thanks.

System: openSUSE 12.3 RC1, gnome-shell-3.6.2.
Comment 23 Florian Müllner 2013-02-11 15:04:22 UTC
The patch uses API that has been only introduced during the 3.7.x cycle, so applying it unmodified to the 3.6.2 version is not supposed to work. There are probably some errors in ~/.cache/gdm/session.log which hint at what exactly is not working.
(For what it's worth, I do have a backported version of the patch locally that I plan to apply (and include in a 3.6.3 release) once we get designer approval)
Comment 24 Atri 2013-02-11 16:12:33 UTC
I took the patch attached with comment 2 (and mentioned as gnome 3.6), but I understand. Would be very thankful if you attached the backported patch for 3.6.x here (or emailed me), as this would fix a rather important issue for users of openSUSE 12.3 (which comes with GNOME 3.6).

Thanks a lot for the quick response!
Comment 25 Florian Müllner 2013-02-11 16:25:53 UTC
(In reply to comment #24)
> Would be very thankful if you attached the backported patch for
> 3.6.x here (or emailed me), as this would fix a rather important issue for
> users of openSUSE 12.3 (which comes with GNOME 3.6).

Sorry, but I prefer to land the patch upstream first (the code is fine, and the designers are reviewing the strings as we speak, so I expect this to land later today), at which point they'll appear on the stable gnome-3-6 branch as well.
Comment 26 Allan Day 2013-02-11 16:32:18 UTC
The strings from those two screenshots:

"Failed to activate screen lock

The screen lock is inhibited by an application capturing the keyboard."

"Failed to activate screen lock

The activation of the screen lock was blocked by an application that captured the keyboard."

They both seem to say the same thing, so I don't think we need two different notifications. I'd probably go with:

"Unable to lock

Lock was blocked by an application"
Comment 27 Giovanni Campagna 2013-02-13 16:48:04 UTC
Created attachment 235909 [details] [review]
ScreenShield: try harder to become modal, and catch failures

The screenshield was not checking the return value of pushModal(), meaning
that it believed it was fully locked when it was not. Later, calling
popModal() would fail, causing an exception and blocking the unlock.
Now when we fail we include an explanatory message, pointing the user
to the actual cause of the issue.
Comment 28 Giovanni Campagna 2013-02-13 16:57:24 UTC
Pushed with Allan's proposed text.
Attachment 235909 [details] pushed as 4dc9540 - ScreenShield: try harder to become modal, and catch failures
Comment 29 Florian Müllner 2013-02-14 20:00:13 UTC
*** Bug 691094 has been marked as a duplicate of this bug. ***
Comment 30 Giovanni Campagna 2013-02-17 15:32:49 UTC
*** Bug 692991 has been marked as a duplicate of this bug. ***
Comment 31 hokasch 2013-02-18 12:12:16 UTC
Thanks, I can confirm this fixes duplicate Bug 691094. With gnome-shell 3.6.3, locking now fails gracefully when a virtualbox guest has focus.
Comment 32 Bastien Nocera 2014-08-20 19:33:48 UTC
*** Bug 353437 has been marked as a duplicate of this bug. ***