1 | /*
|
---|
2 | * External interface to generic rootless mode
|
---|
3 | */
|
---|
4 | /*
|
---|
5 | * Copyright (c) 2001 Greg Parker. All Rights Reserved.
|
---|
6 | * Copyright (c) 2002-2003 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 | #ifndef _ROOTLESS_H
|
---|
36 | #define _ROOTLESS_H
|
---|
37 |
|
---|
38 | #include "rootlessConfig.h"
|
---|
39 | #include "mi.h"
|
---|
40 | #include "gcstruct.h"
|
---|
41 |
|
---|
42 | /*
|
---|
43 | Each top-level rootless window has a one-to-one correspondence to a physical
|
---|
44 | on-screen window. The physical window is refered to as a "frame".
|
---|
45 | */
|
---|
46 |
|
---|
47 | typedef void * RootlessFrameID;
|
---|
48 |
|
---|
49 | /*
|
---|
50 | * RootlessWindowRec
|
---|
51 | * This structure stores the per-frame data used by the rootless code.
|
---|
52 | * Each top-level X window has one RootlessWindowRec associated with it.
|
---|
53 | */
|
---|
54 | typedef struct _RootlessWindowRec {
|
---|
55 | // Position and size includes the window border
|
---|
56 | // Position is in per-screen coordinates
|
---|
57 | int x, y;
|
---|
58 | unsigned int width, height;
|
---|
59 | unsigned int borderWidth;
|
---|
60 | int level;
|
---|
61 |
|
---|
62 | RootlessFrameID wid; // implementation specific frame id
|
---|
63 | WindowPtr win; // underlying X window
|
---|
64 |
|
---|
65 | // Valid only when drawing (ie. is_drawing is set)
|
---|
66 | char *pixelData;
|
---|
67 | int bytesPerRow;
|
---|
68 |
|
---|
69 | PixmapPtr pixmap;
|
---|
70 |
|
---|
71 | #ifdef ROOTLESS_TRACK_DAMAGE
|
---|
72 | RegionRec damage;
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | unsigned int is_drawing :1; // Currently drawing?
|
---|
76 | unsigned int is_reorder_pending :1;
|
---|
77 | unsigned int is_offscreen :1;
|
---|
78 | unsigned int is_obscured :1;
|
---|
79 | } RootlessWindowRec, *RootlessWindowPtr;
|
---|
80 |
|
---|
81 |
|
---|
82 | /* Offset for screen-local to global coordinate transforms */
|
---|
83 | #ifdef ROOTLESS_GLOBAL_COORDS
|
---|
84 | extern int rootlessGlobalOffsetX;
|
---|
85 | extern int rootlessGlobalOffsetY;
|
---|
86 | #endif
|
---|
87 |
|
---|
88 | /* The minimum number of bytes or pixels for which to use the
|
---|
89 | implementation's accelerated functions. */
|
---|
90 | extern unsigned int rootless_CopyBytes_threshold;
|
---|
91 | extern unsigned int rootless_FillBytes_threshold;
|
---|
92 | extern unsigned int rootless_CompositePixels_threshold;
|
---|
93 | extern unsigned int rootless_CopyWindow_threshold;
|
---|
94 |
|
---|
95 | /* Operations used by CompositePixels */
|
---|
96 | enum rl_composite_op_enum {
|
---|
97 | RL_COMPOSITE_SRC = 0,
|
---|
98 | RL_COMPOSITE_OVER,
|
---|
99 | };
|
---|
100 |
|
---|
101 | /* Data formats for depth field and composite functions */
|
---|
102 | enum rl_depth_enum {
|
---|
103 | RL_DEPTH_NIL = 0, /* null source when compositing */
|
---|
104 | RL_DEPTH_ARGB8888,
|
---|
105 | RL_DEPTH_RGB555,
|
---|
106 | RL_DEPTH_A8, /* for masks when compositing */
|
---|
107 | RL_DEPTH_INDEX8,
|
---|
108 | };
|
---|
109 |
|
---|
110 | /* Macro to form the composite function for CompositePixels */
|
---|
111 | #define RL_COMPOSITE_FUNCTION(op, src_depth, mask_depth, dest_depth) \
|
---|
112 | (((op) << 24) | ((src_depth) << 16) \
|
---|
113 | | ((mask_depth) << 8) | ((dest_depth) << 0))
|
---|
114 |
|
---|
115 | /* Gravity for window contents during resizing */
|
---|
116 | enum rl_gravity_enum {
|
---|
117 | RL_GRAVITY_NONE = 0, /* no gravity, fill everything */
|
---|
118 | RL_GRAVITY_NORTH_WEST = 1, /* anchor to top-left corner */
|
---|
119 | RL_GRAVITY_NORTH_EAST = 2, /* anchor to top-right corner */
|
---|
120 | RL_GRAVITY_SOUTH_EAST = 3, /* anchor to bottom-right corner */
|
---|
121 | RL_GRAVITY_SOUTH_WEST = 4, /* anchor to bottom-left corner */
|
---|
122 | };
|
---|
123 |
|
---|
124 |
|
---|
125 | /*------------------------------------------
|
---|
126 | Rootless Implementation Functions
|
---|
127 | ------------------------------------------*/
|
---|
128 |
|
---|
129 | /*
|
---|
130 | * Create a new frame.
|
---|
131 | * The frame is created unmapped.
|
---|
132 | *
|
---|
133 | * pFrame RootlessWindowPtr for this frame should be completely
|
---|
134 | * initialized before calling except for pFrame->wid, which
|
---|
135 | * is set by this function.
|
---|
136 | * pScreen Screen on which to place the new frame
|
---|
137 | * newX, newY Position of the frame. These will be identical to pFrame-x,
|
---|
138 | * pFrame->y unless ROOTLESS_GLOBAL_COORDS is set.
|
---|
139 | * pNewShape Shape for the frame (in frame-local coordinates). NULL for
|
---|
140 | * unshaped frames.
|
---|
141 | */
|
---|
142 | typedef Bool (*RootlessCreateFrameProc)
|
---|
143 | (RootlessWindowPtr pFrame, ScreenPtr pScreen, int newX, int newY,
|
---|
144 | RegionPtr pNewShape);
|
---|
145 |
|
---|
146 | /*
|
---|
147 | * Destroy a frame.
|
---|
148 | * Drawing is stopped and all updates are flushed before this is called.
|
---|
149 | *
|
---|
150 | * wid Frame id
|
---|
151 | */
|
---|
152 | typedef void (*RootlessDestroyFrameProc)
|
---|
153 | (RootlessFrameID wid);
|
---|
154 |
|
---|
155 | /*
|
---|
156 | * Move a frame on screen.
|
---|
157 | * Drawing is stopped and all updates are flushed before this is called.
|
---|
158 | *
|
---|
159 | * wid Frame id
|
---|
160 | * pScreen Screen to move the new frame to
|
---|
161 | * newX, newY New position of the frame
|
---|
162 | */
|
---|
163 | typedef void (*RootlessMoveFrameProc)
|
---|
164 | (RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
|
---|
165 |
|
---|
166 | /*
|
---|
167 | * Resize and move a frame.
|
---|
168 | * Drawing is stopped and all updates are flushed before this is called.
|
---|
169 | *
|
---|
170 | * wid Frame id
|
---|
171 | * pScreen Screen to move the new frame to
|
---|
172 | * newX, newY New position of the frame
|
---|
173 | * newW, newH New size of the frame
|
---|
174 | * gravity Gravity for window contents (rl_gravity_enum). This is always
|
---|
175 | * RL_GRAVITY_NONE unless ROOTLESS_RESIZE_GRAVITY is set.
|
---|
176 | */
|
---|
177 | typedef void (*RootlessResizeFrameProc)
|
---|
178 | (RootlessFrameID wid, ScreenPtr pScreen,
|
---|
179 | int newX, int newY, unsigned int newW, unsigned int newH,
|
---|
180 | unsigned int gravity);
|
---|
181 |
|
---|
182 | /*
|
---|
183 | * Change frame ordering (AKA stacking, layering).
|
---|
184 | * Drawing is stopped before this is called. Unmapped frames are mapped by
|
---|
185 | * setting their ordering.
|
---|
186 | *
|
---|
187 | * wid Frame id
|
---|
188 | * nextWid Frame id of frame that is now above this one or NULL if this
|
---|
189 | * frame is at the top.
|
---|
190 | */
|
---|
191 | typedef void (*RootlessRestackFrameProc)
|
---|
192 | (RootlessFrameID wid, RootlessFrameID nextWid);
|
---|
193 |
|
---|
194 | /*
|
---|
195 | * Change frame's shape.
|
---|
196 | * Drawing is stopped before this is called.
|
---|
197 | *
|
---|
198 | * wid Frame id
|
---|
199 | * pNewShape New shape for the frame (in frame-local coordinates)
|
---|
200 | * or NULL if now unshaped.
|
---|
201 | */
|
---|
202 | typedef void (*RootlessReshapeFrameProc)
|
---|
203 | (RootlessFrameID wid, RegionPtr pNewShape);
|
---|
204 |
|
---|
205 | /*
|
---|
206 | * Unmap a frame.
|
---|
207 | *
|
---|
208 | * wid Frame id
|
---|
209 | */
|
---|
210 | typedef void (*RootlessUnmapFrameProc)
|
---|
211 | (RootlessFrameID wid);
|
---|
212 |
|
---|
213 | /*
|
---|
214 | * Start drawing to a frame.
|
---|
215 | * Prepare a frame for direct access to its backing buffer.
|
---|
216 | *
|
---|
217 | * wid Frame id
|
---|
218 | * pixelData Address of the backing buffer (returned)
|
---|
219 | * bytesPerRow Width in bytes of the backing buffer (returned)
|
---|
220 | */
|
---|
221 | typedef void (*RootlessStartDrawingProc)
|
---|
222 | (RootlessFrameID wid, char **pixelData, int *bytesPerRow);
|
---|
223 |
|
---|
224 | /*
|
---|
225 | * Stop drawing to a frame.
|
---|
226 | * No drawing to the frame's backing buffer will occur until drawing
|
---|
227 | * is started again.
|
---|
228 | *
|
---|
229 | * wid Frame id
|
---|
230 | * flush Flush drawing updates for this frame to the screen. This
|
---|
231 | * will always be FALSE if ROOTLESS_TRACK_DAMAGE is set.
|
---|
232 | */
|
---|
233 | typedef void (*RootlessStopDrawingProc)
|
---|
234 | (RootlessFrameID wid, Bool flush);
|
---|
235 |
|
---|
236 | /*
|
---|
237 | * Flush drawing updates to the screen.
|
---|
238 | * Drawing is stopped before this is called.
|
---|
239 | *
|
---|
240 | * wid Frame id
|
---|
241 | * pDamage Region containing all the changed pixels in frame-lcoal
|
---|
242 | * coordinates. This is clipped to the window's clip. This
|
---|
243 | * will be NULL if ROOTLESS_TRACK_DAMAGE is not set.
|
---|
244 | */
|
---|
245 | typedef void (*RootlessUpdateRegionProc)
|
---|
246 | (RootlessFrameID wid, RegionPtr pDamage);
|
---|
247 |
|
---|
248 | /*
|
---|
249 | * Mark damaged rectangles as requiring redisplay to screen.
|
---|
250 | * This will only be called if ROOTLESS_TRACK_DAMAGE is not set.
|
---|
251 | *
|
---|
252 | * wid Frame id
|
---|
253 | * nrects Number of damaged rectangles
|
---|
254 | * rects Array of damaged rectangles in frame-local coordinates
|
---|
255 | * shift_x, Vector to shift rectangles by
|
---|
256 | * shift_y
|
---|
257 | */
|
---|
258 | typedef void (*RootlessDamageRectsProc)
|
---|
259 | (RootlessFrameID wid, int nrects, const BoxRec *rects,
|
---|
260 | int shift_x, int shift_y);
|
---|
261 |
|
---|
262 | /*
|
---|
263 | * Switch the window associated with a frame. (Optional)
|
---|
264 | * When a framed window is reparented, the frame is resized and set to
|
---|
265 | * use the new top-level parent. If defined this function will be called
|
---|
266 | * afterwards for implementation specific bookkeeping.
|
---|
267 | *
|
---|
268 | * pFrame Frame whose window has switched
|
---|
269 | * oldWin Previous window wrapped by this frame
|
---|
270 | */
|
---|
271 | typedef void (*RootlessSwitchWindowProc)
|
---|
272 | (RootlessWindowPtr pFrame, WindowPtr oldWin);
|
---|
273 |
|
---|
274 | /*
|
---|
275 | * Check if window should be reordered. (Optional)
|
---|
276 | * The underlying window system may animate windows being ordered in.
|
---|
277 | * We want them to be mapped but remain ordered out until the animation
|
---|
278 | * completes. If defined this function will be called to check if a
|
---|
279 | * framed window should be reordered now. If this function returns
|
---|
280 | * FALSE, the window will still be mapped from the X11 perspective, but
|
---|
281 | * the RestackFrame function will not be called for its frame.
|
---|
282 | *
|
---|
283 | * pFrame Frame to reorder
|
---|
284 | */
|
---|
285 | typedef Bool (*RootlessDoReorderWindowProc)
|
---|
286 | (RootlessWindowPtr pFrame);
|
---|
287 |
|
---|
288 | /*
|
---|
289 | * Copy bytes. (Optional)
|
---|
290 | * Source and destinate may overlap and the right thing should happen.
|
---|
291 | *
|
---|
292 | * width Bytes to copy per row
|
---|
293 | * height Number of rows
|
---|
294 | * src Source data
|
---|
295 | * srcRowBytes Width of source in bytes
|
---|
296 | * dst Destination data
|
---|
297 | * dstRowBytes Width of destination in bytes
|
---|
298 | */
|
---|
299 | typedef void (*RootlessCopyBytesProc)
|
---|
300 | (unsigned int width, unsigned int height,
|
---|
301 | const void *src, unsigned int srcRowBytes,
|
---|
302 | void *dst, unsigned int dstRowBytes);
|
---|
303 |
|
---|
304 | /*
|
---|
305 | * Fill memory with 32-bit pattern. (Optional)
|
---|
306 | *
|
---|
307 | * width Bytes to fill per row
|
---|
308 | * height Number of rows
|
---|
309 | * value 32-bit pattern to fill with
|
---|
310 | * dst Destination data
|
---|
311 | * dstRowBytes Width of destination in bytes
|
---|
312 | */
|
---|
313 | typedef void (*RootlessFillBytesProc)
|
---|
314 | (unsigned int width, unsigned int height, unsigned int value,
|
---|
315 | void *dst, unsigned int dstRowBytes);
|
---|
316 |
|
---|
317 | /*
|
---|
318 | * Composite pixels from source and mask to destination. (Optional)
|
---|
319 | *
|
---|
320 | * width, height Size of area to composite to in pizels
|
---|
321 | * function Composite function built with RL_COMPOSITE_FUNCTION
|
---|
322 | * src Source data
|
---|
323 | * srcRowBytes Width of source in bytes (Passing NULL means source
|
---|
324 | * is a single pixel.
|
---|
325 | * mask Mask data
|
---|
326 | * maskRowBytes Width of mask in bytes
|
---|
327 | * dst Destination data
|
---|
328 | * dstRowBytes Width of destination in bytes
|
---|
329 | *
|
---|
330 | * For src and dst, the first element of the array is the color data. If
|
---|
331 | * the second element is non-null it implies there is alpha data (which
|
---|
332 | * may be meshed or planar). Data without alpha is assumed to be opaque.
|
---|
333 | *
|
---|
334 | * An X11 error code is returned.
|
---|
335 | */
|
---|
336 | typedef int (*RootlessCompositePixelsProc)
|
---|
337 | (unsigned int width, unsigned int height, unsigned int function,
|
---|
338 | void *src[2], unsigned int srcRowBytes[2],
|
---|
339 | void *mask, unsigned int maskRowBytes,
|
---|
340 | void *dst[2], unsigned int dstRowBytes[2]);
|
---|
341 |
|
---|
342 | /*
|
---|
343 | * Copy area in frame to another part of frame. (Optional)
|
---|
344 | *
|
---|
345 | * wid Frame id
|
---|
346 | * dstNrects Number of rectangles to copy
|
---|
347 | * dstRects Array of rectangles to copy
|
---|
348 | * dx, dy Number of pixels away to copy area
|
---|
349 | */
|
---|
350 | typedef void (*RootlessCopyWindowProc)
|
---|
351 | (RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
|
---|
352 | int dx, int dy);
|
---|
353 |
|
---|
354 | /*
|
---|
355 | * Rootless implementation function list
|
---|
356 | */
|
---|
357 | typedef struct _RootlessFrameProcs {
|
---|
358 | RootlessCreateFrameProc CreateFrame;
|
---|
359 | RootlessDestroyFrameProc DestroyFrame;
|
---|
360 |
|
---|
361 | RootlessMoveFrameProc MoveFrame;
|
---|
362 | RootlessResizeFrameProc ResizeFrame;
|
---|
363 | RootlessRestackFrameProc RestackFrame;
|
---|
364 | RootlessReshapeFrameProc ReshapeFrame;
|
---|
365 | RootlessUnmapFrameProc UnmapFrame;
|
---|
366 |
|
---|
367 | RootlessStartDrawingProc StartDrawing;
|
---|
368 | RootlessStopDrawingProc StopDrawing;
|
---|
369 | RootlessUpdateRegionProc UpdateRegion;
|
---|
370 | #ifndef ROOTLESS_TRACK_DAMAGE
|
---|
371 | RootlessDamageRectsProc DamageRects;
|
---|
372 | #endif
|
---|
373 |
|
---|
374 | /* Optional frame functions */
|
---|
375 | RootlessSwitchWindowProc SwitchWindow;
|
---|
376 | RootlessDoReorderWindowProc DoReorderWindow;
|
---|
377 |
|
---|
378 | /* Optional acceleration functions */
|
---|
379 | RootlessCopyBytesProc CopyBytes;
|
---|
380 | RootlessFillBytesProc FillBytes;
|
---|
381 | RootlessCompositePixelsProc CompositePixels;
|
---|
382 | RootlessCopyWindowProc CopyWindow;
|
---|
383 | } RootlessFrameProcsRec, *RootlessFrameProcsPtr;
|
---|
384 |
|
---|
385 |
|
---|
386 | /*
|
---|
387 | * Initialize rootless mode on the given screen.
|
---|
388 | */
|
---|
389 | Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs);
|
---|
390 |
|
---|
391 | /*
|
---|
392 | * Initialize acceleration for rootless mode on a given screen.
|
---|
393 | * Note: RootlessAccelInit() must be called before DamageSetup()
|
---|
394 | * and RootlessInit() must be called afterwards.
|
---|
395 | */
|
---|
396 | Bool RootlessAccelInit(ScreenPtr pScreen);
|
---|
397 |
|
---|
398 | /*
|
---|
399 | * Return the frame ID for the physical window displaying the given window.
|
---|
400 | *
|
---|
401 | * create If true and the window has no frame, attempt to create one
|
---|
402 | */
|
---|
403 | RootlessFrameID RootlessFrameForWindow(WindowPtr pWin, Bool create);
|
---|
404 |
|
---|
405 | /*
|
---|
406 | * Return the top-level parent of a window.
|
---|
407 | * The root is the top-level parent of itself, even though the root is
|
---|
408 | * not otherwise considered to be a top-level window.
|
---|
409 | */
|
---|
410 | WindowPtr TopLevelParent(WindowPtr pWindow);
|
---|
411 |
|
---|
412 | /*
|
---|
413 | * Prepare a window for direct access to its backing buffer.
|
---|
414 | */
|
---|
415 | void RootlessStartDrawing(WindowPtr pWindow);
|
---|
416 |
|
---|
417 | /*
|
---|
418 | * Finish drawing to a window's backing buffer.
|
---|
419 | *
|
---|
420 | * flush If true and ROOTLESS_TRACK_DAMAGE is set, damaged areas
|
---|
421 | * are flushed to the screen.
|
---|
422 | */
|
---|
423 | void RootlessStopDrawing(WindowPtr pWindow, Bool flush);
|
---|
424 |
|
---|
425 | /*
|
---|
426 | * Alocate a new screen pixmap.
|
---|
427 | * miCreateScreenResources does not do this properly with a null
|
---|
428 | * framebuffer pointer.
|
---|
429 | */
|
---|
430 | void RootlessUpdateScreenPixmap(ScreenPtr pScreen);
|
---|
431 |
|
---|
432 | /*
|
---|
433 | * Reposition all windows on a screen to their correct positions.
|
---|
434 | */
|
---|
435 | void RootlessRepositionWindows(ScreenPtr pScreen);
|
---|
436 |
|
---|
437 | /*
|
---|
438 | * Bring all windows to the front of the Aqua stack
|
---|
439 | */
|
---|
440 | void RootlessOrderAllWindows (void);
|
---|
441 | #endif /* _ROOTLESS_H */
|
---|