2 * Window position related functions.
4 * Copyright 1993, 1994, 1995 Alexandre Julliard
5 * 1995, 1996 Alex Korobka
10 #include <X11/Xatom.h>
11 #include "sysmetrics.h"
22 #include "nonclient.h"
25 #define HAS_DLGFRAME(style,exStyle) \
26 (((exStyle) & WS_EX_DLGMODALFRAME) || \
27 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
29 #define HAS_THICKFRAME(style) \
30 (((style) & WS_THICKFRAME) && \
31 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
33 #define SWP_AGG_NOGEOMETRYCHANGE \
34 (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
35 #define SWP_AGG_NOPOSCHANGE \
36 (SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
37 #define SWP_AGG_STATUSFLAGS \
38 (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
40 #define EMPTYPOINT(pt) ((*(LONG*)&(pt)) == -1)
42 #define PLACE_MIN 0x0001
43 #define PLACE_MAX 0x0002
44 #define PLACE_RECT 0x0004
46 #define SMC_NOCOPY 0x0001
47 #define SMC_NOPARENTERASE 0x0002
48 #define SMC_DRAWFRAME 0x0004
49 #define SMC_SETXPOS 0x0008
51 /* ----- external functions ----- */
53 extern void FOCUS_SwitchFocus( HWND32
, HWND32
);
54 extern HWND32
CARET_GetHwnd();
56 /* ----- internal variables ----- */
58 static HWND32 hwndActive
= 0; /* Currently active window */
59 static HWND32 hwndPrevActive
= 0; /* Previously active window */
61 static LPCSTR atomInternalPos
;
63 extern MESSAGEQUEUE
* pActiveQueue
;
65 /***********************************************************************
66 * WINPOS_CreateInternalPosAtom
68 BOOL32
WINPOS_CreateInternalPosAtom()
71 atomInternalPos
= (LPCSTR
)(DWORD
)GlobalAddAtom32A(str
);
72 return (atomInternalPos
) ? TRUE
: FALSE
;
75 /***********************************************************************
76 * WINPOS_CheckInternalPos
78 * Called when a window is destroyed.
80 void WINPOS_CheckInternalPos( HWND32 hwnd
)
82 LPINTERNALPOS lpPos
= (LPINTERNALPOS
) GetProp32A( hwnd
, atomInternalPos
);
84 if( hwnd
== hwndPrevActive
) hwndPrevActive
= 0;
85 if( hwnd
== hwndActive
)
88 WARN(win
, "\tattempt to activate destroyed window!\n");
93 if( IsWindow32(lpPos
->hwndIconTitle
) )
94 DestroyWindow32( lpPos
->hwndIconTitle
);
95 HeapFree( SystemHeap
, 0, lpPos
);
99 /***********************************************************************
102 * Find a suitable place for an iconic window.
104 static POINT16
WINPOS_FindIconPos( WND
* wndPtr
, POINT16 pt
)
107 short x
, y
, xspacing
, yspacing
;
109 GetClientRect16( wndPtr
->parent
->hwndSelf
, &rectParent
);
110 if ((pt
.x
>= rectParent
.left
) && (pt
.x
+ SYSMETRICS_CXICON
< rectParent
.right
) &&
111 (pt
.y
>= rectParent
.top
) && (pt
.y
+ SYSMETRICS_CYICON
< rectParent
.bottom
))
112 return pt
; /* The icon already has a suitable position */
114 xspacing
= SYSMETRICS_CXICONSPACING
;
115 yspacing
= SYSMETRICS_CYICONSPACING
;
117 y
= rectParent
.bottom
;
120 for (x
= rectParent
.left
; x
<= rectParent
.right
-xspacing
; x
+= xspacing
)
122 /* Check if another icon already occupies this spot */
123 WND
*childPtr
= wndPtr
->parent
->child
;
126 if ((childPtr
->dwStyle
& WS_MINIMIZE
) && (childPtr
!= wndPtr
))
128 if ((childPtr
->rectWindow
.left
< x
+ xspacing
) &&
129 (childPtr
->rectWindow
.right
>= x
) &&
130 (childPtr
->rectWindow
.top
<= y
) &&
131 (childPtr
->rectWindow
.bottom
> y
- yspacing
))
132 break; /* There's a window in there */
134 childPtr
= childPtr
->next
;
136 if (!childPtr
) /* No window was found, so it's OK for us */
138 pt
.x
= x
+ (xspacing
- SYSMETRICS_CXICON
) / 2;
139 pt
.y
= y
- (yspacing
+ SYSMETRICS_CYICON
) / 2;
148 /***********************************************************************
149 * ArrangeIconicWindows16 (USER.170)
151 UINT16 WINAPI
ArrangeIconicWindows16( HWND16 parent
)
153 return ArrangeIconicWindows32(parent
);
155 /***********************************************************************
156 * ArrangeIconicWindows32 (USER32.7)
158 UINT32 WINAPI
ArrangeIconicWindows32( HWND32 parent
)
162 INT32 x
, y
, xspacing
, yspacing
;
164 GetClientRect32( parent
, &rectParent
);
166 y
= rectParent
.bottom
;
167 xspacing
= SYSMETRICS_CXICONSPACING
;
168 yspacing
= SYSMETRICS_CYICONSPACING
;
170 hwndChild
= GetWindow32( parent
, GW_CHILD
);
173 if( IsIconic32( hwndChild
) )
175 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild
), FALSE
);
176 SetWindowPos32( hwndChild
, 0, x
+ (xspacing
- SYSMETRICS_CXICON
) / 2,
177 y
- yspacing
- SYSMETRICS_CYICON
/2, 0, 0,
178 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
179 if( IsWindow32(hwndChild
) )
180 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild
), TRUE
);
181 if (x
<= rectParent
.right
- xspacing
) x
+= xspacing
;
188 hwndChild
= GetWindow32( hwndChild
, GW_HWNDNEXT
);
194 /***********************************************************************
195 * SwitchToThisWindow16 (USER.172)
197 void WINAPI
SwitchToThisWindow16( HWND16 hwnd
, BOOL16 restore
)
199 SwitchToThisWindow32( hwnd
, restore
);
203 /***********************************************************************
204 * SwitchToThisWindow32 (USER32.539)
206 void WINAPI
SwitchToThisWindow32( HWND32 hwnd
, BOOL32 restore
)
208 ShowWindow32( hwnd
, restore
? SW_RESTORE
: SW_SHOWMINIMIZED
);
212 /***********************************************************************
213 * GetWindowRect16 (USER.32)
215 void WINAPI
GetWindowRect16( HWND16 hwnd
, LPRECT16 rect
)
217 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
220 CONV_RECT32TO16( &wndPtr
->rectWindow
, rect
);
221 if (wndPtr
->dwStyle
& WS_CHILD
)
222 MapWindowPoints16( wndPtr
->parent
->hwndSelf
, 0, (POINT16
*)rect
, 2 );
226 /***********************************************************************
227 * GetWindowRect32 (USER32.308)
229 void WINAPI
GetWindowRect32( HWND32 hwnd
, LPRECT32 rect
)
231 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
234 *rect
= wndPtr
->rectWindow
;
235 if (wndPtr
->dwStyle
& WS_CHILD
)
236 MapWindowPoints32( wndPtr
->parent
->hwndSelf
, 0, (POINT32
*)rect
, 2 );
240 /***********************************************************************
241 * GetClientRect16 (USER.33)
243 void WINAPI
GetClientRect16( HWND16 hwnd
, LPRECT16 rect
)
245 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
247 rect
->left
= rect
->top
= rect
->right
= rect
->bottom
= 0;
250 rect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
;
251 rect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
;
256 /***********************************************************************
257 * GetClientRect32 (USER32.220)
259 void WINAPI
GetClientRect32( HWND32 hwnd
, LPRECT32 rect
)
261 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
263 rect
->left
= rect
->top
= rect
->right
= rect
->bottom
= 0;
266 rect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
;
267 rect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
;
272 /*******************************************************************
273 * ClientToScreen16 (USER.28)
275 void WINAPI
ClientToScreen16( HWND16 hwnd
, LPPOINT16 lppnt
)
277 MapWindowPoints16( hwnd
, 0, lppnt
, 1 );
281 /*******************************************************************
282 * ClientToScreen32 (USER32.52)
284 BOOL32 WINAPI
ClientToScreen32( HWND32 hwnd
, LPPOINT32 lppnt
)
286 MapWindowPoints32( hwnd
, 0, lppnt
, 1 );
291 /*******************************************************************
292 * ScreenToClient16 (USER.29)
294 void WINAPI
ScreenToClient16( HWND16 hwnd
, LPPOINT16 lppnt
)
296 MapWindowPoints16( 0, hwnd
, lppnt
, 1 );
300 /*******************************************************************
301 * ScreenToClient32 (USER32.447)
303 void WINAPI
ScreenToClient32( HWND32 hwnd
, LPPOINT32 lppnt
)
305 MapWindowPoints32( 0, hwnd
, lppnt
, 1 );
309 /***********************************************************************
310 * WINPOS_WindowFromPoint
312 * Find the window and hittest for a given point.
314 INT16
WINPOS_WindowFromPoint( WND
* wndScope
, POINT16 pt
, WND
**ppWnd
)
317 INT16 hittest
= HTERROR
;
321 wndPtr
= wndScope
->child
;
322 MapWindowPoints16( GetDesktopWindow16(), wndScope
->hwndSelf
, &xy
, 1 );
328 /* If point is in window, and window is visible, and it */
329 /* is enabled (or it's a top-level window), then explore */
330 /* its children. Otherwise, go to the next window. */
332 if ((wndPtr
->dwStyle
& WS_VISIBLE
) &&
333 (!(wndPtr
->dwStyle
& WS_DISABLED
) ||
334 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) != WS_CHILD
)) &&
335 (xy
.x
>= wndPtr
->rectWindow
.left
) &&
336 (xy
.x
< wndPtr
->rectWindow
.right
) &&
337 (xy
.y
>= wndPtr
->rectWindow
.top
) &&
338 (xy
.y
< wndPtr
->rectWindow
.bottom
))
340 *ppWnd
= wndPtr
; /* Got a suitable window */
342 /* If window is minimized or disabled, return at once */
343 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
344 if (wndPtr
->dwStyle
& WS_DISABLED
) return HTERROR
;
346 /* If point is not in client area, ignore the children */
347 if ((xy
.x
< wndPtr
->rectClient
.left
) ||
348 (xy
.x
>= wndPtr
->rectClient
.right
) ||
349 (xy
.y
< wndPtr
->rectClient
.top
) ||
350 (xy
.y
>= wndPtr
->rectClient
.bottom
)) break;
352 xy
.x
-= wndPtr
->rectClient
.left
;
353 xy
.y
-= wndPtr
->rectClient
.top
;
354 wndPtr
= wndPtr
->child
;
356 else wndPtr
= wndPtr
->next
;
359 /* If nothing found, try the scope window */
360 if (!*ppWnd
) *ppWnd
= wndScope
;
362 /* Send the WM_NCHITTEST message (only if to the same task) */
363 if ((*ppWnd
)->hmemTaskQ
== GetTaskQueue(0))
365 hittest
= (INT16
)SendMessage16( (*ppWnd
)->hwndSelf
, WM_NCHITTEST
,
366 0, MAKELONG( pt
.x
, pt
.y
) );
367 if (hittest
!= HTTRANSPARENT
) return hittest
; /* Found the window */
369 else return HTCLIENT
;
371 /* If no children found in last search, make point relative to parent */
374 xy
.x
+= (*ppWnd
)->rectClient
.left
;
375 xy
.y
+= (*ppWnd
)->rectClient
.top
;
378 /* Restart the search from the next sibling */
379 wndPtr
= (*ppWnd
)->next
;
380 *ppWnd
= (*ppWnd
)->parent
;
385 /*******************************************************************
386 * WindowFromPoint16 (USER.30)
388 HWND16 WINAPI
WindowFromPoint16( POINT16 pt
)
391 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt
, &pWnd
);
392 return pWnd
->hwndSelf
;
396 /*******************************************************************
397 * WindowFromPoint32 (USER32.582)
399 HWND32 WINAPI
WindowFromPoint32( POINT32 pt
)
403 CONV_POINT32TO16( &pt
, &pt16
);
404 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt16
, &pWnd
);
405 return (HWND32
)pWnd
->hwndSelf
;
409 /*******************************************************************
410 * ChildWindowFromPoint16 (USER.191)
412 HWND16 WINAPI
ChildWindowFromPoint16( HWND16 hwndParent
, POINT16 pt
)
415 CONV_POINT16TO32( &pt
, &pt32
);
416 return (HWND16
)ChildWindowFromPoint32( hwndParent
, pt32
);
420 /*******************************************************************
421 * ChildWindowFromPoint32 (USER32.49)
423 HWND32 WINAPI
ChildWindowFromPoint32( HWND32 hwndParent
, POINT32 pt
)
425 /* pt is in the client coordinates */
427 WND
* wnd
= WIN_FindWndPtr(hwndParent
);
432 /* get client rect fast */
433 rect
.top
= rect
.left
= 0;
434 rect
.right
= wnd
->rectClient
.right
- wnd
->rectClient
.left
;
435 rect
.bottom
= wnd
->rectClient
.bottom
- wnd
->rectClient
.top
;
437 if (!PtInRect32( &rect
, pt
)) return 0;
442 if (PtInRect32( &wnd
->rectWindow
, pt
)) return wnd
->hwndSelf
;
449 /*******************************************************************
450 * WINPOS_GetWinOffset
452 * Calculate the offset between the origin of the two windows. Used
453 * to implement MapWindowPoints.
455 static void WINPOS_GetWinOffset( HWND32 hwndFrom
, HWND32 hwndTo
,
460 offset
->x
= offset
->y
= 0;
461 if (hwndFrom
== hwndTo
) return;
463 /* Translate source window origin to screen coords */
466 if (!(wndPtr
= WIN_FindWndPtr( hwndFrom
)))
468 ERR(win
,"bad hwndFrom = %04x\n",hwndFrom
);
471 while (wndPtr
->parent
)
473 offset
->x
+= wndPtr
->rectClient
.left
;
474 offset
->y
+= wndPtr
->rectClient
.top
;
475 wndPtr
= wndPtr
->parent
;
479 /* Translate origin to destination window coords */
482 if (!(wndPtr
= WIN_FindWndPtr( hwndTo
)))
484 ERR(win
,"bad hwndTo = %04x\n", hwndTo
);
487 while (wndPtr
->parent
)
489 offset
->x
-= wndPtr
->rectClient
.left
;
490 offset
->y
-= wndPtr
->rectClient
.top
;
491 wndPtr
= wndPtr
->parent
;
497 /*******************************************************************
498 * MapWindowPoints16 (USER.258)
500 void WINAPI
MapWindowPoints16( HWND16 hwndFrom
, HWND16 hwndTo
,
501 LPPOINT16 lppt
, UINT16 count
)
505 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
515 /*******************************************************************
516 * MapWindowPoints32 (USER32.386)
518 void WINAPI
MapWindowPoints32( HWND32 hwndFrom
, HWND32 hwndTo
,
519 LPPOINT32 lppt
, UINT32 count
)
523 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
533 /***********************************************************************
534 * IsIconic16 (USER.31)
536 BOOL16 WINAPI
IsIconic16(HWND16 hWnd
)
538 return IsIconic32(hWnd
);
542 /***********************************************************************
543 * IsIconic32 (USER32.345)
545 BOOL32 WINAPI
IsIconic32(HWND32 hWnd
)
547 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
548 if (wndPtr
== NULL
) return FALSE
;
549 return (wndPtr
->dwStyle
& WS_MINIMIZE
) != 0;
553 /***********************************************************************
554 * IsZoomed (USER.272)
556 BOOL16 WINAPI
IsZoomed16(HWND16 hWnd
)
558 return IsZoomed32(hWnd
);
562 /***********************************************************************
563 * IsZoomed (USER32.352)
565 BOOL32 WINAPI
IsZoomed32(HWND32 hWnd
)
567 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
568 if (wndPtr
== NULL
) return FALSE
;
569 return (wndPtr
->dwStyle
& WS_MAXIMIZE
) != 0;
573 /*******************************************************************
574 * GetActiveWindow (USER.60)
576 HWND16 WINAPI
GetActiveWindow16(void)
578 return (HWND16
)hwndActive
;
581 /*******************************************************************
582 * GetActiveWindow (USER32.205)
584 HWND32 WINAPI
GetActiveWindow32(void)
586 return (HWND32
)hwndActive
;
590 /*******************************************************************
593 static BOOL32
WINPOS_CanActivate(WND
* pWnd
)
595 if( pWnd
&& ((pWnd
->dwStyle
& (WS_DISABLED
| WS_VISIBLE
| WS_CHILD
))
596 == WS_VISIBLE
) ) return TRUE
;
601 /*******************************************************************
602 * SetActiveWindow16 (USER.59)
604 HWND16 WINAPI
SetActiveWindow16( HWND16 hwnd
)
606 return SetActiveWindow32(hwnd
);
610 /*******************************************************************
611 * SetActiveWindow32 (USER32.463)
613 HWND32 WINAPI
SetActiveWindow32( HWND32 hwnd
)
615 HWND32 prev
= hwndActive
;
616 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
618 if ( !WINPOS_CanActivate(wndPtr
) ) return 0;
620 WINPOS_SetActiveWindow( hwnd
, 0, 0 );
625 /*******************************************************************
626 * GetForegroundWindow16 (USER.608)
628 HWND16 WINAPI
GetForegroundWindow16(void)
630 return (HWND16
)GetForegroundWindow32();
634 /*******************************************************************
635 * SetForegroundWindow16 (USER.609)
637 BOOL16 WINAPI
SetForegroundWindow16( HWND16 hwnd
)
639 return SetForegroundWindow32( hwnd
);
643 /*******************************************************************
644 * GetForegroundWindow32 (USER32.241)
646 HWND32 WINAPI
GetForegroundWindow32(void)
648 return GetActiveWindow32();
652 /*******************************************************************
653 * SetForegroundWindow32 (USER32.482)
655 BOOL32 WINAPI
SetForegroundWindow32( HWND32 hwnd
)
657 SetActiveWindow32( hwnd
);
662 /*******************************************************************
663 * GetShellWindow16 (USER.600)
665 HWND16 WINAPI
GetShellWindow16(void)
667 return GetShellWindow32();
670 /*******************************************************************
671 * SetShellWindow32 (USER32.504)
673 HWND32 WINAPI
SetShellWindow32(HWND32 hwndshell
)
675 FIXME(win
, "(%08x): empty stub\n",hwndshell
);
680 /*******************************************************************
681 * GetShellWindow32 (USER32.287)
683 HWND32 WINAPI
GetShellWindow32(void)
685 FIXME(win
, "(void): empty stub\n" );
690 /***********************************************************************
691 * BringWindowToTop16 (USER.45)
693 BOOL16 WINAPI
BringWindowToTop16( HWND16 hwnd
)
695 return BringWindowToTop32(hwnd
);
699 /***********************************************************************
700 * BringWindowToTop32 (USER32.11)
702 BOOL32 WINAPI
BringWindowToTop32( HWND32 hwnd
)
704 return SetWindowPos32( hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
708 /***********************************************************************
709 * MoveWindow16 (USER.56)
711 BOOL16 WINAPI
MoveWindow16( HWND16 hwnd
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
714 return MoveWindow32(hwnd
,x
,y
,cx
,cy
,repaint
);
718 /***********************************************************************
719 * MoveWindow32 (USER32.399)
721 BOOL32 WINAPI
MoveWindow32( HWND32 hwnd
, INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
724 int flags
= SWP_NOZORDER
| SWP_NOACTIVATE
;
725 if (!repaint
) flags
|= SWP_NOREDRAW
;
726 TRACE(win
, "%04x %d,%d %dx%d %d\n",
727 hwnd
, x
, y
, cx
, cy
, repaint
);
728 return SetWindowPos32( hwnd
, 0, x
, y
, cx
, cy
, flags
);
731 /***********************************************************************
732 * WINPOS_InitInternalPos
734 static LPINTERNALPOS
WINPOS_InitInternalPos( WND
* wnd
, POINT32 pt
,
735 LPRECT32 restoreRect
)
737 LPINTERNALPOS lpPos
= (LPINTERNALPOS
) GetProp32A( wnd
->hwndSelf
,
741 /* this happens when the window is minimized/maximized
742 * for the first time (rectWindow is not adjusted yet) */
744 lpPos
= HeapAlloc( SystemHeap
, 0, sizeof(INTERNALPOS
) );
745 if( !lpPos
) return NULL
;
747 SetProp32A( wnd
->hwndSelf
, atomInternalPos
, (HANDLE32
)lpPos
);
748 lpPos
->hwndIconTitle
= 0; /* defer until needs to be shown */
749 CONV_RECT32TO16( &wnd
->rectWindow
, &lpPos
->rectNormal
);
750 *(UINT32
*)&lpPos
->ptIconPos
= *(UINT32
*)&lpPos
->ptMaxPos
= 0xFFFFFFFF;
753 if( wnd
->dwStyle
& WS_MINIMIZE
)
754 CONV_POINT32TO16( &pt
, &lpPos
->ptIconPos
);
755 else if( wnd
->dwStyle
& WS_MAXIMIZE
)
756 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
757 else if( restoreRect
)
758 CONV_RECT32TO16( restoreRect
, &lpPos
->rectNormal
);
763 /***********************************************************************
764 * WINPOS_RedrawIconTitle
766 BOOL32
WINPOS_RedrawIconTitle( HWND32 hWnd
)
768 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)GetProp32A( hWnd
, atomInternalPos
);
771 if( lpPos
->hwndIconTitle
)
773 SendMessage32A( lpPos
->hwndIconTitle
, WM_SHOWWINDOW
, TRUE
, 0);
774 InvalidateRect32( lpPos
->hwndIconTitle
, NULL
, TRUE
);
781 /***********************************************************************
782 * WINPOS_ShowIconTitle
784 BOOL32
WINPOS_ShowIconTitle( WND
* pWnd
, BOOL32 bShow
)
786 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)GetProp32A( pWnd
->hwndSelf
, atomInternalPos
);
788 if( lpPos
&& !(pWnd
->flags
& WIN_MANAGED
))
790 HWND16 hWnd
= lpPos
->hwndIconTitle
;
792 TRACE(win
,"0x%04x %i\n", pWnd
->hwndSelf
, (bShow
!= 0) );
795 lpPos
->hwndIconTitle
= hWnd
= ICONTITLE_Create( pWnd
);
798 pWnd
= WIN_FindWndPtr(hWnd
);
800 if( !(pWnd
->dwStyle
& WS_VISIBLE
) )
802 SendMessage32A( hWnd
, WM_SHOWWINDOW
, TRUE
, 0 );
803 SetWindowPos32( hWnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
804 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_SHOWWINDOW
);
807 else ShowWindow32( hWnd
, SW_HIDE
);
812 /*******************************************************************
813 * WINPOS_GetMinMaxInfo
815 * Get the minimized and maximized information for a window.
817 void WINPOS_GetMinMaxInfo( WND
*wndPtr
, POINT32
*maxSize
, POINT32
*maxPos
,
818 POINT32
*minTrack
, POINT32
*maxTrack
)
824 /* Compute default values */
826 MinMax
.ptMaxSize
.x
= SYSMETRICS_CXSCREEN
;
827 MinMax
.ptMaxSize
.y
= SYSMETRICS_CYSCREEN
;
828 MinMax
.ptMinTrackSize
.x
= SYSMETRICS_CXMINTRACK
;
829 MinMax
.ptMinTrackSize
.y
= SYSMETRICS_CYMINTRACK
;
830 MinMax
.ptMaxTrackSize
.x
= SYSMETRICS_CXSCREEN
;
831 MinMax
.ptMaxTrackSize
.y
= SYSMETRICS_CYSCREEN
;
833 if (wndPtr
->flags
& WIN_MANAGED
) xinc
= yinc
= 0;
834 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
836 xinc
= SYSMETRICS_CXDLGFRAME
;
837 yinc
= SYSMETRICS_CYDLGFRAME
;
842 if (HAS_THICKFRAME(wndPtr
->dwStyle
))
844 xinc
+= SYSMETRICS_CXFRAME
;
845 yinc
+= SYSMETRICS_CYFRAME
;
847 if (wndPtr
->dwStyle
& WS_BORDER
)
849 xinc
+= SYSMETRICS_CXBORDER
;
850 yinc
+= SYSMETRICS_CYBORDER
;
853 MinMax
.ptMaxSize
.x
+= 2 * xinc
;
854 MinMax
.ptMaxSize
.y
+= 2 * yinc
;
856 lpPos
= (LPINTERNALPOS
)GetProp32A( wndPtr
->hwndSelf
, atomInternalPos
);
857 if( lpPos
&& !EMPTYPOINT(lpPos
->ptMaxPos
) )
858 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &MinMax
.ptMaxPosition
);
861 MinMax
.ptMaxPosition
.x
= -xinc
;
862 MinMax
.ptMaxPosition
.y
= -yinc
;
865 SendMessage32A( wndPtr
->hwndSelf
, WM_GETMINMAXINFO
, 0, (LPARAM
)&MinMax
);
867 /* Some sanity checks */
869 TRACE(win
,"%d %d / %d %d / %d %d / %d %d\n",
870 MinMax
.ptMaxSize
.x
, MinMax
.ptMaxSize
.y
,
871 MinMax
.ptMaxPosition
.x
, MinMax
.ptMaxPosition
.y
,
872 MinMax
.ptMaxTrackSize
.x
, MinMax
.ptMaxTrackSize
.y
,
873 MinMax
.ptMinTrackSize
.x
, MinMax
.ptMinTrackSize
.y
);
874 MinMax
.ptMaxTrackSize
.x
= MAX( MinMax
.ptMaxTrackSize
.x
,
875 MinMax
.ptMinTrackSize
.x
);
876 MinMax
.ptMaxTrackSize
.y
= MAX( MinMax
.ptMaxTrackSize
.y
,
877 MinMax
.ptMinTrackSize
.y
);
879 if (maxSize
) *maxSize
= MinMax
.ptMaxSize
;
880 if (maxPos
) *maxPos
= MinMax
.ptMaxPosition
;
881 if (minTrack
) *minTrack
= MinMax
.ptMinTrackSize
;
882 if (maxTrack
) *maxTrack
= MinMax
.ptMaxTrackSize
;
885 /***********************************************************************
888 * Fill in lpRect and return additional flags to be used with SetWindowPos().
889 * This function assumes that 'cmd' is different from the current window
892 UINT16
WINPOS_MinMaximize( WND
* wndPtr
, UINT16 cmd
, LPRECT16 lpRect
)
896 POINT32 size
= { wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
};
897 LPINTERNALPOS lpPos
= WINPOS_InitInternalPos( wndPtr
, size
,
898 &wndPtr
->rectWindow
);
900 TRACE(win
,"0x%04x %u\n", wndPtr
->hwndSelf
, cmd
);
902 if (lpPos
&& !HOOK_CallHooks16(WH_CBT
, HCBT_MINMAX
, wndPtr
->hwndSelf
, cmd
))
904 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
906 if( !SendMessage32A( wndPtr
->hwndSelf
, WM_QUERYOPEN
, 0, 0L ) )
907 return (SWP_NOSIZE
| SWP_NOMOVE
);
908 swpFlags
|= SWP_NOCOPYBITS
;
913 if( wndPtr
->dwStyle
& WS_MAXIMIZE
)
915 wndPtr
->flags
|= WIN_RESTORE_MAX
;
916 wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
919 wndPtr
->flags
&= ~WIN_RESTORE_MAX
;
920 wndPtr
->dwStyle
|= WS_MINIMIZE
;
922 lpPos
->ptIconPos
= WINPOS_FindIconPos( wndPtr
, lpPos
->ptIconPos
);
924 SetRect16( lpRect
, lpPos
->ptIconPos
.x
, lpPos
->ptIconPos
.y
,
925 SYSMETRICS_CXICON
, SYSMETRICS_CYICON
);
926 swpFlags
|= SWP_NOCOPYBITS
;
930 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &pt
);
931 WINPOS_GetMinMaxInfo( wndPtr
, &size
, &pt
, NULL
, NULL
);
932 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
934 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
936 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
937 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
939 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
941 SetRect16( lpRect
, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
,
946 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
948 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
949 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
950 if( wndPtr
->flags
& WIN_RESTORE_MAX
)
952 /* Restore to maximized position */
953 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &pt
);
954 WINPOS_GetMinMaxInfo( wndPtr
, &size
, &pt
, NULL
, NULL
);
955 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
956 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
957 SetRect16( lpRect
, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
, size
.x
, size
.y
);
962 if( !(wndPtr
->dwStyle
& WS_MAXIMIZE
) ) return (UINT16
)(-1);
963 else wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
965 /* Restore to normal position */
967 *lpRect
= lpPos
->rectNormal
;
968 lpRect
->right
-= lpRect
->left
;
969 lpRect
->bottom
-= lpRect
->top
;
973 } else swpFlags
|= SWP_NOSIZE
| SWP_NOMOVE
;
977 /***********************************************************************
978 * ShowWindow16 (USER.42)
980 BOOL16 WINAPI
ShowWindow16( HWND16 hwnd
, INT16 cmd
)
982 return ShowWindow32(hwnd
,cmd
);
986 /***********************************************************************
987 * ShowWindow32 (USER.42)
989 BOOL32 WINAPI
ShowWindow32( HWND32 hwnd
, INT32 cmd
)
991 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
992 BOOL32 wasVisible
, showFlag
;
993 RECT16 newPos
= {0, 0, 0, 0};
996 if (!wndPtr
) return FALSE
;
998 TRACE(win
,"hwnd=%04x, cmd=%d\n", hwnd
, cmd
);
1000 wasVisible
= (wndPtr
->dwStyle
& WS_VISIBLE
) != 0;
1005 if (!wasVisible
) return FALSE
;
1006 swp
|= SWP_HIDEWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
|
1007 SWP_NOACTIVATE
| SWP_NOZORDER
;
1010 case SW_SHOWMINNOACTIVE
:
1011 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1013 case SW_SHOWMINIMIZED
:
1014 swp
|= SWP_SHOWWINDOW
;
1017 swp
|= SWP_FRAMECHANGED
;
1018 if( !(wndPtr
->dwStyle
& WS_MINIMIZE
) )
1019 swp
|= WINPOS_MinMaximize( wndPtr
, SW_MINIMIZE
, &newPos
);
1020 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1023 case SW_SHOWMAXIMIZED
: /* same as SW_MAXIMIZE */
1024 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
1025 if( !(wndPtr
->dwStyle
& WS_MAXIMIZE
) )
1026 swp
|= WINPOS_MinMaximize( wndPtr
, SW_MAXIMIZE
, &newPos
);
1027 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1031 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1034 swp
|= SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
;
1037 case SW_SHOWNOACTIVATE
:
1038 swp
|= SWP_NOZORDER
;
1039 if (GetActiveWindow32()) swp
|= SWP_NOACTIVATE
;
1041 case SW_SHOWNORMAL
: /* same as SW_NORMAL: */
1042 case SW_SHOWDEFAULT
: /* FIXME: should have its own handler */
1044 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
1046 if( wndPtr
->dwStyle
& (WS_MINIMIZE
| WS_MAXIMIZE
) )
1047 swp
|= WINPOS_MinMaximize( wndPtr
, SW_RESTORE
, &newPos
);
1048 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1052 showFlag
= (cmd
!= SW_HIDE
);
1053 if (showFlag
!= wasVisible
)
1055 SendMessage32A( hwnd
, WM_SHOWWINDOW
, showFlag
, 0 );
1056 if (!IsWindow32( hwnd
)) return wasVisible
;
1059 if ((wndPtr
->dwStyle
& WS_CHILD
) &&
1060 !IsWindowVisible32( wndPtr
->parent
->hwndSelf
) &&
1061 (swp
& (SWP_NOSIZE
| SWP_NOMOVE
)) == (SWP_NOSIZE
| SWP_NOMOVE
) )
1063 /* Don't call SetWindowPos32() on invisible child windows */
1064 if (cmd
== SW_HIDE
) wndPtr
->dwStyle
&= ~WS_VISIBLE
;
1065 else wndPtr
->dwStyle
|= WS_VISIBLE
;
1069 /* We can't activate a child window */
1070 if (wndPtr
->dwStyle
& WS_CHILD
) swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1071 SetWindowPos32( hwnd
, HWND_TOP
,
1072 newPos
.left
, newPos
.top
, newPos
.right
, newPos
.bottom
, swp
);
1073 if (!IsWindow32( hwnd
)) return wasVisible
;
1074 else if( wndPtr
->dwStyle
& WS_MINIMIZE
) WINPOS_ShowIconTitle( wndPtr
, TRUE
);
1077 if (wndPtr
->flags
& WIN_NEED_SIZE
)
1079 /* should happen only in CreateWindowEx() */
1080 int wParam
= SIZE_RESTORED
;
1082 wndPtr
->flags
&= ~WIN_NEED_SIZE
;
1083 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wParam
= SIZE_MAXIMIZED
;
1084 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= SIZE_MINIMIZED
;
1085 SendMessage32A( hwnd
, WM_SIZE
, wParam
,
1086 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
1087 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
1088 SendMessage32A( hwnd
, WM_MOVE
, 0,
1089 MAKELONG(wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
) );
1096 /***********************************************************************
1097 * GetInternalWindowPos16 (USER.460)
1099 UINT16 WINAPI
GetInternalWindowPos16( HWND16 hwnd
, LPRECT16 rectWnd
,
1102 WINDOWPLACEMENT16 wndpl
;
1103 if (GetWindowPlacement16( hwnd
, &wndpl
))
1105 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1106 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1107 return wndpl
.showCmd
;
1113 /***********************************************************************
1114 * GetInternalWindowPos32 (USER32.245)
1116 UINT32 WINAPI
GetInternalWindowPos32( HWND32 hwnd
, LPRECT32 rectWnd
,
1119 WINDOWPLACEMENT32 wndpl
;
1120 if (GetWindowPlacement32( hwnd
, &wndpl
))
1122 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1123 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1124 return wndpl
.showCmd
;
1129 /***********************************************************************
1130 * GetWindowPlacement16 (USER.370)
1132 BOOL16 WINAPI
GetWindowPlacement16( HWND16 hwnd
, WINDOWPLACEMENT16
*wndpl
)
1134 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
1137 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)WINPOS_InitInternalPos( pWnd
,
1138 *(LPPOINT32
)&pWnd
->rectWindow
.left
, &pWnd
->rectWindow
);
1139 wndpl
->length
= sizeof(*wndpl
);
1140 if( pWnd
->dwStyle
& WS_MINIMIZE
)
1141 wndpl
->showCmd
= SW_SHOWMAXIMIZED
;
1143 wndpl
->showCmd
= ( pWnd
->dwStyle
& WS_MAXIMIZE
)
1144 ? SW_SHOWMINIMIZED
: SW_SHOWNORMAL
;
1145 if( pWnd
->flags
& WIN_RESTORE_MAX
)
1146 wndpl
->flags
= WPF_RESTORETOMAXIMIZED
;
1149 wndpl
->ptMinPosition
= lpPos
->ptIconPos
;
1150 wndpl
->ptMaxPosition
= lpPos
->ptMaxPos
;
1151 wndpl
->rcNormalPosition
= lpPos
->rectNormal
;
1158 /***********************************************************************
1159 * GetWindowPlacement32 (USER32.307)
1161 BOOL32 WINAPI
GetWindowPlacement32( HWND32 hwnd
, WINDOWPLACEMENT32
*pwpl32
)
1165 WINDOWPLACEMENT16 wpl
;
1166 wpl
.length
= sizeof(wpl
);
1167 if( GetWindowPlacement16( hwnd
, &wpl
) )
1169 pwpl32
->length
= sizeof(*pwpl32
);
1170 pwpl32
->flags
= wpl
.flags
;
1171 pwpl32
->showCmd
= wpl
.showCmd
;
1172 CONV_POINT16TO32( &wpl
.ptMinPosition
, &pwpl32
->ptMinPosition
);
1173 CONV_POINT16TO32( &wpl
.ptMaxPosition
, &pwpl32
->ptMaxPosition
);
1174 CONV_RECT16TO32( &wpl
.rcNormalPosition
, &pwpl32
->rcNormalPosition
);
1182 /***********************************************************************
1183 * WINPOS_SetPlacement
1185 static BOOL32
WINPOS_SetPlacement( HWND32 hwnd
, const WINDOWPLACEMENT16
*wndpl
,
1188 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
1191 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)WINPOS_InitInternalPos( pWnd
,
1192 *(LPPOINT32
)&pWnd
->rectWindow
.left
, &pWnd
->rectWindow
);
1194 if( flags
& PLACE_MIN
) lpPos
->ptIconPos
= wndpl
->ptMinPosition
;
1195 if( flags
& PLACE_MAX
) lpPos
->ptMaxPos
= wndpl
->ptMaxPosition
;
1196 if( flags
& PLACE_RECT
) lpPos
->rectNormal
= wndpl
->rcNormalPosition
;
1198 if( pWnd
->dwStyle
& WS_MINIMIZE
)
1200 WINPOS_ShowIconTitle( pWnd
, FALSE
);
1201 if( wndpl
->flags
& WPF_SETMINPOSITION
&& !EMPTYPOINT(lpPos
->ptIconPos
))
1202 SetWindowPos32( hwnd
, 0, lpPos
->ptIconPos
.x
, lpPos
->ptIconPos
.y
,
1203 0, 0, SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1205 else if( pWnd
->dwStyle
& WS_MAXIMIZE
)
1207 if( !EMPTYPOINT(lpPos
->ptMaxPos
) )
1208 SetWindowPos32( hwnd
, 0, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
,
1209 0, 0, SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1211 else if( flags
& PLACE_RECT
)
1212 SetWindowPos32( hwnd
, 0, lpPos
->rectNormal
.left
, lpPos
->rectNormal
.top
,
1213 lpPos
->rectNormal
.right
- lpPos
->rectNormal
.left
,
1214 lpPos
->rectNormal
.bottom
- lpPos
->rectNormal
.top
,
1215 SWP_NOZORDER
| SWP_NOACTIVATE
);
1217 ShowWindow32( hwnd
, wndpl
->showCmd
);
1218 if( IsWindow32(hwnd
) && pWnd
->dwStyle
& WS_MINIMIZE
)
1220 if( pWnd
->dwStyle
& WS_VISIBLE
) WINPOS_ShowIconTitle( pWnd
, TRUE
);
1222 /* SDK: ...valid only the next time... */
1223 if( wndpl
->flags
& WPF_RESTORETOMAXIMIZED
) pWnd
->flags
|= WIN_RESTORE_MAX
;
1231 /***********************************************************************
1232 * SetWindowPlacement16 (USER.371)
1234 BOOL16 WINAPI
SetWindowPlacement16(HWND16 hwnd
, const WINDOWPLACEMENT16
*wndpl
)
1236 return WINPOS_SetPlacement( hwnd
, wndpl
,
1237 PLACE_MIN
| PLACE_MAX
| PLACE_RECT
);
1240 /***********************************************************************
1241 * SetWindowPlacement32 (USER32.519)
1243 BOOL32 WINAPI
SetWindowPlacement32( HWND32 hwnd
, const WINDOWPLACEMENT32
*pwpl32
)
1247 WINDOWPLACEMENT16 wpl
= { sizeof(WINDOWPLACEMENT16
),
1248 pwpl32
->flags
, pwpl32
->showCmd
, { pwpl32
->ptMinPosition
.x
,
1249 pwpl32
->ptMinPosition
.y
}, { pwpl32
->ptMaxPosition
.x
,
1250 pwpl32
->ptMaxPosition
.y
}, { pwpl32
->rcNormalPosition
.left
,
1251 pwpl32
->rcNormalPosition
.top
, pwpl32
->rcNormalPosition
.right
,
1252 pwpl32
->rcNormalPosition
.bottom
} };
1254 return WINPOS_SetPlacement( hwnd
, &wpl
, PLACE_MIN
| PLACE_MAX
| PLACE_RECT
);
1260 /***********************************************************************
1261 * SetInternalWindowPos16 (USER.461)
1263 void WINAPI
SetInternalWindowPos16( HWND16 hwnd
, UINT16 showCmd
,
1264 LPRECT16 rect
, LPPOINT16 pt
)
1266 if( IsWindow16(hwnd
) )
1268 WINDOWPLACEMENT16 wndpl
;
1271 wndpl
.length
= sizeof(wndpl
);
1272 wndpl
.showCmd
= showCmd
;
1273 wndpl
.flags
= flags
= 0;
1278 wndpl
.flags
|= WPF_SETMINPOSITION
;
1279 wndpl
.ptMinPosition
= *pt
;
1283 flags
|= PLACE_RECT
;
1284 wndpl
.rcNormalPosition
= *rect
;
1286 WINPOS_SetPlacement( hwnd
, &wndpl
, flags
);
1291 /***********************************************************************
1292 * SetInternalWindowPos32 (USER32.483)
1294 void WINAPI
SetInternalWindowPos32( HWND32 hwnd
, UINT32 showCmd
,
1295 LPRECT32 rect
, LPPOINT32 pt
)
1297 if( IsWindow32(hwnd
) )
1299 WINDOWPLACEMENT16 wndpl
;
1302 wndpl
.length
= sizeof(wndpl
);
1303 wndpl
.showCmd
= showCmd
;
1304 wndpl
.flags
= flags
= 0;
1309 wndpl
.flags
|= WPF_SETMINPOSITION
;
1310 CONV_POINT32TO16( pt
, &wndpl
.ptMinPosition
);
1314 flags
|= PLACE_RECT
;
1315 CONV_RECT32TO16( rect
, &wndpl
.rcNormalPosition
);
1317 WINPOS_SetPlacement( hwnd
, &wndpl
, flags
);
1322 /***********************************************************************
1323 * WINPOS_ForceXWindowRaise
1325 * Raise a window on top of the X stacking order, while preserving
1326 * the correct Windows Z order.
1328 static void WINPOS_ForceXWindowRaise( WND
* pWnd
)
1330 XWindowChanges winChanges
;
1333 /* Raise all windows up to pWnd according to their Z order.
1334 * (it would be easier with sibling-related Below but it doesn't
1335 * work very well with SGI mwm for instance)
1337 winChanges
.stack_mode
= Above
;
1340 if (pWnd
->window
) TSXReconfigureWMWindow( display
, pWnd
->window
, 0,
1341 CWStackMode
, &winChanges
);
1342 wndPrev
= WIN_GetDesktop()->child
;
1343 if (wndPrev
== pWnd
) break;
1344 while (wndPrev
&& (wndPrev
->next
!= pWnd
)) wndPrev
= wndPrev
->next
;
1350 /*******************************************************************
1351 * WINPOS_SetActiveWindow
1353 * SetActiveWindow() back-end. This is the only function that
1354 * can assign active status to a window. It must be called only
1355 * for the top level windows.
1357 BOOL32
WINPOS_SetActiveWindow( HWND32 hWnd
, BOOL32 fMouse
, BOOL32 fChangeFocus
)
1359 CBTACTIVATESTRUCT16
* cbtStruct
;
1360 WND
* wndPtr
, *wndTemp
;
1361 HQUEUE16 hOldActiveQueue
, hNewActiveQueue
;
1364 /* paranoid checks */
1365 if( hWnd
== GetDesktopWindow32() || hWnd
== hwndActive
) return 0;
1367 /* if (wndPtr && (GetTaskQueue(0) != wndPtr->hmemTaskQ))
1370 wndPtr
= WIN_FindWndPtr(hWnd
);
1371 hOldActiveQueue
= (pActiveQueue
)?pActiveQueue
->self
: 0;
1373 if( (wndTemp
= WIN_FindWndPtr(hwndActive
)) )
1374 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1376 TRACE(win
,"no current active window.\n");
1378 /* call CBT hook chain */
1379 if ((cbtStruct
= SEGPTR_NEW(CBTACTIVATESTRUCT16
)))
1382 cbtStruct
->fMouse
= fMouse
;
1383 cbtStruct
->hWndActive
= hwndActive
;
1384 wRet
= HOOK_CallHooks16( WH_CBT
, HCBT_ACTIVATE
, (WPARAM16
)hWnd
,
1385 (LPARAM
)SEGPTR_GET(cbtStruct
) );
1386 SEGPTR_FREE(cbtStruct
);
1387 if (wRet
) return wRet
;
1390 /* set prev active wnd to current active wnd and send notification */
1391 if ((hwndPrevActive
= hwndActive
) && IsWindow32(hwndPrevActive
))
1393 if (!SendMessage32A( hwndPrevActive
, WM_NCACTIVATE
, FALSE
, 0 ))
1395 if (GetSysModalWindow16() != hWnd
) return 0;
1396 /* disregard refusal if hWnd is sysmodal */
1400 SendMessage32A( hwndPrevActive
, WM_ACTIVATE
,
1401 MAKEWPARAM( WA_INACTIVE
, wIconized
),
1404 /* FIXME: must be SendMessage16() because 32A doesn't do
1405 * intertask at this time */
1406 SendMessage16( hwndPrevActive
, WM_ACTIVATE
, WA_INACTIVE
,
1407 MAKELPARAM( (HWND16
)hWnd
, wIconized
) );
1410 /* check if something happened during message processing */
1411 if( hwndPrevActive
!= hwndActive
) return 0;
1414 /* set active wnd */
1417 /* send palette messages */
1418 if (hWnd
&& SendMessage16( hWnd
, WM_QUERYNEWPALETTE
, 0, 0L))
1419 SendMessage16((HWND16
)-1, WM_PALETTEISCHANGING
, (WPARAM16
)hWnd
, 0L );
1421 /* if prev wnd is minimized redraw icon title */
1422 if( IsIconic32( hwndPrevActive
) ) WINPOS_RedrawIconTitle(hwndPrevActive
);
1424 /* managed windows will get ConfigureNotify event */
1425 if (wndPtr
&& !(wndPtr
->dwStyle
& WS_CHILD
) && !(wndPtr
->flags
& WIN_MANAGED
))
1427 /* check Z-order and bring hWnd to the top */
1428 for (wndTemp
= WIN_GetDesktop()->child
; wndTemp
; wndTemp
= wndTemp
->next
)
1429 if (wndTemp
->dwStyle
& WS_VISIBLE
) break;
1431 if( wndTemp
!= wndPtr
)
1432 SetWindowPos32(hWnd
, HWND_TOP
, 0,0,0,0,
1433 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1434 if (!IsWindow32(hWnd
)) return 0;
1437 hNewActiveQueue
= wndPtr
? wndPtr
->hmemTaskQ
: 0;
1439 /* send WM_ACTIVATEAPP if necessary */
1440 if (hOldActiveQueue
!= hNewActiveQueue
)
1442 WND
**list
, **ppWnd
;
1444 if ((list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1446 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1448 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
1450 if ((*ppWnd
)->hmemTaskQ
== hOldActiveQueue
)
1451 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1452 0, QUEUE_GetQueueTask(hNewActiveQueue
) );
1454 HeapFree( SystemHeap
, 0, list
);
1457 pActiveQueue
= (hNewActiveQueue
)
1458 ? (MESSAGEQUEUE
*) GlobalLock16(hNewActiveQueue
) : NULL
;
1460 if ((list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1462 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1464 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
1466 if ((*ppWnd
)->hmemTaskQ
== hNewActiveQueue
)
1467 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1468 1, QUEUE_GetQueueTask( hOldActiveQueue
) );
1470 HeapFree( SystemHeap
, 0, list
);
1472 if (!IsWindow32(hWnd
)) return 0;
1477 /* walk up to the first unowned window */
1479 while (wndTemp
->owner
) wndTemp
= wndTemp
->owner
;
1480 /* and set last active owned popup */
1481 wndTemp
->hwndLastActive
= hWnd
;
1483 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1484 SendMessage32A( hWnd
, WM_NCACTIVATE
, TRUE
, 0 );
1486 SendMessage32A( hWnd
, WM_ACTIVATE
,
1487 MAKEWPARAM( (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
, wIconized
),
1488 (LPARAM
)hwndPrevActive
);
1490 SendMessage16(hWnd
, WM_ACTIVATE
, (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
,
1491 MAKELPARAM( (HWND16
)hwndPrevActive
, wIconized
) );
1494 if( !IsWindow32(hWnd
) ) return 0;
1497 /* change focus if possible */
1498 if( fChangeFocus
&& GetFocus32() )
1499 if( WIN_GetTopParent(GetFocus32()) != hwndActive
)
1500 FOCUS_SwitchFocus( GetFocus32(),
1501 (wndPtr
->dwStyle
& WS_MINIMIZE
)? 0: hwndActive
);
1503 if( !hwndPrevActive
&& wndPtr
&&
1504 wndPtr
->window
&& !(wndPtr
->flags
& WIN_MANAGED
) )
1505 WINPOS_ForceXWindowRaise(wndPtr
);
1507 /* if active wnd is minimized redraw icon title */
1508 if( IsIconic32(hwndActive
) ) WINPOS_RedrawIconTitle(hwndActive
);
1510 return (hWnd
== hwndActive
);
1513 /*******************************************************************
1514 * WINPOS_ActivateOtherWindow
1516 * Activates window other than pWnd.
1518 BOOL32
WINPOS_ActivateOtherWindow(WND
* pWnd
)
1523 if( pWnd
->hwndSelf
== hwndPrevActive
)
1526 if( hwndActive
!= pWnd
->hwndSelf
&&
1527 ( hwndActive
|| QUEUE_IsExitingQueue(pWnd
->hmemTaskQ
)) )
1530 if( !(pWnd
->dwStyle
& WS_POPUP
) || !(pWnd
->owner
) ||
1531 !WINPOS_CanActivate((pWndTo
= WIN_GetTopParentPtr(pWnd
->owner
))) )
1533 WND
* pWndPtr
= WIN_GetTopParentPtr(pWnd
);
1535 pWndTo
= WIN_FindWndPtr(hwndPrevActive
);
1537 while( !WINPOS_CanActivate(pWndTo
) )
1539 /* by now owned windows should've been taken care of */
1541 pWndTo
= pWndPtr
->next
;
1543 if( !pWndTo
) break;
1547 bRet
= WINPOS_SetActiveWindow( pWndTo
? pWndTo
->hwndSelf
: 0, FALSE
, TRUE
);
1549 /* switch desktop queue to current active */
1550 if( pWndTo
) WIN_GetDesktop()->hmemTaskQ
= pWndTo
->hmemTaskQ
;
1556 /*******************************************************************
1557 * WINPOS_ChangeActiveWindow
1560 BOOL32
WINPOS_ChangeActiveWindow( HWND32 hWnd
, BOOL32 mouseMsg
)
1562 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
1564 if (!hWnd
) return WINPOS_SetActiveWindow( 0, mouseMsg
, TRUE
);
1566 if( !wndPtr
) return FALSE
;
1568 /* child windows get WM_CHILDACTIVATE message */
1569 if( (wndPtr
->dwStyle
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
1570 return SendMessage32A(hWnd
, WM_CHILDACTIVATE
, 0, 0L);
1572 /* owned popups imply owner activation - not sure */
1573 if ((wndPtr
->dwStyle
& WS_POPUP
) && wndPtr
->owner
&&
1574 !(wndPtr
->owner
->dwStyle
& WS_DISABLED
))
1576 if (!(wndPtr
= wndPtr
->owner
)) return FALSE
;
1577 hWnd
= wndPtr
->hwndSelf
;
1580 if( hWnd
== hwndActive
) return FALSE
;
1582 if( !WINPOS_SetActiveWindow(hWnd
,mouseMsg
,TRUE
) )
1585 /* switch desktop queue to current active */
1586 if( wndPtr
->parent
== WIN_GetDesktop())
1587 WIN_GetDesktop()->hmemTaskQ
= wndPtr
->hmemTaskQ
;
1593 /***********************************************************************
1594 * WINPOS_SendNCCalcSize
1596 * Send a WM_NCCALCSIZE message to a window.
1597 * All parameters are read-only except newClientRect.
1598 * oldWindowRect, oldClientRect and winpos must be non-NULL only
1599 * when calcValidRect is TRUE.
1601 LONG
WINPOS_SendNCCalcSize( HWND32 hwnd
, BOOL32 calcValidRect
,
1602 RECT32
*newWindowRect
, RECT32
*oldWindowRect
,
1603 RECT32
*oldClientRect
, WINDOWPOS32
*winpos
,
1604 RECT32
*newClientRect
)
1606 NCCALCSIZE_PARAMS32 params
;
1609 params
.rgrc
[0] = *newWindowRect
;
1612 params
.rgrc
[1] = *oldWindowRect
;
1613 params
.rgrc
[2] = *oldClientRect
;
1614 params
.lppos
= winpos
;
1616 result
= SendMessage32A( hwnd
, WM_NCCALCSIZE
, calcValidRect
,
1618 TRACE(win
, "%d,%d-%d,%d\n",
1619 params
.rgrc
[0].left
, params
.rgrc
[0].top
,
1620 params
.rgrc
[0].right
, params
.rgrc
[0].bottom
);
1621 *newClientRect
= params
.rgrc
[0];
1626 /***********************************************************************
1627 * WINPOS_HandleWindowPosChanging16
1629 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1631 LONG
WINPOS_HandleWindowPosChanging16( WND
*wndPtr
, WINDOWPOS16
*winpos
)
1633 POINT32 maxSize
, minTrack
;
1634 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1635 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1636 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1638 WINPOS_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, &minTrack
, NULL
);
1639 if (maxSize
.x
< winpos
->cx
) winpos
->cx
= maxSize
.x
;
1640 if (maxSize
.y
< winpos
->cy
) winpos
->cy
= maxSize
.y
;
1641 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
1643 if (winpos
->cx
< minTrack
.x
) winpos
->cx
= minTrack
.x
;
1644 if (winpos
->cy
< minTrack
.y
) winpos
->cy
= minTrack
.y
;
1651 /***********************************************************************
1652 * WINPOS_HandleWindowPosChanging32
1654 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1656 LONG
WINPOS_HandleWindowPosChanging32( WND
*wndPtr
, WINDOWPOS32
*winpos
)
1659 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1660 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1661 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1663 WINPOS_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, NULL
, NULL
);
1664 winpos
->cx
= MIN( winpos
->cx
, maxSize
.x
);
1665 winpos
->cy
= MIN( winpos
->cy
, maxSize
.y
);
1671 /***********************************************************************
1672 * WINPOS_MoveWindowZOrder
1674 * Move a window in Z order, invalidating everything that needs it.
1675 * Only necessary for windows without associated X window.
1677 static void WINPOS_MoveWindowZOrder( HWND32 hwnd
, HWND32 hwndAfter
)
1680 WND
*pWndAfter
, *pWndCur
, *wndPtr
= WIN_FindWndPtr( hwnd
);
1682 /* We have two possible cases:
1683 * - The window is moving up: we have to invalidate all areas
1684 * of the window that were covered by other windows
1685 * - The window is moving down: we have to invalidate areas
1686 * of other windows covered by this one.
1689 if (hwndAfter
== HWND_TOP
)
1693 else if (hwndAfter
== HWND_BOTTOM
)
1695 if (!wndPtr
->next
) return; /* Already at the bottom */
1700 if (!(pWndAfter
= WIN_FindWndPtr( hwndAfter
))) return;
1701 if (wndPtr
->next
== pWndAfter
) return; /* Already placed right */
1703 /* Determine which window we encounter first in Z-order */
1704 pWndCur
= wndPtr
->parent
->child
;
1705 while ((pWndCur
!= wndPtr
) && (pWndCur
!= pWndAfter
))
1706 pWndCur
= pWndCur
->next
;
1707 movingUp
= (pWndCur
== pWndAfter
);
1712 WND
*pWndPrevAfter
= wndPtr
->next
;
1713 WIN_UnlinkWindow( hwnd
);
1714 WIN_LinkWindow( hwnd
, hwndAfter
);
1715 pWndCur
= wndPtr
->next
;
1716 while (pWndCur
!= pWndPrevAfter
)
1718 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1719 pWndCur
->rectWindow
.top
,
1720 pWndCur
->rectWindow
.right
,
1721 pWndCur
->rectWindow
.bottom
};
1722 OffsetRect32( &rect
, -wndPtr
->rectClient
.left
,
1723 -wndPtr
->rectClient
.top
);
1724 PAINT_RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
1725 RDW_FRAME
| RDW_ERASE
, 0 );
1726 pWndCur
= pWndCur
->next
;
1729 else /* Moving down */
1731 pWndCur
= wndPtr
->next
;
1732 WIN_UnlinkWindow( hwnd
);
1733 WIN_LinkWindow( hwnd
, hwndAfter
);
1734 while (pWndCur
!= wndPtr
)
1736 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1737 pWndCur
->rectWindow
.top
,
1738 pWndCur
->rectWindow
.right
,
1739 pWndCur
->rectWindow
.bottom
};
1740 OffsetRect32( &rect
, -pWndCur
->rectClient
.left
,
1741 -pWndCur
->rectClient
.top
);
1742 PAINT_RedrawWindow( pWndCur
->hwndSelf
, &rect
, 0, RDW_INVALIDATE
|
1743 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
1744 pWndCur
= pWndCur
->next
;
1749 /***********************************************************************
1750 * WINPOS_ReorderOwnedPopups
1752 * fix Z order taking into account owned popups -
1753 * basically we need to maintain them above owner window
1755 HWND32
WINPOS_ReorderOwnedPopups(HWND32 hwndInsertAfter
,WND
* wndPtr
,WORD flags
)
1757 WND
* w
= WIN_GetDesktop()->child
;
1759 if( wndPtr
->dwStyle
& WS_POPUP
&& wndPtr
->owner
)
1761 /* implement "local z-order" between the top and owner window */
1763 HWND32 hwndLocalPrev
= HWND_TOP
;
1765 if( hwndInsertAfter
!= HWND_TOP
)
1767 while( w
!= wndPtr
->owner
)
1769 if (w
!= wndPtr
) hwndLocalPrev
= w
->hwndSelf
;
1770 if( hwndLocalPrev
== hwndInsertAfter
) break;
1773 hwndInsertAfter
= hwndLocalPrev
;
1777 else if( wndPtr
->dwStyle
& WS_CHILD
) return hwndInsertAfter
;
1779 w
= WIN_GetDesktop()->child
;
1782 if( w
== wndPtr
) break;
1784 if( w
->dwStyle
& WS_POPUP
&& w
->owner
== wndPtr
)
1786 SetWindowPos32(w
->hwndSelf
, hwndInsertAfter
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
|
1787 SWP_NOACTIVATE
| SWP_NOSENDCHANGING
| SWP_DEFERERASE
);
1788 hwndInsertAfter
= w
->hwndSelf
;
1793 return hwndInsertAfter
;
1796 /***********************************************************************
1797 * WINPOS_SizeMoveClean
1799 * Make window look nice without excessive repainting
1803 * visible regions are in window coordinates
1804 * update regions are in window client coordinates
1805 * client and window rectangles are in parent client coordinates
1807 * FIXME: Move visible and update regions to the same coordinate system
1808 * (either parent client or window). This is a lot of work though.
1810 static UINT32
WINPOS_SizeMoveClean( WND
* Wnd
, HRGN32 oldVisRgn
,
1811 LPRECT32 lpOldWndRect
,
1812 LPRECT32 lpOldClientRect
, UINT32 uFlags
)
1814 HRGN32 newVisRgn
= DCE_GetVisRgn(Wnd
->hwndSelf
,DCX_WINDOW
| DCX_CLIPSIBLINGS
);
1815 HRGN32 dirtyRgn
= CreateRectRgn32(0,0,0,0);
1818 TRACE(win
,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n",
1819 Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
,
1820 Wnd
->rectWindow
.right
, Wnd
->rectWindow
.bottom
,
1821 lpOldWndRect
->left
, lpOldWndRect
->top
,
1822 lpOldWndRect
->right
, lpOldWndRect
->bottom
);
1823 TRACE(win
,"\tnew client=(%i %i-%i %i) old client=(%i %i-%i %i)\n",
1824 Wnd
->rectClient
.left
, Wnd
->rectClient
.top
,
1825 Wnd
->rectClient
.right
, Wnd
->rectClient
.bottom
,
1826 lpOldClientRect
->left
, lpOldClientRect
->top
,
1827 lpOldClientRect
->right
,lpOldClientRect
->bottom
);
1829 if( (lpOldWndRect
->right
- lpOldWndRect
->left
) != (Wnd
->rectWindow
.right
- Wnd
->rectWindow
.left
) ||
1830 (lpOldWndRect
->bottom
- lpOldWndRect
->top
) != (Wnd
->rectWindow
.bottom
- Wnd
->rectWindow
.top
) )
1831 uFlags
|= SMC_DRAWFRAME
;
1833 CombineRgn32( dirtyRgn
, newVisRgn
, 0, RGN_COPY
);
1835 if( !(uFlags
& SMC_NOCOPY
) )
1836 CombineRgn32( newVisRgn
, newVisRgn
, oldVisRgn
, RGN_AND
);
1838 /* map regions to the parent client area */
1840 OffsetRgn32( dirtyRgn
, Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
);
1841 OffsetRgn32( oldVisRgn
, lpOldWndRect
->left
, lpOldWndRect
->top
);
1843 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1845 other
= CombineRgn32(dirtyRgn
, oldVisRgn
, dirtyRgn
, RGN_DIFF
);
1847 /* map visible region to the Wnd client area */
1849 OffsetRgn32( newVisRgn
, Wnd
->rectWindow
.left
- Wnd
->rectClient
.left
,
1850 Wnd
->rectWindow
.top
- Wnd
->rectClient
.top
);
1852 /* substract previously invalidated region from the Wnd visible region */
1854 my
= (Wnd
->hrgnUpdate
> 1) ? CombineRgn32( newVisRgn
, newVisRgn
,
1855 Wnd
->hrgnUpdate
, RGN_DIFF
)
1858 if( uFlags
& SMC_NOCOPY
) /* invalidate Wnd visible region */
1860 if (my
!= NULLREGION
)
1861 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, newVisRgn
, RDW_INVALIDATE
|
1862 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1863 else if(uFlags
& SMC_DRAWFRAME
)
1864 Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1866 else /* bitblt old client area */
1871 int xfrom
,yfrom
,xto
,yto
,width
,height
;
1873 if( uFlags
& SMC_DRAWFRAME
)
1875 /* copy only client area, frame will be redrawn anyway */
1877 xfrom
= lpOldClientRect
->left
; yfrom
= lpOldClientRect
->top
;
1878 xto
= Wnd
->rectClient
.left
; yto
= Wnd
->rectClient
.top
;
1879 width
= lpOldClientRect
->right
- xfrom
; height
= lpOldClientRect
->bottom
- yfrom
;
1880 updateRgn
= CreateRectRgn32( 0, 0, width
, height
);
1881 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1882 SetRectRgn32( updateRgn
, 0, 0, Wnd
->rectClient
.right
- xto
,
1883 Wnd
->rectClient
.bottom
- yto
);
1887 xfrom
= lpOldWndRect
->left
; yfrom
= lpOldWndRect
->top
;
1888 xto
= Wnd
->rectWindow
.left
; yto
= Wnd
->rectWindow
.top
;
1889 width
= lpOldWndRect
->right
- xfrom
; height
= lpOldWndRect
->bottom
- yfrom
;
1890 updateRgn
= CreateRectRgn32( xto
- Wnd
->rectClient
.left
,
1891 yto
- Wnd
->rectClient
.top
,
1892 Wnd
->rectWindow
.right
- Wnd
->rectClient
.left
,
1893 Wnd
->rectWindow
.bottom
- Wnd
->rectClient
.top
);
1896 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1898 /* substract new visRgn from target rect to get a region that won't be copied */
1900 update
= CombineRgn32( updateRgn
, updateRgn
, newVisRgn
, RGN_DIFF
);
1902 /* Blt valid bits using parent window DC */
1904 if( my
!= NULLREGION
&& (xfrom
!= xto
|| yfrom
!= yto
) )
1907 /* compute clipping region in parent client coordinates */
1909 OffsetRgn32( newVisRgn
, Wnd
->rectClient
.left
, Wnd
->rectClient
.top
);
1910 CombineRgn32( oldVisRgn
, oldVisRgn
, newVisRgn
, RGN_OR
);
1912 hDC
= GetDCEx32( Wnd
->parent
->hwndSelf
, oldVisRgn
,
1913 DCX_KEEPCLIPRGN
| DCX_INTERSECTRGN
|
1914 DCX_CACHE
| DCX_CLIPSIBLINGS
);
1916 BitBlt32( hDC
, xto
, yto
, width
, height
, hDC
, xfrom
, yfrom
, SRCCOPY
);
1917 ReleaseDC32( Wnd
->parent
->hwndSelf
, hDC
);
1920 if( update
!= NULLREGION
)
1921 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, updateRgn
, RDW_INVALIDATE
|
1922 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1923 else if( uFlags
& SMC_DRAWFRAME
) Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1924 DeleteObject32( updateRgn
);
1927 /* erase uncovered areas */
1929 if( !(uFlags
& SMC_NOPARENTERASE
) && (other
!= NULLREGION
) )
1930 PAINT_RedrawWindow( Wnd
->parent
->hwndSelf
, NULL
, dirtyRgn
,
1931 RDW_INVALIDATE
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1932 DeleteObject32(dirtyRgn
);
1933 DeleteObject32(newVisRgn
);
1938 /***********************************************************************
1939 * WINPOS_FindDeskTopXWindow
1941 * Find the actual X window which needs be restacked.
1942 * Used by WINPOS_SetXWindowPos().
1944 static Window
WINPOS_FindDeskTopXWindow( WND
*wndPtr
)
1946 if (!(wndPtr
->flags
& WIN_MANAGED
))
1947 return wndPtr
->window
;
1950 Window window
, root
, parent
, *children
;
1952 window
= wndPtr
->window
;
1955 TSXQueryTree( display
, window
, &root
, &parent
,
1956 &children
, &nchildren
);
1957 TSXFree( children
);
1965 /***********************************************************************
1966 * WINPOS_SetXWindowPos
1968 * SetWindowPos() for an X window. Used by the real SetWindowPos().
1970 static void WINPOS_SetXWindowPos( const WINDOWPOS32
*winpos
)
1972 XWindowChanges winChanges
;
1974 WND
*wndPtr
= WIN_FindWndPtr( winpos
->hwnd
);
1976 if (!(winpos
->flags
& SWP_NOSIZE
))
1978 winChanges
.width
= winpos
->cx
;
1979 winChanges
.height
= winpos
->cy
;
1980 changeMask
|= CWWidth
| CWHeight
;
1982 /* Tweak dialog window size hints */
1984 if ((wndPtr
->flags
& WIN_MANAGED
) &&
1985 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
1987 XSizeHints
*size_hints
= TSXAllocSizeHints();
1991 long supplied_return
;
1993 TSXGetWMSizeHints( display
, wndPtr
->window
, size_hints
,
1994 &supplied_return
, XA_WM_NORMAL_HINTS
);
1995 size_hints
->min_width
= size_hints
->max_width
= winpos
->cx
;
1996 size_hints
->min_height
= size_hints
->max_height
= winpos
->cy
;
1997 TSXSetWMSizeHints( display
, wndPtr
->window
, size_hints
,
1998 XA_WM_NORMAL_HINTS
);
1999 TSXFree(size_hints
);
2003 if (!(winpos
->flags
& SWP_NOMOVE
))
2005 winChanges
.x
= winpos
->x
;
2006 winChanges
.y
= winpos
->y
;
2007 changeMask
|= CWX
| CWY
;
2009 if (!(winpos
->flags
& SWP_NOZORDER
))
2011 winChanges
.stack_mode
= Below
;
2012 changeMask
|= CWStackMode
;
2014 if (winpos
->hwndInsertAfter
== HWND_TOP
) winChanges
.stack_mode
= Above
;
2015 else if (winpos
->hwndInsertAfter
!= HWND_BOTTOM
)
2017 WND
* insertPtr
= WIN_FindWndPtr( winpos
->hwndInsertAfter
);
2020 stack
[0] = WINPOS_FindDeskTopXWindow( insertPtr
);
2021 stack
[1] = WINPOS_FindDeskTopXWindow( wndPtr
);
2023 /* for stupid window managers (i.e. all of them) */
2025 TSXRestackWindows(display
, stack
, 2);
2026 changeMask
&= ~CWStackMode
;
2029 if (!changeMask
) return;
2031 TSXReconfigureWMWindow( display
, wndPtr
->window
, 0, changeMask
, &winChanges
);
2035 /***********************************************************************
2036 * SetWindowPos (USER.232)
2038 BOOL16 WINAPI
SetWindowPos16( HWND16 hwnd
, HWND16 hwndInsertAfter
,
2039 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, WORD flags
)
2041 return SetWindowPos32(hwnd
,(INT32
)(INT16
)hwndInsertAfter
,x
,y
,cx
,cy
,flags
);
2044 /***********************************************************************
2045 * SetWindowPos (USER32.520)
2047 BOOL32 WINAPI
SetWindowPos32( HWND32 hwnd
, HWND32 hwndInsertAfter
,
2048 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
, WORD flags
)
2052 RECT32 newWindowRect
, newClientRect
, oldWindowRect
;
2054 HWND32 tempInsertAfter
= 0;
2057 BOOL32 resync
= FALSE
;
2059 TRACE(win
,"hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
2060 hwnd
, x
, y
, x
+cx
, y
+cy
, flags
);
2061 /* Check window handle */
2063 if (hwnd
== GetDesktopWindow32()) return FALSE
;
2064 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return FALSE
;
2066 if(wndPtr
->dwStyle
& WS_VISIBLE
)
2067 flags
&= ~SWP_SHOWWINDOW
;
2070 uFlags
|= SMC_NOPARENTERASE
;
2071 flags
&= ~SWP_HIDEWINDOW
;
2072 if (!(flags
& SWP_SHOWWINDOW
)) flags
|= SWP_NOREDRAW
;
2075 /* Check for windows that may not be resized
2076 FIXME: this should be done only for Windows 3.0 programs
2077 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
2078 flags |= SWP_NOSIZE | SWP_NOMOVE;
2080 /* Check dimensions */
2082 if (cx
<= 0) cx
= 1;
2083 if (cy
<= 0) cy
= 1;
2087 if (hwnd
== hwndActive
) flags
|= SWP_NOACTIVATE
; /* Already active */
2088 if ((wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
== cx
) &&
2089 (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
== cy
))
2090 flags
|= SWP_NOSIZE
; /* Already the right size */
2091 if ((wndPtr
->rectWindow
.left
== x
) && (wndPtr
->rectWindow
.top
== y
))
2092 flags
|= SWP_NOMOVE
; /* Already the right position */
2094 /* Check hwndInsertAfter */
2096 if (!(flags
& (SWP_NOZORDER
| SWP_NOACTIVATE
)))
2098 /* Ignore TOPMOST flags when activating a window */
2099 /* _and_ moving it in Z order. */
2100 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
2101 (hwndInsertAfter
== HWND_NOTOPMOST
))
2102 hwndInsertAfter
= HWND_TOP
;
2104 /* TOPMOST not supported yet */
2105 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
2106 (hwndInsertAfter
== HWND_NOTOPMOST
)) hwndInsertAfter
= HWND_TOP
;
2108 /* hwndInsertAfter must be a sibling of the window */
2109 if ((hwndInsertAfter
!= HWND_TOP
) && (hwndInsertAfter
!= HWND_BOTTOM
))
2111 WND
* wnd
= WIN_FindWndPtr(hwndInsertAfter
);
2112 if( wnd
->parent
!= wndPtr
->parent
) return FALSE
;
2113 if( wnd
->next
== wndPtr
) flags
|= SWP_NOZORDER
;
2115 else if (!(wndPtr
->window
))
2116 /* FIXME: the following optimization is no good for "X-ed" windows */
2117 if (hwndInsertAfter
== HWND_TOP
)
2118 flags
|= ( wndPtr
->parent
->child
== wndPtr
)? SWP_NOZORDER
: 0;
2119 else /* HWND_BOTTOM */
2120 flags
|= ( wndPtr
->next
)? 0: SWP_NOZORDER
;
2122 /* Fill the WINDOWPOS structure */
2125 winpos
.hwndInsertAfter
= hwndInsertAfter
;
2130 winpos
.flags
= flags
;
2132 /* Send WM_WINDOWPOSCHANGING message */
2134 if (!(winpos
.flags
& SWP_NOSENDCHANGING
))
2135 SendMessage32A( hwnd
, WM_WINDOWPOSCHANGING
, 0, (LPARAM
)&winpos
);
2137 /* Calculate new position and size */
2139 newWindowRect
= wndPtr
->rectWindow
;
2140 newClientRect
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? wndPtr
->rectWindow
2141 : wndPtr
->rectClient
;
2143 if (!(winpos
.flags
& SWP_NOSIZE
))
2145 newWindowRect
.right
= newWindowRect
.left
+ winpos
.cx
;
2146 newWindowRect
.bottom
= newWindowRect
.top
+ winpos
.cy
;
2148 if (!(winpos
.flags
& SWP_NOMOVE
))
2150 newWindowRect
.left
= winpos
.x
;
2151 newWindowRect
.top
= winpos
.y
;
2152 newWindowRect
.right
+= winpos
.x
- wndPtr
->rectWindow
.left
;
2153 newWindowRect
.bottom
+= winpos
.y
- wndPtr
->rectWindow
.top
;
2155 OffsetRect32( &newClientRect
, winpos
.x
- wndPtr
->rectWindow
.left
,
2156 winpos
.y
- wndPtr
->rectWindow
.top
);
2159 winpos
.flags
|= SWP_NOCLIENTMOVE
| SWP_NOCLIENTSIZE
;
2161 /* Reposition window in Z order */
2163 if (!(winpos
.flags
& SWP_NOZORDER
))
2165 /* reorder owned popups if hwnd is top-level window
2167 if( wndPtr
->parent
== WIN_GetDesktop() )
2168 hwndInsertAfter
= WINPOS_ReorderOwnedPopups( hwndInsertAfter
,
2169 wndPtr
, winpos
.flags
);
2173 WIN_UnlinkWindow( winpos
.hwnd
);
2174 WIN_LinkWindow( winpos
.hwnd
, hwndInsertAfter
);
2176 else WINPOS_MoveWindowZOrder( winpos
.hwnd
, hwndInsertAfter
);
2179 if ( !wndPtr
->window
&& !(winpos
.flags
& SWP_NOREDRAW
) &&
2180 ((winpos
.flags
& (SWP_NOMOVE
| SWP_NOSIZE
| SWP_FRAMECHANGED
))
2181 != (SWP_NOMOVE
| SWP_NOSIZE
)) )
2182 visRgn
= DCE_GetVisRgn(hwnd
, DCX_WINDOW
| DCX_CLIPSIBLINGS
);
2185 /* Send WM_NCCALCSIZE message to get new client area */
2186 if( (winpos
.flags
& (SWP_FRAMECHANGED
| SWP_NOSIZE
)) != SWP_NOSIZE
)
2188 result
= WINPOS_SendNCCalcSize( winpos
.hwnd
, TRUE
, &newWindowRect
,
2189 &wndPtr
->rectWindow
, &wndPtr
->rectClient
,
2190 &winpos
, &newClientRect
);
2192 /* FIXME: WVR_ALIGNxxx */
2194 if( newClientRect
.left
!= wndPtr
->rectClient
.left
||
2195 newClientRect
.top
!= wndPtr
->rectClient
.top
)
2196 winpos
.flags
&= ~SWP_NOCLIENTMOVE
;
2198 if( (newClientRect
.right
- newClientRect
.left
!=
2199 wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
) ||
2200 (newClientRect
.bottom
- newClientRect
.top
!=
2201 wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
) )
2202 winpos
.flags
&= ~SWP_NOCLIENTSIZE
;
2205 if( !(flags
& SWP_NOMOVE
) && (newClientRect
.left
!= wndPtr
->rectClient
.left
||
2206 newClientRect
.top
!= wndPtr
->rectClient
.top
) )
2207 winpos
.flags
&= ~SWP_NOCLIENTMOVE
;
2209 /* Update active DCEs
2210 * TODO: Optimize conditions that trigger DCE update.
2213 if( (((winpos
.flags
& SWP_AGG_NOPOSCHANGE
) != SWP_AGG_NOPOSCHANGE
) &&
2214 wndPtr
->dwStyle
& WS_VISIBLE
) ||
2215 (flags
& (SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
2219 UnionRect32(&rect
, &newWindowRect
, &wndPtr
->rectWindow
);
2220 DCE_InvalidateDCE(wndPtr
, &rect
);
2223 /* change geometry */
2225 oldWindowRect
= wndPtr
->rectWindow
;
2229 RECT32 oldClientRect
= wndPtr
->rectClient
;
2231 tempInsertAfter
= winpos
.hwndInsertAfter
;
2233 winpos
.hwndInsertAfter
= hwndInsertAfter
;
2235 /* postpone geometry change */
2237 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
2239 WINPOS_SetXWindowPos( &winpos
);
2240 winpos
.hwndInsertAfter
= tempInsertAfter
;
2242 else uFlags
|= SMC_SETXPOS
;
2244 wndPtr
->rectWindow
= newWindowRect
;
2245 wndPtr
->rectClient
= newClientRect
;
2247 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
2248 if( (oldClientRect
.left
- oldWindowRect
.left
!=
2249 newClientRect
.left
- newWindowRect
.left
) ||
2250 (oldClientRect
.top
- oldWindowRect
.top
!=
2251 newClientRect
.top
- newWindowRect
.top
) ||
2252 winpos
.flags
& SWP_NOCOPYBITS
)
2254 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, RDW_INVALIDATE
|
2255 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
2257 if( winpos
.flags
& SWP_FRAMECHANGED
)
2262 if( oldClientRect
.right
> newClientRect
.right
)
2264 rect
.left
= newClientRect
.right
; rect
.top
= newClientRect
.top
;
2265 rect
.right
= oldClientRect
.right
; rect
.bottom
= newClientRect
.bottom
;
2267 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
2268 RDW_INVALIDATE
| RDW_FRAME
| RDW_ALLCHILDREN
, 0 );
2270 if( oldClientRect
.bottom
> newClientRect
.bottom
)
2272 rect
.left
= newClientRect
.left
; rect
.top
= newClientRect
.bottom
;
2273 rect
.right
= (wErase
)?oldClientRect
.right
:newClientRect
.right
;
2274 rect
.bottom
= oldClientRect
.bottom
;
2276 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
2277 RDW_INVALIDATE
| RDW_FRAME
| RDW_ALLCHILDREN
, 0 );
2279 if( !wErase
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
2284 RECT32 oldClientRect
= wndPtr
->rectClient
;
2286 wndPtr
->rectWindow
= newWindowRect
;
2287 wndPtr
->rectClient
= newClientRect
;
2289 if( oldClientRect
.bottom
- oldClientRect
.top
==
2290 newClientRect
.bottom
- newClientRect
.top
) result
&= ~WVR_VREDRAW
;
2292 if( oldClientRect
.right
- oldClientRect
.left
==
2293 newClientRect
.right
- newClientRect
.left
) result
&= ~WVR_HREDRAW
;
2295 if( !(flags
& (SWP_NOREDRAW
| SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
2297 uFlags
|= ((winpos
.flags
& SWP_NOCOPYBITS
) ||
2298 (result
>= WVR_HREDRAW
&& result
< WVR_VALIDRECTS
)) ? SMC_NOCOPY
: 0;
2299 uFlags
|= (winpos
.flags
& SWP_FRAMECHANGED
) ? SMC_DRAWFRAME
: 0;
2301 if( (winpos
.flags
& SWP_AGG_NOGEOMETRYCHANGE
) != SWP_AGG_NOGEOMETRYCHANGE
)
2302 uFlags
= WINPOS_SizeMoveClean(wndPtr
, visRgn
, &oldWindowRect
,
2303 &oldClientRect
, uFlags
);
2306 /* adjust frame and do not erase parent */
2308 if( winpos
.flags
& SWP_FRAMECHANGED
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
2309 if( winpos
.flags
& SWP_NOZORDER
) uFlags
|= SMC_NOPARENTERASE
;
2312 DeleteObject32(visRgn
);
2315 if (flags
& SWP_SHOWWINDOW
)
2317 wndPtr
->dwStyle
|= WS_VISIBLE
;
2322 if( uFlags
& SMC_SETXPOS
)
2324 WINPOS_SetXWindowPos( &winpos
);
2325 winpos
.hwndInsertAfter
= tempInsertAfter
;
2327 TSXMapWindow( display
, wndPtr
->window
);
2328 if (wndPtr
->flags
& WIN_MANAGED
) resync
= TRUE
;
2330 /* If focus was set to an unmapped window, reset X focus now */
2331 focus
= curr
= GetFocus32();
2335 SetFocus32( focus
);
2338 curr
= GetParent32(curr
);
2343 if (!(flags
& SWP_NOREDRAW
))
2344 PAINT_RedrawWindow( winpos
.hwnd
, NULL
, 0,
2345 RDW_INVALIDATE
| RDW_ALLCHILDREN
|
2346 RDW_FRAME
| RDW_ERASENOW
| RDW_ERASE
, 0 );
2349 else if (flags
& SWP_HIDEWINDOW
)
2351 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
2354 TSXUnmapWindow( display
, wndPtr
->window
);
2355 if( uFlags
& SMC_SETXPOS
)
2357 WINPOS_SetXWindowPos( &winpos
);
2358 winpos
.hwndInsertAfter
= tempInsertAfter
;
2363 if (!(flags
& SWP_NOREDRAW
))
2364 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, &oldWindowRect
,
2365 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
2366 RDW_ERASE
| RDW_ERASENOW
, 0 );
2367 uFlags
|= SMC_NOPARENTERASE
;
2370 if ((winpos
.hwnd
== GetFocus32()) ||
2371 IsChild32( winpos
.hwnd
, GetFocus32()))
2373 /* Revert focus to parent */
2374 SetFocus32( GetParent32(winpos
.hwnd
) );
2376 if (hwnd
== CARET_GetHwnd()) DestroyCaret32();
2378 if (winpos
.hwnd
== hwndActive
)
2379 WINPOS_ActivateOtherWindow( wndPtr
);
2382 /* Activate the window */
2384 if (!(flags
& SWP_NOACTIVATE
))
2385 WINPOS_ChangeActiveWindow( winpos
.hwnd
, FALSE
);
2387 /* Repaint the window */
2389 if (wndPtr
->window
) EVENT_Synchronize(); /* Wait for all expose events */
2391 if (!GetCapture32())
2392 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
2394 if (!(flags
& SWP_DEFERERASE
) && !(uFlags
& SMC_NOPARENTERASE
) )
2395 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_ALLCHILDREN
| RDW_ERASENOW
, 0 );
2396 else if( wndPtr
->parent
== WIN_GetDesktop() && wndPtr
->parent
->flags
& WIN_NEEDS_ERASEBKGND
)
2397 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_NOCHILDREN
| RDW_ERASENOW
, 0 );
2399 /* And last, send the WM_WINDOWPOSCHANGED message */
2401 TRACE(win
,"\tstatus flags = %04x\n", winpos
.flags
& SWP_AGG_STATUSFLAGS
);
2404 (((winpos
.flags
& SWP_AGG_STATUSFLAGS
) != SWP_AGG_NOPOSCHANGE
) &&
2405 !(winpos
.flags
& SWP_NOSENDCHANGING
)) )
2407 SendMessage32A( winpos
.hwnd
, WM_WINDOWPOSCHANGED
, 0, (LPARAM
)&winpos
);
2408 if (resync
) EVENT_Synchronize ();
2415 /***********************************************************************
2416 * BeginDeferWindowPos16 (USER.259)
2418 HDWP16 WINAPI
BeginDeferWindowPos16( INT16 count
)
2420 return BeginDeferWindowPos32( count
);
2424 /***********************************************************************
2425 * BeginDeferWindowPos32 (USER32.9)
2427 HDWP32 WINAPI
BeginDeferWindowPos32( INT32 count
)
2432 if (count
<= 0) return 0;
2433 handle
= USER_HEAP_ALLOC( sizeof(DWP
) + (count
-1)*sizeof(WINDOWPOS32
) );
2434 if (!handle
) return 0;
2435 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( handle
);
2436 pDWP
->actualCount
= 0;
2437 pDWP
->suggestedCount
= count
;
2439 pDWP
->wMagic
= DWP_MAGIC
;
2440 pDWP
->hwndParent
= 0;
2445 /***********************************************************************
2446 * DeferWindowPos16 (USER.260)
2448 HDWP16 WINAPI
DeferWindowPos16( HDWP16 hdwp
, HWND16 hwnd
, HWND16 hwndAfter
,
2449 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
2452 return DeferWindowPos32( hdwp
, hwnd
, (INT32
)(INT16
)hwndAfter
,
2453 x
, y
, cx
, cy
, flags
);
2457 /***********************************************************************
2458 * DeferWindowPos32 (USER32.128)
2460 HDWP32 WINAPI
DeferWindowPos32( HDWP32 hdwp
, HWND32 hwnd
, HWND32 hwndAfter
,
2461 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
2466 HDWP32 newhdwp
= hdwp
;
2470 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2471 if (!pDWP
) return 0;
2472 if (hwnd
== GetDesktopWindow32()) return 0;
2474 /* All the windows of a DeferWindowPos() must have the same parent */
2475 if (!(pWnd
=WIN_FindWndPtr( hwnd
))) {
2476 USER_HEAP_FREE( hdwp
);
2480 parent
= pWnd
->parent
->hwndSelf
;
2481 if (pDWP
->actualCount
== 0) pDWP
->hwndParent
= parent
;
2482 else if (parent
!= pDWP
->hwndParent
)
2484 USER_HEAP_FREE( hdwp
);
2488 for (i
= 0; i
< pDWP
->actualCount
; i
++)
2490 if (pDWP
->winPos
[i
].hwnd
== hwnd
)
2492 /* Merge with the other changes */
2493 if (!(flags
& SWP_NOZORDER
))
2495 pDWP
->winPos
[i
].hwndInsertAfter
= hwndAfter
;
2497 if (!(flags
& SWP_NOMOVE
))
2499 pDWP
->winPos
[i
].x
= x
;
2500 pDWP
->winPos
[i
].y
= y
;
2502 if (!(flags
& SWP_NOSIZE
))
2504 pDWP
->winPos
[i
].cx
= cx
;
2505 pDWP
->winPos
[i
].cy
= cy
;
2507 pDWP
->winPos
[i
].flags
&= flags
| ~(SWP_NOSIZE
| SWP_NOMOVE
|
2508 SWP_NOZORDER
| SWP_NOREDRAW
|
2509 SWP_NOACTIVATE
| SWP_NOCOPYBITS
|
2511 pDWP
->winPos
[i
].flags
|= flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
|
2516 if (pDWP
->actualCount
>= pDWP
->suggestedCount
)
2518 newhdwp
= USER_HEAP_REALLOC( hdwp
,
2519 sizeof(DWP
) + pDWP
->suggestedCount
*sizeof(WINDOWPOS32
) );
2520 if (!newhdwp
) return 0;
2521 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( newhdwp
);
2522 pDWP
->suggestedCount
++;
2524 pDWP
->winPos
[pDWP
->actualCount
].hwnd
= hwnd
;
2525 pDWP
->winPos
[pDWP
->actualCount
].hwndInsertAfter
= hwndAfter
;
2526 pDWP
->winPos
[pDWP
->actualCount
].x
= x
;
2527 pDWP
->winPos
[pDWP
->actualCount
].y
= y
;
2528 pDWP
->winPos
[pDWP
->actualCount
].cx
= cx
;
2529 pDWP
->winPos
[pDWP
->actualCount
].cy
= cy
;
2530 pDWP
->winPos
[pDWP
->actualCount
].flags
= flags
;
2531 pDWP
->actualCount
++;
2536 /***********************************************************************
2537 * EndDeferWindowPos16 (USER.261)
2539 BOOL16 WINAPI
EndDeferWindowPos16( HDWP16 hdwp
)
2541 return EndDeferWindowPos32( hdwp
);
2545 /***********************************************************************
2546 * EndDeferWindowPos32 (USER32.173)
2548 BOOL32 WINAPI
EndDeferWindowPos32( HDWP32 hdwp
)
2551 WINDOWPOS32
*winpos
;
2555 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2556 if (!pDWP
) return FALSE
;
2557 for (i
= 0, winpos
= pDWP
->winPos
; i
< pDWP
->actualCount
; i
++, winpos
++)
2559 if (!(res
= SetWindowPos32( winpos
->hwnd
, winpos
->hwndInsertAfter
,
2560 winpos
->x
, winpos
->y
, winpos
->cx
,
2561 winpos
->cy
, winpos
->flags
))) break;
2563 USER_HEAP_FREE( hdwp
);
2568 /***********************************************************************
2569 * TileChildWindows (USER.199)
2571 void WINAPI
TileChildWindows( HWND16 parent
, WORD action
)
2573 FIXME(win
, "(%04x, %d): stub\n", parent
, action
);
2576 /***********************************************************************
2577 * CascageChildWindows (USER.198)
2579 void WINAPI
CascadeChildWindows( HWND16 parent
, WORD action
)
2581 FIXME(win
, "(%04x, %d): stub\n", parent
, action
);