[gtk+] menu: Realize window before positioning
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] menu: Realize window before positioning
- Date: Wed, 25 May 2011 02:50:22 +0000 (UTC)
commit 067dc19177c6aa4cdfbe9c166cc2e6c961d1e4fc
Author: Benjamin Otte <otte redhat com>
Date: Wed May 25 04:48:20 2011 +0200
menu: Realize window before positioning
We want the menu realized so we know the size it's allocating to itself.
And we need that size to position the menu properly.
This is best visible on right-to-left.
gtk/gtkmenu.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index b6e4ee8..90ae933 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1695,7 +1695,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
gtk_widget_size_allocate (priv->toplevel, &tmp_allocation);
- gtk_widget_realize (GTK_WIDGET (menu));
+ gtk_widget_realize (priv->toplevel);
}
gtk_menu_scroll_to (menu, priv->scroll_offset);
@@ -4656,10 +4656,12 @@ gtk_menu_position (GtkMenu *menu,
pointer = _gtk_menu_shell_get_grab_device (GTK_MENU_SHELL (menu));
gdk_device_get_position (pointer, &pointer_screen, &x, &y);
- /* Get the minimum height for minimum width to figure out
+ /* Realize so we have the proper width and heigh to figure out
* the right place to popup the menu.
*/
- gtk_widget_get_preferred_size (widget, &requisition, NULL);
+ gtk_widget_realize (priv->toplevel);
+ requisition.width = gtk_widget_get_allocated_width (widget);
+ requisition.height = gtk_widget_get_allocated_height (widget);
if (pointer_screen != screen)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]