From 79e1bb53d371c83cf68d8290986c31d2421afa34 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Fri, 2 Apr 2010 13:31:31 -0400 Subject: [PATCH] Menu positioning bug I noticed a bug today in menu workspace positioning (in the next tree): if I right-click and hold the button down at the left edge of the screen, the menu appears (correctly) half off the edge but will *not* slide back onto the screen. Compare the behavior to right-clicking at the right edge of the screen: the menu appears half off the edge, but sliding the mouse to the edge causes the menu to slide until it is fully visible. Also, opening a submenu in this state positions the submenu as if the menu were fully on the screen, leaving a gap between the menu and the submenu. If the menu happens to also go off the bottom of the screen, moving the mouse to the bottom edge causes the issue to be magically fixed as soon as the sliding upwards begins. I also note inconsistent behavior when simply right-clicking (without holding) to bring up the menu: at the right or bottom edge the menu appears in the correct partially off the edge position, but at the left edge it immediately jumps to be fully on-screen, almost as if WrapMenus = YES were set for the left edge only. I bisected it to d3162603952a8a00cdafe390791e4e99d2118dc1. As far as I can tell the "fix" there was to position the menu at the correct negative X position but then lie to wmaker so it thought the menu was at X=0. Presumably the "WrapMenus" behavior was the intended result. Since (AFAIK) the window menu is the only one with this problem, why don't we just check if x is too negative in OpenWindowMenu()? --- src/menu.c | 4 ++-- src/winmenu.c | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/menu.c b/src/menu.c index 2e75b7fb..e6eff2ab 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1078,8 +1078,8 @@ void wMenuMapAt(WMenu * menu, int x, int y, int keyboard) } XMoveWindow(dpy, menu->frame->core->window, x, y); - menu->frame_x = (x < 0) ? 0 : x; - menu->frame_y = (y < 0) ? 0 : y; + menu->frame_x = x; + menu->frame_y = y; XMapWindow(dpy, menu->frame->core->window); wRaiseFrame(menu->frame->core); menu->flags.mapped = 1; diff --git a/src/winmenu.c b/src/winmenu.c index 45d3593e..4ad0fa8b 100644 --- a/src/winmenu.c +++ b/src/winmenu.c @@ -44,6 +44,7 @@ #include "dialog.h" #include "stacking.h" #include "icon.h" +#include "xinerama.h" #define MC_MAXIMIZE 0 #define MC_MINIATURIZE 1 @@ -589,6 +590,7 @@ void OpenWindowMenu(WWindow * wwin, int x, int y, int keyboard) { WMenu *menu; WScreen *scr = wwin->screen_ptr; + WMRect rect; wwin->flags.menu_open_for_me = 1; @@ -619,6 +621,13 @@ void OpenWindowMenu(WWindow * wwin, int x, int y, int keyboard) if (x < wwin->frame_x) x = wwin->frame_x; + rect = wGetRectForHead(menu->frame->screen_ptr, + wGetHeadForPointerLocation(menu->frame->screen_ptr)); + if (x < rect.pos.x - menu->frame->core->width / 2) + x = rect.pos.x - menu->frame->core->width / 2; + if (y < rect.pos.y) + y = rect.pos.y; + if (!wwin->flags.internal_window) wMenuMapAt(menu, x, y, keyboard); } -- 2.11.4.GIT