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 WIN_ReleaseWndPtr( win );
60 SetWindowLongW( hwnd, GWL_WNDPROC, (LONG)desktop_winproc );
61 X11DRV_register_window( display, hwnd, root_window );
62 TSXMapWindow( display, root_window );
64 while (GetMessageW( &msg, hwnd, 0, 0 )) DispatchMessageW( &msg );
69 /***********************************************************************
70 * X11DRV_create_desktop_thread
72 * Create the thread that manages the desktop window
74 void X11DRV_create_desktop_thread(void)
76 HANDLE handle = CreateThread( NULL, 0, desktop_thread, NtCurrentTeb()->driver_data, 0, NULL );
79 MESSAGE( "Could not create desktop thread\n" );
82 /* we transferred our driver data to the new thread */
83 NtCurrentTeb()->driver_data = NULL;
84 CloseHandle( handle );
88 /***********************************************************************
89 * X11DRV_create_desktop
91 * Create the X11 desktop window for the desktop mode.
93 Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry )
95 int x = 0, y = 0, flags;
96 unsigned int width = 640, height = 480; /* Default size = 640x480 */
97 char *name = "Wine desktop";
98 XSizeHints *size_hints;
100 XClassHint *class_hints;
101 XSetWindowAttributes win_attr;
102 XTextProperty window_name;
104 Display *display = thread_display();
107 flags = XParseGeometry( geometry, &x, &y, &width, &height );
108 screen_width = width;
109 screen_height = height;
112 win_attr.background_pixel = BlackPixel(display, 0);
113 win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
114 PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
115 win_attr.cursor = XCreateFontCursor( display, XC_top_left_arrow );
118 win_attr.colormap = XCreateColormap( display, DefaultRootWindow(display),
121 win_attr.colormap = None;
123 win = XCreateWindow( display, DefaultRootWindow(display),
124 x, y, width, height, 0, screen_depth, InputOutput, visual,
125 CWBackPixel | CWEventMask | CWCursor | CWColormap, &win_attr );
127 /* Set window manager properties */
128 size_hints = XAllocSizeHints();
129 wm_hints = XAllocWMHints();
130 class_hints = XAllocClassHint();
131 if (!size_hints || !wm_hints || !class_hints)
133 MESSAGE("Not enough memory for window manager hints.\n" );
136 size_hints->min_width = size_hints->max_width = width;
137 size_hints->min_height = size_hints->max_height = height;
138 size_hints->flags = PMinSize | PMaxSize;
139 if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
140 if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
141 else size_hints->flags |= PSize;
143 wm_hints->flags = InputHint | StateHint;
144 wm_hints->input = True;
145 wm_hints->initial_state = NormalState;
146 class_hints->res_name = "wine";
147 class_hints->res_class = "Wine";
149 XStringListToTextProperty( &name, 1, &window_name );
150 XSetWMProperties( display, win, &window_name, &window_name,
151 NULL, 0, size_hints, wm_hints, class_hints );
154 XFree( class_hints );