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 736694 - Fixes for xwayland/wayland association
Fixes for xwayland/wayland association
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2014-09-15 19:37 UTC by Owen Taylor
Modified: 2014-09-16 17:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Do xwayland/wayland window association in a later, not an idle (3.50 KB, patch)
2014-09-15 19:37 UTC, Owen Taylor
committed Details | Review
Cleanup xwayland/wayland window association from the "unmanage" signal (2.94 KB, patch)
2014-09-15 19:37 UTC, Owen Taylor
committed Details | Review

Description Owen Taylor 2014-09-15 19:37:05 UTC
This is to fix a warning because the idle runs after the window has
been unmanaged; the first patch doesn't reliably fix the problem, but
is still the right thing to do.
Comment 1 Owen Taylor 2014-09-15 19:37:07 UTC
Created attachment 286228 [details] [review]
Do xwayland/wayland window association in a later, not an idle

g_idle_add() makes no guarantee about when it will be run - if Mutter
is busy drawing and blocking glXSwapBuffers() it could happen only
minutes later.  Use meta_later_add (META_LATER_BEFORE_REDRAW) instead -
this will deterministically be run after the Wayland socket is read
from but before the next frame is painted.
Comment 2 Owen Taylor 2014-09-15 19:37:11 UTC
Created attachment 286229 [details] [review]
Cleanup xwayland/wayland window association from the "unmanage" signal

Windows can be freed at some point after they are unmanaged - because
there is an effect in progress, because a language binding is holding
a reference. Therefore, we need to clean up the later to associate
the xwayland and wayland windows deterministically in an "unamanaged"
handler.
Comment 3 Jasper St. Pierre (not reading bugmail) 2014-09-15 19:50:55 UTC
Review of attachment 286228 [details] [review]:

Looks good.

::: src/tests/stacking/basic-x11.metatest
@@ +1,1 @@
+new_client a1 x11

Unrelated change?
Comment 4 Jasper St. Pierre (not reading bugmail) 2014-09-15 19:58:55 UTC
Review of attachment 286229 [details] [review]:

"unamanaged" in the commit message

::: src/wayland/meta-xwayland.c
@@ +86,2 @@
 {
+  if (op->later_id)

if (op->later_id > 0)

is the usual style

@@ +88,3 @@
+    meta_later_remove (op->later_id);
+  g_signal_handlers_disconnect_by_func (op->window,
+                                        (gpointer) associate_window_with_surface_window_unmanaged,

Why the cast to gpointer?
Comment 5 Owen Taylor 2014-09-16 14:40:22 UTC
(In reply to comment #4)
> Review of attachment 286229 [details] [review]:
> 
> "unamanaged" in the commit message
> 
> ::: src/wayland/meta-xwayland.c
> @@ +86,2 @@
>  {
> +  if (op->later_id)
> 
> if (op->later_id > 0)
> 
> is the usual style

screen.c:
  if (screen->check_fullscreen_later != 0)
  if (!screen->check_fullscreen_later)

stack-tracker.c:
  if (tracker->sync_stack_later)
  if (tracker->sync_stack_later == 0)

window.c:
          if (queue_pending[queuenum] == NULL && queue_later[queuenum] != 0)
          if (queue_later[queuenum] == 0)

prefs.c:
  if (changed_idle == 0)

utils.c:
  if (later->source)
          if (later->source == 0)

So rather a lack of consistency!, even for the same idle ID, but I don't see that particular pattern ;-) ... I'll change it to != 0, since I like that better than > 0.

> @@ +88,3 @@
> +    meta_later_remove (op->later_id);
> +  g_signal_handlers_disconnect_by_func (op->window,
> +                                        (gpointer)
> associate_window_with_surface_window_unmanaged,
> 
> Why the cast to gpointer?

g_signal_handlers_disconnect_by_func() was accidentally messed up to take a void * rather than a GCallback, so it's impossible to call it in a C standard compliant way. [the same applies to dlsym, so it will actually work fine on any POSIX platform] 

The (gpointer) cast does *not* make it any more C standard compliant. At this point, not sure why I started doing it:

 A) It made some compiler not warn about the construct. Hard to prove positive or negative at this point - current GCC doesn't seem to warn either way unless you add -pendantic and then it warns both ways. A compiler is certainly allowed to emit different diagnostics with and without the cast.
 B) It simply points out what is going on - the natural and nonsensical thing to do is to write G_CALLBACK (associate_window_with_surface_window_unmanage) and if you see people doing the above, you are made to investigate and not accidentally do that.
Comment 6 Jasper St. Pierre (not reading bugmail) 2014-09-16 14:44:40 UTC
I thought functions (well, any single pointer type like char *) always had an implicit cast to void *.
Comment 7 Owen Taylor 2014-09-16 14:49:35 UTC
(In reply to comment #6)
> I thought functions (well, any single pointer type like char *) always had an
> implicit cast to void *.

Since casting a function to a void * is not defined in standard C at all, there's also no implicit cast from function to void *. GCC allows it and allows the implicit cast.
Comment 8 Owen Taylor 2014-09-16 17:45:14 UTC
Attachment 286228 [details] pushed as 9c465a2 - Do xwayland/wayland window association in a later, not an idle
Attachment 286229 [details] pushed as d6624b0 - Cleanup xwayland/wayland window association from the "unmanage" signal