Skip to content

Commit

Permalink
Allow negative window coordinates when saving and restoring the posit…
Browse files Browse the repository at this point in the history
…ion of the main window.

Restore the main window position and size *after* the window has been realised to get it positioned accordingly (this affects at least Windows).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3666 ea778897-0a13-0410-b9d1-a72fbfd435f5
  • Loading branch information
eht16 committed Mar 27, 2009
1 parent a6cecbd commit 9431eea
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Expand Up @@ -3,6 +3,12 @@
* src/keyfile.c, src/utils.c, src/utils.h:
Add utils_path_skip_root(), a relative path safe variant of
g_path_skip_root (forgotten patch by Colomban Wendling, #2518658).
* src/keyfile.c, src/main.c:
Allow negative window coordinates when saving and restoring the
position of the main window.
Restore the main window position and size *after* the window has
been realised to get it positioned accordingly
(this affects at least Windows).


2009-03-26 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Expand Down
4 changes: 2 additions & 2 deletions src/keyfile.c
Expand Up @@ -800,10 +800,10 @@ static void load_ui_prefs(GKeyFile *config)
ui_prefs.geometry[4] = geo[4];

/* don't use insane values but when main windows was maximized last time, pos might be
* negative at least on Windows for some reason */
* negative (due to differences in root window and window decorations) */
if (ui_prefs.geometry[4] != 1)
{
for (i = 0; i < 4; i++)
for (i = 2; i < 4; i++)
{
if (ui_prefs.geometry[i] < -1)
ui_prefs.geometry[i] = -1;
Expand Down
29 changes: 19 additions & 10 deletions src/main.c
Expand Up @@ -150,6 +150,17 @@ static GOptionEntry entries[] =
};


static void setup_window_position(void)
{
/* interprets the saved window geometry */
if (prefs.save_winpos)
{
gtk_window_move(GTK_WINDOW(main_widgets.window), ui_prefs.geometry[0], ui_prefs.geometry[1]);
gtk_window_set_default_size(GTK_WINDOW(main_widgets.window), ui_prefs.geometry[2], ui_prefs.geometry[3]);
if (ui_prefs.geometry[4] == 1)
gtk_window_maximize(GTK_WINDOW(main_widgets.window));
}
}

/* special things for the initial setup of the checkboxes and related stuff
* an action on a setting is only performed if the setting is not equal to the program default
Expand Down Expand Up @@ -214,15 +225,6 @@ static void apply_settings(void)

ui_update_view_editor_menu_items();

/* interprets the saved window geometry */
if (prefs.save_winpos && ui_prefs.geometry[0] != -1)
{
gtk_window_move(GTK_WINDOW(main_widgets.window), ui_prefs.geometry[0], ui_prefs.geometry[1]);
gtk_window_set_default_size(GTK_WINDOW(main_widgets.window), ui_prefs.geometry[2], ui_prefs.geometry[3]);
if (ui_prefs.geometry[4] == 1)
gtk_window_maximize(GTK_WINDOW(main_widgets.window));
}

/* hide statusbar if desired */
if (! interface_prefs.statusbar_visible)
{
Expand Down Expand Up @@ -1051,7 +1053,14 @@ gint main(gint argc, gchar **argv)
build_menu_update(doc);
treeviews_update_tag_list(doc, FALSE);

/* finally realize the window to show the user what we have done */
#ifdef G_OS_WIN32
/* Manually realise the main window to be able to set the position but don't show it.
* We don't set the position after showing the window to avoid flickering. */
gtk_widget_realize(main_widgets.window);
#endif
setup_window_position();

/* finally show the window */
gtk_widget_show(main_widgets.window);
main_status.main_window_realized = TRUE;

Expand Down

0 comments on commit 9431eea

Please sign in to comment.