Commit 4323004b authored by Alexandre Julliard's avatar Alexandre Julliard

Create an X connection for each thread, and process X events in the

thread that created the corresponding X window. Spawn a separate thread to run the desktop message loop in desktop mode.
parent 50792143
...@@ -97,21 +97,44 @@ static HBITMAP DESKTOP_LoadBitmap( HDC hdc, const char *filename ) ...@@ -97,21 +97,44 @@ static HBITMAP DESKTOP_LoadBitmap( HDC hdc, const char *filename )
} }
/*********************************************************************** /***********************************************************************
* DESKTOP_DoEraseBkgnd * DesktopWndProc
*
* Handle the WM_ERASEBKGND message.
*/ */
static LRESULT DESKTOP_DoEraseBkgnd( HWND hwnd, HDC hdc, static LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
DESKTOP *desktopPtr )
{ {
RECT rect; LRESULT retvalue = 0;
WND* Wnd = WIN_FindWndPtr( hwnd ); WND *wndPtr = WIN_FindWndPtr( hwnd );
DESKTOP *desktopPtr = (DESKTOP *)wndPtr->wExtra;
if (Wnd->hrgnUpdate > 1) DeleteObject( Wnd->hrgnUpdate ); if (message == WM_NCCREATE)
Wnd->hrgnUpdate = 0; {
desktopPtr->hbrushPattern = 0;
desktopPtr->hbitmapWallPaper = 0;
SetDeskPattern();
SetDeskWallPaper( (LPSTR)-1 );
retvalue = 1;
}
/* all other messages are ignored */
WIN_ReleaseWndPtr(Wnd); WIN_ReleaseWndPtr(wndPtr);
return retvalue;
}
/***********************************************************************
* PaintDesktop (USER32.@)
*
*/
BOOL WINAPI PaintDesktop(HDC hdc)
{
HWND hwnd = GetDesktopWindow();
WND *wndPtr = WIN_FindWndPtr( hwnd );
DESKTOP *desktopPtr = (DESKTOP *)wndPtr->wExtra;
/* check for a queue; otherwise don't paint anything (non-desktop mode) */
if (wndPtr->hmemTaskQ)
{
RECT rect;
GetClientRect( hwnd, &rect ); GetClientRect( hwnd, &rect );
...@@ -156,81 +179,9 @@ static LRESULT DESKTOP_DoEraseBkgnd( HWND hwnd, HDC hdc, ...@@ -156,81 +179,9 @@ static LRESULT DESKTOP_DoEraseBkgnd( HWND hwnd, HDC hdc,
} }
DeleteDC( hMemDC ); DeleteDC( hMemDC );
} }
return 1;
}
/***********************************************************************
* DesktopWndProc_locked
*
* Window procedure for the desktop window.
*/
static inline LRESULT WINAPI DesktopWndProc_locked( WND *wndPtr, UINT message,
WPARAM wParam, LPARAM lParam )
{
DESKTOP *desktopPtr = (DESKTOP *)wndPtr->wExtra;
HWND hwnd = wndPtr->hwndSelf;
/* Most messages are ignored (we DON'T call DefWindowProc) */
switch(message)
{
/* Warning: this message is sent directly by */
/* WIN_CreateDesktopWindow() and does not contain a valid lParam */
case WM_NCCREATE:
desktopPtr->hbrushPattern = 0;
desktopPtr->hbitmapWallPaper = 0;
SetDeskPattern();
SetDeskWallPaper( (LPSTR)-1 );
return 1;
case WM_ERASEBKGND:
if(!USER_Driver.pIsSingleWindow())
return 1;
return DESKTOP_DoEraseBkgnd( hwnd, (HDC)wParam, desktopPtr );
case WM_SYSCOMMAND:
if ((wParam & 0xfff0) != SC_CLOSE)
return 0;
ExitWindows16( 0, 0 );
case WM_SETCURSOR:
return (LRESULT)SetCursor( LoadCursorA( 0, IDC_ARROWA ) );
} }
return 0;
}
/***********************************************************************
* DesktopWndProc
*
* This is just a wrapper for the DesktopWndProc which does windows
* locking and unlocking.
*/
static LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
LRESULT retvalue = DesktopWndProc_locked(wndPtr,message,wParam,lParam);
WIN_ReleaseWndPtr(wndPtr); WIN_ReleaseWndPtr(wndPtr);
return retvalue; return TRUE;
}
/***********************************************************************
* PaintDesktop (USER32.@)
*
*/
BOOL WINAPI PaintDesktop(HDC hdc)
{
BOOL retvalue;
HWND hwnd = GetDesktopWindow();
WND *wndPtr = WIN_FindWndPtr( hwnd );
DESKTOP *desktopPtr = (DESKTOP *)wndPtr->wExtra;
retvalue = DESKTOP_DoEraseBkgnd( hwnd, hdc, desktopPtr );
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -11,7 +11,6 @@ debug_channels (ttydrv) ...@@ -11,7 +11,6 @@ debug_channels (ttydrv)
# USER driver # USER driver
@ cdecl UserRepaintDisable(long) TTYDRV_UserRepaintDisable
@ cdecl InitKeyboard() TTYDRV_InitKeyboard @ cdecl InitKeyboard() TTYDRV_InitKeyboard
@ cdecl VkKeyScan(long) TTYDRV_VkKeyScan @ cdecl VkKeyScan(long) TTYDRV_VkKeyScan
@ cdecl MapVirtualKey(long long) TTYDRV_MapVirtualKey @ cdecl MapVirtualKey(long long) TTYDRV_MapVirtualKey
...@@ -32,7 +31,6 @@ debug_channels (ttydrv) ...@@ -32,7 +31,6 @@ debug_channels (ttydrv)
@ cdecl DestroyWindow(long) TTYDRV_DestroyWindow @ cdecl DestroyWindow(long) TTYDRV_DestroyWindow
@ cdecl GetDC(long long long long) TTYDRV_GetDC @ cdecl GetDC(long long long long) TTYDRV_GetDC
@ cdecl SetWindowPos(ptr) TTYDRV_SetWindowPos @ cdecl SetWindowPos(ptr) TTYDRV_SetWindowPos
@ cdecl IsSingleWindow() TTYDRV_IsSingleWindow
@ cdecl AcquireClipboard() TTYDRV_AcquireClipboard @ cdecl AcquireClipboard() TTYDRV_AcquireClipboard
@ cdecl ReleaseClipboard() TTYDRV_ReleaseClipboard @ cdecl ReleaseClipboard() TTYDRV_ReleaseClipboard
@ cdecl SetClipboardData(long) TTYDRV_SetClipboardData @ cdecl SetClipboardData(long) TTYDRV_SetClipboardData
......
...@@ -11,13 +11,6 @@ ...@@ -11,13 +11,6 @@
DEFAULT_DEBUG_CHANNEL(ttydrv); DEFAULT_DEBUG_CHANNEL(ttydrv);
/***********************************************************************
* TTYDRV_UserRepaintDisable
*/
void TTYDRV_UserRepaintDisable( BOOL bDisable )
{
}
/*********************************************************************** /***********************************************************************
* TTYDRV_InitKeyboard * TTYDRV_InitKeyboard
...@@ -170,14 +163,6 @@ HANDLE TTYDRV_LoadOEMResource(WORD resid, WORD type) ...@@ -170,14 +163,6 @@ HANDLE TTYDRV_LoadOEMResource(WORD resid, WORD type)
} }
/*********************************************************************** /***********************************************************************
* TTYDRV_IsSingleWindow
*/
BOOL TTYDRV_IsSingleWindow(void)
{
return TRUE;
}
/***********************************************************************
* TTYDRV_AcquireClipboard * TTYDRV_AcquireClipboard
*/ */
void TTYDRV_AcquireClipboard(void) void TTYDRV_AcquireClipboard(void)
......
...@@ -76,6 +76,6 @@ DWORD WINAPI DISPLAY_GetDriverResourceID( WORD wQueriedResID, LPSTR lpsResName ) ...@@ -76,6 +76,6 @@ DWORD WINAPI DISPLAY_GetDriverResourceID( WORD wQueriedResID, LPSTR lpsResName )
*/ */
VOID WINAPI UserRepaintDisable16( BOOL16 disable ) VOID WINAPI UserRepaintDisable16( BOOL16 disable )
{ {
USER_Driver.pUserRepaintDisable( disable ); FIXME("stub\n");
} }
...@@ -12,8 +12,10 @@ ...@@ -12,8 +12,10 @@
#include "wine/winuser16.h" #include "wine/winuser16.h"
#include "controls.h" #include "controls.h"
#include "cursoricon.h"
#include "global.h" #include "global.h"
#include "input.h" #include "input.h"
#include "hook.h"
#include "keyboard.h" #include "keyboard.h"
#include "message.h" #include "message.h"
#include "queue.h" #include "queue.h"
...@@ -58,7 +60,6 @@ static BOOL load_driver(void) ...@@ -58,7 +60,6 @@ static BOOL load_driver(void)
return FALSE; return FALSE;
} }
GET_USER_FUNC(UserRepaintDisable);
GET_USER_FUNC(InitKeyboard); GET_USER_FUNC(InitKeyboard);
GET_USER_FUNC(VkKeyScan); GET_USER_FUNC(VkKeyScan);
GET_USER_FUNC(MapVirtualKey); GET_USER_FUNC(MapVirtualKey);
...@@ -75,7 +76,6 @@ static BOOL load_driver(void) ...@@ -75,7 +76,6 @@ static BOOL load_driver(void)
GET_USER_FUNC(GetScreenSaveTimeout); GET_USER_FUNC(GetScreenSaveTimeout);
GET_USER_FUNC(SetScreenSaveTimeout); GET_USER_FUNC(SetScreenSaveTimeout);
GET_USER_FUNC(LoadOEMResource); GET_USER_FUNC(LoadOEMResource);
GET_USER_FUNC(IsSingleWindow);
GET_USER_FUNC(AcquireClipboard); GET_USER_FUNC(AcquireClipboard);
GET_USER_FUNC(ReleaseClipboard); GET_USER_FUNC(ReleaseClipboard);
GET_USER_FUNC(SetClipboardData); GET_USER_FUNC(SetClipboardData);
...@@ -88,6 +88,7 @@ static BOOL load_driver(void) ...@@ -88,6 +88,7 @@ static BOOL load_driver(void)
GET_USER_FUNC(DestroyWindow); GET_USER_FUNC(DestroyWindow);
GET_USER_FUNC(GetDC); GET_USER_FUNC(GetDC);
GET_USER_FUNC(EnableWindow); GET_USER_FUNC(EnableWindow);
GET_USER_FUNC(MsgWaitForMultipleObjects);
GET_USER_FUNC(ScrollWindowEx); GET_USER_FUNC(ScrollWindowEx);
GET_USER_FUNC(SetFocus); GET_USER_FUNC(SetFocus);
GET_USER_FUNC(SetParent); GET_USER_FUNC(SetParent);
...@@ -191,13 +192,11 @@ static void tweak_init(void) ...@@ -191,13 +192,11 @@ static void tweak_init(void)
/*********************************************************************** /***********************************************************************
* USER initialisation routine * USER initialisation routine
*/ */
BOOL WINAPI USER_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) static BOOL process_attach(void)
{ {
HINSTANCE16 instance; HINSTANCE16 instance;
int queueSize; int queueSize;
if ( USER_HeapSel ) return TRUE;
/* Create USER heap */ /* Create USER heap */
if ((instance = LoadLibrary16( "USER.EXE" )) < 32) return FALSE; if ((instance = LoadLibrary16( "USER.EXE" )) < 32) return FALSE;
USER_HeapSel = instance | 7; USER_HeapSel = instance | 7;
...@@ -250,8 +249,66 @@ BOOL WINAPI USER_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) ...@@ -250,8 +249,66 @@ BOOL WINAPI USER_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
/* Initialize mouse driver */ /* Initialize mouse driver */
MOUSE_Enable( mouse_event ); MOUSE_Enable( mouse_event );
/* Start processing X events */
USER_Driver.pUserRepaintDisable( FALSE );
return TRUE; return TRUE;
} }
/**********************************************************************
* thread
*/
static void thread_detach(void)
{
HQUEUE16 hQueue = GetThreadQueue16( 0 );
if (hQueue)
{
WND* desktop = WIN_GetDesktop();
TIMER_RemoveQueueTimers( hQueue );
HOOK_FreeQueueHooks( hQueue );
QUEUE_SetExitingQueue( hQueue );
WIN_ResetQueueWindows( desktop, hQueue, 0 );
QUEUE_SetExitingQueue( 0 );
QUEUE_DeleteMsgQueue( hQueue );
WIN_ReleaseDesktop();
SetThreadQueue16( 0, 0 );
}
if (!(NtCurrentTeb()->tibflags & TEBF_WIN32))
{
HMODULE16 hModule = GetExePtr( MapHModuleLS(0) );
/* FIXME: maybe destroy menus (Windows only complains about them
* but does nothing);
*/
if (GetModuleUsage16( hModule ) <= 1)
{
/* ModuleUnload() in "Internals" */
HOOK_FreeModuleHooks( hModule );
CLASS_FreeModuleClasses( hModule );
CURSORICON_FreeModuleIcons( hModule );
}
}
}
/***********************************************************************
* USER initialisation routine
*/
BOOL WINAPI USER_Init( HINSTANCE inst, DWORD reason, LPVOID reserved )
{
BOOL ret = TRUE;
switch(reason)
{
case DLL_PROCESS_ATTACH:
ret = process_attach();
break;
case DLL_THREAD_DETACH:
thread_detach();
break;
}
return ret;
}
...@@ -7,6 +7,7 @@ EXTRALIBS = $(LIBTSX11) $(X_LIBS) $(XLIB) ...@@ -7,6 +7,7 @@ EXTRALIBS = $(LIBTSX11) $(X_LIBS) $(XLIB)
IMPORTS = user32 gdi32 kernel32 IMPORTS = user32 gdi32 kernel32
C_SRCS = \ C_SRCS = \
desktop.c \
dga2.c \ dga2.c \
window.c \ window.c \
winpos.c \ winpos.c \
......
/*
* X11DRV desktop window handling
*
* Copyright 2001 Alexandre Julliard
*/
#include "config.h"
#include <X11/cursorfont.h>
#include "ts_xlib.h"
#include "win.h"
#include "x11drv.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(x11drv);
/* desktop window procedure */
static LRESULT WINAPI desktop_winproc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch(message)
{
case WM_ERASEBKGND:
PaintDesktop( (HDC)wParam );
ValidateRect( hwnd, NULL );
break;
case WM_SYSCOMMAND:
if ((wParam & 0xfff0) == SC_CLOSE) ExitWindows( 0, 0 );
break;
case WM_SETCURSOR:
return SetCursor( LoadCursorA( 0, IDC_ARROWA ) );
case WM_NCHITTEST:
return HTCLIENT;
}
return 0;
}
/* desktop window manager thread */
static DWORD CALLBACK desktop_thread( LPVOID driver_data )
{
Display *display;
MSG msg;
HWND hwnd;
WND *win;
NtCurrentTeb()->driver_data = driver_data;
display = thread_display();
hwnd = GetDesktopWindow();
/* patch the desktop window queue to point to our queue */
win = WIN_FindWndPtr( hwnd );
win->hmemTaskQ = GetFastQueue16();
WIN_ReleaseWndPtr( win );
SetWindowLongW( hwnd, GWL_WNDPROC, (LONG)desktop_winproc );
X11DRV_register_window( display, hwnd, root_window );
TSXMapWindow( display, root_window );
while (GetMessageW( &msg, hwnd, 0, 0 )) DispatchMessageW( &msg );
return 0;
}
/***********************************************************************
* X11DRV_create_desktop_thread
*
* Create the thread that manages the desktop window
*/
void X11DRV_create_desktop_thread(void)
{
HANDLE handle = CreateThread( NULL, 0, desktop_thread, NtCurrentTeb()->driver_data, 0, NULL );
if (!handle)
{
MESSAGE( "Could not create desktop thread\n" );
ExitProcess(1);
}
/* we transferred our driver data to the new thread */
NtCurrentTeb()->driver_data = NULL;
CloseHandle( handle );
}
/***********************************************************************
* X11DRV_create_desktop
*
* Create the X11 desktop window for the desktop mode.
*/
Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry )
{
int x = 0, y = 0, flags;
unsigned int width = 640, height = 480; /* Default size = 640x480 */
char *name = "Wine desktop";
XSizeHints *size_hints;
XWMHints *wm_hints;
XClassHint *class_hints;
XSetWindowAttributes win_attr;
XTextProperty window_name;
Window win;
Display *display = thread_display();
wine_tsx11_lock();
flags = XParseGeometry( geometry, &x, &y, &width, &height );
screen_width = width;
screen_height = height;
/* Create window */
win_attr.background_pixel = BlackPixel(display, 0);
win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
win_attr.cursor = XCreateFontCursor( display, XC_top_left_arrow );
if (desktop_vi)
win_attr.colormap = XCreateColormap( display, DefaultRootWindow(display),
visual, AllocNone );
else
win_attr.colormap = None;
win = XCreateWindow( display, DefaultRootWindow(display),
x, y, width, height, 0, screen_depth, InputOutput, visual,
CWBackPixel | CWEventMask | CWCursor | CWColormap, &win_attr );
/* Set window manager properties */
size_hints = XAllocSizeHints();
wm_hints = XAllocWMHints();
class_hints = XAllocClassHint();
if (!size_hints || !wm_hints || !class_hints)
{
MESSAGE("Not enough memory for window manager hints.\n" );
ExitProcess(1);
}
size_hints->min_width = size_hints->max_width = width;
size_hints->min_height = size_hints->max_height = height;
size_hints->flags = PMinSize | PMaxSize;
if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
else size_hints->flags |= PSize;
wm_hints->flags = InputHint | StateHint;
wm_hints->input = True;
wm_hints->initial_state = NormalState;
class_hints->res_name = "wine";
class_hints->res_class = "Wine";
XStringListToTextProperty( &name, 1, &window_name );
XSetWMProperties( display, win, &window_name, &window_name,
NULL, 0, size_hints, wm_hints, class_hints );
XFree( size_hints );
XFree( wm_hints );
XFree( class_hints );
XFlush( display );
wine_tsx11_unlock();
return win;
}
...@@ -51,7 +51,7 @@ void X11DRV_XF86DGA2_Init(void) ...@@ -51,7 +51,7 @@ void X11DRV_XF86DGA2_Init(void)
if (xf86dga2_modes) return; /* already initialized? */ if (xf86dga2_modes) return; /* already initialized? */
/* if in desktop mode, don't use DGA */ /* if in desktop mode, don't use DGA */
if (X11DRV_GetXRootWindow() != DefaultRootWindow(display)) return; if (root_window != DefaultRootWindow(display)) return;
if (!usedga) return; if (!usedga) return;
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
DEFAULT_DEBUG_CHANNEL(win); DEFAULT_DEBUG_CHANNEL(win);
extern Cursor X11DRV_MOUSE_XCursor; /* current X cursor */
extern Pixmap X11DRV_BITMAP_Pixmap( HBITMAP ); extern Pixmap X11DRV_BITMAP_Pixmap( HBITMAP );
#define HAS_DLGFRAME(style,exStyle) \ #define HAS_DLGFRAME(style,exStyle) \
...@@ -42,11 +41,11 @@ Atom _kde_net_wm_system_tray_window_for = None; /* KDE 2 Final */ ...@@ -42,11 +41,11 @@ Atom _kde_net_wm_system_tray_window_for = None; /* KDE 2 Final */
/*********************************************************************** /***********************************************************************
* register_window * X11DRV_register_window
* *
* Associate an X window to a HWND. * Associate an X window to a HWND.
*/ */
static void register_window( HWND hwnd, Window win ) void X11DRV_register_window( Display *display, HWND hwnd, Window win )
{ {
if (!winContext) winContext = TSXUniqueContext(); if (!winContext) winContext = TSXUniqueContext();
TSXSaveContext( display, win, winContext, (char *)hwnd ); TSXSaveContext( display, win, winContext, (char *)hwnd );
...@@ -59,7 +58,7 @@ static void register_window( HWND hwnd, Window win ) ...@@ -59,7 +58,7 @@ static void register_window( HWND hwnd, Window win )
* *
* Set a window manager hint. * Set a window manager hint.
*/ */
static void set_wm_hint( Window win, int hint, int val ) static void set_wm_hint( Display *display, Window win, int hint, int val )
{ {
XWMHints* wm_hints = TSXGetWMHints( display, win ); XWMHints* wm_hints = TSXGetWMHints( display, win );
if (!wm_hints) wm_hints = TSXAllocWMHints(); if (!wm_hints) wm_hints = TSXAllocWMHints();
...@@ -95,7 +94,7 @@ static void set_wm_hint( Window win, int hint, int val ) ...@@ -95,7 +94,7 @@ static void set_wm_hint( Window win, int hint, int val )
* *
* Set the icon wm hints * Set the icon wm hints
*/ */
static void set_icon_hints( WND *wndPtr, XWMHints *hints ) static void set_icon_hints( Display *display, WND *wndPtr, XWMHints *hints )
{ {
X11DRV_WND_DATA *data = wndPtr->pDriverData; X11DRV_WND_DATA *data = wndPtr->pDriverData;
HICON hIcon = GetClassLongA( wndPtr->hwndSelf, GCL_HICON ); HICON hIcon = GetClassLongA( wndPtr->hwndSelf, GCL_HICON );
...@@ -155,7 +154,7 @@ static void set_icon_hints( WND *wndPtr, XWMHints *hints ) ...@@ -155,7 +154,7 @@ static void set_icon_hints( WND *wndPtr, XWMHints *hints )
* *
* all others: to be added ;) * all others: to be added ;)
*/ */
inline static void dock_window( Window win ) inline static void dock_window( Display *display, Window win )
{ {
int data = 1; int data = 1;
if (kwmDockWindow != None) if (kwmDockWindow != None)
...@@ -170,7 +169,7 @@ inline static void dock_window( Window win ) ...@@ -170,7 +169,7 @@ inline static void dock_window( Window win )
/********************************************************************** /**********************************************************************
* create_desktop * create_desktop
*/ */
static void create_desktop(WND *wndPtr) static void create_desktop( Display *display, WND *wndPtr )
{ {
X11DRV_WND_DATA *data = wndPtr->pDriverData; X11DRV_WND_DATA *data = wndPtr->pDriverData;
...@@ -183,8 +182,11 @@ static void create_desktop(WND *wndPtr) ...@@ -183,8 +182,11 @@ static void create_desktop(WND *wndPtr)
_kde_net_wm_system_tray_window_for = TSXInternAtom( display, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False ); _kde_net_wm_system_tray_window_for = TSXInternAtom( display, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False );
data->window = root_window; data->window = root_window;
if (root_window != DefaultRootWindow(display)) wndPtr->flags |= WIN_NATIVE; if (root_window != DefaultRootWindow(display))
register_window( wndPtr->hwndSelf, root_window ); {
wndPtr->flags |= WIN_NATIVE;
X11DRV_create_desktop_thread();
}
} }
...@@ -193,6 +195,7 @@ static void create_desktop(WND *wndPtr) ...@@ -193,6 +195,7 @@ static void create_desktop(WND *wndPtr)
*/ */
BOOL X11DRV_CreateWindow( HWND hwnd ) BOOL X11DRV_CreateWindow( HWND hwnd )
{ {
Display *display = thread_display();
X11DRV_WND_DATA *data; X11DRV_WND_DATA *data;
WND *wndPtr = WIN_FindWndPtr( hwnd ); WND *wndPtr = WIN_FindWndPtr( hwnd );
int x = wndPtr->rectWindow.left; int x = wndPtr->rectWindow.left;
...@@ -210,7 +213,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd ) ...@@ -210,7 +213,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
if (!wndPtr->parent) if (!wndPtr->parent)
{ {
create_desktop( wndPtr ); create_desktop( display, wndPtr );
WIN_ReleaseWndPtr( wndPtr ); WIN_ReleaseWndPtr( wndPtr );
return TRUE; return TRUE;
} }
...@@ -246,11 +249,13 @@ BOOL X11DRV_CreateWindow( HWND hwnd ) ...@@ -246,11 +249,13 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
} }
wndPtr->flags |= WIN_NATIVE; wndPtr->flags |= WIN_NATIVE;
wine_tsx11_lock();
win_attr.bit_gravity = (wndPtr->clsStyle & (CS_VREDRAW | CS_HREDRAW)) ? ForgetGravity : NorthWestGravity; win_attr.bit_gravity = (wndPtr->clsStyle & (CS_VREDRAW | CS_HREDRAW)) ? ForgetGravity : NorthWestGravity;
win_attr.colormap = X11DRV_PALETTE_PaletteXColormap; win_attr.colormap = X11DRV_PALETTE_PaletteXColormap;
win_attr.backing_store = NotUseful; win_attr.backing_store = NotUseful;
win_attr.save_under = ((wndPtr->clsStyle & CS_SAVEBITS) != 0); win_attr.save_under = ((wndPtr->clsStyle & CS_SAVEBITS) != 0);
win_attr.cursor = X11DRV_MOUSE_XCursor; win_attr.cursor = X11DRV_GetCursor( display, GlobalLock16(GetCursor()) );
data->hWMIconBitmap = 0; data->hWMIconBitmap = 0;
data->hWMIconMask = 0; data->hWMIconMask = 0;
...@@ -262,7 +267,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd ) ...@@ -262,7 +267,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
if (cx <= 0) cx = 1; if (cx <= 0) cx = 1;
if (cy <= 0) cy = 1; if (cy <= 0) cy = 1;
data->window = TSXCreateWindow( display, root_window, data->window = XCreateWindow( display, root_window,
x, y, cx, cy, x, y, cx, cy,
0, screen_depth, 0, screen_depth,
InputOutput, visual, InputOutput, visual,
...@@ -271,7 +276,10 @@ BOOL X11DRV_CreateWindow( HWND hwnd ) ...@@ -271,7 +276,10 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
CWBackingStore | CWBitGravity, CWBackingStore | CWBitGravity,
&win_attr ); &win_attr );
if(!(wGroupLeader = X11DRV_WND_GetXWindow(wndPtr))) if (win_attr.cursor) XFreeCursor( display, win_attr.cursor );
wine_tsx11_unlock();
if(!(wGroupLeader = data->window))
{ {
HeapFree( GetProcessHeap(), 0, data ); HeapFree( GetProcessHeap(), 0, data );
WIN_ReleaseWndPtr( wndPtr ); WIN_ReleaseWndPtr( wndPtr );
...@@ -279,7 +287,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd ) ...@@ -279,7 +287,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
} }
/* If we are the systray, we need to be managed to be noticed by KWM */ /* If we are the systray, we need to be managed to be noticed by KWM */
if (wndPtr->dwExStyle & WS_EX_TRAYWINDOW) dock_window( data->window ); if (wndPtr->dwExStyle & WS_EX_TRAYWINDOW) dock_window( display, data->window );
if (wndPtr->dwExStyle & WS_EX_MANAGED) if (wndPtr->dwExStyle & WS_EX_MANAGED)
{ {
...@@ -331,7 +339,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd ) ...@@ -331,7 +339,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
if (wndPtr->dwExStyle & WS_EX_MANAGED) if (wndPtr->dwExStyle & WS_EX_MANAGED)
{ {
set_icon_hints( wndPtr, wm_hints ); set_icon_hints( display, wndPtr, wm_hints );
wm_hints->initial_state = (wndPtr->dwStyle & WS_MINIMIZE) wm_hints->initial_state = (wndPtr->dwStyle & WS_MINIMIZE)
? IconicState : NormalState; ? IconicState : NormalState;
} }
...@@ -342,7 +350,8 @@ BOOL X11DRV_CreateWindow( HWND hwnd ) ...@@ -342,7 +350,8 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
TSXSetWMHints( display, X11DRV_WND_GetXWindow(wndPtr), wm_hints ); TSXSetWMHints( display, X11DRV_WND_GetXWindow(wndPtr), wm_hints );
TSXFree(wm_hints); TSXFree(wm_hints);
} }
register_window( hwnd, data->window ); X11DRV_register_window( display, hwnd, data->window );
TSXFlush( display );
} }
WIN_ReleaseWndPtr( wndPtr ); WIN_ReleaseWndPtr( wndPtr );
return TRUE; return TRUE;
...@@ -354,6 +363,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd ) ...@@ -354,6 +363,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
*/ */
BOOL X11DRV_DestroyWindow( HWND hwnd ) BOOL X11DRV_DestroyWindow( HWND hwnd )
{ {
Display *display = thread_display();
WND *wndPtr = WIN_FindWndPtr( hwnd ); WND *wndPtr = WIN_FindWndPtr( hwnd );
X11DRV_WND_DATA *data = wndPtr->pDriverData; X11DRV_WND_DATA *data = wndPtr->pDriverData;
Window w; Window w;
...@@ -361,9 +371,12 @@ BOOL X11DRV_DestroyWindow( HWND hwnd ) ...@@ -361,9 +371,12 @@ BOOL X11DRV_DestroyWindow( HWND hwnd )
if (data && (w = data->window)) if (data && (w = data->window))
{ {
XEvent xe; XEvent xe;
TSXDeleteContext( display, w, winContext ); wine_tsx11_lock();
TSXDestroyWindow( display, w ); XSync( gdi_display, False ); /* flush any reference to this drawable in GDI queue */
while( TSXCheckWindowEvent(display, w, NoEventMask, &xe) ); XDeleteContext( display, w, winContext );
XDestroyWindow( display, w );
while( XCheckWindowEvent(display, w, NoEventMask, &xe) );
wine_tsx11_unlock();
data->window = None; data->window = None;
if( data->hWMIconBitmap ) if( data->hWMIconBitmap )
...@@ -389,6 +402,7 @@ BOOL X11DRV_DestroyWindow( HWND hwnd ) ...@@ -389,6 +402,7 @@ BOOL X11DRV_DestroyWindow( HWND hwnd )
*/ */
HWND X11DRV_SetParent( HWND hwnd, HWND parent ) HWND X11DRV_SetParent( HWND hwnd, HWND parent )
{ {
Display *display = thread_display();
WND *wndPtr; WND *wndPtr;
WND *pWndParent; WND *pWndParent;
DWORD dwStyle; DWORD dwStyle;
...@@ -464,6 +478,7 @@ HWND X11DRV_SetParent( HWND hwnd, HWND parent ) ...@@ -464,6 +478,7 @@ HWND X11DRV_SetParent( HWND hwnd, HWND parent )
*/ */
BOOL X11DRV_EnableWindow( HWND hwnd, BOOL enable ) BOOL X11DRV_EnableWindow( HWND hwnd, BOOL enable )
{ {
Display *display = thread_display();
WND *wndPtr; WND *wndPtr;
BOOL retvalue; BOOL retvalue;
Window w; Window w;
...@@ -478,7 +493,7 @@ BOOL X11DRV_EnableWindow( HWND hwnd, BOOL enable ) ...@@ -478,7 +493,7 @@ BOOL X11DRV_EnableWindow( HWND hwnd, BOOL enable )
wndPtr->dwStyle &= ~WS_DISABLED; wndPtr->dwStyle &= ~WS_DISABLED;
if ((wndPtr->dwExStyle & WS_EX_MANAGED) && (w = X11DRV_WND_GetXWindow( wndPtr ))) if ((wndPtr->dwExStyle & WS_EX_MANAGED) && (w = X11DRV_WND_GetXWindow( wndPtr )))
set_wm_hint( w, InputHint, TRUE ); set_wm_hint( display, w, InputHint, TRUE );
SendMessageA( hwnd, WM_ENABLE, TRUE, 0 ); SendMessageA( hwnd, WM_ENABLE, TRUE, 0 );
} }
...@@ -490,7 +505,7 @@ BOOL X11DRV_EnableWindow( HWND hwnd, BOOL enable ) ...@@ -490,7 +505,7 @@ BOOL X11DRV_EnableWindow( HWND hwnd, BOOL enable )
wndPtr->dwStyle |= WS_DISABLED; wndPtr->dwStyle |= WS_DISABLED;
if ((wndPtr->dwExStyle & WS_EX_MANAGED) && (w = X11DRV_WND_GetXWindow( wndPtr ))) if ((wndPtr->dwExStyle & WS_EX_MANAGED) && (w = X11DRV_WND_GetXWindow( wndPtr )))
set_wm_hint( w, InputHint, FALSE ); set_wm_hint( display, w, InputHint, FALSE );
if (hwnd == GetFocus()) if (hwnd == GetFocus())
SetFocus( 0 ); /* A disabled window can't have the focus */ SetFocus( 0 ); /* A disabled window can't have the focus */
...@@ -513,6 +528,7 @@ BOOL X11DRV_EnableWindow( HWND hwnd, BOOL enable ) ...@@ -513,6 +528,7 @@ BOOL X11DRV_EnableWindow( HWND hwnd, BOOL enable )
*/ */
void X11DRV_SetFocus( HWND hwnd ) void X11DRV_SetFocus( HWND hwnd )
{ {
Display *display = thread_display();
XWindowAttributes win_attr; XWindowAttributes win_attr;
Window win; Window win;
WND *wndPtr = WIN_FindWndPtr( hwnd ); WND *wndPtr = WIN_FindWndPtr( hwnd );
...@@ -558,6 +574,7 @@ void X11DRV_SetFocus( HWND hwnd ) ...@@ -558,6 +574,7 @@ void X11DRV_SetFocus( HWND hwnd )
*/ */
BOOL X11DRV_SetWindowText( HWND hwnd, LPCWSTR text ) BOOL X11DRV_SetWindowText( HWND hwnd, LPCWSTR text )
{ {
Display *display = thread_display();
UINT count; UINT count;
char *buffer; char *buffer;
static UINT text_cp = (UINT)-1; static UINT text_cp = (UINT)-1;
...@@ -604,6 +621,7 @@ BOOL X11DRV_SetWindowText( HWND hwnd, LPCWSTR text ) ...@@ -604,6 +621,7 @@ BOOL X11DRV_SetWindowText( HWND hwnd, LPCWSTR text )
*/ */
HICON X11DRV_SetWindowIcon( HWND hwnd, HICON icon, BOOL small ) HICON X11DRV_SetWindowIcon( HWND hwnd, HICON icon, BOOL small )
{ {
Display *display = thread_display();
WND *wndPtr = WIN_FindWndPtr( hwnd ); WND *wndPtr = WIN_FindWndPtr( hwnd );
int index = small ? GCL_HICONSM : GCL_HICON; int index = small ? GCL_HICONSM : GCL_HICON;
HICON old; HICON old;
...@@ -624,7 +642,7 @@ HICON X11DRV_SetWindowIcon( HWND hwnd, HICON icon, BOOL small ) ...@@ -624,7 +642,7 @@ HICON X11DRV_SetWindowIcon( HWND hwnd, HICON icon, BOOL small )
if (!wm_hints) wm_hints = TSXAllocWMHints(); if (!wm_hints) wm_hints = TSXAllocWMHints();
if (wm_hints) if (wm_hints)
{ {
set_icon_hints( wndPtr, wm_hints ); set_icon_hints( display, wndPtr, wm_hints );
TSXSetWMHints( display, win, wm_hints ); TSXSetWMHints( display, win, wm_hints );
TSXFree( wm_hints ); TSXFree( wm_hints );
} }
......
...@@ -405,7 +405,7 @@ BOOL X11DRV_GetDC( HWND hwnd, HDC hdc, HRGN hrgn, DWORD flags ) ...@@ -405,7 +405,7 @@ BOOL X11DRV_GetDC( HWND hwnd, HDC hdc, HRGN hrgn, DWORD flags )
} }
else else
{ {
if ((hwnd == GetDesktopWindow()) && (root_window != DefaultRootWindow(display))) if ((hwnd == GetDesktopWindow()) && (root_window != DefaultRootWindow(thread_display())))
hrgnVisible = CreateRectRgn( 0, 0, GetSystemMetrics(SM_CXSCREEN), hrgnVisible = CreateRectRgn( 0, 0, GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN) ); GetSystemMetrics(SM_CYSCREEN) );
else else
...@@ -1280,6 +1280,7 @@ BOOL X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw ) ...@@ -1280,6 +1280,7 @@ BOOL X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
SWP_NOZORDER | (redraw ? 0 : SWP_NOREDRAW) ); SWP_NOZORDER | (redraw ? 0 : SWP_NOREDRAW) );
#ifdef HAVE_LIBXSHAPE #ifdef HAVE_LIBXSHAPE
{ {
Display *display = thread_display();
Window win = X11DRV_WND_GetXWindow(wndPtr); Window win = X11DRV_WND_GetXWindow(wndPtr);
if (win) if (win)
...@@ -1474,7 +1475,10 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam ) ...@@ -1474,7 +1475,10 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
BOOL moved = FALSE; BOOL moved = FALSE;
DWORD dwPoint = GetMessagePos (); DWORD dwPoint = GetMessagePos ();
BOOL DragFullWindows = FALSE; BOOL DragFullWindows = FALSE;
BOOL grab;
int iWndsLocks; int iWndsLocks;
Display *old_gdi_display = NULL;
Display *display = thread_display();
SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0); SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0);
...@@ -1563,9 +1567,18 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam ) ...@@ -1563,9 +1567,18 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN ); RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
/* grab the server only when moving top-level windows without desktop */ /* grab the server only when moving top-level windows without desktop */
if ((root_window == DefaultRootWindow(display)) && grab = (!DragFullWindows && (root_window == DefaultRootWindow(gdi_display)) &&
(wndPtr->parent->hwndSelf == GetDesktopWindow())) (wndPtr->parent->hwndSelf == GetDesktopWindow()));
TSXGrabServer( display ); if (grab)
{
wine_tsx11_lock();
XSync( gdi_display, False );
XGrabServer( display );
/* switch gdi display to the thread display, since the server is grabbed */
old_gdi_display = gdi_display;
gdi_display = display;
wine_tsx11_unlock();
}
while(1) while(1)
{ {
...@@ -1673,9 +1686,14 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam ) ...@@ -1673,9 +1686,14 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
else else
ReleaseDC( 0, hdc ); ReleaseDC( 0, hdc );
if ((root_window == DefaultRootWindow(display)) && if (grab)
(wndPtr->parent->hwndSelf == GetDesktopWindow())) {
TSXUngrabServer( display ); wine_tsx11_lock();
XSync( display, False );
XUngrabServer( display );
gdi_display = old_gdi_display;
wine_tsx11_unlock();
}
if (HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE, hwnd, (LPARAM)&sizingRect )) if (HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE, hwnd, (LPARAM)&sizingRect ))
sizingRect = wndPtr->rectWindow; sizingRect = wndPtr->rectWindow;
......
...@@ -48,6 +48,7 @@ static void SetPrimaryDIB(HBITMAP hBmp) ...@@ -48,6 +48,7 @@ static void SetPrimaryDIB(HBITMAP hBmp)
static void GrabPointer(HWND hWnd) static void GrabPointer(HWND hWnd)
{ {
Display *display = thread_display();
if (hWnd) { if (hWnd) {
WND *tmpWnd; WND *tmpWnd;
Window win; Window win;
......
...@@ -11,7 +11,6 @@ debug_channels (bitblt bitmap clipboard cursor dinput event font gdi graphics ...@@ -11,7 +11,6 @@ debug_channels (bitblt bitmap clipboard cursor dinput event font gdi graphics
# USER driver # USER driver
@ cdecl UserRepaintDisable(long) X11DRV_UserRepaintDisable
@ cdecl InitKeyboard() X11DRV_InitKeyboard @ cdecl InitKeyboard() X11DRV_InitKeyboard
@ cdecl VkKeyScan(long) X11DRV_VkKeyScan @ cdecl VkKeyScan(long) X11DRV_VkKeyScan
@ cdecl MapVirtualKey(long long) X11DRV_MapVirtualKey @ cdecl MapVirtualKey(long long) X11DRV_MapVirtualKey
...@@ -32,6 +31,7 @@ debug_channels (bitblt bitmap clipboard cursor dinput event font gdi graphics ...@@ -32,6 +31,7 @@ debug_channels (bitblt bitmap clipboard cursor dinput event font gdi graphics
@ cdecl DestroyWindow(long) X11DRV_DestroyWindow @ cdecl DestroyWindow(long) X11DRV_DestroyWindow
@ cdecl GetDC(long long long long) X11DRV_GetDC @ cdecl GetDC(long long long long) X11DRV_GetDC
@ cdecl EnableWindow(long long) X11DRV_EnableWindow @ cdecl EnableWindow(long long) X11DRV_EnableWindow
@ cdecl MsgWaitForMultipleObjects(long ptr long long) X11DRV_MsgWaitForMultipleObjects
@ cdecl ScrollWindowEx(long long long ptr ptr long ptr long) X11DRV_ScrollWindowEx @ cdecl ScrollWindowEx(long long long ptr ptr long ptr long) X11DRV_ScrollWindowEx
@ cdecl SetFocus(long) X11DRV_SetFocus @ cdecl SetFocus(long) X11DRV_SetFocus
@ cdecl SetParent(long long) X11DRV_SetParent @ cdecl SetParent(long long) X11DRV_SetParent
...@@ -40,7 +40,6 @@ debug_channels (bitblt bitmap clipboard cursor dinput event font gdi graphics ...@@ -40,7 +40,6 @@ debug_channels (bitblt bitmap clipboard cursor dinput event font gdi graphics
@ cdecl SetWindowIcon(long long long) X11DRV_SetWindowIcon @ cdecl SetWindowIcon(long long long) X11DRV_SetWindowIcon
@ cdecl SetWindowText(long wstr) X11DRV_SetWindowText @ cdecl SetWindowText(long wstr) X11DRV_SetWindowText
@ cdecl SysCommandSizeMove(long long) X11DRV_SysCommandSizeMove @ cdecl SysCommandSizeMove(long long) X11DRV_SysCommandSizeMove
@ cdecl IsSingleWindow() X11DRV_IsSingleWindow
@ cdecl AcquireClipboard() X11DRV_AcquireClipboard @ cdecl AcquireClipboard() X11DRV_AcquireClipboard
@ cdecl ReleaseClipboard() X11DRV_ReleaseClipboard @ cdecl ReleaseClipboard() X11DRV_ReleaseClipboard
@ cdecl SetClipboardData(long) X11DRV_SetClipboardData @ cdecl SetClipboardData(long) X11DRV_SetClipboardData
......
...@@ -33,6 +33,7 @@ static int *ph_errno = &h_errno; ...@@ -33,6 +33,7 @@ static int *ph_errno = &h_errno;
#include "debugtools.h" #include "debugtools.h"
#include "gdi.h" #include "gdi.h"
#include "file.h"
#include "options.h" #include "options.h"
#include "user.h" #include "user.h"
#include "win.h" #include "win.h"
...@@ -48,7 +49,6 @@ static void (*old_tsx11_unlock)(void); ...@@ -48,7 +49,6 @@ static void (*old_tsx11_unlock)(void);
static CRITICAL_SECTION X11DRV_CritSection = CRITICAL_SECTION_INIT; static CRITICAL_SECTION X11DRV_CritSection = CRITICAL_SECTION_INIT;
Display *display;
Screen *screen; Screen *screen;
Visual *visual; Visual *visual;
unsigned int screen_width; unsigned int screen_width;
...@@ -61,6 +61,7 @@ unsigned int X11DRV_server_startticks; ...@@ -61,6 +61,7 @@ unsigned int X11DRV_server_startticks;
static BOOL synchronous; /* run in synchronous mode? */ static BOOL synchronous; /* run in synchronous mode? */
static char *desktop_geometry; static char *desktop_geometry;
static XVisualInfo *desktop_vi;
#ifdef NO_REENTRANT_X11 #ifdef NO_REENTRANT_X11
static int* (*old_errno_location)(void); static int* (*old_errno_location)(void);
...@@ -232,9 +233,8 @@ static void setup_options(void) ...@@ -232,9 +233,8 @@ static void setup_options(void)
* window (if it exists). If OpenGL isn't available, the visual is simply * window (if it exists). If OpenGL isn't available, the visual is simply
* set to the default visual for the display * set to the default visual for the display
*/ */
XVisualInfo *desktop_vi = NULL;
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
static void setup_opengl_visual( void ) static void setup_opengl_visual( Display *display )
{ {
int err_base, evt_base; int err_base, evt_base;
...@@ -257,87 +257,12 @@ static void setup_opengl_visual( void ) ...@@ -257,87 +257,12 @@ static void setup_opengl_visual( void )
#endif /* HAVE_OPENGL */ #endif /* HAVE_OPENGL */
/*********************************************************************** /***********************************************************************
* create_desktop
*
* Create the desktop window for the --desktop mode.
*/
static void create_desktop( const char *geometry )
{
int x = 0, y = 0, flags;
unsigned int width = 640, height = 480; /* Default size = 640x480 */
char *name = "Wine desktop";
XSizeHints *size_hints;
XWMHints *wm_hints;
XClassHint *class_hints;
XSetWindowAttributes win_attr;
XTextProperty window_name;
Atom XA_WM_DELETE_WINDOW;
flags = TSXParseGeometry( geometry, &x, &y, &width, &height );
screen_width = width;
screen_height = height;
/* Create window */
win_attr.background_pixel = BlackPixel(display, 0);
win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
PointerMotionMask | ButtonPressMask |
ButtonReleaseMask | EnterWindowMask;
win_attr.cursor = TSXCreateFontCursor( display, XC_top_left_arrow );
if (desktop_vi != NULL) {
win_attr.colormap = XCreateColormap(display, RootWindow(display,desktop_vi->screen),
desktop_vi->visual, AllocNone);
}
root_window = TSXCreateWindow( display,
(desktop_vi == NULL ? DefaultRootWindow(display) : RootWindow(display, desktop_vi->screen)),
x, y, width, height, 0,
(desktop_vi == NULL ? CopyFromParent : desktop_vi->depth),
InputOutput,
(desktop_vi == NULL ? CopyFromParent : desktop_vi->visual),
CWBackPixel | CWEventMask | CWCursor | (desktop_vi == NULL ? 0 : CWColormap),
&win_attr );
/* Set window manager properties */
size_hints = TSXAllocSizeHints();
wm_hints = TSXAllocWMHints();
class_hints = TSXAllocClassHint();
if (!size_hints || !wm_hints || !class_hints)
{
MESSAGE("Not enough memory for window manager hints.\n" );
ExitProcess(1);
}
size_hints->min_width = size_hints->max_width = width;
size_hints->min_height = size_hints->max_height = height;
size_hints->flags = PMinSize | PMaxSize;
if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
else size_hints->flags |= PSize;
wm_hints->flags = InputHint | StateHint;
wm_hints->input = True;
wm_hints->initial_state = NormalState;
class_hints->res_name = "wine";
class_hints->res_class = "Wine";
TSXStringListToTextProperty( &name, 1, &window_name );
TSXSetWMProperties( display, root_window, &window_name, &window_name,
NULL, 0, size_hints, wm_hints, class_hints );
XA_WM_DELETE_WINDOW = TSXInternAtom( display, "WM_DELETE_WINDOW", False );
TSXSetWMProtocols( display, root_window, &XA_WM_DELETE_WINDOW, 1 );
TSXFree( size_hints );
TSXFree( wm_hints );
TSXFree( class_hints );
/* Map window */
TSXMapWindow( display, root_window );
}
/***********************************************************************
* X11DRV process initialisation routine * X11DRV process initialisation routine
*/ */
static void process_attach(void) static void process_attach(void)
{ {
Display *display;
WND_Driver = &X11DRV_WND_Driver; WND_Driver = &X11DRV_WND_Driver;
get_server_startup(); get_server_startup();
...@@ -386,7 +311,7 @@ static void process_attach(void) ...@@ -386,7 +311,7 @@ static void process_attach(void)
/* If OpenGL is available, change the default visual, etc as necessary */ /* If OpenGL is available, change the default visual, etc as necessary */
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
setup_opengl_visual(); setup_opengl_visual( display );
#endif /* HAVE_OPENGL */ #endif /* HAVE_OPENGL */
/* tell the libX11 that we will do input method handling ourselves /* tell the libX11 that we will do input method handling ourselves
...@@ -409,7 +334,7 @@ static void process_attach(void) ...@@ -409,7 +334,7 @@ static void process_attach(void)
if (desktop_geometry) if (desktop_geometry)
{ {
Options.managed = FALSE; Options.managed = FALSE;
create_desktop( desktop_geometry ); root_window = X11DRV_create_desktop( desktop_vi, desktop_geometry );
} }
/* initialize GDI */ /* initialize GDI */
...@@ -419,9 +344,6 @@ static void process_attach(void) ...@@ -419,9 +344,6 @@ static void process_attach(void)
ExitProcess(1); ExitProcess(1);
} }
/* initialize event handling */
X11DRV_EVENT_Init();
#ifdef HAVE_LIBXXF86VM #ifdef HAVE_LIBXXF86VM
/* initialize XVidMode */ /* initialize XVidMode */
X11DRV_XF86VM_Init(); X11DRV_XF86VM_Init();
...@@ -441,6 +363,24 @@ static void process_attach(void) ...@@ -441,6 +363,24 @@ static void process_attach(void)
/*********************************************************************** /***********************************************************************
* X11DRV thread termination routine
*/
static void thread_detach(void)
{
struct x11drv_thread_data *data = NtCurrentTeb()->driver_data;
if (data)
{
CloseHandle( data->display_fd );
wine_tsx11_lock();
XCloseDisplay( data->display );
wine_tsx11_unlock();
HeapFree( GetProcessHeap(), 0, data );
}
}
/***********************************************************************
* X11DRV process termination routine * X11DRV process termination routine
*/ */
static void process_detach(void) static void process_detach(void)
...@@ -458,12 +398,11 @@ static void process_detach(void) ...@@ -458,12 +398,11 @@ static void process_detach(void)
X11DRV_XF86VM_Cleanup(); X11DRV_XF86VM_Cleanup();
#endif #endif
/* cleanup event handling */ /* FIXME: should detach all threads */
X11DRV_EVENT_Cleanup(); thread_detach();
/* cleanup GDI */ /* cleanup GDI */
X11DRV_GDI_Finalize(); X11DRV_GDI_Finalize();
display = NULL;
/* restore TSX11 locking */ /* restore TSX11 locking */
wine_tsx11_lock = old_tsx11_lock; wine_tsx11_lock = old_tsx11_lock;
...@@ -477,6 +416,36 @@ static void process_detach(void) ...@@ -477,6 +416,36 @@ static void process_detach(void)
/*********************************************************************** /***********************************************************************
* X11DRV thread initialisation routine
*/
struct x11drv_thread_data *x11drv_init_thread_data(void)
{
struct x11drv_thread_data *data;
if (!(data = HeapAlloc( GetProcessHeap(), 0, sizeof(*data) )))
{
ERR( "could not create data\n" );
ExitProcess(1);
}
wine_tsx11_lock();
if (!(data->display = XOpenDisplay(NULL)))
{
wine_tsx11_unlock();
MESSAGE( "x11drv: Can't open display: %s\n", XDisplayName(NULL) );
ExitProcess(1);
}
fcntl( ConnectionNumber(data->display), F_SETFD, 1 ); /* set close on exec flag */
if (synchronous) XSynchronize( data->display, True );
wine_tsx11_unlock();
data->display_fd = FILE_DupUnixHandle( ConnectionNumber(data->display),
GENERIC_READ | SYNCHRONIZE );
data->process_event_count = 0;
NtCurrentTeb()->driver_data = data;
return data;
}
/***********************************************************************
* X11DRV initialisation routine * X11DRV initialisation routine
*/ */
BOOL WINAPI X11DRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved ) BOOL WINAPI X11DRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
...@@ -486,6 +455,9 @@ BOOL WINAPI X11DRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved ) ...@@ -486,6 +455,9 @@ BOOL WINAPI X11DRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
process_attach(); process_attach();
break; break;
case DLL_THREAD_DETACH:
thread_detach();
break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
process_detach(); process_detach();
break; break;
...@@ -542,11 +514,3 @@ void X11DRV_SetScreenSaveTimeout(int nTimeout) ...@@ -542,11 +514,3 @@ void X11DRV_SetScreenSaveTimeout(int nTimeout)
if (nTimeout>32767) nTimeout = 32767; if (nTimeout>32767) nTimeout = 32767;
TSXSetScreenSaver(gdi_display, nTimeout, 60, DefaultBlanking, DefaultExposures); TSXSetScreenSaver(gdi_display, nTimeout, 60, DefaultBlanking, DefaultExposures);
} }
/***********************************************************************
* X11DRV_IsSingleWindow
*/
BOOL X11DRV_IsSingleWindow(void)
{
return (root_window != DefaultRootWindow(gdi_display));
}
...@@ -101,10 +101,11 @@ typedef struct _TEB ...@@ -101,10 +101,11 @@ typedef struct _TEB
void *debug_info; /* --3 21c Info for debugstr functions */ void *debug_info; /* --3 21c Info for debugstr functions */
void *pthread_data; /* --3 220 Data for pthread emulation */ void *pthread_data; /* --3 220 Data for pthread emulation */
struct async_private *pending_list; /* --3 224 list of pending async operations */ struct async_private *pending_list; /* --3 224 list of pending async operations */
void *driver_data; /* --3 228 Graphics driver private data */
/* here is plenty space for wine specific fields (don't forget to change pad6!!) */ /* here is plenty space for wine specific fields (don't forget to change pad6!!) */
/* the following are nt specific fields */ /* the following are nt specific fields */
DWORD pad6[628]; /* --n 228 */ DWORD pad6[627]; /* --n 22c */
UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */ UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */
USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */ USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */
DWORD pad7; /* --n e0c */ DWORD pad7; /* --n e0c */
......
...@@ -38,8 +38,6 @@ typedef VOID CALLBACK (*LPMOUSE_EVENT_PROC)(DWORD,DWORD,DWORD,DWORD,DWORD); ...@@ -38,8 +38,6 @@ typedef VOID CALLBACK (*LPMOUSE_EVENT_PROC)(DWORD,DWORD,DWORD,DWORD,DWORD);
struct tagWND; struct tagWND;
typedef struct tagUSER_DRIVER { typedef struct tagUSER_DRIVER {
/* event functions */
void (*pUserRepaintDisable)(BOOL);
/* keyboard functions */ /* keyboard functions */
void (*pInitKeyboard)(void); void (*pInitKeyboard)(void);
WORD (*pVkKeyScan)(CHAR); WORD (*pVkKeyScan)(CHAR);
...@@ -75,6 +73,7 @@ typedef struct tagUSER_DRIVER { ...@@ -75,6 +73,7 @@ typedef struct tagUSER_DRIVER {
BOOL (*pDestroyWindow)(HWND); BOOL (*pDestroyWindow)(HWND);
BOOL (*pGetDC)(HWND,HDC,HRGN,DWORD); BOOL (*pGetDC)(HWND,HDC,HRGN,DWORD);
BOOL (*pEnableWindow)(HWND,BOOL); BOOL (*pEnableWindow)(HWND,BOOL);
DWORD (*pMsgWaitForMultipleObjects)(DWORD,HANDLE*,BOOL,DWORD);
INT (*pScrollWindowEx)(HWND,INT,INT,const RECT*,const RECT*,HRGN,LPRECT,UINT); INT (*pScrollWindowEx)(HWND,INT,INT,const RECT*,const RECT*,HRGN,LPRECT,UINT);
void (*pSetFocus)(HWND); void (*pSetFocus)(HWND);
HWND (*pSetParent)(HWND,HWND); HWND (*pSetParent)(HWND,HWND);
...@@ -83,7 +82,6 @@ typedef struct tagUSER_DRIVER { ...@@ -83,7 +82,6 @@ typedef struct tagUSER_DRIVER {
HICON (*pSetWindowIcon)(HWND,HICON,BOOL); HICON (*pSetWindowIcon)(HWND,HICON,BOOL);
BOOL (*pSetWindowText)(HWND,LPCWSTR); BOOL (*pSetWindowText)(HWND,LPCWSTR);
void (*pSysCommandSizeMove)(HWND,WPARAM); void (*pSysCommandSizeMove)(HWND,WPARAM);
BOOL (*pIsSingleWindow)(void);
} USER_DRIVER; } USER_DRIVER;
extern USER_DRIVER USER_Driver; extern USER_DRIVER USER_Driver;
......
...@@ -19,12 +19,11 @@ ...@@ -19,12 +19,11 @@
#include "winbase.h" #include "winbase.h"
#include "gdi.h" #include "gdi.h"
#include "user.h" #include "user.h"
#include "thread.h"
#define MAX_PIXELFORMATS 8 #define MAX_PIXELFORMATS 8
struct tagBITMAPOBJ; struct tagBITMAPOBJ;
struct tagCLASS;
struct tagCREATESTRUCTA;
struct tagCURSORICONINFO; struct tagCURSORICONINFO;
struct tagDC; struct tagDC;
struct tagDeviceCaps; struct tagDeviceCaps;
...@@ -304,18 +303,32 @@ extern BOOL X11DRV_PALETTE_IsDark(int pixel); ...@@ -304,18 +303,32 @@ extern BOOL X11DRV_PALETTE_IsDark(int pixel);
* X11 USER driver * X11 USER driver
*/ */
extern Display *display; struct x11drv_thread_data
extern Screen *screen; {
Display *display;
HANDLE display_fd;
int process_event_count;
};
extern struct x11drv_thread_data *x11drv_init_thread_data(void);
inline static struct x11drv_thread_data *x11drv_thread_data(void)
{
struct x11drv_thread_data *data = NtCurrentTeb()->driver_data;
if (!data) data = x11drv_init_thread_data();
return data;
}
inline static Display *thread_display(void) { return x11drv_thread_data()->display; }
extern Visual *visual; extern Visual *visual;
extern Window root_window; extern Window root_window;
extern unsigned int screen_width; extern unsigned int screen_width;
extern unsigned int screen_height; extern unsigned int screen_height;
extern unsigned int screen_depth; extern unsigned int screen_depth;
static inline Screen *X11DRV_GetXScreen(void) { return screen; }
static inline Visual *X11DRV_GetVisual(void) { return visual; } static inline Visual *X11DRV_GetVisual(void) { return visual; }
static inline Window X11DRV_GetXRootWindow(void) { return root_window; } static inline Window X11DRV_GetXRootWindow(void) { return root_window; }
static inline unsigned int X11DRV_GetDepth(void) { return screen_depth; }
/* X11 clipboard driver */ /* X11 clipboard driver */
...@@ -332,8 +345,6 @@ extern BOOL X11DRV_GetClipboardData(UINT wFormat); ...@@ -332,8 +345,6 @@ extern BOOL X11DRV_GetClipboardData(UINT wFormat);
extern WORD X11DRV_EVENT_XStateToKeyState( int state ) ; extern WORD X11DRV_EVENT_XStateToKeyState( int state ) ;
extern void X11DRV_EVENT_Init(void);
extern void X11DRV_EVENT_Cleanup(void);
extern void X11DRV_Synchronize( void ); extern void X11DRV_Synchronize( void );
typedef enum { typedef enum {
...@@ -388,5 +399,10 @@ extern void X11DRV_WND_SetGravity(struct tagWND* wndPtr, int value ); ...@@ -388,5 +399,10 @@ extern void X11DRV_WND_SetGravity(struct tagWND* wndPtr, int value );
extern BOOL X11DRV_WND_SetHostAttr(struct tagWND *wndPtr, INT haKey, INT value); extern BOOL X11DRV_WND_SetHostAttr(struct tagWND *wndPtr, INT haKey, INT value);
extern void X11DRV_SetFocus( HWND hwnd ); extern void X11DRV_SetFocus( HWND hwnd );
extern Cursor X11DRV_GetCursor( Display *display, struct tagCURSORICONINFO *ptr );
extern void X11DRV_register_window( Display *display, HWND hwnd, Window win );
extern void X11DRV_create_desktop_thread(void);
extern Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry );
#endif /* __WINE_X11DRV_H */ #endif /* __WINE_X11DRV_H */
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "dde.h" #include "dde.h"
#include "queue.h" #include "queue.h"
#include "winproc.h" #include "winproc.h"
#include "user.h"
#include "thread.h" #include "thread.h"
#include "options.h" #include "options.h"
#include "controls.h" #include "controls.h"
...@@ -147,7 +148,7 @@ static DWORD MSG_TranslateMouseMsg( HWND hTopWnd, DWORD first, DWORD last, ...@@ -147,7 +148,7 @@ static DWORD MSG_TranslateMouseMsg( HWND hTopWnd, DWORD first, DWORD last,
/* stop if not the right queue */ /* stop if not the right queue */
if (pWnd->hmemTaskQ != hQ) if (pWnd->hmemTaskQ && pWnd->hmemTaskQ != hQ)
{ {
/* Not for the current task */ /* Not for the current task */
if (queue) QUEUE_ClearWakeBit( queue, QS_MOUSE ); if (queue) QUEUE_ClearWakeBit( queue, QS_MOUSE );
...@@ -377,7 +378,7 @@ static DWORD MSG_TranslateKbdMsg( HWND hTopWnd, DWORD first, DWORD last, ...@@ -377,7 +378,7 @@ static DWORD MSG_TranslateKbdMsg( HWND hTopWnd, DWORD first, DWORD last,
if ( !hWnd ) return SYSQ_MSG_ABANDON; if ( !hWnd ) return SYSQ_MSG_ABANDON;
pWnd = WIN_FindWndPtr( hWnd ); pWnd = WIN_FindWndPtr( hWnd );
if (pWnd && (pWnd->hmemTaskQ != GetFastQueue16())) if (pWnd && pWnd->hmemTaskQ && (pWnd->hmemTaskQ != GetFastQueue16()))
{ {
/* Not for the current task */ /* Not for the current task */
MESSAGEQUEUE *queue = QUEUE_Lock( GetFastQueue16() ); MESSAGEQUEUE *queue = QUEUE_Lock( GetFastQueue16() );
...@@ -1252,6 +1253,10 @@ static BOOL MSG_PeekMessage( int type, LPMSG msg_out, HWND hwnd, ...@@ -1252,6 +1253,10 @@ static BOOL MSG_PeekMessage( int type, LPMSG msg_out, HWND hwnd,
#if 0 /* FIXME */ #if 0 /* FIXME */
if (!(flags & PM_NOYIELD)) UserYield16(); if (!(flags & PM_NOYIELD)) UserYield16();
#endif #endif
/* check for graphics events */
if (USER_Driver.pMsgWaitForMultipleObjects)
USER_Driver.pMsgWaitForMultipleObjects( 0, NULL, FALSE, 0 );
QUEUE_Unlock( msgQueue ); QUEUE_Unlock( msgQueue );
WIN_RestoreWndsLock(iWndsLocks); WIN_RestoreWndsLock(iWndsLocks);
return FALSE; return FALSE;
...@@ -1860,7 +1865,7 @@ static LRESULT MSG_SendMessage( HWND hwnd, UINT msg, WPARAM wParam, ...@@ -1860,7 +1865,7 @@ static LRESULT MSG_SendMessage( HWND hwnd, UINT msg, WPARAM wParam,
else else
SPY_EnterMessage( SPY_SENDMESSAGE16, hwnd, msg, wParam, lParam ); SPY_EnterMessage( SPY_SENDMESSAGE16, hwnd, msg, wParam, lParam );
if (wndPtr->hmemTaskQ != GetFastQueue16()) if (wndPtr->hmemTaskQ && wndPtr->hmemTaskQ != GetFastQueue16())
ret = MSG_SendMessageInterThread( wndPtr->hmemTaskQ, hwnd, msg, ret = MSG_SendMessageInterThread( wndPtr->hmemTaskQ, hwnd, msg,
wParam, lParam, timeout, flags, pRes ); wParam, lParam, timeout, flags, pRes );
else else
...@@ -2064,6 +2069,12 @@ DWORD WINAPI MsgWaitForMultipleObjects( DWORD nCount, HANDLE *pHandles, ...@@ -2064,6 +2069,12 @@ DWORD WINAPI MsgWaitForMultipleObjects( DWORD nCount, HANDLE *pHandles,
/* Add the thread event to the handle list */ /* Add the thread event to the handle list */
for (i = 0; i < nCount; i++) handles[i] = pHandles[i]; for (i = 0; i < nCount; i++) handles[i] = pHandles[i];
handles[nCount] = msgQueue->server_queue; handles[nCount] = msgQueue->server_queue;
if (USER_Driver.pMsgWaitForMultipleObjects)
{
ret = USER_Driver.pMsgWaitForMultipleObjects(nCount+1, handles, fWaitAll, dwMilliseconds);
if (ret == nCount+1) ret = nCount; /* pretend the msg queue is ready */
}
else
ret = WaitForMultipleObjects( nCount+1, handles, fWaitAll, dwMilliseconds ); ret = WaitForMultipleObjects( nCount+1, handles, fWaitAll, dwMilliseconds );
QUEUE_Unlock( msgQueue ); QUEUE_Unlock( msgQueue );
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "wine/winuser16.h" #include "wine/winuser16.h"
#include "queue.h" #include "queue.h"
#include "win.h" #include "win.h"
#include "user.h"
#include "hook.h" #include "hook.h"
#include "thread.h" #include "thread.h"
#include "debugtools.h" #include "debugtools.h"
...@@ -731,11 +732,15 @@ int QUEUE_WaitBits( WORD bits, DWORD timeout ) ...@@ -731,11 +732,15 @@ int QUEUE_WaitBits( WORD bits, DWORD timeout )
} }
queue->wakeMask = bits | QS_SENDMESSAGE; queue->wakeMask = bits | QS_SENDMESSAGE;
TRACE_(msg)("%04x) wakeMask is %04x, waiting\n", queue->self, queue->wakeMask); TRACE_(msg)("%04x: wakeMask is %04x, waiting\n", queue->self, queue->wakeMask);
LeaveCriticalSection( &queue->cSection ); LeaveCriticalSection( &queue->cSection );
ReleaseThunkLock( &dwlc ); ReleaseThunkLock( &dwlc );
if (dwlc) TRACE_(msg)("had win16 lock\n"); if (dwlc) TRACE_(msg)("had win16 lock\n");
if (USER_Driver.pMsgWaitForMultipleObjects)
USER_Driver.pMsgWaitForMultipleObjects( 1, &queue->server_queue, FALSE, timeout );
else
WaitForSingleObject( queue->server_queue, timeout ); WaitForSingleObject( queue->server_queue, timeout );
if (dwlc) RestoreThunkLock( dwlc ); if (dwlc) RestoreThunkLock( dwlc );
} }
...@@ -1095,6 +1100,7 @@ void QUEUE_RemoveMsg( MESSAGEQUEUE * msgQueue, QMSG *qmsg ) ...@@ -1095,6 +1100,7 @@ void QUEUE_RemoveMsg( MESSAGEQUEUE * msgQueue, QMSG *qmsg )
} }
#if 0
/*********************************************************************** /***********************************************************************
* QUEUE_WakeSomeone * QUEUE_WakeSomeone
* *
...@@ -1161,6 +1167,7 @@ static void QUEUE_WakeSomeone( UINT message ) ...@@ -1161,6 +1167,7 @@ static void QUEUE_WakeSomeone( UINT message )
WARN_(msg)("couldn't find queue\n"); WARN_(msg)("couldn't find queue\n");
} }
#endif
/*********************************************************************** /***********************************************************************
...@@ -1174,6 +1181,7 @@ void hardware_event( UINT message, WPARAM wParam, LPARAM lParam, ...@@ -1174,6 +1181,7 @@ void hardware_event( UINT message, WPARAM wParam, LPARAM lParam,
{ {
MSG *msg; MSG *msg;
QMSG *qmsg; QMSG *qmsg;
MESSAGEQUEUE *queue;
int mergeMsg = 0; int mergeMsg = 0;
if (!sysMsgQueue) return; if (!sysMsgQueue) return;
...@@ -1237,7 +1245,16 @@ void hardware_event( UINT message, WPARAM wParam, LPARAM lParam, ...@@ -1237,7 +1245,16 @@ void hardware_event( UINT message, WPARAM wParam, LPARAM lParam,
LeaveCriticalSection( &sysMsgQueue->cSection ); LeaveCriticalSection( &sysMsgQueue->cSection );
QUEUE_WakeSomeone( message ); if ((queue = QUEUE_Lock( GetFastQueue16() )))
{
WORD wakeBit;
if ((message >= WM_KEYFIRST) && (message <= WM_KEYLAST)) wakeBit = QS_KEY;
else wakeBit = (message == WM_MOUSEMOVE) ? QS_MOUSEMOVE : QS_MOUSEBUTTON;
QUEUE_SetWakeBit( queue, wakeBit );
QUEUE_Unlock( queue );
}
} }
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "winuser.h" #include "winuser.h"
#include "heap.h" #include "heap.h"
#include "user.h" #include "user.h"
#include "task.h"
#include "queue.h" #include "queue.h"
#include "win.h" #include "win.h"
#include "controls.h" #include "controls.h"
...@@ -101,56 +100,6 @@ static void USER_ModuleUnload( HMODULE16 hModule ) ...@@ -101,56 +100,6 @@ static void USER_ModuleUnload( HMODULE16 hModule )
CURSORICON_FreeModuleIcons( hModule ); CURSORICON_FreeModuleIcons( hModule );
} }
/**********************************************************************
* USER_QueueCleanup
*/
static void USER_QueueCleanup( HQUEUE16 hQueue )
{
if ( hQueue )
{
WND* desktop = WIN_GetDesktop();
/* Patch desktop window */
if ( desktop->hmemTaskQ == hQueue )
{
HTASK16 nextTask = TASK_GetNextTask( GetCurrentTask() );
desktop->hmemTaskQ = GetTaskQueue16( nextTask );
}
TIMER_RemoveQueueTimers( hQueue );
HOOK_FreeQueueHooks( hQueue );
QUEUE_SetExitingQueue( hQueue );
WIN_ResetQueueWindows( desktop, hQueue, (HQUEUE16)0);
QUEUE_SetExitingQueue( 0 );
/* Free the message queue */
QUEUE_DeleteMsgQueue( hQueue );
WIN_ReleaseDesktop();
}
}
/**********************************************************************
* USER_AppExit
*/
static void USER_AppExit(void)
{
HINSTANCE16 hInstance = MapHModuleLS(0);
/* FIXME: maybe destroy menus (Windows only complains about them
* but does nothing);
*/
/* ModuleUnload() in "Internals" */
hInstance = GetExePtr( hInstance );
if( GetModuleUsage16( hInstance ) <= 1 )
USER_ModuleUnload( hInstance );
}
/*********************************************************************** /***********************************************************************
* SignalProc (USER.314) * SignalProc (USER.314)
*/ */
...@@ -190,34 +139,16 @@ WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID, ...@@ -190,34 +139,16 @@ WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
break; break;
case USIG_DLL_UNLOAD_ORPHANS: case USIG_DLL_UNLOAD_ORPHANS:
break;
case USIG_FAULT_DIALOG_PUSH: case USIG_FAULT_DIALOG_PUSH:
case USIG_FAULT_DIALOG_POP: case USIG_FAULT_DIALOG_POP:
break;
case USIG_THREAD_INIT: case USIG_THREAD_INIT:
break;
case USIG_THREAD_EXIT: case USIG_THREAD_EXIT:
USER_QueueCleanup( GetThreadQueue16( dwThreadOrProcessID ) );
SetThreadQueue16( dwThreadOrProcessID, 0 );
break;
case USIG_PROCESS_CREATE: case USIG_PROCESS_CREATE:
break;
case USIG_PROCESS_INIT: case USIG_PROCESS_INIT:
case USIG_PROCESS_LOADED: case USIG_PROCESS_LOADED:
break;
case USIG_PROCESS_RUNNING: case USIG_PROCESS_RUNNING:
break;
case USIG_PROCESS_EXIT: case USIG_PROCESS_EXIT:
break;
case USIG_PROCESS_DESTROY: case USIG_PROCESS_DESTROY:
USER_AppExit();
break; break;
default: default:
......
...@@ -359,6 +359,7 @@ HWND WIN_FindWinToRepaint( HWND hwnd, HQUEUE16 hQueue ) ...@@ -359,6 +359,7 @@ HWND WIN_FindWinToRepaint( HWND hwnd, HQUEUE16 hQueue )
* The real reason why is because Windows DesktopWndProc * The real reason why is because Windows DesktopWndProc
* does ValidateRgn inside WM_ERASEBKGND handler. * does ValidateRgn inside WM_ERASEBKGND handler.
*/ */
if (hwnd == GetDesktopWindow()) hwnd = 0;
pWnd = hwnd ? WIN_FindWndPtr(hwnd) : WIN_LockWndPtr(pWndDesktop->child); pWnd = hwnd ? WIN_FindWndPtr(hwnd) : WIN_LockWndPtr(pWndDesktop->child);
...@@ -601,7 +602,7 @@ BOOL WIN_CreateDesktopWindow(void) ...@@ -601,7 +602,7 @@ BOOL WIN_CreateDesktopWindow(void)
pWndDesktop->rectWindow.bottom = GetSystemMetrics(SM_CYSCREEN); pWndDesktop->rectWindow.bottom = GetSystemMetrics(SM_CYSCREEN);
pWndDesktop->rectClient = pWndDesktop->rectWindow; pWndDesktop->rectClient = pWndDesktop->rectWindow;
pWndDesktop->text = NULL; pWndDesktop->text = NULL;
pWndDesktop->hmemTaskQ = GetFastQueue16(); pWndDesktop->hmemTaskQ = 0;
pWndDesktop->hrgnUpdate = 0; pWndDesktop->hrgnUpdate = 0;
pWndDesktop->hwndLastActive = hwndDesktop; pWndDesktop->hwndLastActive = hwndDesktop;
pWndDesktop->dwStyle = WS_VISIBLE | WS_CLIPCHILDREN | pWndDesktop->dwStyle = WS_VISIBLE | WS_CLIPCHILDREN |
......
...@@ -1987,13 +1987,7 @@ BOOL WINPOS_ActivateOtherWindow(WND* pWnd) ...@@ -1987,13 +1987,7 @@ BOOL WINPOS_ActivateOtherWindow(WND* pWnd)
bRet = WINPOS_SetActiveWindow( pWndTo ? pWndTo->hwndSelf : 0, FALSE, TRUE ); bRet = WINPOS_SetActiveWindow( pWndTo ? pWndTo->hwndSelf : 0, FALSE, TRUE );
/* switch desktop queue to current active */ if( pWndTo ) WIN_ReleaseWndPtr(pWndTo);
if( pWndTo )
{
WIN_GetDesktop()->hmemTaskQ = pWndTo->hmemTaskQ;
WIN_ReleaseWndPtr(pWndTo);
WIN_ReleaseDesktop();
}
hwndPrevActive = 0; hwndPrevActive = 0;
return bRet; return bRet;
...@@ -2005,7 +1999,7 @@ BOOL WINPOS_ActivateOtherWindow(WND* pWnd) ...@@ -2005,7 +1999,7 @@ BOOL WINPOS_ActivateOtherWindow(WND* pWnd)
*/ */
BOOL WINPOS_ChangeActiveWindow( HWND hWnd, BOOL mouseMsg ) BOOL WINPOS_ChangeActiveWindow( HWND hWnd, BOOL mouseMsg )
{ {
WND *wndPtr, *wndTemp; WND *wndPtr;
BOOL retvalue; BOOL retvalue;
HWND hwndActive = 0; HWND hwndActive = 0;
...@@ -2045,12 +2039,6 @@ BOOL WINPOS_ChangeActiveWindow( HWND hWnd, BOOL mouseMsg ) ...@@ -2045,12 +2039,6 @@ BOOL WINPOS_ChangeActiveWindow( HWND hWnd, BOOL mouseMsg )
goto end; goto end;
} }
/* switch desktop queue to current active */
wndTemp = WIN_GetDesktop();
if( wndPtr->parent == wndTemp)
wndTemp->hmemTaskQ = wndPtr->hmemTaskQ;
WIN_ReleaseDesktop();
retvalue = TRUE; retvalue = TRUE;
end: end:
WIN_ReleaseWndPtr(wndPtr); WIN_ReleaseWndPtr(wndPtr);
......
...@@ -176,7 +176,7 @@ Atom X11DRV_CLIPBOARD_MapFormatToProperty(UINT wFormat) ...@@ -176,7 +176,7 @@ Atom X11DRV_CLIPBOARD_MapFormatToProperty(UINT wFormat)
if (fmtName) if (fmtName)
{ {
strncat(str, fmtName, sizeof(str) - strlen(FMT_PREFIX)); strncat(str, fmtName, sizeof(str) - strlen(FMT_PREFIX));
prop = TSXInternAtom(display, str, False); prop = TSXInternAtom(thread_display(), str, False);
} }
break; break;
} }
...@@ -196,7 +196,7 @@ Atom X11DRV_CLIPBOARD_MapFormatToProperty(UINT wFormat) ...@@ -196,7 +196,7 @@ Atom X11DRV_CLIPBOARD_MapFormatToProperty(UINT wFormat)
*/ */
BOOL X11DRV_CLIPBOARD_IsNativeProperty(Atom prop) BOOL X11DRV_CLIPBOARD_IsNativeProperty(Atom prop)
{ {
char *itemFmtName = TSXGetAtomName(display, prop); char *itemFmtName = TSXGetAtomName(thread_display(), prop);
BOOL bRet = FALSE; BOOL bRet = FALSE;
if ( 0 == strncmp(itemFmtName, FMT_PREFIX, strlen(FMT_PREFIX)) ) if ( 0 == strncmp(itemFmtName, FMT_PREFIX, strlen(FMT_PREFIX)) )
...@@ -217,6 +217,7 @@ BOOL X11DRV_CLIPBOARD_IsNativeProperty(Atom prop) ...@@ -217,6 +217,7 @@ BOOL X11DRV_CLIPBOARD_IsNativeProperty(Atom prop)
BOOL X11DRV_CLIPBOARD_LaunchServer() BOOL X11DRV_CLIPBOARD_LaunchServer()
{ {
int iWndsLocks; int iWndsLocks;
char clearSelection[8];
/* If persistant selection has been disabled in the .winerc Clipboard section, /* If persistant selection has been disabled in the .winerc Clipboard section,
* don't launch the server * don't launch the server
...@@ -224,6 +225,9 @@ BOOL X11DRV_CLIPBOARD_LaunchServer() ...@@ -224,6 +225,9 @@ BOOL X11DRV_CLIPBOARD_LaunchServer()
if ( !PROFILE_GetWineIniInt("Clipboard", "PersistentSelection", 1) ) if ( !PROFILE_GetWineIniInt("Clipboard", "PersistentSelection", 1) )
return FALSE; return FALSE;
/* Get the clear selection preference */
sprintf(clearSelection, "%d", PROFILE_GetWineIniInt("Clipboard", "ClearAllSelections", 0));
/* Start up persistant WINE X clipboard server process which will /* Start up persistant WINE X clipboard server process which will
* take ownership of the X selection and continue to service selection * take ownership of the X selection and continue to service selection
* requests from other apps. * requests from other apps.
...@@ -234,16 +238,8 @@ BOOL X11DRV_CLIPBOARD_LaunchServer() ...@@ -234,16 +238,8 @@ BOOL X11DRV_CLIPBOARD_LaunchServer()
/* NOTE: This code only executes in the context of the child process /* NOTE: This code only executes in the context of the child process
* Do note make any Wine specific calls here. * Do note make any Wine specific calls here.
*/ */
int dbgClasses = 0; int dbgClasses = 0;
char selMask[8], dbgClassMask[8], clearSelection[8]; char selMask[8], dbgClassMask[8];
int i;
/* Don't inherit wine's X sockets to the wineclipsrv, otherwise
* windows stay around when you have to kill a hanging wine...
*/
for (i = 3; i < 256; ++i)
fcntl(i, F_SETFD, 1);
sprintf(selMask, "%d", selectionAcquired); sprintf(selMask, "%d", selectionAcquired);
...@@ -256,10 +252,6 @@ BOOL X11DRV_CLIPBOARD_LaunchServer() ...@@ -256,10 +252,6 @@ BOOL X11DRV_CLIPBOARD_LaunchServer()
dbgClasses |= TRACE_ON(clipboard) ? 8 : 0; dbgClasses |= TRACE_ON(clipboard) ? 8 : 0;
sprintf(dbgClassMask, "%d", dbgClasses); sprintf(dbgClassMask, "%d", dbgClasses);
/* Get the clear selection preference */
sprintf(clearSelection, "%d",
PROFILE_GetWineIniInt("Clipboard", "ClearAllSelections", 0));
/* Exec the clipboard server passing it the selection and debug class masks */ /* Exec the clipboard server passing it the selection and debug class masks */
execl( BINDIR "/wineclipsrv", "wineclipsrv", execl( BINDIR "/wineclipsrv", "wineclipsrv",
selMask, dbgClassMask, clearSelection, NULL ); selMask, dbgClassMask, clearSelection, NULL );
...@@ -295,7 +287,7 @@ BOOL X11DRV_CLIPBOARD_LaunchServer() ...@@ -295,7 +287,7 @@ BOOL X11DRV_CLIPBOARD_LaunchServer()
TRACE("Waiting for clipboard server to acquire selection\n"); TRACE("Waiting for clipboard server to acquire selection\n");
if ( WaitForSingleObject( selectionClearEvent, 60000 ) != WAIT_OBJECT_0 ) if ( MsgWaitForMultipleObjects( 1, &selectionClearEvent, FALSE, 60000, QS_ALLINPUT ) != WAIT_OBJECT_0 )
TRACE("Server could not acquire selection, or a timeout occurred!\n"); TRACE("Server could not acquire selection, or a timeout occurred!\n");
else else
TRACE("Server successfully acquired selection\n"); TRACE("Server successfully acquired selection\n");
...@@ -320,6 +312,7 @@ BOOL X11DRV_CLIPBOARD_LaunchServer() ...@@ -320,6 +312,7 @@ BOOL X11DRV_CLIPBOARD_LaunchServer()
*/ */
int X11DRV_CLIPBOARD_CacheDataFormats( Atom SelectionName ) int X11DRV_CLIPBOARD_CacheDataFormats( Atom SelectionName )
{ {
Display *display = thread_display();
HWND hWnd = 0; HWND hWnd = 0;
HWND hWndClipWindow = GetOpenClipboardWindow(); HWND hWndClipWindow = GetOpenClipboardWindow();
WND* wnd = NULL; WND* wnd = NULL;
...@@ -458,6 +451,7 @@ int X11DRV_CLIPBOARD_CacheDataFormats( Atom SelectionName ) ...@@ -458,6 +451,7 @@ int X11DRV_CLIPBOARD_CacheDataFormats( Atom SelectionName )
*/ */
static BOOL X11DRV_CLIPBOARD_ReadSelection(UINT wFormat, Window w, Atom prop, Atom reqType) static BOOL X11DRV_CLIPBOARD_ReadSelection(UINT wFormat, Window w, Atom prop, Atom reqType)
{ {
Display *display = thread_display();
Atom atype=AnyPropertyType; Atom atype=AnyPropertyType;
int aformat; int aformat;
unsigned long total,nitems,remain,itemSize,val_cnt; unsigned long total,nitems,remain,itemSize,val_cnt;
...@@ -685,6 +679,7 @@ END: ...@@ -685,6 +679,7 @@ END:
*/ */
void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd) void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd)
{ {
Display *display = thread_display();
Atom xaClipboard = TSXInternAtom(display, "CLIPBOARD", False); Atom xaClipboard = TSXInternAtom(display, "CLIPBOARD", False);
int clearAllSelections = PROFILE_GetWineIniInt("Clipboard", "ClearAllSelections", 0); int clearAllSelections = PROFILE_GetWineIniInt("Clipboard", "ClearAllSelections", 0);
...@@ -797,6 +792,7 @@ void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd) ...@@ -797,6 +792,7 @@ void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd)
*/ */
void X11DRV_ReleaseClipboard(void) void X11DRV_ReleaseClipboard(void)
{ {
Display *display = thread_display();
if( selectionAcquired ) if( selectionAcquired )
{ {
XEvent xe; XEvent xe;
...@@ -847,6 +843,7 @@ void X11DRV_ReleaseClipboard(void) ...@@ -847,6 +843,7 @@ void X11DRV_ReleaseClipboard(void)
*/ */
void X11DRV_AcquireClipboard(void) void X11DRV_AcquireClipboard(void)
{ {
Display *display = thread_display();
Window owner; Window owner;
HWND hWndClipWindow = GetOpenClipboardWindow(); HWND hWndClipWindow = GetOpenClipboardWindow();
...@@ -900,6 +897,7 @@ void X11DRV_AcquireClipboard(void) ...@@ -900,6 +897,7 @@ void X11DRV_AcquireClipboard(void)
*/ */
BOOL X11DRV_IsClipboardFormatAvailable(UINT wFormat) BOOL X11DRV_IsClipboardFormatAvailable(UINT wFormat)
{ {
Display *display = thread_display();
Atom xaClipboard = TSXInternAtom(display, _CLIPBOARD, False); Atom xaClipboard = TSXInternAtom(display, _CLIPBOARD, False);
Window ownerPrimary = TSXGetSelectionOwner(display,XA_PRIMARY); Window ownerPrimary = TSXGetSelectionOwner(display,XA_PRIMARY);
Window ownerClipboard = TSXGetSelectionOwner(display,xaClipboard); Window ownerClipboard = TSXGetSelectionOwner(display,xaClipboard);
...@@ -957,6 +955,7 @@ BOOL X11DRV_IsClipboardFormatAvailable(UINT wFormat) ...@@ -957,6 +955,7 @@ BOOL X11DRV_IsClipboardFormatAvailable(UINT wFormat)
*/ */
BOOL X11DRV_RegisterClipboardFormat( LPCSTR FormatName ) BOOL X11DRV_RegisterClipboardFormat( LPCSTR FormatName )
{ {
Display *display = thread_display();
Atom prop = None; Atom prop = None;
char str[256]; char str[256];
...@@ -1009,6 +1008,7 @@ void X11DRV_SetClipboardData(UINT wFormat) ...@@ -1009,6 +1008,7 @@ void X11DRV_SetClipboardData(UINT wFormat)
*/ */
BOOL X11DRV_GetClipboardData(UINT wFormat) BOOL X11DRV_GetClipboardData(UINT wFormat)
{ {
Display *display = thread_display();
BOOL bRet = selectionAcquired; BOOL bRet = selectionAcquired;
HWND hWndClipWindow = GetOpenClipboardWindow(); HWND hWndClipWindow = GetOpenClipboardWindow();
HWND hWnd = (hWndClipWindow) ? hWndClipWindow : GetActiveWindow(); HWND hWnd = (hWndClipWindow) ? hWndClipWindow : GetActiveWindow();
...@@ -1087,6 +1087,7 @@ BOOL X11DRV_GetClipboardData(UINT wFormat) ...@@ -1087,6 +1087,7 @@ BOOL X11DRV_GetClipboardData(UINT wFormat)
*/ */
void X11DRV_ResetSelectionOwner(WND *pWnd, BOOL bFooBar) void X11DRV_ResetSelectionOwner(WND *pWnd, BOOL bFooBar)
{ {
Display *display = thread_display();
HWND hWndClipOwner = 0; HWND hWndClipOwner = 0;
Window XWnd = X11DRV_WND_GetXWindow(pWnd); Window XWnd = X11DRV_WND_GetXWindow(pWnd);
Atom xaClipboard; Atom xaClipboard;
......
...@@ -691,7 +691,7 @@ void X11DRV_KEYBOARD_UpdateState ( void ) ...@@ -691,7 +691,7 @@ void X11DRV_KEYBOARD_UpdateState ( void )
char keys_return[32]; char keys_return[32];
TRACE("called\n"); TRACE("called\n");
if (!TSXQueryKeymap(display, keys_return)) { if (!TSXQueryKeymap(thread_display(), keys_return)) {
ERR("Error getting keymap !\n"); ERR("Error getting keymap !\n");
return; return;
} }
...@@ -839,6 +839,7 @@ void X11DRV_KEYBOARD_HandleEvent( WND *pWnd, XKeyEvent *event ) ...@@ -839,6 +839,7 @@ void X11DRV_KEYBOARD_HandleEvent( WND *pWnd, XKeyEvent *event )
static void static void
X11DRV_KEYBOARD_DetectLayout (void) X11DRV_KEYBOARD_DetectLayout (void)
{ {
Display *display = thread_display();
unsigned current, match, mismatch, seq; unsigned current, match, mismatch, seq;
int score, keyc, i, key, pkey, ok, syms; int score, keyc, i, key, pkey, ok, syms;
KeySym keysym; KeySym keysym;
...@@ -937,6 +938,7 @@ void X11DRV_InitKeyboard(void) ...@@ -937,6 +938,7 @@ void X11DRV_InitKeyboard(void)
#ifdef HAVE_XKB #ifdef HAVE_XKB
int xkb_major = XkbMajorVersion, xkb_minor = XkbMinorVersion; int xkb_major = XkbMajorVersion, xkb_minor = XkbMinorVersion;
#endif #endif
Display *display = thread_display();
KeySym *ksp; KeySym *ksp;
XModifierKeymap *mmp; XModifierKeymap *mmp;
KeySym keysym; KeySym keysym;
...@@ -1164,6 +1166,7 @@ void X11DRV_InitKeyboard(void) ...@@ -1164,6 +1166,7 @@ void X11DRV_InitKeyboard(void)
*/ */
WORD X11DRV_VkKeyScan(CHAR cChar) WORD X11DRV_VkKeyScan(CHAR cChar)
{ {
Display *display = thread_display();
KeyCode keycode; KeyCode keycode;
KeySym keysym; KeySym keysym;
int i,index; int i,index;
...@@ -1212,6 +1215,8 @@ WORD X11DRV_VkKeyScan(CHAR cChar) ...@@ -1212,6 +1215,8 @@ WORD X11DRV_VkKeyScan(CHAR cChar)
*/ */
UINT16 X11DRV_MapVirtualKey(UINT16 wCode, UINT16 wMapType) UINT16 X11DRV_MapVirtualKey(UINT16 wCode, UINT16 wMapType)
{ {
Display *display = thread_display();
#define returnMVK(value) { TRACE("returning 0x%x.\n",value); return value; } #define returnMVK(value) { TRACE("returning 0x%x.\n",value); return value; }
TRACE("MapVirtualKey wCode=0x%x wMapType=%d ... \n", wCode,wMapType); TRACE("MapVirtualKey wCode=0x%x wMapType=%d ... \n", wCode,wMapType);
...@@ -1366,7 +1371,7 @@ INT16 X11DRV_GetKeyNameText(LONG lParam, LPSTR lpBuffer, INT16 nSize) ...@@ -1366,7 +1371,7 @@ INT16 X11DRV_GetKeyNameText(LONG lParam, LPSTR lpBuffer, INT16 nSize)
break; break;
if (keyc <= max_keycode) if (keyc <= max_keycode)
{ {
keys = TSXKeycodeToKeysym(display, keyc, 0); keys = TSXKeycodeToKeysym(thread_display(), keyc, 0);
name = TSXKeysymToString(keys); name = TSXKeysymToString(keys);
TRACE("found scan=%04x keyc=%04x keysym=%04x string=%s\n", TRACE("found scan=%04x keyc=%04x keysym=%04x string=%s\n",
scanCode, keyc, (int)keys, name); scanCode, keyc, (int)keys, name);
...@@ -1484,6 +1489,7 @@ static char KEYBOARD_MapDeadKeysym(KeySym keysym) ...@@ -1484,6 +1489,7 @@ static char KEYBOARD_MapDeadKeysym(KeySym keysym)
INT X11DRV_ToUnicode(UINT virtKey, UINT scanCode, LPBYTE lpKeyState, INT X11DRV_ToUnicode(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
LPWSTR bufW, int bufW_size, UINT flags) LPWSTR bufW, int bufW_size, UINT flags)
{ {
Display *display = thread_display();
XKeyEvent e; XKeyEvent e;
KeySym keysym; KeySym keysym;
INT ret; INT ret;
...@@ -1628,7 +1634,7 @@ INT X11DRV_ToUnicode(UINT virtKey, UINT scanCode, LPBYTE lpKeyState, ...@@ -1628,7 +1634,7 @@ INT X11DRV_ToUnicode(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
*/ */
void X11DRV_Beep(void) void X11DRV_Beep(void)
{ {
TSXBell(display, 0); TSXBell(thread_display(), 0);
} }
/*********************************************************************** /***********************************************************************
......
...@@ -115,7 +115,7 @@ void X11DRV_WND_ForceWindowRaise(WND *wndPtr) ...@@ -115,7 +115,7 @@ void X11DRV_WND_ForceWindowRaise(WND *wndPtr)
while (wndPtr) while (wndPtr)
{ {
if ( !X11DRV_WND_IsZeroSizeWnd(wndPtr) && X11DRV_WND_GetXWindow(wndPtr) ) if ( !X11DRV_WND_IsZeroSizeWnd(wndPtr) && X11DRV_WND_GetXWindow(wndPtr) )
TSXReconfigureWMWindow( display, X11DRV_WND_GetXWindow(wndPtr), 0, TSXReconfigureWMWindow( thread_display(), X11DRV_WND_GetXWindow(wndPtr), 0,
CWStackMode, &winChanges ); CWStackMode, &winChanges );
wndPrev = pDesktop->child; wndPrev = pDesktop->child;
...@@ -144,7 +144,7 @@ static Window X11DRV_WND_FindDesktopXWindow( WND *wndPtr ) ...@@ -144,7 +144,7 @@ static Window X11DRV_WND_FindDesktopXWindow( WND *wndPtr )
window = X11DRV_WND_GetXWindow(wndPtr); window = X11DRV_WND_GetXWindow(wndPtr);
for (;;) for (;;)
{ {
TSXQueryTree( display, window, &root, &parent, TSXQueryTree( thread_display(), window, &root, &parent,
&children, &nchildren ); &children, &nchildren );
TSXFree( children ); TSXFree( children );
if (parent == root) if (parent == root)
...@@ -162,6 +162,7 @@ static Window X11DRV_WND_FindDesktopXWindow( WND *wndPtr ) ...@@ -162,6 +162,7 @@ static Window X11DRV_WND_FindDesktopXWindow( WND *wndPtr )
void X11DRV_WND_SetWindowPos(WND *wndPtr, const WINDOWPOS *winpos, BOOL bChangePos) void X11DRV_WND_SetWindowPos(WND *wndPtr, const WINDOWPOS *winpos, BOOL bChangePos)
{ {
XWindowChanges winChanges; XWindowChanges winChanges;
Display *display = thread_display();
int changeMask = 0; int changeMask = 0;
BOOL isZeroSizeWnd = FALSE; BOOL isZeroSizeWnd = FALSE;
BOOL forceMapWindow = FALSE; BOOL forceMapWindow = FALSE;
...@@ -392,7 +393,7 @@ void X11DRV_WND_SetGravity( WND* wnd, int value ) ...@@ -392,7 +393,7 @@ void X11DRV_WND_SetGravity( WND* wnd, int value )
XSetWindowAttributes win_attr; XSetWindowAttributes win_attr;
win_attr.bit_gravity = value; win_attr.bit_gravity = value;
data->bit_gravity = value; data->bit_gravity = value;
TSXChangeWindowAttributes( display, data->window, CWBitGravity, &win_attr ); TSXChangeWindowAttributes( thread_display(), data->window, CWBitGravity, &win_attr );
} }
} }
...@@ -410,6 +411,7 @@ BOOL X11DRV_WND_SetHostAttr(WND* wnd, INT ha, INT value) ...@@ -410,6 +411,7 @@ BOOL X11DRV_WND_SetHostAttr(WND* wnd, INT ha, INT value)
if( (w = X11DRV_WND_GetXWindow(wnd)) ) if( (w = X11DRV_WND_GetXWindow(wnd)) )
{ {
Display *display = thread_display();
switch( ha ) switch( ha )
{ {
case HAK_ICONICSTATE: /* called when a window is minimized/restored */ case HAK_ICONICSTATE: /* called when a window is minimized/restored */
...@@ -435,8 +437,7 @@ BOOL X11DRV_WND_SetHostAttr(WND* wnd, INT ha, INT value) ...@@ -435,8 +437,7 @@ BOOL X11DRV_WND_SetHostAttr(WND* wnd, INT ha, INT value)
ev.data.l[0] = IconicState; ev.data.l[0] = IconicState;
ev.window = w; ev.window = w;
if( TSXSendEvent (display, if( TSXSendEvent (display, DefaultRootWindow(display),
RootWindow( display, XScreenNumberOfScreen(X11DRV_GetXScreen()) ),
True, (SubstructureRedirectMask | SubstructureNotifyMask), (XEvent*)&ev)) True, (SubstructureRedirectMask | SubstructureNotifyMask), (XEvent*)&ev))
{ {
XEvent xe; XEvent xe;
......
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