X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffg_menu.c;h=853c1b451509b84d14f5b3d3defa6b6720b1ca7f;hb=4a451851ec51ea7c3b79534fa5faebadceedf4df;hp=e60a5f88615de81275f6f5f73f0c1fc235292faf;hpb=378de1f7693a73536400c7de8889d8b6bec1641f;p=freeglut diff --git a/src/fg_menu.c b/src/fg_menu.c index e60a5f8..853c1b4 100644 --- a/src/fg_menu.c +++ b/src/fg_menu.c @@ -76,7 +76,7 @@ static float menu_pen_hback [4] = FREEGLUT_MENU_PEN_HBACK_COLORS; extern GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y ); -extern void fghPlatformGetCursorPos(SFG_XYUse *mouse_pos); +extern void fghPlatformGetCursorPos(const SFG_Window *window, GLboolean client, SFG_XYUse *mouse_pos); /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */ @@ -534,7 +534,7 @@ static void fghActivateMenu( SFG_Window* window, int button ) * origin when looking at a child window * for parent windows: window->State.MouseX + glutGet( GLUT_WINDOW_X ) == mouse_pos.X */ - fghPlatformGetCursorPos(&mouse_pos); + fghPlatformGetCursorPos(NULL, GL_FALSE, &mouse_pos); menu->X = mouse_pos.X; menu->Y = mouse_pos.Y; @@ -667,10 +667,18 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed, ( window->Menu[ button ] ) && pressed ) { - /* XXX Posting a requisite Redisplay seems bogus. */ - window->State.Redisplay = GL_TRUE; - fghActivateMenu( window, button ); - return GL_TRUE; + /* If mouseclick was outside the parent window, ignore. This can + * happen when another mouse button is already depressed and the + * window thus has mouse capture + */ + if (window->State.MouseX>0 && window->State.MouseY>0 && + window->State.MouseXState.Width && window->State.MouseXState.Height) + { + /* XXX Posting a requisite Redisplay seems bogus. */ + window->State.Redisplay = GL_TRUE; + fghActivateMenu( window, button ); + return GL_TRUE; + } } return GL_FALSE; @@ -736,12 +744,9 @@ void fgDeactivateMenu( SFG_Window *window ) fgState.MenuStateCallback(GLUT_MENU_NOT_IN_USE); if (fgState.MenuStatusCallback) { - /* Get cursor position on screen and convert to relative to parent_window's client area */ + /* Get cursor position relative to parent_window's client area */ SFG_XYUse mouse_pos; - fghPlatformGetCursorPos(&mouse_pos); - - mouse_pos.X -= glutGet( GLUT_WINDOW_X ); - mouse_pos.Y -= glutGet( GLUT_WINDOW_Y ); + fghPlatformGetCursorPos(parent_window, GL_TRUE, &mouse_pos); fgState.MenuStatusCallback(GLUT_MENU_NOT_IN_USE, mouse_pos.X, mouse_pos.Y); }