From 7af5019d862d62147fdd747b0a62d3513f9f6f16 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Mon, 20 Feb 2012 23:02:21 +0100 Subject: [PATCH] Fix katze_widget_popup_position_menu for GTK+ The window NULL-check was wrong in any case. The key issue here is that GtkEntry internals changed in GTK+3 and we need to take that into account. --- katze/katze-utils.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/katze/katze-utils.c b/katze/katze-utils.c index 25def2d6..3c211aa0 100644 --- a/katze/katze-utils.c +++ b/katze/katze-utils.c @@ -910,21 +910,29 @@ katze_widget_popup_position_menu (GtkMenu* menu, GtkRequisition widget_req; KatzePopupInfo* info = user_data; GtkWidget* widget = info->widget; + GdkWindow* window = gtk_widget_get_window (widget); gint widget_height; - gtk_widget_get_allocation (widget, &allocation); + if (!window) + return; + + #if !GTK_CHECK_VERSION (3, 0, 0) + if (GTK_IS_ENTRY (widget)) + window = gdk_window_get_parent (window); + #endif /* Retrieve size and position of both widget and menu */ - if (!gtk_widget_get_has_window (widget)) - { - gdk_window_get_position (gtk_widget_get_window (widget), &wx, &wy); - wx += allocation.x; - wy += allocation.y; - } - else - gdk_window_get_origin (gtk_widget_get_window (widget), &wx, &wy); + gtk_widget_get_allocation (widget, &allocation); + gdk_window_get_origin (window, &wx, &wy); + wx += allocation.x; + wy += allocation.y; + #if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL); + gtk_widget_get_preferred_size (widget, &widget_req, NULL); + #else gtk_widget_size_request (GTK_WIDGET (menu), &menu_req); gtk_widget_size_request (widget, &widget_req); + #endif menu_width = menu_req.width; widget_height = widget_req.height; /* Better than allocation.height */