Added missing #include "config.h"
[wine/multimedia.git] / windows / x11drv / init.c
blob8ca6b38acef1b3d6b2c184d050b683dcb0a091d1
1 /*
2 * X11 windows driver
4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 1998 Patrik Stridvall
6 */
8 #include <string.h>
9 #include <X11/Xatom.h>
10 #include "ts_xlib.h"
11 #include "color.h"
12 #include "cursoricon.h"
13 #include "dce.h"
14 #include "options.h"
15 #include "message.h"
16 #include "win.h"
17 #include "windows.h"
18 #include "x11drv.h"
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,
26 X11DRV_WND_SetParent
29 /**********************************************************************
30 * X11DRV_WND_CreateWindow [Internal]
32 static BOOL32 X11DRV_WND_CreateWindow(WND *wndPtr, CLASS *classPtr, CREATESTRUCT32A *cs, BOOL32 bUnicode)
34 /* Create the X window (only for top-level windows, and then only */
35 /* when there's no desktop window) */
37 if (!(cs->style & WS_CHILD) && (rootWindow == DefaultRootWindow(display)))
39 XSetWindowAttributes win_attr;
41 if (Options.managed && ((cs->style & (WS_DLGFRAME | WS_THICKFRAME)) ||
42 (cs->dwExStyle & WS_EX_DLGMODALFRAME)))
44 win_attr.event_mask = ExposureMask | KeyPressMask |
45 KeyReleaseMask | PointerMotionMask |
46 ButtonPressMask | ButtonReleaseMask |
47 FocusChangeMask | StructureNotifyMask;
48 win_attr.override_redirect = FALSE;
49 wndPtr->flags |= WIN_MANAGED;
51 else
53 win_attr.event_mask = ExposureMask | KeyPressMask |
54 KeyReleaseMask | PointerMotionMask |
55 ButtonPressMask | ButtonReleaseMask |
56 FocusChangeMask;
57 win_attr.override_redirect = TRUE;
59 win_attr.colormap = COLOR_GetColormap();
60 win_attr.backing_store = Options.backingstore ? WhenMapped : NotUseful;
61 win_attr.save_under = ((classPtr->style & CS_SAVEBITS) != 0);
62 win_attr.cursor = CURSORICON_XCursor;
63 wndPtr->window = TSXCreateWindow( display, rootWindow, cs->x, cs->y,
64 cs->cx, cs->cy, 0, CopyFromParent,
65 InputOutput, CopyFromParent,
66 CWEventMask | CWOverrideRedirect |
67 CWColormap | CWCursor | CWSaveUnder |
68 CWBackingStore, &win_attr );
70 if ((wndPtr->flags & WIN_MANAGED) &&
71 (cs->dwExStyle & WS_EX_DLGMODALFRAME))
73 XSizeHints* size_hints = TSXAllocSizeHints();
75 if (size_hints)
77 size_hints->min_width = size_hints->max_width = cs->cx;
78 size_hints->min_height = size_hints->max_height = cs->cy;
79 size_hints->flags = (PSize | PMinSize | PMaxSize);
80 TSXSetWMSizeHints( display, wndPtr->window, size_hints,
81 XA_WM_NORMAL_HINTS );
82 TSXFree(size_hints);
86 if (cs->hwndParent) /* Get window owner */
88 Window win = WIN_GetXWindow( cs->hwndParent );
89 if (win) TSXSetTransientForHint( display, wndPtr->window, win );
91 EVENT_RegisterWindow( wndPtr );
93 return TRUE;
96 /*****************************************************************
97 * X11DRV_WND_SetParent [Internal]
99 static WND *X11DRV_WND_SetParent(WND *wndPtr, WND *pWndParent)
101 if( wndPtr && pWndParent && (wndPtr != WIN_GetDesktop()) )
103 WND* pWndPrev = wndPtr->parent;
105 if( pWndParent != pWndPrev )
107 BOOL32 bFixupDCE = IsWindowVisible32(wndPtr->hwndSelf);
109 if ( wndPtr->window )
111 /* Toplevel window needs to be reparented. Used by Tk 8.0 */
113 TSXDestroyWindow( display, wndPtr->window );
114 wndPtr->window = None;
116 else if( bFixupDCE )
117 DCE_InvalidateDCE( wndPtr, &wndPtr->rectWindow );
119 WIN_UnlinkWindow(wndPtr->hwndSelf);
120 wndPtr->parent = pWndParent;
122 /* FIXME: Create an X counterpart for reparented top-level windows
123 * when not in the desktop mode. */
125 if ( pWndParent != WIN_GetDesktop() ) wndPtr->dwStyle |= WS_CHILD;
126 WIN_LinkWindow(wndPtr->hwndSelf, HWND_BOTTOM);
128 if( bFixupDCE )
130 DCE_InvalidateDCE( wndPtr, &wndPtr->rectWindow );
131 UpdateWindow32(wndPtr->hwndSelf);
134 return pWndPrev;
135 } /* failure */
136 return 0;