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