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( POINT16 pt
, WND
**ppWnd
)
259 INT16 hittest
= HTERROR
;
265 wndPtr
= WIN_GetDesktop()->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 desktop window */
304 *ppWnd
= WIN_GetDesktop();
308 /* Send the WM_NCHITTEST message (only if to the same task) */
309 if ((*ppWnd
)->hmemTaskQ
!= GetTaskQueue(0)) return HTCLIENT
;
310 hittest
= (INT
)SendMessage16( (*ppWnd
)->hwndSelf
, WM_NCHITTEST
, 0,
311 MAKELONG( pt
.x
, pt
.y
) );
312 if (hittest
!= HTTRANSPARENT
) return hittest
; /* Found the window */
314 /* If no children found in last search, make point relative to parent*/
317 x
+= (*ppWnd
)->rectClient
.left
;
318 y
+= (*ppWnd
)->rectClient
.top
;
321 /* Restart the search from the next sibling */
322 wndPtr
= (*ppWnd
)->next
;
323 *ppWnd
= (*ppWnd
)->parent
;
328 /*******************************************************************
329 * WindowFromPoint16 (USER.30)
331 HWND16
WindowFromPoint16( POINT16 pt
)
334 WINPOS_WindowFromPoint( pt
, &pWnd
);
335 return pWnd
->hwndSelf
;
339 /*******************************************************************
340 * WindowFromPoint32 (USER32.581)
342 HWND32
WindowFromPoint32( POINT32 pt
)
346 CONV_POINT32TO16( &pt
, &pt16
);
347 WINPOS_WindowFromPoint( pt16
, &pWnd
);
348 return (HWND32
)pWnd
->hwndSelf
;
352 /*******************************************************************
353 * ChildWindowFromPoint16 (USER.191)
355 HWND16
ChildWindowFromPoint16( HWND16 hwndParent
, POINT16 pt
)
357 /* pt is in the client coordinates */
359 WND
* wnd
= WIN_FindWndPtr(hwndParent
);
364 /* get client rect fast */
365 rect
.top
= rect
.left
= 0;
366 rect
.right
= wnd
->rectClient
.right
- wnd
->rectClient
.left
;
367 rect
.bottom
= wnd
->rectClient
.bottom
- wnd
->rectClient
.top
;
369 if (!PtInRect16( &rect
, pt
)) return 0;
374 if (PtInRect16( &wnd
->rectWindow
, pt
)) return wnd
->hwndSelf
;
381 /*******************************************************************
382 * ChildWindowFromPoint32 (USER32.)
384 HWND32
ChildWindowFromPoint32( HWND32 hwndParent
, POINT32 pt
)
387 CONV_POINT32TO16( &pt
, &pt16
);
388 return (HWND32
)ChildWindowFromPoint16( hwndParent
, pt16
);
392 /*******************************************************************
393 * WINPOS_GetWinOffset
395 * Calculate the offset between the origin of the two windows. Used
396 * to implement MapWindowPoints.
398 static void WINPOS_GetWinOffset( HWND32 hwndFrom
, HWND32 hwndTo
,
403 offset
->x
= offset
->y
= 0;
404 if (hwndFrom
== hwndTo
) return;
406 /* Translate source window origin to screen coords */
409 if (!(wndPtr
= WIN_FindWndPtr( hwndFrom
)))
411 fprintf(stderr
,"MapWindowPoints: bad hwndFrom = %04x\n",hwndFrom
);
414 while (wndPtr
->parent
)
416 offset
->x
+= wndPtr
->rectClient
.left
;
417 offset
->y
+= wndPtr
->rectClient
.top
;
418 wndPtr
= wndPtr
->parent
;
422 /* Translate origin to destination window coords */
425 if (!(wndPtr
= WIN_FindWndPtr( hwndTo
)))
427 fprintf(stderr
,"MapWindowPoints: bad hwndTo = %04x\n", hwndTo
);
430 while (wndPtr
->parent
)
432 offset
->x
-= wndPtr
->rectClient
.left
;
433 offset
->y
-= wndPtr
->rectClient
.top
;
434 wndPtr
= wndPtr
->parent
;
440 /*******************************************************************
441 * MapWindowPoints16 (USER.258)
443 void MapWindowPoints16( HWND16 hwndFrom
, HWND16 hwndTo
,
444 LPPOINT16 lppt
, UINT16 count
)
448 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
458 /*******************************************************************
459 * MapWindowPoints32 (USER32.385)
461 void MapWindowPoints32( HWND32 hwndFrom
, HWND32 hwndTo
,
462 LPPOINT32 lppt
, UINT32 count
)
466 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
476 /***********************************************************************
479 BOOL
IsIconic(HWND hWnd
)
481 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
482 if (wndPtr
== NULL
) return FALSE
;
483 return (wndPtr
->dwStyle
& WS_MINIMIZE
) != 0;
487 /***********************************************************************
488 * IsZoomed (USER.272)
490 BOOL
IsZoomed(HWND hWnd
)
492 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
493 if (wndPtr
== NULL
) return FALSE
;
494 return (wndPtr
->dwStyle
& WS_MAXIMIZE
) != 0;
498 /*******************************************************************
499 * GetActiveWindow (USER.60)
501 HWND
GetActiveWindow(void)
507 /*******************************************************************
508 * WINPOS_IsGoodEnough
510 static BOOL32
WINPOS_IsGoodEnough(WND
* pWnd
)
512 return (pWnd
) ? ((!(pWnd
->dwStyle
& WS_DISABLED
) &&
513 pWnd
->dwStyle
& WS_VISIBLE
) ? TRUE
: FALSE
) : FALSE
;
517 /*******************************************************************
518 * SetActiveWindow (USER.59)
520 HWND
SetActiveWindow( HWND hwnd
)
522 HWND prev
= hwndActive
;
523 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
525 if ( !WINPOS_IsGoodEnough(wndPtr
) ) return 0;
527 WINPOS_SetActiveWindow( hwnd
, 0, 0 );
532 /***********************************************************************
533 * BringWindowToTop (USER.45)
535 BOOL
BringWindowToTop( HWND hwnd
)
537 return SetWindowPos( hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
);
541 /***********************************************************************
542 * MoveWindow (USER.56)
544 BOOL
MoveWindow( HWND hwnd
, short x
, short y
, short cx
, short cy
, BOOL repaint
)
546 int flags
= SWP_NOZORDER
| SWP_NOACTIVATE
;
547 if (!repaint
) flags
|= SWP_NOREDRAW
;
548 dprintf_win(stddeb
, "MoveWindow: %04x %d,%d %dx%d %d\n",
549 hwnd
, x
, y
, cx
, cy
, repaint
);
550 return SetWindowPos( hwnd
, 0, x
, y
, cx
, cy
, flags
);
554 /***********************************************************************
555 * ShowWindow (USER.42)
557 BOOL
ShowWindow( HWND hwnd
, int cmd
)
559 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
560 BOOL32 wasVisible
, showFlag
;
563 short x
= 0, y
= 0, cx
= 0, cy
= 0;
565 if (!wndPtr
) return FALSE
;
567 dprintf_win(stddeb
,"ShowWindow: hwnd=%04x, cmd=%d\n", hwnd
, cmd
);
569 wasVisible
= (wndPtr
->dwStyle
& WS_VISIBLE
) != 0;
574 if (!wasVisible
) return FALSE
;
575 swpflags
|= SWP_HIDEWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
|
576 SWP_NOACTIVATE
| SWP_NOZORDER
;
579 case SW_SHOWMINNOACTIVE
:
580 swpflags
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
582 case SW_SHOWMINIMIZED
:
583 swpflags
|= SWP_SHOWWINDOW
;
586 swpflags
|= SWP_FRAMECHANGED
;
587 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
589 if( HOOK_CallHooks( WH_CBT
, HCBT_MINMAX
, hwnd
, cmd
) )
592 if (wndPtr
->dwStyle
& WS_MAXIMIZE
)
594 wndPtr
->flags
|= WIN_RESTORE_MAX
;
595 wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
599 wndPtr
->flags
&= ~WIN_RESTORE_MAX
;
600 wndPtr
->rectNormal
= wndPtr
->rectWindow
;
602 wndPtr
->dwStyle
|= WS_MINIMIZE
;
603 WINPOS_FindIconPos( hwnd
);
604 x
= wndPtr
->ptIconPos
.x
;
605 y
= wndPtr
->ptIconPos
.y
;
606 cx
= SYSMETRICS_CXICON
;
607 cy
= SYSMETRICS_CYICON
;
608 swpflags
|= SWP_NOCOPYBITS
;
610 else swpflags
|= SWP_NOSIZE
| SWP_NOMOVE
;
613 case SW_SHOWMAXIMIZED
: /* same as SW_MAXIMIZE: */
614 swpflags
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
615 if (!(wndPtr
->dwStyle
& WS_MAXIMIZE
))
617 if( HOOK_CallHooks( WH_CBT
, HCBT_MINMAX
, hwnd
, cmd
) )
620 /* Store the current position and find the maximized size */
621 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
622 wndPtr
->rectNormal
= wndPtr
->rectWindow
;
624 NC_GetMinMaxInfo( hwnd
, &maxSize
,
625 &wndPtr
->ptMaxPos
, NULL
, NULL
);
626 x
= wndPtr
->ptMaxPos
.x
;
627 y
= wndPtr
->ptMaxPos
.y
;
629 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
630 if( !SendMessage16( hwnd
, WM_QUERYOPEN
, 0, 0L ) )
632 swpflags
|= SWP_NOSIZE
| SWP_NOMOVE
;
635 else swpflags
|= SWP_NOCOPYBITS
;
639 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
640 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
642 else swpflags
|= SWP_NOSIZE
| SWP_NOMOVE
;
646 swpflags
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
649 swpflags
|= SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
;
652 case SW_SHOWNOACTIVATE
:
653 swpflags
|= SWP_NOZORDER
;
654 if (GetActiveWindow()) swpflags
|= SWP_NOACTIVATE
;
656 case SW_SHOWNORMAL
: /* same as SW_NORMAL: */
657 case SW_SHOWDEFAULT
: /* FIXME: should have its own handler */
659 swpflags
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
661 if (wndPtr
->dwStyle
& WS_MINIMIZE
)
663 if( HOOK_CallHooks( WH_CBT
, HCBT_MINMAX
, hwnd
, cmd
) )
666 if( !SendMessage16( hwnd
, WM_QUERYOPEN
, 0, 0L) )
668 swpflags
|= SWP_NOSIZE
| SWP_NOMOVE
;
671 wndPtr
->ptIconPos
.x
= wndPtr
->rectWindow
.left
;
672 wndPtr
->ptIconPos
.y
= wndPtr
->rectWindow
.top
;
673 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
674 if (wndPtr
->flags
& WIN_RESTORE_MAX
)
676 /* Restore to maximized position */
677 NC_GetMinMaxInfo( hwnd
, &maxSize
, &wndPtr
->ptMaxPos
,
679 x
= wndPtr
->ptMaxPos
.x
;
680 y
= wndPtr
->ptMaxPos
.y
;
683 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
685 else /* Restore to normal position */
687 x
= wndPtr
->rectNormal
.left
;
688 y
= wndPtr
->rectNormal
.top
;
689 cx
= wndPtr
->rectNormal
.right
- wndPtr
->rectNormal
.left
;
690 cy
= wndPtr
->rectNormal
.bottom
- wndPtr
->rectNormal
.top
;
692 swpflags
|= SWP_NOCOPYBITS
;
694 else if (wndPtr
->dwStyle
& WS_MAXIMIZE
)
696 if( HOOK_CallHooks( WH_CBT
, HCBT_MINMAX
, hwnd
, cmd
) )
699 wndPtr
->ptMaxPos
.x
= wndPtr
->rectWindow
.left
;
700 wndPtr
->ptMaxPos
.y
= wndPtr
->rectWindow
.top
;
701 wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
702 x
= wndPtr
->rectNormal
.left
;
703 y
= wndPtr
->rectNormal
.top
;
704 cx
= wndPtr
->rectNormal
.right
- wndPtr
->rectNormal
.left
;
705 cy
= wndPtr
->rectNormal
.bottom
- wndPtr
->rectNormal
.top
;
707 else swpflags
|= SWP_NOSIZE
| SWP_NOMOVE
;
711 showFlag
= (cmd
!= SW_HIDE
);
712 if (showFlag
!= wasVisible
)
714 SendMessage16( hwnd
, WM_SHOWWINDOW
, showFlag
, 0 );
715 if (!IsWindow( hwnd
)) return wasVisible
;
718 if ((wndPtr
->dwStyle
& WS_CHILD
) &&
719 !IsWindowVisible( wndPtr
->parent
->hwndSelf
) &&
720 (swpflags
& SWP_NOSIZE
) && (swpflags
& SWP_NOMOVE
))
722 /* Don't call SetWindowPos() on invisible child windows */
723 if (cmd
== SW_HIDE
) wndPtr
->dwStyle
&= ~WS_VISIBLE
;
724 else wndPtr
->dwStyle
|= WS_VISIBLE
;
728 /* We can't activate a child window */
729 if (wndPtr
->dwStyle
& WS_CHILD
)
730 swpflags
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
731 SetWindowPos( hwnd
, HWND_TOP
, x
, y
, cx
, cy
, swpflags
);
732 if (!IsWindow( hwnd
)) return wasVisible
;
735 if (wndPtr
->flags
& WIN_NEED_SIZE
)
737 /* should happen only in CreateWindowEx() */
738 int wParam
= SIZE_RESTORED
;
740 wndPtr
->flags
&= ~WIN_NEED_SIZE
;
741 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wParam
= SIZE_MAXIMIZED
;
742 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= SIZE_MINIMIZED
;
743 SendMessage16( hwnd
, WM_SIZE
, wParam
,
744 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
745 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
746 SendMessage16( hwnd
, WM_MOVE
, 0,
747 MAKELONG(wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
) );
754 /***********************************************************************
755 * GetInternalWindowPos16 (USER.460)
757 UINT16
GetInternalWindowPos16( HWND16 hwnd
, LPRECT16 rectWnd
, LPPOINT16 ptIcon
)
759 WINDOWPLACEMENT16 wndpl
;
760 if (!GetWindowPlacement16( hwnd
, &wndpl
)) return 0;
761 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
762 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
763 return wndpl
.showCmd
;
767 /***********************************************************************
768 * GetInternalWindowPos32 (USER32.244)
770 UINT32
GetInternalWindowPos32( HWND32 hwnd
, LPRECT32 rectWnd
, LPPOINT32 ptIcon
)
772 WINDOWPLACEMENT32 wndpl
;
773 if (!GetWindowPlacement32( hwnd
, &wndpl
)) return 0;
774 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
775 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
776 return wndpl
.showCmd
;
780 /***********************************************************************
781 * SetInternalWindowPos16 (USER.461)
783 void SetInternalWindowPos16( HWND16 hwnd
, UINT16 showCmd
,
784 LPRECT16 rect
, LPPOINT16 pt
)
786 WINDOWPLACEMENT16 wndpl
;
787 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
789 wndpl
.length
= sizeof(wndpl
);
790 wndpl
.flags
= (pt
!= NULL
) ? WPF_SETMINPOSITION
: 0;
791 wndpl
.showCmd
= showCmd
;
792 if (pt
) wndpl
.ptMinPosition
= *pt
;
793 wndpl
.rcNormalPosition
= (rect
!= NULL
) ? *rect
: wndPtr
->rectNormal
;
794 wndpl
.ptMaxPosition
= wndPtr
->ptMaxPos
;
795 SetWindowPlacement16( hwnd
, &wndpl
);
799 /***********************************************************************
800 * SetInternalWindowPos32 (USER32.482)
802 void SetInternalWindowPos32( HWND32 hwnd
, UINT32 showCmd
,
803 LPRECT32 rect
, LPPOINT32 pt
)
805 WINDOWPLACEMENT32 wndpl
;
806 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
808 wndpl
.length
= sizeof(wndpl
);
809 wndpl
.flags
= (pt
!= NULL
) ? WPF_SETMINPOSITION
: 0;
810 wndpl
.showCmd
= showCmd
;
811 if (pt
) wndpl
.ptMinPosition
= *pt
;
812 if (rect
) wndpl
.rcNormalPosition
= *rect
;
813 else CONV_RECT16TO32( &wndPtr
->rectNormal
, &wndpl
.rcNormalPosition
);
814 CONV_POINT16TO32( &wndPtr
->ptMaxPos
, &wndpl
.ptMaxPosition
);
815 SetWindowPlacement32( hwnd
, &wndpl
);
819 /***********************************************************************
820 * GetWindowPlacement16 (USER.370)
822 BOOL16
GetWindowPlacement16( HWND16 hwnd
, WINDOWPLACEMENT16
*wndpl
)
824 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
825 if (!wndPtr
) return FALSE
;
827 wndpl
->length
= sizeof(*wndpl
);
829 wndpl
->showCmd
= IsZoomed(hwnd
) ? SW_SHOWMAXIMIZED
:
830 (IsIconic(hwnd
) ? SW_SHOWMINIMIZED
: SW_SHOWNORMAL
);
831 wndpl
->ptMinPosition
= wndPtr
->ptIconPos
;
832 wndpl
->ptMaxPosition
= wndPtr
->ptMaxPos
;
833 wndpl
->rcNormalPosition
= wndPtr
->rectNormal
;
838 /***********************************************************************
839 * GetWindowPlacement32 (USER32.306)
841 BOOL32
GetWindowPlacement32( HWND32 hwnd
, WINDOWPLACEMENT32
*wndpl
)
843 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
844 if (!wndPtr
) return FALSE
;
846 wndpl
->length
= sizeof(*wndpl
);
848 wndpl
->showCmd
= IsZoomed(hwnd
) ? SW_SHOWMAXIMIZED
:
849 (IsIconic(hwnd
) ? SW_SHOWMINIMIZED
: SW_SHOWNORMAL
);
850 CONV_POINT16TO32( &wndPtr
->ptIconPos
, &wndpl
->ptMinPosition
);
851 CONV_POINT16TO32( &wndPtr
->ptMaxPos
, &wndpl
->ptMaxPosition
);
852 CONV_RECT16TO32( &wndPtr
->rectNormal
, &wndpl
->rcNormalPosition
);
857 /***********************************************************************
858 * SetWindowPlacement16 (USER.371)
860 BOOL16
SetWindowPlacement16( HWND16 hwnd
, const WINDOWPLACEMENT16
*wndpl
)
862 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
863 if (!wndPtr
) return FALSE
;
865 if (wndpl
->flags
& WPF_SETMINPOSITION
)
866 wndPtr
->ptIconPos
= wndpl
->ptMinPosition
;
867 if ((wndpl
->flags
& WPF_RESTORETOMAXIMIZED
) &&
868 (wndpl
->showCmd
== SW_SHOWMINIMIZED
)) wndPtr
->flags
|= WIN_RESTORE_MAX
;
869 wndPtr
->ptMaxPos
= wndpl
->ptMaxPosition
;
870 wndPtr
->rectNormal
= wndpl
->rcNormalPosition
;
871 ShowWindow( hwnd
, wndpl
->showCmd
);
876 /***********************************************************************
877 * SetWindowPlacement32 (USER32.518)
879 BOOL32
SetWindowPlacement32( HWND32 hwnd
, const WINDOWPLACEMENT32
*wndpl
)
881 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
882 if (!wndPtr
) return FALSE
;
884 if (wndpl
->flags
& WPF_SETMINPOSITION
)
885 CONV_POINT32TO16( &wndpl
->ptMinPosition
, &wndPtr
->ptIconPos
);
886 if ((wndpl
->flags
& WPF_RESTORETOMAXIMIZED
) &&
887 (wndpl
->showCmd
== SW_SHOWMINIMIZED
)) wndPtr
->flags
|= WIN_RESTORE_MAX
;
888 CONV_POINT32TO16( &wndpl
->ptMaxPosition
, &wndPtr
->ptMaxPos
);
889 CONV_RECT32TO16( &wndpl
->rcNormalPosition
, &wndPtr
->rectNormal
);
890 ShowWindow( hwnd
, wndpl
->showCmd
);
894 /***********************************************************************
895 * WINPOS_ForceXWindowRaise
897 void WINPOS_ForceXWindowRaise( WND
* pWnd
)
899 XWindowChanges winChanges
;
900 WND
*wndStop
, *wndLast
;
902 if (!pWnd
->window
) return;
904 wndLast
= wndStop
= pWnd
;
905 winChanges
.stack_mode
= Above
;
906 XReconfigureWMWindow( display
, pWnd
->window
, 0, CWStackMode
, &winChanges
);
908 /* Recursively raise owned popups according to their z-order
909 * (it would be easier with sibling-related Below but it doesn't
910 * work very well with SGI mwm for instance)
914 WND
*wnd
= WIN_GetDesktop()->child
;
916 while (wnd
!= wndStop
)
918 if (wnd
->owner
== pWnd
&&
919 (wnd
->dwStyle
& WS_POPUP
) &&
920 (wnd
->dwStyle
& WS_VISIBLE
))
926 WINPOS_ForceXWindowRaise( wndLast
);
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_CallHooks( WH_CBT
, HCBT_ACTIVATE
, (WPARAM
)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
, (WPARAM
)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 (int)params
->rgrc
[0].top
, (int)params
->rgrc
[0].left
,
1204 (int)params
->rgrc
[0].bottom
, (int)params
->rgrc
[0].right
);
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( winpos
->hwnd
, &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( winpos
->hwnd
, &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
= CreateRectRgn(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 CombineRgn( dirtyRgn
, newVisRgn
, 0, RGN_COPY
);
1406 if( !(uFlags
& SMC_NOCOPY
) )
1407 CombineRgn( newVisRgn
, newVisRgn
, oldVisRgn
, RGN_AND
);
1409 /* map regions to the parent client area */
1411 OffsetRgn(dirtyRgn
, Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
);
1412 OffsetRgn(oldVisRgn
, lpOldWndRect
->left
, lpOldWndRect
->top
);
1414 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1416 other
= CombineRgn(dirtyRgn
, oldVisRgn
, dirtyRgn
, RGN_DIFF
);
1418 /* map visible region to the Wnd client area */
1420 OffsetRgn( 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)? CombineRgn( newVisRgn
, newVisRgn
, Wnd
->hrgnUpdate
, RGN_DIFF
)
1428 if( uFlags
& SMC_NOCOPY
) /* invalidate Wnd visible region */
1430 if (my
!= NULLREGION
) PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, newVisRgn
, RDW_INVALIDATE
|
1431 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1433 else /* bitblt old client area */
1438 int xfrom
,yfrom
,xto
,yto
,width
,height
;
1440 if( uFlags
& SMC_DRAWFRAME
)
1442 /* copy only client area, frame will be redrawn anyway */
1444 xfrom
= lpOldClientRect
->left
; yfrom
= lpOldClientRect
->top
;
1445 xto
= Wnd
->rectClient
.left
; yto
= Wnd
->rectClient
.top
;
1446 width
= lpOldClientRect
->right
- xfrom
; height
= lpOldClientRect
->bottom
- yfrom
;
1447 updateRgn
= CreateRectRgn( 0, 0, width
, height
);
1448 CombineRgn( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1449 SetRectRgn( updateRgn
, 0, 0, Wnd
->rectClient
.right
- xto
, Wnd
->rectClient
.bottom
- yto
);
1453 xfrom
= lpOldWndRect
->left
; yfrom
= lpOldWndRect
->top
;
1454 xto
= Wnd
->rectWindow
.left
; yto
= Wnd
->rectWindow
.top
;
1455 width
= lpOldWndRect
->right
- xfrom
; height
= lpOldWndRect
->bottom
- yfrom
;
1456 updateRgn
= CreateRectRgn( xto
- Wnd
->rectClient
.left
,
1457 yto
- Wnd
->rectClient
.top
,
1458 Wnd
->rectWindow
.right
- Wnd
->rectClient
.left
,
1459 Wnd
->rectWindow
.bottom
- Wnd
->rectClient
.top
);
1462 CombineRgn( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1464 /* substract new visRgn from target rect to get a region that won't be copied */
1466 update
= CombineRgn( updateRgn
, updateRgn
, newVisRgn
, RGN_DIFF
);
1468 /* Blt valid bits using parent window DC */
1470 if( my
!= NULLREGION
&& (xfrom
!= xto
|| yfrom
!= yto
) )
1473 /* compute clipping region in parent client coordinates */
1475 OffsetRgn( newVisRgn
, Wnd
->rectClient
.left
, Wnd
->rectClient
.top
);
1476 CombineRgn( oldVisRgn
, oldVisRgn
, newVisRgn
, RGN_OR
);
1478 hDC
= GetDCEx32( Wnd
->parent
->hwndSelf
, oldVisRgn
,
1479 DCX_KEEPCLIPRGN
| DCX_INTERSECTRGN
|
1480 DCX_CACHE
| DCX_CLIPSIBLINGS
);
1482 BitBlt( hDC
, xto
, yto
, width
, height
, hDC
, xfrom
, yfrom
, SRCCOPY
);
1484 ReleaseDC32( Wnd
->parent
->hwndSelf
, hDC
);
1487 if( update
!= NULLREGION
)
1488 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, updateRgn
, RDW_INVALIDATE
|
1489 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1490 else if( uFlags
& SMC_DRAWFRAME
) Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1491 DeleteObject( updateRgn
);
1494 /* erase uncovered areas */
1496 if( !(uFlags
& SMC_NOPARENTERASE
) && (other
!= NULLREGION
) )
1497 PAINT_RedrawWindow( Wnd
->parent
->hwndSelf
, NULL
, dirtyRgn
,
1498 RDW_INVALIDATE
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1499 DeleteObject(dirtyRgn
);
1500 DeleteObject(newVisRgn
);
1505 /***********************************************************************
1506 * WINPOS_SetXWindowPos
1508 * SetWindowPos() for an X window. Used by the real SetWindowPos().
1510 static void WINPOS_SetXWindowPos( WINDOWPOS16
*winpos
)
1512 XWindowChanges winChanges
;
1514 WND
*wndPtr
= WIN_FindWndPtr( winpos
->hwnd
);
1516 if (!(winpos
->flags
& SWP_NOSIZE
))
1518 winChanges
.width
= winpos
->cx
;
1519 winChanges
.height
= winpos
->cy
;
1520 changeMask
|= CWWidth
| CWHeight
;
1522 /* Tweak dialog window size hints */
1524 if ((wndPtr
->flags
& WIN_MANAGED
) &&
1525 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
1527 XSizeHints
*size_hints
= XAllocSizeHints();
1531 long supplied_return
;
1533 XGetWMSizeHints( display
, wndPtr
->window
, size_hints
,
1534 &supplied_return
, XA_WM_NORMAL_HINTS
);
1535 size_hints
->min_width
= size_hints
->max_width
= winpos
->cx
;
1536 size_hints
->min_height
= size_hints
->max_height
= winpos
->cy
;
1537 XSetWMSizeHints( display
, wndPtr
->window
, size_hints
,
1538 XA_WM_NORMAL_HINTS
);
1543 if (!(winpos
->flags
& SWP_NOMOVE
))
1545 winChanges
.x
= winpos
->x
;
1546 winChanges
.y
= winpos
->y
;
1547 changeMask
|= CWX
| CWY
;
1549 if (!(winpos
->flags
& SWP_NOZORDER
))
1551 winChanges
.stack_mode
= Below
;
1552 changeMask
|= CWStackMode
;
1554 if (winpos
->hwndInsertAfter
== HWND_TOP
) winChanges
.stack_mode
= Above
;
1555 else if (winpos
->hwndInsertAfter
!= HWND_BOTTOM
)
1557 WND
* insertPtr
= WIN_FindWndPtr( winpos
->hwndInsertAfter
);
1560 stack
[0] = insertPtr
->window
;
1561 stack
[1] = wndPtr
->window
;
1563 /* for stupid window managers (i.e. all of them) */
1565 XRestackWindows(display
, stack
, 2);
1566 changeMask
&= ~CWStackMode
;
1569 if (!changeMask
) return;
1571 XReconfigureWMWindow( display
, wndPtr
->window
, 0, changeMask
, &winChanges
);
1575 /***********************************************************************
1576 * SetWindowPos (USER.232)
1578 BOOL
SetWindowPos( HWND hwnd
, HWND hwndInsertAfter
, INT x
, INT y
,
1579 INT cx
, INT cy
, WORD flags
)
1581 WINDOWPOS16
*winpos
;
1583 RECT16 newWindowRect
, newClientRect
, oldWindowRect
;
1585 HWND tempInsertAfter
= 0;
1589 dprintf_win(stddeb
,"SetWindowPos: hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
1590 hwnd
, x
, y
, x
+cx
, y
+cy
, flags
);
1591 /* Check window handle */
1593 if (hwnd
== GetDesktopWindow32()) return FALSE
;
1594 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return FALSE
;
1596 if (wndPtr
->dwStyle
& WS_VISIBLE
) flags
&= ~SWP_SHOWWINDOW
;
1599 uFlags
|= SMC_NOPARENTERASE
;
1600 flags
&= ~SWP_HIDEWINDOW
;
1601 if (!(flags
& SWP_SHOWWINDOW
)) flags
|= SWP_NOREDRAW
;
1604 /* Check for windows that may not be resized
1605 FIXME: this should be done only for Windows 3.0 programs
1606 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
1607 flags |= SWP_NOSIZE | SWP_NOMOVE;
1609 /* Check dimensions */
1611 if (cx
<= 0) cx
= 1;
1612 if (cy
<= 0) cy
= 1;
1616 if (hwnd
== hwndActive
) flags
|= SWP_NOACTIVATE
; /* Already active */
1617 if ((wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
== cx
) &&
1618 (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
== cy
))
1619 flags
|= SWP_NOSIZE
; /* Already the right size */
1620 if ((wndPtr
->rectWindow
.left
== x
) && (wndPtr
->rectWindow
.top
== y
))
1621 flags
|= SWP_NOMOVE
; /* Already the right position */
1623 /* Check hwndInsertAfter */
1625 if (!(flags
& (SWP_NOZORDER
| SWP_NOACTIVATE
)))
1627 /* Ignore TOPMOST flags when activating a window */
1628 /* _and_ moving it in Z order. */
1629 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
1630 (hwndInsertAfter
== HWND_NOTOPMOST
))
1631 hwndInsertAfter
= HWND_TOP
;
1633 /* TOPMOST not supported yet */
1634 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
1635 (hwndInsertAfter
== HWND_NOTOPMOST
)) hwndInsertAfter
= HWND_TOP
;
1637 /* hwndInsertAfter must be a sibling of the window */
1638 if ((hwndInsertAfter
!= HWND_TOP
) && (hwndInsertAfter
!= HWND_BOTTOM
))
1640 WND
* wnd
= WIN_FindWndPtr(hwndInsertAfter
);
1641 if( wnd
->parent
!= wndPtr
->parent
) return FALSE
;
1642 if( wnd
->next
== wndPtr
) flags
|= SWP_NOZORDER
;
1645 if (hwndInsertAfter
== HWND_TOP
)
1646 flags
|= ( wndPtr
->parent
->child
== wndPtr
)? SWP_NOZORDER
: 0;
1647 else /* HWND_BOTTOM */
1648 flags
|= ( wndPtr
->next
)? 0: SWP_NOZORDER
;
1650 /* Fill the WINDOWPOS structure */
1652 if (!(winpos
= SEGPTR_NEW(WINDOWPOS16
))) return FALSE
;
1653 winpos
->hwnd
= hwnd
;
1654 winpos
->hwndInsertAfter
= hwndInsertAfter
;
1659 winpos
->flags
= flags
;
1661 /* Send WM_WINDOWPOSCHANGING message */
1663 if (!(flags
& SWP_NOSENDCHANGING
))
1664 SendMessage16( hwnd
, WM_WINDOWPOSCHANGING
, 0,
1665 (LPARAM
)SEGPTR_GET(winpos
) );
1667 /* Calculate new position and size */
1669 newWindowRect
= wndPtr
->rectWindow
;
1670 newClientRect
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? wndPtr
->rectWindow
1671 : wndPtr
->rectClient
;
1673 if (!(winpos
->flags
& SWP_NOSIZE
))
1675 newWindowRect
.right
= newWindowRect
.left
+ winpos
->cx
;
1676 newWindowRect
.bottom
= newWindowRect
.top
+ winpos
->cy
;
1678 if (!(winpos
->flags
& SWP_NOMOVE
))
1680 newWindowRect
.left
= winpos
->x
;
1681 newWindowRect
.top
= winpos
->y
;
1682 newWindowRect
.right
+= winpos
->x
- wndPtr
->rectWindow
.left
;
1683 newWindowRect
.bottom
+= winpos
->y
- wndPtr
->rectWindow
.top
;
1685 OffsetRect16( &newClientRect
, winpos
->x
- wndPtr
->rectWindow
.left
,
1686 winpos
->y
- wndPtr
->rectWindow
.top
);
1689 winpos
->flags
|= SWP_NOCLIENTMOVE
| SWP_NOCLIENTSIZE
;
1691 /* Reposition window in Z order */
1693 if (!(winpos
->flags
& SWP_NOZORDER
))
1695 /* reorder owned popups if hwnd is top-level window
1697 if( wndPtr
->parent
== WIN_GetDesktop() )
1698 hwndInsertAfter
= WINPOS_ReorderOwnedPopups( hwndInsertAfter
,
1703 WIN_UnlinkWindow( winpos
->hwnd
);
1704 WIN_LinkWindow( winpos
->hwnd
, hwndInsertAfter
);
1706 else WINPOS_MoveWindowZOrder( winpos
->hwnd
, hwndInsertAfter
);
1709 if ( !wndPtr
->window
&& !(flags
& SWP_NOREDRAW
) &&
1710 (!(flags
& SWP_NOMOVE
) || !(flags
& SWP_NOSIZE
) || (flags
& SWP_FRAMECHANGED
)) )
1711 visRgn
= DCE_GetVisRgn(hwnd
, DCX_WINDOW
| DCX_CLIPSIBLINGS
);
1714 /* Send WM_NCCALCSIZE message to get new client area */
1715 if( (flags
& (SWP_FRAMECHANGED
| SWP_NOSIZE
)) != SWP_NOSIZE
)
1717 result
= WINPOS_SendNCCalcSize( winpos
->hwnd
, TRUE
, &newWindowRect
,
1718 &wndPtr
->rectWindow
, &wndPtr
->rectClient
,
1719 SEGPTR_GET(winpos
), &newClientRect
);
1721 /* FIXME: WVR_ALIGNxxx */
1723 if( newClientRect
.left
!= wndPtr
->rectClient
.left
||
1724 newClientRect
.top
!= wndPtr
->rectClient
.top
)
1725 winpos
->flags
&= ~SWP_NOCLIENTMOVE
;
1727 if( (newClientRect
.right
- newClientRect
.left
!=
1728 wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
) ||
1729 (newClientRect
.bottom
- newClientRect
.top
!=
1730 wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
) )
1731 winpos
->flags
&= ~SWP_NOCLIENTSIZE
;
1734 if( !(flags
& SWP_NOMOVE
) && (newClientRect
.left
!= wndPtr
->rectClient
.left
||
1735 newClientRect
.top
!= wndPtr
->rectClient
.top
) )
1736 winpos
->flags
&= ~SWP_NOCLIENTMOVE
;
1738 /* Update active DCEs */
1740 if( !(flags
& SWP_NOZORDER
) || (flags
& SWP_HIDEWINDOW
) || (flags
& SWP_SHOWWINDOW
)
1741 || (memcmp(&newWindowRect
,&wndPtr
->rectWindow
,sizeof(RECT16
))
1742 && wndPtr
->dwStyle
& WS_VISIBLE
) )
1746 UnionRect16(&rect
,&newWindowRect
,&wndPtr
->rectWindow
);
1747 DCE_InvalidateDCE(wndPtr
->parent
, &rect
);
1750 /* change geometry */
1752 oldWindowRect
= wndPtr
->rectWindow
;
1756 RECT16 oldClientRect
= wndPtr
->rectClient
;
1758 tempInsertAfter
= winpos
->hwndInsertAfter
;
1760 winpos
->hwndInsertAfter
= hwndInsertAfter
;
1762 /* postpone geometry change */
1764 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
1766 WINPOS_SetXWindowPos( winpos
);
1767 winpos
->hwndInsertAfter
= tempInsertAfter
;
1769 else uFlags
|= SMC_SETXPOS
;
1771 wndPtr
->rectWindow
= newWindowRect
;
1772 wndPtr
->rectClient
= newClientRect
;
1774 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
1775 if( (oldClientRect
.left
- oldWindowRect
.left
!=
1776 newClientRect
.left
- newWindowRect
.left
) ||
1777 (oldClientRect
.top
- oldWindowRect
.top
!=
1778 newClientRect
.top
- newWindowRect
.top
) || winpos
->flags
& SWP_NOCOPYBITS
)
1780 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, RDW_INVALIDATE
|
1781 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
1783 if( winpos
->flags
& SWP_FRAMECHANGED
)
1788 if( oldClientRect
.right
> newClientRect
.right
)
1790 rect
.left
= newClientRect
.right
; rect
.top
= newClientRect
.top
;
1791 rect
.right
= oldClientRect
.right
; rect
.bottom
= newClientRect
.bottom
;
1793 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
1794 RDW_INVALIDATE
| RDW_FRAME
| RDW_ALLCHILDREN
, 0 );
1796 if( oldClientRect
.bottom
> newClientRect
.bottom
)
1798 rect
.left
= newClientRect
.left
; rect
.top
= newClientRect
.bottom
;
1799 rect
.right
= (wErase
)?oldClientRect
.right
:newClientRect
.right
;
1800 rect
.bottom
= oldClientRect
.bottom
;
1802 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
1803 RDW_INVALIDATE
| RDW_FRAME
| RDW_ALLCHILDREN
, 0 );
1805 if( !wErase
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
1810 RECT16 oldClientRect
= wndPtr
->rectClient
;
1812 wndPtr
->rectWindow
= newWindowRect
;
1813 wndPtr
->rectClient
= newClientRect
;
1815 if( oldClientRect
.bottom
- oldClientRect
.top
==
1816 newClientRect
.bottom
- newClientRect
.top
) result
&= ~WVR_VREDRAW
;
1818 if( oldClientRect
.right
- oldClientRect
.left
==
1819 newClientRect
.right
- newClientRect
.left
) result
&= ~WVR_HREDRAW
;
1821 if( !(flags
& (SWP_NOREDRAW
| SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
1823 uFlags
|= ((winpos
->flags
& SWP_NOCOPYBITS
) ||
1824 (result
>= WVR_HREDRAW
&& result
< WVR_VALIDRECTS
)) ? SMC_NOCOPY
: 0;
1825 uFlags
|= (winpos
->flags
& SWP_FRAMECHANGED
) ? SMC_DRAWFRAME
: 0;
1827 if( (winpos
->flags
& SWP_AGG_NOGEOMETRYCHANGE
) != SWP_AGG_NOGEOMETRYCHANGE
)
1828 uFlags
= WINPOS_SizeMoveClean(wndPtr
, visRgn
, &oldWindowRect
,
1829 &oldClientRect
, uFlags
);
1832 /* adjust frame and do not erase parent */
1834 if( winpos
->flags
& SWP_FRAMECHANGED
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
1835 if( winpos
->flags
& SWP_NOZORDER
) uFlags
|= SMC_NOPARENTERASE
;
1838 DeleteObject(visRgn
);
1841 if (flags
& SWP_SHOWWINDOW
)
1843 wndPtr
->dwStyle
|= WS_VISIBLE
;
1846 if( uFlags
& SMC_SETXPOS
)
1848 WINPOS_SetXWindowPos( winpos
);
1849 winpos
->hwndInsertAfter
= tempInsertAfter
;
1851 XMapWindow( display
, wndPtr
->window
);
1855 if (!(flags
& SWP_NOREDRAW
))
1856 PAINT_RedrawWindow( winpos
->hwnd
, NULL
, 0,
1857 RDW_INVALIDATE
| RDW_ALLCHILDREN
|
1858 RDW_FRAME
| RDW_ERASENOW
| RDW_ERASE
, 0 );
1861 else if (flags
& SWP_HIDEWINDOW
)
1863 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
1866 XUnmapWindow( display
, wndPtr
->window
);
1867 if( uFlags
& SMC_SETXPOS
)
1869 WINPOS_SetXWindowPos( winpos
);
1870 winpos
->hwndInsertAfter
= tempInsertAfter
;
1875 if (!(flags
& SWP_NOREDRAW
))
1877 RECT32 rect
= { oldWindowRect
.left
, oldWindowRect
.top
,
1878 oldWindowRect
.right
, oldWindowRect
.bottom
};
1879 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, &rect
, 0,
1880 RDW_INVALIDATE
| RDW_ALLCHILDREN
| RDW_ERASE
| RDW_ERASENOW
, 0);
1882 uFlags
|= SMC_NOPARENTERASE
;
1885 if ((winpos
->hwnd
== GetFocus32()) ||
1886 IsChild( winpos
->hwnd
, GetFocus32()))
1888 /* Revert focus to parent */
1889 SetFocus32( GetParent32(winpos
->hwnd
) );
1891 if (hwnd
== CARET_GetHwnd()) DestroyCaret();
1893 if (winpos
->hwnd
== hwndActive
)
1895 /* Activate previously active window if possible */
1896 HWND newActive
= hwndPrevActive
;
1897 if (!IsWindow(newActive
) || (newActive
== winpos
->hwnd
))
1899 newActive
= GetTopWindow( GetDesktopWindow32() );
1900 if (newActive
== winpos
->hwnd
)
1901 newActive
= wndPtr
->next
? wndPtr
->next
->hwndSelf
: 0;
1903 WINPOS_ChangeActiveWindow( newActive
, FALSE
);
1907 /* Activate the window */
1909 if (!(flags
& SWP_NOACTIVATE
))
1910 WINPOS_ChangeActiveWindow( winpos
->hwnd
, FALSE
);
1912 /* Repaint the window */
1914 if (wndPtr
->window
) EVENT_Synchronize(); /* Wait for all expose events */
1916 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
1918 if (!(flags
& SWP_DEFERERASE
) && !(uFlags
& SMC_NOPARENTERASE
) )
1921 CONV_RECT16TO32( &oldWindowRect
, &rect
);
1922 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, (wndPtr
->flags
& WIN_SAVEUNDER_OVERRIDE
)
1923 ? &rect
: NULL
, 0, RDW_ALLCHILDREN
| RDW_ERASENOW
|
1924 ((wndPtr
->flags
& WIN_SAVEUNDER_OVERRIDE
) ? RDW_INVALIDATE
: 0), 0 );
1925 wndPtr
->flags
&= ~WIN_SAVEUNDER_OVERRIDE
;
1927 else if( wndPtr
->parent
== WIN_GetDesktop() && wndPtr
->parent
->flags
& WIN_NEEDS_ERASEBKGND
)
1928 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_NOCHILDREN
| RDW_ERASENOW
, 0 );
1930 /* And last, send the WM_WINDOWPOSCHANGED message */
1932 dprintf_win(stddeb
,"\tstatus flags = %04x\n", winpos
->flags
& SWP_AGG_STATUSFLAGS
);
1934 if ( ((winpos
->flags
& SWP_AGG_STATUSFLAGS
) != SWP_AGG_NOPOSCHANGE
) &&
1935 !(winpos
->flags
& SWP_NOSENDCHANGING
))
1936 SendMessage16( winpos
->hwnd
, WM_WINDOWPOSCHANGED
,
1937 0, (LPARAM
)SEGPTR_GET(winpos
) );
1939 SEGPTR_FREE(winpos
);
1944 /***********************************************************************
1945 * BeginDeferWindowPos (USER.259)
1947 HDWP16
BeginDeferWindowPos( INT count
)
1952 if (count
<= 0) return 0;
1953 handle
= USER_HEAP_ALLOC( sizeof(DWP
) + (count
-1)*sizeof(WINDOWPOS16
) );
1954 if (!handle
) return 0;
1955 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( handle
);
1956 pDWP
->actualCount
= 0;
1957 pDWP
->suggestedCount
= count
;
1959 pDWP
->wMagic
= DWP_MAGIC
;
1960 pDWP
->hwndParent
= 0;
1965 /***********************************************************************
1966 * DeferWindowPos (USER.260)
1968 HDWP16
DeferWindowPos( HDWP16 hdwp
, HWND hwnd
, HWND hwndAfter
, INT x
, INT y
,
1969 INT cx
, INT cy
, UINT flags
)
1973 HDWP16 newhdwp
= hdwp
;
1976 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
1977 if (!pDWP
) return 0;
1978 if (hwnd
== GetDesktopWindow32()) return 0;
1980 /* All the windows of a DeferWindowPos() must have the same parent */
1982 parent
= WIN_FindWndPtr( hwnd
)->parent
->hwndSelf
;
1983 if (pDWP
->actualCount
== 0) pDWP
->hwndParent
= parent
;
1984 else if (parent
!= pDWP
->hwndParent
)
1986 USER_HEAP_FREE( hdwp
);
1990 for (i
= 0; i
< pDWP
->actualCount
; i
++)
1992 if (pDWP
->winPos
[i
].hwnd
== hwnd
)
1994 /* Merge with the other changes */
1995 if (!(flags
& SWP_NOZORDER
))
1997 pDWP
->winPos
[i
].hwndInsertAfter
= hwndAfter
;
1999 if (!(flags
& SWP_NOMOVE
))
2001 pDWP
->winPos
[i
].x
= x
;
2002 pDWP
->winPos
[i
].y
= y
;
2004 if (!(flags
& SWP_NOSIZE
))
2006 pDWP
->winPos
[i
].cx
= cx
;
2007 pDWP
->winPos
[i
].cy
= cy
;
2009 pDWP
->winPos
[i
].flags
&= flags
& (SWP_NOSIZE
| SWP_NOMOVE
|
2010 SWP_NOZORDER
| SWP_NOREDRAW
|
2011 SWP_NOACTIVATE
| SWP_NOCOPYBITS
|
2013 pDWP
->winPos
[i
].flags
|= flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
|
2018 if (pDWP
->actualCount
>= pDWP
->suggestedCount
)
2020 newhdwp
= USER_HEAP_REALLOC( hdwp
,
2021 sizeof(DWP
) + pDWP
->suggestedCount
*sizeof(WINDOWPOS16
) );
2022 if (!newhdwp
) return 0;
2023 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( newhdwp
);
2024 pDWP
->suggestedCount
++;
2026 pDWP
->winPos
[pDWP
->actualCount
].hwnd
= hwnd
;
2027 pDWP
->winPos
[pDWP
->actualCount
].hwndInsertAfter
= hwndAfter
;
2028 pDWP
->winPos
[pDWP
->actualCount
].x
= x
;
2029 pDWP
->winPos
[pDWP
->actualCount
].y
= y
;
2030 pDWP
->winPos
[pDWP
->actualCount
].cx
= cx
;
2031 pDWP
->winPos
[pDWP
->actualCount
].cy
= cy
;
2032 pDWP
->winPos
[pDWP
->actualCount
].flags
= flags
;
2033 pDWP
->actualCount
++;
2038 /***********************************************************************
2039 * EndDeferWindowPos (USER.261)
2041 BOOL
EndDeferWindowPos( HDWP16 hdwp
)
2044 WINDOWPOS16
*winpos
;
2048 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2049 if (!pDWP
) return FALSE
;
2050 for (i
= 0, winpos
= pDWP
->winPos
; i
< pDWP
->actualCount
; i
++, winpos
++)
2052 if (!(res
= SetWindowPos( winpos
->hwnd
, winpos
->hwndInsertAfter
,
2053 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
,
2054 winpos
->flags
))) break;
2056 USER_HEAP_FREE( hdwp
);
2061 /***********************************************************************
2062 * TileChildWindows (USER.199)
2064 void TileChildWindows( HWND parent
, WORD action
)
2066 printf("STUB TileChildWindows(%04x, %d)\n", parent
, action
);
2069 /***********************************************************************
2070 * CascageChildWindows (USER.198)
2072 void CascadeChildWindows( HWND parent
, WORD action
)
2074 printf("STUB CascadeChildWindows(%04x, %d)\n", parent
, action
);