2001-04-24 23:28:52 +00:00
|
|
|
/*
|
|
|
|
* Window related functions
|
|
|
|
*
|
|
|
|
* Copyright 1993, 1994, 1995, 1996, 2001 Alexandre Julliard
|
|
|
|
* Copyright 1993 David Metcalfe
|
|
|
|
* Copyright 1995, 1996 Alex Korobka
|
2002-03-09 23:29:33 +00: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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-04-24 23:28:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
2001-06-19 03:32:44 +00:00
|
|
|
#include <stdlib.h>
|
2006-08-23 00:14:11 +00:00
|
|
|
#include <stdio.h>
|
2003-08-08 21:07:23 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2001-06-19 03:32:44 +00:00
|
|
|
|
2003-11-21 21:48:36 +00:00
|
|
|
#include <X11/Xlib.h>
|
2002-09-24 18:36:51 +00:00
|
|
|
#include <X11/Xresource.h>
|
|
|
|
#include <X11/Xutil.h>
|
2008-01-23 15:30:18 +00:00
|
|
|
#ifdef HAVE_LIBXSHAPE
|
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
#endif /* HAVE_LIBXSHAPE */
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "windef.h"
|
2001-04-24 23:28:52 +00:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2001-10-02 18:44:56 +00:00
|
|
|
#include "wine/unicode.h"
|
2001-04-24 23:28:52 +00:00
|
|
|
|
|
|
|
#include "x11drv.h"
|
2007-09-26 05:43:38 +00:00
|
|
|
#include "xcomposite.h"
|
2005-03-25 10:38:56 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/server.h"
|
2005-01-17 19:17:47 +00:00
|
|
|
#include "win.h"
|
2002-01-21 18:41:27 +00:00
|
|
|
#include "mwm.h"
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
|
2001-04-24 23:28:52 +00:00
|
|
|
|
|
|
|
/* X context to associate a hwnd to an X window */
|
|
|
|
XContext winContext = 0;
|
|
|
|
|
2005-01-28 17:25:50 +00:00
|
|
|
/* X context to associate a struct x11drv_win_data to an hwnd */
|
|
|
|
static XContext win_data_context;
|
|
|
|
|
2005-07-07 17:30:57 +00:00
|
|
|
static const char whole_window_prop[] = "__wine_x11_whole_window";
|
|
|
|
static const char icon_window_prop[] = "__wine_x11_icon_window";
|
2007-09-15 20:02:32 +00:00
|
|
|
static const char fbconfig_id_prop[] = "__wine_x11_fbconfig_id";
|
2007-09-25 17:20:58 +00:00
|
|
|
static const char gl_drawable_prop[] = "__wine_x11_gl_drawable";
|
2007-09-26 15:17:13 +00:00
|
|
|
static const char pixmap_prop[] = "__wine_x11_pixmap";
|
2005-07-07 17:30:57 +00:00
|
|
|
static const char managed_prop[] = "__wine_x11_managed";
|
|
|
|
static const char visual_id_prop[] = "__wine_x11_visual_id";
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2006-08-23 00:14:11 +00:00
|
|
|
/* for XDG systray icons */
|
|
|
|
#define SYSTEM_TRAY_REQUEST_DOCK 0
|
|
|
|
|
2007-09-26 05:43:38 +00:00
|
|
|
extern int usexcomposite;
|
|
|
|
|
2001-04-24 23:28:52 +00:00
|
|
|
/***********************************************************************
|
2001-06-04 21:55:17 +00:00
|
|
|
* is_window_managed
|
2001-04-24 23:28:52 +00:00
|
|
|
*
|
2001-06-04 21:55:17 +00:00
|
|
|
* Check if a given window should be managed
|
2001-04-24 23:28:52 +00:00
|
|
|
*/
|
2007-08-27 10:37:14 +00:00
|
|
|
BOOL is_window_managed( HWND hwnd, UINT swp_flags, const RECT *window_rect )
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2005-01-17 19:17:47 +00:00
|
|
|
DWORD style, ex_style;
|
|
|
|
|
2008-01-24 09:21:07 +00:00
|
|
|
if (!managed_mode) return FALSE;
|
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
/* child windows are not managed */
|
2005-01-17 19:17:47 +00:00
|
|
|
style = GetWindowLongW( hwnd, GWL_STYLE );
|
2007-07-25 02:09:50 +00:00
|
|
|
if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD) return FALSE;
|
2007-08-27 10:37:14 +00:00
|
|
|
/* activated windows are managed */
|
|
|
|
if (!(swp_flags & (SWP_NOACTIVATE|SWP_HIDEWINDOW))) return TRUE;
|
|
|
|
if (hwnd == GetActiveWindow()) return TRUE;
|
2003-12-04 21:54:13 +00:00
|
|
|
/* windows with caption are managed */
|
2005-01-17 19:17:47 +00:00
|
|
|
if ((style & WS_CAPTION) == WS_CAPTION) return TRUE;
|
2003-12-04 21:54:13 +00:00
|
|
|
/* tool windows are not managed */
|
2008-01-23 20:40:45 +00:00
|
|
|
ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
|
2005-01-17 19:17:47 +00:00
|
|
|
if (ex_style & WS_EX_TOOLWINDOW) return FALSE;
|
2003-12-04 21:54:13 +00:00
|
|
|
/* windows with thick frame are managed */
|
2005-01-17 19:17:47 +00:00
|
|
|
if (style & WS_THICKFRAME) return TRUE;
|
2003-12-13 00:05:53 +00:00
|
|
|
/* application windows are managed */
|
2005-01-17 19:17:47 +00:00
|
|
|
if (ex_style & WS_EX_APPWINDOW) return TRUE;
|
|
|
|
if (style & WS_POPUP)
|
2004-02-06 05:17:55 +00:00
|
|
|
{
|
2007-02-10 17:40:50 +00:00
|
|
|
/* popup with sysmenu == caption are managed */
|
|
|
|
if (style & WS_SYSMENU) return TRUE;
|
|
|
|
/* full-screen popup windows are managed */
|
2007-08-20 20:06:33 +00:00
|
|
|
if ((window_rect->right - window_rect->left) == screen_width &&
|
|
|
|
(window_rect->bottom - window_rect->top) == screen_height)
|
2005-01-17 19:17:47 +00:00
|
|
|
return TRUE;
|
2004-02-06 05:17:55 +00:00
|
|
|
}
|
2001-06-04 21:55:17 +00:00
|
|
|
/* default: not managed */
|
|
|
|
return FALSE;
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-27 23:32:01 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_is_window_rect_mapped
|
|
|
|
*
|
|
|
|
* Check if the X whole window should be mapped based on its rectangle
|
|
|
|
*/
|
|
|
|
BOOL X11DRV_is_window_rect_mapped( const RECT *rect )
|
|
|
|
{
|
|
|
|
/* don't map if rect is empty */
|
|
|
|
if (IsRectEmpty( rect )) return FALSE;
|
|
|
|
|
|
|
|
/* don't map if rect is off-screen */
|
2006-10-23 12:37:17 +00:00
|
|
|
if (rect->left >= virtual_screen_rect.right ||
|
|
|
|
rect->top >= virtual_screen_rect.bottom ||
|
|
|
|
rect->right <= virtual_screen_rect.left ||
|
|
|
|
rect->bottom <= virtual_screen_rect.top)
|
|
|
|
return FALSE;
|
2004-04-27 23:32:01 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-11 10:24:27 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* get_mwm_decorations
|
|
|
|
*/
|
|
|
|
static unsigned long get_mwm_decorations( DWORD style, DWORD ex_style )
|
|
|
|
{
|
|
|
|
unsigned long ret = 0;
|
|
|
|
|
|
|
|
if (ex_style & WS_EX_TOOLWINDOW) return 0;
|
|
|
|
|
|
|
|
if ((style & WS_CAPTION) == WS_CAPTION)
|
|
|
|
{
|
|
|
|
ret |= MWM_DECOR_TITLE | MWM_DECOR_BORDER;
|
|
|
|
if (style & WS_SYSMENU) ret |= MWM_DECOR_MENU;
|
|
|
|
if (style & WS_MINIMIZEBOX) ret |= MWM_DECOR_MINIMIZE;
|
|
|
|
if (style & WS_MAXIMIZEBOX) ret |= MWM_DECOR_MAXIMIZE;
|
|
|
|
}
|
|
|
|
if (ex_style & WS_EX_DLGMODALFRAME) ret |= MWM_DECOR_BORDER;
|
|
|
|
else if (style & WS_THICKFRAME) ret |= MWM_DECOR_BORDER | MWM_DECOR_RESIZEH;
|
|
|
|
else if ((style & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME) ret |= MWM_DECOR_BORDER;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* get_x11_rect_offset
|
|
|
|
*
|
|
|
|
* Helper for X11DRV_window_to_X_rect and X11DRV_X_to_window_rect.
|
|
|
|
*/
|
|
|
|
static void get_x11_rect_offset( struct x11drv_win_data *data, RECT *rect )
|
|
|
|
{
|
|
|
|
DWORD style, ex_style, style_mask = 0, ex_style_mask = 0;
|
|
|
|
unsigned long decor;
|
|
|
|
|
|
|
|
rect->top = rect->bottom = rect->left = rect->right = 0;
|
|
|
|
|
|
|
|
style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
|
|
|
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
|
|
|
|
decor = get_mwm_decorations( style, ex_style );
|
|
|
|
|
|
|
|
if (decor & MWM_DECOR_TITLE) style_mask |= WS_CAPTION;
|
|
|
|
if (decor & MWM_DECOR_BORDER)
|
|
|
|
{
|
|
|
|
style_mask |= WS_DLGFRAME | WS_THICKFRAME;
|
|
|
|
ex_style_mask |= WS_EX_DLGMODALFRAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
AdjustWindowRectEx( rect, style & style_mask, FALSE, ex_style & ex_style_mask );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* get_window_attributes
|
|
|
|
*
|
2001-06-12 04:02:10 +00:00
|
|
|
* Fill the window attributes structure for an X window.
|
2001-06-04 21:55:17 +00:00
|
|
|
*/
|
2006-03-27 13:33:43 +00:00
|
|
|
static int get_window_attributes( Display *display, struct x11drv_win_data *data,
|
|
|
|
XSetWindowAttributes *attr )
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
2005-02-01 18:53:59 +00:00
|
|
|
attr->override_redirect = !data->managed;
|
2001-06-04 21:55:17 +00:00
|
|
|
attr->colormap = X11DRV_PALETTE_PaletteXColormap;
|
2005-01-17 19:17:47 +00:00
|
|
|
attr->save_under = ((GetClassLongW( data->hwnd, GCL_STYLE ) & CS_SAVEBITS) != 0);
|
2002-06-14 00:08:40 +00:00
|
|
|
attr->cursor = x11drv_thread_data()->cursor;
|
2007-08-20 12:23:10 +00:00
|
|
|
attr->bit_gravity = NorthWestGravity;
|
|
|
|
attr->backing_store = NotUseful;
|
|
|
|
attr->event_mask = (ExposureMask | PointerMotionMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
|
|
|
|
KeyPressMask | KeyReleaseMask | FocusChangeMask | KeymapStateMask);
|
|
|
|
if (data->managed) attr->event_mask |= StructureNotifyMask;
|
|
|
|
|
|
|
|
return (CWOverrideRedirect | CWSaveUnder | CWColormap | CWCursor |
|
|
|
|
CWEventMask | CWBitGravity | CWBackingStore);
|
2001-06-12 04:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2002-08-20 00:36:45 +00:00
|
|
|
* X11DRV_sync_window_style
|
2001-06-12 04:02:10 +00:00
|
|
|
*
|
|
|
|
* Change the X window attributes when the window style has changed.
|
|
|
|
*/
|
2005-01-17 19:17:47 +00:00
|
|
|
void X11DRV_sync_window_style( Display *display, struct x11drv_win_data *data )
|
2001-06-12 04:02:10 +00:00
|
|
|
{
|
2007-08-20 12:23:10 +00:00
|
|
|
if (data->whole_window != root_window)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
int mask = get_window_attributes( display, data, &attr );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2007-08-20 12:23:10 +00:00
|
|
|
wine_tsx11_lock();
|
2006-03-06 20:02:59 +00:00
|
|
|
XChangeWindowAttributes( display, data->whole_window, mask, &attr );
|
2007-08-20 12:23:10 +00:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
2001-06-04 21:55:17 +00:00
|
|
|
}
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2008-01-23 15:30:18 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* sync_window_region
|
|
|
|
*
|
|
|
|
* Update the X11 window region.
|
|
|
|
*/
|
|
|
|
static void sync_window_region( Display *display, struct x11drv_win_data *data, HRGN hrgn )
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LIBXSHAPE
|
|
|
|
if (!data->whole_window) return;
|
|
|
|
|
|
|
|
if (!hrgn)
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XShapeCombineMask( display, data->whole_window, ShapeBounding, 0, 0, None, ShapeSet );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RGNDATA *pRegionData = X11DRV_GetRegionData( hrgn, 0 );
|
|
|
|
if (pRegionData)
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XShapeCombineRectangles( display, data->whole_window, ShapeBounding,
|
|
|
|
data->window_rect.left - data->whole_rect.left,
|
|
|
|
data->window_rect.top - data->whole_rect.top,
|
|
|
|
(XRectangle *)pRegionData->Buffer,
|
|
|
|
pRegionData->rdh.nCount, ShapeSet, YXBanded );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
HeapFree(GetProcessHeap(), 0, pRegionData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* HAVE_LIBXSHAPE */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-23 15:32:55 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* sync_window_text
|
|
|
|
*/
|
|
|
|
static void sync_window_text( Display *display, Window win, const WCHAR *text )
|
|
|
|
{
|
|
|
|
UINT count;
|
|
|
|
char *buffer, *utf8_buffer;
|
|
|
|
XTextProperty prop;
|
|
|
|
|
|
|
|
/* allocate new buffer for window text */
|
|
|
|
count = WideCharToMultiByte(CP_UNIXCP, 0, text, -1, NULL, 0, NULL, NULL);
|
|
|
|
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, count ))) return;
|
|
|
|
WideCharToMultiByte(CP_UNIXCP, 0, text, -1, buffer, count, NULL, NULL);
|
|
|
|
|
|
|
|
count = WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), NULL, 0, NULL, NULL);
|
|
|
|
if (!(utf8_buffer = HeapAlloc( GetProcessHeap(), 0, count )))
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), utf8_buffer, count, NULL, NULL);
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (XmbTextListToTextProperty( display, &buffer, 1, XStdICCTextStyle, &prop ) == Success)
|
|
|
|
{
|
|
|
|
XSetWMName( display, win, &prop );
|
|
|
|
XSetWMIconName( display, win, &prop );
|
|
|
|
XFree( prop.value );
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
Implements a NET_WM UTF-8 title. It should be without a trailing \0,
|
|
|
|
according to the standard
|
|
|
|
( http://www.pps.jussieu.fr/~jch/software/UTF8_STRING/UTF8_STRING.text ).
|
|
|
|
*/
|
|
|
|
XChangeProperty( display, win, x11drv_atom(_NET_WM_NAME), x11drv_atom(UTF8_STRING),
|
|
|
|
8, PropModeReplace, (unsigned char *) utf8_buffer, count);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, utf8_buffer );
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-15 20:02:32 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_set_win_format
|
|
|
|
*/
|
|
|
|
BOOL X11DRV_set_win_format( HWND hwnd, XID fbconfig_id )
|
|
|
|
{
|
2007-09-26 05:43:38 +00:00
|
|
|
Display *display = thread_display();
|
2007-09-15 20:02:32 +00:00
|
|
|
struct x11drv_win_data *data;
|
2007-09-26 05:43:38 +00:00
|
|
|
XVisualInfo *vis;
|
|
|
|
Drawable parent;
|
|
|
|
HWND next_hwnd;
|
|
|
|
int w, h;
|
2007-09-15 20:02:32 +00:00
|
|
|
|
2008-01-24 09:20:51 +00:00
|
|
|
if (!(data = X11DRV_get_win_data(hwnd)) &&
|
|
|
|
!(data = X11DRV_create_win_data(hwnd))) return FALSE;
|
2007-09-15 20:02:32 +00:00
|
|
|
|
2007-09-26 05:43:38 +00:00
|
|
|
wine_tsx11_lock();
|
|
|
|
|
|
|
|
vis = visual_from_fbconfig_id(fbconfig_id);
|
2007-10-20 23:15:53 +00:00
|
|
|
if(!vis)
|
|
|
|
{
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-09-26 05:43:38 +00:00
|
|
|
|
|
|
|
if(data->whole_window && vis->visualid == XVisualIDFromVisual(visual))
|
|
|
|
{
|
|
|
|
TRACE("Whole window available and visual match, rendering onscreen\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
parent = data->whole_window;
|
|
|
|
next_hwnd = hwnd;
|
|
|
|
while(!parent)
|
|
|
|
{
|
|
|
|
next_hwnd = GetAncestor(next_hwnd, GA_PARENT);
|
|
|
|
if(!next_hwnd)
|
|
|
|
{
|
|
|
|
ERR("Could not find parent HWND with a drawable!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
parent = X11DRV_get_whole_window(next_hwnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
w = data->client_rect.right - data->client_rect.left;
|
|
|
|
h = data->client_rect.bottom - data->client_rect.top;
|
|
|
|
|
|
|
|
if(w <= 0) w = 1;
|
|
|
|
if(h <= 0) h = 1;
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
#ifdef SONAME_LIBXCOMPOSITE
|
|
|
|
if(usexcomposite)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attrib;
|
|
|
|
|
|
|
|
attrib.override_redirect = True;
|
|
|
|
attrib.colormap = XCreateColormap(display, parent, vis->visual,
|
|
|
|
(vis->class == PseudoColor ||
|
|
|
|
vis->class == GrayScale ||
|
|
|
|
vis->class == DirectColor) ?
|
|
|
|
AllocAll : AllocNone);
|
|
|
|
XInstallColormap(gdi_display, attrib.colormap);
|
|
|
|
|
|
|
|
data->gl_drawable = XCreateWindow(display, parent, -w, 0, w, h, 0,
|
|
|
|
vis->depth, InputOutput, vis->visual,
|
|
|
|
CWColormap | CWOverrideRedirect,
|
|
|
|
&attrib);
|
|
|
|
if(data->gl_drawable)
|
|
|
|
{
|
|
|
|
pXCompositeRedirectWindow(display, data->gl_drawable,
|
|
|
|
CompositeRedirectManual);
|
|
|
|
XMapWindow(display, data->gl_drawable);
|
|
|
|
}
|
|
|
|
}
|
2007-09-26 15:17:13 +00:00
|
|
|
else
|
2007-09-26 05:43:38 +00:00
|
|
|
#endif
|
2007-09-26 15:17:13 +00:00
|
|
|
{
|
|
|
|
WARN("XComposite is not available, using GLXPixmap hack\n");
|
|
|
|
|
|
|
|
data->pixmap = XCreatePixmap(display, parent, w, h, vis->depth);
|
|
|
|
if(!data->pixmap)
|
|
|
|
{
|
|
|
|
ERR("Failed to create pixmap for offscreen rendering\n");
|
|
|
|
XFree(vis);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->gl_drawable = create_glxpixmap(display, vis, data->pixmap);
|
|
|
|
if(!data->gl_drawable)
|
|
|
|
{
|
|
|
|
XFreePixmap(display, data->pixmap);
|
|
|
|
data->pixmap = 0;
|
|
|
|
}
|
|
|
|
}
|
2007-09-26 05:43:38 +00:00
|
|
|
|
|
|
|
if(!data->gl_drawable)
|
|
|
|
{
|
|
|
|
ERR("Failed to create drawable for offscreen rendering\n");
|
|
|
|
XFree(vis);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
XFree(vis);
|
|
|
|
|
|
|
|
XFlush(display);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
TRACE("Created GL drawable 0x%lx, using FBConfigID 0x%lx\n",
|
|
|
|
data->gl_drawable, fbconfig_id);
|
|
|
|
|
2007-09-15 20:02:32 +00:00
|
|
|
data->fbconfig_id = fbconfig_id;
|
|
|
|
SetPropA(hwnd, fbconfig_id_prop, (HANDLE)data->fbconfig_id);
|
2007-09-26 05:43:38 +00:00
|
|
|
SetPropA(hwnd, gl_drawable_prop, (HANDLE)data->gl_drawable);
|
2007-09-26 15:17:13 +00:00
|
|
|
SetPropA(hwnd, pixmap_prop, (HANDLE)data->pixmap);
|
2007-09-17 14:57:09 +00:00
|
|
|
invalidate_dce( hwnd, &data->window_rect );
|
2007-09-15 20:02:32 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-01-23 11:28:01 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_sync_gl_drawable
|
|
|
|
*/
|
|
|
|
void X11DRV_sync_gl_drawable(Display *display, struct x11drv_win_data *data)
|
2007-09-26 05:43:38 +00:00
|
|
|
{
|
|
|
|
int w = data->client_rect.right - data->client_rect.left;
|
|
|
|
int h = data->client_rect.bottom - data->client_rect.top;
|
2007-09-26 15:17:13 +00:00
|
|
|
XVisualInfo *vis;
|
|
|
|
Drawable parent;
|
|
|
|
HWND next_hwnd;
|
|
|
|
Drawable glxp;
|
|
|
|
Pixmap pix;
|
2007-09-26 05:43:38 +00:00
|
|
|
|
|
|
|
TRACE("Resizing GL drawable 0x%lx to %dx%d\n", data->gl_drawable, w, h);
|
|
|
|
#ifdef SONAME_LIBXCOMPOSITE
|
|
|
|
if(usexcomposite)
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XMoveResizeWindow(display, data->gl_drawable, -w, 0, w, h);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2007-09-26 15:17:13 +00:00
|
|
|
|
|
|
|
parent = data->whole_window;
|
|
|
|
next_hwnd = data->hwnd;
|
|
|
|
while(!parent)
|
|
|
|
{
|
|
|
|
next_hwnd = GetAncestor(next_hwnd, GA_PARENT);
|
|
|
|
if(!next_hwnd)
|
|
|
|
{
|
|
|
|
ERR("Could not find parent HWND with a drawable!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
parent = X11DRV_get_whole_window(next_hwnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
|
|
|
|
vis = visual_from_fbconfig_id(data->fbconfig_id);
|
2007-10-20 23:15:53 +00:00
|
|
|
if(!vis)
|
|
|
|
{
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return;
|
|
|
|
}
|
2007-09-26 15:17:13 +00:00
|
|
|
|
|
|
|
pix = XCreatePixmap(display, parent, w, h, vis->depth);
|
|
|
|
if(!pix)
|
|
|
|
{
|
|
|
|
ERR("Failed to create pixmap for offscreen rendering\n");
|
|
|
|
XFree(vis);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
glxp = create_glxpixmap(display, vis, pix);
|
|
|
|
if(!glxp)
|
|
|
|
{
|
|
|
|
ERR("Failed to create drawable for offscreen rendering\n");
|
|
|
|
XFreePixmap(display, pix);
|
|
|
|
XFree(vis);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree(vis);
|
|
|
|
|
|
|
|
mark_drawable_dirty(data->gl_drawable, glxp);
|
|
|
|
|
|
|
|
XFreePixmap(display, data->pixmap);
|
|
|
|
destroy_glxpixmap(display, data->gl_drawable);
|
|
|
|
|
|
|
|
data->pixmap = pix;
|
|
|
|
data->gl_drawable = glxp;
|
|
|
|
|
|
|
|
XFlush(display);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
SetPropA(data->hwnd, gl_drawable_prop, (HANDLE)data->gl_drawable);
|
|
|
|
SetPropA(data->hwnd, pixmap_prop, (HANDLE)data->pixmap);
|
|
|
|
invalidate_dce( data->hwnd, &data->window_rect );
|
2007-09-26 05:43:38 +00:00
|
|
|
}
|
|
|
|
|
2007-09-15 20:02:32 +00:00
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* get_window_changes
|
|
|
|
*
|
|
|
|
* fill the window changes structure
|
|
|
|
*/
|
|
|
|
static int get_window_changes( XWindowChanges *changes, const RECT *old, const RECT *new )
|
|
|
|
{
|
|
|
|
int mask = 0;
|
|
|
|
|
|
|
|
if (old->right - old->left != new->right - new->left )
|
|
|
|
{
|
|
|
|
if (!(changes->width = new->right - new->left)) changes->width = 1;
|
|
|
|
mask |= CWWidth;
|
|
|
|
}
|
|
|
|
if (old->bottom - old->top != new->bottom - new->top)
|
|
|
|
{
|
|
|
|
if (!(changes->height = new->bottom - new->top)) changes->height = 1;
|
|
|
|
mask |= CWHeight;
|
|
|
|
}
|
|
|
|
if (old->left != new->left)
|
|
|
|
{
|
|
|
|
changes->x = new->left;
|
|
|
|
mask |= CWX;
|
|
|
|
}
|
|
|
|
if (old->top != new->top)
|
|
|
|
{
|
|
|
|
changes->y = new->top;
|
|
|
|
mask |= CWY;
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
2001-06-04 21:55:17 +00:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* create_icon_window
|
|
|
|
*/
|
2005-01-17 19:17:47 +00:00
|
|
|
static Window create_icon_window( Display *display, struct x11drv_win_data *data )
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
attr.event_mask = (ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask |
|
2002-06-14 00:08:40 +00:00
|
|
|
ButtonPressMask | ButtonReleaseMask | EnterWindowMask);
|
2001-06-04 21:55:17 +00:00
|
|
|
attr.bit_gravity = NorthWestGravity;
|
|
|
|
attr.backing_store = NotUseful/*WhenMapped*/;
|
2001-07-12 22:27:56 +00:00
|
|
|
attr.colormap = X11DRV_PALETTE_PaletteXColormap; /* Needed due to our visual */
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2001-06-26 21:10:11 +00:00
|
|
|
wine_tsx11_lock();
|
|
|
|
data->icon_window = XCreateWindow( display, root_window, 0, 0,
|
|
|
|
GetSystemMetrics( SM_CXICON ),
|
|
|
|
GetSystemMetrics( SM_CYICON ),
|
|
|
|
0, screen_depth,
|
|
|
|
InputOutput, visual,
|
2001-07-12 22:27:56 +00:00
|
|
|
CWEventMask | CWBitGravity | CWBackingStore | CWColormap, &attr );
|
2005-01-17 19:17:47 +00:00
|
|
|
XSaveContext( display, data->icon_window, winContext, (char *)data->hwnd );
|
2001-06-26 21:10:11 +00:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
TRACE( "created %lx\n", data->icon_window );
|
2005-07-07 17:30:57 +00:00
|
|
|
SetPropA( data->hwnd, icon_window_prop, (HANDLE)data->icon_window );
|
2001-06-04 21:55:17 +00:00
|
|
|
return data->icon_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* destroy_icon_window
|
|
|
|
*/
|
2005-01-31 16:34:07 +00:00
|
|
|
static void destroy_icon_window( Display *display, struct x11drv_win_data *data )
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
|
|
|
if (!data->icon_window) return;
|
2002-06-14 00:08:40 +00:00
|
|
|
if (x11drv_thread_data()->cursor_window == data->icon_window)
|
|
|
|
x11drv_thread_data()->cursor_window = None;
|
2001-07-12 02:49:31 +00:00
|
|
|
wine_tsx11_lock();
|
2001-06-04 21:55:17 +00:00
|
|
|
XDeleteContext( display, data->icon_window, winContext );
|
|
|
|
XDestroyWindow( display, data->icon_window );
|
|
|
|
data->icon_window = 0;
|
2001-07-12 02:49:31 +00:00
|
|
|
wine_tsx11_unlock();
|
2005-07-07 17:30:57 +00:00
|
|
|
RemovePropA( data->hwnd, icon_window_prop );
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* set_icon_hints
|
|
|
|
*
|
|
|
|
* Set the icon wm hints
|
|
|
|
*/
|
2007-08-16 21:27:37 +00:00
|
|
|
static void set_icon_hints( Display *display, struct x11drv_win_data *data, HICON hIcon )
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2007-08-16 21:27:37 +00:00
|
|
|
XWMHints *hints = data->wm_hints;
|
|
|
|
|
2001-04-24 23:28:52 +00:00
|
|
|
if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap );
|
|
|
|
if (data->hWMIconMask) DeleteObject( data->hWMIconMask);
|
2001-06-12 04:02:10 +00:00
|
|
|
data->hWMIconBitmap = 0;
|
|
|
|
data->hWMIconMask = 0;
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2008-01-23 15:40:19 +00:00
|
|
|
if (!hIcon)
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2005-01-17 19:17:47 +00:00
|
|
|
if (!data->icon_window) create_icon_window( display, data );
|
2001-06-04 21:55:17 +00:00
|
|
|
hints->icon_window = data->icon_window;
|
|
|
|
hints->flags = (hints->flags & ~(IconPixmapHint | IconMaskHint)) | IconWindowHint;
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HBITMAP hbmOrig;
|
|
|
|
RECT rcMask;
|
|
|
|
BITMAP bmMask;
|
|
|
|
ICONINFO ii;
|
|
|
|
HDC hDC;
|
|
|
|
|
|
|
|
GetIconInfo(hIcon, &ii);
|
|
|
|
|
|
|
|
GetObjectA(ii.hbmMask, sizeof(bmMask), &bmMask);
|
|
|
|
rcMask.top = 0;
|
|
|
|
rcMask.left = 0;
|
|
|
|
rcMask.right = bmMask.bmWidth;
|
|
|
|
rcMask.bottom = bmMask.bmHeight;
|
|
|
|
|
|
|
|
hDC = CreateCompatibleDC(0);
|
|
|
|
hbmOrig = SelectObject(hDC, ii.hbmMask);
|
|
|
|
InvertRect(hDC, &rcMask);
|
2002-05-31 18:43:22 +00:00
|
|
|
SelectObject(hDC, ii.hbmColor); /* force the color bitmap to x11drv mode too */
|
2001-04-24 23:28:52 +00:00
|
|
|
SelectObject(hDC, hbmOrig);
|
|
|
|
DeleteDC(hDC);
|
|
|
|
|
|
|
|
data->hWMIconBitmap = ii.hbmColor;
|
|
|
|
data->hWMIconMask = ii.hbmMask;
|
|
|
|
|
2005-03-27 18:30:51 +00:00
|
|
|
hints->icon_pixmap = X11DRV_get_pixmap(data->hWMIconBitmap);
|
|
|
|
hints->icon_mask = X11DRV_get_pixmap(data->hWMIconMask);
|
2005-01-17 19:17:47 +00:00
|
|
|
destroy_icon_window( display, data );
|
2001-06-04 21:55:17 +00:00
|
|
|
hints->flags = (hints->flags & ~IconWindowHint) | IconPixmapHint | IconMaskHint;
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-23 00:14:11 +00:00
|
|
|
/***********************************************************************
|
2008-01-23 20:40:45 +00:00
|
|
|
* wine_make_systray_window (X11DRV.@)
|
2006-08-23 00:14:11 +00:00
|
|
|
*
|
|
|
|
* Docks the given X window with the NETWM system tray.
|
|
|
|
*/
|
2008-01-23 20:40:45 +00:00
|
|
|
void X11DRV_make_systray_window( HWND hwnd )
|
2006-08-23 00:14:11 +00:00
|
|
|
{
|
|
|
|
static Atom systray_atom;
|
2008-01-23 20:40:45 +00:00
|
|
|
Display *display = thread_display();
|
|
|
|
struct x11drv_win_data *data;
|
2006-08-23 00:14:11 +00:00
|
|
|
Window systray_window;
|
|
|
|
|
2008-01-24 09:20:51 +00:00
|
|
|
if (!(data = X11DRV_get_win_data( hwnd )) &&
|
|
|
|
!(data = X11DRV_create_win_data( hwnd ))) return;
|
2008-01-23 20:40:45 +00:00
|
|
|
|
2006-08-23 00:14:11 +00:00
|
|
|
wine_tsx11_lock();
|
|
|
|
if (!systray_atom)
|
|
|
|
{
|
|
|
|
if (DefaultScreen( display ) == 0)
|
|
|
|
systray_atom = x11drv_atom(_NET_SYSTEM_TRAY_S0);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char systray_buffer[29]; /* strlen(_NET_SYSTEM_TRAY_S4294967295)+1 */
|
|
|
|
sprintf( systray_buffer, "_NET_SYSTEM_TRAY_S%u", DefaultScreen( display ) );
|
|
|
|
systray_atom = XInternAtom( display, systray_buffer, False );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
systray_window = XGetSelectionOwner( display, systray_atom );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
TRACE("Docking tray icon %p\n", data->hwnd);
|
|
|
|
|
|
|
|
if (systray_window != None)
|
|
|
|
{
|
|
|
|
XEvent ev;
|
|
|
|
unsigned long info[2];
|
|
|
|
|
|
|
|
/* Put the window offscreen so it isn't mapped. The window _cannot_ be
|
|
|
|
* mapped if we intend to dock with an XEMBED tray. If the window is
|
|
|
|
* mapped when we dock, it may become visible as a child of the root
|
|
|
|
* window after it docks, which isn't the proper behavior.
|
|
|
|
*
|
|
|
|
* For more information on this problem, see
|
|
|
|
* http://standards.freedesktop.org/xembed-spec/latest/ar01s04.html */
|
|
|
|
|
2006-10-23 12:37:17 +00:00
|
|
|
SetWindowPos( data->hwnd, NULL, virtual_screen_rect.right + 1, virtual_screen_rect.bottom + 1,
|
2007-08-23 14:44:24 +00:00
|
|
|
0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE );
|
2006-08-23 00:14:11 +00:00
|
|
|
|
|
|
|
/* set XEMBED protocol data on the window */
|
|
|
|
info[0] = 0; /* protocol version */
|
|
|
|
info[1] = 1; /* mapped = true */
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XChangeProperty( display, data->whole_window,
|
|
|
|
x11drv_atom(_XEMBED_INFO),
|
|
|
|
x11drv_atom(_XEMBED_INFO), 32, PropModeReplace,
|
|
|
|
(unsigned char*)info, 2 );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
/* send the docking request message */
|
|
|
|
ZeroMemory( &ev, sizeof(ev) );
|
|
|
|
ev.xclient.type = ClientMessage;
|
|
|
|
ev.xclient.window = systray_window;
|
|
|
|
ev.xclient.message_type = x11drv_atom( _NET_SYSTEM_TRAY_OPCODE );
|
|
|
|
ev.xclient.format = 32;
|
|
|
|
ev.xclient.data.l[0] = CurrentTime;
|
|
|
|
ev.xclient.data.l[1] = SYSTEM_TRAY_REQUEST_DOCK;
|
|
|
|
ev.xclient.data.l[2] = data->whole_window;
|
|
|
|
ev.xclient.data.l[3] = 0;
|
|
|
|
ev.xclient.data.l[4] = 0;
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XSendEvent( display, systray_window, False, NoEventMask, &ev );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int val = 1;
|
|
|
|
|
|
|
|
/* fall back to he KDE hints if the WM doesn't support XEMBED'ed
|
|
|
|
* systrays */
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XChangeProperty( display, data->whole_window,
|
|
|
|
x11drv_atom(KWM_DOCKWINDOW),
|
|
|
|
x11drv_atom(KWM_DOCKWINDOW), 32, PropModeReplace,
|
|
|
|
(unsigned char*)&val, 1 );
|
|
|
|
XChangeProperty( display, data->whole_window,
|
|
|
|
x11drv_atom(_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR),
|
|
|
|
XA_WINDOW, 32, PropModeReplace,
|
|
|
|
(unsigned char*)&data->whole_window, 1 );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-24 23:28:52 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-04 21:55:17 +00:00
|
|
|
* set_size_hints
|
2001-04-24 23:28:52 +00:00
|
|
|
*
|
2001-06-04 21:55:17 +00:00
|
|
|
* set the window size hints
|
2001-04-24 23:28:52 +00:00
|
|
|
*/
|
2005-01-17 19:17:47 +00:00
|
|
|
static void set_size_hints( Display *display, struct x11drv_win_data *data, DWORD style )
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2001-06-04 21:55:17 +00:00
|
|
|
XSizeHints* size_hints;
|
|
|
|
|
|
|
|
if ((size_hints = XAllocSizeHints()))
|
|
|
|
{
|
2006-03-27 20:16:04 +00:00
|
|
|
size_hints->flags = 0;
|
|
|
|
|
|
|
|
if (data->hwnd != GetDesktopWindow()) /* don't force position of desktop */
|
|
|
|
{
|
|
|
|
size_hints->win_gravity = StaticGravity;
|
|
|
|
size_hints->x = data->whole_rect.left;
|
|
|
|
size_hints->y = data->whole_rect.top;
|
|
|
|
size_hints->flags |= PWinGravity | PPosition;
|
|
|
|
}
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2005-01-17 19:17:47 +00:00
|
|
|
if ( !(style & WS_THICKFRAME) )
|
2001-06-04 21:55:17 +00: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;
|
|
|
|
size_hints->min_width = size_hints->max_width;
|
|
|
|
size_hints->min_height = size_hints->max_height;
|
|
|
|
size_hints->flags |= PMinSize | PMaxSize;
|
|
|
|
}
|
|
|
|
XSetWMNormalHints( display, data->whole_window, size_hints );
|
|
|
|
XFree( size_hints );
|
|
|
|
}
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-01 16:16:00 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* get_process_name
|
|
|
|
*
|
|
|
|
* get the name of the current process for setting class hints
|
|
|
|
*/
|
|
|
|
static char *get_process_name(void)
|
|
|
|
{
|
|
|
|
static char *name;
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
{
|
|
|
|
WCHAR module[MAX_PATH];
|
|
|
|
DWORD len = GetModuleFileNameW( 0, module, MAX_PATH );
|
|
|
|
if (len && len < MAX_PATH)
|
|
|
|
{
|
|
|
|
char *ptr;
|
|
|
|
WCHAR *p, *appname = module;
|
|
|
|
|
|
|
|
if ((p = strrchrW( appname, '/' ))) appname = p + 1;
|
|
|
|
if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
|
|
|
|
len = WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, NULL, 0, NULL, NULL );
|
|
|
|
if ((ptr = HeapAlloc( GetProcessHeap(), 0, len )))
|
|
|
|
{
|
|
|
|
WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, ptr, len, NULL, NULL );
|
|
|
|
name = ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 12:04:36 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* set_initial_wm_hints
|
|
|
|
*
|
|
|
|
* Set the window manager hints that don't change over the lifetime of a window.
|
|
|
|
*/
|
|
|
|
static void set_initial_wm_hints( Display *display, struct x11drv_win_data *data )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
Atom protocols[3];
|
|
|
|
Atom dndVersion = 4;
|
|
|
|
XClassHint *class_hints;
|
|
|
|
char *process_name = get_process_name();
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
|
|
|
|
/* wm protocols */
|
|
|
|
i = 0;
|
|
|
|
protocols[i++] = x11drv_atom(WM_DELETE_WINDOW);
|
|
|
|
protocols[i++] = x11drv_atom(_NET_WM_PING);
|
|
|
|
if (use_take_focus) protocols[i++] = x11drv_atom(WM_TAKE_FOCUS);
|
|
|
|
XChangeProperty( display, data->whole_window, x11drv_atom(WM_PROTOCOLS),
|
|
|
|
XA_ATOM, 32, PropModeReplace, (unsigned char *)protocols, i );
|
|
|
|
|
|
|
|
/* class hints */
|
|
|
|
if ((class_hints = XAllocClassHint()))
|
|
|
|
{
|
|
|
|
static char wine[] = "Wine";
|
|
|
|
|
|
|
|
class_hints->res_name = process_name;
|
|
|
|
class_hints->res_class = wine;
|
|
|
|
XSetClassHint( display, data->whole_window, class_hints );
|
|
|
|
XFree( class_hints );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the WM_CLIENT_MACHINE and WM_LOCALE_NAME properties */
|
|
|
|
XSetWMProperties(display, data->whole_window, NULL, NULL, NULL, 0, NULL, NULL, NULL);
|
|
|
|
/* set the pid. together, these properties are needed so the window manager can kill us if we freeze */
|
|
|
|
i = getpid();
|
|
|
|
XChangeProperty(display, data->whole_window, x11drv_atom(_NET_WM_PID),
|
|
|
|
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&i, 1);
|
|
|
|
|
|
|
|
XChangeProperty( display, data->whole_window, x11drv_atom(XdndAware),
|
|
|
|
XA_ATOM, 32, PropModeReplace, (unsigned char*)&dndVersion, 1 );
|
|
|
|
|
2008-01-22 09:17:52 +00:00
|
|
|
data->wm_hints = XAllocWMHints();
|
2007-08-20 12:04:36 +00:00
|
|
|
wine_tsx11_unlock();
|
2008-01-18 13:34:57 +00:00
|
|
|
|
|
|
|
if (data->wm_hints)
|
|
|
|
{
|
2008-01-23 15:40:54 +00:00
|
|
|
HICON icon = (HICON)SendMessageW( data->hwnd, WM_GETICON, ICON_BIG, 0 );
|
|
|
|
if (!icon) icon = (HICON)GetClassLongPtrW( data->hwnd, GCLP_HICON );
|
2008-01-18 13:34:57 +00:00
|
|
|
data->wm_hints->flags = 0;
|
2008-01-23 15:40:54 +00:00
|
|
|
set_icon_hints( display, data, icon );
|
2008-01-18 13:34:57 +00:00
|
|
|
}
|
2007-08-20 12:04:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
/***********************************************************************
|
2002-08-20 00:36:45 +00:00
|
|
|
* X11DRV_set_wm_hints
|
2001-06-04 21:55:17 +00:00
|
|
|
*
|
|
|
|
* Set the window manager hints for a newly-created window
|
2001-04-24 23:28:52 +00:00
|
|
|
*/
|
2005-01-17 19:17:47 +00:00
|
|
|
void X11DRV_set_wm_hints( Display *display, struct x11drv_win_data *data )
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2001-06-04 21:55:17 +00:00
|
|
|
Window group_leader;
|
2006-10-11 15:32:22 +00:00
|
|
|
Atom window_type;
|
2003-11-20 04:24:18 +00:00
|
|
|
MwmHints mwm_hints;
|
2005-01-17 19:17:47 +00:00
|
|
|
DWORD style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
|
|
|
DWORD ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
|
|
|
|
HWND owner = GetWindow( data->hwnd, GW_OWNER );
|
|
|
|
|
2006-03-27 20:16:04 +00:00
|
|
|
if (data->hwnd == GetDesktopWindow())
|
|
|
|
{
|
|
|
|
/* force some styles for the desktop to get the correct decorations */
|
|
|
|
style |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
|
|
|
|
owner = 0;
|
|
|
|
}
|
|
|
|
|
2005-01-17 19:17:47 +00:00
|
|
|
/* transient for hint */
|
|
|
|
if (owner)
|
|
|
|
{
|
|
|
|
Window owner_win = X11DRV_get_whole_window( owner );
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XSetTransientForHint( display, data->whole_window, owner_win );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
group_leader = owner_win;
|
|
|
|
}
|
|
|
|
else group_leader = data->whole_window;
|
2001-06-04 21:55:17 +00:00
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
|
|
|
|
/* size hints */
|
2005-01-17 19:17:47 +00:00
|
|
|
set_size_hints( display, data, style );
|
2002-01-21 18:41:27 +00:00
|
|
|
|
2006-10-11 15:32:22 +00:00
|
|
|
/* set the WM_WINDOW_TYPE */
|
|
|
|
window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_NORMAL);
|
|
|
|
if (ex_style & WS_EX_TOOLWINDOW) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_UTILITY);
|
|
|
|
else if (style & WS_THICKFRAME) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_NORMAL);
|
|
|
|
else if (style & WS_DLGFRAME) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_DIALOG);
|
|
|
|
else if (ex_style & WS_EX_DLGMODALFRAME) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_DIALOG);
|
|
|
|
|
|
|
|
XChangeProperty(display, data->whole_window, x11drv_atom(_NET_WM_WINDOW_TYPE),
|
|
|
|
XA_ATOM, 32, PropModeReplace, (unsigned char*)&window_type, 1);
|
2003-12-04 21:54:13 +00:00
|
|
|
|
2003-11-20 04:24:18 +00:00
|
|
|
mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
2007-10-11 10:24:27 +00:00
|
|
|
mwm_hints.decorations = get_mwm_decorations( style, ex_style );
|
2006-10-05 14:16:36 +00:00
|
|
|
mwm_hints.functions = MWM_FUNC_MOVE;
|
2007-08-29 10:02:57 +00:00
|
|
|
if (style & WS_THICKFRAME) mwm_hints.functions |= MWM_FUNC_RESIZE;
|
2005-01-17 19:17:47 +00:00
|
|
|
if (style & WS_MINIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MINIMIZE;
|
|
|
|
if (style & WS_MAXIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MAXIMIZE;
|
2007-08-29 10:02:57 +00:00
|
|
|
if (style & WS_SYSMENU) mwm_hints.functions |= MWM_FUNC_CLOSE;
|
2003-11-20 04:24:18 +00:00
|
|
|
|
|
|
|
XChangeProperty( display, data->whole_window, x11drv_atom(_MOTIF_WM_HINTS),
|
|
|
|
x11drv_atom(_MOTIF_WM_HINTS), 32, PropModeReplace,
|
2005-03-22 21:17:34 +00:00
|
|
|
(unsigned char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2001-07-12 02:49:31 +00:00
|
|
|
/* wm hints */
|
2007-08-16 21:27:37 +00:00
|
|
|
if (data->wm_hints)
|
2001-07-12 02:49:31 +00:00
|
|
|
{
|
2008-01-18 13:34:57 +00:00
|
|
|
data->wm_hints->flags |= InputHint | StateHint | WindowGroupHint;
|
2007-08-16 21:27:37 +00:00
|
|
|
data->wm_hints->input = !(style & WS_DISABLED);
|
|
|
|
data->wm_hints->initial_state = (style & WS_MINIMIZE) ? IconicState : NormalState;
|
|
|
|
data->wm_hints->window_group = group_leader;
|
|
|
|
XSetWMHints( display, data->whole_window, data->wm_hints );
|
2001-07-12 02:49:31 +00:00
|
|
|
}
|
2008-01-18 13:34:57 +00:00
|
|
|
|
|
|
|
wine_tsx11_unlock();
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_set_iconic_state
|
|
|
|
*
|
|
|
|
* Set the X11 iconic state according to the window style.
|
2001-04-24 23:28:52 +00:00
|
|
|
*/
|
2005-01-17 19:17:47 +00:00
|
|
|
void X11DRV_set_iconic_state( HWND hwnd )
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2001-05-16 19:52:29 +00:00
|
|
|
Display *display = thread_display();
|
2005-01-17 19:17:47 +00:00
|
|
|
struct x11drv_win_data *data;
|
|
|
|
RECT rect;
|
|
|
|
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
BOOL iconic = (style & WS_MINIMIZE) != 0;
|
|
|
|
|
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
2008-01-24 09:20:11 +00:00
|
|
|
if (!data->whole_window) return;
|
2005-01-17 19:17:47 +00:00
|
|
|
|
|
|
|
GetWindowRect( hwnd, &rect );
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
wine_tsx11_lock();
|
|
|
|
|
2007-08-16 21:27:37 +00:00
|
|
|
if (data->wm_hints)
|
|
|
|
{
|
|
|
|
data->wm_hints->flags |= StateHint | IconPositionHint;
|
|
|
|
data->wm_hints->initial_state = iconic ? IconicState : NormalState;
|
|
|
|
data->wm_hints->icon_x = rect.left - virtual_screen_rect.left;
|
|
|
|
data->wm_hints->icon_y = rect.top - virtual_screen_rect.top;
|
|
|
|
XSetWMHints( display, data->whole_window, data->wm_hints );
|
|
|
|
}
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2008-01-23 11:28:32 +00:00
|
|
|
if (data->mapped)
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2001-06-04 21:55:17 +00:00
|
|
|
if (iconic)
|
|
|
|
XIconifyWindow( display, data->whole_window, DefaultScreen(display) );
|
|
|
|
else
|
2005-01-17 19:17:47 +00:00
|
|
|
if (X11DRV_is_window_rect_mapped( &rect ))
|
2004-04-27 23:32:01 +00:00
|
|
|
XMapWindow( display, data->whole_window );
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_window_to_X_rect
|
|
|
|
*
|
|
|
|
* Convert a rect from client to X window coordinates
|
|
|
|
*/
|
2005-02-01 18:53:59 +00:00
|
|
|
void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect )
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
2001-07-20 18:37:37 +00:00
|
|
|
RECT rc;
|
|
|
|
|
2005-02-01 18:53:59 +00:00
|
|
|
if (!data->managed) return;
|
2001-06-04 21:55:17 +00:00
|
|
|
if (IsRectEmpty( rect )) return;
|
|
|
|
|
2007-10-11 10:24:27 +00:00
|
|
|
get_x11_rect_offset( data, &rc );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2001-07-20 18:37:37 +00:00
|
|
|
rect->left -= rc.left;
|
|
|
|
rect->right -= rc.right;
|
|
|
|
rect->top -= rc.top;
|
|
|
|
rect->bottom -= rc.bottom;
|
2001-06-04 21:55:17 +00:00
|
|
|
if (rect->top >= rect->bottom) rect->bottom = rect->top + 1;
|
|
|
|
if (rect->left >= rect->right) rect->right = rect->left + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_X_to_window_rect
|
|
|
|
*
|
|
|
|
* Opposite of X11DRV_window_to_X_rect
|
|
|
|
*/
|
2005-02-01 18:53:59 +00:00
|
|
|
void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect )
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
2007-10-11 10:24:27 +00:00
|
|
|
RECT rc;
|
2007-08-29 10:02:57 +00:00
|
|
|
|
2005-02-01 18:53:59 +00:00
|
|
|
if (!data->managed) return;
|
2001-06-04 21:55:17 +00:00
|
|
|
if (IsRectEmpty( rect )) return;
|
|
|
|
|
2007-10-11 10:24:27 +00:00
|
|
|
get_x11_rect_offset( data, &rc );
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2007-10-11 10:24:27 +00:00
|
|
|
rect->left += rc.left;
|
|
|
|
rect->right += rc.right;
|
|
|
|
rect->top += rc.top;
|
|
|
|
rect->bottom += rc.bottom;
|
2001-06-04 21:55:17 +00:00
|
|
|
if (rect->top >= rect->bottom) rect->bottom = rect->top + 1;
|
|
|
|
if (rect->left >= rect->right) rect->right = rect->left + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-01-31 16:34:07 +00:00
|
|
|
* X11DRV_sync_window_position
|
2001-06-04 21:55:17 +00:00
|
|
|
*
|
2005-01-31 16:34:07 +00:00
|
|
|
* Synchronize the X window position with the Windows one
|
2001-06-04 21:55:17 +00:00
|
|
|
*/
|
2005-01-31 16:34:07 +00:00
|
|
|
void X11DRV_sync_window_position( Display *display, struct x11drv_win_data *data,
|
2008-01-23 11:28:01 +00:00
|
|
|
UINT swp_flags, const RECT *old_client_rect,
|
|
|
|
const RECT *old_whole_rect )
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
|
|
|
XWindowChanges changes;
|
2008-01-23 11:28:12 +00:00
|
|
|
int mask = get_window_changes( &changes, old_whole_rect, &data->whole_rect );
|
2005-01-31 16:34:07 +00:00
|
|
|
|
|
|
|
if (!(swp_flags & SWP_NOZORDER))
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
2005-01-31 16:34:07 +00: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-24 23:28:52 +00:00
|
|
|
{
|
2005-01-31 16:34:07 +00:00
|
|
|
changes.stack_mode = Above;
|
|
|
|
mask |= CWStackMode;
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-31 16:34:07 +00:00
|
|
|
/* should use stack_mode Below but most window managers don't get it right */
|
|
|
|
/* so move it above the next one in Z order */
|
2005-01-17 19:17:47 +00:00
|
|
|
HWND next = GetWindow( data->hwnd, GW_HWNDNEXT );
|
2005-01-31 16:34:07 +00:00
|
|
|
while (next && !(GetWindowLongW( next, GWL_STYLE ) & WS_VISIBLE))
|
|
|
|
next = GetWindow( next, GW_HWNDNEXT );
|
|
|
|
if (next)
|
2003-05-19 19:08:57 +00:00
|
|
|
{
|
|
|
|
changes.stack_mode = Above;
|
|
|
|
changes.sibling = X11DRV_get_whole_window(next);
|
|
|
|
mask |= CWStackMode | CWSibling;
|
|
|
|
}
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
2001-06-04 21:55:17 +00:00
|
|
|
}
|
|
|
|
|
2008-01-17 18:53:59 +00:00
|
|
|
/* only the size is allowed to change for the desktop window */
|
|
|
|
if (data->whole_window == root_window) mask &= CWWidth | CWHeight;
|
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
if (mask)
|
|
|
|
{
|
2005-01-31 16:34:07 +00:00
|
|
|
DWORD style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2006-10-07 23:34:01 +00:00
|
|
|
TRACE( "setting win %lx pos %d,%d,%dx%d after %lx changes=%x\n",
|
2005-01-31 16:34:07 +00:00
|
|
|
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 );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
|
|
|
wine_tsx11_lock();
|
2005-01-31 16:34:07 +00:00
|
|
|
if (mask & (CWWidth|CWHeight)) set_size_hints( display, data, style );
|
2006-10-26 10:53:59 +00:00
|
|
|
if (mask & CWX) changes.x -= virtual_screen_rect.left;
|
|
|
|
if (mask & CWY) changes.y -= virtual_screen_rect.top;
|
2005-01-31 16:34:07 +00:00
|
|
|
XReconfigureWMWindow( display, data->whole_window,
|
|
|
|
DefaultScreen(display), mask, &changes );
|
2001-05-16 19:52:29 +00:00
|
|
|
wine_tsx11_unlock();
|
2001-06-04 21:55:17 +00:00
|
|
|
}
|
|
|
|
}
|
2001-05-16 19:52:29 +00:00
|
|
|
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* create_whole_window
|
|
|
|
*
|
|
|
|
* Create the whole X window for a given window
|
|
|
|
*/
|
2008-01-23 20:39:32 +00:00
|
|
|
static Window create_whole_window( Display *display, struct x11drv_win_data *data )
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
|
|
|
int cx, cy, mask;
|
|
|
|
XSetWindowAttributes attr;
|
2005-01-31 16:34:07 +00:00
|
|
|
XIM xim;
|
2008-01-23 15:32:55 +00:00
|
|
|
WCHAR text[1024];
|
2008-01-23 15:30:18 +00:00
|
|
|
HRGN hrgn;
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2007-08-20 20:06:33 +00:00
|
|
|
if (!(cx = data->window_rect.right - data->window_rect.left)) cx = 1;
|
|
|
|
if (!(cy = data->window_rect.bottom - data->window_rect.top)) cy = 1;
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2006-03-27 13:33:43 +00:00
|
|
|
mask = get_window_attributes( display, data, &attr );
|
2001-06-12 04:02:10 +00:00
|
|
|
|
2005-01-17 19:17:47 +00:00
|
|
|
wine_tsx11_lock();
|
|
|
|
|
2007-08-20 20:06:33 +00:00
|
|
|
data->whole_rect = data->window_rect;
|
2006-10-26 10:53:59 +00:00
|
|
|
data->whole_window = XCreateWindow( display, root_window,
|
2007-08-20 20:06:33 +00:00
|
|
|
data->window_rect.left - virtual_screen_rect.left,
|
|
|
|
data->window_rect.top - virtual_screen_rect.top,
|
2006-10-26 10:53:59 +00:00
|
|
|
cx, cy, 0, screen_depth, InputOutput,
|
|
|
|
visual, mask, &attr );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2001-07-12 02:49:31 +00:00
|
|
|
if (!data->whole_window)
|
|
|
|
{
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
return 0;
|
|
|
|
}
|
2005-01-28 17:25:50 +00:00
|
|
|
XSaveContext( display, data->whole_window, winContext, (char *)data->hwnd );
|
2001-07-12 02:49:31 +00:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
|
2005-01-31 16:34:07 +00:00
|
|
|
xim = x11drv_thread_data()->xim;
|
|
|
|
if (xim) data->xic = X11DRV_CreateIC( xim, display, data->whole_window );
|
|
|
|
|
2007-08-20 12:04:36 +00:00
|
|
|
set_initial_wm_hints( display, data );
|
2005-01-31 16:34:07 +00:00
|
|
|
X11DRV_set_wm_hints( display, data );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2005-07-07 17:30:57 +00:00
|
|
|
SetPropA( data->hwnd, whole_window_prop, (HANDLE)data->whole_window );
|
2008-01-23 15:30:18 +00:00
|
|
|
|
2008-01-23 15:32:55 +00:00
|
|
|
/* set the window text */
|
|
|
|
if (!InternalGetWindowText( data->hwnd, text, sizeof(text)/sizeof(WCHAR) )) text[0] = 0;
|
|
|
|
sync_window_text( display, data->whole_window, text );
|
|
|
|
|
2008-01-23 15:30:18 +00:00
|
|
|
/* set the window region */
|
|
|
|
if ((hrgn = CreateRectRgn( 0, 0, 0, 0 )))
|
|
|
|
{
|
|
|
|
if (GetWindowRgn( data->hwnd, hrgn ) != ERROR) sync_window_region( display, data, hrgn );
|
|
|
|
DeleteObject( hrgn );
|
|
|
|
}
|
2001-06-04 21:55:17 +00:00
|
|
|
return data->whole_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2005-01-31 16:34:07 +00:00
|
|
|
* destroy_whole_window
|
2001-06-04 21:55:17 +00:00
|
|
|
*
|
2005-01-31 16:34:07 +00:00
|
|
|
* Destroy the whole X window for a given window.
|
2001-06-04 21:55:17 +00:00
|
|
|
*/
|
2005-01-31 16:34:07 +00:00
|
|
|
static void destroy_whole_window( Display *display, struct x11drv_win_data *data )
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
2005-01-31 16:34:07 +00:00
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2005-01-31 16:34:07 +00:00
|
|
|
if (!data->whole_window) return;
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2005-01-31 16:34:07 +00:00
|
|
|
TRACE( "win %p xwin %lx\n", data->hwnd, data->whole_window );
|
|
|
|
if (thread_data->cursor_window == data->whole_window) thread_data->cursor_window = None;
|
2001-06-12 04:02:10 +00:00
|
|
|
wine_tsx11_lock();
|
2005-01-31 16:34:07 +00:00
|
|
|
XDeleteContext( display, data->whole_window, winContext );
|
2008-01-24 09:20:11 +00:00
|
|
|
XDestroyWindow( display, data->whole_window );
|
2005-01-31 16:34:07 +00:00
|
|
|
data->whole_window = 0;
|
|
|
|
if (data->xic)
|
|
|
|
{
|
|
|
|
XUnsetICFocus( data->xic );
|
|
|
|
XDestroyIC( data->xic );
|
|
|
|
}
|
2006-05-09 15:32:40 +00:00
|
|
|
/* Outlook stops processing messages after destroying a dialog, so we need an explicit flush */
|
|
|
|
XFlush( display );
|
2008-01-22 09:17:52 +00:00
|
|
|
XFree( data->wm_hints );
|
|
|
|
data->wm_hints = NULL;
|
2001-06-12 04:02:10 +00:00
|
|
|
wine_tsx11_unlock();
|
2005-07-07 17:30:57 +00:00
|
|
|
RemovePropA( data->hwnd, whole_window_prop );
|
2001-06-04 21:55:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* SetWindowText (X11DRV.@)
|
|
|
|
*/
|
2005-07-18 13:20:18 +00:00
|
|
|
void X11DRV_SetWindowText( HWND hwnd, LPCWSTR text )
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
|
|
|
Display *display = thread_display();
|
|
|
|
Window win;
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2006-03-28 10:21:37 +00:00
|
|
|
if ((win = X11DRV_get_whole_window( hwnd )) && win != DefaultRootWindow(display))
|
2008-01-23 15:32:55 +00:00
|
|
|
sync_window_text( display, win, text );
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DestroyWindow (X11DRV.@)
|
|
|
|
*/
|
2005-07-18 13:20:18 +00:00
|
|
|
void X11DRV_DestroyWindow( HWND hwnd )
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2002-06-14 00:08:40 +00:00
|
|
|
struct x11drv_thread_data *thread_data = x11drv_thread_data();
|
|
|
|
Display *display = thread_data->display;
|
2005-01-28 17:25:50 +00:00
|
|
|
struct x11drv_win_data *data;
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2005-07-18 13:20:18 +00:00
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2007-09-26 15:17:13 +00:00
|
|
|
if (data->pixmap)
|
|
|
|
{
|
|
|
|
destroy_glxpixmap(display, data->gl_drawable);
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XFreePixmap(display, data->pixmap);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
else if (data->gl_drawable)
|
2007-09-26 05:43:38 +00:00
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XDestroyWindow(display, data->gl_drawable);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
2005-03-25 16:47:04 +00:00
|
|
|
free_window_dce( data );
|
2005-01-31 16:34:07 +00:00
|
|
|
destroy_whole_window( display, data );
|
|
|
|
destroy_icon_window( display, data );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2005-01-31 16:34:07 +00:00
|
|
|
if (thread_data->last_focus == hwnd) thread_data->last_focus = 0;
|
2001-06-04 21:55:17 +00:00
|
|
|
if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap );
|
|
|
|
if (data->hWMIconMask) DeleteObject( data->hWMIconMask);
|
2005-01-28 17:25:50 +00:00
|
|
|
wine_tsx11_lock();
|
2005-02-09 14:01:40 +00:00
|
|
|
XDeleteContext( display, (XID)hwnd, win_data_context );
|
2005-01-28 17:25:50 +00:00
|
|
|
wine_tsx11_unlock();
|
2001-04-24 23:28:52 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-07 20:33:29 +00:00
|
|
|
static struct x11drv_win_data *alloc_win_data( Display *display, HWND hwnd )
|
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
2008-01-22 09:15:38 +00:00
|
|
|
if ((data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data))))
|
2005-07-07 20:33:29 +00:00
|
|
|
{
|
2008-01-22 09:15:38 +00:00
|
|
|
data->hwnd = hwnd;
|
2005-07-07 20:33:29 +00:00
|
|
|
wine_tsx11_lock();
|
|
|
|
if (!winContext) winContext = XUniqueContext();
|
|
|
|
if (!win_data_context) win_data_context = XUniqueContext();
|
|
|
|
XSaveContext( display, (XID)hwnd, win_data_context, (char *)data );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-17 18:53:59 +00:00
|
|
|
/* initialize the desktop window id in the desktop manager process */
|
2008-01-24 09:20:11 +00:00
|
|
|
static struct x11drv_win_data *create_desktop_win_data( Display *display, HWND hwnd )
|
2006-03-27 20:43:03 +00:00
|
|
|
{
|
2008-01-24 09:20:11 +00:00
|
|
|
struct x11drv_win_data *data;
|
|
|
|
VisualID visualid;
|
2006-03-27 20:43:03 +00:00
|
|
|
|
2008-01-24 09:20:11 +00:00
|
|
|
if (!(data = alloc_win_data( display, hwnd ))) return NULL;
|
|
|
|
wine_tsx11_lock();
|
|
|
|
visualid = XVisualIDFromVisual(visual);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
data->whole_window = root_window;
|
|
|
|
data->managed = TRUE;
|
|
|
|
SetPropA( data->hwnd, managed_prop, (HANDLE)1 );
|
|
|
|
SetPropA( data->hwnd, whole_window_prop, (HANDLE)root_window );
|
|
|
|
SetPropA( data->hwnd, visual_id_prop, (HANDLE)visualid );
|
|
|
|
set_initial_wm_hints( display, data );
|
|
|
|
return data;
|
2006-03-27 20:43:03 +00:00
|
|
|
}
|
|
|
|
|
2005-07-07 20:33:29 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* CreateDesktopWindow (X11DRV.@)
|
|
|
|
*/
|
|
|
|
BOOL X11DRV_CreateDesktopWindow( HWND hwnd )
|
|
|
|
{
|
2008-01-17 18:53:59 +00:00
|
|
|
unsigned int width, height;
|
2005-07-07 20:33:29 +00:00
|
|
|
|
2008-01-17 18:53:59 +00:00
|
|
|
/* retrieve the real size of the desktop */
|
|
|
|
SERVER_START_REQ( get_window_rectangles )
|
|
|
|
{
|
|
|
|
req->handle = hwnd;
|
|
|
|
wine_server_call( req );
|
|
|
|
width = reply->window.right - reply->window.left;
|
|
|
|
height = reply->window.bottom - reply->window.top;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2005-07-07 20:33:29 +00:00
|
|
|
|
2008-01-17 18:53:59 +00:00
|
|
|
if (!width && !height) /* not initialized yet */
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( set_window_pos )
|
|
|
|
{
|
|
|
|
req->handle = hwnd;
|
|
|
|
req->previous = 0;
|
|
|
|
req->flags = SWP_NOZORDER;
|
|
|
|
req->window.left = virtual_screen_rect.left;
|
|
|
|
req->window.top = virtual_screen_rect.top;
|
|
|
|
req->window.right = virtual_screen_rect.right;
|
|
|
|
req->window.bottom = virtual_screen_rect.bottom;
|
|
|
|
req->client = req->window;
|
|
|
|
wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Window win = (Window)GetPropA( hwnd, whole_window_prop );
|
|
|
|
if (win && win != root_window) X11DRV_init_desktop( win, width, height );
|
|
|
|
}
|
2005-07-07 20:33:29 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* CreateWindow (X11DRV.@)
|
|
|
|
*/
|
2001-06-06 21:26:50 +00:00
|
|
|
BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
|
|
|
Display *display = thread_display();
|
|
|
|
WND *wndPtr;
|
2005-07-07 20:33:29 +00:00
|
|
|
HWND insert_after;
|
2001-06-12 04:02:10 +00:00
|
|
|
RECT rect;
|
2005-01-17 19:17:47 +00:00
|
|
|
DWORD style;
|
2002-10-29 00:41:42 +00:00
|
|
|
CBT_CREATEWNDA cbtc;
|
2005-03-23 10:26:15 +00:00
|
|
|
CREATESTRUCTA cbcs;
|
2001-06-04 21:55:17 +00:00
|
|
|
BOOL ret = FALSE;
|
2008-01-22 09:16:19 +00:00
|
|
|
INT cx = cs->cx, cy = cs->cy;
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2008-01-24 09:20:51 +00:00
|
|
|
if (hwnd == GetDesktopWindow() && root_window != DefaultRootWindow( display ))
|
2008-01-24 09:20:11 +00:00
|
|
|
{
|
2008-01-24 09:20:51 +00:00
|
|
|
/* the desktop win data can't be created lazily */
|
|
|
|
if (!create_desktop_win_data( display, hwnd )) return FALSE;
|
2006-03-27 20:43:03 +00:00
|
|
|
}
|
2001-06-26 21:10:11 +00:00
|
|
|
|
2002-01-09 19:09:06 +00:00
|
|
|
/* Call the WH_CBT hook */
|
2005-03-25 16:47:04 +00:00
|
|
|
|
2005-03-23 10:26:15 +00:00
|
|
|
/* the window style passed to the hook must be the real window style,
|
|
|
|
* rather than just the window style that the caller to CreateWindowEx
|
|
|
|
* passed in, so we have to copy the original CREATESTRUCT and get the
|
|
|
|
* the real style. */
|
|
|
|
cbcs = *cs;
|
|
|
|
cbcs.style = GetWindowLongW(hwnd, GWL_STYLE);
|
|
|
|
|
|
|
|
cbtc.lpcs = &cbcs;
|
2003-10-24 04:21:46 +00:00
|
|
|
cbtc.hwndInsertAfter = HWND_TOP;
|
2002-10-29 00:41:42 +00:00
|
|
|
if (HOOK_CallHooks( WH_CBT, HCBT_CREATEWND, (WPARAM)hwnd, (LPARAM)&cbtc, unicode ))
|
2002-01-09 19:09:06 +00:00
|
|
|
{
|
2002-10-29 00:41:42 +00:00
|
|
|
TRACE("CBT-hook returned !0\n");
|
|
|
|
goto failed;
|
2002-01-09 19:09:06 +00:00
|
|
|
}
|
|
|
|
|
2001-10-22 19:08:33 +00:00
|
|
|
/* Send the WM_GETMINMAXINFO message and fix the size if needed */
|
|
|
|
if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
|
|
|
|
{
|
|
|
|
POINT maxSize, maxPos, minTrack, maxTrack;
|
2007-04-08 10:28:05 +00:00
|
|
|
|
2001-10-22 19:08:33 +00:00
|
|
|
WINPOS_GetMinMaxInfo( hwnd, &maxSize, &maxPos, &minTrack, &maxTrack);
|
2008-01-22 09:16:19 +00:00
|
|
|
if (maxTrack.x < cx) cx = maxTrack.x;
|
|
|
|
if (maxTrack.y < cy) cy = maxTrack.y;
|
2001-10-22 19:08:33 +00:00
|
|
|
}
|
|
|
|
|
2008-01-22 09:16:19 +00:00
|
|
|
if (cx < 0) cx = 0;
|
|
|
|
if (cy < 0) cy = 0;
|
|
|
|
SetRect( &rect, cs->x, cs->y, cs->x + cx, cs->y + cy );
|
|
|
|
if (!X11DRV_SetWindowPos( hwnd, 0, &rect, &rect, SWP_NOZORDER | SWP_NOACTIVATE, NULL ))
|
|
|
|
return FALSE;
|
|
|
|
|
2001-06-12 04:02:10 +00:00
|
|
|
/* send WM_NCCREATE */
|
2002-10-31 02:38:20 +00:00
|
|
|
TRACE( "hwnd %p cs %d,%d %dx%d\n", hwnd, cs->x, cs->y, cs->cx, cs->cy );
|
2001-06-06 21:26:50 +00:00
|
|
|
if (unicode)
|
2001-06-04 21:55:17 +00:00
|
|
|
ret = SendMessageW( hwnd, WM_NCCREATE, 0, (LPARAM)cs );
|
|
|
|
else
|
|
|
|
ret = SendMessageA( hwnd, WM_NCCREATE, 0, (LPARAM)cs );
|
2001-06-08 19:00:56 +00:00
|
|
|
if (!ret)
|
|
|
|
{
|
2001-10-22 19:08:33 +00:00
|
|
|
WARN("aborted by WM_xxCREATE!\n");
|
2001-06-08 19:00:56 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2005-01-17 19:17:47 +00:00
|
|
|
/* make sure the window is still valid */
|
2008-01-24 09:20:11 +00:00
|
|
|
if (!(wndPtr = WIN_GetPtr(hwnd))) return FALSE;
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2001-06-12 04:02:10 +00:00
|
|
|
/* send WM_NCCALCSIZE */
|
2008-01-24 09:20:11 +00:00
|
|
|
rect = wndPtr->rectWindow;
|
|
|
|
WIN_ReleasePtr( wndPtr );
|
2001-06-12 04:02:10 +00:00
|
|
|
SendMessageW( hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rect );
|
2001-10-22 19:08:33 +00:00
|
|
|
|
|
|
|
if (!(wndPtr = WIN_GetPtr(hwnd))) return FALSE;
|
2004-12-07 17:31:53 +00:00
|
|
|
|
|
|
|
/* yes, even if the CBT hook was called with HWND_TOP */
|
2007-01-04 14:32:05 +00:00
|
|
|
insert_after = (wndPtr->dwStyle & WS_CHILD) ? HWND_BOTTOM : HWND_TOP;
|
2004-12-07 17:31:53 +00:00
|
|
|
|
2007-08-20 20:06:50 +00:00
|
|
|
X11DRV_SetWindowPos( hwnd, insert_after, &wndPtr->rectWindow, &rect, SWP_NOACTIVATE, NULL );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2001-10-22 19:08:33 +00:00
|
|
|
WIN_ReleasePtr( wndPtr );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2001-06-06 21:26:50 +00:00
|
|
|
if (unicode)
|
2001-06-04 21:55:17 +00:00
|
|
|
ret = (SendMessageW( hwnd, WM_CREATE, 0, (LPARAM)cs ) != -1);
|
|
|
|
else
|
|
|
|
ret = (SendMessageA( hwnd, WM_CREATE, 0, (LPARAM)cs ) != -1);
|
|
|
|
|
2005-03-25 10:38:56 +00:00
|
|
|
if (!ret) return FALSE;
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2005-02-03 16:40:20 +00:00
|
|
|
NotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_WINDOW, 0);
|
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
/* Send the size messages */
|
|
|
|
|
2005-01-20 20:07:42 +00:00
|
|
|
if (!(wndPtr = WIN_GetPtr(hwnd)) || wndPtr == WND_OTHER_PROCESS) return FALSE;
|
2001-06-04 21:55:17 +00:00
|
|
|
if (!(wndPtr->flags & WIN_NEED_SIZE))
|
|
|
|
{
|
2005-01-20 20:07:42 +00:00
|
|
|
RECT rect = wndPtr->rectClient;
|
|
|
|
WIN_ReleasePtr( wndPtr );
|
2001-06-04 21:55:17 +00:00
|
|
|
/* send it anyway */
|
2005-01-20 20:07:42 +00:00
|
|
|
if (((rect.right-rect.left) <0) ||((rect.bottom-rect.top)<0))
|
2006-10-07 23:34:01 +00:00
|
|
|
WARN("sending bogus WM_SIZE message 0x%08x\n",
|
2005-01-20 20:07:42 +00:00
|
|
|
MAKELONG(rect.right-rect.left, rect.bottom-rect.top));
|
2001-06-04 21:55:17 +00:00
|
|
|
SendMessageW( hwnd, WM_SIZE, SIZE_RESTORED,
|
2005-01-20 20:07:42 +00:00
|
|
|
MAKELONG(rect.right-rect.left, rect.bottom-rect.top));
|
|
|
|
SendMessageW( hwnd, WM_MOVE, 0, MAKELONG( rect.left, rect.top ) );
|
2001-06-04 21:55:17 +00:00
|
|
|
}
|
2005-01-20 20:07:42 +00:00
|
|
|
else WIN_ReleasePtr( wndPtr );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
|
|
|
/* Show the window, maximizing or minimizing if needed */
|
|
|
|
|
2005-01-17 19:17:47 +00:00
|
|
|
style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
if (style & (WS_MINIMIZE | WS_MAXIMIZE))
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
|
|
|
extern UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect ); /*FIXME*/
|
|
|
|
|
|
|
|
RECT newPos;
|
2005-01-17 19:17:47 +00:00
|
|
|
UINT swFlag = (style & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
|
2005-01-21 10:32:13 +00:00
|
|
|
WIN_SetStyle( hwnd, 0, WS_MAXIMIZE | WS_MINIMIZE );
|
2006-12-19 11:35:42 +00:00
|
|
|
swFlag = WINPOS_MinMaximize( hwnd, swFlag, &newPos );
|
2005-11-30 11:32:22 +00:00
|
|
|
|
2006-12-19 11:35:42 +00:00
|
|
|
swFlag |= SWP_FRAMECHANGED; /* Frame always gets changed */
|
2005-11-30 11:32:22 +00:00
|
|
|
if (!(style & WS_VISIBLE) || (style & WS_CHILD) || GetActiveWindow()) swFlag |= SWP_NOACTIVATE;
|
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
SetWindowPos( hwnd, 0, newPos.left, newPos.top,
|
|
|
|
newPos.right, newPos.bottom, swFlag );
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
failed:
|
2001-10-22 19:08:33 +00:00
|
|
|
X11DRV_DestroyWindow( hwnd );
|
2001-06-04 21:55:17 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2005-01-17 19:17:47 +00:00
|
|
|
* X11DRV_get_win_data
|
2001-06-04 21:55:17 +00:00
|
|
|
*
|
2005-01-17 19:17:47 +00:00
|
|
|
* Return the X11 data structure associated with a window.
|
2001-06-04 21:55:17 +00:00
|
|
|
*/
|
2005-01-17 19:17:47 +00:00
|
|
|
struct x11drv_win_data *X11DRV_get_win_data( HWND hwnd )
|
2001-06-04 21:55:17 +00:00
|
|
|
{
|
2005-01-28 17:25:50 +00:00
|
|
|
char *data;
|
2005-02-09 14:01:40 +00:00
|
|
|
|
|
|
|
if (!hwnd || XFindContext( thread_display(), (XID)hwnd, win_data_context, &data )) data = NULL;
|
2005-01-28 17:25:50 +00:00
|
|
|
return (struct x11drv_win_data *)data;
|
2001-06-04 21:55:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-24 09:20:51 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_create_win_data
|
|
|
|
*
|
|
|
|
* Create an X11 data window structure for an existing window.
|
|
|
|
*/
|
|
|
|
struct x11drv_win_data *X11DRV_create_win_data( HWND hwnd )
|
|
|
|
{
|
|
|
|
Display *display = thread_display();
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
HWND parent;
|
|
|
|
|
|
|
|
if (!(parent = GetAncestor( hwnd, GA_PARENT ))) return NULL; /* desktop */
|
|
|
|
if (!(data = alloc_win_data( display, hwnd ))) return NULL;
|
|
|
|
|
|
|
|
GetWindowRect( hwnd, &data->window_rect );
|
|
|
|
MapWindowPoints( 0, parent, (POINT *)&data->window_rect, 2 );
|
|
|
|
data->whole_rect = data->window_rect;
|
|
|
|
GetClientRect( hwnd, &data->client_rect );
|
|
|
|
MapWindowPoints( hwnd, parent, (POINT *)&data->client_rect, 2 );
|
|
|
|
|
|
|
|
if (parent == GetDesktopWindow())
|
|
|
|
{
|
|
|
|
if (!create_whole_window( display, data ))
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
TRACE( "win %p/%lx window %s whole %s client %s\n",
|
|
|
|
hwnd, data->whole_window, wine_dbgstr_rect( &data->window_rect ),
|
|
|
|
wine_dbgstr_rect( &data->whole_rect ), wine_dbgstr_rect( &data->client_rect ));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get class or window DC if needed */
|
|
|
|
alloc_window_dce( data );
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 21:55:17 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_get_whole_window
|
|
|
|
*
|
|
|
|
* Return the X window associated with the full area of a window
|
|
|
|
*/
|
|
|
|
Window X11DRV_get_whole_window( HWND hwnd )
|
|
|
|
{
|
2005-01-17 19:17:47 +00:00
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
2001-10-15 17:56:45 +00:00
|
|
|
|
2008-01-17 18:53:59 +00:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
if (hwnd == GetDesktopWindow()) return root_window;
|
|
|
|
return (Window)GetPropA( hwnd, whole_window_prop );
|
|
|
|
}
|
2005-01-17 19:17:47 +00:00
|
|
|
return data->whole_window;
|
2001-06-04 21:55:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-15 20:02:32 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_get_fbconfig_id
|
|
|
|
*
|
|
|
|
* Return the GLXFBConfig ID of the drawable used by the window for
|
|
|
|
* OpenGL rendering. This is 0 for windows without a pixel format set.
|
|
|
|
*/
|
|
|
|
XID X11DRV_get_fbconfig_id( HWND hwnd )
|
|
|
|
{
|
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
|
|
|
|
|
|
|
if (!data) return (XID)GetPropA( hwnd, fbconfig_id_prop );
|
|
|
|
return data->fbconfig_id;
|
|
|
|
}
|
|
|
|
|
2007-09-25 17:20:58 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_get_gl_drawable
|
|
|
|
*
|
|
|
|
* Return the GL drawable for this window.
|
|
|
|
*/
|
|
|
|
Drawable X11DRV_get_gl_drawable( HWND hwnd )
|
|
|
|
{
|
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
|
|
|
|
|
|
|
if (!data) return (Drawable)GetPropA( hwnd, gl_drawable_prop );
|
|
|
|
return data->gl_drawable;
|
|
|
|
}
|
|
|
|
|
2007-09-26 15:17:13 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_get_gl_pixmap
|
|
|
|
*
|
|
|
|
* Return the Pixmap associated with the GL drawable (if any) for this window.
|
|
|
|
*/
|
|
|
|
Pixmap X11DRV_get_gl_pixmap( HWND hwnd )
|
|
|
|
{
|
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
|
|
|
|
|
|
|
if (!data) return (Pixmap)GetPropA( hwnd, pixmap_prop );
|
|
|
|
return data->pixmap;
|
|
|
|
}
|
|
|
|
|
2007-09-15 20:02:32 +00:00
|
|
|
|
2003-01-23 01:28:12 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_get_ic
|
|
|
|
*
|
|
|
|
* Return the X input context associated with a window
|
|
|
|
*/
|
|
|
|
XIC X11DRV_get_ic( HWND hwnd )
|
|
|
|
{
|
2005-01-17 19:17:47 +00:00
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
2003-01-23 01:28:12 +00:00
|
|
|
|
2005-01-17 19:17:47 +00:00
|
|
|
if (!data) return 0;
|
|
|
|
return data->xic;
|
2003-01-23 01:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-24 23:28:52 +00:00
|
|
|
/*****************************************************************
|
|
|
|
* SetParent (X11DRV.@)
|
|
|
|
*/
|
2006-12-10 22:21:28 +00:00
|
|
|
void X11DRV_SetParent( HWND hwnd, HWND parent, HWND old_parent )
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2001-05-16 19:52:29 +00:00
|
|
|
Display *display = thread_display();
|
2006-12-10 22:21:28 +00:00
|
|
|
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
|
2001-06-04 21:55:17 +00:00
|
|
|
|
2006-12-10 22:21:28 +00:00
|
|
|
if (!data) return;
|
|
|
|
if (parent == old_parent) return;
|
2005-03-25 10:38:56 +00:00
|
|
|
|
2006-12-10 22:21:28 +00:00
|
|
|
if (parent != GetDesktopWindow()) /* a child window */
|
2005-03-25 10:38:56 +00:00
|
|
|
{
|
2006-12-10 22:21:28 +00:00
|
|
|
if (old_parent == GetDesktopWindow())
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2006-12-10 22:21:28 +00:00
|
|
|
/* destroy the old X windows */
|
|
|
|
destroy_whole_window( display, data );
|
|
|
|
destroy_icon_window( display, data );
|
|
|
|
if (data->managed)
|
2005-01-31 16:34:07 +00:00
|
|
|
{
|
2006-12-10 22:21:28 +00:00
|
|
|
data->managed = FALSE;
|
|
|
|
RemovePropA( data->hwnd, managed_prop );
|
2005-01-31 16:34:07 +00:00
|
|
|
}
|
|
|
|
}
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
2006-12-10 22:21:28 +00:00
|
|
|
else /* new top level window */
|
|
|
|
{
|
|
|
|
/* FIXME: we ignore errors since we can't really recover anyway */
|
2008-01-23 20:39:32 +00:00
|
|
|
create_whole_window( display, data );
|
2006-12-10 22:21:28 +00:00
|
|
|
}
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* SetFocus (X11DRV.@)
|
|
|
|
*
|
|
|
|
* Set the X focus.
|
|
|
|
* Explicit colormap management seems to work only with OLVWM.
|
|
|
|
*/
|
|
|
|
void X11DRV_SetFocus( HWND hwnd )
|
|
|
|
{
|
2001-05-16 19:52:29 +00:00
|
|
|
Display *display = thread_display();
|
2005-02-01 18:53:59 +00:00
|
|
|
struct x11drv_win_data *data;
|
2001-04-24 23:28:52 +00:00
|
|
|
XWindowAttributes win_attr;
|
|
|
|
|
|
|
|
/* Only mess with the X focus if there's */
|
|
|
|
/* no desktop window and if the window is not managed by the WM. */
|
2001-08-24 00:26:59 +00:00
|
|
|
if (root_window != DefaultRootWindow(display)) return;
|
2001-04-24 23:28:52 +00:00
|
|
|
|
|
|
|
if (!hwnd) /* If setting the focus to 0, uninstall the colormap */
|
|
|
|
{
|
2003-11-21 00:17:33 +00:00
|
|
|
wine_tsx11_lock();
|
2001-04-24 23:28:52 +00:00
|
|
|
if (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_PRIVATE)
|
2003-11-21 00:17:33 +00:00
|
|
|
XUninstallColormap( display, X11DRV_PALETTE_PaletteXColormap );
|
|
|
|
wine_tsx11_unlock();
|
2001-08-24 00:26:59 +00:00
|
|
|
return;
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
2001-08-24 00:26:59 +00:00
|
|
|
|
|
|
|
hwnd = GetAncestor( hwnd, GA_ROOT );
|
2005-02-01 18:53:59 +00:00
|
|
|
|
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
2005-08-22 09:14:21 +00:00
|
|
|
if (data->managed || !data->whole_window) return;
|
2001-08-24 00:26:59 +00:00
|
|
|
|
|
|
|
/* Set X focus and install colormap */
|
|
|
|
wine_tsx11_lock();
|
2005-02-01 18:53:59 +00:00
|
|
|
if (XGetWindowAttributes( display, data->whole_window, &win_attr ) &&
|
2001-08-24 00:26:59 +00:00
|
|
|
(win_attr.map_state == IsViewable))
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2001-08-24 00:26:59 +00:00
|
|
|
/* If window is not viewable, don't change anything */
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2001-08-24 00:26:59 +00:00
|
|
|
/* we must not use CurrentTime (ICCCM), so try to use last message time instead */
|
|
|
|
/* FIXME: this is not entirely correct */
|
2005-02-01 18:53:59 +00:00
|
|
|
XSetInputFocus( display, data->whole_window, RevertToParent,
|
2005-01-14 17:06:40 +00:00
|
|
|
/* CurrentTime */
|
|
|
|
GetMessageTime() - EVENT_x11_time_to_win32_time(0));
|
2001-08-24 00:26:59 +00:00
|
|
|
if (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_PRIVATE)
|
|
|
|
XInstallColormap( display, X11DRV_PALETTE_PaletteXColormap );
|
|
|
|
}
|
|
|
|
wine_tsx11_unlock();
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* SetWindowIcon (X11DRV.@)
|
2001-04-24 23:28:52 +00:00
|
|
|
*
|
|
|
|
* hIcon or hIconSm has changed (or is being initialised for the
|
|
|
|
* first time). Complete the X11 driver-specific initialisation
|
|
|
|
* and set the window hints.
|
|
|
|
*
|
|
|
|
* This is not entirely correct, may need to create
|
|
|
|
* an icon window and set the pixmap as a background
|
|
|
|
*/
|
2003-12-31 23:51:52 +00:00
|
|
|
void X11DRV_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2001-05-16 19:52:29 +00:00
|
|
|
Display *display = thread_display();
|
2005-01-17 19:17:47 +00:00
|
|
|
struct x11drv_win_data *data;
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2003-12-31 23:51:52 +00:00
|
|
|
if (type != ICON_BIG) return; /* nothing to do here */
|
2001-04-24 23:28:52 +00:00
|
|
|
|
2005-01-17 19:17:47 +00:00
|
|
|
if (!(data = X11DRV_get_win_data( hwnd ))) return;
|
2005-01-31 16:34:07 +00:00
|
|
|
if (!data->whole_window) return;
|
2005-02-01 18:53:59 +00:00
|
|
|
if (!data->managed) return;
|
2001-10-15 17:56:45 +00:00
|
|
|
|
2007-08-16 21:27:37 +00:00
|
|
|
if (data->wm_hints)
|
2001-04-24 23:28:52 +00:00
|
|
|
{
|
2007-08-16 21:27:37 +00:00
|
|
|
set_icon_hints( display, data, icon );
|
2002-09-24 18:36:51 +00:00
|
|
|
wine_tsx11_lock();
|
2007-08-16 21:27:37 +00:00
|
|
|
XSetWMHints( display, data->whole_window, data->wm_hints );
|
2002-09-24 18:36:51 +00:00
|
|
|
wine_tsx11_unlock();
|
2001-04-24 23:28:52 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-23 15:30:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetWindowRgn (X11DRV.@)
|
|
|
|
*
|
|
|
|
* Assign specified region to window (for non-rectangular windows)
|
|
|
|
*/
|
|
|
|
int X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
|
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
|
|
|
if ((data = X11DRV_get_win_data( hwnd )))
|
|
|
|
{
|
|
|
|
sync_window_region( thread_display(), data, hrgn );
|
|
|
|
invalidate_dce( hwnd, &data->window_rect );
|
|
|
|
}
|
|
|
|
else if (GetWindowThreadProcessId( hwnd, NULL ) != GetCurrentThreadId())
|
|
|
|
{
|
|
|
|
FIXME( "not supported on other thread window %p\n", hwnd );
|
|
|
|
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|