From c961d3de76d36bc0a39147a04ff645d5cb4e4e66 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 23 Aug 2002 02:44:33 +0000 Subject: Ensure popup menu is fully visible and does not overlap screen right or bottom. --- gtk/PlatGTK.cxx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'gtk') diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 5e6bdf48c..2edae58c7 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -907,7 +907,20 @@ void Menu::Destroy() { } void Menu::Show(Point pt, Window &) { - gtk_item_factory_popup(reinterpret_cast(id), pt.x - 4, pt.y, 3, 0); + int screenHeight = gdk_screen_height(); + int screenWidth = gdk_screen_width(); + GtkItemFactory *factory = reinterpret_cast(id); + GtkWidget *widget = gtk_item_factory_get_widget(factory, "
"); + gtk_widget_show_all(widget); + GtkRequisition requisition; + gtk_widget_size_request(widget, &requisition); + if ((pt.x + requisition.width) > screenWidth) { + pt.x = screenWidth - requisition.width; + } + if ((pt.y + requisition.height) > screenHeight) { + pt.y = screenHeight - requisition.height; + } + gtk_item_factory_popup(factory, pt.x - 4, pt.y, 3, 0); } ElapsedTime::ElapsedTime() { -- cgit v1.2.3