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