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 696882 - [regression] GtkWindow changes size after hide/show cycle
[regression] GtkWindow changes size after hide/show cycle
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
3.8.2
: 696187 698584 698795 698806 698811 698841 699299 699449 699969 700795 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-03-29 23:23 UTC by John Lindgren
Modified: 2013-05-31 22:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (456 bytes, text/plain)
2013-03-29 23:23 UTC, John Lindgren
  Details
Fix #696882: window would revert to minimum size after hide/show (2.01 KB, patch)
2013-03-31 12:55 UTC, Olivier Brunel (jjacky)
reviewed Details | Review
Fix #696882: window would revert to minimum size after hide/show (2.05 KB, patch)
2013-04-03 23:03 UTC, Olivier Brunel (jjacky)
none Details | Review
window: restore size after hide/show properly (4.94 KB, patch)
2013-04-08 14:30 UTC, Benjamin Otte (Company)
committed Details | Review
Test case #2 (626 bytes, text/plain)
2013-04-08 22:29 UTC, John Lindgren
  Details
Test case #3 (692 bytes, text/plain)
2013-04-11 01:13 UTC, John Lindgren
  Details
patch to revert 38b62e46 as a workaround (4.29 KB, patch)
2013-05-08 14:46 UTC, Adam Dingle
none Details | Review

Description John Lindgren 2013-03-29 23:23:12 UTC
Created attachment 240144 [details]
Test case

Calling gtk_widget_hide() and then gtk_widget_show() on a GtkWindow changes the size of the window since https://git.gnome.org/browse/gtk+/commit/?id=b495ce5446a0bbf2ed63b5880537779e4b123515.  This was originally reported to Audacious as http://redmine.audacious-media-player.org/issues/259.

Test case attached.  Notice how the shown window is initially around 200x200 pixels but changes to 1x1 after the first hide/show cycle.  Using the mouse to resize the window also makes no difference; the size again reverts to 1x1 after the next cycle.
Comment 1 Olivier Brunel (jjacky) 2013-03-31 12:55:11 UTC
Created attachment 240201 [details] [review]
Fix #696882: window would revert to minimum size after  hide/show

Fixes the issue by returning a different allocation when not visible (as seem to have been the intent of the orginal commit), but while preserving the allocation for when the widget is made visible again.
Comment 2 Emmanuele Bassi (:ebassi) 2013-04-03 16:14:48 UTC
Review of attachment 240201 [details] [review]:

minimal review, it will still need a formal review from Matthias and/or Benjamin.

::: gtk/gtkwidget.c
@@ +13916,3 @@
 
+  if (priv->visible)
+      *allocation = priv->allocation;

coding style: only two spaces for the indentation.

@@ +13918,3 @@
+      *allocation = priv->allocation;
+  else
+      *allocation = (GtkAllocation) { -1, -1, 1, 1 };

this is a GCC-ism, and it's not portable. it should be rewritten in a portable way.

also, coding style (as above).
Comment 3 Olivier Brunel (jjacky) 2013-04-03 23:03:15 UTC
Created attachment 240558 [details] [review]
Fix #696882: window would revert to minimum size after  hide/show
Comment 4 Bastien Nocera 2013-04-04 14:44:25 UTC
This doesn't fix bug 697275, where it ignores the values set using gtk_window_set_default_size().
Comment 5 Olivier Brunel (jjacky) 2013-04-04 20:01:42 UTC
Lots of bugs this doesn't fix ;-)

Was that bug also introduced by b495ce5446a0? Also, do you have a test case for it? Trying a simple code that creates a window, calls gtk_window_set_default_size() and shows the window have it at the expected size.
Comment 6 Chris Vine 2013-04-05 10:40:51 UTC
This patch fixes the resize problem but does not fix the abort for me in the audacious bug report: gtk_widget_unregister_window: assertion failed: (user_data == widget)
Aborted
Comment 7 Thomas Lange 2013-04-05 16:00:01 UTC
I experienced the abort bug with 3.7.12 but 3.8.0 fixed it.
Are you sure you are not using an older version?
Comment 8 Chris Vine 2013-04-05 17:05:31 UTC
I am definitely using 3.8.0.  It seems to be a problem with GtkStatusIcon in gtk+-3.8.0, as I have the same problem, with the same backtrace, with another program.  If I am the only one experiencing this and if I have time I will try some tests on GtkStatusIcon over the weekend (I may not).
Comment 9 Chris Vine 2013-04-06 13:00:25 UTC
The GtkIconStatus bug is trivially reproducible with GTK+-3.8.0 and I have filed a separate bug #697427 for that.
Comment 10 Benjamin Otte (Company) 2013-04-08 14:30:59 UTC
Created attachment 240952 [details] [review]
window: restore size after hide/show properly

Old code assumed the size was stored in widget.allocation. This is no
longer true as the allocation is cleared upon hide. However, we store
the last configure request, and that one tracks the last size, so we can
just use that number.

Sometimes things are so easy - once you figure them out...
Comment 11 Benjamin Otte (Company) 2013-04-08 14:34:04 UTC
That's the patch I'm gonna push to master - and to gtk-3-8 unless issues show up. I'd be happy if people could test that it fixes all the issues they've been seeing. I only checked that it fixes the attached test.
Comment 12 Thomas Lange 2013-04-08 17:07:14 UTC
It also fixes the bug with Audacious, thanks for your patches.
Comment 13 Thomas Lange 2013-04-08 17:14:11 UTC
(In reply to comment #12)
> It also fixes the bug with Audacious, thanks for your patches.

Sorry, I was wrong. If you resize the window and click twice on the statusicon, the size is not the new one.
Comment 14 John Lindgren 2013-04-08 22:29:58 UTC
Created attachment 240985 [details]
Test case #2

I confirm Thomas's observations, the test case is fixed but Audacious is still broken.  Here is a second test case that is closer to what Audacious actually does.  The only difference is the addition of a gtk_window_get_position() right before gtk_widget_hide() and a corresponding gtk_window_move() right before gtk_widget_show().
Comment 15 John Lindgren 2013-04-08 22:35:42 UTC
In my testing, I'm applying the patch on top of 3.8.0, btw.
Comment 16 Benjamin Otte (Company) 2013-04-08 23:24:05 UTC
Hrm, the testcase works here with master.
Comment 17 John Lindgren 2013-04-09 02:33:47 UTC
I tried master and it is still not working here (the window reverts to 200x200 now instead of 1x1, however).  Screencast: https://www.box.com/s/bvtqc1sfskdpiai5qq1u
Comment 18 Benjamin Otte (Company) 2013-04-09 10:33:31 UTC
Pushed c4dc0e8e40e2144d84810f7603c9d1552e25fb43 as another fix for the issue you pointed out.

Also pushed the patches to the gtk-3-8 branch. And now I'm closing this, please reopen if there's still things broken.
Comment 19 John Lindgren 2013-04-09 22:43:23 UTC
Seems to be fixed.
Comment 20 Thomas Lange 2013-04-10 17:00:57 UTC
(In reply to comment #19)
> Seems to be fixed.

Which branch? I have tested gtk-3-8 and Audacious still does not restore the size
if I resize it manually and click the status icon. But your test case #2 works fine now.
Comment 21 John Lindgren 2013-04-11 01:13:18 UTC
Created attachment 241215 [details]
Test case #3

Hmm, not fixed yet after all.  Adding a call to gtk_window_set_default_size() causes the window to forget its size again and always come back at the default size.  Attaching test case #3.
Comment 22 Olivier Brunel (jjacky) 2013-04-24 09:00:18 UTC
Yeah, another way it manifests itself is on window using an expander. When toggling an expander the window will be reset to its default size, thus undoing any user/manual resize previously done.

This can be seen by using the expander example from gtk3-demo, only replacing the call to gtk_window_set_resizable() with one to gtk_window_set_default_size()
Comment 23 Andrew Cowie 2013-04-25 09:26:59 UTC
Just hit this with GTK 3.8.1 on a GNOME 3.8 system. It's affecting Evolution badly, but now giggle is doing it too.

AfC
Comment 24 bwatkins 2013-04-25 11:04:11 UTC
It effects empathy VERY badly too. Every single time the contact list updates it resizes to become super-wide. Massive regression and very annoying :(

Using arch linux with gtk 3.8.1-1

other apps that are affected are disks, inkscape.
Comment 25 Bastien Nocera 2013-04-25 14:43:32 UTC
*** Bug 698795 has been marked as a duplicate of this bug. ***
Comment 26 Adam Dingle 2013-04-25 14:58:47 UTC
*** Bug 698841 has been marked as a duplicate of this bug. ***
Comment 27 bwatkins 2013-04-25 15:24:04 UTC
*** Bug 698811 has been marked as a duplicate of this bug. ***
Comment 28 Olivier Brunel (jjacky) 2013-04-26 12:57:10 UTC
So, I've been running GTK 3.8.1 with the fix (38b62e46) reverted, and using the patch I submitted earlier instead. AFAICS it fixes the original bug without introducing new ones, e.g. hiding/showing windows or windows w/ expander work as expected, as do all submitted test cases. (I don't use Audacious or any of the other mentionned apps, so I didn't check that.)

(The only thing I noticed was a bug in tooltip placement, but that only made it happen all the time, whereas it would otherwise happen on some occasions only. Either way, a patch is here: https://bugzilla.gnome.org/show_bug.cgi?id=698730)

Seems to me that this would fix the issue properly. Now, the committed fix does change behavior in GtkWindow, but the original commit (b495ce54) wasn't about GtkWindow but GtkWidget, so even if the new bugs were fixed, wouldn't that left things not the way they should, one way or another? (e.g. after setting visible to FALSE on a widget, get_allocation() doesn't return { -1, -1, 1, 1 } as was the intent)

Comments?
Comment 29 Sébastien Wilmet 2013-04-27 16:24:12 UTC
Another problem with the commit 38b62e46 (en the gtk-3-8 branch):

When a GtkWindow is hidden and then shown again, the child widget is not visible anymore. The "visible" property on the child widget doesn't change and is TRUE, so there is a problem.
Comment 30 aatdark 2013-04-28 12:19:40 UTC
*** Bug 698806 has been marked as a duplicate of this bug. ***
Comment 31 Luis Henrique Mello 2013-05-01 20:16:54 UTC
*** Bug 699299 has been marked as a duplicate of this bug. ***
Comment 32 Bastian Ilsø 2013-05-02 15:32:16 UTC
*** Bug 698584 has been marked as a duplicate of this bug. ***
Comment 33 Germán Poo-Caamaño 2013-05-02 20:17:52 UTC
*** Bug 699449 has been marked as a duplicate of this bug. ***
Comment 34 Thomas Lange 2013-05-02 22:35:13 UTC
Still not fixed with commit https://git.gnome.org/browse/gtk+/commit/?id=2d29c4a43fbdab4d9fcae2589cf729b2dd1c3783.

If you reduce the window size, the default size is restored in testcase #1 and #2.
Tested with GTK master.
Comment 35 Dustin Falgout 2013-05-06 19:30:38 UTC
This very annoying bug is still alive and well on GNOME 3.8.1 using GTK 3.8.1-2.4. Any new developments? I would be glad to help with testing a fix.
Comment 36 Adam Dingle 2013-05-08 14:44:59 UTC
Yes, this bug is quite annoying in its current manifestation.  The easiest workaround is to simply revert the commit 38b62e46.  Here's a patch that reverts that commit.  I had to resolve a merge conflict in making this, so you'll find it easier to apply this patch than to run 'git revert' directly.  It applies cleanly to the head of the gtk-3-8 branch.
Comment 37 Adam Dingle 2013-05-08 14:46:01 UTC
Created attachment 243593 [details] [review]
patch to revert 38b62e46 as a workaround
Comment 38 Dustin Falgout 2013-05-08 14:48:49 UTC
You just made my day :-D . I am going to apply it right now! THANKS! 


(In reply to comment #36)
> Yes, this bug is quite annoying in its current manifestation.  The easiest
> workaround is to simply revert the commit 38b62e46.  Here's a patch that
> reverts that commit.  I had to resolve a merge conflict in making this, so
> you'll find it easier to apply this patch than to run 'git revert' directly. 
> It applies cleanly to the head of the gtk-3-8 branch.
Comment 39 Igor Gnatenko 2013-05-09 12:46:22 UTC
What patch I need apply ?
Comment 40 Adam Dingle 2013-05-09 12:59:21 UTC
(In reply to comment #39)
> What patch I need apply ?

The patch I attached in comment #37.  You could do this, for example:

~/src/gtk+$ git am 0001-Revert-window-restore-size-after-hide-show-properly.patch
~/src/gtk+$ make
~/src/gtk+$ make install
Comment 41 Olivier Brunel (jjacky) 2013-05-09 13:09:46 UTC
Though obviously simply reverting 38b62e46 doesn't fix the original bug. However as said earlier, using the patch from comment #3 should do the trick.
Comment 42 Dustin Falgout 2013-05-09 13:37:01 UTC
I hadn't realized that the patch from comment 3 actually did correct the bug! I thought that it was said that none of those patches fixed it. After reading everything again I see that we may be dealing with more than the just the one bug that comment 3 fixes. We should probably try to get separate bug reports started if that's is the case. Anyway, maybe someone here help me out. I spent 3 hours last night on yet another linux learning maze (lol) trying to apply the patch that was posted yesterday. I have the branch from git cloned locally and I successfully applied and committed the patch to the branch I created. Where do I go from this point to actually have the patched version installed on my system? If someone could point me in the right direction, I'd really appreciate it. Thanks!
Comment 43 Adam Dingle 2013-05-09 13:50:46 UTC
(In reply to comment #42)
> Where
> do I go from this point to actually have the patched version installed on my
> system? If someone could point me in the right direction, I'd really appreciate
> it. Thanks!

Unfortunately that's not a question with a simple answer.  In theory, you could simply run 'make' followed by 'make install'.  In practice you may hit the following issues:

- If you install GTK in /usr/local, then it may be unable to find your theme and other libraries it needs unless you install those in /usr/local too.
- If you install in /usr, you're clobbering your system installation of GTK which is a bad idea.
- If you're running a system such as Ubuntu which applies its own patches to GTK, then installing a GTK built directly from a clone of the GNOME repository may lead to odd behaviors.

The most straightforward path forward is probably to rebuild your system's GTK package having applied this patch.  Just how to do that depends on which operating system you are on.  This is getting off-topic for this bug, so I'd suggest following up on a mailing list such as gnome-love to get more help with this.
Comment 44 Dustin Falgout 2013-05-09 13:58:24 UTC
Ok, Ill do that. Thanks so much for the response! I am assuming since today is Thursday that someone will be updating this bug to at least CONFIRMED? I was going to ask in the IRC but after reviewing the triage wiki decided to hold off.
Comment 45 Matthias Clasen 2013-05-12 15:06:18 UTC
Please try current git master or the gtk-3-8 branch. I've pushed a few fixes that make all our window-sizing related tests pass.

If you find that there are still problems in apps, please reopen this bug or file a new one.
Comment 46 Igor Gnatenko 2013-05-12 15:10:10 UTC
(In reply to comment #45)
> Please try current git master or the gtk-3-8 branch. I've pushed a few fixes
> that make all our window-sizing related tests pass.
> 
> If you find that there are still problems in apps, please reopen this bug or
> file a new one.
I will test it at the night. But it's very good news =)
Comment 47 Igor Gnatenko 2013-05-12 16:09:43 UTC
(In reply to comment #45)
> Please try current git master or the gtk-3-8 branch. I've pushed a few fixes
> that make all our window-sizing related tests pass.
> 
> If you find that there are still problems in apps, please reopen this bug or
> file a new one.
yeah ! All works fine !
I love you =)
Comment 48 Dustin Falgout 2013-05-12 16:28:41 UTC
Awesome! I'll test it when I get home this evening and will hopefully be posting good news afterwards!

-Dustin
Comment 49 Dustin Falgout 2013-05-12 16:33:58 UTC
That's awesome. . This was an annoying bug. Thanks for all your work!
Comment 50 Igor Gnatenko 2013-05-12 18:31:13 UTC
ReOpen bug, please.
Empathy main window always on restart changed to:
-geometry 569x600+-9+19
I created Bug 700196 that I am not sure that it belongs to the current bug
Comment 51 Thomas Lange 2013-05-12 20:14:03 UTC
The original bug report
http://redmine.audacious-media-player.org/issues/259
is fixed now. Thanks a lot.
Comment 52 Lionel Landwerlin 2013-05-15 15:05:21 UTC
*** Bug 700089 has been marked as a duplicate of this bug. ***
Comment 53 Claudio Saavedra 2013-05-20 22:32:14 UTC
*** Bug 699969 has been marked as a duplicate of this bug. ***
Comment 54 Ignacio Casal Quinteiro (nacho) 2013-05-27 15:31:28 UTC
*** Bug 700795 has been marked as a duplicate of this bug. ***
Comment 55 Benjamin Otte (Company) 2013-05-31 22:25:27 UTC
*** Bug 696187 has been marked as a duplicate of this bug. ***