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 683357 - ScreenShield: wait for stage mapping before taking a grab
ScreenShield: wait for stage mapping before taking a grab
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2012-09-04 19:00 UTC by Giovanni Campagna
Modified: 2012-09-13 22:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ScreenShield: wait for stage mapping before taking a grab (1.37 KB, patch)
2012-09-04 19:00 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2012-09-04 19:00:46 UTC
The patch is on top of everything (dynamic session mode,
multi-state screenshield, fixes and changes and bah), so
please review the others first.
Comment 1 Giovanni Campagna 2012-09-04 19:00:49 UTC
Created attachment 223458 [details] [review]
ScreenShield: wait for stage mapping before taking a grab

In gdm, we would attempt to become modal during the synchronous initialization,
and this would fail, as X prevents grabs on unmapped windows. Instead,
wait for the stage to be visible before becoming modal.
Comment 2 Jasper St. Pierre (not reading bugmail) 2012-09-04 19:13:56 UTC
Review of attachment 223458 [details] [review]:

I thought the stage was mapped synchronously as the first thing in meta_run, before we ran any JS code.
Comment 3 Giovanni Campagna 2012-09-04 19:53:58 UTC
I don't know, I didn't check through.
What I do know is that the sync pushModal always fails, whereas with this patch it works.
I thought it could be a timestamp problem, but even using get_current_time_roundtrip() doesn't fix it, so if I read the Xlib docs right, the next candidate is GrabNotViewable, ie. the stage is not mapped.

(Btw, I think it would flicker if we mapped the stage before the first paint)
Comment 4 drago01 2012-09-05 09:37:21 UTC
(In reply to comment #2)
> Review of attachment 223458 [details] [review]:
> 
> I thought the stage was mapped synchronously as the first thing in meta_run,
> before we ran any JS code.

No it isn't.

From compositor.c:

  /*
   * Delay the creation of the overlay window as long as we can, to avoid
   * blanking out the screen. This means that during the plugin loading, the
   * overlay window is not accessible; if the plugin needs to access it
   * directly, it should hook into the "show" signal on stage, and do
   * its stuff there.
   */

We do connect to the show signal in xdndHandler.js for the exact same reason. We should do the same here instead of using Meta.LaterType.BEFORE_REDRAW for consistency with both the comment in compositor.c and what we do in other places (Xdndhandler).
Comment 5 drago01 2012-09-05 09:38:15 UTC
Review of attachment 223458 [details] [review]:

::: js/ui/screenShield.js
@@ +620,3 @@
+        // Ensure that the stage window is mapped, before taking a grab
+        // otherwise X errors out
+        Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {

Connect to the stage's show signal instead.
Comment 6 Giovanni Campagna 2012-09-05 14:06:03 UTC
(In reply to comment #5)
> Review of attachment 223458 [details] [review]:
> 
> ::: js/ui/screenShield.js
> @@ +620,3 @@
> +        // Ensure that the stage window is mapped, before taking a grab
> +        // otherwise X errors out
> +        Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
> function() {
> 
> Connect to the stage's show signal instead.

No way. If I use the show signal, I get a completely transparent screen (i.e. the lock dialog group is not shown)
I worked around it by commenting the pushModal part (and stuff still works because LoginDialog does another pushModal), but I feel this is wrong.
Comment 7 Giovanni Campagna 2012-09-13 22:56:24 UTC
Accepted after IRC discussion.
Attachment 223458 [details] pushed as be290fa - ScreenShield: wait for stage mapping before taking a grab