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 | /* $XFree86: xc/programs/Xserver/miext/rootless/rootlessCommon.h,v 1.5 2004/07/02 01:30:33 torrey Exp $ */
|
---|
31 |
|
---|
32 | #ifdef HAVE_DIX_CONFIG_H
|
---|
33 | #include <dix-config.h>
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #ifndef _ROOTLESSCOMMON_H
|
---|
37 | #define _ROOTLESSCOMMON_H
|
---|
38 |
|
---|
39 | #include "rootless.h"
|
---|
40 | #include "fb.h"
|
---|
41 |
|
---|
42 | #ifdef RENDER
|
---|
43 | #include "picturestr.h"
|
---|
44 | #endif
|
---|
45 |
|
---|
46 |
|
---|
47 | // Debug output, or not.
|
---|
48 | #ifdef ROOTLESSDEBUG
|
---|
49 | #define RL_DEBUG_MSG ErrorF
|
---|
50 | #else
|
---|
51 | #define RL_DEBUG_MSG(a, ...)
|
---|
52 | #endif
|
---|
53 |
|
---|
54 |
|
---|
55 | // Global variables
|
---|
56 | extern int rootlessGCPrivateIndex;
|
---|
57 | extern int rootlessScreenPrivateIndex;
|
---|
58 | extern int rootlessWindowPrivateIndex;
|
---|
59 |
|
---|
60 |
|
---|
61 | // RootlessGCRec: private per-gc data
|
---|
62 | typedef struct {
|
---|
63 | GCFuncs *originalFuncs;
|
---|
64 | GCOps *originalOps;
|
---|
65 | } RootlessGCRec;
|
---|
66 |
|
---|
67 |
|
---|
68 | // RootlessScreenRec: per-screen private data
|
---|
69 | typedef struct _RootlessScreenRec {
|
---|
70 | // Rootless implementation functions
|
---|
71 | RootlessFrameProcsPtr imp;
|
---|
72 |
|
---|
73 | // Wrapped screen functions
|
---|
74 | CreateScreenResourcesProcPtr CreateScreenResources;
|
---|
75 | CloseScreenProcPtr CloseScreen;
|
---|
76 |
|
---|
77 | CreateWindowProcPtr CreateWindow;
|
---|
78 | DestroyWindowProcPtr DestroyWindow;
|
---|
79 | RealizeWindowProcPtr RealizeWindow;
|
---|
80 | UnrealizeWindowProcPtr UnrealizeWindow;
|
---|
81 | MoveWindowProcPtr MoveWindow;
|
---|
82 | ResizeWindowProcPtr ResizeWindow;
|
---|
83 | RestackWindowProcPtr RestackWindow;
|
---|
84 | ReparentWindowProcPtr ReparentWindow;
|
---|
85 | ChangeBorderWidthProcPtr ChangeBorderWidth;
|
---|
86 | PositionWindowProcPtr PositionWindow;
|
---|
87 | ChangeWindowAttributesProcPtr ChangeWindowAttributes;
|
---|
88 |
|
---|
89 | CreateGCProcPtr CreateGC;
|
---|
90 | PaintWindowBackgroundProcPtr PaintWindowBackground;
|
---|
91 | PaintWindowBorderProcPtr PaintWindowBorder;
|
---|
92 | CopyWindowProcPtr CopyWindow;
|
---|
93 | GetImageProcPtr GetImage;
|
---|
94 | SourceValidateProcPtr SourceValidate;
|
---|
95 |
|
---|
96 | MarkOverlappedWindowsProcPtr MarkOverlappedWindows;
|
---|
97 | ValidateTreeProcPtr ValidateTree;
|
---|
98 |
|
---|
99 | #ifdef SHAPE
|
---|
100 | SetShapeProcPtr SetShape;
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | #ifdef RENDER
|
---|
104 | CompositeProcPtr Composite;
|
---|
105 | GlyphsProcPtr Glyphs;
|
---|
106 | #endif
|
---|
107 |
|
---|
108 | void *pixmap_data;
|
---|
109 | unsigned int pixmap_data_size;
|
---|
110 |
|
---|
111 | void *redisplay_timer;
|
---|
112 | unsigned int redisplay_timer_set :1;
|
---|
113 | unsigned int redisplay_queued :1;
|
---|
114 | unsigned int redisplay_expired :1;
|
---|
115 | } RootlessScreenRec, *RootlessScreenPtr;
|
---|
116 |
|
---|
117 |
|
---|
118 | #undef MIN
|
---|
119 | #define MIN(x,y) ((x) < (y) ? (x) : (y))
|
---|
120 | #undef MAX
|
---|
121 | #define MAX(x,y) ((x) > (y) ? (x) : (y))
|
---|
122 |
|
---|
123 | // "Definition of the Porting Layer for the X11 Sample Server" says
|
---|
124 | // unwrap and rewrap of screen functions is unnecessary, but
|
---|
125 | // screen->CreateGC changes after a call to cfbCreateGC.
|
---|
126 |
|
---|
127 | #define SCREEN_UNWRAP(screen, fn) \
|
---|
128 | screen->fn = SCREENREC(screen)->fn;
|
---|
129 |
|
---|
130 | #define SCREEN_WRAP(screen, fn) \
|
---|
131 | SCREENREC(screen)->fn = screen->fn; \
|
---|
132 | screen->fn = Rootless##fn
|
---|
133 |
|
---|
134 |
|
---|
135 | // Accessors for screen and window privates
|
---|
136 |
|
---|
137 | #define SCREENREC(pScreen) \
|
---|
138 | ((RootlessScreenRec *)(pScreen)->devPrivates[rootlessScreenPrivateIndex].ptr)
|
---|
139 |
|
---|
140 | #define WINREC(pWin) \
|
---|
141 | ((RootlessWindowRec *)(pWin)->devPrivates[rootlessWindowPrivateIndex].ptr)
|
---|
142 |
|
---|
143 |
|
---|
144 | // Call a rootless implementation function.
|
---|
145 | // Many rootless implementation functions are allowed to be NULL.
|
---|
146 | #define CallFrameProc(pScreen, proc, params) \
|
---|
147 | if (SCREENREC(pScreen)->frameProcs.proc) { \
|
---|
148 | RL_DEBUG_MSG("calling frame proc " #proc " "); \
|
---|
149 | SCREENREC(pScreen)->frameProcs.proc params; \
|
---|
150 | }
|
---|
151 |
|
---|
152 |
|
---|
153 | // BoxRec manipulators
|
---|
154 | // Copied from shadowfb
|
---|
155 |
|
---|
156 | #define TRIM_BOX(box, pGC) { \
|
---|
157 | BoxPtr extents = &pGC->pCompositeClip->extents;\
|
---|
158 | if(box.x1 < extents->x1) box.x1 = extents->x1; \
|
---|
159 | if(box.x2 > extents->x2) box.x2 = extents->x2; \
|
---|
160 | if(box.y1 < extents->y1) box.y1 = extents->y1; \
|
---|
161 | if(box.y2 > extents->y2) box.y2 = extents->y2; \
|
---|
162 | }
|
---|
163 |
|
---|
164 | #define TRANSLATE_BOX(box, pDraw) { \
|
---|
165 | box.x1 += pDraw->x; \
|
---|
166 | box.x2 += pDraw->x; \
|
---|
167 | box.y1 += pDraw->y; \
|
---|
168 | box.y2 += pDraw->y; \
|
---|
169 | }
|
---|
170 |
|
---|
171 | #define TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC) { \
|
---|
172 | TRANSLATE_BOX(box, pDraw); \
|
---|
173 | TRIM_BOX(box, pGC); \
|
---|
174 | }
|
---|
175 |
|
---|
176 | #define BOX_NOT_EMPTY(box) \
|
---|
177 | (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
|
---|
178 |
|
---|
179 |
|
---|
180 | // HUGE_ROOT and NORMAL_ROOT
|
---|
181 | // We don't want to clip windows to the edge of the screen.
|
---|
182 | // HUGE_ROOT temporarily makes the root window really big.
|
---|
183 | // This is needed as a wrapper around any function that calls
|
---|
184 | // SetWinSize or SetBorderSize which clip a window against its
|
---|
185 | // parents, including the root.
|
---|
186 |
|
---|
187 | extern RegionRec rootlessHugeRoot;
|
---|
188 |
|
---|
189 | #define HUGE_ROOT(pWin) \
|
---|
190 | do { \
|
---|
191 | WindowPtr w = pWin; \
|
---|
192 | while (w->parent) \
|
---|
193 | w = w->parent; \
|
---|
194 | saveRoot = w->winSize; \
|
---|
195 | w->winSize = rootlessHugeRoot; \
|
---|
196 | } while (0)
|
---|
197 |
|
---|
198 | #define NORMAL_ROOT(pWin) \
|
---|
199 | do { \
|
---|
200 | WindowPtr w = pWin; \
|
---|
201 | while (w->parent) \
|
---|
202 | w = w->parent; \
|
---|
203 | w->winSize = saveRoot; \
|
---|
204 | } while (0)
|
---|
205 |
|
---|
206 |
|
---|
207 | // Returns TRUE if this window is a top-level window (i.e. child of the root)
|
---|
208 | // The root is not a top-level window.
|
---|
209 | #define IsTopLevel(pWin) \
|
---|
210 | ((pWin) && (pWin)->parent && !(pWin)->parent->parent)
|
---|
211 |
|
---|
212 | // Returns TRUE if this window is a root window
|
---|
213 | #define IsRoot(pWin) \
|
---|
214 | ((pWin) == WindowTable[(pWin)->drawable.pScreen->myNum])
|
---|
215 |
|
---|
216 |
|
---|
217 | /*
|
---|
218 | * SetPixmapBaseToScreen
|
---|
219 | * Move the given pixmap's base address to where pixel (0, 0)
|
---|
220 | * would be if the pixmap's actual data started at (x, y).
|
---|
221 | * Can't access the bits before the first word of the drawable's data in
|
---|
222 | * rootless mode, so make sure our base address is always 32-bit aligned.
|
---|
223 | */
|
---|
224 | #define SetPixmapBaseToScreen(pix, _x, _y) { \
|
---|
225 | PixmapPtr _pPix = (PixmapPtr) (pix); \
|
---|
226 | _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
|
---|
227 | ((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \
|
---|
228 | (int)(_y) * _pPix->devKind); \
|
---|
229 | if (_pPix->drawable.bitsPerPixel != FB_UNIT) { \
|
---|
230 | unsigned _diff = ((unsigned) _pPix->devPrivate.ptr) & \
|
---|
231 | (FB_UNIT / CHAR_BIT - 1); \
|
---|
232 | _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
|
---|
233 | _diff; \
|
---|
234 | _pPix->drawable.x = _diff / \
|
---|
235 | (_pPix->drawable.bitsPerPixel / CHAR_BIT); \
|
---|
236 | } \
|
---|
237 | }
|
---|
238 |
|
---|
239 |
|
---|
240 | // Returns TRUE if this window is visible inside a frame
|
---|
241 | // (e.g. it is visible and has a top-level or root parent)
|
---|
242 | Bool IsFramedWindow(WindowPtr pWin);
|
---|
243 |
|
---|
244 | // Routines that cause regions to get redrawn.
|
---|
245 | // DamageRegion and DamageRect are in global coordinates.
|
---|
246 | // DamageBox is in window-local coordinates.
|
---|
247 | void RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion);
|
---|
248 | void RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h);
|
---|
249 | void RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox);
|
---|
250 | void RootlessRedisplay(WindowPtr pWindow);
|
---|
251 | void RootlessRedisplayScreen(ScreenPtr pScreen);
|
---|
252 |
|
---|
253 | void RootlessQueueRedisplay(ScreenPtr pScreen);
|
---|
254 |
|
---|
255 | // Move a window to its proper location on the screen.
|
---|
256 | void RootlessRepositionWindow(WindowPtr pWin);
|
---|
257 |
|
---|
258 | // Move the window to it's correct place in the physical stacking order.
|
---|
259 | void RootlessReorderWindow(WindowPtr pWin);
|
---|
260 |
|
---|
261 | #endif /* _ROOTLESSCOMMON_H */
|
---|