2 * X11DRV desktop window handling
4 * Copyright 2001 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <X11/cursorfont.h>
26 #include "wine/winuser16.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(x11drv
);
34 /* desktop window procedure */
35 static LRESULT WINAPI
desktop_winproc( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
40 PaintDesktop( (HDC
)wParam
);
41 ValidateRect( hwnd
, NULL
);
45 if ((wParam
& 0xfff0) == SC_CLOSE
) ExitWindows( 0, 0 );
49 return (LRESULT
)SetCursor( LoadCursorA( 0, IDC_ARROWA
) );
58 /* desktop window manager thread */
59 static DWORD CALLBACK
desktop_thread( LPVOID driver_data
)
66 NtCurrentTeb()->driver_data
= driver_data
;
67 display
= thread_display();
68 hwnd
= GetDesktopWindow();
70 /* patch the desktop window queue to point to our queue */
71 win
= WIN_GetPtr( hwnd
);
72 win
->tid
= GetCurrentThreadId();
73 win
->hmemTaskQ
= InitThreadInput16( 0, 0 );
74 X11DRV_register_window( display
, hwnd
, win
->pDriverData
);
75 WIN_ReleasePtr( win
);
77 SetWindowLongW( hwnd
, GWL_WNDPROC
, (LONG
)desktop_winproc
);
79 XSetWMProtocols( display
, root_window
, &wmDeleteWindow
, 1 );
80 XMapWindow( display
, root_window
);
83 while (GetMessageW( &msg
, hwnd
, 0, 0 )) DispatchMessageW( &msg
);
88 /***********************************************************************
89 * X11DRV_create_desktop_thread
91 * Create the thread that manages the desktop window
93 void X11DRV_create_desktop_thread(void)
95 HANDLE handle
= CreateThread( NULL
, 0, desktop_thread
, NtCurrentTeb()->driver_data
, 0, NULL
);
98 MESSAGE( "Could not create desktop thread\n" );
101 /* we transferred our driver data to the new thread */
102 NtCurrentTeb()->driver_data
= NULL
;
103 CloseHandle( handle
);
107 /***********************************************************************
108 * X11DRV_create_desktop
110 * Create the X11 desktop window for the desktop mode.
112 Window
X11DRV_create_desktop( XVisualInfo
*desktop_vi
, const char *geometry
)
114 int x
= 0, y
= 0, flags
;
115 unsigned int width
= 640, height
= 480; /* Default size = 640x480 */
116 char *name
= GetCommandLineA();
117 XSizeHints
*size_hints
;
119 XClassHint
*class_hints
;
120 XSetWindowAttributes win_attr
;
121 XTextProperty window_name
;
123 Display
*display
= thread_display();
126 flags
= XParseGeometry( geometry
, &x
, &y
, &width
, &height
);
127 screen_width
= width
;
128 screen_height
= height
;
131 win_attr
.background_pixel
= BlackPixel(display
, 0);
132 win_attr
.event_mask
= ExposureMask
| KeyPressMask
| KeyReleaseMask
|
133 PointerMotionMask
| ButtonPressMask
| ButtonReleaseMask
;
134 win_attr
.cursor
= XCreateFontCursor( display
, XC_top_left_arrow
);
137 win_attr
.colormap
= XCreateColormap( display
, DefaultRootWindow(display
),
140 win_attr
.colormap
= None
;
142 win
= XCreateWindow( display
, DefaultRootWindow(display
),
143 x
, y
, width
, height
, 0, screen_depth
, InputOutput
, visual
,
144 CWBackPixel
| CWEventMask
| CWCursor
| CWColormap
, &win_attr
);
146 /* Set window manager properties */
147 size_hints
= XAllocSizeHints();
148 wm_hints
= XAllocWMHints();
149 class_hints
= XAllocClassHint();
150 if (!size_hints
|| !wm_hints
|| !class_hints
)
152 MESSAGE("Not enough memory for window manager hints.\n" );
155 size_hints
->min_width
= size_hints
->max_width
= width
;
156 size_hints
->min_height
= size_hints
->max_height
= height
;
157 size_hints
->flags
= PMinSize
| PMaxSize
;
158 if (flags
& (XValue
| YValue
)) size_hints
->flags
|= USPosition
;
159 if (flags
& (WidthValue
| HeightValue
)) size_hints
->flags
|= USSize
;
160 else size_hints
->flags
|= PSize
;
162 wm_hints
->flags
= InputHint
| StateHint
;
163 wm_hints
->input
= True
;
164 wm_hints
->initial_state
= NormalState
;
165 class_hints
->res_name
= "wine";
166 class_hints
->res_class
= "Wine";
168 XStringListToTextProperty( &name
, 1, &window_name
);
169 XSetWMProperties( display
, win
, &window_name
, &window_name
,
170 NULL
, 0, size_hints
, wm_hints
, class_hints
);
173 XFree( class_hints
);