VirtualBox

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

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

export to OSE

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