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 706922 - Set the opaque region when using CSD
Set the opaque region when using CSD
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-08-27 19:44 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2013-08-28 14:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtkwindow: Consistently set the style classes for window-frame (2.24 KB, patch)
2013-08-27 19:44 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
gdk: Add opaque region setters (5.87 KB, patch)
2013-08-27 19:44 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
gtkwindow: Calculate the opaque window based off of the style (4.02 KB, patch)
2013-08-27 19:44 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review

Description Jasper St. Pierre (not reading bugmail) 2013-08-27 19:44:37 UTC
A quite important optimization...
Comment 1 Jasper St. Pierre (not reading bugmail) 2013-08-27 19:44:39 UTC
Created attachment 253300 [details] [review]
gtkwindow: Consistently set the style classes for window-frame

In one place, we forgot to remove the BACKGROUND style class before
adding window-frame. Add a helper method so these are all the same.
Comment 2 Jasper St. Pierre (not reading bugmail) 2013-08-27 19:44:41 UTC
Created attachment 253301 [details] [review]
gdk: Add opaque region setters
Comment 3 Jasper St. Pierre (not reading bugmail) 2013-08-27 19:44:45 UTC
Created attachment 253302 [details] [review]
gtkwindow: Calculate the opaque window based off of the style
Comment 4 Benjamin Otte (Company) 2013-08-27 20:58:56 UTC
Comment on attachment 253301 [details] [review]
gdk: Add opaque region setters

This needs API docs. Those docs should mention that this is a "fire-and-forget" function, ie that GDK doesn't keep track of the opaque region and you need to manage it yourself. And they should mention that it's just an optimization that is useful but not necessary. Not sure if we should mention that it only works on toplevels?
Comment 5 Benjamin Otte (Company) 2013-08-27 21:07:13 UTC
Comment on attachment 253302 [details] [review]
gtkwindow: Calculate the opaque window based off of the style

- Needs update in style_updated()
- Needs to unset opaque region when CSD is turned off
- Did you check that we do the right thing in a hide/unrealize/show cycle of the GtkWindow? Ie do we call set_allocation there? Because we do create a new GdkWindow...
Comment 6 Benjamin Otte (Company) 2013-08-27 21:07:50 UTC
In fact, do window properties survive an unmap/remap of an XWindow?
Comment 7 Matthias Clasen 2013-08-28 03:17:17 UTC
Review of attachment 253301 [details] [review]:

Should this warn or fail for non-toplevel windows ?
Comment 8 Benjamin Otte (Company) 2013-08-28 06:37:10 UTC
I think it should be a no-op for non-toplevels just like it is for toplevels that don't implement this operation (Broadway, Windows, ...). We generally treat functions called on non-toplevels that don't make sense on them as no-ops.

What does the code do for non-toplevels actually? I actually have no idea what GET_IMPL_CLASS() does in that case.
Comment 9 Jasper St. Pierre (not reading bugmail) 2013-08-28 12:50:14 UTC
(In reply to comment #5)
> - Needs update in style_updated()

I don't understand why -- if the style updates, we'll do a move resize to adjust borders anyway, which should cause the set_allocation() path to get triggered again.

> - Needs to unset opaque region when CSD is turned off

Oops, right now, update_opaque_region only happens inside client_decorated because I'm an idiot and that was testing code. We should indeed always set it to the best of our knowledge.

If the user replaces CSD with a headerbar, we should still set the opaque region. And if there's no CSD at all, but an argb32 visual, with a background, we should still set the opaque region to the best of our knowledge.

The only case where the user needs to set the opaque region him/herself is when the background of the window is transparent, where we can't autodetect this.

> - Did you check that we do the right thing in a hide/unrealize/show cycle of
> the GtkWindow? Ie do we call set_allocation there? Because we do create a new
> GdkWindow...

Hm. I'll double-check, but do you know of any tests that do this so I don't have to write one myself?

(In reply to comment #6)
> In fact, do window properties survive an unmap/remap of an XWindow?

Yes.
Comment 10 Benjamin Otte (Company) 2013-08-28 13:58:18 UTC
(In reply to comment #9)
> (In reply to comment #5)
> > - Needs update in style_updated()
> 
> I don't understand why -- if the style updates, we'll do a move resize to
> adjust borders anyway, which should cause the set_allocation() path to get
> triggered again.
> 
Because we only queue a resize when properties affecting the size change: https://git.gnome.org/browse/gtk+/tree/gtk/gtkwidget.c?h=3.9.10#n7579

If you're interested, those are set via the GTK_STYLE_PROPERTY_NO_RESIZE flag in https://git.gnome.org/browse/gtk+/tree/gtk/gtkcssstylepropertyimpl.c?h=3.9.10#n69 and a similar optimization exists for fonts as you can see.

And neither the border-radius nor the background-color properties require a resize when they change.

Does that explain it?
Comment 11 Jasper St. Pierre (not reading bugmail) 2013-08-28 14:34:54 UTC
Attachment 253300 [details] pushed as 64cf8b7 - gtkwindow: Consistently set the style classes for window-frame
Attachment 253301 [details] pushed as 08fbba4 - gdk: Add opaque region setters
Attachment 253302 [details] pushed as 3c2c3ab - gtkwindow: Calculate the opaque window based off of the style


added doc comment; discussed on IRC why the style_updated handler was not necessary -- GtkWindow's style_updated handler already queues a resize as a brute-force approach to CSD. For the next cycle, we'll look into making that more tame, and then we'll need to calculate stuff better.