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( wndPtr
, &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( wndPtr
, &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
);
895 /***********************************************************************
896 * WINPOS_ForceXWindowRaise
898 * Raise a window on top of the X stacking order, while preserving
899 * the correct Windows Z order.
901 static void WINPOS_ForceXWindowRaise( WND
* pWnd
)
903 XWindowChanges winChanges
;
906 /* Raise all windows up to pWnd according to their Z order.
907 * (it would be easier with sibling-related Below but it doesn't
908 * work very well with SGI mwm for instance)
910 winChanges
.stack_mode
= Above
;
913 if (pWnd
->window
) XReconfigureWMWindow( display
, pWnd
->window
, 0,
914 CWStackMode
, &winChanges
);
915 wndPrev
= WIN_GetDesktop()->child
;
916 if (wndPrev
== pWnd
) break;
917 while (wndPrev
&& (wndPrev
->next
!= pWnd
)) wndPrev
= wndPrev
->next
;
923 /*******************************************************************
924 * WINPOS_SetActiveWindow
926 * back-end to SetActiveWindow
928 BOOL32
WINPOS_SetActiveWindow( HWND32 hWnd
, BOOL32 fMouse
, BOOL32 fChangeFocus
)
930 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
931 WND
*wndTemp
= WIN_FindWndPtr(hwndActive
);
932 CBTACTIVATESTRUCT16
*cbtStruct
;
934 HQUEUE16 hOldActiveQueue
= (pActiveQueue
)?pActiveQueue
->self
:0;
935 HQUEUE16 hNewActiveQueue
;
937 /* paranoid checks */
938 if( hWnd
== GetDesktopWindow32() || hWnd
== hwndActive
)
941 /* if (wndPtr && (GetTaskQueue(0) != wndPtr->hmemTaskQ))
946 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
948 dprintf_win(stddeb
,"WINPOS_ActivateWindow: no current active window.\n");
950 /* call CBT hook chain */
951 if ((cbtStruct
= SEGPTR_NEW(CBTACTIVATESTRUCT16
)))
954 cbtStruct
->fMouse
= fMouse
;
955 cbtStruct
->hWndActive
= hwndActive
;
956 wRet
= HOOK_CallHooks( WH_CBT
, HCBT_ACTIVATE
, (WPARAM16
)hWnd
,
957 (LPARAM
)SEGPTR_GET(cbtStruct
) );
958 SEGPTR_FREE(cbtStruct
);
959 if (wRet
) return wRet
;
962 /* set prev active wnd to current active wnd and send notification */
963 if ((hwndPrevActive
= hwndActive
) && IsWindow(hwndPrevActive
))
965 if (!SendMessage16( hwndPrevActive
, WM_NCACTIVATE
, FALSE
, 0 ))
967 if (GetSysModalWindow16() != hWnd
) return 0;
968 /* disregard refusal if hWnd is sysmodal */
971 SendMessage32A( hwndPrevActive
, WM_ACTIVATE
,
972 MAKEWPARAM( WA_INACTIVE
, wIconized
),
975 /* check if something happened during message processing */
976 if( hwndPrevActive
!= hwndActive
) return 0;
982 /* send palette messages */
983 if (hWnd
&& SendMessage16( hWnd
, WM_QUERYNEWPALETTE
, 0, 0L))
984 SendMessage16((HWND16
)-1, WM_PALETTEISCHANGING
, (WPARAM16
)hWnd
, 0L );
986 /* if prev wnd is minimized redraw icon title
989 wndTemp = WIN_FindWndPtr( WIN_GetTopParent( hwndPrevActive ) );
991 if(wndTemp->dwStyle & WS_MINIMIZE)
992 RedrawIconTitle(hwndPrevActive);
996 /* managed windows will get ConfigureNotify event */
997 if (wndPtr
&& !(wndPtr
->dwStyle
& WS_CHILD
) && !(wndPtr
->flags
& WIN_MANAGED
))
999 /* check Z-order and bring hWnd to the top */
1000 for (wndTemp
= WIN_GetDesktop()->child
; wndTemp
; wndTemp
= wndTemp
->next
)
1001 if (wndTemp
->dwStyle
& WS_VISIBLE
) break;
1003 if( wndTemp
!= wndPtr
)
1004 SetWindowPos(hWnd
, HWND_TOP
, 0,0,0,0,
1005 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1006 if( !IsWindow(hWnd
) ) return 0;
1009 hNewActiveQueue
= wndPtr
? wndPtr
->hmemTaskQ
: 0;
1011 /* send WM_ACTIVATEAPP if necessary */
1012 if (hOldActiveQueue
!= hNewActiveQueue
)
1014 WND
**list
, **ppWnd
;
1016 if ((list
= WIN_BuildWinArray( WIN_GetDesktop() )))
1018 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1020 if (!IsWindow( (*ppWnd
)->hwndSelf
)) continue;
1022 if ((*ppWnd
)->hmemTaskQ
== hOldActiveQueue
)
1023 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1024 0, QUEUE_GetQueueTask(hNewActiveQueue
) );
1026 HeapFree( SystemHeap
, 0, list
);
1029 pActiveQueue
= (hNewActiveQueue
)
1030 ? (MESSAGEQUEUE
*) GlobalLock16(hNewActiveQueue
) : NULL
;
1032 if ((list
= WIN_BuildWinArray( WIN_GetDesktop() )))
1034 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1036 if (!IsWindow( (*ppWnd
)->hwndSelf
)) continue;
1038 if ((*ppWnd
)->hmemTaskQ
== hNewActiveQueue
)
1039 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1040 1, QUEUE_GetQueueTask( hOldActiveQueue
) );
1042 HeapFree( SystemHeap
, 0, list
);
1044 if (!IsWindow(hWnd
)) return 0;
1049 /* walk up to the first unowned window */
1051 while (wndTemp
->owner
) wndTemp
= wndTemp
->owner
;
1052 /* and set last active owned popup */
1053 wndTemp
->hwndLastActive
= hWnd
;
1055 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1056 SendMessage16( hWnd
, WM_NCACTIVATE
, TRUE
, 0 );
1057 SendMessage32A( hWnd
, WM_ACTIVATE
,
1058 MAKEWPARAM( (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
, wIconized
),
1059 (LPARAM
)hwndPrevActive
);
1061 if( !IsWindow(hWnd
) ) return 0;
1064 /* change focus if possible */
1065 if( fChangeFocus
&& GetFocus32() )
1066 if( WIN_GetTopParent(GetFocus32()) != hwndActive
)
1067 FOCUS_SwitchFocus( GetFocus32(),
1068 (wndPtr
->dwStyle
& WS_MINIMIZE
)? 0: hwndActive
);
1070 if( !hwndPrevActive
&& wndPtr
&&
1071 wndPtr
->window
&& !(wndPtr
->flags
& WIN_MANAGED
) )
1072 WINPOS_ForceXWindowRaise(wndPtr
);
1074 /* if active wnd is minimized redraw icon title
1077 wndPtr = WIN_FindWndPtr(hwndActive);
1078 if(wndPtr->dwStyle & WS_MINIMIZE)
1079 RedrawIconTitle(hwndActive);
1082 return (hWnd
== hwndActive
);
1085 /*******************************************************************
1086 * WINPOS_ActivateOtherWindow
1088 * DestroyWindow() helper. pWnd must be a top-level window.
1090 BOOL32
WINPOS_ActivateOtherWindow(WND
* pWnd
)
1095 if( pWnd
->hwndSelf
== hwndPrevActive
)
1098 if( hwndActive
!= pWnd
->hwndSelf
&&
1099 ( hwndActive
|| QUEUE_IsDoomedQueue(pWnd
->hmemTaskQ
)) )
1102 if( pWnd
->dwStyle
& WS_POPUP
&&
1103 WINPOS_IsGoodEnough( pWnd
->owner
) ) pWndTo
= pWnd
->owner
;
1106 WND
* pWndPtr
= pWnd
;
1108 pWndTo
= WIN_FindWndPtr(hwndPrevActive
);
1110 while( !WINPOS_IsGoodEnough(pWndTo
) )
1112 /* by now owned windows should've been taken care of */
1114 pWndTo
= pWndPtr
->next
;
1116 if( !pWndTo
) return 0;
1120 bRet
= WINPOS_SetActiveWindow( pWndTo
->hwndSelf
, FALSE
, TRUE
);
1122 /* switch desktop queue to current active */
1123 if( pWndTo
->parent
== WIN_GetDesktop())
1124 WIN_GetDesktop()->hmemTaskQ
= pWndTo
->hmemTaskQ
;
1130 /*******************************************************************
1131 * WINPOS_ChangeActiveWindow
1134 BOOL32
WINPOS_ChangeActiveWindow( HWND32 hWnd
, BOOL32 mouseMsg
)
1136 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
1138 if (!hWnd
) return WINPOS_SetActiveWindow( 0, mouseMsg
, TRUE
);
1140 if( !wndPtr
) return FALSE
;
1142 /* child windows get WM_CHILDACTIVATE message */
1143 if( (wndPtr
->dwStyle
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
1144 return SendMessage16(hWnd
, WM_CHILDACTIVATE
, 0, 0L);
1146 /* owned popups imply owner activation - not sure */
1147 if ((wndPtr
->dwStyle
& WS_POPUP
) && wndPtr
->owner
&&
1148 !(wndPtr
->owner
->dwStyle
& WS_DISABLED
))
1150 if (!(wndPtr
= wndPtr
->owner
)) return FALSE
;
1151 hWnd
= wndPtr
->hwndSelf
;
1154 if( hWnd
== hwndActive
) return FALSE
;
1156 if( !WINPOS_SetActiveWindow(hWnd
,mouseMsg
,TRUE
) )
1159 /* switch desktop queue to current active */
1160 if( wndPtr
->parent
== WIN_GetDesktop())
1161 WIN_GetDesktop()->hmemTaskQ
= wndPtr
->hmemTaskQ
;
1167 /***********************************************************************
1168 * WINPOS_SendNCCalcSize
1170 * Send a WM_NCCALCSIZE message to a window.
1171 * All parameters are read-only except newClientRect.
1172 * oldWindowRect, oldClientRect and winpos must be non-NULL only
1173 * when calcValidRect is TRUE.
1175 LONG
WINPOS_SendNCCalcSize( HWND32 hwnd
, BOOL32 calcValidRect
,
1176 RECT16
*newWindowRect
, RECT16
*oldWindowRect
,
1177 RECT16
*oldClientRect
, SEGPTR winpos
,
1178 RECT16
*newClientRect
)
1180 NCCALCSIZE_PARAMS16
*params
;
1183 if (!(params
= SEGPTR_NEW(NCCALCSIZE_PARAMS16
))) return 0;
1184 params
->rgrc
[0] = *newWindowRect
;
1187 params
->rgrc
[1] = *oldWindowRect
;
1188 params
->rgrc
[2] = *oldClientRect
;
1189 params
->lppos
= winpos
;
1191 result
= SendMessage16( hwnd
, WM_NCCALCSIZE
, calcValidRect
,
1192 (LPARAM
)SEGPTR_GET( params
) );
1193 dprintf_win( stddeb
, "WINPOS_SendNCCalcSize: %d,%d-%d,%d\n",
1194 params
->rgrc
[0].left
, params
->rgrc
[0].top
,
1195 params
->rgrc
[0].right
, params
->rgrc
[0].bottom
);
1196 *newClientRect
= params
->rgrc
[0];
1197 SEGPTR_FREE(params
);
1202 /***********************************************************************
1203 * WINPOS_HandleWindowPosChanging16
1205 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1207 LONG
WINPOS_HandleWindowPosChanging16( WND
*wndPtr
, WINDOWPOS16
*winpos
)
1210 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1211 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1212 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1214 NC_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, NULL
, NULL
);
1215 winpos
->cx
= MIN( winpos
->cx
, maxSize
.x
);
1216 winpos
->cy
= MIN( winpos
->cy
, maxSize
.y
);
1222 /***********************************************************************
1223 * WINPOS_HandleWindowPosChanging32
1225 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1227 LONG
WINPOS_HandleWindowPosChanging32( WND
*wndPtr
, WINDOWPOS32
*winpos
)
1230 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1231 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1232 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1234 NC_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, NULL
, NULL
);
1235 winpos
->cx
= MIN( winpos
->cx
, maxSize
.x
);
1236 winpos
->cy
= MIN( winpos
->cy
, maxSize
.y
);
1242 /***********************************************************************
1243 * WINPOS_MoveWindowZOrder
1245 * Move a window in Z order, invalidating everything that needs it.
1246 * Only necessary for windows without associated X window.
1248 static void WINPOS_MoveWindowZOrder( HWND hwnd
, HWND hwndAfter
)
1251 WND
*pWndAfter
, *pWndCur
, *wndPtr
= WIN_FindWndPtr( hwnd
);
1253 /* We have two possible cases:
1254 * - The window is moving up: we have to invalidate all areas
1255 * of the window that were covered by other windows
1256 * - The window is moving down: we have to invalidate areas
1257 * of other windows covered by this one.
1260 if (hwndAfter
== HWND_TOP
)
1264 else if (hwndAfter
== HWND_BOTTOM
)
1266 if (!wndPtr
->next
) return; /* Already at the bottom */
1271 if (!(pWndAfter
= WIN_FindWndPtr( hwndAfter
))) return;
1272 if (wndPtr
->next
== pWndAfter
) return; /* Already placed right */
1274 /* Determine which window we encounter first in Z-order */
1275 pWndCur
= wndPtr
->parent
->child
;
1276 while ((pWndCur
!= wndPtr
) && (pWndCur
!= pWndAfter
))
1277 pWndCur
= pWndCur
->next
;
1278 movingUp
= (pWndCur
== pWndAfter
);
1283 WND
*pWndPrevAfter
= wndPtr
->next
;
1284 WIN_UnlinkWindow( hwnd
);
1285 WIN_LinkWindow( hwnd
, hwndAfter
);
1286 pWndCur
= wndPtr
->next
;
1287 while (pWndCur
!= pWndPrevAfter
)
1289 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1290 pWndCur
->rectWindow
.top
,
1291 pWndCur
->rectWindow
.right
,
1292 pWndCur
->rectWindow
.bottom
};
1293 OffsetRect32( &rect
, -wndPtr
->rectClient
.left
,
1294 -wndPtr
->rectClient
.top
);
1295 PAINT_RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
1296 RDW_FRAME
| RDW_ERASE
, 0 );
1297 pWndCur
= pWndCur
->next
;
1300 else /* Moving down */
1302 pWndCur
= wndPtr
->next
;
1303 WIN_UnlinkWindow( hwnd
);
1304 WIN_LinkWindow( hwnd
, hwndAfter
);
1305 while (pWndCur
!= wndPtr
)
1307 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1308 pWndCur
->rectWindow
.top
,
1309 pWndCur
->rectWindow
.right
,
1310 pWndCur
->rectWindow
.bottom
};
1311 OffsetRect32( &rect
, -pWndCur
->rectClient
.left
,
1312 -pWndCur
->rectClient
.top
);
1313 PAINT_RedrawWindow( pWndCur
->hwndSelf
, &rect
, 0, RDW_INVALIDATE
|
1314 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
1315 pWndCur
= pWndCur
->next
;
1320 /***********************************************************************
1321 * WINPOS_ReorderOwnedPopups
1323 * fix Z order taking into account owned popups -
1324 * basically we need to maintain them above owner window
1326 HWND
WINPOS_ReorderOwnedPopups(HWND hwndInsertAfter
, WND
* wndPtr
, WORD flags
)
1328 WND
* w
= WIN_GetDesktop()->child
;
1330 if( wndPtr
->dwStyle
& WS_POPUP
&& wndPtr
->owner
)
1332 /* implement "local z-order" between the top and owner window */
1334 HWND hwndLocalPrev
= HWND_TOP
;
1336 if( hwndInsertAfter
!= HWND_TOP
)
1338 while( w
!= wndPtr
->owner
)
1340 hwndLocalPrev
= w
->hwndSelf
;
1341 if( hwndLocalPrev
== hwndInsertAfter
) break;
1344 hwndInsertAfter
= hwndLocalPrev
;
1348 else if( wndPtr
->dwStyle
& WS_CHILD
) return hwndInsertAfter
;
1350 w
= WIN_GetDesktop()->child
;
1353 if( w
== wndPtr
) break;
1355 if( w
->dwStyle
& WS_POPUP
&& w
->owner
== wndPtr
)
1357 SetWindowPos(w
->hwndSelf
, hwndInsertAfter
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
|
1358 SWP_NOACTIVATE
| SWP_NOSENDCHANGING
| SWP_DEFERERASE
);
1359 hwndInsertAfter
= w
->hwndSelf
;
1364 return hwndInsertAfter
;
1367 /***********************************************************************
1368 * WINPOS_SizeMoveClean
1370 * Make window look nice without excessive repainting
1374 * visible regions are in window coordinates
1375 * update regions are in window client coordinates
1376 * client and window rectangles are in parent client coordinates
1378 static UINT
WINPOS_SizeMoveClean(WND
* Wnd
, HRGN32 oldVisRgn
, LPRECT16 lpOldWndRect
, LPRECT16 lpOldClientRect
, UINT uFlags
)
1380 HRGN32 newVisRgn
= DCE_GetVisRgn(Wnd
->hwndSelf
,DCX_WINDOW
| DCX_CLIPSIBLINGS
);
1381 HRGN32 dirtyRgn
= CreateRectRgn32(0,0,0,0);
1384 dprintf_win(stddeb
,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n\
1385 \t\tnew client=(%i %i-%i %i) old client=(%i %i-%i %i)\n",
1386 Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
, Wnd
->rectWindow
.right
, Wnd
->rectWindow
.bottom
,
1387 lpOldWndRect
->left
, lpOldWndRect
->top
, lpOldWndRect
->right
, lpOldWndRect
->bottom
,
1388 Wnd
->rectClient
.left
,Wnd
->rectClient
.top
,Wnd
->rectClient
.right
,Wnd
->rectClient
.bottom
,
1389 lpOldClientRect
->left
,lpOldClientRect
->top
,lpOldClientRect
->right
,lpOldClientRect
->bottom
);
1391 if( (lpOldWndRect
->right
- lpOldWndRect
->left
) != (Wnd
->rectWindow
.right
- Wnd
->rectWindow
.left
) ||
1392 (lpOldWndRect
->bottom
- lpOldWndRect
->top
) != (Wnd
->rectWindow
.bottom
- Wnd
->rectWindow
.top
) )
1393 uFlags
|= SMC_DRAWFRAME
;
1395 CombineRgn32( dirtyRgn
, newVisRgn
, 0, RGN_COPY
);
1397 if( !(uFlags
& SMC_NOCOPY
) )
1398 CombineRgn32( newVisRgn
, newVisRgn
, oldVisRgn
, RGN_AND
);
1400 /* map regions to the parent client area */
1402 OffsetRgn32( dirtyRgn
, Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
);
1403 OffsetRgn32( oldVisRgn
, lpOldWndRect
->left
, lpOldWndRect
->top
);
1405 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1407 other
= CombineRgn32(dirtyRgn
, oldVisRgn
, dirtyRgn
, RGN_DIFF
);
1409 /* map visible region to the Wnd client area */
1411 OffsetRgn32( newVisRgn
, Wnd
->rectWindow
.left
- Wnd
->rectClient
.left
,
1412 Wnd
->rectWindow
.top
- Wnd
->rectClient
.top
);
1414 /* substract previously invalidated region from the Wnd visible region */
1416 my
= (Wnd
->hrgnUpdate
> 1) ? CombineRgn32( newVisRgn
, newVisRgn
,
1417 Wnd
->hrgnUpdate
, RGN_DIFF
)
1420 if( uFlags
& SMC_NOCOPY
) /* invalidate Wnd visible region */
1422 if (my
!= NULLREGION
) PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, newVisRgn
, RDW_INVALIDATE
|
1423 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1425 else /* bitblt old client area */
1430 int xfrom
,yfrom
,xto
,yto
,width
,height
;
1432 if( uFlags
& SMC_DRAWFRAME
)
1434 /* copy only client area, frame will be redrawn anyway */
1436 xfrom
= lpOldClientRect
->left
; yfrom
= lpOldClientRect
->top
;
1437 xto
= Wnd
->rectClient
.left
; yto
= Wnd
->rectClient
.top
;
1438 width
= lpOldClientRect
->right
- xfrom
; height
= lpOldClientRect
->bottom
- yfrom
;
1439 updateRgn
= CreateRectRgn32( 0, 0, width
, height
);
1440 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1441 SetRectRgn( updateRgn
, 0, 0, Wnd
->rectClient
.right
- xto
, Wnd
->rectClient
.bottom
- yto
);
1445 xfrom
= lpOldWndRect
->left
; yfrom
= lpOldWndRect
->top
;
1446 xto
= Wnd
->rectWindow
.left
; yto
= Wnd
->rectWindow
.top
;
1447 width
= lpOldWndRect
->right
- xfrom
; height
= lpOldWndRect
->bottom
- yfrom
;
1448 updateRgn
= CreateRectRgn32( xto
- Wnd
->rectClient
.left
,
1449 yto
- Wnd
->rectClient
.top
,
1450 Wnd
->rectWindow
.right
- Wnd
->rectClient
.left
,
1451 Wnd
->rectWindow
.bottom
- Wnd
->rectClient
.top
);
1454 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1456 /* substract new visRgn from target rect to get a region that won't be copied */
1458 update
= CombineRgn32( updateRgn
, updateRgn
, newVisRgn
, RGN_DIFF
);
1460 /* Blt valid bits using parent window DC */
1462 if( my
!= NULLREGION
&& (xfrom
!= xto
|| yfrom
!= yto
) )
1465 /* compute clipping region in parent client coordinates */
1467 OffsetRgn32( newVisRgn
, Wnd
->rectClient
.left
, Wnd
->rectClient
.top
);
1468 CombineRgn32( oldVisRgn
, oldVisRgn
, newVisRgn
, RGN_OR
);
1470 hDC
= GetDCEx32( Wnd
->parent
->hwndSelf
, oldVisRgn
,
1471 DCX_KEEPCLIPRGN
| DCX_INTERSECTRGN
|
1472 DCX_CACHE
| DCX_CLIPSIBLINGS
);
1474 BitBlt( hDC
, xto
, yto
, width
, height
, hDC
, xfrom
, yfrom
, SRCCOPY
);
1476 ReleaseDC32( Wnd
->parent
->hwndSelf
, hDC
);
1479 if( update
!= NULLREGION
)
1480 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, updateRgn
, RDW_INVALIDATE
|
1481 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1482 else if( uFlags
& SMC_DRAWFRAME
) Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1483 DeleteObject32( updateRgn
);
1486 /* erase uncovered areas */
1488 if( !(uFlags
& SMC_NOPARENTERASE
) && (other
!= NULLREGION
) )
1489 PAINT_RedrawWindow( Wnd
->parent
->hwndSelf
, NULL
, dirtyRgn
,
1490 RDW_INVALIDATE
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1491 DeleteObject32(dirtyRgn
);
1492 DeleteObject32(newVisRgn
);
1497 /***********************************************************************
1498 * WINPOS_SetXWindowPos
1500 * SetWindowPos() for an X window. Used by the real SetWindowPos().
1502 static void WINPOS_SetXWindowPos( WINDOWPOS16
*winpos
)
1504 XWindowChanges winChanges
;
1506 WND
*wndPtr
= WIN_FindWndPtr( winpos
->hwnd
);
1508 if (!(winpos
->flags
& SWP_NOSIZE
))
1510 winChanges
.width
= winpos
->cx
;
1511 winChanges
.height
= winpos
->cy
;
1512 changeMask
|= CWWidth
| CWHeight
;
1514 /* Tweak dialog window size hints */
1516 if ((wndPtr
->flags
& WIN_MANAGED
) &&
1517 (wndPtr
->dwExStyle
& WS_EX_DLGMODALFRAME
))
1519 XSizeHints
*size_hints
= XAllocSizeHints();
1523 long supplied_return
;
1525 XGetWMSizeHints( display
, wndPtr
->window
, size_hints
,
1526 &supplied_return
, XA_WM_NORMAL_HINTS
);
1527 size_hints
->min_width
= size_hints
->max_width
= winpos
->cx
;
1528 size_hints
->min_height
= size_hints
->max_height
= winpos
->cy
;
1529 XSetWMSizeHints( display
, wndPtr
->window
, size_hints
,
1530 XA_WM_NORMAL_HINTS
);
1535 if (!(winpos
->flags
& SWP_NOMOVE
))
1537 winChanges
.x
= winpos
->x
;
1538 winChanges
.y
= winpos
->y
;
1539 changeMask
|= CWX
| CWY
;
1541 if (!(winpos
->flags
& SWP_NOZORDER
))
1543 winChanges
.stack_mode
= Below
;
1544 changeMask
|= CWStackMode
;
1546 if (winpos
->hwndInsertAfter
== HWND_TOP
) winChanges
.stack_mode
= Above
;
1547 else if (winpos
->hwndInsertAfter
!= HWND_BOTTOM
)
1549 WND
* insertPtr
= WIN_FindWndPtr( winpos
->hwndInsertAfter
);
1552 stack
[0] = insertPtr
->window
;
1553 stack
[1] = wndPtr
->window
;
1555 /* for stupid window managers (i.e. all of them) */
1557 XRestackWindows(display
, stack
, 2);
1558 changeMask
&= ~CWStackMode
;
1561 if (!changeMask
) return;
1563 XReconfigureWMWindow( display
, wndPtr
->window
, 0, changeMask
, &winChanges
);
1567 /***********************************************************************
1568 * SetWindowPos (USER.232)
1570 BOOL
SetWindowPos( HWND hwnd
, HWND hwndInsertAfter
, INT x
, INT y
,
1571 INT cx
, INT cy
, WORD flags
)
1573 WINDOWPOS16
*winpos
;
1575 RECT16 newWindowRect
, newClientRect
, oldWindowRect
;
1577 HWND tempInsertAfter
= 0;
1581 dprintf_win(stddeb
,"SetWindowPos: hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
1582 hwnd
, x
, y
, x
+cx
, y
+cy
, flags
);
1583 /* Check window handle */
1585 if (hwnd
== GetDesktopWindow32()) return FALSE
;
1586 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return FALSE
;
1588 if (wndPtr
->dwStyle
& WS_VISIBLE
) flags
&= ~SWP_SHOWWINDOW
;
1591 uFlags
|= SMC_NOPARENTERASE
;
1592 flags
&= ~SWP_HIDEWINDOW
;
1593 if (!(flags
& SWP_SHOWWINDOW
)) flags
|= SWP_NOREDRAW
;
1596 /* Check for windows that may not be resized
1597 FIXME: this should be done only for Windows 3.0 programs
1598 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
1599 flags |= SWP_NOSIZE | SWP_NOMOVE;
1601 /* Check dimensions */
1603 if (cx
<= 0) cx
= 1;
1604 if (cy
<= 0) cy
= 1;
1608 if (hwnd
== hwndActive
) flags
|= SWP_NOACTIVATE
; /* Already active */
1609 if ((wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
== cx
) &&
1610 (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
== cy
))
1611 flags
|= SWP_NOSIZE
; /* Already the right size */
1612 if ((wndPtr
->rectWindow
.left
== x
) && (wndPtr
->rectWindow
.top
== y
))
1613 flags
|= SWP_NOMOVE
; /* Already the right position */
1615 /* Check hwndInsertAfter */
1617 if (!(flags
& (SWP_NOZORDER
| SWP_NOACTIVATE
)))
1619 /* Ignore TOPMOST flags when activating a window */
1620 /* _and_ moving it in Z order. */
1621 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
1622 (hwndInsertAfter
== HWND_NOTOPMOST
))
1623 hwndInsertAfter
= HWND_TOP
;
1625 /* TOPMOST not supported yet */
1626 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
1627 (hwndInsertAfter
== HWND_NOTOPMOST
)) hwndInsertAfter
= HWND_TOP
;
1629 /* hwndInsertAfter must be a sibling of the window */
1630 if ((hwndInsertAfter
!= HWND_TOP
) && (hwndInsertAfter
!= HWND_BOTTOM
))
1632 WND
* wnd
= WIN_FindWndPtr(hwndInsertAfter
);
1633 if( wnd
->parent
!= wndPtr
->parent
) return FALSE
;
1634 if( wnd
->next
== wndPtr
) flags
|= SWP_NOZORDER
;
1637 if (hwndInsertAfter
== HWND_TOP
)
1638 flags
|= ( wndPtr
->parent
->child
== wndPtr
)? SWP_NOZORDER
: 0;
1639 else /* HWND_BOTTOM */
1640 flags
|= ( wndPtr
->next
)? 0: SWP_NOZORDER
;
1642 /* Fill the WINDOWPOS structure */
1644 if (!(winpos
= SEGPTR_NEW(WINDOWPOS16
))) return FALSE
;
1645 winpos
->hwnd
= hwnd
;
1646 winpos
->hwndInsertAfter
= hwndInsertAfter
;
1651 winpos
->flags
= flags
;
1653 /* Send WM_WINDOWPOSCHANGING message */
1655 if (!(flags
& SWP_NOSENDCHANGING
))
1656 SendMessage16( hwnd
, WM_WINDOWPOSCHANGING
, 0,
1657 (LPARAM
)SEGPTR_GET(winpos
) );
1659 /* Calculate new position and size */
1661 newWindowRect
= wndPtr
->rectWindow
;
1662 newClientRect
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? wndPtr
->rectWindow
1663 : wndPtr
->rectClient
;
1665 if (!(winpos
->flags
& SWP_NOSIZE
))
1667 newWindowRect
.right
= newWindowRect
.left
+ winpos
->cx
;
1668 newWindowRect
.bottom
= newWindowRect
.top
+ winpos
->cy
;
1670 if (!(winpos
->flags
& SWP_NOMOVE
))
1672 newWindowRect
.left
= winpos
->x
;
1673 newWindowRect
.top
= winpos
->y
;
1674 newWindowRect
.right
+= winpos
->x
- wndPtr
->rectWindow
.left
;
1675 newWindowRect
.bottom
+= winpos
->y
- wndPtr
->rectWindow
.top
;
1677 OffsetRect16( &newClientRect
, winpos
->x
- wndPtr
->rectWindow
.left
,
1678 winpos
->y
- wndPtr
->rectWindow
.top
);
1681 winpos
->flags
|= SWP_NOCLIENTMOVE
| SWP_NOCLIENTSIZE
;
1683 /* Reposition window in Z order */
1685 if (!(winpos
->flags
& SWP_NOZORDER
))
1687 /* reorder owned popups if hwnd is top-level window
1689 if( wndPtr
->parent
== WIN_GetDesktop() )
1690 hwndInsertAfter
= WINPOS_ReorderOwnedPopups( hwndInsertAfter
,
1695 WIN_UnlinkWindow( winpos
->hwnd
);
1696 WIN_LinkWindow( winpos
->hwnd
, hwndInsertAfter
);
1698 else WINPOS_MoveWindowZOrder( winpos
->hwnd
, hwndInsertAfter
);
1701 if ( !wndPtr
->window
&& !(flags
& SWP_NOREDRAW
) &&
1702 (!(flags
& SWP_NOMOVE
) || !(flags
& SWP_NOSIZE
) || (flags
& SWP_FRAMECHANGED
)) )
1703 visRgn
= DCE_GetVisRgn(hwnd
, DCX_WINDOW
| DCX_CLIPSIBLINGS
);
1706 /* Send WM_NCCALCSIZE message to get new client area */
1707 if( (flags
& (SWP_FRAMECHANGED
| SWP_NOSIZE
)) != SWP_NOSIZE
)
1709 result
= WINPOS_SendNCCalcSize( winpos
->hwnd
, TRUE
, &newWindowRect
,
1710 &wndPtr
->rectWindow
, &wndPtr
->rectClient
,
1711 SEGPTR_GET(winpos
), &newClientRect
);
1713 /* FIXME: WVR_ALIGNxxx */
1715 if( newClientRect
.left
!= wndPtr
->rectClient
.left
||
1716 newClientRect
.top
!= wndPtr
->rectClient
.top
)
1717 winpos
->flags
&= ~SWP_NOCLIENTMOVE
;
1719 if( (newClientRect
.right
- newClientRect
.left
!=
1720 wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
) ||
1721 (newClientRect
.bottom
- newClientRect
.top
!=
1722 wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
) )
1723 winpos
->flags
&= ~SWP_NOCLIENTSIZE
;
1726 if( !(flags
& SWP_NOMOVE
) && (newClientRect
.left
!= wndPtr
->rectClient
.left
||
1727 newClientRect
.top
!= wndPtr
->rectClient
.top
) )
1728 winpos
->flags
&= ~SWP_NOCLIENTMOVE
;
1730 /* Update active DCEs */
1732 if( !(flags
& SWP_NOZORDER
) || (flags
& SWP_HIDEWINDOW
) || (flags
& SWP_SHOWWINDOW
)
1733 || (memcmp(&newWindowRect
,&wndPtr
->rectWindow
,sizeof(RECT16
))
1734 && wndPtr
->dwStyle
& WS_VISIBLE
) )
1738 UnionRect16(&rect
,&newWindowRect
,&wndPtr
->rectWindow
);
1739 DCE_InvalidateDCE(wndPtr
->parent
, &rect
);
1742 /* change geometry */
1744 oldWindowRect
= wndPtr
->rectWindow
;
1748 RECT16 oldClientRect
= wndPtr
->rectClient
;
1750 tempInsertAfter
= winpos
->hwndInsertAfter
;
1752 winpos
->hwndInsertAfter
= hwndInsertAfter
;
1754 /* postpone geometry change */
1756 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
1758 WINPOS_SetXWindowPos( winpos
);
1759 winpos
->hwndInsertAfter
= tempInsertAfter
;
1761 else uFlags
|= SMC_SETXPOS
;
1763 wndPtr
->rectWindow
= newWindowRect
;
1764 wndPtr
->rectClient
= newClientRect
;
1766 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
1767 if( (oldClientRect
.left
- oldWindowRect
.left
!=
1768 newClientRect
.left
- newWindowRect
.left
) ||
1769 (oldClientRect
.top
- oldWindowRect
.top
!=
1770 newClientRect
.top
- newWindowRect
.top
) || winpos
->flags
& SWP_NOCOPYBITS
)
1772 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, RDW_INVALIDATE
|
1773 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
1775 if( winpos
->flags
& SWP_FRAMECHANGED
)
1780 if( oldClientRect
.right
> newClientRect
.right
)
1782 rect
.left
= newClientRect
.right
; rect
.top
= newClientRect
.top
;
1783 rect
.right
= oldClientRect
.right
; rect
.bottom
= newClientRect
.bottom
;
1785 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
1786 RDW_INVALIDATE
| RDW_FRAME
| RDW_ALLCHILDREN
, 0 );
1788 if( oldClientRect
.bottom
> newClientRect
.bottom
)
1790 rect
.left
= newClientRect
.left
; rect
.top
= newClientRect
.bottom
;
1791 rect
.right
= (wErase
)?oldClientRect
.right
:newClientRect
.right
;
1792 rect
.bottom
= oldClientRect
.bottom
;
1794 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
1795 RDW_INVALIDATE
| RDW_FRAME
| RDW_ALLCHILDREN
, 0 );
1797 if( !wErase
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
1802 RECT16 oldClientRect
= wndPtr
->rectClient
;
1804 wndPtr
->rectWindow
= newWindowRect
;
1805 wndPtr
->rectClient
= newClientRect
;
1807 if( oldClientRect
.bottom
- oldClientRect
.top
==
1808 newClientRect
.bottom
- newClientRect
.top
) result
&= ~WVR_VREDRAW
;
1810 if( oldClientRect
.right
- oldClientRect
.left
==
1811 newClientRect
.right
- newClientRect
.left
) result
&= ~WVR_HREDRAW
;
1813 if( !(flags
& (SWP_NOREDRAW
| SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
1815 uFlags
|= ((winpos
->flags
& SWP_NOCOPYBITS
) ||
1816 (result
>= WVR_HREDRAW
&& result
< WVR_VALIDRECTS
)) ? SMC_NOCOPY
: 0;
1817 uFlags
|= (winpos
->flags
& SWP_FRAMECHANGED
) ? SMC_DRAWFRAME
: 0;
1819 if( (winpos
->flags
& SWP_AGG_NOGEOMETRYCHANGE
) != SWP_AGG_NOGEOMETRYCHANGE
)
1820 uFlags
= WINPOS_SizeMoveClean(wndPtr
, visRgn
, &oldWindowRect
,
1821 &oldClientRect
, uFlags
);
1824 /* adjust frame and do not erase parent */
1826 if( winpos
->flags
& SWP_FRAMECHANGED
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
1827 if( winpos
->flags
& SWP_NOZORDER
) uFlags
|= SMC_NOPARENTERASE
;
1830 DeleteObject32(visRgn
);
1833 if (flags
& SWP_SHOWWINDOW
)
1835 wndPtr
->dwStyle
|= WS_VISIBLE
;
1838 if( uFlags
& SMC_SETXPOS
)
1840 WINPOS_SetXWindowPos( winpos
);
1841 winpos
->hwndInsertAfter
= tempInsertAfter
;
1843 XMapWindow( display
, wndPtr
->window
);
1847 if (!(flags
& SWP_NOREDRAW
))
1848 PAINT_RedrawWindow( winpos
->hwnd
, NULL
, 0,
1849 RDW_INVALIDATE
| RDW_ALLCHILDREN
|
1850 RDW_FRAME
| RDW_ERASENOW
| RDW_ERASE
, 0 );
1853 else if (flags
& SWP_HIDEWINDOW
)
1855 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
1858 XUnmapWindow( display
, wndPtr
->window
);
1859 if( uFlags
& SMC_SETXPOS
)
1861 WINPOS_SetXWindowPos( winpos
);
1862 winpos
->hwndInsertAfter
= tempInsertAfter
;
1867 if (!(flags
& SWP_NOREDRAW
))
1869 RECT32 rect
= { oldWindowRect
.left
, oldWindowRect
.top
,
1870 oldWindowRect
.right
, oldWindowRect
.bottom
};
1871 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, &rect
, 0,
1872 RDW_INVALIDATE
| RDW_ALLCHILDREN
| RDW_ERASE
| RDW_ERASENOW
, 0);
1874 uFlags
|= SMC_NOPARENTERASE
;
1877 if ((winpos
->hwnd
== GetFocus32()) ||
1878 IsChild( winpos
->hwnd
, GetFocus32()))
1880 /* Revert focus to parent */
1881 SetFocus32( GetParent32(winpos
->hwnd
) );
1883 if (hwnd
== CARET_GetHwnd()) DestroyCaret();
1885 if (winpos
->hwnd
== hwndActive
)
1887 /* Activate previously active window if possible */
1888 HWND newActive
= hwndPrevActive
;
1889 if (!IsWindow(newActive
) || (newActive
== winpos
->hwnd
))
1891 newActive
= GetTopWindow( GetDesktopWindow32() );
1892 if (newActive
== winpos
->hwnd
)
1893 newActive
= wndPtr
->next
? wndPtr
->next
->hwndSelf
: 0;
1895 WINPOS_ChangeActiveWindow( newActive
, FALSE
);
1899 /* Activate the window */
1901 if (!(flags
& SWP_NOACTIVATE
))
1902 WINPOS_ChangeActiveWindow( winpos
->hwnd
, FALSE
);
1904 /* Repaint the window */
1906 if (wndPtr
->window
) EVENT_Synchronize(); /* Wait for all expose events */
1908 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
1910 if (!(flags
& SWP_DEFERERASE
) && !(uFlags
& SMC_NOPARENTERASE
) )
1913 CONV_RECT16TO32( &oldWindowRect
, &rect
);
1914 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, (wndPtr
->flags
& WIN_SAVEUNDER_OVERRIDE
)
1915 ? &rect
: NULL
, 0, RDW_ALLCHILDREN
| RDW_ERASENOW
|
1916 ((wndPtr
->flags
& WIN_SAVEUNDER_OVERRIDE
) ? RDW_INVALIDATE
: 0), 0 );
1917 wndPtr
->flags
&= ~WIN_SAVEUNDER_OVERRIDE
;
1919 else if( wndPtr
->parent
== WIN_GetDesktop() && wndPtr
->parent
->flags
& WIN_NEEDS_ERASEBKGND
)
1920 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_NOCHILDREN
| RDW_ERASENOW
, 0 );
1922 /* And last, send the WM_WINDOWPOSCHANGED message */
1924 dprintf_win(stddeb
,"\tstatus flags = %04x\n", winpos
->flags
& SWP_AGG_STATUSFLAGS
);
1926 if ( ((winpos
->flags
& SWP_AGG_STATUSFLAGS
) != SWP_AGG_NOPOSCHANGE
) &&
1927 !(winpos
->flags
& SWP_NOSENDCHANGING
))
1928 SendMessage16( winpos
->hwnd
, WM_WINDOWPOSCHANGED
,
1929 0, (LPARAM
)SEGPTR_GET(winpos
) );
1931 SEGPTR_FREE(winpos
);
1936 /***********************************************************************
1937 * BeginDeferWindowPos (USER.259)
1939 HDWP16
BeginDeferWindowPos( INT count
)
1944 if (count
<= 0) return 0;
1945 handle
= USER_HEAP_ALLOC( sizeof(DWP
) + (count
-1)*sizeof(WINDOWPOS16
) );
1946 if (!handle
) return 0;
1947 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( handle
);
1948 pDWP
->actualCount
= 0;
1949 pDWP
->suggestedCount
= count
;
1951 pDWP
->wMagic
= DWP_MAGIC
;
1952 pDWP
->hwndParent
= 0;
1957 /***********************************************************************
1958 * DeferWindowPos (USER.260)
1960 HDWP16
DeferWindowPos( HDWP16 hdwp
, HWND hwnd
, HWND hwndAfter
, INT x
, INT y
,
1961 INT cx
, INT cy
, UINT flags
)
1965 HDWP16 newhdwp
= hdwp
;
1968 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
1969 if (!pDWP
) return 0;
1970 if (hwnd
== GetDesktopWindow32()) return 0;
1972 /* All the windows of a DeferWindowPos() must have the same parent */
1974 parent
= WIN_FindWndPtr( hwnd
)->parent
->hwndSelf
;
1975 if (pDWP
->actualCount
== 0) pDWP
->hwndParent
= parent
;
1976 else if (parent
!= pDWP
->hwndParent
)
1978 USER_HEAP_FREE( hdwp
);
1982 for (i
= 0; i
< pDWP
->actualCount
; i
++)
1984 if (pDWP
->winPos
[i
].hwnd
== hwnd
)
1986 /* Merge with the other changes */
1987 if (!(flags
& SWP_NOZORDER
))
1989 pDWP
->winPos
[i
].hwndInsertAfter
= hwndAfter
;
1991 if (!(flags
& SWP_NOMOVE
))
1993 pDWP
->winPos
[i
].x
= x
;
1994 pDWP
->winPos
[i
].y
= y
;
1996 if (!(flags
& SWP_NOSIZE
))
1998 pDWP
->winPos
[i
].cx
= cx
;
1999 pDWP
->winPos
[i
].cy
= cy
;
2001 pDWP
->winPos
[i
].flags
&= flags
& (SWP_NOSIZE
| SWP_NOMOVE
|
2002 SWP_NOZORDER
| SWP_NOREDRAW
|
2003 SWP_NOACTIVATE
| SWP_NOCOPYBITS
|
2005 pDWP
->winPos
[i
].flags
|= flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
|
2010 if (pDWP
->actualCount
>= pDWP
->suggestedCount
)
2012 newhdwp
= USER_HEAP_REALLOC( hdwp
,
2013 sizeof(DWP
) + pDWP
->suggestedCount
*sizeof(WINDOWPOS16
) );
2014 if (!newhdwp
) return 0;
2015 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( newhdwp
);
2016 pDWP
->suggestedCount
++;
2018 pDWP
->winPos
[pDWP
->actualCount
].hwnd
= hwnd
;
2019 pDWP
->winPos
[pDWP
->actualCount
].hwndInsertAfter
= hwndAfter
;
2020 pDWP
->winPos
[pDWP
->actualCount
].x
= x
;
2021 pDWP
->winPos
[pDWP
->actualCount
].y
= y
;
2022 pDWP
->winPos
[pDWP
->actualCount
].cx
= cx
;
2023 pDWP
->winPos
[pDWP
->actualCount
].cy
= cy
;
2024 pDWP
->winPos
[pDWP
->actualCount
].flags
= flags
;
2025 pDWP
->actualCount
++;
2030 /***********************************************************************
2031 * EndDeferWindowPos (USER.261)
2033 BOOL
EndDeferWindowPos( HDWP16 hdwp
)
2036 WINDOWPOS16
*winpos
;
2040 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2041 if (!pDWP
) return FALSE
;
2042 for (i
= 0, winpos
= pDWP
->winPos
; i
< pDWP
->actualCount
; i
++, winpos
++)
2044 if (!(res
= SetWindowPos( winpos
->hwnd
, winpos
->hwndInsertAfter
,
2045 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
,
2046 winpos
->flags
))) break;
2048 USER_HEAP_FREE( hdwp
);
2053 /***********************************************************************
2054 * TileChildWindows (USER.199)
2056 void TileChildWindows( HWND parent
, WORD action
)
2058 printf("STUB TileChildWindows(%04x, %d)\n", parent
, action
);
2061 /***********************************************************************
2062 * CascageChildWindows (USER.198)
2064 void CascadeChildWindows( HWND parent
, WORD action
)
2066 printf("STUB CascadeChildWindows(%04x, %d)\n", parent
, action
);