2 * X11DRV desktop window handling
4 * Copyright 2001 Alexandre Julliard
8 #include <X11/cursorfont.h>
12 #include "wine/winuser16.h"
15 #include "debugtools.h"
17 DEFAULT_DEBUG_CHANNEL(x11drv);
20 /* desktop window procedure */
21 static LRESULT WINAPI desktop_winproc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
26 PaintDesktop( (HDC)wParam );
27 ValidateRect( hwnd, NULL );
31 if ((wParam & 0xfff0) == SC_CLOSE) ExitWindows( 0, 0 );
35 return SetCursor( LoadCursorA( 0, IDC_ARROWA ) );
44 /* desktop window manager thread */
45 static DWORD CALLBACK desktop_thread( LPVOID driver_data )
52 NtCurrentTeb()->driver_data = driver_data;
53 display = thread_display();
54 hwnd = GetDesktopWindow();
56 /* patch the desktop window queue to point to our queue */
57 win = WIN_FindWndPtr( hwnd );
58 win->tid = GetCurrentThreadId();
59 win->hmemTaskQ = InitThreadInput16( 0, 0 );
60 X11DRV_register_window( display, hwnd, win->pDriverData );
61 WIN_ReleaseWndPtr( win );
63 SetWindowLongW( hwnd, GWL_WNDPROC, (LONG)desktop_winproc );
65 XSetWMProtocols( display, root_window, &wmDeleteWindow, 1 );
66 XMapWindow( display, root_window );
69 while (GetMessageW( &msg, hwnd, 0, 0 )) DispatchMessageW( &msg );
74 /***********************************************************************
75 * X11DRV_create_desktop_thread
77 * Create the thread that manages the desktop window
79 void X11DRV_create_desktop_thread(void)
81 HANDLE handle = CreateThread( NULL, 0, desktop_thread, NtCurrentTeb()->driver_data, 0, NULL );
84 MESSAGE( "Could not create desktop thread\n" );
87 /* we transferred our driver data to the new thread */
88 NtCurrentTeb()->driver_data = NULL;
89 CloseHandle( handle );
93 /***********************************************************************
94 * X11DRV_create_desktop
96 * Create the X11 desktop window for the desktop mode.
98 Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry )
100 int x = 0, y = 0, flags;
101 unsigned int width = 640, height = 480; /* Default size = 640x480 */
102 char *name = "Wine desktop";
103 XSizeHints *size_hints;
105 XClassHint *class_hints;
106 XSetWindowAttributes win_attr;
107 XTextProperty window_name;
109 Display *display = thread_display();
112 flags = XParseGeometry( geometry, &x, &y, &width, &height );
113 screen_width = width;
114 screen_height = height;
117 win_attr.background_pixel = BlackPixel(display, 0);
118 win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
119 PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
120 win_attr.cursor = XCreateFontCursor( display, XC_top_left_arrow );
123 win_attr.colormap = XCreateColormap( display, DefaultRootWindow(display),
126 win_attr.colormap = None;
128 win = XCreateWindow( display, DefaultRootWindow(display),
129 x, y, width, height, 0, screen_depth, InputOutput, visual,
130 CWBackPixel | CWEventMask | CWCursor | CWColormap, &win_attr );
132 /* Set window manager properties */
133 size_hints = XAllocSizeHints();
134 wm_hints = XAllocWMHints();
135 class_hints = XAllocClassHint();
136 if (!size_hints || !wm_hints || !class_hints)
138 MESSAGE("Not enough memory for window manager hints.\n" );
141 size_hints->min_width = size_hints->max_width = width;
142 size_hints->min_height = size_hints->max_height = height;
143 size_hints->flags = PMinSize | PMaxSize;
144 if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
145 if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
146 else size_hints->flags |= PSize;
148 wm_hints->flags = InputHint | StateHint;
149 wm_hints->input = True;
150 wm_hints->initial_state = NormalState;
151 class_hints->res_name = "wine";
152 class_hints->res_class = "Wine";
154 XStringListToTextProperty( &name, 1, &window_name );
155 XSetWMProperties( display, win, &window_name, &window_name,
156 NULL, 0, size_hints, wm_hints, class_hints );
159 XFree( class_hints );