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 774534 - [wayland] input shape and opaque region not applied without begin_paint()/end_paint()
[wayland] input shape and opaque region not applied without begin_paint()/end...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Wayland
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 774546
 
 
Reported: 2016-11-16 14:05 UTC by Olivier Fourdan
Modified: 2016-12-15 12:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for gtk-3-22 (1.37 KB, patch)
2016-11-16 14:08 UTC, Olivier Fourdan
none Details | Review
[PATCH gtk-3-22] wayland: apply input shape and opaque region (1.30 KB, patch)
2016-11-30 13:39 UTC, Olivier Fourdan
none Details | Review
[PATCH] wayland: apply empty input shape on parent commit (2.39 KB, patch)
2016-12-06 13:41 UTC, Olivier Fourdan
committed Details | Review

Description Olivier Fourdan 2016-11-16 14:05:15 UTC
Description:

When using the Wayland GDK backend, setting an opaque region (with gdk_window_set_opaque_region()) or an input shape (with gdk_window_input_shape_combine_region()) has no effect without begin_paint()/end_paint().

Reason for this is the actual input_region and opaque_region are set/sync'ed only from gdk_window_impl_wayland_end_paint().

If the caller is not using begin_paint()/end_paint(), the input_shape and opaque_region are not applied.

This is a difference with the other backends such as x11 where the input_shape and opaque_region are applied as soon as set with gdk_window_set_opaque_region() and gdk_window_input_shape_combine_region()
Comment 1 Olivier Fourdan 2016-11-16 14:08:15 UTC
Created attachment 340013 [details] [review]
Patch for gtk-3-22
Comment 2 Olivier Fourdan 2016-11-16 14:09:01 UTC
Patch also applies to current master.
Comment 3 Matthias Clasen 2016-11-17 11:01:34 UTC
I know there was irc discussion of this issue. What was the outcome ?
Comment 4 Olivier Fourdan 2016-11-17 14:02:36 UTC
(In reply to Matthias Clasen from comment #3)
> I know there was irc discussion of this issue. What was the outcome ?

Emmanuele pointed out we want people to use begin_paint()/end_paint(), but Clutter doesn't and this is precisely for clutter and its subsurface on Wayland.
Comment 5 Olivier Fourdan 2016-11-17 14:05:14 UTC
(All this is for bug 771320, which so far is still wip)
Comment 6 Emmanuele Bassi (:ebassi) 2016-11-17 14:41:39 UTC
(In reply to Olivier Fourdan from comment #4)
> (In reply to Matthias Clasen from comment #3)
> > I know there was irc discussion of this issue. What was the outcome ?
> 
> Emmanuele pointed out we want people to use begin_paint()/end_paint(), but
> Clutter doesn't and this is precisely for clutter and its subsurface on
> Wayland.

Indeed, Clutter is "special" in that it assumes complete control over the windowing system surface.

The main issue is that begin_draw_frame()/end_draw_frame() redirect rendering to a Pixmap on X11, which is not a valid target for a GLX context, since we cannot call glXSwapBuffers() on that intermediate buffer; for Wayland it's less of a problem because the target is still going to be an EGL surface, and it's assumed that all rendering is client-side. It may be interesting to just add the begin_draw_frame()/end_draw_frame() calls when using the GDK backend on Wayland, and see if that breaks everything or not.

The only other option would be to port Cogl and Clutter to use GdkGLContext, and do their rendering on a separate FBO, but it would be a massive rework of their internals, and it's something I'm not going to commit myself doing — especially since applications are porting away from the whole Clutter API.

The path of least resistance is to update the input and opaque regions immediately after changing them, but I'm not familiar enough with Wayland to determine whether or not it's a good approach.
Comment 7 Olivier Fourdan 2016-11-30 09:12:13 UTC
I suspect there might still be a race somehow because the input shape is not /always/ applied in totem (with the patch from bug 774546 to use gdk subsurfaces in Wayland).

Yet applying the input shape on configure notifications in clutter works, so /something/ is either clearing the input shape or it's not applied when done just after the subsurface creation.
Comment 8 Olivier Fourdan 2016-11-30 09:36:53 UTC
Although it might be mutter because the same works fine in weston, apparently...
Comment 9 Olivier Fourdan 2016-11-30 13:39:47 UTC
Created attachment 341050 [details] [review]
[PATCH gtk-3-22] wayland: apply input shape and opaque region

For subsurfaces, the new state which includes the input shape and opaque
region is not applied by the compositor if the subsurface is in
effective synchronous mode.

So we need to apply the input shape and opaque region once the
subsurface is desynchronized and its parent surface is in effective
desynchronized mode, which is when the parent surface is committed,
otherwise these may never be applied if the widget is not using
being_paint()/end_paint() (like clutter).
Comment 10 Olivier Fourdan 2016-12-06 13:39:45 UTC
  <jadahl> ofourdan: i see, could we make that explicit maybe? instead of 
           sync... we do "wl_surface_set_input_region(empty)" with a comment
           saying why its empty and its fine?
<ofourdan> jadahl: sorry I didn't quite get what you mean about making it
           explicit
  <jadahl> ofourdan: instead of using the sync function, just do it directly
           with the special case (i.e. empty region) so that its obvious that
           it won't break on resize
<ofourdan> I still don't get what you mean, do you mean in gdk or in clutter?
           in clutter, we cannot as there is no api to retrieve the actual
           wayland subsurface from gdk
<ofourdan> oh, you mean, same as now but only for the special case?
  <jadahl> ofourdan: i meant in gdk, yes. make the special case more obvious by
           making it explicit
  <jadahl> ofourdan: since the fact that it'll get set to no-input is hidden 
           from the call site
  <jadahl> ofourdan: as a matter of fact, we could set the input region very 
           early, so the first ever commit catches it (if there is any before
           set_desync)
Comment 11 Olivier Fourdan 2016-12-06 13:41:09 UTC
Created attachment 341478 [details] [review]
[PATCH] wayland: apply empty input shape on parent commit

For subsurfaces, the new state which includes the input shape is not
applied by the compositor if the subsurface is in effective synchronous
mode.

So we need to apply the input shape once parent surface is in effective
desynchronized mode, which is when it's committed, otherwise the input
shape may never be applied if the widget is not using being_paint() /
end_paint() to draw on its subsurface, like clutter does.

We do that only for empty input shape as those won't need update when
the subsurface is resized, for all other non-empty input shape, the
client still has to use begin_paint()/end_paint() for the input shape to
be applied.
Comment 12 Jonas Ådahl 2016-12-14 07:40:05 UTC
Review of attachment 341478 [details] [review]:

Looks good. Should we think out a long term plan? I.e. if clutter wants to use GDK for some things, but still drive the drawing itself, should we add explicit API for that so we still can do the things we do in begin/end_frame()?
Comment 13 Olivier Fourdan 2016-12-15 12:48:03 UTC
Comment on attachment 341478 [details] [review]
[PATCH] wayland: apply empty input shape on parent commit

attachment 341478 [details] [review] pushed to git master as commit 5c3192c - wayland: apply empty input shape on parent commit

attachment 341478 [details] [review] pushed to branch gtk-3-22 as commit 78f8f23 - wayland: apply empty input shape on parent commit