mdi: Don't use SWP_FRAMECHANGED from WM_MDISETMENU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This causes bad performance problems in IDA.

Looking at the docs on MSDN for WM_MDISETMENU, it says "After sending this 
message, an application must call the DrawMenuBar function to update the menu 
bar". Which implies that the application is in charge of telling the menu bar 
to redraw, meaning the use of SWP_FRAMECHANGED is superfluous.

However, SetMenu() is used non by MDI menus as well, which DO expect the menu 
to be updated automatically (MSDN: "The window is redrawn to reflect the menu 
change"), which means it can't just be removed.

The way I've fixed it is the neatest way I could think of. If someone can 
suggest a better method please do, and I'll sort it.
Index: windows/mdi.c
===================================================================
RCS file: /home/wine/wine/windows/mdi.c,v
retrieving revision 1.113
diff -u -r1.113 mdi.c
--- windows/mdi.c	23 Sep 2003 22:47:55 -0000	1.113
+++ windows/mdi.c	4 Dec 2003 14:52:47 -0000
@@ -431,7 +431,7 @@
 
     if (hmenuFrame)
     {
-        SetMenu(hwndFrame, hmenuFrame);
+        MENU_SetMenuNoUpdate(hwndFrame, hmenuFrame);
         if( hmenuFrame!=oldFrameMenu )
         {
             if( ci->hwndChildMaximized )
Index: controls/menu.c
===================================================================
RCS file: /home/wine/wine/controls/menu.c,v
retrieving revision 1.171
diff -u -r1.171 menu.c
--- controls/menu.c	26 Nov 2003 05:08:48 -0000	1.171
+++ controls/menu.c	4 Dec 2003 14:52:53 -0000
@@ -3756,9 +3756,9 @@
 
 
 /**********************************************************************
- *         SetMenu    (USER32.@)
+ *         MENU_SetMenuNoUpdate
  */
-BOOL WINAPI SetMenu( HWND hWnd, HMENU hMenu )
+BOOL MENU_SetMenuNoUpdate( HWND hWnd, HMENU hMenu )
 {
     TRACE("(%p, %p);\n", hWnd, hMenu);
 
@@ -3783,9 +3783,23 @@
     }
     SetWindowLongW( hWnd, GWL_ID, (LONG_PTR)hMenu );
 
-    if (IsWindowVisible(hWnd))
-        SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
-                      SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
+    return TRUE;
+}
+
+
+
+/**********************************************************************
+ *         SetMenu    (USER32.@)
+ */
+BOOL WINAPI SetMenu( HWND hWnd, HMENU hMenu )
+{
+    if (!MENU_SetMenuNoUpdate(hWnd, hMenu)) return FALSE;
+    
+    if (IsWindowVisible(hWnd)) {
+	 SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
+		       SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
+    }
+
     return TRUE;
 }
 
Index: include/winuser.h
===================================================================
RCS file: /home/wine/wine/include/winuser.h,v
retrieving revision 1.175
diff -u -r1.175 winuser.h
--- include/winuser.h	26 Nov 2003 05:22:42 -0000	1.175
+++ include/winuser.h	4 Dec 2003 14:52:59 -0000
@@ -501,6 +501,10 @@
 #ifdef __WINESRC__
 /* force using a cast when inside Wine */
 #define MAKEINTRESOURCE(i) ((ULONG_PTR)((WORD)(i)))
+    
+/* Special SetMenu function necessary for MDI_MDISetMenu */
+BOOL MENU_SetMenuNoUpdate( HWND hWnd, HMENU hMenu );
+
 #else
 #define MAKEINTRESOURCE WINELIB_NAME_AW(MAKEINTRESOURCE)
 #endif

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux