2 * Window position related functions.
4 * Copyright 1993, 1994, 1995 Alexandre Julliard
5 * 1995, 1996 Alex Korobka
11 #include <X11/Xatom.h>
12 #include "sysmetrics.h"
23 #include "nonclient.h"
26 #define HAS_DLGFRAME(style,exStyle) \
27 (((exStyle) & WS_EX_DLGMODALFRAME) || \
28 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
30 #define HAS_THICKFRAME(style) \
31 (((style) & WS_THICKFRAME) && \
32 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
34 #define SWP_AGG_NOGEOMETRYCHANGE \
35 (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
36 #define SWP_AGG_NOPOSCHANGE \
37 (SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
38 #define SWP_AGG_STATUSFLAGS \
39 (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
41 #define EMPTYPOINT(pt) ((*(LONG*)&(pt)) == -1)
43 #define PLACE_MIN 0x0001
44 #define PLACE_MAX 0x0002
45 #define PLACE_RECT 0x0004
47 #define SMC_NOCOPY 0x0001
48 #define SMC_NOPARENTERASE 0x0002
49 #define SMC_DRAWFRAME 0x0004
50 #define SMC_SETXPOS 0x0008
52 /* ----- internal variables ----- */
54 static HWND32 hwndActive
= 0; /* Currently active window */
55 static HWND32 hwndPrevActive
= 0; /* Previously active window */
56 static HWND32 hGlobalShellWindow
=0; /*the shell*/
58 static LPCSTR atomInternalPos
;
60 extern MESSAGEQUEUE
* pActiveQueue
;
62 /***********************************************************************
63 * WINPOS_CreateInternalPosAtom
65 BOOL32
WINPOS_CreateInternalPosAtom()
68 atomInternalPos
= (LPCSTR
)(DWORD
)GlobalAddAtom32A(str
);
69 return (atomInternalPos
) ? TRUE
: FALSE
;
72 /***********************************************************************
73 * WINPOS_CheckInternalPos
75 * Called when a window is destroyed.
77 void WINPOS_CheckInternalPos( HWND32 hwnd
)
79 LPINTERNALPOS lpPos
= (LPINTERNALPOS
) GetProp32A( hwnd
, atomInternalPos
);
81 if( hwnd
== hwndPrevActive
) hwndPrevActive
= 0;
82 if( hwnd
== hwndActive
)
85 WARN(win
, "\tattempt to activate destroyed window!\n");
90 if( IsWindow32(lpPos
->hwndIconTitle
) )
91 DestroyWindow32( lpPos
->hwndIconTitle
);
92 HeapFree( SystemHeap
, 0, lpPos
);
96 /***********************************************************************
99 * Find a suitable place for an iconic window.
101 static POINT16
WINPOS_FindIconPos( WND
* wndPtr
, POINT16 pt
)
104 short x
, y
, xspacing
, yspacing
;
106 GetClientRect16( wndPtr
->parent
->hwndSelf
, &rectParent
);
107 if ((pt
.x
>= rectParent
.left
) && (pt
.x
+ SYSMETRICS_CXICON
< rectParent
.right
) &&
108 (pt
.y
>= rectParent
.top
) && (pt
.y
+ SYSMETRICS_CYICON
< rectParent
.bottom
))
109 return pt
; /* The icon already has a suitable position */
111 xspacing
= SYSMETRICS_CXICONSPACING
;
112 yspacing
= SYSMETRICS_CYICONSPACING
;
114 y
= rectParent
.bottom
;
117 for (x
= rectParent
.left
; x
<= rectParent
.right
-xspacing
; x
+= xspacing
)
119 /* Check if another icon already occupies this spot */
120 WND
*childPtr
= wndPtr
->parent
->child
;
123 if ((childPtr
->dwStyle
& WS_MINIMIZE
) && (childPtr
!= wndPtr
))
125 if ((childPtr
->rectWindow
.left
< x
+ xspacing
) &&
126 (childPtr
->rectWindow
.right
>= x
) &&
127 (childPtr
->rectWindow
.top
<= y
) &&
128 (childPtr
->rectWindow
.bottom
> y
- yspacing
))
129 break; /* There's a window in there */
131 childPtr
= childPtr
->next
;
133 if (!childPtr
) /* No window was found, so it's OK for us */
135 pt
.x
= x
+ (xspacing
- SYSMETRICS_CXICON
) / 2;
136 pt
.y
= y
- (yspacing
+ SYSMETRICS_CYICON
) / 2;
145 /***********************************************************************
146 * ArrangeIconicWindows16 (USER.170)
148 UINT16 WINAPI
ArrangeIconicWindows16( HWND16 parent
)
150 return ArrangeIconicWindows32(parent
);
152 /***********************************************************************
153 * ArrangeIconicWindows32 (USER32.7)
155 UINT32 WINAPI
ArrangeIconicWindows32( HWND32 parent
)
159 INT32 x
, y
, xspacing
, yspacing
;
161 GetClientRect32( parent
, &rectParent
);
163 y
= rectParent
.bottom
;
164 xspacing
= SYSMETRICS_CXICONSPACING
;
165 yspacing
= SYSMETRICS_CYICONSPACING
;
167 hwndChild
= GetWindow32( parent
, GW_CHILD
);
170 if( IsIconic32( hwndChild
) )
172 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild
), FALSE
);
173 SetWindowPos32( hwndChild
, 0, x
+ (xspacing
- SYSMETRICS_CXICON
) / 2,
174 y
- yspacing
- SYSMETRICS_CYICON
/2, 0, 0,
175 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
176 if( IsWindow32(hwndChild
) )
177 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild
), TRUE
);
178 if (x
<= rectParent
.right
- xspacing
) x
+= xspacing
;
185 hwndChild
= GetWindow32( hwndChild
, GW_HWNDNEXT
);
191 /***********************************************************************
192 * SwitchToThisWindow16 (USER.172)
194 void WINAPI
SwitchToThisWindow16( HWND16 hwnd
, BOOL16 restore
)
196 SwitchToThisWindow32( hwnd
, restore
);
200 /***********************************************************************
201 * SwitchToThisWindow32 (USER32.539)
203 void WINAPI
SwitchToThisWindow32( HWND32 hwnd
, BOOL32 restore
)
205 ShowWindow32( hwnd
, restore
? SW_RESTORE
: SW_SHOWMINIMIZED
);
209 /***********************************************************************
210 * GetWindowRect16 (USER.32)
212 void WINAPI
GetWindowRect16( HWND16 hwnd
, LPRECT16 rect
)
214 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
217 CONV_RECT32TO16( &wndPtr
->rectWindow
, rect
);
218 if (wndPtr
->dwStyle
& WS_CHILD
)
219 MapWindowPoints16( wndPtr
->parent
->hwndSelf
, 0, (POINT16
*)rect
, 2 );
223 /***********************************************************************
224 * GetWindowRect32 (USER32.308)
226 BOOL32 WINAPI
GetWindowRect32( HWND32 hwnd
, LPRECT32 rect
)
228 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
229 if (!wndPtr
) return FALSE
;
231 *rect
= wndPtr
->rectWindow
;
232 if (wndPtr
->dwStyle
& WS_CHILD
)
233 MapWindowPoints32( wndPtr
->parent
->hwndSelf
, 0, (POINT32
*)rect
, 2 );
238 /***********************************************************************
241 BOOL32 WINAPI
GetWindowRgn32 ( HWND32 hwnd
, HRGN32 hrgn
)
245 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
246 if (!wndPtr
) return (ERROR
);
248 FIXME (win
, "GetWindowRgn32: doesn't really do regions\n");
250 memset (&rect
, 0, sizeof(rect
));
252 GetWindowRect32 ( hwnd
, &rect
);
254 FIXME (win
, "Check whether a valid region here\n");
256 SetRectRgn32 ( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
258 return (SIMPLEREGION
);
261 /***********************************************************************
264 INT32 WINAPI
SetWindowRgn32( HWND32 hwnd
, HRGN32 hrgn
,BOOL32 bRedraw
)
268 FIXME (win
, "SetWindowRgn32: stub\n");
272 /***********************************************************************
275 INT16 WINAPI
SetWindowRgn16( HWND16 hwnd
, HRGN16 hrgn
,BOOL16 bRedraw
)
279 FIXME (win
, "SetWindowRgn16: stub\n");
284 /***********************************************************************
285 * GetClientRect16 (USER.33)
287 void WINAPI
GetClientRect16( HWND16 hwnd
, LPRECT16 rect
)
289 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
291 rect
->left
= rect
->top
= rect
->right
= rect
->bottom
= 0;
294 rect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
;
295 rect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
;
300 /***********************************************************************
301 * GetClientRect32 (USER32.220)
303 void WINAPI
GetClientRect32( HWND32 hwnd
, LPRECT32 rect
)
305 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
307 rect
->left
= rect
->top
= rect
->right
= rect
->bottom
= 0;
310 rect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
;
311 rect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
;
316 /*******************************************************************
317 * ClientToScreen16 (USER.28)
319 void WINAPI
ClientToScreen16( HWND16 hwnd
, LPPOINT16 lppnt
)
321 MapWindowPoints16( hwnd
, 0, lppnt
, 1 );
325 /*******************************************************************
326 * ClientToScreen32 (USER32.52)
328 BOOL32 WINAPI
ClientToScreen32( HWND32 hwnd
, LPPOINT32 lppnt
)
330 MapWindowPoints32( hwnd
, 0, lppnt
, 1 );
335 /*******************************************************************
336 * ScreenToClient16 (USER.29)
338 void WINAPI
ScreenToClient16( HWND16 hwnd
, LPPOINT16 lppnt
)
340 MapWindowPoints16( 0, hwnd
, lppnt
, 1 );
344 /*******************************************************************
345 * ScreenToClient32 (USER32.447)
347 void WINAPI
ScreenToClient32( HWND32 hwnd
, LPPOINT32 lppnt
)
349 MapWindowPoints32( 0, hwnd
, lppnt
, 1 );
353 /***********************************************************************
354 * WINPOS_WindowFromPoint
356 * Find the window and hittest for a given point.
358 INT16
WINPOS_WindowFromPoint( WND
* wndScope
, POINT16 pt
, WND
**ppWnd
)
361 INT16 hittest
= HTERROR
;
365 wndPtr
= wndScope
->child
;
366 if( wndScope
->flags
& WIN_MANAGED
)
368 /* this prevents mouse clicks from going "through" scrollbars in managed mode */
369 if( pt
.x
< wndScope
->rectClient
.left
|| pt
.x
>= wndScope
->rectClient
.right
||
370 pt
.y
< wndScope
->rectClient
.top
|| pt
.y
>= wndScope
->rectClient
.bottom
)
373 MapWindowPoints16( GetDesktopWindow16(), wndScope
->hwndSelf
, &xy
, 1 );
379 /* If point is in window, and window is visible, and it */
380 /* is enabled (or it's a top-level window), then explore */
381 /* its children. Otherwise, go to the next window. */
383 if ((wndPtr
->dwStyle
& WS_VISIBLE
) &&
384 (!(wndPtr
->dwStyle
& WS_DISABLED
) ||
385 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) != WS_CHILD
)) &&
386 (xy
.x
>= wndPtr
->rectWindow
.left
) &&
387 (xy
.x
< wndPtr
->rectWindow
.right
) &&
388 (xy
.y
>= wndPtr
->rectWindow
.top
) &&
389 (xy
.y
< wndPtr
->rectWindow
.bottom
))
391 *ppWnd
= wndPtr
; /* Got a suitable window */
393 /* If window is minimized or disabled, return at once */
394 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
395 if (wndPtr
->dwStyle
& WS_DISABLED
) return HTERROR
;
397 /* If point is not in client area, ignore the children */
398 if ((xy
.x
< wndPtr
->rectClient
.left
) ||
399 (xy
.x
>= wndPtr
->rectClient
.right
) ||
400 (xy
.y
< wndPtr
->rectClient
.top
) ||
401 (xy
.y
>= wndPtr
->rectClient
.bottom
)) break;
403 xy
.x
-= wndPtr
->rectClient
.left
;
404 xy
.y
-= wndPtr
->rectClient
.top
;
405 wndPtr
= wndPtr
->child
;
407 else wndPtr
= wndPtr
->next
;
411 /* If nothing found, try the scope window */
412 if (!*ppWnd
) *ppWnd
= wndScope
;
414 /* Send the WM_NCHITTEST message (only if to the same task) */
415 if ((*ppWnd
)->hmemTaskQ
== GetTaskQueue(0))
417 hittest
= (INT16
)SendMessage16( (*ppWnd
)->hwndSelf
, WM_NCHITTEST
,
418 0, MAKELONG( pt
.x
, pt
.y
) );
419 if (hittest
!= HTTRANSPARENT
) return hittest
; /* Found the window */
421 else return HTCLIENT
;
423 /* If no children found in last search, make point relative to parent */
426 xy
.x
+= (*ppWnd
)->rectClient
.left
;
427 xy
.y
+= (*ppWnd
)->rectClient
.top
;
430 /* Restart the search from the next sibling */
431 wndPtr
= (*ppWnd
)->next
;
432 *ppWnd
= (*ppWnd
)->parent
;
437 /*******************************************************************
438 * WindowFromPoint16 (USER.30)
440 HWND16 WINAPI
WindowFromPoint16( POINT16 pt
)
443 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt
, &pWnd
);
444 return pWnd
->hwndSelf
;
448 /*******************************************************************
449 * WindowFromPoint32 (USER32.582)
451 HWND32 WINAPI
WindowFromPoint32( POINT32 pt
)
455 CONV_POINT32TO16( &pt
, &pt16
);
456 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt16
, &pWnd
);
457 return (HWND32
)pWnd
->hwndSelf
;
461 /*******************************************************************
462 * ChildWindowFromPoint16 (USER.191)
464 HWND16 WINAPI
ChildWindowFromPoint16( HWND16 hwndParent
, POINT16 pt
)
467 CONV_POINT16TO32( &pt
, &pt32
);
468 return (HWND16
)ChildWindowFromPoint32( hwndParent
, pt32
);
472 /*******************************************************************
473 * ChildWindowFromPoint32 (USER32.49)
475 HWND32 WINAPI
ChildWindowFromPoint32( HWND32 hwndParent
, POINT32 pt
)
477 /* pt is in the client coordinates */
479 WND
* wnd
= WIN_FindWndPtr(hwndParent
);
484 /* get client rect fast */
485 rect
.top
= rect
.left
= 0;
486 rect
.right
= wnd
->rectClient
.right
- wnd
->rectClient
.left
;
487 rect
.bottom
= wnd
->rectClient
.bottom
- wnd
->rectClient
.top
;
489 if (!PtInRect32( &rect
, pt
)) return 0;
494 if (PtInRect32( &wnd
->rectWindow
, pt
)) return wnd
->hwndSelf
;
500 /*******************************************************************
501 * ChildWindowFromPointEx16 (USER.50)
503 HWND16 WINAPI
ChildWindowFromPointEx16( HWND16 hwndParent
, POINT16 pt
, UINT16 uFlags
)
506 CONV_POINT16TO32( &pt
, &pt32
);
507 return (HWND16
)ChildWindowFromPointEx32( hwndParent
, pt32
, uFlags
);
511 /*******************************************************************
512 * ChildWindowFromPointEx32 (USER32.50)
514 HWND32 WINAPI
ChildWindowFromPointEx32( HWND32 hwndParent
, POINT32 pt
,
517 /* pt is in the client coordinates */
519 WND
* wnd
= WIN_FindWndPtr(hwndParent
);
524 /* get client rect fast */
525 rect
.top
= rect
.left
= 0;
526 rect
.right
= wnd
->rectClient
.right
- wnd
->rectClient
.left
;
527 rect
.bottom
= wnd
->rectClient
.bottom
- wnd
->rectClient
.top
;
529 if (!PtInRect32( &rect
, pt
)) return 0;
534 if (PtInRect32( &wnd
->rectWindow
, pt
)) {
535 if ( (uFlags
& CWP_SKIPINVISIBLE
) &&
536 !(wnd
->dwStyle
& WS_VISIBLE
) )
538 else if ( (uFlags
& CWP_SKIPDISABLED
) &&
539 (wnd
->dwStyle
& WS_DISABLED
) )
541 else if ( (uFlags
& CWP_SKIPTRANSPARENT
) &&
542 (wnd
->dwExStyle
& WS_EX_TRANSPARENT
) )
545 return wnd
->hwndSelf
;
552 /*******************************************************************
553 * WINPOS_GetWinOffset
555 * Calculate the offset between the origin of the two windows. Used
556 * to implement MapWindowPoints.
558 static void WINPOS_GetWinOffset( HWND32 hwndFrom
, HWND32 hwndTo
,
563 offset
->x
= offset
->y
= 0;
564 if (hwndFrom
== hwndTo
) return;
566 /* Translate source window origin to screen coords */
569 if (!(wndPtr
= WIN_FindWndPtr( hwndFrom
)))
571 ERR(win
,"bad hwndFrom = %04x\n",hwndFrom
);
574 while (wndPtr
->parent
)
576 offset
->x
+= wndPtr
->rectClient
.left
;
577 offset
->y
+= wndPtr
->rectClient
.top
;
578 wndPtr
= wndPtr
->parent
;
582 /* Translate origin to destination window coords */
585 if (!(wndPtr
= WIN_FindWndPtr( hwndTo
)))
587 ERR(win
,"bad hwndTo = %04x\n", hwndTo
);
590 while (wndPtr
->parent
)
592 offset
->x
-= wndPtr
->rectClient
.left
;
593 offset
->y
-= wndPtr
->rectClient
.top
;
594 wndPtr
= wndPtr
->parent
;
600 /*******************************************************************
601 * MapWindowPoints16 (USER.258)
603 void WINAPI
MapWindowPoints16( HWND16 hwndFrom
, HWND16 hwndTo
,
604 LPPOINT16 lppt
, UINT16 count
)
608 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
618 /*******************************************************************
619 * MapWindowPoints32 (USER32.386)
621 void WINAPI
MapWindowPoints32( HWND32 hwndFrom
, HWND32 hwndTo
,
622 LPPOINT32 lppt
, UINT32 count
)
626 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
636 /***********************************************************************
637 * IsIconic16 (USER.31)
639 BOOL16 WINAPI
IsIconic16(HWND16 hWnd
)
641 return IsIconic32(hWnd
);
645 /***********************************************************************
646 * IsIconic32 (USER32.345)
648 BOOL32 WINAPI
IsIconic32(HWND32 hWnd
)
650 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
651 if (wndPtr
== NULL
) return FALSE
;
652 return (wndPtr
->dwStyle
& WS_MINIMIZE
) != 0;
656 /***********************************************************************
657 * IsZoomed (USER.272)
659 BOOL16 WINAPI
IsZoomed16(HWND16 hWnd
)
661 return IsZoomed32(hWnd
);
665 /***********************************************************************
666 * IsZoomed (USER32.352)
668 BOOL32 WINAPI
IsZoomed32(HWND32 hWnd
)
670 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
671 if (wndPtr
== NULL
) return FALSE
;
672 return (wndPtr
->dwStyle
& WS_MAXIMIZE
) != 0;
676 /*******************************************************************
677 * GetActiveWindow (USER.60)
679 HWND16 WINAPI
GetActiveWindow16(void)
681 return (HWND16
)hwndActive
;
684 /*******************************************************************
685 * GetActiveWindow (USER32.205)
687 HWND32 WINAPI
GetActiveWindow32(void)
689 return (HWND32
)hwndActive
;
693 /*******************************************************************
696 static BOOL32
WINPOS_CanActivate(WND
* pWnd
)
698 if( pWnd
&& ((pWnd
->dwStyle
& (WS_DISABLED
| WS_VISIBLE
| WS_CHILD
))
699 == WS_VISIBLE
) ) return TRUE
;
704 /*******************************************************************
705 * SetActiveWindow16 (USER.59)
707 HWND16 WINAPI
SetActiveWindow16( HWND16 hwnd
)
709 return SetActiveWindow32(hwnd
);
713 /*******************************************************************
714 * SetActiveWindow32 (USER32.463)
716 HWND32 WINAPI
SetActiveWindow32( HWND32 hwnd
)
718 HWND32 prev
= hwndActive
;
719 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
721 if ( !WINPOS_CanActivate(wndPtr
) ) return 0;
723 WINPOS_SetActiveWindow( hwnd
, 0, 0 );
728 /*******************************************************************
729 * GetForegroundWindow16 (USER.608)
731 HWND16 WINAPI
GetForegroundWindow16(void)
733 return (HWND16
)GetForegroundWindow32();
737 /*******************************************************************
738 * SetForegroundWindow16 (USER.609)
740 BOOL16 WINAPI
SetForegroundWindow16( HWND16 hwnd
)
742 return SetForegroundWindow32( hwnd
);
746 /*******************************************************************
747 * GetForegroundWindow32 (USER32.241)
749 HWND32 WINAPI
GetForegroundWindow32(void)
751 return GetActiveWindow32();
755 /*******************************************************************
756 * SetForegroundWindow32 (USER32.482)
758 BOOL32 WINAPI
SetForegroundWindow32( HWND32 hwnd
)
760 SetActiveWindow32( hwnd
);
765 /*******************************************************************
766 * GetShellWindow16 (USER.600)
768 HWND16 WINAPI
GetShellWindow16(void)
770 return GetShellWindow32();
773 /*******************************************************************
774 * SetShellWindow32 (USER32.504)
776 HWND32 WINAPI
SetShellWindow32(HWND32 hwndshell
)
777 { WARN(win
, "(hWnd=%08x) semi stub\n",hwndshell
);
779 hGlobalShellWindow
= hwndshell
;
780 return hGlobalShellWindow
;
784 /*******************************************************************
785 * GetShellWindow32 (USER32.287)
787 HWND32 WINAPI
GetShellWindow32(void)
788 { WARN(win
, "(hWnd=%x) semi stub\n",hGlobalShellWindow
);
790 return hGlobalShellWindow
;
794 /***********************************************************************
795 * BringWindowToTop16 (USER.45)
797 BOOL16 WINAPI
BringWindowToTop16( HWND16 hwnd
)
799 return BringWindowToTop32(hwnd
);
803 /***********************************************************************
804 * BringWindowToTop32 (USER32.11)
806 BOOL32 WINAPI
BringWindowToTop32( HWND32 hwnd
)
808 return SetWindowPos32( hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
812 /***********************************************************************
813 * MoveWindow16 (USER.56)
815 BOOL16 WINAPI
MoveWindow16( HWND16 hwnd
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
818 return MoveWindow32(hwnd
,x
,y
,cx
,cy
,repaint
);
822 /***********************************************************************
823 * MoveWindow32 (USER32.399)
825 BOOL32 WINAPI
MoveWindow32( HWND32 hwnd
, INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
828 int flags
= SWP_NOZORDER
| SWP_NOACTIVATE
;
829 if (!repaint
) flags
|= SWP_NOREDRAW
;
830 TRACE(win
, "%04x %d,%d %dx%d %d\n",
831 hwnd
, x
, y
, cx
, cy
, repaint
);
832 return SetWindowPos32( hwnd
, 0, x
, y
, cx
, cy
, flags
);
835 /***********************************************************************
836 * WINPOS_InitInternalPos
838 static LPINTERNALPOS
WINPOS_InitInternalPos( WND
* wnd
, POINT32 pt
,
839 LPRECT32 restoreRect
)
841 LPINTERNALPOS lpPos
= (LPINTERNALPOS
) GetProp32A( wnd
->hwndSelf
,
845 /* this happens when the window is minimized/maximized
846 * for the first time (rectWindow is not adjusted yet) */
848 lpPos
= HeapAlloc( SystemHeap
, 0, sizeof(INTERNALPOS
) );
849 if( !lpPos
) return NULL
;
851 SetProp32A( wnd
->hwndSelf
, atomInternalPos
, (HANDLE32
)lpPos
);
852 lpPos
->hwndIconTitle
= 0; /* defer until needs to be shown */
853 CONV_RECT32TO16( &wnd
->rectWindow
, &lpPos
->rectNormal
);
854 *(UINT32
*)&lpPos
->ptIconPos
= *(UINT32
*)&lpPos
->ptMaxPos
= 0xFFFFFFFF;
857 if( wnd
->dwStyle
& WS_MINIMIZE
)
858 CONV_POINT32TO16( &pt
, &lpPos
->ptIconPos
);
859 else if( wnd
->dwStyle
& WS_MAXIMIZE
)
860 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
861 else if( restoreRect
)
862 CONV_RECT32TO16( restoreRect
, &lpPos
->rectNormal
);
867 /***********************************************************************
868 * WINPOS_RedrawIconTitle
870 BOOL32
WINPOS_RedrawIconTitle( HWND32 hWnd
)
872 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)GetProp32A( hWnd
, atomInternalPos
);
875 if( lpPos
->hwndIconTitle
)
877 SendMessage32A( lpPos
->hwndIconTitle
, WM_SHOWWINDOW
, TRUE
, 0);
878 InvalidateRect32( lpPos
->hwndIconTitle
, NULL
, TRUE
);
885 /***********************************************************************
886 * WINPOS_ShowIconTitle
888 BOOL32
WINPOS_ShowIconTitle( WND
* pWnd
, BOOL32 bShow
)
890 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)GetProp32A( pWnd
->hwndSelf
, atomInternalPos
);
892 if( lpPos
&& !(pWnd
->flags
& WIN_MANAGED
))
894 HWND16 hWnd
= lpPos
->hwndIconTitle
;
896 TRACE(win
,"0x%04x %i\n", pWnd
->hwndSelf
, (bShow
!= 0) );
899 lpPos
->hwndIconTitle
= hWnd
= ICONTITLE_Create( pWnd
);
902 pWnd
= WIN_FindWndPtr(hWnd
);
904 if( !(pWnd
->dwStyle
& WS_VISIBLE
) )
906 SendMessage32A( hWnd
, WM_SHOWWINDOW
, TRUE
, 0 );
907 SetWindowPos32( hWnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
908 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_SHOWWINDOW
);
911 else ShowWindow32( hWnd
, SW_HIDE
);
916 /*******************************************************************
917 * WINPOS_GetMinMaxInfo
919 * Get the minimized and maximized information for a window.
921 void WINPOS_GetMinMaxInfo( WND
*wndPtr
, POINT32
*maxSize
, POINT32
*maxPos
,
922 POINT32
*minTrack
, POINT32
*maxTrack
)
928 /* Compute default values */
930 MinMax
.ptMaxSize
.x
= SYSMETRICS_CXSCREEN
;
931 MinMax
.ptMaxSize
.y
= SYSMETRICS_CYSCREEN
;
932 MinMax
.ptMinTrackSize
.x
= SYSMETRICS_CXMINTRACK
;
933 MinMax
.ptMinTrackSize
.y
= SYSMETRICS_CYMINTRACK
;
934 MinMax
.ptMaxTrackSize
.x
= SYSMETRICS_CXSCREEN
;
935 MinMax
.ptMaxTrackSize
.y
= SYSMETRICS_CYSCREEN
;
937 if (wndPtr
->flags
& WIN_MANAGED
) xinc
= yinc
= 0;
938 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
940 xinc
= SYSMETRICS_CXDLGFRAME
;
941 yinc
= SYSMETRICS_CYDLGFRAME
;
946 if (HAS_THICKFRAME(wndPtr
->dwStyle
))
948 xinc
+= SYSMETRICS_CXFRAME
;
949 yinc
+= SYSMETRICS_CYFRAME
;
951 if (wndPtr
->dwStyle
& WS_BORDER
)
953 xinc
+= SYSMETRICS_CXBORDER
;
954 yinc
+= SYSMETRICS_CYBORDER
;
957 MinMax
.ptMaxSize
.x
+= 2 * xinc
;
958 MinMax
.ptMaxSize
.y
+= 2 * yinc
;
960 lpPos
= (LPINTERNALPOS
)GetProp32A( wndPtr
->hwndSelf
, atomInternalPos
);
961 if( lpPos
&& !EMPTYPOINT(lpPos
->ptMaxPos
) )
962 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &MinMax
.ptMaxPosition
);
965 MinMax
.ptMaxPosition
.x
= -xinc
;
966 MinMax
.ptMaxPosition
.y
= -yinc
;
969 SendMessage32A( wndPtr
->hwndSelf
, WM_GETMINMAXINFO
, 0, (LPARAM
)&MinMax
);
971 /* Some sanity checks */
973 TRACE(win
,"%d %d / %d %d / %d %d / %d %d\n",
974 MinMax
.ptMaxSize
.x
, MinMax
.ptMaxSize
.y
,
975 MinMax
.ptMaxPosition
.x
, MinMax
.ptMaxPosition
.y
,
976 MinMax
.ptMaxTrackSize
.x
, MinMax
.ptMaxTrackSize
.y
,
977 MinMax
.ptMinTrackSize
.x
, MinMax
.ptMinTrackSize
.y
);
978 MinMax
.ptMaxTrackSize
.x
= MAX( MinMax
.ptMaxTrackSize
.x
,
979 MinMax
.ptMinTrackSize
.x
);
980 MinMax
.ptMaxTrackSize
.y
= MAX( MinMax
.ptMaxTrackSize
.y
,
981 MinMax
.ptMinTrackSize
.y
);
983 if (maxSize
) *maxSize
= MinMax
.ptMaxSize
;
984 if (maxPos
) *maxPos
= MinMax
.ptMaxPosition
;
985 if (minTrack
) *minTrack
= MinMax
.ptMinTrackSize
;
986 if (maxTrack
) *maxTrack
= MinMax
.ptMaxTrackSize
;
989 /***********************************************************************
992 * Fill in lpRect and return additional flags to be used with SetWindowPos().
993 * This function assumes that 'cmd' is different from the current window
996 UINT16
WINPOS_MinMaximize( WND
* wndPtr
, UINT16 cmd
, LPRECT16 lpRect
)
1000 POINT32 size
= { wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
};
1001 LPINTERNALPOS lpPos
= WINPOS_InitInternalPos( wndPtr
, size
,
1002 &wndPtr
->rectWindow
);
1004 TRACE(win
,"0x%04x %u\n", wndPtr
->hwndSelf
, cmd
);
1006 if (lpPos
&& !HOOK_CallHooks16(WH_CBT
, HCBT_MINMAX
, wndPtr
->hwndSelf
, cmd
))
1008 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1010 if( !SendMessage32A( wndPtr
->hwndSelf
, WM_QUERYOPEN
, 0, 0L ) )
1011 return (SWP_NOSIZE
| SWP_NOMOVE
);
1012 swpFlags
|= SWP_NOCOPYBITS
;
1017 if( wndPtr
->dwStyle
& WS_MAXIMIZE
)
1019 wndPtr
->flags
|= WIN_RESTORE_MAX
;
1020 wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
1023 wndPtr
->flags
&= ~WIN_RESTORE_MAX
;
1024 wndPtr
->dwStyle
|= WS_MINIMIZE
;
1026 lpPos
->ptIconPos
= WINPOS_FindIconPos( wndPtr
, lpPos
->ptIconPos
);
1028 SetRect16( lpRect
, lpPos
->ptIconPos
.x
, lpPos
->ptIconPos
.y
,
1029 SYSMETRICS_CXICON
, SYSMETRICS_CYICON
);
1030 swpFlags
|= SWP_NOCOPYBITS
;
1034 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &pt
);
1035 WINPOS_GetMinMaxInfo( wndPtr
, &size
, &pt
, NULL
, NULL
);
1036 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
1038 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1040 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
1041 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
1043 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
1045 SetRect16( lpRect
, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
,
1050 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1052 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
1053 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
1054 if( wndPtr
->flags
& WIN_RESTORE_MAX
)
1056 /* Restore to maximized position */
1057 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &pt
);
1058 WINPOS_GetMinMaxInfo( wndPtr
, &size
, &pt
, NULL
, NULL
);
1059 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
1060 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
1061 SetRect16( lpRect
, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
, size
.x
, size
.y
);
1066 if( !(wndPtr
->dwStyle
& WS_MAXIMIZE
) ) return (UINT16
)(-1);
1067 else wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
1069 /* Restore to normal position */
1071 *lpRect
= lpPos
->rectNormal
;
1072 lpRect
->right
-= lpRect
->left
;
1073 lpRect
->bottom
-= lpRect
->top
;
1077 } else swpFlags
|= SWP_NOSIZE
| SWP_NOMOVE
;
1081 /***********************************************************************
1082 * ShowWindowAsync32 (USER32.535)
1084 * doesn't wait; returns immediately.
1085 * used by threads to toggle windows in other (possibly hanging) threads
1087 BOOL32 WINAPI
ShowWindowAsync32( HWND32 hwnd
, INT32 cmd
)
1089 /* FIXME: does ShowWindow32() return immediately ? */
1090 return ShowWindow32(hwnd
, cmd
);
1094 /***********************************************************************
1095 * ShowWindow16 (USER.42)
1097 BOOL16 WINAPI
ShowWindow16( HWND16 hwnd
, INT16 cmd
)
1099 return ShowWindow32(hwnd
,cmd
);
1103 /***********************************************************************
1104 * ShowWindow32 (USER32.534)
1106 BOOL32 WINAPI
ShowWindow32( HWND32 hwnd
, INT32 cmd
)
1108 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1109 BOOL32 wasVisible
, showFlag
;
1110 RECT16 newPos
= {0, 0, 0, 0};
1113 if (!wndPtr
) return FALSE
;
1115 TRACE(win
,"hwnd=%04x, cmd=%d\n", hwnd
, cmd
);
1117 wasVisible
= (wndPtr
->dwStyle
& WS_VISIBLE
) != 0;
1122 if (!wasVisible
) return FALSE
;
1123 swp
|= SWP_HIDEWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
|
1124 SWP_NOACTIVATE
| SWP_NOZORDER
;
1127 case SW_SHOWMINNOACTIVE
:
1128 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1130 case SW_SHOWMINIMIZED
:
1131 swp
|= SWP_SHOWWINDOW
;
1134 swp
|= SWP_FRAMECHANGED
;
1135 if( !(wndPtr
->dwStyle
& WS_MINIMIZE
) )
1136 swp
|= WINPOS_MinMaximize( wndPtr
, SW_MINIMIZE
, &newPos
);
1137 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1140 case SW_SHOWMAXIMIZED
: /* same as SW_MAXIMIZE */
1141 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
1142 if( !(wndPtr
->dwStyle
& WS_MAXIMIZE
) )
1143 swp
|= WINPOS_MinMaximize( wndPtr
, SW_MAXIMIZE
, &newPos
);
1144 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1148 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1151 swp
|= SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
;
1154 case SW_SHOWNOACTIVATE
:
1155 swp
|= SWP_NOZORDER
;
1156 if (GetActiveWindow32()) swp
|= SWP_NOACTIVATE
;
1158 case SW_SHOWNORMAL
: /* same as SW_NORMAL: */
1159 case SW_SHOWDEFAULT
: /* FIXME: should have its own handler */
1161 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
1163 if( wndPtr
->dwStyle
& (WS_MINIMIZE
| WS_MAXIMIZE
) )
1164 swp
|= WINPOS_MinMaximize( wndPtr
, SW_RESTORE
, &newPos
);
1165 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1169 showFlag
= (cmd
!= SW_HIDE
);
1170 if (showFlag
!= wasVisible
)
1172 SendMessage32A( hwnd
, WM_SHOWWINDOW
, showFlag
, 0 );
1173 if (!IsWindow32( hwnd
)) return wasVisible
;
1176 if ((wndPtr
->dwStyle
& WS_CHILD
) &&
1177 !IsWindowVisible32( wndPtr
->parent
->hwndSelf
) &&
1178 (swp
& (SWP_NOSIZE
| SWP_NOMOVE
)) == (SWP_NOSIZE
| SWP_NOMOVE
) )
1180 /* Don't call SetWindowPos32() on invisible child windows */
1181 if (cmd
== SW_HIDE
) wndPtr
->dwStyle
&= ~WS_VISIBLE
;
1182 else wndPtr
->dwStyle
|= WS_VISIBLE
;
1186 /* We can't activate a child window */
1187 if (wndPtr
->dwStyle
& WS_CHILD
) swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1188 SetWindowPos32( hwnd
, HWND_TOP
,
1189 newPos
.left
, newPos
.top
, newPos
.right
, newPos
.bottom
, swp
);
1190 if (!IsWindow32( hwnd
)) return wasVisible
;
1191 else if( wndPtr
->dwStyle
& WS_MINIMIZE
) WINPOS_ShowIconTitle( wndPtr
, TRUE
);
1194 if (wndPtr
->flags
& WIN_NEED_SIZE
)
1196 /* should happen only in CreateWindowEx() */
1197 int wParam
= SIZE_RESTORED
;
1199 wndPtr
->flags
&= ~WIN_NEED_SIZE
;
1200 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wParam
= SIZE_MAXIMIZED
;
1201 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= SIZE_MINIMIZED
;
1202 SendMessage32A( hwnd
, WM_SIZE
, wParam
,
1203 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
1204 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
1205 SendMessage32A( hwnd
, WM_MOVE
, 0,
1206 MAKELONG(wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
) );
1213 /***********************************************************************
1214 * GetInternalWindowPos16 (USER.460)
1216 UINT16 WINAPI
GetInternalWindowPos16( HWND16 hwnd
, LPRECT16 rectWnd
,
1219 WINDOWPLACEMENT16 wndpl
;
1220 if (GetWindowPlacement16( hwnd
, &wndpl
))
1222 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1223 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1224 return wndpl
.showCmd
;
1230 /***********************************************************************
1231 * GetInternalWindowPos32 (USER32.245)
1233 UINT32 WINAPI
GetInternalWindowPos32( HWND32 hwnd
, LPRECT32 rectWnd
,
1236 WINDOWPLACEMENT32 wndpl
;
1237 if (GetWindowPlacement32( hwnd
, &wndpl
))
1239 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1240 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1241 return wndpl
.showCmd
;
1246 /***********************************************************************
1247 * GetWindowPlacement16 (USER.370)
1249 BOOL16 WINAPI
GetWindowPlacement16( HWND16 hwnd
, WINDOWPLACEMENT16
*wndpl
)
1251 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
1254 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)WINPOS_InitInternalPos( pWnd
,
1255 *(LPPOINT32
)&pWnd
->rectWindow
.left
, &pWnd
->rectWindow
);
1256 wndpl
->length
= sizeof(*wndpl
);
1257 if( pWnd
->dwStyle
& WS_MINIMIZE
)
1258 wndpl
->showCmd
= SW_SHOWMINIMIZED
;
1260 wndpl
->showCmd
= ( pWnd
->dwStyle
& WS_MAXIMIZE
)
1261 ? SW_SHOWMAXIMIZED
: SW_SHOWNORMAL
;
1262 if( pWnd
->flags
& WIN_RESTORE_MAX
)
1263 wndpl
->flags
= WPF_RESTORETOMAXIMIZED
;
1266 wndpl
->ptMinPosition
= lpPos
->ptIconPos
;
1267 wndpl
->ptMaxPosition
= lpPos
->ptMaxPos
;
1268 wndpl
->rcNormalPosition
= lpPos
->rectNormal
;
1275 /***********************************************************************
1276 * GetWindowPlacement32 (USER32.307)
1278 BOOL32 WINAPI
GetWindowPlacement32( HWND32 hwnd
, WINDOWPLACEMENT32
*pwpl32
)
1282 WINDOWPLACEMENT16 wpl
;
1283 wpl
.length
= sizeof(wpl
);
1284 if( GetWindowPlacement16( hwnd
, &wpl
) )
1286 pwpl32
->length
= sizeof(*pwpl32
);
1287 pwpl32
->flags
= wpl
.flags
;
1288 pwpl32
->showCmd
= wpl
.showCmd
;
1289 CONV_POINT16TO32( &wpl
.ptMinPosition
, &pwpl32
->ptMinPosition
);
1290 CONV_POINT16TO32( &wpl
.ptMaxPosition
, &pwpl32
->ptMaxPosition
);
1291 CONV_RECT16TO32( &wpl
.rcNormalPosition
, &pwpl32
->rcNormalPosition
);
1299 /***********************************************************************
1300 * WINPOS_SetPlacement
1302 static BOOL32
WINPOS_SetPlacement( HWND32 hwnd
, const WINDOWPLACEMENT16
*wndpl
,
1305 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
1308 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)WINPOS_InitInternalPos( pWnd
,
1309 *(LPPOINT32
)&pWnd
->rectWindow
.left
, &pWnd
->rectWindow
);
1311 if( flags
& PLACE_MIN
) lpPos
->ptIconPos
= wndpl
->ptMinPosition
;
1312 if( flags
& PLACE_MAX
) lpPos
->ptMaxPos
= wndpl
->ptMaxPosition
;
1313 if( flags
& PLACE_RECT
) lpPos
->rectNormal
= wndpl
->rcNormalPosition
;
1315 if( pWnd
->dwStyle
& WS_MINIMIZE
)
1317 WINPOS_ShowIconTitle( pWnd
, FALSE
);
1318 if( wndpl
->flags
& WPF_SETMINPOSITION
&& !EMPTYPOINT(lpPos
->ptIconPos
))
1319 SetWindowPos32( hwnd
, 0, lpPos
->ptIconPos
.x
, lpPos
->ptIconPos
.y
,
1320 0, 0, SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1322 else if( pWnd
->dwStyle
& WS_MAXIMIZE
)
1324 if( !EMPTYPOINT(lpPos
->ptMaxPos
) )
1325 SetWindowPos32( hwnd
, 0, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
,
1326 0, 0, SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1328 else if( flags
& PLACE_RECT
)
1329 SetWindowPos32( hwnd
, 0, lpPos
->rectNormal
.left
, lpPos
->rectNormal
.top
,
1330 lpPos
->rectNormal
.right
- lpPos
->rectNormal
.left
,
1331 lpPos
->rectNormal
.bottom
- lpPos
->rectNormal
.top
,
1332 SWP_NOZORDER
| SWP_NOACTIVATE
);
1334 ShowWindow32( hwnd
, wndpl
->showCmd
);
1335 if( IsWindow32(hwnd
) && pWnd
->dwStyle
& WS_MINIMIZE
)
1337 if( pWnd
->dwStyle
& WS_VISIBLE
) WINPOS_ShowIconTitle( pWnd
, TRUE
);
1339 /* SDK: ...valid only the next time... */
1340 if( wndpl
->flags
& WPF_RESTORETOMAXIMIZED
) pWnd
->flags
|= WIN_RESTORE_MAX
;
1348 /***********************************************************************
1349 * SetWindowPlacement16 (USER.371)
1351 BOOL16 WINAPI
SetWindowPlacement16(HWND16 hwnd
, const WINDOWPLACEMENT16
*wndpl
)
1353 return WINPOS_SetPlacement( hwnd
, wndpl
,
1354 PLACE_MIN
| PLACE_MAX
| PLACE_RECT
);
1357 /***********************************************************************
1358 * SetWindowPlacement32 (USER32.519)
1360 BOOL32 WINAPI
SetWindowPlacement32( HWND32 hwnd
, const WINDOWPLACEMENT32
*pwpl32
)
1364 WINDOWPLACEMENT16 wpl
= { sizeof(WINDOWPLACEMENT16
),
1365 pwpl32
->flags
, pwpl32
->showCmd
, { pwpl32
->ptMinPosition
.x
,
1366 pwpl32
->ptMinPosition
.y
}, { pwpl32
->ptMaxPosition
.x
,
1367 pwpl32
->ptMaxPosition
.y
}, { pwpl32
->rcNormalPosition
.left
,
1368 pwpl32
->rcNormalPosition
.top
, pwpl32
->rcNormalPosition
.right
,
1369 pwpl32
->rcNormalPosition
.bottom
} };
1371 return WINPOS_SetPlacement( hwnd
, &wpl
, PLACE_MIN
| PLACE_MAX
| PLACE_RECT
);
1377 /***********************************************************************
1378 * SetInternalWindowPos16 (USER.461)
1380 void WINAPI
SetInternalWindowPos16( HWND16 hwnd
, UINT16 showCmd
,
1381 LPRECT16 rect
, LPPOINT16 pt
)
1383 if( IsWindow16(hwnd
) )
1385 WINDOWPLACEMENT16 wndpl
;
1388 wndpl
.length
= sizeof(wndpl
);
1389 wndpl
.showCmd
= showCmd
;
1390 wndpl
.flags
= flags
= 0;
1395 wndpl
.flags
|= WPF_SETMINPOSITION
;
1396 wndpl
.ptMinPosition
= *pt
;
1400 flags
|= PLACE_RECT
;
1401 wndpl
.rcNormalPosition
= *rect
;
1403 WINPOS_SetPlacement( hwnd
, &wndpl
, flags
);
1408 /***********************************************************************
1409 * SetInternalWindowPos32 (USER32.483)
1411 void WINAPI
SetInternalWindowPos32( HWND32 hwnd
, UINT32 showCmd
,
1412 LPRECT32 rect
, LPPOINT32 pt
)
1414 if( IsWindow32(hwnd
) )
1416 WINDOWPLACEMENT16 wndpl
;
1419 wndpl
.length
= sizeof(wndpl
);
1420 wndpl
.showCmd
= showCmd
;
1421 wndpl
.flags
= flags
= 0;
1426 wndpl
.flags
|= WPF_SETMINPOSITION
;
1427 CONV_POINT32TO16( pt
, &wndpl
.ptMinPosition
);
1431 flags
|= PLACE_RECT
;
1432 CONV_RECT32TO16( rect
, &wndpl
.rcNormalPosition
);
1434 WINPOS_SetPlacement( hwnd
, &wndpl
, flags
);
1439 /***********************************************************************
1440 * WINPOS_ForceXWindowRaise
1442 * Raise a window on top of the X stacking order, while preserving
1443 * the correct Windows Z order.
1445 static void WINPOS_ForceXWindowRaise( WND
* pWnd
)
1447 XWindowChanges winChanges
;
1450 /* Raise all windows up to pWnd according to their Z order.
1451 * (it would be easier with sibling-related Below but it doesn't
1452 * work very well with SGI mwm for instance)
1454 winChanges
.stack_mode
= Above
;
1457 if (pWnd
->window
) TSXReconfigureWMWindow( display
, pWnd
->window
, 0,
1458 CWStackMode
, &winChanges
);
1459 wndPrev
= WIN_GetDesktop()->child
;
1460 if (wndPrev
== pWnd
) break;
1461 while (wndPrev
&& (wndPrev
->next
!= pWnd
)) wndPrev
= wndPrev
->next
;
1467 /*******************************************************************
1468 * WINPOS_SetActiveWindow
1470 * SetActiveWindow() back-end. This is the only function that
1471 * can assign active status to a window. It must be called only
1472 * for the top level windows.
1474 BOOL32
WINPOS_SetActiveWindow( HWND32 hWnd
, BOOL32 fMouse
, BOOL32 fChangeFocus
)
1476 CBTACTIVATESTRUCT16
* cbtStruct
;
1477 WND
* wndPtr
, *wndTemp
;
1478 HQUEUE16 hOldActiveQueue
, hNewActiveQueue
;
1481 /* paranoid checks */
1482 if( hWnd
== GetDesktopWindow32() || hWnd
== hwndActive
) return 0;
1484 /* if (wndPtr && (GetTaskQueue(0) != wndPtr->hmemTaskQ))
1487 wndPtr
= WIN_FindWndPtr(hWnd
);
1488 hOldActiveQueue
= (pActiveQueue
)?pActiveQueue
->self
: 0;
1490 if( (wndTemp
= WIN_FindWndPtr(hwndActive
)) )
1491 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1493 TRACE(win
,"no current active window.\n");
1495 /* call CBT hook chain */
1496 if ((cbtStruct
= SEGPTR_NEW(CBTACTIVATESTRUCT16
)))
1499 cbtStruct
->fMouse
= fMouse
;
1500 cbtStruct
->hWndActive
= hwndActive
;
1501 wRet
= HOOK_CallHooks16( WH_CBT
, HCBT_ACTIVATE
, (WPARAM16
)hWnd
,
1502 (LPARAM
)SEGPTR_GET(cbtStruct
) );
1503 SEGPTR_FREE(cbtStruct
);
1504 if (wRet
) return wRet
;
1507 /* set prev active wnd to current active wnd and send notification */
1508 if ((hwndPrevActive
= hwndActive
) && IsWindow32(hwndPrevActive
))
1510 if (!SendMessage32A( hwndPrevActive
, WM_NCACTIVATE
, FALSE
, 0 ))
1512 if (GetSysModalWindow16() != hWnd
) return 0;
1513 /* disregard refusal if hWnd is sysmodal */
1517 SendMessage32A( hwndPrevActive
, WM_ACTIVATE
,
1518 MAKEWPARAM( WA_INACTIVE
, wIconized
),
1521 /* FIXME: must be SendMessage16() because 32A doesn't do
1522 * intertask at this time */
1523 SendMessage16( hwndPrevActive
, WM_ACTIVATE
, WA_INACTIVE
,
1524 MAKELPARAM( (HWND16
)hWnd
, wIconized
) );
1527 /* check if something happened during message processing */
1528 if( hwndPrevActive
!= hwndActive
) return 0;
1531 /* set active wnd */
1534 /* send palette messages */
1535 if (hWnd
&& SendMessage16( hWnd
, WM_QUERYNEWPALETTE
, 0, 0L))
1536 SendMessage16((HWND16
)-1, WM_PALETTEISCHANGING
, (WPARAM16
)hWnd
, 0L );
1538 /* if prev wnd is minimized redraw icon title */
1539 if( IsIconic32( hwndPrevActive
) ) WINPOS_RedrawIconTitle(hwndPrevActive
);
1541 /* managed windows will get ConfigureNotify event */
1542 if (wndPtr
&& !(wndPtr
->dwStyle
& WS_CHILD
) && !(wndPtr
->flags
& WIN_MANAGED
))
1544 /* check Z-order and bring hWnd to the top */
1545 for (wndTemp
= WIN_GetDesktop()->child
; wndTemp
; wndTemp
= wndTemp
->next
)
1546 if (wndTemp
->dwStyle
& WS_VISIBLE
) break;
1548 if( wndTemp
!= wndPtr
)
1549 SetWindowPos32(hWnd
, HWND_TOP
, 0,0,0,0,
1550 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1551 if (!IsWindow32(hWnd
)) return 0;
1554 hNewActiveQueue
= wndPtr
? wndPtr
->hmemTaskQ
: 0;
1556 /* send WM_ACTIVATEAPP if necessary */
1557 if (hOldActiveQueue
!= hNewActiveQueue
)
1559 WND
**list
, **ppWnd
;
1561 if ((list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1563 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1565 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
1567 if ((*ppWnd
)->hmemTaskQ
== hOldActiveQueue
)
1568 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1569 0, QUEUE_GetQueueTask(hNewActiveQueue
) );
1571 HeapFree( SystemHeap
, 0, list
);
1574 pActiveQueue
= (hNewActiveQueue
)
1575 ? (MESSAGEQUEUE
*) GlobalLock16(hNewActiveQueue
) : NULL
;
1577 if ((list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1579 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1581 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
1583 if ((*ppWnd
)->hmemTaskQ
== hNewActiveQueue
)
1584 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1585 1, QUEUE_GetQueueTask( hOldActiveQueue
) );
1587 HeapFree( SystemHeap
, 0, list
);
1589 if (!IsWindow32(hWnd
)) return 0;
1594 /* walk up to the first unowned window */
1596 while (wndTemp
->owner
) wndTemp
= wndTemp
->owner
;
1597 /* and set last active owned popup */
1598 wndTemp
->hwndLastActive
= hWnd
;
1600 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1601 SendMessage32A( hWnd
, WM_NCACTIVATE
, TRUE
, 0 );
1603 SendMessage32A( hWnd
, WM_ACTIVATE
,
1604 MAKEWPARAM( (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
, wIconized
),
1605 (LPARAM
)hwndPrevActive
);
1607 SendMessage16(hWnd
, WM_ACTIVATE
, (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
,
1608 MAKELPARAM( (HWND16
)hwndPrevActive
, wIconized
) );
1611 if( !IsWindow32(hWnd
) ) return 0;
1614 /* change focus if possible */
1615 if( fChangeFocus
&& GetFocus32() )
1616 if( WIN_GetTopParent(GetFocus32()) != hwndActive
)
1617 FOCUS_SwitchFocus( GetFocus32(),
1618 (wndPtr
&& (wndPtr
->dwStyle
& WS_MINIMIZE
))?
1623 if( !hwndPrevActive
&& wndPtr
&&
1624 wndPtr
->window
&& !(wndPtr
->flags
& WIN_MANAGED
) )
1625 WINPOS_ForceXWindowRaise(wndPtr
);
1627 /* if active wnd is minimized redraw icon title */
1628 if( IsIconic32(hwndActive
) ) WINPOS_RedrawIconTitle(hwndActive
);
1630 return (hWnd
== hwndActive
);
1633 /*******************************************************************
1634 * WINPOS_ActivateOtherWindow
1636 * Activates window other than pWnd.
1638 BOOL32
WINPOS_ActivateOtherWindow(WND
* pWnd
)
1643 if( pWnd
->hwndSelf
== hwndPrevActive
)
1646 if( hwndActive
!= pWnd
->hwndSelf
&&
1647 ( hwndActive
|| QUEUE_IsExitingQueue(pWnd
->hmemTaskQ
)) )
1650 if( !(pWnd
->dwStyle
& WS_POPUP
) || !(pWnd
->owner
) ||
1651 !WINPOS_CanActivate((pWndTo
= WIN_GetTopParentPtr(pWnd
->owner
))) )
1653 WND
* pWndPtr
= WIN_GetTopParentPtr(pWnd
);
1655 pWndTo
= WIN_FindWndPtr(hwndPrevActive
);
1657 while( !WINPOS_CanActivate(pWndTo
) )
1659 /* by now owned windows should've been taken care of */
1661 pWndTo
= pWndPtr
->next
;
1663 if( !pWndTo
) break;
1667 bRet
= WINPOS_SetActiveWindow( pWndTo
? pWndTo
->hwndSelf
: 0, FALSE
, TRUE
);
1669 /* switch desktop queue to current active */
1670 if( pWndTo
) WIN_GetDesktop()->hmemTaskQ
= pWndTo
->hmemTaskQ
;
1676 /*******************************************************************
1677 * WINPOS_ChangeActiveWindow
1680 BOOL32
WINPOS_ChangeActiveWindow( HWND32 hWnd
, BOOL32 mouseMsg
)
1682 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
1684 if (!hWnd
) return WINPOS_SetActiveWindow( 0, mouseMsg
, TRUE
);
1686 if( !wndPtr
) return FALSE
;
1688 /* child windows get WM_CHILDACTIVATE message */
1689 if( (wndPtr
->dwStyle
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
1690 return SendMessage32A(hWnd
, WM_CHILDACTIVATE
, 0, 0L);
1692 /* owned popups imply owner activation - not sure */
1693 if ((wndPtr
->dwStyle
& WS_POPUP
) && wndPtr
->owner
&&
1694 (wndPtr
->owner
->dwStyle
& WS_VISIBLE
) &&
1695 !(wndPtr
->owner
->dwStyle
& WS_DISABLED
))
1697 if (!(wndPtr
= wndPtr
->owner
)) return FALSE
;
1698 hWnd
= wndPtr
->hwndSelf
;
1701 if( hWnd
== hwndActive
) return FALSE
;
1703 if( !WINPOS_SetActiveWindow(hWnd
,mouseMsg
,TRUE
) )
1706 /* switch desktop queue to current active */
1707 if( wndPtr
->parent
== WIN_GetDesktop())
1708 WIN_GetDesktop()->hmemTaskQ
= wndPtr
->hmemTaskQ
;
1714 /***********************************************************************
1715 * WINPOS_SendNCCalcSize
1717 * Send a WM_NCCALCSIZE message to a window.
1718 * All parameters are read-only except newClientRect.
1719 * oldWindowRect, oldClientRect and winpos must be non-NULL only
1720 * when calcValidRect is TRUE.
1722 LONG
WINPOS_SendNCCalcSize( HWND32 hwnd
, BOOL32 calcValidRect
,
1723 RECT32
*newWindowRect
, RECT32
*oldWindowRect
,
1724 RECT32
*oldClientRect
, WINDOWPOS32
*winpos
,
1725 RECT32
*newClientRect
)
1727 NCCALCSIZE_PARAMS32 params
;
1728 WINDOWPOS32 winposCopy
;
1731 params
.rgrc
[0] = *newWindowRect
;
1734 winposCopy
= *winpos
;
1735 params
.rgrc
[1] = *oldWindowRect
;
1736 params
.rgrc
[2] = *oldClientRect
;
1737 params
.lppos
= &winposCopy
;
1739 result
= SendMessage32A( hwnd
, WM_NCCALCSIZE
, calcValidRect
,
1741 TRACE(win
, "%d,%d-%d,%d\n",
1742 params
.rgrc
[0].left
, params
.rgrc
[0].top
,
1743 params
.rgrc
[0].right
, params
.rgrc
[0].bottom
);
1744 *newClientRect
= params
.rgrc
[0];
1749 /***********************************************************************
1750 * WINPOS_HandleWindowPosChanging16
1752 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1754 LONG
WINPOS_HandleWindowPosChanging16( WND
*wndPtr
, WINDOWPOS16
*winpos
)
1756 POINT32 maxSize
, minTrack
;
1757 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1758 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1759 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1761 WINPOS_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, &minTrack
, NULL
);
1762 if (maxSize
.x
< winpos
->cx
) winpos
->cx
= maxSize
.x
;
1763 if (maxSize
.y
< winpos
->cy
) winpos
->cy
= maxSize
.y
;
1764 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
1766 if (winpos
->cx
< minTrack
.x
) winpos
->cx
= minTrack
.x
;
1767 if (winpos
->cy
< minTrack
.y
) winpos
->cy
= minTrack
.y
;
1774 /***********************************************************************
1775 * WINPOS_HandleWindowPosChanging32
1777 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1779 LONG
WINPOS_HandleWindowPosChanging32( WND
*wndPtr
, WINDOWPOS32
*winpos
)
1782 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1783 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1784 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1786 WINPOS_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, NULL
, NULL
);
1787 winpos
->cx
= MIN( winpos
->cx
, maxSize
.x
);
1788 winpos
->cy
= MIN( winpos
->cy
, maxSize
.y
);
1794 /***********************************************************************
1795 * WINPOS_MoveWindowZOrder
1797 * Move a window in Z order, invalidating everything that needs it.
1798 * Only necessary for windows without associated X window.
1800 static void WINPOS_MoveWindowZOrder( HWND32 hwnd
, HWND32 hwndAfter
)
1803 WND
*pWndAfter
, *pWndCur
, *wndPtr
= WIN_FindWndPtr( hwnd
);
1805 /* We have two possible cases:
1806 * - The window is moving up: we have to invalidate all areas
1807 * of the window that were covered by other windows
1808 * - The window is moving down: we have to invalidate areas
1809 * of other windows covered by this one.
1812 if (hwndAfter
== HWND_TOP
)
1816 else if (hwndAfter
== HWND_BOTTOM
)
1818 if (!wndPtr
->next
) return; /* Already at the bottom */
1823 if (!(pWndAfter
= WIN_FindWndPtr( hwndAfter
))) return;
1824 if (wndPtr
->next
== pWndAfter
) return; /* Already placed right */
1826 /* Determine which window we encounter first in Z-order */
1827 pWndCur
= wndPtr
->parent
->child
;
1828 while ((pWndCur
!= wndPtr
) && (pWndCur
!= pWndAfter
))
1829 pWndCur
= pWndCur
->next
;
1830 movingUp
= (pWndCur
== pWndAfter
);
1835 WND
*pWndPrevAfter
= wndPtr
->next
;
1836 WIN_UnlinkWindow( hwnd
);
1837 WIN_LinkWindow( hwnd
, hwndAfter
);
1838 pWndCur
= wndPtr
->next
;
1839 while (pWndCur
!= pWndPrevAfter
)
1841 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1842 pWndCur
->rectWindow
.top
,
1843 pWndCur
->rectWindow
.right
,
1844 pWndCur
->rectWindow
.bottom
};
1845 OffsetRect32( &rect
, -wndPtr
->rectClient
.left
,
1846 -wndPtr
->rectClient
.top
);
1847 PAINT_RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
1848 RDW_FRAME
| RDW_ERASE
, 0 );
1849 pWndCur
= pWndCur
->next
;
1852 else /* Moving down */
1854 pWndCur
= wndPtr
->next
;
1855 WIN_UnlinkWindow( hwnd
);
1856 WIN_LinkWindow( hwnd
, hwndAfter
);
1857 while (pWndCur
!= wndPtr
)
1859 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1860 pWndCur
->rectWindow
.top
,
1861 pWndCur
->rectWindow
.right
,
1862 pWndCur
->rectWindow
.bottom
};
1863 OffsetRect32( &rect
, -pWndCur
->rectClient
.left
,
1864 -pWndCur
->rectClient
.top
);
1865 PAINT_RedrawWindow( pWndCur
->hwndSelf
, &rect
, 0, RDW_INVALIDATE
|
1866 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
1867 pWndCur
= pWndCur
->next
;
1872 /***********************************************************************
1873 * WINPOS_ReorderOwnedPopups
1875 * fix Z order taking into account owned popups -
1876 * basically we need to maintain them above the window that owns them
1878 HWND32
WINPOS_ReorderOwnedPopups(HWND32 hwndInsertAfter
,WND
* wndPtr
,WORD flags
)
1880 WND
* w
= WIN_GetDesktop()->child
;
1882 if( wndPtr
->dwStyle
& WS_POPUP
&& wndPtr
->owner
)
1884 /* implement "local z-order" between the top and owner window */
1886 HWND32 hwndLocalPrev
= HWND_TOP
;
1888 if( hwndInsertAfter
!= HWND_TOP
)
1890 while( w
!= wndPtr
->owner
)
1892 if (w
!= wndPtr
) hwndLocalPrev
= w
->hwndSelf
;
1893 if( hwndLocalPrev
== hwndInsertAfter
) break;
1896 hwndInsertAfter
= hwndLocalPrev
;
1900 else if( wndPtr
->dwStyle
& WS_CHILD
) return hwndInsertAfter
;
1902 w
= WIN_GetDesktop()->child
;
1905 if( w
== wndPtr
) break;
1907 if( w
->dwStyle
& WS_POPUP
&& w
->owner
== wndPtr
)
1909 SetWindowPos32(w
->hwndSelf
, hwndInsertAfter
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
|
1910 SWP_NOACTIVATE
| SWP_NOSENDCHANGING
| SWP_DEFERERASE
);
1911 hwndInsertAfter
= w
->hwndSelf
;
1916 return hwndInsertAfter
;
1919 /***********************************************************************
1920 * WINPOS_SizeMoveClean
1922 * Make window look nice without excessive repainting
1926 * visible regions are in window coordinates
1927 * update regions are in window client coordinates
1928 * client and window rectangles are in parent client coordinates
1930 * FIXME: Move visible and update regions to the same coordinate system
1931 * (either parent client or window). This is a lot of work though.
1933 static UINT32
WINPOS_SizeMoveClean( WND
* Wnd
, HRGN32 oldVisRgn
,
1934 LPRECT32 lpOldWndRect
,
1935 LPRECT32 lpOldClientRect
, UINT32 uFlags
)
1937 HRGN32 newVisRgn
= DCE_GetVisRgn(Wnd
->hwndSelf
,DCX_WINDOW
| DCX_CLIPSIBLINGS
);
1938 HRGN32 dirtyRgn
= CreateRectRgn32(0,0,0,0);
1941 TRACE(win
,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n",
1942 Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
,
1943 Wnd
->rectWindow
.right
, Wnd
->rectWindow
.bottom
,
1944 lpOldWndRect
->left
, lpOldWndRect
->top
,
1945 lpOldWndRect
->right
, lpOldWndRect
->bottom
);
1946 TRACE(win
,"\tnew client=(%i %i-%i %i) old client=(%i %i-%i %i)\n",
1947 Wnd
->rectClient
.left
, Wnd
->rectClient
.top
,
1948 Wnd
->rectClient
.right
, Wnd
->rectClient
.bottom
,
1949 lpOldClientRect
->left
, lpOldClientRect
->top
,
1950 lpOldClientRect
->right
,lpOldClientRect
->bottom
);
1952 if( (lpOldWndRect
->right
- lpOldWndRect
->left
) != (Wnd
->rectWindow
.right
- Wnd
->rectWindow
.left
) ||
1953 (lpOldWndRect
->bottom
- lpOldWndRect
->top
) != (Wnd
->rectWindow
.bottom
- Wnd
->rectWindow
.top
) )
1954 uFlags
|= SMC_DRAWFRAME
;
1956 CombineRgn32( dirtyRgn
, newVisRgn
, 0, RGN_COPY
);
1958 if( !(uFlags
& SMC_NOCOPY
) )
1959 CombineRgn32( newVisRgn
, newVisRgn
, oldVisRgn
, RGN_AND
);
1961 /* map regions to the parent client area */
1963 OffsetRgn32( dirtyRgn
, Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
);
1964 OffsetRgn32( oldVisRgn
, lpOldWndRect
->left
, lpOldWndRect
->top
);
1966 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1968 other
= CombineRgn32(dirtyRgn
, oldVisRgn
, dirtyRgn
, RGN_DIFF
);
1970 /* map visible region to the Wnd client area */
1972 OffsetRgn32( newVisRgn
, Wnd
->rectWindow
.left
- Wnd
->rectClient
.left
,
1973 Wnd
->rectWindow
.top
- Wnd
->rectClient
.top
);
1975 /* substract previously invalidated region from the Wnd visible region */
1977 my
= (Wnd
->hrgnUpdate
> 1) ? CombineRgn32( newVisRgn
, newVisRgn
,
1978 Wnd
->hrgnUpdate
, RGN_DIFF
)
1981 if( uFlags
& SMC_NOCOPY
) /* invalidate Wnd visible region */
1983 if (my
!= NULLREGION
)
1984 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, newVisRgn
, RDW_INVALIDATE
|
1985 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1986 else if(uFlags
& SMC_DRAWFRAME
)
1987 Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1989 else /* bitblt old client area */
1994 int xfrom
,yfrom
,xto
,yto
,width
,height
;
1996 if( uFlags
& SMC_DRAWFRAME
)
1998 /* copy only client area, frame will be redrawn anyway */
2000 xfrom
= lpOldClientRect
->left
; yfrom
= lpOldClientRect
->top
;
2001 xto
= Wnd
->rectClient
.left
; yto
= Wnd
->rectClient
.top
;
2002 width
= lpOldClientRect
->right
- xfrom
; height
= lpOldClientRect
->bottom
- yfrom
;
2003 updateRgn
= CreateRectRgn32( 0, 0, width
, height
);
2004 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
2005 SetRectRgn32( updateRgn
, 0, 0, Wnd
->rectClient
.right
- xto
,
2006 Wnd
->rectClient
.bottom
- yto
);
2010 xfrom
= lpOldWndRect
->left
; yfrom
= lpOldWndRect
->top
;
2011 xto
= Wnd
->rectWindow
.left
; yto
= Wnd
->rectWindow
.top
;
2012 width
= lpOldWndRect
->right
- xfrom
; height
= lpOldWndRect
->bottom
- yfrom
;
2013 updateRgn
= CreateRectRgn32( xto
- Wnd
->rectClient
.left
,
2014 yto
- Wnd
->rectClient
.top
,
2015 Wnd
->rectWindow
.right
- Wnd
->rectClient
.left
,
2016 Wnd
->rectWindow
.bottom
- Wnd
->rectClient
.top
);
2019 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
2021 /* substract new visRgn from target rect to get a region that won't be copied */
2023 update
= CombineRgn32( updateRgn
, updateRgn
, newVisRgn
, RGN_DIFF
);
2025 /* Blt valid bits using parent window DC */
2027 if( my
!= NULLREGION
&& (xfrom
!= xto
|| yfrom
!= yto
) )
2030 /* compute clipping region in parent client coordinates */
2032 OffsetRgn32( newVisRgn
, Wnd
->rectClient
.left
, Wnd
->rectClient
.top
);
2033 CombineRgn32( oldVisRgn
, oldVisRgn
, newVisRgn
, RGN_OR
);
2035 hDC
= GetDCEx32( Wnd
->parent
->hwndSelf
, oldVisRgn
,
2036 DCX_KEEPCLIPRGN
| DCX_INTERSECTRGN
|
2037 DCX_CACHE
| DCX_CLIPSIBLINGS
);
2039 BitBlt32( hDC
, xto
, yto
, width
, height
, hDC
, xfrom
, yfrom
, SRCCOPY
);
2040 ReleaseDC32( Wnd
->parent
->hwndSelf
, hDC
);
2043 if( update
!= NULLREGION
)
2044 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, updateRgn
, RDW_INVALIDATE
|
2045 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
2046 else if( uFlags
& SMC_DRAWFRAME
) Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
2047 DeleteObject32( updateRgn
);
2050 /* erase uncovered areas */
2052 if( !(uFlags
& SMC_NOPARENTERASE
) && (other
!= NULLREGION
) )
2053 PAINT_RedrawWindow( Wnd
->parent
->hwndSelf
, NULL
, dirtyRgn
,
2054 RDW_INVALIDATE
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
2055 DeleteObject32(dirtyRgn
);
2056 DeleteObject32(newVisRgn
);
2061 /***********************************************************************
2062 * WINPOS_FindDeskTopXWindow
2064 * Find the actual X window which needs be restacked.
2065 * Used by WINPOS_SetXWindowPos().
2067 static Window
WINPOS_FindDeskTopXWindow( WND
*wndPtr
)
2069 if (!(wndPtr
->flags
& WIN_MANAGED
))
2070 return wndPtr
->window
;
2073 Window window
, root
, parent
, *children
;
2075 window
= wndPtr
->window
;
2078 TSXQueryTree( display
, window
, &root
, &parent
,
2079 &children
, &nchildren
);
2080 TSXFree( children
);
2088 /***********************************************************************
2089 * WINPOS_SetXWindowPos
2091 * SetWindowPos() for an X window. Used by the real SetWindowPos().
2093 static void WINPOS_SetXWindowPos( const WINDOWPOS32
*winpos
)
2095 XWindowChanges winChanges
;
2097 WND
*wndPtr
= WIN_FindWndPtr( winpos
->hwnd
);
2099 if (!(winpos
->flags
& SWP_NOSIZE
))
2101 winChanges
.width
= winpos
->cx
;
2102 winChanges
.height
= winpos
->cy
;
2103 changeMask
|= CWWidth
| CWHeight
;
2105 /* Tweak dialog window size hints */
2107 if ((wndPtr
->flags
& WIN_MANAGED
) &&
2108 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
2110 XSizeHints
*size_hints
= TSXAllocSizeHints();
2114 long supplied_return
;
2116 TSXGetWMSizeHints( display
, wndPtr
->window
, size_hints
,
2117 &supplied_return
, XA_WM_NORMAL_HINTS
);
2118 size_hints
->min_width
= size_hints
->max_width
= winpos
->cx
;
2119 size_hints
->min_height
= size_hints
->max_height
= winpos
->cy
;
2120 TSXSetWMSizeHints( display
, wndPtr
->window
, size_hints
,
2121 XA_WM_NORMAL_HINTS
);
2122 TSXFree(size_hints
);
2126 if (!(winpos
->flags
& SWP_NOMOVE
))
2128 winChanges
.x
= winpos
->x
;
2129 winChanges
.y
= winpos
->y
;
2130 changeMask
|= CWX
| CWY
;
2132 if (!(winpos
->flags
& SWP_NOZORDER
))
2134 winChanges
.stack_mode
= Below
;
2135 changeMask
|= CWStackMode
;
2137 if (winpos
->hwndInsertAfter
== HWND_TOP
) winChanges
.stack_mode
= Above
;
2138 else if (winpos
->hwndInsertAfter
!= HWND_BOTTOM
)
2140 WND
* insertPtr
= WIN_FindWndPtr( winpos
->hwndInsertAfter
);
2143 stack
[0] = WINPOS_FindDeskTopXWindow( insertPtr
);
2144 stack
[1] = WINPOS_FindDeskTopXWindow( wndPtr
);
2146 /* for stupid window managers (i.e. all of them) */
2148 TSXRestackWindows(display
, stack
, 2);
2149 changeMask
&= ~CWStackMode
;
2152 if (!changeMask
) return;
2154 TSXReconfigureWMWindow( display
, wndPtr
->window
, 0, changeMask
, &winChanges
);
2158 /***********************************************************************
2159 * SetWindowPos (USER.232)
2161 BOOL16 WINAPI
SetWindowPos16( HWND16 hwnd
, HWND16 hwndInsertAfter
,
2162 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, WORD flags
)
2164 return SetWindowPos32(hwnd
,(INT32
)(INT16
)hwndInsertAfter
,x
,y
,cx
,cy
,flags
);
2167 /***********************************************************************
2168 * SetWindowPos (USER32.520)
2170 BOOL32 WINAPI
SetWindowPos32( HWND32 hwnd
, HWND32 hwndInsertAfter
,
2171 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
, WORD flags
)
2175 RECT32 newWindowRect
, newClientRect
, oldWindowRect
;
2177 HWND32 tempInsertAfter
= 0;
2180 BOOL32 resync
= FALSE
;
2182 TRACE(win
,"hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
2183 hwnd
, x
, y
, x
+cx
, y
+cy
, flags
);
2184 /* Check window handle */
2186 if (hwnd
== GetDesktopWindow32()) return FALSE
;
2187 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return FALSE
;
2189 if(wndPtr
->dwStyle
& WS_VISIBLE
)
2190 flags
&= ~SWP_SHOWWINDOW
;
2193 uFlags
|= SMC_NOPARENTERASE
;
2194 flags
&= ~SWP_HIDEWINDOW
;
2195 if (!(flags
& SWP_SHOWWINDOW
)) flags
|= SWP_NOREDRAW
;
2198 /* Check for windows that may not be resized
2199 FIXME: this should be done only for Windows 3.0 programs
2200 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
2201 flags |= SWP_NOSIZE | SWP_NOMOVE;
2203 /* Check dimensions */
2205 if (cx
<= 0) cx
= 1;
2206 if (cy
<= 0) cy
= 1;
2210 if (hwnd
== hwndActive
) flags
|= SWP_NOACTIVATE
; /* Already active */
2211 if ((wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
== cx
) &&
2212 (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
== cy
))
2213 flags
|= SWP_NOSIZE
; /* Already the right size */
2214 if ((wndPtr
->rectWindow
.left
== x
) && (wndPtr
->rectWindow
.top
== y
))
2215 flags
|= SWP_NOMOVE
; /* Already the right position */
2217 /* Check hwndInsertAfter */
2219 if (!(flags
& (SWP_NOZORDER
| SWP_NOACTIVATE
)))
2221 /* Ignore TOPMOST flags when activating a window */
2222 /* _and_ moving it in Z order. */
2223 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
2224 (hwndInsertAfter
== HWND_NOTOPMOST
))
2225 hwndInsertAfter
= HWND_TOP
;
2227 /* TOPMOST not supported yet */
2228 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
2229 (hwndInsertAfter
== HWND_NOTOPMOST
)) hwndInsertAfter
= HWND_TOP
;
2231 /* hwndInsertAfter must be a sibling of the window */
2232 if ((hwndInsertAfter
!= HWND_TOP
) && (hwndInsertAfter
!= HWND_BOTTOM
))
2234 WND
* wnd
= WIN_FindWndPtr(hwndInsertAfter
);
2237 if( wnd
->parent
!= wndPtr
->parent
) return FALSE
;
2238 if( wnd
->next
== wndPtr
) flags
|= SWP_NOZORDER
;
2241 else if (!(wndPtr
->window
))
2243 /* FIXME: the following optimization is no good for "X-ed" windows */
2244 if (hwndInsertAfter
== HWND_TOP
)
2245 flags
|= ( wndPtr
->parent
->child
== wndPtr
)? SWP_NOZORDER
: 0;
2246 else /* HWND_BOTTOM */
2247 flags
|= ( wndPtr
->next
)? 0: SWP_NOZORDER
;
2250 /* Fill the WINDOWPOS structure */
2253 winpos
.hwndInsertAfter
= hwndInsertAfter
;
2258 winpos
.flags
= flags
;
2260 /* Send WM_WINDOWPOSCHANGING message */
2262 if (!(winpos
.flags
& SWP_NOSENDCHANGING
))
2263 SendMessage32A( hwnd
, WM_WINDOWPOSCHANGING
, 0, (LPARAM
)&winpos
);
2265 /* Calculate new position and size */
2267 newWindowRect
= wndPtr
->rectWindow
;
2268 newClientRect
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? wndPtr
->rectWindow
2269 : wndPtr
->rectClient
;
2271 if (!(winpos
.flags
& SWP_NOSIZE
))
2273 newWindowRect
.right
= newWindowRect
.left
+ winpos
.cx
;
2274 newWindowRect
.bottom
= newWindowRect
.top
+ winpos
.cy
;
2276 if (!(winpos
.flags
& SWP_NOMOVE
))
2278 newWindowRect
.left
= winpos
.x
;
2279 newWindowRect
.top
= winpos
.y
;
2280 newWindowRect
.right
+= winpos
.x
- wndPtr
->rectWindow
.left
;
2281 newWindowRect
.bottom
+= winpos
.y
- wndPtr
->rectWindow
.top
;
2283 OffsetRect32( &newClientRect
, winpos
.x
- wndPtr
->rectWindow
.left
,
2284 winpos
.y
- wndPtr
->rectWindow
.top
);
2287 winpos
.flags
|= SWP_NOCLIENTMOVE
| SWP_NOCLIENTSIZE
;
2289 /* Reposition window in Z order */
2291 if (!(winpos
.flags
& SWP_NOZORDER
))
2293 /* reorder owned popups if hwnd is top-level window
2295 if( wndPtr
->parent
== WIN_GetDesktop() )
2296 hwndInsertAfter
= WINPOS_ReorderOwnedPopups( hwndInsertAfter
,
2297 wndPtr
, winpos
.flags
);
2301 WIN_UnlinkWindow( winpos
.hwnd
);
2302 WIN_LinkWindow( winpos
.hwnd
, hwndInsertAfter
);
2304 else WINPOS_MoveWindowZOrder( winpos
.hwnd
, hwndInsertAfter
);
2307 if ( !wndPtr
->window
&& !(winpos
.flags
& SWP_NOREDRAW
) &&
2308 ((winpos
.flags
& (SWP_NOMOVE
| SWP_NOSIZE
| SWP_FRAMECHANGED
))
2309 != (SWP_NOMOVE
| SWP_NOSIZE
)) )
2310 visRgn
= DCE_GetVisRgn(hwnd
, DCX_WINDOW
| DCX_CLIPSIBLINGS
);
2313 /* Send WM_NCCALCSIZE message to get new client area */
2314 if( (winpos
.flags
& (SWP_FRAMECHANGED
| SWP_NOSIZE
)) != SWP_NOSIZE
)
2316 result
= WINPOS_SendNCCalcSize( winpos
.hwnd
, TRUE
, &newWindowRect
,
2317 &wndPtr
->rectWindow
, &wndPtr
->rectClient
,
2318 &winpos
, &newClientRect
);
2320 /* FIXME: WVR_ALIGNxxx */
2322 if( newClientRect
.left
!= wndPtr
->rectClient
.left
||
2323 newClientRect
.top
!= wndPtr
->rectClient
.top
)
2324 winpos
.flags
&= ~SWP_NOCLIENTMOVE
;
2326 if( (newClientRect
.right
- newClientRect
.left
!=
2327 wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
) ||
2328 (newClientRect
.bottom
- newClientRect
.top
!=
2329 wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
) )
2330 winpos
.flags
&= ~SWP_NOCLIENTSIZE
;
2333 if( !(flags
& SWP_NOMOVE
) && (newClientRect
.left
!= wndPtr
->rectClient
.left
||
2334 newClientRect
.top
!= wndPtr
->rectClient
.top
) )
2335 winpos
.flags
&= ~SWP_NOCLIENTMOVE
;
2337 /* Update active DCEs
2338 * TODO: Optimize conditions that trigger DCE update.
2341 if( (((winpos
.flags
& SWP_AGG_NOPOSCHANGE
) != SWP_AGG_NOPOSCHANGE
) &&
2342 wndPtr
->dwStyle
& WS_VISIBLE
) ||
2343 (flags
& (SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
2347 UnionRect32(&rect
, &newWindowRect
, &wndPtr
->rectWindow
);
2348 DCE_InvalidateDCE(wndPtr
, &rect
);
2351 /* change geometry */
2353 oldWindowRect
= wndPtr
->rectWindow
;
2357 RECT32 oldClientRect
= wndPtr
->rectClient
;
2359 tempInsertAfter
= winpos
.hwndInsertAfter
;
2361 winpos
.hwndInsertAfter
= hwndInsertAfter
;
2363 /* postpone geometry change */
2365 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
2367 WINPOS_SetXWindowPos( &winpos
);
2368 winpos
.hwndInsertAfter
= tempInsertAfter
;
2370 else uFlags
|= SMC_SETXPOS
;
2372 wndPtr
->rectWindow
= newWindowRect
;
2373 wndPtr
->rectClient
= newClientRect
;
2375 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
2377 if( (oldClientRect
.left
- oldWindowRect
.left
!=
2378 newClientRect
.left
- newWindowRect
.left
) ||
2379 (oldClientRect
.top
- oldWindowRect
.top
!=
2380 newClientRect
.top
- newWindowRect
.top
) ||
2381 (winpos
.flags
& SWP_NOCOPYBITS
) )
2383 /* if the client area moved as a result of WM_NCCALCSIZE returning
2384 * obscure WVR_ALIGNxxx flags then we simply redraw the whole thing
2386 * TODO: use WINPOS_SizeMoveClean() if there is no SWP_NOCOPYBITS
2389 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, RDW_INVALIDATE
|
2390 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
2393 if( winpos
.flags
& SWP_FRAMECHANGED
)
2398 if( newClientRect
.right
> oldClientRect
.right
) /* redraw exposed client area on the right */
2400 rect
.top
= 0; rect
.bottom
= newClientRect
.bottom
- newClientRect
.top
;
2401 rect
.left
= oldClientRect
.right
- newClientRect
.left
;
2402 rect
.right
= newClientRect
.right
- newClientRect
.left
;
2404 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
2405 RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
| RDW_ALLCHILDREN
, 0 );
2407 if( newClientRect
.bottom
> oldClientRect
.bottom
) /* redraw exposed client area on the bottom */
2409 rect
.left
= 0; rect
.right
= ((wErase
)?oldClientRect
.right
:newClientRect
.right
) - newClientRect
.left
;
2410 rect
.top
= oldClientRect
.bottom
- newClientRect
.top
;
2411 rect
.bottom
= newClientRect
.bottom
- newClientRect
.top
;
2413 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
2414 RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
| RDW_ALLCHILDREN
, 0 );
2416 if( !wErase
) /* just update the nonclient area */
2417 wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
2420 uFlags
|= SMC_NOPARENTERASE
; /* X windows do not have eraseable parents */
2422 else /* not an X window */
2424 RECT32 oldClientRect
= wndPtr
->rectClient
;
2426 wndPtr
->rectWindow
= newWindowRect
;
2427 wndPtr
->rectClient
= newClientRect
;
2429 if( oldClientRect
.bottom
- oldClientRect
.top
==
2430 newClientRect
.bottom
- newClientRect
.top
) result
&= ~WVR_VREDRAW
;
2432 if( oldClientRect
.right
- oldClientRect
.left
==
2433 newClientRect
.right
- newClientRect
.left
) result
&= ~WVR_HREDRAW
;
2435 if( !(flags
& (SWP_NOREDRAW
| SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
2437 uFlags
|= ((winpos
.flags
& SWP_NOCOPYBITS
) ||
2438 (result
>= WVR_HREDRAW
&& result
< WVR_VALIDRECTS
)) ? SMC_NOCOPY
: 0;
2439 uFlags
|= (winpos
.flags
& SWP_FRAMECHANGED
) ? SMC_DRAWFRAME
: 0;
2441 if( (winpos
.flags
& SWP_AGG_NOGEOMETRYCHANGE
) != SWP_AGG_NOGEOMETRYCHANGE
)
2442 uFlags
= WINPOS_SizeMoveClean(wndPtr
, visRgn
, &oldWindowRect
,
2443 &oldClientRect
, uFlags
);
2446 /* adjust the frame and do not erase the parent */
2448 if( winpos
.flags
& SWP_FRAMECHANGED
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
2449 if( winpos
.flags
& SWP_NOZORDER
) uFlags
|= SMC_NOPARENTERASE
;
2452 DeleteObject32(visRgn
);
2455 if (flags
& SWP_SHOWWINDOW
)
2457 wndPtr
->dwStyle
|= WS_VISIBLE
;
2462 if( uFlags
& SMC_SETXPOS
)
2464 WINPOS_SetXWindowPos( &winpos
);
2465 winpos
.hwndInsertAfter
= tempInsertAfter
;
2467 TSXMapWindow( display
, wndPtr
->window
);
2468 if (wndPtr
->flags
& WIN_MANAGED
) resync
= TRUE
;
2470 /* If focus was set to an unmapped window, reset X focus now */
2471 focus
= curr
= GetFocus32();
2475 SetFocus32( focus
);
2478 curr
= GetParent32(curr
);
2483 if (!(flags
& SWP_NOREDRAW
))
2484 PAINT_RedrawWindow( winpos
.hwnd
, NULL
, 0,
2485 RDW_INVALIDATE
| RDW_ALLCHILDREN
|
2486 RDW_FRAME
| RDW_ERASENOW
| RDW_ERASE
, 0 );
2489 else if (flags
& SWP_HIDEWINDOW
)
2493 if (wndPtr
->dwStyle
& WS_VISIBLE
) TSXUnmapWindow( display
, wndPtr
->window
);
2494 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
2495 if( uFlags
& SMC_SETXPOS
)
2497 WINPOS_SetXWindowPos( &winpos
);
2498 winpos
.hwndInsertAfter
= tempInsertAfter
;
2503 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
2504 if (!(flags
& SWP_NOREDRAW
))
2505 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, &oldWindowRect
,
2506 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
2507 RDW_ERASE
| RDW_ERASENOW
, 0 );
2508 uFlags
|= SMC_NOPARENTERASE
;
2511 if ((winpos
.hwnd
== GetFocus32()) ||
2512 IsChild32( winpos
.hwnd
, GetFocus32()))
2514 /* Revert focus to parent */
2515 SetFocus32( GetParent32(winpos
.hwnd
) );
2517 if (hwnd
== CARET_GetHwnd()) DestroyCaret32();
2519 if (winpos
.hwnd
== hwndActive
)
2520 WINPOS_ActivateOtherWindow( wndPtr
);
2523 /* Activate the window */
2525 if (!(flags
& SWP_NOACTIVATE
))
2526 WINPOS_ChangeActiveWindow( winpos
.hwnd
, FALSE
);
2528 /* Repaint the window */
2530 if (wndPtr
->window
) EVENT_Synchronize(); /* Wait for all expose events */
2532 if (!GetCapture32())
2533 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
2535 if (!(flags
& SWP_DEFERERASE
) && !(uFlags
& SMC_NOPARENTERASE
) )
2536 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_ALLCHILDREN
| RDW_ERASENOW
, 0 );
2537 else if( wndPtr
->parent
== WIN_GetDesktop() && wndPtr
->parent
->flags
& WIN_NEEDS_ERASEBKGND
)
2538 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_NOCHILDREN
| RDW_ERASENOW
, 0 );
2540 /* And last, send the WM_WINDOWPOSCHANGED message */
2542 TRACE(win
,"\tstatus flags = %04x\n", winpos
.flags
& SWP_AGG_STATUSFLAGS
);
2545 (((winpos
.flags
& SWP_AGG_STATUSFLAGS
) != SWP_AGG_NOPOSCHANGE
) &&
2546 !(winpos
.flags
& SWP_NOSENDCHANGING
)) )
2548 SendMessage32A( winpos
.hwnd
, WM_WINDOWPOSCHANGED
, 0, (LPARAM
)&winpos
);
2549 if (resync
) EVENT_Synchronize ();
2556 /***********************************************************************
2557 * BeginDeferWindowPos16 (USER.259)
2559 HDWP16 WINAPI
BeginDeferWindowPos16( INT16 count
)
2561 return BeginDeferWindowPos32( count
);
2565 /***********************************************************************
2566 * BeginDeferWindowPos32 (USER32.9)
2568 HDWP32 WINAPI
BeginDeferWindowPos32( INT32 count
)
2573 if (count
<= 0) return 0;
2574 handle
= USER_HEAP_ALLOC( sizeof(DWP
) + (count
-1)*sizeof(WINDOWPOS32
) );
2575 if (!handle
) return 0;
2576 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( handle
);
2577 pDWP
->actualCount
= 0;
2578 pDWP
->suggestedCount
= count
;
2580 pDWP
->wMagic
= DWP_MAGIC
;
2581 pDWP
->hwndParent
= 0;
2586 /***********************************************************************
2587 * DeferWindowPos16 (USER.260)
2589 HDWP16 WINAPI
DeferWindowPos16( HDWP16 hdwp
, HWND16 hwnd
, HWND16 hwndAfter
,
2590 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
2593 return DeferWindowPos32( hdwp
, hwnd
, (INT32
)(INT16
)hwndAfter
,
2594 x
, y
, cx
, cy
, flags
);
2598 /***********************************************************************
2599 * DeferWindowPos32 (USER32.128)
2601 HDWP32 WINAPI
DeferWindowPos32( HDWP32 hdwp
, HWND32 hwnd
, HWND32 hwndAfter
,
2602 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
2607 HDWP32 newhdwp
= hdwp
;
2608 /* HWND32 parent; */
2611 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2612 if (!pDWP
) return 0;
2613 if (hwnd
== GetDesktopWindow32()) return 0;
2615 if (!(pWnd
=WIN_FindWndPtr( hwnd
))) {
2616 USER_HEAP_FREE( hdwp
);
2620 /* Numega Bounds Checker Demo dislikes the following code.
2621 In fact, I've not been able to find any "same parent" requirement in any docu
2625 /* All the windows of a DeferWindowPos() must have the same parent */
2626 parent
= pWnd
->parent
->hwndSelf
;
2627 if (pDWP
->actualCount
== 0) pDWP
->hwndParent
= parent
;
2628 else if (parent
!= pDWP
->hwndParent
)
2630 USER_HEAP_FREE( hdwp
);
2635 for (i
= 0; i
< pDWP
->actualCount
; i
++)
2637 if (pDWP
->winPos
[i
].hwnd
== hwnd
)
2639 /* Merge with the other changes */
2640 if (!(flags
& SWP_NOZORDER
))
2642 pDWP
->winPos
[i
].hwndInsertAfter
= hwndAfter
;
2644 if (!(flags
& SWP_NOMOVE
))
2646 pDWP
->winPos
[i
].x
= x
;
2647 pDWP
->winPos
[i
].y
= y
;
2649 if (!(flags
& SWP_NOSIZE
))
2651 pDWP
->winPos
[i
].cx
= cx
;
2652 pDWP
->winPos
[i
].cy
= cy
;
2654 pDWP
->winPos
[i
].flags
&= flags
| ~(SWP_NOSIZE
| SWP_NOMOVE
|
2655 SWP_NOZORDER
| SWP_NOREDRAW
|
2656 SWP_NOACTIVATE
| SWP_NOCOPYBITS
|
2658 pDWP
->winPos
[i
].flags
|= flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
|
2663 if (pDWP
->actualCount
>= pDWP
->suggestedCount
)
2665 newhdwp
= USER_HEAP_REALLOC( hdwp
,
2666 sizeof(DWP
) + pDWP
->suggestedCount
*sizeof(WINDOWPOS32
) );
2667 if (!newhdwp
) return 0;
2668 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( newhdwp
);
2669 pDWP
->suggestedCount
++;
2671 pDWP
->winPos
[pDWP
->actualCount
].hwnd
= hwnd
;
2672 pDWP
->winPos
[pDWP
->actualCount
].hwndInsertAfter
= hwndAfter
;
2673 pDWP
->winPos
[pDWP
->actualCount
].x
= x
;
2674 pDWP
->winPos
[pDWP
->actualCount
].y
= y
;
2675 pDWP
->winPos
[pDWP
->actualCount
].cx
= cx
;
2676 pDWP
->winPos
[pDWP
->actualCount
].cy
= cy
;
2677 pDWP
->winPos
[pDWP
->actualCount
].flags
= flags
;
2678 pDWP
->actualCount
++;
2683 /***********************************************************************
2684 * EndDeferWindowPos16 (USER.261)
2686 BOOL16 WINAPI
EndDeferWindowPos16( HDWP16 hdwp
)
2688 return EndDeferWindowPos32( hdwp
);
2692 /***********************************************************************
2693 * EndDeferWindowPos32 (USER32.173)
2695 BOOL32 WINAPI
EndDeferWindowPos32( HDWP32 hdwp
)
2698 WINDOWPOS32
*winpos
;
2702 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2703 if (!pDWP
) return FALSE
;
2704 for (i
= 0, winpos
= pDWP
->winPos
; i
< pDWP
->actualCount
; i
++, winpos
++)
2706 if (!(res
= SetWindowPos32( winpos
->hwnd
, winpos
->hwndInsertAfter
,
2707 winpos
->x
, winpos
->y
, winpos
->cx
,
2708 winpos
->cy
, winpos
->flags
))) break;
2710 USER_HEAP_FREE( hdwp
);
2715 /***********************************************************************
2716 * TileChildWindows (USER.199)
2718 void WINAPI
TileChildWindows( HWND16 parent
, WORD action
)
2720 FIXME(win
, "(%04x, %d): stub\n", parent
, action
);
2723 /***********************************************************************
2724 * CascageChildWindows (USER.198)
2726 void WINAPI
CascadeChildWindows( HWND16 parent
, WORD action
)
2728 FIXME(win
, "(%04x, %d): stub\n", parent
, action
);
2730 /***********************************************************************
2731 * GetProgmanWindow [USER32.289]
2733 HRESULT WINAPI
GetProgmanWindow ( )
2734 { FIXME(win
,"stub\n");
2737 /***********************************************************************
2738 * GetTaskmanWindow [USER32.304]
2740 HRESULT WINAPI
GetTaskmanWindow ( )
2741 { FIXME(win
,"stub\n");
2744 /***********************************************************************
2745 * SetProgmanWindow [USER32.522]
2747 HRESULT WINAPI
SetProgmanWindow ( DWORD x
)
2748 { FIXME(win
,"0x%08lx stub\n",x
);
2751 /***********************************************************************
2752 * SetShellWindowEx [USER32.531]
2754 HRESULT WINAPI
SetShellWindowEx ( DWORD x
, DWORD y
)
2755 { FIXME(win
,"0x%08lx 0x%08lx stub\n",x
,y
);
2758 /***********************************************************************
2759 * SetTaskmanWindow [USER32.537]
2761 HRESULT WINAPI
SetTaskmanWindow ( DWORD x
)
2762 { FIXME(win
,"0x%08lx stub\n",x
);