2001-04-25 01:28:52 +02:00
|
|
|
/*
|
|
|
|
* Window related functions
|
|
|
|
*
|
|
|
|
* Copyright 1993, 1994, 1995, 1996, 2001 Alexandre Julliard
|
|
|
|
* Copyright 1993 David Metcalfe
|
|
|
|
* Copyright 1995, 1996 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-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-06-19 05:32:44 +02:00
|
|
|
#include <stdlib.h>
|
2006-08-23 02:14:11 +02:00
|
|
|
#include <stdio.h>
|
2003-08-08 23:07:23 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2001-06-19 05:32:44 +02:00
|
|
|
|
2003-11-21 22:48:36 +01:00
|
|
|
#include <X11/Xlib.h>
|
2002-09-24 20:36:51 +02:00
|
|
|
#include <X11/Xresource.h>
|
|
|
|
#include <X11/Xutil.h>
|
2008-01-23 16:30:18 +01:00
|
|
|
#ifdef HAVE_LIBXSHAPE
|
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
#endif /* HAVE_LIBXSHAPE */
|
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-02 20:44:56 +02:00
|
|
|
#include "wine/unicode.h"
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
#include "x11drv.h"
|
2007-09-26 07:43:38 +02:00
|
|
|
#include "xcomposite.h"
|
2005-03-25 11:38:56 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/server.h"
|
2002-01-21 19:41:27 +01:00
|
|
|
#include "mwm.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
|
|
|
|
2008-04-17 16:13:34 +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
|
|
|
|
#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9
|
|
|
|
#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10
|
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
#define _NET_WM_STATE_REMOVE 0
|
|
|
|
#define _NET_WM_STATE_ADD 1
|
|
|
|
#define _NET_WM_STATE_TOGGLE 2
|
|
|
|
|
|
|
|
#define SWP_AGG_NOPOSCHANGE (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOZORDER)
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
/* X context to associate a hwnd to an X window */
|
|
|
|
XContext winContext = 0;
|
|
|
|
|
2005-01-28 18:25:50 +01:00
|
|
|
/* X context to associate a struct x11drv_win_data to an hwnd */
|
|
|
|
static XContext win_data_context;
|
|
|
|
|
2010-06-29 11:08:51 +02:00
|
|
|
/* time of last user event and window where it's stored */
|
|
|
|
static Time last_user_time;
|
|
|
|
static Window user_time_window;
|
|
|
|
|
2010-11-15 20:41:07 +01:00
|
|
|
static const char foreign_window_prop[] = "__wine_x11_foreign_window";
|
2005-07-07 19:30:57 +02:00
|
|
|
static const char whole_window_prop[] = "__wine_x11_whole_window";
|
2008-02-21 12:29:36 +01:00
|
|
|
static const char client_window_prop[]= "__wine_x11_client_window";
|
2005-07-07 19:30:57 +02:00
|
|
|
static const char icon_window_prop[] = "__wine_x11_icon_window";
|
2007-09-15 22:02:32 +02:00
|
|
|
static const char fbconfig_id_prop[] = "__wine_x11_fbconfig_id";
|
2007-09-25 19:20:58 +02:00
|
|
|
static const char gl_drawable_prop[] = "__wine_x11_gl_drawable";
|
2007-09-26 17:17:13 +02:00
|
|
|
static const char pixmap_prop[] = "__wine_x11_pixmap";
|
2005-07-07 19:30:57 +02:00
|
|
|
static const char managed_prop[] = "__wine_x11_managed";
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2009-01-06 19:59:07 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* http://standards.freedesktop.org/startup-notification-spec
|
|
|
|
*/
|
|
|
|
static void remove_startup_notification(Display *display, Window window)
|
|
|
|
{
|
|
|
|
static LONG startup_notification_removed = 0;
|
|
|
|
char id[1024];
|
|
|
|
char message[1024];
|
|
|
|
int i;
|
|
|
|
int pos;
|
|
|
|
XEvent xevent;
|
|
|
|
const char *src;
|
|
|
|
int srclen;
|
|
|
|
|
|
|
|
if (InterlockedCompareExchange(&startup_notification_removed, 1, 0) != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (GetEnvironmentVariableA("DESKTOP_STARTUP_ID", id, sizeof(id)) == 0)
|
|
|
|
return;
|
|
|
|
SetEnvironmentVariableA("DESKTOP_STARTUP_ID", NULL);
|
|
|
|
|
2010-06-29 11:08:51 +02:00
|
|
|
if ((src = strstr( id, "_TIME" ))) update_user_time( atol( src + 5 ));
|
|
|
|
|
2009-01-06 19:59:07 +01:00
|
|
|
pos = snprintf(message, sizeof(message), "remove: ID=");
|
|
|
|
message[pos++] = '"';
|
|
|
|
for (i = 0; id[i] && pos < sizeof(message) - 2; i++)
|
|
|
|
{
|
|
|
|
if (id[i] == '"' || id[i] == '\\')
|
|
|
|
message[pos++] = '\\';
|
|
|
|
message[pos++] = id[i];
|
|
|
|
}
|
|
|
|
message[pos++] = '"';
|
|
|
|
message[pos++] = '\0';
|
|
|
|
|
|
|
|
xevent.xclient.type = ClientMessage;
|
|
|
|
xevent.xclient.message_type = x11drv_atom(_NET_STARTUP_INFO_BEGIN);
|
|
|
|
xevent.xclient.display = display;
|
|
|
|
xevent.xclient.window = window;
|
|
|
|
xevent.xclient.format = 8;
|
|
|
|
|
|
|
|
src = message;
|
|
|
|
srclen = strlen(src) + 1;
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
while (srclen > 0)
|
|
|
|
{
|
|
|
|
int msglen = srclen;
|
|
|
|
if (msglen > 20)
|
|
|
|
msglen = 20;
|
|
|
|
memset(&xevent.xclient.data.b[0], 0, 20);
|
|
|
|
memcpy(&xevent.xclient.data.b[0], src, msglen);
|
|
|
|
src += msglen;
|
|
|
|
srclen -= msglen;
|
|
|
|
|
|
|
|
XSendEvent( display, DefaultRootWindow( display ), False, PropertyChangeMask, &xevent );
|
|
|
|
xevent.xclient.message_type = x11drv_atom(_NET_STARTUP_INFO);
|
|
|
|
}
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-23 12:34:19 +01:00
|
|
|
struct has_popup_result
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
BOOL found;
|
|
|
|
};
|
|
|
|
|
|
|
|
static BOOL CALLBACK has_popup( HWND hwnd, LPARAM lparam )
|
|
|
|
{
|
|
|
|
struct has_popup_result *result = (struct has_popup_result *)lparam;
|
|
|
|
|
|
|
|
if (hwnd == result->hwnd) return FALSE; /* popups are always above owner */
|
|
|
|
result->found = (GetWindow( hwnd, GW_OWNER ) == result->hwnd);
|
|
|
|
return !result->found;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL has_owned_popups( HWND hwnd )
|
|
|
|
{
|
|
|
|
struct has_popup_result result;
|
|
|
|
|
|
|
|
result.hwnd = hwnd;
|
|
|
|
result.found = FALSE;
|
|
|
|
EnumWindows( has_popup, (LPARAM)&result );
|
|
|
|
return result.found;
|
|
|
|
}
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
/***********************************************************************
|
2001-06-04 23:55:17 +02:00
|
|
|
* is_window_managed
|
2001-04-25 01:28:52 +02:00
|
|
|
*
|
2001-06-04 23:55:17 +02:00
|
|
|
* Check if a given window should be managed
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
2008-04-23 15:32:58 +02:00
|
|
|
static BOOL is_window_managed( HWND hwnd, UINT swp_flags, const RECT *window_rect )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2005-01-17 20:17:47 +01:00
|
|
|
DWORD style, ex_style;
|
|
|
|
|
2008-01-24 10:21:07 +01:00
|
|
|
if (!managed_mode) return FALSE;
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/* child windows are not managed */
|
2005-01-17 20:17:47 +01:00
|
|
|
style = GetWindowLongW( hwnd, GWL_STYLE );
|
2007-07-25 04:09:50 +02:00
|
|
|
if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD) return FALSE;
|
2007-08-27 12:37:14 +02:00
|
|
|
/* activated windows are managed */
|
|
|
|
if (!(swp_flags & (SWP_NOACTIVATE|SWP_HIDEWINDOW))) return TRUE;
|
|
|
|
if (hwnd == GetActiveWindow()) return TRUE;
|
2003-12-04 22:54:13 +01:00
|
|
|
/* windows with caption are managed */
|
2005-01-17 20:17:47 +01:00
|
|
|
if ((style & WS_CAPTION) == WS_CAPTION) return TRUE;
|
2003-12-04 22:54:13 +01:00
|
|
|
/* windows with thick frame are managed */
|
2005-01-17 20:17:47 +01:00
|
|
|
if (style & WS_THICKFRAME) return TRUE;
|
|
|
|
if (style & WS_POPUP)
|
2004-02-06 06:17:55 +01:00
|
|
|
{
|
2008-10-07 05:14:52 +02:00
|
|
|
HMONITOR hmon;
|
|
|
|
MONITORINFO mi;
|
|
|
|
|
2007-02-10 18:40:50 +01:00
|
|
|
/* popup with sysmenu == caption are managed */
|
|
|
|
if (style & WS_SYSMENU) return TRUE;
|
|
|
|
/* full-screen popup windows are managed */
|
2008-10-07 05:14:52 +02:00
|
|
|
hmon = MonitorFromWindow( hwnd, MONITOR_DEFAULTTOPRIMARY );
|
|
|
|
mi.cbSize = sizeof( mi );
|
|
|
|
GetMonitorInfoW( hmon, &mi );
|
|
|
|
if (window_rect->left <= mi.rcWork.left && window_rect->right >= mi.rcWork.right &&
|
|
|
|
window_rect->top <= mi.rcWork.top && window_rect->bottom >= mi.rcWork.bottom)
|
2005-01-17 20:17:47 +01:00
|
|
|
return TRUE;
|
2004-02-06 06:17:55 +01:00
|
|
|
}
|
2008-04-25 14:26:52 +02:00
|
|
|
/* application windows are managed */
|
|
|
|
ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
|
|
|
|
if (ex_style & WS_EX_APPWINDOW) return TRUE;
|
2010-02-23 12:34:19 +01:00
|
|
|
/* windows that own popups are managed */
|
|
|
|
if (has_owned_popups( hwnd )) return TRUE;
|
2001-06-04 23:55:17 +02:00
|
|
|
/* default: not managed */
|
|
|
|
return FALSE;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-28 01:32:01 +02:00
|
|
|
/***********************************************************************
|
2010-05-28 12:16:17 +02:00
|
|
|
* is_window_rect_mapped
|
2004-04-28 01:32:01 +02:00
|
|
|
*
|
|
|
|
* Check if the X whole window should be mapped based on its rectangle
|
|
|
|
*/
|
2008-04-23 15:32:58 +02:00
|
|
|
static BOOL is_window_rect_mapped( const RECT *rect )
|
2004-04-28 01:32:01 +02:00
|
|
|
{
|
|
|
|
/* don't map if rect is off-screen */
|
2006-10-23 14:37:17 +02:00
|
|
|
if (rect->left >= virtual_screen_rect.right ||
|
|
|
|
rect->top >= virtual_screen_rect.bottom ||
|
|
|
|
rect->right <= virtual_screen_rect.left ||
|
|
|
|
rect->bottom <= virtual_screen_rect.top)
|
|
|
|
return FALSE;
|
2004-04-28 01:32:01 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-04 11:25:48 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* is_window_resizable
|
|
|
|
*
|
|
|
|
* Check if window should be made resizable by the window manager
|
|
|
|
*/
|
|
|
|
static inline BOOL is_window_resizable( struct x11drv_win_data *data, DWORD style )
|
|
|
|
{
|
|
|
|
if (style & WS_THICKFRAME) return TRUE;
|
|
|
|
/* Metacity needs the window to be resizable to make it fullscreen */
|
|
|
|
return (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 12:24:27 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_mwm_decorations
|
|
|
|
*/
|
2008-04-16 09:50:29 +02:00
|
|
|
static unsigned long get_mwm_decorations( struct x11drv_win_data *data,
|
|
|
|
DWORD style, DWORD ex_style )
|
2007-10-11 12:24:27 +02:00
|
|
|
{
|
|
|
|
unsigned long ret = 0;
|
|
|
|
|
2008-04-16 09:50:29 +02:00
|
|
|
if (!decorated_mode) return 0;
|
|
|
|
|
|
|
|
if (IsRectEmpty( &data->window_rect )) return 0;
|
2008-04-29 12:46:16 +02:00
|
|
|
if (data->shaped) return 0;
|
2008-04-10 21:53:45 +02:00
|
|
|
|
2007-10-11 12:24:27 +02:00
|
|
|
if (ex_style & WS_EX_TOOLWINDOW) return 0;
|
|
|
|
|
|
|
|
if ((style & WS_CAPTION) == WS_CAPTION)
|
|
|
|
{
|
|
|
|
ret |= MWM_DECOR_TITLE | MWM_DECOR_BORDER;
|
|
|
|
if (style & WS_SYSMENU) ret |= MWM_DECOR_MENU;
|
|
|
|
if (style & WS_MINIMIZEBOX) ret |= MWM_DECOR_MINIMIZE;
|
|
|
|
if (style & WS_MAXIMIZEBOX) ret |= MWM_DECOR_MAXIMIZE;
|
|
|
|
}
|
|
|
|
if (ex_style & WS_EX_DLGMODALFRAME) ret |= MWM_DECOR_BORDER;
|
|
|
|
else if (style & WS_THICKFRAME) ret |= MWM_DECOR_BORDER | MWM_DECOR_RESIZEH;
|
|
|
|
else if ((style & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME) ret |= MWM_DECOR_BORDER;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* get_x11_rect_offset
|
|
|
|
*
|
|
|
|
* Helper for X11DRV_window_to_X_rect and X11DRV_X_to_window_rect.
|
|
|
|
*/
|
|
|
|
static void get_x11_rect_offset( struct x11drv_win_data *data, RECT *rect )
|
|
|
|
{
|
|
|
|
DWORD style, ex_style, style_mask = 0, ex_style_mask = 0;
|
|
|
|
unsigned long decor;
|
|
|
|
|
|
|
|
rect->top = rect->bottom = rect->left = rect->right = 0;
|
|
|
|
|
|
|
|
style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
|
|
|
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
|
2008-04-16 09:50:29 +02:00
|
|
|
decor = get_mwm_decorations( data, style, ex_style );
|
2007-10-11 12:24:27 +02:00
|
|
|
|
|
|
|
if (decor & MWM_DECOR_TITLE) style_mask |= WS_CAPTION;
|
|
|
|
if (decor & MWM_DECOR_BORDER)
|
|
|
|
{
|
|
|
|
style_mask |= WS_DLGFRAME | WS_THICKFRAME;
|
|
|
|
ex_style_mask |= WS_EX_DLGMODALFRAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
AdjustWindowRectEx( rect, style & style_mask, FALSE, ex_style & ex_style_mask );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_window_attributes
|
|
|
|
*
|
2001-06-12 06:02:10 +02:00
|
|
|
* Fill the window attributes structure for an X window.
|
2001-06-04 23:55:17 +02:00
|
|
|
*/
|
2006-03-27 15:33:43 +02:00
|
|
|
static int get_window_attributes( Display *display, struct x11drv_win_data *data,
|
|
|
|
XSetWindowAttributes *attr )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2005-02-01 19:53:59 +01:00
|
|
|
attr->override_redirect = !data->managed;
|
2001-06-04 23:55:17 +02:00
|
|
|
attr->colormap = X11DRV_PALETTE_PaletteXColormap;
|
2005-01-17 20:17:47 +01:00
|
|
|
attr->save_under = ((GetClassLongW( data->hwnd, GCL_STYLE ) & CS_SAVEBITS) != 0);
|
2007-08-20 14:23:10 +02:00
|
|
|
attr->bit_gravity = NorthWestGravity;
|
2008-04-23 15:33:29 +02:00
|
|
|
attr->win_gravity = StaticGravity;
|
2007-08-20 14:23:10 +02:00
|
|
|
attr->backing_store = NotUseful;
|
|
|
|
attr->event_mask = (ExposureMask | PointerMotionMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
|
2008-12-16 01:47:24 +01:00
|
|
|
KeyPressMask | KeyReleaseMask | FocusChangeMask |
|
|
|
|
KeymapStateMask | StructureNotifyMask);
|
|
|
|
if (data->managed) attr->event_mask |= PropertyChangeMask;
|
2007-08-20 14:23:10 +02:00
|
|
|
|
2010-04-20 20:52:17 +02:00
|
|
|
return (CWOverrideRedirect | CWSaveUnder | CWColormap |
|
2007-08-20 14:23:10 +02:00
|
|
|
CWEventMask | CWBitGravity | CWBackingStore);
|
2001-06-12 06:02:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-22 10:40:22 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* create_client_window
|
|
|
|
*/
|
|
|
|
static Window create_client_window( Display *display, struct x11drv_win_data *data, XVisualInfo *vis )
|
|
|
|
{
|
|
|
|
int cx, cy, mask;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
Window client;
|
2008-05-13 10:43:48 +02:00
|
|
|
Visual *client_visual = vis ? vis->visual : visual;
|
2008-02-22 10:40:22 +01:00
|
|
|
|
|
|
|
attr.bit_gravity = NorthWestGravity;
|
|
|
|
attr.win_gravity = NorthWestGravity;
|
|
|
|
attr.backing_store = NotUseful;
|
|
|
|
attr.event_mask = (ExposureMask | PointerMotionMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask | EnterWindowMask);
|
|
|
|
mask = CWEventMask | CWBitGravity | CWWinGravity | CWBackingStore;
|
|
|
|
|
|
|
|
if ((cx = data->client_rect.right - data->client_rect.left) <= 0) cx = 1;
|
2009-05-05 15:36:25 +02:00
|
|
|
else if (cx > 65535) cx = 65535;
|
2008-02-22 10:40:22 +01:00
|
|
|
if ((cy = data->client_rect.bottom - data->client_rect.top) <= 0) cy = 1;
|
2009-05-05 15:36:25 +02:00
|
|
|
else if (cy > 65535) cy = 65535;
|
2008-02-22 10:40:22 +01:00
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
|
|
|
|
if (vis)
|
|
|
|
{
|
|
|
|
attr.colormap = XCreateColormap( display, root_window, vis->visual,
|
|
|
|
(vis->class == PseudoColor || vis->class == GrayScale ||
|
|
|
|
vis->class == DirectColor) ? AllocAll : AllocNone );
|
|
|
|
mask |= CWColormap;
|
|
|
|
}
|
|
|
|
|
|
|
|
client = XCreateWindow( display, data->whole_window,
|
|
|
|
data->client_rect.left - data->whole_rect.left,
|
|
|
|
data->client_rect.top - data->whole_rect.top,
|
|
|
|
cx, cy, 0, screen_depth, InputOutput,
|
2008-05-13 10:43:48 +02:00
|
|
|
client_visual, mask, &attr );
|
2008-02-22 10:40:22 +01:00
|
|
|
if (!client)
|
|
|
|
{
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data->client_window)
|
|
|
|
{
|
|
|
|
XDeleteContext( display, data->client_window, winContext );
|
|
|
|
XDestroyWindow( display, data->client_window );
|
|
|
|
}
|
|
|
|
data->client_window = client;
|
2008-05-13 10:43:48 +02:00
|
|
|
data->visualid = XVisualIDFromVisual( client_visual );
|
2008-02-22 10:40:22 +01:00
|
|
|
|
|
|
|
if (data->colormap) XFreeColormap( display, data->colormap );
|
|
|
|
data->colormap = vis ? attr.colormap : 0;
|
|
|
|
|
|
|
|
XMapWindow( display, data->client_window );
|
|
|
|
XSaveContext( display, data->client_window, winContext, (char *)data->hwnd );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
SetPropA( data->hwnd, client_window_prop, (HANDLE)data->client_window );
|
|
|
|
return data->client_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-12 06:02:10 +02:00
|
|
|
/***********************************************************************
|
2008-04-23 15:32:58 +02:00
|
|
|
* sync_window_style
|
2001-06-12 06:02:10 +02:00
|
|
|
*
|
|
|
|
* Change the X window attributes when the window style has changed.
|
|
|
|
*/
|
2008-04-23 15:32:58 +02:00
|
|
|
static void sync_window_style( Display *display, struct x11drv_win_data *data )
|
2001-06-12 06:02:10 +02:00
|
|
|
{
|
2007-08-20 14:23:10 +02:00
|
|
|
if (data->whole_window != root_window)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
int mask = get_window_attributes( display, data, &attr );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2007-08-20 14:23:10 +02:00
|
|
|
wine_tsx11_lock();
|
2006-03-06 21:02:59 +01:00
|
|
|
XChangeWindowAttributes( display, data->whole_window, mask, &attr );
|
2007-08-20 14:23:10 +02:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2008-01-23 16:30:18 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* sync_window_region
|
|
|
|
*
|
|
|
|
* Update the X11 window region.
|
|
|
|
*/
|
2008-09-08 15:51:08 +02:00
|
|
|
static void sync_window_region( Display *display, struct x11drv_win_data *data, HRGN win_region )
|
2008-01-23 16:30:18 +01:00
|
|
|
{
|
|
|
|
#ifdef HAVE_LIBXSHAPE
|
2008-09-08 15:51:08 +02:00
|
|
|
HRGN hrgn = win_region;
|
|
|
|
|
2008-01-23 16:30:18 +01:00
|
|
|
if (!data->whole_window) return;
|
2008-04-29 12:46:16 +02:00
|
|
|
data->shaped = FALSE;
|
2008-01-23 16:30:18 +01:00
|
|
|
|
2010-05-28 12:14:43 +02:00
|
|
|
if (IsRectEmpty( &data->window_rect )) /* set an empty shape */
|
|
|
|
{
|
|
|
|
static XRectangle empty_rect;
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XShapeCombineRectangles( display, data->whole_window, ShapeBounding, 0, 0,
|
|
|
|
&empty_rect, 1, ShapeSet, YXBanded );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-09-08 15:51:08 +02:00
|
|
|
if (hrgn == (HRGN)1) /* hack: win_region == 1 means retrieve region from server */
|
|
|
|
{
|
|
|
|
if (!(hrgn = CreateRectRgn( 0, 0, 0, 0 ))) return;
|
|
|
|
if (GetWindowRgn( data->hwnd, hrgn ) == ERROR)
|
|
|
|
{
|
|
|
|
DeleteObject( hrgn );
|
|
|
|
hrgn = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-23 16:30:18 +01:00
|
|
|
if (!hrgn)
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XShapeCombineMask( display, data->whole_window, ShapeBounding, 0, 0, None, ShapeSet );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-27 21:06:38 +02:00
|
|
|
RGNDATA *pRegionData;
|
|
|
|
|
|
|
|
if (GetWindowLongW( data->hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL) MirrorRgn( data->hwnd, hrgn );
|
|
|
|
if ((pRegionData = X11DRV_GetRegionData( hrgn, 0 )))
|
2008-01-23 16:30:18 +01:00
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XShapeCombineRectangles( display, data->whole_window, ShapeBounding,
|
|
|
|
data->window_rect.left - data->whole_rect.left,
|
|
|
|
data->window_rect.top - data->whole_rect.top,
|
|
|
|
(XRectangle *)pRegionData->Buffer,
|
|
|
|
pRegionData->rdh.nCount, ShapeSet, YXBanded );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
HeapFree(GetProcessHeap(), 0, pRegionData);
|
2008-04-29 12:46:16 +02:00
|
|
|
data->shaped = TRUE;
|
2008-01-23 16:30:18 +01:00
|
|
|
}
|
|
|
|
}
|
2008-09-08 15:51:08 +02:00
|
|
|
if (hrgn && hrgn != win_region) DeleteObject( hrgn );
|
2008-01-23 16:30:18 +01:00
|
|
|
#endif /* HAVE_LIBXSHAPE */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-12 15:54:02 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* sync_window_opacity
|
|
|
|
*/
|
|
|
|
static void sync_window_opacity( Display *display, Window win,
|
|
|
|
COLORREF key, BYTE alpha, DWORD flags )
|
|
|
|
{
|
|
|
|
unsigned long opacity = 0xffffffff;
|
|
|
|
|
|
|
|
if (flags & LWA_ALPHA) opacity = (0xffffffff / 0xff) * alpha;
|
|
|
|
|
|
|
|
if (flags & LWA_COLORKEY) FIXME("LWA_COLORKEY not supported\n");
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (opacity == 0xffffffff)
|
|
|
|
XDeleteProperty( display, win, x11drv_atom(_NET_WM_WINDOW_OPACITY) );
|
|
|
|
else
|
|
|
|
XChangeProperty( display, win, x11drv_atom(_NET_WM_WINDOW_OPACITY),
|
|
|
|
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&opacity, 1 );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-23 16:32:55 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* sync_window_text
|
|
|
|
*/
|
|
|
|
static void sync_window_text( Display *display, Window win, const WCHAR *text )
|
|
|
|
{
|
|
|
|
UINT count;
|
|
|
|
char *buffer, *utf8_buffer;
|
|
|
|
XTextProperty prop;
|
|
|
|
|
|
|
|
/* allocate new buffer for window text */
|
|
|
|
count = WideCharToMultiByte(CP_UNIXCP, 0, text, -1, NULL, 0, NULL, NULL);
|
|
|
|
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, count ))) return;
|
|
|
|
WideCharToMultiByte(CP_UNIXCP, 0, text, -1, buffer, count, NULL, NULL);
|
|
|
|
|
|
|
|
count = WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), NULL, 0, NULL, NULL);
|
|
|
|
if (!(utf8_buffer = HeapAlloc( GetProcessHeap(), 0, count )))
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), utf8_buffer, count, NULL, NULL);
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (XmbTextListToTextProperty( display, &buffer, 1, XStdICCTextStyle, &prop ) == Success)
|
|
|
|
{
|
|
|
|
XSetWMName( display, win, &prop );
|
|
|
|
XSetWMIconName( display, win, &prop );
|
|
|
|
XFree( prop.value );
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
Implements a NET_WM UTF-8 title. It should be without a trailing \0,
|
|
|
|
according to the standard
|
|
|
|
( http://www.pps.jussieu.fr/~jch/software/UTF8_STRING/UTF8_STRING.text ).
|
|
|
|
*/
|
|
|
|
XChangeProperty( display, win, x11drv_atom(_NET_WM_NAME), x11drv_atom(UTF8_STRING),
|
|
|
|
8, PropModeReplace, (unsigned char *) utf8_buffer, count);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, utf8_buffer );
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-15 22:02:32 +02:00
|
|
|
/***********************************************************************
|
2008-09-08 15:42:24 +02:00
|
|
|
* set_win_format
|
2007-09-15 22:02:32 +02:00
|
|
|
*/
|
2008-09-08 15:42:24 +02:00
|
|
|
static BOOL set_win_format( HWND hwnd, XID fbconfig_id )
|
2007-09-15 22:02:32 +02:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
2007-09-26 07:43:38 +02:00
|
|
|
XVisualInfo *vis;
|
|
|
|
int w, h;
|
2007-09-15 22:02:32 +02:00
|
|
|
|
2008-01-24 10:20:51 +01:00
|
|
|
if (!(data = X11DRV_get_win_data(hwnd)) &&
|
|
|
|
!(data = X11DRV_create_win_data(hwnd))) return FALSE;
|
2007-09-15 22:02:32 +02:00
|
|
|
|
2008-05-28 17:02:07 +02:00
|
|
|
if (!(vis = visual_from_fbconfig_id(fbconfig_id))) return FALSE;
|
2007-09-26 07:43:38 +02:00
|
|
|
|
2008-02-22 10:40:22 +01:00
|
|
|
if (data->whole_window)
|
2007-09-26 07:43:38 +02:00
|
|
|
{
|
2008-05-12 19:37:54 +02:00
|
|
|
Display *display = thread_display();
|
2008-02-22 10:40:22 +01:00
|
|
|
Window client = data->client_window;
|
|
|
|
|
2008-05-13 10:43:48 +02:00
|
|
|
if (vis->visualid != data->visualid)
|
2007-09-26 07:43:38 +02:00
|
|
|
{
|
2008-02-22 10:40:22 +01:00
|
|
|
client = create_client_window( display, data, vis );
|
|
|
|
TRACE( "re-created client window %lx for %p fbconfig %lx\n", client, data->hwnd, fbconfig_id );
|
2007-09-26 07:43:38 +02:00
|
|
|
}
|
2008-02-22 10:40:22 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XFree(vis);
|
2008-05-12 19:37:54 +02:00
|
|
|
XFlush( display );
|
2008-02-22 10:40:22 +01:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
if (client) goto done;
|
|
|
|
return FALSE;
|
2007-09-26 07:43:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
w = data->client_rect.right - data->client_rect.left;
|
|
|
|
h = data->client_rect.bottom - data->client_rect.top;
|
|
|
|
|
|
|
|
if(w <= 0) w = 1;
|
|
|
|
if(h <= 0) h = 1;
|
|
|
|
|
|
|
|
#ifdef SONAME_LIBXCOMPOSITE
|
|
|
|
if(usexcomposite)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attrib;
|
2008-05-12 19:14:11 +02:00
|
|
|
static Window dummy_parent;
|
2007-09-26 07:43:38 +02:00
|
|
|
|
2008-02-22 10:40:22 +01:00
|
|
|
wine_tsx11_lock();
|
2008-05-12 19:14:11 +02:00
|
|
|
attrib.override_redirect = True;
|
|
|
|
if (!dummy_parent)
|
|
|
|
{
|
|
|
|
dummy_parent = XCreateWindow( gdi_display, root_window, -1, -1, 1, 1, 0, screen_depth,
|
|
|
|
InputOutput, visual, CWOverrideRedirect, &attrib );
|
|
|
|
XMapWindow( gdi_display, dummy_parent );
|
|
|
|
}
|
|
|
|
data->colormap = XCreateColormap(gdi_display, dummy_parent, vis->visual,
|
2008-02-21 20:23:32 +01:00
|
|
|
(vis->class == PseudoColor ||
|
|
|
|
vis->class == GrayScale ||
|
|
|
|
vis->class == DirectColor) ?
|
|
|
|
AllocAll : AllocNone);
|
|
|
|
attrib.colormap = data->colormap;
|
2007-09-26 07:43:38 +02:00
|
|
|
XInstallColormap(gdi_display, attrib.colormap);
|
|
|
|
|
2008-04-23 00:15:15 +02:00
|
|
|
if(data->gl_drawable) XDestroyWindow(gdi_display, data->gl_drawable);
|
2008-05-12 19:14:11 +02:00
|
|
|
data->gl_drawable = XCreateWindow(gdi_display, dummy_parent, -w, 0, w, h, 0,
|
2007-09-26 07:43:38 +02:00
|
|
|
vis->depth, InputOutput, vis->visual,
|
|
|
|
CWColormap | CWOverrideRedirect,
|
|
|
|
&attrib);
|
|
|
|
if(data->gl_drawable)
|
|
|
|
{
|
2008-05-12 19:37:54 +02:00
|
|
|
pXCompositeRedirectWindow(gdi_display, data->gl_drawable,
|
2007-09-26 07:43:38 +02:00
|
|
|
CompositeRedirectManual);
|
2008-05-12 19:37:54 +02:00
|
|
|
XMapWindow(gdi_display, data->gl_drawable);
|
2007-09-26 07:43:38 +02:00
|
|
|
}
|
2008-02-22 10:40:22 +01:00
|
|
|
XFree(vis);
|
2008-05-12 19:37:54 +02:00
|
|
|
XFlush( gdi_display );
|
2008-02-22 10:40:22 +01:00
|
|
|
wine_tsx11_unlock();
|
2007-09-26 07:43:38 +02:00
|
|
|
}
|
2007-09-26 17:17:13 +02:00
|
|
|
else
|
2007-09-26 07:43:38 +02:00
|
|
|
#endif
|
2007-09-26 17:17:13 +02:00
|
|
|
{
|
|
|
|
WARN("XComposite is not available, using GLXPixmap hack\n");
|
|
|
|
|
2008-02-22 10:40:22 +01:00
|
|
|
wine_tsx11_lock();
|
2008-04-23 00:15:15 +02:00
|
|
|
|
2008-05-12 19:37:54 +02:00
|
|
|
if(data->pixmap) XFreePixmap(gdi_display, data->pixmap);
|
|
|
|
data->pixmap = XCreatePixmap(gdi_display, root_window, w, h, vis->depth);
|
2007-09-26 17:17:13 +02:00
|
|
|
if(!data->pixmap)
|
|
|
|
{
|
|
|
|
XFree(vis);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-05-12 19:37:54 +02:00
|
|
|
if(data->gl_drawable) destroy_glxpixmap(gdi_display, data->gl_drawable);
|
|
|
|
data->gl_drawable = create_glxpixmap(gdi_display, vis, data->pixmap);
|
2007-09-26 17:17:13 +02:00
|
|
|
if(!data->gl_drawable)
|
|
|
|
{
|
2008-05-12 19:37:54 +02:00
|
|
|
XFreePixmap(gdi_display, data->pixmap);
|
2007-09-26 17:17:13 +02:00
|
|
|
data->pixmap = 0;
|
|
|
|
}
|
2007-09-26 07:43:38 +02:00
|
|
|
XFree(vis);
|
2008-05-12 19:37:54 +02:00
|
|
|
XFlush( gdi_display );
|
2007-09-26 07:43:38 +02:00
|
|
|
wine_tsx11_unlock();
|
2008-02-22 10:40:22 +01:00
|
|
|
if (data->pixmap) SetPropA(hwnd, pixmap_prop, (HANDLE)data->pixmap);
|
2007-09-26 07:43:38 +02:00
|
|
|
}
|
|
|
|
|
2008-02-22 10:40:22 +01:00
|
|
|
if (!data->gl_drawable) return FALSE;
|
2007-09-26 07:43:38 +02:00
|
|
|
|
|
|
|
TRACE("Created GL drawable 0x%lx, using FBConfigID 0x%lx\n",
|
|
|
|
data->gl_drawable, fbconfig_id);
|
2008-02-22 10:40:22 +01:00
|
|
|
SetPropA(hwnd, gl_drawable_prop, (HANDLE)data->gl_drawable);
|
2007-09-26 07:43:38 +02:00
|
|
|
|
2008-02-22 10:40:22 +01:00
|
|
|
done:
|
2007-09-15 22:02:32 +02:00
|
|
|
data->fbconfig_id = fbconfig_id;
|
|
|
|
SetPropA(hwnd, fbconfig_id_prop, (HANDLE)data->fbconfig_id);
|
2008-04-21 20:32:22 +02:00
|
|
|
/* force DCE invalidation */
|
|
|
|
SetWindowPos( hwnd, 0, 0, 0, 0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE |
|
2008-06-18 20:10:56 +02:00
|
|
|
SWP_NOREDRAW | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_STATECHANGED);
|
2007-09-15 22:02:32 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-01-23 12:28:01 +01:00
|
|
|
/***********************************************************************
|
2008-02-21 12:29:36 +01:00
|
|
|
* sync_gl_drawable
|
2008-01-23 12:28:01 +01:00
|
|
|
*/
|
2008-05-12 19:37:54 +02:00
|
|
|
static void sync_gl_drawable(struct x11drv_win_data *data)
|
2007-09-26 07:43:38 +02:00
|
|
|
{
|
|
|
|
int w = data->client_rect.right - data->client_rect.left;
|
|
|
|
int h = data->client_rect.bottom - data->client_rect.top;
|
2007-09-26 17:17:13 +02:00
|
|
|
XVisualInfo *vis;
|
|
|
|
Drawable glxp;
|
|
|
|
Pixmap pix;
|
2007-09-26 07:43:38 +02:00
|
|
|
|
2008-02-22 16:30:10 +01:00
|
|
|
if (w <= 0) w = 1;
|
|
|
|
if (h <= 0) h = 1;
|
|
|
|
|
2007-09-26 07:43:38 +02:00
|
|
|
TRACE("Resizing GL drawable 0x%lx to %dx%d\n", data->gl_drawable, w, h);
|
|
|
|
#ifdef SONAME_LIBXCOMPOSITE
|
|
|
|
if(usexcomposite)
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
2008-05-12 19:37:54 +02:00
|
|
|
XMoveResizeWindow(gdi_display, data->gl_drawable, -w, 0, w, h);
|
2007-09-26 07:43:38 +02:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2007-09-26 17:17:13 +02:00
|
|
|
|
2008-05-28 17:02:07 +02:00
|
|
|
if (!(vis = visual_from_fbconfig_id(data->fbconfig_id))) return;
|
2007-09-26 17:17:13 +02:00
|
|
|
|
2008-05-28 17:02:07 +02:00
|
|
|
wine_tsx11_lock();
|
2008-05-12 19:37:54 +02:00
|
|
|
pix = XCreatePixmap(gdi_display, root_window, w, h, vis->depth);
|
2007-09-26 17:17:13 +02:00
|
|
|
if(!pix)
|
|
|
|
{
|
|
|
|
ERR("Failed to create pixmap for offscreen rendering\n");
|
|
|
|
XFree(vis);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-12 19:37:54 +02:00
|
|
|
glxp = create_glxpixmap(gdi_display, vis, pix);
|
2007-09-26 17:17:13 +02:00
|
|
|
if(!glxp)
|
|
|
|
{
|
|
|
|
ERR("Failed to create drawable for offscreen rendering\n");
|
2008-05-12 19:37:54 +02:00
|
|
|
XFreePixmap(gdi_display, pix);
|
2007-09-26 17:17:13 +02:00
|
|
|
XFree(vis);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree(vis);
|
|
|
|
|
|
|
|
mark_drawable_dirty(data->gl_drawable, glxp);
|
|
|
|
|
2008-05-12 19:37:54 +02:00
|
|
|
XFreePixmap(gdi_display, data->pixmap);
|
|
|
|
destroy_glxpixmap(gdi_display, data->gl_drawable);
|
2008-04-21 20:32:22 +02:00
|
|
|
TRACE( "Recreated GL drawable %lx to replace %lx\n", glxp, data->gl_drawable );
|
2007-09-26 17:17:13 +02:00
|
|
|
|
|
|
|
data->pixmap = pix;
|
|
|
|
data->gl_drawable = glxp;
|
|
|
|
|
2008-05-12 19:37:54 +02:00
|
|
|
XFlush( gdi_display );
|
2007-09-26 17:17:13 +02:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
SetPropA(data->hwnd, gl_drawable_prop, (HANDLE)data->gl_drawable);
|
|
|
|
SetPropA(data->hwnd, pixmap_prop, (HANDLE)data->pixmap);
|
2007-09-26 07:43:38 +02:00
|
|
|
}
|
|
|
|
|
2007-09-15 22:02:32 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_window_changes
|
|
|
|
*
|
|
|
|
* fill the window changes structure
|
|
|
|
*/
|
|
|
|
static int get_window_changes( XWindowChanges *changes, const RECT *old, const RECT *new )
|
|
|
|
{
|
|
|
|
int mask = 0;
|
|
|
|
|
|
|
|
if (old->right - old->left != new->right - new->left )
|
|
|
|
{
|
2008-02-21 12:29:36 +01:00
|
|
|
if ((changes->width = new->right - new->left) <= 0) changes->width = 1;
|
2009-05-05 15:36:25 +02:00
|
|
|
else if (changes->width > 65535) changes->width = 65535;
|
2001-06-04 23:55:17 +02:00
|
|
|
mask |= CWWidth;
|
|
|
|
}
|
|
|
|
if (old->bottom - old->top != new->bottom - new->top)
|
|
|
|
{
|
2008-02-21 12:29:36 +01:00
|
|
|
if ((changes->height = new->bottom - new->top) <= 0) changes->height = 1;
|
2009-05-05 15:36:25 +02:00
|
|
|
else if (changes->height > 65535) changes->height = 65535;
|
2001-06-04 23:55:17 +02:00
|
|
|
mask |= CWHeight;
|
|
|
|
}
|
|
|
|
if (old->left != new->left)
|
|
|
|
{
|
|
|
|
changes->x = new->left;
|
|
|
|
mask |= CWX;
|
|
|
|
}
|
|
|
|
if (old->top != new->top)
|
|
|
|
{
|
|
|
|
changes->y = new->top;
|
|
|
|
mask |= CWY;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* create_icon_window
|
|
|
|
*/
|
2005-01-17 20:17:47 +01:00
|
|
|
static Window create_icon_window( Display *display, struct x11drv_win_data *data )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
attr.event_mask = (ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask |
|
2002-06-14 02:08:40 +02:00
|
|
|
ButtonPressMask | ButtonReleaseMask | EnterWindowMask);
|
2001-06-04 23:55:17 +02:00
|
|
|
attr.bit_gravity = NorthWestGravity;
|
|
|
|
attr.backing_store = NotUseful/*WhenMapped*/;
|
2001-07-13 00:27:56 +02:00
|
|
|
attr.colormap = X11DRV_PALETTE_PaletteXColormap; /* Needed due to our visual */
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2001-06-26 23:10:11 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
data->icon_window = XCreateWindow( display, root_window, 0, 0,
|
|
|
|
GetSystemMetrics( SM_CXICON ),
|
|
|
|
GetSystemMetrics( SM_CYICON ),
|
|
|
|
0, screen_depth,
|
|
|
|
InputOutput, visual,
|
2001-07-13 00:27:56 +02:00
|
|
|
CWEventMask | CWBitGravity | CWBackingStore | CWColormap, &attr );
|
2005-01-17 20:17:47 +01:00
|
|
|
XSaveContext( display, data->icon_window, winContext, (char *)data->hwnd );
|
2008-04-09 20:24:27 +02:00
|
|
|
XFlush( display ); /* make sure the window exists before we start painting to it */
|
2001-06-26 23:10:11 +02:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
TRACE( "created %lx\n", data->icon_window );
|
2005-07-07 19:30:57 +02:00
|
|
|
SetPropA( data->hwnd, icon_window_prop, (HANDLE)data->icon_window );
|
2001-06-04 23:55:17 +02:00
|
|
|
return data->icon_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* destroy_icon_window
|
|
|
|
*/
|
2005-01-31 17:34:07 +01:00
|
|
|
static void destroy_icon_window( Display *display, struct x11drv_win_data *data )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
|
|
|
if (!data->icon_window) return;
|
2001-07-12 04:49:31 +02:00
|
|
|
wine_tsx11_lock();
|
2001-06-04 23:55:17 +02:00
|
|
|
XDeleteContext( display, data->icon_window, winContext );
|
|
|
|
XDestroyWindow( display, data->icon_window );
|
|
|
|
data->icon_window = 0;
|
2001-07-12 04:49:31 +02:00
|
|
|
wine_tsx11_unlock();
|
2005-07-07 19:30:57 +02:00
|
|
|
RemovePropA( data->hwnd, icon_window_prop );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-19 11:13:34 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_bitmap_argb
|
|
|
|
*
|
|
|
|
* Return the bitmap bits in ARGB format. Helper for setting icon hints.
|
|
|
|
*/
|
|
|
|
static unsigned long *get_bitmap_argb( HDC hdc, HBITMAP color, HBITMAP mask, unsigned int *size )
|
|
|
|
{
|
|
|
|
BITMAP bm;
|
|
|
|
BITMAPINFO *info;
|
2010-04-19 14:49:26 +02:00
|
|
|
unsigned int *ptr, *bits = NULL;
|
|
|
|
unsigned char *mask_bits = NULL;
|
|
|
|
int i, j, has_alpha = 0;
|
2010-04-19 11:13:34 +02:00
|
|
|
|
|
|
|
if (!GetObjectW( color, sizeof(bm), &bm )) return NULL;
|
|
|
|
if (!(info = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] )))) return NULL;
|
|
|
|
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
info->bmiHeader.biWidth = bm.bmWidth;
|
|
|
|
info->bmiHeader.biHeight = -bm.bmHeight;
|
|
|
|
info->bmiHeader.biPlanes = 1;
|
|
|
|
info->bmiHeader.biBitCount = 32;
|
|
|
|
info->bmiHeader.biCompression = BI_RGB;
|
|
|
|
info->bmiHeader.biSizeImage = bm.bmWidth * bm.bmHeight * 4;
|
|
|
|
info->bmiHeader.biXPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biYPelsPerMeter = 0;
|
|
|
|
info->bmiHeader.biClrUsed = 0;
|
|
|
|
info->bmiHeader.biClrImportant = 0;
|
|
|
|
*size = bm.bmWidth * bm.bmHeight + 2;
|
|
|
|
if (!(bits = HeapAlloc( GetProcessHeap(), 0, *size * sizeof(long) ))) goto failed;
|
|
|
|
if (!GetDIBits( hdc, color, 0, bm.bmHeight, bits + 2, info, DIB_RGB_COLORS )) goto failed;
|
|
|
|
|
|
|
|
bits[0] = bm.bmWidth;
|
|
|
|
bits[1] = bm.bmHeight;
|
|
|
|
|
2010-04-19 14:49:26 +02:00
|
|
|
for (i = 0; i < bm.bmWidth * bm.bmHeight; i++)
|
|
|
|
if ((has_alpha = (bits[i + 2] & 0xff000000) != 0)) break;
|
|
|
|
|
|
|
|
if (!has_alpha)
|
|
|
|
{
|
|
|
|
unsigned int width_bytes = (bm.bmWidth + 31) / 32 * 4;
|
|
|
|
/* generate alpha channel from the mask */
|
|
|
|
info->bmiHeader.biBitCount = 1;
|
|
|
|
info->bmiHeader.biSizeImage = width_bytes * bm.bmHeight;
|
|
|
|
if (!(mask_bits = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto failed;
|
|
|
|
if (!GetDIBits( hdc, mask, 0, bm.bmHeight, mask_bits, info, DIB_RGB_COLORS )) goto failed;
|
|
|
|
ptr = bits + 2;
|
|
|
|
for (i = 0; i < bm.bmHeight; i++)
|
|
|
|
for (j = 0; j < bm.bmWidth; j++, ptr++)
|
2010-04-22 14:16:44 +02:00
|
|
|
if (!((mask_bits[i * width_bytes + j / 8] << (j % 8)) & 0x80)) *ptr |= 0xff000000;
|
2010-04-20 13:55:11 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, mask_bits );
|
2010-04-19 14:49:26 +02:00
|
|
|
}
|
2010-04-20 13:55:11 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, info );
|
2010-04-19 14:49:26 +02:00
|
|
|
|
2010-04-19 11:13:34 +02:00
|
|
|
/* convert to array of longs */
|
|
|
|
if (bits && sizeof(long) > sizeof(int))
|
|
|
|
for (i = *size - 1; i >= 0; i--) ((unsigned long *)bits)[i] = bits[i];
|
|
|
|
|
|
|
|
return (unsigned long *)bits;
|
|
|
|
|
|
|
|
failed:
|
|
|
|
HeapFree( GetProcessHeap(), 0, info );
|
|
|
|
HeapFree( GetProcessHeap(), 0, bits );
|
2010-04-19 14:49:26 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, mask_bits );
|
2010-04-19 11:13:34 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* set_icon_hints
|
|
|
|
*
|
|
|
|
* Set the icon wm hints
|
|
|
|
*/
|
2010-04-19 17:51:44 +02:00
|
|
|
static void set_icon_hints( Display *display, struct x11drv_win_data *data,
|
|
|
|
HICON icon_big, HICON icon_small )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2007-08-16 23:27:37 +02:00
|
|
|
XWMHints *hints = data->wm_hints;
|
|
|
|
|
2010-04-19 17:51:44 +02:00
|
|
|
if (!icon_big)
|
|
|
|
{
|
|
|
|
icon_big = (HICON)SendMessageW( data->hwnd, WM_GETICON, ICON_BIG, 0 );
|
|
|
|
if (!icon_big) icon_big = (HICON)GetClassLongPtrW( data->hwnd, GCLP_HICON );
|
|
|
|
}
|
|
|
|
if (!icon_small)
|
|
|
|
{
|
|
|
|
icon_small = (HICON)SendMessageW( data->hwnd, WM_GETICON, ICON_SMALL, 0 );
|
|
|
|
if (!icon_small) icon_small = (HICON)GetClassLongPtrW( data->hwnd, GCLP_HICONSM );
|
|
|
|
}
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap );
|
|
|
|
if (data->hWMIconMask) DeleteObject( data->hWMIconMask);
|
2001-06-12 06:02:10 +02:00
|
|
|
data->hWMIconBitmap = 0;
|
|
|
|
data->hWMIconMask = 0;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2010-04-19 17:51:44 +02:00
|
|
|
if (!icon_big)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2005-01-17 20:17:47 +01:00
|
|
|
if (!data->icon_window) create_icon_window( display, data );
|
2001-06-04 23:55:17 +02:00
|
|
|
hints->icon_window = data->icon_window;
|
|
|
|
hints->flags = (hints->flags & ~(IconPixmapHint | IconMaskHint)) | IconWindowHint;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HBITMAP hbmOrig;
|
|
|
|
RECT rcMask;
|
2010-04-16 16:23:33 +02:00
|
|
|
BITMAP bm;
|
2010-05-20 17:37:28 +02:00
|
|
|
ICONINFO ii, ii_small;
|
2001-04-25 01:28:52 +02:00
|
|
|
HDC hDC;
|
2010-04-19 11:13:34 +02:00
|
|
|
unsigned int size;
|
|
|
|
unsigned long *bits;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2010-05-20 17:37:28 +02:00
|
|
|
if (!GetIconInfo(icon_big, &ii)) return;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2010-04-16 16:23:33 +02:00
|
|
|
GetObjectW(ii.hbmMask, sizeof(bm), &bm);
|
2001-04-25 01:28:52 +02:00
|
|
|
rcMask.top = 0;
|
|
|
|
rcMask.left = 0;
|
2010-04-16 16:23:33 +02:00
|
|
|
rcMask.right = bm.bmWidth;
|
|
|
|
rcMask.bottom = bm.bmHeight;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
hDC = CreateCompatibleDC(0);
|
2010-04-19 11:13:34 +02:00
|
|
|
bits = get_bitmap_argb( hDC, ii.hbmColor, ii.hbmMask, &size );
|
2010-05-20 17:37:28 +02:00
|
|
|
if (bits && GetIconInfo( icon_small, &ii_small ))
|
2010-04-19 17:51:44 +02:00
|
|
|
{
|
|
|
|
unsigned int size_small;
|
|
|
|
unsigned long *bits_small, *new;
|
|
|
|
|
2010-05-20 17:37:28 +02:00
|
|
|
if ((bits_small = get_bitmap_argb( hDC, ii_small.hbmColor, ii_small.hbmMask, &size_small )) &&
|
2010-04-22 14:47:57 +02:00
|
|
|
(bits_small[0] != bits[0] || bits_small[1] != bits[1])) /* size must be different */
|
2010-04-19 17:51:44 +02:00
|
|
|
{
|
|
|
|
if ((new = HeapReAlloc( GetProcessHeap(), 0, bits,
|
|
|
|
(size + size_small) * sizeof(unsigned long) )))
|
|
|
|
{
|
|
|
|
bits = new;
|
|
|
|
memcpy( bits + size, bits_small, size_small * sizeof(unsigned long) );
|
|
|
|
size += size_small;
|
|
|
|
}
|
|
|
|
}
|
2010-04-22 14:47:57 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, bits_small );
|
2010-05-20 17:37:28 +02:00
|
|
|
DeleteObject( ii_small.hbmColor );
|
|
|
|
DeleteObject( ii_small.hbmMask );
|
2010-04-19 17:51:44 +02:00
|
|
|
}
|
2010-04-19 11:13:34 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
if (bits)
|
|
|
|
XChangeProperty( display, data->whole_window, x11drv_atom(_NET_WM_ICON),
|
|
|
|
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)bits, size );
|
|
|
|
else
|
|
|
|
XDeleteProperty( display, data->whole_window, x11drv_atom(_NET_WM_ICON) );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
HeapFree( GetProcessHeap(), 0, bits );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2010-04-22 14:16:44 +02:00
|
|
|
hbmOrig = SelectObject(hDC, ii.hbmMask);
|
|
|
|
InvertRect(hDC, &rcMask);
|
|
|
|
SelectObject(hDC, ii.hbmColor); /* force the color bitmap to x11drv mode too */
|
|
|
|
SelectObject(hDC, hbmOrig);
|
|
|
|
|
|
|
|
data->hWMIconBitmap = ii.hbmColor;
|
|
|
|
data->hWMIconMask = ii.hbmMask;
|
|
|
|
|
|
|
|
hints->icon_pixmap = X11DRV_get_pixmap(data->hWMIconBitmap);
|
|
|
|
hints->icon_mask = X11DRV_get_pixmap(data->hWMIconMask);
|
|
|
|
destroy_icon_window( display, data );
|
|
|
|
hints->flags = (hints->flags & ~IconWindowHint) | IconPixmapHint | IconMaskHint;
|
|
|
|
|
2010-04-19 17:51:44 +02:00
|
|
|
DeleteDC(hDC);
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-04 23:55:17 +02:00
|
|
|
* set_size_hints
|
2001-04-25 01:28:52 +02:00
|
|
|
*
|
2001-06-04 23:55:17 +02:00
|
|
|
* set the window size hints
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
2005-01-17 20:17:47 +01:00
|
|
|
static void set_size_hints( Display *display, struct x11drv_win_data *data, DWORD style )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-06-04 23:55:17 +02:00
|
|
|
XSizeHints* size_hints;
|
|
|
|
|
2008-04-04 11:28:30 +02:00
|
|
|
if (!(size_hints = XAllocSizeHints())) return;
|
2006-03-27 22:16:04 +02:00
|
|
|
|
2008-04-23 15:33:29 +02:00
|
|
|
size_hints->win_gravity = StaticGravity;
|
|
|
|
size_hints->flags |= PWinGravity;
|
|
|
|
|
2008-04-04 11:28:30 +02:00
|
|
|
/* don't update size hints if window is not in normal state */
|
|
|
|
if (!(style & (WS_MINIMIZE | WS_MAXIMIZE)))
|
|
|
|
{
|
2006-03-27 22:16:04 +02:00
|
|
|
if (data->hwnd != GetDesktopWindow()) /* don't force position of desktop */
|
|
|
|
{
|
|
|
|
size_hints->x = data->whole_rect.left;
|
|
|
|
size_hints->y = data->whole_rect.top;
|
2008-04-23 15:33:29 +02:00
|
|
|
size_hints->flags |= PPosition;
|
2006-03-27 22:16:04 +02:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2008-04-04 11:25:48 +02:00
|
|
|
if (!is_window_resizable( data, style ))
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2008-04-04 11:25:48 +02:00
|
|
|
size_hints->max_width = data->whole_rect.right - data->whole_rect.left;
|
|
|
|
size_hints->max_height = data->whole_rect.bottom - data->whole_rect.top;
|
2010-05-28 12:13:01 +02:00
|
|
|
if (size_hints->max_width <= 0 ||size_hints->max_height <= 0)
|
|
|
|
size_hints->max_width = size_hints->max_height = 1;
|
2008-04-04 11:25:48 +02:00
|
|
|
size_hints->min_width = size_hints->max_width;
|
|
|
|
size_hints->min_height = size_hints->max_height;
|
|
|
|
size_hints->flags |= PMinSize | PMaxSize;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
}
|
2008-04-04 11:28:30 +02:00
|
|
|
XSetWMNormalHints( display, data->whole_window, size_hints );
|
|
|
|
XFree( size_hints );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-01 18:16:00 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_process_name
|
|
|
|
*
|
|
|
|
* get the name of the current process for setting class hints
|
|
|
|
*/
|
|
|
|
static char *get_process_name(void)
|
|
|
|
{
|
|
|
|
static char *name;
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
{
|
|
|
|
WCHAR module[MAX_PATH];
|
|
|
|
DWORD len = GetModuleFileNameW( 0, module, MAX_PATH );
|
|
|
|
if (len && len < MAX_PATH)
|
|
|
|
{
|
|
|
|
char *ptr;
|
|
|
|
WCHAR *p, *appname = module;
|
|
|
|
|
|
|
|
if ((p = strrchrW( appname, '/' ))) appname = p + 1;
|
|
|
|
if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
|
|
|
|
len = WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, NULL, 0, NULL, NULL );
|
|
|
|
if ((ptr = HeapAlloc( GetProcessHeap(), 0, len )))
|
|
|
|
{
|
|
|
|
WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, ptr, len, NULL, NULL );
|
|
|
|
name = ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 14:04:36 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* set_initial_wm_hints
|
|
|
|
*
|
|
|
|
* Set the window manager hints that don't change over the lifetime of a window.
|
|
|
|
*/
|
|
|
|
static void set_initial_wm_hints( Display *display, struct x11drv_win_data *data )
|
|
|
|
{
|
2008-04-07 11:41:54 +02:00
|
|
|
long i;
|
2007-08-20 14:04:36 +02:00
|
|
|
Atom protocols[3];
|
2010-02-20 09:57:07 +01:00
|
|
|
Atom dndVersion = WINE_XDND_VERSION;
|
2007-08-20 14:04:36 +02:00
|
|
|
XClassHint *class_hints;
|
|
|
|
char *process_name = get_process_name();
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
|
|
|
|
/* wm protocols */
|
|
|
|
i = 0;
|
|
|
|
protocols[i++] = x11drv_atom(WM_DELETE_WINDOW);
|
|
|
|
protocols[i++] = x11drv_atom(_NET_WM_PING);
|
|
|
|
if (use_take_focus) protocols[i++] = x11drv_atom(WM_TAKE_FOCUS);
|
|
|
|
XChangeProperty( display, data->whole_window, x11drv_atom(WM_PROTOCOLS),
|
|
|
|
XA_ATOM, 32, PropModeReplace, (unsigned char *)protocols, i );
|
|
|
|
|
|
|
|
/* class hints */
|
|
|
|
if ((class_hints = XAllocClassHint()))
|
|
|
|
{
|
|
|
|
static char wine[] = "Wine";
|
|
|
|
|
|
|
|
class_hints->res_name = process_name;
|
|
|
|
class_hints->res_class = wine;
|
|
|
|
XSetClassHint( display, data->whole_window, class_hints );
|
|
|
|
XFree( class_hints );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the WM_CLIENT_MACHINE and WM_LOCALE_NAME properties */
|
|
|
|
XSetWMProperties(display, data->whole_window, NULL, NULL, NULL, 0, NULL, NULL, NULL);
|
|
|
|
/* set the pid. together, these properties are needed so the window manager can kill us if we freeze */
|
|
|
|
i = getpid();
|
|
|
|
XChangeProperty(display, data->whole_window, x11drv_atom(_NET_WM_PID),
|
|
|
|
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&i, 1);
|
|
|
|
|
|
|
|
XChangeProperty( display, data->whole_window, x11drv_atom(XdndAware),
|
|
|
|
XA_ATOM, 32, PropModeReplace, (unsigned char*)&dndVersion, 1 );
|
|
|
|
|
2010-06-29 11:08:51 +02:00
|
|
|
update_user_time( 0 ); /* make sure that the user time window exists */
|
|
|
|
if (user_time_window)
|
|
|
|
XChangeProperty( display, data->whole_window, x11drv_atom(_NET_WM_USER_TIME_WINDOW),
|
|
|
|
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&user_time_window, 1 );
|
|
|
|
|
2008-01-22 10:17:52 +01:00
|
|
|
data->wm_hints = XAllocWMHints();
|
2007-08-20 14:04:36 +02:00
|
|
|
wine_tsx11_unlock();
|
2008-01-18 14:34:57 +01:00
|
|
|
|
|
|
|
if (data->wm_hints)
|
|
|
|
{
|
|
|
|
data->wm_hints->flags = 0;
|
2010-04-19 17:51:44 +02:00
|
|
|
set_icon_hints( display, data, 0, 0 );
|
2008-01-18 14:34:57 +01:00
|
|
|
}
|
2007-08-20 14:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-23 12:33:01 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* get_owner_whole_window
|
|
|
|
*
|
|
|
|
* Retrieve an owner's window, creating it if necessary.
|
|
|
|
*/
|
2010-03-20 20:16:42 +01:00
|
|
|
static Window get_owner_whole_window( HWND owner, BOOL force_managed )
|
2010-02-23 12:33:01 +01:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
|
|
|
if (!owner) return 0;
|
|
|
|
|
|
|
|
if (!(data = X11DRV_get_win_data( owner )))
|
|
|
|
{
|
2010-03-01 17:06:19 +01:00
|
|
|
if (GetWindowThreadProcessId( owner, NULL ) != GetCurrentThreadId() ||
|
|
|
|
!(data = X11DRV_create_win_data( owner )))
|
2010-02-23 12:33:01 +01:00
|
|
|
return (Window)GetPropA( owner, whole_window_prop );
|
|
|
|
}
|
2010-03-20 20:16:42 +01:00
|
|
|
else if (!data->managed && force_managed) /* make it managed */
|
2010-02-23 12:35:10 +01:00
|
|
|
{
|
|
|
|
SetWindowPos( owner, 0, 0, 0, 0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE |
|
|
|
|
SWP_NOREDRAW | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_STATECHANGED );
|
|
|
|
}
|
2010-02-23 12:33:01 +01:00
|
|
|
return data->whole_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/***********************************************************************
|
2008-04-23 15:32:58 +02:00
|
|
|
* set_wm_hints
|
2001-06-04 23:55:17 +02:00
|
|
|
*
|
|
|
|
* Set the window manager hints for a newly-created window
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
2008-04-23 15:32:58 +02:00
|
|
|
static void set_wm_hints( Display *display, struct x11drv_win_data *data )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2010-02-23 12:33:01 +01:00
|
|
|
Window group_leader = data->whole_window;
|
|
|
|
Window owner_win = 0;
|
2006-10-11 17:32:22 +02:00
|
|
|
Atom window_type;
|
2003-11-20 05:24:18 +01:00
|
|
|
MwmHints mwm_hints;
|
2008-04-14 13:27:38 +02:00
|
|
|
DWORD style, ex_style;
|
|
|
|
HWND owner;
|
2005-01-17 20:17:47 +01:00
|
|
|
|
2006-03-27 22:16:04 +02:00
|
|
|
if (data->hwnd == GetDesktopWindow())
|
|
|
|
{
|
|
|
|
/* force some styles for the desktop to get the correct decorations */
|
2008-04-14 13:27:38 +02:00
|
|
|
style = WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
|
|
|
|
ex_style = WS_EX_APPWINDOW;
|
2006-03-27 22:16:04 +02:00
|
|
|
owner = 0;
|
|
|
|
}
|
2008-04-14 13:27:38 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
|
|
|
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
|
2010-05-28 12:14:43 +02:00
|
|
|
owner = GetWindow( data->hwnd, GW_OWNER );
|
2010-03-20 20:16:42 +01:00
|
|
|
if ((owner_win = get_owner_whole_window( owner, data->managed ))) group_leader = owner_win;
|
2008-04-14 13:27:38 +02:00
|
|
|
}
|
2006-03-27 22:16:04 +02:00
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
|
2010-02-23 12:33:01 +01:00
|
|
|
if (owner_win) XSetTransientForHint( display, data->whole_window, owner_win );
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/* size hints */
|
2005-01-17 20:17:47 +01:00
|
|
|
set_size_hints( display, data, style );
|
2002-01-21 19:41:27 +01:00
|
|
|
|
2006-10-11 17:32:22 +02:00
|
|
|
/* set the WM_WINDOW_TYPE */
|
2008-04-07 06:37:44 +02:00
|
|
|
if (style & WS_THICKFRAME) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_NORMAL);
|
2008-04-14 13:27:19 +02:00
|
|
|
else if (ex_style & WS_EX_APPWINDOW) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_NORMAL);
|
2010-05-28 12:12:32 +02:00
|
|
|
else if (style & WS_MINIMIZEBOX) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_NORMAL);
|
2006-10-11 17:32:22 +02:00
|
|
|
else if (style & WS_DLGFRAME) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_DIALOG);
|
|
|
|
else if (ex_style & WS_EX_DLGMODALFRAME) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_DIALOG);
|
2010-12-28 11:49:37 +01:00
|
|
|
/* many window managers don't handle utility windows very well, so we don't use TYPE_UTILITY here */
|
|
|
|
else if (ex_style & WS_EX_TOOLWINDOW) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_NORMAL);
|
2008-04-21 20:33:18 +02:00
|
|
|
else if ((style & WS_POPUP) && owner) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_DIALOG);
|
2008-04-14 13:27:19 +02:00
|
|
|
else window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_NORMAL);
|
2006-10-11 17:32:22 +02:00
|
|
|
|
|
|
|
XChangeProperty(display, data->whole_window, x11drv_atom(_NET_WM_WINDOW_TYPE),
|
|
|
|
XA_ATOM, 32, PropModeReplace, (unsigned char*)&window_type, 1);
|
2003-12-04 22:54:13 +01:00
|
|
|
|
2003-11-20 05:24:18 +01:00
|
|
|
mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
2008-04-16 09:50:29 +02:00
|
|
|
mwm_hints.decorations = get_mwm_decorations( data, style, ex_style );
|
2006-10-05 16:16:36 +02:00
|
|
|
mwm_hints.functions = MWM_FUNC_MOVE;
|
2008-04-04 11:25:48 +02:00
|
|
|
if (is_window_resizable( data, style )) mwm_hints.functions |= MWM_FUNC_RESIZE;
|
2010-04-07 08:41:01 +02:00
|
|
|
if (!(style & WS_DISABLED))
|
|
|
|
{
|
|
|
|
if (style & WS_MINIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MINIMIZE;
|
|
|
|
if (style & WS_MAXIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MAXIMIZE;
|
|
|
|
if (style & WS_SYSMENU) mwm_hints.functions |= MWM_FUNC_CLOSE;
|
|
|
|
}
|
2003-11-20 05:24:18 +01:00
|
|
|
|
|
|
|
XChangeProperty( display, data->whole_window, x11drv_atom(_MOTIF_WM_HINTS),
|
|
|
|
x11drv_atom(_MOTIF_WM_HINTS), 32, PropModeReplace,
|
2005-03-22 22:17:34 +01:00
|
|
|
(unsigned char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2001-07-12 04:49:31 +02:00
|
|
|
/* wm hints */
|
2007-08-16 23:27:37 +02:00
|
|
|
if (data->wm_hints)
|
2001-07-12 04:49:31 +02:00
|
|
|
{
|
2008-01-18 14:34:57 +01:00
|
|
|
data->wm_hints->flags |= InputHint | StateHint | WindowGroupHint;
|
2009-08-13 18:18:22 +02:00
|
|
|
data->wm_hints->input = !use_take_focus && !(style & WS_DISABLED);
|
2007-08-16 23:27:37 +02:00
|
|
|
data->wm_hints->initial_state = (style & WS_MINIMIZE) ? IconicState : NormalState;
|
|
|
|
data->wm_hints->window_group = group_leader;
|
|
|
|
XSetWMHints( display, data->whole_window, data->wm_hints );
|
2001-07-12 04:49:31 +02:00
|
|
|
}
|
2008-01-18 14:34:57 +01:00
|
|
|
|
|
|
|
wine_tsx11_unlock();
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-29 11:08:51 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* update_user_time
|
|
|
|
*/
|
|
|
|
void update_user_time( Time time )
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (!user_time_window)
|
|
|
|
{
|
|
|
|
user_time_window = XCreateWindow( gdi_display, root_window, -1, -1, 1, 1, 0, 0, InputOnly,
|
|
|
|
DefaultVisual(gdi_display,DefaultScreen(gdi_display)), 0, NULL );
|
|
|
|
TRACE( "user time window %lx\n", user_time_window );
|
|
|
|
}
|
|
|
|
if (time && (!last_user_time || (long)(time - last_user_time) > 0))
|
|
|
|
{
|
|
|
|
last_user_time = time;
|
|
|
|
XChangeProperty( gdi_display, user_time_window, x11drv_atom(_NET_WM_USER_TIME),
|
|
|
|
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&time, 1 );
|
|
|
|
}
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* update_net_wm_states
|
|
|
|
*/
|
|
|
|
void update_net_wm_states( Display *display, struct x11drv_win_data *data )
|
|
|
|
{
|
|
|
|
static const unsigned int state_atoms[NB_NET_WM_STATES] =
|
|
|
|
{
|
|
|
|
XATOM__NET_WM_STATE_FULLSCREEN,
|
|
|
|
XATOM__NET_WM_STATE_ABOVE,
|
|
|
|
XATOM__NET_WM_STATE_MAXIMIZED_VERT,
|
|
|
|
XATOM__NET_WM_STATE_SKIP_PAGER,
|
|
|
|
XATOM__NET_WM_STATE_SKIP_TASKBAR
|
|
|
|
};
|
|
|
|
|
|
|
|
DWORD i, style, ex_style, new_state = 0;
|
|
|
|
|
|
|
|
if (!data->managed) return;
|
|
|
|
if (data->whole_window == root_window) return;
|
|
|
|
|
|
|
|
style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
|
|
|
if (data->whole_rect.left <= 0 && data->whole_rect.right >= screen_width &&
|
|
|
|
data->whole_rect.top <= 0 && data->whole_rect.bottom >= screen_height)
|
|
|
|
{
|
|
|
|
if ((style & WS_MAXIMIZE) && (style & WS_CAPTION) == WS_CAPTION)
|
|
|
|
new_state |= (1 << NET_WM_STATE_MAXIMIZED);
|
|
|
|
else if (!(style & WS_MINIMIZE))
|
|
|
|
new_state |= (1 << NET_WM_STATE_FULLSCREEN);
|
|
|
|
}
|
|
|
|
else if (style & WS_MAXIMIZE)
|
|
|
|
new_state |= (1 << NET_WM_STATE_MAXIMIZED);
|
|
|
|
|
|
|
|
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
|
|
|
|
if (ex_style & WS_EX_TOPMOST)
|
|
|
|
new_state |= (1 << NET_WM_STATE_ABOVE);
|
2010-06-01 13:37:48 +02:00
|
|
|
if (ex_style & (WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE))
|
2008-04-23 15:32:58 +02:00
|
|
|
new_state |= (1 << NET_WM_STATE_SKIP_TASKBAR) | (1 << NET_WM_STATE_SKIP_PAGER);
|
2010-05-28 12:14:43 +02:00
|
|
|
if (!(ex_style & WS_EX_APPWINDOW) && GetWindow( data->hwnd, GW_OWNER ))
|
2008-04-23 15:32:58 +02:00
|
|
|
new_state |= (1 << NET_WM_STATE_SKIP_TASKBAR);
|
|
|
|
|
|
|
|
if (!data->mapped) /* set the _NET_WM_STATE atom directly */
|
|
|
|
{
|
|
|
|
Atom atoms[NB_NET_WM_STATES+1];
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
for (i = count = 0; i < NB_NET_WM_STATES; i++)
|
|
|
|
{
|
|
|
|
if (!(new_state & (1 << i))) continue;
|
|
|
|
TRACE( "setting wm state %u for unmapped window %p/%lx\n",
|
|
|
|
i, data->hwnd, data->whole_window );
|
|
|
|
atoms[count++] = X11DRV_Atoms[state_atoms[i] - FIRST_XATOM];
|
|
|
|
if (state_atoms[i] == XATOM__NET_WM_STATE_MAXIMIZED_VERT)
|
|
|
|
atoms[count++] = x11drv_atom(_NET_WM_STATE_MAXIMIZED_HORZ);
|
|
|
|
}
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XChangeProperty( display, data->whole_window, x11drv_atom(_NET_WM_STATE), XA_ATOM,
|
|
|
|
32, PropModeReplace, (unsigned char *)atoms, count );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
else /* ask the window manager to do it for us */
|
|
|
|
{
|
|
|
|
XEvent xev;
|
|
|
|
|
|
|
|
xev.xclient.type = ClientMessage;
|
|
|
|
xev.xclient.window = data->whole_window;
|
|
|
|
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[3] = 1;
|
|
|
|
|
|
|
|
for (i = 0; i < NB_NET_WM_STATES; i++)
|
|
|
|
{
|
|
|
|
if (!((data->net_wm_state ^ new_state) & (1 << i))) continue; /* unchanged */
|
|
|
|
|
|
|
|
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->net_wm_state & (1 << i)) != 0 );
|
|
|
|
|
|
|
|
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];
|
|
|
|
xev.xclient.data.l[2] = ((state_atoms[i] == XATOM__NET_WM_STATE_MAXIMIZED_VERT) ?
|
|
|
|
x11drv_atom(_NET_WM_STATE_MAXIMIZED_HORZ) : 0);
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XSendEvent( display, root_window, False,
|
|
|
|
SubstructureRedirectMask | SubstructureNotifyMask, &xev );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data->net_wm_state = new_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* set_xembed_flags
|
|
|
|
*/
|
|
|
|
static void set_xembed_flags( Display *display, struct x11drv_win_data *data, unsigned long flags )
|
|
|
|
{
|
|
|
|
unsigned long info[2];
|
|
|
|
|
2010-11-05 13:42:05 +01:00
|
|
|
if (!data->whole_window) return;
|
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
info[0] = 0; /* protocol version */
|
|
|
|
info[1] = flags;
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XChangeProperty( display, data->whole_window, x11drv_atom(_XEMBED_INFO),
|
|
|
|
x11drv_atom(_XEMBED_INFO), 32, PropModeReplace, (unsigned char*)info, 2 );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* map_window
|
|
|
|
*/
|
|
|
|
static void map_window( Display *display, struct x11drv_win_data *data, DWORD new_style )
|
|
|
|
{
|
|
|
|
TRACE( "win %p/%lx\n", data->hwnd, data->whole_window );
|
|
|
|
|
2009-01-06 19:59:07 +01:00
|
|
|
remove_startup_notification( display, data->whole_window );
|
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
wait_for_withdrawn_state( display, data, TRUE );
|
|
|
|
|
|
|
|
if (!data->embedded)
|
|
|
|
{
|
|
|
|
update_net_wm_states( display, data );
|
|
|
|
sync_window_style( display, data );
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XMapWindow( display, data->whole_window );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
else set_xembed_flags( display, data, XEMBED_MAPPED );
|
|
|
|
|
|
|
|
data->mapped = TRUE;
|
|
|
|
data->iconic = (new_style & WS_MINIMIZE) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* unmap_window
|
|
|
|
*/
|
|
|
|
static void unmap_window( Display *display, struct x11drv_win_data *data )
|
|
|
|
{
|
|
|
|
TRACE( "win %p/%lx\n", data->hwnd, data->whole_window );
|
|
|
|
|
|
|
|
if (!data->embedded)
|
|
|
|
{
|
|
|
|
wait_for_withdrawn_state( display, data, FALSE );
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (data->managed) XWithdrawWindow( display, data->whole_window, DefaultScreen(display) );
|
|
|
|
else XUnmapWindow( display, data->whole_window );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
else set_xembed_flags( display, data, 0 );
|
|
|
|
|
|
|
|
data->mapped = FALSE;
|
|
|
|
data->net_wm_state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* make_window_embedded
|
|
|
|
*/
|
|
|
|
void make_window_embedded( Display *display, struct x11drv_win_data *data )
|
|
|
|
{
|
2010-11-05 13:42:05 +01:00
|
|
|
BOOL was_mapped = data->mapped;
|
|
|
|
/* the window cannot be mapped before being embedded */
|
|
|
|
if (data->mapped) unmap_window( display, data );
|
|
|
|
|
|
|
|
data->embedded = TRUE;
|
|
|
|
data->managed = TRUE;
|
|
|
|
SetPropA( data->hwnd, managed_prop, (HANDLE)1 );
|
|
|
|
sync_window_style( display, data );
|
|
|
|
|
|
|
|
if (was_mapped)
|
2008-04-23 15:32:58 +02:00
|
|
|
map_window( display, data, 0 );
|
|
|
|
else
|
|
|
|
set_xembed_flags( display, data, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_window_to_X_rect
|
|
|
|
*
|
|
|
|
* Convert a rect from client to X window coordinates
|
|
|
|
*/
|
2009-01-29 22:40:50 +01:00
|
|
|
static void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2001-07-20 20:37:37 +02:00
|
|
|
RECT rc;
|
|
|
|
|
2005-02-01 19:53:59 +01:00
|
|
|
if (!data->managed) return;
|
2001-06-04 23:55:17 +02:00
|
|
|
if (IsRectEmpty( rect )) return;
|
|
|
|
|
2007-10-11 12:24:27 +02:00
|
|
|
get_x11_rect_offset( data, &rc );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2001-07-20 20:37:37 +02:00
|
|
|
rect->left -= rc.left;
|
|
|
|
rect->right -= rc.right;
|
|
|
|
rect->top -= rc.top;
|
|
|
|
rect->bottom -= rc.bottom;
|
2001-06-04 23:55:17 +02:00
|
|
|
if (rect->top >= rect->bottom) rect->bottom = rect->top + 1;
|
|
|
|
if (rect->left >= rect->right) rect->right = rect->left + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_X_to_window_rect
|
|
|
|
*
|
|
|
|
* Opposite of X11DRV_window_to_X_rect
|
|
|
|
*/
|
2005-02-01 19:53:59 +01:00
|
|
|
void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2007-10-11 12:24:27 +02:00
|
|
|
RECT rc;
|
2007-08-29 12:02:57 +02:00
|
|
|
|
2005-02-01 19:53:59 +01:00
|
|
|
if (!data->managed) return;
|
2001-06-04 23:55:17 +02:00
|
|
|
if (IsRectEmpty( rect )) return;
|
|
|
|
|
2007-10-11 12:24:27 +02:00
|
|
|
get_x11_rect_offset( data, &rc );
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2007-10-11 12:24:27 +02:00
|
|
|
rect->left += rc.left;
|
|
|
|
rect->right += rc.right;
|
|
|
|
rect->top += rc.top;
|
|
|
|
rect->bottom += rc.bottom;
|
2001-06-04 23:55:17 +02:00
|
|
|
if (rect->top >= rect->bottom) rect->bottom = rect->top + 1;
|
|
|
|
if (rect->left >= rect->right) rect->right = rect->left + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2008-04-23 15:32:58 +02:00
|
|
|
* sync_window_position
|
2001-06-04 23:55:17 +02:00
|
|
|
*
|
2005-01-31 17:34:07 +01:00
|
|
|
* Synchronize the X window position with the Windows one
|
2001-06-04 23:55:17 +02:00
|
|
|
*/
|
2008-04-23 15:32:58 +02:00
|
|
|
static void sync_window_position( Display *display, struct x11drv_win_data *data,
|
2010-02-08 17:14:01 +01:00
|
|
|
UINT swp_flags, const RECT *old_window_rect,
|
|
|
|
const RECT *old_whole_rect, const RECT *old_client_rect )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2008-04-04 11:20:45 +02:00
|
|
|
DWORD style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
2001-06-04 23:55:17 +02:00
|
|
|
XWindowChanges changes;
|
2008-04-23 15:34:07 +02:00
|
|
|
unsigned int mask = 0;
|
2008-04-04 11:20:45 +02:00
|
|
|
|
|
|
|
if (data->managed && data->iconic) return;
|
|
|
|
|
2008-04-23 15:34:07 +02:00
|
|
|
/* resizing a managed maximized window is not allowed */
|
|
|
|
if (!(style & WS_MAXIMIZE) || !data->managed)
|
|
|
|
{
|
2008-09-17 21:11:47 +02:00
|
|
|
changes.width = data->whole_rect.right - data->whole_rect.left;
|
|
|
|
changes.height = data->whole_rect.bottom - data->whole_rect.top;
|
|
|
|
/* if window rect is empty force size to 1x1 */
|
|
|
|
if (changes.width <= 0 || changes.height <= 0) changes.width = changes.height = 1;
|
2009-05-05 15:36:25 +02:00
|
|
|
if (changes.width > 65535) changes.width = 65535;
|
|
|
|
if (changes.height > 65535) changes.height = 65535;
|
2008-04-23 15:34:07 +02:00
|
|
|
mask |= CWWidth | CWHeight;
|
|
|
|
}
|
2008-04-04 11:20:45 +02:00
|
|
|
|
|
|
|
/* only the size is allowed to change for the desktop window */
|
|
|
|
if (data->whole_window != root_window)
|
|
|
|
{
|
|
|
|
changes.x = data->whole_rect.left - virtual_screen_rect.left;
|
|
|
|
changes.y = data->whole_rect.top - virtual_screen_rect.top;
|
|
|
|
mask |= CWX | CWY;
|
|
|
|
}
|
2005-01-31 17:34:07 +01:00
|
|
|
|
2008-08-29 13:34:55 +02:00
|
|
|
if (!(swp_flags & SWP_NOZORDER) || (swp_flags & SWP_SHOWWINDOW))
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2005-01-31 17:34:07 +01:00
|
|
|
/* find window that this one must be after */
|
|
|
|
HWND prev = GetWindow( data->hwnd, GW_HWNDPREV );
|
|
|
|
while (prev && !(GetWindowLongW( prev, GWL_STYLE ) & WS_VISIBLE))
|
|
|
|
prev = GetWindow( prev, GW_HWNDPREV );
|
|
|
|
if (!prev) /* top child */
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2005-01-31 17:34:07 +01:00
|
|
|
changes.stack_mode = Above;
|
|
|
|
mask |= CWStackMode;
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2008-03-24 15:47:28 +01:00
|
|
|
/* should use stack_mode Below but most window managers don't get it right */
|
|
|
|
/* and Above with a sibling doesn't work so well either, so we ignore it */
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
2008-04-04 11:20:45 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
set_size_hints( display, data, style );
|
2010-01-04 17:56:32 +01:00
|
|
|
data->configure_serial = NextRequest( display );
|
2008-04-04 11:20:45 +02:00
|
|
|
XReconfigureWMWindow( display, data->whole_window,
|
|
|
|
DefaultScreen(display), mask, &changes );
|
2010-02-04 17:27:19 +01:00
|
|
|
#ifdef HAVE_LIBXSHAPE
|
2010-05-28 12:14:43 +02:00
|
|
|
if (IsRectEmpty( old_window_rect ) != IsRectEmpty( &data->window_rect ))
|
|
|
|
sync_window_region( display, data, (HRGN)1 );
|
2010-02-04 17:27:19 +01:00
|
|
|
if (data->shaped)
|
|
|
|
{
|
2010-02-08 17:14:01 +01:00
|
|
|
int old_x_offset = old_window_rect->left - old_whole_rect->left;
|
|
|
|
int old_y_offset = old_window_rect->top - old_whole_rect->top;
|
|
|
|
int new_x_offset = data->window_rect.left - data->whole_rect.left;
|
|
|
|
int new_y_offset = data->window_rect.top - data->whole_rect.top;
|
|
|
|
if (old_x_offset != new_x_offset || old_y_offset != new_y_offset)
|
|
|
|
XShapeOffsetShape( display, data->whole_window, ShapeBounding,
|
|
|
|
new_x_offset - old_x_offset, new_y_offset - old_y_offset );
|
2010-02-04 17:27:19 +01:00
|
|
|
}
|
|
|
|
#endif
|
2008-04-04 11:20:45 +02:00
|
|
|
wine_tsx11_unlock();
|
2010-01-04 17:56:32 +01:00
|
|
|
|
|
|
|
TRACE( "win %p/%lx pos %d,%d,%dx%d after %lx changes=%x serial=%lu\n",
|
|
|
|
data->hwnd, data->whole_window, data->whole_rect.left, data->whole_rect.top,
|
|
|
|
data->whole_rect.right - data->whole_rect.left,
|
|
|
|
data->whole_rect.bottom - data->whole_rect.top,
|
|
|
|
changes.sibling, mask, data->configure_serial );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2001-05-16 21:52:29 +02:00
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2008-02-21 12:29:36 +01:00
|
|
|
/***********************************************************************
|
2008-04-23 15:32:58 +02:00
|
|
|
* sync_client_position
|
2008-02-21 12:29:36 +01:00
|
|
|
*
|
|
|
|
* Synchronize the X client window position with the Windows one
|
|
|
|
*/
|
2008-04-23 15:32:58 +02:00
|
|
|
static void sync_client_position( Display *display, struct x11drv_win_data *data,
|
2008-02-21 12:29:36 +01:00
|
|
|
UINT swp_flags, const RECT *old_client_rect,
|
|
|
|
const RECT *old_whole_rect )
|
|
|
|
{
|
|
|
|
int mask;
|
|
|
|
XWindowChanges changes;
|
|
|
|
RECT old = *old_client_rect;
|
|
|
|
RECT new = data->client_rect;
|
|
|
|
|
|
|
|
OffsetRect( &old, -old_whole_rect->left, -old_whole_rect->top );
|
|
|
|
OffsetRect( &new, -data->whole_rect.left, -data->whole_rect.top );
|
|
|
|
if (!(mask = get_window_changes( &changes, &old, &new ))) return;
|
|
|
|
|
|
|
|
if (data->client_window)
|
|
|
|
{
|
|
|
|
TRACE( "setting client win %lx pos %d,%d,%dx%d changes=%x\n",
|
|
|
|
data->client_window, new.left, new.top,
|
|
|
|
new.right - new.left, new.bottom - new.top, mask );
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XConfigureWindow( display, data->client_window, mask, &changes );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
2008-05-12 19:37:54 +02:00
|
|
|
if (data->gl_drawable && (mask & (CWWidth|CWHeight))) sync_gl_drawable( data );
|
2008-02-21 12:29:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-23 15:32:58 +02: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,
|
|
|
|
const RECT *old_client_rect )
|
|
|
|
{
|
|
|
|
RECT src_rect = *old_rect;
|
|
|
|
RECT dst_rect = *new_rect;
|
|
|
|
HDC hdc_src, hdc_dst;
|
|
|
|
INT code;
|
2011-01-31 12:30:43 +01:00
|
|
|
HRGN rgn;
|
2008-04-23 15:32:58 +02:00
|
|
|
HWND parent = 0;
|
|
|
|
|
|
|
|
if (!data->whole_window)
|
|
|
|
{
|
|
|
|
OffsetRect( &dst_rect, -data->window_rect.left, -data->window_rect.top );
|
|
|
|
parent = GetAncestor( data->hwnd, GA_PARENT );
|
|
|
|
hdc_src = GetDCEx( parent, 0, DCX_CACHE );
|
|
|
|
hdc_dst = GetDCEx( data->hwnd, 0, DCX_CACHE | DCX_WINDOW );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OffsetRect( &dst_rect, -data->client_rect.left, -data->client_rect.top );
|
|
|
|
/* make src rect relative to the old position of the window */
|
|
|
|
OffsetRect( &src_rect, -old_client_rect->left, -old_client_rect->top );
|
|
|
|
if (dst_rect.left == src_rect.left && dst_rect.top == src_rect.top) return;
|
|
|
|
hdc_src = hdc_dst = GetDCEx( data->hwnd, 0, DCX_CACHE );
|
|
|
|
}
|
|
|
|
|
2011-01-31 12:30:43 +01:00
|
|
|
rgn = CreateRectRgnIndirect( &dst_rect );
|
|
|
|
SelectClipRgn( hdc_dst, rgn );
|
|
|
|
DeleteObject( rgn );
|
2010-09-14 07:24:11 +02:00
|
|
|
ExcludeUpdateRgn( hdc_dst, data->hwnd );
|
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
code = X11DRV_START_EXPOSURES;
|
|
|
|
ExtEscape( hdc_dst, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL );
|
|
|
|
|
|
|
|
TRACE( "copying bits for win %p/%lx/%lx %s -> %s\n",
|
|
|
|
data->hwnd, data->whole_window, data->client_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 );
|
|
|
|
|
2011-01-31 12:30:43 +01:00
|
|
|
rgn = 0;
|
2008-04-23 15:32:58 +02:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (!data->whole_window)
|
|
|
|
{
|
|
|
|
/* map region to client rect since we are using DCX_WINDOW */
|
|
|
|
OffsetRgn( rgn, data->window_rect.left - data->client_rect.left,
|
|
|
|
data->window_rect.top - data->client_rect.top );
|
|
|
|
RedrawWindow( data->hwnd, NULL, rgn,
|
|
|
|
RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ALLCHILDREN );
|
|
|
|
}
|
|
|
|
else RedrawWindow( data->hwnd, NULL, rgn, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
|
|
|
|
DeleteObject( rgn );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* create_whole_window
|
|
|
|
*
|
|
|
|
* Create the whole X window for a given window
|
|
|
|
*/
|
2008-01-23 21:39:32 +01:00
|
|
|
static Window create_whole_window( Display *display, struct x11drv_win_data *data )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
|
|
|
int cx, cy, mask;
|
|
|
|
XSetWindowAttributes attr;
|
2008-01-23 16:32:55 +01:00
|
|
|
WCHAR text[1024];
|
2008-09-12 15:54:02 +02:00
|
|
|
COLORREF key;
|
|
|
|
BYTE alpha;
|
|
|
|
DWORD layered_flags;
|
2010-02-01 22:35:32 +01:00
|
|
|
HRGN win_rgn;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2008-01-25 12:07:11 +01:00
|
|
|
if (!data->managed && is_window_managed( data->hwnd, SWP_NOACTIVATE, &data->window_rect ))
|
|
|
|
{
|
|
|
|
TRACE( "making win %p/%lx managed\n", data->hwnd, data->whole_window );
|
|
|
|
data->managed = TRUE;
|
|
|
|
SetPropA( data->hwnd, managed_prop, (HANDLE)1 );
|
|
|
|
}
|
|
|
|
|
2010-02-01 22:35:32 +01:00
|
|
|
if ((win_rgn = CreateRectRgn( 0, 0, 0, 0 )) &&
|
|
|
|
GetWindowRgn( data->hwnd, win_rgn ) == ERROR)
|
|
|
|
{
|
|
|
|
DeleteObject( win_rgn );
|
|
|
|
win_rgn = 0;
|
|
|
|
}
|
|
|
|
data->shaped = (win_rgn != 0);
|
|
|
|
|
2006-03-27 15:33:43 +02:00
|
|
|
mask = get_window_attributes( display, data, &attr );
|
2001-06-12 06:02:10 +02:00
|
|
|
|
2007-08-20 22:06:33 +02:00
|
|
|
data->whole_rect = data->window_rect;
|
2009-06-25 12:10:44 +02:00
|
|
|
X11DRV_window_to_X_rect( data, &data->whole_rect );
|
|
|
|
if (!(cx = data->whole_rect.right - data->whole_rect.left)) cx = 1;
|
|
|
|
else if (cx > 65535) cx = 65535;
|
|
|
|
if (!(cy = data->whole_rect.bottom - data->whole_rect.top)) cy = 1;
|
|
|
|
else if (cy > 65535) cy = 65535;
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
2006-10-26 12:53:59 +02:00
|
|
|
data->whole_window = XCreateWindow( display, root_window,
|
2009-06-25 12:10:44 +02:00
|
|
|
data->whole_rect.left - virtual_screen_rect.left,
|
|
|
|
data->whole_rect.top - virtual_screen_rect.top,
|
2006-10-26 12:53:59 +02:00
|
|
|
cx, cy, 0, screen_depth, InputOutput,
|
|
|
|
visual, mask, &attr );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2008-02-22 10:40:22 +01:00
|
|
|
if (data->whole_window) XSaveContext( display, data->whole_window, winContext, (char *)data->hwnd );
|
|
|
|
wine_tsx11_unlock();
|
2008-02-21 12:29:36 +01:00
|
|
|
|
2010-02-01 22:35:32 +01:00
|
|
|
if (!data->whole_window) goto done;
|
2008-02-21 12:29:36 +01:00
|
|
|
|
2008-02-22 10:40:22 +01:00
|
|
|
if (!create_client_window( display, data, NULL ))
|
2008-02-21 12:29:36 +01:00
|
|
|
{
|
2008-02-22 10:40:22 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XDeleteContext( display, data->whole_window, winContext );
|
2008-02-21 12:29:36 +01:00
|
|
|
XDestroyWindow( display, data->whole_window );
|
|
|
|
data->whole_window = 0;
|
|
|
|
wine_tsx11_unlock();
|
2010-02-01 22:35:32 +01:00
|
|
|
goto done;
|
2008-02-21 12:29:36 +01:00
|
|
|
}
|
|
|
|
|
2007-08-20 14:04:36 +02:00
|
|
|
set_initial_wm_hints( display, data );
|
2008-04-23 15:32:58 +02:00
|
|
|
set_wm_hints( display, data );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2005-07-07 19:30:57 +02:00
|
|
|
SetPropA( data->hwnd, whole_window_prop, (HANDLE)data->whole_window );
|
2008-01-23 16:30:18 +01:00
|
|
|
|
2008-01-23 16:32:55 +01:00
|
|
|
/* set the window text */
|
|
|
|
if (!InternalGetWindowText( data->hwnd, text, sizeof(text)/sizeof(WCHAR) )) text[0] = 0;
|
|
|
|
sync_window_text( display, data->whole_window, text );
|
|
|
|
|
2008-01-23 16:30:18 +01:00
|
|
|
/* set the window region */
|
2010-05-28 12:14:43 +02:00
|
|
|
if (win_rgn || IsRectEmpty( &data->window_rect )) sync_window_region( display, data, win_rgn );
|
2008-09-08 15:51:08 +02:00
|
|
|
|
2008-09-12 15:54:02 +02:00
|
|
|
/* set the window opacity */
|
|
|
|
if (!GetLayeredWindowAttributes( data->hwnd, &key, &alpha, &layered_flags )) layered_flags = 0;
|
|
|
|
sync_window_opacity( display, data->whole_window, key, alpha, layered_flags );
|
|
|
|
|
2008-04-09 20:24:27 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XFlush( display ); /* make sure the window exists before we start painting to it */
|
|
|
|
wine_tsx11_unlock();
|
2010-05-10 12:33:59 +02:00
|
|
|
|
|
|
|
sync_window_cursor( data );
|
2011-02-23 21:46:08 +01:00
|
|
|
/* setting the cursor can fail if the window isn't created yet */
|
|
|
|
/* so make sure that we try again once we receive a mouse event */
|
|
|
|
data->cursor = (HANDLE)~0u;
|
|
|
|
|
2010-02-01 22:35:32 +01:00
|
|
|
done:
|
|
|
|
if (win_rgn) DeleteObject( win_rgn );
|
2001-06-04 23:55:17 +02:00
|
|
|
return data->whole_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2005-01-31 17:34:07 +01:00
|
|
|
* destroy_whole_window
|
2001-06-04 23:55:17 +02:00
|
|
|
*
|
2005-01-31 17:34:07 +01:00
|
|
|
* Destroy the whole X window for a given window.
|
2001-06-04 23:55:17 +02:00
|
|
|
*/
|
2008-03-05 16:51:09 +01:00
|
|
|
static void destroy_whole_window( Display *display, struct x11drv_win_data *data, BOOL already_destroyed )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2010-11-15 20:41:07 +01:00
|
|
|
if (!data->whole_window)
|
|
|
|
{
|
|
|
|
if (data->embedded)
|
|
|
|
{
|
|
|
|
Window xwin = (Window)GetPropA( data->hwnd, foreign_window_prop );
|
|
|
|
if (xwin)
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (!already_destroyed) XSelectInput( display, xwin, 0 );
|
|
|
|
XDeleteContext( display, xwin, winContext );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
RemovePropA( data->hwnd, foreign_window_prop );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2008-02-21 12:29:36 +01:00
|
|
|
TRACE( "win %p xwin %lx/%lx\n", data->hwnd, data->whole_window, data->client_window );
|
2001-06-12 06:02:10 +02:00
|
|
|
wine_tsx11_lock();
|
2005-01-31 17:34:07 +01:00
|
|
|
XDeleteContext( display, data->whole_window, winContext );
|
2008-02-21 12:29:36 +01:00
|
|
|
XDeleteContext( display, data->client_window, winContext );
|
2008-03-05 16:51:09 +01:00
|
|
|
if (!already_destroyed) XDestroyWindow( display, data->whole_window );
|
2008-02-21 12:29:36 +01:00
|
|
|
data->whole_window = data->client_window = 0;
|
2008-03-05 16:51:09 +01:00
|
|
|
data->wm_state = WithdrawnState;
|
|
|
|
data->net_wm_state = 0;
|
|
|
|
data->mapped = FALSE;
|
2005-01-31 17:34:07 +01:00
|
|
|
if (data->xic)
|
|
|
|
{
|
|
|
|
XUnsetICFocus( data->xic );
|
|
|
|
XDestroyIC( data->xic );
|
2008-03-05 16:51:09 +01:00
|
|
|
data->xic = 0;
|
2005-01-31 17:34:07 +01:00
|
|
|
}
|
2006-05-09 17:32:40 +02:00
|
|
|
/* Outlook stops processing messages after destroying a dialog, so we need an explicit flush */
|
|
|
|
XFlush( display );
|
2008-01-22 10:17:52 +01:00
|
|
|
XFree( data->wm_hints );
|
|
|
|
data->wm_hints = NULL;
|
2001-06-12 06:02:10 +02:00
|
|
|
wine_tsx11_unlock();
|
2005-07-07 19:30:57 +02:00
|
|
|
RemovePropA( data->hwnd, whole_window_prop );
|
2008-02-21 12:29:36 +01:00
|
|
|
RemovePropA( data->hwnd, client_window_prop );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* SetWindowText (X11DRV.@)
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_SetWindowText( HWND hwnd, LPCWSTR text )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
|
|
|
Window win;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2008-06-26 16:47:42 +02:00
|
|
|
if ((win = X11DRV_get_whole_window( hwnd )) && win != DefaultRootWindow(gdi_display))
|
|
|
|
{
|
|
|
|
Display *display = thread_init_display();
|
2008-01-23 16:32:55 +01:00
|
|
|
sync_window_text( display, win, text );
|
2008-06-26 16:47:42 +02:00
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetWindowStyle (X11DRV.@)
|
|
|
|
*
|
|
|
|
* Update the X state of a window to reflect a style change
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style )
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
2010-12-09 19:45:34 +01:00
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
2008-09-12 14:55:07 +02:00
|
|
|
DWORD changed;
|
2008-04-23 15:32:58 +02:00
|
|
|
|
|
|
|
if (hwnd == GetDesktopWindow()) return;
|
2008-09-12 14:55:07 +02:00
|
|
|
changed = style->styleNew ^ style->styleOld;
|
2008-04-23 15:32:58 +02:00
|
|
|
|
2010-12-09 19:45:34 +01:00
|
|
|
/* if WS_VISIBLE was set through WM_SETREDRAW, map the window if it's the first time */
|
|
|
|
if (offset == GWL_STYLE && (changed & WS_VISIBLE) && (style->styleNew & WS_VISIBLE) && !data)
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
2010-12-09 19:45:34 +01:00
|
|
|
if (!(data = X11DRV_create_win_data( hwnd ))) return;
|
2008-04-23 15:32:58 +02:00
|
|
|
|
|
|
|
if (data->whole_window && is_window_rect_mapped( &data->window_rect ))
|
|
|
|
{
|
2008-06-26 16:47:42 +02:00
|
|
|
Display *display = thread_display();
|
2008-04-23 15:32:58 +02:00
|
|
|
set_wm_hints( display, data );
|
2008-09-12 14:55:07 +02:00
|
|
|
if (!data->mapped) map_window( display, data, style->styleNew );
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
}
|
2010-12-09 19:45:34 +01:00
|
|
|
if (!data || !data->whole_window) return;
|
2008-04-23 15:32:58 +02:00
|
|
|
|
2008-09-12 14:55:07 +02:00
|
|
|
if (offset == GWL_STYLE && (changed & WS_DISABLED))
|
2010-12-09 19:45:34 +01:00
|
|
|
set_wm_hints( thread_display(), data );
|
2008-09-12 15:54:02 +02:00
|
|
|
|
2010-12-09 19:45:34 +01:00
|
|
|
if (offset == GWL_EXSTYLE && (changed & WS_EX_LAYERED)) /* changing WS_EX_LAYERED resets attributes */
|
|
|
|
sync_window_opacity( thread_display(), data->whole_window, 0, 0, 0 );
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DestroyWindow (X11DRV.@)
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_DestroyWindow( HWND hwnd )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2002-06-14 02:08:40 +02:00
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
2005-01-28 18:25:50 +01:00
|
|
|
struct x11drv_win_data *data;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2005-07-18 15:20:18 +02:00
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2007-09-26 17:17:13 +02:00
|
|
|
if (data->pixmap)
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
2008-05-12 19:37:54 +02:00
|
|
|
destroy_glxpixmap(gdi_display, data->gl_drawable);
|
|
|
|
XFreePixmap(gdi_display, data->pixmap);
|
2007-09-26 17:17:13 +02:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
else if (data->gl_drawable)
|
2007-09-26 07:43:38 +02:00
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
2008-05-12 19:37:54 +02:00
|
|
|
XDestroyWindow(gdi_display, data->gl_drawable);
|
2007-09-26 07:43:38 +02:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
2008-06-26 15:08:08 +02:00
|
|
|
destroy_whole_window( thread_data->display, data, FALSE );
|
|
|
|
destroy_icon_window( thread_data->display, data );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2008-02-21 20:23:32 +01:00
|
|
|
if (data->colormap)
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
2008-06-26 15:08:08 +02:00
|
|
|
XFreeColormap( thread_data->display, data->colormap );
|
2008-02-21 20:23:32 +01:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
2005-01-31 17:34:07 +01:00
|
|
|
if (thread_data->last_focus == hwnd) thread_data->last_focus = 0;
|
2010-07-23 15:21:58 +02:00
|
|
|
if (thread_data->last_xic_hwnd == hwnd) thread_data->last_xic_hwnd = 0;
|
2001-06-04 23:55:17 +02:00
|
|
|
if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap );
|
|
|
|
if (data->hWMIconMask) DeleteObject( data->hWMIconMask);
|
2005-01-28 18:25:50 +01:00
|
|
|
wine_tsx11_lock();
|
2008-06-26 15:08:08 +02:00
|
|
|
XDeleteContext( thread_data->display, (XID)hwnd, win_data_context );
|
2005-01-28 18:25:50 +01:00
|
|
|
wine_tsx11_unlock();
|
2001-04-25 01:28:52 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-05 16:51:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DestroyNotify
|
|
|
|
*/
|
|
|
|
void X11DRV_DestroyNotify( HWND hwnd, XEvent *event )
|
|
|
|
{
|
|
|
|
Display *display = event->xdestroywindow.display;
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
2010-11-01 19:45:12 +01:00
|
|
|
if (!data->embedded) FIXME( "window %p/%lx destroyed from the outside\n", hwnd, data->whole_window );
|
2010-11-08 15:28:09 +01:00
|
|
|
|
2010-11-15 20:41:07 +01:00
|
|
|
destroy_whole_window( display, data, TRUE );
|
2010-11-01 19:45:12 +01:00
|
|
|
if (data->embedded) SendMessageW( hwnd, WM_CLOSE, 0, 0 );
|
2008-03-05 16:51:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-07 22:33:29 +02:00
|
|
|
static struct x11drv_win_data *alloc_win_data( Display *display, HWND hwnd )
|
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
2008-01-22 10:15:38 +01:00
|
|
|
if ((data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data))))
|
2005-07-07 22:33:29 +02:00
|
|
|
{
|
2008-01-22 10:15:38 +01:00
|
|
|
data->hwnd = hwnd;
|
2005-07-07 22:33:29 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
if (!winContext) winContext = XUniqueContext();
|
|
|
|
if (!win_data_context) win_data_context = XUniqueContext();
|
|
|
|
XSaveContext( display, (XID)hwnd, win_data_context, (char *)data );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-17 19:53:59 +01:00
|
|
|
/* initialize the desktop window id in the desktop manager process */
|
2008-01-24 10:20:11 +01:00
|
|
|
static struct x11drv_win_data *create_desktop_win_data( Display *display, HWND hwnd )
|
2006-03-27 22:43:03 +02:00
|
|
|
{
|
2008-01-24 10:20:11 +01:00
|
|
|
struct x11drv_win_data *data;
|
2006-03-27 22:43:03 +02:00
|
|
|
|
2008-01-24 10:20:11 +01:00
|
|
|
if (!(data = alloc_win_data( display, hwnd ))) return NULL;
|
2008-02-21 12:29:36 +01:00
|
|
|
data->whole_window = data->client_window = root_window;
|
2008-01-24 10:20:11 +01:00
|
|
|
data->managed = TRUE;
|
|
|
|
SetPropA( data->hwnd, managed_prop, (HANDLE)1 );
|
|
|
|
SetPropA( data->hwnd, whole_window_prop, (HANDLE)root_window );
|
2008-02-21 12:29:36 +01:00
|
|
|
SetPropA( data->hwnd, client_window_prop, (HANDLE)root_window );
|
2008-01-24 10:20:11 +01:00
|
|
|
set_initial_wm_hints( display, data );
|
|
|
|
return data;
|
2006-03-27 22:43:03 +02:00
|
|
|
}
|
|
|
|
|
2005-07-07 22:33:29 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* CreateDesktopWindow (X11DRV.@)
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
BOOL CDECL X11DRV_CreateDesktopWindow( HWND hwnd )
|
2005-07-07 22:33:29 +02:00
|
|
|
{
|
2008-01-17 19:53:59 +01:00
|
|
|
unsigned int width, height;
|
2005-07-07 22:33:29 +02:00
|
|
|
|
2008-01-17 19:53:59 +01:00
|
|
|
/* retrieve the real size of the desktop */
|
|
|
|
SERVER_START_REQ( get_window_rectangles )
|
|
|
|
{
|
2008-12-08 16:58:20 +01:00
|
|
|
req->handle = wine_server_user_handle( hwnd );
|
2010-09-07 14:31:30 +02:00
|
|
|
req->relative = COORDS_CLIENT;
|
2008-01-17 19:53:59 +01:00
|
|
|
wine_server_call( req );
|
2010-09-07 14:31:30 +02:00
|
|
|
width = reply->window.right;
|
|
|
|
height = reply->window.bottom;
|
2008-01-17 19:53:59 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2005-07-07 22:33:29 +02:00
|
|
|
|
2008-01-17 19:53:59 +01:00
|
|
|
if (!width && !height) /* not initialized yet */
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( set_window_pos )
|
|
|
|
{
|
2008-12-08 16:58:20 +01:00
|
|
|
req->handle = wine_server_user_handle( hwnd );
|
2008-01-17 19:53:59 +01:00
|
|
|
req->previous = 0;
|
|
|
|
req->flags = SWP_NOZORDER;
|
|
|
|
req->window.left = virtual_screen_rect.left;
|
|
|
|
req->window.top = virtual_screen_rect.top;
|
|
|
|
req->window.right = virtual_screen_rect.right;
|
|
|
|
req->window.bottom = virtual_screen_rect.bottom;
|
|
|
|
req->client = req->window;
|
|
|
|
wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Window win = (Window)GetPropA( hwnd, whole_window_prop );
|
|
|
|
if (win && win != root_window) X11DRV_init_desktop( win, width, height );
|
|
|
|
}
|
2005-07-07 22:33:29 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* CreateWindow (X11DRV.@)
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
BOOL CDECL X11DRV_CreateWindow( HWND hwnd )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2008-06-26 16:47:42 +02:00
|
|
|
if (hwnd == GetDesktopWindow() && root_window != DefaultRootWindow( gdi_display ))
|
2008-01-24 10:20:11 +01:00
|
|
|
{
|
2008-06-26 16:47:42 +02:00
|
|
|
Display *display = thread_init_display();
|
|
|
|
|
2008-01-24 10:20:51 +01:00
|
|
|
/* the desktop win data can't be created lazily */
|
|
|
|
if (!create_desktop_win_data( display, hwnd )) return FALSE;
|
2006-03-27 22:43:03 +02:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-01-17 20:17:47 +01:00
|
|
|
* X11DRV_get_win_data
|
2001-06-04 23:55:17 +02:00
|
|
|
*
|
2005-01-17 20:17:47 +01:00
|
|
|
* Return the X11 data structure associated with a window.
|
2001-06-04 23:55:17 +02:00
|
|
|
*/
|
2005-01-17 20:17:47 +01:00
|
|
|
struct x11drv_win_data *X11DRV_get_win_data( HWND hwnd )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2008-06-26 15:08:08 +02:00
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
2005-01-28 18:25:50 +01:00
|
|
|
char *data;
|
2005-02-09 15:01:40 +01:00
|
|
|
|
2008-06-26 15:08:08 +02:00
|
|
|
if (!thread_data) return NULL;
|
|
|
|
if (!hwnd) return NULL;
|
|
|
|
if (XFindContext( thread_data->display, (XID)hwnd, win_data_context, &data )) data = NULL;
|
2005-01-28 18:25:50 +01:00
|
|
|
return (struct x11drv_win_data *)data;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-24 10:20:51 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_create_win_data
|
|
|
|
*
|
|
|
|
* Create an X11 data window structure for an existing window.
|
|
|
|
*/
|
|
|
|
struct x11drv_win_data *X11DRV_create_win_data( HWND hwnd )
|
|
|
|
{
|
2008-06-26 16:47:42 +02:00
|
|
|
Display *display;
|
2008-01-24 10:20:51 +01:00
|
|
|
struct x11drv_win_data *data;
|
|
|
|
HWND parent;
|
|
|
|
|
|
|
|
if (!(parent = GetAncestor( hwnd, GA_PARENT ))) return NULL; /* desktop */
|
2008-06-26 16:47:42 +02:00
|
|
|
|
2008-06-26 16:49:09 +02:00
|
|
|
/* don't create win data for HWND_MESSAGE windows */
|
|
|
|
if (parent != GetDesktopWindow() && !GetAncestor( parent, GA_PARENT )) return NULL;
|
|
|
|
|
2008-06-26 16:47:42 +02:00
|
|
|
display = thread_init_display();
|
2008-01-24 10:20:51 +01:00
|
|
|
if (!(data = alloc_win_data( display, hwnd ))) return NULL;
|
|
|
|
|
|
|
|
GetWindowRect( hwnd, &data->window_rect );
|
|
|
|
MapWindowPoints( 0, parent, (POINT *)&data->window_rect, 2 );
|
|
|
|
data->whole_rect = data->window_rect;
|
|
|
|
GetClientRect( hwnd, &data->client_rect );
|
|
|
|
MapWindowPoints( hwnd, parent, (POINT *)&data->client_rect, 2 );
|
|
|
|
|
|
|
|
if (parent == GetDesktopWindow())
|
|
|
|
{
|
|
|
|
if (!create_whole_window( display, data ))
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-02-21 12:29:36 +01:00
|
|
|
TRACE( "win %p/%lx/%lx window %s whole %s client %s\n",
|
|
|
|
hwnd, data->whole_window, data->client_window, wine_dbgstr_rect( &data->window_rect ),
|
2008-01-24 10:20:51 +01:00
|
|
|
wine_dbgstr_rect( &data->whole_rect ), wine_dbgstr_rect( &data->client_rect ));
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-08 15:28:09 +01:00
|
|
|
/* window procedure for foreign windows */
|
|
|
|
static LRESULT WINAPI foreign_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
|
|
|
|
{
|
|
|
|
switch(msg)
|
|
|
|
{
|
2010-12-15 16:25:38 +01:00
|
|
|
case WM_WINDOWPOSCHANGED:
|
|
|
|
update_systray_balloon_position();
|
|
|
|
break;
|
2010-11-08 15:28:09 +01:00
|
|
|
case WM_PARENTNOTIFY:
|
|
|
|
if (LOWORD(wparam) == WM_DESTROY)
|
|
|
|
{
|
|
|
|
TRACE( "%p: got parent notify destroy for win %lx\n", hwnd, lparam );
|
|
|
|
PostMessageW( hwnd, WM_CLOSE, 0, 0 ); /* so that we come back here once the child is gone */
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case WM_CLOSE:
|
|
|
|
if (GetWindow( hwnd, GW_CHILD )) return 0; /* refuse to die if we still have children */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return DefWindowProcW( hwnd, msg, wparam, lparam );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* create_foreign_window
|
|
|
|
*
|
|
|
|
* Create a foreign window for the specified X window and its ancestors
|
|
|
|
*/
|
|
|
|
HWND create_foreign_window( Display *display, Window xwin )
|
|
|
|
{
|
|
|
|
static const WCHAR classW[] = {'_','_','w','i','n','e','_','x','1','1','_','f','o','r','e','i','g','n','_','w','i','n','d','o','w',0};
|
|
|
|
static BOOL class_registered;
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
HWND hwnd, parent;
|
|
|
|
Window xparent, xroot;
|
|
|
|
Window *xchildren;
|
|
|
|
unsigned int nchildren;
|
|
|
|
XWindowAttributes attr;
|
|
|
|
DWORD style = WS_CLIPCHILDREN;
|
|
|
|
|
|
|
|
if (!class_registered)
|
|
|
|
{
|
|
|
|
WNDCLASSEXW class;
|
|
|
|
|
|
|
|
memset( &class, 0, sizeof(class) );
|
|
|
|
class.cbSize = sizeof(class);
|
|
|
|
class.lpfnWndProc = foreign_window_proc;
|
|
|
|
class.lpszClassName = classW;
|
|
|
|
if (!RegisterClassExW( &class ) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS)
|
|
|
|
{
|
|
|
|
ERR( "Could not register foreign window class\n" );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
class_registered = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (XFindContext( display, xwin, winContext, (char **)&hwnd )) hwnd = 0;
|
|
|
|
if (hwnd) /* already created */
|
|
|
|
{
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
XSelectInput( display, xwin, StructureNotifyMask );
|
|
|
|
if (!XGetWindowAttributes( display, xwin, &attr ) ||
|
|
|
|
!XQueryTree( display, xwin, &xroot, &xparent, &xchildren, &nchildren ))
|
|
|
|
{
|
|
|
|
XSelectInput( display, xwin, 0 );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
XFree( xchildren );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
if (xparent == xroot)
|
|
|
|
{
|
|
|
|
parent = GetDesktopWindow();
|
|
|
|
style |= WS_POPUP;
|
|
|
|
attr.x += virtual_screen_rect.left;
|
|
|
|
attr.y += virtual_screen_rect.top;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parent = create_foreign_window( display, xparent );
|
|
|
|
style |= WS_CHILD;
|
|
|
|
}
|
|
|
|
|
|
|
|
hwnd = CreateWindowW( classW, NULL, style, attr.x, attr.y, attr.width, attr.height,
|
|
|
|
parent, 0, 0, NULL );
|
|
|
|
|
|
|
|
if (!(data = alloc_win_data( display, hwnd )))
|
|
|
|
{
|
|
|
|
DestroyWindow( hwnd );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
SetRect( &data->window_rect, attr.x, attr.y, attr.x + attr.width, attr.y + attr.height );
|
|
|
|
data->whole_rect = data->client_rect = data->window_rect;
|
|
|
|
data->whole_window = data->client_window = 0;
|
|
|
|
data->embedded = TRUE;
|
|
|
|
data->mapped = TRUE;
|
|
|
|
|
2010-11-15 20:41:07 +01:00
|
|
|
SetPropA( hwnd, foreign_window_prop, (HANDLE)xwin );
|
2010-11-08 15:28:09 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XSaveContext( display, xwin, winContext, (char *)data->hwnd );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
ShowWindow( hwnd, SW_SHOW );
|
|
|
|
|
|
|
|
TRACE( "win %lx parent %p style %08x %s -> hwnd %p\n",
|
|
|
|
xwin, parent, style, wine_dbgstr_rect(&data->window_rect), hwnd );
|
|
|
|
|
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_get_whole_window
|
|
|
|
*
|
|
|
|
* Return the X window associated with the full area of a window
|
|
|
|
*/
|
|
|
|
Window X11DRV_get_whole_window( HWND hwnd )
|
|
|
|
{
|
2005-01-17 20:17:47 +01:00
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
2001-10-15 19:56:45 +02:00
|
|
|
|
2008-01-17 19:53:59 +01:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
if (hwnd == GetDesktopWindow()) return root_window;
|
|
|
|
return (Window)GetPropA( hwnd, whole_window_prop );
|
|
|
|
}
|
2005-01-17 20:17:47 +01:00
|
|
|
return data->whole_window;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-21 12:29:36 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_get_client_window
|
|
|
|
*
|
|
|
|
* Return the X window associated with the client area of a window
|
|
|
|
*/
|
2009-01-29 22:40:50 +01:00
|
|
|
static Window X11DRV_get_client_window( HWND hwnd )
|
2008-02-21 12:29:36 +01:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
if (hwnd == GetDesktopWindow()) return root_window;
|
|
|
|
return (Window)GetPropA( hwnd, client_window_prop );
|
|
|
|
}
|
|
|
|
return data->client_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-15 22:02:32 +02:00
|
|
|
/***********************************************************************
|
2008-02-25 15:59:19 +01:00
|
|
|
* X11DRV_get_ic
|
2007-09-15 22:02:32 +02:00
|
|
|
*
|
2008-02-25 15:59:19 +01:00
|
|
|
* Return the X input context associated with a window
|
2007-09-15 22:02:32 +02:00
|
|
|
*/
|
2008-02-25 15:59:19 +01:00
|
|
|
XIC X11DRV_get_ic( HWND hwnd )
|
2007-09-15 22:02:32 +02:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
2008-04-04 13:44:36 +02:00
|
|
|
XIM xim;
|
2007-09-15 22:02:32 +02:00
|
|
|
|
2008-02-25 15:59:19 +01:00
|
|
|
if (!data) return 0;
|
2010-07-23 15:21:58 +02:00
|
|
|
|
|
|
|
x11drv_thread_data()->last_xic_hwnd = hwnd;
|
2008-04-04 13:44:36 +02:00
|
|
|
if (data->xic) return data->xic;
|
|
|
|
if (!(xim = x11drv_thread_data()->xim)) return 0;
|
|
|
|
return X11DRV_CreateIC( xim, data );
|
2007-09-15 22:02:32 +02:00
|
|
|
}
|
|
|
|
|
2008-02-25 15:59:19 +01:00
|
|
|
|
2007-09-25 19:20:58 +02:00
|
|
|
/***********************************************************************
|
2008-02-25 15:59:19 +01:00
|
|
|
* X11DRV_GetDC (X11DRV.@)
|
2007-09-25 19:20:58 +02:00
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect,
|
|
|
|
const RECT *top_rect, DWORD flags )
|
2007-09-25 19:20:58 +02:00
|
|
|
{
|
2008-02-25 15:59:19 +01:00
|
|
|
struct x11drv_escape_set_drawable escape;
|
2007-09-25 19:20:58 +02:00
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
2010-11-08 15:46:07 +01:00
|
|
|
HWND parent;
|
2007-09-25 19:20:58 +02:00
|
|
|
|
2008-02-25 15:59:19 +01:00
|
|
|
escape.code = X11DRV_SET_DRAWABLE;
|
|
|
|
escape.mode = IncludeInferiors;
|
|
|
|
escape.fbconfig_id = 0;
|
|
|
|
escape.gl_drawable = 0;
|
|
|
|
escape.pixmap = 0;
|
2008-05-28 17:52:06 +02:00
|
|
|
escape.gl_copy = FALSE;
|
2007-09-25 19:20:58 +02:00
|
|
|
|
2010-11-08 15:46:07 +01:00
|
|
|
escape.dc_rect.left = win_rect->left - top_rect->left;
|
|
|
|
escape.dc_rect.top = win_rect->top - top_rect->top;
|
|
|
|
escape.dc_rect.right = win_rect->right - top_rect->left;
|
|
|
|
escape.dc_rect.bottom = win_rect->bottom - top_rect->top;
|
|
|
|
escape.drawable_rect.left = top_rect->left;
|
|
|
|
escape.drawable_rect.top = top_rect->top;
|
|
|
|
escape.drawable_rect.right = top_rect->right;
|
|
|
|
escape.drawable_rect.bottom = top_rect->bottom;
|
|
|
|
|
2010-04-11 21:47:49 +02:00
|
|
|
if (top == hwnd)
|
2008-02-25 15:59:19 +01:00
|
|
|
{
|
2008-05-28 17:52:06 +02:00
|
|
|
escape.fbconfig_id = data ? data->fbconfig_id : (XID)GetPropA( hwnd, fbconfig_id_prop );
|
|
|
|
/* GL draws to the client area even for window DCs */
|
|
|
|
escape.gl_drawable = data ? data->client_window : X11DRV_get_client_window( hwnd );
|
2010-04-11 21:47:49 +02:00
|
|
|
if (data && IsIconic( hwnd ) && data->icon_window)
|
|
|
|
{
|
|
|
|
escape.drawable = data->icon_window;
|
|
|
|
}
|
|
|
|
else if (flags & DCX_WINDOW)
|
2008-05-28 17:52:06 +02:00
|
|
|
escape.drawable = data ? data->whole_window : X11DRV_get_whole_window( hwnd );
|
|
|
|
else
|
|
|
|
escape.drawable = escape.gl_drawable;
|
2008-02-25 15:59:19 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-08 15:46:07 +01:00
|
|
|
/* find the first ancestor that has a drawable */
|
|
|
|
for (parent = hwnd; parent && parent != top; parent = GetAncestor( parent, GA_PARENT ))
|
|
|
|
if ((escape.drawable = X11DRV_get_client_window( parent ))) break;
|
|
|
|
|
|
|
|
if (escape.drawable)
|
|
|
|
{
|
|
|
|
POINT pt = { 0, 0 };
|
|
|
|
MapWindowPoints( top, parent, &pt, 1 );
|
|
|
|
OffsetRect( &escape.dc_rect, pt.x, pt.y );
|
|
|
|
OffsetRect( &escape.drawable_rect, -pt.x, -pt.y );
|
|
|
|
}
|
|
|
|
else escape.drawable = X11DRV_get_client_window( top );
|
|
|
|
|
2008-02-25 15:59:19 +01:00
|
|
|
escape.fbconfig_id = data ? data->fbconfig_id : (XID)GetPropA( hwnd, fbconfig_id_prop );
|
|
|
|
escape.gl_drawable = data ? data->gl_drawable : (Drawable)GetPropA( hwnd, gl_drawable_prop );
|
|
|
|
escape.pixmap = data ? data->pixmap : (Pixmap)GetPropA( hwnd, pixmap_prop );
|
2008-05-28 17:52:06 +02:00
|
|
|
escape.gl_copy = (escape.gl_drawable != 0);
|
2008-03-18 12:42:25 +01:00
|
|
|
if (flags & DCX_CLIPCHILDREN) escape.mode = ClipByChildren;
|
2008-02-25 15:59:19 +01:00
|
|
|
}
|
2007-09-26 17:17:13 +02:00
|
|
|
|
2008-02-25 15:59:19 +01:00
|
|
|
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
|
2007-09-26 17:17:13 +02:00
|
|
|
}
|
|
|
|
|
2007-09-15 22:02:32 +02:00
|
|
|
|
2003-01-23 02:28:12 +01:00
|
|
|
/***********************************************************************
|
2008-02-25 15:59:19 +01:00
|
|
|
* X11DRV_ReleaseDC (X11DRV.@)
|
2003-01-23 02:28:12 +01:00
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_ReleaseDC( HWND hwnd, HDC hdc )
|
2003-01-23 02:28:12 +01:00
|
|
|
{
|
2008-02-25 15:59:19 +01:00
|
|
|
struct x11drv_escape_set_drawable escape;
|
|
|
|
|
|
|
|
escape.code = X11DRV_SET_DRAWABLE;
|
|
|
|
escape.drawable = root_window;
|
|
|
|
escape.mode = IncludeInferiors;
|
|
|
|
escape.drawable_rect = virtual_screen_rect;
|
|
|
|
SetRect( &escape.dc_rect, 0, 0, virtual_screen_rect.right - virtual_screen_rect.left,
|
|
|
|
virtual_screen_rect.bottom - virtual_screen_rect.top );
|
2010-02-16 12:37:42 +01:00
|
|
|
OffsetRect( &escape.dc_rect, -escape.drawable_rect.left, -escape.drawable_rect.top );
|
2008-02-25 15:59:19 +01:00
|
|
|
escape.fbconfig_id = 0;
|
|
|
|
escape.gl_drawable = 0;
|
|
|
|
escape.pixmap = 0;
|
|
|
|
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
|
2003-01-23 02:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-12 15:01:24 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetCapture (X11DRV.@)
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_SetCapture( HWND hwnd, UINT flags )
|
2008-03-12 15:01:24 +01:00
|
|
|
{
|
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
|
|
|
|
2008-06-26 15:08:08 +02:00
|
|
|
if (!thread_data) return;
|
2008-03-24 17:59:40 +01:00
|
|
|
if (!(flags & (GUI_INMOVESIZE | GUI_INMENUMODE))) return;
|
2008-03-12 15:01:24 +01:00
|
|
|
|
|
|
|
if (hwnd)
|
|
|
|
{
|
|
|
|
Window grab_win = X11DRV_get_client_window( GetAncestor( hwnd, GA_ROOT ) );
|
|
|
|
|
|
|
|
if (!grab_win) return;
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XFlush( gdi_display );
|
|
|
|
XGrabPointer( thread_data->display, grab_win, False,
|
|
|
|
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
|
2008-03-24 17:59:40 +01:00
|
|
|
GrabModeAsync, GrabModeAsync, None, None, CurrentTime );
|
2008-03-12 15:01:24 +01:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
thread_data->grab_window = grab_win;
|
|
|
|
}
|
|
|
|
else /* release capture */
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XFlush( gdi_display );
|
|
|
|
XUngrabPointer( thread_data->display, CurrentTime );
|
2009-01-26 15:12:55 +01:00
|
|
|
XFlush( thread_data->display );
|
2008-03-12 15:01:24 +01:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
thread_data->grab_window = None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
/*****************************************************************
|
|
|
|
* SetParent (X11DRV.@)
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_SetParent( HWND hwnd, HWND parent, HWND old_parent )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-05-16 21:52:29 +02:00
|
|
|
Display *display = thread_display();
|
2006-12-10 23:21:28 +01:00
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2006-12-10 23:21:28 +01:00
|
|
|
if (!data) return;
|
|
|
|
if (parent == old_parent) return;
|
2010-11-08 15:28:09 +01:00
|
|
|
if (data->embedded) return;
|
2005-03-25 11:38:56 +01:00
|
|
|
|
2006-12-10 23:21:28 +01:00
|
|
|
if (parent != GetDesktopWindow()) /* a child window */
|
2005-03-25 11:38:56 +01:00
|
|
|
{
|
2006-12-10 23:21:28 +01:00
|
|
|
if (old_parent == GetDesktopWindow())
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2006-12-10 23:21:28 +01:00
|
|
|
/* destroy the old X windows */
|
2008-03-05 16:51:09 +01:00
|
|
|
destroy_whole_window( display, data, FALSE );
|
2006-12-10 23:21:28 +01:00
|
|
|
destroy_icon_window( display, data );
|
|
|
|
if (data->managed)
|
2005-01-31 17:34:07 +01:00
|
|
|
{
|
2006-12-10 23:21:28 +01:00
|
|
|
data->managed = FALSE;
|
|
|
|
RemovePropA( data->hwnd, managed_prop );
|
2005-01-31 17:34:07 +01:00
|
|
|
}
|
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
2006-12-10 23:21:28 +01:00
|
|
|
else /* new top level window */
|
|
|
|
{
|
|
|
|
/* FIXME: we ignore errors since we can't really recover anyway */
|
2008-01-23 21:39:32 +01:00
|
|
|
create_whole_window( display, data );
|
2006-12-10 23:21:28 +01:00
|
|
|
}
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* SetFocus (X11DRV.@)
|
|
|
|
*
|
|
|
|
* Set the X focus.
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_SetFocus( HWND hwnd )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-05-16 21:52:29 +02:00
|
|
|
Display *display = thread_display();
|
2005-02-01 19:53:59 +01:00
|
|
|
struct x11drv_win_data *data;
|
2008-02-18 17:22:51 +01:00
|
|
|
XWindowChanges changes;
|
2010-03-17 18:29:23 +01:00
|
|
|
DWORD timestamp;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2008-06-26 16:21:32 +02:00
|
|
|
if (!(hwnd = GetAncestor( hwnd, GA_ROOT ))) return;
|
2005-02-01 19:53:59 +01:00
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
2005-08-22 11:14:21 +02:00
|
|
|
if (data->managed || !data->whole_window) return;
|
2001-08-24 02:26:59 +02:00
|
|
|
|
2010-03-17 18:29:23 +01:00
|
|
|
if (EVENT_x11_time_to_win32_time(0))
|
|
|
|
/* ICCCM says don't use CurrentTime, so try to use last message time if possible */
|
|
|
|
/* FIXME: this is not entirely correct */
|
|
|
|
timestamp = GetMessageTime() - EVENT_x11_time_to_win32_time(0);
|
|
|
|
else
|
|
|
|
timestamp = CurrentTime;
|
|
|
|
|
2001-08-24 02:26:59 +02:00
|
|
|
/* Set X focus and install colormap */
|
|
|
|
wine_tsx11_lock();
|
2008-02-18 17:22:51 +01:00
|
|
|
changes.stack_mode = Above;
|
|
|
|
XConfigureWindow( display, data->whole_window, CWStackMode, &changes );
|
2010-03-17 18:29:23 +01:00
|
|
|
XSetInputFocus( display, data->whole_window, RevertToParent, timestamp );
|
2001-08-24 02:26:59 +02:00
|
|
|
wine_tsx11_unlock();
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
/***********************************************************************
|
2008-07-02 15:40:10 +02:00
|
|
|
* WindowPosChanging (X11DRV.@)
|
2008-04-23 15:32:58 +02:00
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
|
|
|
|
const RECT *window_rect, const RECT *client_rect, RECT *visible_rect )
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
2008-07-02 15:40:10 +02:00
|
|
|
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
|
2008-04-23 15:32:58 +02:00
|
|
|
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
/* create the win data if the window is being made visible */
|
2008-07-02 15:40:10 +02:00
|
|
|
if (!(style & WS_VISIBLE) && !(swp_flags & SWP_SHOWWINDOW)) return;
|
2008-04-23 15:32:58 +02:00
|
|
|
if (!(data = X11DRV_create_win_data( hwnd ))) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if we need to switch the window to managed */
|
2008-07-02 15:40:10 +02:00
|
|
|
if (!data->managed && data->whole_window && is_window_managed( hwnd, swp_flags, window_rect ))
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
|
|
|
TRACE( "making win %p/%lx managed\n", hwnd, data->whole_window );
|
2008-07-02 15:40:10 +02:00
|
|
|
if (data->mapped) unmap_window( thread_display(), data );
|
2008-04-23 15:32:58 +02:00
|
|
|
data->managed = TRUE;
|
|
|
|
SetPropA( hwnd, managed_prop, (HANDLE)1 );
|
|
|
|
}
|
|
|
|
|
2008-07-02 15:40:10 +02:00
|
|
|
*visible_rect = *window_rect;
|
|
|
|
X11DRV_window_to_X_rect( data, visible_rect );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WindowPosChanged (X11DRV.@)
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
|
|
|
|
const RECT *rectWindow, const RECT *rectClient,
|
|
|
|
const RECT *visible_rect, const RECT *valid_rects )
|
2008-07-02 15:40:10 +02:00
|
|
|
{
|
|
|
|
struct x11drv_thread_data *thread_data;
|
|
|
|
Display *display;
|
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
|
|
|
DWORD new_style = GetWindowLongW( hwnd, GWL_STYLE );
|
2010-02-08 17:14:01 +01:00
|
|
|
RECT old_window_rect, old_whole_rect, old_client_rect;
|
2008-07-02 15:40:10 +02:00
|
|
|
int event_type;
|
|
|
|
|
|
|
|
if (!data) return;
|
|
|
|
|
|
|
|
thread_data = x11drv_thread_data();
|
|
|
|
display = thread_data->display;
|
|
|
|
|
2010-02-08 17:14:01 +01:00
|
|
|
old_window_rect = data->window_rect;
|
2008-04-23 15:32:58 +02:00
|
|
|
old_whole_rect = data->whole_rect;
|
|
|
|
old_client_rect = data->client_rect;
|
|
|
|
data->window_rect = *rectWindow;
|
2008-07-02 15:40:10 +02:00
|
|
|
data->whole_rect = *visible_rect;
|
2008-04-23 15:32:58 +02:00
|
|
|
data->client_rect = *rectClient;
|
|
|
|
|
|
|
|
TRACE( "win %p window %s client %s style %08x flags %08x\n",
|
|
|
|
hwnd, wine_dbgstr_rect(rectWindow), wine_dbgstr_rect(rectClient), new_style, swp_flags );
|
|
|
|
|
|
|
|
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) ))
|
|
|
|
{
|
|
|
|
/* if we have an X window the bits will be moved by the X server */
|
2010-09-14 07:22:56 +02:00
|
|
|
if (!data->whole_window && (x_offset != 0 || y_offset != 0))
|
2008-04-23 15:32:58 +02:00
|
|
|
move_window_bits( data, &old_whole_rect, &data->whole_rect, &old_client_rect );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
move_window_bits( data, &valid_rects[1], &valid_rects[0], &old_client_rect );
|
|
|
|
}
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XFlush( gdi_display ); /* make sure painting is done before we move the window */
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
sync_client_position( display, data, swp_flags, &old_client_rect, &old_whole_rect );
|
|
|
|
|
|
|
|
if (!data->whole_window) return;
|
|
|
|
|
|
|
|
/* check if we are currently processing an event relevant to this window */
|
|
|
|
event_type = 0;
|
|
|
|
if (thread_data->current_event && thread_data->current_event->xany.window == data->whole_window)
|
|
|
|
event_type = thread_data->current_event->type;
|
|
|
|
|
2010-11-08 15:28:09 +01:00
|
|
|
if (event_type != ConfigureNotify && event_type != PropertyNotify &&
|
|
|
|
event_type != GravityNotify && event_type != ReparentNotify)
|
2008-04-23 15:32:58 +02:00
|
|
|
event_type = 0; /* ignore other events */
|
|
|
|
|
2010-11-08 15:28:09 +01:00
|
|
|
if (data->mapped && event_type != ReparentNotify)
|
2008-05-01 17:45:17 +02:00
|
|
|
{
|
|
|
|
if (((swp_flags & SWP_HIDEWINDOW) && !(new_style & WS_VISIBLE)) ||
|
2011-03-07 15:11:10 +01:00
|
|
|
(!event_type &&
|
2010-05-28 12:16:17 +02:00
|
|
|
!is_window_rect_mapped( rectWindow ) && is_window_rect_mapped( &old_window_rect )))
|
2008-05-01 17:45:17 +02:00
|
|
|
unmap_window( display, data );
|
|
|
|
}
|
2008-04-23 15:32:58 +02:00
|
|
|
|
|
|
|
/* don't change position if we are about to minimize or maximize a managed window */
|
|
|
|
if (!event_type &&
|
|
|
|
!(data->managed && (swp_flags & SWP_STATECHANGED) && (new_style & (WS_MINIMIZE|WS_MAXIMIZE))))
|
2010-02-08 17:14:01 +01:00
|
|
|
sync_window_position( display, data, swp_flags,
|
|
|
|
&old_window_rect, &old_whole_rect, &old_client_rect );
|
2008-04-23 15:32:58 +02:00
|
|
|
|
|
|
|
if ((new_style & WS_VISIBLE) &&
|
|
|
|
((new_style & WS_MINIMIZE) || is_window_rect_mapped( rectWindow )))
|
|
|
|
{
|
|
|
|
if (!data->mapped || (swp_flags & (SWP_FRAMECHANGED|SWP_STATECHANGED)))
|
|
|
|
set_wm_hints( display, data );
|
|
|
|
|
|
|
|
if (!data->mapped)
|
|
|
|
{
|
|
|
|
map_window( display, data, new_style );
|
|
|
|
}
|
|
|
|
else if ((swp_flags & SWP_STATECHANGED) && (!data->iconic != !(new_style & WS_MINIMIZE)))
|
|
|
|
{
|
|
|
|
data->iconic = (new_style & WS_MINIMIZE) != 0;
|
|
|
|
TRACE( "changing win %p iconic state to %u\n", data->hwnd, data->iconic );
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (data->iconic)
|
|
|
|
XIconifyWindow( display, data->whole_window, DefaultScreen(display) );
|
|
|
|
else if (is_window_rect_mapped( rectWindow ))
|
|
|
|
XMapWindow( display, data->whole_window );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
update_net_wm_states( display, data );
|
|
|
|
}
|
|
|
|
else if (!event_type)
|
|
|
|
{
|
|
|
|
update_net_wm_states( display, data );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XFlush( display ); /* make sure changes are done before we start painting again */
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-31 11:40:49 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ShowWindow (X11DRV.@)
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
UINT CDECL X11DRV_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp )
|
2008-07-31 11:40:49 +02:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
unsigned int width, height, border, depth;
|
|
|
|
Window root, top;
|
|
|
|
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
|
|
|
|
|
|
|
if (!data || !data->whole_window || !data->managed || !data->mapped || data->iconic) return swp;
|
|
|
|
if (style & WS_MINIMIZE) return swp;
|
2008-09-17 21:13:11 +02:00
|
|
|
if (IsRectEmpty( rect )) return swp;
|
2008-07-31 11:40:49 +02:00
|
|
|
|
|
|
|
/* only fetch the new rectangle if the ShowWindow was a result of a window manager event */
|
|
|
|
|
|
|
|
if (!thread_data->current_event || thread_data->current_event->xany.window != data->whole_window)
|
|
|
|
return swp;
|
|
|
|
|
|
|
|
if (thread_data->current_event->type != ConfigureNotify &&
|
|
|
|
thread_data->current_event->type != PropertyNotify)
|
|
|
|
return swp;
|
|
|
|
|
|
|
|
TRACE( "win %p/%lx cmd %d at %s flags %08x\n",
|
|
|
|
hwnd, data->whole_window, cmd, wine_dbgstr_rect(rect), swp );
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XGetGeometry( thread_data->display, data->whole_window,
|
|
|
|
&root, &x, &y, &width, &height, &border, &depth );
|
|
|
|
XTranslateCoordinates( thread_data->display, data->whole_window, root, 0, 0, &x, &y, &top );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
rect->left = x;
|
|
|
|
rect->top = y;
|
|
|
|
rect->right = x + width;
|
|
|
|
rect->bottom = y + height;
|
|
|
|
OffsetRect( rect, virtual_screen_rect.left, virtual_screen_rect.top );
|
|
|
|
X11DRV_X_to_window_rect( data, rect );
|
|
|
|
return swp & ~(SWP_NOMOVE | SWP_NOCLIENTMOVE | SWP_NOSIZE | SWP_NOCLIENTSIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
/**********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* SetWindowIcon (X11DRV.@)
|
2001-04-25 01:28:52 +02:00
|
|
|
*
|
|
|
|
* hIcon or hIconSm has changed (or is being initialised for the
|
|
|
|
* first time). Complete the X11 driver-specific initialisation
|
|
|
|
* and set the window hints.
|
|
|
|
*
|
|
|
|
* This is not entirely correct, may need to create
|
|
|
|
* an icon window and set the pixmap as a background
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2001-05-16 21:52:29 +02:00
|
|
|
Display *display = thread_display();
|
2005-01-17 20:17:47 +01:00
|
|
|
struct x11drv_win_data *data;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
|
|
|
|
2005-01-17 20:17:47 +01:00
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
2005-01-31 17:34:07 +01:00
|
|
|
if (!data->whole_window) return;
|
2005-02-01 19:53:59 +01:00
|
|
|
if (!data->managed) return;
|
2001-10-15 19:56:45 +02:00
|
|
|
|
2007-08-16 23:27:37 +02:00
|
|
|
if (data->wm_hints)
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2010-04-19 17:51:44 +02:00
|
|
|
if (type == ICON_BIG) set_icon_hints( display, data, icon, 0 );
|
|
|
|
else set_icon_hints( display, data, 0, icon );
|
2002-09-24 20:36:51 +02:00
|
|
|
wine_tsx11_lock();
|
2007-08-16 23:27:37 +02:00
|
|
|
XSetWMHints( display, data->whole_window, data->wm_hints );
|
2002-09-24 20:36:51 +02:00
|
|
|
wine_tsx11_unlock();
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
}
|
2008-01-23 16:30:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetWindowRgn (X11DRV.@)
|
|
|
|
*
|
|
|
|
* Assign specified region to window (for non-rectangular windows)
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
int CDECL X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
|
2008-01-23 16:30:18 +01:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
|
|
|
if ((data = X11DRV_get_win_data( hwnd )))
|
|
|
|
{
|
|
|
|
sync_window_region( thread_display(), data, hrgn );
|
|
|
|
}
|
2008-09-08 15:51:08 +02:00
|
|
|
else if (X11DRV_get_whole_window( hwnd ))
|
2008-01-23 16:30:18 +01:00
|
|
|
{
|
2008-09-08 15:51:08 +02:00
|
|
|
SendMessageW( hwnd, WM_X11DRV_SET_WIN_REGION, 0, 0 );
|
2008-01-23 16:30:18 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2008-04-17 16:13:34 +02:00
|
|
|
|
|
|
|
|
2008-09-12 15:54:02 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetLayeredWindowAttributes (X11DRV.@)
|
|
|
|
*
|
|
|
|
* Set transparency attributes for a layered window.
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
void CDECL X11DRV_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
|
2008-09-12 15:54:02 +02:00
|
|
|
{
|
2008-09-22 12:52:53 +02:00
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
2008-09-12 15:54:02 +02:00
|
|
|
|
2008-09-22 12:52:53 +02:00
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
if (data->whole_window)
|
|
|
|
sync_window_opacity( thread_display(), data->whole_window, key, alpha, flags );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Window win = X11DRV_get_whole_window( hwnd );
|
|
|
|
if (win) sync_window_opacity( gdi_display, win, key, alpha, flags );
|
|
|
|
}
|
2008-09-12 15:54:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-08 15:42:24 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_WindowMessage (X11DRV.@)
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
LRESULT CDECL X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
|
2008-09-08 15:42:24 +02:00
|
|
|
{
|
2008-09-08 15:51:08 +02:00
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
2008-09-08 15:42:24 +02:00
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case WM_X11DRV_ACQUIRE_SELECTION:
|
|
|
|
return X11DRV_AcquireClipboard( hwnd );
|
|
|
|
case WM_X11DRV_SET_WIN_FORMAT:
|
|
|
|
return set_win_format( hwnd, (XID)wp );
|
2008-09-08 15:51:08 +02:00
|
|
|
case WM_X11DRV_SET_WIN_REGION:
|
|
|
|
if ((data = X11DRV_get_win_data( hwnd ))) sync_window_region( thread_display(), data, (HRGN)1 );
|
|
|
|
return 0;
|
2008-09-08 15:42:24 +02:00
|
|
|
case WM_X11DRV_RESIZE_DESKTOP:
|
|
|
|
X11DRV_resize_desktop( LOWORD(lp), HIWORD(lp) );
|
|
|
|
return 0;
|
2010-04-29 02:23:05 +02:00
|
|
|
case WM_X11DRV_SET_CURSOR:
|
2011-02-23 21:46:08 +01:00
|
|
|
if ((data = X11DRV_get_win_data( hwnd ))) set_window_cursor( data, (HCURSOR)lp );
|
2010-04-29 02:23:05 +02:00
|
|
|
return 0;
|
2008-09-08 15:42:24 +02:00
|
|
|
default:
|
|
|
|
FIXME( "got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, wp, lp );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-17 16:13:34 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* is_netwm_supported
|
|
|
|
*/
|
|
|
|
static BOOL is_netwm_supported( Display *display, Atom atom )
|
|
|
|
{
|
|
|
|
static Atom *net_supported;
|
|
|
|
static int net_supported_count = -1;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (net_supported_count == -1)
|
|
|
|
{
|
|
|
|
Atom type;
|
|
|
|
int format;
|
|
|
|
unsigned long count, remaining;
|
|
|
|
|
|
|
|
if (!XGetWindowProperty( display, DefaultRootWindow(display), x11drv_atom(_NET_SUPPORTED), 0,
|
|
|
|
~0UL, False, XA_ATOM, &type, &format, &count,
|
|
|
|
&remaining, (unsigned char **)&net_supported ))
|
|
|
|
net_supported_count = get_property_size( format, count ) / sizeof(Atom);
|
|
|
|
else
|
|
|
|
net_supported_count = 0;
|
|
|
|
}
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
for (i = 0; i < net_supported_count; i++)
|
|
|
|
if (net_supported[i] == atom) return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SysCommand (X11DRV.@)
|
|
|
|
*
|
|
|
|
* Perform WM_SYSCOMMAND handling.
|
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
LRESULT CDECL X11DRV_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
|
2008-04-17 16:13:34 +02:00
|
|
|
{
|
|
|
|
WPARAM hittest = wparam & 0x0f;
|
|
|
|
DWORD dwPoint;
|
|
|
|
int x, y, dir;
|
|
|
|
XEvent xev;
|
|
|
|
Display *display = thread_display();
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return -1;
|
|
|
|
if (!data->whole_window || !data->managed || !data->mapped) return -1;
|
|
|
|
|
|
|
|
switch (wparam & 0xfff0)
|
|
|
|
{
|
|
|
|
case SC_MOVE:
|
|
|
|
if (!hittest) dir = _NET_WM_MOVERESIZE_MOVE_KEYBOARD;
|
|
|
|
else dir = _NET_WM_MOVERESIZE_MOVE;
|
|
|
|
break;
|
|
|
|
case SC_SIZE:
|
|
|
|
/* windows without WS_THICKFRAME are not resizable through the window manager */
|
|
|
|
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_THICKFRAME)) return -1;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SC_KEYMENU:
|
|
|
|
/* prevent a simple ALT press+release from activating the system menu,
|
|
|
|
* as that can get confusing on managed windows */
|
|
|
|
if ((WCHAR)lparam) return -1; /* got an explicit char */
|
|
|
|
if (GetMenu( hwnd )) return -1; /* window has a real menu */
|
|
|
|
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_SYSMENU)) return -1; /* no system menu */
|
|
|
|
TRACE( "ignoring SC_KEYMENU wp %lx lp %lx\n", wparam, lparam );
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsZoomed(hwnd)) return -1;
|
|
|
|
|
|
|
|
if (!is_netwm_supported( display, x11drv_atom(_NET_WM_MOVERESIZE) ))
|
|
|
|
{
|
|
|
|
TRACE( "_NET_WM_MOVERESIZE not supported\n" );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwPoint = GetMessagePos();
|
|
|
|
x = (short)LOWORD(dwPoint);
|
|
|
|
y = (short)HIWORD(dwPoint);
|
|
|
|
|
|
|
|
TRACE("hwnd %p, x %d, y %d, dir %d\n", hwnd, x, y, dir);
|
|
|
|
|
|
|
|
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;
|
2008-09-12 11:03:26 +02:00
|
|
|
xev.xclient.data.l[0] = x - virtual_screen_rect.left; /* x coord */
|
|
|
|
xev.xclient.data.l[1] = y - virtual_screen_rect.top; /* y coord */
|
2008-04-17 16:13:34 +02:00
|
|
|
xev.xclient.data.l[2] = dir; /* direction */
|
|
|
|
xev.xclient.data.l[3] = 1; /* button */
|
|
|
|
xev.xclient.data.l[4] = 0; /* unused */
|
|
|
|
|
|
|
|
/* need to ungrab the pointer that may have been automatically grabbed
|
|
|
|
* with a ButtonPress event */
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XUngrabPointer( display, CurrentTime );
|
2010-08-01 20:06:05 +02:00
|
|
|
XSendEvent(display, root_window, False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
|
2008-04-17 16:13:34 +02:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
return 0;
|
|
|
|
}
|