4 * Copyright 1998 Patrik Stridvall
10 #ifndef X_DISPLAY_MISSING
13 #include <X11/cursorfont.h>
17 #include "debugtools.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 MESSAGE("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 MESSAGE( "%s: Depth %d not supported on this screen.\n",
162 Options.programName, pX11Monitor->depth );
167 pX11Monitor->depth = DefaultDepthOfScreen( pX11Monitor->screen );
169 if (Options.desktopGeometry)
170 X11DRV_MONITOR_CreateDesktop(pMonitor);
172 pX11Monitor->rootWindow =
173 DefaultRootWindow( display );
176 /***********************************************************************
177 * X11DRV_MONITOR_Finalize
179 void X11DRV_MONITOR_Finalize(MONITOR *pMonitor)
181 HeapFree(SystemHeap, 0, pMonitor->pDriverData);
184 /***********************************************************************
185 * X11DRV_MONITOR_IsSingleWindow
187 BOOL X11DRV_MONITOR_IsSingleWindow(MONITOR *pMonitor)
189 X11DRV_MONITOR_DATA *pX11Monitor =
190 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
192 return (pX11Monitor->rootWindow != DefaultRootWindow(display));
195 /***********************************************************************
196 * X11DRV_MONITOR_GetWidth
198 * Return the width of the monitor
200 int X11DRV_MONITOR_GetWidth(MONITOR *pMonitor)
202 X11DRV_MONITOR_DATA *pX11Monitor =
203 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
205 return pX11Monitor->width;
208 /***********************************************************************
209 * X11DRV_MONITOR_GetHeight
211 * Return the height of the monitor
213 int X11DRV_MONITOR_GetHeight(MONITOR *pMonitor)
215 X11DRV_MONITOR_DATA *pX11Monitor =
216 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
218 return pX11Monitor->height;
221 /***********************************************************************
222 * X11DRV_MONITOR_GetDepth
224 * Return the depth of the monitor
226 int X11DRV_MONITOR_GetDepth(MONITOR *pMonitor)
228 X11DRV_MONITOR_DATA *pX11Monitor =
229 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
231 return pX11Monitor->depth;
234 /***********************************************************************
235 * X11DRV_MONITOR_GetScreenSaveActive
237 * Returns the active status of the screen saver
239 BOOL X11DRV_MONITOR_GetScreenSaveActive(MONITOR *pMonitor)
242 TSXGetScreenSaver(display, &timeout, &temp, &temp, &temp);
243 return timeout!=NULL;
246 /***********************************************************************
247 * X11DRV_MONITOR_SetScreenSaveActive
249 * Activate/Deactivate the screen saver
251 void X11DRV_MONITOR_SetScreenSaveActive(MONITOR *pMonitor, BOOL bActivate)
254 TSXActivateScreenSaver(display);
256 TSXResetScreenSaver(display);
259 /***********************************************************************
260 * X11DRV_MONITOR_GetScreenSaveTimeout
262 * Return the screen saver timeout
264 int X11DRV_MONITOR_GetScreenSaveTimeout(MONITOR *pMonitor)
267 TSXGetScreenSaver(display, &timeout, &temp, &temp, &temp);
271 /***********************************************************************
272 * X11DRV_MONITOR_SetScreenSaveTimeout
274 * Set the screen saver timeout
276 void X11DRV_MONITOR_SetScreenSaveTimeout(
277 MONITOR *pMonitor, int nTimeout)
279 TSXSetScreenSaver(display, nTimeout, 60,
280 DefaultBlanking, DefaultExposures);
283 #endif /* X_DISPLAY_MISSING */