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"
24 /* #define DEBUG_WIN */
27 #define HAS_DLGFRAME(style,exStyle) \
28 (((exStyle) & WS_EX_DLGMODALFRAME) || \
29 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
31 #define HAS_THICKFRAME(style) \
32 (((style) & WS_THICKFRAME) && \
33 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
35 #define SWP_AGG_NOGEOMETRYCHANGE \
36 (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
37 #define SWP_AGG_NOPOSCHANGE \
38 (SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
39 #define SWP_AGG_STATUSFLAGS \
40 (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
42 #define EMPTYPOINT(pt) ((*(LONG*)&(pt)) == -1)
44 #define PLACE_MIN 0x0001
45 #define PLACE_MAX 0x0002
46 #define PLACE_RECT 0x0004
48 #define SMC_NOCOPY 0x0001
49 #define SMC_NOPARENTERASE 0x0002
50 #define SMC_DRAWFRAME 0x0004
51 #define SMC_SETXPOS 0x0008
53 /* ----- external functions ----- */
55 extern void FOCUS_SwitchFocus( HWND32
, HWND32
);
56 extern HWND32
CARET_GetHwnd();
58 /* ----- internal variables ----- */
60 static HWND32 hwndActive
= 0; /* Currently active window */
61 static HWND32 hwndPrevActive
= 0; /* Previously active window */
63 static LPCSTR atomInternalPos
;
65 extern MESSAGEQUEUE
* pActiveQueue
;
67 /***********************************************************************
68 * WINPOS_CreateInternalPosAtom
70 BOOL32
WINPOS_CreateInternalPosAtom()
73 atomInternalPos
= (LPCSTR
)(DWORD
)GlobalAddAtom32A(str
);
74 return (atomInternalPos
) ? TRUE
: FALSE
;
77 /***********************************************************************
78 * WINPOS_CheckInternalPos
80 * Called when a window is destroyed.
82 void WINPOS_CheckInternalPos( HWND32 hwnd
)
84 LPINTERNALPOS lpPos
= (LPINTERNALPOS
) GetProp32A( hwnd
, atomInternalPos
);
86 if( hwnd
== hwndPrevActive
) hwndPrevActive
= 0;
87 if( hwnd
== hwndActive
)
90 dprintf_win(stddeb
,"\tattempt to activate destroyed window!\n");
95 if( IsWindow32(lpPos
->hwndIconTitle
) )
96 DestroyWindow32( lpPos
->hwndIconTitle
);
97 HeapFree( SystemHeap
, 0, lpPos
);
101 /***********************************************************************
104 * Find a suitable place for an iconic window.
106 static POINT16
WINPOS_FindIconPos( WND
* wndPtr
, POINT16 pt
)
109 short x
, y
, xspacing
, yspacing
;
111 GetClientRect16( wndPtr
->parent
->hwndSelf
, &rectParent
);
112 if ((pt
.x
>= rectParent
.left
) && (pt
.x
+ SYSMETRICS_CXICON
< rectParent
.right
) &&
113 (pt
.y
>= rectParent
.top
) && (pt
.y
+ SYSMETRICS_CYICON
< rectParent
.bottom
))
114 return pt
; /* The icon already has a suitable position */
116 xspacing
= SYSMETRICS_CXICONSPACING
;
117 yspacing
= SYSMETRICS_CYICONSPACING
;
119 y
= rectParent
.bottom
;
122 for (x
= rectParent
.left
; x
<= rectParent
.right
-xspacing
; x
+= xspacing
)
124 /* Check if another icon already occupies this spot */
125 WND
*childPtr
= wndPtr
->parent
->child
;
128 if ((childPtr
->dwStyle
& WS_MINIMIZE
) && (childPtr
!= wndPtr
))
130 if ((childPtr
->rectWindow
.left
< x
+ xspacing
) &&
131 (childPtr
->rectWindow
.right
>= x
) &&
132 (childPtr
->rectWindow
.top
<= y
) &&
133 (childPtr
->rectWindow
.bottom
> y
- yspacing
))
134 break; /* There's a window in there */
136 childPtr
= childPtr
->next
;
138 if (!childPtr
) /* No window was found, so it's OK for us */
140 pt
.x
= x
+ (xspacing
- SYSMETRICS_CXICON
) / 2;
141 pt
.y
= y
- (yspacing
+ SYSMETRICS_CYICON
) / 2;
150 /***********************************************************************
151 * ArrangeIconicWindows16 (USER.170)
153 UINT16 WINAPI
ArrangeIconicWindows16( HWND16 parent
)
155 return ArrangeIconicWindows32(parent
);
157 /***********************************************************************
158 * ArrangeIconicWindows32 (USER32.6)
160 UINT32 WINAPI
ArrangeIconicWindows32( HWND32 parent
)
164 INT32 x
, y
, xspacing
, yspacing
;
166 GetClientRect32( parent
, &rectParent
);
168 y
= rectParent
.bottom
;
169 xspacing
= SYSMETRICS_CXICONSPACING
;
170 yspacing
= SYSMETRICS_CYICONSPACING
;
172 hwndChild
= GetWindow32( parent
, GW_CHILD
);
175 if( IsIconic32( hwndChild
) )
177 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild
), FALSE
);
178 SetWindowPos32( hwndChild
, 0, x
+ (xspacing
- SYSMETRICS_CXICON
) / 2,
179 y
- yspacing
- SYSMETRICS_CYICON
/2, 0, 0,
180 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
181 if( IsWindow32(hwndChild
) )
182 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild
), TRUE
);
183 if (x
<= rectParent
.right
- xspacing
) x
+= xspacing
;
190 hwndChild
= GetWindow32( hwndChild
, GW_HWNDNEXT
);
196 /***********************************************************************
197 * SwitchToThisWindow16 (USER.172)
199 void WINAPI
SwitchToThisWindow16( HWND16 hwnd
, BOOL16 restore
)
201 SwitchToThisWindow32( hwnd
, restore
);
205 /***********************************************************************
206 * SwitchToThisWindow32 (USER32.538)
208 void WINAPI
SwitchToThisWindow32( HWND32 hwnd
, BOOL32 restore
)
210 ShowWindow32( hwnd
, restore
? SW_RESTORE
: SW_SHOWMINIMIZED
);
214 /***********************************************************************
215 * GetWindowRect16 (USER.32)
217 void WINAPI
GetWindowRect16( HWND16 hwnd
, LPRECT16 rect
)
219 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
222 CONV_RECT32TO16( &wndPtr
->rectWindow
, rect
);
223 if (wndPtr
->dwStyle
& WS_CHILD
)
224 MapWindowPoints16( wndPtr
->parent
->hwndSelf
, 0, (POINT16
*)rect
, 2 );
228 /***********************************************************************
229 * GetWindowRect32 (USER.32)
231 void WINAPI
GetWindowRect32( HWND32 hwnd
, LPRECT32 rect
)
233 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
236 *rect
= wndPtr
->rectWindow
;
237 if (wndPtr
->dwStyle
& WS_CHILD
)
238 MapWindowPoints32( wndPtr
->parent
->hwndSelf
, 0, (POINT32
*)rect
, 2 );
242 /***********************************************************************
243 * GetClientRect16 (USER.33)
245 void WINAPI
GetClientRect16( HWND16 hwnd
, LPRECT16 rect
)
247 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
249 rect
->left
= rect
->top
= rect
->right
= rect
->bottom
= 0;
252 rect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
;
253 rect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
;
258 /***********************************************************************
259 * GetClientRect32 (USER32.219)
261 void WINAPI
GetClientRect32( HWND32 hwnd
, LPRECT32 rect
)
263 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
265 rect
->left
= rect
->top
= rect
->right
= rect
->bottom
= 0;
268 rect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
;
269 rect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
;
274 /*******************************************************************
275 * ClientToScreen16 (USER.28)
277 void WINAPI
ClientToScreen16( HWND16 hwnd
, LPPOINT16 lppnt
)
279 MapWindowPoints16( hwnd
, 0, lppnt
, 1 );
283 /*******************************************************************
284 * ClientToScreen32 (USER32.51)
286 BOOL32 WINAPI
ClientToScreen32( HWND32 hwnd
, LPPOINT32 lppnt
)
288 MapWindowPoints32( hwnd
, 0, lppnt
, 1 );
293 /*******************************************************************
294 * ScreenToClient16 (USER.29)
296 void WINAPI
ScreenToClient16( HWND16 hwnd
, LPPOINT16 lppnt
)
298 MapWindowPoints16( 0, hwnd
, lppnt
, 1 );
302 /*******************************************************************
303 * ScreenToClient32 (USER32.446)
305 void WINAPI
ScreenToClient32( HWND32 hwnd
, LPPOINT32 lppnt
)
307 MapWindowPoints32( 0, hwnd
, lppnt
, 1 );
311 /***********************************************************************
312 * WINPOS_WindowFromPoint
314 * Find the window and hittest for a given point.
316 INT16
WINPOS_WindowFromPoint( WND
* wndScope
, POINT16 pt
, WND
**ppWnd
)
319 INT16 hittest
= HTERROR
;
323 wndPtr
= wndScope
->child
;
324 MapWindowPoints16( GetDesktopWindow16(), wndScope
->hwndSelf
, &xy
, 1 );
330 /* If point is in window, and window is visible, and it */
331 /* is enabled (or it's a top-level window), then explore */
332 /* its children. Otherwise, go to the next window. */
334 if ((wndPtr
->dwStyle
& WS_VISIBLE
) &&
335 (!(wndPtr
->dwStyle
& WS_DISABLED
) ||
336 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) != WS_CHILD
)) &&
337 (xy
.x
>= wndPtr
->rectWindow
.left
) &&
338 (xy
.x
< wndPtr
->rectWindow
.right
) &&
339 (xy
.y
>= wndPtr
->rectWindow
.top
) &&
340 (xy
.y
< wndPtr
->rectWindow
.bottom
))
342 *ppWnd
= wndPtr
; /* Got a suitable window */
344 /* If window is minimized or disabled, return at once */
345 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
346 if (wndPtr
->dwStyle
& WS_DISABLED
) return HTERROR
;
348 /* If point is not in client area, ignore the children */
349 if ((xy
.x
< wndPtr
->rectClient
.left
) ||
350 (xy
.x
>= wndPtr
->rectClient
.right
) ||
351 (xy
.y
< wndPtr
->rectClient
.top
) ||
352 (xy
.y
>= wndPtr
->rectClient
.bottom
)) break;
354 xy
.x
-= wndPtr
->rectClient
.left
;
355 xy
.y
-= wndPtr
->rectClient
.top
;
356 wndPtr
= wndPtr
->child
;
358 else wndPtr
= wndPtr
->next
;
361 /* If nothing found, try the scope window */
362 if (!*ppWnd
) *ppWnd
= wndScope
;
364 /* Send the WM_NCHITTEST message (only if to the same task) */
365 if ((*ppWnd
)->hmemTaskQ
== GetTaskQueue(0))
367 hittest
= (INT16
)SendMessage16( (*ppWnd
)->hwndSelf
, WM_NCHITTEST
,
368 0, MAKELONG( pt
.x
, pt
.y
) );
369 if (hittest
!= HTTRANSPARENT
) return hittest
; /* Found the window */
371 else return HTCLIENT
;
373 /* If no children found in last search, make point relative to parent */
376 xy
.x
+= (*ppWnd
)->rectClient
.left
;
377 xy
.y
+= (*ppWnd
)->rectClient
.top
;
380 /* Restart the search from the next sibling */
381 wndPtr
= (*ppWnd
)->next
;
382 *ppWnd
= (*ppWnd
)->parent
;
387 /*******************************************************************
388 * WindowFromPoint16 (USER.30)
390 HWND16 WINAPI
WindowFromPoint16( POINT16 pt
)
393 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt
, &pWnd
);
394 return pWnd
->hwndSelf
;
398 /*******************************************************************
399 * WindowFromPoint32 (USER32.581)
401 HWND32 WINAPI
WindowFromPoint32( POINT32 pt
)
405 CONV_POINT32TO16( &pt
, &pt16
);
406 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt16
, &pWnd
);
407 return (HWND32
)pWnd
->hwndSelf
;
411 /*******************************************************************
412 * ChildWindowFromPoint16 (USER.191)
414 HWND16 WINAPI
ChildWindowFromPoint16( HWND16 hwndParent
, POINT16 pt
)
417 CONV_POINT16TO32( &pt
, &pt32
);
418 return (HWND16
)ChildWindowFromPoint32( hwndParent
, pt32
);
422 /*******************************************************************
423 * ChildWindowFromPoint32 (USER32.48)
425 HWND32 WINAPI
ChildWindowFromPoint32( HWND32 hwndParent
, POINT32 pt
)
427 /* pt is in the client coordinates */
429 WND
* wnd
= WIN_FindWndPtr(hwndParent
);
434 /* get client rect fast */
435 rect
.top
= rect
.left
= 0;
436 rect
.right
= wnd
->rectClient
.right
- wnd
->rectClient
.left
;
437 rect
.bottom
= wnd
->rectClient
.bottom
- wnd
->rectClient
.top
;
439 if (!PtInRect32( &rect
, pt
)) return 0;
444 if (PtInRect32( &wnd
->rectWindow
, pt
)) return wnd
->hwndSelf
;
451 /*******************************************************************
452 * WINPOS_GetWinOffset
454 * Calculate the offset between the origin of the two windows. Used
455 * to implement MapWindowPoints.
457 static void WINPOS_GetWinOffset( HWND32 hwndFrom
, HWND32 hwndTo
,
462 offset
->x
= offset
->y
= 0;
463 if (hwndFrom
== hwndTo
) return;
465 /* Translate source window origin to screen coords */
468 if (!(wndPtr
= WIN_FindWndPtr( hwndFrom
)))
470 fprintf(stderr
,"MapWindowPoints: bad hwndFrom = %04x\n",hwndFrom
);
473 while (wndPtr
->parent
)
475 offset
->x
+= wndPtr
->rectClient
.left
;
476 offset
->y
+= wndPtr
->rectClient
.top
;
477 wndPtr
= wndPtr
->parent
;
481 /* Translate origin to destination window coords */
484 if (!(wndPtr
= WIN_FindWndPtr( hwndTo
)))
486 fprintf(stderr
,"MapWindowPoints: bad hwndTo = %04x\n", hwndTo
);
489 while (wndPtr
->parent
)
491 offset
->x
-= wndPtr
->rectClient
.left
;
492 offset
->y
-= wndPtr
->rectClient
.top
;
493 wndPtr
= wndPtr
->parent
;
499 /*******************************************************************
500 * MapWindowPoints16 (USER.258)
502 void WINAPI
MapWindowPoints16( HWND16 hwndFrom
, HWND16 hwndTo
,
503 LPPOINT16 lppt
, UINT16 count
)
507 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
517 /*******************************************************************
518 * MapWindowPoints32 (USER32.385)
520 void WINAPI
MapWindowPoints32( HWND32 hwndFrom
, HWND32 hwndTo
,
521 LPPOINT32 lppt
, UINT32 count
)
525 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
535 /***********************************************************************
536 * IsIconic16 (USER.31)
538 BOOL16 WINAPI
IsIconic16(HWND16 hWnd
)
540 return IsIconic32(hWnd
);
544 /***********************************************************************
545 * IsIconic32 (USER32.344)
547 BOOL32 WINAPI
IsIconic32(HWND32 hWnd
)
549 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
550 if (wndPtr
== NULL
) return FALSE
;
551 return (wndPtr
->dwStyle
& WS_MINIMIZE
) != 0;
555 /***********************************************************************
556 * IsZoomed (USER.272)
558 BOOL16 WINAPI
IsZoomed16(HWND16 hWnd
)
560 return IsZoomed32(hWnd
);
564 /***********************************************************************
565 * IsZoomed (USER32.351)
567 BOOL32 WINAPI
IsZoomed32(HWND32 hWnd
)
569 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
570 if (wndPtr
== NULL
) return FALSE
;
571 return (wndPtr
->dwStyle
& WS_MAXIMIZE
) != 0;
575 /*******************************************************************
576 * GetActiveWindow (USER.60)
578 HWND16 WINAPI
GetActiveWindow16(void)
580 return (HWND16
)hwndActive
;
583 /*******************************************************************
584 * GetActiveWindow (USER32.204)
586 HWND32 WINAPI
GetActiveWindow32(void)
588 return (HWND32
)hwndActive
;
592 /*******************************************************************
595 static BOOL32
WINPOS_CanActivate(WND
* pWnd
)
597 if( pWnd
&& ((pWnd
->dwStyle
& (WS_DISABLED
| WS_VISIBLE
| WS_CHILD
))
598 == WS_VISIBLE
) ) return TRUE
;
603 /*******************************************************************
604 * SetActiveWindow16 (USER.59)
606 HWND16 WINAPI
SetActiveWindow16( HWND16 hwnd
)
608 return SetActiveWindow32(hwnd
);
612 /*******************************************************************
613 * SetActiveWindow32 (USER32.462)
615 HWND32 WINAPI
SetActiveWindow32( HWND32 hwnd
)
617 HWND32 prev
= hwndActive
;
618 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
620 if ( !WINPOS_CanActivate(wndPtr
) ) return 0;
622 WINPOS_SetActiveWindow( hwnd
, 0, 0 );
627 /*******************************************************************
628 * GetForegroundWindow16 (USER.608)
630 HWND16 WINAPI
GetForegroundWindow16(void)
632 return (HWND16
)GetForegroundWindow32();
636 /*******************************************************************
637 * SetForegroundWindow16 (USER.609)
639 BOOL16 WINAPI
SetForegroundWindow16( HWND16 hwnd
)
641 return SetForegroundWindow32( hwnd
);
645 /*******************************************************************
646 * GetForegroundWindow32 (USER32.241)
648 HWND32 WINAPI
GetForegroundWindow32(void)
650 return GetActiveWindow32();
654 /*******************************************************************
655 * SetForegroundWindow32 (USER32.482)
657 BOOL32 WINAPI
SetForegroundWindow32( HWND32 hwnd
)
659 SetActiveWindow32( hwnd
);
664 /*******************************************************************
665 * GetShellWindow16 (USER.600)
667 HWND16 WINAPI
GetShellWindow16(void)
669 return GetShellWindow32();
673 /*******************************************************************
674 * GetShellWindow32 (USER32.287)
676 HWND32 WINAPI
GetShellWindow32(void)
678 fprintf( stdnimp
, "GetShellWindow: empty stub\n" );
683 /***********************************************************************
684 * BringWindowToTop16 (USER.45)
686 BOOL16 WINAPI
BringWindowToTop16( HWND16 hwnd
)
688 return BringWindowToTop32(hwnd
);
692 /***********************************************************************
693 * BringWindowToTop32 (USER32.10)
695 BOOL32 WINAPI
BringWindowToTop32( HWND32 hwnd
)
697 return SetWindowPos32( hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
701 /***********************************************************************
702 * MoveWindow16 (USER.56)
704 BOOL16 WINAPI
MoveWindow16( HWND16 hwnd
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
707 return MoveWindow32(hwnd
,x
,y
,cx
,cy
,repaint
);
711 /***********************************************************************
712 * MoveWindow32 (USER32.398)
714 BOOL32 WINAPI
MoveWindow32( HWND32 hwnd
, INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
717 int flags
= SWP_NOZORDER
| SWP_NOACTIVATE
;
718 if (!repaint
) flags
|= SWP_NOREDRAW
;
719 dprintf_win(stddeb
, "MoveWindow: %04x %d,%d %dx%d %d\n",
720 hwnd
, x
, y
, cx
, cy
, repaint
);
721 return SetWindowPos32( hwnd
, 0, x
, y
, cx
, cy
, flags
);
724 /***********************************************************************
725 * WINPOS_InitInternalPos
727 static LPINTERNALPOS
WINPOS_InitInternalPos( WND
* wnd
, POINT32 pt
,
728 LPRECT32 restoreRect
)
730 LPINTERNALPOS lpPos
= (LPINTERNALPOS
) GetProp32A( wnd
->hwndSelf
,
734 /* this happens when the window is minimized/maximized
735 * for the first time (rectWindow is not adjusted yet) */
737 lpPos
= HeapAlloc( SystemHeap
, 0, sizeof(INTERNALPOS
) );
738 if( !lpPos
) return NULL
;
740 SetProp32A( wnd
->hwndSelf
, atomInternalPos
, (HANDLE32
)lpPos
);
741 lpPos
->hwndIconTitle
= 0; /* defer until needs to be shown */
742 CONV_RECT32TO16( &wnd
->rectWindow
, &lpPos
->rectNormal
);
743 *(UINT32
*)&lpPos
->ptIconPos
= *(UINT32
*)&lpPos
->ptMaxPos
= 0xFFFFFFFF;
746 if( wnd
->dwStyle
& WS_MINIMIZE
)
747 CONV_POINT32TO16( &pt
, &lpPos
->ptIconPos
);
748 else if( wnd
->dwStyle
& WS_MAXIMIZE
)
749 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
750 else if( restoreRect
)
751 CONV_RECT32TO16( restoreRect
, &lpPos
->rectNormal
);
756 /***********************************************************************
757 * WINPOS_RedrawIconTitle
759 BOOL32
WINPOS_RedrawIconTitle( HWND32 hWnd
)
761 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)GetProp32A( hWnd
, atomInternalPos
);
764 if( lpPos
->hwndIconTitle
)
766 SendMessage32A( lpPos
->hwndIconTitle
, WM_SHOWWINDOW
, TRUE
, 0);
767 InvalidateRect32( lpPos
->hwndIconTitle
, NULL
, TRUE
);
774 /***********************************************************************
775 * WINPOS_ShowIconTitle
777 BOOL32
WINPOS_ShowIconTitle( WND
* pWnd
, BOOL32 bShow
)
779 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)GetProp32A( pWnd
->hwndSelf
, atomInternalPos
);
781 if( lpPos
&& !(pWnd
->flags
& WIN_MANAGED
))
783 HWND16 hWnd
= lpPos
->hwndIconTitle
;
785 dprintf_win(stddeb
,"ShowIconTitle: 0x%04x %i\n", pWnd
->hwndSelf
, (bShow
!= 0) );
788 lpPos
->hwndIconTitle
= hWnd
= ICONTITLE_Create( pWnd
);
791 pWnd
= WIN_FindWndPtr(hWnd
);
793 if( !(pWnd
->dwStyle
& WS_VISIBLE
) )
795 SendMessage32A( hWnd
, WM_SHOWWINDOW
, TRUE
, 0 );
796 SetWindowPos32( hWnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
797 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_SHOWWINDOW
);
800 else ShowWindow32( hWnd
, SW_HIDE
);
805 /*******************************************************************
806 * WINPOS_GetMinMaxInfo
808 * Get the minimized and maximized information for a window.
810 void WINPOS_GetMinMaxInfo( WND
*wndPtr
, POINT32
*maxSize
, POINT32
*maxPos
,
811 POINT32
*minTrack
, POINT32
*maxTrack
)
817 /* Compute default values */
819 MinMax
.ptMaxSize
.x
= SYSMETRICS_CXSCREEN
;
820 MinMax
.ptMaxSize
.y
= SYSMETRICS_CYSCREEN
;
821 MinMax
.ptMinTrackSize
.x
= SYSMETRICS_CXMINTRACK
;
822 MinMax
.ptMinTrackSize
.y
= SYSMETRICS_CYMINTRACK
;
823 MinMax
.ptMaxTrackSize
.x
= SYSMETRICS_CXSCREEN
;
824 MinMax
.ptMaxTrackSize
.y
= SYSMETRICS_CYSCREEN
;
826 if (wndPtr
->flags
& WIN_MANAGED
) xinc
= yinc
= 0;
827 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
829 xinc
= SYSMETRICS_CXDLGFRAME
;
830 yinc
= SYSMETRICS_CYDLGFRAME
;
835 if (HAS_THICKFRAME(wndPtr
->dwStyle
))
837 xinc
+= SYSMETRICS_CXFRAME
;
838 yinc
+= SYSMETRICS_CYFRAME
;
840 if (wndPtr
->dwStyle
& WS_BORDER
)
842 xinc
+= SYSMETRICS_CXBORDER
;
843 yinc
+= SYSMETRICS_CYBORDER
;
846 MinMax
.ptMaxSize
.x
+= 2 * xinc
;
847 MinMax
.ptMaxSize
.y
+= 2 * yinc
;
849 lpPos
= (LPINTERNALPOS
)GetProp32A( wndPtr
->hwndSelf
, atomInternalPos
);
850 if( lpPos
&& !EMPTYPOINT(lpPos
->ptMaxPos
) )
851 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &MinMax
.ptMaxPosition
);
854 MinMax
.ptMaxPosition
.x
= -xinc
;
855 MinMax
.ptMaxPosition
.y
= -yinc
;
858 SendMessage32A( wndPtr
->hwndSelf
, WM_GETMINMAXINFO
, 0, (LPARAM
)&MinMax
);
860 /* Some sanity checks */
862 dprintf_win(stddeb
,"GetMinMaxInfo: %d %d / %d %d / %d %d / %d %d\n",
863 MinMax
.ptMaxSize
.x
, MinMax
.ptMaxSize
.y
,
864 MinMax
.ptMaxPosition
.x
, MinMax
.ptMaxPosition
.y
,
865 MinMax
.ptMaxTrackSize
.x
, MinMax
.ptMaxTrackSize
.y
,
866 MinMax
.ptMinTrackSize
.x
, MinMax
.ptMinTrackSize
.y
);
867 MinMax
.ptMaxTrackSize
.x
= MAX( MinMax
.ptMaxTrackSize
.x
,
868 MinMax
.ptMinTrackSize
.x
);
869 MinMax
.ptMaxTrackSize
.y
= MAX( MinMax
.ptMaxTrackSize
.y
,
870 MinMax
.ptMinTrackSize
.y
);
872 if (maxSize
) *maxSize
= MinMax
.ptMaxSize
;
873 if (maxPos
) *maxPos
= MinMax
.ptMaxPosition
;
874 if (minTrack
) *minTrack
= MinMax
.ptMinTrackSize
;
875 if (maxTrack
) *maxTrack
= MinMax
.ptMaxTrackSize
;
878 /***********************************************************************
881 * Fill in lpRect and return additional flags to be used with SetWindowPos().
882 * This function assumes that 'cmd' is different from the current window
885 UINT16
WINPOS_MinMaximize( WND
* wndPtr
, UINT16 cmd
, LPRECT16 lpRect
)
889 POINT32 size
= { wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
};
890 LPINTERNALPOS lpPos
= WINPOS_InitInternalPos( wndPtr
, size
,
891 &wndPtr
->rectWindow
);
893 dprintf_win(stddeb
,"MinMaximize: 0x%04x %u\n", wndPtr
->hwndSelf
, cmd
);
895 if (lpPos
&& !HOOK_CallHooks16(WH_CBT
, HCBT_MINMAX
, wndPtr
->hwndSelf
, cmd
))
897 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
899 if( !SendMessage32A( wndPtr
->hwndSelf
, WM_QUERYOPEN
, 0, 0L ) )
900 return (SWP_NOSIZE
| SWP_NOMOVE
);
901 swpFlags
|= SWP_NOCOPYBITS
;
906 if( wndPtr
->dwStyle
& WS_MAXIMIZE
)
908 wndPtr
->flags
|= WIN_RESTORE_MAX
;
909 wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
912 wndPtr
->flags
&= ~WIN_RESTORE_MAX
;
913 wndPtr
->dwStyle
|= WS_MINIMIZE
;
915 lpPos
->ptIconPos
= WINPOS_FindIconPos( wndPtr
, lpPos
->ptIconPos
);
917 SetRect16( lpRect
, lpPos
->ptIconPos
.x
, lpPos
->ptIconPos
.y
,
918 SYSMETRICS_CXICON
, SYSMETRICS_CYICON
);
919 swpFlags
|= SWP_NOCOPYBITS
;
923 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &pt
);
924 WINPOS_GetMinMaxInfo( wndPtr
, &size
, &pt
, NULL
, NULL
);
925 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
927 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
929 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
930 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
932 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
934 SetRect16( lpRect
, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
,
939 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
941 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
942 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
943 if( wndPtr
->flags
& WIN_RESTORE_MAX
)
945 /* Restore to maximized position */
946 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &pt
);
947 WINPOS_GetMinMaxInfo( wndPtr
, &size
, &pt
, NULL
, NULL
);
948 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
949 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
953 if( !(wndPtr
->dwStyle
& WS_MAXIMIZE
) ) return (UINT16
)(-1);
954 else wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
956 /* Restore to normal position */
958 *lpRect
= lpPos
->rectNormal
;
959 lpRect
->right
-= lpRect
->left
;
960 lpRect
->bottom
-= lpRect
->top
;
964 } else swpFlags
|= SWP_NOSIZE
| SWP_NOMOVE
;
968 /***********************************************************************
969 * ShowWindow16 (USER.42)
971 BOOL16 WINAPI
ShowWindow16( HWND16 hwnd
, INT16 cmd
)
973 return ShowWindow32(hwnd
,cmd
);
977 /***********************************************************************
978 * ShowWindow32 (USER.42)
980 BOOL32 WINAPI
ShowWindow32( HWND32 hwnd
, INT32 cmd
)
982 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
983 BOOL32 wasVisible
, showFlag
;
984 RECT16 newPos
= {0, 0, 0, 0};
987 if (!wndPtr
) return FALSE
;
989 dprintf_win(stddeb
,"ShowWindow: hwnd=%04x, cmd=%d\n", hwnd
, cmd
);
991 wasVisible
= (wndPtr
->dwStyle
& WS_VISIBLE
) != 0;
996 if (!wasVisible
) return FALSE
;
997 swp
|= SWP_HIDEWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
|
998 SWP_NOACTIVATE
| SWP_NOZORDER
;
1001 case SW_SHOWMINNOACTIVE
:
1002 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1004 case SW_SHOWMINIMIZED
:
1005 swp
|= SWP_SHOWWINDOW
;
1008 swp
|= SWP_FRAMECHANGED
;
1009 if( !(wndPtr
->dwStyle
& WS_MINIMIZE
) )
1010 swp
|= WINPOS_MinMaximize( wndPtr
, SW_MINIMIZE
, &newPos
);
1011 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1014 case SW_SHOWMAXIMIZED
: /* same as SW_MAXIMIZE */
1015 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
1016 if( !(wndPtr
->dwStyle
& WS_MAXIMIZE
) )
1017 swp
|= WINPOS_MinMaximize( wndPtr
, SW_MAXIMIZE
, &newPos
);
1018 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1022 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1025 swp
|= SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
;
1028 case SW_SHOWNOACTIVATE
:
1029 swp
|= SWP_NOZORDER
;
1030 if (GetActiveWindow32()) swp
|= SWP_NOACTIVATE
;
1032 case SW_SHOWNORMAL
: /* same as SW_NORMAL: */
1033 case SW_SHOWDEFAULT
: /* FIXME: should have its own handler */
1035 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
1037 if( wndPtr
->dwStyle
& (WS_MINIMIZE
| WS_MAXIMIZE
) )
1038 swp
|= WINPOS_MinMaximize( wndPtr
, SW_RESTORE
, &newPos
);
1039 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1043 showFlag
= (cmd
!= SW_HIDE
);
1044 if (showFlag
!= wasVisible
)
1046 SendMessage32A( hwnd
, WM_SHOWWINDOW
, showFlag
, 0 );
1047 if (!IsWindow32( hwnd
)) return wasVisible
;
1050 if ((wndPtr
->dwStyle
& WS_CHILD
) &&
1051 !IsWindowVisible32( wndPtr
->parent
->hwndSelf
) &&
1052 (swp
& (SWP_NOSIZE
| SWP_NOMOVE
)) == (SWP_NOSIZE
| SWP_NOMOVE
) )
1054 /* Don't call SetWindowPos32() on invisible child windows */
1055 if (cmd
== SW_HIDE
) wndPtr
->dwStyle
&= ~WS_VISIBLE
;
1056 else wndPtr
->dwStyle
|= WS_VISIBLE
;
1060 /* We can't activate a child window */
1061 if (wndPtr
->dwStyle
& WS_CHILD
) swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1062 SetWindowPos32( hwnd
, HWND_TOP
,
1063 newPos
.left
, newPos
.top
, newPos
.right
, newPos
.bottom
, swp
);
1064 if (!IsWindow32( hwnd
)) return wasVisible
;
1065 else if( wndPtr
->dwStyle
& WS_MINIMIZE
) WINPOS_ShowIconTitle( wndPtr
, TRUE
);
1068 if (wndPtr
->flags
& WIN_NEED_SIZE
)
1070 /* should happen only in CreateWindowEx() */
1071 int wParam
= SIZE_RESTORED
;
1073 wndPtr
->flags
&= ~WIN_NEED_SIZE
;
1074 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wParam
= SIZE_MAXIMIZED
;
1075 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= SIZE_MINIMIZED
;
1076 SendMessage32A( hwnd
, WM_SIZE
, wParam
,
1077 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
1078 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
1079 SendMessage32A( hwnd
, WM_MOVE
, 0,
1080 MAKELONG(wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
) );
1087 /***********************************************************************
1088 * GetInternalWindowPos16 (USER.460)
1090 UINT16 WINAPI
GetInternalWindowPos16( HWND16 hwnd
, LPRECT16 rectWnd
,
1093 WINDOWPLACEMENT16 wndpl
;
1094 if (GetWindowPlacement16( hwnd
, &wndpl
))
1096 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1097 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1098 return wndpl
.showCmd
;
1104 /***********************************************************************
1105 * GetInternalWindowPos32 (USER32.244)
1107 UINT32 WINAPI
GetInternalWindowPos32( HWND32 hwnd
, LPRECT32 rectWnd
,
1110 WINDOWPLACEMENT32 wndpl
;
1111 if (GetWindowPlacement32( hwnd
, &wndpl
))
1113 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1114 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1115 return wndpl
.showCmd
;
1120 /***********************************************************************
1121 * GetWindowPlacement16 (USER.370)
1123 BOOL16 WINAPI
GetWindowPlacement16( HWND16 hwnd
, WINDOWPLACEMENT16
*wndpl
)
1125 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
1128 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)WINPOS_InitInternalPos( pWnd
,
1129 *(LPPOINT32
)&pWnd
->rectWindow
.left
, &pWnd
->rectWindow
);
1130 wndpl
->length
= sizeof(*wndpl
);
1131 if( pWnd
->dwStyle
& WS_MINIMIZE
)
1132 wndpl
->showCmd
= SW_SHOWMAXIMIZED
;
1134 wndpl
->showCmd
= ( pWnd
->dwStyle
& WS_MAXIMIZE
)
1135 ? SW_SHOWMINIMIZED
: SW_SHOWNORMAL
;
1136 if( pWnd
->flags
& WIN_RESTORE_MAX
)
1137 wndpl
->flags
= WPF_RESTORETOMAXIMIZED
;
1140 wndpl
->ptMinPosition
= lpPos
->ptIconPos
;
1141 wndpl
->ptMaxPosition
= lpPos
->ptMaxPos
;
1142 wndpl
->rcNormalPosition
= lpPos
->rectNormal
;
1149 /***********************************************************************
1150 * GetWindowPlacement32 (USER32.306)
1152 BOOL32 WINAPI
GetWindowPlacement32( HWND32 hwnd
, WINDOWPLACEMENT32
*pwpl32
)
1156 WINDOWPLACEMENT16 wpl
;
1157 wpl
.length
= sizeof(wpl
);
1158 if( GetWindowPlacement16( hwnd
, &wpl
) )
1160 pwpl32
->length
= sizeof(*pwpl32
);
1161 pwpl32
->flags
= wpl
.flags
;
1162 pwpl32
->showCmd
= wpl
.showCmd
;
1163 CONV_POINT16TO32( &wpl
.ptMinPosition
, &pwpl32
->ptMinPosition
);
1164 CONV_POINT16TO32( &wpl
.ptMaxPosition
, &pwpl32
->ptMaxPosition
);
1165 CONV_RECT16TO32( &wpl
.rcNormalPosition
, &pwpl32
->rcNormalPosition
);
1173 /***********************************************************************
1174 * WINPOS_SetPlacement
1176 static BOOL32
WINPOS_SetPlacement( HWND32 hwnd
, const WINDOWPLACEMENT16
*wndpl
,
1179 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
1182 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)WINPOS_InitInternalPos( pWnd
,
1183 *(LPPOINT32
)&pWnd
->rectWindow
.left
, &pWnd
->rectWindow
);
1185 if( flags
& PLACE_MIN
) lpPos
->ptIconPos
= wndpl
->ptMinPosition
;
1186 if( flags
& PLACE_MAX
) lpPos
->ptMaxPos
= wndpl
->ptMaxPosition
;
1187 if( flags
& PLACE_RECT
) lpPos
->rectNormal
= wndpl
->rcNormalPosition
;
1189 if( pWnd
->dwStyle
& WS_MINIMIZE
)
1191 WINPOS_ShowIconTitle( pWnd
, FALSE
);
1192 if( wndpl
->flags
& WPF_SETMINPOSITION
&& !EMPTYPOINT(lpPos
->ptIconPos
))
1193 SetWindowPos32( hwnd
, 0, lpPos
->ptIconPos
.x
, lpPos
->ptIconPos
.y
,
1194 0, 0, SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1196 else if( pWnd
->dwStyle
& WS_MAXIMIZE
)
1198 if( !EMPTYPOINT(lpPos
->ptMaxPos
) )
1199 SetWindowPos32( hwnd
, 0, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
,
1200 0, 0, SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1202 else if( flags
& PLACE_RECT
)
1203 SetWindowPos32( hwnd
, 0, lpPos
->rectNormal
.left
, lpPos
->rectNormal
.top
,
1204 lpPos
->rectNormal
.right
- lpPos
->rectNormal
.left
,
1205 lpPos
->rectNormal
.bottom
- lpPos
->rectNormal
.top
,
1206 SWP_NOZORDER
| SWP_NOACTIVATE
);
1208 ShowWindow32( hwnd
, wndpl
->showCmd
);
1209 if( IsWindow32(hwnd
) && pWnd
->dwStyle
& WS_MINIMIZE
)
1211 if( pWnd
->dwStyle
& WS_VISIBLE
) WINPOS_ShowIconTitle( pWnd
, TRUE
);
1213 /* SDK: ...valid only the next time... */
1214 if( wndpl
->flags
& WPF_RESTORETOMAXIMIZED
) pWnd
->flags
|= WIN_RESTORE_MAX
;
1222 /***********************************************************************
1223 * SetWindowPlacement16 (USER.371)
1225 BOOL16 WINAPI
SetWindowPlacement16(HWND16 hwnd
, const WINDOWPLACEMENT16
*wndpl
)
1227 return WINPOS_SetPlacement( hwnd
, wndpl
,
1228 PLACE_MIN
| PLACE_MAX
| PLACE_RECT
);
1231 /***********************************************************************
1232 * SetWindowPlacement32 (USER32.518)
1234 BOOL32 WINAPI
SetWindowPlacement32( HWND32 hwnd
, const WINDOWPLACEMENT32
*pwpl32
)
1238 WINDOWPLACEMENT16 wpl
= { sizeof(WINDOWPLACEMENT16
),
1239 pwpl32
->flags
, pwpl32
->showCmd
, { pwpl32
->ptMinPosition
.x
,
1240 pwpl32
->ptMinPosition
.y
}, { pwpl32
->ptMaxPosition
.x
,
1241 pwpl32
->ptMaxPosition
.y
}, { pwpl32
->rcNormalPosition
.left
,
1242 pwpl32
->rcNormalPosition
.top
, pwpl32
->rcNormalPosition
.right
,
1243 pwpl32
->rcNormalPosition
.bottom
} };
1245 return WINPOS_SetPlacement( hwnd
, &wpl
, PLACE_MIN
| PLACE_MAX
| PLACE_RECT
);
1251 /***********************************************************************
1252 * SetInternalWindowPos16 (USER.461)
1254 void WINAPI
SetInternalWindowPos16( HWND16 hwnd
, UINT16 showCmd
,
1255 LPRECT16 rect
, LPPOINT16 pt
)
1257 if( IsWindow16(hwnd
) )
1259 WINDOWPLACEMENT16 wndpl
;
1262 wndpl
.length
= sizeof(wndpl
);
1263 wndpl
.showCmd
= showCmd
;
1264 wndpl
.flags
= flags
= 0;
1269 wndpl
.flags
|= WPF_SETMINPOSITION
;
1270 wndpl
.ptMinPosition
= *pt
;
1274 flags
|= PLACE_RECT
;
1275 wndpl
.rcNormalPosition
= *rect
;
1277 WINPOS_SetPlacement( hwnd
, &wndpl
, flags
);
1282 /***********************************************************************
1283 * SetInternalWindowPos32 (USER32.482)
1285 void WINAPI
SetInternalWindowPos32( HWND32 hwnd
, UINT32 showCmd
,
1286 LPRECT32 rect
, LPPOINT32 pt
)
1288 if( IsWindow32(hwnd
) )
1290 WINDOWPLACEMENT16 wndpl
;
1293 wndpl
.length
= sizeof(wndpl
);
1294 wndpl
.showCmd
= showCmd
;
1295 wndpl
.flags
= flags
= 0;
1300 wndpl
.flags
|= WPF_SETMINPOSITION
;
1301 CONV_POINT32TO16( pt
, &wndpl
.ptMinPosition
);
1305 flags
|= PLACE_RECT
;
1306 CONV_RECT32TO16( rect
, &wndpl
.rcNormalPosition
);
1308 WINPOS_SetPlacement( hwnd
, &wndpl
, flags
);
1313 /***********************************************************************
1314 * WINPOS_ForceXWindowRaise
1316 * Raise a window on top of the X stacking order, while preserving
1317 * the correct Windows Z order.
1319 static void WINPOS_ForceXWindowRaise( WND
* pWnd
)
1321 XWindowChanges winChanges
;
1324 /* Raise all windows up to pWnd according to their Z order.
1325 * (it would be easier with sibling-related Below but it doesn't
1326 * work very well with SGI mwm for instance)
1328 winChanges
.stack_mode
= Above
;
1331 if (pWnd
->window
) XReconfigureWMWindow( display
, pWnd
->window
, 0,
1332 CWStackMode
, &winChanges
);
1333 wndPrev
= WIN_GetDesktop()->child
;
1334 if (wndPrev
== pWnd
) break;
1335 while (wndPrev
&& (wndPrev
->next
!= pWnd
)) wndPrev
= wndPrev
->next
;
1341 /*******************************************************************
1342 * WINPOS_SetActiveWindow
1344 * SetActiveWindow() back-end. This is the only function that
1345 * can assign active status to a window. It must be called only
1346 * for the top level windows.
1348 BOOL32
WINPOS_SetActiveWindow( HWND32 hWnd
, BOOL32 fMouse
, BOOL32 fChangeFocus
)
1350 CBTACTIVATESTRUCT16
* cbtStruct
;
1351 WND
* wndPtr
, *wndTemp
;
1352 HQUEUE16 hOldActiveQueue
, hNewActiveQueue
;
1355 /* paranoid checks */
1356 if( hWnd
== GetDesktopWindow32() || hWnd
== hwndActive
) return 0;
1358 /* if (wndPtr && (GetTaskQueue(0) != wndPtr->hmemTaskQ))
1361 wndPtr
= WIN_FindWndPtr(hWnd
);
1362 hOldActiveQueue
= (pActiveQueue
)?pActiveQueue
->self
: 0;
1364 if( (wndTemp
= WIN_FindWndPtr(hwndActive
)) )
1365 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1367 dprintf_win(stddeb
,"WINPOS_ActivateWindow: no current active window.\n");
1369 /* call CBT hook chain */
1370 if ((cbtStruct
= SEGPTR_NEW(CBTACTIVATESTRUCT16
)))
1373 cbtStruct
->fMouse
= fMouse
;
1374 cbtStruct
->hWndActive
= hwndActive
;
1375 wRet
= HOOK_CallHooks16( WH_CBT
, HCBT_ACTIVATE
, (WPARAM16
)hWnd
,
1376 (LPARAM
)SEGPTR_GET(cbtStruct
) );
1377 SEGPTR_FREE(cbtStruct
);
1378 if (wRet
) return wRet
;
1381 /* set prev active wnd to current active wnd and send notification */
1382 if ((hwndPrevActive
= hwndActive
) && IsWindow32(hwndPrevActive
))
1384 if (!SendMessage32A( hwndPrevActive
, WM_NCACTIVATE
, FALSE
, 0 ))
1386 if (GetSysModalWindow16() != hWnd
) return 0;
1387 /* disregard refusal if hWnd is sysmodal */
1391 SendMessage32A( hwndPrevActive
, WM_ACTIVATE
,
1392 MAKEWPARAM( WA_INACTIVE
, wIconized
),
1395 /* FIXME: must be SendMessage16() because 32A doesn't do
1396 * intertask at this time */
1397 SendMessage16( hwndPrevActive
, WM_ACTIVATE
, WA_INACTIVE
,
1398 MAKELPARAM( (HWND16
)hWnd
, wIconized
) );
1401 /* check if something happened during message processing */
1402 if( hwndPrevActive
!= hwndActive
) return 0;
1405 /* set active wnd */
1408 /* send palette messages */
1409 if (hWnd
&& SendMessage16( hWnd
, WM_QUERYNEWPALETTE
, 0, 0L))
1410 SendMessage16((HWND16
)-1, WM_PALETTEISCHANGING
, (WPARAM16
)hWnd
, 0L );
1412 /* if prev wnd is minimized redraw icon title */
1413 if( IsIconic32( hwndPrevActive
) ) WINPOS_RedrawIconTitle(hwndPrevActive
);
1415 /* managed windows will get ConfigureNotify event */
1416 if (wndPtr
&& !(wndPtr
->dwStyle
& WS_CHILD
) && !(wndPtr
->flags
& WIN_MANAGED
))
1418 /* check Z-order and bring hWnd to the top */
1419 for (wndTemp
= WIN_GetDesktop()->child
; wndTemp
; wndTemp
= wndTemp
->next
)
1420 if (wndTemp
->dwStyle
& WS_VISIBLE
) break;
1422 if( wndTemp
!= wndPtr
)
1423 SetWindowPos32(hWnd
, HWND_TOP
, 0,0,0,0,
1424 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1425 if (!IsWindow32(hWnd
)) return 0;
1428 hNewActiveQueue
= wndPtr
? wndPtr
->hmemTaskQ
: 0;
1430 /* send WM_ACTIVATEAPP if necessary */
1431 if (hOldActiveQueue
!= hNewActiveQueue
)
1433 WND
**list
, **ppWnd
;
1435 if ((list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1437 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1439 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
1441 if ((*ppWnd
)->hmemTaskQ
== hOldActiveQueue
)
1442 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1443 0, QUEUE_GetQueueTask(hNewActiveQueue
) );
1445 HeapFree( SystemHeap
, 0, list
);
1448 pActiveQueue
= (hNewActiveQueue
)
1449 ? (MESSAGEQUEUE
*) GlobalLock16(hNewActiveQueue
) : NULL
;
1451 if ((list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1453 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1455 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
1457 if ((*ppWnd
)->hmemTaskQ
== hNewActiveQueue
)
1458 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1459 1, QUEUE_GetQueueTask( hOldActiveQueue
) );
1461 HeapFree( SystemHeap
, 0, list
);
1463 if (!IsWindow32(hWnd
)) return 0;
1468 /* walk up to the first unowned window */
1470 while (wndTemp
->owner
) wndTemp
= wndTemp
->owner
;
1471 /* and set last active owned popup */
1472 wndTemp
->hwndLastActive
= hWnd
;
1474 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1475 SendMessage32A( hWnd
, WM_NCACTIVATE
, TRUE
, 0 );
1477 SendMessage32A( hWnd
, WM_ACTIVATE
,
1478 MAKEWPARAM( (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
, wIconized
),
1479 (LPARAM
)hwndPrevActive
);
1481 SendMessage16(hWnd
, WM_ACTIVATE
, (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
,
1482 MAKELPARAM( (HWND16
)hwndPrevActive
, wIconized
) );
1485 if( !IsWindow32(hWnd
) ) return 0;
1488 /* change focus if possible */
1489 if( fChangeFocus
&& GetFocus32() )
1490 if( WIN_GetTopParent(GetFocus32()) != hwndActive
)
1491 FOCUS_SwitchFocus( GetFocus32(),
1492 (wndPtr
->dwStyle
& WS_MINIMIZE
)? 0: hwndActive
);
1494 if( !hwndPrevActive
&& wndPtr
&&
1495 wndPtr
->window
&& !(wndPtr
->flags
& WIN_MANAGED
) )
1496 WINPOS_ForceXWindowRaise(wndPtr
);
1498 /* if active wnd is minimized redraw icon title */
1499 if( IsIconic32(hwndActive
) ) WINPOS_RedrawIconTitle(hwndActive
);
1501 return (hWnd
== hwndActive
);
1504 /*******************************************************************
1505 * WINPOS_ActivateOtherWindow
1507 * Activates window other than pWnd.
1509 BOOL32
WINPOS_ActivateOtherWindow(WND
* pWnd
)
1514 if( pWnd
->hwndSelf
== hwndPrevActive
)
1517 if( hwndActive
!= pWnd
->hwndSelf
&&
1518 ( hwndActive
|| QUEUE_IsExitingQueue(pWnd
->hmemTaskQ
)) )
1521 if( !(pWnd
->dwStyle
& WS_POPUP
) || !(pWnd
->owner
) ||
1522 !WINPOS_CanActivate((pWndTo
= WIN_GetTopParentPtr(pWnd
->owner
))) )
1524 WND
* pWndPtr
= WIN_GetTopParentPtr(pWnd
);
1526 pWndTo
= WIN_FindWndPtr(hwndPrevActive
);
1528 while( !WINPOS_CanActivate(pWndTo
) )
1530 /* by now owned windows should've been taken care of */
1532 pWndTo
= pWndPtr
->next
;
1534 if( !pWndTo
) break;
1538 bRet
= WINPOS_SetActiveWindow( pWndTo
? pWndTo
->hwndSelf
: 0, FALSE
, TRUE
);
1540 /* switch desktop queue to current active */
1541 if( pWndTo
) WIN_GetDesktop()->hmemTaskQ
= pWndTo
->hmemTaskQ
;
1547 /*******************************************************************
1548 * WINPOS_ChangeActiveWindow
1551 BOOL32
WINPOS_ChangeActiveWindow( HWND32 hWnd
, BOOL32 mouseMsg
)
1553 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
1555 if (!hWnd
) return WINPOS_SetActiveWindow( 0, mouseMsg
, TRUE
);
1557 if( !wndPtr
) return FALSE
;
1559 /* child windows get WM_CHILDACTIVATE message */
1560 if( (wndPtr
->dwStyle
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
1561 return SendMessage32A(hWnd
, WM_CHILDACTIVATE
, 0, 0L);
1563 /* owned popups imply owner activation - not sure */
1564 if ((wndPtr
->dwStyle
& WS_POPUP
) && wndPtr
->owner
&&
1565 !(wndPtr
->owner
->dwStyle
& WS_DISABLED
))
1567 if (!(wndPtr
= wndPtr
->owner
)) return FALSE
;
1568 hWnd
= wndPtr
->hwndSelf
;
1571 if( hWnd
== hwndActive
) return FALSE
;
1573 if( !WINPOS_SetActiveWindow(hWnd
,mouseMsg
,TRUE
) )
1576 /* switch desktop queue to current active */
1577 if( wndPtr
->parent
== WIN_GetDesktop())
1578 WIN_GetDesktop()->hmemTaskQ
= wndPtr
->hmemTaskQ
;
1584 /***********************************************************************
1585 * WINPOS_SendNCCalcSize
1587 * Send a WM_NCCALCSIZE message to a window.
1588 * All parameters are read-only except newClientRect.
1589 * oldWindowRect, oldClientRect and winpos must be non-NULL only
1590 * when calcValidRect is TRUE.
1592 LONG
WINPOS_SendNCCalcSize( HWND32 hwnd
, BOOL32 calcValidRect
,
1593 RECT32
*newWindowRect
, RECT32
*oldWindowRect
,
1594 RECT32
*oldClientRect
, WINDOWPOS32
*winpos
,
1595 RECT32
*newClientRect
)
1597 NCCALCSIZE_PARAMS32 params
;
1600 params
.rgrc
[0] = *newWindowRect
;
1603 params
.rgrc
[1] = *oldWindowRect
;
1604 params
.rgrc
[2] = *oldClientRect
;
1605 params
.lppos
= winpos
;
1607 result
= SendMessage32A( hwnd
, WM_NCCALCSIZE
, calcValidRect
,
1609 dprintf_win( stddeb
, "WINPOS_SendNCCalcSize: %d,%d-%d,%d\n",
1610 params
.rgrc
[0].left
, params
.rgrc
[0].top
,
1611 params
.rgrc
[0].right
, params
.rgrc
[0].bottom
);
1612 *newClientRect
= params
.rgrc
[0];
1617 /***********************************************************************
1618 * WINPOS_HandleWindowPosChanging16
1620 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1622 LONG
WINPOS_HandleWindowPosChanging16( WND
*wndPtr
, WINDOWPOS16
*winpos
)
1624 POINT32 maxSize
, minTrack
;
1625 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1626 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1627 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1629 WINPOS_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, &minTrack
, NULL
);
1630 if (maxSize
.x
< winpos
->cx
) winpos
->cx
= maxSize
.x
;
1631 if (maxSize
.y
< winpos
->cy
) winpos
->cy
= maxSize
.y
;
1632 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
1634 if (winpos
->cx
< minTrack
.x
) winpos
->cx
= minTrack
.x
;
1635 if (winpos
->cy
< minTrack
.y
) winpos
->cy
= minTrack
.y
;
1642 /***********************************************************************
1643 * WINPOS_HandleWindowPosChanging32
1645 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1647 LONG
WINPOS_HandleWindowPosChanging32( WND
*wndPtr
, WINDOWPOS32
*winpos
)
1650 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1651 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1652 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1654 WINPOS_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, NULL
, NULL
);
1655 winpos
->cx
= MIN( winpos
->cx
, maxSize
.x
);
1656 winpos
->cy
= MIN( winpos
->cy
, maxSize
.y
);
1662 /***********************************************************************
1663 * WINPOS_MoveWindowZOrder
1665 * Move a window in Z order, invalidating everything that needs it.
1666 * Only necessary for windows without associated X window.
1668 static void WINPOS_MoveWindowZOrder( HWND32 hwnd
, HWND32 hwndAfter
)
1671 WND
*pWndAfter
, *pWndCur
, *wndPtr
= WIN_FindWndPtr( hwnd
);
1673 /* We have two possible cases:
1674 * - The window is moving up: we have to invalidate all areas
1675 * of the window that were covered by other windows
1676 * - The window is moving down: we have to invalidate areas
1677 * of other windows covered by this one.
1680 if (hwndAfter
== HWND_TOP
)
1684 else if (hwndAfter
== HWND_BOTTOM
)
1686 if (!wndPtr
->next
) return; /* Already at the bottom */
1691 if (!(pWndAfter
= WIN_FindWndPtr( hwndAfter
))) return;
1692 if (wndPtr
->next
== pWndAfter
) return; /* Already placed right */
1694 /* Determine which window we encounter first in Z-order */
1695 pWndCur
= wndPtr
->parent
->child
;
1696 while ((pWndCur
!= wndPtr
) && (pWndCur
!= pWndAfter
))
1697 pWndCur
= pWndCur
->next
;
1698 movingUp
= (pWndCur
== pWndAfter
);
1703 WND
*pWndPrevAfter
= wndPtr
->next
;
1704 WIN_UnlinkWindow( hwnd
);
1705 WIN_LinkWindow( hwnd
, hwndAfter
);
1706 pWndCur
= wndPtr
->next
;
1707 while (pWndCur
!= pWndPrevAfter
)
1709 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1710 pWndCur
->rectWindow
.top
,
1711 pWndCur
->rectWindow
.right
,
1712 pWndCur
->rectWindow
.bottom
};
1713 OffsetRect32( &rect
, -wndPtr
->rectClient
.left
,
1714 -wndPtr
->rectClient
.top
);
1715 PAINT_RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
1716 RDW_FRAME
| RDW_ERASE
, 0 );
1717 pWndCur
= pWndCur
->next
;
1720 else /* Moving down */
1722 pWndCur
= wndPtr
->next
;
1723 WIN_UnlinkWindow( hwnd
);
1724 WIN_LinkWindow( hwnd
, hwndAfter
);
1725 while (pWndCur
!= wndPtr
)
1727 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1728 pWndCur
->rectWindow
.top
,
1729 pWndCur
->rectWindow
.right
,
1730 pWndCur
->rectWindow
.bottom
};
1731 OffsetRect32( &rect
, -pWndCur
->rectClient
.left
,
1732 -pWndCur
->rectClient
.top
);
1733 PAINT_RedrawWindow( pWndCur
->hwndSelf
, &rect
, 0, RDW_INVALIDATE
|
1734 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
1735 pWndCur
= pWndCur
->next
;
1740 /***********************************************************************
1741 * WINPOS_ReorderOwnedPopups
1743 * fix Z order taking into account owned popups -
1744 * basically we need to maintain them above owner window
1746 HWND32
WINPOS_ReorderOwnedPopups(HWND32 hwndInsertAfter
,WND
* wndPtr
,WORD flags
)
1748 WND
* w
= WIN_GetDesktop()->child
;
1750 if( wndPtr
->dwStyle
& WS_POPUP
&& wndPtr
->owner
)
1752 /* implement "local z-order" between the top and owner window */
1754 HWND32 hwndLocalPrev
= HWND_TOP
;
1756 if( hwndInsertAfter
!= HWND_TOP
)
1758 while( w
!= wndPtr
->owner
)
1760 if (w
!= wndPtr
) hwndLocalPrev
= w
->hwndSelf
;
1761 if( hwndLocalPrev
== hwndInsertAfter
) break;
1764 hwndInsertAfter
= hwndLocalPrev
;
1768 else if( wndPtr
->dwStyle
& WS_CHILD
) return hwndInsertAfter
;
1770 w
= WIN_GetDesktop()->child
;
1773 if( w
== wndPtr
) break;
1775 if( w
->dwStyle
& WS_POPUP
&& w
->owner
== wndPtr
)
1777 SetWindowPos32(w
->hwndSelf
, hwndInsertAfter
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
|
1778 SWP_NOACTIVATE
| SWP_NOSENDCHANGING
| SWP_DEFERERASE
);
1779 hwndInsertAfter
= w
->hwndSelf
;
1784 return hwndInsertAfter
;
1787 /***********************************************************************
1788 * WINPOS_SizeMoveClean
1790 * Make window look nice without excessive repainting
1794 * visible regions are in window coordinates
1795 * update regions are in window client coordinates
1796 * client and window rectangles are in parent client coordinates
1798 * FIXME: Move visible and update regions to the same coordinate system
1799 * (either parent client or window). This is a lot of work though.
1801 static UINT32
WINPOS_SizeMoveClean( WND
* Wnd
, HRGN32 oldVisRgn
,
1802 LPRECT32 lpOldWndRect
,
1803 LPRECT32 lpOldClientRect
, UINT32 uFlags
)
1805 HRGN32 newVisRgn
= DCE_GetVisRgn(Wnd
->hwndSelf
,DCX_WINDOW
| DCX_CLIPSIBLINGS
);
1806 HRGN32 dirtyRgn
= CreateRectRgn32(0,0,0,0);
1809 dprintf_win(stddeb
,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n\
1810 \t\tnew client=(%i %i-%i %i) old client=(%i %i-%i %i)\n",
1811 Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
,
1812 Wnd
->rectWindow
.right
, Wnd
->rectWindow
.bottom
,
1813 lpOldWndRect
->left
, lpOldWndRect
->top
,
1814 lpOldWndRect
->right
, lpOldWndRect
->bottom
,
1815 Wnd
->rectClient
.left
, Wnd
->rectClient
.top
,
1816 Wnd
->rectClient
.right
, Wnd
->rectClient
.bottom
,
1817 lpOldClientRect
->left
, lpOldClientRect
->top
,
1818 lpOldClientRect
->right
,lpOldClientRect
->bottom
);
1820 if( (lpOldWndRect
->right
- lpOldWndRect
->left
) != (Wnd
->rectWindow
.right
- Wnd
->rectWindow
.left
) ||
1821 (lpOldWndRect
->bottom
- lpOldWndRect
->top
) != (Wnd
->rectWindow
.bottom
- Wnd
->rectWindow
.top
) )
1822 uFlags
|= SMC_DRAWFRAME
;
1824 CombineRgn32( dirtyRgn
, newVisRgn
, 0, RGN_COPY
);
1826 if( !(uFlags
& SMC_NOCOPY
) )
1827 CombineRgn32( newVisRgn
, newVisRgn
, oldVisRgn
, RGN_AND
);
1829 /* map regions to the parent client area */
1831 OffsetRgn32( dirtyRgn
, Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
);
1832 OffsetRgn32( oldVisRgn
, lpOldWndRect
->left
, lpOldWndRect
->top
);
1834 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1836 other
= CombineRgn32(dirtyRgn
, oldVisRgn
, dirtyRgn
, RGN_DIFF
);
1838 /* map visible region to the Wnd client area */
1840 OffsetRgn32( newVisRgn
, Wnd
->rectWindow
.left
- Wnd
->rectClient
.left
,
1841 Wnd
->rectWindow
.top
- Wnd
->rectClient
.top
);
1843 /* substract previously invalidated region from the Wnd visible region */
1845 my
= (Wnd
->hrgnUpdate
> 1) ? CombineRgn32( newVisRgn
, newVisRgn
,
1846 Wnd
->hrgnUpdate
, RGN_DIFF
)
1849 if( uFlags
& SMC_NOCOPY
) /* invalidate Wnd visible region */
1851 if (my
!= NULLREGION
)
1852 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, newVisRgn
, RDW_INVALIDATE
|
1853 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1854 else if(uFlags
& SMC_DRAWFRAME
)
1855 Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1857 else /* bitblt old client area */
1862 int xfrom
,yfrom
,xto
,yto
,width
,height
;
1864 if( uFlags
& SMC_DRAWFRAME
)
1866 /* copy only client area, frame will be redrawn anyway */
1868 xfrom
= lpOldClientRect
->left
; yfrom
= lpOldClientRect
->top
;
1869 xto
= Wnd
->rectClient
.left
; yto
= Wnd
->rectClient
.top
;
1870 width
= lpOldClientRect
->right
- xfrom
; height
= lpOldClientRect
->bottom
- yfrom
;
1871 updateRgn
= CreateRectRgn32( 0, 0, width
, height
);
1872 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1873 SetRectRgn32( updateRgn
, 0, 0, Wnd
->rectClient
.right
- xto
,
1874 Wnd
->rectClient
.bottom
- yto
);
1878 xfrom
= lpOldWndRect
->left
; yfrom
= lpOldWndRect
->top
;
1879 xto
= Wnd
->rectWindow
.left
; yto
= Wnd
->rectWindow
.top
;
1880 width
= lpOldWndRect
->right
- xfrom
; height
= lpOldWndRect
->bottom
- yfrom
;
1881 updateRgn
= CreateRectRgn32( xto
- Wnd
->rectClient
.left
,
1882 yto
- Wnd
->rectClient
.top
,
1883 Wnd
->rectWindow
.right
- Wnd
->rectClient
.left
,
1884 Wnd
->rectWindow
.bottom
- Wnd
->rectClient
.top
);
1887 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1889 /* substract new visRgn from target rect to get a region that won't be copied */
1891 update
= CombineRgn32( updateRgn
, updateRgn
, newVisRgn
, RGN_DIFF
);
1893 /* Blt valid bits using parent window DC */
1895 if( my
!= NULLREGION
&& (xfrom
!= xto
|| yfrom
!= yto
) )
1898 /* compute clipping region in parent client coordinates */
1900 OffsetRgn32( newVisRgn
, Wnd
->rectClient
.left
, Wnd
->rectClient
.top
);
1901 CombineRgn32( oldVisRgn
, oldVisRgn
, newVisRgn
, RGN_OR
);
1903 hDC
= GetDCEx32( Wnd
->parent
->hwndSelf
, oldVisRgn
,
1904 DCX_KEEPCLIPRGN
| DCX_INTERSECTRGN
|
1905 DCX_CACHE
| DCX_CLIPSIBLINGS
);
1907 BitBlt32( hDC
, xto
, yto
, width
, height
, hDC
, xfrom
, yfrom
, SRCCOPY
);
1908 ReleaseDC32( Wnd
->parent
->hwndSelf
, hDC
);
1911 if( update
!= NULLREGION
)
1912 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, updateRgn
, RDW_INVALIDATE
|
1913 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1914 else if( uFlags
& SMC_DRAWFRAME
) Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1915 DeleteObject32( updateRgn
);
1918 /* erase uncovered areas */
1920 if( !(uFlags
& SMC_NOPARENTERASE
) && (other
!= NULLREGION
) )
1921 PAINT_RedrawWindow( Wnd
->parent
->hwndSelf
, NULL
, dirtyRgn
,
1922 RDW_INVALIDATE
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1923 DeleteObject32(dirtyRgn
);
1924 DeleteObject32(newVisRgn
);
1929 /***********************************************************************
1930 * WINPOS_FindDeskTopXWindow
1932 * Find the actual X window which needs be restacked.
1933 * Used by WINPOS_SetXWindowPos().
1935 static Window
WINPOS_FindDeskTopXWindow( WND
*wndPtr
)
1937 if (!(wndPtr
->flags
& WIN_MANAGED
))
1938 return wndPtr
->window
;
1941 Window window
, root
, parent
, *children
;
1943 window
= wndPtr
->window
;
1946 XQueryTree( display
, window
, &root
, &parent
,
1947 &children
, &nchildren
);
1956 /***********************************************************************
1957 * WINPOS_SetXWindowPos
1959 * SetWindowPos() for an X window. Used by the real SetWindowPos().
1961 static void WINPOS_SetXWindowPos( const WINDOWPOS32
*winpos
)
1963 XWindowChanges winChanges
;
1965 WND
*wndPtr
= WIN_FindWndPtr( winpos
->hwnd
);
1967 if (!(winpos
->flags
& SWP_NOSIZE
))
1969 winChanges
.width
= winpos
->cx
;
1970 winChanges
.height
= winpos
->cy
;
1971 changeMask
|= CWWidth
| CWHeight
;
1973 /* Tweak dialog window size hints */
1975 if ((wndPtr
->flags
& WIN_MANAGED
) &&
1976 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
1978 XSizeHints
*size_hints
= XAllocSizeHints();
1982 long supplied_return
;
1984 XGetWMSizeHints( display
, wndPtr
->window
, size_hints
,
1985 &supplied_return
, XA_WM_NORMAL_HINTS
);
1986 size_hints
->min_width
= size_hints
->max_width
= winpos
->cx
;
1987 size_hints
->min_height
= size_hints
->max_height
= winpos
->cy
;
1988 XSetWMSizeHints( display
, wndPtr
->window
, size_hints
,
1989 XA_WM_NORMAL_HINTS
);
1994 if (!(winpos
->flags
& SWP_NOMOVE
))
1996 winChanges
.x
= winpos
->x
;
1997 winChanges
.y
= winpos
->y
;
1998 changeMask
|= CWX
| CWY
;
2000 if (!(winpos
->flags
& SWP_NOZORDER
))
2002 winChanges
.stack_mode
= Below
;
2003 changeMask
|= CWStackMode
;
2005 if (winpos
->hwndInsertAfter
== HWND_TOP
) winChanges
.stack_mode
= Above
;
2006 else if (winpos
->hwndInsertAfter
!= HWND_BOTTOM
)
2008 WND
* insertPtr
= WIN_FindWndPtr( winpos
->hwndInsertAfter
);
2011 stack
[0] = WINPOS_FindDeskTopXWindow( insertPtr
);
2012 stack
[1] = WINPOS_FindDeskTopXWindow( wndPtr
);
2014 /* for stupid window managers (i.e. all of them) */
2016 XRestackWindows(display
, stack
, 2);
2017 changeMask
&= ~CWStackMode
;
2020 if (!changeMask
) return;
2022 XReconfigureWMWindow( display
, wndPtr
->window
, 0, changeMask
, &winChanges
);
2026 /***********************************************************************
2027 * SetWindowPos (USER.232)
2029 BOOL16 WINAPI
SetWindowPos16( HWND16 hwnd
, HWND16 hwndInsertAfter
,
2030 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, WORD flags
)
2032 return SetWindowPos32(hwnd
,(INT32
)(INT16
)hwndInsertAfter
,x
,y
,cx
,cy
,flags
);
2035 /***********************************************************************
2036 * SetWindowPos (USER32.519)
2038 BOOL32 WINAPI
SetWindowPos32( HWND32 hwnd
, HWND32 hwndInsertAfter
,
2039 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
, WORD flags
)
2043 RECT32 newWindowRect
, newClientRect
, oldWindowRect
;
2045 HWND32 tempInsertAfter
= 0;
2049 dprintf_win(stddeb
,"SetWindowPos: hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
2050 hwnd
, x
, y
, x
+cx
, y
+cy
, flags
);
2051 /* Check window handle */
2053 if (hwnd
== GetDesktopWindow32()) return FALSE
;
2054 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return FALSE
;
2056 if (wndPtr
->dwStyle
& WS_VISIBLE
) flags
&= ~SWP_SHOWWINDOW
;
2059 uFlags
|= SMC_NOPARENTERASE
;
2060 flags
&= ~SWP_HIDEWINDOW
;
2061 if (!(flags
& SWP_SHOWWINDOW
)) flags
|= SWP_NOREDRAW
;
2064 /* Check for windows that may not be resized
2065 FIXME: this should be done only for Windows 3.0 programs
2066 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
2067 flags |= SWP_NOSIZE | SWP_NOMOVE;
2069 /* Check dimensions */
2071 if (cx
<= 0) cx
= 1;
2072 if (cy
<= 0) cy
= 1;
2076 if (hwnd
== hwndActive
) flags
|= SWP_NOACTIVATE
; /* Already active */
2077 if ((wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
== cx
) &&
2078 (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
== cy
))
2079 flags
|= SWP_NOSIZE
; /* Already the right size */
2080 if ((wndPtr
->rectWindow
.left
== x
) && (wndPtr
->rectWindow
.top
== y
))
2081 flags
|= SWP_NOMOVE
; /* Already the right position */
2083 /* Check hwndInsertAfter */
2085 if (!(flags
& (SWP_NOZORDER
| SWP_NOACTIVATE
)))
2087 /* Ignore TOPMOST flags when activating a window */
2088 /* _and_ moving it in Z order. */
2089 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
2090 (hwndInsertAfter
== HWND_NOTOPMOST
))
2091 hwndInsertAfter
= HWND_TOP
;
2093 /* TOPMOST not supported yet */
2094 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
2095 (hwndInsertAfter
== HWND_NOTOPMOST
)) hwndInsertAfter
= HWND_TOP
;
2097 /* hwndInsertAfter must be a sibling of the window */
2098 if ((hwndInsertAfter
!= HWND_TOP
) && (hwndInsertAfter
!= HWND_BOTTOM
))
2100 WND
* wnd
= WIN_FindWndPtr(hwndInsertAfter
);
2101 if( wnd
->parent
!= wndPtr
->parent
) return FALSE
;
2102 if( wnd
->next
== wndPtr
) flags
|= SWP_NOZORDER
;
2104 else if (!(wndPtr
->window
))
2105 /* FIXME: the following optimization is no good for "X-ed" windows */
2106 if (hwndInsertAfter
== HWND_TOP
)
2107 flags
|= ( wndPtr
->parent
->child
== wndPtr
)? SWP_NOZORDER
: 0;
2108 else /* HWND_BOTTOM */
2109 flags
|= ( wndPtr
->next
)? 0: SWP_NOZORDER
;
2111 /* Fill the WINDOWPOS structure */
2114 winpos
.hwndInsertAfter
= hwndInsertAfter
;
2119 winpos
.flags
= flags
;
2121 /* Send WM_WINDOWPOSCHANGING message */
2123 if (!(flags
& SWP_NOSENDCHANGING
))
2124 SendMessage32A( hwnd
, WM_WINDOWPOSCHANGING
, 0, (LPARAM
)&winpos
);
2126 /* Calculate new position and size */
2128 newWindowRect
= wndPtr
->rectWindow
;
2129 newClientRect
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? wndPtr
->rectWindow
2130 : wndPtr
->rectClient
;
2132 if (!(winpos
.flags
& SWP_NOSIZE
))
2134 newWindowRect
.right
= newWindowRect
.left
+ winpos
.cx
;
2135 newWindowRect
.bottom
= newWindowRect
.top
+ winpos
.cy
;
2137 if (!(winpos
.flags
& SWP_NOMOVE
))
2139 newWindowRect
.left
= winpos
.x
;
2140 newWindowRect
.top
= winpos
.y
;
2141 newWindowRect
.right
+= winpos
.x
- wndPtr
->rectWindow
.left
;
2142 newWindowRect
.bottom
+= winpos
.y
- wndPtr
->rectWindow
.top
;
2144 OffsetRect32( &newClientRect
, winpos
.x
- wndPtr
->rectWindow
.left
,
2145 winpos
.y
- wndPtr
->rectWindow
.top
);
2148 winpos
.flags
|= SWP_NOCLIENTMOVE
| SWP_NOCLIENTSIZE
;
2150 /* Reposition window in Z order */
2152 if (!(winpos
.flags
& SWP_NOZORDER
))
2154 /* reorder owned popups if hwnd is top-level window
2156 if( wndPtr
->parent
== WIN_GetDesktop() )
2157 hwndInsertAfter
= WINPOS_ReorderOwnedPopups( hwndInsertAfter
,
2162 WIN_UnlinkWindow( winpos
.hwnd
);
2163 WIN_LinkWindow( winpos
.hwnd
, hwndInsertAfter
);
2165 else WINPOS_MoveWindowZOrder( winpos
.hwnd
, hwndInsertAfter
);
2168 if ( !wndPtr
->window
&& !(flags
& SWP_NOREDRAW
) &&
2169 (!(flags
& SWP_NOMOVE
) || !(flags
& SWP_NOSIZE
) || (flags
& SWP_FRAMECHANGED
)) )
2170 visRgn
= DCE_GetVisRgn(hwnd
, DCX_WINDOW
| DCX_CLIPSIBLINGS
);
2173 /* Send WM_NCCALCSIZE message to get new client area */
2174 if( (flags
& (SWP_FRAMECHANGED
| SWP_NOSIZE
)) != SWP_NOSIZE
)
2176 result
= WINPOS_SendNCCalcSize( winpos
.hwnd
, TRUE
, &newWindowRect
,
2177 &wndPtr
->rectWindow
, &wndPtr
->rectClient
,
2178 &winpos
, &newClientRect
);
2180 /* FIXME: WVR_ALIGNxxx */
2182 if( newClientRect
.left
!= wndPtr
->rectClient
.left
||
2183 newClientRect
.top
!= wndPtr
->rectClient
.top
)
2184 winpos
.flags
&= ~SWP_NOCLIENTMOVE
;
2186 if( (newClientRect
.right
- newClientRect
.left
!=
2187 wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
) ||
2188 (newClientRect
.bottom
- newClientRect
.top
!=
2189 wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
) )
2190 winpos
.flags
&= ~SWP_NOCLIENTSIZE
;
2193 if( !(flags
& SWP_NOMOVE
) && (newClientRect
.left
!= wndPtr
->rectClient
.left
||
2194 newClientRect
.top
!= wndPtr
->rectClient
.top
) )
2195 winpos
.flags
&= ~SWP_NOCLIENTMOVE
;
2197 /* Update active DCEs */
2199 if( !(flags
& SWP_NOZORDER
) || (flags
& SWP_HIDEWINDOW
) || (flags
& SWP_SHOWWINDOW
)
2200 || (memcmp(&newWindowRect
,&wndPtr
->rectWindow
,sizeof(newWindowRect
))
2201 && wndPtr
->dwStyle
& WS_VISIBLE
) )
2205 UnionRect32(&rect
,&newWindowRect
,&wndPtr
->rectWindow
);
2206 DCE_InvalidateDCE(wndPtr
->parent
, &rect
);
2209 /* change geometry */
2211 oldWindowRect
= wndPtr
->rectWindow
;
2215 RECT32 oldClientRect
= wndPtr
->rectClient
;
2217 tempInsertAfter
= winpos
.hwndInsertAfter
;
2219 winpos
.hwndInsertAfter
= hwndInsertAfter
;
2221 /* postpone geometry change */
2223 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
2225 WINPOS_SetXWindowPos( &winpos
);
2226 winpos
.hwndInsertAfter
= tempInsertAfter
;
2228 else uFlags
|= SMC_SETXPOS
;
2230 wndPtr
->rectWindow
= newWindowRect
;
2231 wndPtr
->rectClient
= newClientRect
;
2233 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
2234 if( (oldClientRect
.left
- oldWindowRect
.left
!=
2235 newClientRect
.left
- newWindowRect
.left
) ||
2236 (oldClientRect
.top
- oldWindowRect
.top
!=
2237 newClientRect
.top
- newWindowRect
.top
) ||
2238 winpos
.flags
& SWP_NOCOPYBITS
)
2240 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, RDW_INVALIDATE
|
2241 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
2243 if( winpos
.flags
& SWP_FRAMECHANGED
)
2248 if( oldClientRect
.right
> newClientRect
.right
)
2250 rect
.left
= newClientRect
.right
; rect
.top
= newClientRect
.top
;
2251 rect
.right
= oldClientRect
.right
; rect
.bottom
= newClientRect
.bottom
;
2253 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
2254 RDW_INVALIDATE
| RDW_FRAME
| RDW_ALLCHILDREN
, 0 );
2256 if( oldClientRect
.bottom
> newClientRect
.bottom
)
2258 rect
.left
= newClientRect
.left
; rect
.top
= newClientRect
.bottom
;
2259 rect
.right
= (wErase
)?oldClientRect
.right
:newClientRect
.right
;
2260 rect
.bottom
= oldClientRect
.bottom
;
2262 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
2263 RDW_INVALIDATE
| RDW_FRAME
| RDW_ALLCHILDREN
, 0 );
2265 if( !wErase
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
2270 RECT32 oldClientRect
= wndPtr
->rectClient
;
2272 wndPtr
->rectWindow
= newWindowRect
;
2273 wndPtr
->rectClient
= newClientRect
;
2275 if( oldClientRect
.bottom
- oldClientRect
.top
==
2276 newClientRect
.bottom
- newClientRect
.top
) result
&= ~WVR_VREDRAW
;
2278 if( oldClientRect
.right
- oldClientRect
.left
==
2279 newClientRect
.right
- newClientRect
.left
) result
&= ~WVR_HREDRAW
;
2281 if( !(flags
& (SWP_NOREDRAW
| SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
2283 uFlags
|= ((winpos
.flags
& SWP_NOCOPYBITS
) ||
2284 (result
>= WVR_HREDRAW
&& result
< WVR_VALIDRECTS
)) ? SMC_NOCOPY
: 0;
2285 uFlags
|= (winpos
.flags
& SWP_FRAMECHANGED
) ? SMC_DRAWFRAME
: 0;
2287 if( (winpos
.flags
& SWP_AGG_NOGEOMETRYCHANGE
) != SWP_AGG_NOGEOMETRYCHANGE
)
2288 uFlags
= WINPOS_SizeMoveClean(wndPtr
, visRgn
, &oldWindowRect
,
2289 &oldClientRect
, uFlags
);
2292 /* adjust frame and do not erase parent */
2294 if( winpos
.flags
& SWP_FRAMECHANGED
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
2295 if( winpos
.flags
& SWP_NOZORDER
) uFlags
|= SMC_NOPARENTERASE
;
2298 DeleteObject32(visRgn
);
2301 if (flags
& SWP_SHOWWINDOW
)
2303 wndPtr
->dwStyle
|= WS_VISIBLE
;
2306 if( uFlags
& SMC_SETXPOS
)
2308 WINPOS_SetXWindowPos( &winpos
);
2309 winpos
.hwndInsertAfter
= tempInsertAfter
;
2311 XMapWindow( display
, wndPtr
->window
);
2315 if (!(flags
& SWP_NOREDRAW
))
2316 PAINT_RedrawWindow( winpos
.hwnd
, NULL
, 0,
2317 RDW_INVALIDATE
| RDW_ALLCHILDREN
|
2318 RDW_FRAME
| RDW_ERASENOW
| RDW_ERASE
, 0 );
2321 else if (flags
& SWP_HIDEWINDOW
)
2323 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
2326 XUnmapWindow( display
, wndPtr
->window
);
2327 if( uFlags
& SMC_SETXPOS
)
2329 WINPOS_SetXWindowPos( &winpos
);
2330 winpos
.hwndInsertAfter
= tempInsertAfter
;
2335 if (!(flags
& SWP_NOREDRAW
))
2336 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, &oldWindowRect
,
2337 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
2338 RDW_ERASE
| RDW_ERASENOW
, 0 );
2339 uFlags
|= SMC_NOPARENTERASE
;
2342 if ((winpos
.hwnd
== GetFocus32()) ||
2343 IsChild32( winpos
.hwnd
, GetFocus32()))
2345 /* Revert focus to parent */
2346 SetFocus32( GetParent32(winpos
.hwnd
) );
2348 if (hwnd
== CARET_GetHwnd()) DestroyCaret32();
2350 if (winpos
.hwnd
== hwndActive
)
2351 WINPOS_ActivateOtherWindow( wndPtr
);
2354 /* Activate the window */
2356 if (!(flags
& SWP_NOACTIVATE
))
2357 WINPOS_ChangeActiveWindow( winpos
.hwnd
, FALSE
);
2359 /* Repaint the window */
2361 if (wndPtr
->window
) EVENT_Synchronize(); /* Wait for all expose events */
2363 if (!GetCapture32())
2364 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
2366 if (!(flags
& SWP_DEFERERASE
) && !(uFlags
& SMC_NOPARENTERASE
) )
2368 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
,
2369 (wndPtr
->flags
& WIN_SAVEUNDER_OVERRIDE
) ? &oldWindowRect
: NULL
,
2370 0, RDW_ALLCHILDREN
| RDW_ERASENOW
|
2371 ((wndPtr
->flags
& WIN_SAVEUNDER_OVERRIDE
) ? RDW_INVALIDATE
: 0), 0 );
2372 wndPtr
->flags
&= ~WIN_SAVEUNDER_OVERRIDE
;
2374 else if( wndPtr
->parent
== WIN_GetDesktop() && wndPtr
->parent
->flags
& WIN_NEEDS_ERASEBKGND
)
2375 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_NOCHILDREN
| RDW_ERASENOW
, 0 );
2377 /* And last, send the WM_WINDOWPOSCHANGED message */
2379 dprintf_win(stddeb
,"\tstatus flags = %04x\n", winpos
.flags
& SWP_AGG_STATUSFLAGS
);
2381 if ( ((winpos
.flags
& SWP_AGG_STATUSFLAGS
) != SWP_AGG_NOPOSCHANGE
) &&
2382 !(winpos
.flags
& SWP_NOSENDCHANGING
))
2383 SendMessage32A( winpos
.hwnd
, WM_WINDOWPOSCHANGED
,
2384 0, (LPARAM
)&winpos
);
2390 /***********************************************************************
2391 * BeginDeferWindowPos16 (USER.259)
2393 HDWP16 WINAPI
BeginDeferWindowPos16( INT16 count
)
2395 return BeginDeferWindowPos32( count
);
2399 /***********************************************************************
2400 * BeginDeferWindowPos32 (USER32.8)
2402 HDWP32 WINAPI
BeginDeferWindowPos32( INT32 count
)
2407 if (count
<= 0) return 0;
2408 handle
= USER_HEAP_ALLOC( sizeof(DWP
) + (count
-1)*sizeof(WINDOWPOS32
) );
2409 if (!handle
) return 0;
2410 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( handle
);
2411 pDWP
->actualCount
= 0;
2412 pDWP
->suggestedCount
= count
;
2414 pDWP
->wMagic
= DWP_MAGIC
;
2415 pDWP
->hwndParent
= 0;
2420 /***********************************************************************
2421 * DeferWindowPos16 (USER.260)
2423 HDWP16 WINAPI
DeferWindowPos16( HDWP16 hdwp
, HWND16 hwnd
, HWND16 hwndAfter
,
2424 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
2427 return DeferWindowPos32( hdwp
, hwnd
, (INT32
)(INT16
)hwndAfter
,
2428 x
, y
, cx
, cy
, flags
);
2432 /***********************************************************************
2433 * DeferWindowPos32 (USER32.127)
2435 HDWP32 WINAPI
DeferWindowPos32( HDWP32 hdwp
, HWND32 hwnd
, HWND32 hwndAfter
,
2436 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
2441 HDWP32 newhdwp
= hdwp
;
2445 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2446 if (!pDWP
) return 0;
2447 if (hwnd
== GetDesktopWindow32()) return 0;
2449 /* All the windows of a DeferWindowPos() must have the same parent */
2450 if (!(pWnd
=WIN_FindWndPtr( hwnd
))) {
2451 USER_HEAP_FREE( hdwp
);
2455 parent
= pWnd
->parent
->hwndSelf
;
2456 if (pDWP
->actualCount
== 0) pDWP
->hwndParent
= parent
;
2457 else if (parent
!= pDWP
->hwndParent
)
2459 USER_HEAP_FREE( hdwp
);
2463 for (i
= 0; i
< pDWP
->actualCount
; i
++)
2465 if (pDWP
->winPos
[i
].hwnd
== hwnd
)
2467 /* Merge with the other changes */
2468 if (!(flags
& SWP_NOZORDER
))
2470 pDWP
->winPos
[i
].hwndInsertAfter
= hwndAfter
;
2472 if (!(flags
& SWP_NOMOVE
))
2474 pDWP
->winPos
[i
].x
= x
;
2475 pDWP
->winPos
[i
].y
= y
;
2477 if (!(flags
& SWP_NOSIZE
))
2479 pDWP
->winPos
[i
].cx
= cx
;
2480 pDWP
->winPos
[i
].cy
= cy
;
2482 pDWP
->winPos
[i
].flags
&= flags
| ~(SWP_NOSIZE
| SWP_NOMOVE
|
2483 SWP_NOZORDER
| SWP_NOREDRAW
|
2484 SWP_NOACTIVATE
| SWP_NOCOPYBITS
|
2486 pDWP
->winPos
[i
].flags
|= flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
|
2491 if (pDWP
->actualCount
>= pDWP
->suggestedCount
)
2493 newhdwp
= USER_HEAP_REALLOC( hdwp
,
2494 sizeof(DWP
) + pDWP
->suggestedCount
*sizeof(WINDOWPOS32
) );
2495 if (!newhdwp
) return 0;
2496 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( newhdwp
);
2497 pDWP
->suggestedCount
++;
2499 pDWP
->winPos
[pDWP
->actualCount
].hwnd
= hwnd
;
2500 pDWP
->winPos
[pDWP
->actualCount
].hwndInsertAfter
= hwndAfter
;
2501 pDWP
->winPos
[pDWP
->actualCount
].x
= x
;
2502 pDWP
->winPos
[pDWP
->actualCount
].y
= y
;
2503 pDWP
->winPos
[pDWP
->actualCount
].cx
= cx
;
2504 pDWP
->winPos
[pDWP
->actualCount
].cy
= cy
;
2505 pDWP
->winPos
[pDWP
->actualCount
].flags
= flags
;
2506 pDWP
->actualCount
++;
2511 /***********************************************************************
2512 * EndDeferWindowPos16 (USER.261)
2514 BOOL16 WINAPI
EndDeferWindowPos16( HDWP16 hdwp
)
2516 return EndDeferWindowPos32( hdwp
);
2520 /***********************************************************************
2521 * EndDeferWindowPos32 (USER32.172)
2523 BOOL32 WINAPI
EndDeferWindowPos32( HDWP32 hdwp
)
2526 WINDOWPOS32
*winpos
;
2530 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2531 if (!pDWP
) return FALSE
;
2532 for (i
= 0, winpos
= pDWP
->winPos
; i
< pDWP
->actualCount
; i
++, winpos
++)
2534 if (!(res
= SetWindowPos32( winpos
->hwnd
, winpos
->hwndInsertAfter
,
2535 winpos
->x
, winpos
->y
, winpos
->cx
,
2536 winpos
->cy
, winpos
->flags
))) break;
2538 USER_HEAP_FREE( hdwp
);
2543 /***********************************************************************
2544 * TileChildWindows (USER.199)
2546 void WINAPI
TileChildWindows( HWND16 parent
, WORD action
)
2548 printf("STUB TileChildWindows(%04x, %d)\n", parent
, action
);
2551 /***********************************************************************
2552 * CascageChildWindows (USER.198)
2554 void WINAPI
CascadeChildWindows( HWND16 parent
, WORD action
)
2556 printf("STUB CascadeChildWindows(%04x, %d)\n", parent
, action
);