VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.5.3/rootlessCommon.h@ 17471

Last change on this file since 17471 was 17471, checked in by vboxsync, 16 years ago

export to OSE

  • Property svn:eol-style set to native
File size: 9.5 KB
Line 
1/*
2 * Common internal rootless definitions and code
3 */
4/*
5 * Copyright (c) 2001 Greg Parker. All Rights Reserved.
6 * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 *
26 * Except as contained in this notice, the name(s) of the above copyright
27 * holders shall not be used in advertising or otherwise to promote the sale,
28 * use or other dealings in this Software without prior written authorization.
29 */
30
31#ifdef HAVE_DIX_CONFIG_H
32#include <dix-config.h>
33#endif
34
35#include <stdint.h>
36#ifndef _ROOTLESSCOMMON_H
37#define _ROOTLESSCOMMON_H
38
39#include "rootless.h"
40#include "fb.h"
41
42#ifdef SHAPE
43#include "scrnintstr.h"
44#endif /* SHAPE */
45
46#ifdef RENDER
47#include "picturestr.h"
48#endif
49
50
51// Debug output, or not.
52#ifdef ROOTLESSDEBUG
53#define RL_DEBUG_MSG ErrorF
54#else
55#define RL_DEBUG_MSG(a, ...)
56#endif
57
58
59// Global variables
60extern DevPrivateKey rootlessGCPrivateKey;
61extern DevPrivateKey rootlessScreenPrivateKey;
62extern DevPrivateKey rootlessWindowPrivateKey;
63extern DevPrivateKey rootlessWindowOldPixmapPrivateKey;
64
65
66// RootlessGCRec: private per-gc data
67typedef struct {
68 GCFuncs *originalFuncs;
69 GCOps *originalOps;
70} RootlessGCRec;
71
72
73// RootlessScreenRec: per-screen private data
74typedef struct _RootlessScreenRec {
75 // Rootless implementation functions
76 RootlessFrameProcsPtr imp;
77
78 // Wrapped screen functions
79 CreateScreenResourcesProcPtr CreateScreenResources;
80 CloseScreenProcPtr CloseScreen;
81
82 CreateWindowProcPtr CreateWindow;
83 DestroyWindowProcPtr DestroyWindow;
84 RealizeWindowProcPtr RealizeWindow;
85 UnrealizeWindowProcPtr UnrealizeWindow;
86 MoveWindowProcPtr MoveWindow;
87 ResizeWindowProcPtr ResizeWindow;
88 RestackWindowProcPtr RestackWindow;
89 ReparentWindowProcPtr ReparentWindow;
90 ChangeBorderWidthProcPtr ChangeBorderWidth;
91 PositionWindowProcPtr PositionWindow;
92 ChangeWindowAttributesProcPtr ChangeWindowAttributes;
93
94 CreateGCProcPtr CreateGC;
95 CopyWindowProcPtr CopyWindow;
96 GetImageProcPtr GetImage;
97 SourceValidateProcPtr SourceValidate;
98
99 MarkOverlappedWindowsProcPtr MarkOverlappedWindows;
100 ValidateTreeProcPtr ValidateTree;
101
102#ifdef SHAPE
103 SetShapeProcPtr SetShape;
104#endif
105
106#ifdef RENDER
107 CompositeProcPtr Composite;
108 GlyphsProcPtr Glyphs;
109#endif
110
111 InstallColormapProcPtr InstallColormap;
112 UninstallColormapProcPtr UninstallColormap;
113 StoreColorsProcPtr StoreColors;
114
115 void *pixmap_data;
116 unsigned int pixmap_data_size;
117
118 ColormapPtr colormap;
119
120 void *redisplay_timer;
121 unsigned int redisplay_timer_set :1;
122 unsigned int redisplay_queued :1;
123 unsigned int redisplay_expired :1;
124 unsigned int colormap_changed :1;
125} RootlessScreenRec, *RootlessScreenPtr;
126
127
128#undef MIN
129#define MIN(x,y) ((x) < (y) ? (x) : (y))
130#undef MAX
131#define MAX(x,y) ((x) > (y) ? (x) : (y))
132
133// "Definition of the Porting Layer for the X11 Sample Server" says
134// unwrap and rewrap of screen functions is unnecessary, but
135// screen->CreateGC changes after a call to cfbCreateGC.
136
137#define SCREEN_UNWRAP(screen, fn) \
138 screen->fn = SCREENREC(screen)->fn;
139
140#define SCREEN_WRAP(screen, fn) \
141 SCREENREC(screen)->fn = screen->fn; \
142 screen->fn = Rootless##fn
143
144
145// Accessors for screen and window privates
146
147#define SCREENREC(pScreen) ((RootlessScreenRec *) \
148 dixLookupPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey))
149
150#define SETSCREENREC(pScreen, v) \
151 dixSetPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey, v)
152
153#define WINREC(pWin) ((RootlessWindowRec *) \
154 dixLookupPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey))
155
156#define SETWINREC(pWin, v) \
157 dixSetPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey, v)
158
159// Call a rootless implementation function.
160// Many rootless implementation functions are allowed to be NULL.
161#define CallFrameProc(pScreen, proc, params) \
162 if (SCREENREC(pScreen)->frameProcs.proc) { \
163 RL_DEBUG_MSG("calling frame proc " #proc " "); \
164 SCREENREC(pScreen)->frameProcs.proc params; \
165 }
166
167
168// BoxRec manipulators
169// Copied from shadowfb
170
171#define TRIM_BOX(box, pGC) { \
172 BoxPtr extents = &pGC->pCompositeClip->extents;\
173 if(box.x1 < extents->x1) box.x1 = extents->x1; \
174 if(box.x2 > extents->x2) box.x2 = extents->x2; \
175 if(box.y1 < extents->y1) box.y1 = extents->y1; \
176 if(box.y2 > extents->y2) box.y2 = extents->y2; \
177}
178
179#define TRANSLATE_BOX(box, pDraw) { \
180 box.x1 += pDraw->x; \
181 box.x2 += pDraw->x; \
182 box.y1 += pDraw->y; \
183 box.y2 += pDraw->y; \
184}
185
186#define TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC) { \
187 TRANSLATE_BOX(box, pDraw); \
188 TRIM_BOX(box, pGC); \
189}
190
191#define BOX_NOT_EMPTY(box) \
192 (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
193
194
195// HUGE_ROOT and NORMAL_ROOT
196// We don't want to clip windows to the edge of the screen.
197// HUGE_ROOT temporarily makes the root window really big.
198// This is needed as a wrapper around any function that calls
199// SetWinSize or SetBorderSize which clip a window against its
200// parents, including the root.
201
202extern RegionRec rootlessHugeRoot;
203
204#define HUGE_ROOT(pWin) \
205 do { \
206 WindowPtr w = pWin; \
207 while (w->parent) \
208 w = w->parent; \
209 saveRoot = w->winSize; \
210 w->winSize = rootlessHugeRoot; \
211 } while (0)
212
213#define NORMAL_ROOT(pWin) \
214 do { \
215 WindowPtr w = pWin; \
216 while (w->parent) \
217 w = w->parent; \
218 w->winSize = saveRoot; \
219 } while (0)
220
221
222// Returns TRUE if this window is a top-level window (i.e. child of the root)
223// The root is not a top-level window.
224#define IsTopLevel(pWin) \
225 ((pWin) && (pWin)->parent && !(pWin)->parent->parent)
226
227// Returns TRUE if this window is a root window
228#define IsRoot(pWin) \
229 ((pWin) == WindowTable[(pWin)->drawable.pScreen->myNum])
230
231
232/*
233 * SetPixmapBaseToScreen
234 * Move the given pixmap's base address to where pixel (0, 0)
235 * would be if the pixmap's actual data started at (x, y).
236 * Can't access the bits before the first word of the drawable's data in
237 * rootless mode, so make sure our base address is always 32-bit aligned.
238 */
239#define SetPixmapBaseToScreen(pix, _x, _y) { \
240 PixmapPtr _pPix = (PixmapPtr) (pix); \
241 _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
242 ((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \
243 (int)(_y) * _pPix->devKind); \
244 if (_pPix->drawable.bitsPerPixel != FB_UNIT) { \
245 unsigned _diff = ((unsigned) _pPix->devPrivate.ptr) & \
246 (FB_UNIT / CHAR_BIT - 1); \
247 _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
248 _diff; \
249 _pPix->drawable.x = _diff / \
250 (_pPix->drawable.bitsPerPixel / CHAR_BIT); \
251 } \
252}
253
254
255// Returns TRUE if this window is visible inside a frame
256// (e.g. it is visible and has a top-level or root parent)
257Bool IsFramedWindow(WindowPtr pWin);
258
259// Routines that cause regions to get redrawn.
260// DamageRegion and DamageRect are in global coordinates.
261// DamageBox is in window-local coordinates.
262void RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion);
263void RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h);
264void RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox);
265void RootlessRedisplay(WindowPtr pWindow);
266void RootlessRedisplayScreen(ScreenPtr pScreen);
267
268void RootlessQueueRedisplay(ScreenPtr pScreen);
269
270/* Return the colormap currently installed on the given screen. */
271ColormapPtr RootlessGetColormap (ScreenPtr pScreen);
272
273/* Convert colormap to ARGB. */
274Bool RootlessResolveColormap (ScreenPtr pScreen, int first_color,
275 int n_colors, uint32_t *colors);
276
277void RootlessFlushWindowColormap (WindowPtr pWin);
278void RootlessFlushScreenColormaps (ScreenPtr pScreen);
279
280// Move a window to its proper location on the screen.
281void RootlessRepositionWindow(WindowPtr pWin);
282
283// Move the window to it's correct place in the physical stacking order.
284void RootlessReorderWindow(WindowPtr pWin);
285
286#endif /* _ROOTLESSCOMMON_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette