ReactOS 0.4.16-dev-197-g92996da
winpos.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS user32.dll
4 * FILE: win32ss/user/user32/windows/winpos.c
5 * PURPOSE: Window management
6 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * UPDATE HISTORY:
8 * 06-06-2001 CSH Created
9 */
10
11#include <user32.h>
12
14
15void mirror_rect( const RECT *window_rect, RECT *rect )
16{
17 int width = window_rect->right - window_rect->left;
18 int tmp = rect->left;
19 rect->left = width - rect->right;
20 rect->right = width - tmp;
21}
22
23/* FUNCTIONS *****************************************************************/
24
25#if 0 // Keep legacy code. Moved to Win32k:NtUser:WinPos.c.
26#define EMPTYPOINT(pt) ((pt).x == -1 && (pt).y == -1)
27
29WinPosGetMinMaxInfo(HWND hwnd, POINT* maxSize, POINT* maxPos,
30 POINT* minTrack, POINT* maxTrack)
31{
32 MINMAXINFO MinMax;
33 HMONITOR monitor;
34 INT xinc, yinc;
36 LONG adjustedStyle;
37 LONG exstyle = GetWindowLongW( hwnd, GWL_EXSTYLE );
38 RECT rc;
39 WND *win;
40
41 /* Compute default values */
42
43 GetWindowRect(hwnd, &rc);
44 MinMax.ptReserved.x = rc.left;
45 MinMax.ptReserved.y = rc.top;
46
47 if ((style & WS_CAPTION) == WS_CAPTION)
48 adjustedStyle = style & ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
49 else
50 adjustedStyle = style;
51
53 AdjustWindowRectEx(&rc, adjustedStyle, ((style & WS_POPUP) && GetMenu(hwnd)), exstyle);
54
55 xinc = -rc.left;
56 yinc = -rc.top;
57
58 MinMax.ptMaxSize.x = rc.right - rc.left;
59 MinMax.ptMaxSize.y = rc.bottom - rc.top;
60 if (style & (WS_DLGFRAME | WS_BORDER))
61 {
64 }
65 else
66 {
67 MinMax.ptMinTrackSize.x = 2 * xinc;
68 MinMax.ptMinTrackSize.y = 2 * yinc;
69 }
72 MinMax.ptMaxPosition.x = -xinc;
73 MinMax.ptMaxPosition.y = -yinc;
74
75 if ((win = ValidateHwnd( hwnd )) )//&& win != WND_DESKTOP && win != WND_OTHER_PROCESS)
76 {
77 if (!EMPTYPOINT(win->InternalPos.MaxPos)) MinMax.ptMaxPosition = win->InternalPos.MaxPos;
78 }
79
81
82 /* if the app didn't change the values, adapt them for the current monitor */
83
84 if ((monitor = MonitorFromWindow( hwnd, MONITOR_DEFAULTTOPRIMARY )))
85 {
86 RECT rc_work;
87 MONITORINFO mon_info;
88
89 mon_info.cbSize = sizeof(mon_info);
90 GetMonitorInfoW( monitor, &mon_info );
91
92 rc_work = mon_info.rcMonitor;
93
95 {
96 if ((style & WS_CAPTION) == WS_CAPTION || !(style & (WS_CHILD | WS_POPUP)))
97 rc_work = mon_info.rcWork;
98 }
99
100 if (MinMax.ptMaxSize.x == GetSystemMetrics(SM_CXSCREEN) + 2 * xinc &&
101 MinMax.ptMaxSize.y == GetSystemMetrics(SM_CYSCREEN) + 2 * yinc)
102 {
103 MinMax.ptMaxSize.x = (rc_work.right - rc_work.left) + 2 * xinc;
104 MinMax.ptMaxSize.y = (rc_work.bottom - rc_work.top) + 2 * yinc;
105 }
106 if (MinMax.ptMaxPosition.x == -xinc && MinMax.ptMaxPosition.y == -yinc)
107 {
108 MinMax.ptMaxPosition.x = rc_work.left - xinc;
109 MinMax.ptMaxPosition.y = rc_work.top - yinc;
110 }
111 }
112
113 /* Some sanity checks */
114
115 TRACE("%d %d / %d %d / %d %d / %d %d\n",
116 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
117 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
118 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
119 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y);
120 MinMax.ptMaxTrackSize.x = max( MinMax.ptMaxTrackSize.x,
121 MinMax.ptMinTrackSize.x );
122 MinMax.ptMaxTrackSize.y = max( MinMax.ptMaxTrackSize.y,
123 MinMax.ptMinTrackSize.y );
124
125 if (maxSize) *maxSize = MinMax.ptMaxSize;
126 if (maxPos) *maxPos = MinMax.ptMaxPosition;
127 if (minTrack) *minTrack = MinMax.ptMinTrackSize;
128 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
129
130 return 0; //FIXME: what does it return? Wine returns MINMAXINFO.
131}
132#endif
133
134/*
135 * @implemented
136 */
139{
141}
142
143
144/*
145 * @unimplemented
146 */
149{
151}
152
153/*
154 * @implemented
155 */
158{
159 //TODO: Determine what the actual parameters to
160 // NtUserWindowFromPoint are.
162}
163
164/*
165 * @implemented
166 */
167int WINAPI
168MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints)
169{
170 PWND FromWnd = NULL, ToWnd = NULL;
171 BOOL mirror_from, mirror_to;
172 POINT Delta;
173 UINT i;
174 int Change = 1;
175
176 if (hWndFrom)
177 {
178 FromWnd = ValidateHwnd(hWndFrom);
179 if (!FromWnd)
180 return 0;
181 }
182 if (hWndTo)
183 {
184 ToWnd = ValidateHwnd(hWndTo);
185 if (!ToWnd)
186 return 0;
187 }
188
189 /* Note: Desktop Top and Left is always 0! */
190 Delta.x = Delta.y = 0;
191 mirror_from = mirror_to = FALSE;
192
193 if (FromWnd && hWndFrom != GetDesktopWindow()) // FromWnd->fnid != FNID_DESKTOP)
194 {
195 if (FromWnd->ExStyle & WS_EX_LAYOUTRTL)
196 {
197 mirror_from = TRUE;
198 Change = -Change;
199 Delta.x = -FromWnd->rcClient.right;
200 }
201 else
202 Delta.x = FromWnd->rcClient.left;
203 Delta.y = FromWnd->rcClient.top;
204 }
205
206 if (ToWnd && hWndTo != GetDesktopWindow()) // ToWnd->fnid != FNID_DESKTOP)
207 {
208 if (ToWnd->ExStyle & WS_EX_LAYOUTRTL)
209 {
210 mirror_to = TRUE;
211 Change = -Change;
212 Delta.x += Change * ToWnd->rcClient.right;
213 }
214 else
215 Delta.x -= Change * ToWnd->rcClient.left;
216 Delta.y -= ToWnd->rcClient.top;
217 }
218
219 for (i = 0; i != cPoints; i++)
220 {
221 lpPoints[i].x += Delta.x;
222 lpPoints[i].x *= Change;
223 lpPoints[i].y += Delta.y;
224 }
225
226 if ((mirror_from || mirror_to) && cPoints == 2) /* special case for rectangle */
227 {
228 int tmp = min(lpPoints[0].x, lpPoints[1].x);
229 lpPoints[1].x = max(lpPoints[0].x, lpPoints[1].x);
230 lpPoints[0].x = tmp;
231 }
232
233 return MAKELONG(LOWORD(Delta.x), LOWORD(Delta.y));
234}
235
236/*
237 * @implemented
238 */
241{
242 PWND Wnd;
243 /* Note: Desktop Top and Left is always 0! */
244 Wnd = ValidateHwnd(hWnd);
245 if (!Wnd)
246 return FALSE;
247
248 if (hWnd != GetDesktopWindow()) // Wnd->fnid != FNID_DESKTOP )
249 {
250 if (Wnd->ExStyle & WS_EX_LAYOUTRTL)
251 lpPoint->x = Wnd->rcClient.right - lpPoint->x;
252 else
253 lpPoint->x -= Wnd->rcClient.left;
254 lpPoint->y -= Wnd->rcClient.top;
255 }
256 return TRUE;
257}
258
259/*
260 * @implemented
261 */
264{
265 PWND Wnd;
266 /* Note: Desktop Top and Left is always 0! */
267 Wnd = ValidateHwnd(hWnd);
268 if (!Wnd)
269 return FALSE;
270
271 if ( hWnd != GetDesktopWindow()) // Wnd->fnid != FNID_DESKTOP )
272 {
273 if (Wnd->ExStyle & WS_EX_LAYOUTRTL)
274 lpPoint->x = Wnd->rcClient.right - lpPoint->x;
275 else
276 lpPoint->x += Wnd->rcClient.left;
277 lpPoint->y += Wnd->rcClient.top;
278 }
279 return TRUE;
280}
Arabic default style
Definition: afstyles.h:94
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ValidateHwnd(hwnd)
Definition: precomp.h:85
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ THREADSTATE_ACTIVEWINDOW
Definition: ntuser.h:2473
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:240
static real win[4][36]
#define min(a, b)
Definition: monoChain.cc:55
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
unsigned int UINT
Definition: ndis.h:50
#define EMPTYPOINT(pt)
Definition: winpos.c:29
HWND APIENTRY NtUserWindowFromPoint(LONG X, LONG Y)
Definition: winpos.c:3847
EXTINLINE UINT NtUserxArrangeIconicWindows(HWND hWnd)
Definition: ntwrapper.h:768
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
#define WS_CAPTION
Definition: pedump.c:624
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define WS_BORDER
Definition: pedump.c:625
#define WS_POPUP
Definition: pedump.c:616
long LONG
Definition: pedump.c:60
#define WS_DLGFRAME
Definition: pedump.c:626
#define TRACE(s)
Definition: solgame.cpp:4
& rect
Definition: startmenu.cpp:1413
Definition: ntuser.h:694
DWORD ExStyle
Definition: ntuser.h:704
RECT rcClient
Definition: ntuser.h:717
POINT ptMaxPosition
Definition: winuser.h:3632
POINT ptMaxSize
Definition: winuser.h:3631
POINT ptMinTrackSize
Definition: winuser.h:3633
POINT ptReserved
Definition: winuser.h:3630
POINT ptMaxTrackSize
Definition: winuser.h:3634
RECT rcMonitor
Definition: winuser.h:3788
DWORD cbSize
Definition: winuser.h:3787
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define max(a, b)
Definition: svc.c:63
int32_t INT
Definition: typedefs.h:58
#define MAKELONG(a, b)
Definition: typedefs.h:249
BOOL WINAPI ScreenToClient(HWND hWnd, LPPOINT lpPoint)
Definition: winpos.c:240
BOOL WINAPI ClientToScreen(HWND hWnd, LPPOINT lpPoint)
Definition: winpos.c:263
int WINAPI MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints)
Definition: winpos.c:168
UINT WINAPI ArrangeIconicWindows(HWND hWnd)
Definition: winpos.c:148
void mirror_rect(const RECT *window_rect, RECT *rect)
Definition: winpos.c:15
HWND WINAPI WindowFromPoint(POINT Point)
Definition: winpos.c:157
UINT WINAPI WinPosGetMinMaxInfo(HWND hWnd, POINT *MaxSize, POINT *MaxPos, POINT *MinTrack, POINT *MaxTrack)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
#define WINAPI
Definition: msvc.h:6
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
#define SM_CYSCREEN
Definition: winuser.h:963
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SM_CXMINTRACK
Definition: winuser.h:1000
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
#define GA_PARENT
Definition: winuser.h:2791
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SM_CXMAXTRACK
Definition: winuser.h:1025
#define WM_GETMINMAXINFO
Definition: winuser.h:1643
#define SM_CYMAXTRACK
Definition: winuser.h:1026
#define SM_CXSCREEN
Definition: winuser.h:962
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
#define GWL_STYLE
Definition: winuser.h:855
int WINAPI GetSystemMetrics(_In_ int)
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)
#define SM_CYMINTRACK
Definition: winuser.h:1001
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HMENU WINAPI GetMenu(_In_ HWND)
#define GWL_EXSTYLE
Definition: winuser.h:854
static ULONG Delta
Definition: xboxvideo.c:33