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"
|
2019-05-03 12:28:38 +02:00
|
|
|
#include "wine/port.h"
|
2001-04-25 01:28:52 +02:00
|
|
|
|
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
|
|
|
|
2020-11-29 21:35:16 +01:00
|
|
|
/* avoid conflict with field names in included win32 headers */
|
|
|
|
#undef Status
|
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"
|
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
|
|
|
|
|
2015-07-01 20:43:48 +02:00
|
|
|
static const unsigned int net_wm_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
|
|
|
|
};
|
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
#define SWP_AGG_NOPOSCHANGE (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOZORDER)
|
|
|
|
|
2011-04-14 12:04:45 +02:00
|
|
|
/* is cursor clipping active? */
|
2013-11-29 12:33:09 +01:00
|
|
|
BOOL clipping_cursor = FALSE;
|
2011-04-05 11:50:45 +02:00
|
|
|
|
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 */
|
2012-08-15 15:51:06 +02:00
|
|
|
XContext win_data_context = 0;
|
2005-01-28 18:25:50 +01:00
|
|
|
|
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";
|
2011-04-05 11:50:45 +02:00
|
|
|
static const char clip_window_prop[] = "__wine_x11_clip_window";
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2012-09-17 13:03:52 +02:00
|
|
|
static CRITICAL_SECTION win_data_section;
|
|
|
|
static CRITICAL_SECTION_DEBUG critsect_debug =
|
|
|
|
{
|
|
|
|
0, 0, &win_data_section,
|
|
|
|
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": win_data_section") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION win_data_section = { &critsect_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
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++] = '"';
|
2016-01-19 07:52:10 +01:00
|
|
|
for (i = 0; id[i] && pos < sizeof(message) - 3; i++)
|
2009-01-06 19:59:07 +01:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-23 12:34:19 +01:00
|
|
|
struct has_popup_result
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
BOOL found;
|
|
|
|
};
|
|
|
|
|
2012-09-21 11:31:28 +02:00
|
|
|
static BOOL is_managed( HWND hwnd )
|
|
|
|
{
|
|
|
|
struct x11drv_win_data *data = get_win_data( hwnd );
|
|
|
|
BOOL ret = data && data->managed;
|
|
|
|
release_win_data( data );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-12-19 11:12:38 +01:00
|
|
|
static BOOL CALLBACK has_managed_popup( HWND hwnd, LPARAM lparam )
|
2010-02-23 12:34:19 +01:00
|
|
|
{
|
|
|
|
struct has_popup_result *result = (struct has_popup_result *)lparam;
|
|
|
|
|
|
|
|
if (hwnd == result->hwnd) return FALSE; /* popups are always above owner */
|
2011-12-19 11:12:38 +01:00
|
|
|
if (GetWindow( hwnd, GW_OWNER ) != result->hwnd) return TRUE;
|
2012-09-21 11:31:28 +02:00
|
|
|
result->found = is_managed( hwnd );
|
2010-02-23 12:34:19 +01:00
|
|
|
return !result->found;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL has_owned_popups( HWND hwnd )
|
|
|
|
{
|
|
|
|
struct has_popup_result result;
|
|
|
|
|
|
|
|
result.hwnd = hwnd;
|
|
|
|
result.found = FALSE;
|
2011-12-19 11:12:38 +01:00
|
|
|
EnumWindows( has_managed_popup, (LPARAM)&result );
|
2010-02-23 12:34:19 +01:00
|
|
|
return result.found;
|
|
|
|
}
|
|
|
|
|
2018-02-12 15:49:23 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* alloc_win_data
|
|
|
|
*/
|
|
|
|
static struct x11drv_win_data *alloc_win_data( Display *display, HWND hwnd )
|
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
|
|
|
if ((data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data))))
|
|
|
|
{
|
|
|
|
data->display = display;
|
|
|
|
data->vis = default_visual;
|
|
|
|
data->hwnd = hwnd;
|
|
|
|
EnterCriticalSection( &win_data_section );
|
|
|
|
XSaveContext( gdi_display, (XID)hwnd, win_data_context, (char *)data );
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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 */
|
2020-08-25 09:20:48 +02:00
|
|
|
return is_window_rect_full_screen( &data->whole_rect );
|
2008-04-04 11:25:48 +02:00
|
|
|
}
|
|
|
|
|
2020-08-25 09:20:48 +02:00
|
|
|
struct monitor_info
|
|
|
|
{
|
|
|
|
const RECT *rect;
|
|
|
|
BOOL full_screen;
|
|
|
|
};
|
|
|
|
|
|
|
|
static BOOL CALLBACK enum_monitor_proc( HMONITOR monitor, HDC hdc, RECT *monitor_rect, LPARAM lparam )
|
|
|
|
{
|
|
|
|
struct monitor_info *info = (struct monitor_info *)lparam;
|
|
|
|
|
|
|
|
if (info->rect->left <= monitor_rect->left && info->rect->right >= monitor_rect->right &&
|
|
|
|
info->rect->top <= monitor_rect->top && info->rect->bottom >= monitor_rect->bottom)
|
|
|
|
{
|
|
|
|
info->full_screen = TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL is_window_rect_full_screen( const RECT *rect )
|
|
|
|
{
|
|
|
|
struct monitor_info info = {rect, FALSE};
|
|
|
|
|
|
|
|
EnumDisplayMonitors( NULL, NULL, enum_monitor_proc, (LPARAM)&info );
|
|
|
|
return info.full_screen;
|
|
|
|
}
|
2008-04-04 11:25:48 +02:00
|
|
|
|
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,
|
2020-03-18 14:46:07 +01:00
|
|
|
DWORD style, DWORD ex_style,
|
|
|
|
const RECT *window_rect,
|
|
|
|
const RECT *client_rect )
|
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;
|
|
|
|
|
2020-03-18 14:46:07 +01:00
|
|
|
if (EqualRect( window_rect, client_rect )) return 0;
|
|
|
|
if (IsRectEmpty( 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;
|
2012-10-02 13:51:56 +02:00
|
|
|
if (ex_style & WS_EX_LAYERED) return 0;
|
2007-10-11 12:24:27 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
static int get_window_attributes( 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;
|
2019-09-19 04:44:19 +02:00
|
|
|
attr->colormap = data->whole_colormap ? data->whole_colormap : default_colormap;
|
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;
|
|
|
|
attr->backing_store = NotUseful;
|
2012-09-25 15:51:03 +02:00
|
|
|
attr->border_pixel = 0;
|
2007-08-20 14:23:10 +02:00
|
|
|
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
|
|
|
|
2012-09-25 15:51:03 +02:00
|
|
|
return (CWOverrideRedirect | CWSaveUnder | CWColormap | CWBorderPixel |
|
2007-08-20 14:23:10 +02:00
|
|
|
CWEventMask | CWBitGravity | CWBackingStore);
|
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.
|
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
static void sync_window_style( 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;
|
2012-09-21 16:29:24 +02:00
|
|
|
int mask = get_window_attributes( data, &attr );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
XChangeWindowAttributes( data->display, data->whole_window, mask, &attr );
|
2007-08-20 14:23:10 +02:00
|
|
|
}
|
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.
|
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
static void sync_window_region( 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;
|
2012-09-21 16:29:24 +02:00
|
|
|
XShapeCombineRectangles( data->display, data->whole_window, ShapeBounding, 0, 0,
|
2010-05-28 12:14:43 +02:00
|
|
|
&empty_rect, 1, ShapeSet, YXBanded );
|
|
|
|
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)
|
|
|
|
{
|
2012-09-21 16:29:24 +02:00
|
|
|
XShapeCombineMask( data->display, data->whole_window, ShapeBounding, 0, 0, None, ShapeSet );
|
2008-01-23 16:30:18 +01:00
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2012-09-21 16:29:24 +02:00
|
|
|
XShapeCombineRectangles( data->display, data->whole_window, ShapeBounding,
|
2008-01-23 16:30:18 +01:00
|
|
|
data->window_rect.left - data->whole_rect.left,
|
|
|
|
data->window_rect.top - data->whole_rect.top,
|
|
|
|
(XRectangle *)pRegionData->Buffer,
|
|
|
|
pRegionData->rdh.nCount, ShapeSet, YXBanded );
|
|
|
|
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 (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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, utf8_buffer );
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
2012-05-15 20:58:39 +02:00
|
|
|
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *info = (BITMAPINFO *)buffer;
|
2010-04-19 11:13:34 +02:00
|
|
|
BITMAP bm;
|
2010-04-19 14:49:26 +02:00
|
|
|
unsigned int *ptr, *bits = NULL;
|
|
|
|
unsigned char *mask_bits = NULL;
|
2013-10-01 23:33:53 +02:00
|
|
|
int i, j;
|
|
|
|
BOOL has_alpha = FALSE;
|
2010-04-19 11:13:34 +02:00
|
|
|
|
|
|
|
if (!GetObjectW( color, sizeof(bm), &bm )) 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-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, bits );
|
2010-04-19 14:49:26 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, mask_bits );
|
2010-04-19 11:13:34 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-15 20:58:39 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* create_icon_pixmaps
|
|
|
|
*/
|
2012-09-21 11:52:29 +02:00
|
|
|
static BOOL create_icon_pixmaps( HDC hdc, const ICONINFO *icon, Pixmap *icon_ret, Pixmap *mask_ret )
|
2012-05-15 20:58:39 +02:00
|
|
|
{
|
|
|
|
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *info = (BITMAPINFO *)buffer;
|
2012-09-25 15:51:03 +02:00
|
|
|
XVisualInfo vis = default_visual;
|
2012-05-15 20:58:39 +02:00
|
|
|
struct gdi_image_bits bits;
|
|
|
|
Pixmap color_pixmap = 0, mask_pixmap = 0;
|
2013-03-05 23:52:11 +01:00
|
|
|
int lines;
|
|
|
|
unsigned int i;
|
2012-05-15 20:58:39 +02:00
|
|
|
|
|
|
|
bits.ptr = NULL;
|
|
|
|
bits.free = NULL;
|
|
|
|
bits.is_copy = TRUE;
|
|
|
|
|
|
|
|
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
info->bmiHeader.biBitCount = 0;
|
|
|
|
if (!(lines = GetDIBits( hdc, icon->hbmColor, 0, 0, NULL, info, DIB_RGB_COLORS ))) goto failed;
|
|
|
|
if (!(bits.ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto failed;
|
|
|
|
if (!GetDIBits( hdc, icon->hbmColor, 0, lines, bits.ptr, info, DIB_RGB_COLORS )) goto failed;
|
|
|
|
|
|
|
|
color_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS );
|
|
|
|
HeapFree( GetProcessHeap(), 0, bits.ptr );
|
|
|
|
bits.ptr = NULL;
|
|
|
|
if (!color_pixmap) goto failed;
|
|
|
|
|
|
|
|
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
info->bmiHeader.biBitCount = 0;
|
|
|
|
if (!(lines = GetDIBits( hdc, icon->hbmMask, 0, 0, NULL, info, DIB_RGB_COLORS ))) goto failed;
|
|
|
|
if (!(bits.ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto failed;
|
|
|
|
if (!GetDIBits( hdc, icon->hbmMask, 0, lines, bits.ptr, info, DIB_RGB_COLORS )) goto failed;
|
|
|
|
|
|
|
|
/* invert the mask */
|
|
|
|
for (i = 0; i < info->bmiHeader.biSizeImage / sizeof(DWORD); i++) ((DWORD *)bits.ptr)[i] ^= ~0u;
|
|
|
|
|
|
|
|
vis.depth = 1;
|
|
|
|
mask_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS );
|
|
|
|
HeapFree( GetProcessHeap(), 0, bits.ptr );
|
|
|
|
bits.ptr = NULL;
|
|
|
|
if (!mask_pixmap) goto failed;
|
|
|
|
|
2012-09-21 11:52:29 +02:00
|
|
|
*icon_ret = color_pixmap;
|
|
|
|
*mask_ret = mask_pixmap;
|
2012-05-15 20:58:39 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
failed:
|
|
|
|
if (color_pixmap) XFreePixmap( gdi_display, color_pixmap );
|
|
|
|
HeapFree( GetProcessHeap(), 0, bits.ptr );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 01:28:52 +02:00
|
|
|
/***********************************************************************
|
2012-09-21 11:52:29 +02:00
|
|
|
* fetch_icon_data
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
2012-09-21 11:52:29 +02:00
|
|
|
static void fetch_icon_data( HWND hwnd, HICON icon_big, HICON icon_small )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2012-09-13 20:08:01 +02:00
|
|
|
struct x11drv_win_data *data;
|
2012-09-04 17:14:46 +02:00
|
|
|
ICONINFO ii, ii_small;
|
|
|
|
HDC hDC;
|
|
|
|
unsigned int size;
|
|
|
|
unsigned long *bits;
|
2012-09-21 11:52:29 +02:00
|
|
|
Pixmap icon_pixmap, mask_pixmap;
|
2007-08-16 23:27:37 +02:00
|
|
|
|
2010-04-19 17:51:44 +02:00
|
|
|
if (!icon_big)
|
|
|
|
{
|
2012-09-13 20:08:01 +02:00
|
|
|
icon_big = (HICON)SendMessageW( hwnd, WM_GETICON, ICON_BIG, 0 );
|
|
|
|
if (!icon_big) icon_big = (HICON)GetClassLongPtrW( hwnd, GCLP_HICON );
|
2012-09-04 17:14:46 +02:00
|
|
|
if (!icon_big) icon_big = LoadIconW( 0, (LPWSTR)IDI_WINLOGO );
|
2010-04-19 17:51:44 +02:00
|
|
|
}
|
|
|
|
if (!icon_small)
|
|
|
|
{
|
2012-09-13 20:08:01 +02:00
|
|
|
icon_small = (HICON)SendMessageW( hwnd, WM_GETICON, ICON_SMALL, 0 );
|
|
|
|
if (!icon_small) icon_small = (HICON)GetClassLongPtrW( hwnd, GCLP_HICONSM );
|
2010-04-19 17:51:44 +02:00
|
|
|
}
|
|
|
|
|
2012-09-04 17:14:46 +02:00
|
|
|
if (!GetIconInfo(icon_big, &ii)) return;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2012-09-04 17:14:46 +02:00
|
|
|
hDC = CreateCompatibleDC(0);
|
|
|
|
bits = get_bitmap_argb( hDC, ii.hbmColor, ii.hbmMask, &size );
|
|
|
|
if (bits && GetIconInfo( icon_small, &ii_small ))
|
|
|
|
{
|
|
|
|
unsigned int size_small;
|
|
|
|
unsigned long *bits_small, *new;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2012-09-04 17:14:46 +02:00
|
|
|
if ((bits_small = get_bitmap_argb( hDC, ii_small.hbmColor, ii_small.hbmMask, &size_small )) &&
|
|
|
|
(bits_small[0] != bits[0] || bits_small[1] != bits[1])) /* size must be different */
|
2010-04-19 17:51:44 +02:00
|
|
|
{
|
2012-09-04 17:14:46 +02:00
|
|
|
if ((new = HeapReAlloc( GetProcessHeap(), 0, bits,
|
|
|
|
(size + size_small) * sizeof(unsigned long) )))
|
2010-04-19 17:51:44 +02:00
|
|
|
{
|
2012-09-04 17:14:46 +02:00
|
|
|
bits = new;
|
|
|
|
memcpy( bits + size, bits_small, size_small * sizeof(unsigned long) );
|
|
|
|
size += size_small;
|
2010-04-19 17:51:44 +02:00
|
|
|
}
|
|
|
|
}
|
2012-09-04 17:14:46 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, bits_small );
|
|
|
|
DeleteObject( ii_small.hbmColor );
|
|
|
|
DeleteObject( ii_small.hbmMask );
|
|
|
|
}
|
2010-04-22 14:16:44 +02:00
|
|
|
|
2012-09-21 11:52:29 +02:00
|
|
|
if (!create_icon_pixmaps( hDC, &ii, &icon_pixmap, &mask_pixmap )) icon_pixmap = mask_pixmap = 0;
|
|
|
|
|
2012-09-04 17:14:46 +02:00
|
|
|
DeleteObject( ii.hbmColor );
|
|
|
|
DeleteObject( ii.hbmMask );
|
|
|
|
DeleteDC(hDC);
|
2012-09-21 11:52:29 +02:00
|
|
|
|
|
|
|
if ((data = get_win_data( hwnd )))
|
|
|
|
{
|
|
|
|
if (data->icon_pixmap) XFreePixmap( gdi_display, data->icon_pixmap );
|
|
|
|
if (data->icon_mask) XFreePixmap( gdi_display, data->icon_mask );
|
|
|
|
HeapFree( GetProcessHeap(), 0, data->icon_bits );
|
|
|
|
data->icon_pixmap = icon_pixmap;
|
|
|
|
data->icon_mask = mask_pixmap;
|
|
|
|
data->icon_bits = bits;
|
|
|
|
data->icon_size = size;
|
|
|
|
release_win_data( data );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (icon_pixmap) XFreePixmap( gdi_display, icon_pixmap );
|
|
|
|
if (mask_pixmap) XFreePixmap( gdi_display, mask_pixmap );
|
|
|
|
HeapFree( GetProcessHeap(), 0, bits );
|
|
|
|
}
|
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
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
static void set_size_hints( 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
|
|
|
}
|
2011-05-12 16:25:50 +02:00
|
|
|
else size_hints->win_gravity = NorthWestGravity;
|
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
|
|
|
}
|
|
|
|
}
|
2012-09-21 16:29:24 +02:00
|
|
|
XSetWMNormalHints( data->display, data->whole_window, size_hints );
|
2008-04-04 11:28:30 +02:00
|
|
|
XFree( size_hints );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-16 12:08:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* set_mwm_hints
|
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
static void set_mwm_hints( struct x11drv_win_data *data, DWORD style, DWORD ex_style )
|
2011-12-16 12:08:08 +01:00
|
|
|
{
|
|
|
|
MwmHints mwm_hints;
|
|
|
|
|
2011-12-19 11:12:12 +01:00
|
|
|
if (data->hwnd == GetDesktopWindow())
|
|
|
|
{
|
2012-08-13 11:39:41 +02:00
|
|
|
if (is_desktop_fullscreen()) mwm_hints.decorations = 0;
|
|
|
|
else mwm_hints.decorations = MWM_DECOR_TITLE | MWM_DECOR_BORDER | MWM_DECOR_MENU | MWM_DECOR_MINIMIZE;
|
|
|
|
mwm_hints.functions = MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE | MWM_FUNC_CLOSE;
|
2011-12-19 11:12:12 +01:00
|
|
|
}
|
|
|
|
else
|
2011-12-16 12:08:08 +01:00
|
|
|
{
|
2020-03-18 14:46:07 +01:00
|
|
|
mwm_hints.decorations = get_mwm_decorations( data, style, ex_style, &data->window_rect, &data->client_rect );
|
2011-12-19 11:12:12 +01:00
|
|
|
mwm_hints.functions = MWM_FUNC_MOVE;
|
|
|
|
if (is_window_resizable( data, style )) mwm_hints.functions |= MWM_FUNC_RESIZE;
|
|
|
|
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;
|
2020-11-13 14:26:18 +01:00
|
|
|
|
|
|
|
/* The window can be programmatically minimized even without
|
|
|
|
a minimize box button. Allow the WM to restore it. */
|
|
|
|
if (style & WS_MINIMIZE) mwm_hints.functions |= MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE;
|
2011-12-19 11:12:12 +01:00
|
|
|
}
|
2011-12-16 12:08:08 +01:00
|
|
|
}
|
2011-12-19 11:12:12 +01:00
|
|
|
|
2011-12-16 12:08:08 +01:00
|
|
|
TRACE( "%p setting mwm hints to %lx,%lx (style %x exstyle %x)\n",
|
|
|
|
data->hwnd, mwm_hints.decorations, mwm_hints.functions, style, ex_style );
|
|
|
|
|
2011-12-19 11:12:12 +01:00
|
|
|
mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
2015-05-28 11:13:41 +02:00
|
|
|
mwm_hints.input_mode = 0;
|
|
|
|
mwm_hints.status = 0;
|
2012-09-21 16:29:24 +02:00
|
|
|
XChangeProperty( data->display, data->whole_window, x11drv_atom(_MOTIF_WM_HINTS),
|
2011-12-16 12:08:08 +01:00
|
|
|
x11drv_atom(_MOTIF_WM_HINTS), 32, PropModeReplace,
|
|
|
|
(unsigned char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-21 11:31:28 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* set_style_hints
|
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
static void set_style_hints( struct x11drv_win_data *data, DWORD style, DWORD ex_style )
|
2012-09-21 11:31:28 +02:00
|
|
|
{
|
|
|
|
Window group_leader = data->whole_window;
|
|
|
|
HWND owner = GetWindow( data->hwnd, GW_OWNER );
|
2016-06-25 13:59:49 +02:00
|
|
|
Window owner_win = 0;
|
2012-09-21 11:52:29 +02:00
|
|
|
XWMHints *wm_hints;
|
2012-09-21 11:31:28 +02:00
|
|
|
Atom window_type;
|
|
|
|
|
2016-06-25 13:59:49 +02:00
|
|
|
if (owner)
|
|
|
|
{
|
|
|
|
owner = GetAncestor( owner, GA_ROOT );
|
|
|
|
owner_win = X11DRV_get_whole_window( owner );
|
|
|
|
}
|
|
|
|
|
2012-09-21 11:31:28 +02:00
|
|
|
if (owner_win)
|
|
|
|
{
|
2012-09-21 16:29:24 +02:00
|
|
|
XSetTransientForHint( data->display, data->whole_window, owner_win );
|
2012-09-21 11:31:28 +02:00
|
|
|
group_leader = owner_win;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only use dialog type for owned popups. Metacity allows making fullscreen
|
|
|
|
* only normal windows, and doesn't handle correctly TRANSIENT_FOR hint for
|
|
|
|
* dialogs owned by fullscreen windows.
|
|
|
|
*/
|
|
|
|
if (((style & WS_POPUP) || (ex_style & WS_EX_DLGMODALFRAME)) && owner)
|
|
|
|
window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_DIALOG);
|
|
|
|
else
|
|
|
|
window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_NORMAL);
|
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
XChangeProperty(data->display, data->whole_window, x11drv_atom(_NET_WM_WINDOW_TYPE),
|
2012-09-21 11:31:28 +02:00
|
|
|
XA_ATOM, 32, PropModeReplace, (unsigned char*)&window_type, 1);
|
|
|
|
|
2012-09-21 11:52:29 +02:00
|
|
|
if ((wm_hints = XAllocWMHints()))
|
2012-09-21 11:31:28 +02:00
|
|
|
{
|
2012-09-21 11:52:29 +02:00
|
|
|
wm_hints->flags = InputHint | StateHint | WindowGroupHint;
|
|
|
|
wm_hints->input = !use_take_focus && !(style & WS_DISABLED);
|
|
|
|
wm_hints->initial_state = (style & WS_MINIMIZE) ? IconicState : NormalState;
|
|
|
|
wm_hints->window_group = group_leader;
|
|
|
|
if (data->icon_pixmap)
|
|
|
|
{
|
|
|
|
wm_hints->icon_pixmap = data->icon_pixmap;
|
|
|
|
wm_hints->icon_mask = data->icon_mask;
|
|
|
|
wm_hints->flags |= IconPixmapHint | IconMaskHint;
|
|
|
|
}
|
2012-09-21 16:29:24 +02:00
|
|
|
XSetWMHints( data->display, data->whole_window, wm_hints );
|
2012-09-21 11:52:29 +02:00
|
|
|
XFree( wm_hints );
|
2012-09-21 11:31:28 +02:00
|
|
|
}
|
2012-09-21 11:52:29 +02:00
|
|
|
|
|
|
|
if (data->icon_bits)
|
2012-09-21 16:29:24 +02:00
|
|
|
XChangeProperty( data->display, data->whole_window, x11drv_atom(_NET_WM_ICON),
|
2012-09-21 11:52:29 +02:00
|
|
|
XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
(unsigned char *)data->icon_bits, data->icon_size );
|
|
|
|
else
|
2012-09-21 16:29:24 +02:00
|
|
|
XDeleteProperty( data->display, data->whole_window, x11drv_atom(_NET_WM_ICON) );
|
2012-09-21 11:52:29 +02:00
|
|
|
|
2012-09-21 11:31:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2012-09-21 12:45:35 +02:00
|
|
|
static void set_initial_wm_hints( Display *display, Window window )
|
2007-08-20 14:04:36 +02:00
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
/* 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);
|
2012-09-21 12:45:35 +02:00
|
|
|
XChangeProperty( display, window, x11drv_atom(WM_PROTOCOLS),
|
2007-08-20 14:04:36 +02:00
|
|
|
XA_ATOM, 32, PropModeReplace, (unsigned char *)protocols, i );
|
|
|
|
|
|
|
|
/* class hints */
|
|
|
|
if ((class_hints = XAllocClassHint()))
|
|
|
|
{
|
|
|
|
class_hints->res_name = process_name;
|
2020-04-17 00:47:16 +02:00
|
|
|
class_hints->res_class = process_name;
|
2012-09-21 12:45:35 +02:00
|
|
|
XSetClassHint( display, window, class_hints );
|
2007-08-20 14:04:36 +02:00
|
|
|
XFree( class_hints );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the WM_CLIENT_MACHINE and WM_LOCALE_NAME properties */
|
2012-09-21 12:45:35 +02:00
|
|
|
XSetWMProperties(display, window, NULL, NULL, NULL, 0, NULL, NULL, NULL);
|
2007-08-20 14:04:36 +02:00
|
|
|
/* set the pid. together, these properties are needed so the window manager can kill us if we freeze */
|
|
|
|
i = getpid();
|
2012-09-21 12:45:35 +02:00
|
|
|
XChangeProperty(display, window, x11drv_atom(_NET_WM_PID),
|
2007-08-20 14:04:36 +02:00
|
|
|
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&i, 1);
|
|
|
|
|
2012-09-21 12:45:35 +02:00
|
|
|
XChangeProperty( display, window, x11drv_atom(XdndAware),
|
2007-08-20 14:04:36 +02:00
|
|
|
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)
|
2012-09-21 12:45:35 +02:00
|
|
|
XChangeProperty( display, window, x11drv_atom(_NET_WM_USER_TIME_WINDOW),
|
2010-06-29 11:08:51 +02:00
|
|
|
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&user_time_window, 1 );
|
2007-08-20 14:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-23 12:33:01 +01:00
|
|
|
/***********************************************************************
|
2012-09-21 11:31:28 +02:00
|
|
|
* make_owner_managed
|
2010-02-23 12:33:01 +01:00
|
|
|
*
|
2012-09-21 11:31:28 +02:00
|
|
|
* If the window is managed, make sure its owner window is too.
|
2010-02-23 12:33:01 +01:00
|
|
|
*/
|
2012-09-21 11:31:28 +02:00
|
|
|
static void make_owner_managed( HWND hwnd )
|
2010-02-23 12:33:01 +01:00
|
|
|
{
|
2012-09-21 11:31:28 +02:00
|
|
|
HWND owner;
|
2010-02-23 12:33:01 +01:00
|
|
|
|
2012-09-21 11:31:28 +02:00
|
|
|
if (!(owner = GetWindow( hwnd, GW_OWNER ))) return;
|
|
|
|
if (is_managed( owner )) return;
|
|
|
|
if (!is_managed( hwnd )) return;
|
2012-09-04 13:34:15 +02:00
|
|
|
|
2012-09-21 11:31:28 +02: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
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
*
|
2012-09-21 11:31:28 +02:00
|
|
|
* Set all the window manager hints for a window.
|
2001-04-25 01:28:52 +02:00
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
static void set_wm_hints( struct x11drv_win_data *data )
|
2001-04-25 01:28:52 +02:00
|
|
|
{
|
2008-04-14 13:27:38 +02:00
|
|
|
DWORD style, ex_style;
|
2005-01-17 20:17:47 +01:00
|
|
|
|
2012-09-21 12:45:35 +02:00
|
|
|
if (data->hwnd == GetDesktopWindow())
|
2006-03-27 22:16:04 +02:00
|
|
|
{
|
|
|
|
/* 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
|
|
|
}
|
2008-04-14 13:27:38 +02:00
|
|
|
else
|
|
|
|
{
|
2012-09-21 12:45:35 +02:00
|
|
|
style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
|
|
|
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
|
2008-04-14 13:27:38 +02:00
|
|
|
}
|
2006-03-27 22:16:04 +02:00
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
set_size_hints( data, style );
|
|
|
|
set_mwm_hints( data, style, ex_style );
|
|
|
|
set_style_hints( data, style, ex_style );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-14 12:04:45 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* init_clip_window
|
|
|
|
*/
|
|
|
|
Window init_clip_window(void)
|
|
|
|
{
|
|
|
|
struct x11drv_thread_data *data = x11drv_init_thread_data();
|
|
|
|
|
|
|
|
if (!data->clip_window &&
|
|
|
|
(data->clip_window = (Window)GetPropA( GetDesktopWindow(), clip_window_prop )))
|
|
|
|
{
|
|
|
|
XSelectInput( data->display, data->clip_window, StructureNotifyMask );
|
|
|
|
}
|
|
|
|
return data->clip_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-29 11:08:51 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* update_user_time
|
|
|
|
*/
|
|
|
|
void update_user_time( Time time )
|
|
|
|
{
|
|
|
|
if (!user_time_window)
|
|
|
|
{
|
2012-09-25 15:51:03 +02:00
|
|
|
Window win = XCreateWindow( gdi_display, root_window, -1, -1, 1, 1, 0, CopyFromParent,
|
|
|
|
InputOnly, CopyFromParent, 0, NULL );
|
2012-08-16 16:46:37 +02:00
|
|
|
if (InterlockedCompareExchangePointer( (void **)&user_time_window, (void *)win, 0 ))
|
|
|
|
XDestroyWindow( gdi_display, win );
|
2010-06-29 11:08:51 +02:00
|
|
|
TRACE( "user time window %lx\n", user_time_window );
|
|
|
|
}
|
2012-08-16 16:46:37 +02:00
|
|
|
|
|
|
|
if (!time) return;
|
|
|
|
XLockDisplay( gdi_display );
|
|
|
|
if (!last_user_time || (long)(time - last_user_time) > 0)
|
2010-06-29 11:08:51 +02:00
|
|
|
{
|
|
|
|
last_user_time = time;
|
|
|
|
XChangeProperty( gdi_display, user_time_window, x11drv_atom(_NET_WM_USER_TIME),
|
|
|
|
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&time, 1 );
|
|
|
|
}
|
2012-08-16 16:46:37 +02:00
|
|
|
XUnlockDisplay( gdi_display );
|
2010-06-29 11:08:51 +02:00
|
|
|
}
|
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* update_net_wm_states
|
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
void update_net_wm_states( struct x11drv_win_data *data )
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
|
|
|
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 );
|
2014-07-10 22:29:29 +02:00
|
|
|
if (style & WS_MINIMIZE)
|
2015-07-17 22:48:24 +02:00
|
|
|
new_state |= data->net_wm_state & ((1 << NET_WM_STATE_FULLSCREEN)|(1 << NET_WM_STATE_MAXIMIZED));
|
2020-08-25 09:20:48 +02:00
|
|
|
if (is_window_rect_full_screen( &data->whole_rect ))
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
|
|
|
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 );
|
2015-07-01 20:43:48 +02:00
|
|
|
atoms[count++] = X11DRV_Atoms[net_wm_state_atoms[i] - FIRST_XATOM];
|
|
|
|
if (net_wm_state_atoms[i] == XATOM__NET_WM_STATE_MAXIMIZED_VERT)
|
2008-04-23 15:32:58 +02:00
|
|
|
atoms[count++] = x11drv_atom(_NET_WM_STATE_MAXIMIZED_HORZ);
|
|
|
|
}
|
2012-09-21 16:29:24 +02:00
|
|
|
XChangeProperty( data->display, data->whole_window, x11drv_atom(_NET_WM_STATE), XA_ATOM,
|
2008-04-23 15:32:58 +02:00
|
|
|
32, PropModeReplace, (unsigned char *)atoms, count );
|
|
|
|
}
|
|
|
|
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;
|
2012-09-21 16:29:24 +02:00
|
|
|
xev.xclient.display = data->display;
|
2008-04-23 15:32:58 +02:00
|
|
|
xev.xclient.send_event = True;
|
|
|
|
xev.xclient.format = 32;
|
|
|
|
xev.xclient.data.l[3] = 1;
|
2015-08-27 23:19:46 +02:00
|
|
|
xev.xclient.data.l[4] = 0;
|
2008-04-23 15:32:58 +02:00
|
|
|
|
|
|
|
for (i = 0; i < NB_NET_WM_STATES; i++)
|
|
|
|
{
|
|
|
|
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;
|
2015-07-01 20:43:48 +02:00
|
|
|
xev.xclient.data.l[1] = X11DRV_Atoms[net_wm_state_atoms[i] - FIRST_XATOM];
|
|
|
|
xev.xclient.data.l[2] = ((net_wm_state_atoms[i] == XATOM__NET_WM_STATE_MAXIMIZED_VERT) ?
|
2008-04-23 15:32:58 +02:00
|
|
|
x11drv_atom(_NET_WM_STATE_MAXIMIZED_HORZ) : 0);
|
2012-09-21 16:29:24 +02:00
|
|
|
XSendEvent( data->display, root_window, False,
|
2008-04-23 15:32:58 +02:00
|
|
|
SubstructureRedirectMask | SubstructureNotifyMask, &xev );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data->net_wm_state = new_state;
|
|
|
|
}
|
|
|
|
|
2015-07-01 20:43:48 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* read_net_wm_states
|
|
|
|
*/
|
|
|
|
void read_net_wm_states( Display* display, struct x11drv_win_data *data )
|
|
|
|
{
|
|
|
|
Atom type, *state;
|
|
|
|
int format;
|
|
|
|
unsigned long i, j, count, remaining;
|
|
|
|
DWORD new_state = 0;
|
|
|
|
BOOL maximized_horz = FALSE;
|
|
|
|
|
|
|
|
if (!data->whole_window) return;
|
|
|
|
|
|
|
|
if (!XGetWindowProperty( display, data->whole_window, x11drv_atom(_NET_WM_STATE), 0,
|
|
|
|
65536/sizeof(CARD32), False, XA_ATOM, &type, &format, &count,
|
|
|
|
&remaining, (unsigned char **)&state ))
|
|
|
|
{
|
|
|
|
if (type == XA_ATOM && format == 32)
|
|
|
|
{
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (state[i] == x11drv_atom(_NET_WM_STATE_MAXIMIZED_HORZ))
|
|
|
|
maximized_horz = TRUE;
|
|
|
|
for (j=0; j < NB_NET_WM_STATES; j++)
|
|
|
|
{
|
|
|
|
if (state[i] == X11DRV_Atoms[net_wm_state_atoms[j] - FIRST_XATOM])
|
|
|
|
{
|
|
|
|
new_state |= 1 << j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XFree( state );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!maximized_horz)
|
|
|
|
new_state &= ~(1 << NET_WM_STATE_MAXIMIZED);
|
|
|
|
|
|
|
|
data->net_wm_state = new_state;
|
|
|
|
}
|
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* set_xembed_flags
|
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
static void set_xembed_flags( struct x11drv_win_data *data, unsigned long flags )
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
|
|
|
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;
|
2012-09-21 16:29:24 +02:00
|
|
|
XChangeProperty( data->display, data->whole_window, x11drv_atom(_XEMBED_INFO),
|
2008-04-23 15:32:58 +02:00
|
|
|
x11drv_atom(_XEMBED_INFO), 32, PropModeReplace, (unsigned char*)info, 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* map_window
|
|
|
|
*/
|
2012-09-13 20:08:01 +02:00
|
|
|
static void map_window( HWND hwnd, DWORD new_style )
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
2012-09-21 16:50:17 +02:00
|
|
|
struct x11drv_win_data *data;
|
2009-01-06 19:59:07 +01:00
|
|
|
|
2012-09-24 14:06:42 +02:00
|
|
|
make_owner_managed( hwnd );
|
2012-09-13 20:08:01 +02:00
|
|
|
wait_for_withdrawn_state( hwnd, TRUE );
|
2008-04-23 15:32:58 +02:00
|
|
|
|
2012-09-21 16:50:17 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
|
|
|
|
|
|
|
if (data->whole_window && !data->mapped)
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
2012-09-21 16:50:17 +02:00
|
|
|
TRACE( "win %p/%lx\n", data->hwnd, data->whole_window );
|
2008-04-23 15:32:58 +02:00
|
|
|
|
2012-09-21 16:50:17 +02:00
|
|
|
remove_startup_notification( data->display, data->whole_window );
|
|
|
|
set_wm_hints( data );
|
|
|
|
|
|
|
|
if (!data->embedded)
|
|
|
|
{
|
|
|
|
update_net_wm_states( data );
|
|
|
|
sync_window_style( data );
|
|
|
|
XMapWindow( data->display, data->whole_window );
|
2012-09-24 14:06:42 +02:00
|
|
|
XFlush( data->display );
|
2012-09-26 13:12:17 +02:00
|
|
|
if (data->surface && data->vis.visualid != default_visual.visualid)
|
|
|
|
data->surface->funcs->flush( data->surface );
|
2012-09-21 16:50:17 +02:00
|
|
|
}
|
|
|
|
else set_xembed_flags( data, XEMBED_MAPPED );
|
|
|
|
|
|
|
|
data->mapped = TRUE;
|
|
|
|
data->iconic = (new_style & WS_MINIMIZE) != 0;
|
|
|
|
}
|
|
|
|
release_win_data( data );
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* unmap_window
|
|
|
|
*/
|
2012-09-13 20:08:01 +02:00
|
|
|
static void unmap_window( HWND hwnd )
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
2012-09-21 16:50:17 +02:00
|
|
|
struct x11drv_win_data *data;
|
2012-09-13 20:08:01 +02:00
|
|
|
|
2012-09-21 16:50:17 +02:00
|
|
|
wait_for_withdrawn_state( hwnd, FALSE );
|
|
|
|
|
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
2008-04-23 15:32:58 +02:00
|
|
|
|
2012-09-21 16:50:17 +02:00
|
|
|
if (data->mapped)
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
2012-09-21 16:50:17 +02:00
|
|
|
TRACE( "win %p/%lx\n", data->hwnd, data->whole_window );
|
|
|
|
|
|
|
|
if (data->embedded) set_xembed_flags( data, 0 );
|
|
|
|
else if (!data->managed) XUnmapWindow( data->display, data->whole_window );
|
2012-09-26 12:19:37 +02:00
|
|
|
else XWithdrawWindow( data->display, data->whole_window, data->vis.screen );
|
2008-04-23 15:32:58 +02:00
|
|
|
|
2012-09-21 16:50:17 +02:00
|
|
|
data->mapped = FALSE;
|
|
|
|
data->net_wm_state = 0;
|
|
|
|
}
|
|
|
|
release_win_data( data );
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* make_window_embedded
|
|
|
|
*/
|
2012-10-01 15:59:49 +02:00
|
|
|
void make_window_embedded( struct x11drv_win_data *data )
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
2012-09-21 16:50:17 +02:00
|
|
|
/* the window cannot be mapped before being embedded */
|
|
|
|
if (data->mapped)
|
|
|
|
{
|
2016-05-17 05:34:26 +02:00
|
|
|
if (!data->managed) XUnmapWindow( data->display, data->whole_window );
|
2012-09-26 12:19:37 +02:00
|
|
|
else XWithdrawWindow( data->display, data->whole_window, data->vis.screen );
|
2012-09-21 16:50:17 +02:00
|
|
|
data->net_wm_state = 0;
|
|
|
|
}
|
2010-11-05 13:42:05 +01:00
|
|
|
data->embedded = TRUE;
|
|
|
|
data->managed = TRUE;
|
2012-09-21 16:29:24 +02:00
|
|
|
sync_window_style( data );
|
2013-10-26 18:34:32 +02:00
|
|
|
set_xembed_flags( data, (data->mapped || data->embedder) ? XEMBED_MAPPED : 0 );
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/***********************************************************************
|
2020-05-19 14:18:47 +02:00
|
|
|
* get_decoration_rect
|
2001-06-04 23:55:17 +02:00
|
|
|
*/
|
2020-05-19 14:18:47 +02:00
|
|
|
static void get_decoration_rect( struct x11drv_win_data *data, RECT *rect,
|
|
|
|
const RECT *window_rect, const RECT *client_rect )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2018-08-23 10:50:47 +02:00
|
|
|
DWORD style, ex_style, style_mask = 0, ex_style_mask = 0;
|
|
|
|
unsigned long decor;
|
2001-07-20 20:37:37 +02:00
|
|
|
|
2020-05-19 14:18:47 +02:00
|
|
|
SetRectEmpty( rect );
|
2005-02-01 19:53:59 +01:00
|
|
|
if (!data->managed) return;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2018-08-23 10:50:47 +02:00
|
|
|
style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
|
|
|
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
|
2020-03-18 14:46:07 +01:00
|
|
|
decor = get_mwm_decorations( data, style, ex_style, window_rect, client_rect );
|
2018-08-23 10:50:47 +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;
|
|
|
|
}
|
|
|
|
|
2020-05-19 14:18:47 +02:00
|
|
|
AdjustWindowRectEx( rect, style & style_mask, FALSE, ex_style & ex_style_mask );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_window_to_X_rect
|
|
|
|
*
|
|
|
|
* Convert a rect from client to X window coordinates
|
|
|
|
*/
|
|
|
|
static void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect,
|
|
|
|
const RECT *window_rect, const RECT *client_rect )
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
if (IsRectEmpty( rect )) return;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2020-05-19 14:18:47 +02:00
|
|
|
get_decoration_rect( data, &rc, window_rect, client_rect );
|
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
|
|
|
|
*/
|
2018-08-23 10:50:47 +02:00
|
|
|
void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect, int x, int y, int cx, int cy )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2020-05-19 14:18:48 +02:00
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
get_decoration_rect( data, &rc, &data->window_rect, &data->client_rect );
|
|
|
|
|
|
|
|
x += min( data->window_rect.left - data->whole_rect.left, rc.left );
|
|
|
|
y += min( data->window_rect.top - data->whole_rect.top, rc.top );
|
|
|
|
cx += max( (data->window_rect.right - data->window_rect.left) -
|
|
|
|
(data->whole_rect.right - data->whole_rect.left), rc.right - rc.left );
|
|
|
|
cy += max( (data->window_rect.bottom - data->window_rect.top) -
|
|
|
|
(data->whole_rect.bottom - data->whole_rect.top), rc.bottom - rc.top );
|
2018-08-23 10:50:47 +02:00
|
|
|
SetRect( rect, x, y, x + cx, y + cy );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
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
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
static void sync_window_position( 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 );
|
2011-12-16 12:08:08 +01:00
|
|
|
DWORD ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
|
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)
|
|
|
|
{
|
2013-10-14 14:20:08 +02:00
|
|
|
POINT pt = virtual_screen_to_root( data->whole_rect.left, data->whole_rect.top );
|
|
|
|
changes.x = pt.x;
|
|
|
|
changes.y = pt.y;
|
2008-04-04 11:20:45 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
set_size_hints( data, style );
|
|
|
|
set_mwm_hints( data, style, ex_style );
|
2020-05-07 10:17:28 +02:00
|
|
|
update_net_wm_states( data );
|
2012-09-21 16:29:24 +02:00
|
|
|
data->configure_serial = NextRequest( data->display );
|
2012-09-26 12:19:37 +02:00
|
|
|
XReconfigureWMWindow( data->display, data->whole_window, data->vis.screen, 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 ))
|
2012-09-21 16:29:24 +02:00
|
|
|
sync_window_region( 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)
|
2012-09-21 16:29:24 +02:00
|
|
|
XShapeOffsetShape( data->display, data->whole_window, ShapeBounding,
|
2010-02-08 17:14:01 +01:00
|
|
|
new_x_offset - old_x_offset, new_y_offset - old_y_offset );
|
2010-02-04 17:27:19 +01:00
|
|
|
}
|
|
|
|
#endif
|
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
|
|
|
|
2013-01-23 13:35:30 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* sync_client_position
|
|
|
|
*
|
|
|
|
* Synchronize the X client window position with the Windows one
|
|
|
|
*/
|
|
|
|
static void sync_client_position( struct x11drv_win_data *data,
|
|
|
|
const RECT *old_client_rect, const RECT *old_whole_rect )
|
|
|
|
{
|
|
|
|
int mask = 0;
|
|
|
|
XWindowChanges changes;
|
|
|
|
|
|
|
|
if (!data->client_window) return;
|
|
|
|
|
|
|
|
changes.x = data->client_rect.left - data->whole_rect.left;
|
|
|
|
changes.y = data->client_rect.top - data->whole_rect.top;
|
|
|
|
changes.width = min( max( 1, data->client_rect.right - data->client_rect.left ), 65535 );
|
|
|
|
changes.height = min( max( 1, data->client_rect.bottom - data->client_rect.top ), 65535 );
|
|
|
|
|
|
|
|
if (changes.x != old_client_rect->left - old_whole_rect->left) mask |= CWX;
|
|
|
|
if (changes.y != old_client_rect->top - old_whole_rect->top) mask |= CWY;
|
|
|
|
if (changes.width != old_client_rect->right - old_client_rect->left) mask |= CWWidth;
|
|
|
|
if (changes.height != old_client_rect->bottom - old_client_rect->top) mask |= CWHeight;
|
|
|
|
|
|
|
|
if (mask)
|
|
|
|
{
|
|
|
|
TRACE( "setting client win %lx pos %d,%d,%dx%d changes=%x\n",
|
|
|
|
data->client_window, changes.x, changes.y, changes.width, changes.height, mask );
|
|
|
|
XConfigureWindow( data->display, data->client_window, mask, &changes );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* move_window_bits
|
|
|
|
*
|
|
|
|
* Move the window bits when a window is moved.
|
|
|
|
*/
|
2012-09-24 14:06:42 +02:00
|
|
|
static void move_window_bits( HWND hwnd, Window window, const RECT *old_rect, const RECT *new_rect,
|
|
|
|
const RECT *old_client_rect, const RECT *new_client_rect,
|
|
|
|
const RECT *new_window_rect )
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2012-09-24 14:06:42 +02:00
|
|
|
if (!window)
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
2012-09-24 14:06:42 +02:00
|
|
|
OffsetRect( &dst_rect, -new_window_rect->left, -new_window_rect->top );
|
|
|
|
parent = GetAncestor( hwnd, GA_PARENT );
|
2008-04-23 15:32:58 +02:00
|
|
|
hdc_src = GetDCEx( parent, 0, DCX_CACHE );
|
2012-09-24 14:06:42 +02:00
|
|
|
hdc_dst = GetDCEx( hwnd, 0, DCX_CACHE | DCX_WINDOW );
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-24 14:06:42 +02:00
|
|
|
OffsetRect( &dst_rect, -new_client_rect->left, -new_client_rect->top );
|
2008-04-23 15:32:58 +02:00
|
|
|
/* 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;
|
2012-09-24 14:06:42 +02:00
|
|
|
hdc_src = hdc_dst = GetDCEx( hwnd, 0, DCX_CACHE );
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
|
2011-01-31 12:30:43 +01:00
|
|
|
rgn = CreateRectRgnIndirect( &dst_rect );
|
|
|
|
SelectClipRgn( hdc_dst, rgn );
|
|
|
|
DeleteObject( rgn );
|
2015-06-29 11:54:07 +02:00
|
|
|
/* WS_CLIPCHILDREN doesn't exclude children from the window update
|
|
|
|
* region, and ExcludeUpdateRgn call may inappropriately clip valid
|
|
|
|
* child window contents from the copied parent window bits, but we
|
|
|
|
* still want to avoid copying invalid window bits when possible.
|
|
|
|
*/
|
|
|
|
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_CLIPCHILDREN ))
|
|
|
|
ExcludeUpdateRgn( hdc_dst, hwnd );
|
2010-09-14 07:24:11 +02:00
|
|
|
|
2008-04-23 15:32:58 +02:00
|
|
|
code = X11DRV_START_EXPOSURES;
|
|
|
|
ExtEscape( hdc_dst, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL );
|
|
|
|
|
2012-08-30 18:17:05 +02:00
|
|
|
TRACE( "copying bits for win %p/%lx %s -> %s\n",
|
2012-09-24 14:06:42 +02:00
|
|
|
hwnd, window, wine_dbgstr_rect(&src_rect), wine_dbgstr_rect(&dst_rect) );
|
2008-04-23 15:32:58 +02:00
|
|
|
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 );
|
|
|
|
|
2012-09-24 14:06:42 +02:00
|
|
|
ReleaseDC( hwnd, hdc_dst );
|
2008-04-23 15:32:58 +02:00
|
|
|
if (hdc_src != hdc_dst) ReleaseDC( parent, hdc_src );
|
|
|
|
|
|
|
|
if (rgn)
|
|
|
|
{
|
2012-09-24 14:06:42 +02:00
|
|
|
if (!window)
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
|
|
|
/* map region to client rect since we are using DCX_WINDOW */
|
2012-09-24 14:06:42 +02:00
|
|
|
OffsetRgn( rgn, new_window_rect->left - new_client_rect->left,
|
|
|
|
new_window_rect->top - new_client_rect->top );
|
|
|
|
RedrawWindow( hwnd, NULL, rgn,
|
2008-04-23 15:32:58 +02:00
|
|
|
RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ALLCHILDREN );
|
|
|
|
}
|
2012-09-24 14:06:42 +02:00
|
|
|
else RedrawWindow( hwnd, NULL, rgn, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
|
2008-04-23 15:32:58 +02:00
|
|
|
DeleteObject( rgn );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-12 15:41:45 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* get_dummy_parent
|
|
|
|
*
|
|
|
|
* Create a dummy parent window for child windows that don't have a true X11 parent.
|
|
|
|
*/
|
|
|
|
static Window get_dummy_parent(void)
|
|
|
|
{
|
|
|
|
static Window dummy_parent;
|
|
|
|
|
|
|
|
if (!dummy_parent)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attrib;
|
|
|
|
|
|
|
|
attrib.override_redirect = True;
|
|
|
|
attrib.border_pixel = 0;
|
|
|
|
attrib.colormap = default_colormap;
|
|
|
|
dummy_parent = XCreateWindow( gdi_display, root_window, -1, -1, 1, 1, 0, default_visual.depth,
|
|
|
|
InputOutput, default_visual.visual,
|
|
|
|
CWColormap | CWBorderPixel | CWOverrideRedirect, &attrib );
|
|
|
|
XMapWindow( gdi_display, dummy_parent );
|
|
|
|
}
|
|
|
|
return dummy_parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-23 13:35:30 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* create_client_window
|
|
|
|
*/
|
2018-02-12 15:49:23 +01:00
|
|
|
Window create_client_window( HWND hwnd, const XVisualInfo *visual )
|
2013-01-23 13:35:30 +01:00
|
|
|
{
|
2018-02-12 15:41:45 +01:00
|
|
|
Window dummy_parent = get_dummy_parent();
|
2018-02-12 15:49:23 +01:00
|
|
|
struct x11drv_win_data *data = get_win_data( hwnd );
|
2013-01-23 13:35:30 +01:00
|
|
|
XSetWindowAttributes attr;
|
2018-02-12 15:49:23 +01:00
|
|
|
Window ret;
|
|
|
|
int x, y, cx, cy;
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
/* explicitly create data for HWND_MESSAGE windows since they can be used for OpenGL */
|
|
|
|
HWND parent = GetAncestor( hwnd, GA_PARENT );
|
|
|
|
if (parent == GetDesktopWindow() || GetAncestor( parent, GA_PARENT )) return 0;
|
|
|
|
if (!(data = alloc_win_data( thread_init_display(), hwnd ))) return 0;
|
|
|
|
GetClientRect( hwnd, &data->client_rect );
|
|
|
|
data->window_rect = data->whole_rect = data->client_rect;
|
|
|
|
}
|
2013-01-23 13:35:30 +01:00
|
|
|
|
2014-03-11 00:23:13 +01:00
|
|
|
if (data->client_window)
|
|
|
|
{
|
|
|
|
XDeleteContext( data->display, data->client_window, winContext );
|
2018-02-12 15:41:45 +01:00
|
|
|
XReparentWindow( gdi_display, data->client_window, dummy_parent, 0, 0 );
|
|
|
|
TRACE( "%p reparent xwin %lx/%lx\n", data->hwnd, data->whole_window, data->client_window );
|
2014-03-11 00:23:13 +01:00
|
|
|
}
|
|
|
|
|
2019-09-19 04:44:19 +02:00
|
|
|
if (data->client_colormap) XFreeColormap( gdi_display, data->client_colormap );
|
|
|
|
data->client_colormap = XCreateColormap( gdi_display, dummy_parent, visual->visual,
|
|
|
|
(visual->class == PseudoColor ||
|
|
|
|
visual->class == GrayScale ||
|
|
|
|
visual->class == DirectColor) ? AllocAll : AllocNone );
|
|
|
|
attr.colormap = data->client_colormap;
|
2013-01-23 13:35:30 +01:00
|
|
|
attr.bit_gravity = NorthWestGravity;
|
|
|
|
attr.win_gravity = NorthWestGravity;
|
|
|
|
attr.backing_store = NotUseful;
|
2013-03-04 13:34:06 +01:00
|
|
|
attr.border_pixel = 0;
|
2013-01-23 13:35:30 +01:00
|
|
|
|
2018-02-12 15:49:23 +01:00
|
|
|
x = data->client_rect.left - data->whole_rect.left;
|
|
|
|
y = data->client_rect.top - data->whole_rect.top;
|
|
|
|
cx = min( max( 1, data->client_rect.right - data->client_rect.left ), 65535 );
|
|
|
|
cy = min( max( 1, data->client_rect.bottom - data->client_rect.top ), 65535 );
|
|
|
|
|
|
|
|
ret = data->client_window = XCreateWindow( gdi_display,
|
|
|
|
data->whole_window ? data->whole_window : dummy_parent,
|
|
|
|
x, y, cx, cy, 0, default_visual.depth, InputOutput,
|
|
|
|
visual->visual, CWBitGravity | CWWinGravity |
|
|
|
|
CWBackingStore | CWColormap | CWBorderPixel, &attr );
|
|
|
|
if (data->client_window)
|
|
|
|
{
|
|
|
|
XSaveContext( data->display, data->client_window, winContext, (char *)data->hwnd );
|
|
|
|
XMapWindow( gdi_display, data->client_window );
|
|
|
|
XSync( gdi_display, False );
|
|
|
|
if (data->whole_window) XSelectInput( data->display, data->client_window, ExposureMask );
|
|
|
|
TRACE( "%p xwin %lx/%lx\n", data->hwnd, data->whole_window, data->client_window );
|
|
|
|
}
|
|
|
|
release_win_data( data );
|
|
|
|
return ret;
|
2013-01-23 13:35:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 23:55:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* create_whole_window
|
|
|
|
*
|
|
|
|
* Create the whole X window for a given window
|
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
static void create_whole_window( 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;
|
2013-10-14 14:20:08 +02:00
|
|
|
POINT pos;
|
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;
|
|
|
|
}
|
|
|
|
|
2012-09-21 12:45:35 +02:00
|
|
|
if ((win_rgn = CreateRectRgn( 0, 0, 0, 0 )) && GetWindowRgn( data->hwnd, win_rgn ) == ERROR)
|
2010-02-01 22:35:32 +01:00
|
|
|
{
|
|
|
|
DeleteObject( win_rgn );
|
|
|
|
win_rgn = 0;
|
|
|
|
}
|
|
|
|
data->shaped = (win_rgn != 0);
|
|
|
|
|
2012-09-26 12:19:37 +02:00
|
|
|
if (data->vis.visualid != default_visual.visualid)
|
2019-09-19 04:44:19 +02:00
|
|
|
data->whole_colormap = XCreateColormap( data->display, root_window, data->vis.visual, AllocNone );
|
2012-09-26 12:19:37 +02:00
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
mask = get_window_attributes( data, &attr );
|
2001-06-12 06:02:10 +02:00
|
|
|
|
2009-06-25 12:10:44 +02:00
|
|
|
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;
|
|
|
|
|
2013-10-14 14:20:08 +02:00
|
|
|
pos = virtual_screen_to_root( data->whole_rect.left, data->whole_rect.top );
|
2015-11-23 09:16:03 +01:00
|
|
|
data->whole_window = XCreateWindow( data->display, root_window, pos.x, pos.y,
|
2012-09-26 12:19:37 +02:00
|
|
|
cx, cy, 0, data->vis.depth, InputOutput,
|
|
|
|
data->vis.visual, mask, &attr );
|
2010-02-01 22:35:32 +01:00
|
|
|
if (!data->whole_window) goto done;
|
2008-02-21 12:29:36 +01:00
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
set_initial_wm_hints( data->display, data->whole_window );
|
|
|
|
set_wm_hints( data );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
XSaveContext( data->display, data->whole_window, winContext, (char *)data->hwnd );
|
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 */
|
2018-09-19 21:01:10 +02:00
|
|
|
if (!InternalGetWindowText( data->hwnd, text, ARRAY_SIZE( text ))) text[0] = 0;
|
2012-09-21 16:29:24 +02:00
|
|
|
sync_window_text( data->display, data->whole_window, text );
|
2008-01-23 16:32:55 +01:00
|
|
|
|
2008-01-23 16:30:18 +01:00
|
|
|
/* set the window region */
|
2012-09-21 16:29:24 +02:00
|
|
|
if (win_rgn || IsRectEmpty( &data->window_rect )) sync_window_region( 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;
|
2012-09-21 16:29:24 +02:00
|
|
|
sync_window_opacity( data->display, data->whole_window, key, alpha, layered_flags );
|
2008-09-12 15:54:02 +02:00
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
XFlush( data->display ); /* make sure the window exists before we start painting to it */
|
2010-05-10 12:33:59 +02:00
|
|
|
|
2011-04-06 12:35:11 +02:00
|
|
|
sync_window_cursor( data->whole_window );
|
2011-02-23 21:46:08 +01:00
|
|
|
|
2010-02-01 22:35:32 +01:00
|
|
|
done:
|
|
|
|
if (win_rgn) DeleteObject( win_rgn );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
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
|
|
|
*/
|
2012-09-21 16:29:24 +02:00
|
|
|
static void destroy_whole_window( struct x11drv_win_data *data, BOOL already_destroyed )
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2018-02-12 15:49:23 +01:00
|
|
|
TRACE( "win %p xwin %lx/%lx\n", data->hwnd, data->whole_window, data->client_window );
|
|
|
|
|
|
|
|
if (data->client_window) XDeleteContext( data->display, data->client_window, winContext );
|
|
|
|
|
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)
|
|
|
|
{
|
2012-09-21 16:29:24 +02:00
|
|
|
if (!already_destroyed) XSelectInput( data->display, xwin, 0 );
|
|
|
|
XDeleteContext( data->display, xwin, winContext );
|
2010-11-15 20:41:07 +01:00
|
|
|
RemovePropA( data->hwnd, foreign_window_prop );
|
|
|
|
}
|
2018-02-12 15:49:23 +01:00
|
|
|
return;
|
2010-11-15 20:41:07 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-12 15:49:23 +01:00
|
|
|
else
|
2018-02-12 15:41:45 +01:00
|
|
|
{
|
2018-02-12 15:49:23 +01:00
|
|
|
if (data->client_window && !already_destroyed)
|
2018-02-12 15:41:45 +01:00
|
|
|
{
|
|
|
|
XSelectInput( data->display, data->client_window, 0 );
|
|
|
|
XReparentWindow( data->display, data->client_window, get_dummy_parent(), 0, 0 );
|
2018-02-12 15:49:23 +01:00
|
|
|
XSync( data->display, False );
|
2018-02-12 15:41:45 +01:00
|
|
|
}
|
2018-02-12 15:49:23 +01:00
|
|
|
XDeleteContext( data->display, data->whole_window, winContext );
|
|
|
|
if (!already_destroyed) XDestroyWindow( data->display, data->whole_window );
|
2018-02-12 15:41:45 +01:00
|
|
|
}
|
2019-09-19 04:44:19 +02:00
|
|
|
if (data->whole_colormap) XFreeColormap( data->display, data->whole_colormap );
|
2013-01-23 13:35:30 +01:00
|
|
|
data->whole_window = data->client_window = 0;
|
2019-09-19 04:44:19 +02:00
|
|
|
data->whole_colormap = 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 */
|
2012-09-21 16:29:24 +02:00
|
|
|
XFlush( data->display );
|
2012-09-06 12:39:34 +02:00
|
|
|
if (data->surface) window_surface_release( data->surface );
|
|
|
|
data->surface = NULL;
|
2005-07-07 19:30:57 +02:00
|
|
|
RemovePropA( data->hwnd, whole_window_prop );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-26 13:12:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* set_window_visual
|
|
|
|
*
|
|
|
|
* Change the visual by destroying and recreating the X window if needed.
|
|
|
|
*/
|
2018-01-26 13:39:03 +01:00
|
|
|
void set_window_visual( struct x11drv_win_data *data, const XVisualInfo *vis, BOOL use_alpha )
|
2012-09-26 13:12:17 +02:00
|
|
|
{
|
2013-02-13 14:51:00 +01:00
|
|
|
Window client_window = data->client_window;
|
|
|
|
Window whole_window = data->whole_window;
|
|
|
|
|
2018-01-26 13:39:03 +01:00
|
|
|
if (!data->use_alpha == !use_alpha) return;
|
|
|
|
if (data->surface) window_surface_release( data->surface );
|
|
|
|
data->surface = NULL;
|
|
|
|
data->use_alpha = use_alpha;
|
|
|
|
|
2012-09-26 13:12:17 +02:00
|
|
|
if (data->vis.visualid == vis->visualid) return;
|
2013-02-13 14:51:00 +01:00
|
|
|
data->client_window = 0;
|
|
|
|
destroy_whole_window( data, client_window != 0 /* don't destroy whole_window until reparented */ );
|
2012-09-26 13:12:17 +02:00
|
|
|
data->vis = *vis;
|
|
|
|
create_whole_window( data );
|
2013-02-13 14:51:00 +01:00
|
|
|
if (!client_window) return;
|
|
|
|
/* move the client to the new parent */
|
|
|
|
XReparentWindow( data->display, client_window, data->whole_window,
|
|
|
|
data->client_rect.left - data->whole_rect.left,
|
|
|
|
data->client_rect.top - data->whole_rect.top );
|
|
|
|
data->client_window = client_window;
|
|
|
|
XDestroyWindow( data->display, whole_window );
|
2012-09-26 13:12:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2012-09-24 14:08:33 +02:00
|
|
|
struct x11drv_win_data *data;
|
|
|
|
DWORD changed = style->styleNew ^ style->styleOld;
|
2008-04-23 15:32:58 +02:00
|
|
|
|
|
|
|
if (hwnd == GetDesktopWindow()) return;
|
2012-09-24 14:08:33 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
|
|
|
if (!data->whole_window) goto done;
|
2012-08-29 18:08:37 +02:00
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
if (offset == GWL_STYLE && (changed & WS_DISABLED)) set_wm_hints( 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 */
|
2012-09-12 16:00:18 +02:00
|
|
|
{
|
2012-10-29 14:37:56 +01:00
|
|
|
data->layered = FALSE;
|
2018-01-26 13:39:03 +01:00
|
|
|
set_window_visual( data, &default_visual, FALSE );
|
2012-09-21 16:29:24 +02:00
|
|
|
sync_window_opacity( data->display, data->whole_window, 0, 0, 0 );
|
2012-09-12 16:00:18 +02:00
|
|
|
if (data->surface) set_surface_color_key( data->surface, CLR_INVALID );
|
|
|
|
}
|
2012-09-24 14:08:33 +02:00
|
|
|
done:
|
|
|
|
release_win_data( data );
|
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
|
|
|
|
2012-09-17 13:03:52 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
destroy_whole_window( data, FALSE );
|
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;
|
2012-05-15 20:58:39 +02:00
|
|
|
if (data->icon_pixmap) XFreePixmap( gdi_display, data->icon_pixmap );
|
|
|
|
if (data->icon_mask) XFreePixmap( gdi_display, data->icon_mask );
|
2019-09-19 04:44:19 +02:00
|
|
|
if (data->client_colormap) XFreeColormap( data->display, data->client_colormap );
|
2012-09-21 11:52:29 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, data->icon_bits );
|
2012-09-17 13:03:52 +02:00
|
|
|
XDeleteContext( gdi_display, (XID)hwnd, win_data_context );
|
|
|
|
release_win_data( data );
|
2001-04-25 01:28:52 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
2018-02-12 15:41:45 +01:00
|
|
|
destroy_gl_drawable( hwnd );
|
2018-06-13 22:08:20 +02:00
|
|
|
wine_vk_surface_destroy( hwnd );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-05 16:51:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_DestroyNotify
|
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
BOOL X11DRV_DestroyNotify( HWND hwnd, XEvent *event )
|
2008-03-05 16:51:09 +01:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
2012-09-17 13:03:52 +02:00
|
|
|
BOOL embedded;
|
2008-03-05 16:51:09 +01:00
|
|
|
|
2016-08-23 15:13:26 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return FALSE;
|
2012-09-17 13:03:52 +02:00
|
|
|
embedded = data->embedded;
|
|
|
|
if (!embedded) FIXME( "window %p/%lx destroyed from the outside\n", hwnd, data->whole_window );
|
2010-11-08 15:28:09 +01:00
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
destroy_whole_window( data, TRUE );
|
2012-09-17 13:03:52 +02:00
|
|
|
release_win_data( data );
|
|
|
|
if (embedded) SendMessageW( hwnd, WM_CLOSE, 0, 0 );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2008-03-05 16:51:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-17 19:53:59 +01:00
|
|
|
/* initialize the desktop window id in the desktop manager process */
|
2013-10-16 12:13:50 +02:00
|
|
|
BOOL create_desktop_win_data( Window win )
|
2006-03-27 22:43:03 +02:00
|
|
|
{
|
2013-10-16 12:13:50 +02:00
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
|
|
|
Display *display = thread_data->display;
|
2008-01-24 10:20:11 +01:00
|
|
|
struct x11drv_win_data *data;
|
2006-03-27 22:43:03 +02:00
|
|
|
|
2013-10-16 12:13:50 +02:00
|
|
|
if (!(data = alloc_win_data( display, GetDesktopWindow() ))) return FALSE;
|
|
|
|
data->whole_window = win;
|
2008-01-24 10:20:11 +01:00
|
|
|
data->managed = TRUE;
|
2013-10-16 12:13:50 +02:00
|
|
|
SetPropA( data->hwnd, whole_window_prop, (HANDLE)win );
|
|
|
|
set_initial_wm_hints( display, win );
|
2012-09-17 13:03:52 +02:00
|
|
|
release_win_data( data );
|
2013-10-16 12:13:50 +02:00
|
|
|
if (thread_data->clip_window) XReparentWindow( display, thread_data->clip_window, win, 0, 0 );
|
2012-09-17 13:03:52 +02:00
|
|
|
return TRUE;
|
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 */
|
|
|
|
{
|
2013-10-14 14:38:58 +02:00
|
|
|
RECT rect = get_virtual_screen_rect();
|
|
|
|
|
2008-01-17 19:53:59 +01:00
|
|
|
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;
|
2012-10-09 11:32:38 +02:00
|
|
|
req->swp_flags = SWP_NOZORDER;
|
2013-10-14 14:38:58 +02:00
|
|
|
req->window.left = rect.left;
|
|
|
|
req->window.top = rect.top;
|
|
|
|
req->window.right = rect.right;
|
|
|
|
req->window.bottom = rect.bottom;
|
2008-01-17 19:53:59 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-04 17:16:41 +02:00
|
|
|
static WNDPROC desktop_orig_wndproc;
|
|
|
|
|
|
|
|
#define WM_WINE_NOTIFY_ACTIVITY WM_USER
|
|
|
|
|
|
|
|
static LRESULT CALLBACK desktop_wndproc_wrapper( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_WINE_NOTIFY_ACTIVITY:
|
2019-09-17 15:09:36 +02:00
|
|
|
{
|
|
|
|
static ULONGLONG last = 0;
|
|
|
|
ULONGLONG now = GetTickCount64();
|
|
|
|
/* calling XResetScreenSaver too often can cause performance
|
|
|
|
* problems, so throttle it */
|
|
|
|
if (now > last + 5000)
|
|
|
|
{
|
|
|
|
XResetScreenSaver( gdi_display );
|
|
|
|
XFlush( gdi_display );
|
|
|
|
last = now;
|
|
|
|
}
|
2018-07-04 17:16:41 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-09-17 15:09:36 +02:00
|
|
|
}
|
2018-07-04 17:16:41 +02:00
|
|
|
return desktop_orig_wndproc( hwnd, msg, wp, lp );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2011-04-05 11:50:45 +02:00
|
|
|
if (hwnd == GetDesktopWindow())
|
2008-01-24 10:20:11 +01:00
|
|
|
{
|
2011-04-14 12:04:45 +02:00
|
|
|
struct x11drv_thread_data *data = x11drv_init_thread_data();
|
2011-04-05 11:50:45 +02:00
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
2018-07-04 17:16:41 +02:00
|
|
|
desktop_orig_wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)desktop_wndproc_wrapper );
|
|
|
|
|
2011-04-05 11:50:45 +02:00
|
|
|
/* create the cursor clipping window */
|
|
|
|
attr.override_redirect = TRUE;
|
2011-04-25 10:49:49 +02:00
|
|
|
attr.event_mask = StructureNotifyMask | FocusChangeMask;
|
2011-04-14 12:04:45 +02:00
|
|
|
data->clip_window = XCreateWindow( data->display, root_window, 0, 0, 1, 1, 0, 0,
|
2012-09-25 15:51:03 +02:00
|
|
|
InputOnly, default_visual.visual,
|
|
|
|
CWOverrideRedirect | CWEventMask, &attr );
|
2012-02-13 20:52:03 +01:00
|
|
|
XFlush( data->display );
|
2011-04-14 12:04:45 +02:00
|
|
|
SetPropA( hwnd, clip_window_prop, (HANDLE)data->clip_window );
|
2016-09-26 13:27:40 +02:00
|
|
|
X11DRV_InitClipboard();
|
2019-11-01 14:20:21 +01:00
|
|
|
X11DRV_DisplayDevices_RegisterEventHandlers();
|
2006-03-27 22:43:03 +02:00
|
|
|
}
|
2001-06-04 23:55:17 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-17 13:03:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_win_data
|
|
|
|
*
|
|
|
|
* Lock and return the X11 data structure associated with a window.
|
|
|
|
*/
|
|
|
|
struct x11drv_win_data *get_win_data( HWND hwnd )
|
|
|
|
{
|
|
|
|
char *data;
|
|
|
|
|
|
|
|
if (!hwnd) return NULL;
|
|
|
|
EnterCriticalSection( &win_data_section );
|
|
|
|
if (!XFindContext( gdi_display, (XID)hwnd, win_data_context, &data ))
|
|
|
|
return (struct x11drv_win_data *)data;
|
|
|
|
LeaveCriticalSection( &win_data_section );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* release_win_data
|
|
|
|
*
|
|
|
|
* Release the data returned by get_win_data.
|
|
|
|
*/
|
|
|
|
void release_win_data( struct x11drv_win_data *data )
|
|
|
|
{
|
|
|
|
if (data) LeaveCriticalSection( &win_data_section );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-24 10:20:51 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_create_win_data
|
|
|
|
*
|
|
|
|
* Create an X11 data window structure for an existing window.
|
|
|
|
*/
|
2012-09-04 13:34:15 +02:00
|
|
|
static struct x11drv_win_data *X11DRV_create_win_data( HWND hwnd, const RECT *window_rect,
|
|
|
|
const RECT *client_rect )
|
2008-01-24 10:20:51 +01:00
|
|
|
{
|
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;
|
|
|
|
|
2012-09-17 13:03:52 +02:00
|
|
|
if (GetWindowThreadProcessId( hwnd, NULL ) != GetCurrentThreadId()) return NULL;
|
|
|
|
|
2019-04-10 21:04:18 +02:00
|
|
|
/* Recreate the parent gl_drawable now that we know there are child windows
|
|
|
|
* that will need clipping support.
|
|
|
|
*/
|
|
|
|
sync_gl_drawable( parent, TRUE );
|
|
|
|
|
2008-06-26 16:47:42 +02:00
|
|
|
display = thread_init_display();
|
2012-09-21 12:45:35 +02:00
|
|
|
init_clip_window(); /* make sure the clip window is initialized in this thread */
|
|
|
|
|
2008-01-24 10:20:51 +01:00
|
|
|
if (!(data = alloc_win_data( display, hwnd ))) return NULL;
|
|
|
|
|
2012-09-04 13:34:15 +02:00
|
|
|
data->whole_rect = data->window_rect = *window_rect;
|
|
|
|
data->client_rect = *client_rect;
|
2008-01-24 10:20:51 +01:00
|
|
|
if (parent == GetDesktopWindow())
|
|
|
|
{
|
2012-09-21 16:29:24 +02:00
|
|
|
create_whole_window( data );
|
2012-08-30 18:17:05 +02:00
|
|
|
TRACE( "win %p/%lx window %s whole %s client %s\n",
|
|
|
|
hwnd, data->whole_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;
|
2013-10-14 14:20:08 +02:00
|
|
|
POINT pos;
|
2010-11-08 15:28:09 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (XFindContext( display, xwin, winContext, (char **)&hwnd )) hwnd = 0;
|
2012-08-14 13:38:03 +02:00
|
|
|
if (hwnd) return hwnd; /* already created */
|
2010-11-08 15:28:09 +01:00
|
|
|
|
|
|
|
XSelectInput( display, xwin, StructureNotifyMask );
|
|
|
|
if (!XGetWindowAttributes( display, xwin, &attr ) ||
|
|
|
|
!XQueryTree( display, xwin, &xroot, &xparent, &xchildren, &nchildren ))
|
|
|
|
{
|
|
|
|
XSelectInput( display, xwin, 0 );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
XFree( xchildren );
|
|
|
|
|
|
|
|
if (xparent == xroot)
|
|
|
|
{
|
|
|
|
parent = GetDesktopWindow();
|
|
|
|
style |= WS_POPUP;
|
2013-10-14 14:20:08 +02:00
|
|
|
pos = root_to_virtual_screen( attr.x, attr.y );
|
2010-11-08 15:28:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parent = create_foreign_window( display, xparent );
|
|
|
|
style |= WS_CHILD;
|
2013-10-14 14:20:08 +02:00
|
|
|
pos.x = attr.x;
|
|
|
|
pos.y = attr.y;
|
2010-11-08 15:28:09 +01:00
|
|
|
}
|
|
|
|
|
2013-10-14 14:20:08 +02:00
|
|
|
hwnd = CreateWindowW( classW, NULL, style, pos.x, pos.y, attr.width, attr.height,
|
2010-11-08 15:28:09 +01:00
|
|
|
parent, 0, 0, NULL );
|
|
|
|
|
|
|
|
if (!(data = alloc_win_data( display, hwnd )))
|
|
|
|
{
|
|
|
|
DestroyWindow( hwnd );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-10-14 14:20:08 +02:00
|
|
|
SetRect( &data->window_rect, pos.x, pos.y, pos.x + attr.width, pos.y + attr.height );
|
2010-11-08 15:28:09 +01:00
|
|
|
data->whole_rect = data->client_rect = data->window_rect;
|
2013-01-23 13:35:30 +01:00
|
|
|
data->whole_window = data->client_window = 0;
|
2010-11-08 15:28:09 +01:00
|
|
|
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
|
|
|
XSaveContext( display, xwin, winContext, (char *)data->hwnd );
|
|
|
|
|
|
|
|
TRACE( "win %lx parent %p style %08x %s -> hwnd %p\n",
|
|
|
|
xwin, parent, style, wine_dbgstr_rect(&data->window_rect), hwnd );
|
|
|
|
|
2013-09-24 05:50:33 +02:00
|
|
|
release_win_data( data );
|
|
|
|
|
|
|
|
ShowWindow( hwnd, SW_SHOW );
|
2010-11-08 15:28:09 +01:00
|
|
|
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 )
|
|
|
|
{
|
2012-09-17 13:03:52 +02:00
|
|
|
struct x11drv_win_data *data = get_win_data( hwnd );
|
|
|
|
Window ret;
|
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 );
|
|
|
|
}
|
2012-09-17 13:03:52 +02:00
|
|
|
ret = data->whole_window;
|
|
|
|
release_win_data( data );
|
|
|
|
return ret;
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2012-09-17 13:03:52 +02:00
|
|
|
struct x11drv_win_data *data = get_win_data( hwnd );
|
2008-04-04 13:44:36 +02:00
|
|
|
XIM xim;
|
2012-09-17 13:03:52 +02:00
|
|
|
XIC ret = 0;
|
2007-09-15 22:02:32 +02:00
|
|
|
|
2012-09-17 13:03:52 +02:00
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
x11drv_thread_data()->last_xic_hwnd = hwnd;
|
|
|
|
ret = data->xic;
|
|
|
|
if (!ret && (xim = x11drv_thread_data()->xim)) ret = X11DRV_CreateIC( xim, data );
|
|
|
|
release_win_data( data );
|
|
|
|
}
|
|
|
|
return ret;
|
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;
|
2010-11-08 15:46:07 +01:00
|
|
|
HWND parent;
|
2007-09-25 19:20:58 +02:00
|
|
|
|
2014-04-01 04:47:04 +02:00
|
|
|
escape.code = X11DRV_SET_DRAWABLE;
|
|
|
|
escape.mode = IncludeInferiors;
|
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;
|
|
|
|
|
2010-04-11 21:47:49 +02:00
|
|
|
if (top == hwnd)
|
2008-02-25 15:59:19 +01:00
|
|
|
{
|
2012-09-24 14:09:43 +02:00
|
|
|
struct x11drv_win_data *data = get_win_data( hwnd );
|
|
|
|
|
2012-09-04 17:14:46 +02:00
|
|
|
escape.drawable = data ? data->whole_window : X11DRV_get_whole_window( hwnd );
|
2011-04-22 12:16:33 +02:00
|
|
|
|
|
|
|
/* special case: when repainting the root window, clip out top-level windows */
|
|
|
|
if (data && data->whole_window == root_window) escape.mode = ClipByChildren;
|
2012-09-24 14:09:43 +02:00
|
|
|
release_win_data( data );
|
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 ))
|
2012-08-30 14:40:31 +02:00
|
|
|
if ((escape.drawable = X11DRV_get_whole_window( parent ))) break;
|
2010-11-08 15:46:07 +01:00
|
|
|
|
|
|
|
if (escape.drawable)
|
|
|
|
{
|
|
|
|
POINT pt = { 0, 0 };
|
2012-08-30 14:40:31 +02:00
|
|
|
MapWindowPoints( 0, parent, &pt, 1 );
|
|
|
|
escape.dc_rect = *win_rect;
|
2010-11-08 15:46:07 +01:00
|
|
|
OffsetRect( &escape.dc_rect, pt.x, pt.y );
|
2012-08-30 14:40:31 +02:00
|
|
|
if (flags & DCX_CLIPCHILDREN) escape.mode = ClipByChildren;
|
2010-11-08 15:46:07 +01:00
|
|
|
}
|
2012-08-30 14:40:31 +02:00
|
|
|
else escape.drawable = X11DRV_get_whole_window( top );
|
2012-08-30 17:46:33 +02:00
|
|
|
}
|
2010-11-08 15:46:07 +01: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;
|
2013-10-14 14:38:58 +02:00
|
|
|
escape.dc_rect = get_virtual_screen_rect();
|
|
|
|
OffsetRect( &escape.dc_rect, -2 * escape.dc_rect.left, -2 * escape.dc_rect.top );
|
2008-02-25 15:59:19 +01:00
|
|
|
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
|
2003-01-23 02:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-19 12:27:59 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* ScrollDC (X11DRV.@)
|
|
|
|
*/
|
|
|
|
BOOL CDECL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, HRGN update )
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
BOOL ret;
|
|
|
|
HRGN expose_rgn = 0;
|
|
|
|
|
|
|
|
GetClipBox( hdc, &rect );
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
{
|
|
|
|
INT code = X11DRV_START_EXPOSURES;
|
|
|
|
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL );
|
|
|
|
|
|
|
|
ret = BitBlt( hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
|
|
|
|
hdc, rect.left - dx, rect.top - dy, SRCCOPY );
|
|
|
|
|
|
|
|
code = X11DRV_END_EXPOSURES;
|
|
|
|
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code,
|
|
|
|
sizeof(expose_rgn), (LPSTR)&expose_rgn );
|
|
|
|
if (expose_rgn)
|
|
|
|
{
|
|
|
|
CombineRgn( update, update, expose_rgn, RGN_OR );
|
|
|
|
DeleteObject( expose_rgn );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else ret = BitBlt( hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
|
|
|
|
hdc, rect.left - dx, rect.top - dy, SRCCOPY );
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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();
|
2016-03-10 14:03:02 +01:00
|
|
|
struct x11drv_win_data *data;
|
2008-03-12 15:01:24 +01:00
|
|
|
|
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)
|
|
|
|
{
|
2016-03-10 14:03:02 +01:00
|
|
|
if (!(data = get_win_data( GetAncestor( hwnd, GA_ROOT )))) return;
|
|
|
|
if (data->whole_window)
|
|
|
|
{
|
|
|
|
XFlush( gdi_display );
|
|
|
|
XGrabPointer( data->display, data->whole_window, False,
|
|
|
|
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
|
|
|
|
GrabModeAsync, GrabModeAsync, None, None, CurrentTime );
|
|
|
|
thread_data->grab_hwnd = data->hwnd;
|
|
|
|
}
|
|
|
|
release_win_data( data );
|
2008-03-12 15:01:24 +01:00
|
|
|
}
|
|
|
|
else /* release capture */
|
|
|
|
{
|
2016-03-10 14:03:02 +01:00
|
|
|
if (!(data = get_win_data( thread_data->grab_hwnd ))) return;
|
2008-03-12 15:01:24 +01:00
|
|
|
XFlush( gdi_display );
|
2016-03-10 14:03:02 +01:00
|
|
|
XUngrabPointer( data->display, CurrentTime );
|
|
|
|
XFlush( data->display );
|
|
|
|
thread_data->grab_hwnd = NULL;
|
|
|
|
release_win_data( data );
|
2008-03-12 15:01:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2012-09-21 12:45:35 +02:00
|
|
|
struct x11drv_win_data *data;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2006-12-10 23:21:28 +01:00
|
|
|
if (parent == old_parent) return;
|
2012-09-21 12:45:35 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
|
|
|
if (data->embedded) goto done;
|
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 */
|
2012-09-21 16:29:24 +02:00
|
|
|
destroy_whole_window( data, FALSE );
|
2012-10-15 16:19:09 +02:00
|
|
|
data->managed = FALSE;
|
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 */
|
|
|
|
{
|
2012-09-21 16:29:24 +02:00
|
|
|
create_whole_window( data );
|
2006-12-10 23:21:28 +01:00
|
|
|
}
|
2012-09-21 12:45:35 +02:00
|
|
|
done:
|
|
|
|
release_win_data( data );
|
2012-10-10 10:46:16 +02:00
|
|
|
set_gl_drawable_parent( hwnd, parent );
|
2019-04-10 21:04:18 +02:00
|
|
|
|
|
|
|
/* Recreate the parent gl_drawable now that we know there are child windows
|
|
|
|
* that will need clipping support.
|
|
|
|
*/
|
|
|
|
sync_gl_drawable( parent, TRUE );
|
|
|
|
|
2012-09-21 12:45:35 +02:00
|
|
|
fetch_icon_data( hwnd, 0, 0 );
|
2001-04-25 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-22 12:45:35 +01:00
|
|
|
static inline BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rect )
|
2012-09-06 12:39:34 +02:00
|
|
|
{
|
2018-01-22 12:45:35 +01:00
|
|
|
*surface_rect = get_virtual_screen_rect();
|
2012-09-06 12:39:34 +02:00
|
|
|
|
2018-01-22 12:45:35 +01:00
|
|
|
if (!IntersectRect( surface_rect, surface_rect, visible_rect )) return FALSE;
|
|
|
|
OffsetRect( surface_rect, -visible_rect->left, -visible_rect->top );
|
|
|
|
surface_rect->left &= ~31;
|
|
|
|
surface_rect->top &= ~31;
|
|
|
|
surface_rect->right = max( surface_rect->left + 32, (surface_rect->right + 31) & ~31 );
|
|
|
|
surface_rect->bottom = max( surface_rect->top + 32, (surface_rect->bottom + 31) & ~31 );
|
|
|
|
return TRUE;
|
2012-09-06 12:39:34 +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,
|
2012-09-06 12:32:52 +02:00
|
|
|
const RECT *window_rect, const RECT *client_rect, RECT *visible_rect,
|
|
|
|
struct window_surface **surface )
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
2012-09-24 14:06:42 +02:00
|
|
|
struct x11drv_win_data *data = get_win_data( hwnd );
|
2012-09-06 12:39:34 +02:00
|
|
|
RECT surface_rect;
|
2012-09-12 16:00:18 +02:00
|
|
|
DWORD flags;
|
|
|
|
COLORREF key;
|
|
|
|
BOOL layered = GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED;
|
2008-04-23 15:32:58 +02:00
|
|
|
|
2012-09-04 13:34:15 +02:00
|
|
|
if (!data && !(data = X11DRV_create_win_data( hwnd, window_rect, client_rect ))) return;
|
2008-04-23 15:32:58 +02:00
|
|
|
|
|
|
|
/* 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 );
|
2012-09-24 14:06:42 +02:00
|
|
|
release_win_data( data );
|
|
|
|
unmap_window( hwnd );
|
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
2008-04-23 15:32:58 +02:00
|
|
|
data->managed = TRUE;
|
|
|
|
}
|
|
|
|
|
2008-07-02 15:40:10 +02:00
|
|
|
*visible_rect = *window_rect;
|
2020-03-18 14:46:07 +01:00
|
|
|
X11DRV_window_to_X_rect( data, visible_rect, window_rect, client_rect );
|
2012-09-06 12:39:34 +02:00
|
|
|
|
|
|
|
/* create the window surface if necessary */
|
2012-10-01 13:09:27 +02:00
|
|
|
|
2012-10-21 12:18:16 +02:00
|
|
|
if (!data->whole_window && !data->embedded) goto done;
|
2012-09-24 14:06:42 +02:00
|
|
|
if (swp_flags & SWP_HIDEWINDOW) goto done;
|
2018-01-26 13:39:03 +01:00
|
|
|
if (data->use_alpha) goto done;
|
2018-01-22 12:45:35 +01:00
|
|
|
if (!get_surface_rect( visible_rect, &surface_rect )) goto done;
|
2012-10-01 13:09:27 +02:00
|
|
|
|
|
|
|
if (*surface) window_surface_release( *surface );
|
|
|
|
*surface = NULL; /* indicate that we want to draw directly to the window */
|
|
|
|
|
|
|
|
if (data->embedded) goto done;
|
2012-09-24 14:06:42 +02:00
|
|
|
if (data->whole_window == root_window) goto done;
|
2013-06-11 18:07:07 +02:00
|
|
|
if (data->client_window) goto done;
|
2012-09-24 14:06:42 +02:00
|
|
|
if (!client_side_graphics && !layered) goto done;
|
2012-09-06 12:39:34 +02:00
|
|
|
|
|
|
|
if (data->surface)
|
|
|
|
{
|
2016-10-13 17:05:08 +02:00
|
|
|
if (EqualRect( &data->surface->rect, &surface_rect ))
|
2012-09-06 12:39:34 +02:00
|
|
|
{
|
|
|
|
/* existing surface is good enough */
|
|
|
|
window_surface_add_ref( data->surface );
|
|
|
|
*surface = data->surface;
|
2012-09-24 14:06:42 +02:00
|
|
|
goto done;
|
2012-09-06 12:39:34 +02:00
|
|
|
}
|
|
|
|
}
|
2012-09-24 14:06:42 +02:00
|
|
|
else if (!(swp_flags & SWP_SHOWWINDOW) && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) goto done;
|
2012-09-06 12:39:34 +02:00
|
|
|
|
2012-09-12 16:00:18 +02:00
|
|
|
if (!layered || !GetLayeredWindowAttributes( hwnd, &key, NULL, &flags ) || !(flags & LWA_COLORKEY))
|
|
|
|
key = CLR_INVALID;
|
|
|
|
|
2012-09-27 20:47:08 +02:00
|
|
|
*surface = create_surface( data->whole_window, &data->vis, &surface_rect, key, FALSE );
|
2012-09-24 14:06:42 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
release_win_data( data );
|
2008-07-02 15:40:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* 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,
|
2012-09-06 12:32:52 +02:00
|
|
|
const RECT *visible_rect, const RECT *valid_rects,
|
|
|
|
struct window_surface *surface )
|
2008-07-02 15:40:10 +02:00
|
|
|
{
|
|
|
|
struct x11drv_thread_data *thread_data;
|
2012-09-24 14:06:42 +02:00
|
|
|
struct x11drv_win_data *data;
|
2008-07-02 15:40:10 +02:00
|
|
|
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;
|
|
|
|
|
2012-09-24 14:06:42 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
2008-07-02 15:40:10 +02:00
|
|
|
|
|
|
|
thread_data = x11drv_thread_data();
|
|
|
|
|
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;
|
2012-09-26 13:12:17 +02:00
|
|
|
if (data->vis.visualid == default_visual.visualid)
|
|
|
|
{
|
|
|
|
if (surface) window_surface_add_ref( surface );
|
|
|
|
if (data->surface) window_surface_release( data->surface );
|
|
|
|
data->surface = surface;
|
|
|
|
}
|
2008-04-23 15:32:58 +02:00
|
|
|
|
|
|
|
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] ))
|
|
|
|
{
|
2012-09-24 14:06:42 +02:00
|
|
|
Window window = data->whole_window;
|
2008-04-23 15:32:58 +02:00
|
|
|
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 &&
|
2016-10-13 17:05:08 +02:00
|
|
|
EqualRect( &valid_rects[0], &data->client_rect ))
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
|
|
|
/* if we have an X window the bits will be moved by the X server */
|
2012-09-24 14:06:42 +02:00
|
|
|
if (!window && (x_offset != 0 || y_offset != 0))
|
|
|
|
{
|
|
|
|
release_win_data( data );
|
|
|
|
move_window_bits( hwnd, window, &old_whole_rect, visible_rect,
|
|
|
|
&old_client_rect, rectClient, rectWindow );
|
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
|
|
|
}
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
else
|
2012-09-24 14:06:42 +02:00
|
|
|
{
|
|
|
|
release_win_data( data );
|
|
|
|
move_window_bits( hwnd, window, &valid_rects[1], &valid_rects[0],
|
|
|
|
&old_client_rect, rectClient, rectWindow );
|
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
|
|
|
}
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
XFlush( gdi_display ); /* make sure painting is done before we move the window */
|
|
|
|
|
2013-01-23 13:35:30 +01:00
|
|
|
sync_client_position( data, &old_client_rect, &old_whole_rect );
|
2008-04-23 15:32:58 +02:00
|
|
|
|
2013-01-23 13:35:30 +01:00
|
|
|
if (!data->whole_window)
|
|
|
|
{
|
2018-02-12 15:49:23 +01:00
|
|
|
BOOL needs_resize = (!data->client_window &&
|
|
|
|
(data->client_rect.right - data->client_rect.left !=
|
|
|
|
old_client_rect.right - old_client_rect.left ||
|
|
|
|
data->client_rect.bottom - data->client_rect.top !=
|
|
|
|
old_client_rect.bottom - old_client_rect.top));
|
2013-01-23 13:35:30 +01:00
|
|
|
release_win_data( data );
|
2019-04-10 21:04:18 +02:00
|
|
|
if (needs_resize) sync_gl_drawable( hwnd, FALSE );
|
2013-01-23 13:35:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-04-23 15:32:58 +02:00
|
|
|
|
|
|
|
/* check if we are currently processing an event relevant to this window */
|
|
|
|
event_type = 0;
|
2012-09-24 14:06:42 +02:00
|
|
|
if (thread_data &&
|
|
|
|
thread_data->current_event &&
|
|
|
|
thread_data->current_event->xany.window == data->whole_window)
|
|
|
|
{
|
2008-04-23 15:32:58 +02:00
|
|
|
event_type = thread_data->current_event->type;
|
2012-09-24 14:06:42 +02:00
|
|
|
if (event_type != ConfigureNotify && event_type != PropertyNotify &&
|
|
|
|
event_type != GravityNotify && event_type != ReparentNotify)
|
|
|
|
event_type = 0; /* ignore other events */
|
|
|
|
}
|
2008-04-23 15:32:58 +02:00
|
|
|
|
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)) ||
|
2012-10-15 16:17:22 +02:00
|
|
|
(!event_type && !(new_style & WS_MINIMIZE) &&
|
2010-05-28 12:16:17 +02:00
|
|
|
!is_window_rect_mapped( rectWindow ) && is_window_rect_mapped( &old_window_rect )))
|
2012-01-31 13:45:04 +01:00
|
|
|
{
|
2012-09-24 14:06:42 +02:00
|
|
|
release_win_data( data );
|
2012-09-13 20:08:01 +02:00
|
|
|
unmap_window( hwnd );
|
2020-08-25 09:21:03 +02:00
|
|
|
if (is_window_rect_full_screen( &old_window_rect )) reset_clipping_window();
|
2012-09-24 14:06:42 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
2012-01-31 13:45:04 +01:00
|
|
|
}
|
2008-05-01 17:45:17 +02:00
|
|
|
}
|
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))))
|
2012-09-21 16:29:24 +02:00
|
|
|
sync_window_position( 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)
|
|
|
|
{
|
2012-09-24 14:06:42 +02:00
|
|
|
BOOL needs_icon = !data->icon_pixmap;
|
2012-10-29 14:37:56 +01:00
|
|
|
BOOL needs_map = TRUE;
|
2012-09-24 14:06:42 +02:00
|
|
|
|
2012-10-29 14:37:56 +01:00
|
|
|
/* layered windows are mapped only once their attributes are set */
|
2021-01-04 13:43:39 +01:00
|
|
|
if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED)
|
|
|
|
needs_map = data->layered || IsRectEmpty( rectWindow );
|
2012-09-24 14:06:42 +02:00
|
|
|
release_win_data( data );
|
|
|
|
if (needs_icon) fetch_icon_data( hwnd, 0, 0 );
|
2012-10-29 14:37:56 +01:00
|
|
|
if (needs_map) map_window( hwnd, new_style );
|
2012-09-24 14:06:42 +02:00
|
|
|
return;
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
else if ((swp_flags & SWP_STATECHANGED) && (!data->iconic != !(new_style & WS_MINIMIZE)))
|
|
|
|
{
|
2012-09-21 16:29:24 +02:00
|
|
|
set_wm_hints( data );
|
2008-04-23 15:32:58 +02:00
|
|
|
data->iconic = (new_style & WS_MINIMIZE) != 0;
|
|
|
|
TRACE( "changing win %p iconic state to %u\n", data->hwnd, data->iconic );
|
|
|
|
if (data->iconic)
|
2012-09-26 12:19:37 +02:00
|
|
|
XIconifyWindow( data->display, data->whole_window, data->vis.screen );
|
2008-04-23 15:32:58 +02:00
|
|
|
else if (is_window_rect_mapped( rectWindow ))
|
2012-09-21 16:29:24 +02:00
|
|
|
XMapWindow( data->display, data->whole_window );
|
|
|
|
update_net_wm_states( data );
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
2012-09-21 12:45:35 +02:00
|
|
|
else
|
2008-04-23 15:32:58 +02:00
|
|
|
{
|
2012-09-21 16:29:24 +02:00
|
|
|
if (swp_flags & (SWP_FRAMECHANGED|SWP_STATECHANGED)) set_wm_hints( data );
|
|
|
|
if (!event_type) update_net_wm_states( data );
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
XFlush( data->display ); /* make sure changes are done before we start painting again */
|
2012-09-26 13:12:17 +02:00
|
|
|
if (data->surface && data->vis.visualid != default_visual.visualid)
|
|
|
|
data->surface->funcs->flush( data->surface );
|
|
|
|
|
2012-09-24 14:06:42 +02:00
|
|
|
release_win_data( data );
|
2008-04-23 15:32:58 +02:00
|
|
|
}
|
|
|
|
|
2016-05-31 15:41:37 +02:00
|
|
|
/* check if the window icon should be hidden (i.e. moved off-screen) */
|
|
|
|
static BOOL hide_icon( struct x11drv_win_data *data )
|
|
|
|
{
|
|
|
|
static const WCHAR trayW[] = {'S','h','e','l','l','_','T','r','a','y','W','n','d',0};
|
|
|
|
|
|
|
|
if (data->managed) return TRUE;
|
|
|
|
/* hide icons in desktop mode when the taskbar is active */
|
2019-11-05 14:04:07 +01:00
|
|
|
if (!is_virtual_desktop()) return FALSE;
|
2016-05-31 15:41:37 +02:00
|
|
|
return IsWindowVisible( FindWindowW( trayW, NULL ));
|
|
|
|
}
|
2008-04-23 15:32:58 +02:00
|
|
|
|
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;
|
2013-10-14 14:20:08 +02:00
|
|
|
POINT pos;
|
2008-07-31 11:40:49 +02:00
|
|
|
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
2012-09-24 13:36:35 +02:00
|
|
|
struct x11drv_win_data *data = get_win_data( hwnd );
|
2008-07-31 11:40:49 +02:00
|
|
|
|
2016-05-31 15:41:37 +02:00
|
|
|
if (!data || !data->whole_window) goto done;
|
2012-09-24 13:36:35 +02:00
|
|
|
if (IsRectEmpty( rect )) goto done;
|
2012-10-15 16:17:22 +02:00
|
|
|
if (style & WS_MINIMIZE)
|
|
|
|
{
|
2016-05-31 15:41:37 +02:00
|
|
|
if (((rect->left != -32000 || rect->top != -32000)) && hide_icon( data ))
|
2012-10-15 16:17:22 +02:00
|
|
|
{
|
|
|
|
OffsetRect( rect, -32000 - rect->left, -32000 - rect->top );
|
|
|
|
swp &= ~(SWP_NOMOVE | SWP_NOCLIENTMOVE);
|
|
|
|
}
|
|
|
|
goto done;
|
|
|
|
}
|
2016-05-31 15:41:37 +02:00
|
|
|
if (!data->managed || !data->mapped || data->iconic) goto done;
|
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)
|
2012-09-24 13:36:35 +02:00
|
|
|
goto done;
|
2008-07-31 11:40:49 +02:00
|
|
|
|
|
|
|
if (thread_data->current_event->type != ConfigureNotify &&
|
|
|
|
thread_data->current_event->type != PropertyNotify)
|
2012-09-24 13:36:35 +02:00
|
|
|
goto done;
|
2008-07-31 11:40:49 +02:00
|
|
|
|
|
|
|
TRACE( "win %p/%lx cmd %d at %s flags %08x\n",
|
|
|
|
hwnd, data->whole_window, cmd, wine_dbgstr_rect(rect), swp );
|
|
|
|
|
|
|
|
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 );
|
2013-10-14 14:20:08 +02:00
|
|
|
pos = root_to_virtual_screen( x, y );
|
2018-08-23 10:50:47 +02:00
|
|
|
X11DRV_X_to_window_rect( data, rect, pos.x, pos.y, width, height );
|
2012-09-24 13:36:35 +02:00
|
|
|
swp &= ~(SWP_NOMOVE | SWP_NOCLIENTMOVE | SWP_NOSIZE | SWP_NOCLIENTSIZE);
|
|
|
|
|
|
|
|
done:
|
|
|
|
release_win_data( data );
|
|
|
|
return swp;
|
2008-07-31 11:40:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
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
|
|
|
{
|
2005-01-17 20:17:47 +01:00
|
|
|
struct x11drv_win_data *data;
|
2001-04-25 01:28:52 +02:00
|
|
|
|
2012-09-21 12:45:35 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
|
|
|
if (!data->whole_window) goto done;
|
|
|
|
release_win_data( data ); /* release the lock, fetching the icon requires sending messages */
|
|
|
|
|
2012-09-21 11:52:29 +02:00
|
|
|
if (type == ICON_BIG) fetch_icon_data( hwnd, icon, 0 );
|
|
|
|
else fetch_icon_data( hwnd, 0, icon );
|
2012-09-21 12:45:35 +02:00
|
|
|
|
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
2012-09-21 16:29:24 +02:00
|
|
|
set_wm_hints( data );
|
2012-09-21 12:45:35 +02:00
|
|
|
done:
|
|
|
|
release_win_data( data );
|
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)
|
|
|
|
*/
|
2014-05-01 12:31:14 +02:00
|
|
|
void CDECL X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
|
2008-01-23 16:30:18 +01:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
2012-09-21 15:53:48 +02:00
|
|
|
if ((data = get_win_data( hwnd )))
|
2008-01-23 16:30:18 +01:00
|
|
|
{
|
2012-09-21 16:29:24 +02:00
|
|
|
sync_window_region( data, hrgn );
|
2012-09-21 15:53:48 +02:00
|
|
|
release_win_data( data );
|
2008-01-23 16:30:18 +01:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
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
|
|
|
{
|
2012-09-24 14:09:04 +02:00
|
|
|
struct x11drv_win_data *data = get_win_data( hwnd );
|
2008-09-12 15:54:02 +02:00
|
|
|
|
2008-09-22 12:52:53 +02:00
|
|
|
if (data)
|
|
|
|
{
|
2018-01-26 13:39:03 +01:00
|
|
|
set_window_visual( data, &default_visual, FALSE );
|
2017-04-18 18:43:19 +02:00
|
|
|
|
2008-09-22 12:52:53 +02:00
|
|
|
if (data->whole_window)
|
2012-09-21 16:29:24 +02:00
|
|
|
sync_window_opacity( data->display, data->whole_window, key, alpha, flags );
|
2012-09-12 16:00:18 +02:00
|
|
|
if (data->surface)
|
|
|
|
set_surface_color_key( data->surface, (flags & LWA_COLORKEY) ? key : CLR_INVALID );
|
2012-10-29 14:37:56 +01:00
|
|
|
|
|
|
|
data->layered = TRUE;
|
|
|
|
if (!data->mapped) /* mapping is delayed until attributes are set */
|
|
|
|
{
|
|
|
|
DWORD style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
|
|
|
|
|
|
|
if ((style & WS_VISIBLE) &&
|
|
|
|
((style & WS_MINIMIZE) || is_window_rect_mapped( &data->window_rect )))
|
|
|
|
{
|
|
|
|
release_win_data( data );
|
|
|
|
map_window( hwnd, style );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-09-24 14:09:04 +02:00
|
|
|
release_win_data( data );
|
2008-09-22 12:52:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Window win = X11DRV_get_whole_window( hwnd );
|
2012-09-12 16:00:18 +02:00
|
|
|
if (win)
|
|
|
|
{
|
|
|
|
sync_window_opacity( gdi_display, win, key, alpha, flags );
|
|
|
|
if (flags & LWA_COLORKEY)
|
2012-09-24 14:09:04 +02:00
|
|
|
FIXME( "LWA_COLORKEY not supported on foreign process window %p\n", hwnd );
|
2012-09-12 16:00:18 +02:00
|
|
|
}
|
2008-09-22 12:52:53 +02:00
|
|
|
}
|
2008-09-12 15:54:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-27 18:13:01 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* UpdateLayeredWindow (X11DRV.@)
|
|
|
|
*/
|
|
|
|
BOOL CDECL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
|
|
|
|
const RECT *window_rect )
|
|
|
|
{
|
2012-09-26 13:12:17 +02:00
|
|
|
struct window_surface *surface;
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, 0 };
|
|
|
|
COLORREF color_key = (info->dwFlags & ULW_COLORKEY) ? info->crKey : CLR_INVALID;
|
|
|
|
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *bmi = (BITMAPINFO *)buffer;
|
|
|
|
void *src_bits, *dst_bits;
|
2017-06-27 17:40:36 +02:00
|
|
|
RECT rect, src_rect;
|
2012-09-26 13:12:17 +02:00
|
|
|
HDC hdc = 0;
|
|
|
|
HBITMAP dib;
|
|
|
|
BOOL ret = FALSE;
|
2012-09-27 18:13:01 +02:00
|
|
|
|
2012-09-26 13:12:17 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return FALSE;
|
2012-09-27 18:13:01 +02:00
|
|
|
|
2012-10-29 14:37:56 +01:00
|
|
|
data->layered = TRUE;
|
2018-01-26 13:39:03 +01:00
|
|
|
if (!data->embedded && argb_visual.visualid) set_window_visual( data, &argb_visual, TRUE );
|
2012-09-27 18:13:01 +02:00
|
|
|
|
2012-09-26 13:12:17 +02:00
|
|
|
rect = *window_rect;
|
|
|
|
OffsetRect( &rect, -window_rect->left, -window_rect->top );
|
2012-09-27 18:13:01 +02:00
|
|
|
|
2012-09-26 13:12:17 +02:00
|
|
|
surface = data->surface;
|
2016-10-13 17:05:08 +02:00
|
|
|
if (!surface || !EqualRect( &surface->rect, &rect ))
|
2012-09-26 13:12:17 +02:00
|
|
|
{
|
2012-09-27 20:47:08 +02:00
|
|
|
data->surface = create_surface( data->whole_window, &data->vis, &rect,
|
2018-04-04 18:24:41 +02:00
|
|
|
color_key, data->use_alpha );
|
2012-09-26 13:12:17 +02:00
|
|
|
if (surface) window_surface_release( surface );
|
|
|
|
surface = data->surface;
|
2012-09-27 18:13:01 +02:00
|
|
|
}
|
2012-09-26 13:12:17 +02:00
|
|
|
else set_surface_color_key( surface, color_key );
|
2012-09-27 18:13:01 +02:00
|
|
|
|
2012-10-04 10:34:41 +02:00
|
|
|
if (surface) window_surface_add_ref( surface );
|
2012-09-26 13:12:17 +02:00
|
|
|
release_win_data( data );
|
|
|
|
|
|
|
|
if (!surface) return FALSE;
|
2012-10-04 10:34:41 +02:00
|
|
|
if (!info->hdcSrc)
|
|
|
|
{
|
|
|
|
window_surface_release( surface );
|
|
|
|
return TRUE;
|
|
|
|
}
|
2012-09-26 13:12:17 +02:00
|
|
|
|
|
|
|
dst_bits = surface->funcs->get_info( surface, bmi );
|
|
|
|
|
|
|
|
if (!(dib = CreateDIBSection( info->hdcDst, bmi, DIB_RGB_COLORS, &src_bits, NULL, 0 ))) goto done;
|
|
|
|
if (!(hdc = CreateCompatibleDC( 0 ))) goto done;
|
|
|
|
|
|
|
|
SelectObject( hdc, dib );
|
|
|
|
|
|
|
|
surface->funcs->lock( surface );
|
2012-10-03 00:08:30 +02:00
|
|
|
|
|
|
|
if (info->prcDirty)
|
|
|
|
{
|
2012-10-04 10:34:41 +02:00
|
|
|
IntersectRect( &rect, &rect, info->prcDirty );
|
2012-10-03 00:08:30 +02:00
|
|
|
memcpy( src_bits, dst_bits, bmi->bmiHeader.biSizeImage );
|
|
|
|
PatBlt( hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, BLACKNESS );
|
|
|
|
}
|
2017-06-27 17:40:36 +02:00
|
|
|
src_rect = rect;
|
|
|
|
if (info->pptSrc) OffsetRect( &src_rect, info->pptSrc->x, info->pptSrc->y );
|
|
|
|
DPtoLP( info->hdcSrc, (POINT *)&src_rect, 2 );
|
|
|
|
|
2012-10-03 00:08:30 +02:00
|
|
|
ret = GdiAlphaBlend( hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
|
2017-06-27 17:40:36 +02:00
|
|
|
info->hdcSrc, src_rect.left, src_rect.top,
|
|
|
|
src_rect.right - src_rect.left, src_rect.bottom - src_rect.top,
|
2012-10-03 00:08:30 +02:00
|
|
|
(info->dwFlags & ULW_ALPHA) ? *info->pblend : blend );
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
memcpy( dst_bits, src_bits, bmi->bmiHeader.biSizeImage );
|
|
|
|
add_bounds_rect( surface->funcs->get_bounds( surface ), &rect );
|
|
|
|
}
|
|
|
|
|
2012-09-26 13:12:17 +02:00
|
|
|
surface->funcs->unlock( surface );
|
|
|
|
surface->funcs->flush( surface );
|
|
|
|
|
|
|
|
done:
|
2012-10-04 10:34:41 +02:00
|
|
|
window_surface_release( surface );
|
2012-09-26 13:12:17 +02:00
|
|
|
if (hdc) DeleteDC( hdc );
|
|
|
|
if (dib) DeleteObject( dib );
|
|
|
|
return ret;
|
2012-09-27 18:13:01 +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)
|
|
|
|
{
|
2016-09-26 13:27:40 +02:00
|
|
|
case WM_X11DRV_UPDATE_CLIPBOARD:
|
|
|
|
return update_clipboard( hwnd );
|
2008-09-08 15:51:08 +02:00
|
|
|
case WM_X11DRV_SET_WIN_REGION:
|
2012-09-21 15:53:48 +02:00
|
|
|
if ((data = get_win_data( hwnd )))
|
|
|
|
{
|
2012-09-21 16:29:24 +02:00
|
|
|
sync_window_region( data, (HRGN)1 );
|
2012-09-21 15:53:48 +02:00
|
|
|
release_win_data( data );
|
|
|
|
}
|
2008-09-08 15:51:08 +02:00
|
|
|
return 0;
|
2008-09-08 15:42:24 +02:00
|
|
|
case WM_X11DRV_RESIZE_DESKTOP:
|
2020-05-11 10:55:38 +02:00
|
|
|
X11DRV_resize_desktop( (BOOL)lp );
|
2008-09-08 15:42:24 +02:00
|
|
|
return 0;
|
2010-04-29 02:23:05 +02:00
|
|
|
case WM_X11DRV_SET_CURSOR:
|
2012-09-24 14:09:43 +02:00
|
|
|
if ((data = get_win_data( hwnd )))
|
|
|
|
{
|
2018-03-27 08:00:07 +02:00
|
|
|
Window win = data->whole_window;
|
2012-09-24 14:09:43 +02:00
|
|
|
release_win_data( data );
|
2018-03-27 08:00:07 +02:00
|
|
|
if (win) set_window_cursor( win, (HCURSOR)lp );
|
2012-09-24 14:09:43 +02:00
|
|
|
}
|
2011-11-09 14:26:34 +01:00
|
|
|
else if (hwnd == x11drv_thread_data()->clip_hwnd)
|
|
|
|
set_window_cursor( x11drv_thread_data()->clip_window, (HCURSOR)lp );
|
2010-04-29 02:23:05 +02:00
|
|
|
return 0;
|
2020-10-01 22:24:30 +02:00
|
|
|
case WM_X11DRV_CLIP_CURSOR_NOTIFY:
|
2019-09-16 10:00:18 +02:00
|
|
|
return clip_cursor_notify( hwnd, (HWND)wp, (HWND)lp );
|
2020-10-01 22:24:30 +02:00
|
|
|
case WM_X11DRV_CLIP_CURSOR_REQUEST:
|
2020-10-01 22:24:31 +02:00
|
|
|
return clip_cursor_request( hwnd, (BOOL)wp, (BOOL)lp );
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < net_supported_count; i++)
|
|
|
|
if (net_supported[i] == atom) return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-03 12:28:38 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* start_screensaver
|
|
|
|
*/
|
|
|
|
static LRESULT start_screensaver(void)
|
|
|
|
{
|
2019-11-05 14:04:07 +01:00
|
|
|
if (!is_virtual_desktop())
|
2019-05-03 12:28:38 +02:00
|
|
|
{
|
|
|
|
const char *argv[3] = { "xdg-screensaver", "activate", NULL };
|
|
|
|
int pid = _spawnvp( _P_DETACH, argv[0], argv );
|
|
|
|
if (pid > 0)
|
|
|
|
{
|
|
|
|
TRACE( "started process %d\n", pid );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-17 16:13:34 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* 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;
|
2012-02-01 15:46:52 +01:00
|
|
|
int dir;
|
2008-04-17 16:13:34 +02:00
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
2019-05-03 12:28:38 +02:00
|
|
|
if (!(data = get_win_data( hwnd )))
|
|
|
|
{
|
|
|
|
if (wparam == SC_SCREENSAVE && hwnd == GetDesktopWindow()) return start_screensaver();
|
|
|
|
return -1;
|
|
|
|
}
|
2012-09-24 13:41:20 +02:00
|
|
|
if (!data->whole_window || !data->managed || !data->mapped) goto failed;
|
2008-04-17 16:13:34 +02:00
|
|
|
|
|
|
|
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 */
|
2012-09-24 13:41:20 +02:00
|
|
|
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_THICKFRAME)) goto failed;
|
2008-04-17 16:13:34 +02:00
|
|
|
|
|
|
|
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;
|
2020-07-29 19:07:40 +02:00
|
|
|
case 9: dir = _NET_WM_MOVERESIZE_MOVE; break;
|
2008-04-17 16:13:34 +02:00
|
|
|
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 */
|
2012-09-24 13:41:20 +02:00
|
|
|
if ((WCHAR)lparam) goto failed; /* got an explicit char */
|
|
|
|
if (GetMenu( hwnd )) goto failed; /* window has a real menu */
|
|
|
|
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_SYSMENU)) goto failed; /* no system menu */
|
2008-04-17 16:13:34 +02:00
|
|
|
TRACE( "ignoring SC_KEYMENU wp %lx lp %lx\n", wparam, lparam );
|
2012-09-24 13:41:20 +02:00
|
|
|
release_win_data( data );
|
2008-04-17 16:13:34 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
2012-09-24 13:41:20 +02:00
|
|
|
goto failed;
|
2008-04-17 16:13:34 +02:00
|
|
|
}
|
|
|
|
|
2012-09-24 13:41:20 +02:00
|
|
|
if (IsZoomed(hwnd)) goto failed;
|
2008-04-17 16:13:34 +02:00
|
|
|
|
2012-09-21 16:29:24 +02:00
|
|
|
if (!is_netwm_supported( data->display, x11drv_atom(_NET_WM_MOVERESIZE) ))
|
2008-04-17 16:13:34 +02:00
|
|
|
{
|
|
|
|
TRACE( "_NET_WM_MOVERESIZE not supported\n" );
|
2012-09-24 13:41:20 +02:00
|
|
|
goto failed;
|
2008-04-17 16:13:34 +02:00
|
|
|
}
|
|
|
|
|
2012-09-24 13:41:20 +02:00
|
|
|
release_win_data( data );
|
2012-09-13 20:08:01 +02:00
|
|
|
move_resize_window( hwnd, dir );
|
2008-04-17 16:13:34 +02:00
|
|
|
return 0;
|
2012-09-24 13:41:20 +02:00
|
|
|
|
|
|
|
failed:
|
|
|
|
release_win_data( data );
|
|
|
|
return -1;
|
2008-04-17 16:13:34 +02:00
|
|
|
}
|
2015-10-13 07:52:37 +02:00
|
|
|
|
|
|
|
void CDECL X11DRV_FlashWindowEx( PFLASHWINFO pfinfo )
|
|
|
|
{
|
|
|
|
struct x11drv_win_data *data = get_win_data( pfinfo->hwnd );
|
|
|
|
XEvent xev;
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (data->mapped)
|
|
|
|
{
|
|
|
|
xev.type = ClientMessage;
|
|
|
|
xev.xclient.window = data->whole_window;
|
|
|
|
xev.xclient.message_type = x11drv_atom( _NET_WM_STATE );
|
|
|
|
xev.xclient.serial = 0;
|
|
|
|
xev.xclient.display = data->display;
|
|
|
|
xev.xclient.send_event = True;
|
|
|
|
xev.xclient.format = 32;
|
|
|
|
xev.xclient.data.l[0] = pfinfo->dwFlags ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
|
|
|
|
xev.xclient.data.l[1] = x11drv_atom( _NET_WM_STATE_DEMANDS_ATTENTION );
|
|
|
|
xev.xclient.data.l[2] = 0;
|
|
|
|
xev.xclient.data.l[3] = 1;
|
|
|
|
xev.xclient.data.l[4] = 0;
|
|
|
|
|
|
|
|
XSendEvent( data->display, DefaultRootWindow( data->display ), False,
|
|
|
|
SubstructureNotifyMask, &xev );
|
|
|
|
}
|
|
|
|
release_win_data( data );
|
|
|
|
}
|