X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=inline;f=src%2Fmswin%2Ffg_main_mswin.c;h=daa8fdc25004740bacc81805b4858a9c42fb4384;hb=cc8230fde8220aeab13bbc2457cb32c0fcc19d5e;hp=4052bcd06ae1edeb4d585ee710488788bded55eb;hpb=21e64055d922c8ba69b1956b892db2d8cd35de74;p=freeglut diff --git a/src/mswin/fg_main_mswin.c b/src/mswin/fg_main_mswin.c index 4052bcd..daa8fdc 100644 --- a/src/mswin/fg_main_mswin.c +++ b/src/mswin/fg_main_mswin.c @@ -179,6 +179,11 @@ static LRESULT fghWindowProcKeyPress(SFG_Window *window, UINT uMsg, GLboolean ke POINT mouse_pos ; /* if keydown, check for repeat */ + /* If repeat is globally switched off, it cannot be switched back on per window. + * But if it is globally switched on, it can be switched off per window. This matches + * GLUT's behavior on X11, but not Nate Robbins' win32 GLUT, as he didn't implement the + * global state switch. + */ if( keydown && ( fgState.KeyRepeat==GLUT_KEY_REPEAT_OFF || window->State.IgnoreKeyRepeat==GL_TRUE ) && (HIWORD(lParam) & KF_REPEAT) ) return 1; @@ -323,6 +328,33 @@ static LRESULT fghWindowProcKeyPress(SFG_Window *window, UINT uMsg, GLboolean ke 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); + } + } + } +} + /* * The window procedure for handling Win32 events */ @@ -347,22 +379,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 ) {