xserver-multidpi/miext/rootless/rootlessScreen.c

753 lines
21 KiB
C
Raw Normal View History

2003-11-25 20:29:01 +01:00
/*
* Screen routines for generic rootless X server
*/
/*
* Copyright (c) 2001 Greg Parker. All Rights Reserved.
* Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
* Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright
* holders shall not be used in advertising or otherwise to promote the sale,
* use or other dealings in this Software without prior written authorization.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
2003-11-25 20:29:01 +01:00
#include "mi.h"
#include "scrnintstr.h"
#include "gcstruct.h"
#include "pixmapstr.h"
#include "windowstr.h"
#include "propertyst.h"
#include "mivalidate.h"
#include "picturestr.h"
#include "colormapst.h"
2003-11-25 20:29:01 +01:00
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include "rootlessCommon.h"
#include "rootlessWindow.h"
/* In milliseconds */
#ifndef ROOTLESS_REDISPLAY_DELAY
#define ROOTLESS_REDISPLAY_DELAY 10
#endif
extern int RootlessMiValidateTree(WindowPtr pRoot, WindowPtr pChild,
VTKind kind);
extern Bool RootlessCreateGC(GCPtr pGC);
// Initialize globals
DevPrivateKeyRec rootlessGCPrivateKeyRec;
DevPrivateKeyRec rootlessScreenPrivateKeyRec;
DevPrivateKeyRec rootlessWindowPrivateKeyRec;
DevPrivateKeyRec rootlessWindowOldPixmapPrivateKeyRec;
2003-11-25 20:29:01 +01:00
/*
* RootlessUpdateScreenPixmap
* miCreateScreenResources does not like a null framebuffer pointer,
* it leaves the screen pixmap with an uninitialized data pointer.
* Thus, rootless implementations typically set the framebuffer width
* to zero so that miCreateScreenResources does not allocate a screen
* pixmap for us. We allocate our own screen pixmap here since we need
* the screen pixmap to be valid (e.g. CopyArea from the root window).
*/
void
RootlessUpdateScreenPixmap(ScreenPtr pScreen)
{
RootlessScreenRec *s = SCREENREC(pScreen);
PixmapPtr pPix;
unsigned int rowbytes;
pPix = (*pScreen->GetScreenPixmap) (pScreen);
2003-11-25 20:29:01 +01:00
if (pPix == NULL) {
pPix = (*pScreen->CreatePixmap) (pScreen, 0, 0, pScreen->rootDepth, 0);
(*pScreen->SetScreenPixmap) (pPix);
2003-11-25 20:29:01 +01:00
}
rowbytes = PixmapBytePad(pScreen->width, pScreen->rootDepth);
if (s->pixmap_data_size < rowbytes) {
free(s->pixmap_data);
2003-11-25 20:29:01 +01:00
s->pixmap_data_size = rowbytes;
s->pixmap_data = malloc(s->pixmap_data_size);
2003-11-25 20:29:01 +01:00
if (s->pixmap_data == NULL)
return;
memset(s->pixmap_data, 0xFF, s->pixmap_data_size);
pScreen->ModifyPixmapHeader(pPix, pScreen->width, pScreen->height,
pScreen->rootDepth,
BitsPerPixel(pScreen->rootDepth),
0, s->pixmap_data);
/* ModifyPixmapHeader ignores zero arguments, so install rowbytes
by hand. */
pPix->devKind = 0;
}
}
/*
* RootlessCreateScreenResources
* Rootless implementations typically set a null framebuffer pointer, which
* causes problems with miCreateScreenResources. We fix things up here.
*/
static Bool
RootlessCreateScreenResources(ScreenPtr pScreen)
{
Bool ret = TRUE;
SCREEN_UNWRAP(pScreen, CreateScreenResources);
if (pScreen->CreateScreenResources != NULL)
ret = (*pScreen->CreateScreenResources) (pScreen);
2003-11-25 20:29:01 +01:00
SCREEN_WRAP(pScreen, CreateScreenResources);
if (!ret)
return ret;
/* Make sure we have a valid screen pixmap. */
RootlessUpdateScreenPixmap(pScreen);
return ret;
}
static Bool
api: rework the X server driver API to avoid global arrays. This is a squash merge containing all the API changes, as well as the video ABI bump. Its been squashed to make bisection easier. Full patch log below: commit b202738bbf0c5a1c1172767119c2c71f1e7f8070 Author: Aaron Plattner <aplattner@nvidia.com> Date: Mon May 14 15:16:11 2012 -0700 xfree86: Bump video ABI to 13.0 The ABI was broken by changes to convert from screen index numbers to ScreenPtr / ScrnInfoPtr in various structures and function signatures. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 10:56:57 2012 +0100 xf86: xf86ClearEntityListForScreen should take a pScrn When adding GPU screens this make life easier. (also fix comment, as pointed out by Alan) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Dave Airlie <airlied@redhat.com> commit afee8b5ab4501597ecc1ade34124d7ca227ab055 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 07:07:32 2012 +0100 xf86i2c: add pscrn for drivers to use This just adds a pScrn pointer into the struct for the drivers to use instead of scrnIndex. Mostly scrnIndex is used for logging, but some drivers use it to lookup xf86Screens, so let them stash a pScrn instead. Removing the scrnIndex is a bit more involved and I'm not sure its worth the effort. Doing i2c in the X server is legacy code as far as I'm concerned. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit ea5092f1f679691d187f1eee9427e6057beec56e Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 19:25:20 2012 +0100 dix/gc: consolidate GC object creation in one place The standard GC create and scratch GC create were 90% the same really, and I have a need in the future for creating GC objects without the other bits, so wanted to avoid a third copy. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 10:24:06 2012 +0100 xf86: add a define to denote the new non-index interfaces are being used This can be used by drivers to provide compatible APIs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 15:09:12 2012 +0100 dix: make Create/Free scratch pixmaps take a ScreenPtr While technically an API/ABI change I doubt anyone uses it, but it helps in splitting screens up. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:57:55 2012 +0100 xf86/xv: remove scrnIndexfrom xf86FindXvOptions. Move this interface to taking an ScrnInfoPtr. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:53:59 2012 +0100 xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2) stop passing indices into this function. v2: drop flags argument. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 58824e414f35682435f15bfe6c4b656bd90b9235 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:48:09 2012 +0100 xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:18:59 2012 +0100 xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2) Instead of passing an index, pass the actual ScreenPtr. This allows more moving towards not abusing xf86Screens + screenInfo. v2: drop the blockData/wakeupData args as per ajax's suggestion., fix docs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 790d003de20fb47674420a24dadd92412d78620d Author: Dave Airlie <airlied@gmail.com> Date: Wed Apr 11 09:53:14 2012 +0100 xf86/common: remove some more pScrn->pScreen uses remove some more conversions that appeared after api cleanups. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:34:53 2012 +0100 ddc: change API to take ScrnInfoPtr (v2) This removes all xf86Screens usage from ddc code, it modifies the API for some functions to avoid taking indices. v2: address Alan's comments about dropping DDC2Init parameter. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit fe3f57b6eaf6860a33876a54f9439f69578f03a5 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:31:26 2012 +0100 vbe: don't use index for VBEInterpretPanelID (API) Remove use of xf86screens from vbe module. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit abf1965f4ed91529036d3fdb470d6a3ce6f29675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:25:11 2012 +0100 int10/vbe: don't use xf86Screens. (ABI) (v3) Pass the ScrnInfoPtr instead of the index in the int10 struct. This saves us using it to dereference xf86Screens. v2: address Alan's comment to fix struct alignment. v3: squash in all the int10 fixes, test the vm86 code builds, after comments by Keith. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 23cca612b4fb5efc33683c7624b803b457387e3d Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:30:18 2012 +0100 xserver: drop index argument to ScreenInit (ABI/API) (v2) This drops the index argument, its the same as pScreen->myNum, and its the last major index abuse I can find. v2: address Alan's review - update docs, fix xwin/xnest/darwin Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:23:01 2012 +0100 xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API) This migrates PointerMoved from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:20:46 2012 +0100 xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API) This migrates the PMEvent from index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:18:30 2012 +0100 xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API) This migrates the SetDGAMode callback from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit baf5e4818a74f2b68c3dfdcc56f54322351039a0 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:14:11 2012 +0100 xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2) This migrates the ChangeGamma interface to avoid passing a index. v2: fix xf86RandR12.c + xf86cmap.c call Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 51e5f90ada929d6b23176090badbb42fdb3fa550 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:11:09 2012 +0100 xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API) The EXA interface migrates to ScreenPtr, and the xf86 interface migrated to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 94f1f21d17e86f96d4a54292a399160950087675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:02:11 2012 +0100 xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API) This migrates the ValidMode to passing a ScrnInfoPtr instead of an index. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3f8f18198fed4f39ec805b508a3482e91eea26b2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:59:46 2012 +0100 xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2) This migrate the SwitchMode interface to take a ScrnInfoPtr instead of an index. v2: drop flags. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d06a038a5c49328ab3a8d969d24f9fcd22c63202 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:50:37 2012 +0100 xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2) This converts AdjustFrame code paths to passing a ScrnInfoPtr instead of an integer index. v2: drop flags args. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:41:27 2012 +0100 xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2) Another index->pScrn conversion. v2: drop flags arg. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:35:41 2012 +0100 xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2) This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr instead of an index into xf86Screens. This allows dropping more public dereferences of the xf86Screens and screenInfo. v2: drop flags args as suggested by Keith, fix docs. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 06729dbbc804a20242e6499f446acb5d94023c3c Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:04:59 2012 +0100 xserver: remove index from CloseScreen (API/ABI breakage) This drops the index from the CloseScreen callback, its always been useless really, since the pScreen contains it. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 14:22:18 +02:00
RootlessCloseScreen(ScreenPtr pScreen)
2003-11-25 20:29:01 +01:00
{
RootlessScreenRec *s;
s = SCREENREC(pScreen);
// fixme unwrap everything that was wrapped?
pScreen->CloseScreen = s->CloseScreen;
if (s->pixmap_data != NULL) {
free(s->pixmap_data);
2003-11-25 20:29:01 +01:00
s->pixmap_data = NULL;
s->pixmap_data_size = 0;
}
free(s);
api: rework the X server driver API to avoid global arrays. This is a squash merge containing all the API changes, as well as the video ABI bump. Its been squashed to make bisection easier. Full patch log below: commit b202738bbf0c5a1c1172767119c2c71f1e7f8070 Author: Aaron Plattner <aplattner@nvidia.com> Date: Mon May 14 15:16:11 2012 -0700 xfree86: Bump video ABI to 13.0 The ABI was broken by changes to convert from screen index numbers to ScreenPtr / ScrnInfoPtr in various structures and function signatures. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 10:56:57 2012 +0100 xf86: xf86ClearEntityListForScreen should take a pScrn When adding GPU screens this make life easier. (also fix comment, as pointed out by Alan) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Dave Airlie <airlied@redhat.com> commit afee8b5ab4501597ecc1ade34124d7ca227ab055 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 07:07:32 2012 +0100 xf86i2c: add pscrn for drivers to use This just adds a pScrn pointer into the struct for the drivers to use instead of scrnIndex. Mostly scrnIndex is used for logging, but some drivers use it to lookup xf86Screens, so let them stash a pScrn instead. Removing the scrnIndex is a bit more involved and I'm not sure its worth the effort. Doing i2c in the X server is legacy code as far as I'm concerned. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit ea5092f1f679691d187f1eee9427e6057beec56e Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 19:25:20 2012 +0100 dix/gc: consolidate GC object creation in one place The standard GC create and scratch GC create were 90% the same really, and I have a need in the future for creating GC objects without the other bits, so wanted to avoid a third copy. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 10:24:06 2012 +0100 xf86: add a define to denote the new non-index interfaces are being used This can be used by drivers to provide compatible APIs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 15:09:12 2012 +0100 dix: make Create/Free scratch pixmaps take a ScreenPtr While technically an API/ABI change I doubt anyone uses it, but it helps in splitting screens up. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:57:55 2012 +0100 xf86/xv: remove scrnIndexfrom xf86FindXvOptions. Move this interface to taking an ScrnInfoPtr. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:53:59 2012 +0100 xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2) stop passing indices into this function. v2: drop flags argument. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 58824e414f35682435f15bfe6c4b656bd90b9235 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:48:09 2012 +0100 xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:18:59 2012 +0100 xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2) Instead of passing an index, pass the actual ScreenPtr. This allows more moving towards not abusing xf86Screens + screenInfo. v2: drop the blockData/wakeupData args as per ajax's suggestion., fix docs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 790d003de20fb47674420a24dadd92412d78620d Author: Dave Airlie <airlied@gmail.com> Date: Wed Apr 11 09:53:14 2012 +0100 xf86/common: remove some more pScrn->pScreen uses remove some more conversions that appeared after api cleanups. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:34:53 2012 +0100 ddc: change API to take ScrnInfoPtr (v2) This removes all xf86Screens usage from ddc code, it modifies the API for some functions to avoid taking indices. v2: address Alan's comments about dropping DDC2Init parameter. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit fe3f57b6eaf6860a33876a54f9439f69578f03a5 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:31:26 2012 +0100 vbe: don't use index for VBEInterpretPanelID (API) Remove use of xf86screens from vbe module. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit abf1965f4ed91529036d3fdb470d6a3ce6f29675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:25:11 2012 +0100 int10/vbe: don't use xf86Screens. (ABI) (v3) Pass the ScrnInfoPtr instead of the index in the int10 struct. This saves us using it to dereference xf86Screens. v2: address Alan's comment to fix struct alignment. v3: squash in all the int10 fixes, test the vm86 code builds, after comments by Keith. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 23cca612b4fb5efc33683c7624b803b457387e3d Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:30:18 2012 +0100 xserver: drop index argument to ScreenInit (ABI/API) (v2) This drops the index argument, its the same as pScreen->myNum, and its the last major index abuse I can find. v2: address Alan's review - update docs, fix xwin/xnest/darwin Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:23:01 2012 +0100 xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API) This migrates PointerMoved from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:20:46 2012 +0100 xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API) This migrates the PMEvent from index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:18:30 2012 +0100 xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API) This migrates the SetDGAMode callback from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit baf5e4818a74f2b68c3dfdcc56f54322351039a0 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:14:11 2012 +0100 xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2) This migrates the ChangeGamma interface to avoid passing a index. v2: fix xf86RandR12.c + xf86cmap.c call Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 51e5f90ada929d6b23176090badbb42fdb3fa550 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:11:09 2012 +0100 xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API) The EXA interface migrates to ScreenPtr, and the xf86 interface migrated to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 94f1f21d17e86f96d4a54292a399160950087675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:02:11 2012 +0100 xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API) This migrates the ValidMode to passing a ScrnInfoPtr instead of an index. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3f8f18198fed4f39ec805b508a3482e91eea26b2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:59:46 2012 +0100 xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2) This migrate the SwitchMode interface to take a ScrnInfoPtr instead of an index. v2: drop flags. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d06a038a5c49328ab3a8d969d24f9fcd22c63202 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:50:37 2012 +0100 xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2) This converts AdjustFrame code paths to passing a ScrnInfoPtr instead of an integer index. v2: drop flags args. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:41:27 2012 +0100 xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2) Another index->pScrn conversion. v2: drop flags arg. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:35:41 2012 +0100 xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2) This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr instead of an index into xf86Screens. This allows dropping more public dereferences of the xf86Screens and screenInfo. v2: drop flags args as suggested by Keith, fix docs. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 06729dbbc804a20242e6499f446acb5d94023c3c Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:04:59 2012 +0100 xserver: remove index from CloseScreen (API/ABI breakage) This drops the index from the CloseScreen callback, its always been useless really, since the pScreen contains it. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 14:22:18 +02:00
return pScreen->CloseScreen(pScreen);
2003-11-25 20:29:01 +01:00
}
static void
RootlessGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
unsigned int format, unsigned long planeMask, char *pdstLine)
{
ScreenPtr pScreen = pDrawable->pScreen;
2003-11-25 20:29:01 +01:00
SCREEN_UNWRAP(pScreen, GetImage);
if (pDrawable->type == DRAWABLE_WINDOW) {
int x0, y0, x1, y1;
RootlessWindowRec *winRec;
// Many apps use GetImage to sync with the visible frame buffer
// FIXME: entire screen or just window or all screens?
RootlessRedisplayScreen(pScreen);
// RedisplayScreen stops drawing, so we need to start it again
RootlessStartDrawing((WindowPtr) pDrawable);
2003-11-25 20:29:01 +01:00
/* Check that we have some place to read from. */
winRec = WINREC(TopLevelParent((WindowPtr) pDrawable));
if (winRec == NULL)
goto out;
/* Clip to top-level window bounds. */
/* FIXME: fbGetImage uses the width parameter to calculate the
stride of the destination pixmap. If w is clipped, the data
returned will be garbage, although we will not crash. */
x0 = pDrawable->x + sx;
y0 = pDrawable->y + sy;
x1 = x0 + w;
y1 = y0 + h;
x0 = max(x0, winRec->x);
y0 = max(y0, winRec->y);
x1 = min(x1, winRec->x + winRec->width);
y1 = min(y1, winRec->y + winRec->height);
2003-11-25 20:29:01 +01:00
sx = x0 - pDrawable->x;
sy = y0 - pDrawable->y;
w = x1 - x0;
h = y1 - y0;
if (w <= 0 || h <= 0)
goto out;
}
pScreen->GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
out:
2003-11-25 20:29:01 +01:00
SCREEN_WRAP(pScreen, GetImage);
}
/*
* RootlessSourceValidate
* CopyArea and CopyPlane use a GC tied to the destination drawable.
* StartDrawing/StopDrawing wrappers won't be called if source is
* a visible window but the destination isn't. So, we call StartDrawing
* here and leave StopDrawing for the block handler.
*/
static void
RootlessSourceValidate(DrawablePtr pDrawable, int x, int y, int w, int h,
unsigned int subWindowMode)
2003-11-25 20:29:01 +01:00
{
SCREEN_UNWRAP(pDrawable->pScreen, SourceValidate);
if (pDrawable->type == DRAWABLE_WINDOW) {
WindowPtr pWin = (WindowPtr) pDrawable;
2003-11-25 20:29:01 +01:00
RootlessStartDrawing(pWin);
}
if (pDrawable->pScreen->SourceValidate) {
pDrawable->pScreen->SourceValidate(pDrawable, x, y, w, h,
subWindowMode);
2003-11-25 20:29:01 +01:00
}
SCREEN_WRAP(pDrawable->pScreen, SourceValidate);
}
static void
RootlessComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
2003-11-25 20:29:01 +01:00
INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
{
ScreenPtr pScreen = pDst->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
WindowPtr srcWin, dstWin, maskWin = NULL;
if (pMask) { // pMask can be NULL
maskWin = (pMask->pDrawable &&
pMask->pDrawable->type ==
DRAWABLE_WINDOW) ? (WindowPtr) pMask->pDrawable : NULL;
2003-11-25 20:29:01 +01:00
}
srcWin = (pSrc->pDrawable && pSrc->pDrawable->type == DRAWABLE_WINDOW) ?
(WindowPtr) pSrc->pDrawable : NULL;
dstWin = (pDst->pDrawable->type == DRAWABLE_WINDOW) ?
(WindowPtr) pDst->pDrawable : NULL;
2003-11-25 20:29:01 +01:00
// SCREEN_UNWRAP(ps, Composite);
ps->Composite = SCREENREC(pScreen)->Composite;
if (srcWin && IsFramedWindow(srcWin))
2003-11-25 20:29:01 +01:00
RootlessStartDrawing(srcWin);
if (maskWin && IsFramedWindow(maskWin))
RootlessStartDrawing(maskWin);
if (dstWin && IsFramedWindow(dstWin))
2003-11-25 20:29:01 +01:00
RootlessStartDrawing(dstWin);
ps->Composite(op, pSrc, pMask, pDst,
xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
2003-11-25 20:29:01 +01:00
if (dstWin && IsFramedWindow(dstWin)) {
2003-11-25 20:29:01 +01:00
RootlessDamageRect(dstWin, xDst, yDst, width, height);
}
ps->Composite = RootlessComposite;
// SCREEN_WRAP(ps, Composite);
}
static void
RootlessGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
int nlist, GlyphListPtr list, GlyphPtr * glyphs)
2003-11-25 20:29:01 +01:00
{
ScreenPtr pScreen = pDst->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
int x, y;
int n;
GlyphPtr glyph;
WindowPtr srcWin, dstWin;
srcWin = (pSrc->pDrawable && pSrc->pDrawable->type == DRAWABLE_WINDOW) ?
(WindowPtr) pSrc->pDrawable : NULL;
2003-11-25 20:29:01 +01:00
dstWin = (pDst->pDrawable->type == DRAWABLE_WINDOW) ?
(WindowPtr) pDst->pDrawable : NULL;
2003-11-25 20:29:01 +01:00
if (srcWin && IsFramedWindow(srcWin))
RootlessStartDrawing(srcWin);
if (dstWin && IsFramedWindow(dstWin))
RootlessStartDrawing(dstWin);
2003-11-25 20:29:01 +01:00
//SCREEN_UNWRAP(ps, Glyphs);
ps->Glyphs = SCREENREC(pScreen)->Glyphs;
ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
ps->Glyphs = RootlessGlyphs;
//SCREEN_WRAP(ps, Glyphs);
if (dstWin && IsFramedWindow(dstWin)) {
x = xSrc;
y = ySrc;
while (nlist--) {
x += list->xOff;
y += list->yOff;
n = list->len;
/* Calling DamageRect for the bounding box of each glyph is
inefficient. So compute the union of all glyphs in a list
and damage that. */
if (n > 0) {
BoxRec box;
glyph = *glyphs++;
box.x1 = x - glyph->info.x;
box.y1 = y - glyph->info.y;
box.x2 = box.x1 + glyph->info.width;
box.y2 = box.y1 + glyph->info.height;
2003-11-25 20:29:01 +01:00
x += glyph->info.xOff;
y += glyph->info.yOff;
while (--n > 0) {
short x1, y1, x2, y2;
glyph = *glyphs++;
x1 = x - glyph->info.x;
y1 = y - glyph->info.y;
x2 = x1 + glyph->info.width;
y2 = y1 + glyph->info.height;
box.x1 = max(box.x1, x1);
box.y1 = max(box.y1, y1);
box.x2 = max(box.x2, x2);
box.y2 = max(box.y2, y2);
2003-11-25 20:29:01 +01:00
x += glyph->info.xOff;
y += glyph->info.yOff;
}
RootlessDamageBox(dstWin, &box);
}
list++;
}
}
}
/*
* RootlessValidateTree
* ValidateTree is modified in two ways:
* - top-level windows don't clip each other
* - windows aren't clipped against root.
* These only matter when validating from the root.
*/
static int
RootlessValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
{
int result;
RegionRec saveRoot;
ScreenPtr pScreen = pParent->drawable.pScreen;
SCREEN_UNWRAP(pScreen, ValidateTree);
RL_DEBUG_MSG("VALIDATETREE start ");
// Use our custom version to validate from root
if (IsRoot(pParent)) {
RL_DEBUG_MSG("custom ");
result = RootlessMiValidateTree(pParent, pChild, kind);
}
else {
2003-11-25 20:29:01 +01:00
HUGE_ROOT(pParent);
result = pScreen->ValidateTree(pParent, pChild, kind);
NORMAL_ROOT(pParent);
}
SCREEN_WRAP(pScreen, ValidateTree);
RL_DEBUG_MSG("VALIDATETREE end\n");
return result;
}
/*
* RootlessMarkOverlappedWindows
* MarkOverlappedWindows is modified to ignore overlapping
* top-level windows.
*/
static Bool
RootlessMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst,
WindowPtr *ppLayerWin)
{
RegionRec saveRoot;
Bool result;
ScreenPtr pScreen = pWin->drawable.pScreen;
2003-11-25 20:29:01 +01:00
SCREEN_UNWRAP(pScreen, MarkOverlappedWindows);
RL_DEBUG_MSG("MARKOVERLAPPEDWINDOWS start ");
HUGE_ROOT(pWin);
if (IsRoot(pWin)) {
// root - mark nothing
RL_DEBUG_MSG("is root not marking ");
result = FALSE;
}
else if (!IsTopLevel(pWin)) {
2003-11-25 20:29:01 +01:00
// not top-level window - mark normally
result = pScreen->MarkOverlappedWindows(pWin, pFirst, ppLayerWin);
}
else {
//top-level window - mark children ONLY - NO overlaps with sibs (?)
// This code copied from miMarkOverlappedWindows()
register WindowPtr pChild;
Bool anyMarked = FALSE;
MarkWindowProcPtr MarkWindow = pScreen->MarkWindow;
2003-11-25 20:29:01 +01:00
RL_DEBUG_MSG("is top level! ");
/* single layered systems are easy */
if (ppLayerWin)
*ppLayerWin = pWin;
2003-11-25 20:29:01 +01:00
if (pWin == pFirst) {
/* Blindly mark pWin and all of its inferiors. This is a slight
* overkill if there are mapped windows that outside pWin's border,
* but it's better than wasting time on RectIn checks.
*/
pChild = pWin;
while (1) {
if (pChild->viewable) {
if (RegionBroken(&pChild->winSize))
SetWinSize(pChild);
if (RegionBroken(&pChild->borderSize))
SetBorderSize(pChild);
(*MarkWindow) (pChild);
2003-11-25 20:29:01 +01:00
if (pChild->firstChild) {
pChild = pChild->firstChild;
continue;
}
}
while (!pChild->nextSib && (pChild != pWin))
pChild = pChild->parent;
if (pChild == pWin)
break;
pChild = pChild->nextSib;
}
anyMarked = TRUE;
}
if (anyMarked)
(*MarkWindow) (pWin->parent);
2003-11-25 20:29:01 +01:00
result = anyMarked;
}
NORMAL_ROOT(pWin);
SCREEN_WRAP(pScreen, MarkOverlappedWindows);
RL_DEBUG_MSG("MARKOVERLAPPEDWINDOWS end\n");
return result;
}
static void
expose_1(WindowPtr pWin)
{
WindowPtr pChild;
if (!pWin->realized)
return;
pWin->drawable.pScreen->PaintWindow(pWin, &pWin->borderClip, PW_BACKGROUND);
/* FIXME: comments in windowstr.h indicate that borderClip doesn't
include subwindow visibility. But I'm not so sure.. so we may
be exposing too much.. */
miSendExposures(pWin, &pWin->borderClip,
pWin->drawable.x, pWin->drawable.y);
for (pChild = pWin->firstChild; pChild != NULL; pChild = pChild->nextSib)
expose_1(pChild);
}
void
RootlessScreenExpose(ScreenPtr pScreen)
{
expose_1(pScreen->root);
}
ColormapPtr
RootlessGetColormap(ScreenPtr pScreen)
{
RootlessScreenRec *s = SCREENREC(pScreen);
return s->colormap;
}
static void
RootlessInstallColormap(ColormapPtr pMap)
{
ScreenPtr pScreen = pMap->pScreen;
RootlessScreenRec *s = SCREENREC(pScreen);
SCREEN_UNWRAP(pScreen, InstallColormap);
if (s->colormap != pMap) {
s->colormap = pMap;
s->colormap_changed = TRUE;
RootlessQueueRedisplay(pScreen);
}
pScreen->InstallColormap(pMap);
SCREEN_WRAP(pScreen, InstallColormap);
}
static void
RootlessUninstallColormap(ColormapPtr pMap)
{
ScreenPtr pScreen = pMap->pScreen;
RootlessScreenRec *s = SCREENREC(pScreen);
SCREEN_UNWRAP(pScreen, UninstallColormap);
if (s->colormap == pMap)
s->colormap = NULL;
pScreen->UninstallColormap(pMap);
SCREEN_WRAP(pScreen, UninstallColormap);
}
static void
RootlessStoreColors(ColormapPtr pMap, int ndef, xColorItem * pdef)
{
ScreenPtr pScreen = pMap->pScreen;
RootlessScreenRec *s = SCREENREC(pScreen);
SCREEN_UNWRAP(pScreen, StoreColors);
if (s->colormap == pMap && ndef > 0) {
s->colormap_changed = TRUE;
RootlessQueueRedisplay(pScreen);
}
pScreen->StoreColors(pMap, ndef, pdef);
SCREEN_WRAP(pScreen, StoreColors);
}
2003-11-25 20:29:01 +01:00
static CARD32
RootlessRedisplayCallback(OsTimerPtr timer, CARD32 time, void *arg)
{
RootlessScreenRec *screenRec = arg;
if (!screenRec->redisplay_queued) {
/* No update needed. Stop the timer. */
screenRec->redisplay_timer_set = FALSE;
return 0;
}
screenRec->redisplay_queued = FALSE;
/* Mark that we should redisplay before waiting for I/O next time */
screenRec->redisplay_expired = TRUE;
/* Reinstall the timer immediately, so we get as close to our
redisplay interval as possible. */
return ROOTLESS_REDISPLAY_DELAY;
}
/*
* RootlessQueueRedisplay
* Queue a redisplay after a timer delay to ensure we do not redisplay
* too frequently.
*/
void
RootlessQueueRedisplay(ScreenPtr pScreen)
{
RootlessScreenRec *screenRec = SCREENREC(pScreen);
screenRec->redisplay_queued = TRUE;
if (screenRec->redisplay_timer_set)
return;
screenRec->redisplay_timer = TimerSet(screenRec->redisplay_timer,
0, ROOTLESS_REDISPLAY_DELAY,
RootlessRedisplayCallback, screenRec);
2003-11-25 20:29:01 +01:00
screenRec->redisplay_timer_set = TRUE;
}
/*
* RootlessBlockHandler
* If the redisplay timer has expired, flush drawing before blocking
* on select().
*/
static void
RootlessBlockHandler(void *pbdata, OSTimePtr pTimeout, void *pReadmask)
2003-11-25 20:29:01 +01:00
{
ScreenPtr pScreen = pbdata;
RootlessScreenRec *screenRec = SCREENREC(pScreen);
if (screenRec->redisplay_expired) {
screenRec->redisplay_expired = FALSE;
RootlessRedisplayScreen(pScreen);
}
}
static void
RootlessWakeupHandler(void *data, int i, void *LastSelectMask)
2003-11-25 20:29:01 +01:00
{
// nothing here
}
static Bool
RootlessAllocatePrivates(ScreenPtr pScreen)
{
RootlessScreenRec *s;
if (!dixRegisterPrivateKey
(&rootlessGCPrivateKeyRec, PRIVATE_GC, sizeof(RootlessGCRec)))
return FALSE;
if (!dixRegisterPrivateKey(&rootlessScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&rootlessWindowPrivateKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
if (!dixRegisterPrivateKey
(&rootlessWindowOldPixmapPrivateKeyRec, PRIVATE_WINDOW, 0))
2003-11-25 20:29:01 +01:00
return FALSE;
s = malloc(sizeof(RootlessScreenRec));
if (!s)
return FALSE;
SETSCREENREC(pScreen, s);
2003-11-25 20:29:01 +01:00
s->pixmap_data = NULL;
s->pixmap_data_size = 0;
s->redisplay_timer = NULL;
s->redisplay_timer_set = FALSE;
return TRUE;
}
static void
RootlessWrap(ScreenPtr pScreen)
{
RootlessScreenRec *s = SCREENREC(pScreen);
2003-11-25 20:29:01 +01:00
#define WRAP(a) \
if (pScreen->a) { \
s->a = pScreen->a; \
} else { \
RL_DEBUG_MSG("null screen fn " #a "\n"); \
s->a = NULL; \
} \
pScreen->a = Rootless##a
WRAP(CreateScreenResources);
WRAP(CloseScreen);
WRAP(CreateGC);
WRAP(CopyWindow);
WRAP(PaintWindow);
2003-11-25 20:29:01 +01:00
WRAP(GetImage);
WRAP(SourceValidate);
WRAP(CreateWindow);
WRAP(DestroyWindow);
WRAP(RealizeWindow);
WRAP(UnrealizeWindow);
WRAP(MoveWindow);
WRAP(PositionWindow);
WRAP(ResizeWindow);
WRAP(RestackWindow);
WRAP(ReparentWindow);
WRAP(ChangeBorderWidth);
WRAP(MarkOverlappedWindows);
WRAP(ValidateTree);
WRAP(ChangeWindowAttributes);
WRAP(InstallColormap);
WRAP(UninstallColormap);
WRAP(StoreColors);
2003-11-25 20:29:01 +01:00
WRAP(SetShape);
{
// Composite and Glyphs don't use normal screen wrapping
PictureScreenPtr ps = GetPictureScreen(pScreen);
2003-11-25 20:29:01 +01:00
s->Composite = ps->Composite;
ps->Composite = RootlessComposite;
s->Glyphs = ps->Glyphs;
ps->Glyphs = RootlessGlyphs;
}
// WRAP(ClearToBackground); fixme put this back? useful for shaped wins?
#undef WRAP
}
/*
* RootlessInit
* Called by the rootless implementation to initialize the rootless layer.
* Rootless wraps lots of stuff and needs a bunch of devPrivates.
*/
Bool
RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs)
2003-11-25 20:29:01 +01:00
{
RootlessScreenRec *s;
if (!RootlessAllocatePrivates(pScreen))
return FALSE;
s = SCREENREC(pScreen);
2003-11-25 20:29:01 +01:00
s->imp = procs;
s->colormap = NULL;
s->redisplay_expired = FALSE;
2003-11-25 20:29:01 +01:00
RootlessWrap(pScreen);
if (!RegisterBlockAndWakeupHandlers(RootlessBlockHandler,
RootlessWakeupHandler,
(void *) pScreen)) {
2003-11-25 20:29:01 +01:00
return FALSE;
}
return TRUE;
}
void
RootlessUpdateRooted(Bool state)
{
int i;
if (!state) {
for (i = 0; i < screenInfo.numScreens; i++)
RootlessDisableRoot(screenInfo.screens[i]);
}
else {
for (i = 0; i < screenInfo.numScreens; i++)
RootlessEnableRoot(screenInfo.screens[i]);
}
}