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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include <X11/Xresource.h>
33 #include <X11/Xutil.h>
40 #include "wine/unicode.h"
42 #include "wine/debug.h"
44 #include "wine/server.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(x11drv
);
51 extern Pixmap
X11DRV_BITMAP_Pixmap( HBITMAP
);
53 /* X context to associate a hwnd to an X window */
54 XContext winContext
= 0;
56 Atom X11DRV_Atoms
[NB_XATOMS
- FIRST_XATOM
];
58 static const char * const atom_names
[NB_XATOMS
- FIRST_XATOM
] =
77 "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR",
82 "_NET_WM_WINDOW_TYPE",
83 "_NET_WM_WINDOW_TYPE_UTILITY",
107 static LPCSTR whole_window_atom
;
108 static LPCSTR client_window_atom
;
109 static LPCSTR icon_window_atom
;
111 /***********************************************************************
114 * Check if a given window should be managed
116 inline static BOOL
is_window_managed( WND
*win
)
118 if (!managed_mode
) return FALSE
;
119 /* tray window is always managed */
120 if (win
->dwExStyle
& WS_EX_TRAYWINDOW
) return TRUE
;
121 /* child windows are not managed */
122 if (win
->dwStyle
& WS_CHILD
) return FALSE
;
123 /* windows with caption are managed */
124 if ((win
->dwStyle
& WS_CAPTION
) == WS_CAPTION
) return TRUE
;
125 /* tool windows are not managed */
126 if (win
->dwExStyle
& WS_EX_TOOLWINDOW
) return FALSE
;
127 /* windows with thick frame are managed */
128 if (win
->dwStyle
& WS_THICKFRAME
) return TRUE
;
129 /* application windows are managed */
130 if (win
->dwExStyle
& WS_EX_APPWINDOW
) return TRUE
;
131 /* full-screen popup windows are managed */
132 if ((win
->dwStyle
& WS_POPUP
) &&
133 (win
->rectWindow
.right
-win
->rectWindow
.left
) == screen_width
&&
134 (win
->rectWindow
.bottom
-win
->rectWindow
.top
) == screen_height
)
138 /* default: not managed */
143 /***********************************************************************
144 * is_client_window_mapped
146 * Check if the X client window should be mapped
148 inline static BOOL
is_client_window_mapped( WND
*win
)
150 struct x11drv_win_data
*data
= win
->pDriverData
;
151 return !(win
->dwStyle
& WS_MINIMIZE
) && !IsRectEmpty( &data
->client_rect
);
155 /***********************************************************************
156 * X11DRV_is_window_rect_mapped
158 * Check if the X whole window should be mapped based on its rectangle
160 BOOL
X11DRV_is_window_rect_mapped( const RECT
*rect
)
162 /* don't map if rect is empty */
163 if (IsRectEmpty( rect
)) return FALSE
;
165 /* don't map if rect is off-screen */
166 if (rect
->left
>= (int)screen_width
|| rect
->top
>= (int)screen_height
) return FALSE
;
167 if (rect
->right
< 0 || rect
->bottom
< 0) return FALSE
;
173 /***********************************************************************
174 * get_window_attributes
176 * Fill the window attributes structure for an X window.
178 static int get_window_attributes( Display
*display
, WND
*win
, XSetWindowAttributes
*attr
)
180 BOOL is_top_level
= is_window_top_level( win
);
181 BOOL managed
= is_top_level
&& is_window_managed( win
);
183 if (managed
) WIN_SetExStyle( win
->hwndSelf
, win
->dwExStyle
| WS_EX_MANAGED
);
184 else WIN_SetExStyle( win
->hwndSelf
, win
->dwExStyle
& ~WS_EX_MANAGED
);
186 attr
->override_redirect
= !managed
;
187 attr
->colormap
= X11DRV_PALETTE_PaletteXColormap
;
188 attr
->save_under
= ((win
->clsStyle
& CS_SAVEBITS
) != 0);
189 attr
->cursor
= x11drv_thread_data()->cursor
;
190 attr
->event_mask
= (ExposureMask
| PointerMotionMask
|
191 ButtonPressMask
| ButtonReleaseMask
| EnterWindowMask
);
193 if (is_window_top_level( win
))
194 attr
->event_mask
|= (KeyPressMask
| KeyReleaseMask
| StructureNotifyMask
|
195 FocusChangeMask
| KeymapStateMask
);
197 return (CWOverrideRedirect
| CWSaveUnder
| CWEventMask
| CWColormap
| CWCursor
);
201 /***********************************************************************
202 * X11DRV_sync_window_style
204 * Change the X window attributes when the window style has changed.
206 void X11DRV_sync_window_style( Display
*display
, WND
*win
)
208 XSetWindowAttributes attr
;
212 mask
= get_window_attributes( display
, win
, &attr
);
213 XChangeWindowAttributes( display
, get_whole_window(win
), mask
, &attr
);
218 /***********************************************************************
221 * fill the window changes structure
223 static int get_window_changes( XWindowChanges
*changes
, const RECT
*old
, const RECT
*new )
227 if (old
->right
- old
->left
!= new->right
- new->left
)
229 if (!(changes
->width
= new->right
- new->left
)) changes
->width
= 1;
232 if (old
->bottom
- old
->top
!= new->bottom
- new->top
)
234 if (!(changes
->height
= new->bottom
- new->top
)) changes
->height
= 1;
237 if (old
->left
!= new->left
)
239 changes
->x
= new->left
;
242 if (old
->top
!= new->top
)
244 changes
->y
= new->top
;
251 /***********************************************************************
254 static Window
create_icon_window( Display
*display
, WND
*win
)
256 struct x11drv_win_data
*data
= win
->pDriverData
;
257 XSetWindowAttributes attr
;
259 attr
.event_mask
= (ExposureMask
| KeyPressMask
| KeyReleaseMask
| PointerMotionMask
|
260 ButtonPressMask
| ButtonReleaseMask
| EnterWindowMask
);
261 attr
.bit_gravity
= NorthWestGravity
;
262 attr
.backing_store
= NotUseful
/*WhenMapped*/;
263 attr
.colormap
= X11DRV_PALETTE_PaletteXColormap
; /* Needed due to our visual */
266 data
->icon_window
= XCreateWindow( display
, root_window
, 0, 0,
267 GetSystemMetrics( SM_CXICON
),
268 GetSystemMetrics( SM_CYICON
),
271 CWEventMask
| CWBitGravity
| CWBackingStore
| CWColormap
, &attr
);
272 XSaveContext( display
, data
->icon_window
, winContext
, (char *)win
->hwndSelf
);
275 TRACE( "created %lx\n", data
->icon_window
);
276 SetPropA( win
->hwndSelf
, icon_window_atom
, (HANDLE
)data
->icon_window
);
277 return data
->icon_window
;
282 /***********************************************************************
283 * destroy_icon_window
285 inline static void destroy_icon_window( Display
*display
, WND
*win
)
287 struct x11drv_win_data
*data
= win
->pDriverData
;
289 if (!data
->icon_window
) return;
290 if (x11drv_thread_data()->cursor_window
== data
->icon_window
)
291 x11drv_thread_data()->cursor_window
= None
;
293 XDeleteContext( display
, data
->icon_window
, winContext
);
294 XDestroyWindow( display
, data
->icon_window
);
295 data
->icon_window
= 0;
297 RemovePropA( win
->hwndSelf
, icon_window_atom
);
301 /***********************************************************************
304 * Set the icon wm hints
306 static void set_icon_hints( Display
*display
, WND
*wndPtr
, XWMHints
*hints
, HICON hIcon
)
308 X11DRV_WND_DATA
*data
= wndPtr
->pDriverData
;
310 if (data
->hWMIconBitmap
) DeleteObject( data
->hWMIconBitmap
);
311 if (data
->hWMIconMask
) DeleteObject( data
->hWMIconMask
);
312 data
->hWMIconBitmap
= 0;
313 data
->hWMIconMask
= 0;
315 if (!(wndPtr
->dwExStyle
& WS_EX_MANAGED
))
317 destroy_icon_window( display
, wndPtr
);
318 hints
->flags
&= ~(IconPixmapHint
| IconMaskHint
| IconWindowHint
);
322 if (!data
->icon_window
) create_icon_window( display
, wndPtr
);
323 hints
->icon_window
= data
->icon_window
;
324 hints
->flags
= (hints
->flags
& ~(IconPixmapHint
| IconMaskHint
)) | IconWindowHint
;
334 GetIconInfo(hIcon
, &ii
);
336 GetObjectA(ii
.hbmMask
, sizeof(bmMask
), &bmMask
);
339 rcMask
.right
= bmMask
.bmWidth
;
340 rcMask
.bottom
= bmMask
.bmHeight
;
342 hDC
= CreateCompatibleDC(0);
343 hbmOrig
= SelectObject(hDC
, ii
.hbmMask
);
344 InvertRect(hDC
, &rcMask
);
345 SelectObject(hDC
, ii
.hbmColor
); /* force the color bitmap to x11drv mode too */
346 SelectObject(hDC
, hbmOrig
);
349 data
->hWMIconBitmap
= ii
.hbmColor
;
350 data
->hWMIconMask
= ii
.hbmMask
;
352 hints
->icon_pixmap
= X11DRV_BITMAP_Pixmap(data
->hWMIconBitmap
);
353 hints
->icon_mask
= X11DRV_BITMAP_Pixmap(data
->hWMIconMask
);
354 destroy_icon_window( display
, wndPtr
);
355 hints
->flags
= (hints
->flags
& ~IconWindowHint
) | IconPixmapHint
| IconMaskHint
;
360 /***********************************************************************
363 * set the window size hints
365 static void set_size_hints( Display
*display
, WND
*win
)
367 XSizeHints
* size_hints
;
368 struct x11drv_win_data
*data
= win
->pDriverData
;
370 if ((size_hints
= XAllocSizeHints()))
372 size_hints
->win_gravity
= StaticGravity
;
373 size_hints
->x
= data
->whole_rect
.left
;
374 size_hints
->y
= data
->whole_rect
.top
;
375 size_hints
->flags
= PWinGravity
| PPosition
;
377 if ( !(win
->dwStyle
& WS_THICKFRAME
) )
379 size_hints
->max_width
= data
->whole_rect
.right
- data
->whole_rect
.left
;
380 size_hints
->max_height
= data
->whole_rect
.bottom
- data
->whole_rect
.top
;
381 size_hints
->min_width
= size_hints
->max_width
;
382 size_hints
->min_height
= size_hints
->max_height
;
383 size_hints
->flags
|= PMinSize
| PMaxSize
;
385 XSetWMNormalHints( display
, data
->whole_window
, size_hints
);
391 /***********************************************************************
392 * X11DRV_set_wm_hints
394 * Set the window manager hints for a newly-created window
396 void X11DRV_set_wm_hints( Display
*display
, WND
*win
)
398 struct x11drv_win_data
*data
= win
->pDriverData
;
400 XClassHint
*class_hints
;
411 protocols
[i
++] = x11drv_atom(WM_DELETE_WINDOW
);
412 protocols
[i
++] = x11drv_atom(_NET_WM_PING
);
413 if (use_take_focus
) protocols
[i
++] = x11drv_atom(WM_TAKE_FOCUS
);
414 XChangeProperty( display
, data
->whole_window
, x11drv_atom(WM_PROTOCOLS
),
415 XA_ATOM
, 32, PropModeReplace
, (char *)protocols
, i
);
418 if ((class_hints
= XAllocClassHint()))
420 class_hints
->res_name
= "wine";
421 class_hints
->res_class
= "Wine";
422 XSetClassHint( display
, data
->whole_window
, class_hints
);
423 XFree( class_hints
);
426 /* transient for hint */
429 Window owner_win
= X11DRV_get_whole_window( win
->owner
);
430 XSetTransientForHint( display
, data
->whole_window
, owner_win
);
431 group_leader
= owner_win
;
433 else group_leader
= data
->whole_window
;
436 set_size_hints( display
, win
);
438 /* systray properties (KDE only for now) */
439 if (win
->dwExStyle
& WS_EX_TRAYWINDOW
)
442 XChangeProperty( display
, data
->whole_window
, x11drv_atom(KWM_DOCKWINDOW
),
443 x11drv_atom(KWM_DOCKWINDOW
), 32, PropModeReplace
, (char*)&val
, 1 );
444 XChangeProperty( display
, data
->whole_window
, x11drv_atom(_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR
),
445 XA_WINDOW
, 32, PropModeReplace
, (char*)&data
->whole_window
, 1 );
448 /* set the WM_CLIENT_MACHINE and WM_LOCALE_NAME properties */
449 XSetWMProperties(display
, data
->whole_window
, NULL
, NULL
, NULL
, 0, NULL
, NULL
, NULL
);
450 /* set the pid. together, these properties are needed so the window manager can kill us if we freeze */
452 XChangeProperty(display
, data
->whole_window
, x11drv_atom(_NET_WM_PID
),
453 XA_CARDINAL
, 32, PropModeReplace
, (char *)&i
, 1);
455 /* map WS_EX_TOOLWINDOW to _NET_WM_WINDOW_TYPE_UTILITY */
456 if (win
->dwExStyle
& WS_EX_TOOLWINDOW
)
458 Atom a
= x11drv_atom(_NET_WM_WINDOW_TYPE_UTILITY
);
459 XChangeProperty(display
, data
->whole_window
, x11drv_atom(_NET_WM_WINDOW_TYPE
),
460 XA_ATOM
, 32, PropModeReplace
, (char*)&a
, 1);
463 mwm_hints
.flags
= MWM_HINTS_FUNCTIONS
| MWM_HINTS_DECORATIONS
;
464 mwm_hints
.functions
= 0;
465 if ((win
->dwStyle
& WS_CAPTION
) == WS_CAPTION
) mwm_hints
.functions
|= MWM_FUNC_MOVE
;
466 if (win
->dwStyle
& WS_THICKFRAME
) mwm_hints
.functions
|= MWM_FUNC_MOVE
| MWM_FUNC_RESIZE
;
467 if (win
->dwStyle
& WS_MINIMIZEBOX
) mwm_hints
.functions
|= MWM_FUNC_MINIMIZE
;
468 if (win
->dwStyle
& WS_MAXIMIZEBOX
) mwm_hints
.functions
|= MWM_FUNC_MAXIMIZE
;
469 if (win
->dwStyle
& WS_SYSMENU
) mwm_hints
.functions
|= MWM_FUNC_CLOSE
;
470 mwm_hints
.decorations
= 0;
471 if ((win
->dwStyle
& WS_CAPTION
) == WS_CAPTION
) mwm_hints
.decorations
|= MWM_DECOR_TITLE
;
472 if (win
->dwExStyle
& WS_EX_DLGMODALFRAME
) mwm_hints
.decorations
|= MWM_DECOR_BORDER
;
473 else if (win
->dwStyle
& WS_THICKFRAME
) mwm_hints
.decorations
|= MWM_DECOR_BORDER
| MWM_DECOR_RESIZEH
;
474 else if ((win
->dwStyle
& (WS_DLGFRAME
|WS_BORDER
)) == WS_DLGFRAME
) mwm_hints
.decorations
|= MWM_DECOR_BORDER
;
475 else if (win
->dwStyle
& WS_BORDER
) mwm_hints
.decorations
|= MWM_DECOR_BORDER
;
476 else if (!(win
->dwStyle
& (WS_CHILD
|WS_POPUP
))) mwm_hints
.decorations
|= MWM_DECOR_BORDER
;
477 if (win
->dwStyle
& WS_SYSMENU
) mwm_hints
.decorations
|= MWM_DECOR_MENU
;
478 if (win
->dwStyle
& WS_MINIMIZEBOX
) mwm_hints
.decorations
|= MWM_DECOR_MINIMIZE
;
479 if (win
->dwStyle
& WS_MAXIMIZEBOX
) mwm_hints
.decorations
|= MWM_DECOR_MAXIMIZE
;
481 XChangeProperty( display
, data
->whole_window
, x11drv_atom(_MOTIF_WM_HINTS
),
482 x11drv_atom(_MOTIF_WM_HINTS
), 32, PropModeReplace
,
483 (char*)&mwm_hints
, sizeof(mwm_hints
)/sizeof(long) );
485 XChangeProperty( display
, data
->whole_window
, x11drv_atom(XdndAware
),
486 XA_ATOM
, 32, PropModeReplace
, (unsigned char*)&dndVersion
, 1 );
488 wm_hints
= XAllocWMHints();
494 wm_hints
->flags
= InputHint
| StateHint
| WindowGroupHint
;
495 wm_hints
->input
= !(win
->dwStyle
& WS_DISABLED
);
497 set_icon_hints( display
, win
, wm_hints
, (HICON
)GetClassLongA( win
->hwndSelf
, GCL_HICON
));
499 wm_hints
->initial_state
= (win
->dwStyle
& WS_MINIMIZE
) ? IconicState
: NormalState
;
500 wm_hints
->window_group
= group_leader
;
503 XSetWMHints( display
, data
->whole_window
, wm_hints
);
510 /***********************************************************************
511 * X11DRV_set_iconic_state
513 * Set the X11 iconic state according to the window style.
515 void X11DRV_set_iconic_state( WND
*win
)
517 Display
*display
= thread_display();
518 struct x11drv_win_data
*data
= win
->pDriverData
;
520 BOOL iconic
= IsIconic( win
->hwndSelf
);
524 if (iconic
) XUnmapWindow( display
, data
->client_window
);
525 else if (is_client_window_mapped( win
)) XMapWindow( display
, data
->client_window
);
527 if (!(wm_hints
= XGetWMHints( display
, data
->whole_window
))) wm_hints
= XAllocWMHints();
528 wm_hints
->flags
|= StateHint
| IconPositionHint
;
529 wm_hints
->initial_state
= iconic
? IconicState
: NormalState
;
530 wm_hints
->icon_x
= win
->rectWindow
.left
;
531 wm_hints
->icon_y
= win
->rectWindow
.top
;
532 XSetWMHints( display
, data
->whole_window
, wm_hints
);
534 if (win
->dwStyle
& WS_VISIBLE
)
537 XIconifyWindow( display
, data
->whole_window
, DefaultScreen(display
) );
539 if (X11DRV_is_window_rect_mapped( &win
->rectWindow
))
540 XMapWindow( display
, data
->whole_window
);
548 /***********************************************************************
549 * X11DRV_window_to_X_rect
551 * Convert a rect from client to X window coordinates
553 void X11DRV_window_to_X_rect( WND
*win
, RECT
*rect
)
557 if (!(win
->dwExStyle
& WS_EX_MANAGED
)) return;
558 if (IsRectEmpty( rect
)) return;
560 rc
.top
= rc
.bottom
= rc
.left
= rc
.right
= 0;
562 AdjustWindowRectEx( &rc
, win
->dwStyle
& ~(WS_HSCROLL
|WS_VSCROLL
), FALSE
, win
->dwExStyle
);
564 rect
->left
-= rc
.left
;
565 rect
->right
-= rc
.right
;
567 rect
->bottom
-= rc
.bottom
;
568 if (rect
->top
>= rect
->bottom
) rect
->bottom
= rect
->top
+ 1;
569 if (rect
->left
>= rect
->right
) rect
->right
= rect
->left
+ 1;
573 /***********************************************************************
574 * X11DRV_X_to_window_rect
576 * Opposite of X11DRV_window_to_X_rect
578 void X11DRV_X_to_window_rect( WND
*win
, RECT
*rect
)
580 if (!(win
->dwExStyle
& WS_EX_MANAGED
)) return;
581 if (IsRectEmpty( rect
)) return;
583 AdjustWindowRectEx( rect
, win
->dwStyle
& ~(WS_HSCROLL
|WS_VSCROLL
), FALSE
, win
->dwExStyle
);
585 if (rect
->top
>= rect
->bottom
) rect
->bottom
= rect
->top
+ 1;
586 if (rect
->left
>= rect
->right
) rect
->right
= rect
->left
+ 1;
590 /***********************************************************************
591 * X11DRV_sync_whole_window_position
593 * Synchronize the X whole window position with the Windows one
595 int X11DRV_sync_whole_window_position( Display
*display
, WND
*win
, int zorder
)
597 XWindowChanges changes
;
599 struct x11drv_win_data
*data
= win
->pDriverData
;
600 RECT whole_rect
= win
->rectWindow
;
602 X11DRV_window_to_X_rect( win
, &whole_rect
);
603 mask
= get_window_changes( &changes
, &data
->whole_rect
, &whole_rect
);
607 if (is_window_top_level( win
))
609 /* find window that this one must be after */
610 HWND prev
= GetWindow( win
->hwndSelf
, GW_HWNDPREV
);
611 while (prev
&& !(GetWindowLongW( prev
, GWL_STYLE
) & WS_VISIBLE
))
612 prev
= GetWindow( prev
, GW_HWNDPREV
);
613 if (!prev
) /* top child */
615 changes
.stack_mode
= Above
;
620 /* should use stack_mode Below but most window managers don't get it right */
621 /* so move it above the next one in Z order */
622 HWND next
= GetWindow( win
->hwndSelf
, GW_HWNDNEXT
);
623 while (next
&& !(GetWindowLongW( next
, GWL_STYLE
) & WS_VISIBLE
))
624 next
= GetWindow( next
, GW_HWNDNEXT
);
627 changes
.stack_mode
= Above
;
628 changes
.sibling
= X11DRV_get_whole_window(next
);
629 mask
|= CWStackMode
| CWSibling
;
635 HWND next
= GetWindow( win
->hwndSelf
, GW_HWNDNEXT
);
637 if (win
->parent
== GetDesktopWindow() &&
638 root_window
!= DefaultRootWindow(display
))
640 /* in desktop mode we need the sibling to belong to the same process */
643 WND
*ptr
= WIN_GetPtr( next
);
644 if (ptr
!= WND_OTHER_PROCESS
)
646 WIN_ReleasePtr( ptr
);
649 next
= GetWindow( next
, GW_HWNDNEXT
);
653 if (!next
) /* bottom child */
655 changes
.stack_mode
= Below
;
660 changes
.stack_mode
= Above
;
661 changes
.sibling
= X11DRV_get_whole_window(next
);
662 mask
|= CWStackMode
| CWSibling
;
667 data
->whole_rect
= whole_rect
;
671 TRACE( "setting win %lx pos %ld,%ld,%ldx%ld after %lx changes=%x\n",
672 data
->whole_window
, whole_rect
.left
, whole_rect
.top
,
673 whole_rect
.right
- whole_rect
.left
, whole_rect
.bottom
- whole_rect
.top
,
674 changes
.sibling
, mask
);
676 XSync( gdi_display
, False
); /* flush graphics operations before moving the window */
677 if (is_window_top_level( win
))
679 if (mask
& (CWWidth
|CWHeight
)) set_size_hints( display
, win
);
680 XReconfigureWMWindow( display
, data
->whole_window
,
681 DefaultScreen(display
), mask
, &changes
);
683 else XConfigureWindow( display
, data
->whole_window
, mask
, &changes
);
690 /***********************************************************************
691 * X11DRV_sync_client_window_position
693 * Synchronize the X client window position with the Windows one
695 int X11DRV_sync_client_window_position( Display
*display
, WND
*win
)
697 XWindowChanges changes
;
699 struct x11drv_win_data
*data
= win
->pDriverData
;
700 RECT client_rect
= win
->rectClient
;
702 OffsetRect( &client_rect
, -data
->whole_rect
.left
, -data
->whole_rect
.top
);
704 if ((mask
= get_window_changes( &changes
, &data
->client_rect
, &client_rect
)))
706 BOOL was_mapped
= is_client_window_mapped( win
);
708 TRACE( "setting win %lx pos %ld,%ld,%ldx%ld (was %ld,%ld,%ldx%ld) after %lx changes=%x\n",
709 data
->client_window
, client_rect
.left
, client_rect
.top
,
710 client_rect
.right
- client_rect
.left
, client_rect
.bottom
- client_rect
.top
,
711 data
->client_rect
.left
, data
->client_rect
.top
,
712 data
->client_rect
.right
- data
->client_rect
.left
,
713 data
->client_rect
.bottom
- data
->client_rect
.top
,
714 changes
.sibling
, mask
);
715 data
->client_rect
= client_rect
;
717 XSync( gdi_display
, False
); /* flush graphics operations before moving the window */
718 if (was_mapped
&& !is_client_window_mapped( win
))
719 XUnmapWindow( display
, data
->client_window
);
720 XConfigureWindow( display
, data
->client_window
, mask
, &changes
);
721 if (!was_mapped
&& is_client_window_mapped( win
))
722 XMapWindow( display
, data
->client_window
);
729 /***********************************************************************
730 * X11DRV_register_window
732 * Associate an X window to a HWND.
734 void X11DRV_register_window( Display
*display
, HWND hwnd
, struct x11drv_win_data
*data
)
737 XSaveContext( display
, data
->whole_window
, winContext
, (char *)hwnd
);
738 XSaveContext( display
, data
->client_window
, winContext
, (char *)hwnd
);
743 /***********************************************************************
744 * X11DRV_set_window_rectangles
746 * Set the window and client rectangles.
748 void X11DRV_set_window_rectangles( HWND hwnd
, const RECT
*rectWindow
, const RECT
*rectClient
)
750 WND
*win
= WIN_GetPtr( hwnd
);
754 if (win
== WND_OTHER_PROCESS
)
756 if (IsWindow( hwnd
)) ERR( "cannot set rectangles of other process window %p\n", hwnd
);
759 SERVER_START_REQ( set_window_rectangles
)
762 req
->window
.left
= rectWindow
->left
;
763 req
->window
.top
= rectWindow
->top
;
764 req
->window
.right
= rectWindow
->right
;
765 req
->window
.bottom
= rectWindow
->bottom
;
766 req
->client
.left
= rectClient
->left
;
767 req
->client
.top
= rectClient
->top
;
768 req
->client
.right
= rectClient
->right
;
769 req
->client
.bottom
= rectClient
->bottom
;
770 ret
= !wine_server_call( req
);
775 win
->rectWindow
= *rectWindow
;
776 win
->rectClient
= *rectClient
;
778 TRACE( "win %p window (%ld,%ld)-(%ld,%ld) client (%ld,%ld)-(%ld,%ld)\n", hwnd
,
779 rectWindow
->left
, rectWindow
->top
, rectWindow
->right
, rectWindow
->bottom
,
780 rectClient
->left
, rectClient
->top
, rectClient
->right
, rectClient
->bottom
);
782 WIN_ReleasePtr( win
);
786 /**********************************************************************
789 static void create_desktop( Display
*display
, WND
*wndPtr
)
791 X11DRV_WND_DATA
*data
= wndPtr
->pDriverData
;
794 winContext
= XUniqueContext();
795 XInternAtoms( display
, (char **)atom_names
, NB_XATOMS
- FIRST_XATOM
, False
, X11DRV_Atoms
);
798 whole_window_atom
= MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_whole_window" ));
799 client_window_atom
= MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_client_window" ));
800 icon_window_atom
= MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_icon_window" ));
802 data
->whole_window
= data
->client_window
= root_window
;
803 data
->whole_rect
= data
->client_rect
= wndPtr
->rectWindow
;
805 SetPropA( wndPtr
->hwndSelf
, whole_window_atom
, (HANDLE
)root_window
);
806 SetPropA( wndPtr
->hwndSelf
, client_window_atom
, (HANDLE
)root_window
);
807 SetPropA( wndPtr
->hwndSelf
, "__wine_x11_visual_id", (HANDLE
)XVisualIDFromVisual(visual
) );
809 X11DRV_InitClipboard();
811 if (root_window
!= DefaultRootWindow(display
)) X11DRV_create_desktop_thread();
815 /**********************************************************************
816 * create_whole_window
818 * Create the whole X window for a given window
820 static Window
create_whole_window( Display
*display
, WND
*win
)
822 struct x11drv_win_data
*data
= win
->pDriverData
;
824 XSetWindowAttributes attr
;
827 BOOL is_top_level
= is_window_top_level( win
);
829 rect
= win
->rectWindow
;
830 X11DRV_window_to_X_rect( win
, &rect
);
832 if (!(cx
= rect
.right
- rect
.left
)) cx
= 1;
833 if (!(cy
= rect
.bottom
- rect
.top
)) cy
= 1;
835 parent
= X11DRV_get_client_window( win
->parent
);
839 mask
= get_window_attributes( display
, win
, &attr
);
841 /* set the attributes that don't change over the lifetime of the window */
842 attr
.bit_gravity
= ForgetGravity
;
843 attr
.win_gravity
= NorthWestGravity
;
844 attr
.backing_store
= NotUseful
/*WhenMapped*/;
845 mask
|= CWBitGravity
| CWWinGravity
| CWBackingStore
;
847 data
->whole_rect
= rect
;
848 data
->whole_window
= XCreateWindow( display
, parent
, rect
.left
, rect
.top
, cx
, cy
,
849 0, screen_depth
, InputOutput
, visual
,
852 if (!data
->whole_window
)
858 /* non-maximized child must be at bottom of Z order */
859 if ((win
->dwStyle
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
861 XWindowChanges changes
;
862 changes
.stack_mode
= Below
;
863 XConfigureWindow( display
, data
->whole_window
, CWStackMode
, &changes
);
870 XIM xim
= x11drv_thread_data()->xim
;
871 if (xim
) data
->xic
= X11DRV_CreateIC( xim
, display
, data
->whole_window
);
872 X11DRV_set_wm_hints( display
, win
);
875 return data
->whole_window
;
879 /**********************************************************************
880 * create_client_window
882 * Create the client window for a given window
884 static Window
create_client_window( Display
*display
, WND
*win
)
886 struct x11drv_win_data
*data
= win
->pDriverData
;
887 RECT rect
= data
->whole_rect
;
888 XSetWindowAttributes attr
;
890 OffsetRect( &rect
, -data
->whole_rect
.left
, -data
->whole_rect
.top
);
891 data
->client_rect
= rect
;
893 attr
.event_mask
= (ExposureMask
| PointerMotionMask
|
894 ButtonPressMask
| ButtonReleaseMask
| EnterWindowMask
);
895 attr
.bit_gravity
= (win
->clsStyle
& (CS_VREDRAW
| CS_HREDRAW
)) ?
896 ForgetGravity
: NorthWestGravity
;
897 attr
.backing_store
= NotUseful
/*WhenMapped*/;
900 data
->client_window
= XCreateWindow( display
, data
->whole_window
, 0, 0,
901 max( rect
.right
- rect
.left
, 1 ),
902 max( rect
.bottom
- rect
.top
, 1 ),
905 CWEventMask
| CWBitGravity
| CWBackingStore
, &attr
);
906 if (data
->client_window
&& is_client_window_mapped( win
))
907 XMapWindow( display
, data
->client_window
);
909 return data
->client_window
;
913 /*****************************************************************
914 * SetWindowText (X11DRV.@)
916 BOOL
X11DRV_SetWindowText( HWND hwnd
, LPCWSTR text
)
918 Display
*display
= thread_display();
925 if ((win
= X11DRV_get_whole_window( hwnd
)))
927 /* allocate new buffer for window text */
928 count
= WideCharToMultiByte(CP_UNIXCP
, 0, text
, -1, NULL
, 0, NULL
, NULL
);
929 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, count
)))
931 ERR("Not enough memory for window text\n");
934 WideCharToMultiByte(CP_UNIXCP
, 0, text
, -1, buffer
, count
, NULL
, NULL
);
936 count
= WideCharToMultiByte(CP_UTF8
, 0, text
, strlenW(text
), NULL
, 0, NULL
, NULL
);
937 if (!(utf8_buffer
= HeapAlloc( GetProcessHeap(), 0, count
)))
939 ERR("Not enough memory for window text in UTF-8\n");
942 WideCharToMultiByte(CP_UTF8
, 0, text
, strlenW(text
), utf8_buffer
, count
, NULL
, NULL
);
945 if (XmbTextListToTextProperty( display
, &buffer
, 1, XStdICCTextStyle
, &prop
) == Success
)
947 XSetWMName( display
, win
, &prop
);
948 XSetWMIconName( display
, win
, &prop
);
952 Implements a NET_WM UTF-8 title. It should be without a trailing \0,
953 according to the standard
954 ( http://www.pps.jussieu.fr/~jch/software/UTF8_STRING/UTF8_STRING.text ).
956 XChangeProperty( display
, win
, x11drv_atom(_NET_WM_NAME
), x11drv_atom(UTF8_STRING
),
957 8, PropModeReplace
, (unsigned char *) utf8_buffer
, count
);
960 HeapFree( GetProcessHeap(), 0, utf8_buffer
);
961 HeapFree( GetProcessHeap(), 0, buffer
);
967 /***********************************************************************
968 * DestroyWindow (X11DRV.@)
970 BOOL
X11DRV_DestroyWindow( HWND hwnd
)
972 struct x11drv_thread_data
*thread_data
= x11drv_thread_data();
973 Display
*display
= thread_data
->display
;
974 WND
*wndPtr
= WIN_GetPtr( hwnd
);
975 X11DRV_WND_DATA
*data
= wndPtr
->pDriverData
;
977 if (!data
) goto done
;
979 if (data
->whole_window
)
981 TRACE( "win %p xwin %lx/%lx\n", hwnd
, data
->whole_window
, data
->client_window
);
982 if (thread_data
->cursor_window
== data
->whole_window
) thread_data
->cursor_window
= None
;
983 if (thread_data
->last_focus
== hwnd
) thread_data
->last_focus
= 0;
985 XSync( gdi_display
, False
); /* flush any reference to this drawable in GDI queue */
986 XDeleteContext( display
, data
->whole_window
, winContext
);
987 XDeleteContext( display
, data
->client_window
, winContext
);
988 XDestroyWindow( display
, data
->whole_window
); /* this destroys client too */
991 XUnsetICFocus( data
->xic
);
992 XDestroyIC( data
->xic
);
994 destroy_icon_window( display
, wndPtr
);
998 if (data
->hWMIconBitmap
) DeleteObject( data
->hWMIconBitmap
);
999 if (data
->hWMIconMask
) DeleteObject( data
->hWMIconMask
);
1000 HeapFree( GetProcessHeap(), 0, data
);
1001 wndPtr
->pDriverData
= NULL
;
1003 WIN_ReleasePtr( wndPtr
);
1008 /**********************************************************************
1009 * CreateWindow (X11DRV.@)
1011 BOOL
X11DRV_CreateWindow( HWND hwnd
, CREATESTRUCTA
*cs
, BOOL unicode
)
1013 Display
*display
= thread_display();
1015 struct x11drv_win_data
*data
;
1017 CBT_CREATEWNDA cbtc
;
1022 ERR( "invalid window width %d\n", cs
->cx
);
1027 ERR( "invalid window height %d\n", cs
->cy
);
1031 if (!(data
= HeapAlloc(GetProcessHeap(), 0, sizeof(*data
)))) return FALSE
;
1032 data
->whole_window
= 0;
1033 data
->client_window
= 0;
1034 data
->icon_window
= 0;
1036 data
->hWMIconBitmap
= 0;
1037 data
->hWMIconMask
= 0;
1039 wndPtr
= WIN_GetPtr( hwnd
);
1040 wndPtr
->pDriverData
= data
;
1042 /* initialize the dimensions before sending WM_GETMINMAXINFO */
1043 SetRect( &rect
, cs
->x
, cs
->y
, cs
->x
+ cs
->cx
, cs
->y
+ cs
->cy
);
1044 X11DRV_set_window_rectangles( hwnd
, &rect
, &rect
);
1046 if (!wndPtr
->parent
)
1048 create_desktop( display
, wndPtr
);
1049 WIN_ReleasePtr( wndPtr
);
1053 if (!create_whole_window( display
, wndPtr
)) goto failed
;
1054 if (!create_client_window( display
, wndPtr
)) goto failed
;
1056 XSync( display
, False
);
1057 wine_tsx11_unlock();
1059 SetPropA( hwnd
, whole_window_atom
, (HANDLE
)data
->whole_window
);
1060 SetPropA( hwnd
, client_window_atom
, (HANDLE
)data
->client_window
);
1062 /* Call the WH_CBT hook */
1064 cbtc
.hwndInsertAfter
= HWND_TOP
;
1065 if (HOOK_CallHooks( WH_CBT
, HCBT_CREATEWND
, (WPARAM
)hwnd
, (LPARAM
)&cbtc
, unicode
))
1067 TRACE("CBT-hook returned !0\n");
1071 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
1072 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
1074 POINT maxSize
, maxPos
, minTrack
, maxTrack
;
1076 WIN_ReleasePtr( wndPtr
);
1077 WINPOS_GetMinMaxInfo( hwnd
, &maxSize
, &maxPos
, &minTrack
, &maxTrack
);
1078 if (maxSize
.x
< cs
->cx
) cs
->cx
= maxSize
.x
;
1079 if (maxSize
.y
< cs
->cy
) cs
->cy
= maxSize
.y
;
1080 if (cs
->cx
< 0) cs
->cx
= 0;
1081 if (cs
->cy
< 0) cs
->cy
= 0;
1083 if (!(wndPtr
= WIN_GetPtr( hwnd
))) return FALSE
;
1084 SetRect( &rect
, cs
->x
, cs
->y
, cs
->x
+ cs
->cx
, cs
->y
+ cs
->cy
);
1085 X11DRV_set_window_rectangles( hwnd
, &rect
, &rect
);
1086 X11DRV_sync_whole_window_position( display
, wndPtr
, 0 );
1088 WIN_ReleasePtr( wndPtr
);
1090 /* send WM_NCCREATE */
1091 TRACE( "hwnd %p cs %d,%d %dx%d\n", hwnd
, cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
1093 ret
= SendMessageW( hwnd
, WM_NCCREATE
, 0, (LPARAM
)cs
);
1095 ret
= SendMessageA( hwnd
, WM_NCCREATE
, 0, (LPARAM
)cs
);
1098 WARN("aborted by WM_xxCREATE!\n");
1102 if (!(wndPtr
= WIN_GetPtr(hwnd
))) return FALSE
;
1104 X11DRV_sync_window_style( display
, wndPtr
);
1106 /* send WM_NCCALCSIZE */
1107 rect
= wndPtr
->rectWindow
;
1108 WIN_ReleasePtr( wndPtr
);
1109 SendMessageW( hwnd
, WM_NCCALCSIZE
, FALSE
, (LPARAM
)&rect
);
1111 if (!(wndPtr
= WIN_GetPtr(hwnd
))) return FALSE
;
1112 if (rect
.left
> rect
.right
|| rect
.top
> rect
.bottom
) rect
= wndPtr
->rectWindow
;
1113 X11DRV_set_window_rectangles( hwnd
, &wndPtr
->rectWindow
, &rect
);
1114 X11DRV_sync_client_window_position( display
, wndPtr
);
1115 X11DRV_register_window( display
, hwnd
, data
);
1117 TRACE( "win %p window %ld,%ld,%ld,%ld client %ld,%ld,%ld,%ld whole %ld,%ld,%ld,%ld X client %ld,%ld,%ld,%ld xwin %x/%x\n",
1118 hwnd
, wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
,
1119 wndPtr
->rectWindow
.right
, wndPtr
->rectWindow
.bottom
,
1120 wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
,
1121 wndPtr
->rectClient
.right
, wndPtr
->rectClient
.bottom
,
1122 data
->whole_rect
.left
, data
->whole_rect
.top
,
1123 data
->whole_rect
.right
, data
->whole_rect
.bottom
,
1124 data
->client_rect
.left
, data
->client_rect
.top
,
1125 data
->client_rect
.right
, data
->client_rect
.bottom
,
1126 (unsigned int)data
->whole_window
, (unsigned int)data
->client_window
);
1128 /* yes, even if the CBT hook was called with HWND_TOP */
1129 if ((wndPtr
->dwStyle
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
1130 WIN_LinkWindow( hwnd
, wndPtr
->parent
, HWND_BOTTOM
);
1132 WIN_LinkWindow( hwnd
, wndPtr
->parent
, HWND_TOP
);
1134 WIN_ReleasePtr( wndPtr
);
1137 ret
= (SendMessageW( hwnd
, WM_CREATE
, 0, (LPARAM
)cs
) != -1);
1139 ret
= (SendMessageA( hwnd
, WM_CREATE
, 0, (LPARAM
)cs
) != -1);
1143 WIN_UnlinkWindow( hwnd
);
1147 /* Send the size messages */
1149 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return FALSE
;
1150 if (!(wndPtr
->flags
& WIN_NEED_SIZE
))
1152 /* send it anyway */
1153 if (((wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
) <0)
1154 ||((wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
)<0))
1155 WARN("sending bogus WM_SIZE message 0x%08lx\n",
1156 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
1157 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
1158 SendMessageW( hwnd
, WM_SIZE
, SIZE_RESTORED
,
1159 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
1160 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
1161 SendMessageW( hwnd
, WM_MOVE
, 0,
1162 MAKELONG( wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
) );
1165 /* Show the window, maximizing or minimizing if needed */
1167 if (wndPtr
->dwStyle
& (WS_MINIMIZE
| WS_MAXIMIZE
))
1169 extern UINT
WINPOS_MinMaximize( HWND hwnd
, UINT cmd
, LPRECT rect
); /*FIXME*/
1172 UINT swFlag
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? SW_MINIMIZE
: SW_MAXIMIZE
;
1173 WIN_SetStyle( hwnd
, wndPtr
->dwStyle
& ~(WS_MAXIMIZE
| WS_MINIMIZE
) );
1174 WINPOS_MinMaximize( hwnd
, swFlag
, &newPos
);
1175 swFlag
= ((wndPtr
->dwStyle
& WS_CHILD
) || GetActiveWindow())
1176 ? SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
1177 : SWP_NOZORDER
| SWP_FRAMECHANGED
;
1178 SetWindowPos( hwnd
, 0, newPos
.left
, newPos
.top
,
1179 newPos
.right
, newPos
.bottom
, swFlag
);
1182 WIN_ReleaseWndPtr( wndPtr
);
1186 X11DRV_DestroyWindow( hwnd
);
1187 if (wndPtr
) WIN_ReleasePtr( wndPtr
);
1192 /***********************************************************************
1193 * X11DRV_get_client_window
1195 * Return the X window associated with the client area of a window
1197 Window
X11DRV_get_client_window( HWND hwnd
)
1200 WND
*win
= WIN_GetPtr( hwnd
);
1202 if (win
== WND_OTHER_PROCESS
)
1203 return (Window
)GetPropA( hwnd
, client_window_atom
);
1207 struct x11drv_win_data
*data
= win
->pDriverData
;
1208 ret
= data
->client_window
;
1209 WIN_ReleasePtr( win
);
1215 /***********************************************************************
1216 * X11DRV_get_whole_window
1218 * Return the X window associated with the full area of a window
1220 Window
X11DRV_get_whole_window( HWND hwnd
)
1223 WND
*win
= WIN_GetPtr( hwnd
);
1225 if (win
== WND_OTHER_PROCESS
)
1226 return (Window
)GetPropA( hwnd
, whole_window_atom
);
1230 struct x11drv_win_data
*data
= win
->pDriverData
;
1231 ret
= data
->whole_window
;
1232 WIN_ReleasePtr( win
);
1238 /***********************************************************************
1241 * Return the X input context associated with a window
1243 XIC
X11DRV_get_ic( HWND hwnd
)
1246 WND
*win
= WIN_GetPtr( hwnd
);
1248 if (win
&& win
!= WND_OTHER_PROCESS
)
1250 struct x11drv_win_data
*data
= win
->pDriverData
;
1252 WIN_ReleasePtr( win
);
1258 /*****************************************************************
1259 * SetParent (X11DRV.@)
1261 HWND
X11DRV_SetParent( HWND hwnd
, HWND parent
)
1263 Display
*display
= thread_display();
1267 /* Windows hides the window first, then shows it again
1268 * including the WM_SHOWWINDOW messages and all */
1269 BOOL was_visible
= ShowWindow( hwnd
, SW_HIDE
);
1271 if (!IsWindow( parent
)) return 0;
1272 if (!(wndPtr
= WIN_GetPtr(hwnd
)) || wndPtr
== WND_OTHER_PROCESS
) return 0;
1274 retvalue
= wndPtr
->parent
; /* old parent */
1275 if (parent
!= retvalue
)
1277 struct x11drv_win_data
*data
= wndPtr
->pDriverData
;
1279 WIN_LinkWindow( hwnd
, parent
, HWND_TOP
);
1281 if (parent
!= GetDesktopWindow()) /* a child window */
1283 if (!(wndPtr
->dwStyle
& WS_CHILD
))
1285 HMENU menu
= (HMENU
)SetWindowLongPtrW( hwnd
, GWLP_ID
, 0 );
1286 if (menu
) DestroyMenu( menu
);
1290 if (is_window_top_level( wndPtr
)) X11DRV_set_wm_hints( display
, wndPtr
);
1292 X11DRV_sync_window_style( display
, wndPtr
);
1293 XReparentWindow( display
, data
->whole_window
, X11DRV_get_client_window(parent
),
1294 data
->whole_rect
.left
, data
->whole_rect
.top
);
1295 wine_tsx11_unlock();
1297 WIN_ReleasePtr( wndPtr
);
1299 /* SetParent additionally needs to make hwnd the topmost window
1300 in the x-order and send the expected WM_WINDOWPOSCHANGING and
1301 WM_WINDOWPOSCHANGED notification messages.
1303 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0,
1304 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOSIZE
| (was_visible
? SWP_SHOWWINDOW
: 0) );
1305 /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
1306 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
1312 /*****************************************************************
1313 * SetFocus (X11DRV.@)
1316 * Explicit colormap management seems to work only with OLVWM.
1318 void X11DRV_SetFocus( HWND hwnd
)
1320 Display
*display
= thread_display();
1321 XWindowAttributes win_attr
;
1324 /* Only mess with the X focus if there's */
1325 /* no desktop window and if the window is not managed by the WM. */
1326 if (root_window
!= DefaultRootWindow(display
)) return;
1328 if (!hwnd
) /* If setting the focus to 0, uninstall the colormap */
1331 if (X11DRV_PALETTE_PaletteFlags
& X11DRV_PALETTE_PRIVATE
)
1332 XUninstallColormap( display
, X11DRV_PALETTE_PaletteXColormap
);
1333 wine_tsx11_unlock();
1337 hwnd
= GetAncestor( hwnd
, GA_ROOT
);
1338 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_MANAGED
) return;
1339 if (!(win
= X11DRV_get_whole_window( hwnd
))) return;
1341 /* Set X focus and install colormap */
1343 if (XGetWindowAttributes( display
, win
, &win_attr
) &&
1344 (win_attr
.map_state
== IsViewable
))
1346 /* If window is not viewable, don't change anything */
1348 /* we must not use CurrentTime (ICCCM), so try to use last message time instead */
1349 /* FIXME: this is not entirely correct */
1350 XSetInputFocus( display
, win
, RevertToParent
,
1351 /*CurrentTime*/ GetMessageTime() + X11DRV_server_startticks
);
1352 if (X11DRV_PALETTE_PaletteFlags
& X11DRV_PALETTE_PRIVATE
)
1353 XInstallColormap( display
, X11DRV_PALETTE_PaletteXColormap
);
1355 wine_tsx11_unlock();
1359 /**********************************************************************
1360 * SetWindowIcon (X11DRV.@)
1362 * hIcon or hIconSm has changed (or is being initialised for the
1363 * first time). Complete the X11 driver-specific initialisation
1364 * and set the window hints.
1366 * This is not entirely correct, may need to create
1367 * an icon window and set the pixmap as a background
1369 void X11DRV_SetWindowIcon( HWND hwnd
, UINT type
, HICON icon
)
1372 Display
*display
= thread_display();
1374 if (type
!= ICON_BIG
) return; /* nothing to do here */
1376 if (!(wndPtr
= WIN_GetPtr( hwnd
)) || wndPtr
== WND_OTHER_PROCESS
) return;
1378 if (wndPtr
->dwExStyle
& WS_EX_MANAGED
)
1380 Window win
= get_whole_window(wndPtr
);
1384 if (!(wm_hints
= XGetWMHints( display
, win
))) wm_hints
= XAllocWMHints();
1385 wine_tsx11_unlock();
1388 set_icon_hints( display
, wndPtr
, wm_hints
, icon
);
1390 XSetWMHints( display
, win
, wm_hints
);
1392 wine_tsx11_unlock();
1395 WIN_ReleasePtr( wndPtr
);