Bug 796256 - Closing Gnucash when minimized on windows

Closing Gnucash on Windows when minimized causes the window position to
be saved as -32000,-32000 and on restart the window can not be seen. To
fix this the previous retrieved position is saved and used if on exit
the window is minimized.
This commit is contained in:
Robert Fewell 2018-06-02 11:22:58 +01:00
parent f77e6e34c4
commit 51093e43ba

View File

@ -224,7 +224,8 @@ typedef struct GncMainWindowPrivate
GncPluginPage *current_page; GncPluginPage *current_page;
/** The identifier for this window's engine event handler. */ /** The identifier for this window's engine event handler. */
gint event_handler_id; gint event_handler_id;
/** Array for window position. */
gint pos[2];
/** A hash table of all action groups that have been installed /** A hash table of all action groups that have been installed
* into this window. The keys are the name of an action * into this window. The keys are the name of an action
* group, the values are structures of type * group, the values are structures of type
@ -773,6 +774,8 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da
else else
{ {
gtk_window_move(GTK_WINDOW(window), pos[0], pos[1]); gtk_window_move(GTK_WINDOW(window), pos[0], pos[1]);
priv->pos[0] = pos[0];
priv->pos[1] = pos[1];
DEBUG("window (%p) position %dx%d", window, pos[0], pos[1]); DEBUG("window (%p) position %dx%d", window, pos[0], pos[1]);
} }
if (geom) if (geom)
@ -1004,7 +1007,7 @@ gnc_main_window_save_window (GncMainWindow *window, GncMainWindowSaveData *data)
GncMainWindowPrivate *priv; GncMainWindowPrivate *priv;
GtkAction *action; GtkAction *action;
gint i, num_pages, coords[4], *order; gint i, num_pages, coords[4], *order;
gboolean maximized, visible; gboolean maximized, minimized, visible;
gchar *window_group; gchar *window_group;
/* Setup */ /* Setup */
@ -1045,8 +1048,19 @@ gnc_main_window_save_window (GncMainWindow *window, GncMainWindowSaveData *data)
gtk_window_get_size(GTK_WINDOW(window), &coords[2], &coords[3]); gtk_window_get_size(GTK_WINDOW(window), &coords[2], &coords[3]);
maximized = (gdk_window_get_state(gtk_widget_get_window ((GTK_WIDGET(window)))) maximized = (gdk_window_get_state(gtk_widget_get_window ((GTK_WIDGET(window))))
& GDK_WINDOW_STATE_MAXIMIZED) != 0; & GDK_WINDOW_STATE_MAXIMIZED) != 0;
g_key_file_set_integer_list(data->key_file, window_group, minimized = (gdk_window_get_state(gtk_widget_get_window ((GTK_WIDGET(window))))
WINDOW_POSITION, &coords[0], 2); & GDK_WINDOW_STATE_ICONIFIED) != 0;
if (minimized)
{
gint *pos = priv->pos;
g_key_file_set_integer_list(data->key_file, window_group,
WINDOW_POSITION, &pos[0], 2);
DEBUG("window minimized (%p) position %dx%d", window, pos[0], pos[1]);
}
else
g_key_file_set_integer_list(data->key_file, window_group,
WINDOW_POSITION, &coords[0], 2);
g_key_file_set_integer_list(data->key_file, window_group, g_key_file_set_integer_list(data->key_file, window_group,
WINDOW_GEOMETRY, &coords[2], 2); WINDOW_GEOMETRY, &coords[2], 2);
g_key_file_set_boolean(data->key_file, window_group, g_key_file_set_boolean(data->key_file, window_group,