This repository was archived by the owner on Sep 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,6 +78,13 @@ void SaveWindowState(GtkWindow* window) {
7878 gint width = DEFAULT_WINDOW_WIDTH;
7979 gint height = DEFAULT_WINDOW_HEIGHT;
8080
81+ // Try to center the window.
82+ GdkScreen* screen = gdk_screen_get_default ();
83+ if (screen) {
84+ left = (gdk_screen_get_width (screen) - DEFAULT_WINDOW_WIDTH) / 2 ;
85+ top = (gdk_screen_get_height (screen) - DEFAULT_WINDOW_HEIGHT) / 2 ;
86+ }
87+
8188 GKeyFile* key_file = g_key_file_new ();
8289 GError* err = NULL ;
8390 gchar* filePath = NULL ;
@@ -182,17 +189,16 @@ void LoadWindowState(GtkWindow* window) {
182189 height = DEFAULT_WINDOW_HEIGHT;
183190 maximized = TRUE ;
184191 }
185-
186- gtk_window_move (GTK_WINDOW (window), left, top);
187- gtk_window_set_default_size (GTK_WINDOW (window), width, height);
188-
189- if (maximized)
190- MaximizeWindow (window);
191-
192192 } else {
193193 any_error = true ;
194194 }
195195
196+ gtk_window_move (GTK_WINDOW (window), left, top);
197+ gtk_window_set_default_size (GTK_WINDOW (window), width, height);
198+
199+ if (maximized)
200+ MaximizeWindow (window);
201+
196202 if (err || any_error) {
197203
198204 // The failure could be because the file may not have been present,
You can’t perform that action at this time.
0 commit comments