2 * X11DRV desktop window handling
4 * Copyright 2001 Alexandre Julliard
8 #include <X11/cursorfont.h>
14 #include "debugtools.h"
16 DEFAULT_DEBUG_CHANNEL(x11drv
);
19 /* desktop window procedure */
20 static LRESULT WINAPI
desktop_winproc( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
25 PaintDesktop( (HDC
)wParam
);
26 ValidateRect( hwnd
, NULL
);
30 if ((wParam
& 0xfff0) == SC_CLOSE
) ExitWindows( 0, 0 );
34 return SetCursor( LoadCursorA( 0, IDC_ARROWA
) );
43 /* desktop window manager thread */
44 static DWORD CALLBACK
desktop_thread( LPVOID driver_data
)
51 NtCurrentTeb()->driver_data
= driver_data
;
52 display
= thread_display();
53 hwnd
= GetDesktopWindow();
55 /* patch the desktop window queue to point to our queue */
56 win
= WIN_FindWndPtr( hwnd
);
57 win
->hmemTaskQ
= GetFastQueue16();
58 X11DRV_register_window( display
, hwnd
, win
->pDriverData
);
59 WIN_ReleaseWndPtr( win
);
61 SetWindowLongW( hwnd
, GWL_WNDPROC
, (LONG
)desktop_winproc
);
63 XSetWMProtocols( display
, root_window
, &wmDeleteWindow
, 1 );
64 XMapWindow( display
, root_window
);
67 while (GetMessageW( &msg
, hwnd
, 0, 0 )) DispatchMessageW( &msg
);
72 /***********************************************************************
73 * X11DRV_create_desktop_thread
75 * Create the thread that manages the desktop window
77 void X11DRV_create_desktop_thread(void)
79 HANDLE handle
= CreateThread( NULL
, 0, desktop_thread
, NtCurrentTeb()->driver_data
, 0, NULL
);
82 MESSAGE( "Could not create desktop thread\n" );
85 /* we transferred our driver data to the new thread */
86 NtCurrentTeb()->driver_data
= NULL
;
87 CloseHandle( handle
);
91 /***********************************************************************
92 * X11DRV_create_desktop
94 * Create the X11 desktop window for the desktop mode.
96 Window
X11DRV_create_desktop( XVisualInfo
*desktop_vi
, const char *geometry
)
98 int x
= 0, y
= 0, flags
;
99 unsigned int width
= 640, height
= 480; /* Default size = 640x480 */
100 char *name
= "Wine desktop";
101 XSizeHints
*size_hints
;
103 XClassHint
*class_hints
;
104 XSetWindowAttributes win_attr
;
105 XTextProperty window_name
;
107 Display
*display
= thread_display();
110 flags
= XParseGeometry( geometry
, &x
, &y
, &width
, &height
);
111 screen_width
= width
;
112 screen_height
= height
;
115 win_attr
.background_pixel
= BlackPixel(display
, 0);
116 win_attr
.event_mask
= ExposureMask
| KeyPressMask
| KeyReleaseMask
|
117 PointerMotionMask
| ButtonPressMask
| ButtonReleaseMask
;
118 win_attr
.cursor
= XCreateFontCursor( display
, XC_top_left_arrow
);
121 win_attr
.colormap
= XCreateColormap( display
, DefaultRootWindow(display
),
124 win_attr
.colormap
= None
;
126 win
= XCreateWindow( display
, DefaultRootWindow(display
),
127 x
, y
, width
, height
, 0, screen_depth
, InputOutput
, visual
,
128 CWBackPixel
| CWEventMask
| CWCursor
| CWColormap
, &win_attr
);
130 /* Set window manager properties */
131 size_hints
= XAllocSizeHints();
132 wm_hints
= XAllocWMHints();
133 class_hints
= XAllocClassHint();
134 if (!size_hints
|| !wm_hints
|| !class_hints
)
136 MESSAGE("Not enough memory for window manager hints.\n" );
139 size_hints
->min_width
= size_hints
->max_width
= width
;
140 size_hints
->min_height
= size_hints
->max_height
= height
;
141 size_hints
->flags
= PMinSize
| PMaxSize
;
142 if (flags
& (XValue
| YValue
)) size_hints
->flags
|= USPosition
;
143 if (flags
& (WidthValue
| HeightValue
)) size_hints
->flags
|= USSize
;
144 else size_hints
->flags
|= PSize
;
146 wm_hints
->flags
= InputHint
| StateHint
;
147 wm_hints
->input
= True
;
148 wm_hints
->initial_state
= NormalState
;
149 class_hints
->res_name
= "wine";
150 class_hints
->res_class
= "Wine";
152 XStringListToTextProperty( &name
, 1, &window_name
);
153 XSetWMProperties( display
, win
, &window_name
, &window_name
,
154 NULL
, 0, size_hints
, wm_hints
, class_hints
);
157 XFree( class_hints
);