X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_menu.c;h=bb04f4813a93a21f7f0af95f003994ba46804685;hb=6f5c26d4ca8c520af1905fd23cd157cf37ee1ace;hp=3894b42a9a118aa0b824d2cf06c22dc6cc1ef85e;hpb=78d46c63a115e0a868d83f365399864b62a4ea7f;p=freeglut diff --git a/src/freeglut_menu.c b/src/freeglut_menu.c index 3894b42..bb04f48 100644 --- a/src/freeglut_menu.c +++ b/src/freeglut_menu.c @@ -134,6 +134,37 @@ static void fghDeactivateSubMenu( SFG_MenuEntry *menuEntry ) } /* + * Private function to get the virtual maximum screen extent + */ +static GLvoid fghGetVMaxExtent( SFG_Window* window, int* x, int* y ) +{ + if( fgStructure.GameMode ) + { +#if TARGET_HOST_UNIX_X11 + int wx, wy; + Window w; + + XTranslateCoordinates( + fgDisplay.Display, + window->Window.Handle, + fgDisplay.RootWindow, + 0, 0, &wx, &wy, &w); + + *x = fgState.GameModeSize.X + wx; + *y = fgState.GameModeSize.Y + wy; +#else + *x = glutGet ( GLUT_SCREEN_WIDTH ); + *y = glutGet ( GLUT_SCREEN_HEIGHT ); +#endif + } + else + { + *x = fgDisplay.ScreenWidth; + *y = fgDisplay.ScreenHeight; + } +} + +/* * Private function to check for the current menu/sub menu activity state */ static GLboolean fghCheckMenuStatus( SFG_Window* window, SFG_Menu* menu ) @@ -215,23 +246,22 @@ static GLboolean fghCheckMenuStatus( SFG_Window* window, SFG_Menu* menu ) { if ( ! menuEntry->SubMenu->IsActive ) { + int max_x, max_y; SFG_Window *current_window = fgStructure.CurrentWindow; /* Set up the initial menu position now... */ menuEntry->SubMenu->IsActive = GL_TRUE; /* Set up the initial submenu position now: */ + fghGetVMaxExtent(menu->ParentWindow, &max_x, &max_y); menuEntry->SubMenu->X = menu->X + menu->Width; menuEntry->SubMenu->Y = menu->Y + menuEntry->Ordinal * FREEGLUT_MENU_HEIGHT; - if( menuEntry->SubMenu->X + menuEntry->SubMenu->Width > - glutGet( GLUT_SCREEN_WIDTH ) ) - menuEntry->SubMenu->X = menu->X - - menuEntry->SubMenu->Width; + if( menuEntry->SubMenu->X + menuEntry->SubMenu->Width > max_x ) + menuEntry->SubMenu->X = menu->X - menuEntry->SubMenu->Width; - if( menuEntry->SubMenu->Y + menuEntry->SubMenu->Height > - glutGet( GLUT_SCREEN_HEIGHT ) ) + if( menuEntry->SubMenu->Y + menuEntry->SubMenu->Height > max_y ) menuEntry->SubMenu->Y -= ( menuEntry->SubMenu->Height - FREEGLUT_MENU_HEIGHT - 2 * FREEGLUT_MENU_BORDER ); @@ -493,6 +523,8 @@ void fgDisplayMenu( void ) */ static void fghActivateMenu( SFG_Window* window, int button ) { + int max_x, max_y; + /* We'll be referencing this menu a lot, so remember its address: */ SFG_Menu* menu = window->Menu[ button ]; @@ -507,13 +539,14 @@ static void fghActivateMenu( SFG_Window* window, int button ) fgState.ActiveMenus++; /* Set up the initial menu position now: */ + fghGetVMaxExtent(menu->ParentWindow, &max_x, &max_y); menu->X = window->State.MouseX + glutGet( GLUT_WINDOW_X ); menu->Y = window->State.MouseY + glutGet( GLUT_WINDOW_Y ); - if( menu->X + menu->Width > glutGet ( GLUT_SCREEN_WIDTH ) ) + if( menu->X + menu->Width > max_x ) menu->X -=menu->Width; - if( menu->Y + menu->Height > glutGet ( GLUT_SCREEN_HEIGHT ) ) + if( menu->Y + menu->Height > max_y ) menu->Y -=menu->Height; fgSetWindow( menu->Window );