]> Dogcows Code - chaz/openbox/commitdiff
Let menus place themselves on monitors where the mouse is not present
authorDana Jansens <danakj@orodu.net>
Mon, 14 Dec 2009 21:08:30 +0000 (16:08 -0500)
committerDana Jansens <danakj@orodu.net>
Mon, 14 Dec 2009 21:08:30 +0000 (16:08 -0500)
This fixes a bug which forced menus to show up on the same monitor as the
mouse pointer.

openbox/menuframe.c
openbox/screen.c
openbox/screen.h

index a9b544081fb110a88f9da17ce17c6ada88c2640f..3b53a63ea8328052bc03e0818dbb99cf07727d43 100644 (file)
@@ -192,6 +192,7 @@ static void menu_entry_frame_free(ObMenuEntryFrame *self)
 void menu_frame_move(ObMenuFrame *self, gint x, gint y)
 {
     RECT_SET_POINT(self->area, x, y);
+    self->monitor = screen_find_monitor_point(x, y);
     XMoveWindow(ob_display, self->window, self->area.x, self->area.y);
 }
 
@@ -294,7 +295,7 @@ void menu_frame_move_on_screen(ObMenuFrame *self, gint x, gint y,
 
     *dx = *dy = 0;
 
-    a = screen_physical_area_monitor(self->monitor);
+    a = screen_physical_area_monitor(screen_find_monitor_point(x, y));
 
     half = g_list_length(self->entries) / 2;
     pos = g_list_index(self->entries, self->selected);
@@ -953,17 +954,6 @@ gboolean menu_frame_show_topmenu(ObMenuFrame *self, gint x, gint y,
     if (!menu_frame_show(self))
         return FALSE;
 
-    /* find the monitor the menu is on */
-    for (i = 0; i < screen_num_monitors; ++i) {
-        Rect *a = screen_physical_area_monitor(i);
-        gboolean contains = RECT_CONTAINS(*a, x, y);
-        g_free(a);
-        if (contains) {
-            self->monitor = i;
-            break;
-        }
-    }
-
     if (self->menu->place_func)
         self->menu->place_func(self, &x, &y, mouse, self->menu->data);
     else
index 8d0460d570a7a70daecaefa9bc7dc35956c9735c..35c9f5433b8bfbd702c7f1a6ced89588c25156d2 100644 (file)
@@ -1719,17 +1719,21 @@ void screen_set_root_cursor(void)
                       ob_cursor(OB_CURSOR_POINTER));
 }
 
-guint screen_monitor_pointer()
+guint screen_find_monitor_point(guint x, guint y)
 {
     Rect mon;
-    gint x, y;
-    if (screen_pointer_pos(&x, &y))
-        RECT_SET(mon, x, y, 1, 1);
-    else
-        RECT_SET(mon, 0, 0, 1, 1);
+    RECT_SET(mon, x, y, 1, 1);
     return screen_find_monitor(&mon);
 }
 
+guint screen_monitor_pointer()
+{
+    gint x, y;
+    if (!screen_pointer_pos(&x, &y))
+        x = y = 0;
+    return screen_find_monitor_point(x, y);
+}
+
 gboolean screen_pointer_pos(gint *x, gint *y)
 {
     Window w;
index 7df47f396fca396f3094ad595d1c52e4e236416f..4a8d8a1e141868479c07fe3c3ef69a1b4c7952b2 100644 (file)
@@ -134,6 +134,9 @@ gboolean screen_physical_area_monitor_contains(guint head, Rect *search);
 */
 guint screen_find_monitor(Rect *search);
 
+/*! Finds the monitor which contains the point @x, @y */
+guint screen_find_monitor_point(guint x, guint y);
+
 /*! Sets the root cursor. This function decides which cursor to use, but you
   gotta call it to let it know it should change. */
 void screen_set_root_cursor();
This page took 0.027212 seconds and 4 git commands to generate.