Don't remember the window position but the size only.

It is often useful to have multiple browser windows opening at once,
and having them open on top of each other is counterproductive.
Most window managers, on the other hand, have code to decide where
to place a window so that it is accessible by the user.
This commit is contained in:
Ori Bernstein 2007-12-27 01:01:22 +01:00 committed by Christian Dywan
parent 3f4c2e3c14
commit e3561c71ad
3 changed files with 5 additions and 24 deletions

View file

@ -823,14 +823,6 @@ void on_findbox_button_close_clicked(GtkWidget* widget, CBrowser* browser)
gtk_widget_hide(browser->findbox); gtk_widget_hide(browser->findbox);
} }
static gboolean on_window_configure(GtkWidget* widget, GdkEventConfigure* event
, CBrowser* browser)
{
gtk_window_get_position(GTK_WINDOW(browser->window)
, &config->winLeft, &config->winTop);
return FALSE;
}
static void on_window_size_allocate(GtkWidget* widget, GtkAllocation* allocation static void on_window_size_allocate(GtkWidget* widget, GtkAllocation* allocation
, CBrowser* browser) , CBrowser* browser)
{ {
@ -882,24 +874,19 @@ CBrowser* browser_new(CBrowser* oldBrowser)
GdkScreen* screen = gtk_window_get_screen(GTK_WINDOW(browser->window)); GdkScreen* screen = gtk_window_get_screen(GTK_WINDOW(browser->window));
const gint defaultWidth = (gint)gdk_screen_get_width(screen) / 1.7; const gint defaultWidth = (gint)gdk_screen_get_width(screen) / 1.7;
const gint defaultHeight = (gint)gdk_screen_get_height(screen) / 1.7; const gint defaultHeight = (gint)gdk_screen_get_height(screen) / 1.7;
if(config->rememberWinMetrics) if(config->rememberWinSize)
{ {
if(!config->winWidth && !config->winHeight) if(!config->winWidth && !config->winHeight)
{ {
config->winWidth = defaultWidth; config->winWidth = defaultWidth;
config->winHeight = defaultWidth; config->winHeight = defaultWidth;
} }
if(config->winLeft && config->winTop)
gtk_window_move(GTK_WINDOW(browser->window)
, config->winLeft, config->winTop);
gtk_window_set_default_size(GTK_WINDOW(browser->window) gtk_window_set_default_size(GTK_WINDOW(browser->window)
, config->winWidth, config->winHeight); , config->winWidth, config->winHeight);
} }
else else
gtk_window_set_default_size(GTK_WINDOW(browser->window) gtk_window_set_default_size(GTK_WINDOW(browser->window)
, defaultWidth, defaultHeight); , defaultWidth, defaultHeight);
g_signal_connect(browser->window, "configure-event"
, G_CALLBACK(on_window_configure), browser);
g_signal_connect(browser->window, "size-allocate" g_signal_connect(browser->window, "size-allocate"
, G_CALLBACK(on_window_size_allocate), browser); , G_CALLBACK(on_window_size_allocate), browser);
// FIXME: Use custom program icon // FIXME: Use custom program icon

View file

@ -87,9 +87,7 @@ gboolean config_from_file(CConfig* config, const gchar* filename, GError** error
#define GET_STR(var, key, default) \ #define GET_STR(var, key, default) \
var = sokoke_key_file_get_string_default( \ var = sokoke_key_file_get_string_default( \
keyFile, "session", key, default, NULL) keyFile, "session", key, default, NULL)
GET_INT(config->rememberWinMetrics , "RememberWinMetrics", TRUE); GET_INT(config->rememberWinSize, "RememberWinSize", TRUE);
GET_INT(config->winLeft , "WinLeft", 0);
GET_INT(config->winTop , "WinTop", 0);
GET_INT(config->winWidth, "WinWidth", 0); GET_INT(config->winWidth, "WinWidth", 0);
GET_INT(config->winHeight, "WinHeight", 0); GET_INT(config->winHeight, "WinHeight", 0);
GET_INT(config->winPanelPos, "WinPanelPos", 0); GET_INT(config->winPanelPos, "WinPanelPos", 0);
@ -149,9 +147,7 @@ gboolean config_to_file(CConfig* config, const gchar* filename, GError** error)
g_key_file_set_integer(keyFile, "content", "EnableJavaScript", config->enableJavaScript); g_key_file_set_integer(keyFile, "content", "EnableJavaScript", config->enableJavaScript);
g_key_file_set_integer(keyFile, "content", "EnablePlugins", config->enablePlugins); g_key_file_set_integer(keyFile, "content", "EnablePlugins", config->enablePlugins);
g_key_file_set_integer(keyFile, "session", "RememberWinMetrics", config->rememberWinMetrics); g_key_file_set_integer(keyFile, "session", "RememberWinSize", config->rememberWinSize);
g_key_file_set_integer(keyFile, "session", "WinLeft", config->winLeft);
g_key_file_set_integer(keyFile, "session", "WinTop", config->winTop);
g_key_file_set_integer(keyFile, "session", "WinWidth", config->winWidth); g_key_file_set_integer(keyFile, "session", "WinWidth", config->winWidth);
g_key_file_set_integer(keyFile, "session", "WinHeight", config->winHeight); g_key_file_set_integer(keyFile, "session", "WinHeight", config->winHeight);
g_key_file_set_integer(keyFile, "session", "WinPanelPos", config->winPanelPos); g_key_file_set_integer(keyFile, "session", "WinPanelPos", config->winPanelPos);

View file

@ -43,9 +43,7 @@ typedef struct _CConfig
gboolean enableJavaScript; gboolean enableJavaScript;
gboolean enablePlugins; gboolean enablePlugins;
gboolean rememberWinMetrics; // Restore last state upon startup? gboolean rememberWinSize; // Restore window size upon startup?
gint winLeft;
gint winTop;
gint winWidth; gint winWidth;
gint winHeight; gint winHeight;
guint winPanelPos; guint winPanelPos;