1/***********************************************************
2
3Copyright 1987, 1998  The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24
25
26Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
27
28                        All Rights Reserved
29
30Permission to use, copy, modify, and distribute this software and its
31documentation for any purpose and without fee is hereby granted,
32provided that the above copyright notice appear in all copies and that
33both that copyright notice and this permission notice appear in
34supporting documentation, and that the name of Digital not be
35used in advertising or publicity pertaining to distribution of the
36software without specific, written prior permission.
37
38DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44SOFTWARE.
45
46******************************************************************/
47
48#ifndef SCREENINTSTRUCT_H
49#define SCREENINTSTRUCT_H
50
51#include "screenint.h"
52#include "regionstr.h"
53#include "colormap.h"
54#include "cursor.h"
55#include "validate.h"
56#include <X11/Xproto.h>
57#include "dix.h"
58#include "privates.h"
59
60typedef struct _PixmapFormat {
61    unsigned char	depth;
62    unsigned char	bitsPerPixel;
63    unsigned char	scanlinePad;
64    } PixmapFormatRec;
65
66typedef struct _Visual {
67    VisualID		vid;
68    short		class;
69    short		bitsPerRGBValue;
70    short		ColormapEntries;
71    short		nplanes;/* = log2 (ColormapEntries). This does not
72				 * imply that the screen has this many planes.
73				 * it may have more or fewer */
74    unsigned long	redMask, greenMask, blueMask;
75    int			offsetRed, offsetGreen, offsetBlue;
76  } VisualRec;
77
78typedef struct _Depth {
79    unsigned char	depth;
80    short		numVids;
81    VisualID		*vids;    /* block of visual ids for this depth */
82  } DepthRec;
83
84typedef struct _ScreenSaverStuff {
85    WindowPtr pWindow;
86    XID       wid;
87    char      blanked;
88    Bool      (*ExternalScreenSaver)(
89	ScreenPtr	/*pScreen*/,
90	int		/*xstate*/,
91	Bool		/*force*/);
92} ScreenSaverStuffRec;
93
94
95/*
96 *  There is a typedef for each screen function pointer so that code that
97 *  needs to declare a screen function pointer (e.g. in a screen private
98 *  or as a local variable) can easily do so and retain full type checking.
99 */
100
101typedef    Bool (* CloseScreenProcPtr)(
102	int /*index*/,
103	ScreenPtr /*pScreen*/);
104
105typedef    void (* QueryBestSizeProcPtr)(
106	int /*class*/,
107	unsigned short * /*pwidth*/,
108	unsigned short * /*pheight*/,
109	ScreenPtr /*pScreen*/);
110
111typedef    Bool (* SaveScreenProcPtr)(
112	 ScreenPtr /*pScreen*/,
113	 int /*on*/);
114
115typedef    void (* GetImageProcPtr)(
116	DrawablePtr /*pDrawable*/,
117	int /*sx*/,
118	int /*sy*/,
119	int /*w*/,
120	int /*h*/,
121	unsigned int /*format*/,
122	unsigned long /*planeMask*/,
123	char * /*pdstLine*/);
124
125typedef    void (* GetSpansProcPtr)(
126	DrawablePtr /*pDrawable*/,
127	int /*wMax*/,
128	DDXPointPtr /*ppt*/,
129	int* /*pwidth*/,
130	int /*nspans*/,
131	char * /*pdstStart*/);
132
133typedef    void (* SourceValidateProcPtr)(
134	DrawablePtr /*pDrawable*/,
135	int /*x*/,
136	int /*y*/,
137	int /*width*/,
138	int /*height*/,
139	unsigned int /*subWindowMode*/);
140
141typedef    Bool (* CreateWindowProcPtr)(
142	WindowPtr /*pWindow*/);
143
144typedef    Bool (* DestroyWindowProcPtr)(
145	WindowPtr /*pWindow*/);
146
147typedef    Bool (* PositionWindowProcPtr)(
148	WindowPtr /*pWindow*/,
149	int /*x*/,
150	int /*y*/);
151
152typedef    Bool (* ChangeWindowAttributesProcPtr)(
153	WindowPtr /*pWindow*/,
154	unsigned long /*mask*/);
155
156typedef    Bool (* RealizeWindowProcPtr)(
157	WindowPtr /*pWindow*/);
158
159typedef    Bool (* UnrealizeWindowProcPtr)(
160	WindowPtr /*pWindow*/);
161
162typedef    void (* RestackWindowProcPtr)(
163	WindowPtr /*pWindow*/,
164	WindowPtr /*pOldNextSib*/);
165
166typedef    int  (* ValidateTreeProcPtr)(
167	WindowPtr /*pParent*/,
168	WindowPtr /*pChild*/,
169	VTKind /*kind*/);
170
171typedef    void (* PostValidateTreeProcPtr)(
172	WindowPtr /*pParent*/,
173	WindowPtr /*pChild*/,
174	VTKind /*kind*/);
175
176typedef    void (* WindowExposuresProcPtr)(
177	WindowPtr /*pWindow*/,
178	RegionPtr /*prgn*/,
179	RegionPtr /*other_exposed*/);
180
181typedef    void (* CopyWindowProcPtr)(
182	WindowPtr /*pWindow*/,
183	DDXPointRec /*ptOldOrg*/,
184	RegionPtr /*prgnSrc*/);
185
186typedef    void (* ClearToBackgroundProcPtr)(
187	WindowPtr /*pWindow*/,
188	int /*x*/,
189	int /*y*/,
190	int /*w*/,
191	int /*h*/,
192	Bool /*generateExposures*/);
193
194typedef    void (* ClipNotifyProcPtr)(
195	WindowPtr /*pWindow*/,
196	int /*dx*/,
197	int /*dy*/);
198
199/* pixmap will exist only for the duration of the current rendering operation */
200#define CREATE_PIXMAP_USAGE_SCRATCH                     1
201/* pixmap will be the backing pixmap for a redirected window */
202#define CREATE_PIXMAP_USAGE_BACKING_PIXMAP              2
203/* pixmap will contain a glyph */
204#define CREATE_PIXMAP_USAGE_GLYPH_PICTURE               3
205
206typedef    PixmapPtr (* CreatePixmapProcPtr)(
207	ScreenPtr /*pScreen*/,
208	int /*width*/,
209	int /*height*/,
210	int /*depth*/,
211	unsigned /*usage_hint*/);
212
213typedef    Bool (* DestroyPixmapProcPtr)(
214	PixmapPtr /*pPixmap*/);
215
216typedef    Bool (* RealizeFontProcPtr)(
217	ScreenPtr /*pScreen*/,
218	FontPtr /*pFont*/);
219
220typedef    Bool (* UnrealizeFontProcPtr)(
221	ScreenPtr /*pScreen*/,
222	FontPtr /*pFont*/);
223
224typedef    void (* ConstrainCursorProcPtr)(
225        DeviceIntPtr /*pDev*/,
226	ScreenPtr /*pScreen*/,
227	BoxPtr /*pBox*/);
228
229typedef    void (* CursorLimitsProcPtr)(
230        DeviceIntPtr /* pDev */,
231	ScreenPtr /*pScreen*/,
232	CursorPtr /*pCursor*/,
233	BoxPtr /*pHotBox*/,
234	BoxPtr /*pTopLeftBox*/);
235
236typedef    Bool (* DisplayCursorProcPtr)(
237        DeviceIntPtr /* pDev */,
238	ScreenPtr /*pScreen*/,
239	CursorPtr /*pCursor*/);
240
241typedef    Bool (* RealizeCursorProcPtr)(
242        DeviceIntPtr /* pDev */,
243	ScreenPtr /*pScreen*/,
244	CursorPtr /*pCursor*/);
245
246typedef    Bool (* UnrealizeCursorProcPtr)(
247        DeviceIntPtr /* pDev */,
248	ScreenPtr /*pScreen*/,
249	CursorPtr /*pCursor*/);
250
251typedef    void (* RecolorCursorProcPtr)(
252        DeviceIntPtr /* pDev */,
253	ScreenPtr /*pScreen*/,
254	CursorPtr /*pCursor*/,
255	Bool /*displayed*/);
256
257typedef    Bool (* SetCursorPositionProcPtr)(
258        DeviceIntPtr /* pDev */,
259	ScreenPtr /*pScreen*/,
260	int /*x*/,
261	int /*y*/,
262	Bool /*generateEvent*/);
263
264typedef    Bool (* CreateGCProcPtr)(
265	GCPtr /*pGC*/);
266
267typedef    Bool (* CreateColormapProcPtr)(
268	ColormapPtr /*pColormap*/);
269
270typedef    void (* DestroyColormapProcPtr)(
271	ColormapPtr /*pColormap*/);
272
273typedef    void (* InstallColormapProcPtr)(
274	ColormapPtr /*pColormap*/);
275
276typedef    void (* UninstallColormapProcPtr)(
277	ColormapPtr /*pColormap*/);
278
279typedef    int (* ListInstalledColormapsProcPtr) (
280	ScreenPtr /*pScreen*/,
281	XID* /*pmaps */);
282
283typedef    void (* StoreColorsProcPtr)(
284	ColormapPtr /*pColormap*/,
285	int /*ndef*/,
286	xColorItem * /*pdef*/);
287
288typedef    void (* ResolveColorProcPtr)(
289	unsigned short* /*pred*/,
290	unsigned short* /*pgreen*/,
291	unsigned short* /*pblue*/,
292	VisualPtr /*pVisual*/);
293
294typedef    RegionPtr (* BitmapToRegionProcPtr)(
295	PixmapPtr /*pPix*/);
296
297typedef    void (* SendGraphicsExposeProcPtr)(
298	ClientPtr /*client*/,
299	RegionPtr /*pRgn*/,
300	XID /*drawable*/,
301	int /*major*/,
302	int /*minor*/);
303
304typedef    void (* ScreenBlockHandlerProcPtr)(
305	int /*screenNum*/,
306	pointer /*blockData*/,
307	pointer /*pTimeout*/,
308	pointer /*pReadmask*/);
309
310typedef    void (* ScreenWakeupHandlerProcPtr)(
311	 int /*screenNum*/,
312	 pointer /*wakeupData*/,
313	 unsigned long /*result*/,
314	 pointer /*pReadMask*/);
315
316typedef    Bool (* CreateScreenResourcesProcPtr)(
317	ScreenPtr /*pScreen*/);
318
319typedef    Bool (* ModifyPixmapHeaderProcPtr)(
320	PixmapPtr /*pPixmap*/,
321	int /*width*/,
322	int /*height*/,
323	int /*depth*/,
324	int /*bitsPerPixel*/,
325	int /*devKind*/,
326	pointer /*pPixData*/);
327
328typedef    PixmapPtr (* GetWindowPixmapProcPtr)(
329	WindowPtr /*pWin*/);
330
331typedef    void (* SetWindowPixmapProcPtr)(
332	WindowPtr /*pWin*/,
333	PixmapPtr /*pPix*/);
334
335typedef    PixmapPtr (* GetScreenPixmapProcPtr)(
336	ScreenPtr /*pScreen*/);
337
338typedef    void (* SetScreenPixmapProcPtr)(
339	PixmapPtr /*pPix*/);
340
341typedef    void (* MarkWindowProcPtr)(
342	WindowPtr /*pWin*/);
343
344typedef    Bool (* MarkOverlappedWindowsProcPtr)(
345	WindowPtr /*parent*/,
346	WindowPtr /*firstChild*/,
347	WindowPtr * /*pLayerWin*/);
348
349typedef    int (* ConfigNotifyProcPtr)(
350	WindowPtr /*pWin*/,
351	int /*x*/,
352	int /*y*/,
353	int /*w*/,
354	int /*h*/,
355	int /*bw*/,
356	WindowPtr /*pSib*/);
357
358typedef    void (* MoveWindowProcPtr)(
359	WindowPtr /*pWin*/,
360	int /*x*/,
361	int /*y*/,
362	WindowPtr /*pSib*/,
363	VTKind /*kind*/);
364
365typedef    void (* ResizeWindowProcPtr)(
366    WindowPtr /*pWin*/,
367    int /*x*/,
368    int /*y*/,
369    unsigned int /*w*/,
370    unsigned int /*h*/,
371    WindowPtr /*pSib*/
372);
373
374typedef    WindowPtr (* GetLayerWindowProcPtr)(
375    WindowPtr /*pWin*/
376);
377
378typedef    void (* HandleExposuresProcPtr)(
379    WindowPtr /*pWin*/);
380
381typedef    void (* ReparentWindowProcPtr)(
382    WindowPtr /*pWin*/,
383    WindowPtr /*pPriorParent*/);
384
385typedef    void (* SetShapeProcPtr)(
386        WindowPtr /*pWin*/,
387        int /* kind */);
388
389typedef    void (* ChangeBorderWidthProcPtr)(
390	WindowPtr /*pWin*/,
391	unsigned int /*width*/);
392
393typedef    void (* MarkUnrealizedWindowProcPtr)(
394	WindowPtr /*pChild*/,
395	WindowPtr /*pWin*/,
396	Bool /*fromConfigure*/);
397
398typedef    Bool (* DeviceCursorInitializeProcPtr)(
399        DeviceIntPtr /* pDev */,
400        ScreenPtr    /* pScreen */);
401
402typedef    void (* DeviceCursorCleanupProcPtr)(
403        DeviceIntPtr /* pDev */,
404        ScreenPtr    /* pScreen */);
405
406typedef void (*ConstrainCursorHarderProcPtr)(
407       DeviceIntPtr, ScreenPtr, int, int *, int *);
408
409typedef struct _Screen {
410    int			myNum;	/* index of this instance in Screens[] */
411    ATOM		id;
412    short		x, y, width, height;
413    short		mmWidth, mmHeight;
414    short		numDepths;
415    unsigned char      	rootDepth;
416    DepthPtr       	allowedDepths;
417    unsigned long      	rootVisual;
418    unsigned long	defColormap;
419    short		minInstalledCmaps, maxInstalledCmaps;
420    char                backingStoreSupport, saveUnderSupport;
421    unsigned long	whitePixel, blackPixel;
422    GCPtr		GCperDepth[MAXFORMATS+1];
423			/* next field is a stipple to use as default in
424			   a GC.  we don't build default tiles of all depths
425			   because they are likely to be of a color
426			   different from the default fg pixel, so
427			   we don't win anything by building
428			   a standard one.
429			*/
430    PixmapPtr		PixmapPerDepth[1];
431    pointer		devPrivate;
432    short       	numVisuals;
433    VisualPtr		visuals;
434    WindowPtr		root;
435    ScreenSaverStuffRec screensaver;
436
437    /* Random screen procedures */
438
439    CloseScreenProcPtr		CloseScreen;
440    QueryBestSizeProcPtr	QueryBestSize;
441    SaveScreenProcPtr		SaveScreen;
442    GetImageProcPtr		GetImage;
443    GetSpansProcPtr		GetSpans;
444    SourceValidateProcPtr	SourceValidate;
445
446    /* Window Procedures */
447
448    CreateWindowProcPtr		CreateWindow;
449    DestroyWindowProcPtr	DestroyWindow;
450    PositionWindowProcPtr	PositionWindow;
451    ChangeWindowAttributesProcPtr ChangeWindowAttributes;
452    RealizeWindowProcPtr	RealizeWindow;
453    UnrealizeWindowProcPtr	UnrealizeWindow;
454    ValidateTreeProcPtr		ValidateTree;
455    PostValidateTreeProcPtr	PostValidateTree;
456    WindowExposuresProcPtr	WindowExposures;
457    CopyWindowProcPtr		CopyWindow;
458    ClearToBackgroundProcPtr	ClearToBackground;
459    ClipNotifyProcPtr		ClipNotify;
460    RestackWindowProcPtr	RestackWindow;
461
462    /* Pixmap procedures */
463
464    CreatePixmapProcPtr		CreatePixmap;
465    DestroyPixmapProcPtr	DestroyPixmap;
466
467    /* Font procedures */
468
469    RealizeFontProcPtr		RealizeFont;
470    UnrealizeFontProcPtr	UnrealizeFont;
471
472    /* Cursor Procedures */
473
474    ConstrainCursorProcPtr	ConstrainCursor;
475    ConstrainCursorHarderProcPtr ConstrainCursorHarder;
476    CursorLimitsProcPtr		CursorLimits;
477    DisplayCursorProcPtr	DisplayCursor;
478    RealizeCursorProcPtr	RealizeCursor;
479    UnrealizeCursorProcPtr	UnrealizeCursor;
480    RecolorCursorProcPtr	RecolorCursor;
481    SetCursorPositionProcPtr	SetCursorPosition;
482
483    /* GC procedures */
484
485    CreateGCProcPtr		CreateGC;
486
487    /* Colormap procedures */
488
489    CreateColormapProcPtr	CreateColormap;
490    DestroyColormapProcPtr	DestroyColormap;
491    InstallColormapProcPtr	InstallColormap;
492    UninstallColormapProcPtr	UninstallColormap;
493    ListInstalledColormapsProcPtr ListInstalledColormaps;
494    StoreColorsProcPtr		StoreColors;
495    ResolveColorProcPtr		ResolveColor;
496
497    /* Region procedures */
498
499    BitmapToRegionProcPtr	BitmapToRegion;
500    SendGraphicsExposeProcPtr	SendGraphicsExpose;
501
502    /* os layer procedures */
503
504    ScreenBlockHandlerProcPtr	BlockHandler;
505    ScreenWakeupHandlerProcPtr	WakeupHandler;
506
507    pointer blockData;
508    pointer wakeupData;
509
510    /* anybody can get a piece of this array */
511    PrivateRec	*devPrivates;
512
513    CreateScreenResourcesProcPtr CreateScreenResources;
514    ModifyPixmapHeaderProcPtr	ModifyPixmapHeader;
515
516    GetWindowPixmapProcPtr	GetWindowPixmap;
517    SetWindowPixmapProcPtr	SetWindowPixmap;
518    GetScreenPixmapProcPtr	GetScreenPixmap;
519    SetScreenPixmapProcPtr	SetScreenPixmap;
520
521    PixmapPtr pScratchPixmap;		/* scratch pixmap "pool" */
522
523    unsigned int		totalPixmapSize;
524
525    MarkWindowProcPtr		MarkWindow;
526    MarkOverlappedWindowsProcPtr MarkOverlappedWindows;
527    ConfigNotifyProcPtr		ConfigNotify;
528    MoveWindowProcPtr		MoveWindow;
529    ResizeWindowProcPtr		ResizeWindow;
530    GetLayerWindowProcPtr	GetLayerWindow;
531    HandleExposuresProcPtr	HandleExposures;
532    ReparentWindowProcPtr	ReparentWindow;
533
534    SetShapeProcPtr		SetShape;
535
536    ChangeBorderWidthProcPtr	ChangeBorderWidth;
537    MarkUnrealizedWindowProcPtr	MarkUnrealizedWindow;
538
539    /* Device cursor procedures */
540    DeviceCursorInitializeProcPtr DeviceCursorInitialize;
541    DeviceCursorCleanupProcPtr    DeviceCursorCleanup;
542
543    /* set it in driver side if X server can copy the framebuffer content.
544     * Meant to be used together with '-background none' option, avoiding
545     * malicious users to steal framebuffer's content if that would be the
546     * default */
547    Bool		canDoBGNoneRoot;
548} ScreenRec;
549
550static inline RegionPtr BitmapToRegion(ScreenPtr _pScreen, PixmapPtr pPix) {
551    return (*(_pScreen)->BitmapToRegion)(pPix); /* no mi version?! */
552}
553
554typedef struct _ScreenInfo {
555    int		imageByteOrder;
556    int		bitmapScanlineUnit;
557    int		bitmapScanlinePad;
558    int		bitmapBitOrder;
559    int		numPixmapFormats;
560    PixmapFormatRec
561		formats[MAXFORMATS];
562    int		numScreens;
563    ScreenPtr	screens[MAXSCREENS];
564} ScreenInfo;
565
566extern _X_EXPORT ScreenInfo screenInfo;
567
568extern _X_EXPORT void InitOutput(
569    ScreenInfo 	* /*pScreenInfo*/,
570    int     	/*argc*/,
571    char    	** /*argv*/);
572
573#endif /* SCREENINTSTRUCT_H */
574