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 SWP_AGG_NOGEOMETRYCHANGE \
28 (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
29 #define SWP_AGG_NOPOSCHANGE \
30 (SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
31 #define SWP_AGG_STATUSFLAGS \
32 (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
34 #define SMC_NOCOPY 0x0001
35 #define SMC_NOPARENTERASE 0x0002
36 #define SMC_DRAWFRAME 0x0004
37 #define SMC_SETXPOS 0x0008
39 /* ----- external functions ----- */
41 extern void FOCUS_SwitchFocus( HWND
, HWND
);
42 extern HRGN32
DCE_GetVisRgn( HWND
, WORD
);
43 extern HWND
CARET_GetHwnd();
44 extern BOOL
DCE_InvalidateDCE(WND
*, RECT16
* );
46 /* ----- internal variables ----- */
48 static HWND hwndActive
= 0; /* Currently active window */
49 static HWND hwndPrevActive
= 0; /* Previously active window */
51 extern MESSAGEQUEUE
* pActiveQueue
;
53 /***********************************************************************
56 void WINPOS_CheckActive( HWND32 hwnd
)
58 if( hwnd
== hwndPrevActive
) hwndPrevActive
= 0;
59 if( hwnd
== hwndActive
)
62 dprintf_win(stddeb
,"\tattempt to activate destroyed window!\n");
66 /***********************************************************************
69 * Find a suitable place for an iconic window.
70 * The new position is stored into wndPtr->ptIconPos.
72 void WINPOS_FindIconPos( HWND32 hwnd
)
75 short x
, y
, xspacing
, yspacing
;
76 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
78 if (!wndPtr
|| !wndPtr
->parent
) return;
79 GetClientRect16( wndPtr
->parent
->hwndSelf
, &rectParent
);
80 if ((wndPtr
->ptIconPos
.x
>= rectParent
.left
) &&
81 (wndPtr
->ptIconPos
.x
+ SYSMETRICS_CXICON
< rectParent
.right
) &&
82 (wndPtr
->ptIconPos
.y
>= rectParent
.top
) &&
83 (wndPtr
->ptIconPos
.y
+ SYSMETRICS_CYICON
< rectParent
.bottom
))
84 return; /* The icon already has a suitable position */
86 xspacing
= yspacing
= 70; /* FIXME: This should come from WIN.INI */
87 y
= rectParent
.bottom
;
90 for (x
= rectParent
.left
; x
<=rectParent
.right
-xspacing
; x
+= xspacing
)
92 /* Check if another icon already occupies this spot */
93 WND
*childPtr
= wndPtr
->parent
->child
;
96 if ((childPtr
->dwStyle
& WS_MINIMIZE
) && (childPtr
!= wndPtr
))
98 if ((childPtr
->rectWindow
.left
< x
+ xspacing
) &&
99 (childPtr
->rectWindow
.right
>= x
) &&
100 (childPtr
->rectWindow
.top
<= y
) &&
101 (childPtr
->rectWindow
.bottom
> y
- yspacing
))
102 break; /* There's a window in there */
104 childPtr
= childPtr
->next
;
108 /* No window was found, so it's OK for us */
109 wndPtr
->ptIconPos
.x
= x
+ (xspacing
- SYSMETRICS_CXICON
) / 2;
110 wndPtr
->ptIconPos
.y
= y
- (yspacing
+ SYSMETRICS_CYICON
) / 2;
119 /***********************************************************************
120 * ArrangeIconicWindows (USER.170)
122 UINT
ArrangeIconicWindows( HWND parent
)
126 INT x
, y
, xspacing
, yspacing
;
128 GetClientRect16( parent
, &rectParent
);
130 y
= rectParent
.bottom
;
131 xspacing
= yspacing
= 70; /* FIXME: This should come from WIN.INI */
132 hwndChild
= GetWindow( parent
, GW_CHILD
);
135 if (IsIconic( hwndChild
))
137 SetWindowPos( hwndChild
, 0, x
+ (xspacing
- SYSMETRICS_CXICON
) / 2,
138 y
- (yspacing
+ SYSMETRICS_CYICON
) / 2, 0, 0,
139 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
140 if (x
<= rectParent
.right
- xspacing
) x
+= xspacing
;
147 hwndChild
= GetWindow( hwndChild
, GW_HWNDNEXT
);
153 /***********************************************************************
154 * GetWindowRect16 (USER.32)
156 void GetWindowRect16( HWND16 hwnd
, LPRECT16 rect
)
158 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
161 *rect
= wndPtr
->rectWindow
;
162 if (wndPtr
->dwStyle
& WS_CHILD
)
163 MapWindowPoints16( wndPtr
->parent
->hwndSelf
, 0, (POINT16
*)rect
, 2 );
167 /***********************************************************************
168 * GetWindowRect32 (USER.32)
170 void GetWindowRect32( HWND32 hwnd
, LPRECT32 rect
)
172 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
175 CONV_RECT16TO32( &wndPtr
->rectWindow
, rect
);
176 if (wndPtr
->dwStyle
& WS_CHILD
)
177 MapWindowPoints32( wndPtr
->parent
->hwndSelf
, 0, (POINT32
*)rect
, 2 );
181 /***********************************************************************
182 * GetClientRect16 (USER.33)
184 void GetClientRect16( HWND16 hwnd
, LPRECT16 rect
)
186 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
188 rect
->left
= rect
->top
= rect
->right
= rect
->bottom
= 0;
191 rect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
;
192 rect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
;
197 /***********************************************************************
198 * GetClientRect32 (USER32.219)
200 void GetClientRect32( HWND32 hwnd
, LPRECT32 rect
)
202 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
204 rect
->left
= rect
->top
= rect
->right
= rect
->bottom
= 0;
207 rect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
;
208 rect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
;
213 /*******************************************************************
214 * ClientToScreen16 (USER.28)
216 BOOL16
ClientToScreen16( HWND16 hwnd
, LPPOINT16 lppnt
)
218 MapWindowPoints16( hwnd
, 0, lppnt
, 1 );
223 /*******************************************************************
224 * ClientToScreen32 (USER32.51)
226 BOOL32
ClientToScreen32( HWND32 hwnd
, LPPOINT32 lppnt
)
228 MapWindowPoints32( hwnd
, 0, lppnt
, 1 );
233 /*******************************************************************
234 * ScreenToClient16 (USER.29)
236 void ScreenToClient16( HWND16 hwnd
, LPPOINT16 lppnt
)
238 MapWindowPoints16( 0, hwnd
, lppnt
, 1 );
242 /*******************************************************************
243 * ScreenToClient32 (USER32.446)
245 void ScreenToClient32( HWND32 hwnd
, LPPOINT32 lppnt
)
247 MapWindowPoints32( 0, hwnd
, lppnt
, 1 );
251 /***********************************************************************
252 * WINPOS_WindowFromPoint
254 * Find the window and hittest for a given point.
256 INT16
WINPOS_WindowFromPoint( WND
* wndScope
, POINT16 pt
, WND
**ppWnd
)
259 INT16 hittest
= HTERROR
;
265 wndPtr
= wndScope
->child
;
270 /* If point is in window, and window is visible, and it */
271 /* is enabled (or it's a top-level window), then explore */
272 /* its children. Otherwise, go to the next window. */
274 if ((wndPtr
->dwStyle
& WS_VISIBLE
) &&
275 (!(wndPtr
->dwStyle
& WS_DISABLED
) ||
276 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) != WS_CHILD
)) &&
277 (x
>= wndPtr
->rectWindow
.left
) &&
278 (x
< wndPtr
->rectWindow
.right
) &&
279 (y
>= wndPtr
->rectWindow
.top
) &&
280 (y
< wndPtr
->rectWindow
.bottom
))
282 *ppWnd
= wndPtr
; /* Got a suitable window */
284 /* If window is minimized or disabled, return at once */
285 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
286 if (wndPtr
->dwStyle
& WS_DISABLED
) return HTERROR
;
288 /* If point is not in client area, ignore the children */
289 if ((x
< wndPtr
->rectClient
.left
) ||
290 (x
>= wndPtr
->rectClient
.right
) ||
291 (y
< wndPtr
->rectClient
.top
) ||
292 (y
>= wndPtr
->rectClient
.bottom
)) break;
294 x
-= wndPtr
->rectClient
.left
;
295 y
-= wndPtr
->rectClient
.top
;
296 wndPtr
= wndPtr
->child
;
298 else wndPtr
= wndPtr
->next
;
301 /* If nothing found, return the scope window */
305 if( pt
.x
>= (wndScope
->rectClient
.left
- wndScope
->rectWindow
.left
) &&
306 pt
.x
>= (wndScope
->rectClient
.top
- wndScope
->rectWindow
.top
) &&
307 pt
.x
<= (wndScope
->rectClient
.right
- wndScope
->rectWindow
.left
) &&
308 pt
.x
<= (wndScope
->rectClient
.bottom
- wndScope
->rectWindow
.top
) )
310 if( pt
.x
< 0 || pt
.y
< 0 ||
311 pt
.x
> (wndScope
->rectWindow
.right
- wndScope
->rectWindow
.left
) ||
312 pt
.y
> (wndScope
->rectWindow
.bottom
- wndScope
->rectWindow
.top
) )
314 return HTCAPTION
; /* doesn't matter in this case */
317 /* Send the WM_NCHITTEST message (only if to the same task) */
318 if ((*ppWnd
)->hmemTaskQ
!= GetTaskQueue(0)) return HTCLIENT
;
319 hittest
= (INT
)SendMessage16( (*ppWnd
)->hwndSelf
, WM_NCHITTEST
, 0,
320 MAKELONG( pt
.x
, pt
.y
) );
321 if (hittest
!= HTTRANSPARENT
) return hittest
; /* Found the window */
323 /* If no children found in last search, make point relative to parent*/
326 x
+= (*ppWnd
)->rectClient
.left
;
327 y
+= (*ppWnd
)->rectClient
.top
;
330 /* Restart the search from the next sibling */
331 wndPtr
= (*ppWnd
)->next
;
332 *ppWnd
= (*ppWnd
)->parent
;
337 /*******************************************************************
338 * WindowFromPoint16 (USER.30)
340 HWND16
WindowFromPoint16( POINT16 pt
)
343 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt
, &pWnd
);
344 return pWnd
->hwndSelf
;
348 /*******************************************************************
349 * WindowFromPoint32 (USER32.581)
351 HWND32
WindowFromPoint32( POINT32 pt
)
355 CONV_POINT32TO16( &pt
, &pt16
);
356 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt16
, &pWnd
);
357 return (HWND32
)pWnd
->hwndSelf
;
361 /*******************************************************************
362 * ChildWindowFromPoint16 (USER.191)
364 HWND16
ChildWindowFromPoint16( HWND16 hwndParent
, POINT16 pt
)
366 /* pt is in the client coordinates */
368 WND
* wnd
= WIN_FindWndPtr(hwndParent
);
373 /* get client rect fast */
374 rect
.top
= rect
.left
= 0;
375 rect
.right
= wnd
->rectClient
.right
- wnd
->rectClient
.left
;
376 rect
.bottom
= wnd
->rectClient
.bottom
- wnd
->rectClient
.top
;
378 if (!PtInRect16( &rect
, pt
)) return 0;
383 if (PtInRect16( &wnd
->rectWindow
, pt
)) return wnd
->hwndSelf
;
390 /*******************************************************************
391 * ChildWindowFromPoint32 (USER32.)
393 HWND32
ChildWindowFromPoint32( HWND32 hwndParent
, POINT32 pt
)
396 CONV_POINT32TO16( &pt
, &pt16
);
397 return (HWND32
)ChildWindowFromPoint16( hwndParent
, pt16
);
401 /*******************************************************************
402 * WINPOS_GetWinOffset
404 * Calculate the offset between the origin of the two windows. Used
405 * to implement MapWindowPoints.
407 static void WINPOS_GetWinOffset( HWND32 hwndFrom
, HWND32 hwndTo
,
412 offset
->x
= offset
->y
= 0;
413 if (hwndFrom
== hwndTo
) return;
415 /* Translate source window origin to screen coords */
418 if (!(wndPtr
= WIN_FindWndPtr( hwndFrom
)))
420 fprintf(stderr
,"MapWindowPoints: bad hwndFrom = %04x\n",hwndFrom
);
423 while (wndPtr
->parent
)
425 offset
->x
+= wndPtr
->rectClient
.left
;
426 offset
->y
+= wndPtr
->rectClient
.top
;
427 wndPtr
= wndPtr
->parent
;
431 /* Translate origin to destination window coords */
434 if (!(wndPtr
= WIN_FindWndPtr( hwndTo
)))
436 fprintf(stderr
,"MapWindowPoints: bad hwndTo = %04x\n", hwndTo
);
439 while (wndPtr
->parent
)
441 offset
->x
-= wndPtr
->rectClient
.left
;
442 offset
->y
-= wndPtr
->rectClient
.top
;
443 wndPtr
= wndPtr
->parent
;
449 /*******************************************************************
450 * MapWindowPoints16 (USER.258)
452 void MapWindowPoints16( HWND16 hwndFrom
, HWND16 hwndTo
,
453 LPPOINT16 lppt
, UINT16 count
)
457 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
467 /*******************************************************************
468 * MapWindowPoints32 (USER32.385)
470 void MapWindowPoints32( HWND32 hwndFrom
, HWND32 hwndTo
,
471 LPPOINT32 lppt
, UINT32 count
)
475 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
485 /***********************************************************************
488 BOOL
IsIconic(HWND hWnd
)
490 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
491 if (wndPtr
== NULL
) return FALSE
;
492 return (wndPtr
->dwStyle
& WS_MINIMIZE
) != 0;
496 /***********************************************************************
497 * IsZoomed (USER.272)
499 BOOL
IsZoomed(HWND hWnd
)
501 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
502 if (wndPtr
== NULL
) return FALSE
;
503 return (wndPtr
->dwStyle
& WS_MAXIMIZE
) != 0;
507 /*******************************************************************
508 * GetActiveWindow (USER.60)
510 HWND
GetActiveWindow(void)
516 /*******************************************************************
517 * WINPOS_IsGoodEnough
519 static BOOL32
WINPOS_IsGoodEnough(WND
* pWnd
)
521 return (pWnd
) ? ((!(pWnd
->dwStyle
& WS_DISABLED
) &&
522 pWnd
->dwStyle
& WS_VISIBLE
) ? TRUE
: FALSE
) : FALSE
;
526 /*******************************************************************
527 * SetActiveWindow (USER.59)
529 HWND
SetActiveWindow( HWND hwnd
)
531 HWND prev
= hwndActive
;
532 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
534 if ( !WINPOS_IsGoodEnough(wndPtr
) ) return 0;
536 WINPOS_SetActiveWindow( hwnd
, 0, 0 );
541 /***********************************************************************
542 * BringWindowToTop (USER.45)
544 BOOL
BringWindowToTop( HWND hwnd
)
546 return SetWindowPos( hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
);
550 /***********************************************************************
551 * MoveWindow (USER.56)
553 BOOL
MoveWindow( HWND hwnd
, short x
, short y
, short cx
, short cy
, BOOL repaint
)
555 int flags
= SWP_NOZORDER
| SWP_NOACTIVATE
;
556 if (!repaint
) flags
|= SWP_NOREDRAW
;
557 dprintf_win(stddeb
, "MoveWindow: %04x %d,%d %dx%d %d\n",
558 hwnd
, x
, y
, cx
, cy
, repaint
);
559 return SetWindowPos( hwnd
, 0, x
, y
, cx
, cy
, flags
);
563 /***********************************************************************
564 * ShowWindow (USER.42)
566 BOOL
ShowWindow( HWND hwnd
, int cmd
)
568 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
569 BOOL32 wasVisible
, showFlag
;
572 short x
= 0, y
= 0, cx
= 0, cy
= 0;
574 if (!wndPtr
) return FALSE
;
576 dprintf_win(stddeb
,"ShowWindow: hwnd=%04x, cmd=%d\n", hwnd
, cmd
);
578 wasVisible
= (wndPtr
->dwStyle
& WS_VISIBLE
) != 0;
583 if (!wasVisible
) return FALSE
;
584 swpflags
|= SWP_HIDEWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
|
585 SWP_NOACTIVATE
| SWP_NOZORDER
;
588 case SW_SHOWMINNOACTIVE
:
589 swpflags
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
591 case SW_SHOWMINIMIZED
:
592 swpflags
|= SWP_SHOWWINDOW
;
595 swpflags
|= SWP_FRAMECHANGED
;
596 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
598 if( HOOK_CallHooks16( WH_CBT
, HCBT_MINMAX
, hwnd
, cmd
) )
601 if (wndPtr
->dwStyle
& WS_MAXIMIZE
)
603 wndPtr
->flags
|= WIN_RESTORE_MAX
;
604 wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
608 wndPtr
->flags
&= ~WIN_RESTORE_MAX
;
609 wndPtr
->rectNormal
= wndPtr
->rectWindow
;
611 wndPtr
->dwStyle
|= WS_MINIMIZE
;
612 WINPOS_FindIconPos( hwnd
);
613 x
= wndPtr
->ptIconPos
.x
;
614 y
= wndPtr
->ptIconPos
.y
;
615 cx
= SYSMETRICS_CXICON
;
616 cy
= SYSMETRICS_CYICON
;
617 swpflags
|= SWP_NOCOPYBITS
;
619 else swpflags
|= SWP_NOSIZE
| SWP_NOMOVE
;
622 case SW_SHOWMAXIMIZED
: /* same as SW_MAXIMIZE: */
623 swpflags
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
624 if (!(wndPtr
->dwStyle
& WS_MAXIMIZE
))
626 if( HOOK_CallHooks16( WH_CBT
, HCBT_MINMAX
, hwnd
, cmd
) )
629 /* Store the current position and find the maximized size */
630 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
631 wndPtr
->rectNormal
= wndPtr
->rectWindow
;
633 NC_GetMinMaxInfo( wndPtr
, &maxSize
,
634 &wndPtr
->ptMaxPos
, NULL
, NULL
);
635 x
= wndPtr
->ptMaxPos
.x
;
636 y
= wndPtr
->ptMaxPos
.y
;
638 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
639 if( !SendMessage16( hwnd
, WM_QUERYOPEN
, 0, 0L ) )
641 swpflags
|= SWP_NOSIZE
| SWP_NOMOVE
;
644 else swpflags
|= SWP_NOCOPYBITS
;
648 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
649 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
651 else swpflags
|= SWP_NOSIZE
| SWP_NOMOVE
;
655 swpflags
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
658 swpflags
|= SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
;
661 case SW_SHOWNOACTIVATE
:
662 swpflags
|= SWP_NOZORDER
;
663 if (GetActiveWindow()) swpflags
|= SWP_NOACTIVATE
;
665 case SW_SHOWNORMAL
: /* same as SW_NORMAL: */
666 case SW_SHOWDEFAULT
: /* FIXME: should have its own handler */
668 swpflags
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
670 if (wndPtr
->dwStyle
& WS_MINIMIZE
)
672 if( HOOK_CallHooks16( WH_CBT
, HCBT_MINMAX
, hwnd
, cmd
) )
675 if( !SendMessage16( hwnd
, WM_QUERYOPEN
, 0, 0L) )
677 swpflags
|= SWP_NOSIZE
| SWP_NOMOVE
;
680 wndPtr
->ptIconPos
.x
= wndPtr
->rectWindow
.left
;
681 wndPtr
->ptIconPos
.y
= wndPtr
->rectWindow
.top
;
682 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
683 if (wndPtr
->flags
& WIN_RESTORE_MAX
)
685 /* Restore to maximized position */
686 NC_GetMinMaxInfo( wndPtr
, &maxSize
, &wndPtr
->ptMaxPos
,
688 x
= wndPtr
->ptMaxPos
.x
;
689 y
= wndPtr
->ptMaxPos
.y
;
692 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
694 else /* Restore to normal position */
696 x
= wndPtr
->rectNormal
.left
;
697 y
= wndPtr
->rectNormal
.top
;
698 cx
= wndPtr
->rectNormal
.right
- wndPtr
->rectNormal
.left
;
699 cy
= wndPtr
->rectNormal
.bottom
- wndPtr
->rectNormal
.top
;
701 swpflags
|= SWP_NOCOPYBITS
;
703 else if (wndPtr
->dwStyle
& WS_MAXIMIZE
)
705 if( HOOK_CallHooks16( WH_CBT
, HCBT_MINMAX
, hwnd
, cmd
) )
708 wndPtr
->ptMaxPos
.x
= wndPtr
->rectWindow
.left
;
709 wndPtr
->ptMaxPos
.y
= wndPtr
->rectWindow
.top
;
710 wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
711 x
= wndPtr
->rectNormal
.left
;
712 y
= wndPtr
->rectNormal
.top
;
713 cx
= wndPtr
->rectNormal
.right
- wndPtr
->rectNormal
.left
;
714 cy
= wndPtr
->rectNormal
.bottom
- wndPtr
->rectNormal
.top
;
716 else swpflags
|= SWP_NOSIZE
| SWP_NOMOVE
;
720 showFlag
= (cmd
!= SW_HIDE
);
721 if (showFlag
!= wasVisible
)
723 SendMessage16( hwnd
, WM_SHOWWINDOW
, showFlag
, 0 );
724 if (!IsWindow( hwnd
)) return wasVisible
;
727 if ((wndPtr
->dwStyle
& WS_CHILD
) &&
728 !IsWindowVisible( wndPtr
->parent
->hwndSelf
) &&
729 (swpflags
& SWP_NOSIZE
) && (swpflags
& SWP_NOMOVE
))
731 /* Don't call SetWindowPos() on invisible child windows */
732 if (cmd
== SW_HIDE
) wndPtr
->dwStyle
&= ~WS_VISIBLE
;
733 else wndPtr
->dwStyle
|= WS_VISIBLE
;
737 /* We can't activate a child window */
738 if (wndPtr
->dwStyle
& WS_CHILD
)
739 swpflags
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
740 SetWindowPos( hwnd
, HWND_TOP
, x
, y
, cx
, cy
, swpflags
);
741 if (!IsWindow( hwnd
)) return wasVisible
;
744 if (wndPtr
->flags
& WIN_NEED_SIZE
)
746 /* should happen only in CreateWindowEx() */
747 int wParam
= SIZE_RESTORED
;
749 wndPtr
->flags
&= ~WIN_NEED_SIZE
;
750 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wParam
= SIZE_MAXIMIZED
;
751 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= SIZE_MINIMIZED
;
752 SendMessage16( hwnd
, WM_SIZE
, wParam
,
753 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
754 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
755 SendMessage16( hwnd
, WM_MOVE
, 0,
756 MAKELONG(wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
) );
763 /***********************************************************************
764 * GetInternalWindowPos16 (USER.460)
766 UINT16
GetInternalWindowPos16( HWND16 hwnd
, LPRECT16 rectWnd
, LPPOINT16 ptIcon
)
768 WINDOWPLACEMENT16 wndpl
;
769 if (!GetWindowPlacement16( hwnd
, &wndpl
)) return 0;
770 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
771 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
772 return wndpl
.showCmd
;
776 /***********************************************************************
777 * GetInternalWindowPos32 (USER32.244)
779 UINT32
GetInternalWindowPos32( HWND32 hwnd
, LPRECT32 rectWnd
, LPPOINT32 ptIcon
)
781 WINDOWPLACEMENT32 wndpl
;
782 if (!GetWindowPlacement32( hwnd
, &wndpl
)) return 0;
783 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
784 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
785 return wndpl
.showCmd
;
789 /***********************************************************************
790 * SetInternalWindowPos16 (USER.461)
792 void SetInternalWindowPos16( HWND16 hwnd
, UINT16 showCmd
,
793 LPRECT16 rect
, LPPOINT16 pt
)
795 WINDOWPLACEMENT16 wndpl
;
796 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
798 wndpl
.length
= sizeof(wndpl
);
799 wndpl
.flags
= (pt
!= NULL
) ? WPF_SETMINPOSITION
: 0;
800 wndpl
.showCmd
= showCmd
;
801 if (pt
) wndpl
.ptMinPosition
= *pt
;
802 wndpl
.rcNormalPosition
= (rect
!= NULL
) ? *rect
: wndPtr
->rectNormal
;
803 wndpl
.ptMaxPosition
= wndPtr
->ptMaxPos
;
804 SetWindowPlacement16( hwnd
, &wndpl
);
808 /***********************************************************************
809 * SetInternalWindowPos32 (USER32.482)
811 void SetInternalWindowPos32( HWND32 hwnd
, UINT32 showCmd
,
812 LPRECT32 rect
, LPPOINT32 pt
)
814 WINDOWPLACEMENT32 wndpl
;
815 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
817 wndpl
.length
= sizeof(wndpl
);
818 wndpl
.flags
= (pt
!= NULL
) ? WPF_SETMINPOSITION
: 0;
819 wndpl
.showCmd
= showCmd
;
820 if (pt
) wndpl
.ptMinPosition
= *pt
;
821 if (rect
) wndpl
.rcNormalPosition
= *rect
;
822 else CONV_RECT16TO32( &wndPtr
->rectNormal
, &wndpl
.rcNormalPosition
);
823 CONV_POINT16TO32( &wndPtr
->ptMaxPos
, &wndpl
.ptMaxPosition
);
824 SetWindowPlacement32( hwnd
, &wndpl
);
828 /***********************************************************************
829 * GetWindowPlacement16 (USER.370)
831 BOOL16
GetWindowPlacement16( HWND16 hwnd
, WINDOWPLACEMENT16
*wndpl
)
833 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
834 if (!wndPtr
) return FALSE
;
836 wndpl
->length
= sizeof(*wndpl
);
838 wndpl
->showCmd
= IsZoomed(hwnd
) ? SW_SHOWMAXIMIZED
:
839 (IsIconic(hwnd
) ? SW_SHOWMINIMIZED
: SW_SHOWNORMAL
);
840 wndpl
->ptMinPosition
= wndPtr
->ptIconPos
;
841 wndpl
->ptMaxPosition
= wndPtr
->ptMaxPos
;
842 wndpl
->rcNormalPosition
= wndPtr
->rectNormal
;
847 /***********************************************************************
848 * GetWindowPlacement32 (USER32.306)
850 BOOL32
GetWindowPlacement32( HWND32 hwnd
, WINDOWPLACEMENT32
*wndpl
)
852 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
853 if (!wndPtr
) return FALSE
;
855 wndpl
->length
= sizeof(*wndpl
);
857 wndpl
->showCmd
= IsZoomed(hwnd
) ? SW_SHOWMAXIMIZED
:
858 (IsIconic(hwnd
) ? SW_SHOWMINIMIZED
: SW_SHOWNORMAL
);
859 CONV_POINT16TO32( &wndPtr
->ptIconPos
, &wndpl
->ptMinPosition
);
860 CONV_POINT16TO32( &wndPtr
->ptMaxPos
, &wndpl
->ptMaxPosition
);
861 CONV_RECT16TO32( &wndPtr
->rectNormal
, &wndpl
->rcNormalPosition
);
866 /***********************************************************************
867 * SetWindowPlacement16 (USER.371)
869 BOOL16
SetWindowPlacement16( HWND16 hwnd
, const WINDOWPLACEMENT16
*wndpl
)
871 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
872 if (!wndPtr
) return FALSE
;
874 if (wndpl
->flags
& WPF_SETMINPOSITION
)
875 wndPtr
->ptIconPos
= wndpl
->ptMinPosition
;
876 if ((wndpl
->flags
& WPF_RESTORETOMAXIMIZED
) &&
877 (wndpl
->showCmd
== SW_SHOWMINIMIZED
)) wndPtr
->flags
|= WIN_RESTORE_MAX
;
878 wndPtr
->ptMaxPos
= wndpl
->ptMaxPosition
;
879 wndPtr
->rectNormal
= wndpl
->rcNormalPosition
;
880 ShowWindow( hwnd
, wndpl
->showCmd
);
885 /***********************************************************************
886 * SetWindowPlacement32 (USER32.518)
888 BOOL32
SetWindowPlacement32( HWND32 hwnd
, const WINDOWPLACEMENT32
*wndpl
)
890 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
891 if (!wndPtr
) return FALSE
;
893 if (wndpl
->flags
& WPF_SETMINPOSITION
)
894 CONV_POINT32TO16( &wndpl
->ptMinPosition
, &wndPtr
->ptIconPos
);
895 if ((wndpl
->flags
& WPF_RESTORETOMAXIMIZED
) &&
896 (wndpl
->showCmd
== SW_SHOWMINIMIZED
)) wndPtr
->flags
|= WIN_RESTORE_MAX
;
897 CONV_POINT32TO16( &wndpl
->ptMaxPosition
, &wndPtr
->ptMaxPos
);
898 CONV_RECT32TO16( &wndpl
->rcNormalPosition
, &wndPtr
->rectNormal
);
899 ShowWindow( hwnd
, wndpl
->showCmd
);
904 /***********************************************************************
905 * WINPOS_ForceXWindowRaise
907 * Raise a window on top of the X stacking order, while preserving
908 * the correct Windows Z order.
910 static void WINPOS_ForceXWindowRaise( WND
* pWnd
)
912 XWindowChanges winChanges
;
915 /* Raise all windows up to pWnd according to their Z order.
916 * (it would be easier with sibling-related Below but it doesn't
917 * work very well with SGI mwm for instance)
919 winChanges
.stack_mode
= Above
;
922 if (pWnd
->window
) XReconfigureWMWindow( display
, pWnd
->window
, 0,
923 CWStackMode
, &winChanges
);
924 wndPrev
= WIN_GetDesktop()->child
;
925 if (wndPrev
== pWnd
) break;
926 while (wndPrev
&& (wndPrev
->next
!= pWnd
)) wndPrev
= wndPrev
->next
;
932 /*******************************************************************
933 * WINPOS_SetActiveWindow
935 * back-end to SetActiveWindow
937 BOOL32
WINPOS_SetActiveWindow( HWND32 hWnd
, BOOL32 fMouse
, BOOL32 fChangeFocus
)
939 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
940 WND
*wndTemp
= WIN_FindWndPtr(hwndActive
);
941 CBTACTIVATESTRUCT16
*cbtStruct
;
943 HQUEUE16 hOldActiveQueue
= (pActiveQueue
)?pActiveQueue
->self
:0;
944 HQUEUE16 hNewActiveQueue
;
946 /* paranoid checks */
947 if( hWnd
== GetDesktopWindow32() || hWnd
== hwndActive
)
950 /* if (wndPtr && (GetTaskQueue(0) != wndPtr->hmemTaskQ))
955 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
957 dprintf_win(stddeb
,"WINPOS_ActivateWindow: no current active window.\n");
959 /* call CBT hook chain */
960 if ((cbtStruct
= SEGPTR_NEW(CBTACTIVATESTRUCT16
)))
963 cbtStruct
->fMouse
= fMouse
;
964 cbtStruct
->hWndActive
= hwndActive
;
965 wRet
= HOOK_CallHooks16( WH_CBT
, HCBT_ACTIVATE
, (WPARAM16
)hWnd
,
966 (LPARAM
)SEGPTR_GET(cbtStruct
) );
967 SEGPTR_FREE(cbtStruct
);
968 if (wRet
) return wRet
;
971 /* set prev active wnd to current active wnd and send notification */
972 if ((hwndPrevActive
= hwndActive
) && IsWindow(hwndPrevActive
))
974 if (!SendMessage16( hwndPrevActive
, WM_NCACTIVATE
, FALSE
, 0 ))
976 if (GetSysModalWindow16() != hWnd
) return 0;
977 /* disregard refusal if hWnd is sysmodal */
980 SendMessage32A( hwndPrevActive
, WM_ACTIVATE
,
981 MAKEWPARAM( WA_INACTIVE
, wIconized
),
984 /* check if something happened during message processing */
985 if( hwndPrevActive
!= hwndActive
) return 0;
991 /* send palette messages */
992 if (hWnd
&& SendMessage16( hWnd
, WM_QUERYNEWPALETTE
, 0, 0L))
993 SendMessage16((HWND16
)-1, WM_PALETTEISCHANGING
, (WPARAM16
)hWnd
, 0L );
995 /* if prev wnd is minimized redraw icon title
998 wndTemp = WIN_FindWndPtr( WIN_GetTopParent( hwndPrevActive ) );
1000 if(wndTemp->dwStyle & WS_MINIMIZE)
1001 RedrawIconTitle(hwndPrevActive);
1005 /* managed windows will get ConfigureNotify event */
1006 if (wndPtr
&& !(wndPtr
->dwStyle
& WS_CHILD
) && !(wndPtr
->flags
& WIN_MANAGED
))
1008 /* check Z-order and bring hWnd to the top */
1009 for (wndTemp
= WIN_GetDesktop()->child
; wndTemp
; wndTemp
= wndTemp
->next
)
1010 if (wndTemp
->dwStyle
& WS_VISIBLE
) break;
1012 if( wndTemp
!= wndPtr
)
1013 SetWindowPos(hWnd
, HWND_TOP
, 0,0,0,0,
1014 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1015 if( !IsWindow(hWnd
) ) return 0;
1018 hNewActiveQueue
= wndPtr
? wndPtr
->hmemTaskQ
: 0;
1020 /* send WM_ACTIVATEAPP if necessary */
1021 if (hOldActiveQueue
!= hNewActiveQueue
)
1023 WND
**list
, **ppWnd
;
1025 if ((list
= WIN_BuildWinArray( WIN_GetDesktop() )))
1027 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1029 if (!IsWindow( (*ppWnd
)->hwndSelf
)) continue;
1031 if ((*ppWnd
)->hmemTaskQ
== hOldActiveQueue
)
1032 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1033 0, QUEUE_GetQueueTask(hNewActiveQueue
) );
1035 HeapFree( SystemHeap
, 0, list
);
1038 pActiveQueue
= (hNewActiveQueue
)
1039 ? (MESSAGEQUEUE
*) GlobalLock16(hNewActiveQueue
) : NULL
;
1041 if ((list
= WIN_BuildWinArray( WIN_GetDesktop() )))
1043 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1045 if (!IsWindow( (*ppWnd
)->hwndSelf
)) continue;
1047 if ((*ppWnd
)->hmemTaskQ
== hNewActiveQueue
)
1048 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1049 1, QUEUE_GetQueueTask( hOldActiveQueue
) );
1051 HeapFree( SystemHeap
, 0, list
);
1053 if (!IsWindow(hWnd
)) return 0;
1058 /* walk up to the first unowned window */
1060 while (wndTemp
->owner
) wndTemp
= wndTemp
->owner
;
1061 /* and set last active owned popup */
1062 wndTemp
->hwndLastActive
= hWnd
;
1064 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1065 SendMessage16( hWnd
, WM_NCACTIVATE
, TRUE
, 0 );
1066 SendMessage32A( hWnd
, WM_ACTIVATE
,
1067 MAKEWPARAM( (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
, wIconized
),
1068 (LPARAM
)hwndPrevActive
);
1070 if( !IsWindow(hWnd
) ) return 0;
1073 /* change focus if possible */
1074 if( fChangeFocus
&& GetFocus32() )
1075 if( WIN_GetTopParent(GetFocus32()) != hwndActive
)
1076 FOCUS_SwitchFocus( GetFocus32(),
1077 (wndPtr
->dwStyle
& WS_MINIMIZE
)? 0: hwndActive
);
1079 if( !hwndPrevActive
&& wndPtr
&&
1080 wndPtr
->window
&& !(wndPtr
->flags
& WIN_MANAGED
) )
1081 WINPOS_ForceXWindowRaise(wndPtr
);
1083 /* if active wnd is minimized redraw icon title
1086 wndPtr = WIN_FindWndPtr(hwndActive);
1087 if(wndPtr->dwStyle & WS_MINIMIZE)
1088 RedrawIconTitle(hwndActive);
1091 return (hWnd
== hwndActive
);
1094 /*******************************************************************
1095 * WINPOS_ActivateOtherWindow
1097 * DestroyWindow() helper. pWnd must be a top-level window.
1099 BOOL32
WINPOS_ActivateOtherWindow(WND
* pWnd
)
1104 if( pWnd
->hwndSelf
== hwndPrevActive
)
1107 if( hwndActive
!= pWnd
->hwndSelf
&&
1108 ( hwndActive
|| QUEUE_IsDoomedQueue(pWnd
->hmemTaskQ
)) )
1111 if( pWnd
->dwStyle
& WS_POPUP
&&
1112 WINPOS_IsGoodEnough( pWnd
->owner
) ) pWndTo
= pWnd
->owner
;
1115 WND
* pWndPtr
= pWnd
;
1117 pWndTo
= WIN_FindWndPtr(hwndPrevActive
);
1119 while( !WINPOS_IsGoodEnough(pWndTo
) )
1121 /* by now owned windows should've been taken care of */
1123 pWndTo
= pWndPtr
->next
;
1125 if( !pWndTo
) return 0;
1129 bRet
= WINPOS_SetActiveWindow( pWndTo
->hwndSelf
, FALSE
, TRUE
);
1131 /* switch desktop queue to current active */
1132 if( pWndTo
->parent
== WIN_GetDesktop())
1133 WIN_GetDesktop()->hmemTaskQ
= pWndTo
->hmemTaskQ
;
1139 /*******************************************************************
1140 * WINPOS_ChangeActiveWindow
1143 BOOL32
WINPOS_ChangeActiveWindow( HWND32 hWnd
, BOOL32 mouseMsg
)
1145 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
1147 if (!hWnd
) return WINPOS_SetActiveWindow( 0, mouseMsg
, TRUE
);
1149 if( !wndPtr
) return FALSE
;
1151 /* child windows get WM_CHILDACTIVATE message */
1152 if( (wndPtr
->dwStyle
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
1153 return SendMessage16(hWnd
, WM_CHILDACTIVATE
, 0, 0L);
1155 /* owned popups imply owner activation - not sure */
1156 if ((wndPtr
->dwStyle
& WS_POPUP
) && wndPtr
->owner
&&
1157 !(wndPtr
->owner
->dwStyle
& WS_DISABLED
))
1159 if (!(wndPtr
= wndPtr
->owner
)) return FALSE
;
1160 hWnd
= wndPtr
->hwndSelf
;
1163 if( hWnd
== hwndActive
) return FALSE
;
1165 if( !WINPOS_SetActiveWindow(hWnd
,mouseMsg
,TRUE
) )
1168 /* switch desktop queue to current active */
1169 if( wndPtr
->parent
== WIN_GetDesktop())
1170 WIN_GetDesktop()->hmemTaskQ
= wndPtr
->hmemTaskQ
;
1176 /***********************************************************************
1177 * WINPOS_SendNCCalcSize
1179 * Send a WM_NCCALCSIZE message to a window.
1180 * All parameters are read-only except newClientRect.
1181 * oldWindowRect, oldClientRect and winpos must be non-NULL only
1182 * when calcValidRect is TRUE.
1184 LONG
WINPOS_SendNCCalcSize( HWND32 hwnd
, BOOL32 calcValidRect
,
1185 RECT16
*newWindowRect
, RECT16
*oldWindowRect
,
1186 RECT16
*oldClientRect
, SEGPTR winpos
,
1187 RECT16
*newClientRect
)
1189 NCCALCSIZE_PARAMS16
*params
;
1192 if (!(params
= SEGPTR_NEW(NCCALCSIZE_PARAMS16
))) return 0;
1193 params
->rgrc
[0] = *newWindowRect
;
1196 params
->rgrc
[1] = *oldWindowRect
;
1197 params
->rgrc
[2] = *oldClientRect
;
1198 params
->lppos
= winpos
;
1200 result
= SendMessage16( hwnd
, WM_NCCALCSIZE
, calcValidRect
,
1201 (LPARAM
)SEGPTR_GET( params
) );
1202 dprintf_win( stddeb
, "WINPOS_SendNCCalcSize: %d,%d-%d,%d\n",
1203 params
->rgrc
[0].left
, params
->rgrc
[0].top
,
1204 params
->rgrc
[0].right
, params
->rgrc
[0].bottom
);
1205 *newClientRect
= params
->rgrc
[0];
1206 SEGPTR_FREE(params
);
1211 /***********************************************************************
1212 * WINPOS_HandleWindowPosChanging16
1214 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1216 LONG
WINPOS_HandleWindowPosChanging16( WND
*wndPtr
, WINDOWPOS16
*winpos
)
1219 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1220 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1221 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1223 NC_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, NULL
, NULL
);
1224 winpos
->cx
= MIN( winpos
->cx
, maxSize
.x
);
1225 winpos
->cy
= MIN( winpos
->cy
, maxSize
.y
);
1231 /***********************************************************************
1232 * WINPOS_HandleWindowPosChanging32
1234 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1236 LONG
WINPOS_HandleWindowPosChanging32( WND
*wndPtr
, WINDOWPOS32
*winpos
)
1239 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1240 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1241 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1243 NC_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, NULL
, NULL
);
1244 winpos
->cx
= MIN( winpos
->cx
, maxSize
.x
);
1245 winpos
->cy
= MIN( winpos
->cy
, maxSize
.y
);
1251 /***********************************************************************
1252 * WINPOS_MoveWindowZOrder
1254 * Move a window in Z order, invalidating everything that needs it.
1255 * Only necessary for windows without associated X window.
1257 static void WINPOS_MoveWindowZOrder( HWND hwnd
, HWND hwndAfter
)
1260 WND
*pWndAfter
, *pWndCur
, *wndPtr
= WIN_FindWndPtr( hwnd
);
1262 /* We have two possible cases:
1263 * - The window is moving up: we have to invalidate all areas
1264 * of the window that were covered by other windows
1265 * - The window is moving down: we have to invalidate areas
1266 * of other windows covered by this one.
1269 if (hwndAfter
== HWND_TOP
)
1273 else if (hwndAfter
== HWND_BOTTOM
)
1275 if (!wndPtr
->next
) return; /* Already at the bottom */
1280 if (!(pWndAfter
= WIN_FindWndPtr( hwndAfter
))) return;
1281 if (wndPtr
->next
== pWndAfter
) return; /* Already placed right */
1283 /* Determine which window we encounter first in Z-order */
1284 pWndCur
= wndPtr
->parent
->child
;
1285 while ((pWndCur
!= wndPtr
) && (pWndCur
!= pWndAfter
))
1286 pWndCur
= pWndCur
->next
;
1287 movingUp
= (pWndCur
== pWndAfter
);
1292 WND
*pWndPrevAfter
= wndPtr
->next
;
1293 WIN_UnlinkWindow( hwnd
);
1294 WIN_LinkWindow( hwnd
, hwndAfter
);
1295 pWndCur
= wndPtr
->next
;
1296 while (pWndCur
!= pWndPrevAfter
)
1298 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1299 pWndCur
->rectWindow
.top
,
1300 pWndCur
->rectWindow
.right
,
1301 pWndCur
->rectWindow
.bottom
};
1302 OffsetRect32( &rect
, -wndPtr
->rectClient
.left
,
1303 -wndPtr
->rectClient
.top
);
1304 PAINT_RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
1305 RDW_FRAME
| RDW_ERASE
, 0 );
1306 pWndCur
= pWndCur
->next
;
1309 else /* Moving down */
1311 pWndCur
= wndPtr
->next
;
1312 WIN_UnlinkWindow( hwnd
);
1313 WIN_LinkWindow( hwnd
, hwndAfter
);
1314 while (pWndCur
!= wndPtr
)
1316 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1317 pWndCur
->rectWindow
.top
,
1318 pWndCur
->rectWindow
.right
,
1319 pWndCur
->rectWindow
.bottom
};
1320 OffsetRect32( &rect
, -pWndCur
->rectClient
.left
,
1321 -pWndCur
->rectClient
.top
);
1322 PAINT_RedrawWindow( pWndCur
->hwndSelf
, &rect
, 0, RDW_INVALIDATE
|
1323 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
1324 pWndCur
= pWndCur
->next
;
1329 /***********************************************************************
1330 * WINPOS_ReorderOwnedPopups
1332 * fix Z order taking into account owned popups -
1333 * basically we need to maintain them above owner window
1335 HWND
WINPOS_ReorderOwnedPopups(HWND hwndInsertAfter
, WND
* wndPtr
, WORD flags
)
1337 WND
* w
= WIN_GetDesktop()->child
;
1339 if( wndPtr
->dwStyle
& WS_POPUP
&& wndPtr
->owner
)
1341 /* implement "local z-order" between the top and owner window */
1343 HWND hwndLocalPrev
= HWND_TOP
;
1345 if( hwndInsertAfter
!= HWND_TOP
)
1347 while( w
!= wndPtr
->owner
)
1349 hwndLocalPrev
= w
->hwndSelf
;
1350 if( hwndLocalPrev
== hwndInsertAfter
) break;
1353 hwndInsertAfter
= hwndLocalPrev
;
1357 else if( wndPtr
->dwStyle
& WS_CHILD
) return hwndInsertAfter
;
1359 w
= WIN_GetDesktop()->child
;
1362 if( w
== wndPtr
) break;
1364 if( w
->dwStyle
& WS_POPUP
&& w
->owner
== wndPtr
)
1366 SetWindowPos(w
->hwndSelf
, hwndInsertAfter
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
|
1367 SWP_NOACTIVATE
| SWP_NOSENDCHANGING
| SWP_DEFERERASE
);
1368 hwndInsertAfter
= w
->hwndSelf
;
1373 return hwndInsertAfter
;
1376 /***********************************************************************
1377 * WINPOS_SizeMoveClean
1379 * Make window look nice without excessive repainting
1383 * visible regions are in window coordinates
1384 * update regions are in window client coordinates
1385 * client and window rectangles are in parent client coordinates
1387 static UINT
WINPOS_SizeMoveClean(WND
* Wnd
, HRGN32 oldVisRgn
, LPRECT16 lpOldWndRect
, LPRECT16 lpOldClientRect
, UINT uFlags
)
1389 HRGN32 newVisRgn
= DCE_GetVisRgn(Wnd
->hwndSelf
,DCX_WINDOW
| DCX_CLIPSIBLINGS
);
1390 HRGN32 dirtyRgn
= CreateRectRgn32(0,0,0,0);
1393 dprintf_win(stddeb
,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n\
1394 \t\tnew client=(%i %i-%i %i) old client=(%i %i-%i %i)\n",
1395 Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
, Wnd
->rectWindow
.right
, Wnd
->rectWindow
.bottom
,
1396 lpOldWndRect
->left
, lpOldWndRect
->top
, lpOldWndRect
->right
, lpOldWndRect
->bottom
,
1397 Wnd
->rectClient
.left
,Wnd
->rectClient
.top
,Wnd
->rectClient
.right
,Wnd
->rectClient
.bottom
,
1398 lpOldClientRect
->left
,lpOldClientRect
->top
,lpOldClientRect
->right
,lpOldClientRect
->bottom
);
1400 if( (lpOldWndRect
->right
- lpOldWndRect
->left
) != (Wnd
->rectWindow
.right
- Wnd
->rectWindow
.left
) ||
1401 (lpOldWndRect
->bottom
- lpOldWndRect
->top
) != (Wnd
->rectWindow
.bottom
- Wnd
->rectWindow
.top
) )
1402 uFlags
|= SMC_DRAWFRAME
;
1404 CombineRgn32( dirtyRgn
, newVisRgn
, 0, RGN_COPY
);
1406 if( !(uFlags
& SMC_NOCOPY
) )
1407 CombineRgn32( newVisRgn
, newVisRgn
, oldVisRgn
, RGN_AND
);
1409 /* map regions to the parent client area */
1411 OffsetRgn32( dirtyRgn
, Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
);
1412 OffsetRgn32( oldVisRgn
, lpOldWndRect
->left
, lpOldWndRect
->top
);
1414 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1416 other
= CombineRgn32(dirtyRgn
, oldVisRgn
, dirtyRgn
, RGN_DIFF
);
1418 /* map visible region to the Wnd client area */
1420 OffsetRgn32( newVisRgn
, Wnd
->rectWindow
.left
- Wnd
->rectClient
.left
,
1421 Wnd
->rectWindow
.top
- Wnd
->rectClient
.top
);
1423 /* substract previously invalidated region from the Wnd visible region */
1425 my
= (Wnd
->hrgnUpdate
> 1) ? CombineRgn32( newVisRgn
, newVisRgn
,
1426 Wnd
->hrgnUpdate
, RGN_DIFF
)
1429 if( uFlags
& SMC_NOCOPY
) /* invalidate Wnd visible region */
1431 if (my
!= NULLREGION
)
1432 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, newVisRgn
, RDW_INVALIDATE
|
1433 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1434 else if(uFlags
& SMC_DRAWFRAME
)
1435 Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1437 else /* bitblt old client area */
1442 int xfrom
,yfrom
,xto
,yto
,width
,height
;
1444 if( uFlags
& SMC_DRAWFRAME
)
1446 /* copy only client area, frame will be redrawn anyway */
1448 xfrom
= lpOldClientRect
->left
; yfrom
= lpOldClientRect
->top
;
1449 xto
= Wnd
->rectClient
.left
; yto
= Wnd
->rectClient
.top
;
1450 width
= lpOldClientRect
->right
- xfrom
; height
= lpOldClientRect
->bottom
- yfrom
;
1451 updateRgn
= CreateRectRgn32( 0, 0, width
, height
);
1452 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1453 SetRectRgn( updateRgn
, 0, 0, Wnd
->rectClient
.right
- xto
, Wnd
->rectClient
.bottom
- yto
);
1457 xfrom
= lpOldWndRect
->left
; yfrom
= lpOldWndRect
->top
;
1458 xto
= Wnd
->rectWindow
.left
; yto
= Wnd
->rectWindow
.top
;
1459 width
= lpOldWndRect
->right
- xfrom
; height
= lpOldWndRect
->bottom
- yfrom
;
1460 updateRgn
= CreateRectRgn32( xto
- Wnd
->rectClient
.left
,
1461 yto
- Wnd
->rectClient
.top
,
1462 Wnd
->rectWindow
.right
- Wnd
->rectClient
.left
,
1463 Wnd
->rectWindow
.bottom
- Wnd
->rectClient
.top
);
1466 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1468 /* substract new visRgn from target rect to get a region that won't be copied */
1470 update
= CombineRgn32( updateRgn
, updateRgn
, newVisRgn
, RGN_DIFF
);
1472 /* Blt valid bits using parent window DC */
1474 if( my
!= NULLREGION
&& (xfrom
!= xto
|| yfrom
!= yto
) )
1477 /* compute clipping region in parent client coordinates */
1479 OffsetRgn32( newVisRgn
, Wnd
->rectClient
.left
, Wnd
->rectClient
.top
);
1480 CombineRgn32( oldVisRgn
, oldVisRgn
, newVisRgn
, RGN_OR
);
1482 hDC
= GetDCEx32( Wnd
->parent
->hwndSelf
, oldVisRgn
,
1483 DCX_KEEPCLIPRGN
| DCX_INTERSECTRGN
|
1484 DCX_CACHE
| DCX_CLIPSIBLINGS
);
1486 BitBlt32( hDC
, xto
, yto
, width
, height
, hDC
, xfrom
, yfrom
, SRCCOPY
);
1487 ReleaseDC32( Wnd
->parent
->hwndSelf
, hDC
);
1490 if( update
!= NULLREGION
)
1491 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, updateRgn
, RDW_INVALIDATE
|
1492 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1493 else if( uFlags
& SMC_DRAWFRAME
) Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1494 DeleteObject32( updateRgn
);
1497 /* erase uncovered areas */
1499 if( !(uFlags
& SMC_NOPARENTERASE
) && (other
!= NULLREGION
) )
1500 PAINT_RedrawWindow( Wnd
->parent
->hwndSelf
, NULL
, dirtyRgn
,
1501 RDW_INVALIDATE
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1502 DeleteObject32(dirtyRgn
);
1503 DeleteObject32(newVisRgn
);
1508 /***********************************************************************
1509 * WINPOS_SetXWindowPos
1511 * SetWindowPos() for an X window. Used by the real SetWindowPos().
1513 static void WINPOS_SetXWindowPos( WINDOWPOS16
*winpos
)
1515 XWindowChanges winChanges
;
1517 WND
*wndPtr
= WIN_FindWndPtr( winpos
->hwnd
);
1519 if (!(winpos
->flags
& SWP_NOSIZE
))
1521 winChanges
.width
= winpos
->cx
;
1522 winChanges
.height
= winpos
->cy
;
1523 changeMask
|= CWWidth
| CWHeight
;
1525 /* Tweak dialog window size hints */
1527 if ((wndPtr
->flags
& WIN_MANAGED
) &&
1528 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
1530 XSizeHints
*size_hints
= XAllocSizeHints();
1534 long supplied_return
;
1536 XGetWMSizeHints( display
, wndPtr
->window
, size_hints
,
1537 &supplied_return
, XA_WM_NORMAL_HINTS
);
1538 size_hints
->min_width
= size_hints
->max_width
= winpos
->cx
;
1539 size_hints
->min_height
= size_hints
->max_height
= winpos
->cy
;
1540 XSetWMSizeHints( display
, wndPtr
->window
, size_hints
,
1541 XA_WM_NORMAL_HINTS
);
1546 if (!(winpos
->flags
& SWP_NOMOVE
))
1548 winChanges
.x
= winpos
->x
;
1549 winChanges
.y
= winpos
->y
;
1550 changeMask
|= CWX
| CWY
;
1552 if (!(winpos
->flags
& SWP_NOZORDER
))
1554 winChanges
.stack_mode
= Below
;
1555 changeMask
|= CWStackMode
;
1557 if (winpos
->hwndInsertAfter
== HWND_TOP
) winChanges
.stack_mode
= Above
;
1558 else if (winpos
->hwndInsertAfter
!= HWND_BOTTOM
)
1560 WND
* insertPtr
= WIN_FindWndPtr( winpos
->hwndInsertAfter
);
1563 stack
[0] = insertPtr
->window
;
1564 stack
[1] = wndPtr
->window
;
1566 /* for stupid window managers (i.e. all of them) */
1568 XRestackWindows(display
, stack
, 2);
1569 changeMask
&= ~CWStackMode
;
1572 if (!changeMask
) return;
1574 XReconfigureWMWindow( display
, wndPtr
->window
, 0, changeMask
, &winChanges
);
1578 /***********************************************************************
1579 * SetWindowPos (USER.232)
1581 BOOL
SetWindowPos( HWND hwnd
, HWND hwndInsertAfter
, INT x
, INT y
,
1582 INT cx
, INT cy
, WORD flags
)
1584 WINDOWPOS16
*winpos
;
1586 RECT16 newWindowRect
, newClientRect
, oldWindowRect
;
1588 HWND tempInsertAfter
= 0;
1592 dprintf_win(stddeb
,"SetWindowPos: hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
1593 hwnd
, x
, y
, x
+cx
, y
+cy
, flags
);
1594 /* Check window handle */
1596 if (hwnd
== GetDesktopWindow32()) return FALSE
;
1597 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return FALSE
;
1599 if (wndPtr
->dwStyle
& WS_VISIBLE
) flags
&= ~SWP_SHOWWINDOW
;
1602 uFlags
|= SMC_NOPARENTERASE
;
1603 flags
&= ~SWP_HIDEWINDOW
;
1604 if (!(flags
& SWP_SHOWWINDOW
)) flags
|= SWP_NOREDRAW
;
1607 /* Check for windows that may not be resized
1608 FIXME: this should be done only for Windows 3.0 programs
1609 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
1610 flags |= SWP_NOSIZE | SWP_NOMOVE;
1612 /* Check dimensions */
1614 if (cx
<= 0) cx
= 1;
1615 if (cy
<= 0) cy
= 1;
1619 if (hwnd
== hwndActive
) flags
|= SWP_NOACTIVATE
; /* Already active */
1620 if ((wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
== cx
) &&
1621 (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
== cy
))
1622 flags
|= SWP_NOSIZE
; /* Already the right size */
1623 if ((wndPtr
->rectWindow
.left
== x
) && (wndPtr
->rectWindow
.top
== y
))
1624 flags
|= SWP_NOMOVE
; /* Already the right position */
1626 /* Check hwndInsertAfter */
1628 if (!(flags
& (SWP_NOZORDER
| SWP_NOACTIVATE
)))
1630 /* Ignore TOPMOST flags when activating a window */
1631 /* _and_ moving it in Z order. */
1632 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
1633 (hwndInsertAfter
== HWND_NOTOPMOST
))
1634 hwndInsertAfter
= HWND_TOP
;
1636 /* TOPMOST not supported yet */
1637 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
1638 (hwndInsertAfter
== HWND_NOTOPMOST
)) hwndInsertAfter
= HWND_TOP
;
1640 /* hwndInsertAfter must be a sibling of the window */
1641 if ((hwndInsertAfter
!= HWND_TOP
) && (hwndInsertAfter
!= HWND_BOTTOM
))
1643 WND
* wnd
= WIN_FindWndPtr(hwndInsertAfter
);
1644 if( wnd
->parent
!= wndPtr
->parent
) return FALSE
;
1645 if( wnd
->next
== wndPtr
) flags
|= SWP_NOZORDER
;
1648 if (hwndInsertAfter
== HWND_TOP
)
1649 flags
|= ( wndPtr
->parent
->child
== wndPtr
)? SWP_NOZORDER
: 0;
1650 else /* HWND_BOTTOM */
1651 flags
|= ( wndPtr
->next
)? 0: SWP_NOZORDER
;
1653 /* Fill the WINDOWPOS structure */
1655 if (!(winpos
= SEGPTR_NEW(WINDOWPOS16
))) return FALSE
;
1656 winpos
->hwnd
= hwnd
;
1657 winpos
->hwndInsertAfter
= hwndInsertAfter
;
1662 winpos
->flags
= flags
;
1664 /* Send WM_WINDOWPOSCHANGING message */
1666 if (!(flags
& SWP_NOSENDCHANGING
))
1667 SendMessage16( hwnd
, WM_WINDOWPOSCHANGING
, 0,
1668 (LPARAM
)SEGPTR_GET(winpos
) );
1670 /* Calculate new position and size */
1672 newWindowRect
= wndPtr
->rectWindow
;
1673 newClientRect
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? wndPtr
->rectWindow
1674 : wndPtr
->rectClient
;
1676 if (!(winpos
->flags
& SWP_NOSIZE
))
1678 newWindowRect
.right
= newWindowRect
.left
+ winpos
->cx
;
1679 newWindowRect
.bottom
= newWindowRect
.top
+ winpos
->cy
;
1681 if (!(winpos
->flags
& SWP_NOMOVE
))
1683 newWindowRect
.left
= winpos
->x
;
1684 newWindowRect
.top
= winpos
->y
;
1685 newWindowRect
.right
+= winpos
->x
- wndPtr
->rectWindow
.left
;
1686 newWindowRect
.bottom
+= winpos
->y
- wndPtr
->rectWindow
.top
;
1688 OffsetRect16( &newClientRect
, winpos
->x
- wndPtr
->rectWindow
.left
,
1689 winpos
->y
- wndPtr
->rectWindow
.top
);
1692 winpos
->flags
|= SWP_NOCLIENTMOVE
| SWP_NOCLIENTSIZE
;
1694 /* Reposition window in Z order */
1696 if (!(winpos
->flags
& SWP_NOZORDER
))
1698 /* reorder owned popups if hwnd is top-level window
1700 if( wndPtr
->parent
== WIN_GetDesktop() )
1701 hwndInsertAfter
= WINPOS_ReorderOwnedPopups( hwndInsertAfter
,
1706 WIN_UnlinkWindow( winpos
->hwnd
);
1707 WIN_LinkWindow( winpos
->hwnd
, hwndInsertAfter
);
1709 else WINPOS_MoveWindowZOrder( winpos
->hwnd
, hwndInsertAfter
);
1712 if ( !wndPtr
->window
&& !(flags
& SWP_NOREDRAW
) &&
1713 (!(flags
& SWP_NOMOVE
) || !(flags
& SWP_NOSIZE
) || (flags
& SWP_FRAMECHANGED
)) )
1714 visRgn
= DCE_GetVisRgn(hwnd
, DCX_WINDOW
| DCX_CLIPSIBLINGS
);
1717 /* Send WM_NCCALCSIZE message to get new client area */
1718 if( (flags
& (SWP_FRAMECHANGED
| SWP_NOSIZE
)) != SWP_NOSIZE
)
1720 result
= WINPOS_SendNCCalcSize( winpos
->hwnd
, TRUE
, &newWindowRect
,
1721 &wndPtr
->rectWindow
, &wndPtr
->rectClient
,
1722 SEGPTR_GET(winpos
), &newClientRect
);
1724 /* FIXME: WVR_ALIGNxxx */
1726 if( newClientRect
.left
!= wndPtr
->rectClient
.left
||
1727 newClientRect
.top
!= wndPtr
->rectClient
.top
)
1728 winpos
->flags
&= ~SWP_NOCLIENTMOVE
;
1730 if( (newClientRect
.right
- newClientRect
.left
!=
1731 wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
) ||
1732 (newClientRect
.bottom
- newClientRect
.top
!=
1733 wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
) )
1734 winpos
->flags
&= ~SWP_NOCLIENTSIZE
;
1737 if( !(flags
& SWP_NOMOVE
) && (newClientRect
.left
!= wndPtr
->rectClient
.left
||
1738 newClientRect
.top
!= wndPtr
->rectClient
.top
) )
1739 winpos
->flags
&= ~SWP_NOCLIENTMOVE
;
1741 /* Update active DCEs */
1743 if( !(flags
& SWP_NOZORDER
) || (flags
& SWP_HIDEWINDOW
) || (flags
& SWP_SHOWWINDOW
)
1744 || (memcmp(&newWindowRect
,&wndPtr
->rectWindow
,sizeof(RECT16
))
1745 && wndPtr
->dwStyle
& WS_VISIBLE
) )
1749 UnionRect16(&rect
,&newWindowRect
,&wndPtr
->rectWindow
);
1750 DCE_InvalidateDCE(wndPtr
->parent
, &rect
);
1753 /* change geometry */
1755 oldWindowRect
= wndPtr
->rectWindow
;
1759 RECT16 oldClientRect
= wndPtr
->rectClient
;
1761 tempInsertAfter
= winpos
->hwndInsertAfter
;
1763 winpos
->hwndInsertAfter
= hwndInsertAfter
;
1765 /* postpone geometry change */
1767 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
1769 WINPOS_SetXWindowPos( winpos
);
1770 winpos
->hwndInsertAfter
= tempInsertAfter
;
1772 else uFlags
|= SMC_SETXPOS
;
1774 wndPtr
->rectWindow
= newWindowRect
;
1775 wndPtr
->rectClient
= newClientRect
;
1777 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
1778 if( (oldClientRect
.left
- oldWindowRect
.left
!=
1779 newClientRect
.left
- newWindowRect
.left
) ||
1780 (oldClientRect
.top
- oldWindowRect
.top
!=
1781 newClientRect
.top
- newWindowRect
.top
) || winpos
->flags
& SWP_NOCOPYBITS
)
1783 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, RDW_INVALIDATE
|
1784 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
1786 if( winpos
->flags
& SWP_FRAMECHANGED
)
1791 if( oldClientRect
.right
> newClientRect
.right
)
1793 rect
.left
= newClientRect
.right
; rect
.top
= newClientRect
.top
;
1794 rect
.right
= oldClientRect
.right
; rect
.bottom
= newClientRect
.bottom
;
1796 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
1797 RDW_INVALIDATE
| RDW_FRAME
| RDW_ALLCHILDREN
, 0 );
1799 if( oldClientRect
.bottom
> newClientRect
.bottom
)
1801 rect
.left
= newClientRect
.left
; rect
.top
= newClientRect
.bottom
;
1802 rect
.right
= (wErase
)?oldClientRect
.right
:newClientRect
.right
;
1803 rect
.bottom
= oldClientRect
.bottom
;
1805 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
1806 RDW_INVALIDATE
| RDW_FRAME
| RDW_ALLCHILDREN
, 0 );
1808 if( !wErase
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
1813 RECT16 oldClientRect
= wndPtr
->rectClient
;
1815 wndPtr
->rectWindow
= newWindowRect
;
1816 wndPtr
->rectClient
= newClientRect
;
1818 if( oldClientRect
.bottom
- oldClientRect
.top
==
1819 newClientRect
.bottom
- newClientRect
.top
) result
&= ~WVR_VREDRAW
;
1821 if( oldClientRect
.right
- oldClientRect
.left
==
1822 newClientRect
.right
- newClientRect
.left
) result
&= ~WVR_HREDRAW
;
1824 if( !(flags
& (SWP_NOREDRAW
| SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
1826 uFlags
|= ((winpos
->flags
& SWP_NOCOPYBITS
) ||
1827 (result
>= WVR_HREDRAW
&& result
< WVR_VALIDRECTS
)) ? SMC_NOCOPY
: 0;
1828 uFlags
|= (winpos
->flags
& SWP_FRAMECHANGED
) ? SMC_DRAWFRAME
: 0;
1830 if( (winpos
->flags
& SWP_AGG_NOGEOMETRYCHANGE
) != SWP_AGG_NOGEOMETRYCHANGE
)
1831 uFlags
= WINPOS_SizeMoveClean(wndPtr
, visRgn
, &oldWindowRect
,
1832 &oldClientRect
, uFlags
);
1835 /* adjust frame and do not erase parent */
1837 if( winpos
->flags
& SWP_FRAMECHANGED
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
1838 if( winpos
->flags
& SWP_NOZORDER
) uFlags
|= SMC_NOPARENTERASE
;
1841 DeleteObject32(visRgn
);
1844 if (flags
& SWP_SHOWWINDOW
)
1846 wndPtr
->dwStyle
|= WS_VISIBLE
;
1849 if( uFlags
& SMC_SETXPOS
)
1851 WINPOS_SetXWindowPos( winpos
);
1852 winpos
->hwndInsertAfter
= tempInsertAfter
;
1854 XMapWindow( display
, wndPtr
->window
);
1858 if (!(flags
& SWP_NOREDRAW
))
1859 PAINT_RedrawWindow( winpos
->hwnd
, NULL
, 0,
1860 RDW_INVALIDATE
| RDW_ALLCHILDREN
|
1861 RDW_FRAME
| RDW_ERASENOW
| RDW_ERASE
, 0 );
1864 else if (flags
& SWP_HIDEWINDOW
)
1866 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
1869 XUnmapWindow( display
, wndPtr
->window
);
1870 if( uFlags
& SMC_SETXPOS
)
1872 WINPOS_SetXWindowPos( winpos
);
1873 winpos
->hwndInsertAfter
= tempInsertAfter
;
1878 if (!(flags
& SWP_NOREDRAW
))
1880 RECT32 rect
= { oldWindowRect
.left
, oldWindowRect
.top
,
1881 oldWindowRect
.right
, oldWindowRect
.bottom
};
1882 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, &rect
, 0,
1883 RDW_INVALIDATE
| RDW_ALLCHILDREN
| RDW_ERASE
| RDW_ERASENOW
, 0);
1885 uFlags
|= SMC_NOPARENTERASE
;
1888 if ((winpos
->hwnd
== GetFocus32()) ||
1889 IsChild( winpos
->hwnd
, GetFocus32()))
1891 /* Revert focus to parent */
1892 SetFocus32( GetParent32(winpos
->hwnd
) );
1894 if (hwnd
== CARET_GetHwnd()) DestroyCaret();
1896 if (winpos
->hwnd
== hwndActive
)
1898 /* Activate previously active window if possible */
1899 HWND newActive
= hwndPrevActive
;
1900 if (!IsWindow(newActive
) || (newActive
== winpos
->hwnd
))
1902 newActive
= GetTopWindow( GetDesktopWindow32() );
1903 if (newActive
== winpos
->hwnd
)
1904 newActive
= wndPtr
->next
? wndPtr
->next
->hwndSelf
: 0;
1906 WINPOS_ChangeActiveWindow( newActive
, FALSE
);
1910 /* Activate the window */
1912 if (!(flags
& SWP_NOACTIVATE
))
1913 WINPOS_ChangeActiveWindow( winpos
->hwnd
, FALSE
);
1915 /* Repaint the window */
1917 if (wndPtr
->window
) EVENT_Synchronize(); /* Wait for all expose events */
1919 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
1921 if (!(flags
& SWP_DEFERERASE
) && !(uFlags
& SMC_NOPARENTERASE
) )
1924 CONV_RECT16TO32( &oldWindowRect
, &rect
);
1925 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, (wndPtr
->flags
& WIN_SAVEUNDER_OVERRIDE
)
1926 ? &rect
: NULL
, 0, RDW_ALLCHILDREN
| RDW_ERASENOW
|
1927 ((wndPtr
->flags
& WIN_SAVEUNDER_OVERRIDE
) ? RDW_INVALIDATE
: 0), 0 );
1928 wndPtr
->flags
&= ~WIN_SAVEUNDER_OVERRIDE
;
1930 else if( wndPtr
->parent
== WIN_GetDesktop() && wndPtr
->parent
->flags
& WIN_NEEDS_ERASEBKGND
)
1931 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_NOCHILDREN
| RDW_ERASENOW
, 0 );
1933 /* And last, send the WM_WINDOWPOSCHANGED message */
1935 dprintf_win(stddeb
,"\tstatus flags = %04x\n", winpos
->flags
& SWP_AGG_STATUSFLAGS
);
1937 if ( ((winpos
->flags
& SWP_AGG_STATUSFLAGS
) != SWP_AGG_NOPOSCHANGE
) &&
1938 !(winpos
->flags
& SWP_NOSENDCHANGING
))
1939 SendMessage16( winpos
->hwnd
, WM_WINDOWPOSCHANGED
,
1940 0, (LPARAM
)SEGPTR_GET(winpos
) );
1942 SEGPTR_FREE(winpos
);
1947 /***********************************************************************
1948 * BeginDeferWindowPos (USER.259)
1950 HDWP16
BeginDeferWindowPos( INT count
)
1955 if (count
<= 0) return 0;
1956 handle
= USER_HEAP_ALLOC( sizeof(DWP
) + (count
-1)*sizeof(WINDOWPOS16
) );
1957 if (!handle
) return 0;
1958 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( handle
);
1959 pDWP
->actualCount
= 0;
1960 pDWP
->suggestedCount
= count
;
1962 pDWP
->wMagic
= DWP_MAGIC
;
1963 pDWP
->hwndParent
= 0;
1968 /***********************************************************************
1969 * DeferWindowPos (USER.260)
1971 HDWP16
DeferWindowPos( HDWP16 hdwp
, HWND hwnd
, HWND hwndAfter
, INT x
, INT y
,
1972 INT cx
, INT cy
, UINT flags
)
1976 HDWP16 newhdwp
= hdwp
;
1979 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
1980 if (!pDWP
) return 0;
1981 if (hwnd
== GetDesktopWindow32()) return 0;
1983 /* All the windows of a DeferWindowPos() must have the same parent */
1985 parent
= WIN_FindWndPtr( hwnd
)->parent
->hwndSelf
;
1986 if (pDWP
->actualCount
== 0) pDWP
->hwndParent
= parent
;
1987 else if (parent
!= pDWP
->hwndParent
)
1989 USER_HEAP_FREE( hdwp
);
1993 for (i
= 0; i
< pDWP
->actualCount
; i
++)
1995 if (pDWP
->winPos
[i
].hwnd
== hwnd
)
1997 /* Merge with the other changes */
1998 if (!(flags
& SWP_NOZORDER
))
2000 pDWP
->winPos
[i
].hwndInsertAfter
= hwndAfter
;
2002 if (!(flags
& SWP_NOMOVE
))
2004 pDWP
->winPos
[i
].x
= x
;
2005 pDWP
->winPos
[i
].y
= y
;
2007 if (!(flags
& SWP_NOSIZE
))
2009 pDWP
->winPos
[i
].cx
= cx
;
2010 pDWP
->winPos
[i
].cy
= cy
;
2012 pDWP
->winPos
[i
].flags
&= flags
& (SWP_NOSIZE
| SWP_NOMOVE
|
2013 SWP_NOZORDER
| SWP_NOREDRAW
|
2014 SWP_NOACTIVATE
| SWP_NOCOPYBITS
|
2016 pDWP
->winPos
[i
].flags
|= flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
|
2021 if (pDWP
->actualCount
>= pDWP
->suggestedCount
)
2023 newhdwp
= USER_HEAP_REALLOC( hdwp
,
2024 sizeof(DWP
) + pDWP
->suggestedCount
*sizeof(WINDOWPOS16
) );
2025 if (!newhdwp
) return 0;
2026 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( newhdwp
);
2027 pDWP
->suggestedCount
++;
2029 pDWP
->winPos
[pDWP
->actualCount
].hwnd
= hwnd
;
2030 pDWP
->winPos
[pDWP
->actualCount
].hwndInsertAfter
= hwndAfter
;
2031 pDWP
->winPos
[pDWP
->actualCount
].x
= x
;
2032 pDWP
->winPos
[pDWP
->actualCount
].y
= y
;
2033 pDWP
->winPos
[pDWP
->actualCount
].cx
= cx
;
2034 pDWP
->winPos
[pDWP
->actualCount
].cy
= cy
;
2035 pDWP
->winPos
[pDWP
->actualCount
].flags
= flags
;
2036 pDWP
->actualCount
++;
2041 /***********************************************************************
2042 * EndDeferWindowPos (USER.261)
2044 BOOL
EndDeferWindowPos( HDWP16 hdwp
)
2047 WINDOWPOS16
*winpos
;
2051 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2052 if (!pDWP
) return FALSE
;
2053 for (i
= 0, winpos
= pDWP
->winPos
; i
< pDWP
->actualCount
; i
++, winpos
++)
2055 if (!(res
= SetWindowPos( winpos
->hwnd
, winpos
->hwndInsertAfter
,
2056 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
,
2057 winpos
->flags
))) break;
2059 USER_HEAP_FREE( hdwp
);
2064 /***********************************************************************
2065 * TileChildWindows (USER.199)
2067 void TileChildWindows( HWND parent
, WORD action
)
2069 printf("STUB TileChildWindows(%04x, %d)\n", parent
, action
);
2072 /***********************************************************************
2073 * CascageChildWindows (USER.198)
2075 void CascadeChildWindows( HWND parent
, WORD action
)
2077 printf("STUB CascadeChildWindows(%04x, %d)\n", parent
, action
);