X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmswin%2Ffg_main_mswin.c;h=d336f5e8dcbf75f9668b7d2170fb249a981d94ff;hb=9a83e1923241a52132e87f333184433067456097;hp=7f33ac180db598133adcbe9a38e55a954eb82497;hpb=3b8c74a07a7e9de271191dca77ff475d50499c04;p=freeglut diff --git a/src/mswin/fg_main_mswin.c b/src/mswin/fg_main_mswin.c index 7f33ac1..d336f5e 100644 --- a/src/mswin/fg_main_mswin.c +++ b/src/mswin/fg_main_mswin.c @@ -170,7 +170,7 @@ static int fgPlatformGetModifiers (void) ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 ); } -static void fghKeyPress(SFG_Window *window, GLboolean keydown, WPARAM wParam, LPARAM lParam) +static LRESULT fghWindowProcKeyPress(SFG_Window *window, UINT uMsg, GLboolean keydown, WPARAM wParam, LPARAM lParam) { static unsigned char lControl = 0, lShift = 0, lAlt = 0, rControl = 0, rShift = 0, rAlt = 0; @@ -180,7 +180,7 @@ static void fghKeyPress(SFG_Window *window, GLboolean keydown, WPARAM wParam, LP /* if keydown, check for repeat */ if( keydown && ( fgState.KeyRepeat==GLUT_KEY_REPEAT_OFF || window->State.IgnoreKeyRepeat==GL_TRUE ) && (HIWORD(lParam) & KF_REPEAT) ) - return; + return 1; /* Remember the current modifiers state so user can query it from their callback */ fgState.Modifiers = fgPlatformGetModifiers( ); @@ -315,6 +315,39 @@ static void fghKeyPress(SFG_Window *window, GLboolean keydown, WPARAM wParam, LP ); fgState.Modifiers = INVALID_MODIFIERS; + + /* SYSKEY events should be sent to default window proc for system to handle them */ + if (uMsg==WM_SYSKEYDOWN || uMsg==WM_SYSKEYUP) + return DefWindowProc( window->Window.Handle, uMsg, wParam, lParam ); + else + return 1; +} + +void fghWindowUnderCursor(SFG_Window *window, SFG_Window **child_window) +{ + /* Check if the current window that the mouse is over is a child window + * of the window the message was sent to. + */ + if (window && window->Children.First) + { + POINT mouse_pos; + SFG_WindowHandleType hwnd; + SFG_Window* temp_window; + + GetCursorPos( &mouse_pos ); + ScreenToClient( window->Window.Handle, &mouse_pos ); + hwnd = ChildWindowFromPoint(window->Window.Handle, mouse_pos); + if (hwnd && hwnd!=window->Window.Handle) /* can be NULL if mouse outside parent by the time we get here, or can be same as parent if we didn't find a child */ + { + temp_window = fgWindowByHandle(hwnd); + if (temp_window) /* Verify we got a FreeGLUT window */ + { + *child_window = temp_window; + /* ChildWindowFromPoint only searches immediate children, so search again to see if actually in grandchild or further descendant */ + fghWindowUnderCursor(temp_window,child_window); + } + } + } } /* @@ -341,22 +374,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR * we make sure that we process callbacks on the child window instead. * This mirrors how GLUT does things. */ - if (window && window->Children.First) - { - POINT mouse_pos; - SFG_WindowHandleType hwnd; - SFG_Window* temp_window; - - GetCursorPos( &mouse_pos ); - ScreenToClient( window->Window.Handle, &mouse_pos ); - hwnd = ChildWindowFromPoint(window->Window.Handle, mouse_pos); - if (hwnd) /* can be NULL if mouse outside parent by the time we get here */ - { - temp_window = fgWindowByHandle(hwnd); - if (temp_window && temp_window->Parent) /* Verify we got a child window */ - child_window = temp_window; - } - } + fghWindowUnderCursor(window, &child_window); switch( uMsg ) { @@ -787,14 +805,14 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR case WM_KEYDOWN: if (child_window) window = child_window; - fghKeyPress(window,GL_TRUE,wParam,lParam); + lRet = fghWindowProcKeyPress(window,uMsg,GL_TRUE,wParam,lParam); break; case WM_SYSKEYUP: case WM_KEYUP: if (child_window) window = child_window; - fghKeyPress(window,GL_FALSE,wParam,lParam); + lRet = fghWindowProcKeyPress(window,uMsg,GL_FALSE,wParam,lParam); break; case WM_SYSCHAR: