2 * External interface to generic rootless mode
5 * Copyright (c) 2001 Greg Parker. All Rights Reserved.
6 * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
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:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
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.
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.
31 #ifdef HAVE_DIX_CONFIG_H
32 #include <dix-config.h>
38 #include "rootlessConfig.h"
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".
47 typedef void * RootlessFrameID
;
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.
54 typedef struct _RootlessWindowRec
{
55 // Position and size includes the window border
56 // Position is in per-screen coordinates
58 unsigned int width
, height
;
59 unsigned int borderWidth
;
61 RootlessFrameID wid
; // implementation specific frame id
62 WindowPtr win
; // underlying X window
64 // Valid only when drawing (ie. is_drawing is set)
71 #ifdef ROOTLESS_TRACK_DAMAGE
75 unsigned int is_drawing
:1; // Currently drawing?
76 unsigned int is_reorder_pending
:1;
77 } RootlessWindowRec
, *RootlessWindowPtr
;
80 /* Offset for screen-local to global coordinate transforms */
81 #ifdef ROOTLESS_GLOBAL_COORDS
82 extern int rootlessGlobalOffsetX
;
83 extern int rootlessGlobalOffsetY
;
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
;
93 /* Operations used by CompositePixels */
94 enum rl_composite_op_enum
{
99 /* Data formats for depth field and composite functions */
101 RL_DEPTH_NIL
= 0, /* null source when compositing */
104 RL_DEPTH_A8
, /* for masks when compositing */
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))
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 */
123 /*------------------------------------------
124 Rootless Implementation Functions
125 ------------------------------------------*/
128 * Create a new frame.
129 * The frame is created unmapped.
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
140 typedef Bool (*RootlessCreateFrameProc
)
141 (RootlessWindowPtr pFrame
, ScreenPtr pScreen
, int newX
, int newY
,
142 RegionPtr pNewShape
);
146 * Drawing is stopped and all updates are flushed before this is called.
150 typedef void (*RootlessDestroyFrameProc
)
151 (RootlessFrameID wid
);
154 * Move a frame on screen.
155 * Drawing is stopped and all updates are flushed before this is called.
158 * pScreen Screen to move the new frame to
159 * newX, newY New position of the frame
161 typedef void (*RootlessMoveFrameProc
)
162 (RootlessFrameID wid
, ScreenPtr pScreen
, int newX
, int newY
);
165 * Resize and move a frame.
166 * Drawing is stopped and all updates are flushed before this is called.
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.
175 typedef void (*RootlessResizeFrameProc
)
176 (RootlessFrameID wid
, ScreenPtr pScreen
,
177 int newX
, int newY
, unsigned int newW
, unsigned int newH
,
178 unsigned int gravity
);
181 * Change frame ordering (AKA stacking, layering).
182 * Drawing is stopped before this is called. Unmapped frames are mapped by
183 * setting their ordering.
186 * nextWid Frame id of frame that is now above this one or NULL if this
187 * frame is at the top.
189 typedef void (*RootlessRestackFrameProc
)
190 (RootlessFrameID wid
, RootlessFrameID nextWid
);
193 * Change frame's shape.
194 * Drawing is stopped before this is called.
197 * pNewShape New shape for the frame (in frame-local coordinates)
198 * or NULL if now unshaped.
200 typedef void (*RootlessReshapeFrameProc
)
201 (RootlessFrameID wid
, RegionPtr pNewShape
);
208 typedef void (*RootlessUnmapFrameProc
)
209 (RootlessFrameID wid
);
212 * Start drawing to a frame.
213 * Prepare a frame for direct access to its backing buffer.
216 * pixelData Address of the backing buffer (returned)
217 * bytesPerRow Width in bytes of the backing buffer (returned)
219 typedef void (*RootlessStartDrawingProc
)
220 (RootlessFrameID wid
, char **pixelData
, int *bytesPerRow
);
223 * Stop drawing to a frame.
224 * No drawing to the frame's backing buffer will occur until drawing
228 * flush Flush drawing updates for this frame to the screen. This
229 * will always be FALSE if ROOTLESS_TRACK_DAMAGE is set.
231 typedef void (*RootlessStopDrawingProc
)
232 (RootlessFrameID wid
, Bool flush
);
235 * Flush drawing updates to the screen.
236 * Drawing is stopped before this is called.
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.
243 typedef void (*RootlessUpdateRegionProc
)
244 (RootlessFrameID wid
, RegionPtr pDamage
);
247 * Mark damaged rectangles as requiring redisplay to screen.
248 * This will only be called if ROOTLESS_TRACK_DAMAGE is not set.
251 * nrects Number of damaged rectangles
252 * rects Array of damaged rectangles in frame-local coordinates
253 * shift_x, Vector to shift rectangles by
256 typedef void (*RootlessDamageRectsProc
)
257 (RootlessFrameID wid
, int nrects
, const BoxRec
*rects
,
258 int shift_x
, int shift_y
);
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.
266 * pFrame Frame whose window has switched
267 * oldWin Previous window wrapped by this frame
269 typedef void (*RootlessSwitchWindowProc
)
270 (RootlessWindowPtr pFrame
, WindowPtr oldWin
);
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.
281 * pFrame Frame to reorder
283 typedef Bool (*RootlessDoReorderWindowProc
)
284 (RootlessWindowPtr pFrame
);
287 * Copy bytes. (Optional)
288 * Source and destinate may overlap and the right thing should happen.
290 * width Bytes to copy per row
291 * height Number of rows
293 * srcRowBytes Width of source in bytes
294 * dst Destination data
295 * dstRowBytes Width of destination in bytes
297 typedef void (*RootlessCopyBytesProc
)
298 (unsigned int width
, unsigned int height
,
299 const void *src
, unsigned int srcRowBytes
,
300 void *dst
, unsigned int dstRowBytes
);
303 * Fill memory with 32-bit pattern. (Optional)
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
311 typedef void (*RootlessFillBytesProc
)
312 (unsigned int width
, unsigned int height
, unsigned int value
,
313 void *dst
, unsigned int dstRowBytes
);
316 * Composite pixels from source and mask to destination. (Optional)
318 * width, height Size of area to composite to in pizels
319 * function Composite function built with RL_COMPOSITE_FUNCTION
321 * srcRowBytes Width of source in bytes (Passing NULL means source
324 * maskRowBytes Width of mask in bytes
325 * dst Destination data
326 * dstRowBytes Width of destination in bytes
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.
332 * An X11 error code is returned.
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]);
341 * Copy area in frame to another part of frame. (Optional)
344 * dstNrects Number of rectangles to copy
345 * dstRects Array of rectangles to copy
346 * dx, dy Number of pixels away to copy area
348 typedef void (*RootlessCopyWindowProc
)
349 (RootlessFrameID wid
, int dstNrects
, const BoxRec
*dstRects
,
353 * Rootless implementation function list
355 typedef struct _RootlessFrameProcs
{
356 RootlessCreateFrameProc CreateFrame
;
357 RootlessDestroyFrameProc DestroyFrame
;
359 RootlessMoveFrameProc MoveFrame
;
360 RootlessResizeFrameProc ResizeFrame
;
361 RootlessRestackFrameProc RestackFrame
;
362 RootlessReshapeFrameProc ReshapeFrame
;
363 RootlessUnmapFrameProc UnmapFrame
;
365 RootlessStartDrawingProc StartDrawing
;
366 RootlessStopDrawingProc StopDrawing
;
367 RootlessUpdateRegionProc UpdateRegion
;
368 #ifndef ROOTLESS_TRACK_DAMAGE
369 RootlessDamageRectsProc DamageRects
;
372 /* Optional frame functions */
373 RootlessSwitchWindowProc SwitchWindow
;
374 RootlessDoReorderWindowProc DoReorderWindow
;
376 /* Optional acceleration functions */
377 RootlessCopyBytesProc CopyBytes
;
378 RootlessFillBytesProc FillBytes
;
379 RootlessCompositePixelsProc CompositePixels
;
380 RootlessCopyWindowProc CopyWindow
;
381 } RootlessFrameProcsRec
, *RootlessFrameProcsPtr
;
385 * Initialize rootless mode on the given screen.
387 Bool
RootlessInit(ScreenPtr pScreen
, RootlessFrameProcsPtr procs
);
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.
394 Bool
RootlessAccelInit(ScreenPtr pScreen
);
397 * Return the frame ID for the physical window displaying the given window.
399 * create If true and the window has no frame, attempt to create one
401 RootlessFrameID
RootlessFrameForWindow(WindowPtr pWin
, Bool create
);
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.
408 WindowPtr
TopLevelParent(WindowPtr pWindow
);
411 * Prepare a window for direct access to its backing buffer.
413 void RootlessStartDrawing(WindowPtr pWindow
);
416 * Finish drawing to a window's backing buffer.
418 * flush If true and ROOTLESS_TRACK_DAMAGE is set, damaged areas
419 * are flushed to the screen.
421 void RootlessStopDrawing(WindowPtr pWindow
, Bool flush
);
424 * Alocate a new screen pixmap.
425 * miCreateScreenResources does not do this properly with a null
426 * framebuffer pointer.
428 void RootlessUpdateScreenPixmap(ScreenPtr pScreen
);
431 * Reposition all windows on a screen to their correct positions.
433 void RootlessRepositionWindows(ScreenPtr pScreen
);
435 #endif /* _ROOTLESS_H */