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"
48 WINE_DEFAULT_DEBUG_CHANNEL(x11drv
);
50 extern Pixmap
X11DRV_BITMAP_Pixmap( HBITMAP
);
52 #define HAS_DLGFRAME(style,exStyle) \
53 (((exStyle) & WS_EX_DLGMODALFRAME) || \
54 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
56 /* X context to associate a hwnd to an X window */
57 XContext winContext
= 0;
59 Atom X11DRV_Atoms
[NB_XATOMS
- FIRST_XATOM
];
61 static const char * const atom_names
[NB_XATOMS
- FIRST_XATOM
] =
80 "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR",
84 "_NET_WM_WINDOW_TYPE",
85 "_NET_WM_WINDOW_TYPE_UTILITY",
108 static LPCSTR whole_window_atom
;
109 static LPCSTR client_window_atom
;
110 static LPCSTR icon_window_atom
;
112 /***********************************************************************
115 * Check if a given window should be managed
117 inline static BOOL
is_window_managed( WND
*win
)
119 if (!managed_mode
) return FALSE
;
120 /* tray window is always managed */
121 if (win
->dwExStyle
& WS_EX_TRAYWINDOW
) return TRUE
;
122 /* child windows are not managed */
123 if (win
->dwStyle
& WS_CHILD
) return FALSE
;
124 /* windows with caption are managed */
125 if ((win
->dwStyle
& WS_CAPTION
) == WS_CAPTION
) return TRUE
;
126 /* tool windows are not managed */
127 if (win
->dwExStyle
& WS_EX_TOOLWINDOW
) return FALSE
;
128 /* windows with thick frame are managed */
129 if (win
->dwStyle
& WS_THICKFRAME
) return TRUE
;
130 /* application windows are managed */
131 if (win
->dwExStyle
& WS_EX_APPWINDOW
) return TRUE
;
132 /* popup windows that aren't owned are managed */
133 if ((win
->dwStyle
& WS_POPUP
) && !win
->owner
) return TRUE
;
134 /* default: not managed */
139 /***********************************************************************
140 * is_client_window_mapped
142 * Check if the X client window should be mapped
144 inline static BOOL
is_client_window_mapped( WND
*win
)
146 struct x11drv_win_data
*data
= win
->pDriverData
;
147 return !(win
->dwStyle
& WS_MINIMIZE
) && !IsRectEmpty( &data
->client_rect
);
151 /***********************************************************************
152 * get_window_attributes
154 * Fill the window attributes structure for an X window.
156 static int get_window_attributes( Display
*display
, WND
*win
, XSetWindowAttributes
*attr
)
158 BOOL is_top_level
= is_window_top_level( win
);
159 BOOL managed
= is_top_level
&& is_window_managed( win
);
161 if (managed
) WIN_SetExStyle( win
->hwndSelf
, win
->dwExStyle
| WS_EX_MANAGED
);
162 else WIN_SetExStyle( win
->hwndSelf
, win
->dwExStyle
& ~WS_EX_MANAGED
);
164 attr
->override_redirect
= !managed
;
165 attr
->colormap
= X11DRV_PALETTE_PaletteXColormap
;
166 attr
->save_under
= ((win
->clsStyle
& CS_SAVEBITS
) != 0);
167 attr
->cursor
= x11drv_thread_data()->cursor
;
168 attr
->event_mask
= (ExposureMask
| PointerMotionMask
|
169 ButtonPressMask
| ButtonReleaseMask
| EnterWindowMask
);
171 if (is_window_top_level( win
))
172 attr
->event_mask
|= (KeyPressMask
| KeyReleaseMask
| StructureNotifyMask
|
173 FocusChangeMask
| KeymapStateMask
);
175 return (CWOverrideRedirect
| CWSaveUnder
| CWEventMask
| CWColormap
| CWCursor
);
179 /***********************************************************************
180 * X11DRV_sync_window_style
182 * Change the X window attributes when the window style has changed.
184 void X11DRV_sync_window_style( Display
*display
, WND
*win
)
186 XSetWindowAttributes attr
;
190 mask
= get_window_attributes( display
, win
, &attr
);
191 XChangeWindowAttributes( display
, get_whole_window(win
), mask
, &attr
);
196 /***********************************************************************
199 * fill the window changes structure
201 static int get_window_changes( XWindowChanges
*changes
, const RECT
*old
, const RECT
*new )
205 if (old
->right
- old
->left
!= new->right
- new->left
)
207 if (!(changes
->width
= new->right
- new->left
)) changes
->width
= 1;
210 if (old
->bottom
- old
->top
!= new->bottom
- new->top
)
212 if (!(changes
->height
= new->bottom
- new->top
)) changes
->height
= 1;
215 if (old
->left
!= new->left
)
217 changes
->x
= new->left
;
220 if (old
->top
!= new->top
)
222 changes
->y
= new->top
;
229 /***********************************************************************
232 static Window
create_icon_window( Display
*display
, WND
*win
)
234 struct x11drv_win_data
*data
= win
->pDriverData
;
235 XSetWindowAttributes attr
;
237 attr
.event_mask
= (ExposureMask
| KeyPressMask
| KeyReleaseMask
| PointerMotionMask
|
238 ButtonPressMask
| ButtonReleaseMask
| EnterWindowMask
);
239 attr
.bit_gravity
= NorthWestGravity
;
240 attr
.backing_store
= NotUseful
/*WhenMapped*/;
241 attr
.colormap
= X11DRV_PALETTE_PaletteXColormap
; /* Needed due to our visual */
244 data
->icon_window
= XCreateWindow( display
, root_window
, 0, 0,
245 GetSystemMetrics( SM_CXICON
),
246 GetSystemMetrics( SM_CYICON
),
249 CWEventMask
| CWBitGravity
| CWBackingStore
| CWColormap
, &attr
);
250 XSaveContext( display
, data
->icon_window
, winContext
, (char *)win
->hwndSelf
);
253 TRACE( "created %lx\n", data
->icon_window
);
254 SetPropA( win
->hwndSelf
, icon_window_atom
, (HANDLE
)data
->icon_window
);
255 return data
->icon_window
;
260 /***********************************************************************
261 * destroy_icon_window
263 inline static void destroy_icon_window( Display
*display
, WND
*win
)
265 struct x11drv_win_data
*data
= win
->pDriverData
;
267 if (!data
->icon_window
) return;
268 if (x11drv_thread_data()->cursor_window
== data
->icon_window
)
269 x11drv_thread_data()->cursor_window
= None
;
271 XDeleteContext( display
, data
->icon_window
, winContext
);
272 XDestroyWindow( display
, data
->icon_window
);
273 data
->icon_window
= 0;
275 RemovePropA( win
->hwndSelf
, icon_window_atom
);
279 /***********************************************************************
282 * Set the icon wm hints
284 static void set_icon_hints( Display
*display
, WND
*wndPtr
, XWMHints
*hints
, HICON hIcon
)
286 X11DRV_WND_DATA
*data
= wndPtr
->pDriverData
;
288 if (data
->hWMIconBitmap
) DeleteObject( data
->hWMIconBitmap
);
289 if (data
->hWMIconMask
) DeleteObject( data
->hWMIconMask
);
290 data
->hWMIconBitmap
= 0;
291 data
->hWMIconMask
= 0;
293 if (!(wndPtr
->dwExStyle
& WS_EX_MANAGED
))
295 destroy_icon_window( display
, wndPtr
);
296 hints
->flags
&= ~(IconPixmapHint
| IconMaskHint
| IconWindowHint
);
300 if (!data
->icon_window
) create_icon_window( display
, wndPtr
);
301 hints
->icon_window
= data
->icon_window
;
302 hints
->flags
= (hints
->flags
& ~(IconPixmapHint
| IconMaskHint
)) | IconWindowHint
;
312 GetIconInfo(hIcon
, &ii
);
314 GetObjectA(ii
.hbmMask
, sizeof(bmMask
), &bmMask
);
317 rcMask
.right
= bmMask
.bmWidth
;
318 rcMask
.bottom
= bmMask
.bmHeight
;
320 hDC
= CreateCompatibleDC(0);
321 hbmOrig
= SelectObject(hDC
, ii
.hbmMask
);
322 InvertRect(hDC
, &rcMask
);
323 SelectObject(hDC
, ii
.hbmColor
); /* force the color bitmap to x11drv mode too */
324 SelectObject(hDC
, hbmOrig
);
327 data
->hWMIconBitmap
= ii
.hbmColor
;
328 data
->hWMIconMask
= ii
.hbmMask
;
330 hints
->icon_pixmap
= X11DRV_BITMAP_Pixmap(data
->hWMIconBitmap
);
331 hints
->icon_mask
= X11DRV_BITMAP_Pixmap(data
->hWMIconMask
);
332 destroy_icon_window( display
, wndPtr
);
333 hints
->flags
= (hints
->flags
& ~IconWindowHint
) | IconPixmapHint
| IconMaskHint
;
338 /***********************************************************************
341 * set the window size hints
343 static void set_size_hints( Display
*display
, WND
*win
)
345 XSizeHints
* size_hints
;
346 struct x11drv_win_data
*data
= win
->pDriverData
;
348 if ((size_hints
= XAllocSizeHints()))
350 size_hints
->win_gravity
= StaticGravity
;
351 size_hints
->x
= data
->whole_rect
.left
;
352 size_hints
->y
= data
->whole_rect
.top
;
353 size_hints
->flags
= PWinGravity
| PPosition
;
355 if (HAS_DLGFRAME( win
->dwStyle
, win
->dwExStyle
))
357 size_hints
->max_width
= data
->whole_rect
.right
- data
->whole_rect
.left
;
358 size_hints
->max_height
= data
->whole_rect
.bottom
- data
->whole_rect
.top
;
359 size_hints
->min_width
= size_hints
->max_width
;
360 size_hints
->min_height
= size_hints
->max_height
;
361 size_hints
->flags
|= PMinSize
| PMaxSize
;
363 XSetWMNormalHints( display
, data
->whole_window
, size_hints
);
369 /***********************************************************************
370 * X11DRV_set_wm_hints
372 * Set the window manager hints for a newly-created window
374 void X11DRV_set_wm_hints( Display
*display
, WND
*win
)
376 struct x11drv_win_data
*data
= win
->pDriverData
;
378 XClassHint
*class_hints
;
389 protocols
[i
++] = x11drv_atom(WM_DELETE_WINDOW
);
390 protocols
[i
++] = x11drv_atom(_NET_WM_PING
);
391 if (use_take_focus
) protocols
[i
++] = x11drv_atom(WM_TAKE_FOCUS
);
392 XChangeProperty( display
, data
->whole_window
, x11drv_atom(WM_PROTOCOLS
),
393 XA_ATOM
, 32, PropModeReplace
, (char *)protocols
, i
);
396 if ((class_hints
= XAllocClassHint()))
398 class_hints
->res_name
= "wine";
399 class_hints
->res_class
= "Wine";
400 XSetClassHint( display
, data
->whole_window
, class_hints
);
401 XFree( class_hints
);
404 /* transient for hint */
407 Window owner_win
= X11DRV_get_whole_window( win
->owner
);
408 XSetTransientForHint( display
, data
->whole_window
, owner_win
);
409 group_leader
= owner_win
;
411 else group_leader
= data
->whole_window
;
414 set_size_hints( display
, win
);
416 /* systray properties (KDE only for now) */
417 if (win
->dwExStyle
& WS_EX_TRAYWINDOW
)
420 XChangeProperty( display
, data
->whole_window
, x11drv_atom(KWM_DOCKWINDOW
),
421 x11drv_atom(KWM_DOCKWINDOW
), 32, PropModeReplace
, (char*)&val
, 1 );
422 XChangeProperty( display
, data
->whole_window
, x11drv_atom(_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR
),
423 XA_WINDOW
, 32, PropModeReplace
, (char*)&data
->whole_window
, 1 );
426 /* set the WM_CLIENT_MACHINE and WM_LOCALE_NAME properties */
427 XSetWMProperties(display
, data
->whole_window
, NULL
, NULL
, NULL
, 0, NULL
, NULL
, NULL
);
428 /* set the pid. together, these properties are needed so the window manager can kill us if we freeze */
430 XChangeProperty(display
, data
->whole_window
, x11drv_atom(_NET_WM_PID
),
431 XA_CARDINAL
, 32, PropModeReplace
, (char *)&i
, 1);
433 /* map WS_EX_TOOLWINDOW to _NET_WM_WINDOW_TYPE_UTILITY */
434 if (win
->dwExStyle
& WS_EX_TOOLWINDOW
)
436 Atom a
= x11drv_atom(_NET_WM_WINDOW_TYPE_UTILITY
);
437 XChangeProperty(display
, data
->whole_window
, x11drv_atom(_NET_WM_WINDOW_TYPE
),
438 XA_ATOM
, 32, PropModeReplace
, (char*)&a
, 1);
441 mwm_hints
.flags
= MWM_HINTS_FUNCTIONS
| MWM_HINTS_DECORATIONS
;
442 mwm_hints
.functions
= 0;
443 if ((win
->dwStyle
& WS_CAPTION
) == WS_CAPTION
) mwm_hints
.functions
|= MWM_FUNC_MOVE
;
444 if (win
->dwStyle
& WS_THICKFRAME
) mwm_hints
.functions
|= MWM_FUNC_MOVE
| MWM_FUNC_RESIZE
;
445 if (win
->dwStyle
& WS_MINIMIZEBOX
) mwm_hints
.functions
|= MWM_FUNC_MINIMIZE
;
446 if (win
->dwStyle
& WS_MAXIMIZEBOX
) mwm_hints
.functions
|= MWM_FUNC_MAXIMIZE
;
447 if (win
->dwStyle
& WS_SYSMENU
) mwm_hints
.functions
|= MWM_FUNC_CLOSE
;
448 mwm_hints
.decorations
= 0;
449 if ((win
->dwStyle
& WS_CAPTION
) == WS_CAPTION
) mwm_hints
.decorations
|= MWM_DECOR_TITLE
;
450 if (win
->dwExStyle
& WS_EX_DLGMODALFRAME
) mwm_hints
.decorations
|= MWM_DECOR_BORDER
;
451 else if (win
->dwStyle
& WS_THICKFRAME
) mwm_hints
.decorations
|= MWM_DECOR_BORDER
| MWM_DECOR_RESIZEH
;
452 else if ((win
->dwStyle
& (WS_DLGFRAME
|WS_BORDER
)) == WS_DLGFRAME
) mwm_hints
.decorations
|= MWM_DECOR_BORDER
;
453 else if (win
->dwStyle
& WS_BORDER
) mwm_hints
.decorations
|= MWM_DECOR_BORDER
;
454 else if (!(win
->dwStyle
& (WS_CHILD
|WS_POPUP
))) mwm_hints
.decorations
|= MWM_DECOR_BORDER
;
455 if (win
->dwStyle
& WS_SYSMENU
) mwm_hints
.decorations
|= MWM_DECOR_MENU
;
456 if (win
->dwStyle
& WS_MINIMIZEBOX
) mwm_hints
.decorations
|= MWM_DECOR_MINIMIZE
;
457 if (win
->dwStyle
& WS_MAXIMIZEBOX
) mwm_hints
.decorations
|= MWM_DECOR_MAXIMIZE
;
459 XChangeProperty( display
, data
->whole_window
, x11drv_atom(_MOTIF_WM_HINTS
),
460 x11drv_atom(_MOTIF_WM_HINTS
), 32, PropModeReplace
,
461 (char*)&mwm_hints
, sizeof(mwm_hints
)/sizeof(long) );
463 XChangeProperty( display
, data
->whole_window
, x11drv_atom(XdndAware
),
464 XA_ATOM
, 32, PropModeReplace
, (unsigned char*)&dndVersion
, 1 );
466 wm_hints
= XAllocWMHints();
472 wm_hints
->flags
= InputHint
| StateHint
| WindowGroupHint
;
473 wm_hints
->input
= !(win
->dwStyle
& WS_DISABLED
);
475 set_icon_hints( display
, win
, wm_hints
, (HICON
)GetClassLongA( win
->hwndSelf
, GCL_HICON
));
477 wm_hints
->initial_state
= (win
->dwStyle
& WS_MINIMIZE
) ? IconicState
: NormalState
;
478 wm_hints
->window_group
= group_leader
;
481 XSetWMHints( display
, data
->whole_window
, wm_hints
);
488 /***********************************************************************
489 * X11DRV_set_iconic_state
491 * Set the X11 iconic state according to the window style.
493 void X11DRV_set_iconic_state( WND
*win
)
495 Display
*display
= thread_display();
496 struct x11drv_win_data
*data
= win
->pDriverData
;
498 BOOL iconic
= IsIconic( win
->hwndSelf
);
502 if (iconic
) XUnmapWindow( display
, data
->client_window
);
503 else if (is_client_window_mapped( win
)) XMapWindow( display
, data
->client_window
);
505 if (!(wm_hints
= XGetWMHints( display
, data
->whole_window
))) wm_hints
= XAllocWMHints();
506 wm_hints
->flags
|= StateHint
| IconPositionHint
;
507 wm_hints
->initial_state
= iconic
? IconicState
: NormalState
;
508 wm_hints
->icon_x
= win
->rectWindow
.left
;
509 wm_hints
->icon_y
= win
->rectWindow
.top
;
510 XSetWMHints( display
, data
->whole_window
, wm_hints
);
512 if (win
->dwStyle
& WS_VISIBLE
)
515 XIconifyWindow( display
, data
->whole_window
, DefaultScreen(display
) );
517 if (!IsRectEmpty( &win
->rectWindow
)) XMapWindow( display
, data
->whole_window
);
525 /***********************************************************************
526 * X11DRV_window_to_X_rect
528 * Convert a rect from client to X window coordinates
530 void X11DRV_window_to_X_rect( WND
*win
, RECT
*rect
)
534 if (!(win
->dwExStyle
& WS_EX_MANAGED
)) return;
535 if (IsRectEmpty( rect
)) return;
537 rc
.top
= rc
.bottom
= rc
.left
= rc
.right
= 0;
539 AdjustWindowRectEx( &rc
, win
->dwStyle
& ~(WS_HSCROLL
|WS_VSCROLL
), FALSE
, win
->dwExStyle
);
541 rect
->left
-= rc
.left
;
542 rect
->right
-= rc
.right
;
544 rect
->bottom
-= rc
.bottom
;
545 if (rect
->top
>= rect
->bottom
) rect
->bottom
= rect
->top
+ 1;
546 if (rect
->left
>= rect
->right
) rect
->right
= rect
->left
+ 1;
550 /***********************************************************************
551 * X11DRV_X_to_window_rect
553 * Opposite of X11DRV_window_to_X_rect
555 void X11DRV_X_to_window_rect( WND
*win
, RECT
*rect
)
557 if (!(win
->dwExStyle
& WS_EX_MANAGED
)) return;
558 if (IsRectEmpty( rect
)) return;
560 AdjustWindowRectEx( rect
, win
->dwStyle
& ~(WS_HSCROLL
|WS_VSCROLL
), FALSE
, win
->dwExStyle
);
562 if (rect
->top
>= rect
->bottom
) rect
->bottom
= rect
->top
+ 1;
563 if (rect
->left
>= rect
->right
) rect
->right
= rect
->left
+ 1;
567 /***********************************************************************
568 * X11DRV_sync_whole_window_position
570 * Synchronize the X whole window position with the Windows one
572 int X11DRV_sync_whole_window_position( Display
*display
, WND
*win
, int zorder
)
574 XWindowChanges changes
;
576 struct x11drv_win_data
*data
= win
->pDriverData
;
577 RECT whole_rect
= win
->rectWindow
;
579 X11DRV_window_to_X_rect( win
, &whole_rect
);
580 mask
= get_window_changes( &changes
, &data
->whole_rect
, &whole_rect
);
584 if (is_window_top_level( win
))
586 /* find window that this one must be after */
587 HWND prev
= GetWindow( win
->hwndSelf
, GW_HWNDPREV
);
588 while (prev
&& !(GetWindowLongW( prev
, GWL_STYLE
) & WS_VISIBLE
))
589 prev
= GetWindow( prev
, GW_HWNDPREV
);
590 if (!prev
) /* top child */
592 changes
.stack_mode
= Above
;
597 /* should use stack_mode Below but most window managers don't get it right */
598 /* so move it above the next one in Z order */
599 HWND next
= GetWindow( win
->hwndSelf
, GW_HWNDNEXT
);
600 while (next
&& !(GetWindowLongW( next
, GWL_STYLE
) & WS_VISIBLE
))
601 next
= GetWindow( next
, GW_HWNDNEXT
);
604 changes
.stack_mode
= Above
;
605 changes
.sibling
= X11DRV_get_whole_window(next
);
606 mask
|= CWStackMode
| CWSibling
;
612 HWND next
= GetWindow( win
->hwndSelf
, GW_HWNDNEXT
);
614 if (win
->parent
== GetDesktopWindow() &&
615 root_window
!= DefaultRootWindow(display
))
617 /* in desktop mode we need the sibling to belong to the same process */
620 WND
*ptr
= WIN_GetPtr( next
);
621 if (ptr
!= WND_OTHER_PROCESS
)
623 WIN_ReleasePtr( ptr
);
626 next
= GetWindow( next
, GW_HWNDNEXT
);
630 if (!next
) /* bottom child */
632 changes
.stack_mode
= Below
;
637 changes
.stack_mode
= Above
;
638 changes
.sibling
= X11DRV_get_whole_window(next
);
639 mask
|= CWStackMode
| CWSibling
;
644 data
->whole_rect
= whole_rect
;
648 TRACE( "setting win %lx pos %ld,%ld,%ldx%ld after %lx changes=%x\n",
649 data
->whole_window
, whole_rect
.left
, whole_rect
.top
,
650 whole_rect
.right
- whole_rect
.left
, whole_rect
.bottom
- whole_rect
.top
,
651 changes
.sibling
, mask
);
653 XSync( gdi_display
, False
); /* flush graphics operations before moving the window */
654 if (is_window_top_level( win
))
656 if (mask
& (CWWidth
|CWHeight
)) set_size_hints( display
, win
);
657 XReconfigureWMWindow( display
, data
->whole_window
,
658 DefaultScreen(display
), mask
, &changes
);
660 else XConfigureWindow( display
, data
->whole_window
, mask
, &changes
);
667 /***********************************************************************
668 * X11DRV_sync_client_window_position
670 * Synchronize the X client window position with the Windows one
672 int X11DRV_sync_client_window_position( Display
*display
, WND
*win
)
674 XWindowChanges changes
;
676 struct x11drv_win_data
*data
= win
->pDriverData
;
677 RECT client_rect
= win
->rectClient
;
679 OffsetRect( &client_rect
, -data
->whole_rect
.left
, -data
->whole_rect
.top
);
681 if ((mask
= get_window_changes( &changes
, &data
->client_rect
, &client_rect
)))
683 BOOL was_mapped
= is_client_window_mapped( win
);
685 TRACE( "setting win %lx pos %ld,%ld,%ldx%ld (was %ld,%ld,%ldx%ld) after %lx changes=%x\n",
686 data
->client_window
, client_rect
.left
, client_rect
.top
,
687 client_rect
.right
- client_rect
.left
, client_rect
.bottom
- client_rect
.top
,
688 data
->client_rect
.left
, data
->client_rect
.top
,
689 data
->client_rect
.right
- data
->client_rect
.left
,
690 data
->client_rect
.bottom
- data
->client_rect
.top
,
691 changes
.sibling
, mask
);
692 data
->client_rect
= client_rect
;
694 XSync( gdi_display
, False
); /* flush graphics operations before moving the window */
695 if (was_mapped
&& !is_client_window_mapped( win
))
696 XUnmapWindow( display
, data
->client_window
);
697 XConfigureWindow( display
, data
->client_window
, mask
, &changes
);
698 if (!was_mapped
&& is_client_window_mapped( win
))
699 XMapWindow( display
, data
->client_window
);
706 /***********************************************************************
707 * X11DRV_register_window
709 * Associate an X window to a HWND.
711 void X11DRV_register_window( Display
*display
, HWND hwnd
, struct x11drv_win_data
*data
)
714 XSaveContext( display
, data
->whole_window
, winContext
, (char *)hwnd
);
715 XSaveContext( display
, data
->client_window
, winContext
, (char *)hwnd
);
720 /**********************************************************************
723 static void create_desktop( Display
*display
, WND
*wndPtr
)
725 X11DRV_WND_DATA
*data
= wndPtr
->pDriverData
;
728 winContext
= XUniqueContext();
729 XInternAtoms( display
, (char **)atom_names
, NB_XATOMS
- FIRST_XATOM
, False
, X11DRV_Atoms
);
732 whole_window_atom
= MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_whole_window" ));
733 client_window_atom
= MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_client_window" ));
734 icon_window_atom
= MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_icon_window" ));
736 data
->whole_window
= data
->client_window
= root_window
;
737 data
->whole_rect
= data
->client_rect
= wndPtr
->rectWindow
;
739 SetPropA( wndPtr
->hwndSelf
, whole_window_atom
, (HANDLE
)root_window
);
740 SetPropA( wndPtr
->hwndSelf
, client_window_atom
, (HANDLE
)root_window
);
741 SetPropA( wndPtr
->hwndSelf
, "__wine_x11_visual_id", (HANDLE
)XVisualIDFromVisual(visual
) );
743 X11DRV_InitClipboard();
745 if (root_window
!= DefaultRootWindow(display
)) X11DRV_create_desktop_thread();
749 /**********************************************************************
750 * create_whole_window
752 * Create the whole X window for a given window
754 static Window
create_whole_window( Display
*display
, WND
*win
)
756 struct x11drv_win_data
*data
= win
->pDriverData
;
758 XSetWindowAttributes attr
;
761 BOOL is_top_level
= is_window_top_level( win
);
763 rect
= win
->rectWindow
;
764 X11DRV_window_to_X_rect( win
, &rect
);
766 if (!(cx
= rect
.right
- rect
.left
)) cx
= 1;
767 if (!(cy
= rect
.bottom
- rect
.top
)) cy
= 1;
769 parent
= X11DRV_get_client_window( win
->parent
);
773 mask
= get_window_attributes( display
, win
, &attr
);
775 /* set the attributes that don't change over the lifetime of the window */
776 attr
.bit_gravity
= ForgetGravity
;
777 attr
.win_gravity
= NorthWestGravity
;
778 attr
.backing_store
= NotUseful
/*WhenMapped*/;
779 mask
|= CWBitGravity
| CWWinGravity
| CWBackingStore
;
781 data
->whole_rect
= rect
;
782 data
->whole_window
= XCreateWindow( display
, parent
, rect
.left
, rect
.top
, cx
, cy
,
783 0, screen_depth
, InputOutput
, visual
,
786 if (!data
->whole_window
)
794 XIM xim
= x11drv_thread_data()->xim
;
795 if (xim
) data
->xic
= XCreateIC( xim
,
796 XNInputStyle
, XIMPreeditNothing
| XIMStatusNothing
,
797 XNClientWindow
, data
->whole_window
,
798 XNFocusWindow
, data
->whole_window
,
802 /* non-maximized child must be at bottom of Z order */
803 if ((win
->dwStyle
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
805 XWindowChanges changes
;
806 changes
.stack_mode
= Below
;
807 XConfigureWindow( display
, data
->whole_window
, CWStackMode
, &changes
);
812 if (is_top_level
) X11DRV_set_wm_hints( display
, win
);
814 return data
->whole_window
;
818 /**********************************************************************
819 * create_client_window
821 * Create the client window for a given window
823 static Window
create_client_window( Display
*display
, WND
*win
)
825 struct x11drv_win_data
*data
= win
->pDriverData
;
826 RECT rect
= data
->whole_rect
;
827 XSetWindowAttributes attr
;
829 OffsetRect( &rect
, -data
->whole_rect
.left
, -data
->whole_rect
.top
);
830 data
->client_rect
= rect
;
832 attr
.event_mask
= (ExposureMask
| PointerMotionMask
|
833 ButtonPressMask
| ButtonReleaseMask
| EnterWindowMask
);
834 attr
.bit_gravity
= (win
->clsStyle
& (CS_VREDRAW
| CS_HREDRAW
)) ?
835 ForgetGravity
: NorthWestGravity
;
836 attr
.backing_store
= NotUseful
/*WhenMapped*/;
839 data
->client_window
= XCreateWindow( display
, data
->whole_window
, 0, 0,
840 max( rect
.right
- rect
.left
, 1 ),
841 max( rect
.bottom
- rect
.top
, 1 ),
844 CWEventMask
| CWBitGravity
| CWBackingStore
, &attr
);
845 if (data
->client_window
&& is_client_window_mapped( win
))
846 XMapWindow( display
, data
->client_window
);
848 return data
->client_window
;
852 /*****************************************************************
853 * SetWindowText (X11DRV.@)
855 BOOL
X11DRV_SetWindowText( HWND hwnd
, LPCWSTR text
)
857 Display
*display
= thread_display();
864 if ((win
= X11DRV_get_whole_window( hwnd
)))
866 /* allocate new buffer for window text */
867 count
= WideCharToMultiByte(CP_UNIXCP
, 0, text
, -1, NULL
, 0, NULL
, NULL
);
868 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, count
)))
870 ERR("Not enough memory for window text\n");
873 WideCharToMultiByte(CP_UNIXCP
, 0, text
, -1, buffer
, count
, NULL
, NULL
);
875 count
= WideCharToMultiByte(CP_UTF8
, 0, text
, strlenW(text
), NULL
, 0, NULL
, NULL
);
876 if (!(utf8_buffer
= HeapAlloc( GetProcessHeap(), 0, count
)))
878 ERR("Not enough memory for window text in UTF-8\n");
881 WideCharToMultiByte(CP_UTF8
, 0, text
, strlenW(text
), utf8_buffer
, count
, NULL
, NULL
);
884 if (XmbTextListToTextProperty( display
, &buffer
, 1, XStdICCTextStyle
, &prop
) == Success
)
886 XSetWMName( display
, win
, &prop
);
887 XSetWMIconName( display
, win
, &prop
);
891 Implements a NET_WM UTF-8 title. It should be without a trailing \0,
892 according to the standard
893 ( http://www.pps.jussieu.fr/~jch/software/UTF8_STRING/UTF8_STRING.text ).
895 XChangeProperty( display
, win
, x11drv_atom(_NET_WM_NAME
), x11drv_atom(UTF8_STRING
),
896 8, PropModeReplace
, (unsigned char *) utf8_buffer
, count
);
899 HeapFree( GetProcessHeap(), 0, utf8_buffer
);
900 HeapFree( GetProcessHeap(), 0, buffer
);
906 /***********************************************************************
907 * DestroyWindow (X11DRV.@)
909 BOOL
X11DRV_DestroyWindow( HWND hwnd
)
911 struct x11drv_thread_data
*thread_data
= x11drv_thread_data();
912 Display
*display
= thread_data
->display
;
913 WND
*wndPtr
= WIN_GetPtr( hwnd
);
914 X11DRV_WND_DATA
*data
= wndPtr
->pDriverData
;
916 if (!data
) goto done
;
918 if (data
->whole_window
)
920 TRACE( "win %p xwin %lx/%lx\n", hwnd
, data
->whole_window
, data
->client_window
);
921 if (thread_data
->cursor_window
== data
->whole_window
) thread_data
->cursor_window
= None
;
922 if (thread_data
->last_focus
== hwnd
) thread_data
->last_focus
= 0;
924 XSync( gdi_display
, False
); /* flush any reference to this drawable in GDI queue */
925 XDeleteContext( display
, data
->whole_window
, winContext
);
926 XDeleteContext( display
, data
->client_window
, winContext
);
927 XDestroyWindow( display
, data
->whole_window
); /* this destroys client too */
930 XUnsetICFocus( data
->xic
);
931 XDestroyIC( data
->xic
);
933 destroy_icon_window( display
, wndPtr
);
937 if (data
->hWMIconBitmap
) DeleteObject( data
->hWMIconBitmap
);
938 if (data
->hWMIconMask
) DeleteObject( data
->hWMIconMask
);
939 HeapFree( GetProcessHeap(), 0, data
);
940 wndPtr
->pDriverData
= NULL
;
942 WIN_ReleasePtr( wndPtr
);
947 /**********************************************************************
948 * CreateWindow (X11DRV.@)
950 BOOL
X11DRV_CreateWindow( HWND hwnd
, CREATESTRUCTA
*cs
, BOOL unicode
)
952 Display
*display
= thread_display();
954 struct x11drv_win_data
*data
;
961 ERR( "invalid window width %d\n", cs
->cx
);
966 ERR( "invalid window height %d\n", cs
->cx
);
970 if (!(data
= HeapAlloc(GetProcessHeap(), 0, sizeof(*data
)))) return FALSE
;
971 data
->whole_window
= 0;
972 data
->client_window
= 0;
973 data
->icon_window
= 0;
975 data
->hWMIconBitmap
= 0;
976 data
->hWMIconMask
= 0;
978 wndPtr
= WIN_GetPtr( hwnd
);
979 wndPtr
->pDriverData
= data
;
981 /* initialize the dimensions before sending WM_GETMINMAXINFO */
982 SetRect( &rect
, cs
->x
, cs
->y
, cs
->x
+ cs
->cx
, cs
->y
+ cs
->cy
);
983 WIN_SetRectangles( hwnd
, &rect
, &rect
);
987 create_desktop( display
, wndPtr
);
988 WIN_ReleasePtr( wndPtr
);
992 if (!create_whole_window( display
, wndPtr
)) goto failed
;
993 if (!create_client_window( display
, wndPtr
)) goto failed
;
995 XSync( display
, False
);
998 SetPropA( hwnd
, whole_window_atom
, (HANDLE
)data
->whole_window
);
999 SetPropA( hwnd
, client_window_atom
, (HANDLE
)data
->client_window
);
1001 /* Call the WH_CBT hook */
1003 cbtc
.hwndInsertAfter
= HWND_TOP
;
1004 if (HOOK_CallHooks( WH_CBT
, HCBT_CREATEWND
, (WPARAM
)hwnd
, (LPARAM
)&cbtc
, unicode
))
1006 TRACE("CBT-hook returned !0\n");
1010 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
1011 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
1013 POINT maxSize
, maxPos
, minTrack
, maxTrack
;
1015 WIN_ReleasePtr( wndPtr
);
1016 WINPOS_GetMinMaxInfo( hwnd
, &maxSize
, &maxPos
, &minTrack
, &maxTrack
);
1017 if (maxSize
.x
< cs
->cx
) cs
->cx
= maxSize
.x
;
1018 if (maxSize
.y
< cs
->cy
) cs
->cy
= maxSize
.y
;
1019 if (cs
->cx
< minTrack
.x
) cs
->cx
= minTrack
.x
;
1020 if (cs
->cy
< minTrack
.y
) cs
->cy
= minTrack
.y
;
1021 if (cs
->cx
< 0) cs
->cx
= 0;
1022 if (cs
->cy
< 0) cs
->cy
= 0;
1024 if (!(wndPtr
= WIN_GetPtr( hwnd
))) return FALSE
;
1025 SetRect( &rect
, cs
->x
, cs
->y
, cs
->x
+ cs
->cx
, cs
->y
+ cs
->cy
);
1026 WIN_SetRectangles( hwnd
, &rect
, &rect
);
1027 X11DRV_sync_whole_window_position( display
, wndPtr
, 0 );
1029 WIN_ReleasePtr( wndPtr
);
1031 /* send WM_NCCREATE */
1032 TRACE( "hwnd %p cs %d,%d %dx%d\n", hwnd
, cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
1034 ret
= SendMessageW( hwnd
, WM_NCCREATE
, 0, (LPARAM
)cs
);
1036 ret
= SendMessageA( hwnd
, WM_NCCREATE
, 0, (LPARAM
)cs
);
1039 WARN("aborted by WM_xxCREATE!\n");
1043 if (!(wndPtr
= WIN_GetPtr(hwnd
))) return FALSE
;
1045 X11DRV_sync_window_style( display
, wndPtr
);
1047 /* send WM_NCCALCSIZE */
1048 rect
= wndPtr
->rectWindow
;
1049 WIN_ReleasePtr( wndPtr
);
1050 SendMessageW( hwnd
, WM_NCCALCSIZE
, FALSE
, (LPARAM
)&rect
);
1052 if (!(wndPtr
= WIN_GetPtr(hwnd
))) return FALSE
;
1053 if (rect
.left
> rect
.right
|| rect
.top
> rect
.bottom
) rect
= wndPtr
->rectWindow
;
1054 WIN_SetRectangles( hwnd
, &wndPtr
->rectWindow
, &rect
);
1055 X11DRV_sync_client_window_position( display
, wndPtr
);
1056 X11DRV_register_window( display
, hwnd
, data
);
1058 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",
1059 hwnd
, wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
,
1060 wndPtr
->rectWindow
.right
, wndPtr
->rectWindow
.bottom
,
1061 wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
,
1062 wndPtr
->rectClient
.right
, wndPtr
->rectClient
.bottom
,
1063 data
->whole_rect
.left
, data
->whole_rect
.top
,
1064 data
->whole_rect
.right
, data
->whole_rect
.bottom
,
1065 data
->client_rect
.left
, data
->client_rect
.top
,
1066 data
->client_rect
.right
, data
->client_rect
.bottom
,
1067 (unsigned int)data
->whole_window
, (unsigned int)data
->client_window
);
1069 if ((wndPtr
->dwStyle
& (WS_CHILD
|WS_MAXIMIZE
)) == WS_CHILD
)
1070 WIN_LinkWindow( hwnd
, wndPtr
->parent
, HWND_BOTTOM
);
1072 WIN_LinkWindow( hwnd
, wndPtr
->parent
, HWND_TOP
);
1074 WIN_ReleasePtr( wndPtr
);
1077 ret
= (SendMessageW( hwnd
, WM_CREATE
, 0, (LPARAM
)cs
) != -1);
1079 ret
= (SendMessageA( hwnd
, WM_CREATE
, 0, (LPARAM
)cs
) != -1);
1083 WIN_UnlinkWindow( hwnd
);
1087 /* Send the size messages */
1089 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return FALSE
;
1090 if (!(wndPtr
->flags
& WIN_NEED_SIZE
))
1092 /* send it anyway */
1093 if (((wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
) <0)
1094 ||((wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
)<0))
1095 WARN("sending bogus WM_SIZE message 0x%08lx\n",
1096 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
1097 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
1098 SendMessageW( hwnd
, WM_SIZE
, SIZE_RESTORED
,
1099 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
1100 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
1101 SendMessageW( hwnd
, WM_MOVE
, 0,
1102 MAKELONG( wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
) );
1105 /* Show the window, maximizing or minimizing if needed */
1107 if (wndPtr
->dwStyle
& (WS_MINIMIZE
| WS_MAXIMIZE
))
1109 extern UINT
WINPOS_MinMaximize( HWND hwnd
, UINT cmd
, LPRECT rect
); /*FIXME*/
1112 UINT swFlag
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? SW_MINIMIZE
: SW_MAXIMIZE
;
1113 WIN_SetStyle( hwnd
, wndPtr
->dwStyle
& ~(WS_MAXIMIZE
| WS_MINIMIZE
) );
1114 WINPOS_MinMaximize( hwnd
, swFlag
, &newPos
);
1115 swFlag
= ((wndPtr
->dwStyle
& WS_CHILD
) || GetActiveWindow())
1116 ? SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
1117 : SWP_NOZORDER
| SWP_FRAMECHANGED
;
1118 SetWindowPos( hwnd
, 0, newPos
.left
, newPos
.top
,
1119 newPos
.right
, newPos
.bottom
, swFlag
);
1122 /* if the window was made visible set create struct flag so that
1123 * we do a proper ShowWindow later on */
1124 if (wndPtr
->dwStyle
& WS_VISIBLE
) cs
->style
|= WS_VISIBLE
;
1126 WIN_ReleaseWndPtr( wndPtr
);
1131 X11DRV_DestroyWindow( hwnd
);
1132 if (wndPtr
) WIN_ReleasePtr( wndPtr
);
1137 /***********************************************************************
1138 * X11DRV_get_client_window
1140 * Return the X window associated with the client area of a window
1142 Window
X11DRV_get_client_window( HWND hwnd
)
1145 WND
*win
= WIN_GetPtr( hwnd
);
1147 if (win
== WND_OTHER_PROCESS
)
1148 return (Window
)GetPropA( hwnd
, client_window_atom
);
1152 struct x11drv_win_data
*data
= win
->pDriverData
;
1153 ret
= data
->client_window
;
1154 WIN_ReleasePtr( win
);
1160 /***********************************************************************
1161 * X11DRV_get_whole_window
1163 * Return the X window associated with the full area of a window
1165 Window
X11DRV_get_whole_window( HWND hwnd
)
1168 WND
*win
= WIN_GetPtr( hwnd
);
1170 if (win
== WND_OTHER_PROCESS
)
1171 return (Window
)GetPropA( hwnd
, whole_window_atom
);
1175 struct x11drv_win_data
*data
= win
->pDriverData
;
1176 ret
= data
->whole_window
;
1177 WIN_ReleasePtr( win
);
1183 /***********************************************************************
1186 * Return the X input context associated with a window
1188 XIC
X11DRV_get_ic( HWND hwnd
)
1191 WND
*win
= WIN_GetPtr( hwnd
);
1193 if (win
&& win
!= WND_OTHER_PROCESS
)
1195 struct x11drv_win_data
*data
= win
->pDriverData
;
1197 WIN_ReleasePtr( win
);
1203 /*****************************************************************
1204 * SetParent (X11DRV.@)
1206 HWND
X11DRV_SetParent( HWND hwnd
, HWND parent
)
1208 Display
*display
= thread_display();
1212 /* Windows hides the window first, then shows it again
1213 * including the WM_SHOWWINDOW messages and all */
1214 BOOL was_visible
= ShowWindow( hwnd
, SW_HIDE
);
1216 if (!IsWindow( parent
)) return 0;
1217 if (!(wndPtr
= WIN_GetPtr(hwnd
)) || wndPtr
== WND_OTHER_PROCESS
) return 0;
1219 retvalue
= wndPtr
->parent
; /* old parent */
1220 if (parent
!= retvalue
)
1222 struct x11drv_win_data
*data
= wndPtr
->pDriverData
;
1224 WIN_LinkWindow( hwnd
, parent
, HWND_TOP
);
1226 if (parent
!= GetDesktopWindow()) /* a child window */
1228 if (!(wndPtr
->dwStyle
& WS_CHILD
))
1230 HMENU menu
= (HMENU
)SetWindowLongW( hwnd
, GWL_ID
, 0 );
1231 if (menu
) DestroyMenu( menu
);
1235 if (is_window_top_level( wndPtr
)) X11DRV_set_wm_hints( display
, wndPtr
);
1237 X11DRV_sync_window_style( display
, wndPtr
);
1238 XReparentWindow( display
, data
->whole_window
, X11DRV_get_client_window(parent
),
1239 data
->whole_rect
.left
, data
->whole_rect
.top
);
1240 wine_tsx11_unlock();
1242 WIN_ReleasePtr( wndPtr
);
1244 /* SetParent additionally needs to make hwnd the topmost window
1245 in the x-order and send the expected WM_WINDOWPOSCHANGING and
1246 WM_WINDOWPOSCHANGED notification messages.
1248 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0,
1249 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOSIZE
| (was_visible
? SWP_SHOWWINDOW
: 0) );
1250 /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
1251 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
1257 /*****************************************************************
1258 * SetFocus (X11DRV.@)
1261 * Explicit colormap management seems to work only with OLVWM.
1263 void X11DRV_SetFocus( HWND hwnd
)
1265 Display
*display
= thread_display();
1266 XWindowAttributes win_attr
;
1269 /* Only mess with the X focus if there's */
1270 /* no desktop window and if the window is not managed by the WM. */
1271 if (root_window
!= DefaultRootWindow(display
)) return;
1273 if (!hwnd
) /* If setting the focus to 0, uninstall the colormap */
1276 if (X11DRV_PALETTE_PaletteFlags
& X11DRV_PALETTE_PRIVATE
)
1277 XUninstallColormap( display
, X11DRV_PALETTE_PaletteXColormap
);
1278 wine_tsx11_unlock();
1282 hwnd
= GetAncestor( hwnd
, GA_ROOT
);
1283 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_MANAGED
) return;
1284 if (!(win
= X11DRV_get_whole_window( hwnd
))) return;
1286 /* Set X focus and install colormap */
1288 if (XGetWindowAttributes( display
, win
, &win_attr
) &&
1289 (win_attr
.map_state
== IsViewable
))
1291 /* If window is not viewable, don't change anything */
1293 /* we must not use CurrentTime (ICCCM), so try to use last message time instead */
1294 /* FIXME: this is not entirely correct */
1295 XSetInputFocus( display
, win
, RevertToParent
,
1296 /*CurrentTime*/ GetMessageTime() + X11DRV_server_startticks
);
1297 if (X11DRV_PALETTE_PaletteFlags
& X11DRV_PALETTE_PRIVATE
)
1298 XInstallColormap( display
, X11DRV_PALETTE_PaletteXColormap
);
1300 wine_tsx11_unlock();
1304 /**********************************************************************
1305 * SetWindowIcon (X11DRV.@)
1307 * hIcon or hIconSm has changed (or is being initialised for the
1308 * first time). Complete the X11 driver-specific initialisation
1309 * and set the window hints.
1311 * This is not entirely correct, may need to create
1312 * an icon window and set the pixmap as a background
1314 void X11DRV_SetWindowIcon( HWND hwnd
, UINT type
, HICON icon
)
1317 Display
*display
= thread_display();
1319 if (type
!= ICON_BIG
) return; /* nothing to do here */
1321 if (!(wndPtr
= WIN_GetPtr( hwnd
)) || wndPtr
== WND_OTHER_PROCESS
) return;
1323 if (wndPtr
->dwExStyle
& WS_EX_MANAGED
)
1325 Window win
= get_whole_window(wndPtr
);
1329 if (!(wm_hints
= XGetWMHints( display
, win
))) wm_hints
= XAllocWMHints();
1330 wine_tsx11_unlock();
1333 set_icon_hints( display
, wndPtr
, wm_hints
, icon
);
1335 XSetWMHints( display
, win
, wm_hints
);
1337 wine_tsx11_unlock();
1340 WIN_ReleasePtr( wndPtr
);