From 446fd7d72afabb397fbe98279ac8b66765133940 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Wed, 3 Sep 2008 12:38:32 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20547449=20=E2=80=93=20Entry/=20Combo=20pop?= =?UTF-8?q?up=20misplaced=20after=20resize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/trunk/; revision=21263 --- ChangeLog | 10 ++++++++++ gtk/gtkcombobox.c | 31 +++++++++++++++++++++++++++++-- gtk/gtkentry.c | 5 +++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8699550df0..5b0f73aa05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-09-03 Christian Dywan + + Bug 547449 – Entry/ Combo popup misplaced after resize + + * gtk/gtkcombobox.c (gtk_combo_box_menu_position), + (gtk_combo_box_size_allocate): reposition the combo popup when the + allocation changes + * gtk/gtkentry.c (gtk_entry_size_allocate): reposition the + completion popup when the allocation changes + 2008-09-03 Michael Natterer * gtk/gtkmenu.c (get_arrows_visible_area): proper function header diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 1255e7c0e1..df6b601094 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -1605,8 +1605,9 @@ gtk_combo_box_menu_position (GtkMenu *menu, gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data); } - gtk_window_set_type_hint (GTK_WINDOW (GTK_MENU (priv->popup_widget)->toplevel), - GDK_WINDOW_TYPE_HINT_COMBO); + if (!GTK_WIDGET_VISIBLE (GTK_MENU (priv->popup_widget)->toplevel)) + gtk_window_set_type_hint (GTK_WINDOW (GTK_MENU (priv->popup_widget)->toplevel), + GDK_WINDOW_TYPE_HINT_COMBO); } static void @@ -2293,6 +2294,23 @@ gtk_combo_box_size_allocate (GtkWidget *widget, child.width -= child.x; } + if (GTK_WIDGET_VISIBLE (priv->popup_widget)) + { + gint width; + GtkRequisition requisition; + + /* Warning here, without the check in the position func */ + gtk_menu_reposition (GTK_MENU (priv->popup_widget)); + if (priv->wrap_width == 0) + { + width = GTK_WIDGET (combo_box)->allocation.width; + gtk_widget_set_size_request (priv->popup_widget, -1, -1); + gtk_widget_size_request (priv->popup_widget, &requisition); + gtk_widget_set_size_request (priv->popup_widget, + MAX (width, requisition.width), -1); + } + } + child.width = MAX (1, child.width); child.height = MAX (1, child.height); gtk_widget_size_allocate (GTK_BIN (widget)->child, &child); @@ -2362,6 +2380,15 @@ gtk_combo_box_size_allocate (GtkWidget *widget, child.width -= delta_x * 2; child.height -= delta_y * 2; } + + if (GTK_WIDGET_VISIBLE (priv->popup_window)) + { + gint x, y, width, height; + gtk_combo_box_list_position (combo_box, &x, &y, &width, &height); + gtk_window_move (GTK_WINDOW (priv->popup_window), x, y); + gtk_widget_set_size_request (priv->popup_window, width, height); + } + child.width = MAX (1, child.width); child.height = MAX (1, child.height); diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 4383057ee3..76d17b64ab 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -1581,6 +1581,7 @@ gtk_entry_size_allocate (GtkWidget *widget, * be affected by the usize of the entry, if set */ gint x, y, width, height; + GtkEntryCompletion* completion; get_widget_window_size (entry, &x, &y, &width, &height); @@ -1593,6 +1594,10 @@ gtk_entry_size_allocate (GtkWidget *widget, x, y, width, height); gtk_entry_recompute (entry); + + completion = gtk_entry_get_completion (entry); + if (completion && GTK_WIDGET_MAPPED (completion->priv->popup_window)) + _gtk_entry_completion_resize_popup (completion); } }