4 * Copyright 1998,1999 Patrik Stridvall
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(ttydrv
);
32 #define SWP_AGG_NOGEOMETRYCHANGE \
33 (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
34 #define SWP_AGG_NOPOSCHANGE \
35 (SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
36 #define SWP_AGG_STATUSFLAGS \
37 (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
39 /**********************************************************************
40 * CreateWindow (TTYDRV.@)
42 BOOL
TTYDRV_CreateWindow( HWND hwnd
, CREATESTRUCTA
*cs
, BOOL unicode
)
49 WND
*wndPtr
= WIN_GetPtr( hwnd
);
51 INT cellWidth
=8, cellHeight
=8; /* FIXME: Hardcoded */
53 TRACE("(%p)\n", hwnd
);
55 /* Only create top-level windows */
56 if (!(wndPtr
->dwStyle
& WS_CHILD
))
58 if (!wndPtr
->parent
) /* desktop */
62 int x
= wndPtr
->rectWindow
.left
;
63 int y
= wndPtr
->rectWindow
.top
;
64 int cx
= wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
;
65 int cy
= wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
;
67 window
= subwin( root_window
, cy
/cellHeight
, cx
/cellWidth
,
68 y
/cellHeight
, x
/cellWidth
);
72 wndPtr
->pDriverData
= window
;
74 WIN_ReleasePtr( wndPtr
);
75 #else /* defined(WINE_CURSES) */
76 FIXME("(%x): stub\n", hwnd
);
77 #endif /* defined(WINE_CURSES) */
79 /* Call the WH_CBT hook */
81 hwndLinkAfter
= ((cs
->style
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
82 ? HWND_BOTTOM
: HWND_TOP
;
85 cbtc
.hwndInsertAfter
= hwndLinkAfter
;
86 if (HOOK_CallHooks( WH_CBT
, HCBT_CREATEWND
, (WPARAM
)hwnd
, (LPARAM
)&cbtc
, unicode
))
88 TRACE("CBT-hook returned !0\n");
94 ret
= SendMessageW( hwnd
, WM_NCCREATE
, 0, (LPARAM
)cs
);
95 if (ret
) ret
= (SendMessageW( hwnd
, WM_CREATE
, 0, (LPARAM
)cs
) != -1);
99 ret
= SendMessageA( hwnd
, WM_NCCREATE
, 0, (LPARAM
)cs
);
100 if (ret
) ret
= (SendMessageA( hwnd
, WM_CREATE
, 0, (LPARAM
)cs
) != -1);
105 /***********************************************************************
106 * DestroyWindow (TTYDRV.@)
108 BOOL
TTYDRV_DestroyWindow( HWND hwnd
)
111 WND
*wndPtr
= WIN_GetPtr( hwnd
);
112 WINDOW
*window
= wndPtr
->pDriverData
;
114 TRACE("(%p)\n", hwnd
);
116 if (window
&& window
!= root_window
) delwin(window
);
117 wndPtr
->pDriverData
= NULL
;
118 WIN_ReleasePtr( wndPtr
);
119 #else /* defined(WINE_CURSES) */
120 FIXME("(%x): stub\n", hwnd
);
121 #endif /* defined(WINE_CURSES) */
126 /***********************************************************************
129 * Calculate the visible rectangle of a window (i.e. the client or
130 * window area clipped by the client area of all ancestors) in the
131 * corresponding coordinates. Return FALSE if the visible region is empty.
133 static BOOL
DCE_GetVisRect( WND
*wndPtr
, BOOL clientArea
, RECT
*lprect
)
135 *lprect
= clientArea
? wndPtr
->rectClient
: wndPtr
->rectWindow
;
137 if (wndPtr
->dwStyle
& WS_VISIBLE
)
139 INT xoffset
= lprect
->left
;
140 INT yoffset
= lprect
->top
;
142 while ((wndPtr
= WIN_FindWndPtr( GetAncestor(wndPtr
->hwndSelf
,GA_PARENT
) )))
144 if ( (wndPtr
->dwStyle
& (WS_ICONIC
| WS_VISIBLE
)) != WS_VISIBLE
)
146 WIN_ReleaseWndPtr(wndPtr
);
150 xoffset
+= wndPtr
->rectClient
.left
;
151 yoffset
+= wndPtr
->rectClient
.top
;
152 OffsetRect( lprect
, wndPtr
->rectClient
.left
,
153 wndPtr
->rectClient
.top
);
155 if( (wndPtr
->rectClient
.left
>= wndPtr
->rectClient
.right
) ||
156 (wndPtr
->rectClient
.top
>= wndPtr
->rectClient
.bottom
) ||
157 (lprect
->left
>= wndPtr
->rectClient
.right
) ||
158 (lprect
->right
<= wndPtr
->rectClient
.left
) ||
159 (lprect
->top
>= wndPtr
->rectClient
.bottom
) ||
160 (lprect
->bottom
<= wndPtr
->rectClient
.top
) )
162 WIN_ReleaseWndPtr(wndPtr
);
166 lprect
->left
= max( lprect
->left
, wndPtr
->rectClient
.left
);
167 lprect
->right
= min( lprect
->right
, wndPtr
->rectClient
.right
);
168 lprect
->top
= max( lprect
->top
, wndPtr
->rectClient
.top
);
169 lprect
->bottom
= min( lprect
->bottom
, wndPtr
->rectClient
.bottom
);
171 WIN_ReleaseWndPtr(wndPtr
);
173 OffsetRect( lprect
, -xoffset
, -yoffset
);
178 SetRectEmpty( lprect
);
183 /***********************************************************************
186 * Go through the linked list of windows from pWndStart to pWndEnd,
187 * adding to the clip region the intersection of the target rectangle
188 * with an offset window rectangle.
190 static void DCE_AddClipRects( HWND parent
, HWND end
, HRGN hrgnClip
, LPRECT lpRect
, int x
, int y
)
195 HWND
*list
= WIN_ListChildren( parent
);
199 for (i
= 0; list
[i
]; i
++)
201 if (list
[i
] == end
) break;
202 if (!(pWnd
= WIN_FindWndPtr( list
[i
] ))) continue;
203 if (pWnd
->dwStyle
& WS_VISIBLE
)
205 rect
.left
= pWnd
->rectWindow
.left
+ x
;
206 rect
.top
= pWnd
->rectWindow
.top
+ y
;
207 rect
.right
= pWnd
->rectWindow
.right
+ x
;
208 rect
.bottom
= pWnd
->rectWindow
.bottom
+ y
;
209 if( IntersectRect( &rect
, &rect
, lpRect
))
211 if (!hrgn
) hrgn
= CreateRectRgnIndirect( &rect
);
212 else SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
213 CombineRgn( hrgnClip
, hrgnClip
, hrgn
, RGN_OR
);
216 WIN_ReleaseWndPtr( pWnd
);
218 if (hrgn
) DeleteObject( hrgn
);
219 HeapFree( GetProcessHeap(), 0, list
);
223 /***********************************************************************
226 * Return the visible region of a window, i.e. the client or window area
227 * clipped by the client area of all ancestors, and then optionally
228 * by siblings and children.
230 static HRGN
DCE_GetVisRgn( HWND hwnd
, WORD flags
, HWND hwndChild
, WORD cflags
)
234 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
235 WND
*childWnd
= WIN_FindWndPtr( hwndChild
);
237 /* Get visible rectangle and create a region with it. */
239 if (wndPtr
&& DCE_GetVisRect(wndPtr
, !(flags
& DCX_WINDOW
), &rect
))
241 if((hrgnVis
= CreateRectRgnIndirect( &rect
)))
243 HRGN hrgnClip
= CreateRectRgn( 0, 0, 0, 0 );
244 INT xoffset
, yoffset
;
248 /* Compute obscured region for the visible rectangle by
249 * clipping children, siblings, and ancestors. Note that
250 * DCE_GetVisRect() returns a rectangle either in client
251 * or in window coordinates (for DCX_WINDOW request). */
253 if (flags
& DCX_CLIPCHILDREN
)
255 if( flags
& DCX_WINDOW
)
257 /* adjust offsets since child window rectangles are
258 * in client coordinates */
260 xoffset
= wndPtr
->rectClient
.left
- wndPtr
->rectWindow
.left
;
261 yoffset
= wndPtr
->rectClient
.top
- wndPtr
->rectWindow
.top
;
264 xoffset
= yoffset
= 0;
266 DCE_AddClipRects( wndPtr
->hwndSelf
, 0, hrgnClip
, &rect
, xoffset
, yoffset
);
269 /* We may need to clip children of child window, if a window with PARENTDC
270 * class style and CLIPCHILDREN window style (like in Free Agent 16
271 * preference dialogs) gets here, we take the region for the parent window
272 * but apparently still need to clip the children of the child window... */
274 if( (cflags
& DCX_CLIPCHILDREN
) && childWnd
)
276 if( flags
& DCX_WINDOW
)
278 /* adjust offsets since child window rectangles are
279 * in client coordinates */
281 xoffset
= wndPtr
->rectClient
.left
- wndPtr
->rectWindow
.left
;
282 yoffset
= wndPtr
->rectClient
.top
- wndPtr
->rectWindow
.top
;
285 xoffset
= yoffset
= 0;
287 /* client coordinates of child window */
288 xoffset
+= childWnd
->rectClient
.left
;
289 yoffset
+= childWnd
->rectClient
.top
;
291 DCE_AddClipRects( childWnd
->hwndSelf
, 0, hrgnClip
,
292 &rect
, xoffset
, yoffset
);
295 /* sibling window rectangles are in client
296 * coordinates of the parent window */
298 if (flags
& DCX_WINDOW
)
300 xoffset
= -wndPtr
->rectWindow
.left
;
301 yoffset
= -wndPtr
->rectWindow
.top
;
305 xoffset
= -wndPtr
->rectClient
.left
;
306 yoffset
= -wndPtr
->rectClient
.top
;
309 if (flags
& DCX_CLIPSIBLINGS
&& wndPtr
->parent
)
310 DCE_AddClipRects( wndPtr
->parent
, wndPtr
->hwndSelf
,
311 hrgnClip
, &rect
, xoffset
, yoffset
);
313 /* Clip siblings of all ancestors that have the
314 * WS_CLIPSIBLINGS style
317 while (wndPtr
->parent
)
319 WND
*ptr
= WIN_FindWndPtr( wndPtr
->parent
);
320 WIN_ReleaseWndPtr( wndPtr
);
322 xoffset
-= wndPtr
->rectClient
.left
;
323 yoffset
-= wndPtr
->rectClient
.top
;
324 if(wndPtr
->dwStyle
& WS_CLIPSIBLINGS
&& wndPtr
->parent
)
326 DCE_AddClipRects( wndPtr
->parent
, wndPtr
->hwndSelf
,
327 hrgnClip
, &rect
, xoffset
, yoffset
);
331 /* Now once we've got a jumbo clip region we have
332 * to substract it from the visible rectangle.
334 CombineRgn( hrgnVis
, hrgnVis
, hrgnClip
, RGN_DIFF
);
335 DeleteObject( hrgnClip
);
339 DeleteObject( hrgnVis
);
345 hrgnVis
= CreateRectRgn(0, 0, 0, 0); /* empty */
346 WIN_ReleaseWndPtr(wndPtr
);
347 WIN_ReleaseWndPtr(childWnd
);
352 /***********************************************************************
355 * Set the drawable, origin and dimensions for the DC associated to
358 BOOL
TTYDRV_GetDC( HWND hwnd
, HDC hdc
, HRGN hrgn
, DWORD flags
)
360 WND
*wndPtr
= WIN_FindWndPtr(hwnd
);
361 HRGN hrgnVisible
= 0;
364 if (!wndPtr
) return FALSE
;
366 if(flags
& DCX_WINDOW
)
368 org
.x
= wndPtr
->rectWindow
.left
;
369 org
.y
= wndPtr
->rectWindow
.top
;
373 org
.x
= wndPtr
->rectClient
.left
;
374 org
.y
= wndPtr
->rectClient
.top
;
377 SetDCOrg16( HDC_16(hdc
), org
.x
, org
.y
);
379 if (SetHookFlags16( HDC_16(hdc
), DCHF_VALIDATEVISRGN
)) /* DC was dirty */
381 if (flags
& DCX_PARENTCLIP
)
383 WND
*parentPtr
= WIN_FindWndPtr( wndPtr
->parent
);
385 if( wndPtr
->dwStyle
& WS_VISIBLE
&& !(parentPtr
->dwStyle
& WS_MINIMIZE
) )
389 if( parentPtr
->dwStyle
& WS_CLIPSIBLINGS
)
390 dcxFlags
= DCX_CLIPSIBLINGS
| (flags
& ~(DCX_CLIPCHILDREN
| DCX_WINDOW
));
392 dcxFlags
= flags
& ~(DCX_CLIPSIBLINGS
| DCX_CLIPCHILDREN
| DCX_WINDOW
);
394 hrgnVisible
= DCE_GetVisRgn( parentPtr
->hwndSelf
, dcxFlags
,
395 wndPtr
->hwndSelf
, flags
);
396 if( flags
& DCX_WINDOW
)
397 OffsetRgn( hrgnVisible
, -wndPtr
->rectWindow
.left
,
398 -wndPtr
->rectWindow
.top
);
400 OffsetRgn( hrgnVisible
, -wndPtr
->rectClient
.left
,
401 -wndPtr
->rectClient
.top
);
404 hrgnVisible
= CreateRectRgn( 0, 0, 0, 0 );
405 WIN_ReleaseWndPtr(parentPtr
);
409 hrgnVisible
= DCE_GetVisRgn( hwnd
, flags
, 0, 0 );
410 OffsetRgn( hrgnVisible
, org
.x
, org
.y
);
412 SelectVisRgn16( HDC_16(hdc
), HRGN_16(hrgnVisible
) );
415 /* apply additional region operation (if any) */
417 if( flags
& (DCX_EXCLUDERGN
| DCX_INTERSECTRGN
) )
419 if( !hrgnVisible
) hrgnVisible
= CreateRectRgn( 0, 0, 0, 0 );
421 TRACE("\tsaved VisRgn, clipRgn = %p\n", hrgn
);
423 SaveVisRgn16( HDC_16(hdc
) );
424 CombineRgn( hrgnVisible
, hrgn
, 0, RGN_COPY
);
425 OffsetRgn( hrgnVisible
, org
.x
, org
.y
);
426 CombineRgn( hrgnVisible
, HRGN_32(InquireVisRgn16(HDC_16(hdc
))), hrgnVisible
,
427 (flags
& DCX_INTERSECTRGN
) ? RGN_AND
: RGN_DIFF
);
428 SelectVisRgn16(HDC_16(hdc
), HRGN_16(hrgnVisible
));
431 if (hrgnVisible
) DeleteObject( hrgnVisible
);
433 WIN_ReleaseWndPtr( wndPtr
);
438 /***********************************************************************
439 * SetWindowPos (TTYDRV.@)
441 BOOL
TTYDRV_SetWindowPos( WINDOWPOS
*winpos
)
444 RECT newWindowRect
, newClientRect
;
446 HWND hwndActive
= GetForegroundWindow();
448 TRACE( "hwnd %p, swp (%i,%i)-(%i,%i) flags %08x\n",
449 winpos
->hwnd
, winpos
->x
, winpos
->y
,
450 winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
, winpos
->flags
);
452 /* ------------------------------------------------------------------------ CHECKS */
454 /* Check window handle */
456 if (winpos
->hwnd
== GetDesktopWindow()) return FALSE
;
457 if (!(wndPtr
= WIN_FindWndPtr( winpos
->hwnd
))) return FALSE
;
459 TRACE("\tcurrent (%i,%i)-(%i,%i), style %08x\n",
460 wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
,
461 wndPtr
->rectWindow
.right
, wndPtr
->rectWindow
.bottom
, (unsigned)wndPtr
->dwStyle
);
463 /* Fix redundant flags */
465 if(wndPtr
->dwStyle
& WS_VISIBLE
)
466 winpos
->flags
&= ~SWP_SHOWWINDOW
;
469 if (!(winpos
->flags
& SWP_SHOWWINDOW
)) winpos
->flags
|= SWP_NOREDRAW
;
470 winpos
->flags
&= ~SWP_HIDEWINDOW
;
473 if ( winpos
->cx
< 0 ) winpos
->cx
= 0;
474 if ( winpos
->cy
< 0 ) winpos
->cy
= 0;
476 if ((wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
== winpos
->cx
) &&
477 (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
== winpos
->cy
))
478 winpos
->flags
|= SWP_NOSIZE
; /* Already the right size */
480 if ((wndPtr
->rectWindow
.left
== winpos
->x
) && (wndPtr
->rectWindow
.top
== winpos
->y
))
481 winpos
->flags
|= SWP_NOMOVE
; /* Already the right position */
483 if (winpos
->hwnd
== hwndActive
)
484 winpos
->flags
|= SWP_NOACTIVATE
; /* Already active */
485 else if ( (wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) != WS_CHILD
)
487 if(!(winpos
->flags
& SWP_NOACTIVATE
)) /* Bring to the top when activating */
489 winpos
->flags
&= ~SWP_NOZORDER
;
490 winpos
->hwndInsertAfter
= HWND_TOP
;
495 /* Check hwndInsertAfter */
497 /* FIXME: TOPMOST not supported yet */
498 if ((winpos
->hwndInsertAfter
== HWND_TOPMOST
) ||
499 (winpos
->hwndInsertAfter
== HWND_NOTOPMOST
)) winpos
->hwndInsertAfter
= HWND_TOP
;
501 /* hwndInsertAfter must be a sibling of the window */
502 if ((winpos
->hwndInsertAfter
!= HWND_TOP
) && (winpos
->hwndInsertAfter
!= HWND_BOTTOM
))
504 WND
* wnd
= WIN_FindWndPtr(winpos
->hwndInsertAfter
);
507 if( wnd
->parent
!= wndPtr
->parent
)
510 WIN_ReleaseWndPtr(wnd
);
513 /* don't need to change the Zorder of hwnd if it's already inserted
514 * after hwndInsertAfter or when inserting hwnd after itself.
516 if ((winpos
->hwnd
== winpos
->hwndInsertAfter
) ||
517 (winpos
->hwnd
== GetWindow( winpos
->hwndInsertAfter
, GW_HWNDNEXT
)))
518 winpos
->flags
|= SWP_NOZORDER
;
520 WIN_ReleaseWndPtr(wnd
);
523 Pos
: /* ------------------------------------------------------------------------ MAIN part */
525 /* Send WM_WINDOWPOSCHANGING message */
527 if (!(winpos
->flags
& SWP_NOSENDCHANGING
))
528 SendMessageA( wndPtr
->hwndSelf
, WM_WINDOWPOSCHANGING
, 0, (LPARAM
)winpos
);
530 /* Calculate new position and size */
532 newWindowRect
= wndPtr
->rectWindow
;
533 newClientRect
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? wndPtr
->rectWindow
534 : wndPtr
->rectClient
;
536 if (!(winpos
->flags
& SWP_NOSIZE
))
538 newWindowRect
.right
= newWindowRect
.left
+ winpos
->cx
;
539 newWindowRect
.bottom
= newWindowRect
.top
+ winpos
->cy
;
541 if (!(winpos
->flags
& SWP_NOMOVE
))
543 newWindowRect
.left
= winpos
->x
;
544 newWindowRect
.top
= winpos
->y
;
545 newWindowRect
.right
+= winpos
->x
- wndPtr
->rectWindow
.left
;
546 newWindowRect
.bottom
+= winpos
->y
- wndPtr
->rectWindow
.top
;
548 OffsetRect( &newClientRect
, winpos
->x
- wndPtr
->rectWindow
.left
,
549 winpos
->y
- wndPtr
->rectWindow
.top
);
552 if( winpos
->hwndInsertAfter
== HWND_TOP
)
554 if (GetWindow( wndPtr
->hwndSelf
, GW_HWNDFIRST
) == wndPtr
->hwndSelf
)
555 winpos
->flags
|= SWP_NOZORDER
;
558 if( winpos
->hwndInsertAfter
== HWND_BOTTOM
)
560 if (!GetWindow( wndPtr
->hwndSelf
, GW_HWNDNEXT
))
561 winpos
->flags
|= SWP_NOZORDER
;
564 if( !(winpos
->flags
& SWP_NOZORDER
) )
565 if( GetWindow(winpos
->hwndInsertAfter
, GW_HWNDNEXT
) == wndPtr
->hwndSelf
)
566 winpos
->flags
|= SWP_NOZORDER
;
568 /* Common operations */
570 /* Send WM_NCCALCSIZE message to get new client area */
571 if( (winpos
->flags
& (SWP_FRAMECHANGED
| SWP_NOSIZE
)) != SWP_NOSIZE
)
573 NCCALCSIZE_PARAMS params
;
574 WINDOWPOS winposCopy
;
576 params
.rgrc
[0] = newWindowRect
;
577 params
.rgrc
[1] = wndPtr
->rectWindow
;
578 params
.rgrc
[2] = wndPtr
->rectClient
;
579 params
.lppos
= &winposCopy
;
580 winposCopy
= *winpos
;
582 SendMessageW( winpos
->hwnd
, WM_NCCALCSIZE
, TRUE
, (LPARAM
)¶ms
);
584 TRACE( "%d,%d-%d,%d\n", params
.rgrc
[0].left
, params
.rgrc
[0].top
,
585 params
.rgrc
[0].right
, params
.rgrc
[0].bottom
);
587 /* If the application send back garbage, ignore it */
588 if (params
.rgrc
[0].left
<= params
.rgrc
[0].right
&&
589 params
.rgrc
[0].top
<= params
.rgrc
[0].bottom
)
590 newClientRect
= params
.rgrc
[0];
592 /* FIXME: WVR_ALIGNxxx */
594 if( newClientRect
.left
!= wndPtr
->rectClient
.left
||
595 newClientRect
.top
!= wndPtr
->rectClient
.top
)
596 winpos
->flags
&= ~SWP_NOCLIENTMOVE
;
598 if( (newClientRect
.right
- newClientRect
.left
!=
599 wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
) ||
600 (newClientRect
.bottom
- newClientRect
.top
!=
601 wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
) )
602 winpos
->flags
&= ~SWP_NOCLIENTSIZE
;
605 if(!(winpos
->flags
& SWP_NOZORDER
) && winpos
->hwnd
!= winpos
->hwndInsertAfter
)
607 HWND parent
= GetAncestor( winpos
->hwnd
, GA_PARENT
);
608 if (parent
) WIN_LinkWindow( winpos
->hwnd
, parent
, winpos
->hwndInsertAfter
);
611 /* FIXME: actually do something with WVR_VALIDRECTS */
613 WIN_SetRectangles( winpos
->hwnd
, &newWindowRect
, &newClientRect
);
615 if( winpos
->flags
& SWP_SHOWWINDOW
)
616 WIN_SetStyle( winpos
->hwnd
, wndPtr
->dwStyle
| WS_VISIBLE
);
617 else if( winpos
->flags
& SWP_HIDEWINDOW
)
618 WIN_SetStyle( winpos
->hwnd
, wndPtr
->dwStyle
& ~WS_VISIBLE
);
620 /* ------------------------------------------------------------------------ FINAL */
622 /* repaint invalidated region (if any)
624 * FIXME: if SWP_NOACTIVATE is not set then set invalid regions here without any painting
625 * and force update after ChangeActiveWindow() to avoid painting frames twice.
628 if( !(winpos
->flags
& SWP_NOREDRAW
) )
630 RedrawWindow( wndPtr
->parent
, NULL
, 0,
631 RDW_ERASE
| RDW_INVALIDATE
| RDW_ALLCHILDREN
);
632 if (wndPtr
->parent
== GetDesktopWindow())
633 RedrawWindow( wndPtr
->parent
, NULL
, 0,
634 RDW_ERASENOW
| RDW_NOCHILDREN
);
637 if (!(winpos
->flags
& SWP_NOACTIVATE
)) SetActiveWindow( winpos
->hwnd
);
639 /* And last, send the WM_WINDOWPOSCHANGED message */
641 TRACE("\tstatus flags = %04x\n", winpos
->flags
& SWP_AGG_STATUSFLAGS
);
643 if ((((winpos
->flags
& SWP_AGG_STATUSFLAGS
) != SWP_AGG_NOPOSCHANGE
) &&
644 !(winpos
->flags
& SWP_NOSENDCHANGING
)) )
645 SendMessageA( winpos
->hwnd
, WM_WINDOWPOSCHANGED
, 0, (LPARAM
)winpos
);
649 WIN_ReleaseWndPtr(wndPtr
);
654 /***********************************************************************
655 * WINPOS_MinMaximize (internal)
657 *Lifted from x11 driver
659 static UINT
WINPOS_MinMaximize( HWND hwnd
, UINT cmd
, LPRECT rect
)
664 TRACE("%p %u\n", hwnd
, cmd
);
665 FIXME("(%p): stub\n", hwnd
);
667 wpl
.length
= sizeof(wpl
);
668 GetWindowPlacement( hwnd
, &wpl
);
670 /* If I glark this right, yields an immutable window*/
671 swpFlags
= SWP_NOSIZE
| SWP_NOMOVE
;
673 /*cmd handling goes here. see dlls/x1drv/winpos.c*/
678 /***********************************************************************
679 * ShowWindow (TTYDRV.@)
681 *Lifted from x11 driver
682 *Sets the specified windows' show state.
684 BOOL
TTYDRV_ShowWindow( HWND hwnd
, INT cmd
)
686 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
687 BOOL wasVisible
, showFlag
;
688 RECT newPos
= {0, 0, 0, 0};
691 if (!wndPtr
) return FALSE
;
692 hwnd
= wndPtr
->hwndSelf
; /* make it a full handle */
694 TRACE("hwnd=%p, cmd=%d\n", hwnd
, cmd
);
696 wasVisible
= (wndPtr
->dwStyle
& WS_VISIBLE
) != 0;
701 if (!wasVisible
) goto END
;
702 swp
|= SWP_HIDEWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
|
703 SWP_NOACTIVATE
| SWP_NOZORDER
;
706 case SW_SHOWMINNOACTIVE
:
707 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
709 case SW_SHOWMINIMIZED
:
710 swp
|= SWP_SHOWWINDOW
;
713 swp
|= SWP_FRAMECHANGED
;
714 if( !(wndPtr
->dwStyle
& WS_MINIMIZE
) )
715 swp
|= WINPOS_MinMaximize( hwnd
, SW_MINIMIZE
, &newPos
);
716 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
719 case SW_SHOWMAXIMIZED
: /* same as SW_MAXIMIZE */
720 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
721 if( !(wndPtr
->dwStyle
& WS_MAXIMIZE
) )
722 swp
|= WINPOS_MinMaximize( hwnd
, SW_MAXIMIZE
, &newPos
);
723 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
727 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
730 swp
|= SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
;
733 * ShowWindow has a little peculiar behavior that if the
734 * window is already the topmost window, it will not
737 if (GetTopWindow((HWND
)0)==hwnd
&& (wasVisible
|| GetActiveWindow() == hwnd
))
738 swp
|= SWP_NOACTIVATE
;
742 case SW_SHOWNOACTIVATE
:
744 if (GetActiveWindow()) swp
|= SWP_NOACTIVATE
;
746 case SW_SHOWNORMAL
: /* same as SW_NORMAL: */
747 case SW_SHOWDEFAULT
: /* FIXME: should have its own handler */
749 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
751 if( wndPtr
->dwStyle
& (WS_MINIMIZE
| WS_MAXIMIZE
) )
752 swp
|= WINPOS_MinMaximize( hwnd
, SW_RESTORE
, &newPos
);
753 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
757 showFlag
= (cmd
!= SW_HIDE
);
758 if (showFlag
!= wasVisible
)
760 SendMessageA( hwnd
, WM_SHOWWINDOW
, showFlag
, 0 );
761 if (!IsWindow( hwnd
)) goto END
;
764 /* We can't activate a child window */
765 if ((wndPtr
->dwStyle
& WS_CHILD
) &&
766 !(wndPtr
->dwExStyle
& WS_EX_MDICHILD
))
767 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
769 SetWindowPos( hwnd
, HWND_TOP
, newPos
.left
, newPos
.top
,
770 newPos
.right
, newPos
.bottom
, LOWORD(swp
) );
773 /* FIXME: This will cause the window to be activated irrespective
774 * of whether it is owned by the same thread. Has to be done
778 if (hwnd
== GetActiveWindow())
779 WINPOS_ActivateOtherWindow(hwnd
);
781 /* Revert focus to parent */
782 if (hwnd
== GetFocus() || IsChild(hwnd
, GetFocus()))
783 SetFocus( GetParent(hwnd
) );
785 if (!IsWindow( hwnd
)) goto END
;
786 else if( wndPtr
->dwStyle
& WS_MINIMIZE
) WINPOS_ShowIconTitle( hwnd
, TRUE
);
788 if (wndPtr
->flags
& WIN_NEED_SIZE
)
790 /* should happen only in CreateWindowEx() */
791 int wParam
= SIZE_RESTORED
;
793 wndPtr
->flags
&= ~WIN_NEED_SIZE
;
794 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wParam
= SIZE_MAXIMIZED
;
795 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= SIZE_MINIMIZED
;
796 SendMessageA( hwnd
, WM_SIZE
, wParam
,
797 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
798 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
799 SendMessageA( hwnd
, WM_MOVE
, 0,
800 MAKELONG(wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
) );
804 WIN_ReleaseWndPtr(wndPtr
);