4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 1998 Patrik Stridvall
20 static BOOL32 X11DRV_WND_CreateWindow(WND *wndPtr, CLASS *classPtr, CREATESTRUCT32A *cs, BOOL32 bUnicode);
21 static WND *X11DRV_WND_SetParent(WND *wndPtr, WND *pWndParent);
23 WND_DRIVER X11DRV_WND_Driver =
25 X11DRV_WND_CreateWindow,
29 extern Cursor DISPLAY_XCursor; /* Current X cursor */
31 /**********************************************************************
32 * X11DRV_WND_CreateWindow [Internal]
34 static BOOL32 X11DRV_WND_CreateWindow(WND *wndPtr, CLASS *classPtr, CREATESTRUCT32A *cs, BOOL32 bUnicode)
36 /* Create the X window (only for top-level windows, and then only */
37 /* when there's no desktop window) */
39 if (!(cs->style & WS_CHILD) && (rootWindow == DefaultRootWindow(display)))
41 XSetWindowAttributes win_attr;
43 if (Options.managed && ((cs->style & (WS_DLGFRAME | WS_THICKFRAME)) ||
44 (cs->dwExStyle & WS_EX_DLGMODALFRAME)))
46 win_attr.event_mask = ExposureMask | KeyPressMask |
47 KeyReleaseMask | PointerMotionMask |
48 ButtonPressMask | ButtonReleaseMask |
49 FocusChangeMask | StructureNotifyMask;
50 win_attr.override_redirect = FALSE;
51 wndPtr->flags |= WIN_MANAGED;
55 win_attr.event_mask = ExposureMask | KeyPressMask |
56 KeyReleaseMask | PointerMotionMask |
57 ButtonPressMask | ButtonReleaseMask |
59 win_attr.override_redirect = TRUE;
61 win_attr.colormap = COLOR_GetColormap();
62 win_attr.backing_store = Options.backingstore ? WhenMapped : NotUseful;
63 win_attr.save_under = ((classPtr->style & CS_SAVEBITS) != 0);
64 win_attr.cursor = DISPLAY_XCursor;
65 wndPtr->window = TSXCreateWindow( display, rootWindow, cs->x, cs->y,
66 cs->cx, cs->cy, 0, CopyFromParent,
67 InputOutput, CopyFromParent,
68 CWEventMask | CWOverrideRedirect |
69 CWColormap | CWCursor | CWSaveUnder |
70 CWBackingStore, &win_attr );
72 if ((wndPtr->flags & WIN_MANAGED) &&
73 (cs->dwExStyle & WS_EX_DLGMODALFRAME))
75 XSizeHints* size_hints = TSXAllocSizeHints();
79 size_hints->min_width = size_hints->max_width = cs->cx;
80 size_hints->min_height = size_hints->max_height = cs->cy;
81 size_hints->flags = (PSize | PMinSize | PMaxSize);
82 TSXSetWMSizeHints( display, wndPtr->window, size_hints,
88 if (cs->hwndParent) /* Get window owner */
90 Window win = WIN_GetXWindow( cs->hwndParent );
91 if (win) TSXSetTransientForHint( display, wndPtr->window, win );
93 EVENT_RegisterWindow( wndPtr );
98 /*****************************************************************
99 * X11DRV_WND_SetParent [Internal]
101 static WND *X11DRV_WND_SetParent(WND *wndPtr, WND *pWndParent)
103 if( wndPtr && pWndParent && (wndPtr != WIN_GetDesktop()) )
105 WND* pWndPrev = wndPtr->parent;
107 if( pWndParent != pWndPrev )
109 BOOL32 bFixupDCE = IsWindowVisible32(wndPtr->hwndSelf);
111 if ( wndPtr->window )
113 /* Toplevel window needs to be reparented. Used by Tk 8.0 */
115 TSXDestroyWindow( display, wndPtr->window );
116 wndPtr->window = None;
119 DCE_InvalidateDCE( wndPtr, &wndPtr->rectWindow );
121 WIN_UnlinkWindow(wndPtr->hwndSelf);
122 wndPtr->parent = pWndParent;
124 /* FIXME: Create an X counterpart for reparented top-level windows
125 * when not in the desktop mode. */
127 if ( pWndParent != WIN_GetDesktop() ) wndPtr->dwStyle |= WS_CHILD;
128 WIN_LinkWindow(wndPtr->hwndSelf, HWND_BOTTOM);
132 DCE_InvalidateDCE( wndPtr, &wndPtr->rectWindow );
133 UpdateWindow32(wndPtr->hwndSelf);