Release 980315
[wine/multimedia.git] / windows / winpos.c
blob760380752d1742da92dbbddcc627134a8e0373ec
1 /*
2 * Window position related functions.
4 * Copyright 1993, 1994, 1995 Alexandre Julliard
5 * 1995, 1996 Alex Korobka
6 */
8 #include "ts_xlib.h"
9 #include "ts_xutil.h"
10 #include <X11/Xatom.h>
11 #include "sysmetrics.h"
12 #include "heap.h"
13 #include "module.h"
14 #include "user.h"
15 #include "win.h"
16 #include "hook.h"
17 #include "message.h"
18 #include "queue.h"
19 #include "options.h"
20 #include "winpos.h"
21 #include "dce.h"
22 #include "nonclient.h"
23 #include "debug.h"
25 #define HAS_DLGFRAME(style,exStyle) \
26 (((exStyle) & WS_EX_DLGMODALFRAME) || \
27 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
29 #define HAS_THICKFRAME(style) \
30 (((style) & WS_THICKFRAME) && \
31 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
33 #define SWP_AGG_NOGEOMETRYCHANGE \
34 (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
35 #define SWP_AGG_NOPOSCHANGE \
36 (SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
37 #define SWP_AGG_STATUSFLAGS \
38 (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
40 #define EMPTYPOINT(pt) ((*(LONG*)&(pt)) == -1)
42 #define PLACE_MIN 0x0001
43 #define PLACE_MAX 0x0002
44 #define PLACE_RECT 0x0004
46 #define SMC_NOCOPY 0x0001
47 #define SMC_NOPARENTERASE 0x0002
48 #define SMC_DRAWFRAME 0x0004
49 #define SMC_SETXPOS 0x0008
51 /* ----- external functions ----- */
53 extern void FOCUS_SwitchFocus( HWND32 , HWND32 );
54 extern HWND32 CARET_GetHwnd();
56 /* ----- internal variables ----- */
58 static HWND32 hwndActive = 0; /* Currently active window */
59 static HWND32 hwndPrevActive = 0; /* Previously active window */
61 static LPCSTR atomInternalPos;
63 extern MESSAGEQUEUE* pActiveQueue;
65 /***********************************************************************
66 * WINPOS_CreateInternalPosAtom
68 BOOL32 WINPOS_CreateInternalPosAtom()
70 LPSTR str = "SysIP";
71 atomInternalPos = (LPCSTR)(DWORD)GlobalAddAtom32A(str);
72 return (atomInternalPos) ? TRUE : FALSE;
75 /***********************************************************************
76 * WINPOS_CheckInternalPos
78 * Called when a window is destroyed.
80 void WINPOS_CheckInternalPos( HWND32 hwnd )
82 LPINTERNALPOS lpPos = (LPINTERNALPOS) GetProp32A( hwnd, atomInternalPos );
84 if( hwnd == hwndPrevActive ) hwndPrevActive = 0;
85 if( hwnd == hwndActive )
87 hwndActive = 0;
88 WARN(win, "\tattempt to activate destroyed window!\n");
91 if( lpPos )
93 if( IsWindow32(lpPos->hwndIconTitle) )
94 DestroyWindow32( lpPos->hwndIconTitle );
95 HeapFree( SystemHeap, 0, lpPos );
99 /***********************************************************************
100 * WINPOS_FindIconPos
102 * Find a suitable place for an iconic window.
104 static POINT16 WINPOS_FindIconPos( WND* wndPtr, POINT16 pt )
106 RECT16 rectParent;
107 short x, y, xspacing, yspacing;
109 GetClientRect16( wndPtr->parent->hwndSelf, &rectParent );
110 if ((pt.x >= rectParent.left) && (pt.x + SYSMETRICS_CXICON < rectParent.right) &&
111 (pt.y >= rectParent.top) && (pt.y + SYSMETRICS_CYICON < rectParent.bottom))
112 return pt; /* The icon already has a suitable position */
114 xspacing = SYSMETRICS_CXICONSPACING;
115 yspacing = SYSMETRICS_CYICONSPACING;
117 y = rectParent.bottom;
118 for (;;)
120 for (x = rectParent.left; x <= rectParent.right-xspacing; x += xspacing)
122 /* Check if another icon already occupies this spot */
123 WND *childPtr = wndPtr->parent->child;
124 while (childPtr)
126 if ((childPtr->dwStyle & WS_MINIMIZE) && (childPtr != wndPtr))
128 if ((childPtr->rectWindow.left < x + xspacing) &&
129 (childPtr->rectWindow.right >= x) &&
130 (childPtr->rectWindow.top <= y) &&
131 (childPtr->rectWindow.bottom > y - yspacing))
132 break; /* There's a window in there */
134 childPtr = childPtr->next;
136 if (!childPtr) /* No window was found, so it's OK for us */
138 pt.x = x + (xspacing - SYSMETRICS_CXICON) / 2;
139 pt.y = y - (yspacing + SYSMETRICS_CYICON) / 2;
140 return pt;
143 y -= yspacing;
148 /***********************************************************************
149 * ArrangeIconicWindows16 (USER.170)
151 UINT16 WINAPI ArrangeIconicWindows16( HWND16 parent)
153 return ArrangeIconicWindows32(parent);
155 /***********************************************************************
156 * ArrangeIconicWindows32 (USER32.6)
158 UINT32 WINAPI ArrangeIconicWindows32( HWND32 parent )
160 RECT32 rectParent;
161 HWND32 hwndChild;
162 INT32 x, y, xspacing, yspacing;
164 GetClientRect32( parent, &rectParent );
165 x = rectParent.left;
166 y = rectParent.bottom;
167 xspacing = SYSMETRICS_CXICONSPACING;
168 yspacing = SYSMETRICS_CYICONSPACING;
170 hwndChild = GetWindow32( parent, GW_CHILD );
171 while (hwndChild)
173 if( IsIconic32( hwndChild ) )
175 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild), FALSE );
176 SetWindowPos32( hwndChild, 0, x + (xspacing - SYSMETRICS_CXICON) / 2,
177 y - yspacing - SYSMETRICS_CYICON/2, 0, 0,
178 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
179 if( IsWindow32(hwndChild) )
180 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild), TRUE );
181 if (x <= rectParent.right - xspacing) x += xspacing;
182 else
184 x = rectParent.left;
185 y -= yspacing;
188 hwndChild = GetWindow32( hwndChild, GW_HWNDNEXT );
190 return yspacing;
194 /***********************************************************************
195 * SwitchToThisWindow16 (USER.172)
197 void WINAPI SwitchToThisWindow16( HWND16 hwnd, BOOL16 restore )
199 SwitchToThisWindow32( hwnd, restore );
203 /***********************************************************************
204 * SwitchToThisWindow32 (USER32.538)
206 void WINAPI SwitchToThisWindow32( HWND32 hwnd, BOOL32 restore )
208 ShowWindow32( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED );
212 /***********************************************************************
213 * GetWindowRect16 (USER.32)
215 void WINAPI GetWindowRect16( HWND16 hwnd, LPRECT16 rect )
217 WND * wndPtr = WIN_FindWndPtr( hwnd );
218 if (!wndPtr) return;
220 CONV_RECT32TO16( &wndPtr->rectWindow, rect );
221 if (wndPtr->dwStyle & WS_CHILD)
222 MapWindowPoints16( wndPtr->parent->hwndSelf, 0, (POINT16 *)rect, 2 );
226 /***********************************************************************
227 * GetWindowRect32 (USER32.308)
229 void WINAPI GetWindowRect32( HWND32 hwnd, LPRECT32 rect )
231 WND * wndPtr = WIN_FindWndPtr( hwnd );
232 if (!wndPtr) return;
234 *rect = wndPtr->rectWindow;
235 if (wndPtr->dwStyle & WS_CHILD)
236 MapWindowPoints32( wndPtr->parent->hwndSelf, 0, (POINT32 *)rect, 2 );
240 /***********************************************************************
241 * GetClientRect16 (USER.33)
243 void WINAPI GetClientRect16( HWND16 hwnd, LPRECT16 rect )
245 WND * wndPtr = WIN_FindWndPtr( hwnd );
247 rect->left = rect->top = rect->right = rect->bottom = 0;
248 if (wndPtr)
250 rect->right = wndPtr->rectClient.right - wndPtr->rectClient.left;
251 rect->bottom = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
256 /***********************************************************************
257 * GetClientRect32 (USER32.219)
259 void WINAPI GetClientRect32( HWND32 hwnd, LPRECT32 rect )
261 WND * wndPtr = WIN_FindWndPtr( hwnd );
263 rect->left = rect->top = rect->right = rect->bottom = 0;
264 if (wndPtr)
266 rect->right = wndPtr->rectClient.right - wndPtr->rectClient.left;
267 rect->bottom = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
272 /*******************************************************************
273 * ClientToScreen16 (USER.28)
275 void WINAPI ClientToScreen16( HWND16 hwnd, LPPOINT16 lppnt )
277 MapWindowPoints16( hwnd, 0, lppnt, 1 );
281 /*******************************************************************
282 * ClientToScreen32 (USER32.51)
284 BOOL32 WINAPI ClientToScreen32( HWND32 hwnd, LPPOINT32 lppnt )
286 MapWindowPoints32( hwnd, 0, lppnt, 1 );
287 return TRUE;
291 /*******************************************************************
292 * ScreenToClient16 (USER.29)
294 void WINAPI ScreenToClient16( HWND16 hwnd, LPPOINT16 lppnt )
296 MapWindowPoints16( 0, hwnd, lppnt, 1 );
300 /*******************************************************************
301 * ScreenToClient32 (USER32.446)
303 void WINAPI ScreenToClient32( HWND32 hwnd, LPPOINT32 lppnt )
305 MapWindowPoints32( 0, hwnd, lppnt, 1 );
309 /***********************************************************************
310 * WINPOS_WindowFromPoint
312 * Find the window and hittest for a given point.
314 INT16 WINPOS_WindowFromPoint( WND* wndScope, POINT16 pt, WND **ppWnd )
316 WND *wndPtr;
317 INT16 hittest = HTERROR;
318 POINT16 xy = pt;
320 *ppWnd = NULL;
321 wndPtr = wndScope->child;
322 MapWindowPoints16( GetDesktopWindow16(), wndScope->hwndSelf, &xy, 1 );
324 for (;;)
326 while (wndPtr)
328 /* If point is in window, and window is visible, and it */
329 /* is enabled (or it's a top-level window), then explore */
330 /* its children. Otherwise, go to the next window. */
332 if ((wndPtr->dwStyle & WS_VISIBLE) &&
333 (!(wndPtr->dwStyle & WS_DISABLED) ||
334 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)) &&
335 (xy.x >= wndPtr->rectWindow.left) &&
336 (xy.x < wndPtr->rectWindow.right) &&
337 (xy.y >= wndPtr->rectWindow.top) &&
338 (xy.y < wndPtr->rectWindow.bottom))
340 *ppWnd = wndPtr; /* Got a suitable window */
342 /* If window is minimized or disabled, return at once */
343 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
344 if (wndPtr->dwStyle & WS_DISABLED) return HTERROR;
346 /* If point is not in client area, ignore the children */
347 if ((xy.x < wndPtr->rectClient.left) ||
348 (xy.x >= wndPtr->rectClient.right) ||
349 (xy.y < wndPtr->rectClient.top) ||
350 (xy.y >= wndPtr->rectClient.bottom)) break;
352 xy.x -= wndPtr->rectClient.left;
353 xy.y -= wndPtr->rectClient.top;
354 wndPtr = wndPtr->child;
356 else wndPtr = wndPtr->next;
359 /* If nothing found, try the scope window */
360 if (!*ppWnd) *ppWnd = wndScope;
362 /* Send the WM_NCHITTEST message (only if to the same task) */
363 if ((*ppWnd)->hmemTaskQ == GetTaskQueue(0))
365 hittest = (INT16)SendMessage16( (*ppWnd)->hwndSelf, WM_NCHITTEST,
366 0, MAKELONG( pt.x, pt.y ) );
367 if (hittest != HTTRANSPARENT) return hittest; /* Found the window */
369 else return HTCLIENT;
371 /* If no children found in last search, make point relative to parent */
372 if (!wndPtr)
374 xy.x += (*ppWnd)->rectClient.left;
375 xy.y += (*ppWnd)->rectClient.top;
378 /* Restart the search from the next sibling */
379 wndPtr = (*ppWnd)->next;
380 *ppWnd = (*ppWnd)->parent;
385 /*******************************************************************
386 * WindowFromPoint16 (USER.30)
388 HWND16 WINAPI WindowFromPoint16( POINT16 pt )
390 WND *pWnd;
391 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt, &pWnd );
392 return pWnd->hwndSelf;
396 /*******************************************************************
397 * WindowFromPoint32 (USER32.581)
399 HWND32 WINAPI WindowFromPoint32( POINT32 pt )
401 WND *pWnd;
402 POINT16 pt16;
403 CONV_POINT32TO16( &pt, &pt16 );
404 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt16, &pWnd );
405 return (HWND32)pWnd->hwndSelf;
409 /*******************************************************************
410 * ChildWindowFromPoint16 (USER.191)
412 HWND16 WINAPI ChildWindowFromPoint16( HWND16 hwndParent, POINT16 pt )
414 POINT32 pt32;
415 CONV_POINT16TO32( &pt, &pt32 );
416 return (HWND16)ChildWindowFromPoint32( hwndParent, pt32 );
420 /*******************************************************************
421 * ChildWindowFromPoint32 (USER32.48)
423 HWND32 WINAPI ChildWindowFromPoint32( HWND32 hwndParent, POINT32 pt )
425 /* pt is in the client coordinates */
427 WND* wnd = WIN_FindWndPtr(hwndParent);
428 RECT32 rect;
430 if( !wnd ) return 0;
432 /* get client rect fast */
433 rect.top = rect.left = 0;
434 rect.right = wnd->rectClient.right - wnd->rectClient.left;
435 rect.bottom = wnd->rectClient.bottom - wnd->rectClient.top;
437 if (!PtInRect32( &rect, pt )) return 0;
439 wnd = wnd->child;
440 while ( wnd )
442 if (PtInRect32( &wnd->rectWindow, pt )) return wnd->hwndSelf;
443 wnd = wnd->next;
445 return hwndParent;
449 /*******************************************************************
450 * WINPOS_GetWinOffset
452 * Calculate the offset between the origin of the two windows. Used
453 * to implement MapWindowPoints.
455 static void WINPOS_GetWinOffset( HWND32 hwndFrom, HWND32 hwndTo,
456 POINT32 *offset )
458 WND * wndPtr;
460 offset->x = offset->y = 0;
461 if (hwndFrom == hwndTo ) return;
463 /* Translate source window origin to screen coords */
464 if (hwndFrom)
466 if (!(wndPtr = WIN_FindWndPtr( hwndFrom )))
468 fprintf(stderr,"MapWindowPoints: bad hwndFrom = %04x\n",hwndFrom);
469 return;
471 while (wndPtr->parent)
473 offset->x += wndPtr->rectClient.left;
474 offset->y += wndPtr->rectClient.top;
475 wndPtr = wndPtr->parent;
479 /* Translate origin to destination window coords */
480 if (hwndTo)
482 if (!(wndPtr = WIN_FindWndPtr( hwndTo )))
484 fprintf(stderr,"MapWindowPoints: bad hwndTo = %04x\n", hwndTo );
485 return;
487 while (wndPtr->parent)
489 offset->x -= wndPtr->rectClient.left;
490 offset->y -= wndPtr->rectClient.top;
491 wndPtr = wndPtr->parent;
497 /*******************************************************************
498 * MapWindowPoints16 (USER.258)
500 void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo,
501 LPPOINT16 lppt, UINT16 count )
503 POINT32 offset;
505 WINPOS_GetWinOffset( hwndFrom, hwndTo, &offset );
506 while (count--)
508 lppt->x += offset.x;
509 lppt->y += offset.y;
510 lppt++;
515 /*******************************************************************
516 * MapWindowPoints32 (USER32.385)
518 void WINAPI MapWindowPoints32( HWND32 hwndFrom, HWND32 hwndTo,
519 LPPOINT32 lppt, UINT32 count )
521 POINT32 offset;
523 WINPOS_GetWinOffset( hwndFrom, hwndTo, &offset );
524 while (count--)
526 lppt->x += offset.x;
527 lppt->y += offset.y;
528 lppt++;
533 /***********************************************************************
534 * IsIconic16 (USER.31)
536 BOOL16 WINAPI IsIconic16(HWND16 hWnd)
538 return IsIconic32(hWnd);
542 /***********************************************************************
543 * IsIconic32 (USER32.344)
545 BOOL32 WINAPI IsIconic32(HWND32 hWnd)
547 WND * wndPtr = WIN_FindWndPtr(hWnd);
548 if (wndPtr == NULL) return FALSE;
549 return (wndPtr->dwStyle & WS_MINIMIZE) != 0;
553 /***********************************************************************
554 * IsZoomed (USER.272)
556 BOOL16 WINAPI IsZoomed16(HWND16 hWnd)
558 return IsZoomed32(hWnd);
562 /***********************************************************************
563 * IsZoomed (USER32.351)
565 BOOL32 WINAPI IsZoomed32(HWND32 hWnd)
567 WND * wndPtr = WIN_FindWndPtr(hWnd);
568 if (wndPtr == NULL) return FALSE;
569 return (wndPtr->dwStyle & WS_MAXIMIZE) != 0;
573 /*******************************************************************
574 * GetActiveWindow (USER.60)
576 HWND16 WINAPI GetActiveWindow16(void)
578 return (HWND16)hwndActive;
581 /*******************************************************************
582 * GetActiveWindow (USER32.204)
584 HWND32 WINAPI GetActiveWindow32(void)
586 return (HWND32)hwndActive;
590 /*******************************************************************
591 * WINPOS_CanActivate
593 static BOOL32 WINPOS_CanActivate(WND* pWnd)
595 if( pWnd && ((pWnd->dwStyle & (WS_DISABLED | WS_VISIBLE | WS_CHILD))
596 == WS_VISIBLE) ) return TRUE;
597 return FALSE;
601 /*******************************************************************
602 * SetActiveWindow16 (USER.59)
604 HWND16 WINAPI SetActiveWindow16( HWND16 hwnd )
606 return SetActiveWindow32(hwnd);
610 /*******************************************************************
611 * SetActiveWindow32 (USER32.462)
613 HWND32 WINAPI SetActiveWindow32( HWND32 hwnd )
615 HWND32 prev = hwndActive;
616 WND *wndPtr = WIN_FindWndPtr( hwnd );
618 if ( !WINPOS_CanActivate(wndPtr) ) return 0;
620 WINPOS_SetActiveWindow( hwnd, 0, 0 );
621 return prev;
625 /*******************************************************************
626 * GetForegroundWindow16 (USER.608)
628 HWND16 WINAPI GetForegroundWindow16(void)
630 return (HWND16)GetForegroundWindow32();
634 /*******************************************************************
635 * SetForegroundWindow16 (USER.609)
637 BOOL16 WINAPI SetForegroundWindow16( HWND16 hwnd )
639 return SetForegroundWindow32( hwnd );
643 /*******************************************************************
644 * GetForegroundWindow32 (USER32.241)
646 HWND32 WINAPI GetForegroundWindow32(void)
648 return GetActiveWindow32();
652 /*******************************************************************
653 * SetForegroundWindow32 (USER32.482)
655 BOOL32 WINAPI SetForegroundWindow32( HWND32 hwnd )
657 SetActiveWindow32( hwnd );
658 return TRUE;
662 /*******************************************************************
663 * GetShellWindow16 (USER.600)
665 HWND16 WINAPI GetShellWindow16(void)
667 return GetShellWindow32();
670 /*******************************************************************
671 * SetShellWindow32 (USER32.287)
673 HWND32 WINAPI SetShellWindow32(HWND32 hwndshell)
675 fprintf( stdnimp, "SetShellWindow(%08x): empty stub\n",hwndshell );
676 return 0;
680 /*******************************************************************
681 * GetShellWindow32 (USER32.287)
683 HWND32 WINAPI GetShellWindow32(void)
685 fprintf( stdnimp, "GetShellWindow: empty stub\n" );
686 return 0;
690 /***********************************************************************
691 * BringWindowToTop16 (USER.45)
693 BOOL16 WINAPI BringWindowToTop16( HWND16 hwnd )
695 return BringWindowToTop32(hwnd);
699 /***********************************************************************
700 * BringWindowToTop32 (USER32.10)
702 BOOL32 WINAPI BringWindowToTop32( HWND32 hwnd )
704 return SetWindowPos32( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
708 /***********************************************************************
709 * MoveWindow16 (USER.56)
711 BOOL16 WINAPI MoveWindow16( HWND16 hwnd, INT16 x, INT16 y, INT16 cx, INT16 cy,
712 BOOL16 repaint )
714 return MoveWindow32(hwnd,x,y,cx,cy,repaint);
718 /***********************************************************************
719 * MoveWindow32 (USER32.398)
721 BOOL32 WINAPI MoveWindow32( HWND32 hwnd, INT32 x, INT32 y, INT32 cx, INT32 cy,
722 BOOL32 repaint )
724 int flags = SWP_NOZORDER | SWP_NOACTIVATE;
725 if (!repaint) flags |= SWP_NOREDRAW;
726 TRACE(win, "%04x %d,%d %dx%d %d\n",
727 hwnd, x, y, cx, cy, repaint );
728 return SetWindowPos32( hwnd, 0, x, y, cx, cy, flags );
731 /***********************************************************************
732 * WINPOS_InitInternalPos
734 static LPINTERNALPOS WINPOS_InitInternalPos( WND* wnd, POINT32 pt,
735 LPRECT32 restoreRect )
737 LPINTERNALPOS lpPos = (LPINTERNALPOS) GetProp32A( wnd->hwndSelf,
738 atomInternalPos );
739 if( !lpPos )
741 /* this happens when the window is minimized/maximized
742 * for the first time (rectWindow is not adjusted yet) */
744 lpPos = HeapAlloc( SystemHeap, 0, sizeof(INTERNALPOS) );
745 if( !lpPos ) return NULL;
747 SetProp32A( wnd->hwndSelf, atomInternalPos, (HANDLE32)lpPos );
748 lpPos->hwndIconTitle = 0; /* defer until needs to be shown */
749 CONV_RECT32TO16( &wnd->rectWindow, &lpPos->rectNormal );
750 *(UINT32*)&lpPos->ptIconPos = *(UINT32*)&lpPos->ptMaxPos = 0xFFFFFFFF;
753 if( wnd->dwStyle & WS_MINIMIZE )
754 CONV_POINT32TO16( &pt, &lpPos->ptIconPos );
755 else if( wnd->dwStyle & WS_MAXIMIZE )
756 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
757 else if( restoreRect )
758 CONV_RECT32TO16( restoreRect, &lpPos->rectNormal );
760 return lpPos;
763 /***********************************************************************
764 * WINPOS_RedrawIconTitle
766 BOOL32 WINPOS_RedrawIconTitle( HWND32 hWnd )
768 LPINTERNALPOS lpPos = (LPINTERNALPOS)GetProp32A( hWnd, atomInternalPos );
769 if( lpPos )
771 if( lpPos->hwndIconTitle )
773 SendMessage32A( lpPos->hwndIconTitle, WM_SHOWWINDOW, TRUE, 0);
774 InvalidateRect32( lpPos->hwndIconTitle, NULL, TRUE );
775 return TRUE;
778 return FALSE;
781 /***********************************************************************
782 * WINPOS_ShowIconTitle
784 BOOL32 WINPOS_ShowIconTitle( WND* pWnd, BOOL32 bShow )
786 LPINTERNALPOS lpPos = (LPINTERNALPOS)GetProp32A( pWnd->hwndSelf, atomInternalPos );
788 if( lpPos && !(pWnd->flags & WIN_MANAGED))
790 HWND16 hWnd = lpPos->hwndIconTitle;
792 TRACE(win,"0x%04x %i\n", pWnd->hwndSelf, (bShow != 0) );
794 if( !hWnd )
795 lpPos->hwndIconTitle = hWnd = ICONTITLE_Create( pWnd );
796 if( bShow )
798 pWnd = WIN_FindWndPtr(hWnd);
800 if( !(pWnd->dwStyle & WS_VISIBLE) )
802 SendMessage32A( hWnd, WM_SHOWWINDOW, TRUE, 0 );
803 SetWindowPos32( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
804 SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
807 else ShowWindow32( hWnd, SW_HIDE );
809 return FALSE;
812 /*******************************************************************
813 * WINPOS_GetMinMaxInfo
815 * Get the minimized and maximized information for a window.
817 void WINPOS_GetMinMaxInfo( WND *wndPtr, POINT32 *maxSize, POINT32 *maxPos,
818 POINT32 *minTrack, POINT32 *maxTrack )
820 LPINTERNALPOS lpPos;
821 MINMAXINFO32 MinMax;
822 INT32 xinc, yinc;
824 /* Compute default values */
826 MinMax.ptMaxSize.x = SYSMETRICS_CXSCREEN;
827 MinMax.ptMaxSize.y = SYSMETRICS_CYSCREEN;
828 MinMax.ptMinTrackSize.x = SYSMETRICS_CXMINTRACK;
829 MinMax.ptMinTrackSize.y = SYSMETRICS_CYMINTRACK;
830 MinMax.ptMaxTrackSize.x = SYSMETRICS_CXSCREEN;
831 MinMax.ptMaxTrackSize.y = SYSMETRICS_CYSCREEN;
833 if (wndPtr->flags & WIN_MANAGED) xinc = yinc = 0;
834 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
836 xinc = SYSMETRICS_CXDLGFRAME;
837 yinc = SYSMETRICS_CYDLGFRAME;
839 else
841 xinc = yinc = 0;
842 if (HAS_THICKFRAME(wndPtr->dwStyle))
844 xinc += SYSMETRICS_CXFRAME;
845 yinc += SYSMETRICS_CYFRAME;
847 if (wndPtr->dwStyle & WS_BORDER)
849 xinc += SYSMETRICS_CXBORDER;
850 yinc += SYSMETRICS_CYBORDER;
853 MinMax.ptMaxSize.x += 2 * xinc;
854 MinMax.ptMaxSize.y += 2 * yinc;
856 lpPos = (LPINTERNALPOS)GetProp32A( wndPtr->hwndSelf, atomInternalPos );
857 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
858 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
859 else
861 MinMax.ptMaxPosition.x = -xinc;
862 MinMax.ptMaxPosition.y = -yinc;
865 SendMessage32A( wndPtr->hwndSelf, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
867 /* Some sanity checks */
869 TRACE(win,"%d %d / %d %d / %d %d / %d %d\n",
870 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
871 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
872 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
873 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y);
874 MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
875 MinMax.ptMinTrackSize.x );
876 MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
877 MinMax.ptMinTrackSize.y );
879 if (maxSize) *maxSize = MinMax.ptMaxSize;
880 if (maxPos) *maxPos = MinMax.ptMaxPosition;
881 if (minTrack) *minTrack = MinMax.ptMinTrackSize;
882 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
885 /***********************************************************************
886 * WINPOS_MinMaximize
888 * Fill in lpRect and return additional flags to be used with SetWindowPos().
889 * This function assumes that 'cmd' is different from the current window
890 * state.
892 UINT16 WINPOS_MinMaximize( WND* wndPtr, UINT16 cmd, LPRECT16 lpRect )
894 UINT16 swpFlags = 0;
895 POINT32 pt;
896 POINT32 size = { wndPtr->rectWindow.left, wndPtr->rectWindow.top };
897 LPINTERNALPOS lpPos = WINPOS_InitInternalPos( wndPtr, size,
898 &wndPtr->rectWindow );
900 TRACE(win,"0x%04x %u\n", wndPtr->hwndSelf, cmd );
902 if (lpPos && !HOOK_CallHooks16(WH_CBT, HCBT_MINMAX, wndPtr->hwndSelf, cmd))
904 if( wndPtr->dwStyle & WS_MINIMIZE )
906 if( !SendMessage32A( wndPtr->hwndSelf, WM_QUERYOPEN, 0, 0L ) )
907 return (SWP_NOSIZE | SWP_NOMOVE);
908 swpFlags |= SWP_NOCOPYBITS;
910 switch( cmd )
912 case SW_MINIMIZE:
913 if( wndPtr->dwStyle & WS_MAXIMIZE)
915 wndPtr->flags |= WIN_RESTORE_MAX;
916 wndPtr->dwStyle &= ~WS_MAXIMIZE;
918 else
919 wndPtr->flags &= ~WIN_RESTORE_MAX;
920 wndPtr->dwStyle |= WS_MINIMIZE;
922 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
924 SetRect16( lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
925 SYSMETRICS_CXICON, SYSMETRICS_CYICON );
926 swpFlags |= SWP_NOCOPYBITS;
927 break;
929 case SW_MAXIMIZE:
930 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
931 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
932 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
934 if( wndPtr->dwStyle & WS_MINIMIZE )
936 WINPOS_ShowIconTitle( wndPtr, FALSE );
937 wndPtr->dwStyle &= ~WS_MINIMIZE;
939 wndPtr->dwStyle |= WS_MAXIMIZE;
941 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
942 size.x, size.y );
943 break;
945 case SW_RESTORE:
946 if( wndPtr->dwStyle & WS_MINIMIZE )
948 wndPtr->dwStyle &= ~WS_MINIMIZE;
949 WINPOS_ShowIconTitle( wndPtr, FALSE );
950 if( wndPtr->flags & WIN_RESTORE_MAX)
952 /* Restore to maximized position */
953 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
954 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
955 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
956 wndPtr->dwStyle |= WS_MAXIMIZE;
957 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
958 break;
961 else
962 if( !(wndPtr->dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
963 else wndPtr->dwStyle &= ~WS_MAXIMIZE;
965 /* Restore to normal position */
967 *lpRect = lpPos->rectNormal;
968 lpRect->right -= lpRect->left;
969 lpRect->bottom -= lpRect->top;
971 break;
973 } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
974 return swpFlags;
977 /***********************************************************************
978 * ShowWindow16 (USER.42)
980 BOOL16 WINAPI ShowWindow16( HWND16 hwnd, INT16 cmd )
982 return ShowWindow32(hwnd,cmd);
986 /***********************************************************************
987 * ShowWindow32 (USER.42)
989 BOOL32 WINAPI ShowWindow32( HWND32 hwnd, INT32 cmd )
991 WND* wndPtr = WIN_FindWndPtr( hwnd );
992 BOOL32 wasVisible, showFlag;
993 RECT16 newPos = {0, 0, 0, 0};
994 int swp = 0;
996 if (!wndPtr) return FALSE;
998 TRACE(win,"hwnd=%04x, cmd=%d\n", hwnd, cmd);
1000 wasVisible = (wndPtr->dwStyle & WS_VISIBLE) != 0;
1002 switch(cmd)
1004 case SW_HIDE:
1005 if (!wasVisible) return FALSE;
1006 swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
1007 SWP_NOACTIVATE | SWP_NOZORDER;
1008 break;
1010 case SW_SHOWMINNOACTIVE:
1011 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1012 /* fall through */
1013 case SW_SHOWMINIMIZED:
1014 swp |= SWP_SHOWWINDOW;
1015 /* fall through */
1016 case SW_MINIMIZE:
1017 swp |= SWP_FRAMECHANGED;
1018 if( !(wndPtr->dwStyle & WS_MINIMIZE) )
1019 swp |= WINPOS_MinMaximize( wndPtr, SW_MINIMIZE, &newPos );
1020 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1021 break;
1023 case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
1024 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
1025 if( !(wndPtr->dwStyle & WS_MAXIMIZE) )
1026 swp |= WINPOS_MinMaximize( wndPtr, SW_MAXIMIZE, &newPos );
1027 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1028 break;
1030 case SW_SHOWNA:
1031 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1032 /* fall through */
1033 case SW_SHOW:
1034 swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
1035 break;
1037 case SW_SHOWNOACTIVATE:
1038 swp |= SWP_NOZORDER;
1039 if (GetActiveWindow32()) swp |= SWP_NOACTIVATE;
1040 /* fall through */
1041 case SW_SHOWNORMAL: /* same as SW_NORMAL: */
1042 case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
1043 case SW_RESTORE:
1044 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
1046 if( wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE) )
1047 swp |= WINPOS_MinMaximize( wndPtr, SW_RESTORE, &newPos );
1048 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1049 break;
1052 showFlag = (cmd != SW_HIDE);
1053 if (showFlag != wasVisible)
1055 SendMessage32A( hwnd, WM_SHOWWINDOW, showFlag, 0 );
1056 if (!IsWindow32( hwnd )) return wasVisible;
1059 if ((wndPtr->dwStyle & WS_CHILD) &&
1060 !IsWindowVisible32( wndPtr->parent->hwndSelf ) &&
1061 (swp & (SWP_NOSIZE | SWP_NOMOVE)) == (SWP_NOSIZE | SWP_NOMOVE) )
1063 /* Don't call SetWindowPos32() on invisible child windows */
1064 if (cmd == SW_HIDE) wndPtr->dwStyle &= ~WS_VISIBLE;
1065 else wndPtr->dwStyle |= WS_VISIBLE;
1067 else
1069 /* We can't activate a child window */
1070 if (wndPtr->dwStyle & WS_CHILD) swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1071 SetWindowPos32( hwnd, HWND_TOP,
1072 newPos.left, newPos.top, newPos.right, newPos.bottom, swp );
1073 if (!IsWindow32( hwnd )) return wasVisible;
1074 else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( wndPtr, TRUE );
1077 if (wndPtr->flags & WIN_NEED_SIZE)
1079 /* should happen only in CreateWindowEx() */
1080 int wParam = SIZE_RESTORED;
1082 wndPtr->flags &= ~WIN_NEED_SIZE;
1083 if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED;
1084 else if (wndPtr->dwStyle & WS_MINIMIZE) wParam = SIZE_MINIMIZED;
1085 SendMessage32A( hwnd, WM_SIZE, wParam,
1086 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
1087 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
1088 SendMessage32A( hwnd, WM_MOVE, 0,
1089 MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top) );
1092 return wasVisible;
1096 /***********************************************************************
1097 * GetInternalWindowPos16 (USER.460)
1099 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd,
1100 LPPOINT16 ptIcon )
1102 WINDOWPLACEMENT16 wndpl;
1103 if (GetWindowPlacement16( hwnd, &wndpl ))
1105 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1106 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1107 return wndpl.showCmd;
1109 return 0;
1113 /***********************************************************************
1114 * GetInternalWindowPos32 (USER32.244)
1116 UINT32 WINAPI GetInternalWindowPos32( HWND32 hwnd, LPRECT32 rectWnd,
1117 LPPOINT32 ptIcon )
1119 WINDOWPLACEMENT32 wndpl;
1120 if (GetWindowPlacement32( hwnd, &wndpl ))
1122 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1123 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1124 return wndpl.showCmd;
1126 return 0;
1129 /***********************************************************************
1130 * GetWindowPlacement16 (USER.370)
1132 BOOL16 WINAPI GetWindowPlacement16( HWND16 hwnd, WINDOWPLACEMENT16 *wndpl )
1134 WND *pWnd = WIN_FindWndPtr( hwnd );
1135 if( pWnd )
1137 LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd,
1138 *(LPPOINT32)&pWnd->rectWindow.left, &pWnd->rectWindow );
1139 wndpl->length = sizeof(*wndpl);
1140 if( pWnd->dwStyle & WS_MINIMIZE )
1141 wndpl->showCmd = SW_SHOWMAXIMIZED;
1142 else
1143 wndpl->showCmd = ( pWnd->dwStyle & WS_MAXIMIZE )
1144 ? SW_SHOWMINIMIZED : SW_SHOWNORMAL ;
1145 if( pWnd->flags & WIN_RESTORE_MAX )
1146 wndpl->flags = WPF_RESTORETOMAXIMIZED;
1147 else
1148 wndpl->flags = 0;
1149 wndpl->ptMinPosition = lpPos->ptIconPos;
1150 wndpl->ptMaxPosition = lpPos->ptMaxPos;
1151 wndpl->rcNormalPosition = lpPos->rectNormal;
1152 return TRUE;
1154 return FALSE;
1158 /***********************************************************************
1159 * GetWindowPlacement32 (USER32.306)
1161 BOOL32 WINAPI GetWindowPlacement32( HWND32 hwnd, WINDOWPLACEMENT32 *pwpl32 )
1163 if( pwpl32 )
1165 WINDOWPLACEMENT16 wpl;
1166 wpl.length = sizeof(wpl);
1167 if( GetWindowPlacement16( hwnd, &wpl ) )
1169 pwpl32->length = sizeof(*pwpl32);
1170 pwpl32->flags = wpl.flags;
1171 pwpl32->showCmd = wpl.showCmd;
1172 CONV_POINT16TO32( &wpl.ptMinPosition, &pwpl32->ptMinPosition );
1173 CONV_POINT16TO32( &wpl.ptMaxPosition, &pwpl32->ptMaxPosition );
1174 CONV_RECT16TO32( &wpl.rcNormalPosition, &pwpl32->rcNormalPosition );
1175 return TRUE;
1178 return FALSE;
1182 /***********************************************************************
1183 * WINPOS_SetPlacement
1185 static BOOL32 WINPOS_SetPlacement( HWND32 hwnd, const WINDOWPLACEMENT16 *wndpl,
1186 UINT32 flags )
1188 WND *pWnd = WIN_FindWndPtr( hwnd );
1189 if( pWnd )
1191 LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd,
1192 *(LPPOINT32)&pWnd->rectWindow.left, &pWnd->rectWindow );
1194 if( flags & PLACE_MIN ) lpPos->ptIconPos = wndpl->ptMinPosition;
1195 if( flags & PLACE_MAX ) lpPos->ptMaxPos = wndpl->ptMaxPosition;
1196 if( flags & PLACE_RECT) lpPos->rectNormal = wndpl->rcNormalPosition;
1198 if( pWnd->dwStyle & WS_MINIMIZE )
1200 WINPOS_ShowIconTitle( pWnd, FALSE );
1201 if( wndpl->flags & WPF_SETMINPOSITION && !EMPTYPOINT(lpPos->ptIconPos))
1202 SetWindowPos32( hwnd, 0, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
1203 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1205 else if( pWnd->dwStyle & WS_MAXIMIZE )
1207 if( !EMPTYPOINT(lpPos->ptMaxPos) )
1208 SetWindowPos32( hwnd, 0, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
1209 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1211 else if( flags & PLACE_RECT )
1212 SetWindowPos32( hwnd, 0, lpPos->rectNormal.left, lpPos->rectNormal.top,
1213 lpPos->rectNormal.right - lpPos->rectNormal.left,
1214 lpPos->rectNormal.bottom - lpPos->rectNormal.top,
1215 SWP_NOZORDER | SWP_NOACTIVATE );
1217 ShowWindow32( hwnd, wndpl->showCmd );
1218 if( IsWindow32(hwnd) && pWnd->dwStyle & WS_MINIMIZE )
1220 if( pWnd->dwStyle & WS_VISIBLE ) WINPOS_ShowIconTitle( pWnd, TRUE );
1222 /* SDK: ...valid only the next time... */
1223 if( wndpl->flags & WPF_RESTORETOMAXIMIZED ) pWnd->flags |= WIN_RESTORE_MAX;
1225 return TRUE;
1227 return FALSE;
1231 /***********************************************************************
1232 * SetWindowPlacement16 (USER.371)
1234 BOOL16 WINAPI SetWindowPlacement16(HWND16 hwnd, const WINDOWPLACEMENT16 *wndpl)
1236 return WINPOS_SetPlacement( hwnd, wndpl,
1237 PLACE_MIN | PLACE_MAX | PLACE_RECT );
1240 /***********************************************************************
1241 * SetWindowPlacement32 (USER32.518)
1243 BOOL32 WINAPI SetWindowPlacement32( HWND32 hwnd, const WINDOWPLACEMENT32 *pwpl32 )
1245 if( pwpl32 )
1247 WINDOWPLACEMENT16 wpl = { sizeof(WINDOWPLACEMENT16),
1248 pwpl32->flags, pwpl32->showCmd, { pwpl32->ptMinPosition.x,
1249 pwpl32->ptMinPosition.y }, { pwpl32->ptMaxPosition.x,
1250 pwpl32->ptMaxPosition.y }, { pwpl32->rcNormalPosition.left,
1251 pwpl32->rcNormalPosition.top, pwpl32->rcNormalPosition.right,
1252 pwpl32->rcNormalPosition.bottom } };
1254 return WINPOS_SetPlacement( hwnd, &wpl, PLACE_MIN | PLACE_MAX | PLACE_RECT );
1256 return FALSE;
1260 /***********************************************************************
1261 * SetInternalWindowPos16 (USER.461)
1263 void WINAPI SetInternalWindowPos16( HWND16 hwnd, UINT16 showCmd,
1264 LPRECT16 rect, LPPOINT16 pt )
1266 if( IsWindow16(hwnd) )
1268 WINDOWPLACEMENT16 wndpl;
1269 UINT32 flags;
1271 wndpl.length = sizeof(wndpl);
1272 wndpl.showCmd = showCmd;
1273 wndpl.flags = flags = 0;
1275 if( pt )
1277 flags |= PLACE_MIN;
1278 wndpl.flags |= WPF_SETMINPOSITION;
1279 wndpl.ptMinPosition = *pt;
1281 if( rect )
1283 flags |= PLACE_RECT;
1284 wndpl.rcNormalPosition = *rect;
1286 WINPOS_SetPlacement( hwnd, &wndpl, flags );
1291 /***********************************************************************
1292 * SetInternalWindowPos32 (USER32.482)
1294 void WINAPI SetInternalWindowPos32( HWND32 hwnd, UINT32 showCmd,
1295 LPRECT32 rect, LPPOINT32 pt )
1297 if( IsWindow32(hwnd) )
1299 WINDOWPLACEMENT16 wndpl;
1300 UINT32 flags;
1302 wndpl.length = sizeof(wndpl);
1303 wndpl.showCmd = showCmd;
1304 wndpl.flags = flags = 0;
1306 if( pt )
1308 flags |= PLACE_MIN;
1309 wndpl.flags |= WPF_SETMINPOSITION;
1310 CONV_POINT32TO16( pt, &wndpl.ptMinPosition );
1312 if( rect )
1314 flags |= PLACE_RECT;
1315 CONV_RECT32TO16( rect, &wndpl.rcNormalPosition );
1317 WINPOS_SetPlacement( hwnd, &wndpl, flags );
1322 /***********************************************************************
1323 * WINPOS_ForceXWindowRaise
1325 * Raise a window on top of the X stacking order, while preserving
1326 * the correct Windows Z order.
1328 static void WINPOS_ForceXWindowRaise( WND* pWnd )
1330 XWindowChanges winChanges;
1331 WND *wndPrev;
1333 /* Raise all windows up to pWnd according to their Z order.
1334 * (it would be easier with sibling-related Below but it doesn't
1335 * work very well with SGI mwm for instance)
1337 winChanges.stack_mode = Above;
1338 while (pWnd)
1340 if (pWnd->window) TSXReconfigureWMWindow( display, pWnd->window, 0,
1341 CWStackMode, &winChanges );
1342 wndPrev = WIN_GetDesktop()->child;
1343 if (wndPrev == pWnd) break;
1344 while (wndPrev && (wndPrev->next != pWnd)) wndPrev = wndPrev->next;
1345 pWnd = wndPrev;
1350 /*******************************************************************
1351 * WINPOS_SetActiveWindow
1353 * SetActiveWindow() back-end. This is the only function that
1354 * can assign active status to a window. It must be called only
1355 * for the top level windows.
1357 BOOL32 WINPOS_SetActiveWindow( HWND32 hWnd, BOOL32 fMouse, BOOL32 fChangeFocus)
1359 CBTACTIVATESTRUCT16* cbtStruct;
1360 WND* wndPtr, *wndTemp;
1361 HQUEUE16 hOldActiveQueue, hNewActiveQueue;
1362 WORD wIconized = 0;
1364 /* paranoid checks */
1365 if( hWnd == GetDesktopWindow32() || hWnd == hwndActive ) return 0;
1367 /* if (wndPtr && (GetTaskQueue(0) != wndPtr->hmemTaskQ))
1368 * return 0;
1370 wndPtr = WIN_FindWndPtr(hWnd);
1371 hOldActiveQueue = (pActiveQueue)?pActiveQueue->self : 0;
1373 if( (wndTemp = WIN_FindWndPtr(hwndActive)) )
1374 wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
1375 else
1376 TRACE(win,"no current active window.\n");
1378 /* call CBT hook chain */
1379 if ((cbtStruct = SEGPTR_NEW(CBTACTIVATESTRUCT16)))
1381 LRESULT wRet;
1382 cbtStruct->fMouse = fMouse;
1383 cbtStruct->hWndActive = hwndActive;
1384 wRet = HOOK_CallHooks16( WH_CBT, HCBT_ACTIVATE, (WPARAM16)hWnd,
1385 (LPARAM)SEGPTR_GET(cbtStruct) );
1386 SEGPTR_FREE(cbtStruct);
1387 if (wRet) return wRet;
1390 /* set prev active wnd to current active wnd and send notification */
1391 if ((hwndPrevActive = hwndActive) && IsWindow32(hwndPrevActive))
1393 if (!SendMessage32A( hwndPrevActive, WM_NCACTIVATE, FALSE, 0 ))
1395 if (GetSysModalWindow16() != hWnd) return 0;
1396 /* disregard refusal if hWnd is sysmodal */
1399 #if 1
1400 SendMessage32A( hwndPrevActive, WM_ACTIVATE,
1401 MAKEWPARAM( WA_INACTIVE, wIconized ),
1402 (LPARAM)hWnd );
1403 #else
1404 /* FIXME: must be SendMessage16() because 32A doesn't do
1405 * intertask at this time */
1406 SendMessage16( hwndPrevActive, WM_ACTIVATE, WA_INACTIVE,
1407 MAKELPARAM( (HWND16)hWnd, wIconized ) );
1408 #endif
1410 /* check if something happened during message processing */
1411 if( hwndPrevActive != hwndActive ) return 0;
1414 /* set active wnd */
1415 hwndActive = hWnd;
1417 /* send palette messages */
1418 if (hWnd && SendMessage16( hWnd, WM_QUERYNEWPALETTE, 0, 0L))
1419 SendMessage16((HWND16)-1, WM_PALETTEISCHANGING, (WPARAM16)hWnd, 0L );
1421 /* if prev wnd is minimized redraw icon title */
1422 if( IsIconic32( hwndPrevActive ) ) WINPOS_RedrawIconTitle(hwndPrevActive);
1424 /* managed windows will get ConfigureNotify event */
1425 if (wndPtr && !(wndPtr->dwStyle & WS_CHILD) && !(wndPtr->flags & WIN_MANAGED))
1427 /* check Z-order and bring hWnd to the top */
1428 for (wndTemp = WIN_GetDesktop()->child; wndTemp; wndTemp = wndTemp->next)
1429 if (wndTemp->dwStyle & WS_VISIBLE) break;
1431 if( wndTemp != wndPtr )
1432 SetWindowPos32(hWnd, HWND_TOP, 0,0,0,0,
1433 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE );
1434 if (!IsWindow32(hWnd)) return 0;
1437 hNewActiveQueue = wndPtr ? wndPtr->hmemTaskQ : 0;
1439 /* send WM_ACTIVATEAPP if necessary */
1440 if (hOldActiveQueue != hNewActiveQueue)
1442 WND **list, **ppWnd;
1444 if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1446 for (ppWnd = list; *ppWnd; ppWnd++)
1448 if (!IsWindow32( (*ppWnd)->hwndSelf )) continue;
1450 if ((*ppWnd)->hmemTaskQ == hOldActiveQueue)
1451 SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
1452 0, QUEUE_GetQueueTask(hNewActiveQueue) );
1454 HeapFree( SystemHeap, 0, list );
1457 pActiveQueue = (hNewActiveQueue)
1458 ? (MESSAGEQUEUE*) GlobalLock16(hNewActiveQueue) : NULL;
1460 if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1462 for (ppWnd = list; *ppWnd; ppWnd++)
1464 if (!IsWindow32( (*ppWnd)->hwndSelf )) continue;
1466 if ((*ppWnd)->hmemTaskQ == hNewActiveQueue)
1467 SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
1468 1, QUEUE_GetQueueTask( hOldActiveQueue ) );
1470 HeapFree( SystemHeap, 0, list );
1472 if (!IsWindow32(hWnd)) return 0;
1475 if (hWnd)
1477 /* walk up to the first unowned window */
1478 wndTemp = wndPtr;
1479 while (wndTemp->owner) wndTemp = wndTemp->owner;
1480 /* and set last active owned popup */
1481 wndTemp->hwndLastActive = hWnd;
1483 wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
1484 SendMessage32A( hWnd, WM_NCACTIVATE, TRUE, 0 );
1485 #if 1
1486 SendMessage32A( hWnd, WM_ACTIVATE,
1487 MAKEWPARAM( (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE, wIconized),
1488 (LPARAM)hwndPrevActive );
1489 #else
1490 SendMessage16(hWnd, WM_ACTIVATE, (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE,
1491 MAKELPARAM( (HWND16)hwndPrevActive, wIconized) );
1492 #endif
1494 if( !IsWindow32(hWnd) ) return 0;
1497 /* change focus if possible */
1498 if( fChangeFocus && GetFocus32() )
1499 if( WIN_GetTopParent(GetFocus32()) != hwndActive )
1500 FOCUS_SwitchFocus( GetFocus32(),
1501 (wndPtr->dwStyle & WS_MINIMIZE)? 0: hwndActive);
1503 if( !hwndPrevActive && wndPtr &&
1504 wndPtr->window && !(wndPtr->flags & WIN_MANAGED) )
1505 WINPOS_ForceXWindowRaise(wndPtr);
1507 /* if active wnd is minimized redraw icon title */
1508 if( IsIconic32(hwndActive) ) WINPOS_RedrawIconTitle(hwndActive);
1510 return (hWnd == hwndActive);
1513 /*******************************************************************
1514 * WINPOS_ActivateOtherWindow
1516 * Activates window other than pWnd.
1518 BOOL32 WINPOS_ActivateOtherWindow(WND* pWnd)
1520 BOOL32 bRet = 0;
1521 WND* pWndTo = NULL;
1523 if( pWnd->hwndSelf == hwndPrevActive )
1524 hwndPrevActive = 0;
1526 if( hwndActive != pWnd->hwndSelf &&
1527 ( hwndActive || QUEUE_IsExitingQueue(pWnd->hmemTaskQ)) )
1528 return 0;
1530 if( !(pWnd->dwStyle & WS_POPUP) || !(pWnd->owner) ||
1531 !WINPOS_CanActivate((pWndTo = WIN_GetTopParentPtr(pWnd->owner))) )
1533 WND* pWndPtr = WIN_GetTopParentPtr(pWnd);
1535 pWndTo = WIN_FindWndPtr(hwndPrevActive);
1537 while( !WINPOS_CanActivate(pWndTo) )
1539 /* by now owned windows should've been taken care of */
1541 pWndTo = pWndPtr->next;
1542 pWndPtr = pWndTo;
1543 if( !pWndTo ) break;
1547 bRet = WINPOS_SetActiveWindow( pWndTo ? pWndTo->hwndSelf : 0, FALSE, TRUE );
1549 /* switch desktop queue to current active */
1550 if( pWndTo ) WIN_GetDesktop()->hmemTaskQ = pWndTo->hmemTaskQ;
1552 hwndPrevActive = 0;
1553 return bRet;
1556 /*******************************************************************
1557 * WINPOS_ChangeActiveWindow
1560 BOOL32 WINPOS_ChangeActiveWindow( HWND32 hWnd, BOOL32 mouseMsg )
1562 WND *wndPtr = WIN_FindWndPtr(hWnd);
1564 if (!hWnd) return WINPOS_SetActiveWindow( 0, mouseMsg, TRUE );
1566 if( !wndPtr ) return FALSE;
1568 /* child windows get WM_CHILDACTIVATE message */
1569 if( (wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD )
1570 return SendMessage32A(hWnd, WM_CHILDACTIVATE, 0, 0L);
1572 /* owned popups imply owner activation - not sure */
1573 if ((wndPtr->dwStyle & WS_POPUP) && wndPtr->owner &&
1574 !(wndPtr->owner->dwStyle & WS_DISABLED ))
1576 if (!(wndPtr = wndPtr->owner)) return FALSE;
1577 hWnd = wndPtr->hwndSelf;
1580 if( hWnd == hwndActive ) return FALSE;
1582 if( !WINPOS_SetActiveWindow(hWnd ,mouseMsg ,TRUE) )
1583 return FALSE;
1585 /* switch desktop queue to current active */
1586 if( wndPtr->parent == WIN_GetDesktop())
1587 WIN_GetDesktop()->hmemTaskQ = wndPtr->hmemTaskQ;
1589 return TRUE;
1593 /***********************************************************************
1594 * WINPOS_SendNCCalcSize
1596 * Send a WM_NCCALCSIZE message to a window.
1597 * All parameters are read-only except newClientRect.
1598 * oldWindowRect, oldClientRect and winpos must be non-NULL only
1599 * when calcValidRect is TRUE.
1601 LONG WINPOS_SendNCCalcSize( HWND32 hwnd, BOOL32 calcValidRect,
1602 RECT32 *newWindowRect, RECT32 *oldWindowRect,
1603 RECT32 *oldClientRect, WINDOWPOS32 *winpos,
1604 RECT32 *newClientRect )
1606 NCCALCSIZE_PARAMS32 params;
1607 LONG result;
1609 params.rgrc[0] = *newWindowRect;
1610 if (calcValidRect)
1612 params.rgrc[1] = *oldWindowRect;
1613 params.rgrc[2] = *oldClientRect;
1614 params.lppos = winpos;
1616 result = SendMessage32A( hwnd, WM_NCCALCSIZE, calcValidRect,
1617 (LPARAM)&params );
1618 TRACE(win, "%d,%d-%d,%d\n",
1619 params.rgrc[0].left, params.rgrc[0].top,
1620 params.rgrc[0].right, params.rgrc[0].bottom );
1621 *newClientRect = params.rgrc[0];
1622 return result;
1626 /***********************************************************************
1627 * WINPOS_HandleWindowPosChanging16
1629 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1631 LONG WINPOS_HandleWindowPosChanging16( WND *wndPtr, WINDOWPOS16 *winpos )
1633 POINT32 maxSize, minTrack;
1634 if (winpos->flags & SWP_NOSIZE) return 0;
1635 if ((wndPtr->dwStyle & WS_THICKFRAME) ||
1636 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
1638 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, &minTrack, NULL );
1639 if (maxSize.x < winpos->cx) winpos->cx = maxSize.x;
1640 if (maxSize.y < winpos->cy) winpos->cy = maxSize.y;
1641 if (!(wndPtr->dwStyle & WS_MINIMIZE))
1643 if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x;
1644 if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y;
1647 return 0;
1651 /***********************************************************************
1652 * WINPOS_HandleWindowPosChanging32
1654 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1656 LONG WINPOS_HandleWindowPosChanging32( WND *wndPtr, WINDOWPOS32 *winpos )
1658 POINT32 maxSize;
1659 if (winpos->flags & SWP_NOSIZE) return 0;
1660 if ((wndPtr->dwStyle & WS_THICKFRAME) ||
1661 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
1663 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, NULL, NULL );
1664 winpos->cx = MIN( winpos->cx, maxSize.x );
1665 winpos->cy = MIN( winpos->cy, maxSize.y );
1667 return 0;
1671 /***********************************************************************
1672 * WINPOS_MoveWindowZOrder
1674 * Move a window in Z order, invalidating everything that needs it.
1675 * Only necessary for windows without associated X window.
1677 static void WINPOS_MoveWindowZOrder( HWND32 hwnd, HWND32 hwndAfter )
1679 BOOL32 movingUp;
1680 WND *pWndAfter, *pWndCur, *wndPtr = WIN_FindWndPtr( hwnd );
1682 /* We have two possible cases:
1683 * - The window is moving up: we have to invalidate all areas
1684 * of the window that were covered by other windows
1685 * - The window is moving down: we have to invalidate areas
1686 * of other windows covered by this one.
1689 if (hwndAfter == HWND_TOP)
1691 movingUp = TRUE;
1693 else if (hwndAfter == HWND_BOTTOM)
1695 if (!wndPtr->next) return; /* Already at the bottom */
1696 movingUp = FALSE;
1698 else
1700 if (!(pWndAfter = WIN_FindWndPtr( hwndAfter ))) return;
1701 if (wndPtr->next == pWndAfter) return; /* Already placed right */
1703 /* Determine which window we encounter first in Z-order */
1704 pWndCur = wndPtr->parent->child;
1705 while ((pWndCur != wndPtr) && (pWndCur != pWndAfter))
1706 pWndCur = pWndCur->next;
1707 movingUp = (pWndCur == pWndAfter);
1710 if (movingUp)
1712 WND *pWndPrevAfter = wndPtr->next;
1713 WIN_UnlinkWindow( hwnd );
1714 WIN_LinkWindow( hwnd, hwndAfter );
1715 pWndCur = wndPtr->next;
1716 while (pWndCur != pWndPrevAfter)
1718 RECT32 rect = { pWndCur->rectWindow.left,
1719 pWndCur->rectWindow.top,
1720 pWndCur->rectWindow.right,
1721 pWndCur->rectWindow.bottom };
1722 OffsetRect32( &rect, -wndPtr->rectClient.left,
1723 -wndPtr->rectClient.top );
1724 PAINT_RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN |
1725 RDW_FRAME | RDW_ERASE, 0 );
1726 pWndCur = pWndCur->next;
1729 else /* Moving down */
1731 pWndCur = wndPtr->next;
1732 WIN_UnlinkWindow( hwnd );
1733 WIN_LinkWindow( hwnd, hwndAfter );
1734 while (pWndCur != wndPtr)
1736 RECT32 rect = { pWndCur->rectWindow.left,
1737 pWndCur->rectWindow.top,
1738 pWndCur->rectWindow.right,
1739 pWndCur->rectWindow.bottom };
1740 OffsetRect32( &rect, -pWndCur->rectClient.left,
1741 -pWndCur->rectClient.top );
1742 PAINT_RedrawWindow( pWndCur->hwndSelf, &rect, 0, RDW_INVALIDATE |
1743 RDW_ALLCHILDREN | RDW_FRAME | RDW_ERASE, 0 );
1744 pWndCur = pWndCur->next;
1749 /***********************************************************************
1750 * WINPOS_ReorderOwnedPopups
1752 * fix Z order taking into account owned popups -
1753 * basically we need to maintain them above owner window
1755 HWND32 WINPOS_ReorderOwnedPopups(HWND32 hwndInsertAfter,WND* wndPtr,WORD flags)
1757 WND* w = WIN_GetDesktop()->child;
1759 if( wndPtr->dwStyle & WS_POPUP && wndPtr->owner )
1761 /* implement "local z-order" between the top and owner window */
1763 HWND32 hwndLocalPrev = HWND_TOP;
1765 if( hwndInsertAfter != HWND_TOP )
1767 while( w != wndPtr->owner )
1769 if (w != wndPtr) hwndLocalPrev = w->hwndSelf;
1770 if( hwndLocalPrev == hwndInsertAfter ) break;
1771 w = w->next;
1773 hwndInsertAfter = hwndLocalPrev;
1777 else if( wndPtr->dwStyle & WS_CHILD ) return hwndInsertAfter;
1779 w = WIN_GetDesktop()->child;
1780 while( w )
1782 if( w == wndPtr ) break;
1784 if( w->dwStyle & WS_POPUP && w->owner == wndPtr )
1786 SetWindowPos32(w->hwndSelf, hwndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE |
1787 SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_DEFERERASE);
1788 hwndInsertAfter = w->hwndSelf;
1790 w = w->next;
1793 return hwndInsertAfter;
1796 /***********************************************************************
1797 * WINPOS_SizeMoveClean
1799 * Make window look nice without excessive repainting
1801 * the pain:
1803 * visible regions are in window coordinates
1804 * update regions are in window client coordinates
1805 * client and window rectangles are in parent client coordinates
1807 * FIXME: Move visible and update regions to the same coordinate system
1808 * (either parent client or window). This is a lot of work though.
1810 static UINT32 WINPOS_SizeMoveClean( WND* Wnd, HRGN32 oldVisRgn,
1811 LPRECT32 lpOldWndRect,
1812 LPRECT32 lpOldClientRect, UINT32 uFlags )
1814 HRGN32 newVisRgn = DCE_GetVisRgn(Wnd->hwndSelf,DCX_WINDOW | DCX_CLIPSIBLINGS);
1815 HRGN32 dirtyRgn = CreateRectRgn32(0,0,0,0);
1816 int other, my;
1818 TRACE(win,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n",
1819 Wnd->rectWindow.left, Wnd->rectWindow.top,
1820 Wnd->rectWindow.right, Wnd->rectWindow.bottom,
1821 lpOldWndRect->left, lpOldWndRect->top,
1822 lpOldWndRect->right, lpOldWndRect->bottom);
1823 TRACE(win,"\tnew client=(%i %i-%i %i) old client=(%i %i-%i %i)\n",
1824 Wnd->rectClient.left, Wnd->rectClient.top,
1825 Wnd->rectClient.right, Wnd->rectClient.bottom,
1826 lpOldClientRect->left, lpOldClientRect->top,
1827 lpOldClientRect->right,lpOldClientRect->bottom );
1829 if( (lpOldWndRect->right - lpOldWndRect->left) != (Wnd->rectWindow.right - Wnd->rectWindow.left) ||
1830 (lpOldWndRect->bottom - lpOldWndRect->top) != (Wnd->rectWindow.bottom - Wnd->rectWindow.top) )
1831 uFlags |= SMC_DRAWFRAME;
1833 CombineRgn32( dirtyRgn, newVisRgn, 0, RGN_COPY);
1835 if( !(uFlags & SMC_NOCOPY) )
1836 CombineRgn32( newVisRgn, newVisRgn, oldVisRgn, RGN_AND );
1838 /* map regions to the parent client area */
1840 OffsetRgn32( dirtyRgn, Wnd->rectWindow.left, Wnd->rectWindow.top );
1841 OffsetRgn32( oldVisRgn, lpOldWndRect->left, lpOldWndRect->top );
1843 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1845 other = CombineRgn32(dirtyRgn, oldVisRgn, dirtyRgn, RGN_DIFF);
1847 /* map visible region to the Wnd client area */
1849 OffsetRgn32( newVisRgn, Wnd->rectWindow.left - Wnd->rectClient.left,
1850 Wnd->rectWindow.top - Wnd->rectClient.top );
1852 /* substract previously invalidated region from the Wnd visible region */
1854 my = (Wnd->hrgnUpdate > 1) ? CombineRgn32( newVisRgn, newVisRgn,
1855 Wnd->hrgnUpdate, RGN_DIFF)
1856 : COMPLEXREGION;
1858 if( uFlags & SMC_NOCOPY ) /* invalidate Wnd visible region */
1860 if (my != NULLREGION)
1861 PAINT_RedrawWindow( Wnd->hwndSelf, NULL, newVisRgn, RDW_INVALIDATE |
1862 RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
1863 else if(uFlags & SMC_DRAWFRAME)
1864 Wnd->flags |= WIN_NEEDS_NCPAINT;
1866 else /* bitblt old client area */
1868 HDC32 hDC;
1869 int update;
1870 HRGN32 updateRgn;
1871 int xfrom,yfrom,xto,yto,width,height;
1873 if( uFlags & SMC_DRAWFRAME )
1875 /* copy only client area, frame will be redrawn anyway */
1877 xfrom = lpOldClientRect->left; yfrom = lpOldClientRect->top;
1878 xto = Wnd->rectClient.left; yto = Wnd->rectClient.top;
1879 width = lpOldClientRect->right - xfrom; height = lpOldClientRect->bottom - yfrom;
1880 updateRgn = CreateRectRgn32( 0, 0, width, height );
1881 CombineRgn32( newVisRgn, newVisRgn, updateRgn, RGN_AND );
1882 SetRectRgn32( updateRgn, 0, 0, Wnd->rectClient.right - xto,
1883 Wnd->rectClient.bottom - yto );
1885 else
1887 xfrom = lpOldWndRect->left; yfrom = lpOldWndRect->top;
1888 xto = Wnd->rectWindow.left; yto = Wnd->rectWindow.top;
1889 width = lpOldWndRect->right - xfrom; height = lpOldWndRect->bottom - yfrom;
1890 updateRgn = CreateRectRgn32( xto - Wnd->rectClient.left,
1891 yto - Wnd->rectClient.top,
1892 Wnd->rectWindow.right - Wnd->rectClient.left,
1893 Wnd->rectWindow.bottom - Wnd->rectClient.top );
1896 CombineRgn32( newVisRgn, newVisRgn, updateRgn, RGN_AND );
1898 /* substract new visRgn from target rect to get a region that won't be copied */
1900 update = CombineRgn32( updateRgn, updateRgn, newVisRgn, RGN_DIFF );
1902 /* Blt valid bits using parent window DC */
1904 if( my != NULLREGION && (xfrom != xto || yfrom != yto) )
1907 /* compute clipping region in parent client coordinates */
1909 OffsetRgn32( newVisRgn, Wnd->rectClient.left, Wnd->rectClient.top );
1910 CombineRgn32( oldVisRgn, oldVisRgn, newVisRgn, RGN_OR );
1912 hDC = GetDCEx32( Wnd->parent->hwndSelf, oldVisRgn,
1913 DCX_KEEPCLIPRGN | DCX_INTERSECTRGN |
1914 DCX_CACHE | DCX_CLIPSIBLINGS);
1916 BitBlt32( hDC, xto, yto, width, height, hDC, xfrom, yfrom, SRCCOPY );
1917 ReleaseDC32( Wnd->parent->hwndSelf, hDC);
1920 if( update != NULLREGION )
1921 PAINT_RedrawWindow( Wnd->hwndSelf, NULL, updateRgn, RDW_INVALIDATE |
1922 RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
1923 else if( uFlags & SMC_DRAWFRAME ) Wnd->flags |= WIN_NEEDS_NCPAINT;
1924 DeleteObject32( updateRgn );
1927 /* erase uncovered areas */
1929 if( !(uFlags & SMC_NOPARENTERASE) && (other != NULLREGION ) )
1930 PAINT_RedrawWindow( Wnd->parent->hwndSelf, NULL, dirtyRgn,
1931 RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
1932 DeleteObject32(dirtyRgn);
1933 DeleteObject32(newVisRgn);
1934 return uFlags;
1938 /***********************************************************************
1939 * WINPOS_FindDeskTopXWindow
1941 * Find the actual X window which needs be restacked.
1942 * Used by WINPOS_SetXWindowPos().
1944 static Window WINPOS_FindDeskTopXWindow( WND *wndPtr )
1946 if (!(wndPtr->flags & WIN_MANAGED))
1947 return wndPtr->window;
1948 else
1950 Window window, root, parent, *children;
1951 int nchildren;
1952 window = wndPtr->window;
1953 for (;;)
1955 TSXQueryTree( display, window, &root, &parent,
1956 &children, &nchildren );
1957 TSXFree( children );
1958 if (parent == root)
1959 return window;
1960 window = parent;
1965 /***********************************************************************
1966 * WINPOS_SetXWindowPos
1968 * SetWindowPos() for an X window. Used by the real SetWindowPos().
1970 static void WINPOS_SetXWindowPos( const WINDOWPOS32 *winpos )
1972 XWindowChanges winChanges;
1973 int changeMask = 0;
1974 WND *wndPtr = WIN_FindWndPtr( winpos->hwnd );
1976 if (!(winpos->flags & SWP_NOSIZE))
1978 winChanges.width = winpos->cx;
1979 winChanges.height = winpos->cy;
1980 changeMask |= CWWidth | CWHeight;
1982 /* Tweak dialog window size hints */
1984 if ((wndPtr->flags & WIN_MANAGED) &&
1985 (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME))
1987 XSizeHints *size_hints = TSXAllocSizeHints();
1989 if (size_hints)
1991 long supplied_return;
1993 TSXGetWMSizeHints( display, wndPtr->window, size_hints,
1994 &supplied_return, XA_WM_NORMAL_HINTS);
1995 size_hints->min_width = size_hints->max_width = winpos->cx;
1996 size_hints->min_height = size_hints->max_height = winpos->cy;
1997 TSXSetWMSizeHints( display, wndPtr->window, size_hints,
1998 XA_WM_NORMAL_HINTS );
1999 TSXFree(size_hints);
2003 if (!(winpos->flags & SWP_NOMOVE))
2005 winChanges.x = winpos->x;
2006 winChanges.y = winpos->y;
2007 changeMask |= CWX | CWY;
2009 if (!(winpos->flags & SWP_NOZORDER))
2011 winChanges.stack_mode = Below;
2012 changeMask |= CWStackMode;
2014 if (winpos->hwndInsertAfter == HWND_TOP) winChanges.stack_mode = Above;
2015 else if (winpos->hwndInsertAfter != HWND_BOTTOM)
2017 WND* insertPtr = WIN_FindWndPtr( winpos->hwndInsertAfter );
2018 Window stack[2];
2020 stack[0] = WINPOS_FindDeskTopXWindow( insertPtr );
2021 stack[1] = WINPOS_FindDeskTopXWindow( wndPtr );
2023 /* for stupid window managers (i.e. all of them) */
2025 TSXRestackWindows(display, stack, 2);
2026 changeMask &= ~CWStackMode;
2029 if (!changeMask) return;
2031 TSXReconfigureWMWindow( display, wndPtr->window, 0, changeMask, &winChanges );
2035 /***********************************************************************
2036 * SetWindowPos (USER.232)
2038 BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter,
2039 INT16 x, INT16 y, INT16 cx, INT16 cy, WORD flags)
2041 return SetWindowPos32(hwnd,(INT32)(INT16)hwndInsertAfter,x,y,cx,cy,flags);
2044 /***********************************************************************
2045 * SetWindowPos (USER32.519)
2047 BOOL32 WINAPI SetWindowPos32( HWND32 hwnd, HWND32 hwndInsertAfter,
2048 INT32 x, INT32 y, INT32 cx, INT32 cy, WORD flags)
2050 WINDOWPOS32 winpos;
2051 WND * wndPtr;
2052 RECT32 newWindowRect, newClientRect, oldWindowRect;
2053 HRGN32 visRgn = 0;
2054 HWND32 tempInsertAfter= 0;
2055 int result = 0;
2056 UINT32 uFlags = 0;
2058 TRACE(win,"hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
2059 hwnd, x, y, x+cx, y+cy, flags);
2060 /* Check window handle */
2062 if (hwnd == GetDesktopWindow32()) return FALSE;
2063 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
2065 if(wndPtr->dwStyle & WS_VISIBLE)
2066 flags &= ~SWP_SHOWWINDOW;
2067 else
2069 uFlags |= SMC_NOPARENTERASE;
2070 flags &= ~SWP_HIDEWINDOW;
2071 if (!(flags & SWP_SHOWWINDOW)) flags |= SWP_NOREDRAW;
2074 /* Check for windows that may not be resized
2075 FIXME: this should be done only for Windows 3.0 programs
2076 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
2077 flags |= SWP_NOSIZE | SWP_NOMOVE;
2079 /* Check dimensions */
2081 if (cx <= 0) cx = 1;
2082 if (cy <= 0) cy = 1;
2084 /* Check flags */
2086 if (hwnd == hwndActive) flags |= SWP_NOACTIVATE; /* Already active */
2087 if ((wndPtr->rectWindow.right - wndPtr->rectWindow.left == cx) &&
2088 (wndPtr->rectWindow.bottom - wndPtr->rectWindow.top == cy))
2089 flags |= SWP_NOSIZE; /* Already the right size */
2090 if ((wndPtr->rectWindow.left == x) && (wndPtr->rectWindow.top == y))
2091 flags |= SWP_NOMOVE; /* Already the right position */
2093 /* Check hwndInsertAfter */
2095 if (!(flags & (SWP_NOZORDER | SWP_NOACTIVATE)))
2097 /* Ignore TOPMOST flags when activating a window */
2098 /* _and_ moving it in Z order. */
2099 if ((hwndInsertAfter == HWND_TOPMOST) ||
2100 (hwndInsertAfter == HWND_NOTOPMOST))
2101 hwndInsertAfter = HWND_TOP;
2103 /* TOPMOST not supported yet */
2104 if ((hwndInsertAfter == HWND_TOPMOST) ||
2105 (hwndInsertAfter == HWND_NOTOPMOST)) hwndInsertAfter = HWND_TOP;
2107 /* hwndInsertAfter must be a sibling of the window */
2108 if ((hwndInsertAfter != HWND_TOP) && (hwndInsertAfter != HWND_BOTTOM))
2110 WND* wnd = WIN_FindWndPtr(hwndInsertAfter);
2111 if( wnd->parent != wndPtr->parent ) return FALSE;
2112 if( wnd->next == wndPtr ) flags |= SWP_NOZORDER;
2114 else if (!(wndPtr->window))
2115 /* FIXME: the following optimization is no good for "X-ed" windows */
2116 if (hwndInsertAfter == HWND_TOP)
2117 flags |= ( wndPtr->parent->child == wndPtr)? SWP_NOZORDER: 0;
2118 else /* HWND_BOTTOM */
2119 flags |= ( wndPtr->next )? 0: SWP_NOZORDER;
2121 /* Fill the WINDOWPOS structure */
2123 winpos.hwnd = hwnd;
2124 winpos.hwndInsertAfter = hwndInsertAfter;
2125 winpos.x = x;
2126 winpos.y = y;
2127 winpos.cx = cx;
2128 winpos.cy = cy;
2129 winpos.flags = flags;
2131 /* Send WM_WINDOWPOSCHANGING message */
2133 if (!(winpos.flags & SWP_NOSENDCHANGING))
2134 SendMessage32A( hwnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)&winpos );
2136 /* Calculate new position and size */
2138 newWindowRect = wndPtr->rectWindow;
2139 newClientRect = (wndPtr->dwStyle & WS_MINIMIZE) ? wndPtr->rectWindow
2140 : wndPtr->rectClient;
2142 if (!(winpos.flags & SWP_NOSIZE))
2144 newWindowRect.right = newWindowRect.left + winpos.cx;
2145 newWindowRect.bottom = newWindowRect.top + winpos.cy;
2147 if (!(winpos.flags & SWP_NOMOVE))
2149 newWindowRect.left = winpos.x;
2150 newWindowRect.top = winpos.y;
2151 newWindowRect.right += winpos.x - wndPtr->rectWindow.left;
2152 newWindowRect.bottom += winpos.y - wndPtr->rectWindow.top;
2154 OffsetRect32( &newClientRect, winpos.x - wndPtr->rectWindow.left,
2155 winpos.y - wndPtr->rectWindow.top );
2158 winpos.flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
2160 /* Reposition window in Z order */
2162 if (!(winpos.flags & SWP_NOZORDER))
2164 /* reorder owned popups if hwnd is top-level window
2166 if( wndPtr->parent == WIN_GetDesktop() )
2167 hwndInsertAfter = WINPOS_ReorderOwnedPopups( hwndInsertAfter,
2168 wndPtr, winpos.flags );
2170 if (wndPtr->window)
2172 WIN_UnlinkWindow( winpos.hwnd );
2173 WIN_LinkWindow( winpos.hwnd, hwndInsertAfter );
2175 else WINPOS_MoveWindowZOrder( winpos.hwnd, hwndInsertAfter );
2178 if ( !wndPtr->window && !(winpos.flags & SWP_NOREDRAW) &&
2179 ((winpos.flags & (SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED))
2180 != (SWP_NOMOVE | SWP_NOSIZE)) )
2181 visRgn = DCE_GetVisRgn(hwnd, DCX_WINDOW | DCX_CLIPSIBLINGS);
2184 /* Send WM_NCCALCSIZE message to get new client area */
2185 if( (winpos.flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE )
2187 result = WINPOS_SendNCCalcSize( winpos.hwnd, TRUE, &newWindowRect,
2188 &wndPtr->rectWindow, &wndPtr->rectClient,
2189 &winpos, &newClientRect );
2191 /* FIXME: WVR_ALIGNxxx */
2193 if( newClientRect.left != wndPtr->rectClient.left ||
2194 newClientRect.top != wndPtr->rectClient.top )
2195 winpos.flags &= ~SWP_NOCLIENTMOVE;
2197 if( (newClientRect.right - newClientRect.left !=
2198 wndPtr->rectClient.right - wndPtr->rectClient.left) ||
2199 (newClientRect.bottom - newClientRect.top !=
2200 wndPtr->rectClient.bottom - wndPtr->rectClient.top) )
2201 winpos.flags &= ~SWP_NOCLIENTSIZE;
2203 else
2204 if( !(flags & SWP_NOMOVE) && (newClientRect.left != wndPtr->rectClient.left ||
2205 newClientRect.top != wndPtr->rectClient.top) )
2206 winpos.flags &= ~SWP_NOCLIENTMOVE;
2208 /* Update active DCEs
2209 * TODO: Optimize conditions that trigger DCE update.
2212 if( (((winpos.flags & SWP_AGG_NOPOSCHANGE) != SWP_AGG_NOPOSCHANGE) &&
2213 wndPtr->dwStyle & WS_VISIBLE) ||
2214 (flags & (SWP_HIDEWINDOW | SWP_SHOWWINDOW)) )
2216 RECT32 rect;
2218 UnionRect32(&rect, &newWindowRect, &wndPtr->rectWindow);
2219 DCE_InvalidateDCE(wndPtr, &rect);
2222 /* change geometry */
2224 oldWindowRect = wndPtr->rectWindow;
2226 if (wndPtr->window)
2228 RECT32 oldClientRect = wndPtr->rectClient;
2230 tempInsertAfter = winpos.hwndInsertAfter;
2232 winpos.hwndInsertAfter = hwndInsertAfter;
2234 /* postpone geometry change */
2236 if( !(flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW)) )
2238 WINPOS_SetXWindowPos( &winpos );
2239 winpos.hwndInsertAfter = tempInsertAfter;
2241 else uFlags |= SMC_SETXPOS;
2243 wndPtr->rectWindow = newWindowRect;
2244 wndPtr->rectClient = newClientRect;
2246 if( !(flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW)) )
2247 if( (oldClientRect.left - oldWindowRect.left !=
2248 newClientRect.left - newWindowRect.left) ||
2249 (oldClientRect.top - oldWindowRect.top !=
2250 newClientRect.top - newWindowRect.top) ||
2251 winpos.flags & SWP_NOCOPYBITS )
2253 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, RDW_INVALIDATE |
2254 RDW_ALLCHILDREN | RDW_FRAME | RDW_ERASE, 0 );
2255 else
2256 if( winpos.flags & SWP_FRAMECHANGED )
2258 WORD wErase = 0;
2259 RECT32 rect;
2261 if( oldClientRect.right > newClientRect.right )
2263 rect.left = newClientRect.right; rect.top = newClientRect.top;
2264 rect.right = oldClientRect.right; rect.bottom = newClientRect.bottom;
2265 wErase = 1;
2266 PAINT_RedrawWindow( wndPtr->hwndSelf, &rect, 0,
2267 RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN, 0 );
2269 if( oldClientRect.bottom > newClientRect.bottom )
2271 rect.left = newClientRect.left; rect.top = newClientRect.bottom;
2272 rect.right = (wErase)?oldClientRect.right:newClientRect.right;
2273 rect.bottom = oldClientRect.bottom;
2274 wErase = 1;
2275 PAINT_RedrawWindow( wndPtr->hwndSelf, &rect, 0,
2276 RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN, 0 );
2278 if( !wErase ) wndPtr->flags |= WIN_NEEDS_NCPAINT;
2281 else
2283 RECT32 oldClientRect = wndPtr->rectClient;
2285 wndPtr->rectWindow = newWindowRect;
2286 wndPtr->rectClient = newClientRect;
2288 if( oldClientRect.bottom - oldClientRect.top ==
2289 newClientRect.bottom - newClientRect.top ) result &= ~WVR_VREDRAW;
2291 if( oldClientRect.right - oldClientRect.left ==
2292 newClientRect.right - newClientRect.left ) result &= ~WVR_HREDRAW;
2294 if( !(flags & (SWP_NOREDRAW | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) )
2296 uFlags |= ((winpos.flags & SWP_NOCOPYBITS) ||
2297 (result >= WVR_HREDRAW && result < WVR_VALIDRECTS)) ? SMC_NOCOPY : 0;
2298 uFlags |= (winpos.flags & SWP_FRAMECHANGED) ? SMC_DRAWFRAME : 0;
2300 if( (winpos.flags & SWP_AGG_NOGEOMETRYCHANGE) != SWP_AGG_NOGEOMETRYCHANGE )
2301 uFlags = WINPOS_SizeMoveClean(wndPtr, visRgn, &oldWindowRect,
2302 &oldClientRect, uFlags);
2303 else
2305 /* adjust frame and do not erase parent */
2307 if( winpos.flags & SWP_FRAMECHANGED ) wndPtr->flags |= WIN_NEEDS_NCPAINT;
2308 if( winpos.flags & SWP_NOZORDER ) uFlags |= SMC_NOPARENTERASE;
2311 DeleteObject32(visRgn);
2314 if (flags & SWP_SHOWWINDOW)
2316 wndPtr->dwStyle |= WS_VISIBLE;
2317 if (wndPtr->window)
2319 HWND32 focus, curr;
2321 if( uFlags & SMC_SETXPOS )
2323 WINPOS_SetXWindowPos( &winpos );
2324 winpos.hwndInsertAfter = tempInsertAfter;
2326 TSXMapWindow( display, wndPtr->window );
2328 /* If focus was set to an unmapped window, reset X focus now */
2329 focus = curr = GetFocus32();
2330 while (curr) {
2331 if (curr == hwnd) {
2332 SetFocus32( 0 );
2333 SetFocus32( focus );
2334 break;
2336 curr = GetParent32(curr);
2339 else
2341 if (!(flags & SWP_NOREDRAW))
2342 PAINT_RedrawWindow( winpos.hwnd, NULL, 0,
2343 RDW_INVALIDATE | RDW_ALLCHILDREN |
2344 RDW_FRAME | RDW_ERASENOW | RDW_ERASE, 0 );
2347 else if (flags & SWP_HIDEWINDOW)
2349 wndPtr->dwStyle &= ~WS_VISIBLE;
2350 if (wndPtr->window)
2352 TSXUnmapWindow( display, wndPtr->window );
2353 if( uFlags & SMC_SETXPOS )
2355 WINPOS_SetXWindowPos( &winpos );
2356 winpos.hwndInsertAfter = tempInsertAfter;
2359 else
2361 if (!(flags & SWP_NOREDRAW))
2362 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, &oldWindowRect,
2363 0, RDW_INVALIDATE | RDW_ALLCHILDREN |
2364 RDW_ERASE | RDW_ERASENOW, 0 );
2365 uFlags |= SMC_NOPARENTERASE;
2368 if ((winpos.hwnd == GetFocus32()) ||
2369 IsChild32( winpos.hwnd, GetFocus32()))
2371 /* Revert focus to parent */
2372 SetFocus32( GetParent32(winpos.hwnd) );
2374 if (hwnd == CARET_GetHwnd()) DestroyCaret32();
2376 if (winpos.hwnd == hwndActive)
2377 WINPOS_ActivateOtherWindow( wndPtr );
2380 /* Activate the window */
2382 if (!(flags & SWP_NOACTIVATE))
2383 WINPOS_ChangeActiveWindow( winpos.hwnd, FALSE );
2385 /* Repaint the window */
2387 if (wndPtr->window) EVENT_Synchronize(); /* Wait for all expose events */
2389 if (!GetCapture32())
2390 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
2392 if (!(flags & SWP_DEFERERASE) && !(uFlags & SMC_NOPARENTERASE) )
2393 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, NULL, 0, RDW_ALLCHILDREN | RDW_ERASENOW, 0 );
2394 else if( wndPtr->parent == WIN_GetDesktop() && wndPtr->parent->flags & WIN_NEEDS_ERASEBKGND )
2395 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, NULL, 0, RDW_NOCHILDREN | RDW_ERASENOW, 0 );
2397 /* And last, send the WM_WINDOWPOSCHANGED message */
2399 TRACE(win,"\tstatus flags = %04x\n", winpos.flags & SWP_AGG_STATUSFLAGS);
2401 if ( ((winpos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE) &&
2402 !(winpos.flags & SWP_NOSENDCHANGING))
2403 SendMessage32A( winpos.hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)&winpos );
2405 return TRUE;
2409 /***********************************************************************
2410 * BeginDeferWindowPos16 (USER.259)
2412 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
2414 return BeginDeferWindowPos32( count );
2418 /***********************************************************************
2419 * BeginDeferWindowPos32 (USER32.8)
2421 HDWP32 WINAPI BeginDeferWindowPos32( INT32 count )
2423 HDWP32 handle;
2424 DWP *pDWP;
2426 if (count <= 0) return 0;
2427 handle = USER_HEAP_ALLOC( sizeof(DWP) + (count-1)*sizeof(WINDOWPOS32) );
2428 if (!handle) return 0;
2429 pDWP = (DWP *) USER_HEAP_LIN_ADDR( handle );
2430 pDWP->actualCount = 0;
2431 pDWP->suggestedCount = count;
2432 pDWP->valid = TRUE;
2433 pDWP->wMagic = DWP_MAGIC;
2434 pDWP->hwndParent = 0;
2435 return handle;
2439 /***********************************************************************
2440 * DeferWindowPos16 (USER.260)
2442 HDWP16 WINAPI DeferWindowPos16( HDWP16 hdwp, HWND16 hwnd, HWND16 hwndAfter,
2443 INT16 x, INT16 y, INT16 cx, INT16 cy,
2444 UINT16 flags )
2446 return DeferWindowPos32( hdwp, hwnd, (INT32)(INT16)hwndAfter,
2447 x, y, cx, cy, flags );
2451 /***********************************************************************
2452 * DeferWindowPos32 (USER32.127)
2454 HDWP32 WINAPI DeferWindowPos32( HDWP32 hdwp, HWND32 hwnd, HWND32 hwndAfter,
2455 INT32 x, INT32 y, INT32 cx, INT32 cy,
2456 UINT32 flags )
2458 DWP *pDWP;
2459 int i;
2460 HDWP32 newhdwp = hdwp;
2461 HWND32 parent;
2462 WND *pWnd;
2464 pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp );
2465 if (!pDWP) return 0;
2466 if (hwnd == GetDesktopWindow32()) return 0;
2468 /* All the windows of a DeferWindowPos() must have the same parent */
2469 if (!(pWnd=WIN_FindWndPtr( hwnd ))) {
2470 USER_HEAP_FREE( hdwp );
2471 return 0;
2474 parent = pWnd->parent->hwndSelf;
2475 if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
2476 else if (parent != pDWP->hwndParent)
2478 USER_HEAP_FREE( hdwp );
2479 return 0;
2482 for (i = 0; i < pDWP->actualCount; i++)
2484 if (pDWP->winPos[i].hwnd == hwnd)
2486 /* Merge with the other changes */
2487 if (!(flags & SWP_NOZORDER))
2489 pDWP->winPos[i].hwndInsertAfter = hwndAfter;
2491 if (!(flags & SWP_NOMOVE))
2493 pDWP->winPos[i].x = x;
2494 pDWP->winPos[i].y = y;
2496 if (!(flags & SWP_NOSIZE))
2498 pDWP->winPos[i].cx = cx;
2499 pDWP->winPos[i].cy = cy;
2501 pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
2502 SWP_NOZORDER | SWP_NOREDRAW |
2503 SWP_NOACTIVATE | SWP_NOCOPYBITS|
2504 SWP_NOOWNERZORDER);
2505 pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
2506 SWP_FRAMECHANGED);
2507 return hdwp;
2510 if (pDWP->actualCount >= pDWP->suggestedCount)
2512 newhdwp = USER_HEAP_REALLOC( hdwp,
2513 sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS32) );
2514 if (!newhdwp) return 0;
2515 pDWP = (DWP *) USER_HEAP_LIN_ADDR( newhdwp );
2516 pDWP->suggestedCount++;
2518 pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
2519 pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
2520 pDWP->winPos[pDWP->actualCount].x = x;
2521 pDWP->winPos[pDWP->actualCount].y = y;
2522 pDWP->winPos[pDWP->actualCount].cx = cx;
2523 pDWP->winPos[pDWP->actualCount].cy = cy;
2524 pDWP->winPos[pDWP->actualCount].flags = flags;
2525 pDWP->actualCount++;
2526 return newhdwp;
2530 /***********************************************************************
2531 * EndDeferWindowPos16 (USER.261)
2533 BOOL16 WINAPI EndDeferWindowPos16( HDWP16 hdwp )
2535 return EndDeferWindowPos32( hdwp );
2539 /***********************************************************************
2540 * EndDeferWindowPos32 (USER32.172)
2542 BOOL32 WINAPI EndDeferWindowPos32( HDWP32 hdwp )
2544 DWP *pDWP;
2545 WINDOWPOS32 *winpos;
2546 BOOL32 res = TRUE;
2547 int i;
2549 pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp );
2550 if (!pDWP) return FALSE;
2551 for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
2553 if (!(res = SetWindowPos32( winpos->hwnd, winpos->hwndInsertAfter,
2554 winpos->x, winpos->y, winpos->cx,
2555 winpos->cy, winpos->flags ))) break;
2557 USER_HEAP_FREE( hdwp );
2558 return res;
2562 /***********************************************************************
2563 * TileChildWindows (USER.199)
2565 void WINAPI TileChildWindows( HWND16 parent, WORD action )
2567 printf("STUB TileChildWindows(%04x, %d)\n", parent, action);
2570 /***********************************************************************
2571 * CascageChildWindows (USER.198)
2573 void WINAPI CascadeChildWindows( HWND16 parent, WORD action )
2575 printf("STUB CascadeChildWindows(%04x, %d)\n", parent, action);