4 * Copyright 1998 Patrik Stridvall
10 #ifndef X_DISPLAY_MISSING
13 #include <X11/cursorfont.h>
17 #include "debugtools.h"
24 /***********************************************************************
25 * X11DRV_MONITOR_CreateDesktop
27 * The desktop should create created in X11DRV_DESKTOP_Initialize
28 * instead but it can't be yet because some code depends on that
29 * the desktop always exists.
32 static void X11DRV_MONITOR_CreateDesktop(MONITOR *pMonitor)
34 X11DRV_MONITOR_DATA *pX11Monitor =
35 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
37 int x = 0, y = 0, flags;
38 unsigned int width = 640, height = 480; /* Default size = 640x480 */
39 char *name = "Wine desktop";
40 XSizeHints *size_hints;
42 XClassHint *class_hints;
43 XSetWindowAttributes win_attr;
44 XTextProperty window_name;
45 Atom XA_WM_DELETE_WINDOW;
47 flags = TSXParseGeometry( Options.desktopGeometry, &x, &y, &width, &height );
48 pX11Monitor->width = width;
49 pX11Monitor->height = height;
53 win_attr.background_pixel = BlackPixel(display, 0);
55 ExposureMask | KeyPressMask | KeyReleaseMask |
56 PointerMotionMask | ButtonPressMask |
57 ButtonReleaseMask | EnterWindowMask;
58 win_attr.cursor = TSXCreateFontCursor( display, XC_top_left_arrow );
60 root_window = TSXCreateWindow( display,
61 DefaultRootWindow(display),
62 x, y, width, height, 0,
63 CopyFromParent, InputOutput, CopyFromParent,
64 CWBackPixel | CWEventMask | CWCursor, &win_attr);
66 /* Set window manager properties */
68 size_hints = TSXAllocSizeHints();
69 wm_hints = TSXAllocWMHints();
70 class_hints = TSXAllocClassHint();
71 if (!size_hints || !wm_hints || !class_hints)
73 MESSAGE("Not enough memory for window manager hints.\n" );
76 size_hints->min_width = size_hints->max_width = width;
77 size_hints->min_height = size_hints->max_height = height;
78 size_hints->flags = PMinSize | PMaxSize;
79 if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
80 if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
81 else size_hints->flags |= PSize;
83 wm_hints->flags = InputHint | StateHint;
84 wm_hints->input = True;
85 wm_hints->initial_state = NormalState;
86 class_hints->res_name = (char *)argv0;
87 class_hints->res_class = "Wine";
89 TSXStringListToTextProperty( &name, 1, &window_name );
90 TSXSetWMProperties( display, root_window, &window_name, &window_name,
91 Options.argv, Options.argc, size_hints, wm_hints, class_hints );
92 XA_WM_DELETE_WINDOW = TSXInternAtom( display, "WM_DELETE_WINDOW", False );
93 TSXSetWMProtocols( display, root_window, &XA_WM_DELETE_WINDOW, 1 );
94 TSXFree( size_hints );
96 TSXFree( class_hints );
100 TSXMapWindow( display, root_window );
103 /***********************************************************************
104 * X11DRV_MONITOR_Initialize
106 void X11DRV_MONITOR_Initialize(MONITOR *pMonitor)
108 X11DRV_MONITOR_DATA *pX11Monitor = (X11DRV_MONITOR_DATA *)
109 HeapAlloc(SystemHeap, 0, sizeof(X11DRV_MONITOR_DATA));
111 pMonitor->pDriverData = pX11Monitor;
113 pX11Monitor->width = WidthOfScreen( screen );
114 pX11Monitor->height = HeightOfScreen( screen );
116 if (Options.desktopGeometry) X11DRV_MONITOR_CreateDesktop(pMonitor);
119 /***********************************************************************
120 * X11DRV_MONITOR_Finalize
122 void X11DRV_MONITOR_Finalize(MONITOR *pMonitor)
124 HeapFree(SystemHeap, 0, pMonitor->pDriverData);
127 /***********************************************************************
128 * X11DRV_MONITOR_IsSingleWindow
130 BOOL X11DRV_MONITOR_IsSingleWindow(MONITOR *pMonitor)
132 return (root_window != DefaultRootWindow(display));
135 /***********************************************************************
136 * X11DRV_MONITOR_GetWidth
138 * Return the width of the monitor
140 int X11DRV_MONITOR_GetWidth(MONITOR *pMonitor)
142 X11DRV_MONITOR_DATA *pX11Monitor =
143 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
145 return pX11Monitor->width;
148 /***********************************************************************
149 * X11DRV_MONITOR_GetHeight
151 * Return the height of the monitor
153 int X11DRV_MONITOR_GetHeight(MONITOR *pMonitor)
155 X11DRV_MONITOR_DATA *pX11Monitor =
156 (X11DRV_MONITOR_DATA *) pMonitor->pDriverData;
158 return pX11Monitor->height;
161 /***********************************************************************
162 * X11DRV_MONITOR_GetDepth
164 * Return the depth of the monitor
166 int X11DRV_MONITOR_GetDepth(MONITOR *pMonitor)
171 /***********************************************************************
172 * X11DRV_MONITOR_GetScreenSaveActive
174 * Returns the active status of the screen saver
176 BOOL X11DRV_MONITOR_GetScreenSaveActive(MONITOR *pMonitor)
179 TSXGetScreenSaver(display, &timeout, &temp, &temp, &temp);
180 return timeout!=NULL;
183 /***********************************************************************
184 * X11DRV_MONITOR_SetScreenSaveActive
186 * Activate/Deactivate the screen saver
188 void X11DRV_MONITOR_SetScreenSaveActive(MONITOR *pMonitor, BOOL bActivate)
191 TSXActivateScreenSaver(display);
193 TSXResetScreenSaver(display);
196 /***********************************************************************
197 * X11DRV_MONITOR_GetScreenSaveTimeout
199 * Return the screen saver timeout
201 int X11DRV_MONITOR_GetScreenSaveTimeout(MONITOR *pMonitor)
204 TSXGetScreenSaver(display, &timeout, &temp, &temp, &temp);
208 /***********************************************************************
209 * X11DRV_MONITOR_SetScreenSaveTimeout
211 * Set the screen saver timeout
213 void X11DRV_MONITOR_SetScreenSaveTimeout(
214 MONITOR *pMonitor, int nTimeout)
216 TSXSetScreenSaver(display, nTimeout, 60,
217 DefaultBlanking, DefaultExposures);
220 #endif /* X_DISPLAY_MISSING */