all repos — openbox @ 111465b7373cdcdd791b603aefd882ae06d5bf0b

openbox fork - make it a bit more like ryudo

Let menus place themselves on monitors where the mouse is not present

This fixes a bug which forced menus to show up on the same monitor as the
mouse pointer.
Dana Jansens danakj@orodu.net
commit

111465b7373cdcdd791b603aefd882ae06d5bf0b

parent

d55f4b41c6ebf00e36a5e91ddc962a753f6c9ef8

3 files changed, 15 insertions(+), 18 deletions(-)

jump to
M openbox/menuframe.copenbox/menuframe.c

@@ -192,6 +192,7 @@

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 @@ gint pos, half;

*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);

@@ -952,17 +953,6 @@ if (menu_frame_is_visible(self))

return TRUE; 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);
M openbox/screen.copenbox/screen.c

@@ -1719,15 +1719,19 @@ XDefineCursor(ob_display, RootWindow(ob_display, ob_screen),

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)
M openbox/screen.hopenbox/screen.h

@@ -134,6 +134,9 @@ monitor containing the greatest area of the rectangle is returned.

*/ 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();