push 421a6d0d1068c98851feb4eb01bb0e754f615ce9
[wine/hacks.git] / dlls / winex11.drv / window.c
blob8364460c5465b6c0092ab7581c5ffbfefedfb023
1 /*
2 * Window related functions
4 * Copyright 1993, 1994, 1995, 1996, 2001 Alexandre Julliard
5 * Copyright 1993 David Metcalfe
6 * Copyright 1995, 1996 Alex Korobka
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
25 #include <stdarg.h>
26 #include <stdlib.h>
27 #include <stdio.h>
28 #ifdef HAVE_UNISTD_H
29 # include <unistd.h>
30 #endif
32 #include <X11/Xlib.h>
33 #include <X11/Xresource.h>
34 #include <X11/Xutil.h>
36 #include "windef.h"
37 #include "winbase.h"
38 #include "wingdi.h"
39 #include "winuser.h"
40 #include "wine/unicode.h"
42 #include "x11drv.h"
43 #include "wine/debug.h"
44 #include "wine/server.h"
45 #include "win.h"
46 #include "mwm.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
50 /* X context to associate a hwnd to an X window */
51 XContext winContext = 0;
53 /* X context to associate a struct x11drv_win_data to an hwnd */
54 static XContext win_data_context;
56 static const char whole_window_prop[] = "__wine_x11_whole_window";
57 static const char icon_window_prop[] = "__wine_x11_icon_window";
58 static const char managed_prop[] = "__wine_x11_managed";
59 static const char visual_id_prop[] = "__wine_x11_visual_id";
61 /* for XDG systray icons */
62 #define SYSTEM_TRAY_REQUEST_DOCK 0
64 /***********************************************************************
65 * is_window_managed
67 * Check if a given window should be managed
69 BOOL is_window_managed( HWND hwnd, const RECT *window_rect )
71 DWORD style, ex_style;
73 /* tray window is always managed */
74 ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
75 if (ex_style & WS_EX_TRAYWINDOW) return TRUE;
76 /* child windows are not managed */
77 style = GetWindowLongW( hwnd, GWL_STYLE );
78 if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD) return FALSE;
79 #ifndef DEFAULTMANAGED
80 /* set to 1 to enable default managed instead of default not managed */
81 #define DEFAULTMANAGED 0
82 #endif
83 if(!DEFAULTMANAGED){
84 /* windows with caption are managed */
85 if ((style & WS_CAPTION) == WS_CAPTION) return TRUE;
86 /* tool windows are not managed */
87 if (ex_style & WS_EX_TOOLWINDOW) return FALSE;
88 /* windows with thick frame are managed */
89 if (style & WS_THICKFRAME) return TRUE;
90 /* application windows are managed */
91 if (ex_style & WS_EX_APPWINDOW) return TRUE;
93 if (style & WS_POPUP)
95 /* popup with sysmenu == caption are managed */
96 if (style & WS_SYSMENU) return TRUE;
97 /* full-screen popup windows are managed */
98 if ((window_rect->right - window_rect->left) == screen_width &&
99 (window_rect->bottom - window_rect->top) == screen_height)
100 return TRUE;
101 if(DEFAULTMANAGED) {
102 /* all other popups are not managed */
103 return FALSE;
106 if(DEFAULTMANAGED) {
107 /* default: managed */
108 return TRUE;
109 } else {
110 /* default: not managed */
111 return FALSE;
117 /***********************************************************************
118 * X11DRV_is_window_rect_mapped
120 * Check if the X whole window should be mapped based on its rectangle
122 BOOL X11DRV_is_window_rect_mapped( const RECT *rect )
124 /* don't map if rect is empty */
125 if (IsRectEmpty( rect )) return FALSE;
127 /* don't map if rect is off-screen */
128 if (rect->left >= virtual_screen_rect.right ||
129 rect->top >= virtual_screen_rect.bottom ||
130 rect->right <= virtual_screen_rect.left ||
131 rect->bottom <= virtual_screen_rect.top)
132 return FALSE;
134 return TRUE;
138 /***********************************************************************
139 * get_window_attributes
141 * Fill the window attributes structure for an X window.
143 static int get_window_attributes( Display *display, struct x11drv_win_data *data,
144 XSetWindowAttributes *attr )
146 attr->override_redirect = !data->managed;
147 attr->colormap = X11DRV_PALETTE_PaletteXColormap;
148 attr->save_under = ((GetClassLongW( data->hwnd, GCL_STYLE ) & CS_SAVEBITS) != 0);
149 attr->cursor = x11drv_thread_data()->cursor;
150 attr->bit_gravity = NorthWestGravity;
151 attr->backing_store = NotUseful;
152 attr->event_mask = (ExposureMask | PointerMotionMask |
153 ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
154 KeyPressMask | KeyReleaseMask | FocusChangeMask | KeymapStateMask);
155 if (data->managed) attr->event_mask |= StructureNotifyMask;
157 return (CWOverrideRedirect | CWSaveUnder | CWColormap | CWCursor |
158 CWEventMask | CWBitGravity | CWBackingStore);
162 /***********************************************************************
163 * X11DRV_sync_window_style
165 * Change the X window attributes when the window style has changed.
167 void X11DRV_sync_window_style( Display *display, struct x11drv_win_data *data )
169 if (data->whole_window != root_window)
171 XSetWindowAttributes attr;
172 int mask = get_window_attributes( display, data, &attr );
174 wine_tsx11_lock();
175 XChangeWindowAttributes( display, data->whole_window, mask, &attr );
176 wine_tsx11_unlock();
181 /***********************************************************************
182 * get_window_changes
184 * fill the window changes structure
186 static int get_window_changes( XWindowChanges *changes, const RECT *old, const RECT *new )
188 int mask = 0;
190 if (old->right - old->left != new->right - new->left )
192 if (!(changes->width = new->right - new->left)) changes->width = 1;
193 mask |= CWWidth;
195 if (old->bottom - old->top != new->bottom - new->top)
197 if (!(changes->height = new->bottom - new->top)) changes->height = 1;
198 mask |= CWHeight;
200 if (old->left != new->left)
202 changes->x = new->left;
203 mask |= CWX;
205 if (old->top != new->top)
207 changes->y = new->top;
208 mask |= CWY;
210 return mask;
214 /***********************************************************************
215 * create_icon_window
217 static Window create_icon_window( Display *display, struct x11drv_win_data *data )
219 XSetWindowAttributes attr;
221 attr.event_mask = (ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask |
222 ButtonPressMask | ButtonReleaseMask | EnterWindowMask);
223 attr.bit_gravity = NorthWestGravity;
224 attr.backing_store = NotUseful/*WhenMapped*/;
225 attr.colormap = X11DRV_PALETTE_PaletteXColormap; /* Needed due to our visual */
227 wine_tsx11_lock();
228 data->icon_window = XCreateWindow( display, root_window, 0, 0,
229 GetSystemMetrics( SM_CXICON ),
230 GetSystemMetrics( SM_CYICON ),
231 0, screen_depth,
232 InputOutput, visual,
233 CWEventMask | CWBitGravity | CWBackingStore | CWColormap, &attr );
234 XSaveContext( display, data->icon_window, winContext, (char *)data->hwnd );
235 wine_tsx11_unlock();
237 TRACE( "created %lx\n", data->icon_window );
238 SetPropA( data->hwnd, icon_window_prop, (HANDLE)data->icon_window );
239 return data->icon_window;
244 /***********************************************************************
245 * destroy_icon_window
247 static void destroy_icon_window( Display *display, struct x11drv_win_data *data )
249 if (!data->icon_window) return;
250 if (x11drv_thread_data()->cursor_window == data->icon_window)
251 x11drv_thread_data()->cursor_window = None;
252 wine_tsx11_lock();
253 XDeleteContext( display, data->icon_window, winContext );
254 XDestroyWindow( display, data->icon_window );
255 data->icon_window = 0;
256 wine_tsx11_unlock();
257 RemovePropA( data->hwnd, icon_window_prop );
261 /***********************************************************************
262 * set_icon_hints
264 * Set the icon wm hints
266 static void set_icon_hints( Display *display, struct x11drv_win_data *data, HICON hIcon )
268 XWMHints *hints = data->wm_hints;
270 if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap );
271 if (data->hWMIconMask) DeleteObject( data->hWMIconMask);
272 data->hWMIconBitmap = 0;
273 data->hWMIconMask = 0;
275 if (!data->managed)
277 destroy_icon_window( display, data );
278 hints->flags &= ~(IconPixmapHint | IconMaskHint | IconWindowHint);
280 else if (!hIcon)
282 if (!data->icon_window) create_icon_window( display, data );
283 hints->icon_window = data->icon_window;
284 hints->flags = (hints->flags & ~(IconPixmapHint | IconMaskHint)) | IconWindowHint;
286 else
288 HBITMAP hbmOrig;
289 RECT rcMask;
290 BITMAP bmMask;
291 ICONINFO ii;
292 HDC hDC;
294 GetIconInfo(hIcon, &ii);
296 GetObjectA(ii.hbmMask, sizeof(bmMask), &bmMask);
297 rcMask.top = 0;
298 rcMask.left = 0;
299 rcMask.right = bmMask.bmWidth;
300 rcMask.bottom = bmMask.bmHeight;
302 hDC = CreateCompatibleDC(0);
303 hbmOrig = SelectObject(hDC, ii.hbmMask);
304 InvertRect(hDC, &rcMask);
305 SelectObject(hDC, ii.hbmColor); /* force the color bitmap to x11drv mode too */
306 SelectObject(hDC, hbmOrig);
307 DeleteDC(hDC);
309 data->hWMIconBitmap = ii.hbmColor;
310 data->hWMIconMask = ii.hbmMask;
312 hints->icon_pixmap = X11DRV_get_pixmap(data->hWMIconBitmap);
313 hints->icon_mask = X11DRV_get_pixmap(data->hWMIconMask);
314 destroy_icon_window( display, data );
315 hints->flags = (hints->flags & ~IconWindowHint) | IconPixmapHint | IconMaskHint;
319 /***********************************************************************
320 * systray_dock_window
322 * Docks the given X window with the NETWM system tray.
324 static void systray_dock_window( Display *display, struct x11drv_win_data *data )
326 static Atom systray_atom;
327 Window systray_window;
329 wine_tsx11_lock();
330 if (!systray_atom)
332 if (DefaultScreen( display ) == 0)
333 systray_atom = x11drv_atom(_NET_SYSTEM_TRAY_S0);
334 else
336 char systray_buffer[29]; /* strlen(_NET_SYSTEM_TRAY_S4294967295)+1 */
337 sprintf( systray_buffer, "_NET_SYSTEM_TRAY_S%u", DefaultScreen( display ) );
338 systray_atom = XInternAtom( display, systray_buffer, False );
341 systray_window = XGetSelectionOwner( display, systray_atom );
342 wine_tsx11_unlock();
344 TRACE("Docking tray icon %p\n", data->hwnd);
346 if (systray_window != None)
348 XEvent ev;
349 unsigned long info[2];
351 /* Put the window offscreen so it isn't mapped. The window _cannot_ be
352 * mapped if we intend to dock with an XEMBED tray. If the window is
353 * mapped when we dock, it may become visible as a child of the root
354 * window after it docks, which isn't the proper behavior.
356 * For more information on this problem, see
357 * http://standards.freedesktop.org/xembed-spec/latest/ar01s04.html */
359 SetWindowPos( data->hwnd, NULL, virtual_screen_rect.right + 1, virtual_screen_rect.bottom + 1,
360 0, 0, SWP_NOZORDER | SWP_NOSIZE );
362 /* set XEMBED protocol data on the window */
363 info[0] = 0; /* protocol version */
364 info[1] = 1; /* mapped = true */
366 wine_tsx11_lock();
367 XChangeProperty( display, data->whole_window,
368 x11drv_atom(_XEMBED_INFO),
369 x11drv_atom(_XEMBED_INFO), 32, PropModeReplace,
370 (unsigned char*)info, 2 );
371 wine_tsx11_unlock();
373 /* send the docking request message */
374 ZeroMemory( &ev, sizeof(ev) );
375 ev.xclient.type = ClientMessage;
376 ev.xclient.window = systray_window;
377 ev.xclient.message_type = x11drv_atom( _NET_SYSTEM_TRAY_OPCODE );
378 ev.xclient.format = 32;
379 ev.xclient.data.l[0] = CurrentTime;
380 ev.xclient.data.l[1] = SYSTEM_TRAY_REQUEST_DOCK;
381 ev.xclient.data.l[2] = data->whole_window;
382 ev.xclient.data.l[3] = 0;
383 ev.xclient.data.l[4] = 0;
385 wine_tsx11_lock();
386 XSendEvent( display, systray_window, False, NoEventMask, &ev );
387 wine_tsx11_unlock();
390 else
392 int val = 1;
394 /* fall back to he KDE hints if the WM doesn't support XEMBED'ed
395 * systrays */
397 wine_tsx11_lock();
398 XChangeProperty( display, data->whole_window,
399 x11drv_atom(KWM_DOCKWINDOW),
400 x11drv_atom(KWM_DOCKWINDOW), 32, PropModeReplace,
401 (unsigned char*)&val, 1 );
402 XChangeProperty( display, data->whole_window,
403 x11drv_atom(_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR),
404 XA_WINDOW, 32, PropModeReplace,
405 (unsigned char*)&data->whole_window, 1 );
406 wine_tsx11_unlock();
411 /***********************************************************************
412 * set_size_hints
414 * set the window size hints
416 static void set_size_hints( Display *display, struct x11drv_win_data *data, DWORD style )
418 XSizeHints* size_hints;
420 if ((size_hints = XAllocSizeHints()))
422 size_hints->flags = 0;
424 if (data->hwnd != GetDesktopWindow()) /* don't force position of desktop */
426 size_hints->win_gravity = StaticGravity;
427 size_hints->x = data->whole_rect.left;
428 size_hints->y = data->whole_rect.top;
429 size_hints->flags |= PWinGravity | PPosition;
432 if ( !(style & WS_THICKFRAME) )
434 size_hints->max_width = data->whole_rect.right - data->whole_rect.left;
435 size_hints->max_height = data->whole_rect.bottom - data->whole_rect.top;
436 size_hints->min_width = size_hints->max_width;
437 size_hints->min_height = size_hints->max_height;
438 size_hints->flags |= PMinSize | PMaxSize;
440 XSetWMNormalHints( display, data->whole_window, size_hints );
441 XFree( size_hints );
446 /***********************************************************************
447 * get_process_name
449 * get the name of the current process for setting class hints
451 static char *get_process_name(void)
453 static char *name;
455 if (!name)
457 WCHAR module[MAX_PATH];
458 DWORD len = GetModuleFileNameW( 0, module, MAX_PATH );
459 if (len && len < MAX_PATH)
461 char *ptr;
462 WCHAR *p, *appname = module;
464 if ((p = strrchrW( appname, '/' ))) appname = p + 1;
465 if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
466 len = WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, NULL, 0, NULL, NULL );
467 if ((ptr = HeapAlloc( GetProcessHeap(), 0, len )))
469 WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, ptr, len, NULL, NULL );
470 name = ptr;
474 return name;
478 /***********************************************************************
479 * set_initial_wm_hints
481 * Set the window manager hints that don't change over the lifetime of a window.
483 static void set_initial_wm_hints( Display *display, struct x11drv_win_data *data )
485 int i;
486 Atom protocols[3];
487 Atom dndVersion = 4;
488 XClassHint *class_hints;
489 char *process_name = get_process_name();
491 wine_tsx11_lock();
493 /* wm protocols */
494 i = 0;
495 protocols[i++] = x11drv_atom(WM_DELETE_WINDOW);
496 protocols[i++] = x11drv_atom(_NET_WM_PING);
497 if (use_take_focus) protocols[i++] = x11drv_atom(WM_TAKE_FOCUS);
498 XChangeProperty( display, data->whole_window, x11drv_atom(WM_PROTOCOLS),
499 XA_ATOM, 32, PropModeReplace, (unsigned char *)protocols, i );
501 /* class hints */
502 if ((class_hints = XAllocClassHint()))
504 static char wine[] = "Wine";
506 class_hints->res_name = process_name;
507 class_hints->res_class = wine;
508 XSetClassHint( display, data->whole_window, class_hints );
509 XFree( class_hints );
512 /* set the WM_CLIENT_MACHINE and WM_LOCALE_NAME properties */
513 XSetWMProperties(display, data->whole_window, NULL, NULL, NULL, 0, NULL, NULL, NULL);
514 /* set the pid. together, these properties are needed so the window manager can kill us if we freeze */
515 i = getpid();
516 XChangeProperty(display, data->whole_window, x11drv_atom(_NET_WM_PID),
517 XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&i, 1);
519 XChangeProperty( display, data->whole_window, x11drv_atom(XdndAware),
520 XA_ATOM, 32, PropModeReplace, (unsigned char*)&dndVersion, 1 );
522 wine_tsx11_unlock();
526 /***********************************************************************
527 * X11DRV_set_wm_hints
529 * Set the window manager hints for a newly-created window
531 void X11DRV_set_wm_hints( Display *display, struct x11drv_win_data *data )
533 Window group_leader;
534 Atom window_type;
535 MwmHints mwm_hints;
536 DWORD style = GetWindowLongW( data->hwnd, GWL_STYLE );
537 DWORD ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
538 HWND owner = GetWindow( data->hwnd, GW_OWNER );
540 if (data->hwnd == GetDesktopWindow())
542 if (data->whole_window == DefaultRootWindow(display)) return;
543 /* force some styles for the desktop to get the correct decorations */
544 style |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
545 owner = 0;
548 /* transient for hint */
549 if (owner)
551 Window owner_win = X11DRV_get_whole_window( owner );
552 wine_tsx11_lock();
553 XSetTransientForHint( display, data->whole_window, owner_win );
554 wine_tsx11_unlock();
555 group_leader = owner_win;
557 else group_leader = data->whole_window;
559 wine_tsx11_lock();
561 /* size hints */
562 set_size_hints( display, data, style );
564 /* set the WM_WINDOW_TYPE */
565 window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_NORMAL);
566 if (ex_style & WS_EX_TOOLWINDOW) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_UTILITY);
567 else if (style & WS_THICKFRAME) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_NORMAL);
568 else if (style & WS_DLGFRAME) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_DIALOG);
569 else if (ex_style & WS_EX_DLGMODALFRAME) window_type = x11drv_atom(_NET_WM_WINDOW_TYPE_DIALOG);
571 XChangeProperty(display, data->whole_window, x11drv_atom(_NET_WM_WINDOW_TYPE),
572 XA_ATOM, 32, PropModeReplace, (unsigned char*)&window_type, 1);
574 mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
575 mwm_hints.functions = MWM_FUNC_MOVE;
576 if (style & WS_THICKFRAME) mwm_hints.functions |= MWM_FUNC_RESIZE;
577 if (style & WS_MINIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MINIMIZE;
578 if (style & WS_MAXIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MAXIMIZE;
579 if (style & WS_SYSMENU) mwm_hints.functions |= MWM_FUNC_CLOSE;
580 mwm_hints.decorations = 0;
581 if ((style & WS_CAPTION) == WS_CAPTION)
583 mwm_hints.decorations |= MWM_DECOR_TITLE;
584 if (style & WS_SYSMENU) mwm_hints.decorations |= MWM_DECOR_MENU;
585 if (style & WS_MINIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MINIMIZE;
586 if (style & WS_MAXIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MAXIMIZE;
588 if (ex_style & WS_EX_DLGMODALFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER;
589 else if (style & WS_THICKFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER | MWM_DECOR_RESIZEH;
590 else if ((style & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER;
591 else if (style & WS_BORDER) mwm_hints.decorations |= MWM_DECOR_BORDER;
592 else if (!(style & (WS_CHILD|WS_POPUP))) mwm_hints.decorations |= MWM_DECOR_BORDER;
594 XChangeProperty( display, data->whole_window, x11drv_atom(_MOTIF_WM_HINTS),
595 x11drv_atom(_MOTIF_WM_HINTS), 32, PropModeReplace,
596 (unsigned char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
598 wine_tsx11_unlock();
600 /* wm hints */
601 if (data->wm_hints)
603 data->wm_hints->flags = InputHint | StateHint | WindowGroupHint;
604 data->wm_hints->input = !(style & WS_DISABLED);
605 data->wm_hints->initial_state = (style & WS_MINIMIZE) ? IconicState : NormalState;
606 data->wm_hints->window_group = group_leader;
607 set_icon_hints( display, data, (HICON)GetClassLongPtrW( data->hwnd, GCLP_HICON ) );
609 wine_tsx11_lock();
610 XSetWMHints( display, data->whole_window, data->wm_hints );
611 wine_tsx11_unlock();
616 /***********************************************************************
617 * X11DRV_set_iconic_state
619 * Set the X11 iconic state according to the window style.
621 void X11DRV_set_iconic_state( HWND hwnd )
623 Display *display = thread_display();
624 struct x11drv_win_data *data;
625 RECT rect;
626 DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
627 BOOL iconic = (style & WS_MINIMIZE) != 0;
629 if (!(data = X11DRV_get_win_data( hwnd ))) return;
630 if (!data->whole_window || data->whole_window == DefaultRootWindow(display)) return;
632 GetWindowRect( hwnd, &rect );
634 wine_tsx11_lock();
636 if (data->wm_hints)
638 data->wm_hints->flags |= StateHint | IconPositionHint;
639 data->wm_hints->initial_state = iconic ? IconicState : NormalState;
640 data->wm_hints->icon_x = rect.left - virtual_screen_rect.left;
641 data->wm_hints->icon_y = rect.top - virtual_screen_rect.top;
642 XSetWMHints( display, data->whole_window, data->wm_hints );
645 if (style & WS_VISIBLE)
647 if (iconic)
648 XIconifyWindow( display, data->whole_window, DefaultScreen(display) );
649 else
650 if (X11DRV_is_window_rect_mapped( &rect ))
651 XMapWindow( display, data->whole_window );
654 wine_tsx11_unlock();
658 /***********************************************************************
659 * X11DRV_window_to_X_rect
661 * Convert a rect from client to X window coordinates
663 void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect )
665 RECT rc;
667 if (!data->managed) return;
668 if (IsRectEmpty( rect )) return;
670 rc.top = rc.bottom = rc.left = rc.right = 0;
672 AdjustWindowRectEx( &rc, GetWindowLongW( data->hwnd, GWL_STYLE ) & ~(WS_HSCROLL|WS_VSCROLL),
673 FALSE, GetWindowLongW( data->hwnd, GWL_EXSTYLE ) );
675 rect->left -= rc.left;
676 rect->right -= rc.right;
677 rect->top -= rc.top;
678 rect->bottom -= rc.bottom;
679 if (rect->top >= rect->bottom) rect->bottom = rect->top + 1;
680 if (rect->left >= rect->right) rect->right = rect->left + 1;
684 /***********************************************************************
685 * X11DRV_X_to_window_rect
687 * Opposite of X11DRV_window_to_X_rect
689 void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect )
691 if (!data->managed) return;
692 if (IsRectEmpty( rect )) return;
694 AdjustWindowRectEx( rect, GetWindowLongW( data->hwnd, GWL_STYLE ) & ~(WS_HSCROLL|WS_VSCROLL),
695 FALSE, GetWindowLongW( data->hwnd, GWL_EXSTYLE ));
697 if (rect->top >= rect->bottom) rect->bottom = rect->top + 1;
698 if (rect->left >= rect->right) rect->right = rect->left + 1;
702 /***********************************************************************
703 * X11DRV_sync_window_position
705 * Synchronize the X window position with the Windows one
707 void X11DRV_sync_window_position( Display *display, struct x11drv_win_data *data,
708 UINT swp_flags, const RECT *new_client_rect,
709 const RECT *new_whole_rect )
711 XWindowChanges changes;
712 int mask;
713 RECT old_whole_rect;
715 old_whole_rect = data->whole_rect;
716 data->whole_rect = *new_whole_rect;
718 data->client_rect = *new_client_rect;
719 OffsetRect( &data->client_rect, -data->whole_rect.left, -data->whole_rect.top );
721 if (!data->whole_window || data->lock_changes) return;
723 mask = get_window_changes( &changes, &old_whole_rect, &data->whole_rect );
725 if (!(swp_flags & SWP_NOZORDER))
727 /* find window that this one must be after */
728 HWND prev = GetWindow( data->hwnd, GW_HWNDPREV );
729 while (prev && !(GetWindowLongW( prev, GWL_STYLE ) & WS_VISIBLE))
730 prev = GetWindow( prev, GW_HWNDPREV );
731 if (!prev) /* top child */
733 changes.stack_mode = Above;
734 mask |= CWStackMode;
736 else
738 /* should use stack_mode Below but most window managers don't get it right */
739 /* so move it above the next one in Z order */
740 HWND next = GetWindow( data->hwnd, GW_HWNDNEXT );
741 while (next && !(GetWindowLongW( next, GWL_STYLE ) & WS_VISIBLE))
742 next = GetWindow( next, GW_HWNDNEXT );
743 if (next)
745 changes.stack_mode = Above;
746 changes.sibling = X11DRV_get_whole_window(next);
747 mask |= CWStackMode | CWSibling;
752 if (mask)
754 DWORD style = GetWindowLongW( data->hwnd, GWL_STYLE );
756 TRACE( "setting win %lx pos %d,%d,%dx%d after %lx changes=%x\n",
757 data->whole_window, data->whole_rect.left, data->whole_rect.top,
758 data->whole_rect.right - data->whole_rect.left,
759 data->whole_rect.bottom - data->whole_rect.top, changes.sibling, mask );
761 wine_tsx11_lock();
762 if (mask & (CWWidth|CWHeight)) set_size_hints( display, data, style );
763 if (mask & CWX) changes.x -= virtual_screen_rect.left;
764 if (mask & CWY) changes.y -= virtual_screen_rect.top;
765 XReconfigureWMWindow( display, data->whole_window,
766 DefaultScreen(display), mask, &changes );
767 wine_tsx11_unlock();
772 /**********************************************************************
773 * create_whole_window
775 * Create the whole X window for a given window
777 static Window create_whole_window( Display *display, struct x11drv_win_data *data, DWORD style )
779 int cx, cy, mask;
780 XSetWindowAttributes attr;
781 XIM xim;
783 if (!(cx = data->window_rect.right - data->window_rect.left)) cx = 1;
784 if (!(cy = data->window_rect.bottom - data->window_rect.top)) cy = 1;
786 mask = get_window_attributes( display, data, &attr );
788 wine_tsx11_lock();
790 data->whole_rect = data->window_rect;
791 data->whole_window = XCreateWindow( display, root_window,
792 data->window_rect.left - virtual_screen_rect.left,
793 data->window_rect.top - virtual_screen_rect.top,
794 cx, cy, 0, screen_depth, InputOutput,
795 visual, mask, &attr );
797 if (!data->whole_window)
799 wine_tsx11_unlock();
800 return 0;
802 XSaveContext( display, data->whole_window, winContext, (char *)data->hwnd );
804 /* non-maximized child must be at bottom of Z order */
805 if ((style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
807 XWindowChanges changes;
808 changes.stack_mode = Below;
809 XConfigureWindow( display, data->whole_window, CWStackMode, &changes );
811 wine_tsx11_unlock();
813 xim = x11drv_thread_data()->xim;
814 if (xim) data->xic = X11DRV_CreateIC( xim, display, data->whole_window );
816 set_initial_wm_hints( display, data );
817 X11DRV_set_wm_hints( display, data );
819 SetPropA( data->hwnd, whole_window_prop, (HANDLE)data->whole_window );
820 return data->whole_window;
824 /**********************************************************************
825 * destroy_whole_window
827 * Destroy the whole X window for a given window.
829 static void destroy_whole_window( Display *display, struct x11drv_win_data *data )
831 struct x11drv_thread_data *thread_data = x11drv_thread_data();
833 if (!data->whole_window) return;
835 TRACE( "win %p xwin %lx\n", data->hwnd, data->whole_window );
836 if (thread_data->cursor_window == data->whole_window) thread_data->cursor_window = None;
837 wine_tsx11_lock();
838 XDeleteContext( display, data->whole_window, winContext );
839 if (data->whole_window != DefaultRootWindow(display))
840 XDestroyWindow( display, data->whole_window );
841 data->whole_window = 0;
842 if (data->xic)
844 XUnsetICFocus( data->xic );
845 XDestroyIC( data->xic );
847 /* Outlook stops processing messages after destroying a dialog, so we need an explicit flush */
848 XFlush( display );
849 wine_tsx11_unlock();
850 RemovePropA( data->hwnd, whole_window_prop );
854 /*****************************************************************
855 * SetWindowText (X11DRV.@)
857 void X11DRV_SetWindowText( HWND hwnd, LPCWSTR text )
859 Display *display = thread_display();
860 UINT count;
861 char *buffer;
862 char *utf8_buffer;
863 Window win;
864 XTextProperty prop;
866 if ((win = X11DRV_get_whole_window( hwnd )) && win != DefaultRootWindow(display))
868 /* allocate new buffer for window text */
869 count = WideCharToMultiByte(CP_UNIXCP, 0, text, -1, NULL, 0, NULL, NULL);
870 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, count )))
872 ERR("Not enough memory for window text\n");
873 return;
875 WideCharToMultiByte(CP_UNIXCP, 0, text, -1, buffer, count, NULL, NULL);
877 count = WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), NULL, 0, NULL, NULL);
878 if (!(utf8_buffer = HeapAlloc( GetProcessHeap(), 0, count )))
880 ERR("Not enough memory for window text in UTF-8\n");
881 HeapFree( GetProcessHeap(), 0, buffer );
882 return;
884 WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), utf8_buffer, count, NULL, NULL);
886 wine_tsx11_lock();
887 if (XmbTextListToTextProperty( display, &buffer, 1, XStdICCTextStyle, &prop ) == Success)
889 XSetWMName( display, win, &prop );
890 XSetWMIconName( display, win, &prop );
891 XFree( prop.value );
894 Implements a NET_WM UTF-8 title. It should be without a trailing \0,
895 according to the standard
896 ( http://www.pps.jussieu.fr/~jch/software/UTF8_STRING/UTF8_STRING.text ).
898 XChangeProperty( display, win, x11drv_atom(_NET_WM_NAME), x11drv_atom(UTF8_STRING),
899 8, PropModeReplace, (unsigned char *) utf8_buffer, count);
900 wine_tsx11_unlock();
902 HeapFree( GetProcessHeap(), 0, utf8_buffer );
903 HeapFree( GetProcessHeap(), 0, buffer );
908 /***********************************************************************
909 * DestroyWindow (X11DRV.@)
911 void X11DRV_DestroyWindow( HWND hwnd )
913 struct x11drv_thread_data *thread_data = x11drv_thread_data();
914 Display *display = thread_data->display;
915 struct x11drv_win_data *data;
917 if (!(data = X11DRV_get_win_data( hwnd ))) return;
919 free_window_dce( data );
920 destroy_whole_window( display, data );
921 destroy_icon_window( display, data );
923 if (thread_data->last_focus == hwnd) thread_data->last_focus = 0;
924 if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap );
925 if (data->hWMIconMask) DeleteObject( data->hWMIconMask);
926 wine_tsx11_lock();
927 XDeleteContext( display, (XID)hwnd, win_data_context );
928 XFree( data->wm_hints );
929 wine_tsx11_unlock();
930 HeapFree( GetProcessHeap(), 0, data );
934 static struct x11drv_win_data *alloc_win_data( Display *display, HWND hwnd )
936 struct x11drv_win_data *data;
938 if ((data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data))))
940 data->hwnd = hwnd;
941 data->whole_window = 0;
942 data->icon_window = 0;
943 data->xic = 0;
944 data->managed = FALSE;
945 data->dce = NULL;
946 data->lock_changes = 0;
947 data->hWMIconBitmap = 0;
948 data->hWMIconMask = 0;
950 wine_tsx11_lock();
951 if (!winContext) winContext = XUniqueContext();
952 if (!win_data_context) win_data_context = XUniqueContext();
953 XSaveContext( display, (XID)hwnd, win_data_context, (char *)data );
954 data->wm_hints = XAllocWMHints();
955 wine_tsx11_unlock();
957 return data;
961 /* fill in the desktop X window id in the x11drv_win_data structure */
962 static void get_desktop_xwin( Display *display, struct x11drv_win_data *data )
964 Window win = (Window)GetPropA( data->hwnd, whole_window_prop );
966 if (win)
968 unsigned int width, height;
970 /* retrieve the real size of the desktop */
971 SERVER_START_REQ( get_window_rectangles )
973 req->handle = data->hwnd;
974 wine_server_call( req );
975 width = reply->window.right - reply->window.left;
976 height = reply->window.bottom - reply->window.top;
978 SERVER_END_REQ;
979 data->whole_window = win;
980 if (win != root_window) X11DRV_init_desktop( win, width, height );
982 else
984 VisualID visualid;
986 wine_tsx11_lock();
987 visualid = XVisualIDFromVisual(visual);
988 wine_tsx11_unlock();
989 SetPropA( data->hwnd, whole_window_prop, (HANDLE)root_window );
990 SetPropA( data->hwnd, visual_id_prop, (HANDLE)visualid );
991 data->whole_window = root_window;
992 X11DRV_SetWindowPos( data->hwnd, 0, &virtual_screen_rect, &virtual_screen_rect,
993 SWP_NOZORDER | SWP_NOACTIVATE, NULL );
994 if (root_window != DefaultRootWindow( display ))
996 data->managed = TRUE;
997 SetPropA( data->hwnd, managed_prop, (HANDLE)1 );
1002 /**********************************************************************
1003 * CreateDesktopWindow (X11DRV.@)
1005 BOOL X11DRV_CreateDesktopWindow( HWND hwnd )
1007 Display *display = thread_display();
1008 struct x11drv_win_data *data;
1010 if (!(data = alloc_win_data( display, hwnd ))) return FALSE;
1012 get_desktop_xwin( display, data );
1014 return TRUE;
1018 /**********************************************************************
1019 * CreateWindow (X11DRV.@)
1021 BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
1023 Display *display = thread_display();
1024 WND *wndPtr;
1025 struct x11drv_win_data *data;
1026 HWND insert_after;
1027 RECT rect;
1028 DWORD style;
1029 CBT_CREATEWNDA cbtc;
1030 CREATESTRUCTA cbcs;
1031 BOOL ret = FALSE;
1033 if (!(data = alloc_win_data( display, hwnd ))) return FALSE;
1035 if (cs->cx > 65535)
1037 ERR( "invalid window width %d\n", cs->cx );
1038 cs->cx = 65535;
1040 if (cs->cy > 65535)
1042 ERR( "invalid window height %d\n", cs->cy );
1043 cs->cy = 65535;
1045 if (cs->cx < 0)
1047 ERR( "invalid window width %d\n", cs->cx );
1048 cs->cx = 0;
1050 if (cs->cy < 0)
1052 ERR( "invalid window height %d\n", cs->cy );
1053 cs->cy = 0;
1056 /* initialize the dimensions before sending WM_GETMINMAXINFO */
1057 SetRect( &rect, cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy );
1058 X11DRV_SetWindowPos( hwnd, 0, &rect, &rect, SWP_NOZORDER | SWP_NOACTIVATE, NULL );
1060 /* create an X window if it's a top level window */
1061 if (GetAncestor( hwnd, GA_PARENT ) == GetDesktopWindow())
1063 if (!create_whole_window( display, data, cs->style )) goto failed;
1065 else if (hwnd == GetDesktopWindow())
1067 get_desktop_xwin( display, data );
1070 /* get class or window DC if needed */
1071 alloc_window_dce( data );
1073 /* Call the WH_CBT hook */
1075 /* the window style passed to the hook must be the real window style,
1076 * rather than just the window style that the caller to CreateWindowEx
1077 * passed in, so we have to copy the original CREATESTRUCT and get the
1078 * the real style. */
1079 cbcs = *cs;
1080 cbcs.style = GetWindowLongW(hwnd, GWL_STYLE);
1082 cbtc.lpcs = &cbcs;
1083 cbtc.hwndInsertAfter = HWND_TOP;
1084 if (HOOK_CallHooks( WH_CBT, HCBT_CREATEWND, (WPARAM)hwnd, (LPARAM)&cbtc, unicode ))
1086 TRACE("CBT-hook returned !0\n");
1087 goto failed;
1090 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
1091 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
1093 POINT maxSize, maxPos, minTrack, maxTrack;
1095 WINPOS_GetMinMaxInfo( hwnd, &maxSize, &maxPos, &minTrack, &maxTrack);
1096 if (maxTrack.x < cs->cx) cs->cx = maxTrack.x;
1097 if (maxTrack.y < cs->cy) cs->cy = maxTrack.y;
1098 if (cs->cx < 0) cs->cx = 0;
1099 if (cs->cy < 0) cs->cy = 0;
1101 SetRect( &rect, cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy );
1102 if (!X11DRV_SetWindowPos( hwnd, 0, &rect, &rect, SWP_NOZORDER | SWP_NOACTIVATE, NULL ))
1103 return FALSE;
1106 /* send WM_NCCREATE */
1107 TRACE( "hwnd %p cs %d,%d %dx%d\n", hwnd, cs->x, cs->y, cs->cx, cs->cy );
1108 if (unicode)
1109 ret = SendMessageW( hwnd, WM_NCCREATE, 0, (LPARAM)cs );
1110 else
1111 ret = SendMessageA( hwnd, WM_NCCREATE, 0, (LPARAM)cs );
1112 if (!ret)
1114 WARN("aborted by WM_xxCREATE!\n");
1115 return FALSE;
1118 /* make sure the window is still valid */
1119 if (!(data = X11DRV_get_win_data( hwnd ))) return FALSE;
1120 if (data->whole_window) X11DRV_sync_window_style( display, data );
1122 /* send WM_NCCALCSIZE */
1123 rect = data->window_rect;
1124 SendMessageW( hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rect );
1126 if (!(wndPtr = WIN_GetPtr(hwnd))) return FALSE;
1128 /* yes, even if the CBT hook was called with HWND_TOP */
1129 insert_after = (wndPtr->dwStyle & WS_CHILD) ? HWND_BOTTOM : HWND_TOP;
1131 X11DRV_SetWindowPos( hwnd, insert_after, &wndPtr->rectWindow, &rect, SWP_NOACTIVATE, NULL );
1133 TRACE( "win %p window %d,%d,%d,%d client %d,%d,%d,%d whole %d,%d,%d,%d X client %d,%d,%d,%d xwin %x\n",
1134 hwnd, wndPtr->rectWindow.left, wndPtr->rectWindow.top,
1135 wndPtr->rectWindow.right, wndPtr->rectWindow.bottom,
1136 wndPtr->rectClient.left, wndPtr->rectClient.top,
1137 wndPtr->rectClient.right, wndPtr->rectClient.bottom,
1138 data->whole_rect.left, data->whole_rect.top,
1139 data->whole_rect.right, data->whole_rect.bottom,
1140 data->client_rect.left, data->client_rect.top,
1141 data->client_rect.right, data->client_rect.bottom,
1142 (unsigned int)data->whole_window );
1144 WIN_ReleasePtr( wndPtr );
1146 if (unicode)
1147 ret = (SendMessageW( hwnd, WM_CREATE, 0, (LPARAM)cs ) != -1);
1148 else
1149 ret = (SendMessageA( hwnd, WM_CREATE, 0, (LPARAM)cs ) != -1);
1151 if (!ret) return FALSE;
1153 NotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_WINDOW, 0);
1155 /* Send the size messages */
1157 if (!(wndPtr = WIN_GetPtr(hwnd)) || wndPtr == WND_OTHER_PROCESS) return FALSE;
1158 if (!(wndPtr->flags & WIN_NEED_SIZE))
1160 RECT rect = wndPtr->rectClient;
1161 WIN_ReleasePtr( wndPtr );
1162 /* send it anyway */
1163 if (((rect.right-rect.left) <0) ||((rect.bottom-rect.top)<0))
1164 WARN("sending bogus WM_SIZE message 0x%08x\n",
1165 MAKELONG(rect.right-rect.left, rect.bottom-rect.top));
1166 SendMessageW( hwnd, WM_SIZE, SIZE_RESTORED,
1167 MAKELONG(rect.right-rect.left, rect.bottom-rect.top));
1168 SendMessageW( hwnd, WM_MOVE, 0, MAKELONG( rect.left, rect.top ) );
1170 else WIN_ReleasePtr( wndPtr );
1172 /* Show the window, maximizing or minimizing if needed */
1174 style = GetWindowLongW( hwnd, GWL_STYLE );
1175 if (style & (WS_MINIMIZE | WS_MAXIMIZE))
1177 extern UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect ); /*FIXME*/
1179 RECT newPos;
1180 UINT swFlag = (style & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
1181 WIN_SetStyle( hwnd, 0, WS_MAXIMIZE | WS_MINIMIZE );
1182 swFlag = WINPOS_MinMaximize( hwnd, swFlag, &newPos );
1184 swFlag |= SWP_FRAMECHANGED; /* Frame always gets changed */
1185 if (!(style & WS_VISIBLE) || (style & WS_CHILD) || GetActiveWindow()) swFlag |= SWP_NOACTIVATE;
1187 SetWindowPos( hwnd, 0, newPos.left, newPos.top,
1188 newPos.right, newPos.bottom, swFlag );
1191 /* Dock system tray windows. */
1192 /* Dock after the window is created so we don't have problems calling
1193 * SetWindowPos. */
1194 if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_TRAYWINDOW)
1195 systray_dock_window( display, data );
1197 return TRUE;
1199 failed:
1200 X11DRV_DestroyWindow( hwnd );
1201 return FALSE;
1205 /***********************************************************************
1206 * X11DRV_get_win_data
1208 * Return the X11 data structure associated with a window.
1210 struct x11drv_win_data *X11DRV_get_win_data( HWND hwnd )
1212 char *data;
1214 if (!hwnd || XFindContext( thread_display(), (XID)hwnd, win_data_context, &data )) data = NULL;
1215 return (struct x11drv_win_data *)data;
1219 /***********************************************************************
1220 * X11DRV_get_whole_window
1222 * Return the X window associated with the full area of a window
1224 Window X11DRV_get_whole_window( HWND hwnd )
1226 struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
1228 if (!data) return (Window)GetPropA( hwnd, whole_window_prop );
1229 return data->whole_window;
1233 /***********************************************************************
1234 * X11DRV_get_ic
1236 * Return the X input context associated with a window
1238 XIC X11DRV_get_ic( HWND hwnd )
1240 struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
1242 if (!data) return 0;
1243 return data->xic;
1247 /*****************************************************************
1248 * SetParent (X11DRV.@)
1250 void X11DRV_SetParent( HWND hwnd, HWND parent, HWND old_parent )
1252 Display *display = thread_display();
1253 struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
1255 if (!data) return;
1256 if (parent == old_parent) return;
1258 if (parent != GetDesktopWindow()) /* a child window */
1260 if (old_parent == GetDesktopWindow())
1262 /* destroy the old X windows */
1263 destroy_whole_window( display, data );
1264 destroy_icon_window( display, data );
1265 if (data->managed)
1267 data->managed = FALSE;
1268 RemovePropA( data->hwnd, managed_prop );
1272 else /* new top level window */
1274 /* FIXME: we ignore errors since we can't really recover anyway */
1275 create_whole_window( display, data, GetWindowLongW( hwnd, GWL_STYLE ) );
1280 /*****************************************************************
1281 * SetFocus (X11DRV.@)
1283 * Set the X focus.
1284 * Explicit colormap management seems to work only with OLVWM.
1286 void X11DRV_SetFocus( HWND hwnd )
1288 Display *display = thread_display();
1289 struct x11drv_win_data *data;
1290 XWindowAttributes win_attr;
1292 /* Only mess with the X focus if there's */
1293 /* no desktop window and if the window is not managed by the WM. */
1294 if (root_window != DefaultRootWindow(display)) return;
1296 if (!hwnd) /* If setting the focus to 0, uninstall the colormap */
1298 wine_tsx11_lock();
1299 if (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_PRIVATE)
1300 XUninstallColormap( display, X11DRV_PALETTE_PaletteXColormap );
1301 wine_tsx11_unlock();
1302 return;
1305 hwnd = GetAncestor( hwnd, GA_ROOT );
1307 if (!(data = X11DRV_get_win_data( hwnd ))) return;
1308 if (data->managed || !data->whole_window) return;
1310 /* Set X focus and install colormap */
1311 wine_tsx11_lock();
1312 if (XGetWindowAttributes( display, data->whole_window, &win_attr ) &&
1313 (win_attr.map_state == IsViewable))
1315 /* If window is not viewable, don't change anything */
1317 /* we must not use CurrentTime (ICCCM), so try to use last message time instead */
1318 /* FIXME: this is not entirely correct */
1319 XSetInputFocus( display, data->whole_window, RevertToParent,
1320 /* CurrentTime */
1321 GetMessageTime() - EVENT_x11_time_to_win32_time(0));
1322 if (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_PRIVATE)
1323 XInstallColormap( display, X11DRV_PALETTE_PaletteXColormap );
1325 wine_tsx11_unlock();
1329 /**********************************************************************
1330 * SetWindowIcon (X11DRV.@)
1332 * hIcon or hIconSm has changed (or is being initialised for the
1333 * first time). Complete the X11 driver-specific initialisation
1334 * and set the window hints.
1336 * This is not entirely correct, may need to create
1337 * an icon window and set the pixmap as a background
1339 void X11DRV_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
1341 Display *display = thread_display();
1342 struct x11drv_win_data *data;
1344 if (type != ICON_BIG) return; /* nothing to do here */
1346 if (!(data = X11DRV_get_win_data( hwnd ))) return;
1347 if (!data->whole_window) return;
1348 if (!data->managed) return;
1350 if (data->wm_hints)
1352 set_icon_hints( display, data, icon );
1353 wine_tsx11_lock();
1354 XSetWMHints( display, data->whole_window, data->wm_hints );
1355 wine_tsx11_unlock();