1706f2543Smrg/* 2706f2543Smrg * External interface to generic rootless mode 3706f2543Smrg */ 4706f2543Smrg/* 5706f2543Smrg * Copyright (c) 2001 Greg Parker. All Rights Reserved. 6706f2543Smrg * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved. 7706f2543Smrg * 8706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a 9706f2543Smrg * copy of this software and associated documentation files (the "Software"), 10706f2543Smrg * to deal in the Software without restriction, including without limitation 11706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the 13706f2543Smrg * Software is furnished to do so, subject to the following conditions: 14706f2543Smrg * 15706f2543Smrg * The above copyright notice and this permission notice shall be included in 16706f2543Smrg * all copies or substantial portions of the Software. 17706f2543Smrg * 18706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19706f2543Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21706f2543Smrg * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 22706f2543Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23706f2543Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24706f2543Smrg * DEALINGS IN THE SOFTWARE. 25706f2543Smrg * 26706f2543Smrg * Except as contained in this notice, the name(s) of the above copyright 27706f2543Smrg * holders shall not be used in advertising or otherwise to promote the sale, 28706f2543Smrg * use or other dealings in this Software without prior written authorization. 29706f2543Smrg */ 30706f2543Smrg 31706f2543Smrg#ifdef HAVE_DIX_CONFIG_H 32706f2543Smrg#include <dix-config.h> 33706f2543Smrg#endif 34706f2543Smrg 35706f2543Smrg#ifndef _ROOTLESS_H 36706f2543Smrg#define _ROOTLESS_H 37706f2543Smrg 38706f2543Smrg#include "rootlessConfig.h" 39706f2543Smrg#include "mi.h" 40706f2543Smrg#include "gcstruct.h" 41706f2543Smrg 42706f2543Smrg/* 43706f2543Smrg Each top-level rootless window has a one-to-one correspondence to a physical 44706f2543Smrg on-screen window. The physical window is refered to as a "frame". 45706f2543Smrg */ 46706f2543Smrg 47706f2543Smrgtypedef void * RootlessFrameID; 48706f2543Smrg 49706f2543Smrg/* 50706f2543Smrg * RootlessWindowRec 51706f2543Smrg * This structure stores the per-frame data used by the rootless code. 52706f2543Smrg * Each top-level X window has one RootlessWindowRec associated with it. 53706f2543Smrg */ 54706f2543Smrgtypedef struct _RootlessWindowRec { 55706f2543Smrg // Position and size includes the window border 56706f2543Smrg // Position is in per-screen coordinates 57706f2543Smrg int x, y; 58706f2543Smrg unsigned int width, height; 59706f2543Smrg unsigned int borderWidth; 60706f2543Smrg int level; 61706f2543Smrg 62706f2543Smrg RootlessFrameID wid; // implementation specific frame id 63706f2543Smrg WindowPtr win; // underlying X window 64706f2543Smrg 65706f2543Smrg // Valid only when drawing (ie. is_drawing is set) 66706f2543Smrg char *pixelData; 67706f2543Smrg int bytesPerRow; 68706f2543Smrg 69706f2543Smrg PixmapPtr pixmap; 70706f2543Smrg 71706f2543Smrg unsigned int is_drawing :1; // Currently drawing? 72706f2543Smrg unsigned int is_reorder_pending :1; 73706f2543Smrg unsigned int is_offscreen :1; 74706f2543Smrg unsigned int is_obscured :1; 75706f2543Smrg} RootlessWindowRec, *RootlessWindowPtr; 76706f2543Smrg 77706f2543Smrg 78706f2543Smrg/* Offset for screen-local to global coordinate transforms */ 79706f2543Smrgextern int rootlessGlobalOffsetX; 80706f2543Smrgextern int rootlessGlobalOffsetY; 81706f2543Smrg 82706f2543Smrg/* The minimum number of bytes or pixels for which to use the 83706f2543Smrg implementation's accelerated functions. */ 84706f2543Smrgextern unsigned int rootless_CopyBytes_threshold; 85706f2543Smrgextern unsigned int rootless_CopyWindow_threshold; 86706f2543Smrg 87706f2543Smrg/* Gravity for window contents during resizing */ 88706f2543Smrgenum rl_gravity_enum { 89706f2543Smrg RL_GRAVITY_NONE = 0, /* no gravity, fill everything */ 90706f2543Smrg RL_GRAVITY_NORTH_WEST = 1, /* anchor to top-left corner */ 91706f2543Smrg RL_GRAVITY_NORTH_EAST = 2, /* anchor to top-right corner */ 92706f2543Smrg RL_GRAVITY_SOUTH_EAST = 3, /* anchor to bottom-right corner */ 93706f2543Smrg RL_GRAVITY_SOUTH_WEST = 4, /* anchor to bottom-left corner */ 94706f2543Smrg}; 95706f2543Smrg 96706f2543Smrg 97706f2543Smrg/*------------------------------------------ 98706f2543Smrg Rootless Implementation Functions 99706f2543Smrg ------------------------------------------*/ 100706f2543Smrg 101706f2543Smrg/* 102706f2543Smrg * Create a new frame. 103706f2543Smrg * The frame is created unmapped. 104706f2543Smrg * 105706f2543Smrg * pFrame RootlessWindowPtr for this frame should be completely 106706f2543Smrg * initialized before calling except for pFrame->wid, which 107706f2543Smrg * is set by this function. 108706f2543Smrg * pScreen Screen on which to place the new frame 109706f2543Smrg * newX, newY Position of the frame. 110706f2543Smrg * pNewShape Shape for the frame (in frame-local coordinates). NULL for 111706f2543Smrg * unshaped frames. 112706f2543Smrg */ 113706f2543Smrgtypedef Bool (*RootlessCreateFrameProc) 114706f2543Smrg (RootlessWindowPtr pFrame, ScreenPtr pScreen, int newX, int newY, 115706f2543Smrg RegionPtr pNewShape); 116706f2543Smrg 117706f2543Smrg/* 118706f2543Smrg * Destroy a frame. 119706f2543Smrg * Drawing is stopped and all updates are flushed before this is called. 120706f2543Smrg * 121706f2543Smrg * wid Frame id 122706f2543Smrg */ 123706f2543Smrgtypedef void (*RootlessDestroyFrameProc) 124706f2543Smrg (RootlessFrameID wid); 125706f2543Smrg 126706f2543Smrg/* 127706f2543Smrg * Move a frame on screen. 128706f2543Smrg * Drawing is stopped and all updates are flushed before this is called. 129706f2543Smrg * 130706f2543Smrg * wid Frame id 131706f2543Smrg * pScreen Screen to move the new frame to 132706f2543Smrg * newX, newY New position of the frame 133706f2543Smrg */ 134706f2543Smrgtypedef void (*RootlessMoveFrameProc) 135706f2543Smrg (RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY); 136706f2543Smrg 137706f2543Smrg/* 138706f2543Smrg * Resize and move a frame. 139706f2543Smrg * Drawing is stopped and all updates are flushed before this is called. 140706f2543Smrg * 141706f2543Smrg * wid Frame id 142706f2543Smrg * pScreen Screen to move the new frame to 143706f2543Smrg * newX, newY New position of the frame 144706f2543Smrg * newW, newH New size of the frame 145706f2543Smrg * gravity Gravity for window contents (rl_gravity_enum). This is always 146706f2543Smrg * RL_GRAVITY_NONE unless ROOTLESS_RESIZE_GRAVITY is set. 147706f2543Smrg */ 148706f2543Smrgtypedef void (*RootlessResizeFrameProc) 149706f2543Smrg (RootlessFrameID wid, ScreenPtr pScreen, 150706f2543Smrg int newX, int newY, unsigned int newW, unsigned int newH, 151706f2543Smrg unsigned int gravity); 152706f2543Smrg 153706f2543Smrg/* 154706f2543Smrg * Change frame ordering (AKA stacking, layering). 155706f2543Smrg * Drawing is stopped before this is called. Unmapped frames are mapped by 156706f2543Smrg * setting their ordering. 157706f2543Smrg * 158706f2543Smrg * wid Frame id 159706f2543Smrg * nextWid Frame id of frame that is now above this one or NULL if this 160706f2543Smrg * frame is at the top. 161706f2543Smrg */ 162706f2543Smrgtypedef void (*RootlessRestackFrameProc) 163706f2543Smrg (RootlessFrameID wid, RootlessFrameID nextWid); 164706f2543Smrg 165706f2543Smrg/* 166706f2543Smrg * Change frame's shape. 167706f2543Smrg * Drawing is stopped before this is called. 168706f2543Smrg * 169706f2543Smrg * wid Frame id 170706f2543Smrg * pNewShape New shape for the frame (in frame-local coordinates) 171706f2543Smrg * or NULL if now unshaped. 172706f2543Smrg */ 173706f2543Smrgtypedef void (*RootlessReshapeFrameProc) 174706f2543Smrg (RootlessFrameID wid, RegionPtr pNewShape); 175706f2543Smrg 176706f2543Smrg/* 177706f2543Smrg * Unmap a frame. 178706f2543Smrg * 179706f2543Smrg * wid Frame id 180706f2543Smrg */ 181706f2543Smrgtypedef void (*RootlessUnmapFrameProc) 182706f2543Smrg (RootlessFrameID wid); 183706f2543Smrg 184706f2543Smrg/* 185706f2543Smrg * Start drawing to a frame. 186706f2543Smrg * Prepare a frame for direct access to its backing buffer. 187706f2543Smrg * 188706f2543Smrg * wid Frame id 189706f2543Smrg * pixelData Address of the backing buffer (returned) 190706f2543Smrg * bytesPerRow Width in bytes of the backing buffer (returned) 191706f2543Smrg */ 192706f2543Smrgtypedef void (*RootlessStartDrawingProc) 193706f2543Smrg (RootlessFrameID wid, char **pixelData, int *bytesPerRow); 194706f2543Smrg 195706f2543Smrg/* 196706f2543Smrg * Stop drawing to a frame. 197706f2543Smrg * No drawing to the frame's backing buffer will occur until drawing 198706f2543Smrg * is started again. 199706f2543Smrg * 200706f2543Smrg * wid Frame id 201706f2543Smrg * flush Flush drawing updates for this frame to the screen. 202706f2543Smrg */ 203706f2543Smrgtypedef void (*RootlessStopDrawingProc) 204706f2543Smrg (RootlessFrameID wid, Bool flush); 205706f2543Smrg 206706f2543Smrg/* 207706f2543Smrg * Flush drawing updates to the screen. 208706f2543Smrg * Drawing is stopped before this is called. 209706f2543Smrg * 210706f2543Smrg * wid Frame id 211706f2543Smrg * pDamage Region containing all the changed pixels in frame-lcoal 212706f2543Smrg * coordinates. This is clipped to the window's clip. 213706f2543Smrg */ 214706f2543Smrgtypedef void (*RootlessUpdateRegionProc) 215706f2543Smrg (RootlessFrameID wid, RegionPtr pDamage); 216706f2543Smrg 217706f2543Smrg/* 218706f2543Smrg * Mark damaged rectangles as requiring redisplay to screen. 219706f2543Smrg * 220706f2543Smrg * wid Frame id 221706f2543Smrg * nrects Number of damaged rectangles 222706f2543Smrg * rects Array of damaged rectangles in frame-local coordinates 223706f2543Smrg * shift_x, Vector to shift rectangles by 224706f2543Smrg * shift_y 225706f2543Smrg */ 226706f2543Smrgtypedef void (*RootlessDamageRectsProc) 227706f2543Smrg (RootlessFrameID wid, int nrects, const BoxRec *rects, 228706f2543Smrg int shift_x, int shift_y); 229706f2543Smrg 230706f2543Smrg/* 231706f2543Smrg * Switch the window associated with a frame. (Optional) 232706f2543Smrg * When a framed window is reparented, the frame is resized and set to 233706f2543Smrg * use the new top-level parent. If defined this function will be called 234706f2543Smrg * afterwards for implementation specific bookkeeping. 235706f2543Smrg * 236706f2543Smrg * pFrame Frame whose window has switched 237706f2543Smrg * oldWin Previous window wrapped by this frame 238706f2543Smrg */ 239706f2543Smrgtypedef void (*RootlessSwitchWindowProc) 240706f2543Smrg (RootlessWindowPtr pFrame, WindowPtr oldWin); 241706f2543Smrg 242706f2543Smrg/* 243706f2543Smrg * Check if window should be reordered. (Optional) 244706f2543Smrg * The underlying window system may animate windows being ordered in. 245706f2543Smrg * We want them to be mapped but remain ordered out until the animation 246706f2543Smrg * completes. If defined this function will be called to check if a 247706f2543Smrg * framed window should be reordered now. If this function returns 248706f2543Smrg * FALSE, the window will still be mapped from the X11 perspective, but 249706f2543Smrg * the RestackFrame function will not be called for its frame. 250706f2543Smrg * 251706f2543Smrg * pFrame Frame to reorder 252706f2543Smrg */ 253706f2543Smrgtypedef Bool (*RootlessDoReorderWindowProc) 254706f2543Smrg (RootlessWindowPtr pFrame); 255706f2543Smrg 256706f2543Smrg/* 257706f2543Smrg * Copy bytes. (Optional) 258706f2543Smrg * Source and destinate may overlap and the right thing should happen. 259706f2543Smrg * 260706f2543Smrg * width Bytes to copy per row 261706f2543Smrg * height Number of rows 262706f2543Smrg * src Source data 263706f2543Smrg * srcRowBytes Width of source in bytes 264706f2543Smrg * dst Destination data 265706f2543Smrg * dstRowBytes Width of destination in bytes 266706f2543Smrg */ 267706f2543Smrgtypedef void (*RootlessCopyBytesProc) 268706f2543Smrg (unsigned int width, unsigned int height, 269706f2543Smrg const void *src, unsigned int srcRowBytes, 270706f2543Smrg void *dst, unsigned int dstRowBytes); 271706f2543Smrg 272706f2543Smrg/* 273706f2543Smrg * Copy area in frame to another part of frame. (Optional) 274706f2543Smrg * 275706f2543Smrg * wid Frame id 276706f2543Smrg * dstNrects Number of rectangles to copy 277706f2543Smrg * dstRects Array of rectangles to copy 278706f2543Smrg * dx, dy Number of pixels away to copy area 279706f2543Smrg */ 280706f2543Smrgtypedef void (*RootlessCopyWindowProc) 281706f2543Smrg (RootlessFrameID wid, int dstNrects, const BoxRec *dstRects, 282706f2543Smrg int dx, int dy); 283706f2543Smrg 284706f2543Smrg 285706f2543Smrgtypedef void (*RootlessHideWindowProc) 286706f2543Smrg (RootlessFrameID wid); 287706f2543Smrg 288706f2543Smrgtypedef void (*RootlessUpdateColormapProc) 289706f2543Smrg (RootlessFrameID wid, ScreenPtr pScreen); 290706f2543Smrg 291706f2543Smrg/* 292706f2543Smrg * Rootless implementation function list 293706f2543Smrg */ 294706f2543Smrgtypedef struct _RootlessFrameProcs { 295706f2543Smrg RootlessCreateFrameProc CreateFrame; 296706f2543Smrg RootlessDestroyFrameProc DestroyFrame; 297706f2543Smrg 298706f2543Smrg RootlessMoveFrameProc MoveFrame; 299706f2543Smrg RootlessResizeFrameProc ResizeFrame; 300706f2543Smrg RootlessRestackFrameProc RestackFrame; 301706f2543Smrg RootlessReshapeFrameProc ReshapeFrame; 302706f2543Smrg RootlessUnmapFrameProc UnmapFrame; 303706f2543Smrg 304706f2543Smrg RootlessStartDrawingProc StartDrawing; 305706f2543Smrg RootlessStopDrawingProc StopDrawing; 306706f2543Smrg RootlessUpdateRegionProc UpdateRegion; 307706f2543Smrg RootlessDamageRectsProc DamageRects; 308706f2543Smrg 309706f2543Smrg /* Optional frame functions */ 310706f2543Smrg RootlessSwitchWindowProc SwitchWindow; 311706f2543Smrg RootlessDoReorderWindowProc DoReorderWindow; 312706f2543Smrg RootlessHideWindowProc HideWindow; 313706f2543Smrg RootlessUpdateColormapProc UpdateColormap; 314706f2543Smrg 315706f2543Smrg /* Optional acceleration functions */ 316706f2543Smrg RootlessCopyBytesProc CopyBytes; 317706f2543Smrg RootlessCopyWindowProc CopyWindow; 318706f2543Smrg} RootlessFrameProcsRec, *RootlessFrameProcsPtr; 319706f2543Smrg 320706f2543Smrg 321706f2543Smrg/* 322706f2543Smrg * Initialize rootless mode on the given screen. 323706f2543Smrg */ 324706f2543SmrgBool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs); 325706f2543Smrg 326706f2543Smrg/* 327706f2543Smrg * Return the frame ID for the physical window displaying the given window. 328706f2543Smrg * 329706f2543Smrg * create If true and the window has no frame, attempt to create one 330706f2543Smrg */ 331706f2543SmrgRootlessFrameID RootlessFrameForWindow(WindowPtr pWin, Bool create); 332706f2543Smrg 333706f2543Smrg/* 334706f2543Smrg * Return the top-level parent of a window. 335706f2543Smrg * The root is the top-level parent of itself, even though the root is 336706f2543Smrg * not otherwise considered to be a top-level window. 337706f2543Smrg */ 338706f2543SmrgWindowPtr TopLevelParent(WindowPtr pWindow); 339706f2543Smrg 340706f2543Smrg/* 341706f2543Smrg * Prepare a window for direct access to its backing buffer. 342706f2543Smrg */ 343706f2543Smrgvoid RootlessStartDrawing(WindowPtr pWindow); 344706f2543Smrg 345706f2543Smrg/* 346706f2543Smrg * Finish drawing to a window's backing buffer. 347706f2543Smrg * 348706f2543Smrg * flush If true, damaged areas are flushed to the screen. 349706f2543Smrg */ 350706f2543Smrgvoid RootlessStopDrawing(WindowPtr pWindow, Bool flush); 351706f2543Smrg 352706f2543Smrg/* 353706f2543Smrg * Alocate a new screen pixmap. 354706f2543Smrg * miCreateScreenResources does not do this properly with a null 355706f2543Smrg * framebuffer pointer. 356706f2543Smrg */ 357706f2543Smrgvoid RootlessUpdateScreenPixmap(ScreenPtr pScreen); 358706f2543Smrg 359706f2543Smrg/* 360706f2543Smrg * Reposition all windows on a screen to their correct positions. 361706f2543Smrg */ 362706f2543Smrgvoid RootlessRepositionWindows(ScreenPtr pScreen); 363706f2543Smrg 364706f2543Smrg/* 365706f2543Smrg * Bring all windows to the front of the native stack 366706f2543Smrg */ 367706f2543Smrgvoid RootlessOrderAllWindows (Bool include_unhitable); 368706f2543Smrg#endif /* _ROOTLESS_H */ 369