]> Pileus Git - ~andy/gtk/commitdiff
Made Xinerama-aware. (#85711)
authorMatthias Clasen <maclas@gmx.de>
Sat, 14 Dec 2002 22:50:38 +0000 (22:50 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sat, 14 Dec 2002 22:50:38 +0000 (22:50 +0000)
2002-12-14  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Made
Xinerama-aware.  (#85711)

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

index 3f831f76e38433b484a11216c5dff874eadf16d8..f6a8aa5a2c65ecd46c7909e18c2b59f5d44a3445 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2002-12-14  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Made
+       Xinerama-aware.  (#85711)
+
 Sat Dec 14 14:19:16 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c: Add a new binding signal, "move_scroll",
index 3f831f76e38433b484a11216c5dff874eadf16d8..f6a8aa5a2c65ecd46c7909e18c2b59f5d44a3445 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-14  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Made
+       Xinerama-aware.  (#85711)
+
 Sat Dec 14 14:19:16 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c: Add a new binding signal, "move_scroll",
index 3f831f76e38433b484a11216c5dff874eadf16d8..f6a8aa5a2c65ecd46c7909e18c2b59f5d44a3445 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-14  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Made
+       Xinerama-aware.  (#85711)
+
 Sat Dec 14 14:19:16 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c: Add a new binding signal, "move_scroll",
index 3f831f76e38433b484a11216c5dff874eadf16d8..f6a8aa5a2c65ecd46c7909e18c2b59f5d44a3445 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-14  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Made
+       Xinerama-aware.  (#85711)
+
 Sat Dec 14 14:19:16 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c: Add a new binding signal, "move_scroll",
index 3f831f76e38433b484a11216c5dff874eadf16d8..f6a8aa5a2c65ecd46c7909e18c2b59f5d44a3445 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-14  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Made
+       Xinerama-aware.  (#85711)
+
 Sat Dec 14 14:19:16 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c: Add a new binding signal, "move_scroll",
index 3f831f76e38433b484a11216c5dff874eadf16d8..f6a8aa5a2c65ecd46c7909e18c2b59f5d44a3445 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-14  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Made
+       Xinerama-aware.  (#85711)
+
 Sat Dec 14 14:19:16 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c: Add a new binding signal, "move_scroll",
index 9e774940b4679249f2330b54953f42043c6b6e4a..a1910bab294f42e73f888af515e65f3eb11b1ddd 100644 (file)
@@ -922,11 +922,11 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
   GtkWidget *widget;
   GtkWidget *parent_menu_item;
   GdkScreen *screen;
-  gint screen_width;
-  gint screen_height;
   gint twidth, theight;
   gint tx, ty;
   GtkTextDirection direction;
+  GdkRectangle monitor;
+  gint monitor_num;
 
   g_return_if_fail (menu != NULL);
   g_return_if_fail (x != NULL);
@@ -941,8 +941,10 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
   theight = GTK_WIDGET (menu)->requisition.height;
 
   screen = gtk_widget_get_screen (widget);
-  screen_width = gdk_screen_get_width (screen);
-  screen_height = gdk_screen_get_height (screen);
+  monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
+  if (monitor_num < 0)
+    monitor_num = 0;
+  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
 
   if (!gdk_window_get_origin (widget->window, &tx, &ty))
     {
@@ -964,11 +966,11 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
          tx += widget->allocation.width - twidth;
        }
 
-      if ((ty + widget->allocation.height + theight) <= screen_height)
+      if ((ty + widget->allocation.height + theight) <= monitor.y + monitor.height)
        ty += widget->allocation.height;
-      else if ((ty - theight) >= 0)
+      else if ((ty - theight) >= monitor.y)
        ty -= theight;
-      else if (screen_height - (ty + widget->allocation.height) > ty)
+      else if (monitor.y + monitor.height - (ty + widget->allocation.height) > ty)
        ty += widget->allocation.height;
       else
        ty -= theight;
@@ -988,7 +990,7 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
       switch (menu_item->submenu_direction)
        {
        case GTK_DIRECTION_LEFT:
-         if ((tx - twidth) >= 0)
+         if ((tx - twidth) >= monitor.x)
            tx -= twidth;
          else
            {
@@ -998,7 +1000,7 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
          break;
 
        case GTK_DIRECTION_RIGHT:
-         if ((tx + widget->allocation.width + twidth - 5) <= screen_width)
+         if ((tx + widget->allocation.width + twidth - 5) <= monitor.x + monitor.width)
            tx += widget->allocation.width - 5;
          else
            {
@@ -1011,14 +1013,14 @@ gtk_menu_item_position_menu (GtkMenu  *menu,
       ty += widget->allocation.height / 4;
 
       /* If the height of the menu doesn't fit we move it upward. */
-      ty = CLAMP (ty, 0, MAX (0, screen_height - theight));
+      ty = CLAMP (ty, monitor.y, MAX (monitor.y, monitor.y + monitor.height - theight));
       break;
     }
 
   /* If we have negative, tx, here it is because we can't get
    * the menu all the way on screen. Favor the left portion.
    */
-  *x = CLAMP (tx, 0, MAX (0, screen_width - twidth));
+  *x = CLAMP (tx, monitor.x, MAX (monitor.x, monitor.x + monitor.width - twidth));
   *y = ty;
 }