File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,13 @@ void SaveWindowState(GtkWindow* window) {
78
78
gint width = DEFAULT_WINDOW_WIDTH;
79
79
gint height = DEFAULT_WINDOW_HEIGHT;
80
80
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
+
81
88
GKeyFile* key_file = g_key_file_new ();
82
89
GError* err = NULL ;
83
90
gchar* filePath = NULL ;
@@ -182,17 +189,16 @@ void LoadWindowState(GtkWindow* window) {
182
189
height = DEFAULT_WINDOW_HEIGHT;
183
190
maximized = TRUE ;
184
191
}
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
-
192
192
} else {
193
193
any_error = true ;
194
194
}
195
195
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
+
196
202
if (err || any_error) {
197
203
198
204
// The failure could be because the file may not have been present,
You can’t perform that action at this time.
0 commit comments