Author: cazfi Date: Sat Mar 5 23:43:38 2016 New Revision: 32188 URL: http://svn.gna.org/viewcvs/freeciv?rev=32188&view=rev Log: Fixed "gdk_window_move_resize_internal: assertion 'GDK_IS_WINDOW (window)'" error when detaching lower part of the gtk3 or gtk3x-client window.
See bug #24474 Modified: trunk/client/gui-gtk-3.0/gui_main.c trunk/client/gui-gtk-3.x/gui_main.c Modified: trunk/client/gui-gtk-3.0/gui_main.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/gui_main.c?rev=32188&r1=32187&r2=32188&view=diff ============================================================================== --- trunk/client/gui-gtk-3.0/gui_main.c (original) +++ trunk/client/gui-gtk-3.0/gui_main.c Sat Mar 5 23:43:38 2016 @@ -358,6 +358,7 @@ gpointer data) { static int old_width = 0, old_height = 0; + if (allocation->width != old_width || allocation->height != old_height) { chatline_scroll_to_bottom(TRUE); @@ -748,7 +749,7 @@ } /************************************************************************** - reattaches the detached widget when the user destroys it. + Reattaches the detached widget when the user destroys it. **************************************************************************/ static void tearoff_destroy(GtkWidget *w, gpointer data) { @@ -764,17 +765,18 @@ } /************************************************************************** - propagates a keypress in a tearoff back to the toplevel window. + Propagates a keypress in a tearoff back to the toplevel window. **************************************************************************/ static gboolean propagate_keypress(GtkWidget *w, GdkEventKey *ev) { gtk_widget_event(toplevel, (GdkEvent *)ev); + return FALSE; } /************************************************************************** - callback for the toggle button in the detachable widget: causes the - widget to detach or reattach. + Callback for the toggle button in the detachable widget: causes the + widget to detach or reattach. **************************************************************************/ static void tearoff_callback(GtkWidget *b, gpointer data) { @@ -782,6 +784,8 @@ GtkWidget *w; if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b))) { + GtkWidget *temp_hide; + w = gtk_window_new(GTK_WINDOW_TOPLEVEL); setup_dialog(w, toplevel); gtk_widget_set_name(w, "Freeciv"); @@ -791,11 +795,17 @@ g_signal_connect(w, "key_press_event", G_CALLBACK(propagate_keypress), NULL); - g_object_set_data(G_OBJECT(w), "parent", gtk_widget_get_parent(box)); g_object_set_data(G_OBJECT(w), "toggle", b); + temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent"); + if (temp_hide != NULL) { + gtk_widget_hide(temp_hide); + } gtk_widget_reparent(box, w); gtk_widget_show(w); + if (temp_hide != NULL) { + gtk_widget_show(temp_hide); + } } else { gtk_widget_destroy(gtk_widget_get_parent(box)); } @@ -1050,12 +1060,13 @@ **************************************************************************/ static void setup_widgets(void) { - GtkWidget *page, *ebox, *hgrid, *hgrid2, *sbox, *label; + GtkWidget *page, *ebox, *hgrid, *hgrid2, *label; GtkWidget *frame, *table, *table2, *paned, *hpaned, *sw, *text; GtkWidget *button, *view, *vgrid, *right_vbox = NULL; int i; char buf[256]; GtkWidget *notebook, *statusbar; + GtkWidget *dtach_lowbox = NULL; message_buffer = gtk_text_buffer_new(NULL); @@ -1460,9 +1471,9 @@ bottom_hpaned = hpaned = paned; right_notebook = bottom_notebook = top_notebook; } else { - sbox = detached_widget_new(); - gtk_paned_pack2(GTK_PANED(paned), sbox, FALSE, TRUE); - avbox = detached_widget_fill(sbox); + dtach_lowbox = detached_widget_new(); + gtk_paned_pack2(GTK_PANED(paned), dtach_lowbox, FALSE, TRUE); + avbox = detached_widget_fill(dtach_lowbox); vgrid = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), @@ -1527,6 +1538,9 @@ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5); main_message_area = GTK_TEXT_VIEW(text); + if (dtach_lowbox != NULL) { + g_object_set_data(G_OBJECT(dtach_lowbox), "hide-over-reparent", main_message_area); + } chat_welcome_message(TRUE); Modified: trunk/client/gui-gtk-3.x/gui_main.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/gui_main.c?rev=32188&r1=32187&r2=32188&view=diff ============================================================================== --- trunk/client/gui-gtk-3.x/gui_main.c (original) +++ trunk/client/gui-gtk-3.x/gui_main.c Sat Mar 5 23:43:38 2016 @@ -361,6 +361,7 @@ gpointer data) { static int old_width = 0, old_height = 0; + if (allocation->width != old_width || allocation->height != old_height) { chatline_scroll_to_bottom(TRUE); @@ -774,17 +775,18 @@ } /************************************************************************** - propagates a keypress in a tearoff back to the toplevel window. + Propagates a keypress in a tearoff back to the toplevel window. **************************************************************************/ static gboolean propagate_keypress(GtkWidget *w, GdkEventKey *ev) { gtk_widget_event(toplevel, (GdkEvent *)ev); + return FALSE; } /************************************************************************** - callback for the toggle button in the detachable widget: causes the - widget to detach or reattach. + Callback for the toggle button in the detachable widget: causes the + widget to detach or reattach. **************************************************************************/ static void tearoff_callback(GtkWidget *b, gpointer data) { @@ -793,6 +795,7 @@ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b))) { GtkWidget *old_parent; GtkWidget *w; + GtkWidget *temp_hide; old_parent = gtk_widget_get_parent(box); w = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -807,12 +810,21 @@ g_object_set_data(G_OBJECT(w), "parent", gtk_widget_get_parent(box)); g_object_set_data(G_OBJECT(w), "toggle", b); + temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent"); + if (temp_hide != NULL) { + gtk_widget_hide(temp_hide); + } + g_object_ref(box); /* Make sure reference count stays above 0 * during the transition to new parent. */ gtk_container_remove(GTK_CONTAINER(old_parent), box); gtk_container_add(GTK_CONTAINER(w), box); g_object_unref(box); gtk_widget_show(w); + + if (temp_hide != NULL) { + gtk_widget_show(temp_hide); + } } else { gtk_widget_destroy(gtk_widget_get_parent(box)); } @@ -1072,12 +1084,13 @@ **************************************************************************/ static void setup_widgets(void) { - GtkWidget *page, *ebox, *hgrid, *hgrid2, *sbox, *label; + GtkWidget *page, *ebox, *hgrid, *hgrid2, *label; GtkWidget *frame, *table, *table2, *paned, *hpaned, *sw, *text; GtkWidget *button, *view, *vgrid, *right_vbox = NULL; int i; char buf[256]; GtkWidget *notebook, *statusbar; + GtkWidget *dtach_lowbox = NULL; struct sprite *spr; message_buffer = gtk_text_buffer_new(NULL); @@ -1502,9 +1515,9 @@ bottom_hpaned = hpaned = paned; right_notebook = bottom_notebook = top_notebook; } else { - sbox = detached_widget_new(); - gtk_paned_pack2(GTK_PANED(paned), sbox, FALSE, TRUE); - avbox = detached_widget_fill(sbox); + dtach_lowbox = detached_widget_new(); + gtk_paned_pack2(GTK_PANED(paned), dtach_lowbox, FALSE, TRUE); + avbox = detached_widget_fill(dtach_lowbox); vgrid = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), @@ -1569,6 +1582,9 @@ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5); main_message_area = GTK_TEXT_VIEW(text); + if (dtach_lowbox != NULL) { + g_object_set_data(G_OBJECT(dtach_lowbox), "hide-over-reparent", main_message_area); + } chat_welcome_message(TRUE); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits