Commit 2fb7c875 authored by Alexandre Julliard's avatar Alexandre Julliard

Moved DCE support to the X11 driver.

parent dc84b8a4
......@@ -18,7 +18,6 @@ C_SRCS = \
$(TOPOBJDIR)/windows/class.c \
$(TOPOBJDIR)/windows/clipboard.c \
$(TOPOBJDIR)/windows/cursoricon.c \
$(TOPOBJDIR)/windows/dce.c \
$(TOPOBJDIR)/windows/defdlg.c \
$(TOPOBJDIR)/windows/defwnd.c \
$(TOPOBJDIR)/windows/dialog.c \
......
......@@ -32,7 +32,7 @@
#include "winuser.h"
#include "wine/server.h"
#include "win.h"
#include "dce.h"
#include "user_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(win);
......@@ -417,6 +417,111 @@ BOOL WINAPI EndPaint( HWND hwnd, const PAINTSTRUCT *lps )
/***********************************************************************
* GetDCEx (USER32.@)
*/
HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
{
if (!hwnd) hwnd = GetDesktopWindow();
else hwnd = WIN_GetFullHandle( hwnd );
if (USER_Driver.pGetDCEx) return USER_Driver.pGetDCEx( hwnd, hrgnClip, flags );
return 0;
}
/***********************************************************************
* GetDC (USER32.@)
*
* Get a device context.
*
* RETURNS
* Success: Handle to the device context
* Failure: NULL.
*/
HDC WINAPI GetDC( HWND hwnd )
{
if (!hwnd) return GetDCEx( 0, 0, DCX_CACHE | DCX_WINDOW );
return GetDCEx( hwnd, 0, DCX_USESTYLE );
}
/***********************************************************************
* GetWindowDC (USER32.@)
*/
HDC WINAPI GetWindowDC( HWND hwnd )
{
return GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW );
}
/***********************************************************************
* ReleaseDC (USER32.@)
*
* Release a device context.
*
* RETURNS
* Success: Non-zero. Resources used by hdc are released.
* Failure: 0.
*/
INT WINAPI ReleaseDC( HWND hwnd, HDC hdc )
{
if (USER_Driver.pReleaseDC) return USER_Driver.pReleaseDC( hwnd, hdc );
return 0;
}
/**********************************************************************
* WindowFromDC (USER32.@)
*/
HWND WINAPI WindowFromDC( HDC hDC )
{
if (USER_Driver.pWindowFromDC) return USER_Driver.pWindowFromDC( hDC );
return 0;
}
/***********************************************************************
* LockWindowUpdate (USER32.@)
*/
BOOL WINAPI LockWindowUpdate( HWND hwnd )
{
static HWND lockedWnd;
/* This function is fully implemented by the following patch:
*
* http://www.winehq.org/hypermail/wine-patches/2004/01/0142.html
*
* but in order to work properly, it needs the ability to invalidate
* DCEs in other processes when the lock window is changed, which
* isn't possible yet.
* -mike
*/
FIXME("(%p), partial stub!\n",hwnd);
USER_Lock();
if (lockedWnd)
{
if (!hwnd)
{
/* Unlock lockedWnd */
/* FIXME: Do something */
}
else
{
/* Attempted to lock a second window */
/* Return FALSE and do nothing */
USER_Unlock();
return FALSE;
}
}
lockedWnd = hwnd;
USER_Unlock();
return TRUE;
}
/***********************************************************************
* RedrawWindow (USER32.@)
*/
BOOL WINAPI RedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags )
......
......@@ -811,6 +811,16 @@ BOOL16 WINAPI IsMenu16( HMENU16 hmenu )
}
/***********************************************************************
* DCHook (USER.362)
*/
BOOL16 WINAPI DCHook16( HDC16 hdc, WORD code, DWORD data, LPARAM lParam )
{
FIXME( "hDC = %x, %i: stub\n", hdc, code );
return FALSE;
}
/**********************************************************************
* SetMenuContextHelpId (USER.384)
*/
......
......@@ -725,7 +725,6 @@
################################################################
# Wine dll separation hacks, these will go away, don't use them
#
@ cdecl DCE_InvalidateDCE(long ptr)
@ cdecl HOOK_CallHooks(long long long long long)
@ cdecl USER_Unlock()
@ cdecl WINPOS_ActivateOtherWindow(long)
......
......@@ -116,7 +116,7 @@ static BOOL load_driver(void)
GET_USER_FUNC(EnumDisplaySettingsExW);
GET_USER_FUNC(CreateWindow);
GET_USER_FUNC(DestroyWindow);
GET_USER_FUNC(GetDC);
GET_USER_FUNC(GetDCEx);
GET_USER_FUNC(MsgWaitForMultipleObjectsEx);
GET_USER_FUNC(ReleaseDC);
GET_USER_FUNC(ScrollDC);
......@@ -129,6 +129,7 @@ static BOOL load_driver(void)
GET_USER_FUNC(SetWindowText);
GET_USER_FUNC(ShowWindow);
GET_USER_FUNC(SysCommandSizeMove);
GET_USER_FUNC(WindowFromDC);
GET_USER_FUNC(WindowMessage);
return TRUE;
......
......@@ -100,9 +100,9 @@ typedef struct tagUSER_DRIVER {
/* windowing functions */
BOOL (*pCreateWindow)(HWND,CREATESTRUCTA*,BOOL);
BOOL (*pDestroyWindow)(HWND);
BOOL (*pGetDC)(HWND,HDC,HRGN,DWORD);
HDC (*pGetDCEx)(HWND,HRGN,DWORD);
DWORD (*pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,DWORD,DWORD,DWORD);
void (*pReleaseDC)(HWND,HDC);
BOOL (*pReleaseDC)(HWND,HDC);
BOOL (*pScrollDC)(HDC, INT, INT, const RECT *, const RECT *, HRGN, LPRECT);
void (*pSetFocus)(HWND);
HWND (*pSetParent)(HWND,HWND);
......@@ -113,6 +113,7 @@ typedef struct tagUSER_DRIVER {
BOOL (*pSetWindowText)(HWND,LPCWSTR);
BOOL (*pShowWindow)(HWND,INT);
void (*pSysCommandSizeMove)(HWND,WPARAM);
HWND (*pWindowFromDC)(HDC);
LRESULT (*pWindowMessage)(HWND,UINT,WPARAM,LPARAM);
} USER_DRIVER;
......
......@@ -14,6 +14,7 @@ C_SRCS = \
clipboard.c \
clipping.c \
codepage.c \
dce.c \
desktop.c \
dga2.c \
dib.c \
......
......@@ -845,6 +845,7 @@ BOOL X11DRV_DestroyWindow( HWND hwnd )
if (!(data = X11DRV_get_win_data( hwnd ))) return TRUE;
free_window_dce( data );
destroy_whole_window( display, data );
destroy_icon_window( display, data );
......@@ -902,6 +903,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
data->icon_window = 0;
data->xic = 0;
data->managed = FALSE;
data->dce = NULL;
data->hWMIconBitmap = 0;
data->hWMIconMask = 0;
......@@ -927,8 +929,11 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
if (!create_whole_window( display, data, cs->style )) goto failed;
}
/* get class or window DC if needed */
alloc_window_dce( data );
/* Call the WH_CBT hook */
/* the window style passed to the hook must be the real window style,
* rather than just the window style that the caller to CreateWindowEx
* passed in, so we have to copy the original CREATESTRUCT and get the
......
......@@ -40,7 +40,6 @@
#include "x11drv.h"
#include "win.h"
#include "winpos.h"
#include "dce.h"
#include "wine/server.h"
#include "wine/debug.h"
......@@ -83,58 +82,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
/***********************************************************************
* get_server_visible_region
*/
static HRGN get_server_visible_region( HWND hwnd, UINT flags )
{
RGNDATA *data;
NTSTATUS status;
HRGN ret = 0;
size_t size = 256;
do
{
if (!(data = HeapAlloc( GetProcessHeap(), 0, sizeof(*data) + size - 1 ))) return 0;
SERVER_START_REQ( get_visible_region )
{
req->window = hwnd;
req->flags = flags;
wine_server_set_reply( req, data->Buffer, size );
if (!(status = wine_server_call( req )))
{
size_t reply_size = wine_server_reply_size( reply );
data->rdh.dwSize = sizeof(data->rdh);
data->rdh.iType = RDH_RECTANGLES;
data->rdh.nCount = reply_size / sizeof(RECT);
data->rdh.nRgnSize = reply_size;
ret = ExtCreateRegion( NULL, size, data );
}
else size = reply->total_size;
}
SERVER_END_REQ;
HeapFree( GetProcessHeap(), 0, data );
} while (status == STATUS_BUFFER_OVERFLOW);
if (status) SetLastError( RtlNtStatusToDosError(status) );
return ret;
}
/***********************************************************************
* get_top_clipping_window
*
* Get the top window to clip against (i.e. the top parent that has
* an associated X window).
*/
static HWND get_top_clipping_window( HWND hwnd )
{
HWND ret = GetAncestor( hwnd, GA_ROOT );
if (!ret) ret = GetDesktopWindow();
return ret;
}
/***********************************************************************
* X11DRV_Expose
*/
void X11DRV_Expose( HWND hwnd, XEvent *xev )
......@@ -177,116 +124,6 @@ void X11DRV_Expose( HWND hwnd, XEvent *xev )
/***********************************************************************
* GetDC (X11DRV.@)
*
* Set the drawable, origin and dimensions for the DC associated to
* a given window.
*/
BOOL X11DRV_GetDC( HWND hwnd, HDC hdc, HRGN hrgn, DWORD flags )
{
HWND top = get_top_clipping_window( hwnd );
struct x11drv_escape_set_drawable escape;
struct x11drv_win_data *data;
escape.mode = IncludeInferiors;
/* don't clip siblings if using parent clip region */
if (flags & DCX_PARENTCLIP) flags &= ~DCX_CLIPSIBLINGS;
if (top != hwnd || !(data = X11DRV_get_win_data( hwnd )))
{
POINT client_offset;
if (flags & DCX_WINDOW)
{
RECT rect;
GetWindowRect( hwnd, &rect );
escape.org.x = rect.left;
escape.org.y = rect.top;
MapWindowPoints( 0, top, &escape.org, 1 );
escape.drawable_org.x = rect.left - escape.org.x;
escape.drawable_org.y = rect.top - escape.org.y;
}
else
{
escape.org.x = escape.org.y = 0;
escape.drawable_org.x = escape.drawable_org.y = 0;
MapWindowPoints( hwnd, top, &escape.org, 1 );
MapWindowPoints( top, 0, &escape.drawable_org, 1 );
}
/* now make origins relative to the X window and not the client area */
client_offset = X11DRV_get_client_area_offset( top );
escape.org.x += client_offset.x;
escape.org.y += client_offset.y;
escape.drawable_org.x -= client_offset.x;
escape.drawable_org.y -= client_offset.y;
escape.drawable = X11DRV_get_whole_window( top );
}
else
{
if (IsIconic( hwnd ))
{
escape.drawable = data->icon_window ? data->icon_window : data->whole_window;
escape.org.x = 0;
escape.org.y = 0;
escape.drawable_org = escape.org;
MapWindowPoints( hwnd, 0, &escape.drawable_org, 1 );
}
else
{
escape.drawable = data->whole_window;
escape.drawable_org.x = data->whole_rect.left;
escape.drawable_org.y = data->whole_rect.top;
if (flags & DCX_WINDOW)
{
escape.org.x = data->window_rect.left - data->whole_rect.left;
escape.org.y = data->window_rect.top - data->whole_rect.top;
}
else
{
escape.org.x = data->client_rect.left;
escape.org.y = data->client_rect.top;
}
}
}
escape.code = X11DRV_SET_DRAWABLE;
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
if (flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN) ||
SetHookFlags16( HDC_16(hdc), DCHF_VALIDATEVISRGN )) /* DC was dirty */
{
/* need to recompute the visible region */
HRGN visRgn = get_server_visible_region( hwnd, flags );
if (flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN))
CombineRgn( visRgn, visRgn, hrgn, (flags & DCX_INTERSECTRGN) ? RGN_AND : RGN_DIFF );
SelectVisRgn16( HDC_16(hdc), HRGN_16(visRgn) );
DeleteObject( visRgn );
}
return TRUE;
}
/***********************************************************************
* ReleaseDC (X11DRV.@)
*/
void X11DRV_ReleaseDC( HWND hwnd, HDC hdc )
{
struct x11drv_escape_set_drawable escape;
escape.code = X11DRV_SET_DRAWABLE;
escape.drawable = root_window;
escape.mode = IncludeInferiors;
escape.org.x = escape.org.y = 0;
escape.drawable_org.x = escape.drawable_org.y = 0;
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
}
/***********************************************************************
* SWP_DoWinPosChanging
*/
static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT* pNewClientRect )
......@@ -659,7 +496,7 @@ void X11DRV_SetWindowStyle( HWND hwnd, DWORD old_style )
}
/* we don't unmap windows, that causes trouble with the window manager */
}
DCE_InvalidateDCE( hwnd, &data->window_rect );
invalidate_dce( hwnd, &data->window_rect );
}
if (changed & WS_DISABLED)
......@@ -764,7 +601,7 @@ BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow
{
RECT rect;
UnionRect( &rect, rectWindow, &win->rectWindow );
DCE_InvalidateDCE( hwnd, &rect );
invalidate_dce( hwnd, &rect );
}
win->rectWindow = *rectWindow;
......@@ -1238,7 +1075,7 @@ void X11DRV_MapNotify( HWND hwnd, XEvent *event )
rect.bottom = y + height;
X11DRV_X_to_window_rect( data, &rect );
DCE_InvalidateDCE( hwnd, &data->window_rect );
invalidate_dce( hwnd, &data->window_rect );
if (win->flags & WIN_RESTORE_MAX) style |= WS_MAXIMIZE;
WIN_SetStyle( hwnd, style, WS_MINIMIZE );
......
......@@ -627,16 +627,17 @@ enum x11drv_window_messages
/* x11drv private window data */
struct x11drv_win_data
{
HWND hwnd; /* hwnd that this private data belongs to */
Window whole_window; /* X window for the complete window */
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 client_rect; /* client area relative to whole window */
XIC xic; /* X input context */
BOOL managed; /* is window managed? */
HBITMAP hWMIconBitmap;
HBITMAP hWMIconMask;
HWND hwnd; /* hwnd that this private data belongs to */
Window whole_window; /* X window for the complete window */
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 client_rect; /* client area relative to whole window */
XIC xic; /* X input context */
BOOL managed; /* is window managed? */
struct dce *dce; /* DCE for CS_OWNDC or CS_CLASSDC windows */
HBITMAP hWMIconBitmap;
HBITMAP hWMIconMask;
};
extern struct x11drv_win_data *X11DRV_get_win_data( HWND hwnd );
......@@ -645,6 +646,9 @@ extern Window X11DRV_get_whole_window( HWND hwnd );
extern BOOL X11DRV_is_window_rect_mapped( const RECT *rect );
extern XIC X11DRV_get_ic( HWND hwnd );
extern void alloc_window_dce( struct x11drv_win_data *data );
extern void free_window_dce( struct x11drv_win_data *data );
extern void invalidate_dce( HWND hwnd, const RECT *rect );
/* X context to associate a hwnd to an X window */
extern XContext winContext;
......
......@@ -92,7 +92,7 @@
@ cdecl EnumClipboardFormats(long) X11DRV_EnumClipboardFormats
@ cdecl GetClipboardData(long ptr ptr) X11DRV_GetClipboardData
@ cdecl GetClipboardFormatName(long str long) X11DRV_GetClipboardFormatName
@ cdecl GetDC(long long long long) X11DRV_GetDC
@ cdecl GetDCEx(long long long) X11DRV_GetDCEx
@ cdecl IsClipboardFormatAvailable(long) X11DRV_IsClipboardFormatAvailable
@ cdecl MsgWaitForMultipleObjectsEx(long ptr long long long) X11DRV_MsgWaitForMultipleObjectsEx
@ cdecl RegisterClipboardFormat(str) X11DRV_RegisterClipboardFormat
......@@ -109,6 +109,7 @@
@ cdecl SetWindowText(long wstr) X11DRV_SetWindowText
@ cdecl ShowWindow(long long) X11DRV_ShowWindow
@ cdecl SysCommandSizeMove(long long) X11DRV_SysCommandSizeMove
@ cdecl WindowFromDC(long) X11DRV_WindowFromDC
@ cdecl WindowMessage(long long long long) X11DRV_WindowMessage
# WinTab32
......
/*
* USER DCE definitions
*
* Copyright 1993 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WINE_DCE_H
#define __WINE_DCE_H
#include <windef.h>
/* internal DCX flags */
#define DCX_DCEEMPTY 0x00000800
#define DCX_DCEBUSY 0x00001000
#define DCX_DCEDIRTY 0x00002000
#define DCX_WINDOWPAINT 0x00020000
typedef enum
{
DCE_CACHE_DC, /* This is a cached DC (allocated by USER) */
DCE_CLASS_DC, /* This is a class DC (style CS_CLASSDC) */
DCE_WINDOW_DC /* This is a window DC (style CS_OWNDC) */
} DCE_TYPE;
struct tagDCE;
extern struct tagDCE *DCE_AllocDCE( HWND hWnd, DCE_TYPE type );
extern void DCE_FreeDCE( struct tagDCE *dce );
extern void DCE_FreeWindowDCE( HWND );
extern BOOL DCE_InvalidateDCE( HWND, const RECT* );
#endif /* __WINE_DCE_H */
......@@ -31,7 +31,6 @@
#define WND_MAGIC 0x444e4957 /* 'WIND' */
struct tagCLASS;
struct tagDCE;
typedef struct tagWND
{
......@@ -48,7 +47,6 @@ typedef struct tagWND
LPWSTR text; /* Window text */
void *pVScroll; /* Vertical scroll-bar info */
void *pHScroll; /* Horizontal scroll-bar info */
struct tagDCE *dce; /* Window DCE (if CS_OWNDC or CS_CLASSDC) */
DWORD dwStyle; /* Window style (from CreateWindow) */
DWORD dwExStyle; /* Extended style (from CreateWindowEx) */
DWORD clsStyle; /* Class style at window creation */
......@@ -108,4 +106,7 @@ inline static void WIN_ReleasePtr( WND *ptr )
extern LRESULT HOOK_CallHooks( INT id, INT code, WPARAM wparam, LPARAM lparam, BOOL unicode );
/* internal GetDC flag (FIXME) */
#define DCX_WINDOWPAINT 0x00020000
#endif /* __WINE_WIN_H */
......@@ -36,7 +36,6 @@
#include "win.h"
#include "user_private.h"
#include "controls.h"
#include "dce.h"
#include "winproc.h"
#include "wine/server.h"
#include "wine/list.h"
......@@ -55,7 +54,6 @@ typedef struct tagCLASS
INT cbWndExtra; /* Window extra bytes */
LPWSTR menuName; /* Default menu name (Unicode followed by ASCII) */
SEGPTR segMenuName; /* Default menu name as SEGPTR */
struct tagDCE *dce; /* Class DCE (if CS_CLASSDC) */
HINSTANCE hInstance; /* Module that created the task */
HICON hIcon; /* Default icon */
HICON hIconSm; /* Default small icon */
......@@ -292,7 +290,6 @@ static void CLASS_FreeClass( CLASS *classPtr )
USER_Lock();
list_remove( &classPtr->entry );
if (classPtr->dce) DCE_FreeDCE( classPtr->dce );
if (classPtr->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1))
DeleteObject( classPtr->hbrBackground );
UnMapLS( classPtr->segMenuName );
......@@ -421,7 +418,6 @@ static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE hInstance, BOOL local,
classPtr->cbClsExtra = classExtra;
classPtr->hInstance = hInstance;
classPtr->atomName = atom;
classPtr->dce = (style & CS_CLASSDC) ? DCE_AllocDCE( 0, DCE_CLASS_DC ) : NULL;
/* Other non-null values must be set by caller */
......@@ -509,7 +505,6 @@ void CLASS_AddWindow( CLASS *class, WND *win, WINDOWPROCTYPE type )
}
win->class = class;
win->clsStyle = class->style;
win->dce = class->dce;
}
......
......@@ -29,7 +29,6 @@
#include "wownt32.h"
#include "win.h"
#include "user_private.h"
#include "dce.h"
#include "controls.h"
#include "cursoricon.h"
#include "winpos.h"
......
......@@ -34,7 +34,6 @@
#include "wine/unicode.h"
#include "win.h"
#include "user_private.h"
#include "dce.h"
#include "controls.h"
#include "cursoricon.h"
#include "message.h"
......@@ -578,7 +577,6 @@ LRESULT WIN_DestroyWindow( HWND hwnd )
if (menu) DestroyMenu( menu );
if (sys_menu) DestroyMenu( sys_menu );
DCE_FreeWindowDCE( hwnd ); /* Always do this to catch orphaned DCs */
if (USER_Driver.pDestroyWindow) USER_Driver.pDestroyWindow( hwnd );
free_window_handle( hwnd );
......@@ -1066,10 +1064,6 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
}
SERVER_END_REQ;
/* Get class or window DC if needed */
if (wndPtr->clsStyle & CS_OWNDC) wndPtr->dce = DCE_AllocDCE(hwnd,DCE_WINDOW_DC);
/* Set the window menu */
if (((wndPtr->dwStyle & (WS_CAPTION|WS_CHILD)) == WS_CAPTION) ||
......
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