Geany built from git. GTK+ v3.24.30, GLib v2.68.4.
Steps to reproduce:
1. Geany in normal window mode. Close. Reopen. Window is restored to previous size. (as expected) 2. Toggle between maximized and normal states. Normal window size does not change. (as expected) 3. Maximize Geany. Close. Reopen. Window is restored to maximized state. (as expected) 4. Toggle to normal state. Window is shorter than previously (on KDE Plasma). Expected is for the previous size of the normal state to be restored.
Notes: * This occurs regardless of whether the message window and sidebar are visible. * The behavior described occurs on KDE plasma with 2x display scaling enabled. On XFCE with no display scaling, the window is larger than expected. * Potential solution: The geometry setting appears to have a flag to indicate the maximized state. There is no need to change the width/height when the window is maximized.
Here with Cinnamon the result is same window height but different width and position.
I don't think its anything to do with Geany's saved geometry. When the window is unmaximised the new size is set by the window manager IIUC, and the window manager does not save it when an application window is closed and re-opened. SO the fact that three different window managers give three different sizes is unsurprising. Clearly its some default setting in the WM, which may be modifiable in the desktop, but isn't under Geany control.
I don't think its anything to do with Geany's saved geometry.
Actually it is, I edited geometry on a Geany closed while maximised and restarted and when unmaximised the position and size matched the edited values.
So all that is needed when saving ui prefs is to test maximised first and not save geometry if its set.
On startup, the normal geometry can be restored prior to maximizing.
Thats what Geany already does, so all we need to do is to not modify geometry if maximised is set [here](https://github.com/geany/geany/blob/04566236d3f9811d55d6c7bcc492b3a60369fd20...)
@elextr When I change `keyfile.c` to not save size and position when maximized, the normal window size restores properly. But the msgwin and sidebar don't. ```C /* Save window size and position only when not maximized */ wstate = gdk_window_get_state(gtk_widget_get_window(main_widgets.window)); if (wstate & GDK_WINDOW_STATE_MAXIMIZED) ui_prefs.geometry[4] = 1; else { gtk_window_get_position(GTK_WINDOW(main_widgets.window), &ui_prefs.geometry[0], &ui_prefs.geometry[1]); gtk_window_get_size(GTK_WINDOW(main_widgets.window), &ui_prefs.geometry[2], &ui_prefs.geometry[3]); ui_prefs.geometry[4] = 0; } g_key_file_set_integer_list(config, PACKAGE, "geometry", ui_prefs.geometry, 5); ```
But the msgwin and sidebar don't.
"Position" of those panes seems to be the edit window side in both cases. Geany just saves and restores the number `gtk_paned_get_position()` returns.
But the edit window size changes when maximised (see the change from 493 to 642 in your post on #2977), not something Geany does, it must be part of the GTK sizing algorithm when the window size changes. This changed position for the panes is saved in config on close and then restored on restart so the position that was set by Geany set is now different. Note that max/unmax without closing the pane goes back to the original position, but since again AFAIK Geany does not do that, again it must be part of GTK sizing algorithm.
Thats harder to fix because it _should_ save the maximised position if closed when maximised, and that gets restored on restart and there is no record of the un-maximised position any more.
An unmaximised position needs to be saved separately for each pane, the unmax signal captured and the position changed after the unmax. I don't think its worth it frankly.
An unmaximised position needs to be saved separately for each pane, the unmax signal captured and the position changed after the unmax.
Couldn't an adjusted position be calculated with the maximized and normal window sizes? All available at the time the settings are saved.
Related: [sf.net/geany#568](https://sourceforge.net/p/geany/bugs/568/)
Not sure what you mean?
Let me try a sequence that shows the two options I understand:
1. Geany opened unmaximised, pane position P1 is read from the config file and set 2. Geany is maximised, GTK resizes the edit pane and calculates a new pane position so the message window stays the same size, P2 3. Geany is unmaximised, GTK resizes the edit pane and calculates a new pane position so the message window stays the same size, P3 (==P1) 4. Geany is maximised, GTK resizes the edit pane and calculates a new pane position so the message window stays the same size, P4 (==P2) 5. Geany is closed, option a (current behaviour): save P4, option b (possible alternative): save P1 originally read and stashed in a variable
Option a (current behaviour) :
6. Geany is opened and maximises, P4 is loaded from the config file and set, Geany is restored as it last was [chirping birds of happyness] 7. Geany is unmaximised, GTK only knows about P4 (Geany set it at step 6) so it uses that and the size of the message window changes [expletive deleted]
Option b (possible alternative):
6. Geany is opened and maximises, P1 is loaded from the config file and set, the message window has changed size [expletive deleted] 7. Geany is unmaximised, GTK only knows about P1 set at step 6, so the message window returns to the original size [possibly chirping birds of happiness, or expletive deleted its changed AGAIN!!!]
Note how the two options mirror each other, one works maximised, the other works unmaximised.
Can you explain your option c.
What the SF bug adds into the mix is iconified as well as maximised :grin:
Numbers are for illustration.
1. Geany started. Reads and restores config in non-max state, 400x300, sidebar at 300.
2. Geany maximized. 640x480. GTK magic: sidebar at 540.
3. User moves sidebar to position 500.
4. Geany closed. a. Calculate adjusted sidebar position as current sidebar position - maximized width (current) + non-maximized width (previous) = 500 - 640 + 480 = 340. b. Save maximized state (true). Save original geometry (400x300). Save adjusted sidebar position.
Oops... I meant... adjusted position = normal width - maximized width + current position; 400 - 640 + 500 = 260.
5. Geany opened, maximises and sets pane to 260????? Thats not either of the previous positions.
Geany opened, maximises and sets pane to 260????? Thats not either of the previous positions.
It's not. Because "3. User moves sidebar to position 500." So the new sidebar size is 140. If instead of closing, I had gone on...
4. Geany unmaximized. GTK magic: Non-max state restored, 400x300. Sidebar position **260**. (This is the adjusted size that was saved in the previous scenario.)
In 4b when Geany is closed maximised you saved adjusted sidebar position == 260 (IIUC), so I'm asking what happens when its next opened, it will read 260 from the config file and set that then maximise?
so I'm asking what happens when its next opened, it will read 260 from the config file and set that then maximise?
4. Close Geany in maximized state. Save original geometry (400x300). Save adjusted sidebar position (260). 5. Reopen Geany. a. Geany restores non-maximized geometry, 400x300. Sets sidebar position 260 from config. b. Geany restores maximized state. Geometry changes to 640x480. GTK magic: sidebar position changed to 500. (Where user had left it.)
Ok, thats clearer and makes sense (provided GTK magic is reliable), so now what happens when the user unmaximises?
6. Geany unmaximized. Geometry changed back to 400x300 (as previously set). GTK magic: sidebar position changed to 260.
github-comments@lists.geany.org