f78b12e570284aa8291f4ca1add24937fd107403vboxsync/*
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Common internal rootless definitions and code
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/*
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Copyright (c) 2001 Greg Parker. All Rights Reserved.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync *
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Permission is hereby granted, free of charge, to any person obtaining a
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * copy of this software and associated documentation files (the "Software"),
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * to deal in the Software without restriction, including without limitation
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * the rights to use, copy, modify, merge, publish, distribute, sublicense,
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * and/or sell copies of the Software, and to permit persons to whom the
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Software is furnished to do so, subject to the following conditions:
f78b12e570284aa8291f4ca1add24937fd107403vboxsync *
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * The above copyright notice and this permission notice shall be included in
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * all copies or substantial portions of the Software.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync *
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * DEALINGS IN THE SOFTWARE.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync *
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Except as contained in this notice, the name(s) of the above copyright
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * holders shall not be used in advertising or otherwise to promote the sale,
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * use or other dealings in this Software without prior written authorization.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifdef HAVE_DIX_CONFIG_H
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <dix-config.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <stdint.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifndef _ROOTLESSCOMMON_H
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define _ROOTLESSCOMMON_H
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include "misc.h"
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include "rootless.h"
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include "fb.h"
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include "scrnintstr.h"
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include "picturestr.h"
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Debug output, or not.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifdef ROOTLESSDEBUG
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define RL_DEBUG_MSG ErrorF
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#else
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define RL_DEBUG_MSG(a, ...)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Global variables
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern DevPrivateKeyRec rootlessGCPrivateKeyRec;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define rootlessGCPrivateKey (&rootlessGCPrivateKeyRec)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern DevPrivateKeyRec rootlessScreenPrivateKeyRec;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define rootlessScreenPrivateKey (&rootlessScreenPrivateKeyRec)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern DevPrivateKeyRec rootlessWindowPrivateKeyRec;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define rootlessWindowPrivateKey (&rootlessWindowPrivateKeyRec)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern DevPrivateKeyRec rootlessWindowOldPixmapPrivateKeyRec;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define rootlessWindowOldPixmapPrivateKey (&rootlessWindowOldPixmapPrivateKeyRec)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// RootlessGCRec: private per-gc data
f78b12e570284aa8291f4ca1add24937fd107403vboxsynctypedef struct {
f78b12e570284aa8291f4ca1add24937fd107403vboxsync GCFuncs *originalFuncs;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync GCOps *originalOps;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync} RootlessGCRec;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// RootlessScreenRec: per-screen private data
f78b12e570284aa8291f4ca1add24937fd107403vboxsynctypedef struct _RootlessScreenRec {
f78b12e570284aa8291f4ca1add24937fd107403vboxsync // Rootless implementation functions
f78b12e570284aa8291f4ca1add24937fd107403vboxsync RootlessFrameProcsPtr imp;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync // Wrapped screen functions
f78b12e570284aa8291f4ca1add24937fd107403vboxsync CreateScreenResourcesProcPtr CreateScreenResources;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync CloseScreenProcPtr CloseScreen;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync CreateWindowProcPtr CreateWindow;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync DestroyWindowProcPtr DestroyWindow;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync RealizeWindowProcPtr RealizeWindow;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync UnrealizeWindowProcPtr UnrealizeWindow;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync MoveWindowProcPtr MoveWindow;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ResizeWindowProcPtr ResizeWindow;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync RestackWindowProcPtr RestackWindow;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ReparentWindowProcPtr ReparentWindow;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ChangeBorderWidthProcPtr ChangeBorderWidth;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync PositionWindowProcPtr PositionWindow;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ChangeWindowAttributesProcPtr ChangeWindowAttributes;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync CreateGCProcPtr CreateGC;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync CopyWindowProcPtr CopyWindow;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync GetImageProcPtr GetImage;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync SourceValidateProcPtr SourceValidate;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync MarkOverlappedWindowsProcPtr MarkOverlappedWindows;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ValidateTreeProcPtr ValidateTree;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync SetShapeProcPtr SetShape;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync CompositeProcPtr Composite;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync GlyphsProcPtr Glyphs;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync InstallColormapProcPtr InstallColormap;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync UninstallColormapProcPtr UninstallColormap;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync StoreColorsProcPtr StoreColors;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync void *pixmap_data;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync unsigned int pixmap_data_size;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ColormapPtr colormap;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync void *redisplay_timer;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync unsigned int redisplay_timer_set :1;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync unsigned int redisplay_queued :1;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync unsigned int redisplay_expired :1;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync unsigned int colormap_changed :1;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync} RootlessScreenRec, *RootlessScreenPtr;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// "Definition of the Porting Layer for the X11 Sample Server" says
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// unwrap and rewrap of screen functions is unnecessary, but
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// screen->CreateGC changes after a call to cfbCreateGC.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define SCREEN_UNWRAP(screen, fn) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync screen->fn = SCREENREC(screen)->fn;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define SCREEN_WRAP(screen, fn) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync SCREENREC(screen)->fn = screen->fn; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync screen->fn = Rootless##fn
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Accessors for screen and window privates
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define SCREENREC(pScreen) ((RootlessScreenRec *) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync dixLookupPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define SETSCREENREC(pScreen, v) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync dixSetPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey, v)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define WINREC(pWin) ((RootlessWindowRec *) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync dixLookupPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define SETWINREC(pWin, v) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync dixSetPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey, v)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Call a rootless implementation function.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Many rootless implementation functions are allowed to be NULL.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define CallFrameProc(pScreen, proc, params) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync if (SCREENREC(pScreen)->frameProcs.proc) { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync RL_DEBUG_MSG("calling frame proc " #proc " "); \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync SCREENREC(pScreen)->frameProcs.proc params; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync }
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// BoxRec manipulators
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Copied from shadowfb
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define TRIM_BOX(box, pGC) { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync BoxPtr extents = &pGC->pCompositeClip->extents;\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync if(box.x1 < extents->x1) box.x1 = extents->x1; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync if(box.x2 > extents->x2) box.x2 = extents->x2; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync if(box.y1 < extents->y1) box.y1 = extents->y1; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync if(box.y2 > extents->y2) box.y2 = extents->y2; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync}
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define TRANSLATE_BOX(box, pDraw) { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync box.x1 += pDraw->x; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync box.x2 += pDraw->x; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync box.y1 += pDraw->y; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync box.y2 += pDraw->y; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync}
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC) { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync TRANSLATE_BOX(box, pDraw); \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync TRIM_BOX(box, pGC); \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync}
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define BOX_NOT_EMPTY(box) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// HUGE_ROOT and NORMAL_ROOT
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// We don't want to clip windows to the edge of the screen.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// HUGE_ROOT temporarily makes the root window really big.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// This is needed as a wrapper around any function that calls
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// SetWinSize or SetBorderSize which clip a window against its
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// parents, including the root.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern RegionRec rootlessHugeRoot;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define HUGE_ROOT(pWin) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync do { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync WindowPtr w = pWin; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync while (w->parent) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync w = w->parent; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync saveRoot = w->winSize; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync w->winSize = rootlessHugeRoot; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync } while (0)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define NORMAL_ROOT(pWin) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync do { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync WindowPtr w = pWin; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync while (w->parent) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync w = w->parent; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync w->winSize = saveRoot; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync } while (0)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Returns TRUE if this window is a top-level window (i.e. child of the root)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// The root is not a top-level window.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define IsTopLevel(pWin) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((pWin) && (pWin)->parent && !(pWin)->parent->parent)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Returns TRUE if this window is a root window
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define IsRoot(pWin) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((pWin) == (pWin)->drawable.pScreen->root)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/*
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * SetPixmapBaseToScreen
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Move the given pixmap's base address to where pixel (0, 0)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * would be if the pixmap's actual data started at (x, y).
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Can't access the bits before the first word of the drawable's data in
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * rootless mode, so make sure our base address is always 32-bit aligned.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define SetPixmapBaseToScreen(pix, _x, _y) { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync PixmapPtr _pPix = (PixmapPtr) (pix); \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync (int)(_y) * _pPix->devKind); \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync if (_pPix->drawable.bitsPerPixel != FB_UNIT) { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync size_t _diff = ((size_t) _pPix->devPrivate.ptr) & \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync (FB_UNIT / CHAR_BIT - 1); \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync _diff; \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync _pPix->drawable.x = _diff / \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync (_pPix->drawable.bitsPerPixel / CHAR_BIT); \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync } \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync}
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Returns TRUE if this window is visible inside a frame
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// (e.g. it is visible and has a top-level or root parent)
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncBool IsFramedWindow(WindowPtr pWin);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Routines that cause regions to get redrawn.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// DamageRegion and DamageRect are in global coordinates.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// DamageBox is in window-local coordinates.
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion);
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h);
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox);
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessRedisplay(WindowPtr pWindow);
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessRedisplayScreen(ScreenPtr pScreen);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessQueueRedisplay(ScreenPtr pScreen);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* Return the colormap currently installed on the given screen. */
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncColormapPtr RootlessGetColormap (ScreenPtr pScreen);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* Convert colormap to ARGB. */
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncBool RootlessResolveColormap (ScreenPtr pScreen, int first_color,
f78b12e570284aa8291f4ca1add24937fd107403vboxsync int n_colors, uint32_t *colors);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessFlushWindowColormap (WindowPtr pWin);
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessFlushScreenColormaps (ScreenPtr pScreen);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Move a window to its proper location on the screen.
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessRepositionWindow(WindowPtr pWin);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync// Move the window to it's correct place in the physical stacking order.
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessReorderWindow(WindowPtr pWin);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessScreenExpose (ScreenPtr pScreen);
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessHideAllWindows (void);
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessShowAllWindows (void);
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessUpdateRooted (Bool state);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessEnableRoot (ScreenPtr pScreen);
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessDisableRoot (ScreenPtr pScreen);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncvoid RootlessSetPixmapOfAncestors(WindowPtr pWin);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif /* _ROOTLESSCOMMON_H */