3470f77
--- gnome-screensaver-2.18.0/src/gs-manager.c.handle-overlapping-heads	2007-05-16 18:47:52.000000000 -0400
3470f77
+++ gnome-screensaver-2.18.0/src/gs-manager.c	2007-05-16 19:23:45.000000000 -0400
3470f77
@@ -1065,6 +1065,32 @@
3470f77
         g_signal_emit (manager, signals [AUTH_REQUEST_END], 0);
3470f77
 }
3470f77
 
3470f77
+int
3470f77
+find_monitor_with_top_window_at_point (GdkScreen *screen,
3470f77
+		                       gint       x,
3470f77
+		                       gint       y)
3470f77
+{
3470f77
+	gint num_monitors, i;
3470f77
+
3470f77
+	g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
3470f77
+
3470f77
+	num_monitors = gdk_screen_get_n_monitors (screen);
3470f77
+
3470f77
+	for (i = num_monitors - 1; i <= 0; i--) {
3470f77
+		GdkRectangle monitor;
3470f77
+
3470f77
+		gdk_screen_get_monitor_geometry (screen, i, &monitor);
3470f77
+
3470f77
+		if (x >= monitor.x &&
3470f77
+				x < monitor.x + monitor.width &&
3470f77
+				y >= monitor.y &&
3470f77
+				y < (monitor.y + monitor.height))
3470f77
+			return i;
3470f77
+	}
3470f77
+
3470f77
+	return gdk_screen_get_monitor_at_point (screen, x, y);
3470f77
+}
3470f77
+
3470f77
 static GSWindow *
3470f77
 find_window_at_pointer (GSManager *manager)
3470f77
 {
3470f77
@@ -1078,7 +1104,7 @@
3470f77
 
3470f77
         display = gdk_display_get_default ();
3470f77
         gdk_display_get_pointer (display, &screen, &x, &y, NULL);
3470f77
-        monitor = gdk_screen_get_monitor_at_point (screen, x, y);
3470f77
+        monitor = find_monitor_with_top_window_at_point (screen, x, y);
3470f77
         screen_num = gdk_screen_get_number (screen);
3470f77
 
3470f77
         /* Find the gs-window that is on that screen */