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 756618 - GtkWindow CSD: gtk_window_resize() also includes client side decorations size
GtkWindow CSD: gtk_window_resize() also includes client side decorations size
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.18.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 757690 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-10-15 09:24 UTC by Olivier Fourdan
Modified: 2016-02-15 07:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (mostly an RFC) (2.95 KB, patch)
2015-10-15 09:34 UTC, Olivier Fourdan
none Details | Review
Proposed patch (Updated) (3.85 KB, patch)
2015-10-15 09:46 UTC, Olivier Fourdan
none Details | Review
Proposed patch (Updated) (4.12 KB, patch)
2015-10-16 09:24 UTC, Olivier Fourdan
none Details | Review
Updated patch (4.07 KB, patch)
2015-10-19 14:12 UTC, Olivier Fourdan
none Details | Review
Proposed patch (Updated) (4.17 KB, patch)
2015-10-20 11:21 UTC, Olivier Fourdan
committed Details | Review
Another patch for gtk_window_move()/gtk_window_get_pos() (4.38 KB, patch)
2015-10-22 13:05 UTC, Olivier Fourdan
committed Details | Review
screenshot: nautilus desktop window (329.48 KB, image/jpeg)
2015-10-30 12:51 UTC, Alberts Muktupāvels
  Details
Proposed patch (2.51 KB, patch)
2015-10-30 14:36 UTC, Olivier Fourdan
none Details | Review
Proposed patch (Updated) (1.73 KB, patch)
2015-10-30 16:46 UTC, Olivier Fourdan
none Details | Review
Proposed patch (Updated) (1.79 KB, patch)
2015-11-02 09:37 UTC, Olivier Fourdan
committed Details | Review
gtkwindow: css offset for toplevel only (2.17 KB, patch)
2015-11-10 11:14 UTC, Olivier Fourdan
committed Details | Review
gtkwindow: apply csd offset to set/get_default_size (4.26 KB, patch)
2015-11-12 16:06 UTC, Olivier Fourdan
committed Details | Review
gtkwindow: apply CSD adjustments to the default size when used instead of when setting it (3.02 KB, patch)
2015-11-18 18:25 UTC, Christoph Reiter (lazka)
committed Details | Review
gtkheaderbar: update the window buttons on ::hierarchy-changed instead of ::realize (2.93 KB, patch)
2015-11-18 20:31 UTC, Christoph Reiter (lazka)
committed Details | Review
gtkwindow: apply CSD in configure size request (2.22 KB, patch)
2015-11-26 10:13 UTC, Olivier Fourdan
none Details | Review
gtkwindow: remove headerbar after disposing parent (1.06 KB, patch)
2015-11-26 10:14 UTC, Olivier Fourdan
committed Details | Review
gtkwindow: apply CSD in configure size request (2.04 KB, patch)
2015-11-26 12:19 UTC, Olivier Fourdan
committed Details | Review
gtkwindow: Document further resize with csd (1.48 KB, patch)
2015-12-02 10:34 UTC, Olivier Fourdan
committed Details | Review
gtkheaderbar: update windows buttons also on realize (921 bytes, patch)
2015-12-28 03:01 UTC, Alberts Muktupāvels
none Details | Review
gtkheaderbar: update window buttons also on realize (1.06 KB, patch)
2015-12-28 19:10 UTC, Alberts Muktupāvels
committed Details | Review

Description Olivier Fourdan 2015-10-15 09:24:38 UTC
Reproducer included in downstream bug https://bugzilla.redhat.com/show_bug.cgi?id=1269437

When CSD is enabled (export GTK_CSD=1) gtk_window_get_size()/gtk_window_resize() for toplevel windows also counts the shadow size.

So resized windows are smaller than expected and also actual window size is wrong.
Comment 1 Olivier Fourdan 2015-10-15 09:34:22 UTC
Created attachment 313356 [details] [review]
Proposed patch (mostly an RFC)

This patch is mostly for comments, it seems to work with the reproducer from the downstream bug, but there is no garantee that it will be 100% accurate (I am not actually sure we can be 100% accurate here, but that's still an improvement over the current status imho).
Comment 2 Olivier Fourdan 2015-10-15 09:46:39 UTC
Created attachment 313358 [details] [review]
Proposed patch (Updated)

Updated patch to document the change to the give nsize and potential lack of accuracy.
Comment 3 Matthias Clasen 2015-10-15 20:15:59 UTC
Review of attachment 313358 [details] [review]:

::: gtk/gtkwindow.c
@@ +5214,3 @@
+ * size, but there is no garantee that the result will be totally
+ * accurate because the title bar and shadows are themes dependent and
+ * may not be known at the time the resize is issued.

And by 'actual window size' here we mean the 'non-titlebar, non-border, non-shadow portions of the window' ? Maybe that needs clarification.
Comment 4 Olivier Fourdan 2015-10-16 09:24:52 UTC
Created attachment 313441 [details] [review]
Proposed patch (Updated)


Reworded the descriptions as per the review.

As a side note, I also tried to make the patch smarter by recalculating the sizes when the title bar is added, but that adds more complexity and doesn't work reliably so I think it's better to keep it simple as it is.
Comment 5 Matthias Clasen 2015-10-17 02:40:58 UTC
Review of attachment 313441 [details] [review]:

I think this is probably the best we can do, so I'm ok with it after moving the doc comment.
Does this solve a firefox problem ?

::: gtk/gtkwindow.c
@@ +5220,2 @@
  * Windows may not be resized smaller than 1 by 1 pixels.
  * 

I'd prefer if the doc comment stayed right above the function it documents. Move the aux. stuff above it.
Comment 6 Olivier Fourdan 2015-10-19 14:12:05 UTC
Created attachment 313665 [details] [review]
Updated patch

(In reply to Matthias Clasen from comment #5)
> [...]
> I think this is probably the best we can do, so I'm ok with it after moving
> the doc comment.

Patch updated.

> Does this solve a firefox problem ?

According to https://bugzilla.redhat.com/show_bug.cgi?id=1269437#c20 it appears to help, yet I have not been able to confirm that myself in my own tests.

> I'd prefer if the doc comment stayed right above the function it documents.
> Move the aux. stuff above it.

Yeap, done in this updated version.
Comment 7 Matthias Clasen 2015-10-20 10:45:41 UTC
Review of attachment 313665 [details] [review]:

::: gtk/gtkwindow.c
@@ +5255,3 @@
+    *height = 1;
+}
+

Still looks to me like the aux function sits between gtk_window_resize and its docs...
Comment 8 Olivier Fourdan 2015-10-20 11:21:34 UTC
Created attachment 313733 [details] [review]
Proposed patch (Updated)

(In reply to Matthias Clasen from comment #7)
> Still looks to me like the aux function sits between gtk_window_resize and
> its docs...

Oh, I see, sorry I misunderstood! Fixed now, hopefully :-)
Comment 9 Matthias Clasen 2015-10-20 11:59:54 UTC
Tangential question: Have you looked at doing the same kind of fixup for gtk_window_move ? It'll be more complicated if you try to handle window gravity...
Comment 10 Matthias Clasen 2015-10-20 12:00:11 UTC
Review of attachment 313733 [details] [review]:

looks good now
Comment 11 Olivier Fourdan 2015-10-20 12:30:37 UTC
(In reply to Matthias Clasen from comment #9)
> Tangential question: Have you looked at doing the same kind of fixup for
> gtk_window_move ? It'll be more complicated if you try to handle window
> gravity...

Good point, no I haven't but I will now.
Comment 12 Olivier Fourdan 2015-10-22 13:05:37 UTC
Created attachment 313859 [details] [review]
Another patch for gtk_window_move()/gtk_window_get_pos()

Tested with tests/testgtk gravity windows ("Window sizing" test, "Show gravity test windows") - Works with both move to current position and move to starting position, for all gravities.

We could merge these two patches (haven't done so because first one is already reviewed but it's the same issue after all).
Comment 13 Matthias Clasen 2015-10-25 17:23:38 UTC
Review of attachment 313859 [details] [review]:

No need to merge them. Looks good to me.
Comment 14 Olivier Fourdan 2015-10-26 09:22:26 UTC
attachment 313733 [details] [review] pushed as 3450f53 GtkWindow: add up CSD size in gtk_window_resize()

attachment 313859 [details] [review] pushed as 305b34a GtkWindow: fix move/get position with CSD
Comment 15 Alberts Muktupāvels 2015-10-30 12:32:07 UTC
This causes regression...

gnome-terminal: Sub menus in File, Edit are not correctly positioned any more.
gnome-panel: Same problem as above - all sub menus are positioned incorrectly.
nautilus: desktop window is positioned incorrectly.

Looks like all above has negative left and top offsets.

I think this might be problem why "tooltip: use an element name" and related theme changes was reverted.
Comment 16 Olivier Fourdan 2015-10-30 12:37:56 UTC
(In reply to Alberts Muktupāvels from comment #15)
> This causes regression...
> 
> gnome-terminal: Sub menus in File, Edit are not correctly positioned any
> more.
> gnome-panel: Same problem as above - all sub menus are positioned
> incorrectly.
> nautilus: desktop window is positioned incorrectly.
> 
> Looks like all above has negative left and top offsets.
> 
> I think this might be problem why "tooltip: use an element name" and related
> theme changes was reverted.

Can you please elaborate on how to reproduce? I don't see any offset error in submenus - Is that under Wayland or X11, or other?
Comment 17 Alberts Muktupāvels 2015-10-30 12:44:31 UTC
I am using nvidia proprietary driver, so X11.

I have full GNOME session build with jhbuild. GTK+ is current master, but other packages might not be fully up to date - max one week old.

Just login in GNOME Shell session, open terminal, and click on 'File'. Should I attach screenshot?
Comment 18 Olivier Fourdan 2015-10-30 12:46:55 UTC
Ideally, a simple reproducer in C would be the best.
Comment 19 Olivier Fourdan 2015-10-30 12:49:31 UTC
OK, I see what you mean with gnome-terminal...
Comment 20 Alberts Muktupāvels 2015-10-30 12:51:44 UTC
Created attachment 314468 [details]
screenshot: nautilus desktop window
Comment 21 Olivier Fourdan 2015-10-30 12:56:11 UTC
So from what I can see, it looks like these apps would presumably have a shadow but actually don't so the computation of the actual location takes the shadows into account while it should not, resulting in a negative offset...
Comment 22 Olivier Fourdan 2015-10-30 14:36:40 UTC
Created attachment 314490 [details] [review]
Proposed patch

Can you check with this patch applied to gtk+?
Comment 23 Olivier Fourdan 2015-10-30 14:39:58 UTC
Note that, while it should fix the issue, it also introduces a slight regression wrt the previous patches because trying to place a CSD window before it's mapped on screen will ignore the shadow, so it won't be placed at the expected location...
Comment 24 Alberts Muktupāvels 2015-10-30 15:03:27 UTC
Offset problem is fixed with your proposed patch.

Well if there is other regressions than I would say that patches must be reverted until better fix is found, no?
Comment 25 Olivier Fourdan 2015-10-30 15:09:42 UTC
(In reply to Alberts Muktupāvels from comment #24)
> Offset problem is fixed with your proposed patch.
> 
> Well if there is other regressions than I would say that patches must be
> reverted until better fix is found, no?

No, the regression I mentioned is with this new patch against the previous commit 305b34a to address the original issue, reverting these patches won't help that.
Comment 26 Olivier Fourdan 2015-10-30 16:46:31 UTC
Created attachment 314509 [details] [review]
Proposed patch (Updated)

OK, let's start over. The issue was actually in gtk+ before any of these patches were pushed, but it was kept unnoticed till now.

The source of the problem is that get_shadow_width() does not return accurate values when there is no shadows apparently. Reason for this is a couple of logic mistakes in get_shadow_width() and gtk_window_should_use_csd().

Can you wipe out the previous patch and retry with this one instead?
Comment 27 Alberts Muktupāvels 2015-10-30 17:16:20 UTC
This patch works too.

I reverted also these commits:
c4eb14eb01d5d17541fb320a9c464132e5fb6904
854c7d1f0fd98a6eaf283603adc05f1dec4f6e39
cab40f07434c7b4036660d08c974542a9868a09e

And tooltip positioning works.
Comment 28 Alberts Muktupāvels 2015-10-30 19:37:10 UTC
Your last patch breaks CSD window shadows...
Comment 29 Olivier Fourdan 2015-10-30 19:54:22 UTC
(In reply to Alberts Muktupāvels from comment #28)
> Your last patch breaks CSD window shadows...

In what sense? it works here afaiks...
Comment 30 Olivier Fourdan 2015-10-30 19:56:31 UTC
(In reply to Olivier Fourdan from comment #29)
> In what sense? it works here afaiks...

I yes I see it...

GTK_CSD=1 ./tests/testgtk works

 whereas

gtk3-demo doesn't.
Comment 31 Olivier Fourdan 2015-11-02 09:37:12 UTC
Created attachment 314612 [details] [review]
Proposed patch (Updated)

This updated patch seems to give consistent results, I tried with both X11 and Wayland with GTK_CSD set on X11 with regular and CSD windows, it works as expected as far as I can see (but admittedly there is a surprising number of different flags in GtkWindowPrivate which make things a tad confusing...)

Anyway, could you try this new patch?
Comment 32 Alberts Muktupāvels 2015-11-02 09:55:23 UTC
There is same offset with nautilus desktop window.
Comment 33 Olivier Fourdan 2015-11-02 10:33:04 UTC
(In reply to Alberts Muktupāvels from comment #32)
> There is same offset with nautilus desktop window.

Yes, Nautilus desktop window is not a popup window, so as far as gtk+ is concerned, it would use a shadow, that's the problem.

in nautilus-desktop-window.c, nautilus_desktop_window_constructed() does:

	gtk_window_move (GTK_WINDOW (window), 0, 0);
	gtk_window_set_decorated (GTK_WINDOW (window),
				  FALSE);

See https://git.gnome.org/browse/nautilus/tree/src/nautilus-desktop-window.c#n174

If, instead, we do:

	gtk_window_set_decorated (GTK_WINDOW (window),
				  FALSE);
	gtk_window_move (GTK_WINDOW (window), 0, 0);

Then it works, because gtk+ "knows" the window is not decorated.
Comment 34 Olivier Fourdan 2015-11-02 10:53:20 UTC
We cannot fix that in gtk+ using the type hint (desktop) because Nautilus set the type hint after the move as well...

This need to be fixed in Nautilus, I'll send a patch accordingly.
Comment 35 Olivier Fourdan 2015-11-02 12:44:55 UTC
(In reply to Olivier Fourdan from comment #34)
> This need to be fixed in Nautilus, I'll send a patch accordingly.

I filed bug 757471 for this.
Comment 36 Matthias Clasen 2015-11-02 17:14:28 UTC
Review of attachment 314612 [details] [review]:

ok
Comment 37 Olivier Fourdan 2015-11-03 08:42:48 UTC
attachment 314612 [details] [review] pushed as commit a5b1cdd GtkWindow: Fix the shadow width logic
Comment 38 Matthias Clasen 2015-11-10 00:45:00 UTC
I have to reopen this again, unfortunately.

With the current git master code, the _gtk_window_request_csd calls in gtkmenu.c and gtktooltip.c are just ignored, and this is causing tooltips to have pointy corners, when they are supposed to be nice and rounded.
Comment 39 Olivier Fourdan 2015-11-10 07:41:53 UTC
Yes, I think it's ignored because _gtk_window_request_csd() sets "csd_requested" while both menus and tooltips are popup windows that are ignored because of commit a5b1cdd

And we need commit a5b1cdd otherwise menu and tooltips are misplaced because of the negative offset induced by the shadow which is not drawn for popup windows.
Comment 40 Olivier Fourdan 2015-11-10 10:40:19 UTC
I think I start to understand what is going on, even gtk_window_draw() uses the non-zero borders. But gtk_menu_draw() will draw differently.

So I think it's impossible for gtkwindow to get this right, it should therefore take client side decorations into account for positioning/resizing only for regular toplevel windows. It's actually a lot simpler and safer.

What about apps that draw their background themselves using gtk_widget_set_app_paintable(), should we ignore those as well?
Comment 41 Olivier Fourdan 2015-11-10 10:52:00 UTC
(In reply to Olivier Fourdan from comment #40)
> [...]
> What about apps that draw their background themselves using
> gtk_widget_set_app_paintable(), should we ignore those as well?

Using "GTK_CSD=1 ./tests/animated-resizing" gives interesting results, but kinda show that an app that uses gtk_widget_set_app_paintable() could be drawing pretty much anywhere in its window so it's hard to conclude.
Comment 42 Olivier Fourdan 2015-11-10 11:14:13 UTC
Created attachment 315184 [details] [review]
gtkwindow: css offset for toplevel only

    At the time gtk_window_move() or gtk_window_resize() get called, there
    is no way to predict if a popup window will actually draw its shadow, so
    applying an offset in this case may end up with a wrong size or
    positioning for such windows.
    
    Changing the logic in gtk_window_should_use_csd() as previously done to
    address that issue will cause some other breakage as popup windows may
    not draw a shadow but still need CSD.
    
    So best is to actually apply client side decorations offset for regular,
    top level windows only. This is actually a lot simpler and safer and
    less likely to cause additional breakage.
Comment 43 Matthias Clasen 2015-11-10 17:50:00 UTC
Attachment 315184 [details] pushed as f2b373a - gtkwindow: css offset for toplevel only
Comment 44 Olivier Fourdan 2015-11-12 16:03:18 UTC
Sorry, I have to reopen this bug once again for gtk_window_set_default_size() and gtk_window_get_default_size() as well
Comment 45 Olivier Fourdan 2015-11-12 16:06:11 UTC
Created attachment 315350 [details] [review]
gtkwindow: apply csd offset to set/get_default_size

An application may use gtk_window_get_size() to retrieve the current window size and later reuse that size with gtk_window_set_default_size().

gtk_window_set_default_size() and gtk_window_get_default_size() should also take client side decorations offset into account.
Comment 46 Christoph Reiter (lazka) 2015-11-12 16:13:57 UTC
Related: bug 739174 (aspect ratio with CSD), bug 740922 (default_size with CSD)
Comment 47 Olivier Fourdan 2015-11-12 16:18:39 UTC
(In reply to Christoph Reiter (lazka) from comment #46)
> Related: bug 739174 (aspect ratio with CSD), bug 740922 (default_size with
> CSD)

Yeah, but aspect ratio is geometry and I haven't touch those on purpose (for now).
Comment 48 Eric Williams 2015-11-16 16:36:41 UTC
*** Bug 757690 has been marked as a duplicate of this bug. ***
Comment 49 Christian Stadelmann 2015-11-17 16:15:21 UTC
Will this issue be fixed on the 3.18.x gtk release too?
Comment 50 Matthias Clasen 2015-11-17 21:07:47 UTC
Review of attachment 315350 [details] [review]:

as I said on irc, please commit this
Comment 51 Olivier Fourdan 2015-11-18 07:43:06 UTC
Yeap, I was kinda waiting for an update from bug 758159 to see if this helps (as I could not reproduce) but if I guess it doesn't hurt to land it anyway, so:

attachment 315350 [details] [review] pushed as 370e346 gtkwindow: apply csd offset to set/get_default_size

Note: Leaving the bug opened for now, until the dust settles a bit.
Comment 52 Christoph Reiter (lazka) 2015-11-18 11:28:27 UTC
The following example gives me three different window sizes with current trunk (compared to two with 3.18): https://paste.gnome.org/pvj6brkdz
Comment 53 Olivier Fourdan 2015-11-18 12:31:13 UTC
(In reply to Christoph Reiter (lazka) from comment #52)
> The following example gives me three different window sizes with current
> trunk (compared to two with 3.18): https://paste.gnome.org/pvj6brkdz

This is to be expected, the resize functions will compensate for the gtkheaderbar only if it's known at the time the size is set.

If additional controls get added after the resize, this will cause a smaller window content and not a larger window.

Similarly, for the client-side decorations border size to be accounted for, the window need to be realized first.

And that's also true if the either the header bar or the shadows change their size after the resize occurred, those will not be compensated.

That's a lot of limitations, I know, but still an improvement as compared as before. And setting window size programatically should remain the exception rather than the rule, as window's size should be determined by its content.
Comment 54 Emmanuele Bassi (:ebassi) 2015-11-18 12:34:27 UTC
(In reply to Olivier Fourdan from comment #53)
> (In reply to Christoph Reiter (lazka) from comment #52)
> > The following example gives me three different window sizes with current
> > trunk (compared to two with 3.18): https://paste.gnome.org/pvj6brkdz
> 
> This is to be expected, the resize functions will compensate for the
> gtkheaderbar only if it's known at the time the size is set.
> 
> If additional controls get added after the resize, this will cause a smaller
> window content and not a larger window.
> 
> Similarly, for the client-side decorations border size to be accounted for,
> the window need to be realized first.
> 
> And that's also true if the either the header bar or the shadows change
> their size after the resize occurred, those will not be compensated.

Could you turn this comment into a documentation patch explaining the behaviour of the API? That would be useful.
Comment 55 Olivier Fourdan 2015-11-18 12:41:49 UTC
(In reply to Emmanuele Bassi (:ebassi) from comment #54)
> Could you turn this comment into a documentation patch explaining the
> behaviour of the API? That would be useful.

attachment 313733 [details] [review] had some explanation added but I agree it needs more.
Comment 56 Christoph Reiter (lazka) 2015-11-18 18:25:22 UTC
Created attachment 315850 [details] [review]
gtkwindow: apply CSD adjustments to the default size when used instead of when setting it

Before the resulting window size would differ if the default size was set
before adding a headerbar vs after. Now the saved state is again the actual
requested size and it is adjusted at the time we request a window size
Comment 57 Christoph Reiter (lazka) 2015-11-18 18:27:31 UTC
There is still a difference of the height for the content area because get_preferred_height() for the headerbar is returning something wrong... haven't looked at what's the problem there...
Comment 58 Olivier Fourdan 2015-11-18 18:36:54 UTC
(In reply to Christoph Reiter (lazka) from comment #57)
> There is still a difference of the height for the content area because
> get_preferred_height() for the headerbar is returning something wrong...
> haven't looked at what's the problem there...

I don't think it's returning something wrong, it's returning the preferred height at the time it's called, but later buttons and label are added which may grow the header bar larger than initially computed.

At least it's hat happens in the case of Nautilus for example.
Comment 59 Christoph Reiter (lazka) 2015-11-18 19:03:46 UTC
(In reply to Olivier Fourdan from comment #58)
> (In reply to Christoph Reiter (lazka) from comment #57)
> > There is still a difference of the height for the content area because
> > get_preferred_height() for the headerbar is returning something wrong...
> > haven't looked at what's the problem there...
> 
> I don't think it's returning something wrong, it's returning the preferred
> height at the time it's called, but later buttons and label are added which
> may grow the header bar larger than initially computed.

Right, it seems GtkHeaderBar needs to be realized for it's buttons to be really added and until that happens get_preferred_height() returns a wrong result.

A quick workaround might be to add a dummy image button on set_show_close_button() when the headerbar isn't realized..
Comment 60 Christoph Reiter (lazka) 2015-11-18 20:31:32 UTC
Created attachment 315855 [details] [review]
gtkheaderbar: update the window buttons on ::hierarchy-changed instead of ::realize

The window button setup depends on properties of the toplevel window.
Instead of updating the setup on realize, do it when the toplevel
changes.

This makes sure that when a GtkHeaderBar is added to a window
all the widgets are present and get_preferred_height() will return
the height the widget will have when finally shown. This allows
the logic in gtkwindow to select the right window size so that
the content size will match the requested default size.
Comment 61 Christoph Reiter (lazka) 2015-11-18 20:37:07 UTC
With these two patches the example from https://bugzilla.gnome.org/show_bug.cgi?id=756618#c52 works as expected in all four cases.
Comment 62 Olivier Fourdan 2015-11-19 08:26:06 UTC
I tested with both attachment 315850 [details] [review] and attachment 315855 [details] [review] applied against the known regressions previously reported and found no problem with those.

Both patches look good to me and seem like an improvement overall (for example, Nautilus window does not shrink anymore upon restart with this, I guess thanks to attachment 315855 [details] [review] which helps getting a more accurate header bar height from the start).

I'll Matthias do a proper review of these patches before landing them if possible, but they have my vote.
Comment 63 Matthias Clasen 2015-11-19 20:09:35 UTC
Review of attachment 315855 [details] [review]:

Makes sense to me.
Comment 64 Matthias Clasen 2015-11-19 20:11:21 UTC
Review of attachment 315850 [details] [review]:

ok
Comment 65 Christoph Reiter (lazka) 2015-11-19 20:52:02 UTC
Thanks, pushed to master.
Comment 66 Matthias Clasen 2015-11-23 16:59:24 UTC
Lets try again to close this
Comment 67 Olivier Fourdan 2015-11-26 10:09:58 UTC
Reopening for a gtkfilechooser issue.

With the current state of patches, the file chooser would grow each time its closed and reopened.

Reason is gtkfilechooser saves its size to dconf in the unmap callback, which is called from the dispose callback and the heder bar is removed first, so the computed size end up wrong because of this.

Will post a couple of patches to fix ths.
Comment 68 Olivier Fourdan 2015-11-26 10:13:50 UTC
Created attachment 316294 [details] [review]
gtkwindow: apply CSD in configure size request

Just like we did for the default size, that reduces the chances of having the headerbar missing when computing the client side decorations controls.
Comment 69 Olivier Fourdan 2015-11-26 10:14:56 UTC
Created attachment 316295 [details] [review]
gtkwindow: remove headerbar after disposing parent

Widgets such as gtkfilechooser may be saving their size and position on the unmap callback, if the client-side decoration header bar is removed first, the reported size will be wrong.
Comment 70 Christoph Reiter (lazka) 2015-11-26 11:49:05 UTC
Review of attachment 316294 [details] [review]:

::: gtk/gtkwindow.c
@@ +5105,2 @@
   if (!priv->decorated ||
+      !priv->client_decorated ||

Why is that needed?
Comment 71 Christoph Reiter (lazka) 2015-11-26 11:49:43 UTC
Review of attachment 316294 [details] [review]:

::: gtk/gtkwindow.c
@@ +5105,2 @@
   if (!priv->decorated ||
+      !priv->client_decorated ||

Why is that needed?
Comment 72 Olivier Fourdan 2015-11-26 12:19:28 UTC
Created attachment 316309 [details] [review]
gtkwindow: apply CSD in configure size request

(In reply to Christoph Reiter (lazka) from comment #71)
> Review of attachment 316294 [details] [review] [review]:
> 
> ::: gtk/gtkwindow.c
> @@ +5105,2 @@
>    if (!priv->decorated ||
> +      !priv->client_decorated ||
> 
> Why is that needed?

I agree it is not needed, it was meant as an optimization because this routine is called for ssd as well.

But I guess it's possible to have a header bar with ssd so it's safer to leave that change alone, updated patch attached.
Comment 73 Matthias Clasen 2015-12-01 14:34:18 UTC
Review of attachment 316295 [details] [review]:

hmm, a bit ugly, but ok.
Comment 74 Matthias Clasen 2015-12-01 14:35:43 UTC
Review of attachment 316309 [details] [review]:

This one looks dangerous to me - it brings in this size adjustment in a lot of fiddly code paths. Has it been tested thoroughly ?
Comment 75 Christoph Reiter (lazka) 2015-12-01 14:43:00 UTC
(In reply to Matthias Clasen from comment #74)
> Review of attachment 316309 [details] [review] [review]:
> 
> This one looks dangerous to me - it brings in this size adjustment in a lot
> of fiddly code paths. Has it been tested thoroughly ?

resize_width/height is only set in gtk_window_resize(_to_geometry) and read in gtk_window_compute_configure_request_size so this only adds the adjustment to the gtk_window_resize_to_geometry path compared to master.
Comment 76 Olivier Fourdan 2015-12-01 15:24:51 UTC
attachment 316295 [details] [review] pushed as commit 103d369 gtkwindow: remove headerbar after disposing parent
Comment 77 Matthias Clasen 2015-12-01 18:20:07 UTC
Review of attachment 316309 [details] [review]:

couldn't make this break anything in some testing
Comment 78 Olivier Fourdan 2015-12-02 07:57:33 UTC
Review of attachment 316309 [details] [review]:

attachment 316309 [details] [review] pushed as commit e933233 gtkwindow: apply CSD in configure size request
Comment 79 Olivier Fourdan 2015-12-02 10:34:59 UTC
Created attachment 316650 [details] [review]
gtkwindow: Document further resize with csd

(In reply to Olivier Fourdan from comment #55)
> (In reply to Emmanuele Bassi (:ebassi) from comment #54)
> > Could you turn this comment into a documentation patch explaining the
> > behaviour of the API? That would be useful.
> 
> attachment 313733 [details] [review] [review] had some explanation added but I agree
> it needs more.

This is an attempt at documenting this pitfall.

Note that with the recent commit e933233 and commit 308aec5, chances of getting the CSD sizes right are greatly increased.
Comment 80 Matthias Clasen 2015-12-03 02:37:21 UTC
Review of attachment 316650 [details] [review]:

sure, thanks
Comment 81 Olivier Fourdan 2015-12-03 08:20:04 UTC
Review of attachment 316650 [details] [review]:

attachment 316650 [details] [review] pushed as commit de41389 gtkwindow: Document further resize with csd
Comment 82 Olivier Fourdan 2015-12-03 08:21:15 UTC
To paraphrase Matthias, "Lets try again to close this".
Comment 83 Alberts Muktupāvels 2015-12-28 03:00:35 UTC
Review of attachment 315855 [details] [review]:

This patch introduced regression. Now _gtk_header_bar_update_window_buttons is called before gtk_application_set_app_menu... So if gtk-shell-shows-app-menu == FALSE applications with appmenu does not show it (at least initially).
Comment 84 Alberts Muktupāvels 2015-12-28 03:01:22 UTC
Created attachment 317944 [details] [review]
gtkheaderbar: update windows buttons also on realize
Comment 85 Christoph Reiter (lazka) 2015-12-28 07:09:40 UTC
Review of attachment 317944 [details] [review]:

Please include the description on why this is needed in the commit message.

otherwise lgtm
Comment 86 Alberts Muktupāvels 2015-12-28 19:10:57 UTC
Created attachment 317981 [details] [review]
gtkheaderbar: update window buttons also on realize
Comment 87 Christoph Reiter (lazka) 2016-01-01 13:55:19 UTC
Review of attachment 317981 [details] [review]:

thanks
Comment 88 Michael Catanzaro 2016-02-13 01:38:20 UTC
It introduced a weird regression in several apps, see bug #761978.
Comment 89 Olivier Fourdan 2016-02-15 07:42:05 UTC
(In reply to Michael Catanzaro from comment #88)
> It introduced a weird regression in several apps, see bug #761978.

Most likely these apps try to save their size using a method that doesn't take decorations into account (e.g. gtk_widget_get_allocation) and restore it using another method which does (e.g. gtk_window_set_default_size), thus causing the window to grow.

See bug 759117 for an example of what I mean.