diff options
author | nyamatongwe <unknown> | 2002-08-23 02:44:33 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2002-08-23 02:44:33 +0000 |
commit | c961d3de76d36bc0a39147a04ff645d5cb4e4e66 (patch) | |
tree | c062f52682c4af96cf9547e899b42e67eaed796c | |
parent | 377966e649fa3bc55fc594e6e4aaca37b0ff6fa6 (diff) | |
download | scintilla-mirror-c961d3de76d36bc0a39147a04ff645d5cb4e4e66.tar.gz |
Ensure popup menu is fully visible and does not overlap screen right or bottom.
-rw-r--r-- | gtk/PlatGTK.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
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<GtkItemFactory *>(id), pt.x - 4, pt.y, 3, 0); + int screenHeight = gdk_screen_height(); + int screenWidth = gdk_screen_width(); + GtkItemFactory *factory = reinterpret_cast<GtkItemFactory *>(id); + GtkWidget *widget = gtk_item_factory_get_widget(factory, "<main>"); + 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() { |