2010-12-31 04:43:35 +00:00
|
|
|
/*
|
2003-07-27 11:54:42 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS user32.dll
|
2015-11-01 09:41:29 +00:00
|
|
|
* FILE: win32ss/user/user32/windows/winpos.c
|
2003-07-27 11:54:42 +00:00
|
|
|
* PURPOSE: Window management
|
|
|
|
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* 06-06-2001 CSH Created
|
|
|
|
*/
|
|
|
|
|
2005-06-19 18:06:53 +00:00
|
|
|
#include <user32.h>
|
2003-07-27 11:54:42 +00:00
|
|
|
|
2007-07-26 15:13:36 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(user32);
|
2006-06-26 13:16:43 +00:00
|
|
|
|
2012-04-23 18:51:48 +00:00
|
|
|
void mirror_rect( const RECT *window_rect, RECT *rect )
|
|
|
|
{
|
|
|
|
int width = window_rect->right - window_rect->left;
|
|
|
|
int tmp = rect->left;
|
|
|
|
rect->left = width - rect->right;
|
|
|
|
rect->right = width - tmp;
|
|
|
|
}
|
|
|
|
|
2003-07-27 11:54:42 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2019-03-26 20:56:57 +00:00
|
|
|
#if 0 // Keep legacy code. Moved to Win32k:NtUser:WinPos.c.
|
2011-12-10 07:41:56 +00:00
|
|
|
#define EMPTYPOINT(pt) ((pt).x == -1 && (pt).y == -1)
|
2006-08-01 21:14:45 +00:00
|
|
|
|
2008-11-30 11:42:05 +00:00
|
|
|
UINT WINAPI
|
2011-12-10 07:41:56 +00:00
|
|
|
WinPosGetMinMaxInfo(HWND hwnd, POINT* maxSize, POINT* maxPos,
|
|
|
|
POINT* minTrack, POINT* maxTrack)
|
2003-07-27 11:54:42 +00:00
|
|
|
{
|
2011-12-10 07:41:56 +00:00
|
|
|
MINMAXINFO MinMax;
|
|
|
|
HMONITOR monitor;
|
|
|
|
INT xinc, yinc;
|
|
|
|
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
LONG adjustedStyle;
|
|
|
|
LONG exstyle = GetWindowLongW( hwnd, GWL_EXSTYLE );
|
|
|
|
RECT rc;
|
|
|
|
WND *win;
|
|
|
|
|
|
|
|
/* Compute default values */
|
|
|
|
|
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
MinMax.ptReserved.x = rc.left;
|
|
|
|
MinMax.ptReserved.y = rc.top;
|
|
|
|
|
|
|
|
if ((style & WS_CAPTION) == WS_CAPTION)
|
|
|
|
adjustedStyle = style & ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
|
|
|
|
else
|
|
|
|
adjustedStyle = style;
|
|
|
|
|
|
|
|
GetClientRect(GetAncestor(hwnd,GA_PARENT), &rc);
|
|
|
|
AdjustWindowRectEx(&rc, adjustedStyle, ((style & WS_POPUP) && GetMenu(hwnd)), exstyle);
|
|
|
|
|
|
|
|
xinc = -rc.left;
|
|
|
|
yinc = -rc.top;
|
|
|
|
|
|
|
|
MinMax.ptMaxSize.x = rc.right - rc.left;
|
|
|
|
MinMax.ptMaxSize.y = rc.bottom - rc.top;
|
|
|
|
if (style & (WS_DLGFRAME | WS_BORDER))
|
|
|
|
{
|
|
|
|
MinMax.ptMinTrackSize.x = GetSystemMetrics(SM_CXMINTRACK);
|
|
|
|
MinMax.ptMinTrackSize.y = GetSystemMetrics(SM_CYMINTRACK);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MinMax.ptMinTrackSize.x = 2 * xinc;
|
|
|
|
MinMax.ptMinTrackSize.y = 2 * yinc;
|
|
|
|
}
|
|
|
|
MinMax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXMAXTRACK);
|
|
|
|
MinMax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYMAXTRACK);
|
|
|
|
MinMax.ptMaxPosition.x = -xinc;
|
|
|
|
MinMax.ptMaxPosition.y = -yinc;
|
|
|
|
|
|
|
|
if ((win = ValidateHwnd( hwnd )) )//&& win != WND_DESKTOP && win != WND_OTHER_PROCESS)
|
|
|
|
{
|
|
|
|
if (!EMPTYPOINT(win->InternalPos.MaxPos)) MinMax.ptMaxPosition = win->InternalPos.MaxPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
SendMessageW( hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
|
|
|
|
|
|
|
|
/* if the app didn't change the values, adapt them for the current monitor */
|
|
|
|
|
|
|
|
if ((monitor = MonitorFromWindow( hwnd, MONITOR_DEFAULTTOPRIMARY )))
|
|
|
|
{
|
|
|
|
RECT rc_work;
|
|
|
|
MONITORINFO mon_info;
|
|
|
|
|
|
|
|
mon_info.cbSize = sizeof(mon_info);
|
|
|
|
GetMonitorInfoW( monitor, &mon_info );
|
|
|
|
|
|
|
|
rc_work = mon_info.rcMonitor;
|
|
|
|
|
|
|
|
if (style & WS_MAXIMIZEBOX)
|
|
|
|
{
|
|
|
|
if ((style & WS_CAPTION) == WS_CAPTION || !(style & (WS_CHILD | WS_POPUP)))
|
|
|
|
rc_work = mon_info.rcWork;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MinMax.ptMaxSize.x == GetSystemMetrics(SM_CXSCREEN) + 2 * xinc &&
|
|
|
|
MinMax.ptMaxSize.y == GetSystemMetrics(SM_CYSCREEN) + 2 * yinc)
|
|
|
|
{
|
|
|
|
MinMax.ptMaxSize.x = (rc_work.right - rc_work.left) + 2 * xinc;
|
|
|
|
MinMax.ptMaxSize.y = (rc_work.bottom - rc_work.top) + 2 * yinc;
|
|
|
|
}
|
|
|
|
if (MinMax.ptMaxPosition.x == -xinc && MinMax.ptMaxPosition.y == -yinc)
|
|
|
|
{
|
|
|
|
MinMax.ptMaxPosition.x = rc_work.left - xinc;
|
|
|
|
MinMax.ptMaxPosition.y = rc_work.top - yinc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Some sanity checks */
|
|
|
|
|
|
|
|
TRACE("%d %d / %d %d / %d %d / %d %d\n",
|
|
|
|
MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
|
|
|
|
MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
|
|
|
|
MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
|
|
|
|
MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y);
|
|
|
|
MinMax.ptMaxTrackSize.x = max( MinMax.ptMaxTrackSize.x,
|
|
|
|
MinMax.ptMinTrackSize.x );
|
|
|
|
MinMax.ptMaxTrackSize.y = max( MinMax.ptMaxTrackSize.y,
|
|
|
|
MinMax.ptMinTrackSize.y );
|
|
|
|
|
|
|
|
if (maxSize) *maxSize = MinMax.ptMaxSize;
|
|
|
|
if (maxPos) *maxPos = MinMax.ptMaxPosition;
|
|
|
|
if (minTrack) *minTrack = MinMax.ptMinTrackSize;
|
|
|
|
if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
|
|
|
|
|
2019-03-26 20:56:57 +00:00
|
|
|
return 0; //FIXME: what does it return? Wine returns MINMAXINFO.
|
2003-07-27 11:54:42 +00:00
|
|
|
}
|
2019-03-26 20:56:57 +00:00
|
|
|
#endif
|
2003-07-27 11:54:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
HWND WINAPI
|
2003-07-27 11:54:42 +00:00
|
|
|
GetActiveWindow(VOID)
|
|
|
|
{
|
Patch by Stefan Ginsberg (stefan__100__ AT hotmail DOT com):
- remove NtUserEnumClipboardFormats, use ->ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMAT insetad
- remove NtUserRegisterClipboardFormat, use NtUserRegisterWIndowsMessage instead
- remove NtUserKillSystemTimer, use HWNDPARAM_ROUTINE_KILLSYSTEMTIMER instead
- remove NtUserInsertMenuItem, use NtUserThunkedMenuItemInfo instead
- remove NtUserGetCapture, use THREADSTATE_CAPTUREWINDOW instead
- remove NtUserGetActiveWindow, use THREADSTATE_ACTIVEWINDOW instead
- remove NtUserGetQueueStatus, use ONEPARAM_ROUTIME_GETQUEUESTATUS instead
- remove NtUserGetLastActivePopup, wasn't implemented
- remove NtUserRealizePalette from ntuser.h, it's not implemented
- remove duplicate NtUserGetLastInputInfo from ntuser.h
- remove PrivateCsrssRergisterPrimitive from user32, it was unused and unimplemented
- remove NtUserDereferenceWndprocHandle, it was unused
- move WNDPROC_INFO structure from ntuser.h to win32k/include/class.h, as it's not used in usermode anymore
tested with AbiWord and FF on VMWare
svn path=/trunk/; revision=32825
2008-04-03 02:13:34 +00:00
|
|
|
return (HWND)NtUserGetThreadState(THREADSTATE_ACTIVEWINDOW);
|
2003-07-27 11:54:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-18 03:13:11 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
UINT WINAPI
|
2005-07-18 03:13:11 +00:00
|
|
|
ArrangeIconicWindows(HWND hWnd)
|
|
|
|
{
|
2011-08-25 08:51:26 +00:00
|
|
|
return NtUserxArrangeIconicWindows( hWnd );
|
2005-07-18 03:13:11 +00:00
|
|
|
}
|
2010-12-31 04:43:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HWND WINAPI
|
|
|
|
WindowFromPoint(POINT Point)
|
|
|
|
{
|
|
|
|
//TODO: Determine what the actual parameters to
|
|
|
|
// NtUserWindowFromPoint are.
|
|
|
|
return NtUserWindowFromPoint(Point.x, Point.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
int WINAPI
|
|
|
|
MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints)
|
|
|
|
{
|
2010-12-31 21:10:29 +00:00
|
|
|
PWND FromWnd = NULL, ToWnd = NULL;
|
|
|
|
BOOL mirror_from, mirror_to;
|
2010-12-31 04:43:35 +00:00
|
|
|
POINT Delta;
|
|
|
|
UINT i;
|
2012-04-23 18:51:48 +00:00
|
|
|
int Change = 1;
|
2010-12-31 04:43:35 +00:00
|
|
|
|
2010-12-31 21:10:29 +00:00
|
|
|
if (hWndFrom)
|
|
|
|
{
|
|
|
|
FromWnd = ValidateHwnd(hWndFrom);
|
|
|
|
if (!FromWnd)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (hWndTo)
|
|
|
|
{
|
|
|
|
ToWnd = ValidateHwnd(hWndTo);
|
|
|
|
if (!ToWnd)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: Desktop Top and Left is always 0! */
|
|
|
|
Delta.x = Delta.y = 0;
|
|
|
|
mirror_from = mirror_to = FALSE;
|
|
|
|
|
2011-10-24 14:13:19 +00:00
|
|
|
if (FromWnd && hWndFrom != GetDesktopWindow()) // FromWnd->fnid != FNID_DESKTOP)
|
2010-12-31 21:10:29 +00:00
|
|
|
{
|
|
|
|
if (FromWnd->ExStyle & WS_EX_LAYOUTRTL)
|
|
|
|
{
|
|
|
|
mirror_from = TRUE;
|
2012-04-23 18:51:48 +00:00
|
|
|
Change = -Change;
|
|
|
|
Delta.x = -FromWnd->rcClient.right;
|
2010-12-31 21:10:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Delta.x = FromWnd->rcClient.left;
|
|
|
|
Delta.y = FromWnd->rcClient.top;
|
|
|
|
}
|
2010-12-31 04:43:35 +00:00
|
|
|
|
2011-10-24 14:13:19 +00:00
|
|
|
if (ToWnd && hWndTo != GetDesktopWindow()) // ToWnd->fnid != FNID_DESKTOP)
|
2010-12-31 21:10:29 +00:00
|
|
|
{
|
|
|
|
if (ToWnd->ExStyle & WS_EX_LAYOUTRTL)
|
|
|
|
{
|
|
|
|
mirror_to = TRUE;
|
2012-04-23 18:51:48 +00:00
|
|
|
Change = -Change;
|
|
|
|
Delta.x += Change * ToWnd->rcClient.right;
|
2010-12-31 21:10:29 +00:00
|
|
|
}
|
|
|
|
else
|
2012-04-23 18:51:48 +00:00
|
|
|
Delta.x -= Change * ToWnd->rcClient.left;
|
2010-12-31 21:10:29 +00:00
|
|
|
Delta.y -= ToWnd->rcClient.top;
|
|
|
|
}
|
2010-12-31 04:43:35 +00:00
|
|
|
|
|
|
|
for (i = 0; i != cPoints; i++)
|
|
|
|
{
|
|
|
|
lpPoints[i].x += Delta.x;
|
2012-04-23 18:51:48 +00:00
|
|
|
lpPoints[i].x *= Change;
|
2010-12-31 04:43:35 +00:00
|
|
|
lpPoints[i].y += Delta.y;
|
2010-12-31 21:10:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((mirror_from || mirror_to) && cPoints == 2) /* special case for rectangle */
|
|
|
|
{
|
2012-04-23 18:51:48 +00:00
|
|
|
int tmp = min(lpPoints[0].x, lpPoints[1].x);
|
|
|
|
lpPoints[1].x = max(lpPoints[0].x, lpPoints[1].x);
|
|
|
|
lpPoints[0].x = tmp;
|
2010-12-31 04:43:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return MAKELONG(LOWORD(Delta.x), LOWORD(Delta.y));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
ScreenToClient(HWND hWnd, LPPOINT lpPoint)
|
|
|
|
{
|
2010-12-31 21:10:29 +00:00
|
|
|
PWND Wnd;
|
|
|
|
/* Note: Desktop Top and Left is always 0! */
|
2010-12-31 04:43:35 +00:00
|
|
|
Wnd = ValidateHwnd(hWnd);
|
|
|
|
if (!Wnd)
|
|
|
|
return FALSE;
|
|
|
|
|
2011-10-24 14:13:19 +00:00
|
|
|
if (hWnd != GetDesktopWindow()) // Wnd->fnid != FNID_DESKTOP )
|
2010-12-31 21:10:29 +00:00
|
|
|
{
|
|
|
|
if (Wnd->ExStyle & WS_EX_LAYOUTRTL)
|
|
|
|
lpPoint->x = Wnd->rcClient.right - lpPoint->x;
|
|
|
|
else
|
|
|
|
lpPoint->x -= Wnd->rcClient.left;
|
|
|
|
lpPoint->y -= Wnd->rcClient.top;
|
|
|
|
}
|
2010-12-31 04:43:35 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
ClientToScreen(HWND hWnd, LPPOINT lpPoint)
|
|
|
|
{
|
2010-12-31 21:10:29 +00:00
|
|
|
PWND Wnd;
|
|
|
|
/* Note: Desktop Top and Left is always 0! */
|
2010-12-31 04:43:35 +00:00
|
|
|
Wnd = ValidateHwnd(hWnd);
|
|
|
|
if (!Wnd)
|
|
|
|
return FALSE;
|
|
|
|
|
2011-10-24 14:13:19 +00:00
|
|
|
if ( hWnd != GetDesktopWindow()) // Wnd->fnid != FNID_DESKTOP )
|
2010-12-31 21:10:29 +00:00
|
|
|
{
|
|
|
|
if (Wnd->ExStyle & WS_EX_LAYOUTRTL)
|
|
|
|
lpPoint->x = Wnd->rcClient.right - lpPoint->x;
|
|
|
|
else
|
|
|
|
lpPoint->x += Wnd->rcClient.left;
|
|
|
|
lpPoint->y += Wnd->rcClient.top;
|
|
|
|
}
|
2010-12-31 04:43:35 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|