2001-04-25 01:28:52 +02:00
|
|
|
/*
|
|
|
|
* Window position related functions.
|
|
|
|
*
|
|
|
|
* Copyright 1993, 1994, 1995, 2001 Alexandre Julliard
|
|
|
|
* Copyright 1995, 1996, 1999 Alex Korobka
|
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
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-11-21 22:48:36 +01:00
|
|
|
#include <X11/Xlib.h>
|
2002-09-24 05:17:31 +02:00
|
|
|
#ifdef HAVE_LIBXSHAPE
|
|
|
|
#include <X11/IntrinsicP.h>
|
|
|
|
#include <X11/extensions/shape.h>
|
2002-09-24 05:59:08 +02:00
|
|
|
#endif /* HAVE_LIBXSHAPE */
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2001-04-25 01:28:52 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2001-10-22 21:08:33 +02:00
|
|
|
#include "winerror.h"
|
2002-10-31 03:12:18 +01:00
|
|
|
#include "wownt32.h"
|
2004-01-20 23:48:57 +01:00
|
|
|
#include "wine/wingdi16.h"
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
#include "x11drv.h"
|
|
|
|
#include "win.h"
|
|
|
|
#include "winpos.h"
|
|
|
|
#include "dce.h"
|
2001-05-09 19:21:04 +02:00
|
|
|
#include "cursoricon.h"
|
|
|
|
#include "nonclient.h"
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2002-10-12 03:24:37 +02:00
|
|
|
#include "wine/server.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
|
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)
|
|
|
|
|
|
|
|
#define SWP_EX_NOCOPY 0x0001
|
|
|
|
#define SWP_EX_PAINTSELF 0x0002
|
|
|
|
#define SWP_EX_NONCLIENT 0x0004
|
|
|
|
|
2001-05-09 19:21:04 +02:00
|
|
|
#define HAS_THICKFRAME(style,exStyle) \
|
|
|
|
(((style) & WS_THICKFRAME) && \
|
|
|
|
!(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
|
|
|
|
|
|
|
|
#define ON_LEFT_BORDER(hit) \
|
|
|
|
(((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
|
|
|
|
#define ON_RIGHT_BORDER(hit) \
|
|
|
|
(((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
|
|
|
|
#define ON_TOP_BORDER(hit) \
|
|
|
|
(((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
|
|
|
|
#define ON_BOTTOM_BORDER(hit) \
|
|
|
|
(((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-04 23:55:17 +02:00
|
|
|
* clip_children
|
2001-04-25 01:28:52 +02:00
|
|
|
*
|
2001-06-04 23:55:17 +02:00
|
|
|
* Clip all children of a given window out of the visible region
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
2001-10-10 22:28:17 +02:00
|
|
|
static int clip_children( HWND parent, HWND last, HRGN hrgn, int whole_window )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
HWND *list;
|
2001-06-04 23:55:17 +02:00
|
|
|
WND *ptr;
|
|
|
|
HRGN rectRgn;
|
2001-10-10 22:28:17 +02:00
|
|
|
int i, x, y, ret = SIMPLEREGION;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/* first check if we have anything to do */
|
2001-10-10 22:28:17 +02:00
|
|
|
if (!(list = WIN_ListChildren( parent ))) return ret;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
if (whole_window)
|
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
WND *win = WIN_FindWndPtr( parent );
|
2001-06-04 23:55:17 +02:00
|
|
|
x = win->rectWindow.left - win->rectClient.left;
|
|
|
|
y = win->rectWindow.top - win->rectClient.top;
|
2001-10-10 22:28:17 +02:00
|
|
|
WIN_ReleaseWndPtr( win );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
else x = y = 0;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
rectRgn = CreateRectRgn( 0, 0, 0, 0 );
|
2001-10-10 22:28:17 +02:00
|
|
|
|
2003-11-27 01:56:05 +01:00
|
|
|
for (i = 0; list[i] && list[i] != last; i++)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
if (!(ptr = WIN_FindWndPtr( list[i] ))) continue;
|
2003-11-27 01:56:05 +01:00
|
|
|
if ((ptr->dwStyle & WS_VISIBLE) && !(ptr->dwExStyle & WS_EX_TRANSPARENT))
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
SetRectRgn( rectRgn, ptr->rectWindow.left + x, ptr->rectWindow.top + y,
|
|
|
|
ptr->rectWindow.right + x, ptr->rectWindow.bottom + y );
|
2001-06-20 02:22:40 +02:00
|
|
|
if ((ret = CombineRgn( hrgn, hrgn, rectRgn, RGN_DIFF )) == NULLREGION)
|
2001-10-10 22:28:17 +02:00
|
|
|
{
|
|
|
|
WIN_ReleaseWndPtr( ptr );
|
2001-06-04 23:55:17 +02:00
|
|
|
break; /* no need to go on, region is empty */
|
2001-10-10 22:28:17 +02:00
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2001-10-10 22:28:17 +02:00
|
|
|
WIN_ReleaseWndPtr( ptr );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
DeleteObject( rectRgn );
|
2001-10-10 22:28:17 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, list );
|
2001-06-20 02:22:40 +02:00
|
|
|
return ret;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2004-06-23 22:44:58 +02:00
|
|
|
* get_server_visible_region
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
2004-06-23 22:44:58 +02:00
|
|
|
static HRGN get_server_visible_region( HWND hwnd, HWND top, UINT flags )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2004-06-23 22:44:58 +02:00
|
|
|
RGNDATA *data;
|
|
|
|
HRGN ret = 0;
|
|
|
|
size_t size = 256;
|
|
|
|
BOOL retry = FALSE;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2004-06-23 22:44:58 +02:00
|
|
|
do
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2004-06-23 22:44:58 +02:00
|
|
|
if (!(data = HeapAlloc( GetProcessHeap(), 0, sizeof(*data) + size - 1 ))) return 0;
|
|
|
|
SERVER_START_REQ( get_visible_region )
|
2001-06-13 22:07:48 +02:00
|
|
|
{
|
2004-06-23 22:44:58 +02:00
|
|
|
req->window = hwnd;
|
|
|
|
req->top_win = top;
|
|
|
|
req->flags = flags;
|
|
|
|
wine_server_set_reply( req, data->Buffer, size );
|
|
|
|
if (!wine_server_call_err( req ))
|
2001-06-20 02:22:40 +02:00
|
|
|
{
|
2004-06-23 22:44:58 +02:00
|
|
|
if (reply->total_size <= size)
|
|
|
|
{
|
|
|
|
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 );
|
2004-06-24 06:06:51 +02:00
|
|
|
retry = FALSE;
|
2004-06-23 22:44:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size = reply->total_size;
|
|
|
|
retry = TRUE;
|
|
|
|
}
|
2001-06-20 02:22:40 +02:00
|
|
|
}
|
2001-06-13 22:07:48 +02:00
|
|
|
}
|
2004-06-23 22:44:58 +02:00
|
|
|
SERVER_END_REQ;
|
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
|
|
|
} while (retry);
|
|
|
|
return ret;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-22 05:42:27 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_covered_region
|
|
|
|
*
|
|
|
|
* Compute the portion of 'rgn' that is covered by non-clipped siblings.
|
|
|
|
* This is the area that is covered from X point of view, but may still need
|
|
|
|
* to be exposed.
|
|
|
|
* 'rgn' must be relative to the client area of the parent of 'win'.
|
|
|
|
*/
|
|
|
|
static int get_covered_region( WND *win, HRGN rgn )
|
|
|
|
{
|
|
|
|
HRGN tmp;
|
|
|
|
int ret;
|
2001-10-15 19:56:45 +02:00
|
|
|
WND *parent, *ptr = WIN_FindWndPtr( win->hwndSelf );
|
2001-06-22 05:42:27 +02:00
|
|
|
int xoffset = 0, yoffset = 0;
|
|
|
|
|
|
|
|
tmp = CreateRectRgn( 0, 0, 0, 0 );
|
|
|
|
CombineRgn( tmp, rgn, 0, RGN_COPY );
|
|
|
|
|
|
|
|
/* to make things easier we actually build the uncovered
|
|
|
|
* area by removing all siblings and then we subtract that
|
|
|
|
* from the total region to get the covered area */
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (!(ptr->dwStyle & WS_CLIPSIBLINGS))
|
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
if (clip_children( ptr->parent, ptr->hwndSelf, tmp, FALSE ) == NULLREGION) break;
|
2001-06-22 05:42:27 +02:00
|
|
|
}
|
2001-10-10 22:28:17 +02:00
|
|
|
if (!(parent = WIN_FindWndPtr( ptr->parent ))) break;
|
|
|
|
WIN_ReleaseWndPtr( ptr );
|
|
|
|
ptr = parent;
|
2001-06-22 05:42:27 +02:00
|
|
|
OffsetRgn( tmp, ptr->rectClient.left, ptr->rectClient.top );
|
|
|
|
xoffset += ptr->rectClient.left;
|
|
|
|
yoffset += ptr->rectClient.top;
|
|
|
|
}
|
2001-10-10 22:28:17 +02:00
|
|
|
WIN_ReleaseWndPtr( ptr );
|
2001-06-22 05:42:27 +02:00
|
|
|
/* make it relative to the target window again */
|
|
|
|
OffsetRgn( tmp, -xoffset, -yoffset );
|
|
|
|
|
|
|
|
/* now subtract the computed region from the original one */
|
|
|
|
ret = CombineRgn( rgn, rgn, tmp, RGN_DIFF );
|
|
|
|
DeleteObject( tmp );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* expose_window
|
|
|
|
*
|
|
|
|
* Expose a region of a given window.
|
|
|
|
*/
|
2001-10-10 22:28:17 +02:00
|
|
|
static void expose_window( HWND hwnd, RECT *rect, HRGN rgn, int flags )
|
2001-06-22 05:42:27 +02:00
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
POINT offset;
|
|
|
|
HWND top = 0;
|
|
|
|
HWND *list;
|
|
|
|
int i;
|
2001-06-22 05:42:27 +02:00
|
|
|
|
|
|
|
/* find the top most parent that doesn't clip children or siblings and
|
|
|
|
* invalidate the area on its parent, including all children */
|
2001-10-10 22:28:17 +02:00
|
|
|
if ((list = WIN_ListParents( hwnd )))
|
2001-06-22 05:42:27 +02:00
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
HWND current = hwnd;
|
|
|
|
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
for (i = 0; list[i] && list[i] != GetDesktopWindow(); i++)
|
|
|
|
{
|
|
|
|
if (!(style & WS_CLIPSIBLINGS)) top = current;
|
|
|
|
style = GetWindowLongW( list[i], GWL_STYLE );
|
|
|
|
if (!(style & WS_CLIPCHILDREN)) top = current;
|
|
|
|
current = list[i];
|
|
|
|
}
|
2001-06-22 05:42:27 +02:00
|
|
|
|
2001-10-10 22:28:17 +02:00
|
|
|
if (top)
|
|
|
|
{
|
|
|
|
/* find the parent of the top window, reusing the parent list */
|
|
|
|
if (top == hwnd) i = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; list[i]; i++) if (list[i] == top) break;
|
|
|
|
if (list[i] && list[i+1]) i++;
|
|
|
|
}
|
|
|
|
if (list[i] != GetDesktopWindow()) top = list[i];
|
|
|
|
flags &= ~RDW_FRAME; /* parent will invalidate children frame anyway */
|
|
|
|
flags |= RDW_ALLCHILDREN;
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, list );
|
2001-06-22 05:42:27 +02:00
|
|
|
}
|
2001-10-10 22:28:17 +02:00
|
|
|
|
|
|
|
if (!top) top = hwnd;
|
2001-06-22 05:42:27 +02:00
|
|
|
|
|
|
|
/* make coords relative to top */
|
2001-10-10 22:28:17 +02:00
|
|
|
offset.x = offset.y = 0;
|
|
|
|
MapWindowPoints( hwnd, top, &offset, 1 );
|
2001-06-22 05:42:27 +02:00
|
|
|
|
|
|
|
if (rect)
|
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
OffsetRect( rect, offset.x, offset.y );
|
|
|
|
RedrawWindow( top, rect, 0, flags );
|
2001-06-22 05:42:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
OffsetRgn( rgn, offset.x, offset.y );
|
|
|
|
RedrawWindow( top, NULL, rgn, flags );
|
2001-06-22 05:42:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* expose_covered_parent_area
|
|
|
|
*
|
|
|
|
* Expose the parent area that has been uncovered by moving/hiding a
|
|
|
|
* given window, but that is still covered by other siblings (the area
|
|
|
|
* not covered by siblings will be exposed automatically by X).
|
|
|
|
*/
|
|
|
|
static void expose_covered_parent_area( WND *win, const RECT *old_rect )
|
|
|
|
{
|
|
|
|
int ret = SIMPLEREGION;
|
|
|
|
HRGN hrgn = CreateRectRgnIndirect( old_rect );
|
|
|
|
|
|
|
|
if (win->dwStyle & WS_VISIBLE)
|
|
|
|
{
|
|
|
|
HRGN tmp = CreateRectRgnIndirect( &win->rectWindow );
|
|
|
|
ret = CombineRgn( hrgn, hrgn, tmp, RGN_DIFF );
|
|
|
|
DeleteObject( tmp );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret != NULLREGION)
|
|
|
|
{
|
|
|
|
if (get_covered_region( win, hrgn ) != NULLREGION)
|
|
|
|
expose_window( win->parent, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
|
|
|
|
}
|
|
|
|
DeleteObject( hrgn );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* expose_covered_window_area
|
|
|
|
*
|
|
|
|
* Expose the area of a window that is covered by other siblings.
|
|
|
|
*/
|
|
|
|
static void expose_covered_window_area( WND *win, const RECT *old_client_rect, BOOL frame )
|
|
|
|
{
|
|
|
|
HRGN hrgn;
|
|
|
|
int ret = SIMPLEREGION;
|
|
|
|
|
|
|
|
if (frame)
|
|
|
|
hrgn = CreateRectRgn( win->rectWindow.left - win->rectClient.left,
|
|
|
|
win->rectWindow.top - win->rectClient.top,
|
|
|
|
win->rectWindow.right - win->rectWindow.left,
|
|
|
|
win->rectWindow.bottom - win->rectWindow.top );
|
|
|
|
else
|
|
|
|
hrgn = CreateRectRgn( 0, 0,
|
|
|
|
win->rectClient.right - win->rectClient.left,
|
|
|
|
win->rectClient.bottom - win->rectClient.top );
|
|
|
|
|
|
|
|
/* if the client rect didn't move we don't need to repaint it all */
|
|
|
|
if (old_client_rect->left == win->rectClient.left &&
|
|
|
|
old_client_rect->top == win->rectClient.top)
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
if (IntersectRect( &rc, old_client_rect, &win->rectClient ))
|
|
|
|
{
|
|
|
|
HRGN tmp;
|
|
|
|
/* subtract the unchanged client area from the region to expose */
|
|
|
|
OffsetRect( &rc, -win->rectClient.left, -win->rectClient.top );
|
|
|
|
if ((tmp = CreateRectRgnIndirect( &rc )))
|
|
|
|
{
|
|
|
|
ret = CombineRgn( hrgn, hrgn, tmp, RGN_DIFF );
|
|
|
|
DeleteObject( tmp );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret != NULLREGION)
|
|
|
|
{
|
|
|
|
if (get_covered_region( win, hrgn ) != NULLREGION)
|
2001-10-10 22:28:17 +02:00
|
|
|
expose_window( win->hwndSelf, NULL, hrgn,
|
2001-06-22 05:42:27 +02:00
|
|
|
RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
|
|
|
|
}
|
|
|
|
|
|
|
|
DeleteObject( hrgn );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_Expose
|
|
|
|
*/
|
|
|
|
void X11DRV_Expose( HWND hwnd, XExposeEvent *event )
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
int flags = RDW_INVALIDATE | RDW_ERASE;
|
|
|
|
WND *win;
|
|
|
|
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "win %p (%lx) %d,%d %dx%d\n",
|
2001-06-22 05:42:27 +02:00
|
|
|
hwnd, event->window, event->x, event->y, event->width, event->height );
|
|
|
|
|
|
|
|
rect.left = event->x;
|
|
|
|
rect.top = event->y;
|
|
|
|
rect.right = rect.left + event->width;
|
|
|
|
rect.bottom = rect.top + event->height;
|
|
|
|
|
2001-10-15 19:56:45 +02:00
|
|
|
if (!(win = WIN_GetPtr( hwnd ))) return;
|
2001-06-22 05:42:27 +02:00
|
|
|
data = win->pDriverData;
|
|
|
|
|
|
|
|
if (event->window != data->client_window) /* whole window or icon window */
|
|
|
|
{
|
|
|
|
flags |= RDW_FRAME;
|
|
|
|
/* make position relative to client area instead of window */
|
|
|
|
OffsetRect( &rect, -data->client_rect.left, -data->client_rect.top );
|
|
|
|
}
|
2001-10-15 19:56:45 +02:00
|
|
|
WIN_ReleasePtr( win );
|
2001-10-10 22:28:17 +02:00
|
|
|
|
|
|
|
expose_window( hwnd, &rect, 0, flags );
|
2001-06-22 05:42:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* GetDC (X11DRV.@)
|
2001-04-25 01:28:52 +02:00
|
|
|
*
|
|
|
|
* Set the drawable, origin and dimensions for the DC associated to
|
|
|
|
* a given window.
|
|
|
|
*/
|
|
|
|
BOOL X11DRV_GetDC( HWND hwnd, HDC hdc, HRGN hrgn, DWORD flags )
|
|
|
|
{
|
2001-10-22 21:08:33 +02:00
|
|
|
WND *win = WIN_GetPtr( hwnd );
|
2001-10-10 22:28:17 +02:00
|
|
|
HWND top = 0;
|
2001-06-04 23:55:17 +02:00
|
|
|
X11DRV_WND_DATA *data = win->pDriverData;
|
2004-01-14 05:53:11 +01:00
|
|
|
struct x11drv_escape_set_drawable escape;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2004-01-14 05:53:11 +01:00
|
|
|
escape.mode = IncludeInferiors;
|
2001-06-04 23:55:17 +02:00
|
|
|
/* don't clip siblings if using parent clip region */
|
|
|
|
if (flags & DCX_PARENTCLIP) flags &= ~DCX_CLIPSIBLINGS;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2004-06-23 22:44:58 +02:00
|
|
|
top = GetAncestor( hwnd, GA_ROOT );
|
|
|
|
if (top != hwnd)
|
2001-06-26 22:09:19 +02:00
|
|
|
{
|
2004-01-14 05:53:11 +01:00
|
|
|
escape.org.x = escape.org.y = 0;
|
2001-06-13 22:07:48 +02:00
|
|
|
if (flags & DCX_WINDOW)
|
|
|
|
{
|
2004-01-14 05:53:11 +01:00
|
|
|
escape.org.x = win->rectWindow.left - win->rectClient.left;
|
|
|
|
escape.org.y = win->rectWindow.top - win->rectClient.top;
|
2001-06-13 22:07:48 +02:00
|
|
|
}
|
2004-06-23 22:44:58 +02:00
|
|
|
MapWindowPoints( hwnd, top, &escape.org, 1 );
|
2004-01-14 05:53:11 +01:00
|
|
|
escape.drawable_org.x = escape.drawable_org.y = 0;
|
2004-06-23 22:44:58 +02:00
|
|
|
MapWindowPoints( top, 0, &escape.drawable_org, 1 );
|
|
|
|
escape.drawable = X11DRV_get_client_window( top );
|
2001-06-13 22:07:48 +02:00
|
|
|
}
|
|
|
|
else
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
if (IsIconic( hwnd ))
|
|
|
|
{
|
2004-01-14 05:53:11 +01:00
|
|
|
escape.drawable = data->icon_window ? data->icon_window : data->whole_window;
|
|
|
|
escape.org.x = 0;
|
|
|
|
escape.org.y = 0;
|
|
|
|
escape.drawable_org = escape.org;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-06-23 22:44:58 +02:00
|
|
|
escape.drawable = data->whole_window;
|
|
|
|
escape.drawable_org.x = data->whole_rect.left;
|
|
|
|
escape.drawable_org.y = data->whole_rect.top;
|
|
|
|
if (flags & DCX_WINDOW)
|
|
|
|
{
|
|
|
|
escape.org.x = win->rectWindow.left - data->whole_rect.left;
|
|
|
|
escape.org.y = win->rectWindow.top - data->whole_rect.top;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
escape.org.x = win->rectClient.left - data->whole_rect.left;
|
|
|
|
escape.org.y = win->rectClient.top - data->whole_rect.top;
|
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
2004-01-14 05:53:11 +01:00
|
|
|
escape.code = X11DRV_SET_DRAWABLE;
|
|
|
|
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
if (flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN) ||
|
2002-10-31 03:12:18 +01:00
|
|
|
SetHookFlags16( HDC_16(hdc), DCHF_VALIDATEVISRGN )) /* DC was dirty */
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
/* need to recompute the visible region */
|
2004-06-23 22:44:58 +02:00
|
|
|
HRGN visRgn = get_server_visible_region( hwnd, top, flags );
|
2001-06-26 22:09:19 +02:00
|
|
|
|
2004-06-23 22:44:58 +02: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
|
|
|
|
2002-10-31 03:12:18 +01:00
|
|
|
SelectVisRgn16( HDC_16(hdc), HRGN_16(visRgn) );
|
2001-06-04 23:55:17 +02:00
|
|
|
DeleteObject( visRgn );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
WIN_ReleasePtr( win );
|
2001-04-25 01:28:52 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-14 23:30:20 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ReleaseDC (X11DRV.@)
|
|
|
|
*/
|
|
|
|
void X11DRV_ReleaseDC( HWND hwnd, HDC hdc )
|
|
|
|
{
|
2004-01-14 05:53:11 +01:00
|
|
|
struct x11drv_escape_set_drawable escape;
|
2002-11-14 23:30:20 +01:00
|
|
|
|
2004-01-14 05:53:11 +01:00
|
|
|
escape.code = X11DRV_SET_DRAWABLE;
|
|
|
|
escape.drawable = root_window;
|
|
|
|
escape.mode = IncludeInferiors;
|
|
|
|
escape.org.x = escape.org.y = 0;
|
|
|
|
escape.drawable_org.x = escape.drawable_org.y = 0;
|
|
|
|
|
|
|
|
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
|
2002-11-14 23:30:20 +01:00
|
|
|
}
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SWP_DoWinPosChanging
|
|
|
|
*/
|
2001-06-04 23:55:17 +02:00
|
|
|
static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT* pNewClientRect )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
WND *wndPtr;
|
|
|
|
|
|
|
|
/* Send WM_WINDOWPOSCHANGING message */
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
if (!(pWinpos->flags & SWP_NOSENDCHANGING))
|
2004-04-02 22:14:15 +02:00
|
|
|
SendMessageW( pWinpos->hwnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)pWinpos );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
if (!(wndPtr = WIN_GetPtr( pWinpos->hwnd )) || wndPtr == WND_OTHER_PROCESS) return FALSE;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
/* Calculate new position and size */
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
*pNewWindowRect = wndPtr->rectWindow;
|
|
|
|
*pNewClientRect = (wndPtr->dwStyle & WS_MINIMIZE) ? wndPtr->rectWindow
|
|
|
|
: wndPtr->rectClient;
|
|
|
|
|
|
|
|
if (!(pWinpos->flags & SWP_NOSIZE))
|
|
|
|
{
|
|
|
|
pNewWindowRect->right = pNewWindowRect->left + pWinpos->cx;
|
|
|
|
pNewWindowRect->bottom = pNewWindowRect->top + pWinpos->cy;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
|
|
|
OffsetRect( pNewClientRect, pWinpos->x - wndPtr->rectWindow.left,
|
|
|
|
pWinpos->y - wndPtr->rectWindow.top );
|
|
|
|
}
|
|
|
|
pWinpos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
|
2001-10-16 23:58:58 +02:00
|
|
|
WIN_ReleasePtr( wndPtr );
|
2001-04-25 01:28:52 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SWP_DoNCCalcSize
|
|
|
|
*/
|
2001-10-16 23:58:58 +02:00
|
|
|
static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT* pNewClientRect )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
|
|
|
UINT wvrFlags = 0;
|
2001-10-16 23:58:58 +02:00
|
|
|
WND *wndPtr;
|
|
|
|
|
|
|
|
if (!(wndPtr = WIN_GetPtr( pWinpos->hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
/* Send WM_NCCALCSIZE message to get new client area */
|
|
|
|
if( (pWinpos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE )
|
|
|
|
{
|
2001-10-16 23:58:58 +02:00
|
|
|
NCCALCSIZE_PARAMS params;
|
|
|
|
WINDOWPOS winposCopy;
|
|
|
|
|
|
|
|
params.rgrc[0] = *pNewWindowRect;
|
|
|
|
params.rgrc[1] = wndPtr->rectWindow;
|
|
|
|
params.rgrc[2] = wndPtr->rectClient;
|
|
|
|
params.lppos = &winposCopy;
|
|
|
|
winposCopy = *pWinpos;
|
|
|
|
WIN_ReleasePtr( wndPtr );
|
|
|
|
|
|
|
|
wvrFlags = SendMessageW( pWinpos->hwnd, WM_NCCALCSIZE, TRUE, (LPARAM)¶ms );
|
|
|
|
|
2003-01-08 22:09:25 +01:00
|
|
|
TRACE( "(%ld,%ld)-(%ld,%ld)\n", params.rgrc[0].left, params.rgrc[0].top,
|
2001-10-16 23:58:58 +02:00
|
|
|
params.rgrc[0].right, params.rgrc[0].bottom );
|
|
|
|
|
|
|
|
/* If the application send back garbage, ignore it */
|
|
|
|
if (params.rgrc[0].left <= params.rgrc[0].right &&
|
|
|
|
params.rgrc[0].top <= params.rgrc[0].bottom)
|
|
|
|
*pNewClientRect = params.rgrc[0];
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
/* FIXME: WVR_ALIGNxxx */
|
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
if (!(wndPtr = WIN_GetPtr( pWinpos->hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
|
|
|
|
|
|
|
|
if( pNewClientRect->left != wndPtr->rectClient.left ||
|
|
|
|
pNewClientRect->top != wndPtr->rectClient.top )
|
|
|
|
pWinpos->flags &= ~SWP_NOCLIENTMOVE;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
if( (pNewClientRect->right - pNewClientRect->left !=
|
|
|
|
wndPtr->rectClient.right - wndPtr->rectClient.left) ||
|
|
|
|
(pNewClientRect->bottom - pNewClientRect->top !=
|
|
|
|
wndPtr->rectClient.bottom - wndPtr->rectClient.top) )
|
|
|
|
pWinpos->flags &= ~SWP_NOCLIENTSIZE;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
else
|
2001-10-16 23:58:58 +02:00
|
|
|
{
|
|
|
|
if (!(pWinpos->flags & SWP_NOMOVE) &&
|
|
|
|
(pNewClientRect->left != wndPtr->rectClient.left ||
|
|
|
|
pNewClientRect->top != wndPtr->rectClient.top))
|
2001-04-25 01:28:52 +02:00
|
|
|
pWinpos->flags &= ~SWP_NOCLIENTMOVE;
|
2001-10-16 23:58:58 +02:00
|
|
|
}
|
|
|
|
WIN_ReleasePtr( wndPtr );
|
2001-04-25 01:28:52 +02:00
|
|
|
return wvrFlags;
|
|
|
|
}
|
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* 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.
|
|
|
|
*/
|
2001-08-24 02:26:59 +02:00
|
|
|
static HWND SWP_DoOwnedPopups(HWND hwnd, HWND hwndInsertAfter)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-08-24 02:26:59 +02:00
|
|
|
HWND *list = NULL;
|
|
|
|
HWND owner = GetWindow( hwnd, GW_OWNER );
|
|
|
|
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2002-10-31 03:38:20 +01:00
|
|
|
WARN("(%p) hInsertAfter = %p\n", hwnd, hwndInsertAfter );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-08-24 02:26:59 +02:00
|
|
|
if ((style & WS_POPUP) && owner)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
|
|
|
/* make sure this popup stays above the owner */
|
|
|
|
|
|
|
|
HWND hwndLocalPrev = HWND_TOP;
|
|
|
|
|
|
|
|
if( hwndInsertAfter != HWND_TOP )
|
|
|
|
{
|
2001-08-24 21:28:21 +02:00
|
|
|
if ((list = WIN_ListChildren( GetDesktopWindow() )))
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-08-24 02:26:59 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-24 02:26:59 +02:00
|
|
|
else if (style & WS_CHILD) return hwndInsertAfter;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-08-24 21:28:21 +02:00
|
|
|
if (!list) list = WIN_ListChildren( GetDesktopWindow() );
|
2001-08-24 02:26:59 +02:00
|
|
|
if (list)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-08-24 02:26:59 +02:00
|
|
|
int i;
|
|
|
|
for (i = 0; list[i]; i++)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-08-24 02:26:59 +02: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-04-25 01:28:52 +02:00
|
|
|
}
|
2001-08-24 21:28:21 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, list );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return hwndInsertAfter;
|
|
|
|
}
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
/* fix redundant flags and values in the WINDOWPOS structure */
|
|
|
|
static BOOL fixup_flags( WINDOWPOS *winpos )
|
|
|
|
{
|
2001-10-22 21:08:33 +02:00
|
|
|
WND *wndPtr = WIN_GetPtr( winpos->hwnd );
|
2001-06-04 23:55:17 +02:00
|
|
|
BOOL ret = TRUE;
|
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
if (!wndPtr || wndPtr == WND_OTHER_PROCESS)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-09-14 02:24:39 +02:00
|
|
|
winpos->hwnd = wndPtr->hwndSelf; /* make it a full handle */
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2004-03-11 04:51:46 +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;
|
|
|
|
|
|
|
|
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-06-04 23:55:17 +02:00
|
|
|
if (wndPtr->dwStyle & WS_VISIBLE) winpos->flags &= ~SWP_SHOWWINDOW;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
winpos->flags &= ~SWP_HIDEWINDOW;
|
|
|
|
if (!(winpos->flags & SWP_SHOWWINDOW)) winpos->flags |= SWP_NOREDRAW;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 */
|
|
|
|
|
2004-04-02 22:18:20 +02:00
|
|
|
if (winpos->hwnd == GetActiveWindow())
|
2001-06-04 23:55:17 +02:00
|
|
|
winpos->flags |= SWP_NOACTIVATE; /* Already active */
|
|
|
|
else if ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)
|
|
|
|
{
|
|
|
|
if (!(winpos->flags & SWP_NOACTIVATE)) /* Bring to the top when activating */
|
|
|
|
{
|
|
|
|
winpos->flags &= ~SWP_NOZORDER;
|
|
|
|
winpos->hwndInsertAfter = HWND_TOP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check hwndInsertAfter */
|
2002-04-25 00:20:11 +02:00
|
|
|
if (winpos->flags & SWP_NOZORDER) goto done;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2001-09-19 22:37:04 +02:00
|
|
|
/* fix sign extension */
|
|
|
|
if (winpos->hwndInsertAfter == (HWND)0xffff) winpos->hwndInsertAfter = HWND_TOPMOST;
|
|
|
|
else if (winpos->hwndInsertAfter == (HWND)0xfffe) winpos->hwndInsertAfter = HWND_NOTOPMOST;
|
|
|
|
|
2001-06-04 23:55:17 +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 */
|
2004-04-02 22:22:29 +02: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-06-04 23:55:17 +02:00
|
|
|
{
|
2001-10-22 21:08:33 +02:00
|
|
|
if (GetAncestor( winpos->hwndInsertAfter, GA_PARENT ) != wndPtr->parent) ret = FALSE;
|
|
|
|
else
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2001-10-22 21:08:33 +02: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-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
done:
|
2001-10-22 21:08:33 +02:00
|
|
|
WIN_ReleasePtr( wndPtr );
|
2001-06-04 23:55:17 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-20 02:36:45 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* set_visible_style
|
|
|
|
*
|
|
|
|
* Set/clear the WS_VISIBLE style of a window and map/unmap the X window.
|
|
|
|
*/
|
|
|
|
static void set_visible_style( HWND hwnd, BOOL set )
|
|
|
|
{
|
|
|
|
WND *win;
|
|
|
|
|
|
|
|
if (!(win = WIN_GetPtr( hwnd ))) return;
|
|
|
|
if (win == WND_OTHER_PROCESS) return;
|
|
|
|
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "hwnd %p (%lx) set %d visible %d empty %d\n",
|
2002-08-20 02:36:45 +02:00
|
|
|
hwnd, get_whole_window(win),
|
|
|
|
set, (win->dwStyle & WS_VISIBLE) != 0, IsRectEmpty(&win->rectWindow) );
|
|
|
|
|
|
|
|
if (set)
|
|
|
|
{
|
|
|
|
if (win->dwStyle & WS_VISIBLE) goto done;
|
|
|
|
WIN_SetStyle( hwnd, win->dwStyle | WS_VISIBLE );
|
2004-04-28 01:32:01 +02:00
|
|
|
if (X11DRV_is_window_rect_mapped( &win->rectWindow ) &&
|
|
|
|
get_whole_window(win) && is_window_top_level(win))
|
2002-08-20 02:36:45 +02:00
|
|
|
{
|
|
|
|
Display *display = thread_display();
|
|
|
|
X11DRV_sync_window_style( display, win );
|
|
|
|
X11DRV_set_wm_hints( display, win );
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "mapping win %p\n", hwnd );
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XMapWindow( display, get_whole_window(win) );
|
|
|
|
wine_tsx11_unlock();
|
2002-08-20 02:36:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!(win->dwStyle & WS_VISIBLE)) goto done;
|
|
|
|
WIN_SetStyle( hwnd, win->dwStyle & ~WS_VISIBLE );
|
2004-04-28 01:32:01 +02:00
|
|
|
if (X11DRV_is_window_rect_mapped( &win->rectWindow ) &&
|
|
|
|
get_whole_window(win) && is_window_top_level(win))
|
2002-08-20 02:36:45 +02:00
|
|
|
{
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "unmapping win %p\n", hwnd );
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XUnmapWindow( thread_display(), get_whole_window(win) );
|
|
|
|
wine_tsx11_unlock();
|
2002-08-20 02:36:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
done:
|
|
|
|
WIN_ReleasePtr( win );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-03 20:44:02 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetWindowStyle (X11DRV.@)
|
|
|
|
*
|
|
|
|
* Update the X state of a window to reflect a style change
|
|
|
|
*/
|
|
|
|
void X11DRV_SetWindowStyle( HWND hwnd, LONG oldStyle )
|
|
|
|
{
|
|
|
|
Display *display = thread_display();
|
2001-10-22 21:08:33 +02:00
|
|
|
WND *wndPtr;
|
|
|
|
LONG changed;
|
2001-10-03 20:44:02 +02:00
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
if (hwnd == GetDesktopWindow()) return;
|
|
|
|
if (!(wndPtr = WIN_GetPtr( hwnd ))) return;
|
|
|
|
if (wndPtr == WND_OTHER_PROCESS) return;
|
|
|
|
|
|
|
|
changed = wndPtr->dwStyle ^ oldStyle;
|
|
|
|
|
|
|
|
if (changed & WS_VISIBLE)
|
2001-10-03 20:44:02 +02:00
|
|
|
{
|
2004-04-28 01:32:01 +02:00
|
|
|
if (X11DRV_is_window_rect_mapped( &wndPtr->rectWindow ))
|
2001-10-03 20:44:02 +02:00
|
|
|
{
|
2001-10-22 21:08:33 +02:00
|
|
|
if (wndPtr->dwStyle & WS_VISIBLE)
|
|
|
|
{
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "mapping win %p\n", hwnd );
|
2003-06-24 21:31:47 +02:00
|
|
|
if (is_window_top_level(wndPtr))
|
|
|
|
{
|
|
|
|
X11DRV_sync_window_style( display, wndPtr );
|
|
|
|
X11DRV_set_wm_hints( display, wndPtr );
|
|
|
|
}
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XMapWindow( display, get_whole_window(wndPtr) );
|
|
|
|
wine_tsx11_unlock();
|
2001-10-22 21:08:33 +02:00
|
|
|
}
|
2003-06-24 21:31:47 +02:00
|
|
|
else if (!is_window_top_level(wndPtr)) /* don't unmap managed windows */
|
2001-10-22 21:08:33 +02:00
|
|
|
{
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "unmapping win %p\n", hwnd );
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XUnmapWindow( display, get_whole_window(wndPtr) );
|
|
|
|
wine_tsx11_unlock();
|
2001-10-22 21:08:33 +02:00
|
|
|
}
|
2001-10-03 20:44:02 +02:00
|
|
|
}
|
|
|
|
}
|
2001-10-22 21:08:33 +02:00
|
|
|
|
|
|
|
if (changed & WS_DISABLED)
|
|
|
|
{
|
|
|
|
if (wndPtr->dwExStyle & WS_EX_MANAGED)
|
|
|
|
{
|
|
|
|
XWMHints *wm_hints;
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (!(wm_hints = XGetWMHints( display, get_whole_window(wndPtr) )))
|
|
|
|
wm_hints = XAllocWMHints();
|
|
|
|
if (wm_hints)
|
|
|
|
{
|
|
|
|
wm_hints->flags |= InputHint;
|
|
|
|
wm_hints->input = !(wndPtr->dwStyle & WS_DISABLED);
|
|
|
|
XSetWMHints( display, get_whole_window(wndPtr), wm_hints );
|
|
|
|
XFree(wm_hints);
|
|
|
|
}
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WIN_ReleasePtr(wndPtr);
|
2001-10-03 20:44:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
/***********************************************************************
|
2001-06-04 23:55:17 +02:00
|
|
|
* SetWindowPos (X11DRV.@)
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
2001-06-04 23:55:17 +02:00
|
|
|
BOOL X11DRV_SetWindowPos( WINDOWPOS *winpos )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
WND *wndPtr;
|
|
|
|
RECT newWindowRect, newClientRect;
|
|
|
|
RECT oldWindowRect, oldClientRect;
|
|
|
|
UINT wvrFlags = 0;
|
|
|
|
BOOL bChangePos;
|
|
|
|
|
2003-11-04 05:21:42 +01:00
|
|
|
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-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
bChangePos = !(winpos->flags & SWP_WINE_NOHOSTMOVE);
|
|
|
|
winpos->flags &= ~SWP_WINE_NOHOSTMOVE;
|
|
|
|
|
2001-09-14 02:24:39 +02:00
|
|
|
/* Check window handle */
|
|
|
|
if (winpos->hwnd == GetDesktopWindow()) return FALSE;
|
|
|
|
|
2004-03-11 04:51:46 +01:00
|
|
|
/* First make sure that coordinates are valid for WM_WINDOWPOSCHANGING */
|
|
|
|
if (!(winpos->flags & SWP_NOMOVE))
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2003-11-04 05:21:42 +01:00
|
|
|
if (!SWP_DoWinPosChanging( winpos, &newWindowRect, &newClientRect )) return FALSE;
|
|
|
|
|
|
|
|
/* Fix redundant flags */
|
|
|
|
if (!fixup_flags( winpos )) return FALSE;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
if (!(wndPtr = WIN_FindWndPtr( winpos->hwnd ))) return FALSE;
|
|
|
|
|
2003-01-08 22:09:25 +01:00
|
|
|
TRACE("\tcurrent (%ld,%ld)-(%ld,%ld), style %08x\n",
|
2001-06-04 23:55:17 +02:00
|
|
|
wndPtr->rectWindow.left, wndPtr->rectWindow.top,
|
|
|
|
wndPtr->rectWindow.right, wndPtr->rectWindow.bottom, (unsigned)wndPtr->dwStyle );
|
|
|
|
|
|
|
|
if((winpos->flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) != SWP_NOZORDER)
|
|
|
|
{
|
2001-08-24 02:26:59 +02:00
|
|
|
if (GetAncestor( winpos->hwnd, GA_PARENT ) == GetDesktopWindow())
|
|
|
|
winpos->hwndInsertAfter = SWP_DoOwnedPopups( winpos->hwnd, winpos->hwndInsertAfter );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Common operations */
|
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
wvrFlags = SWP_DoNCCalcSize( winpos, &newWindowRect, &newClientRect );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
if(!(winpos->flags & SWP_NOZORDER) && winpos->hwnd != winpos->hwndInsertAfter)
|
|
|
|
{
|
2001-08-28 20:44:52 +02:00
|
|
|
HWND parent = GetAncestor( winpos->hwnd, GA_PARENT );
|
|
|
|
if (parent) WIN_LinkWindow( winpos->hwnd, parent, winpos->hwndInsertAfter );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset active DCEs */
|
|
|
|
|
|
|
|
if( (((winpos->flags & SWP_AGG_NOPOSCHANGE) != SWP_AGG_NOPOSCHANGE) &&
|
|
|
|
wndPtr->dwStyle & WS_VISIBLE) ||
|
|
|
|
(winpos->flags & (SWP_HIDEWINDOW | SWP_SHOWWINDOW)) )
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
UnionRect(&rect, &newWindowRect, &wndPtr->rectWindow);
|
2001-08-24 02:26:59 +02:00
|
|
|
DCE_InvalidateDCE(wndPtr->hwndSelf, &rect);
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
oldWindowRect = wndPtr->rectWindow;
|
|
|
|
oldClientRect = wndPtr->rectClient;
|
|
|
|
|
|
|
|
/* Find out if we have to redraw the whole client rect */
|
|
|
|
|
|
|
|
if( oldClientRect.bottom - oldClientRect.top ==
|
|
|
|
newClientRect.bottom - newClientRect.top ) wvrFlags &= ~WVR_VREDRAW;
|
|
|
|
|
|
|
|
if( oldClientRect.right - oldClientRect.left ==
|
|
|
|
newClientRect.right - newClientRect.left ) wvrFlags &= ~WVR_HREDRAW;
|
|
|
|
|
|
|
|
/* FIXME: actually do something with WVR_VALIDRECTS */
|
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
WIN_SetRectangles( winpos->hwnd, &newWindowRect, &newClientRect );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
if (get_whole_window(wndPtr)) /* don't do anything if X window not created yet */
|
|
|
|
{
|
|
|
|
Display *display = thread_display();
|
|
|
|
|
|
|
|
if (!(winpos->flags & SWP_SHOWWINDOW) && (winpos->flags & SWP_HIDEWINDOW))
|
|
|
|
{
|
2001-10-22 21:08:33 +02:00
|
|
|
/* clear the update region */
|
2001-11-13 23:02:20 +01:00
|
|
|
RedrawWindow( winpos->hwnd, NULL, 0, RDW_VALIDATE | RDW_NOFRAME |
|
|
|
|
RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ALLCHILDREN );
|
2002-08-20 02:36:45 +02:00
|
|
|
set_visible_style( winpos->hwnd, FALSE );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2004-06-19 00:34:19 +02:00
|
|
|
else if ((wndPtr->dwStyle & WS_VISIBLE) && bChangePos &&
|
2004-04-28 01:32:01 +02:00
|
|
|
X11DRV_is_window_rect_mapped( &oldWindowRect ) &&
|
|
|
|
!X11DRV_is_window_rect_mapped( &newWindowRect ))
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2004-04-28 01:32:01 +02:00
|
|
|
/* resizing to zero size or off screen -> unmap */
|
|
|
|
TRACE( "unmapping zero size or off-screen win %p\n", winpos->hwnd );
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XUnmapWindow( display, get_whole_window(wndPtr) );
|
|
|
|
wine_tsx11_unlock();
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
wine_tsx11_lock();
|
2001-06-04 23:55:17 +02:00
|
|
|
if (bChangePos)
|
|
|
|
X11DRV_sync_whole_window_position( display, wndPtr, !(winpos->flags & SWP_NOZORDER) );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct x11drv_win_data *data = wndPtr->pDriverData;
|
|
|
|
data->whole_rect = wndPtr->rectWindow;
|
|
|
|
X11DRV_window_to_X_rect( wndPtr, &data->whole_rect );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (X11DRV_sync_client_window_position( display, wndPtr ) ||
|
|
|
|
(winpos->flags & SWP_FRAMECHANGED))
|
|
|
|
{
|
|
|
|
/* if we moved the client area, repaint the whole non-client window */
|
|
|
|
XClearArea( display, get_whole_window(wndPtr), 0, 0, 0, 0, True );
|
2001-06-22 05:42:27 +02:00
|
|
|
winpos->flags |= SWP_FRAMECHANGED;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
if (winpos->flags & SWP_SHOWWINDOW)
|
|
|
|
{
|
2002-08-20 02:36:45 +02:00
|
|
|
set_visible_style( winpos->hwnd, TRUE );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2004-06-19 00:34:19 +02:00
|
|
|
else if ((wndPtr->dwStyle & WS_VISIBLE) && bChangePos &&
|
2004-04-28 01:32:01 +02:00
|
|
|
!X11DRV_is_window_rect_mapped( &oldWindowRect ) &&
|
|
|
|
X11DRV_is_window_rect_mapped( &newWindowRect ))
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
|
|
|
/* resizing from zero size to non-zero -> map */
|
2004-04-28 01:32:01 +02:00
|
|
|
TRACE( "mapping non zero size or off-screen win %p\n", winpos->hwnd );
|
2001-06-04 23:55:17 +02:00
|
|
|
XMapWindow( display, get_whole_window(wndPtr) );
|
|
|
|
}
|
|
|
|
XFlush( display ); /* FIXME: should not be necessary */
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
2001-10-22 21:08:33 +02:00
|
|
|
else /* no X window, simply toggle the window style */
|
|
|
|
{
|
|
|
|
if (winpos->flags & SWP_SHOWWINDOW)
|
2002-08-20 02:36:45 +02:00
|
|
|
set_visible_style( winpos->hwnd, TRUE );
|
2001-10-22 21:08:33 +02:00
|
|
|
else if (winpos->flags & SWP_HIDEWINDOW)
|
2002-08-20 02:36:45 +02:00
|
|
|
set_visible_style( winpos->hwnd, FALSE );
|
2001-10-22 21:08:33 +02:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2001-06-22 05:42:27 +02:00
|
|
|
/* manually expose the areas that X won't expose because they are still covered by something */
|
|
|
|
|
|
|
|
if (!(winpos->flags & SWP_SHOWWINDOW))
|
|
|
|
expose_covered_parent_area( wndPtr, &oldWindowRect );
|
|
|
|
|
|
|
|
if (wndPtr->dwStyle & WS_VISIBLE)
|
|
|
|
expose_covered_window_area( wndPtr, &oldClientRect, winpos->flags & SWP_FRAMECHANGED );
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
WIN_ReleaseWndPtr(wndPtr);
|
|
|
|
|
|
|
|
if (wvrFlags & WVR_REDRAW) RedrawWindow( winpos->hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE );
|
|
|
|
|
2002-10-17 03:24:33 +02:00
|
|
|
if( winpos->flags & SWP_HIDEWINDOW )
|
|
|
|
HideCaret(winpos->hwnd);
|
|
|
|
else if (winpos->flags & SWP_SHOWWINDOW)
|
|
|
|
ShowCaret(winpos->hwnd);
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2001-11-08 00:19:42 +01:00
|
|
|
if (!(winpos->flags & SWP_NOACTIVATE))
|
|
|
|
{
|
|
|
|
/* 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
|
2002-10-12 01:41:06 +02:00
|
|
|
SetForegroundWindow( winpos->hwnd );
|
2001-11-08 00:19:42 +01:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
/* And last, send the WM_WINDOWPOSCHANGED message */
|
|
|
|
|
|
|
|
TRACE("\tstatus flags = %04x\n", winpos->flags & SWP_AGG_STATUSFLAGS);
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2002-08-27 02:33:07 +02:00
|
|
|
if (((winpos->flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE))
|
2004-06-23 22:50:30 +02:00
|
|
|
{
|
|
|
|
/* 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-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WINPOS_FindIconPos
|
|
|
|
*
|
|
|
|
* Find a suitable place for an iconic window.
|
|
|
|
*/
|
|
|
|
static POINT WINPOS_FindIconPos( WND* wndPtr, POINT pt )
|
|
|
|
{
|
|
|
|
RECT rectParent;
|
2001-10-10 22:28:17 +02:00
|
|
|
HWND *list;
|
2001-06-04 23:55:17 +02:00
|
|
|
short x, y, xspacing, yspacing;
|
|
|
|
|
2001-10-10 22:28:17 +02:00
|
|
|
GetClientRect( wndPtr->parent, &rectParent );
|
2001-06-04 23:55:17 +02:00
|
|
|
if ((pt.x >= rectParent.left) && (pt.x + GetSystemMetrics(SM_CXICON) < rectParent.right) &&
|
|
|
|
(pt.y >= rectParent.top) && (pt.y + GetSystemMetrics(SM_CYICON) < rectParent.bottom))
|
|
|
|
return pt; /* The icon already has a suitable position */
|
|
|
|
|
|
|
|
xspacing = GetSystemMetrics(SM_CXICONSPACING);
|
|
|
|
yspacing = GetSystemMetrics(SM_CYICONSPACING);
|
|
|
|
|
2001-10-10 22:28:17 +02:00
|
|
|
list = WIN_ListChildren( wndPtr->parent );
|
2001-06-04 23:55:17 +02:00
|
|
|
y = rectParent.bottom;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
x = rectParent.left;
|
|
|
|
do
|
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
/* Check if another icon already occupies this spot */
|
|
|
|
/* FIXME: this is completely inefficient */
|
|
|
|
if (list)
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
int i;
|
|
|
|
WND *childPtr;
|
|
|
|
|
|
|
|
for (i = 0; list[i]; i++)
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
if (list[i] == wndPtr->hwndSelf) continue;
|
|
|
|
if (!IsIconic( list[i] )) continue;
|
|
|
|
if (!(childPtr = WIN_FindWndPtr( list[i] ))) continue;
|
2001-06-04 23:55:17 +02:00
|
|
|
if ((childPtr->rectWindow.left < x + xspacing) &&
|
|
|
|
(childPtr->rectWindow.right >= x) &&
|
|
|
|
(childPtr->rectWindow.top <= y) &&
|
|
|
|
(childPtr->rectWindow.bottom > y - yspacing))
|
2001-10-10 22:28:17 +02:00
|
|
|
{
|
|
|
|
WIN_ReleaseWndPtr( childPtr );
|
2001-06-04 23:55:17 +02:00
|
|
|
break; /* There's a window in there */
|
2001-10-10 22:28:17 +02:00
|
|
|
}
|
|
|
|
WIN_ReleaseWndPtr( childPtr );
|
|
|
|
}
|
|
|
|
if (list[i])
|
|
|
|
{
|
|
|
|
/* found something here, try next spot */
|
|
|
|
x += xspacing;
|
|
|
|
continue;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
}
|
2001-10-10 22:28:17 +02:00
|
|
|
|
|
|
|
/* No window was found, so it's OK for us */
|
|
|
|
pt.x = x + (xspacing - GetSystemMetrics(SM_CXICON)) / 2;
|
|
|
|
pt.y = y - (yspacing + GetSystemMetrics(SM_CYICON)) / 2;
|
2002-06-14 01:54:55 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, list );
|
2001-10-10 22:28:17 +02:00
|
|
|
return pt;
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
} while(x <= rectParent.right-xspacing);
|
|
|
|
y -= yspacing;
|
|
|
|
}
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
|
|
|
|
{
|
2001-10-16 23:58:58 +02:00
|
|
|
WND *wndPtr;
|
2001-06-04 23:55:17 +02:00
|
|
|
UINT swpFlags = 0;
|
|
|
|
POINT size;
|
2001-10-22 21:08:33 +02:00
|
|
|
LONG old_style;
|
2001-06-04 23:55:17 +02:00
|
|
|
WINDOWPLACEMENT wpl;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE("%p %u\n", hwnd, cmd );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
wpl.length = sizeof(wpl);
|
|
|
|
GetWindowPlacement( hwnd, &wpl );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2002-10-29 01:41:42 +01:00
|
|
|
if (HOOK_CallHooks( WH_CBT, HCBT_MINMAX, (WPARAM)hwnd, cmd, TRUE ))
|
2001-10-16 23:58:58 +02:00
|
|
|
return SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
|
|
|
|
if (IsIconic( hwnd ))
|
|
|
|
{
|
|
|
|
if (cmd == SW_MINIMIZE) return SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
if (!SendMessageA( hwnd, WM_QUERYOPEN, 0, 0 )) return SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
swpFlags |= SWP_NOCOPYBITS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
size.x = wndPtr->rectWindow.left;
|
|
|
|
size.y = wndPtr->rectWindow.top;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
switch( cmd )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2001-10-16 23:58:58 +02:00
|
|
|
case SW_MINIMIZE:
|
2001-10-22 21:08:33 +02:00
|
|
|
if( wndPtr->dwStyle & WS_MAXIMIZE) wndPtr->flags |= WIN_RESTORE_MAX;
|
|
|
|
else wndPtr->flags &= ~WIN_RESTORE_MAX;
|
|
|
|
|
|
|
|
WIN_SetStyle( hwnd, (wndPtr->dwStyle & ~WS_MAXIMIZE) | WS_MINIMIZE );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
X11DRV_set_iconic_state( wndPtr );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
wpl.ptMinPosition = WINPOS_FindIconPos( wndPtr, wpl.ptMinPosition );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
SetRect( rect, wpl.ptMinPosition.x, wpl.ptMinPosition.y,
|
|
|
|
GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
|
|
|
|
swpFlags |= SWP_NOCOPYBITS;
|
|
|
|
break;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
case SW_MAXIMIZE:
|
|
|
|
WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
old_style = WIN_SetStyle( hwnd, (wndPtr->dwStyle & ~WS_MINIMIZE) | WS_MAXIMIZE );
|
|
|
|
if (old_style & WS_MINIMIZE)
|
2001-10-16 23:58:58 +02:00
|
|
|
{
|
|
|
|
WINPOS_ShowIconTitle( hwnd, FALSE );
|
|
|
|
X11DRV_set_iconic_state( wndPtr );
|
|
|
|
}
|
|
|
|
SetRect( rect, wpl.ptMaxPosition.x, wpl.ptMaxPosition.y, size.x, size.y );
|
|
|
|
break;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
case SW_RESTORE:
|
2001-10-22 21:08:33 +02:00
|
|
|
old_style = WIN_SetStyle( hwnd, wndPtr->dwStyle & ~(WS_MINIMIZE|WS_MAXIMIZE) );
|
|
|
|
if (old_style & WS_MINIMIZE)
|
2001-10-16 23:58:58 +02:00
|
|
|
{
|
|
|
|
WINPOS_ShowIconTitle( hwnd, FALSE );
|
|
|
|
X11DRV_set_iconic_state( wndPtr );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
if( wndPtr->flags & WIN_RESTORE_MAX)
|
|
|
|
{
|
|
|
|
/* Restore to maximized position */
|
|
|
|
WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL);
|
2001-10-22 21:08:33 +02:00
|
|
|
WIN_SetStyle( hwnd, wndPtr->dwStyle | WS_MAXIMIZE );
|
2001-10-16 23:58:58 +02:00
|
|
|
SetRect( rect, wpl.ptMaxPosition.x, wpl.ptMaxPosition.y, size.x, size.y );
|
|
|
|
break;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2001-10-16 23:58:58 +02:00
|
|
|
}
|
2001-10-22 21:08:33 +02:00
|
|
|
else if (!(old_style & WS_MAXIMIZE)) break;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
/* Restore to normal position */
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
*rect = wpl.rcNormalPosition;
|
|
|
|
rect->right -= rect->left;
|
|
|
|
rect->bottom -= rect->top;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
break;
|
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
WIN_ReleaseWndPtr( wndPtr );
|
|
|
|
return swpFlags;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* ShowWindow (X11DRV.@)
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
2001-06-04 23:55:17 +02:00
|
|
|
BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
WND* wndPtr = WIN_FindWndPtr( hwnd );
|
2004-04-08 21:07:20 +02:00
|
|
|
BOOL wasVisible, showFlag;
|
2001-06-04 23:55:17 +02:00
|
|
|
RECT newPos = {0, 0, 0, 0};
|
|
|
|
UINT swp = 0;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
if (!wndPtr) return FALSE;
|
2001-09-14 02:24:39 +02:00
|
|
|
hwnd = wndPtr->hwndSelf; /* make it a full handle */
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
wasVisible = (wndPtr->dwStyle & WS_VISIBLE) != 0;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2004-06-14 21:32:21 +02:00
|
|
|
TRACE("hwnd=%p, cmd=%d, wasVisible %d\n", hwnd, cmd, wasVisible);
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
switch(cmd)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
case SW_HIDE:
|
2004-06-04 01:26:35 +02:00
|
|
|
if (!wasVisible) goto END;
|
2001-09-11 01:27:57 +02:00
|
|
|
swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
|
2001-06-04 23:55:17 +02:00
|
|
|
SWP_NOACTIVATE | SWP_NOZORDER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SW_SHOWMINNOACTIVE:
|
|
|
|
swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
|
|
|
/* fall through */
|
|
|
|
case SW_SHOWMINIMIZED:
|
2002-03-12 20:18:48 +01:00
|
|
|
case SW_FORCEMINIMIZE: /* FIXME: Does not work if thread is hung. */
|
2001-06-04 23:55:17 +02:00
|
|
|
swp |= SWP_SHOWWINDOW;
|
|
|
|
/* fall through */
|
|
|
|
case SW_MINIMIZE:
|
|
|
|
swp |= SWP_FRAMECHANGED;
|
|
|
|
if( !(wndPtr->dwStyle & WS_MINIMIZE) )
|
|
|
|
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;
|
|
|
|
if( !(wndPtr->dwStyle & WS_MAXIMIZE) )
|
|
|
|
swp |= WINPOS_MinMaximize( hwnd, SW_MAXIMIZE, &newPos );
|
|
|
|
else swp |= SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SW_SHOWNA:
|
|
|
|
swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
|
|
|
/* fall through */
|
|
|
|
case SW_SHOW:
|
2004-06-14 21:32:21 +02:00
|
|
|
if (wasVisible) goto END;
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SW_SHOWNOACTIVATE:
|
2002-04-25 00:26:34 +02:00
|
|
|
swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
2001-06-04 23:55:17 +02:00
|
|
|
/* fall through */
|
|
|
|
case SW_SHOWNORMAL: /* same as SW_NORMAL: */
|
|
|
|
case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
|
|
|
|
case SW_RESTORE:
|
|
|
|
swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
|
|
|
|
|
|
|
|
if( wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE) )
|
|
|
|
swp |= WINPOS_MinMaximize( hwnd, SW_RESTORE, &newPos );
|
|
|
|
else swp |= SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
break;
|
2004-04-08 21:07:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
showFlag = (cmd != SW_HIDE);
|
|
|
|
if (showFlag != wasVisible)
|
|
|
|
{
|
|
|
|
SendMessageW( hwnd, WM_SHOWWINDOW, showFlag, 0 );
|
|
|
|
if (!IsWindow( hwnd )) goto END;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/* We can't activate a child window */
|
|
|
|
if ((wndPtr->dwStyle & WS_CHILD) &&
|
|
|
|
!(wndPtr->dwExStyle & WS_EX_MDICHILD))
|
|
|
|
swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
SetWindowPos( hwnd, HWND_TOP, newPos.left, newPos.top,
|
|
|
|
newPos.right, newPos.bottom, LOWORD(swp) );
|
|
|
|
if (cmd == SW_HIDE)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2004-04-08 21:47:01 +02:00
|
|
|
HWND hFocus;
|
|
|
|
|
2001-06-04 23:55:17 +02: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.
|
|
|
|
*/
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
if (hwnd == GetActiveWindow())
|
2001-08-11 00:51:42 +02:00
|
|
|
WINPOS_ActivateOtherWindow(hwnd);
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/* Revert focus to parent */
|
2004-04-08 21:47:01 +02:00
|
|
|
hFocus = GetFocus();
|
|
|
|
if (hwnd == hFocus || IsChild(hwnd, hFocus))
|
|
|
|
{
|
|
|
|
HWND parent = GetAncestor(hwnd, GA_PARENT);
|
|
|
|
if (parent == GetDesktopWindow()) parent = 0;
|
|
|
|
SetFocus(parent);
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
if (!IsWindow( hwnd )) goto END;
|
2001-08-11 00:51:42 +02:00
|
|
|
else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( hwnd, TRUE );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
if (wndPtr->flags & WIN_NEED_SIZE)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
/* should happen only in CreateWindowEx() */
|
|
|
|
int wParam = SIZE_RESTORED;
|
|
|
|
|
|
|
|
wndPtr->flags &= ~WIN_NEED_SIZE;
|
|
|
|
if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED;
|
|
|
|
else if (wndPtr->dwStyle & WS_MINIMIZE) wParam = SIZE_MINIMIZED;
|
|
|
|
SendMessageA( hwnd, WM_SIZE, wParam,
|
|
|
|
MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
|
|
|
|
wndPtr->rectClient.bottom-wndPtr->rectClient.top));
|
|
|
|
SendMessageA( hwnd, WM_MOVE, 0,
|
|
|
|
MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top) );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
END:
|
|
|
|
WIN_ReleaseWndPtr(wndPtr);
|
|
|
|
return wasVisible;
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_MapNotify
|
|
|
|
*/
|
|
|
|
void X11DRV_MapNotify( HWND hwnd, XMapEvent *event )
|
|
|
|
{
|
|
|
|
HWND hwndFocus = GetFocus();
|
|
|
|
WND *win;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
if (!(win = WIN_GetPtr( hwnd ))) return;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
if ((win->dwStyle & WS_VISIBLE) &&
|
|
|
|
(win->dwStyle & WS_MINIMIZE) &&
|
|
|
|
(win->dwExStyle & WS_EX_MANAGED))
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
int x, y;
|
|
|
|
unsigned int width, height, border, depth;
|
|
|
|
Window root, top;
|
2001-04-25 01:28:52 +02:00
|
|
|
RECT rect;
|
2001-10-22 21:08:33 +02:00
|
|
|
LONG style = (win->dwStyle & ~(WS_MINIMIZE|WS_MAXIMIZE)) | WS_VISIBLE;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/* FIXME: hack */
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XGetGeometry( event->display, get_whole_window(win), &root, &x, &y, &width, &height,
|
|
|
|
&border, &depth );
|
|
|
|
XTranslateCoordinates( event->display, get_whole_window(win), root, 0, 0, &x, &y, &top );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
rect.left = x;
|
|
|
|
rect.top = y;
|
|
|
|
rect.right = x + width;
|
|
|
|
rect.bottom = y + height;
|
|
|
|
X11DRV_X_to_window_rect( win, &rect );
|
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
DCE_InvalidateDCE( hwnd, &win->rectWindow );
|
|
|
|
|
|
|
|
if (win->flags & WIN_RESTORE_MAX) style |= WS_MAXIMIZE;
|
|
|
|
WIN_SetStyle( hwnd, style );
|
|
|
|
WIN_ReleasePtr( win );
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
SendMessageA( hwnd, WM_SHOWWINDOW, SW_RESTORE, 0 );
|
|
|
|
SetWindowPos( hwnd, 0, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
|
|
|
|
SWP_NOZORDER | SWP_WINE_NOHOSTMOVE );
|
|
|
|
}
|
2001-10-22 21:08:33 +02:00
|
|
|
else WIN_ReleasePtr( win );
|
2001-06-04 23:55:17 +02:00
|
|
|
if (hwndFocus && IsChild( hwnd, hwndFocus )) X11DRV_SetFocus(hwndFocus); /* FIXME */
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_UnmapNotify
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
2001-06-04 23:55:17 +02:00
|
|
|
void X11DRV_UnmapNotify( HWND hwnd, XUnmapEvent *event )
|
|
|
|
{
|
|
|
|
WND *win;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
if (!(win = WIN_GetPtr( hwnd ))) return;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2004-04-28 01:32:01 +02:00
|
|
|
if ((win->dwStyle & WS_VISIBLE) && (win->dwExStyle & WS_EX_MANAGED) &&
|
|
|
|
X11DRV_is_window_rect_mapped( &win->rectWindow ))
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
if (win->dwStyle & WS_MAXIMIZE)
|
|
|
|
win->flags |= WIN_RESTORE_MAX;
|
2001-10-22 21:08:33 +02:00
|
|
|
else
|
|
|
|
win->flags &= ~WIN_RESTORE_MAX;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
WIN_SetStyle( hwnd, (win->dwStyle & ~WS_MAXIMIZE) | WS_MINIMIZE );
|
|
|
|
WIN_ReleasePtr( win );
|
|
|
|
|
|
|
|
EndMenu();
|
|
|
|
SendMessageA( hwnd, WM_SHOWWINDOW, SW_MINIMIZE, 0 );
|
2001-06-04 23:55:17 +02:00
|
|
|
SetWindowPos( hwnd, 0, 0, 0, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON),
|
|
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_WINE_NOHOSTMOVE );
|
|
|
|
}
|
2001-10-22 21:08:33 +02:00
|
|
|
else WIN_ReleasePtr( win );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* query_zorder
|
|
|
|
*
|
|
|
|
* Synchronize internal z-order with the window manager's.
|
|
|
|
*/
|
|
|
|
static Window __get_common_ancestor( Display *display, Window A, Window B,
|
|
|
|
Window** children, unsigned* total )
|
|
|
|
{
|
|
|
|
/* find the real root window */
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
Window root, *childrenB;
|
|
|
|
unsigned totalB;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
2001-06-04 23:55:17 +02:00
|
|
|
while( A != B && A && B )
|
|
|
|
{
|
2003-11-21 22:48:36 +01:00
|
|
|
XQueryTree( display, A, &root, &A, children, total );
|
|
|
|
XQueryTree( display, B, &root, &B, &childrenB, &totalB );
|
|
|
|
if( childrenB ) XFree( childrenB );
|
|
|
|
if( *children ) XFree( *children ), *children = NULL;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
if( A && B )
|
|
|
|
{
|
2003-11-21 22:48:36 +01:00
|
|
|
XQueryTree( display, A, &root, &B, children, total );
|
|
|
|
wine_tsx11_unlock();
|
2001-06-04 23:55:17 +02:00
|
|
|
return A;
|
|
|
|
}
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_unlock();
|
2001-06-04 23:55:17 +02:00
|
|
|
return 0 ;
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
static Window __get_top_decoration( Display *display, Window w, Window ancestor )
|
|
|
|
{
|
|
|
|
Window* children, root, prev = w, parent = w;
|
|
|
|
unsigned total;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
2001-06-04 23:55:17 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
w = parent;
|
2003-11-21 22:48:36 +01:00
|
|
|
XQueryTree( display, w, &root, &parent, &children, &total );
|
|
|
|
if( children ) XFree( children );
|
2001-06-04 23:55:17 +02:00
|
|
|
} while( parent && parent != ancestor );
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_unlock();
|
2001-06-04 23:55:17 +02:00
|
|
|
TRACE("\t%08x -> %08x\n", (unsigned)prev, (unsigned)w );
|
|
|
|
return ( parent ) ? w : 0 ;
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
static unsigned __td_lookup( Window w, Window* list, unsigned max )
|
|
|
|
{
|
|
|
|
unsigned i;
|
2002-06-22 00:25:17 +02:00
|
|
|
for( i = max; i > 0; i-- ) if( list[i - 1] == w ) break;
|
2001-06-04 23:55:17 +02:00
|
|
|
return i;
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
static HWND query_zorder( Display *display, HWND hWndCheck)
|
|
|
|
{
|
|
|
|
HWND hwndInsertAfter = HWND_TOP;
|
|
|
|
Window w, parent, *children = NULL;
|
|
|
|
unsigned total, check, pos, best;
|
2001-10-11 22:49:40 +02:00
|
|
|
HWND *list = WIN_ListChildren( GetDesktopWindow() );
|
|
|
|
HWND hwndA = 0, hwndB = 0;
|
|
|
|
int i;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2001-10-11 22:49:40 +02:00
|
|
|
/* find at least two managed windows */
|
|
|
|
if (!list) return 0;
|
|
|
|
for (i = 0; list[i]; i++)
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2001-12-17 23:09:18 +01:00
|
|
|
if (!(GetWindowLongW( list[i], GWL_EXSTYLE ) & WS_EX_MANAGED)) continue;
|
|
|
|
if (!(GetWindowLongW( list[i], GWL_STYLE ) & WS_VISIBLE)) continue;
|
|
|
|
if (!hwndA) hwndA = list[i];
|
|
|
|
else
|
2001-10-11 22:49:40 +02:00
|
|
|
{
|
2001-12-17 23:09:18 +01:00
|
|
|
hwndB = list[i];
|
|
|
|
break;
|
2001-10-11 22:49:40 +02:00
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2001-10-11 22:49:40 +02:00
|
|
|
if (!hwndA || !hwndB) goto done;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2001-10-11 22:49:40 +02:00
|
|
|
parent = __get_common_ancestor( display, X11DRV_get_whole_window(hwndA),
|
|
|
|
X11DRV_get_whole_window(hwndB), &children, &total );
|
2001-06-04 23:55:17 +02:00
|
|
|
if( parent && children )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-10-11 22:49:40 +02:00
|
|
|
/* w is the ancestor if hWndCheck that is a direct descendant of 'parent' */
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2001-10-11 22:49:40 +02:00
|
|
|
w = __get_top_decoration( display, X11DRV_get_whole_window(hWndCheck), parent );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
if( w != children[total-1] ) /* check if at the top */
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
/* X child at index 0 is at the bottom, at index total-1 is at the top */
|
|
|
|
check = __td_lookup( w, children, total );
|
|
|
|
best = total;
|
|
|
|
|
2001-10-11 22:49:40 +02:00
|
|
|
/* go through all windows in Wine z-order... */
|
|
|
|
for (i = 0; list[i]; i++)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-10-11 22:49:40 +02:00
|
|
|
if (list[i] == hWndCheck) continue;
|
|
|
|
if (!(GetWindowLongW( list[i], GWL_EXSTYLE ) & WS_EX_MANAGED)) continue;
|
|
|
|
if (!(w = __get_top_decoration( display, X11DRV_get_whole_window(list[i]),
|
|
|
|
parent ))) continue;
|
|
|
|
pos = __td_lookup( w, children, total );
|
|
|
|
if( pos < best && pos > check )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2001-10-11 22:49:40 +02:00
|
|
|
/* find a nearest Wine window precedes hWndCheck in the real z-order */
|
|
|
|
best = pos;
|
|
|
|
hwndInsertAfter = list[i];
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2001-10-11 22:49:40 +02:00
|
|
|
if( best - check == 1 ) break;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
if( children ) XFree( children );
|
|
|
|
wine_tsx11_unlock();
|
2001-10-11 22:49:40 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
HeapFree( GetProcessHeap(), 0, list );
|
2001-06-04 23:55:17 +02:00
|
|
|
return hwndInsertAfter;
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
|
2004-02-13 04:58:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_handle_desktop_resize
|
|
|
|
*/
|
|
|
|
void X11DRV_handle_desktop_resize( unsigned int width, unsigned int height )
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
HWND hwnd = GetDesktopWindow();
|
|
|
|
|
|
|
|
screen_width = width;
|
|
|
|
screen_height = height;
|
|
|
|
TRACE("desktop %p change to (%dx%d)\n", hwnd, width, height);
|
|
|
|
SetRect( &rect, 0, 0, width, height );
|
|
|
|
WIN_SetRectangles( hwnd, &rect, &rect );
|
|
|
|
SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_depth,
|
|
|
|
MAKELPARAM( width, height ), SMTO_ABORTIFHUNG, 2000, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_ConfigureNotify
|
|
|
|
*/
|
|
|
|
void X11DRV_ConfigureNotify( HWND hwnd, XConfigureEvent *event )
|
|
|
|
{
|
|
|
|
HWND oldInsertAfter;
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
WND *win;
|
|
|
|
RECT rect;
|
|
|
|
WINDOWPOS winpos;
|
|
|
|
int x = event->x, y = event->y;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-15 19:56:45 +02:00
|
|
|
if (!(win = WIN_GetPtr( hwnd ))) return;
|
2001-06-04 23:55:17 +02:00
|
|
|
data = win->pDriverData;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/* Get geometry */
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
if (!event->send_event) /* normal event, need to map coordinates to the root */
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
Window child;
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XTranslateCoordinates( event->display, data->whole_window, root_window,
|
|
|
|
0, 0, &x, &y, &child );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
rect.left = x;
|
|
|
|
rect.top = y;
|
|
|
|
rect.right = x + event->width;
|
|
|
|
rect.bottom = y + event->height;
|
2003-01-08 22:09:25 +01:00
|
|
|
TRACE( "win %p new X rect %ld,%ld,%ldx%ld (event %d,%d,%dx%d)\n",
|
2001-06-04 23:55:17 +02:00
|
|
|
hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
|
|
|
|
event->x, event->y, event->width, event->height );
|
|
|
|
X11DRV_X_to_window_rect( win, &rect );
|
2001-10-15 19:56:45 +02:00
|
|
|
WIN_ReleasePtr( win );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
winpos.hwnd = hwnd;
|
|
|
|
winpos.x = rect.left;
|
|
|
|
winpos.y = rect.top;
|
|
|
|
winpos.cx = rect.right - rect.left;
|
|
|
|
winpos.cy = rect.bottom - rect.top;
|
|
|
|
winpos.flags = SWP_NOACTIVATE;
|
|
|
|
|
|
|
|
/* Get Z-order (FIXME) */
|
|
|
|
|
|
|
|
winpos.hwndInsertAfter = query_zorder( event->display, hwnd );
|
|
|
|
|
|
|
|
/* needs to find the first Visible Window above the current one */
|
|
|
|
oldInsertAfter = hwnd;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
oldInsertAfter = GetWindow( oldInsertAfter, GW_HWNDPREV );
|
|
|
|
if (!oldInsertAfter)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
oldInsertAfter = HWND_TOP;
|
|
|
|
break;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
if (GetWindowLongA( oldInsertAfter, GWL_STYLE ) & WS_VISIBLE) break;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/* Compare what has changed */
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
GetWindowRect( hwnd, &rect );
|
|
|
|
if (rect.left == winpos.x && rect.top == winpos.y) winpos.flags |= SWP_NOMOVE;
|
|
|
|
else
|
2003-01-08 22:09:25 +01:00
|
|
|
TRACE( "%p moving from (%ld,%ld) to (%d,%d)\n",
|
2001-06-04 23:55:17 +02:00
|
|
|
hwnd, rect.left, rect.top, winpos.x, winpos.y );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-09-11 01:27:57 +02:00
|
|
|
if ((rect.right - rect.left == winpos.cx && rect.bottom - rect.top == winpos.cy) ||
|
2001-09-21 23:04:56 +02:00
|
|
|
IsIconic(hwnd) ||
|
2001-09-11 01:27:57 +02:00
|
|
|
(IsRectEmpty( &rect ) && winpos.cx == 1 && winpos.cy == 1))
|
|
|
|
winpos.flags |= SWP_NOSIZE;
|
2001-06-04 23:55:17 +02:00
|
|
|
else
|
2003-01-08 22:09:25 +01:00
|
|
|
TRACE( "%p resizing from (%ldx%ld) to (%dx%d)\n",
|
2001-06-04 23:55:17 +02:00
|
|
|
hwnd, rect.right - rect.left, rect.bottom - rect.top,
|
|
|
|
winpos.cx, winpos.cy );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
if (winpos.hwndInsertAfter == oldInsertAfter) winpos.flags |= SWP_NOZORDER;
|
|
|
|
else
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "%p restacking from after %p to after %p\n",
|
2001-06-04 23:55:17 +02:00
|
|
|
hwnd, oldInsertAfter, winpos.hwndInsertAfter );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/* if nothing changed, don't do anything */
|
|
|
|
if (winpos.flags == (SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE)) return;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
SetWindowPos( hwnd, winpos.hwndInsertAfter, winpos.x, winpos.y,
|
|
|
|
winpos.cx, winpos.cy, winpos.flags | SWP_WINE_NOHOSTMOVE );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetWindowRgn (X11DRV.@)
|
|
|
|
*
|
|
|
|
* Assign specified region to window (for non-rectangular windows)
|
|
|
|
*/
|
2001-10-22 21:08:33 +02:00
|
|
|
int X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-10-22 21:08:33 +02:00
|
|
|
WND *wndPtr;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
if ((wndPtr = WIN_GetPtr( hwnd )) == WND_OTHER_PROCESS)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-10-22 21:08:33 +02:00
|
|
|
if (IsWindow( hwnd ))
|
2002-10-31 03:38:20 +01:00
|
|
|
FIXME( "not supported on other process window %p\n", hwnd );
|
2001-10-22 21:08:33 +02:00
|
|
|
wndPtr = NULL;
|
|
|
|
}
|
|
|
|
if (!wndPtr)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
|
|
|
|
return FALSE;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXSHAPE
|
|
|
|
{
|
2001-05-16 21:52:29 +02:00
|
|
|
Display *display = thread_display();
|
2001-06-04 23:55:17 +02:00
|
|
|
X11DRV_WND_DATA *data = wndPtr->pDriverData;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
if (data->whole_window)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
|
|
|
if (!hrgn)
|
|
|
|
{
|
2002-09-24 05:17:31 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XShapeCombineMask( display, data->whole_window,
|
|
|
|
ShapeBounding, 0, 0, None, ShapeSet );
|
|
|
|
wine_tsx11_unlock();
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-06-29 01:54:22 +02:00
|
|
|
RGNDATA *pRegionData = X11DRV_GetRegionData( hrgn, 0 );
|
|
|
|
if (pRegionData)
|
2001-10-22 21:08:33 +02:00
|
|
|
{
|
2002-09-24 05:17:31 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XShapeCombineRectangles( display, data->whole_window, ShapeBounding,
|
2004-06-29 01:54:22 +02:00
|
|
|
wndPtr->rectWindow.left - data->whole_rect.left,
|
|
|
|
wndPtr->rectWindow.top - data->whole_rect.top,
|
|
|
|
(XRectangle *)pRegionData->Buffer,
|
|
|
|
pRegionData->rdh.nCount,
|
|
|
|
ShapeSet, YXBanded );
|
2002-09-24 05:17:31 +02:00
|
|
|
wine_tsx11_unlock();
|
2004-06-29 01:54:22 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, pRegionData);
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* HAVE_LIBXSHAPE */
|
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
WIN_ReleasePtr( wndPtr );
|
|
|
|
return TRUE;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* draw_moving_frame
|
|
|
|
*
|
|
|
|
* Draw the frame used when moving or resizing window.
|
|
|
|
*
|
|
|
|
* FIXME: This causes problems in Win95 mode. (why?)
|
|
|
|
*/
|
|
|
|
static void draw_moving_frame( HDC hdc, RECT *rect, BOOL thickframe )
|
|
|
|
{
|
|
|
|
if (thickframe)
|
|
|
|
{
|
|
|
|
const int width = GetSystemMetrics(SM_CXFRAME);
|
|
|
|
const int height = GetSystemMetrics(SM_CYFRAME);
|
|
|
|
|
|
|
|
HBRUSH hbrush = SelectObject( hdc, GetStockObject( GRAY_BRUSH ) );
|
|
|
|
PatBlt( hdc, rect->left, rect->top,
|
|
|
|
rect->right - rect->left - width, height, PATINVERT );
|
|
|
|
PatBlt( hdc, rect->left, rect->top + height, width,
|
|
|
|
rect->bottom - rect->top - height, PATINVERT );
|
|
|
|
PatBlt( hdc, rect->left + width, rect->bottom - 1,
|
|
|
|
rect->right - rect->left - width, -height, PATINVERT );
|
|
|
|
PatBlt( hdc, rect->right - 1, rect->top, -width,
|
|
|
|
rect->bottom - rect->top - height, PATINVERT );
|
|
|
|
SelectObject( hdc, hbrush );
|
|
|
|
}
|
|
|
|
else DrawFocusRect( hdc, rect );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* start_size_move
|
|
|
|
*
|
|
|
|
* Initialisation of a move or resize, when initiatied from a menu choice.
|
|
|
|
* Return hit test code for caption or sizing border.
|
|
|
|
*/
|
2001-08-18 20:08:26 +02:00
|
|
|
static LONG start_size_move( HWND hwnd, WPARAM wParam, POINT *capturePoint, LONG style )
|
2001-05-09 19:21:04 +02:00
|
|
|
{
|
|
|
|
LONG hittest = 0;
|
|
|
|
POINT pt;
|
|
|
|
MSG msg;
|
|
|
|
RECT rectWindow;
|
|
|
|
|
2001-08-18 20:08:26 +02:00
|
|
|
GetWindowRect( hwnd, &rectWindow );
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
if ((wParam & 0xfff0) == SC_MOVE)
|
|
|
|
{
|
|
|
|
/* Move pointer at the center of the caption */
|
|
|
|
RECT rect;
|
2001-08-18 20:08:26 +02:00
|
|
|
NC_GetInsideRect( hwnd, &rect );
|
|
|
|
if (style & WS_SYSMENU)
|
2001-05-09 19:21:04 +02:00
|
|
|
rect.left += GetSystemMetrics(SM_CXSIZE) + 1;
|
2001-08-18 20:08:26 +02:00
|
|
|
if (style & WS_MINIMIZEBOX)
|
2001-05-09 19:21:04 +02:00
|
|
|
rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
|
2001-08-18 20:08:26 +02:00
|
|
|
if (style & WS_MAXIMIZEBOX)
|
2001-05-09 19:21:04 +02:00
|
|
|
rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
|
|
|
|
pt.x = rectWindow.left + (rect.right - rect.left) / 2;
|
|
|
|
pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2;
|
|
|
|
hittest = HTCAPTION;
|
|
|
|
*capturePoint = pt;
|
|
|
|
}
|
|
|
|
else /* SC_SIZE */
|
|
|
|
{
|
|
|
|
while(!hittest)
|
|
|
|
{
|
2001-08-06 20:05:47 +02:00
|
|
|
GetMessageW( &msg, 0, WM_KEYFIRST, WM_MOUSELAST );
|
|
|
|
if (CallMsgFilterW( &msg, MSGF_SIZE )) continue;
|
|
|
|
|
2001-05-09 19:21:04 +02:00
|
|
|
switch(msg.message)
|
|
|
|
{
|
|
|
|
case WM_MOUSEMOVE:
|
2001-08-18 20:08:26 +02:00
|
|
|
hittest = NC_HandleNCHitTest( hwnd, msg.pt );
|
2001-05-09 19:21:04 +02:00
|
|
|
if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
|
|
|
|
hittest = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
switch(msg.wParam)
|
|
|
|
{
|
|
|
|
case VK_UP:
|
|
|
|
hittest = HTTOP;
|
|
|
|
pt.x =(rectWindow.left+rectWindow.right)/2;
|
|
|
|
pt.y = rectWindow.top + GetSystemMetrics(SM_CYFRAME) / 2;
|
|
|
|
break;
|
|
|
|
case VK_DOWN:
|
|
|
|
hittest = HTBOTTOM;
|
|
|
|
pt.x =(rectWindow.left+rectWindow.right)/2;
|
|
|
|
pt.y = rectWindow.bottom - GetSystemMetrics(SM_CYFRAME) / 2;
|
|
|
|
break;
|
|
|
|
case VK_LEFT:
|
|
|
|
hittest = HTLEFT;
|
|
|
|
pt.x = rectWindow.left + GetSystemMetrics(SM_CXFRAME) / 2;
|
|
|
|
pt.y =(rectWindow.top+rectWindow.bottom)/2;
|
|
|
|
break;
|
|
|
|
case VK_RIGHT:
|
|
|
|
hittest = HTRIGHT;
|
|
|
|
pt.x = rectWindow.right - GetSystemMetrics(SM_CXFRAME) / 2;
|
|
|
|
pt.y =(rectWindow.top+rectWindow.bottom)/2;
|
|
|
|
break;
|
|
|
|
case VK_RETURN:
|
|
|
|
case VK_ESCAPE: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*capturePoint = pt;
|
|
|
|
}
|
|
|
|
SetCursorPos( pt.x, pt.y );
|
2001-09-19 22:37:04 +02:00
|
|
|
NC_HandleSetCursor( hwnd, (WPARAM)hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
|
2001-05-09 19:21:04 +02:00
|
|
|
return hittest;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-12 03:24:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* set_movesize_capture
|
|
|
|
*/
|
|
|
|
static void set_movesize_capture( HWND hwnd )
|
|
|
|
{
|
|
|
|
HWND previous = 0;
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_capture_window )
|
|
|
|
{
|
|
|
|
req->handle = hwnd;
|
|
|
|
req->flags = CAPTURE_MOVESIZE;
|
|
|
|
if (!wine_server_call_err( req ))
|
|
|
|
{
|
|
|
|
previous = reply->previous;
|
|
|
|
hwnd = reply->full_handle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
if (previous && previous != hwnd)
|
|
|
|
SendMessageW( previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-09 19:21:04 +02:00
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* SysCommandSizeMove (X11DRV.@)
|
2001-05-09 19:21:04 +02:00
|
|
|
*
|
|
|
|
* Perform SC_MOVE and SC_SIZE commands.
|
|
|
|
*/
|
|
|
|
void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
RECT sizingRect, mouseRect, origRect;
|
|
|
|
HDC hdc;
|
2001-08-18 20:08:26 +02:00
|
|
|
HWND parent;
|
2001-05-09 19:21:04 +02:00
|
|
|
LONG hittest = (LONG)(wParam & 0x0f);
|
2002-10-10 23:22:09 +02:00
|
|
|
HCURSOR hDragCursor = 0, hOldCursor = 0;
|
2001-05-09 19:21:04 +02:00
|
|
|
POINT minTrack, maxTrack;
|
|
|
|
POINT capturePoint, pt;
|
2001-08-18 20:08:26 +02:00
|
|
|
LONG style = GetWindowLongA( hwnd, GWL_STYLE );
|
|
|
|
LONG exstyle = GetWindowLongA( hwnd, GWL_EXSTYLE );
|
|
|
|
BOOL thickframe = HAS_THICKFRAME( style, exstyle );
|
|
|
|
BOOL iconic = style & WS_MINIMIZE;
|
2001-05-09 19:21:04 +02:00
|
|
|
BOOL moved = FALSE;
|
|
|
|
DWORD dwPoint = GetMessagePos ();
|
|
|
|
BOOL DragFullWindows = FALSE;
|
2001-05-16 21:52:29 +02:00
|
|
|
BOOL grab;
|
2001-05-09 19:21:04 +02:00
|
|
|
int iWndsLocks;
|
2001-05-16 21:52:29 +02:00
|
|
|
Display *old_gdi_display = NULL;
|
|
|
|
Display *display = thread_display();
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0);
|
|
|
|
|
2003-09-17 06:28:28 +02:00
|
|
|
pt.x = (short)LOWORD(dwPoint);
|
|
|
|
pt.y = (short)HIWORD(dwPoint);
|
2001-05-09 19:21:04 +02:00
|
|
|
capturePoint = pt;
|
|
|
|
|
2001-08-18 20:08:26 +02:00
|
|
|
if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) || (exstyle & WS_EX_MANAGED)) return;
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
if ((wParam & 0xfff0) == SC_MOVE)
|
|
|
|
{
|
2001-08-18 20:08:26 +02:00
|
|
|
if (!hittest) hittest = start_size_move( hwnd, wParam, &capturePoint, style );
|
|
|
|
if (!hittest) return;
|
2001-05-09 19:21:04 +02:00
|
|
|
}
|
|
|
|
else /* SC_SIZE */
|
|
|
|
{
|
2001-08-18 20:08:26 +02:00
|
|
|
if (!thickframe) return;
|
2003-02-19 00:24:57 +01:00
|
|
|
if ( hittest && ((wParam & 0xfff0) != SC_MOUSEMENU) )
|
|
|
|
hittest += (HTLEFT - WMSZ_LEFT);
|
2001-05-09 19:21:04 +02:00
|
|
|
else
|
|
|
|
{
|
2002-10-12 03:24:37 +02:00
|
|
|
set_movesize_capture( hwnd );
|
2001-08-18 20:08:26 +02:00
|
|
|
hittest = start_size_move( hwnd, wParam, &capturePoint, style );
|
2001-05-09 19:21:04 +02:00
|
|
|
if (!hittest)
|
|
|
|
{
|
2002-10-12 03:24:37 +02:00
|
|
|
set_movesize_capture(0);
|
2001-08-18 20:08:26 +02:00
|
|
|
return;
|
2001-05-09 19:21:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get min/max info */
|
|
|
|
|
2001-08-11 00:51:42 +02:00
|
|
|
WINPOS_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack );
|
2001-08-18 20:08:26 +02:00
|
|
|
GetWindowRect( hwnd, &sizingRect );
|
|
|
|
if (style & WS_CHILD)
|
|
|
|
{
|
|
|
|
parent = GetParent(hwnd);
|
|
|
|
/* make sizing rect relative to parent */
|
|
|
|
MapWindowPoints( 0, parent, (POINT*)&sizingRect, 2 );
|
|
|
|
GetClientRect( parent, &mouseRect );
|
|
|
|
}
|
2001-05-09 19:21:04 +02:00
|
|
|
else
|
2001-08-18 20:08:26 +02:00
|
|
|
{
|
|
|
|
parent = 0;
|
2001-05-09 19:21:04 +02:00
|
|
|
SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
|
2001-08-18 20:08:26 +02:00
|
|
|
}
|
|
|
|
origRect = sizingRect;
|
|
|
|
|
2001-05-09 19:21:04 +02:00
|
|
|
if (ON_LEFT_BORDER(hittest))
|
|
|
|
{
|
|
|
|
mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x );
|
|
|
|
mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x );
|
|
|
|
}
|
|
|
|
else if (ON_RIGHT_BORDER(hittest))
|
|
|
|
{
|
|
|
|
mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x );
|
|
|
|
mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x );
|
|
|
|
}
|
|
|
|
if (ON_TOP_BORDER(hittest))
|
|
|
|
{
|
|
|
|
mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y );
|
|
|
|
mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y);
|
|
|
|
}
|
|
|
|
else if (ON_BOTTOM_BORDER(hittest))
|
|
|
|
{
|
|
|
|
mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y );
|
|
|
|
mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y );
|
|
|
|
}
|
2001-08-18 20:08:26 +02:00
|
|
|
if (parent) MapWindowPoints( parent, 0, (LPPOINT)&mouseRect, 2 );
|
2001-05-09 19:21:04 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/* Retrieve a default cache DC (without using the window style) */
|
2001-08-18 20:08:26 +02:00
|
|
|
hdc = GetDCEx( parent, 0, DCX_CACHE );
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
if( iconic ) /* create a cursor for dragging */
|
|
|
|
{
|
2002-10-10 23:22:09 +02:00
|
|
|
hDragCursor = (HCURSOR)GetClassLongA( hwnd, GCL_HICON);
|
2002-06-02 23:29:23 +02:00
|
|
|
if( !hDragCursor ) hDragCursor = (HCURSOR)SendMessageA( hwnd, WM_QUERYDRAGICON, 0, 0L);
|
2001-05-09 19:21:04 +02:00
|
|
|
if( !hDragCursor ) iconic = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* repaint the window before moving it around */
|
|
|
|
RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
SendMessageA( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
|
2002-10-12 03:24:37 +02:00
|
|
|
set_movesize_capture( hwnd );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2001-05-09 19:21:04 +02:00
|
|
|
/* grab the server only when moving top-level windows without desktop */
|
2001-08-18 20:08:26 +02:00
|
|
|
grab = (!DragFullWindows && !parent && (root_window == DefaultRootWindow(gdi_display)));
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
wine_tsx11_lock();
|
2001-05-16 21:52:29 +02:00
|
|
|
if (grab)
|
|
|
|
{
|
|
|
|
XSync( gdi_display, False );
|
|
|
|
XGrabServer( display );
|
2001-06-04 23:55:17 +02:00
|
|
|
XSync( display, False );
|
2001-05-16 21:52:29 +02:00
|
|
|
/* switch gdi display to the thread display, since the server is grabbed */
|
|
|
|
old_gdi_display = gdi_display;
|
|
|
|
gdi_display = display;
|
|
|
|
}
|
2001-08-18 20:08:26 +02:00
|
|
|
XGrabPointer( display, X11DRV_get_whole_window(hwnd), False,
|
2001-06-04 23:55:17 +02:00
|
|
|
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
|
2001-08-18 20:08:26 +02:00
|
|
|
GrabModeAsync, GrabModeAsync,
|
|
|
|
parent ? X11DRV_get_client_window(parent) : root_window,
|
2001-06-04 23:55:17 +02:00
|
|
|
None, CurrentTime );
|
|
|
|
wine_tsx11_unlock();
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
int dx = 0, dy = 0;
|
|
|
|
|
2001-08-06 20:05:47 +02:00
|
|
|
if (!GetMessageW( &msg, 0, WM_KEYFIRST, WM_MOUSELAST )) break;
|
|
|
|
if (CallMsgFilterW( &msg, MSGF_SIZE )) continue;
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
/* Exit on button-up, Return, or Esc */
|
|
|
|
if ((msg.message == WM_LBUTTONUP) ||
|
|
|
|
((msg.message == WM_KEYDOWN) &&
|
|
|
|
((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
|
|
|
|
|
|
|
|
if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE))
|
|
|
|
continue; /* We are not interested in other messages */
|
|
|
|
|
|
|
|
pt = msg.pt;
|
|
|
|
|
|
|
|
if (msg.message == WM_KEYDOWN) switch(msg.wParam)
|
|
|
|
{
|
|
|
|
case VK_UP: pt.y -= 8; break;
|
|
|
|
case VK_DOWN: pt.y += 8; break;
|
|
|
|
case VK_LEFT: pt.x -= 8; break;
|
|
|
|
case VK_RIGHT: pt.x += 8; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pt.x = max( pt.x, mouseRect.left );
|
|
|
|
pt.x = min( pt.x, mouseRect.right );
|
|
|
|
pt.y = max( pt.y, mouseRect.top );
|
|
|
|
pt.y = min( pt.y, mouseRect.bottom );
|
|
|
|
|
|
|
|
dx = pt.x - capturePoint.x;
|
|
|
|
dy = pt.y - capturePoint.y;
|
|
|
|
|
|
|
|
if (dx || dy)
|
|
|
|
{
|
|
|
|
if( !moved )
|
|
|
|
{
|
|
|
|
moved = TRUE;
|
|
|
|
|
|
|
|
if( iconic ) /* ok, no system popup tracking */
|
|
|
|
{
|
|
|
|
hOldCursor = SetCursor(hDragCursor);
|
|
|
|
ShowCursor( TRUE );
|
2001-08-11 00:51:42 +02:00
|
|
|
WINPOS_ShowIconTitle( hwnd, FALSE );
|
2001-05-09 19:21:04 +02:00
|
|
|
}
|
|
|
|
else if(!DragFullWindows)
|
|
|
|
draw_moving_frame( hdc, &sizingRect, thickframe );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RECT newRect = sizingRect;
|
|
|
|
WPARAM wpSizingHit = 0;
|
|
|
|
|
|
|
|
if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy );
|
|
|
|
if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
|
|
|
|
else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
|
|
|
|
if (ON_TOP_BORDER(hittest)) newRect.top += dy;
|
|
|
|
else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
|
|
|
|
if(!iconic && !DragFullWindows) draw_moving_frame( hdc, &sizingRect, thickframe );
|
|
|
|
capturePoint = pt;
|
|
|
|
|
|
|
|
/* determine the hit location */
|
|
|
|
if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT)
|
|
|
|
wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT);
|
|
|
|
SendMessageA( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect );
|
|
|
|
|
|
|
|
if (!iconic)
|
|
|
|
{
|
|
|
|
if(!DragFullWindows)
|
|
|
|
draw_moving_frame( hdc, &newRect, thickframe );
|
|
|
|
else {
|
|
|
|
/* To avoid any deadlocks, all the locks on the windows
|
|
|
|
structures must be suspended before the SetWindowPos */
|
|
|
|
iWndsLocks = WIN_SuspendWndsLock();
|
|
|
|
SetWindowPos( hwnd, 0, newRect.left, newRect.top,
|
|
|
|
newRect.right - newRect.left,
|
|
|
|
newRect.bottom - newRect.top,
|
|
|
|
( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
|
|
|
|
WIN_RestoreWndsLock(iWndsLocks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sizingRect = newRect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-12 03:24:37 +02:00
|
|
|
set_movesize_capture(0);
|
2001-05-09 19:21:04 +02:00
|
|
|
if( iconic )
|
|
|
|
{
|
|
|
|
if( moved ) /* restore cursors, show icon title later on */
|
|
|
|
{
|
|
|
|
ShowCursor( FALSE );
|
|
|
|
SetCursor( hOldCursor );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (moved && !DragFullWindows)
|
|
|
|
draw_moving_frame( hdc, &sizingRect, thickframe );
|
|
|
|
|
2001-08-18 20:08:26 +02:00
|
|
|
ReleaseDC( parent, hdc );
|
2001-05-09 19:21:04 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XUngrabPointer( display, CurrentTime );
|
2001-05-16 21:52:29 +02:00
|
|
|
if (grab)
|
|
|
|
{
|
|
|
|
XSync( display, False );
|
|
|
|
XUngrabServer( display );
|
2001-06-04 23:55:17 +02:00
|
|
|
XSync( display, False );
|
2001-05-16 21:52:29 +02:00
|
|
|
gdi_display = old_gdi_display;
|
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
wine_tsx11_unlock();
|
2001-05-09 19:21:04 +02:00
|
|
|
|
2002-10-29 01:41:42 +01:00
|
|
|
if (HOOK_CallHooks( WH_CBT, HCBT_MOVESIZE, (WPARAM)hwnd, (LPARAM)&sizingRect, TRUE ))
|
|
|
|
moved = FALSE;
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 );
|
|
|
|
SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L);
|
|
|
|
|
|
|
|
/* window moved or resized */
|
|
|
|
if (moved)
|
|
|
|
{
|
|
|
|
/* To avoid any deadlocks, all the locks on the windows
|
|
|
|
structures must be suspended before the SetWindowPos */
|
|
|
|
iWndsLocks = WIN_SuspendWndsLock();
|
|
|
|
|
|
|
|
/* if the moving/resizing isn't canceled call SetWindowPos
|
|
|
|
* with the new position or the new size of the window
|
|
|
|
*/
|
|
|
|
if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
|
|
|
|
{
|
|
|
|
/* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
|
|
|
|
if(!DragFullWindows)
|
|
|
|
SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top,
|
|
|
|
sizingRect.right - sizingRect.left,
|
|
|
|
sizingRect.bottom - sizingRect.top,
|
|
|
|
( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* restore previous size/position */
|
|
|
|
if(DragFullWindows)
|
|
|
|
SetWindowPos( hwnd, 0, origRect.left, origRect.top,
|
|
|
|
origRect.right - origRect.left,
|
|
|
|
origRect.bottom - origRect.top,
|
|
|
|
( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
WIN_RestoreWndsLock(iWndsLocks);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsIconic(hwnd))
|
|
|
|
{
|
|
|
|
/* Single click brings up the system menu when iconized */
|
|
|
|
|
|
|
|
if( !moved )
|
|
|
|
{
|
2001-08-18 20:08:26 +02:00
|
|
|
if(style & WS_SYSMENU )
|
2001-05-09 19:21:04 +02:00
|
|
|
SendMessageA( hwnd, WM_SYSCOMMAND,
|
|
|
|
SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y));
|
|
|
|
}
|
2001-08-11 00:51:42 +02:00
|
|
|
else WINPOS_ShowIconTitle( hwnd, TRUE );
|
2001-05-09 19:21:04 +02:00
|
|
|
}
|
|
|
|
}
|
2001-06-29 03:26:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* ForceWindowRaise (X11DRV.@)
|
2001-06-29 03:26:41 +02:00
|
|
|
*
|
2001-09-11 01:27:57 +02:00
|
|
|
* Raise a window on top of the X stacking order, while preserving
|
2001-06-29 03:26:41 +02:00
|
|
|
* the correct Windows Z order.
|
|
|
|
*
|
|
|
|
* FIXME: this should go away.
|
|
|
|
*/
|
|
|
|
void X11DRV_ForceWindowRaise( HWND hwnd )
|
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
int i = 0;
|
|
|
|
HWND *list;
|
2001-06-29 03:26:41 +02:00
|
|
|
XWindowChanges winChanges;
|
|
|
|
Display *display = thread_display();
|
2001-10-10 22:28:17 +02:00
|
|
|
WND *wndPtr = WIN_FindWndPtr( hwnd );
|
2001-06-29 03:26:41 +02:00
|
|
|
|
|
|
|
if (!wndPtr) return;
|
|
|
|
|
|
|
|
if ((wndPtr->dwExStyle & WS_EX_MANAGED) ||
|
2001-10-10 22:28:17 +02:00
|
|
|
wndPtr->parent != GetDesktopWindow() ||
|
2001-06-29 03:26:41 +02:00
|
|
|
IsRectEmpty( &wndPtr->rectWindow ) ||
|
|
|
|
!get_whole_window(wndPtr))
|
|
|
|
{
|
|
|
|
WIN_ReleaseWndPtr( wndPtr );
|
|
|
|
return;
|
|
|
|
}
|
2001-10-10 22:28:17 +02:00
|
|
|
WIN_ReleaseWndPtr( wndPtr );
|
2001-06-29 03:26:41 +02:00
|
|
|
|
|
|
|
/* Raise all windows up to wndPtr according to their Z order.
|
|
|
|
* (it would be easier with sibling-related Below but it doesn't
|
|
|
|
* work very well with SGI mwm for instance)
|
|
|
|
*/
|
|
|
|
winChanges.stack_mode = Above;
|
2001-10-10 22:28:17 +02:00
|
|
|
if (!(list = WIN_ListChildren( GetDesktopWindow() ))) return;
|
|
|
|
while (list[i] && list[i] != hwnd) i++;
|
|
|
|
if (list[i])
|
2001-06-29 03:26:41 +02:00
|
|
|
{
|
2001-10-10 22:28:17 +02:00
|
|
|
for ( ; i >= 0; i--)
|
|
|
|
{
|
|
|
|
WND *ptr = WIN_FindWndPtr( list[i] );
|
|
|
|
if (!ptr) continue;
|
|
|
|
if (!IsRectEmpty( &ptr->rectWindow ) && get_whole_window(ptr))
|
2003-11-21 01:17:33 +01:00
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XReconfigureWMWindow( display, get_whole_window(ptr), 0, CWStackMode, &winChanges );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
2001-10-10 22:28:17 +02:00
|
|
|
WIN_ReleaseWndPtr( ptr );
|
|
|
|
}
|
2001-06-29 03:26:41 +02:00
|
|
|
}
|
2001-10-10 22:28:17 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, list );
|
2001-06-29 03:26:41 +02:00
|
|
|
}
|