From 3f2f73d410c84aa74ec109085e51e3338b6b532b Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 7 Jul 2007 02:54:22 +0000 Subject: Allows the popup to be displayed below as long as it can fit on the monitor the cursor is on rather than flipping up above the current point when near bottom of window. Implemented for GTK+ by John Ehresman. Partial Windows implementation #ifdefed out because it uses calls unavailable on Windows 95. --- gtk/PlatGTK.cxx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'gtk') diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 72e6eff83..4a7b2ed8d 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -1874,6 +1874,33 @@ void Window::SetTitle(const char *s) { gtk_window_set_title(GTK_WINDOW(id), s); } +/* Returns rectangle of monitor pt is on, both rect and pt are in Window's + gdk window coordinates */ +PRectangle Window::GetMonitorRect(Point pt) { + gint x_offset, y_offset; + + gdk_window_get_origin(PWidget(id)->window, &x_offset, &y_offset); + +// gtk 2.2+ +#if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 2) + { + GdkScreen* screen; + gint monitor_num; + GdkRectangle rect; + + screen = gtk_widget_get_screen(PWidget(id)); + monitor_num = gdk_screen_get_monitor_at_point(screen, pt.x + x_offset, pt.y + y_offset); + gdk_screen_get_monitor_geometry(screen, monitor_num, &rect); + rect.x -= x_offset; + rect.y -= y_offset; + return PRectangle(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); + } +#else + return PRectangle(-x_offset, -y_offset, (-x_offset) + gdk_screen_width(), + (-y_offset) + gdk_screen_height()); +#endif +} + struct ListImage { const char *xpm_data; #if GTK_MAJOR_VERSION < 2 -- cgit v1.2.3