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
;
501 /*******************************************************************
502 * WINPOS_GetWinOffset
504 * Calculate the offset between the origin of the two windows. Used
505 * to implement MapWindowPoints.
507 static void WINPOS_GetWinOffset( HWND32 hwndFrom
, HWND32 hwndTo
,
512 offset
->x
= offset
->y
= 0;
513 if (hwndFrom
== hwndTo
) return;
515 /* Translate source window origin to screen coords */
518 if (!(wndPtr
= WIN_FindWndPtr( hwndFrom
)))
520 ERR(win
,"bad hwndFrom = %04x\n",hwndFrom
);
523 while (wndPtr
->parent
)
525 offset
->x
+= wndPtr
->rectClient
.left
;
526 offset
->y
+= wndPtr
->rectClient
.top
;
527 wndPtr
= wndPtr
->parent
;
531 /* Translate origin to destination window coords */
534 if (!(wndPtr
= WIN_FindWndPtr( hwndTo
)))
536 ERR(win
,"bad hwndTo = %04x\n", hwndTo
);
539 while (wndPtr
->parent
)
541 offset
->x
-= wndPtr
->rectClient
.left
;
542 offset
->y
-= wndPtr
->rectClient
.top
;
543 wndPtr
= wndPtr
->parent
;
549 /*******************************************************************
550 * MapWindowPoints16 (USER.258)
552 void WINAPI
MapWindowPoints16( HWND16 hwndFrom
, HWND16 hwndTo
,
553 LPPOINT16 lppt
, UINT16 count
)
557 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
567 /*******************************************************************
568 * MapWindowPoints32 (USER32.386)
570 void WINAPI
MapWindowPoints32( HWND32 hwndFrom
, HWND32 hwndTo
,
571 LPPOINT32 lppt
, UINT32 count
)
575 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
585 /***********************************************************************
586 * IsIconic16 (USER.31)
588 BOOL16 WINAPI
IsIconic16(HWND16 hWnd
)
590 return IsIconic32(hWnd
);
594 /***********************************************************************
595 * IsIconic32 (USER32.345)
597 BOOL32 WINAPI
IsIconic32(HWND32 hWnd
)
599 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
600 if (wndPtr
== NULL
) return FALSE
;
601 return (wndPtr
->dwStyle
& WS_MINIMIZE
) != 0;
605 /***********************************************************************
606 * IsZoomed (USER.272)
608 BOOL16 WINAPI
IsZoomed16(HWND16 hWnd
)
610 return IsZoomed32(hWnd
);
614 /***********************************************************************
615 * IsZoomed (USER32.352)
617 BOOL32 WINAPI
IsZoomed32(HWND32 hWnd
)
619 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
620 if (wndPtr
== NULL
) return FALSE
;
621 return (wndPtr
->dwStyle
& WS_MAXIMIZE
) != 0;
625 /*******************************************************************
626 * GetActiveWindow (USER.60)
628 HWND16 WINAPI
GetActiveWindow16(void)
630 return (HWND16
)hwndActive
;
633 /*******************************************************************
634 * GetActiveWindow (USER32.205)
636 HWND32 WINAPI
GetActiveWindow32(void)
638 return (HWND32
)hwndActive
;
642 /*******************************************************************
645 static BOOL32
WINPOS_CanActivate(WND
* pWnd
)
647 if( pWnd
&& ((pWnd
->dwStyle
& (WS_DISABLED
| WS_VISIBLE
| WS_CHILD
))
648 == WS_VISIBLE
) ) return TRUE
;
653 /*******************************************************************
654 * SetActiveWindow16 (USER.59)
656 HWND16 WINAPI
SetActiveWindow16( HWND16 hwnd
)
658 return SetActiveWindow32(hwnd
);
662 /*******************************************************************
663 * SetActiveWindow32 (USER32.463)
665 HWND32 WINAPI
SetActiveWindow32( HWND32 hwnd
)
667 HWND32 prev
= hwndActive
;
668 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
670 if ( !WINPOS_CanActivate(wndPtr
) ) return 0;
672 WINPOS_SetActiveWindow( hwnd
, 0, 0 );
677 /*******************************************************************
678 * GetForegroundWindow16 (USER.608)
680 HWND16 WINAPI
GetForegroundWindow16(void)
682 return (HWND16
)GetForegroundWindow32();
686 /*******************************************************************
687 * SetForegroundWindow16 (USER.609)
689 BOOL16 WINAPI
SetForegroundWindow16( HWND16 hwnd
)
691 return SetForegroundWindow32( hwnd
);
695 /*******************************************************************
696 * GetForegroundWindow32 (USER32.241)
698 HWND32 WINAPI
GetForegroundWindow32(void)
700 return GetActiveWindow32();
704 /*******************************************************************
705 * SetForegroundWindow32 (USER32.482)
707 BOOL32 WINAPI
SetForegroundWindow32( HWND32 hwnd
)
709 SetActiveWindow32( hwnd
);
714 /*******************************************************************
715 * GetShellWindow16 (USER.600)
717 HWND16 WINAPI
GetShellWindow16(void)
719 return GetShellWindow32();
722 /*******************************************************************
723 * SetShellWindow32 (USER32.504)
725 HWND32 WINAPI
SetShellWindow32(HWND32 hwndshell
)
726 { WARN(win
, "(hWnd=%08x) semi stub\n",hwndshell
);
728 hGlobalShellWindow
= hwndshell
;
729 return hGlobalShellWindow
;
733 /*******************************************************************
734 * GetShellWindow32 (USER32.287)
736 HWND32 WINAPI
GetShellWindow32(void)
737 { WARN(win
, "(hWnd=%x) semi stub\n",hGlobalShellWindow
);
739 return hGlobalShellWindow
;
743 /***********************************************************************
744 * BringWindowToTop16 (USER.45)
746 BOOL16 WINAPI
BringWindowToTop16( HWND16 hwnd
)
748 return BringWindowToTop32(hwnd
);
752 /***********************************************************************
753 * BringWindowToTop32 (USER32.11)
755 BOOL32 WINAPI
BringWindowToTop32( HWND32 hwnd
)
757 return SetWindowPos32( hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
761 /***********************************************************************
762 * MoveWindow16 (USER.56)
764 BOOL16 WINAPI
MoveWindow16( HWND16 hwnd
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
767 return MoveWindow32(hwnd
,x
,y
,cx
,cy
,repaint
);
771 /***********************************************************************
772 * MoveWindow32 (USER32.399)
774 BOOL32 WINAPI
MoveWindow32( HWND32 hwnd
, INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
777 int flags
= SWP_NOZORDER
| SWP_NOACTIVATE
;
778 if (!repaint
) flags
|= SWP_NOREDRAW
;
779 TRACE(win
, "%04x %d,%d %dx%d %d\n",
780 hwnd
, x
, y
, cx
, cy
, repaint
);
781 return SetWindowPos32( hwnd
, 0, x
, y
, cx
, cy
, flags
);
784 /***********************************************************************
785 * WINPOS_InitInternalPos
787 static LPINTERNALPOS
WINPOS_InitInternalPos( WND
* wnd
, POINT32 pt
,
788 LPRECT32 restoreRect
)
790 LPINTERNALPOS lpPos
= (LPINTERNALPOS
) GetProp32A( wnd
->hwndSelf
,
794 /* this happens when the window is minimized/maximized
795 * for the first time (rectWindow is not adjusted yet) */
797 lpPos
= HeapAlloc( SystemHeap
, 0, sizeof(INTERNALPOS
) );
798 if( !lpPos
) return NULL
;
800 SetProp32A( wnd
->hwndSelf
, atomInternalPos
, (HANDLE32
)lpPos
);
801 lpPos
->hwndIconTitle
= 0; /* defer until needs to be shown */
802 CONV_RECT32TO16( &wnd
->rectWindow
, &lpPos
->rectNormal
);
803 *(UINT32
*)&lpPos
->ptIconPos
= *(UINT32
*)&lpPos
->ptMaxPos
= 0xFFFFFFFF;
806 if( wnd
->dwStyle
& WS_MINIMIZE
)
807 CONV_POINT32TO16( &pt
, &lpPos
->ptIconPos
);
808 else if( wnd
->dwStyle
& WS_MAXIMIZE
)
809 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
810 else if( restoreRect
)
811 CONV_RECT32TO16( restoreRect
, &lpPos
->rectNormal
);
816 /***********************************************************************
817 * WINPOS_RedrawIconTitle
819 BOOL32
WINPOS_RedrawIconTitle( HWND32 hWnd
)
821 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)GetProp32A( hWnd
, atomInternalPos
);
824 if( lpPos
->hwndIconTitle
)
826 SendMessage32A( lpPos
->hwndIconTitle
, WM_SHOWWINDOW
, TRUE
, 0);
827 InvalidateRect32( lpPos
->hwndIconTitle
, NULL
, TRUE
);
834 /***********************************************************************
835 * WINPOS_ShowIconTitle
837 BOOL32
WINPOS_ShowIconTitle( WND
* pWnd
, BOOL32 bShow
)
839 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)GetProp32A( pWnd
->hwndSelf
, atomInternalPos
);
841 if( lpPos
&& !(pWnd
->flags
& WIN_MANAGED
))
843 HWND16 hWnd
= lpPos
->hwndIconTitle
;
845 TRACE(win
,"0x%04x %i\n", pWnd
->hwndSelf
, (bShow
!= 0) );
848 lpPos
->hwndIconTitle
= hWnd
= ICONTITLE_Create( pWnd
);
851 pWnd
= WIN_FindWndPtr(hWnd
);
853 if( !(pWnd
->dwStyle
& WS_VISIBLE
) )
855 SendMessage32A( hWnd
, WM_SHOWWINDOW
, TRUE
, 0 );
856 SetWindowPos32( hWnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
857 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_SHOWWINDOW
);
860 else ShowWindow32( hWnd
, SW_HIDE
);
865 /*******************************************************************
866 * WINPOS_GetMinMaxInfo
868 * Get the minimized and maximized information for a window.
870 void WINPOS_GetMinMaxInfo( WND
*wndPtr
, POINT32
*maxSize
, POINT32
*maxPos
,
871 POINT32
*minTrack
, POINT32
*maxTrack
)
877 /* Compute default values */
879 MinMax
.ptMaxSize
.x
= SYSMETRICS_CXSCREEN
;
880 MinMax
.ptMaxSize
.y
= SYSMETRICS_CYSCREEN
;
881 MinMax
.ptMinTrackSize
.x
= SYSMETRICS_CXMINTRACK
;
882 MinMax
.ptMinTrackSize
.y
= SYSMETRICS_CYMINTRACK
;
883 MinMax
.ptMaxTrackSize
.x
= SYSMETRICS_CXSCREEN
;
884 MinMax
.ptMaxTrackSize
.y
= SYSMETRICS_CYSCREEN
;
886 if (wndPtr
->flags
& WIN_MANAGED
) xinc
= yinc
= 0;
887 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
889 xinc
= SYSMETRICS_CXDLGFRAME
;
890 yinc
= SYSMETRICS_CYDLGFRAME
;
895 if (HAS_THICKFRAME(wndPtr
->dwStyle
))
897 xinc
+= SYSMETRICS_CXFRAME
;
898 yinc
+= SYSMETRICS_CYFRAME
;
900 if (wndPtr
->dwStyle
& WS_BORDER
)
902 xinc
+= SYSMETRICS_CXBORDER
;
903 yinc
+= SYSMETRICS_CYBORDER
;
906 MinMax
.ptMaxSize
.x
+= 2 * xinc
;
907 MinMax
.ptMaxSize
.y
+= 2 * yinc
;
909 lpPos
= (LPINTERNALPOS
)GetProp32A( wndPtr
->hwndSelf
, atomInternalPos
);
910 if( lpPos
&& !EMPTYPOINT(lpPos
->ptMaxPos
) )
911 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &MinMax
.ptMaxPosition
);
914 MinMax
.ptMaxPosition
.x
= -xinc
;
915 MinMax
.ptMaxPosition
.y
= -yinc
;
918 SendMessage32A( wndPtr
->hwndSelf
, WM_GETMINMAXINFO
, 0, (LPARAM
)&MinMax
);
920 /* Some sanity checks */
922 TRACE(win
,"%d %d / %d %d / %d %d / %d %d\n",
923 MinMax
.ptMaxSize
.x
, MinMax
.ptMaxSize
.y
,
924 MinMax
.ptMaxPosition
.x
, MinMax
.ptMaxPosition
.y
,
925 MinMax
.ptMaxTrackSize
.x
, MinMax
.ptMaxTrackSize
.y
,
926 MinMax
.ptMinTrackSize
.x
, MinMax
.ptMinTrackSize
.y
);
927 MinMax
.ptMaxTrackSize
.x
= MAX( MinMax
.ptMaxTrackSize
.x
,
928 MinMax
.ptMinTrackSize
.x
);
929 MinMax
.ptMaxTrackSize
.y
= MAX( MinMax
.ptMaxTrackSize
.y
,
930 MinMax
.ptMinTrackSize
.y
);
932 if (maxSize
) *maxSize
= MinMax
.ptMaxSize
;
933 if (maxPos
) *maxPos
= MinMax
.ptMaxPosition
;
934 if (minTrack
) *minTrack
= MinMax
.ptMinTrackSize
;
935 if (maxTrack
) *maxTrack
= MinMax
.ptMaxTrackSize
;
938 /***********************************************************************
941 * Fill in lpRect and return additional flags to be used with SetWindowPos().
942 * This function assumes that 'cmd' is different from the current window
945 UINT16
WINPOS_MinMaximize( WND
* wndPtr
, UINT16 cmd
, LPRECT16 lpRect
)
949 POINT32 size
= { wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
};
950 LPINTERNALPOS lpPos
= WINPOS_InitInternalPos( wndPtr
, size
,
951 &wndPtr
->rectWindow
);
953 TRACE(win
,"0x%04x %u\n", wndPtr
->hwndSelf
, cmd
);
955 if (lpPos
&& !HOOK_CallHooks16(WH_CBT
, HCBT_MINMAX
, wndPtr
->hwndSelf
, cmd
))
957 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
959 if( !SendMessage32A( wndPtr
->hwndSelf
, WM_QUERYOPEN
, 0, 0L ) )
960 return (SWP_NOSIZE
| SWP_NOMOVE
);
961 swpFlags
|= SWP_NOCOPYBITS
;
966 if( wndPtr
->dwStyle
& WS_MAXIMIZE
)
968 wndPtr
->flags
|= WIN_RESTORE_MAX
;
969 wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
972 wndPtr
->flags
&= ~WIN_RESTORE_MAX
;
973 wndPtr
->dwStyle
|= WS_MINIMIZE
;
975 lpPos
->ptIconPos
= WINPOS_FindIconPos( wndPtr
, lpPos
->ptIconPos
);
977 SetRect16( lpRect
, lpPos
->ptIconPos
.x
, lpPos
->ptIconPos
.y
,
978 SYSMETRICS_CXICON
, SYSMETRICS_CYICON
);
979 swpFlags
|= SWP_NOCOPYBITS
;
983 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &pt
);
984 WINPOS_GetMinMaxInfo( wndPtr
, &size
, &pt
, NULL
, NULL
);
985 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
987 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
989 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
990 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
992 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
994 SetRect16( lpRect
, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
,
999 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1001 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
1002 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
1003 if( wndPtr
->flags
& WIN_RESTORE_MAX
)
1005 /* Restore to maximized position */
1006 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &pt
);
1007 WINPOS_GetMinMaxInfo( wndPtr
, &size
, &pt
, NULL
, NULL
);
1008 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
1009 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
1010 SetRect16( lpRect
, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
, size
.x
, size
.y
);
1015 if( !(wndPtr
->dwStyle
& WS_MAXIMIZE
) ) return (UINT16
)(-1);
1016 else wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
1018 /* Restore to normal position */
1020 *lpRect
= lpPos
->rectNormal
;
1021 lpRect
->right
-= lpRect
->left
;
1022 lpRect
->bottom
-= lpRect
->top
;
1026 } else swpFlags
|= SWP_NOSIZE
| SWP_NOMOVE
;
1030 /***********************************************************************
1031 * ShowWindowAsync32 (USER32.535)
1033 * doesn't wait; returns immediately.
1034 * used by threads to toggle windows in other (possibly hanging) threads
1036 BOOL32 WINAPI
ShowWindowAsync32( HWND32 hwnd
, INT32 cmd
)
1038 /* FIXME: does ShowWindow32() return immediately ? */
1039 return ShowWindow32(hwnd
, cmd
);
1043 /***********************************************************************
1044 * ShowWindow16 (USER.42)
1046 BOOL16 WINAPI
ShowWindow16( HWND16 hwnd
, INT16 cmd
)
1048 return ShowWindow32(hwnd
,cmd
);
1052 /***********************************************************************
1053 * ShowWindow32 (USER32.534)
1055 BOOL32 WINAPI
ShowWindow32( HWND32 hwnd
, INT32 cmd
)
1057 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1058 BOOL32 wasVisible
, showFlag
;
1059 RECT16 newPos
= {0, 0, 0, 0};
1062 if (!wndPtr
) return FALSE
;
1064 TRACE(win
,"hwnd=%04x, cmd=%d\n", hwnd
, cmd
);
1066 wasVisible
= (wndPtr
->dwStyle
& WS_VISIBLE
) != 0;
1071 if (!wasVisible
) return FALSE
;
1072 swp
|= SWP_HIDEWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
|
1073 SWP_NOACTIVATE
| SWP_NOZORDER
;
1076 case SW_SHOWMINNOACTIVE
:
1077 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1079 case SW_SHOWMINIMIZED
:
1080 swp
|= SWP_SHOWWINDOW
;
1083 swp
|= SWP_FRAMECHANGED
;
1084 if( !(wndPtr
->dwStyle
& WS_MINIMIZE
) )
1085 swp
|= WINPOS_MinMaximize( wndPtr
, SW_MINIMIZE
, &newPos
);
1086 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1089 case SW_SHOWMAXIMIZED
: /* same as SW_MAXIMIZE */
1090 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
1091 if( !(wndPtr
->dwStyle
& WS_MAXIMIZE
) )
1092 swp
|= WINPOS_MinMaximize( wndPtr
, SW_MAXIMIZE
, &newPos
);
1093 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1097 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1100 swp
|= SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
;
1103 case SW_SHOWNOACTIVATE
:
1104 swp
|= SWP_NOZORDER
;
1105 if (GetActiveWindow32()) swp
|= SWP_NOACTIVATE
;
1107 case SW_SHOWNORMAL
: /* same as SW_NORMAL: */
1108 case SW_SHOWDEFAULT
: /* FIXME: should have its own handler */
1110 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
1112 if( wndPtr
->dwStyle
& (WS_MINIMIZE
| WS_MAXIMIZE
) )
1113 swp
|= WINPOS_MinMaximize( wndPtr
, SW_RESTORE
, &newPos
);
1114 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1118 showFlag
= (cmd
!= SW_HIDE
);
1119 if (showFlag
!= wasVisible
)
1121 SendMessage32A( hwnd
, WM_SHOWWINDOW
, showFlag
, 0 );
1122 if (!IsWindow32( hwnd
)) return wasVisible
;
1125 if ((wndPtr
->dwStyle
& WS_CHILD
) &&
1126 !IsWindowVisible32( wndPtr
->parent
->hwndSelf
) &&
1127 (swp
& (SWP_NOSIZE
| SWP_NOMOVE
)) == (SWP_NOSIZE
| SWP_NOMOVE
) )
1129 /* Don't call SetWindowPos32() on invisible child windows */
1130 if (cmd
== SW_HIDE
) wndPtr
->dwStyle
&= ~WS_VISIBLE
;
1131 else wndPtr
->dwStyle
|= WS_VISIBLE
;
1135 /* We can't activate a child window */
1136 if (wndPtr
->dwStyle
& WS_CHILD
) swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1137 SetWindowPos32( hwnd
, HWND_TOP
,
1138 newPos
.left
, newPos
.top
, newPos
.right
, newPos
.bottom
, swp
);
1139 if (!IsWindow32( hwnd
)) return wasVisible
;
1140 else if( wndPtr
->dwStyle
& WS_MINIMIZE
) WINPOS_ShowIconTitle( wndPtr
, TRUE
);
1143 if (wndPtr
->flags
& WIN_NEED_SIZE
)
1145 /* should happen only in CreateWindowEx() */
1146 int wParam
= SIZE_RESTORED
;
1148 wndPtr
->flags
&= ~WIN_NEED_SIZE
;
1149 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wParam
= SIZE_MAXIMIZED
;
1150 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= SIZE_MINIMIZED
;
1151 SendMessage32A( hwnd
, WM_SIZE
, wParam
,
1152 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
1153 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
1154 SendMessage32A( hwnd
, WM_MOVE
, 0,
1155 MAKELONG(wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
) );
1162 /***********************************************************************
1163 * GetInternalWindowPos16 (USER.460)
1165 UINT16 WINAPI
GetInternalWindowPos16( HWND16 hwnd
, LPRECT16 rectWnd
,
1168 WINDOWPLACEMENT16 wndpl
;
1169 if (GetWindowPlacement16( hwnd
, &wndpl
))
1171 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1172 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1173 return wndpl
.showCmd
;
1179 /***********************************************************************
1180 * GetInternalWindowPos32 (USER32.245)
1182 UINT32 WINAPI
GetInternalWindowPos32( HWND32 hwnd
, LPRECT32 rectWnd
,
1185 WINDOWPLACEMENT32 wndpl
;
1186 if (GetWindowPlacement32( hwnd
, &wndpl
))
1188 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1189 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1190 return wndpl
.showCmd
;
1195 /***********************************************************************
1196 * GetWindowPlacement16 (USER.370)
1198 BOOL16 WINAPI
GetWindowPlacement16( HWND16 hwnd
, WINDOWPLACEMENT16
*wndpl
)
1200 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
1203 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)WINPOS_InitInternalPos( pWnd
,
1204 *(LPPOINT32
)&pWnd
->rectWindow
.left
, &pWnd
->rectWindow
);
1205 wndpl
->length
= sizeof(*wndpl
);
1206 if( pWnd
->dwStyle
& WS_MINIMIZE
)
1207 wndpl
->showCmd
= SW_SHOWMINIMIZED
;
1209 wndpl
->showCmd
= ( pWnd
->dwStyle
& WS_MAXIMIZE
)
1210 ? SW_SHOWMAXIMIZED
: SW_SHOWNORMAL
;
1211 if( pWnd
->flags
& WIN_RESTORE_MAX
)
1212 wndpl
->flags
= WPF_RESTORETOMAXIMIZED
;
1215 wndpl
->ptMinPosition
= lpPos
->ptIconPos
;
1216 wndpl
->ptMaxPosition
= lpPos
->ptMaxPos
;
1217 wndpl
->rcNormalPosition
= lpPos
->rectNormal
;
1224 /***********************************************************************
1225 * GetWindowPlacement32 (USER32.307)
1227 BOOL32 WINAPI
GetWindowPlacement32( HWND32 hwnd
, WINDOWPLACEMENT32
*pwpl32
)
1231 WINDOWPLACEMENT16 wpl
;
1232 wpl
.length
= sizeof(wpl
);
1233 if( GetWindowPlacement16( hwnd
, &wpl
) )
1235 pwpl32
->length
= sizeof(*pwpl32
);
1236 pwpl32
->flags
= wpl
.flags
;
1237 pwpl32
->showCmd
= wpl
.showCmd
;
1238 CONV_POINT16TO32( &wpl
.ptMinPosition
, &pwpl32
->ptMinPosition
);
1239 CONV_POINT16TO32( &wpl
.ptMaxPosition
, &pwpl32
->ptMaxPosition
);
1240 CONV_RECT16TO32( &wpl
.rcNormalPosition
, &pwpl32
->rcNormalPosition
);
1248 /***********************************************************************
1249 * WINPOS_SetPlacement
1251 static BOOL32
WINPOS_SetPlacement( HWND32 hwnd
, const WINDOWPLACEMENT16
*wndpl
,
1254 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
1257 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)WINPOS_InitInternalPos( pWnd
,
1258 *(LPPOINT32
)&pWnd
->rectWindow
.left
, &pWnd
->rectWindow
);
1260 if( flags
& PLACE_MIN
) lpPos
->ptIconPos
= wndpl
->ptMinPosition
;
1261 if( flags
& PLACE_MAX
) lpPos
->ptMaxPos
= wndpl
->ptMaxPosition
;
1262 if( flags
& PLACE_RECT
) lpPos
->rectNormal
= wndpl
->rcNormalPosition
;
1264 if( pWnd
->dwStyle
& WS_MINIMIZE
)
1266 WINPOS_ShowIconTitle( pWnd
, FALSE
);
1267 if( wndpl
->flags
& WPF_SETMINPOSITION
&& !EMPTYPOINT(lpPos
->ptIconPos
))
1268 SetWindowPos32( hwnd
, 0, lpPos
->ptIconPos
.x
, lpPos
->ptIconPos
.y
,
1269 0, 0, SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1271 else if( pWnd
->dwStyle
& WS_MAXIMIZE
)
1273 if( !EMPTYPOINT(lpPos
->ptMaxPos
) )
1274 SetWindowPos32( hwnd
, 0, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
,
1275 0, 0, SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1277 else if( flags
& PLACE_RECT
)
1278 SetWindowPos32( hwnd
, 0, lpPos
->rectNormal
.left
, lpPos
->rectNormal
.top
,
1279 lpPos
->rectNormal
.right
- lpPos
->rectNormal
.left
,
1280 lpPos
->rectNormal
.bottom
- lpPos
->rectNormal
.top
,
1281 SWP_NOZORDER
| SWP_NOACTIVATE
);
1283 ShowWindow32( hwnd
, wndpl
->showCmd
);
1284 if( IsWindow32(hwnd
) && pWnd
->dwStyle
& WS_MINIMIZE
)
1286 if( pWnd
->dwStyle
& WS_VISIBLE
) WINPOS_ShowIconTitle( pWnd
, TRUE
);
1288 /* SDK: ...valid only the next time... */
1289 if( wndpl
->flags
& WPF_RESTORETOMAXIMIZED
) pWnd
->flags
|= WIN_RESTORE_MAX
;
1297 /***********************************************************************
1298 * SetWindowPlacement16 (USER.371)
1300 BOOL16 WINAPI
SetWindowPlacement16(HWND16 hwnd
, const WINDOWPLACEMENT16
*wndpl
)
1302 return WINPOS_SetPlacement( hwnd
, wndpl
,
1303 PLACE_MIN
| PLACE_MAX
| PLACE_RECT
);
1306 /***********************************************************************
1307 * SetWindowPlacement32 (USER32.519)
1309 BOOL32 WINAPI
SetWindowPlacement32( HWND32 hwnd
, const WINDOWPLACEMENT32
*pwpl32
)
1313 WINDOWPLACEMENT16 wpl
= { sizeof(WINDOWPLACEMENT16
),
1314 pwpl32
->flags
, pwpl32
->showCmd
, { pwpl32
->ptMinPosition
.x
,
1315 pwpl32
->ptMinPosition
.y
}, { pwpl32
->ptMaxPosition
.x
,
1316 pwpl32
->ptMaxPosition
.y
}, { pwpl32
->rcNormalPosition
.left
,
1317 pwpl32
->rcNormalPosition
.top
, pwpl32
->rcNormalPosition
.right
,
1318 pwpl32
->rcNormalPosition
.bottom
} };
1320 return WINPOS_SetPlacement( hwnd
, &wpl
, PLACE_MIN
| PLACE_MAX
| PLACE_RECT
);
1326 /***********************************************************************
1327 * SetInternalWindowPos16 (USER.461)
1329 void WINAPI
SetInternalWindowPos16( HWND16 hwnd
, UINT16 showCmd
,
1330 LPRECT16 rect
, LPPOINT16 pt
)
1332 if( IsWindow16(hwnd
) )
1334 WINDOWPLACEMENT16 wndpl
;
1337 wndpl
.length
= sizeof(wndpl
);
1338 wndpl
.showCmd
= showCmd
;
1339 wndpl
.flags
= flags
= 0;
1344 wndpl
.flags
|= WPF_SETMINPOSITION
;
1345 wndpl
.ptMinPosition
= *pt
;
1349 flags
|= PLACE_RECT
;
1350 wndpl
.rcNormalPosition
= *rect
;
1352 WINPOS_SetPlacement( hwnd
, &wndpl
, flags
);
1357 /***********************************************************************
1358 * SetInternalWindowPos32 (USER32.483)
1360 void WINAPI
SetInternalWindowPos32( HWND32 hwnd
, UINT32 showCmd
,
1361 LPRECT32 rect
, LPPOINT32 pt
)
1363 if( IsWindow32(hwnd
) )
1365 WINDOWPLACEMENT16 wndpl
;
1368 wndpl
.length
= sizeof(wndpl
);
1369 wndpl
.showCmd
= showCmd
;
1370 wndpl
.flags
= flags
= 0;
1375 wndpl
.flags
|= WPF_SETMINPOSITION
;
1376 CONV_POINT32TO16( pt
, &wndpl
.ptMinPosition
);
1380 flags
|= PLACE_RECT
;
1381 CONV_RECT32TO16( rect
, &wndpl
.rcNormalPosition
);
1383 WINPOS_SetPlacement( hwnd
, &wndpl
, flags
);
1388 /***********************************************************************
1389 * WINPOS_ForceXWindowRaise
1391 * Raise a window on top of the X stacking order, while preserving
1392 * the correct Windows Z order.
1394 static void WINPOS_ForceXWindowRaise( WND
* pWnd
)
1396 XWindowChanges winChanges
;
1399 /* Raise all windows up to pWnd according to their Z order.
1400 * (it would be easier with sibling-related Below but it doesn't
1401 * work very well with SGI mwm for instance)
1403 winChanges
.stack_mode
= Above
;
1406 if (pWnd
->window
) TSXReconfigureWMWindow( display
, pWnd
->window
, 0,
1407 CWStackMode
, &winChanges
);
1408 wndPrev
= WIN_GetDesktop()->child
;
1409 if (wndPrev
== pWnd
) break;
1410 while (wndPrev
&& (wndPrev
->next
!= pWnd
)) wndPrev
= wndPrev
->next
;
1416 /*******************************************************************
1417 * WINPOS_SetActiveWindow
1419 * SetActiveWindow() back-end. This is the only function that
1420 * can assign active status to a window. It must be called only
1421 * for the top level windows.
1423 BOOL32
WINPOS_SetActiveWindow( HWND32 hWnd
, BOOL32 fMouse
, BOOL32 fChangeFocus
)
1425 CBTACTIVATESTRUCT16
* cbtStruct
;
1426 WND
* wndPtr
, *wndTemp
;
1427 HQUEUE16 hOldActiveQueue
, hNewActiveQueue
;
1430 /* paranoid checks */
1431 if( hWnd
== GetDesktopWindow32() || hWnd
== hwndActive
) return 0;
1433 /* if (wndPtr && (GetTaskQueue(0) != wndPtr->hmemTaskQ))
1436 wndPtr
= WIN_FindWndPtr(hWnd
);
1437 hOldActiveQueue
= (pActiveQueue
)?pActiveQueue
->self
: 0;
1439 if( (wndTemp
= WIN_FindWndPtr(hwndActive
)) )
1440 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1442 TRACE(win
,"no current active window.\n");
1444 /* call CBT hook chain */
1445 if ((cbtStruct
= SEGPTR_NEW(CBTACTIVATESTRUCT16
)))
1448 cbtStruct
->fMouse
= fMouse
;
1449 cbtStruct
->hWndActive
= hwndActive
;
1450 wRet
= HOOK_CallHooks16( WH_CBT
, HCBT_ACTIVATE
, (WPARAM16
)hWnd
,
1451 (LPARAM
)SEGPTR_GET(cbtStruct
) );
1452 SEGPTR_FREE(cbtStruct
);
1453 if (wRet
) return wRet
;
1456 /* set prev active wnd to current active wnd and send notification */
1457 if ((hwndPrevActive
= hwndActive
) && IsWindow32(hwndPrevActive
))
1459 if (!SendMessage32A( hwndPrevActive
, WM_NCACTIVATE
, FALSE
, 0 ))
1461 if (GetSysModalWindow16() != hWnd
) return 0;
1462 /* disregard refusal if hWnd is sysmodal */
1466 SendMessage32A( hwndPrevActive
, WM_ACTIVATE
,
1467 MAKEWPARAM( WA_INACTIVE
, wIconized
),
1470 /* FIXME: must be SendMessage16() because 32A doesn't do
1471 * intertask at this time */
1472 SendMessage16( hwndPrevActive
, WM_ACTIVATE
, WA_INACTIVE
,
1473 MAKELPARAM( (HWND16
)hWnd
, wIconized
) );
1476 /* check if something happened during message processing */
1477 if( hwndPrevActive
!= hwndActive
) return 0;
1480 /* set active wnd */
1483 /* send palette messages */
1484 if (hWnd
&& SendMessage16( hWnd
, WM_QUERYNEWPALETTE
, 0, 0L))
1485 SendMessage16((HWND16
)-1, WM_PALETTEISCHANGING
, (WPARAM16
)hWnd
, 0L );
1487 /* if prev wnd is minimized redraw icon title */
1488 if( IsIconic32( hwndPrevActive
) ) WINPOS_RedrawIconTitle(hwndPrevActive
);
1490 /* managed windows will get ConfigureNotify event */
1491 if (wndPtr
&& !(wndPtr
->dwStyle
& WS_CHILD
) && !(wndPtr
->flags
& WIN_MANAGED
))
1493 /* check Z-order and bring hWnd to the top */
1494 for (wndTemp
= WIN_GetDesktop()->child
; wndTemp
; wndTemp
= wndTemp
->next
)
1495 if (wndTemp
->dwStyle
& WS_VISIBLE
) break;
1497 if( wndTemp
!= wndPtr
)
1498 SetWindowPos32(hWnd
, HWND_TOP
, 0,0,0,0,
1499 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1500 if (!IsWindow32(hWnd
)) return 0;
1503 hNewActiveQueue
= wndPtr
? wndPtr
->hmemTaskQ
: 0;
1505 /* send WM_ACTIVATEAPP if necessary */
1506 if (hOldActiveQueue
!= hNewActiveQueue
)
1508 WND
**list
, **ppWnd
;
1510 if ((list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1512 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1514 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
1516 if ((*ppWnd
)->hmemTaskQ
== hOldActiveQueue
)
1517 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1518 0, QUEUE_GetQueueTask(hNewActiveQueue
) );
1520 HeapFree( SystemHeap
, 0, list
);
1523 pActiveQueue
= (hNewActiveQueue
)
1524 ? (MESSAGEQUEUE
*) GlobalLock16(hNewActiveQueue
) : NULL
;
1526 if ((list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1528 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1530 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
1532 if ((*ppWnd
)->hmemTaskQ
== hNewActiveQueue
)
1533 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1534 1, QUEUE_GetQueueTask( hOldActiveQueue
) );
1536 HeapFree( SystemHeap
, 0, list
);
1538 if (!IsWindow32(hWnd
)) return 0;
1543 /* walk up to the first unowned window */
1545 while (wndTemp
->owner
) wndTemp
= wndTemp
->owner
;
1546 /* and set last active owned popup */
1547 wndTemp
->hwndLastActive
= hWnd
;
1549 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1550 SendMessage32A( hWnd
, WM_NCACTIVATE
, TRUE
, 0 );
1552 SendMessage32A( hWnd
, WM_ACTIVATE
,
1553 MAKEWPARAM( (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
, wIconized
),
1554 (LPARAM
)hwndPrevActive
);
1556 SendMessage16(hWnd
, WM_ACTIVATE
, (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
,
1557 MAKELPARAM( (HWND16
)hwndPrevActive
, wIconized
) );
1560 if( !IsWindow32(hWnd
) ) return 0;
1563 /* change focus if possible */
1564 if( fChangeFocus
&& GetFocus32() )
1565 if( WIN_GetTopParent(GetFocus32()) != hwndActive
)
1566 FOCUS_SwitchFocus( GetFocus32(),
1567 (wndPtr
&& (wndPtr
->dwStyle
& WS_MINIMIZE
))?
1572 if( !hwndPrevActive
&& wndPtr
&&
1573 wndPtr
->window
&& !(wndPtr
->flags
& WIN_MANAGED
) )
1574 WINPOS_ForceXWindowRaise(wndPtr
);
1576 /* if active wnd is minimized redraw icon title */
1577 if( IsIconic32(hwndActive
) ) WINPOS_RedrawIconTitle(hwndActive
);
1579 return (hWnd
== hwndActive
);
1582 /*******************************************************************
1583 * WINPOS_ActivateOtherWindow
1585 * Activates window other than pWnd.
1587 BOOL32
WINPOS_ActivateOtherWindow(WND
* pWnd
)
1592 if( pWnd
->hwndSelf
== hwndPrevActive
)
1595 if( hwndActive
!= pWnd
->hwndSelf
&&
1596 ( hwndActive
|| QUEUE_IsExitingQueue(pWnd
->hmemTaskQ
)) )
1599 if( !(pWnd
->dwStyle
& WS_POPUP
) || !(pWnd
->owner
) ||
1600 !WINPOS_CanActivate((pWndTo
= WIN_GetTopParentPtr(pWnd
->owner
))) )
1602 WND
* pWndPtr
= WIN_GetTopParentPtr(pWnd
);
1604 pWndTo
= WIN_FindWndPtr(hwndPrevActive
);
1606 while( !WINPOS_CanActivate(pWndTo
) )
1608 /* by now owned windows should've been taken care of */
1610 pWndTo
= pWndPtr
->next
;
1612 if( !pWndTo
) break;
1616 bRet
= WINPOS_SetActiveWindow( pWndTo
? pWndTo
->hwndSelf
: 0, FALSE
, TRUE
);
1618 /* switch desktop queue to current active */
1619 if( pWndTo
) WIN_GetDesktop()->hmemTaskQ
= pWndTo
->hmemTaskQ
;
1625 /*******************************************************************
1626 * WINPOS_ChangeActiveWindow
1629 BOOL32
WINPOS_ChangeActiveWindow( HWND32 hWnd
, BOOL32 mouseMsg
)
1631 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
1633 if (!hWnd
) return WINPOS_SetActiveWindow( 0, mouseMsg
, TRUE
);
1635 if( !wndPtr
) return FALSE
;
1637 /* child windows get WM_CHILDACTIVATE message */
1638 if( (wndPtr
->dwStyle
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
1639 return SendMessage32A(hWnd
, WM_CHILDACTIVATE
, 0, 0L);
1641 /* owned popups imply owner activation - not sure */
1642 if ((wndPtr
->dwStyle
& WS_POPUP
) && wndPtr
->owner
&&
1643 (wndPtr
->owner
->dwStyle
& WS_VISIBLE
) &&
1644 !(wndPtr
->owner
->dwStyle
& WS_DISABLED
))
1646 if (!(wndPtr
= wndPtr
->owner
)) return FALSE
;
1647 hWnd
= wndPtr
->hwndSelf
;
1650 if( hWnd
== hwndActive
) return FALSE
;
1652 if( !WINPOS_SetActiveWindow(hWnd
,mouseMsg
,TRUE
) )
1655 /* switch desktop queue to current active */
1656 if( wndPtr
->parent
== WIN_GetDesktop())
1657 WIN_GetDesktop()->hmemTaskQ
= wndPtr
->hmemTaskQ
;
1663 /***********************************************************************
1664 * WINPOS_SendNCCalcSize
1666 * Send a WM_NCCALCSIZE message to a window.
1667 * All parameters are read-only except newClientRect.
1668 * oldWindowRect, oldClientRect and winpos must be non-NULL only
1669 * when calcValidRect is TRUE.
1671 LONG
WINPOS_SendNCCalcSize( HWND32 hwnd
, BOOL32 calcValidRect
,
1672 RECT32
*newWindowRect
, RECT32
*oldWindowRect
,
1673 RECT32
*oldClientRect
, WINDOWPOS32
*winpos
,
1674 RECT32
*newClientRect
)
1676 NCCALCSIZE_PARAMS32 params
;
1677 WINDOWPOS32 winposCopy
;
1680 params
.rgrc
[0] = *newWindowRect
;
1683 winposCopy
= *winpos
;
1684 params
.rgrc
[1] = *oldWindowRect
;
1685 params
.rgrc
[2] = *oldClientRect
;
1686 params
.lppos
= &winposCopy
;
1688 result
= SendMessage32A( hwnd
, WM_NCCALCSIZE
, calcValidRect
,
1690 TRACE(win
, "%d,%d-%d,%d\n",
1691 params
.rgrc
[0].left
, params
.rgrc
[0].top
,
1692 params
.rgrc
[0].right
, params
.rgrc
[0].bottom
);
1693 *newClientRect
= params
.rgrc
[0];
1698 /***********************************************************************
1699 * WINPOS_HandleWindowPosChanging16
1701 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1703 LONG
WINPOS_HandleWindowPosChanging16( WND
*wndPtr
, WINDOWPOS16
*winpos
)
1705 POINT32 maxSize
, minTrack
;
1706 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1707 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1708 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1710 WINPOS_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, &minTrack
, NULL
);
1711 if (maxSize
.x
< winpos
->cx
) winpos
->cx
= maxSize
.x
;
1712 if (maxSize
.y
< winpos
->cy
) winpos
->cy
= maxSize
.y
;
1713 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
1715 if (winpos
->cx
< minTrack
.x
) winpos
->cx
= minTrack
.x
;
1716 if (winpos
->cy
< minTrack
.y
) winpos
->cy
= minTrack
.y
;
1723 /***********************************************************************
1724 * WINPOS_HandleWindowPosChanging32
1726 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1728 LONG
WINPOS_HandleWindowPosChanging32( WND
*wndPtr
, WINDOWPOS32
*winpos
)
1731 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1732 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1733 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1735 WINPOS_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, NULL
, NULL
);
1736 winpos
->cx
= MIN( winpos
->cx
, maxSize
.x
);
1737 winpos
->cy
= MIN( winpos
->cy
, maxSize
.y
);
1743 /***********************************************************************
1744 * WINPOS_MoveWindowZOrder
1746 * Move a window in Z order, invalidating everything that needs it.
1747 * Only necessary for windows without associated X window.
1749 static void WINPOS_MoveWindowZOrder( HWND32 hwnd
, HWND32 hwndAfter
)
1752 WND
*pWndAfter
, *pWndCur
, *wndPtr
= WIN_FindWndPtr( hwnd
);
1754 /* We have two possible cases:
1755 * - The window is moving up: we have to invalidate all areas
1756 * of the window that were covered by other windows
1757 * - The window is moving down: we have to invalidate areas
1758 * of other windows covered by this one.
1761 if (hwndAfter
== HWND_TOP
)
1765 else if (hwndAfter
== HWND_BOTTOM
)
1767 if (!wndPtr
->next
) return; /* Already at the bottom */
1772 if (!(pWndAfter
= WIN_FindWndPtr( hwndAfter
))) return;
1773 if (wndPtr
->next
== pWndAfter
) return; /* Already placed right */
1775 /* Determine which window we encounter first in Z-order */
1776 pWndCur
= wndPtr
->parent
->child
;
1777 while ((pWndCur
!= wndPtr
) && (pWndCur
!= pWndAfter
))
1778 pWndCur
= pWndCur
->next
;
1779 movingUp
= (pWndCur
== pWndAfter
);
1784 WND
*pWndPrevAfter
= wndPtr
->next
;
1785 WIN_UnlinkWindow( hwnd
);
1786 WIN_LinkWindow( hwnd
, hwndAfter
);
1787 pWndCur
= wndPtr
->next
;
1788 while (pWndCur
!= pWndPrevAfter
)
1790 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1791 pWndCur
->rectWindow
.top
,
1792 pWndCur
->rectWindow
.right
,
1793 pWndCur
->rectWindow
.bottom
};
1794 OffsetRect32( &rect
, -wndPtr
->rectClient
.left
,
1795 -wndPtr
->rectClient
.top
);
1796 PAINT_RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
1797 RDW_FRAME
| RDW_ERASE
, 0 );
1798 pWndCur
= pWndCur
->next
;
1801 else /* Moving down */
1803 pWndCur
= wndPtr
->next
;
1804 WIN_UnlinkWindow( hwnd
);
1805 WIN_LinkWindow( hwnd
, hwndAfter
);
1806 while (pWndCur
!= wndPtr
)
1808 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1809 pWndCur
->rectWindow
.top
,
1810 pWndCur
->rectWindow
.right
,
1811 pWndCur
->rectWindow
.bottom
};
1812 OffsetRect32( &rect
, -pWndCur
->rectClient
.left
,
1813 -pWndCur
->rectClient
.top
);
1814 PAINT_RedrawWindow( pWndCur
->hwndSelf
, &rect
, 0, RDW_INVALIDATE
|
1815 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
1816 pWndCur
= pWndCur
->next
;
1821 /***********************************************************************
1822 * WINPOS_ReorderOwnedPopups
1824 * fix Z order taking into account owned popups -
1825 * basically we need to maintain them above the window that owns them
1827 HWND32
WINPOS_ReorderOwnedPopups(HWND32 hwndInsertAfter
,WND
* wndPtr
,WORD flags
)
1829 WND
* w
= WIN_GetDesktop()->child
;
1831 if( wndPtr
->dwStyle
& WS_POPUP
&& wndPtr
->owner
)
1833 /* implement "local z-order" between the top and owner window */
1835 HWND32 hwndLocalPrev
= HWND_TOP
;
1837 if( hwndInsertAfter
!= HWND_TOP
)
1839 while( w
!= wndPtr
->owner
)
1841 if (w
!= wndPtr
) hwndLocalPrev
= w
->hwndSelf
;
1842 if( hwndLocalPrev
== hwndInsertAfter
) break;
1845 hwndInsertAfter
= hwndLocalPrev
;
1849 else if( wndPtr
->dwStyle
& WS_CHILD
) return hwndInsertAfter
;
1851 w
= WIN_GetDesktop()->child
;
1854 if( w
== wndPtr
) break;
1856 if( w
->dwStyle
& WS_POPUP
&& w
->owner
== wndPtr
)
1858 SetWindowPos32(w
->hwndSelf
, hwndInsertAfter
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
|
1859 SWP_NOACTIVATE
| SWP_NOSENDCHANGING
| SWP_DEFERERASE
);
1860 hwndInsertAfter
= w
->hwndSelf
;
1865 return hwndInsertAfter
;
1868 /***********************************************************************
1869 * WINPOS_SizeMoveClean
1871 * Make window look nice without excessive repainting
1875 * visible regions are in window coordinates
1876 * update regions are in window client coordinates
1877 * client and window rectangles are in parent client coordinates
1879 * FIXME: Move visible and update regions to the same coordinate system
1880 * (either parent client or window). This is a lot of work though.
1882 static UINT32
WINPOS_SizeMoveClean( WND
* Wnd
, HRGN32 oldVisRgn
,
1883 LPRECT32 lpOldWndRect
,
1884 LPRECT32 lpOldClientRect
, UINT32 uFlags
)
1886 HRGN32 newVisRgn
= DCE_GetVisRgn(Wnd
->hwndSelf
,DCX_WINDOW
| DCX_CLIPSIBLINGS
);
1887 HRGN32 dirtyRgn
= CreateRectRgn32(0,0,0,0);
1890 TRACE(win
,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n",
1891 Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
,
1892 Wnd
->rectWindow
.right
, Wnd
->rectWindow
.bottom
,
1893 lpOldWndRect
->left
, lpOldWndRect
->top
,
1894 lpOldWndRect
->right
, lpOldWndRect
->bottom
);
1895 TRACE(win
,"\tnew client=(%i %i-%i %i) old client=(%i %i-%i %i)\n",
1896 Wnd
->rectClient
.left
, Wnd
->rectClient
.top
,
1897 Wnd
->rectClient
.right
, Wnd
->rectClient
.bottom
,
1898 lpOldClientRect
->left
, lpOldClientRect
->top
,
1899 lpOldClientRect
->right
,lpOldClientRect
->bottom
);
1901 if( (lpOldWndRect
->right
- lpOldWndRect
->left
) != (Wnd
->rectWindow
.right
- Wnd
->rectWindow
.left
) ||
1902 (lpOldWndRect
->bottom
- lpOldWndRect
->top
) != (Wnd
->rectWindow
.bottom
- Wnd
->rectWindow
.top
) )
1903 uFlags
|= SMC_DRAWFRAME
;
1905 CombineRgn32( dirtyRgn
, newVisRgn
, 0, RGN_COPY
);
1907 if( !(uFlags
& SMC_NOCOPY
) )
1908 CombineRgn32( newVisRgn
, newVisRgn
, oldVisRgn
, RGN_AND
);
1910 /* map regions to the parent client area */
1912 OffsetRgn32( dirtyRgn
, Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
);
1913 OffsetRgn32( oldVisRgn
, lpOldWndRect
->left
, lpOldWndRect
->top
);
1915 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1917 other
= CombineRgn32(dirtyRgn
, oldVisRgn
, dirtyRgn
, RGN_DIFF
);
1919 /* map visible region to the Wnd client area */
1921 OffsetRgn32( newVisRgn
, Wnd
->rectWindow
.left
- Wnd
->rectClient
.left
,
1922 Wnd
->rectWindow
.top
- Wnd
->rectClient
.top
);
1924 /* substract previously invalidated region from the Wnd visible region */
1926 my
= (Wnd
->hrgnUpdate
> 1) ? CombineRgn32( newVisRgn
, newVisRgn
,
1927 Wnd
->hrgnUpdate
, RGN_DIFF
)
1930 if( uFlags
& SMC_NOCOPY
) /* invalidate Wnd visible region */
1932 if (my
!= NULLREGION
)
1933 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, newVisRgn
, RDW_INVALIDATE
|
1934 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1935 else if(uFlags
& SMC_DRAWFRAME
)
1936 Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1938 else /* bitblt old client area */
1943 int xfrom
,yfrom
,xto
,yto
,width
,height
;
1945 if( uFlags
& SMC_DRAWFRAME
)
1947 /* copy only client area, frame will be redrawn anyway */
1949 xfrom
= lpOldClientRect
->left
; yfrom
= lpOldClientRect
->top
;
1950 xto
= Wnd
->rectClient
.left
; yto
= Wnd
->rectClient
.top
;
1951 width
= lpOldClientRect
->right
- xfrom
; height
= lpOldClientRect
->bottom
- yfrom
;
1952 updateRgn
= CreateRectRgn32( 0, 0, width
, height
);
1953 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1954 SetRectRgn32( updateRgn
, 0, 0, Wnd
->rectClient
.right
- xto
,
1955 Wnd
->rectClient
.bottom
- yto
);
1959 xfrom
= lpOldWndRect
->left
; yfrom
= lpOldWndRect
->top
;
1960 xto
= Wnd
->rectWindow
.left
; yto
= Wnd
->rectWindow
.top
;
1961 width
= lpOldWndRect
->right
- xfrom
; height
= lpOldWndRect
->bottom
- yfrom
;
1962 updateRgn
= CreateRectRgn32( xto
- Wnd
->rectClient
.left
,
1963 yto
- Wnd
->rectClient
.top
,
1964 Wnd
->rectWindow
.right
- Wnd
->rectClient
.left
,
1965 Wnd
->rectWindow
.bottom
- Wnd
->rectClient
.top
);
1968 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1970 /* substract new visRgn from target rect to get a region that won't be copied */
1972 update
= CombineRgn32( updateRgn
, updateRgn
, newVisRgn
, RGN_DIFF
);
1974 /* Blt valid bits using parent window DC */
1976 if( my
!= NULLREGION
&& (xfrom
!= xto
|| yfrom
!= yto
) )
1979 /* compute clipping region in parent client coordinates */
1981 OffsetRgn32( newVisRgn
, Wnd
->rectClient
.left
, Wnd
->rectClient
.top
);
1982 CombineRgn32( oldVisRgn
, oldVisRgn
, newVisRgn
, RGN_OR
);
1984 hDC
= GetDCEx32( Wnd
->parent
->hwndSelf
, oldVisRgn
,
1985 DCX_KEEPCLIPRGN
| DCX_INTERSECTRGN
|
1986 DCX_CACHE
| DCX_CLIPSIBLINGS
);
1988 BitBlt32( hDC
, xto
, yto
, width
, height
, hDC
, xfrom
, yfrom
, SRCCOPY
);
1989 ReleaseDC32( Wnd
->parent
->hwndSelf
, hDC
);
1992 if( update
!= NULLREGION
)
1993 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, updateRgn
, RDW_INVALIDATE
|
1994 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1995 else if( uFlags
& SMC_DRAWFRAME
) Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1996 DeleteObject32( updateRgn
);
1999 /* erase uncovered areas */
2001 if( !(uFlags
& SMC_NOPARENTERASE
) && (other
!= NULLREGION
) )
2002 PAINT_RedrawWindow( Wnd
->parent
->hwndSelf
, NULL
, dirtyRgn
,
2003 RDW_INVALIDATE
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
2004 DeleteObject32(dirtyRgn
);
2005 DeleteObject32(newVisRgn
);
2010 /***********************************************************************
2011 * WINPOS_FindDeskTopXWindow
2013 * Find the actual X window which needs be restacked.
2014 * Used by WINPOS_SetXWindowPos().
2016 static Window
WINPOS_FindDeskTopXWindow( WND
*wndPtr
)
2018 if (!(wndPtr
->flags
& WIN_MANAGED
))
2019 return wndPtr
->window
;
2022 Window window
, root
, parent
, *children
;
2024 window
= wndPtr
->window
;
2027 TSXQueryTree( display
, window
, &root
, &parent
,
2028 &children
, &nchildren
);
2029 TSXFree( children
);
2037 /***********************************************************************
2038 * WINPOS_SetXWindowPos
2040 * SetWindowPos() for an X window. Used by the real SetWindowPos().
2042 static void WINPOS_SetXWindowPos( const WINDOWPOS32
*winpos
)
2044 XWindowChanges winChanges
;
2046 WND
*wndPtr
= WIN_FindWndPtr( winpos
->hwnd
);
2048 if (!(winpos
->flags
& SWP_NOSIZE
))
2050 winChanges
.width
= winpos
->cx
;
2051 winChanges
.height
= winpos
->cy
;
2052 changeMask
|= CWWidth
| CWHeight
;
2054 /* Tweak dialog window size hints */
2056 if ((wndPtr
->flags
& WIN_MANAGED
) &&
2057 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
2059 XSizeHints
*size_hints
= TSXAllocSizeHints();
2063 long supplied_return
;
2065 TSXGetWMSizeHints( display
, wndPtr
->window
, size_hints
,
2066 &supplied_return
, XA_WM_NORMAL_HINTS
);
2067 size_hints
->min_width
= size_hints
->max_width
= winpos
->cx
;
2068 size_hints
->min_height
= size_hints
->max_height
= winpos
->cy
;
2069 TSXSetWMSizeHints( display
, wndPtr
->window
, size_hints
,
2070 XA_WM_NORMAL_HINTS
);
2071 TSXFree(size_hints
);
2075 if (!(winpos
->flags
& SWP_NOMOVE
))
2077 winChanges
.x
= winpos
->x
;
2078 winChanges
.y
= winpos
->y
;
2079 changeMask
|= CWX
| CWY
;
2081 if (!(winpos
->flags
& SWP_NOZORDER
))
2083 winChanges
.stack_mode
= Below
;
2084 changeMask
|= CWStackMode
;
2086 if (winpos
->hwndInsertAfter
== HWND_TOP
) winChanges
.stack_mode
= Above
;
2087 else if (winpos
->hwndInsertAfter
!= HWND_BOTTOM
)
2089 WND
* insertPtr
= WIN_FindWndPtr( winpos
->hwndInsertAfter
);
2092 stack
[0] = WINPOS_FindDeskTopXWindow( insertPtr
);
2093 stack
[1] = WINPOS_FindDeskTopXWindow( wndPtr
);
2095 /* for stupid window managers (i.e. all of them) */
2097 TSXRestackWindows(display
, stack
, 2);
2098 changeMask
&= ~CWStackMode
;
2101 if (!changeMask
) return;
2103 TSXReconfigureWMWindow( display
, wndPtr
->window
, 0, changeMask
, &winChanges
);
2107 /***********************************************************************
2108 * SetWindowPos (USER.232)
2110 BOOL16 WINAPI
SetWindowPos16( HWND16 hwnd
, HWND16 hwndInsertAfter
,
2111 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, WORD flags
)
2113 return SetWindowPos32(hwnd
,(INT32
)(INT16
)hwndInsertAfter
,x
,y
,cx
,cy
,flags
);
2116 /***********************************************************************
2117 * SetWindowPos (USER32.520)
2119 BOOL32 WINAPI
SetWindowPos32( HWND32 hwnd
, HWND32 hwndInsertAfter
,
2120 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
, WORD flags
)
2124 RECT32 newWindowRect
, newClientRect
, oldWindowRect
;
2126 HWND32 tempInsertAfter
= 0;
2129 BOOL32 resync
= FALSE
;
2131 TRACE(win
,"hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
2132 hwnd
, x
, y
, x
+cx
, y
+cy
, flags
);
2133 /* Check window handle */
2135 if (hwnd
== GetDesktopWindow32()) return FALSE
;
2136 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return FALSE
;
2138 if(wndPtr
->dwStyle
& WS_VISIBLE
)
2139 flags
&= ~SWP_SHOWWINDOW
;
2142 uFlags
|= SMC_NOPARENTERASE
;
2143 flags
&= ~SWP_HIDEWINDOW
;
2144 if (!(flags
& SWP_SHOWWINDOW
)) flags
|= SWP_NOREDRAW
;
2147 /* Check for windows that may not be resized
2148 FIXME: this should be done only for Windows 3.0 programs
2149 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
2150 flags |= SWP_NOSIZE | SWP_NOMOVE;
2152 /* Check dimensions */
2154 if (cx
<= 0) cx
= 1;
2155 if (cy
<= 0) cy
= 1;
2159 if (hwnd
== hwndActive
) flags
|= SWP_NOACTIVATE
; /* Already active */
2160 if ((wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
== cx
) &&
2161 (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
== cy
))
2162 flags
|= SWP_NOSIZE
; /* Already the right size */
2163 if ((wndPtr
->rectWindow
.left
== x
) && (wndPtr
->rectWindow
.top
== y
))
2164 flags
|= SWP_NOMOVE
; /* Already the right position */
2166 /* Check hwndInsertAfter */
2168 if (!(flags
& (SWP_NOZORDER
| SWP_NOACTIVATE
)))
2170 /* Ignore TOPMOST flags when activating a window */
2171 /* _and_ moving it in Z order. */
2172 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
2173 (hwndInsertAfter
== HWND_NOTOPMOST
))
2174 hwndInsertAfter
= HWND_TOP
;
2176 /* TOPMOST not supported yet */
2177 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
2178 (hwndInsertAfter
== HWND_NOTOPMOST
)) hwndInsertAfter
= HWND_TOP
;
2180 /* hwndInsertAfter must be a sibling of the window */
2181 if ((hwndInsertAfter
!= HWND_TOP
) && (hwndInsertAfter
!= HWND_BOTTOM
))
2183 WND
* wnd
= WIN_FindWndPtr(hwndInsertAfter
);
2186 if( wnd
->parent
!= wndPtr
->parent
) return FALSE
;
2187 if( wnd
->next
== wndPtr
) flags
|= SWP_NOZORDER
;
2190 else if (!(wndPtr
->window
))
2192 /* FIXME: the following optimization is no good for "X-ed" windows */
2193 if (hwndInsertAfter
== HWND_TOP
)
2194 flags
|= ( wndPtr
->parent
->child
== wndPtr
)? SWP_NOZORDER
: 0;
2195 else /* HWND_BOTTOM */
2196 flags
|= ( wndPtr
->next
)? 0: SWP_NOZORDER
;
2199 /* Fill the WINDOWPOS structure */
2202 winpos
.hwndInsertAfter
= hwndInsertAfter
;
2207 winpos
.flags
= flags
;
2209 /* Send WM_WINDOWPOSCHANGING message */
2211 if (!(winpos
.flags
& SWP_NOSENDCHANGING
))
2212 SendMessage32A( hwnd
, WM_WINDOWPOSCHANGING
, 0, (LPARAM
)&winpos
);
2214 /* Calculate new position and size */
2216 newWindowRect
= wndPtr
->rectWindow
;
2217 newClientRect
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? wndPtr
->rectWindow
2218 : wndPtr
->rectClient
;
2220 if (!(winpos
.flags
& SWP_NOSIZE
))
2222 newWindowRect
.right
= newWindowRect
.left
+ winpos
.cx
;
2223 newWindowRect
.bottom
= newWindowRect
.top
+ winpos
.cy
;
2225 if (!(winpos
.flags
& SWP_NOMOVE
))
2227 newWindowRect
.left
= winpos
.x
;
2228 newWindowRect
.top
= winpos
.y
;
2229 newWindowRect
.right
+= winpos
.x
- wndPtr
->rectWindow
.left
;
2230 newWindowRect
.bottom
+= winpos
.y
- wndPtr
->rectWindow
.top
;
2232 OffsetRect32( &newClientRect
, winpos
.x
- wndPtr
->rectWindow
.left
,
2233 winpos
.y
- wndPtr
->rectWindow
.top
);
2236 winpos
.flags
|= SWP_NOCLIENTMOVE
| SWP_NOCLIENTSIZE
;
2238 /* Reposition window in Z order */
2240 if (!(winpos
.flags
& SWP_NOZORDER
))
2242 /* reorder owned popups if hwnd is top-level window
2244 if( wndPtr
->parent
== WIN_GetDesktop() )
2245 hwndInsertAfter
= WINPOS_ReorderOwnedPopups( hwndInsertAfter
,
2246 wndPtr
, winpos
.flags
);
2250 WIN_UnlinkWindow( winpos
.hwnd
);
2251 WIN_LinkWindow( winpos
.hwnd
, hwndInsertAfter
);
2253 else WINPOS_MoveWindowZOrder( winpos
.hwnd
, hwndInsertAfter
);
2256 if ( !wndPtr
->window
&& !(winpos
.flags
& SWP_NOREDRAW
) &&
2257 ((winpos
.flags
& (SWP_NOMOVE
| SWP_NOSIZE
| SWP_FRAMECHANGED
))
2258 != (SWP_NOMOVE
| SWP_NOSIZE
)) )
2259 visRgn
= DCE_GetVisRgn(hwnd
, DCX_WINDOW
| DCX_CLIPSIBLINGS
);
2262 /* Send WM_NCCALCSIZE message to get new client area */
2263 if( (winpos
.flags
& (SWP_FRAMECHANGED
| SWP_NOSIZE
)) != SWP_NOSIZE
)
2265 result
= WINPOS_SendNCCalcSize( winpos
.hwnd
, TRUE
, &newWindowRect
,
2266 &wndPtr
->rectWindow
, &wndPtr
->rectClient
,
2267 &winpos
, &newClientRect
);
2269 /* FIXME: WVR_ALIGNxxx */
2271 if( newClientRect
.left
!= wndPtr
->rectClient
.left
||
2272 newClientRect
.top
!= wndPtr
->rectClient
.top
)
2273 winpos
.flags
&= ~SWP_NOCLIENTMOVE
;
2275 if( (newClientRect
.right
- newClientRect
.left
!=
2276 wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
) ||
2277 (newClientRect
.bottom
- newClientRect
.top
!=
2278 wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
) )
2279 winpos
.flags
&= ~SWP_NOCLIENTSIZE
;
2282 if( !(flags
& SWP_NOMOVE
) && (newClientRect
.left
!= wndPtr
->rectClient
.left
||
2283 newClientRect
.top
!= wndPtr
->rectClient
.top
) )
2284 winpos
.flags
&= ~SWP_NOCLIENTMOVE
;
2286 /* Update active DCEs
2287 * TODO: Optimize conditions that trigger DCE update.
2290 if( (((winpos
.flags
& SWP_AGG_NOPOSCHANGE
) != SWP_AGG_NOPOSCHANGE
) &&
2291 wndPtr
->dwStyle
& WS_VISIBLE
) ||
2292 (flags
& (SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
2296 UnionRect32(&rect
, &newWindowRect
, &wndPtr
->rectWindow
);
2297 DCE_InvalidateDCE(wndPtr
, &rect
);
2300 /* change geometry */
2302 oldWindowRect
= wndPtr
->rectWindow
;
2306 RECT32 oldClientRect
= wndPtr
->rectClient
;
2308 tempInsertAfter
= winpos
.hwndInsertAfter
;
2310 winpos
.hwndInsertAfter
= hwndInsertAfter
;
2312 /* postpone geometry change */
2314 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
2316 WINPOS_SetXWindowPos( &winpos
);
2317 winpos
.hwndInsertAfter
= tempInsertAfter
;
2319 else uFlags
|= SMC_SETXPOS
;
2321 wndPtr
->rectWindow
= newWindowRect
;
2322 wndPtr
->rectClient
= newClientRect
;
2324 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
2326 if( (oldClientRect
.left
- oldWindowRect
.left
!=
2327 newClientRect
.left
- newWindowRect
.left
) ||
2328 (oldClientRect
.top
- oldWindowRect
.top
!=
2329 newClientRect
.top
- newWindowRect
.top
) ||
2330 (winpos
.flags
& SWP_NOCOPYBITS
) )
2332 /* if the client area moved as a result of WM_NCCALCSIZE returning
2333 * obscure WVR_ALIGNxxx flags then we simply redraw the whole thing
2335 * TODO: use WINPOS_SizeMoveClean() if there is no SWP_NOCOPYBITS
2338 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, RDW_INVALIDATE
|
2339 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
2342 if( winpos
.flags
& SWP_FRAMECHANGED
)
2347 if( newClientRect
.right
> oldClientRect
.right
) /* redraw exposed client area on the right */
2349 rect
.top
= 0; rect
.bottom
= newClientRect
.bottom
- newClientRect
.top
;
2350 rect
.left
= oldClientRect
.right
- newClientRect
.left
;
2351 rect
.right
= newClientRect
.right
- newClientRect
.left
;
2353 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
2354 RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
| RDW_ALLCHILDREN
, 0 );
2356 if( newClientRect
.bottom
> oldClientRect
.bottom
) /* redraw exposed client area on the bottom */
2358 rect
.left
= 0; rect
.right
= ((wErase
)?oldClientRect
.right
:newClientRect
.right
) - newClientRect
.left
;
2359 rect
.top
= oldClientRect
.bottom
- newClientRect
.top
;
2360 rect
.bottom
= newClientRect
.bottom
- newClientRect
.top
;
2362 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
2363 RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
| RDW_ALLCHILDREN
, 0 );
2365 if( !wErase
) /* just update the nonclient area */
2366 wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
2369 uFlags
|= SMC_NOPARENTERASE
; /* X windows do not have eraseable parents */
2371 else /* not an X window */
2373 RECT32 oldClientRect
= wndPtr
->rectClient
;
2375 wndPtr
->rectWindow
= newWindowRect
;
2376 wndPtr
->rectClient
= newClientRect
;
2378 if( oldClientRect
.bottom
- oldClientRect
.top
==
2379 newClientRect
.bottom
- newClientRect
.top
) result
&= ~WVR_VREDRAW
;
2381 if( oldClientRect
.right
- oldClientRect
.left
==
2382 newClientRect
.right
- newClientRect
.left
) result
&= ~WVR_HREDRAW
;
2384 if( !(flags
& (SWP_NOREDRAW
| SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
2386 uFlags
|= ((winpos
.flags
& SWP_NOCOPYBITS
) ||
2387 (result
>= WVR_HREDRAW
&& result
< WVR_VALIDRECTS
)) ? SMC_NOCOPY
: 0;
2388 uFlags
|= (winpos
.flags
& SWP_FRAMECHANGED
) ? SMC_DRAWFRAME
: 0;
2390 if( (winpos
.flags
& SWP_AGG_NOGEOMETRYCHANGE
) != SWP_AGG_NOGEOMETRYCHANGE
)
2391 uFlags
= WINPOS_SizeMoveClean(wndPtr
, visRgn
, &oldWindowRect
,
2392 &oldClientRect
, uFlags
);
2395 /* adjust the frame and do not erase the parent */
2397 if( winpos
.flags
& SWP_FRAMECHANGED
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
2398 if( winpos
.flags
& SWP_NOZORDER
) uFlags
|= SMC_NOPARENTERASE
;
2401 DeleteObject32(visRgn
);
2404 if (flags
& SWP_SHOWWINDOW
)
2406 wndPtr
->dwStyle
|= WS_VISIBLE
;
2411 if( uFlags
& SMC_SETXPOS
)
2413 WINPOS_SetXWindowPos( &winpos
);
2414 winpos
.hwndInsertAfter
= tempInsertAfter
;
2416 TSXMapWindow( display
, wndPtr
->window
);
2417 if (wndPtr
->flags
& WIN_MANAGED
) resync
= TRUE
;
2419 /* If focus was set to an unmapped window, reset X focus now */
2420 focus
= curr
= GetFocus32();
2424 SetFocus32( focus
);
2427 curr
= GetParent32(curr
);
2432 if (!(flags
& SWP_NOREDRAW
))
2433 PAINT_RedrawWindow( winpos
.hwnd
, NULL
, 0,
2434 RDW_INVALIDATE
| RDW_ALLCHILDREN
|
2435 RDW_FRAME
| RDW_ERASENOW
| RDW_ERASE
, 0 );
2438 else if (flags
& SWP_HIDEWINDOW
)
2440 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
2443 TSXUnmapWindow( display
, wndPtr
->window
);
2444 if( uFlags
& SMC_SETXPOS
)
2446 WINPOS_SetXWindowPos( &winpos
);
2447 winpos
.hwndInsertAfter
= tempInsertAfter
;
2452 if (!(flags
& SWP_NOREDRAW
))
2453 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, &oldWindowRect
,
2454 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
2455 RDW_ERASE
| RDW_ERASENOW
, 0 );
2456 uFlags
|= SMC_NOPARENTERASE
;
2459 if ((winpos
.hwnd
== GetFocus32()) ||
2460 IsChild32( winpos
.hwnd
, GetFocus32()))
2462 /* Revert focus to parent */
2463 SetFocus32( GetParent32(winpos
.hwnd
) );
2465 if (hwnd
== CARET_GetHwnd()) DestroyCaret32();
2467 if (winpos
.hwnd
== hwndActive
)
2468 WINPOS_ActivateOtherWindow( wndPtr
);
2471 /* Activate the window */
2473 if (!(flags
& SWP_NOACTIVATE
))
2474 WINPOS_ChangeActiveWindow( winpos
.hwnd
, FALSE
);
2476 /* Repaint the window */
2478 if (wndPtr
->window
) EVENT_Synchronize(); /* Wait for all expose events */
2480 if (!GetCapture32())
2481 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
2483 if (!(flags
& SWP_DEFERERASE
) && !(uFlags
& SMC_NOPARENTERASE
) )
2484 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_ALLCHILDREN
| RDW_ERASENOW
, 0 );
2485 else if( wndPtr
->parent
== WIN_GetDesktop() && wndPtr
->parent
->flags
& WIN_NEEDS_ERASEBKGND
)
2486 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_NOCHILDREN
| RDW_ERASENOW
, 0 );
2488 /* And last, send the WM_WINDOWPOSCHANGED message */
2490 TRACE(win
,"\tstatus flags = %04x\n", winpos
.flags
& SWP_AGG_STATUSFLAGS
);
2493 (((winpos
.flags
& SWP_AGG_STATUSFLAGS
) != SWP_AGG_NOPOSCHANGE
) &&
2494 !(winpos
.flags
& SWP_NOSENDCHANGING
)) )
2496 SendMessage32A( winpos
.hwnd
, WM_WINDOWPOSCHANGED
, 0, (LPARAM
)&winpos
);
2497 if (resync
) EVENT_Synchronize ();
2504 /***********************************************************************
2505 * BeginDeferWindowPos16 (USER.259)
2507 HDWP16 WINAPI
BeginDeferWindowPos16( INT16 count
)
2509 return BeginDeferWindowPos32( count
);
2513 /***********************************************************************
2514 * BeginDeferWindowPos32 (USER32.9)
2516 HDWP32 WINAPI
BeginDeferWindowPos32( INT32 count
)
2521 if (count
<= 0) return 0;
2522 handle
= USER_HEAP_ALLOC( sizeof(DWP
) + (count
-1)*sizeof(WINDOWPOS32
) );
2523 if (!handle
) return 0;
2524 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( handle
);
2525 pDWP
->actualCount
= 0;
2526 pDWP
->suggestedCount
= count
;
2528 pDWP
->wMagic
= DWP_MAGIC
;
2529 pDWP
->hwndParent
= 0;
2534 /***********************************************************************
2535 * DeferWindowPos16 (USER.260)
2537 HDWP16 WINAPI
DeferWindowPos16( HDWP16 hdwp
, HWND16 hwnd
, HWND16 hwndAfter
,
2538 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
2541 return DeferWindowPos32( hdwp
, hwnd
, (INT32
)(INT16
)hwndAfter
,
2542 x
, y
, cx
, cy
, flags
);
2546 /***********************************************************************
2547 * DeferWindowPos32 (USER32.128)
2549 HDWP32 WINAPI
DeferWindowPos32( HDWP32 hdwp
, HWND32 hwnd
, HWND32 hwndAfter
,
2550 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
2555 HDWP32 newhdwp
= hdwp
;
2556 /* HWND32 parent; */
2559 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2560 if (!pDWP
) return 0;
2561 if (hwnd
== GetDesktopWindow32()) return 0;
2563 if (!(pWnd
=WIN_FindWndPtr( hwnd
))) {
2564 USER_HEAP_FREE( hdwp
);
2568 /* Numega Bounds Checker Demo dislikes the following code.
2569 In fact, I've not been able to find any "same parent" requirement in any docu
2573 /* All the windows of a DeferWindowPos() must have the same parent */
2574 parent
= pWnd
->parent
->hwndSelf
;
2575 if (pDWP
->actualCount
== 0) pDWP
->hwndParent
= parent
;
2576 else if (parent
!= pDWP
->hwndParent
)
2578 USER_HEAP_FREE( hdwp
);
2583 for (i
= 0; i
< pDWP
->actualCount
; i
++)
2585 if (pDWP
->winPos
[i
].hwnd
== hwnd
)
2587 /* Merge with the other changes */
2588 if (!(flags
& SWP_NOZORDER
))
2590 pDWP
->winPos
[i
].hwndInsertAfter
= hwndAfter
;
2592 if (!(flags
& SWP_NOMOVE
))
2594 pDWP
->winPos
[i
].x
= x
;
2595 pDWP
->winPos
[i
].y
= y
;
2597 if (!(flags
& SWP_NOSIZE
))
2599 pDWP
->winPos
[i
].cx
= cx
;
2600 pDWP
->winPos
[i
].cy
= cy
;
2602 pDWP
->winPos
[i
].flags
&= flags
| ~(SWP_NOSIZE
| SWP_NOMOVE
|
2603 SWP_NOZORDER
| SWP_NOREDRAW
|
2604 SWP_NOACTIVATE
| SWP_NOCOPYBITS
|
2606 pDWP
->winPos
[i
].flags
|= flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
|
2611 if (pDWP
->actualCount
>= pDWP
->suggestedCount
)
2613 newhdwp
= USER_HEAP_REALLOC( hdwp
,
2614 sizeof(DWP
) + pDWP
->suggestedCount
*sizeof(WINDOWPOS32
) );
2615 if (!newhdwp
) return 0;
2616 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( newhdwp
);
2617 pDWP
->suggestedCount
++;
2619 pDWP
->winPos
[pDWP
->actualCount
].hwnd
= hwnd
;
2620 pDWP
->winPos
[pDWP
->actualCount
].hwndInsertAfter
= hwndAfter
;
2621 pDWP
->winPos
[pDWP
->actualCount
].x
= x
;
2622 pDWP
->winPos
[pDWP
->actualCount
].y
= y
;
2623 pDWP
->winPos
[pDWP
->actualCount
].cx
= cx
;
2624 pDWP
->winPos
[pDWP
->actualCount
].cy
= cy
;
2625 pDWP
->winPos
[pDWP
->actualCount
].flags
= flags
;
2626 pDWP
->actualCount
++;
2631 /***********************************************************************
2632 * EndDeferWindowPos16 (USER.261)
2634 BOOL16 WINAPI
EndDeferWindowPos16( HDWP16 hdwp
)
2636 return EndDeferWindowPos32( hdwp
);
2640 /***********************************************************************
2641 * EndDeferWindowPos32 (USER32.173)
2643 BOOL32 WINAPI
EndDeferWindowPos32( HDWP32 hdwp
)
2646 WINDOWPOS32
*winpos
;
2650 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2651 if (!pDWP
) return FALSE
;
2652 for (i
= 0, winpos
= pDWP
->winPos
; i
< pDWP
->actualCount
; i
++, winpos
++)
2654 if (!(res
= SetWindowPos32( winpos
->hwnd
, winpos
->hwndInsertAfter
,
2655 winpos
->x
, winpos
->y
, winpos
->cx
,
2656 winpos
->cy
, winpos
->flags
))) break;
2658 USER_HEAP_FREE( hdwp
);
2663 /***********************************************************************
2664 * TileChildWindows (USER.199)
2666 void WINAPI
TileChildWindows( HWND16 parent
, WORD action
)
2668 FIXME(win
, "(%04x, %d): stub\n", parent
, action
);
2671 /***********************************************************************
2672 * CascageChildWindows (USER.198)
2674 void WINAPI
CascadeChildWindows( HWND16 parent
, WORD action
)
2676 FIXME(win
, "(%04x, %d): stub\n", parent
, action
);
2678 /***********************************************************************
2679 * GetProgmanWindow [USER32.289]
2681 HRESULT WINAPI
GetProgmanWindow ( )
2682 { FIXME(win
,"stub\n");
2685 /***********************************************************************
2686 * GetTaskmanWindow [USER32.304]
2688 HRESULT WINAPI
GetTaskmanWindow ( )
2689 { FIXME(win
,"stub\n");
2692 /***********************************************************************
2693 * SetProgmanWindow [USER32.522]
2695 HRESULT WINAPI
SetProgmanWindow ( DWORD x
)
2696 { FIXME(win
,"0x%08lx stub\n",x
);
2699 /***********************************************************************
2700 * SetShellWindowEx [USER32.531]
2702 HRESULT WINAPI
SetShellWindowEx ( DWORD x
, DWORD y
)
2703 { FIXME(win
,"0x%08lx 0x%08lx stub\n",x
,y
);
2706 /***********************************************************************
2707 * SetTaskmanWindow [USER32.537]
2709 HRESULT WINAPI
SetTaskmanWindow ( DWORD x
)
2710 { FIXME(win
,"0x%08lx stub\n",x
);