now handling WM_MOUSEACTIVATE so that menus don't get activated upon mouseclick
[freeglut] / src / mswin / fg_main_mswin.c
index ad80055..a35bfca 100644 (file)
@@ -296,7 +296,7 @@ static LRESULT fghWindowProcKeyPress(SFG_Window *window, UINT uMsg, GLboolean ke
                 wParam=code[ 0 ];
 
             INVOKE_WCB( *window, KeyboardUp,
-                   ( (char)wParam,
+                   ( (char)(wParam & 0xFF), /* and with 0xFF to indicate to runtime that we want to strip out higher bits - otherwise we get a runtime error when "Smaller Type Checks" is enabled */
                         window->State.MouseX, window->State.MouseY )
             );
         }
@@ -589,9 +589,20 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
         fgPlatformCheckMenuDeactivate();
         break;
 
+    case WM_MOUSEACTIVATE:
+        /* Clicks should not activate the menu.
+         * Especially important when clicking on a menu's submenu item which has no effect.
+         */
+        printf("WM_MOUSEACTIVATE\n");
+        if (window->IsMenu)
+            lRet = MA_NOACTIVATEANDEAT;
+        else
+            lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
+        break;
+
 #if 0
     case WM_ACTIVATE:
-        //printf("WM_ACTIVATE: %x (ID: %i) %d %d\n",lParam, window->ID, HIWORD(wParam), LOWORD(wParam));
+        /* printf("WM_ACTIVATE: %x (ID: %i) %d %d\n",lParam, window->ID, HIWORD(wParam), LOWORD(wParam)); */
         if (LOWORD(wParam) != WA_INACTIVE)
         {
 /*            printf("WM_ACTIVATE: fgSetCursor( %p, %d)\n", window,
@@ -629,7 +640,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
                     tme.hwndTrack = window->Window.Handle;
                     TrackMouseEvent(&tme);
 
-                    window->State.pWState.MouseTracking = GL_TRUE;
+                    window->State.pWState.MouseTracking = TRUE;
                 }
             }
         }
@@ -648,7 +659,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
             INVOKE_WCB( *window, Entry, ( GLUT_LEFT ) );
             fgSetWindow(saved_window);
 
-            window->State.pWState.MouseTracking = GL_FALSE;
+            window->State.pWState.MouseTracking = FALSE;
             lRet = 0;   /* As per docs, must return zero */
         }
         break;
@@ -981,6 +992,12 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
         /* Help screen says this message must be passed to "DefWindowProc" */
         break;
 
+    case WM_DISPLAYCHANGE: /* 0x007E */
+        /* The system display resolution/depth has changed */
+        fgDisplay.ScreenWidth = LOWORD(lParam);
+        fgDisplay.ScreenHeight = HIWORD(lParam);
+        break;
+
     case WM_SYSCOMMAND :  /* 0x0112 */
         {
           /*