From 314b9a28b0f04b3f7c5475e74dfcde6ed49f68ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20A=2E=20Mart=C3=ADnez?= Date: Fri, 6 Apr 2018 20:01:28 +0200 Subject: [PATCH 1/5] Window state remembering - initial commit --- appshell/browser/root_window_gtk.cc | 102 +++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 9 deletions(-) diff --git a/appshell/browser/root_window_gtk.cc b/appshell/browser/root_window_gtk.cc index 60f66302e..bb60dd9d1 100644 --- a/appshell/browser/root_window_gtk.cc +++ b/appshell/browser/root_window_gtk.cc @@ -49,6 +49,89 @@ void MaximizeWindow(GtkWindow* window) { gtk_window_maximize(window); } +void SaveWindowState(GtkWindow* window) { + gint left, top; + gint width, height; + + GKeyFile* key_file = g_key_file_new(); + GError* error = NULL; + gchar* filePath = g_strdup_printf("%s/%s/%s", g_get_user_config_dir(), APP_NAME, "window.ini"); + bool maximized = IsWindowMaximized(window); + + // If window is not maximized, save current size and position + if (!maximized) { + gtk_window_get_position(window, &left, &top); + gtk_window_get_size(window, &width, &height); + // If maximized, load size and position from file + // to preserve last saved values + } else { + if(g_key_file_load_from_file(key_file, filePath, G_KEY_FILE_NONE, NULL)) + { + left = g_key_file_get_integer(key_file, "position", "left", &error); + top = g_key_file_get_integer(key_file, "position", "top", &error); + width = g_key_file_get_integer(key_file, "size", "width", &error); + height = g_key_file_get_integer(key_file, "size", "height", &error); + // If any value can not be readed, save defaults + if (left == 0 || top == 0 || width == 0 || height == 0) { + left = 1; + top = 1; + width = 800; + height = 600; + } + // If we can not load the file, save defaults + } else { + left = 1; + top = 1; + width = 800; + height = 600; + } + } + // The file will be written always. + g_key_file_set_integer(key_file, "position", "left", left); + g_key_file_set_integer(key_file, "position", "top", top); + g_key_file_set_integer(key_file, "size", "width", width - 1); // DelayedResize() 1 pixel compensation + g_key_file_set_integer(key_file, "size", "height", height - 1); // DelayedResize() 1 pixel compensation + g_key_file_set_boolean(key_file, "state", "maximized", maximized); + + if(!g_key_file_save_to_file(key_file, filePath, NULL)) + { + printf("%s", "Error -> SaveWindowState(): can not write `window.ini`\n"); + } +} + +void LoadWindowState(GtkWindow* window) { + gint left = 1; + gint top = 1; + gint width = 800; + gint height = 600; + bool maximized = FALSE; + + GKeyFile* key_file = g_key_file_new(); + GError* error = NULL; + gchar* filePath = g_strdup_printf("%s/%s/%s", g_get_user_config_dir(), APP_NAME, "window.ini"); + + if(g_key_file_load_from_file(key_file, filePath, G_KEY_FILE_NONE, NULL)) + { + left = g_key_file_get_integer(key_file, "position", "left", &error); + top = g_key_file_get_integer(key_file, "position", "top", &error); + width = g_key_file_get_integer(key_file, "size", "width", &error); + height = g_key_file_get_integer(key_file, "size", "height", &error); + maximized = g_key_file_get_boolean(key_file, "state", "maximized", &error); + // If any value can not be readed, load defaults + if (left == 0 || top == 0 || width == 0 || height == 0) { + left = 1; + top = 1; + width = 800; + height = 600; + maximized = FALSE; + } + } + gtk_window_move(GTK_WINDOW(window), left, top); + gtk_window_set_default_size(GTK_WINDOW(window), width, height); + if (maximized) + MaximizeWindow(window); +} + } // namespace RootWindowGtk::RootWindowGtk() @@ -197,6 +280,7 @@ void RootWindowGtk::Close(bool force) { REQUIRE_MAIN_THREAD(); if (window_) { + SaveWindowState(GTK_WINDOW(window_)); force_close_ = force; gtk_widget_destroy(window_); } @@ -242,18 +326,18 @@ void RootWindowGtk::CreateRootWindow(const CefBrowserSettings& settings) { // in the upper-left corner. Maybe there's a better default place to put it? int x = start_rect_.x; int y = start_rect_.y; - int width, height; + int width = start_rect_.width; + int height = start_rect_.height; + + window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); + if (start_rect_.IsEmpty()) { - // TODO(port): Also, maybe there's a better way to choose the default size. - width = 800; - height = 600; + LoadWindowState(GTK_WINDOW(window_)); } else { - width = start_rect_.width; - height = start_rect_.height; + gtk_window_move(GTK_WINDOW(window_), x, y); + gtk_window_set_default_size(GTK_WINDOW(window_), width, height); } - window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size(GTK_WINDOW(window_), width, height); g_signal_connect(G_OBJECT(window_), "focus-in-event", G_CALLBACK(&RootWindowGtk::WindowFocusIn), this); g_signal_connect(G_OBJECT(window_), "window-state-event", @@ -341,7 +425,7 @@ void RootWindowGtk::CreateRootWindow(const CefBrowserSettings& settings) { // Most window managers ignore requests for initial window positions (instead // using a user-defined placement algorithm) and honor requests after the // window has already been shown. - gtk_window_move(GTK_WINDOW(window_), x, y); + //gtk_window_move(GTK_WINDOW(window_), x, y); // Windowed browsers are parented to the X11 Window underlying the GtkWindow* // and must be sized manually. The OSR GTK widget, on the other hand, can be From d283b0b73b316bac677d702ea15d78180962b9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20A=2E=20Mart=C3=ADnez?= Date: Sat, 7 Apr 2018 06:56:53 +0200 Subject: [PATCH 2/5] Comments update --- appshell/browser/root_window_gtk.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/appshell/browser/root_window_gtk.cc b/appshell/browser/root_window_gtk.cc index bb60dd9d1..646456ec7 100644 --- a/appshell/browser/root_window_gtk.cc +++ b/appshell/browser/root_window_gtk.cc @@ -71,14 +71,14 @@ void SaveWindowState(GtkWindow* window) { top = g_key_file_get_integer(key_file, "position", "top", &error); width = g_key_file_get_integer(key_file, "size", "width", &error); height = g_key_file_get_integer(key_file, "size", "height", &error); - // If any value can not be readed, save defaults + // If any value can not be readed, restore defaults if (left == 0 || top == 0 || width == 0 || height == 0) { left = 1; top = 1; width = 800; height = 600; } - // If we can not load the file, save defaults + // If we can not load the file, set defaults } else { left = 1; top = 1; @@ -100,6 +100,7 @@ void SaveWindowState(GtkWindow* window) { } void LoadWindowState(GtkWindow* window) { + // Default values if It is not possible to load the key file gint left = 1; gint top = 1; gint width = 800; @@ -117,7 +118,7 @@ void LoadWindowState(GtkWindow* window) { width = g_key_file_get_integer(key_file, "size", "width", &error); height = g_key_file_get_integer(key_file, "size", "height", &error); maximized = g_key_file_get_boolean(key_file, "state", "maximized", &error); - // If any value can not be readed, load defaults + // If any value can not be readed, set defaults again if (left == 0 || top == 0 || width == 0 || height == 0) { left = 1; top = 1; From e74f80fe90b18a5b681b7669c901d96eac719bf3 Mon Sep 17 00:00:00 2001 From: Prashanth Nethi Date: Thu, 19 Apr 2018 20:22:36 +0530 Subject: [PATCH 3/5] Code cleanup and change in behavior of restore in case window.ini file is not found --- appshell/browser/root_window_gtk.cc | 234 ++++++++++++++++++---------- 1 file changed, 155 insertions(+), 79 deletions(-) diff --git a/appshell/browser/root_window_gtk.cc b/appshell/browser/root_window_gtk.cc index 646456ec7..be79a2300 100644 --- a/appshell/browser/root_window_gtk.cc +++ b/appshell/browser/root_window_gtk.cc @@ -21,9 +21,14 @@ #include "appshell/browser/window_test.h" #include "appshell/common/client_switches.h" -// Brackets specific change. +// Brackets specific changes. #include "appshell/native_menu_model.h" #include "appshell/command_callbacks.h" +#include "appshell/appshell_helpers.h" + +#define DEFAULT_WINDOW_WIDTH 800 +#define DEFAULT_WINDOW_HEIGHT 600 +// End of Brackets specific changes. namespace client { @@ -31,107 +36,176 @@ namespace { const char kMenuIdKey[] = "menu_id"; -bool IsWindowMaximized(GtkWindow* window) { - GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window)); - gint state = gdk_window_get_state(gdk_window); - return (state & GDK_WINDOW_STATE_MAXIMIZED) ? true : false; +// Brackets specific changes. +gboolean IsWindowMaximized(GtkWindow* window) { + + if (window) { + GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window)); + if (gdk_window) { + gint state = gdk_window_get_state(gdk_window); + return (state & GDK_WINDOW_STATE_MAXIMIZED) ? TRUE : FALSE; + } + } else { + return FALSE; + } + } void MinimizeWindow(GtkWindow* window) { - // Unmaximize the window before minimizing so restore behaves correctly. - if (IsWindowMaximized(window)) - gtk_window_unmaximize(window); - gtk_window_iconify(window); + if (window) { + // Unmaximize the window before minimizing so restore behaves correctly. + if (IsWindowMaximized(window)) + gtk_window_unmaximize(window); + + gtk_window_iconify(window); + } } void MaximizeWindow(GtkWindow* window) { - gtk_window_maximize(window); + if (window) { + gtk_window_maximize(window); + } } void SaveWindowState(GtkWindow* window) { - gint left, top; - gint width, height; + + if (!window) + return; + + gint left = 1; + gint top = 1; + gint width = DEFAULT_WINDOW_WIDTH; + gint height = DEFAULT_WINDOW_HEIGHT; GKeyFile* key_file = g_key_file_new(); - GError* error = NULL; - gchar* filePath = g_strdup_printf("%s/%s/%s", g_get_user_config_dir(), APP_NAME, "window.ini"); - bool maximized = IsWindowMaximized(window); - - // If window is not maximized, save current size and position - if (!maximized) { - gtk_window_get_position(window, &left, &top); - gtk_window_get_size(window, &width, &height); - // If maximized, load size and position from file - // to preserve last saved values - } else { - if(g_key_file_load_from_file(key_file, filePath, G_KEY_FILE_NONE, NULL)) - { - left = g_key_file_get_integer(key_file, "position", "left", &error); - top = g_key_file_get_integer(key_file, "position", "top", &error); - width = g_key_file_get_integer(key_file, "size", "width", &error); - height = g_key_file_get_integer(key_file, "size", "height", &error); - // If any value can not be readed, restore defaults - if (left == 0 || top == 0 || width == 0 || height == 0) { - left = 1; - top = 1; - width = 800; - height = 600; + GError* err = NULL; + if (key_file) { + gchar* filePath = g_strdup_printf("%s/%s", appshell::AppGetSupportDirectory().ToString().c_str(), "window.ini"); + gboolean maximized = IsWindowMaximized(window); + + // If window is not maximized, save current size and position + + if (!maximized) { + gtk_window_get_position(window, &left, &top); + gtk_window_get_size(window, &width, &height); + } else if (g_key_file_load_from_file(key_file, filePath, G_KEY_FILE_NONE, &err)) { + + // If maximized, load size and position from file + // to preserve last saved values + left = g_key_file_get_integer(key_file, "position", "left", &err); + if (!err) + top = g_key_file_get_integer(key_file, "position", "top", &err); + + if (!err) + width = g_key_file_get_integer(key_file, "size", "width", &err); + + if (!err) + height = g_key_file_get_integer(key_file, "size", "height", &err); + + // If any value can not be read, restore defaults + if (err) { + left = 1; + top = 1; + width = DEFAULT_WINDOW_WIDTH; + height = DEFAULT_WINDOW_HEIGHT; + g_error_free(err); } - // If we can not load the file, set defaults - } else { - left = 1; - top = 1; - width = 800; - height = 600; } - } - // The file will be written always. - g_key_file_set_integer(key_file, "position", "left", left); - g_key_file_set_integer(key_file, "position", "top", top); - g_key_file_set_integer(key_file, "size", "width", width - 1); // DelayedResize() 1 pixel compensation - g_key_file_set_integer(key_file, "size", "height", height - 1); // DelayedResize() 1 pixel compensation - g_key_file_set_boolean(key_file, "state", "maximized", maximized); - - if(!g_key_file_save_to_file(key_file, filePath, NULL)) - { - printf("%s", "Error -> SaveWindowState(): can not write `window.ini`\n"); + + // The values would always be written to file. + g_key_file_set_integer(key_file, "position", "left", left); + g_key_file_set_integer(key_file, "position", "top", top); + g_key_file_set_integer(key_file, "size", "width", width - 1); // DelayedResize() 1 pixel compensation + g_key_file_set_integer(key_file, "size", "height", height - 1); // DelayedResize() 1 pixel compensation + g_key_file_set_boolean(key_file, "state", "maximized", maximized); + + g_key_file_save_to_file(key_file, filePath, &err); + + if (err) { + fprintf(stderr, "Err -> SaveWindowState(): could not write to `window.ini`. Error Description: %s\n", err->message); + g_error_free(err); + } + } else { + fprintf(stderr, "Err -> SaveWindowState(): could not write to `window.ini`\n"); } } void LoadWindowState(GtkWindow* window) { - // Default values if It is not possible to load the key file - gint left = 1; - gint top = 1; - gint width = 800; - gint height = 600; - bool maximized = FALSE; + + if (!window) { + return; + } + + // Default values for the window state. + gint left = 1; + gint top = 1; + gint width = DEFAULT_WINDOW_WIDTH; + gint height = DEFAULT_WINDOW_HEIGHT; + + gboolean maximized = false; GKeyFile* key_file = g_key_file_new(); - GError* error = NULL; - gchar* filePath = g_strdup_printf("%s/%s/%s", g_get_user_config_dir(), APP_NAME, "window.ini"); - - if(g_key_file_load_from_file(key_file, filePath, G_KEY_FILE_NONE, NULL)) - { - left = g_key_file_get_integer(key_file, "position", "left", &error); - top = g_key_file_get_integer(key_file, "position", "top", &error); - width = g_key_file_get_integer(key_file, "size", "width", &error); - height = g_key_file_get_integer(key_file, "size", "height", &error); - maximized = g_key_file_get_boolean(key_file, "state", "maximized", &error); - // If any value can not be readed, set defaults again - if (left == 0 || top == 0 || width == 0 || height == 0) { - left = 1; - top = 1; - width = 800; - height = 600; - maximized = FALSE; - } + bool any_error = false; + GError* err = NULL; + + if (key_file) { + + gchar* filePath = g_strdup_printf("%s/%s", appshell::AppGetSupportDirectory().ToString().c_str(), "window.ini"); + + if(g_key_file_load_from_file(key_file, filePath, G_KEY_FILE_NONE, &err)) { + + left = g_key_file_get_integer(key_file, "position", "left", &err); + if (!err) + top = g_key_file_get_integer(key_file, "position", "top", &err); + + if (!err) + width = g_key_file_get_integer(key_file, "size", "width", &err); + + if (!err) + height = g_key_file_get_integer(key_file, "size", "height", &err); + + if (!err) + maximized = g_key_file_get_boolean(key_file, "state", "maximized", &err); + + // If any value can not be readed, set defaults again + if (err) { + left = 1; + top = 1; + width = DEFAULT_WINDOW_WIDTH; + height = DEFAULT_WINDOW_HEIGHT; + maximized = TRUE; + } + + gtk_window_move(GTK_WINDOW(window), left, top); + gtk_window_set_default_size(GTK_WINDOW(window), width, height); + + if (maximized) + MaximizeWindow(window); + } + + } else { + any_error = true; } - gtk_window_move(GTK_WINDOW(window), left, top); - gtk_window_set_default_size(GTK_WINDOW(window), width, height); - if (maximized) + + if (err || any_error) { + + // The failure could be because the file may not have been present, + // or the file read itself failed. + // In either of the cases default to maximizing the window. MaximizeWindow(window); + + if (err) { + if (err && err->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND){ + fprintf(stderr, "Err -> SaveWindowState(): could not create a file object to read `window.ini`. Error Description:%s.\n", err->message); + } + g_error_free(err); + } else { + fprintf(stderr, "Err -> SaveWindowState(): could not create a file object to read `window.ini`.\n"); + } + } } +// End of Brackets specific changes. } // namespace @@ -332,12 +406,14 @@ void RootWindowGtk::CreateRootWindow(const CefBrowserSettings& settings) { window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); + // Brackets specific change. if (start_rect_.IsEmpty()) { LoadWindowState(GTK_WINDOW(window_)); } else { gtk_window_move(GTK_WINDOW(window_), x, y); gtk_window_set_default_size(GTK_WINDOW(window_), width, height); } + // End of Brackets specific change. g_signal_connect(G_OBJECT(window_), "focus-in-event", G_CALLBACK(&RootWindowGtk::WindowFocusIn), this); From b6b13715faed34dc887b2a2feb88dfe7bc54e773 Mon Sep 17 00:00:00 2001 From: Prashanth Nethi Date: Tue, 24 Apr 2018 11:28:06 +0530 Subject: [PATCH 4/5] Fixed errors w.r.t error reporting and also added default window size as centered size. --- appshell/browser/root_window_gtk.cc | 71 +++++++++++++++-------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/appshell/browser/root_window_gtk.cc b/appshell/browser/root_window_gtk.cc index be79a2300..e32fbcc82 100644 --- a/appshell/browser/root_window_gtk.cc +++ b/appshell/browser/root_window_gtk.cc @@ -80,8 +80,10 @@ void SaveWindowState(GtkWindow* window) { GKeyFile* key_file = g_key_file_new(); GError* err = NULL; + gchar* filePath = NULL; + if (key_file) { - gchar* filePath = g_strdup_printf("%s/%s", appshell::AppGetSupportDirectory().ToString().c_str(), "window.ini"); + filePath = g_strdup_printf("%s/%s", appshell::AppGetSupportDirectory().ToString().c_str(), "window.ini"); gboolean maximized = IsWindowMaximized(window); // If window is not maximized, save current size and position @@ -119,12 +121,12 @@ void SaveWindowState(GtkWindow* window) { g_key_file_set_integer(key_file, "size", "width", width - 1); // DelayedResize() 1 pixel compensation g_key_file_set_integer(key_file, "size", "height", height - 1); // DelayedResize() 1 pixel compensation g_key_file_set_boolean(key_file, "state", "maximized", maximized); - + + err = NULL; g_key_file_save_to_file(key_file, filePath, &err); if (err) { fprintf(stderr, "Err -> SaveWindowState(): could not write to `window.ini`. Error Description: %s\n", err->message); - g_error_free(err); } } else { fprintf(stderr, "Err -> SaveWindowState(): could not write to `window.ini`\n"); @@ -143,46 +145,49 @@ void LoadWindowState(GtkWindow* window) { gint width = DEFAULT_WINDOW_WIDTH; gint height = DEFAULT_WINDOW_HEIGHT; + // Try to center the window. + GdkScreen* screen = gdk_screen_get_default(); + if (screen) { + left = (gdk_screen_get_width(screen) - DEFAULT_WINDOW_WIDTH) / 2 ; + top = (gdk_screen_get_height(screen) - DEFAULT_WINDOW_HEIGHT) / 2 ; + } + gboolean maximized = false; GKeyFile* key_file = g_key_file_new(); bool any_error = false; GError* err = NULL; + gchar* filePath = g_strdup_printf("%s/%s", appshell::AppGetSupportDirectory().ToString().c_str(), "window.ini"); - if (key_file) { - - gchar* filePath = g_strdup_printf("%s/%s", appshell::AppGetSupportDirectory().ToString().c_str(), "window.ini"); + if (key_file && g_key_file_load_from_file(key_file, filePath, G_KEY_FILE_NONE, &err)) { - if(g_key_file_load_from_file(key_file, filePath, G_KEY_FILE_NONE, &err)) { - - left = g_key_file_get_integer(key_file, "position", "left", &err); - if (!err) - top = g_key_file_get_integer(key_file, "position", "top", &err); + left = g_key_file_get_integer(key_file, "position", "left", &err); + if (!err) + top = g_key_file_get_integer(key_file, "position", "top", &err); - if (!err) - width = g_key_file_get_integer(key_file, "size", "width", &err); + if (!err) + width = g_key_file_get_integer(key_file, "size", "width", &err); - if (!err) - height = g_key_file_get_integer(key_file, "size", "height", &err); + if (!err) + height = g_key_file_get_integer(key_file, "size", "height", &err); - if (!err) - maximized = g_key_file_get_boolean(key_file, "state", "maximized", &err); + if (!err) + maximized = g_key_file_get_boolean(key_file, "state", "maximized", &err); - // If any value can not be readed, set defaults again - if (err) { - left = 1; - top = 1; - width = DEFAULT_WINDOW_WIDTH; - height = DEFAULT_WINDOW_HEIGHT; - maximized = TRUE; - } + // If any value can not be readed, set defaults again + if (err) { + left = 1; + top = 1; + width = DEFAULT_WINDOW_WIDTH; + height = DEFAULT_WINDOW_HEIGHT; + maximized = TRUE; + } - gtk_window_move(GTK_WINDOW(window), left, top); - gtk_window_set_default_size(GTK_WINDOW(window), width, height); + gtk_window_move(GTK_WINDOW(window), left, top); + gtk_window_set_default_size(GTK_WINDOW(window), width, height); - if (maximized) - MaximizeWindow(window); - } + if (maximized) + MaximizeWindow(window); } else { any_error = true; @@ -196,12 +201,12 @@ void LoadWindowState(GtkWindow* window) { MaximizeWindow(window); if (err) { - if (err && err->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND){ - fprintf(stderr, "Err -> SaveWindowState(): could not create a file object to read `window.ini`. Error Description:%s.\n", err->message); + if (err->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND){ + fprintf(stderr, "LoadWindowState(): Could not read %s. Error Description:%s.\n", filePath, err->message); } g_error_free(err); } else { - fprintf(stderr, "Err -> SaveWindowState(): could not create a file object to read `window.ini`.\n"); + fprintf(stderr, "LoadWindowState(): Could not read %s.\n", filePath); } } } From df563cc59d2ef01baff99f874ef4da4ce08a5b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20A=2E=20Mart=C3=ADnez?= Date: Wed, 2 May 2018 07:45:59 +0200 Subject: [PATCH 5/5] Center window on first save. Avoid the size of window too small when demaximizing (in the first execution). --- appshell/browser/root_window_gtk.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/appshell/browser/root_window_gtk.cc b/appshell/browser/root_window_gtk.cc index e32fbcc82..fb5f312b2 100644 --- a/appshell/browser/root_window_gtk.cc +++ b/appshell/browser/root_window_gtk.cc @@ -78,6 +78,13 @@ void SaveWindowState(GtkWindow* window) { gint width = DEFAULT_WINDOW_WIDTH; gint height = DEFAULT_WINDOW_HEIGHT; + // Try to center the window. + GdkScreen* screen = gdk_screen_get_default(); + if (screen) { + left = (gdk_screen_get_width(screen) - DEFAULT_WINDOW_WIDTH) / 2 ; + top = (gdk_screen_get_height(screen) - DEFAULT_WINDOW_HEIGHT) / 2 ; + } + GKeyFile* key_file = g_key_file_new(); GError* err = NULL; gchar* filePath = NULL; @@ -182,17 +189,16 @@ void LoadWindowState(GtkWindow* window) { height = DEFAULT_WINDOW_HEIGHT; maximized = TRUE; } - - gtk_window_move(GTK_WINDOW(window), left, top); - gtk_window_set_default_size(GTK_WINDOW(window), width, height); - - if (maximized) - MaximizeWindow(window); - } else { any_error = true; } + gtk_window_move(GTK_WINDOW(window), left, top); + gtk_window_set_default_size(GTK_WINDOW(window), width, height); + + if (maximized) + MaximizeWindow(window); + if (err || any_error) { // The failure could be because the file may not have been present,