From ad9263ec39f150103854061eae34f225ccdcc0bf Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Fri, 3 Sep 1999 16:51:12 +0000 Subject: [ Fixes pointed out by Ettore Perazzoli ] Fri Sep 3 12:26:33 1999 Owen Taylor [ Fixes pointed out by Ettore Perazzoli ] * gtk/gtkmenu.c (gtk_menu_position): Make sure we never position menus with negative x, y, since gtk_widget_set_uposition() can't handle that. * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Modify the positioning code a bit so that we always put the top-left corner onscreen. (This is for UI reasons, gtk_menu_position() now takes care of gtk_widet_set_uposition() brokeness.) --- ChangeLog | 16 ++++++++++++++-- ChangeLog.pre-2-0 | 16 ++++++++++++++-- ChangeLog.pre-2-10 | 16 ++++++++++++++-- ChangeLog.pre-2-2 | 16 ++++++++++++++-- ChangeLog.pre-2-4 | 16 ++++++++++++++-- ChangeLog.pre-2-6 | 16 ++++++++++++++-- ChangeLog.pre-2-8 | 16 ++++++++++++++-- gtk/gtkmenu.c | 21 ++++++++------------- gtk/gtkmenuitem.c | 23 +++++++---------------- 9 files changed, 113 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5eca4ecda..3e0e1cc8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Fri Sep 3 12:26:33 1999 Owen Taylor + + [ Fixes pointed out by Ettore Perazzoli ] + + * gtk/gtkmenu.c (gtk_menu_position): Make + sure we never position menus with negative x, y, + since gtk_widget_set_uposition() can't handle that. + + * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): + Modify the positioning code a bit so that we always + put the top-left corner onscreen. (This is for + UI reasons, gtk_menu_position() now takes care of + gtk_widet_set_uposition() brokeness.) + Fri Sep 3 16:04:41 1999 Tim Janik * gtk-config.in (--version): don't echo @GTK_VERSION@, but @@ -443,7 +457,6 @@ Sat Aug 21 14:07:36 1999 Lars Hamann show them instead. (Bug#1805 Reported by: Dave Cole ) ->>>>>>> 1.1061.2.110 Wed Aug 18 09:20:10 1999 Tim Janik * gtk/gtkwindow.c: @@ -500,7 +513,6 @@ Tue Aug 17 07:43:04 1999 Tim Janik function from gtk_tooltips_expose, as we connect to ::expose_event *and* ::draw now. ->>>>>>> 1.1061.2.104 1999-08-18 Federico Mena Quintero * gtk/gtkselection.c (gtk_target_list_ref): Added missing sanity diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 5eca4ecda..3e0e1cc8b 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,17 @@ +Fri Sep 3 12:26:33 1999 Owen Taylor + + [ Fixes pointed out by Ettore Perazzoli ] + + * gtk/gtkmenu.c (gtk_menu_position): Make + sure we never position menus with negative x, y, + since gtk_widget_set_uposition() can't handle that. + + * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): + Modify the positioning code a bit so that we always + put the top-left corner onscreen. (This is for + UI reasons, gtk_menu_position() now takes care of + gtk_widet_set_uposition() brokeness.) + Fri Sep 3 16:04:41 1999 Tim Janik * gtk-config.in (--version): don't echo @GTK_VERSION@, but @@ -443,7 +457,6 @@ Sat Aug 21 14:07:36 1999 Lars Hamann show them instead. (Bug#1805 Reported by: Dave Cole ) ->>>>>>> 1.1061.2.110 Wed Aug 18 09:20:10 1999 Tim Janik * gtk/gtkwindow.c: @@ -500,7 +513,6 @@ Tue Aug 17 07:43:04 1999 Tim Janik function from gtk_tooltips_expose, as we connect to ::expose_event *and* ::draw now. ->>>>>>> 1.1061.2.104 1999-08-18 Federico Mena Quintero * gtk/gtkselection.c (gtk_target_list_ref): Added missing sanity diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 5eca4ecda..3e0e1cc8b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +Fri Sep 3 12:26:33 1999 Owen Taylor + + [ Fixes pointed out by Ettore Perazzoli ] + + * gtk/gtkmenu.c (gtk_menu_position): Make + sure we never position menus with negative x, y, + since gtk_widget_set_uposition() can't handle that. + + * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): + Modify the positioning code a bit so that we always + put the top-left corner onscreen. (This is for + UI reasons, gtk_menu_position() now takes care of + gtk_widet_set_uposition() brokeness.) + Fri Sep 3 16:04:41 1999 Tim Janik * gtk-config.in (--version): don't echo @GTK_VERSION@, but @@ -443,7 +457,6 @@ Sat Aug 21 14:07:36 1999 Lars Hamann show them instead. (Bug#1805 Reported by: Dave Cole ) ->>>>>>> 1.1061.2.110 Wed Aug 18 09:20:10 1999 Tim Janik * gtk/gtkwindow.c: @@ -500,7 +513,6 @@ Tue Aug 17 07:43:04 1999 Tim Janik function from gtk_tooltips_expose, as we connect to ::expose_event *and* ::draw now. ->>>>>>> 1.1061.2.104 1999-08-18 Federico Mena Quintero * gtk/gtkselection.c (gtk_target_list_ref): Added missing sanity diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 5eca4ecda..3e0e1cc8b 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,17 @@ +Fri Sep 3 12:26:33 1999 Owen Taylor + + [ Fixes pointed out by Ettore Perazzoli ] + + * gtk/gtkmenu.c (gtk_menu_position): Make + sure we never position menus with negative x, y, + since gtk_widget_set_uposition() can't handle that. + + * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): + Modify the positioning code a bit so that we always + put the top-left corner onscreen. (This is for + UI reasons, gtk_menu_position() now takes care of + gtk_widet_set_uposition() brokeness.) + Fri Sep 3 16:04:41 1999 Tim Janik * gtk-config.in (--version): don't echo @GTK_VERSION@, but @@ -443,7 +457,6 @@ Sat Aug 21 14:07:36 1999 Lars Hamann show them instead. (Bug#1805 Reported by: Dave Cole ) ->>>>>>> 1.1061.2.110 Wed Aug 18 09:20:10 1999 Tim Janik * gtk/gtkwindow.c: @@ -500,7 +513,6 @@ Tue Aug 17 07:43:04 1999 Tim Janik function from gtk_tooltips_expose, as we connect to ::expose_event *and* ::draw now. ->>>>>>> 1.1061.2.104 1999-08-18 Federico Mena Quintero * gtk/gtkselection.c (gtk_target_list_ref): Added missing sanity diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 5eca4ecda..3e0e1cc8b 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,17 @@ +Fri Sep 3 12:26:33 1999 Owen Taylor + + [ Fixes pointed out by Ettore Perazzoli ] + + * gtk/gtkmenu.c (gtk_menu_position): Make + sure we never position menus with negative x, y, + since gtk_widget_set_uposition() can't handle that. + + * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): + Modify the positioning code a bit so that we always + put the top-left corner onscreen. (This is for + UI reasons, gtk_menu_position() now takes care of + gtk_widet_set_uposition() brokeness.) + Fri Sep 3 16:04:41 1999 Tim Janik * gtk-config.in (--version): don't echo @GTK_VERSION@, but @@ -443,7 +457,6 @@ Sat Aug 21 14:07:36 1999 Lars Hamann show them instead. (Bug#1805 Reported by: Dave Cole ) ->>>>>>> 1.1061.2.110 Wed Aug 18 09:20:10 1999 Tim Janik * gtk/gtkwindow.c: @@ -500,7 +513,6 @@ Tue Aug 17 07:43:04 1999 Tim Janik function from gtk_tooltips_expose, as we connect to ::expose_event *and* ::draw now. ->>>>>>> 1.1061.2.104 1999-08-18 Federico Mena Quintero * gtk/gtkselection.c (gtk_target_list_ref): Added missing sanity diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 5eca4ecda..3e0e1cc8b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,17 @@ +Fri Sep 3 12:26:33 1999 Owen Taylor + + [ Fixes pointed out by Ettore Perazzoli ] + + * gtk/gtkmenu.c (gtk_menu_position): Make + sure we never position menus with negative x, y, + since gtk_widget_set_uposition() can't handle that. + + * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): + Modify the positioning code a bit so that we always + put the top-left corner onscreen. (This is for + UI reasons, gtk_menu_position() now takes care of + gtk_widet_set_uposition() brokeness.) + Fri Sep 3 16:04:41 1999 Tim Janik * gtk-config.in (--version): don't echo @GTK_VERSION@, but @@ -443,7 +457,6 @@ Sat Aug 21 14:07:36 1999 Lars Hamann show them instead. (Bug#1805 Reported by: Dave Cole ) ->>>>>>> 1.1061.2.110 Wed Aug 18 09:20:10 1999 Tim Janik * gtk/gtkwindow.c: @@ -500,7 +513,6 @@ Tue Aug 17 07:43:04 1999 Tim Janik function from gtk_tooltips_expose, as we connect to ::expose_event *and* ::draw now. ->>>>>>> 1.1061.2.104 1999-08-18 Federico Mena Quintero * gtk/gtkselection.c (gtk_target_list_ref): Added missing sanity diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 5eca4ecda..3e0e1cc8b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +Fri Sep 3 12:26:33 1999 Owen Taylor + + [ Fixes pointed out by Ettore Perazzoli ] + + * gtk/gtkmenu.c (gtk_menu_position): Make + sure we never position menus with negative x, y, + since gtk_widget_set_uposition() can't handle that. + + * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): + Modify the positioning code a bit so that we always + put the top-left corner onscreen. (This is for + UI reasons, gtk_menu_position() now takes care of + gtk_widet_set_uposition() brokeness.) + Fri Sep 3 16:04:41 1999 Tim Janik * gtk-config.in (--version): don't echo @GTK_VERSION@, but @@ -443,7 +457,6 @@ Sat Aug 21 14:07:36 1999 Lars Hamann show them instead. (Bug#1805 Reported by: Dave Cole ) ->>>>>>> 1.1061.2.110 Wed Aug 18 09:20:10 1999 Tim Janik * gtk/gtkwindow.c: @@ -500,7 +513,6 @@ Tue Aug 17 07:43:04 1999 Tim Janik function from gtk_tooltips_expose, as we connect to ::expose_event *and* ::draw now. ->>>>>>> 1.1061.2.104 1999-08-18 Federico Mena Quintero * gtk/gtkselection.c (gtk_target_list_ref): Added missing sanity diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 16d48eda1..15ac8813e 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -1180,22 +1180,17 @@ gtk_menu_position (GtkMenu *menu) screen_width = gdk_screen_width (); screen_height = gdk_screen_height (); - x -= 2; - y -= 2; - - if ((x + requisition.width) > screen_width) - x -= ((x + requisition.width) - screen_width); - if (x < 0) - x = 0; - if ((y + requisition.height) > screen_height) - y -= ((y + requisition.height) - screen_height); - if (y < 0) - y = 0; + x = CLAMP (x - 2, 0, MAX (0, screen_width - requisition.width)); + y = CLAMP (y - 2, 0, MAX (0, screen_height - requisition.height)); } - + + /* FIXME: The MAX() here is because gtk_widget_set_uposition + * is broken. Once we provide an alternate interface that + * allows negative values, then we can remove them. + */ gtk_widget_set_uposition (GTK_MENU_SHELL (menu)->active ? menu->toplevel : menu->tearoff_window, - x, y); + MAX (x, 0), MAX (y, 0)); } /* Reparent the menu, taking care of the refcounting diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index 58c92c6a8..263159c5a 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -709,12 +709,6 @@ gtk_menu_item_position_menu (GtkMenu *menu, else ty += GTK_WIDGET (menu_item)->allocation.height; - if ((tx + twidth) > screen_width) - { - tx -= ((tx + twidth) - screen_width); - if (tx < 0) - tx = 0; - } break; case GTK_LEFT_RIGHT: @@ -746,19 +740,16 @@ gtk_menu_item_position_menu (GtkMenu *menu, break; } - if ((ty + GTK_WIDGET (menu_item)->allocation.height / 4 + theight) <= screen_height) - ty += GTK_WIDGET (menu_item)->allocation.height / 4; - else - { - ty -= ((ty + theight) - screen_height); - if (ty < 0) - ty = 0; - } + ty += GTK_WIDGET (menu_item)->allocation.height / 4; + break; } - *x = tx; - *y = ty; + /* If we have negative, tx, ty here it is because we can't get + * the menu all the way on screen. Favor the upper-left portion. + */ + *x = CLAMP (tx, 0, MAX (0, screen_width - twidth)); + *y = CLAMP (ty, 0, MAX (0, screen_height - theight)); } void -- cgit v1.2.1