]> Pileus Git - ~andy/gtk/commitdiff
Handle the case where the pointer isn't on the same screen as the widget
authorOwen Taylor <otaylor@redhat.com>
Sat, 14 Dec 2002 06:05:00 +0000 (06:05 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sat, 14 Dec 2002 06:05:00 +0000 (06:05 +0000)
Sat Dec 14 01:00:12 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkmenu.c (gtk_menu_position): Handle the case
        where the pointer isn't on the same screen as the widget
        by centering the menu on the widget's screen. (#94563)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkmenu.c

index f197a66b4c3767ebdfc3792bc28e9b154e5542ae..38ee76787f475838a073e84591f60801523b5077 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Sat Dec 14 01:00:12 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (gtk_menu_position): Handle the case
+       where the pointer isn't on the same screen as the widget
+       by centering the menu on the widget's screen. (#94563)
+
+Fri Dec 13 23:58:06 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_point)
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_window): 
+       Provide a useful fallback on failure - return a monitor
+       close to the point or window. (#79991)
+
+       * gtk/gtkmenu.c (gtk_menu_position): Remove a now
+       unneeded check for failure of 
+       gdk_screen_get_monitor_at_point()
+
 Fri Dec 13 23:10:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkclist.c: Fix a problem with the focus row
index f197a66b4c3767ebdfc3792bc28e9b154e5542ae..38ee76787f475838a073e84591f60801523b5077 100644 (file)
@@ -1,3 +1,20 @@
+Sat Dec 14 01:00:12 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (gtk_menu_position): Handle the case
+       where the pointer isn't on the same screen as the widget
+       by centering the menu on the widget's screen. (#94563)
+
+Fri Dec 13 23:58:06 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_point)
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_window): 
+       Provide a useful fallback on failure - return a monitor
+       close to the point or window. (#79991)
+
+       * gtk/gtkmenu.c (gtk_menu_position): Remove a now
+       unneeded check for failure of 
+       gdk_screen_get_monitor_at_point()
+
 Fri Dec 13 23:10:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkclist.c: Fix a problem with the focus row
index f197a66b4c3767ebdfc3792bc28e9b154e5542ae..38ee76787f475838a073e84591f60801523b5077 100644 (file)
@@ -1,3 +1,20 @@
+Sat Dec 14 01:00:12 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (gtk_menu_position): Handle the case
+       where the pointer isn't on the same screen as the widget
+       by centering the menu on the widget's screen. (#94563)
+
+Fri Dec 13 23:58:06 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_point)
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_window): 
+       Provide a useful fallback on failure - return a monitor
+       close to the point or window. (#79991)
+
+       * gtk/gtkmenu.c (gtk_menu_position): Remove a now
+       unneeded check for failure of 
+       gdk_screen_get_monitor_at_point()
+
 Fri Dec 13 23:10:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkclist.c: Fix a problem with the focus row
index f197a66b4c3767ebdfc3792bc28e9b154e5542ae..38ee76787f475838a073e84591f60801523b5077 100644 (file)
@@ -1,3 +1,20 @@
+Sat Dec 14 01:00:12 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (gtk_menu_position): Handle the case
+       where the pointer isn't on the same screen as the widget
+       by centering the menu on the widget's screen. (#94563)
+
+Fri Dec 13 23:58:06 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_point)
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_window): 
+       Provide a useful fallback on failure - return a monitor
+       close to the point or window. (#79991)
+
+       * gtk/gtkmenu.c (gtk_menu_position): Remove a now
+       unneeded check for failure of 
+       gdk_screen_get_monitor_at_point()
+
 Fri Dec 13 23:10:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkclist.c: Fix a problem with the focus row
index f197a66b4c3767ebdfc3792bc28e9b154e5542ae..38ee76787f475838a073e84591f60801523b5077 100644 (file)
@@ -1,3 +1,20 @@
+Sat Dec 14 01:00:12 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (gtk_menu_position): Handle the case
+       where the pointer isn't on the same screen as the widget
+       by centering the menu on the widget's screen. (#94563)
+
+Fri Dec 13 23:58:06 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_point)
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_window): 
+       Provide a useful fallback on failure - return a monitor
+       close to the point or window. (#79991)
+
+       * gtk/gtkmenu.c (gtk_menu_position): Remove a now
+       unneeded check for failure of 
+       gdk_screen_get_monitor_at_point()
+
 Fri Dec 13 23:10:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkclist.c: Fix a problem with the focus row
index f197a66b4c3767ebdfc3792bc28e9b154e5542ae..38ee76787f475838a073e84591f60801523b5077 100644 (file)
@@ -1,3 +1,20 @@
+Sat Dec 14 01:00:12 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkmenu.c (gtk_menu_position): Handle the case
+       where the pointer isn't on the same screen as the widget
+       by centering the menu on the widget's screen. (#94563)
+
+Fri Dec 13 23:58:06 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_point)
+       * gdk/gdkscreen.c (gdk_screen_get_monitor_at_window): 
+       Provide a useful fallback on failure - return a monitor
+       close to the point or window. (#79991)
+
+       * gtk/gtkmenu.c (gtk_menu_position): Remove a now
+       unneeded check for failure of 
+       gdk_screen_get_monitor_at_point()
+
 Fri Dec 13 23:10:21 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkclist.c: Fix a problem with the focus row
index 0af02b613c96d740d786690883671ddbd1d2ddd9..3a3cf67e5f96bdd47584ca64881562793cc25bbd 100644 (file)
@@ -2595,6 +2595,7 @@ gtk_menu_position (GtkMenu *menu)
   gint menu_height;
   gboolean push_in;
   GdkScreen *screen;
+  GdkScreen *pointer_screen;
   GdkRectangle monitor;
   gint monitor_num;
 
@@ -2602,12 +2603,9 @@ gtk_menu_position (GtkMenu *menu)
 
   widget = GTK_WIDGET (menu);
 
-  gdk_window_get_pointer (gtk_widget_get_root_window (widget),
-                         &x, &y, NULL);
-
   screen = gtk_widget_get_screen (widget);
-  monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
-  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+  gdk_display_get_pointer (gdk_screen_get_display (screen),
+                          &pointer_screen, &x, &y, NULL);
 
   /* We need the requisition to figure out the right place to
    * popup the menu. In fact, we always need to ask here, since
@@ -2616,6 +2614,20 @@ gtk_menu_position (GtkMenu *menu)
    */
   gtk_widget_size_request (widget, &requisition);
 
+  if (pointer_screen != screen)
+    {
+      /* Pointer is on a different screen; roughly center the
+       * menu on the screen. If someone was using multiscreen
+       * + Xinerama together they'd probably want something
+       * fancier; but that is likely to be vanishingly rare.
+       */
+      x = MAX (0, (gdk_screen_get_width (screen) - requisition.width) / 2);
+      y = MAX (0, (gdk_screen_get_height (screen) - requisition.height) / 2);
+    }
+
+  monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
+  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
   push_in = FALSE;
   
   if (menu->position_func)