[PATCH] Store the main window maximized state in the configuration

Dirk Hohndel dirk at hohndel.org
Sun Mar 3 07:56:09 PST 2013


The behavior with this patch seems a bit odd...

First time I started after compiling the window was maximized (and it
certainly wasn't the last time I ran Subsurface before).

And when exiting with the window maximized then un-maximizing the window
gets me an odd two pane display with no divelist.

Is that "as intended"? I think the position of the panes needs to be
stored separately for maximized and non-maximized or something.

/D


"Lubomir I. Ivanov" <neolit123 at gmail.com> writes:

> From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
>
> In save_window_geometry() use gdk_window_get_state() to retrieve
> the window maximized state and store it in the user configuration.
> Then in restore_window_geometry() restore the maximized state with
> gtk_window_maximize(), if needed.
>
> A side effect is that the windows resize now only occurs if
> the window wasn't maximized, otherwise clicking the "restore"
> (or "un-maximize") button will simply remove the maximized state,
> but the window will remain with fullscreen dimensions.
>
> Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
> ---
>  gtk-gui.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/gtk-gui.c b/gtk-gui.c
> index 5397903..c48bef2 100644
> --- a/gtk-gui.c
> +++ b/gtk-gui.c
> @@ -337,9 +337,14 @@ void save_window_geometry(void)
>  {
>  	/* GDK_GRAVITY_NORTH_WEST assumed ( it is the default ) */
>  	int window_width, window_height;
> -	gtk_window_get_size(GTK_WINDOW (main_window), &window_width, &window_height);
> +	gboolean is_maximized;
> +
> +	gtk_window_get_size(GTK_WINDOW(main_window), &window_width, &window_height);
> +	is_maximized = gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(main_window))) &
> +		GDK_WINDOW_STATE_MAXIMIZED;
>  	subsurface_set_conf_int("window_width", window_width);
>  	subsurface_set_conf_int("window_height", window_height);
> +	subsurface_set_conf_bool("window_maximized", is_maximized);
>  	save_pane_position();
>  	subsurface_flush_conf();
>  }
> @@ -347,6 +352,7 @@ void save_window_geometry(void)
>  void restore_window_geometry(void)
>  {
>  	int window_width, window_height;
> +	gboolean is_maximized = subsurface_get_conf_bool("window_maximized");
>  
>  	window_height = subsurface_get_conf_int("window_height");
>  	window_width = subsurface_get_conf_int("window_width");
> @@ -356,7 +362,11 @@ void restore_window_geometry(void)
>  
>  	gtk_paned_set_position(GTK_PANED(vpane), subsurface_get_conf_int("vpane_position"));
>  	gtk_paned_set_position(GTK_PANED(hpane), subsurface_get_conf_int("hpane_position"));
> -	gtk_window_resize (GTK_WINDOW (main_window), window_width, window_height);
> +	/* don't resize the window if in maximized state */
> +	if (is_maximized)
> +		gtk_window_maximize(GTK_WINDOW(main_window));
> +	else
> +		gtk_window_resize(GTK_WINDOW(main_window), window_width, window_height);
>  }
>  
>  gboolean on_delete(GtkWidget* w, gpointer data)
> -- 
> 1.7.11.msysgit.0
>
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

-- 
Dirk Hohndel
Intel Open Source Technology Center


More information about the subsurface mailing list