GNOME Bugzilla – Bug 688959
Resize reverted on focus loss
Last modified: 2013-02-26 12:15:54 UTC
Open a gnome-terminal window, and open a second tab. Resize the window. Then switch to another window (or click on the desktop). When g-t loses the focus, it reverts back to its previous size. Apparently the bug happens if the currently active tab is not the oldest one, and you do not switch (not even temporarily) to this oldest tab after resizing. [Originally seen on http://bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/1071295 , but apparently it's not Ubuntu specific.] A little bit of debugging revealed the following. In terminal_window_set_size_force_grid() I print the values of screen (as pointer), grid_width and grid_height. What you see is, on every focus loss or similar event, this method is called once for every tab you have, in apparently reverse order of their creation. This happens via terminal_screen_style_updated() which calls terminal_screen_change_font() which in turn calls terminal_window_set_size(). This is combined with the fact that g-t does not resize all its terminal tabs on window resize, only the active one; it defers resizing each tab (each terminal) until they become the selected one. So all the tabs that were not made the selected one after the resize still carry the old logical size. When someone (it's not clear to me yet who and why) iterates through all the tabs (apparently in reverse order of their creation) and adjusts the window size to match them, so the window size eventually will match the terminal size of the oldest tab, which might not have been updated since the resize. I'm really not sure if terminal_screen_style_updated() indeed needs to be called for every tab, but as a proof of concept inside this method I changed if (gtk_widget_get_realized (widget)) terminal_screen_change_font (screen); to if (gtk_widget_get_mapped (widget)) terminal_screen_change_font (screen); and this seems to solve the problem - I'm not sure about its side effects though (e.g. I never have tabs with different font sizes, I don't know what happens and what should happen in that case). I hope that based on these findings it'll be quite easy for you developer guys to come up with a proper fix :)
Created attachment 229745 [details] [review] proof of concept
*** This bug has been marked as a duplicate of bug 685507 ***
*** Bug 694738 has been marked as a duplicate of this bug. ***