Avoid most references to the internals of the WND structure by passing

around an x11drv_win_data pointer instead.
This commit is contained in:
Alexandre Julliard 2005-01-17 19:17:47 +00:00
parent b819f4cd5c
commit fc5ce14592
9 changed files with 316 additions and 327 deletions

View File

@ -78,7 +78,6 @@
#include "winbase.h" #include "winbase.h"
#include "winreg.h" #include "winreg.h"
#include "wine/wingdi16.h" #include "wine/wingdi16.h"
#include "win.h"
#include "x11drv.h" #include "x11drv.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h" #include "wine/unicode.h"

View File

@ -1051,18 +1051,19 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
} u; } u;
int x, y; int x, y;
BOOL bAccept; BOOL bAccept;
Window w_aux_root, w_aux_child; Window win, w_aux_root, w_aux_child;
WND* pWnd; WND* pWnd;
HWND hScope = hWnd; HWND hScope = hWnd;
pWnd = WIN_FindWndPtr(hWnd); win = X11DRV_get_whole_window(hWnd);
wine_tsx11_lock(); wine_tsx11_lock();
XQueryPointer( event->display, get_whole_window(pWnd), &w_aux_root, &w_aux_child, XQueryPointer( event->display, win, &w_aux_root, &w_aux_child,
&x, &y, (int *) &u.pt_aux.x, (int *) &u.pt_aux.y, &x, &y, (int *) &u.pt_aux.x, (int *) &u.pt_aux.y,
(unsigned int*)&aux_long); (unsigned int*)&aux_long);
wine_tsx11_unlock(); wine_tsx11_unlock();
pWnd = WIN_FindWndPtr(hWnd);
/* find out drop point and drop window */ /* find out drop point and drop window */
if( x < 0 || y < 0 || if( x < 0 || y < 0 ||
x > (pWnd->rectWindow.right - pWnd->rectWindow.left) || x > (pWnd->rectWindow.right - pWnd->rectWindow.left) ||

View File

@ -32,6 +32,7 @@
#include "winbase.h" #include "winbase.h"
#include "wine/winuser16.h" #include "wine/winuser16.h"
#include "win.h"
#include "x11drv.h" #include "x11drv.h"
#include "wine/debug.h" #include "wine/debug.h"
@ -69,19 +70,15 @@ static BYTE *pKeyStateTable;
*/ */
static void get_coords( HWND *hwnd, Window window, int x, int y, POINT *pt ) static void get_coords( HWND *hwnd, Window window, int x, int y, POINT *pt )
{ {
struct x11drv_win_data *data; struct x11drv_win_data *data = X11DRV_get_win_data( *hwnd );
WND *win;
if (!(win = WIN_GetPtr( *hwnd )) || win == WND_OTHER_PROCESS) return; if (!data) return;
data = win->pDriverData;
if (window == data->whole_window) if (window == data->whole_window)
{ {
x -= data->client_rect.left; x -= data->client_rect.left;
y -= data->client_rect.top; y -= data->client_rect.top;
} }
WIN_ReleasePtr( win );
pt->x = x; pt->x = x;
pt->y = y; pt->y = y;
if (*hwnd != GetDesktopWindow()) if (*hwnd != GetDesktopWindow())

View File

@ -31,7 +31,6 @@
#include "winuser.h" #include "winuser.h"
#include "x11drv.h" #include "x11drv.h"
#include "win.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(scroll); WINE_DEFAULT_DEBUG_CHANNEL(scroll);

View File

@ -41,6 +41,7 @@
#include "wine/debug.h" #include "wine/debug.h"
#include "x11drv.h" #include "x11drv.h"
#include "win.h"
#include "winpos.h" #include "winpos.h"
#include "mwm.h" #include "mwm.h"
@ -111,27 +112,32 @@ static LPCSTR icon_window_atom;
* *
* Check if a given window should be managed * Check if a given window should be managed
*/ */
inline static BOOL is_window_managed( WND *win ) inline static BOOL is_window_managed( HWND hwnd )
{ {
DWORD style, ex_style;
if (!managed_mode) return FALSE; if (!managed_mode) return FALSE;
/* tray window is always managed */ /* tray window is always managed */
if (win->dwExStyle & WS_EX_TRAYWINDOW) return TRUE; ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
if (ex_style & WS_EX_TRAYWINDOW) return TRUE;
/* child windows are not managed */ /* child windows are not managed */
if (win->dwStyle & WS_CHILD) return FALSE; style = GetWindowLongW( hwnd, GWL_STYLE );
if (style & WS_CHILD) return FALSE;
/* windows with caption are managed */ /* windows with caption are managed */
if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) return TRUE; if ((style & WS_CAPTION) == WS_CAPTION) return TRUE;
/* tool windows are not managed */ /* tool windows are not managed */
if (win->dwExStyle & WS_EX_TOOLWINDOW) return FALSE; if (ex_style & WS_EX_TOOLWINDOW) return FALSE;
/* windows with thick frame are managed */ /* windows with thick frame are managed */
if (win->dwStyle & WS_THICKFRAME) return TRUE; if (style & WS_THICKFRAME) return TRUE;
/* application windows are managed */ /* application windows are managed */
if (win->dwExStyle & WS_EX_APPWINDOW) return TRUE; if (ex_style & WS_EX_APPWINDOW) return TRUE;
/* full-screen popup windows are managed */ /* full-screen popup windows are managed */
if ((win->dwStyle & WS_POPUP) && if (style & WS_POPUP)
(win->rectWindow.right-win->rectWindow.left) == screen_width &&
(win->rectWindow.bottom-win->rectWindow.top) == screen_height)
{ {
return TRUE; RECT rect;
GetWindowRect( hwnd, &rect );
if ((rect.right - rect.left) == screen_width && (rect.bottom - rect.top) == screen_height)
return TRUE;
} }
/* default: not managed */ /* default: not managed */
return FALSE; return FALSE;
@ -143,10 +149,9 @@ inline static BOOL is_window_managed( WND *win )
* *
* Check if the X client window should be mapped * Check if the X client window should be mapped
*/ */
inline static BOOL is_client_window_mapped( WND *win ) inline static BOOL is_client_window_mapped( struct x11drv_win_data *data )
{ {
struct x11drv_win_data *data = win->pDriverData; return !(GetWindowLongW( data->hwnd, GWL_STYLE ) & WS_MINIMIZE) && !IsRectEmpty( &data->client_rect );
return !(win->dwStyle & WS_MINIMIZE) && !IsRectEmpty( &data->client_rect );
} }
@ -173,22 +178,23 @@ BOOL X11DRV_is_window_rect_mapped( const RECT *rect )
* *
* Fill the window attributes structure for an X window. * Fill the window attributes structure for an X window.
*/ */
static int get_window_attributes( Display *display, WND *win, XSetWindowAttributes *attr ) static int get_window_attributes( struct x11drv_win_data *data, XSetWindowAttributes *attr )
{ {
BOOL is_top_level = is_window_top_level( win ); BOOL is_top_level = is_window_top_level( data->hwnd );
BOOL managed = is_top_level && is_window_managed( win ); BOOL managed = is_top_level && is_window_managed( data->hwnd );
DWORD ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
if (managed) WIN_SetExStyle( win->hwndSelf, win->dwExStyle | WS_EX_MANAGED ); if (managed) WIN_SetExStyle( data->hwnd, ex_style | WS_EX_MANAGED );
else WIN_SetExStyle( win->hwndSelf, win->dwExStyle & ~WS_EX_MANAGED ); else WIN_SetExStyle( data->hwnd, ex_style & ~WS_EX_MANAGED );
attr->override_redirect = !managed; attr->override_redirect = !managed;
attr->colormap = X11DRV_PALETTE_PaletteXColormap; attr->colormap = X11DRV_PALETTE_PaletteXColormap;
attr->save_under = ((win->clsStyle & CS_SAVEBITS) != 0); attr->save_under = ((GetClassLongW( data->hwnd, GCL_STYLE ) & CS_SAVEBITS) != 0);
attr->cursor = x11drv_thread_data()->cursor; attr->cursor = x11drv_thread_data()->cursor;
attr->event_mask = (ExposureMask | PointerMotionMask | attr->event_mask = (ExposureMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | EnterWindowMask); ButtonPressMask | ButtonReleaseMask | EnterWindowMask);
if (is_window_top_level( win )) if (is_top_level)
attr->event_mask |= (KeyPressMask | KeyReleaseMask | StructureNotifyMask | attr->event_mask |= (KeyPressMask | KeyReleaseMask | StructureNotifyMask |
FocusChangeMask | KeymapStateMask); FocusChangeMask | KeymapStateMask);
@ -201,14 +207,13 @@ static int get_window_attributes( Display *display, WND *win, XSetWindowAttribut
* *
* Change the X window attributes when the window style has changed. * Change the X window attributes when the window style has changed.
*/ */
void X11DRV_sync_window_style( Display *display, WND *win ) void X11DRV_sync_window_style( Display *display, struct x11drv_win_data *data )
{ {
XSetWindowAttributes attr; XSetWindowAttributes attr;
int mask; int mask = get_window_attributes( data, &attr );
wine_tsx11_lock(); wine_tsx11_lock();
mask = get_window_attributes( display, win, &attr ); XChangeWindowAttributes( display, data->whole_window, mask, &attr );
XChangeWindowAttributes( display, get_whole_window(win), mask, &attr );
wine_tsx11_unlock(); wine_tsx11_unlock();
} }
@ -249,9 +254,8 @@ static int get_window_changes( XWindowChanges *changes, const RECT *old, const R
/*********************************************************************** /***********************************************************************
* create_icon_window * create_icon_window
*/ */
static Window create_icon_window( Display *display, WND *win ) static Window create_icon_window( Display *display, struct x11drv_win_data *data )
{ {
struct x11drv_win_data *data = win->pDriverData;
XSetWindowAttributes attr; XSetWindowAttributes attr;
attr.event_mask = (ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask | attr.event_mask = (ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask |
@ -267,11 +271,11 @@ static Window create_icon_window( Display *display, WND *win )
0, screen_depth, 0, screen_depth,
InputOutput, visual, InputOutput, visual,
CWEventMask | CWBitGravity | CWBackingStore | CWColormap, &attr ); CWEventMask | CWBitGravity | CWBackingStore | CWColormap, &attr );
XSaveContext( display, data->icon_window, winContext, (char *)win->hwndSelf ); XSaveContext( display, data->icon_window, winContext, (char *)data->hwnd );
wine_tsx11_unlock(); wine_tsx11_unlock();
TRACE( "created %lx\n", data->icon_window ); TRACE( "created %lx\n", data->icon_window );
SetPropA( win->hwndSelf, icon_window_atom, (HANDLE)data->icon_window ); SetPropA( data->hwnd, icon_window_atom, (HANDLE)data->icon_window );
return data->icon_window; return data->icon_window;
} }
@ -280,10 +284,8 @@ static Window create_icon_window( Display *display, WND *win )
/*********************************************************************** /***********************************************************************
* destroy_icon_window * destroy_icon_window
*/ */
inline static void destroy_icon_window( Display *display, WND *win ) inline static void destroy_icon_window( Display *display, struct x11drv_win_data *data )
{ {
struct x11drv_win_data *data = win->pDriverData;
if (!data->icon_window) return; if (!data->icon_window) return;
if (x11drv_thread_data()->cursor_window == data->icon_window) if (x11drv_thread_data()->cursor_window == data->icon_window)
x11drv_thread_data()->cursor_window = None; x11drv_thread_data()->cursor_window = None;
@ -292,7 +294,7 @@ inline static void destroy_icon_window( Display *display, WND *win )
XDestroyWindow( display, data->icon_window ); XDestroyWindow( display, data->icon_window );
data->icon_window = 0; data->icon_window = 0;
wine_tsx11_unlock(); wine_tsx11_unlock();
RemovePropA( win->hwndSelf, icon_window_atom ); RemovePropA( data->hwnd, icon_window_atom );
} }
@ -301,23 +303,22 @@ inline static void destroy_icon_window( Display *display, WND *win )
* *
* Set the icon wm hints * Set the icon wm hints
*/ */
static void set_icon_hints( Display *display, WND *wndPtr, XWMHints *hints, HICON hIcon ) static void set_icon_hints( Display *display, struct x11drv_win_data *data,
XWMHints *hints, HICON hIcon, DWORD ex_style )
{ {
X11DRV_WND_DATA *data = wndPtr->pDriverData;
if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap ); if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap );
if (data->hWMIconMask) DeleteObject( data->hWMIconMask); if (data->hWMIconMask) DeleteObject( data->hWMIconMask);
data->hWMIconBitmap = 0; data->hWMIconBitmap = 0;
data->hWMIconMask = 0; data->hWMIconMask = 0;
if (!(wndPtr->dwExStyle & WS_EX_MANAGED)) if (!(ex_style & WS_EX_MANAGED))
{ {
destroy_icon_window( display, wndPtr ); destroy_icon_window( display, data );
hints->flags &= ~(IconPixmapHint | IconMaskHint | IconWindowHint); hints->flags &= ~(IconPixmapHint | IconMaskHint | IconWindowHint);
} }
else if (!hIcon) else if (!hIcon)
{ {
if (!data->icon_window) create_icon_window( display, wndPtr ); if (!data->icon_window) create_icon_window( display, data );
hints->icon_window = data->icon_window; hints->icon_window = data->icon_window;
hints->flags = (hints->flags & ~(IconPixmapHint | IconMaskHint)) | IconWindowHint; hints->flags = (hints->flags & ~(IconPixmapHint | IconMaskHint)) | IconWindowHint;
} }
@ -349,7 +350,7 @@ static void set_icon_hints( Display *display, WND *wndPtr, XWMHints *hints, HICO
hints->icon_pixmap = X11DRV_BITMAP_Pixmap(data->hWMIconBitmap); hints->icon_pixmap = X11DRV_BITMAP_Pixmap(data->hWMIconBitmap);
hints->icon_mask = X11DRV_BITMAP_Pixmap(data->hWMIconMask); hints->icon_mask = X11DRV_BITMAP_Pixmap(data->hWMIconMask);
destroy_icon_window( display, wndPtr ); destroy_icon_window( display, data );
hints->flags = (hints->flags & ~IconWindowHint) | IconPixmapHint | IconMaskHint; hints->flags = (hints->flags & ~IconWindowHint) | IconPixmapHint | IconMaskHint;
} }
} }
@ -360,10 +361,9 @@ static void set_icon_hints( Display *display, WND *wndPtr, XWMHints *hints, HICO
* *
* set the window size hints * set the window size hints
*/ */
static void set_size_hints( Display *display, WND *win ) static void set_size_hints( Display *display, struct x11drv_win_data *data, DWORD style )
{ {
XSizeHints* size_hints; XSizeHints* size_hints;
struct x11drv_win_data *data = win->pDriverData;
if ((size_hints = XAllocSizeHints())) if ((size_hints = XAllocSizeHints()))
{ {
@ -372,7 +372,7 @@ static void set_size_hints( Display *display, WND *win )
size_hints->y = data->whole_rect.top; size_hints->y = data->whole_rect.top;
size_hints->flags = PWinGravity | PPosition; size_hints->flags = PWinGravity | PPosition;
if ( !(win->dwStyle & WS_THICKFRAME) ) if ( !(style & WS_THICKFRAME) )
{ {
size_hints->max_width = data->whole_rect.right - data->whole_rect.left; 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->max_height = data->whole_rect.bottom - data->whole_rect.top;
@ -391,9 +391,8 @@ static void set_size_hints( Display *display, WND *win )
* *
* Set the window manager hints for a newly-created window * Set the window manager hints for a newly-created window
*/ */
void X11DRV_set_wm_hints( Display *display, WND *win ) void X11DRV_set_wm_hints( Display *display, struct x11drv_win_data *data )
{ {
struct x11drv_win_data *data = win->pDriverData;
Window group_leader; Window group_leader;
XClassHint *class_hints; XClassHint *class_hints;
XWMHints* wm_hints; XWMHints* wm_hints;
@ -401,6 +400,20 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
MwmHints mwm_hints; MwmHints mwm_hints;
Atom dndVersion = 4; Atom dndVersion = 4;
int i; int i;
DWORD style = GetWindowLongW( data->hwnd, GWL_STYLE );
DWORD ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
HWND owner = GetWindow( data->hwnd, GW_OWNER );
/* 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;
wine_tsx11_lock(); wine_tsx11_lock();
@ -421,20 +434,11 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
XFree( class_hints ); XFree( class_hints );
} }
/* transient for hint */
if (win->owner)
{
Window owner_win = X11DRV_get_whole_window( win->owner );
XSetTransientForHint( display, data->whole_window, owner_win );
group_leader = owner_win;
}
else group_leader = data->whole_window;
/* size hints */ /* size hints */
set_size_hints( display, win ); set_size_hints( display, data, style );
/* systray properties (KDE only for now) */ /* systray properties (KDE only for now) */
if (win->dwExStyle & WS_EX_TRAYWINDOW) if (ex_style & WS_EX_TRAYWINDOW)
{ {
int val = 1; int val = 1;
XChangeProperty( display, data->whole_window, x11drv_atom(KWM_DOCKWINDOW), XChangeProperty( display, data->whole_window, x11drv_atom(KWM_DOCKWINDOW),
@ -451,7 +455,7 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
XA_CARDINAL, 32, PropModeReplace, (char *)&i, 1); XA_CARDINAL, 32, PropModeReplace, (char *)&i, 1);
/* map WS_EX_TOOLWINDOW to _NET_WM_WINDOW_TYPE_UTILITY */ /* map WS_EX_TOOLWINDOW to _NET_WM_WINDOW_TYPE_UTILITY */
if (win->dwExStyle & WS_EX_TOOLWINDOW) if (ex_style & WS_EX_TOOLWINDOW)
{ {
Atom a = x11drv_atom(_NET_WM_WINDOW_TYPE_UTILITY); Atom a = x11drv_atom(_NET_WM_WINDOW_TYPE_UTILITY);
XChangeProperty(display, data->whole_window, x11drv_atom(_NET_WM_WINDOW_TYPE), XChangeProperty(display, data->whole_window, x11drv_atom(_NET_WM_WINDOW_TYPE),
@ -460,21 +464,21 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
mwm_hints.functions = 0; mwm_hints.functions = 0;
if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.functions |= MWM_FUNC_MOVE; if ((style & WS_CAPTION) == WS_CAPTION) mwm_hints.functions |= MWM_FUNC_MOVE;
if (win->dwStyle & WS_THICKFRAME) mwm_hints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE; if (style & WS_THICKFRAME) mwm_hints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
if (win->dwStyle & WS_MINIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MINIMIZE; if (style & WS_MINIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MINIMIZE;
if (win->dwStyle & WS_MAXIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MAXIMIZE; if (style & WS_MAXIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MAXIMIZE;
if (win->dwStyle & WS_SYSMENU) mwm_hints.functions |= MWM_FUNC_CLOSE; if (style & WS_SYSMENU) mwm_hints.functions |= MWM_FUNC_CLOSE;
mwm_hints.decorations = 0; mwm_hints.decorations = 0;
if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.decorations |= MWM_DECOR_TITLE; if ((style & WS_CAPTION) == WS_CAPTION) mwm_hints.decorations |= MWM_DECOR_TITLE;
if (win->dwExStyle & WS_EX_DLGMODALFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER; if (ex_style & WS_EX_DLGMODALFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER;
else if (win->dwStyle & WS_THICKFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER | MWM_DECOR_RESIZEH; else if (style & WS_THICKFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER | MWM_DECOR_RESIZEH;
else if ((win->dwStyle & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER; else if ((style & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER;
else if (win->dwStyle & WS_BORDER) mwm_hints.decorations |= MWM_DECOR_BORDER; else if (style & WS_BORDER) mwm_hints.decorations |= MWM_DECOR_BORDER;
else if (!(win->dwStyle & (WS_CHILD|WS_POPUP))) mwm_hints.decorations |= MWM_DECOR_BORDER; else if (!(style & (WS_CHILD|WS_POPUP))) mwm_hints.decorations |= MWM_DECOR_BORDER;
if (win->dwStyle & WS_SYSMENU) mwm_hints.decorations |= MWM_DECOR_MENU; if (style & WS_SYSMENU) mwm_hints.decorations |= MWM_DECOR_MENU;
if (win->dwStyle & WS_MINIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MINIMIZE; if (style & WS_MINIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MINIMIZE;
if (win->dwStyle & WS_MAXIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MAXIMIZE; if (style & WS_MAXIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MAXIMIZE;
XChangeProperty( display, data->whole_window, x11drv_atom(_MOTIF_WM_HINTS), XChangeProperty( display, data->whole_window, x11drv_atom(_MOTIF_WM_HINTS),
x11drv_atom(_MOTIF_WM_HINTS), 32, PropModeReplace, x11drv_atom(_MOTIF_WM_HINTS), 32, PropModeReplace,
@ -490,11 +494,12 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
if (wm_hints) if (wm_hints)
{ {
wm_hints->flags = InputHint | StateHint | WindowGroupHint; wm_hints->flags = InputHint | StateHint | WindowGroupHint;
wm_hints->input = !(win->dwStyle & WS_DISABLED); wm_hints->input = !(style & WS_DISABLED);
set_icon_hints( display, win, wm_hints, (HICON)GetClassLongA( win->hwndSelf, GCL_HICON )); set_icon_hints( display, data, wm_hints,
(HICON)GetClassLongW( data->hwnd, GCL_HICON ), ex_style );
wm_hints->initial_state = (win->dwStyle & WS_MINIMIZE) ? IconicState : NormalState; wm_hints->initial_state = (style & WS_MINIMIZE) ? IconicState : NormalState;
wm_hints->window_group = group_leader; wm_hints->window_group = group_leader;
wine_tsx11_lock(); wine_tsx11_lock();
@ -510,31 +515,37 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
* *
* Set the X11 iconic state according to the window style. * Set the X11 iconic state according to the window style.
*/ */
void X11DRV_set_iconic_state( WND *win ) void X11DRV_set_iconic_state( HWND hwnd )
{ {
Display *display = thread_display(); Display *display = thread_display();
struct x11drv_win_data *data = win->pDriverData; struct x11drv_win_data *data;
RECT rect;
XWMHints* wm_hints; XWMHints* wm_hints;
BOOL iconic = IsIconic( win->hwndSelf ); DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
BOOL iconic = (style & WS_MINIMIZE) != 0;
if (!(data = X11DRV_get_win_data( hwnd ))) return;
GetWindowRect( hwnd, &rect );
wine_tsx11_lock(); wine_tsx11_lock();
if (iconic) XUnmapWindow( display, data->client_window ); if (iconic) XUnmapWindow( display, data->client_window );
else if (is_client_window_mapped( win )) XMapWindow( display, data->client_window ); else if (!IsRectEmpty( &data->client_rect )) XMapWindow( display, data->client_window );
if (!(wm_hints = XGetWMHints( display, data->whole_window ))) wm_hints = XAllocWMHints(); if (!(wm_hints = XGetWMHints( display, data->whole_window ))) wm_hints = XAllocWMHints();
wm_hints->flags |= StateHint | IconPositionHint; wm_hints->flags |= StateHint | IconPositionHint;
wm_hints->initial_state = iconic ? IconicState : NormalState; wm_hints->initial_state = iconic ? IconicState : NormalState;
wm_hints->icon_x = win->rectWindow.left; wm_hints->icon_x = rect.left;
wm_hints->icon_y = win->rectWindow.top; wm_hints->icon_y = rect.top;
XSetWMHints( display, data->whole_window, wm_hints ); XSetWMHints( display, data->whole_window, wm_hints );
if (win->dwStyle & WS_VISIBLE) if (style & WS_VISIBLE)
{ {
if (iconic) if (iconic)
XIconifyWindow( display, data->whole_window, DefaultScreen(display) ); XIconifyWindow( display, data->whole_window, DefaultScreen(display) );
else else
if (X11DRV_is_window_rect_mapped( &win->rectWindow )) if (X11DRV_is_window_rect_mapped( &rect ))
XMapWindow( display, data->whole_window ); XMapWindow( display, data->whole_window );
} }
@ -548,16 +559,18 @@ void X11DRV_set_iconic_state( WND *win )
* *
* Convert a rect from client to X window coordinates * Convert a rect from client to X window coordinates
*/ */
void X11DRV_window_to_X_rect( WND *win, RECT *rect ) void X11DRV_window_to_X_rect( HWND hwnd, RECT *rect )
{ {
RECT rc; RECT rc;
DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
if (!(win->dwExStyle & WS_EX_MANAGED)) return; if (!(ex_style & WS_EX_MANAGED)) return;
if (IsRectEmpty( rect )) return; if (IsRectEmpty( rect )) return;
rc.top = rc.bottom = rc.left = rc.right = 0; rc.top = rc.bottom = rc.left = rc.right = 0;
AdjustWindowRectEx( &rc, win->dwStyle & ~(WS_HSCROLL|WS_VSCROLL), FALSE, win->dwExStyle ); AdjustWindowRectEx( &rc, GetWindowLongW(hwnd, GWL_STYLE) & ~(WS_HSCROLL|WS_VSCROLL),
FALSE, ex_style );
rect->left -= rc.left; rect->left -= rc.left;
rect->right -= rc.right; rect->right -= rc.right;
@ -573,12 +586,15 @@ void X11DRV_window_to_X_rect( WND *win, RECT *rect )
* *
* Opposite of X11DRV_window_to_X_rect * Opposite of X11DRV_window_to_X_rect
*/ */
void X11DRV_X_to_window_rect( WND *win, RECT *rect ) void X11DRV_X_to_window_rect( HWND hwnd, RECT *rect )
{ {
if (!(win->dwExStyle & WS_EX_MANAGED)) return; DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
if (!(ex_style & WS_EX_MANAGED)) return;
if (IsRectEmpty( rect )) return; if (IsRectEmpty( rect )) return;
AdjustWindowRectEx( rect, win->dwStyle & ~(WS_HSCROLL|WS_VSCROLL), FALSE, win->dwExStyle ); AdjustWindowRectEx( rect, GetWindowLongW(hwnd, GWL_STYLE) & ~(WS_HSCROLL|WS_VSCROLL),
FALSE, ex_style );
if (rect->top >= rect->bottom) rect->bottom = rect->top + 1; if (rect->top >= rect->bottom) rect->bottom = rect->top + 1;
if (rect->left >= rect->right) rect->right = rect->left + 1; if (rect->left >= rect->right) rect->right = rect->left + 1;
@ -590,22 +606,22 @@ void X11DRV_X_to_window_rect( WND *win, RECT *rect )
* *
* Synchronize the X whole window position with the Windows one * Synchronize the X whole window position with the Windows one
*/ */
int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder ) int X11DRV_sync_whole_window_position( Display *display, struct x11drv_win_data *data, int zorder )
{ {
XWindowChanges changes; XWindowChanges changes;
int mask; int mask;
struct x11drv_win_data *data = win->pDriverData; RECT whole_rect;
RECT whole_rect = win->rectWindow;
X11DRV_window_to_X_rect( win, &whole_rect ); whole_rect = data->window_rect;
X11DRV_window_to_X_rect( data->hwnd, &whole_rect );
mask = get_window_changes( &changes, &data->whole_rect, &whole_rect ); mask = get_window_changes( &changes, &data->whole_rect, &whole_rect );
if (zorder) if (zorder)
{ {
if (is_window_top_level( win )) if (is_window_top_level( data->hwnd ))
{ {
/* find window that this one must be after */ /* find window that this one must be after */
HWND prev = GetWindow( win->hwndSelf, GW_HWNDPREV ); HWND prev = GetWindow( data->hwnd, GW_HWNDPREV );
while (prev && !(GetWindowLongW( prev, GWL_STYLE ) & WS_VISIBLE)) while (prev && !(GetWindowLongW( prev, GWL_STYLE ) & WS_VISIBLE))
prev = GetWindow( prev, GW_HWNDPREV ); prev = GetWindow( prev, GW_HWNDPREV );
if (!prev) /* top child */ if (!prev) /* top child */
@ -617,7 +633,7 @@ int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder )
{ {
/* should use stack_mode Below but most window managers don't get it right */ /* should use stack_mode Below but most window managers don't get it right */
/* so move it above the next one in Z order */ /* so move it above the next one in Z order */
HWND next = GetWindow( win->hwndSelf, GW_HWNDNEXT ); HWND next = GetWindow( data->hwnd, GW_HWNDNEXT );
while (next && !(GetWindowLongW( next, GWL_STYLE ) & WS_VISIBLE)) while (next && !(GetWindowLongW( next, GWL_STYLE ) & WS_VISIBLE))
next = GetWindow( next, GW_HWNDNEXT ); next = GetWindow( next, GW_HWNDNEXT );
if (next) if (next)
@ -630,20 +646,15 @@ int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder )
} }
else else
{ {
HWND next = GetWindow( win->hwndSelf, GW_HWNDNEXT ); HWND next = GetWindow( data->hwnd, GW_HWNDNEXT );
if (win->parent == GetDesktopWindow() && if (GetAncestor( data->hwnd, GA_PARENT ) == GetDesktopWindow() &&
root_window != DefaultRootWindow(display)) root_window != DefaultRootWindow(display))
{ {
/* in desktop mode we need the sibling to belong to the same process */ /* in desktop mode we need the sibling to belong to the same process */
while (next) while (next)
{ {
WND *ptr = WIN_GetPtr( next ); if (X11DRV_get_win_data( next )) break;
if (ptr != WND_OTHER_PROCESS)
{
WIN_ReleasePtr( ptr );
break;
}
next = GetWindow( next, GW_HWNDNEXT ); next = GetWindow( next, GW_HWNDNEXT );
} }
} }
@ -672,14 +683,24 @@ int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder )
changes.sibling, mask ); changes.sibling, mask );
wine_tsx11_lock(); wine_tsx11_lock();
XSync( gdi_display, False ); /* flush graphics operations before moving the window */ XSync( gdi_display, False ); /* flush graphics operations before moving the window */
if (is_window_top_level( win )) wine_tsx11_unlock();
if (is_window_top_level( data->hwnd ))
{ {
if (mask & (CWWidth|CWHeight)) set_size_hints( display, win ); DWORD style = GetWindowLongW( data->hwnd, GWL_STYLE );
wine_tsx11_lock();
if (mask & (CWWidth|CWHeight)) set_size_hints( display, data, style );
XReconfigureWMWindow( display, data->whole_window, XReconfigureWMWindow( display, data->whole_window,
DefaultScreen(display), mask, &changes ); DefaultScreen(display), mask, &changes );
wine_tsx11_unlock();
}
else
{
wine_tsx11_lock();
XConfigureWindow( display, data->whole_window, mask, &changes );
wine_tsx11_unlock();
} }
else XConfigureWindow( display, data->whole_window, mask, &changes );
wine_tsx11_unlock();
} }
return mask; return mask;
} }
@ -690,18 +711,18 @@ int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder )
* *
* Synchronize the X client window position with the Windows one * Synchronize the X client window position with the Windows one
*/ */
int X11DRV_sync_client_window_position( Display *display, WND *win ) int X11DRV_sync_client_window_position( Display *display, struct x11drv_win_data *data,
const RECT *new_client_rect )
{ {
XWindowChanges changes; XWindowChanges changes;
int mask; int mask;
struct x11drv_win_data *data = win->pDriverData; RECT client_rect = *new_client_rect;
RECT client_rect = win->rectClient;
OffsetRect( &client_rect, -data->whole_rect.left, -data->whole_rect.top ); OffsetRect( &client_rect, -data->whole_rect.left, -data->whole_rect.top );
if ((mask = get_window_changes( &changes, &data->client_rect, &client_rect ))) if ((mask = get_window_changes( &changes, &data->client_rect, &client_rect )))
{ {
BOOL was_mapped = is_client_window_mapped( win ); BOOL is_mapped;
TRACE( "setting win %lx pos %ld,%ld,%ldx%ld (was %ld,%ld,%ldx%ld) after %lx changes=%x\n", TRACE( "setting win %lx pos %ld,%ld,%ldx%ld (was %ld,%ld,%ldx%ld) after %lx changes=%x\n",
data->client_window, client_rect.left, client_rect.top, data->client_window, client_rect.left, client_rect.top,
@ -710,14 +731,14 @@ int X11DRV_sync_client_window_position( Display *display, WND *win )
data->client_rect.right - data->client_rect.left, data->client_rect.right - data->client_rect.left,
data->client_rect.bottom - data->client_rect.top, data->client_rect.bottom - data->client_rect.top,
changes.sibling, mask ); changes.sibling, mask );
data->client_rect = client_rect; data->client_rect = client_rect;
is_mapped = is_client_window_mapped( data );
wine_tsx11_lock(); wine_tsx11_lock();
XSync( gdi_display, False ); /* flush graphics operations before moving the window */ XSync( gdi_display, False ); /* flush graphics operations before moving the window */
if (was_mapped && !is_client_window_mapped( win )) if (!is_mapped) XUnmapWindow( display, data->client_window );
XUnmapWindow( display, data->client_window );
XConfigureWindow( display, data->client_window, mask, &changes ); XConfigureWindow( display, data->client_window, mask, &changes );
if (!was_mapped && is_client_window_mapped( win )) if (is_mapped) XMapWindow( display, data->client_window );
XMapWindow( display, data->client_window );
wine_tsx11_unlock(); wine_tsx11_unlock();
} }
return mask; return mask;
@ -741,9 +762,8 @@ void X11DRV_register_window( Display *display, HWND hwnd, struct x11drv_win_data
/********************************************************************** /**********************************************************************
* create_desktop * create_desktop
*/ */
static void create_desktop( Display *display, WND *wndPtr ) static void create_desktop( Display *display, struct x11drv_win_data *data )
{ {
X11DRV_WND_DATA *data = wndPtr->pDriverData;
VisualID visualid; VisualID visualid;
wine_tsx11_lock(); wine_tsx11_lock();
@ -757,11 +777,11 @@ static void create_desktop( Display *display, WND *wndPtr )
icon_window_atom = MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_icon_window" )); icon_window_atom = MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_icon_window" ));
data->whole_window = data->client_window = root_window; data->whole_window = data->client_window = root_window;
data->whole_rect = data->client_rect = wndPtr->rectWindow; data->whole_rect = data->client_rect = data->window_rect;
SetPropA( wndPtr->hwndSelf, whole_window_atom, (HANDLE)root_window ); SetPropA( data->hwnd, whole_window_atom, (HANDLE)root_window );
SetPropA( wndPtr->hwndSelf, client_window_atom, (HANDLE)root_window ); SetPropA( data->hwnd, client_window_atom, (HANDLE)root_window );
SetPropA( wndPtr->hwndSelf, "__wine_x11_visual_id", (HANDLE)visualid ); SetPropA( data->hwnd, "__wine_x11_visual_id", (HANDLE)visualid );
X11DRV_InitClipboard(); X11DRV_InitClipboard();
@ -774,26 +794,23 @@ static void create_desktop( Display *display, WND *wndPtr )
* *
* Create the whole X window for a given window * Create the whole X window for a given window
*/ */
static Window create_whole_window( Display *display, WND *win ) static Window create_whole_window( Display *display, struct x11drv_win_data *data, DWORD style )
{ {
struct x11drv_win_data *data = win->pDriverData;
int cx, cy, mask; int cx, cy, mask;
XSetWindowAttributes attr; XSetWindowAttributes attr;
Window parent; Window parent;
RECT rect; RECT rect;
BOOL is_top_level = is_window_top_level( win ); BOOL is_top_level = is_window_top_level( data->hwnd );
rect = win->rectWindow; rect = data->window_rect;
X11DRV_window_to_X_rect( win, &rect ); X11DRV_window_to_X_rect( data->hwnd, &rect );
if (!(cx = rect.right - rect.left)) cx = 1; if (!(cx = rect.right - rect.left)) cx = 1;
if (!(cy = rect.bottom - rect.top)) cy = 1; if (!(cy = rect.bottom - rect.top)) cy = 1;
parent = X11DRV_get_client_window( win->parent ); parent = X11DRV_get_client_window( GetAncestor( data->hwnd, GA_PARENT ) );
wine_tsx11_lock(); mask = get_window_attributes( data, &attr );
mask = get_window_attributes( display, win, &attr );
/* set the attributes that don't change over the lifetime of the window */ /* set the attributes that don't change over the lifetime of the window */
attr.bit_gravity = ForgetGravity; attr.bit_gravity = ForgetGravity;
@ -801,6 +818,8 @@ static Window create_whole_window( Display *display, WND *win )
attr.backing_store = NotUseful/*WhenMapped*/; attr.backing_store = NotUseful/*WhenMapped*/;
mask |= CWBitGravity | CWWinGravity | CWBackingStore; mask |= CWBitGravity | CWWinGravity | CWBackingStore;
wine_tsx11_lock();
data->whole_rect = rect; data->whole_rect = rect;
data->whole_window = XCreateWindow( display, parent, rect.left, rect.top, cx, cy, data->whole_window = XCreateWindow( display, parent, rect.left, rect.top, cx, cy,
0, screen_depth, InputOutput, visual, 0, screen_depth, InputOutput, visual,
@ -813,7 +832,7 @@ static Window create_whole_window( Display *display, WND *win )
} }
/* non-maximized child must be at bottom of Z order */ /* non-maximized child must be at bottom of Z order */
if ((win->dwStyle & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD) if ((style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
{ {
XWindowChanges changes; XWindowChanges changes;
changes.stack_mode = Below; changes.stack_mode = Below;
@ -826,7 +845,7 @@ static Window create_whole_window( Display *display, WND *win )
{ {
XIM xim = x11drv_thread_data()->xim; XIM xim = x11drv_thread_data()->xim;
if (xim) data->xic = X11DRV_CreateIC( xim, display, data->whole_window ); if (xim) data->xic = X11DRV_CreateIC( xim, display, data->whole_window );
X11DRV_set_wm_hints( display, win ); X11DRV_set_wm_hints( display, data );
} }
return data->whole_window; return data->whole_window;
@ -838,18 +857,19 @@ static Window create_whole_window( Display *display, WND *win )
* *
* Create the client window for a given window * Create the client window for a given window
*/ */
static Window create_client_window( Display *display, WND *win ) static Window create_client_window( Display *display, struct x11drv_win_data *data )
{ {
struct x11drv_win_data *data = win->pDriverData;
RECT rect = data->whole_rect; RECT rect = data->whole_rect;
XSetWindowAttributes attr; XSetWindowAttributes attr;
BOOL is_mapped;
OffsetRect( &rect, -data->whole_rect.left, -data->whole_rect.top ); OffsetRect( &rect, -data->whole_rect.left, -data->whole_rect.top );
data->client_rect = rect; data->client_rect = rect;
is_mapped = is_client_window_mapped( data );
attr.event_mask = (ExposureMask | PointerMotionMask | attr.event_mask = (ExposureMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | EnterWindowMask); ButtonPressMask | ButtonReleaseMask | EnterWindowMask);
attr.bit_gravity = (win->clsStyle & (CS_VREDRAW | CS_HREDRAW)) ? attr.bit_gravity = (GetClassLongW( data->hwnd, GCL_STYLE ) & (CS_VREDRAW | CS_HREDRAW)) ?
ForgetGravity : NorthWestGravity; ForgetGravity : NorthWestGravity;
attr.backing_store = NotUseful/*WhenMapped*/; attr.backing_store = NotUseful/*WhenMapped*/;
@ -860,8 +880,7 @@ static Window create_client_window( Display *display, WND *win )
0, screen_depth, 0, screen_depth,
InputOutput, visual, InputOutput, visual,
CWEventMask | CWBitGravity | CWBackingStore, &attr ); CWEventMask | CWBitGravity | CWBackingStore, &attr );
if (data->client_window && is_client_window_mapped( win )) if (data->client_window && is_mapped) XMapWindow( display, data->client_window );
XMapWindow( display, data->client_window );
wine_tsx11_unlock(); wine_tsx11_unlock();
return data->client_window; return data->client_window;
} }
@ -930,7 +949,7 @@ BOOL X11DRV_DestroyWindow( HWND hwnd )
struct x11drv_thread_data *thread_data = x11drv_thread_data(); struct x11drv_thread_data *thread_data = x11drv_thread_data();
Display *display = thread_data->display; Display *display = thread_data->display;
WND *wndPtr = WIN_GetPtr( hwnd ); WND *wndPtr = WIN_GetPtr( hwnd );
X11DRV_WND_DATA *data = wndPtr->pDriverData; struct x11drv_win_data *data = wndPtr->pDriverData;
if (!data) goto done; if (!data) goto done;
@ -949,8 +968,8 @@ BOOL X11DRV_DestroyWindow( HWND hwnd )
XUnsetICFocus( data->xic ); XUnsetICFocus( data->xic );
XDestroyIC( data->xic ); XDestroyIC( data->xic );
} }
destroy_icon_window( display, wndPtr );
wine_tsx11_unlock(); wine_tsx11_unlock();
destroy_icon_window( display, data );
} }
if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap ); if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap );
@ -973,6 +992,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
struct x11drv_win_data *data; struct x11drv_win_data *data;
HWND insert_after; HWND insert_after;
RECT rect; RECT rect;
DWORD style;
CBT_CREATEWNDA cbtc; CBT_CREATEWNDA cbtc;
BOOL ret = FALSE; BOOL ret = FALSE;
@ -998,6 +1018,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
} }
if (!(data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data)))) return FALSE; if (!(data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data)))) return FALSE;
data->hwnd = hwnd;
data->whole_window = 0; data->whole_window = 0;
data->client_window = 0; data->client_window = 0;
data->icon_window = 0; data->icon_window = 0;
@ -1014,13 +1035,14 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
if (!wndPtr->parent) if (!wndPtr->parent)
{ {
create_desktop( display, wndPtr ); create_desktop( display, data );
WIN_ReleasePtr( wndPtr ); WIN_ReleasePtr( wndPtr );
return TRUE; return TRUE;
} }
WIN_ReleasePtr( wndPtr );
if (!create_whole_window( display, wndPtr )) goto failed; if (!create_whole_window( display, data, cs->style )) goto failed;
if (!create_client_window( display, wndPtr )) goto failed; if (!create_client_window( display, data )) goto failed;
wine_tsx11_lock(); wine_tsx11_lock();
XSync( display, False ); XSync( display, False );
wine_tsx11_unlock(); wine_tsx11_unlock();
@ -1042,18 +1064,15 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
{ {
POINT maxSize, maxPos, minTrack, maxTrack; POINT maxSize, maxPos, minTrack, maxTrack;
WIN_ReleasePtr( wndPtr );
WINPOS_GetMinMaxInfo( hwnd, &maxSize, &maxPos, &minTrack, &maxTrack); WINPOS_GetMinMaxInfo( hwnd, &maxSize, &maxPos, &minTrack, &maxTrack);
if (maxSize.x < cs->cx) cs->cx = maxSize.x; if (maxSize.x < cs->cx) cs->cx = maxSize.x;
if (maxSize.y < cs->cy) cs->cy = maxSize.y; if (maxSize.y < cs->cy) cs->cy = maxSize.y;
if (cs->cx < 0) cs->cx = 0; if (cs->cx < 0) cs->cx = 0;
if (cs->cy < 0) cs->cy = 0; if (cs->cy < 0) cs->cy = 0;
if (!(wndPtr = WIN_GetPtr( hwnd ))) return FALSE;
SetRect( &rect, cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy ); SetRect( &rect, cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy );
X11DRV_set_window_pos( hwnd, 0, &rect, &rect, SWP_NOZORDER, 0 ); if (!X11DRV_set_window_pos( hwnd, 0, &rect, &rect, SWP_NOZORDER, 0 )) return FALSE;
} }
WIN_ReleasePtr( wndPtr );
/* send WM_NCCREATE */ /* send WM_NCCREATE */
TRACE( "hwnd %p cs %d,%d %dx%d\n", hwnd, cs->x, cs->y, cs->cx, cs->cy ); TRACE( "hwnd %p cs %d,%d %dx%d\n", hwnd, cs->x, cs->y, cs->cx, cs->cy );
@ -1067,13 +1086,12 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
return FALSE; return FALSE;
} }
if (!(wndPtr = WIN_GetPtr(hwnd))) return FALSE; /* make sure the window is still valid */
if (!(data = X11DRV_get_win_data( hwnd ))) return FALSE;
X11DRV_sync_window_style( display, wndPtr ); X11DRV_sync_window_style( display, data );
/* send WM_NCCALCSIZE */ /* send WM_NCCALCSIZE */
rect = wndPtr->rectWindow; rect = data->window_rect;
WIN_ReleasePtr( wndPtr );
SendMessageW( hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rect ); SendMessageW( hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rect );
if (!(wndPtr = WIN_GetPtr(hwnd))) return FALSE; if (!(wndPtr = WIN_GetPtr(hwnd))) return FALSE;
@ -1130,34 +1148,53 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
SendMessageW( hwnd, WM_MOVE, 0, SendMessageW( hwnd, WM_MOVE, 0,
MAKELONG( wndPtr->rectClient.left, wndPtr->rectClient.top ) ); MAKELONG( wndPtr->rectClient.left, wndPtr->rectClient.top ) );
} }
WIN_ReleaseWndPtr( wndPtr );
/* Show the window, maximizing or minimizing if needed */ /* Show the window, maximizing or minimizing if needed */
if (wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE)) style = GetWindowLongW( hwnd, GWL_STYLE );
if (style & (WS_MINIMIZE | WS_MAXIMIZE))
{ {
extern UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect ); /*FIXME*/ extern UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect ); /*FIXME*/
RECT newPos; RECT newPos;
UINT swFlag = (wndPtr->dwStyle & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE; UINT swFlag = (style & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
WIN_SetStyle( hwnd, wndPtr->dwStyle & ~(WS_MAXIMIZE | WS_MINIMIZE) ); WIN_SetStyle( hwnd, style & ~(WS_MAXIMIZE | WS_MINIMIZE) );
WINPOS_MinMaximize( hwnd, swFlag, &newPos ); WINPOS_MinMaximize( hwnd, swFlag, &newPos );
swFlag = ((wndPtr->dwStyle & WS_CHILD) || GetActiveWindow()) swFlag = ((style & WS_CHILD) || GetActiveWindow())
? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
: SWP_NOZORDER | SWP_FRAMECHANGED; : SWP_NOZORDER | SWP_FRAMECHANGED;
SetWindowPos( hwnd, 0, newPos.left, newPos.top, SetWindowPos( hwnd, 0, newPos.left, newPos.top,
newPos.right, newPos.bottom, swFlag ); newPos.right, newPos.bottom, swFlag );
} }
WIN_ReleaseWndPtr( wndPtr );
return TRUE; return TRUE;
failed: failed:
X11DRV_DestroyWindow( hwnd ); X11DRV_DestroyWindow( hwnd );
if (wndPtr) WIN_ReleasePtr( wndPtr );
return FALSE; return FALSE;
} }
/***********************************************************************
* X11DRV_get_win_data
*
* Return the X11 data structure associated with a window.
*/
struct x11drv_win_data *X11DRV_get_win_data( HWND hwnd )
{
struct x11drv_win_data *ret = NULL;
WND *win = WIN_GetPtr( hwnd );
if (win && win != WND_OTHER_PROCESS)
{
ret = win->pDriverData;
WIN_ReleasePtr( win );
}
return ret;
}
/*********************************************************************** /***********************************************************************
* X11DRV_get_client_window * X11DRV_get_client_window
* *
@ -1165,19 +1202,10 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
*/ */
Window X11DRV_get_client_window( HWND hwnd ) Window X11DRV_get_client_window( HWND hwnd )
{ {
Window ret = 0; struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
WND *win = WIN_GetPtr( hwnd );
if (win == WND_OTHER_PROCESS) if (!data) return (Window)GetPropA( hwnd, client_window_atom );
return (Window)GetPropA( hwnd, client_window_atom ); return data->client_window;
if (win)
{
struct x11drv_win_data *data = win->pDriverData;
ret = data->client_window;
WIN_ReleasePtr( win );
}
return ret;
} }
@ -1188,19 +1216,10 @@ Window X11DRV_get_client_window( HWND hwnd )
*/ */
Window X11DRV_get_whole_window( HWND hwnd ) Window X11DRV_get_whole_window( HWND hwnd )
{ {
Window ret = 0; struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
WND *win = WIN_GetPtr( hwnd );
if (win == WND_OTHER_PROCESS) if (!data) return (Window)GetPropA( hwnd, whole_window_atom );
return (Window)GetPropA( hwnd, whole_window_atom ); return data->whole_window;
if (win)
{
struct x11drv_win_data *data = win->pDriverData;
ret = data->whole_window;
WIN_ReleasePtr( win );
}
return ret;
} }
@ -1211,16 +1230,10 @@ Window X11DRV_get_whole_window( HWND hwnd )
*/ */
XIC X11DRV_get_ic( HWND hwnd ) XIC X11DRV_get_ic( HWND hwnd )
{ {
XIC ret = 0; struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
WND *win = WIN_GetPtr( hwnd );
if (win && win != WND_OTHER_PROCESS) if (!data) return 0;
{ return data->xic;
struct x11drv_win_data *data = win->pDriverData;
ret = data->xic;
WIN_ReleasePtr( win );
}
return ret;
} }
@ -1244,6 +1257,7 @@ HWND X11DRV_SetParent( HWND hwnd, HWND parent )
if (parent != retvalue) if (parent != retvalue)
{ {
struct x11drv_win_data *data = wndPtr->pDriverData; struct x11drv_win_data *data = wndPtr->pDriverData;
Window new_parent = X11DRV_get_client_window( parent );
WIN_LinkWindow( hwnd, parent, HWND_TOP ); WIN_LinkWindow( hwnd, parent, HWND_TOP );
@ -1256,10 +1270,10 @@ HWND X11DRV_SetParent( HWND hwnd, HWND parent )
} }
} }
if (is_window_top_level( wndPtr )) X11DRV_set_wm_hints( display, wndPtr ); if (is_window_top_level( data->hwnd )) X11DRV_set_wm_hints( display, data );
X11DRV_sync_window_style( display, data );
wine_tsx11_lock(); wine_tsx11_lock();
X11DRV_sync_window_style( display, wndPtr ); XReparentWindow( display, data->whole_window, new_parent,
XReparentWindow( display, data->whole_window, X11DRV_get_client_window(parent),
data->whole_rect.left, data->whole_rect.top ); data->whole_rect.left, data->whole_rect.top );
wine_tsx11_unlock(); wine_tsx11_unlock();
} }
@ -1338,29 +1352,29 @@ void X11DRV_SetFocus( HWND hwnd )
*/ */
void X11DRV_SetWindowIcon( HWND hwnd, UINT type, HICON icon ) void X11DRV_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
{ {
WND *wndPtr;
Display *display = thread_display(); Display *display = thread_display();
struct x11drv_win_data *data;
DWORD ex_style;
if (type != ICON_BIG) return; /* nothing to do here */ if (type != ICON_BIG) return; /* nothing to do here */
if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return; if (!(data = X11DRV_get_win_data( hwnd ))) return;
if (wndPtr->dwExStyle & WS_EX_MANAGED) ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
if (ex_style & WS_EX_MANAGED)
{ {
Window win = get_whole_window(wndPtr);
XWMHints* wm_hints; XWMHints* wm_hints;
wine_tsx11_lock(); wine_tsx11_lock();
if (!(wm_hints = XGetWMHints( display, win ))) wm_hints = XAllocWMHints(); if (!(wm_hints = XGetWMHints( display, data->whole_window ))) wm_hints = XAllocWMHints();
wine_tsx11_unlock(); wine_tsx11_unlock();
if (wm_hints) if (wm_hints)
{ {
set_icon_hints( display, wndPtr, wm_hints, icon ); set_icon_hints( display, data, wm_hints, icon, ex_style );
wine_tsx11_lock(); wine_tsx11_lock();
XSetWMHints( display, win, wm_hints ); XSetWMHints( display, data->whole_window, wm_hints );
XFree( wm_hints ); XFree( wm_hints );
wine_tsx11_unlock(); wine_tsx11_unlock();
} }
} }
WIN_ReleasePtr( wndPtr );
} }

View File

@ -209,26 +209,23 @@ void X11DRV_Expose( HWND hwnd, XExposeEvent *event )
RECT rect; RECT rect;
struct x11drv_win_data *data; struct x11drv_win_data *data;
int flags = RDW_INVALIDATE | RDW_ERASE; int flags = RDW_INVALIDATE | RDW_ERASE;
WND *win;
TRACE( "win %p (%lx) %d,%d %dx%d\n", TRACE( "win %p (%lx) %d,%d %dx%d\n",
hwnd, event->window, event->x, event->y, event->width, event->height ); hwnd, event->window, event->x, event->y, event->width, event->height );
if (!(data = X11DRV_get_win_data( hwnd ))) return;
rect.left = event->x; rect.left = event->x;
rect.top = event->y; rect.top = event->y;
rect.right = rect.left + event->width; rect.right = rect.left + event->width;
rect.bottom = rect.top + event->height; rect.bottom = rect.top + event->height;
if (!(win = WIN_GetPtr( hwnd ))) return;
data = win->pDriverData;
if (event->window != data->client_window) /* whole window or icon window */ if (event->window != data->client_window) /* whole window or icon window */
{ {
flags |= RDW_FRAME; flags |= RDW_FRAME;
/* make position relative to client area instead of window */ /* make position relative to client area instead of window */
OffsetRect( &rect, -data->client_rect.left, -data->client_rect.top ); OffsetRect( &rect, -data->client_rect.left, -data->client_rect.top );
} }
WIN_ReleasePtr( win );
expose_window( hwnd, &rect, 0, flags ); expose_window( hwnd, &rect, 0, flags );
} }
@ -244,7 +241,7 @@ BOOL X11DRV_GetDC( HWND hwnd, HDC hdc, HRGN hrgn, DWORD flags )
{ {
HWND top = get_top_clipping_window( hwnd ); HWND top = get_top_clipping_window( hwnd );
WND *win = WIN_GetPtr( hwnd ); WND *win = WIN_GetPtr( hwnd );
X11DRV_WND_DATA *data = win->pDriverData; struct x11drv_win_data *data = win->pDriverData;
struct x11drv_escape_set_drawable escape; struct x11drv_escape_set_drawable escape;
escape.mode = IncludeInferiors; escape.mode = IncludeInferiors;
@ -615,63 +612,63 @@ static BOOL fixup_flags( WINDOWPOS *winpos )
* *
* Update the X state of a window to reflect a style change * Update the X state of a window to reflect a style change
*/ */
void X11DRV_SetWindowStyle( HWND hwnd, LONG oldStyle ) void X11DRV_SetWindowStyle( HWND hwnd, DWORD old_style )
{ {
Display *display = thread_display(); Display *display = thread_display();
WND *wndPtr; struct x11drv_win_data *data;
LONG changed; DWORD new_style, changed;
if (hwnd == GetDesktopWindow()) return; if (hwnd == GetDesktopWindow()) return;
if (!(wndPtr = WIN_GetPtr( hwnd ))) return; if (!(data = X11DRV_get_win_data( hwnd ))) return;
if (wndPtr == WND_OTHER_PROCESS) return;
changed = wndPtr->dwStyle ^ oldStyle; new_style = GetWindowLongW( hwnd, GWL_STYLE );
changed = new_style ^ old_style;
if (changed & WS_VISIBLE) if (changed & WS_VISIBLE)
{ {
if (X11DRV_is_window_rect_mapped( &wndPtr->rectWindow )) if (X11DRV_is_window_rect_mapped( &data->window_rect ))
{ {
if (wndPtr->dwStyle & WS_VISIBLE) if (new_style & WS_VISIBLE)
{ {
TRACE( "mapping win %p\n", hwnd ); TRACE( "mapping win %p\n", hwnd );
if (is_window_top_level(wndPtr)) if (is_window_top_level( hwnd ))
{ {
X11DRV_sync_window_style( display, wndPtr ); X11DRV_sync_window_style( display, data );
X11DRV_set_wm_hints( display, wndPtr ); X11DRV_set_wm_hints( display, data );
} }
wine_tsx11_lock(); wine_tsx11_lock();
XMapWindow( display, get_whole_window(wndPtr) ); XMapWindow( display, data->whole_window );
wine_tsx11_unlock(); wine_tsx11_unlock();
} }
else if (!is_window_top_level(wndPtr)) /* don't unmap managed windows */ else if (!is_window_top_level( hwnd )) /* don't unmap managed windows */
{ {
TRACE( "unmapping win %p\n", hwnd ); TRACE( "unmapping win %p\n", hwnd );
wine_tsx11_lock(); wine_tsx11_lock();
XUnmapWindow( display, get_whole_window(wndPtr) ); XUnmapWindow( display, data->whole_window );
wine_tsx11_unlock(); wine_tsx11_unlock();
} }
} }
DCE_InvalidateDCE( hwnd, &data->window_rect );
} }
if (changed & WS_DISABLED) if (changed & WS_DISABLED)
{ {
if (wndPtr->dwExStyle & WS_EX_MANAGED) if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_MANAGED)
{ {
XWMHints *wm_hints; XWMHints *wm_hints;
wine_tsx11_lock(); wine_tsx11_lock();
if (!(wm_hints = XGetWMHints( display, get_whole_window(wndPtr) ))) if (!(wm_hints = XGetWMHints( display, data->whole_window )))
wm_hints = XAllocWMHints(); wm_hints = XAllocWMHints();
if (wm_hints) if (wm_hints)
{ {
wm_hints->flags |= InputHint; wm_hints->flags |= InputHint;
wm_hints->input = !(wndPtr->dwStyle & WS_DISABLED); wm_hints->input = !(new_style & WS_DISABLED);
XSetWMHints( display, get_whole_window(wndPtr), wm_hints ); XSetWMHints( display, data->whole_window, wm_hints );
XFree(wm_hints); XFree(wm_hints);
} }
wine_tsx11_unlock(); wine_tsx11_unlock();
} }
} }
WIN_ReleasePtr(wndPtr);
} }
@ -730,9 +727,10 @@ BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow
DCE_InvalidateDCE( hwnd, &rect ); DCE_InvalidateDCE( hwnd, &rect );
} }
win->rectWindow = *rectWindow; win->rectWindow = *rectWindow;
win->rectClient = *rectClient; win->rectClient = *rectClient;
win->dwStyle = new_style; win->dwStyle = new_style;
data->window_rect = *rectWindow;
TRACE( "win %p window %s client %s style %08lx\n", TRACE( "win %p window %s client %s style %08lx\n",
hwnd, wine_dbgstr_rect(rectWindow), wine_dbgstr_rect(rectClient), new_style ); hwnd, wine_dbgstr_rect(rectWindow), wine_dbgstr_rect(rectClient), new_style );
@ -742,9 +740,9 @@ BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow
if (swp_flags & SWP_WINE_NOHOSTMOVE) if (swp_flags & SWP_WINE_NOHOSTMOVE)
{ {
data->whole_rect = *rectWindow; data->whole_rect = *rectWindow;
X11DRV_window_to_X_rect( win, &data->whole_rect ); X11DRV_window_to_X_rect( hwnd, &data->whole_rect );
if (data->client_window != data->whole_window) if (data->client_window != data->whole_window)
X11DRV_sync_client_window_position( display, win ); X11DRV_sync_client_window_position( display, data, rectClient );
} }
else if (data->whole_window) /* don't do anything if X window not created yet */ else if (data->whole_window) /* don't do anything if X window not created yet */
{ {
@ -765,8 +763,8 @@ BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow
wine_tsx11_unlock(); wine_tsx11_unlock();
} }
X11DRV_sync_whole_window_position( display, win, !(swp_flags & SWP_NOZORDER) ); X11DRV_sync_whole_window_position( display, data, !(swp_flags & SWP_NOZORDER) );
X11DRV_sync_client_window_position( display, win ); X11DRV_sync_client_window_position( display, data, rectClient );
if (!(old_style & WS_VISIBLE) && (new_style & WS_VISIBLE)) if (!(old_style & WS_VISIBLE) && (new_style & WS_VISIBLE))
{ {
@ -774,10 +772,10 @@ BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow
if (X11DRV_is_window_rect_mapped( rectWindow )) if (X11DRV_is_window_rect_mapped( rectWindow ))
{ {
TRACE( "mapping win %p\n", hwnd ); TRACE( "mapping win %p\n", hwnd );
if (is_window_top_level(win)) if (is_window_top_level( hwnd ))
{ {
X11DRV_sync_window_style( display, win ); X11DRV_sync_window_style( display, data );
X11DRV_set_wm_hints( display, win ); X11DRV_set_wm_hints( display, data );
} }
wine_tsx11_lock(); wine_tsx11_lock();
XMapWindow( display, data->whole_window ); XMapWindow( display, data->whole_window );
@ -999,7 +997,7 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
WIN_SetStyle( hwnd, (wndPtr->dwStyle & ~WS_MAXIMIZE) | WS_MINIMIZE ); WIN_SetStyle( hwnd, (wndPtr->dwStyle & ~WS_MAXIMIZE) | WS_MINIMIZE );
X11DRV_set_iconic_state( wndPtr ); X11DRV_set_iconic_state( hwnd );
wpl.ptMinPosition = WINPOS_FindIconPos( wndPtr, wpl.ptMinPosition ); wpl.ptMinPosition = WINPOS_FindIconPos( wndPtr, wpl.ptMinPosition );
@ -1015,7 +1013,7 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
if (old_style & WS_MINIMIZE) if (old_style & WS_MINIMIZE)
{ {
WINPOS_ShowIconTitle( hwnd, FALSE ); WINPOS_ShowIconTitle( hwnd, FALSE );
X11DRV_set_iconic_state( wndPtr ); X11DRV_set_iconic_state( hwnd );
} }
SetRect( rect, wpl.ptMaxPosition.x, wpl.ptMaxPosition.y, size.x, size.y ); SetRect( rect, wpl.ptMaxPosition.x, wpl.ptMaxPosition.y, size.x, size.y );
break; break;
@ -1025,7 +1023,7 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
if (old_style & WS_MINIMIZE) if (old_style & WS_MINIMIZE)
{ {
WINPOS_ShowIconTitle( hwnd, FALSE ); WINPOS_ShowIconTitle( hwnd, FALSE );
X11DRV_set_iconic_state( wndPtr ); X11DRV_set_iconic_state( hwnd );
if( wndPtr->flags & WIN_RESTORE_MAX) if( wndPtr->flags & WIN_RESTORE_MAX)
{ {
@ -1195,6 +1193,7 @@ void X11DRV_MapNotify( HWND hwnd, XMapEvent *event )
(win->dwStyle & WS_MINIMIZE) && (win->dwStyle & WS_MINIMIZE) &&
(win->dwExStyle & WS_EX_MANAGED)) (win->dwExStyle & WS_EX_MANAGED))
{ {
struct x11drv_win_data *data = win->pDriverData;
int x, y; int x, y;
unsigned int width, height, border, depth; unsigned int width, height, border, depth;
Window root, top; Window root, top;
@ -1203,15 +1202,15 @@ void X11DRV_MapNotify( HWND hwnd, XMapEvent *event )
/* FIXME: hack */ /* FIXME: hack */
wine_tsx11_lock(); wine_tsx11_lock();
XGetGeometry( event->display, get_whole_window(win), &root, &x, &y, &width, &height, XGetGeometry( event->display, data->whole_window, &root, &x, &y, &width, &height,
&border, &depth ); &border, &depth );
XTranslateCoordinates( event->display, get_whole_window(win), root, 0, 0, &x, &y, &top ); XTranslateCoordinates( event->display, data->whole_window, root, 0, 0, &x, &y, &top );
wine_tsx11_unlock(); wine_tsx11_unlock();
rect.left = x; rect.left = x;
rect.top = y; rect.top = y;
rect.right = x + width; rect.right = x + width;
rect.bottom = y + height; rect.bottom = y + height;
X11DRV_X_to_window_rect( win, &rect ); X11DRV_X_to_window_rect( hwnd, &rect );
DCE_InvalidateDCE( hwnd, &win->rectWindow ); DCE_InvalidateDCE( hwnd, &win->rectWindow );
@ -1404,13 +1403,11 @@ void X11DRV_ConfigureNotify( HWND hwnd, XConfigureEvent *event )
{ {
HWND oldInsertAfter; HWND oldInsertAfter;
struct x11drv_win_data *data; struct x11drv_win_data *data;
WND *win;
RECT rect; RECT rect;
WINDOWPOS winpos; WINDOWPOS winpos;
int x = event->x, y = event->y; int x = event->x, y = event->y;
if (!(win = WIN_GetPtr( hwnd ))) return; if (!(data = X11DRV_get_win_data( hwnd ))) return;
data = win->pDriverData;
/* Get geometry */ /* Get geometry */
@ -1429,8 +1426,7 @@ void X11DRV_ConfigureNotify( HWND hwnd, XConfigureEvent *event )
TRACE( "win %p new X rect %ld,%ld,%ldx%ld (event %d,%d,%dx%d)\n", TRACE( "win %p new X rect %ld,%ld,%ldx%ld (event %d,%d,%dx%d)\n",
hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
event->x, event->y, event->width, event->height ); event->x, event->y, event->width, event->height );
X11DRV_X_to_window_rect( win, &rect ); X11DRV_X_to_window_rect( hwnd, &rect );
WIN_ReleasePtr( win );
winpos.hwnd = hwnd; winpos.hwnd = hwnd;
winpos.x = rect.left; winpos.x = rect.left;
@ -1493,55 +1489,47 @@ void X11DRV_ConfigureNotify( HWND hwnd, XConfigureEvent *event )
*/ */
int X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw ) int X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
{ {
WND *wndPtr; struct x11drv_win_data *data;
if ((wndPtr = WIN_GetPtr( hwnd )) == WND_OTHER_PROCESS) if (!(data = X11DRV_get_win_data( hwnd )))
{ {
if (IsWindow( hwnd )) if (IsWindow( hwnd ))
FIXME( "not supported on other process window %p\n", hwnd ); FIXME( "not supported on other process window %p\n", hwnd );
wndPtr = NULL;
}
if (!wndPtr)
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE ); SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return FALSE; return FALSE;
} }
#ifdef HAVE_LIBXSHAPE #ifdef HAVE_LIBXSHAPE
if (data->whole_window)
{ {
Display *display = thread_display(); Display *display = thread_display();
X11DRV_WND_DATA *data = wndPtr->pDriverData;
if (data->whole_window) if (!hrgn)
{ {
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(); wine_tsx11_lock();
XShapeCombineMask( display, data->whole_window, XShapeCombineRectangles( display, data->whole_window, ShapeBounding,
ShapeBounding, 0, 0, None, ShapeSet ); 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(); wine_tsx11_unlock();
} HeapFree(GetProcessHeap(), 0, pRegionData);
else
{
RGNDATA *pRegionData = X11DRV_GetRegionData( hrgn, 0 );
if (pRegionData)
{
wine_tsx11_lock();
XShapeCombineRectangles( display, data->whole_window, ShapeBounding,
wndPtr->rectWindow.left - data->whole_rect.left,
wndPtr->rectWindow.top - data->whole_rect.top,
(XRectangle *)pRegionData->Buffer,
pRegionData->rdh.nCount,
ShapeSet, YXBanded );
wine_tsx11_unlock();
HeapFree(GetProcessHeap(), 0, pRegionData);
}
} }
} }
} }
#endif /* HAVE_LIBXSHAPE */ #endif /* HAVE_LIBXSHAPE */
WIN_ReleasePtr( wndPtr );
return TRUE; return TRUE;
} }
@ -1696,12 +1684,6 @@ static void X11DRV_WMMoveResizeWindow( HWND hwnd, int x, int y, int dir )
XEvent xev; XEvent xev;
Display *display = thread_display(); Display *display = thread_display();
wine_tsx11_lock();
/* need to ungrab the pointer that may have been automatically grabbed
* with a ButtonPress event */
XUngrabPointer( display, CurrentTime );
xev.xclient.type = ClientMessage; xev.xclient.type = ClientMessage;
xev.xclient.window = X11DRV_get_whole_window(hwnd); xev.xclient.window = X11DRV_get_whole_window(hwnd);
xev.xclient.message_type = x11drv_atom(_NET_WM_MOVERESIZE); xev.xclient.message_type = x11drv_atom(_NET_WM_MOVERESIZE);
@ -1714,8 +1696,12 @@ static void X11DRV_WMMoveResizeWindow( HWND hwnd, int x, int y, int dir )
xev.xclient.data.l[2] = dir; /* direction */ xev.xclient.data.l[2] = dir; /* direction */
xev.xclient.data.l[3] = 1; /* button */ xev.xclient.data.l[3] = 1; /* button */
xev.xclient.data.l[4] = 0; /* unused */ xev.xclient.data.l[4] = 0; /* unused */
XSendEvent(display, root_window, False, SubstructureNotifyMask, &xev);
/* need to ungrab the pointer that may have been automatically grabbed
* with a ButtonPress event */
wine_tsx11_lock();
XUngrabPointer( display, CurrentTime );
XSendEvent(display, root_window, False, SubstructureNotifyMask, &xev);
wine_tsx11_unlock(); wine_tsx11_unlock();
} }
@ -1743,6 +1729,7 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
DWORD dwPoint = GetMessagePos (); DWORD dwPoint = GetMessagePos ();
BOOL DragFullWindows = FALSE; BOOL DragFullWindows = FALSE;
BOOL grab; BOOL grab;
Window parent_win, whole_win;
Display *old_gdi_display = NULL; Display *old_gdi_display = NULL;
Display *display = thread_display(); Display *display = thread_display();
@ -1863,21 +1850,24 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
/* grab the server only when moving top-level windows without desktop */ /* grab the server only when moving top-level windows without desktop */
grab = (!DragFullWindows && !parent && (root_window == DefaultRootWindow(gdi_display))); grab = (!DragFullWindows && !parent && (root_window == DefaultRootWindow(gdi_display)));
wine_tsx11_lock();
if (grab) if (grab)
{ {
wine_tsx11_lock();
XSync( gdi_display, False ); XSync( gdi_display, False );
XGrabServer( display ); XGrabServer( display );
XSync( display, False ); XSync( display, False );
/* switch gdi display to the thread display, since the server is grabbed */ /* switch gdi display to the thread display, since the server is grabbed */
old_gdi_display = gdi_display; old_gdi_display = gdi_display;
gdi_display = display; gdi_display = display;
wine_tsx11_unlock();
} }
XGrabPointer( display, X11DRV_get_whole_window(hwnd), False, whole_win = X11DRV_get_whole_window(hwnd);
parent_win = parent ? X11DRV_get_client_window(parent) : root_window;
wine_tsx11_lock();
XGrabPointer( display, whole_win, False,
PointerMotionMask | ButtonPressMask | ButtonReleaseMask, PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, GrabModeAsync, GrabModeAsync, parent_win, None, CurrentTime );
parent ? X11DRV_get_client_window(parent) : root_window,
None, CurrentTime );
wine_tsx11_unlock(); wine_tsx11_unlock();
while(1) while(1)

View File

@ -40,7 +40,8 @@ typedef int Status;
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "win.h" #include "wingdi.h"
#include "winuser.h"
#include "ddrawi.h" #include "ddrawi.h"
#include "thread.h" #include "thread.h"
@ -508,9 +509,11 @@ extern int X11DRV_ProcessTabletEvent(HWND hwnd, XEvent *event);
/* x11drv private window data */ /* x11drv private window data */
struct x11drv_win_data struct x11drv_win_data
{ {
HWND hwnd; /* hwnd that this private data belongs to */
Window whole_window; /* X window for the complete window */ Window whole_window; /* X window for the complete window */
Window client_window; /* X window for the client area */ Window client_window; /* X window for the client area */
Window icon_window; /* X window for the icon */ Window icon_window; /* X window for the icon */
RECT window_rect; /* USER window rectangle relative to parent */
RECT whole_rect; /* X window rectangle for the whole window relative to parent */ RECT whole_rect; /* X window rectangle for the whole window relative to parent */
RECT client_rect; /* client area relative to whole window */ RECT client_rect; /* client area relative to whole window */
XIC xic; /* X input context */ XIC xic; /* X input context */
@ -518,28 +521,16 @@ struct x11drv_win_data
HBITMAP hWMIconMask; HBITMAP hWMIconMask;
}; };
typedef struct x11drv_win_data X11DRV_WND_DATA; extern struct x11drv_win_data *X11DRV_get_win_data( HWND hwnd );
extern Window X11DRV_get_client_window( HWND hwnd ); extern Window X11DRV_get_client_window( HWND hwnd );
extern Window X11DRV_get_whole_window( HWND hwnd ); extern Window X11DRV_get_whole_window( HWND hwnd );
extern BOOL X11DRV_is_window_rect_mapped( const RECT *rect ); extern BOOL X11DRV_is_window_rect_mapped( const RECT *rect );
extern XIC X11DRV_get_ic( HWND hwnd ); extern XIC X11DRV_get_ic( HWND hwnd );
inline static Window get_client_window( WND *wnd ) inline static BOOL is_window_top_level( HWND hwnd )
{ {
struct x11drv_win_data *data = wnd->pDriverData; return (root_window == DefaultRootWindow(gdi_display) &&
return data->client_window; GetAncestor( hwnd, GA_PARENT ) == GetDesktopWindow());
}
inline static Window get_whole_window( WND *wnd )
{
struct x11drv_win_data *data = wnd->pDriverData;
return data->whole_window;
}
inline static BOOL is_window_top_level( WND *win )
{
return (root_window == DefaultRootWindow(gdi_display) && win->parent == GetDesktopWindow());
} }
extern void X11DRV_SetFocus( HWND hwnd ); extern void X11DRV_SetFocus( HWND hwnd );
@ -550,17 +541,19 @@ typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void
extern void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg ); extern void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg );
extern int X11DRV_check_error(void); extern int X11DRV_check_error(void);
extern void X11DRV_register_window( Display *display, HWND hwnd, struct x11drv_win_data *data ); extern void X11DRV_register_window( Display *display, HWND hwnd, struct x11drv_win_data *data );
extern void X11DRV_set_iconic_state( WND *win ); extern void X11DRV_set_iconic_state( HWND hwnd );
extern void X11DRV_window_to_X_rect( WND *win, RECT *rect ); extern void X11DRV_window_to_X_rect( HWND hwnd, RECT *rect );
extern void X11DRV_X_to_window_rect( WND *win, RECT *rect ); extern void X11DRV_X_to_window_rect( HWND hwnd, RECT *rect );
extern void X11DRV_create_desktop_thread(void); extern void X11DRV_create_desktop_thread(void);
extern Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry ); extern Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry );
extern void X11DRV_sync_window_style( Display *display, WND *win ); extern void X11DRV_sync_window_style( Display *display, struct x11drv_win_data *data );
extern int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder ); extern int X11DRV_sync_whole_window_position( Display *display, struct x11drv_win_data *data,
extern int X11DRV_sync_client_window_position( Display *display, WND *win ); int zorder );
extern int X11DRV_sync_client_window_position( Display *display, struct x11drv_win_data *data,
const RECT *new_client_rect );
extern BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow, extern BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow,
const RECT *rectClient, UINT swp_flags, UINT wvr_flags ); const RECT *rectClient, UINT swp_flags, UINT wvr_flags );
extern void X11DRV_set_wm_hints( Display *display, WND *win ); extern void X11DRV_set_wm_hints( Display *display, struct x11drv_win_data *data );
extern void X11DRV_handle_desktop_resize(unsigned int width, unsigned int height); extern void X11DRV_handle_desktop_resize(unsigned int width, unsigned int height);
extern void X11DRV_Settings_AddDepthModes(void); extern void X11DRV_Settings_AddDepthModes(void);

View File

@ -59,7 +59,6 @@
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "winreg.h" #include "winreg.h"
#include "win.h"
#include "x11drv.h" #include "x11drv.h"
#include "xvidmode.h" #include "xvidmode.h"
#include "xrandr.h" #include "xrandr.h"

View File

@ -35,7 +35,6 @@
#include "controls.h" #include "controls.h"
#include "nonclient.h" #include "nonclient.h"
#include "winpos.h" #include "winpos.h"
#include "dce.h"
#include "message.h" #include "message.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/winuser16.h" #include "wine/winuser16.h"
@ -201,7 +200,6 @@ static void DEFWND_SetRedraw( HWND hwnd, WPARAM wParam )
if( !bVisible ) if( !bVisible )
{ {
WIN_SetStyle( hwnd, wndPtr->dwStyle | WS_VISIBLE ); WIN_SetStyle( hwnd, wndPtr->dwStyle | WS_VISIBLE );
DCE_InvalidateDCE( hwnd, &wndPtr->rectWindow );
} }
} }
else if( bVisible ) else if( bVisible )
@ -210,7 +208,6 @@ static void DEFWND_SetRedraw( HWND hwnd, WPARAM wParam )
else wParam = RDW_ALLCHILDREN | RDW_VALIDATE; else wParam = RDW_ALLCHILDREN | RDW_VALIDATE;
RedrawWindow( hwnd, NULL, 0, wParam ); RedrawWindow( hwnd, NULL, 0, wParam );
DCE_InvalidateDCE( hwnd, &wndPtr->rectWindow );
WIN_SetStyle( hwnd, wndPtr->dwStyle & ~WS_VISIBLE ); WIN_SetStyle( hwnd, wndPtr->dwStyle & ~WS_VISIBLE );
} }
WIN_ReleaseWndPtr( wndPtr ); WIN_ReleaseWndPtr( wndPtr );