From b362113e1f4e9a76ecaab4791368cda7eb4ee11f Mon Sep 17 00:00:00 2001 From: dcnieho Date: Wed, 27 Feb 2013 08:06:24 +0000 Subject: [PATCH] Only do mouse tracking for EntryFunc if user specified an entryfunc git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1521 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/src/mswin/fg_main_mswin.c | 26 +++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/freeglut/freeglut/src/mswin/fg_main_mswin.c b/freeglut/freeglut/src/mswin/fg_main_mswin.c index daa611c..d304169 100644 --- a/freeglut/freeglut/src/mswin/fg_main_mswin.c +++ b/freeglut/freeglut/src/mswin/fg_main_mswin.c @@ -554,16 +554,24 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR { TRACKMOUSEEVENT tme; - /* Cursor just entered window, set cursor look, invoke callback and start tracking so that we get a WM_MOUSELEAVE message */ + /* Cursor just entered window, set cursor look */ fgSetCursor ( window, window->State.Cursor ) ; - INVOKE_WCB( *window, Entry, ( GLUT_ENTERED ) ); - tme.cbSize = sizeof(TRACKMOUSEEVENT); - tme.dwFlags = TME_LEAVE; - tme.hwndTrack = window->Window.Handle; - TrackMouseEvent(&tme); + /* If an EntryFunc callback is specified by the user, also + * invoke that callback and start mouse tracking so that + * we get a WM_MOUSELEAVE message + */ + if (FETCH_WCB( *window, Entry )) + { + INVOKE_WCB( *window, Entry, ( GLUT_ENTERED ) ); - window->State.pWState.MouseTracking = GL_TRUE; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = window->Window.Handle; + TrackMouseEvent(&tme); + + window->State.pWState.MouseTracking = GL_TRUE; + } } } else @@ -573,6 +581,10 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR case WM_MOUSELEAVE: { + /* NB: This message is only received when a EntryFunc callback + * is specified by the user, as that is the only condition under + * which mouse tracking is setup in WM_SETCURSOR handler above + */ SFG_Window* saved_window = fgStructure.CurrentWindow; INVOKE_WCB( *window, Entry, ( GLUT_LEFT ) ); fgSetWindow(saved_window);