From 8dbc5110708b9ec3b0d0058e0f5c080c3d65a1a1 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 10 May 2004 18:17:47 +0000 Subject: [PATCH] If we don't do the move-selected-item below pointer thingie, do the 2004-05-10 Matthias Clasen * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't do the move-selected-item below pointer thingie, do the place-below-or-above one. --- ChangeLog | 4 ++++ ChangeLog.pre-2-10 | 4 ++++ ChangeLog.pre-2-6 | 4 ++++ ChangeLog.pre-2-8 | 4 ++++ gtk/gtkcombobox.c | 38 ++++++++++++++++++++++++++++---------- 5 files changed, 44 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76f24eeba9..d5cbf40fc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2004-05-10 Matthias Clasen + * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't + do the move-selected-item below pointer thingie, do the + place-below-or-above one. + * tests/testentrycompletion.c: Make the second example use the ::match-selected signal to make it actually work. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 76f24eeba9..d5cbf40fc6 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,9 @@ 2004-05-10 Matthias Clasen + * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't + do the move-selected-item below pointer thingie, do the + place-below-or-above one. + * tests/testentrycompletion.c: Make the second example use the ::match-selected signal to make it actually work. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 76f24eeba9..d5cbf40fc6 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,5 +1,9 @@ 2004-05-10 Matthias Clasen + * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't + do the move-selected-item below pointer thingie, do the + place-below-or-above one. + * tests/testentrycompletion.c: Make the second example use the ::match-selected signal to make it actually work. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 76f24eeba9..d5cbf40fc6 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,9 @@ 2004-05-10 Matthias Clasen + * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't + do the move-selected-item below pointer thingie, do the + place-below-or-above one. + * tests/testentrycompletion.c: Make the second example use the ::match-selected signal to make it actually work. diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 118267e0bd..fdb1c67535 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -948,30 +948,48 @@ gtk_combo_box_menu_position_below (GtkMenu *menu, gint *push_in, gpointer user_data) { + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); gint sx, sy; GtkWidget *child; GtkRequisition req; - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + GdkScreen *screen; + gint monitor_num; + GdkRectangle monitor; /* FIXME: is using the size request here broken? */ child = GTK_BIN (combo_box)->child; gdk_window_get_origin (child->window, &sx, &sy); + if (GTK_WIDGET_NO_WINDOW (child)) + { + sx += child->allocation.x; + sy += child->allocation.y; + } + gtk_widget_size_request (GTK_WIDGET (menu), &req); - + if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR) *x = sx; else *x = sx + child->allocation.width - req.width; - *y = sy + child->allocation.height; - - if (GTK_WIDGET_NO_WINDOW (child)) - { - *x += child->allocation.x; - *y += child->allocation.y; - } - + *y = sy; + + screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); + monitor_num = gdk_screen_get_monitor_at_window (screen, + GTK_WIDGET (combo_box)->window); + gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); + + if (*x < monitor.x) + *x = monitor.x; + else if (*x + req.width > monitor.x + monitor.width) + *x = monitor.x + monitor.width - req.width; + + if (*y + child->allocation.height + req.height <= monitor.y + monitor.height) + *y += child->allocation.height; + else + *y -= req.height; + *push_in = TRUE; }