[gtk+/toplevel-embedding] Dont show the GtkWindow when removing it from a parent and becomming a toplevel
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/toplevel-embedding] Dont show the GtkWindow when removing it from a parent and becomming a toplevel
- Date: Mon, 3 Jan 2011 15:49:53 +0000 (UTC)
commit 4d795437f1bca0c397e36cd4482f4af15ee7bec7
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Tue Jan 4 00:55:04 2011 +0900
Dont show the GtkWindow when removing it from a parent and becomming a toplevel
Showing the window causes it to try to grab focus, this causes problems
when embedded toplevels run through dispose cycles.
gtk/gtkwindow.c | 17 ++++++-----------
tests/testtoplevelembed.c | 1 +
2 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 112227b..c2d9c88 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -9237,14 +9237,16 @@ _gtk_window_set_is_toplevel (GtkWindow *window,
if (is_toplevel)
{
- gboolean was_visible = gtk_widget_get_visible (widget);
-
/* Pass through regular pathways of an embedded toplevel
* to go through unmapping and hiding the widget before
* becomming a toplevel again.
+ *
+ * We remain hidden after becomming toplevel in order to
+ * avoid problems during an embedded toplevel's dispose cycle
+ * (When a toplevel window is shown it tries to grab focus again,
+ * this causes problems while disposing).
*/
- if (was_visible)
- gtk_widget_hide (widget);
+ gtk_widget_hide (widget);
/* Save the toplevel this widget was previously anchored into before
* propagating a hierarchy-changed.
@@ -9267,13 +9269,6 @@ _gtk_window_set_is_toplevel (GtkWindow *window,
_gtk_widget_propagate_hierarchy_changed (widget, toplevel);
toplevel_list = g_slist_prepend (toplevel_list, window);
-
- /* If an embedded toplevel gets removed from the hierarchy
- * and is still in a visible state, we need to show it again
- * so it will be realized as a real toplevel again.
- */
- if (was_visible)
- gtk_widget_show (widget);
}
else
{
diff --git a/tests/testtoplevelembed.c b/tests/testtoplevelembed.c
index 12a79b2..c698252 100644
--- a/tests/testtoplevelembed.c
+++ b/tests/testtoplevelembed.c
@@ -9,6 +9,7 @@ remove_notebook_page (GtkWidget *button,
GtkWidget *toplevel)
{
gtk_container_remove (GTK_CONTAINER (notebook), toplevel);
+ gtk_widget_show (toplevel);
}
GtkWidget *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]