4 * Copyright 1998 Patrik Stridvall
10 #ifndef X_DISPLAY_MISSING
13 #include <X11/cursorfont.h>
24 /**********************************************************************/
26 extern Display *display;
28 /***********************************************************************
29 * X11DRV_MONITOR_GetXScreen
31 * Return the X screen associated to the MONITOR.
33 Screen *X11DRV_MONITOR_GetXScreen(MONITOR *pMonitor)
35 X11DRV_MONITOR_DATA *pX11Monitor =
36 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
38 return pX11Monitor->screen;
41 /***********************************************************************
42 * X11DRV_MONITOR_GetXRootWindow
44 * Return the X screen associated to the MONITOR.
46 Window X11DRV_MONITOR_GetXRootWindow(MONITOR *pMonitor)
48 X11DRV_MONITOR_DATA *pX11Monitor =
49 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
51 return pX11Monitor->rootWindow;
54 /***********************************************************************
55 * X11DRV_MONITOR_CreateDesktop
57 * The desktop should create created in X11DRV_DESKTOP_Initialize
58 * instead but it can't be yet because some code depends on that
59 * the desktop always exists.
62 static void X11DRV_MONITOR_CreateDesktop(MONITOR *pMonitor)
64 X11DRV_MONITOR_DATA *pX11Monitor =
65 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
68 unsigned int width = 640, height = 480; /* Default size = 640x480 */
69 char *name = "Wine desktop";
70 XSizeHints *size_hints;
72 XClassHint *class_hints;
73 XSetWindowAttributes win_attr;
74 XTextProperty window_name;
75 Atom XA_WM_DELETE_WINDOW;
77 flags = TSXParseGeometry( Options.desktopGeometry, &x, &y, &width, &height );
78 pX11Monitor->width = width;
79 pX11Monitor->height = height;
83 win_attr.background_pixel = BlackPixel(display, 0);
85 ExposureMask | KeyPressMask | KeyReleaseMask |
86 PointerMotionMask | ButtonPressMask |
87 ButtonReleaseMask | EnterWindowMask;
88 win_attr.cursor = TSXCreateFontCursor( display, XC_top_left_arrow );
90 pX11Monitor->rootWindow =
91 TSXCreateWindow( display,
92 DefaultRootWindow(display),
93 x, y, width, height, 0,
94 CopyFromParent, InputOutput, CopyFromParent,
95 CWBackPixel | CWEventMask | CWCursor, &win_attr);
97 /* Set window manager properties */
99 size_hints = TSXAllocSizeHints();
100 wm_hints = TSXAllocWMHints();
101 class_hints = TSXAllocClassHint();
102 if (!size_hints || !wm_hints || !class_hints)
104 MSG("Not enough memory for window manager hints.\n" );
107 size_hints->min_width = size_hints->max_width = width;
108 size_hints->min_height = size_hints->max_height = height;
109 size_hints->flags = PMinSize | PMaxSize;
110 if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
111 if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
112 else size_hints->flags |= PSize;
114 wm_hints->flags = InputHint | StateHint;
115 wm_hints->input = True;
116 wm_hints->initial_state = NormalState;
117 class_hints->res_name = Options.argv[0]; /* FIXME: Options.argv0 insteed? */
118 class_hints->res_class = "Wine";
120 TSXStringListToTextProperty( &name, 1, &window_name );
121 TSXSetWMProperties( display, pX11Monitor->rootWindow, &window_name, &window_name,
122 Options.argv, *Options.argc, size_hints, wm_hints, class_hints );
123 XA_WM_DELETE_WINDOW = TSXInternAtom( display, "WM_DELETE_WINDOW", False );
124 TSXSetWMProtocols( display, pX11Monitor->rootWindow, &XA_WM_DELETE_WINDOW, 1 );
125 TSXFree( size_hints );
127 TSXFree( class_hints );
131 TSXMapWindow( display, pX11Monitor->rootWindow );
134 /***********************************************************************
135 * X11DRV_MONITOR_Initialize
137 void X11DRV_MONITOR_Initialize(MONITOR *pMonitor)
139 X11DRV_MONITOR_DATA *pX11Monitor = (X11DRV_MONITOR_DATA *)
140 HeapAlloc(SystemHeap, 0, sizeof(X11DRV_MONITOR_DATA));
145 pMonitor->pDriverData = pX11Monitor;
147 pX11Monitor->screen = DefaultScreenOfDisplay( display );
149 pX11Monitor->width = WidthOfScreen( pX11Monitor->screen );
150 pX11Monitor->height = HeightOfScreen( pX11Monitor->screen );
152 pX11Monitor->depth = Options.screenDepth;
153 if (pX11Monitor->depth) /* -depth option specified */
155 depth_list = TSXListDepths(display, DefaultScreen(display), &depth_count);
156 for (i = 0; i < depth_count; i++)
157 if (depth_list[i] == pX11Monitor->depth) break;
158 TSXFree( depth_list );
159 if (i >= depth_count)
161 MSG( "%s: Depth %d not supported on this screen.\n",
162 Options.programName, pX11Monitor->depth );
167 pX11Monitor->depth = DefaultDepthOfScreen( pX11Monitor->screen );
169 if (Options.synchronous) TSXSynchronize( display, True );
171 if (Options.desktopGeometry)
172 X11DRV_MONITOR_CreateDesktop(pMonitor);
174 pX11Monitor->rootWindow =
175 DefaultRootWindow( display );
178 /***********************************************************************
179 * X11DRV_MONITOR_Finalize
181 void X11DRV_MONITOR_Finalize(MONITOR *pMonitor)
183 HeapFree(SystemHeap, 0, pMonitor->pDriverData);
186 /***********************************************************************
187 * X11DRV_MONITOR_GetWidth
189 * Return the width of the monitor
191 int X11DRV_MONITOR_GetWidth(MONITOR *pMonitor)
193 X11DRV_MONITOR_DATA *pX11Monitor =
194 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
196 return pX11Monitor->width;
199 /***********************************************************************
200 * X11DRV_MONITOR_GetHeight
202 * Return the height of the monitor
204 int X11DRV_MONITOR_GetHeight(MONITOR *pMonitor)
206 X11DRV_MONITOR_DATA *pX11Monitor =
207 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
209 return pX11Monitor->height;
212 /***********************************************************************
213 * X11DRV_MONITOR_GetDepth
215 * Return the depth of the monitor
217 int X11DRV_MONITOR_GetDepth(MONITOR *pMonitor)
219 X11DRV_MONITOR_DATA *pX11Monitor =
220 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
222 return pX11Monitor->depth;
225 #endif /* X_DISPLAY_MISSING */