From 71b930e61ea4b57c7b2305ca47c71b876ce8ae5e Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Fri, 18 Feb 2005 00:00:48 +0000 Subject: Fix #130990 "Mixing up workspaces of windows when restoring session". * src/ephy-session.c: (impl_attach_window), (write_ephy_window), (restore_geometry), (ephy_session_load): Fix #130990 "Mixing up workspaces of windows when restoring session". Commited patch referenced in bug with slight modifications to make it work properly. --- ChangeLog | 9 +++++++++ src/ephy-session.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 411c1884c..5a62cfe6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-02-18 Xan Lopez + + * src/ephy-session.c: (impl_attach_window), (write_ephy_window), + (restore_geometry), (ephy_session_load): + + Fix #130990 "Mixing up workspaces of windows when restoring session". + Commited patch referenced in bug with slight modifications to make it + work properly. + 2005-02-14 Christian Persch * embed/ephy-embed-single.c: (ephy_embed_single_iface_init): diff --git a/src/ephy-session.c b/src/ephy-session.c index 49ca547d9..3d1781bc3 100644 --- a/src/ephy-session.c +++ b/src/ephy-session.c @@ -227,6 +227,22 @@ impl_attach_window (EphyExtension *extension, G_CALLBACK (tab_removed_cb), session); g_signal_connect (notebook, "tabs_reordered", G_CALLBACK (tabs_reordered_cb), session); + + /* Set unique identifier as role, so that on restore, the WM can + * place the window on the right workspace + */ + + if (gtk_window_get_role (GTK_WINDOW (window)) == NULL) + { + /* I guess rand() is unique enough, otherwise we could use + * time + pid or something + */ + char *role; + + role = g_strdup_printf ("epiphany-window-%x", rand()); + gtk_window_set_role (GTK_WINDOW (window), role); + g_free (role); + } } static void @@ -556,6 +572,7 @@ write_ephy_window (xmlTextWriterPtr writer, EphyWindow *window) { GList *tabs, *l; + const char *role; int ret; tabs = ephy_window_get_tabs (window); @@ -571,6 +588,13 @@ write_ephy_window (xmlTextWriterPtr writer, ret = write_window_geometry (writer, GTK_WINDOW (window)); if (ret < 0) return ret; + role = gtk_window_get_role (GTK_WINDOW (window)); + if (role != NULL) + { + ret = xmlTextWriterWriteAttribute (writer, "role", role); + if (ret < 0) return ret; + } + for (l = tabs; l != NULL; l = l->next) { EphyTab *tab = EPHY_TAB(l->data); @@ -741,8 +765,16 @@ restore_geometry (GtkWindow *window, if (success) { + tmp = xmlGetProp (node, (xmlChar *)"role"); + if (tmp != NULL) + { + gtk_window_set_role (GTK_WINDOW (window), (const char *)tmp); + xmlFree (tmp); + } + gtk_window_move (window, x, y); gtk_window_set_default_size (window, width, height); + } } /* @@ -792,7 +824,7 @@ ephy_session_load (EphySession *session, ephy_gui_window_update_user_time (widget, user_time); - gtk_window_present (GTK_WINDOW (widget)); + gtk_widget_show (widget); } else if (xmlStrEqual (child->name, (const xmlChar *) "toolwindow")) { @@ -819,7 +851,7 @@ ephy_session_load (EphySession *session, ephy_gui_window_update_user_time (widget, user_time); - gtk_window_present (GTK_WINDOW (widget)); + gtk_widget_show (widget); } child = child->next; -- cgit v1.2.3