ReactOS 0.4.15-dev-6055-g36cdd34
winpos.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Windows
5 * FILE: win32ss/user/ntuser/winpos.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
8 */
9
10#include <win32k.h>
11#include <ddk/immdev.h>
13
14/* GLOBALS *******************************************************************/
15
16#define MINMAX_NOSWP (0x00010000)
17
18#define SWP_EX_NOCOPY 0x0001
19#define SWP_EX_PAINTSELF 0x0002
20
21#define SWP_AGG_NOGEOMETRYCHANGE \
22 (SWP_NOSIZE | SWP_NOCLIENTSIZE | SWP_NOZORDER)
23#define SWP_AGG_NOPOSCHANGE \
24 (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOZORDER)
25#define SWP_AGG_STATUSFLAGS \
26 (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
27#define SWP_AGG_NOCLIENTCHANGE \
28 (SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
29
30#define EMPTYPOINT(pt) ((pt).x == -1 && (pt).y == -1)
31#define PLACE_MIN 0x0001
32#define PLACE_MAX 0x0002
33#define PLACE_RECT 0x0004
34
35/* FUNCTIONS *****************************************************************/
36
37#if DBG
38/***********************************************************************
39 * dump_winpos_flags
40 */
41static void dump_winpos_flags(UINT flags)
42{
43 static const DWORD dumped_flags = (SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW |
48 TRACE("flags:");
49 if(flags & SWP_NOSIZE) TRACE(" SWP_NOSIZE");
50 if(flags & SWP_NOMOVE) TRACE(" SWP_NOMOVE");
51 if(flags & SWP_NOZORDER) TRACE(" SWP_NOZORDER");
52 if(flags & SWP_NOREDRAW) TRACE(" SWP_NOREDRAW");
53 if(flags & SWP_NOACTIVATE) TRACE(" SWP_NOACTIVATE");
54 if(flags & SWP_FRAMECHANGED) TRACE(" SWP_FRAMECHANGED");
55 if(flags & SWP_SHOWWINDOW) TRACE(" SWP_SHOWWINDOW");
56 if(flags & SWP_HIDEWINDOW) TRACE(" SWP_HIDEWINDOW");
57 if(flags & SWP_NOCOPYBITS) TRACE(" SWP_NOCOPYBITS");
58 if(flags & SWP_NOOWNERZORDER) TRACE(" SWP_NOOWNERZORDER");
59 if(flags & SWP_NOSENDCHANGING) TRACE(" SWP_NOSENDCHANGING");
60 if(flags & SWP_DEFERERASE) TRACE(" SWP_DEFERERASE");
61 if(flags & SWP_ASYNCWINDOWPOS) TRACE(" SWP_ASYNCWINDOWPOS");
62 if(flags & SWP_NOCLIENTSIZE) TRACE(" SWP_NOCLIENTSIZE");
63 if(flags & SWP_NOCLIENTMOVE) TRACE(" SWP_NOCLIENTMOVE");
64 if(flags & SWP_STATECHANGED) TRACE(" SWP_STATECHANGED");
65
66 if(flags & ~dumped_flags) TRACE(" %08x", flags & ~dumped_flags);
67 TRACE("\n");
68}
69#endif
70
73{
75 if (Window == NULL)
76 {
77 Point->x = Point->y = 0;
78 return FALSE;
79 }
80 Point->x = Window->rcClient.left;
81 Point->y = Window->rcClient.top;
82
83 return TRUE;
84}
85
94{
95 ASSERT( Wnd );
96 ASSERT( Rect );
97 if (Wnd->style & WS_MINIMIZED)
98 {
99 Rect->left = Rect->top = 0;
102 return;
103 }
104 if (!UserIsDesktopWindow(Wnd))
105 {
106 *Rect = Wnd->rcClient;
108 }
109 else
110 {
111 Rect->left = Rect->top = 0;
112 Rect->right = Wnd->rcClient.right;
113 Rect->bottom = Wnd->rcClient.bottom;
114 /* Do this until Init bug is fixed. This sets 640x480, see InitMetrics.
115 Rect->right = UserGetSystemMetrics(SM_CXSCREEN);
116 Rect->bottom = UserGetSystemMetrics(SM_CYSCREEN);
117 */
118 }
119}
120
123{
124 ASSERT( Wnd );
125 ASSERT( Rect );
126 if (!Wnd) return FALSE;
127 if (!UserIsDesktopWindow(Wnd))
128 {
129 *Rect = Wnd->rcWindow;
130 }
131 else
132 {
133 Rect->left = Rect->top = 0;
134 Rect->right = Wnd->rcWindow.right;
135 Rect->bottom = Wnd->rcWindow.bottom;
136/* Do this until Init bug is fixed. This sets 640x480, see InitMetrics.
137 Rect->right = GetSystemMetrics(SM_CXSCREEN);
138 Rect->bottom = GetSystemMetrics(SM_CYSCREEN);
139*/ }
140 return TRUE;
141}
142
143
145IntMapWindowPoints(PWND FromWnd, PWND ToWnd, LPPOINT lpPoints, UINT cPoints)
146{
147 BOOL mirror_from, mirror_to;
148 POINT Delta;
149 UINT i;
150 int Change = 1;
151
152 /* Note: Desktop Top and Left is always 0! */
153 Delta.x = Delta.y = 0;
154 mirror_from = mirror_to = FALSE;
155
156 if (FromWnd && !UserIsDesktopWindow(FromWnd))
157 {
158 if (FromWnd->ExStyle & WS_EX_LAYOUTRTL)
159 {
160 mirror_from = TRUE;
161 Change = -Change;
162 Delta.x = -FromWnd->rcClient.right;
163 }
164 else
165 Delta.x = FromWnd->rcClient.left;
166 Delta.y = FromWnd->rcClient.top;
167 }
168
169 if (ToWnd && !UserIsDesktopWindow(ToWnd))
170 {
171 if (ToWnd->ExStyle & WS_EX_LAYOUTRTL)
172 {
173 mirror_to = TRUE;
174 Change = -Change;
175 Delta.x += Change * ToWnd->rcClient.right;
176 }
177 else
178 Delta.x -= Change * ToWnd->rcClient.left;
179 Delta.y -= ToWnd->rcClient.top;
180 }
181
182 for (i = 0; i != cPoints; i++)
183 {
184 lpPoints[i].x += Delta.x;
185 lpPoints[i].x *= Change;
186 lpPoints[i].y += Delta.y;
187 }
188
189 if ((mirror_from || mirror_to) && cPoints == 2) /* special case for rectangle */
190 {
191 int tmp = min(lpPoints[0].x, lpPoints[1].x);
192 lpPoints[1].x = max(lpPoints[0].x, lpPoints[1].x);
193 lpPoints[0].x = tmp;
194 }
195
196 return MAKELONG(LOWORD(Delta.x), LOWORD(Delta.y));
197}
198
201{
202 if (Wnd && Wnd->fnid != FNID_DESKTOP )
203 {
204 if (Wnd->ExStyle & WS_EX_LAYOUTRTL)
205 lpPoint->x = Wnd->rcClient.right - lpPoint->x;
206 else
207 lpPoint->x += Wnd->rcClient.left;
208 lpPoint->y += Wnd->rcClient.top;
209 }
210 return TRUE;
211}
212
215{
216 if (Wnd && Wnd->fnid != FNID_DESKTOP )
217 {
218 if (Wnd->ExStyle & WS_EX_LAYOUTRTL)
219 lpPoint->x = Wnd->rcClient.right - lpPoint->x;
220 else
221 lpPoint->x -= Wnd->rcClient.left;
222 lpPoint->y -= Wnd->rcClient.top;
223 }
224 return TRUE;
225}
226
228{
229 do
230 {
231 if ( (pWnd->style & (WS_POPUP|WS_CHILD)) != WS_CHILD ||
232 !(pWnd = pWnd->spwndParent) )
233 return TRUE;
234 }
235 while (pWnd->style & WS_VISIBLE);
236 return FALSE;
237}
238
240{
241 PWND pWnd;
242 PDESKTOP rpdesk = gptiCurrent->rpdesk;
243
244 if ( rpdesk &&
245 (pWnd = rpdesk->pDeskInfo->spwnd->spwndChild) &&
246 pWnd->ExStyle & WS_EX_TOPMOST)
247 {
248 for (;;)
249 {
250 if (!pWnd->spwndNext) break;
251 if (!(pWnd->spwndNext->ExStyle & WS_EX_TOPMOST)) break;
252 pWnd = pWnd->spwndNext;
253 }
254 return pWnd;
255 }
256 return NULL;
257}
258
259VOID
261{
262 if (Window->hrgnClip)
263 {
264 /* Delete no longer needed region handle */
266 GreDeleteObject(Window->hrgnClip);
267 Window->hrgnClip = NULL;
268 }
269
270 if (hRgnClip > HRGN_WINDOW)
271 {
272 /*if (!UserIsDesktopWindow(Window))
273 {
274 NtGdiOffsetRgn(hRgnClip, Window->rcWindow.left, Window->rcWindow.top);
275 }*/
276 /* Set public ownership */
278
279 Window->hrgnClip = hRgnClip;
280 }
281}
282
283//
284// This helps with CORE-6129 forcing modal dialog active when another app is minimized or closed.
285//
287{
288 BOOL ActivePrev, FindTopWnd;
289 PWND pWndTopMost, pWndChild, pWndSetActive, pWndTemp, pWndDesk;
292
293 //ERR("AOWM 1 %p\n",Wnd->head.h);
294 ActivePrev = (pti->MessageQueue->spwndActivePrev != NULL);
295 FindTopWnd = TRUE;
296
297 if ((pWndTopMost = IntGetLastTopMostWindow()))
298 pWndChild = pWndTopMost->spwndNext;
299 else
300 pWndChild = Wnd->spwndParent->spwndChild;
301
302 for (;;)
303 {
304 if ( ActivePrev )
305 pWndSetActive = pti->MessageQueue->spwndActivePrev;
306 else
307 pWndSetActive = pWndChild;
308
309 pWndTemp = NULL;
310
311 while(pWndSetActive)
312 {
313 if ( VerifyWnd(pWndSetActive) &&
314 !(pWndSetActive->ExStyle & WS_EX_NOACTIVATE) &&
315 (pWndSetActive->style & (WS_VISIBLE|WS_DISABLED)) == WS_VISIBLE &&
316 (!(pWndSetActive->style & WS_ICONIC) /* FIXME MinMax pos? */ ) )
317 {
318 if (!(pWndSetActive->ExStyle & WS_EX_TOOLWINDOW) )
319 {
320 UserRefObjectCo(pWndSetActive, &Ref);
321 //ERR("ActivateOtherWindowMin Set FG 1\n");
322 co_IntSetForegroundWindow(pWndSetActive);
323 UserDerefObjectCo(pWndSetActive);
324 //ERR("AOWM 2 Exit Good %p\n",pWndSetActive->head.h);
325 return TRUE;
326 }
327 if (!pWndTemp ) pWndTemp = pWndSetActive;
328 }
329 if ( ActivePrev )
330 {
331 ActivePrev = FALSE;
332 pWndSetActive = pWndChild;
333 }
334 else
335 pWndSetActive = pWndSetActive->spwndNext;
336 }
337
338 if ( !FindTopWnd ) break;
339 FindTopWnd = FALSE;
340
341 if ( pWndChild )
342 {
343 pWndChild = pWndChild->spwndParent->spwndChild;
344 continue;
345 }
346
347 if (!(pWndDesk = IntGetThreadDesktopWindow(pti)))
348 {
349 pWndChild = NULL;
350 continue;
351 }
352 pWndChild = pWndDesk->spwndChild;
353 }
354
355 if ((pWndSetActive = pWndTemp))
356 {
357 UserRefObjectCo(pWndSetActive, &Ref);
358 //ERR("ActivateOtherWindowMin Set FG 2\n");
359 co_IntSetForegroundWindow(pWndSetActive);
360 UserDerefObjectCo(pWndSetActive);
361 //ERR("AOWM 3 Exit Good %p\n",pWndSetActive->head.h);
362 return TRUE;
363 }
364 //ERR("AOWM 4 Bad\n");
365 return FALSE;
366}
367
368/*******************************************************************
369 * can_activate_window
370 *
371 * Check if we can activate the specified window.
372 */
373static
375{
376 LONG style;
377
378 if (!Wnd) return FALSE;
379
380 style = Wnd->style;
381 if (!(style & WS_VISIBLE)) return FALSE;
382 if (style & WS_MINIMIZE) return FALSE;
383 if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE;
384 if (Wnd->ExStyle & WS_EX_NOACTIVATE) return FALSE;
385 return TRUE;
386 /* FIXME: This window could be disable because the child that closed
387 was a popup. */
388 //return !(style & WS_DISABLED);
389}
390
391
392/*******************************************************************
393 * WinPosActivateOtherWindow
394 *
395 * Activates window other than pWnd.
396 */
399{
400 PWND WndTo = NULL;
402
403 ASSERT_REFS_CO(Wnd);
404
405 if (IntIsDesktopWindow(Wnd))
406 {
407 //ERR("WinPosActivateOtherWindow Set Focus Msg Q No window!\n");
409 return;
410 }
411
412 /* If this is popup window, try to activate the owner first. */
413 if ((Wnd->style & WS_POPUP) && (WndTo = Wnd->spwndOwner))
414 {
415 TRACE("WPAOW Popup with Owner\n");
416 WndTo = UserGetAncestor( WndTo, GA_ROOT );
417 if (can_activate_window(WndTo)) goto done;
418 }
419
420 /* Pick a next top-level window. */
421 /* FIXME: Search for non-tooltip windows first. */
422 WndTo = Wnd;
423 for (;;)
424 {
425 if (!(WndTo = WndTo->spwndNext)) break;
426 if (can_activate_window( WndTo )) goto done;
427 }
428
429 /*
430 Fixes wine win.c:test_SetParent last ShowWindow test after popup dies.
431 Check for previous active window to bring to top.
432 */
433 if (Wnd)
434 {
435 WndTo = Wnd->head.pti->MessageQueue->spwndActivePrev;
436 if (can_activate_window( WndTo )) goto done;
437 }
438
439 // Find any window to bring to top. Works Okay for wine since it does not see X11 windows.
440 WndTo = UserGetDesktopWindow();
441 if ((WndTo == NULL) || (WndTo->spwndChild == NULL))
442 {
443 //ERR("WinPosActivateOtherWindow No window!\n");
444 return;
445 }
446 WndTo = WndTo->spwndChild;
447 for (;;)
448 {
449 if (WndTo == Wnd)
450 {
451 WndTo = NULL;
452 break;
453 }
454 if (can_activate_window( WndTo )) goto done;
455 if (!(WndTo = WndTo->spwndNext)) break;
456 }
457
458done:
459 if (WndTo) UserRefObjectCo(WndTo, &Ref);
460
462 {
463 /* ReactOS can pass WndTo = NULL to co_IntSetForegroundWindow and returns FALSE. */
464 //ERR("WinPosActivateOtherWindow Set FG 0x%p hWnd %p\n",WndTo, WndTo ? WndTo->head.h : 0);
465 if (co_IntSetForegroundWindow(WndTo))
466 {
467 if (WndTo) UserDerefObjectCo(WndTo);
468 return;
469 }
470 }
471 //ERR("WinPosActivateOtherWindow Set Active 0x%p\n",WndTo);
472 if (!UserSetActiveWindow(WndTo)) /* Ok for WndTo to be NULL here */
473 {
474 //ERR("WPAOW SA 1\n");
476 }
477 if (WndTo) UserDerefObjectCo(WndTo);
478}
479
482{
483 POINT Size;
484 RECTL Rect = *RestoreRect;
485
487 {
489 -Wnd->spwndParent->rcClient.left,
490 -Wnd->spwndParent->rcClient.top);
491 }
492
493 Size.x = Rect.left;
494 Size.y = Rect.top;
495
496 if (!Wnd->InternalPosInitialized)
497 {
498 // FIXME: Use check point Atom..
499 Wnd->InternalPos.flags = 0;
500 Wnd->InternalPos.MaxPos.x = Wnd->InternalPos.MaxPos.y = -1;
501 Wnd->InternalPos.IconPos.x = Wnd->InternalPos.IconPos.y = -1;
502 Wnd->InternalPos.NormalRect = Rect;
504 }
505
506 if (Wnd->style & WS_MINIMIZE)
507 {
508 Wnd->InternalPos.IconPos = Size;
509 Wnd->InternalPos.flags |= WPF_MININIT;
510 }
511 else if (Wnd->style & WS_MAXIMIZE)
512 {
513 Wnd->InternalPos.flags |= WPF_MAXINIT;
514
515 if ( Wnd->spwndParent == Wnd->head.rpdesk->pDeskInfo->spwnd )
516 {
518 {
519 Wnd->InternalPos.flags &= ~WPF_MAXINIT;
520 Wnd->InternalPos.MaxPos.x = Wnd->InternalPos.MaxPos.y = -1;
521 }
522 else
523 {
524 RECTL WorkArea;
525 PMONITOR pmonitor = UserMonitorFromRect(&Rect, MONITOR_DEFAULTTOPRIMARY );
526 // FIXME: support DPI aware, rcWorkDPI/Real etc..
527 WorkArea = pmonitor->rcMonitor;
528
529 if (Wnd->style & WS_MAXIMIZEBOX)
530 { // Support (Wnd->state & WNDS_HASCAPTION) || pmonitor->cFullScreen too.
531 if ((Wnd->style & WS_CAPTION) == WS_CAPTION || !(Wnd->style & (WS_CHILD | WS_POPUP)))
532 {
533 WorkArea = pmonitor->rcWork;
534 //ERR("rcWork\n");
535 }
536 }
537
538 Wnd->InternalPos.MaxPos.x = Rect.left - WorkArea.left;
539 Wnd->InternalPos.MaxPos.y = Rect.top - WorkArea.top;
540
541 /*ERR("WinPosIP 2 X %d = R.l %d - W.l %d | Y %d = R.t %d - W.t %d\n",
542 Wnd->InternalPos.MaxPos.x,
543 Rect.left, WorkArea.left,
544 Wnd->InternalPos.MaxPos.y,
545 Rect.top, WorkArea.top);*/
546 }
547 }
548 else
549 Wnd->InternalPos.MaxPos = Size;
550 }
551 else
552 {
553 Wnd->InternalPos.NormalRect = Rect;
554 }
555}
556
557// Win: _GetWindowPlacement
558BOOL
561{
562 if (!Wnd) return FALSE;
563
564 if(lpwndpl->length != sizeof(WINDOWPLACEMENT))
565 {
566 return FALSE;
567 }
568
569 lpwndpl->flags = 0;
570
572
573 lpwndpl->showCmd = SW_HIDE;
574
575 if ( Wnd->style & WS_MINIMIZE )
576 lpwndpl->showCmd = SW_SHOWMINIMIZED;
577 else
578 lpwndpl->showCmd = ( Wnd->style & WS_MAXIMIZE ) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL ;
579
580 lpwndpl->rcNormalPosition = Wnd->InternalPos.NormalRect;
581
582 if (Wnd->InternalPos.flags & WPF_MININIT) // Return if it was set!
583 {
584 lpwndpl->ptMinPosition.x = Wnd->InternalPos.IconPos.x;
585 lpwndpl->ptMinPosition.y = Wnd->InternalPos.IconPos.y;
586 }
587 else
588 lpwndpl->ptMinPosition.x = lpwndpl->ptMinPosition.y = -1;
589
590 if ( Wnd->InternalPos.flags & WPF_MAXINIT && // Return if set and not maximized to monitor!
592 {
593 lpwndpl->ptMaxPosition.x = Wnd->InternalPos.MaxPos.x;
594 lpwndpl->ptMaxPosition.y = Wnd->InternalPos.MaxPos.y;
595 }
596 else
597 lpwndpl->ptMaxPosition.x = lpwndpl->ptMaxPosition.y = -1;
598
599 if ( Wnd->spwndParent == Wnd->head.rpdesk->pDeskInfo->spwnd &&
600 !(Wnd->ExStyle & WS_EX_TOOLWINDOW))
601 {
602 PMONITOR pmonitor = UserMonitorFromRect(&lpwndpl->rcNormalPosition, MONITOR_DEFAULTTOPRIMARY );
603
604 // FIXME: support DPI aware, rcWorkDPI/Real etc..
605 if (Wnd->InternalPos.flags & WPF_MININIT)
606 {
607 lpwndpl->ptMinPosition.x -= (pmonitor->rcWork.left - pmonitor->rcMonitor.left);
608 lpwndpl->ptMinPosition.y -= (pmonitor->rcWork.top - pmonitor->rcMonitor.top);
609 }
611 pmonitor->rcMonitor.left - pmonitor->rcWork.left,
612 pmonitor->rcMonitor.top - pmonitor->rcWork.top);
613 }
614
615 if ( Wnd->InternalPos.flags & WPF_RESTORETOMAXIMIZED || Wnd->style & WS_MAXIMIZE )
616 lpwndpl->flags |= WPF_RESTORETOMAXIMIZED;
617
618 if ( ((Wnd->style & (WS_CHILD|WS_POPUP)) == WS_CHILD) && Wnd->InternalPos.flags & WPF_SETMINPOSITION)
619 lpwndpl->flags |= WPF_SETMINPOSITION;
620
621 return TRUE;
622}
623
624/* make sure the specified rect is visible on screen */
626{
627 PMONITOR pmonitor = UserMonitorFromRect( rect, MONITOR_DEFAULTTONEAREST ); // Wine uses this.
628
629 // FIXME: support DPI aware, rcWorkDPI/Real etc..
630 if (!pmonitor) return;
631 /* FIXME: map coordinates from rcWork to rcMonitor */
632 if (rect->right <= pmonitor->rcWork.left)
633 {
634 rect->right += pmonitor->rcWork.left - rect->left;
635 rect->left = pmonitor->rcWork.left;
636 }
637 else if (rect->left >= pmonitor->rcWork.right)
638 {
639 rect->left += pmonitor->rcWork.right - rect->right;
640 rect->right = pmonitor->rcWork.right;
641 }
642 if (rect->bottom <= pmonitor->rcWork.top)
643 {
644 rect->bottom += pmonitor->rcWork.top - rect->top;
645 rect->top = pmonitor->rcWork.top;
646 }
647 else if (rect->top >= pmonitor->rcWork.bottom)
648 {
649 rect->top += pmonitor->rcWork.bottom - rect->bottom;
650 rect->bottom = pmonitor->rcWork.bottom;
651 }
652}
653
654/* make sure the specified point is visible on screen */
656{
657 RECT rect;
658
659 RECTL_vSetRect( &rect, pt->x, pt->y, pt->x + 1, pt->y + 1 );
661 pt->x = rect.left;
662 pt->y = rect.top;
663}
664
667{
668 BOOL sAsync;
669 UINT SWP_Flags;
670
674
675 if (!Wnd || Wnd == Wnd->head.rpdesk->pDeskInfo->spwnd) return FALSE;
676
677 if ( Flags & PLACE_MIN ) Wnd->InternalPos.IconPos = wpl->ptMinPosition;
678 if ( Flags & PLACE_MAX ) Wnd->InternalPos.MaxPos = wpl->ptMaxPosition;
679 if ( Flags & PLACE_RECT) Wnd->InternalPos.NormalRect = wpl->rcNormalPosition;
680
681 SWP_Flags = SWP_NOZORDER | SWP_NOACTIVATE | ((wpl->flags & WPF_ASYNCWINDOWPLACEMENT) ? SWP_ASYNCWINDOWPOS : 0);
682
683 if (Wnd->style & WS_MINIMIZE )
684 {
685 if (Flags & PLACE_MIN || Wnd->InternalPos.flags & WPF_SETMINPOSITION)
686 {
688 wpl->ptMinPosition.x, wpl->ptMinPosition.y, 0, 0,
689 SWP_NOSIZE | SWP_Flags);
690 Wnd->InternalPos.flags |= WPF_MININIT;
691 }
692 }
693 else if (Wnd->style & WS_MAXIMIZE )
694 {
695 if (Flags & PLACE_MAX)
696 {
698 wpl->ptMaxPosition.x, wpl->ptMaxPosition.y, 0, 0,
699 SWP_NOSIZE | SWP_Flags);
700 Wnd->InternalPos.flags |= WPF_MAXINIT;
701 }
702 }
703 else if (Flags & PLACE_RECT)
704 {
709 SWP_Flags);
710 }
711
712 sAsync = (Wnd->head.pti->MessageQueue != gptiCurrent->MessageQueue && wpl->flags & WPF_ASYNCWINDOWPLACEMENT);
713
714 if ( sAsync )
716 else
717 co_WinPosShowWindow(Wnd, wpl->showCmd);
718
719 if ( Wnd->style & WS_MINIMIZE && !sAsync )
720 {
721 if ( wpl->flags & WPF_SETMINPOSITION )
722 Wnd->InternalPos.flags |= WPF_SETMINPOSITION;
723
724 if ( wpl->flags & WPF_RESTORETOMAXIMIZED )
726 }
727 return TRUE;
728}
729
730UINT
733{
734 RECTL rectParent;
735 PWND Child;
736 INT x, y, xspacing, yspacing, sx, sy;
737
739
740 IntGetClientRect( parent, &rectParent );
741 // FIXME: Support Minimize Metrics gspv.mm.iArrange.
742 // Default: ARW_BOTTOMLEFT
743 x = rectParent.left;
744 y = rectParent.bottom;
745
748
749 Child = parent->spwndChild;
750 while(Child)
751 {
752 if((Child->style & WS_MINIMIZE) != 0 )
753 {
755 UserRefObjectCo(Child, &Ref);
756
758 sy = y - yspacing - UserGetSystemMetrics(SM_CYBORDER);
759
760 Child->InternalPos.IconPos.x = sx;
761 Child->InternalPos.IconPos.y = sy;
762 Child->InternalPos.flags |= WPF_MININIT;
763
765
767
768 if (x <= rectParent.right - xspacing)
769 x += xspacing;
770 else
771 {
772 x = rectParent.left;
773 y -= yspacing;
774 }
775 }
776 Child = Child->spwndNext;
777 }
778 return yspacing;
779}
780
781static VOID FASTCALL
783{
784 RECT rectParent;
785 PWND pwndChild, pwndParent;
786 int x, y, xspacing, yspacing;
787
788 pwndParent = Window->spwndParent;
789 if (UserIsDesktopWindow(pwndParent))
790 {
791 ERR("FIXME: Parent is Desktop, Min off screen!\n");
792 /* FIXME: ReactOS doesn't support iconic minimize to desktop */
793 Pos->x = Pos->y = -32000;
794 Window->InternalPos.flags |= WPF_MININIT;
795 Window->InternalPos.IconPos.x = Pos->x;
796 Window->InternalPos.IconPos.y = Pos->y;
797 return;
798 }
799
800 IntGetClientRect( pwndParent, &rectParent );
801 // FIXME: Support Minimize Metrics gspv.mm.iArrange.
802 // Default: ARW_BOTTOMLEFT
803 x = rectParent.left;
804 y = rectParent.bottom;
805
808
809 // Set to default position when minimized.
811 Pos->y = y - yspacing - UserGetSystemMetrics(SM_CYBORDER);
812
813 for (pwndChild = pwndParent->spwndChild; pwndChild; pwndChild = pwndChild->spwndNext)
814 {
815 if (pwndChild == Window) continue;
816
817 if ((pwndChild->style & (WS_VISIBLE|WS_MINIMIZE)) != (WS_VISIBLE|WS_MINIMIZE) )
818 {
819 continue;
820 }
821
822 if ( pwndChild->InternalPos.IconPos.x != Pos->x && pwndChild->InternalPos.IconPos.y != Pos->y )
823 {
824 break;
825 }
826 if (x <= rectParent.right - xspacing)
827 x += xspacing;
828 else
829 {
830 x = rectParent.left;
831 y -= yspacing;
832 }
834 Pos->y = y - yspacing - UserGetSystemMetrics(SM_CYBORDER);
835 }
836
837 Window->InternalPos.IconPos.x = Pos->x;
838 Window->InternalPos.IconPos.y = Pos->y;
839 Window->InternalPos.flags |= WPF_MININIT;
840 TRACE("Position is set! X:%d Y:%d\n",Pos->x,Pos->y);
841 return;
842}
843
844BOOL
846{
847 if (Style & WS_MINIMIZE)
848 return TRUE;
850 return TRUE;
852 return FALSE;
853 if (Style & WS_THICKFRAME)
854 return TRUE;
855 Style &= WS_CAPTION;
856 if (Style == WS_DLGFRAME || Style == WS_CAPTION)
857 return TRUE;
858 return FALSE;
859}
860
863{
864 if(HAS_DLGFRAME(Wnd->style, Wnd->ExStyle) && !(Wnd->style & WS_MINIMIZE))
865 {
868 }
869 else
870 {
871 if(HAS_THICKFRAME(Wnd->style, Wnd->ExStyle)&& !(Wnd->style & WS_MINIMIZE))
872 {
875 }
876 else if(HAS_THINFRAME(Wnd->style, Wnd->ExStyle))
877 {
880 }
881 else
882 {
883 *cx = *cy = 0;
884 }
885 }
886}
887
888VOID
890{
891 DWORD Border = 0;
892
894 Border += 2;
896 Border += 1; /* for the outer frame always present */
897 if ((ExStyle & WS_EX_CLIENTEDGE) && WithClient)
898 Border += 2;
900 Border ++; /* The other border */
901 Size->cx = Size->cy = Border;
902 if ((Style & WS_THICKFRAME) && !(Style & WS_MINIMIZE)) /* The resize border */
903 {
906 }
909}
910
911//
912// Fix CORE-5177
913// See winetests:user32:win.c:wine_AdjustWindowRectEx,
914// Simplified version.
915//
917{
918 DWORD adjust = 0;
919
920 if ( ExStyle & WS_EX_WINDOWEDGE ) // 1st
921 adjust = 2; /* outer */
922 else if ( ExStyle & WS_EX_STATICEDGE ) // 2nd
923 adjust = 1; /* for the outer frame always present */
924
926 adjust += 2;
927
929 adjust++; /* The other border */
930
931 return adjust;
932}
933
936 POINT* MinTrack, POINT* MaxTrack)
937{
938 MINMAXINFO MinMax;
939 PMONITOR monitor;
940 INT xinc, yinc;
941 LONG style = Window->style;
942 LONG adjustedStyle;
943 LONG exstyle = Window->ExStyle;
944 RECT rc;
945 DWORD adjust;
946
948
949 /* Compute default values */
950
951 rc = Window->rcWindow;
952 MinMax.ptReserved.x = rc.left;
953 MinMax.ptReserved.y = rc.top;
954
955 if ((style & WS_CAPTION) == WS_CAPTION)
956 adjustedStyle = style & ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
957 else
958 adjustedStyle = style;
959
960 if (Window->spwndParent)
961 IntGetClientRect(Window->spwndParent, &rc);
962
963 adjust = IntGetWindowBorders(adjustedStyle, exstyle);
964
965 // Handle special case while maximized. CORE-15893
966 if ((adjustedStyle & WS_THICKFRAME) && !(adjustedStyle & WS_CHILD) && !(adjustedStyle & WS_MINIMIZE))
967 adjust += 1;
968
969 xinc = yinc = adjust;
970
971 if ((adjustedStyle & WS_THICKFRAME) && (adjustedStyle & WS_CHILD) && !(adjustedStyle & WS_MINIMIZE))
972 {
975 }
976
980
981 xinc = -rc.left;
982 yinc = -rc.top;
983
984 MinMax.ptMaxSize.x = rc.right - rc.left;
985 MinMax.ptMaxSize.y = rc.bottom - rc.top;
986 if (style & (WS_DLGFRAME | WS_BORDER))
987 {
990 }
991 else
992 {
993 MinMax.ptMinTrackSize.x = 2 * xinc;
994 MinMax.ptMinTrackSize.y = 2 * yinc;
995 }
998 MinMax.ptMaxPosition.x = -xinc;
999 MinMax.ptMaxPosition.y = -yinc;
1000
1001 if (!EMPTYPOINT(Window->InternalPos.MaxPos)) MinMax.ptMaxPosition = Window->InternalPos.MaxPos;
1002
1003 co_IntSendMessage(Window->head.h, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax);
1004
1005 /* if the app didn't change the values, adapt them for the current monitor */
1006 if ((monitor = UserGetPrimaryMonitor()))
1007 {
1008 RECT rc_work;
1009
1010 rc_work = monitor->rcMonitor;
1011
1012 if (style & WS_MAXIMIZEBOX)
1013 {
1014 if ((style & WS_CAPTION) == WS_CAPTION || !(style & (WS_CHILD | WS_POPUP)))
1015 rc_work = monitor->rcWork;
1016 }
1017
1018 if (MinMax.ptMaxSize.x == UserGetSystemMetrics(SM_CXSCREEN) + 2 * xinc &&
1019 MinMax.ptMaxSize.y == UserGetSystemMetrics(SM_CYSCREEN) + 2 * yinc)
1020 {
1021 MinMax.ptMaxSize.x = (rc_work.right - rc_work.left) + 2 * xinc;
1022 MinMax.ptMaxSize.y = (rc_work.bottom - rc_work.top) + 2 * yinc;
1023 }
1024 if (MinMax.ptMaxPosition.x == -xinc && MinMax.ptMaxPosition.y == -yinc)
1025 {
1026 MinMax.ptMaxPosition.x = rc_work.left - xinc;
1027 MinMax.ptMaxPosition.y = rc_work.top - yinc;
1028 }
1029 if (MinMax.ptMaxSize.x >= (monitor->rcMonitor.right - monitor->rcMonitor.left) &&
1030 MinMax.ptMaxSize.y >= (monitor->rcMonitor.bottom - monitor->rcMonitor.top) )
1031 {
1033 }
1034 else
1035 Window->state &= ~WNDS_MAXIMIZESTOMONITOR;
1036 }
1037
1038
1039 MinMax.ptMaxTrackSize.x = max(MinMax.ptMaxTrackSize.x,
1040 MinMax.ptMinTrackSize.x);
1041 MinMax.ptMaxTrackSize.y = max(MinMax.ptMaxTrackSize.y,
1042 MinMax.ptMinTrackSize.y);
1043
1044 if (MaxSize)
1045 *MaxSize = MinMax.ptMaxSize;
1046 if (MaxPos)
1047 *MaxPos = MinMax.ptMaxPosition;
1048 if (MinTrack)
1049 *MinTrack = MinMax.ptMinTrackSize;
1050 if (MaxTrack)
1051 *MaxTrack = MinMax.ptMaxTrackSize;
1052
1053 return 0; // FIXME: What does it return? Wine returns MINMAXINFO.
1054}
1055
1056static
1057BOOL
1059{
1060 PWND ParentWnd = Child->spwndParent;
1061
1062 while (ParentWnd)
1063 {
1064 if (ParentWnd->style & WS_CLIPCHILDREN)
1065 break;
1066
1067 if (ParentWnd->hrgnUpdate != 0)
1068 {
1069 IntInvalidateWindows( ParentWnd,
1072 }
1073
1074 ParentWnd = ParentWnd->spwndParent;
1075 }
1076
1077 return TRUE;
1078}
1079
1080static
1082FixClientRect(PRECTL ClientRect, PRECTL WindowRect)
1083{
1084 if (ClientRect->left < WindowRect->left)
1085 {
1086 ClientRect->left = WindowRect->left;
1087 }
1088 else if (WindowRect->right < ClientRect->left)
1089 {
1090 ClientRect->left = WindowRect->right;
1091 }
1092 if (ClientRect->right < WindowRect->left)
1093 {
1094 ClientRect->right = WindowRect->left;
1095 }
1096 else if (WindowRect->right < ClientRect->right)
1097 {
1098 ClientRect->right = WindowRect->right;
1099 }
1100 if (ClientRect->top < WindowRect->top)
1101 {
1102 ClientRect->top = WindowRect->top;
1103 }
1104 else if (WindowRect->bottom < ClientRect->top)
1105 {
1106 ClientRect->top = WindowRect->bottom;
1107 }
1108 if (ClientRect->bottom < WindowRect->top)
1109 {
1110 ClientRect->bottom = WindowRect->top;
1111 }
1112 else if (WindowRect->bottom < ClientRect->bottom)
1113 {
1114 ClientRect->bottom = WindowRect->bottom;
1115 }
1116}
1117/***********************************************************************
1118 * get_valid_rects
1119 *
1120 * Compute the valid rects from the old and new client rect and WVR_* flags.
1121 * Helper for WM_NCCALCSIZE handling.
1122 */
1123static
1125get_valid_rects( RECTL *old_client, RECTL *new_client, UINT flags, RECTL *valid )
1126{
1127 int cx, cy;
1128
1129 if (flags & WVR_REDRAW)
1130 {
1133 return;
1134 }
1135
1136 if (flags & WVR_VALIDRECTS)
1137 {
1138 if (!RECTL_bIntersectRect( &valid[0], &valid[0], new_client ) ||
1139 !RECTL_bIntersectRect( &valid[1], &valid[1], old_client ))
1140 {
1143 return;
1144 }
1146 }
1147 else
1148 {
1149 valid[0] = *new_client;
1150 valid[1] = *old_client;
1151 }
1152
1153 /* make sure the rectangles have the same size */
1154 cx = min( valid[0].right - valid[0].left, valid[1].right - valid[1].left );
1155 cy = min( valid[0].bottom - valid[0].top, valid[1].bottom - valid[1].top );
1156
1157 if (flags & WVR_ALIGNBOTTOM)
1158 {
1159 valid[0].top = valid[0].bottom - cy;
1160 valid[1].top = valid[1].bottom - cy;
1161 }
1162 else
1163 {
1164 valid[0].bottom = valid[0].top + cy;
1165 valid[1].bottom = valid[1].top + cy;
1166 }
1167 if (flags & WVR_ALIGNRIGHT)
1168 {
1169 valid[0].left = valid[0].right - cx;
1170 valid[1].left = valid[1].right - cx;
1171 }
1172 else
1173 {
1174 valid[0].right = valid[0].left + cx;
1175 valid[1].right = valid[1].left + cx;
1176 }
1177}
1178
1179static
1181co_WinPosDoNCCALCSize(PWND Window, PWINDOWPOS WinPos, RECTL* WindowRect, RECTL* ClientRect, RECTL* validRects)
1182{
1183 PWND Parent;
1184 UINT wvrFlags = 0;
1185
1187
1188 /* Send WM_NCCALCSIZE message to get new client area */
1189 if ((WinPos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE)
1190 {
1192 WINDOWPOS winposCopy;
1193
1194 params.rgrc[0] = *WindowRect; // new coordinates of a window that has been moved or resized
1195 params.rgrc[1] = Window->rcWindow; // window before it was moved or resized
1196 params.rgrc[2] = Window->rcClient; // client area before the window was moved or resized
1197
1198 Parent = Window->spwndParent;
1199 if (0 != (Window->style & WS_CHILD) && Parent)
1200 {
1201 RECTL_vOffsetRect(&(params.rgrc[0]), - Parent->rcClient.left, - Parent->rcClient.top);
1202 RECTL_vOffsetRect(&(params.rgrc[1]), - Parent->rcClient.left, - Parent->rcClient.top);
1203 RECTL_vOffsetRect(&(params.rgrc[2]), - Parent->rcClient.left, - Parent->rcClient.top);
1204 }
1205
1206 params.lppos = &winposCopy;
1207 winposCopy = *WinPos;
1208
1209 wvrFlags = co_IntSendMessage(Window->head.h, WM_NCCALCSIZE, TRUE, (LPARAM) &params);
1210
1211 /* If the application send back garbage, ignore it */
1212 if (params.rgrc[0].left <= params.rgrc[0].right &&
1213 params.rgrc[0].top <= params.rgrc[0].bottom)
1214 {
1215 *ClientRect = params.rgrc[0]; // First rectangle contains the coordinates of the new client rectangle resulting from the move or resize
1216 if ((Window->style & WS_CHILD) && Parent)
1217 {
1218 RECTL_vOffsetRect(ClientRect, Parent->rcClient.left, Parent->rcClient.top);
1219 }
1220 FixClientRect(ClientRect, WindowRect);
1221 }
1222
1223 if (ClientRect->left != Window->rcClient.left ||
1224 ClientRect->top != Window->rcClient.top)
1225 {
1226 WinPos->flags &= ~SWP_NOCLIENTMOVE;
1227 }
1228
1229 if (ClientRect->right - ClientRect->left != Window->rcClient.right - Window->rcClient.left)
1230 {
1231 WinPos->flags &= ~SWP_NOCLIENTSIZE;
1232 }
1233 else
1234 wvrFlags &= ~WVR_HREDRAW;
1235
1236 if (ClientRect->bottom - ClientRect->top != Window->rcClient.bottom - Window->rcClient.top)
1237 {
1238 WinPos->flags &= ~SWP_NOCLIENTSIZE;
1239 }
1240 else
1241 wvrFlags &= ~WVR_VREDRAW;
1242
1243 validRects[0] = params.rgrc[1]; // second rectangle contains the valid destination rectangle
1244 validRects[1] = params.rgrc[2]; // third rectangle contains the valid source rectangle
1245 }
1246 else
1247 {
1248 if (!(WinPos->flags & SWP_NOMOVE) &&
1249 (ClientRect->left != Window->rcClient.left ||
1250 ClientRect->top != Window->rcClient.top))
1251 {
1252 WinPos->flags &= ~SWP_NOCLIENTMOVE;
1253 }
1254 }
1255
1257 {
1258 RECTL_vSetEmptyRect( &validRects[0] );
1259 RECTL_vSetEmptyRect( &validRects[1] );
1260 }
1261 else get_valid_rects( &Window->rcClient, ClientRect, wvrFlags, validRects );
1262
1263 return wvrFlags;
1264}
1265
1266static
1269 PWINDOWPOS WinPos,
1270 PRECTL WindowRect,
1271 PRECTL ClientRect)
1272{
1274
1275 /* Send WM_WINDOWPOSCHANGING message */
1276
1277 if (!(WinPos->flags & SWP_NOSENDCHANGING)
1278 && !((WinPos->flags & SWP_AGG_NOCLIENTCHANGE) && (WinPos->flags & SWP_SHOWWINDOW)))
1279 {
1280 TRACE("Sending WM_WINDOWPOSCHANGING to hwnd %p flags %04x.\n", Window->head.h,WinPos->flags);
1281 co_IntSendMessage(Window->head.h, WM_WINDOWPOSCHANGING, 0, (LPARAM) WinPos);
1282 }
1283
1284 /* Calculate new position and size */
1285
1286 *WindowRect = Window->rcWindow;
1287 *ClientRect = (Window->style & WS_MINIMIZE) ? Window->rcWindow : Window->rcClient;
1288
1289 if (!(WinPos->flags & SWP_NOSIZE))
1290 {
1291 if (Window->style & WS_MINIMIZE)
1292 {
1293 WindowRect->right = WindowRect->left + UserGetSystemMetrics(SM_CXMINIMIZED);
1294 WindowRect->bottom = WindowRect->top + UserGetSystemMetrics(SM_CYMINIMIZED);
1295 }
1296 else
1297 {
1298 WindowRect->right = WindowRect->left + WinPos->cx;
1299 WindowRect->bottom = WindowRect->top + WinPos->cy;
1300 }
1301 }
1302
1303 if (!(WinPos->flags & SWP_NOMOVE))
1304 {
1305 INT X, Y;
1306 PWND Parent;
1307 X = WinPos->x;
1308 Y = WinPos->y;
1309
1310 Parent = Window->spwndParent;
1311
1312 // Parent child position issue is in here. SetParent_W7 test CORE-6651.
1313 if (//((Window->style & WS_CHILD) != 0) && <- Fixes wine msg test_SetParent: "rects do not match", the last test.
1314 Parent &&
1315 Parent != Window->head.rpdesk->pDeskInfo->spwnd)
1316 {
1317 TRACE("Not SWP_NOMOVE 1 Parent client offset X %d Y %d\n",X,Y);
1318 X += Parent->rcClient.left;
1319 Y += Parent->rcClient.top;
1320 TRACE("Not SWP_NOMOVE 2 Parent client offset X %d Y %d\n",X,Y);
1321 }
1322
1323 WindowRect->left = X;
1324 WindowRect->top = Y;
1325 WindowRect->right += X - Window->rcWindow.left;
1326 WindowRect->bottom += Y - Window->rcWindow.top;
1327
1328 RECTL_vOffsetRect(ClientRect, X - Window->rcWindow.left,
1329 Y - Window->rcWindow.top);
1330 }
1332
1333 TRACE( "hwnd %p, after %p, swp %d,%d %dx%d flags %08x\n",
1334 WinPos->hwnd, WinPos->hwndInsertAfter, WinPos->x, WinPos->y,
1335 WinPos->cx, WinPos->cy, WinPos->flags );
1336 TRACE("WindowRect: %d %d %d %d\n", WindowRect->left,WindowRect->top,WindowRect->right,WindowRect->bottom);
1337 TRACE("ClientRect: %d %d %d %d\n", ClientRect->left,ClientRect->top,ClientRect->right,ClientRect->bottom);
1338
1339 return TRUE;
1340}
1341
1342/*
1343 * Fix Z order taking into account owned popups -
1344 * basically we need to maintain them above the window that owns them
1345 *
1346 * FIXME: hide/show owned popups when owner visibility changes.
1347 *
1348 * ReactOS: See bug CORE-6129 and CORE-6554.
1349 *
1350 */
1352 // Pass all the win:test_children/popup_zorder tests except "move hwnd_F and its popups down" which is if'ed out.
1353 // Side effect, breaks more of the DeferWindowPos api tests, but wine breaks more!!!!
1354static
1357{
1358 HWND *List = NULL;
1359 HWND Owner;
1360 LONG Style;
1361 PWND DesktopWindow, ChildObject;
1362 int i;
1363
1364 TRACE("(%p) hInsertAfter = %p\n", Window, hWndInsertAfter );
1365
1366 Style = Window->style;
1367
1368 if (Style & WS_CHILD)
1369 {
1370 TRACE("Window is child\n");
1371 return hWndInsertAfter;
1372 }
1373
1374 Owner = Window->spwndOwner ? Window->spwndOwner->head.h : NULL;
1375
1376 if (Owner)
1377 {
1378 /* Make sure this popup stays above the owner */
1379
1380 if (hWndInsertAfter != HWND_TOPMOST)
1381 {
1384
1385 if (List != NULL)
1386 {
1387 for (i = 0; List[i]; i++)
1388 {
1389 BOOL topmost = FALSE;
1390
1391 ChildObject = ValidateHwndNoErr(List[i]);
1392 if (ChildObject)
1393 {
1394 topmost = (ChildObject->ExStyle & WS_EX_TOPMOST) != 0;
1395 }
1396
1397 if (List[i] == Owner)
1398 {
1399 /* We found its Owner, so we must handle it here. */
1400 if (i > 0)
1401 {
1402 if (List[i - 1] != UserHMGetHandle(Window))
1403 {
1404 /*
1405 * If the popup to be inserted is not already just
1406 * before the Owner, insert it there. The modified
1407 * hWndInsertAfter will be handled below.
1408 *
1409 * (NOTE: Do not allow hWndInsertAfter to become equal
1410 * to the popup's window handle, as this would cause
1411 * the popup to link to itself).
1412 */
1413 hWndInsertAfter = List[i - 1];
1414 }
1415 else
1416 {
1417 /* If the popup to be inserted is already
1418 * before the Owner, we are done. */
1420 return hWndInsertAfter;
1421 }
1422 }
1423 else
1424 {
1425 hWndInsertAfter = topmost ? HWND_TOPMOST : HWND_TOP;
1426 }
1427 break;
1428 }
1429
1430 if (hWndInsertAfter == HWND_TOP || hWndInsertAfter == HWND_NOTOPMOST)
1431 {
1432 if (!topmost) break;
1433 }
1434 else if (List[i] == hWndInsertAfter) break;
1435 }
1436 }
1437 else
1438 return hWndInsertAfter;
1439 }
1440 }
1441
1442 if (hWndInsertAfter == HWND_BOTTOM)
1443 {
1444 ERR("Window is HWND_BOTTOM hwnd %p\n",hWndInsertAfter);
1446 goto done;
1447 }
1448
1449 if (!List)
1450 {
1453 }
1454
1455 if (List != NULL)
1456 {
1457 i = 0;
1458
1459 if (hWndInsertAfter == HWND_TOP || hWndInsertAfter == HWND_NOTOPMOST)
1460 {
1461 if (hWndInsertAfter == HWND_NOTOPMOST || !(Window->ExStyle & WS_EX_TOPMOST))
1462 {
1463 TRACE("skip all the topmost windows\n");
1464 /* skip all the topmost windows */
1465 while (List[i] &&
1466 (ChildObject = ValidateHwndNoErr(List[i])) &&
1467 (ChildObject->ExStyle & WS_EX_TOPMOST)) i++;
1468 }
1469 }
1470 else if (hWndInsertAfter != HWND_TOPMOST)
1471 {
1472 /* skip windows that are already placed correctly */
1473 for (i = 0; List[i]; i++)
1474 {
1475 if (List[i] == hWndInsertAfter) break;
1476 if (List[i] == UserHMGetHandle(Window))
1477 {
1479 goto done; /* nothing to do if window is moving backwards in z-order */
1480 }
1481 }
1482 }
1483
1484 for (; List[i]; i++)
1485 {
1486 PWND Wnd;
1488
1489 if (List[i] == UserHMGetHandle(Window))
1490 break;
1491
1492 if (!(Wnd = ValidateHwndNoErr(List[i])))
1493 continue;
1494
1495 Owner = Wnd->spwndOwner ? Wnd->spwndOwner->head.h : NULL;
1496
1497 if (Owner != UserHMGetHandle(Window)) continue;
1498
1499 UserRefObjectCo(Wnd, &Ref);
1500 TRACE( "moving %p owned by %p after %p\n", List[i], UserHMGetHandle(Window), hWndInsertAfter );
1501 co_WinPosSetWindowPos(Wnd, hWndInsertAfter, 0, 0, 0, 0,
1503
1504 UserDerefObjectCo(Wnd);
1505 hWndInsertAfter = List[i];
1506 }
1508 }
1509done:
1510 return hWndInsertAfter;
1511}
1513
1514/***********************************************************************
1515 * WinPosInternalMoveWindow
1516 *
1517 * Update WindowRect and ClientRect of Window and all of its children
1518 * We keep both WindowRect and ClientRect in screen coordinates internally
1519 */
1520static
1523{
1524 PWND Child;
1525
1526 ASSERT(Window != Window->spwndChild);
1527 TRACE("InternalMoveWin X %d Y %d\n", MoveX, MoveY);
1528
1529 Window->rcWindow.left += MoveX;
1530 Window->rcWindow.right += MoveX;
1531 Window->rcWindow.top += MoveY;
1532 Window->rcWindow.bottom += MoveY;
1533
1534 Window->rcClient.left += MoveX;
1535 Window->rcClient.right += MoveX;
1536 Window->rcClient.top += MoveY;
1537 Window->rcClient.bottom += MoveY;
1538
1539 for(Child = Window->spwndChild; Child; Child = Child->spwndNext)
1540 {
1541 WinPosInternalMoveWindow(Child, MoveX, MoveY);
1542 }
1543}
1544
1545/*
1546 * WinPosFixupSWPFlags
1547 *
1548 * Fix redundant flags and values in the WINDOWPOS structure.
1549 */
1550static
1553{
1554 PWND Parent;
1555 POINT pt;
1556
1557 /* Finally make sure that all coordinates are valid */
1558 if (WinPos->x < -32768) WinPos->x = -32768;
1559 else if (WinPos->x > 32767) WinPos->x = 32767;
1560 if (WinPos->y < -32768) WinPos->y = -32768;
1561 else if (WinPos->y > 32767) WinPos->y = 32767;
1562
1563 WinPos->cx = max(WinPos->cx, 0);
1564 WinPos->cy = max(WinPos->cy, 0);
1565
1567 if (!IntIsWindowVisible( Parent ) &&
1568 /* Fix B : wine msg test_SetParent:WmSetParentSeq_2:25 wParam bits! */
1570
1571 if (Wnd->style & WS_VISIBLE) WinPos->flags &= ~SWP_SHOWWINDOW;
1572 else
1573 {
1574 WinPos->flags &= ~SWP_HIDEWINDOW;
1575 if (!(WinPos->flags & SWP_SHOWWINDOW)) WinPos->flags |= SWP_NOREDRAW;
1576 }
1577
1578 /* Check for right size */
1579 if (Wnd->rcWindow.right - Wnd->rcWindow.left == WinPos->cx &&
1580 Wnd->rcWindow.bottom - Wnd->rcWindow.top == WinPos->cy)
1581 {
1582 WinPos->flags |= SWP_NOSIZE;
1583 }
1584
1585 pt.x = WinPos->x;
1586 pt.y = WinPos->y;
1588 TRACE("WPFU C2S wpx %d wpy %d ptx %d pty %d\n",WinPos->x,WinPos->y,pt.x,pt.y);
1589 /* Check for right position */
1590 if (Wnd->rcWindow.left == pt.x && Wnd->rcWindow.top == pt.y)
1591 {
1592 //ERR("In right pos\n");
1593 WinPos->flags |= SWP_NOMOVE;
1594 }
1595
1596 if ( WinPos->hwnd != UserGetForegroundWindow() && (Wnd->style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
1597 {
1598 /* Bring to the top when activating */
1599 if (!(WinPos->flags & (SWP_NOACTIVATE|SWP_HIDEWINDOW)) &&
1600 (WinPos->flags & SWP_NOZORDER ||
1601 (WinPos->hwndInsertAfter != HWND_TOPMOST && WinPos->hwndInsertAfter != HWND_NOTOPMOST)))
1602 {
1603 WinPos->flags &= ~SWP_NOZORDER;
1604 WinPos->hwndInsertAfter = (0 != (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_TOP);
1605 }
1606 }
1607
1608 /* Check hwndInsertAfter */
1609 if (!(WinPos->flags & SWP_NOZORDER))
1610 {
1611 /* Fix sign extension */
1612 if (WinPos->hwndInsertAfter == (HWND)0xffff)
1613 {
1614 WinPos->hwndInsertAfter = HWND_TOPMOST;
1615 }
1616 else if (WinPos->hwndInsertAfter == (HWND)0xfffe)
1617 {
1619 }
1620
1621 if (WinPos->hwndInsertAfter == HWND_TOP)
1622 {
1623 /* Keep it topmost when it's already topmost */
1624 if ((Wnd->ExStyle & WS_EX_TOPMOST) != 0)
1625 WinPos->hwndInsertAfter = HWND_TOPMOST;
1626
1627 if (IntGetWindow(WinPos->hwnd, GW_HWNDFIRST) == WinPos->hwnd)
1628 {
1629 WinPos->flags |= SWP_NOZORDER;
1630 }
1631 }
1632 else if (WinPos->hwndInsertAfter == HWND_BOTTOM)
1633 {
1634 if (!(Wnd->ExStyle & WS_EX_TOPMOST) && IntGetWindow(WinPos->hwnd, GW_HWNDLAST) == WinPos->hwnd)
1635 WinPos->flags |= SWP_NOZORDER;
1636 }
1637 else if (WinPos->hwndInsertAfter == HWND_TOPMOST)
1638 {
1639 if ((Wnd->ExStyle & WS_EX_TOPMOST) && IntGetWindow(WinPos->hwnd, GW_HWNDFIRST) == WinPos->hwnd)
1640 WinPos->flags |= SWP_NOZORDER;
1641 }
1642 else if (WinPos->hwndInsertAfter == HWND_NOTOPMOST)
1643 {
1644 if (!(Wnd->ExStyle & WS_EX_TOPMOST))
1645 WinPos->flags |= SWP_NOZORDER;
1646 }
1647 else /* hwndInsertAfter must be a sibling of the window */
1648 {
1649 PWND InsAfterWnd;
1650
1651 InsAfterWnd = ValidateHwndNoErr(WinPos->hwndInsertAfter);
1652 if(!InsAfterWnd)
1653 {
1654 return TRUE;
1655 }
1656
1657 if (InsAfterWnd->spwndParent != Wnd->spwndParent)
1658 {
1659 /* Note from wine User32 Win test_SetWindowPos:
1660 "Returns TRUE also for windows that are not siblings"
1661 "Does not seem to do anything even without passing flags, still returns TRUE"
1662 "Same thing the other way around."
1663 ".. and with these windows."
1664 */
1665 return FALSE;
1666 }
1667 else
1668 {
1669 /*
1670 * We don't need to change the Z order of hwnd if it's already
1671 * inserted after hwndInsertAfter or when inserting hwnd after
1672 * itself.
1673 */
1674 if ((WinPos->hwnd == WinPos->hwndInsertAfter) ||
1675 ((InsAfterWnd->spwndNext) && (WinPos->hwnd == InsAfterWnd->spwndNext->head.h)))
1676 {
1677 WinPos->flags |= SWP_NOZORDER;
1678 }
1679 }
1680 }
1681 }
1682
1683 return TRUE;
1684}
1685
1686//
1687// This is a NC HACK fix for forcing painting of non client areas.
1688// Further troubleshooting in painting.c is required to remove this hack.
1689// See CORE-7166 & CORE-15934
1690//
1691VOID
1693{
1694 HDC hDC;
1695 PREGION RgnUpdate;
1696 UINT RgnType;
1697 BOOL Create = FALSE;
1698
1699 if (Wnd->hrgnUpdate == NULL)
1700 {
1701 Wnd->hrgnUpdate = NtGdiCreateRectRgn(0, 0, 0, 0);
1703 Create = TRUE;
1704 }
1705
1706 if (Wnd->hrgnUpdate != HRGN_WINDOW)
1707 {
1708 RgnUpdate = REGION_LockRgn(Wnd->hrgnUpdate);
1709 if (RgnUpdate)
1710 {
1711 RgnType = IntGdiCombineRgn(RgnUpdate, RgnUpdate, pRgn, RGN_OR);
1712 REGION_UnlockRgn(RgnUpdate);
1713 if (RgnType == NULLREGION)
1714 {
1717 Wnd->hrgnUpdate = NULL;
1718 Create = FALSE;
1719 }
1720 }
1721 }
1722
1723 IntSendNCPaint( Wnd, hRgn ); // Region can be deleted by the application.
1724
1725 if (Wnd->hrgnUpdate)
1726 {
1727 hDC = UserGetDCEx( Wnd,
1728 Wnd->hrgnUpdate,
1730
1732 // Kill the loop, so Clear before we send.
1734 {
1736 }
1737 UserReleaseDC(Wnd, hDC, FALSE);
1738 }
1739
1740 if (Create)
1741 {
1744 Wnd->hrgnUpdate = NULL;
1745 }
1746}
1747
1749{
1750 HWND *phwnd;
1751 PWND pwndNode, pwndDesktop = UserGetDesktopWindow();
1752 PWINDOWLIST pWL;
1754
1755 if (!pwndDesktop)
1756 return;
1757
1758 /* Enumerate the windows to get the IME windows (of default and non-default) */
1759 pWL = IntBuildHwndList(pwndDesktop->spwndChild, IACE_LIST, gptiCurrent);
1760 if (!pWL)
1761 return;
1762
1763 for (phwnd = pWL->ahwnd; *phwnd != HWND_TERMINATOR; ++phwnd)
1764 {
1766 break;
1767
1768 pwndNode = ValidateHwndNoErr(*phwnd);
1769 if (pwndNode == NULL ||
1770 pwndNode->head.pti != gptiCurrent ||
1772 {
1773 continue;
1774 }
1775
1776 /* Now hwndNode is an IME window of the current thread */
1777 UserRefObjectCo(pwndNode, &Ref);
1779 UserDerefObjectCo(pwndNode);
1780 }
1781
1782 IntFreeHwndList(pWL);
1783}
1784
1785/* x and y are always screen relative */
1788 PWND Window,
1789 HWND WndInsertAfter,
1790 INT x,
1791 INT y,
1792 INT cx,
1793 INT cy,
1794 UINT flags
1795 )
1796{
1797 WINDOWPOS WinPos;
1798 RECTL NewWindowRect;
1799 RECTL NewClientRect;
1800 RECTL valid_rects[2];
1801 PREGION VisBefore = NULL;
1802 PREGION VisBeforeJustClient = NULL;
1803 PREGION VisAfter = NULL;
1805 ULONG WvrFlags = 0;
1806 RECTL OldWindowRect, OldClientRect;
1807 int RgnType;
1808 HDC Dc;
1810 PWND Ancestor;
1811 BOOL bPointerInWindow, PosChanged = FALSE;
1813
1815
1816 TRACE("pwnd %p, after %p, %d,%d (%dx%d), flags 0x%x\n",
1817 Window, WndInsertAfter, x, y, cx, cy, flags);
1818#if DBG
1819 dump_winpos_flags(flags);
1820#endif
1821
1822 /* FIXME: Get current active window from active queue. Why? since r2915. */
1823
1824 bPointerInWindow = IntPtInWindow(Window, gpsi->ptCursor.x, gpsi->ptCursor.y);
1825
1826 WinPos.hwnd = Window->head.h;
1827 WinPos.hwndInsertAfter = WndInsertAfter;
1828 WinPos.x = x;
1829 WinPos.y = y;
1830 WinPos.cx = cx;
1831 WinPos.cy = cy;
1832 WinPos.flags = flags;
1833
1834 if ( flags & SWP_ASYNCWINDOWPOS )
1835 {
1836 LRESULT lRes;
1838 if ( ppos )
1839 {
1840 WinPos.flags &= ~SWP_ASYNCWINDOWPOS; // Clear flag.
1841 *ppos = WinPos;
1842 /* Yes it's a pointer inside Win32k! */
1843 lRes = co_IntSendMessageNoWait( WinPos.hwnd, WM_ASYNC_SETWINDOWPOS, 0, (LPARAM)ppos);
1844 /* We handle this the same way as Event Hooks and Hooks. */
1845 if ( !lRes )
1846 {
1848 return FALSE;
1849 }
1850 return TRUE;
1851 }
1852 return FALSE;
1853 }
1854
1855 co_WinPosDoWinPosChanging(Window, &WinPos, &NewWindowRect, &NewClientRect);
1856
1857 /* Does the window still exist? */
1858 if (!IntIsWindow(WinPos.hwnd))
1859 {
1860 TRACE("WinPosSetWindowPos: Invalid handle 0x%p!\n",WinPos.hwnd);
1862 return FALSE;
1863 }
1864
1865 /* Fix up the flags. */
1866 if (!WinPosFixupFlags(&WinPos, Window))
1867 {
1868 // See Note.
1869 return TRUE;
1870 }
1871
1872 Ancestor = UserGetAncestor(Window, GA_PARENT);
1873 if ( (WinPos.flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) != SWP_NOZORDER &&
1874 Ancestor && Ancestor->head.h == IntGetDesktopWindow() )
1875 {
1877 }
1878
1879 if (!(WinPos.flags & SWP_NOREDRAW))
1880 {
1881 /* Compute the visible region before the window position is changed */
1882 if (!(WinPos.flags & SWP_SHOWWINDOW) &&
1883 (WinPos.flags & (SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
1886 {
1888 (Window->style & WS_CLIPSIBLINGS) ? TRUE : FALSE);
1889
1890 if ( VisBefore != NULL &&
1891 REGION_Complexity(VisBefore) == NULLREGION )
1892 {
1893 REGION_Delete(VisBefore);
1894 VisBefore = NULL;
1895 }
1896 else if(VisBefore)
1897 {
1898 REGION_bOffsetRgn(VisBefore, -Window->rcWindow.left, -Window->rcWindow.top);
1899 }
1900
1901 /* Calculate the non client area for resizes, as this is used in the copy region */
1902 if ((WinPos.flags & (SWP_NOSIZE | SWP_FRAMECHANGED)) != SWP_NOSIZE)
1903 {
1904 VisBeforeJustClient = VIS_ComputeVisibleRegion(Window, TRUE, FALSE,
1905 (Window->style & WS_CLIPSIBLINGS) ? TRUE : FALSE);
1906
1907 if ( VisBeforeJustClient != NULL &&
1908 REGION_Complexity(VisBeforeJustClient) == NULLREGION )
1909 {
1910 REGION_Delete(VisBeforeJustClient);
1911 VisBeforeJustClient = NULL;
1912 }
1913 else if(VisBeforeJustClient)
1914 {
1915 REGION_bOffsetRgn(VisBeforeJustClient, -Window->rcWindow.left, -Window->rcWindow.top);
1916 }
1917 }
1918 }
1919 }
1920
1922 if (Window->hrgnNewFrame)
1923 {
1924 SelectWindowRgn( Window, Window->hrgnNewFrame ); // Should be PSMWP->acvr->hrgnClip
1925 Window->hrgnNewFrame = NULL;
1926 }
1927
1928 WvrFlags = co_WinPosDoNCCALCSize(Window, &WinPos, &NewWindowRect, &NewClientRect, valid_rects);
1929
1930// ERR("co_WinPosDoNCCALCSize returned 0x%x\n valid dest: %d %d %d %d\n valid src : %d %d %d %d\n", WvrFlags,
1931// valid_rects[0].left,valid_rects[0].top,valid_rects[0].right,valid_rects[0].bottom,
1932// valid_rects[1].left,valid_rects[1].top,valid_rects[1].right,valid_rects[1].bottom);
1933
1934 /* Validate link windows. (also take into account shell window in hwndShellWindow) */
1935 if (!(WinPos.flags & SWP_NOZORDER) && WinPos.hwnd != UserGetShellWindow())
1936 {
1938 }
1939
1940 OldWindowRect = Window->rcWindow;
1941 OldClientRect = Window->rcClient;
1942
1943 if (NewClientRect.left != OldClientRect.left ||
1944 NewClientRect.top != OldClientRect.top)
1945 {
1946 // Move child window if their parent is moved. Keep Child window relative to Parent...
1948 NewClientRect.left - OldClientRect.left,
1949 NewClientRect.top - OldClientRect.top);
1950 PosChanged = TRUE;
1951 }
1952
1953 Window->rcWindow = NewWindowRect;
1954 Window->rcClient = NewClientRect;
1955
1956 /* erase parent when hiding or resizing child */
1957 if (WinPos.flags & SWP_HIDEWINDOW)
1958 {
1959 /* Clear the update region */
1961 NULL,
1962 0,
1964
1965 if (UserIsDesktopWindow(Window->spwndParent))
1967
1968 Window->style &= ~WS_VISIBLE; //IntSetStyle( Window, 0, WS_VISIBLE );
1969 Window->head.pti->cVisWindows--;
1971 }
1972 else if (WinPos.flags & SWP_SHOWWINDOW)
1973 {
1974 if (Window->style & WS_CHILD)
1975 {
1976 if ((Window->style & WS_POPUP) && (Window->ExStyle & WS_EX_APPWINDOW))
1977 {
1979 if (!(WinPos.flags & SWP_NOACTIVATE))
1981 }
1982 }
1983 else if ((Window->ExStyle & WS_EX_APPWINDOW) ||
1984 (!(Window->ExStyle & WS_EX_TOOLWINDOW) && !Window->spwndOwner &&
1985 (!Window->spwndParent || UserIsDesktopWindow(Window->spwndParent))))
1986 {
1988 {
1990 if (!(WinPos.flags & SWP_NOACTIVATE))
1992 }
1993 }
1994
1995 Window->style |= WS_VISIBLE; //IntSetStyle( Window, WS_VISIBLE, 0 );
1996 Window->head.pti->cVisWindows++;
1998 }
1999 else
2000 {
2002 }
2003
2004 if (Window->hrgnUpdate != NULL && Window->hrgnUpdate != HRGN_WINDOW)
2005 {
2006 NtGdiOffsetRgn(Window->hrgnUpdate,
2007 NewWindowRect.left - OldWindowRect.left,
2008 NewWindowRect.top - OldWindowRect.top);
2009 }
2010
2011 DceResetActiveDCEs(Window); // For WS_VISIBLE changes.
2012
2013 // Change or update, set send non-client paint flag.
2014 if ( Window->style & WS_VISIBLE &&
2015 (WinPos.flags & SWP_STATECHANGED || (!(Window->state2 & WNDS2_WIN31COMPAT) && WinPos.flags & SWP_NOREDRAW ) ) )
2016 {
2017 TRACE("Set WNDS_SENDNCPAINT %p\n",Window);
2018 Window->state |= WNDS_SENDNCPAINT;
2019 }
2020
2021 if (!(WinPos.flags & SWP_NOREDRAW) && ((WinPos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE))
2022 {
2023 /* Determine the new visible region */
2025 (Window->style & WS_CLIPSIBLINGS) ? TRUE : FALSE);
2026
2027 if ( VisAfter != NULL &&
2028 REGION_Complexity(VisAfter) == NULLREGION )
2029 {
2030 REGION_Delete(VisAfter);
2031 VisAfter = NULL;
2032 }
2033 else if(VisAfter)
2034 {
2035 REGION_bOffsetRgn(VisAfter, -Window->rcWindow.left, -Window->rcWindow.top);
2036 }
2037
2038 /*
2039 * Determine which pixels can be copied from the old window position
2040 * to the new. Those pixels must be visible in both the old and new
2041 * position. Also, check the class style to see if the windows of this
2042 * class need to be completely repainted on (horizontal/vertical) size
2043 * change.
2044 */
2045 if ( ( VisBefore != NULL &&
2046 VisAfter != NULL &&
2047 !(WinPos.flags & SWP_NOCOPYBITS) &&
2048 ((WinPos.flags & SWP_NOSIZE) || !(WvrFlags & WVR_REDRAW)) &&
2049 !(Window->ExStyle & WS_EX_TRANSPARENT) ) )
2050 {
2051
2052 /*
2053 * If this is (also) a window resize, the whole nonclient area
2054 * needs to be repainted. So we limit the copy to the client area,
2055 * 'cause there is no use in copying it (would possibly cause
2056 * "flashing" too). However, if the copy region is already empty,
2057 * we don't have to crop (can't take anything away from an empty
2058 * region...)
2059 */
2060
2061 CopyRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
2062 if ((WinPos.flags & SWP_NOSIZE) && (WinPos.flags & SWP_NOCLIENTSIZE))
2063 RgnType = IntGdiCombineRgn(CopyRgn, VisAfter, VisBefore, RGN_AND);
2064 else if (VisBeforeJustClient != NULL)
2065 {
2066 RgnType = IntGdiCombineRgn(CopyRgn, VisAfter, VisBeforeJustClient, RGN_AND);
2067 }
2068
2069 if (VisBeforeJustClient != NULL)
2070 {
2071 REGION_Delete(VisBeforeJustClient);
2072 }
2073
2074 /* Now use in copying bits which are in the update region. */
2075 if (Window->hrgnUpdate != NULL)
2076 {
2077 PREGION RgnUpdate = REGION_LockRgn(Window->hrgnUpdate);
2078 if (RgnUpdate)
2079 {
2080 REGION_bOffsetRgn(CopyRgn, NewWindowRect.left, NewWindowRect.top);
2082 REGION_bOffsetRgn(CopyRgn, -NewWindowRect.left, -NewWindowRect.top);
2083 REGION_UnlockRgn(RgnUpdate);
2084 }
2085 }
2086
2087 /*
2088 * Now, get the bounding box of the copy region. If it's empty
2089 * there's nothing to copy. Also, it's no use copying bits onto
2090 * themselves.
2091 */
2093 {
2094 /* Nothing to copy, clean up */
2096 CopyRgn = NULL;
2097 }
2098 else if ( OldWindowRect.left != NewWindowRect.left ||
2099 OldWindowRect.top != NewWindowRect.top ||
2100 (WinPos.flags & SWP_FRAMECHANGED) )
2101 {
2102 HRGN DcRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
2103 PREGION DcRgnObj = REGION_LockRgn(DcRgn);
2104
2105 /*
2106 * Small trick here: there is no function to bitblt a region. So
2107 * we set the region as the clipping region, take the bounding box
2108 * of the region and bitblt that. Since nothing outside the clipping
2109 * region is copied, this has the effect of bitblt'ing the region.
2110 *
2111 * Since NtUserGetDCEx takes ownership of the clip region, we need
2112 * to create a copy of CopyRgn and pass that. We need CopyRgn later
2113 */
2115 REGION_bOffsetRgn(DcRgnObj, NewWindowRect.left, NewWindowRect.top);
2116 REGION_UnlockRgn(DcRgnObj);
2117 Dc = UserGetDCEx( Window,
2118 DcRgn,
2119 DCX_WINDOW|DCX_CACHE|DCX_INTERSECTRGN|DCX_CLIPSIBLINGS|DCX_KEEPCLIPRGN); // DCX_WINDOW will set first, go read WinDC.c.
2120 NtGdiBitBlt( Dc,
2121 CopyRect.left, CopyRect.top,
2122 CopyRect.right - CopyRect.left,
2123 CopyRect.bottom - CopyRect.top,
2124 Dc,
2125 CopyRect.left + (OldWindowRect.left - NewWindowRect.left),
2126 CopyRect.top + (OldWindowRect.top - NewWindowRect.top),
2127 SRCCOPY,
2128 0,
2129 0);
2130
2133 GreDeleteObject(DcRgn);
2134 }
2135 }
2136 else
2137 {
2138 CopyRgn = NULL;
2139 }
2140
2141 /* We need to redraw what wasn't visible before or force a redraw */
2142 if (VisAfter != NULL)
2143 {
2144 PREGION DirtyRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
2145 if (DirtyRgn)
2146 {
2147 if (CopyRgn != NULL)
2148 {
2149 RgnType = IntGdiCombineRgn(DirtyRgn, VisAfter, CopyRgn, RGN_DIFF);
2150 }
2151 else
2152 {
2153 RgnType = IntGdiCombineRgn(DirtyRgn, VisAfter, 0, RGN_COPY);
2154 }
2155
2156 if (RgnType != ERROR && RgnType != NULLREGION) // Regions moved.
2157 {
2158 /* old code
2159 NtGdiOffsetRgn(DirtyRgn, Window->rcWindow.left, Window->rcWindow.top);
2160 IntInvalidateWindows( Window,
2161 DirtyRgn,
2162 RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
2163 }
2164 GreDeleteObject(DirtyRgn);
2165 */
2166
2167 PWND Parent = Window->spwndParent;
2168
2169 REGION_bOffsetRgn( DirtyRgn, Window->rcWindow.left, Window->rcWindow.top);
2170
2171 if ( (Window->style & WS_CHILD) && (Parent) && !(Parent->style & WS_CLIPCHILDREN))
2172 {
2175 }
2177 }
2178 else if ( RgnType != ERROR && RgnType == NULLREGION ) // Must be the same. See CORE-7166 & CORE-15934, NC HACK fix.
2179 {
2180 if ( !PosChanged &&
2181 !(WinPos.flags & SWP_DEFERERASE) &&
2182 (WinPos.flags & SWP_FRAMECHANGED) )
2183 {
2184 PWND pwnd = Window;
2185 PWND Parent = Window->spwndParent;
2186
2187 if ( pwnd->style & WS_CHILD ) // Fix ProgMan menu bar drawing.
2188 {
2189 TRACE("SWP_FRAMECHANGED win child %p Parent %p\n",pwnd,Parent);
2190 pwnd = Parent ? Parent : pwnd;
2191 }
2192
2193 if ( !(pwnd->style & WS_CHILD) )
2194 {
2195 /*
2196 * Check if we have these specific windows style bits set/reset.
2197 * FIXME: There may be other combinations of styles that need this handling as well.
2198 * This fixes the ReactOS Calculator buttons disappearing in CORE-16827.
2199 */
2200 if ((Window->style & WS_CLIPSIBLINGS) && !(Window->style & (WS_POPUP | WS_CLIPCHILDREN | WS_SIZEBOX)))
2201 {
2202 IntSendNCPaint(pwnd, HRGN_WINDOW); // Paint the whole frame.
2203 }
2204 else // Use region handling
2205 {
2206 HRGN DcRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
2207 PREGION DcRgnObj = REGION_LockRgn(DcRgn);
2208 TRACE("SWP_FRAMECHANGED win %p hRgn %p\n",pwnd, DcRgn);
2209 IntGdiCombineRgn(DcRgnObj, VisBefore, NULL, RGN_COPY);
2210 REGION_UnlockRgn(DcRgnObj);
2211 ForceNCPaintErase(pwnd, DcRgn, DcRgnObj);
2212 GreDeleteObject(DcRgn);
2213 }
2214 }
2215 }
2216 }
2217 REGION_Delete(DirtyRgn);
2218 }
2219 }
2220
2221 if (CopyRgn != NULL)
2222 {
2224 }
2225
2226 /* Expose what was covered before but not covered anymore */
2227 if ( VisBefore != NULL )
2228 {
2229 PREGION ExposedRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
2230 if (ExposedRgn)
2231 {
2232 RgnType = IntGdiCombineRgn(ExposedRgn, VisBefore, NULL, RGN_COPY);
2233 REGION_bOffsetRgn(ExposedRgn,
2234 OldWindowRect.left - NewWindowRect.left,
2235 OldWindowRect.top - NewWindowRect.top);
2236
2237 if ( VisAfter != NULL )
2238 RgnType = IntGdiCombineRgn(ExposedRgn, ExposedRgn, VisAfter, RGN_DIFF);
2239
2240 if (RgnType != ERROR && RgnType != NULLREGION)
2241 {
2243 }
2244 REGION_Delete(ExposedRgn);
2245 }
2246 REGION_Delete(VisBefore);
2247 }
2248
2249 if (VisAfter != NULL)
2250 {
2251 REGION_Delete(VisAfter);
2252 }
2253 }
2254
2255 if (!(WinPos.flags & (SWP_NOACTIVATE|SWP_HIDEWINDOW)))
2256 {
2257 if ((Window->style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
2258 {
2260 }
2261 else
2262 {
2263 //ERR("SetWindowPos Set FG Window!\n");
2264 if ( pti->MessageQueue->spwndActive != Window ||
2265 pti->MessageQueue != gpqForeground )
2266 {
2267 //ERR("WPSWP : set active window\n");
2268 if (!(Window->state & WNDS_BEINGACTIVATED)) // Inside SAW?
2269 {
2270 co_IntSetForegroundWindow(Window); // Fixes SW_HIDE issues. Wine win test_SetActiveWindow & test_SetForegroundWindow.
2271 }
2272 }
2273 }
2274 }
2275
2276 if ( !PosChanged &&
2277 (WinPos.flags & SWP_FRAMECHANGED) &&
2278 !(WinPos.flags & SWP_DEFERERASE) && // Prevent sending WM_SYNCPAINT message.
2279 VisAfter )
2280 {
2281 PWND Parent = Window->spwndParent;
2282 if ( !(Window->style & WS_CHILD) && (Parent) && (Parent->style & WS_CLIPCHILDREN))
2283 {
2284 TRACE("SWP_FRAMECHANGED Parent %p WS_CLIPCHILDREN %p\n",Parent,Window);
2285 UserSyncAndPaintWindows( Parent, RDW_CLIPCHILDREN); // NC should redraw here, see NC HACK fix.
2286 }
2287 }
2288
2289 // Fix wine msg test_SetFocus, prevents sending WM_WINDOWPOSCHANGED.
2290 if ( VisBefore == NULL &&
2291 VisBeforeJustClient == NULL &&
2292 !(Window->ExStyle & WS_EX_TOPMOST) &&
2294 {
2295 TRACE("No drawing, set no Z order and no redraw!\n");
2297 }
2298
2299 if(!(flags & SWP_DEFERERASE))
2300 {
2301 /* erase parent when hiding or resizing child */
2302 if ((flags & SWP_HIDEWINDOW) ||
2303 (!(flags & SWP_SHOWWINDOW) &&
2305 {
2306 PWND Parent = Window->spwndParent;
2309 }
2310
2311 /* Give newly shown windows a chance to redraw */
2314 {
2316 }
2317 }
2318
2319 /* And last, send the WM_WINDOWPOSCHANGED message */
2320
2321 TRACE("\tstatus hwnd %p flags = %04x\n",Window?Window->head.h:NULL,WinPos.flags & SWP_AGG_STATUSFLAGS);
2322
2325 {
2326 /* WM_WINDOWPOSCHANGED is sent even if SWP_NOSENDCHANGING is set
2327 and always contains final window position.
2328 */
2329 WinPos.x = NewWindowRect.left;
2330 WinPos.y = NewWindowRect.top;
2331 WinPos.cx = NewWindowRect.right - NewWindowRect.left;
2332 WinPos.cy = NewWindowRect.bottom - NewWindowRect.top;
2333 TRACE("WM_WINDOWPOSCHANGED hwnd %p Flags %04x\n",WinPos.hwnd,WinPos.flags);
2335 }
2336
2337 if ( WinPos.flags & SWP_FRAMECHANGED || WinPos.flags & SWP_STATECHANGED ||
2338 !(WinPos.flags & SWP_NOCLIENTSIZE) || !(WinPos.flags & SWP_NOCLIENTMOVE) )
2339 {
2340 PWND pWnd = ValidateHwndNoErr(WinPos.hwnd);
2341 if (pWnd)
2342 IntNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, pWnd, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI);
2343 }
2344
2345 /* Send WM_IME_SYSTEM:IMS_UPDATEIMEUI to the IME windows if necessary */
2346 if ((WinPos.flags & (SWP_NOMOVE | SWP_NOSIZE)) != (SWP_NOMOVE | SWP_NOSIZE))
2347 {
2348 if (IS_IMM_MODE())
2350 }
2351
2352 if(bPointerInWindow != IntPtInWindow(Window, gpsi->ptCursor.x, gpsi->ptCursor.y))
2353 {
2354 /* Generate mouse move message */
2355 MSG msg;
2356 msg.message = WM_MOUSEMOVE;
2357 msg.wParam = UserGetMouseButtonsState();
2358 msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
2359 msg.pt = gpsi->ptCursor;
2361 }
2362
2363 return TRUE;
2364}
2365
2368{
2370
2372
2373 *ClientRect = *WindowRect;
2375
2376 FixClientRect(ClientRect, WindowRect);
2377
2378 return Result;
2379}
2380
2381void FASTCALL
2383{
2384 RECTL Rect;
2385 LPARAM lParam;
2387
2388 IntGetClientRect(Wnd, &Rect);
2389 lParam = MAKELONG(Rect.right-Rect.left, Rect.bottom-Rect.top);
2390
2391 Wnd->state &= ~WNDS_SENDSIZEMOVEMSGS;
2392
2393 if (Wnd->style & WS_MAXIMIZE)
2394 {
2396 }
2397 else if (Wnd->style & WS_MINIMIZE)
2398 {
2400 lParam = 0;
2401 }
2402
2404
2406 lParam = MAKELONG(Wnd->rcClient.left, Wnd->rcClient.top);
2407 else
2408 lParam = MAKELONG(Wnd->rcClient.left-Wnd->spwndParent->rcClient.left, Wnd->rcClient.top-Wnd->spwndParent->rcClient.top);
2409
2411
2413}
2414
2416co_WinPosMinMaximize(PWND Wnd, UINT ShowFlag, RECT* NewPos)
2417{
2418 POINT Size;
2419 WINDOWPLACEMENT wpl;
2420 LONG old_style;
2421 UINT SwpFlags = 0;
2422
2423 ASSERT_REFS_CO(Wnd);
2424
2425 wpl.length = sizeof(wpl);
2426 IntGetWindowPlacement( Wnd, &wpl );
2427
2428 if (co_HOOK_CallHooks( WH_CBT, HCBT_MINMAX, (WPARAM)Wnd->head.h, ShowFlag))
2429 {
2430 ERR("WinPosMinMaximize WH_CBT Call Hook return!\n");
2431 return SWP_NOSIZE | SWP_NOMOVE;
2432 }
2433 if (Wnd->style & WS_MINIMIZE)
2434 {
2435 switch (ShowFlag)
2436 {
2437 case SW_MINIMIZE:
2438 case SW_SHOWMINNOACTIVE:
2439 case SW_SHOWMINIMIZED:
2440 case SW_FORCEMINIMIZE:
2441 return SWP_NOSIZE | SWP_NOMOVE;
2442 }
2443 if (!co_IntSendMessageNoWait(Wnd->head.h, WM_QUERYOPEN, 0, 0))
2444 {
2445 return(SWP_NOSIZE | SWP_NOMOVE);
2446 }
2447 SwpFlags |= SWP_NOCOPYBITS;
2448 }
2449 switch (ShowFlag)
2450 {
2451 case SW_MINIMIZE:
2452 case SW_SHOWMINNOACTIVE:
2453 case SW_SHOWMINIMIZED:
2454 case SW_FORCEMINIMIZE:
2455 {
2456 //ERR("MinMaximize Minimize\n");
2457 if (Wnd->style & WS_MAXIMIZE)
2458 {
2459 Wnd->InternalPos.flags |= WPF_RESTORETOMAXIMIZED;
2460 }
2461 else
2462 {
2463 Wnd->InternalPos.flags &= ~WPF_RESTORETOMAXIMIZED;
2464 }
2465
2466 old_style = IntSetStyle( Wnd, WS_MINIMIZE, WS_MAXIMIZE );
2467
2469
2470 if (!(Wnd->InternalPos.flags & WPF_SETMINPOSITION))
2471 Wnd->InternalPos.flags &= ~WPF_MININIT;
2472
2474
2475 if (!(old_style & WS_MINIMIZE))
2476 {
2477 SwpFlags |= SWP_STATECHANGED;
2479 }
2480
2481 RECTL_vSetRect(NewPos, wpl.ptMinPosition.x, wpl.ptMinPosition.y,
2484 SwpFlags |= SWP_NOCOPYBITS;
2485 break;
2486 }
2487
2488 case SW_MAXIMIZE:
2489 {
2490 //ERR("MinMaximize Maximize\n");
2491 if ((Wnd->style & WS_MAXIMIZE) && (Wnd->style & WS_VISIBLE))
2492 {
2493 SwpFlags = SWP_NOSIZE | SWP_NOMOVE;
2494 break;
2495 }
2497
2498 /*ERR("Maximize: %d,%d %dx%d\n",
2499 wpl.ptMaxPosition.x, wpl.ptMaxPosition.y, Size.x, Size.y);
2500 */
2501 old_style = IntSetStyle( Wnd, WS_MAXIMIZE, WS_MINIMIZE );
2502 /*if (old_style & WS_MINIMIZE)
2503 {
2504 IntShowOwnedPopups(Wnd, TRUE);
2505 }*/
2506
2507 if (!(old_style & WS_MAXIMIZE)) SwpFlags |= SWP_STATECHANGED;
2508 RECTL_vSetRect(NewPos, wpl.ptMaxPosition.x, wpl.ptMaxPosition.y,
2509 //wpl.ptMaxPosition.x + Size.x, wpl.ptMaxPosition.y + Size.y);
2510 Size.x, Size.y);
2511 break;
2512 }
2513
2514 case SW_SHOWNOACTIVATE:
2515 Wnd->InternalPos.flags &= ~WPF_RESTORETOMAXIMIZED;
2516 /* fall through */
2517 case SW_SHOWNORMAL:
2518 case SW_RESTORE:
2519 case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
2520 {
2521 //ERR("MinMaximize Restore\n");
2522 old_style = IntSetStyle( Wnd, 0, WS_MINIMIZE | WS_MAXIMIZE );
2523 if (old_style & WS_MINIMIZE)
2524 {
2526
2527 if (Wnd->InternalPos.flags & WPF_RESTORETOMAXIMIZED)
2528 {
2530 IntSetStyle( Wnd, WS_MAXIMIZE, 0 );
2531 SwpFlags |= SWP_STATECHANGED;
2532 RECTL_vSetRect(NewPos, wpl.ptMaxPosition.x, wpl.ptMaxPosition.y,
2533 wpl.ptMaxPosition.x + Size.x, wpl.ptMaxPosition.y + Size.y);
2534 break;
2535 }
2536 else
2537 {
2538 *NewPos = wpl.rcNormalPosition;
2539 NewPos->right -= NewPos->left;
2540 NewPos->bottom -= NewPos->top;
2541 break;
2542 }
2543 }
2544 else
2545 {
2546 if (!(old_style & WS_MAXIMIZE))
2547 {
2548 break;
2549 }
2550 SwpFlags |= SWP_STATECHANGED;
2551 Wnd->InternalPos.flags &= ~WPF_RESTORETOMAXIMIZED;
2552 *NewPos = wpl.rcNormalPosition;
2553 NewPos->right -= NewPos->left;
2554 NewPos->bottom -= NewPos->top;
2555 break;
2556 }
2557 }
2558 }
2559 return SwpFlags;
2560}
2561
2562/*
2563 ShowWindow does not set SWP_FRAMECHANGED!!! Fix wine msg test_SetParent:WmSetParentSeq_2:23 wParam bits!
2564 Win: xxxShowWindow
2565 */
2568{
2569 BOOLEAN WasVisible;
2570 UINT Swp = 0, EventMsg = 0;
2571 RECTL NewPos = {0, 0, 0, 0};
2572 BOOLEAN ShowFlag;
2573 LONG style;
2574 PWND Parent;
2575 PTHREADINFO pti;
2576 //HRGN VisibleRgn;
2577 BOOL ShowOwned = FALSE;
2578 BOOL FirstTime = FALSE;
2579 ASSERT_REFS_CO(Wnd);
2580 //KeRosDumpStackFrames(NULL, 20);
2582 WasVisible = (Wnd->style & WS_VISIBLE) != 0;
2583 style = Wnd->style;
2584
2585 TRACE("co_WinPosShowWindow START hwnd %p Cmd %d usicmd %u\n",
2586 Wnd->head.h, Cmd, pti->ppi->usi.wShowWindow);
2587
2588 if ( pti->ppi->usi.dwFlags & STARTF_USESHOWWINDOW )
2589 {
2590 if ((Wnd->style & (WS_POPUP|WS_CHILD)) != WS_CHILD)
2591 {
2592 if ((Wnd->style & WS_CAPTION) == WS_CAPTION)
2593 {
2594 if (Wnd->spwndOwner == NULL)
2595 {
2596 if ( Cmd == SW_SHOWNORMAL || Cmd == SW_SHOW)
2597 {
2599 }
2600 FirstTime = TRUE;
2601 TRACE("co_WPSW FT 1\n");
2602 }
2603 }
2604 }
2605 }
2606
2607 if ( Cmd == SW_SHOWDEFAULT )
2608 {
2609 if ( pti->ppi->usi.dwFlags & STARTF_USESHOWWINDOW )
2610 {
2611 Cmd = pti->ppi->usi.wShowWindow;
2612 FirstTime = TRUE;
2613 TRACE("co_WPSW FT 2\n");
2614 }
2615 }
2616
2617 if (FirstTime)
2618 {
2620 }
2621
2622 switch (Cmd)
2623 {
2624 case SW_HIDE:
2625 {
2626 if (!WasVisible)
2627 {
2628 //ERR("co_WinPosShowWindow Exit Bad\n");
2629 return FALSE;
2630 }
2632 if (Wnd != pti->MessageQueue->spwndActive)
2634 break;
2635 }
2636
2637 case SW_FORCEMINIMIZE: /* FIXME: Does not work if thread is hung. */
2638 case SW_SHOWMINNOACTIVE:
2640 /* Fall through. */
2641 case SW_SHOWMINIMIZED:
2642 case SW_MINIMIZE: /* CORE-15669: SW_MINIMIZE also shows */
2643 Swp |= SWP_SHOWWINDOW;
2644 {
2645 Swp |= SWP_NOACTIVATE;
2646 if (!(style & WS_MINIMIZE))
2647 {
2649 // Fix wine Win test_SetFocus todo #1 & #2,
2650 if (Cmd == SW_SHOWMINIMIZED)
2651 {
2652 //ERR("co_WinPosShowWindow Set focus 1\n");
2653 if ((style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
2655 else
2656 co_UserSetFocus(0);
2657 }
2658
2659 Swp |= co_WinPosMinMaximize(Wnd, Cmd, &NewPos);
2660
2661 EventMsg = EVENT_SYSTEM_MINIMIZESTART;
2662 }
2663 else
2664 {
2665 if (WasVisible)
2666 {
2667 //ERR("co_WinPosShowWindow Exit Good\n");
2668 return TRUE;
2669 }
2670 Swp |= SWP_NOSIZE | SWP_NOMOVE;
2671 }
2672 break;
2673 }
2674
2675 case SW_SHOWMAXIMIZED:
2676 {
2677 Swp |= SWP_SHOWWINDOW;
2678 if (!(style & WS_MAXIMIZE))
2679 {
2680 ShowOwned = TRUE;
2681
2682 Swp |= co_WinPosMinMaximize(Wnd, SW_MAXIMIZE, &NewPos);
2683
2684 EventMsg = EVENT_SYSTEM_MINIMIZEEND;
2685 }
2686 else
2687 {
2688 if (WasVisible)
2689 {
2690 //ERR("co_WinPosShowWindow Exit Good 1\n");
2691 return TRUE;
2692 }
2693 Swp |= SWP_NOSIZE | SWP_NOMOVE;
2694 }
2695 break;
2696 }
2697
2698 case SW_SHOWNA:
2700 if (style & WS_CHILD && !(Wnd->ExStyle & WS_EX_MDICHILD)) Swp |= SWP_NOZORDER;
2701 break;
2702 case SW_SHOW:
2703 if (WasVisible) return(TRUE); // Nothing to do!
2705 /* Don't activate the topmost window. */
2706 if (style & WS_CHILD && !(Wnd->ExStyle & WS_EX_MDICHILD)) Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
2707 break;
2708
2709 case SW_SHOWNOACTIVATE:
2711 /* Fall through. */
2712 case SW_SHOWNORMAL:
2713 case SW_SHOWDEFAULT:
2714 case SW_RESTORE:
2715 if (!WasVisible) Swp |= SWP_SHOWWINDOW;
2716 if (style & (WS_MINIMIZE | WS_MAXIMIZE))
2717 {
2718 Swp |= co_WinPosMinMaximize(Wnd, Cmd, &NewPos);
2719 if (style & WS_MINIMIZE) EventMsg = EVENT_SYSTEM_MINIMIZEEND;
2720 }
2721 else
2722 {
2723 if (WasVisible)
2724 {
2725 //ERR("co_WinPosShowWindow Exit Good 3\n");
2726 return TRUE;
2727 }
2728 Swp |= SWP_NOSIZE | SWP_NOMOVE;
2729 }
2730 if ( style & WS_CHILD &&
2731 !(Wnd->ExStyle & WS_EX_MDICHILD) &&
2732 !(Swp & SWP_STATECHANGED))
2734 break;
2735
2736 default:
2737 //ERR("co_WinPosShowWindow Exit Good 4\n");
2738 return FALSE;
2739 }
2740
2741 ShowFlag = (Cmd != SW_HIDE);
2742
2743 if ((ShowFlag != WasVisible || Cmd == SW_SHOWNA) && Cmd != SW_SHOWMAXIMIZED && !(Swp & SWP_STATECHANGED))
2744 {
2745 co_IntSendMessageNoWait(Wnd->head.h, WM_SHOWWINDOW, ShowFlag, 0);
2746#if 0 // Fix wine msg test_SetParent:WmSetParentSeq_1:2
2747 if (!(Wnd->state2 & WNDS2_WIN31COMPAT)) // <------------- XP sets this bit!
2748 co_IntSendMessageNoWait(Wnd->head.h, WM_SETVISIBLE, ShowFlag, 0);
2749#endif
2750 if (!VerifyWnd(Wnd)) return WasVisible;
2751 }
2752
2753 /* We can't activate a child window */
2754 if ((Wnd->style & WS_CHILD) &&
2755 !(Wnd->ExStyle & WS_EX_MDICHILD) &&
2756 Cmd != SW_SHOWNA)
2757 {
2758 //ERR("SWP Child No active and ZOrder\n");
2760 }
2761
2762#if 0 // Explorer issues with common controls? Someone does not know how CS_SAVEBITS works.
2763 // Breaks startup and shutdown active window...
2764 if ((Wnd->style & (WS_POPUP|WS_CHILD)) != WS_CHILD &&
2765 Wnd->pcls->style & CS_SAVEBITS &&
2766 ((Cmd == SW_SHOW) || (Cmd == SW_NORMAL)))
2767 {
2768 ERR("WinPosShowWindow Set active\n");
2769 //UserSetActiveWindow(Wnd);
2770 co_IntSetForegroundWindow(Wnd); // HACK
2772 }
2773#endif
2774
2775 if (IsChildVisible(Wnd) || Swp & SWP_STATECHANGED)
2776 {
2777 TRACE("Child is Vis %s or State changed %s. ShowFlag %s Swp %04x\n",
2778 (IsChildVisible(Wnd) ? "TRUE" : "FALSE"), (Swp & SWP_STATECHANGED ? "TRUE" : "FALSE"),
2779 (ShowFlag ? "TRUE" : "FALSE"),LOWORD(Swp));
2781 0 != (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_TOP,
2782 NewPos.left,
2783 NewPos.top,
2784 NewPos.right, // NewPos.right - NewPos.left, when minimized and restore, the window becomes smaller.
2785 NewPos.bottom,// NewPos.bottom - NewPos.top,
2786 LOWORD(Swp));
2787 }
2788 else
2789 {
2790 TRACE("Parent Vis?\n");
2791 /* if parent is not visible simply toggle WS_VISIBLE and return */
2792 if (ShowFlag) IntSetStyle( Wnd, WS_VISIBLE, 0 );
2793 else IntSetStyle( Wnd, 0, WS_VISIBLE );
2794 }
2795
2796 if ( EventMsg ) IntNotifyWinEvent(EventMsg, Wnd, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI);
2797
2798 if ( ShowOwned ) IntShowOwnedPopups(Wnd, TRUE );
2799
2800 if ((Cmd == SW_HIDE) || (Cmd == SW_MINIMIZE))
2801 {
2802 if ( Wnd == pti->MessageQueue->spwndActive && pti->MessageQueue == IntGetFocusMessageQueue() )
2803 {
2805 {
2806 if (!ActivateOtherWindowMin(Wnd))
2807 {
2809 }
2810 }
2811 else
2812 {
2814 }
2815 }
2816
2817 /* Revert focus to parent */
2818 if (Wnd == pti->MessageQueue->spwndFocus)
2819 {
2820 Parent = Wnd->spwndParent;
2822 Parent = 0;
2824 }
2825 // Hide, just return.
2826 if (Cmd == SW_HIDE) return WasVisible;
2827 }
2828
2829 /* FIXME: Check for window destruction. */
2830
2831 if ((Wnd->state & WNDS_SENDSIZEMOVEMSGS) &&
2832 !(Wnd->state2 & WNDS2_INDESTROY))
2833 {
2835 }
2836
2837 /* if previous state was minimized Windows sets focus to the window */
2838 if (style & WS_MINIMIZE)
2839 {
2840 co_UserSetFocus(Wnd);
2841 // Fix wine Win test_SetFocus todo #3,
2843 }
2844 //ERR("co_WinPosShowWindow EXIT\n");
2845 return WasVisible;
2846}
2847
2848static PWND
2850 IN PWND ScopeWin,
2851 IN POINT *Point,
2852 IN OUT USHORT *HitTest,
2853 IN BOOL Ignore
2854 )
2855{
2856 HWND *List, *phWnd;
2857 PWND pwndChild = NULL;
2858
2859 /* not visible */
2860 if (!(ScopeWin->style & WS_VISIBLE))
2861 {
2862 return NULL;
2863 }
2864
2865 /* not in window or in window region */
2866 if (!IntPtInWindow(ScopeWin, Point->x, Point->y))
2867 {
2868 return NULL;
2869 }
2870
2871 /* transparent */
2872 if ((ScopeWin->ExStyle & (WS_EX_LAYERED|WS_EX_TRANSPARENT)) == (WS_EX_LAYERED|WS_EX_TRANSPARENT))
2873 {
2874 return NULL;
2875 }
2876
2877 if (!Ignore && (ScopeWin->style & WS_DISABLED))
2878 { /* disabled child */
2879 if ((ScopeWin->style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return NULL;
2880 /* process the hit error */
2881 *HitTest = HTERROR;
2882 return ScopeWin;
2883 }
2884
2885 /* not minimized and check if point is inside the window */
2886 if (!(ScopeWin->style & WS_MINIMIZE) &&
2887 RECTL_bPointInRect(&ScopeWin->rcClient, Point->x, Point->y) )
2888 {
2889 UserReferenceObject(ScopeWin);
2890
2891 List = IntWinListChildren(ScopeWin);
2892 if (List)
2893 {
2894 for (phWnd = List; *phWnd; ++phWnd)
2895 {
2896 if (!(pwndChild = ValidateHwndNoErr(*phWnd)))
2897 {
2898 continue;
2899 }
2900
2901 pwndChild = co_WinPosSearchChildren(pwndChild, Point, HitTest, Ignore);
2902
2903 if (pwndChild != NULL)
2904 {
2905 /* We found a window. Don't send any more WM_NCHITTEST messages */
2907 UserDereferenceObject(ScopeWin);
2908 return pwndChild;
2909 }
2910 }
2912 }
2913 UserDereferenceObject(ScopeWin);
2914 }
2915
2916 if (ScopeWin->head.pti == PsGetCurrentThreadWin32Thread())
2917 {
2918 *HitTest = (USHORT)co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0, MAKELONG(Point->x, Point->y));
2919
2920 if ((*HitTest) == (USHORT)HTTRANSPARENT)
2921 {
2922 return NULL;
2923 }
2924 }
2925 else
2926 {
2927 if (*HitTest == HTNOWHERE && pwndChild == NULL) *HitTest = HTCLIENT;
2928 }
2929
2930 return ScopeWin;
2931}
2932
2935 IN PWND ScopeWin,
2936 IN POINT *WinPoint,
2937 IN OUT USHORT* HitTest,
2938 IN BOOL Ignore)
2939{
2940 PWND Window;
2941 POINT Point = *WinPoint;
2943
2944 if( ScopeWin == NULL )
2945 {
2946 ScopeWin = UserGetDesktopWindow();
2947 if(ScopeWin == NULL)
2948 return NULL;
2949 }
2950
2951 *HitTest = HTNOWHERE;
2952
2953 ASSERT_REFS_CO(ScopeWin);
2954 UserRefObjectCo(ScopeWin, &Ref);
2955
2956 Window = co_WinPosSearchChildren(ScopeWin, &Point, HitTest, Ignore);
2957
2958 UserDerefObjectCo(ScopeWin);
2959 if (Window)
2961 ASSERT_REFS_CO(ScopeWin);
2962
2963 return Window;
2964}
2965
2966/* Win: _RealChildWindowFromPoint */
2969{
2970 POINTL Pt;
2971 HWND *List, *phWnd;
2972 PWND pwndHit = NULL;
2973
2974 Pt.x = x;
2975 Pt.y = y;
2976
2978 {
2979 Pt.x += Parent->rcClient.left;
2980 Pt.y += Parent->rcClient.top;
2981 }
2982
2983 if (!IntPtInWindow(Parent, Pt.x, Pt.y)) return NULL;
2984
2986 {
2987 for (phWnd = List; *phWnd; phWnd++)
2988 {
2989 PWND Child;
2990 if ((Child = ValidateHwndNoErr(*phWnd)))
2991 {
2992 if ( Child->style & WS_VISIBLE && IntPtInWindow(Child, Pt.x, Pt.y) )
2993 {
2994 if ( Child->pcls->atomClassName != gpsi->atomSysClass[ICLS_BUTTON] ||
2995 (Child->style & BS_TYPEMASK) != BS_GROUPBOX )
2996 {
2998 return Child;
2999 }
3000 pwndHit = Child;
3001 }
3002 }
3003 }
3005 }
3006 return pwndHit ? pwndHit : Parent;
3007}
3008
3009/* Win: _ChildWindowFromPointEx */
3012{
3013 POINTL Pt;
3014 HWND *List, *phWnd;
3015 PWND pwndHit = NULL;
3016
3017 Pt.x = x;
3018 Pt.y = y;
3019
3021 {
3022 if (Parent->ExStyle & WS_EX_LAYOUTRTL)
3023 Pt.x = Parent->rcClient.right - Pt.x;
3024 else
3025 Pt.x += Parent->rcClient.left;
3026 Pt.y += Parent->rcClient.top;
3027 }
3028
3029 if (!IntPtInWindow(Parent, Pt.x, Pt.y)) return NULL;
3030
3032 {
3033 for (phWnd = List; *phWnd; phWnd++)
3034 {
3035 PWND Child;
3036 if ((Child = ValidateHwndNoErr(*phWnd)))
3037 {
3038 if (uiFlags & (CWP_SKIPINVISIBLE|CWP_SKIPDISABLED))
3039 {
3040 if (!(Child->style & WS_VISIBLE) && (uiFlags & CWP_SKIPINVISIBLE)) continue;
3041 if ((Child->style & WS_DISABLED) && (uiFlags & CWP_SKIPDISABLED)) continue;
3042 }
3043
3044 if (uiFlags & CWP_SKIPTRANSPARENT)
3045 {
3046 if (Child->ExStyle & WS_EX_TRANSPARENT) continue;
3047 }
3048
3049 if (IntPtInWindow(Child, Pt.x, Pt.y))
3050 {
3051 pwndHit = Child;
3052 break;
3053 }
3054 }
3055 }
3057 }
3058 return pwndHit ? pwndHit : Parent;
3059}
3060
3061/* Win: _DeferWindowPos(PSMWP, PWND, PWND, ...) */
3062HDWP
3065 HWND hwnd,
3066 HWND hwndAfter,
3067 INT x,
3068 INT y,
3069 INT cx,
3070 INT cy,
3071 UINT flags )
3072{
3073 PSMWP pDWP;
3074 int i;
3075 HDWP retvalue = hdwp;
3076
3077 TRACE("hdwp %p, hwnd %p, after %p, %d,%d (%dx%d), flags %08x\n",
3078 hdwp, hwnd, hwndAfter, x, y, cx, cy, flags);
3079
3080 if (flags & ~(SWP_NOSIZE | SWP_NOMOVE |
3085 {
3087 return NULL;
3088 }
3089
3090 if (!(pDWP = (PSMWP)UserGetObject(gHandleTable, hdwp, TYPE_SETWINDOWPOS)))
3091 {
3093 return NULL;
3094 }
3095
3096 for (i = 0; i < pDWP->ccvr; i++)
3097 {
3098 if (pDWP->acvr[i].pos.hwnd == hwnd)
3099 {
3100 /* Merge with the other changes */
3101 if (!(flags & SWP_NOZORDER))
3102 {
3103 pDWP->acvr[i].pos.hwndInsertAfter = hwndAfter;
3104 }
3105 if (!(flags & SWP_NOMOVE))
3106 {
3107 pDWP->acvr[i].pos.x = x;
3108 pDWP->acvr[i].pos.y = y;
3109 }
3110 if (!(flags & SWP_NOSIZE))
3111 {
3112 pDWP->acvr[i].pos.cx = cx;
3113 pDWP->acvr[i].pos.cy = cy;
3114 }
3115 pDWP->acvr[i].pos.flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
3121 goto END;
3122 }
3123 }
3124 if (pDWP->ccvr >= pDWP->ccvrAlloc)
3125 {
3126 PCVR newpos = ExAllocatePoolWithTag(PagedPool, pDWP->ccvrAlloc * 2 * sizeof(CVR), USERTAG_SWP);
3127 if (!newpos)
3128 {
3129 retvalue = NULL;
3130 goto END;
3131 }
3132 RtlZeroMemory(newpos, pDWP->ccvrAlloc * 2 * sizeof(CVR));
3133 RtlCopyMemory(newpos, pDWP->acvr, pDWP->ccvrAlloc * sizeof(CVR));
3135 pDWP->ccvrAlloc *= 2;
3136 pDWP->acvr = newpos;
3137 }
3138 pDWP->acvr[pDWP->ccvr].pos.hwnd = hwnd;
3139 pDWP->acvr[pDWP->ccvr].pos.hwndInsertAfter = hwndAfter;
3140 pDWP->acvr[pDWP->ccvr].pos.x = x;
3141 pDWP->acvr[pDWP->ccvr].pos.y = y;
3142 pDWP->acvr[pDWP->ccvr].pos.cx = cx;
3143 pDWP->acvr[pDWP->ccvr].pos.cy = cy;
3144 pDWP->acvr[pDWP->ccvr].pos.flags = flags;
3145 pDWP->acvr[pDWP->ccvr].hrgnClip = NULL;
3146 pDWP->acvr[pDWP->ccvr].hrgnInterMonitor = NULL;
3147 pDWP->ccvr++;
3148END:
3149 return retvalue;
3150}
3151
3152/* Win: xxxEndDeferWindowPosEx */
3154{
3155 PSMWP pDWP;
3156 PCVR winpos;
3157 BOOL res = TRUE;
3158 int i;
3159
3160 TRACE("%p\n", hdwp);
3161
3162 if (!(pDWP = (PSMWP)UserGetObject(gHandleTable, hdwp, TYPE_SETWINDOWPOS)))
3163 {
3165 return FALSE;
3166 }
3167
3168 for (i = 0, winpos = pDWP->acvr; res && i < pDWP->ccvr; i++, winpos++)
3169 {
3170 PWND pwnd;
3172
3173 TRACE("hwnd %p, after %p, %d,%d (%dx%d), flags %08x\n",
3174 winpos->pos.hwnd, winpos->pos.hwndInsertAfter, winpos->pos.x, winpos->pos.y,
3175 winpos->pos.cx, winpos->pos.cy, winpos->pos.flags);
3176
3177 pwnd = ValidateHwndNoErr(winpos->pos.hwnd);
3178 if (!pwnd)
3179 continue;
3180
3181 UserRefObjectCo(pwnd, &Ref);
3182
3183 if (bAsync)
3184 {
3185 LRESULT lRes;
3187 if ( ppos )
3188 {
3189 *ppos = winpos->pos;
3190 /* Yes it's a pointer inside Win32k! */
3191 lRes = co_IntSendMessageNoWait( winpos->pos.hwnd, WM_ASYNC_SETWINDOWPOS, 0, (LPARAM)ppos);
3192 /* We handle this the same way as Event Hooks and Hooks. */
3193 if ( !lRes )
3194 {
3196 }
3197 }
3198 }
3199 else
3200 res = co_WinPosSetWindowPos( pwnd,
3201 winpos->pos.hwndInsertAfter,
3202 winpos->pos.x,
3203 winpos->pos.y,
3204 winpos->pos.cx,
3205 winpos->pos.cy,
3206 winpos->pos.flags);
3207
3208 // Hack to pass tests.... Must have some work to do so clear the error.
3209 if (res && (winpos->pos.flags & (SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER)) == SWP_NOZORDER )
3211
3212 UserDerefObjectCo(pwnd);
3213 }
3214
3218 return res;
3219}
3220
3221/*
3222 * @implemented
3223 */
3226 LONG x,
3227 LONG y,
3228 UINT uiFlags)
3229{
3230 PWND pwndParent;
3231 TRACE("Enter NtUserChildWindowFromPointEx\n");
3233 if ((pwndParent = UserGetWindowObject(hwndParent)))
3234 {
3235 pwndParent = IntChildWindowFromPointEx(pwndParent, x, y, uiFlags);
3236 }
3237 UserLeave();
3238 TRACE("Leave NtUserChildWindowFromPointEx\n");
3239 return pwndParent ? UserHMGetHandle(pwndParent) : NULL;
3240}
3241
3242/*
3243 * @implemented
3244 */
3247 BOOL bAsync)
3248{
3249 BOOL Ret;
3250 TRACE("Enter NtUserEndDeferWindowPosEx\n");
3252 Ret = IntEndDeferWindowPosEx(WinPosInfo, bAsync);
3253 TRACE("Leave NtUserEndDeferWindowPosEx, ret=%i\n", Ret);
3254 UserLeave();
3255 return Ret;
3256}
3257
3258/*
3259 * @implemented
3260 */
3261HDWP APIENTRY
3262NtUserDeferWindowPos(HDWP WinPosInfo,
3263 HWND Wnd,
3264 HWND WndInsertAfter,
3265 int x,
3266 int y,
3267 int cx,
3268 int cy,
3269 UINT Flags)
3270{
3271 PWND pWnd, pWndIA;
3272 HDWP Ret = NULL;
3276
3277 TRACE("Enter NtUserDeferWindowPos\n");
3279
3280 if ( Flags & Tmp )
3281 {
3283 goto Exit;
3284 }
3285
3286 pWnd = UserGetWindowObject(Wnd);
3287 if (!pWnd || UserIsDesktopWindow(pWnd) || UserIsMessageWindow(pWnd))
3288 {
3289 goto Exit;
3290 }
3291
3292 if ( WndInsertAfter &&
3293 WndInsertAfter != HWND_BOTTOM &&
3294 WndInsertAfter != HWND_TOPMOST &&
3295 WndInsertAfter != HWND_NOTOPMOST )
3296 {
3297 pWndIA = UserGetWindowObject(WndInsertAfter);
3298 if (!pWndIA || UserIsDesktopWindow(pWndIA) || UserIsMessageWindow(pWndIA))
3299 {
3300 goto Exit;
3301 }
3302 }
3303
3304 Ret = IntDeferWindowPos(WinPosInfo, Wnd, WndInsertAfter, x, y, cx, cy, Flags);
3305
3306Exit:
3307 TRACE("Leave NtUserDeferWindowPos, ret=%p\n", Ret);
3308 UserLeave();
3309 return Ret;
3310}
3311
3312/*
3313 * @implemented
3314 */
3317 LPRECT rectWnd,
3318 LPPOINT ptIcon)
3319{
3320 PWND Window;
3321 DWORD Ret = 0;
3322 BOOL Hit = FALSE;
3323 WINDOWPLACEMENT wndpl;
3324
3326
3328 {
3329 Hit = FALSE;
3330 goto Exit;
3331 }
3332
3333 _SEH2_TRY
3334 {
3335 if(rectWnd)
3336 {
3337 ProbeForWrite(rectWnd,
3338 sizeof(RECT),
3339 1);
3340 }
3341 if(ptIcon)
3342 {
3343 ProbeForWrite(ptIcon,
3344 sizeof(POINT),
3345 1);
3346 }
3347
3348 }
3350 {
3352 Hit = TRUE;
3353 }
3354 _SEH2_END;
3355
3356 wndpl.length = sizeof(WINDOWPLACEMENT);
3357
3358 if (IntGetWindowPlacement(Window, &wndpl) && !Hit)
3359 {
3360 _SEH2_TRY
3361 {
3362 if (rectWnd)
3363 {
3364 RtlCopyMemory(rectWnd, &wndpl.rcNormalPosition , sizeof(RECT));
3365 }
3366 if (ptIcon)
3367 {
3368 RtlCopyMemory(ptIcon, &wndpl.ptMinPosition, sizeof(POINT));
3369 }
3370
3371 }
3373 {
3375 Hit = TRUE;
3376 }
3377 _SEH2_END;
3378
3379 if (!Hit) Ret = wndpl.showCmd;
3380 }
3381Exit:
3382 UserLeave();
3383 return Ret;
3384}
3385
3386/*
3387 * @implemented
3388 */
3391 WINDOWPLACEMENT *lpwndpl)
3392{
3393 PWND Wnd;
3394 WINDOWPLACEMENT Safepl;
3397
3398 TRACE("Enter NtUserGetWindowPlacement\n");
3400
3401 if (!(Wnd = UserGetWindowObject(hWnd)))
3402 {
3403 RETURN( FALSE);
3404 }
3405
3406 Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
3407 if (!NT_SUCCESS(Status))
3408 {
3410 RETURN( FALSE);
3411 }
3412
3413 Safepl.length = sizeof(WINDOWPLACEMENT);
3414
3415 IntGetWindowPlacement(Wnd, &Safepl);
3416
3417 Status = MmCopyToCaller(lpwndpl, &Safepl, sizeof(WINDOWPLACEMENT));
3418 if (!NT_SUCCESS(Status))
3419 {
3421 RETURN( FALSE);
3422 }
3423
3424 RETURN( TRUE);
3425
3426CLEANUP:
3427 TRACE("Leave NtUserGetWindowPlacement, ret=%i\n",_ret_);
3428 UserLeave();
3430}
3431
3432DWORD
3435 HWND hWnd,
3436 UINT cmd, // Wine SW_ commands
3437 BOOL Hide)
3438{
3439 PWND pWnd;
3440
3441 TRACE("Enter NtUserMinMaximize\n");
3443
3444 pWnd = UserGetWindowObject(hWnd);
3445 if (!pWnd || UserIsDesktopWindow(pWnd) || UserIsMessageWindow(pWnd))
3446 {
3447 goto Exit;
3448 }
3449
3450 if ( cmd > SW_MAX || pWnd->state2 & WNDS2_INDESTROY)
3451 {
3453 goto Exit;
3454 }
3455
3456 cmd |= Hide ? SW_HIDE : 0;
3457
3458 co_WinPosShowWindow(pWnd, cmd);
3459
3460Exit:
3461 TRACE("Leave NtUserMinMaximize\n");
3462 UserLeave();
3463 return 0; // Always NULL?
3464}
3465
3466/*
3467 * @implemented
3468 */
3471 HWND hWnd,
3472 int X,
3473 int Y,
3474 int nWidth,
3475 int nHeight,
3476 BOOL bRepaint)
3477{
3478 return NtUserSetWindowPos(hWnd, 0, X, Y, nWidth, nHeight,
3479 (bRepaint ? SWP_NOZORDER | SWP_NOACTIVATE :
3481}
3482
3483/*
3484 * @implemented
3485 */
3488 LONG x,
3489 LONG y)
3490{
3491 PWND pwndParent;
3492 TRACE("Enter NtUserRealChildWindowFromPoint\n");
3494 if ((pwndParent = UserGetWindowObject(Parent)))
3495 {
3496 pwndParent = IntRealChildWindowFromPoint(pwndParent, x, y);
3497 }
3498 UserLeave();
3499 TRACE("Leave NtUserRealChildWindowFromPoint\n");
3500 return pwndParent ? UserHMGetHandle(pwndParent) : NULL;
3501}
3502
3503/*
3504 * @implemented
3505 */
3508 HWND hWnd,
3509 HWND hWndInsertAfter,
3510 int X,
3511 int Y,
3512 int cx,
3513 int cy,
3514 UINT uFlags)
3515{
3517 PWND Window, pWndIA;
3518 BOOL ret;
3520
3521 TRACE("Enter NtUserSetWindowPos\n");
3523
3524 if (!(Window = UserGetWindowObject(hWnd)) ||
3526 {
3527 ERR("NtUserSetWindowPos bad window handle!\n");
3528 RETURN(FALSE);
3529 }
3530
3531 if ( hWndInsertAfter != HWND_TOP &&
3532 hWndInsertAfter != HWND_BOTTOM &&
3533 hWndInsertAfter != HWND_TOPMOST &&
3534 hWndInsertAfter != HWND_NOTOPMOST )
3535 {
3536 if (!(pWndIA = UserGetWindowObject(hWndInsertAfter)) ||
3537 UserIsDesktopWindow(pWndIA) || UserIsMessageWindow(pWndIA))
3538 {
3539 ERR("NtUserSetWindowPos bad insert window handle!\n");
3540 RETURN(FALSE);
3541 }
3542 }
3543
3544 /* First make sure that coordinates are valid for WM_WINDOWPOSCHANGING */
3545 if (!(uFlags & SWP_NOMOVE))
3546 {
3547 if (X < -32768) X = -32768;
3548 else if (X > 32767) X = 32767;
3549 if (Y < -32768) Y = -32768;
3550 else if (Y > 32767) Y = 32767;
3551 }
3552 if (!(uFlags & SWP_NOSIZE))
3553 {
3554 if (cx < 0) cx = 0;
3555 else if (cx > 32767) cx = 32767;
3556 if (cy < 0) cy = 0;
3557 else if (cy > 32767) cy = 32767;
3558 }
3559
3560 UserRefObjectCo(Window, &Ref);
3561 ret = co_WinPosSetWindowPos(Window, hWndInsertAfter, X, Y, cx, cy, uFlags);
3563
3564 RETURN(ret);
3565
3566CLEANUP:
3567 TRACE("Leave NtUserSetWindowPos, ret=%i\n",_ret_);
3568 UserLeave();
3570}
3571
3572/*
3573 * @implemented
3574 */
3577 HWND hWnd,
3578 HRGN hRgn,
3579 BOOL bRedraw)
3580{
3581 HRGN hrgnCopy = NULL;
3582 PWND Window;
3584 BOOLEAN Ret = FALSE;
3586
3587 TRACE("Enter NtUserSetWindowRgn\n");
3589
3590 if (!(Window = UserGetWindowObject(hWnd)) ||
3592 {
3593 RETURN( 0);
3594 }
3595
3596 if (hRgn) // The region will be deleted in user32.
3597 {
3599 {
3600 hrgnCopy = NtGdiCreateRectRgn(0, 0, 0, 0);
3601 /* The coordinates of a window's window region are relative to the
3602 upper-left corner of the window, not the client area of the window. */
3603 NtGdiCombineRgn( hrgnCopy, hRgn, 0, RGN_COPY);
3604 }
3605 else
3606 RETURN( 0);
3607 }
3608
3610 if (hrgnCopy)
3611 {
3612 Window->hrgnNewFrame = hrgnCopy; // Should be PSMWP->acvr->hrgnClip
3613 }
3614 else
3615 {
3616 Window->hrgnNewFrame = HRGN_WINDOW;
3617 }
3619 Ret = co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0, bRedraw ? flags : (flags|SWP_NOREDRAW) );
3620
3621 RETURN( (INT)Ret);
3622
3623CLEANUP:
3624 TRACE("Leave NtUserSetWindowRgn, ret=%i\n",_ret_);
3625 UserLeave();
3627}
3628
3629/*
3630 * @implemented
3631 */
3634 HWND hwnd,
3635 UINT showCmd,
3636 LPRECT lprect,
3637 LPPOINT lppt)
3638{
3639 WINDOWPLACEMENT wndpl;
3640 UINT flags;
3641 PWND Wnd;
3642 RECT rect;
3643 POINT pt = {0};
3646
3647 TRACE("Enter NtUserSetWindowPlacement\n");
3649
3650 if (!(Wnd = UserGetWindowObject(hwnd)) || // FIXME:
3652 {
3653 RETURN( FALSE);
3654 }
3655
3656 _SEH2_TRY
3657 {
3658 if (lppt)
3659 {
3660 ProbeForRead(lppt, sizeof(POINT), 1);
3661 RtlCopyMemory(&pt, lppt, sizeof(POINT));
3662 }
3663 if (lprect)
3664 {
3665 ProbeForRead(lprect, sizeof(RECT), 1);
3666 RtlCopyMemory(&rect, lprect, sizeof(RECT));
3667 }
3668 }
3670 {
3673 }
3674 _SEH2_END
3675
3676 wndpl.length = sizeof(wndpl);
3677 wndpl.showCmd = showCmd;
3678 wndpl.flags = flags = 0;
3679
3680 if ( lppt )
3681 {
3682 flags |= PLACE_MIN;
3683 wndpl.flags |= WPF_SETMINPOSITION;
3684 wndpl.ptMinPosition = pt;
3685 }
3686 if ( lprect )
3687 {
3688 flags |= PLACE_RECT;
3689 wndpl.rcNormalPosition = rect;
3690 }
3691
3692 UserRefObjectCo(Wnd, &Ref);
3693 IntSetWindowPlacement(Wnd, &wndpl, flags);
3694 UserDerefObjectCo(Wnd);
3695 RETURN(TRUE);
3696
3697CLEANUP:
3698 TRACE("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_);
3699 UserLeave();
3701}
3702
3703/*
3704 * @implemented
3705 */
3708 WINDOWPLACEMENT *lpwndpl)
3709{
3710 PWND Wnd;
3711 WINDOWPLACEMENT Safepl;
3712 UINT Flags;
3715
3716 TRACE("Enter NtUserSetWindowPlacement\n");
3718
3719 if (!(Wnd = UserGetWindowObject(hWnd)) ||
3721 {
3722 RETURN( FALSE);
3723 }
3724
3725 _SEH2_TRY
3726 {
3727 ProbeForRead(lpwndpl, sizeof(WINDOWPLACEMENT), 1);
3728 RtlCopyMemory(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
3729 }
3731 {
3734 }
3735 _SEH2_END
3736
3737 if(Safepl.length != sizeof(WINDOWPLACEMENT))
3738 {
3739 RETURN( FALSE);
3740 }
3741
3743 if (Safepl.flags & WPF_SETMINPOSITION) Flags |= PLACE_MIN;
3744 UserRefObjectCo(Wnd, &Ref);
3745 IntSetWindowPlacement(Wnd, &Safepl, Flags);
3746 UserDerefObjectCo(Wnd);
3747 RETURN(TRUE);
3748
3749CLEANUP:
3750 TRACE("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_);
3751 UserLeave();
3753}
3754
3755/*
3756 * @implemented
3757 */
3760{
3761 PWND Window;
3762 BOOL ret;
3765
3766 TRACE("Enter NtUserShowWindowAsync\n");
3768
3769 if (!(Window = UserGetWindowObject(hWnd)) ||
3771 {
3772 RETURN(FALSE);
3773 }
3774
3775 if ( nCmdShow > SW_MAX )
3776 {
3778 RETURN(FALSE);
3779 }
3780
3781 UserRefObjectCo(Window, &Ref);
3784 if (-1 == (int) ret || !ret) ret = FALSE;
3785
3786 RETURN(ret);
3787
3788CLEANUP:
3789 TRACE("Leave NtUserShowWindowAsync, ret=%i\n",_ret_);
3790 UserLeave();
3792}
3793
3794/*
3795 * @implemented
3796 */
3799{
3800 PWND Window;
3801 BOOL ret;
3804
3805 TRACE("Enter NtUserShowWindow hWnd %p SW_ %d\n",hWnd, nCmdShow);
3807
3808 if (!(Window = UserGetWindowObject(hWnd)) ||
3810 {
3811 RETURN(FALSE);
3812 }
3813
3814 if ( nCmdShow > SW_MAX || Window->state2 & WNDS2_INDESTROY)
3815 {
3817 RETURN(FALSE);
3818 }
3819
3820 UserRefObjectCo(Window, &Ref);
3821 ret = co_WinPosShowWindow(Window, nCmdShow);
3823
3824 RETURN(ret);
3825
3826CLEANUP:
3827 TRACE("Leave NtUserShowWindow, ret=%i\n",_ret_);
3828 UserLeave();
3830}
3831
3832
3833/*
3834 * @implemented
3835 */
3838{
3839 POINT pt;
3840 HWND Ret;
3842 USHORT hittest;
3845
3846 TRACE("Enter NtUserWindowFromPoint\n");
3848
3850 {
3851 //PTHREADINFO pti;
3852
3853 pt.x = X;
3854 pt.y = Y;
3855
3856 // Hmm... Threads live on desktops thus we have a reference on the desktop and indirectly the desktop window.
3857 // It is possible this referencing is useless, though it should not hurt...
3859
3860 //pti = PsGetCurrentThreadWin32Thread();
3862
3863 if (Window)
3864 {
3865 Ret = UserHMGetHandle(Window);
3866
3867 RETURN( Ret);
3868 }
3869 }
3870
3871 RETURN( NULL);
3872
3873CLEANUP:
3875
3876 TRACE("Leave NtUserWindowFromPoint, ret=%p\n", _ret_);
3877 UserLeave();
3879}
3880
3881/* EOF */
static HDC hDC
Definition: 3dtext.c:33
#define RETURN(x)
#define DCX_USESTYLE
Definition: GetDCEx.c:10
unsigned char BOOLEAN
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
Arabic default style
Definition: afstyles.h:94
const DWORD Style
Definition: appswitch.c:71
const DWORD ExStyle
Definition: appswitch.c:72
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
LONG NTSTATUS
Definition: precomp.h:26
@ Create
Definition: registry.c:563
#define ERR(fmt,...)
Definition: debug.h:110
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:103
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define SWP_NOCLIENTSIZE
Definition: msg.h:29
#define SWP_NOCLIENTMOVE
Definition: msg.h:30
static HWND hwndParent
Definition: cryptui.c:300
VOID FASTCALL DceResetActiveDCEs(PWND Window)
Definition: windc.c:816
ush Pos
Definition: deflate.h:92
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define APIENTRY
Definition: api.h:79
#define Y(I)
UINT uFlags
Definition: api.c:59
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
PSERVERINFO gpsi
Definition: imm.c:18
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
#define pt(x, y)
Definition: drawing.c:79
r parent
Definition: btrfs.c:3010
VOID FASTCALL IntEngWindowChanged(_In_ struct _WND *Window, _In_ FLONG flChanged)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define ERROR(name)
Definition: error_private.h:53
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND FASTCALL co_UserSetFocus(PWND Window)
Definition: focus.c:1314
BOOL FASTCALL IntCheckFullscreen(PWND Window)
Definition: focus.c:79
BOOL FASTCALL UserSetActiveWindow(_In_opt_ PWND Wnd)
Definition: focus.c:1260
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:13
VOID FASTCALL UpdateShellHook(PWND Window)
Definition: focus.c:99
BOOL FASTCALL co_IntSetForegroundWindow(PWND Window)
Definition: focus.c:1550
HWND FASTCALL UserGetForegroundWindow(VOID)
Definition: focus.c:1421
BOOLEAN valid
Status
Definition: gdiplustypes.h:25
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint res
Definition: glext.h:9613
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLdouble GLdouble right
Definition: glext.h:10859
GLenum const GLfloat * params
Definition: glext.h:5645
GLint left
Definition: glext.h:7726
GLbitfield flags
Definition: glext.h:7161
GLint GLint bottom
Definition: glext.h:7726
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
#define X(b, s)
#define IMS_UPDATEIMEUI
Definition: immdev.h:29
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define WNDS2_WIN31COMPAT
Definition: ntuser.h:644
#define ICLS_IME
Definition: ntuser.h:922
#define TIF_INCLEANUP
Definition: ntuser.h:262
#define WNDS_BEINGACTIVATED
Definition: ntuser.h:620
#define FNID_DESKTOP
Definition: ntuser.h:857
#define WNDS_SENDNCPAINT
Definition: ntuser.h:611
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#define WNDS_MAXIMIZESTOMONITOR
Definition: ntuser.h:630
#define IS_IMM_MODE()
Definition: ntuser.h:1232
#define ICLS_BUTTON
Definition: ntuser.h:907
@ TYPE_SETWINDOWPOS
Definition: ntuser.h:44
#define WNDS_ERASEBACKGROUND
Definition: ntuser.h:610
#define WEF_SETBYWNDPTI
Definition: ntuser.h:235
#define WPF_MAXINIT
Definition: ntuser.h:682
#define WNDS2_INDESTROY
Definition: ntuser.h:643
#define WNDS_SENDSIZEMOVEMSGS
Definition: ntuser.h:604
#define WPF_MININIT
Definition: ntuser.h:681
#define HRGN_WINDOW
Definition: ntuser.h:356
#define WNDS_SENDERASEBACKGROUND
Definition: ntuser.h:609
if(dx< 0)
Definition: linetemp.h:194
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define for
Definition: utility.h:88
#define END
Definition: options.h:105
static HDC
Definition: imagelist.c:92
static HRGN hRgn
Definition: mapping.c:33
#define SWP_STATECHANGED
Definition: msg.c:42
#define min(a, b)
Definition: monoChain.cc:55
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:580
@ WM_ASYNC_SHOWWINDOW
Definition: msgqueue.h:117
@ WM_ASYNC_SETWINDOWPOS
Definition: msgqueue.h:118
unsigned int UINT
Definition: ndis.h:50
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ SaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ OwnerSize PSID Owner
Definition: rtlfuncs.h:1597
#define FASTCALL
Definition: nt_native.h:50
__kernel_entry W32KAPI INT APIENTRY NtGdiCombineRgn(_In_ HRGN hrgnDst, _In_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ INT iMode)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiBitBlt(_In_ HDC hdcDst, _In_ INT x, _In_ INT y, _In_ INT cx, _In_ INT cy, _In_opt_ HDC hdcSrc, _In_ INT xSrc, _In_ INT ySrc, _In_ DWORD rop4, _In_ DWORD crBackColor, _In_ FLONG fl)
__kernel_entry W32KAPI HRGN APIENTRY NtGdiCreateRectRgn(_In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
__kernel_entry W32KAPI INT APIENTRY NtGdiOffsetRgn(_In_ HRGN hrgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:3980
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1102
BOOL FASTCALL IntClientToScreen(PWND Wnd, LPPOINT lpPoint)
Definition: winpos.c:200
UINT FASTCALL co_WinPosMinMaximize(PWND Wnd, UINT ShowFlag, RECT *NewPos)
Definition: winpos.c:2416
INT APIENTRY NtUserSetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
Definition: winpos.c:3576
BOOL APIENTRY NtUserSetWindowPlacement(HWND hWnd, WINDOWPLACEMENT *lpwndpl)
Definition: winpos.c:3707
DWORD APIENTRY NtUserMinMaximize(HWND hWnd, UINT cmd, BOOL Hide)
Definition: winpos.c:3434
UINT FASTCALL co_WinPosArrangeIconicWindows(PWND parent)
Definition: winpos.c:732
static VOID FASTCALL FixClientRect(PRECTL ClientRect, PRECTL WindowRect)
Definition: winpos.c:1082
BOOL FASTCALL IntSetWindowPlacement(PWND Wnd, WINDOWPLACEMENT *wpl, UINT Flags)
Definition: winpos.c:666
static BOOL FASTCALL co_WinPosDoWinPosChanging(PWND Window, PWINDOWPOS WinPos, PRECTL WindowRect, PRECTL ClientRect)
Definition: winpos.c:1268
VOID FASTCALL co_WinPosActivateOtherWindow(PWND Wnd)
Definition: winpos.c:398
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1787
static BOOL FASTCALL WinPosFixupFlags(WINDOWPOS *WinPos, PWND Wnd)
Definition: winpos.c:1552
BOOL APIENTRY NtUserMoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, BOOL bRepaint)
Definition: winpos.c:3470
INT FASTCALL IntMapWindowPoints(PWND FromWnd, PWND ToWnd, LPPOINT lpPoints, UINT cPoints)
Definition: winpos.c:145
BOOL FASTCALL IsChildVisible(PWND pWnd)
Definition: winpos.c:227
PWND FASTCALL IntGetLastTopMostWindow(VOID)
Definition: winpos.c:239
BOOL APIENTRY NtUserSetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
Definition: winpos.c:3507
VOID ForceNCPaintErase(PWND Wnd, HRGN hRgn, PREGION pRgn)
Definition: winpos.c:1692
#define EMPTYPOINT(pt)
Definition: winpos.c:30
DWORD APIENTRY NtUserGetInternalWindowPos(HWND hWnd, LPRECT rectWnd, LPPOINT ptIcon)
Definition: winpos.c:3316
static void make_point_onscreen(POINT *pt)
Definition: winpos.c:655
DWORD IntGetWindowBorders(DWORD Style, DWORD ExStyle)
Definition: winpos.c:916
VOID FASTCALL WinPosInitInternalPos(PWND Wnd, RECTL *RestoreRect)
Definition: winpos.c:481
DWORD APIENTRY NtUserSetInternalWindowPos(HWND hwnd, UINT showCmd, LPRECT lprect, LPPOINT lppt)
Definition: winpos.c:3633
BOOL FASTCALL IntGetWindowPlacement(PWND Wnd, WINDOWPLACEMENT *lpwndpl)
Definition: winpos.c:560
static PWND co_WinPosSearchChildren(IN PWND ScopeWin, IN POINT *Point, IN OUT USHORT *HitTest, IN BOOL Ignore)
Definition: winpos.c:2849
static VOID FASTCALL get_valid_rects(RECTL *old_client, RECTL *new_client, UINT flags, RECTL *valid)
Definition: winpos.c:1125
BOOL FASTCALL ActivateOtherWindowMin(PWND Wnd)
Definition: winpos.c:286
static void make_rect_onscreen(RECT *rect)
Definition: winpos.c:625
#define PLACE_RECT
Definition: winpos.c:33
PWND APIENTRY co_WinPosWindowFromPoint(IN PWND ScopeWin, IN POINT *WinPoint, IN OUT USHORT *HitTest, IN BOOL Ignore)
Definition: winpos.c:2934
#define SWP_AGG_STATUSFLAGS
Definition: winpos.c:25
static VOID FASTCALL WinPosFindIconPos(PWND Window, POINT *Pos)
Definition: winpos.c:782
BOOL APIENTRY NtUserShowWindow(HWND hWnd, LONG nCmdShow)
Definition: winpos.c:3798
#define PLACE_MAX
Definition: winpos.c:32
HWND APIENTRY NtUserRealChildWindowFromPoint(HWND Parent, LONG x, LONG y)
Definition: winpos.c:3487
LRESULT FASTCALL co_WinPosGetNonClientSize(PWND Window, RECT *WindowRect, RECT *ClientRect)
Definition: winpos.c:2367
static VOID FASTCALL WinPosInternalMoveWindow(PWND Window, INT MoveX, INT MoveY)
Definition: winpos.c:1522
VOID FASTCALL IntGetClientRect(PWND Wnd, RECTL *Rect)
Definition: winpos.c:93
BOOL APIENTRY NtUserShowWindowAsync(HWND hWnd, LONG nCmdShow)
Definition: winpos.c:3759
static BOOL IntValidateParent(PWND Child, PREGION ValidateRgn)
Definition: winpos.c:1058
BOOL FASTCALL IntGetWindowRect(PWND Wnd, RECTL *Rect)
Definition: winpos.c:122
#define SWP_AGG_NOCLIENTCHANGE
Definition: winpos.c:27
UINT FASTCALL co_WinPosGetMinMaxInfo(PWND Window, POINT *MaxSize, POINT *MaxPos, POINT *MinTrack, POINT *MaxTrack)
Definition: winpos.c:935
static HWND FASTCALL WinPosDoOwnedPopups(PWND Window, HWND hWndInsertAfter)
Definition: winpos.c:1356
BOOL FASTCALL IntScreenToClient(PWND Wnd, LPPOINT lpPoint)
Definition: winpos.c:214
PWND APIENTRY IntChildWindowFromPointEx(PWND Parent, LONG x, LONG y, UINT uiFlags)
Definition: winpos.c:3011
BOOL APIENTRY NtUserGetWindowPlacement(HWND hWnd, WINDOWPLACEMENT *lpwndpl)
Definition: winpos.c:3390
static BOOL FASTCALL can_activate_window(PWND Wnd OPTIONAL)
Definition: winpos.c:374
void FASTCALL co_WinPosSendSizeMove(PWND Wnd)
Definition: winpos.c:2382
BOOL UserHasWindowEdge(DWORD Style, DWORD ExStyle)
Definition: winpos.c:845
HWND APIENTRY NtUserWindowFromPoint(LONG X, LONG Y)
Definition: winpos.c:3837
HDWP APIENTRY NtUserDeferWindowPos(HDWP WinPosInfo, HWND Wnd, HWND WndInsertAfter, int x, int y, int cx, int cy, UINT Flags)
Definition: winpos.c:3262
HWND APIENTRY NtUserChildWindowFromPointEx(HWND hwndParent, LONG x, LONG y, UINT uiFlags)
Definition: winpos.c:3225
BOOLEAN FASTCALL co_WinPosShowWindow(PWND Wnd, INT Cmd)
Definition: winpos.c:2567
BOOL FASTCALL IntGetClientOrigin(PWND Window OPTIONAL, LPPOINT Point)
Definition: winpos.c:72
#define SWP_AGG_NOGEOMETRYCHANGE
Definition: winpos.c:21
VOID UserGetWindowBorders(DWORD Style, DWORD ExStyle, SIZE *Size, BOOL WithClient)
Definition: winpos.c:889
#define SWP_AGG_NOPOSCHANGE
Definition: winpos.c:23
VOID FASTCALL IntGetWindowBorderMeasures(PWND Wnd, UINT *cx, UINT *cy)
Definition: winpos.c:862
VOID SelectWindowRgn(PWND Window, HRGN hRgnClip)
Definition: winpos.c:260
PWND FASTCALL IntRealChildWindowFromPoint(PWND Parent, LONG x, LONG y)
Definition: winpos.c:2968
HDWP FASTCALL IntDeferWindowPos(HDWP hdwp, HWND hwnd, HWND hwndAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:3064
#define PLACE_MIN
Definition: winpos.c:31
BOOL APIENTRY NtUserEndDeferWindowPosEx(HDWP WinPosInfo, BOOL bAsync)
Definition: winpos.c:3246
BOOL FASTCALL IntEndDeferWindowPosEx(HDWP hdwp, BOOL bAsync)
Definition: winpos.c:3153
static LONG FASTCALL co_WinPosDoNCCALCSize(PWND Window, PWINDOWPOS WinPos, RECTL *WindowRect, RECTL *ClientRect, RECTL *validRects)
Definition: winpos.c:1181
static VOID FASTCALL IntImeWindowPosChanged(VOID)
Definition: winpos.c:1748
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:254
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:238
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
#define RDW_CLIPCHILDREN
Definition: painting.h:15
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
#define WS_CAPTION
Definition: pedump.c:624
#define WS_SIZEBOX
Definition: pedump.c:642
#define WS_ICONIC
Definition: pedump.c:641
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define WS_MAXIMIZE
Definition: pedump.c:623
#define WS_BORDER
Definition: pedump.c:625
#define WS_POPUP
Definition: pedump.c:616
#define WS_MINIMIZE
Definition: pedump.c:622
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_EX_TOPMOST
Definition: pedump.c:647
long LONG
Definition: pedump.c:60
#define BS_GROUPBOX
Definition: pedump.c:658
#define WS_DISABLED
Definition: pedump.c:621
#define WS_DLGFRAME
Definition: pedump.c:626
#define WS_EX_TRANSPARENT
Definition: pedump.c:649
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
unsigned short USHORT
Definition: pedump.c:61
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define WS_THICKFRAME
Definition: pedump.c:630
#define MmCopyFromCaller
Definition: polytest.cpp:29
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
@ Cmd
Definition: sacdrv.h:278
static void Exit(void)
Definition: sock.c:1330
#define TRACE(s)
Definition: solgame.cpp:4
& rect
Definition: startmenu.cpp:1413
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
Implementation of the Explorer desktop window.
Definition: desktop.h:52