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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-11-21 22:48:36 +01:00
|
|
|
#include <X11/Xlib.h>
|
2006-06-19 22:36:51 +02:00
|
|
|
#include <X11/Xutil.h>
|
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"
|
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"
|
|
|
|
|
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_NOPOSCHANGE \
|
2005-02-03 14:40:12 +01:00
|
|
|
(SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOZORDER)
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
#define SWP_EX_NOCOPY 0x0001
|
|
|
|
#define SWP_EX_PAINTSELF 0x0002
|
|
|
|
#define SWP_EX_NONCLIENT 0x0004
|
|
|
|
|
2005-02-01 19:53:59 +01:00
|
|
|
#define HAS_THICKFRAME(style) \
|
2001-05-09 19:21:04 +02:00
|
|
|
(((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
|
|
|
|
2004-08-19 01:47:48 +02:00
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_TOP 1
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_LEFT 7
|
|
|
|
#define _NET_WM_MOVERESIZE_MOVE 8 /* movement only */
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */
|
|
|
|
#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */
|
|
|
|
|
2006-06-19 19:25:54 +02:00
|
|
|
#define _NET_WM_STATE_REMOVE 0
|
|
|
|
#define _NET_WM_STATE_ADD 1
|
|
|
|
#define _NET_WM_STATE_TOGGLE 2
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2007-08-20 22:06:33 +02:00
|
|
|
static const char managed_prop[] = "__wine_x11_managed";
|
|
|
|
|
2001-06-22 05:42:27 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_Expose
|
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
void X11DRV_Expose( HWND hwnd, XEvent *xev )
|
2001-06-22 05:42:27 +02:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XExposeEvent *event = &xev->xexpose;
|
2001-06-22 05:42:27 +02:00
|
|
|
RECT rect;
|
|
|
|
struct x11drv_win_data *data;
|
2005-01-31 17:34:07 +01:00
|
|
|
int flags = RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN;
|
2001-06-22 05:42:27 +02:00
|
|
|
|
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 );
|
|
|
|
|
2005-01-17 20:17:47 +01:00
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
|
|
|
|
2008-01-22 20:08:56 +01:00
|
|
|
rect.left = data->whole_rect.left + event->x;
|
|
|
|
rect.top = data->whole_rect.top + event->y;
|
2001-06-22 05:42:27 +02:00
|
|
|
rect.right = rect.left + event->width;
|
|
|
|
rect.bottom = rect.top + event->height;
|
|
|
|
|
2006-10-26 12:53:59 +02:00
|
|
|
if (event->window == root_window)
|
|
|
|
OffsetRect( &rect, virtual_screen_rect.left, virtual_screen_rect.top );
|
|
|
|
|
2005-01-31 17:34:07 +01:00
|
|
|
if (rect.left < data->client_rect.left ||
|
|
|
|
rect.top < data->client_rect.top ||
|
|
|
|
rect.right > data->client_rect.right ||
|
|
|
|
rect.bottom > data->client_rect.bottom) flags |= RDW_FRAME;
|
2001-10-10 22:28:17 +02:00
|
|
|
|
2005-03-21 13:37:00 +01:00
|
|
|
SERVER_START_REQ( update_window_zorder )
|
|
|
|
{
|
|
|
|
req->window = hwnd;
|
2008-01-22 20:08:56 +01:00
|
|
|
req->rect.left = rect.left;
|
|
|
|
req->rect.top = rect.top;
|
|
|
|
req->rect.right = rect.right;
|
|
|
|
req->rect.bottom = rect.bottom;
|
2005-03-21 13:37:00 +01:00
|
|
|
wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2008-01-22 20:08:56 +01:00
|
|
|
/* make position relative to client area instead of parent */
|
2005-01-31 17:34:07 +01:00
|
|
|
OffsetRect( &rect, -data->client_rect.left, -data->client_rect.top );
|
|
|
|
RedrawWindow( hwnd, &rect, 0, flags );
|
2001-06-22 05:42:27 +02:00
|
|
|
}
|
|
|
|
|
2001-10-03 20:44:02 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetWindowStyle (X11DRV.@)
|
|
|
|
*
|
|
|
|
* Update the X state of a window to reflect a style change
|
|
|
|
*/
|
2005-01-17 20:17:47 +01:00
|
|
|
void X11DRV_SetWindowStyle( HWND hwnd, DWORD old_style )
|
2001-10-03 20:44:02 +02:00
|
|
|
{
|
|
|
|
Display *display = thread_display();
|
2005-01-17 20:17:47 +01:00
|
|
|
struct x11drv_win_data *data;
|
|
|
|
DWORD new_style, changed;
|
2001-10-03 20:44:02 +02:00
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
if (hwnd == GetDesktopWindow()) return;
|
2005-01-17 20:17:47 +01:00
|
|
|
new_style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
changed = new_style ^ old_style;
|
2001-10-22 21:08:33 +02:00
|
|
|
|
|
|
|
if (changed & WS_VISIBLE)
|
2001-10-03 20:44:02 +02:00
|
|
|
{
|
2008-01-25 12:07:11 +01:00
|
|
|
data = X11DRV_get_win_data( hwnd );
|
|
|
|
if (data) invalidate_dce( hwnd, &data->window_rect );
|
|
|
|
|
|
|
|
/* we don't unmap windows, that causes trouble with the window manager */
|
|
|
|
if (!(new_style & WS_VISIBLE)) return;
|
2008-01-24 10:20:51 +01:00
|
|
|
|
2008-01-25 12:07:11 +01:00
|
|
|
if (!data && !(data = X11DRV_create_win_data( hwnd ))) return;
|
|
|
|
|
|
|
|
if (data->whole_window && X11DRV_is_window_rect_mapped( &data->window_rect ))
|
2001-10-03 20:44:02 +02:00
|
|
|
{
|
2008-01-23 12:28:32 +01:00
|
|
|
X11DRV_set_wm_hints( display, data );
|
|
|
|
if (!data->mapped)
|
2001-10-22 21:08:33 +02:00
|
|
|
{
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "mapping win %p\n", hwnd );
|
2005-01-31 17:34:07 +01:00
|
|
|
X11DRV_sync_window_style( display, data );
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_lock();
|
2005-01-17 20:17:47 +01:00
|
|
|
XMapWindow( display, data->whole_window );
|
2003-11-21 22:48:36 +01:00
|
|
|
wine_tsx11_unlock();
|
2008-01-23 12:28:32 +01:00
|
|
|
data->mapped = TRUE;
|
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)
|
|
|
|
{
|
2008-01-24 10:20:51 +01:00
|
|
|
data = X11DRV_get_win_data( hwnd );
|
|
|
|
if (data && data->wm_hints)
|
2001-10-22 21:08:33 +02:00
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
2007-08-16 23:27:37 +02:00
|
|
|
data->wm_hints->input = !(new_style & WS_DISABLED);
|
|
|
|
XSetWMHints( display, data->whole_window, data->wm_hints );
|
2001-10-22 21:08:33 +02:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
}
|
2001-10-03 20:44:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-19 19:25:54 +02:00
|
|
|
/***********************************************************************
|
2007-10-11 11:38:59 +02:00
|
|
|
* update_wm_states
|
2006-06-19 19:25:54 +02:00
|
|
|
*/
|
2007-10-11 11:38:59 +02:00
|
|
|
static void update_wm_states( Display *display, struct x11drv_win_data *data, BOOL force )
|
2006-06-19 19:25:54 +02:00
|
|
|
{
|
2007-10-11 11:38:59 +02:00
|
|
|
static const unsigned int state_atoms[NB_WM_STATES] =
|
|
|
|
{
|
|
|
|
XATOM__NET_WM_STATE_FULLSCREEN,
|
2007-10-31 18:13:20 +01:00
|
|
|
XATOM__NET_WM_STATE_ABOVE,
|
2007-10-11 11:40:55 +02:00
|
|
|
XATOM__NET_WM_STATE_SKIP_PAGER,
|
|
|
|
XATOM__NET_WM_STATE_SKIP_TASKBAR
|
2007-10-11 11:38:59 +02:00
|
|
|
};
|
|
|
|
|
2007-10-11 11:40:55 +02:00
|
|
|
DWORD i, ex_style, new_state = 0;
|
2006-06-19 19:25:54 +02:00
|
|
|
XEvent xev;
|
2007-01-09 16:57:33 +01:00
|
|
|
|
2007-10-11 11:38:59 +02:00
|
|
|
if (!data->managed) return;
|
2008-01-23 12:28:32 +01:00
|
|
|
if (!data->mapped) return;
|
2007-10-11 11:38:59 +02:00
|
|
|
|
2008-01-22 20:08:56 +01:00
|
|
|
if (data->whole_rect.left <= 0 && data->whole_rect.right >= screen_width &&
|
|
|
|
data->whole_rect.top <= 0 && data->whole_rect.bottom >= screen_height)
|
2007-10-11 11:38:59 +02:00
|
|
|
new_state |= (1 << WM_STATE_FULLSCREEN);
|
2007-01-09 16:57:33 +01:00
|
|
|
|
2007-10-11 11:40:55 +02:00
|
|
|
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
|
2007-10-31 18:13:20 +01:00
|
|
|
if (ex_style & WS_EX_TOPMOST)
|
|
|
|
new_state |= (1 << WM_STATE_ABOVE);
|
2007-10-11 11:40:55 +02:00
|
|
|
if (ex_style & WS_EX_TOOLWINDOW)
|
|
|
|
new_state |= (1 << WM_STATE_SKIP_TASKBAR) | (1 << WM_STATE_SKIP_PAGER);
|
|
|
|
|
2007-01-09 16:57:33 +01:00
|
|
|
xev.xclient.type = ClientMessage;
|
2007-10-11 11:38:59 +02:00
|
|
|
xev.xclient.window = data->whole_window;
|
2007-01-09 16:57:33 +01:00
|
|
|
xev.xclient.message_type = x11drv_atom(_NET_WM_STATE);
|
|
|
|
xev.xclient.serial = 0;
|
|
|
|
xev.xclient.display = display;
|
|
|
|
xev.xclient.send_event = True;
|
|
|
|
xev.xclient.format = 32;
|
|
|
|
xev.xclient.data.l[2] = 0;
|
2007-10-11 11:38:59 +02:00
|
|
|
xev.xclient.data.l[3] = 1;
|
2007-01-09 16:57:33 +01:00
|
|
|
|
2007-10-11 11:38:59 +02:00
|
|
|
for (i = 0; i < NB_WM_STATES; i++)
|
|
|
|
{
|
|
|
|
if (!((data->wm_state ^ new_state) & (1 << i))) /* unchanged */
|
|
|
|
{
|
|
|
|
/* if forced, we only add states, we don't remove them */
|
|
|
|
if (!force || !(new_state & (1 << i))) continue;
|
|
|
|
}
|
2006-06-19 19:25:54 +02:00
|
|
|
|
2007-10-11 11:38:59 +02:00
|
|
|
TRACE( "setting wm state %u for window %p/%lx to %u prev %u\n",
|
|
|
|
i, data->hwnd, data->whole_window,
|
|
|
|
(new_state & (1 << i)) != 0, (data->wm_state & (1 << i)) != 0 );
|
2006-06-19 19:25:54 +02:00
|
|
|
|
2007-10-11 11:38:59 +02:00
|
|
|
xev.xclient.data.l[0] = (new_state & (1 << i)) ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
|
|
|
|
xev.xclient.data.l[1] = X11DRV_Atoms[state_atoms[i] - FIRST_XATOM];
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XSendEvent( display, root_window, False, SubstructureRedirectMask | SubstructureNotifyMask, &xev );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
data->wm_state = new_state;
|
2006-06-19 19:25:54 +02:00
|
|
|
}
|
|
|
|
|
2007-01-09 16:57:33 +01:00
|
|
|
|
2008-01-22 20:30:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* move_window_bits
|
|
|
|
*
|
|
|
|
* Move the window bits when a window is moved.
|
|
|
|
*/
|
|
|
|
static void move_window_bits( struct x11drv_win_data *data, const RECT *old_rect, const RECT *new_rect,
|
2008-01-23 12:28:01 +01:00
|
|
|
const RECT *old_whole_rect )
|
2008-01-22 20:30:04 +01:00
|
|
|
{
|
2008-01-22 20:34:11 +01:00
|
|
|
RECT src_rect = *old_rect;
|
|
|
|
RECT dst_rect = *new_rect;
|
|
|
|
HDC hdc_src, hdc_dst;
|
|
|
|
INT code;
|
|
|
|
HRGN rgn = 0;
|
|
|
|
HWND parent = 0;
|
|
|
|
|
|
|
|
if (!data->whole_window)
|
|
|
|
{
|
2008-01-23 12:28:01 +01:00
|
|
|
OffsetRect( &dst_rect, -data->window_rect.left, -data->window_rect.top );
|
2008-01-22 20:34:11 +01:00
|
|
|
parent = GetAncestor( data->hwnd, GA_PARENT );
|
|
|
|
hdc_src = GetDCEx( parent, 0, DCX_CACHE );
|
|
|
|
hdc_dst = GetDCEx( data->hwnd, 0, DCX_CACHE | DCX_WINDOW );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-01-23 12:28:01 +01:00
|
|
|
OffsetRect( &dst_rect, -data->whole_rect.left, -data->whole_rect.top );
|
2008-01-22 20:34:11 +01:00
|
|
|
/* make src rect relative to the old position of the window */
|
2008-01-23 12:28:01 +01:00
|
|
|
OffsetRect( &src_rect, -old_whole_rect->left, -old_whole_rect->top );
|
2008-01-22 20:34:11 +01:00
|
|
|
if (dst_rect.left == src_rect.left && dst_rect.top == src_rect.top) return;
|
|
|
|
/* now make them relative to window rect for DCX_WINDOW */
|
2008-01-23 12:28:01 +01:00
|
|
|
OffsetRect( &dst_rect, data->whole_rect.left - data->window_rect.left,
|
|
|
|
data->whole_rect.top - data->window_rect.top );
|
|
|
|
OffsetRect( &src_rect, data->whole_rect.left - data->window_rect.left,
|
|
|
|
data->whole_rect.top - data->window_rect.top );
|
2008-01-22 20:34:11 +01:00
|
|
|
hdc_src = hdc_dst = GetDCEx( data->hwnd, 0, DCX_CACHE | DCX_WINDOW );
|
|
|
|
}
|
|
|
|
|
|
|
|
code = X11DRV_START_EXPOSURES;
|
|
|
|
ExtEscape( hdc_dst, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL );
|
|
|
|
|
|
|
|
TRACE( "copying bits for win %p/%lx %s -> %s\n",
|
|
|
|
data->hwnd, data->whole_window, wine_dbgstr_rect(&src_rect), wine_dbgstr_rect(&dst_rect) );
|
|
|
|
BitBlt( hdc_dst, dst_rect.left, dst_rect.top,
|
|
|
|
dst_rect.right - dst_rect.left, dst_rect.bottom - dst_rect.top,
|
|
|
|
hdc_src, src_rect.left, src_rect.top, SRCCOPY );
|
|
|
|
|
|
|
|
code = X11DRV_END_EXPOSURES;
|
|
|
|
ExtEscape( hdc_dst, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, sizeof(rgn), (LPSTR)&rgn );
|
|
|
|
|
|
|
|
ReleaseDC( data->hwnd, hdc_dst );
|
|
|
|
if (hdc_src != hdc_dst) ReleaseDC( parent, hdc_src );
|
|
|
|
|
|
|
|
if (rgn)
|
|
|
|
{
|
2008-01-23 12:28:01 +01:00
|
|
|
OffsetRgn( rgn, data->window_rect.left - data->client_rect.left,
|
|
|
|
data->window_rect.top - data->client_rect.top );
|
2008-01-22 20:34:11 +01:00
|
|
|
RedrawWindow( data->hwnd, NULL, rgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ALLCHILDREN );
|
|
|
|
DeleteObject( rgn );
|
|
|
|
}
|
2008-01-22 20:30:04 +01:00
|
|
|
}
|
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
/***********************************************************************
|
2006-11-26 23:21:02 +01:00
|
|
|
* SetWindowPos (X11DRV.@)
|
2004-12-07 18:31:53 +01:00
|
|
|
*/
|
2008-01-24 11:23:09 +01:00
|
|
|
void X11DRV_SetWindowPos( HWND hwnd, HWND insert_after, UINT swp_flags,
|
|
|
|
const RECT *rectWindow, const RECT *rectClient,
|
|
|
|
const RECT *visible_rect, const RECT *valid_rects )
|
2004-12-07 18:31:53 +01:00
|
|
|
{
|
2007-08-20 22:06:33 +02:00
|
|
|
Display *display = thread_display();
|
2008-01-24 11:23:09 +01:00
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
|
|
|
DWORD new_style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
RECT old_window_rect, old_whole_rect, old_client_rect;
|
2008-01-23 12:28:12 +01:00
|
|
|
|
2008-01-24 11:23:09 +01:00
|
|
|
if (!data)
|
2008-01-24 10:20:51 +01:00
|
|
|
{
|
|
|
|
/* create the win data if the window is being made visible */
|
2008-01-24 11:23:09 +01:00
|
|
|
if (!(new_style & WS_VISIBLE)) return;
|
|
|
|
if (!(data = X11DRV_create_win_data( hwnd ))) return;
|
2008-01-24 10:20:51 +01:00
|
|
|
}
|
2008-01-23 12:28:12 +01:00
|
|
|
|
2007-08-20 22:06:33 +02:00
|
|
|
/* check if we need to switch the window to managed */
|
2008-01-24 10:21:07 +01:00
|
|
|
if (!data->managed && data->whole_window && is_window_managed( hwnd, swp_flags, rectWindow ))
|
2007-08-20 22:06:33 +02:00
|
|
|
{
|
2008-01-23 12:28:12 +01:00
|
|
|
TRACE( "making win %p/%lx managed\n", hwnd, data->whole_window );
|
|
|
|
data->managed = TRUE;
|
|
|
|
SetPropA( hwnd, managed_prop, (HANDLE)1 );
|
2008-01-23 12:28:32 +01:00
|
|
|
if (data->mapped)
|
2007-08-20 22:06:33 +02:00
|
|
|
{
|
2008-01-23 12:28:12 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XUnmapWindow( display, data->whole_window );
|
|
|
|
wine_tsx11_unlock();
|
2008-01-23 12:28:32 +01:00
|
|
|
data->mapped = FALSE;
|
2007-08-20 22:06:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-23 12:28:12 +01:00
|
|
|
old_window_rect = data->window_rect;
|
|
|
|
old_whole_rect = data->whole_rect;
|
|
|
|
old_client_rect = data->client_rect;
|
|
|
|
data->window_rect = *rectWindow;
|
|
|
|
data->whole_rect = *rectWindow;
|
|
|
|
data->client_rect = *rectClient;
|
|
|
|
X11DRV_window_to_X_rect( data, &data->whole_rect );
|
|
|
|
if (memcmp( &visible_rect, &data->whole_rect, sizeof(RECT) ))
|
2005-07-07 22:33:29 +02:00
|
|
|
{
|
2008-01-23 12:28:12 +01:00
|
|
|
TRACE( "%p: need to update visible rect %s -> %s\n", hwnd,
|
2008-01-24 11:23:09 +01:00
|
|
|
wine_dbgstr_rect(visible_rect), wine_dbgstr_rect(&data->whole_rect) );
|
2008-01-23 12:28:12 +01:00
|
|
|
SERVER_START_REQ( set_window_visible_rect )
|
2006-03-06 21:02:59 +01:00
|
|
|
{
|
2008-01-23 12:28:12 +01:00
|
|
|
req->handle = hwnd;
|
|
|
|
req->flags = swp_flags;
|
|
|
|
req->visible.left = data->whole_rect.left;
|
|
|
|
req->visible.top = data->whole_rect.top;
|
|
|
|
req->visible.right = data->whole_rect.right;
|
|
|
|
req->visible.bottom = data->whole_rect.bottom;
|
|
|
|
wine_server_call( req );
|
2008-01-22 20:01:21 +01:00
|
|
|
}
|
2008-01-23 12:28:12 +01:00
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
2008-01-22 20:01:21 +01:00
|
|
|
|
2008-01-23 12:28:12 +01:00
|
|
|
/* invalidate DCEs */
|
|
|
|
if ((((swp_flags & SWP_AGG_NOPOSCHANGE) != SWP_AGG_NOPOSCHANGE) && (new_style & WS_VISIBLE)) ||
|
|
|
|
(swp_flags & (SWP_HIDEWINDOW | SWP_SHOWWINDOW)))
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
UnionRect( &rect, rectWindow, &old_window_rect );
|
|
|
|
invalidate_dce( hwnd, &rect );
|
|
|
|
}
|
2005-03-24 16:18:50 +01:00
|
|
|
|
2008-01-23 12:28:12 +01:00
|
|
|
TRACE( "win %p window %s client %s style %08x\n",
|
|
|
|
hwnd, wine_dbgstr_rect(rectWindow), wine_dbgstr_rect(rectClient), new_style );
|
2004-12-07 18:31:53 +01:00
|
|
|
|
2008-01-23 12:28:12 +01:00
|
|
|
if (!IsRectEmpty( &valid_rects[0] ))
|
|
|
|
{
|
|
|
|
int x_offset = old_whole_rect.left - data->whole_rect.left;
|
|
|
|
int y_offset = old_whole_rect.top - data->whole_rect.top;
|
|
|
|
|
|
|
|
/* if all that happened is that the whole window moved, copy everything */
|
|
|
|
if (!(swp_flags & SWP_FRAMECHANGED) &&
|
|
|
|
old_whole_rect.right - data->whole_rect.right == x_offset &&
|
|
|
|
old_whole_rect.bottom - data->whole_rect.bottom == y_offset &&
|
|
|
|
old_client_rect.left - data->client_rect.left == x_offset &&
|
|
|
|
old_client_rect.right - data->client_rect.right == x_offset &&
|
|
|
|
old_client_rect.top - data->client_rect.top == y_offset &&
|
|
|
|
old_client_rect.bottom - data->client_rect.bottom == y_offset &&
|
|
|
|
!memcmp( &valid_rects[0], &data->client_rect, sizeof(RECT) ))
|
2004-12-07 18:31:53 +01:00
|
|
|
{
|
2008-01-23 12:28:12 +01:00
|
|
|
/* if we have an X window the bits will be moved by the X server */
|
|
|
|
if (!data->whole_window)
|
|
|
|
move_window_bits( data, &old_whole_rect, &data->whole_rect, &old_whole_rect );
|
2004-12-07 18:31:53 +01:00
|
|
|
}
|
2008-01-23 12:28:12 +01:00
|
|
|
else
|
|
|
|
move_window_bits( data, &valid_rects[1], &valid_rects[0], &old_whole_rect );
|
|
|
|
}
|
2004-12-07 18:31:53 +01:00
|
|
|
|
2008-01-23 12:28:12 +01:00
|
|
|
if (data->gl_drawable &&
|
|
|
|
data->client_rect.right-data->client_rect.left == old_client_rect.right-old_client_rect.left &&
|
|
|
|
data->client_rect.bottom-data->client_rect.top == old_client_rect.bottom-old_client_rect.top)
|
|
|
|
X11DRV_sync_gl_drawable( display, data );
|
2004-12-07 18:31:53 +01:00
|
|
|
|
2008-01-24 11:23:09 +01:00
|
|
|
if (!data->whole_window || data->lock_changes) return; /* nothing more to do */
|
2007-08-20 22:06:33 +02:00
|
|
|
|
2008-01-23 12:28:32 +01:00
|
|
|
if (data->mapped && (!(new_style & WS_VISIBLE) || !X11DRV_is_window_rect_mapped( rectWindow )))
|
2008-01-23 12:28:12 +01:00
|
|
|
{
|
|
|
|
TRACE( "unmapping win %p\n", hwnd );
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XUnmapWindow( display, data->whole_window );
|
|
|
|
wine_tsx11_unlock();
|
2008-01-23 12:28:32 +01:00
|
|
|
data->mapped = FALSE;
|
2008-01-23 12:28:12 +01:00
|
|
|
}
|
2007-02-23 20:26:28 +01:00
|
|
|
|
2008-01-23 12:28:12 +01:00
|
|
|
X11DRV_sync_window_position( display, data, swp_flags, &old_client_rect, &old_whole_rect );
|
2004-12-07 18:31:53 +01:00
|
|
|
|
2008-01-23 12:28:12 +01:00
|
|
|
if ((new_style & WS_VISIBLE) && !(new_style & WS_MINIMIZE) &&
|
|
|
|
X11DRV_is_window_rect_mapped( rectWindow ))
|
|
|
|
{
|
2008-01-23 12:28:32 +01:00
|
|
|
BOOL was_mapped = data->mapped;
|
2008-01-23 12:28:12 +01:00
|
|
|
|
2008-01-23 12:28:32 +01:00
|
|
|
if (!data->mapped || (swp_flags & SWP_FRAMECHANGED))
|
2008-01-23 12:28:12 +01:00
|
|
|
X11DRV_set_wm_hints( display, data );
|
2004-12-07 18:31:53 +01:00
|
|
|
|
2008-01-23 12:28:32 +01:00
|
|
|
if (!data->mapped)
|
2005-01-31 17:34:07 +01:00
|
|
|
{
|
2008-01-23 12:28:32 +01:00
|
|
|
TRACE( "mapping win %p\n", hwnd );
|
2008-01-23 12:28:12 +01:00
|
|
|
X11DRV_sync_window_style( display, data );
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XMapWindow( display, data->whole_window );
|
|
|
|
XFlush( display );
|
|
|
|
wine_tsx11_unlock();
|
2008-01-23 12:28:32 +01:00
|
|
|
data->mapped = TRUE;
|
2004-12-07 18:31:53 +01:00
|
|
|
}
|
2008-01-23 12:28:32 +01:00
|
|
|
update_wm_states( display, data, !was_mapped );
|
2004-12-07 18:31:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* WINPOS_FindIconPos
|
|
|
|
*
|
|
|
|
* Find a suitable place for an iconic window.
|
|
|
|
*/
|
2005-03-23 13:00:51 +01:00
|
|
|
static POINT WINPOS_FindIconPos( HWND hwnd, POINT pt )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2005-03-24 21:41:27 +01:00
|
|
|
RECT rect, rectParent;
|
|
|
|
HWND parent, child;
|
|
|
|
HRGN hrgn, tmp;
|
|
|
|
int xspacing, yspacing;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
parent = GetAncestor( hwnd, GA_PARENT );
|
|
|
|
GetClientRect( 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);
|
|
|
|
|
2005-03-24 21:41:27 +01:00
|
|
|
/* Check if another icon already occupies this spot */
|
|
|
|
/* FIXME: this is completely inefficient */
|
|
|
|
|
|
|
|
hrgn = CreateRectRgn( 0, 0, 0, 0 );
|
|
|
|
tmp = CreateRectRgn( 0, 0, 0, 0 );
|
|
|
|
for (child = GetWindow( parent, GW_HWNDFIRST ); child; child = GetWindow( child, GW_HWNDNEXT ))
|
|
|
|
{
|
|
|
|
WND *childPtr;
|
|
|
|
if (child == hwnd) continue;
|
|
|
|
if ((GetWindowLongW( child, GWL_STYLE ) & (WS_VISIBLE|WS_MINIMIZE)) != (WS_VISIBLE|WS_MINIMIZE))
|
|
|
|
continue;
|
|
|
|
if (!(childPtr = WIN_GetPtr( child )) || childPtr == WND_OTHER_PROCESS)
|
|
|
|
continue;
|
|
|
|
SetRectRgn( tmp, childPtr->rectWindow.left, childPtr->rectWindow.top,
|
|
|
|
childPtr->rectWindow.right, childPtr->rectWindow.bottom );
|
|
|
|
CombineRgn( hrgn, hrgn, tmp, RGN_OR );
|
|
|
|
WIN_ReleasePtr( childPtr );
|
|
|
|
}
|
|
|
|
DeleteObject( tmp );
|
|
|
|
|
|
|
|
for (rect.bottom = rectParent.bottom; rect.bottom >= yspacing; rect.bottom -= yspacing)
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2005-03-24 21:41:27 +01:00
|
|
|
for (rect.left = rectParent.left; rect.left <= rectParent.right - xspacing; rect.left += xspacing)
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2005-03-24 21:41:27 +01:00
|
|
|
rect.right = rect.left + xspacing;
|
|
|
|
rect.top = rect.bottom - yspacing;
|
|
|
|
if (!RectInRegion( hrgn, &rect ))
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2005-03-24 21:41:27 +01:00
|
|
|
/* No window was found, so it's OK for us */
|
|
|
|
pt.x = rect.left + (xspacing - GetSystemMetrics(SM_CXICON)) / 2;
|
|
|
|
pt.y = rect.top + (yspacing - GetSystemMetrics(SM_CYICON)) / 2;
|
|
|
|
DeleteObject( hrgn );
|
|
|
|
return pt;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2005-03-24 21:41:27 +01:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2005-03-24 21:41:27 +01:00
|
|
|
DeleteObject( hrgn );
|
|
|
|
pt.x = pt.y = 0;
|
|
|
|
return pt;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
|
2006-11-26 23:21:02 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* WINPOS_MinMaximize
|
|
|
|
*/
|
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 ))
|
|
|
|
{
|
2006-05-17 09:35:26 +02:00
|
|
|
switch (cmd)
|
|
|
|
{
|
|
|
|
case SW_SHOWMINNOACTIVE:
|
|
|
|
case SW_SHOWMINIMIZED:
|
|
|
|
case SW_FORCEMINIMIZE:
|
|
|
|
case SW_MINIMIZE:
|
|
|
|
return SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
}
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!SendMessageW( hwnd, WM_QUERYOPEN, 0, 0 )) return SWP_NOSIZE | SWP_NOMOVE;
|
2001-10-16 23:58:58 +02:00
|
|
|
swpFlags |= SWP_NOCOPYBITS;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( cmd )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2006-05-17 09:35:26 +02:00
|
|
|
case SW_SHOWMINNOACTIVE:
|
|
|
|
case SW_SHOWMINIMIZED:
|
|
|
|
case SW_FORCEMINIMIZE:
|
2001-10-16 23:58:58 +02:00
|
|
|
case SW_MINIMIZE:
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
|
2001-10-22 21:08:33 +02:00
|
|
|
if( wndPtr->dwStyle & WS_MAXIMIZE) wndPtr->flags |= WIN_RESTORE_MAX;
|
|
|
|
else wndPtr->flags &= ~WIN_RESTORE_MAX;
|
2005-03-23 13:00:51 +01:00
|
|
|
WIN_ReleasePtr( wndPtr );
|
2001-10-22 21:08:33 +02:00
|
|
|
|
2006-12-19 12:35:42 +01:00
|
|
|
old_style = WIN_SetStyle( hwnd, WS_MINIMIZE, WS_MAXIMIZE );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-01-17 20:17:47 +01:00
|
|
|
X11DRV_set_iconic_state( hwnd );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
wpl.ptMinPosition = WINPOS_FindIconPos( hwnd, wpl.ptMinPosition );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2006-12-19 12:35:42 +01:00
|
|
|
if (!(old_style & WS_MINIMIZE)) swpFlags |= SWP_STATECHANGED;
|
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:
|
2006-05-17 09:35:26 +02:00
|
|
|
old_style = GetWindowLongW( hwnd, GWL_STYLE );
|
2006-10-16 16:23:34 +02:00
|
|
|
if ((old_style & WS_MAXIMIZE) && (old_style & WS_VISIBLE)) return SWP_NOSIZE | SWP_NOMOVE;
|
2006-05-17 09:35:26 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-01-21 11:32:13 +01:00
|
|
|
old_style = WIN_SetStyle( hwnd, WS_MAXIMIZE, WS_MINIMIZE );
|
2001-10-22 21:08:33 +02:00
|
|
|
if (old_style & WS_MINIMIZE)
|
2001-10-16 23:58:58 +02:00
|
|
|
{
|
|
|
|
WINPOS_ShowIconTitle( hwnd, FALSE );
|
2005-01-17 20:17:47 +01:00
|
|
|
X11DRV_set_iconic_state( hwnd );
|
2001-10-16 23:58:58 +02:00
|
|
|
}
|
2006-12-19 12:35:42 +01:00
|
|
|
if (!(old_style & WS_MAXIMIZE)) swpFlags |= SWP_STATECHANGED;
|
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
|
|
|
|
2006-12-19 12:35:42 +01:00
|
|
|
case SW_SHOWNOACTIVATE:
|
|
|
|
case SW_SHOWNORMAL:
|
2001-10-16 23:58:58 +02:00
|
|
|
case SW_RESTORE:
|
2005-01-21 11:32:13 +01:00
|
|
|
old_style = WIN_SetStyle( hwnd, 0, WS_MINIMIZE | WS_MAXIMIZE );
|
2001-10-22 21:08:33 +02:00
|
|
|
if (old_style & WS_MINIMIZE)
|
2001-10-16 23:58:58 +02:00
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
BOOL restore_max;
|
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
WINPOS_ShowIconTitle( hwnd, FALSE );
|
2005-01-17 20:17:47 +01:00
|
|
|
X11DRV_set_iconic_state( hwnd );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
|
|
|
|
restore_max = (wndPtr->flags & WIN_RESTORE_MAX) != 0;
|
|
|
|
WIN_ReleasePtr( wndPtr );
|
|
|
|
if (restore_max)
|
2001-10-16 23:58:58 +02:00
|
|
|
{
|
|
|
|
/* Restore to maximized position */
|
|
|
|
WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL);
|
2005-01-21 11:32:13 +01:00
|
|
|
WIN_SetStyle( hwnd, WS_MAXIMIZE, 0 );
|
2006-12-19 12:35:42 +01:00
|
|
|
swpFlags |= SWP_STATECHANGED;
|
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
|
|
|
|
2006-12-19 12:35:42 +01:00
|
|
|
swpFlags |= SWP_STATECHANGED;
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
{
|
2005-03-23 13:00:51 +01:00
|
|
|
WND *wndPtr;
|
2006-03-27 21:45:47 +02:00
|
|
|
HWND parent;
|
2005-03-23 13:00:51 +01:00
|
|
|
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
BOOL wasVisible = (style & WS_VISIBLE) != 0;
|
2006-12-19 12:35:42 +01:00
|
|
|
BOOL showFlag = TRUE;
|
2005-03-23 13:00:51 +01:00
|
|
|
RECT newPos = {0, 0, 0, 0};
|
|
|
|
UINT swp = 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:
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!wasVisible) return FALSE;
|
|
|
|
showFlag = FALSE;
|
2005-06-17 23:05:16 +02:00
|
|
|
swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
if (hwnd != GetActiveWindow())
|
|
|
|
swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
2001-06-04 23:55:17 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SW_SHOWMINNOACTIVE:
|
|
|
|
swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
|
|
|
/* fall through */
|
2006-05-19 11:55:50 +02:00
|
|
|
case SW_MINIMIZE:
|
2002-03-12 20:18:48 +01:00
|
|
|
case SW_FORCEMINIMIZE: /* FIXME: Does not work if thread is hung. */
|
2006-05-19 11:55:50 +02:00
|
|
|
if (style & WS_CHILD) swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
2001-06-04 23:55:17 +02:00
|
|
|
/* fall through */
|
2006-05-19 11:55:50 +02:00
|
|
|
case SW_SHOWMINIMIZED:
|
|
|
|
swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
|
2006-05-17 09:35:26 +02:00
|
|
|
swp |= WINPOS_MinMaximize( hwnd, cmd, &newPos );
|
2006-12-22 11:32:04 +01:00
|
|
|
if ((style & WS_MINIMIZE) && wasVisible) return TRUE;
|
2001-06-04 23:55:17 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
|
2006-12-19 12:35:42 +01:00
|
|
|
if (!wasVisible) swp |= SWP_SHOWWINDOW;
|
|
|
|
swp |= SWP_FRAMECHANGED;
|
2005-11-30 12:43:50 +01:00
|
|
|
swp |= WINPOS_MinMaximize( hwnd, SW_MAXIMIZE, &newPos );
|
2006-12-22 11:32:04 +01:00
|
|
|
if ((style & WS_MAXIMIZE) && wasVisible) return TRUE;
|
2001-06-04 23:55:17 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SW_SHOWNA:
|
2005-01-25 12:21:20 +01:00
|
|
|
swp |= SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
|
2005-03-23 13:00:51 +01:00
|
|
|
if (style & WS_CHILD) swp |= SWP_NOZORDER;
|
2005-01-25 12:21:20 +01:00
|
|
|
break;
|
2001-06-04 23:55:17 +02:00
|
|
|
case SW_SHOW:
|
2005-03-23 13:00:51 +01:00
|
|
|
if (wasVisible) return TRUE;
|
2001-06-04 23:55:17 +02:00
|
|
|
swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
|
2006-05-19 11:55:50 +02:00
|
|
|
if (style & WS_CHILD) swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
2001-06-04 23:55:17 +02:00
|
|
|
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 */
|
2006-12-19 12:35:42 +01:00
|
|
|
case SW_RESTORE:
|
|
|
|
/* fall through */
|
2001-06-04 23:55:17 +02:00
|
|
|
case SW_SHOWNORMAL: /* same as SW_NORMAL: */
|
|
|
|
case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
|
2006-12-30 15:03:36 +01:00
|
|
|
if (!wasVisible) swp |= SWP_SHOWWINDOW;
|
2005-03-23 13:00:51 +01:00
|
|
|
if (style & (WS_MINIMIZE | WS_MAXIMIZE))
|
2006-12-19 12:35:42 +01:00
|
|
|
{
|
|
|
|
swp |= SWP_FRAMECHANGED;
|
|
|
|
swp |= WINPOS_MinMaximize( hwnd, cmd, &newPos );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-12-31 10:27:23 +01:00
|
|
|
if (wasVisible) return TRUE;
|
2006-12-19 12:35:42 +01:00
|
|
|
swp |= SWP_NOSIZE | SWP_NOMOVE;
|
|
|
|
}
|
|
|
|
if (style & WS_CHILD && !(swp & SWP_STATECHANGED)) swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
2001-06-04 23:55:17 +02:00
|
|
|
break;
|
2004-04-08 21:07:20 +02:00
|
|
|
}
|
|
|
|
|
2006-12-19 12:35:42 +01:00
|
|
|
if ((showFlag != wasVisible || cmd == SW_SHOWNA) && cmd != SW_SHOWMAXIMIZED && !(swp & SWP_STATECHANGED))
|
2004-04-08 21:07:20 +02:00
|
|
|
{
|
|
|
|
SendMessageW( hwnd, WM_SHOWWINDOW, showFlag, 0 );
|
2005-03-23 13:00:51 +01:00
|
|
|
if (!IsWindow( hwnd )) return wasVisible;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
2006-03-27 21:45:47 +02:00
|
|
|
parent = GetAncestor( hwnd, GA_PARENT );
|
2006-12-19 12:35:42 +01:00
|
|
|
if (parent && !IsWindowVisible( parent ) && !(swp & SWP_STATECHANGED))
|
2005-11-09 11:35:48 +01:00
|
|
|
{
|
|
|
|
/* if parent is not visible simply toggle WS_VISIBLE and return */
|
|
|
|
if (showFlag) WIN_SetStyle( hwnd, WS_VISIBLE, 0 );
|
|
|
|
else WIN_SetStyle( hwnd, 0, WS_VISIBLE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetWindowPos( hwnd, HWND_TOP, newPos.left, newPos.top,
|
|
|
|
newPos.right, newPos.bottom, LOWORD(swp) );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
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
|
|
|
}
|
2005-03-23 13:00:51 +01:00
|
|
|
|
|
|
|
if (IsIconic(hwnd)) WINPOS_ShowIconTitle( hwnd, TRUE );
|
|
|
|
|
|
|
|
if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return wasVisible;
|
2001-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;
|
2005-03-23 13:00:51 +01:00
|
|
|
RECT client = wndPtr->rectClient;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
|
|
|
wndPtr->flags &= ~WIN_NEED_SIZE;
|
|
|
|
if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED;
|
|
|
|
else if (wndPtr->dwStyle & WS_MINIMIZE) wParam = SIZE_MINIMIZED;
|
2005-03-23 13:00:51 +01:00
|
|
|
WIN_ReleasePtr( wndPtr );
|
|
|
|
|
|
|
|
SendMessageW( hwnd, WM_SIZE, wParam,
|
|
|
|
MAKELONG( client.right - client.left, client.bottom - client.top ));
|
|
|
|
SendMessageW( hwnd, WM_MOVE, 0, MAKELONG( client.left, client.top ));
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2005-03-23 13:00:51 +01:00
|
|
|
else WIN_ReleasePtr( wndPtr );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2007-01-31 11:39:40 +01:00
|
|
|
/* if previous state was minimized Windows sets focus to the window */
|
|
|
|
if (style & WS_MINIMIZE) SetFocus( hwnd );
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
return wasVisible;
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_MapNotify
|
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
void X11DRV_MapNotify( HWND hwnd, XEvent *event )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2005-01-28 18:25:50 +01:00
|
|
|
struct x11drv_win_data *data;
|
2001-06-04 23:55:17 +02:00
|
|
|
HWND hwndFocus = GetFocus();
|
|
|
|
WND *win;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-01-28 18:25:50 +01:00
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
if (!(win = WIN_GetPtr( hwnd ))) return;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-02-01 19:53:59 +01:00
|
|
|
if (data->managed && (win->dwStyle & WS_VISIBLE) && (win->dwStyle & WS_MINIMIZE))
|
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;
|
2005-01-21 11:32:13 +01:00
|
|
|
LONG style = WS_VISIBLE;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/* FIXME: hack */
|
|
|
|
wine_tsx11_lock();
|
2005-02-26 18:49:38 +01:00
|
|
|
XGetGeometry( event->xmap.display, data->whole_window, &root, &x, &y, &width, &height,
|
2001-06-04 23:55:17 +02:00
|
|
|
&border, &depth );
|
2005-02-26 18:49:38 +01:00
|
|
|
XTranslateCoordinates( event->xmap.display, data->whole_window, root, 0, 0, &x, &y, &top );
|
2001-06-04 23:55:17 +02:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
rect.left = x;
|
|
|
|
rect.top = y;
|
|
|
|
rect.right = x + width;
|
|
|
|
rect.bottom = y + height;
|
2006-10-26 12:53:59 +02:00
|
|
|
OffsetRect( &rect, virtual_screen_rect.left, virtual_screen_rect.top );
|
2005-02-01 19:53:59 +01:00
|
|
|
X11DRV_X_to_window_rect( data, &rect );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2005-03-25 17:47:04 +01:00
|
|
|
invalidate_dce( hwnd, &data->window_rect );
|
2001-10-22 21:08:33 +02:00
|
|
|
|
|
|
|
if (win->flags & WIN_RESTORE_MAX) style |= WS_MAXIMIZE;
|
2005-01-21 11:32:13 +01:00
|
|
|
WIN_SetStyle( hwnd, style, WS_MINIMIZE );
|
2001-10-22 21:08:33 +02:00
|
|
|
WIN_ReleasePtr( win );
|
|
|
|
|
2006-05-10 21:32:56 +02:00
|
|
|
SendMessageW( hwnd, WM_SHOWWINDOW, SW_RESTORE, 0 );
|
2006-03-29 18:27:01 +02:00
|
|
|
data->lock_changes++;
|
2001-06-04 23:55:17 +02:00
|
|
|
SetWindowPos( hwnd, 0, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
|
2007-08-20 22:06:50 +02:00
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED | SWP_STATECHANGED );
|
2006-03-29 18:27:01 +02:00
|
|
|
data->lock_changes--;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
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
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
void X11DRV_UnmapNotify( HWND hwnd, XEvent *event )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2005-02-01 19:53:59 +01:00
|
|
|
struct x11drv_win_data *data;
|
2001-06-04 23:55:17 +02:00
|
|
|
WND *win;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-02-01 19:53:59 +01:00
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
|
|
|
|
2001-10-22 21:08:33 +02:00
|
|
|
if (!(win = WIN_GetPtr( hwnd ))) return;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-02-01 19:53:59 +01:00
|
|
|
if ((win->dwStyle & WS_VISIBLE) && data->managed &&
|
2004-04-28 01:32:01 +02:00
|
|
|
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;
|
2006-12-22 11:32:04 +01:00
|
|
|
else if (!(win->dwStyle & WS_MINIMIZE))
|
2001-10-22 21:08:33 +02:00
|
|
|
win->flags &= ~WIN_RESTORE_MAX;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-01-21 11:32:13 +01:00
|
|
|
WIN_SetStyle( hwnd, WS_MINIMIZE, WS_MAXIMIZE );
|
2001-10-22 21:08:33 +02:00
|
|
|
WIN_ReleasePtr( win );
|
|
|
|
|
|
|
|
EndMenu();
|
2006-05-10 21:32:56 +02:00
|
|
|
SendMessageW( hwnd, WM_SHOWWINDOW, SW_MINIMIZE, 0 );
|
2006-03-29 18:27:01 +02:00
|
|
|
data->lock_changes++;
|
2001-06-04 23:55:17 +02:00
|
|
|
SetWindowPos( hwnd, 0, 0, 0, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON),
|
2006-12-19 12:35:42 +01:00
|
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_STATECHANGED );
|
2006-03-29 18:27:01 +02:00
|
|
|
data->lock_changes--;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
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
|
|
|
|
2006-11-14 10:40:49 +01:00
|
|
|
struct desktop_resize_data
|
|
|
|
{
|
|
|
|
RECT old_screen_rect;
|
|
|
|
RECT old_virtual_rect;
|
|
|
|
};
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2006-11-14 10:40:49 +01:00
|
|
|
static BOOL CALLBACK update_windows_on_desktop_resize( HWND hwnd, LPARAM lparam )
|
2006-06-29 10:44:53 +02:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
Display *display = thread_display();
|
2006-11-14 10:40:49 +01:00
|
|
|
struct desktop_resize_data *resize_data = (struct desktop_resize_data *)lparam;
|
|
|
|
int mask = 0;
|
|
|
|
|
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return TRUE;
|
|
|
|
|
|
|
|
if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)
|
2007-01-09 16:57:33 +01:00
|
|
|
{
|
2007-10-11 11:38:59 +02:00
|
|
|
/* update the full screen state */
|
|
|
|
update_wm_states( display, data, FALSE );
|
2007-01-09 16:57:33 +01:00
|
|
|
}
|
2006-06-29 10:44:53 +02:00
|
|
|
|
2006-11-14 10:40:49 +01:00
|
|
|
if (resize_data->old_virtual_rect.left != virtual_screen_rect.left) mask |= CWX;
|
|
|
|
if (resize_data->old_virtual_rect.top != virtual_screen_rect.top) mask |= CWY;
|
|
|
|
if (mask && data->whole_window)
|
2006-06-29 10:44:53 +02:00
|
|
|
{
|
2006-11-14 10:40:49 +01:00
|
|
|
XWindowChanges changes;
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
changes.x = data->whole_rect.left - virtual_screen_rect.left;
|
|
|
|
changes.y = data->whole_rect.top - virtual_screen_rect.top;
|
|
|
|
XReconfigureWMWindow( display, data->whole_window,
|
|
|
|
DefaultScreen(display), mask, &changes );
|
|
|
|
wine_tsx11_unlock();
|
2006-06-29 10:44:53 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-13 04:58:21 +01:00
|
|
|
/***********************************************************************
|
2008-01-17 19:53:59 +01:00
|
|
|
* X11DRV_resize_desktop
|
2004-02-13 04:58:21 +01:00
|
|
|
*/
|
2008-01-17 19:53:59 +01:00
|
|
|
void X11DRV_resize_desktop( unsigned int width, unsigned int height )
|
2004-02-13 04:58:21 +01:00
|
|
|
{
|
|
|
|
HWND hwnd = GetDesktopWindow();
|
2006-11-14 10:40:49 +01:00
|
|
|
struct desktop_resize_data resize_data;
|
2004-02-13 04:58:21 +01:00
|
|
|
|
2006-11-14 10:40:49 +01:00
|
|
|
SetRect( &resize_data.old_screen_rect, 0, 0, screen_width, screen_height );
|
|
|
|
resize_data.old_virtual_rect = virtual_screen_rect;
|
2006-06-29 10:44:53 +02:00
|
|
|
|
2008-01-17 19:59:22 +01:00
|
|
|
xinerama_init( width, height );
|
2008-01-17 19:53:59 +01:00
|
|
|
|
2008-01-24 10:20:11 +01:00
|
|
|
if (GetWindowThreadProcessId( hwnd, NULL ) != GetCurrentThreadId())
|
2008-01-17 19:53:59 +01:00
|
|
|
{
|
|
|
|
SendMessageW( hwnd, WM_X11DRV_RESIZE_DESKTOP, 0, MAKELPARAM( width, height ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE( "desktop %p change to (%dx%d)\n", hwnd, width, height );
|
|
|
|
SetWindowPos( hwnd, 0, virtual_screen_rect.left, virtual_screen_rect.top,
|
|
|
|
virtual_screen_rect.right - virtual_screen_rect.left,
|
|
|
|
virtual_screen_rect.bottom - virtual_screen_rect.top,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE );
|
|
|
|
SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_bpp,
|
|
|
|
MAKELPARAM( width, height ), SMTO_ABORTIFHUNG, 2000, NULL );
|
|
|
|
}
|
2006-06-29 10:44:53 +02:00
|
|
|
|
2006-11-14 10:40:49 +01:00
|
|
|
EnumWindows( update_windows_on_desktop_resize, (LPARAM)&resize_data );
|
2004-02-13 04:58:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_ConfigureNotify
|
|
|
|
*/
|
2005-02-26 18:49:38 +01:00
|
|
|
void X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XConfigureEvent *event = &xev->xconfigure;
|
2001-06-04 23:55:17 +02:00
|
|
|
struct x11drv_win_data *data;
|
|
|
|
RECT rect;
|
2005-03-21 11:57:21 +01:00
|
|
|
UINT flags;
|
|
|
|
int cx, cy, x = event->x, y = event->y;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-02-26 18:49:38 +01:00
|
|
|
if (!hwnd) return;
|
2005-01-17 20:17:47 +01:00
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
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;
|
2006-10-26 12:53:59 +02:00
|
|
|
OffsetRect( &rect, virtual_screen_rect.left, virtual_screen_rect.top );
|
2006-10-08 01:34:01 +02:00
|
|
|
TRACE( "win %p new X rect %d,%d,%dx%d (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 );
|
2005-02-01 19:53:59 +01:00
|
|
|
X11DRV_X_to_window_rect( data, &rect );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2005-03-21 11:57:21 +01:00
|
|
|
x = rect.left;
|
|
|
|
y = rect.top;
|
|
|
|
cx = rect.right - rect.left;
|
|
|
|
cy = rect.bottom - rect.top;
|
2006-03-29 18:27:01 +02:00
|
|
|
flags = SWP_NOACTIVATE | SWP_NOZORDER;
|
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 );
|
2005-03-21 11:57:21 +01:00
|
|
|
if (rect.left == x && rect.top == y) flags |= SWP_NOMOVE;
|
2001-06-04 23:55:17 +02:00
|
|
|
else
|
2006-10-08 01:34:01 +02:00
|
|
|
TRACE( "%p moving from (%d,%d) to (%d,%d)\n",
|
2005-03-21 11:57:21 +01:00
|
|
|
hwnd, rect.left, rect.top, x, y );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-03-21 11:57:21 +01:00
|
|
|
if ((rect.right - rect.left == cx && rect.bottom - rect.top == cy) ||
|
2001-09-21 23:04:56 +02:00
|
|
|
IsIconic(hwnd) ||
|
2005-09-19 17:25:53 +02:00
|
|
|
(IsRectEmpty( &rect ) && event->width == 1 && event->height == 1))
|
2005-03-21 11:57:21 +01:00
|
|
|
{
|
|
|
|
if (flags & SWP_NOMOVE) return; /* if nothing changed, don't do anything */
|
|
|
|
flags |= SWP_NOSIZE;
|
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
else
|
2006-10-08 01:34:01 +02:00
|
|
|
TRACE( "%p resizing from (%dx%d) to (%dx%d)\n",
|
2005-03-21 11:57:21 +01:00
|
|
|
hwnd, rect.right - rect.left, rect.bottom - rect.top, cx, cy );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2006-03-29 18:27:01 +02:00
|
|
|
data->lock_changes++;
|
2005-03-21 11:57:21 +01:00
|
|
|
SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
|
2006-03-29 18:27:01 +02:00
|
|
|
data->lock_changes--;
|
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
|
|
|
|
*
|
2008-01-04 20:37:14 +01:00
|
|
|
* Initialization of a move or resize, when initiated from a menu choice.
|
2001-05-09 19:21:04 +02:00
|
|
|
* 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 */
|
2005-01-17 21:27:11 +01:00
|
|
|
RECT rect = rectWindow;
|
|
|
|
/* Note: to be exactly centered we should take the different types
|
2008-01-04 20:37:14 +01:00
|
|
|
* of border into account, but it shouldn't make more than a few pixels
|
2005-01-17 21:27:11 +01:00
|
|
|
* of difference so let's not bother with that */
|
|
|
|
rect.top += GetSystemMetrics(SM_CYBORDER);
|
2001-08-18 20:08:26 +02:00
|
|
|
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;
|
2005-01-17 21:27:11 +01:00
|
|
|
pt.x = (rect.right + rect.left) / 2;
|
|
|
|
pt.y = rect.top + GetSystemMetrics(SM_CYSIZE)/2;
|
2001-05-09 19:21:04 +02:00
|
|
|
hittest = HTCAPTION;
|
|
|
|
*capturePoint = pt;
|
|
|
|
}
|
|
|
|
else /* SC_SIZE */
|
|
|
|
{
|
2005-03-22 22:17:34 +01:00
|
|
|
pt.x = pt.y = 0;
|
2001-05-09 19:21:04 +02:00
|
|
|
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:
|
2005-01-17 21:27:11 +01:00
|
|
|
pt = msg.pt;
|
|
|
|
hittest = SendMessageW( hwnd, WM_NCHITTEST, 0, MAKELONG( pt.x, pt.y ) );
|
|
|
|
if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT)) hittest = 0;
|
2001-05-09 19:21:04 +02:00
|
|
|
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 );
|
2005-01-17 21:27:11 +01:00
|
|
|
SendMessageW( hwnd, WM_SETCURSOR, (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 );
|
|
|
|
}
|
|
|
|
|
2004-08-19 01:47:48 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_WMMoveResizeWindow
|
|
|
|
*
|
|
|
|
* Tells the window manager to initiate a move or resize operation.
|
|
|
|
*
|
|
|
|
* SEE
|
|
|
|
* http://freedesktop.org/Standards/wm-spec/1.3/ar01s04.html
|
|
|
|
* or search for "_NET_WM_MOVERESIZE"
|
|
|
|
*/
|
2007-09-19 17:54:33 +02:00
|
|
|
static BOOL X11DRV_WMMoveResizeWindow( HWND hwnd, int x, int y, WPARAM wparam )
|
2004-08-19 01:47:48 +02:00
|
|
|
{
|
2007-09-19 17:54:33 +02:00
|
|
|
WPARAM syscommand = wparam & 0xfff0;
|
|
|
|
WPARAM hittest = wparam & 0x0f;
|
|
|
|
int dir;
|
2004-08-19 01:47:48 +02:00
|
|
|
XEvent xev;
|
|
|
|
Display *display = thread_display();
|
|
|
|
|
2007-09-19 17:54:33 +02:00
|
|
|
if (syscommand == SC_MOVE)
|
|
|
|
{
|
|
|
|
if (!hittest) dir = _NET_WM_MOVERESIZE_MOVE_KEYBOARD;
|
|
|
|
else dir = _NET_WM_MOVERESIZE_MOVE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* windows without WS_THICKFRAME are not resizable through the window manager */
|
|
|
|
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_THICKFRAME)) return FALSE;
|
|
|
|
|
|
|
|
switch (hittest)
|
|
|
|
{
|
|
|
|
case WMSZ_LEFT: dir = _NET_WM_MOVERESIZE_SIZE_LEFT; break;
|
|
|
|
case WMSZ_RIGHT: dir = _NET_WM_MOVERESIZE_SIZE_RIGHT; break;
|
|
|
|
case WMSZ_TOP: dir = _NET_WM_MOVERESIZE_SIZE_TOP; break;
|
|
|
|
case WMSZ_TOPLEFT: dir = _NET_WM_MOVERESIZE_SIZE_TOPLEFT; break;
|
|
|
|
case WMSZ_TOPRIGHT: dir = _NET_WM_MOVERESIZE_SIZE_TOPRIGHT; break;
|
|
|
|
case WMSZ_BOTTOM: dir = _NET_WM_MOVERESIZE_SIZE_BOTTOM; break;
|
|
|
|
case WMSZ_BOTTOMLEFT: dir = _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT; break;
|
|
|
|
case WMSZ_BOTTOMRIGHT: dir = _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT; break;
|
|
|
|
default: dir = _NET_WM_MOVERESIZE_SIZE_KEYBOARD; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-05 16:16:36 +02:00
|
|
|
TRACE("hwnd %p, x %d, y %d, dir %d\n", hwnd, x, y, dir);
|
|
|
|
|
2004-08-19 01:47:48 +02:00
|
|
|
xev.xclient.type = ClientMessage;
|
|
|
|
xev.xclient.window = X11DRV_get_whole_window(hwnd);
|
|
|
|
xev.xclient.message_type = x11drv_atom(_NET_WM_MOVERESIZE);
|
|
|
|
xev.xclient.serial = 0;
|
|
|
|
xev.xclient.display = display;
|
|
|
|
xev.xclient.send_event = True;
|
|
|
|
xev.xclient.format = 32;
|
|
|
|
xev.xclient.data.l[0] = x; /* x coord */
|
|
|
|
xev.xclient.data.l[1] = y; /* y coord */
|
|
|
|
xev.xclient.data.l[2] = dir; /* direction */
|
|
|
|
xev.xclient.data.l[3] = 1; /* button */
|
|
|
|
xev.xclient.data.l[4] = 0; /* unused */
|
|
|
|
|
2005-01-17 20:17:47 +01:00
|
|
|
/* need to ungrab the pointer that may have been automatically grabbed
|
|
|
|
* with a ButtonPress event */
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XUngrabPointer( display, CurrentTime );
|
|
|
|
XSendEvent(display, root_window, False, SubstructureNotifyMask, &xev);
|
2004-08-19 01:47:48 +02:00
|
|
|
wine_tsx11_unlock();
|
2007-09-19 17:54:33 +02:00
|
|
|
return TRUE;
|
2004-08-19 01:47:48 +02:00
|
|
|
}
|
2002-10-12 03:24:37 +02:00
|
|
|
|
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);
|
2004-08-19 01:47:48 +02:00
|
|
|
WPARAM syscommand = wParam & 0xfff0;
|
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 );
|
2005-02-01 19:53:59 +01:00
|
|
|
BOOL thickframe = HAS_THICKFRAME( style );
|
2001-08-18 20:08:26 +02:00
|
|
|
BOOL iconic = style & WS_MINIMIZE;
|
2001-05-09 19:21:04 +02:00
|
|
|
BOOL moved = FALSE;
|
|
|
|
DWORD dwPoint = GetMessagePos ();
|
2007-09-27 20:13:57 +02:00
|
|
|
BOOL DragFullWindows = TRUE;
|
2005-01-17 20:17:47 +01:00
|
|
|
Window parent_win, whole_win;
|
2005-03-21 13:37:00 +01:00
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
2005-02-01 19:53:59 +01:00
|
|
|
struct x11drv_win_data *data;
|
2001-05-09 19:21:04 +02:00
|
|
|
|
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;
|
|
|
|
|
2004-08-19 01:47:48 +02:00
|
|
|
if (IsZoomed(hwnd) || !IsWindowVisible(hwnd)) return;
|
2001-05-09 19:21:04 +02:00
|
|
|
|
2005-02-01 19:53:59 +01:00
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("hwnd %p (%smanaged), command %04lx, hittest %d, pos %d,%d\n",
|
2006-10-05 16:16:36 +02:00
|
|
|
hwnd, data->managed ? "" : "NOT ", syscommand, hittest, pt.x, pt.y);
|
|
|
|
|
2004-08-19 01:47:48 +02:00
|
|
|
/* if we are managed then we let the WM do all the work */
|
2007-09-19 17:54:33 +02:00
|
|
|
if (data->managed && X11DRV_WMMoveResizeWindow( hwnd, pt.x, pt.y, wParam )) return;
|
2004-08-19 01:47:48 +02:00
|
|
|
|
|
|
|
if (syscommand == SC_MOVE)
|
2001-05-09 19:21:04 +02:00
|
|
|
{
|
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 */
|
|
|
|
{
|
2004-08-19 01:47:48 +02:00
|
|
|
if ( hittest && (syscommand != SC_MOUSEMENU) )
|
2003-02-19 00:24:57 +01:00
|
|
|
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;
|
2006-10-23 14:37:17 +02:00
|
|
|
mouseRect = virtual_screen_rect;
|
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 */
|
|
|
|
{
|
2005-02-15 22:51:06 +01:00
|
|
|
hDragCursor = (HCURSOR)GetClassLongPtrW( hwnd, GCLP_HICON);
|
|
|
|
if( !hDragCursor ) hDragCursor = (HCURSOR)SendMessageW( 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 );
|
|
|
|
|
2006-05-10 21:32:56 +02:00
|
|
|
SendMessageW( 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
|
|
|
|
2007-09-27 20:13:57 +02:00
|
|
|
/* we only allow disabling the full window drag for child windows, or in desktop mode */
|
|
|
|
/* otherwise we'd need to grab the server and we want to avoid that */
|
|
|
|
if (parent || (root_window != DefaultRootWindow(gdi_display)))
|
|
|
|
SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0);
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2005-01-31 17:34:07 +01:00
|
|
|
whole_win = X11DRV_get_whole_window( GetAncestor(hwnd,GA_ROOT) );
|
|
|
|
parent_win = parent ? X11DRV_get_whole_window( GetAncestor(parent,GA_ROOT) ) : root_window;
|
2005-01-17 20:17:47 +01:00
|
|
|
|
|
|
|
wine_tsx11_lock();
|
2005-03-21 13:37:00 +01:00
|
|
|
XGrabPointer( thread_data->display, whole_win, False,
|
2001-06-04 23:55:17 +02:00
|
|
|
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
|
2005-01-17 20:17:47 +01:00
|
|
|
GrabModeAsync, GrabModeAsync, parent_win, None, CurrentTime );
|
2001-06-04 23:55:17 +02:00
|
|
|
wine_tsx11_unlock();
|
2005-03-21 13:37:00 +01:00
|
|
|
thread_data->grab_window = whole_win;
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
int dx = 0, dy = 0;
|
|
|
|
|
2007-10-17 12:40:24 +02:00
|
|
|
if (!GetMessageW( &msg, 0, 0, 0 )) break;
|
2001-08-06 20:05:47 +02:00
|
|
|
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))
|
2007-10-17 12:40:24 +02:00
|
|
|
{
|
|
|
|
TranslateMessage( &msg );
|
|
|
|
DispatchMessageW( &msg );
|
2001-05-09 19:21:04 +02:00
|
|
|
continue; /* We are not interested in other messages */
|
2007-10-17 12:40:24 +02:00
|
|
|
}
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
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);
|
2006-05-10 21:32:56 +02:00
|
|
|
SendMessageW( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect );
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
if (!iconic)
|
|
|
|
{
|
|
|
|
if(!DragFullWindows)
|
|
|
|
draw_moving_frame( hdc, &newRect, thickframe );
|
2005-01-17 16:49:02 +01:00
|
|
|
else
|
2001-05-09 19:21:04 +02:00
|
|
|
SetWindowPos( hwnd, 0, newRect.left, newRect.top,
|
|
|
|
newRect.right - newRect.left,
|
|
|
|
newRect.bottom - newRect.top,
|
|
|
|
( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
|
|
|
|
}
|
|
|
|
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)
|
2007-11-21 13:22:42 +01:00
|
|
|
{
|
2001-05-09 19:21:04 +02:00
|
|
|
draw_moving_frame( hdc, &sizingRect, thickframe );
|
2007-11-21 13:22:42 +01:00
|
|
|
/* make sure the moving frame is erased before we move the window */
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XFlush( gdi_display );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
2001-05-09 19:21:04 +02:00
|
|
|
|
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();
|
2005-03-21 13:37:00 +01:00
|
|
|
XUngrabPointer( thread_data->display, CurrentTime );
|
2001-06-04 23:55:17 +02:00
|
|
|
wine_tsx11_unlock();
|
2005-03-21 13:37:00 +01:00
|
|
|
thread_data->grab_window = None;
|
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
|
|
|
|
2006-05-10 21:32:56 +02:00
|
|
|
SendMessageW( hwnd, WM_EXITSIZEMOVE, 0, 0 );
|
|
|
|
SendMessageW( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L);
|
2001-05-09 19:21:04 +02:00
|
|
|
|
|
|
|
/* window moved or resized */
|
|
|
|
if (moved)
|
|
|
|
{
|
|
|
|
/* 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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 )
|
2006-05-10 21:32:56 +02:00
|
|
|
SendMessageW( hwnd, WM_SYSCOMMAND,
|
2001-05-09 19:21:04 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|