4 * Copyright 1993, 1994, 1995, 1996 Alexandre Julliard
6 * 1995, 1996 Alex Korobka
11 #ifndef X_DISPLAY_MISSING
13 #include <X11/Xatom.h>
21 #include "debugtools.h"
31 #include "wine/winuser16.h"
33 DEFAULT_DEBUG_CHANNEL(win)
35 /* Some useful macros */
36 #define HAS_DLGFRAME(style,exStyle) \
37 ((!((style) & WS_THICKFRAME)) && (((style) & WS_DLGFRAME) || ((exStyle) & WS_EX_DLGMODALFRAME)))
39 /**********************************************************************/
41 extern Cursor X11DRV_MOUSE_XCursor; /* Current X cursor */
42 extern BOOL X11DRV_CreateBitmap( HBITMAP );
43 extern Pixmap X11DRV_BITMAP_Pixmap( HBITMAP );
45 /**********************************************************************/
47 /* X context to associate a hwnd to an X window */
48 XContext winContext = 0;
50 Atom wmProtocols = None;
51 Atom wmDeleteWindow = None;
52 Atom dndProtocol = None;
53 Atom dndSelection = None;
54 Atom wmChangeState = None;
56 /***********************************************************************
57 * X11DRV_WND_GetXWindow
59 * Return the X window associated to a window.
61 Window X11DRV_WND_GetXWindow(WND *wndPtr)
63 return wndPtr && wndPtr->pDriverData ?
64 ((X11DRV_WND_DATA *) wndPtr->pDriverData)->window : 0;
67 /***********************************************************************
68 * X11DRV_WND_FindXWindow
70 * Return the the first X window associated to a window chain.
72 Window X11DRV_WND_FindXWindow(WND *wndPtr)
75 !((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
76 wndPtr = wndPtr->parent;
78 ((X11DRV_WND_DATA *) wndPtr->pDriverData)->window : 0;
81 /***********************************************************************
82 * X11DRV_WND_GetXScreen
84 * Return the X screen associated to the window.
86 Screen *X11DRV_WND_GetXScreen(WND *wndPtr)
88 while(wndPtr->parent) wndPtr = wndPtr->parent;
89 return X11DRV_DESKTOP_GetXScreen((struct tagDESKTOP *) wndPtr->wExtra);
92 /***********************************************************************
93 * X11DRV_WND_GetXRootWindow
95 * Return the X display associated to the window.
97 Window X11DRV_WND_GetXRootWindow(WND *wndPtr)
99 while(wndPtr->parent) wndPtr = wndPtr->parent;
100 return X11DRV_DESKTOP_GetXRootWindow((struct tagDESKTOP *) wndPtr->wExtra);
103 /***********************************************************************
104 * X11DRV_WND_RegisterWindow
106 * Associate an X window to a HWND.
108 static void X11DRV_WND_RegisterWindow(WND *wndPtr)
110 TSXSetWMProtocols( display, X11DRV_WND_GetXWindow(wndPtr), &wmDeleteWindow, 1 );
112 if (!winContext) winContext = TSXUniqueContext();
113 TSXSaveContext( display, X11DRV_WND_GetXWindow(wndPtr),
114 winContext, (char *) wndPtr->hwndSelf );
117 /**********************************************************************
118 * X11DRV_WND_Initialize
120 void X11DRV_WND_Initialize(WND *wndPtr)
122 X11DRV_WND_DATA *pWndDriverData =
123 (X11DRV_WND_DATA *) HeapAlloc(SystemHeap, 0, sizeof(X11DRV_WND_DATA));
125 wndPtr->pDriverData = (void *) pWndDriverData;
127 pWndDriverData->window = 0;
130 /**********************************************************************
131 * X11DRV_WND_Finalize
133 void X11DRV_WND_Finalize(WND *wndPtr)
135 X11DRV_WND_DATA *pWndDriverData =
136 (X11DRV_WND_DATA *) wndPtr->pDriverData;
138 if (!wndPtr->pDriverData) {
139 ERR("Trying to destroy window again. Not good.\n");
142 if(pWndDriverData->window)
145 "WND destroyed without destroying "
146 "the associated X Window (%ld)\n",
147 pWndDriverData->window
150 HeapFree(SystemHeap, 0, wndPtr->pDriverData);
151 wndPtr->pDriverData = NULL;
154 /**********************************************************************
155 * X11DRV_WND_CreateDesktopWindow
157 BOOL X11DRV_WND_CreateDesktopWindow(WND *wndPtr, CLASS *classPtr, BOOL bUnicode)
159 if (wmProtocols == None)
160 wmProtocols = TSXInternAtom( display, "WM_PROTOCOLS", True );
161 if (wmDeleteWindow == None)
162 wmDeleteWindow = TSXInternAtom( display, "WM_DELETE_WINDOW", True );
163 if( dndProtocol == None )
164 dndProtocol = TSXInternAtom( display, "DndProtocol" , False );
165 if( dndSelection == None )
166 dndSelection = TSXInternAtom( display, "DndSelection" , False );
167 if( wmChangeState == None )
168 wmChangeState = TSXInternAtom (display, "WM_CHANGE_STATE", False);
170 ((X11DRV_WND_DATA *) wndPtr->pDriverData)->window =
171 X11DRV_WND_GetXRootWindow( wndPtr );
172 X11DRV_WND_RegisterWindow( wndPtr );
178 /**********************************************************************
179 * X11DRV_WND_CreateWindow
181 BOOL X11DRV_WND_CreateWindow(WND *wndPtr, CLASS *classPtr, CREATESTRUCTA *cs, BOOL bUnicode)
183 /* Create the X window (only for top-level windows, and then only */
184 /* when there's no desktop window) */
186 if (!(cs->style & WS_CHILD) &&
187 (X11DRV_WND_GetXRootWindow(wndPtr) == DefaultRootWindow(display)))
191 XSetWindowAttributes win_attr;
193 /* Create "managed" windows only if a title bar or resizable */
194 /* frame is required. */
195 if (WIN_WindowNeedsWMBorder(cs->style, cs->dwExStyle))
197 win_attr.event_mask = ExposureMask | KeyPressMask |
198 KeyReleaseMask | PointerMotionMask |
199 ButtonPressMask | ButtonReleaseMask |
200 FocusChangeMask | StructureNotifyMask;
201 win_attr.override_redirect = FALSE;
202 wndPtr->flags |= WIN_MANAGED;
206 win_attr.event_mask = ExposureMask | KeyPressMask |
207 KeyReleaseMask | PointerMotionMask |
208 ButtonPressMask | ButtonReleaseMask |
210 win_attr.override_redirect = TRUE;
212 wndPtr->flags |= WIN_NATIVE;
214 win_attr.bit_gravity = (classPtr->style & (CS_VREDRAW | CS_HREDRAW)) ? BGForget : BGNorthWest;
215 win_attr.colormap = X11DRV_PALETTE_PaletteXColormap;
216 win_attr.backing_store = Options.backingstore ? WhenMapped : NotUseful;
217 win_attr.save_under = ((classPtr->style & CS_SAVEBITS) != 0);
218 win_attr.cursor = X11DRV_MOUSE_XCursor;
220 ((X11DRV_WND_DATA *) wndPtr->pDriverData)->hWMIconBitmap = 0;
221 ((X11DRV_WND_DATA *) wndPtr->pDriverData)->bit_gravity = win_attr.bit_gravity;
222 ((X11DRV_WND_DATA *) wndPtr->pDriverData)->window =
223 TSXCreateWindow( display,
224 X11DRV_WND_GetXRootWindow(wndPtr),
225 cs->x, cs->y, cs->cx, cs->cy,
227 InputOutput, CopyFromParent,
228 CWEventMask | CWOverrideRedirect |
229 CWColormap | CWCursor | CWSaveUnder |
230 CWBackingStore | CWBitGravity,
233 if(!(wGroupLeader = X11DRV_WND_GetXWindow(wndPtr)))
236 if (wndPtr->flags & WIN_MANAGED)
238 XClassHint *class_hints = TSXAllocClassHint();
239 XSizeHints* size_hints = TSXAllocSizeHints();
243 class_hints->res_name = "wineManaged";
244 class_hints->res_class = "Wine";
245 TSXSetClassHint( display, ((X11DRV_WND_DATA *) wndPtr->pDriverData)->window, class_hints );
246 TSXFree (class_hints);
251 size_hints->win_gravity = StaticGravity;
252 size_hints->flags = PWinGravity;
254 if (HAS_DLGFRAME(cs->style,cs->dwExStyle))
256 size_hints->min_width = size_hints->max_width = cs->cx;
257 size_hints->min_height = size_hints->max_height = cs->cy;
258 size_hints->flags |= PMinSize | PMaxSize;
261 TSXSetWMSizeHints( display, X11DRV_WND_GetXWindow(wndPtr),
262 size_hints, XA_WM_NORMAL_HINTS );
267 if (cs->hwndParent) /* Get window owner */
270 WND *tmpWnd = WIN_FindWndPtr(cs->hwndParent);
272 w = X11DRV_WND_FindXWindow( tmpWnd );
275 TSXSetTransientForHint( display, X11DRV_WND_GetXWindow(wndPtr), w );
278 WIN_ReleaseWndPtr(tmpWnd);
281 wm_hints = TSXAllocWMHints();
283 wm_hints->flags = InputHint | StateHint | WindowGroupHint;
284 wm_hints->input = True;
286 if( wndPtr->flags & WIN_MANAGED )
288 if( wndPtr->class->hIcon )
292 if( (ptr = (CURSORICONINFO *)GlobalLock16( wndPtr->class->hIcon )) )
294 /* This is not entirely correct, may need to create
295 * an icon window and set the pixmap as a background */
297 HBITMAP hBitmap = CreateBitmap( ptr->nWidth, ptr->nHeight,
298 ptr->bPlanes, ptr->bBitsPerPixel, (char *)(ptr + 1) +
299 ptr->nHeight * BITMAP_GetWidthBytes(ptr->nWidth,1) );
303 ((X11DRV_WND_DATA *) wndPtr->pDriverData)->hWMIconBitmap = hBitmap;
304 X11DRV_CreateBitmap( hBitmap );
305 wm_hints->flags |= IconPixmapHint;
306 wm_hints->icon_pixmap = X11DRV_BITMAP_Pixmap( hBitmap );
310 wm_hints->initial_state = (wndPtr->dwStyle & WS_MINIMIZE)
311 ? IconicState : NormalState;
314 wm_hints->initial_state = NormalState;
315 wm_hints->window_group = wGroupLeader;
317 TSXSetWMHints( display, X11DRV_WND_GetXWindow(wndPtr), wm_hints );
320 X11DRV_WND_RegisterWindow( wndPtr );
325 /***********************************************************************
326 * X11DRV_WND_DestroyWindow
328 BOOL X11DRV_WND_DestroyWindow(WND *wndPtr)
331 if ((w = X11DRV_WND_GetXWindow(wndPtr)))
334 TSXDeleteContext( display, w, winContext );
335 TSXDestroyWindow( display, w );
336 while( TSXCheckWindowEvent(display, w, NoEventMask, &xe) );
338 ((X11DRV_WND_DATA *) wndPtr->pDriverData)->window = None;
339 if( ((X11DRV_WND_DATA *) wndPtr->pDriverData)->hWMIconBitmap )
341 DeleteObject( ((X11DRV_WND_DATA *) wndPtr->pDriverData)->hWMIconBitmap );
342 ((X11DRV_WND_DATA *) wndPtr->pDriverData)->hWMIconBitmap = 0;
349 /*****************************************************************
350 * X11DRV_WND_SetParent
352 WND *X11DRV_WND_SetParent(WND *wndPtr, WND *pWndParent)
354 WND *pDesktop = WIN_GetDesktop();
356 if( wndPtr && pWndParent && (wndPtr != pDesktop) )
358 WND* pWndPrev = wndPtr->parent;
360 if( pWndParent != pWndPrev )
362 if ( X11DRV_WND_GetXWindow(wndPtr) )
364 /* Toplevel window needs to be reparented. Used by Tk 8.0 */
366 TSXDestroyWindow( display, X11DRV_WND_GetXWindow(wndPtr) );
367 ((X11DRV_WND_DATA *) wndPtr->pDriverData)->window = None;
370 WIN_UnlinkWindow(wndPtr->hwndSelf);
371 wndPtr->parent = pWndParent;
373 /* Create an X counterpart for reparented top-level windows
374 * when not in the desktop mode. */
376 if( pWndParent == pDesktop )
378 wndPtr->dwStyle &= ~WS_CHILD;
380 if( X11DRV_WND_GetXRootWindow(wndPtr) == DefaultRootWindow(display) )
383 cs.lpCreateParams = NULL;
384 cs.hInstance = 0; /* not used if following call */
385 cs.hMenu = 0; /* not used in following call */
386 cs.hwndParent = pWndParent->hwndSelf;
387 cs.cy = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
390 cs.cx = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
393 cs.y = wndPtr->rectWindow.top;
394 cs.x = wndPtr->rectWindow.left;
395 cs.style = wndPtr->dwStyle;
396 cs.lpszName = 0; /* not used in following call */
397 cs.lpszClass = 0; /*not used in following call */
398 cs.dwExStyle = wndPtr->dwExStyle;
399 X11DRV_WND_CreateWindow(wndPtr, wndPtr->class,
403 else /* a child window */
405 if( !( wndPtr->dwStyle & WS_CHILD ) )
407 wndPtr->dwStyle |= WS_CHILD;
408 if( wndPtr->wIDmenu != 0)
410 DestroyMenu( (HMENU) wndPtr->wIDmenu );
415 WIN_LinkWindow(wndPtr->hwndSelf, HWND_TOP);
417 WIN_ReleaseDesktop();
420 WIN_ReleaseDesktop();
424 /***********************************************************************
425 * X11DRV_WND_ForceWindowRaise
427 * Raise a window on top of the X stacking order, while preserving
428 * the correct Windows Z order.
430 void X11DRV_WND_ForceWindowRaise(WND *wndPtr)
432 XWindowChanges winChanges;
433 WND *wndPrev,*pDesktop = WIN_GetDesktop();
435 if( !wndPtr || !X11DRV_WND_GetXWindow(wndPtr) || (wndPtr->flags & WIN_MANAGED) )
437 WIN_ReleaseDesktop();
441 /* Raise all windows up to wndPtr according to their Z order.
442 * (it would be easier with sibling-related Below but it doesn't
443 * work very well with SGI mwm for instance)
445 winChanges.stack_mode = Above;
448 if (X11DRV_WND_GetXWindow(wndPtr))
449 TSXReconfigureWMWindow( display, X11DRV_WND_GetXWindow(wndPtr), 0,
450 CWStackMode, &winChanges );
451 wndPrev = pDesktop->child;
452 if (wndPrev == wndPtr) break;
453 while (wndPrev && (wndPrev->next != wndPtr)) wndPrev = wndPrev->next;
456 WIN_ReleaseDesktop();
459 /***********************************************************************
460 * X11DRV_WND_FindDesktopXWindow [Internal]
462 * Find the actual X window which needs be restacked.
463 * Used by X11DRV_SetWindowPos().
465 static Window X11DRV_WND_FindDesktopXWindow( WND *wndPtr )
467 if (!(wndPtr->flags & WIN_MANAGED))
468 return X11DRV_WND_GetXWindow(wndPtr);
471 Window window, root, parent, *children;
473 window = X11DRV_WND_GetXWindow(wndPtr);
476 TSXQueryTree( display, window, &root, &parent,
477 &children, &nchildren );
486 /***********************************************************************
487 * WINPOS_SetXWindowPos
489 * SetWindowPos() for an X window. Used by the real SetWindowPos().
491 void X11DRV_WND_SetWindowPos(WND *wndPtr, const WINDOWPOS *winpos, BOOL bChangePos)
493 XWindowChanges winChanges;
495 WND *winposPtr = WIN_FindWndPtr( winpos->hwnd );
496 if ( !winposPtr ) return;
498 if(!wndPtr->hwndSelf) wndPtr = NULL; /* FIXME: WND destroyed, shouldn't happend!!! */
500 if (!(winpos->flags & SWP_SHOWWINDOW) && (winpos->flags & SWP_HIDEWINDOW))
502 if(X11DRV_WND_GetXWindow(wndPtr))
503 TSXUnmapWindow( display, X11DRV_WND_GetXWindow(wndPtr) );
508 if ( !(winpos->flags & SWP_NOSIZE))
510 winChanges.width = (winpos->cx > 0 ) ? winpos->cx : 1;
511 winChanges.height = (winpos->cy > 0 ) ? winpos->cy : 1;
512 changeMask |= CWWidth | CWHeight;
514 /* Tweak dialog window size hints */
516 if ((winposPtr->flags & WIN_MANAGED) &&
517 HAS_DLGFRAME(winposPtr->dwStyle,winposPtr->dwExStyle))
519 XSizeHints *size_hints = TSXAllocSizeHints();
523 long supplied_return;
525 TSXGetWMSizeHints( display, X11DRV_WND_GetXWindow(winposPtr), size_hints,
526 &supplied_return, XA_WM_NORMAL_HINTS);
527 size_hints->min_width = size_hints->max_width = winpos->cx;
528 size_hints->min_height = size_hints->max_height = winpos->cy;
529 TSXSetWMSizeHints( display, X11DRV_WND_GetXWindow(winposPtr), size_hints,
530 XA_WM_NORMAL_HINTS );
535 if (!(winpos->flags & SWP_NOMOVE))
537 winChanges.x = winpos->x;
538 winChanges.y = winpos->y;
539 changeMask |= CWX | CWY;
541 if (!(winpos->flags & SWP_NOZORDER))
543 winChanges.stack_mode = Below;
544 changeMask |= CWStackMode;
546 if (winpos->hwndInsertAfter == HWND_TOP) winChanges.stack_mode = Above;
547 else if (winpos->hwndInsertAfter != HWND_BOTTOM)
549 WND* insertPtr = WIN_FindWndPtr( winpos->hwndInsertAfter );
552 stack[0] = X11DRV_WND_FindDesktopXWindow( insertPtr );
553 stack[1] = X11DRV_WND_FindDesktopXWindow( winposPtr );
555 /* for stupid window managers (i.e. all of them) */
557 TSXRestackWindows(display, stack, 2);
558 changeMask &= ~CWStackMode;
560 WIN_ReleaseWndPtr(insertPtr);
563 if (changeMask && X11DRV_WND_GetXWindow(winposPtr))
565 TSXReconfigureWMWindow( display, X11DRV_WND_GetXWindow(winposPtr), 0, changeMask, &winChanges );
566 if( winposPtr->class->style & (CS_VREDRAW | CS_HREDRAW) )
567 X11DRV_WND_SetHostAttr( winposPtr, HAK_BITGRAVITY, BGForget );
571 if ( winpos->flags & SWP_SHOWWINDOW )
573 if(X11DRV_WND_GetXWindow(wndPtr))
574 TSXMapWindow( display, X11DRV_WND_GetXWindow(wndPtr) );
576 WIN_ReleaseWndPtr(winposPtr);
579 /*****************************************************************
582 void X11DRV_WND_SetText(WND *wndPtr, LPCSTR text)
584 if (!X11DRV_WND_GetXWindow(wndPtr))
587 TSXStoreName( display, X11DRV_WND_GetXWindow(wndPtr), text );
588 TSXSetIconName( display, X11DRV_WND_GetXWindow(wndPtr), text );
591 /*****************************************************************
592 * X11DRV_WND_SetFocus
595 * Explicit colormap management seems to work only with OLVWM.
597 void X11DRV_WND_SetFocus(WND *wndPtr)
599 HWND hwnd = wndPtr->hwndSelf;
600 XWindowAttributes win_attr;
603 /* Only mess with the X focus if there's */
604 /* no desktop window and if the window is not managed by the WM. */
605 if ((X11DRV_WND_GetXRootWindow(wndPtr) != DefaultRootWindow(display))
606 || (wndPtr->flags & WIN_MANAGED)) return;
608 if (!hwnd) /* If setting the focus to 0, uninstall the colormap */
610 if (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_PRIVATE)
611 TSXUninstallColormap( display, X11DRV_PALETTE_PaletteXColormap );
615 /* Set X focus and install colormap */
617 if (!(win = X11DRV_WND_FindXWindow(wndPtr))) return;
618 if (!TSXGetWindowAttributes( display, win, &win_attr ) ||
619 (win_attr.map_state != IsViewable))
620 return; /* If window is not viewable, don't change anything */
622 TSXSetInputFocus( display, win, RevertToParent, CurrentTime );
623 if (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_PRIVATE)
624 TSXInstallColormap( display, X11DRV_PALETTE_PaletteXColormap );
629 /*****************************************************************
630 * X11DRV_WND_PreSizeMove
632 void X11DRV_WND_PreSizeMove(WND *wndPtr)
634 if (!(wndPtr->dwStyle & WS_CHILD) &&
635 (X11DRV_WND_GetXRootWindow(wndPtr) == DefaultRootWindow(display)))
636 TSXGrabServer( display );
639 /*****************************************************************
640 * X11DRV_WND_PostSizeMove
642 void X11DRV_WND_PostSizeMove(WND *wndPtr)
644 if (!(wndPtr->dwStyle & WS_CHILD) &&
645 (X11DRV_GetXRootWindow() == DefaultRootWindow(display)))
646 TSXUngrabServer( display );
649 /*****************************************************************
650 * X11DRV_WND_SurfaceCopy
652 * Copies rect to (rect.left + dx, rect.top + dy).
654 void X11DRV_WND_SurfaceCopy(WND* wndPtr, DC *dcPtr, INT dx, INT dy,
655 const RECT *rect, BOOL bUpdate)
657 X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dcPtr->physDev;
660 dst.x = (src.x = dcPtr->w.DCOrgX + rect->left) + dx;
661 dst.y = (src.y = dcPtr->w.DCOrgY + rect->top) + dy;
663 if (bUpdate) /* handles non-Wine windows hanging over the copied area */
664 TSXSetGraphicsExposures( display, physDev->gc, True );
665 TSXSetFunction( display, physDev->gc, GXcopy );
666 TSXCopyArea( display, physDev->drawable, physDev->drawable,
667 physDev->gc, src.x, src.y,
668 rect->right - rect->left,
669 rect->bottom - rect->top,
672 TSXSetGraphicsExposures( display, physDev->gc, False );
674 if (bUpdate) /* Make sure exposure events have been processed */
678 /***********************************************************************
679 * X11DRV_WND_SetDrawable
681 * Set the drawable, origin and dimensions for the DC associated to
684 void X11DRV_WND_SetDrawable(WND *wndPtr, DC *dc, WORD flags, BOOL bSetClipOrigin)
686 X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
687 INT dcOrgXCopy, dcOrgYCopy;
688 BOOL offsetClipRgn = FALSE;
690 if (!wndPtr) /* Get a DC for the whole screen */
694 physDev->drawable = X11DRV_WND_GetXRootWindow(wndPtr);
695 TSXSetSubwindowMode( display, physDev->gc, IncludeInferiors );
700 * This function change the coordinate system (DCOrgX,DCOrgY)
701 * values. When it moves the origin, other data like the current clipping
702 * region will not be moved to that new origin. In the case of DCs that are class
703 * or window DCs that clipping region might be a valid value from a previous use
704 * of the DC and changing the origin of the DC without moving the clip region
705 * results in a clip region that is not placed properly in the DC.
706 * This code will save the dc origin, let the SetDrawable
707 * modify the origin and reset the clipping. When the clipping is set,
708 * it is moved according to the new DC origin.
710 if ( (wndPtr->class->style & (CS_OWNDC | CS_CLASSDC)) && (dc->w.hClipRgn > 0))
712 dcOrgXCopy = dc->w.DCOrgX;
713 dcOrgYCopy = dc->w.DCOrgY;
714 offsetClipRgn = TRUE;
717 if (flags & DCX_WINDOW)
719 dc->w.DCOrgX = wndPtr->rectWindow.left;
720 dc->w.DCOrgY = wndPtr->rectWindow.top;
724 dc->w.DCOrgX = wndPtr->rectClient.left;
725 dc->w.DCOrgY = wndPtr->rectClient.top;
727 while (!X11DRV_WND_GetXWindow(wndPtr))
729 wndPtr = wndPtr->parent;
730 dc->w.DCOrgX += wndPtr->rectClient.left;
731 dc->w.DCOrgY += wndPtr->rectClient.top;
733 dc->w.DCOrgX -= wndPtr->rectWindow.left;
734 dc->w.DCOrgY -= wndPtr->rectWindow.top;
736 /* reset the clip region, according to the new origin */
739 OffsetRgn(dc->w.hClipRgn, dc->w.DCOrgX - dcOrgXCopy,dc->w.DCOrgY - dcOrgYCopy);
742 physDev->drawable = X11DRV_WND_GetXWindow(wndPtr);
745 /* This is needed when we reuse a cached DC because
746 * SetDCState() called by ReleaseDC() screws up DC
747 * origins for child windows.
751 TSXSetClipOrigin( display, physDev->gc, dc->w.DCOrgX, dc->w.DCOrgY );
756 /***********************************************************************
759 static BOOL X11DRV_SetWMHint(Display* display, WND* wndPtr, int hint, int val)
761 XWMHints* wm_hints = TSXAllocWMHints();
763 wm_hints->flags = hint;
767 wm_hints->input = val;
771 wm_hints->initial_state = val;
775 wm_hints->icon_pixmap = (Pixmap)val;
779 wm_hints->icon_window = (Window)val;
783 TSXSetWMHints( display, X11DRV_WND_GetXWindow(wndPtr), wm_hints );
791 /***********************************************************************
792 * X11DRV_WND_SetHostAttr
794 * This function returns TRUE if the attribute is supported and the
795 * action was successful. Otherwise it should return FALSE and Wine will try
796 * to get by without the functionality provided by the host window system.
798 BOOL X11DRV_WND_SetHostAttr(WND* wnd, INT ha, INT value)
802 if( (w = X11DRV_WND_GetXWindow(wnd)) )
804 XSetWindowAttributes win_attr;
808 case HAK_ICONICSTATE: /* called when a window is minimized/restored */
810 if( (wnd->flags & WIN_MANAGED) )
814 if( wnd->dwStyle & WS_VISIBLE )
816 XClientMessageEvent ev;
818 /* FIXME: set proper icon */
820 ev.type = ClientMessage;
821 ev.display = display;
822 ev.message_type = wmChangeState;
824 ev.data.l[0] = IconicState;
827 if( TSXSendEvent (display,
828 RootWindow( display, XScreenNumberOfScreen(X11DRV_WND_GetXScreen(wnd)) ),
829 True, (SubstructureRedirectMask | SubstructureNotifyMask), (XEvent*)&ev))
833 while( !TSXCheckTypedWindowEvent( display, w, UnmapNotify, &xe) );
839 X11DRV_SetWMHint( display, wnd, StateHint, IconicState );
843 if( !(wnd->flags & WS_VISIBLE) )
844 X11DRV_SetWMHint( display, wnd, StateHint, NormalState );
848 TSXMapWindow(display, w );
849 while( !TSXCheckTypedWindowEvent( display, w, MapNotify, &xe) );
856 case HAK_BITGRAVITY: /* called when a window is resized */
858 if( ((X11DRV_WND_DATA *) wnd->pDriverData)->bit_gravity != value )
860 win_attr.bit_gravity = value;
861 ((X11DRV_WND_DATA *) wnd->pDriverData)->bit_gravity = value;
862 TSXChangeWindowAttributes( display, w, CWBitGravity, &win_attr );
866 case HAK_ACCEPTFOCUS: /* called when a window is disabled/enabled */
868 if( (wnd->flags & WIN_MANAGED) )
869 return X11DRV_SetWMHint( display, wnd, InputHint, value );
875 /***********************************************************************
876 * X11DRV_WND_IsSelfClipping
878 BOOL X11DRV_WND_IsSelfClipping(WND *wndPtr)
880 return X11DRV_WND_GetXWindow(wndPtr) != None;
883 #endif /* !defined(X_DISPLAY_MISSING) */