Commit ddc3317b authored by Alexandre Julliard's avatar Alexandre Julliard

Store in the server all the window information accessible with

Get/SetWindowLong.
parent 3bb9a36e
......@@ -1714,10 +1714,8 @@ LPINT lpMax /* [out] Where to store maximum value */)
BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
BOOL fShowH, BOOL fShowV )
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
BOOL retvalue = FALSE;
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
if (!wndPtr) return FALSE;
TRACE("hwnd=%04x bar=%d horz=%d, vert=%d\n",
hwnd, nBar, fShowH, fShowV );
......@@ -1725,20 +1723,19 @@ BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
{
case SB_CTL:
ShowWindow( hwnd, fShowH ? SW_SHOW : SW_HIDE );
retvalue = TRUE;
goto END;
return TRUE;
case SB_BOTH:
case SB_HORZ:
if (fShowH)
{
fShowH = !(wndPtr->dwStyle & WS_HSCROLL);
wndPtr->dwStyle |= WS_HSCROLL;
fShowH = !(style & WS_HSCROLL);
style |= WS_HSCROLL;
}
else /* hide it */
{
fShowH = (wndPtr->dwStyle & WS_HSCROLL);
wndPtr->dwStyle &= ~WS_HSCROLL;
fShowH = (style & WS_HSCROLL);
style &= ~WS_HSCROLL;
}
if( nBar == SB_HORZ ) {
fShowV = FALSE;
......@@ -1749,35 +1746,30 @@ BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
case SB_VERT:
if (fShowV)
{
fShowV = !(wndPtr->dwStyle & WS_VSCROLL);
wndPtr->dwStyle |= WS_VSCROLL;
fShowV = !(style & WS_VSCROLL);
style |= WS_VSCROLL;
}
else /* hide it */
{
fShowV = (wndPtr->dwStyle & WS_VSCROLL);
wndPtr->dwStyle &= ~WS_VSCROLL;
fShowV = (style & WS_VSCROLL);
style &= ~WS_VSCROLL;
}
if ( nBar == SB_VERT )
fShowH = FALSE;
break;
default:
retvalue = FALSE; /* Nothing to do! */
goto END;
return FALSE; /* Nothing to do! */
}
if( fShowH || fShowV ) /* frame has been changed, let the window redraw itself */
{
WIN_SetStyle( hwnd, style );
SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
| SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
retvalue = TRUE;
goto END;
return TRUE;
}
retvalue = FALSE; /* no frame changes */
END:
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
return FALSE; /* no frame changes */
}
......
......@@ -609,13 +609,9 @@ BOOL TTYDRV_SetWindowPos( WINDOWPOS *winpos )
WIN_SetRectangles( winpos->hwnd, &newWindowRect, &newClientRect );
if( winpos->flags & SWP_SHOWWINDOW )
{
wndPtr->dwStyle |= WS_VISIBLE;
}
WIN_SetStyle( winpos->hwnd, wndPtr->dwStyle | WS_VISIBLE );
else if( winpos->flags & SWP_HIDEWINDOW )
{
wndPtr->dwStyle &= ~WS_VISIBLE;
}
WIN_SetStyle( winpos->hwnd, wndPtr->dwStyle & ~WS_VISIBLE );
/* ------------------------------------------------------------------------ FINAL */
......
......@@ -1084,16 +1084,21 @@ static void reply_message( struct received_message_info *info, LRESULT result, B
*/
static LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
if (hwnd == GetDesktopWindow()) return 0;
switch(msg)
{
case WM_WINE_DESTROYWINDOW:
return WIN_DestroyWindow( hwnd );
case WM_WINE_SETWINDOWPOS:
return USER_Driver.pSetWindowPos( (WINDOWPOS *)lparam );
case WM_WINE_SHOWWINDOW:
return USER_Driver.pShowWindow( hwnd, wparam );
case WM_WINE_DESTROYWINDOW:
return WIN_DestroyWindow( hwnd );
return ShowWindow( hwnd, wparam );
case WM_WINE_SETPARENT:
return (LRESULT)WIN_SetParent( hwnd, (HWND)wparam );
return (LRESULT)SetParent( hwnd, (HWND)wparam );
case WM_WINE_SETWINDOWLONG:
return (LRESULT)SetWindowLongW( hwnd, wparam, lparam );
case WM_WINE_ENABLEWINDOW:
return EnableWindow( hwnd, wparam );
default:
FIXME( "unknown internal message %x\n", msg );
return 0;
......
......@@ -87,7 +87,6 @@ static BOOL load_driver(void)
GET_USER_FUNC(CreateWindow);
GET_USER_FUNC(DestroyWindow);
GET_USER_FUNC(GetDC);
GET_USER_FUNC(EnableWindow);
GET_USER_FUNC(ForceWindowRaise);
GET_USER_FUNC(MsgWaitForMultipleObjectsEx);
GET_USER_FUNC(ScrollDC);
......
......@@ -22,6 +22,7 @@
#include "debugtools.h"
#include "x11drv.h"
#include "win.h"
#include "winpos.h"
#include "dce.h"
#include "options.h"
......@@ -106,8 +107,8 @@ static int get_window_attributes( Display *display, WND *win, XSetWindowAttribut
BOOL is_top_level = is_window_top_level( win );
BOOL managed = is_top_level && is_window_managed( win );
if (managed) win->dwExStyle |= WS_EX_MANAGED;
else win->dwExStyle &= ~WS_EX_MANAGED;
if (managed) WIN_SetExStyle( win->hwndSelf, win->dwExStyle | WS_EX_MANAGED );
else WIN_SetExStyle( win->hwndSelf, win->dwExStyle & ~WS_EX_MANAGED );
attr->override_redirect = !managed;
attr->colormap = X11DRV_PALETTE_PaletteXColormap;
......@@ -833,13 +834,17 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
data->hWMIconBitmap = 0;
data->hWMIconMask = 0;
wndPtr = WIN_FindWndPtr( hwnd );
wndPtr = WIN_GetPtr( hwnd );
wndPtr->pDriverData = data;
/* initialize the dimensions before sending WM_GETMINMAXINFO */
SetRect( &rect, cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy );
WIN_SetRectangles( hwnd, &rect, &rect );
if (!wndPtr->parent)
{
create_desktop( display, wndPtr, cs );
WIN_ReleaseWndPtr( wndPtr );
WIN_ReleasePtr( wndPtr );
return TRUE;
}
......@@ -847,11 +852,30 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
if (!create_client_window( display, wndPtr )) goto failed;
TSXSync( display, False );
WIN_ReleaseWndPtr( wndPtr );
SetPropA( hwnd, whole_window_atom, (HANDLE)data->whole_window );
SetPropA( hwnd, client_window_atom, (HANDLE)data->client_window );
/* 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;
WIN_ReleasePtr( wndPtr );
WINPOS_GetMinMaxInfo( hwnd, &maxSize, &maxPos, &minTrack, &maxTrack);
if (maxSize.x < cs->cx) cs->cx = maxSize.x;
if (maxSize.y < cs->cy) cs->cy = maxSize.y;
if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
if (cs->cx < 0) cs->cx = 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 );
WIN_SetRectangles( hwnd, &rect, &rect );
X11DRV_sync_whole_window_position( display, wndPtr, 0 );
}
WIN_ReleasePtr( wndPtr );
/* send WM_NCCREATE */
TRACE( "hwnd %x cs %d,%d %dx%d\n", hwnd, cs->x, cs->y, cs->cx, cs->cy );
if (unicode)
......@@ -860,17 +884,20 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
ret = SendMessageA( hwnd, WM_NCCREATE, 0, (LPARAM)cs );
if (!ret)
{
X11DRV_DestroyWindow( hwnd );
WARN("aborted by WM_xxCREATE!\n");
return FALSE;
}
if (!(wndPtr = WIN_FindWndPtr(hwnd))) return FALSE;
if (!(wndPtr = WIN_GetPtr(hwnd))) return FALSE;
sync_window_style( display, wndPtr );
/* send WM_NCCALCSIZE */
rect = wndPtr->rectWindow;
WIN_ReleasePtr( wndPtr );
SendMessageW( hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rect );
if (!(wndPtr = WIN_GetPtr(hwnd))) return FALSE;
if (rect.left > rect.right || rect.top > rect.bottom) rect = wndPtr->rectWindow;
WIN_SetRectangles( hwnd, &wndPtr->rectWindow, &rect );
X11DRV_sync_client_window_position( display, wndPtr );
......@@ -892,7 +919,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
else
WIN_LinkWindow( hwnd, wndPtr->parent, HWND_TOP );
WIN_ReleaseWndPtr( wndPtr );
WIN_ReleasePtr( wndPtr );
if (unicode)
ret = (SendMessageW( hwnd, WM_CREATE, 0, (LPARAM)cs ) != -1);
......@@ -902,7 +929,6 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
if (!ret)
{
WIN_UnlinkWindow( hwnd );
X11DRV_DestroyWindow( hwnd );
return FALSE;
}
......@@ -932,7 +958,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
RECT newPos;
UINT swFlag = (wndPtr->dwStyle & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
wndPtr->dwStyle &= ~(WS_MAXIMIZE | WS_MINIMIZE);
WIN_SetStyle( hwnd, wndPtr->dwStyle & ~(WS_MAXIMIZE | WS_MINIMIZE) );
WINPOS_MinMaximize( hwnd, swFlag, &newPos );
swFlag = ((wndPtr->dwStyle & WS_CHILD) || GetActiveWindow())
? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
......@@ -946,8 +972,8 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
failed:
X11DRV_DestroyWindow( wndPtr->hwndSelf );
WIN_ReleaseWndPtr( wndPtr );
X11DRV_DestroyWindow( hwnd );
if (wndPtr) WIN_ReleasePtr( wndPtr );
return FALSE;
}
......@@ -1052,78 +1078,6 @@ HWND X11DRV_SetParent( HWND hwnd, HWND parent )
}
/*******************************************************************
* EnableWindow (X11DRV.@)
*/
BOOL X11DRV_EnableWindow( HWND hwnd, BOOL enable )
{
Display *display = thread_display();
XWMHints *wm_hints;
WND *wndPtr;
BOOL retvalue;
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
hwnd = wndPtr->hwndSelf; /* make it a full handle */
retvalue = ((wndPtr->dwStyle & WS_DISABLED) != 0);
if (enable && (wndPtr->dwStyle & WS_DISABLED))
{
/* Enable window */
wndPtr->dwStyle &= ~WS_DISABLED;
if (wndPtr->dwExStyle & WS_EX_MANAGED)
{
wine_tsx11_lock();
if (!(wm_hints = XGetWMHints( display, get_whole_window(wndPtr) )))
wm_hints = XAllocWMHints();
if (wm_hints)
{
wm_hints->flags |= InputHint;
wm_hints->input = TRUE;
XSetWMHints( display, get_whole_window(wndPtr), wm_hints );
XFree(wm_hints);
}
wine_tsx11_unlock();
}
SendMessageA( hwnd, WM_ENABLE, TRUE, 0 );
}
else if (!enable && !(wndPtr->dwStyle & WS_DISABLED))
{
SendMessageA( wndPtr->hwndSelf, WM_CANCELMODE, 0, 0 );
/* Disable window */
wndPtr->dwStyle |= WS_DISABLED;
if (wndPtr->dwExStyle & WS_EX_MANAGED)
{
wine_tsx11_lock();
if (!(wm_hints = XGetWMHints( display, get_whole_window(wndPtr) )))
wm_hints = XAllocWMHints();
if (wm_hints)
{
wm_hints->flags |= InputHint;
wm_hints->input = FALSE;
XSetWMHints( display, get_whole_window(wndPtr), wm_hints );
XFree(wm_hints);
}
wine_tsx11_unlock();
}
if (hwnd == GetFocus())
SetFocus( 0 ); /* A disabled window can't have the focus */
if (hwnd == GetCapture())
ReleaseCapture(); /* A disabled window can't capture the mouse */
SendMessageA( hwnd, WM_ENABLE, FALSE, 0 );
}
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
/*****************************************************************
* SetFocus (X11DRV.@)
*
......
......@@ -78,7 +78,6 @@ debug_channels (bitblt bitmap clipboard cursor dinput event font gdi graphics
@ cdecl CreateWindow(long ptr long) X11DRV_CreateWindow
@ cdecl DestroyWindow(long) X11DRV_DestroyWindow
@ cdecl GetDC(long long long long) X11DRV_GetDC
@ cdecl EnableWindow(long long) X11DRV_EnableWindow
@ cdecl ForceWindowRaise(long) X11DRV_ForceWindowRaise
@ cdecl MsgWaitForMultipleObjectsEx(long ptr long long long) X11DRV_MsgWaitForMultipleObjectsEx
@ cdecl ScrollDC(long long long ptr ptr long ptr) X11DRV_ScrollDC
......
......@@ -38,7 +38,9 @@ enum wine_internal_message
WM_WINE_DESTROYWINDOW = 0x80000000,
WM_WINE_SETWINDOWPOS,
WM_WINE_SHOWWINDOW,
WM_WINE_SETPARENT
WM_WINE_SETPARENT,
WM_WINE_SETWINDOWLONG,
WM_WINE_ENABLEWINDOW
};
/* internal SendInput codes (FIXME) */
......@@ -79,7 +81,6 @@ typedef struct tagUSER_DRIVER {
BOOL (*pCreateWindow)(HWND,CREATESTRUCTA*,BOOL);
BOOL (*pDestroyWindow)(HWND);
BOOL (*pGetDC)(HWND,HDC,HRGN,DWORD);
BOOL (*pEnableWindow)(HWND,BOOL);
void (*pForceWindowRaise)(HWND);
DWORD (*pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,DWORD,DWORD,DWORD);
BOOL (*pScrollDC)(HDC,INT,INT,const RECT*,const RECT*,HRGN,LPRECT);
......@@ -87,7 +88,7 @@ typedef struct tagUSER_DRIVER {
void (*pSetFocus)(HWND);
HWND (*pSetParent)(HWND,HWND);
BOOL (*pSetWindowPos)(WINDOWPOS *);
BOOL (*pSetWindowRgn)(HWND,HRGN,BOOL);
int (*pSetWindowRgn)(HWND,HRGN,BOOL);
HICON (*pSetWindowIcon)(HWND,HICON,BOOL);
void (*pSetWindowStyle)(HWND,DWORD);
BOOL (*pSetWindowText)(HWND,LPCWSTR);
......
......@@ -89,6 +89,8 @@ extern HWND WIN_IsCurrentThread( HWND hwnd );
extern void WIN_LinkWindow( HWND hwnd, HWND parent, HWND hwndInsertAfter );
extern void WIN_UnlinkWindow( HWND hwnd );
extern void WIN_SetOwner( HWND hwnd, HWND owner );
extern LONG WIN_SetStyle( HWND hwnd, LONG style );
extern LONG WIN_SetExStyle( HWND hwnd, LONG style );
extern void WIN_SetRectangles( HWND hwnd, const RECT *rectWindow, const RECT *rectClient );
extern HWND WIN_FindWinToRepaint( HWND hwnd );
extern LRESULT WIN_DestroyWindow( HWND hwnd );
......@@ -97,7 +99,6 @@ extern BOOL WIN_CreateDesktopWindow(void);
extern BOOL WIN_IsWindowDrawable( HWND hwnd, BOOL );
extern HWND *WIN_ListParents( HWND hwnd );
extern HWND *WIN_ListChildren( HWND hwnd );
extern HWND WIN_SetParent( HWND hwnd, HWND parent );
extern BOOL WIN_InternalShowOwnedPopups( HWND owner, BOOL fShow, BOOL unmanagedOnly );
inline static HWND WIN_GetFullHandle( HWND hwnd )
......
......@@ -1601,6 +1601,7 @@ struct link_window_request
user_handle_t handle;
user_handle_t parent;
user_handle_t previous;
user_handle_t full_parent;
};
......@@ -1613,6 +1614,16 @@ struct destroy_window_request
struct set_window_owner_request
{
struct request_header __header;
user_handle_t handle;
user_handle_t owner;
user_handle_t full_owner;
};
struct get_window_info_request
{
struct request_header __header;
......@@ -1620,7 +1631,32 @@ struct get_window_info_request
user_handle_t full_handle;
void* pid;
void* tid;
atom_t atom;
};
struct set_window_info_request
{
struct request_header __header;
user_handle_t handle;
unsigned int flags;
unsigned int style;
unsigned int ex_style;
unsigned int id;
void* instance;
void* user_data;
unsigned int old_style;
unsigned int old_ex_style;
unsigned int old_id;
void* old_instance;
void* old_user_data;
};
#define SET_WIN_STYLE 0x01
#define SET_WIN_EXSTYLE 0x02
#define SET_WIN_ID 0x04
#define SET_WIN_INSTANCE 0x08
#define SET_WIN_USERDATA 0x10
......@@ -1858,7 +1894,9 @@ enum request
REQ_create_window,
REQ_link_window,
REQ_destroy_window,
REQ_set_window_owner,
REQ_get_window_info,
REQ_set_window_info,
REQ_get_window_parents,
REQ_get_window_children,
REQ_get_window_tree,
......@@ -2001,7 +2039,9 @@ union generic_request
struct create_window_request create_window;
struct link_window_request link_window;
struct destroy_window_request destroy_window;
struct set_window_owner_request set_window_owner;
struct get_window_info_request get_window_info;
struct set_window_info_request set_window_info;
struct get_window_parents_request get_window_parents;
struct get_window_children_request get_window_children;
struct get_window_tree_request get_window_tree;
......@@ -2014,6 +2054,6 @@ union generic_request
struct get_window_properties_request get_window_properties;
};
#define SERVER_PROTOCOL_VERSION 60
#define SERVER_PROTOCOL_VERSION 61
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -1434,6 +1434,7 @@ enum message_type
user_handle_t parent; /* handle to the parent */
user_handle_t previous; /* previous child in Z-order */
@REPLY
user_handle_t full_parent; /* full handle of new parent */
@END
......@@ -1443,6 +1444,15 @@ enum message_type
@END
/* Set a window owner */
@REQ(set_window_owner)
user_handle_t handle; /* handle to the window */
user_handle_t owner; /* new owner */
@REPLY
user_handle_t full_owner; /* full handle of new owner */
@END
/* Get information from a window handle */
@REQ(get_window_info)
user_handle_t handle; /* handle to the window */
......@@ -1450,9 +1460,33 @@ enum message_type
user_handle_t full_handle; /* full 32-bit handle */
void* pid; /* process owning the window */
void* tid; /* thread owning the window */
atom_t atom; /* class atom */
@END
/* Set some information in a window */
@REQ(set_window_info)
user_handle_t handle; /* handle to the window */
unsigned int flags; /* flags for fields to set (see below) */
unsigned int style; /* window style */
unsigned int ex_style; /* window extended style */
unsigned int id; /* window id */
void* instance; /* creator instance */
void* user_data; /* user-specific data */
@REPLY
unsigned int old_style; /* old window style */
unsigned int old_ex_style; /* old window extended style */
unsigned int old_id; /* old window id */
void* old_instance; /* old creator instance */
void* old_user_data; /* old user-specific data */
@END
#define SET_WIN_STYLE 0x01
#define SET_WIN_EXSTYLE 0x02
#define SET_WIN_ID 0x04
#define SET_WIN_INSTANCE 0x08
#define SET_WIN_USERDATA 0x10
/* Get a list of the window parents, up to the root of the tree */
@REQ(get_window_parents)
user_handle_t handle; /* handle to the window */
......
......@@ -191,7 +191,9 @@ DECL_HANDLER(get_named_pipe_info);
DECL_HANDLER(create_window);
DECL_HANDLER(link_window);
DECL_HANDLER(destroy_window);
DECL_HANDLER(set_window_owner);
DECL_HANDLER(get_window_info);
DECL_HANDLER(set_window_info);
DECL_HANDLER(get_window_parents);
DECL_HANDLER(get_window_children);
DECL_HANDLER(get_window_tree);
......@@ -333,7 +335,9 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_create_window,
(req_handler)req_link_window,
(req_handler)req_destroy_window,
(req_handler)req_set_window_owner,
(req_handler)req_get_window_info,
(req_handler)req_set_window_info,
(req_handler)req_get_window_parents,
(req_handler)req_get_window_children,
(req_handler)req_get_window_tree,
......
......@@ -1707,11 +1707,27 @@ static void dump_link_window_request( const struct link_window_request *req )
fprintf( stderr, " previous=%08x", req->previous );
}
static void dump_link_window_reply( const struct link_window_request *req )
{
fprintf( stderr, " full_parent=%08x", req->full_parent );
}
static void dump_destroy_window_request( const struct destroy_window_request *req )
{
fprintf( stderr, " handle=%08x", req->handle );
}
static void dump_set_window_owner_request( const struct set_window_owner_request *req )
{
fprintf( stderr, " handle=%08x,", req->handle );
fprintf( stderr, " owner=%08x", req->owner );
}
static void dump_set_window_owner_reply( const struct set_window_owner_request *req )
{
fprintf( stderr, " full_owner=%08x", req->full_owner );
}
static void dump_get_window_info_request( const struct get_window_info_request *req )
{
fprintf( stderr, " handle=%08x", req->handle );
......@@ -1721,7 +1737,28 @@ static void dump_get_window_info_reply( const struct get_window_info_request *re
{
fprintf( stderr, " full_handle=%08x,", req->full_handle );
fprintf( stderr, " pid=%p,", req->pid );
fprintf( stderr, " tid=%p", req->tid );
fprintf( stderr, " tid=%p,", req->tid );
fprintf( stderr, " atom=%04x", req->atom );
}
static void dump_set_window_info_request( const struct set_window_info_request *req )
{
fprintf( stderr, " handle=%08x,", req->handle );
fprintf( stderr, " flags=%08x,", req->flags );
fprintf( stderr, " style=%08x,", req->style );
fprintf( stderr, " ex_style=%08x,", req->ex_style );
fprintf( stderr, " id=%08x,", req->id );
fprintf( stderr, " instance=%p,", req->instance );
fprintf( stderr, " user_data=%p", req->user_data );
}
static void dump_set_window_info_reply( const struct set_window_info_request *req )
{
fprintf( stderr, " old_style=%08x,", req->old_style );
fprintf( stderr, " old_ex_style=%08x,", req->old_ex_style );
fprintf( stderr, " old_id=%08x,", req->old_id );
fprintf( stderr, " old_instance=%p,", req->old_instance );
fprintf( stderr, " old_user_data=%p", req->old_user_data );
}
static void dump_get_window_parents_request( const struct get_window_parents_request *req )
......@@ -1970,7 +2007,9 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_create_window_request,
(dump_func)dump_link_window_request,
(dump_func)dump_destroy_window_request,
(dump_func)dump_set_window_owner_request,
(dump_func)dump_get_window_info_request,
(dump_func)dump_set_window_info_request,
(dump_func)dump_get_window_parents_request,
(dump_func)dump_get_window_children_request,
(dump_func)dump_get_window_tree_request,
......@@ -2107,9 +2146,11 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)0,
(dump_func)dump_get_named_pipe_info_reply,
(dump_func)dump_create_window_reply,
(dump_func)dump_link_window_reply,
(dump_func)0,
(dump_func)0,
(dump_func)dump_set_window_owner_reply,
(dump_func)dump_get_window_info_reply,
(dump_func)dump_set_window_info_reply,
(dump_func)dump_get_window_parents_reply,
(dump_func)dump_get_window_children_reply,
(dump_func)dump_get_window_tree_reply,
......@@ -2248,7 +2289,9 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"create_window",
"link_window",
"destroy_window",
"set_window_owner",
"get_window_info",
"set_window_info",
"get_window_parents",
"get_window_children",
"get_window_tree",
......
......@@ -42,6 +42,11 @@ struct window
atom_t atom; /* class atom */
rectangle_t window_rect; /* window rectangle */
rectangle_t client_rect; /* client rectangle */
unsigned int style; /* window style */
unsigned int ex_style; /* window extended style */
unsigned int id; /* window id */
void* instance; /* creator instance */
void* user_data; /* user-specific data */
int prop_inuse; /* number of in-use window properties */
int prop_alloc; /* number of allocated window properties */
struct property *properties; /* window properties array */
......@@ -81,7 +86,11 @@ static void link_window( struct window *win, struct window *parent, struct windo
if (parent)
{
win->parent = parent;
if (win->parent != parent)
{
win->owner = NULL; /* reset owner if changing parent */
win->parent = parent;
}
if ((win->prev = previous))
{
if ((win->next = previous->next)) win->next->prev = win;
......@@ -261,6 +270,11 @@ static struct window *create_window( struct window *parent, struct window *owner
win->first_unlinked = NULL;
win->thread = current;
win->atom = atom;
win->style = 0;
win->ex_style = 0;
win->id = 0;
win->instance = NULL;
win->user_data = NULL;
win->prop_inuse = 0;
win->prop_alloc = 0;
win->properties = NULL;
......@@ -323,6 +337,12 @@ DECL_HANDLER(create_window)
if (!(parent = get_window( req->parent ))) return;
if (req->owner && !(owner = get_window( req->owner ))) return;
if (owner && owner->parent != parent)
{
/* owner must be a sibling of the new window */
set_error( STATUS_ACCESS_DENIED );
return;
}
if (!(win = create_window( parent, owner, req->atom ))) return;
req->handle = win->handle;
}
......@@ -342,6 +362,7 @@ DECL_HANDLER(link_window)
set_error( STATUS_INVALID_PARAMETER );
return;
}
req->full_parent = parent ? parent->handle : 0;
if (parent && req->previous)
{
if (req->previous == (user_handle_t)1) /* special case: HWND_BOTTOM */
......@@ -376,6 +397,24 @@ DECL_HANDLER(destroy_window)
}
/* set a window owner */
DECL_HANDLER(set_window_owner)
{
struct window *win = get_window( req->handle );
struct window *owner = get_window( req->owner );
if (!win || !owner) return;
if (owner->parent != win->parent)
{
/* owner has to be a sibling of window */
set_error( STATUS_ACCESS_DENIED );
return;
}
win->owner = owner;
req->full_owner = owner->handle;
}
/* get information from a window handle */
DECL_HANDLER(get_window_info)
{
......@@ -388,13 +427,32 @@ DECL_HANDLER(get_window_info)
req->full_handle = win->handle;
if (win->thread)
{
req->tid = get_thread_id( win->thread );
req->pid = get_process_id( win->thread->process );
req->tid = get_thread_id( win->thread );
req->pid = get_process_id( win->thread->process );
req->atom = win->atom;
}
}
}
/* set some information in a window */
DECL_HANDLER(set_window_info)
{
struct window *win = get_window( req->handle );
if (!win) return;
req->old_style = win->style;
req->old_ex_style = win->ex_style;
req->old_id = win->id;
req->old_instance = win->instance;
req->old_user_data = win->user_data;
if (req->flags & SET_WIN_STYLE) win->style = req->style;
if (req->flags & SET_WIN_EXSTYLE) win->ex_style = req->ex_style;
if (req->flags & SET_WIN_ID) win->id = req->id;
if (req->flags & SET_WIN_INSTANCE) win->instance = req->instance;
if (req->flags & SET_WIN_USERDATA) win->user_data = req->user_data;
}
/* get a list of the window parents, up to the root of the tree */
DECL_HANDLER(get_window_parents)
{
......
......@@ -168,9 +168,7 @@ static void DEFWND_SetRedraw( HWND hwnd, WPARAM wParam )
{
if( !bVisible )
{
wndPtr->dwStyle |= WS_VISIBLE;
if (USER_Driver.pSetWindowStyle)
USER_Driver.pSetWindowStyle( hwnd, wndPtr->dwStyle & ~WS_VISIBLE );
WIN_SetStyle( hwnd, wndPtr->dwStyle | WS_VISIBLE );
DCE_InvalidateDCE( hwnd, &wndPtr->rectWindow );
}
}
......@@ -181,9 +179,7 @@ static void DEFWND_SetRedraw( HWND hwnd, WPARAM wParam )
RedrawWindow( hwnd, NULL, 0, wParam );
DCE_InvalidateDCE( hwnd, &wndPtr->rectWindow );
wndPtr->dwStyle &= ~WS_VISIBLE;
if (USER_Driver.pSetWindowStyle)
USER_Driver.pSetWindowStyle( hwnd, wndPtr->dwStyle | WS_VISIBLE );
WIN_SetStyle( hwnd, wndPtr->dwStyle & ~WS_VISIBLE );
}
WIN_ReleaseWndPtr( wndPtr );
}
......
......@@ -215,15 +215,25 @@ BOOL WINAPI GetWindowRect( HWND hwnd, LPRECT rect )
int WINAPI GetWindowRgn ( HWND hwnd, HRGN hrgn )
{
int nRet = ERROR;
WND *wndPtr = WIN_FindWndPtr( hwnd );
if (wndPtr)
WND *wndPtr = WIN_GetPtr( hwnd );
if (wndPtr == WND_OTHER_PROCESS)
{
if (wndPtr->hrgnWnd) nRet = CombineRgn( hrgn, wndPtr->hrgnWnd, 0, RGN_COPY );
WIN_ReleaseWndPtr(wndPtr);
if (IsWindow( hwnd ))
FIXME( "not supported on other process window %x\n", hwnd );
wndPtr = NULL;
}
if (!wndPtr)
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return ERROR;
}
if (wndPtr->hrgnWnd) nRet = CombineRgn( hrgn, wndPtr->hrgnWnd, 0, RGN_COPY );
WIN_ReleasePtr( wndPtr );
return nRet;
}
/***********************************************************************
* SetWindowRgn (USER32.@)
*/
......@@ -231,22 +241,31 @@ int WINAPI SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL bRedraw )
{
RECT rect;
WND *wndPtr;
int ret = FALSE;
if (hrgn) /* verify that region really exists */
{
if (GetRgnBox( hrgn, &rect ) == ERROR) return FALSE;
}
if (USER_Driver.pSetWindowRgn)
return USER_Driver.pSetWindowRgn( hwnd, hrgn, bRedraw );
if (!(wndPtr = WIN_FindWndPtr(hwnd))) return FALSE;
if (wndPtr->hrgnWnd == hrgn)
if ((wndPtr = WIN_GetPtr( hwnd )) == WND_OTHER_PROCESS)
{
ret = TRUE;
goto done;
if (IsWindow( hwnd ))
FIXME( "not supported on other process window %x\n", hwnd );
wndPtr = NULL;
}
if (!wndPtr)
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return FALSE;
}
if (hrgn) /* verify that region really exists */
if (wndPtr->hrgnWnd == hrgn)
{
if (GetRgnBox( hrgn, &rect ) == ERROR) goto done;
WIN_ReleasePtr( wndPtr );
return TRUE;
}
if (wndPtr->hrgnWnd)
......@@ -256,17 +275,14 @@ int WINAPI SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL bRedraw )
wndPtr->hrgnWnd = 0;
}
wndPtr->hrgnWnd = hrgn;
WIN_ReleasePtr( wndPtr );
/* Size the window to the rectangle of the new region (if it isn't NULL) */
if (hrgn) SetWindowPos( hwnd, 0, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
SWP_NOSIZE | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOACTIVATE |
SWP_NOZORDER | (bRedraw ? 0 : SWP_NOREDRAW) );
ret = TRUE;
done:
WIN_ReleaseWndPtr(wndPtr);
return ret;
return TRUE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment