1998-12-07 10:36:13 +01:00
|
|
|
/*
|
|
|
|
* TTY window driver
|
|
|
|
*
|
1999-02-04 14:14:42 +01:00
|
|
|
* Copyright 1998,1999 Patrik Stridvall
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1998-12-07 10:36:13 +01:00
|
|
|
*/
|
|
|
|
|
1999-11-24 00:43:29 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-12-07 10:36:13 +01:00
|
|
|
#include "ttydrv.h"
|
2005-01-19 18:02:50 +01:00
|
|
|
#include "ntstatus.h"
|
1999-02-04 14:14:42 +01:00
|
|
|
#include "win.h"
|
2001-04-25 01:28:52 +02:00
|
|
|
#include "winpos.h"
|
2002-10-25 21:00:49 +02:00
|
|
|
#include "wownt32.h"
|
2004-01-20 23:48:57 +01:00
|
|
|
#include "wine/wingdi16.h"
|
2004-09-09 02:30:29 +02:00
|
|
|
#include "wine/server.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-11-24 00:43:29 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
|
2000-08-10 03:16:19 +02:00
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
#define SWP_AGG_NOGEOMETRYCHANGE \
|
|
|
|
(SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
|
|
|
|
#define SWP_AGG_NOPOSCHANGE \
|
|
|
|
(SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
|
|
|
|
#define SWP_AGG_STATUSFLAGS \
|
|
|
|
(SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
|
1999-02-04 14:14:42 +01:00
|
|
|
|
2005-01-19 18:02:50 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* get_server_visible_region
|
|
|
|
*/
|
2005-03-17 15:02:06 +01:00
|
|
|
static HRGN get_server_visible_region( HWND hwnd, UINT flags )
|
2005-01-19 18:02:50 +01:00
|
|
|
{
|
|
|
|
RGNDATA *data;
|
|
|
|
NTSTATUS status;
|
|
|
|
HRGN ret = 0;
|
|
|
|
size_t size = 256;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!(data = HeapAlloc( GetProcessHeap(), 0, sizeof(*data) + size - 1 ))) return 0;
|
|
|
|
SERVER_START_REQ( get_visible_region )
|
|
|
|
{
|
|
|
|
req->window = hwnd;
|
|
|
|
req->flags = flags;
|
|
|
|
wine_server_set_reply( req, data->Buffer, size );
|
|
|
|
if (!(status = wine_server_call( req )))
|
|
|
|
{
|
|
|
|
size_t reply_size = wine_server_reply_size( reply );
|
|
|
|
data->rdh.dwSize = sizeof(data->rdh);
|
|
|
|
data->rdh.iType = RDH_RECTANGLES;
|
|
|
|
data->rdh.nCount = reply_size / sizeof(RECT);
|
|
|
|
data->rdh.nRgnSize = reply_size;
|
|
|
|
ret = ExtCreateRegion( NULL, size, data );
|
|
|
|
}
|
|
|
|
else size = reply->total_size;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
|
|
|
} while (status == STATUS_BUFFER_OVERFLOW);
|
|
|
|
|
|
|
|
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-09 02:30:29 +02:00
|
|
|
/***********************************************************************
|
2004-12-07 18:31:53 +01:00
|
|
|
* set_window_pos
|
2004-09-09 02:30:29 +02:00
|
|
|
*
|
2004-12-07 18:31:53 +01:00
|
|
|
* Set a window position and Z order.
|
2004-09-09 02:30:29 +02:00
|
|
|
*/
|
2005-03-23 13:00:51 +01:00
|
|
|
static BOOL set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow,
|
2005-02-03 14:40:12 +01:00
|
|
|
const RECT *rectClient, UINT swp_flags )
|
2004-09-09 02:30:29 +02:00
|
|
|
{
|
|
|
|
WND *win = WIN_GetPtr( hwnd );
|
|
|
|
BOOL ret;
|
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!win) return FALSE;
|
2004-09-09 02:30:29 +02:00
|
|
|
if (win == WND_OTHER_PROCESS)
|
|
|
|
{
|
|
|
|
if (IsWindow( hwnd )) ERR( "cannot set rectangles of other process window %p\n", hwnd );
|
2005-03-23 13:00:51 +01:00
|
|
|
return FALSE;
|
2004-09-09 02:30:29 +02:00
|
|
|
}
|
2004-12-07 18:31:53 +01:00
|
|
|
SERVER_START_REQ( set_window_pos )
|
2004-09-09 02:30:29 +02:00
|
|
|
{
|
|
|
|
req->handle = hwnd;
|
2004-12-07 18:31:53 +01:00
|
|
|
req->previous = insert_after;
|
|
|
|
req->flags = swp_flags;
|
2004-09-09 02:30:29 +02:00
|
|
|
req->window.left = rectWindow->left;
|
|
|
|
req->window.top = rectWindow->top;
|
|
|
|
req->window.right = rectWindow->right;
|
|
|
|
req->window.bottom = rectWindow->bottom;
|
|
|
|
req->client.left = rectClient->left;
|
|
|
|
req->client.top = rectClient->top;
|
|
|
|
req->client.right = rectClient->right;
|
|
|
|
req->client.bottom = rectClient->bottom;
|
|
|
|
ret = !wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2005-03-24 16:18:50 +01:00
|
|
|
if (win == WND_DESKTOP) return ret;
|
2004-09-09 02:30:29 +02:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
win->rectWindow = *rectWindow;
|
|
|
|
win->rectClient = *rectClient;
|
|
|
|
|
|
|
|
TRACE( "win %p window (%ld,%ld)-(%ld,%ld) client (%ld,%ld)-(%ld,%ld)\n", hwnd,
|
|
|
|
rectWindow->left, rectWindow->top, rectWindow->right, rectWindow->bottom,
|
|
|
|
rectClient->left, rectClient->top, rectClient->right, rectClient->bottom );
|
|
|
|
}
|
|
|
|
WIN_ReleasePtr( win );
|
2005-03-23 13:00:51 +01:00
|
|
|
return ret;
|
2004-09-09 02:30:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-02-04 14:14:42 +01:00
|
|
|
/**********************************************************************
|
2001-04-25 01:28:52 +02:00
|
|
|
* CreateWindow (TTYDRV.@)
|
1999-02-04 14:14:42 +01:00
|
|
|
*/
|
2001-06-06 23:26:50 +02:00
|
|
|
BOOL TTYDRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
|
1999-02-04 14:14:42 +01:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
BOOL ret;
|
2004-09-09 02:30:29 +02:00
|
|
|
RECT rect;
|
2005-01-19 18:02:50 +01:00
|
|
|
HWND parent, hwndLinkAfter;
|
2002-10-29 01:41:42 +01:00
|
|
|
CBT_CREATEWNDA cbtc;
|
1999-11-24 00:43:29 +01:00
|
|
|
|
2002-10-25 21:00:49 +02:00
|
|
|
TRACE("(%p)\n", hwnd);
|
1999-11-24 00:43:29 +01:00
|
|
|
|
2004-09-09 02:30:29 +02:00
|
|
|
/* initialize the dimensions before sending WM_GETMINMAXINFO */
|
|
|
|
SetRect( &rect, cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy );
|
2005-02-03 14:40:12 +01:00
|
|
|
set_window_pos( hwnd, 0, &rect, &rect, SWP_NOZORDER );
|
2004-09-09 02:30:29 +02:00
|
|
|
|
2005-01-19 18:02:50 +01:00
|
|
|
parent = GetAncestor( hwnd, GA_PARENT );
|
|
|
|
if (!parent) /* desktop window */
|
2003-04-19 23:27:19 +02:00
|
|
|
{
|
2005-01-19 18:02:50 +01:00
|
|
|
SetPropA( hwnd, "__wine_ttydrv_window", root_window );
|
2003-04-19 23:27:19 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WINE_CURSES
|
2001-04-25 01:28:52 +02:00
|
|
|
/* Only create top-level windows */
|
2005-01-19 18:02:50 +01:00
|
|
|
if (parent == GetDesktopWindow())
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2003-04-19 23:27:19 +02:00
|
|
|
WINDOW *window;
|
|
|
|
const INT cellWidth=8, cellHeight=8; /* FIXME: Hardcoded */
|
|
|
|
|
2005-01-19 18:02:50 +01:00
|
|
|
window = subwin( root_window, cs->cy/cellHeight, cs->cx/cellWidth,
|
|
|
|
cs->y/cellHeight, cs->x/cellWidth);
|
2003-04-19 23:27:19 +02:00
|
|
|
werase(window);
|
|
|
|
wrefresh(window);
|
2005-01-19 18:02:50 +01:00
|
|
|
SetPropA( hwnd, "__wine_ttydrv_window", window );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2000-03-30 21:26:44 +02:00
|
|
|
#else /* defined(WINE_CURSES) */
|
2003-11-09 01:30:50 +01:00
|
|
|
FIXME("(%p): stub\n", hwnd);
|
2000-03-30 21:26:44 +02:00
|
|
|
#endif /* defined(WINE_CURSES) */
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2002-01-09 20:09:06 +01:00
|
|
|
/* Call the WH_CBT hook */
|
|
|
|
|
2003-04-19 23:27:19 +02:00
|
|
|
hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD) ? HWND_BOTTOM : HWND_TOP;
|
2002-01-09 20:09:06 +01:00
|
|
|
|
2002-10-29 01:41:42 +01:00
|
|
|
cbtc.lpcs = cs;
|
|
|
|
cbtc.hwndInsertAfter = hwndLinkAfter;
|
|
|
|
if (HOOK_CallHooks( WH_CBT, HCBT_CREATEWND, (WPARAM)hwnd, (LPARAM)&cbtc, unicode ))
|
2002-01-09 20:09:06 +01:00
|
|
|
{
|
2002-10-29 01:41:42 +01:00
|
|
|
TRACE("CBT-hook returned !0\n");
|
|
|
|
return FALSE;
|
2002-01-09 20:09:06 +01:00
|
|
|
}
|
|
|
|
|
2001-06-06 23:26:50 +02:00
|
|
|
if (unicode)
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
|
|
|
ret = SendMessageW( hwnd, WM_NCCREATE, 0, (LPARAM)cs );
|
|
|
|
if (ret) ret = (SendMessageW( hwnd, WM_CREATE, 0, (LPARAM)cs ) != -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = SendMessageA( hwnd, WM_NCCREATE, 0, (LPARAM)cs );
|
|
|
|
if (ret) ret = (SendMessageA( hwnd, WM_CREATE, 0, (LPARAM)cs ) != -1);
|
|
|
|
}
|
2005-02-03 17:40:20 +01:00
|
|
|
if (ret) NotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_WINDOW, 0);
|
2001-06-04 23:55:17 +02:00
|
|
|
return ret;
|
1999-02-04 14:14:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-04-25 01:28:52 +02:00
|
|
|
* DestroyWindow (TTYDRV.@)
|
1999-02-04 14:14:42 +01:00
|
|
|
*/
|
2001-04-25 01:28:52 +02:00
|
|
|
BOOL TTYDRV_DestroyWindow( HWND hwnd )
|
1999-02-04 14:14:42 +01:00
|
|
|
{
|
2000-03-30 21:26:44 +02:00
|
|
|
#ifdef WINE_CURSES
|
2005-01-19 18:02:50 +01:00
|
|
|
WINDOW *window = GetPropA( hwnd, "__wine_ttydrv_window" );
|
1999-11-24 00:43:29 +01:00
|
|
|
|
2002-10-25 21:00:49 +02:00
|
|
|
TRACE("(%p)\n", hwnd);
|
1999-11-24 00:43:29 +01:00
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
if (window && window != root_window) delwin(window);
|
2000-03-30 21:26:44 +02:00
|
|
|
#else /* defined(WINE_CURSES) */
|
2003-11-09 01:30:50 +01:00
|
|
|
FIXME("(%p): stub\n", hwnd);
|
2000-03-30 21:26:44 +02:00
|
|
|
#endif /* defined(WINE_CURSES) */
|
2001-04-25 01:28:52 +02:00
|
|
|
return TRUE;
|
1999-02-04 14:14:42 +01:00
|
|
|
}
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2000-07-29 01:04:54 +02:00
|
|
|
/***********************************************************************
|
2001-04-25 01:28:52 +02:00
|
|
|
* GetDC (TTYDRV.@)
|
|
|
|
*
|
|
|
|
* Set the drawable, origin and dimensions for the DC associated to
|
|
|
|
* a given window.
|
2000-07-29 01:04:54 +02:00
|
|
|
*/
|
2001-04-25 01:28:52 +02:00
|
|
|
BOOL TTYDRV_GetDC( HWND hwnd, HDC hdc, HRGN hrgn, DWORD flags )
|
2000-07-29 01:04:54 +02:00
|
|
|
{
|
2004-12-09 12:45:16 +01:00
|
|
|
struct ttydrv_escape_set_drawable escape;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
if(flags & DCX_WINDOW)
|
|
|
|
{
|
2005-01-19 18:02:50 +01:00
|
|
|
RECT rect;
|
|
|
|
GetWindowRect( hwnd, &rect );
|
|
|
|
escape.org.x = rect.left;
|
|
|
|
escape.org.y = rect.top;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-19 18:02:50 +01:00
|
|
|
escape.org.x = escape.org.y = 0;
|
|
|
|
MapWindowPoints( hwnd, 0, &escape.org, 1 );
|
2002-05-07 04:08:46 +02:00
|
|
|
}
|
|
|
|
|
2004-12-09 12:45:16 +01:00
|
|
|
escape.code = TTYDRV_SET_DRAWABLE;
|
|
|
|
ExtEscape( hdc, TTYDRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-01-19 18:02:50 +01:00
|
|
|
if (flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN) ||
|
|
|
|
SetHookFlags16( HDC_16(hdc), DCHF_VALIDATEVISRGN )) /* DC was dirty */
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2005-01-19 18:02:50 +01:00
|
|
|
/* need to recompute the visible region */
|
2005-03-17 15:02:06 +01:00
|
|
|
HRGN visRgn = get_server_visible_region( hwnd, flags );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-01-19 18:02:50 +01:00
|
|
|
if (flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN))
|
|
|
|
CombineRgn( visRgn, visRgn, hrgn, (flags & DCX_INTERSECTRGN) ? RGN_AND : RGN_DIFF );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-01-19 18:02:50 +01:00
|
|
|
SelectVisRgn16( HDC_16(hdc), HRGN_16(visRgn) );
|
|
|
|
DeleteObject( visRgn );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
2000-07-29 01:04:54 +02:00
|
|
|
}
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
/* fix redundant flags and values in the WINDOWPOS structure */
|
|
|
|
static BOOL fixup_flags( WINDOWPOS *winpos )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
HWND parent;
|
|
|
|
WND *wndPtr = WIN_GetPtr( winpos->hwnd );
|
|
|
|
BOOL ret = TRUE;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!wndPtr || wndPtr == WND_OTHER_PROCESS)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
winpos->hwnd = wndPtr->hwndSelf; /* make it a full handle */
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
/* Finally make sure that all coordinates are valid */
|
|
|
|
if (winpos->x < -32768) winpos->x = -32768;
|
|
|
|
else if (winpos->x > 32767) winpos->x = 32767;
|
|
|
|
if (winpos->y < -32768) winpos->y = -32768;
|
|
|
|
else if (winpos->y > 32767) winpos->y = 32767;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (winpos->cx < 0) winpos->cx = 0;
|
|
|
|
else if (winpos->cx > 32767) winpos->cx = 32767;
|
|
|
|
if (winpos->cy < 0) winpos->cy = 0;
|
|
|
|
else if (winpos->cy > 32767) winpos->cy = 32767;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
parent = GetAncestor( winpos->hwnd, GA_PARENT );
|
|
|
|
if (!IsWindowVisible( parent )) winpos->flags |= SWP_NOREDRAW;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (wndPtr->dwStyle & WS_VISIBLE) winpos->flags &= ~SWP_SHOWWINDOW;
|
2001-04-25 01:28:52 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
winpos->flags &= ~SWP_HIDEWINDOW;
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!(winpos->flags & SWP_SHOWWINDOW)) winpos->flags |= SWP_NOREDRAW;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((wndPtr->rectWindow.right - wndPtr->rectWindow.left == winpos->cx) &&
|
|
|
|
(wndPtr->rectWindow.bottom - wndPtr->rectWindow.top == winpos->cy))
|
|
|
|
winpos->flags |= SWP_NOSIZE; /* Already the right size */
|
|
|
|
|
|
|
|
if ((wndPtr->rectWindow.left == winpos->x) && (wndPtr->rectWindow.top == winpos->y))
|
|
|
|
winpos->flags |= SWP_NOMOVE; /* Already the right position */
|
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!(winpos->flags & (SWP_NOACTIVATE|SWP_HIDEWINDOW))) /* Bring to the top when activating */
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
|
|
|
winpos->flags &= ~SWP_NOZORDER;
|
|
|
|
winpos->hwndInsertAfter = HWND_TOP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check hwndInsertAfter */
|
2005-03-23 13:00:51 +01:00
|
|
|
if (winpos->flags & SWP_NOZORDER) goto done;
|
|
|
|
|
|
|
|
/* fix sign extension */
|
|
|
|
if (winpos->hwndInsertAfter == (HWND)0xffff) winpos->hwndInsertAfter = HWND_TOPMOST;
|
|
|
|
else if (winpos->hwndInsertAfter == (HWND)0xfffe) winpos->hwndInsertAfter = HWND_NOTOPMOST;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
/* FIXME: TOPMOST not supported yet */
|
|
|
|
if ((winpos->hwndInsertAfter == HWND_TOPMOST) ||
|
|
|
|
(winpos->hwndInsertAfter == HWND_NOTOPMOST)) winpos->hwndInsertAfter = HWND_TOP;
|
|
|
|
|
|
|
|
/* hwndInsertAfter must be a sibling of the window */
|
2005-03-23 13:00:51 +01:00
|
|
|
if (winpos->hwndInsertAfter == HWND_TOP)
|
|
|
|
{
|
|
|
|
if (GetWindow(winpos->hwnd, GW_HWNDFIRST) == winpos->hwnd)
|
|
|
|
winpos->flags |= SWP_NOZORDER;
|
|
|
|
}
|
|
|
|
else if (winpos->hwndInsertAfter == HWND_BOTTOM)
|
|
|
|
{
|
|
|
|
if (GetWindow(winpos->hwnd, GW_HWNDLAST) == winpos->hwnd)
|
|
|
|
winpos->flags |= SWP_NOZORDER;
|
|
|
|
}
|
|
|
|
else
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
if (GetAncestor( winpos->hwndInsertAfter, GA_PARENT ) != parent) ret = FALSE;
|
|
|
|
else
|
2005-01-19 18:02:50 +01:00
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
/* don't need to change the Zorder of hwnd if it's already inserted
|
|
|
|
* after hwndInsertAfter or when inserting hwnd after itself.
|
|
|
|
*/
|
|
|
|
if ((winpos->hwnd == winpos->hwndInsertAfter) ||
|
|
|
|
(winpos->hwnd == GetWindow( winpos->hwndInsertAfter, GW_HWNDNEXT )))
|
|
|
|
winpos->flags |= SWP_NOZORDER;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
}
|
2005-03-23 13:00:51 +01:00
|
|
|
done:
|
|
|
|
WIN_ReleasePtr( wndPtr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SWP_DoNCCalcSize
|
|
|
|
*/
|
|
|
|
static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RECT* pNewClientRect )
|
|
|
|
{
|
|
|
|
UINT wvrFlags = 0;
|
|
|
|
WND *wndPtr;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!(wndPtr = WIN_GetPtr( pWinpos->hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
/* Send WM_NCCALCSIZE message to get new client area */
|
|
|
|
if( (pWinpos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE )
|
|
|
|
{
|
|
|
|
NCCALCSIZE_PARAMS params;
|
|
|
|
WINDOWPOS winposCopy;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
params.rgrc[0] = *pNewWindowRect;
|
|
|
|
params.rgrc[1] = wndPtr->rectWindow;
|
|
|
|
params.rgrc[2] = wndPtr->rectClient;
|
|
|
|
params.lppos = &winposCopy;
|
|
|
|
winposCopy = *pWinpos;
|
|
|
|
WIN_ReleasePtr( wndPtr );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
wvrFlags = SendMessageW( pWinpos->hwnd, WM_NCCALCSIZE, TRUE, (LPARAM)¶ms );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
*pNewClientRect = params.rgrc[0];
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!(wndPtr = WIN_GetPtr( pWinpos->hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
|
|
|
|
|
|
|
|
TRACE( "hwnd %p old win %s old client %s new win %s new client %s\n", pWinpos->hwnd,
|
|
|
|
wine_dbgstr_rect(&wndPtr->rectWindow), wine_dbgstr_rect(&wndPtr->rectClient),
|
|
|
|
wine_dbgstr_rect(pNewWindowRect), wine_dbgstr_rect(pNewClientRect) );
|
|
|
|
|
|
|
|
if( pNewClientRect->left != wndPtr->rectClient.left ||
|
|
|
|
pNewClientRect->top != wndPtr->rectClient.top )
|
|
|
|
pWinpos->flags &= ~SWP_NOCLIENTMOVE;
|
|
|
|
|
|
|
|
if( (pNewClientRect->right - pNewClientRect->left !=
|
|
|
|
wndPtr->rectClient.right - wndPtr->rectClient.left))
|
|
|
|
pWinpos->flags &= ~SWP_NOCLIENTSIZE;
|
|
|
|
else
|
|
|
|
wvrFlags &= ~WVR_HREDRAW;
|
|
|
|
|
|
|
|
if (pNewClientRect->bottom - pNewClientRect->top !=
|
|
|
|
wndPtr->rectClient.bottom - wndPtr->rectClient.top)
|
|
|
|
pWinpos->flags &= ~SWP_NOCLIENTSIZE;
|
|
|
|
else
|
|
|
|
wvrFlags &= ~WVR_VREDRAW;
|
|
|
|
}
|
|
|
|
else
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!(pWinpos->flags & SWP_NOMOVE) &&
|
|
|
|
(pNewClientRect->left != wndPtr->rectClient.left ||
|
|
|
|
pNewClientRect->top != wndPtr->rectClient.top))
|
|
|
|
pWinpos->flags &= ~SWP_NOCLIENTMOVE;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2005-03-23 13:00:51 +01:00
|
|
|
|
|
|
|
WIN_ReleasePtr( wndPtr );
|
|
|
|
return wvrFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SWP_DoOwnedPopups
|
|
|
|
*
|
|
|
|
* fix Z order taking into account owned popups -
|
|
|
|
* basically we need to maintain them above the window that owns them
|
|
|
|
*
|
|
|
|
* FIXME: hide/show owned popups when owner visibility changes.
|
|
|
|
*/
|
|
|
|
static HWND SWP_DoOwnedPopups(HWND hwnd, HWND hwndInsertAfter)
|
|
|
|
{
|
|
|
|
HWND *list = NULL;
|
|
|
|
HWND owner = GetWindow( hwnd, GW_OWNER );
|
|
|
|
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
|
|
|
|
WARN("(%p) hInsertAfter = %p\n", hwnd, hwndInsertAfter );
|
|
|
|
|
|
|
|
if ((style & WS_POPUP) && owner)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
/* make sure this popup stays above the owner */
|
|
|
|
|
|
|
|
HWND hwndLocalPrev = HWND_TOP;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if( hwndInsertAfter != HWND_TOP )
|
|
|
|
{
|
|
|
|
if ((list = WIN_ListChildren( GetDesktopWindow() )))
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; list[i]; i++)
|
|
|
|
{
|
|
|
|
if (list[i] == owner) break;
|
|
|
|
if (list[i] != hwnd) hwndLocalPrev = list[i];
|
|
|
|
if (hwndLocalPrev == hwndInsertAfter) break;
|
|
|
|
}
|
|
|
|
hwndInsertAfter = hwndLocalPrev;
|
|
|
|
}
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2005-03-23 13:00:51 +01:00
|
|
|
else if (style & WS_CHILD) return hwndInsertAfter;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!list) list = WIN_ListChildren( GetDesktopWindow() );
|
|
|
|
if (list)
|
2001-10-10 22:28:17 +02:00
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
int i;
|
|
|
|
for (i = 0; list[i]; i++)
|
2001-10-11 22:49:40 +02:00
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
if (list[i] == hwnd) break;
|
|
|
|
if ((GetWindowLongW( list[i], GWL_STYLE ) & WS_POPUP) &&
|
|
|
|
GetWindow( list[i], GW_OWNER ) == hwnd)
|
|
|
|
{
|
|
|
|
SetWindowPos( list[i], hwndInsertAfter, 0, 0, 0, 0,
|
|
|
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE |
|
|
|
|
SWP_NOSENDCHANGING | SWP_DEFERERASE );
|
|
|
|
hwndInsertAfter = list[i];
|
|
|
|
}
|
2001-10-11 22:49:40 +02:00
|
|
|
}
|
2005-03-23 13:00:51 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, list );
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
return hwndInsertAfter;
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SWP_DoWinPosChanging
|
|
|
|
*/
|
|
|
|
static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT* pNewClientRect )
|
|
|
|
{
|
|
|
|
WND *wndPtr;
|
2001-10-16 23:58:58 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
/* Send WM_WINDOWPOSCHANGING message */
|
2001-10-16 23:58:58 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!(pWinpos->flags & SWP_NOSENDCHANGING))
|
|
|
|
SendMessageW( pWinpos->hwnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)pWinpos );
|
2001-10-16 23:58:58 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!(wndPtr = WIN_GetPtr( pWinpos->hwnd )) || wndPtr == WND_OTHER_PROCESS) return FALSE;
|
2001-10-16 23:58:58 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
/* Calculate new position and size */
|
2001-10-16 23:58:58 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
*pNewWindowRect = wndPtr->rectWindow;
|
|
|
|
*pNewClientRect = (wndPtr->dwStyle & WS_MINIMIZE) ? wndPtr->rectWindow
|
|
|
|
: wndPtr->rectClient;
|
2001-10-16 23:58:58 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!(pWinpos->flags & SWP_NOSIZE))
|
|
|
|
{
|
|
|
|
pNewWindowRect->right = pNewWindowRect->left + pWinpos->cx;
|
|
|
|
pNewWindowRect->bottom = pNewWindowRect->top + pWinpos->cy;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!(pWinpos->flags & SWP_NOMOVE))
|
|
|
|
{
|
|
|
|
pNewWindowRect->left = pWinpos->x;
|
|
|
|
pNewWindowRect->top = pWinpos->y;
|
|
|
|
pNewWindowRect->right += pWinpos->x - wndPtr->rectWindow.left;
|
|
|
|
pNewWindowRect->bottom += pWinpos->y - wndPtr->rectWindow.top;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
OffsetRect( pNewClientRect, pWinpos->x - wndPtr->rectWindow.left,
|
|
|
|
pWinpos->y - wndPtr->rectWindow.top );
|
|
|
|
}
|
|
|
|
pWinpos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
TRACE( "hwnd %p, after %p, swp %d,%d %dx%d flags %08x\n",
|
|
|
|
pWinpos->hwnd, pWinpos->hwndInsertAfter, pWinpos->x, pWinpos->y,
|
|
|
|
pWinpos->cx, pWinpos->cy, pWinpos->flags );
|
|
|
|
TRACE( "current %s style %08lx new %s\n",
|
|
|
|
wine_dbgstr_rect( &wndPtr->rectWindow ), wndPtr->dwStyle,
|
|
|
|
wine_dbgstr_rect( pNewWindowRect ));
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
WIN_ReleasePtr( wndPtr );
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetWindowPos (TTYDRV.@)
|
|
|
|
*/
|
|
|
|
BOOL TTYDRV_SetWindowPos( WINDOWPOS *winpos )
|
|
|
|
{
|
|
|
|
RECT newWindowRect, newClientRect;
|
|
|
|
UINT orig_flags;
|
|
|
|
|
|
|
|
TRACE( "hwnd %p, after %p, swp %d,%d %dx%d flags %08x\n",
|
|
|
|
winpos->hwnd, winpos->hwndInsertAfter, winpos->x, winpos->y,
|
|
|
|
winpos->cx, winpos->cy, winpos->flags);
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
orig_flags = winpos->flags;
|
|
|
|
winpos->flags &= ~SWP_WINE_NOHOSTMOVE;
|
|
|
|
|
|
|
|
/* Check window handle */
|
|
|
|
if (winpos->hwnd == GetDesktopWindow()) return FALSE;
|
|
|
|
|
|
|
|
/* First make sure that coordinates are valid for WM_WINDOWPOSCHANGING */
|
|
|
|
if (!(winpos->flags & SWP_NOMOVE))
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
if (winpos->x < -32768) winpos->x = -32768;
|
|
|
|
else if (winpos->x > 32767) winpos->x = 32767;
|
|
|
|
if (winpos->y < -32768) winpos->y = -32768;
|
|
|
|
else if (winpos->y > 32767) winpos->y = 32767;
|
|
|
|
}
|
|
|
|
if (!(winpos->flags & SWP_NOSIZE))
|
|
|
|
{
|
|
|
|
if (winpos->cx < 0) winpos->cx = 0;
|
|
|
|
else if (winpos->cx > 32767) winpos->cx = 32767;
|
|
|
|
if (winpos->cy < 0) winpos->cy = 0;
|
|
|
|
else if (winpos->cy > 32767) winpos->cy = 32767;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SWP_DoWinPosChanging( winpos, &newWindowRect, &newClientRect )) return FALSE;
|
|
|
|
|
|
|
|
/* Fix redundant flags */
|
|
|
|
if (!fixup_flags( winpos )) return FALSE;
|
|
|
|
|
|
|
|
if((winpos->flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) != SWP_NOZORDER)
|
|
|
|
{
|
|
|
|
if (GetAncestor( winpos->hwnd, GA_PARENT ) == GetDesktopWindow())
|
|
|
|
winpos->hwndInsertAfter = SWP_DoOwnedPopups( winpos->hwnd, winpos->hwndInsertAfter );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
/* Common operations */
|
|
|
|
|
|
|
|
SWP_DoNCCalcSize( winpos, &newWindowRect, &newClientRect );
|
|
|
|
|
|
|
|
if (!set_window_pos( winpos->hwnd, winpos->hwndInsertAfter,
|
|
|
|
&newWindowRect, &newClientRect, orig_flags ))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if( winpos->flags & SWP_HIDEWINDOW )
|
|
|
|
HideCaret(winpos->hwnd);
|
|
|
|
else if (winpos->flags & SWP_SHOWWINDOW)
|
|
|
|
ShowCaret(winpos->hwnd);
|
|
|
|
|
|
|
|
if (!(winpos->flags & (SWP_NOACTIVATE|SWP_HIDEWINDOW)))
|
|
|
|
{
|
|
|
|
/* child windows get WM_CHILDACTIVATE message */
|
|
|
|
if ((GetWindowLongW( winpos->hwnd, GWL_STYLE ) & (WS_CHILD | WS_POPUP)) == WS_CHILD)
|
|
|
|
SendMessageA( winpos->hwnd, WM_CHILDACTIVATE, 0, 0 );
|
|
|
|
else
|
|
|
|
SetForegroundWindow( winpos->hwnd );
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
/* And last, send the WM_WINDOWPOSCHANGED message */
|
|
|
|
|
|
|
|
TRACE("\tstatus flags = %04x\n", winpos->flags & SWP_AGG_STATUSFLAGS);
|
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (((winpos->flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE))
|
|
|
|
{
|
|
|
|
/* WM_WINDOWPOSCHANGED is sent even if SWP_NOSENDCHANGING is set
|
|
|
|
and always contains final window position.
|
|
|
|
*/
|
|
|
|
winpos->x = newWindowRect.left;
|
|
|
|
winpos->y = newWindowRect.top;
|
|
|
|
winpos->cx = newWindowRect.right - newWindowRect.left;
|
|
|
|
winpos->cy = newWindowRect.bottom - newWindowRect.top;
|
|
|
|
SendMessageW( winpos->hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)winpos );
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
return TRUE;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2001-12-13 01:54:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WINPOS_MinMaximize (internal)
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
*Lifted from x11 driver
|
2001-12-13 01:54:52 +01:00
|
|
|
*/
|
|
|
|
static UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
|
|
|
|
{
|
|
|
|
UINT swpFlags = 0;
|
|
|
|
WINDOWPLACEMENT wpl;
|
|
|
|
|
2002-10-25 21:00:49 +02:00
|
|
|
TRACE("%p %u\n", hwnd, cmd );
|
|
|
|
FIXME("(%p): stub\n", hwnd);
|
2001-12-13 01:54:52 +01:00
|
|
|
|
|
|
|
wpl.length = sizeof(wpl);
|
|
|
|
GetWindowPlacement( hwnd, &wpl );
|
|
|
|
|
|
|
|
/* If I glark this right, yields an immutable window*/
|
|
|
|
swpFlags = SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
|
|
|
|
/*cmd handling goes here. see dlls/x1drv/winpos.c*/
|
|
|
|
|
|
|
|
return swpFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ShowWindow (TTYDRV.@)
|
|
|
|
*
|
|
|
|
*Lifted from x11 driver
|
2002-06-01 01:06:46 +02:00
|
|
|
*Sets the specified windows' show state.
|
2001-12-13 01:54:52 +01:00
|
|
|
*/
|
|
|
|
BOOL TTYDRV_ShowWindow( HWND hwnd, INT cmd )
|
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
WND *wndPtr;
|
|
|
|
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
BOOL wasVisible = (style & WS_VISIBLE) != 0;
|
|
|
|
BOOL showFlag = TRUE;
|
|
|
|
RECT newPos = {0, 0, 0, 0};
|
|
|
|
UINT swp = 0;
|
2001-12-13 01:54:52 +01:00
|
|
|
|
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
TRACE("hwnd=%p, cmd=%d, wasVisible %d\n", hwnd, cmd, wasVisible);
|
2001-12-13 01:54:52 +01:00
|
|
|
|
|
|
|
switch(cmd)
|
|
|
|
{
|
|
|
|
case SW_HIDE:
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!wasVisible) return FALSE;
|
|
|
|
showFlag = FALSE;
|
|
|
|
swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER;
|
2001-12-13 01:54:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SW_SHOWMINNOACTIVE:
|
|
|
|
swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
|
|
|
/* fall through */
|
|
|
|
case SW_SHOWMINIMIZED:
|
2005-03-23 13:00:51 +01:00
|
|
|
case SW_FORCEMINIMIZE: /* FIXME: Does not work if thread is hung. */
|
2001-12-13 01:54:52 +01:00
|
|
|
swp |= SWP_SHOWWINDOW;
|
|
|
|
/* fall through */
|
|
|
|
case SW_MINIMIZE:
|
|
|
|
swp |= SWP_FRAMECHANGED;
|
2005-03-23 13:00:51 +01:00
|
|
|
if( !(style & WS_MINIMIZE) )
|
2001-12-13 01:54:52 +01:00
|
|
|
swp |= WINPOS_MinMaximize( hwnd, SW_MINIMIZE, &newPos );
|
|
|
|
else swp |= SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
|
|
|
|
swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
|
2005-03-23 13:00:51 +01:00
|
|
|
if( !(style & WS_MAXIMIZE) )
|
2001-12-13 01:54:52 +01:00
|
|
|
swp |= WINPOS_MinMaximize( hwnd, SW_MAXIMIZE, &newPos );
|
|
|
|
else swp |= SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SW_SHOWNA:
|
2005-03-23 13:00:51 +01:00
|
|
|
swp |= SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
if (style & WS_CHILD) swp |= SWP_NOZORDER;
|
|
|
|
break;
|
2001-12-13 01:54:52 +01:00
|
|
|
case SW_SHOW:
|
2005-03-23 13:00:51 +01:00
|
|
|
if (wasVisible) return TRUE;
|
2001-12-13 01:54:52 +01:00
|
|
|
swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
break;
|
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
case SW_RESTORE:
|
|
|
|
swp |= SWP_FRAMECHANGED;
|
|
|
|
/* fall through */
|
2001-12-13 01:54:52 +01:00
|
|
|
case SW_SHOWNOACTIVATE:
|
2005-03-23 13:00:51 +01:00
|
|
|
swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
2001-12-13 01:54:52 +01:00
|
|
|
/* fall through */
|
|
|
|
case SW_SHOWNORMAL: /* same as SW_NORMAL: */
|
|
|
|
case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
|
2005-03-23 13:00:51 +01:00
|
|
|
swp |= SWP_SHOWWINDOW;
|
2001-12-13 01:54:52 +01:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (style & (WS_MINIMIZE | WS_MAXIMIZE))
|
2001-12-13 01:54:52 +01:00
|
|
|
swp |= WINPOS_MinMaximize( hwnd, SW_RESTORE, &newPos );
|
|
|
|
else swp |= SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (showFlag != wasVisible || cmd == SW_SHOWNA)
|
2001-12-13 01:54:52 +01:00
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
SendMessageW( hwnd, WM_SHOWWINDOW, showFlag, 0 );
|
|
|
|
if (!IsWindow( hwnd )) return wasVisible;
|
2001-12-13 01:54:52 +01:00
|
|
|
}
|
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
/* ShowWindow won't activate a not being maximized child window */
|
|
|
|
if ((style & WS_CHILD) && cmd != SW_MAXIMIZE)
|
2001-12-13 01:54:52 +01:00
|
|
|
swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
|
|
|
|
|
|
|
SetWindowPos( hwnd, HWND_TOP, newPos.left, newPos.top,
|
|
|
|
newPos.right, newPos.bottom, LOWORD(swp) );
|
|
|
|
if (cmd == SW_HIDE)
|
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
HWND hFocus;
|
|
|
|
|
2001-12-13 01:54:52 +01:00
|
|
|
/* FIXME: This will cause the window to be activated irrespective
|
|
|
|
* of whether it is owned by the same thread. Has to be done
|
|
|
|
* asynchronously.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (hwnd == GetActiveWindow())
|
|
|
|
WINPOS_ActivateOtherWindow(hwnd);
|
|
|
|
|
|
|
|
/* Revert focus to parent */
|
2005-03-23 13:00:51 +01:00
|
|
|
hFocus = GetFocus();
|
|
|
|
if (hwnd == hFocus || IsChild(hwnd, hFocus))
|
|
|
|
{
|
|
|
|
HWND parent = GetAncestor(hwnd, GA_PARENT);
|
|
|
|
if (parent == GetDesktopWindow()) parent = 0;
|
|
|
|
SetFocus(parent);
|
|
|
|
}
|
2001-12-13 01:54:52 +01:00
|
|
|
}
|
2005-03-23 13:00:51 +01:00
|
|
|
|
|
|
|
if (IsIconic(hwnd)) WINPOS_ShowIconTitle( hwnd, TRUE );
|
|
|
|
|
|
|
|
if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return wasVisible;
|
2001-12-13 01:54:52 +01:00
|
|
|
|
|
|
|
if (wndPtr->flags & WIN_NEED_SIZE)
|
|
|
|
{
|
|
|
|
/* should happen only in CreateWindowEx() */
|
|
|
|
int wParam = SIZE_RESTORED;
|
2005-03-23 13:00:51 +01:00
|
|
|
RECT client = wndPtr->rectClient;
|
2001-12-13 01:54:52 +01:00
|
|
|
|
|
|
|
wndPtr->flags &= ~WIN_NEED_SIZE;
|
|
|
|
if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED;
|
|
|
|
else if (wndPtr->dwStyle & WS_MINIMIZE) wParam = SIZE_MINIMIZED;
|
2005-03-23 13:00:51 +01:00
|
|
|
WIN_ReleasePtr( wndPtr );
|
|
|
|
|
|
|
|
SendMessageW( hwnd, WM_SIZE, wParam,
|
|
|
|
MAKELONG( client.right - client.left, client.bottom - client.top ));
|
|
|
|
SendMessageW( hwnd, WM_MOVE, 0, MAKELONG( client.left, client.top ));
|
2001-12-13 01:54:52 +01:00
|
|
|
}
|
2005-03-23 13:00:51 +01:00
|
|
|
else WIN_ReleasePtr( wndPtr );
|
2001-12-13 01:54:52 +01:00
|
|
|
|
|
|
|
return wasVisible;
|
|
|
|
}
|