Author: jimtabor
Date: Wed Oct 28 02:43:59 2009
New Revision: 43803
URL:
http://svn.reactos.org/svn/reactos?rev=43803&view=rev
Log:
- [User32] Update MenuShowPopup with wine and add menu check for MenuTrackMenu.
MenuTrackMenu menu check fixed the first stop with wine menu test.
Modified:
trunk/reactos/dll/win32/user32/windows/menu.c
Modified: trunk/reactos/dll/win32/user32/windows/menu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/menu.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/menu.c [iso-8859-1] Wed Oct 28 02:43:59 2009
@@ -1928,12 +1928,15 @@
* Display a popup menu.
*/
static BOOL FASTCALL
-MenuShowPopup(HWND WndOwner, HMENU Menu, UINT Id,
+MenuShowPopup(HWND WndOwner, HMENU Menu, UINT Id, UINT flags,
INT X, INT Y, INT XAnchor, INT YAnchor )
{
ROSMENUINFO MenuInfo;
ROSMENUITEMINFO ItemInfo;
UINT Width, Height;
+ POINT pt;
+ HMONITOR monitor;
+ MONITORINFO info;
TRACE("owner=%x hmenu=%x id=0x%04x x=0x%04x y=0x%04x xa=0x%04x ya=0x%04x\n",
WndOwner, Menu, Id, X, Y, XAnchor, YAnchor);
@@ -1967,38 +1970,40 @@
Width = MenuInfo.Width + GetSystemMetrics(SM_CXBORDER);
Height = MenuInfo.Height + GetSystemMetrics(SM_CYBORDER);
- if (GetSystemMetrics(SM_CXSCREEN ) < X + Width)
- {
- if (0 != XAnchor && X >= Width - XAnchor)
- {
- X -= Width - XAnchor;
- }
- if (GetSystemMetrics(SM_CXSCREEN) < X + Width)
- {
- X = GetSystemMetrics(SM_CXSCREEN) - Width;
- }
- }
- if (X < 0 )
- {
- X = 0;
- }
-
- if (GetSystemMetrics(SM_CYSCREEN) < Y + Height)
- {
- if (0 != YAnchor && Y >= Height + YAnchor)
- {
- Y -= Height + YAnchor;
- }
- if (GetSystemMetrics(SM_CYSCREEN) < Y + Height)
- {
- Y = GetSystemMetrics(SM_CYSCREEN) - Height;
- }
- }
- if (Y < 0 )
- {
- Y = 0;
- }
-
+ /* FIXME: should use item rect */
+ pt.x = X;
+ pt.y = Y;
+ monitor = MonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST );
+ info.cbSize = sizeof(info);
+ GetMonitorInfoW( monitor, &info );
+
+ if( flags & TPM_RIGHTALIGN ) X -= Width;
+ if( flags & TPM_CENTERALIGN ) X -= Width / 2;
+
+ if( flags & TPM_BOTTOMALIGN ) Y -= Height;
+ if( flags & TPM_VCENTERALIGN ) Y -= Height / 2;
+
+ if (X + Width > info.rcWork.right)
+ {
+ if ( XAnchor && X >= Width - XAnchor)
+ X -= Width - XAnchor;
+
+ if ( X + Width > info.rcWork.right)
+ X = info.rcWork.right - Width;
+ }
+
+ if ( X < info.rcWork.left ) X = info.rcWork.left;
+
+ if (Y + Height > info.rcWork.bottom)
+ {
+ if ( YAnchor && Y >= Height + YAnchor)
+ Y -= Height + YAnchor;
+
+ if ( Y + Height > info.rcWork.bottom)
+ Y = info.rcWork.bottom - Height;
+ }
+
+ if ( Y < info.rcWork.top ) Y = info.rcWork.top;
/* NOTE: In Windows, top menu popup is not owned. */
MenuInfo.Wnd = CreateWindowExW(0, POPUPMENU_CLASS_ATOMW, NULL,
@@ -2413,7 +2418,7 @@
}
}
- MenuShowPopup(WndOwner, ItemInfo.hSubMenu, MenuInfo->FocusedItem,
+ MenuShowPopup(WndOwner, ItemInfo.hSubMenu, MenuInfo->FocusedItem, Flags,
Rect.left, Rect.top, Rect.right, Rect.bottom );
if (SelectFirst && MenuGetRosMenuInfo(&SubMenuInfo, ItemInfo.hSubMenu))
{
@@ -3389,8 +3394,13 @@
SetCapture(Mt.OwnerWnd);
(void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, Mt.OwnerWnd);
+ ERR("MenuTrackMenu 1\n");
while (! fEndMenu)
{
+ PVOID menu = ValidateHandle(Mt.CurrentMenu, VALIDATE_TYPE_MENU);
+ if (!menu) /* sometimes happens if I do a window manager close */
+ break;
+
/* we have to keep the message in the queue until it's
* clear that menu loop is not over yet. */
@@ -3665,6 +3675,7 @@
Mt.TrackFlags &= ~TF_SKIPREMOVE;
}
}
+ ERR("MenuTrackMenu 2\n");
(void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, NULL);
SetCapture(NULL); /* release the capture */
@@ -4787,9 +4798,8 @@
IsMenu(
HMENU Menu)
{
- ROSMENUINFO MenuInfo;
-
- return MenuGetRosMenuInfo(&MenuInfo, Menu);
+ if (ValidateHandle(Menu, VALIDATE_TYPE_MENU)) return TRUE;
+ return FALSE;
}
@@ -5205,12 +5215,11 @@
SendMessageW(Wnd, WM_INITMENUPOPUP, (WPARAM) Menu, 0);
}
- if (MenuShowPopup(Wnd, Menu, 0, x, y, 0, 0 ))
+ if (MenuShowPopup(Wnd, Menu, 0, Flags, x, y, 0, 0 ))
{
ret = MenuTrackMenu(Menu, Flags | TPM_POPUPMENU, 0, 0, Wnd, Rect);
}
MenuExitTracking(Wnd);
-
return ret;
}