diff options
Diffstat (limited to 'xorg-server')
444 files changed, 75004 insertions, 74428 deletions
diff --git a/xorg-server/Xext/Makefile.am b/xorg-server/Xext/Makefile.am index fa007aa91..cdf8366c1 100644 --- a/xorg-server/Xext/Makefile.am +++ b/xorg-server/Xext/Makefile.am @@ -1,140 +1,139 @@ -# libXext.la: includes all extensions and should be linked into Xvfb, -# Xnest, Xdmx and Xprt -# libXextbuiltin.la: includes those extensions that are built directly into -# Xorg by default -# libXextmodule.la: includes those extensions that are built into a module -# that Xorg loads -if XORG -noinst_LTLIBRARIES = libXext.la libXextbuiltin.la libXextmodule.la -else -noinst_LTLIBRARIES = libXext.la -endif - -INCLUDES = -I$(top_srcdir)/hw/xfree86/dixmods/extmod - -AM_CFLAGS = $(DIX_CFLAGS) - -if XORG -sdk_HEADERS = xvdix.h xvmcext.h geext.h geint.h shmint.h -endif - -# Sources always included in libXextbuiltin.la & libXext.la -BUILTIN_SRCS = \ - bigreq.c \ - geext.c \ - shape.c \ - sleepuntil.c \ - sleepuntil.h \ - sync.c \ - syncsrv.h \ - xcmisc.c \ - xtest.c - -# Sources always included in libXextmodule.la & libXext.la. That's right, zero. -MODULE_SRCS = -MODULE_LIBS = - -# Optional sources included if extension enabled by configure.ac rules - -# MIT Shared Memory extension -MITSHM_SRCS = shm.c shmint.h -if MITSHM -BUILTIN_SRCS += $(MITSHM_SRCS) -endif - -# XVideo extension -XV_SRCS = xvmain.c xvdisp.c xvmc.c xvdix.h xvmcext.h xvdisp.h -if XV -MODULE_SRCS += $(XV_SRCS) -endif - -# XResource extension: lets clients get data about per-client resource usage -RES_SRCS = xres.c -if RES -MODULE_SRCS += $(RES_SRCS) -endif - -# MIT ScreenSaver extension -SCREENSAVER_SRCS = saver.c -if SCREENSAVER -MODULE_SRCS += $(SCREENSAVER_SRCS) -endif - -# Xinerama extension: making multiple video devices act as one virtual screen -XINERAMA_SRCS = panoramiX.c panoramiX.h panoramiXh.h panoramiXsrv.h panoramiXprocs.c panoramiXSwap.c -if XINERAMA -BUILTIN_SRCS += $(XINERAMA_SRCS) -if XORG -sdk_HEADERS += panoramiXsrv.h panoramiX.h -endif -endif - -# X-ACE extension: provides hooks for building security policy extensions -# like XC-Security, X-SELinux & XTSol -XACE_SRCS = xace.c xace.h xacestr.h -if XACE -BUILTIN_SRCS += $(XACE_SRCS) -if XORG -sdk_HEADERS += xace.h xacestr.h -endif -endif - -# SELinux extension: provides SELinux policy support for X objects -# requires X-ACE extension -XSELINUX_SRCS = xselinux_ext.c xselinux_hooks.c xselinux_label.c xselinux.h xselinuxint.h -if XSELINUX -MODULE_SRCS += $(XSELINUX_SRCS) -MODULE_LIBS += $(SELINUX_LIBS) -endif - -# Security extension: multi-level security to protect clients from each other -XCSECURITY_SRCS = security.c securitysrv.h -if XCSECURITY -BUILTIN_SRCS += $(XCSECURITY_SRCS) -endif - -XCALIBRATE_SRCS = xcalibrate.c -if XCALIBRATE -BUILTIN_SRCS += $(XCALIBRATE_SRCS) -# XCalibrate needs tslib -endif - -# XF86 Big Font extension -BIGFONT_SRCS = xf86bigfont.c xf86bigfontsrv.h -if XF86BIGFONT -BUILTIN_SRCS += $(BIGFONT_SRCS) -endif - -# DPMS extension -DPMS_SRCS = dpms.c dpmsproc.h -if DPMSExtension -MODULE_SRCS += $(DPMS_SRCS) -endif - -# Now take all of the above, mix well, bake for 10 minutes and get libXext*.la - -libXext_la_SOURCES = $(BUILTIN_SRCS) $(MODULE_SRCS) -libXext_la_LIBADD = $(MODULE_LIBS) - -if XORG -libXextbuiltin_la_SOURCES = $(BUILTIN_SRCS) - -libXextmodule_la_SOURCES = $(MODULE_SRCS) -libXextmodule_la_LIBADD = $(MODULE_LIBS) -endif - -EXTRA_DIST = \ - $(MITSHM_SRCS) \ - $(XV_SRCS) \ - $(RES_SRCS) \ - $(SCREENSAVER_SRCS) \ - $(XACE_SRCS) \ - $(XCSECURITY_SRCS) \ - $(XSELINUX_SRCS) \ - $(XCALIBRATE_SRCS) \ - $(XINERAMA_SRCS) \ - $(FONTCACHE_SRCS) \ - $(BIGFONT_SRCS) \ - $(DPMS_SRCS) \ - $(GE_SRCS) - +# libXext.la: includes all extensions and should be linked into Xvfb,
+# Xnest, Xdmx and Xprt
+# libXextbuiltin.la: includes those extensions that are built directly into
+# Xorg by default
+# libXextmodule.la: includes those extensions that are built into a module
+# that Xorg loads
+if XORG
+noinst_LTLIBRARIES = libXext.la libXextbuiltin.la libXextmodule.la
+else
+noinst_LTLIBRARIES = libXext.la
+endif
+
+INCLUDES = -I$(top_srcdir)/hw/xfree86/dixmods/extmod
+
+AM_CFLAGS = $(DIX_CFLAGS)
+
+if XORG
+sdk_HEADERS = xvdix.h xvmcext.h geext.h geint.h shmint.h
+endif
+
+# Sources always included in libXextbuiltin.la & libXext.la
+BUILTIN_SRCS = \
+ bigreq.c \
+ geext.c \
+ shape.c \
+ sleepuntil.c \
+ sleepuntil.h \
+ sync.c \
+ syncsrv.h \
+ xcmisc.c \
+ xtest.c
+
+# Sources always included in libXextmodule.la & libXext.la. That's right, zero.
+MODULE_SRCS =
+MODULE_LIBS =
+
+# Optional sources included if extension enabled by configure.ac rules
+
+# MIT Shared Memory extension
+MITSHM_SRCS = shm.c shmint.h
+if MITSHM
+BUILTIN_SRCS += $(MITSHM_SRCS)
+endif
+
+# XVideo extension
+XV_SRCS = xvmain.c xvdisp.c xvmc.c xvdix.h xvmcext.h xvdisp.h
+if XV
+MODULE_SRCS += $(XV_SRCS)
+endif
+
+# XResource extension: lets clients get data about per-client resource usage
+RES_SRCS = xres.c
+if RES
+MODULE_SRCS += $(RES_SRCS)
+endif
+
+# MIT ScreenSaver extension
+SCREENSAVER_SRCS = saver.c
+if SCREENSAVER
+MODULE_SRCS += $(SCREENSAVER_SRCS)
+endif
+
+# Xinerama extension: making multiple video devices act as one virtual screen
+XINERAMA_SRCS = panoramiX.c panoramiX.h panoramiXh.h panoramiXsrv.h panoramiXprocs.c panoramiXSwap.c
+if XINERAMA
+BUILTIN_SRCS += $(XINERAMA_SRCS)
+if XORG
+sdk_HEADERS += panoramiXsrv.h panoramiX.h
+endif
+endif
+
+# X-ACE extension: provides hooks for building security policy extensions
+# like XC-Security, X-SELinux & XTSol
+XACE_SRCS = xace.c xace.h xacestr.h
+if XACE
+BUILTIN_SRCS += $(XACE_SRCS)
+if XORG
+sdk_HEADERS += xace.h xacestr.h
+endif
+endif
+
+# SELinux extension: provides SELinux policy support for X objects
+# requires X-ACE extension
+XSELINUX_SRCS = xselinux_ext.c xselinux_hooks.c xselinux_label.c xselinux.h xselinuxint.h
+if XSELINUX
+MODULE_SRCS += $(XSELINUX_SRCS)
+MODULE_LIBS += $(SELINUX_LIBS)
+endif
+
+# Security extension: multi-level security to protect clients from each other
+XCSECURITY_SRCS = security.c securitysrv.h
+if XCSECURITY
+BUILTIN_SRCS += $(XCSECURITY_SRCS)
+endif
+
+XCALIBRATE_SRCS = xcalibrate.c
+if XCALIBRATE
+BUILTIN_SRCS += $(XCALIBRATE_SRCS)
+# XCalibrate needs tslib
+endif
+
+# XF86 Big Font extension
+BIGFONT_SRCS = xf86bigfont.c xf86bigfontsrv.h
+if XF86BIGFONT
+BUILTIN_SRCS += $(BIGFONT_SRCS)
+endif
+
+# DPMS extension
+DPMS_SRCS = dpms.c dpmsproc.h
+if DPMSExtension
+MODULE_SRCS += $(DPMS_SRCS)
+endif
+
+# Now take all of the above, mix well, bake for 10 minutes and get libXext*.la
+
+libXext_la_SOURCES = $(BUILTIN_SRCS) $(MODULE_SRCS)
+libXext_la_LIBADD = $(MODULE_LIBS)
+
+if XORG
+libXextbuiltin_la_SOURCES = $(BUILTIN_SRCS)
+
+libXextmodule_la_SOURCES = $(MODULE_SRCS)
+libXextmodule_la_LIBADD = $(MODULE_LIBS)
+endif
+
+EXTRA_DIST = \
+ $(MITSHM_SRCS) \
+ $(XV_SRCS) \
+ $(RES_SRCS) \
+ $(SCREENSAVER_SRCS) \
+ $(XACE_SRCS) \
+ $(XCSECURITY_SRCS) \
+ $(XSELINUX_SRCS) \
+ $(XCALIBRATE_SRCS) \
+ $(XINERAMA_SRCS) \
+ $(BIGFONT_SRCS) \
+ $(DPMS_SRCS) \
+ $(GE_SRCS)
+
diff --git a/xorg-server/Xext/geext.c b/xorg-server/Xext/geext.c index 253c87bc9..be37843ec 100644 --- a/xorg-server/Xext/geext.c +++ b/xorg-server/Xext/geext.c @@ -36,12 +36,10 @@ #define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
-static int GEClientPrivateKeyIndex;
-DevPrivateKey GEClientPrivateKey = &GEClientPrivateKeyIndex;
+DevPrivateKeyRec GEClientPrivateKeyRec;
int RT_GECLIENT = 0;
-
GEExtension GEExtensions[MAXEXTENSIONS];
/* Major available requests */
@@ -209,7 +207,7 @@ GEExtensionInit(void) {
ExtensionEntry *extEntry;
- if (!dixRequestPrivate(GEClientPrivateKey, sizeof(GEClientInfoRec)))
+ if (!dixRegisterPrivateKey(&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec)))
FatalError("GEExtensionInit: GE private request failed.\n");
if(!AddCallback(&ClientStateCallback, GEClientCallback, 0))
diff --git a/xorg-server/Xext/geint.h b/xorg-server/Xext/geint.h index 10a33cea3..5c64a20f4 100644 --- a/xorg-server/Xext/geint.h +++ b/xorg-server/Xext/geint.h @@ -1,52 +1,53 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * 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 (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef _GEINT_H_ -#define _GEINT_H_ - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "misc.h" -#include "os.h" -#include "dixstruct.h" -#include "extnsionst.h" -#include <X11/extensions/geproto.h> - -extern _X_EXPORT DevPrivateKey GEClientPrivateKey; - -typedef struct _GEClientInfo { - CARD32 major_version; - CARD32 minor_version; -} GEClientInfoRec, *GEClientInfoPtr; - -#define GEGetClient(pClient) ((GEClientInfoPtr)(dixLookupPrivate(&((pClient)->devPrivates), GEClientPrivateKey))) - -extern _X_EXPORT int (*ProcGEVector[/*GENumRequests*/])(ClientPtr); -extern _X_EXPORT int (*SProcGEVector[/*GENumRequests*/])(ClientPtr); - -#endif /* _GEINT_H_ */ +/*
+ * Copyright 2007-2008 Peter Hutterer
+ *
+ * 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 (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Author: Peter Hutterer, University of South Australia, NICTA
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _GEINT_H_
+#define _GEINT_H_
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include <X11/extensions/geproto.h>
+
+extern _X_EXPORT DevPrivateKeyRec GEClientPrivateKeyRec;
+#define GEClientPrivateKey (&GEClientPrivateKeyRec)
+
+typedef struct _GEClientInfo {
+ CARD32 major_version;
+ CARD32 minor_version;
+} GEClientInfoRec, *GEClientInfoPtr;
+
+#define GEGetClient(pClient) ((GEClientInfoPtr)(dixLookupPrivate(&((pClient)->devPrivates), GEClientPrivateKey)))
+
+extern _X_EXPORT int (*ProcGEVector[/*GENumRequests*/])(ClientPtr);
+extern _X_EXPORT int (*SProcGEVector[/*GENumRequests*/])(ClientPtr);
+
+#endif /* _GEINT_H_ */
diff --git a/xorg-server/Xext/panoramiX.c b/xorg-server/Xext/panoramiX.c index 65af9a71f..1b340e80e 100644 --- a/xorg-server/Xext/panoramiX.c +++ b/xorg-server/Xext/panoramiX.c @@ -70,7 +70,6 @@ int PanoramiXPixWidth = 0; int PanoramiXPixHeight = 0;
int PanoramiXNumScreens = 0;
-PanoramiXData *panoramiXdataPtr = NULL;
static RegionRec PanoramiXScreenRegion = {{0, 0, 0, 0}, NULL};
static int PanoramiXNumDepths;
@@ -104,10 +103,10 @@ static void PanoramiXResetProc(ExtensionEntry*); int (* SavedProcVector[256]) (ClientPtr client) = { NULL, };
-static int PanoramiXGCKeyIndex;
-static DevPrivateKey PanoramiXGCKey = &PanoramiXGCKeyIndex;
-static int PanoramiXScreenKeyIndex;
-static DevPrivateKey PanoramiXScreenKey = &PanoramiXScreenKeyIndex;
+static DevPrivateKeyRec PanoramiXGCKeyRec;
+#define PanoramiXGCKey (&PanoramiXGCKeyRec)
+static DevPrivateKeyRec PanoramiXScreenKeyRec;
+#define PanoramiXScreenKey (&PanoramiXScreenKeyRec)
typedef struct {
DDXPointRec clipOrg;
@@ -120,8 +119,6 @@ typedef struct { CloseScreenProcPtr CloseScreen;
} PanoramiXScreenRec, *PanoramiXScreenPtr;
-RegionRec XineramaScreenRegions[MAXSCREENS];
-
static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr);
static void XineramaChangeGC(GCPtr, unsigned long);
static void XineramaCopyGC(GCPtr, unsigned long, GCPtr);
@@ -154,9 +151,8 @@ XineramaCloseScreen (int i, ScreenPtr pScreen) pScreen->CloseScreen = pScreenPriv->CloseScreen;
pScreen->CreateGC = pScreenPriv->CreateGC;
- REGION_UNINIT(pScreen, &XineramaScreenRegions[pScreen->myNum]);
if (pScreen->myNum == 0)
- REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
+ RegionUninit(&PanoramiXScreenRegion);
free((pointer) pScreenPriv);
@@ -199,8 +195,8 @@ XineramaValidateGC( if((pDraw->type == DRAWABLE_WINDOW) && !(((WindowPtr)pDraw)->parent)) {
/* the root window */
- int x_off = panoramiXdataPtr[pGC->pScreen->myNum].x;
- int y_off = panoramiXdataPtr[pGC->pScreen->myNum].y;
+ int x_off = pGC->pScreen->x;
+ int y_off = pGC->pScreen->y;
int new_val;
new_val = pGCPriv->clipOrg.x - x_off;
@@ -343,7 +339,7 @@ XineramaFindIDByScrnum(pointer resource, XID id, pointer privdata) PanoramiXRes *res = (PanoramiXRes*)resource;
PanoramiXSearchData *data = (PanoramiXSearchData*)privdata;
- return (res->info[data->screen].id == data->id);
+ return res->info[data->screen].id == data->id;
}
PanoramiXRes *
@@ -390,33 +386,31 @@ static void XineramaInitData(ScreenPtr pScreen) {
int i, w, h;
- REGION_NULL(pScreen, &PanoramiXScreenRegion)
+ RegionNull(&PanoramiXScreenRegion);
for (i = 0; i < PanoramiXNumScreens; i++) {
BoxRec TheBox;
+ RegionRec ScreenRegion;
pScreen = screenInfo.screens[i];
- panoramiXdataPtr[i].x = dixScreenOrigins[i].x;
- panoramiXdataPtr[i].y = dixScreenOrigins[i].y;
- panoramiXdataPtr[i].width = pScreen->width;
- panoramiXdataPtr[i].height = pScreen->height;
-
- TheBox.x1 = panoramiXdataPtr[i].x;
- TheBox.x2 = TheBox.x1 + panoramiXdataPtr[i].width;
- TheBox.y1 = panoramiXdataPtr[i].y;
- TheBox.y2 = TheBox.y1 + panoramiXdataPtr[i].height;
+ TheBox.x1 = pScreen->x;
+ TheBox.x2 = TheBox.x1 + pScreen->width;
+ TheBox.y1 = pScreen->y;
+ TheBox.y2 = TheBox.y1 + pScreen->height;
- REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1);
- REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion,
- &XineramaScreenRegions[i]);
+ RegionInit(&ScreenRegion, &TheBox, 1);
+ RegionUnion(&PanoramiXScreenRegion, &PanoramiXScreenRegion,
+ &ScreenRegion);
+ RegionUninit(&ScreenRegion);
}
- PanoramiXPixWidth = panoramiXdataPtr[0].x + panoramiXdataPtr[0].width;
- PanoramiXPixHeight = panoramiXdataPtr[0].y + panoramiXdataPtr[0].height;
+ PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width;
+ PanoramiXPixHeight = screenInfo.screens[0]->y + screenInfo.screens[0]->height;
for (i = 1; i < PanoramiXNumScreens; i++) {
- w = panoramiXdataPtr[i].x + panoramiXdataPtr[i].width;
- h = panoramiXdataPtr[i].y + panoramiXdataPtr[i].height;
+ pScreen = screenInfo.screens[i];
+ w = pScreen->x + pScreen->width;
+ h = pScreen->y + pScreen->height;
if (PanoramiXPixWidth < w)
PanoramiXPixWidth = w;
@@ -427,12 +421,7 @@ static void XineramaInitData(ScreenPtr pScreen) void XineramaReinitData(ScreenPtr pScreen)
{
- int i;
-
- REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
- for (i = 0; i < PanoramiXNumScreens; i++)
- REGION_UNINIT(pScreen, &XineramaScreenRegions[i]);
-
+ RegionUninit(&PanoramiXScreenRegion);
XineramaInitData(pScreen);
}
@@ -454,6 +443,16 @@ void PanoramiXExtensionInit(int argc, char *argv[]) if (noPanoramiXExtension)
return;
+ if (!dixRegisterPrivateKey(&PanoramiXScreenKeyRec, PRIVATE_SCREEN, 0)) {
+ noPanoramiXExtension = TRUE;
+ return;
+ }
+
+ if (!dixRegisterPrivateKey(&PanoramiXGCKeyRec, PRIVATE_GC, sizeof(PanoramiXGCRec))) {
+ noPanoramiXExtension = TRUE;
+ return;
+ }
+
PanoramiXNumScreens = screenInfo.numScreens;
if (PanoramiXNumScreens == 1) { /* Only 1 screen */
noPanoramiXExtension = TRUE;
@@ -473,17 +472,6 @@ void PanoramiXExtensionInit(int argc, char *argv[]) * run in non-PanoramiXeen mode.
*/
- panoramiXdataPtr = (PanoramiXData *)
- calloc(PanoramiXNumScreens, sizeof(PanoramiXData));
-
- if (!panoramiXdataPtr)
- break;
-
- if (!dixRequestPrivate(PanoramiXGCKey, sizeof(PanoramiXGCRec))) {
- noPanoramiXExtension = TRUE;
- return;
- }
-
for (i = 0; i < PanoramiXNumScreens; i++) {
pScreen = screenInfo.screens[i];
pScreenPriv = malloc(sizeof(PanoramiXScreenRec));
@@ -836,13 +824,14 @@ PanoramiXConsolidate(void) saver->type = XRT_WINDOW;
for (i = 0; i < PanoramiXNumScreens; i++) {
- root->info[i].id = WindowTable[i]->drawable.id;
+ ScreenPtr pScreen = screenInfo.screens[i];
+ root->info[i].id = pScreen->root->drawable.id;
root->u.win.class = InputOutput;
root->u.win.root = TRUE;
- saver->info[i].id = savedScreenInfo[i].wid;
+ saver->info[i].id = pScreen->screensaver.wid;
saver->u.win.class = InputOutput;
saver->u.win.root = TRUE;
- defmap->info[i].id = (screenInfo.screens[i])->defColormap;
+ defmap->info[i].id = pScreen->defColormap;
}
AddResource(root->info[0].id, XRT_WINDOW, root);
@@ -896,8 +885,6 @@ static void PanoramiXResetProc(ExtensionEntry* extEntry) screenInfo.numScreens = PanoramiXNumScreens;
for (i = 256; i--; )
ProcVector[i] = SavedProcVector[i];
-
- free(panoramiXdataPtr);
}
@@ -999,8 +986,8 @@ ProcPanoramiXGetScreenSize(ClientPtr client) rep.length = 0;
rep.sequenceNumber = client->sequence;
/* screen dimensions */
- rep.width = panoramiXdataPtr[stuff->screen].width;
- rep.height = panoramiXdataPtr[stuff->screen].height;
+ rep.width = screenInfo.screens[stuff->screen]->width;
+ rep.height = screenInfo.screens[stuff->screen]->height;
rep.window = stuff->window;
rep.screen = stuff->screen;
if (client->swapped) {
@@ -1072,10 +1059,10 @@ ProcXineramaQueryScreens(ClientPtr client) int i;
for(i = 0; i < PanoramiXNumScreens; i++) {
- scratch.x_org = panoramiXdataPtr[i].x;
- scratch.y_org = panoramiXdataPtr[i].y;
- scratch.width = panoramiXdataPtr[i].width;
- scratch.height = panoramiXdataPtr[i].height;
+ scratch.x_org = screenInfo.screens[i]->x;
+ scratch.y_org = screenInfo.screens[i]->y;
+ scratch.width = screenInfo.screens[i]->width;
+ scratch.height = screenInfo.screens[i]->height;
if(client->swapped) {
int n;
@@ -1153,7 +1140,7 @@ XineramaGetImageData( int pitch,
Bool isRoot
){
- RegionRec SrcRegion, GrabRegion;
+ RegionRec SrcRegion, ScreenRegion, GrabRegion;
BoxRec SrcBox, *pbox;
int x, y, w, h, i, j, nbox, size, sizeNeeded, ScratchPitch, inOut, depth;
DrawablePtr pDraw = pDrawables[0];
@@ -1165,38 +1152,47 @@ XineramaGetImageData( SrcBox.x1 = left;
SrcBox.y1 = top;
if(!isRoot) {
- SrcBox.x1 += pDraw->x + panoramiXdataPtr[0].x;
- SrcBox.y1 += pDraw->y + panoramiXdataPtr[0].y;
+ SrcBox.x1 += pDraw->x + screenInfo.screens[0]->x;
+ SrcBox.y1 += pDraw->y + screenInfo.screens[0]->y;
}
SrcBox.x2 = SrcBox.x1 + width;
SrcBox.y2 = SrcBox.y1 + height;
- REGION_INIT(pScreen, &SrcRegion, &SrcBox, 1);
- REGION_NULL(pScreen, &GrabRegion);
+ RegionInit(&SrcRegion, &SrcBox, 1);
+ RegionNull(&GrabRegion);
depth = (format == XYPixmap) ? 1 : pDraw->depth;
for(i = 0; i < PanoramiXNumScreens; i++) {
+ BoxRec TheBox;
+ ScreenPtr pScreen;
pDraw = pDrawables[i];
+ pScreen = pDraw->pScreen;
+
+ TheBox.x1 = pScreen->x;
+ TheBox.x2 = TheBox.x1 + pScreen->width;
+ TheBox.y1 = pScreen->y;
+ TheBox.y2 = TheBox.y1 + pScreen->height;
- inOut = RECT_IN_REGION(pScreen,&XineramaScreenRegions[i],&SrcBox);
+ RegionInit(&ScreenRegion, &TheBox, 1);
+ inOut = RegionContainsRect(&ScreenRegion, &SrcBox);
+ if(inOut == rgnPART)
+ RegionIntersect(&GrabRegion, &SrcRegion, &ScreenRegion);
+ RegionUninit(&ScreenRegion);
if(inOut == rgnIN) {
- (*pDraw->pScreen->GetImage)(pDraw,
- SrcBox.x1 - pDraw->x - panoramiXdataPtr[i].x,
- SrcBox.y1 - pDraw->y - panoramiXdataPtr[i].y,
+ (*pScreen->GetImage)(pDraw,
+ SrcBox.x1 - pDraw->x - screenInfo.screens[i]->x,
+ SrcBox.y1 - pDraw->y - screenInfo.screens[i]->y,
width, height, format, planemask, data);
break;
} else if (inOut == rgnOUT)
continue;
- REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion,
- &XineramaScreenRegions[i]);
-
- nbox = REGION_NUM_RECTS(&GrabRegion);
+ nbox = RegionNumRects(&GrabRegion);
if(nbox) {
- pbox = REGION_RECTS(&GrabRegion);
+ pbox = RegionRects(&GrabRegion);
while(nbox--) {
w = pbox->x2 - pbox->x1;
@@ -1215,10 +1211,10 @@ XineramaGetImageData( }
}
- x = pbox->x1 - pDraw->x - panoramiXdataPtr[i].x;
- y = pbox->y1 - pDraw->y - panoramiXdataPtr[i].y;
+ x = pbox->x1 - pDraw->x - screenInfo.screens[i]->x;
+ y = pbox->y1 - pDraw->y - screenInfo.screens[i]->y;
- (*pDraw->pScreen->GetImage)(pDraw, x, y, w, h,
+ (*pScreen->GetImage)(pDraw, x, y, w, h,
format, planemask, ScratchMem);
/* copy the memory over */
@@ -1273,16 +1269,15 @@ XineramaGetImageData( pbox++;
}
- REGION_SUBTRACT(pScreen, &SrcRegion, &SrcRegion, &GrabRegion);
- if(!REGION_NOTEMPTY(pScreen, &SrcRegion))
+ RegionSubtract(&SrcRegion, &SrcRegion, &GrabRegion);
+ if(!RegionNotEmpty(&SrcRegion))
break;
}
}
- if(ScratchMem)
- free(ScratchMem);
+ free(ScratchMem);
- REGION_UNINIT(pScreen, &SrcRegion);
- REGION_UNINIT(pScreen, &GrabRegion);
+ RegionUninit(&SrcRegion);
+ RegionUninit(&GrabRegion);
}
diff --git a/xorg-server/Xext/panoramiX.h b/xorg-server/Xext/panoramiX.h index 35de17951..1bf6194c6 100644 --- a/xorg-server/Xext/panoramiX.h +++ b/xorg-server/Xext/panoramiX.h @@ -1,85 +1,78 @@ -/***************************************************************** - -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. - -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. - -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 -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. - -******************************************************************/ - - -/* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */ - -/* - * PanoramiX definitions - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef _PANORAMIX_H_ -#define _PANORAMIX_H_ - -#define _PANORAMIX_SERVER -#include <X11/extensions/panoramiXproto.h> -#undef _PANORAMIX_SERVER -#include "gcstruct.h" - - -typedef struct _PanoramiXData { - int x; - int y; - int width; - int height; -} PanoramiXData; - -typedef struct _PanoramiXInfo { - XID id ; -} PanoramiXInfo; - -typedef struct { - PanoramiXInfo info[MAXSCREENS]; - RESTYPE type; - union { - struct { - char visibility; - char class; - char root; - } win; - struct { - Bool shared; - } pix; - struct { - Bool root; - } pict; - char raw_data[4]; - } u; -} PanoramiXRes; - -#define FOR_NSCREENS_FORWARD(j) for(j = 0; j < PanoramiXNumScreens; j++) -#define FOR_NSCREENS_BACKWARD(j) for(j = PanoramiXNumScreens - 1; j >= 0; j--) -#define FOR_NSCREENS(j) FOR_NSCREENS_FORWARD(j) - -#define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared) - -#endif /* _PANORAMIX_H_ */ +/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+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.
+
+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
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+
+/* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */
+
+/*
+ * PanoramiX definitions
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PANORAMIX_H_
+#define _PANORAMIX_H_
+
+#define _PANORAMIX_SERVER
+#include <X11/extensions/panoramiXproto.h>
+#undef _PANORAMIX_SERVER
+#include "gcstruct.h"
+
+
+typedef struct _PanoramiXInfo {
+ XID id ;
+} PanoramiXInfo;
+
+typedef struct {
+ PanoramiXInfo info[MAXSCREENS];
+ RESTYPE type;
+ union {
+ struct {
+ char visibility;
+ char class;
+ char root;
+ } win;
+ struct {
+ Bool shared;
+ } pix;
+ struct {
+ Bool root;
+ } pict;
+ char raw_data[4];
+ } u;
+} PanoramiXRes;
+
+#define FOR_NSCREENS_FORWARD(j) for(j = 0; j < PanoramiXNumScreens; j++)
+#define FOR_NSCREENS_BACKWARD(j) for(j = PanoramiXNumScreens - 1; j >= 0; j--)
+#define FOR_NSCREENS(j) FOR_NSCREENS_FORWARD(j)
+
+#define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared)
+
+#endif /* _PANORAMIX_H_ */
diff --git a/xorg-server/Xext/panoramiXprocs.c b/xorg-server/Xext/panoramiXprocs.c index 2fe329886..067fb6cf7 100644 --- a/xorg-server/Xext/panoramiXprocs.c +++ b/xorg-server/Xext/panoramiXprocs.c @@ -129,14 +129,14 @@ int PanoramiXCreateWindow(ClientPtr client) orig_visual = stuff->visual;
orig_x = stuff->x;
orig_y = stuff->y;
- parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) ||
- (stuff->parent == savedScreenInfo[0].wid);
+ parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) ||
+ (stuff->parent == screenInfo.screens[0]->screensaver.wid);
FOR_NSCREENS_BACKWARD(j) {
stuff->wid = newWin->info[j].id;
stuff->parent = parent->info[j].id;
if (parentIsRoot) {
- stuff->x = orig_x - panoramiXdataPtr[j].x;
- stuff->y = orig_y - panoramiXdataPtr[j].y;
+ stuff->x = orig_x - screenInfo.screens[j]->x;
+ stuff->y = orig_y - screenInfo.screens[j]->y;
}
if (backPix)
*((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id;
@@ -155,7 +155,7 @@ int PanoramiXCreateWindow(ClientPtr client) else
free(newWin);
- return (result);
+ return result;
}
@@ -227,7 +227,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client) result = (*SavedProcVector[X_ChangeWindowAttributes])(client);
}
- return (result);
+ return result;
}
@@ -253,7 +253,7 @@ int PanoramiXDestroyWindow(ClientPtr client) /* Since ProcDestroyWindow is using FreeResource, it will free
our resource for us on the last pass through the loop above */
- return (result);
+ return result;
}
@@ -279,7 +279,7 @@ int PanoramiXDestroySubwindows(ClientPtr client) /* DestroySubwindows is using FreeResource which will free
our resources for us on the last pass through the loop above */
- return (result);
+ return result;
}
@@ -302,7 +302,7 @@ int PanoramiXChangeSaveSet(ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -328,20 +328,20 @@ int PanoramiXReparentWindow(ClientPtr client) x = stuff->x;
y = stuff->y;
- parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) ||
- (stuff->parent == savedScreenInfo[0].wid);
+ parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) ||
+ (stuff->parent == screenInfo.screens[0]->screensaver.wid);
FOR_NSCREENS_BACKWARD(j) {
stuff->window = win->info[j].id;
stuff->parent = parent->info[j].id;
if(parentIsRoot) {
- stuff->x = x - panoramiXdataPtr[j].x;
- stuff->y = y - panoramiXdataPtr[j].y;
+ stuff->x = x - screenInfo.screens[j]->x;
+ stuff->y = y - screenInfo.screens[j]->y;
}
result = (*SavedProcVector[X_ReparentWindow])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -364,7 +364,7 @@ int PanoramiXMapWindow(ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -387,7 +387,7 @@ int PanoramiXMapSubwindows(ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -410,7 +410,7 @@ int PanoramiXUnmapWindow(ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -433,7 +433,7 @@ int PanoramiXUnmapSubwindows(ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -475,8 +475,8 @@ int PanoramiXConfigureWindow(ClientPtr client) }
}
- if(pWin->parent && ((pWin->parent == WindowTable[0]) ||
- (pWin->parent->drawable.id == savedScreenInfo[0].wid)))
+ if(pWin->parent && ((pWin->parent == screenInfo.screens[0]->root) ||
+ (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid)))
{
if ((Mask)stuff->mask & CWX) {
x_offset = 0;
@@ -495,14 +495,14 @@ int PanoramiXConfigureWindow(ClientPtr client) if(sib)
*((CARD32 *) &stuff[1] + sib_offset) = sib->info[j].id;
if(x_offset >= 0)
- *((CARD32 *) &stuff[1] + x_offset) = x - panoramiXdataPtr[j].x;
+ *((CARD32 *) &stuff[1] + x_offset) = x - screenInfo.screens[j]->x;
if(y_offset >= 0)
- *((CARD32 *) &stuff[1] + y_offset) = y - panoramiXdataPtr[j].y;
+ *((CARD32 *) &stuff[1] + y_offset) = y - screenInfo.screens[j]->y;
result = (*SavedProcVector[X_ConfigureWindow])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -525,7 +525,7 @@ int PanoramiXCirculateWindow(ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -544,7 +544,7 @@ int PanoramiXGetGeometry(ClientPtr client) rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
- rep.root = WindowTable[0]->drawable.id;
+ rep.root = screenInfo.screens[0]->root->drawable.id;
rep.depth = pDraw->depth;
rep.width = pDraw->width;
rep.height = pDraw->height;
@@ -557,16 +557,16 @@ int PanoramiXGetGeometry(ClientPtr client) rep.width = root->pixWidth;
rep.height = root->pixHeight;
} else
- if ((pDraw->type == UNDRAWABLE_WINDOW) || (pDraw->type == DRAWABLE_WINDOW))
+ if (WindowDrawable(pDraw->type))
{
WindowPtr pWin = (WindowPtr)pDraw;
rep.x = pWin->origin.x - wBorderWidth (pWin);
rep.y = pWin->origin.y - wBorderWidth (pWin);
- if((pWin->parent == WindowTable[0]) ||
- (pWin->parent->drawable.id == savedScreenInfo[0].wid))
+ if((pWin->parent == screenInfo.screens[0]->root) ||
+ (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid))
{
- rep.x += panoramiXdataPtr[0].x;
- rep.y += panoramiXdataPtr[0].y;
+ rep.x += screenInfo.screens[0]->x;
+ rep.y += screenInfo.screens[0]->y;
}
rep.borderWidth = pWin->borderWidth;
}
@@ -596,11 +596,11 @@ int PanoramiXTranslateCoords(ClientPtr client) rep.sameScreen = xTrue;
rep.child = None;
- if((pWin == WindowTable[0]) ||
- (pWin->drawable.id == savedScreenInfo[0].wid))
+ if((pWin == screenInfo.screens[0]->root) ||
+ (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
{
- x = stuff->srcX - panoramiXdataPtr[0].x;
- y = stuff->srcY - panoramiXdataPtr[0].y;
+ x = stuff->srcX - screenInfo.screens[0]->x;
+ y = stuff->srcY - screenInfo.screens[0]->y;
} else {
x = pWin->drawable.x + stuff->srcX;
y = pWin->drawable.y + stuff->srcY;
@@ -620,8 +620,7 @@ int PanoramiXTranslateCoords(ClientPtr client) * borderSize
*/
&& (!wBoundingShape(pWin) ||
- POINT_IN_REGION(pWin->drawable.pScreen,
- wBoundingShape(pWin),
+ RegionContainsPoint(wBoundingShape(pWin),
x - pWin->drawable.x,
y - pWin->drawable.y, &box))
)
@@ -634,11 +633,11 @@ int PanoramiXTranslateCoords(ClientPtr client) }
rep.dstX = x - pDst->drawable.x;
rep.dstY = y - pDst->drawable.y;
- if((pDst == WindowTable[0]) ||
- (pDst->drawable.id == savedScreenInfo[0].wid))
+ if((pDst == screenInfo.screens[0]->root) ||
+ (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
{
- rep.dstX += panoramiXdataPtr[0].x;
- rep.dstY += panoramiXdataPtr[0].y;
+ rep.dstX += screenInfo.screens[0]->x;
+ rep.dstY += screenInfo.screens[0]->y;
}
WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep);
@@ -680,7 +679,7 @@ int PanoramiXCreatePixmap(ClientPtr client) else
free(newPix);
- return (result);
+ return result;
}
@@ -708,7 +707,7 @@ int PanoramiXFreePixmap(ClientPtr client) /* Since ProcFreePixmap is using FreeResource, it will free
our resource for us on the last pass through the loop above */
- return (result);
+ return result;
}
@@ -790,7 +789,7 @@ int PanoramiXCreateGC(ClientPtr client) else
free(newGC);
- return (result);
+ return result;
}
int PanoramiXChangeGC(ClientPtr client)
@@ -856,7 +855,7 @@ int PanoramiXChangeGC(ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -885,7 +884,7 @@ int PanoramiXCopyGC(ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -908,7 +907,7 @@ int PanoramiXSetDashes(ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -931,7 +930,7 @@ int PanoramiXSetClipRectangles(ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -957,7 +956,7 @@ int PanoramiXFreeGC(ClientPtr client) /* Since ProcFreeGC is using FreeResource, it will free
our resource for us on the last pass through the loop above */
- return (result);
+ return result;
}
@@ -981,14 +980,14 @@ int PanoramiXClearToBackground(ClientPtr client) FOR_NSCREENS_BACKWARD(j) {
stuff->window = win->info[j].id;
if(isRoot) {
- stuff->x = x - panoramiXdataPtr[j].x;
- stuff->y = y - panoramiXdataPtr[j].y;
+ stuff->x = x - screenInfo.screens[j]->x;
+ stuff->y = y - screenInfo.screens[j]->y;
}
result = (*SavedProcVector[X_ClearArea])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -1070,7 +1069,7 @@ int PanoramiXCopyArea(ClientPtr client) if(drawables[0]->depth != pDst->depth) {
client->errorValue = stuff->dstDrawable;
free(data);
- return (BadMatch);
+ return BadMatch;
}
(*pGC->ops->PutImage) (pDst, pGC, pDst->depth, dstx, dsty,
@@ -1084,20 +1083,22 @@ int PanoramiXCopyArea(ClientPtr client) } else {
DrawablePtr pDst = NULL, pSrc = NULL;
GCPtr pGC = NULL;
- RegionPtr pRgn[MAXSCREENS];
+ RegionRec totalReg;
int rc;
+ RegionNull(&totalReg);
FOR_NSCREENS_BACKWARD(j) {
+ RegionPtr pRgn;
stuff->dstDrawable = dst->info[j].id;
stuff->srcDrawable = src->info[j].id;
stuff->gc = gc->info[j].id;
if (srcIsRoot) {
- stuff->srcX = srcx - panoramiXdataPtr[j].x;
- stuff->srcY = srcy - panoramiXdataPtr[j].y;
+ stuff->srcX = srcx - screenInfo.screens[j]->x;
+ stuff->srcY = srcy - screenInfo.screens[j]->y;
}
if (dstIsRoot) {
- stuff->dstX = dstx - panoramiXdataPtr[j].x;
- stuff->dstY = dsty - panoramiXdataPtr[j].y;
+ stuff->dstX = dstx - screenInfo.screens[j]->x;
+ stuff->dstY = dsty - screenInfo.screens[j]->y;
}
VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess);
@@ -1111,42 +1112,34 @@ int PanoramiXCopyArea(ClientPtr client) if ((pDst->pScreen != pSrc->pScreen) ||
(pDst->depth != pSrc->depth)) {
client->errorValue = stuff->dstDrawable;
- return (BadMatch);
+ return BadMatch;
}
} else
pSrc = pDst;
- pRgn[j] = (*pGC->ops->CopyArea)(pSrc, pDst, pGC,
+ pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC,
stuff->srcX, stuff->srcY,
stuff->width, stuff->height,
stuff->dstX, stuff->dstY);
+ if(pGC->graphicsExposures && pRgn) {
+ if(srcIsRoot) {
+ RegionTranslate(pRgn,
+ screenInfo.screens[j]->x, screenInfo.screens[j]->y);
+ }
+ RegionAppend(&totalReg, pRgn);
+ RegionDestroy(pRgn);
+ }
- if(dstShared) {
- while(j--) pRgn[j] = NULL;
+ if(dstShared)
break;
- }
}
if(pGC->graphicsExposures) {
- ScreenPtr pScreen = pDst->pScreen;
- RegionRec totalReg;
Bool overlap;
-
- REGION_NULL(pScreen, &totalReg);
- FOR_NSCREENS_BACKWARD(j) {
- if(pRgn[j]) {
- if(srcIsRoot) {
- REGION_TRANSLATE(pScreen, pRgn[j],
- panoramiXdataPtr[j].x, panoramiXdataPtr[j].y);
- }
- REGION_APPEND(pScreen, &totalReg, pRgn[j]);
- REGION_DESTROY(pScreen, pRgn[j]);
- }
- }
- REGION_VALIDATE(pScreen, &totalReg, &overlap);
- (*pScreen->SendGraphicsExpose)(
+ RegionValidate(&totalReg, &overlap);
+ (*pDst->pScreen->SendGraphicsExpose)(
client, &totalReg, stuff->dstDrawable, X_CopyArea, 0);
- REGION_UNINIT(pScreen, &totalReg);
+ RegionUninit(&totalReg);
}
}
@@ -1163,7 +1156,7 @@ int PanoramiXCopyPlane(ClientPtr client) Bool srcShared, dstShared;
DrawablePtr psrcDraw, pdstDraw = NULL;
GCPtr pGC = NULL;
- RegionPtr pRgn[MAXSCREENS];
+ RegionRec totalReg;
REQUEST(xCopyPlaneReq);
REQUEST_SIZE_MATCH(xCopyPlaneReq);
@@ -1198,17 +1191,19 @@ int PanoramiXCopyPlane(ClientPtr client) srcx = stuff->srcX; srcy = stuff->srcY;
dstx = stuff->dstX; dsty = stuff->dstY;
+ RegionNull(&totalReg);
FOR_NSCREENS_BACKWARD(j) {
+ RegionPtr pRgn;
stuff->dstDrawable = dst->info[j].id;
stuff->srcDrawable = src->info[j].id;
stuff->gc = gc->info[j].id;
if (srcIsRoot) {
- stuff->srcX = srcx - panoramiXdataPtr[j].x;
- stuff->srcY = srcy - panoramiXdataPtr[j].y;
+ stuff->srcX = srcx - screenInfo.screens[j]->x;
+ stuff->srcY = srcy - screenInfo.screens[j]->y;
}
if (dstIsRoot) {
- stuff->dstX = dstx - panoramiXdataPtr[j].x;
- stuff->dstY = dsty - panoramiXdataPtr[j].y;
+ stuff->dstX = dstx - screenInfo.screens[j]->x;
+ stuff->dstY = dsty - screenInfo.screens[j]->y;
}
VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess);
@@ -1220,7 +1215,7 @@ int PanoramiXCopyPlane(ClientPtr client) if (pdstDraw->pScreen != psrcDraw->pScreen) {
client->errorValue = stuff->dstDrawable;
- return (BadMatch);
+ return BadMatch;
}
} else
psrcDraw = pdstDraw;
@@ -1228,36 +1223,28 @@ int PanoramiXCopyPlane(ClientPtr client) if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) ||
(stuff->bitPlane > (1L << (psrcDraw->depth - 1)))) {
client->errorValue = stuff->bitPlane;
- return(BadValue);
+ return BadValue;
}
- pRgn[j] = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC,
+ pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC,
stuff->srcX, stuff->srcY,
stuff->width, stuff->height,
stuff->dstX, stuff->dstY, stuff->bitPlane);
+ if(pGC->graphicsExposures && pRgn) {
+ RegionAppend(&totalReg, pRgn);
+ RegionDestroy(pRgn);
+ }
- if(dstShared) {
- while(j--) pRgn[j] = NULL;
+ if(dstShared)
break;
- }
}
if(pGC->graphicsExposures) {
- ScreenPtr pScreen = pdstDraw->pScreen;
- RegionRec totalReg;
Bool overlap;
-
- REGION_NULL(pScreen, &totalReg);
- FOR_NSCREENS_BACKWARD(j) {
- if(pRgn[j]) {
- REGION_APPEND(pScreen, &totalReg, pRgn[j]);
- REGION_DESTROY(pScreen, pRgn[j]);
- }
- }
- REGION_VALIDATE(pScreen, &totalReg, &overlap);
- (*pScreen->SendGraphicsExpose)(
+ RegionValidate(&totalReg, &overlap);
+ (*pdstDraw->pScreen->SendGraphicsExpose)(
client, &totalReg, stuff->dstDrawable, X_CopyPlane, 0);
- REGION_UNINIT(pScreen, &totalReg);
+ RegionUninit(&totalReg);
}
return Success;
@@ -1297,8 +1284,8 @@ int PanoramiXPolyPoint(ClientPtr client) if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint));
if (isRoot) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
xPoint *pnts = (xPoint*)&stuff[1];
@@ -1318,7 +1305,7 @@ int PanoramiXPolyPoint(ClientPtr client) if(result != Success) break;
}
free(origPts);
- return (result);
+ return result;
} else
return Success;
}
@@ -1357,8 +1344,8 @@ int PanoramiXPolyLine(ClientPtr client) if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint));
if (isRoot) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
xPoint *pnts = (xPoint*)&stuff[1];
@@ -1378,7 +1365,7 @@ int PanoramiXPolyLine(ClientPtr client) if(result != Success) break;
}
free(origPts);
- return (result);
+ return result;
} else
return Success;
}
@@ -1420,8 +1407,8 @@ int PanoramiXPolySegment(ClientPtr client) if(j) memcpy(&stuff[1], origSegs, nsegs * sizeof(xSegment));
if (isRoot) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
xSegment *segs = (xSegment*)&stuff[1];
@@ -1441,7 +1428,7 @@ int PanoramiXPolySegment(ClientPtr client) if(result != Success) break;
}
free(origSegs);
- return (result);
+ return result;
} else
return Success;
}
@@ -1483,8 +1470,8 @@ int PanoramiXPolyRectangle(ClientPtr client) if(j) memcpy(&stuff[1], origRecs, nrects * sizeof(xRectangle));
if (isRoot) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
@@ -1503,7 +1490,7 @@ int PanoramiXPolyRectangle(ClientPtr client) if(result != Success) break;
}
free(origRecs);
- return (result);
+ return result;
} else
return Success;
}
@@ -1545,8 +1532,8 @@ int PanoramiXPolyArc(ClientPtr client) if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc));
if (isRoot) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
xArc *arcs = (xArc *) &stuff[1];
@@ -1563,7 +1550,7 @@ int PanoramiXPolyArc(ClientPtr client) if(result != Success) break;
}
free(origArcs);
- return (result);
+ return result;
} else
return Success;
}
@@ -1603,8 +1590,8 @@ int PanoramiXFillPoly(ClientPtr client) if(j) memcpy(&stuff[1], locPts, count * sizeof(DDXPointRec));
if (isRoot) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
DDXPointPtr pnts = (DDXPointPtr)&stuff[1];
@@ -1624,7 +1611,7 @@ int PanoramiXFillPoly(ClientPtr client) if(result != Success) break;
}
free(locPts);
- return (result);
+ return result;
} else
return Success;
}
@@ -1666,8 +1653,8 @@ int PanoramiXPolyFillRectangle(ClientPtr client) if(j) memcpy(&stuff[1], origRects, things * sizeof(xRectangle));
if (isRoot) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
xRectangle *rects = (xRectangle *) &stuff[1];
@@ -1685,7 +1672,7 @@ int PanoramiXPolyFillRectangle(ClientPtr client) if(result != Success) break;
}
free(origRects);
- return (result);
+ return result;
} else
return Success;
}
@@ -1727,8 +1714,8 @@ int PanoramiXPolyFillArc(ClientPtr client) if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc));
if (isRoot) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
xArc *arcs = (xArc *) &stuff[1];
@@ -1746,7 +1733,7 @@ int PanoramiXPolyFillArc(ClientPtr client) if(result != Success) break;
}
free(origArcs);
- return (result);
+ return result;
} else
return Success;
}
@@ -1780,15 +1767,15 @@ int PanoramiXPutImage(ClientPtr client) orig_y = stuff->dstY;
FOR_NSCREENS_BACKWARD(j){
if (isRoot) {
- stuff->dstX = orig_x - panoramiXdataPtr[j].x;
- stuff->dstY = orig_y - panoramiXdataPtr[j].y;
+ stuff->dstX = orig_x - screenInfo.screens[j]->x;
+ stuff->dstY = orig_y - screenInfo.screens[j]->y;
}
stuff->drawable = draw->info[j].id;
stuff->gc = gc->info[j].id;
result = (* SavedProcVector[X_PutImage])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -1811,7 +1798,7 @@ int PanoramiXGetImage(ClientPtr client) if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
client->errorValue = stuff->format;
- return(BadValue);
+ return BadValue;
}
rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
@@ -1828,7 +1815,7 @@ int PanoramiXGetImage(ClientPtr client) return rc;
if(!((WindowPtr)pDraw)->realized)
- return(BadMatch);
+ return BadMatch;
x = stuff->x;
y = stuff->y;
@@ -1843,19 +1830,19 @@ int PanoramiXGetImage(ClientPtr client) if( /* check for being onscreen */
x < 0 || x + w > PanoramiXPixWidth ||
y < 0 || y + h > PanoramiXPixHeight )
- return(BadMatch);
+ return BadMatch;
} else {
if( /* check for being onscreen */
- panoramiXdataPtr[0].x + pDraw->x + x < 0 ||
- panoramiXdataPtr[0].x + pDraw->x + x + w > PanoramiXPixWidth ||
- panoramiXdataPtr[0].y + pDraw->y + y < 0 ||
- panoramiXdataPtr[0].y + pDraw->y + y + h > PanoramiXPixHeight ||
+ screenInfo.screens[0]->x + pDraw->x + x < 0 ||
+ screenInfo.screens[0]->x + pDraw->x + x + w > PanoramiXPixWidth ||
+ screenInfo.screens[0]->y + pDraw->y + y < 0 ||
+ screenInfo.screens[0]->y + pDraw->y + y + h > PanoramiXPixHeight ||
/* check for being inside of border */
x < - wBorderWidth((WindowPtr)pDraw) ||
x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
y < -wBorderWidth((WindowPtr)pDraw) ||
y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height)
- return(BadMatch);
+ return BadMatch;
}
drawables[0] = pDraw;
@@ -1897,7 +1884,7 @@ int PanoramiXGetImage(ClientPtr client) }
length = linesPerBuf * widthBytesLine;
if(!(pBuf = malloc(length)))
- return (BadAlloc);
+ return BadAlloc;
WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
@@ -1910,7 +1897,7 @@ int PanoramiXGetImage(ClientPtr client) nlines = min(linesPerBuf, h - linesDone);
if(pDraw->depth == 1)
- bzero(pBuf, nlines * widthBytesLine);
+ memset(pBuf, 0, nlines * widthBytesLine);
XineramaGetImageData(drawables, x, y + linesDone, w, nlines,
format, planemask, pBuf, widthBytesLine, isRoot);
@@ -1927,7 +1914,7 @@ int PanoramiXGetImage(ClientPtr client) while (h - linesDone > 0) {
nlines = min(linesPerBuf, h - linesDone);
- bzero(pBuf, nlines * widthBytesLine);
+ memset(pBuf, 0, nlines * widthBytesLine);
XineramaGetImageData(drawables, x, y + linesDone, w,
nlines, format, plane, pBuf,
@@ -1983,13 +1970,13 @@ PanoramiXPolyText8(ClientPtr client) stuff->drawable = draw->info[j].id;
stuff->gc = gc->info[j].id;
if (isRoot) {
- stuff->x = orig_x - panoramiXdataPtr[j].x;
- stuff->y = orig_y - panoramiXdataPtr[j].y;
+ stuff->x = orig_x - screenInfo.screens[j]->x;
+ stuff->y = orig_y - screenInfo.screens[j]->y;
}
result = (*SavedProcVector[X_PolyText8])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
int
@@ -2024,13 +2011,13 @@ PanoramiXPolyText16(ClientPtr client) stuff->drawable = draw->info[j].id;
stuff->gc = gc->info[j].id;
if (isRoot) {
- stuff->x = orig_x - panoramiXdataPtr[j].x;
- stuff->y = orig_y - panoramiXdataPtr[j].y;
+ stuff->x = orig_x - screenInfo.screens[j]->x;
+ stuff->y = orig_y - screenInfo.screens[j]->y;
}
result = (*SavedProcVector[X_PolyText16])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -2065,13 +2052,13 @@ int PanoramiXImageText8(ClientPtr client) stuff->drawable = draw->info[j].id;
stuff->gc = gc->info[j].id;
if (isRoot) {
- stuff->x = orig_x - panoramiXdataPtr[j].x;
- stuff->y = orig_y - panoramiXdataPtr[j].y;
+ stuff->x = orig_x - screenInfo.screens[j]->x;
+ stuff->y = orig_y - screenInfo.screens[j]->y;
}
result = (*SavedProcVector[X_ImageText8])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -2106,13 +2093,13 @@ int PanoramiXImageText16(ClientPtr client) stuff->drawable = draw->info[j].id;
stuff->gc = gc->info[j].id;
if (isRoot) {
- stuff->x = orig_x - panoramiXdataPtr[j].x;
- stuff->y = orig_y - panoramiXdataPtr[j].y;
+ stuff->x = orig_x - screenInfo.screens[j]->x;
+ stuff->y = orig_y - screenInfo.screens[j]->y;
}
result = (*SavedProcVector[X_ImageText16])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -2152,7 +2139,7 @@ int PanoramiXCreateColormap(ClientPtr client) else
free(newCmap);
- return (result);
+ return result;
}
@@ -2180,7 +2167,7 @@ int PanoramiXFreeColormap(ClientPtr client) /* Since ProcFreeColormap is using FreeResource, it will free
our resource for us on the last pass through the loop above */
- return (result);
+ return result;
}
@@ -2221,7 +2208,7 @@ PanoramiXCopyColormapAndFree(ClientPtr client) else
free(newCmap);
- return (result);
+ return result;
}
@@ -2245,7 +2232,7 @@ int PanoramiXInstallColormap(ClientPtr client) result = (* SavedProcVector[X_InstallColormap])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -2269,7 +2256,7 @@ int PanoramiXUninstallColormap(ClientPtr client) result = (* SavedProcVector[X_UninstallColormap])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -2293,7 +2280,7 @@ int PanoramiXAllocColor(ClientPtr client) result = (* SavedProcVector[X_AllocColor])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -2317,7 +2304,7 @@ int PanoramiXAllocNamedColor(ClientPtr client) result = (* SavedProcVector[X_AllocNamedColor])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -2341,7 +2328,7 @@ int PanoramiXAllocColorCells(ClientPtr client) result = (* SavedProcVector[X_AllocColorCells])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -2365,7 +2352,7 @@ int PanoramiXAllocColorPlanes(ClientPtr client) result = (* SavedProcVector[X_AllocColorPlanes])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -2389,7 +2376,7 @@ int PanoramiXFreeColors(ClientPtr client) stuff->cmap = cmap->info[j].id;
result = (* SavedProcVector[X_FreeColors])(client);
}
- return (result);
+ return result;
}
@@ -2413,7 +2400,7 @@ int PanoramiXStoreColors(ClientPtr client) result = (* SavedProcVector[X_StoreColors])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
@@ -2437,5 +2424,5 @@ int PanoramiXStoreNamedColor(ClientPtr client) result = (* SavedProcVector[X_StoreNamedColor])(client);
if(result != Success) break;
}
- return (result);
+ return result;
}
diff --git a/xorg-server/Xext/panoramiXsrv.h b/xorg-server/Xext/panoramiXsrv.h index c77b11927..28b039458 100644 --- a/xorg-server/Xext/panoramiXsrv.h +++ b/xorg-server/Xext/panoramiXsrv.h @@ -1,56 +1,53 @@ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef _PANORAMIXSRV_H_ -#define _PANORAMIXSRV_H_ - -#include "panoramiX.h" - -extern _X_EXPORT int PanoramiXNumScreens; -extern _X_EXPORT PanoramiXData *panoramiXdataPtr; -extern _X_EXPORT int PanoramiXPixWidth; -extern _X_EXPORT int PanoramiXPixHeight; - -extern _X_EXPORT VisualID PanoramiXTranslateVisualID(int screen, VisualID orig); -extern _X_EXPORT void PanoramiXConsolidate(void); -extern _X_EXPORT Bool PanoramiXCreateConnectionBlock(void); -extern _X_EXPORT PanoramiXRes * PanoramiXFindIDByScrnum(RESTYPE, XID, int); -extern _X_EXPORT Bool XineramaRegisterConnectionBlockCallback(void (*func)(void)); -extern _X_EXPORT int XineramaDeleteResource(pointer, XID); - -extern _X_EXPORT void XineramaReinitData(ScreenPtr); - -extern _X_EXPORT RegionRec XineramaScreenRegions[MAXSCREENS]; - -extern _X_EXPORT unsigned long XRC_DRAWABLE; -extern _X_EXPORT unsigned long XRT_WINDOW; -extern _X_EXPORT unsigned long XRT_PIXMAP; -extern _X_EXPORT unsigned long XRT_GC; -extern _X_EXPORT unsigned long XRT_COLORMAP; - -/* - * Drivers are allowed to wrap this function. Each wrapper can decide that the - * two visuals are unequal, but if they are deemed equal, the wrapper must call - * down and return FALSE if the wrapped function does. This ensures that all - * layers agree that the visuals are equal. The first visual is always from - * screen 0. - */ -typedef Bool (*XineramaVisualsEqualProcPtr)(VisualPtr, ScreenPtr, VisualPtr); -extern _X_EXPORT XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr; - -extern _X_EXPORT void XineramaGetImageData( - DrawablePtr *pDrawables, - int left, - int top, - int width, - int height, - unsigned int format, - unsigned long planemask, - char *data, - int pitch, - Bool isRoot -); - -#endif /* _PANORAMIXSRV_H_ */ +
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PANORAMIXSRV_H_
+#define _PANORAMIXSRV_H_
+
+#include "panoramiX.h"
+
+extern _X_EXPORT int PanoramiXNumScreens;
+extern _X_EXPORT int PanoramiXPixWidth;
+extern _X_EXPORT int PanoramiXPixHeight;
+
+extern _X_EXPORT VisualID PanoramiXTranslateVisualID(int screen, VisualID orig);
+extern _X_EXPORT void PanoramiXConsolidate(void);
+extern _X_EXPORT Bool PanoramiXCreateConnectionBlock(void);
+extern _X_EXPORT PanoramiXRes * PanoramiXFindIDByScrnum(RESTYPE, XID, int);
+extern _X_EXPORT Bool XineramaRegisterConnectionBlockCallback(void (*func)(void));
+extern _X_EXPORT int XineramaDeleteResource(pointer, XID);
+
+extern _X_EXPORT void XineramaReinitData(ScreenPtr);
+
+extern _X_EXPORT unsigned long XRC_DRAWABLE;
+extern _X_EXPORT unsigned long XRT_WINDOW;
+extern _X_EXPORT unsigned long XRT_PIXMAP;
+extern _X_EXPORT unsigned long XRT_GC;
+extern _X_EXPORT unsigned long XRT_COLORMAP;
+
+/*
+ * Drivers are allowed to wrap this function. Each wrapper can decide that the
+ * two visuals are unequal, but if they are deemed equal, the wrapper must call
+ * down and return FALSE if the wrapped function does. This ensures that all
+ * layers agree that the visuals are equal. The first visual is always from
+ * screen 0.
+ */
+typedef Bool (*XineramaVisualsEqualProcPtr)(VisualPtr, ScreenPtr, VisualPtr);
+extern _X_EXPORT XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr;
+
+extern _X_EXPORT void XineramaGetImageData(
+ DrawablePtr *pDrawables,
+ int left,
+ int top,
+ int width,
+ int height,
+ unsigned int format,
+ unsigned long planemask,
+ char *data,
+ int pitch,
+ Bool isRoot
+);
+
+#endif /* _PANORAMIXSRV_H_ */
diff --git a/xorg-server/Xext/saver.c b/xorg-server/Xext/saver.c index 298f09042..910bb2e9a 100644 --- a/xorg-server/Xext/saver.c +++ b/xorg-server/Xext/saver.c @@ -232,8 +232,8 @@ MakeScreenPrivate ( ScreenPtr /* pScreen */
);
-static int ScreenPrivateKeyIndex;
-static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKeyIndex;
+static DevPrivateKeyRec ScreenPrivateKeyRec;
+#define ScreenPrivateKey (&ScreenPrivateKeyRec)
#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
@@ -258,6 +258,9 @@ ScreenSaverExtensionInit(INITARGS) int i;
ScreenPtr pScreen;
+ if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
AttrType = CreateNewResourceType(ScreenSaverFreeAttr, "SaverAttr");
SaverEventType = CreateNewResourceType(ScreenSaverFreeEvents,
"SaverEvent");
@@ -291,7 +294,7 @@ CheckScreenPrivate (ScreenPtr pScreen) {
free(pPriv);
SetScreenPrivate (pScreen, NULL);
- savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL;
+ pScreen->screensaver.ExternalScreenSaver = NULL;
}
}
@@ -310,7 +313,7 @@ MakeScreenPrivate (ScreenPtr pScreen) pPriv->hasWindow = FALSE;
pPriv->installedMap = None;
SetScreenPrivate (pScreen, pPriv);
- savedScreenInfo[pScreen->myNum].ExternalScreenSaver = ScreenSaverHandle;
+ pScreen->screensaver.ExternalScreenSaver = ScreenSaverHandle;
return pPriv;
}
@@ -509,8 +512,8 @@ SendScreenSaverNotify (ScreenPtr pScreen, int state, Bool forced) ev.type = ScreenSaverNotify + ScreenSaverEventBase;
ev.state = state;
ev.timestamp = currentTime.milliseconds;
- ev.root = WindowTable[pScreen->myNum]->drawable.id;
- ev.window = savedScreenInfo[pScreen->myNum].wid;
+ ev.root = pScreen->root->drawable.id;
+ ev.window = pScreen->screensaver.wid;
ev.kind = kind;
ev.forced = forced;
WriteEventsToClient (pEv->client, 1, (xEvent *) &ev);
@@ -565,7 +568,7 @@ CreateSaverWindow (ScreenPtr pScreen) Colormap wantMap;
ColormapPtr pCmap;
- pSaver = &savedScreenInfo[pScreen->myNum];
+ pSaver = &pScreen->screensaver;
if (pSaver->pWindow)
{
pSaver->pWindow = NullWindow;
@@ -586,7 +589,7 @@ CreateSaverWindow (ScreenPtr pScreen) if (GrabInProgress && GrabInProgress != pAttr->client->index)
return FALSE;
- pWin = CreateWindow (pSaver->wid, WindowTable[pScreen->myNum],
+ pWin = CreateWindow (pSaver->wid, pScreen->root,
pAttr->x, pAttr->y, pAttr->width, pAttr->height,
pAttr->borderWidth, pAttr->class,
pAttr->mask, (XID *)pAttr->values,
@@ -678,7 +681,7 @@ DestroySaverWindow (ScreenPtr pScreen) if (!pPriv || !pPriv->hasWindow)
return FALSE;
- pSaver = &savedScreenInfo[pScreen->myNum];
+ pSaver = &pScreen->screensaver;
if (pSaver->pWindow)
{
pSaver->pWindow = NullWindow;
@@ -762,7 +765,7 @@ ProcScreenSaverQueryInfo (ClientPtr client) if (rc != Success)
return rc;
- pSaver = &savedScreenInfo[pDraw->pScreen->myNum];
+ pSaver = &pDraw->pScreen->screensaver;
pPriv = GetScreenPrivate (pDraw->pScreen);
UpdateCurrentTime ();
@@ -872,7 +875,7 @@ ScreenSaverSetAttributes (ClientPtr client) if (ret != Success)
return ret;
pScreen = pDraw->pScreen;
- pParent = WindowTable[pScreen->myNum];
+ pParent = pScreen->root;
ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess);
if (ret != Success)
diff --git a/xorg-server/Xext/security.c b/xorg-server/Xext/security.c index 1eecf4a6e..b57dbc4d6 100644 --- a/xorg-server/Xext/security.c +++ b/xorg-server/Xext/security.c @@ -53,8 +53,8 @@ static RESTYPE RTEventClient; static CallbackListPtr SecurityValidateGroupCallback = NULL;
/* Private state record */
-static int stateKeyIndex;
-static DevPrivateKey stateKey = &stateKeyIndex;
+static DevPrivateKeyRec stateKeyRec;
+#define stateKey (&stateKeyRec)
/* This is what we store as client security state */
typedef struct {
@@ -244,7 +244,7 @@ SecurityDeleteAuthorizationEventClient( else
pAuth->eventClients = pEventClient->next;
free(pEventClient);
- return(Success);
+ return Success;
}
prev = pEventClient;
}
@@ -606,7 +606,7 @@ bailout: if (removeAuth)
RemoveAuthorization(stuff->nbytesAuthProto, protoname,
authdata_len, pAuthdata);
- if (pAuth) free(pAuth);
+ free(pAuth);
return err;
} /* ProcSecurityGenerateAuthorization */
@@ -807,7 +807,6 @@ SecurityResource(CallbackListPtr *pcbl, pointer unused, pointer calldata) Mask allowed = SecurityResourceMask;
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
- obj = dixLookupPrivate(&clients[cid]->devPrivates, stateKey);
/* disable background None for untrusted windows */
if ((requested & DixCreateAccess) && (rec->rtype == RT_WINDOW))
@@ -833,8 +832,11 @@ SecurityResource(CallbackListPtr *pcbl, pointer unused, pointer calldata) allowed |= DixReadAccess;
}
- if (SecurityDoCheck(subj, obj, requested, allowed) == Success)
- return;
+ if (clients[cid] != NULL) {
+ obj = dixLookupPrivate(&clients[cid]->devPrivates, stateKey);
+ if (SecurityDoCheck(subj, obj, requested, allowed) == Success)
+ return;
+ }
SecurityAudit("Security: denied client %d access %x to resource 0x%x "
"of client %d on request %s\n", rec->client->index,
@@ -1110,7 +1112,7 @@ SecurityExtensionInit(INITARGS) RTEventClient |= RC_NEVERRETAIN;
/* Allocate the private storage */
- if (!dixRequestPrivate(stateKey, sizeof(SecurityStateRec)))
+ if (!dixRegisterPrivateKey(stateKey, PRIVATE_CLIENT, sizeof(SecurityStateRec)))
FatalError("SecurityExtensionSetup: Can't allocate client private.\n");
/* Register callbacks */
diff --git a/xorg-server/Xext/shape.c b/xorg-server/Xext/shape.c index ee635e9c2..3ee9e027e 100644 --- a/xorg-server/Xext/shape.c +++ b/xorg-server/Xext/shape.c @@ -152,14 +152,12 @@ RegionOperate ( int xoff, int yoff,
CreateDftPtr create)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
if (srcRgn && (xoff || yoff))
- REGION_TRANSLATE(pScreen, srcRgn, xoff, yoff);
+ RegionTranslate(srcRgn, xoff, yoff);
if (!pWin->parent)
{
if (srcRgn)
- REGION_DESTROY(pScreen, srcRgn);
+ RegionDestroy(srcRgn);
return Success;
}
@@ -170,7 +168,7 @@ RegionOperate ( */
if (srcRgn == NULL) {
if (*destRgnp != NULL) {
- REGION_DESTROY (pScreen, *destRgnp);
+ RegionDestroy(*destRgnp);
*destRgnp = 0;
/* go on to remove shape and generate ShapeNotify */
}
@@ -189,17 +187,17 @@ RegionOperate ( else switch (op) {
case ShapeSet:
if (*destRgnp)
- REGION_DESTROY(pScreen, *destRgnp);
+ RegionDestroy(*destRgnp);
*destRgnp = srcRgn;
srcRgn = 0;
break;
case ShapeUnion:
if (*destRgnp)
- REGION_UNION(pScreen, *destRgnp, *destRgnp, srcRgn);
+ RegionUnion(*destRgnp, *destRgnp, srcRgn);
break;
case ShapeIntersect:
if (*destRgnp)
- REGION_INTERSECT(pScreen, *destRgnp, *destRgnp, srcRgn);
+ RegionIntersect(*destRgnp, *destRgnp, srcRgn);
else {
*destRgnp = srcRgn;
srcRgn = 0;
@@ -208,21 +206,21 @@ RegionOperate ( case ShapeSubtract:
if (!*destRgnp)
*destRgnp = (*create)(pWin);
- REGION_SUBTRACT(pScreen, *destRgnp, *destRgnp, srcRgn);
+ RegionSubtract(*destRgnp, *destRgnp, srcRgn);
break;
case ShapeInvert:
if (!*destRgnp)
- *destRgnp = REGION_CREATE(pScreen, (BoxPtr) 0, 0);
+ *destRgnp = RegionCreate((BoxPtr) 0, 0);
else
- REGION_SUBTRACT(pScreen, *destRgnp, srcRgn, *destRgnp);
+ RegionSubtract(*destRgnp, srcRgn, *destRgnp);
break;
default:
client->errorValue = op;
return BadValue;
}
if (srcRgn)
- REGION_DESTROY(pScreen, srcRgn);
- (*pScreen->SetShape) (pWin);
+ RegionDestroy(srcRgn);
+ (*pWin->drawable.pScreen->SetShape) (pWin, kind);
SendShapeNotify (pWin, kind);
return Success;
}
@@ -236,7 +234,7 @@ CreateBoundingShape (WindowPtr pWin) extents.y1 = -wBorderWidth (pWin);
extents.x2 = pWin->drawable.width + wBorderWidth (pWin);
extents.y2 = pWin->drawable.height + wBorderWidth (pWin);
- return REGION_CREATE(pWin->drawable.pScreen, &extents, 1);
+ return RegionCreate(&extents, 1);
}
RegionPtr
@@ -248,7 +246,7 @@ CreateClipShape (WindowPtr pWin) extents.y1 = 0;
extents.x2 = pWin->drawable.width;
extents.y2 = pWin->drawable.height;
- return REGION_CREATE(pWin->drawable.pScreen, &extents, 1);
+ return RegionCreate(&extents, 1);
}
static int
@@ -283,7 +281,6 @@ static int ProcShapeRectangles (ClientPtr client)
{
WindowPtr pWin;
- ScreenPtr pScreen;
REQUEST(xShapeRectanglesReq);
xRectangle *prects;
int nrects, ctype, rc;
@@ -316,7 +313,6 @@ ProcShapeRectangles (ClientPtr client) client->errorValue = stuff->ordering;
return BadValue;
}
- pScreen = pWin->drawable.pScreen;
nrects = ((stuff->length << 2) - sizeof(xShapeRectanglesReq));
if (nrects & 4)
return BadLength;
@@ -325,7 +321,7 @@ ProcShapeRectangles (ClientPtr client) ctype = VerifyRectOrder(nrects, prects, (int)stuff->ordering);
if (ctype < 0)
return BadMatch;
- srcRgn = RECTS_TO_REGION(pScreen, nrects, prects, ctype);
+ srcRgn = RegionFromRects(nrects, prects, ctype);
if (!pWin->optional)
MakeWindowOptional (pWin);
@@ -369,7 +365,7 @@ ProcPanoramiXShapeRectangles( result = ProcShapeRectangles (client);
if (result != Success) break;
}
- return (result);
+ return result;
}
#endif
@@ -421,7 +417,7 @@ ProcShapeMask (ClientPtr client) if (pPixmap->drawable.pScreen != pScreen ||
pPixmap->drawable.depth != 1)
return BadMatch;
- srcRgn = BITMAP_TO_REGION(pScreen, pPixmap);
+ srcRgn = BitmapToRegion(pScreen, pPixmap);
if (!srcRgn)
return BadAlloc;
}
@@ -478,7 +474,7 @@ ProcPanoramiXShapeMask( result = ProcShapeMask (client);
if (result != Success) break;
}
- return (result);
+ return result;
}
#endif
@@ -491,7 +487,6 @@ static int ProcShapeCombine (ClientPtr client)
{
WindowPtr pSrcWin, pDestWin;
- ScreenPtr pScreen;
REQUEST(xShapeCombineReq);
RegionPtr srcRgn;
RegionPtr *destRgn;
@@ -521,7 +516,6 @@ ProcShapeCombine (ClientPtr client) client->errorValue = stuff->destKind;
return BadValue;
}
- pScreen = pDestWin->drawable.pScreen;
rc = dixLookupWindow(&pSrcWin, stuff->src, client, DixGetAttrAccess);
if (rc != Success)
@@ -543,14 +537,14 @@ ProcShapeCombine (ClientPtr client) client->errorValue = stuff->srcKind;
return BadValue;
}
- if (pSrcWin->drawable.pScreen != pScreen)
+ if (pSrcWin->drawable.pScreen != pDestWin->drawable.pScreen)
{
return BadMatch;
}
if (srcRgn) {
- tmp = REGION_CREATE(pScreen, (BoxPtr) 0, 0);
- REGION_COPY(pScreen, tmp, srcRgn);
+ tmp = RegionCreate((BoxPtr) 0, 0);
+ RegionCopy(tmp, srcRgn);
srcRgn = tmp;
} else
srcRgn = (*createSrc) (pSrcWin);
@@ -604,7 +598,7 @@ ProcPanoramiXShapeCombine( result = ProcShapeCombine (client);
if (result != Success) break;
}
- return (result);
+ return result;
}
#endif
@@ -616,7 +610,6 @@ static int ProcShapeOffset (ClientPtr client)
{
WindowPtr pWin;
- ScreenPtr pScreen;
REQUEST(xShapeOffsetReq);
RegionPtr srcRgn;
int rc;
@@ -640,11 +633,10 @@ ProcShapeOffset (ClientPtr client) client->errorValue = stuff->destKind;
return BadValue;
}
- pScreen = pWin->drawable.pScreen;
if (srcRgn)
{
- REGION_TRANSLATE(pScreen, srcRgn, stuff->xOff, stuff->yOff);
- (*pScreen->SetShape) (pWin);
+ RegionTranslate(srcRgn, stuff->xOff, stuff->yOff);
+ (*pWin->drawable.pScreen->SetShape) (pWin, stuff->destKind);
}
SendShapeNotify (pWin, (int)stuff->destKind);
return Success;
@@ -672,7 +664,7 @@ ProcPanoramiXShapeOffset( result = ProcShapeOffset (client);
if(result != Success) break;
}
- return (result);
+ return result;
}
#endif
@@ -699,7 +691,7 @@ ProcShapeQueryExtents (ClientPtr client) rep.clipShaped = (wClipShape(pWin) != 0);
if ((region = wBoundingShape(pWin))) {
/* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
- pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region);
+ pExtents = RegionExtents(region);
extents = *pExtents;
} else {
extents.x1 = -wBorderWidth (pWin);
@@ -713,7 +705,7 @@ ProcShapeQueryExtents (ClientPtr client) rep.heightBoundingShape = extents.y2 - extents.y1;
if ((region = wClipShape(pWin))) {
/* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
- pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region);
+ pExtents = RegionExtents(region);
extents = *pExtents;
} else {
extents.x1 = 0;
@@ -901,7 +893,7 @@ SendShapeNotify (WindowPtr pWin, int which) case ShapeBounding:
region = wBoundingShape(pWin);
if (region) {
- extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
+ extents = *RegionExtents(region);
shaped = xTrue;
} else {
extents.x1 = -wBorderWidth (pWin);
@@ -914,7 +906,7 @@ SendShapeNotify (WindowPtr pWin, int which) case ShapeClip:
region = wClipShape(pWin);
if (region) {
- extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
+ extents = *RegionExtents(region);
shaped = xTrue;
} else {
extents.x1 = 0;
@@ -927,7 +919,7 @@ SendShapeNotify (WindowPtr pWin, int which) case ShapeInput:
region = wInputShape(pWin);
if (region) {
- extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
+ extents = *RegionExtents(region);
shaped = xTrue;
} else {
extents.x1 = -wBorderWidth (pWin);
@@ -1052,8 +1044,8 @@ ProcShapeGetRectangles (ClientPtr client) }
} else {
BoxPtr box;
- nrects = REGION_NUM_RECTS(region);
- box = REGION_RECTS(region);
+ nrects = RegionNumRects(region);
+ box = RegionRects(region);
rects = malloc(nrects * sizeof (xRectangle));
if (!rects && nrects)
return BadAlloc;
diff --git a/xorg-server/Xext/shm.c b/xorg-server/Xext/shm.c index a5ba7e8ca..638211bd2 100644 --- a/xorg-server/Xext/shm.c +++ b/xorg-server/Xext/shm.c @@ -143,10 +143,10 @@ int BadShmSegCode; RESTYPE ShmSegType;
static ShmDescPtr Shmsegs;
static Bool sharedPixmaps;
-static int shmScrPrivateKeyIndex;
-static DevPrivateKey shmScrPrivateKey = &shmScrPrivateKeyIndex;
-static int shmPixmapPrivateIndex;
-static DevPrivateKey shmPixmapPrivate = &shmPixmapPrivateIndex;
+static DevPrivateKeyRec shmScrPrivateKeyRec;
+#define shmScrPrivateKey (&shmScrPrivateKeyRec)
+static DevPrivateKeyRec shmPixmapPrivateKeyRec;
+#define shmPixmapPrivateKey (&shmPixmapPrivateKeyRec)
static ShmFuncs miFuncs = {NULL, NULL};
static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL};
@@ -215,7 +215,7 @@ static Bool CheckForShmSyscall(void) badSysCall = TRUE;
}
signal(SIGSYS, oldHandler);
- return(!badSysCall);
+ return !badSysCall;
}
#define MUST_CHECK_FOR_SHM_SYSCALL
@@ -246,6 +246,16 @@ ShmInitScreenPriv(ScreenPtr pScreen) return screen_priv;
}
+static Bool
+ShmRegisterPrivates(void)
+{
+ if (!dixRegisterPrivateKey(&shmScrPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&shmPixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
+ return FALSE;
+ return TRUE;
+}
+
void
ShmExtensionInit(INITARGS)
{
@@ -260,6 +270,9 @@ ShmExtensionInit(INITARGS) }
#endif
+ if (!ShmRegisterPrivates())
+ return;
+
sharedPixmaps = xFalse;
{
sharedPixmaps = xTrue;
@@ -305,6 +318,8 @@ ShmResetProc(ExtensionEntry *extEntry) void
ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs)
{
+ if (!ShmRegisterPrivates())
+ return;
ShmInitScreenPriv(pScreen)->shmFuncs = funcs;
}
@@ -318,7 +333,7 @@ ShmDestroyPixmap (PixmapPtr pPixmap) {
ShmDescPtr shmdesc;
shmdesc = (ShmDescPtr)dixLookupPrivate(&pPixmap->devPrivates,
- shmPixmapPrivate);
+ shmPixmapPrivateKey);
if (shmdesc)
ShmDetachSegment ((pointer) shmdesc, pPixmap->drawable.id);
}
@@ -458,7 +473,7 @@ ProcShmAttach(ClientPtr client) if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse))
{
client->errorValue = stuff->readOnly;
- return(BadValue);
+ return BadValue;
}
for (shmdesc = Shmsegs;
shmdesc && (shmdesc->shmid != stuff->shmid);
@@ -617,13 +632,13 @@ ProcPanoramiXShmPutImage(ClientPtr client) stuff->drawable = draw->info[j].id;
stuff->gc = gc->info[j].id;
if (isRoot) {
- stuff->dstX = orig_x - panoramiXdataPtr[j].x;
- stuff->dstY = orig_y - panoramiXdataPtr[j].y;
+ stuff->dstX = orig_x - screenInfo.screens[j]->x;
+ stuff->dstY = orig_y - screenInfo.screens[j]->y;
}
result = ProcShmPutImage(client);
if(result != Success) break;
}
- return(result);
+ return result;
}
static int
@@ -645,7 +660,7 @@ ProcPanoramiXShmGetImage(ClientPtr client) if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
client->errorValue = stuff->format;
- return(BadValue);
+ return BadValue;
}
rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable,
@@ -676,24 +691,24 @@ ProcPanoramiXShmGetImage(ClientPtr client) if( /* check for being onscreen */
x < 0 || x + w > PanoramiXPixWidth ||
y < 0 || y + h > PanoramiXPixHeight )
- return(BadMatch);
+ return BadMatch;
} else {
if( /* check for being onscreen */
- panoramiXdataPtr[0].x + pDraw->x + x < 0 ||
- panoramiXdataPtr[0].x + pDraw->x + x + w > PanoramiXPixWidth ||
- panoramiXdataPtr[0].y + pDraw->y + y < 0 ||
- panoramiXdataPtr[0].y + pDraw->y + y + h > PanoramiXPixHeight ||
+ screenInfo.screens[0]->x + pDraw->x + x < 0 ||
+ screenInfo.screens[0]->x + pDraw->x + x + w > PanoramiXPixWidth ||
+ screenInfo.screens[0]->y + pDraw->y + y < 0 ||
+ screenInfo.screens[0]->y + pDraw->y + y + h > PanoramiXPixHeight ||
/* check for being inside of border */
x < - wBorderWidth((WindowPtr)pDraw) ||
x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
y < -wBorderWidth((WindowPtr)pDraw) ||
y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height)
- return(BadMatch);
+ return BadMatch;
}
drawables = calloc(PanoramiXNumScreens, sizeof(DrawablePtr));
if(!drawables)
- return(BadAlloc);
+ return BadAlloc;
drawables[0] = pDraw;
for(i = 1; i < PanoramiXNumScreens; i++) {
@@ -836,7 +851,7 @@ CreatePmap: shmdesc->addr + stuff->offset);
if (pMap) {
- dixSetPrivate(&pMap->devPrivates, shmPixmapPrivate, shmdesc);
+ dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc);
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = newPix->info[j].id;
@@ -991,7 +1006,7 @@ ProcShmGetImage(ClientPtr client) if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap))
{
client->errorValue = stuff->format;
- return(BadValue);
+ return BadValue;
}
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixReadAccess);
@@ -1015,7 +1030,7 @@ ProcShmGetImage(ClientPtr client) stuff->y + (int)stuff->height >
wBorderWidth((WindowPtr)pDraw) + (int)pDraw->height
)
- return(BadMatch);
+ return BadMatch;
xgi.visual = wVisual(((WindowPtr)pDraw));
}
else
@@ -1025,7 +1040,7 @@ ProcShmGetImage(ClientPtr client) stuff->y < 0 ||
stuff->y+(int)stuff->height > pDraw->height
)
- return(BadMatch);
+ return BadMatch;
xgi.visual = None;
}
xgi.type = X_Reply;
@@ -1175,7 +1190,7 @@ CreatePmap: pDraw->pScreen->DestroyPixmap(pMap);
return rc;
}
- dixSetPrivate(&pMap->devPrivates, shmPixmapPrivate, shmdesc);
+ dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc);
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid;
@@ -1185,7 +1200,7 @@ CreatePmap: }
pDraw->pScreen->DestroyPixmap(pMap);
}
- return (BadAlloc);
+ return BadAlloc;
}
static int
diff --git a/xorg-server/Xext/xace.c b/xorg-server/Xext/xace.c index 4381e553a..48c5fb644 100644 --- a/xorg-server/Xext/xace.c +++ b/xorg-server/Xext/xace.c @@ -245,24 +245,21 @@ XaceCensorImage( unsigned int format,
char *pBuf)
{
- ScreenPtr pScreen;
RegionRec imageRegion; /* region representing x,y,w,h */
RegionRec censorRegion; /* region to obliterate */
BoxRec imageBox;
int nRects;
- pScreen = pDraw->pScreen;
-
imageBox.x1 = x;
imageBox.y1 = y;
imageBox.x2 = x + w;
imageBox.y2 = y + h;
- REGION_INIT(pScreen, &imageRegion, &imageBox, 1);
- REGION_NULL(pScreen, &censorRegion);
+ RegionInit(&imageRegion, &imageBox, 1);
+ RegionNull(&censorRegion);
/* censorRegion = imageRegion - visibleRegion */
- REGION_SUBTRACT(pScreen, &censorRegion, &imageRegion, pVisibleRegion);
- nRects = REGION_NUM_RECTS(&censorRegion);
+ RegionSubtract(&censorRegion, &imageRegion, pVisibleRegion);
+ nRects = RegionNumRects(&censorRegion);
if (nRects > 0)
{ /* we have something to censor */
GCPtr pScratchGC = NULL;
@@ -282,7 +279,7 @@ XaceCensorImage( failed = TRUE;
goto failSafe;
}
- for (pBox = REGION_RECTS(&censorRegion), i = 0;
+ for (pBox = RegionRects(&censorRegion), i = 0;
i < nRects;
i++, pBox++)
{
@@ -326,14 +323,14 @@ XaceCensorImage( /* Censoring was not completed above. To be safe, wipe out
* all the image data so that nothing trusted gets out.
*/
- bzero(pBuf, (int)(widthBytesLine * h));
+ memset(pBuf, 0, (int)(widthBytesLine * h));
}
- if (pRects) free(pRects);
+ free(pRects);
if (pScratchGC) FreeScratchGC(pScratchGC);
if (pPix) FreeScratchPixmapHeader(pPix);
}
- REGION_UNINIT(pScreen, &imageRegion);
- REGION_UNINIT(pScreen, &censorRegion);
+ RegionUninit(&imageRegion);
+ RegionUninit(&censorRegion);
} /* XaceCensorImage */
/*
diff --git a/xorg-server/Xext/xf86bigfont.c b/xorg-server/Xext/xf86bigfont.c index 2f0875faa..9d1223677 100644 --- a/xorg-server/Xext/xf86bigfont.c +++ b/xorg-server/Xext/xf86bigfont.c @@ -134,7 +134,7 @@ CheckForShmSyscall(void) badSysCall = TRUE;
}
signal(SIGSYS, oldHandler);
- return (!badSysCall);
+ return !badSysCall;
}
#define MUST_CHECK_FOR_SHM_SYSCALL
diff --git a/xorg-server/Xext/xselinux_hooks.c b/xorg-server/Xext/xselinux_hooks.c index 6075a34e8..57e49c090 100644 --- a/xorg-server/Xext/xselinux_hooks.c +++ b/xorg-server/Xext/xselinux_hooks.c @@ -59,12 +59,9 @@ typedef struct { } SELinuxAuditRec;
/* private state keys */
-static int subjectKeyIndex;
-DevPrivateKey subjectKey = &subjectKeyIndex;
-static int objectKeyIndex;
-DevPrivateKey objectKey = &objectKeyIndex;
-static int dataKeyIndex;
-DevPrivateKey dataKey = &dataKeyIndex;
+DevPrivateKeyRec subjectKeyRec;
+DevPrivateKeyRec objectKeyRec;
+DevPrivateKeyRec dataKeyRec;
/* audit file descriptor */
static int audit_fd;
@@ -896,9 +893,9 @@ SELinuxFlaskInit(void) FatalError("SELinux: Failed to open the system audit log\n");
/* Allocate private storage */
- if (!dixRequestPrivate(subjectKey, sizeof(SELinuxSubjectRec)) ||
- !dixRequestPrivate(objectKey, sizeof(SELinuxObjectRec)) ||
- !dixRequestPrivate(dataKey, sizeof(SELinuxObjectRec)))
+ if (!dixRegisterPrivateKey(subjectKey, PRIVATE_XSELINUX, sizeof(SELinuxSubjectRec)) ||
+ !dixRegisterPrivateKey(objectKey, PRIVATE_XSELINUX, sizeof(SELinuxObjectRec)) ||
+ !dixRegisterPrivateKey(dataKey, PRIVATE_XSELINUX, sizeof(SELinuxObjectRec)))
FatalError("SELinux: Failed to allocate private storage.\n");
/* Create atoms for doing window labeling */
diff --git a/xorg-server/Xext/xselinuxint.h b/xorg-server/Xext/xselinuxint.h index f084b94b2..fb1d7f4c7 100644 --- a/xorg-server/Xext/xselinuxint.h +++ b/xorg-server/Xext/xselinuxint.h @@ -62,9 +62,12 @@ typedef struct { * Globals
*/
-extern DevPrivateKey subjectKey;
-extern DevPrivateKey objectKey;
-extern DevPrivateKey dataKey;
+extern DevPrivateKeyRec subjectKeyRec;
+#define subjectKey (&subjectKeyRec)
+extern DevPrivateKeyRec objectKeyRec;
+#define objectKey (&objectKeyRec)
+extern DevPrivateKeyRec dataKeyRec;
+#define dataKey (&dataKeyRec)
/*
* Label functions
diff --git a/xorg-server/Xext/xtest.c b/xorg-server/Xext/xtest.c index b8f5e86d8..9873f662a 100644 --- a/xorg-server/Xext/xtest.c +++ b/xorg-server/Xext/xtest.c @@ -62,10 +62,6 @@ extern int DeviceValuator; * other's memory */
static EventListPtr xtest_evlist;
-/* Used to store if a device is an XTest Virtual device */
-static int XTestDevicePrivateKeyIndex;
-DevPrivateKey XTestDevicePrivateKey = &XTestDevicePrivateKeyIndex;
-
/**
* xtestpointer
* is the virtual pointer for XTest. It is the first slave
@@ -469,7 +465,7 @@ ProcXTestGrabControl(ClientPtr client) if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse))
{
client->errorValue = stuff->impervious;
- return(BadValue);
+ return BadValue;
}
if (stuff->impervious)
MakeClientGrabImpervious(client);
@@ -645,8 +641,8 @@ int AllocXTestDevice (ClientPtr client, char* name, retval = AllocDevicePair( client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE);
if ( retval == Success ){
- dixSetPrivate(&((*ptr)->devPrivates), XTestDevicePrivateKey, (void *)(intptr_t)master_ptr->id);
- dixSetPrivate(&((*keybd)->devPrivates), XTestDevicePrivateKey, (void *)(intptr_t)master_keybd->id);
+ (*ptr)->xtest_master_id = master_ptr->id;
+ (*keybd)->xtest_master_id = master_keybd->id;
XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
XA_INTEGER, 8, PropModeReplace, 1, &dummy,
@@ -674,23 +670,15 @@ int AllocXTestDevice (ClientPtr client, char* name, BOOL
IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master)
{
- int is_XTest = FALSE;
- int mid;
- void *tmp; /* shut up, gcc! */
-
if (IsMaster(dev))
- return is_XTest;
-
- tmp = dixLookupPrivate(&dev->devPrivates, XTestDevicePrivateKey);
- mid = (intptr_t)tmp;
+ return FALSE;
/* deviceid 0 is reserved for XIAllDevices, non-zero mid means XTest
* device */
- if ((!master && mid) ||
- (master && mid == master->id))
- is_XTest = TRUE;
+ if (master)
+ return dev->xtest_master_id == master->id;
- return is_XTest;
+ return dev->xtest_master_id != 0;
}
/**
diff --git a/xorg-server/Xext/xvdisp.c b/xorg-server/Xext/xvdisp.c index f346b6cea..e723fd84b 100644 --- a/xorg-server/Xext/xvdisp.c +++ b/xorg-server/Xext/xvdisp.c @@ -483,7 +483,7 @@ ProcXvQueryEncodings(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
rep.type = X_Reply;
@@ -540,14 +540,14 @@ ProcXvPutVideo(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
if (!(pPort->pAdaptor->type & XvInputMask) ||
!(pPort->pAdaptor->type & XvVideoMask))
{
client->errorValue = stuff->port;
- return (BadMatch);
+ return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
@@ -578,14 +578,14 @@ ProcXvPutStill(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
if (!(pPort->pAdaptor->type & XvInputMask) ||
!(pPort->pAdaptor->type & XvStillMask))
{
client->errorValue = stuff->port;
- return (BadMatch);
+ return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
@@ -616,14 +616,14 @@ ProcXvGetVideo(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
if (!(pPort->pAdaptor->type & XvOutputMask) ||
!(pPort->pAdaptor->type & XvVideoMask))
{
client->errorValue = stuff->port;
- return (BadMatch);
+ return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
@@ -654,14 +654,14 @@ ProcXvGetStill(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
if (!(pPort->pAdaptor->type & XvOutputMask) ||
!(pPort->pAdaptor->type & XvStillMask))
{
client->errorValue = stuff->port;
- return (BadMatch);
+ return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
@@ -703,7 +703,7 @@ ProcXvSelectPortNotify(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
return XvdiSelectPortNotify(client, pPort, stuff->onoff);
@@ -723,7 +723,7 @@ ProcXvGrabPort(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
status = XvdiGrabPort(client, pPort, stuff->time, &result);
@@ -756,7 +756,7 @@ ProcXvUngrabPort(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
return XvdiUngrabPort(client, pPort, stuff->time);
@@ -776,7 +776,7 @@ ProcXvStopVideo(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess);
@@ -799,13 +799,13 @@ ProcXvSetPortAttribute(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
if (!ValidAtom(stuff->attribute))
{
client->errorValue = stuff->attribute;
- return(BadAtom);
+ return BadAtom;
}
status = XvdiSetPortAttribute(client, pPort, stuff->attribute, stuff->value);
@@ -833,13 +833,13 @@ ProcXvGetPortAttribute(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
if (!ValidAtom(stuff->attribute))
{
client->errorValue = stuff->attribute;
- return(BadAtom);
+ return BadAtom;
}
status = XvdiGetPortAttribute(client, pPort, stuff->attribute, &value);
@@ -874,7 +874,7 @@ ProcXvQueryBestSize(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
rep.type = X_Reply;
@@ -911,7 +911,7 @@ ProcXvQueryPortAttributes(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
rep.type = X_Reply;
@@ -967,14 +967,14 @@ ProcXvPutImage(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
if (!(pPort->pAdaptor->type & XvImageMask) ||
!(pPort->pAdaptor->type & XvInputMask))
{
client->errorValue = stuff->port;
- return (BadMatch);
+ return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
@@ -1047,14 +1047,14 @@ ProcXvShmPutImage(ClientPtr client) if ((status = _AllocatePort(stuff->port, pPort)) != Success)
{
client->errorValue = stuff->port;
- return (status);
+ return status;
}
if (!(pPort->pAdaptor->type & XvImageMask) ||
!(pPort->pAdaptor->type & XvInputMask))
{
client->errorValue = stuff->port;
- return (BadMatch);
+ return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
@@ -1113,7 +1113,7 @@ static int ProcXvShmPutImage(ClientPtr client)
{
SendErrorToClient(client, XvReqCode, xv_ShmPutImage, 0, BadImplementation);
- return(BadImplementation);
+ return BadImplementation;
}
#endif
@@ -1267,7 +1267,7 @@ ProcXvDispatch(ClientPtr client) if (stuff->data > xvNumRequests) {
SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest);
- return(BadRequest);
+ return BadRequest;
}
return XvProcVector[stuff->data](client);
@@ -1591,7 +1591,7 @@ SProcXvDispatch(ClientPtr client) if (stuff->data > xvNumRequests) {
SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest);
- return(BadRequest);
+ return BadRequest;
}
return SXvProcVector[stuff->data](client);
@@ -1690,8 +1690,8 @@ XineramaXvShmPutImage(ClientPtr client) stuff->drw_x = x;
stuff->drw_y = y;
if(isRoot) {
- stuff->drw_x -= panoramiXdataPtr[i].x;
- stuff->drw_y -= panoramiXdataPtr[i].y;
+ stuff->drw_x -= screenInfo.screens[i]->x;
+ stuff->drw_y -= screenInfo.screens[i]->y;
}
stuff->send_event = (send_event && !i) ? 1 : 0;
@@ -1742,8 +1742,8 @@ XineramaXvPutImage(ClientPtr client) stuff->drw_x = x;
stuff->drw_y = y;
if(isRoot) {
- stuff->drw_x -= panoramiXdataPtr[i].x;
- stuff->drw_y -= panoramiXdataPtr[i].y;
+ stuff->drw_x -= screenInfo.screens[i]->x;
+ stuff->drw_y -= screenInfo.screens[i]->y;
}
result = ProcXvPutImage(client);
@@ -1790,8 +1790,8 @@ XineramaXvPutVideo(ClientPtr client) stuff->drw_x = x;
stuff->drw_y = y;
if(isRoot) {
- stuff->drw_x -= panoramiXdataPtr[i].x;
- stuff->drw_y -= panoramiXdataPtr[i].y;
+ stuff->drw_x -= screenInfo.screens[i]->x;
+ stuff->drw_y -= screenInfo.screens[i]->y;
}
result = ProcXvPutVideo(client);
@@ -1838,8 +1838,8 @@ XineramaXvPutStill(ClientPtr client) stuff->drw_x = x;
stuff->drw_y = y;
if(isRoot) {
- stuff->drw_x -= panoramiXdataPtr[i].x;
- stuff->drw_y -= panoramiXdataPtr[i].y;
+ stuff->drw_x -= screenInfo.screens[i]->x;
+ stuff->drw_y -= screenInfo.screens[i]->y;
}
result = ProcXvPutStill(client);
diff --git a/xorg-server/Xext/xvmain.c b/xorg-server/Xext/xvmain.c index ffceb999f..330d323cb 100644 --- a/xorg-server/Xext/xvmain.c +++ b/xorg-server/Xext/xvmain.c @@ -105,8 +105,8 @@ SOFTWARE. #endif
#include "xvdisp.h"
-static int XvScreenKeyIndex;
-static DevPrivateKey XvScreenKey = &XvScreenKeyIndex;
+static DevPrivateKeyRec XvScreenKeyRec;
+#define XvScreenKey (&XvScreenKeyRec)
unsigned long XvExtensionGeneration = 0;
unsigned long XvScreenGeneration = 0;
unsigned long XvResourceGeneration = 0;
@@ -156,6 +156,9 @@ XvExtensionInit(void) {
ExtensionEntry *extEntry;
+ if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
/* LOOK TO SEE IF ANY SCREENS WERE INITIALIZED; IF NOT THEN
INIT GLOBAL VARIABLES SO THE EXTENSION CAN FUNCTION */
if (XvScreenGeneration != serverGeneration)
@@ -269,6 +272,9 @@ XvScreenInit(ScreenPtr pScreen) XvScreenGeneration = serverGeneration;
}
+ if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
+ return BadAlloc;
+
if (dixLookupPrivate(&pScreen->devPrivates, XvScreenKey))
{
ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n");
@@ -284,7 +290,6 @@ XvScreenInit(ScreenPtr pScreen) }
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs);
-
pxvs->DestroyPixmap = pScreen->DestroyPixmap;
pxvs->DestroyWindow = pScreen->DestroyWindow;
@@ -629,7 +634,7 @@ XvdiPutVideo( pPort->time = currentTime;
- return (Success);
+ return Success;
}
@@ -759,7 +764,7 @@ XvdiGetVideo( pPort->time = currentTime;
- return (Success);
+ return Success;
}
diff --git a/xorg-server/Xext/xvmc.c b/xorg-server/Xext/xvmc.c index 4866d1d45..9b9dd0bc2 100644 --- a/xorg-server/Xext/xvmc.c +++ b/xorg-server/Xext/xvmc.c @@ -33,8 +33,9 @@ #define DR_CLIENT_DRIVER_NAME_SIZE 48
#define DR_BUSID_SIZE 48
-static int XvMCScreenKeyIndex;
-static DevPrivateKey XvMCScreenKey;
+static DevPrivateKeyRec XvMCScreenKeyRec;
+#define XvMCScreenKey (&XvMCScreenKeyRec)
+static Bool XvMCInUse;
unsigned long XvMCGeneration = 0;
@@ -138,7 +139,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client) VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if(XvMCScreenKey) { /* any adaptors at all */
+ if(XvMCInUse) { /* any adaptors at all */
ScreenPtr pScreen = pPort->pAdaptor->pScreen;
if((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */
for(i = 0; i < pScreenPriv->num_adaptors; i++) {
@@ -193,7 +194,7 @@ ProcXvMCCreateContext(ClientPtr client) pScreen = pPort->pAdaptor->pScreen;
- if(XvMCScreenKey == NULL) /* no XvMC adaptors */
+ if(!XvMCInUse) /* no XvMC adaptors */
return BadMatch;
if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */
@@ -258,8 +259,7 @@ ProcXvMCCreateContext(ClientPtr client) WriteToClient(client, dwords << 2, (char*)data);
AddResource(pContext->context_id, XvMCRTContext, pContext);
- if(data)
- free(data);
+ free(data);
return Success;
}
@@ -326,8 +326,7 @@ ProcXvMCCreateSurface(ClientPtr client) WriteToClient(client, dwords << 2, (char*)data);
AddResource(pSurface->surface_id, XvMCRTSurface, pSurface);
- if(data)
- free(data);
+ free(data);
pContext->refcnt++;
@@ -443,8 +442,7 @@ ProcXvMCCreateSubpicture(ClientPtr client) WriteToClient(client, dwords << 2, (char*)data);
AddResource(pSubpicture->subpicture_id, XvMCRTSubpicture, pSubpicture);
- if(data)
- free(data);
+ free(data);
pContext->refcnt++;
@@ -716,7 +714,8 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt) {
XvMCScreenPtr pScreenPriv;
- XvMCScreenKey = &XvMCScreenKeyIndex;
+ if (!dixRegisterPrivateKey(&XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
+ return BadAlloc;
if(!(pScreenPriv = malloc(sizeof(XvMCScreenRec))))
return BadAlloc;
@@ -734,6 +733,8 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt) pScreenPriv->minor = 0;
pScreenPriv->patchLevel = 0;
+ XvMCInUse = TRUE;
+
return Success;
}
diff --git a/xorg-server/Xi/closedev.c b/xorg-server/Xi/closedev.c index 159ead55c..fcd0ed832 100644 --- a/xorg-server/Xi/closedev.c +++ b/xorg-server/Xi/closedev.c @@ -1,167 +1,167 @@ -/************************************************************ - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -Copyright 1989 by Hewlett-Packard Company, Palo Alto, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Hewlett-Packard not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -********************************************************/ - -/*********************************************************************** - * - * Extension function to close an extension input device. - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include "scrnintstr.h" /* screen structure */ -#include <X11/extensions/XI.h> -#include <X11/extensions/XIproto.h> -#include "XIstubs.h" -#include "exglobals.h" - -#include "closedev.h" - -/*********************************************************************** - * - * This procedure closes an input device. - * - */ - -int -SProcXCloseDevice(ClientPtr client) -{ - char n; - - REQUEST(xCloseDeviceReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCloseDeviceReq); - return (ProcXCloseDevice(client)); -} - -/*********************************************************************** - * - * Clear out event selections and passive grabs from a window for the - * specified device. - * - */ - -static void -DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) -{ - InputClientsPtr others; - OtherInputMasks *pOthers; - GrabPtr grab, next; - - if ((pOthers = wOtherInputMasks(pWin)) != 0) - for (others = pOthers->inputClients; others; others = others->next) - if (SameClient(others, client)) - others->mask[dev->id] = NoEventMask; - - for (grab = wPassiveGrabs(pWin); grab; grab = next) { - next = grab->next; - if ((grab->device == dev) && - (client->clientAsMask == CLIENT_BITS(grab->resource))) - FreeResource(grab->resource, RT_NONE); - } -} - -/*********************************************************************** - * - * Walk througth the window tree, deleting event selections for this client - * from this device from all windows. - * - */ - -static void -DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client) -{ - WindowPtr p2; - - while (p1) { - p2 = p1->firstChild; - DeleteDeviceEvents(dev, p1, client); - DeleteEventsFromChildren(dev, p2, client); - p1 = p1->nextSib; - } -} - -/*********************************************************************** - * - * This procedure closes an input device. - * - */ - -int -ProcXCloseDevice(ClientPtr client) -{ - int rc, i; - WindowPtr pWin, p1; - DeviceIntPtr d; - - REQUEST(xCloseDeviceReq); - REQUEST_SIZE_MATCH(xCloseDeviceReq); - - rc = dixLookupDevice(&d, stuff->deviceid, client, DixUseAccess); - if (rc != Success) - return rc; - - if (d->deviceGrab.grab && SameClient(d->deviceGrab.grab, client)) - (*d->deviceGrab.DeactivateGrab) (d); /* release active grab */ - - /* Remove event selections from all windows for events from this device - * and selected by this client. - * Delete passive grabs from all windows for this device. */ - - for (i = 0; i < screenInfo.numScreens; i++) { - pWin = WindowTable[i]; - DeleteDeviceEvents(d, pWin, client); - p1 = pWin->firstChild; - DeleteEventsFromChildren(d, p1, client); - } - - CloseInputDevice(d, client); - return Success; -} +/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * Extension function to close an extension input device.
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include "scrnintstr.h" /* screen structure */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+#include "exglobals.h"
+
+#include "closedev.h"
+
+/***********************************************************************
+ *
+ * This procedure closes an input device.
+ *
+ */
+
+int
+SProcXCloseDevice(ClientPtr client)
+{
+ char n;
+
+ REQUEST(xCloseDeviceReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCloseDeviceReq);
+ return (ProcXCloseDevice(client));
+}
+
+/***********************************************************************
+ *
+ * Clear out event selections and passive grabs from a window for the
+ * specified device.
+ *
+ */
+
+static void
+DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
+{
+ InputClientsPtr others;
+ OtherInputMasks *pOthers;
+ GrabPtr grab, next;
+
+ if ((pOthers = wOtherInputMasks(pWin)) != 0)
+ for (others = pOthers->inputClients; others; others = others->next)
+ if (SameClient(others, client))
+ others->mask[dev->id] = NoEventMask;
+
+ for (grab = wPassiveGrabs(pWin); grab; grab = next) {
+ next = grab->next;
+ if ((grab->device == dev) &&
+ (client->clientAsMask == CLIENT_BITS(grab->resource)))
+ FreeResource(grab->resource, RT_NONE);
+ }
+}
+
+/***********************************************************************
+ *
+ * Walk througth the window tree, deleting event selections for this client
+ * from this device from all windows.
+ *
+ */
+
+static void
+DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client)
+{
+ WindowPtr p2;
+
+ while (p1) {
+ p2 = p1->firstChild;
+ DeleteDeviceEvents(dev, p1, client);
+ DeleteEventsFromChildren(dev, p2, client);
+ p1 = p1->nextSib;
+ }
+}
+
+/***********************************************************************
+ *
+ * This procedure closes an input device.
+ *
+ */
+
+int
+ProcXCloseDevice(ClientPtr client)
+{
+ int rc, i;
+ WindowPtr pWin, p1;
+ DeviceIntPtr d;
+
+ REQUEST(xCloseDeviceReq);
+ REQUEST_SIZE_MATCH(xCloseDeviceReq);
+
+ rc = dixLookupDevice(&d, stuff->deviceid, client, DixUseAccess);
+ if (rc != Success)
+ return rc;
+
+ if (d->deviceGrab.grab && SameClient(d->deviceGrab.grab, client))
+ (*d->deviceGrab.DeactivateGrab) (d); /* release active grab */
+
+ /* Remove event selections from all windows for events from this device
+ * and selected by this client.
+ * Delete passive grabs from all windows for this device. */
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pWin = screenInfo.screens[i]->root;
+ DeleteDeviceEvents(d, pWin, client);
+ p1 = pWin->firstChild;
+ DeleteEventsFromChildren(d, p1, client);
+ }
+
+ CloseInputDevice(d, client);
+ return Success;
+}
diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c index 6eb51ca02..8e566737a 100644 --- a/xorg-server/Xi/exevents.c +++ b/xorg-server/Xi/exevents.c @@ -195,16 +195,12 @@ void CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
{
KeyClassPtr mk = master->key;
- KeyClassPtr dk = device->key;
- int i;
if (device == master)
return;
mk->sourceid = device->id;
- for (i = 0; i < 8; i++)
- mk->modifierKeyCount[i] = dk->modifierKeyCount[i];
if (!XkbCopyDeviceKeymap(master, device))
FatalError("Couldn't pivot keymap from device to core!\n");
@@ -928,8 +924,8 @@ ProcessRawEvent(RawDeviceEvent *ev, DeviceIntPtr device) }
for (i = 0; i < screenInfo.numScreens; i++)
- if (WindowTable[i])
- DeliverEventsToWindow(device, WindowTable[i], xi, 1,
+ if (screenInfo.screens[i] && screenInfo.screens[i]->root)
+ DeliverEventsToWindow(device, screenInfo.screens[i]->root, xi, 1,
GetEventFilter(device, xi), NULL);
free(xi);
}
@@ -1047,7 +1043,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device) /* see comment in EnqueueEvents regarding the next three lines */
if (ev->any.type == ET_Motion)
- ev->device_event.root = WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id;
+ ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
eventinfo.device = device;
eventinfo.event = ev;
@@ -1711,7 +1707,7 @@ InputClientGone(WindowPtr pWin, XID id) InputClientsPtr other, prev;
if (!wOtherInputMasks(pWin))
- return (Success);
+ return Success;
prev = 0;
for (other = wOtherInputMasks(pWin)->inputClients; other;
other = other->next) {
@@ -1737,7 +1733,7 @@ InputClientGone(WindowPtr pWin, XID id) free(other);
}
RecalculateDeviceDeliverableEvents(pWin);
- return (Success);
+ return Success;
}
prev = other;
}
@@ -1838,7 +1834,7 @@ ChangeKeyMapping(ClientPtr client, KeyClassPtr k = dev->key;
if (k == NULL)
- return (BadMatch);
+ return BadMatch;
if (len != (keyCodes * keySymsPerKeyCode))
return BadLength;
@@ -1981,7 +1977,7 @@ MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask) pEvents->detail = NotifyNormal;
}
}
- return (0);
+ return 0;
}
void
@@ -2129,7 +2125,7 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count) WindowPtr pWin, p1;
for (i = 0; i < screenInfo.numScreens; i++) {
- pWin = WindowTable[i];
+ pWin = screenInfo.screens[i]->root;
if (!pWin)
continue;
DeliverEventsToWindow(dev, pWin, ev, count, mask, NullGrab);
diff --git a/xorg-server/Xi/exglobals.h b/xorg-server/Xi/exglobals.h index 2d2d25c0b..4f09e6ca3 100644 --- a/xorg-server/Xi/exglobals.h +++ b/xorg-server/Xi/exglobals.h @@ -1,82 +1,84 @@ -/************************************************************ - -Copyright 1996 by Thomas E. Dickey <dickey@clark.net> - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of the above listed -copyright holder(s) not be used in advertising or publicity pertaining -to distribution of the software without specific, written prior -permission. - -THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD -TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE -LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -********************************************************/ - -/***************************************************************** - * - * Globals referenced elsewhere in the server. - * - */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif -#include "privates.h" - -#ifndef EXGLOBALS_H -#define EXGLOBALS_H 1 - -extern int IReqCode; -extern int IEventBase; -extern int BadDevice; -extern int BadMode; -extern int DeviceBusy; -extern int BadClass; - -/* Note: only the ones needed in files other than extinit.c are declared */ -extern const Mask DevicePointerMotionMask; -extern const Mask DevicePointerMotionHintMask; -extern const Mask DeviceFocusChangeMask; -extern const Mask DeviceStateNotifyMask; -extern const Mask DeviceMappingNotifyMask; -extern const Mask DeviceOwnerGrabButtonMask; -extern const Mask DeviceButtonGrabMask; -extern const Mask DeviceButtonMotionMask; -extern const Mask DevicePresenceNotifyMask; -extern const Mask DevicePropertyNotifyMask; -extern const Mask XIAllMasks; - -extern Mask PropagateMask[]; - -extern int DeviceValuator; -extern int DeviceKeyPress; -extern int DeviceKeyRelease; -extern int DeviceButtonPress; -extern int DeviceButtonRelease; -extern int DeviceMotionNotify; -extern int DeviceFocusIn; -extern int DeviceFocusOut; -extern int ProximityIn; -extern int ProximityOut; -extern int DeviceStateNotify; -extern int DeviceKeyStateNotify; -extern int DeviceButtonStateNotify; -extern int DeviceMappingNotify; -extern int ChangeDeviceNotify; -extern int DevicePresenceNotify; -extern int DevicePropertyNotify; - -extern int RT_INPUTCLIENT; - -extern DevPrivateKey XIClientPrivateKey; -#endif /* EXGLOBALS_H */ +/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*****************************************************************
+ *
+ * Globals referenced elsewhere in the server.
+ *
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+#include "privates.h"
+
+#ifndef EXGLOBALS_H
+#define EXGLOBALS_H 1
+
+extern int IReqCode;
+extern int IEventBase;
+extern int BadDevice;
+extern int BadMode;
+extern int DeviceBusy;
+extern int BadClass;
+
+/* Note: only the ones needed in files other than extinit.c are declared */
+extern const Mask DevicePointerMotionMask;
+extern const Mask DevicePointerMotionHintMask;
+extern const Mask DeviceFocusChangeMask;
+extern const Mask DeviceStateNotifyMask;
+extern const Mask DeviceMappingNotifyMask;
+extern const Mask DeviceOwnerGrabButtonMask;
+extern const Mask DeviceButtonGrabMask;
+extern const Mask DeviceButtonMotionMask;
+extern const Mask DevicePresenceNotifyMask;
+extern const Mask DevicePropertyNotifyMask;
+extern const Mask XIAllMasks;
+
+extern Mask PropagateMask[];
+
+extern int DeviceValuator;
+extern int DeviceKeyPress;
+extern int DeviceKeyRelease;
+extern int DeviceButtonPress;
+extern int DeviceButtonRelease;
+extern int DeviceMotionNotify;
+extern int DeviceFocusIn;
+extern int DeviceFocusOut;
+extern int ProximityIn;
+extern int ProximityOut;
+extern int DeviceStateNotify;
+extern int DeviceKeyStateNotify;
+extern int DeviceButtonStateNotify;
+extern int DeviceMappingNotify;
+extern int ChangeDeviceNotify;
+extern int DevicePresenceNotify;
+extern int DevicePropertyNotify;
+
+extern int RT_INPUTCLIENT;
+
+extern DevPrivateKeyRec XIClientPrivateKeyRec;
+#define XIClientPrivateKey (&XIClientPrivateKeyRec)
+
+#endif /* EXGLOBALS_H */
diff --git a/xorg-server/Xi/extinit.c b/xorg-server/Xi/extinit.c index 9d6c81a5b..58943f08d 100644 --- a/xorg-server/Xi/extinit.c +++ b/xorg-server/Xi/extinit.c @@ -377,9 +377,7 @@ Mask PropagateMask[MAXDEVICES]; *
*/
-static int XIClientPrivateKeyIndex;
-DevPrivateKey XIClientPrivateKey = &XIClientPrivateKeyIndex;
-
+DevPrivateKeyRec XIClientPrivateKeyRec;
/*****************************************************************
*
@@ -1256,7 +1254,7 @@ XInputExtensionInit(void) SERVER_XI_MINOR_VERSION,
};
- if (!dixRequestPrivate(XIClientPrivateKey, sizeof(XIClientRec)))
+ if (!dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec)))
FatalError("Cannot request private for XI.\n");
if (!AddCallback(&ClientStateCallback, XIClientCallback, 0))
diff --git a/xorg-server/Xi/getprop.c b/xorg-server/Xi/getprop.c index 8f2d792be..5be09c685 100644 --- a/xorg-server/Xi/getprop.c +++ b/xorg-server/Xi/getprop.c @@ -164,7 +164,7 @@ XEventClass *buf++ = (id << 8) | EventInfo[j].type;
}
}
- return (buf);
+ return buf;
}
/***********************************************************************
diff --git a/xorg-server/Xi/gtmotion.c b/xorg-server/Xi/gtmotion.c index 930e08c8c..ae69a3c92 100644 --- a/xorg-server/Xi/gtmotion.c +++ b/xorg-server/Xi/gtmotion.c @@ -153,8 +153,7 @@ ProcXGetDeviceMotionEvents(ClientPtr client) }
WriteToClient(client, length * 4, (char *)coords);
}
- if (coords)
- free(coords);
+ free(coords);
return Success;
}
diff --git a/xorg-server/Xi/listdev.c b/xorg-server/Xi/listdev.c index 2015f9cdd..52fc85f57 100644 --- a/xorg-server/Xi/listdev.c +++ b/xorg-server/Xi/listdev.c @@ -269,7 +269,7 @@ CopySwapValuatorClass(ClientPtr client, ValuatorClassPtr v, char **buf) *buf += sizeof(xAxisInfo);
}
}
- return (i);
+ return i;
}
static void
diff --git a/xorg-server/Xi/opendev.c b/xorg-server/Xi/opendev.c index 3844d25a2..092b464ee 100644 --- a/xorg-server/Xi/opendev.c +++ b/xorg-server/Xi/opendev.c @@ -1,175 +1,175 @@ -/************************************************************ - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -Copyright 1989 by Hewlett-Packard Company, Palo Alto, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Hewlett-Packard not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -********************************************************/ - -/*********************************************************************** - * - * Request to open an extension input device. - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "inputstr.h" /* DeviceIntPtr */ -#include <X11/extensions/XI.h> -#include <X11/extensions/XIproto.h> -#include "XIstubs.h" -#include "windowstr.h" /* window structure */ -#include "exglobals.h" -#include "exevents.h" - -#include "opendev.h" - -extern CARD8 event_base[]; - -/*********************************************************************** - * - * This procedure swaps the request if the server and client have different - * byte orderings. - * - */ - -int -SProcXOpenDevice(ClientPtr client) -{ - char n; - - REQUEST(xOpenDeviceReq); - swaps(&stuff->length, n); - return (ProcXOpenDevice(client)); -} - -/*********************************************************************** - * - * This procedure causes the server to open an input device. - * - */ - -int -ProcXOpenDevice(ClientPtr client) -{ - xInputClassInfo evbase[numInputClasses]; - int j = 0; - int status = Success; - xOpenDeviceReply rep; - DeviceIntPtr dev; - - REQUEST(xOpenDeviceReq); - REQUEST_SIZE_MATCH(xOpenDeviceReq); - - status = dixLookupDevice(&dev, stuff->deviceid, client, DixUseAccess); - - if (status == BadDevice) { /* not open */ - for (dev = inputInfo.off_devices; dev; dev = dev->next) - if (dev->id == stuff->deviceid) - break; - if (dev == NULL) - return BadDevice; - } else if (status != Success) - return status; - - if (IsMaster(dev)) - return BadDevice; - - OpenInputDevice(dev, client, &status); - if (status != Success) - return status; - - memset(&rep, 0, sizeof(xOpenDeviceReply)); - rep.repType = X_Reply; - rep.RepType = X_OpenDevice; - rep.sequenceNumber = client->sequence; - if (dev->key != NULL) { - evbase[j].class = KeyClass; - evbase[j++].event_type_base = event_base[KeyClass]; - } - if (dev->button != NULL) { - evbase[j].class = ButtonClass; - evbase[j++].event_type_base = event_base[ButtonClass]; - } - if (dev->valuator != NULL) { - evbase[j].class = ValuatorClass; - evbase[j++].event_type_base = event_base[ValuatorClass]; - } - if (dev->kbdfeed != NULL || dev->ptrfeed != NULL || dev->leds != NULL || - dev->intfeed != NULL || dev->bell != NULL || dev->stringfeed != NULL) { - evbase[j].class = FeedbackClass; - evbase[j++].event_type_base = event_base[FeedbackClass]; - } - if (dev->focus != NULL) { - evbase[j].class = FocusClass; - evbase[j++].event_type_base = event_base[FocusClass]; - } - if (dev->proximity != NULL) { - evbase[j].class = ProximityClass; - evbase[j++].event_type_base = event_base[ProximityClass]; - } - evbase[j].class = OtherClass; - evbase[j++].event_type_base = event_base[OtherClass]; - rep.length = bytes_to_int32(j * sizeof(xInputClassInfo)); - rep.num_classes = j; - WriteReplyToClient(client, sizeof(xOpenDeviceReply), &rep); - WriteToClient(client, j * sizeof(xInputClassInfo), (char *)evbase); - return (Success); -} - -/*********************************************************************** - * - * This procedure writes the reply for the XOpenDevice function, - * if the client and server have a different byte ordering. - * - */ - -void -SRepXOpenDevice(ClientPtr client, int size, xOpenDeviceReply * rep) -{ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - WriteToClient(client, size, (char *)rep); -} +/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * Request to open an extension input device.
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+#include "windowstr.h" /* window structure */
+#include "exglobals.h"
+#include "exevents.h"
+
+#include "opendev.h"
+
+extern CARD8 event_base[];
+
+/***********************************************************************
+ *
+ * This procedure swaps the request if the server and client have different
+ * byte orderings.
+ *
+ */
+
+int
+SProcXOpenDevice(ClientPtr client)
+{
+ char n;
+
+ REQUEST(xOpenDeviceReq);
+ swaps(&stuff->length, n);
+ return (ProcXOpenDevice(client));
+}
+
+/***********************************************************************
+ *
+ * This procedure causes the server to open an input device.
+ *
+ */
+
+int
+ProcXOpenDevice(ClientPtr client)
+{
+ xInputClassInfo evbase[numInputClasses];
+ int j = 0;
+ int status = Success;
+ xOpenDeviceReply rep;
+ DeviceIntPtr dev;
+
+ REQUEST(xOpenDeviceReq);
+ REQUEST_SIZE_MATCH(xOpenDeviceReq);
+
+ status = dixLookupDevice(&dev, stuff->deviceid, client, DixUseAccess);
+
+ if (status == BadDevice) { /* not open */
+ for (dev = inputInfo.off_devices; dev; dev = dev->next)
+ if (dev->id == stuff->deviceid)
+ break;
+ if (dev == NULL)
+ return BadDevice;
+ } else if (status != Success)
+ return status;
+
+ if (IsMaster(dev))
+ return BadDevice;
+
+ OpenInputDevice(dev, client, &status);
+ if (status != Success)
+ return status;
+
+ memset(&rep, 0, sizeof(xOpenDeviceReply));
+ rep.repType = X_Reply;
+ rep.RepType = X_OpenDevice;
+ rep.sequenceNumber = client->sequence;
+ if (dev->key != NULL) {
+ evbase[j].class = KeyClass;
+ evbase[j++].event_type_base = event_base[KeyClass];
+ }
+ if (dev->button != NULL) {
+ evbase[j].class = ButtonClass;
+ evbase[j++].event_type_base = event_base[ButtonClass];
+ }
+ if (dev->valuator != NULL) {
+ evbase[j].class = ValuatorClass;
+ evbase[j++].event_type_base = event_base[ValuatorClass];
+ }
+ if (dev->kbdfeed != NULL || dev->ptrfeed != NULL || dev->leds != NULL ||
+ dev->intfeed != NULL || dev->bell != NULL || dev->stringfeed != NULL) {
+ evbase[j].class = FeedbackClass;
+ evbase[j++].event_type_base = event_base[FeedbackClass];
+ }
+ if (dev->focus != NULL) {
+ evbase[j].class = FocusClass;
+ evbase[j++].event_type_base = event_base[FocusClass];
+ }
+ if (dev->proximity != NULL) {
+ evbase[j].class = ProximityClass;
+ evbase[j++].event_type_base = event_base[ProximityClass];
+ }
+ evbase[j].class = OtherClass;
+ evbase[j++].event_type_base = event_base[OtherClass];
+ rep.length = bytes_to_int32(j * sizeof(xInputClassInfo));
+ rep.num_classes = j;
+ WriteReplyToClient(client, sizeof(xOpenDeviceReply), &rep);
+ WriteToClient(client, j * sizeof(xInputClassInfo), (char *)evbase);
+ return Success;
+}
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XOpenDevice function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXOpenDevice(ClientPtr client, int size, xOpenDeviceReply * rep)
+{
+ char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+}
diff --git a/xorg-server/Xi/sendexev.c b/xorg-server/Xi/sendexev.c index bd96d74c7..59fe93db7 100644 --- a/xorg-server/Xi/sendexev.c +++ b/xorg-server/Xi/sendexev.c @@ -1,156 +1,156 @@ -/************************************************************ - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -Copyright 1989 by Hewlett-Packard Company, Palo Alto, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Hewlett-Packard not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -********************************************************/ - -/*********************************************************************** - * - * Request to send an extension event. - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* Window */ -#include "extnsionst.h" /* EventSwapPtr */ -#include <X11/extensions/XI.h> -#include <X11/extensions/XIproto.h> -#include "exevents.h" -#include "exglobals.h" - -#include "grabdev.h" -#include "sendexev.h" - -extern int lastEvent; /* Defined in extension.c */ - -/*********************************************************************** - * - * Handle requests from clients with a different byte order than us. - * - */ - -int -SProcXSendExtensionEvent(ClientPtr client) -{ - char n; - CARD32 *p; - int i; - xEvent eventT; - xEvent *eventP; - EventSwapPtr proc; - - REQUEST(xSendExtensionEventReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq); - swapl(&stuff->destination, n); - swaps(&stuff->count, n); - - if (stuff->length != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count + - bytes_to_int32(stuff->num_events * sizeof(xEvent))) - return BadLength; - - eventP = (xEvent *) & stuff[1]; - for (i = 0; i < stuff->num_events; i++, eventP++) { - proc = EventSwapVector[eventP->u.u.type & 0177]; - if (proc == NotImplemented) /* no swapping proc; invalid event type? */ - return (BadValue); - (*proc) (eventP, &eventT); - *eventP = eventT; - } - - p = (CARD32 *)(((xEvent *) & stuff[1]) + stuff->num_events); - SwapLongs(p, stuff->count); - return (ProcXSendExtensionEvent(client)); -} - -/*********************************************************************** - * - * Send an event to some client, as if it had come from an extension input - * device. - * - */ - -int -ProcXSendExtensionEvent(ClientPtr client) -{ - int ret; - DeviceIntPtr dev; - xEvent *first; - XEventClass *list; - struct tmask tmp[EMASKSIZE]; - - REQUEST(xSendExtensionEventReq); - REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq); - - if (stuff->length != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count + - (stuff->num_events * bytes_to_int32(sizeof(xEvent)))) - return BadLength; - - ret = dixLookupDevice(&dev, stuff->deviceid, client, DixWriteAccess); - if (ret != Success) - return ret; - - /* The client's event type must be one defined by an extension. */ - - first = ((xEvent *) & stuff[1]); - if (!((EXTENSION_EVENT_BASE <= first->u.u.type) && - (first->u.u.type < lastEvent))) { - client->errorValue = first->u.u.type; - return BadValue; - } - - list = (XEventClass *) (first + stuff->num_events); - if ((ret = CreateMaskFromList(client, list, stuff->count, tmp, dev, - X_SendExtensionEvent)) != Success) - return ret; - - ret = (SendEvent(client, dev, stuff->destination, - stuff->propagate, (xEvent *) & stuff[1], - tmp[stuff->deviceid].mask, stuff->num_events)); - - return ret; -} +/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * Request to send an extension event.
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* Window */
+#include "extnsionst.h" /* EventSwapPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "exevents.h"
+#include "exglobals.h"
+
+#include "grabdev.h"
+#include "sendexev.h"
+
+extern int lastEvent; /* Defined in extension.c */
+
+/***********************************************************************
+ *
+ * Handle requests from clients with a different byte order than us.
+ *
+ */
+
+int
+SProcXSendExtensionEvent(ClientPtr client)
+{
+ char n;
+ CARD32 *p;
+ int i;
+ xEvent eventT;
+ xEvent *eventP;
+ EventSwapPtr proc;
+
+ REQUEST(xSendExtensionEventReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
+ swapl(&stuff->destination, n);
+ swaps(&stuff->count, n);
+
+ if (stuff->length != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count +
+ bytes_to_int32(stuff->num_events * sizeof(xEvent)))
+ return BadLength;
+
+ eventP = (xEvent *) & stuff[1];
+ for (i = 0; i < stuff->num_events; i++, eventP++) {
+ proc = EventSwapVector[eventP->u.u.type & 0177];
+ if (proc == NotImplemented) /* no swapping proc; invalid event type? */
+ return BadValue;
+ (*proc) (eventP, &eventT);
+ *eventP = eventT;
+ }
+
+ p = (CARD32 *)(((xEvent *) & stuff[1]) + stuff->num_events);
+ SwapLongs(p, stuff->count);
+ return (ProcXSendExtensionEvent(client));
+}
+
+/***********************************************************************
+ *
+ * Send an event to some client, as if it had come from an extension input
+ * device.
+ *
+ */
+
+int
+ProcXSendExtensionEvent(ClientPtr client)
+{
+ int ret;
+ DeviceIntPtr dev;
+ xEvent *first;
+ XEventClass *list;
+ struct tmask tmp[EMASKSIZE];
+
+ REQUEST(xSendExtensionEventReq);
+ REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
+
+ if (stuff->length != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count +
+ (stuff->num_events * bytes_to_int32(sizeof(xEvent))))
+ return BadLength;
+
+ ret = dixLookupDevice(&dev, stuff->deviceid, client, DixWriteAccess);
+ if (ret != Success)
+ return ret;
+
+ /* The client's event type must be one defined by an extension. */
+
+ first = ((xEvent *) & stuff[1]);
+ if (!((EXTENSION_EVENT_BASE <= first->u.u.type) &&
+ (first->u.u.type < lastEvent))) {
+ client->errorValue = first->u.u.type;
+ return BadValue;
+ }
+
+ list = (XEventClass *) (first + stuff->num_events);
+ if ((ret = CreateMaskFromList(client, list, stuff->count, tmp, dev,
+ X_SendExtensionEvent)) != Success)
+ return ret;
+
+ ret = (SendEvent(client, dev, stuff->destination,
+ stuff->propagate, (xEvent *) & stuff[1],
+ tmp[stuff->deviceid].mask, stuff->num_events));
+
+ return ret;
+}
diff --git a/xorg-server/Xi/stubs.c b/xorg-server/Xi/stubs.c index 6931b26f0..4921b36f9 100644 --- a/xorg-server/Xi/stubs.c +++ b/xorg-server/Xi/stubs.c @@ -207,14 +207,14 @@ ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev, {
switch (control->control) {
case DEVICE_RESOLUTION:
- return (BadMatch);
+ return BadMatch;
case DEVICE_ABS_CALIB:
case DEVICE_ABS_AREA:
- return (BadMatch);
+ return BadMatch;
case DEVICE_CORE:
- return (BadMatch);
+ return BadMatch;
default:
- return (BadMatch);
+ return BadMatch;
}
}
diff --git a/xorg-server/Xi/xichangecursor.c b/xorg-server/Xi/xichangecursor.c index 825f8227a..2d58fa529 100644 --- a/xorg-server/Xi/xichangecursor.c +++ b/xorg-server/Xi/xichangecursor.c @@ -93,7 +93,7 @@ int ProcXIChangeCursor(ClientPtr client) if (stuff->cursor == None)
{
- if (pWin == WindowTable[pWin->drawable.pScreen->myNum])
+ if (pWin == pWin->drawable.pScreen->root)
pCursor = rootCursor;
else
pCursor = (CursorPtr)None;
diff --git a/xorg-server/Xi/xiproperty.c b/xorg-server/Xi/xiproperty.c index 4f8d2430d..11739f9ae 100644 --- a/xorg-server/Xi/xiproperty.c +++ b/xorg-server/Xi/xiproperty.c @@ -177,7 +177,9 @@ static struct dev_properties {0, BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP},
{0, BTN_LABEL_PROP_BTN_GEAR_DOWN},
- {0, BTN_LABEL_PROP_BTN_GEAR_UP}
+ {0, BTN_LABEL_PROP_BTN_GEAR_UP},
+
+ {0, XI_PROP_TRANSFORM}
};
static long XIPropHandlerID = 1;
@@ -252,18 +254,18 @@ get_property(ClientPtr client, DeviceIntPtr dev, Atom property, Atom type, if (!ValidAtom(property))
{
client->errorValue = property;
- return(BadAtom);
+ return BadAtom;
}
if ((delete != xTrue) && (delete != xFalse))
{
client->errorValue = delete;
- return(BadValue);
+ return BadValue;
}
if ((type != AnyPropertyType) && !ValidAtom(type))
{
client->errorValue = type;
- return(BadAtom);
+ return BadAtom;
}
for (prop = dev->properties.properties; prop; prop = prop->next)
@@ -348,12 +350,12 @@ check_change_property(ClientPtr client, Atom property, Atom type, int format, if (!ValidAtom(property))
{
client->errorValue = property;
- return(BadAtom);
+ return BadAtom;
}
if (!ValidAtom(type))
{
client->errorValue = type;
- return(BadAtom);
+ return BadAtom;
}
return Success;
@@ -620,8 +622,7 @@ XIFetchDeviceProperty(DeviceIntPtr dev, Atom property) static void
XIDestroyDeviceProperty (XIPropertyPtr prop)
{
- if (prop->value.data)
- free(prop->value.data);
+ free(prop->value.data);
free(prop);
}
@@ -682,7 +683,7 @@ XIDeleteDeviceProperty (DeviceIntPtr device, Atom property, Bool fromClient) if (handler->DeleteProperty)
rc = handler->DeleteProperty(device, prop->propertyName);
if (rc != Success)
- return (rc);
+ return rc;
handler = handler->next;
}
}
@@ -719,7 +720,7 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type, {
prop = XICreateDeviceProperty (property);
if (!prop)
- return(BadAlloc);
+ return BadAlloc;
add = TRUE;
mode = PropModeReplace;
}
@@ -731,9 +732,9 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type, "PropModeReplace" since they will be written over. */
if ((format != prop_value->format) && (mode != PropModeReplace))
- return(BadMatch);
+ return BadMatch;
if ((prop_value->type != type) && (mode != PropModeReplace))
- return(BadMatch);
+ return BadMatch;
new_value = *prop_value;
if (mode == PropModeReplace)
total_len = len;
@@ -796,9 +797,8 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type, &new_value, checkonly);
if (checkonly && rc != Success)
{
- if (new_value.data)
- free(new_value.data);
- return (rc);
+ free(new_value.data);
+ return rc;
}
}
handler = handler->next;
@@ -806,8 +806,7 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type, checkonly = !checkonly;
} while (!checkonly);
}
- if (prop_value->data)
- free(prop_value->data);
+ free(prop_value->data);
*prop_value = new_value;
} else if (len == 0)
{
@@ -824,7 +823,7 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type, send_property_event(dev, prop->propertyName,
(add) ? XIPropertyCreated : XIPropertyModified);
- return(Success);
+ return Success;
}
int
@@ -957,7 +956,7 @@ ProcXDeleteDeviceProperty (ClientPtr client) if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
- return (BadAtom);
+ return BadAtom;
}
rc = XIDeleteDeviceProperty(dev, stuff->property, TRUE);
@@ -1200,7 +1199,7 @@ ProcXIDeleteProperty(ClientPtr client) if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
- return (BadAtom);
+ return BadAtom;
}
rc = XIDeleteDeviceProperty(dev, stuff->property, TRUE);
diff --git a/xorg-server/Xi/xiquerypointer.c b/xorg-server/Xi/xiquerypointer.c index a5855bef3..0c6079d23 100644 --- a/xorg-server/Xi/xiquerypointer.c +++ b/xorg-server/Xi/xiquerypointer.c @@ -43,6 +43,7 @@ #include "exevents.h"
#include "exglobals.h"
#include "eventconvert.h"
+#include "scrnintstr.h"
#include "xkbsrv.h"
#ifdef PANORAMIX
@@ -181,12 +182,12 @@ ProcXIQueryPointer(ClientPtr client) #ifdef PANORAMIX
if(!noPanoramiXExtension) {
- rep.root_x += FP1616(panoramiXdataPtr[0].x, 0);
- rep.root_y += FP1616(panoramiXdataPtr[0].y, 0);
+ rep.root_x += FP1616(screenInfo.screens[0]->x, 0);
+ rep.root_y += FP1616(screenInfo.screens[0]->y, 0);
if (stuff->win == rep.root)
{
- rep.win_x += FP1616(panoramiXdataPtr[0].x, 0);
- rep.win_y += FP1616(panoramiXdataPtr[0].y, 0);
+ rep.win_x += FP1616(screenInfo.screens[0]->x, 0);
+ rep.win_y += FP1616(screenInfo.screens[0]->y, 0);
}
}
#endif
diff --git a/xorg-server/composite/compalloc.c b/xorg-server/composite/compalloc.c index c2c8a0687..c578fe45c 100644 --- a/xorg-server/composite/compalloc.c +++ b/xorg-server/composite/compalloc.c @@ -134,7 +134,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update) EnableMapUnmapEvents (pWin);
}
- REGION_NULL (pScreen, &cw->borderClip);
+ RegionNull(&cw->borderClip);
cw->borderClipX = 0;
cw->borderClipY = 0;
cw->update = CompositeRedirectAutomatic;
@@ -143,6 +143,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update) cw->oldy = COMP_ORIGIN_INVALID;
cw->damageRegistered = FALSE;
cw->damaged = FALSE;
+ cw->pOldPixmap = NullPixmap;
dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, cw);
}
ccw->next = cw->clients;
@@ -226,7 +227,7 @@ compFreeClientWindow (WindowPtr pWin, XID id) if (cw->damage)
DamageDestroy (cw->damage);
- REGION_UNINIT (pScreen, &cw->borderClip);
+ RegionUninit(&cw->borderClip);
dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, NULL);
free(cw);
@@ -598,7 +599,7 @@ compFreePixmap (WindowPtr pWin) * case correctly. Unmap adds the window borderClip to the
* parent exposed area; regions beyond the parent cause crashes
*/
- REGION_COPY (pScreen, &pWin->borderClip, &cw->borderClip);
+ RegionCopy(&pWin->borderClip, &cw->borderClip);
pRedirectPixmap = (*pScreen->GetWindowPixmap) (pWin);
pParentPixmap = (*pScreen->GetWindowPixmap) (pWin->parent);
pWin->redirectDraw = RedirectDrawNone;
diff --git a/xorg-server/composite/compext.c b/xorg-server/composite/compext.c index 5e557dd0b..a87b37ca8 100644 --- a/xorg-server/composite/compext.c +++ b/xorg-server/composite/compext.c @@ -50,8 +50,8 @@ #include "protocol-versions.h"
static CARD8 CompositeReqCode;
-static int CompositeClientPrivateKeyIndex;
-static DevPrivateKey CompositeClientPrivateKey = &CompositeClientPrivateKeyIndex;
+static DevPrivateKeyRec CompositeClientPrivateKeyRec;
+#define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec)
RESTYPE CompositeClientWindowType;
RESTYPE CompositeClientSubwindowsType;
RESTYPE CompositeClientOverlayType;
@@ -218,7 +218,7 @@ ProcCompositeCreateRegionFromBorderClip (ClientPtr client) pRegion = XFixesRegionCopy (pBorderClip);
if (!pRegion)
return BadAlloc;
- REGION_TRANSLATE (pScreen, pRegion, -pWin->drawable.x, -pWin->drawable.y);
+ RegionTranslate(pRegion, -pWin->drawable.x, -pWin->drawable.y);
if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
@@ -558,8 +558,8 @@ CompositeExtensionInit (void) if (!CompositeClientOverlayType)
return;
- if (!dixRequestPrivate(CompositeClientPrivateKey,
- sizeof(CompositeClientRec)))
+ if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec, PRIVATE_CLIENT,
+ sizeof(CompositeClientRec)))
return;
if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0))
diff --git a/xorg-server/composite/compinit.c b/xorg-server/composite/compinit.c index 9a99ce633..389cf0bfb 100644 --- a/xorg-server/composite/compinit.c +++ b/xorg-server/composite/compinit.c @@ -48,13 +48,9 @@ #include "compint.h"
#include "compositeext.h"
-static int CompScreenPrivateKeyIndex;
-DevPrivateKey CompScreenPrivateKey = &CompScreenPrivateKeyIndex;
-static int CompWindowPrivateKeyIndex;
-DevPrivateKey CompWindowPrivateKey = &CompWindowPrivateKeyIndex;
-static int CompSubwindowsPrivateKeyIndex;
-DevPrivateKey CompSubwindowsPrivateKey = &CompSubwindowsPrivateKeyIndex;
-
+DevPrivateKeyRec CompScreenPrivateKeyRec;
+DevPrivateKeyRec CompWindowPrivateKeyRec;
+DevPrivateKeyRec CompSubwindowsPrivateKeyRec;
static Bool
compCloseScreen (int index, ScreenPtr pScreen)
@@ -69,9 +65,7 @@ compCloseScreen (int index, ScreenPtr pScreen) pScreen->InstallColormap = cs->InstallColormap;
pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes;
pScreen->ReparentWindow = cs->ReparentWindow;
- pScreen->MoveWindow = cs->MoveWindow;
- pScreen->ResizeWindow = cs->ResizeWindow;
- pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
+ pScreen->ConfigNotify = cs->ConfigNotify;
pScreen->ClipNotify = cs->ClipNotify;
pScreen->UnrealizeWindow = cs->UnrealizeWindow;
@@ -141,7 +135,7 @@ compScreenUpdate (ScreenPtr pScreen) compCheckTree (pScreen);
if (cs->damaged)
{
- compWindowUpdate (WindowTable[pScreen->myNum]);
+ compWindowUpdate (pScreen->root);
cs->damaged = FALSE;
}
}
@@ -321,6 +315,13 @@ compScreenInit (ScreenPtr pScreen) {
CompScreenPtr cs;
+ if (!dixRegisterPrivateKey(&CompScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&CompWindowPrivateKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&CompSubwindowsPrivateKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
if (GetCompScreen (pScreen))
return TRUE;
cs = (CompScreenPtr) malloc(sizeof (CompScreenRec));
@@ -362,14 +363,8 @@ compScreenInit (ScreenPtr pScreen) cs->ClipNotify = pScreen->ClipNotify;
pScreen->ClipNotify = compClipNotify;
- cs->MoveWindow = pScreen->MoveWindow;
- pScreen->MoveWindow = compMoveWindow;
-
- cs->ResizeWindow = pScreen->ResizeWindow;
- pScreen->ResizeWindow = compResizeWindow;
-
- cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
- pScreen->ChangeBorderWidth = compChangeBorderWidth;
+ cs->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = compConfigNotify;
cs->ReparentWindow = pScreen->ReparentWindow;
pScreen->ReparentWindow = compReparentWindow;
diff --git a/xorg-server/composite/compint.h b/xorg-server/composite/compint.h index 845a196f6..e02d22c6b 100644 --- a/xorg-server/composite/compint.h +++ b/xorg-server/composite/compint.h @@ -1,319 +1,314 @@ -/* - * Copyright © 2006 Sun Microsystems, 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 (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Copyright © 2003 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef _COMPINT_H_ -#define _COMPINT_H_ - -#include "misc.h" -#include "scrnintstr.h" -#include "os.h" -#include "regionstr.h" -#include "validate.h" -#include "windowstr.h" -#include "input.h" -#include "resource.h" -#include "colormapst.h" -#include "cursorstr.h" -#include "dixstruct.h" -#include "gcstruct.h" -#include "servermd.h" -#include "dixevents.h" -#include "globals.h" -#include "picturestr.h" -#include "extnsionst.h" -#include "privates.h" -#include "mi.h" -#include "damage.h" -#include "damageextint.h" -#include "xfixes.h" -#include <X11/extensions/compositeproto.h> -#include <assert.h> - -/* - * enable this for debugging - - #define COMPOSITE_DEBUG - */ - -typedef struct _CompClientWindow { - struct _CompClientWindow *next; - XID id; - int update; -} CompClientWindowRec, *CompClientWindowPtr; - -typedef struct _CompWindow { - RegionRec borderClip; - DamagePtr damage; /* for automatic update mode */ - Bool damageRegistered; - Bool damaged; - int update; - CompClientWindowPtr clients; - int oldx; - int oldy; - PixmapPtr pOldPixmap; - int borderClipX, borderClipY; -} CompWindowRec, *CompWindowPtr; - -#define COMP_ORIGIN_INVALID 0x80000000 - -typedef struct _CompSubwindows { - int update; - CompClientWindowPtr clients; -} CompSubwindowsRec, *CompSubwindowsPtr; - -#ifndef COMP_INCLUDE_RGB24_VISUAL -#define COMP_INCLUDE_RGB24_VISUAL 0 -#endif - -typedef struct _CompOverlayClientRec *CompOverlayClientPtr; - -typedef struct _CompOverlayClientRec { - CompOverlayClientPtr pNext; - ClientPtr pClient; - ScreenPtr pScreen; - XID resource; -} CompOverlayClientRec; - -typedef struct _CompScreen { - PositionWindowProcPtr PositionWindow; - CopyWindowProcPtr CopyWindow; - CreateWindowProcPtr CreateWindow; - DestroyWindowProcPtr DestroyWindow; - RealizeWindowProcPtr RealizeWindow; - UnrealizeWindowProcPtr UnrealizeWindow; - ClipNotifyProcPtr ClipNotify; - /* - * Called from ConfigureWindow, these - * three track changes to the offscreen storage - * geometry - */ - MoveWindowProcPtr MoveWindow; - ResizeWindowProcPtr ResizeWindow; - ChangeBorderWidthProcPtr ChangeBorderWidth; - /* - * Reparenting has an effect on Subwindows redirect - */ - ReparentWindowProcPtr ReparentWindow; - - /* - * Colormaps for new visuals better not get installed - */ - InstallColormapProcPtr InstallColormap; - - /* - * Fake backing store via automatic redirection - */ - ChangeWindowAttributesProcPtr ChangeWindowAttributes; - - ScreenBlockHandlerProcPtr BlockHandler; - CloseScreenProcPtr CloseScreen; - Bool damaged; - int numAlternateVisuals; - VisualID *alternateVisuals; - - WindowPtr pOverlayWin; - Window overlayWid; - CompOverlayClientPtr pOverlayClients; - -} CompScreenRec, *CompScreenPtr; - -extern DevPrivateKey CompScreenPrivateKey; -extern DevPrivateKey CompWindowPrivateKey; -extern DevPrivateKey CompSubwindowsPrivateKey; - -#define GetCompScreen(s) ((CompScreenPtr) \ - dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey)) -#define GetCompWindow(w) ((CompWindowPtr) \ - dixLookupPrivate(&(w)->devPrivates, CompWindowPrivateKey)) -#define GetCompSubwindows(w) ((CompSubwindowsPtr) \ - dixLookupPrivate(&(w)->devPrivates, CompSubwindowsPrivateKey)) - -extern RESTYPE CompositeClientWindowType; -extern RESTYPE CompositeClientSubwindowsType; -extern RESTYPE CompositeClientOverlayType; - -/* - * compalloc.c - */ - -Bool -compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update); - -void -compFreeClientWindow (WindowPtr pWin, XID id); - -int -compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update); - -int -compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update); - -void -compFreeClientSubwindows (WindowPtr pWin, XID id); - -int -compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update); - -int -compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin); - -int -compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin); - -Bool -compAllocPixmap (WindowPtr pWin); - -void -compFreePixmap (WindowPtr pWin); - -Bool -compReallocPixmap (WindowPtr pWin, int x, int y, - unsigned int w, unsigned int h, int bw); - -/* - * compext.c - */ - -void -CompositeExtensionInit (void); - -/* - * compinit.c - */ - -Bool -compScreenInit (ScreenPtr pScreen); - -/* - * compoverlay.c - */ - -void -compFreeOverlayClient (CompOverlayClientPtr pOcToDel); - -CompOverlayClientPtr -compFindOverlayClient (ScreenPtr pScreen, ClientPtr pClient); - -CompOverlayClientPtr -compCreateOverlayClient (ScreenPtr pScreen, ClientPtr pClient); - -Bool -compCreateOverlayWindow (ScreenPtr pScreen); - -void -compDestroyOverlayWindow (ScreenPtr pScreen); - -/* - * compwindow.c - */ - -#ifdef COMPOSITE_DEBUG -void -compCheckTree (ScreenPtr pScreen); -#else -#define compCheckTree(s) -#endif - -PictFormatPtr -compWindowFormat (WindowPtr pWin); - -void -compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap); - -Bool -compCheckRedirect (WindowPtr pWin); - -Bool -compPositionWindow (WindowPtr pWin, int x, int y); - -Bool -compRealizeWindow (WindowPtr pWin); - -Bool -compUnrealizeWindow (WindowPtr pWin); - -void -compClipNotify (WindowPtr pWin, int dx, int dy); - -void -compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind); - -void -compResizeWindow (WindowPtr pWin, int x, int y, - unsigned int w, unsigned int h, WindowPtr pSib); - -void -compChangeBorderWidth (WindowPtr pWin, unsigned int border_width); - -void -compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent); - -Bool -compCreateWindow (WindowPtr pWin); - -Bool -compDestroyWindow (WindowPtr pWin); - -void -compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion); - -RegionPtr -compGetRedirectBorderClip (WindowPtr pWin); - -void -compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc); - -void -compWindowUpdate (WindowPtr pWin); - -WindowPtr -CompositeRealChildHead (WindowPtr pWin); - -int -DeleteWindowNoInputDevices(pointer value, XID wid); - -#endif /* _COMPINT_H_ */ +/*
+ * Copyright © 2006 Sun Microsystems, 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 (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _COMPINT_H_
+#define _COMPINT_H_
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "dixevents.h"
+#include "globals.h"
+#include "picturestr.h"
+#include "extnsionst.h"
+#include "privates.h"
+#include "mi.h"
+#include "damage.h"
+#include "damageextint.h"
+#include "xfixes.h"
+#include <X11/extensions/compositeproto.h>
+#include <assert.h>
+
+/*
+ * enable this for debugging
+
+ #define COMPOSITE_DEBUG
+ */
+
+typedef struct _CompClientWindow {
+ struct _CompClientWindow *next;
+ XID id;
+ int update;
+} CompClientWindowRec, *CompClientWindowPtr;
+
+typedef struct _CompWindow {
+ RegionRec borderClip;
+ DamagePtr damage; /* for automatic update mode */
+ Bool damageRegistered;
+ Bool damaged;
+ int update;
+ CompClientWindowPtr clients;
+ int oldx;
+ int oldy;
+ PixmapPtr pOldPixmap;
+ int borderClipX, borderClipY;
+} CompWindowRec, *CompWindowPtr;
+
+#define COMP_ORIGIN_INVALID 0x80000000
+
+typedef struct _CompSubwindows {
+ int update;
+ CompClientWindowPtr clients;
+} CompSubwindowsRec, *CompSubwindowsPtr;
+
+#ifndef COMP_INCLUDE_RGB24_VISUAL
+#define COMP_INCLUDE_RGB24_VISUAL 0
+#endif
+
+typedef struct _CompOverlayClientRec *CompOverlayClientPtr;
+
+typedef struct _CompOverlayClientRec {
+ CompOverlayClientPtr pNext;
+ ClientPtr pClient;
+ ScreenPtr pScreen;
+ XID resource;
+} CompOverlayClientRec;
+
+typedef struct _CompScreen {
+ PositionWindowProcPtr PositionWindow;
+ CopyWindowProcPtr CopyWindow;
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ ClipNotifyProcPtr ClipNotify;
+ /*
+ * Called from ConfigureWindow.
+ */
+ ConfigNotifyProcPtr ConfigNotify;
+ /*
+ * Reparenting has an effect on Subwindows redirect
+ */
+ ReparentWindowProcPtr ReparentWindow;
+
+ /*
+ * Colormaps for new visuals better not get installed
+ */
+ InstallColormapProcPtr InstallColormap;
+
+ /*
+ * Fake backing store via automatic redirection
+ */
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+
+ ScreenBlockHandlerProcPtr BlockHandler;
+ CloseScreenProcPtr CloseScreen;
+ Bool damaged;
+ int numAlternateVisuals;
+ VisualID *alternateVisuals;
+
+ WindowPtr pOverlayWin;
+ Window overlayWid;
+ CompOverlayClientPtr pOverlayClients;
+
+} CompScreenRec, *CompScreenPtr;
+
+extern DevPrivateKeyRec CompScreenPrivateKeyRec;
+#define CompScreenPrivateKey (&CompScreenPrivateKeyRec)
+
+extern DevPrivateKeyRec CompWindowPrivateKeyRec;
+#define CompWindowPrivateKey (&CompWindowPrivateKeyRec)
+
+extern DevPrivateKeyRec CompSubwindowsPrivateKeyRec;
+#define CompSubwindowsPrivateKey (&CompSubwindowsPrivateKeyRec)
+
+#define GetCompScreen(s) ((CompScreenPtr) \
+ dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey))
+#define GetCompWindow(w) ((CompWindowPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompWindowPrivateKey))
+#define GetCompSubwindows(w) ((CompSubwindowsPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompSubwindowsPrivateKey))
+
+extern RESTYPE CompositeClientWindowType;
+extern RESTYPE CompositeClientSubwindowsType;
+extern RESTYPE CompositeClientOverlayType;
+
+/*
+ * compalloc.c
+ */
+
+Bool
+compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
+
+void
+compFreeClientWindow (WindowPtr pWin, XID id);
+
+int
+compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
+
+int
+compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
+
+void
+compFreeClientSubwindows (WindowPtr pWin, XID id);
+
+int
+compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
+
+int
+compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
+
+int
+compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
+
+Bool
+compAllocPixmap (WindowPtr pWin);
+
+void
+compFreePixmap (WindowPtr pWin);
+
+Bool
+compReallocPixmap (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, int bw);
+
+/*
+ * compext.c
+ */
+
+void
+CompositeExtensionInit (void);
+
+/*
+ * compinit.c
+ */
+
+Bool
+compScreenInit (ScreenPtr pScreen);
+
+/*
+ * compoverlay.c
+ */
+
+void
+compFreeOverlayClient (CompOverlayClientPtr pOcToDel);
+
+CompOverlayClientPtr
+compFindOverlayClient (ScreenPtr pScreen, ClientPtr pClient);
+
+CompOverlayClientPtr
+compCreateOverlayClient (ScreenPtr pScreen, ClientPtr pClient);
+
+Bool
+compCreateOverlayWindow (ScreenPtr pScreen);
+
+void
+compDestroyOverlayWindow (ScreenPtr pScreen);
+
+/*
+ * compwindow.c
+ */
+
+#ifdef COMPOSITE_DEBUG
+void
+compCheckTree (ScreenPtr pScreen);
+#else
+#define compCheckTree(s)
+#endif
+
+PictFormatPtr
+compWindowFormat (WindowPtr pWin);
+
+void
+compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap);
+
+Bool
+compCheckRedirect (WindowPtr pWin);
+
+Bool
+compPositionWindow (WindowPtr pWin, int x, int y);
+
+Bool
+compRealizeWindow (WindowPtr pWin);
+
+Bool
+compUnrealizeWindow (WindowPtr pWin);
+
+void
+compClipNotify (WindowPtr pWin, int dx, int dy);
+
+void
+compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent);
+
+Bool
+compCreateWindow (WindowPtr pWin);
+
+Bool
+compDestroyWindow (WindowPtr pWin);
+
+void
+compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion);
+
+RegionPtr
+compGetRedirectBorderClip (WindowPtr pWin);
+
+void
+compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
+void
+compWindowUpdate (WindowPtr pWin);
+
+WindowPtr
+CompositeRealChildHead (WindowPtr pWin);
+
+int
+DeleteWindowNoInputDevices(pointer value, XID wid);
+
+int
+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
+ int bw, WindowPtr pSib);
+
+#endif /* _COMPINT_H_ */
diff --git a/xorg-server/composite/compoverlay.c b/xorg-server/composite/compoverlay.c index 5846c34c5..e43c529e6 100644 --- a/xorg-server/composite/compoverlay.c +++ b/xorg-server/composite/compoverlay.c @@ -128,7 +128,7 @@ Bool compCreateOverlayWindow (ScreenPtr pScreen)
{
CompScreenPtr cs = GetCompScreen(pScreen);
- WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
WindowPtr pWin;
XID attrs[] = { None, TRUE }; /* backPixmap, overrideRedirect */
int result;
diff --git a/xorg-server/composite/compwindow.c b/xorg-server/composite/compwindow.c index f2f6ea3cd..82f9b4cfd 100644 --- a/xorg-server/composite/compwindow.c +++ b/xorg-server/composite/compwindow.c @@ -1,824 +1,743 @@ -/* - * Copyright © 2006 Sun Microsystems, 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 (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Copyright © 2003 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "compint.h" - -#ifdef COMPOSITE_DEBUG -static int -compCheckWindow (WindowPtr pWin, pointer data) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - PixmapPtr pWinPixmap = (*pScreen->GetWindowPixmap) (pWin); - PixmapPtr pParentPixmap = pWin->parent ? (*pScreen->GetWindowPixmap) (pWin->parent) : 0; - PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen); - - if (!pWin->parent) - { - assert (pWin->redirectDraw == RedirectDrawNone); - assert (pWinPixmap == pScreenPixmap); - } - else if (pWin->redirectDraw != RedirectDrawNone) - { - assert (pWinPixmap != pParentPixmap); - assert (pWinPixmap != pScreenPixmap); - } - else - { - assert (pWinPixmap == pParentPixmap); - } - assert (0 < pWinPixmap->refcnt && pWinPixmap->refcnt < 3); - assert (0 < pScreenPixmap->refcnt && pScreenPixmap->refcnt < 3); - if (pParentPixmap) - assert (0 <= pParentPixmap->refcnt && pParentPixmap->refcnt < 3); - return WT_WALKCHILDREN; -} - -void -compCheckTree (ScreenPtr pScreen) -{ - WalkTree (pScreen, compCheckWindow, 0); -} -#endif - -typedef struct _compPixmapVisit { - WindowPtr pWindow; - PixmapPtr pPixmap; -} CompPixmapVisitRec, *CompPixmapVisitPtr; - -static Bool -compRepaintBorder (ClientPtr pClient, pointer closure) -{ - WindowPtr pWindow; - int rc = dixLookupWindow(&pWindow, (XID)(intptr_t)closure, pClient, DixWriteAccess); - - if (rc == Success) { - RegionRec exposed; - - REGION_NULL(pScreen, &exposed); - REGION_SUBTRACT(pScreen, &exposed, &pWindow->borderClip, &pWindow->winSize); - miPaintWindow(pWindow, &exposed, PW_BORDER); - REGION_UNINIT(pScreen, &exposed); - } - return TRUE; -} - -static int -compSetPixmapVisitWindow (WindowPtr pWindow, pointer data) -{ - CompPixmapVisitPtr pVisit = (CompPixmapVisitPtr) data; - ScreenPtr pScreen = pWindow->drawable.pScreen; - - if (pWindow != pVisit->pWindow && pWindow->redirectDraw != RedirectDrawNone) - return WT_DONTWALKCHILDREN; - (*pScreen->SetWindowPixmap) (pWindow, pVisit->pPixmap); - /* - * Recompute winSize and borderSize. This is duplicate effort - * when resizing pixmaps, but necessary when changing redirection. - * Might be nice to fix this. - */ - SetWinSize (pWindow); - SetBorderSize (pWindow); - if (HasBorder (pWindow)) - QueueWorkProc (compRepaintBorder, serverClient, - (pointer)(intptr_t) pWindow->drawable.id); - return WT_WALKCHILDREN; -} - -void -compSetPixmap (WindowPtr pWindow, PixmapPtr pPixmap) -{ - CompPixmapVisitRec visitRec; - - visitRec.pWindow = pWindow; - visitRec.pPixmap = pPixmap; - TraverseTree (pWindow, compSetPixmapVisitWindow, (pointer) &visitRec); - compCheckTree (pWindow->drawable.pScreen); -} - -Bool -compCheckRedirect (WindowPtr pWin) -{ - CompWindowPtr cw = GetCompWindow (pWin); - CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen); - Bool should; - - should = pWin->realized && (pWin->drawable.class != InputOnly) && - (cw != NULL) && (pWin->parent != NULL); - - /* Never redirect the overlay window */ - if (cs->pOverlayWin != NULL) { - if (pWin == cs->pOverlayWin) { - should = FALSE; - } - } - - if (should != (pWin->redirectDraw != RedirectDrawNone)) - { - if (should) - return compAllocPixmap (pWin); - else - compFreePixmap (pWin); - } - return TRUE; -} - -static int -updateOverlayWindow(ScreenPtr pScreen) -{ - CompScreenPtr cs; - WindowPtr pWin; /* overlay window */ - XID vlist[2]; - - cs = GetCompScreen(pScreen); - if ((pWin = cs->pOverlayWin) != NULL) { - if ((pWin->drawable.width == pScreen->width) && - (pWin->drawable.height == pScreen->height)) - return Success; - - /* Let's resize the overlay window. */ - vlist[0] = pScreen->width; - vlist[1] = pScreen->height; - return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin)); - } - - /* Let's be on the safe side and not assume an overlay window is always allocated. */ - return Success; -} - -Bool -compPositionWindow (WindowPtr pWin, int x, int y) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - CompScreenPtr cs = GetCompScreen (pScreen); - Bool ret = TRUE; - - pScreen->PositionWindow = cs->PositionWindow; - /* - * "Shouldn't need this as all possible places should be wrapped - * - compCheckRedirect (pWin); - */ -#ifdef COMPOSITE_DEBUG - if ((pWin->redirectDraw != RedirectDrawNone) != - (pWin->viewable && (GetCompWindow(pWin) != NULL))) - OsAbort (); -#endif - if (pWin->redirectDraw != RedirectDrawNone) - { - PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin); - int bw = wBorderWidth (pWin); - int nx = pWin->drawable.x - bw; - int ny = pWin->drawable.y - bw; - - if (pPixmap->screen_x != nx || pPixmap->screen_y != ny) - { - pPixmap->screen_x = nx; - pPixmap->screen_y = ny; - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - } - } - - if (!(*pScreen->PositionWindow) (pWin, x, y)) - ret = FALSE; - cs->PositionWindow = pScreen->PositionWindow; - pScreen->PositionWindow = compPositionWindow; - compCheckTree (pWin->drawable.pScreen); - if (updateOverlayWindow(pScreen) != Success) - ret = FALSE; - return ret; -} - -Bool -compRealizeWindow (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - CompScreenPtr cs = GetCompScreen (pScreen); - Bool ret = TRUE; - - pScreen->RealizeWindow = cs->RealizeWindow; - compCheckRedirect (pWin); - if (!(*pScreen->RealizeWindow) (pWin)) - ret = FALSE; - cs->RealizeWindow = pScreen->RealizeWindow; - pScreen->RealizeWindow = compRealizeWindow; - compCheckTree (pWin->drawable.pScreen); - return ret; -} - -Bool -compUnrealizeWindow (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - CompScreenPtr cs = GetCompScreen (pScreen); - Bool ret = TRUE; - - pScreen->UnrealizeWindow = cs->UnrealizeWindow; - compCheckRedirect (pWin); - if (!(*pScreen->UnrealizeWindow) (pWin)) - ret = FALSE; - cs->UnrealizeWindow = pScreen->UnrealizeWindow; - pScreen->UnrealizeWindow = compUnrealizeWindow; - compCheckTree (pWin->drawable.pScreen); - return ret; -} - -/* - * Called after the borderClip for the window has settled down - * We use this to make sure our extra borderClip has the right origin - */ - -void -compClipNotify (WindowPtr pWin, int dx, int dy) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - CompScreenPtr cs = GetCompScreen (pScreen); - CompWindowPtr cw = GetCompWindow (pWin); - - if (cw) - { - if (cw->borderClipX != pWin->drawable.x || - cw->borderClipY != pWin->drawable.y) - { - REGION_TRANSLATE (pScreen, &cw->borderClip, - pWin->drawable.x - cw->borderClipX, - pWin->drawable.y - cw->borderClipY); - cw->borderClipX = pWin->drawable.x; - cw->borderClipY = pWin->drawable.y; - } - } - if (cs->ClipNotify) - { - pScreen->ClipNotify = cs->ClipNotify; - (*pScreen->ClipNotify) (pWin, dx, dy); - cs->ClipNotify = pScreen->ClipNotify; - pScreen->ClipNotify = compClipNotify; - } -} - -/* - * Returns TRUE if the window needs server-provided automatic redirect, - * which is true if the child and parent aren't both regular or ARGB visuals - */ - -static Bool -compIsAlternateVisual (ScreenPtr pScreen, - XID visual) -{ - CompScreenPtr cs = GetCompScreen (pScreen); - int i; - - for (i = 0; i < cs->numAlternateVisuals; i++) - if (cs->alternateVisuals[i] == visual) - return TRUE; - return FALSE; -} - -static Bool -compImplicitRedirect (WindowPtr pWin, WindowPtr pParent) -{ - if (pParent) - { - ScreenPtr pScreen = pWin->drawable.pScreen; - XID winVisual = wVisual (pWin); - XID parentVisual = wVisual (pParent); - - if (winVisual != parentVisual && - (compIsAlternateVisual (pScreen, winVisual) || - compIsAlternateVisual (pScreen, parentVisual))) - return TRUE; - } - return FALSE; -} - -void -compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - CompScreenPtr cs = GetCompScreen (pScreen); - - compCheckTree (pScreen); - if (pWin->redirectDraw != RedirectDrawNone) - { - WindowPtr pParent; - int draw_x, draw_y; - unsigned int w, h, bw; - - /* if this is a root window, can't be moved */ - if (!(pParent = pWin->parent)) - return; - - bw = wBorderWidth (pWin); - draw_x = pParent->drawable.x + x + (int)bw; - draw_y = pParent->drawable.y + y + (int)bw; - w = pWin->drawable.width; - h = pWin->drawable.height; - compReallocPixmap (pWin, draw_x, draw_y, w, h, bw); - } - compCheckTree (pScreen); - - pScreen->MoveWindow = cs->MoveWindow; - (*pScreen->MoveWindow) (pWin, x, y, pSib, kind); - cs->MoveWindow = pScreen->MoveWindow; - pScreen->MoveWindow = compMoveWindow; - - if (pWin->redirectDraw != RedirectDrawNone) - { - CompWindowPtr cw = GetCompWindow (pWin); - if (cw->pOldPixmap) - { - (*pScreen->DestroyPixmap) (cw->pOldPixmap); - cw->pOldPixmap = NullPixmap; - } - } - - compCheckTree (pScreen); -} - -void -compResizeWindow (WindowPtr pWin, int x, int y, - unsigned int w, unsigned int h, WindowPtr pSib) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - CompScreenPtr cs = GetCompScreen (pScreen); - - compCheckTree (pScreen); - if (pWin->redirectDraw != RedirectDrawNone) - { - WindowPtr pParent; - int draw_x, draw_y; - unsigned int bw; - - /* if this is a root window, can't be moved */ - if (!(pParent = pWin->parent)) - return; - - bw = wBorderWidth (pWin); - draw_x = pParent->drawable.x + x + (int)bw; - draw_y = pParent->drawable.y + y + (int)bw; - compReallocPixmap (pWin, draw_x, draw_y, w, h, bw); - } - compCheckTree (pScreen); - - pScreen->ResizeWindow = cs->ResizeWindow; - (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib); - cs->ResizeWindow = pScreen->ResizeWindow; - pScreen->ResizeWindow = compResizeWindow; - if (pWin->redirectDraw != RedirectDrawNone) - { - CompWindowPtr cw = GetCompWindow (pWin); - if (cw->pOldPixmap) - { - (*pScreen->DestroyPixmap) (cw->pOldPixmap); - cw->pOldPixmap = NullPixmap; - } - } - compCheckTree (pWin->drawable.pScreen); -} - -void -compChangeBorderWidth (WindowPtr pWin, unsigned int bw) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - CompScreenPtr cs = GetCompScreen (pScreen); - - compCheckTree (pScreen); - if (pWin->redirectDraw != RedirectDrawNone) - { - WindowPtr pParent; - int draw_x, draw_y; - unsigned int w, h; - - /* if this is a root window, can't be moved */ - if (!(pParent = pWin->parent)) - return; - - draw_x = pWin->drawable.x; - draw_y = pWin->drawable.y; - w = pWin->drawable.width; - h = pWin->drawable.height; - compReallocPixmap (pWin, draw_x, draw_y, w, h, bw); - } - compCheckTree (pScreen); - - pScreen->ChangeBorderWidth = cs->ChangeBorderWidth; - (*pScreen->ChangeBorderWidth) (pWin, bw); - cs->ChangeBorderWidth = pScreen->ChangeBorderWidth; - pScreen->ChangeBorderWidth = compChangeBorderWidth; - if (pWin->redirectDraw != RedirectDrawNone) - { - CompWindowPtr cw = GetCompWindow (pWin); - if (cw->pOldPixmap) - { - (*pScreen->DestroyPixmap) (cw->pOldPixmap); - cw->pOldPixmap = NullPixmap; - } - } - compCheckTree (pWin->drawable.pScreen); -} - -void -compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - CompScreenPtr cs = GetCompScreen (pScreen); - - pScreen->ReparentWindow = cs->ReparentWindow; - /* - * Remove any implicit redirect due to synthesized visual - */ - if (compImplicitRedirect (pWin, pPriorParent)) - compUnredirectWindow (serverClient, pWin, CompositeRedirectAutomatic); - /* - * Handle subwindows redirection - */ - compUnredirectOneSubwindow (pPriorParent, pWin); - compRedirectOneSubwindow (pWin->parent, pWin); - /* - * Add any implict redirect due to synthesized visual - */ - if (compImplicitRedirect (pWin, pWin->parent)) - compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic); - - /* - * Allocate any necessary redirect pixmap - * (this actually should never be true; pWin is always unmapped) - */ - compCheckRedirect (pWin); - - /* - * Reset pixmap pointers as appropriate - */ - if (pWin->parent && pWin->redirectDraw == RedirectDrawNone) - compSetPixmap (pWin, (*pScreen->GetWindowPixmap) (pWin->parent)); - /* - * Call down to next function - */ - if (pScreen->ReparentWindow) - (*pScreen->ReparentWindow) (pWin, pPriorParent); - cs->ReparentWindow = pScreen->ReparentWindow; - pScreen->ReparentWindow = compReparentWindow; - compCheckTree (pWin->drawable.pScreen); -} - -void -compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - CompScreenPtr cs = GetCompScreen (pScreen); - int dx = 0, dy = 0; - - if (pWin->redirectDraw != RedirectDrawNone) - { - PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin); - CompWindowPtr cw = GetCompWindow (pWin); - - assert (cw->oldx != COMP_ORIGIN_INVALID); - assert (cw->oldy != COMP_ORIGIN_INVALID); - if (cw->pOldPixmap) - { - /* - * Ok, the old bits are available in pOldPixmap and - * need to be copied to pNewPixmap. - */ - RegionRec rgnDst; - PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin); - GCPtr pGC; - - dx = ptOldOrg.x - pWin->drawable.x; - dy = ptOldOrg.y - pWin->drawable.y; - REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy); - - REGION_NULL (pWin->drawable.pScreen, &rgnDst); - - REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, - &pWin->borderClip, prgnSrc); - - REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst, - -pPixmap->screen_x, -pPixmap->screen_y); - - dx = dx + pPixmap->screen_x - cw->oldx; - dy = dy + pPixmap->screen_y - cw->oldy; - pGC = GetScratchGC (pPixmap->drawable.depth, pScreen); - if (pGC) - { - BoxPtr pBox = REGION_RECTS (&rgnDst); - int nBox = REGION_NUM_RECTS (&rgnDst); - - ValidateGC(&pPixmap->drawable, pGC); - while (nBox--) - { - (void) (*pGC->ops->CopyArea) (&cw->pOldPixmap->drawable, - &pPixmap->drawable, - pGC, - pBox->x1 + dx, pBox->y1 + dy, - pBox->x2 - pBox->x1, - pBox->y2 - pBox->y1, - pBox->x1, pBox->y1); - pBox++; - } - FreeScratchGC (pGC); - } - return; - } - dx = pPixmap->screen_x - cw->oldx; - dy = pPixmap->screen_y - cw->oldy; - ptOldOrg.x += dx; - ptOldOrg.y += dy; - } - - pScreen->CopyWindow = cs->CopyWindow; - if (ptOldOrg.x != pWin->drawable.x || ptOldOrg.y != pWin->drawable.y) - { - if (dx || dy) - REGION_TRANSLATE (pScreen, prgnSrc, dx, dy); - (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); - if (dx || dy) - REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy); - } - else - { - ptOldOrg.x -= dx; - ptOldOrg.y -= dy; - REGION_TRANSLATE (prgnSrc, prgnSrc, - pWin->drawable.x - ptOldOrg.x, - pWin->drawable.y - ptOldOrg.y); - DamageRegionAppend(&pWin->drawable, prgnSrc); - } - cs->CopyWindow = pScreen->CopyWindow; - pScreen->CopyWindow = compCopyWindow; - compCheckTree (pWin->drawable.pScreen); -} - -Bool -compCreateWindow (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - CompScreenPtr cs = GetCompScreen (pScreen); - Bool ret; - - pScreen->CreateWindow = cs->CreateWindow; - ret = (*pScreen->CreateWindow) (pWin); - if (pWin->parent && ret) - { - CompSubwindowsPtr csw = GetCompSubwindows (pWin->parent); - CompClientWindowPtr ccw; - - (*pScreen->SetWindowPixmap) (pWin, (*pScreen->GetWindowPixmap) (pWin->parent)); - if (csw) - for (ccw = csw->clients; ccw; ccw = ccw->next) - compRedirectWindow (clients[CLIENT_ID(ccw->id)], - pWin, ccw->update); - if (compImplicitRedirect (pWin, pWin->parent)) - compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic); - } - cs->CreateWindow = pScreen->CreateWindow; - pScreen->CreateWindow = compCreateWindow; - compCheckTree (pWin->drawable.pScreen); - return ret; -} - -Bool -compDestroyWindow (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - CompScreenPtr cs = GetCompScreen (pScreen); - CompWindowPtr cw; - CompSubwindowsPtr csw; - Bool ret; - - pScreen->DestroyWindow = cs->DestroyWindow; - while ((cw = GetCompWindow (pWin))) - FreeResource (cw->clients->id, RT_NONE); - while ((csw = GetCompSubwindows (pWin))) - FreeResource (csw->clients->id, RT_NONE); - - if (pWin->redirectDraw != RedirectDrawNone) - compFreePixmap (pWin); - ret = (*pScreen->DestroyWindow) (pWin); - cs->DestroyWindow = pScreen->DestroyWindow; - pScreen->DestroyWindow = compDestroyWindow; -/* compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/ - return ret; -} - -void -compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion) -{ - CompWindowPtr cw = GetCompWindow (pWin); - RegionRec damage; - - REGION_NULL (pScreen, &damage); - /* - * Align old border clip with new border clip - */ - REGION_TRANSLATE (pScreen, &cw->borderClip, - pWin->drawable.x - cw->borderClipX, - pWin->drawable.y - cw->borderClipY); - /* - * Compute newly visible portion of window for repaint - */ - REGION_SUBTRACT (pScreen, &damage, pRegion, &cw->borderClip); - /* - * Report that as damaged so it will be redrawn - */ - DamageRegionAppend(&pWin->drawable, &damage); - REGION_UNINIT (pScreen, &damage); - /* - * Save the new border clip region - */ - REGION_COPY (pScreen, &cw->borderClip, pRegion); - cw->borderClipX = pWin->drawable.x; - cw->borderClipY = pWin->drawable.y; -} - -RegionPtr -compGetRedirectBorderClip (WindowPtr pWin) -{ - CompWindowPtr cw = GetCompWindow (pWin); - - return &cw->borderClip; -} - -static VisualPtr -compGetWindowVisual (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - VisualID vid = wVisual (pWin); - int i; - - for (i = 0; i < pScreen->numVisuals; i++) - if (pScreen->visuals[i].vid == vid) - return &pScreen->visuals[i]; - return 0; -} - -PictFormatPtr -compWindowFormat (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - - return PictureMatchVisual (pScreen, pWin->drawable.depth, - compGetWindowVisual (pWin)); -} - -static void -compWindowUpdateAutomatic (WindowPtr pWin) -{ - CompWindowPtr cw = GetCompWindow (pWin); - ScreenPtr pScreen = pWin->drawable.pScreen; - WindowPtr pParent = pWin->parent; - PixmapPtr pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin); - PictFormatPtr pSrcFormat = compWindowFormat (pWin); - PictFormatPtr pDstFormat = compWindowFormat (pWin->parent); - int error; - RegionPtr pRegion = DamageRegion (cw->damage); - PicturePtr pSrcPicture = CreatePicture (0, &pSrcPixmap->drawable, - pSrcFormat, - 0, 0, - serverClient, - &error); - XID subwindowMode = IncludeInferiors; - PicturePtr pDstPicture = CreatePicture (0, &pParent->drawable, - pDstFormat, - CPSubwindowMode, - &subwindowMode, - serverClient, - &error); - - /* - * First move the region from window to screen coordinates - */ - REGION_TRANSLATE (pScreen, pRegion, - pWin->drawable.x, pWin->drawable.y); - - /* - * Clip against the "real" border clip - */ - REGION_INTERSECT (pScreen, pRegion, pRegion, &cw->borderClip); - - /* - * Now translate from screen to dest coordinates - */ - REGION_TRANSLATE (pScreen, pRegion, - -pParent->drawable.x, -pParent->drawable.y); - - /* - * Clip the picture - */ - SetPictureClipRegion (pDstPicture, 0, 0, pRegion); - - /* - * And paint - */ - CompositePicture (PictOpSrc, - pSrcPicture, - 0, - pDstPicture, - 0, 0, /* src_x, src_y */ - 0, 0, /* msk_x, msk_y */ - pSrcPixmap->screen_x - pParent->drawable.x, - pSrcPixmap->screen_y - pParent->drawable.y, - pSrcPixmap->drawable.width, - pSrcPixmap->drawable.height); - FreePicture (pSrcPicture, 0); - FreePicture (pDstPicture, 0); - /* - * Empty the damage region. This has the nice effect of - * rendering the translations above harmless - */ - DamageEmpty (cw->damage); -} - -void -compWindowUpdate (WindowPtr pWin) -{ - WindowPtr pChild; - - for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib) - compWindowUpdate (pChild); - if (pWin->redirectDraw != RedirectDrawNone) - { - CompWindowPtr cw = GetCompWindow(pWin); - - if (cw->damaged) - { - compWindowUpdateAutomatic (pWin); - cw->damaged = FALSE; - } - } -} - -WindowPtr -CompositeRealChildHead (WindowPtr pWin) -{ - WindowPtr pChild, pChildBefore; - CompScreenPtr cs; - - if (!pWin->parent && - (screenIsSaved == SCREEN_SAVER_ON) && - (HasSaverWindow (pWin->drawable.pScreen->myNum))) { - - /* First child is the screen saver; see if next child is the overlay */ - pChildBefore = pWin->firstChild; - pChild = pChildBefore->nextSib; - - } else { - pChildBefore = NullWindow; - pChild = pWin->firstChild; - } - - if (!pChild) { - return NullWindow; - } - - cs = GetCompScreen(pWin->drawable.pScreen); - if (pChild == cs->pOverlayWin) { - return pChild; - } else { - return pChildBefore; - } -} +/*
+ * Copyright © 2006 Sun Microsystems, 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 (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "compint.h"
+
+#ifdef COMPOSITE_DEBUG
+static int
+compCheckWindow (WindowPtr pWin, pointer data)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pWinPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ PixmapPtr pParentPixmap = pWin->parent ? (*pScreen->GetWindowPixmap) (pWin->parent) : 0;
+ PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+
+ if (!pWin->parent)
+ {
+ assert (pWin->redirectDraw == RedirectDrawNone);
+ assert (pWinPixmap == pScreenPixmap);
+ }
+ else if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ assert (pWinPixmap != pParentPixmap);
+ assert (pWinPixmap != pScreenPixmap);
+ }
+ else
+ {
+ assert (pWinPixmap == pParentPixmap);
+ }
+ assert (0 < pWinPixmap->refcnt && pWinPixmap->refcnt < 3);
+ assert (0 < pScreenPixmap->refcnt && pScreenPixmap->refcnt < 3);
+ if (pParentPixmap)
+ assert (0 <= pParentPixmap->refcnt && pParentPixmap->refcnt < 3);
+ return WT_WALKCHILDREN;
+}
+
+void
+compCheckTree (ScreenPtr pScreen)
+{
+ WalkTree (pScreen, compCheckWindow, 0);
+}
+#endif
+
+typedef struct _compPixmapVisit {
+ WindowPtr pWindow;
+ PixmapPtr pPixmap;
+} CompPixmapVisitRec, *CompPixmapVisitPtr;
+
+static Bool
+compRepaintBorder (ClientPtr pClient, pointer closure)
+{
+ WindowPtr pWindow;
+ int rc = dixLookupWindow(&pWindow, (XID)(intptr_t)closure, pClient, DixWriteAccess);
+
+ if (rc == Success) {
+ RegionRec exposed;
+
+ RegionNull(&exposed);
+ RegionSubtract(&exposed, &pWindow->borderClip, &pWindow->winSize);
+ miPaintWindow(pWindow, &exposed, PW_BORDER);
+ RegionUninit(&exposed);
+ }
+ return TRUE;
+}
+
+static int
+compSetPixmapVisitWindow (WindowPtr pWindow, pointer data)
+{
+ CompPixmapVisitPtr pVisit = (CompPixmapVisitPtr) data;
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+
+ if (pWindow != pVisit->pWindow && pWindow->redirectDraw != RedirectDrawNone)
+ return WT_DONTWALKCHILDREN;
+ (*pScreen->SetWindowPixmap) (pWindow, pVisit->pPixmap);
+ /*
+ * Recompute winSize and borderSize. This is duplicate effort
+ * when resizing pixmaps, but necessary when changing redirection.
+ * Might be nice to fix this.
+ */
+ SetWinSize (pWindow);
+ SetBorderSize (pWindow);
+ if (HasBorder (pWindow))
+ QueueWorkProc (compRepaintBorder, serverClient,
+ (pointer)(intptr_t) pWindow->drawable.id);
+ return WT_WALKCHILDREN;
+}
+
+void
+compSetPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
+{
+ CompPixmapVisitRec visitRec;
+
+ visitRec.pWindow = pWindow;
+ visitRec.pPixmap = pPixmap;
+ TraverseTree (pWindow, compSetPixmapVisitWindow, (pointer) &visitRec);
+ compCheckTree (pWindow->drawable.pScreen);
+}
+
+Bool
+compCheckRedirect (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen);
+ Bool should;
+
+ should = pWin->realized && (pWin->drawable.class != InputOnly) &&
+ (cw != NULL) && (pWin->parent != NULL);
+
+ /* Never redirect the overlay window */
+ if (cs->pOverlayWin != NULL) {
+ if (pWin == cs->pOverlayWin) {
+ should = FALSE;
+ }
+ }
+
+ if (should != (pWin->redirectDraw != RedirectDrawNone))
+ {
+ if (should)
+ return compAllocPixmap (pWin);
+ else
+ compFreePixmap (pWin);
+ }
+ return TRUE;
+}
+
+static int
+updateOverlayWindow(ScreenPtr pScreen)
+{
+ CompScreenPtr cs;
+ WindowPtr pWin; /* overlay window */
+ XID vlist[2];
+
+ cs = GetCompScreen(pScreen);
+ if ((pWin = cs->pOverlayWin) != NULL) {
+ if ((pWin->drawable.width == pScreen->width) &&
+ (pWin->drawable.height == pScreen->height))
+ return Success;
+
+ /* Let's resize the overlay window. */
+ vlist[0] = pScreen->width;
+ vlist[1] = pScreen->height;
+ return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin));
+ }
+
+ /* Let's be on the safe side and not assume an overlay window is always allocated. */
+ return Success;
+}
+
+Bool
+compPositionWindow (WindowPtr pWin, int x, int y)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->PositionWindow = cs->PositionWindow;
+ /*
+ * "Shouldn't need this as all possible places should be wrapped
+ *
+ compCheckRedirect (pWin);
+ */
+#ifdef COMPOSITE_DEBUG
+ if ((pWin->redirectDraw != RedirectDrawNone) !=
+ (pWin->viewable && (GetCompWindow(pWin) != NULL)))
+ OsAbort ();
+#endif
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ int bw = wBorderWidth (pWin);
+ int nx = pWin->drawable.x - bw;
+ int ny = pWin->drawable.y - bw;
+
+ if (pPixmap->screen_x != nx || pPixmap->screen_y != ny)
+ {
+ pPixmap->screen_x = nx;
+ pPixmap->screen_y = ny;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ }
+
+ if (!(*pScreen->PositionWindow) (pWin, x, y))
+ ret = FALSE;
+ cs->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = compPositionWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ if (updateOverlayWindow(pScreen) != Success)
+ ret = FALSE;
+ return ret;
+}
+
+Bool
+compRealizeWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->RealizeWindow = cs->RealizeWindow;
+ compCheckRedirect (pWin);
+ if (!(*pScreen->RealizeWindow) (pWin))
+ ret = FALSE;
+ cs->RealizeWindow = pScreen->RealizeWindow;
+ pScreen->RealizeWindow = compRealizeWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compUnrealizeWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->UnrealizeWindow = cs->UnrealizeWindow;
+ compCheckRedirect (pWin);
+ if (!(*pScreen->UnrealizeWindow) (pWin))
+ ret = FALSE;
+ cs->UnrealizeWindow = pScreen->UnrealizeWindow;
+ pScreen->UnrealizeWindow = compUnrealizeWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+/*
+ * Called after the borderClip for the window has settled down
+ * We use this to make sure our extra borderClip has the right origin
+ */
+
+void
+compClipNotify (WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (cw)
+ {
+ if (cw->borderClipX != pWin->drawable.x ||
+ cw->borderClipY != pWin->drawable.y)
+ {
+ RegionTranslate(&cw->borderClip,
+ pWin->drawable.x - cw->borderClipX,
+ pWin->drawable.y - cw->borderClipY);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+ }
+ }
+ if (cs->ClipNotify)
+ {
+ pScreen->ClipNotify = cs->ClipNotify;
+ (*pScreen->ClipNotify) (pWin, dx, dy);
+ cs->ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = compClipNotify;
+ }
+}
+
+/*
+ * Returns TRUE if the window needs server-provided automatic redirect,
+ * which is true if the child and parent aren't both regular or ARGB visuals
+ */
+
+static Bool
+compIsAlternateVisual (ScreenPtr pScreen,
+ XID visual)
+{
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int i;
+
+ for (i = 0; i < cs->numAlternateVisuals; i++)
+ if (cs->alternateVisuals[i] == visual)
+ return TRUE;
+ return FALSE;
+}
+
+static Bool
+compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
+{
+ if (pParent)
+ {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XID winVisual = wVisual (pWin);
+ XID parentVisual = wVisual (pParent);
+
+ if (winVisual != parentVisual &&
+ (compIsAlternateVisual (pScreen, winVisual) ||
+ compIsAlternateVisual (pScreen, parentVisual)))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void
+compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->ReparentWindow = cs->ReparentWindow;
+ /*
+ * Remove any implicit redirect due to synthesized visual
+ */
+ if (compImplicitRedirect (pWin, pPriorParent))
+ compUnredirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+ /*
+ * Handle subwindows redirection
+ */
+ compUnredirectOneSubwindow (pPriorParent, pWin);
+ compRedirectOneSubwindow (pWin->parent, pWin);
+ /*
+ * Add any implict redirect due to synthesized visual
+ */
+ if (compImplicitRedirect (pWin, pWin->parent))
+ compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+
+ /*
+ * Allocate any necessary redirect pixmap
+ * (this actually should never be true; pWin is always unmapped)
+ */
+ compCheckRedirect (pWin);
+
+ /*
+ * Reset pixmap pointers as appropriate
+ */
+ if (pWin->parent && pWin->redirectDraw == RedirectDrawNone)
+ compSetPixmap (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
+ /*
+ * Call down to next function
+ */
+ if (pScreen->ReparentWindow)
+ (*pScreen->ReparentWindow) (pWin, pPriorParent);
+ cs->ReparentWindow = pScreen->ReparentWindow;
+ pScreen->ReparentWindow = compReparentWindow;
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int dx = 0, dy = 0;
+
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ assert (cw->oldx != COMP_ORIGIN_INVALID);
+ assert (cw->oldy != COMP_ORIGIN_INVALID);
+ if (cw->pOldPixmap)
+ {
+ /*
+ * Ok, the old bits are available in pOldPixmap and
+ * need to be copied to pNewPixmap.
+ */
+ RegionRec rgnDst;
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ GCPtr pGC;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ RegionTranslate(prgnSrc, -dx, -dy);
+
+ RegionNull(&rgnDst);
+
+ RegionIntersect(&rgnDst,
+ &pWin->borderClip, prgnSrc);
+
+ RegionTranslate(&rgnDst,
+ -pPixmap->screen_x, -pPixmap->screen_y);
+
+ dx = dx + pPixmap->screen_x - cw->oldx;
+ dy = dy + pPixmap->screen_y - cw->oldy;
+ pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+ if (pGC)
+ {
+ BoxPtr pBox = RegionRects (&rgnDst);
+ int nBox = RegionNumRects (&rgnDst);
+
+ ValidateGC(&pPixmap->drawable, pGC);
+ while (nBox--)
+ {
+ (void) (*pGC->ops->CopyArea) (&cw->pOldPixmap->drawable,
+ &pPixmap->drawable,
+ pGC,
+ pBox->x1 + dx, pBox->y1 + dy,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1,
+ pBox->x1, pBox->y1);
+ pBox++;
+ }
+ FreeScratchGC (pGC);
+ }
+ return;
+ }
+ dx = pPixmap->screen_x - cw->oldx;
+ dy = pPixmap->screen_y - cw->oldy;
+ ptOldOrg.x += dx;
+ ptOldOrg.y += dy;
+ }
+
+ pScreen->CopyWindow = cs->CopyWindow;
+ if (ptOldOrg.x != pWin->drawable.x || ptOldOrg.y != pWin->drawable.y)
+ {
+ if (dx || dy)
+ RegionTranslate(prgnSrc, dx, dy);
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
+ if (dx || dy)
+ RegionTranslate(prgnSrc, -dx, -dy);
+ }
+ else
+ {
+ ptOldOrg.x -= dx;
+ ptOldOrg.y -= dy;
+ RegionTranslate(prgnSrc,
+ pWin->drawable.x - ptOldOrg.x,
+ pWin->drawable.y - ptOldOrg.y);
+ DamageRegionAppend(&pWin->drawable, prgnSrc);
+ }
+ cs->CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = compCopyWindow;
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+Bool
+compCreateWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret;
+
+ pScreen->CreateWindow = cs->CreateWindow;
+ ret = (*pScreen->CreateWindow) (pWin);
+ if (pWin->parent && ret)
+ {
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin->parent);
+ CompClientWindowPtr ccw;
+
+ (*pScreen->SetWindowPixmap) (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
+ if (csw)
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ compRedirectWindow (clients[CLIENT_ID(ccw->id)],
+ pWin, ccw->update);
+ if (compImplicitRedirect (pWin, pWin->parent))
+ compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+ }
+ cs->CreateWindow = pScreen->CreateWindow;
+ pScreen->CreateWindow = compCreateWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compDestroyWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw;
+ CompSubwindowsPtr csw;
+ Bool ret;
+
+ pScreen->DestroyWindow = cs->DestroyWindow;
+ while ((cw = GetCompWindow (pWin)))
+ FreeResource (cw->clients->id, RT_NONE);
+ while ((csw = GetCompSubwindows (pWin)))
+ FreeResource (csw->clients->id, RT_NONE);
+
+ if (pWin->redirectDraw != RedirectDrawNone)
+ compFreePixmap (pWin);
+ ret = (*pScreen->DestroyWindow) (pWin);
+ cs->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = compDestroyWindow;
+/* compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/
+ return ret;
+}
+
+void
+compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ RegionRec damage;
+
+ RegionNull(&damage);
+ /*
+ * Align old border clip with new border clip
+ */
+ RegionTranslate(&cw->borderClip,
+ pWin->drawable.x - cw->borderClipX,
+ pWin->drawable.y - cw->borderClipY);
+ /*
+ * Compute newly visible portion of window for repaint
+ */
+ RegionSubtract(&damage, pRegion, &cw->borderClip);
+ /*
+ * Report that as damaged so it will be redrawn
+ */
+ DamageRegionAppend(&pWin->drawable, &damage);
+ RegionUninit(&damage);
+ /*
+ * Save the new border clip region
+ */
+ RegionCopy(&cw->borderClip, pRegion);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+}
+
+RegionPtr
+compGetRedirectBorderClip (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ return &cw->borderClip;
+}
+
+static VisualPtr
+compGetWindowVisual (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ VisualID vid = wVisual (pWin);
+ int i;
+
+ for (i = 0; i < pScreen->numVisuals; i++)
+ if (pScreen->visuals[i].vid == vid)
+ return &pScreen->visuals[i];
+ return 0;
+}
+
+PictFormatPtr
+compWindowFormat (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ return PictureMatchVisual (pScreen, pWin->drawable.depth,
+ compGetWindowVisual (pWin));
+}
+
+static void
+compWindowUpdateAutomatic (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pParent = pWin->parent;
+ PixmapPtr pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ PictFormatPtr pSrcFormat = compWindowFormat (pWin);
+ PictFormatPtr pDstFormat = compWindowFormat (pWin->parent);
+ int error;
+ RegionPtr pRegion = DamageRegion (cw->damage);
+ PicturePtr pSrcPicture = CreatePicture (0, &pSrcPixmap->drawable,
+ pSrcFormat,
+ 0, 0,
+ serverClient,
+ &error);
+ XID subwindowMode = IncludeInferiors;
+ PicturePtr pDstPicture = CreatePicture (0, &pParent->drawable,
+ pDstFormat,
+ CPSubwindowMode,
+ &subwindowMode,
+ serverClient,
+ &error);
+
+ /*
+ * First move the region from window to screen coordinates
+ */
+ RegionTranslate(pRegion,
+ pWin->drawable.x, pWin->drawable.y);
+
+ /*
+ * Clip against the "real" border clip
+ */
+ RegionIntersect(pRegion, pRegion, &cw->borderClip);
+
+ /*
+ * Now translate from screen to dest coordinates
+ */
+ RegionTranslate(pRegion,
+ -pParent->drawable.x, -pParent->drawable.y);
+
+ /*
+ * Clip the picture
+ */
+ SetPictureClipRegion (pDstPicture, 0, 0, pRegion);
+
+ /*
+ * And paint
+ */
+ CompositePicture (PictOpSrc,
+ pSrcPicture,
+ 0,
+ pDstPicture,
+ 0, 0, /* src_x, src_y */
+ 0, 0, /* msk_x, msk_y */
+ pSrcPixmap->screen_x - pParent->drawable.x,
+ pSrcPixmap->screen_y - pParent->drawable.y,
+ pSrcPixmap->drawable.width,
+ pSrcPixmap->drawable.height);
+ FreePicture (pSrcPicture, 0);
+ FreePicture (pDstPicture, 0);
+ /*
+ * Empty the damage region. This has the nice effect of
+ * rendering the translations above harmless
+ */
+ DamageEmpty (cw->damage);
+}
+
+void
+compWindowUpdate (WindowPtr pWin)
+{
+ WindowPtr pChild;
+
+ for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+ compWindowUpdate (pChild);
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ CompWindowPtr cw = GetCompWindow(pWin);
+
+ if (cw->damaged)
+ {
+ compWindowUpdateAutomatic (pWin);
+ cw->damaged = FALSE;
+ }
+ }
+}
+
+WindowPtr
+CompositeRealChildHead (WindowPtr pWin)
+{
+ WindowPtr pChild, pChildBefore;
+ CompScreenPtr cs;
+
+ if (!pWin->parent &&
+ (screenIsSaved == SCREEN_SAVER_ON) &&
+ (HasSaverWindow (pWin->drawable.pScreen))) {
+
+ /* First child is the screen saver; see if next child is the overlay */
+ pChildBefore = pWin->firstChild;
+ pChild = pChildBefore->nextSib;
+
+ } else {
+ pChildBefore = NullWindow;
+ pChild = pWin->firstChild;
+ }
+
+ if (!pChild) {
+ return NullWindow;
+ }
+
+ cs = GetCompScreen(pWin->drawable.pScreen);
+ if (pChild == cs->pOverlayWin) {
+ return pChild;
+ } else {
+ return pChildBefore;
+ }
+}
+
+int
+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
+ int bw, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = 0;
+ WindowPtr pParent = pWin->parent;
+ CompWindowPtr cw;
+ int draw_x, draw_y;
+ Bool alloc_ret;
+
+ if (cs->ConfigNotify)
+ {
+ pScreen->ConfigNotify = cs->ConfigNotify;
+ ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+ cs->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = compConfigNotify;
+
+ if (ret)
+ return ret;
+ }
+
+ if (pWin->redirectDraw == RedirectDrawNone)
+ return Success;
+
+ compCheckTree (pScreen);
+
+ draw_x = pParent->drawable.x + x + bw;
+ draw_y = pParent->drawable.y + y + bw;
+ alloc_ret = compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
+
+ cw = GetCompWindow (pWin);
+ if (cw->pOldPixmap)
+ {
+ (*pScreen->DestroyPixmap) (cw->pOldPixmap);
+ cw->pOldPixmap = NullPixmap;
+ }
+ compCheckTree (pScreen);
+
+ if (alloc_ret == FALSE)
+ return BadAlloc;
+ return Success;
+}
diff --git a/xorg-server/config/Makefile.am b/xorg-server/config/Makefile.am index 675a3b260..d8a7b45f6 100644 --- a/xorg-server/config/Makefile.am +++ b/xorg-server/config/Makefile.am @@ -1,39 +1,39 @@ -AM_CFLAGS = $(DIX_CFLAGS) - -noinst_LTLIBRARIES = libconfig.la -libconfig_la_SOURCES = config.c config-backends.h - -if CONFIG_UDEV - -AM_CFLAGS += $(UDEV_CFLAGS) -libconfig_la_SOURCES += udev.c -libconfig_la_LIBADD = $(UDEV_LIBS) - -xorgconfddir = $(datadir)/X11/$(XF86CONFIGDIR) -xorgconfd_DATA = 10-evdev.conf - -else - -if CONFIG_NEED_DBUS -AM_CFLAGS += $(DBUS_CFLAGS) -libconfig_la_SOURCES += dbus-core.c -libconfig_la_LIBADD = $(DBUS_LIBS) - -if CONFIG_DBUS_API -dbusconfigdir = $(sysconfdir)/dbus-1/system.d -dbusconfig_DATA = xorg-server.conf - -libconfig_la_SOURCES += dbus.c -endif - -if CONFIG_HAL -AM_CFLAGS += $(HAL_CFLAGS) -libconfig_la_SOURCES += hal.c -libconfig_la_LIBADD += $(HAL_LIBS) -endif - -endif # CONFIG_NEED_DBUS - -endif # !CONFIG_UDEV - -EXTRA_DIST = xorg-server.conf x11-input.fdi 10-evdev.conf +AM_CFLAGS = $(DIX_CFLAGS)
+
+noinst_LTLIBRARIES = libconfig.la
+libconfig_la_SOURCES = config.c config-backends.h
+
+if CONFIG_UDEV
+
+AM_CFLAGS += $(UDEV_CFLAGS)
+libconfig_la_SOURCES += udev.c
+libconfig_la_LIBADD = $(UDEV_LIBS)
+
+xorgconfddir = $(datadir)/X11/$(XF86CONFIGDIR)
+xorgconfd_DATA = 10-evdev.conf
+
+else
+
+if CONFIG_NEED_DBUS
+AM_CFLAGS += $(DBUS_CFLAGS)
+libconfig_la_SOURCES += dbus-core.c
+libconfig_la_LIBADD = $(DBUS_LIBS)
+
+if CONFIG_DBUS_API
+dbusconfigdir = $(sysconfdir)/dbus-1/system.d
+dbusconfig_DATA = xorg-server.conf
+
+libconfig_la_SOURCES += dbus.c
+endif
+
+if CONFIG_HAL
+AM_CFLAGS += $(HAL_CFLAGS)
+libconfig_la_SOURCES += hal.c
+libconfig_la_LIBADD += $(HAL_LIBS)
+endif
+
+endif # CONFIG_NEED_DBUS
+
+endif # !CONFIG_UDEV
+
+EXTRA_DIST = xorg-server.conf x11-input.fdi 10-evdev.conf fdi2iclass.py
diff --git a/xorg-server/config/dbus.c b/xorg-server/config/dbus.c index d6316623b..5d11feaa1 100644 --- a/xorg-server/config/dbus.c +++ b/xorg-server/config/dbus.c @@ -27,7 +27,6 @@ #include <dix-config.h>
#endif
-#define DBUS_API_SUBJECT_TO_CHANGE
#include <dbus/dbus.h>
#include <string.h>
@@ -184,10 +183,8 @@ unwind: while (options) {
tmpo = options;
options = options->next;
- if (tmpo->key)
- free(tmpo->key);
- if (tmpo->value)
- free(tmpo->value);
+ free(tmpo->key);
+ free(tmpo->value);
free(tmpo);
}
diff --git a/xorg-server/config/fdi2iclass.py b/xorg-server/config/fdi2iclass.py new file mode 100644 index 000000000..9dc06a76f --- /dev/null +++ b/xorg-server/config/fdi2iclass.py @@ -0,0 +1,202 @@ +#!/usr/bin/python
+#
+# Convert xorg keys from hal FDIs files to xorg.conf InputClass sections.
+# Modified from Martin Pitt's original fdi2mpi.py script:
+# http://cgit.freedesktop.org/media-player-info/tree/tools/fdi2mpi.py
+#
+# (C) 2010 Dan Nicholson
+# (C) 2009 Canonical Ltd.
+# Author: Dan Nicholson <dbn.lists@gmail.com>
+# Author: Martin Pitt <martin.pitt@ubuntu.com>
+#
+# 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
+# fur- nished 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,
+# FIT- NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+# NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+import sys, xml.dom.minidom
+
+# dict converting <match> tags to Match* entries
+match_table = {
+ 'info.product': 'MatchProduct',
+ 'input.product': 'MatchProduct',
+ 'info.vendor': 'MatchVendor',
+ 'input.vendor': 'MatchVendor',
+ 'info.device': 'MatchDevicePath',
+ 'linux.device_file': 'MatchDevicePath',
+ '/org/freedesktop/Hal/devices/computer:system.kernel.name': 'MatchOS',
+ '@info.parent:pnp.id': 'MatchPnPID',
+}
+
+# dict converting info.capabilities list to Match* entries
+cap_match_table = {
+ 'input.keys': 'MatchIsKeyboard',
+ 'input.keyboard': 'MatchIsKeyboard',
+ 'input.keypad': 'MatchIsKeyboard',
+ 'input.mouse': 'MatchIsPointer',
+ 'input.joystick': 'MatchIsJoystick',
+ 'input.tablet': 'MatchIsTablet',
+ 'input.touchpad': 'MatchIsTouchpad',
+ 'input.touchscreen': 'MatchIsTouchscreen',
+}
+
+def device_glob(path):
+ '''Convert a contains device path to a glob entry'''
+ if path[0] != '/':
+ path = '*' + path
+ return path + '*'
+
+def parse_match(node):
+ '''Parse a <match> tag to a tuple with InputClass values'''
+ match = None
+ value = None
+ booltype = False
+
+ # see what type of key we have
+ if node.attributes.has_key('key'):
+ key = node.attributes['key'].nodeValue
+ if key in match_table:
+ match = match_table[key]
+ elif key == 'info.capabilities':
+ booltype = True
+
+ # bail out now if it's unrecognized
+ if not match and not booltype:
+ return (match, value)
+
+ if node.attributes.has_key('string'):
+ value = node.attributes['string'].nodeValue
+ elif node.attributes.has_key('contains'):
+ value = node.attributes['contains'].nodeValue
+ if match == 'MatchDevicePath':
+ value = device_glob(value)
+ elif booltype and value in cap_match_table:
+ match = cap_match_table[value]
+ value = 'yes'
+ elif node.attributes.has_key('string_outof'):
+ value = node.attributes['string_outof'].nodeValue.replace(';','|')
+ elif node.attributes.has_key('contains_outof'):
+ all_values = node.attributes['contains_outof'].nodeValue.split(';')
+ for v in all_values:
+ if match == 'MatchDevicePath':
+ v = device_glob(v)
+ elif match == 'MatchPnPID' and len(v) < 7:
+ v += '*'
+ if value:
+ value += '|' + v
+ else:
+ value = v
+
+ return (match, value)
+
+def parse_options(node):
+ '''Parse the x11_* options and return InputClass entries'''
+ driver = ''
+ ignore = False
+ options = []
+ for n in node.childNodes:
+ if n.nodeType != xml.dom.minidom.Node.ELEMENT_NODE:
+ continue
+
+ tag = n.tagName
+ key = n.attributes['key'].nodeValue
+ value = ''
+
+ if n.hasChildNodes():
+ content_node = n.childNodes[0]
+ assert content_node.nodeType == xml.dom.Node.TEXT_NODE
+ value = content_node.nodeValue
+
+ if tag == 'match':
+ continue
+ assert tag in ('addset', 'merge', 'append', 'remove')
+
+ if tag == 'remove' and key == 'input.x11_driver':
+ ignore = True
+ elif key == 'input.x11_driver':
+ driver = value
+ elif key.startswith('input.x11_options.'):
+ option = key.split('.', 2)[2]
+ options.append((option, value))
+
+ return (driver, ignore, options)
+
+def is_match_node(node):
+ '''Check if a node is a <match> element'''
+ return node.nodeType == xml.dom.minidom.Node.ELEMENT_NODE and \
+ node.tagName == 'match'
+
+def parse_all_matches(node):
+ '''Parse a x11 match tag and any parents that don't supply their
+ own options'''
+ matches = []
+
+ while True:
+ (key, value) = parse_match(node)
+ if key and value:
+ matches.append((key, value))
+
+ # walk up to a parent match node
+ node = node.parentNode
+ if node == None or not is_match_node(node):
+ break
+
+ # leave if there other options at this level
+ children = set([n.tagName for n in node.childNodes
+ if n.nodeType == xml.dom.minidom.Node.ELEMENT_NODE])
+ if children & set(['addset', 'merge', 'append']):
+ break
+
+ return matches
+
+# stupid counter to give "unique" rule names
+num_sections = 1
+def print_section(matches, driver, ignore, options):
+ '''Print a valid InputClass section to stdout'''
+ global num_sections
+ print 'Section "InputClass"'
+ print '\tIdentifier "Converted Class %d"' % num_sections
+ num_sections += 1
+ for m, v in matches:
+ print '\t%s "%s"' % (m, v)
+ if driver:
+ print '\tDriver "%s"' % driver
+ if ignore:
+ print '\tOption "Ignore" "yes"'
+ for o, v in options:
+ print '\tOption "%s" "%s"' % (o, v)
+ print 'EndSection'
+
+def parse_fdi(fdi):
+ '''Parse x11 matches from fdi'''
+ # find all <match> leaf nodes
+ num = 0
+ for match_node in fdi.getElementsByTagName('match'):
+ children = set([n.tagName for n in match_node.childNodes
+ if n.nodeType == xml.dom.minidom.Node.ELEMENT_NODE])
+
+ # see if there are any options at this level
+ (driver, ignore, options) = parse_options(match_node)
+ if not driver and not ignore and not options:
+ continue
+
+ matches = parse_all_matches(match_node)
+ if num > 0:
+ print
+ print_section(matches, driver, ignore, options)
+ num += 1
+
+for f in sys.argv[1:]:
+ parse_fdi(xml.dom.minidom.parse(f))
diff --git a/xorg-server/config/hal.c b/xorg-server/config/hal.c index 738cb3185..1245bb192 100644 --- a/xorg-server/config/hal.c +++ b/xorg-server/config/hal.c @@ -129,6 +129,7 @@ static void device_added(LibHalContext *hal_ctx, const char *udi)
{
char *path = NULL, *driver = NULL, *name = NULL, *config_info = NULL;
+ char *hal_tags, *parent;
InputOption *options = NULL, *tmpo = NULL;
InputAttributes attrs = {0};
DeviceIntPtr dev = NULL;
@@ -164,7 +165,9 @@ device_added(LibHalContext *hal_ctx, const char *udi) attrs.product = xstrdup(name);
attrs.vendor = get_prop_string(hal_ctx, udi, "info.vendor");
- attrs.tags = xstrtokenize(get_prop_string(hal_ctx, udi, "input.tags"), ",");
+ hal_tags = get_prop_string(hal_ctx, udi, "input.tags");
+ attrs.tags = xstrtokenize(hal_tags, ",");
+ free(hal_tags);
if (libhal_device_query_capability(hal_ctx, udi, "input.keys", NULL))
attrs.flags |= ATTR_KEYBOARD;
@@ -179,6 +182,29 @@ device_added(LibHalContext *hal_ctx, const char *udi) if (libhal_device_query_capability(hal_ctx, udi, "input.touchscreen", NULL))
attrs.flags |= ATTR_TOUCHSCREEN;
+ parent = get_prop_string(hal_ctx, udi, "info.parent");
+ if (parent) {
+ int usb_vendor, usb_product;
+
+ attrs.pnp_id = get_prop_string(hal_ctx, parent, "pnp.id");
+
+ /* construct USB ID in lowercase - "0000:ffff" */
+ usb_vendor = libhal_device_get_property_int(hal_ctx, parent,
+ "usb.vendor_id", NULL);
+ LogMessageVerb(X_INFO, 10,
+ "config/hal: getting usb.vendor_id on %s "
+ "returned %04x\n", parent, usb_vendor);
+ usb_product = libhal_device_get_property_int(hal_ctx, parent,
+ "usb.product_id", NULL);
+ LogMessageVerb(X_INFO, 10,
+ "config/hal: getting usb.product_id on %s "
+ "returned %04x\n", parent, usb_product);
+ if (usb_vendor && usb_product)
+ attrs.usb_id = Xprintf("%04x:%04x", usb_vendor, usb_product);
+
+ free(parent);
+ }
+
options = calloc(sizeof(*options), 1);
if (!options){
LogMessage(X_ERROR, "config/hal: couldn't allocate space for input options!\n");
@@ -251,28 +277,23 @@ device_added(LibHalContext *hal_ctx, const char *udi) {
if (!strcasecmp(&tmp[3], "layout"))
{
- if (xkb_opts.layout)
- free(xkb_opts.layout);
+ free(xkb_opts.layout);
xkb_opts.layout = strdup(tmp_val);
} else if (!strcasecmp(&tmp[3], "model"))
{
- if (xkb_opts.model)
- free(xkb_opts.model);
+ free(xkb_opts.model);
xkb_opts.model = strdup(tmp_val);
} else if (!strcasecmp(&tmp[3], "rules"))
{
- if (xkb_opts.rules)
- free(xkb_opts.rules);
+ free(xkb_opts.rules);
xkb_opts.rules = strdup(tmp_val);
} else if (!strcasecmp(&tmp[3], "variant"))
{
- if (xkb_opts.variant)
- free(xkb_opts.variant);
+ free(xkb_opts.variant);
xkb_opts.variant = strdup(tmp_val);
} else if (!strcasecmp(&tmp[3], "options"))
{
- if (xkb_opts.options)
- free(xkb_opts.options);
+ free(xkb_opts.options);
xkb_opts.options = strdup(tmp_val);
}
} else
@@ -289,8 +310,7 @@ device_added(LibHalContext *hal_ctx, const char *udi) (!strcasecmp(&tmp[3], "options")) &&
(tmp_val = get_prop_string_array(hal_ctx, udi, psi_key)))
{
- if (xkb_opts.options)
- free(xkb_opts.options);
+ free(xkb_opts.options);
xkb_opts.options = strdup(tmp_val);
}
}
@@ -366,22 +386,17 @@ device_added(LibHalContext *hal_ctx, const char *udi) }
for (; dev; dev = dev->next){
- if (dev->config_info)
- free(dev->config_info);
+ free(dev->config_info);
dev->config_info = xstrdup(config_info);
}
unwind:
if (set)
libhal_free_property_set(set);
- if (path)
- free(path);
- if (driver)
- free(driver);
- if (name)
- free(name);
- if (config_info)
- free(config_info);
+ free(path);
+ free(driver);
+ free(name);
+ free(config_info);
while (!dev && (tmpo = options)) {
options = tmpo->next;
free(tmpo->key);
@@ -392,6 +407,8 @@ unwind: free(attrs.product);
free(attrs.vendor);
free(attrs.device);
+ free(attrs.pnp_id);
+ free(attrs.usb_id);
if (attrs.tags) {
char **tag = attrs.tags;
while (*tag) {
@@ -401,16 +418,11 @@ unwind: free(attrs.tags);
}
- if (xkb_opts.layout)
- free(xkb_opts.layout);
- if (xkb_opts.rules)
- free(xkb_opts.rules);
- if (xkb_opts.model)
- free(xkb_opts.model);
- if (xkb_opts.variant)
- free(xkb_opts.variant);
- if (xkb_opts.options)
- free(xkb_opts.options);
+ free(xkb_opts.layout);
+ free(xkb_opts.rules);
+ free(xkb_opts.model);
+ free(xkb_opts.variant);
+ free(xkb_opts.options);
dbus_error_free(&error);
@@ -635,7 +647,7 @@ config_hal_init(void) }
/* verbose message */
- LogMessageVerb(X_INFO,7,"config/hal: initialized");
+ LogMessageVerb(X_INFO,7,"config/hal: initialized\n");
return 1;
}
diff --git a/xorg-server/config/udev.c b/xorg-server/config/udev.c index 304ee2c93..bf463168e 100644 --- a/xorg-server/config/udev.c +++ b/xorg-server/config/udev.c @@ -28,6 +28,7 @@ #endif
#include <libudev.h>
+#include <ctype.h>
#include "input.h"
#include "inputstr.h"
@@ -37,6 +38,17 @@ #define UDEV_XKB_PROP_KEY "xkb"
+#define LOG_PROPERTY(path, prop, val) \
+ LogMessageVerb(X_INFO, 10, \
+ "config/udev: getting property %s on %s " \
+ "returned \"%s\"\n", \
+ (prop), (path), (val) ? (val) : "(null)")
+#define LOG_SYSATTR(path, attr, val) \
+ LogMessageVerb(X_INFO, 10, \
+ "config/udev: getting attribute %s on %s " \
+ "returned \"%s\"\n", \
+ (attr), (path), (val) ? (val) : "(null)")
+
static struct udev_monitor *udev_monitor;
static void
@@ -45,6 +57,8 @@ device_added(struct udev_device *udev_device) const char *path, *name = NULL;
char *config_info = NULL;
const char *syspath;
+ const char *tags_prop;
+ const char *usb_vendor = NULL, *usb_model = NULL;
const char *key, *value, *tmp;
InputOption *options = NULL, *tmpo;
InputAttributes attrs = {};
@@ -60,8 +74,13 @@ device_added(struct udev_device *udev_device) if (!path || !syspath)
return;
- if (!udev_device_get_property_value(udev_device, "ID_INPUT"))
+ if (!udev_device_get_property_value(udev_device, "ID_INPUT")) {
+ LogMessageVerb(X_INFO, 10,
+ "config/udev: ignoring device %s without "
+ "property ID_INPUT set\n",
+ path);
return;
+ }
options = calloc(sizeof(*options), 1);
if (!options)
@@ -74,9 +93,17 @@ device_added(struct udev_device *udev_device) parent = udev_device_get_parent(udev_device);
if (parent) {
+ const char *ppath = udev_device_get_devnode(parent);
+
name = udev_device_get_sysattr_value(parent, "name");
- if (!name)
+ LOG_SYSATTR(ppath, "name", name);
+ if (!name) {
name = udev_device_get_property_value(parent, "NAME");
+ LOG_PROPERTY(ppath, "NAME", name);
+ }
+
+ attrs.pnp_id = udev_device_get_sysattr_value(parent, "id");
+ LOG_SYSATTR(ppath, "id", attrs.pnp_id);
}
if (!name)
name = "(unnamed)";
@@ -87,7 +114,10 @@ device_added(struct udev_device *udev_device) add_option(&options, "path", path);
add_option(&options, "device", path);
attrs.device = path;
- attrs.tags = xstrtokenize(udev_device_get_property_value(udev_device, "ID_INPUT.tags"), ",");
+
+ tags_prop = udev_device_get_property_value(udev_device, "ID_INPUT.tags");
+ LOG_PROPERTY(path, "ID_INPUT.tags", tags_prop);
+ attrs.tags = xstrtokenize(tags_prop, ",");
config_info = Xprintf("udev:%s", syspath);
if (!config_info)
@@ -107,6 +137,7 @@ device_added(struct udev_device *udev_device) value = udev_list_entry_get_value(entry);
if (!strncasecmp(key, UDEV_XKB_PROP_KEY,
sizeof(UDEV_XKB_PROP_KEY) - 1)) {
+ LOG_PROPERTY(path, key, value);
tmp = key + sizeof(UDEV_XKB_PROP_KEY) - 1;
if (!strcasecmp(tmp, "rules"))
add_option(&options, "xkb_rules", value);
@@ -119,21 +150,45 @@ device_added(struct udev_device *udev_device) else if (!strcasecmp(tmp, "options"))
add_option(&options, "xkb_options", value);
} else if (!strcmp(key, "ID_VENDOR")) {
+ LOG_PROPERTY(path, key, value);
attrs.vendor = value;
+ } else if (!strcmp(key, "ID_VENDOR_ID")) {
+ LOG_PROPERTY(path, key, value);
+ usb_vendor = value;
+ } else if (!strcmp(key, "ID_VENDOR_MODEL")) {
+ LOG_PROPERTY(path, key, value);
+ usb_model = value;
} else if (!strcmp(key, "ID_INPUT_KEY")) {
+ LOG_PROPERTY(path, key, value);
attrs.flags |= ATTR_KEYBOARD;
} else if (!strcmp(key, "ID_INPUT_MOUSE")) {
+ LOG_PROPERTY(path, key, value);
attrs.flags |= ATTR_POINTER;
} else if (!strcmp(key, "ID_INPUT_JOYSTICK")) {
+ LOG_PROPERTY(path, key, value);
attrs.flags |= ATTR_JOYSTICK;
} else if (!strcmp(key, "ID_INPUT_TABLET")) {
+ LOG_PROPERTY(path, key, value);
attrs.flags |= ATTR_TABLET;
} else if (!strcmp(key, "ID_INPUT_TOUCHPAD")) {
+ LOG_PROPERTY(path, key, value);
attrs.flags |= ATTR_TOUCHPAD;
} else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")) {
+ LOG_PROPERTY(path, key, value);
attrs.flags |= ATTR_TOUCHSCREEN;
}
}
+
+ /* construct USB ID in lowercase hex - "0000:ffff" */
+ if (usb_vendor && usb_model) {
+ attrs.usb_id = Xprintf("%s:%s", usb_vendor, usb_model);
+ if (attrs.usb_id) {
+ char *cur;
+ for (cur = attrs.usb_id; *cur; cur++)
+ *cur = tolower(*cur);
+ }
+ }
+
LogMessage(X_INFO, "config/udev: Adding input device %s (%s)\n",
name, path);
rc = NewInputDeviceRequest(options, &attrs, &dev);
@@ -154,6 +209,7 @@ device_added(struct udev_device *udev_device) free(tmpo);
}
+ free(attrs.usb_id);
if (attrs.tags) {
char **tag = attrs.tags;
while (*tag) {
diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac index 6b94bb642..dec96468d 100644 --- a/xorg-server/configure.ac +++ b/xorg-server/configure.ac @@ -123,7 +123,7 @@ AM_CONDITIONAL(SPECIAL_DTRACE_OBJECTS, [test "x$SPECIAL_DTRACE_OBJECTS" = "xyes" AC_HEADER_DIRENT
AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h dlfcn.h stropts.h fnmatch.h])
+AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h dlfcn.h stropts.h fnmatch.h sys/utsname.h])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@@ -644,6 +644,7 @@ AC_ARG_ENABLE(vgahw, AS_HELP_STRING([--enable-vgahw], [Build Xorg with AC_ARG_ENABLE(vbe, AS_HELP_STRING([--enable-vbe], [Build Xorg with VBE module (default: enabled)]), [VBE=$enableval], [VBE=yes])
AC_ARG_ENABLE(int10-module, AS_HELP_STRING([--enable-int10-module], [Build Xorg with int10 module (default: enabled)]), [INT10MODULE=$enableval], [INT10MODULE=yes])
AC_ARG_ENABLE(windowswm, AS_HELP_STRING([--enable-windowswm], [Build XWin with WindowsWM extension (default: no)]), [WINDOWSWM=$enableval], [WINDOWSWM=no])
+AC_ARG_ENABLE(libdrm, AS_HELP_STRING([--enable-libdrm], [Build Xorg with libdrm support (default: enabled)]), [DRM=$enableval],[DRM=yes])
dnl DDXes.
AC_ARG_ENABLE(xorg, AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
@@ -793,7 +794,7 @@ APPLEWMPROTO="applewmproto >= 1.4" dnl Core modules for most extensions, et al.
REQUIRED_MODULES="[randrproto >= 1.2.99.3] [renderproto >= 0.11] [fixesproto >= 4.1] [damageproto >= 1.1] [xcmiscproto >= 1.2.0] [xextproto >= 7.0.99.3] [xproto >= 7.0.17] [xtrans >= 1.2.2] [bigreqsproto >= 1.1.0] fontsproto [inputproto >= 1.9.99.902] [kbproto >= 1.0.3]"
-REQUIRED_LIBS="xfont xau [pixman-1 >= 0.15.20]"
+REQUIRED_LIBS="xfont xau"
dnl List of libraries that require a specific version
LIBAPPLEWM="applewm >= 1.4"
@@ -808,6 +809,13 @@ LIBPCIACCESS="pciaccess >= 0.8.0" LIBGLIB="glib-2.0 >= 2.16"
LIBUDEV="libudev >= 143"
LIBSELINUX="libselinux >= 2.0.86"
+LIBDBUS="dbus-1 >= 1.0"
+LIBPIXMAN="pixman-1 >= 0.15.20"
+
+dnl Pixman is always required, but we separate it out so we can link
+dnl specific modules against it
+PKG_CHECK_MODULES(PIXMAN, $LIBPIXMAN)
+REQUIRED_LIBS="$REQUIRED_LIBS $LIBPIXMAN"
if test "x$CONFIG_UDEV" = xyes &&
{ test "x$CONFIG_DBUS_API" = xyes || test "x$CONFIG_HAL" = xyes; }; then
@@ -831,7 +839,7 @@ fi dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas
dnl CONFIG_DBUS_API is true if we want to enable the D-Bus config
dnl API.
-PKG_CHECK_MODULES(DBUS, dbus-1, [HAVE_DBUS=yes], [HAVE_DBUS=no])
+PKG_CHECK_MODULES(DBUS, $LIBDBUS, [HAVE_DBUS=yes], [HAVE_DBUS=no])
if test "x$HAVE_DBUS" = xyes; then
AC_DEFINE(HAVE_DBUS, 1, [Have D-Bus support])
fi
@@ -1033,9 +1041,10 @@ esac AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)
if test "x$DRI" = xyes || test "x$DRI2" = xyes; then
- PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
- AC_SUBST(LIBDRM_CFLAGS)
- AC_SUBST(LIBDRM_LIBS)
+ if test "x$DRM" = xyes; then
+ AC_DEFINE(WITH_LIBDRM, 1, [Building with libdrm support])
+ PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
+ fi
fi
if test "x$DRI2" = xyes; then
@@ -1380,7 +1389,7 @@ if test "x$with_sha1" = xlibmd; then [Use libmd SHA1 functions])
SHA1_LIBS=-lmd
fi
-AC_CHECK_LIB([sha1], [sha1_begin], [HAVE_LIBSHA1=yes])
+PKG_CHECK_MODULES([LIBSHA1], [libsha1], [HAVE_LIBSHA1=yes], [HAVE_LIBSHA1=no])
if test "x$with_sha1" = x && test "x$HAVE_LIBSHA1" = xyes; then
with_sha1=libsha1
fi
diff --git a/xorg-server/damageext/damageext.c b/xorg-server/damageext/damageext.c index dc9c2e8e2..fb60e7f72 100644 --- a/xorg-server/damageext/damageext.c +++ b/xorg-server/damageext/damageext.c @@ -32,10 +32,8 @@ static int DamageEventBase; static RESTYPE DamageExtType;
static RESTYPE DamageExtWinType;
-static int DamageClientPrivateKeyIndex;
-static DevPrivateKey DamageClientPrivateKey = &DamageClientPrivateKeyIndex;
-
-#define prScreen screenInfo.screens[0]
+static DevPrivateKeyRec DamageClientPrivateKeyRec;
+#define DamageClientPrivateKey (&DamageClientPrivateKeyRec)
static void
DamageExtNotify (DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes)
@@ -94,10 +92,10 @@ DamageExtReport (DamagePtr pDamage, RegionPtr pRegion, void *closure) switch (pDamageExt->level) {
case DamageReportRawRegion:
case DamageReportDeltaRegion:
- DamageExtNotify (pDamageExt, REGION_RECTS(pRegion), REGION_NUM_RECTS(pRegion));
+ DamageExtNotify (pDamageExt, RegionRects(pRegion), RegionNumRects(pRegion));
break;
case DamageReportBoundingBox:
- DamageExtNotify (pDamageExt, REGION_EXTENTS(prScreen, pRegion), 1);
+ DamageExtNotify (pDamageExt, RegionExtents(pRegion), 1);
break;
case DamageReportNonEmpty:
DamageExtNotify (pDamageExt, NullBox, 0);
@@ -261,14 +259,14 @@ ProcDamageSubtract (ClientPtr client) if (pRepair)
{
if (pParts)
- REGION_INTERSECT (prScreen, pParts, DamageRegion (pDamage), pRepair);
+ RegionIntersect(pParts, DamageRegion (pDamage), pRepair);
if (DamageSubtract (pDamage, pRepair))
DamageExtReport (pDamage, DamageRegion (pDamage), (void *) pDamageExt);
}
else
{
if (pParts)
- REGION_COPY (prScreen, pParts, DamageRegion (pDamage));
+ RegionCopy(pParts, DamageRegion (pDamage));
DamageEmpty (pDamage);
}
}
@@ -293,9 +291,9 @@ ProcDamageAdd (ClientPtr client) /* The region is relative to the drawable origin, so translate it out to
* screen coordinates like damage expects.
*/
- REGION_TRANSLATE(pScreen, pRegion, pDrawable->x, pDrawable->y);
+ RegionTranslate(pRegion, pDrawable->x, pDrawable->y);
DamageRegionAppend(pDrawable, pRegion);
- REGION_TRANSLATE(pScreen, pRegion, -pDrawable->x, -pDrawable->y);
+ RegionTranslate(pRegion, -pDrawable->x, -pDrawable->y);
return Success;
}
@@ -502,8 +500,9 @@ DamageExtensionInit(void) if (!DamageExtWinType)
return;
- if (!dixRequestPrivate(DamageClientPrivateKey, sizeof (DamageClientRec)))
+ if (!dixRegisterPrivateKey(&DamageClientPrivateKeyRec, PRIVATE_CLIENT, sizeof (DamageClientRec)))
return;
+
if (!AddCallback (&ClientStateCallback, DamageClientCallback, 0))
return;
diff --git a/xorg-server/dbe/dbe.c b/xorg-server/dbe/dbe.c index 80383bfc9..d1074a2fb 100644 --- a/xorg-server/dbe/dbe.c +++ b/xorg-server/dbe/dbe.c @@ -57,15 +57,13 @@ /* GLOBALS */
-/* These are static globals copied to DBE's screen private for use by DDX */
-static int dbeScreenPrivKeyIndex;
-static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKeyIndex;
-static int dbeWindowPrivKeyIndex;
-static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKeyIndex;
+/* These are globals for use by DDX */
+DevPrivateKeyRec dbeScreenPrivKeyRec;
+DevPrivateKeyRec dbeWindowPrivKeyRec;
-/* These are static globals copied to DBE's screen private for use by DDX */
-static RESTYPE dbeDrawableResType;
-static RESTYPE dbeWindowPrivResType;
+/* These are globals for use by DDX */
+RESTYPE dbeDrawableResType;
+RESTYPE dbeWindowPrivResType;
/* Used to generate DBE's BadBuffer error. */
static int dbeErrorBase;
@@ -201,7 +199,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client) /* The window must be InputOutput. */
if (pWin->drawable.class != InputOutput)
{
- return(BadMatch);
+ return BadMatch;
}
/* The swap action must be valid. */
@@ -211,7 +209,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client) (swapAction != XdbeUntouched ) &&
(swapAction != XdbeCopied ))
{
- return(BadValue);
+ return BadValue;
}
/* The id must be in range and not already in use. */
@@ -222,12 +220,12 @@ ProcDbeAllocateBackBufferName(ClientPtr client) */
pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
if (!pDbeScreenPriv->GetVisualInfo)
- return(BadMatch); /* screen doesn't support double buffering */
+ return BadMatch; /* screen doesn't support double buffering */
if (!(*pDbeScreenPriv->GetVisualInfo)(pWin->drawable.pScreen, &scrVisInfo))
{
/* GetVisualInfo() failed to allocate visual info data. */
- return(BadAlloc);
+ return BadAlloc;
}
/* See if the window's visual is on the list. */
@@ -245,7 +243,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client) if (!visualMatched)
{
- return(BadMatch);
+ return BadMatch;
}
if ((pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)) == NULL)
@@ -254,9 +252,9 @@ ProcDbeAllocateBackBufferName(ClientPtr client) * Allocate a window priv.
*/
- pDbeWindowPriv = calloc(1, sizeof(DbeWindowPrivRec));
+ pDbeWindowPriv = dixAllocateObjectWithPrivates(DbeWindowPrivRec, PRIVATE_DBE_WINDOW);
if (!pDbeWindowPriv)
- return(BadAlloc);
+ return BadAlloc;
/* Fill out window priv information. */
pDbeWindowPriv->pWindow = pWin;
@@ -323,7 +321,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client) (pDbeWindowPriv->maxAvailableIDs+DBE_INCR_MAX_IDS)*sizeof(XID));
if (!pDbeWindowPriv->IDs)
{
- return(BadAlloc);
+ return BadAlloc;
}
memset(&pDbeWindowPriv->IDs[pDbeWindowPriv->nBufferIDs], 0,
(pDbeWindowPriv->maxAvailableIDs + DBE_INCR_MAX_IDS -
@@ -379,12 +377,12 @@ ProcDbeAllocateBackBufferName(ClientPtr client) /* Set swap action on all calls. */
pDbeWindowPriv->swapAction = stuff->swapAction;
- return(status);
+ return status;
out_free:
dixSetPrivate(&pWin->devPrivates, dbeWindowPrivKey, NULL);
free(pDbeWindowPriv);
- return (status);
+ return status;
} /* ProcDbeAllocateBackBufferName() */
@@ -447,12 +445,12 @@ ProcDbeDeallocateBackBufferName(ClientPtr client) {
/* We did not find the ID in the ID list. */
client->errorValue = stuff->buffer;
- return(dbeErrorBase + DbeBadBuffer);
+ return dbeErrorBase + DbeBadBuffer;
}
FreeResource(stuff->buffer, RT_NONE);
- return(Success);
+ return Success;
} /* ProcDbeDeallocateBackBufferName() */
@@ -498,7 +496,7 @@ ProcDbeSwapBuffers(ClientPtr client) if (nStuff == 0)
{
- return(Success);
+ return Success;
}
if (nStuff > UINT32_MAX / sizeof(DbeSwapInfoRec))
@@ -511,7 +509,7 @@ ProcDbeSwapBuffers(ClientPtr client) swapInfo = (DbeSwapInfoPtr)malloc(nStuff * sizeof(DbeSwapInfoRec));
if (swapInfo == NULL)
{
- return(BadAlloc);
+ return BadAlloc;
}
@@ -531,7 +529,7 @@ ProcDbeSwapBuffers(ClientPtr client) if (DBE_WINDOW_PRIV(pWin) == NULL)
{
free(swapInfo);
- return(BadMatch);
+ return BadMatch;
}
/* Each window must only be specified once - BadMatch. */
@@ -540,7 +538,7 @@ ProcDbeSwapBuffers(ClientPtr client) if (dbeSwapInfo[i].window == dbeSwapInfo[j].window)
{
free(swapInfo);
- return(BadMatch);
+ return BadMatch;
}
}
@@ -551,7 +549,7 @@ ProcDbeSwapBuffers(ClientPtr client) (dbeSwapInfo[i].swapAction != XdbeCopied ))
{
free(swapInfo);
- return(BadValue);
+ return BadValue;
}
/* Everything checks out OK. Fill in the swap info array. */
@@ -581,12 +579,12 @@ ProcDbeSwapBuffers(ClientPtr client) if (error != Success)
{
free(swapInfo);
- return(error);
+ return error;
}
}
free(swapInfo);
- return(Success);
+ return Success;
} /* ProcDbeSwapBuffers() */
@@ -628,7 +626,7 @@ ProcDbeBeginIdiom(ClientPtr client) }
}
- return(Success);
+ return Success;
} /* ProcDbeBeginIdiom() */
@@ -675,7 +673,7 @@ ProcDbeGetVisualInfo(ClientPtr client) if (!(pDrawables = (DrawablePtr *)malloc(stuff->n *
sizeof(DrawablePtr))))
{
- return(BadAlloc);
+ return BadAlloc;
}
drawables = (Drawable *)&stuff[1];
@@ -695,12 +693,9 @@ ProcDbeGetVisualInfo(ClientPtr client) if (!(pScrVisInfo = (XdbeScreenVisualInfo *)malloc(count *
sizeof(XdbeScreenVisualInfo))))
{
- if (pDrawables)
- {
- free(pDrawables);
- }
+ free(pDrawables);
- return(BadAlloc);
+ return BadAlloc;
}
length = 0;
@@ -724,10 +719,7 @@ ProcDbeGetVisualInfo(ClientPtr client) }
/* Free pDrawables if we needed to allocate it above. */
- if (pDrawables)
- {
- free(pDrawables);
- }
+ free(pDrawables);
return (rc == Success) ? BadAlloc : rc;
}
@@ -805,10 +797,7 @@ ProcDbeGetVisualInfo(ClientPtr client) }
free(pScrVisInfo);
- if (pDrawables)
- {
- free(pDrawables);
- }
+ free(pDrawables);
return Success;
@@ -905,7 +894,7 @@ ProcDbeDispatch(ClientPtr client) return(ProcDbeBeginIdiom(client));
case X_DbeEndIdiom:
- return(Success);
+ return Success;
case X_DbeGetVisualInfo:
return(ProcDbeGetVisualInfo(client));
@@ -914,7 +903,7 @@ ProcDbeDispatch(ClientPtr client) return(ProcDbeGetBackBufferAttributes(client));
default:
- return(BadRequest);
+ return BadRequest;
}
} /* ProcDbeDispatch() */
@@ -1206,7 +1195,7 @@ SProcDbeDispatch(ClientPtr client) return(SProcDbeBeginIdiom(client));
case X_DbeEndIdiom:
- return(Success);
+ return Success;
case X_DbeGetVisualInfo:
return(SProcDbeGetVisualInfo(client));
@@ -1215,7 +1204,7 @@ SProcDbeDispatch(ClientPtr client) return(SProcDbeGetBackBufferAttributes(client));
default:
- return (BadRequest);
+ return BadRequest;
}
} /* SProcDbeDispatch() */
@@ -1280,7 +1269,7 @@ DbeSetupBackgroundPainter(WindowPtr pWin, GCPtr pGC) default:
/* pWin->backgroundState == None */
- return(FALSE);
+ return FALSE;
}
return ChangeGC(NullClient, pGC, gcmask, gcvalues) == 0;
@@ -1306,7 +1295,7 @@ DbeSetupBackgroundPainter(WindowPtr pWin, GCPtr pGC) static int
DbeDrawableDelete(pointer pDrawable, XID id)
{
- return(Success);
+ return Success;
} /* DbeDrawableDelete() */
@@ -1346,7 +1335,7 @@ DbeWindowPrivDelete(pointer pDbeWinPriv, XID id) if (i == pDbeWindowPriv->nBufferIDs)
{
/* We did not find the ID in the array. We should never get here. */
- return(BadValue);
+ return BadValue;
}
/* Remove the ID from the array. */
@@ -1410,11 +1399,10 @@ DbeWindowPrivDelete(pointer pDbeWinPriv, XID id) NULL);
/* We are done with the window priv. */
- dixFreePrivates(pDbeWindowPriv->devPrivates);
- free(pDbeWindowPriv);
+ dixFreeObjectWithPrivates(pDbeWindowPriv, PRIVATE_DBE_WINDOW);
}
- return(Success);
+ return Success;
} /* DbeWindowPrivDelete() */
@@ -1535,7 +1523,7 @@ DbeDestroyWindow(WindowPtr pWin) **************************************************************************
*/
- return(ret);
+ return ret;
} /* DbeDestroyWindow() */
@@ -1576,8 +1564,10 @@ DbeExtensionInit(void) if (!dbeWindowPrivResType)
return;
- if (!dixRegisterPrivateOffset(dbeDrawableResType,
- offsetof(PixmapRec, devPrivates)))
+ if (!dixRegisterPrivateKey(&dbeScreenPrivKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
+ if (!dixRegisterPrivateKey(&dbeWindowPrivKeyRec, PRIVATE_WINDOW, 0))
return;
for (i = 0; i < screenInfo.numScreens; i++)
@@ -1606,14 +1596,6 @@ DbeExtensionInit(void) dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, pDbeScreenPriv);
- /* Copy the resource types */
- pDbeScreenPriv->dbeDrawableResType = dbeDrawableResType;
- pDbeScreenPriv->dbeWindowPrivResType = dbeWindowPrivResType;
-
- /* Copy the private indices */
- pDbeScreenPriv->dbeScreenPrivKey = dbeScreenPrivKey;
- pDbeScreenPriv->dbeWindowPrivKey = dbeWindowPrivKey;
-
{
/* We don't have DDX support for DBE anymore */
diff --git a/xorg-server/dbe/dbestruct.h b/xorg-server/dbe/dbestruct.h index ba6b56d79..089719ba7 100644 --- a/xorg-server/dbe/dbestruct.h +++ b/xorg-server/dbe/dbestruct.h @@ -1,222 +1,214 @@ -/****************************************************************************** - * - * Copyright (c) 1994, 1995 Hewlett-Packard Company - * - * 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 HEWLETT-PACKARD COMPANY 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 of the Hewlett-Packard - * Company shall not be used in advertising or otherwise to promote the - * sale, use or other dealings in this Software without prior written - * authorization from the Hewlett-Packard Company. - * - * Header file for DIX-related DBE - * - *****************************************************************************/ - -#ifndef DBE_STRUCT_H -#define DBE_STRUCT_H - - -/* INCLUDES */ - -#define NEED_DBE_PROTOCOL -#include <X11/extensions/dbeproto.h> -#include "windowstr.h" -#include "privates.h" - -typedef struct -{ - VisualID visual; /* one visual ID that supports double-buffering */ - int depth; /* depth of visual in bits */ - int perflevel; /* performance level of visual */ -} -XdbeVisualInfo; - -typedef struct -{ - int count; /* number of items in visual_depth */ - XdbeVisualInfo *visinfo; /* list of visuals & depths for scrn */ -} -XdbeScreenVisualInfo; - -/* DEFINES */ - -#define DBE_SCREEN_PRIV(pScreen) ((DbeScreenPrivPtr) \ - dixLookupPrivate(&(pScreen)->devPrivates, dbeScreenPrivKey)) - -#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \ - DBE_SCREEN_PRIV((pDrawable)->pScreen) - -#define DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(pDbeWindowPriv) \ - DBE_SCREEN_PRIV((pDbeWindowPriv)->pWindow->drawable.pScreen) - -#define DBE_SCREEN_PRIV_FROM_WINDOW(pWindow) \ - DBE_SCREEN_PRIV((pWindow)->drawable.pScreen) - -#define DBE_SCREEN_PRIV_FROM_PIXMAP(pPixmap) \ - DBE_SCREEN_PRIV((pPixmap)->drawable.pScreen) - -#define DBE_SCREEN_PRIV_FROM_GC(pGC)\ - DBE_SCREEN_PRIV((pGC)->pScreen) - -#define DBE_WINDOW_PRIV(pWin) ((DbeWindowPrivPtr) \ - dixLookupPrivate(&(pWin)->devPrivates, dbeWindowPrivKey)) - -/* Initial size of the buffer ID array in the window priv. */ -#define DBE_INIT_MAX_IDS 2 - -/* Reallocation increment for the buffer ID array. */ -#define DBE_INCR_MAX_IDS 4 - -/* Marker for free elements in the buffer ID array. */ -#define DBE_FREE_ID_ELEMENT 0 - -extern _X_EXPORT void DbeExtensionInit (void); - -/* TYPEDEFS */ - -/* Record used to pass swap information between DIX and DDX swapping - * procedures. - */ -typedef struct _DbeSwapInfoRec -{ - WindowPtr pWindow; - unsigned char swapAction; - -} DbeSwapInfoRec, *DbeSwapInfoPtr; - -/* - ****************************************************************************** - ** Per-window data - ****************************************************************************** - */ - -typedef struct _DbeWindowPrivRec -{ - /* A pointer to the window with which the DBE window private (buffer) is - * associated. - */ - WindowPtr pWindow; - - /* Last known swap action for this buffer. Legal values for this field - * are XdbeUndefined, XdbeBackground, XdbeUntouched, and XdbeCopied. - */ - unsigned char swapAction; - - /* Last known buffer size. - */ - unsigned short width, height; - - /* Coordinates used for static gravity when the window is positioned. - */ - short x, y; - - /* Number of XIDs associated with this buffer. - */ - int nBufferIDs; - - /* Capacity of the current buffer ID array, IDs. */ - int maxAvailableIDs; - - /* Pointer to the array of buffer IDs. This initially points to initIDs. - * When the static limit of the initIDs array is reached, the array is - * reallocated and this pointer is set to the new array instead of initIDs. - */ - XID *IDs; - - /* Initial array of buffer IDs. We are defining the XID array within the - * window priv to optimize for data locality. In most cases, only one - * buffer will be associated with a window. Having the array declared - * here can prevent us from accessing the data in another memory page, - * possibly resulting in a page swap and loss of performance. Initially we - * will use this array to store buffer IDs. For situations where we have - * more IDs than can fit in this static array, we will allocate a larger - * array to use, possibly suffering a performance loss. - */ - XID initIDs[DBE_INIT_MAX_IDS]; - - /* Device-specific private information. - */ - PrivateRec *devPrivates; - -} DbeWindowPrivRec, *DbeWindowPrivPtr; - - -/* - ****************************************************************************** - ** Per-screen data - ****************************************************************************** - */ - -typedef struct _DbeScreenPrivRec -{ - /* Resources created by DIX to be used by DDX */ - RESTYPE dbeDrawableResType; - RESTYPE dbeWindowPrivResType; - - /* Private indices created by DIX to be used by DDX */ - DevPrivateKey dbeScreenPrivKey; - DevPrivateKey dbeWindowPrivKey; - - /* Wrapped functions - * It is the responsibilty of the DDX layer to wrap PositionWindow(). - * DbeExtensionInit wraps DestroyWindow(). - */ - PositionWindowProcPtr PositionWindow; - DestroyWindowProcPtr DestroyWindow; - - /* Per-screen DIX routines */ - Bool (*SetupBackgroundPainter)( - WindowPtr /*pWin*/, - GCPtr /*pGC*/ -); - - /* Per-screen DDX routines */ - Bool (*GetVisualInfo)( - ScreenPtr /*pScreen*/, - XdbeScreenVisualInfo * /*pVisInfo*/ -); - int (*AllocBackBufferName)( - WindowPtr /*pWin*/, - XID /*bufId*/, - int /*swapAction*/ -); - int (*SwapBuffers)( - ClientPtr /*client*/, - int * /*pNumWindows*/, - DbeSwapInfoPtr /*swapInfo*/ -); - void (*BeginIdiom)( - ClientPtr /*client*/ -); - void (*EndIdiom)( - ClientPtr /*client*/ -); - void (*WinPrivDelete)( - DbeWindowPrivPtr /*pDbeWindowPriv*/, - XID /*bufId*/ -); - void (*ResetProc)( - ScreenPtr /*pScreen*/ -); - -} DbeScreenPrivRec, *DbeScreenPrivPtr; - -#endif /* DBE_STRUCT_H */ +/******************************************************************************
+ *
+ * Copyright (c) 1994, 1995 Hewlett-Packard Company
+ *
+ * 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 HEWLETT-PACKARD COMPANY 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 of the Hewlett-Packard
+ * Company shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Hewlett-Packard Company.
+ *
+ * Header file for DIX-related DBE
+ *
+ *****************************************************************************/
+
+#ifndef DBE_STRUCT_H
+#define DBE_STRUCT_H
+
+
+/* INCLUDES */
+
+#define NEED_DBE_PROTOCOL
+#include <X11/extensions/dbeproto.h>
+#include "windowstr.h"
+#include "privates.h"
+
+typedef struct
+{
+ VisualID visual; /* one visual ID that supports double-buffering */
+ int depth; /* depth of visual in bits */
+ int perflevel; /* performance level of visual */
+}
+XdbeVisualInfo;
+
+typedef struct
+{
+ int count; /* number of items in visual_depth */
+ XdbeVisualInfo *visinfo; /* list of visuals & depths for scrn */
+}
+XdbeScreenVisualInfo;
+
+/* DEFINES */
+
+#define DBE_SCREEN_PRIV(pScreen) ((DbeScreenPrivPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, dbeScreenPrivKey))
+
+#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \
+ DBE_SCREEN_PRIV((pDrawable)->pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(pDbeWindowPriv) \
+ DBE_SCREEN_PRIV((pDbeWindowPriv)->pWindow->drawable.pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_WINDOW(pWindow) \
+ DBE_SCREEN_PRIV((pWindow)->drawable.pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_PIXMAP(pPixmap) \
+ DBE_SCREEN_PRIV((pPixmap)->drawable.pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_GC(pGC)\
+ DBE_SCREEN_PRIV((pGC)->pScreen)
+
+#define DBE_WINDOW_PRIV(pWin) ((DbeWindowPrivPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, dbeWindowPrivKey))
+
+/* Initial size of the buffer ID array in the window priv. */
+#define DBE_INIT_MAX_IDS 2
+
+/* Reallocation increment for the buffer ID array. */
+#define DBE_INCR_MAX_IDS 4
+
+/* Marker for free elements in the buffer ID array. */
+#define DBE_FREE_ID_ELEMENT 0
+
+extern _X_EXPORT void DbeExtensionInit (void);
+
+/* TYPEDEFS */
+
+/* Record used to pass swap information between DIX and DDX swapping
+ * procedures.
+ */
+typedef struct _DbeSwapInfoRec
+{
+ WindowPtr pWindow;
+ unsigned char swapAction;
+
+} DbeSwapInfoRec, *DbeSwapInfoPtr;
+
+/*
+ ******************************************************************************
+ ** Per-window data
+ ******************************************************************************
+ */
+
+typedef struct _DbeWindowPrivRec
+{
+ /* A pointer to the window with which the DBE window private (buffer) is
+ * associated.
+ */
+ WindowPtr pWindow;
+
+ /* Last known swap action for this buffer. Legal values for this field
+ * are XdbeUndefined, XdbeBackground, XdbeUntouched, and XdbeCopied.
+ */
+ unsigned char swapAction;
+
+ /* Last known buffer size.
+ */
+ unsigned short width, height;
+
+ /* Coordinates used for static gravity when the window is positioned.
+ */
+ short x, y;
+
+ /* Number of XIDs associated with this buffer.
+ */
+ int nBufferIDs;
+
+ /* Capacity of the current buffer ID array, IDs. */
+ int maxAvailableIDs;
+
+ /* Pointer to the array of buffer IDs. This initially points to initIDs.
+ * When the static limit of the initIDs array is reached, the array is
+ * reallocated and this pointer is set to the new array instead of initIDs.
+ */
+ XID *IDs;
+
+ /* Initial array of buffer IDs. We are defining the XID array within the
+ * window priv to optimize for data locality. In most cases, only one
+ * buffer will be associated with a window. Having the array declared
+ * here can prevent us from accessing the data in another memory page,
+ * possibly resulting in a page swap and loss of performance. Initially we
+ * will use this array to store buffer IDs. For situations where we have
+ * more IDs than can fit in this static array, we will allocate a larger
+ * array to use, possibly suffering a performance loss.
+ */
+ XID initIDs[DBE_INIT_MAX_IDS];
+
+ /* Device-specific private information.
+ */
+ PrivateRec *devPrivates;
+
+} DbeWindowPrivRec, *DbeWindowPrivPtr;
+
+
+/*
+ ******************************************************************************
+ ** Per-screen data
+ ******************************************************************************
+ */
+
+typedef struct _DbeScreenPrivRec
+{
+ /* Wrapped functions
+ * It is the responsibilty of the DDX layer to wrap PositionWindow().
+ * DbeExtensionInit wraps DestroyWindow().
+ */
+ PositionWindowProcPtr PositionWindow;
+ DestroyWindowProcPtr DestroyWindow;
+
+ /* Per-screen DIX routines */
+ Bool (*SetupBackgroundPainter)(
+ WindowPtr /*pWin*/,
+ GCPtr /*pGC*/
+);
+
+ /* Per-screen DDX routines */
+ Bool (*GetVisualInfo)(
+ ScreenPtr /*pScreen*/,
+ XdbeScreenVisualInfo * /*pVisInfo*/
+);
+ int (*AllocBackBufferName)(
+ WindowPtr /*pWin*/,
+ XID /*bufId*/,
+ int /*swapAction*/
+);
+ int (*SwapBuffers)(
+ ClientPtr /*client*/,
+ int * /*pNumWindows*/,
+ DbeSwapInfoPtr /*swapInfo*/
+);
+ void (*BeginIdiom)(
+ ClientPtr /*client*/
+);
+ void (*EndIdiom)(
+ ClientPtr /*client*/
+);
+ void (*WinPrivDelete)(
+ DbeWindowPrivPtr /*pDbeWindowPriv*/,
+ XID /*bufId*/
+);
+ void (*ResetProc)(
+ ScreenPtr /*pScreen*/
+);
+
+} DbeScreenPrivRec, *DbeScreenPrivPtr;
+
+#endif /* DBE_STRUCT_H */
diff --git a/xorg-server/dbe/midbe.c b/xorg-server/dbe/midbe.c index cba386c0b..15ae85b36 100644 --- a/xorg-server/dbe/midbe.c +++ b/xorg-server/dbe/midbe.c @@ -58,14 +58,8 @@ #include <stdio.h>
-static int miDbeWindowPrivPrivKeyIndex;
-static DevPrivateKey miDbeWindowPrivPrivKey = &miDbeWindowPrivPrivKeyIndex;
-static RESTYPE dbeDrawableResType;
-static RESTYPE dbeWindowPrivResType;
-static int dbeScreenPrivKeyIndex;
-static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKeyIndex;
-static int dbeWindowPrivKeyIndex;
-static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKeyIndex;
+static DevPrivateKeyRec miDbeWindowPrivPrivKeyRec;
+#define miDbeWindowPrivPrivKey (&miDbeWindowPrivPrivKeyRec)
/******************************************************************************
@@ -102,7 +96,7 @@ miDbeGetVisualInfo(ScreenPtr pScreen, XdbeScreenVisualInfo *pScrVisInfo) /* Allocate an array of XdbeVisualInfo items. */
if (!(visInfo = (XdbeVisualInfo *)malloc(count * sizeof(XdbeVisualInfo))))
{
- return(FALSE); /* memory alloc failure */
+ return FALSE; /* memory alloc failure */
}
for (i = 0, k = 0; i < pScreen->numDepths; i++)
@@ -131,7 +125,7 @@ miDbeGetVisualInfo(ScreenPtr pScreen, XdbeScreenVisualInfo *pScrVisInfo) pScrVisInfo->count = count;
pScrVisInfo->visinfo = visInfo;
- return(TRUE); /* success */
+ return TRUE; /* success */
} /* miDbeGetVisualInfo() */
@@ -181,7 +175,7 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction) pDbeWindowPriv->height,
pWin->drawable.depth, 0)))
{
- return(BadAlloc);
+ return BadAlloc;
}
/* Get a back pixmap. */
@@ -191,7 +185,7 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction) pWin->drawable.depth, 0)))
{
(*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pFrontBuffer);
- return(BadAlloc);
+ return BadAlloc;
}
/* Security creation/labeling check. */
@@ -241,12 +235,12 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction) if (!AddResource(bufId, dbeDrawableResType,
(pointer)pDbeWindowPrivPriv->pBackBuffer))
{
- return(BadAlloc);
+ return BadAlloc;
}
}
- return(Success);
+ return Success;
} /* miDbeAllocBackBufferName() */
@@ -415,7 +409,7 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo) FreeScratchGC(pGC);
- return(Success);
+ return Success;
} /* miSwapBuffers() */
@@ -577,13 +571,13 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) if (!(pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)))
{
- return(ret);
+ return ret;
}
if (pDbeWindowPriv->width == pWin->drawable.width &&
pDbeWindowPriv->height == pWin->drawable.height)
{
- return(ret);
+ return ret;
}
width = pWin->drawable.width;
@@ -684,7 +678,7 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) }
FreeScratchGC(pGC);
- return(FALSE);
+ return FALSE;
}
else
@@ -695,25 +689,33 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
- ValidateGC((DrawablePtr)pFrontBuffer, pGC);
/* I suppose this could avoid quite a bit of work if
* it computed the minimal area required.
*/
+ ValidateGC(&pFrontBuffer->drawable, pGC);
if (clear)
{
(*pGC->ops->PolyFillRect)((DrawablePtr)pFrontBuffer, pGC, 1,
&clearRect);
- (*pGC->ops->PolyFillRect)((DrawablePtr)pBackBuffer , pGC, 1,
- &clearRect);
- }
-
- /* Copy the contents of the old DBE pixmaps to the new pixmaps. */
+ }
+ /* Copy the contents of the old front pixmap to the new one. */
if (pWin->bitGravity != ForgetGravity)
{
(*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer,
(DrawablePtr)pFrontBuffer, pGC, sourcex,
sourcey, savewidth, saveheight, destx, desty);
+ }
+
+ ValidateGC(&pBackBuffer->drawable, pGC);
+ if (clear)
+ {
+ (*pGC->ops->PolyFillRect)((DrawablePtr)pBackBuffer , pGC, 1,
+ &clearRect);
+ }
+ /* Copy the contents of the old back pixmap to the new one. */
+ if (pWin->bitGravity != ForgetGravity)
+ {
(*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
(DrawablePtr)pBackBuffer, pGC, sourcex,
sourcey, savewidth, saveheight, destx, desty);
@@ -735,7 +737,7 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) FreeScratchGC(pGC);
}
- return(ret);
+ return ret;
} /* miDbePositionWindow() */
@@ -779,17 +781,9 @@ miDbeResetProc(ScreenPtr pScreen) Bool
miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
{
- /* Copy resource types created by DIX */
- dbeDrawableResType = pDbeScreenPriv->dbeDrawableResType;
- dbeWindowPrivResType = pDbeScreenPriv->dbeWindowPrivResType;
-
- /* Copy private indices created by DIX */
- dbeScreenPrivKey = pDbeScreenPriv->dbeScreenPrivKey;
- dbeWindowPrivKey = pDbeScreenPriv->dbeWindowPrivKey;
-
- if (!dixRequestPrivate(miDbeWindowPrivPrivKey,
- sizeof(MiDbeWindowPrivPrivRec)))
- return(FALSE);
+ if (!dixRegisterPrivateKey(&miDbeWindowPrivPrivKeyRec, PRIVATE_DBE_WINDOW,
+ sizeof(MiDbeWindowPrivPrivRec)))
+ return FALSE;
/* Wrap functions. */
pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
@@ -804,6 +798,6 @@ miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv) pDbeScreenPriv->ResetProc = miDbeResetProc;
pDbeScreenPriv->WinPrivDelete = miDbeWinPrivDelete;
- return(TRUE);
+ return TRUE;
} /* miDbeInit() */
diff --git a/xorg-server/dbe/midbe.h b/xorg-server/dbe/midbe.h index 007f2e37b..4f09bf432 100644 --- a/xorg-server/dbe/midbe.h +++ b/xorg-server/dbe/midbe.h @@ -1,47 +1,58 @@ -/****************************************************************************** - * Copyright (c) 1994, 1995 Hewlett-Packard Company - * - * 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 HEWLETT-PACKARD COMPANY 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 of the Hewlett-Packard - * Company shall not be used in advertising or otherwise to promote the - * sale, use or other dealings in this Software without prior written - * authorization from the Hewlett-Packard Company. - * - * Header file for users of machine-independent DBE code - * - *****************************************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef MIDBE_H -#define MIDBE_H - -/* EXTERNS */ - -extern Bool miDbeInit( - ScreenPtr pScreen, - DbeScreenPrivPtr pDbeScreenPriv -); - -#endif /* MIDBE_H */ - +/******************************************************************************
+ * Copyright (c) 1994, 1995 Hewlett-Packard Company
+ *
+ * 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 HEWLETT-PACKARD COMPANY 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 of the Hewlett-Packard
+ * Company shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Hewlett-Packard Company.
+ *
+ * Header file for users of machine-independent DBE code
+ *
+ *****************************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef MIDBE_H
+#define MIDBE_H
+
+#include "privates.h"
+
+/* EXTERNS */
+
+extern Bool miDbeInit(
+ ScreenPtr pScreen,
+ DbeScreenPrivPtr pDbeScreenPriv
+);
+
+extern DevPrivateKeyRec dbeScreenPrivKeyRec;
+#define dbeScreenPrivKey (&dbeScreenPrivKeyRec)
+
+extern DevPrivateKeyRec dbeWindowPrivKeyRec;
+#define dbeWindowPrivKey (&dbeWindowPrivKeyRec)
+
+extern RESTYPE dbeDrawableResType;
+extern RESTYPE dbeWindowPrivResType;
+
+#endif /* MIDBE_H */
+
diff --git a/xorg-server/dix/Makefile.am b/xorg-server/dix/Makefile.am index 42b5121fe..8e6f7dd6a 100644 --- a/xorg-server/dix/Makefile.am +++ b/xorg-server/dix/Makefile.am @@ -1,73 +1,74 @@ -noinst_LTLIBRARIES = libdix.la libmain.la - -AM_CFLAGS = $(DIX_CFLAGS) - -libmain_la_SOURCES = \ - main.c - -libdix_la_SOURCES = \ - atom.c \ - colormap.c \ - cursor.c \ - deprecated.c \ - devices.c \ - dispatch.c \ - dispatch.h \ - dixfonts.c \ - dixutils.c \ - enterleave.c \ - enterleave.h \ - events.c \ - eventconvert.c \ - extension.c \ - ffs.c \ - gc.c \ - getevents.c \ - globals.c \ - glyphcurs.c \ - grabs.c \ - initatoms.c \ - inpututils.c \ - pixmap.c \ - privates.c \ - property.c \ - ptrveloc.c \ - registry.c \ - resource.c \ - selection.c \ - swaprep.c \ - swapreq.c \ - tables.c \ - window.c - -EXTRA_DIST = buildatoms BuiltInAtoms Xserver.d Xserver-dtrace.h.in - -# Install list of protocol names -miscconfigdir = $(SERVER_MISC_CONFIG_PATH) -dist_miscconfig_DATA = protocol.txt - -if XSERVER_DTRACE -# Generate dtrace header file for C sources to include -BUILT_SOURCES = Xserver-dtrace.h - -Xserver-dtrace.h: $(srcdir)/Xserver.d - $(AM_V_GEN)$(DTRACE) -C -h -o $@ -s $(srcdir)/Xserver.d \ - || cp Xserver-dtrace.h.in $@ - -endif - -if SPECIAL_DTRACE_OBJECTS -# Generate dtrace object code for probes in libdix -dtrace-dix.o: $(top_srcdir)/dix/Xserver.d $(am_libdix_la_OBJECTS) - $(AM_V_GEN)$(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d $(am_libdix_la_OBJECTS:%.lo=.libs/%.o) - -noinst_PROGRAMS = dix.O - -dix.O: dtrace-dix.o $(am_libdix_la_OBJECTS) - $(AM_V_GEN)ld -r -o $@ $(am_libdix_la_OBJECTS:%.lo=.libs/%.o) -endif - -dix.c: - touch $@ - -CLEANFILES = dix.c Xserver-dtrace.h +noinst_LTLIBRARIES = libdix.la libmain.la
+
+AM_CFLAGS = $(DIX_CFLAGS)
+
+libmain_la_SOURCES = \
+ main.c
+
+libdix_la_SOURCES = \
+ atom.c \
+ colormap.c \
+ cursor.c \
+ deprecated.c \
+ devices.c \
+ dispatch.c \
+ dispatch.h \
+ dixfonts.c \
+ dixutils.c \
+ enterleave.c \
+ enterleave.h \
+ events.c \
+ eventconvert.c \
+ extension.c \
+ ffs.c \
+ gc.c \
+ getevents.c \
+ globals.c \
+ glyphcurs.c \
+ grabs.c \
+ initatoms.c \
+ inpututils.c \
+ pixmap.c \
+ privates.c \
+ property.c \
+ ptrveloc.c \
+ region.c \
+ registry.c \
+ resource.c \
+ selection.c \
+ swaprep.c \
+ swapreq.c \
+ tables.c \
+ window.c
+
+EXTRA_DIST = buildatoms BuiltInAtoms Xserver.d Xserver-dtrace.h.in
+
+# Install list of protocol names
+miscconfigdir = $(SERVER_MISC_CONFIG_PATH)
+dist_miscconfig_DATA = protocol.txt
+
+if XSERVER_DTRACE
+# Generate dtrace header file for C sources to include
+BUILT_SOURCES = Xserver-dtrace.h
+
+Xserver-dtrace.h: $(srcdir)/Xserver.d
+ $(AM_V_GEN)$(DTRACE) -C -h -o $@ -s $(srcdir)/Xserver.d \
+ || cp Xserver-dtrace.h.in $@
+
+endif
+
+if SPECIAL_DTRACE_OBJECTS
+# Generate dtrace object code for probes in libdix
+dtrace-dix.o: $(top_srcdir)/dix/Xserver.d $(am_libdix_la_OBJECTS)
+ $(AM_V_GEN)$(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d $(am_libdix_la_OBJECTS:%.lo=.libs/%.o)
+
+noinst_PROGRAMS = dix.O
+
+dix.O: dtrace-dix.o $(am_libdix_la_OBJECTS)
+ $(AM_V_GEN)ld -r -o $@ $(am_libdix_la_OBJECTS:%.lo=.libs/%.o)
+endif
+
+dix.c:
+ touch $@
+
+CLEANFILES = dix.c Xserver-dtrace.h
diff --git a/xorg-server/dix/colormap.c b/xorg-server/dix/colormap.c index e22c35cb8..d8c702703 100644 --- a/xorg-server/dix/colormap.c +++ b/xorg-server/dix/colormap.c @@ -1,2762 +1,2773 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include <stdio.h> -#include <string.h> -#include <strings.h> -#include "misc.h" -#include "dix.h" -#include "dixstruct.h" -#include "colormapst.h" -#include "os.h" -#include "scrnintstr.h" -#include "resource.h" -#include "windowstr.h" -#include "privates.h" -#include "xace.h" - -#ifdef _MSC_VER -#define UpdateColors thisUpdateColors -#endif - -static Pixel FindBestPixel( - EntryPtr /*pentFirst*/, - int /*size*/, - xrgb * /*prgb*/, - int /*channel*/ -); - -static int AllComp( - EntryPtr /*pent*/, - xrgb * /*prgb*/ -); - -static int RedComp( - EntryPtr /*pent*/, - xrgb * /*prgb*/ -); - -static int GreenComp( - EntryPtr /*pent*/, - xrgb * /*prgb*/ -); - -static int BlueComp( - EntryPtr /*pent*/, - xrgb * /*prgb*/ -); - -static void FreePixels( - ColormapPtr /*pmap*/, - int /*client*/ -); - -static void CopyFree( - int /*channel*/, - int /*client*/, - ColormapPtr /*pmapSrc*/, - ColormapPtr /*pmapDst*/ -); - -static void FreeCell( - ColormapPtr /*pmap*/, - Pixel /*i*/, - int /*channel*/ -); - -static void UpdateColors( - ColormapPtr /*pmap*/ -); - -static int AllocDirect( - int /*client*/, - ColormapPtr /*pmap*/, - int /*c*/, - int /*r*/, - int /*g*/, - int /*b*/, - Bool /*contig*/, - Pixel * /*pixels*/, - Pixel * /*prmask*/, - Pixel * /*pgmask*/, - Pixel * /*pbmask*/ -); - -static int AllocPseudo( - int /*client*/, - ColormapPtr /*pmap*/, - int /*c*/, - int /*r*/, - Bool /*contig*/, - Pixel * /*pixels*/, - Pixel * /*pmask*/, - Pixel ** /*pppixFirst*/ -); - -static Bool AllocCP( - ColormapPtr /*pmap*/, - EntryPtr /*pentFirst*/, - int /*count*/, - int /*planes*/, - Bool /*contig*/, - Pixel * /*pixels*/, - Pixel * /*pMask*/ -); - -static Bool AllocShared( - ColormapPtr /*pmap*/, - Pixel * /*ppix*/, - int /*c*/, - int /*r*/, - int /*g*/, - int /*b*/, - Pixel /*rmask*/, - Pixel /*gmask*/, - Pixel /*bmask*/, - Pixel * /*ppixFirst*/ -); - -static int FreeCo( - ColormapPtr /*pmap*/, - int /*client*/, - int /*color*/, - int /*npixIn*/, - Pixel * /*ppixIn*/, - Pixel /*mask*/ -); - -static int TellNoMap( - WindowPtr /*pwin*/, - Colormap * /*pmid*/ -); - -static void FindColorInRootCmap ( - ColormapPtr /* pmap */, - EntryPtr /* pentFirst */, - int /* size */, - xrgb* /* prgb */, - Pixel* /* pPixel */, - int /* channel */, - ColorCompareProcPtr /* comp */ -); - -#define NUMRED(vis) ((vis->redMask >> vis->offsetRed) + 1) -#define NUMGREEN(vis) ((vis->greenMask >> vis->offsetGreen) + 1) -#define NUMBLUE(vis) ((vis->blueMask >> vis->offsetBlue) + 1) -#if COMPOSITE -#define ALPHAMASK(vis) ((vis)->nplanes < 32 ? 0 : \ - (CARD32) ~((vis)->redMask|(vis)->greenMask|(vis)->blueMask)) -#else -#define ALPHAMASK(vis) 0 -#endif - -#define RGBMASK(vis) (vis->redMask | vis->greenMask | vis->blueMask | ALPHAMASK(vis)) - -/* GetNextBitsOrBreak(bits, mask, base) -- - * (Suggestion: First read the macro, then read this explanation. - * - * Either generate the next value to OR in to a pixel or break out of this - * while loop - * - * This macro is used when we're trying to generate all 2^n combinations of - * bits in mask. What we're doing here is counting in binary, except that - * the bits we use to count may not be contiguous. This macro will be - * called 2^n times, returning a different value in bits each time. Then - * it will cause us to break out of a surrounding loop. (It will always be - * called from within a while loop.) - * On call: mask is the value we want to find all the combinations for - * base has 1 bit set where the least significant bit of mask is set - * - * For example,if mask is 01010, base should be 0010 and we count like this: - * 00010 (see this isn't so hard), - * then we add base to bits and get 0100. (bits & ~mask) is (0100 & 0100) so - * we add that to bits getting (0100 + 0100) = - * 01000 for our next value. - * then we add 0010 to get - * 01010 and we're done (easy as 1, 2, 3) - */ -#define GetNextBitsOrBreak(bits, mask, base) \ - if((bits) == (mask)) \ - break; \ - (bits) += (base); \ - while((bits) & ~(mask)) \ - (bits) += ((bits) & ~(mask)); -/* ID of server as client */ -#define SERVER_ID 0 - -typedef struct _colorResource -{ - Colormap mid; - int client; -} colorResource; - -/* Invariants: - * refcnt == 0 means entry is empty - * refcnt > 0 means entry is useable by many clients, so it can't be changed - * refcnt == AllocPrivate means entry owned by one client only - * fShared should only be set if refcnt == AllocPrivate, and only in red map - */ - - -/** - * Create and initialize the color map - * - * \param mid resource to use for this colormap - * \param alloc 1 iff all entries are allocated writable - */ -int -CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, - ColormapPtr *ppcmap, int alloc, int client) -{ - int class, size; - unsigned long sizebytes; - ColormapPtr pmap; - EntryPtr pent; - int i; - Pixel *ppix, **pptr; - - class = pVisual->class; - if(!(class & DynamicClass) && (alloc != AllocNone) && (client != SERVER_ID)) - return (BadMatch); - - size = pVisual->ColormapEntries; - sizebytes = (size * sizeof(Entry)) + - (MAXCLIENTS * sizeof(Pixel *)) + - (MAXCLIENTS * sizeof(int)); - if ((class | DynamicClass) == DirectColor) - sizebytes *= 3; - sizebytes += sizeof(ColormapRec); - pmap = malloc(sizebytes); - if (!pmap) - return (BadAlloc); -#if defined(_XSERVER64) - pmap->pad0 = 0; - pmap->pad1 = 0; -#if (X_BYTE_ORDER == X_LITTLE_ENDIAN) - pmap->pad2 = 0; -#endif -#endif - pmap->red = (EntryPtr)((char *)pmap + sizeof(ColormapRec)); - sizebytes = size * sizeof(Entry); - pmap->clientPixelsRed = (Pixel **)((char *)pmap->red + sizebytes); - pmap->numPixelsRed = (int *)((char *)pmap->clientPixelsRed + - (MAXCLIENTS * sizeof(Pixel *))); - pmap->mid = mid; - pmap->flags = 0; /* start out with all flags clear */ - if(mid == pScreen->defColormap) - pmap->flags |= IsDefault; - pmap->pScreen = pScreen; - pmap->pVisual = pVisual; - pmap->class = class; - if ((class | DynamicClass) == DirectColor) - size = NUMRED(pVisual); - pmap->freeRed = size; - bzero ((char *) pmap->red, (int)sizebytes); - bzero((char *) pmap->numPixelsRed, MAXCLIENTS * sizeof(int)); - for (pptr = &pmap->clientPixelsRed[MAXCLIENTS]; --pptr >= pmap->clientPixelsRed; ) - *pptr = (Pixel *)NULL; - if (alloc == AllocAll) - { - if (class & DynamicClass) - pmap->flags |= AllAllocated; - for (pent = &pmap->red[size - 1]; pent >= pmap->red; pent--) - pent->refcnt = AllocPrivate; - pmap->freeRed = 0; - ppix = malloc(size * sizeof(Pixel)); - if (!ppix) - { - free(pmap); - return (BadAlloc); - } - pmap->clientPixelsRed[client] = ppix; - for(i = 0; i < size; i++) - ppix[i] = i; - pmap->numPixelsRed[client] = size; - } - - if ((class | DynamicClass) == DirectColor) - { - pmap->freeGreen = NUMGREEN(pVisual); - pmap->green = (EntryPtr)((char *)pmap->numPixelsRed + - (MAXCLIENTS * sizeof(int))); - pmap->clientPixelsGreen = (Pixel **)((char *)pmap->green + sizebytes); - pmap->numPixelsGreen = (int *)((char *)pmap->clientPixelsGreen + - (MAXCLIENTS * sizeof(Pixel *))); - pmap->freeBlue = NUMBLUE(pVisual); - pmap->blue = (EntryPtr)((char *)pmap->numPixelsGreen + - (MAXCLIENTS * sizeof(int))); - pmap->clientPixelsBlue = (Pixel **)((char *)pmap->blue + sizebytes); - pmap->numPixelsBlue = (int *)((char *)pmap->clientPixelsBlue + - (MAXCLIENTS * sizeof(Pixel *))); - - bzero ((char *) pmap->green, (int)sizebytes); - bzero ((char *) pmap->blue, (int)sizebytes); - - memmove((char *) pmap->clientPixelsGreen, - (char *) pmap->clientPixelsRed, - MAXCLIENTS * sizeof(Pixel *)); - memmove((char *) pmap->clientPixelsBlue, - (char *) pmap->clientPixelsRed, - MAXCLIENTS * sizeof(Pixel *)); - bzero((char *) pmap->numPixelsGreen, MAXCLIENTS * sizeof(int)); - bzero((char *) pmap->numPixelsBlue, MAXCLIENTS * sizeof(int)); - - /* If every cell is allocated, mark its refcnt */ - if (alloc == AllocAll) - { - size = pmap->freeGreen; - for(pent = &pmap->green[size-1]; pent >= pmap->green; pent--) - pent->refcnt = AllocPrivate; - pmap->freeGreen = 0; - ppix = malloc(size * sizeof(Pixel)); - if (!ppix) - { - free(pmap->clientPixelsRed[client]); - free(pmap); - return(BadAlloc); - } - pmap->clientPixelsGreen[client] = ppix; - for(i = 0; i < size; i++) - ppix[i] = i; - pmap->numPixelsGreen[client] = size; - - size = pmap->freeBlue; - for(pent = &pmap->blue[size-1]; pent >= pmap->blue; pent--) - pent->refcnt = AllocPrivate; - pmap->freeBlue = 0; - ppix = malloc(size * sizeof(Pixel)); - if (!ppix) - { - free(pmap->clientPixelsGreen[client]); - free(pmap->clientPixelsRed[client]); - free(pmap); - return(BadAlloc); - } - pmap->clientPixelsBlue[client] = ppix; - for(i = 0; i < size; i++) - ppix[i] = i; - pmap->numPixelsBlue[client] = size; - } - } - pmap->devPrivates = NULL; - pmap->flags |= BeingCreated; - - if (!AddResource(mid, RT_COLORMAP, (pointer)pmap)) - return (BadAlloc); - - /* - * Security creation/labeling check - */ - i = XaceHook(XACE_RESOURCE_ACCESS, clients[client], mid, RT_COLORMAP, - pmap, RT_NONE, NULL, DixCreateAccess); - if (i != Success) { - FreeResource(mid, RT_NONE); - return i; - } - - /* If the device wants a chance to initialize the colormap in any way, - * this is it. In specific, if this is a Static colormap, this is the - * time to fill in the colormap's values */ - if (!(*pScreen->CreateColormap)(pmap)) - { - FreeResource (mid, RT_NONE); - return BadAlloc; - } - pmap->flags &= ~BeingCreated; - *ppcmap = pmap; - return (Success); -} - -/** - * - * \param value must conform to DeleteType - */ -int -FreeColormap (pointer value, XID mid) -{ - int i; - EntryPtr pent; - ColormapPtr pmap = (ColormapPtr)value; - - if(CLIENT_ID(mid) != SERVER_ID) - { - (*pmap->pScreen->UninstallColormap) (pmap); - WalkTree(pmap->pScreen, (VisitWindowProcPtr)TellNoMap, (pointer) &mid); - } - - /* This is the device's chance to undo anything it needs to, especially - * to free any storage it allocated */ - (*pmap->pScreen->DestroyColormap)(pmap); - - if(pmap->clientPixelsRed) - { - for(i = 0; i < MAXCLIENTS; i++) - free(pmap->clientPixelsRed[i]); - } - - if ((pmap->class == PseudoColor) || (pmap->class == GrayScale)) - { - for(pent = &pmap->red[pmap->pVisual->ColormapEntries - 1]; - pent >= pmap->red; - pent--) - { - if(pent->fShared) - { - if (--pent->co.shco.red->refcnt == 0) - free(pent->co.shco.red); - if (--pent->co.shco.green->refcnt == 0) - free(pent->co.shco.green); - if (--pent->co.shco.blue->refcnt == 0) - free(pent->co.shco.blue); - } - } - } - if((pmap->class | DynamicClass) == DirectColor) - { - for(i = 0; i < MAXCLIENTS; i++) - { - free(pmap->clientPixelsGreen[i]); - free(pmap->clientPixelsBlue[i]); - } - } - - dixFreePrivates(pmap->devPrivates); - free(pmap); - return(Success); -} - -/* Tell window that pmid has disappeared */ -static int -TellNoMap (WindowPtr pwin, Colormap *pmid) -{ - xEvent xE; - - if (wColormap(pwin) == *pmid) - { - /* This should be call to DeliverEvent */ - xE.u.u.type = ColormapNotify; - xE.u.colormap.window = pwin->drawable.id; - xE.u.colormap.colormap = None; - xE.u.colormap.new = TRUE; - xE.u.colormap.state = ColormapUninstalled; -#ifdef PANORAMIX - if(noPanoramiXExtension || !pwin->drawable.pScreen->myNum) -#endif - DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL); - if (pwin->optional) { - pwin->optional->colormap = None; - CheckWindowOptionalNeed (pwin); - } - } - - return (WT_WALKCHILDREN); -} - -/* Tell window that pmid got uninstalled */ -int -TellLostMap (WindowPtr pwin, pointer value) -{ - Colormap *pmid = (Colormap *)value; - xEvent xE; - -#ifdef PANORAMIX - if(!noPanoramiXExtension && pwin->drawable.pScreen->myNum) - return WT_STOPWALKING; -#endif - if (wColormap(pwin) == *pmid) - { - /* This should be call to DeliverEvent */ - xE.u.u.type = ColormapNotify; - xE.u.colormap.window = pwin->drawable.id; - xE.u.colormap.colormap = *pmid; - xE.u.colormap.new = FALSE; - xE.u.colormap.state = ColormapUninstalled; - DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL); - } - - return (WT_WALKCHILDREN); -} - -/* Tell window that pmid got installed */ -int -TellGainedMap (WindowPtr pwin, pointer value) -{ - Colormap *pmid = (Colormap *)value; - xEvent xE; - -#ifdef PANORAMIX - if(!noPanoramiXExtension && pwin->drawable.pScreen->myNum) - return WT_STOPWALKING; -#endif - if (wColormap (pwin) == *pmid) - { - /* This should be call to DeliverEvent */ - xE.u.u.type = ColormapNotify; - xE.u.colormap.window = pwin->drawable.id; - xE.u.colormap.colormap = *pmid; - xE.u.colormap.new = FALSE; - xE.u.colormap.state = ColormapInstalled; - DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL); - } - - return (WT_WALKCHILDREN); -} - - -int -CopyColormapAndFree (Colormap mid, ColormapPtr pSrc, int client) -{ - ColormapPtr pmap = (ColormapPtr) NULL; - int result, alloc, size; - Colormap midSrc; - ScreenPtr pScreen; - VisualPtr pVisual; - - pScreen = pSrc->pScreen; - pVisual = pSrc->pVisual; - midSrc = pSrc->mid; - alloc = ((pSrc->flags & AllAllocated) && CLIENT_ID(midSrc) == client) ? - AllocAll : AllocNone; - size = pVisual->ColormapEntries; - - /* If the create returns non-0, it failed */ - result = CreateColormap (mid, pScreen, pVisual, &pmap, alloc, client); - if(result != Success) - return(result); - if(alloc == AllocAll) - { - memmove((char *)pmap->red, (char *)pSrc->red, size * sizeof(Entry)); - if((pmap->class | DynamicClass) == DirectColor) - { - memmove((char *)pmap->green, (char *)pSrc->green, size * sizeof(Entry)); - memmove((char *)pmap->blue, (char *)pSrc->blue, size * sizeof(Entry)); - } - pSrc->flags &= ~AllAllocated; - FreePixels(pSrc, client); - UpdateColors(pmap); - return(Success); - } - - CopyFree(REDMAP, client, pSrc, pmap); - if ((pmap->class | DynamicClass) == DirectColor) - { - CopyFree(GREENMAP, client, pSrc, pmap); - CopyFree(BLUEMAP, client, pSrc, pmap); - } - if (pmap->class & DynamicClass) - UpdateColors(pmap); - /* XXX should worry about removing any RT_CMAPENTRY resource */ - return(Success); -} - -/* Helper routine for freeing large numbers of cells from a map */ -static void -CopyFree (int channel, int client, ColormapPtr pmapSrc, ColormapPtr pmapDst) -{ - int z, npix; - EntryPtr pentSrcFirst, pentDstFirst; - EntryPtr pentSrc, pentDst; - Pixel *ppix; - int nalloc; - - switch(channel) - { - default: /* so compiler can see that everything gets initialized */ - case REDMAP: - ppix = (pmapSrc->clientPixelsRed)[client]; - npix = (pmapSrc->numPixelsRed)[client]; - pentSrcFirst = pmapSrc->red; - pentDstFirst = pmapDst->red; - break; - case GREENMAP: - ppix = (pmapSrc->clientPixelsGreen)[client]; - npix = (pmapSrc->numPixelsGreen)[client]; - pentSrcFirst = pmapSrc->green; - pentDstFirst = pmapDst->green; - break; - case BLUEMAP: - ppix = (pmapSrc->clientPixelsBlue)[client]; - npix = (pmapSrc->numPixelsBlue)[client]; - pentSrcFirst = pmapSrc->blue; - pentDstFirst = pmapDst->blue; - break; - } - nalloc = 0; - if (pmapSrc->class & DynamicClass) - { - for(z = npix; --z >= 0; ppix++) - { - /* Copy entries */ - pentSrc = pentSrcFirst + *ppix; - pentDst = pentDstFirst + *ppix; - if (pentDst->refcnt > 0) - { - pentDst->refcnt++; - } - else - { - *pentDst = *pentSrc; - nalloc++; - if (pentSrc->refcnt > 0) - pentDst->refcnt = 1; - else - pentSrc->fShared = FALSE; - } - FreeCell(pmapSrc, *ppix, channel); - } - } - - /* Note that FreeCell has already fixed pmapSrc->free{Color} */ - switch(channel) - { - case REDMAP: - pmapDst->freeRed -= nalloc; - (pmapDst->clientPixelsRed)[client] = - (pmapSrc->clientPixelsRed)[client]; - (pmapSrc->clientPixelsRed)[client] = (Pixel *) NULL; - (pmapDst->numPixelsRed)[client] = (pmapSrc->numPixelsRed)[client]; - (pmapSrc->numPixelsRed)[client] = 0; - break; - case GREENMAP: - pmapDst->freeGreen -= nalloc; - (pmapDst->clientPixelsGreen)[client] = - (pmapSrc->clientPixelsGreen)[client]; - (pmapSrc->clientPixelsGreen)[client] = (Pixel *) NULL; - (pmapDst->numPixelsGreen)[client] = (pmapSrc->numPixelsGreen)[client]; - (pmapSrc->numPixelsGreen)[client] = 0; - break; - case BLUEMAP: - pmapDst->freeBlue -= nalloc; - pmapDst->clientPixelsBlue[client] = pmapSrc->clientPixelsBlue[client]; - pmapSrc->clientPixelsBlue[client] = (Pixel *) NULL; - pmapDst->numPixelsBlue[client] = pmapSrc->numPixelsBlue[client]; - pmapSrc->numPixelsBlue[client] = 0; - break; - } -} - -/* Free the ith entry in a color map. Must handle freeing of - * colors allocated through AllocColorPlanes */ -static void -FreeCell (ColormapPtr pmap, Pixel i, int channel) -{ - EntryPtr pent; - int *pCount; - - - switch (channel) - { - default: /* so compiler can see that everything gets initialized */ - case PSEUDOMAP: - case REDMAP: - pent = (EntryPtr) &pmap->red[i]; - pCount = &pmap->freeRed; - break; - case GREENMAP: - pent = (EntryPtr) &pmap->green[i]; - pCount = &pmap->freeGreen; - break; - case BLUEMAP: - pent = (EntryPtr) &pmap->blue[i]; - pCount = &pmap->freeBlue; - break; - } - /* If it's not privately allocated and it's not time to free it, just - * decrement the count */ - if (pent->refcnt > 1) - pent->refcnt--; - else - { - /* If the color type is shared, find the sharedcolor. If decremented - * refcnt is 0, free the shared cell. */ - if (pent->fShared) - { - if(--pent->co.shco.red->refcnt == 0) - free(pent->co.shco.red); - if(--pent->co.shco.green->refcnt == 0) - free(pent->co.shco.green); - if(--pent->co.shco.blue->refcnt == 0) - free(pent->co.shco.blue); - pent->fShared = FALSE; - } - pent->refcnt = 0; - *pCount += 1; - } -} - -static void -UpdateColors (ColormapPtr pmap) -{ - xColorItem *defs; - xColorItem *pdef; - EntryPtr pent; - VisualPtr pVisual; - int i, n, size; - - pVisual = pmap->pVisual; - size = pVisual->ColormapEntries; - defs = malloc(size * sizeof(xColorItem)); - if (!defs) - return; - n = 0; - pdef = defs; - if (pmap->class == DirectColor) - { - for (i = 0; i < size; i++) - { - if (!pmap->red[i].refcnt && - !pmap->green[i].refcnt && - !pmap->blue[i].refcnt) - continue; - pdef->pixel = ((Pixel)i << pVisual->offsetRed) | - ((Pixel)i << pVisual->offsetGreen) | - ((Pixel)i << pVisual->offsetBlue); - pdef->red = pmap->red[i].co.local.red; - pdef->green = pmap->green[i].co.local.green; - pdef->blue = pmap->blue[i].co.local.blue; - pdef->flags = DoRed|DoGreen|DoBlue; - pdef++; - n++; - } - } - else - { - for (i = 0, pent = pmap->red; i < size; i++, pent++) - { - if (!pent->refcnt) - continue; - pdef->pixel = i; - if(pent->fShared) - { - pdef->red = pent->co.shco.red->color; - pdef->green = pent->co.shco.green->color; - pdef->blue = pent->co.shco.blue->color; - } - else - { - pdef->red = pent->co.local.red; - pdef->green = pent->co.local.green; - pdef->blue = pent->co.local.blue; - } - pdef->flags = DoRed|DoGreen|DoBlue; - pdef++; - n++; - } - } - if (n) - (*pmap->pScreen->StoreColors)(pmap, n, defs); - free(defs); -} - -/* Get a read-only color from a ColorMap (probably slow for large maps) - * Returns by changing the value in pred, pgreen, pblue and pPix - */ -int -AllocColor (ColormapPtr pmap, - unsigned short *pred, unsigned short *pgreen, unsigned short *pblue, - Pixel *pPix, int client) -{ - Pixel pixR, pixG, pixB; - int entries; - xrgb rgb; - int class; - VisualPtr pVisual; - int npix; - Pixel *ppix; - - pVisual = pmap->pVisual; - (*pmap->pScreen->ResolveColor) (pred, pgreen, pblue, pVisual); - rgb.red = *pred; - rgb.green = *pgreen; - rgb.blue = *pblue; - class = pmap->class; - entries = pVisual->ColormapEntries; - - /* If the colormap is being created, then we want to be able to change - * the colormap, even if it's a static type. Otherwise, we'd never be - * able to initialize static colormaps - */ - if(pmap->flags & BeingCreated) - class |= DynamicClass; - - /* If this is one of the static storage classes, and we're not initializing - * it, the best we can do is to find the closest color entry to the - * requested one and return that. - */ - switch (class) { - case StaticColor: - case StaticGray: - /* Look up all three components in the same pmap */ - *pPix = pixR = FindBestPixel(pmap->red, entries, &rgb, PSEUDOMAP); - *pred = pmap->red[pixR].co.local.red; - *pgreen = pmap->red[pixR].co.local.green; - *pblue = pmap->red[pixR].co.local.blue; - npix = pmap->numPixelsRed[client]; - ppix = (Pixel *) realloc(pmap->clientPixelsRed[client], - (npix + 1) * sizeof(Pixel)); - if (!ppix) - return (BadAlloc); - ppix[npix] = pixR; - pmap->clientPixelsRed[client] = ppix; - pmap->numPixelsRed[client]++; - break; - - case TrueColor: - /* Look up each component in its own map, then OR them together */ - pixR = FindBestPixel(pmap->red, NUMRED(pVisual), &rgb, REDMAP); - pixG = FindBestPixel(pmap->green, NUMGREEN(pVisual), &rgb, GREENMAP); - pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP); - *pPix = (pixR << pVisual->offsetRed) | - (pixG << pVisual->offsetGreen) | - (pixB << pVisual->offsetBlue) | - ALPHAMASK(pVisual); - - *pred = pmap->red[pixR].co.local.red; - *pgreen = pmap->green[pixG].co.local.green; - *pblue = pmap->blue[pixB].co.local.blue; - npix = pmap->numPixelsRed[client]; - ppix = (Pixel *) realloc(pmap->clientPixelsRed[client], - (npix + 1) * sizeof(Pixel)); - if (!ppix) - return (BadAlloc); - ppix[npix] = pixR; - pmap->clientPixelsRed[client] = ppix; - npix = pmap->numPixelsGreen[client]; - ppix = (Pixel *) realloc(pmap->clientPixelsGreen[client], - (npix + 1) * sizeof(Pixel)); - if (!ppix) - return (BadAlloc); - ppix[npix] = pixG; - pmap->clientPixelsGreen[client] = ppix; - npix = pmap->numPixelsBlue[client]; - ppix = (Pixel *) realloc(pmap->clientPixelsBlue[client], - (npix + 1) * sizeof(Pixel)); - if (!ppix) - return (BadAlloc); - ppix[npix] = pixB; - pmap->clientPixelsBlue[client] = ppix; - pmap->numPixelsRed[client]++; - pmap->numPixelsGreen[client]++; - pmap->numPixelsBlue[client]++; - break; - - case GrayScale: - case PseudoColor: - if (pmap->mid != pmap->pScreen->defColormap && - pmap->pVisual->vid == pmap->pScreen->rootVisual) - { - ColormapPtr prootmap; - dixLookupResourceByType((pointer *)&prootmap, pmap->pScreen->defColormap, - RT_COLORMAP, clients[client], DixReadAccess); - - if (pmap->class == prootmap->class) - FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb, - pPix, PSEUDOMAP, AllComp); - } - if (FindColor(pmap, pmap->red, entries, &rgb, pPix, PSEUDOMAP, - client, AllComp) != Success) - return (BadAlloc); - break; - - case DirectColor: - if (pmap->mid != pmap->pScreen->defColormap && - pmap->pVisual->vid == pmap->pScreen->rootVisual) - { - ColormapPtr prootmap; - dixLookupResourceByType((pointer *)&prootmap, pmap->pScreen->defColormap, - RT_COLORMAP, clients[client], DixReadAccess); - - if (pmap->class == prootmap->class) - { - pixR = (*pPix & pVisual->redMask) >> pVisual->offsetRed; - FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb, - &pixR, REDMAP, RedComp); - pixG = (*pPix & pVisual->greenMask) >> pVisual->offsetGreen; - FindColorInRootCmap (prootmap, prootmap->green, entries, &rgb, - &pixG, GREENMAP, GreenComp); - pixB = (*pPix & pVisual->blueMask) >> pVisual->offsetBlue; - FindColorInRootCmap (prootmap, prootmap->blue, entries, &rgb, - &pixB, BLUEMAP, BlueComp); - *pPix = pixR | pixG | pixB; - } - } - - pixR = (*pPix & pVisual->redMask) >> pVisual->offsetRed; - if (FindColor(pmap, pmap->red, NUMRED(pVisual), &rgb, &pixR, REDMAP, - client, RedComp) != Success) - return (BadAlloc); - pixG = (*pPix & pVisual->greenMask) >> pVisual->offsetGreen; - if (FindColor(pmap, pmap->green, NUMGREEN(pVisual), &rgb, &pixG, - GREENMAP, client, GreenComp) != Success) - { - (void)FreeCo(pmap, client, REDMAP, 1, &pixR, (Pixel)0); - return (BadAlloc); - } - pixB = (*pPix & pVisual->blueMask) >> pVisual->offsetBlue; - if (FindColor(pmap, pmap->blue, NUMBLUE(pVisual), &rgb, &pixB, BLUEMAP, - client, BlueComp) != Success) - { - (void)FreeCo(pmap, client, GREENMAP, 1, &pixG, (Pixel)0); - (void)FreeCo(pmap, client, REDMAP, 1, &pixR, (Pixel)0); - return (BadAlloc); - } - *pPix = pixR | pixG | pixB | ALPHAMASK(pVisual); - - break; - } - - /* if this is the client's first pixel in this colormap, tell the - * resource manager that the client has pixels in this colormap which - * should be freed when the client dies */ - if ((pmap->numPixelsRed[client] == 1) && - (CLIENT_ID(pmap->mid) != client) && - !(pmap->flags & BeingCreated)) - { - colorResource *pcr; - - pcr = malloc(sizeof(colorResource)); - if (!pcr) - { - (void)FreeColors(pmap, client, 1, pPix, (Pixel)0); - return (BadAlloc); - } - pcr->mid = pmap->mid; - pcr->client = client; - if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr)) - return (BadAlloc); - } - return (Success); -} - -/* - * FakeAllocColor -- fake an AllocColor request by - * returning a free pixel if availible, otherwise returning - * the closest matching pixel. This is used by the mi - * software sprite code to recolor cursors. A nice side-effect - * is that this routine will never return failure. - */ - -void -FakeAllocColor (ColormapPtr pmap, xColorItem *item) -{ - Pixel pixR, pixG, pixB; - Pixel temp; - int entries; - xrgb rgb; - int class; - VisualPtr pVisual; - - pVisual = pmap->pVisual; - rgb.red = item->red; - rgb.green = item->green; - rgb.blue = item->blue; - (*pmap->pScreen->ResolveColor) (&rgb.red, &rgb.green, &rgb.blue, pVisual); - class = pmap->class; - entries = pVisual->ColormapEntries; - - switch (class) { - case GrayScale: - case PseudoColor: - temp = 0; - item->pixel = 0; - if (FindColor(pmap, pmap->red, entries, &rgb, &temp, PSEUDOMAP, - -1, AllComp) == Success) { - item->pixel = temp; - break; - } - /* fall through ... */ - case StaticColor: - case StaticGray: - item->pixel = FindBestPixel(pmap->red, entries, &rgb, PSEUDOMAP); - break; - - case DirectColor: - /* Look up each component in its own map, then OR them together */ - pixR = (item->pixel & pVisual->redMask) >> pVisual->offsetRed; - pixG = (item->pixel & pVisual->greenMask) >> pVisual->offsetGreen; - pixB = (item->pixel & pVisual->blueMask) >> pVisual->offsetBlue; - if (FindColor(pmap, pmap->red, NUMRED(pVisual), &rgb, &pixR, REDMAP, - -1, RedComp) != Success) - pixR = FindBestPixel(pmap->red, NUMRED(pVisual), &rgb, REDMAP) - << pVisual->offsetRed; - if (FindColor(pmap, pmap->green, NUMGREEN(pVisual), &rgb, &pixG, - GREENMAP, -1, GreenComp) != Success) - pixG = FindBestPixel(pmap->green, NUMGREEN(pVisual), &rgb, - GREENMAP) << pVisual->offsetGreen; - if (FindColor(pmap, pmap->blue, NUMBLUE(pVisual), &rgb, &pixB, BLUEMAP, - -1, BlueComp) != Success) - pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP) - << pVisual->offsetBlue; - item->pixel = pixR | pixG | pixB; - break; - - case TrueColor: - /* Look up each component in its own map, then OR them together */ - pixR = FindBestPixel(pmap->red, NUMRED(pVisual), &rgb, REDMAP); - pixG = FindBestPixel(pmap->green, NUMGREEN(pVisual), &rgb, GREENMAP); - pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP); - item->pixel = (pixR << pVisual->offsetRed) | - (pixG << pVisual->offsetGreen) | - (pixB << pVisual->offsetBlue); - break; - } -} - -/* free a pixel value obtained from FakeAllocColor */ -void -FakeFreeColor(ColormapPtr pmap, Pixel pixel) -{ - VisualPtr pVisual; - Pixel pixR, pixG, pixB; - - switch (pmap->class) { - case GrayScale: - case PseudoColor: - if (pmap->red[pixel].refcnt == AllocTemporary) - pmap->red[pixel].refcnt = 0; - break; - case DirectColor: - pVisual = pmap->pVisual; - pixR = (pixel & pVisual->redMask) >> pVisual->offsetRed; - pixG = (pixel & pVisual->greenMask) >> pVisual->offsetGreen; - pixB = (pixel & pVisual->blueMask) >> pVisual->offsetBlue; - if (pmap->red[pixR].refcnt == AllocTemporary) - pmap->red[pixR].refcnt = 0; - if (pmap->green[pixG].refcnt == AllocTemporary) - pmap->green[pixG].refcnt = 0; - if (pmap->blue[pixB].refcnt == AllocTemporary) - pmap->blue[pixB].refcnt = 0; - break; - } -} - -typedef unsigned short BigNumUpper; -typedef unsigned long BigNumLower; - -#define BIGNUMLOWERBITS 24 -#define BIGNUMUPPERBITS 16 -#define BIGNUMLOWER (1 << BIGNUMLOWERBITS) -#define BIGNUMUPPER (1 << BIGNUMUPPERBITS) -#define UPPERPART(i) ((i) >> BIGNUMLOWERBITS) -#define LOWERPART(i) ((i) & (BIGNUMLOWER - 1)) - -typedef struct _bignum { - BigNumUpper upper; - BigNumLower lower; -} BigNumRec, *BigNumPtr; - -#define BigNumGreater(x,y) (((x)->upper > (y)->upper) ||\ - ((x)->upper == (y)->upper && (x)->lower > (y)->lower)) - -#define UnsignedToBigNum(u,r) (((r)->upper = UPPERPART(u)), \ - ((r)->lower = LOWERPART(u))) - -#define MaxBigNum(r) (((r)->upper = BIGNUMUPPER-1), \ - ((r)->lower = BIGNUMLOWER-1)) - -static void -BigNumAdd (BigNumPtr x, BigNumPtr y, BigNumPtr r) -{ - BigNumLower lower, carry = 0; - - lower = x->lower + y->lower; - if (lower >= BIGNUMLOWER) { - lower -= BIGNUMLOWER; - carry = 1; - } - r->lower = lower; - r->upper = x->upper + y->upper + carry; -} - -static Pixel -FindBestPixel(EntryPtr pentFirst, int size, xrgb *prgb, int channel) -{ - EntryPtr pent; - Pixel pixel, final; - long dr, dg, db; - unsigned long sq; - BigNumRec minval, sum, temp; - - final = 0; - MaxBigNum(&minval); - /* look for the minimal difference */ - for (pent = pentFirst, pixel = 0; pixel < size; pent++, pixel++) - { - dr = dg = db = 0; - switch(channel) - { - case PSEUDOMAP: - dg = (long) pent->co.local.green - prgb->green; - db = (long) pent->co.local.blue - prgb->blue; - case REDMAP: - dr = (long) pent->co.local.red - prgb->red; - break; - case GREENMAP: - dg = (long) pent->co.local.green - prgb->green; - break; - case BLUEMAP: - db = (long) pent->co.local.blue - prgb->blue; - break; - } - sq = dr * dr; - UnsignedToBigNum (sq, &sum); - sq = dg * dg; - UnsignedToBigNum (sq, &temp); - BigNumAdd (&sum, &temp, &sum); - sq = db * db; - UnsignedToBigNum (sq, &temp); - BigNumAdd (&sum, &temp, &sum); - if (BigNumGreater (&minval, &sum)) - { - final = pixel; - minval = sum; - } - } - return(final); -} - -static void -FindColorInRootCmap (ColormapPtr pmap, EntryPtr pentFirst, int size, - xrgb *prgb, Pixel *pPixel, int channel, - ColorCompareProcPtr comp) -{ - EntryPtr pent; - Pixel pixel; - int count; - - if ((pixel = *pPixel) >= size) - pixel = 0; - for (pent = pentFirst + pixel, count = size; --count >= 0; pent++, pixel++) - { - if (pent->refcnt > 0 && (*comp) (pent, prgb)) - { - switch (channel) - { - case REDMAP: - pixel <<= pmap->pVisual->offsetRed; - break; - case GREENMAP: - pixel <<= pmap->pVisual->offsetGreen; - break; - case BLUEMAP: - pixel <<= pmap->pVisual->offsetBlue; - break; - default: /* PSEUDOMAP */ - break; - } - *pPixel = pixel; - } - } -} - -/* Tries to find a color in pmap that exactly matches the one requested in prgb - * if it can't it allocates one. - * Starts looking at pentFirst + *pPixel, so if you want a specific pixel, - * load *pPixel with that value, otherwise set it to 0 - */ -int -FindColor (ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb *prgb, - Pixel *pPixel, int channel, int client, - ColorCompareProcPtr comp) -{ - EntryPtr pent; - Bool foundFree; - Pixel pixel, Free = 0; - int npix, count, *nump = NULL; - Pixel **pixp = NULL, *ppix; - xColorItem def; - - foundFree = FALSE; - - if((pixel = *pPixel) >= size) - pixel = 0; - /* see if there is a match, and also look for a free entry */ - for (pent = pentFirst + pixel, count = size; --count >= 0; ) - { - if (pent->refcnt > 0) - { - if ((*comp) (pent, prgb)) - { - if (client >= 0) - pent->refcnt++; - *pPixel = pixel; - switch(channel) - { - case REDMAP: - *pPixel <<= pmap->pVisual->offsetRed; - case PSEUDOMAP: - break; - case GREENMAP: - *pPixel <<= pmap->pVisual->offsetGreen; - break; - case BLUEMAP: - *pPixel <<= pmap->pVisual->offsetBlue; - break; - } - goto gotit; - } - } - else if (!foundFree && pent->refcnt == 0) - { - Free = pixel; - foundFree = TRUE; - /* If we're initializing the colormap, then we are looking for - * the first free cell we can find, not to minimize the number - * of entries we use. So don't look any further. */ - if(pmap->flags & BeingCreated) - break; - } - pixel++; - if(pixel >= size) - { - pent = pentFirst; - pixel = 0; - } - else - pent++; - } - - /* If we got here, we didn't find a match. If we also didn't find - * a free entry, we're out of luck. Otherwise, we'll usurp a free - * entry and fill it in */ - if (!foundFree) - return (BadAlloc); - pent = pentFirst + Free; - pent->fShared = FALSE; - pent->refcnt = (client >= 0) ? 1 : AllocTemporary; - - switch (channel) - { - case PSEUDOMAP: - pent->co.local.red = prgb->red; - pent->co.local.green = prgb->green; - pent->co.local.blue = prgb->blue; - def.red = prgb->red; - def.green = prgb->green; - def.blue = prgb->blue; - def.flags = (DoRed|DoGreen|DoBlue); - if (client >= 0) - pmap->freeRed--; - def.pixel = Free; - break; - - case REDMAP: - pent->co.local.red = prgb->red; - def.red = prgb->red; - def.green = pmap->green[0].co.local.green; - def.blue = pmap->blue[0].co.local.blue; - def.flags = DoRed; - if (client >= 0) - pmap->freeRed--; - def.pixel = Free << pmap->pVisual->offsetRed; - break; - - case GREENMAP: - pent->co.local.green = prgb->green; - def.red = pmap->red[0].co.local.red; - def.green = prgb->green; - def.blue = pmap->blue[0].co.local.blue; - def.flags = DoGreen; - if (client >= 0) - pmap->freeGreen--; - def.pixel = Free << pmap->pVisual->offsetGreen; - break; - - case BLUEMAP: - pent->co.local.blue = prgb->blue; - def.red = pmap->red[0].co.local.red; - def.green = pmap->green[0].co.local.green; - def.blue = prgb->blue; - def.flags = DoBlue; - if (client >= 0) - pmap->freeBlue--; - def.pixel = Free << pmap->pVisual->offsetBlue; - break; - } - (*pmap->pScreen->StoreColors) (pmap, 1, &def); - pixel = Free; - *pPixel = def.pixel; - -gotit: - if (pmap->flags & BeingCreated || client == -1) - return(Success); - /* Now remember the pixel, for freeing later */ - switch (channel) - { - case PSEUDOMAP: - case REDMAP: - nump = pmap->numPixelsRed; - pixp = pmap->clientPixelsRed; - break; - - case GREENMAP: - nump = pmap->numPixelsGreen; - pixp = pmap->clientPixelsGreen; - break; - - case BLUEMAP: - nump = pmap->numPixelsBlue; - pixp = pmap->clientPixelsBlue; - break; - } - npix = nump[client]; - ppix = (Pixel *) realloc(pixp[client], (npix + 1) * sizeof(Pixel)); - if (!ppix) - { - pent->refcnt--; - if (!pent->fShared) - switch (channel) - { - case PSEUDOMAP: - case REDMAP: - pmap->freeRed++; - break; - case GREENMAP: - pmap->freeGreen++; - break; - case BLUEMAP: - pmap->freeBlue++; - break; - } - return(BadAlloc); - } - ppix[npix] = pixel; - pixp[client] = ppix; - nump[client]++; - - return(Success); -} - -/* Comparison functions -- passed to FindColor to determine if an - * entry is already the color we're looking for or not */ -static int -AllComp (EntryPtr pent, xrgb *prgb) -{ - if((pent->co.local.red == prgb->red) && - (pent->co.local.green == prgb->green) && - (pent->co.local.blue == prgb->blue) ) - return (1); - return (0); -} - -static int -RedComp (EntryPtr pent, xrgb *prgb) -{ - if (pent->co.local.red == prgb->red) - return (1); - return (0); -} - -static int -GreenComp (EntryPtr pent, xrgb *prgb) -{ - if (pent->co.local.green == prgb->green) - return (1); - return (0); -} - -static int -BlueComp (EntryPtr pent, xrgb *prgb) -{ - if (pent->co.local.blue == prgb->blue) - return (1); - return (0); -} - - -/* Read the color value of a cell */ - -int -QueryColors (ColormapPtr pmap, int count, Pixel *ppixIn, xrgb *prgbList, ClientPtr client) -{ - Pixel *ppix, pixel; - xrgb *prgb; - VisualPtr pVisual; - EntryPtr pent; - Pixel i; - int errVal = Success; - - pVisual = pmap->pVisual; - if ((pmap->class | DynamicClass) == DirectColor) - { - int numred, numgreen, numblue; - Pixel rgbbad; - - numred = NUMRED(pVisual); - numgreen = NUMGREEN(pVisual); - numblue = NUMBLUE(pVisual); - rgbbad = ~RGBMASK(pVisual); - for( ppix = ppixIn, prgb = prgbList; --count >= 0; ppix++, prgb++) - { - pixel = *ppix; - if (pixel & rgbbad) { - client->errorValue = pixel; - errVal = BadValue; - continue; - } - i = (pixel & pVisual->redMask) >> pVisual->offsetRed; - if (i >= numred) - { - client->errorValue = pixel; - errVal = BadValue; - continue; - } - prgb->red = pmap->red[i].co.local.red; - i = (pixel & pVisual->greenMask) >> pVisual->offsetGreen; - if (i >= numgreen) - { - client->errorValue = pixel; - errVal = BadValue; - continue; - } - prgb->green = pmap->green[i].co.local.green; - i = (pixel & pVisual->blueMask) >> pVisual->offsetBlue; - if (i >= numblue) - { - client->errorValue = pixel; - errVal = BadValue; - continue; - } - prgb->blue = pmap->blue[i].co.local.blue; - } - } - else - { - for( ppix = ppixIn, prgb = prgbList; --count >= 0; ppix++, prgb++) - { - pixel = *ppix; - if (pixel >= pVisual->ColormapEntries) - { - client->errorValue = pixel; - errVal = BadValue; - } - else - { - pent = (EntryPtr)&pmap->red[pixel]; - if (pent->fShared) - { - prgb->red = pent->co.shco.red->color; - prgb->green = pent->co.shco.green->color; - prgb->blue = pent->co.shco.blue->color; - } - else - { - prgb->red = pent->co.local.red; - prgb->green = pent->co.local.green; - prgb->blue = pent->co.local.blue; - } - } - } - } - return (errVal); -} - -static void -FreePixels(ColormapPtr pmap, int client) -{ - Pixel *ppix, *ppixStart; - int n; - int class; - - class = pmap->class; - ppixStart = pmap->clientPixelsRed[client]; - if (class & DynamicClass) - { - n = pmap->numPixelsRed[client]; - for (ppix = ppixStart; --n >= 0; ) - { - FreeCell(pmap, *ppix, REDMAP); - ppix++; - } - } - - free(ppixStart); - pmap->clientPixelsRed[client] = (Pixel *) NULL; - pmap->numPixelsRed[client] = 0; - if ((class | DynamicClass) == DirectColor) - { - ppixStart = pmap->clientPixelsGreen[client]; - if (class & DynamicClass) - for (ppix = ppixStart, n = pmap->numPixelsGreen[client]; --n >= 0;) - FreeCell(pmap, *ppix++, GREENMAP); - free(ppixStart); - pmap->clientPixelsGreen[client] = (Pixel *) NULL; - pmap->numPixelsGreen[client] = 0; - - ppixStart = pmap->clientPixelsBlue[client]; - if (class & DynamicClass) - for (ppix = ppixStart, n = pmap->numPixelsBlue[client]; --n >= 0; ) - FreeCell(pmap, *ppix++, BLUEMAP); - free(ppixStart); - pmap->clientPixelsBlue[client] = (Pixel *) NULL; - pmap->numPixelsBlue[client] = 0; - } -} - -/** - * Frees all of a client's colors and cells. - * - * \param value must conform to DeleteType - * \unused fakeid - */ -int -FreeClientPixels (pointer value, XID fakeid) -{ - pointer pmap; - colorResource *pcr = value; - int rc; - - rc = dixLookupResourceByType(&pmap, pcr->mid, RT_COLORMAP, serverClient, - DixRemoveAccess); - if (rc == Success) - FreePixels((ColormapPtr)pmap, pcr->client); - free(pcr); - return Success; -} - -int -AllocColorCells (int client, ColormapPtr pmap, int colors, int planes, - Bool contig, Pixel *ppix, Pixel *masks) -{ - Pixel rmask, gmask, bmask, *ppixFirst, r, g, b; - int n, class; - int ok; - int oldcount; - colorResource *pcr = (colorResource *)NULL; - - class = pmap->class; - if (!(class & DynamicClass)) - return (BadAlloc); /* Shouldn't try on this type */ - oldcount = pmap->numPixelsRed[client]; - if (pmap->class == DirectColor) - oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client]; - if (!oldcount && (CLIENT_ID(pmap->mid) != client)) - { - pcr = malloc(sizeof(colorResource)); - if (!pcr) - return (BadAlloc); - } - - if (pmap->class == DirectColor) - { - ok = AllocDirect (client, pmap, colors, planes, planes, planes, - contig, ppix, &rmask, &gmask, &bmask); - if(ok == Success) - { - for (r = g = b = 1, n = planes; --n >= 0; r += r, g += g, b += b) - { - while(!(rmask & r)) - r += r; - while(!(gmask & g)) - g += g; - while(!(bmask & b)) - b += b; - *masks++ = r | g | b; - } - } - } - else - { - ok = AllocPseudo (client, pmap, colors, planes, contig, ppix, &rmask, - &ppixFirst); - if(ok == Success) - { - for (r = 1, n = planes; --n >= 0; r += r) - { - while(!(rmask & r)) - r += r; - *masks++ = r; - } - } - } - - /* if this is the client's first pixels in this colormap, tell the - * resource manager that the client has pixels in this colormap which - * should be freed when the client dies */ - if ((ok == Success) && pcr) - { - pcr->mid = pmap->mid; - pcr->client = client; - if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr)) - ok = BadAlloc; - } else if (pcr) - free(pcr); - - return (ok); -} - - -int -AllocColorPlanes (int client, ColormapPtr pmap, int colors, - int r, int g, int b, Bool contig, Pixel *pixels, - Pixel *prmask, Pixel *pgmask, Pixel *pbmask) -{ - int ok; - Pixel mask, *ppixFirst; - Pixel shift; - int i; - int class; - int oldcount; - colorResource *pcr = (colorResource *)NULL; - - class = pmap->class; - if (!(class & DynamicClass)) - return (BadAlloc); /* Shouldn't try on this type */ - oldcount = pmap->numPixelsRed[client]; - if (class == DirectColor) - oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client]; - if (!oldcount && (CLIENT_ID(pmap->mid) != client)) - { - pcr = malloc(sizeof(colorResource)); - if (!pcr) - return (BadAlloc); - } - - if (class == DirectColor) - { - ok = AllocDirect (client, pmap, colors, r, g, b, contig, pixels, - prmask, pgmask, pbmask); - } - else - { - /* Allocate the proper pixels */ - /* XXX This is sort of bad, because of contig is set, we force all - * r + g + b bits to be contiguous. Should only force contiguity - * per mask - */ - ok = AllocPseudo (client, pmap, colors, r + g + b, contig, pixels, - &mask, &ppixFirst); - - if(ok == Success) - { - /* now split that mask into three */ - *prmask = *pgmask = *pbmask = 0; - shift = 1; - for (i = r; --i >= 0; shift += shift) - { - while (!(mask & shift)) - shift += shift; - *prmask |= shift; - } - for (i = g; --i >= 0; shift += shift) - { - while (!(mask & shift)) - shift += shift; - *pgmask |= shift; - } - for (i = b; --i >= 0; shift += shift) - { - while (!(mask & shift)) - shift += shift; - *pbmask |= shift; - } - - /* set up the shared color cells */ - if (!AllocShared(pmap, pixels, colors, r, g, b, - *prmask, *pgmask, *pbmask, ppixFirst)) - { - (void)FreeColors(pmap, client, colors, pixels, mask); - ok = BadAlloc; - } - } - } - - /* if this is the client's first pixels in this colormap, tell the - * resource manager that the client has pixels in this colormap which - * should be freed when the client dies */ - if ((ok == Success) && pcr) - { - pcr->mid = pmap->mid; - pcr->client = client; - if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr)) - ok = BadAlloc; - } else if (pcr) - free(pcr); - - return (ok); -} - -static int -AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool contig, - Pixel *pixels, Pixel *prmask, Pixel *pgmask, Pixel *pbmask) -{ - Pixel *ppixRed, *ppixGreen, *ppixBlue; - Pixel *ppix, *pDst, *p; - int npix, npixR, npixG, npixB; - Bool okR, okG, okB; - Pixel *rpix = 0, *gpix = 0, *bpix = 0; - - npixR = c << r; - npixG = c << g; - npixB = c << b; - if ((r >= 32) || (g >= 32) || (b >= 32) || - (npixR > pmap->freeRed) || (npixR < c) || - (npixG > pmap->freeGreen) || (npixG < c) || - (npixB > pmap->freeBlue) || (npixB < c)) - return BadAlloc; - - /* start out with empty pixels */ - for(p = pixels; p < pixels + c; p++) - *p = 0; - - ppixRed = malloc(npixR * sizeof(Pixel)); - ppixGreen = malloc(npixG * sizeof(Pixel)); - ppixBlue = malloc(npixB * sizeof(Pixel)); - if (!ppixRed || !ppixGreen || !ppixBlue) - { - if (ppixBlue) free(ppixBlue); - if (ppixGreen) free(ppixGreen); - if (ppixRed) free(ppixRed); - return(BadAlloc); - } - - okR = AllocCP(pmap, pmap->red, c, r, contig, ppixRed, prmask); - okG = AllocCP(pmap, pmap->green, c, g, contig, ppixGreen, pgmask); - okB = AllocCP(pmap, pmap->blue, c, b, contig, ppixBlue, pbmask); - - if (okR && okG && okB) - { - rpix = (Pixel *) realloc(pmap->clientPixelsRed[client], - (pmap->numPixelsRed[client] + (c << r)) * - sizeof(Pixel)); - if (rpix) - pmap->clientPixelsRed[client] = rpix; - gpix = (Pixel *) realloc(pmap->clientPixelsGreen[client], - (pmap->numPixelsGreen[client] + (c << g)) * - sizeof(Pixel)); - if (gpix) - pmap->clientPixelsGreen[client] = gpix; - bpix = (Pixel *) realloc(pmap->clientPixelsBlue[client], - (pmap->numPixelsBlue[client] + (c << b)) * - sizeof(Pixel)); - if (bpix) - pmap->clientPixelsBlue[client] = bpix; - } - - if (!okR || !okG || !okB || !rpix || !gpix || !bpix) - { - if (okR) - for(ppix = ppixRed, npix = npixR; --npix >= 0; ppix++) - pmap->red[*ppix].refcnt = 0; - if (okG) - for(ppix = ppixGreen, npix = npixG; --npix >= 0; ppix++) - pmap->green[*ppix].refcnt = 0; - if (okB) - for(ppix = ppixBlue, npix = npixB; --npix >= 0; ppix++) - pmap->blue[*ppix].refcnt = 0; - free(ppixBlue); - free(ppixGreen); - free(ppixRed); - return(BadAlloc); - } - - *prmask <<= pmap->pVisual->offsetRed; - *pgmask <<= pmap->pVisual->offsetGreen; - *pbmask <<= pmap->pVisual->offsetBlue; - - ppix = rpix + pmap->numPixelsRed[client]; - for (pDst = pixels, p = ppixRed; p < ppixRed + npixR; p++) - { - *ppix++ = *p; - if(p < ppixRed + c) - *pDst++ |= *p << pmap->pVisual->offsetRed; - } - pmap->numPixelsRed[client] += npixR; - pmap->freeRed -= npixR; - - ppix = gpix + pmap->numPixelsGreen[client]; - for (pDst = pixels, p = ppixGreen; p < ppixGreen + npixG; p++) - { - *ppix++ = *p; - if(p < ppixGreen + c) - *pDst++ |= *p << pmap->pVisual->offsetGreen; - } - pmap->numPixelsGreen[client] += npixG; - pmap->freeGreen -= npixG; - - ppix = bpix + pmap->numPixelsBlue[client]; - for (pDst = pixels, p = ppixBlue; p < ppixBlue + npixB; p++) - { - *ppix++ = *p; - if(p < ppixBlue + c) - *pDst++ |= *p << pmap->pVisual->offsetBlue; - } - pmap->numPixelsBlue[client] += npixB; - pmap->freeBlue -= npixB; - - - for (pDst = pixels; pDst < pixels + c; pDst++) - *pDst |= ALPHAMASK(pmap->pVisual); - - free(ppixBlue); - free(ppixGreen); - free(ppixRed); - - return (Success); -} - -static int -AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig, - Pixel *pixels, Pixel *pmask, Pixel **pppixFirst) -{ - Pixel *ppix, *p, *pDst, *ppixTemp; - int npix; - Bool ok; - - npix = c << r; - if ((r >= 32) || (npix > pmap->freeRed) || (npix < c)) - return(BadAlloc); - if(!(ppixTemp = malloc(npix * sizeof(Pixel)))) - return(BadAlloc); - ok = AllocCP(pmap, pmap->red, c, r, contig, ppixTemp, pmask); - - if (ok) - { - - /* all the allocated pixels are added to the client pixel list, - * but only the unique ones are returned to the client */ - ppix = (Pixel *)realloc(pmap->clientPixelsRed[client], - (pmap->numPixelsRed[client] + npix) * sizeof(Pixel)); - if (!ppix) - { - for (p = ppixTemp; p < ppixTemp + npix; p++) - pmap->red[*p].refcnt = 0; - return (BadAlloc); - } - pmap->clientPixelsRed[client] = ppix; - ppix += pmap->numPixelsRed[client]; - *pppixFirst = ppix; - pDst = pixels; - for (p = ppixTemp; p < ppixTemp + npix; p++) - { - *ppix++ = *p; - if(p < ppixTemp + c) - *pDst++ = *p; - } - pmap->numPixelsRed[client] += npix; - pmap->freeRed -= npix; - } - free(ppixTemp); - return (ok ? Success : BadAlloc); -} - -/* Allocates count << planes pixels from colormap pmap for client. If - * contig, then the plane mask is made of consecutive bits. Returns - * all count << pixels in the array pixels. The first count of those - * pixels are the unique pixels. *pMask has the mask to Or with the - * unique pixels to get the rest of them. - * - * Returns True iff all pixels could be allocated - * All cells allocated will have refcnt set to AllocPrivate and shared to FALSE - * (see AllocShared for why we care) - */ -static Bool -AllocCP (ColormapPtr pmap, EntryPtr pentFirst, int count, int planes, - Bool contig, Pixel *pixels, Pixel *pMask) -{ - EntryPtr ent; - Pixel pixel, base, entries, maxp, save; - int dplanes, found; - Pixel *ppix; - Pixel mask; - Pixel finalmask; - - dplanes = pmap->pVisual->nplanes; - - /* Easy case. Allocate pixels only */ - if (planes == 0) - { - /* allocate writable entries */ - ppix = pixels; - ent = pentFirst; - pixel = 0; - while (--count >= 0) - { - /* Just find count unallocated cells */ - while (ent->refcnt) - { - ent++; - pixel++; - } - ent->refcnt = AllocPrivate; - *ppix++ = pixel; - ent->fShared = FALSE; - } - *pMask = 0; - return (TRUE); - } - else if (planes > dplanes) - { - return (FALSE); - } - - /* General case count pixels * 2 ^ planes cells to be allocated */ - - /* make room for new pixels */ - ent = pentFirst; - - /* first try for contiguous planes, since it's fastest */ - for (mask = (((Pixel)1) << planes) - 1, base = 1, dplanes -= (planes - 1); - --dplanes >= 0; - mask += mask, base += base) - { - ppix = pixels; - found = 0; - pixel = 0; - entries = pmap->pVisual->ColormapEntries - mask; - while (pixel < entries) - { - save = pixel; - maxp = pixel + mask + base; - /* check if all are free */ - while (pixel != maxp && ent[pixel].refcnt == 0) - pixel += base; - if (pixel == maxp) - { - /* this one works */ - *ppix++ = save; - found++; - if (found == count) - { - /* found enough, allocate them all */ - while (--count >= 0) - { - pixel = pixels[count]; - maxp = pixel + mask; - while (1) - { - ent[pixel].refcnt = AllocPrivate; - ent[pixel].fShared = FALSE; - if (pixel == maxp) - break; - pixel += base; - *ppix++ = pixel; - } - } - *pMask = mask; - return (TRUE); - } - } - pixel = save + 1; - if (pixel & mask) - pixel += mask; - } - } - - dplanes = pmap->pVisual->nplanes; - if (contig || planes == 1 || dplanes < 3) - return (FALSE); - - /* this will be very slow for large maps, need a better algorithm */ - - /* - we can generate the smallest and largest numbers that fits in dplanes - bits and contain exactly planes bits set as follows. First, we need to - check that it is possible to generate such a mask at all. - (Non-contiguous masks need one more bit than contiguous masks). Then - the smallest such mask consists of the rightmost planes-1 bits set, then - a zero, then a one in position planes + 1. The formula is - (3 << (planes-1)) -1 - The largest such masks consists of the leftmost planes-1 bits set, then - a zero, then a one bit in position dplanes-planes-1. If dplanes is - smaller than 32 (the number of bits in a word) then the formula is: - (1<<dplanes) - (1<<(dplanes-planes+1) + (1<<dplanes-planes-1) - If dplanes = 32, then we can't calculate (1<<dplanes) and we have - to use: - ( (1<<(planes-1)) - 1) << (dplanes-planes+1) + (1<<(dplanes-planes-1)) - - << Thank you, Loretta>>> - - */ - - finalmask = - (((((Pixel)1)<<(planes-1)) - 1) << (dplanes-planes+1)) + - (((Pixel)1)<<(dplanes-planes-1)); - for (mask = (((Pixel)3) << (planes -1)) - 1; mask <= finalmask; mask++) - { - /* next 3 magic statements count number of ones (HAKMEM #169) */ - pixel = (mask >> 1) & 033333333333; - pixel = mask - pixel - ((pixel >> 1) & 033333333333); - if ((((pixel + (pixel >> 3)) & 030707070707) % 077) != planes) - continue; - ppix = pixels; - found = 0; - entries = pmap->pVisual->ColormapEntries - mask; - base = lowbit (mask); - for (pixel = 0; pixel < entries; pixel++) - { - if (pixel & mask) - continue; - maxp = 0; - /* check if all are free */ - while (ent[pixel + maxp].refcnt == 0) - { - GetNextBitsOrBreak(maxp, mask, base); - } - if ((maxp < mask) || (ent[pixel + mask].refcnt != 0)) - continue; - /* this one works */ - *ppix++ = pixel; - found++; - if (found < count) - continue; - /* found enough, allocate them all */ - while (--count >= 0) - { - pixel = (pixels)[count]; - maxp = 0; - while (1) - { - ent[pixel + maxp].refcnt = AllocPrivate; - ent[pixel + maxp].fShared = FALSE; - GetNextBitsOrBreak(maxp, mask, base); - *ppix++ = pixel + maxp; - } - } - - *pMask = mask; - return (TRUE); - } - } - return (FALSE); -} - -/** - * - * \param ppixFirst First of the client's new pixels - */ -static Bool -AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b, - Pixel rmask, Pixel gmask, Pixel bmask, Pixel *ppixFirst) -{ - Pixel *pptr, *cptr; - int npix, z, npixClientNew, npixShared; - Pixel basemask, base, bits, common; - SHAREDCOLOR *pshared, **ppshared, **psharedList; - - npixClientNew = c << (r + g + b); - npixShared = (c << r) + (c << g) + (c << b); - psharedList = malloc(npixShared * sizeof(SHAREDCOLOR *)); - if (!psharedList) - return FALSE; - ppshared = psharedList; - for (z = npixShared; --z >= 0; ) - { - if (!(ppshared[z] = malloc(sizeof(SHAREDCOLOR)))) - { - for (z++ ; z < npixShared; z++) - free(ppshared[z]); - return FALSE; - } - } - for(pptr = ppix, npix = c; --npix >= 0; pptr++) - { - basemask = ~(gmask | bmask); - common = *pptr & basemask; - if (rmask) - { - bits = 0; - base = lowbit (rmask); - while(1) - { - pshared = *ppshared++; - pshared->refcnt = 1 << (g + b); - for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++) - { - if ((*cptr & basemask) == (common | bits)) - { - pmap->red[*cptr].fShared = TRUE; - pmap->red[*cptr].co.shco.red = pshared; - } - } - GetNextBitsOrBreak(bits, rmask, base); - } - } - else - { - pshared = *ppshared++; - pshared->refcnt = 1 << (g + b); - for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++) - { - if ((*cptr & basemask) == common) - { - pmap->red[*cptr].fShared = TRUE; - pmap->red[*cptr].co.shco.red = pshared; - } - } - } - basemask = ~(rmask | bmask); - common = *pptr & basemask; - if (gmask) - { - bits = 0; - base = lowbit (gmask); - while(1) - { - pshared = *ppshared++; - pshared->refcnt = 1 << (r + b); - for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++) - { - if ((*cptr & basemask) == (common | bits)) - { - pmap->red[*cptr].co.shco.green = pshared; - } - } - GetNextBitsOrBreak(bits, gmask, base); - } - } - else - { - pshared = *ppshared++; - pshared->refcnt = 1 << (g + b); - for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++) - { - if ((*cptr & basemask) == common) - { - pmap->red[*cptr].co.shco.green = pshared; - } - } - } - basemask = ~(rmask | gmask); - common = *pptr & basemask; - if (bmask) - { - bits = 0; - base = lowbit (bmask); - while(1) - { - pshared = *ppshared++; - pshared->refcnt = 1 << (r + g); - for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++) - { - if ((*cptr & basemask) == (common | bits)) - { - pmap->red[*cptr].co.shco.blue = pshared; - } - } - GetNextBitsOrBreak(bits, bmask, base); - } - } - else - { - pshared = *ppshared++; - pshared->refcnt = 1 << (g + b); - for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++) - { - if ((*cptr & basemask) == common) - { - pmap->red[*cptr].co.shco.blue = pshared; - } - } - } - } - free(psharedList); - return TRUE; -} - - -/** FreeColors - * Free colors and/or cells (probably slow for large numbers) - */ -int -FreeColors (ColormapPtr pmap, int client, int count, Pixel *pixels, Pixel mask) -{ - int rval, result, class; - Pixel rmask; - - class = pmap->class; - if (pmap->flags & AllAllocated) - return(BadAccess); - if ((class | DynamicClass) == DirectColor) - { - rmask = mask & RGBMASK(pmap->pVisual); - result = FreeCo(pmap, client, REDMAP, count, pixels, - mask & pmap->pVisual->redMask); - /* If any of the three calls fails, we must report that, if more - * than one fails, it's ok that we report the last one */ - rval = FreeCo(pmap, client, GREENMAP, count, pixels, - mask & pmap->pVisual->greenMask); - if(rval != Success) - result = rval; - rval = FreeCo(pmap, client, BLUEMAP, count, pixels, - mask & pmap->pVisual->blueMask); - if(rval != Success) - result = rval; - } - else - { - rmask = mask & ((((Pixel)1) << pmap->pVisual->nplanes) - 1); - result = FreeCo(pmap, client, PSEUDOMAP, count, pixels, rmask); - } - if ((mask != rmask) && count) - { - clients[client]->errorValue = *pixels | mask; - result = BadValue; - } - /* XXX should worry about removing any RT_CMAPENTRY resource */ - return (result); -} - -/** - * Helper for FreeColors -- frees all combinations of *newpixels and mask bits - * which the client has allocated in channel colormap cells of pmap. - * doesn't change newpixels if it doesn't need to - * - * \param pmap which colormap head - * \param color which sub-map, eg, RED, BLUE, PSEUDO - * \param npixIn number of pixels passed in - * \param ppixIn number of base pixels - * \param mask mask client gave us - */ -static int -FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixel mask) -{ - Pixel *ppixClient, pixTest; - int npixClient, npixNew, npix; - Pixel bits, base, cmask, rgbbad; - Pixel *pptr, *cptr; - int n, zapped; - int errVal = Success; - int offset, numents; - - if (npixIn == 0) - return (errVal); - bits = 0; - zapped = 0; - base = lowbit (mask); - - switch(color) - { - case REDMAP: - cmask = pmap->pVisual->redMask; - rgbbad = ~RGBMASK(pmap->pVisual); - offset = pmap->pVisual->offsetRed; - numents = (cmask >> offset) + 1; - ppixClient = pmap->clientPixelsRed[client]; - npixClient = pmap->numPixelsRed[client]; - break; - case GREENMAP: - cmask = pmap->pVisual->greenMask; - rgbbad = ~RGBMASK(pmap->pVisual); - offset = pmap->pVisual->offsetGreen; - numents = (cmask >> offset) + 1; - ppixClient = pmap->clientPixelsGreen[client]; - npixClient = pmap->numPixelsGreen[client]; - break; - case BLUEMAP: - cmask = pmap->pVisual->blueMask; - rgbbad = ~RGBMASK(pmap->pVisual); - offset = pmap->pVisual->offsetBlue; - numents = (cmask >> offset) + 1; - ppixClient = pmap->clientPixelsBlue[client]; - npixClient = pmap->numPixelsBlue[client]; - break; - default: /* so compiler can see that everything gets initialized */ - case PSEUDOMAP: - cmask = ~((Pixel)0); - rgbbad = 0; - offset = 0; - numents = pmap->pVisual->ColormapEntries; - ppixClient = pmap->clientPixelsRed[client]; - npixClient = pmap->numPixelsRed[client]; - break; - } - - - /* zap all pixels which match */ - while (1) - { - /* go through pixel list */ - for (pptr = ppixIn, n = npixIn; --n >= 0; pptr++) - { - pixTest = ((*pptr | bits) & cmask) >> offset; - if ((pixTest >= numents) || (*pptr & rgbbad)) - { - clients[client]->errorValue = *pptr | bits; - errVal = BadValue; - continue; - } - - /* find match in client list */ - for (cptr = ppixClient, npix = npixClient; - --npix >= 0 && *cptr != pixTest; - cptr++) ; - - if (npix >= 0) - { - if (pmap->class & DynamicClass) - { - FreeCell(pmap, pixTest, color); - } - *cptr = ~((Pixel)0); - zapped++; - } - else - errVal = BadAccess; - } - /* generate next bits value */ - GetNextBitsOrBreak(bits, mask, base); - } - - /* delete freed pixels from client pixel list */ - if (zapped) - { - npixNew = npixClient - zapped; - if (npixNew) - { - /* Since the list can only get smaller, we can do a copy in - * place and then realloc to a smaller size */ - pptr = cptr = ppixClient; - - /* If we have all the new pixels, we don't have to examine the - * rest of the old ones */ - for(npix = 0; npix < npixNew; cptr++) - { - if (*cptr != ~((Pixel)0)) - { - *pptr++ = *cptr; - npix++; - } - } - pptr = (Pixel *)realloc(ppixClient, npixNew * sizeof(Pixel)); - if (pptr) - ppixClient = pptr; - npixClient = npixNew; - } - else - { - npixClient = 0; - free(ppixClient); - ppixClient = (Pixel *)NULL; - } - switch(color) - { - case PSEUDOMAP: - case REDMAP: - pmap->clientPixelsRed[client] = ppixClient; - pmap->numPixelsRed[client] = npixClient; - break; - case GREENMAP: - pmap->clientPixelsGreen[client] = ppixClient; - pmap->numPixelsGreen[client] = npixClient; - break; - case BLUEMAP: - pmap->clientPixelsBlue[client] = ppixClient; - pmap->numPixelsBlue[client] = npixClient; - break; - } - } - return (errVal); -} - - - -/* Redefine color values */ -int -StoreColors (ColormapPtr pmap, int count, xColorItem *defs, ClientPtr client) -{ - Pixel pix; - xColorItem *pdef; - EntryPtr pent, pentT, pentLast; - VisualPtr pVisual; - SHAREDCOLOR *pred, *pgreen, *pblue; - int n, ChgRed, ChgGreen, ChgBlue, idef; - int class, errVal = Success; - int ok; - - - class = pmap->class; - if(!(class & DynamicClass) && !(pmap->flags & BeingCreated)) - { - return(BadAccess); - } - pVisual = pmap->pVisual; - - idef = 0; - if((class | DynamicClass) == DirectColor) - { - int numred, numgreen, numblue; - Pixel rgbbad; - - numred = NUMRED(pVisual); - numgreen = NUMGREEN(pVisual); - numblue = NUMBLUE(pVisual); - rgbbad = ~RGBMASK(pVisual); - for (pdef = defs, n = 0; n < count; pdef++, n++) - { - ok = TRUE; - (*pmap->pScreen->ResolveColor) - (&pdef->red, &pdef->green, &pdef->blue, pmap->pVisual); - - if (pdef->pixel & rgbbad) - { - errVal = BadValue; - client->errorValue = pdef->pixel; - continue; - } - pix = (pdef->pixel & pVisual->redMask) >> pVisual->offsetRed; - if (pix >= numred) - { - errVal = BadValue; - ok = FALSE; - } - else if (pmap->red[pix].refcnt != AllocPrivate) - { - errVal = BadAccess; - ok = FALSE; - } - else if (pdef->flags & DoRed) - { - pmap->red[pix].co.local.red = pdef->red; - } - else - { - pdef->red = pmap->red[pix].co.local.red; - } - - pix = (pdef->pixel & pVisual->greenMask) >> pVisual->offsetGreen; - if (pix >= numgreen) - { - errVal = BadValue; - ok = FALSE; - } - else if (pmap->green[pix].refcnt != AllocPrivate) - { - errVal = BadAccess; - ok = FALSE; - } - else if (pdef->flags & DoGreen) - { - pmap->green[pix].co.local.green = pdef->green; - } - else - { - pdef->green = pmap->green[pix].co.local.green; - } - - pix = (pdef->pixel & pVisual->blueMask) >> pVisual->offsetBlue; - if (pix >= numblue) - { - errVal = BadValue; - ok = FALSE; - } - else if (pmap->blue[pix].refcnt != AllocPrivate) - { - errVal = BadAccess; - ok = FALSE; - } - else if (pdef->flags & DoBlue) - { - pmap->blue[pix].co.local.blue = pdef->blue; - } - else - { - pdef->blue = pmap->blue[pix].co.local.blue; - } - /* If this is an o.k. entry, then it gets added to the list - * to be sent to the hardware. If not, skip it. Once we've - * skipped one, we have to copy all the others. - */ - if(ok) - { - if(idef != n) - defs[idef] = defs[n]; - idef++; - } else - client->errorValue = pdef->pixel; - } - } - else - { - for (pdef = defs, n = 0; n < count; pdef++, n++) - { - - ok = TRUE; - if (pdef->pixel >= pVisual->ColormapEntries) - { - client->errorValue = pdef->pixel; - errVal = BadValue; - ok = FALSE; - } - else if (pmap->red[pdef->pixel].refcnt != AllocPrivate) - { - errVal = BadAccess; - ok = FALSE; - } - - /* If this is an o.k. entry, then it gets added to the list - * to be sent to the hardware. If not, skip it. Once we've - * skipped one, we have to copy all the others. - */ - if(ok) - { - if(idef != n) - defs[idef] = defs[n]; - idef++; - } - else - continue; - - (*pmap->pScreen->ResolveColor) - (&pdef->red, &pdef->green, &pdef->blue, pmap->pVisual); - - pent = &pmap->red[pdef->pixel]; - - if(pdef->flags & DoRed) - { - if(pent->fShared) - { - pent->co.shco.red->color = pdef->red; - if (pent->co.shco.red->refcnt > 1) - ok = FALSE; - } - else - pent->co.local.red = pdef->red; - } - else - { - if(pent->fShared) - pdef->red = pent->co.shco.red->color; - else - pdef->red = pent->co.local.red; - } - if(pdef->flags & DoGreen) - { - if(pent->fShared) - { - pent->co.shco.green->color = pdef->green; - if (pent->co.shco.green->refcnt > 1) - ok = FALSE; - } - else - pent->co.local.green = pdef->green; - } - else - { - if(pent->fShared) - pdef->green = pent->co.shco.green->color; - else - pdef->green = pent->co.local.green; - } - if(pdef->flags & DoBlue) - { - if(pent->fShared) - { - pent->co.shco.blue->color = pdef->blue; - if (pent->co.shco.blue->refcnt > 1) - ok = FALSE; - } - else - pent->co.local.blue = pdef->blue; - } - else - { - if(pent->fShared) - pdef->blue = pent->co.shco.blue->color; - else - pdef->blue = pent->co.local.blue; - } - - if(!ok) - { - /* have to run through the colormap and change anybody who - * shares this value */ - pred = pent->co.shco.red; - pgreen = pent->co.shco.green; - pblue = pent->co.shco.blue; - ChgRed = pdef->flags & DoRed; - ChgGreen = pdef->flags & DoGreen; - ChgBlue = pdef->flags & DoBlue; - pentLast = pmap->red + pVisual->ColormapEntries; - - for(pentT = pmap->red; pentT < pentLast; pentT++) - { - if(pentT->fShared && (pentT != pent)) - { - xColorItem defChg; - - /* There are, alas, devices in this world too dumb - * to read their own hardware colormaps. Sick, but - * true. So we're going to be really nice and load - * the xColorItem with the proper value for all the - * fields. We will only set the flags for those - * fields that actually change. Smart devices can - * arrange to change only those fields. Dumb devices - * can rest assured that we have provided for them, - * and can change all three fields */ - - defChg.flags = 0; - if(ChgRed && pentT->co.shco.red == pred) - { - defChg.flags |= DoRed; - } - if(ChgGreen && pentT->co.shco.green == pgreen) - { - defChg.flags |= DoGreen; - } - if(ChgBlue && pentT->co.shco.blue == pblue) - { - defChg.flags |= DoBlue; - } - if(defChg.flags != 0) - { - defChg.pixel = pentT - pmap->red; - defChg.red = pentT->co.shco.red->color; - defChg.green = pentT->co.shco.green->color; - defChg.blue = pentT->co.shco.blue->color; - (*pmap->pScreen->StoreColors) (pmap, 1, &defChg); - } - } - } - - } - } - } - /* Note that we use idef, the count of acceptable entries, and not - * count, the count of proposed entries */ - if (idef != 0) - ( *pmap->pScreen->StoreColors) (pmap, idef, defs); - return (errVal); -} - -int -IsMapInstalled(Colormap map, WindowPtr pWin) -{ - Colormap *pmaps; - int imap, nummaps, found; - - pmaps = malloc(pWin->drawable.pScreen->maxInstalledCmaps*sizeof(Colormap)); - if(!pmaps) - return(FALSE); - nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps) - (pWin->drawable.pScreen, pmaps); - found = FALSE; - for(imap = 0; imap < nummaps; imap++) - { - if(pmaps[imap] == map) - { - found = TRUE; - break; - } - } - free(pmaps); - return (found); -} - -struct colormap_lookup_data { - ScreenPtr pScreen; - VisualPtr visuals; -}; - -static void _colormap_find_resource(pointer value, XID id, - pointer cdata) -{ - struct colormap_lookup_data *cmap_data = cdata; - VisualPtr visuals = cmap_data->visuals; - ScreenPtr pScreen = cmap_data->pScreen; - ColormapPtr cmap = value; - int j; - - if (pScreen != cmap->pScreen) - return; - - j = cmap->pVisual - pScreen->visuals; - cmap->pVisual = &visuals[j]; -} - -/* something has realloced the visuals, instead of breaking - ABI fix it up here - glx and compsite did this wrong */ -Bool -ResizeVisualArray(ScreenPtr pScreen, int new_visual_count, - DepthPtr depth) -{ - struct colormap_lookup_data cdata; - int numVisuals; - VisualPtr visuals; - XID *vids, vid; - int first_new_vid, first_new_visual, i; - - first_new_vid = depth->numVids; - first_new_visual = pScreen->numVisuals; - - vids = realloc(depth->vids, (depth->numVids + new_visual_count) * sizeof(XID)); - if (!vids) - return FALSE; - - /* its realloced now no going back if we fail the next one */ - depth->vids = vids; - - numVisuals = pScreen->numVisuals + new_visual_count; - visuals = realloc(pScreen->visuals, numVisuals * sizeof(VisualRec)); - if (!visuals) { - return FALSE; - } - - cdata.visuals = visuals; - cdata.pScreen = pScreen; - FindClientResourcesByType(serverClient, RT_COLORMAP, _colormap_find_resource, &cdata); - - pScreen->visuals = visuals; - - for (i = 0; i < new_visual_count; i++) { - vid = FakeClientID(0); - pScreen->visuals[first_new_visual + i].vid = vid; - vids[first_new_vid + i] = vid; - } - - depth->numVids += new_visual_count; - pScreen->numVisuals += new_visual_count; - - return TRUE; -} +/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include "misc.h"
+#include "dix.h"
+#include "dixstruct.h"
+#include "colormapst.h"
+#include "os.h"
+#include "scrnintstr.h"
+#include "resource.h"
+#include "windowstr.h"
+#include "privates.h"
+#include "xace.h"
+
+#ifdef _MSC_VER
+#define UpdateColors thisUpdateColors
+#endif
+
+static Pixel FindBestPixel(
+ EntryPtr /*pentFirst*/,
+ int /*size*/,
+ xrgb * /*prgb*/,
+ int /*channel*/
+);
+
+static int AllComp(
+ EntryPtr /*pent*/,
+ xrgb * /*prgb*/
+);
+
+static int RedComp(
+ EntryPtr /*pent*/,
+ xrgb * /*prgb*/
+);
+
+static int GreenComp(
+ EntryPtr /*pent*/,
+ xrgb * /*prgb*/
+);
+
+static int BlueComp(
+ EntryPtr /*pent*/,
+ xrgb * /*prgb*/
+);
+
+static void FreePixels(
+ ColormapPtr /*pmap*/,
+ int /*client*/
+);
+
+static void CopyFree(
+ int /*channel*/,
+ int /*client*/,
+ ColormapPtr /*pmapSrc*/,
+ ColormapPtr /*pmapDst*/
+);
+
+static void FreeCell(
+ ColormapPtr /*pmap*/,
+ Pixel /*i*/,
+ int /*channel*/
+);
+
+static void UpdateColors(
+ ColormapPtr /*pmap*/
+);
+
+static int AllocDirect(
+ int /*client*/,
+ ColormapPtr /*pmap*/,
+ int /*c*/,
+ int /*r*/,
+ int /*g*/,
+ int /*b*/,
+ Bool /*contig*/,
+ Pixel * /*pixels*/,
+ Pixel * /*prmask*/,
+ Pixel * /*pgmask*/,
+ Pixel * /*pbmask*/
+);
+
+static int AllocPseudo(
+ int /*client*/,
+ ColormapPtr /*pmap*/,
+ int /*c*/,
+ int /*r*/,
+ Bool /*contig*/,
+ Pixel * /*pixels*/,
+ Pixel * /*pmask*/,
+ Pixel ** /*pppixFirst*/
+);
+
+static Bool AllocCP(
+ ColormapPtr /*pmap*/,
+ EntryPtr /*pentFirst*/,
+ int /*count*/,
+ int /*planes*/,
+ Bool /*contig*/,
+ Pixel * /*pixels*/,
+ Pixel * /*pMask*/
+);
+
+static Bool AllocShared(
+ ColormapPtr /*pmap*/,
+ Pixel * /*ppix*/,
+ int /*c*/,
+ int /*r*/,
+ int /*g*/,
+ int /*b*/,
+ Pixel /*rmask*/,
+ Pixel /*gmask*/,
+ Pixel /*bmask*/,
+ Pixel * /*ppixFirst*/
+);
+
+static int FreeCo(
+ ColormapPtr /*pmap*/,
+ int /*client*/,
+ int /*color*/,
+ int /*npixIn*/,
+ Pixel * /*ppixIn*/,
+ Pixel /*mask*/
+);
+
+static int TellNoMap(
+ WindowPtr /*pwin*/,
+ Colormap * /*pmid*/
+);
+
+static void FindColorInRootCmap (
+ ColormapPtr /* pmap */,
+ EntryPtr /* pentFirst */,
+ int /* size */,
+ xrgb* /* prgb */,
+ Pixel* /* pPixel */,
+ int /* channel */,
+ ColorCompareProcPtr /* comp */
+);
+
+#define NUMRED(vis) ((vis->redMask >> vis->offsetRed) + 1)
+#define NUMGREEN(vis) ((vis->greenMask >> vis->offsetGreen) + 1)
+#define NUMBLUE(vis) ((vis->blueMask >> vis->offsetBlue) + 1)
+#if COMPOSITE
+#define ALPHAMASK(vis) ((vis)->nplanes < 32 ? 0 : \
+ (CARD32) ~((vis)->redMask|(vis)->greenMask|(vis)->blueMask))
+#else
+#define ALPHAMASK(vis) 0
+#endif
+
+#define RGBMASK(vis) (vis->redMask | vis->greenMask | vis->blueMask | ALPHAMASK(vis))
+
+/* GetNextBitsOrBreak(bits, mask, base) --
+ * (Suggestion: First read the macro, then read this explanation.
+ *
+ * Either generate the next value to OR in to a pixel or break out of this
+ * while loop
+ *
+ * This macro is used when we're trying to generate all 2^n combinations of
+ * bits in mask. What we're doing here is counting in binary, except that
+ * the bits we use to count may not be contiguous. This macro will be
+ * called 2^n times, returning a different value in bits each time. Then
+ * it will cause us to break out of a surrounding loop. (It will always be
+ * called from within a while loop.)
+ * On call: mask is the value we want to find all the combinations for
+ * base has 1 bit set where the least significant bit of mask is set
+ *
+ * For example,if mask is 01010, base should be 0010 and we count like this:
+ * 00010 (see this isn't so hard),
+ * then we add base to bits and get 0100. (bits & ~mask) is (0100 & 0100) so
+ * we add that to bits getting (0100 + 0100) =
+ * 01000 for our next value.
+ * then we add 0010 to get
+ * 01010 and we're done (easy as 1, 2, 3)
+ */
+#define GetNextBitsOrBreak(bits, mask, base) \
+ if((bits) == (mask)) \
+ break; \
+ (bits) += (base); \
+ while((bits) & ~(mask)) \
+ (bits) += ((bits) & ~(mask));
+/* ID of server as client */
+#define SERVER_ID 0
+
+typedef struct _colorResource
+{
+ Colormap mid;
+ int client;
+} colorResource;
+
+/* Invariants:
+ * refcnt == 0 means entry is empty
+ * refcnt > 0 means entry is useable by many clients, so it can't be changed
+ * refcnt == AllocPrivate means entry owned by one client only
+ * fShared should only be set if refcnt == AllocPrivate, and only in red map
+ */
+
+
+/**
+ * Create and initialize the color map
+ *
+ * \param mid resource to use for this colormap
+ * \param alloc 1 iff all entries are allocated writable
+ */
+int
+CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
+ ColormapPtr *ppcmap, int alloc, int client)
+{
+ int class, size;
+ unsigned long sizebytes;
+ ColormapPtr pmap;
+ EntryPtr pent;
+ int i;
+ Pixel *ppix, **pptr;
+
+ class = pVisual->class;
+ if(!(class & DynamicClass) && (alloc != AllocNone) && (client != SERVER_ID))
+ return BadMatch;
+
+ size = pVisual->ColormapEntries;
+ sizebytes = (size * sizeof(Entry)) +
+ (MAXCLIENTS * sizeof(Pixel *)) +
+ (MAXCLIENTS * sizeof(int));
+ if ((class | DynamicClass) == DirectColor)
+ sizebytes *= 3;
+ sizebytes += sizeof(ColormapRec);
+ if (mid == pScreen->defColormap) {
+ pmap = malloc(sizebytes);
+ if (!pmap)
+ return BadAlloc;
+ if (!dixAllocatePrivates(&pmap->devPrivates, PRIVATE_COLORMAP)) {
+ free (pmap);
+ return BadAlloc;
+ }
+ } else {
+ pmap = _dixAllocateObjectWithPrivates(sizebytes, sizebytes,
+ offsetof(ColormapRec, devPrivates), PRIVATE_COLORMAP);
+ if (!pmap)
+ return BadAlloc;
+ }
+#if defined(_XSERVER64)
+ pmap->pad0 = 0;
+ pmap->pad1 = 0;
+#if (X_BYTE_ORDER == X_LITTLE_ENDIAN)
+ pmap->pad2 = 0;
+#endif
+#endif
+ pmap->red = (EntryPtr)((char *)pmap + sizeof(ColormapRec));
+ sizebytes = size * sizeof(Entry);
+ pmap->clientPixelsRed = (Pixel **)((char *)pmap->red + sizebytes);
+ pmap->numPixelsRed = (int *)((char *)pmap->clientPixelsRed +
+ (MAXCLIENTS * sizeof(Pixel *)));
+ pmap->mid = mid;
+ pmap->flags = 0; /* start out with all flags clear */
+ if(mid == pScreen->defColormap)
+ pmap->flags |= IsDefault;
+ pmap->pScreen = pScreen;
+ pmap->pVisual = pVisual;
+ pmap->class = class;
+ if ((class | DynamicClass) == DirectColor)
+ size = NUMRED(pVisual);
+ pmap->freeRed = size;
+ memset((char *) pmap->red, 0, (int)sizebytes);
+ memset((char *) pmap->numPixelsRed, 0, MAXCLIENTS * sizeof(int));
+ for (pptr = &pmap->clientPixelsRed[MAXCLIENTS]; --pptr >= pmap->clientPixelsRed; )
+ *pptr = (Pixel *)NULL;
+ if (alloc == AllocAll)
+ {
+ if (class & DynamicClass)
+ pmap->flags |= AllAllocated;
+ for (pent = &pmap->red[size - 1]; pent >= pmap->red; pent--)
+ pent->refcnt = AllocPrivate;
+ pmap->freeRed = 0;
+ ppix = malloc(size * sizeof(Pixel));
+ if (!ppix)
+ {
+ free(pmap);
+ return BadAlloc;
+ }
+ pmap->clientPixelsRed[client] = ppix;
+ for(i = 0; i < size; i++)
+ ppix[i] = i;
+ pmap->numPixelsRed[client] = size;
+ }
+
+ if ((class | DynamicClass) == DirectColor)
+ {
+ pmap->freeGreen = NUMGREEN(pVisual);
+ pmap->green = (EntryPtr)((char *)pmap->numPixelsRed +
+ (MAXCLIENTS * sizeof(int)));
+ pmap->clientPixelsGreen = (Pixel **)((char *)pmap->green + sizebytes);
+ pmap->numPixelsGreen = (int *)((char *)pmap->clientPixelsGreen +
+ (MAXCLIENTS * sizeof(Pixel *)));
+ pmap->freeBlue = NUMBLUE(pVisual);
+ pmap->blue = (EntryPtr)((char *)pmap->numPixelsGreen +
+ (MAXCLIENTS * sizeof(int)));
+ pmap->clientPixelsBlue = (Pixel **)((char *)pmap->blue + sizebytes);
+ pmap->numPixelsBlue = (int *)((char *)pmap->clientPixelsBlue +
+ (MAXCLIENTS * sizeof(Pixel *)));
+
+ memset((char *) pmap->green, 0, (int)sizebytes);
+ memset((char *) pmap->blue, 0, (int)sizebytes);
+
+ memmove((char *) pmap->clientPixelsGreen,
+ (char *) pmap->clientPixelsRed,
+ MAXCLIENTS * sizeof(Pixel *));
+ memmove((char *) pmap->clientPixelsBlue,
+ (char *) pmap->clientPixelsRed,
+ MAXCLIENTS * sizeof(Pixel *));
+ memset((char *) pmap->numPixelsGreen, 0, MAXCLIENTS * sizeof(int));
+ memset((char *) pmap->numPixelsBlue, 0, MAXCLIENTS * sizeof(int));
+
+ /* If every cell is allocated, mark its refcnt */
+ if (alloc == AllocAll)
+ {
+ size = pmap->freeGreen;
+ for(pent = &pmap->green[size-1]; pent >= pmap->green; pent--)
+ pent->refcnt = AllocPrivate;
+ pmap->freeGreen = 0;
+ ppix = malloc(size * sizeof(Pixel));
+ if (!ppix)
+ {
+ free(pmap->clientPixelsRed[client]);
+ free(pmap);
+ return BadAlloc;
+ }
+ pmap->clientPixelsGreen[client] = ppix;
+ for(i = 0; i < size; i++)
+ ppix[i] = i;
+ pmap->numPixelsGreen[client] = size;
+
+ size = pmap->freeBlue;
+ for(pent = &pmap->blue[size-1]; pent >= pmap->blue; pent--)
+ pent->refcnt = AllocPrivate;
+ pmap->freeBlue = 0;
+ ppix = malloc(size * sizeof(Pixel));
+ if (!ppix)
+ {
+ free(pmap->clientPixelsGreen[client]);
+ free(pmap->clientPixelsRed[client]);
+ free(pmap);
+ return BadAlloc;
+ }
+ pmap->clientPixelsBlue[client] = ppix;
+ for(i = 0; i < size; i++)
+ ppix[i] = i;
+ pmap->numPixelsBlue[client] = size;
+ }
+ }
+ pmap->flags |= BeingCreated;
+
+ if (!AddResource(mid, RT_COLORMAP, (pointer)pmap))
+ return BadAlloc;
+
+ /*
+ * Security creation/labeling check
+ */
+ i = XaceHook(XACE_RESOURCE_ACCESS, clients[client], mid, RT_COLORMAP,
+ pmap, RT_NONE, NULL, DixCreateAccess);
+ if (i != Success) {
+ FreeResource(mid, RT_NONE);
+ return i;
+ }
+
+ /* If the device wants a chance to initialize the colormap in any way,
+ * this is it. In specific, if this is a Static colormap, this is the
+ * time to fill in the colormap's values */
+ if (!(*pScreen->CreateColormap)(pmap))
+ {
+ FreeResource (mid, RT_NONE);
+ return BadAlloc;
+ }
+ pmap->flags &= ~BeingCreated;
+ *ppcmap = pmap;
+ return Success;
+}
+
+/**
+ *
+ * \param value must conform to DeleteType
+ */
+int
+FreeColormap (pointer value, XID mid)
+{
+ int i;
+ EntryPtr pent;
+ ColormapPtr pmap = (ColormapPtr)value;
+
+ if(CLIENT_ID(mid) != SERVER_ID)
+ {
+ (*pmap->pScreen->UninstallColormap) (pmap);
+ WalkTree(pmap->pScreen, (VisitWindowProcPtr)TellNoMap, (pointer) &mid);
+ }
+
+ /* This is the device's chance to undo anything it needs to, especially
+ * to free any storage it allocated */
+ (*pmap->pScreen->DestroyColormap)(pmap);
+
+ if(pmap->clientPixelsRed)
+ {
+ for(i = 0; i < MAXCLIENTS; i++)
+ free(pmap->clientPixelsRed[i]);
+ }
+
+ if ((pmap->class == PseudoColor) || (pmap->class == GrayScale))
+ {
+ for(pent = &pmap->red[pmap->pVisual->ColormapEntries - 1];
+ pent >= pmap->red;
+ pent--)
+ {
+ if(pent->fShared)
+ {
+ if (--pent->co.shco.red->refcnt == 0)
+ free(pent->co.shco.red);
+ if (--pent->co.shco.green->refcnt == 0)
+ free(pent->co.shco.green);
+ if (--pent->co.shco.blue->refcnt == 0)
+ free(pent->co.shco.blue);
+ }
+ }
+ }
+ if((pmap->class | DynamicClass) == DirectColor)
+ {
+ for(i = 0; i < MAXCLIENTS; i++)
+ {
+ free(pmap->clientPixelsGreen[i]);
+ free(pmap->clientPixelsBlue[i]);
+ }
+ }
+
+ if (pmap->flags & IsDefault) {
+ dixFreePrivates(pmap->devPrivates, PRIVATE_COLORMAP);
+ free(pmap);
+ } else
+ dixFreeObjectWithPrivates(pmap, PRIVATE_COLORMAP);
+ return Success;
+}
+
+/* Tell window that pmid has disappeared */
+static int
+TellNoMap (WindowPtr pwin, Colormap *pmid)
+{
+ xEvent xE;
+
+ if (wColormap(pwin) == *pmid)
+ {
+ /* This should be call to DeliverEvent */
+ xE.u.u.type = ColormapNotify;
+ xE.u.colormap.window = pwin->drawable.id;
+ xE.u.colormap.colormap = None;
+ xE.u.colormap.new = TRUE;
+ xE.u.colormap.state = ColormapUninstalled;
+#ifdef PANORAMIX
+ if(noPanoramiXExtension || !pwin->drawable.pScreen->myNum)
+#endif
+ DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL);
+ if (pwin->optional) {
+ pwin->optional->colormap = None;
+ CheckWindowOptionalNeed (pwin);
+ }
+ }
+
+ return WT_WALKCHILDREN;
+}
+
+/* Tell window that pmid got uninstalled */
+int
+TellLostMap (WindowPtr pwin, pointer value)
+{
+ Colormap *pmid = (Colormap *)value;
+ xEvent xE;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pwin->drawable.pScreen->myNum)
+ return WT_STOPWALKING;
+#endif
+ if (wColormap(pwin) == *pmid)
+ {
+ /* This should be call to DeliverEvent */
+ xE.u.u.type = ColormapNotify;
+ xE.u.colormap.window = pwin->drawable.id;
+ xE.u.colormap.colormap = *pmid;
+ xE.u.colormap.new = FALSE;
+ xE.u.colormap.state = ColormapUninstalled;
+ DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL);
+ }
+
+ return WT_WALKCHILDREN;
+}
+
+/* Tell window that pmid got installed */
+int
+TellGainedMap (WindowPtr pwin, pointer value)
+{
+ Colormap *pmid = (Colormap *)value;
+ xEvent xE;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pwin->drawable.pScreen->myNum)
+ return WT_STOPWALKING;
+#endif
+ if (wColormap (pwin) == *pmid)
+ {
+ /* This should be call to DeliverEvent */
+ xE.u.u.type = ColormapNotify;
+ xE.u.colormap.window = pwin->drawable.id;
+ xE.u.colormap.colormap = *pmid;
+ xE.u.colormap.new = FALSE;
+ xE.u.colormap.state = ColormapInstalled;
+ DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL);
+ }
+
+ return WT_WALKCHILDREN;
+}
+
+
+int
+CopyColormapAndFree (Colormap mid, ColormapPtr pSrc, int client)
+{
+ ColormapPtr pmap = (ColormapPtr) NULL;
+ int result, alloc, size;
+ Colormap midSrc;
+ ScreenPtr pScreen;
+ VisualPtr pVisual;
+
+ pScreen = pSrc->pScreen;
+ pVisual = pSrc->pVisual;
+ midSrc = pSrc->mid;
+ alloc = ((pSrc->flags & AllAllocated) && CLIENT_ID(midSrc) == client) ?
+ AllocAll : AllocNone;
+ size = pVisual->ColormapEntries;
+
+ /* If the create returns non-0, it failed */
+ result = CreateColormap (mid, pScreen, pVisual, &pmap, alloc, client);
+ if(result != Success)
+ return result;
+ if(alloc == AllocAll)
+ {
+ memmove((char *)pmap->red, (char *)pSrc->red, size * sizeof(Entry));
+ if((pmap->class | DynamicClass) == DirectColor)
+ {
+ memmove((char *)pmap->green, (char *)pSrc->green, size * sizeof(Entry));
+ memmove((char *)pmap->blue, (char *)pSrc->blue, size * sizeof(Entry));
+ }
+ pSrc->flags &= ~AllAllocated;
+ FreePixels(pSrc, client);
+ UpdateColors(pmap);
+ return Success;
+ }
+
+ CopyFree(REDMAP, client, pSrc, pmap);
+ if ((pmap->class | DynamicClass) == DirectColor)
+ {
+ CopyFree(GREENMAP, client, pSrc, pmap);
+ CopyFree(BLUEMAP, client, pSrc, pmap);
+ }
+ if (pmap->class & DynamicClass)
+ UpdateColors(pmap);
+ /* XXX should worry about removing any RT_CMAPENTRY resource */
+ return Success;
+}
+
+/* Helper routine for freeing large numbers of cells from a map */
+static void
+CopyFree (int channel, int client, ColormapPtr pmapSrc, ColormapPtr pmapDst)
+{
+ int z, npix;
+ EntryPtr pentSrcFirst, pentDstFirst;
+ EntryPtr pentSrc, pentDst;
+ Pixel *ppix;
+ int nalloc;
+
+ switch(channel)
+ {
+ default: /* so compiler can see that everything gets initialized */
+ case REDMAP:
+ ppix = (pmapSrc->clientPixelsRed)[client];
+ npix = (pmapSrc->numPixelsRed)[client];
+ pentSrcFirst = pmapSrc->red;
+ pentDstFirst = pmapDst->red;
+ break;
+ case GREENMAP:
+ ppix = (pmapSrc->clientPixelsGreen)[client];
+ npix = (pmapSrc->numPixelsGreen)[client];
+ pentSrcFirst = pmapSrc->green;
+ pentDstFirst = pmapDst->green;
+ break;
+ case BLUEMAP:
+ ppix = (pmapSrc->clientPixelsBlue)[client];
+ npix = (pmapSrc->numPixelsBlue)[client];
+ pentSrcFirst = pmapSrc->blue;
+ pentDstFirst = pmapDst->blue;
+ break;
+ }
+ nalloc = 0;
+ if (pmapSrc->class & DynamicClass)
+ {
+ for(z = npix; --z >= 0; ppix++)
+ {
+ /* Copy entries */
+ pentSrc = pentSrcFirst + *ppix;
+ pentDst = pentDstFirst + *ppix;
+ if (pentDst->refcnt > 0)
+ {
+ pentDst->refcnt++;
+ }
+ else
+ {
+ *pentDst = *pentSrc;
+ nalloc++;
+ if (pentSrc->refcnt > 0)
+ pentDst->refcnt = 1;
+ else
+ pentSrc->fShared = FALSE;
+ }
+ FreeCell(pmapSrc, *ppix, channel);
+ }
+ }
+
+ /* Note that FreeCell has already fixed pmapSrc->free{Color} */
+ switch(channel)
+ {
+ case REDMAP:
+ pmapDst->freeRed -= nalloc;
+ (pmapDst->clientPixelsRed)[client] =
+ (pmapSrc->clientPixelsRed)[client];
+ (pmapSrc->clientPixelsRed)[client] = (Pixel *) NULL;
+ (pmapDst->numPixelsRed)[client] = (pmapSrc->numPixelsRed)[client];
+ (pmapSrc->numPixelsRed)[client] = 0;
+ break;
+ case GREENMAP:
+ pmapDst->freeGreen -= nalloc;
+ (pmapDst->clientPixelsGreen)[client] =
+ (pmapSrc->clientPixelsGreen)[client];
+ (pmapSrc->clientPixelsGreen)[client] = (Pixel *) NULL;
+ (pmapDst->numPixelsGreen)[client] = (pmapSrc->numPixelsGreen)[client];
+ (pmapSrc->numPixelsGreen)[client] = 0;
+ break;
+ case BLUEMAP:
+ pmapDst->freeBlue -= nalloc;
+ pmapDst->clientPixelsBlue[client] = pmapSrc->clientPixelsBlue[client];
+ pmapSrc->clientPixelsBlue[client] = (Pixel *) NULL;
+ pmapDst->numPixelsBlue[client] = pmapSrc->numPixelsBlue[client];
+ pmapSrc->numPixelsBlue[client] = 0;
+ break;
+ }
+}
+
+/* Free the ith entry in a color map. Must handle freeing of
+ * colors allocated through AllocColorPlanes */
+static void
+FreeCell (ColormapPtr pmap, Pixel i, int channel)
+{
+ EntryPtr pent;
+ int *pCount;
+
+
+ switch (channel)
+ {
+ default: /* so compiler can see that everything gets initialized */
+ case PSEUDOMAP:
+ case REDMAP:
+ pent = (EntryPtr) &pmap->red[i];
+ pCount = &pmap->freeRed;
+ break;
+ case GREENMAP:
+ pent = (EntryPtr) &pmap->green[i];
+ pCount = &pmap->freeGreen;
+ break;
+ case BLUEMAP:
+ pent = (EntryPtr) &pmap->blue[i];
+ pCount = &pmap->freeBlue;
+ break;
+ }
+ /* If it's not privately allocated and it's not time to free it, just
+ * decrement the count */
+ if (pent->refcnt > 1)
+ pent->refcnt--;
+ else
+ {
+ /* If the color type is shared, find the sharedcolor. If decremented
+ * refcnt is 0, free the shared cell. */
+ if (pent->fShared)
+ {
+ if(--pent->co.shco.red->refcnt == 0)
+ free(pent->co.shco.red);
+ if(--pent->co.shco.green->refcnt == 0)
+ free(pent->co.shco.green);
+ if(--pent->co.shco.blue->refcnt == 0)
+ free(pent->co.shco.blue);
+ pent->fShared = FALSE;
+ }
+ pent->refcnt = 0;
+ *pCount += 1;
+ }
+}
+
+static void
+UpdateColors (ColormapPtr pmap)
+{
+ xColorItem *defs;
+ xColorItem *pdef;
+ EntryPtr pent;
+ VisualPtr pVisual;
+ int i, n, size;
+
+ pVisual = pmap->pVisual;
+ size = pVisual->ColormapEntries;
+ defs = malloc(size * sizeof(xColorItem));
+ if (!defs)
+ return;
+ n = 0;
+ pdef = defs;
+ if (pmap->class == DirectColor)
+ {
+ for (i = 0; i < size; i++)
+ {
+ if (!pmap->red[i].refcnt &&
+ !pmap->green[i].refcnt &&
+ !pmap->blue[i].refcnt)
+ continue;
+ pdef->pixel = ((Pixel)i << pVisual->offsetRed) |
+ ((Pixel)i << pVisual->offsetGreen) |
+ ((Pixel)i << pVisual->offsetBlue);
+ pdef->red = pmap->red[i].co.local.red;
+ pdef->green = pmap->green[i].co.local.green;
+ pdef->blue = pmap->blue[i].co.local.blue;
+ pdef->flags = DoRed|DoGreen|DoBlue;
+ pdef++;
+ n++;
+ }
+ }
+ else
+ {
+ for (i = 0, pent = pmap->red; i < size; i++, pent++)
+ {
+ if (!pent->refcnt)
+ continue;
+ pdef->pixel = i;
+ if(pent->fShared)
+ {
+ pdef->red = pent->co.shco.red->color;
+ pdef->green = pent->co.shco.green->color;
+ pdef->blue = pent->co.shco.blue->color;
+ }
+ else
+ {
+ pdef->red = pent->co.local.red;
+ pdef->green = pent->co.local.green;
+ pdef->blue = pent->co.local.blue;
+ }
+ pdef->flags = DoRed|DoGreen|DoBlue;
+ pdef++;
+ n++;
+ }
+ }
+ if (n)
+ (*pmap->pScreen->StoreColors)(pmap, n, defs);
+ free(defs);
+}
+
+/* Get a read-only color from a ColorMap (probably slow for large maps)
+ * Returns by changing the value in pred, pgreen, pblue and pPix
+ */
+int
+AllocColor (ColormapPtr pmap,
+ unsigned short *pred, unsigned short *pgreen, unsigned short *pblue,
+ Pixel *pPix, int client)
+{
+ Pixel pixR, pixG, pixB;
+ int entries;
+ xrgb rgb;
+ int class;
+ VisualPtr pVisual;
+ int npix;
+ Pixel *ppix;
+
+ pVisual = pmap->pVisual;
+ (*pmap->pScreen->ResolveColor) (pred, pgreen, pblue, pVisual);
+ rgb.red = *pred;
+ rgb.green = *pgreen;
+ rgb.blue = *pblue;
+ class = pmap->class;
+ entries = pVisual->ColormapEntries;
+
+ /* If the colormap is being created, then we want to be able to change
+ * the colormap, even if it's a static type. Otherwise, we'd never be
+ * able to initialize static colormaps
+ */
+ if(pmap->flags & BeingCreated)
+ class |= DynamicClass;
+
+ /* If this is one of the static storage classes, and we're not initializing
+ * it, the best we can do is to find the closest color entry to the
+ * requested one and return that.
+ */
+ switch (class) {
+ case StaticColor:
+ case StaticGray:
+ /* Look up all three components in the same pmap */
+ *pPix = pixR = FindBestPixel(pmap->red, entries, &rgb, PSEUDOMAP);
+ *pred = pmap->red[pixR].co.local.red;
+ *pgreen = pmap->red[pixR].co.local.green;
+ *pblue = pmap->red[pixR].co.local.blue;
+ npix = pmap->numPixelsRed[client];
+ ppix = (Pixel *) realloc(pmap->clientPixelsRed[client],
+ (npix + 1) * sizeof(Pixel));
+ if (!ppix)
+ return BadAlloc;
+ ppix[npix] = pixR;
+ pmap->clientPixelsRed[client] = ppix;
+ pmap->numPixelsRed[client]++;
+ break;
+
+ case TrueColor:
+ /* Look up each component in its own map, then OR them together */
+ pixR = FindBestPixel(pmap->red, NUMRED(pVisual), &rgb, REDMAP);
+ pixG = FindBestPixel(pmap->green, NUMGREEN(pVisual), &rgb, GREENMAP);
+ pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP);
+ *pPix = (pixR << pVisual->offsetRed) |
+ (pixG << pVisual->offsetGreen) |
+ (pixB << pVisual->offsetBlue) |
+ ALPHAMASK(pVisual);
+
+ *pred = pmap->red[pixR].co.local.red;
+ *pgreen = pmap->green[pixG].co.local.green;
+ *pblue = pmap->blue[pixB].co.local.blue;
+ npix = pmap->numPixelsRed[client];
+ ppix = (Pixel *) realloc(pmap->clientPixelsRed[client],
+ (npix + 1) * sizeof(Pixel));
+ if (!ppix)
+ return BadAlloc;
+ ppix[npix] = pixR;
+ pmap->clientPixelsRed[client] = ppix;
+ npix = pmap->numPixelsGreen[client];
+ ppix = (Pixel *) realloc(pmap->clientPixelsGreen[client],
+ (npix + 1) * sizeof(Pixel));
+ if (!ppix)
+ return BadAlloc;
+ ppix[npix] = pixG;
+ pmap->clientPixelsGreen[client] = ppix;
+ npix = pmap->numPixelsBlue[client];
+ ppix = (Pixel *) realloc(pmap->clientPixelsBlue[client],
+ (npix + 1) * sizeof(Pixel));
+ if (!ppix)
+ return BadAlloc;
+ ppix[npix] = pixB;
+ pmap->clientPixelsBlue[client] = ppix;
+ pmap->numPixelsRed[client]++;
+ pmap->numPixelsGreen[client]++;
+ pmap->numPixelsBlue[client]++;
+ break;
+
+ case GrayScale:
+ case PseudoColor:
+ if (pmap->mid != pmap->pScreen->defColormap &&
+ pmap->pVisual->vid == pmap->pScreen->rootVisual)
+ {
+ ColormapPtr prootmap;
+ dixLookupResourceByType((pointer *)&prootmap, pmap->pScreen->defColormap,
+ RT_COLORMAP, clients[client], DixReadAccess);
+
+ if (pmap->class == prootmap->class)
+ FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb,
+ pPix, PSEUDOMAP, AllComp);
+ }
+ if (FindColor(pmap, pmap->red, entries, &rgb, pPix, PSEUDOMAP,
+ client, AllComp) != Success)
+ return BadAlloc;
+ break;
+
+ case DirectColor:
+ if (pmap->mid != pmap->pScreen->defColormap &&
+ pmap->pVisual->vid == pmap->pScreen->rootVisual)
+ {
+ ColormapPtr prootmap;
+ dixLookupResourceByType((pointer *)&prootmap, pmap->pScreen->defColormap,
+ RT_COLORMAP, clients[client], DixReadAccess);
+
+ if (pmap->class == prootmap->class)
+ {
+ pixR = (*pPix & pVisual->redMask) >> pVisual->offsetRed;
+ FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb,
+ &pixR, REDMAP, RedComp);
+ pixG = (*pPix & pVisual->greenMask) >> pVisual->offsetGreen;
+ FindColorInRootCmap (prootmap, prootmap->green, entries, &rgb,
+ &pixG, GREENMAP, GreenComp);
+ pixB = (*pPix & pVisual->blueMask) >> pVisual->offsetBlue;
+ FindColorInRootCmap (prootmap, prootmap->blue, entries, &rgb,
+ &pixB, BLUEMAP, BlueComp);
+ *pPix = pixR | pixG | pixB;
+ }
+ }
+
+ pixR = (*pPix & pVisual->redMask) >> pVisual->offsetRed;
+ if (FindColor(pmap, pmap->red, NUMRED(pVisual), &rgb, &pixR, REDMAP,
+ client, RedComp) != Success)
+ return BadAlloc;
+ pixG = (*pPix & pVisual->greenMask) >> pVisual->offsetGreen;
+ if (FindColor(pmap, pmap->green, NUMGREEN(pVisual), &rgb, &pixG,
+ GREENMAP, client, GreenComp) != Success)
+ {
+ (void)FreeCo(pmap, client, REDMAP, 1, &pixR, (Pixel)0);
+ return BadAlloc;
+ }
+ pixB = (*pPix & pVisual->blueMask) >> pVisual->offsetBlue;
+ if (FindColor(pmap, pmap->blue, NUMBLUE(pVisual), &rgb, &pixB, BLUEMAP,
+ client, BlueComp) != Success)
+ {
+ (void)FreeCo(pmap, client, GREENMAP, 1, &pixG, (Pixel)0);
+ (void)FreeCo(pmap, client, REDMAP, 1, &pixR, (Pixel)0);
+ return BadAlloc;
+ }
+ *pPix = pixR | pixG | pixB | ALPHAMASK(pVisual);
+
+ break;
+ }
+
+ /* if this is the client's first pixel in this colormap, tell the
+ * resource manager that the client has pixels in this colormap which
+ * should be freed when the client dies */
+ if ((pmap->numPixelsRed[client] == 1) &&
+ (CLIENT_ID(pmap->mid) != client) &&
+ !(pmap->flags & BeingCreated))
+ {
+ colorResource *pcr;
+
+ pcr = malloc(sizeof(colorResource));
+ if (!pcr)
+ {
+ (void)FreeColors(pmap, client, 1, pPix, (Pixel)0);
+ return BadAlloc;
+ }
+ pcr->mid = pmap->mid;
+ pcr->client = client;
+ if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr))
+ return BadAlloc;
+ }
+ return Success;
+}
+
+/*
+ * FakeAllocColor -- fake an AllocColor request by
+ * returning a free pixel if availible, otherwise returning
+ * the closest matching pixel. This is used by the mi
+ * software sprite code to recolor cursors. A nice side-effect
+ * is that this routine will never return failure.
+ */
+
+void
+FakeAllocColor (ColormapPtr pmap, xColorItem *item)
+{
+ Pixel pixR, pixG, pixB;
+ Pixel temp;
+ int entries;
+ xrgb rgb;
+ int class;
+ VisualPtr pVisual;
+
+ pVisual = pmap->pVisual;
+ rgb.red = item->red;
+ rgb.green = item->green;
+ rgb.blue = item->blue;
+ (*pmap->pScreen->ResolveColor) (&rgb.red, &rgb.green, &rgb.blue, pVisual);
+ class = pmap->class;
+ entries = pVisual->ColormapEntries;
+
+ switch (class) {
+ case GrayScale:
+ case PseudoColor:
+ temp = 0;
+ item->pixel = 0;
+ if (FindColor(pmap, pmap->red, entries, &rgb, &temp, PSEUDOMAP,
+ -1, AllComp) == Success) {
+ item->pixel = temp;
+ break;
+ }
+ /* fall through ... */
+ case StaticColor:
+ case StaticGray:
+ item->pixel = FindBestPixel(pmap->red, entries, &rgb, PSEUDOMAP);
+ break;
+
+ case DirectColor:
+ /* Look up each component in its own map, then OR them together */
+ pixR = (item->pixel & pVisual->redMask) >> pVisual->offsetRed;
+ pixG = (item->pixel & pVisual->greenMask) >> pVisual->offsetGreen;
+ pixB = (item->pixel & pVisual->blueMask) >> pVisual->offsetBlue;
+ if (FindColor(pmap, pmap->red, NUMRED(pVisual), &rgb, &pixR, REDMAP,
+ -1, RedComp) != Success)
+ pixR = FindBestPixel(pmap->red, NUMRED(pVisual), &rgb, REDMAP)
+ << pVisual->offsetRed;
+ if (FindColor(pmap, pmap->green, NUMGREEN(pVisual), &rgb, &pixG,
+ GREENMAP, -1, GreenComp) != Success)
+ pixG = FindBestPixel(pmap->green, NUMGREEN(pVisual), &rgb,
+ GREENMAP) << pVisual->offsetGreen;
+ if (FindColor(pmap, pmap->blue, NUMBLUE(pVisual), &rgb, &pixB, BLUEMAP,
+ -1, BlueComp) != Success)
+ pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP)
+ << pVisual->offsetBlue;
+ item->pixel = pixR | pixG | pixB;
+ break;
+
+ case TrueColor:
+ /* Look up each component in its own map, then OR them together */
+ pixR = FindBestPixel(pmap->red, NUMRED(pVisual), &rgb, REDMAP);
+ pixG = FindBestPixel(pmap->green, NUMGREEN(pVisual), &rgb, GREENMAP);
+ pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP);
+ item->pixel = (pixR << pVisual->offsetRed) |
+ (pixG << pVisual->offsetGreen) |
+ (pixB << pVisual->offsetBlue);
+ break;
+ }
+}
+
+/* free a pixel value obtained from FakeAllocColor */
+void
+FakeFreeColor(ColormapPtr pmap, Pixel pixel)
+{
+ VisualPtr pVisual;
+ Pixel pixR, pixG, pixB;
+
+ switch (pmap->class) {
+ case GrayScale:
+ case PseudoColor:
+ if (pmap->red[pixel].refcnt == AllocTemporary)
+ pmap->red[pixel].refcnt = 0;
+ break;
+ case DirectColor:
+ pVisual = pmap->pVisual;
+ pixR = (pixel & pVisual->redMask) >> pVisual->offsetRed;
+ pixG = (pixel & pVisual->greenMask) >> pVisual->offsetGreen;
+ pixB = (pixel & pVisual->blueMask) >> pVisual->offsetBlue;
+ if (pmap->red[pixR].refcnt == AllocTemporary)
+ pmap->red[pixR].refcnt = 0;
+ if (pmap->green[pixG].refcnt == AllocTemporary)
+ pmap->green[pixG].refcnt = 0;
+ if (pmap->blue[pixB].refcnt == AllocTemporary)
+ pmap->blue[pixB].refcnt = 0;
+ break;
+ }
+}
+
+typedef unsigned short BigNumUpper;
+typedef unsigned long BigNumLower;
+
+#define BIGNUMLOWERBITS 24
+#define BIGNUMUPPERBITS 16
+#define BIGNUMLOWER (1 << BIGNUMLOWERBITS)
+#define BIGNUMUPPER (1 << BIGNUMUPPERBITS)
+#define UPPERPART(i) ((i) >> BIGNUMLOWERBITS)
+#define LOWERPART(i) ((i) & (BIGNUMLOWER - 1))
+
+typedef struct _bignum {
+ BigNumUpper upper;
+ BigNumLower lower;
+} BigNumRec, *BigNumPtr;
+
+#define BigNumGreater(x,y) (((x)->upper > (y)->upper) ||\
+ ((x)->upper == (y)->upper && (x)->lower > (y)->lower))
+
+#define UnsignedToBigNum(u,r) (((r)->upper = UPPERPART(u)), \
+ ((r)->lower = LOWERPART(u)))
+
+#define MaxBigNum(r) (((r)->upper = BIGNUMUPPER-1), \
+ ((r)->lower = BIGNUMLOWER-1))
+
+static void
+BigNumAdd (BigNumPtr x, BigNumPtr y, BigNumPtr r)
+{
+ BigNumLower lower, carry = 0;
+
+ lower = x->lower + y->lower;
+ if (lower >= BIGNUMLOWER) {
+ lower -= BIGNUMLOWER;
+ carry = 1;
+ }
+ r->lower = lower;
+ r->upper = x->upper + y->upper + carry;
+}
+
+static Pixel
+FindBestPixel(EntryPtr pentFirst, int size, xrgb *prgb, int channel)
+{
+ EntryPtr pent;
+ Pixel pixel, final;
+ long dr, dg, db;
+ unsigned long sq;
+ BigNumRec minval, sum, temp;
+
+ final = 0;
+ MaxBigNum(&minval);
+ /* look for the minimal difference */
+ for (pent = pentFirst, pixel = 0; pixel < size; pent++, pixel++)
+ {
+ dr = dg = db = 0;
+ switch(channel)
+ {
+ case PSEUDOMAP:
+ dg = (long) pent->co.local.green - prgb->green;
+ db = (long) pent->co.local.blue - prgb->blue;
+ case REDMAP:
+ dr = (long) pent->co.local.red - prgb->red;
+ break;
+ case GREENMAP:
+ dg = (long) pent->co.local.green - prgb->green;
+ break;
+ case BLUEMAP:
+ db = (long) pent->co.local.blue - prgb->blue;
+ break;
+ }
+ sq = dr * dr;
+ UnsignedToBigNum (sq, &sum);
+ sq = dg * dg;
+ UnsignedToBigNum (sq, &temp);
+ BigNumAdd (&sum, &temp, &sum);
+ sq = db * db;
+ UnsignedToBigNum (sq, &temp);
+ BigNumAdd (&sum, &temp, &sum);
+ if (BigNumGreater (&minval, &sum))
+ {
+ final = pixel;
+ minval = sum;
+ }
+ }
+ return final;
+}
+
+static void
+FindColorInRootCmap (ColormapPtr pmap, EntryPtr pentFirst, int size,
+ xrgb *prgb, Pixel *pPixel, int channel,
+ ColorCompareProcPtr comp)
+{
+ EntryPtr pent;
+ Pixel pixel;
+ int count;
+
+ if ((pixel = *pPixel) >= size)
+ pixel = 0;
+ for (pent = pentFirst + pixel, count = size; --count >= 0; pent++, pixel++)
+ {
+ if (pent->refcnt > 0 && (*comp) (pent, prgb))
+ {
+ switch (channel)
+ {
+ case REDMAP:
+ pixel <<= pmap->pVisual->offsetRed;
+ break;
+ case GREENMAP:
+ pixel <<= pmap->pVisual->offsetGreen;
+ break;
+ case BLUEMAP:
+ pixel <<= pmap->pVisual->offsetBlue;
+ break;
+ default: /* PSEUDOMAP */
+ break;
+ }
+ *pPixel = pixel;
+ }
+ }
+}
+
+/* Tries to find a color in pmap that exactly matches the one requested in prgb
+ * if it can't it allocates one.
+ * Starts looking at pentFirst + *pPixel, so if you want a specific pixel,
+ * load *pPixel with that value, otherwise set it to 0
+ */
+int
+FindColor (ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb *prgb,
+ Pixel *pPixel, int channel, int client,
+ ColorCompareProcPtr comp)
+{
+ EntryPtr pent;
+ Bool foundFree;
+ Pixel pixel, Free = 0;
+ int npix, count, *nump = NULL;
+ Pixel **pixp = NULL, *ppix;
+ xColorItem def;
+
+ foundFree = FALSE;
+
+ if((pixel = *pPixel) >= size)
+ pixel = 0;
+ /* see if there is a match, and also look for a free entry */
+ for (pent = pentFirst + pixel, count = size; --count >= 0; )
+ {
+ if (pent->refcnt > 0)
+ {
+ if ((*comp) (pent, prgb))
+ {
+ if (client >= 0)
+ pent->refcnt++;
+ *pPixel = pixel;
+ switch(channel)
+ {
+ case REDMAP:
+ *pPixel <<= pmap->pVisual->offsetRed;
+ case PSEUDOMAP:
+ break;
+ case GREENMAP:
+ *pPixel <<= pmap->pVisual->offsetGreen;
+ break;
+ case BLUEMAP:
+ *pPixel <<= pmap->pVisual->offsetBlue;
+ break;
+ }
+ goto gotit;
+ }
+ }
+ else if (!foundFree && pent->refcnt == 0)
+ {
+ Free = pixel;
+ foundFree = TRUE;
+ /* If we're initializing the colormap, then we are looking for
+ * the first free cell we can find, not to minimize the number
+ * of entries we use. So don't look any further. */
+ if(pmap->flags & BeingCreated)
+ break;
+ }
+ pixel++;
+ if(pixel >= size)
+ {
+ pent = pentFirst;
+ pixel = 0;
+ }
+ else
+ pent++;
+ }
+
+ /* If we got here, we didn't find a match. If we also didn't find
+ * a free entry, we're out of luck. Otherwise, we'll usurp a free
+ * entry and fill it in */
+ if (!foundFree)
+ return BadAlloc;
+ pent = pentFirst + Free;
+ pent->fShared = FALSE;
+ pent->refcnt = (client >= 0) ? 1 : AllocTemporary;
+
+ switch (channel)
+ {
+ case PSEUDOMAP:
+ pent->co.local.red = prgb->red;
+ pent->co.local.green = prgb->green;
+ pent->co.local.blue = prgb->blue;
+ def.red = prgb->red;
+ def.green = prgb->green;
+ def.blue = prgb->blue;
+ def.flags = (DoRed|DoGreen|DoBlue);
+ if (client >= 0)
+ pmap->freeRed--;
+ def.pixel = Free;
+ break;
+
+ case REDMAP:
+ pent->co.local.red = prgb->red;
+ def.red = prgb->red;
+ def.green = pmap->green[0].co.local.green;
+ def.blue = pmap->blue[0].co.local.blue;
+ def.flags = DoRed;
+ if (client >= 0)
+ pmap->freeRed--;
+ def.pixel = Free << pmap->pVisual->offsetRed;
+ break;
+
+ case GREENMAP:
+ pent->co.local.green = prgb->green;
+ def.red = pmap->red[0].co.local.red;
+ def.green = prgb->green;
+ def.blue = pmap->blue[0].co.local.blue;
+ def.flags = DoGreen;
+ if (client >= 0)
+ pmap->freeGreen--;
+ def.pixel = Free << pmap->pVisual->offsetGreen;
+ break;
+
+ case BLUEMAP:
+ pent->co.local.blue = prgb->blue;
+ def.red = pmap->red[0].co.local.red;
+ def.green = pmap->green[0].co.local.green;
+ def.blue = prgb->blue;
+ def.flags = DoBlue;
+ if (client >= 0)
+ pmap->freeBlue--;
+ def.pixel = Free << pmap->pVisual->offsetBlue;
+ break;
+ }
+ (*pmap->pScreen->StoreColors) (pmap, 1, &def);
+ pixel = Free;
+ *pPixel = def.pixel;
+
+gotit:
+ if (pmap->flags & BeingCreated || client == -1)
+ return Success;
+ /* Now remember the pixel, for freeing later */
+ switch (channel)
+ {
+ case PSEUDOMAP:
+ case REDMAP:
+ nump = pmap->numPixelsRed;
+ pixp = pmap->clientPixelsRed;
+ break;
+
+ case GREENMAP:
+ nump = pmap->numPixelsGreen;
+ pixp = pmap->clientPixelsGreen;
+ break;
+
+ case BLUEMAP:
+ nump = pmap->numPixelsBlue;
+ pixp = pmap->clientPixelsBlue;
+ break;
+ }
+ npix = nump[client];
+ ppix = (Pixel *) realloc(pixp[client], (npix + 1) * sizeof(Pixel));
+ if (!ppix)
+ {
+ pent->refcnt--;
+ if (!pent->fShared)
+ switch (channel)
+ {
+ case PSEUDOMAP:
+ case REDMAP:
+ pmap->freeRed++;
+ break;
+ case GREENMAP:
+ pmap->freeGreen++;
+ break;
+ case BLUEMAP:
+ pmap->freeBlue++;
+ break;
+ }
+ return BadAlloc;
+ }
+ ppix[npix] = pixel;
+ pixp[client] = ppix;
+ nump[client]++;
+
+ return Success;
+}
+
+/* Comparison functions -- passed to FindColor to determine if an
+ * entry is already the color we're looking for or not */
+static int
+AllComp (EntryPtr pent, xrgb *prgb)
+{
+ if((pent->co.local.red == prgb->red) &&
+ (pent->co.local.green == prgb->green) &&
+ (pent->co.local.blue == prgb->blue) )
+ return 1;
+ return 0;
+}
+
+static int
+RedComp (EntryPtr pent, xrgb *prgb)
+{
+ if (pent->co.local.red == prgb->red)
+ return 1;
+ return 0;
+}
+
+static int
+GreenComp (EntryPtr pent, xrgb *prgb)
+{
+ if (pent->co.local.green == prgb->green)
+ return 1;
+ return 0;
+}
+
+static int
+BlueComp (EntryPtr pent, xrgb *prgb)
+{
+ if (pent->co.local.blue == prgb->blue)
+ return 1;
+ return 0;
+}
+
+
+/* Read the color value of a cell */
+
+int
+QueryColors (ColormapPtr pmap, int count, Pixel *ppixIn, xrgb *prgbList, ClientPtr client)
+{
+ Pixel *ppix, pixel;
+ xrgb *prgb;
+ VisualPtr pVisual;
+ EntryPtr pent;
+ Pixel i;
+ int errVal = Success;
+
+ pVisual = pmap->pVisual;
+ if ((pmap->class | DynamicClass) == DirectColor)
+ {
+ int numred, numgreen, numblue;
+ Pixel rgbbad;
+
+ numred = NUMRED(pVisual);
+ numgreen = NUMGREEN(pVisual);
+ numblue = NUMBLUE(pVisual);
+ rgbbad = ~RGBMASK(pVisual);
+ for( ppix = ppixIn, prgb = prgbList; --count >= 0; ppix++, prgb++)
+ {
+ pixel = *ppix;
+ if (pixel & rgbbad) {
+ client->errorValue = pixel;
+ errVal = BadValue;
+ continue;
+ }
+ i = (pixel & pVisual->redMask) >> pVisual->offsetRed;
+ if (i >= numred)
+ {
+ client->errorValue = pixel;
+ errVal = BadValue;
+ continue;
+ }
+ prgb->red = pmap->red[i].co.local.red;
+ i = (pixel & pVisual->greenMask) >> pVisual->offsetGreen;
+ if (i >= numgreen)
+ {
+ client->errorValue = pixel;
+ errVal = BadValue;
+ continue;
+ }
+ prgb->green = pmap->green[i].co.local.green;
+ i = (pixel & pVisual->blueMask) >> pVisual->offsetBlue;
+ if (i >= numblue)
+ {
+ client->errorValue = pixel;
+ errVal = BadValue;
+ continue;
+ }
+ prgb->blue = pmap->blue[i].co.local.blue;
+ }
+ }
+ else
+ {
+ for( ppix = ppixIn, prgb = prgbList; --count >= 0; ppix++, prgb++)
+ {
+ pixel = *ppix;
+ if (pixel >= pVisual->ColormapEntries)
+ {
+ client->errorValue = pixel;
+ errVal = BadValue;
+ }
+ else
+ {
+ pent = (EntryPtr)&pmap->red[pixel];
+ if (pent->fShared)
+ {
+ prgb->red = pent->co.shco.red->color;
+ prgb->green = pent->co.shco.green->color;
+ prgb->blue = pent->co.shco.blue->color;
+ }
+ else
+ {
+ prgb->red = pent->co.local.red;
+ prgb->green = pent->co.local.green;
+ prgb->blue = pent->co.local.blue;
+ }
+ }
+ }
+ }
+ return errVal;
+}
+
+static void
+FreePixels(ColormapPtr pmap, int client)
+{
+ Pixel *ppix, *ppixStart;
+ int n;
+ int class;
+
+ class = pmap->class;
+ ppixStart = pmap->clientPixelsRed[client];
+ if (class & DynamicClass)
+ {
+ n = pmap->numPixelsRed[client];
+ for (ppix = ppixStart; --n >= 0; )
+ {
+ FreeCell(pmap, *ppix, REDMAP);
+ ppix++;
+ }
+ }
+
+ free(ppixStart);
+ pmap->clientPixelsRed[client] = (Pixel *) NULL;
+ pmap->numPixelsRed[client] = 0;
+ if ((class | DynamicClass) == DirectColor)
+ {
+ ppixStart = pmap->clientPixelsGreen[client];
+ if (class & DynamicClass)
+ for (ppix = ppixStart, n = pmap->numPixelsGreen[client]; --n >= 0;)
+ FreeCell(pmap, *ppix++, GREENMAP);
+ free(ppixStart);
+ pmap->clientPixelsGreen[client] = (Pixel *) NULL;
+ pmap->numPixelsGreen[client] = 0;
+
+ ppixStart = pmap->clientPixelsBlue[client];
+ if (class & DynamicClass)
+ for (ppix = ppixStart, n = pmap->numPixelsBlue[client]; --n >= 0; )
+ FreeCell(pmap, *ppix++, BLUEMAP);
+ free(ppixStart);
+ pmap->clientPixelsBlue[client] = (Pixel *) NULL;
+ pmap->numPixelsBlue[client] = 0;
+ }
+}
+
+/**
+ * Frees all of a client's colors and cells.
+ *
+ * \param value must conform to DeleteType
+ * \unused fakeid
+ */
+int
+FreeClientPixels (pointer value, XID fakeid)
+{
+ pointer pmap;
+ colorResource *pcr = value;
+ int rc;
+
+ rc = dixLookupResourceByType(&pmap, pcr->mid, RT_COLORMAP, serverClient,
+ DixRemoveAccess);
+ if (rc == Success)
+ FreePixels((ColormapPtr)pmap, pcr->client);
+ free(pcr);
+ return Success;
+}
+
+int
+AllocColorCells (int client, ColormapPtr pmap, int colors, int planes,
+ Bool contig, Pixel *ppix, Pixel *masks)
+{
+ Pixel rmask, gmask, bmask, *ppixFirst, r, g, b;
+ int n, class;
+ int ok;
+ int oldcount;
+ colorResource *pcr = (colorResource *)NULL;
+
+ class = pmap->class;
+ if (!(class & DynamicClass))
+ return BadAlloc; /* Shouldn't try on this type */
+ oldcount = pmap->numPixelsRed[client];
+ if (pmap->class == DirectColor)
+ oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client];
+ if (!oldcount && (CLIENT_ID(pmap->mid) != client))
+ {
+ pcr = malloc(sizeof(colorResource));
+ if (!pcr)
+ return BadAlloc;
+ }
+
+ if (pmap->class == DirectColor)
+ {
+ ok = AllocDirect (client, pmap, colors, planes, planes, planes,
+ contig, ppix, &rmask, &gmask, &bmask);
+ if(ok == Success)
+ {
+ for (r = g = b = 1, n = planes; --n >= 0; r += r, g += g, b += b)
+ {
+ while(!(rmask & r))
+ r += r;
+ while(!(gmask & g))
+ g += g;
+ while(!(bmask & b))
+ b += b;
+ *masks++ = r | g | b;
+ }
+ }
+ }
+ else
+ {
+ ok = AllocPseudo (client, pmap, colors, planes, contig, ppix, &rmask,
+ &ppixFirst);
+ if(ok == Success)
+ {
+ for (r = 1, n = planes; --n >= 0; r += r)
+ {
+ while(!(rmask & r))
+ r += r;
+ *masks++ = r;
+ }
+ }
+ }
+
+ /* if this is the client's first pixels in this colormap, tell the
+ * resource manager that the client has pixels in this colormap which
+ * should be freed when the client dies */
+ if ((ok == Success) && pcr)
+ {
+ pcr->mid = pmap->mid;
+ pcr->client = client;
+ if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr))
+ ok = BadAlloc;
+ } else free(pcr);
+
+ return ok;
+}
+
+
+int
+AllocColorPlanes (int client, ColormapPtr pmap, int colors,
+ int r, int g, int b, Bool contig, Pixel *pixels,
+ Pixel *prmask, Pixel *pgmask, Pixel *pbmask)
+{
+ int ok;
+ Pixel mask, *ppixFirst;
+ Pixel shift;
+ int i;
+ int class;
+ int oldcount;
+ colorResource *pcr = (colorResource *)NULL;
+
+ class = pmap->class;
+ if (!(class & DynamicClass))
+ return BadAlloc; /* Shouldn't try on this type */
+ oldcount = pmap->numPixelsRed[client];
+ if (class == DirectColor)
+ oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client];
+ if (!oldcount && (CLIENT_ID(pmap->mid) != client))
+ {
+ pcr = malloc(sizeof(colorResource));
+ if (!pcr)
+ return BadAlloc;
+ }
+
+ if (class == DirectColor)
+ {
+ ok = AllocDirect (client, pmap, colors, r, g, b, contig, pixels,
+ prmask, pgmask, pbmask);
+ }
+ else
+ {
+ /* Allocate the proper pixels */
+ /* XXX This is sort of bad, because of contig is set, we force all
+ * r + g + b bits to be contiguous. Should only force contiguity
+ * per mask
+ */
+ ok = AllocPseudo (client, pmap, colors, r + g + b, contig, pixels,
+ &mask, &ppixFirst);
+
+ if(ok == Success)
+ {
+ /* now split that mask into three */
+ *prmask = *pgmask = *pbmask = 0;
+ shift = 1;
+ for (i = r; --i >= 0; shift += shift)
+ {
+ while (!(mask & shift))
+ shift += shift;
+ *prmask |= shift;
+ }
+ for (i = g; --i >= 0; shift += shift)
+ {
+ while (!(mask & shift))
+ shift += shift;
+ *pgmask |= shift;
+ }
+ for (i = b; --i >= 0; shift += shift)
+ {
+ while (!(mask & shift))
+ shift += shift;
+ *pbmask |= shift;
+ }
+
+ /* set up the shared color cells */
+ if (!AllocShared(pmap, pixels, colors, r, g, b,
+ *prmask, *pgmask, *pbmask, ppixFirst))
+ {
+ (void)FreeColors(pmap, client, colors, pixels, mask);
+ ok = BadAlloc;
+ }
+ }
+ }
+
+ /* if this is the client's first pixels in this colormap, tell the
+ * resource manager that the client has pixels in this colormap which
+ * should be freed when the client dies */
+ if ((ok == Success) && pcr)
+ {
+ pcr->mid = pmap->mid;
+ pcr->client = client;
+ if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr))
+ ok = BadAlloc;
+ } else free(pcr);
+
+ return ok;
+}
+
+static int
+AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool contig,
+ Pixel *pixels, Pixel *prmask, Pixel *pgmask, Pixel *pbmask)
+{
+ Pixel *ppixRed, *ppixGreen, *ppixBlue;
+ Pixel *ppix, *pDst, *p;
+ int npix, npixR, npixG, npixB;
+ Bool okR, okG, okB;
+ Pixel *rpix = 0, *gpix = 0, *bpix = 0;
+
+ npixR = c << r;
+ npixG = c << g;
+ npixB = c << b;
+ if ((r >= 32) || (g >= 32) || (b >= 32) ||
+ (npixR > pmap->freeRed) || (npixR < c) ||
+ (npixG > pmap->freeGreen) || (npixG < c) ||
+ (npixB > pmap->freeBlue) || (npixB < c))
+ return BadAlloc;
+
+ /* start out with empty pixels */
+ for(p = pixels; p < pixels + c; p++)
+ *p = 0;
+
+ ppixRed = malloc(npixR * sizeof(Pixel));
+ ppixGreen = malloc(npixG * sizeof(Pixel));
+ ppixBlue = malloc(npixB * sizeof(Pixel));
+ if (!ppixRed || !ppixGreen || !ppixBlue)
+ {
+ free(ppixBlue);
+ free(ppixGreen);
+ free(ppixRed);
+ return BadAlloc;
+ }
+
+ okR = AllocCP(pmap, pmap->red, c, r, contig, ppixRed, prmask);
+ okG = AllocCP(pmap, pmap->green, c, g, contig, ppixGreen, pgmask);
+ okB = AllocCP(pmap, pmap->blue, c, b, contig, ppixBlue, pbmask);
+
+ if (okR && okG && okB)
+ {
+ rpix = (Pixel *) realloc(pmap->clientPixelsRed[client],
+ (pmap->numPixelsRed[client] + (c << r)) *
+ sizeof(Pixel));
+ if (rpix)
+ pmap->clientPixelsRed[client] = rpix;
+ gpix = (Pixel *) realloc(pmap->clientPixelsGreen[client],
+ (pmap->numPixelsGreen[client] + (c << g)) *
+ sizeof(Pixel));
+ if (gpix)
+ pmap->clientPixelsGreen[client] = gpix;
+ bpix = (Pixel *) realloc(pmap->clientPixelsBlue[client],
+ (pmap->numPixelsBlue[client] + (c << b)) *
+ sizeof(Pixel));
+ if (bpix)
+ pmap->clientPixelsBlue[client] = bpix;
+ }
+
+ if (!okR || !okG || !okB || !rpix || !gpix || !bpix)
+ {
+ if (okR)
+ for(ppix = ppixRed, npix = npixR; --npix >= 0; ppix++)
+ pmap->red[*ppix].refcnt = 0;
+ if (okG)
+ for(ppix = ppixGreen, npix = npixG; --npix >= 0; ppix++)
+ pmap->green[*ppix].refcnt = 0;
+ if (okB)
+ for(ppix = ppixBlue, npix = npixB; --npix >= 0; ppix++)
+ pmap->blue[*ppix].refcnt = 0;
+ free(ppixBlue);
+ free(ppixGreen);
+ free(ppixRed);
+ return BadAlloc;
+ }
+
+ *prmask <<= pmap->pVisual->offsetRed;
+ *pgmask <<= pmap->pVisual->offsetGreen;
+ *pbmask <<= pmap->pVisual->offsetBlue;
+
+ ppix = rpix + pmap->numPixelsRed[client];
+ for (pDst = pixels, p = ppixRed; p < ppixRed + npixR; p++)
+ {
+ *ppix++ = *p;
+ if(p < ppixRed + c)
+ *pDst++ |= *p << pmap->pVisual->offsetRed;
+ }
+ pmap->numPixelsRed[client] += npixR;
+ pmap->freeRed -= npixR;
+
+ ppix = gpix + pmap->numPixelsGreen[client];
+ for (pDst = pixels, p = ppixGreen; p < ppixGreen + npixG; p++)
+ {
+ *ppix++ = *p;
+ if(p < ppixGreen + c)
+ *pDst++ |= *p << pmap->pVisual->offsetGreen;
+ }
+ pmap->numPixelsGreen[client] += npixG;
+ pmap->freeGreen -= npixG;
+
+ ppix = bpix + pmap->numPixelsBlue[client];
+ for (pDst = pixels, p = ppixBlue; p < ppixBlue + npixB; p++)
+ {
+ *ppix++ = *p;
+ if(p < ppixBlue + c)
+ *pDst++ |= *p << pmap->pVisual->offsetBlue;
+ }
+ pmap->numPixelsBlue[client] += npixB;
+ pmap->freeBlue -= npixB;
+
+
+ for (pDst = pixels; pDst < pixels + c; pDst++)
+ *pDst |= ALPHAMASK(pmap->pVisual);
+
+ free(ppixBlue);
+ free(ppixGreen);
+ free(ppixRed);
+
+ return Success;
+}
+
+static int
+AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig,
+ Pixel *pixels, Pixel *pmask, Pixel **pppixFirst)
+{
+ Pixel *ppix, *p, *pDst, *ppixTemp;
+ int npix;
+ Bool ok;
+
+ npix = c << r;
+ if ((r >= 32) || (npix > pmap->freeRed) || (npix < c))
+ return BadAlloc;
+ if(!(ppixTemp = malloc(npix * sizeof(Pixel))))
+ return BadAlloc;
+ ok = AllocCP(pmap, pmap->red, c, r, contig, ppixTemp, pmask);
+
+ if (ok)
+ {
+
+ /* all the allocated pixels are added to the client pixel list,
+ * but only the unique ones are returned to the client */
+ ppix = (Pixel *)realloc(pmap->clientPixelsRed[client],
+ (pmap->numPixelsRed[client] + npix) * sizeof(Pixel));
+ if (!ppix)
+ {
+ for (p = ppixTemp; p < ppixTemp + npix; p++)
+ pmap->red[*p].refcnt = 0;
+ return BadAlloc;
+ }
+ pmap->clientPixelsRed[client] = ppix;
+ ppix += pmap->numPixelsRed[client];
+ *pppixFirst = ppix;
+ pDst = pixels;
+ for (p = ppixTemp; p < ppixTemp + npix; p++)
+ {
+ *ppix++ = *p;
+ if(p < ppixTemp + c)
+ *pDst++ = *p;
+ }
+ pmap->numPixelsRed[client] += npix;
+ pmap->freeRed -= npix;
+ }
+ free(ppixTemp);
+ return ok ? Success : BadAlloc;
+}
+
+/* Allocates count << planes pixels from colormap pmap for client. If
+ * contig, then the plane mask is made of consecutive bits. Returns
+ * all count << pixels in the array pixels. The first count of those
+ * pixels are the unique pixels. *pMask has the mask to Or with the
+ * unique pixels to get the rest of them.
+ *
+ * Returns True iff all pixels could be allocated
+ * All cells allocated will have refcnt set to AllocPrivate and shared to FALSE
+ * (see AllocShared for why we care)
+ */
+static Bool
+AllocCP (ColormapPtr pmap, EntryPtr pentFirst, int count, int planes,
+ Bool contig, Pixel *pixels, Pixel *pMask)
+{
+ EntryPtr ent;
+ Pixel pixel, base, entries, maxp, save;
+ int dplanes, found;
+ Pixel *ppix;
+ Pixel mask;
+ Pixel finalmask;
+
+ dplanes = pmap->pVisual->nplanes;
+
+ /* Easy case. Allocate pixels only */
+ if (planes == 0)
+ {
+ /* allocate writable entries */
+ ppix = pixels;
+ ent = pentFirst;
+ pixel = 0;
+ while (--count >= 0)
+ {
+ /* Just find count unallocated cells */
+ while (ent->refcnt)
+ {
+ ent++;
+ pixel++;
+ }
+ ent->refcnt = AllocPrivate;
+ *ppix++ = pixel;
+ ent->fShared = FALSE;
+ }
+ *pMask = 0;
+ return TRUE;
+ }
+ else if (planes > dplanes)
+ {
+ return FALSE;
+ }
+
+ /* General case count pixels * 2 ^ planes cells to be allocated */
+
+ /* make room for new pixels */
+ ent = pentFirst;
+
+ /* first try for contiguous planes, since it's fastest */
+ for (mask = (((Pixel)1) << planes) - 1, base = 1, dplanes -= (planes - 1);
+ --dplanes >= 0;
+ mask += mask, base += base)
+ {
+ ppix = pixels;
+ found = 0;
+ pixel = 0;
+ entries = pmap->pVisual->ColormapEntries - mask;
+ while (pixel < entries)
+ {
+ save = pixel;
+ maxp = pixel + mask + base;
+ /* check if all are free */
+ while (pixel != maxp && ent[pixel].refcnt == 0)
+ pixel += base;
+ if (pixel == maxp)
+ {
+ /* this one works */
+ *ppix++ = save;
+ found++;
+ if (found == count)
+ {
+ /* found enough, allocate them all */
+ while (--count >= 0)
+ {
+ pixel = pixels[count];
+ maxp = pixel + mask;
+ while (1)
+ {
+ ent[pixel].refcnt = AllocPrivate;
+ ent[pixel].fShared = FALSE;
+ if (pixel == maxp)
+ break;
+ pixel += base;
+ *ppix++ = pixel;
+ }
+ }
+ *pMask = mask;
+ return TRUE;
+ }
+ }
+ pixel = save + 1;
+ if (pixel & mask)
+ pixel += mask;
+ }
+ }
+
+ dplanes = pmap->pVisual->nplanes;
+ if (contig || planes == 1 || dplanes < 3)
+ return FALSE;
+
+ /* this will be very slow for large maps, need a better algorithm */
+
+ /*
+ we can generate the smallest and largest numbers that fits in dplanes
+ bits and contain exactly planes bits set as follows. First, we need to
+ check that it is possible to generate such a mask at all.
+ (Non-contiguous masks need one more bit than contiguous masks). Then
+ the smallest such mask consists of the rightmost planes-1 bits set, then
+ a zero, then a one in position planes + 1. The formula is
+ (3 << (planes-1)) -1
+ The largest such masks consists of the leftmost planes-1 bits set, then
+ a zero, then a one bit in position dplanes-planes-1. If dplanes is
+ smaller than 32 (the number of bits in a word) then the formula is:
+ (1<<dplanes) - (1<<(dplanes-planes+1) + (1<<dplanes-planes-1)
+ If dplanes = 32, then we can't calculate (1<<dplanes) and we have
+ to use:
+ ( (1<<(planes-1)) - 1) << (dplanes-planes+1) + (1<<(dplanes-planes-1))
+
+ << Thank you, Loretta>>>
+
+ */
+
+ finalmask =
+ (((((Pixel)1)<<(planes-1)) - 1) << (dplanes-planes+1)) +
+ (((Pixel)1)<<(dplanes-planes-1));
+ for (mask = (((Pixel)3) << (planes -1)) - 1; mask <= finalmask; mask++)
+ {
+ /* next 3 magic statements count number of ones (HAKMEM #169) */
+ pixel = (mask >> 1) & 033333333333;
+ pixel = mask - pixel - ((pixel >> 1) & 033333333333);
+ if ((((pixel + (pixel >> 3)) & 030707070707) % 077) != planes)
+ continue;
+ ppix = pixels;
+ found = 0;
+ entries = pmap->pVisual->ColormapEntries - mask;
+ base = lowbit (mask);
+ for (pixel = 0; pixel < entries; pixel++)
+ {
+ if (pixel & mask)
+ continue;
+ maxp = 0;
+ /* check if all are free */
+ while (ent[pixel + maxp].refcnt == 0)
+ {
+ GetNextBitsOrBreak(maxp, mask, base);
+ }
+ if ((maxp < mask) || (ent[pixel + mask].refcnt != 0))
+ continue;
+ /* this one works */
+ *ppix++ = pixel;
+ found++;
+ if (found < count)
+ continue;
+ /* found enough, allocate them all */
+ while (--count >= 0)
+ {
+ pixel = (pixels)[count];
+ maxp = 0;
+ while (1)
+ {
+ ent[pixel + maxp].refcnt = AllocPrivate;
+ ent[pixel + maxp].fShared = FALSE;
+ GetNextBitsOrBreak(maxp, mask, base);
+ *ppix++ = pixel + maxp;
+ }
+ }
+
+ *pMask = mask;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
+ *
+ * \param ppixFirst First of the client's new pixels
+ */
+static Bool
+AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b,
+ Pixel rmask, Pixel gmask, Pixel bmask, Pixel *ppixFirst)
+{
+ Pixel *pptr, *cptr;
+ int npix, z, npixClientNew, npixShared;
+ Pixel basemask, base, bits, common;
+ SHAREDCOLOR *pshared, **ppshared, **psharedList;
+
+ npixClientNew = c << (r + g + b);
+ npixShared = (c << r) + (c << g) + (c << b);
+ psharedList = malloc(npixShared * sizeof(SHAREDCOLOR *));
+ if (!psharedList)
+ return FALSE;
+ ppshared = psharedList;
+ for (z = npixShared; --z >= 0; )
+ {
+ if (!(ppshared[z] = malloc(sizeof(SHAREDCOLOR))))
+ {
+ for (z++ ; z < npixShared; z++)
+ free(ppshared[z]);
+ return FALSE;
+ }
+ }
+ for(pptr = ppix, npix = c; --npix >= 0; pptr++)
+ {
+ basemask = ~(gmask | bmask);
+ common = *pptr & basemask;
+ if (rmask)
+ {
+ bits = 0;
+ base = lowbit (rmask);
+ while(1)
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (g + b);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == (common | bits))
+ {
+ pmap->red[*cptr].fShared = TRUE;
+ pmap->red[*cptr].co.shco.red = pshared;
+ }
+ }
+ GetNextBitsOrBreak(bits, rmask, base);
+ }
+ }
+ else
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (g + b);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == common)
+ {
+ pmap->red[*cptr].fShared = TRUE;
+ pmap->red[*cptr].co.shco.red = pshared;
+ }
+ }
+ }
+ basemask = ~(rmask | bmask);
+ common = *pptr & basemask;
+ if (gmask)
+ {
+ bits = 0;
+ base = lowbit (gmask);
+ while(1)
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (r + b);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == (common | bits))
+ {
+ pmap->red[*cptr].co.shco.green = pshared;
+ }
+ }
+ GetNextBitsOrBreak(bits, gmask, base);
+ }
+ }
+ else
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (g + b);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == common)
+ {
+ pmap->red[*cptr].co.shco.green = pshared;
+ }
+ }
+ }
+ basemask = ~(rmask | gmask);
+ common = *pptr & basemask;
+ if (bmask)
+ {
+ bits = 0;
+ base = lowbit (bmask);
+ while(1)
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (r + g);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == (common | bits))
+ {
+ pmap->red[*cptr].co.shco.blue = pshared;
+ }
+ }
+ GetNextBitsOrBreak(bits, bmask, base);
+ }
+ }
+ else
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (g + b);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == common)
+ {
+ pmap->red[*cptr].co.shco.blue = pshared;
+ }
+ }
+ }
+ }
+ free(psharedList);
+ return TRUE;
+}
+
+
+/** FreeColors
+ * Free colors and/or cells (probably slow for large numbers)
+ */
+int
+FreeColors (ColormapPtr pmap, int client, int count, Pixel *pixels, Pixel mask)
+{
+ int rval, result, class;
+ Pixel rmask;
+
+ class = pmap->class;
+ if (pmap->flags & AllAllocated)
+ return BadAccess;
+ if ((class | DynamicClass) == DirectColor)
+ {
+ rmask = mask & RGBMASK(pmap->pVisual);
+ result = FreeCo(pmap, client, REDMAP, count, pixels,
+ mask & pmap->pVisual->redMask);
+ /* If any of the three calls fails, we must report that, if more
+ * than one fails, it's ok that we report the last one */
+ rval = FreeCo(pmap, client, GREENMAP, count, pixels,
+ mask & pmap->pVisual->greenMask);
+ if(rval != Success)
+ result = rval;
+ rval = FreeCo(pmap, client, BLUEMAP, count, pixels,
+ mask & pmap->pVisual->blueMask);
+ if(rval != Success)
+ result = rval;
+ }
+ else
+ {
+ rmask = mask & ((((Pixel)1) << pmap->pVisual->nplanes) - 1);
+ result = FreeCo(pmap, client, PSEUDOMAP, count, pixels, rmask);
+ }
+ if ((mask != rmask) && count)
+ {
+ clients[client]->errorValue = *pixels | mask;
+ result = BadValue;
+ }
+ /* XXX should worry about removing any RT_CMAPENTRY resource */
+ return result;
+}
+
+/**
+ * Helper for FreeColors -- frees all combinations of *newpixels and mask bits
+ * which the client has allocated in channel colormap cells of pmap.
+ * doesn't change newpixels if it doesn't need to
+ *
+ * \param pmap which colormap head
+ * \param color which sub-map, eg, RED, BLUE, PSEUDO
+ * \param npixIn number of pixels passed in
+ * \param ppixIn number of base pixels
+ * \param mask mask client gave us
+ */
+static int
+FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixel mask)
+{
+ Pixel *ppixClient, pixTest;
+ int npixClient, npixNew, npix;
+ Pixel bits, base, cmask, rgbbad;
+ Pixel *pptr, *cptr;
+ int n, zapped;
+ int errVal = Success;
+ int offset, numents;
+
+ if (npixIn == 0)
+ return errVal;
+ bits = 0;
+ zapped = 0;
+ base = lowbit (mask);
+
+ switch(color)
+ {
+ case REDMAP:
+ cmask = pmap->pVisual->redMask;
+ rgbbad = ~RGBMASK(pmap->pVisual);
+ offset = pmap->pVisual->offsetRed;
+ numents = (cmask >> offset) + 1;
+ ppixClient = pmap->clientPixelsRed[client];
+ npixClient = pmap->numPixelsRed[client];
+ break;
+ case GREENMAP:
+ cmask = pmap->pVisual->greenMask;
+ rgbbad = ~RGBMASK(pmap->pVisual);
+ offset = pmap->pVisual->offsetGreen;
+ numents = (cmask >> offset) + 1;
+ ppixClient = pmap->clientPixelsGreen[client];
+ npixClient = pmap->numPixelsGreen[client];
+ break;
+ case BLUEMAP:
+ cmask = pmap->pVisual->blueMask;
+ rgbbad = ~RGBMASK(pmap->pVisual);
+ offset = pmap->pVisual->offsetBlue;
+ numents = (cmask >> offset) + 1;
+ ppixClient = pmap->clientPixelsBlue[client];
+ npixClient = pmap->numPixelsBlue[client];
+ break;
+ default: /* so compiler can see that everything gets initialized */
+ case PSEUDOMAP:
+ cmask = ~((Pixel)0);
+ rgbbad = 0;
+ offset = 0;
+ numents = pmap->pVisual->ColormapEntries;
+ ppixClient = pmap->clientPixelsRed[client];
+ npixClient = pmap->numPixelsRed[client];
+ break;
+ }
+
+
+ /* zap all pixels which match */
+ while (1)
+ {
+ /* go through pixel list */
+ for (pptr = ppixIn, n = npixIn; --n >= 0; pptr++)
+ {
+ pixTest = ((*pptr | bits) & cmask) >> offset;
+ if ((pixTest >= numents) || (*pptr & rgbbad))
+ {
+ clients[client]->errorValue = *pptr | bits;
+ errVal = BadValue;
+ continue;
+ }
+
+ /* find match in client list */
+ for (cptr = ppixClient, npix = npixClient;
+ --npix >= 0 && *cptr != pixTest;
+ cptr++) ;
+
+ if (npix >= 0)
+ {
+ if (pmap->class & DynamicClass)
+ {
+ FreeCell(pmap, pixTest, color);
+ }
+ *cptr = ~((Pixel)0);
+ zapped++;
+ }
+ else
+ errVal = BadAccess;
+ }
+ /* generate next bits value */
+ GetNextBitsOrBreak(bits, mask, base);
+ }
+
+ /* delete freed pixels from client pixel list */
+ if (zapped)
+ {
+ npixNew = npixClient - zapped;
+ if (npixNew)
+ {
+ /* Since the list can only get smaller, we can do a copy in
+ * place and then realloc to a smaller size */
+ pptr = cptr = ppixClient;
+
+ /* If we have all the new pixels, we don't have to examine the
+ * rest of the old ones */
+ for(npix = 0; npix < npixNew; cptr++)
+ {
+ if (*cptr != ~((Pixel)0))
+ {
+ *pptr++ = *cptr;
+ npix++;
+ }
+ }
+ pptr = (Pixel *)realloc(ppixClient, npixNew * sizeof(Pixel));
+ if (pptr)
+ ppixClient = pptr;
+ npixClient = npixNew;
+ }
+ else
+ {
+ npixClient = 0;
+ free(ppixClient);
+ ppixClient = (Pixel *)NULL;
+ }
+ switch(color)
+ {
+ case PSEUDOMAP:
+ case REDMAP:
+ pmap->clientPixelsRed[client] = ppixClient;
+ pmap->numPixelsRed[client] = npixClient;
+ break;
+ case GREENMAP:
+ pmap->clientPixelsGreen[client] = ppixClient;
+ pmap->numPixelsGreen[client] = npixClient;
+ break;
+ case BLUEMAP:
+ pmap->clientPixelsBlue[client] = ppixClient;
+ pmap->numPixelsBlue[client] = npixClient;
+ break;
+ }
+ }
+ return errVal;
+}
+
+
+
+/* Redefine color values */
+int
+StoreColors (ColormapPtr pmap, int count, xColorItem *defs, ClientPtr client)
+{
+ Pixel pix;
+ xColorItem *pdef;
+ EntryPtr pent, pentT, pentLast;
+ VisualPtr pVisual;
+ SHAREDCOLOR *pred, *pgreen, *pblue;
+ int n, ChgRed, ChgGreen, ChgBlue, idef;
+ int class, errVal = Success;
+ int ok;
+
+
+ class = pmap->class;
+ if(!(class & DynamicClass) && !(pmap->flags & BeingCreated))
+ {
+ return BadAccess;
+ }
+ pVisual = pmap->pVisual;
+
+ idef = 0;
+ if((class | DynamicClass) == DirectColor)
+ {
+ int numred, numgreen, numblue;
+ Pixel rgbbad;
+
+ numred = NUMRED(pVisual);
+ numgreen = NUMGREEN(pVisual);
+ numblue = NUMBLUE(pVisual);
+ rgbbad = ~RGBMASK(pVisual);
+ for (pdef = defs, n = 0; n < count; pdef++, n++)
+ {
+ ok = TRUE;
+ (*pmap->pScreen->ResolveColor)
+ (&pdef->red, &pdef->green, &pdef->blue, pmap->pVisual);
+
+ if (pdef->pixel & rgbbad)
+ {
+ errVal = BadValue;
+ client->errorValue = pdef->pixel;
+ continue;
+ }
+ pix = (pdef->pixel & pVisual->redMask) >> pVisual->offsetRed;
+ if (pix >= numred)
+ {
+ errVal = BadValue;
+ ok = FALSE;
+ }
+ else if (pmap->red[pix].refcnt != AllocPrivate)
+ {
+ errVal = BadAccess;
+ ok = FALSE;
+ }
+ else if (pdef->flags & DoRed)
+ {
+ pmap->red[pix].co.local.red = pdef->red;
+ }
+ else
+ {
+ pdef->red = pmap->red[pix].co.local.red;
+ }
+
+ pix = (pdef->pixel & pVisual->greenMask) >> pVisual->offsetGreen;
+ if (pix >= numgreen)
+ {
+ errVal = BadValue;
+ ok = FALSE;
+ }
+ else if (pmap->green[pix].refcnt != AllocPrivate)
+ {
+ errVal = BadAccess;
+ ok = FALSE;
+ }
+ else if (pdef->flags & DoGreen)
+ {
+ pmap->green[pix].co.local.green = pdef->green;
+ }
+ else
+ {
+ pdef->green = pmap->green[pix].co.local.green;
+ }
+
+ pix = (pdef->pixel & pVisual->blueMask) >> pVisual->offsetBlue;
+ if (pix >= numblue)
+ {
+ errVal = BadValue;
+ ok = FALSE;
+ }
+ else if (pmap->blue[pix].refcnt != AllocPrivate)
+ {
+ errVal = BadAccess;
+ ok = FALSE;
+ }
+ else if (pdef->flags & DoBlue)
+ {
+ pmap->blue[pix].co.local.blue = pdef->blue;
+ }
+ else
+ {
+ pdef->blue = pmap->blue[pix].co.local.blue;
+ }
+ /* If this is an o.k. entry, then it gets added to the list
+ * to be sent to the hardware. If not, skip it. Once we've
+ * skipped one, we have to copy all the others.
+ */
+ if(ok)
+ {
+ if(idef != n)
+ defs[idef] = defs[n];
+ idef++;
+ } else
+ client->errorValue = pdef->pixel;
+ }
+ }
+ else
+ {
+ for (pdef = defs, n = 0; n < count; pdef++, n++)
+ {
+
+ ok = TRUE;
+ if (pdef->pixel >= pVisual->ColormapEntries)
+ {
+ client->errorValue = pdef->pixel;
+ errVal = BadValue;
+ ok = FALSE;
+ }
+ else if (pmap->red[pdef->pixel].refcnt != AllocPrivate)
+ {
+ errVal = BadAccess;
+ ok = FALSE;
+ }
+
+ /* If this is an o.k. entry, then it gets added to the list
+ * to be sent to the hardware. If not, skip it. Once we've
+ * skipped one, we have to copy all the others.
+ */
+ if(ok)
+ {
+ if(idef != n)
+ defs[idef] = defs[n];
+ idef++;
+ }
+ else
+ continue;
+
+ (*pmap->pScreen->ResolveColor)
+ (&pdef->red, &pdef->green, &pdef->blue, pmap->pVisual);
+
+ pent = &pmap->red[pdef->pixel];
+
+ if(pdef->flags & DoRed)
+ {
+ if(pent->fShared)
+ {
+ pent->co.shco.red->color = pdef->red;
+ if (pent->co.shco.red->refcnt > 1)
+ ok = FALSE;
+ }
+ else
+ pent->co.local.red = pdef->red;
+ }
+ else
+ {
+ if(pent->fShared)
+ pdef->red = pent->co.shco.red->color;
+ else
+ pdef->red = pent->co.local.red;
+ }
+ if(pdef->flags & DoGreen)
+ {
+ if(pent->fShared)
+ {
+ pent->co.shco.green->color = pdef->green;
+ if (pent->co.shco.green->refcnt > 1)
+ ok = FALSE;
+ }
+ else
+ pent->co.local.green = pdef->green;
+ }
+ else
+ {
+ if(pent->fShared)
+ pdef->green = pent->co.shco.green->color;
+ else
+ pdef->green = pent->co.local.green;
+ }
+ if(pdef->flags & DoBlue)
+ {
+ if(pent->fShared)
+ {
+ pent->co.shco.blue->color = pdef->blue;
+ if (pent->co.shco.blue->refcnt > 1)
+ ok = FALSE;
+ }
+ else
+ pent->co.local.blue = pdef->blue;
+ }
+ else
+ {
+ if(pent->fShared)
+ pdef->blue = pent->co.shco.blue->color;
+ else
+ pdef->blue = pent->co.local.blue;
+ }
+
+ if(!ok)
+ {
+ /* have to run through the colormap and change anybody who
+ * shares this value */
+ pred = pent->co.shco.red;
+ pgreen = pent->co.shco.green;
+ pblue = pent->co.shco.blue;
+ ChgRed = pdef->flags & DoRed;
+ ChgGreen = pdef->flags & DoGreen;
+ ChgBlue = pdef->flags & DoBlue;
+ pentLast = pmap->red + pVisual->ColormapEntries;
+
+ for(pentT = pmap->red; pentT < pentLast; pentT++)
+ {
+ if(pentT->fShared && (pentT != pent))
+ {
+ xColorItem defChg;
+
+ /* There are, alas, devices in this world too dumb
+ * to read their own hardware colormaps. Sick, but
+ * true. So we're going to be really nice and load
+ * the xColorItem with the proper value for all the
+ * fields. We will only set the flags for those
+ * fields that actually change. Smart devices can
+ * arrange to change only those fields. Dumb devices
+ * can rest assured that we have provided for them,
+ * and can change all three fields */
+
+ defChg.flags = 0;
+ if(ChgRed && pentT->co.shco.red == pred)
+ {
+ defChg.flags |= DoRed;
+ }
+ if(ChgGreen && pentT->co.shco.green == pgreen)
+ {
+ defChg.flags |= DoGreen;
+ }
+ if(ChgBlue && pentT->co.shco.blue == pblue)
+ {
+ defChg.flags |= DoBlue;
+ }
+ if(defChg.flags != 0)
+ {
+ defChg.pixel = pentT - pmap->red;
+ defChg.red = pentT->co.shco.red->color;
+ defChg.green = pentT->co.shco.green->color;
+ defChg.blue = pentT->co.shco.blue->color;
+ (*pmap->pScreen->StoreColors) (pmap, 1, &defChg);
+ }
+ }
+ }
+
+ }
+ }
+ }
+ /* Note that we use idef, the count of acceptable entries, and not
+ * count, the count of proposed entries */
+ if (idef != 0)
+ ( *pmap->pScreen->StoreColors) (pmap, idef, defs);
+ return errVal;
+}
+
+int
+IsMapInstalled(Colormap map, WindowPtr pWin)
+{
+ Colormap *pmaps;
+ int imap, nummaps, found;
+
+ pmaps = malloc(pWin->drawable.pScreen->maxInstalledCmaps*sizeof(Colormap));
+ if(!pmaps)
+ return FALSE;
+ nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
+ (pWin->drawable.pScreen, pmaps);
+ found = FALSE;
+ for(imap = 0; imap < nummaps; imap++)
+ {
+ if(pmaps[imap] == map)
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ free(pmaps);
+ return found;
+}
+
+struct colormap_lookup_data {
+ ScreenPtr pScreen;
+ VisualPtr visuals;
+};
+
+static void _colormap_find_resource(pointer value, XID id,
+ pointer cdata)
+{
+ struct colormap_lookup_data *cmap_data = cdata;
+ VisualPtr visuals = cmap_data->visuals;
+ ScreenPtr pScreen = cmap_data->pScreen;
+ ColormapPtr cmap = value;
+ int j;
+
+ if (pScreen != cmap->pScreen)
+ return;
+
+ j = cmap->pVisual - pScreen->visuals;
+ cmap->pVisual = &visuals[j];
+}
+
+/* something has realloced the visuals, instead of breaking
+ ABI fix it up here - glx and compsite did this wrong */
+Bool
+ResizeVisualArray(ScreenPtr pScreen, int new_visual_count,
+ DepthPtr depth)
+{
+ struct colormap_lookup_data cdata;
+ int numVisuals;
+ VisualPtr visuals;
+ XID *vids, vid;
+ int first_new_vid, first_new_visual, i;
+
+ first_new_vid = depth->numVids;
+ first_new_visual = pScreen->numVisuals;
+
+ vids = realloc(depth->vids, (depth->numVids + new_visual_count) * sizeof(XID));
+ if (!vids)
+ return FALSE;
+
+ /* its realloced now no going back if we fail the next one */
+ depth->vids = vids;
+
+ numVisuals = pScreen->numVisuals + new_visual_count;
+ visuals = realloc(pScreen->visuals, numVisuals * sizeof(VisualRec));
+ if (!visuals) {
+ return FALSE;
+ }
+
+ cdata.visuals = visuals;
+ cdata.pScreen = pScreen;
+ FindClientResourcesByType(serverClient, RT_COLORMAP, _colormap_find_resource, &cdata);
+
+ pScreen->visuals = visuals;
+
+ for (i = 0; i < new_visual_count; i++) {
+ vid = FakeClientID(0);
+ pScreen->visuals[first_new_visual + i].vid = vid;
+ vids[first_new_vid + i] = vid;
+ }
+
+ depth->numVids += new_visual_count;
+ pScreen->numVisuals += new_visual_count;
+
+ return TRUE;
+}
diff --git a/xorg-server/dix/cursor.c b/xorg-server/dix/cursor.c index c8253bba0..acd118a1c 100644 --- a/xorg-server/dix/cursor.c +++ b/xorg-server/dix/cursor.c @@ -72,6 +72,8 @@ typedef struct _GlyphShare { static GlyphSharePtr sharedGlyphs = (GlyphSharePtr)NULL;
+DevPrivateKeyRec cursorScreenDevPriv[MAXSCREENS];
+
#ifdef XFIXES
static CARD32 cursorSerial;
#endif
@@ -86,8 +88,7 @@ FreeCursorBits(CursorBitsPtr bits) #ifdef ARGB_CURSOR
free(bits->argb);
#endif
- dixFreePrivates(bits->devPrivates);
- bits->devPrivates = NULL;
+ dixFiniPrivates(bits, PRIVATE_CURSOR_BITS);
if (bits->refcnt == 0)
{
GlyphSharePtr *prev, this;
@@ -121,17 +122,17 @@ FreeCursor(pointer value, XID cid) DeviceIntPtr pDev = NULL; /* unused anyway */
if ( --pCurs->refcnt != 0)
- return(Success);
+ return Success;
for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
{
pscr = screenInfo.screens[nscr];
(void)( *pscr->UnrealizeCursor)(pDev, pscr, pCurs);
}
- dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(pCurs->bits);
+ dixFiniPrivates(pCurs, PRIVATE_CURSOR);
free( pCurs);
- return(Success);
+ return Success;
}
@@ -217,6 +218,7 @@ RealizeCursorAllScreens(CursorPtr pCurs) return Success;
}
+
/**
* does nothing about the resource table, just creates the data structure.
* does not copy the src and mask bits
@@ -237,14 +239,16 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits, int rc;
*ppCurs = NULL;
- pCurs = (CursorPtr)calloc(sizeof(CursorRec) + sizeof(CursorBits), 1);
+ pCurs = (CursorPtr)calloc(CURSOR_REC_SIZE + CURSOR_BITS_SIZE, 1);
if (!pCurs)
{
free(psrcbits);
free(pmaskbits);
return BadAlloc;
}
- bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec));
+ bits = (CursorBitsPtr)((char *)pCurs + CURSOR_REC_SIZE);
+ dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR);
+ dixInitPrivates(bits, bits + 1, PRIVATE_CURSOR_BITS)
bits->source = psrcbits;
bits->mask = pmaskbits;
#ifdef ARGB_CURSOR
@@ -255,7 +259,6 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits, bits->xhot = cm->xhot;
bits->yhot = cm->yhot;
pCurs->refcnt = 1;
- bits->devPrivates = NULL;
bits->refcnt = -1;
CheckForEmptyMask(bits);
pCurs->bits = bits;
@@ -273,7 +276,6 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits, pCurs->backBlue = backBlue;
pCurs->id = cid;
- pCurs->devPrivates = NULL;
/* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
@@ -289,8 +291,8 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits, return Success;
error:
- dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(bits);
+ dixFiniPrivates(pCurs, PRIVATE_CURSOR);
free(pCurs);
return rc;
@@ -339,9 +341,10 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, }
if (pShare)
{
- pCurs = (CursorPtr)calloc(sizeof(CursorRec), 1);
+ pCurs = (CursorPtr)calloc(CURSOR_REC_SIZE, 1);
if (!pCurs)
return BadAlloc;
+ dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR);
bits = pShare->bits;
bits->refcnt++;
}
@@ -382,17 +385,17 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, if (sourcefont != maskfont)
{
pCurs =
- (CursorPtr)calloc(sizeof(CursorRec) + sizeof(CursorBits), 1);
+ (CursorPtr)calloc(CURSOR_REC_SIZE + CURSOR_BITS_SIZE, 1);
if (pCurs)
- bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec));
+ bits = (CursorBitsPtr)((char *)pCurs + CURSOR_REC_SIZE);
else
bits = (CursorBitsPtr)NULL;
}
else
{
- pCurs = (CursorPtr)calloc(sizeof(CursorRec), 1);
+ pCurs = (CursorPtr)calloc(CURSOR_REC_SIZE, 1);
if (pCurs)
- bits = (CursorBitsPtr)calloc(sizeof(CursorBits), 1);
+ bits = (CursorBitsPtr)calloc(CURSOR_BITS_SIZE, 1);
else
bits = (CursorBitsPtr)NULL;
}
@@ -403,6 +406,8 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, free(srcbits);
return BadAlloc;
}
+ dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR);
+ dixInitPrivates(bits, bits + 1, PRIVATE_CURSOR_BITS);
bits->source = srcbits;
bits->mask = mskbits;
#ifdef ARGB_CURSOR
@@ -412,7 +417,6 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, bits->height = cm.height;
bits->xhot = cm.xhot;
bits->yhot = cm.yhot;
- bits->devPrivates = NULL;
if (sourcefont != maskfont)
bits->refcnt = -1;
else
@@ -451,7 +455,6 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, pCurs->backBlue = backBlue;
pCurs->id = cid;
- pCurs->devPrivates = NULL;
/* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
@@ -467,8 +470,8 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, return Success;
error:
- dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(bits);
+ dixFiniPrivates(pCurs, PRIVATE_CURSOR);
free(pCurs);
return rc;
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c index 58eee47ca..ff5af9379 100644 --- a/xorg-server/dix/devices.c +++ b/xorg-server/dix/devices.c @@ -77,6 +77,8 @@ SOFTWARE. #include <X11/extensions/XI.h>
#include <X11/extensions/XI2.h>
#include <X11/extensions/XIproto.h>
+#include <math.h>
+#include <pixman.h>
#include "exglobals.h"
#include "exevents.h"
#include "xiquerydevice.h" /* for SizeDeviceClasses */
@@ -85,12 +87,58 @@ SOFTWARE. #include "xserver-properties.h"
#include "xichangehierarchy.h" /* For XISendDeviceHierarchyEvent */
+#ifdef _MSC_VER
+#define isfinite(val) _finite(val)
+#endif
+
/** @file
* This file handles input device-related stuff.
*/
static void RecalculateMasterButtons(DeviceIntPtr slave);
+static void
+DeviceSetTransform(DeviceIntPtr dev, float *transform)
+{
+ struct pixman_f_transform scale;
+ double sx, sy;
+ int x, y;
+
+ /**
+ * calculate combined transformation matrix:
+ *
+ * M = InvScale * Transform * Scale
+ *
+ * So we can later transform points using M * p
+ *
+ * Where:
+ * Scale scales coordinates into 0..1 range
+ * Transform is the user supplied (affine) transform
+ * InvScale scales coordinates back up into their native range
+ */
+ sx = dev->valuator->axes[0].max_value - dev->valuator->axes[0].min_value;
+ sy = dev->valuator->axes[1].max_value - dev->valuator->axes[1].min_value;
+
+ /* invscale */
+ pixman_f_transform_init_scale(&scale, sx, sy);
+ scale.m[0][2] = dev->valuator->axes[0].min_value;
+ scale.m[1][2] = dev->valuator->axes[1].min_value;
+
+ /* transform */
+ for (y=0; y<3; y++)
+ for (x=0; x<3; x++)
+ dev->transform.m[y][x] = *transform++;
+
+ pixman_f_transform_multiply(&dev->transform, &scale, &dev->transform);
+
+ /* scale */
+ pixman_f_transform_init_scale(&scale, 1.0 / sx, 1.0 / sy);
+ scale.m[0][2] = -dev->valuator->axes[0].min_value / sx;
+ scale.m[1][2] = -dev->valuator->axes[1].min_value / sy;
+
+ pixman_f_transform_multiply(&dev->transform, &dev->transform, &scale);
+}
+
/**
* DIX property handler.
*/
@@ -115,6 +163,21 @@ DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, else if (!(*((CARD8*)prop->data)) && dev->enabled)
DisableDevice(dev, TRUE);
}
+ } else if (property == XIGetKnownProperty(XI_PROP_TRANSFORM))
+ {
+ float *f = (float*)prop->data;
+ int i;
+
+ if (prop->format != 32 || prop->size != 9 ||
+ prop->type != XIGetKnownProperty(XATOM_FLOAT))
+ return BadValue;
+
+ for (i=0; i<9; i++)
+ if (!isfinite(f[i]))
+ return BadValue;
+
+ if (!checkonly)
+ DeviceSetTransform(dev, f);
}
return Success;
@@ -183,6 +246,7 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart) int devid;
char devind[MAXDEVICES];
BOOL enabled;
+ float transform[9];
/* Find next available id, 0 and 1 are reserved */
memset(devind, 0, sizeof(char)*MAXDEVICES);
@@ -195,7 +259,9 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart) if (devid >= MAXDEVICES)
return (DeviceIntPtr)NULL;
- dev = calloc(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), 1);
+ dev = _dixAllocateObjectWithPrivates(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec),
+ sizeof(DeviceIntRec) + sizeof(SpriteInfoRec),
+ offsetof(DeviceIntRec, devPrivates), PRIVATE_DEVICE);
if (!dev)
return (DeviceIntPtr)NULL;
dev->id = devid;
@@ -234,6 +300,17 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart) XA_INTEGER, 8, PropModeReplace, 1, &enabled,
FALSE);
XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_ENABLED), FALSE);
+
+ /* unity matrix */
+ memset(transform, 0, sizeof(transform));
+ transform[0] = transform[4] = transform[8] = 1.0f;
+
+ XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_TRANSFORM),
+ XIGetKnownProperty(XATOM_FLOAT), 32,
+ PropModeReplace, 9, transform, FALSE);
+ XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_TRANSFORM),
+ FALSE);
+
XIRegisterPropertyHandler(dev, DeviceSetProperty, NULL, NULL);
return dev;
@@ -289,9 +366,9 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent) /* Sprites appear on first root window, so we can hardcode it */
if (dev->spriteInfo->spriteOwner)
{
- InitializeSprite(dev, WindowTable[0]);
+ InitializeSprite(dev, screenInfo.screens[0]->root);
/* mode doesn't matter */
- EnterWindow(dev, WindowTable[0], NotifyAncestor);
+ EnterWindow(dev, screenInfo.screens[0]->root, NotifyAncestor);
}
else if ((other = NextFreePointerDevice()) == NULL)
{
@@ -667,8 +744,7 @@ FreeDeviceClass(int type, pointer *class) case ButtonClass:
{
ButtonClassPtr *b = (ButtonClassPtr*)class;
- if ((*b)->xkb_acts)
- free((*b)->xkb_acts);
+ free((*b)->xkb_acts);
free((*b));
break;
}
@@ -676,8 +752,7 @@ FreeDeviceClass(int type, pointer *class) {
ValuatorClassPtr *v = (ValuatorClassPtr*)class;
- if ((*v)->motion)
- free((*v)->motion);
+ free((*v)->motion);
free((*v));
break;
}
@@ -865,8 +940,7 @@ CloseDevice(DeviceIntPtr dev) }
free(dev->deviceGrab.sync.event);
- dixFreePrivates(dev->devPrivates);
- free(dev);
+ dixFreeObjectWithPrivates(dev, PRIVATE_DEVICE);
}
/**
@@ -1397,10 +1471,8 @@ InitStringFeedbackClassDeviceStruct ( feedc->ctrl.symbols_displayed = malloc(sizeof (KeySym) * max_symbols);
if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed)
{
- if (feedc->ctrl.symbols_supported)
- free(feedc->ctrl.symbols_supported);
- if (feedc->ctrl.symbols_displayed)
- free(feedc->ctrl.symbols_displayed);
+ free(feedc->ctrl.symbols_supported);
+ free(feedc->ctrl.symbols_displayed);
free(feedc);
return FALSE;
}
@@ -1954,7 +2026,7 @@ ProcChangeKeyboardControl (ClientPtr client) keyboard = PickKeyboard(client);
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
- if ((pDev == keyboard || (!IsMaster(keyboard) && pDev->u.master == keyboard)) &&
+ if ((pDev == keyboard || (!IsMaster(pDev) && pDev->u.master == keyboard)) &&
pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess);
if (ret != Success)
@@ -1963,7 +2035,7 @@ ProcChangeKeyboardControl (ClientPtr client) }
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
- if ((pDev == keyboard || (!IsMaster(keyboard) && pDev->u.master == keyboard)) &&
+ if ((pDev == keyboard || (!IsMaster(pDev) && pDev->u.master == keyboard)) &&
pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
ret = DoChangeKeyboardControl(client, pDev, vlist, vmask);
if (ret != Success)
@@ -2053,11 +2125,11 @@ ProcChangePointerControl(ClientPtr client) ctrl = mouse->ptrfeed->ctrl;
if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) {
client->errorValue = stuff->doAccel;
- return(BadValue);
+ return BadValue;
}
if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) {
client->errorValue = stuff->doThresh;
- return(BadValue);
+ return BadValue;
}
if (stuff->doAccel) {
if (stuff->accelNum == -1) {
@@ -2215,8 +2287,7 @@ ProcGetMotionEvents(ClientPtr client) WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord),
(char *)coords);
}
- if (coords)
- free(coords);
+ free(coords);
return Success;
}
@@ -2368,7 +2439,7 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) if (dev->spriteInfo->sprite)
currentRoot = dev->spriteInfo->sprite->spriteTrace[0];
else /* new device auto-set to floating */
- currentRoot = WindowTable[0];
+ currentRoot = screenInfo.screens[0]->root;
/* we need to init a fake sprite */
screen = currentRoot->drawable.pScreen;
diff --git a/xorg-server/dix/dispatch.c b/xorg-server/dix/dispatch.c index fd4f9c330..38666a422 100644 --- a/xorg-server/dix/dispatch.c +++ b/xorg-server/dix/dispatch.c @@ -590,7 +590,7 @@ CreateConnectionBlock(void) VisualPtr pVisual;
pScreen = screenInfo.screens[i];
- root.windowId = WindowTable[i]->drawable.id;
+ root.windowId = pScreen->root->drawable.id;
root.defaultColormap = pScreen->defColormap;
root.whitePixel = pScreen->whitePixel;
root.blackPixel = pScreen->blackPixel;
@@ -659,7 +659,7 @@ CreateConnectionBlock(void) int
ProcBadRequest(ClientPtr client)
{
- return (BadRequest);
+ return BadRequest;
}
int
@@ -940,7 +940,7 @@ GetGeometry(ClientPtr client, xGetGeometryReply *rep) rep->type = X_Reply;
rep->length = 0;
rep->sequenceNumber = client->sequence;
- rep->root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
+ rep->root = pDraw->pScreen->root->drawable.id;
rep->depth = pDraw->depth;
rep->width = pDraw->width;
rep->height = pDraw->height;
@@ -1007,7 +1007,7 @@ ProcQueryTree(ClientPtr client) return rc;
memset(&reply, 0, sizeof(xQueryTreeReply));
reply.type = X_Reply;
- reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
+ reply.root = pWin->drawable.pScreen->root->drawable.id;
reply.sequenceNumber = client->sequence;
if (pWin->parent)
reply.parent = pWin->parent->drawable.id;
@@ -1058,7 +1058,7 @@ ProcInternAtom(ClientPtr client) if ((stuff->onlyIfExists != xTrue) && (stuff->onlyIfExists != xFalse))
{
client->errorValue = stuff->onlyIfExists;
- return(BadValue);
+ return BadValue;
}
tchar = (char *) &stuff[1];
atom = MakeAtom(tchar, stuff->nbytes, !stuff->onlyIfExists);
@@ -1074,7 +1074,7 @@ ProcInternAtom(ClientPtr client) return Success;
}
else
- return (BadAlloc);
+ return BadAlloc;
}
int
@@ -1101,7 +1101,7 @@ ProcGetAtomName(ClientPtr client) else
{
client->errorValue = stuff->id;
- return (BadAtom);
+ return BadAtom;
}
}
@@ -1220,14 +1220,12 @@ ProcTranslateCoords(ClientPtr client) * borderSize
*/
&& (!wBoundingShape(pWin) ||
- POINT_IN_REGION(pWin->drawable.pScreen,
- &pWin->borderSize, x, y, &box))
+ RegionContainsPoint(&pWin->borderSize, x, y, &box))
&& (!wInputShape(pWin) ||
- POINT_IN_REGION(pWin->drawable.pScreen,
- wInputShape(pWin),
- x - pWin->drawable.x,
- y - pWin->drawable.y, &box))
+ RegionContainsPoint(wInputShape(pWin),
+ x - pWin->drawable.x,
+ y - pWin->drawable.y, &box))
)
{
rep.child = pWin->drawable.id;
@@ -1318,7 +1316,7 @@ ProcQueryFont(ClientPtr client) reply = calloc(1, rlength);
if(!reply)
{
- return(BadAlloc);
+ return BadAlloc;
}
reply->type = X_Reply;
@@ -1352,11 +1350,11 @@ ProcQueryTextExtents(ClientPtr client) if (stuff->oddLength)
{
if (length == 0)
- return(BadLength);
+ return BadLength;
length--;
}
if (!QueryTextExtents(pFont, length, (unsigned char *)&stuff[1], &info))
- return(BadAlloc);
+ return BadAlloc;
reply.type = X_Reply;
reply.length = 0;
reply.sequenceNumber = client->sequence;
@@ -1473,7 +1471,7 @@ CreatePmap: return Success;
(*pDraw->pScreen->DestroyPixmap)(pMap);
}
- return (BadAlloc);
+ return BadAlloc;
}
int
@@ -1523,7 +1521,7 @@ ProcCreateGC(ClientPtr client) if (error != Success)
return error;
if (!AddResource(stuff->gc, RT_GC, (pointer)pGC))
- return (BadAlloc);
+ return BadAlloc;
return Success;
}
@@ -1563,7 +1561,7 @@ ProcCopyGC(ClientPtr client) if (result != Success)
return result;
if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth))
- return (BadMatch);
+ return BadMatch;
if (stuff->mask & ~GCAllBits)
{
client->errorValue = stuff->mask;
@@ -1617,7 +1615,7 @@ ProcSetClipRectangles(ClientPtr client) nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq);
if (nr & 4)
- return(BadLength);
+ return BadLength;
nr >>= 3;
return SetClipRects(pGC, stuff->xOrigin, stuff->yOrigin,
nr, (xRectangle *)&stuff[1], (int)stuff->ordering);
@@ -1653,12 +1651,12 @@ ProcClearToBackground(ClientPtr client) if (pWin->drawable.class == InputOnly)
{
client->errorValue = stuff->window;
- return (BadMatch);
+ return BadMatch;
}
if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse))
{
client->errorValue = stuff->exposures;
- return(BadValue);
+ return BadValue;
}
(*pWin->drawable.pScreen->ClearToBackground)(pWin, stuff->x, stuff->y,
stuff->width, stuff->height,
@@ -1688,7 +1686,7 @@ ProcCopyArea(ClientPtr client) if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth))
{
client->errorValue = stuff->dstDrawable;
- return (BadMatch);
+ return BadMatch;
}
}
else
@@ -1702,7 +1700,7 @@ ProcCopyArea(ClientPtr client) (*pDst->pScreen->SendGraphicsExpose)
(client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
if (pRgn)
- REGION_DESTROY(pDst->pScreen, pRgn);
+ RegionDestroy(pRgn);
}
return Success;
@@ -1730,7 +1728,7 @@ ProcCopyPlane(ClientPtr client) if (pdstDraw->pScreen != psrcDraw->pScreen)
{
client->errorValue = stuff->dstDrawable;
- return (BadMatch);
+ return BadMatch;
}
}
else
@@ -1741,7 +1739,7 @@ ProcCopyPlane(ClientPtr client) (stuff->bitPlane > (1L << (psrcDraw->depth - 1))))
{
client->errorValue = stuff->bitPlane;
- return(BadValue);
+ return BadValue;
}
pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, stuff->srcX, stuff->srcY,
@@ -1752,7 +1750,7 @@ ProcCopyPlane(ClientPtr client) (*pdstDraw->pScreen->SendGraphicsExpose)
(client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
if (pRgn)
- REGION_DESTROY(pdstDraw->pScreen, pRgn);
+ RegionDestroy(pRgn);
}
return Success;
}
@@ -1815,7 +1813,7 @@ ProcPolySegment(ClientPtr client) VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq);
if (nsegs & 4)
- return(BadLength);
+ return BadLength;
nsegs >>= 3;
if (nsegs)
(*pGC->ops->PolySegment)(pDraw, pGC, nsegs, (xSegment *) &stuff[1]);
@@ -1834,7 +1832,7 @@ ProcPolyRectangle (ClientPtr client) VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq);
if (nrects & 4)
- return(BadLength);
+ return BadLength;
nrects >>= 3;
if (nrects)
(*pGC->ops->PolyRectangle)(pDraw, pGC,
@@ -1854,7 +1852,7 @@ ProcPolyArc(ClientPtr client) VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
narcs = (client->req_len << 2) - sizeof(xPolyArcReq);
if (narcs % sizeof(xArc))
- return(BadLength);
+ return BadLength;
narcs /= sizeof(xArc);
if (narcs)
(*pGC->ops->PolyArc)(pDraw, pGC, narcs, (xArc *) &stuff[1]);
@@ -1904,7 +1902,7 @@ ProcPolyFillRectangle(ClientPtr client) VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq);
if (things & 4)
- return(BadLength);
+ return BadLength;
things >>= 3;
if (things)
@@ -1925,7 +1923,7 @@ ProcPolyFillArc(ClientPtr client) VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq);
if (narcs % sizeof(xArc))
- return(BadLength);
+ return BadLength;
narcs /= sizeof(xArc);
if (narcs)
(*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]);
@@ -2062,7 +2060,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable, if ((format != XYPixmap) && (format != ZPixmap))
{
client->errorValue = format;
- return(BadValue);
+ return BadValue;
}
rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixReadAccess);
if (rc != Success)
@@ -2096,7 +2094,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable, }
else
{
- pBoundingDraw = (DrawablePtr)WindowTable[pDraw->pScreen->myNum];
+ pBoundingDraw = (DrawablePtr)pDraw->pScreen->root;
}
xgi.visual = wVisual (pWin);
@@ -2146,7 +2144,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable, if (im_return) {
pBuf = calloc(1, sz_xGetImageReply + length);
if (!pBuf)
- return (BadAlloc);
+ return BadAlloc;
if (widthBytesLine == 0)
linesPerBuf = 0;
else
@@ -2183,7 +2181,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable, }
}
if(!(pBuf = calloc(1, length)))
- return (BadAlloc);
+ return BadAlloc;
WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
}
@@ -2192,8 +2190,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable, pVisibleRegion = NotClippedByChildren((WindowPtr)pDraw);
if (pVisibleRegion)
{
- REGION_TRANSLATE(pDraw->pScreen, pVisibleRegion,
- -pDraw->x, -pDraw->y);
+ RegionTranslate(pVisibleRegion, -pDraw->x, -pDraw->y);
}
}
@@ -2281,7 +2278,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable, }
}
if (pVisibleRegion)
- REGION_DESTROY(pDraw->pScreen, pVisibleRegion);
+ RegionDestroy(pVisibleRegion);
if (!im_return)
free(pBuf);
return Success;
@@ -2406,7 +2403,7 @@ ProcCreateColormap(ClientPtr client) if ((stuff->alloc != AllocNone) && (stuff->alloc != AllocAll))
{
client->errorValue = stuff->alloc;
- return(BadValue);
+ return BadValue;
}
mid = stuff->mid;
LEGAL_NEW_RESOURCE(mid, client);
@@ -2425,7 +2422,7 @@ ProcCreateColormap(ClientPtr client) (int)stuff->alloc, client->index);
}
client->errorValue = stuff->visual;
- return(BadMatch);
+ return BadMatch;
}
int
@@ -2551,7 +2548,7 @@ ProcListInstalledColormaps(ClientPtr client) pWin->drawable.pScreen->maxInstalledCmaps *
sizeof(Colormap));
if(!preply)
- return(BadAlloc);
+ return BadAlloc;
preply->type = X_Reply;
preply->sequenceNumber = client->sequence;
@@ -2639,7 +2636,7 @@ ProcAllocNamedColor (ClientPtr client) return Success;
}
else
- return(BadName);
+ return BadName;
}
else
@@ -2670,18 +2667,18 @@ ProcAllocColorCells (ClientPtr client) if (!npixels)
{
client->errorValue = npixels;
- return (BadValue);
+ return BadValue;
}
if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
{
client->errorValue = stuff->contiguous;
- return (BadValue);
+ return BadValue;
}
nmasks = stuff->planes;
length = ((long)npixels + (long)nmasks) * sizeof(Pixel);
ppixels = malloc(length);
if(!ppixels)
- return(BadAlloc);
+ return BadAlloc;
pmasks = ppixels + npixels;
if( (rc = AllocColorCells(client->index, pcmp, npixels, nmasks,
@@ -2734,12 +2731,12 @@ ProcAllocColorPlanes(ClientPtr client) if (!npixels)
{
client->errorValue = npixels;
- return (BadValue);
+ return BadValue;
}
if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
{
client->errorValue = stuff->contiguous;
- return (BadValue);
+ return BadValue;
}
acpr.type = X_Reply;
acpr.sequenceNumber = client->sequence;
@@ -2747,7 +2744,7 @@ ProcAllocColorPlanes(ClientPtr client) length = (long)npixels * sizeof(Pixel);
ppixels = malloc(length);
if(!ppixels)
- return(BadAlloc);
+ return BadAlloc;
if( (rc = AllocColorPlanes(client->index, pcmp, npixels,
(int)stuff->red, (int)stuff->green, (int)stuff->blue,
(Bool)stuff->contiguous, ppixels,
@@ -2790,7 +2787,7 @@ ProcFreeColors(ClientPtr client) int count;
if(pcmp->flags & AllAllocated)
- return(BadAccess);
+ return BadAccess;
count = bytes_to_int32((client->req_len << 2) - sizeof(xFreeColorsReq));
return FreeColors(pcmp, client->index, count,
(Pixel *)&stuff[1], (Pixel)stuff->planeMask);
@@ -2818,7 +2815,7 @@ ProcStoreColors (ClientPtr client) count = (client->req_len << 2) - sizeof(xStoreColorsReq);
if (count % sizeof(xColorItem))
- return(BadLength);
+ return BadLength;
count /= sizeof(xColorItem);
return StoreColors(pcmp, count, (xColorItem *)&stuff[1], client);
}
@@ -2850,7 +2847,7 @@ ProcStoreNamedColor (ClientPtr client) def.pixel = stuff->pixel;
return StoreColors(pcmp, 1, &def, client);
}
- return (BadName);
+ return BadName;
}
else
{
@@ -2878,10 +2875,10 @@ ProcQueryColors(ClientPtr client) count = bytes_to_int32((client->req_len << 2) - sizeof(xQueryColorsReq));
prgbs = calloc(1, count * sizeof(xrgb));
if(!prgbs && count)
- return(BadAlloc);
+ return BadAlloc;
if( (rc = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs, client)) )
{
- if (prgbs) free(prgbs);
+ free(prgbs);
return rc;
}
memset(&qcr, 0, sizeof(xQueryColorsReply));
@@ -2895,7 +2892,7 @@ ProcQueryColors(ClientPtr client) client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend;
WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs);
}
- if (prgbs) free(prgbs);
+ free(prgbs);
return Success;
}
@@ -2936,7 +2933,7 @@ ProcLookupColor(ClientPtr client) WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr);
return Success;
}
- return (BadName);
+ return BadName;
}
else
{
@@ -2984,24 +2981,24 @@ ProcCreateCursor (ClientPtr client) || src->drawable.height != msk->drawable.height
|| src->drawable.depth != 1
|| msk->drawable.depth != 1)
- return (BadMatch);
+ return BadMatch;
width = src->drawable.width;
height = src->drawable.height;
if ( stuff->x > width
|| stuff->y > height )
- return (BadMatch);
+ return BadMatch;
n = BitmapBytePad(width)*height;
srcbits = calloc(1, n);
if (!srcbits)
- return (BadAlloc);
+ return BadAlloc;
mskbits = malloc(n);
if (!mskbits)
{
free(srcbits);
- return (BadAlloc);
+ return BadAlloc;
}
(* src->drawable.pScreen->GetImage)( (DrawablePtr)src, 0, 0, width, height,
@@ -3015,7 +3012,7 @@ ProcCreateCursor (ClientPtr client) else
{
/* zeroing the (pad) bits helps some ddx cursor handling */
- bzero((char *)mskbits, n);
+ memset((char *)mskbits, 0, n);
(* msk->drawable.pScreen->GetImage)( (DrawablePtr)msk, 0, 0, width,
height, XYPixmap, 1, (pointer)mskbits);
}
@@ -3097,7 +3094,7 @@ ProcQueryBestSize (ClientPtr client) (stuff->class != StippleShape))
{
client->errorValue = stuff->class;
- return(BadValue);
+ return BadValue;
}
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY,
@@ -3105,7 +3102,7 @@ ProcQueryBestSize (ClientPtr client) if (rc != Success)
return rc;
if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW)
- return (BadMatch);
+ return BadMatch;
pScreen = pDraw->pScreen;
rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess);
if (rc != Success)
@@ -3245,7 +3242,7 @@ ProcListHosts(ClientPtr client) result = GetHosts(&pdata, &nHosts, &len, &reply.enabled);
if (result != Success)
- return(result);
+ return result;
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
reply.nHosts = nHosts;
@@ -3320,7 +3317,7 @@ ProcKillClient(ClientPtr client) * doesn't try to touch client
*/
isItTimeToYield = TRUE;
- return (Success);
+ return Success;
}
return Success;
}
@@ -3346,12 +3343,12 @@ ProcSetFontPath(ClientPtr client) while (--nfonts >= 0)
{
if ((total == 0) || (total < (n = (*ptr + 1))))
- return(BadLength);
+ return BadLength;
total -= n;
ptr += n;
}
if (total >= 4)
- return(BadLength);
+ return BadLength;
return SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1]);
}
@@ -3400,7 +3397,7 @@ ProcChangeCloseDownMode(ClientPtr client) else
{
client->errorValue = stuff->mode;
- return (BadValue);
+ return BadValue;
}
}
@@ -3539,8 +3536,7 @@ CloseDownClient(ClientPtr client) nextFreeClientID = client->index;
clients[client->index] = NullClient;
SmartLastClient = NullClient;
- dixFreePrivates(client->devPrivates);
- free(client);
+ dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
while (!clients[currentMaxClients-1])
currentMaxClients--;
@@ -3561,7 +3557,6 @@ KillAllClients(void) void InitClient(ClientPtr client, int i, pointer ospriv)
{
- memset(client, 0, sizeof(*client));
client->index = i;
client->clientAsMask = ((Mask)i) << CLIENTOFFSET;
client->closeDownMode = i ? DestroyAll : RetainPermanent;
@@ -3589,13 +3584,13 @@ ClientPtr NextAvailableClient(pointer ospriv) i = nextFreeClientID;
if (i == MAXCLIENTS)
return (ClientPtr)NULL;
- clients[i] = client = malloc(sizeof(ClientRec));
+ clients[i] = client = dixAllocateObjectWithPrivates(ClientRec, PRIVATE_CLIENT);
if (!client)
return (ClientPtr)NULL;
InitClient(client, i, ospriv);
if (!InitClientResources(client))
{
- free(client);
+ dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
return (ClientPtr)NULL;
}
data.reqType = 1;
@@ -3603,7 +3598,7 @@ ClientPtr NextAvailableClient(pointer ospriv) if (!InsertFakeRequest(client, (char *)&data, sz_xReq))
{
FreeClientResources(client);
- free(client);
+ dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
return (ClientPtr)NULL;
}
if (i == currentMaxClients)
@@ -3619,7 +3614,7 @@ ClientPtr NextAvailableClient(pointer ospriv) clientinfo.setup = (xConnSetup *) NULL;
CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
}
- return(client);
+ return client;
}
int
@@ -3631,7 +3626,7 @@ ProcInitialConnection(ClientPtr client) prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
if ((prefix->byteOrder != 'l') && (prefix->byteOrder != 'B'))
- return (client->noClientException = -1);
+ return client->noClientException = -1;
if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) ||
(!(*(char *) &whichbyte) && (prefix->byteOrder == 'l')))
{
@@ -3672,7 +3667,7 @@ SendConnSetup(ClientPtr client, char *reason) else
(void)WriteToClient(client, sz_xConnSetupPrefix, (char *) &csp);
(void)WriteToClient(client, (int)csp.lengthReason, reason);
- return (client->noClientException = -1);
+ return client->noClientException = -1;
}
numScreens = screenInfo.numScreens;
@@ -3707,9 +3702,9 @@ SendConnSetup(ClientPtr client, char *reason) {
unsigned int j;
xDepth *pDepth;
+ WindowPtr pRoot = screenInfo.screens[i]->root;
- root->currentInputMask = WindowTable[i]->eventMask |
- wOtherEventMasks (WindowTable[i]);
+ root->currentInputMask = pRoot->eventMask | wOtherEventMasks(pRoot);
pDepth = (xDepth *)(root + 1);
for (j = 0; j < root->nDepths; j++)
{
@@ -3909,9 +3904,12 @@ AddScreen( if (!pScreen)
return -1;
- pScreen->devPrivates = NULL;
+ if (!dixAllocatePrivates(&pScreen->devPrivates, PRIVATE_SCREEN)) {
+ free (pScreen);
+ return -1;
+ }
pScreen->myNum = i;
- pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8);
+ pScreen->totalPixmapSize = 0; /* computed in CreateScratchPixmapForScreen */
pScreen->ClipNotify = 0; /* for R4 ddx compatibility */
pScreen->CreateScreenResources = 0;
@@ -3957,15 +3955,17 @@ AddScreen( any of the strings pointed to by argv. They may be passed to
multiple screens.
*/
- WindowTable[i] = NullWindow;
screenInfo.screens[i] = pScreen;
screenInfo.numScreens++;
if (!(*pfnInit)(i, pScreen, argc, argv))
{
- dixFreePrivates(pScreen->devPrivates);
+ dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
free(pScreen);
screenInfo.numScreens--;
return -1;
}
+
+ dixRegisterPrivateKey(&cursorScreenDevPriv[i], PRIVATE_CURSOR, 0);
+
return i;
}
diff --git a/xorg-server/dix/dixfonts.c b/xorg-server/dix/dixfonts.c index 431b3ef6f..f46902419 100644 --- a/xorg-server/dix/dixfonts.c +++ b/xorg-server/dix/dixfonts.c @@ -484,7 +484,7 @@ CloseFont(pointer value, XID fid) FontPtr pfont = (FontPtr)value;
if (pfont == NullFont)
- return (Success);
+ return Success;
if (--pfont->refcnt == 0) {
if (patternCache)
RemoveCachedFontPattern (patternCache, pfont);
@@ -506,7 +506,7 @@ CloseFont(pointer value, XID fid) (*fpe_functions[fpe->type].close_font) (fpe, pfont);
FreeFPE(fpe);
}
- return (Success);
+ return Success;
}
@@ -679,7 +679,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) return TRUE;
}
if (err == FontNameAlias) {
- if (resolved) free(resolved);
+ free(resolved);
resolved = malloc(resolvedlen + 1);
if (resolved)
memmove(resolved, tmpname, resolvedlen + 1);
@@ -733,8 +733,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) {
c->saved = c->current;
c->haveSaved = TRUE;
- if (c->savedName)
- free(c->savedName);
+ free(c->savedName);
c->savedName = malloc(namelen + 1);
if (c->savedName)
memmove(c->savedName, name, namelen + 1);
@@ -830,10 +829,10 @@ bail: for (i = 0; i < c->num_fpes; i++)
FreeFPE(c->fpe_list[i]);
free(c->fpe_list);
- if (c->savedName) free(c->savedName);
+ free(c->savedName);
FreeFontNames(names);
free(c);
- if (resolved) free(resolved);
+ free(resolved);
return TRUE;
}
@@ -996,8 +995,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) c->saved = c->current;
c->haveSaved = TRUE;
c->savedNumFonts = numFonts;
- if (c->savedName)
- free(c->savedName);
+ free(c->savedName);
c->savedName = malloc(namelen + 1);
if (c->savedName)
memmove(c->savedName, name, namelen + 1);
@@ -1095,7 +1093,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) }
finish:
length = sizeof(xListFontsWithInfoReply);
- bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply));
+ memset((char *) &finalReply, 0, sizeof(xListFontsWithInfoReply));
finalReply.type = X_Reply;
finalReply.sequenceNumber = client->sequence;
finalReply.length = bytes_to_int32(sizeof(xListFontsWithInfoReply)
@@ -1108,7 +1106,7 @@ bail: FreeFPE(c->fpe_list[i]);
free(c->reply);
free(c->fpe_list);
- if (c->savedName) free(c->savedName);
+ free(c->savedName);
free(c);
return TRUE;
}
diff --git a/xorg-server/dix/dixutils.c b/xorg-server/dix/dixutils.c index 6b6b41d0d..d9d9d8c7d 100644 --- a/xorg-server/dix/dixutils.c +++ b/xorg-server/dix/dixutils.c @@ -296,17 +296,17 @@ AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode, if (mode == SetModeInsert)
{
if (j < numnow) /* duplicate */
- return(Success);
+ return Success;
numnow++;
pTmp = (SaveSetElt *)realloc(client->saveSet, sizeof(*pTmp) * numnow);
if (!pTmp)
- return(BadAlloc);
+ return BadAlloc;
client->saveSet = pTmp;
client->numSaved = numnow;
SaveSetAssignWindow(client->saveSet[numnow - 1], pWin);
SaveSetAssignToRoot(client->saveSet[numnow - 1], toRoot);
SaveSetAssignMap(client->saveSet[numnow - 1], map);
- return(Success);
+ return Success;
}
else if ((mode == SetModeDelete) && (j < numnow))
{
@@ -328,9 +328,9 @@ AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode, client->saveSet = (SaveSetElt *)NULL;
}
client->numSaved = numnow;
- return(Success);
+ return Success;
}
- return(Success);
+ return Success;
}
void
@@ -893,7 +893,7 @@ InitCallbackManager(void) {
DeleteCallbackList(listsToCleanup[i]);
}
- if (listsToCleanup) free(listsToCleanup);
+ free(listsToCleanup);
numCallbackListsToCleanup = 0;
listsToCleanup = NULL;
diff --git a/xorg-server/dix/enterleave.c b/xorg-server/dix/enterleave.c index c08cc3100..73e007dda 100644 --- a/xorg-server/dix/enterleave.c +++ b/xorg-server/dix/enterleave.c @@ -1,1385 +1,1385 @@ -/* - * Copyright © 2008 Red Hat, Inc. - * - * 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 (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Authors: Peter Hutterer - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/extensions/XI2.h> -#include "inputstr.h" -#include "windowstr.h" -#include "scrnintstr.h" -#include "exglobals.h" -#include "enterleave.h" - -/** - * @file - * This file describes the model for sending core enter/leave events and - * focus in/out in the case of multiple pointers/keyboard foci. - * - * Since we can't send more than one Enter or Leave/Focus in or out event per - * window to a core client without confusing it, this is a rather complicated - * approach. - * - * For a full description of the enter/leave model from a window's - * perspective, see - * http://lists.freedesktop.org/archives/xorg/2008-August/037606.html - * - * For a full description of the focus in/out model from a window's - * perspective, see - * http://lists.freedesktop.org/archives/xorg/2008-December/041740.html - * - * Additional notes: - * - The core protocol spec says that "In a LeaveNotify event, if a child of the - * event window contains the initial position of the pointer, then the child - * component is set to that child. Otherwise, it is None. For an EnterNotify - * event, if a child of the event window contains the final pointer position, - * then the child component is set to that child. Otherwise, it is None." - * - * By inference, this means that only NotifyVirtual or NotifyNonlinearVirtual - * events may have a subwindow set to other than None. - * - * - NotifyPointer events may be sent if the focus changes from window A to - * B. The assumption used in this model is that NotifyPointer events are only - * sent for the pointer paired with the keyboard that is involved in the focus - * events. For example, if F(W) changes because of keyboard 2, then - * NotifyPointer events are only sent for pointer 2. - */ - -static WindowPtr PointerWindows[MAXDEVICES]; -static WindowPtr FocusWindows[MAXDEVICES]; - -/** - * Return TRUE if 'win' has a pointer within its boundaries, excluding child - * window. - */ -static BOOL -HasPointer(WindowPtr win) -{ - int i; - - for (i = 0; i < MAXDEVICES; i++) - if (PointerWindows[i] == win) - return TRUE; - - return FALSE; -} - -/** - * Return TRUE if at least one keyboard focus is set to 'win' (excluding - * descendants of win). - */ -static BOOL -HasFocus(WindowPtr win) -{ - int i; - for (i = 0; i < MAXDEVICES; i++) - if (FocusWindows[i] == win) - return TRUE; - - return FALSE; -} - -/** - * Return the window the device dev is currently on. - */ -static WindowPtr -PointerWin(DeviceIntPtr dev) -{ - return PointerWindows[dev->id]; -} - -/** - * Search for the first window below 'win' that has a pointer directly within - * it's boundaries (excluding boundaries of its own descendants). - * - * @return The child window that has the pointer within its boundaries or - * NULL. - */ -static WindowPtr -FirstPointerChild(WindowPtr win) -{ - int i; - for (i = 0; i < MAXDEVICES; i++) - { - if (PointerWindows[i] && IsParent(win, PointerWindows[i])) - return PointerWindows[i]; - } - - return NULL; -} - -/** - * Search for the first window below 'win' that has a focus directly within - * it's boundaries (excluding boundaries of its own descendants). - * - * @return The child window that has the pointer within its boundaries or - * NULL. - */ -static WindowPtr -FirstFocusChild(WindowPtr win) -{ - int i; - for (i = 0; i < MAXDEVICES; i++) - { - if (FocusWindows[i] && FocusWindows[i] != PointerRootWin && - IsParent(win, FocusWindows[i])) - return FocusWindows[i]; - } - - return NULL; -} - -/** - * Set the presence flag for dev to mark that it is now in 'win'. - */ -void -EnterWindow(DeviceIntPtr dev, WindowPtr win, int mode) -{ - PointerWindows[dev->id] = win; -} - -/** - * Unset the presence flag for dev to mark that it is not in 'win' anymore. - */ -void -LeaveWindow(DeviceIntPtr dev) -{ - PointerWindows[dev->id] = NULL; -} - -/** - * Set the presence flag for dev to mark that it is now in 'win'. - */ -void -SetFocusIn(DeviceIntPtr dev, WindowPtr win) -{ - FocusWindows[dev->id] = win; -} - -/** - * Unset the presence flag for dev to mark that it is not in 'win' anymore. - */ -void -SetFocusOut(DeviceIntPtr dev) -{ - FocusWindows[dev->id] = NULL; -} - - - - -/** - * Return the common ancestor of 'a' and 'b' (if one exists). - * @param a A window with the same ancestor as b. - * @param b A window with the same ancestor as a. - * @return The window that is the first ancestor of both 'a' and 'b', or the - * NullWindow if they do not have a common ancestor. - */ -WindowPtr -CommonAncestor( - WindowPtr a, - WindowPtr b) -{ - for (b = b->parent; b; b = b->parent) - if (IsParent(b, a)) return b; - return NullWindow; -} - - -/** - * Send enter notifies to all windows between 'ancestor' and 'child' (excluding - * both). Events are sent running up the window hierarchy. This function - * recurses. - */ -static void -DeviceEnterNotifies(DeviceIntPtr dev, - int sourceid, - WindowPtr ancestor, - WindowPtr child, - int mode, - int detail) -{ - WindowPtr parent = child->parent; - - if (ancestor == parent) - return; - DeviceEnterNotifies(dev, sourceid, ancestor, parent, mode, detail); - DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, detail, parent, - child->drawable.id); -} - -/** - * Send enter notifies to all windows between 'ancestor' and 'child' (excluding - * both). Events are sent running down the window hierarchy. This function - * recurses. - */ -static void -CoreEnterNotifies(DeviceIntPtr dev, - WindowPtr ancestor, - WindowPtr child, - int mode, - int detail) -{ - WindowPtr parent = child->parent; - if (ancestor == parent) - return; - CoreEnterNotifies(dev, ancestor, parent, mode, detail); - - - /* Case 3: - A is above W, B is a descendant - - Classically: The move generates an EnterNotify on W with a detail of - Virtual or NonlinearVirtual - - MPX: - Case 3A: There is at least one other pointer on W itself - P(W) doesn't change, so the event should be suppressed - Case 3B: Otherwise, if there is at least one other pointer in a - descendant - P(W) stays on the same descendant, or changes to a different - descendant. The event should be suppressed. - Case 3C: Otherwise: - P(W) moves from a window above W to a descendant. The subwindow - field is set to the child containing the descendant. The detail - may need to be changed from Virtual to NonlinearVirtual depending - on the previous P(W). */ - - if (!HasPointer(parent) && !FirstPointerChild(parent)) - CoreEnterLeaveEvent(dev, EnterNotify, mode, detail, parent, - child->drawable.id); -} - -static void -CoreLeaveNotifies(DeviceIntPtr dev, - WindowPtr child, - WindowPtr ancestor, - int mode, - int detail) -{ - WindowPtr win; - - if (ancestor == child) - return; - - for (win = child->parent; win != ancestor; win = win->parent) - { - /*Case 7: - A is a descendant of W, B is above W - - Classically: A LeaveNotify is generated on W with a detail of Virtual - or NonlinearVirtual. - - MPX: - Case 3A: There is at least one other pointer on W itself - P(W) doesn't change, the event should be suppressed. - Case 3B: Otherwise, if there is at least one other pointer in a - descendant - P(W) stays on the same descendant, or changes to a different - descendant. The event should be suppressed. - Case 3C: Otherwise: - P(W) changes from the descendant of W to a window above W. - The detail may need to be changed from Virtual to NonlinearVirtual - or vice-versa depending on the new P(W).*/ - - /* If one window has a pointer or a child with a pointer, skip some - * work and exit. */ - if (HasPointer(win) || FirstPointerChild(win)) - return; - - CoreEnterLeaveEvent(dev, LeaveNotify, mode, detail, win, child->drawable.id); - - child = win; - } -} - -/** - * Send leave notifies to all windows between 'child' and 'ancestor'. - * Events are sent running up the hierarchy. - */ -static void -DeviceLeaveNotifies(DeviceIntPtr dev, - int sourceid, - WindowPtr child, - WindowPtr ancestor, - int mode, - int detail) -{ - WindowPtr win; - - if (ancestor == child) - return; - for (win = child->parent; win != ancestor; win = win->parent) - { - DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, detail, win, - child->drawable.id); - child = win; - } -} - -/** - * Pointer dev moves from A to B and A neither a descendant of B nor is - * B a descendant of A. - */ -static void -CoreEnterLeaveNonLinear(DeviceIntPtr dev, - WindowPtr A, - WindowPtr B, - int mode) -{ - WindowPtr X = CommonAncestor(A, B); - /* Case 4: - A is W, B is above W - - Classically: The move generates a LeaveNotify on W with a detail of - Ancestor or Nonlinear - - MPX: - Case 3A: There is at least one other pointer on W itself - P(W) doesn't change, the event should be suppressed - Case 3B: Otherwise, if there is at least one other pointer in a - descendant of W - P(W) changes from W to a descendant of W. The subwindow field - is set to the child containing the new P(W), the detail field - is set to Inferior - Case 3C: Otherwise: - The pointer window moves from W to a window above W. - The detail may need to be changed from Ancestor to Nonlinear or - vice versa depending on the the new P(W) - */ - - if (!HasPointer(A)) - { - WindowPtr child = FirstPointerChild(A); - if (child) - CoreEnterLeaveEvent(dev, LeaveNotify, mode, NotifyInferior, A, None); - else - CoreEnterLeaveEvent(dev, LeaveNotify, mode, NotifyNonlinear, A, None); - } - - - CoreLeaveNotifies(dev, A, X, mode, NotifyNonlinearVirtual); - - /* - Case 9: - A is a descendant of W, B is a descendant of W - - Classically: No events are generated on W - MPX: The pointer window stays the same or moves to a different - descendant of W. No events should be generated on W. - - - Therefore, no event to X. - */ - - CoreEnterNotifies(dev, X, B, mode, NotifyNonlinearVirtual); - - /* Case 2: - A is above W, B=W - - Classically: The move generates an EnterNotify on W with a detail of - Ancestor or Nonlinear - - MPX: - Case 2A: There is at least one other pointer on W itself - P(W) doesn't change, so the event should be suppressed - Case 2B: Otherwise, if there is at least one other pointer in a - descendant - P(W) moves from a descendant to W. detail is changed to Inferior, - subwindow is set to the child containing the previous P(W) - Case 2C: Otherwise: - P(W) changes from a window above W to W itself. - The detail may need to be changed from Ancestor to Nonlinear - or vice-versa depending on the previous P(W). */ - - if (!HasPointer(B)) - { - WindowPtr child = FirstPointerChild(B); - if (child) - CoreEnterLeaveEvent(dev, EnterNotify, mode, NotifyInferior, B, None); - else - CoreEnterLeaveEvent(dev, EnterNotify, mode, NotifyNonlinear, B, None); - } -} - -/** - * Pointer dev moves from A to B and A is a descendant of B. - */ -static void -CoreEnterLeaveToAncestor(DeviceIntPtr dev, - WindowPtr A, - WindowPtr B, - int mode) -{ - /* Case 4: - A is W, B is above W - - Classically: The move generates a LeaveNotify on W with a detail of - Ancestor or Nonlinear - - MPX: - Case 3A: There is at least one other pointer on W itself - P(W) doesn't change, the event should be suppressed - Case 3B: Otherwise, if there is at least one other pointer in a - descendant of W - P(W) changes from W to a descendant of W. The subwindow field - is set to the child containing the new P(W), the detail field - is set to Inferior - Case 3C: Otherwise: - The pointer window moves from W to a window above W. - The detail may need to be changed from Ancestor to Nonlinear or - vice versa depending on the the new P(W) - */ - if (!HasPointer(A)) - { - WindowPtr child = FirstPointerChild(A); - if (child) - CoreEnterLeaveEvent(dev, LeaveNotify, mode, NotifyInferior, A, None); - else - CoreEnterLeaveEvent(dev, LeaveNotify, mode, NotifyAncestor, A, None); - } - - CoreLeaveNotifies(dev, A, B, mode, NotifyVirtual); - - /* Case 8: - A is a descendant of W, B is W - - Classically: A EnterNotify is generated on W with a detail of - NotifyInferior - - MPX: - Case 3A: There is at least one other pointer on W itself - P(W) doesn't change, the event should be suppressed - Case 3B: Otherwise: - P(W) changes from a descendant to W itself. The subwindow - field should be set to the child containing the old P(W) <<< WRONG */ - - if (!HasPointer(B)) - CoreEnterLeaveEvent(dev, EnterNotify, mode, NotifyInferior, B, None); - -} - - -/** - * Pointer dev moves from A to B and B is a descendant of A. - */ -static void -CoreEnterLeaveToDescendant(DeviceIntPtr dev, - WindowPtr A, - WindowPtr B, - int mode) -{ - /* Case 6: - A is W, B is a descendant of W - - Classically: A LeaveNotify is generated on W with a detail of - NotifyInferior - - MPX: - Case 3A: There is at least one other pointer on W itself - P(W) doesn't change, the event should be suppressed - Case 3B: Otherwise: - P(W) changes from W to a descendant of W. The subwindow field - is set to the child containing the new P(W) <<< THIS IS WRONG */ - - if (!HasPointer(A)) - CoreEnterLeaveEvent(dev, LeaveNotify, mode, NotifyInferior, A, None); - - - CoreEnterNotifies(dev, A, B, mode, NotifyVirtual); - - /* Case 2: - A is above W, B=W - - Classically: The move generates an EnterNotify on W with a detail of - Ancestor or Nonlinear - - MPX: - Case 2A: There is at least one other pointer on W itself - P(W) doesn't change, so the event should be suppressed - Case 2B: Otherwise, if there is at least one other pointer in a - descendant - P(W) moves from a descendant to W. detail is changed to Inferior, - subwindow is set to the child containing the previous P(W) - Case 2C: Otherwise: - P(W) changes from a window above W to W itself. - The detail may need to be changed from Ancestor to Nonlinear - or vice-versa depending on the previous P(W). */ - - if (!HasPointer(B)) - { - WindowPtr child = FirstPointerChild(B); - if (child) - CoreEnterLeaveEvent(dev, EnterNotify, mode, NotifyInferior, B, None); - else - CoreEnterLeaveEvent(dev, EnterNotify, mode, NotifyAncestor, B, None); - } -} - -static void -CoreEnterLeaveEvents(DeviceIntPtr dev, - WindowPtr from, - WindowPtr to, - int mode) -{ - if (!IsMaster(dev)) - return; - - LeaveWindow(dev); - - if (IsParent(from, to)) - CoreEnterLeaveToDescendant(dev, from, to, mode); - else if (IsParent(to, from)) - CoreEnterLeaveToAncestor(dev, from, to, mode); - else - CoreEnterLeaveNonLinear(dev, from, to, mode); - - EnterWindow(dev, to, mode); -} - -static void -DeviceEnterLeaveEvents(DeviceIntPtr dev, - int sourceid, - WindowPtr from, - WindowPtr to, - int mode) -{ - if (IsParent(from, to)) - { - DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, NotifyInferior, from, None); - DeviceEnterNotifies(dev, sourceid, from, to, mode, NotifyVirtual); - DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, NotifyAncestor, to, None); - } - else if (IsParent(to, from)) - { - DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, NotifyAncestor, from, None); - DeviceLeaveNotifies(dev, sourceid, from, to, mode, NotifyVirtual); - DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, NotifyInferior, to, None); - } - else - { /* neither from nor to is descendent of the other */ - WindowPtr common = CommonAncestor(to, from); - /* common == NullWindow ==> different screens */ - DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, NotifyNonlinear, from, None); - DeviceLeaveNotifies(dev, sourceid, from, common, mode, NotifyNonlinearVirtual); - DeviceEnterNotifies(dev, sourceid, common, to, mode, NotifyNonlinearVirtual); - DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, NotifyNonlinear, to, None); - } -} - -/** - * Figure out if enter/leave events are necessary and send them to the - * appropriate windows. - * - * @param fromWin Window the sprite moved out of. - * @param toWin Window the sprite moved into. - */ -void -DoEnterLeaveEvents(DeviceIntPtr pDev, - int sourceid, - WindowPtr fromWin, - WindowPtr toWin, - int mode) -{ - if (!IsPointerDevice(pDev)) - return; - - if (fromWin == toWin) - return; - - if (mode != XINotifyPassiveGrab && mode != XINotifyPassiveUngrab) - CoreEnterLeaveEvents(pDev, fromWin, toWin, mode); - DeviceEnterLeaveEvents(pDev, sourceid, fromWin, toWin, mode); -} - -/** - * Send focus out events to all windows between 'child' and 'ancestor'. - * Events are sent running up the hierarchy. - */ -static void -DeviceFocusOutEvents(DeviceIntPtr dev, - WindowPtr child, - WindowPtr ancestor, - int mode, - int detail) -{ - WindowPtr win; - - if (ancestor == child) - return; - for (win = child->parent; win != ancestor; win = win->parent) - DeviceFocusEvent(dev, XI_FocusOut, mode, detail, win); -} - - -/** - * Send enter notifies to all windows between 'ancestor' and 'child' (excluding - * both). Events are sent running up the window hierarchy. This function - * recurses. - */ -static void -DeviceFocusInEvents(DeviceIntPtr dev, - WindowPtr ancestor, - WindowPtr child, - int mode, - int detail) -{ - WindowPtr parent = child->parent; - - if (ancestor == parent || !parent) - return; - DeviceFocusInEvents(dev, ancestor, parent, mode, detail); - DeviceFocusEvent(dev, XI_FocusIn, mode, detail, parent); -} - -/** - * Send FocusIn events to all windows between 'ancestor' and 'child' (excluding - * both). Events are sent running down the window hierarchy. This function - * recurses. - */ -static void -CoreFocusInEvents(DeviceIntPtr dev, - WindowPtr ancestor, - WindowPtr child, - int mode, - int detail) -{ - WindowPtr parent = child->parent; - if (ancestor == parent) - return; - CoreFocusInEvents(dev, ancestor, parent, mode, detail); - - - /* Case 3: - A is above W, B is a descendant - - Classically: The move generates an FocusIn on W with a detail of - Virtual or NonlinearVirtual - - MPX: - Case 3A: There is at least one other focus on W itself - F(W) doesn't change, so the event should be suppressed - Case 3B: Otherwise, if there is at least one other focus in a - descendant - F(W) stays on the same descendant, or changes to a different - descendant. The event should be suppressed. - Case 3C: Otherwise: - F(W) moves from a window above W to a descendant. The detail may - need to be changed from Virtual to NonlinearVirtual depending - on the previous F(W). */ - - if (!HasFocus(parent) && !FirstFocusChild(parent)) - CoreFocusEvent(dev, FocusIn, mode, detail, parent); -} - -static void -CoreFocusOutEvents(DeviceIntPtr dev, - WindowPtr child, - WindowPtr ancestor, - int mode, - int detail) -{ - WindowPtr win; - - if (ancestor == child) - return; - - for (win = child->parent; win != ancestor; win = win->parent) - { - /*Case 7: - A is a descendant of W, B is above W - - Classically: A FocusOut is generated on W with a detail of Virtual - or NonlinearVirtual. - - MPX: - Case 3A: There is at least one other focus on W itself - F(W) doesn't change, the event should be suppressed. - Case 3B: Otherwise, if there is at least one other focus in a - descendant - F(W) stays on the same descendant, or changes to a different - descendant. The event should be suppressed. - Case 3C: Otherwise: - F(W) changes from the descendant of W to a window above W. - The detail may need to be changed from Virtual to NonlinearVirtual - or vice-versa depending on the new P(W).*/ - - /* If one window has a focus or a child with a focuspointer, skip some - * work and exit. */ - if (HasFocus(win) || FirstFocusChild(win)) - return; - - CoreFocusEvent(dev, FocusOut, mode, detail, win); - } -} - -/** - * Send FocusOut(NotifyPointer) events from the current pointer window (which - * is a descendant of pwin_parent) up to (excluding) pwin_parent. - * - * NotifyPointer events are only sent for the device paired with dev. - * - * If the current pointer window is a descendant of 'exclude' or an ancestor of - * 'exclude', no events are sent. If the current pointer IS 'exclude', events - * are sent! - */ -static void -CoreFocusOutNotifyPointerEvents(DeviceIntPtr dev, - WindowPtr pwin_parent, - WindowPtr exclude, - int mode, - int inclusive) -{ - WindowPtr P, stopAt; - - P = PointerWin(GetPairedDevice(dev)); - - if (!P) - return; - if (!IsParent(pwin_parent, P)) - if (!(pwin_parent == P && inclusive)) - return; - - if (exclude != None && exclude != PointerRootWin && - (IsParent(exclude, P) || IsParent(P, exclude))) - return; - - stopAt = (inclusive) ? pwin_parent->parent : pwin_parent; - - for (; P && P != stopAt; P = P->parent) - CoreFocusEvent(dev, FocusOut, mode, NotifyPointer, P); -} - -/** - * DO NOT CALL DIRECTLY. - * Recursion helper for CoreFocusInNotifyPointerEvents. - */ -static void -CoreFocusInRecurse(DeviceIntPtr dev, - WindowPtr win, - WindowPtr stopAt, - int mode, - int inclusive) -{ - if ((!inclusive && win == stopAt) || !win) - return; - - CoreFocusInRecurse(dev, win->parent, stopAt, mode, inclusive); - CoreFocusEvent(dev, FocusIn, mode, NotifyPointer, win); -} - - -/** - * Send FocusIn(NotifyPointer) events from pwin_parent down to - * including the current pointer window (which is a descendant of pwin_parent). - * - * @param pwin The pointer window. - * @param exclude If the pointer window is a child of 'exclude', no events are - * sent. - * @param inclusive If TRUE, pwin_parent will receive the event too. - */ -static void -CoreFocusInNotifyPointerEvents(DeviceIntPtr dev, - WindowPtr pwin_parent, - WindowPtr exclude, - int mode, - int inclusive) -{ - WindowPtr P; - - P = PointerWin(GetPairedDevice(dev)); - - if (!P || P == exclude || (pwin_parent != P && !IsParent(pwin_parent, P))) - return; - - if (exclude != None && (IsParent(exclude, P) || IsParent(P, exclude))) - return; - - CoreFocusInRecurse(dev, P, pwin_parent, mode, inclusive); -} - - -/** - * Focus of dev moves from A to B and A neither a descendant of B nor is - * B a descendant of A. - */ -static void -CoreFocusNonLinear(DeviceIntPtr dev, - WindowPtr A, - WindowPtr B, - int mode) -{ - WindowPtr X = CommonAncestor(A, B); - - /* Case 4: - A is W, B is above W - - Classically: The change generates a FocusOut on W with a detail of - Ancestor or Nonlinear - - MPX: - Case 3A: There is at least one other focus on W itself - F(W) doesn't change, the event should be suppressed - Case 3B: Otherwise, if there is at least one other focus in a - descendant of W - F(W) changes from W to a descendant of W. The detail field - is set to Inferior - Case 3C: Otherwise: - The focus window moves from W to a window above W. - The detail may need to be changed from Ancestor to Nonlinear or - vice versa depending on the the new F(W) - */ - - if (!HasFocus(A)) - { - WindowPtr child = FirstFocusChild(A); - if (child) - { - /* NotifyPointer P-A unless P is child or below*/ - CoreFocusOutNotifyPointerEvents(dev, A, child, mode, FALSE); - CoreFocusEvent(dev, FocusOut, mode, NotifyInferior, A); - } else - { - /* NotifyPointer P-A */ - CoreFocusOutNotifyPointerEvents(dev, A, None, mode, FALSE); - CoreFocusEvent(dev, FocusOut, mode, NotifyNonlinear, A); - } - } - - - CoreFocusOutEvents(dev, A, X, mode, NotifyNonlinearVirtual); - - /* - Case 9: - A is a descendant of W, B is a descendant of W - - Classically: No events are generated on W - MPX: The focus window stays the same or moves to a different - descendant of W. No events should be generated on W. - - - Therefore, no event to X. - */ - - CoreFocusInEvents(dev, X, B, mode, NotifyNonlinearVirtual); - - /* Case 2: - A is above W, B=W - - Classically: The move generates an EnterNotify on W with a detail of - Ancestor or Nonlinear - - MPX: - Case 2A: There is at least one other focus on W itself - F(W) doesn't change, so the event should be suppressed - Case 2B: Otherwise, if there is at least one other focus in a - descendant - F(W) moves from a descendant to W. detail is changed to Inferior. - Case 2C: Otherwise: - F(W) changes from a window above W to W itself. - The detail may need to be changed from Ancestor to Nonlinear - or vice-versa depending on the previous F(W). */ - - if (!HasFocus(B)) - { - WindowPtr child = FirstFocusChild(B); - if (child) - { - CoreFocusEvent(dev, FocusIn, mode, NotifyInferior, B); - /* NotifyPointer B-P unless P is child or below. */ - CoreFocusInNotifyPointerEvents(dev, B, child, mode, FALSE); - } else { - CoreFocusEvent(dev, FocusIn, mode, NotifyNonlinear, B); - /* NotifyPointer B-P unless P is child or below. */ - CoreFocusInNotifyPointerEvents(dev, B, None, mode, FALSE); - } - } -} - - -/** - * Focus of dev moves from A to B and A is a descendant of B. - */ -static void -CoreFocusToAncestor(DeviceIntPtr dev, - WindowPtr A, - WindowPtr B, - int mode) -{ - /* Case 4: - A is W, B is above W - - Classically: The change generates a FocusOut on W with a detail of - Ancestor or Nonlinear - - MPX: - Case 3A: There is at least one other focus on W itself - F(W) doesn't change, the event should be suppressed - Case 3B: Otherwise, if there is at least one other focus in a - descendant of W - F(W) changes from W to a descendant of W. The detail field - is set to Inferior - Case 3C: Otherwise: - The focus window moves from W to a window above W. - The detail may need to be changed from Ancestor to Nonlinear or - vice versa depending on the the new F(W) - */ - if (!HasFocus(A)) - { - WindowPtr child = FirstFocusChild(A); - if (child) - { - /* NotifyPointer P-A unless P is child or below*/ - CoreFocusOutNotifyPointerEvents(dev, A, child, mode, FALSE); - CoreFocusEvent(dev, FocusOut, mode, NotifyInferior, A); - } else - CoreFocusEvent(dev, FocusOut, mode, NotifyAncestor, A); - } - - CoreFocusOutEvents(dev, A, B, mode, NotifyVirtual); - - /* Case 8: - A is a descendant of W, B is W - - Classically: A FocusOut is generated on W with a detail of - NotifyInferior - - MPX: - Case 3A: There is at least one other focus on W itself - F(W) doesn't change, the event should be suppressed - Case 3B: Otherwise: - F(W) changes from a descendant to W itself. */ - - if (!HasFocus(B)) - { - CoreFocusEvent(dev, FocusIn, mode, NotifyInferior, B); - /* NotifyPointer B-P unless P is A or below. */ - CoreFocusInNotifyPointerEvents(dev, B, A, mode, FALSE); - } -} - -/** - * Focus of dev moves from A to B and B is a descendant of A. - */ -static void -CoreFocusToDescendant(DeviceIntPtr dev, - WindowPtr A, - WindowPtr B, - int mode) -{ - /* Case 6: - A is W, B is a descendant of W - - Classically: A FocusOut is generated on W with a detail of - NotifyInferior - - MPX: - Case 3A: There is at least one other focus on W itself - F(W) doesn't change, the event should be suppressed - Case 3B: Otherwise: - F(W) changes from W to a descendant of W. */ - - if (!HasFocus(A)) - { - /* NotifyPointer P-A unless P is B or below*/ - CoreFocusOutNotifyPointerEvents(dev, A, B, mode, FALSE); - CoreFocusEvent(dev, FocusOut, mode, NotifyInferior, A); - } - - - CoreFocusInEvents(dev, A, B, mode, NotifyVirtual); - - /* Case 2: - A is above W, B=W - - Classically: The move generates an FocusIn on W with a detail of - Ancestor or Nonlinear - - MPX: - Case 2A: There is at least one other focus on W itself - F(W) doesn't change, so the event should be suppressed - Case 2B: Otherwise, if there is at least one other focus in a - descendant - F(W) moves from a descendant to W. detail is changed to Inferior. - Case 2C: Otherwise: - F(W) changes from a window above W to W itself. - The detail may need to be changed from Ancestor to Nonlinear - or vice-versa depending on the previous F(W). */ - - if (!HasFocus(B)) - { - WindowPtr child = FirstFocusChild(B); - if (child) - { - CoreFocusEvent(dev, FocusIn, mode, NotifyInferior, B); - /* NotifyPointer B-P unless P is child or below. */ - CoreFocusInNotifyPointerEvents(dev, B, child, mode, FALSE); - } else - CoreFocusEvent(dev, FocusIn, mode, NotifyAncestor, B); - } -} - -static BOOL -HasOtherPointer(WindowPtr win, DeviceIntPtr exclude) -{ - int i; - - for (i = 0; i < MAXDEVICES; i++) - if (i != exclude->id && PointerWindows[i] == win) - return TRUE; - - return FALSE; -} - -/** - * Focus moves from PointerRoot to None or from None to PointerRoot. - * Assumption: Neither A nor B are valid windows. - */ -static void -CoreFocusPointerRootNoneSwitch(DeviceIntPtr dev, - WindowPtr A, /* PointerRootWin or NoneWin */ - WindowPtr B, /* NoneWin or PointerRootWin */ - int mode) -{ - WindowPtr root; - int i; - int nscreens = screenInfo.numScreens; - -#ifdef PANORAMIX - if (!noPanoramiXExtension) - nscreens = 1; -#endif - - for (i = 0; i < nscreens; i++) - { - root = WindowTable[i]; - if (!HasOtherPointer(root, GetPairedDevice(dev)) && !FirstFocusChild(root)) - { - /* If pointer was on PointerRootWin and changes to NoneWin, and - * the pointer paired with dev is below the current root window, - * do a NotifyPointer run. */ - if (dev->focus && dev->focus->win == PointerRootWin && - B != PointerRootWin) - { - WindowPtr ptrwin = PointerWin(GetPairedDevice(dev)); - if (ptrwin && IsParent(root, ptrwin)) - CoreFocusOutNotifyPointerEvents(dev, root, None, mode, TRUE); - } - CoreFocusEvent(dev, FocusOut, mode, A ? NotifyPointerRoot : NotifyDetailNone, root); - CoreFocusEvent(dev, FocusIn, mode, B ? NotifyPointerRoot : NotifyDetailNone, root); - if (B == PointerRootWin) - CoreFocusInNotifyPointerEvents(dev, root, None, mode, TRUE); - } - - } -} - -/** - * Focus moves from window A to PointerRoot or to None. - * Assumption: A is a valid window and not PointerRoot or None. - */ -static void -CoreFocusToPointerRootOrNone(DeviceIntPtr dev, - WindowPtr A, - WindowPtr B, /* PointerRootWin or NoneWin */ - int mode) -{ - WindowPtr root; - int i; - int nscreens = screenInfo.numScreens; - -#ifdef PANORAMIX - if (!noPanoramiXExtension) - nscreens = 1; -#endif - - if (!HasFocus(A)) - { - WindowPtr child = FirstFocusChild(A); - if (child) - { - /* NotifyPointer P-A unless P is B or below*/ - CoreFocusOutNotifyPointerEvents(dev, A, B, mode, FALSE); - CoreFocusEvent(dev, FocusOut, mode, NotifyInferior, A); - } else { - /* NotifyPointer P-A */ - CoreFocusOutNotifyPointerEvents(dev, A, None, mode, FALSE); - CoreFocusEvent(dev, FocusOut, mode, NotifyNonlinear, A); - } - } - - /* NullWindow means we include the root window */ - CoreFocusOutEvents(dev, A, NullWindow, mode, NotifyNonlinearVirtual); - - for (i = 0; i < nscreens; i++) - { - root = WindowTable[i]; - if (!HasFocus(root) && !FirstFocusChild(root)) - { - CoreFocusEvent(dev, FocusIn, mode, B ? NotifyPointerRoot : NotifyDetailNone, root); - if (B == PointerRootWin) - CoreFocusInNotifyPointerEvents(dev, root, None, mode, TRUE); - } - } -} - -/** - * Focus moves from PointerRoot or None to a window B. - * Assumption: B is a valid window and not PointerRoot or None. - */ -static void -CoreFocusFromPointerRootOrNone(DeviceIntPtr dev, - WindowPtr A, /* PointerRootWin or NoneWin */ - WindowPtr B, - int mode) -{ - WindowPtr root; - int i; - int nscreens = screenInfo.numScreens; - -#ifdef PANORAMIX - if (!noPanoramiXExtension) - nscreens = 1; -#endif - - for (i = 0; i < nscreens; i++) - { - root = WindowTable[i]; - if (!HasFocus(root) && !FirstFocusChild(root)) - { - /* If pointer was on PointerRootWin and changes to NoneWin, and - * the pointer paired with dev is below the current root window, - * do a NotifyPointer run. */ - if (dev->focus && dev->focus->win == PointerRootWin && - B != PointerRootWin) - { - WindowPtr ptrwin = PointerWin(GetPairedDevice(dev)); - if (ptrwin) - CoreFocusOutNotifyPointerEvents(dev, root, None, mode, TRUE); - } - CoreFocusEvent(dev, FocusOut, mode, A ? NotifyPointerRoot : NotifyDetailNone, root); - } - } - - root = B; /* get B's root window */ - while(root->parent) - root = root->parent; - - if (B != root) - { - CoreFocusEvent(dev, FocusIn, mode, NotifyNonlinearVirtual, root); - CoreFocusInEvents(dev, root, B, mode, NotifyNonlinearVirtual); - } - - - if (!HasFocus(B)) - { - WindowPtr child = FirstFocusChild(B); - if (child) - { - CoreFocusEvent(dev, FocusIn, mode, NotifyInferior, B); - /* NotifyPointer B-P unless P is child or below. */ - CoreFocusInNotifyPointerEvents(dev, B, child, mode, FALSE); - } else { - CoreFocusEvent(dev, FocusIn, mode, NotifyNonlinear, B); - /* NotifyPointer B-P unless P is child or below. */ - CoreFocusInNotifyPointerEvents(dev, B, None, mode, FALSE); - } - } - -} - -static void -CoreFocusEvents(DeviceIntPtr dev, - WindowPtr from, - WindowPtr to, - int mode) -{ - if (!IsMaster(dev)) - return; - - SetFocusOut(dev); - - if (((to == NullWindow) || (to == PointerRootWin)) && - ((from == NullWindow) || (from == PointerRootWin))) - CoreFocusPointerRootNoneSwitch(dev, from, to, mode); - else if ((to == NullWindow) || (to == PointerRootWin)) - CoreFocusToPointerRootOrNone(dev, from, to, mode); - else if ((from == NullWindow) || (from == PointerRootWin)) - CoreFocusFromPointerRootOrNone(dev, from, to, mode); - else if (IsParent(from, to)) - CoreFocusToDescendant(dev, from, to, mode); - else if (IsParent(to, from)) - CoreFocusToAncestor(dev, from, to, mode); - else - CoreFocusNonLinear(dev, from, to, mode); - - SetFocusIn(dev, to); -} - -/** - * The root window the given device is currently on. - */ -#define RootWindow(dev) dev->spriteInfo->sprite->spriteTrace[0] - -static void -DeviceFocusEvents(DeviceIntPtr dev, - WindowPtr from, - WindowPtr to, - int mode) -{ - int out, in; /* for holding details for to/from - PointerRoot/None */ - int i; - int nscreens = screenInfo.numScreens; - SpritePtr sprite = dev->spriteInfo->sprite; - - if (from == to) - return; - out = (from == NoneWin) ? NotifyDetailNone : NotifyPointerRoot; - in = (to == NoneWin) ? NotifyDetailNone : NotifyPointerRoot; - /* wrong values if neither, but then not referenced */ - -#ifdef PANORAMIX - if (!noPanoramiXExtension) - nscreens = 1; -#endif - - if ((to == NullWindow) || (to == PointerRootWin)) - { - if ((from == NullWindow) || (from == PointerRootWin)) - { - if (from == PointerRootWin) - DeviceFocusOutEvents(dev, sprite->win, RootWindow(dev), mode, - NotifyPointer); - /* Notify all the roots */ - for (i = 0; i < nscreens; i++) - DeviceFocusEvent(dev, XI_FocusOut, mode, out, WindowTable[i]); - } - else - { - if (IsParent(from, sprite->win)) - DeviceFocusOutEvents(dev, sprite->win, from, mode, - NotifyPointer); - DeviceFocusEvent(dev, XI_FocusOut, mode, NotifyNonlinear, from); - /* next call catches the root too, if the screen changed */ - DeviceFocusOutEvents(dev, from->parent, NullWindow, mode, - NotifyNonlinearVirtual); - } - /* Notify all the roots */ - for (i = 0; i < nscreens; i++) - DeviceFocusEvent(dev, XI_FocusIn, mode, in, WindowTable[i]); - if (to == PointerRootWin) - DeviceFocusInEvents(dev, RootWindow(dev), sprite->win, mode, NotifyPointer); - } - else - { - if ((from == NullWindow) || (from == PointerRootWin)) - { - if (from == PointerRootWin) - DeviceFocusOutEvents(dev, sprite->win, RootWindow(dev), mode, - NotifyPointer); - for (i = 0; i < nscreens; i++) - DeviceFocusEvent(dev, XI_FocusOut, mode, out, WindowTable[i]); - if (to->parent != NullWindow) - DeviceFocusInEvents(dev, RootWindow(dev), to, mode, NotifyNonlinearVirtual); - DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyNonlinear, to); - if (IsParent(to, sprite->win)) - DeviceFocusInEvents(dev, to, sprite->win, mode, NotifyPointer); - } - else - { - if (IsParent(to, from)) - { - DeviceFocusEvent(dev, XI_FocusOut, mode, NotifyAncestor, from); - DeviceFocusOutEvents(dev, from->parent, to, mode, - NotifyVirtual); - DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyInferior, to); - if ((IsParent(to, sprite->win)) && - (sprite->win != from) && - (!IsParent(from, sprite->win)) && - (!IsParent(sprite->win, from))) - DeviceFocusInEvents(dev, to, sprite->win, mode, NotifyPointer); - } - else - if (IsParent(from, to)) - { - if ((IsParent(from, sprite->win)) && - (sprite->win != from) && - (!IsParent(to, sprite->win)) && - (!IsParent(sprite->win, to))) - DeviceFocusOutEvents(dev, sprite->win, from, mode, - NotifyPointer); - DeviceFocusEvent(dev, XI_FocusOut, mode, NotifyInferior, from); - DeviceFocusInEvents(dev, from, to, mode, NotifyVirtual); - DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyAncestor, to); - } - else - { - /* neither from or to is child of other */ - WindowPtr common = CommonAncestor(to, from); - /* common == NullWindow ==> different screens */ - if (IsParent(from, sprite->win)) - DeviceFocusOutEvents(dev, sprite->win, from, mode, - NotifyPointer); - DeviceFocusEvent(dev, XI_FocusOut, mode, NotifyNonlinear, from); - if (from->parent != NullWindow) - DeviceFocusOutEvents(dev, from->parent, common, mode, - NotifyNonlinearVirtual); - if (to->parent != NullWindow) - DeviceFocusInEvents(dev, common, to, mode, NotifyNonlinearVirtual); - DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyNonlinear, to); - if (IsParent(to, sprite->win)) - DeviceFocusInEvents(dev, to, sprite->win, mode, NotifyPointer); - } - } - } -} - -/** - * Figure out if focus events are necessary and send them to the - * appropriate windows. - * - * @param from Window the focus moved out of. - * @param to Window the focus moved into. - */ -void -DoFocusEvents(DeviceIntPtr pDev, - WindowPtr from, - WindowPtr to, - int mode) -{ - if (!IsKeyboardDevice(pDev)) - return; - - if (from == to) - return; - - CoreFocusEvents(pDev, from, to, mode); - DeviceFocusEvents(pDev, from, to, mode); -} +/*
+ * Copyright © 2008 Red Hat, Inc.
+ *
+ * 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 (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors: Peter Hutterer
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/extensions/XI2.h>
+#include "inputstr.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "exglobals.h"
+#include "enterleave.h"
+
+/**
+ * @file
+ * This file describes the model for sending core enter/leave events and
+ * focus in/out in the case of multiple pointers/keyboard foci.
+ *
+ * Since we can't send more than one Enter or Leave/Focus in or out event per
+ * window to a core client without confusing it, this is a rather complicated
+ * approach.
+ *
+ * For a full description of the enter/leave model from a window's
+ * perspective, see
+ * http://lists.freedesktop.org/archives/xorg/2008-August/037606.html
+ *
+ * For a full description of the focus in/out model from a window's
+ * perspective, see
+ * http://lists.freedesktop.org/archives/xorg/2008-December/041740.html
+ *
+ * Additional notes:
+ * - The core protocol spec says that "In a LeaveNotify event, if a child of the
+ * event window contains the initial position of the pointer, then the child
+ * component is set to that child. Otherwise, it is None. For an EnterNotify
+ * event, if a child of the event window contains the final pointer position,
+ * then the child component is set to that child. Otherwise, it is None."
+ *
+ * By inference, this means that only NotifyVirtual or NotifyNonlinearVirtual
+ * events may have a subwindow set to other than None.
+ *
+ * - NotifyPointer events may be sent if the focus changes from window A to
+ * B. The assumption used in this model is that NotifyPointer events are only
+ * sent for the pointer paired with the keyboard that is involved in the focus
+ * events. For example, if F(W) changes because of keyboard 2, then
+ * NotifyPointer events are only sent for pointer 2.
+ */
+
+static WindowPtr PointerWindows[MAXDEVICES];
+static WindowPtr FocusWindows[MAXDEVICES];
+
+/**
+ * Return TRUE if 'win' has a pointer within its boundaries, excluding child
+ * window.
+ */
+static BOOL
+HasPointer(WindowPtr win)
+{
+ int i;
+
+ for (i = 0; i < MAXDEVICES; i++)
+ if (PointerWindows[i] == win)
+ return TRUE;
+
+ return FALSE;
+}
+
+/**
+ * Return TRUE if at least one keyboard focus is set to 'win' (excluding
+ * descendants of win).
+ */
+static BOOL
+HasFocus(WindowPtr win)
+{
+ int i;
+ for (i = 0; i < MAXDEVICES; i++)
+ if (FocusWindows[i] == win)
+ return TRUE;
+
+ return FALSE;
+}
+
+/**
+ * Return the window the device dev is currently on.
+ */
+static WindowPtr
+PointerWin(DeviceIntPtr dev)
+{
+ return PointerWindows[dev->id];
+}
+
+/**
+ * Search for the first window below 'win' that has a pointer directly within
+ * it's boundaries (excluding boundaries of its own descendants).
+ *
+ * @return The child window that has the pointer within its boundaries or
+ * NULL.
+ */
+static WindowPtr
+FirstPointerChild(WindowPtr win)
+{
+ int i;
+ for (i = 0; i < MAXDEVICES; i++)
+ {
+ if (PointerWindows[i] && IsParent(win, PointerWindows[i]))
+ return PointerWindows[i];
+ }
+
+ return NULL;
+}
+
+/**
+ * Search for the first window below 'win' that has a focus directly within
+ * it's boundaries (excluding boundaries of its own descendants).
+ *
+ * @return The child window that has the pointer within its boundaries or
+ * NULL.
+ */
+static WindowPtr
+FirstFocusChild(WindowPtr win)
+{
+ int i;
+ for (i = 0; i < MAXDEVICES; i++)
+ {
+ if (FocusWindows[i] && FocusWindows[i] != PointerRootWin &&
+ IsParent(win, FocusWindows[i]))
+ return FocusWindows[i];
+ }
+
+ return NULL;
+}
+
+/**
+ * Set the presence flag for dev to mark that it is now in 'win'.
+ */
+void
+EnterWindow(DeviceIntPtr dev, WindowPtr win, int mode)
+{
+ PointerWindows[dev->id] = win;
+}
+
+/**
+ * Unset the presence flag for dev to mark that it is not in 'win' anymore.
+ */
+void
+LeaveWindow(DeviceIntPtr dev)
+{
+ PointerWindows[dev->id] = NULL;
+}
+
+/**
+ * Set the presence flag for dev to mark that it is now in 'win'.
+ */
+void
+SetFocusIn(DeviceIntPtr dev, WindowPtr win)
+{
+ FocusWindows[dev->id] = win;
+}
+
+/**
+ * Unset the presence flag for dev to mark that it is not in 'win' anymore.
+ */
+void
+SetFocusOut(DeviceIntPtr dev)
+{
+ FocusWindows[dev->id] = NULL;
+}
+
+
+
+
+/**
+ * Return the common ancestor of 'a' and 'b' (if one exists).
+ * @param a A window with the same ancestor as b.
+ * @param b A window with the same ancestor as a.
+ * @return The window that is the first ancestor of both 'a' and 'b', or the
+ * NullWindow if they do not have a common ancestor.
+ */
+WindowPtr
+CommonAncestor(
+ WindowPtr a,
+ WindowPtr b)
+{
+ for (b = b->parent; b; b = b->parent)
+ if (IsParent(b, a)) return b;
+ return NullWindow;
+}
+
+
+/**
+ * Send enter notifies to all windows between 'ancestor' and 'child' (excluding
+ * both). Events are sent running up the window hierarchy. This function
+ * recurses.
+ */
+static void
+DeviceEnterNotifies(DeviceIntPtr dev,
+ int sourceid,
+ WindowPtr ancestor,
+ WindowPtr child,
+ int mode,
+ int detail)
+{
+ WindowPtr parent = child->parent;
+
+ if (ancestor == parent)
+ return;
+ DeviceEnterNotifies(dev, sourceid, ancestor, parent, mode, detail);
+ DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, detail, parent,
+ child->drawable.id);
+}
+
+/**
+ * Send enter notifies to all windows between 'ancestor' and 'child' (excluding
+ * both). Events are sent running down the window hierarchy. This function
+ * recurses.
+ */
+static void
+CoreEnterNotifies(DeviceIntPtr dev,
+ WindowPtr ancestor,
+ WindowPtr child,
+ int mode,
+ int detail)
+{
+ WindowPtr parent = child->parent;
+ if (ancestor == parent)
+ return;
+ CoreEnterNotifies(dev, ancestor, parent, mode, detail);
+
+
+ /* Case 3:
+ A is above W, B is a descendant
+
+ Classically: The move generates an EnterNotify on W with a detail of
+ Virtual or NonlinearVirtual
+
+ MPX:
+ Case 3A: There is at least one other pointer on W itself
+ P(W) doesn't change, so the event should be suppressed
+ Case 3B: Otherwise, if there is at least one other pointer in a
+ descendant
+ P(W) stays on the same descendant, or changes to a different
+ descendant. The event should be suppressed.
+ Case 3C: Otherwise:
+ P(W) moves from a window above W to a descendant. The subwindow
+ field is set to the child containing the descendant. The detail
+ may need to be changed from Virtual to NonlinearVirtual depending
+ on the previous P(W). */
+
+ if (!HasPointer(parent) && !FirstPointerChild(parent))
+ CoreEnterLeaveEvent(dev, EnterNotify, mode, detail, parent,
+ child->drawable.id);
+}
+
+static void
+CoreLeaveNotifies(DeviceIntPtr dev,
+ WindowPtr child,
+ WindowPtr ancestor,
+ int mode,
+ int detail)
+{
+ WindowPtr win;
+
+ if (ancestor == child)
+ return;
+
+ for (win = child->parent; win != ancestor; win = win->parent)
+ {
+ /*Case 7:
+ A is a descendant of W, B is above W
+
+ Classically: A LeaveNotify is generated on W with a detail of Virtual
+ or NonlinearVirtual.
+
+ MPX:
+ Case 3A: There is at least one other pointer on W itself
+ P(W) doesn't change, the event should be suppressed.
+ Case 3B: Otherwise, if there is at least one other pointer in a
+ descendant
+ P(W) stays on the same descendant, or changes to a different
+ descendant. The event should be suppressed.
+ Case 3C: Otherwise:
+ P(W) changes from the descendant of W to a window above W.
+ The detail may need to be changed from Virtual to NonlinearVirtual
+ or vice-versa depending on the new P(W).*/
+
+ /* If one window has a pointer or a child with a pointer, skip some
+ * work and exit. */
+ if (HasPointer(win) || FirstPointerChild(win))
+ return;
+
+ CoreEnterLeaveEvent(dev, LeaveNotify, mode, detail, win, child->drawable.id);
+
+ child = win;
+ }
+}
+
+/**
+ * Send leave notifies to all windows between 'child' and 'ancestor'.
+ * Events are sent running up the hierarchy.
+ */
+static void
+DeviceLeaveNotifies(DeviceIntPtr dev,
+ int sourceid,
+ WindowPtr child,
+ WindowPtr ancestor,
+ int mode,
+ int detail)
+{
+ WindowPtr win;
+
+ if (ancestor == child)
+ return;
+ for (win = child->parent; win != ancestor; win = win->parent)
+ {
+ DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, detail, win,
+ child->drawable.id);
+ child = win;
+ }
+}
+
+/**
+ * Pointer dev moves from A to B and A neither a descendant of B nor is
+ * B a descendant of A.
+ */
+static void
+CoreEnterLeaveNonLinear(DeviceIntPtr dev,
+ WindowPtr A,
+ WindowPtr B,
+ int mode)
+{
+ WindowPtr X = CommonAncestor(A, B);
+ /* Case 4:
+ A is W, B is above W
+
+ Classically: The move generates a LeaveNotify on W with a detail of
+ Ancestor or Nonlinear
+
+ MPX:
+ Case 3A: There is at least one other pointer on W itself
+ P(W) doesn't change, the event should be suppressed
+ Case 3B: Otherwise, if there is at least one other pointer in a
+ descendant of W
+ P(W) changes from W to a descendant of W. The subwindow field
+ is set to the child containing the new P(W), the detail field
+ is set to Inferior
+ Case 3C: Otherwise:
+ The pointer window moves from W to a window above W.
+ The detail may need to be changed from Ancestor to Nonlinear or
+ vice versa depending on the the new P(W)
+ */
+
+ if (!HasPointer(A))
+ {
+ WindowPtr child = FirstPointerChild(A);
+ if (child)
+ CoreEnterLeaveEvent(dev, LeaveNotify, mode, NotifyInferior, A, None);
+ else
+ CoreEnterLeaveEvent(dev, LeaveNotify, mode, NotifyNonlinear, A, None);
+ }
+
+
+ CoreLeaveNotifies(dev, A, X, mode, NotifyNonlinearVirtual);
+
+ /*
+ Case 9:
+ A is a descendant of W, B is a descendant of W
+
+ Classically: No events are generated on W
+ MPX: The pointer window stays the same or moves to a different
+ descendant of W. No events should be generated on W.
+
+
+ Therefore, no event to X.
+ */
+
+ CoreEnterNotifies(dev, X, B, mode, NotifyNonlinearVirtual);
+
+ /* Case 2:
+ A is above W, B=W
+
+ Classically: The move generates an EnterNotify on W with a detail of
+ Ancestor or Nonlinear
+
+ MPX:
+ Case 2A: There is at least one other pointer on W itself
+ P(W) doesn't change, so the event should be suppressed
+ Case 2B: Otherwise, if there is at least one other pointer in a
+ descendant
+ P(W) moves from a descendant to W. detail is changed to Inferior,
+ subwindow is set to the child containing the previous P(W)
+ Case 2C: Otherwise:
+ P(W) changes from a window above W to W itself.
+ The detail may need to be changed from Ancestor to Nonlinear
+ or vice-versa depending on the previous P(W). */
+
+ if (!HasPointer(B))
+ {
+ WindowPtr child = FirstPointerChild(B);
+ if (child)
+ CoreEnterLeaveEvent(dev, EnterNotify, mode, NotifyInferior, B, None);
+ else
+ CoreEnterLeaveEvent(dev, EnterNotify, mode, NotifyNonlinear, B, None);
+ }
+}
+
+/**
+ * Pointer dev moves from A to B and A is a descendant of B.
+ */
+static void
+CoreEnterLeaveToAncestor(DeviceIntPtr dev,
+ WindowPtr A,
+ WindowPtr B,
+ int mode)
+{
+ /* Case 4:
+ A is W, B is above W
+
+ Classically: The move generates a LeaveNotify on W with a detail of
+ Ancestor or Nonlinear
+
+ MPX:
+ Case 3A: There is at least one other pointer on W itself
+ P(W) doesn't change, the event should be suppressed
+ Case 3B: Otherwise, if there is at least one other pointer in a
+ descendant of W
+ P(W) changes from W to a descendant of W. The subwindow field
+ is set to the child containing the new P(W), the detail field
+ is set to Inferior
+ Case 3C: Otherwise:
+ The pointer window moves from W to a window above W.
+ The detail may need to be changed from Ancestor to Nonlinear or
+ vice versa depending on the the new P(W)
+ */
+ if (!HasPointer(A))
+ {
+ WindowPtr child = FirstPointerChild(A);
+ if (child)
+ CoreEnterLeaveEvent(dev, LeaveNotify, mode, NotifyInferior, A, None);
+ else
+ CoreEnterLeaveEvent(dev, LeaveNotify, mode, NotifyAncestor, A, None);
+ }
+
+ CoreLeaveNotifies(dev, A, B, mode, NotifyVirtual);
+
+ /* Case 8:
+ A is a descendant of W, B is W
+
+ Classically: A EnterNotify is generated on W with a detail of
+ NotifyInferior
+
+ MPX:
+ Case 3A: There is at least one other pointer on W itself
+ P(W) doesn't change, the event should be suppressed
+ Case 3B: Otherwise:
+ P(W) changes from a descendant to W itself. The subwindow
+ field should be set to the child containing the old P(W) <<< WRONG */
+
+ if (!HasPointer(B))
+ CoreEnterLeaveEvent(dev, EnterNotify, mode, NotifyInferior, B, None);
+
+}
+
+
+/**
+ * Pointer dev moves from A to B and B is a descendant of A.
+ */
+static void
+CoreEnterLeaveToDescendant(DeviceIntPtr dev,
+ WindowPtr A,
+ WindowPtr B,
+ int mode)
+{
+ /* Case 6:
+ A is W, B is a descendant of W
+
+ Classically: A LeaveNotify is generated on W with a detail of
+ NotifyInferior
+
+ MPX:
+ Case 3A: There is at least one other pointer on W itself
+ P(W) doesn't change, the event should be suppressed
+ Case 3B: Otherwise:
+ P(W) changes from W to a descendant of W. The subwindow field
+ is set to the child containing the new P(W) <<< THIS IS WRONG */
+
+ if (!HasPointer(A))
+ CoreEnterLeaveEvent(dev, LeaveNotify, mode, NotifyInferior, A, None);
+
+
+ CoreEnterNotifies(dev, A, B, mode, NotifyVirtual);
+
+ /* Case 2:
+ A is above W, B=W
+
+ Classically: The move generates an EnterNotify on W with a detail of
+ Ancestor or Nonlinear
+
+ MPX:
+ Case 2A: There is at least one other pointer on W itself
+ P(W) doesn't change, so the event should be suppressed
+ Case 2B: Otherwise, if there is at least one other pointer in a
+ descendant
+ P(W) moves from a descendant to W. detail is changed to Inferior,
+ subwindow is set to the child containing the previous P(W)
+ Case 2C: Otherwise:
+ P(W) changes from a window above W to W itself.
+ The detail may need to be changed from Ancestor to Nonlinear
+ or vice-versa depending on the previous P(W). */
+
+ if (!HasPointer(B))
+ {
+ WindowPtr child = FirstPointerChild(B);
+ if (child)
+ CoreEnterLeaveEvent(dev, EnterNotify, mode, NotifyInferior, B, None);
+ else
+ CoreEnterLeaveEvent(dev, EnterNotify, mode, NotifyAncestor, B, None);
+ }
+}
+
+static void
+CoreEnterLeaveEvents(DeviceIntPtr dev,
+ WindowPtr from,
+ WindowPtr to,
+ int mode)
+{
+ if (!IsMaster(dev))
+ return;
+
+ LeaveWindow(dev);
+
+ if (IsParent(from, to))
+ CoreEnterLeaveToDescendant(dev, from, to, mode);
+ else if (IsParent(to, from))
+ CoreEnterLeaveToAncestor(dev, from, to, mode);
+ else
+ CoreEnterLeaveNonLinear(dev, from, to, mode);
+
+ EnterWindow(dev, to, mode);
+}
+
+static void
+DeviceEnterLeaveEvents(DeviceIntPtr dev,
+ int sourceid,
+ WindowPtr from,
+ WindowPtr to,
+ int mode)
+{
+ if (IsParent(from, to))
+ {
+ DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, NotifyInferior, from, None);
+ DeviceEnterNotifies(dev, sourceid, from, to, mode, NotifyVirtual);
+ DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, NotifyAncestor, to, None);
+ }
+ else if (IsParent(to, from))
+ {
+ DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, NotifyAncestor, from, None);
+ DeviceLeaveNotifies(dev, sourceid, from, to, mode, NotifyVirtual);
+ DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, NotifyInferior, to, None);
+ }
+ else
+ { /* neither from nor to is descendent of the other */
+ WindowPtr common = CommonAncestor(to, from);
+ /* common == NullWindow ==> different screens */
+ DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, NotifyNonlinear, from, None);
+ DeviceLeaveNotifies(dev, sourceid, from, common, mode, NotifyNonlinearVirtual);
+ DeviceEnterNotifies(dev, sourceid, common, to, mode, NotifyNonlinearVirtual);
+ DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, NotifyNonlinear, to, None);
+ }
+}
+
+/**
+ * Figure out if enter/leave events are necessary and send them to the
+ * appropriate windows.
+ *
+ * @param fromWin Window the sprite moved out of.
+ * @param toWin Window the sprite moved into.
+ */
+void
+DoEnterLeaveEvents(DeviceIntPtr pDev,
+ int sourceid,
+ WindowPtr fromWin,
+ WindowPtr toWin,
+ int mode)
+{
+ if (!IsPointerDevice(pDev))
+ return;
+
+ if (fromWin == toWin)
+ return;
+
+ if (mode != XINotifyPassiveGrab && mode != XINotifyPassiveUngrab)
+ CoreEnterLeaveEvents(pDev, fromWin, toWin, mode);
+ DeviceEnterLeaveEvents(pDev, sourceid, fromWin, toWin, mode);
+}
+
+/**
+ * Send focus out events to all windows between 'child' and 'ancestor'.
+ * Events are sent running up the hierarchy.
+ */
+static void
+DeviceFocusOutEvents(DeviceIntPtr dev,
+ WindowPtr child,
+ WindowPtr ancestor,
+ int mode,
+ int detail)
+{
+ WindowPtr win;
+
+ if (ancestor == child)
+ return;
+ for (win = child->parent; win != ancestor; win = win->parent)
+ DeviceFocusEvent(dev, XI_FocusOut, mode, detail, win);
+}
+
+
+/**
+ * Send enter notifies to all windows between 'ancestor' and 'child' (excluding
+ * both). Events are sent running up the window hierarchy. This function
+ * recurses.
+ */
+static void
+DeviceFocusInEvents(DeviceIntPtr dev,
+ WindowPtr ancestor,
+ WindowPtr child,
+ int mode,
+ int detail)
+{
+ WindowPtr parent = child->parent;
+
+ if (ancestor == parent || !parent)
+ return;
+ DeviceFocusInEvents(dev, ancestor, parent, mode, detail);
+ DeviceFocusEvent(dev, XI_FocusIn, mode, detail, parent);
+}
+
+/**
+ * Send FocusIn events to all windows between 'ancestor' and 'child' (excluding
+ * both). Events are sent running down the window hierarchy. This function
+ * recurses.
+ */
+static void
+CoreFocusInEvents(DeviceIntPtr dev,
+ WindowPtr ancestor,
+ WindowPtr child,
+ int mode,
+ int detail)
+{
+ WindowPtr parent = child->parent;
+ if (ancestor == parent)
+ return;
+ CoreFocusInEvents(dev, ancestor, parent, mode, detail);
+
+
+ /* Case 3:
+ A is above W, B is a descendant
+
+ Classically: The move generates an FocusIn on W with a detail of
+ Virtual or NonlinearVirtual
+
+ MPX:
+ Case 3A: There is at least one other focus on W itself
+ F(W) doesn't change, so the event should be suppressed
+ Case 3B: Otherwise, if there is at least one other focus in a
+ descendant
+ F(W) stays on the same descendant, or changes to a different
+ descendant. The event should be suppressed.
+ Case 3C: Otherwise:
+ F(W) moves from a window above W to a descendant. The detail may
+ need to be changed from Virtual to NonlinearVirtual depending
+ on the previous F(W). */
+
+ if (!HasFocus(parent) && !FirstFocusChild(parent))
+ CoreFocusEvent(dev, FocusIn, mode, detail, parent);
+}
+
+static void
+CoreFocusOutEvents(DeviceIntPtr dev,
+ WindowPtr child,
+ WindowPtr ancestor,
+ int mode,
+ int detail)
+{
+ WindowPtr win;
+
+ if (ancestor == child)
+ return;
+
+ for (win = child->parent; win != ancestor; win = win->parent)
+ {
+ /*Case 7:
+ A is a descendant of W, B is above W
+
+ Classically: A FocusOut is generated on W with a detail of Virtual
+ or NonlinearVirtual.
+
+ MPX:
+ Case 3A: There is at least one other focus on W itself
+ F(W) doesn't change, the event should be suppressed.
+ Case 3B: Otherwise, if there is at least one other focus in a
+ descendant
+ F(W) stays on the same descendant, or changes to a different
+ descendant. The event should be suppressed.
+ Case 3C: Otherwise:
+ F(W) changes from the descendant of W to a window above W.
+ The detail may need to be changed from Virtual to NonlinearVirtual
+ or vice-versa depending on the new P(W).*/
+
+ /* If one window has a focus or a child with a focuspointer, skip some
+ * work and exit. */
+ if (HasFocus(win) || FirstFocusChild(win))
+ return;
+
+ CoreFocusEvent(dev, FocusOut, mode, detail, win);
+ }
+}
+
+/**
+ * Send FocusOut(NotifyPointer) events from the current pointer window (which
+ * is a descendant of pwin_parent) up to (excluding) pwin_parent.
+ *
+ * NotifyPointer events are only sent for the device paired with dev.
+ *
+ * If the current pointer window is a descendant of 'exclude' or an ancestor of
+ * 'exclude', no events are sent. If the current pointer IS 'exclude', events
+ * are sent!
+ */
+static void
+CoreFocusOutNotifyPointerEvents(DeviceIntPtr dev,
+ WindowPtr pwin_parent,
+ WindowPtr exclude,
+ int mode,
+ int inclusive)
+{
+ WindowPtr P, stopAt;
+
+ P = PointerWin(GetPairedDevice(dev));
+
+ if (!P)
+ return;
+ if (!IsParent(pwin_parent, P))
+ if (!(pwin_parent == P && inclusive))
+ return;
+
+ if (exclude != None && exclude != PointerRootWin &&
+ (IsParent(exclude, P) || IsParent(P, exclude)))
+ return;
+
+ stopAt = (inclusive) ? pwin_parent->parent : pwin_parent;
+
+ for (; P && P != stopAt; P = P->parent)
+ CoreFocusEvent(dev, FocusOut, mode, NotifyPointer, P);
+}
+
+/**
+ * DO NOT CALL DIRECTLY.
+ * Recursion helper for CoreFocusInNotifyPointerEvents.
+ */
+static void
+CoreFocusInRecurse(DeviceIntPtr dev,
+ WindowPtr win,
+ WindowPtr stopAt,
+ int mode,
+ int inclusive)
+{
+ if ((!inclusive && win == stopAt) || !win)
+ return;
+
+ CoreFocusInRecurse(dev, win->parent, stopAt, mode, inclusive);
+ CoreFocusEvent(dev, FocusIn, mode, NotifyPointer, win);
+}
+
+
+/**
+ * Send FocusIn(NotifyPointer) events from pwin_parent down to
+ * including the current pointer window (which is a descendant of pwin_parent).
+ *
+ * @param pwin The pointer window.
+ * @param exclude If the pointer window is a child of 'exclude', no events are
+ * sent.
+ * @param inclusive If TRUE, pwin_parent will receive the event too.
+ */
+static void
+CoreFocusInNotifyPointerEvents(DeviceIntPtr dev,
+ WindowPtr pwin_parent,
+ WindowPtr exclude,
+ int mode,
+ int inclusive)
+{
+ WindowPtr P;
+
+ P = PointerWin(GetPairedDevice(dev));
+
+ if (!P || P == exclude || (pwin_parent != P && !IsParent(pwin_parent, P)))
+ return;
+
+ if (exclude != None && (IsParent(exclude, P) || IsParent(P, exclude)))
+ return;
+
+ CoreFocusInRecurse(dev, P, pwin_parent, mode, inclusive);
+}
+
+
+/**
+ * Focus of dev moves from A to B and A neither a descendant of B nor is
+ * B a descendant of A.
+ */
+static void
+CoreFocusNonLinear(DeviceIntPtr dev,
+ WindowPtr A,
+ WindowPtr B,
+ int mode)
+{
+ WindowPtr X = CommonAncestor(A, B);
+
+ /* Case 4:
+ A is W, B is above W
+
+ Classically: The change generates a FocusOut on W with a detail of
+ Ancestor or Nonlinear
+
+ MPX:
+ Case 3A: There is at least one other focus on W itself
+ F(W) doesn't change, the event should be suppressed
+ Case 3B: Otherwise, if there is at least one other focus in a
+ descendant of W
+ F(W) changes from W to a descendant of W. The detail field
+ is set to Inferior
+ Case 3C: Otherwise:
+ The focus window moves from W to a window above W.
+ The detail may need to be changed from Ancestor to Nonlinear or
+ vice versa depending on the the new F(W)
+ */
+
+ if (!HasFocus(A))
+ {
+ WindowPtr child = FirstFocusChild(A);
+ if (child)
+ {
+ /* NotifyPointer P-A unless P is child or below*/
+ CoreFocusOutNotifyPointerEvents(dev, A, child, mode, FALSE);
+ CoreFocusEvent(dev, FocusOut, mode, NotifyInferior, A);
+ } else
+ {
+ /* NotifyPointer P-A */
+ CoreFocusOutNotifyPointerEvents(dev, A, None, mode, FALSE);
+ CoreFocusEvent(dev, FocusOut, mode, NotifyNonlinear, A);
+ }
+ }
+
+
+ CoreFocusOutEvents(dev, A, X, mode, NotifyNonlinearVirtual);
+
+ /*
+ Case 9:
+ A is a descendant of W, B is a descendant of W
+
+ Classically: No events are generated on W
+ MPX: The focus window stays the same or moves to a different
+ descendant of W. No events should be generated on W.
+
+
+ Therefore, no event to X.
+ */
+
+ CoreFocusInEvents(dev, X, B, mode, NotifyNonlinearVirtual);
+
+ /* Case 2:
+ A is above W, B=W
+
+ Classically: The move generates an EnterNotify on W with a detail of
+ Ancestor or Nonlinear
+
+ MPX:
+ Case 2A: There is at least one other focus on W itself
+ F(W) doesn't change, so the event should be suppressed
+ Case 2B: Otherwise, if there is at least one other focus in a
+ descendant
+ F(W) moves from a descendant to W. detail is changed to Inferior.
+ Case 2C: Otherwise:
+ F(W) changes from a window above W to W itself.
+ The detail may need to be changed from Ancestor to Nonlinear
+ or vice-versa depending on the previous F(W). */
+
+ if (!HasFocus(B))
+ {
+ WindowPtr child = FirstFocusChild(B);
+ if (child)
+ {
+ CoreFocusEvent(dev, FocusIn, mode, NotifyInferior, B);
+ /* NotifyPointer B-P unless P is child or below. */
+ CoreFocusInNotifyPointerEvents(dev, B, child, mode, FALSE);
+ } else {
+ CoreFocusEvent(dev, FocusIn, mode, NotifyNonlinear, B);
+ /* NotifyPointer B-P unless P is child or below. */
+ CoreFocusInNotifyPointerEvents(dev, B, None, mode, FALSE);
+ }
+ }
+}
+
+
+/**
+ * Focus of dev moves from A to B and A is a descendant of B.
+ */
+static void
+CoreFocusToAncestor(DeviceIntPtr dev,
+ WindowPtr A,
+ WindowPtr B,
+ int mode)
+{
+ /* Case 4:
+ A is W, B is above W
+
+ Classically: The change generates a FocusOut on W with a detail of
+ Ancestor or Nonlinear
+
+ MPX:
+ Case 3A: There is at least one other focus on W itself
+ F(W) doesn't change, the event should be suppressed
+ Case 3B: Otherwise, if there is at least one other focus in a
+ descendant of W
+ F(W) changes from W to a descendant of W. The detail field
+ is set to Inferior
+ Case 3C: Otherwise:
+ The focus window moves from W to a window above W.
+ The detail may need to be changed from Ancestor to Nonlinear or
+ vice versa depending on the the new F(W)
+ */
+ if (!HasFocus(A))
+ {
+ WindowPtr child = FirstFocusChild(A);
+ if (child)
+ {
+ /* NotifyPointer P-A unless P is child or below*/
+ CoreFocusOutNotifyPointerEvents(dev, A, child, mode, FALSE);
+ CoreFocusEvent(dev, FocusOut, mode, NotifyInferior, A);
+ } else
+ CoreFocusEvent(dev, FocusOut, mode, NotifyAncestor, A);
+ }
+
+ CoreFocusOutEvents(dev, A, B, mode, NotifyVirtual);
+
+ /* Case 8:
+ A is a descendant of W, B is W
+
+ Classically: A FocusOut is generated on W with a detail of
+ NotifyInferior
+
+ MPX:
+ Case 3A: There is at least one other focus on W itself
+ F(W) doesn't change, the event should be suppressed
+ Case 3B: Otherwise:
+ F(W) changes from a descendant to W itself. */
+
+ if (!HasFocus(B))
+ {
+ CoreFocusEvent(dev, FocusIn, mode, NotifyInferior, B);
+ /* NotifyPointer B-P unless P is A or below. */
+ CoreFocusInNotifyPointerEvents(dev, B, A, mode, FALSE);
+ }
+}
+
+/**
+ * Focus of dev moves from A to B and B is a descendant of A.
+ */
+static void
+CoreFocusToDescendant(DeviceIntPtr dev,
+ WindowPtr A,
+ WindowPtr B,
+ int mode)
+{
+ /* Case 6:
+ A is W, B is a descendant of W
+
+ Classically: A FocusOut is generated on W with a detail of
+ NotifyInferior
+
+ MPX:
+ Case 3A: There is at least one other focus on W itself
+ F(W) doesn't change, the event should be suppressed
+ Case 3B: Otherwise:
+ F(W) changes from W to a descendant of W. */
+
+ if (!HasFocus(A))
+ {
+ /* NotifyPointer P-A unless P is B or below*/
+ CoreFocusOutNotifyPointerEvents(dev, A, B, mode, FALSE);
+ CoreFocusEvent(dev, FocusOut, mode, NotifyInferior, A);
+ }
+
+
+ CoreFocusInEvents(dev, A, B, mode, NotifyVirtual);
+
+ /* Case 2:
+ A is above W, B=W
+
+ Classically: The move generates an FocusIn on W with a detail of
+ Ancestor or Nonlinear
+
+ MPX:
+ Case 2A: There is at least one other focus on W itself
+ F(W) doesn't change, so the event should be suppressed
+ Case 2B: Otherwise, if there is at least one other focus in a
+ descendant
+ F(W) moves from a descendant to W. detail is changed to Inferior.
+ Case 2C: Otherwise:
+ F(W) changes from a window above W to W itself.
+ The detail may need to be changed from Ancestor to Nonlinear
+ or vice-versa depending on the previous F(W). */
+
+ if (!HasFocus(B))
+ {
+ WindowPtr child = FirstFocusChild(B);
+ if (child)
+ {
+ CoreFocusEvent(dev, FocusIn, mode, NotifyInferior, B);
+ /* NotifyPointer B-P unless P is child or below. */
+ CoreFocusInNotifyPointerEvents(dev, B, child, mode, FALSE);
+ } else
+ CoreFocusEvent(dev, FocusIn, mode, NotifyAncestor, B);
+ }
+}
+
+static BOOL
+HasOtherPointer(WindowPtr win, DeviceIntPtr exclude)
+{
+ int i;
+
+ for (i = 0; i < MAXDEVICES; i++)
+ if (i != exclude->id && PointerWindows[i] == win)
+ return TRUE;
+
+ return FALSE;
+}
+
+/**
+ * Focus moves from PointerRoot to None or from None to PointerRoot.
+ * Assumption: Neither A nor B are valid windows.
+ */
+static void
+CoreFocusPointerRootNoneSwitch(DeviceIntPtr dev,
+ WindowPtr A, /* PointerRootWin or NoneWin */
+ WindowPtr B, /* NoneWin or PointerRootWin */
+ int mode)
+{
+ WindowPtr root;
+ int i;
+ int nscreens = screenInfo.numScreens;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension)
+ nscreens = 1;
+#endif
+
+ for (i = 0; i < nscreens; i++)
+ {
+ root = screenInfo.screens[i]->root;
+ if (!HasOtherPointer(root, GetPairedDevice(dev)) && !FirstFocusChild(root))
+ {
+ /* If pointer was on PointerRootWin and changes to NoneWin, and
+ * the pointer paired with dev is below the current root window,
+ * do a NotifyPointer run. */
+ if (dev->focus && dev->focus->win == PointerRootWin &&
+ B != PointerRootWin)
+ {
+ WindowPtr ptrwin = PointerWin(GetPairedDevice(dev));
+ if (ptrwin && IsParent(root, ptrwin))
+ CoreFocusOutNotifyPointerEvents(dev, root, None, mode, TRUE);
+ }
+ CoreFocusEvent(dev, FocusOut, mode, A ? NotifyPointerRoot : NotifyDetailNone, root);
+ CoreFocusEvent(dev, FocusIn, mode, B ? NotifyPointerRoot : NotifyDetailNone, root);
+ if (B == PointerRootWin)
+ CoreFocusInNotifyPointerEvents(dev, root, None, mode, TRUE);
+ }
+
+ }
+}
+
+/**
+ * Focus moves from window A to PointerRoot or to None.
+ * Assumption: A is a valid window and not PointerRoot or None.
+ */
+static void
+CoreFocusToPointerRootOrNone(DeviceIntPtr dev,
+ WindowPtr A,
+ WindowPtr B, /* PointerRootWin or NoneWin */
+ int mode)
+{
+ WindowPtr root;
+ int i;
+ int nscreens = screenInfo.numScreens;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension)
+ nscreens = 1;
+#endif
+
+ if (!HasFocus(A))
+ {
+ WindowPtr child = FirstFocusChild(A);
+ if (child)
+ {
+ /* NotifyPointer P-A unless P is B or below*/
+ CoreFocusOutNotifyPointerEvents(dev, A, B, mode, FALSE);
+ CoreFocusEvent(dev, FocusOut, mode, NotifyInferior, A);
+ } else {
+ /* NotifyPointer P-A */
+ CoreFocusOutNotifyPointerEvents(dev, A, None, mode, FALSE);
+ CoreFocusEvent(dev, FocusOut, mode, NotifyNonlinear, A);
+ }
+ }
+
+ /* NullWindow means we include the root window */
+ CoreFocusOutEvents(dev, A, NullWindow, mode, NotifyNonlinearVirtual);
+
+ for (i = 0; i < nscreens; i++)
+ {
+ root = screenInfo.screens[i]->root;
+ if (!HasFocus(root) && !FirstFocusChild(root))
+ {
+ CoreFocusEvent(dev, FocusIn, mode, B ? NotifyPointerRoot : NotifyDetailNone, root);
+ if (B == PointerRootWin)
+ CoreFocusInNotifyPointerEvents(dev, root, None, mode, TRUE);
+ }
+ }
+}
+
+/**
+ * Focus moves from PointerRoot or None to a window B.
+ * Assumption: B is a valid window and not PointerRoot or None.
+ */
+static void
+CoreFocusFromPointerRootOrNone(DeviceIntPtr dev,
+ WindowPtr A, /* PointerRootWin or NoneWin */
+ WindowPtr B,
+ int mode)
+{
+ WindowPtr root;
+ int i;
+ int nscreens = screenInfo.numScreens;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension)
+ nscreens = 1;
+#endif
+
+ for (i = 0; i < nscreens; i++)
+ {
+ root = screenInfo.screens[i]->root;
+ if (!HasFocus(root) && !FirstFocusChild(root))
+ {
+ /* If pointer was on PointerRootWin and changes to NoneWin, and
+ * the pointer paired with dev is below the current root window,
+ * do a NotifyPointer run. */
+ if (dev->focus && dev->focus->win == PointerRootWin &&
+ B != PointerRootWin)
+ {
+ WindowPtr ptrwin = PointerWin(GetPairedDevice(dev));
+ if (ptrwin)
+ CoreFocusOutNotifyPointerEvents(dev, root, None, mode, TRUE);
+ }
+ CoreFocusEvent(dev, FocusOut, mode, A ? NotifyPointerRoot : NotifyDetailNone, root);
+ }
+ }
+
+ root = B; /* get B's root window */
+ while(root->parent)
+ root = root->parent;
+
+ if (B != root)
+ {
+ CoreFocusEvent(dev, FocusIn, mode, NotifyNonlinearVirtual, root);
+ CoreFocusInEvents(dev, root, B, mode, NotifyNonlinearVirtual);
+ }
+
+
+ if (!HasFocus(B))
+ {
+ WindowPtr child = FirstFocusChild(B);
+ if (child)
+ {
+ CoreFocusEvent(dev, FocusIn, mode, NotifyInferior, B);
+ /* NotifyPointer B-P unless P is child or below. */
+ CoreFocusInNotifyPointerEvents(dev, B, child, mode, FALSE);
+ } else {
+ CoreFocusEvent(dev, FocusIn, mode, NotifyNonlinear, B);
+ /* NotifyPointer B-P unless P is child or below. */
+ CoreFocusInNotifyPointerEvents(dev, B, None, mode, FALSE);
+ }
+ }
+
+}
+
+static void
+CoreFocusEvents(DeviceIntPtr dev,
+ WindowPtr from,
+ WindowPtr to,
+ int mode)
+{
+ if (!IsMaster(dev))
+ return;
+
+ SetFocusOut(dev);
+
+ if (((to == NullWindow) || (to == PointerRootWin)) &&
+ ((from == NullWindow) || (from == PointerRootWin)))
+ CoreFocusPointerRootNoneSwitch(dev, from, to, mode);
+ else if ((to == NullWindow) || (to == PointerRootWin))
+ CoreFocusToPointerRootOrNone(dev, from, to, mode);
+ else if ((from == NullWindow) || (from == PointerRootWin))
+ CoreFocusFromPointerRootOrNone(dev, from, to, mode);
+ else if (IsParent(from, to))
+ CoreFocusToDescendant(dev, from, to, mode);
+ else if (IsParent(to, from))
+ CoreFocusToAncestor(dev, from, to, mode);
+ else
+ CoreFocusNonLinear(dev, from, to, mode);
+
+ SetFocusIn(dev, to);
+}
+
+/**
+ * The root window the given device is currently on.
+ */
+#define RootWindow(dev) dev->spriteInfo->sprite->spriteTrace[0]
+
+static void
+DeviceFocusEvents(DeviceIntPtr dev,
+ WindowPtr from,
+ WindowPtr to,
+ int mode)
+{
+ int out, in; /* for holding details for to/from
+ PointerRoot/None */
+ int i;
+ int nscreens = screenInfo.numScreens;
+ SpritePtr sprite = dev->spriteInfo->sprite;
+
+ if (from == to)
+ return;
+ out = (from == NoneWin) ? NotifyDetailNone : NotifyPointerRoot;
+ in = (to == NoneWin) ? NotifyDetailNone : NotifyPointerRoot;
+ /* wrong values if neither, but then not referenced */
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension)
+ nscreens = 1;
+#endif
+
+ if ((to == NullWindow) || (to == PointerRootWin))
+ {
+ if ((from == NullWindow) || (from == PointerRootWin))
+ {
+ if (from == PointerRootWin)
+ DeviceFocusOutEvents(dev, sprite->win, RootWindow(dev), mode,
+ NotifyPointer);
+ /* Notify all the roots */
+ for (i = 0; i < nscreens; i++)
+ DeviceFocusEvent(dev, XI_FocusOut, mode, out, screenInfo.screens[i]->root);
+ }
+ else
+ {
+ if (IsParent(from, sprite->win))
+ DeviceFocusOutEvents(dev, sprite->win, from, mode,
+ NotifyPointer);
+ DeviceFocusEvent(dev, XI_FocusOut, mode, NotifyNonlinear, from);
+ /* next call catches the root too, if the screen changed */
+ DeviceFocusOutEvents(dev, from->parent, NullWindow, mode,
+ NotifyNonlinearVirtual);
+ }
+ /* Notify all the roots */
+ for (i = 0; i < nscreens; i++)
+ DeviceFocusEvent(dev, XI_FocusIn, mode, in, screenInfo.screens[i]->root);
+ if (to == PointerRootWin)
+ DeviceFocusInEvents(dev, RootWindow(dev), sprite->win, mode, NotifyPointer);
+ }
+ else
+ {
+ if ((from == NullWindow) || (from == PointerRootWin))
+ {
+ if (from == PointerRootWin)
+ DeviceFocusOutEvents(dev, sprite->win, RootWindow(dev), mode,
+ NotifyPointer);
+ for (i = 0; i < nscreens; i++)
+ DeviceFocusEvent(dev, XI_FocusOut, mode, out, screenInfo.screens[i]->root);
+ if (to->parent != NullWindow)
+ DeviceFocusInEvents(dev, RootWindow(dev), to, mode, NotifyNonlinearVirtual);
+ DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyNonlinear, to);
+ if (IsParent(to, sprite->win))
+ DeviceFocusInEvents(dev, to, sprite->win, mode, NotifyPointer);
+ }
+ else
+ {
+ if (IsParent(to, from))
+ {
+ DeviceFocusEvent(dev, XI_FocusOut, mode, NotifyAncestor, from);
+ DeviceFocusOutEvents(dev, from->parent, to, mode,
+ NotifyVirtual);
+ DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyInferior, to);
+ if ((IsParent(to, sprite->win)) &&
+ (sprite->win != from) &&
+ (!IsParent(from, sprite->win)) &&
+ (!IsParent(sprite->win, from)))
+ DeviceFocusInEvents(dev, to, sprite->win, mode, NotifyPointer);
+ }
+ else
+ if (IsParent(from, to))
+ {
+ if ((IsParent(from, sprite->win)) &&
+ (sprite->win != from) &&
+ (!IsParent(to, sprite->win)) &&
+ (!IsParent(sprite->win, to)))
+ DeviceFocusOutEvents(dev, sprite->win, from, mode,
+ NotifyPointer);
+ DeviceFocusEvent(dev, XI_FocusOut, mode, NotifyInferior, from);
+ DeviceFocusInEvents(dev, from, to, mode, NotifyVirtual);
+ DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyAncestor, to);
+ }
+ else
+ {
+ /* neither from or to is child of other */
+ WindowPtr common = CommonAncestor(to, from);
+ /* common == NullWindow ==> different screens */
+ if (IsParent(from, sprite->win))
+ DeviceFocusOutEvents(dev, sprite->win, from, mode,
+ NotifyPointer);
+ DeviceFocusEvent(dev, XI_FocusOut, mode, NotifyNonlinear, from);
+ if (from->parent != NullWindow)
+ DeviceFocusOutEvents(dev, from->parent, common, mode,
+ NotifyNonlinearVirtual);
+ if (to->parent != NullWindow)
+ DeviceFocusInEvents(dev, common, to, mode, NotifyNonlinearVirtual);
+ DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyNonlinear, to);
+ if (IsParent(to, sprite->win))
+ DeviceFocusInEvents(dev, to, sprite->win, mode, NotifyPointer);
+ }
+ }
+ }
+}
+
+/**
+ * Figure out if focus events are necessary and send them to the
+ * appropriate windows.
+ *
+ * @param from Window the focus moved out of.
+ * @param to Window the focus moved into.
+ */
+void
+DoFocusEvents(DeviceIntPtr pDev,
+ WindowPtr from,
+ WindowPtr to,
+ int mode)
+{
+ if (!IsKeyboardDevice(pDev))
+ return;
+
+ if (from == to)
+ return;
+
+ CoreFocusEvents(pDev, from, to, mode);
+ DeviceFocusEvents(pDev, from, to, mode);
+}
diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c index d156cf3ed..91966c4a8 100644 --- a/xorg-server/dix/events.c +++ b/xorg-server/dix/events.c @@ -331,7 +331,7 @@ IsKeyboardDevice(DeviceIntPtr dev) Bool
IsMaster(DeviceIntPtr dev)
{
- return (dev->type == MASTER_POINTER || dev->type == MASTER_KEYBOARD);
+ return dev->type == MASTER_POINTER || dev->type == MASTER_KEYBOARD;
}
static WindowPtr XYToWindow(
@@ -486,6 +486,13 @@ SyntheticMotion(DeviceIntPtr dev, int x, int y) { static void PostNewCursor(DeviceIntPtr pDev);
static Bool
+pointOnScreen(ScreenPtr pScreen, int x, int y)
+{
+ return x >= pScreen->x && x < pScreen->x + pScreen->width &&
+ y >= pScreen->y && y < pScreen->y + pScreen->height;
+}
+
+static Bool
XineramaSetCursorPosition(
DeviceIntPtr pDev,
int x,
@@ -493,7 +500,6 @@ XineramaSetCursorPosition( Bool generateEvent
){
ScreenPtr pScreen;
- BoxRec box;
int i;
SpritePtr pSprite = pDev->spriteInfo->sprite;
@@ -502,17 +508,16 @@ XineramaSetCursorPosition( that screen are. */
pScreen = pSprite->screen;
- x += panoramiXdataPtr[0].x;
- y += panoramiXdataPtr[0].y;
+ x += screenInfo.screens[0]->x;
+ y += screenInfo.screens[0]->y;
- if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
- x, y, &box))
+ if(!pointOnScreen(pScreen, x, y))
{
FOR_NSCREENS(i)
{
if(i == pScreen->myNum)
continue;
- if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i], x, y, &box))
+ if(pointOnScreen(screenInfo.screens[i], x, y))
{
pScreen = screenInfo.screens[i];
break;
@@ -521,10 +526,10 @@ XineramaSetCursorPosition( }
pSprite->screen = pScreen;
- pSprite->hotPhys.x = x - panoramiXdataPtr[0].x;
- pSprite->hotPhys.y = y - panoramiXdataPtr[0].y;
- x -= panoramiXdataPtr[pScreen->myNum].x;
- y -= panoramiXdataPtr[pScreen->myNum].y;
+ pSprite->hotPhys.x = x - screenInfo.screens[0]->x;
+ pSprite->hotPhys.y = y - screenInfo.screens[0]->y;
+ x -= pScreen->x;
+ y -= pScreen->y;
return (*pScreen->SetCursorPosition)(pDev, pScreen, x, y, generateEvent);
}
@@ -542,10 +547,10 @@ XineramaConstrainCursor(DeviceIntPtr pDev) /* Translate the constraining box to the screen
the sprite is actually on */
- newBox.x1 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x;
- newBox.x2 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x;
- newBox.y1 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
- newBox.y2 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
+ newBox.x1 += screenInfo.screens[0]->x - pScreen->x;
+ newBox.x2 += screenInfo.screens[0]->x - pScreen->x;
+ newBox.y1 += screenInfo.screens[0]->y - pScreen->y;
+ newBox.y2 += screenInfo.screens[0]->y - pScreen->y;
(* pScreen->ConstrainCursor)(pDev, pScreen, &newBox);
}
@@ -556,9 +561,10 @@ XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin) {
SpritePtr pSprite = pDev->spriteInfo->sprite;
- if(pWin == WindowTable[0]) {
- memcpy(pSprite->windows, WindowTable,
- PanoramiXNumScreens*sizeof(WindowPtr));
+ if(pWin == screenInfo.screens[0]->root) {
+ int i;
+ for (i = 0; i < PanoramiXNumScreens; i++)
+ pSprite->windows[i] = screenInfo.screens[i]->root;
} else {
PanoramiXRes *win;
int rc, i;
@@ -592,34 +598,34 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev, i = PanoramiXNumScreens - 1;
- REGION_COPY(pSprite->screen, &pSprite->Reg1,
+ RegionCopy(&pSprite->Reg1,
&pSprite->windows[i]->borderSize);
- off_x = panoramiXdataPtr[i].x;
- off_y = panoramiXdataPtr[i].y;
+ off_x = screenInfo.screens[i]->x;
+ off_y = screenInfo.screens[i]->y;
while(i--) {
- x = off_x - panoramiXdataPtr[i].x;
- y = off_y - panoramiXdataPtr[i].y;
+ x = off_x - screenInfo.screens[i]->x;
+ y = off_y - screenInfo.screens[i]->y;
if(x || y)
- REGION_TRANSLATE(pSprite->screen, &pSprite->Reg1, x, y);
+ RegionTranslate(&pSprite->Reg1, x, y);
- REGION_UNION(pSprite->screen, &pSprite->Reg1, &pSprite->Reg1,
+ RegionUnion(&pSprite->Reg1, &pSprite->Reg1,
&pSprite->windows[i]->borderSize);
- off_x = panoramiXdataPtr[i].x;
- off_y = panoramiXdataPtr[i].y;
+ off_x = screenInfo.screens[i]->x;
+ off_y = screenInfo.screens[i]->y;
}
- pSprite->hotLimits = *REGION_EXTENTS(pSprite->screen, &pSprite->Reg1);
+ pSprite->hotLimits = *RegionExtents(&pSprite->Reg1);
- if(REGION_NUM_RECTS(&pSprite->Reg1) > 1)
+ if(RegionNumRects(&pSprite->Reg1) > 1)
pSprite->hotShape = &pSprite->Reg1;
else
pSprite->hotShape = NullRegion;
pSprite->confined = FALSE;
- pSprite->confineWin = (pWin == WindowTable[0]) ? NullWindow : pWin;
+ pSprite->confineWin = (pWin == screenInfo.screens[0]->root) ? NullWindow : pWin;
CheckPhysLimits(pDev, pSprite->current, generateEvents, FALSE, NULL);
}
@@ -665,9 +671,9 @@ ConfineToShape(DeviceIntPtr pDev, RegionPtr shape, int *px, int *py) SpritePtr pSprite;
pSprite = pDev->spriteInfo->sprite;
- if (POINT_IN_REGION(pSprite->hot.pScreen, shape, x, y, &box))
+ if (RegionContainsPoint(shape, x, y, &box))
return;
- box = *REGION_EXTENTS(pSprite->hot.pScreen, shape);
+ box = *RegionExtents(shape);
/* this is rather crude */
do {
x += incx;
@@ -689,7 +695,7 @@ ConfineToShape(DeviceIntPtr pDev, RegionPtr shape, int *px, int *py) else if (y < box.y1)
return; /* should never get here! */
}
- } while (!POINT_IN_REGION(pSprite->hot.pScreen, shape, x, y, &box));
+ } while (!RegionContainsPoint(shape, x, y, &box));
*px = x;
*py = y;
}
@@ -814,23 +820,23 @@ CheckVirtualMotion( i = PanoramiXNumScreens - 1;
- REGION_COPY(pSprite->screen, &pSprite->Reg2,
+ RegionCopy(&pSprite->Reg2,
&pSprite->windows[i]->borderSize);
- off_x = panoramiXdataPtr[i].x;
- off_y = panoramiXdataPtr[i].y;
+ off_x = screenInfo.screens[i]->x;
+ off_y = screenInfo.screens[i]->y;
while(i--) {
- x = off_x - panoramiXdataPtr[i].x;
- y = off_y - panoramiXdataPtr[i].y;
+ x = off_x - screenInfo.screens[i]->x;
+ y = off_y - screenInfo.screens[i]->y;
if(x || y)
- REGION_TRANSLATE(pSprite->screen, &pSprite->Reg2, x, y);
+ RegionTranslate(&pSprite->Reg2, x, y);
- REGION_UNION(pSprite->screen, &pSprite->Reg2, &pSprite->Reg2,
+ RegionUnion(&pSprite->Reg2, &pSprite->Reg2,
&pSprite->windows[i]->borderSize);
- off_x = panoramiXdataPtr[i].x;
- off_y = panoramiXdataPtr[i].y;
+ off_x = screenInfo.screens[i]->x;
+ off_y = screenInfo.screens[i]->y;
}
} else
#endif
@@ -842,7 +848,7 @@ CheckVirtualMotion( }
}
- lims = *REGION_EXTENTS(pWin->drawable.pScreen, &pWin->borderSize);
+ lims = *RegionExtents(&pWin->borderSize);
if (pSprite->hot.x < lims.x1)
pSprite->hot.x = lims.x1;
else if (pSprite->hot.x >= lims.x2)
@@ -855,7 +861,7 @@ CheckVirtualMotion( #ifdef PANORAMIX
if (!noPanoramiXExtension)
{
- if (REGION_NUM_RECTS(&pSprite->Reg2) > 1)
+ if (RegionNumRects(&pSprite->Reg2) > 1)
reg = &pSprite->Reg2;
} else
@@ -878,13 +884,12 @@ CheckVirtualMotion( #ifdef PANORAMIX
if (noPanoramiXExtension) /* No typo. Only set the root win if disabled */
#endif
- RootWindow(pDev) = WindowTable[pSprite->hot.pScreen->myNum];
+ RootWindow(pDev) = pSprite->hot.pScreen->root;
}
static void
ConfineCursorToWindow(DeviceIntPtr pDev, WindowPtr pWin, Bool generateEvents, Bool confineToScreen)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
SpritePtr pSprite = pDev->spriteInfo->sprite;
if (syncEvents.playingEvents)
@@ -900,11 +905,11 @@ ConfineCursorToWindow(DeviceIntPtr pDev, WindowPtr pWin, Bool generateEvents, Bo return;
}
#endif
- pSprite->hotLimits = *REGION_EXTENTS( pScreen, &pWin->borderSize);
+ pSprite->hotLimits = *RegionExtents(&pWin->borderSize);
pSprite->hotShape = wBoundingShape(pWin) ? &pWin->borderSize
: NullRegion;
CheckPhysLimits(pDev, pSprite->current, generateEvents,
- confineToScreen, pScreen);
+ confineToScreen, pWin->drawable.pScreen);
}
}
@@ -1126,7 +1131,7 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device) * updated yet.
*/
if (ev->any.type == ET_Motion)
- ev->device_event.root = WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id;
+ ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
eventinfo.event = ev;
eventinfo.device = device;
@@ -1137,10 +1142,8 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device) {
#ifdef PANORAMIX
if(!noPanoramiXExtension) {
- event->root_x += panoramiXdataPtr[pSprite->screen->myNum].x -
- panoramiXdataPtr[0].x;
- event->root_y += panoramiXdataPtr[pSprite->screen->myNum].y -
- panoramiXdataPtr[0].y;
+ event->root_x += pSprite->screen->x - screenInfo.screens[0]->x;
+ event->root_y += pSprite->screen->y - screenInfo.screens[0]->y;
}
#endif
pSprite->hotPhys.x = event->root_x;
@@ -1220,10 +1223,10 @@ PlayReleasedEvents(void) case ET_KeyRelease:
case ET_ProximityIn:
case ET_ProximityOut:
- ev->root_x += panoramiXdataPtr[0].x -
- panoramiXdataPtr[pDev->spriteInfo->sprite->screen->myNum].x;
- ev->root_y += panoramiXdataPtr[0].y -
- panoramiXdataPtr[pDev->spriteInfo->sprite->screen->myNum].y;
+ ev->root_x += screenInfo.screens[0]->x -
+ pDev->spriteInfo->sprite->screen->x;
+ ev->root_y += screenInfo.screens[0]->y -
+ pDev->spriteInfo->sprite->screen->y;
break;
default:
break;
@@ -1342,7 +1345,7 @@ playmore: }
else
ConfineCursorToWindow(dev,
- WindowTable[dev->spriteInfo->sprite->hotPhys.pScreen->myNum],
+ dev->spriteInfo->sprite->hotPhys.pScreen->root,
TRUE, FALSE);
PostNewCursor(dev);
}
@@ -1372,7 +1375,7 @@ ScreenRestructured (ScreenPtr pScreen) }
else
ConfineCursorToWindow(pDev,
- WindowTable[pDev->spriteInfo->sprite->hotPhys.pScreen->myNum],
+ pDev->spriteInfo->sprite->hotPhys.pScreen->root,
TRUE, FALSE);
}
}
@@ -2551,7 +2554,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y) {
BoxRec box;
- if(POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderSize, x, y, &box))
+ if(RegionContainsPoint(&pWin->borderSize, x, y, &box))
return TRUE;
#ifdef PANORAMIX
@@ -2561,11 +2564,10 @@ PointInBorderSize(WindowPtr pWin, int x, int y) int i;
for(i = 1; i < PanoramiXNumScreens; i++) {
- if(POINT_IN_REGION(pSprite->screen,
- &pSprite->windows[i]->borderSize,
- x + panoramiXdataPtr[0].x - panoramiXdataPtr[i].x,
- y + panoramiXdataPtr[0].y - panoramiXdataPtr[i].y,
- &box))
+ if(RegionContainsPoint(&pSprite->windows[i]->borderSize,
+ x + screenInfo.screens[0]->x - screenInfo.screens[i]->x,
+ y + screenInfo.screens[0]->y - screenInfo.screens[i]->y,
+ &box))
return TRUE;
}
}
@@ -2609,10 +2611,9 @@ XYToWindow(DeviceIntPtr pDev, int x, int y) */
&& (!wBoundingShape(pWin) || PointInBorderSize(pWin, x, y))
&& (!wInputShape(pWin) ||
- POINT_IN_REGION(pWin->drawable.pScreen,
- wInputShape(pWin),
- x - pWin->drawable.x,
- y - pWin->drawable.y, &box))
+ RegionContainsPoint(wInputShape(pWin),
+ x - pWin->drawable.x,
+ y - pWin->drawable.y, &box))
#ifdef ROOTLESS
/* In rootless mode windows may be offscreen, even when
* they're in X's stack. (E.g. if the native window system
@@ -2762,17 +2763,15 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev) /* Motion events entering DIX get translated to Screen 0
coordinates. Replayed events have already been
translated since they've entered DIX before */
- ev->root_x += panoramiXdataPtr[pSprite->screen->myNum].x -
- panoramiXdataPtr[0].x;
- ev->root_y += panoramiXdataPtr[pSprite->screen->myNum].y -
- panoramiXdataPtr[0].y;
+ ev->root_x += pSprite->screen->x - screenInfo.screens[0]->x;
+ ev->root_y += pSprite->screen->y - screenInfo.screens[0]->y;
} else
#endif
{
if (pSprite->hot.pScreen != pSprite->hotPhys.pScreen)
{
pSprite->hot.pScreen = pSprite->hotPhys.pScreen;
- RootWindow(pDev) = WindowTable[pSprite->hot.pScreen->myNum];
+ RootWindow(pDev) = pSprite->hot.pScreen->root;
}
}
@@ -2855,7 +2854,7 @@ WindowsRestructured(void) #ifdef PANORAMIX
/* This was added to support reconfiguration under Xdmx. The problem is
- * that if the 0th screen (i.e., WindowTable[0]) is moved to an origin
+ * that if the 0th screen (i.e., screenInfo.screens[0]) is moved to an origin
* other than 0,0, the information in the private sprite structure must
* be updated accordingly, or XYToWindow (and other routines) will not
* compute correctly. */
@@ -2884,10 +2883,10 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff) pSprite->hotLimits.x2 -= xoff;
pSprite->hotLimits.y2 -= yoff;
- if (REGION_NOTEMPTY(pSprite->screen, &pSprite->Reg1))
- REGION_TRANSLATE(pSprite->screen, &pSprite->Reg1, xoff, yoff);
- if (REGION_NOTEMPTY(pSprite->screen, &pSprite->Reg2))
- REGION_TRANSLATE(pSprite->screen, &pSprite->Reg2, xoff, yoff);
+ if (RegionNotEmpty(&pSprite->Reg1))
+ RegionTranslate(&pSprite->Reg1, xoff, yoff);
+ if (RegionNotEmpty(&pSprite->Reg2))
+ RegionTranslate(&pSprite->Reg2, xoff, yoff);
/* FIXME: if we call ConfineCursorToWindow, must we do anything else? */
if ((grab = pDev->deviceGrab.grab) && grab->confineTo) {
@@ -2898,7 +2897,7 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff) } else
ConfineCursorToWindow(
pDev,
- WindowTable[pSprite->hotPhys.pScreen->myNum],
+ pSprite->hotPhys.pScreen->root,
TRUE, FALSE);
}
@@ -3013,17 +3012,17 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin) }
#ifdef PANORAMIX
if(!noPanoramiXExtension) {
- pSprite->hotLimits.x1 = -panoramiXdataPtr[0].x;
- pSprite->hotLimits.y1 = -panoramiXdataPtr[0].y;
- pSprite->hotLimits.x2 = PanoramiXPixWidth - panoramiXdataPtr[0].x;
- pSprite->hotLimits.y2 = PanoramiXPixHeight - panoramiXdataPtr[0].y;
+ pSprite->hotLimits.x1 = -screenInfo.screens[0]->x;
+ pSprite->hotLimits.y1 = -screenInfo.screens[0]->y;
+ pSprite->hotLimits.x2 = PanoramiXPixWidth - screenInfo.screens[0]->x;
+ pSprite->hotLimits.y2 = PanoramiXPixHeight - screenInfo.screens[0]->y;
pSprite->physLimits = pSprite->hotLimits;
pSprite->confineWin = NullWindow;
pSprite->hotShape = NullRegion;
pSprite->screen = pScreen;
/* gotta UNINIT these someplace */
- REGION_NULL(pScreen, &pSprite->Reg1);
- REGION_NULL(pScreen, &pSprite->Reg2);
+ RegionNull(&pSprite->Reg1);
+ RegionNull(&pSprite->Reg2);
}
#endif
}
@@ -3057,7 +3056,7 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen) pSprite = pDev->spriteInfo->sprite;
- win = WindowTable[pScreen->myNum];
+ win = pScreen->root;
pSprite->hotPhys.pScreen = pScreen;
pSprite->hot = pSprite->hotPhys;
@@ -3083,10 +3082,10 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen) #ifdef PANORAMIX
if(!noPanoramiXExtension) {
- pSprite->hotLimits.x1 = -panoramiXdataPtr[0].x;
- pSprite->hotLimits.y1 = -panoramiXdataPtr[0].y;
- pSprite->hotLimits.x2 = PanoramiXPixWidth - panoramiXdataPtr[0].x;
- pSprite->hotLimits.y2 = PanoramiXPixHeight - panoramiXdataPtr[0].y;
+ pSprite->hotLimits.x1 = -screenInfo.screens[0]->x;
+ pSprite->hotLimits.y1 = -screenInfo.screens[0]->y;
+ pSprite->hotLimits.x2 = PanoramiXPixWidth - screenInfo.screens[0]->x;
+ pSprite->hotLimits.y2 = PanoramiXPixHeight - screenInfo.screens[0]->y;
pSprite->physLimits = pSprite->hotLimits;
pSprite->screen = pScreen;
}
@@ -3119,10 +3118,8 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y) pSprite->hotPhys.y = y;
#ifdef PANORAMIX
if(!noPanoramiXExtension) {
- pSprite->hotPhys.x += panoramiXdataPtr[newScreen->myNum].x -
- panoramiXdataPtr[0].x;
- pSprite->hotPhys.y += panoramiXdataPtr[newScreen->myNum].y -
- panoramiXdataPtr[0].y;
+ pSprite->hotPhys.x += newScreen->x - screenInfo.screens[0]->x;
+ pSprite->hotPhys.y += newScreen->y - screenInfo.screens[0]->y;
if (newScreen != pSprite->screen) {
pSprite->screen = newScreen;
/* Make sure we tell the DDX to update its copy of the screen */
@@ -3130,23 +3127,22 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y) XineramaConfineCursorToWindow(pDev,
pSprite->confineWin, TRUE);
else
- XineramaConfineCursorToWindow(pDev, WindowTable[0], TRUE);
+ XineramaConfineCursorToWindow(pDev, screenInfo.screens[0]->root, TRUE);
/* if the pointer wasn't confined, the DDX won't get
told of the pointer warp so we reposition it here */
if(!syncEvents.playingEvents)
(*pSprite->screen->SetCursorPosition)(
pDev,
pSprite->screen,
- pSprite->hotPhys.x + panoramiXdataPtr[0].x -
- panoramiXdataPtr[pSprite->screen->myNum].x,
- pSprite->hotPhys.y + panoramiXdataPtr[0].y -
- panoramiXdataPtr[pSprite->screen->myNum].y, FALSE);
+ pSprite->hotPhys.x + screenInfo.screens[0]->x -
+ pSprite->screen->x,
+ pSprite->hotPhys.y + screenInfo.screens[0]->y -
+ pSprite->screen->y, FALSE);
}
} else
#endif
- if (newScreen != pSprite->hotPhys.pScreen && WindowTable[newScreen->myNum])
- ConfineCursorToWindow(pDev, WindowTable[newScreen->myNum],
- TRUE, FALSE);
+ if (newScreen != pSprite->hotPhys.pScreen)
+ ConfineCursorToWindow(pDev, newScreen->root, TRUE, FALSE);
}
#ifdef PANORAMIX
@@ -3158,32 +3154,29 @@ XineramaPointInWindowIsVisible( int y
)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
BoxRec box;
int i, xoff, yoff;
if (!pWin->realized) return FALSE;
- if (POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box))
+ if (RegionContainsPoint(&pWin->borderClip, x, y, &box))
return TRUE;
if(!XineramaSetWindowPntrs(inputInfo.pointer, pWin)) return FALSE;
- xoff = x + panoramiXdataPtr[0].x;
- yoff = y + panoramiXdataPtr[0].y;
+ xoff = x + screenInfo.screens[0]->x;
+ yoff = y + screenInfo.screens[0]->y;
for(i = 1; i < PanoramiXNumScreens; i++) {
pWin = inputInfo.pointer->spriteInfo->sprite->windows[i];
- pScreen = pWin->drawable.pScreen;
- x = xoff - panoramiXdataPtr[i].x;
- y = yoff - panoramiXdataPtr[i].y;
+ x = xoff - screenInfo.screens[i]->x;
+ y = yoff - screenInfo.screens[i]->y;
- if(POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box)
+ if(RegionContainsPoint(&pWin->borderClip, x, y, &box)
&& (!wInputShape(pWin) ||
- POINT_IN_REGION(pWin->drawable.pScreen,
- wInputShape(pWin),
- x - pWin->drawable.x,
- y - pWin->drawable.y, &box)))
+ RegionContainsPoint(wInputShape(pWin),
+ x - pWin->drawable.x,
+ y - pWin->drawable.y, &box)))
return TRUE;
}
@@ -3221,9 +3214,9 @@ XineramaWarpPointer(ClientPtr client) winX = source->drawable.x;
winY = source->drawable.y;
- if(source == WindowTable[0]) {
- winX -= panoramiXdataPtr[0].x;
- winY -= panoramiXdataPtr[0].y;
+ if(source == screenInfo.screens[0]->root) {
+ winX -= screenInfo.screens[0]->x;
+ winY -= screenInfo.screens[0]->y;
}
if (x < winX + stuff->srcX ||
y < winY + stuff->srcY ||
@@ -3237,9 +3230,9 @@ XineramaWarpPointer(ClientPtr client) if (dest) {
x = dest->drawable.x;
y = dest->drawable.y;
- if(dest == WindowTable[0]) {
- x -= panoramiXdataPtr[0].x;
- y -= panoramiXdataPtr[0].y;
+ if(dest == screenInfo.screens[0]->root) {
+ x -= screenInfo.screens[0]->x;
+ y -= screenInfo.screens[0]->y;
}
}
@@ -3374,7 +3367,7 @@ ProcWarpPointer(ClientPtr client) static Bool
BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin)
{
- if(REGION_NOTEMPTY(pDev->spriteInfo->sprite->hotPhys.pScreen, &pWin->borderSize))
+ if(RegionNotEmpty(&pWin->borderSize))
return TRUE;
#ifdef PANORAMIX
@@ -3382,8 +3375,7 @@ BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin) int i;
for(i = 1; i < PanoramiXNumScreens; i++) {
- if(REGION_NOTEMPTY(pDev->spriteInfo->sprite->screen,
- &pDev->spriteInfo->sprite->windows[i]->borderSize))
+ if(RegionNotEmpty(&pDev->spriteInfo->sprite->windows[i]->borderSize))
return TRUE;
}
}
@@ -3807,10 +3799,8 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window) }
unwind:
- if (xE)
- free(xE);
- if (xi2)
- free(xi2);
+ free(xE);
+ free(xi2);
return;
}
@@ -3990,10 +3980,8 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev, }
}
- if (xi)
- free(xi);
- if (xi2)
- free(xi2);
+ free(xi);
+ free(xi2);
}
/* This function is used to set the key pressed or key released state -
@@ -4101,7 +4089,7 @@ OtherClientGone(pointer value, XID id) }
free(other);
RecalculateDeliverableEvents(pWin);
- return(Success);
+ return Success;
}
prev = other;
}
@@ -4324,7 +4312,7 @@ CoreEnterLeaveEvent( xKeymapEvent ke;
ClientPtr client = grab ? rClient(grab) : wClient(pWin);
if (XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess))
- bzero((char *)&ke.map[0], 31);
+ memset((char *)&ke.map[0], 0, 31);
else
memmove((char *)&ke.map[0], (char *)&keybd->key->down[1], 31);
@@ -4434,7 +4422,7 @@ CoreFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin) xKeymapEvent ke;
ClientPtr client = wClient(pWin);
if (XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess))
- bzero((char *)&ke.map[0], 31);
+ memset((char *)&ke.map[0], 0, 31);
else
memmove((char *)&ke.map[0], (char *)&dev->key->down[1], 31);
@@ -4506,7 +4494,7 @@ SetInputFocus( /* It is a match error to try to set the input focus to an
unviewable window. */
if(!focusWin->realized)
- return(BadMatch);
+ return BadMatch;
}
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixSetFocusAccess);
if (rc != Success)
@@ -5003,11 +4991,11 @@ ProcQueryPointer(ClientPtr client) #ifdef PANORAMIX
if(!noPanoramiXExtension) {
- rep.rootX += panoramiXdataPtr[0].x;
- rep.rootY += panoramiXdataPtr[0].y;
+ rep.rootX += screenInfo.screens[0]->x;
+ rep.rootY += screenInfo.screens[0]->y;
if(stuff->id == rep.root) {
- rep.winX += panoramiXdataPtr[0].x;
- rep.winY += panoramiXdataPtr[0].y;
+ rep.winX += screenInfo.screens[0]->x;
+ rep.winY += screenInfo.screens[0]->y;
}
}
#endif
@@ -5023,7 +5011,7 @@ ProcQueryPointer(ClientPtr client) WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep);
- return(Success);
+ return Success;
}
/**
@@ -5227,8 +5215,8 @@ ProcUngrabKey(ClientPtr client) tempGrab.next = NULL;
if (!DeletePassiveGrabFromList(&tempGrab))
- return(BadAlloc);
- return(Success);
+ return BadAlloc;
+ return Success;
}
/**
@@ -5422,8 +5410,8 @@ ProcUngrabButton(ClientPtr client) tempGrab.next = NULL;
if (!DeletePassiveGrabFromList(&tempGrab))
- return(BadAlloc);
- return(Success);
+ return BadAlloc;
+ return Success;
}
/**
@@ -5637,7 +5625,7 @@ ProcRecolorCursor(ClientPtr client) ( *pscr->RecolorCursor)(PickPointer(client), pscr, pCursor,
(pCursor == pSprite->current) && displayed);
}
- return (Success);
+ return Success;
}
/**
@@ -5676,7 +5664,7 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) #ifdef PANORAMIX
if(!noPanoramiXExtension &&
- (panoramiXdataPtr[0].x || panoramiXdataPtr[0].y))
+ (screenInfo.screens[0]->x || screenInfo.screens[0]->y))
{
switch(events->u.u.type) {
case MotionNotify:
@@ -5693,13 +5681,13 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) */
count = 1; /* should always be 1 */
memcpy(&eventCopy, events, sizeof(xEvent));
- eventCopy.u.keyButtonPointer.rootX += panoramiXdataPtr[0].x;
- eventCopy.u.keyButtonPointer.rootY += panoramiXdataPtr[0].y;
+ eventCopy.u.keyButtonPointer.rootX += screenInfo.screens[0]->x;
+ eventCopy.u.keyButtonPointer.rootY += screenInfo.screens[0]->y;
if(eventCopy.u.keyButtonPointer.event ==
eventCopy.u.keyButtonPointer.root)
{
- eventCopy.u.keyButtonPointer.eventX += panoramiXdataPtr[0].x;
- eventCopy.u.keyButtonPointer.eventY += panoramiXdataPtr[0].y;
+ eventCopy.u.keyButtonPointer.eventX += screenInfo.screens[0]->x;
+ eventCopy.u.keyButtonPointer.eventY += screenInfo.screens[0]->y;
}
events = &eventCopy;
break;
diff --git a/xorg-server/dix/extension.c b/xorg-server/dix/extension.c index 57aef003f..f6b33d64c 100644 --- a/xorg-server/dix/extension.c +++ b/xorg-server/dix/extension.c @@ -89,15 +89,19 @@ AddExtension(char *name, int NumEvents, int NumErrors, return((ExtensionEntry *) NULL);
}
- ext = malloc(sizeof(ExtensionEntry));
+ ext = calloc(sizeof (ExtensionEntry), 1);
if (!ext)
- return(NULL);
+ return NULL;
+ if (!dixAllocatePrivates(&ext->devPrivates, PRIVATE_EXTENSION)) {
+ free(ext);
+ return NULL;
+ }
ext->name = malloc(strlen(name) + 1);
ext->num_aliases = 0;
ext->aliases = (char **)NULL;
- ext->devPrivates = NULL;
if (!ext->name)
{
+ dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
free(ext);
return((ExtensionEntry *) NULL);
}
@@ -108,6 +112,7 @@ AddExtension(char *name, int NumEvents, int NumErrors, if (!newexts)
{
free(ext->name);
+ dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
free(ext);
return((ExtensionEntry *) NULL);
}
@@ -144,7 +149,7 @@ AddExtension(char *name, int NumEvents, int NumErrors, }
RegisterExtensionNames(ext);
- return(ext);
+ return ext;
}
Bool AddExtensionAlias(char *alias, ExtensionEntry *ext)
@@ -253,7 +258,7 @@ CloseDownExtensions(void) for (j = extensions[i]->num_aliases; --j >= 0;)
free(extensions[i]->aliases[j]);
free(extensions[i]->aliases);
- dixFreePrivates(extensions[i]->devPrivates);
+ dixFreePrivates(extensions[i]->devPrivates, PRIVATE_EXTENSION);
free(extensions[i]);
}
free(extensions);
@@ -330,7 +335,7 @@ ProcListExtensions(ClientPtr client) reply.length = bytes_to_int32(total_length);
buffer = bufptr = malloc(total_length);
if (!buffer)
- return(BadAlloc);
+ return BadAlloc;
for (i=0; i<NumExtensions; i++)
{
int len;
diff --git a/xorg-server/dix/gc.c b/xorg-server/dix/gc.c index e50c6319b..55ff3b89e 100644 --- a/xorg-server/dix/gc.c +++ b/xorg-server/dix/gc.c @@ -499,7 +499,7 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus, {
GCPtr pGC;
- pGC = malloc(sizeof(GC));
+ pGC = dixAllocateObjectWithPrivates(GC, PRIVATE_GC);
if (!pGC)
{
*pStatus = BadAlloc;
@@ -512,7 +512,6 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus, pGC->planemask = ~0;
pGC->serialNumber = GC_CHANGE_SERIAL_BIT;
pGC->funcs = 0;
- pGC->devPrivates = NULL;
pGC->fgPixel = 0;
pGC->bgPixel = 1;
pGC->lineWidth = 0;
@@ -583,7 +582,7 @@ out: pGC = (GCPtr)NULL;
}
- return (pGC);
+ return pGC;
}
static Bool
@@ -805,9 +804,8 @@ FreeGC(pointer value, XID gid) (*pGC->funcs->DestroyGC) (pGC);
if (pGC->dash != DefaultDash)
free(pGC->dash);
- dixFreePrivates(pGC->devPrivates);
- free(pGC);
- return(Success);
+ dixFreeObjectWithPrivates(pGC, PRIVATE_GC);
+ return Success;
}
/* CreateScratchGC(pScreen, depth)
@@ -828,7 +826,7 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth) {
GCPtr pGC;
- pGC = malloc(sizeof(GC));
+ pGC = dixAllocateObjectWithPrivates(GC, PRIVATE_GC);
if (!pGC)
return (GCPtr)NULL;
@@ -837,7 +835,6 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth) pGC->alu = GXcopy; /* dst <- src */
pGC->planemask = ~0;
pGC->serialNumber = 0;
- pGC->devPrivates = NULL;
pGC->fgPixel = 0;
pGC->bgPixel = 1;
pGC->lineWidth = 0;
@@ -1089,7 +1086,7 @@ SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects, newct = VerifyRectOrder(nrects, prects, ordering);
if (newct < 0)
- return(BadMatch);
+ return BadMatch;
size = nrects * sizeof(xRectangle);
prectsNew = malloc(size);
if (!prectsNew && size)
diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c index efe0c4287..37f05deef 100644 --- a/xorg-server/dix/getevents.c +++ b/xorg-server/dix/getevents.c @@ -33,6 +33,7 @@ #include <X11/X.h>
#include <X11/keysym.h>
#include <X11/Xproto.h>
+#include <math.h>
#include "misc.h"
#include "resource.h"
@@ -56,6 +57,7 @@ #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
+#include <pixman.h>
#include "exglobals.h"
#include "exevents.h"
#include "exglobals.h"
@@ -69,7 +71,12 @@ float roundf(float f) {
return ((f<0.0f) ? ceil(f-.5) : floor (f+.5));
}
+double roundd(double f)
+{
+ return ((f<0.0) ? ceil(f-.5) : floor (f+.5));
+}
#define lroundf(val) ((int)roundf(val))
+#define lround(val) ((int)roundd(val))
#endif
/* Number of motion history events to store. */
@@ -335,8 +342,7 @@ void AllocateMotionHistory(DeviceIntPtr pDev)
{
int size;
- if (pDev->valuator->motion)
- free(pDev->valuator->motion);
+ free(pDev->valuator->motion);
if (pDev->valuator->numMotionEvents < 1)
return;
@@ -1007,6 +1013,22 @@ FreeEventList(EventListPtr list, int num_events) free(list);
}
+static void
+transformAbsolute(DeviceIntPtr dev, int v[MAX_VALUATORS])
+{
+ struct pixman_f_vector p;
+
+ /* p' = M * p in homogeneous coordinates */
+ p.v[0] = v[0];
+ p.v[1] = v[1];
+ p.v[2] = 1.0;
+
+ pixman_f_transform_point(&dev->transform, &p);
+
+ v[0] = lround(p.v[0]);
+ v[1] = lround(p.v[1]);
+}
+
/**
* Generate a series of xEvents (filled into the EventList) representing
* pointer motion, or button presses. Xi and XKB-aware.
@@ -1078,6 +1100,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons, scr->height);
}
+ transformAbsolute(pDev, valuators);
moveAbsolute(pDev, &x, &y, first_valuator, num_valuators, valuators);
} else {
if (flags & POINTER_ACCELERATE) {
@@ -1201,8 +1224,8 @@ PostSyntheticMotion(DeviceIntPtr pDev, will translate from sprite screen to screen 0 upon reentry
to the DIX layer. */
if (!noPanoramiXExtension) {
- x += panoramiXdataPtr[0].x - panoramiXdataPtr[screen].x;
- y += panoramiXdataPtr[0].y - panoramiXdataPtr[screen].y;
+ x += screenInfo.screens[0]->x - screenInfo.screens[screen]->x;
+ y += screenInfo.screens[0]->y - screenInfo.screens[screen]->y;
}
#endif
diff --git a/xorg-server/dix/globals.c b/xorg-server/dix/globals.c index c24a94fbe..622e50f81 100644 --- a/xorg-server/dix/globals.c +++ b/xorg-server/dix/globals.c @@ -1,141 +1,135 @@ -/************************************************************ - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -********************************************************/ - - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> -#include "misc.h" -#include "windowstr.h" -#include "scrnintstr.h" -#include "input.h" -#include "dixfont.h" -#include "site.h" -#include "dixstruct.h" -#include "os.h" - -ScreenInfo screenInfo; -KeybdCtrl defaultKeyboardControl = { - DEFAULT_KEYBOARD_CLICK, - DEFAULT_BELL, - DEFAULT_BELL_PITCH, - DEFAULT_BELL_DURATION, - DEFAULT_AUTOREPEAT, - DEFAULT_AUTOREPEATS, - DEFAULT_LEDS, - 0}; - -PtrCtrl defaultPointerControl = { - DEFAULT_PTR_NUMERATOR, - DEFAULT_PTR_DENOMINATOR, - DEFAULT_PTR_THRESHOLD, - 0}; - -ClientPtr clients[MAXCLIENTS]; -ClientPtr serverClient; -int currentMaxClients; /* current size of clients array */ -long maxBigRequestSize = MAX_BIG_REQUEST_SIZE; - -WindowPtr WindowTable[MAXSCREENS]; - -unsigned long globalSerialNumber = 0; -unsigned long serverGeneration = 0; - -/* these next four are initialized in main.c */ -CARD32 ScreenSaverTime; -CARD32 ScreenSaverInterval; -int ScreenSaverBlanking; -int ScreenSaverAllowExposures; - -#ifdef DPMSExtension -CARD16 DPMSPowerLevel = 0; -Bool DPMSDisabledSwitch = FALSE; -Bool DPMSCapableFlag = FALSE; -CARD32 DPMSStandbyTime; -CARD32 DPMSSuspendTime; -CARD32 DPMSOffTime; -Bool DPMSEnabled; -#endif - -CARD32 defaultScreenSaverTime = DEFAULT_SCREEN_SAVER_TIME; -CARD32 defaultScreenSaverInterval = DEFAULT_SCREEN_SAVER_INTERVAL; -int defaultScreenSaverBlanking = DEFAULT_SCREEN_SAVER_BLANKING; -int defaultScreenSaverAllowExposures = DEFAULT_SCREEN_SAVER_EXPOSURES; -#ifndef NOLOGOHACK -int logoScreenSaver = DEFAULT_LOGO_SCREEN_SAVER; -#endif - -#ifdef SCREENSAVER -Bool screenSaverSuspended = FALSE; -#endif - -char *defaultFontPath = COMPILEDDEFAULTFONTPATH; -char *defaultTextFont = COMPILEDDEFAULTFONT; -char *defaultCursorFont = COMPILEDCURSORFONT; -FontPtr defaultFont; /* not declared in dix.h to avoid including font.h in - every compilation of dix code */ -CursorPtr rootCursor; -Bool party_like_its_1989 = FALSE; -Bool whiteRoot = FALSE; - -int cursorScreenDevPriv[MAXSCREENS]; - -TimeStamp currentTime; -TimeStamp lastDeviceEventTime; - -int defaultColorVisualClass = -1; -int monitorResolution = 0; - -char *display; -char *ConnectionInfo; - -CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND; - -DDXPointRec dixScreenOrigins[MAXSCREENS]; +/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "misc.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "input.h"
+#include "dixfont.h"
+#include "site.h"
+#include "dixstruct.h"
+#include "os.h"
+
+ScreenInfo screenInfo;
+KeybdCtrl defaultKeyboardControl = {
+ DEFAULT_KEYBOARD_CLICK,
+ DEFAULT_BELL,
+ DEFAULT_BELL_PITCH,
+ DEFAULT_BELL_DURATION,
+ DEFAULT_AUTOREPEAT,
+ DEFAULT_AUTOREPEATS,
+ DEFAULT_LEDS,
+ 0};
+
+PtrCtrl defaultPointerControl = {
+ DEFAULT_PTR_NUMERATOR,
+ DEFAULT_PTR_DENOMINATOR,
+ DEFAULT_PTR_THRESHOLD,
+ 0};
+
+ClientPtr clients[MAXCLIENTS];
+ClientPtr serverClient;
+int currentMaxClients; /* current size of clients array */
+long maxBigRequestSize = MAX_BIG_REQUEST_SIZE;
+
+unsigned long globalSerialNumber = 0;
+unsigned long serverGeneration = 0;
+
+/* these next four are initialized in main.c */
+CARD32 ScreenSaverTime;
+CARD32 ScreenSaverInterval;
+int ScreenSaverBlanking;
+int ScreenSaverAllowExposures;
+
+#ifdef DPMSExtension
+CARD16 DPMSPowerLevel = 0;
+Bool DPMSDisabledSwitch = FALSE;
+Bool DPMSCapableFlag = FALSE;
+CARD32 DPMSStandbyTime;
+CARD32 DPMSSuspendTime;
+CARD32 DPMSOffTime;
+Bool DPMSEnabled;
+#endif
+
+CARD32 defaultScreenSaverTime = DEFAULT_SCREEN_SAVER_TIME;
+CARD32 defaultScreenSaverInterval = DEFAULT_SCREEN_SAVER_INTERVAL;
+int defaultScreenSaverBlanking = DEFAULT_SCREEN_SAVER_BLANKING;
+int defaultScreenSaverAllowExposures = DEFAULT_SCREEN_SAVER_EXPOSURES;
+#ifndef NOLOGOHACK
+int logoScreenSaver = DEFAULT_LOGO_SCREEN_SAVER;
+#endif
+
+#ifdef SCREENSAVER
+Bool screenSaverSuspended = FALSE;
+#endif
+
+char *defaultFontPath = COMPILEDDEFAULTFONTPATH;
+char *defaultTextFont = COMPILEDDEFAULTFONT;
+char *defaultCursorFont = COMPILEDCURSORFONT;
+FontPtr defaultFont; /* not declared in dix.h to avoid including font.h in
+ every compilation of dix code */
+CursorPtr rootCursor;
+Bool party_like_its_1989 = FALSE;
+Bool whiteRoot = FALSE;
+
+TimeStamp currentTime;
+TimeStamp lastDeviceEventTime;
+
+int defaultColorVisualClass = -1;
+int monitorResolution = 0;
+
+char *display;
+char *ConnectionInfo;
+
+CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND;
diff --git a/xorg-server/dix/grabs.c b/xorg-server/dix/grabs.c index 1bc4998b2..c588afc7c 100644 --- a/xorg-server/dix/grabs.c +++ b/xorg-server/dix/grabs.c @@ -441,10 +441,10 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) details = malloc(i * sizeof(Mask *));
if (!deletes || !adds || !updates || !details)
{
- if (details) free(details);
- if (updates) free(updates);
- if (adds) free(adds);
- if (deletes) free(deletes);
+ free(details);
+ free(updates);
+ free(adds);
+ free(deletes);
return FALSE;
}
diff --git a/xorg-server/dix/inpututils.c b/xorg-server/dix/inpututils.c index 0ad709a16..778e0a3f0 100644 --- a/xorg-server/dix/inpututils.c +++ b/xorg-server/dix/inpututils.c @@ -360,6 +360,10 @@ DuplicateInputAttributes(InputAttributes *attrs) goto unwind;
if (attrs->device && !(new_attr->device = strdup(attrs->device)))
goto unwind;
+ if (attrs->pnp_id && !(new_attr->pnp_id = strdup(attrs->pnp_id)))
+ goto unwind;
+ if (attrs->usb_id && !(new_attr->usb_id = strdup(attrs->usb_id)))
+ goto unwind;
new_attr->flags = attrs->flags;
@@ -404,6 +408,8 @@ FreeInputAttributes(InputAttributes *attrs) free(attrs->product);
free(attrs->vendor);
free(attrs->device);
+ free(attrs->pnp_id);
+ free(attrs->usb_id);
if ((tags = attrs->tags))
while(*tags)
diff --git a/xorg-server/dix/main.c b/xorg-server/dix/main.c index a4080d39f..187f2e51d 100644 --- a/xorg-server/dix/main.c +++ b/xorg-server/dix/main.c @@ -218,7 +218,7 @@ int main(int argc, char *argv[], char *envp[]) InitProcVectors();
for (i=1; i<MAXCLIENTS; i++)
clients[i] = NullClient;
- serverClient = malloc(sizeof(ClientRec));
+ serverClient = calloc(sizeof(ClientRec), 1);
if (!serverClient)
FatalError("couldn't create server client");
InitClient(serverClient, 0, (pointer)NULL);
@@ -228,6 +228,12 @@ int main(int argc, char *argv[], char *envp[]) clients[0] = serverClient;
currentMaxClients = 1;
+ /* Initialize server client devPrivates, to be reallocated as
+ * more client privates are registered
+ */
+ if (!dixAllocatePrivates(&serverClient->devPrivates, PRIVATE_CLIENT))
+ FatalError("failed to create server client privates");
+
if (!InitClientResources(serverClient)) /* for root resources */
FatalError("couldn't init server resources");
@@ -238,8 +244,7 @@ int main(int argc, char *argv[], char *envp[]) InitEvents();
InitSelections();
InitGlyphCaching();
- if (!dixResetPrivates())
- FatalError("couldn't init private data storage");
+ dixResetPrivates();
dixResetRegistry();
ResetFontPrivateIndex();
InitCallbackManager();
@@ -248,6 +253,7 @@ int main(int argc, char *argv[], char *envp[]) if (screenInfo.numScreens < 1)
FatalError("no screens found");
InitExtensions(argc, argv);
+
for (i = 0; i < screenInfo.numScreens; i++)
{
ScreenPtr pScreen = screenInfo.screens[i];
@@ -293,7 +299,7 @@ int main(int argc, char *argv[], char *envp[]) #endif
for (i = 0; i < screenInfo.numScreens; i++)
- InitRootWindow(WindowTable[i]);
+ InitRootWindow(screenInfo.screens[i]->root);
InitCoreDevices();
InitInput(argc, argv);
@@ -347,7 +353,8 @@ int main(int argc, char *argv[], char *envp[]) CloseInput();
- memset(WindowTable, 0, sizeof(WindowTable));
+ for (i = 0; i < screenInfo.numScreens; i++)
+ screenInfo.screens[i]->root = NullWindow;
CloseDownDevices();
CloseDownEvents();
@@ -357,17 +364,18 @@ int main(int argc, char *argv[], char *envp[]) FreeGCperDepth(i);
FreeDefaultStipple(i);
(* screenInfo.screens[i]->CloseScreen)(i, screenInfo.screens[i]);
- dixFreePrivates(screenInfo.screens[i]->devPrivates);
+ dixFreePrivates(screenInfo.screens[i]->devPrivates, PRIVATE_SCREEN);
free(screenInfo.screens[i]);
screenInfo.numScreens = i;
}
+
+ dixFreePrivates(serverClient->devPrivates, PRIVATE_CLIENT);
+ serverClient->devPrivates = NULL;
+
FreeFonts();
FreeAuditTimer();
- dixFreePrivates(serverClient->devPrivates);
- serverClient->devPrivates = NULL;
-
if (dispatchException & DE_TERMINATE)
{
CloseWellKnownConnections();
@@ -384,6 +392,6 @@ int main(int argc, char *argv[], char *envp[]) free(ConnectionInfo);
ConnectionInfo = NULL;
}
- return(0);
+ return 0;
}
diff --git a/xorg-server/dix/makefile b/xorg-server/dix/makefile index 01e98d638..eeb18919c 100644 --- a/xorg-server/dix/makefile +++ b/xorg-server/dix/makefile @@ -30,6 +30,7 @@ CSRCS=\ privates.c \
property.c \
ptrveloc.c \
+ region.c \
registry.c \
resource.c \
selection.c \
diff --git a/xorg-server/dix/pixmap.c b/xorg-server/dix/pixmap.c index 460da771e..3943f5582 100644 --- a/xorg-server/dix/pixmap.c +++ b/xorg-server/dix/pixmap.c @@ -91,6 +91,11 @@ FreeScratchPixmapHeader(PixmapPtr pPixmap) Bool
CreateScratchPixmapsForScreen(int scrnum)
{
+ unsigned int pixmap_size;
+
+ pixmap_size = sizeof(PixmapRec) + dixPrivatesSize(PRIVATE_PIXMAP);
+ screenInfo.screens[scrnum]->totalPixmapSize = BitmapBytePad(pixmap_size * 8);
+
/* let it be created on first use */
screenInfo.screens[scrnum]->pScratchPixmap = NULL;
return TRUE;
@@ -110,6 +115,8 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize) {
PixmapPtr pPixmap;
+ assert(pScreen->totalPixmapSize > 0);
+
if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
return NullPixmap;
@@ -117,6 +124,14 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize) if (!pPixmap)
return NullPixmap;
- pPixmap->devPrivates = NULL;
+ dixInitPrivates(pPixmap, pPixmap + 1, PRIVATE_PIXMAP);
return pPixmap;
}
+
+/* callable by ddx */
+void
+FreePixmap(PixmapPtr pPixmap)
+{
+ dixFiniPrivates(pPixmap, PRIVATE_PIXMAP);
+ free(pPixmap);
+}
diff --git a/xorg-server/dix/privates.c b/xorg-server/dix/privates.c index 52a8df3f6..75f665678 100644 --- a/xorg-server/dix/privates.c +++ b/xorg-server/dix/privates.c @@ -25,6 +25,28 @@ other dealings in this Software without prior written authorization from The Open Group.
*/
+/*
+ * Copyright © 2010, Keith Packard
+ * Copyright © 2010, Jamey Sharp
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
@@ -38,177 +60,347 @@ from The Open Group. #include "cursorstr.h"
#include "colormapst.h"
#include "inputstr.h"
-
-struct _Private {
- int state;
- pointer value;
+#include "scrnintstr.h"
+#include "extnsionst.h"
+
+static struct {
+ DevPrivateKey key;
+ unsigned offset;
+ int created;
+ int allocated;
+} keys[PRIVATE_LAST];
+
+static const Bool xselinux_private[PRIVATE_LAST] = {
+ /* PRIVATE_XSELINUX,*/ FALSE,
+ /* PRIVATE_SCREEN,*/ FALSE,
+ /* [PRIVATE_EXTENSION] =*/TRUE,
+ /* [PRIVATE_COLORMAP] =*/ TRUE,
+ /* [PRIVATE_DEVICE] =*/ TRUE,
+ /*[PRIVATE_CLIENT] = */ TRUE,
+ /* [PRIVATE_PROPERTY] =*/ TRUE,
+ /* [PRIVATE_SELECTION] =*/TRUE,
+ /* [PRIVATE_WINDOW] =*/ TRUE,
+ /* [PRIVATE_PIXMAP] =*/ TRUE,
+ /* [PRIVATE_GC] =*/ TRUE,
+ /* [PRIVATE_CURSOR] =*/ TRUE,
+ /* PRIVATE_CURSOR_BITS,*/ FALSE,
+ /* PRIVATE_DBE_WINDOW,*/ FALSE,
+ /* PRIVATE_DAMAGE,*/ FALSE,
+ /* PRIVATE_GLYPH,*/ FALSE,
+ /* [PRIVATE_GLYPHSET] =*/ TRUE,
+ /* [PRIVATE_PICTURE] =*/ TRUE
};
-typedef struct _PrivateDesc {
- DevPrivateKey key;
- unsigned size;
-} PrivateDescRec;
+typedef Bool (*FixupFunc)(PrivatePtr *privates, int offset, unsigned bytes);
-#define PRIV_MAX 256
-#define PRIV_STEP 16
+static Bool
+dixReallocPrivates(PrivatePtr *privates, int old_offset, unsigned bytes)
+{
+ void *new_privates;
-/* list of all allocated privates */
-static PrivateDescRec items[PRIV_MAX];
-static int nextPriv;
+ new_privates = realloc(*privates, old_offset + bytes);
+ if (!new_privates)
+ return FALSE;
+ memset((char *) new_privates + old_offset, '\0', bytes);
+ *privates = new_privates;
+ return TRUE;
+}
-static PrivateDescRec *
-findItem(const DevPrivateKey key)
+static Bool
+dixMovePrivates(PrivatePtr *privates, int new_offset, unsigned bytes)
{
- if (!*key) {
- if (nextPriv >= PRIV_MAX)
- return NULL;
+ memmove((char *) *privates + bytes, *privates, new_offset - bytes);
+ memset(*privates, '\0', bytes);
+ return TRUE;
+}
- items[nextPriv].key = key;
- *key = nextPriv;
- nextPriv++;
- }
+static Bool
+fixupScreens(FixupFunc fixup, unsigned bytes)
+{
+ int s;
+ for (s = 0; s < screenInfo.numScreens; s++)
+ if (!fixup(&screenInfo.screens[s]->devPrivates, keys[PRIVATE_SCREEN].offset, bytes))
+ return FALSE;
+ return TRUE;
+}
- return items + *key;
+static Bool
+fixupServerClient(FixupFunc fixup, unsigned bytes)
+{
+ if (serverClient)
+ return fixup(&serverClient->devPrivates, keys[PRIVATE_CLIENT].offset, bytes);
+ return TRUE;
}
-static _X_INLINE int
-privateExists(PrivateRec **privates, const DevPrivateKey key)
+static Bool
+fixupExtensions(FixupFunc fixup, unsigned bytes)
{
- return *key && *privates &&
- (*privates)[0].state > *key &&
- (*privates)[*key].state;
+ unsigned char major;
+ ExtensionEntry *extension;
+ for (major = EXTENSION_BASE; (extension = GetExtensionEntry(major)); major++)
+ if (!fixup(&extension->devPrivates, keys[PRIVATE_EXTENSION].offset, bytes))
+ return FALSE;
+ return TRUE;
}
-/*
- * Request pre-allocated space.
- */
-int
-dixRequestPrivate(const DevPrivateKey key, unsigned size)
+static Bool
+fixupDefaultColormaps(FixupFunc fixup, unsigned bytes)
{
- PrivateDescRec *item = findItem(key);
- if (!item)
- return FALSE;
- if (size > item->size)
- item->size = size;
+ int s;
+ for (s = 0; s < screenInfo.numScreens; s++) {
+ ColormapPtr cmap;
+ dixLookupResourceByType((pointer *) &cmap, screenInfo.screens[s]->defColormap,
+ RT_COLORMAP, serverClient, DixCreateAccess);
+ if (cmap && !fixup(&cmap->devPrivates, keys[PRIVATE_COLORMAP].offset, bytes))
+ return FALSE;
+ }
return TRUE;
}
+static Bool (* const allocated_early[PRIVATE_LAST])(FixupFunc, unsigned) = {
+ /*PRIVATE_XSELINUX,*/ NULL,
+ /*[PRIVATE_SCREEN] =*/ fixupScreens,
+ /*[PRIVATE_EXTENSION] =*/ fixupExtensions,
+ /*[PRIVATE_COLORMAP] =*/ fixupDefaultColormaps,
+ /*PRIVATE_DEVICE,*/ NULL,
+ /*[PRIVATE_CLIENT] =*/ fixupServerClient,
+ /*PRIVATE_PROPERTY,*/ NULL,
+ /*PRIVATE_SELECTION,*/ NULL,
+ /*PRIVATE_WINDOW,*/ NULL,
+ /*PRIVATE_PIXMAP,*/ NULL,
+ /*PRIVATE_GC,*/ NULL,
+ /*PRIVATE_CURSOR,*/ NULL,
+ /*PRIVATE_CURSOR_BITS,*/ NULL,
+ /*PRIVATE_DBE_WINDOW,*/ NULL,
+ /*PRIVATE_DAMAGE,*/ NULL,
+ /*PRIVATE_GLYPH,*/ NULL,
+ /*PRIVATE_GLYPHSET,*/ NULL,
+ /*PRIVATE_PICTURE,*/ NULL
+};
+
/*
- * Allocate a private and attach it to an existing object.
+ * Register a private key. This takes the type of object the key will
+ * be used with, which may be PRIVATE_ALL indicating that this key
+ * will be used with all of the private objects. If 'size' is
+ * non-zero, then the specified amount of space will be allocated in
+ * the private storage. Otherwise, space for a single pointer will
+ * be allocated which can be set with dixSetPrivate
*/
-pointer *
-dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
+Bool
+dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size)
{
- PrivateDescRec *item = findItem(key);
- PrivateRec *ptr;
- pointer value;
- int oldsize, newsize;
-
- newsize = (*key / PRIV_STEP + 1) * PRIV_STEP;
-
- /* resize or init privates array */
- if (!item)
- return NULL;
+ DevPrivateType t;
+ int offset;
+ unsigned bytes;
- /* initialize privates array if necessary */
- if (!*privates) {
- ptr = calloc(newsize, sizeof(*ptr));
- if (!ptr)
- return NULL;
- *privates = ptr;
- (*privates)[0].state = newsize;
+ if (key->initialized) {
+ assert (size == key->size);
+ return TRUE;
}
- oldsize = (*privates)[0].state;
+ /* Compute required space */
+ bytes = size;
+ if (size == 0)
+ bytes = sizeof (void *);
+
+ /* align to void * size */
+ bytes = (bytes + sizeof (void *) - 1) & ~(sizeof (void *) - 1);
+
+ /* Update offsets for all affected keys */
+ if (type == PRIVATE_XSELINUX) {
+ DevPrivateKey k;
+
+ /* Resize if we can, or make sure nothing's allocated if we can't
+ */
+ for (t = PRIVATE_XSELINUX; t < PRIVATE_LAST; t++)
+ if (xselinux_private[t]) {
+ if (!allocated_early[t])
+ assert (!keys[t].created);
+ else if (!allocated_early[t](dixReallocPrivates, bytes))
+ return FALSE;
+ }
- /* resize privates array if necessary */
- if (*key >= oldsize) {
- ptr = realloc(*privates, newsize * sizeof(*ptr));
- if (!ptr)
- return NULL;
- memset(ptr + oldsize, 0, (newsize - oldsize) * sizeof(*ptr));
- *privates = ptr;
- (*privates)[0].state = newsize;
- }
+ /* Move all existing keys up in the privates space to make
+ * room for this new global key
+ */
+ for (t = PRIVATE_XSELINUX; t < PRIVATE_LAST; t++) {
+ if (xselinux_private[t]) {
+ for (k = keys[t].key; k; k = k->next)
+ k->offset += bytes;
+ keys[t].offset += bytes;
+ if (allocated_early[t])
+ allocated_early[t](dixMovePrivates, bytes);
+ }
+ }
- /* initialize slot */
- ptr = *privates + *key;
- ptr->state = 1;
- if (item->size) {
- value = calloc(item->size, 1);
- if (!value)
- return NULL;
- ptr->value = value;
+ offset = 0;
+ } else {
+ /* Resize if we can, or make sure nothing's allocated if we can't */
+ if (!allocated_early[type])
+ assert(!keys[type].created);
+ else if (!allocated_early[type](dixReallocPrivates, bytes))
+ return FALSE;
+ offset = keys[type].offset;
+ keys[type].offset += bytes;
}
- return &ptr->value;
+ /* Setup this key */
+ key->offset = offset;
+ key->size = size;
+ key->initialized = TRUE;
+ key->type = type;
+ key->allocated = FALSE;
+ key->next = keys[type].key;
+ keys[type].key = key;
+
+ return TRUE;
}
/*
- * Look up a private pointer.
+ * Allocate a new private key.
+ *
+ * This manages the storage of the key object itself, freeing it when the
+ * privates system is restarted at server reset time. All other keys
+ * are expected to be statically allocated as the privates must be
+ * reset after all objects have been freed
*/
-pointer
-dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
+DevPrivateKey
+dixCreatePrivateKey(DevPrivateType type, unsigned size)
{
- pointer *ptr;
+ DevPrivateKey key;
- if (privateExists(privates, key))
- return (*privates)[*key].value;
+ key = calloc(sizeof (DevPrivateKeyRec), 1);
+ if (!key)
+ return NULL;
+ if (!dixRegisterPrivateKey(key, type, size)) {
+ free(key);
+ return NULL;
+ }
+ key->allocated = TRUE;
+ return key;
+}
+
+/*
+ * Initialize privates by zeroing them
+ */
+void
+_dixInitPrivates(PrivatePtr *privates, void *addr, DevPrivateType type)
+{
+ keys[type].created++;
+ if (xselinux_private[type])
+ keys[PRIVATE_XSELINUX].created++;
+ if (keys[type].offset == 0)
+ addr = 0;
+ *privates = addr;
+ memset(addr, '\0', keys[type].offset);
+}
- ptr = dixAllocatePrivate(privates, key);
- return ptr ? *ptr : NULL;
+/*
+ * Clean up privates
+ */
+void
+_dixFiniPrivates(PrivatePtr privates, DevPrivateType type)
+{
+ keys[type].created--;
+ if (xselinux_private[type])
+ keys[PRIVATE_XSELINUX].created--;
}
/*
- * Look up the address of a private pointer.
+ * Allocate new object with privates.
+ *
+ * This is expected to be invoked from the
+ * dixAllocateObjectWithPrivates macro
*/
-pointer *
-dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
+void *
+_dixAllocateObjectWithPrivates(unsigned baseSize, unsigned clear, unsigned offset, DevPrivateType type)
{
- if (privateExists(privates, key))
- return &(*privates)[*key].value;
+ unsigned totalSize;
+ void *object;
+ PrivatePtr privates;
+ PrivatePtr *devPrivates;
+
+ assert (type > PRIVATE_SCREEN && type < PRIVATE_LAST);
+
+ /* round up so that void * is aligned */
+ baseSize = (baseSize + sizeof (void *) - 1) & ~(sizeof (void *) - 1);
+ totalSize = baseSize + keys[type].offset;
+ object = malloc(totalSize);
+ if (!object)
+ return NULL;
+
+ memset(object, '\0', clear);
+ privates = (PrivatePtr) (((char *) object) + baseSize);
+ devPrivates = (PrivatePtr *) ((char *) object + offset);
+
+ _dixInitPrivates(devPrivates, privates, type);
- return dixAllocatePrivate(privates, key);
+ return object;
}
/*
- * Set a private pointer.
+ * Allocate privates separately from containing object.
+ * Used for clients and screens.
*/
-int
-dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
+Bool
+dixAllocatePrivates(PrivatePtr *privates, DevPrivateType type)
{
- top:
- if (privateExists(privates, key)) {
- (*privates)[*key].value = val;
- return TRUE;
+ unsigned size;
+ PrivatePtr p;
+
+ assert (type > PRIVATE_XSELINUX && type < PRIVATE_LAST);
+
+ size = keys[type].offset;
+ if (!size) {
+ p = NULL;
+ } else {
+ if (!(p = malloc(size)))
+ return FALSE;
}
- if (!dixAllocatePrivate(privates, key))
- return FALSE;
- goto top;
+ _dixInitPrivates(privates, p, type);
+ ++keys[type].allocated;
+
+ return TRUE;
}
/*
- * Called to free privates at object deletion time.
+ * Free an object that has privates
+ *
+ * This is expected to be invoked from the
+ * dixFreeObjectWithPrivates macro
*/
void
-dixFreePrivates(PrivateRec *privates)
+_dixFreeObjectWithPrivates(void *object, PrivatePtr privates, DevPrivateType type)
{
- int i;
-
- if (privates)
- for (i = 1; i < privates->state; i++)
- if (privates[i].state) {
- /* free pre-allocated memory */
- if (items[i].size)
- free(privates[i].value);
- }
+ _dixFiniPrivates(privates, type);
+ free(object);
+}
+/*
+ * Called to free screen or client privates
+ */
+void
+dixFreePrivates(PrivatePtr privates, DevPrivateType type)
+{
+ _dixFiniPrivates(privates, type);
+ --keys[type].allocated;
free(privates);
}
+/*
+ * Return size of privates for the specified type
+ */
+extern _X_EXPORT int
+dixPrivatesSize(DevPrivateType type)
+{
+ assert (type >= PRIVATE_SCREEN && type < PRIVATE_LAST);
+
+ return keys[type].offset;
+}
+
/* Table of devPrivates offsets */
-static const int offsetDefaults[] = {
+static const int offsets[] = {
-1, /* RT_NONE */
offsetof(WindowRec, devPrivates), /* RT_WINDOW */
offsetof(PixmapRec, devPrivates), /* RT_PIXMAP */
@@ -216,67 +408,106 @@ static const int offsetDefaults[] = { -1, /* RT_FONT */
offsetof(CursorRec, devPrivates), /* RT_CURSOR */
offsetof(ColormapRec, devPrivates), /* RT_COLORMAP */
- -1, /* RT_CMAPENTRY */
- -1, /* RT_OTHERCLIENT */
- -1 /* RT_PASSIVEGRAB */
};
-
-static int *offsets = NULL;
-static int offsetsSize = 0;
-/*
- * Specify where the devPrivates field is located in a structure type
- */
+#define NUM_OFFSETS (sizeof (offsets) / sizeof (offsets[0]))
+
int
-dixRegisterPrivateOffset(RESTYPE type, int offset)
+dixLookupPrivateOffset(RESTYPE type)
{
- type = type & TypeMask;
-
- /* resize offsets table if necessary */
- while (type >= offsetsSize) {
- unsigned i = offsetsSize * 2 * sizeof(int);
- offsets = (int *)realloc(offsets, i);
- if (!offsets) {
- offsetsSize = 0;
- return FALSE;
- }
- for (i=offsetsSize; i < 2*offsetsSize; i++)
- offsets[i] = -1;
- offsetsSize *= 2;
+ /*
+ * Special kludge for DBE which registers a new resource type that
+ * points at pixmaps (thanks, DBE)
+ */
+ if (type & RC_DRAWABLE) {
+ if (type == RT_WINDOW)
+ return offsets[RT_WINDOW & TypeMask];
+ else
+ return offsets[RT_PIXMAP & TypeMask];
}
-
- offsets[type] = offset;
- return TRUE;
+ type = type & TypeMask;
+ if (type < NUM_OFFSETS)
+ return offsets[type];
+ return -1;
}
-int
-dixLookupPrivateOffset(RESTYPE type)
+static const char *key_names[PRIVATE_LAST] = {
+ /* XSELinux uses the same private keys for numerous objects */
+ /*[PRIVATE_XSELINUX] =*/ "XSELINUX",
+
+ /* Otherwise, you get a private in just the requested structure
+ */
+ /* These can have objects created before all of the keys are registered */
+ /*[PRIVATE_SCREEN] =*/ "SCREEN",
+ /*[PRIVATE_EXTENSION] =*/ "EXTENSION",
+ /*[PRIVATE_COLORMAP] =*/ "COLORMAP",
+
+ /* These cannot have any objects before all relevant keys are registered */
+ /*[PRIVATE_DEVICE] =*/ "DEVICE",
+ /*[PRIVATE_CLIENT] =*/ "CLIENT",
+ /*[PRIVATE_PROPERTY] =*/ "PROPERTY",
+ /*[PRIVATE_SELECTION] =*/ "SELECTION",
+ /*[PRIVATE_WINDOW] =*/ "WINDOW",
+ /*[PRIVATE_PIXMAP] =*/ "PIXMAP",
+ /*[PRIVATE_GC] =*/ "GC",
+ /*[PRIVATE_CURSOR] =*/ "CURSOR",
+ /*[PRIVATE_CURSOR_BITS] =*/ "CURSOR_BITS",
+
+ /* extension privates */
+ /*[PRIVATE_DBE_WINDOW] =*/ "DBE_WINDOW",
+ /*[PRIVATE_DAMAGE] =*/ "DAMAGE",
+ /*[PRIVATE_GLYPH] =*/ "GLYPH",
+ /*[PRIVATE_GLYPHSET] =*/ "GLYPHSET",
+ /*[PRIVATE_PICTURE] =*/ "PICTURE"
+};
+
+void
+dixPrivateUsage(void)
{
- type = type & TypeMask;
- assert(type < offsetsSize);
- return offsets[type];
+ int objects = 0;
+ int bytes = 0;
+ int alloc = 0;
+ DevPrivateType t;
+
+ for (t = PRIVATE_XSELINUX + 1; t < PRIVATE_LAST; t++) {
+ if (keys[t].offset) {
+ ErrorF("%s: %d objects of %d bytes = %d total bytes %d private allocs\n",
+ key_names[t], keys[t].created, keys[t].offset, keys[t].created * keys[t].offset,
+ keys[t].allocated);
+ bytes += keys[t].created * keys[t].offset;
+ objects += keys[t].created;
+ alloc += keys[t].allocated;
+ }
+ }
+ ErrorF("TOTAL: %d objects, %d bytes, %d allocs\n",
+ objects, bytes, alloc);
}
-int
+void
dixResetPrivates(void)
{
- int i;
-
- /* reset private descriptors */
- for (i = 1; i < nextPriv; i++) {
- *items[i].key = 0;
- items[i].size = 0;
+ DevPrivateType t;
+
+ for (t = PRIVATE_XSELINUX; t < PRIVATE_LAST; t++) {
+ DevPrivateKey key, next;
+
+ for (key = keys[t].key; key; key = next) {
+ next = key->next;
+ key->offset = 0;
+ key->initialized = FALSE;
+ key->size = 0;
+ key->type = 0;
+ if (key->allocated)
+ free(key);
+ }
+ if (keys[t].created) {
+ ErrorF("%d %ss still allocated at reset\n",
+ keys[t].created, key_names[t]);
+ dixPrivateUsage();
+ }
+ keys[t].key = NULL;
+ keys[t].offset = 0;
+ keys[t].created = 0;
+ keys[t].allocated = 0;
}
- nextPriv = 1;
-
- /* reset offsets */
- if (offsets)
- free(offsets);
- offsetsSize = sizeof(offsetDefaults);
- offsets = malloc(offsetsSize);
- offsetsSize /= sizeof(int);
- if (!offsets)
- return FALSE;
- memcpy(offsets, offsetDefaults, sizeof(offsetDefaults));
- return TRUE;
}
diff --git a/xorg-server/dix/property.c b/xorg-server/dix/property.c index 7c4bd62d2..9d30e726d 100644 --- a/xorg-server/dix/property.c +++ b/xorg-server/dix/property.c @@ -230,12 +230,12 @@ ProcChangeProperty(ClientPtr client) if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
- return(BadAtom);
+ return BadAtom;
}
if (!ValidAtom(stuff->type))
{
client->errorValue = stuff->type;
- return(BadAtom);
+ return BadAtom;
}
err = dixChangeWindowProperty(client, pWin, stuff->property, stuff->type,
@@ -268,15 +268,15 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, if (rc == BadMatch) /* just add to list */
{
if (!pWin->optional && !MakeWindowOptional (pWin))
- return(BadAlloc);
- pProp = malloc(sizeof(PropertyRec));
+ return BadAlloc;
+ pProp = dixAllocateObjectWithPrivates(PropertyRec, PRIVATE_PROPERTY);
if (!pProp)
- return(BadAlloc);
+ return BadAlloc;
data = malloc(totalSize);
if (!data && len)
{
- free(pProp);
- return(BadAlloc);
+ dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
+ return BadAlloc;
}
memcpy(data, value, totalSize);
pProp->propertyName = property;
@@ -289,7 +289,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, DixCreateAccess|DixWriteAccess);
if (rc != Success) {
free(data);
- free(pProp);
+ dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
pClient->errorValue = property;
return rc;
}
@@ -304,9 +304,9 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, "PropModeReplace" since they will be written over. */
if ((format != pProp->format) && (mode != PropModeReplace))
- return(BadMatch);
+ return BadMatch;
if ((pProp->type != type) && (mode != PropModeReplace))
- return(BadMatch);
+ return BadMatch;
/* save the old values for later */
savedProp = *pProp;
@@ -315,7 +315,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, {
data = malloc(totalSize);
if (!data && len)
- return(BadAlloc);
+ return BadAlloc;
memcpy(data, value, totalSize);
pProp->data = data;
pProp->size = len;
@@ -330,7 +330,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, {
data = malloc((pProp->size + len) * sizeInBytes);
if (!data)
- return(BadAlloc);
+ return BadAlloc;
memcpy(data, pProp->data, pProp->size * sizeInBytes);
memcpy(data + pProp->size * sizeInBytes, value, totalSize);
pProp->data = data;
@@ -340,7 +340,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, {
data = malloc(sizeInBytes * (len + pProp->size));
if (!data)
- return(BadAlloc);
+ return BadAlloc;
memcpy(data + totalSize, pProp->data, pProp->size * sizeInBytes);
memcpy(data, value, totalSize);
pProp->data = data;
@@ -369,7 +369,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, if (sendevent)
deliverPropertyNotifyEvent(pWin, PropertyNewValue, pProp->propertyName);
- return(Success);
+ return Success;
}
int
@@ -405,9 +405,8 @@ DeleteProperty(ClientPtr client, WindowPtr pWin, Atom propName) }
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
- dixFreePrivates(pProp->devPrivates);
free(pProp->data);
- free(pProp);
+ dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
}
return rc;
}
@@ -422,9 +421,8 @@ DeleteAllWindowProperties(WindowPtr pWin) {
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
pNextProp = pProp->next;
- dixFreePrivates(pProp->devPrivates);
free(pProp->data);
- free(pProp);
+ dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
pProp = pNextProp;
}
}
@@ -479,17 +477,17 @@ ProcGetProperty(ClientPtr client) if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
- return(BadAtom);
+ return BadAtom;
}
if ((stuff->delete != xTrue) && (stuff->delete != xFalse))
{
client->errorValue = stuff->delete;
- return(BadValue);
+ return BadValue;
}
if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type))
{
client->errorValue = stuff->type;
- return(BadAtom);
+ return BadAtom;
}
memset(&reply, 0, sizeof(xGetPropertyReply));
@@ -515,7 +513,7 @@ ProcGetProperty(ClientPtr client) reply.nItems = 0;
reply.propertyType = pProp->type;
WriteReplyToClient(client, sizeof(xGenericReply), &reply);
- return(Success);
+ return Success;
}
/*
@@ -570,9 +568,8 @@ ProcGetProperty(ClientPtr client) prevProp->next = pProp->next;
}
- dixFreePrivates(pProp->devPrivates);
free(pProp->data);
- free(pProp);
+ dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
}
return Success;
}
@@ -638,7 +635,7 @@ ProcDeleteProperty(ClientPtr client) if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
- return (BadAtom);
+ return BadAtom;
}
return DeleteProperty(client, pWin, stuff->property);
diff --git a/xorg-server/dix/ptrveloc.c b/xorg-server/dix/ptrveloc.c index 7310952c9..27cb766f4 100644 --- a/xorg-server/dix/ptrveloc.c +++ b/xorg-server/dix/ptrveloc.c @@ -503,7 +503,7 @@ CalcTracker(DeviceVelocityPtr vel, int offset, int cur_t){ + vel->tracker[index].dy * vel->tracker[index].dy);
int dtime = cur_t - vel->tracker[index].time;
if(dtime > 0)
- return (dist / dtime);
+ return dist / dtime;
else
return 0;/* synonymous for NaN, since we're not C99 */
}
diff --git a/xorg-server/mi/miregion.c b/xorg-server/dix/region.c index ff58c0372..c0add6ca9 100644 --- a/xorg-server/mi/miregion.c +++ b/xorg-server/dix/region.c @@ -83,8 +83,6 @@ Equipment Corporation. #include <X11/Xprotostr.h>
#include <X11/Xfuncproto.h>
#include "gc.h"
-#include "mi.h"
-#include "mispans.h"
#include <pixman.h>
#undef assert
@@ -101,7 +99,7 @@ Equipment Corporation. #define assert(expr)
#endif
-#define good(reg) assert(miValidRegion(reg))
+#define good(reg) assert(RegionIsValid(reg))
/*
* The functions in this file implement the Region abstraction used extensively
@@ -144,7 +142,7 @@ Equipment Corporation. *
* Adam de Boor wrote most of the original region code. Joel McCormack
* substantially modified or rewrote most of the core arithmetic routines,
- * and added miRegionValidate in order to support several speed improvements
+ * and added RegionValidate in order to support several speed improvements
* to miValidateTree. Bob Scheifler changed the representation to be more
* compact when empty or a single rectangle, and did a bunch of gratuitous
* reformatting.
@@ -171,16 +169,16 @@ Equipment Corporation. ((r1)->y1 <= (r2)->y1) && \
((r1)->y2 >= (r2)->y2) )
-#define xallocData(n) malloc(REGION_SZOF(n))
+#define xallocData(n) malloc(RegionSizeof(n))
#define xfreeData(reg) if ((reg)->data && (reg)->data->size) free((reg)->data)
#define RECTALLOC_BAIL(pReg,n,bail) \
if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
- if (!miRectAlloc(pReg, n)) { goto bail; }
+ if (!RegionRectAlloc(pReg, n)) { goto bail; }
#define RECTALLOC(pReg,n) \
if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
- if (!miRectAlloc(pReg, n)) { return FALSE; }
+ if (!RegionRectAlloc(pReg, n)) { return FALSE; }
#define ADDRECT(pNextRect,nx1,ny1,nx2,ny2) \
{ \
@@ -195,9 +193,9 @@ if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \ { \
if (!(pReg)->data || ((pReg)->data->numRects == (pReg)->data->size))\
{ \
- if (!miRectAlloc(pReg, 1)) \
+ if (!RegionRectAlloc(pReg, 1)) \
return FALSE; \
- pNextRect = REGION_TOP(pReg); \
+ pNextRect = RegionTop(pReg); \
} \
ADDRECT(pNextRect,nx1,ny1,nx2,ny2); \
pReg->data->numRects++; \
@@ -209,7 +207,7 @@ if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \ if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \
{ \
RegDataPtr NewData; \
- NewData = (RegDataPtr)realloc((reg)->data, REGION_SZOF(numRects)); \
+ NewData = (RegDataPtr)realloc((reg)->data, RegionSizeof(numRects)); \
if (NewData) \
{ \
NewData->size = (numRects); \
@@ -218,16 +216,16 @@ if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \ }
-BoxRec miEmptyBox = {0, 0, 0, 0};
-RegDataRec miEmptyData = {0, 0};
+BoxRec RegionEmptyBox = {0, 0, 0, 0};
+RegDataRec RegionEmptyData = {0, 0};
-RegDataRec miBrokenData = {0, 0};
-static RegionRec miBrokenRegion = { { 0, 0, 0, 0 }, &miBrokenData };
+RegDataRec RegionBrokenData = {0, 0};
+static RegionRec RegionBrokenRegion = { { 0, 0, 0, 0 }, &RegionBrokenData };
void
InitRegions (void)
{
- pixman_region_set_static_pointers (&miEmptyBox, &miEmptyData, &miBrokenData);
+ pixman_region_set_static_pointers (&RegionEmptyBox, &RegionEmptyData, &RegionBrokenData);
}
/*****************************************************************
@@ -237,37 +235,37 @@ InitRegions (void) *****************************************************************/
RegionPtr
-miRegionCreate(BoxPtr rect, int size)
+RegionCreate(BoxPtr rect, int size)
{
RegionPtr pReg;
pReg = (RegionPtr)malloc(sizeof(RegionRec));
if (!pReg)
- return &miBrokenRegion;
+ return &RegionBrokenRegion;
- miRegionInit (pReg, rect, size);
+ RegionInit (pReg, rect, size);
- return(pReg);
+ return pReg;
}
void
-miRegionDestroy(RegionPtr pReg)
+RegionDestroy(RegionPtr pReg)
{
pixman_region_fini (pReg);
- if (pReg != &miBrokenRegion)
+ if (pReg != &RegionBrokenRegion)
free(pReg);
}
void
-miPrintRegion(RegionPtr rgn)
+RegionPrint(RegionPtr rgn)
{
int num, size;
int i;
BoxPtr rects;
- num = REGION_NUM_RECTS(rgn);
- size = REGION_SIZE(rgn);
- rects = REGION_RECTS(rgn);
+ num = RegionNumRects(rgn);
+ size = RegionSize(rgn);
+ rects = RegionRects(rgn);
ErrorF("[mi] num: %d size: %d\n", num, size);
ErrorF("[mi] extents: %d %d %d %d\n",
rgn->extents.x1, rgn->extents.y1, rgn->extents.x2, rgn->extents.y2);
@@ -277,34 +275,28 @@ miPrintRegion(RegionPtr rgn) ErrorF("[mi] \n");
}
-Bool
-miRegionEqual(RegionPtr reg1, RegionPtr reg2)
-{
- return pixman_region_equal (reg1, reg2);
-}
-
#ifdef DEBUG
Bool
-miValidRegion(RegionPtr reg)
+RegionIsValid(RegionPtr reg)
{
int i, numRects;
if ((reg->extents.x1 > reg->extents.x2) ||
(reg->extents.y1 > reg->extents.y2))
return FALSE;
- numRects = REGION_NUM_RECTS(reg);
+ numRects = RegionNumRects(reg);
if (!numRects)
return ((reg->extents.x1 == reg->extents.x2) &&
(reg->extents.y1 == reg->extents.y2) &&
- (reg->data->size || (reg->data == &miEmptyData)));
+ (reg->data->size || (reg->data == &RegionEmptyData)));
else if (numRects == 1)
- return (!reg->data);
+ return !reg->data;
else
{
BoxPtr pboxP, pboxN;
BoxRec box;
- pboxP = REGION_RECTS(reg);
+ pboxP = RegionRects(reg);
box = *pboxP;
box.y2 = pboxP[numRects-1].y2;
pboxN = pboxP + 1;
@@ -330,37 +322,17 @@ miValidRegion(RegionPtr reg) }
#endif /* DEBUG */
-/*****************************************************************
- * RegionInit(pReg, rect, size)
- * Outer region rect is statically allocated.
- *****************************************************************/
-
-void
-miRegionInit(RegionPtr pReg, BoxPtr rect, int size)
-{
- if (rect)
- pixman_region_init_with_extents (pReg, rect);
- else
- pixman_region_init (pReg);
-}
-
-void
-miRegionUninit(RegionPtr pReg)
-{
- pixman_region_fini (pReg);
-}
-
Bool
-miRegionBreak (RegionPtr pReg)
+RegionBreak (RegionPtr pReg)
{
xfreeData (pReg);
- pReg->extents = miEmptyBox;
- pReg->data = &miBrokenData;
+ pReg->extents = RegionEmptyBox;
+ pReg->data = &RegionBrokenData;
return FALSE;
}
Bool
-miRectAlloc(RegionPtr pRgn, int n)
+RegionRectAlloc(RegionPtr pRgn, int n)
{
RegDataPtr data;
@@ -369,15 +341,15 @@ miRectAlloc(RegionPtr pRgn, int n) n++;
pRgn->data = xallocData(n);
if (!pRgn->data)
- return miRegionBreak (pRgn);
+ return RegionBreak (pRgn);
pRgn->data->numRects = 1;
- *REGION_BOXPTR(pRgn) = pRgn->extents;
+ *RegionBoxptr(pRgn) = pRgn->extents;
}
else if (!pRgn->data->size)
{
pRgn->data = xallocData(n);
if (!pRgn->data)
- return miRegionBreak (pRgn);
+ return RegionBreak (pRgn);
pRgn->data->numRects = 0;
}
else
@@ -389,31 +361,25 @@ miRectAlloc(RegionPtr pRgn, int n) n = 250;
}
n += pRgn->data->numRects;
- data = (RegDataPtr)realloc(pRgn->data, REGION_SZOF(n));
+ data = (RegDataPtr)realloc(pRgn->data, RegionSizeof(n));
if (!data)
- return miRegionBreak (pRgn);
+ return RegionBreak (pRgn);
pRgn->data = data;
}
pRgn->data->size = n;
return TRUE;
}
-Bool
-miRegionCopy(RegionPtr dst, RegionPtr src)
-{
- return pixman_region_copy (dst, src);
-}
-
/*======================================================================
* Generic Region Operator
*====================================================================*/
/*-
*-----------------------------------------------------------------------
- * miCoalesce --
+ * RegionCoalesce --
* Attempt to merge the boxes in the current band with those in the
* previous one. We are guaranteed that the current band extends to
- * the end of the rects array. Used only by miRegionOp.
+ * the end of the rects array. Used only by RegionOp.
*
* Results:
* The new index for the previous band.
@@ -427,7 +393,7 @@ miRegionCopy(RegionPtr dst, RegionPtr src) *-----------------------------------------------------------------------
*/
_X_INLINE static int
-miCoalesce (
+RegionCoalesce (
RegionPtr pReg, /* Region to coalesce */
int prevStart, /* Index of start of previous band */
int curStart) /* Index of start of current band */
@@ -448,8 +414,8 @@ miCoalesce ( * The bands may only be coalesced if the bottom of the previous
* matches the top scanline of the current.
*/
- pPrevBox = REGION_BOX(pReg, prevStart);
- pCurBox = REGION_BOX(pReg, curStart);
+ pPrevBox = RegionBox(pReg, prevStart);
+ pCurBox = RegionBox(pReg, curStart);
if (pPrevBox->y2 != pCurBox->y1) return curStart;
/*
@@ -462,7 +428,7 @@ miCoalesce ( do {
if ((pPrevBox->x1 != pCurBox->x1) || (pPrevBox->x2 != pCurBox->x2)) {
- return (curStart);
+ return curStart;
}
pPrevBox++;
pCurBox++;
@@ -484,18 +450,18 @@ miCoalesce ( }
-/* Quicky macro to avoid trivial reject procedure calls to miCoalesce */
+/* Quicky macro to avoid trivial reject procedure calls to RegionCoalesce */
#define Coalesce(newReg, prevBand, curBand) \
if (curBand - prevBand == newReg->data->numRects - curBand) { \
- prevBand = miCoalesce(newReg, prevBand, curBand); \
+ prevBand = RegionCoalesce(newReg, prevBand, curBand); \
} else { \
prevBand = curBand; \
}
/*-
*-----------------------------------------------------------------------
- * miAppendNonO --
+ * RegionAppendNonO --
* Handle a non-overlapping band for the union and subtract operations.
* Just adds the (top/bottom-clipped) rectangles into the region.
* Doesn't have to check for subsumption or anything.
@@ -511,7 +477,7 @@ miCoalesce ( */
_X_INLINE static Bool
-miAppendNonO (
+RegionAppendNonO (
RegionPtr pReg,
BoxPtr r,
BoxPtr rEnd,
@@ -528,7 +494,7 @@ miAppendNonO ( /* Make sure we have enough space for all rectangles to be added */
RECTALLOC(pReg, newRects);
- pNextRect = REGION_TOP(pReg);
+ pNextRect = RegionTop(pReg);
pReg->data->numRects += newRects;
do {
assert(r->x1 < r->x2);
@@ -553,7 +519,7 @@ miAppendNonO ( int newRects; \
if ((newRects = rEnd - r)) { \
RECTALLOC(newReg, newRects); \
- memmove((char *)REGION_TOP(newReg),(char *)r, \
+ memmove((char *)RegionTop(newReg),(char *)r, \
newRects * sizeof(BoxRec)); \
newReg->data->numRects += newRects; \
} \
@@ -561,9 +527,9 @@ miAppendNonO ( /*-
*-----------------------------------------------------------------------
- * miRegionOp --
- * Apply an operation to two regions. Called by miUnion, miInverse,
- * miSubtract, miIntersect.... Both regions MUST have at least one
+ * RegionOp --
+ * Apply an operation to two regions. Called by RegionUnion, RegionInverse,
+ * RegionSubtract, RegionIntersect.... Both regions MUST have at least one
* rectangle, and cannot be the same object.
*
* Results:
@@ -599,7 +565,7 @@ typedef Bool (*OverlapProcPtr)( Bool *pOverlap);
static Bool
-miRegionOp(
+RegionOp(
RegionPtr newReg, /* Place to store result */
RegionPtr reg1, /* First region in operation */
RegionPtr reg2, /* 2d region in operation */
@@ -634,8 +600,8 @@ miRegionOp( /*
* Break any region computed from a broken region
*/
- if (REGION_NAR (reg1) || REGION_NAR(reg2))
- return miRegionBreak (newReg);
+ if (RegionNar (reg1) || RegionNar(reg2))
+ return RegionBreak (newReg);
/*
* Initialization:
@@ -645,11 +611,11 @@ miRegionOp( * another array of rectangles for it to use.
*/
- r1 = REGION_RECTS(reg1);
- newSize = REGION_NUM_RECTS(reg1);
+ r1 = RegionRects(reg1);
+ newSize = RegionNumRects(reg1);
r1End = r1 + newSize;
- numRects = REGION_NUM_RECTS(reg2);
- r2 = REGION_RECTS(reg2);
+ numRects = RegionNumRects(reg2);
+ r2 = RegionRects(reg2);
r2End = r2 + numRects;
assert(r1 != r1End);
assert(r2 != r2End);
@@ -659,18 +625,18 @@ miRegionOp( ((newReg == reg2) && (numRects > 1)))
{
oldData = newReg->data;
- newReg->data = &miEmptyData;
+ newReg->data = &RegionEmptyData;
}
/* guess at new size */
if (numRects > newSize)
newSize = numRects;
newSize <<= 1;
if (!newReg->data)
- newReg->data = &miEmptyData;
+ newReg->data = &RegionEmptyData;
else if (newReg->data->size)
newReg->data->numRects = 0;
if (newSize > newReg->data->size)
- if (!miRectAlloc(newReg, newSize))
+ if (!RegionRectAlloc(newReg, newSize))
return FALSE;
/*
@@ -691,7 +657,7 @@ miRegionOp( /*
* prevBand serves to mark the start of the previous band so rectangles
- * can be coalesced into larger rectangles. qv. miCoalesce, above.
+ * can be coalesced into larger rectangles. qv. RegionCoalesce, above.
* In the beginning, there is no previous band, so prevBand == curBand
* (curBand is set later on, of course, but the first band will always
* start at index 0). prevBand and curBand must be indices because of
@@ -728,7 +694,7 @@ miRegionOp( bot = min(r1->y2, r2y1);
if (top != bot) {
curBand = newReg->data->numRects;
- miAppendNonO(newReg, r1, r1BandEnd, top, bot);
+ RegionAppendNonO(newReg, r1, r1BandEnd, top, bot);
Coalesce(newReg, prevBand, curBand);
}
}
@@ -739,7 +705,7 @@ miRegionOp( bot = min(r2->y2, r1y1);
if (top != bot) {
curBand = newReg->data->numRects;
- miAppendNonO(newReg, r2, r2BandEnd, top, bot);
+ RegionAppendNonO(newReg, r2, r2BandEnd, top, bot);
Coalesce(newReg, prevBand, curBand);
}
}
@@ -781,7 +747,7 @@ miRegionOp( /* Do first nonOverlap1Func call, which may be able to coalesce */
FindBand(r1, r1BandEnd, r1End, r1y1);
curBand = newReg->data->numRects;
- miAppendNonO(newReg, r1, r1BandEnd, max(r1y1, ybot), r1->y2);
+ RegionAppendNonO(newReg, r1, r1BandEnd, max(r1y1, ybot), r1->y2);
Coalesce(newReg, prevBand, curBand);
/* Just append the rest of the boxes */
AppendRegions(newReg, r1BandEnd, r1End);
@@ -790,23 +756,22 @@ miRegionOp( /* Do first nonOverlap2Func call, which may be able to coalesce */
FindBand(r2, r2BandEnd, r2End, r2y1);
curBand = newReg->data->numRects;
- miAppendNonO(newReg, r2, r2BandEnd, max(r2y1, ybot), r2->y2);
+ RegionAppendNonO(newReg, r2, r2BandEnd, max(r2y1, ybot), r2->y2);
Coalesce(newReg, prevBand, curBand);
/* Append rest of boxes */
AppendRegions(newReg, r2BandEnd, r2End);
}
- if (oldData)
- free(oldData);
+ free(oldData);
if (!(numRects = newReg->data->numRects))
{
xfreeData(newReg);
- newReg->data = &miEmptyData;
+ newReg->data = &RegionEmptyData;
}
else if (numRects == 1)
{
- newReg->extents = *REGION_BOXPTR(newReg);
+ newReg->extents = *RegionBoxptr(newReg);
xfreeData(newReg);
newReg->data = NULL;
}
@@ -820,10 +785,10 @@ miRegionOp( /*-
*-----------------------------------------------------------------------
- * miSetExtents --
+ * RegionSetExtents --
* Reset the extents of a region to what they should be. Called by
- * miSubtract and miIntersect as they can't figure it out along the
- * way or do so easily, as miUnion can.
+ * Subtract and Intersect as they can't figure it out along the
+ * way or do so easily, as Union can.
*
* Results:
* None.
@@ -834,7 +799,7 @@ miRegionOp( *-----------------------------------------------------------------------
*/
static void
-miSetExtents (RegionPtr pReg)
+RegionSetExtents (RegionPtr pReg)
{
BoxPtr pBox, pBoxEnd;
@@ -847,8 +812,8 @@ miSetExtents (RegionPtr pReg) return;
}
- pBox = REGION_BOXPTR(pReg);
- pBoxEnd = REGION_END(pReg);
+ pBox = RegionBoxptr(pReg);
+ pBoxEnd = RegionEnd(pReg);
/*
* Since pBox is the first rectangle in the region, it must have the
@@ -879,8 +844,8 @@ miSetExtents (RegionPtr pReg) *====================================================================*/
/*-
*-----------------------------------------------------------------------
- * miIntersectO --
- * Handle an overlapping band for miIntersect.
+ * RegionIntersectO --
+ * Handle an overlapping band for RegionIntersect.
*
* Results:
* TRUE if successful.
@@ -891,15 +856,6 @@ miSetExtents (RegionPtr pReg) *-----------------------------------------------------------------------
*/
/*ARGSUSED*/
-Bool
-miIntersect(
- RegionPtr newReg, /* destination Region */
- RegionPtr reg1,
- RegionPtr reg2 /* source regions */
- )
-{
- return pixman_region_intersect (newReg, reg1, reg2);
-}
#define MERGERECT(r) \
{ \
@@ -922,7 +878,7 @@ miIntersect( /*-
*-----------------------------------------------------------------------
- * miUnionO --
+ * RegionUnionO --
* Handle an overlapping band for the union operation. Picks the
* left-most rectangle each time and merges it into the region.
*
@@ -936,7 +892,7 @@ miIntersect( *-----------------------------------------------------------------------
*/
static Bool
-miUnionO (
+RegionUnionO (
RegionPtr pReg,
BoxPtr r1,
BoxPtr r1End,
@@ -953,7 +909,7 @@ miUnionO ( assert (y1 < y2);
assert(r1 != r1End && r2 != r2End);
- pNextRect = REGION_TOP(pReg);
+ pNextRect = RegionTop(pReg);
/* Start off current rectangle */
if (r1->x1 < r2->x1)
@@ -995,29 +951,19 @@ miUnionO ( return TRUE;
}
-Bool
-miUnion(
- RegionPtr newReg, /* destination Region */
- RegionPtr reg1,
- RegionPtr reg2 /* source regions */
- )
-{
- return pixman_region_union (newReg, reg1, reg2);
-}
-
/*======================================================================
* Batch Rectangle Union
*====================================================================*/
/*-
*-----------------------------------------------------------------------
- * miRegionAppend --
+ * RegionAppend --
*
* "Append" the rgn rectangles onto the end of dstrgn, maintaining
* knowledge of YX-banding when it's easy. Otherwise, dstrgn just
* becomes a non-y-x-banded random collection of rectangles, and not
* yet a true region. After a sequence of appends, the caller must
- * call miRegionValidate to ensure that a valid region is constructed.
+ * call RegionValidate to ensure that a valid region is constructed.
*
* Results:
* TRUE if successful.
@@ -1027,32 +973,32 @@ miUnion( *
*/
Bool
-miRegionAppend(RegionPtr dstrgn, RegionPtr rgn)
+RegionAppend(RegionPtr dstrgn, RegionPtr rgn)
{
int numRects, dnumRects, size;
BoxPtr new, old;
Bool prepend;
- if (REGION_NAR(rgn))
- return miRegionBreak (dstrgn);
+ if (RegionNar(rgn))
+ return RegionBreak (dstrgn);
- if (!rgn->data && (dstrgn->data == &miEmptyData))
+ if (!rgn->data && (dstrgn->data == &RegionEmptyData))
{
dstrgn->extents = rgn->extents;
dstrgn->data = NULL;
return TRUE;
}
- numRects = REGION_NUM_RECTS(rgn);
+ numRects = RegionNumRects(rgn);
if (!numRects)
return TRUE;
prepend = FALSE;
size = numRects;
- dnumRects = REGION_NUM_RECTS(dstrgn);
+ dnumRects = RegionNumRects(dstrgn);
if (!dnumRects && (size < 200))
size = 200; /* XXX pick numbers out of a hat */
RECTALLOC(dstrgn, size);
- old = REGION_RECTS(rgn);
+ old = RegionRects(rgn);
if (!dnumRects)
dstrgn->extents = rgn->extents;
else if (dstrgn->extents.x2 > dstrgn->extents.x1)
@@ -1060,7 +1006,7 @@ miRegionAppend(RegionPtr dstrgn, RegionPtr rgn) BoxPtr first, last;
first = old;
- last = REGION_BOXPTR(dstrgn) + (dnumRects - 1);
+ last = RegionBoxptr(dstrgn) + (dnumRects - 1);
if ((first->y1 > last->y2) ||
((first->y1 == last->y1) && (first->y2 == last->y2) &&
(first->x1 > last->x2)))
@@ -1073,7 +1019,7 @@ miRegionAppend(RegionPtr dstrgn, RegionPtr rgn) }
else
{
- first = REGION_BOXPTR(dstrgn);
+ first = RegionBoxptr(dstrgn);
last = old + (numRects - 1);
if ((first->y1 > last->y2) ||
((first->y1 == last->y1) && (first->y2 == last->y2) &&
@@ -1092,16 +1038,16 @@ miRegionAppend(RegionPtr dstrgn, RegionPtr rgn) }
if (prepend)
{
- new = REGION_BOX(dstrgn, numRects);
+ new = RegionBox(dstrgn, numRects);
if (dnumRects == 1)
- *new = *REGION_BOXPTR(dstrgn);
+ *new = *RegionBoxptr(dstrgn);
else
- memmove((char *)new,(char *)REGION_BOXPTR(dstrgn),
+ memmove((char *)new,(char *)RegionBoxptr(dstrgn),
dnumRects * sizeof(BoxRec));
- new = REGION_BOXPTR(dstrgn);
+ new = RegionBoxptr(dstrgn);
}
else
- new = REGION_BOXPTR(dstrgn) + dnumRects;
+ new = RegionBoxptr(dstrgn) + dnumRects;
if (numRects == 1)
*new = *old;
else
@@ -1180,7 +1126,7 @@ QuickSortRects( /*-
*-----------------------------------------------------------------------
- * miRegionValidate --
+ * RegionValidate --
*
* Take a ``region'' which is a non-y-x-banded random collection of
* rectangles, and compute a nice region which is the union of all the
@@ -1204,14 +1150,14 @@ QuickSortRects( * or a coalescing into 1 box (ala Menus).
*
* Step 3. Merge the separate regions down to a single region by calling
- * miUnion. Maximize the work each miUnion call does by using
+ * Union. Maximize the work each Union call does by using
* a binary merge.
*
*-----------------------------------------------------------------------
*/
Bool
-miRegionValidate(RegionPtr badreg, Bool *pOverlap)
+RegionValidate(RegionPtr badreg, Bool *pOverlap)
{
/* Descriptor for regions under construction in Step 2. */
typedef struct {
@@ -1242,7 +1188,7 @@ miRegionValidate(RegionPtr badreg, Bool *pOverlap) numRects = badreg->data->numRects;
if (!numRects)
{
- if (REGION_NAR(badreg))
+ if (RegionNar(badreg))
return FALSE;
good(badreg);
return TRUE;
@@ -1263,7 +1209,7 @@ miRegionValidate(RegionPtr badreg, Bool *pOverlap) }
/* Step 1: Sort the rects array into ascending (y1, x1) order */
- QuickSortRects(REGION_BOXPTR(badreg), numRects);
+ QuickSortRects(RegionBoxptr(badreg), numRects);
/* Step 2: Scatter the sorted array into the minimum number of regions */
@@ -1271,13 +1217,13 @@ miRegionValidate(RegionPtr badreg, Bool *pOverlap) /* Note that step 2 code will never overflow the ri[0].reg rects array */
ri = (RegionInfo *) malloc(4 * sizeof(RegionInfo));
if (!ri)
- return miRegionBreak (badreg);
+ return RegionBreak (badreg);
sizeRI = 4;
numRI = 1;
ri[0].prevBand = 0;
ri[0].curBand = 0;
ri[0].reg = *badreg;
- box = REGION_BOXPTR(&ri[0].reg);
+ box = RegionBoxptr(&ri[0].reg);
ri[0].reg.extents = *box;
ri[0].reg.data->numRects = 1;
@@ -1294,7 +1240,7 @@ miRegionValidate(RegionPtr badreg, Bool *pOverlap) for (j = numRI, rit = ri; --j >= 0; rit++)
{
reg = &rit->reg;
- riBox = REGION_END(reg);
+ riBox = RegionEnd(reg);
if (box->y1 == riBox->y1 && box->y2 == riBox->y2)
{
@@ -1308,7 +1254,7 @@ miRegionValidate(RegionPtr badreg, Bool *pOverlap) else
{
RECTALLOC_BAIL(reg, 1, bail);
- *REGION_TOP(reg) = *box;
+ *RegionTop(reg) = *box;
reg->data->numRects++;
}
goto NextRect; /* So sue me */
@@ -1321,7 +1267,7 @@ miRegionValidate(RegionPtr badreg, Bool *pOverlap) Coalesce(reg, rit->prevBand, rit->curBand);
rit->curBand = reg->data->numRects;
RECTALLOC_BAIL(reg, 1, bail);
- *REGION_TOP(reg) = *box;
+ *RegionTop(reg) = *box;
reg->data->numRects++;
goto NextRect;
}
@@ -1344,7 +1290,7 @@ miRegionValidate(RegionPtr badreg, Bool *pOverlap) rit->curBand = 0;
rit->reg.extents = *box;
rit->reg.data = NULL;
- if (!miRectAlloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */
+ if (!RegionRectAlloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */
goto bail;
NextRect: ;
} /* for i */
@@ -1355,7 +1301,7 @@ NextRect: ; for (j = numRI, rit = ri; --j >= 0; rit++)
{
reg = &rit->reg;
- riBox = REGION_END(reg);
+ riBox = RegionEnd(reg);
reg->extents.y2 = riBox->y2;
if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2;
Coalesce(reg, rit->prevBand, rit->curBand);
@@ -1374,7 +1320,7 @@ NextRect: ; {
reg = &ri[j].reg;
hreg = &ri[j+half].reg;
- if (!miRegionOp(reg, reg, hreg, miUnionO, TRUE, TRUE, pOverlap))
+ if (!RegionOp(reg, reg, hreg, RegionUnionO, TRUE, TRUE, pOverlap))
ret = FALSE;
if (hreg->extents.x1 < reg->extents.x1)
reg->extents.x1 = hreg->extents.x1;
@@ -1396,11 +1342,11 @@ bail: for (i = 0; i < numRI; i++)
xfreeData(&ri[i].reg);
free(ri);
- return miRegionBreak (badreg);
+ return RegionBreak (badreg);
}
RegionPtr
-miRectsToRegion(int nrects, xRectangle *prect, int ctype)
+RegionFromRects(int nrects, xRectangle *prect, int ctype)
{
RegionPtr pRgn;
@@ -1409,8 +1355,8 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype) int i;
int x1, y1, x2, y2;
- pRgn = miRegionCreate(NullBox, 0);
- if (REGION_NAR (pRgn))
+ pRgn = RegionCreate(NullBox, 0);
+ if (RegionNar (pRgn))
return pRgn;
if (!nrects)
return pRgn;
@@ -1435,7 +1381,7 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype) pData = xallocData(nrects);
if (!pData)
{
- miRegionBreak (pRgn);
+ RegionBreak (pRgn);
return pRgn;
}
pBox = (BoxPtr) (pData + 1);
@@ -1465,10 +1411,10 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype) {
Bool overlap; /* result ignored */
pRgn->extents.x1 = pRgn->extents.x2 = 0;
- miRegionValidate(pRgn, &overlap);
+ RegionValidate(pRgn, &overlap);
}
else
- miSetExtents(pRgn);
+ RegionSetExtents(pRgn);
good(pRgn);
}
else
@@ -1478,138 +1424,6 @@ miRectsToRegion(int nrects, xRectangle *prect, int ctype) return pRgn;
}
-/*======================================================================
- * Region Subtraction
- *====================================================================*/
-
-
-/*-
- *-----------------------------------------------------------------------
- * miSubtractO --
- * Overlapping band subtraction. x1 is the left-most point not yet
- * checked.
- *
- * Results:
- * TRUE if successful.
- *
- * Side Effects:
- * pReg may have rectangles added to it.
- *
- *-----------------------------------------------------------------------
- */
-/*ARGSUSED*/
-
-/*-
- *-----------------------------------------------------------------------
- * miSubtract --
- * Subtract regS from regM and leave the result in regD.
- * S stands for subtrahend, M for minuend and D for difference.
- *
- * Results:
- * TRUE if successful.
- *
- * Side Effects:
- * regD is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-Bool
-miSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS)
-{
- return pixman_region_subtract (regD, regM, regS);
-}
-
-/*======================================================================
- * Region Inversion
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * miInverse --
- * Take a region and a box and return a region that is everything
- * in the box but not in the region. The careful reader will note
- * that this is the same as subtracting the region from the box...
- *
- * Results:
- * TRUE.
- *
- * Side Effects:
- * newReg is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-Bool
-miInverse(
- RegionPtr newReg, /* Destination region */
- RegionPtr reg1, /* Region to invert */
- BoxPtr invRect /* Bounding box for inversion */
- )
-{
- return pixman_region_inverse (newReg, reg1, invRect);
-}
-int
-miRectIn(RegionPtr region, BoxPtr prect)
-{
- return pixman_region_contains_rectangle (region, prect);
-}
-
-/* TranslateRegion(pReg, x, y)
- translates in place
-*/
-
-void
-miTranslateRegion(RegionPtr pReg, int x, int y)
-{
- pixman_region_translate (pReg, x, y);
-}
-
-void
-miRegionReset(RegionPtr pReg, BoxPtr pBox)
-{
- pixman_region_reset (pReg, pBox);
-}
-
-Bool
-miPointInRegion(
- RegionPtr pReg,
- int x,
- int y,
- BoxPtr box /* "return" value */
- )
-{
- return pixman_region_contains_point (pReg, x, y, box);
-}
-
-Bool
-miRegionNotEmpty(RegionPtr pReg)
-{
- return pixman_region_not_empty (pReg);
-}
-
-Bool
-miRegionBroken(RegionPtr pReg)
-{
- good(pReg);
- return (REGION_NAR(pReg));
-}
-
-void
-miRegionEmpty(RegionPtr pReg)
-{
- good(pReg);
- xfreeData(pReg);
- pReg->extents.x2 = pReg->extents.x1;
- pReg->extents.y2 = pReg->extents.y1;
- pReg->data = &miEmptyData;
-}
-
-BoxPtr
-miRegionExtents(RegionPtr pReg)
-{
- good(pReg);
- return(&pReg->extents);
-}
-
#define ExchangeSpans(a, b) \
{ \
DDXPointRec tpt; \
@@ -1729,7 +1543,7 @@ static void QuickSortSpans( */
int
-miClipSpans(
+RegionClipSpans(
RegionPtr prgnDst,
DDXPointPtr ppt,
int *pwidth,
@@ -1795,7 +1609,7 @@ miClipSpans( if ((! fSorted) && (nspans > 1))
QuickSortSpans(ppt, pwidth, nspans);
- pboxBandStart = REGION_BOXPTR(prgnDst);
+ pboxBandStart = RegionBoxptr(prgnDst);
pboxLast = pboxBandStart + numRects;
NextBand();
@@ -1841,5 +1655,5 @@ miClipSpans( }
}
}
- return (pwidthNew - pwidthNewStart);
+ return pwidthNew - pwidthNewStart;
}
diff --git a/xorg-server/dix/resource.c b/xorg-server/dix/resource.c index 5364dcc3b..b66348108 100644 --- a/xorg-server/dix/resource.c +++ b/xorg-server/dix/resource.c @@ -255,8 +255,6 @@ CreateNewResourceType(DeleteType deleteFunc, char *name) types = realloc(resourceTypes, (next + 1) * sizeof(*resourceTypes));
if (!types)
return 0;
- if (!dixRegisterPrivateOffset(next, -1))
- return 0;
lastResourceType = next;
resourceTypes = types;
@@ -904,7 +902,7 @@ LegalNewID(XID id, ClientPtr client) rc = dixLookupResourceByClass(&val, id, RC_ANY, serverClient,
DixGetAttrAccess);
- return (rc == BadValue);
+ return rc == BadValue;
}
return FALSE;
}
diff --git a/xorg-server/dix/selection.c b/xorg-server/dix/selection.c index 8763a2d5a..428408f8e 100644 --- a/xorg-server/dix/selection.c +++ b/xorg-server/dix/selection.c @@ -94,8 +94,7 @@ InitSelections(void) pSel = CurrentSelections;
while (pSel) {
pNextSel = pSel->next;
- dixFreePrivates(pSel->devPrivates);
- free(pSel);
+ dixFreeObjectWithPrivates(pSel, PRIVATE_SELECTION);
pSel = pNextSel;
}
diff --git a/xorg-server/dix/swapreq.c b/xorg-server/dix/swapreq.c index 5d7d71c8f..4fbb6ebda 100644 --- a/xorg-server/dix/swapreq.c +++ b/xorg-server/dix/swapreq.c @@ -1,1099 +1,1099 @@ -/************************************************************ - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -********************************************************/ - - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/Xprotostr.h> -#include "misc.h" -#include "dixstruct.h" -#include "extnsionst.h" /* for SendEvent */ -#include "swapreq.h" - -/* Thanks to Jack Palevich for testing and subsequently rewriting all this */ - -/* Byte swap a list of longs */ -void -SwapLongs (CARD32 *list, unsigned long count) -{ - char n; - - while (count >= 8) { - swapl(list+0, n); - swapl(list+1, n); - swapl(list+2, n); - swapl(list+3, n); - swapl(list+4, n); - swapl(list+5, n); - swapl(list+6, n); - swapl(list+7, n); - list += 8; - count -= 8; - } - if (count != 0) { - do { - swapl(list, n); - list++; - } while (--count != 0); - } -} - -/* Byte swap a list of shorts */ -void -SwapShorts (short *list, unsigned long count) -{ - char n; - - while (count >= 16) { - swaps(list+0, n); - swaps(list+1, n); - swaps(list+2, n); - swaps(list+3, n); - swaps(list+4, n); - swaps(list+5, n); - swaps(list+6, n); - swaps(list+7, n); - swaps(list+8, n); - swaps(list+9, n); - swaps(list+10, n); - swaps(list+11, n); - swaps(list+12, n); - swaps(list+13, n); - swaps(list+14, n); - swaps(list+15, n); - list += 16; - count -= 16; - } - if (count != 0) { - do { - swaps(list, n); - list++; - } while (--count != 0); - } -} - -/* The following is used for all requests that have - no fields to be swapped (except "length") */ -int -SProcSimpleReq(ClientPtr client) -{ - char n; - - REQUEST(xReq); - swaps(&stuff->length, n); - return(*ProcVector[stuff->reqType])(client); -} - -/* The following is used for all requests that have - only a single 32-bit field to be swapped, coming - right after the "length" field */ -int -SProcResourceReq(ClientPtr client) -{ - char n; - - REQUEST(xResourceReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xResourceReq); /* not EXACT */ - swapl(&stuff->id, n); - return(*ProcVector[stuff->reqType])(client); -} - -int -SProcCreateWindow(ClientPtr client) -{ - char n; - - REQUEST(xCreateWindowReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xCreateWindowReq); - swapl(&stuff->wid, n); - swapl(&stuff->parent, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swaps(&stuff->borderWidth, n); - swaps(&stuff->class, n); - swapl(&stuff->visual, n); - swapl(&stuff->mask, n); - SwapRestL(stuff); - return((* ProcVector[X_CreateWindow])(client)); -} - -int -SProcChangeWindowAttributes(ClientPtr client) -{ - char n; - - REQUEST(xChangeWindowAttributesReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); - swapl(&stuff->window, n); - swapl(&stuff->valueMask, n); - SwapRestL(stuff); - return((* ProcVector[X_ChangeWindowAttributes])(client)); -} - -int -SProcReparentWindow(ClientPtr client) -{ - char n; - REQUEST(xReparentWindowReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xReparentWindowReq); - swapl(&stuff->window, n); - swapl(&stuff->parent, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - return((* ProcVector[X_ReparentWindow])(client)); -} - -int -SProcConfigureWindow(ClientPtr client) -{ - char n; - REQUEST(xConfigureWindowReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); - swapl(&stuff->window, n); - swaps(&stuff->mask, n); - SwapRestL(stuff); - return((* ProcVector[X_ConfigureWindow])(client)); - -} - - -int -SProcInternAtom(ClientPtr client) -{ - char n; - REQUEST(xInternAtomReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xInternAtomReq); - swaps(&stuff->nbytes, n); - return((* ProcVector[X_InternAtom])(client)); -} - -int -SProcChangeProperty(ClientPtr client) -{ - char n; - REQUEST(xChangePropertyReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xChangePropertyReq); - swapl(&stuff->window, n); - swapl(&stuff->property, n); - swapl(&stuff->type, n); - swapl(&stuff->nUnits, n); - switch ( stuff->format ) { - case 8 : - break; - case 16: - SwapRestS(stuff); - break; - case 32: - SwapRestL(stuff); - break; - } - return((* ProcVector[X_ChangeProperty])(client)); -} - -int -SProcDeleteProperty(ClientPtr client) -{ - char n; - REQUEST(xDeletePropertyReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xDeletePropertyReq); - swapl(&stuff->window, n); - swapl(&stuff->property, n); - return((* ProcVector[X_DeleteProperty])(client)); - -} - -int -SProcGetProperty(ClientPtr client) -{ - char n; - REQUEST(xGetPropertyReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xGetPropertyReq); - swapl(&stuff->window, n); - swapl(&stuff->property, n); - swapl(&stuff->type, n); - swapl(&stuff->longOffset, n); - swapl(&stuff->longLength, n); - return((* ProcVector[X_GetProperty])(client)); -} - -int -SProcSetSelectionOwner(ClientPtr client) -{ - char n; - REQUEST(xSetSelectionOwnerReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); - swapl(&stuff->window, n); - swapl(&stuff->selection, n); - swapl(&stuff->time, n); - return((* ProcVector[X_SetSelectionOwner])(client)); -} - -int -SProcConvertSelection(ClientPtr client) -{ - char n; - REQUEST(xConvertSelectionReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xConvertSelectionReq); - swapl(&stuff->requestor, n); - swapl(&stuff->selection, n); - swapl(&stuff->target, n); - swapl(&stuff->property, n); - swapl(&stuff->time, n); - return((* ProcVector[X_ConvertSelection])(client)); -} - -int -SProcSendEvent(ClientPtr client) -{ - char n; - xEvent eventT; - EventSwapPtr proc; - REQUEST(xSendEventReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xSendEventReq); - swapl(&stuff->destination, n); - swapl(&stuff->eventMask, n); - - /* Swap event */ - proc = EventSwapVector[stuff->event.u.u.type & 0177]; - if (!proc || proc == NotImplemented) /* no swapping proc; invalid event type? */ - return (BadValue); - (*proc)(&stuff->event, &eventT); - stuff->event = eventT; - - return((* ProcVector[X_SendEvent])(client)); -} - -int -SProcGrabPointer(ClientPtr client) -{ - char n; - REQUEST(xGrabPointerReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xGrabPointerReq); - swapl(&stuff->grabWindow, n); - swaps(&stuff->eventMask, n); - swapl(&stuff->confineTo, n); - swapl(&stuff->cursor, n); - swapl(&stuff->time, n); - return((* ProcVector[X_GrabPointer])(client)); -} - -int -SProcGrabButton(ClientPtr client) -{ - char n; - REQUEST(xGrabButtonReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xGrabButtonReq); - swapl(&stuff->grabWindow, n); - swaps(&stuff->eventMask, n); - swapl(&stuff->confineTo, n); - swapl(&stuff->cursor, n); - swaps(&stuff->modifiers, n); - return((* ProcVector[X_GrabButton])(client)); -} - -int -SProcUngrabButton(ClientPtr client) -{ - char n; - REQUEST(xUngrabButtonReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xUngrabButtonReq); - swapl(&stuff->grabWindow, n); - swaps(&stuff->modifiers, n); - return((* ProcVector[X_UngrabButton])(client)); -} - -int -SProcChangeActivePointerGrab(ClientPtr client) -{ - char n; - REQUEST(xChangeActivePointerGrabReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq); - swapl(&stuff->cursor, n); - swapl(&stuff->time, n); - swaps(&stuff->eventMask, n); - return((* ProcVector[X_ChangeActivePointerGrab])(client)); -} - -int -SProcGrabKeyboard(ClientPtr client) -{ - char n; - REQUEST(xGrabKeyboardReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xGrabKeyboardReq); - swapl(&stuff->grabWindow, n); - swapl(&stuff->time, n); - return((* ProcVector[X_GrabKeyboard])(client)); -} - -int -SProcGrabKey(ClientPtr client) -{ - char n; - REQUEST(xGrabKeyReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xGrabKeyReq); - swapl(&stuff->grabWindow, n); - swaps(&stuff->modifiers, n); - return((* ProcVector[X_GrabKey])(client)); -} - -int -SProcUngrabKey(ClientPtr client) -{ - char n; - REQUEST(xUngrabKeyReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xUngrabKeyReq); - swapl(&stuff->grabWindow, n); - swaps(&stuff->modifiers, n); - return((* ProcVector[X_UngrabKey])(client)); -} - -int -SProcGetMotionEvents(ClientPtr client) -{ - char n; - REQUEST(xGetMotionEventsReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xGetMotionEventsReq); - swapl(&stuff->window, n); - swapl(&stuff->start, n); - swapl(&stuff->stop, n); - return((* ProcVector[X_GetMotionEvents])(client)); -} - -int -SProcTranslateCoords(ClientPtr client) -{ - char n; - REQUEST(xTranslateCoordsReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xTranslateCoordsReq); - swapl(&stuff->srcWid, n); - swapl(&stuff->dstWid, n); - swaps(&stuff->srcX, n); - swaps(&stuff->srcY, n); - return((* ProcVector[X_TranslateCoords])(client)); -} - -int -SProcWarpPointer(ClientPtr client) -{ - char n; - REQUEST(xWarpPointerReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xWarpPointerReq); - swapl(&stuff->srcWid, n); - swapl(&stuff->dstWid, n); - swaps(&stuff->srcX, n); - swaps(&stuff->srcY, n); - swaps(&stuff->srcWidth, n); - swaps(&stuff->srcHeight, n); - swaps(&stuff->dstX, n); - swaps(&stuff->dstY, n); - return((* ProcVector[X_WarpPointer])(client)); -} - -int -SProcSetInputFocus(ClientPtr client) -{ - char n; - REQUEST(xSetInputFocusReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xSetInputFocusReq); - swapl(&stuff->focus, n); - swapl(&stuff->time, n); - return((* ProcVector[X_SetInputFocus])(client)); -} - -int -SProcOpenFont(ClientPtr client) -{ - char n; - REQUEST(xOpenFontReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xOpenFontReq); - swapl(&stuff->fid, n); - swaps(&stuff->nbytes, n); - return((* ProcVector[X_OpenFont])(client)); -} - -int -SProcListFonts(ClientPtr client) -{ - char n; - REQUEST(xListFontsReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xListFontsReq); - swaps(&stuff->maxNames, n); - swaps(&stuff->nbytes, n); - return((* ProcVector[X_ListFonts])(client)); -} - -int -SProcListFontsWithInfo(ClientPtr client) -{ - char n; - REQUEST(xListFontsWithInfoReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xListFontsWithInfoReq); - swaps(&stuff->maxNames, n); - swaps(&stuff->nbytes, n); - return((* ProcVector[X_ListFontsWithInfo])(client)); -} - -int -SProcSetFontPath(ClientPtr client) -{ - char n; - REQUEST(xSetFontPathReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xSetFontPathReq); - swaps(&stuff->nFonts, n); - return((* ProcVector[X_SetFontPath])(client)); -} - -int -SProcCreatePixmap(ClientPtr client) -{ - char n; - REQUEST(xCreatePixmapReq); - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCreatePixmapReq); - swapl(&stuff->pid, n); - swapl(&stuff->drawable, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return((* ProcVector[X_CreatePixmap])(client)); -} - -int -SProcCreateGC(ClientPtr client) -{ - char n; - REQUEST(xCreateGCReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xCreateGCReq); - swapl(&stuff->gc, n); - swapl(&stuff->drawable, n); - swapl(&stuff->mask, n); - SwapRestL(stuff); - return((* ProcVector[X_CreateGC])(client)); -} - -int -SProcChangeGC(ClientPtr client) -{ - char n; - REQUEST(xChangeGCReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xChangeGCReq); - swapl(&stuff->gc, n); - swapl(&stuff->mask, n); - SwapRestL(stuff); - return((* ProcVector[X_ChangeGC])(client)); -} - -int -SProcCopyGC(ClientPtr client) -{ - char n; - REQUEST(xCopyGCReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCopyGCReq); - swapl(&stuff->srcGC, n); - swapl(&stuff->dstGC, n); - swapl(&stuff->mask, n); - return((* ProcVector[X_CopyGC])(client)); -} - -int -SProcSetDashes(ClientPtr client) -{ - char n; - REQUEST(xSetDashesReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xSetDashesReq); - swapl(&stuff->gc, n); - swaps(&stuff->dashOffset, n); - swaps(&stuff->nDashes, n); - return((* ProcVector[X_SetDashes])(client)); - -} - -int -SProcSetClipRectangles(ClientPtr client) -{ - char n; - REQUEST(xSetClipRectanglesReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); - swapl(&stuff->gc, n); - swaps(&stuff->xOrigin, n); - swaps(&stuff->yOrigin, n); - SwapRestS(stuff); - return((* ProcVector[X_SetClipRectangles])(client)); -} - -int -SProcClearToBackground(ClientPtr client) -{ - char n; - REQUEST(xClearAreaReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xClearAreaReq); - swapl(&stuff->window, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return((* ProcVector[X_ClearArea])(client)); -} - -int -SProcCopyArea(ClientPtr client) -{ - char n; - REQUEST(xCopyAreaReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCopyAreaReq); - swapl(&stuff->srcDrawable, n); - swapl(&stuff->dstDrawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->srcX, n); - swaps(&stuff->srcY, n); - swaps(&stuff->dstX, n); - swaps(&stuff->dstY, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return((* ProcVector[X_CopyArea])(client)); -} - -int -SProcCopyPlane(ClientPtr client) -{ - char n; - REQUEST(xCopyPlaneReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCopyPlaneReq); - swapl(&stuff->srcDrawable, n); - swapl(&stuff->dstDrawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->srcX, n); - swaps(&stuff->srcY, n); - swaps(&stuff->dstX, n); - swaps(&stuff->dstY, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swapl(&stuff->bitPlane, n); - return((* ProcVector[X_CopyPlane])(client)); -} - -/* The following routine is used for all Poly drawing requests - (except FillPoly, which uses a different request format) */ -int -SProcPoly(ClientPtr client) -{ - char n; - - REQUEST(xPolyPointReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xPolyPointReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - SwapRestS(stuff); - return((* ProcVector[stuff->reqType])(client)); -} - -/* cannot use SProcPoly for this one, because xFillPolyReq - is longer than xPolyPointReq, and we don't want to swap - the difference as shorts! */ -int -SProcFillPoly(ClientPtr client) -{ - char n; - - REQUEST(xFillPolyReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xFillPolyReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - SwapRestS(stuff); - return((* ProcVector[X_FillPoly])(client)); -} - -int -SProcPutImage(ClientPtr client) -{ - char n; - REQUEST(xPutImageReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xPutImageReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swaps(&stuff->dstX, n); - swaps(&stuff->dstY, n); - /* Image should already be swapped */ - return((* ProcVector[X_PutImage])(client)); - -} - -int -SProcGetImage(ClientPtr client) -{ - char n; - REQUEST(xGetImageReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xGetImageReq); - swapl(&stuff->drawable, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swapl(&stuff->planeMask, n); - return((* ProcVector[X_GetImage])(client)); -} - -/* ProcPolyText used for both PolyText8 and PolyText16 */ - -int -SProcPolyText(ClientPtr client) -{ - char n; - REQUEST(xPolyTextReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xPolyTextReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - return((* ProcVector[stuff->reqType])(client)); -} - -/* ProcImageText used for both ImageText8 and ImageText16 */ - -int -SProcImageText(ClientPtr client) -{ - char n; - REQUEST(xImageTextReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xImageTextReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - return((* ProcVector[stuff->reqType])(client)); -} - -int -SProcCreateColormap(ClientPtr client) -{ - char n; - REQUEST(xCreateColormapReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCreateColormapReq); - swapl(&stuff->mid, n); - swapl(&stuff->window, n); - swapl(&stuff->visual, n); - return((* ProcVector[X_CreateColormap])(client)); -} - - -int -SProcCopyColormapAndFree(ClientPtr client) -{ - char n; - REQUEST(xCopyColormapAndFreeReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); - swapl(&stuff->mid, n); - swapl(&stuff->srcCmap, n); - return((* ProcVector[X_CopyColormapAndFree])(client)); - -} - -int -SProcAllocColor(ClientPtr client) -{ - char n; - REQUEST(xAllocColorReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xAllocColorReq); - swapl(&stuff->cmap, n); - swaps(&stuff->red, n); - swaps(&stuff->green, n); - swaps(&stuff->blue, n); - return((* ProcVector[X_AllocColor])(client)); -} - -int -SProcAllocNamedColor(ClientPtr client) -{ - char n; - - REQUEST(xAllocNamedColorReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xAllocNamedColorReq); - swapl(&stuff->cmap, n); - swaps(&stuff->nbytes, n); - return((* ProcVector[X_AllocNamedColor])(client)); -} - -int -SProcAllocColorCells(ClientPtr client) -{ - char n; - REQUEST(xAllocColorCellsReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xAllocColorCellsReq); - swapl(&stuff->cmap, n); - swaps(&stuff->colors, n); - swaps(&stuff->planes, n); - return((* ProcVector[X_AllocColorCells])(client)); -} - -int -SProcAllocColorPlanes(ClientPtr client) -{ - char n; - REQUEST(xAllocColorPlanesReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xAllocColorPlanesReq); - swapl(&stuff->cmap, n); - swaps(&stuff->colors, n); - swaps(&stuff->red, n); - swaps(&stuff->green, n); - swaps(&stuff->blue, n); - return((* ProcVector[X_AllocColorPlanes])(client)); -} - -int -SProcFreeColors(ClientPtr client) -{ - char n; - REQUEST(xFreeColorsReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xFreeColorsReq); - swapl(&stuff->cmap, n); - swapl(&stuff->planeMask, n); - SwapRestL(stuff); - return((* ProcVector[X_FreeColors])(client)); - -} - -void -SwapColorItem(xColorItem *pItem) -{ - char n; - - swapl(&pItem->pixel, n); - swaps(&pItem->red, n); - swaps(&pItem->green, n); - swaps(&pItem->blue, n); -} - -int -SProcStoreColors(ClientPtr client) -{ - char n; - long count; - xColorItem *pItem; - - REQUEST(xStoreColorsReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xStoreColorsReq); - swapl(&stuff->cmap, n); - pItem = (xColorItem *) &stuff[1]; - for(count = LengthRestB(stuff)/sizeof(xColorItem); --count >= 0; ) - SwapColorItem(pItem++); - return((* ProcVector[X_StoreColors])(client)); -} - -int -SProcStoreNamedColor (ClientPtr client) -{ - char n; - REQUEST(xStoreNamedColorReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xStoreNamedColorReq); - swapl(&stuff->cmap, n); - swapl(&stuff->pixel, n); - swaps(&stuff->nbytes, n); - return((* ProcVector[X_StoreNamedColor])(client)); -} - -int -SProcQueryColors (ClientPtr client) -{ - char n; - REQUEST(xQueryColorsReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xQueryColorsReq); - swapl(&stuff->cmap, n); - SwapRestL(stuff); - return((* ProcVector[X_QueryColors])(client)); -} - -int -SProcLookupColor (ClientPtr client) -{ - char n; - REQUEST(xLookupColorReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xLookupColorReq); - swapl(&stuff->cmap, n); - swaps(&stuff->nbytes, n); - return((* ProcVector[X_LookupColor])(client)); -} - -int -SProcCreateCursor (ClientPtr client) -{ - char n; - REQUEST(xCreateCursorReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCreateCursorReq); - swapl(&stuff->cid, n); - swapl(&stuff->source, n); - swapl(&stuff->mask, n); - swaps(&stuff->foreRed, n); - swaps(&stuff->foreGreen, n); - swaps(&stuff->foreBlue, n); - swaps(&stuff->backRed, n); - swaps(&stuff->backGreen, n); - swaps(&stuff->backBlue, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - return((* ProcVector[X_CreateCursor])(client)); -} - -int -SProcCreateGlyphCursor (ClientPtr client) -{ - char n; - REQUEST(xCreateGlyphCursorReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCreateGlyphCursorReq); - swapl(&stuff->cid, n); - swapl(&stuff->source, n); - swapl(&stuff->mask, n); - swaps(&stuff->sourceChar, n); - swaps(&stuff->maskChar, n); - swaps(&stuff->foreRed, n); - swaps(&stuff->foreGreen, n); - swaps(&stuff->foreBlue, n); - swaps(&stuff->backRed, n); - swaps(&stuff->backGreen, n); - swaps(&stuff->backBlue, n); - return((* ProcVector[X_CreateGlyphCursor])(client)); -} - - -int -SProcRecolorCursor (ClientPtr client) -{ - char n; - REQUEST(xRecolorCursorReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xRecolorCursorReq); - swapl(&stuff->cursor, n); - swaps(&stuff->foreRed, n); - swaps(&stuff->foreGreen, n); - swaps(&stuff->foreBlue, n); - swaps(&stuff->backRed, n); - swaps(&stuff->backGreen, n); - swaps(&stuff->backBlue, n); - return((* ProcVector[X_RecolorCursor])(client)); -} - -int -SProcQueryBestSize (ClientPtr client) -{ - char n; - REQUEST(xQueryBestSizeReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xQueryBestSizeReq); - swapl(&stuff->drawable, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return((* ProcVector[X_QueryBestSize])(client)); - -} - -int -SProcQueryExtension (ClientPtr client) -{ - char n; - REQUEST(xQueryExtensionReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xQueryExtensionReq); - swaps(&stuff->nbytes, n); - return((* ProcVector[X_QueryExtension])(client)); -} - -int -SProcChangeKeyboardMapping (ClientPtr client) -{ - char n; - REQUEST(xChangeKeyboardMappingReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); - SwapRestL(stuff); - return((* ProcVector[X_ChangeKeyboardMapping])(client)); -} - - -int -SProcChangeKeyboardControl (ClientPtr client) -{ - char n; - REQUEST(xChangeKeyboardControlReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq); - swapl(&stuff->mask, n); - SwapRestL(stuff); - return((* ProcVector[X_ChangeKeyboardControl])(client)); -} - -int -SProcChangePointerControl (ClientPtr client) -{ - char n; - REQUEST(xChangePointerControlReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xChangePointerControlReq); - swaps(&stuff->accelNum, n); - swaps(&stuff->accelDenum, n); - swaps(&stuff->threshold, n); - return((* ProcVector[X_ChangePointerControl])(client)); -} - - -int -SProcSetScreenSaver (ClientPtr client) -{ - char n; - REQUEST(xSetScreenSaverReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xSetScreenSaverReq); - swaps(&stuff->timeout, n); - swaps(&stuff->interval, n); - return((* ProcVector[X_SetScreenSaver])(client)); -} - -int -SProcChangeHosts (ClientPtr client) -{ - char n; - - REQUEST(xChangeHostsReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xChangeHostsReq); - swaps(&stuff->hostLength, n); - return((* ProcVector[X_ChangeHosts])(client)); - -} - -int SProcRotateProperties (ClientPtr client) -{ - char n; - REQUEST(xRotatePropertiesReq); - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xRotatePropertiesReq); - swapl(&stuff->window, n); - swaps(&stuff->nAtoms, n); - swaps(&stuff->nPositions, n); - SwapRestL(stuff); - return ((* ProcVector[X_RotateProperties])(client)); -} - -int -SProcNoOperation(ClientPtr client) -{ - char n; - REQUEST(xReq); - swaps(&stuff->length, n); - return ((* ProcVector[X_NoOperation])(client)); -} - -void -SwapConnClientPrefix(xConnClientPrefix *pCCP) -{ - char n; - - swaps(&pCCP->majorVersion, n); - swaps(&pCCP->minorVersion, n); - swaps(&pCCP->nbytesAuthProto, n); - swaps(&pCCP->nbytesAuthString, n); -} +/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xprotostr.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h" /* for SendEvent */
+#include "swapreq.h"
+
+/* Thanks to Jack Palevich for testing and subsequently rewriting all this */
+
+/* Byte swap a list of longs */
+void
+SwapLongs (CARD32 *list, unsigned long count)
+{
+ char n;
+
+ while (count >= 8) {
+ swapl(list+0, n);
+ swapl(list+1, n);
+ swapl(list+2, n);
+ swapl(list+3, n);
+ swapl(list+4, n);
+ swapl(list+5, n);
+ swapl(list+6, n);
+ swapl(list+7, n);
+ list += 8;
+ count -= 8;
+ }
+ if (count != 0) {
+ do {
+ swapl(list, n);
+ list++;
+ } while (--count != 0);
+ }
+}
+
+/* Byte swap a list of shorts */
+void
+SwapShorts (short *list, unsigned long count)
+{
+ char n;
+
+ while (count >= 16) {
+ swaps(list+0, n);
+ swaps(list+1, n);
+ swaps(list+2, n);
+ swaps(list+3, n);
+ swaps(list+4, n);
+ swaps(list+5, n);
+ swaps(list+6, n);
+ swaps(list+7, n);
+ swaps(list+8, n);
+ swaps(list+9, n);
+ swaps(list+10, n);
+ swaps(list+11, n);
+ swaps(list+12, n);
+ swaps(list+13, n);
+ swaps(list+14, n);
+ swaps(list+15, n);
+ list += 16;
+ count -= 16;
+ }
+ if (count != 0) {
+ do {
+ swaps(list, n);
+ list++;
+ } while (--count != 0);
+ }
+}
+
+/* The following is used for all requests that have
+ no fields to be swapped (except "length") */
+int
+SProcSimpleReq(ClientPtr client)
+{
+ char n;
+
+ REQUEST(xReq);
+ swaps(&stuff->length, n);
+ return(*ProcVector[stuff->reqType])(client);
+}
+
+/* The following is used for all requests that have
+ only a single 32-bit field to be swapped, coming
+ right after the "length" field */
+int
+SProcResourceReq(ClientPtr client)
+{
+ char n;
+
+ REQUEST(xResourceReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xResourceReq); /* not EXACT */
+ swapl(&stuff->id, n);
+ return(*ProcVector[stuff->reqType])(client);
+}
+
+int
+SProcCreateWindow(ClientPtr client)
+{
+ char n;
+
+ REQUEST(xCreateWindowReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
+ swapl(&stuff->wid, n);
+ swapl(&stuff->parent, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ swaps(&stuff->borderWidth, n);
+ swaps(&stuff->class, n);
+ swapl(&stuff->visual, n);
+ swapl(&stuff->mask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_CreateWindow])(client));
+}
+
+int
+SProcChangeWindowAttributes(ClientPtr client)
+{
+ char n;
+
+ REQUEST(xChangeWindowAttributesReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->valueMask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeWindowAttributes])(client));
+}
+
+int
+SProcReparentWindow(ClientPtr client)
+{
+ char n;
+ REQUEST(xReparentWindowReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xReparentWindowReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->parent, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ return((* ProcVector[X_ReparentWindow])(client));
+}
+
+int
+SProcConfigureWindow(ClientPtr client)
+{
+ char n;
+ REQUEST(xConfigureWindowReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
+ swapl(&stuff->window, n);
+ swaps(&stuff->mask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ConfigureWindow])(client));
+
+}
+
+
+int
+SProcInternAtom(ClientPtr client)
+{
+ char n;
+ REQUEST(xInternAtomReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xInternAtomReq);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_InternAtom])(client));
+}
+
+int
+SProcChangeProperty(ClientPtr client)
+{
+ char n;
+ REQUEST(xChangePropertyReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangePropertyReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->type, n);
+ swapl(&stuff->nUnits, n);
+ switch ( stuff->format ) {
+ case 8 :
+ break;
+ case 16:
+ SwapRestS(stuff);
+ break;
+ case 32:
+ SwapRestL(stuff);
+ break;
+ }
+ return((* ProcVector[X_ChangeProperty])(client));
+}
+
+int
+SProcDeleteProperty(ClientPtr client)
+{
+ char n;
+ REQUEST(xDeletePropertyReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDeletePropertyReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ return((* ProcVector[X_DeleteProperty])(client));
+
+}
+
+int
+SProcGetProperty(ClientPtr client)
+{
+ char n;
+ REQUEST(xGetPropertyReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGetPropertyReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->type, n);
+ swapl(&stuff->longOffset, n);
+ swapl(&stuff->longLength, n);
+ return((* ProcVector[X_GetProperty])(client));
+}
+
+int
+SProcSetSelectionOwner(ClientPtr client)
+{
+ char n;
+ REQUEST(xSetSelectionOwnerReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->selection, n);
+ swapl(&stuff->time, n);
+ return((* ProcVector[X_SetSelectionOwner])(client));
+}
+
+int
+SProcConvertSelection(ClientPtr client)
+{
+ char n;
+ REQUEST(xConvertSelectionReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xConvertSelectionReq);
+ swapl(&stuff->requestor, n);
+ swapl(&stuff->selection, n);
+ swapl(&stuff->target, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->time, n);
+ return((* ProcVector[X_ConvertSelection])(client));
+}
+
+int
+SProcSendEvent(ClientPtr client)
+{
+ char n;
+ xEvent eventT;
+ EventSwapPtr proc;
+ REQUEST(xSendEventReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSendEventReq);
+ swapl(&stuff->destination, n);
+ swapl(&stuff->eventMask, n);
+
+ /* Swap event */
+ proc = EventSwapVector[stuff->event.u.u.type & 0177];
+ if (!proc || proc == NotImplemented) /* no swapping proc; invalid event type? */
+ return BadValue;
+ (*proc)(&stuff->event, &eventT);
+ stuff->event = eventT;
+
+ return((* ProcVector[X_SendEvent])(client));
+}
+
+int
+SProcGrabPointer(ClientPtr client)
+{
+ char n;
+ REQUEST(xGrabPointerReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGrabPointerReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->eventMask, n);
+ swapl(&stuff->confineTo, n);
+ swapl(&stuff->cursor, n);
+ swapl(&stuff->time, n);
+ return((* ProcVector[X_GrabPointer])(client));
+}
+
+int
+SProcGrabButton(ClientPtr client)
+{
+ char n;
+ REQUEST(xGrabButtonReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGrabButtonReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->eventMask, n);
+ swapl(&stuff->confineTo, n);
+ swapl(&stuff->cursor, n);
+ swaps(&stuff->modifiers, n);
+ return((* ProcVector[X_GrabButton])(client));
+}
+
+int
+SProcUngrabButton(ClientPtr client)
+{
+ char n;
+ REQUEST(xUngrabButtonReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xUngrabButtonReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->modifiers, n);
+ return((* ProcVector[X_UngrabButton])(client));
+}
+
+int
+SProcChangeActivePointerGrab(ClientPtr client)
+{
+ char n;
+ REQUEST(xChangeActivePointerGrabReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq);
+ swapl(&stuff->cursor, n);
+ swapl(&stuff->time, n);
+ swaps(&stuff->eventMask, n);
+ return((* ProcVector[X_ChangeActivePointerGrab])(client));
+}
+
+int
+SProcGrabKeyboard(ClientPtr client)
+{
+ char n;
+ REQUEST(xGrabKeyboardReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGrabKeyboardReq);
+ swapl(&stuff->grabWindow, n);
+ swapl(&stuff->time, n);
+ return((* ProcVector[X_GrabKeyboard])(client));
+}
+
+int
+SProcGrabKey(ClientPtr client)
+{
+ char n;
+ REQUEST(xGrabKeyReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGrabKeyReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->modifiers, n);
+ return((* ProcVector[X_GrabKey])(client));
+}
+
+int
+SProcUngrabKey(ClientPtr client)
+{
+ char n;
+ REQUEST(xUngrabKeyReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xUngrabKeyReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->modifiers, n);
+ return((* ProcVector[X_UngrabKey])(client));
+}
+
+int
+SProcGetMotionEvents(ClientPtr client)
+{
+ char n;
+ REQUEST(xGetMotionEventsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGetMotionEventsReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->start, n);
+ swapl(&stuff->stop, n);
+ return((* ProcVector[X_GetMotionEvents])(client));
+}
+
+int
+SProcTranslateCoords(ClientPtr client)
+{
+ char n;
+ REQUEST(xTranslateCoordsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xTranslateCoordsReq);
+ swapl(&stuff->srcWid, n);
+ swapl(&stuff->dstWid, n);
+ swaps(&stuff->srcX, n);
+ swaps(&stuff->srcY, n);
+ return((* ProcVector[X_TranslateCoords])(client));
+}
+
+int
+SProcWarpPointer(ClientPtr client)
+{
+ char n;
+ REQUEST(xWarpPointerReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xWarpPointerReq);
+ swapl(&stuff->srcWid, n);
+ swapl(&stuff->dstWid, n);
+ swaps(&stuff->srcX, n);
+ swaps(&stuff->srcY, n);
+ swaps(&stuff->srcWidth, n);
+ swaps(&stuff->srcHeight, n);
+ swaps(&stuff->dstX, n);
+ swaps(&stuff->dstY, n);
+ return((* ProcVector[X_WarpPointer])(client));
+}
+
+int
+SProcSetInputFocus(ClientPtr client)
+{
+ char n;
+ REQUEST(xSetInputFocusReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSetInputFocusReq);
+ swapl(&stuff->focus, n);
+ swapl(&stuff->time, n);
+ return((* ProcVector[X_SetInputFocus])(client));
+}
+
+int
+SProcOpenFont(ClientPtr client)
+{
+ char n;
+ REQUEST(xOpenFontReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xOpenFontReq);
+ swapl(&stuff->fid, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_OpenFont])(client));
+}
+
+int
+SProcListFonts(ClientPtr client)
+{
+ char n;
+ REQUEST(xListFontsReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xListFontsReq);
+ swaps(&stuff->maxNames, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_ListFonts])(client));
+}
+
+int
+SProcListFontsWithInfo(ClientPtr client)
+{
+ char n;
+ REQUEST(xListFontsWithInfoReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xListFontsWithInfoReq);
+ swaps(&stuff->maxNames, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_ListFontsWithInfo])(client));
+}
+
+int
+SProcSetFontPath(ClientPtr client)
+{
+ char n;
+ REQUEST(xSetFontPathReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
+ swaps(&stuff->nFonts, n);
+ return((* ProcVector[X_SetFontPath])(client));
+}
+
+int
+SProcCreatePixmap(ClientPtr client)
+{
+ char n;
+ REQUEST(xCreatePixmapReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCreatePixmapReq);
+ swapl(&stuff->pid, n);
+ swapl(&stuff->drawable, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return((* ProcVector[X_CreatePixmap])(client));
+}
+
+int
+SProcCreateGC(ClientPtr client)
+{
+ char n;
+ REQUEST(xCreateGCReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xCreateGCReq);
+ swapl(&stuff->gc, n);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->mask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_CreateGC])(client));
+}
+
+int
+SProcChangeGC(ClientPtr client)
+{
+ char n;
+ REQUEST(xChangeGCReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeGCReq);
+ swapl(&stuff->gc, n);
+ swapl(&stuff->mask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeGC])(client));
+}
+
+int
+SProcCopyGC(ClientPtr client)
+{
+ char n;
+ REQUEST(xCopyGCReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCopyGCReq);
+ swapl(&stuff->srcGC, n);
+ swapl(&stuff->dstGC, n);
+ swapl(&stuff->mask, n);
+ return((* ProcVector[X_CopyGC])(client));
+}
+
+int
+SProcSetDashes(ClientPtr client)
+{
+ char n;
+ REQUEST(xSetDashesReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSetDashesReq);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->dashOffset, n);
+ swaps(&stuff->nDashes, n);
+ return((* ProcVector[X_SetDashes])(client));
+
+}
+
+int
+SProcSetClipRectangles(ClientPtr client)
+{
+ char n;
+ REQUEST(xSetClipRectanglesReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->xOrigin, n);
+ swaps(&stuff->yOrigin, n);
+ SwapRestS(stuff);
+ return((* ProcVector[X_SetClipRectangles])(client));
+}
+
+int
+SProcClearToBackground(ClientPtr client)
+{
+ char n;
+ REQUEST(xClearAreaReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xClearAreaReq);
+ swapl(&stuff->window, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return((* ProcVector[X_ClearArea])(client));
+}
+
+int
+SProcCopyArea(ClientPtr client)
+{
+ char n;
+ REQUEST(xCopyAreaReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCopyAreaReq);
+ swapl(&stuff->srcDrawable, n);
+ swapl(&stuff->dstDrawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->srcX, n);
+ swaps(&stuff->srcY, n);
+ swaps(&stuff->dstX, n);
+ swaps(&stuff->dstY, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return((* ProcVector[X_CopyArea])(client));
+}
+
+int
+SProcCopyPlane(ClientPtr client)
+{
+ char n;
+ REQUEST(xCopyPlaneReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCopyPlaneReq);
+ swapl(&stuff->srcDrawable, n);
+ swapl(&stuff->dstDrawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->srcX, n);
+ swaps(&stuff->srcY, n);
+ swaps(&stuff->dstX, n);
+ swaps(&stuff->dstY, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ swapl(&stuff->bitPlane, n);
+ return((* ProcVector[X_CopyPlane])(client));
+}
+
+/* The following routine is used for all Poly drawing requests
+ (except FillPoly, which uses a different request format) */
+int
+SProcPoly(ClientPtr client)
+{
+ char n;
+
+ REQUEST(xPolyPointReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xPolyPointReq);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ SwapRestS(stuff);
+ return((* ProcVector[stuff->reqType])(client));
+}
+
+/* cannot use SProcPoly for this one, because xFillPolyReq
+ is longer than xPolyPointReq, and we don't want to swap
+ the difference as shorts! */
+int
+SProcFillPoly(ClientPtr client)
+{
+ char n;
+
+ REQUEST(xFillPolyReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xFillPolyReq);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ SwapRestS(stuff);
+ return((* ProcVector[X_FillPoly])(client));
+}
+
+int
+SProcPutImage(ClientPtr client)
+{
+ char n;
+ REQUEST(xPutImageReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xPutImageReq);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ swaps(&stuff->dstX, n);
+ swaps(&stuff->dstY, n);
+ /* Image should already be swapped */
+ return((* ProcVector[X_PutImage])(client));
+
+}
+
+int
+SProcGetImage(ClientPtr client)
+{
+ char n;
+ REQUEST(xGetImageReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGetImageReq);
+ swapl(&stuff->drawable, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ swapl(&stuff->planeMask, n);
+ return((* ProcVector[X_GetImage])(client));
+}
+
+/* ProcPolyText used for both PolyText8 and PolyText16 */
+
+int
+SProcPolyText(ClientPtr client)
+{
+ char n;
+ REQUEST(xPolyTextReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xPolyTextReq);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ return((* ProcVector[stuff->reqType])(client));
+}
+
+/* ProcImageText used for both ImageText8 and ImageText16 */
+
+int
+SProcImageText(ClientPtr client)
+{
+ char n;
+ REQUEST(xImageTextReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xImageTextReq);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ return((* ProcVector[stuff->reqType])(client));
+}
+
+int
+SProcCreateColormap(ClientPtr client)
+{
+ char n;
+ REQUEST(xCreateColormapReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCreateColormapReq);
+ swapl(&stuff->mid, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->visual, n);
+ return((* ProcVector[X_CreateColormap])(client));
+}
+
+
+int
+SProcCopyColormapAndFree(ClientPtr client)
+{
+ char n;
+ REQUEST(xCopyColormapAndFreeReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
+ swapl(&stuff->mid, n);
+ swapl(&stuff->srcCmap, n);
+ return((* ProcVector[X_CopyColormapAndFree])(client));
+
+}
+
+int
+SProcAllocColor(ClientPtr client)
+{
+ char n;
+ REQUEST(xAllocColorReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xAllocColorReq);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->red, n);
+ swaps(&stuff->green, n);
+ swaps(&stuff->blue, n);
+ return((* ProcVector[X_AllocColor])(client));
+}
+
+int
+SProcAllocNamedColor(ClientPtr client)
+{
+ char n;
+
+ REQUEST(xAllocNamedColorReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xAllocNamedColorReq);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_AllocNamedColor])(client));
+}
+
+int
+SProcAllocColorCells(ClientPtr client)
+{
+ char n;
+ REQUEST(xAllocColorCellsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xAllocColorCellsReq);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->colors, n);
+ swaps(&stuff->planes, n);
+ return((* ProcVector[X_AllocColorCells])(client));
+}
+
+int
+SProcAllocColorPlanes(ClientPtr client)
+{
+ char n;
+ REQUEST(xAllocColorPlanesReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->colors, n);
+ swaps(&stuff->red, n);
+ swaps(&stuff->green, n);
+ swaps(&stuff->blue, n);
+ return((* ProcVector[X_AllocColorPlanes])(client));
+}
+
+int
+SProcFreeColors(ClientPtr client)
+{
+ char n;
+ REQUEST(xFreeColorsReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
+ swapl(&stuff->cmap, n);
+ swapl(&stuff->planeMask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_FreeColors])(client));
+
+}
+
+void
+SwapColorItem(xColorItem *pItem)
+{
+ char n;
+
+ swapl(&pItem->pixel, n);
+ swaps(&pItem->red, n);
+ swaps(&pItem->green, n);
+ swaps(&pItem->blue, n);
+}
+
+int
+SProcStoreColors(ClientPtr client)
+{
+ char n;
+ long count;
+ xColorItem *pItem;
+
+ REQUEST(xStoreColorsReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
+ swapl(&stuff->cmap, n);
+ pItem = (xColorItem *) &stuff[1];
+ for(count = LengthRestB(stuff)/sizeof(xColorItem); --count >= 0; )
+ SwapColorItem(pItem++);
+ return((* ProcVector[X_StoreColors])(client));
+}
+
+int
+SProcStoreNamedColor (ClientPtr client)
+{
+ char n;
+ REQUEST(xStoreNamedColorReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xStoreNamedColorReq);
+ swapl(&stuff->cmap, n);
+ swapl(&stuff->pixel, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_StoreNamedColor])(client));
+}
+
+int
+SProcQueryColors (ClientPtr client)
+{
+ char n;
+ REQUEST(xQueryColorsReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
+ swapl(&stuff->cmap, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_QueryColors])(client));
+}
+
+int
+SProcLookupColor (ClientPtr client)
+{
+ char n;
+ REQUEST(xLookupColorReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xLookupColorReq);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_LookupColor])(client));
+}
+
+int
+SProcCreateCursor (ClientPtr client)
+{
+ char n;
+ REQUEST(xCreateCursorReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCreateCursorReq);
+ swapl(&stuff->cid, n);
+ swapl(&stuff->source, n);
+ swapl(&stuff->mask, n);
+ swaps(&stuff->foreRed, n);
+ swaps(&stuff->foreGreen, n);
+ swaps(&stuff->foreBlue, n);
+ swaps(&stuff->backRed, n);
+ swaps(&stuff->backGreen, n);
+ swaps(&stuff->backBlue, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ return((* ProcVector[X_CreateCursor])(client));
+}
+
+int
+SProcCreateGlyphCursor (ClientPtr client)
+{
+ char n;
+ REQUEST(xCreateGlyphCursorReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCreateGlyphCursorReq);
+ swapl(&stuff->cid, n);
+ swapl(&stuff->source, n);
+ swapl(&stuff->mask, n);
+ swaps(&stuff->sourceChar, n);
+ swaps(&stuff->maskChar, n);
+ swaps(&stuff->foreRed, n);
+ swaps(&stuff->foreGreen, n);
+ swaps(&stuff->foreBlue, n);
+ swaps(&stuff->backRed, n);
+ swaps(&stuff->backGreen, n);
+ swaps(&stuff->backBlue, n);
+ return((* ProcVector[X_CreateGlyphCursor])(client));
+}
+
+
+int
+SProcRecolorCursor (ClientPtr client)
+{
+ char n;
+ REQUEST(xRecolorCursorReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecolorCursorReq);
+ swapl(&stuff->cursor, n);
+ swaps(&stuff->foreRed, n);
+ swaps(&stuff->foreGreen, n);
+ swaps(&stuff->foreBlue, n);
+ swaps(&stuff->backRed, n);
+ swaps(&stuff->backGreen, n);
+ swaps(&stuff->backBlue, n);
+ return((* ProcVector[X_RecolorCursor])(client));
+}
+
+int
+SProcQueryBestSize (ClientPtr client)
+{
+ char n;
+ REQUEST(xQueryBestSizeReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xQueryBestSizeReq);
+ swapl(&stuff->drawable, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return((* ProcVector[X_QueryBestSize])(client));
+
+}
+
+int
+SProcQueryExtension (ClientPtr client)
+{
+ char n;
+ REQUEST(xQueryExtensionReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xQueryExtensionReq);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_QueryExtension])(client));
+}
+
+int
+SProcChangeKeyboardMapping (ClientPtr client)
+{
+ char n;
+ REQUEST(xChangeKeyboardMappingReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeKeyboardMapping])(client));
+}
+
+
+int
+SProcChangeKeyboardControl (ClientPtr client)
+{
+ char n;
+ REQUEST(xChangeKeyboardControlReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
+ swapl(&stuff->mask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeKeyboardControl])(client));
+}
+
+int
+SProcChangePointerControl (ClientPtr client)
+{
+ char n;
+ REQUEST(xChangePointerControlReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xChangePointerControlReq);
+ swaps(&stuff->accelNum, n);
+ swaps(&stuff->accelDenum, n);
+ swaps(&stuff->threshold, n);
+ return((* ProcVector[X_ChangePointerControl])(client));
+}
+
+
+int
+SProcSetScreenSaver (ClientPtr client)
+{
+ char n;
+ REQUEST(xSetScreenSaverReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSetScreenSaverReq);
+ swaps(&stuff->timeout, n);
+ swaps(&stuff->interval, n);
+ return((* ProcVector[X_SetScreenSaver])(client));
+}
+
+int
+SProcChangeHosts (ClientPtr client)
+{
+ char n;
+
+ REQUEST(xChangeHostsReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeHostsReq);
+ swaps(&stuff->hostLength, n);
+ return((* ProcVector[X_ChangeHosts])(client));
+
+}
+
+int SProcRotateProperties (ClientPtr client)
+{
+ char n;
+ REQUEST(xRotatePropertiesReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xRotatePropertiesReq);
+ swapl(&stuff->window, n);
+ swaps(&stuff->nAtoms, n);
+ swaps(&stuff->nPositions, n);
+ SwapRestL(stuff);
+ return ((* ProcVector[X_RotateProperties])(client));
+}
+
+int
+SProcNoOperation(ClientPtr client)
+{
+ char n;
+ REQUEST(xReq);
+ swaps(&stuff->length, n);
+ return ((* ProcVector[X_NoOperation])(client));
+}
+
+void
+SwapConnClientPrefix(xConnClientPrefix *pCCP)
+{
+ char n;
+
+ swaps(&pCCP->majorVersion, n);
+ swaps(&pCCP->minorVersion, n);
+ swaps(&pCCP->nbytesAuthProto, n);
+ swaps(&pCCP->nbytesAuthString, n);
+}
diff --git a/xorg-server/dix/window.c b/xorg-server/dix/window.c index 5109885e9..62f790c08 100644 --- a/xorg-server/dix/window.c +++ b/xorg-server/dix/window.c @@ -151,13 +151,7 @@ WindowSeekDeviceCursor(WindowPtr pWin, int screenIsSaved = SCREEN_SAVER_OFF;
-ScreenSaverStuffRec savedScreenInfo[MAXSCREENS];
-
-static int FocusPrivatesKeyIndex;
-DevPrivateKey FocusPrivatesKey = &FocusPrivatesKeyIndex;
-
-static Bool TileScreenSaver(int i, int kind);
-
+static Bool TileScreenSaver(ScreenPtr pScreen, int kind);
#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
CWDontPropagate | CWOverrideRedirect | CWCursor )
@@ -197,7 +191,7 @@ PrintChildren(WindowPtr p1, int indent) ErrorF("[dix] ");
for (i=0; i<indent; i++) ErrorF(" ");
ErrorF("%lx\n", p1->drawable.id);
- miPrintRegion(&p1->clipList);
+ RegionPrint(&p1->clipList);
PrintChildren(p2, indent+4);
p1 = p1->nextSib;
}
@@ -212,8 +206,8 @@ PrintWindowTree(void) for (i=0; i<screenInfo.numScreens; i++)
{
ErrorF("[dix] WINDOW %d\n", i);
- pWin = WindowTable[i];
- miPrintRegion(&pWin->clipList);
+ pWin = screenInfo.screens[i]->root;
+ RegionPrint(&pWin->clipList);
p1 = pWin->firstChild;
PrintChildren(p1, 4);
}
@@ -227,12 +221,12 @@ TraverseTree(WindowPtr pWin, VisitWindowProcPtr func, pointer data) WindowPtr pChild;
if (!(pChild = pWin))
- return(WT_NOMATCH);
+ return WT_NOMATCH;
while (1)
{
result = (* func)(pChild, data);
if (result == WT_STOPWALKING)
- return(WT_STOPWALKING);
+ return WT_STOPWALKING;
if ((result == WT_WALKCHILDREN) && pChild->firstChild)
{
pChild = pChild->firstChild;
@@ -244,7 +238,7 @@ TraverseTree(WindowPtr pWin, VisitWindowProcPtr func, pointer data) break;
pChild = pChild->nextSib;
}
- return(WT_NOMATCH);
+ return WT_NOMATCH;
}
/*****
@@ -258,7 +252,7 @@ TraverseTree(WindowPtr pWin, VisitWindowProcPtr func, pointer data) int
WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, pointer data)
{
- return(TraverseTree(WindowTable[pScreen->myNum], func, data));
+ return(TraverseTree(pScreen->root, func, data));
}
/* hack for forcing backing store on all windows */
@@ -359,20 +353,19 @@ CreateRootWindow(ScreenPtr pScreen) BoxRec box;
PixmapFormatRec *format;
- pWin = malloc(sizeof(WindowRec));
+ pWin = dixAllocateObjectWithPrivates(WindowRec, PRIVATE_WINDOW);
if (!pWin)
return FALSE;
- savedScreenInfo[pScreen->myNum].pWindow = NULL;
- savedScreenInfo[pScreen->myNum].wid = FakeClientID(0);
- savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL;
+ pScreen->screensaver.pWindow = NULL;
+ pScreen->screensaver.wid = FakeClientID(0);
+ pScreen->screensaver.ExternalScreenSaver = NULL;
screenIsSaved = SCREEN_SAVER_OFF;
- WindowTable[pScreen->myNum] = pWin;
+ pScreen->root = pWin;
pWin->drawable.pScreen = pScreen;
pWin->drawable.type = DRAWABLE_WINDOW;
- pWin->devPrivates = NULL;
pWin->drawable.depth = pScreen->rootDepth;
for (format = screenInfo.formats;
@@ -418,10 +411,10 @@ CreateRootWindow(ScreenPtr pScreen) box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
- REGION_INIT(pScreen, &pWin->clipList, &box, 1);
- REGION_INIT(pScreen, &pWin->winSize, &box, 1);
- REGION_INIT(pScreen, &pWin->borderSize, &box, 1);
- REGION_INIT(pScreen, &pWin->borderClip, &box, 1);
+ RegionInit(&pWin->clipList, &box, 1);
+ RegionInit(&pWin->winSize, &box, 1);
+ RegionInit(&pWin->borderSize, &box, 1);
+ RegionInit(&pWin->borderClip, &box, 1);
pWin->drawable.class = InputOutput;
pWin->optional->visual = pScreen->rootVisual;
@@ -496,12 +489,8 @@ ClippedRegionFromBox(WindowPtr pWin, RegionPtr Rgn, int x, int y,
int w, int h)
{
- ScreenPtr pScreen;
- BoxRec box;
-
- pScreen = pWin->drawable.pScreen;
+ BoxRec box = *RegionExtents(&pWin->winSize);
- box = *(REGION_EXTENTS(pScreen, &pWin->winSize));
/* we do these calculations to avoid overflows */
if (x > box.x1)
box.x1 = x;
@@ -517,8 +506,8 @@ ClippedRegionFromBox(WindowPtr pWin, RegionPtr Rgn, box.x2 = box.x1;
if (box.y1 > box.y2)
box.y2 = box.y1;
- REGION_RESET(pScreen, Rgn, &box);
- REGION_INTERSECT(pScreen, Rgn, Rgn, &pWin->winSize);
+ RegionReset(Rgn, &box);
+ RegionIntersect(Rgn, Rgn, &pWin->winSize);
}
static RealChildHeadProc realChildHeadProc = NULL;
@@ -539,10 +528,10 @@ RealChildHead(WindowPtr pWin) if (!pWin->parent &&
(screenIsSaved == SCREEN_SAVER_ON) &&
- (HasSaverWindow (pWin->drawable.pScreen->myNum)))
- return (pWin->firstChild);
+ (HasSaverWindow (pWin->drawable.pScreen)))
+ return pWin->firstChild;
else
- return (NullWindow);
+ return NullWindow;
}
/*****
@@ -639,14 +628,13 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w, return NullWindow;
}
- pWin = malloc(sizeof(WindowRec));
+ pWin = dixAllocateObjectWithPrivates(WindowRec, PRIVATE_WINDOW);
if (!pWin)
{
*error = BadAlloc;
return NullWindow;
}
pWin->drawable = pParent->drawable;
- pWin->devPrivates = NULL;
pWin->drawable.depth = depth;
if (depth == pParent->drawable.depth)
pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel;
@@ -670,7 +658,7 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w, {
if (!MakeWindowOptional (pWin))
{
- free(pWin);
+ dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
*error = BadAlloc;
return NullWindow;
}
@@ -685,7 +673,7 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w, *error = XaceHook(XACE_RESOURCE_ACCESS, client, wid, RT_WINDOW, pWin,
RT_WINDOW, pWin->parent, DixCreateAccess|DixSetAttrAccess);
if (*error != Success) {
- free(pWin);
+ dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
return NullWindow;
}
@@ -705,10 +693,10 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w, pWin->drawable.y = pParent->drawable.y + y + (int)bw;
/* set up clip list correctly for unobscured WindowPtr */
- REGION_NULL(pScreen, &pWin->clipList);
- REGION_NULL(pScreen, &pWin->borderClip);
- REGION_NULL(pScreen, &pWin->winSize);
- REGION_NULL(pScreen, &pWin->borderSize);
+ RegionNull(&pWin->clipList);
+ RegionNull(&pWin->borderClip);
+ RegionNull(&pWin->winSize);
+ RegionNull(&pWin->borderSize);
pHead = RealChildHead(pParent);
if (pHead)
@@ -826,16 +814,16 @@ FreeWindowResources(WindowPtr pWin) DeleteWindowFromAnySaveSet(pWin);
DeleteWindowFromAnySelections(pWin);
DeleteWindowFromAnyEvents(pWin, TRUE);
- REGION_UNINIT(pScreen, &pWin->clipList);
- REGION_UNINIT(pScreen, &pWin->winSize);
- REGION_UNINIT(pScreen, &pWin->borderClip);
- REGION_UNINIT(pScreen, &pWin->borderSize);
+ RegionUninit(&pWin->clipList);
+ RegionUninit(&pWin->winSize);
+ RegionUninit(&pWin->borderClip);
+ RegionUninit(&pWin->borderSize);
if (wBoundingShape (pWin))
- REGION_DESTROY(pScreen, wBoundingShape (pWin));
+ RegionDestroy(wBoundingShape (pWin));
if (wClipShape (pWin))
- REGION_DESTROY(pScreen, wClipShape (pWin));
+ RegionDestroy(wClipShape (pWin));
if (wInputShape (pWin))
- REGION_DESTROY(pScreen, wInputShape (pWin));
+ RegionDestroy(wInputShape (pWin));
if (pWin->borderIsPixel == FALSE)
(*pScreen->DestroyPixmap)(pWin->border.pixmap);
if (pWin->backgroundState == BackgroundPixmap)
@@ -883,8 +871,7 @@ CrushTree(WindowPtr pWin) (*UnrealizeWindow)(pChild);
}
FreeWindowResources(pChild);
- dixFreePrivates(pChild->devPrivates);
- free(pChild);
+ dixFreeObjectWithPrivates(pChild, PRIVATE_WINDOW);
if ( (pChild = pSib) )
break;
pChild = pParent;
@@ -934,9 +921,7 @@ DeleteWindow(pointer value, XID wid) if (pWin->prevSib)
pWin->prevSib->nextSib = pWin->nextSib;
}
- free(dixLookupPrivate(&pWin->devPrivates, FocusPrivatesKey));
- dixFreePrivates(pWin->devPrivates);
- free(pWin);
+ dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
return Success;
}
@@ -1329,7 +1314,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) */
if ( cursorID == None)
{
- if (pWin == WindowTable[pWin->drawable.pScreen->myNum])
+ if (pWin == pWin->drawable.pScreen->root)
pCursor = rootCursor;
else
pCursor = (CursorPtr) None;
@@ -1433,10 +1418,10 @@ PatchUp: {
RegionRec exposed;
- REGION_NULL(pScreen, &exposed);
- REGION_SUBTRACT(pScreen, &exposed, &pWin->borderClip, &pWin->winSize);
+ RegionNull(&exposed);
+ RegionSubtract(&exposed, &pWin->borderClip, &pWin->winSize);
miPaintWindow(pWin, &exposed, PW_BORDER);
- REGION_UNINIT(pScreen, &exposed);
+ RegionUninit(&exposed);
}
return error;
}
@@ -1564,7 +1549,7 @@ MoveWindowInStack(WindowPtr pWin, WindowPtr pNextSib) (*pWin->drawable.pScreen->RestackWindow)(pWin, pWin->nextSib);
#endif
- return( pFirstChange );
+ return pFirstChange;
}
void
@@ -1583,7 +1568,7 @@ SetWinSize (WindowPtr pWin) box.y1 = pWin->drawable.y;
box.x2 = pWin->drawable.x + pWin->drawable.width;
box.y2 = pWin->drawable.y + pWin->drawable.height;
- REGION_RESET (pScreen, &pWin->winSize, &box);
+ RegionReset(&pWin->winSize, &box);
}
else
#endif
@@ -1592,18 +1577,15 @@ SetWinSize (WindowPtr pWin) (int)pWin->drawable.width,
(int)pWin->drawable.height);
if (wBoundingShape (pWin) || wClipShape (pWin)) {
- ScreenPtr pScreen;
- pScreen = pWin->drawable.pScreen;
-
- REGION_TRANSLATE(pScreen, &pWin->winSize, - pWin->drawable.x,
+ RegionTranslate(&pWin->winSize, - pWin->drawable.x,
- pWin->drawable.y);
if (wBoundingShape (pWin))
- REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize,
+ RegionIntersect(&pWin->winSize, &pWin->winSize,
wBoundingShape (pWin));
if (wClipShape (pWin))
- REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize,
+ RegionIntersect(&pWin->winSize, &pWin->winSize,
wClipShape (pWin));
- REGION_TRANSLATE(pScreen, &pWin->winSize, pWin->drawable.x,
+ RegionTranslate(&pWin->winSize, pWin->drawable.x,
pWin->drawable.y);
}
}
@@ -1628,7 +1610,7 @@ SetBorderSize (WindowPtr pWin) box.y1 = pWin->drawable.y - bw;
box.x2 = pWin->drawable.x + pWin->drawable.width + bw;
box.y2 = pWin->drawable.y + pWin->drawable.height + bw;
- REGION_RESET (pScreen, &pWin->borderSize, &box);
+ RegionReset(&pWin->borderSize, &box);
}
else
#endif
@@ -1637,21 +1619,17 @@ SetBorderSize (WindowPtr pWin) (int)(pWin->drawable.width + (bw<<1)),
(int)(pWin->drawable.height + (bw<<1)));
if (wBoundingShape (pWin)) {
- ScreenPtr pScreen;
- pScreen = pWin->drawable.pScreen;
-
- REGION_TRANSLATE(pScreen, &pWin->borderSize, - pWin->drawable.x,
+ RegionTranslate(&pWin->borderSize, - pWin->drawable.x,
- pWin->drawable.y);
- REGION_INTERSECT(pScreen, &pWin->borderSize, &pWin->borderSize,
+ RegionIntersect(&pWin->borderSize, &pWin->borderSize,
wBoundingShape (pWin));
- REGION_TRANSLATE(pScreen, &pWin->borderSize, pWin->drawable.x,
+ RegionTranslate(&pWin->borderSize, pWin->drawable.x,
pWin->drawable.y);
- REGION_UNION(pScreen, &pWin->borderSize, &pWin->borderSize,
+ RegionUnion(&pWin->borderSize, &pWin->borderSize,
&pWin->winSize);
}
} else {
- REGION_COPY(pWin->drawable.pScreen, &pWin->borderSize,
- &pWin->winSize);
+ RegionCopy(&pWin->borderSize, &pWin->winSize);
}
}
@@ -1817,12 +1795,12 @@ IsSiblingAboveMe( while (pWin)
{
if (pWin == pSib)
- return(Above);
+ return Above;
else if (pWin == pMe)
- return(Below);
+ return Below;
pWin = pWin->nextSib;
}
- return(Below);
+ return Below;
}
static BoxPtr
@@ -1836,7 +1814,7 @@ WindowExtents( + wBorderWidth (pWin);
pBox->y2 = pWin->drawable.y + (int)pWin->drawable.height
+ wBorderWidth (pWin);
- return(pBox);
+ return pBox;
}
#define IS_SHAPED(pWin) (wBoundingShape (pWin) != (RegionPtr) NULL)
@@ -1846,17 +1824,11 @@ MakeBoundingRegion ( WindowPtr pWin,
BoxPtr pBox)
{
- RegionPtr pRgn;
- ScreenPtr pScreen;
- pScreen = pWin->drawable.pScreen;
-
- pRgn = REGION_CREATE(pScreen, pBox, 1);
+ RegionPtr pRgn = RegionCreate(pBox, 1);
if (wBoundingShape (pWin)) {
- REGION_TRANSLATE(pScreen, pRgn, -pWin->origin.x,
- -pWin->origin.y);
- REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin));
- REGION_TRANSLATE(pScreen, pRgn, pWin->origin.x,
- pWin->origin.y);
+ RegionTranslate(pRgn, -pWin->origin.x, -pWin->origin.y);
+ RegionIntersect(pRgn, pRgn, wBoundingShape (pWin));
+ RegionTranslate(pRgn, pWin->origin.x, pWin->origin.y);
}
return pRgn;
}
@@ -1869,18 +1841,16 @@ ShapeOverlap ( BoxPtr pSibBox)
{
RegionPtr pWinRgn, pSibRgn;
- ScreenPtr pScreen;
Bool ret;
if (!IS_SHAPED(pWin) && !IS_SHAPED(pSib))
return TRUE;
- pScreen = pWin->drawable.pScreen;
pWinRgn = MakeBoundingRegion (pWin, pWinBox);
pSibRgn = MakeBoundingRegion (pSib, pSibBox);
- REGION_INTERSECT(pScreen, pWinRgn, pWinRgn, pSibRgn);
- ret = REGION_NOTEMPTY(pScreen, pWinRgn);
- REGION_DESTROY(pScreen, pWinRgn);
- REGION_DESTROY(pScreen, pSibRgn);
+ RegionIntersect(pWinRgn, pWinRgn, pSibRgn);
+ ret = RegionNotEmpty(pWinRgn);
+ RegionDestroy(pWinRgn);
+ RegionDestroy(pSibRgn);
return ret;
}
@@ -1902,10 +1872,10 @@ AnyWindowOverlapsMe( if (BOXES_OVERLAP(sbox, box)
&& ShapeOverlap (pWin, box, pSib, sbox)
)
- return(TRUE);
+ return TRUE;
}
}
- return(FALSE);
+ return FALSE;
}
static Bool
@@ -1925,10 +1895,10 @@ IOverlapAnyWindow( if (BOXES_OVERLAP(sbox, box)
&& ShapeOverlap (pWin, box, pSib, sbox)
)
- return(TRUE);
+ return TRUE;
}
}
- return(FALSE);
+ return FALSE;
}
/*
@@ -1970,7 +1940,6 @@ WhereDoIGoInTheStack( int smode)
{
BoxRec box;
- ScreenPtr pScreen;
WindowPtr pHead, pFirst;
if ((pWin == pWin->parent->firstChild) &&
@@ -1978,7 +1947,6 @@ WhereDoIGoInTheStack( return((WindowPtr ) NULL);
pHead = RealChildHead(pWin->parent);
pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild;
- pScreen = pWin->drawable.pScreen;
box.x1 = x;
box.y1 = y;
box.x2 = x + (int)w;
@@ -1987,63 +1955,63 @@ WhereDoIGoInTheStack( {
case Above:
if (pSib)
- return(pSib);
+ return pSib;
else if (pWin == pFirst)
- return(pWin->nextSib);
+ return pWin->nextSib;
else
- return(pFirst);
+ return pFirst;
case Below:
if (pSib)
if (pSib->nextSib != pWin)
- return(pSib->nextSib);
+ return pSib->nextSib;
else
- return(pWin->nextSib);
+ return pWin->nextSib;
else
return NullWindow;
case TopIf:
if ((!pWin->mapped || (pSib && !pSib->mapped)))
- return(pWin->nextSib);
+ return pWin->nextSib;
else if (pSib)
{
if ((IsSiblingAboveMe(pWin, pSib) == Above) &&
- (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT))
- return(pFirst);
+ (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT))
+ return pFirst;
else
- return(pWin->nextSib);
+ return pWin->nextSib;
}
else if (AnyWindowOverlapsMe(pWin, pHead, &box))
- return(pFirst);
+ return pFirst;
else
- return(pWin->nextSib);
+ return pWin->nextSib;
case BottomIf:
if ((!pWin->mapped || (pSib && !pSib->mapped)))
- return(pWin->nextSib);
+ return pWin->nextSib;
else if (pSib)
{
if ((IsSiblingAboveMe(pWin, pSib) == Below) &&
- (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT))
+ (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT))
return NullWindow;
else
- return(pWin->nextSib);
+ return pWin->nextSib;
}
else if (IOverlapAnyWindow(pWin, &box))
return NullWindow;
else
- return(pWin->nextSib);
+ return pWin->nextSib;
case Opposite:
if ((!pWin->mapped || (pSib && !pSib->mapped)))
- return(pWin->nextSib);
+ return pWin->nextSib;
else if (pSib)
{
- if (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT)
+ if (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT)
{
if (IsSiblingAboveMe(pWin, pSib) == Above)
- return(pFirst);
+ return pFirst;
else
return NullWindow;
}
else
- return(pWin->nextSib);
+ return pWin->nextSib;
}
else if (AnyWindowOverlapsMe(pWin, pHead, &box))
{
@@ -2051,7 +2019,7 @@ WhereDoIGoInTheStack( * if (pWin == pWin->parent->firstChild)
* return pWin->nextSib;
*/
- return(pFirst);
+ return pFirst;
}
else if (IOverlapAnyWindow(pWin, &box))
return NullWindow;
@@ -2126,10 +2094,10 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client) xEvent event;
if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask))
- return(BadMatch);
+ return BadMatch;
if ((mask & CWSibling) && !(mask & CWStackMode))
- return(BadMatch);
+ return BadMatch;
pVlist = vlist;
@@ -2186,9 +2154,9 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client) return rc;
}
if (pSib->parent != pParent)
- return(BadMatch);
+ return BadMatch;
if (pSib == pWin)
- return(BadMatch);
+ return BadMatch;
break;
case CWStackMode:
GET_CARD8(CWStackMode, smode);
@@ -2196,12 +2164,12 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client) (smode != Opposite) && (smode != Above) && (smode != Below))
{
client->errorValue = smode;
- return(BadValue);
+ return BadValue;
}
break;
default:
client->errorValue = mask;
- return(BadValue);
+ return BadValue;
}
}
/* root really can't be reconfigured, so just return */
@@ -2238,8 +2206,8 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client) event.u.configureRequest.y = y;
#ifdef PANORAMIX
if(!noPanoramiXExtension && (!pParent || !pParent->parent)) {
- event.u.configureRequest.x += panoramiXdataPtr[0].x;
- event.u.configureRequest.y += panoramiXdataPtr[0].y;
+ event.u.configureRequest.x += screenInfo.screens[0]->x;
+ event.u.configureRequest.y += screenInfo.screens[0]->y;
}
#endif
event.u.configureRequest.width = w;
@@ -2249,7 +2217,7 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client) event.u.configureRequest.parent = pParent->drawable.id;
if (MaybeDeliverEventsToClient(pParent, &event, 1,
SubstructureRedirectMask, client) == 1)
- return(Success);
+ return Success;
}
if (action == RESIZE_WIN)
{
@@ -2300,11 +2268,18 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client) #endif
goto ActuallyDoSomething;
}
- return(Success);
+ return Success;
ActuallyDoSomething:
if (pWin->drawable.pScreen->ConfigNotify)
- (*pWin->drawable.pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+ {
+ int ret;
+ ret = (*pWin->drawable.pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+ if (ret) {
+ client->errorValue = 0;
+ return ret;
+ }
+ }
if (SubStrSend(pWin, pParent))
{
@@ -2319,8 +2294,8 @@ ActuallyDoSomething: event.u.configureNotify.y = y;
#ifdef PANORAMIX
if(!noPanoramiXExtension && (!pParent || !pParent->parent)) {
- event.u.configureNotify.x += panoramiXdataPtr[0].x;
- event.u.configureNotify.y += panoramiXdataPtr[0].y;
+ event.u.configureNotify.x += screenInfo.screens[0]->x;
+ event.u.configureNotify.y += screenInfo.screens[0]->y;
}
#endif
event.u.configureNotify.width = w;
@@ -2356,7 +2331,7 @@ ActuallyDoSomething: if (action != RESTACK_WIN)
CheckCursorConfinement(pWin);
- return(Success);
+ return Success;
#undef RESTACK_WIN
#undef MOVE_WIN
#undef RESIZE_WIN
@@ -2417,7 +2392,7 @@ CirculateWindow(WindowPtr pParent, int direction, ClientPtr client) event.u.u.type = CirculateRequest;
if (MaybeDeliverEventsToClient(pParent, &event, 1,
SubstructureRedirectMask, client) == 1)
- return(Success);
+ return Success;
}
event.u.u.type = CirculateNotify;
@@ -2426,7 +2401,7 @@ CirculateWindow(WindowPtr pParent, int direction, ClientPtr client) (direction == RaiseLowest) ? pFirst : NullWindow,
VTStack);
- return(Success);
+ return Success;
}
static int
@@ -2437,9 +2412,9 @@ CompareWIDs( Window *wid = (Window *)value;
if (pWin->drawable.id == *wid)
- return(WT_STOPWALKING);
+ return WT_STOPWALKING;
else
- return(WT_WALKCHILDREN);
+ return WT_WALKCHILDREN;
}
/*****
@@ -2458,9 +2433,9 @@ ReparentWindow(WindowPtr pWin, WindowPtr pParent, pScreen = pWin->drawable.pScreen;
if (TraverseTree(pWin, CompareWIDs, (pointer)&pParent->drawable.id) == WT_STOPWALKING)
- return(BadMatch);
+ return BadMatch;
if (!MakeWindowOptional(pWin))
- return(BadAlloc);
+ return BadAlloc;
if (WasMapped)
UnmapWindow(pWin, FALSE);
@@ -2473,8 +2448,8 @@ ReparentWindow(WindowPtr pWin, WindowPtr pParent, event.u.reparent.y = y;
#ifdef PANORAMIX
if(!noPanoramiXExtension && !pParent->parent) {
- event.u.reparent.x += panoramiXdataPtr[0].x;
- event.u.reparent.y += panoramiXdataPtr[0].y;
+ event.u.reparent.x += screenInfo.screens[0]->x;
+ event.u.reparent.y += screenInfo.screens[0]->y;
}
#endif
event.u.reparent.override = pWin->overrideRedirect;
@@ -2536,7 +2511,7 @@ ReparentWindow(WindowPtr pWin, WindowPtr pParent, if (WasMapped)
MapWindow(pWin, client);
RecalculateDeliverableEvents(pWin);
- return(Success);
+ return Success;
}
static void
@@ -2609,7 +2584,7 @@ MapWindow(WindowPtr pWin, ClientPtr client) WindowPtr pLayerWin;
if (pWin->mapped)
- return(Success);
+ return Success;
/* general check for permission to map window */
if (XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, RT_WINDOW,
@@ -2633,7 +2608,7 @@ MapWindow(WindowPtr pWin, ClientPtr client) if (MaybeDeliverEventsToClient(pParent, &event, 1,
SubstructureRedirectMask, client) == 1)
- return(Success);
+ return Success;
}
pWin->mapped = TRUE;
@@ -2647,7 +2622,7 @@ MapWindow(WindowPtr pWin, ClientPtr client) }
if (!pParent->realized)
- return(Success);
+ return Success;
RealizeTree(pWin);
if (pWin->viewable)
{
@@ -2676,13 +2651,13 @@ MapWindow(WindowPtr pWin, ClientPtr client) (*pScreen->ClipNotify) (pWin, 0, 0);
if (pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(NullWindow, pWin, VTMap);
- REGION_NULL(pScreen, &temp);
- REGION_COPY(pScreen, &temp, &pWin->clipList);
+ RegionNull(&temp);
+ RegionCopy(&temp, &pWin->clipList);
(*pScreen->WindowExposures) (pWin, &temp, NullRegion);
- REGION_UNINIT(pScreen, &temp);
+ RegionUninit(&temp);
}
- return(Success);
+ return Success;
}
@@ -2838,7 +2813,7 @@ UnmapWindow(WindowPtr pWin, Bool fromConfigure) WindowPtr pLayerWin = pWin;
if ((!pWin->mapped) || (!(pParent = pWin->parent)))
- return(Success);
+ return Success;
if (SubStrSend(pWin, pParent) && MapUnmapEventsEnabled(pWin))
{
memset(&event, 0, sizeof(xEvent));
@@ -2868,7 +2843,7 @@ UnmapWindow(WindowPtr pWin, Bool fromConfigure) }
if (wasRealized && !fromConfigure)
WindowsRestructured ();
- return(Success);
+ return Success;
}
/*****
@@ -2966,7 +2941,7 @@ HandleSaveSet(ClientPtr client) pWin = SaveSetWindow(client->saveSet[j]);
#ifdef XFIXES
if (SaveSetToRoot(client->saveSet[j]))
- pParent = WindowTable[pWin->drawable.pScreen->myNum];
+ pParent = pWin->drawable.pScreen->root;
else
#endif
{
@@ -3011,43 +2986,37 @@ PointInWindowIsVisible(WindowPtr pWin, int x, int y) BoxRec box;
if (!pWin->realized)
- return (FALSE);
- if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderClip,
+ return FALSE;
+ if (RegionContainsPoint(&pWin->borderClip,
x, y, &box)
&& (!wInputShape(pWin) ||
- POINT_IN_REGION(pWin->drawable.pScreen,
- wInputShape(pWin),
- x - pWin->drawable.x,
- y - pWin->drawable.y, &box)))
- return(TRUE);
- return(FALSE);
+ RegionContainsPoint(wInputShape(pWin),
+ x - pWin->drawable.x,
+ y - pWin->drawable.y, &box)))
+ return TRUE;
+ return FALSE;
}
RegionPtr
NotClippedByChildren(WindowPtr pWin)
{
- ScreenPtr pScreen;
- RegionPtr pReg;
-
- pScreen = pWin->drawable.pScreen;
- pReg = REGION_CREATE(pScreen, NullBox, 1);
+ RegionPtr pReg = RegionCreate(NullBox, 1);
if (pWin->parent ||
screenIsSaved != SCREEN_SAVER_ON ||
- !HasSaverWindow (pWin->drawable.pScreen->myNum))
+ !HasSaverWindow (pWin->drawable.pScreen))
{
- REGION_INTERSECT(pScreen, pReg, &pWin->borderClip, &pWin->winSize);
+ RegionIntersect(pReg, &pWin->borderClip, &pWin->winSize);
}
- return(pReg);
+ return pReg;
}
void
SendVisibilityNotify(WindowPtr pWin)
{
xEvent event;
-#ifndef NO_XINERAMA_PORT
unsigned int visibility = pWin->visibility;
-#endif
+
if (!MapUnmapEventsEnabled(pWin))
return;
#ifdef PANORAMIX
@@ -3152,33 +3121,33 @@ dixSaveScreens(ClientPtr client, int on, int mode) }
for (i = 0; i < screenInfo.numScreens; i++)
{
+ ScreenPtr pScreen = screenInfo.screens[i];
if (on == SCREEN_SAVER_FORCER)
- (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i], on);
- if (savedScreenInfo[i].ExternalScreenSaver)
+ (* pScreen->SaveScreen) (pScreen, on);
+ if (pScreen->screensaver.ExternalScreenSaver)
{
- if ((*savedScreenInfo[i].ExternalScreenSaver)
- (screenInfo.screens[i], type, on == SCREEN_SAVER_FORCER))
+ if ((*pScreen->screensaver.ExternalScreenSaver)
+ (pScreen, type, on == SCREEN_SAVER_FORCER))
continue;
}
if (type == screenIsSaved)
continue;
switch (type) {
case SCREEN_SAVER_OFF:
- if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED)
+ if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED)
{
- (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i],
- what);
+ (* pScreen->SaveScreen) (pScreen, what);
}
- else if (HasSaverWindow (i))
+ else if (HasSaverWindow (pScreen))
{
- savedScreenInfo[i].pWindow = NullWindow;
- FreeResource(savedScreenInfo[i].wid, RT_NONE);
+ pScreen->screensaver.pWindow = NullWindow;
+ FreeResource(pScreen->screensaver.wid, RT_NONE);
}
break;
case SCREEN_SAVER_CYCLE:
- if (savedScreenInfo[i].blanked == SCREEN_IS_TILED)
+ if (pScreen->screensaver.blanked == SCREEN_IS_TILED)
{
- WindowPtr pWin = savedScreenInfo[i].pWindow;
+ WindowPtr pWin = pScreen->screensaver.pWindow;
/* make it look like screen saver is off, so that
* NotClippedByChildren will compute a clip list
* for the root window, so miPaintWindow works
@@ -3202,35 +3171,33 @@ dixSaveScreens(ClientPtr client, int on, int mode) * Call the DDX saver in case it wants to do something
* at cycle time
*/
- else if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED)
+ else if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED)
{
- (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i],
- type);
+ (* pScreen->SaveScreen) (pScreen, type);
}
break;
case SCREEN_SAVER_ON:
if (ScreenSaverBlanking != DontPreferBlanking)
{
- if ((* screenInfo.screens[i]->SaveScreen)
- (screenInfo.screens[i], what))
+ if ((* pScreen->SaveScreen) (pScreen, what))
{
- savedScreenInfo[i].blanked = SCREEN_IS_BLANKED;
+ pScreen->screensaver.blanked = SCREEN_IS_BLANKED;
continue;
}
if ((ScreenSaverAllowExposures != DontAllowExposures) &&
- TileScreenSaver(i, SCREEN_IS_BLACK))
+ TileScreenSaver(pScreen, SCREEN_IS_BLACK))
{
- savedScreenInfo[i].blanked = SCREEN_IS_BLACK;
+ pScreen->screensaver.blanked = SCREEN_IS_BLACK;
continue;
}
}
if ((ScreenSaverAllowExposures != DontAllowExposures) &&
- TileScreenSaver(i, SCREEN_IS_TILED))
+ TileScreenSaver(pScreen, SCREEN_IS_TILED))
{
- savedScreenInfo[i].blanked = SCREEN_IS_TILED;
+ pScreen->screensaver.blanked = SCREEN_IS_TILED;
}
else
- savedScreenInfo[i].blanked = SCREEN_ISNT_SAVED;
+ pScreen->screensaver.blanked = SCREEN_ISNT_SAVED;
break;
}
}
@@ -3252,7 +3219,7 @@ SaveScreens(int on, int mode) }
static Bool
-TileScreenSaver(int i, int kind)
+TileScreenSaver(ScreenPtr pScreen, int kind)
{
int j;
int result;
@@ -3269,9 +3236,9 @@ TileScreenSaver(int i, int kind) attri = 0;
switch (kind) {
case SCREEN_IS_TILED:
- switch (WindowTable[i]->backgroundState) {
+ switch (pScreen->root->backgroundState) {
case BackgroundPixel:
- attributes[attri++] = WindowTable[i]->background.pixel;
+ attributes[attri++] = pScreen->root->background.pixel;
mask |= CWBackPixel;
break;
case BackgroundPixmap:
@@ -3283,7 +3250,7 @@ TileScreenSaver(int i, int kind) }
break;
case SCREEN_IS_BLACK:
- attributes[attri++] = WindowTable[i]->drawable.pScreen->blackPixel;
+ attributes[attri++] = pScreen->root->drawable.pScreen->blackPixel;
mask |= CWBackPixel;
break;
}
@@ -3330,14 +3297,14 @@ TileScreenSaver(int i, int kind) }
}
- pWin = savedScreenInfo[i].pWindow =
- CreateWindow(savedScreenInfo[i].wid,
- WindowTable[i],
+ pWin = pScreen->screensaver.pWindow =
+ CreateWindow(pScreen->screensaver.wid,
+ pScreen->root,
-RANDOM_WIDTH, -RANDOM_WIDTH,
- (unsigned short)screenInfo.screens[i]->width + RANDOM_WIDTH,
- (unsigned short)screenInfo.screens[i]->height + RANDOM_WIDTH,
+ (unsigned short)pScreen->width + RANDOM_WIDTH,
+ (unsigned short)pScreen->height + RANDOM_WIDTH,
0, InputOutput, mask, attributes, 0, serverClient,
- wVisual (WindowTable[i]), &result);
+ wVisual (pScreen->root), &result);
if (cursor)
FreeResource (cursorID, RT_NONE);
@@ -3346,7 +3313,7 @@ TileScreenSaver(int i, int kind) return FALSE;
if (!AddResource(pWin->drawable.id, RT_WINDOW,
- (pointer)savedScreenInfo[i].pWindow))
+ (pointer)pScreen->screensaver.pWindow))
return FALSE;
if (mask & CWBackPixmap)
diff --git a/xorg-server/doc/xml/Xserver-spec.xml b/xorg-server/doc/xml/Xserver-spec.xml index 022023f5e..7249d4267 100644 --- a/xorg-server/doc/xml/Xserver-spec.xml +++ b/xorg-server/doc/xml/Xserver-spec.xml @@ -2101,7 +2101,7 @@ Making direct calls is faster on many architectures.</para> BoxPtr rect;
int size;
- macro: RegionPtr REGION_CREATE(pScreen, rect, size)
+ macro: RegionPtr RegionCreate(rect, size)
</programlisting></blockquote>
RegionCreate creates a region that describes ONE rectangle. The
@@ -2122,7 +2122,7 @@ applicable.</para> BoxPtr rect;
int size;
- macro: REGION_INIT(pScreen, pRegion, rect, size)
+ macro: RegionInit(pRegion, rect, size)
</programlisting></blockquote>
Given an existing raw region structure (such as an local variable), this
@@ -2136,7 +2136,7 @@ allocation overhead for the region structure itself. Bool pScreen->RegionCopy(dstrgn, srcrgn)
RegionPtr dstrgn, srcrgn;
- macro: Bool REGION_COPY(pScreen, dstrgn, srcrgn)
+ macro: Bool RegionCopy(dstrgn, srcrgn)
</programlisting></blockquote>
RegionCopy copies the description of one region, srcrgn, to another
@@ -2148,7 +2148,7 @@ dstrgn; returning TRUE if the copy succeeded, and FALSE otherwise.</para> void pScreen->RegionDestroy( pRegion)
RegionPtr pRegion;
- macro: REGION_DESTROY(pScreen, pRegion)
+ macro: RegionDestroy(pRegion)
</programlisting></blockquote>
RegionDestroy destroys a region and frees all allocated memory.</para>
@@ -2158,7 +2158,7 @@ RegionDestroy destroys a region and frees all allocated memory.</para> void pScreen->RegionUninit (pRegion)
RegionPtr pRegion;
- macro: REGION_UNINIT(pScreen, pRegion)
+ macro: RegionUninit(pRegion)
</programlisting></blockquote>
Frees everything except the region structure itself, useful when the
@@ -2171,23 +2171,23 @@ it has been RegionInit'ed again.</para> Bool pScreen->Intersect(newReg, reg1, reg2)
RegionPtr newReg, reg1, reg2;
- macro: Bool REGION_INTERSECT(pScreen, newReg, reg1, reg2)
+ macro: Bool RegionIntersect(newReg, reg1, reg2)
Bool pScreen->Union(newReg, reg1, reg2)
RegionPtr newReg, reg1, reg2;
- macro: Bool REGION_UNION(pScreen, newReg, reg1, reg2)
+ macro: Bool RegionUnion(newReg, reg1, reg2)
Bool pScreen->Subtract(newReg, regMinuend, regSubtrahend)
RegionPtr newReg, regMinuend, regSubtrahend;
- macro: Bool REGION_UNION(pScreen, newReg, regMinuend, regSubtrahend)
+ macro: Bool RegionUnion(newReg, regMinuend, regSubtrahend)
Bool pScreen->Inverse(newReg, pReg, pBox)
RegionPtr newReg, pReg;
BoxPtr pBox;
- macro: Bool REGION_INVERSE(pScreen, newReg, pReg, pBox)
+ macro: Bool RegionInverse(newReg, pReg, pBox)
</programlisting></blockquote>
The above four calls all do basic logical operations on regions. They
@@ -2213,7 +2213,7 @@ Each routine must return the value TRUE for success.</para> RegionPtr pRegion;
BoxPtr pBox;
- macro: REGION_RESET(pScreen, pRegion, pBox)
+ macro: RegionReset(pRegion, pBox)
</programlisting></blockquote>
RegionReset sets the region to describe
@@ -2225,7 +2225,7 @@ one rectangle and reallocates it to a size of one rectangle, if applicable.</par RegionPtr pRegion;
int x, y;
- macro: REGION_TRANSLATE(pScreen, pRegion, x, y)
+ macro: RegionTranslate(pRegion, x, y)
</programlisting></blockquote>
TranslateRegion simply moves a region +x in the x direction and +y in the y
@@ -2237,7 +2237,7 @@ direction.</para> RegionPtr pRegion;
BoxPtr pBox;
- macro: int RECT_IN_REGION(pScreen, pRegion, pBox)
+ macro: int RegionContainsRect(pRegion, pBox)
</programlisting></blockquote>
RectIn returns one of the defined constants rgnIN, rgnOUT, or rgnPART,
@@ -2252,7 +2252,7 @@ These constants are defined in Xserver/include/region.h.</para> int x, y;
BoxPtr pBox;
- macro: Bool POINT_IN_REGION(pScreen, pRegion, x, y, pBox)
+ macro: Bool RegionContainsPoint(pRegion, x, y, pBox)
</programlisting></blockquote>
PointInRegion returns true if the point x, y is in the region. In
@@ -2275,7 +2275,7 @@ returned box.</para> Bool pScreen->RegionNotEmpty(pRegion)
RegionPtr pRegion;
- macro: Bool REGION_NOTEMPTY(pScreen, pRegion)
+ macro: Bool RegionNotEmpty(pRegion)
</programlisting></blockquote>
RegionNotEmpty is a boolean function that returns
@@ -2286,7 +2286,7 @@ true or false depending upon whether the region encloses any pixels.</para> void pScreen->RegionEmpty(pRegion)
RegionPtr pRegion;
- macro: REGION_EMPTY(pScreen, pRegion)
+ macro: RegionEmpty(pRegion)
</programlisting></blockquote>
RegionEmpty sets the region to be empty.</para>
@@ -2296,7 +2296,7 @@ RegionEmpty sets the region to be empty.</para> BoxPtr pScreen->RegionExtents(pRegion)
RegionPtr pRegion;
- macro: REGION_EXTENTS(pScreen, pRegion)
+ macro: RegionExtents(pRegion)
</programlisting></blockquote>
RegionExtents returns a rectangle that is the smallest
@@ -2310,13 +2310,13 @@ in your region struct.</para> RegionPtr pDstRgn;
RegionPtr pRegion;
- macro: Bool REGION_APPEND(pScreen, pDstRgn, pRegion)
+ macro: Bool RegionAppend(pDstRgn, pRegion)
Bool pScreen->RegionValidate (pRegion, pOverlap)
RegionPtr pRegion;
Bool *pOverlap;
- macro: Bool REGION_VALIDATE(pScreen, pRegion, pOverlap)
+ macro: Bool RegionValidate(pRegion, pOverlap)
</programlisting></blockquote>
These functions provide an optimization for clip list generation and
@@ -2332,7 +2332,7 @@ regions overlap; FALSE otherwise.</para> RegionPtr pScreen->BitmapToRegion (pPixmap)
PixmapPtr pPixmap;
- macro: RegionPtr BITMAP_TO_REGION(pScreen, pPixmap)
+ macro: RegionPtr BitmapToRegion(pScreen, pPixmap)
</programlisting></blockquote>
Given a depth-1 pixmap, this routine must create a valid region which
@@ -2346,7 +2346,7 @@ areas filled with 0's. This routine returns NULL if out of memory.</para> xRectangle *pRects;
int ordering;
- macro: RegionPtr RECTS_TO_REGION(pScreen, nrects, pRects, ordering)
+ macro: RegionPtr RegionFromRects(nrects, pRects, ordering)
</programlisting></blockquote>
Given a client-supplied list of rectangles, produces a region which includes
diff --git a/xorg-server/exa/exa.c b/xorg-server/exa/exa.c index a7bb5a29f..823c9a23f 100644 --- a/xorg-server/exa/exa.c +++ b/xorg-server/exa/exa.c @@ -37,12 +37,9 @@ #include "exa_priv.h"
#include "exa.h"
-static int exaScreenPrivateKeyIndex;
-DevPrivateKey exaScreenPrivateKey = &exaScreenPrivateKeyIndex;
-static int exaPixmapPrivateKeyIndex;
-DevPrivateKey exaPixmapPrivateKey = &exaPixmapPrivateKeyIndex;
-static int exaGCPrivateKeyIndex;
-DevPrivateKey exaGCPrivateKey = &exaGCPrivateKeyIndex;
+DevPrivateKeyRec exaScreenPrivateKeyRec;
+DevPrivateKeyRec exaPixmapPrivateKeyRec;
+DevPrivateKeyRec exaGCPrivateKeyRec;
#ifdef MITSHM
static ShmFuncs exaShmFuncs = { NULL, NULL };
@@ -161,10 +158,10 @@ exaPixmapDirty (PixmapPtr pPix, int x1, int y1, int x2, int y2) if (box.x1 >= box.x2 || box.y1 >= box.y2)
return;
- REGION_INIT(pScreen, ®ion, &box, 1);
+ RegionInit(®ion, &box, 1);
DamageRegionAppend(&pPix->drawable, ®ion);
DamageRegionProcessPending(&pPix->drawable);
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
}
static int
@@ -658,7 +655,7 @@ exaBitmapToRegion(PixmapPtr pPix) exaPrepareAccess(&pPix->drawable, EXA_PREPARE_SRC);
swap(pExaScr, pScreen, BitmapToRegion);
- ret = pScreen->BitmapToRegion(pPix);
+ ret = (*pScreen->BitmapToRegion)(pPix);
swap(pExaScr, pScreen, BitmapToRegion);
exaFinishAccess(&pPix->drawable, EXA_PREPARE_SRC);
@@ -889,7 +886,13 @@ exaDriverInit (ScreenPtr pScreen, ps = GetPictureScreenIfSet(pScreen);
- pExaScr = calloc(sizeof (ExaScreenPrivRec), 1);
+ if (!dixRegisterPrivateKey(&exaScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) {
+ LogMessage(X_WARNING, "EXA(%d): Failed to register screen private\n",
+ pScreen->myNum);
+ return FALSE;
+ }
+
+ pExaScr = calloc (sizeof (ExaScreenPrivRec), 1);
if (!pExaScr) {
LogMessage(X_WARNING, "EXA(%d): Failed to allocate screen private\n",
pScreen->myNum);
@@ -904,7 +907,7 @@ exaDriverInit (ScreenPtr pScreen, exaDDXDriverInit(pScreen);
- if (!dixRequestPrivate(exaGCPrivateKey, sizeof(ExaGCPrivRec))) {
+ if (!dixRegisterPrivateKey(&exaGCPrivateKeyRec, PRIVATE_GC, sizeof(ExaGCPrivRec))) {
LogMessage(X_WARNING,
"EXA(%d): Failed to allocate GC private\n",
pScreen->myNum);
@@ -953,7 +956,7 @@ exaDriverInit (ScreenPtr pScreen, */
if (pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS)
{
- if (!dixRequestPrivate(exaPixmapPrivateKey, sizeof(ExaPixmapPrivRec))) {
+ if (!dixRegisterPrivateKey(&exaPixmapPrivateKeyRec, PRIVATE_PIXMAP, sizeof(ExaPixmapPrivRec))) {
LogMessage(X_WARNING,
"EXA(%d): Failed to allocate pixmap private\n",
pScreen->myNum);
diff --git a/xorg-server/exa/exa_accel.c b/xorg-server/exa/exa_accel.c index 47f955da5..10713f89b 100644 --- a/xorg-server/exa/exa_accel.c +++ b/xorg-server/exa/exa_accel.c @@ -81,7 +81,7 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n, return;
}
- pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+ pextent = RegionExtents(pClip);
extentX1 = pextent->x1;
extentY1 = pextent->y1;
extentX2 = pextent->x2;
@@ -106,7 +106,7 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n, if (fullX1 >= fullX2)
continue;
- nbox = REGION_NUM_RECTS (pClip);
+ nbox = RegionNumRects (pClip);
if (nbox == 1)
{
(*pExaScr->info->Solid) (pPixmap,
@@ -115,7 +115,7 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n, }
else
{
- pbox = REGION_RECTS(pClip);
+ pbox = RegionRects(pClip);
while(nbox--)
{
if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)
@@ -192,8 +192,8 @@ exaDoPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, y += pDrawable->y;
pClip = fbGetCompositeClip(pGC);
- for (nbox = REGION_NUM_RECTS(pClip),
- pbox = REGION_RECTS(pClip);
+ for (nbox = RegionNumRects(pClip),
+ pbox = RegionRects(pClip);
nbox--;
pbox++)
{
@@ -407,7 +407,7 @@ exaHWCopyNtoN (DrawablePtr pSrcDrawable, rects[i].height = pbox[i].y2 - pbox[i].y1;
}
- /* This must match the miRegionCopy() logic for reversing rect order */
+ /* This must match the RegionCopy() logic for reversing rect order */
if (nbox == 1 || (dx > 0 && dy > 0) ||
(pDstDrawable != pSrcDrawable &&
(pDstDrawable->type != DRAWABLE_WINDOW ||
@@ -416,15 +416,15 @@ exaHWCopyNtoN (DrawablePtr pSrcDrawable, else
ordering = CT_UNSORTED;
- srcregion = RECTS_TO_REGION(pScreen, nbox, rects, ordering);
+ srcregion = RegionFromRects(nbox, rects, ordering);
free(rects);
if (!pGC || !exaGCReadsDestination(pDstDrawable, pGC->planemask,
pGC->fillStyle, pGC->alu,
pGC->clientClipType)) {
- dstregion = REGION_CREATE(pScreen, NullBox, 0);
- REGION_COPY(pScreen, dstregion, srcregion);
- REGION_TRANSLATE(pScreen, dstregion, dst_off_x - dx - src_off_x,
+ dstregion = RegionCreate(NullBox, 0);
+ RegionCopy(dstregion, srcregion);
+ RegionTranslate(dstregion, dst_off_x - dx - src_off_x,
dst_off_y - dy - src_off_y);
}
}
@@ -551,12 +551,12 @@ fallback: out:
if (dstregion) {
- REGION_UNINIT(pScreen, dstregion);
- REGION_DESTROY(pScreen, dstregion);
+ RegionUninit(dstregion);
+ RegionDestroy(dstregion);
}
if (srcregion) {
- REGION_UNINIT(pScreen, srcregion);
- REGION_DESTROY(pScreen, srcregion);
+ RegionUninit(srcregion);
+ RegionDestroy(srcregion);
}
return ret;
@@ -788,13 +788,13 @@ exaPolyFillRect(DrawablePtr pDrawable, int xoff, yoff;
int xorg, yorg;
int n;
- RegionPtr pReg = RECTS_TO_REGION(pScreen, nrect, prect, CT_UNSORTED);
+ RegionPtr pReg = RegionFromRects(nrect, prect, CT_UNSORTED);
/* Compute intersection of rects and clip region */
- REGION_TRANSLATE(pScreen, pReg, pDrawable->x, pDrawable->y);
- REGION_INTERSECT(pScreen, pReg, pClip, pReg);
+ RegionTranslate(pReg, pDrawable->x, pDrawable->y);
+ RegionIntersect(pReg, pClip, pReg);
- if (!REGION_NUM_RECTS(pReg)) {
+ if (!RegionNumRects(pReg)) {
goto out;
}
@@ -856,7 +856,7 @@ fallback: xorg = pDrawable->x;
yorg = pDrawable->y;
- pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+ pextent = RegionExtents(pClip);
extentX1 = pextent->x1;
extentY1 = pextent->y1;
extentX2 = pextent->x2;
@@ -883,7 +883,7 @@ fallback: if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
continue;
- n = REGION_NUM_RECTS (pClip);
+ n = RegionNumRects (pClip);
if (n == 1)
{
(*pExaScr->info->Solid) (pPixmap,
@@ -892,7 +892,7 @@ fallback: }
else
{
- pbox = REGION_RECTS(pClip);
+ pbox = RegionRects(pClip);
/*
* clip the rectangle to each box in the clip region
* this is logically equivalent to calling Intersect(),
@@ -927,8 +927,8 @@ fallback: exaMarkSync(pDrawable->pScreen);
out:
- REGION_UNINIT(pScreen, pReg);
- REGION_DESTROY(pScreen, pReg);
+ RegionUninit(pReg);
+ RegionDestroy(pReg);
}
const GCOps exaOps = {
@@ -964,14 +964,14 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
- REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+ RegionTranslate(prgnSrc, -dx, -dy);
- REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
+ RegionInit(&rgnDst, NullBox, 0);
- REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
#ifdef COMPOSITE
if (pPixmap->screen_x || pPixmap->screen_y)
- REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
+ RegionTranslate(&rgnDst,
-pPixmap->screen_x, -pPixmap->screen_y);
#endif
@@ -987,11 +987,11 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) pExaScr->fallback_flags &= ~EXA_ACCEL_COPYWINDOW;
fallback:
- REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if (pExaScr->fallback_flags & EXA_FALLBACK_COPYWINDOW) {
pExaScr->fallback_flags &= ~EXA_FALLBACK_COPYWINDOW;
- REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, dx, dy);
+ RegionTranslate(prgnSrc, dx, dy);
ExaCheckCopyWindow(pWin, ptOldOrg, prgnSrc);
}
}
@@ -1007,7 +1007,7 @@ exaFillRegionSolid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel, Bool ret = FALSE;
exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
- REGION_TRANSLATE(pScreen, pRegion, xoff, yoff);
+ RegionTranslate(pRegion, xoff, yoff);
if (pExaScr->fallback_counter || pExaPixmap->accel_blocked)
goto out;
@@ -1030,8 +1030,8 @@ exaFillRegionSolid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel, int nbox;
BoxPtr pBox;
- nbox = REGION_NUM_RECTS (pRegion);
- pBox = REGION_RECTS (pRegion);
+ nbox = RegionNumRects (pRegion);
+ pBox = RegionRects (pRegion);
while (nbox--)
{
@@ -1060,18 +1060,18 @@ exaFillRegionSolid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel, *(CARD8*)pExaPixmap->sys_ptr = pixel;
}
- REGION_UNION(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
+ RegionUnion(&pExaPixmap->validSys, &pExaPixmap->validSys,
pRegion);
- REGION_UNION(pScreen, &pExaPixmap->validFB, &pExaPixmap->validFB,
+ RegionUnion(&pExaPixmap->validFB, &pExaPixmap->validFB,
pRegion);
- REGION_SUBTRACT(pScreen, pending_damage, pending_damage, pRegion);
+ RegionSubtract(pending_damage, pending_damage, pRegion);
}
ret = TRUE;
}
out:
- REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
+ RegionTranslate(pRegion, -xoff, -yoff);
return ret;
}
@@ -1090,8 +1090,8 @@ exaFillRegionTiled (DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile, ExaPixmapPrivPtr pTileExaPixmap = ExaGetPixmapPriv(pTile);
int xoff, yoff;
int tileWidth, tileHeight;
- int nbox = REGION_NUM_RECTS (pRegion);
- BoxPtr pBox = REGION_RECTS (pRegion);
+ int nbox = RegionNumRects (pRegion);
+ BoxPtr pBox = RegionRects (pRegion);
Bool ret = FALSE;
int i;
@@ -1137,7 +1137,7 @@ exaFillRegionTiled (DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile, if ((*pExaScr->info->PrepareCopy) (pTile, pPixmap, 1, 1, alu, planemask))
{
if (xoff || yoff)
- REGION_TRANSLATE(pScreen, pRegion, xoff, yoff);
+ RegionTranslate(pRegion, xoff, yoff);
for (i = 0; i < nbox; i++)
{
@@ -1245,7 +1245,7 @@ exaFillRegionTiled (DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile, exaMarkSync(pDrawable->pScreen);
if (xoff || yoff)
- REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
+ RegionTranslate(pRegion, -xoff, -yoff);
}
return ret;
diff --git a/xorg-server/exa/exa_classic.c b/xorg-server/exa/exa_classic.c index e1ead6c0d..8b92d6880 100644 --- a/xorg-server/exa/exa_classic.c +++ b/xorg-server/exa/exa_classic.c @@ -1,267 +1,267 @@ -/* - * Copyright 2009 Maarten Maathuis - * - * 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 (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <string.h> - -#include "exa_priv.h" -#include "exa.h" - -/* This file holds the classic exa specific implementation. */ - -static _X_INLINE void* -ExaGetPixmapAddress(PixmapPtr p) -{ - ExaPixmapPriv(p); - - if (pExaPixmap->use_gpu_copy && pExaPixmap->fb_ptr) - return pExaPixmap->fb_ptr; - else - return pExaPixmap->sys_ptr; -} - -/** - * exaCreatePixmap() creates a new pixmap. - * - * If width and height are 0, this won't be a full-fledged pixmap and it will - * get ModifyPixmapHeader() called on it later. So, we mark it as pinned, because - * ModifyPixmapHeader() would break migration. These types of pixmaps are used - * for scratch pixmaps, or to represent the visible screen. - */ -PixmapPtr -exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth, - unsigned usage_hint) -{ - PixmapPtr pPixmap; - ExaPixmapPrivPtr pExaPixmap; - BoxRec box; - int bpp; - ExaScreenPriv(pScreen); - - if (w > 32767 || h > 32767) - return NullPixmap; - - swap(pExaScr, pScreen, CreatePixmap); - pPixmap = pScreen->CreatePixmap (pScreen, w, h, depth, usage_hint); - swap(pExaScr, pScreen, CreatePixmap); - - if (!pPixmap) - return NULL; - - pExaPixmap = ExaGetPixmapPriv(pPixmap); - pExaPixmap->driverPriv = NULL; - - bpp = pPixmap->drawable.bitsPerPixel; - - pExaPixmap->driverPriv = NULL; - /* Scratch pixmaps may have w/h equal to zero, and may not be - * migrated. - */ - if (!w || !h) - pExaPixmap->score = EXA_PIXMAP_SCORE_PINNED; - else - pExaPixmap->score = EXA_PIXMAP_SCORE_INIT; - - pExaPixmap->sys_ptr = pPixmap->devPrivate.ptr; - pExaPixmap->sys_pitch = pPixmap->devKind; - - pPixmap->devPrivate.ptr = NULL; - pExaPixmap->use_gpu_copy = FALSE; - - pExaPixmap->fb_ptr = NULL; - exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp); - pExaPixmap->fb_size = pExaPixmap->fb_pitch * h; - - if (pExaPixmap->fb_pitch > 131071) { - swap(pExaScr, pScreen, DestroyPixmap); - pScreen->DestroyPixmap (pPixmap); - swap(pExaScr, pScreen, DestroyPixmap); - return NULL; - } - - /* Set up damage tracking */ - pExaPixmap->pDamage = DamageCreate (NULL, NULL, - DamageReportNone, TRUE, - pScreen, pPixmap); - - if (pExaPixmap->pDamage == NULL) { - swap(pExaScr, pScreen, DestroyPixmap); - pScreen->DestroyPixmap (pPixmap); - swap(pExaScr, pScreen, DestroyPixmap); - return NULL; - } - - DamageRegister (&pPixmap->drawable, pExaPixmap->pDamage); - /* This ensures that pending damage reflects the current operation. */ - /* This is used by exa to optimize migration. */ - DamageSetReportAfterOp (pExaPixmap->pDamage, TRUE); - - pExaPixmap->area = NULL; - - /* We set the initial pixmap as completely valid for a simple reason. - * Imagine a 1000x1000 pixmap, it has 1 million pixels, 250000 of which - * could form single pixel rects as part of a region. Setting the complete region - * as valid is a natural defragmentation of the region. - */ - box.x1 = 0; - box.y1 = 0; - box.x2 = w; - box.y2 = h; - REGION_INIT(pScreen, &pExaPixmap->validSys, &box, 0); - REGION_INIT(pScreen, &pExaPixmap->validFB, &box, 0); - - exaSetAccelBlock(pExaScr, pExaPixmap, - w, h, bpp); - - /* During a fallback we must prepare access. */ - if (pExaScr->fallback_counter) - exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_AUX_DEST); - - return pPixmap; -} - -Bool -exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int depth, - int bitsPerPixel, int devKind, pointer pPixData) -{ - ScreenPtr pScreen; - ExaScreenPrivPtr pExaScr; - ExaPixmapPrivPtr pExaPixmap; - Bool ret; - - if (!pPixmap) - return FALSE; - - pScreen = pPixmap->drawable.pScreen; - pExaScr = ExaGetScreenPriv(pScreen); - pExaPixmap = ExaGetPixmapPriv(pPixmap); - - if (pExaPixmap) { - if (pPixData) - pExaPixmap->sys_ptr = pPixData; - - if (devKind > 0) - pExaPixmap->sys_pitch = devKind; - - /* Classic EXA: - * - Framebuffer. - * - Scratch pixmap with gpu memory. - */ - if (pExaScr->info->memoryBase && pPixData) { - if ((CARD8 *)pPixData >= pExaScr->info->memoryBase && - ((CARD8 *)pPixData - pExaScr->info->memoryBase) < - pExaScr->info->memorySize) { - pExaPixmap->fb_ptr = pPixData; - pExaPixmap->fb_pitch = devKind; - pExaPixmap->use_gpu_copy = TRUE; - } - } - - if (width > 0 && height > 0 && bitsPerPixel > 0) { - exaSetFbPitch(pExaScr, pExaPixmap, - width, height, bitsPerPixel); - - exaSetAccelBlock(pExaScr, pExaPixmap, - width, height, bitsPerPixel); - } - - /* Pixmaps subject to ModifyPixmapHeader will be pinned to system or - * gpu memory, so there's no need to track damage. - */ - if (pExaPixmap->pDamage) { - DamageUnregister(&pPixmap->drawable, pExaPixmap->pDamage); - DamageDestroy(pExaPixmap->pDamage); - pExaPixmap->pDamage = NULL; - } - } - - swap(pExaScr, pScreen, ModifyPixmapHeader); - ret = pScreen->ModifyPixmapHeader(pPixmap, width, height, depth, - bitsPerPixel, devKind, pPixData); - swap(pExaScr, pScreen, ModifyPixmapHeader); - - /* Always NULL this, we don't want lingering pointers. */ - pPixmap->devPrivate.ptr = NULL; - - return ret; -} - -Bool -exaDestroyPixmap_classic (PixmapPtr pPixmap) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - ExaScreenPriv(pScreen); - Bool ret; - - if (pPixmap->refcnt == 1) - { - ExaPixmapPriv (pPixmap); - - /* During a fallback we must finish access, but we don't know the index. */ - if (pExaScr->fallback_counter) - exaFinishAccess(&pPixmap->drawable, -1); - - if (pExaPixmap->area) - { - DBG_PIXMAP(("-- 0x%p (0x%x) (%dx%d)\n", - (void*)pPixmap->drawable.id, - ExaGetPixmapPriv(pPixmap)->area->offset, - pPixmap->drawable.width, - pPixmap->drawable.height)); - /* Free the offscreen area */ - exaOffscreenFree (pPixmap->drawable.pScreen, pExaPixmap->area); - pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr; - pPixmap->devKind = pExaPixmap->sys_pitch; - } - REGION_UNINIT(pPixmap->drawable.pScreen, &pExaPixmap->validSys); - REGION_UNINIT(pPixmap->drawable.pScreen, &pExaPixmap->validFB); - } - - swap(pExaScr, pScreen, DestroyPixmap); - ret = pScreen->DestroyPixmap (pPixmap); - swap(pExaScr, pScreen, DestroyPixmap); - - return ret; -} - -Bool -exaPixmapHasGpuCopy_classic(PixmapPtr pPixmap) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - ExaScreenPriv(pScreen); - ExaPixmapPriv(pPixmap); - Bool ret; - - if (pExaScr->info->PixmapIsOffscreen) { - pPixmap->devPrivate.ptr = ExaGetPixmapAddress(pPixmap); - ret = pExaScr->info->PixmapIsOffscreen(pPixmap); - pPixmap->devPrivate.ptr = NULL; - } else - ret = (pExaPixmap->use_gpu_copy && pExaPixmap->fb_ptr); - - return ret; -} +/*
+ * Copyright 2009 Maarten Maathuis
+ *
+ * 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 (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+
+#include "exa_priv.h"
+#include "exa.h"
+
+/* This file holds the classic exa specific implementation. */
+
+static _X_INLINE void*
+ExaGetPixmapAddress(PixmapPtr p)
+{
+ ExaPixmapPriv(p);
+
+ if (pExaPixmap->use_gpu_copy && pExaPixmap->fb_ptr)
+ return pExaPixmap->fb_ptr;
+ else
+ return pExaPixmap->sys_ptr;
+}
+
+/**
+ * exaCreatePixmap() creates a new pixmap.
+ *
+ * If width and height are 0, this won't be a full-fledged pixmap and it will
+ * get ModifyPixmapHeader() called on it later. So, we mark it as pinned, because
+ * ModifyPixmapHeader() would break migration. These types of pixmaps are used
+ * for scratch pixmaps, or to represent the visible screen.
+ */
+PixmapPtr
+exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth,
+ unsigned usage_hint)
+{
+ PixmapPtr pPixmap;
+ ExaPixmapPrivPtr pExaPixmap;
+ BoxRec box;
+ int bpp;
+ ExaScreenPriv(pScreen);
+
+ if (w > 32767 || h > 32767)
+ return NullPixmap;
+
+ swap(pExaScr, pScreen, CreatePixmap);
+ pPixmap = pScreen->CreatePixmap (pScreen, w, h, depth, usage_hint);
+ swap(pExaScr, pScreen, CreatePixmap);
+
+ if (!pPixmap)
+ return NULL;
+
+ pExaPixmap = ExaGetPixmapPriv(pPixmap);
+ pExaPixmap->driverPriv = NULL;
+
+ bpp = pPixmap->drawable.bitsPerPixel;
+
+ pExaPixmap->driverPriv = NULL;
+ /* Scratch pixmaps may have w/h equal to zero, and may not be
+ * migrated.
+ */
+ if (!w || !h)
+ pExaPixmap->score = EXA_PIXMAP_SCORE_PINNED;
+ else
+ pExaPixmap->score = EXA_PIXMAP_SCORE_INIT;
+
+ pExaPixmap->sys_ptr = pPixmap->devPrivate.ptr;
+ pExaPixmap->sys_pitch = pPixmap->devKind;
+
+ pPixmap->devPrivate.ptr = NULL;
+ pExaPixmap->use_gpu_copy = FALSE;
+
+ pExaPixmap->fb_ptr = NULL;
+ exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp);
+ pExaPixmap->fb_size = pExaPixmap->fb_pitch * h;
+
+ if (pExaPixmap->fb_pitch > 131071) {
+ swap(pExaScr, pScreen, DestroyPixmap);
+ pScreen->DestroyPixmap (pPixmap);
+ swap(pExaScr, pScreen, DestroyPixmap);
+ return NULL;
+ }
+
+ /* Set up damage tracking */
+ pExaPixmap->pDamage = DamageCreate (NULL, NULL,
+ DamageReportNone, TRUE,
+ pScreen, pPixmap);
+
+ if (pExaPixmap->pDamage == NULL) {
+ swap(pExaScr, pScreen, DestroyPixmap);
+ pScreen->DestroyPixmap (pPixmap);
+ swap(pExaScr, pScreen, DestroyPixmap);
+ return NULL;
+ }
+
+ DamageRegister (&pPixmap->drawable, pExaPixmap->pDamage);
+ /* This ensures that pending damage reflects the current operation. */
+ /* This is used by exa to optimize migration. */
+ DamageSetReportAfterOp (pExaPixmap->pDamage, TRUE);
+
+ pExaPixmap->area = NULL;
+
+ /* We set the initial pixmap as completely valid for a simple reason.
+ * Imagine a 1000x1000 pixmap, it has 1 million pixels, 250000 of which
+ * could form single pixel rects as part of a region. Setting the complete region
+ * as valid is a natural defragmentation of the region.
+ */
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = w;
+ box.y2 = h;
+ RegionInit(&pExaPixmap->validSys, &box, 0);
+ RegionInit(&pExaPixmap->validFB, &box, 0);
+
+ exaSetAccelBlock(pExaScr, pExaPixmap,
+ w, h, bpp);
+
+ /* During a fallback we must prepare access. */
+ if (pExaScr->fallback_counter)
+ exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_AUX_DEST);
+
+ return pPixmap;
+}
+
+Bool
+exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int depth,
+ int bitsPerPixel, int devKind, pointer pPixData)
+{
+ ScreenPtr pScreen;
+ ExaScreenPrivPtr pExaScr;
+ ExaPixmapPrivPtr pExaPixmap;
+ Bool ret;
+
+ if (!pPixmap)
+ return FALSE;
+
+ pScreen = pPixmap->drawable.pScreen;
+ pExaScr = ExaGetScreenPriv(pScreen);
+ pExaPixmap = ExaGetPixmapPriv(pPixmap);
+
+ if (pExaPixmap) {
+ if (pPixData)
+ pExaPixmap->sys_ptr = pPixData;
+
+ if (devKind > 0)
+ pExaPixmap->sys_pitch = devKind;
+
+ /* Classic EXA:
+ * - Framebuffer.
+ * - Scratch pixmap with gpu memory.
+ */
+ if (pExaScr->info->memoryBase && pPixData) {
+ if ((CARD8 *)pPixData >= pExaScr->info->memoryBase &&
+ ((CARD8 *)pPixData - pExaScr->info->memoryBase) <
+ pExaScr->info->memorySize) {
+ pExaPixmap->fb_ptr = pPixData;
+ pExaPixmap->fb_pitch = devKind;
+ pExaPixmap->use_gpu_copy = TRUE;
+ }
+ }
+
+ if (width > 0 && height > 0 && bitsPerPixel > 0) {
+ exaSetFbPitch(pExaScr, pExaPixmap,
+ width, height, bitsPerPixel);
+
+ exaSetAccelBlock(pExaScr, pExaPixmap,
+ width, height, bitsPerPixel);
+ }
+
+ /* Pixmaps subject to ModifyPixmapHeader will be pinned to system or
+ * gpu memory, so there's no need to track damage.
+ */
+ if (pExaPixmap->pDamage) {
+ DamageUnregister(&pPixmap->drawable, pExaPixmap->pDamage);
+ DamageDestroy(pExaPixmap->pDamage);
+ pExaPixmap->pDamage = NULL;
+ }
+ }
+
+ swap(pExaScr, pScreen, ModifyPixmapHeader);
+ ret = pScreen->ModifyPixmapHeader(pPixmap, width, height, depth,
+ bitsPerPixel, devKind, pPixData);
+ swap(pExaScr, pScreen, ModifyPixmapHeader);
+
+ /* Always NULL this, we don't want lingering pointers. */
+ pPixmap->devPrivate.ptr = NULL;
+
+ return ret;
+}
+
+Bool
+exaDestroyPixmap_classic (PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ ExaScreenPriv(pScreen);
+ Bool ret;
+
+ if (pPixmap->refcnt == 1)
+ {
+ ExaPixmapPriv (pPixmap);
+
+ /* During a fallback we must finish access, but we don't know the index. */
+ if (pExaScr->fallback_counter)
+ exaFinishAccess(&pPixmap->drawable, -1);
+
+ if (pExaPixmap->area)
+ {
+ DBG_PIXMAP(("-- 0x%p (0x%x) (%dx%d)\n",
+ (void*)pPixmap->drawable.id,
+ ExaGetPixmapPriv(pPixmap)->area->offset,
+ pPixmap->drawable.width,
+ pPixmap->drawable.height));
+ /* Free the offscreen area */
+ exaOffscreenFree (pPixmap->drawable.pScreen, pExaPixmap->area);
+ pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr;
+ pPixmap->devKind = pExaPixmap->sys_pitch;
+ }
+ RegionUninit(&pExaPixmap->validSys);
+ RegionUninit(&pExaPixmap->validFB);
+ }
+
+ swap(pExaScr, pScreen, DestroyPixmap);
+ ret = pScreen->DestroyPixmap (pPixmap);
+ swap(pExaScr, pScreen, DestroyPixmap);
+
+ return ret;
+}
+
+Bool
+exaPixmapHasGpuCopy_classic(PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ ExaScreenPriv(pScreen);
+ ExaPixmapPriv(pPixmap);
+ Bool ret;
+
+ if (pExaScr->info->PixmapIsOffscreen) {
+ pPixmap->devPrivate.ptr = ExaGetPixmapAddress(pPixmap);
+ ret = pExaScr->info->PixmapIsOffscreen(pPixmap);
+ pPixmap->devPrivate.ptr = NULL;
+ } else
+ ret = (pExaPixmap->use_gpu_copy && pExaPixmap->fb_ptr);
+
+ return ret;
+}
diff --git a/xorg-server/exa/exa_migration_classic.c b/xorg-server/exa/exa_migration_classic.c index 9e1626c69..eb1081236 100644 --- a/xorg-server/exa/exa_migration_classic.c +++ b/xorg-server/exa/exa_migration_classic.c @@ -78,8 +78,8 @@ exaPixmapIsDirty (PixmapPtr pPix) if (!pExaPixmap->pDamage)
return FALSE;
- return REGION_NOTEMPTY (pScreen, DamageRegion(pExaPixmap->pDamage)) ||
- !REGION_EQUAL(pScreen, &pExaPixmap->validSys, &pExaPixmap->validFB);
+ return RegionNotEmpty(DamageRegion(pExaPixmap->pDamage)) ||
+ !RegionEqual(&pExaPixmap->validSys, &pExaPixmap->validFB);
}
/**
@@ -123,22 +123,22 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc, /* Damaged bits are valid in current copy but invalid in other one */
if (pExaPixmap->use_gpu_copy) {
- REGION_UNION(pScreen, &pExaPixmap->validFB, &pExaPixmap->validFB,
+ RegionUnion(&pExaPixmap->validFB, &pExaPixmap->validFB,
damage);
- REGION_SUBTRACT(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
+ RegionSubtract(&pExaPixmap->validSys, &pExaPixmap->validSys,
damage);
} else {
- REGION_UNION(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
+ RegionUnion(&pExaPixmap->validSys, &pExaPixmap->validSys,
damage);
- REGION_SUBTRACT(pScreen, &pExaPixmap->validFB, &pExaPixmap->validFB,
+ RegionSubtract(&pExaPixmap->validFB, &pExaPixmap->validFB,
damage);
}
- REGION_EMPTY(pScreen, damage);
+ RegionEmpty(damage);
/* Copy bits valid in source but not in destination */
- REGION_NULL(pScreen, &CopyReg);
- REGION_SUBTRACT(pScreen, &CopyReg, pValidSrc, pValidDst);
+ RegionNull(&CopyReg);
+ RegionSubtract(&CopyReg, pValidSrc, pValidDst);
if (migrate->as_dst) {
ExaScreenPriv (pPixmap->drawable.pScreen);
@@ -153,7 +153,7 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc, RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
#if DEBUG_MIGRATE
- if (REGION_NIL(pending_damage)) {
+ if (RegionNil(pending_damage)) {
static Bool firsttime = TRUE;
if (firsttime) {
@@ -167,23 +167,23 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc, * rects by filling it up to the extents of the union of the
* destination valid region and the pending damage region.
*/
- if (REGION_NUM_RECTS(pValidDst) > 10) {
+ if (RegionNumRects(pValidDst) > 10) {
BoxRec box;
BoxPtr pValidExt, pDamageExt;
RegionRec closure;
- pValidExt = REGION_EXTENTS(pScreen, pValidDst);
- pDamageExt = REGION_EXTENTS(pScreen, pending_damage);
+ pValidExt = RegionExtents(pValidDst);
+ pDamageExt = RegionExtents(pending_damage);
box.x1 = min(pValidExt->x1, pDamageExt->x1);
box.y1 = min(pValidExt->y1, pDamageExt->y1);
box.x2 = max(pValidExt->x2, pDamageExt->x2);
box.y2 = max(pValidExt->y2, pDamageExt->y2);
- REGION_INIT(pScreen, &closure, &box, 0);
- REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, &closure);
+ RegionInit(&closure, &box, 0);
+ RegionIntersect(&CopyReg, &CopyReg, &closure);
} else
- REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, pending_damage);
+ RegionIntersect(&CopyReg, &CopyReg, pending_damage);
}
/* The caller may provide a region to be subtracted from the calculated
@@ -191,17 +191,17 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc, * contribute to the result of the operation.
*/
if (migrate->pReg)
- REGION_SUBTRACT(pScreen, &CopyReg, &CopyReg, migrate->pReg);
+ RegionSubtract(&CopyReg, &CopyReg, migrate->pReg);
} else {
/* The caller may restrict the region to be migrated for source pixmaps
* to what's relevant for the operation.
*/
if (migrate->pReg)
- REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, migrate->pReg);
+ RegionIntersect(&CopyReg, &CopyReg, migrate->pReg);
}
- pBox = REGION_RECTS(&CopyReg);
- nbox = REGION_NUM_RECTS(&CopyReg);
+ pBox = RegionRects(&CopyReg);
+ nbox = RegionNumRects(&CopyReg);
save_use_gpu_copy = pExaPixmap->use_gpu_copy;
save_pitch = pPixmap->devKind;
@@ -252,13 +252,13 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc, * removing parts of it which are also in the destination valid region.
* Removing anything beyond that would lead to data loss.
*/
- if (REGION_NUM_RECTS(pValidSrc) > 20)
- REGION_SUBTRACT(pScreen, pValidSrc, pValidSrc, pValidDst);
+ if (RegionNumRects(pValidSrc) > 20)
+ RegionSubtract(pValidSrc, pValidSrc, pValidDst);
/* The copied bits are now valid in destination */
- REGION_UNION(pScreen, pValidDst, pValidDst, &CopyReg);
+ RegionUnion(pValidDst, pValidDst, &CopyReg);
- REGION_UNINIT(pScreen, &CopyReg);
+ RegionUninit(&CopyReg);
if (access_prepared)
exaFinishAccess(&pPixmap->drawable, fallback_index);
@@ -440,7 +440,7 @@ exaPixmapSave (ScreenPtr pScreen, ExaOffscreenArea *area) /* Mark all FB bits as invalid, so all valid system bits get copied to FB
* next time */
- REGION_EMPTY(pPixmap->drawable.pScreen, &pExaPixmap->validFB);
+ RegionEmpty(&pExaPixmap->validFB);
}
/**
@@ -531,15 +531,15 @@ exaAssertNotDirty (PixmapPtr pPixmap) if (exaPixmapIsPinned(pPixmap) || pExaPixmap->area == NULL)
return ret;
- REGION_NULL(pScreen, &ValidReg);
- REGION_INTERSECT(pScreen, &ValidReg, &pExaPixmap->validFB,
+ RegionNull(&ValidReg);
+ RegionIntersect(&ValidReg, &pExaPixmap->validFB,
&pExaPixmap->validSys);
- nbox = REGION_NUM_RECTS(&ValidReg);
+ nbox = RegionNumRects(&ValidReg);
if (!nbox)
goto out;
- pBox = REGION_RECTS(&ValidReg);
+ pBox = RegionRects(&ValidReg);
dst_pitch = pExaPixmap->sys_pitch;
src_pitch = pExaPixmap->fb_pitch;
@@ -586,7 +586,7 @@ skip: pPixmap->devKind = save_pitch;
out:
- REGION_UNINIT(pScreen, &ValidReg);
+ RegionUninit(&ValidReg);
return ret;
}
diff --git a/xorg-server/exa/exa_mixed.c b/xorg-server/exa/exa_mixed.c index 49e04f22a..4425cede4 100644 --- a/xorg-server/exa/exa_mixed.c +++ b/xorg-server/exa/exa_mixed.c @@ -1,292 +1,291 @@ -/* - * Copyright 2009 Maarten Maathuis - * - * 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 (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <string.h> - -#include "exa_priv.h" -#include "exa.h" - -/* This file holds the driver allocated pixmaps + better initial placement code. - */ - -static _X_INLINE void* -ExaGetPixmapAddress(PixmapPtr p) -{ - ExaPixmapPriv(p); - - return pExaPixmap->sys_ptr; -} - -/** - * exaCreatePixmap() creates a new pixmap. - */ -PixmapPtr -exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth, - unsigned usage_hint) -{ - PixmapPtr pPixmap; - ExaPixmapPrivPtr pExaPixmap; - int bpp; - size_t paddedWidth; - ExaScreenPriv(pScreen); - - if (w > 32767 || h > 32767) - return NullPixmap; - - swap(pExaScr, pScreen, CreatePixmap); - pPixmap = pScreen->CreatePixmap(pScreen, 0, 0, depth, usage_hint); - swap(pExaScr, pScreen, CreatePixmap); - - if (!pPixmap) - return NULL; - - pExaPixmap = ExaGetPixmapPriv(pPixmap); - pExaPixmap->driverPriv = NULL; - - bpp = pPixmap->drawable.bitsPerPixel; - - paddedWidth = ((w * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits); - if (paddedWidth / 4 > 32767 || h > 32767) - return NullPixmap; - - /* We will allocate the system pixmap later if needed. */ - pPixmap->devPrivate.ptr = NULL; - pExaPixmap->sys_ptr = NULL; - pExaPixmap->sys_pitch = paddedWidth; - - pExaPixmap->area = NULL; - pExaPixmap->fb_ptr = NULL; - pExaPixmap->pDamage = NULL; - - exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp); - exaSetAccelBlock(pExaScr, pExaPixmap, - w, h, bpp); - - (*pScreen->ModifyPixmapHeader)(pPixmap, w, h, 0, 0, - paddedWidth, NULL); - - /* A scratch pixmap will become a driver pixmap right away. */ - if (!w || !h) { - exaCreateDriverPixmap_mixed(pPixmap); - pExaPixmap->use_gpu_copy = exaPixmapHasGpuCopy(pPixmap); - } else { - pExaPixmap->use_gpu_copy = FALSE; - - if (w == 1 && h == 1) { - pExaPixmap->sys_ptr = malloc((pPixmap->drawable.bitsPerPixel + 7) / 8); - - /* Set up damage tracking */ - pExaPixmap->pDamage = DamageCreate(exaDamageReport_mixed, NULL, - DamageReportNonEmpty, TRUE, - pPixmap->drawable.pScreen, - pPixmap); - - DamageRegister(&pPixmap->drawable, pExaPixmap->pDamage); - /* This ensures that pending damage reflects the current operation. */ - /* This is used by exa to optimize migration. */ - DamageSetReportAfterOp(pExaPixmap->pDamage, TRUE); - } - } - - /* During a fallback we must prepare access. */ - if (pExaScr->fallback_counter) - exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_AUX_DEST); - - return pPixmap; -} - -Bool -exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth, - int bitsPerPixel, int devKind, pointer pPixData) -{ - ScreenPtr pScreen; - ExaScreenPrivPtr pExaScr; - ExaPixmapPrivPtr pExaPixmap; - Bool ret, has_gpu_copy; - - if (!pPixmap) - return FALSE; - - pScreen = pPixmap->drawable.pScreen; - pExaScr = ExaGetScreenPriv(pScreen); - pExaPixmap = ExaGetPixmapPriv(pPixmap); - - if (pPixData) { - if (pExaPixmap->driverPriv) { - if (pExaPixmap->pDamage) { - DamageUnregister(&pPixmap->drawable, pExaPixmap->pDamage); - DamageDestroy(pExaPixmap->pDamage); - pExaPixmap->pDamage = NULL; - } - - pExaScr->info->DestroyPixmap(pScreen, pExaPixmap->driverPriv); - pExaPixmap->driverPriv = NULL; - } - - pExaPixmap->use_gpu_copy = FALSE; - pExaPixmap->score = EXA_PIXMAP_SCORE_PINNED; - } - - has_gpu_copy = exaPixmapHasGpuCopy(pPixmap); - - if (width <= 0) - width = pPixmap->drawable.width; - - if (height <= 0) - height = pPixmap->drawable.height; - - if (bitsPerPixel <= 0) { - if (depth <= 0) - bitsPerPixel = pPixmap->drawable.bitsPerPixel; - else - bitsPerPixel = BitsPerPixel(depth); - } - - if (depth <= 0) - depth = pPixmap->drawable.depth; - - if (width != pPixmap->drawable.width || - height != pPixmap->drawable.height || - depth != pPixmap->drawable.depth || - bitsPerPixel != pPixmap->drawable.bitsPerPixel) { - if (pExaPixmap->driverPriv) { - exaSetFbPitch(pExaScr, pExaPixmap, - width, height, bitsPerPixel); - - exaSetAccelBlock(pExaScr, pExaPixmap, - width, height, bitsPerPixel); - REGION_EMPTY(pScreen, &pExaPixmap->validFB); - } - - /* Need to re-create system copy if there's also a GPU copy */ - if (has_gpu_copy && pExaPixmap->sys_ptr) { - free(pExaPixmap->sys_ptr); - pExaPixmap->sys_ptr = NULL; - pExaPixmap->sys_pitch = devKind > 0 ? devKind : - PixmapBytePad(width, depth); - DamageUnregister(&pPixmap->drawable, pExaPixmap->pDamage); - DamageDestroy(pExaPixmap->pDamage); - pExaPixmap->pDamage = NULL; - REGION_EMPTY(pScreen, &pExaPixmap->validSys); - - if (pExaScr->deferred_mixed_pixmap == pPixmap) - pExaScr->deferred_mixed_pixmap = NULL; - } - } - - if (has_gpu_copy) { - pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr; - pPixmap->devKind = pExaPixmap->fb_pitch; - } else { - pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr; - pPixmap->devKind = pExaPixmap->sys_pitch; - } - - /* Only pass driver pixmaps to the driver. */ - if (pExaScr->info->ModifyPixmapHeader && pExaPixmap->driverPriv) { - ret = pExaScr->info->ModifyPixmapHeader(pPixmap, width, height, depth, - bitsPerPixel, devKind, pPixData); - if (ret == TRUE) - goto out; - } - - swap(pExaScr, pScreen, ModifyPixmapHeader); - ret = pScreen->ModifyPixmapHeader(pPixmap, width, height, depth, - bitsPerPixel, devKind, pPixData); - swap(pExaScr, pScreen, ModifyPixmapHeader); - -out: - if (has_gpu_copy) { - pExaPixmap->fb_ptr = pPixmap->devPrivate.ptr; - pExaPixmap->fb_pitch = pPixmap->devKind; - } else { - pExaPixmap->sys_ptr = pPixmap->devPrivate.ptr; - pExaPixmap->sys_pitch = pPixmap->devKind; - } - /* Always NULL this, we don't want lingering pointers. */ - pPixmap->devPrivate.ptr = NULL; - - return ret; -} - -Bool -exaDestroyPixmap_mixed(PixmapPtr pPixmap) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - ExaScreenPriv(pScreen); - Bool ret; - - if (pPixmap->refcnt == 1) - { - ExaPixmapPriv (pPixmap); - - /* During a fallback we must finish access, but we don't know the index. */ - if (pExaScr->fallback_counter) - exaFinishAccess(&pPixmap->drawable, -1); - - if (pExaScr->deferred_mixed_pixmap == pPixmap) - pExaScr->deferred_mixed_pixmap = NULL; - - if (pExaPixmap->driverPriv) - pExaScr->info->DestroyPixmap(pScreen, pExaPixmap->driverPriv); - pExaPixmap->driverPriv = NULL; - - if (pExaPixmap->pDamage) { - if (pExaPixmap->sys_ptr) - free(pExaPixmap->sys_ptr); - pExaPixmap->sys_ptr = NULL; - pExaPixmap->pDamage = NULL; - } - } - - swap(pExaScr, pScreen, DestroyPixmap); - ret = pScreen->DestroyPixmap (pPixmap); - swap(pExaScr, pScreen, DestroyPixmap); - - return ret; -} - -Bool -exaPixmapHasGpuCopy_mixed(PixmapPtr pPixmap) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - ExaScreenPriv(pScreen); - ExaPixmapPriv(pPixmap); - pointer saved_ptr; - Bool ret; - - if (!pExaPixmap->driverPriv) - return FALSE; - - saved_ptr = pPixmap->devPrivate.ptr; - pPixmap->devPrivate.ptr = ExaGetPixmapAddress(pPixmap); - ret = pExaScr->info->PixmapIsOffscreen(pPixmap); - pPixmap->devPrivate.ptr = saved_ptr; - - return ret; -} +/*
+ * Copyright 2009 Maarten Maathuis
+ *
+ * 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 (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+
+#include "exa_priv.h"
+#include "exa.h"
+
+/* This file holds the driver allocated pixmaps + better initial placement code.
+ */
+
+static _X_INLINE void*
+ExaGetPixmapAddress(PixmapPtr p)
+{
+ ExaPixmapPriv(p);
+
+ return pExaPixmap->sys_ptr;
+}
+
+/**
+ * exaCreatePixmap() creates a new pixmap.
+ */
+PixmapPtr
+exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
+ unsigned usage_hint)
+{
+ PixmapPtr pPixmap;
+ ExaPixmapPrivPtr pExaPixmap;
+ int bpp;
+ size_t paddedWidth;
+ ExaScreenPriv(pScreen);
+
+ if (w > 32767 || h > 32767)
+ return NullPixmap;
+
+ swap(pExaScr, pScreen, CreatePixmap);
+ pPixmap = pScreen->CreatePixmap(pScreen, 0, 0, depth, usage_hint);
+ swap(pExaScr, pScreen, CreatePixmap);
+
+ if (!pPixmap)
+ return NULL;
+
+ pExaPixmap = ExaGetPixmapPriv(pPixmap);
+ pExaPixmap->driverPriv = NULL;
+
+ bpp = pPixmap->drawable.bitsPerPixel;
+
+ paddedWidth = ((w * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
+ if (paddedWidth / 4 > 32767 || h > 32767)
+ return NullPixmap;
+
+ /* We will allocate the system pixmap later if needed. */
+ pPixmap->devPrivate.ptr = NULL;
+ pExaPixmap->sys_ptr = NULL;
+ pExaPixmap->sys_pitch = paddedWidth;
+
+ pExaPixmap->area = NULL;
+ pExaPixmap->fb_ptr = NULL;
+ pExaPixmap->pDamage = NULL;
+
+ exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp);
+ exaSetAccelBlock(pExaScr, pExaPixmap,
+ w, h, bpp);
+
+ (*pScreen->ModifyPixmapHeader)(pPixmap, w, h, 0, 0,
+ paddedWidth, NULL);
+
+ /* A scratch pixmap will become a driver pixmap right away. */
+ if (!w || !h) {
+ exaCreateDriverPixmap_mixed(pPixmap);
+ pExaPixmap->use_gpu_copy = exaPixmapHasGpuCopy(pPixmap);
+ } else {
+ pExaPixmap->use_gpu_copy = FALSE;
+
+ if (w == 1 && h == 1) {
+ pExaPixmap->sys_ptr = malloc((pPixmap->drawable.bitsPerPixel + 7) / 8);
+
+ /* Set up damage tracking */
+ pExaPixmap->pDamage = DamageCreate(exaDamageReport_mixed, NULL,
+ DamageReportNonEmpty, TRUE,
+ pPixmap->drawable.pScreen,
+ pPixmap);
+
+ DamageRegister(&pPixmap->drawable, pExaPixmap->pDamage);
+ /* This ensures that pending damage reflects the current operation. */
+ /* This is used by exa to optimize migration. */
+ DamageSetReportAfterOp(pExaPixmap->pDamage, TRUE);
+ }
+ }
+
+ /* During a fallback we must prepare access. */
+ if (pExaScr->fallback_counter)
+ exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_AUX_DEST);
+
+ return pPixmap;
+}
+
+Bool
+exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth,
+ int bitsPerPixel, int devKind, pointer pPixData)
+{
+ ScreenPtr pScreen;
+ ExaScreenPrivPtr pExaScr;
+ ExaPixmapPrivPtr pExaPixmap;
+ Bool ret, has_gpu_copy;
+
+ if (!pPixmap)
+ return FALSE;
+
+ pScreen = pPixmap->drawable.pScreen;
+ pExaScr = ExaGetScreenPriv(pScreen);
+ pExaPixmap = ExaGetPixmapPriv(pPixmap);
+
+ if (pPixData) {
+ if (pExaPixmap->driverPriv) {
+ if (pExaPixmap->pDamage) {
+ DamageUnregister(&pPixmap->drawable, pExaPixmap->pDamage);
+ DamageDestroy(pExaPixmap->pDamage);
+ pExaPixmap->pDamage = NULL;
+ }
+
+ pExaScr->info->DestroyPixmap(pScreen, pExaPixmap->driverPriv);
+ pExaPixmap->driverPriv = NULL;
+ }
+
+ pExaPixmap->use_gpu_copy = FALSE;
+ pExaPixmap->score = EXA_PIXMAP_SCORE_PINNED;
+ }
+
+ has_gpu_copy = exaPixmapHasGpuCopy(pPixmap);
+
+ if (width <= 0)
+ width = pPixmap->drawable.width;
+
+ if (height <= 0)
+ height = pPixmap->drawable.height;
+
+ if (bitsPerPixel <= 0) {
+ if (depth <= 0)
+ bitsPerPixel = pPixmap->drawable.bitsPerPixel;
+ else
+ bitsPerPixel = BitsPerPixel(depth);
+ }
+
+ if (depth <= 0)
+ depth = pPixmap->drawable.depth;
+
+ if (width != pPixmap->drawable.width ||
+ height != pPixmap->drawable.height ||
+ depth != pPixmap->drawable.depth ||
+ bitsPerPixel != pPixmap->drawable.bitsPerPixel) {
+ if (pExaPixmap->driverPriv) {
+ exaSetFbPitch(pExaScr, pExaPixmap,
+ width, height, bitsPerPixel);
+
+ exaSetAccelBlock(pExaScr, pExaPixmap,
+ width, height, bitsPerPixel);
+ RegionEmpty(&pExaPixmap->validFB);
+ }
+
+ /* Need to re-create system copy if there's also a GPU copy */
+ if (has_gpu_copy && pExaPixmap->sys_ptr) {
+ free(pExaPixmap->sys_ptr);
+ pExaPixmap->sys_ptr = NULL;
+ pExaPixmap->sys_pitch = devKind > 0 ? devKind :
+ PixmapBytePad(width, depth);
+ DamageUnregister(&pPixmap->drawable, pExaPixmap->pDamage);
+ DamageDestroy(pExaPixmap->pDamage);
+ pExaPixmap->pDamage = NULL;
+ RegionEmpty(&pExaPixmap->validSys);
+
+ if (pExaScr->deferred_mixed_pixmap == pPixmap)
+ pExaScr->deferred_mixed_pixmap = NULL;
+ }
+ }
+
+ if (has_gpu_copy) {
+ pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr;
+ pPixmap->devKind = pExaPixmap->fb_pitch;
+ } else {
+ pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr;
+ pPixmap->devKind = pExaPixmap->sys_pitch;
+ }
+
+ /* Only pass driver pixmaps to the driver. */
+ if (pExaScr->info->ModifyPixmapHeader && pExaPixmap->driverPriv) {
+ ret = pExaScr->info->ModifyPixmapHeader(pPixmap, width, height, depth,
+ bitsPerPixel, devKind, pPixData);
+ if (ret == TRUE)
+ goto out;
+ }
+
+ swap(pExaScr, pScreen, ModifyPixmapHeader);
+ ret = pScreen->ModifyPixmapHeader(pPixmap, width, height, depth,
+ bitsPerPixel, devKind, pPixData);
+ swap(pExaScr, pScreen, ModifyPixmapHeader);
+
+out:
+ if (has_gpu_copy) {
+ pExaPixmap->fb_ptr = pPixmap->devPrivate.ptr;
+ pExaPixmap->fb_pitch = pPixmap->devKind;
+ } else {
+ pExaPixmap->sys_ptr = pPixmap->devPrivate.ptr;
+ pExaPixmap->sys_pitch = pPixmap->devKind;
+ }
+ /* Always NULL this, we don't want lingering pointers. */
+ pPixmap->devPrivate.ptr = NULL;
+
+ return ret;
+}
+
+Bool
+exaDestroyPixmap_mixed(PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ ExaScreenPriv(pScreen);
+ Bool ret;
+
+ if (pPixmap->refcnt == 1)
+ {
+ ExaPixmapPriv (pPixmap);
+
+ /* During a fallback we must finish access, but we don't know the index. */
+ if (pExaScr->fallback_counter)
+ exaFinishAccess(&pPixmap->drawable, -1);
+
+ if (pExaScr->deferred_mixed_pixmap == pPixmap)
+ pExaScr->deferred_mixed_pixmap = NULL;
+
+ if (pExaPixmap->driverPriv)
+ pExaScr->info->DestroyPixmap(pScreen, pExaPixmap->driverPriv);
+ pExaPixmap->driverPriv = NULL;
+
+ if (pExaPixmap->pDamage) {
+ free(pExaPixmap->sys_ptr);
+ pExaPixmap->sys_ptr = NULL;
+ pExaPixmap->pDamage = NULL;
+ }
+ }
+
+ swap(pExaScr, pScreen, DestroyPixmap);
+ ret = pScreen->DestroyPixmap (pPixmap);
+ swap(pExaScr, pScreen, DestroyPixmap);
+
+ return ret;
+}
+
+Bool
+exaPixmapHasGpuCopy_mixed(PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ ExaScreenPriv(pScreen);
+ ExaPixmapPriv(pPixmap);
+ pointer saved_ptr;
+ Bool ret;
+
+ if (!pExaPixmap->driverPriv)
+ return FALSE;
+
+ saved_ptr = pPixmap->devPrivate.ptr;
+ pPixmap->devPrivate.ptr = ExaGetPixmapAddress(pPixmap);
+ ret = pExaScr->info->PixmapIsOffscreen(pPixmap);
+ pPixmap->devPrivate.ptr = saved_ptr;
+
+ return ret;
+}
diff --git a/xorg-server/exa/exa_priv.h b/xorg-server/exa/exa_priv.h index 575d836b8..baf49590a 100644 --- a/xorg-server/exa/exa_priv.h +++ b/xorg-server/exa/exa_priv.h @@ -221,9 +221,13 @@ typedef struct { (PixmapWidthPaddingInfo[d].padRoundUp+1)))
#endif
-extern DevPrivateKey exaScreenPrivateKey;
-extern DevPrivateKey exaPixmapPrivateKey;
-extern DevPrivateKey exaGCPrivateKey;
+extern DevPrivateKeyRec exaScreenPrivateKeyRec;
+#define exaScreenPrivateKey (&exaScreenPrivateKeyRec)
+extern DevPrivateKeyRec exaPixmapPrivateKeyRec;
+#define exaPixmapPrivateKey (&exaPixmapPrivateKeyRec)
+extern DevPrivateKeyRec exaGCPrivateKeyRec;
+#define exaGCPrivateKey (&exaGCPrivateKeyRec)
+
#define ExaGetScreenPriv(s) ((ExaScreenPrivPtr)dixLookupPrivate(&(s)->devPrivates, exaScreenPrivateKey))
#define ExaScreenPriv(s) ExaScreenPrivPtr pExaScr = ExaGetScreenPriv(s)
diff --git a/xorg-server/exa/exa_render.c b/xorg-server/exa/exa_render.c index b7f383f38..026f5d16d 100644 --- a/xorg-server/exa/exa_render.c +++ b/xorg-server/exa/exa_render.c @@ -1,1256 +1,1256 @@ -/* - * Copyright © 2001 Keith Packard - * - * Partly based on code that is Copyright © The XFree86 Project Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdlib.h> - -#include "exa_priv.h" - -#include "mipict.h" - -#if DEBUG_TRACE_FALL -static void exaCompositeFallbackPictDesc(PicturePtr pict, char *string, int n) -{ - char format[20]; - char size[20]; - char loc; - int temp; - - if (!pict) { - snprintf(string, n, "None"); - return; - } - - switch (pict->format) - { - case PICT_a8r8g8b8: - snprintf(format, 20, "ARGB8888"); - break; - case PICT_x8r8g8b8: - snprintf(format, 20, "XRGB8888"); - break; - case PICT_b8g8r8a8: - snprintf(format, 20, "BGRA8888"); - break; - case PICT_b8g8r8x8: - snprintf(format, 20, "BGRX8888"); - break; - case PICT_r5g6b5: - snprintf(format, 20, "RGB565 "); - break; - case PICT_x1r5g5b5: - snprintf(format, 20, "RGB555 "); - break; - case PICT_a8: - snprintf(format, 20, "A8 "); - break; - case PICT_a1: - snprintf(format, 20, "A1 "); - break; - default: - snprintf(format, 20, "0x%x", (int)pict->format); - break; - } - - if (pict->pDrawable) { - loc = exaGetOffscreenPixmap(pict->pDrawable, &temp, &temp) ? 's' : 'm'; - - snprintf(size, 20, "%dx%d%s", pict->pDrawable->width, - pict->pDrawable->height, pict->repeat ? - " R" : ""); - } else { - loc = '-'; - - snprintf(size, 20, "%s", pict->repeat ? " R" : ""); - } - - snprintf(string, n, "%p:%c fmt %s (%s)", pict->pDrawable, loc, format, size); -} - -static void -exaPrintCompositeFallback(CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst) -{ - char sop[20]; - char srcdesc[40], maskdesc[40], dstdesc[40]; - - switch(op) - { - case PictOpSrc: - sprintf(sop, "Src"); - break; - case PictOpOver: - sprintf(sop, "Over"); - break; - default: - sprintf(sop, "0x%x", (int)op); - break; - } - - exaCompositeFallbackPictDesc(pSrc, srcdesc, 40); - exaCompositeFallbackPictDesc(pMask, maskdesc, 40); - exaCompositeFallbackPictDesc(pDst, dstdesc, 40); - - ErrorF("Composite fallback: op %s, \n" - " src %s, \n" - " mask %s, \n" - " dst %s, \n", - sop, srcdesc, maskdesc, dstdesc); -} -#endif /* DEBUG_TRACE_FALL */ - -Bool -exaOpReadsDestination (CARD8 op) -{ - /* FALSE (does not read destination) is the list of ops in the protocol - * document with "0" in the "Fb" column and no "Ab" in the "Fa" column. - * That's just Clear and Src. ReduceCompositeOp() will already have - * converted con/disjoint clear/src to Clear or Src. - */ - switch (op) { - case PictOpClear: - case PictOpSrc: - return FALSE; - default: - return TRUE; - } -} - - -static Bool -exaGetPixelFromRGBA(CARD32 *pixel, - CARD16 red, - CARD16 green, - CARD16 blue, - CARD16 alpha, - PictFormatPtr pFormat) -{ - int rbits, bbits, gbits, abits; - int rshift, bshift, gshift, ashift; - - *pixel = 0; - - if (!PICT_FORMAT_COLOR(pFormat->format) && - PICT_FORMAT_TYPE(pFormat->format) != PICT_TYPE_A) - return FALSE; - - rbits = PICT_FORMAT_R(pFormat->format); - gbits = PICT_FORMAT_G(pFormat->format); - bbits = PICT_FORMAT_B(pFormat->format); - abits = PICT_FORMAT_A(pFormat->format); - - rshift = pFormat->direct.red; - gshift = pFormat->direct.green; - bshift = pFormat->direct.blue; - ashift = pFormat->direct.alpha; - - *pixel |= ( blue >> (16 - bbits)) << bshift; - *pixel |= ( red >> (16 - rbits)) << rshift; - *pixel |= (green >> (16 - gbits)) << gshift; - *pixel |= (alpha >> (16 - abits)) << ashift; - - return TRUE; -} - -static Bool -exaGetRGBAFromPixel(CARD32 pixel, - CARD16 *red, - CARD16 *green, - CARD16 *blue, - CARD16 *alpha, - PictFormatPtr pFormat, - PictFormatShort format) -{ - int rbits, bbits, gbits, abits; - int rshift, bshift, gshift, ashift; - - if (!PICT_FORMAT_COLOR(format) && PICT_FORMAT_TYPE(format) != PICT_TYPE_A) - return FALSE; - - rbits = PICT_FORMAT_R(format); - gbits = PICT_FORMAT_G(format); - bbits = PICT_FORMAT_B(format); - abits = PICT_FORMAT_A(format); - - if (pFormat) { - rshift = pFormat->direct.red; - gshift = pFormat->direct.green; - bshift = pFormat->direct.blue; - ashift = pFormat->direct.alpha; - } else if (format == PICT_a8r8g8b8) { - rshift = 16; - gshift = 8; - bshift = 0; - ashift = 24; - } else - FatalError("EXA bug: exaGetRGBAFromPixel() doesn't match " - "createSourcePicture()\n"); - - if (rbits) { - *red = ((pixel >> rshift ) & ((1 << rbits) - 1)) << (16 - rbits); - while (rbits < 16) { - *red |= *red >> rbits; - rbits <<= 1; - } - - *green = ((pixel >> gshift ) & ((1 << gbits) - 1)) << (16 - gbits); - while (gbits < 16) { - *green |= *green >> gbits; - gbits <<= 1; - } - - *blue = ((pixel >> bshift ) & ((1 << bbits) - 1)) << (16 - bbits); - while (bbits < 16) { - *blue |= *blue >> bbits; - bbits <<= 1; - } - } else { - *red = 0x0000; - *green = 0x0000; - *blue = 0x0000; - } - - if (abits) { - *alpha = ((pixel >> ashift ) & ((1 << abits) - 1)) << (16 - abits); - while (abits < 16) { - *alpha |= *alpha >> abits; - abits <<= 1; - } - } else - *alpha = 0xffff; - - return TRUE; -} - -static int -exaTryDriverSolidFill(PicturePtr pSrc, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - ExaScreenPriv (pDst->pDrawable->pScreen); - RegionRec region; - BoxPtr pbox; - int nbox; - int dst_off_x, dst_off_y; - PixmapPtr pSrcPix, pDstPix; - ExaPixmapPrivPtr pDstExaPix; - CARD32 pixel; - CARD16 red, green, blue, alpha; - - pDstPix = exaGetDrawablePixmap (pDst->pDrawable); - pDstExaPix = ExaGetPixmapPriv(pDstPix); - - /* Check whether the accelerator can use the destination pixmap. - */ - if (pDstExaPix->accel_blocked) - { - return -1; - } - - xDst += pDst->pDrawable->x; - yDst += pDst->pDrawable->y; - if (pSrc->pDrawable) { - xSrc += pSrc->pDrawable->x; - ySrc += pSrc->pDrawable->y; - } - - if (!miComputeCompositeRegion (®ion, pSrc, NULL, pDst, - xSrc, ySrc, 0, 0, xDst, yDst, - width, height)) - return 1; - - exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &dst_off_x, &dst_off_y); - - REGION_TRANSLATE(pScreen, ®ion, dst_off_x, dst_off_y); - - if (pSrc->pDrawable) { - pSrcPix = exaGetDrawablePixmap (pSrc->pDrawable); - pixel = exaGetPixmapFirstPixel (pSrcPix); - } else - pixel = pSrc->pSourcePict->solidFill.color; - - if (!exaGetRGBAFromPixel(pixel, &red, &green, &blue, &alpha, - pSrc->pFormat, pSrc->format) || - !exaGetPixelFromRGBA(&pixel, red, green, blue, alpha, - pDst->pFormat)) - { - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - return -1; - } - - if (pExaScr->do_migration) { - ExaMigrationRec pixmaps[1]; - - pixmaps[0].as_dst = TRUE; - pixmaps[0].as_src = FALSE; - pixmaps[0].pPix = pDstPix; - pixmaps[0].pReg = ®ion; - exaDoMigration(pixmaps, 1, TRUE); - } - - if (!exaPixmapHasGpuCopy(pDstPix)) { - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - return 0; - } - - if (!(*pExaScr->info->PrepareSolid) (pDstPix, GXcopy, 0xffffffff, pixel)) - { - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - return -1; - } - - nbox = REGION_NUM_RECTS(®ion); - pbox = REGION_RECTS(®ion); - - while (nbox--) - { - (*pExaScr->info->Solid) (pDstPix, pbox->x1, pbox->y1, pbox->x2, pbox->y2); - pbox++; - } - - (*pExaScr->info->DoneSolid) (pDstPix); - exaMarkSync(pDst->pDrawable->pScreen); - - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - return 1; -} - -static int -exaTryDriverCompositeRects(CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - int nrect, - ExaCompositeRectPtr rects) -{ - ExaScreenPriv (pDst->pDrawable->pScreen); - int src_off_x = 0, src_off_y = 0, mask_off_x = 0, mask_off_y = 0; - int dst_off_x, dst_off_y; - PixmapPtr pSrcPix = NULL, pMaskPix = NULL, pDstPix; - ExaPixmapPrivPtr pSrcExaPix = NULL, pMaskExaPix = NULL, pDstExaPix; - - if (!pExaScr->info->PrepareComposite) - return -1; - - if (pSrc->pDrawable) { - pSrcPix = exaGetDrawablePixmap(pSrc->pDrawable); - pSrcExaPix = ExaGetPixmapPriv(pSrcPix); - } - - if (pMask && pMask->pDrawable) { - pMaskPix = exaGetDrawablePixmap(pMask->pDrawable); - pMaskExaPix = ExaGetPixmapPriv(pMaskPix); - } - - pDstPix = exaGetDrawablePixmap(pDst->pDrawable); - pDstExaPix = ExaGetPixmapPriv(pDstPix); - - /* Check whether the accelerator can use these pixmaps. - * FIXME: If it cannot, use temporary pixmaps so that the drawing - * happens within limits. - */ - if (pDstExaPix->accel_blocked || - (pSrcExaPix && pSrcExaPix->accel_blocked) || - (pMaskExaPix && pMaskExaPix->accel_blocked)) - { - return -1; - } - - if (pExaScr->info->CheckComposite && - !(*pExaScr->info->CheckComposite) (op, pSrc, pMask, pDst)) - { - return -1; - } - - if (pExaScr->do_migration) { - ExaMigrationRec pixmaps[3]; - int i = 0; - - pixmaps[i].as_dst = TRUE; - pixmaps[i].as_src = exaOpReadsDestination(op); - pixmaps[i].pPix = pDstPix; - pixmaps[i].pReg = NULL; - i++; - - if (pSrcPix) { - pixmaps[i].as_dst = FALSE; - pixmaps[i].as_src = TRUE; - pixmaps[i].pPix = pSrcPix; - pixmaps[i].pReg = NULL; - i++; - } - - if (pMaskPix) { - pixmaps[i].as_dst = FALSE; - pixmaps[i].as_src = TRUE; - pixmaps[i].pPix = pMaskPix; - pixmaps[i].pReg = NULL; - i++; - } - - exaDoMigration(pixmaps, i, TRUE); - } - - pDstPix = exaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x, &dst_off_y); - if (!pDstPix) - return 0; - - if (pSrcPix) { - pSrcPix = exaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, &src_off_y); - if (!pSrcPix) - return 0; - } - - if (pMaskPix) { - pMaskPix = exaGetOffscreenPixmap (pMask->pDrawable, &mask_off_x, &mask_off_y); - if (!pMaskPix) - return 0; - } - - if (!(*pExaScr->info->PrepareComposite) (op, pSrc, pMask, pDst, pSrcPix, - pMaskPix, pDstPix)) - return -1; - - while (nrect--) - { - INT16 xDst = rects->xDst + pDst->pDrawable->x; - INT16 yDst = rects->yDst + pDst->pDrawable->y; - INT16 xMask = rects->xMask; - INT16 yMask = rects->yMask; - INT16 xSrc = rects->xSrc; - INT16 ySrc = rects->ySrc; - RegionRec region; - BoxPtr pbox; - int nbox; - - if (pMaskPix) { - xMask += pMask->pDrawable->x; - yMask += pMask->pDrawable->y; - } - - if (pSrcPix) { - xSrc += pSrc->pDrawable->x; - ySrc += pSrc->pDrawable->y; - } - - if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, - xSrc, ySrc, xMask, yMask, xDst, yDst, - rects->width, rects->height)) - goto next_rect; - - REGION_TRANSLATE(pScreen, ®ion, dst_off_x, dst_off_y); - - nbox = REGION_NUM_RECTS(®ion); - pbox = REGION_RECTS(®ion); - - xMask = xMask + mask_off_x - xDst - dst_off_x; - yMask = yMask + mask_off_y - yDst - dst_off_y; - xSrc = xSrc + src_off_x - xDst - dst_off_x; - ySrc = ySrc + src_off_y - yDst - dst_off_y; - - while (nbox--) - { - (*pExaScr->info->Composite) (pDstPix, - pbox->x1 + xSrc, - pbox->y1 + ySrc, - pbox->x1 + xMask, - pbox->y1 + yMask, - pbox->x1, - pbox->y1, - pbox->x2 - pbox->x1, - pbox->y2 - pbox->y1); - pbox++; - } - - next_rect: - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - - rects++; - } - - (*pExaScr->info->DoneComposite) (pDstPix); - exaMarkSync(pDst->pDrawable->pScreen); - - return 1; -} - -/** - * Copy a number of rectangles from source to destination in a single - * operation. This is specialized for glyph rendering: we don't have the - * special-case fallbacks found in exaComposite() - if the driver can support - * it, we use the driver functionality, otherwise we fall back straight to - * software. - */ -void -exaCompositeRects(CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - int nrect, - ExaCompositeRectPtr rects) -{ - ExaScreenPriv (pDst->pDrawable->pScreen); - int n; - ExaCompositeRectPtr r; - int ret; - - /* If we get a mask, that means we're rendering to the exaGlyphs - * destination directly, so the damage layer takes care of this. - */ - if (!pMask) { - RegionRec region; - int x1 = MAXSHORT; - int y1 = MAXSHORT; - int x2 = MINSHORT; - int y2 = MINSHORT; - BoxRec box; - - /* We have to manage the damage ourselves, since CompositeRects isn't - * something in the screen that can be managed by the damage extension, - * and EXA depends on damage to track what needs to be migrated between - * the gpu and the cpu. - */ - - /* Compute the overall extents of the composited region - we're making - * the assumption here that we are compositing a bunch of glyphs that - * cluster closely together and damaging each glyph individually would - * be a loss compared to damaging the bounding box. - */ - n = nrect; - r = rects; - while (n--) { - int rect_x2 = r->xDst + r->width; - int rect_y2 = r->yDst + r->height; - - if (r->xDst < x1) x1 = r->xDst; - if (r->yDst < y1) y1 = r->yDst; - if (rect_x2 > x2) x2 = rect_x2; - if (rect_y2 > y2) y2 = rect_y2; - - r++; - } - - if (x2 <= x1 || y2 <= y1) - return; - - box.x1 = x1; - box.x2 = x2 < MAXSHORT ? x2 : MAXSHORT; - box.y1 = y1; - box.y2 = y2 < MAXSHORT ? y2 : MAXSHORT; - - /* The pixmap migration code relies on pendingDamage indicating - * the bounds of the current rendering, so we need to force - * the actual damage into that region before we do anything, and - * (see use of DamagePendingRegion in exaCopyDirty) - */ - - REGION_INIT(pScreen, ®ion, &box, 1); - - DamageRegionAppend(pDst->pDrawable, ®ion); - - REGION_UNINIT(pScreen, ®ion); - } - - /************************************************************/ - - ValidatePicture (pSrc); - if (pMask) - ValidatePicture (pMask); - ValidatePicture (pDst); - - ret = exaTryDriverCompositeRects(op, pSrc, pMask, pDst, nrect, rects); - - if (ret != 1) { - if (ret == -1 && op == PictOpOver && pMask && pMask->componentAlpha && - (!pExaScr->info->CheckComposite || - ((*pExaScr->info->CheckComposite)(PictOpOutReverse, pSrc, pMask, - pDst) && - (*pExaScr->info->CheckComposite)(PictOpAdd, pSrc, pMask, pDst)))) { - ret = exaTryDriverCompositeRects(PictOpOutReverse, pSrc, pMask, - pDst, nrect, rects); - if (ret == 1) { - op = PictOpAdd; - ret = exaTryDriverCompositeRects(op, pSrc, pMask, pDst, nrect, - rects); - } - } - - if (ret != 1) { - n = nrect; - r = rects; - while (n--) { - ExaCheckComposite (op, pSrc, pMask, pDst, - r->xSrc, r->ySrc, - r->xMask, r->yMask, - r->xDst, r->yDst, - r->width, r->height); - r++; - } - } - } - - /************************************************************/ - - if (!pMask) { - /* Now we have to flush the damage out from pendingDamage => damage - * Calling DamageRegionProcessPending has that effect. - */ - - DamageRegionProcessPending(pDst->pDrawable); - } -} - -static int -exaTryDriverComposite(CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - ExaScreenPriv (pDst->pDrawable->pScreen); - RegionRec region; - BoxPtr pbox; - int nbox; - int src_off_x, src_off_y, mask_off_x, mask_off_y, dst_off_x, dst_off_y; - PixmapPtr pSrcPix = NULL, pMaskPix = NULL, pDstPix; - ExaPixmapPrivPtr pSrcExaPix = NULL, pMaskExaPix = NULL, pDstExaPix; - - if (pSrc->pDrawable) { - pSrcPix = exaGetDrawablePixmap(pSrc->pDrawable); - pSrcExaPix = ExaGetPixmapPriv(pSrcPix); - } - - pDstPix = exaGetDrawablePixmap(pDst->pDrawable); - pDstExaPix = ExaGetPixmapPriv(pDstPix); - - if (pMask && pMask->pDrawable) { - pMaskPix = exaGetDrawablePixmap(pMask->pDrawable); - pMaskExaPix = ExaGetPixmapPriv(pMaskPix); - } - - /* Check whether the accelerator can use these pixmaps. - * FIXME: If it cannot, use temporary pixmaps so that the drawing - * happens within limits. - */ - if (pDstExaPix->accel_blocked || - (pSrcExaPix && pSrcExaPix->accel_blocked) || - (pMaskExaPix && (pMaskExaPix->accel_blocked))) - { - return -1; - } - - xDst += pDst->pDrawable->x; - yDst += pDst->pDrawable->y; - - if (pMaskPix) { - xMask += pMask->pDrawable->x; - yMask += pMask->pDrawable->y; - } - - if (pSrcPix) { - xSrc += pSrc->pDrawable->x; - ySrc += pSrc->pDrawable->y; - } - - if (pExaScr->info->CheckComposite && - !(*pExaScr->info->CheckComposite) (op, pSrc, pMask, pDst)) - { - return -1; - } - - if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, - xSrc, ySrc, xMask, yMask, xDst, yDst, - width, height)) - return 1; - - exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &dst_off_x, &dst_off_y); - - REGION_TRANSLATE(pScreen, ®ion, dst_off_x, dst_off_y); - - if (pExaScr->do_migration) { - ExaMigrationRec pixmaps[3]; - int i = 0; - - pixmaps[i].as_dst = TRUE; - pixmaps[i].as_src = exaOpReadsDestination(op); - pixmaps[i].pPix = pDstPix; - pixmaps[i].pReg = pixmaps[0].as_src ? NULL : ®ion; - i++; - - if (pSrcPix) { - pixmaps[i].as_dst = FALSE; - pixmaps[i].as_src = TRUE; - pixmaps[i].pPix = pSrcPix; - pixmaps[i].pReg = NULL; - i++; - } - - if (pMaskPix) { - pixmaps[i].as_dst = FALSE; - pixmaps[i].as_src = TRUE; - pixmaps[i].pPix = pMaskPix; - pixmaps[i].pReg = NULL; - i++; - } - - exaDoMigration(pixmaps, i, TRUE); - } - - if (pSrcPix) { - pSrcPix = exaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, &src_off_y); - if (!pSrcPix) { - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - return 0; - } - } - - if (pMaskPix) { - pMaskPix = exaGetOffscreenPixmap (pMask->pDrawable, &mask_off_x, - &mask_off_y); - if (!pMaskPix) { - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - return 0; - } - } - - if (!exaPixmapHasGpuCopy(pDstPix)) { - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - return 0; - } - - if (!(*pExaScr->info->PrepareComposite) (op, pSrc, pMask, pDst, pSrcPix, - pMaskPix, pDstPix)) - { - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - return -1; - } - - nbox = REGION_NUM_RECTS(®ion); - pbox = REGION_RECTS(®ion); - - xMask = xMask + mask_off_x - xDst - dst_off_x; - yMask = yMask + mask_off_y - yDst - dst_off_y; - - xSrc = xSrc + src_off_x - xDst - dst_off_x; - ySrc = ySrc + src_off_y - yDst - dst_off_y; - - while (nbox--) - { - (*pExaScr->info->Composite) (pDstPix, - pbox->x1 + xSrc, - pbox->y1 + ySrc, - pbox->x1 + xMask, - pbox->y1 + yMask, - pbox->x1, - pbox->y1, - pbox->x2 - pbox->x1, - pbox->y2 - pbox->y1); - pbox++; - } - (*pExaScr->info->DoneComposite) (pDstPix); - exaMarkSync(pDst->pDrawable->pScreen); - - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - return 1; -} - -/** - * exaTryMagicTwoPassCompositeHelper implements PictOpOver using two passes of - * simpler operations PictOpOutReverse and PictOpAdd. Mainly used for component - * alpha and limited 1-tmu cards. - * - * From http://anholt.livejournal.com/32058.html: - * - * The trouble is that component-alpha rendering requires two different sources - * for blending: one for the source value to the blender, which is the - * per-channel multiplication of source and mask, and one for the source alpha - * for multiplying with the destination channels, which is the multiplication - * of the source channels by the mask alpha. So the equation for Over is: - * - * dst.A = src.A * mask.A + (1 - (src.A * mask.A)) * dst.A - * dst.R = src.R * mask.R + (1 - (src.A * mask.R)) * dst.R - * dst.G = src.G * mask.G + (1 - (src.A * mask.G)) * dst.G - * dst.B = src.B * mask.B + (1 - (src.A * mask.B)) * dst.B - * - * But we can do some simpler operations, right? How about PictOpOutReverse, - * which has a source factor of 0 and dest factor of (1 - source alpha). We - * can get the source alpha value (srca.X = src.A * mask.X) out of the texture - * blenders pretty easily. So we can do a component-alpha OutReverse, which - * gets us: - * - * dst.A = 0 + (1 - (src.A * mask.A)) * dst.A - * dst.R = 0 + (1 - (src.A * mask.R)) * dst.R - * dst.G = 0 + (1 - (src.A * mask.G)) * dst.G - * dst.B = 0 + (1 - (src.A * mask.B)) * dst.B - * - * OK. And if an op doesn't use the source alpha value for the destination - * factor, then we can do the channel multiplication in the texture blenders - * to get the source value, and ignore the source alpha that we wouldn't use. - * We've supported this in the Radeon driver for a long time. An example would - * be PictOpAdd, which does: - * - * dst.A = src.A * mask.A + dst.A - * dst.R = src.R * mask.R + dst.R - * dst.G = src.G * mask.G + dst.G - * dst.B = src.B * mask.B + dst.B - * - * Hey, this looks good! If we do a PictOpOutReverse and then a PictOpAdd right - * after it, we get: - * - * dst.A = src.A * mask.A + ((1 - (src.A * mask.A)) * dst.A) - * dst.R = src.R * mask.R + ((1 - (src.A * mask.R)) * dst.R) - * dst.G = src.G * mask.G + ((1 - (src.A * mask.G)) * dst.G) - * dst.B = src.B * mask.B + ((1 - (src.A * mask.B)) * dst.B) - */ - -static int -exaTryMagicTwoPassCompositeHelper(CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - ExaScreenPriv (pDst->pDrawable->pScreen); - - assert(op == PictOpOver); - - if (pExaScr->info->CheckComposite && - (!(*pExaScr->info->CheckComposite)(PictOpOutReverse, pSrc, pMask, - pDst) || - !(*pExaScr->info->CheckComposite)(PictOpAdd, pSrc, pMask, pDst))) - { - return -1; - } - - /* Now, we think we should be able to accelerate this operation. First, - * composite the destination to be the destination times the source alpha - * factors. - */ - exaComposite(PictOpOutReverse, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, - xDst, yDst, width, height); - - /* Then, add in the source value times the destination alpha factors (1.0). - */ - exaComposite(PictOpAdd, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, - xDst, yDst, width, height); - - return 1; -} - -void -exaComposite(CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - ExaScreenPriv (pDst->pDrawable->pScreen); - int ret = -1; - Bool saveSrcRepeat = pSrc->repeat; - Bool saveMaskRepeat = pMask ? pMask->repeat : 0; - RegionRec region; - - if (pExaScr->swappedOut) - goto fallback; - - /* Remove repeat in source if useless */ - if (pSrc->pDrawable && pSrc->repeat && !pSrc->transform && xSrc >= 0 && - (xSrc + width) <= pSrc->pDrawable->width && ySrc >= 0 && - (ySrc + height) <= pSrc->pDrawable->height) - pSrc->repeat = 0; - - if (!pMask && !pSrc->alphaMap && !pDst->alphaMap && - (op == PictOpSrc || (op == PictOpOver && !PICT_FORMAT_A(pSrc->format)))) - { - if (pSrc->pDrawable ? - (pSrc->pDrawable->width == 1 && pSrc->pDrawable->height == 1 && - pSrc->repeat) : - (pSrc->pSourcePict->type == SourcePictTypeSolidFill)) - { - ret = exaTryDriverSolidFill(pSrc, pDst, xSrc, ySrc, xDst, yDst, - width, height); - if (ret == 1) - goto done; - } else if (pSrc->pDrawable && !pSrc->transform && - ((op == PictOpSrc && - (pSrc->format == pDst->format || - (PICT_FORMAT_COLOR(pDst->format) && - PICT_FORMAT_COLOR(pSrc->format) && - pDst->format == PICT_FORMAT(PICT_FORMAT_BPP(pSrc->format), - PICT_FORMAT_TYPE(pSrc->format), - 0, - PICT_FORMAT_R(pSrc->format), - PICT_FORMAT_G(pSrc->format), - PICT_FORMAT_B(pSrc->format))))) || - (op == PictOpOver && pSrc->format == pDst->format && - !PICT_FORMAT_A(pSrc->format)))) - { - if (!pSrc->repeat && xSrc >= 0 && ySrc >= 0 && - (xSrc + width <= pSrc->pDrawable->width) && - (ySrc + height <= pSrc->pDrawable->height)) - { - Bool ret; - xDst += pDst->pDrawable->x; - yDst += pDst->pDrawable->y; - xSrc += pSrc->pDrawable->x; - ySrc += pSrc->pDrawable->y; - - if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, - xSrc, ySrc, xMask, yMask, xDst, - yDst, width, height)) - goto done; - - ret = exaHWCopyNtoN(pSrc->pDrawable, pDst->pDrawable, NULL, - REGION_RECTS(®ion), REGION_NUM_RECTS(®ion), - xSrc - xDst, ySrc - yDst, FALSE, FALSE); - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - - /* Reset values to their original values. */ - xDst -= pDst->pDrawable->x; - yDst -= pDst->pDrawable->y; - xSrc -= pSrc->pDrawable->x; - ySrc -= pSrc->pDrawable->y; - - if (!ret) - goto fallback; - - goto done; - } - - if (pSrc->repeat && pSrc->repeatType == RepeatNormal && - pSrc->pDrawable->type == DRAWABLE_PIXMAP) - { - DDXPointRec patOrg; - - /* Let's see if the driver can do the repeat in one go */ - if (pExaScr->info->PrepareComposite && !pSrc->alphaMap && - !pDst->alphaMap) - { - ret = exaTryDriverComposite(op, pSrc, pMask, pDst, xSrc, - ySrc, xMask, yMask, xDst, yDst, - width, height); - if (ret == 1) - goto done; - } - - /* Now see if we can use exaFillRegionTiled() */ - xDst += pDst->pDrawable->x; - yDst += pDst->pDrawable->y; - xSrc += pSrc->pDrawable->x; - ySrc += pSrc->pDrawable->y; - - if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, - ySrc, xMask, yMask, xDst, yDst, - width, height)) - goto done; - - /* pattern origin is the point in the destination drawable - * corresponding to (0,0) in the source */ - patOrg.x = xDst - xSrc; - patOrg.y = yDst - ySrc; - - ret = exaFillRegionTiled(pDst->pDrawable, ®ion, - (PixmapPtr)pSrc->pDrawable, - &patOrg, FB_ALLONES, GXcopy, CT_NONE); - - REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); - - if (ret) - goto done; - - /* Let's be correct and restore the variables to their original state. */ - xDst -= pDst->pDrawable->x; - yDst -= pDst->pDrawable->y; - xSrc -= pSrc->pDrawable->x; - ySrc -= pSrc->pDrawable->y; - } - } - } - - /* Remove repeat in mask if useless */ - if (pMask && pMask->pDrawable && pMask->repeat && !pMask->transform && - xMask >= 0 && (xMask + width) <= pMask->pDrawable->width && - yMask >= 0 && (yMask + height) <= pMask->pDrawable->height) - pMask->repeat = 0; - - if (pExaScr->info->PrepareComposite && - !pSrc->alphaMap && (!pMask || !pMask->alphaMap) && !pDst->alphaMap) - { - Bool isSrcSolid; - - ret = exaTryDriverComposite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, - yMask, xDst, yDst, width, height); - if (ret == 1) - goto done; - - /* For generic masks and solid src pictures, mach64 can do Over in two - * passes, similar to the component-alpha case. - */ - isSrcSolid = pSrc->pDrawable ? - (pSrc->pDrawable->width == 1 && pSrc->pDrawable->height == 1 && - pSrc->repeat) : - (pSrc->pSourcePict->type == SourcePictTypeSolidFill); - - /* If we couldn't do the Composite in a single pass, and it was a - * component-alpha Over, see if we can do it in two passes with - * an OutReverse and then an Add. - */ - if (ret == -1 && op == PictOpOver && pMask && - (pMask->componentAlpha || isSrcSolid)) { - ret = exaTryMagicTwoPassCompositeHelper(op, pSrc, pMask, pDst, - xSrc, ySrc, - xMask, yMask, xDst, yDst, - width, height); - if (ret == 1) - goto done; - } - } - -fallback: -#if DEBUG_TRACE_FALL - exaPrintCompositeFallback (op, pSrc, pMask, pDst); -#endif - - ExaCheckComposite (op, pSrc, pMask, pDst, xSrc, ySrc, - xMask, yMask, xDst, yDst, width, height); - -done: - pSrc->repeat = saveSrcRepeat; - if (pMask) - pMask->repeat = saveMaskRepeat; -} - -/** - * Same as miCreateAlphaPicture, except it uses ExaCheckPolyFillRect instead - * of PolyFillRect to initialize the pixmap after creating it, to prevent - * the pixmap from being migrated. - * - * See the comments about exaTrapezoids and exaTriangles. - */ -static PicturePtr -exaCreateAlphaPicture (ScreenPtr pScreen, - PicturePtr pDst, - PictFormatPtr pPictFormat, - CARD16 width, - CARD16 height) -{ - PixmapPtr pPixmap; - PicturePtr pPicture; - GCPtr pGC; - int error; - xRectangle rect; - - if (width > 32767 || height > 32767) - return 0; - - if (!pPictFormat) - { - if (pDst->polyEdge == PolyEdgeSharp) - pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1); - else - pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8); - if (!pPictFormat) - return 0; - } - - pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, - pPictFormat->depth, 0); - if (!pPixmap) - return 0; - pGC = GetScratchGC (pPixmap->drawable.depth, pScreen); - if (!pGC) - { - (*pScreen->DestroyPixmap) (pPixmap); - return 0; - } - ValidateGC (&pPixmap->drawable, pGC); - rect.x = 0; - rect.y = 0; - rect.width = width; - rect.height = height; - ExaCheckPolyFillRect (&pPixmap->drawable, pGC, 1, &rect); - exaPixmapDirty (pPixmap, 0, 0, width, height); - FreeScratchGC (pGC); - pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat, - 0, 0, serverClient, &error); - (*pScreen->DestroyPixmap) (pPixmap); - return pPicture; -} - -/** - * exaTrapezoids is essentially a copy of miTrapezoids that uses - * exaCreateAlphaPicture instead of miCreateAlphaPicture. - * - * The problem with miCreateAlphaPicture is that it calls PolyFillRect - * to initialize the contents after creating the pixmap, which - * causes the pixmap to be moved in for acceleration. The subsequent - * call to RasterizeTrapezoid won't be accelerated however, which - * forces the pixmap to be moved out again. - * - * exaCreateAlphaPicture avoids this roundtrip by using ExaCheckPolyFillRect - * to initialize the contents. - */ -void -exaTrapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, - int ntrap, xTrapezoid *traps) -{ - ScreenPtr pScreen = pDst->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - BoxRec bounds; - - if (maskFormat) { - PicturePtr pPicture; - INT16 xDst, yDst; - INT16 xRel, yRel; - - miTrapezoidBounds (ntrap, traps, &bounds); - - if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) - return; - - xDst = traps[0].left.p1.x >> 16; - yDst = traps[0].left.p1.y >> 16; - - pPicture = exaCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - return; - - exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST); - for (; ntrap; ntrap--, traps++) - (*ps->RasterizeTrapezoid) (pPicture, traps, - -bounds.x1, -bounds.y1); - exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST); - - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); - } else { - if (pDst->polyEdge == PolyEdgeSharp) - maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1); - else - maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8); - for (; ntrap; ntrap--, traps++) - exaTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps); - } -} - -/** - * exaTriangles is essentially a copy of miTriangles that uses - * exaCreateAlphaPicture instead of miCreateAlphaPicture. - * - * The problem with miCreateAlphaPicture is that it calls PolyFillRect - * to initialize the contents after creating the pixmap, which - * causes the pixmap to be moved in for acceleration. The subsequent - * call to AddTriangles won't be accelerated however, which forces the pixmap - * to be moved out again. - * - * exaCreateAlphaPicture avoids this roundtrip by using ExaCheckPolyFillRect - * to initialize the contents. - */ -void -exaTriangles (CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, - int ntri, xTriangle *tris) -{ - ScreenPtr pScreen = pDst->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - BoxRec bounds; - - if (maskFormat) { - PicturePtr pPicture; - INT16 xDst, yDst; - INT16 xRel, yRel; - - miTriangleBounds (ntri, tris, &bounds); - - if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) - return; - - xDst = tris[0].p1.x >> 16; - yDst = tris[0].p1.y >> 16; - - pPicture = exaCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - return; - - exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST); - (*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris); - exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST); - - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); - } else { - if (pDst->polyEdge == PolyEdgeSharp) - maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1); - else - maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8); - - for (; ntri; ntri--, tris++) - exaTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris); - } -} +/*
+ * Copyright © 2001 Keith Packard
+ *
+ * Partly based on code that is Copyright © The XFree86 Project Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "exa_priv.h"
+
+#include "mipict.h"
+
+#if DEBUG_TRACE_FALL
+static void exaCompositeFallbackPictDesc(PicturePtr pict, char *string, int n)
+{
+ char format[20];
+ char size[20];
+ char loc;
+ int temp;
+
+ if (!pict) {
+ snprintf(string, n, "None");
+ return;
+ }
+
+ switch (pict->format)
+ {
+ case PICT_a8r8g8b8:
+ snprintf(format, 20, "ARGB8888");
+ break;
+ case PICT_x8r8g8b8:
+ snprintf(format, 20, "XRGB8888");
+ break;
+ case PICT_b8g8r8a8:
+ snprintf(format, 20, "BGRA8888");
+ break;
+ case PICT_b8g8r8x8:
+ snprintf(format, 20, "BGRX8888");
+ break;
+ case PICT_r5g6b5:
+ snprintf(format, 20, "RGB565 ");
+ break;
+ case PICT_x1r5g5b5:
+ snprintf(format, 20, "RGB555 ");
+ break;
+ case PICT_a8:
+ snprintf(format, 20, "A8 ");
+ break;
+ case PICT_a1:
+ snprintf(format, 20, "A1 ");
+ break;
+ default:
+ snprintf(format, 20, "0x%x", (int)pict->format);
+ break;
+ }
+
+ if (pict->pDrawable) {
+ loc = exaGetOffscreenPixmap(pict->pDrawable, &temp, &temp) ? 's' : 'm';
+
+ snprintf(size, 20, "%dx%d%s", pict->pDrawable->width,
+ pict->pDrawable->height, pict->repeat ?
+ " R" : "");
+ } else {
+ loc = '-';
+
+ snprintf(size, 20, "%s", pict->repeat ? " R" : "");
+ }
+
+ snprintf(string, n, "%p:%c fmt %s (%s)", pict->pDrawable, loc, format, size);
+}
+
+static void
+exaPrintCompositeFallback(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst)
+{
+ char sop[20];
+ char srcdesc[40], maskdesc[40], dstdesc[40];
+
+ switch(op)
+ {
+ case PictOpSrc:
+ sprintf(sop, "Src");
+ break;
+ case PictOpOver:
+ sprintf(sop, "Over");
+ break;
+ default:
+ sprintf(sop, "0x%x", (int)op);
+ break;
+ }
+
+ exaCompositeFallbackPictDesc(pSrc, srcdesc, 40);
+ exaCompositeFallbackPictDesc(pMask, maskdesc, 40);
+ exaCompositeFallbackPictDesc(pDst, dstdesc, 40);
+
+ ErrorF("Composite fallback: op %s, \n"
+ " src %s, \n"
+ " mask %s, \n"
+ " dst %s, \n",
+ sop, srcdesc, maskdesc, dstdesc);
+}
+#endif /* DEBUG_TRACE_FALL */
+
+Bool
+exaOpReadsDestination (CARD8 op)
+{
+ /* FALSE (does not read destination) is the list of ops in the protocol
+ * document with "0" in the "Fb" column and no "Ab" in the "Fa" column.
+ * That's just Clear and Src. ReduceCompositeOp() will already have
+ * converted con/disjoint clear/src to Clear or Src.
+ */
+ switch (op) {
+ case PictOpClear:
+ case PictOpSrc:
+ return FALSE;
+ default:
+ return TRUE;
+ }
+}
+
+
+static Bool
+exaGetPixelFromRGBA(CARD32 *pixel,
+ CARD16 red,
+ CARD16 green,
+ CARD16 blue,
+ CARD16 alpha,
+ PictFormatPtr pFormat)
+{
+ int rbits, bbits, gbits, abits;
+ int rshift, bshift, gshift, ashift;
+
+ *pixel = 0;
+
+ if (!PICT_FORMAT_COLOR(pFormat->format) &&
+ PICT_FORMAT_TYPE(pFormat->format) != PICT_TYPE_A)
+ return FALSE;
+
+ rbits = PICT_FORMAT_R(pFormat->format);
+ gbits = PICT_FORMAT_G(pFormat->format);
+ bbits = PICT_FORMAT_B(pFormat->format);
+ abits = PICT_FORMAT_A(pFormat->format);
+
+ rshift = pFormat->direct.red;
+ gshift = pFormat->direct.green;
+ bshift = pFormat->direct.blue;
+ ashift = pFormat->direct.alpha;
+
+ *pixel |= ( blue >> (16 - bbits)) << bshift;
+ *pixel |= ( red >> (16 - rbits)) << rshift;
+ *pixel |= (green >> (16 - gbits)) << gshift;
+ *pixel |= (alpha >> (16 - abits)) << ashift;
+
+ return TRUE;
+}
+
+static Bool
+exaGetRGBAFromPixel(CARD32 pixel,
+ CARD16 *red,
+ CARD16 *green,
+ CARD16 *blue,
+ CARD16 *alpha,
+ PictFormatPtr pFormat,
+ PictFormatShort format)
+{
+ int rbits, bbits, gbits, abits;
+ int rshift, bshift, gshift, ashift;
+
+ if (!PICT_FORMAT_COLOR(format) && PICT_FORMAT_TYPE(format) != PICT_TYPE_A)
+ return FALSE;
+
+ rbits = PICT_FORMAT_R(format);
+ gbits = PICT_FORMAT_G(format);
+ bbits = PICT_FORMAT_B(format);
+ abits = PICT_FORMAT_A(format);
+
+ if (pFormat) {
+ rshift = pFormat->direct.red;
+ gshift = pFormat->direct.green;
+ bshift = pFormat->direct.blue;
+ ashift = pFormat->direct.alpha;
+ } else if (format == PICT_a8r8g8b8) {
+ rshift = 16;
+ gshift = 8;
+ bshift = 0;
+ ashift = 24;
+ } else
+ FatalError("EXA bug: exaGetRGBAFromPixel() doesn't match "
+ "createSourcePicture()\n");
+
+ if (rbits) {
+ *red = ((pixel >> rshift ) & ((1 << rbits) - 1)) << (16 - rbits);
+ while (rbits < 16) {
+ *red |= *red >> rbits;
+ rbits <<= 1;
+ }
+
+ *green = ((pixel >> gshift ) & ((1 << gbits) - 1)) << (16 - gbits);
+ while (gbits < 16) {
+ *green |= *green >> gbits;
+ gbits <<= 1;
+ }
+
+ *blue = ((pixel >> bshift ) & ((1 << bbits) - 1)) << (16 - bbits);
+ while (bbits < 16) {
+ *blue |= *blue >> bbits;
+ bbits <<= 1;
+ }
+ } else {
+ *red = 0x0000;
+ *green = 0x0000;
+ *blue = 0x0000;
+ }
+
+ if (abits) {
+ *alpha = ((pixel >> ashift ) & ((1 << abits) - 1)) << (16 - abits);
+ while (abits < 16) {
+ *alpha |= *alpha >> abits;
+ abits <<= 1;
+ }
+ } else
+ *alpha = 0xffff;
+
+ return TRUE;
+}
+
+static int
+exaTryDriverSolidFill(PicturePtr pSrc,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ ExaScreenPriv (pDst->pDrawable->pScreen);
+ RegionRec region;
+ BoxPtr pbox;
+ int nbox;
+ int dst_off_x, dst_off_y;
+ PixmapPtr pSrcPix, pDstPix;
+ ExaPixmapPrivPtr pDstExaPix;
+ CARD32 pixel;
+ CARD16 red, green, blue, alpha;
+
+ pDstPix = exaGetDrawablePixmap (pDst->pDrawable);
+ pDstExaPix = ExaGetPixmapPriv(pDstPix);
+
+ /* Check whether the accelerator can use the destination pixmap.
+ */
+ if (pDstExaPix->accel_blocked)
+ {
+ return -1;
+ }
+
+ xDst += pDst->pDrawable->x;
+ yDst += pDst->pDrawable->y;
+ if (pSrc->pDrawable) {
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+ }
+
+ if (!miComputeCompositeRegion (®ion, pSrc, NULL, pDst,
+ xSrc, ySrc, 0, 0, xDst, yDst,
+ width, height))
+ return 1;
+
+ exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &dst_off_x, &dst_off_y);
+
+ RegionTranslate(®ion, dst_off_x, dst_off_y);
+
+ if (pSrc->pDrawable) {
+ pSrcPix = exaGetDrawablePixmap (pSrc->pDrawable);
+ pixel = exaGetPixmapFirstPixel (pSrcPix);
+ } else
+ pixel = pSrc->pSourcePict->solidFill.color;
+
+ if (!exaGetRGBAFromPixel(pixel, &red, &green, &blue, &alpha,
+ pSrc->pFormat, pSrc->format) ||
+ !exaGetPixelFromRGBA(&pixel, red, green, blue, alpha,
+ pDst->pFormat))
+ {
+ RegionUninit(®ion);
+ return -1;
+ }
+
+ if (pExaScr->do_migration) {
+ ExaMigrationRec pixmaps[1];
+
+ pixmaps[0].as_dst = TRUE;
+ pixmaps[0].as_src = FALSE;
+ pixmaps[0].pPix = pDstPix;
+ pixmaps[0].pReg = ®ion;
+ exaDoMigration(pixmaps, 1, TRUE);
+ }
+
+ if (!exaPixmapHasGpuCopy(pDstPix)) {
+ RegionUninit(®ion);
+ return 0;
+ }
+
+ if (!(*pExaScr->info->PrepareSolid) (pDstPix, GXcopy, 0xffffffff, pixel))
+ {
+ RegionUninit(®ion);
+ return -1;
+ }
+
+ nbox = RegionNumRects(®ion);
+ pbox = RegionRects(®ion);
+
+ while (nbox--)
+ {
+ (*pExaScr->info->Solid) (pDstPix, pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ pbox++;
+ }
+
+ (*pExaScr->info->DoneSolid) (pDstPix);
+ exaMarkSync(pDst->pDrawable->pScreen);
+
+ RegionUninit(®ion);
+ return 1;
+}
+
+static int
+exaTryDriverCompositeRects(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ int nrect,
+ ExaCompositeRectPtr rects)
+{
+ ExaScreenPriv (pDst->pDrawable->pScreen);
+ int src_off_x = 0, src_off_y = 0, mask_off_x = 0, mask_off_y = 0;
+ int dst_off_x, dst_off_y;
+ PixmapPtr pSrcPix = NULL, pMaskPix = NULL, pDstPix;
+ ExaPixmapPrivPtr pSrcExaPix = NULL, pMaskExaPix = NULL, pDstExaPix;
+
+ if (!pExaScr->info->PrepareComposite)
+ return -1;
+
+ if (pSrc->pDrawable) {
+ pSrcPix = exaGetDrawablePixmap(pSrc->pDrawable);
+ pSrcExaPix = ExaGetPixmapPriv(pSrcPix);
+ }
+
+ if (pMask && pMask->pDrawable) {
+ pMaskPix = exaGetDrawablePixmap(pMask->pDrawable);
+ pMaskExaPix = ExaGetPixmapPriv(pMaskPix);
+ }
+
+ pDstPix = exaGetDrawablePixmap(pDst->pDrawable);
+ pDstExaPix = ExaGetPixmapPriv(pDstPix);
+
+ /* Check whether the accelerator can use these pixmaps.
+ * FIXME: If it cannot, use temporary pixmaps so that the drawing
+ * happens within limits.
+ */
+ if (pDstExaPix->accel_blocked ||
+ (pSrcExaPix && pSrcExaPix->accel_blocked) ||
+ (pMaskExaPix && pMaskExaPix->accel_blocked))
+ {
+ return -1;
+ }
+
+ if (pExaScr->info->CheckComposite &&
+ !(*pExaScr->info->CheckComposite) (op, pSrc, pMask, pDst))
+ {
+ return -1;
+ }
+
+ if (pExaScr->do_migration) {
+ ExaMigrationRec pixmaps[3];
+ int i = 0;
+
+ pixmaps[i].as_dst = TRUE;
+ pixmaps[i].as_src = exaOpReadsDestination(op);
+ pixmaps[i].pPix = pDstPix;
+ pixmaps[i].pReg = NULL;
+ i++;
+
+ if (pSrcPix) {
+ pixmaps[i].as_dst = FALSE;
+ pixmaps[i].as_src = TRUE;
+ pixmaps[i].pPix = pSrcPix;
+ pixmaps[i].pReg = NULL;
+ i++;
+ }
+
+ if (pMaskPix) {
+ pixmaps[i].as_dst = FALSE;
+ pixmaps[i].as_src = TRUE;
+ pixmaps[i].pPix = pMaskPix;
+ pixmaps[i].pReg = NULL;
+ i++;
+ }
+
+ exaDoMigration(pixmaps, i, TRUE);
+ }
+
+ pDstPix = exaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x, &dst_off_y);
+ if (!pDstPix)
+ return 0;
+
+ if (pSrcPix) {
+ pSrcPix = exaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, &src_off_y);
+ if (!pSrcPix)
+ return 0;
+ }
+
+ if (pMaskPix) {
+ pMaskPix = exaGetOffscreenPixmap (pMask->pDrawable, &mask_off_x, &mask_off_y);
+ if (!pMaskPix)
+ return 0;
+ }
+
+ if (!(*pExaScr->info->PrepareComposite) (op, pSrc, pMask, pDst, pSrcPix,
+ pMaskPix, pDstPix))
+ return -1;
+
+ while (nrect--)
+ {
+ INT16 xDst = rects->xDst + pDst->pDrawable->x;
+ INT16 yDst = rects->yDst + pDst->pDrawable->y;
+ INT16 xMask = rects->xMask;
+ INT16 yMask = rects->yMask;
+ INT16 xSrc = rects->xSrc;
+ INT16 ySrc = rects->ySrc;
+ RegionRec region;
+ BoxPtr pbox;
+ int nbox;
+
+ if (pMaskPix) {
+ xMask += pMask->pDrawable->x;
+ yMask += pMask->pDrawable->y;
+ }
+
+ if (pSrcPix) {
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+ }
+
+ if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ rects->width, rects->height))
+ goto next_rect;
+
+ RegionTranslate(®ion, dst_off_x, dst_off_y);
+
+ nbox = RegionNumRects(®ion);
+ pbox = RegionRects(®ion);
+
+ xMask = xMask + mask_off_x - xDst - dst_off_x;
+ yMask = yMask + mask_off_y - yDst - dst_off_y;
+ xSrc = xSrc + src_off_x - xDst - dst_off_x;
+ ySrc = ySrc + src_off_y - yDst - dst_off_y;
+
+ while (nbox--)
+ {
+ (*pExaScr->info->Composite) (pDstPix,
+ pbox->x1 + xSrc,
+ pbox->y1 + ySrc,
+ pbox->x1 + xMask,
+ pbox->y1 + yMask,
+ pbox->x1,
+ pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ pbox++;
+ }
+
+ next_rect:
+ RegionUninit(®ion);
+
+ rects++;
+ }
+
+ (*pExaScr->info->DoneComposite) (pDstPix);
+ exaMarkSync(pDst->pDrawable->pScreen);
+
+ return 1;
+}
+
+/**
+ * Copy a number of rectangles from source to destination in a single
+ * operation. This is specialized for glyph rendering: we don't have the
+ * special-case fallbacks found in exaComposite() - if the driver can support
+ * it, we use the driver functionality, otherwise we fall back straight to
+ * software.
+ */
+void
+exaCompositeRects(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ int nrect,
+ ExaCompositeRectPtr rects)
+{
+ ExaScreenPriv (pDst->pDrawable->pScreen);
+ int n;
+ ExaCompositeRectPtr r;
+ int ret;
+
+ /* If we get a mask, that means we're rendering to the exaGlyphs
+ * destination directly, so the damage layer takes care of this.
+ */
+ if (!pMask) {
+ RegionRec region;
+ int x1 = MAXSHORT;
+ int y1 = MAXSHORT;
+ int x2 = MINSHORT;
+ int y2 = MINSHORT;
+ BoxRec box;
+
+ /* We have to manage the damage ourselves, since CompositeRects isn't
+ * something in the screen that can be managed by the damage extension,
+ * and EXA depends on damage to track what needs to be migrated between
+ * the gpu and the cpu.
+ */
+
+ /* Compute the overall extents of the composited region - we're making
+ * the assumption here that we are compositing a bunch of glyphs that
+ * cluster closely together and damaging each glyph individually would
+ * be a loss compared to damaging the bounding box.
+ */
+ n = nrect;
+ r = rects;
+ while (n--) {
+ int rect_x2 = r->xDst + r->width;
+ int rect_y2 = r->yDst + r->height;
+
+ if (r->xDst < x1) x1 = r->xDst;
+ if (r->yDst < y1) y1 = r->yDst;
+ if (rect_x2 > x2) x2 = rect_x2;
+ if (rect_y2 > y2) y2 = rect_y2;
+
+ r++;
+ }
+
+ if (x2 <= x1 || y2 <= y1)
+ return;
+
+ box.x1 = x1;
+ box.x2 = x2 < MAXSHORT ? x2 : MAXSHORT;
+ box.y1 = y1;
+ box.y2 = y2 < MAXSHORT ? y2 : MAXSHORT;
+
+ /* The pixmap migration code relies on pendingDamage indicating
+ * the bounds of the current rendering, so we need to force
+ * the actual damage into that region before we do anything, and
+ * (see use of DamagePendingRegion in exaCopyDirty)
+ */
+
+ RegionInit(®ion, &box, 1);
+
+ DamageRegionAppend(pDst->pDrawable, ®ion);
+
+ RegionUninit(®ion);
+ }
+
+ /************************************************************/
+
+ ValidatePicture (pSrc);
+ if (pMask)
+ ValidatePicture (pMask);
+ ValidatePicture (pDst);
+
+ ret = exaTryDriverCompositeRects(op, pSrc, pMask, pDst, nrect, rects);
+
+ if (ret != 1) {
+ if (ret == -1 && op == PictOpOver && pMask && pMask->componentAlpha &&
+ (!pExaScr->info->CheckComposite ||
+ ((*pExaScr->info->CheckComposite)(PictOpOutReverse, pSrc, pMask,
+ pDst) &&
+ (*pExaScr->info->CheckComposite)(PictOpAdd, pSrc, pMask, pDst)))) {
+ ret = exaTryDriverCompositeRects(PictOpOutReverse, pSrc, pMask,
+ pDst, nrect, rects);
+ if (ret == 1) {
+ op = PictOpAdd;
+ ret = exaTryDriverCompositeRects(op, pSrc, pMask, pDst, nrect,
+ rects);
+ }
+ }
+
+ if (ret != 1) {
+ n = nrect;
+ r = rects;
+ while (n--) {
+ ExaCheckComposite (op, pSrc, pMask, pDst,
+ r->xSrc, r->ySrc,
+ r->xMask, r->yMask,
+ r->xDst, r->yDst,
+ r->width, r->height);
+ r++;
+ }
+ }
+ }
+
+ /************************************************************/
+
+ if (!pMask) {
+ /* Now we have to flush the damage out from pendingDamage => damage
+ * Calling DamageRegionProcessPending has that effect.
+ */
+
+ DamageRegionProcessPending(pDst->pDrawable);
+ }
+}
+
+static int
+exaTryDriverComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ ExaScreenPriv (pDst->pDrawable->pScreen);
+ RegionRec region;
+ BoxPtr pbox;
+ int nbox;
+ int src_off_x, src_off_y, mask_off_x, mask_off_y, dst_off_x, dst_off_y;
+ PixmapPtr pSrcPix = NULL, pMaskPix = NULL, pDstPix;
+ ExaPixmapPrivPtr pSrcExaPix = NULL, pMaskExaPix = NULL, pDstExaPix;
+
+ if (pSrc->pDrawable) {
+ pSrcPix = exaGetDrawablePixmap(pSrc->pDrawable);
+ pSrcExaPix = ExaGetPixmapPriv(pSrcPix);
+ }
+
+ pDstPix = exaGetDrawablePixmap(pDst->pDrawable);
+ pDstExaPix = ExaGetPixmapPriv(pDstPix);
+
+ if (pMask && pMask->pDrawable) {
+ pMaskPix = exaGetDrawablePixmap(pMask->pDrawable);
+ pMaskExaPix = ExaGetPixmapPriv(pMaskPix);
+ }
+
+ /* Check whether the accelerator can use these pixmaps.
+ * FIXME: If it cannot, use temporary pixmaps so that the drawing
+ * happens within limits.
+ */
+ if (pDstExaPix->accel_blocked ||
+ (pSrcExaPix && pSrcExaPix->accel_blocked) ||
+ (pMaskExaPix && (pMaskExaPix->accel_blocked)))
+ {
+ return -1;
+ }
+
+ xDst += pDst->pDrawable->x;
+ yDst += pDst->pDrawable->y;
+
+ if (pMaskPix) {
+ xMask += pMask->pDrawable->x;
+ yMask += pMask->pDrawable->y;
+ }
+
+ if (pSrcPix) {
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+ }
+
+ if (pExaScr->info->CheckComposite &&
+ !(*pExaScr->info->CheckComposite) (op, pSrc, pMask, pDst))
+ {
+ return -1;
+ }
+
+ if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ width, height))
+ return 1;
+
+ exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &dst_off_x, &dst_off_y);
+
+ RegionTranslate(®ion, dst_off_x, dst_off_y);
+
+ if (pExaScr->do_migration) {
+ ExaMigrationRec pixmaps[3];
+ int i = 0;
+
+ pixmaps[i].as_dst = TRUE;
+ pixmaps[i].as_src = exaOpReadsDestination(op);
+ pixmaps[i].pPix = pDstPix;
+ pixmaps[i].pReg = pixmaps[0].as_src ? NULL : ®ion;
+ i++;
+
+ if (pSrcPix) {
+ pixmaps[i].as_dst = FALSE;
+ pixmaps[i].as_src = TRUE;
+ pixmaps[i].pPix = pSrcPix;
+ pixmaps[i].pReg = NULL;
+ i++;
+ }
+
+ if (pMaskPix) {
+ pixmaps[i].as_dst = FALSE;
+ pixmaps[i].as_src = TRUE;
+ pixmaps[i].pPix = pMaskPix;
+ pixmaps[i].pReg = NULL;
+ i++;
+ }
+
+ exaDoMigration(pixmaps, i, TRUE);
+ }
+
+ if (pSrcPix) {
+ pSrcPix = exaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, &src_off_y);
+ if (!pSrcPix) {
+ RegionUninit(®ion);
+ return 0;
+ }
+ }
+
+ if (pMaskPix) {
+ pMaskPix = exaGetOffscreenPixmap (pMask->pDrawable, &mask_off_x,
+ &mask_off_y);
+ if (!pMaskPix) {
+ RegionUninit(®ion);
+ return 0;
+ }
+ }
+
+ if (!exaPixmapHasGpuCopy(pDstPix)) {
+ RegionUninit(®ion);
+ return 0;
+ }
+
+ if (!(*pExaScr->info->PrepareComposite) (op, pSrc, pMask, pDst, pSrcPix,
+ pMaskPix, pDstPix))
+ {
+ RegionUninit(®ion);
+ return -1;
+ }
+
+ nbox = RegionNumRects(®ion);
+ pbox = RegionRects(®ion);
+
+ xMask = xMask + mask_off_x - xDst - dst_off_x;
+ yMask = yMask + mask_off_y - yDst - dst_off_y;
+
+ xSrc = xSrc + src_off_x - xDst - dst_off_x;
+ ySrc = ySrc + src_off_y - yDst - dst_off_y;
+
+ while (nbox--)
+ {
+ (*pExaScr->info->Composite) (pDstPix,
+ pbox->x1 + xSrc,
+ pbox->y1 + ySrc,
+ pbox->x1 + xMask,
+ pbox->y1 + yMask,
+ pbox->x1,
+ pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ pbox++;
+ }
+ (*pExaScr->info->DoneComposite) (pDstPix);
+ exaMarkSync(pDst->pDrawable->pScreen);
+
+ RegionUninit(®ion);
+ return 1;
+}
+
+/**
+ * exaTryMagicTwoPassCompositeHelper implements PictOpOver using two passes of
+ * simpler operations PictOpOutReverse and PictOpAdd. Mainly used for component
+ * alpha and limited 1-tmu cards.
+ *
+ * From http://anholt.livejournal.com/32058.html:
+ *
+ * The trouble is that component-alpha rendering requires two different sources
+ * for blending: one for the source value to the blender, which is the
+ * per-channel multiplication of source and mask, and one for the source alpha
+ * for multiplying with the destination channels, which is the multiplication
+ * of the source channels by the mask alpha. So the equation for Over is:
+ *
+ * dst.A = src.A * mask.A + (1 - (src.A * mask.A)) * dst.A
+ * dst.R = src.R * mask.R + (1 - (src.A * mask.R)) * dst.R
+ * dst.G = src.G * mask.G + (1 - (src.A * mask.G)) * dst.G
+ * dst.B = src.B * mask.B + (1 - (src.A * mask.B)) * dst.B
+ *
+ * But we can do some simpler operations, right? How about PictOpOutReverse,
+ * which has a source factor of 0 and dest factor of (1 - source alpha). We
+ * can get the source alpha value (srca.X = src.A * mask.X) out of the texture
+ * blenders pretty easily. So we can do a component-alpha OutReverse, which
+ * gets us:
+ *
+ * dst.A = 0 + (1 - (src.A * mask.A)) * dst.A
+ * dst.R = 0 + (1 - (src.A * mask.R)) * dst.R
+ * dst.G = 0 + (1 - (src.A * mask.G)) * dst.G
+ * dst.B = 0 + (1 - (src.A * mask.B)) * dst.B
+ *
+ * OK. And if an op doesn't use the source alpha value for the destination
+ * factor, then we can do the channel multiplication in the texture blenders
+ * to get the source value, and ignore the source alpha that we wouldn't use.
+ * We've supported this in the Radeon driver for a long time. An example would
+ * be PictOpAdd, which does:
+ *
+ * dst.A = src.A * mask.A + dst.A
+ * dst.R = src.R * mask.R + dst.R
+ * dst.G = src.G * mask.G + dst.G
+ * dst.B = src.B * mask.B + dst.B
+ *
+ * Hey, this looks good! If we do a PictOpOutReverse and then a PictOpAdd right
+ * after it, we get:
+ *
+ * dst.A = src.A * mask.A + ((1 - (src.A * mask.A)) * dst.A)
+ * dst.R = src.R * mask.R + ((1 - (src.A * mask.R)) * dst.R)
+ * dst.G = src.G * mask.G + ((1 - (src.A * mask.G)) * dst.G)
+ * dst.B = src.B * mask.B + ((1 - (src.A * mask.B)) * dst.B)
+ */
+
+static int
+exaTryMagicTwoPassCompositeHelper(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ ExaScreenPriv (pDst->pDrawable->pScreen);
+
+ assert(op == PictOpOver);
+
+ if (pExaScr->info->CheckComposite &&
+ (!(*pExaScr->info->CheckComposite)(PictOpOutReverse, pSrc, pMask,
+ pDst) ||
+ !(*pExaScr->info->CheckComposite)(PictOpAdd, pSrc, pMask, pDst)))
+ {
+ return -1;
+ }
+
+ /* Now, we think we should be able to accelerate this operation. First,
+ * composite the destination to be the destination times the source alpha
+ * factors.
+ */
+ exaComposite(PictOpOutReverse, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
+ xDst, yDst, width, height);
+
+ /* Then, add in the source value times the destination alpha factors (1.0).
+ */
+ exaComposite(PictOpAdd, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
+ xDst, yDst, width, height);
+
+ return 1;
+}
+
+void
+exaComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ ExaScreenPriv (pDst->pDrawable->pScreen);
+ int ret = -1;
+ Bool saveSrcRepeat = pSrc->repeat;
+ Bool saveMaskRepeat = pMask ? pMask->repeat : 0;
+ RegionRec region;
+
+ if (pExaScr->swappedOut)
+ goto fallback;
+
+ /* Remove repeat in source if useless */
+ if (pSrc->pDrawable && pSrc->repeat && !pSrc->transform && xSrc >= 0 &&
+ (xSrc + width) <= pSrc->pDrawable->width && ySrc >= 0 &&
+ (ySrc + height) <= pSrc->pDrawable->height)
+ pSrc->repeat = 0;
+
+ if (!pMask && !pSrc->alphaMap && !pDst->alphaMap &&
+ (op == PictOpSrc || (op == PictOpOver && !PICT_FORMAT_A(pSrc->format))))
+ {
+ if (pSrc->pDrawable ?
+ (pSrc->pDrawable->width == 1 && pSrc->pDrawable->height == 1 &&
+ pSrc->repeat) :
+ (pSrc->pSourcePict->type == SourcePictTypeSolidFill))
+ {
+ ret = exaTryDriverSolidFill(pSrc, pDst, xSrc, ySrc, xDst, yDst,
+ width, height);
+ if (ret == 1)
+ goto done;
+ } else if (pSrc->pDrawable && !pSrc->transform &&
+ ((op == PictOpSrc &&
+ (pSrc->format == pDst->format ||
+ (PICT_FORMAT_COLOR(pDst->format) &&
+ PICT_FORMAT_COLOR(pSrc->format) &&
+ pDst->format == PICT_FORMAT(PICT_FORMAT_BPP(pSrc->format),
+ PICT_FORMAT_TYPE(pSrc->format),
+ 0,
+ PICT_FORMAT_R(pSrc->format),
+ PICT_FORMAT_G(pSrc->format),
+ PICT_FORMAT_B(pSrc->format))))) ||
+ (op == PictOpOver && pSrc->format == pDst->format &&
+ !PICT_FORMAT_A(pSrc->format))))
+ {
+ if (!pSrc->repeat && xSrc >= 0 && ySrc >= 0 &&
+ (xSrc + width <= pSrc->pDrawable->width) &&
+ (ySrc + height <= pSrc->pDrawable->height))
+ {
+ Bool ret;
+ xDst += pDst->pDrawable->x;
+ yDst += pDst->pDrawable->y;
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+
+ if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst,
+ yDst, width, height))
+ goto done;
+
+ ret = exaHWCopyNtoN(pSrc->pDrawable, pDst->pDrawable, NULL,
+ RegionRects(®ion), RegionNumRects(®ion),
+ xSrc - xDst, ySrc - yDst, FALSE, FALSE);
+ RegionUninit(®ion);
+
+ /* Reset values to their original values. */
+ xDst -= pDst->pDrawable->x;
+ yDst -= pDst->pDrawable->y;
+ xSrc -= pSrc->pDrawable->x;
+ ySrc -= pSrc->pDrawable->y;
+
+ if (!ret)
+ goto fallback;
+
+ goto done;
+ }
+
+ if (pSrc->repeat && pSrc->repeatType == RepeatNormal &&
+ pSrc->pDrawable->type == DRAWABLE_PIXMAP)
+ {
+ DDXPointRec patOrg;
+
+ /* Let's see if the driver can do the repeat in one go */
+ if (pExaScr->info->PrepareComposite && !pSrc->alphaMap &&
+ !pDst->alphaMap)
+ {
+ ret = exaTryDriverComposite(op, pSrc, pMask, pDst, xSrc,
+ ySrc, xMask, yMask, xDst, yDst,
+ width, height);
+ if (ret == 1)
+ goto done;
+ }
+
+ /* Now see if we can use exaFillRegionTiled() */
+ xDst += pDst->pDrawable->x;
+ yDst += pDst->pDrawable->y;
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+
+ if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc,
+ ySrc, xMask, yMask, xDst, yDst,
+ width, height))
+ goto done;
+
+ /* pattern origin is the point in the destination drawable
+ * corresponding to (0,0) in the source */
+ patOrg.x = xDst - xSrc;
+ patOrg.y = yDst - ySrc;
+
+ ret = exaFillRegionTiled(pDst->pDrawable, ®ion,
+ (PixmapPtr)pSrc->pDrawable,
+ &patOrg, FB_ALLONES, GXcopy, CT_NONE);
+
+ RegionUninit(®ion);
+
+ if (ret)
+ goto done;
+
+ /* Let's be correct and restore the variables to their original state. */
+ xDst -= pDst->pDrawable->x;
+ yDst -= pDst->pDrawable->y;
+ xSrc -= pSrc->pDrawable->x;
+ ySrc -= pSrc->pDrawable->y;
+ }
+ }
+ }
+
+ /* Remove repeat in mask if useless */
+ if (pMask && pMask->pDrawable && pMask->repeat && !pMask->transform &&
+ xMask >= 0 && (xMask + width) <= pMask->pDrawable->width &&
+ yMask >= 0 && (yMask + height) <= pMask->pDrawable->height)
+ pMask->repeat = 0;
+
+ if (pExaScr->info->PrepareComposite &&
+ !pSrc->alphaMap && (!pMask || !pMask->alphaMap) && !pDst->alphaMap)
+ {
+ Bool isSrcSolid;
+
+ ret = exaTryDriverComposite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask,
+ yMask, xDst, yDst, width, height);
+ if (ret == 1)
+ goto done;
+
+ /* For generic masks and solid src pictures, mach64 can do Over in two
+ * passes, similar to the component-alpha case.
+ */
+ isSrcSolid = pSrc->pDrawable ?
+ (pSrc->pDrawable->width == 1 && pSrc->pDrawable->height == 1 &&
+ pSrc->repeat) :
+ (pSrc->pSourcePict->type == SourcePictTypeSolidFill);
+
+ /* If we couldn't do the Composite in a single pass, and it was a
+ * component-alpha Over, see if we can do it in two passes with
+ * an OutReverse and then an Add.
+ */
+ if (ret == -1 && op == PictOpOver && pMask &&
+ (pMask->componentAlpha || isSrcSolid)) {
+ ret = exaTryMagicTwoPassCompositeHelper(op, pSrc, pMask, pDst,
+ xSrc, ySrc,
+ xMask, yMask, xDst, yDst,
+ width, height);
+ if (ret == 1)
+ goto done;
+ }
+ }
+
+fallback:
+#if DEBUG_TRACE_FALL
+ exaPrintCompositeFallback (op, pSrc, pMask, pDst);
+#endif
+
+ ExaCheckComposite (op, pSrc, pMask, pDst, xSrc, ySrc,
+ xMask, yMask, xDst, yDst, width, height);
+
+done:
+ pSrc->repeat = saveSrcRepeat;
+ if (pMask)
+ pMask->repeat = saveMaskRepeat;
+}
+
+/**
+ * Same as miCreateAlphaPicture, except it uses ExaCheckPolyFillRect instead
+ * of PolyFillRect to initialize the pixmap after creating it, to prevent
+ * the pixmap from being migrated.
+ *
+ * See the comments about exaTrapezoids and exaTriangles.
+ */
+static PicturePtr
+exaCreateAlphaPicture (ScreenPtr pScreen,
+ PicturePtr pDst,
+ PictFormatPtr pPictFormat,
+ CARD16 width,
+ CARD16 height)
+{
+ PixmapPtr pPixmap;
+ PicturePtr pPicture;
+ GCPtr pGC;
+ int error;
+ xRectangle rect;
+
+ if (width > 32767 || height > 32767)
+ return 0;
+
+ if (!pPictFormat)
+ {
+ if (pDst->polyEdge == PolyEdgeSharp)
+ pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+ else
+ pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+ if (!pPictFormat)
+ return 0;
+ }
+
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
+ pPictFormat->depth, 0);
+ if (!pPixmap)
+ return 0;
+ pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+ if (!pGC)
+ {
+ (*pScreen->DestroyPixmap) (pPixmap);
+ return 0;
+ }
+ ValidateGC (&pPixmap->drawable, pGC);
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = width;
+ rect.height = height;
+ ExaCheckPolyFillRect (&pPixmap->drawable, pGC, 1, &rect);
+ exaPixmapDirty (pPixmap, 0, 0, width, height);
+ FreeScratchGC (pGC);
+ pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat,
+ 0, 0, serverClient, &error);
+ (*pScreen->DestroyPixmap) (pPixmap);
+ return pPicture;
+}
+
+/**
+ * exaTrapezoids is essentially a copy of miTrapezoids that uses
+ * exaCreateAlphaPicture instead of miCreateAlphaPicture.
+ *
+ * The problem with miCreateAlphaPicture is that it calls PolyFillRect
+ * to initialize the contents after creating the pixmap, which
+ * causes the pixmap to be moved in for acceleration. The subsequent
+ * call to RasterizeTrapezoid won't be accelerated however, which
+ * forces the pixmap to be moved out again.
+ *
+ * exaCreateAlphaPicture avoids this roundtrip by using ExaCheckPolyFillRect
+ * to initialize the contents.
+ */
+void
+exaTrapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
+ int ntrap, xTrapezoid *traps)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ BoxRec bounds;
+
+ if (maskFormat) {
+ PicturePtr pPicture;
+ INT16 xDst, yDst;
+ INT16 xRel, yRel;
+
+ miTrapezoidBounds (ntrap, traps, &bounds);
+
+ if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
+ return;
+
+ xDst = traps[0].left.p1.x >> 16;
+ yDst = traps[0].left.p1.y >> 16;
+
+ pPicture = exaCreateAlphaPicture (pScreen, pDst, maskFormat,
+ bounds.x2 - bounds.x1,
+ bounds.y2 - bounds.y1);
+ if (!pPicture)
+ return;
+
+ exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
+ for (; ntrap; ntrap--, traps++)
+ (*ps->RasterizeTrapezoid) (pPicture, traps,
+ -bounds.x1, -bounds.y1);
+ exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
+
+ xRel = bounds.x1 + xSrc - xDst;
+ yRel = bounds.y1 + ySrc - yDst;
+ CompositePicture (op, pSrc, pPicture, pDst,
+ xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+ bounds.x2 - bounds.x1,
+ bounds.y2 - bounds.y1);
+ FreePicture (pPicture, 0);
+ } else {
+ if (pDst->polyEdge == PolyEdgeSharp)
+ maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+ else
+ maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+ for (; ntrap; ntrap--, traps++)
+ exaTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps);
+ }
+}
+
+/**
+ * exaTriangles is essentially a copy of miTriangles that uses
+ * exaCreateAlphaPicture instead of miCreateAlphaPicture.
+ *
+ * The problem with miCreateAlphaPicture is that it calls PolyFillRect
+ * to initialize the contents after creating the pixmap, which
+ * causes the pixmap to be moved in for acceleration. The subsequent
+ * call to AddTriangles won't be accelerated however, which forces the pixmap
+ * to be moved out again.
+ *
+ * exaCreateAlphaPicture avoids this roundtrip by using ExaCheckPolyFillRect
+ * to initialize the contents.
+ */
+void
+exaTriangles (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
+ int ntri, xTriangle *tris)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ BoxRec bounds;
+
+ if (maskFormat) {
+ PicturePtr pPicture;
+ INT16 xDst, yDst;
+ INT16 xRel, yRel;
+
+ miTriangleBounds (ntri, tris, &bounds);
+
+ if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
+ return;
+
+ xDst = tris[0].p1.x >> 16;
+ yDst = tris[0].p1.y >> 16;
+
+ pPicture = exaCreateAlphaPicture (pScreen, pDst, maskFormat,
+ bounds.x2 - bounds.x1,
+ bounds.y2 - bounds.y1);
+ if (!pPicture)
+ return;
+
+ exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
+ (*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris);
+ exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
+
+ xRel = bounds.x1 + xSrc - xDst;
+ yRel = bounds.y1 + ySrc - yDst;
+ CompositePicture (op, pSrc, pPicture, pDst,
+ xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+ bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+ FreePicture (pPicture, 0);
+ } else {
+ if (pDst->polyEdge == PolyEdgeSharp)
+ maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+ else
+ maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+
+ for (; ntri; ntri--, tris++)
+ exaTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris);
+ }
+}
diff --git a/xorg-server/exa/exa_unaccel.c b/xorg-server/exa/exa_unaccel.c index 96bdcb9c1..75c341adf 100644 --- a/xorg-server/exa/exa_unaccel.c +++ b/xorg-server/exa/exa_unaccel.c @@ -131,10 +131,10 @@ ExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, PixmapPtr pPixmap = exaGetDrawablePixmap(pSrc);
exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
- REGION_INIT(pScreen, ®, pbox, nbox);
- REGION_TRANSLATE(pScreen, ®, xoff + dx, yoff + dy);
+ RegionInit(®, pbox, nbox);
+ RegionTranslate(®, xoff + dx, yoff + dy);
pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, ®);
- REGION_UNINIT(pScreen, ®);
+ RegionUninit(®);
} else
exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
@@ -144,10 +144,10 @@ ExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, PixmapPtr pPixmap = exaGetDrawablePixmap(pDst);
exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
- REGION_INIT(pScreen, ®, pbox, nbox);
- REGION_TRANSLATE(pScreen, ®, xoff, yoff);
+ RegionInit(®, pbox, nbox);
+ RegionTranslate(®, xoff, yoff);
pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_DEST, ®);
- REGION_UNINIT(pScreen, ®);
+ RegionUninit(®);
} else
exaPrepareAccess (pDst, EXA_PREPARE_DEST);
@@ -188,9 +188,9 @@ ExaFallbackPrepareReg(DrawablePtr pDrawable, box.x2 = box.x1 + width;
box.y2 = box.y1 + height;
- REGION_INIT(pScreen, ®, &box, 1);
+ RegionInit(®, &box, 1);
pExaScr->prepare_access_reg(pPixmap, index, ®);
- REGION_UNINIT(pScreen, ®);
+ RegionUninit(®);
} else
exaPrepareAccess(pDrawable, index);
}
@@ -382,9 +382,9 @@ ExaCheckCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) int xoff, yoff;
exaGetDrawableDeltas(&pWin->drawable, pPixmap, &xoff, &yoff);
- REGION_TRANSLATE(pScreen, prgnSrc, xoff, yoff);
+ RegionTranslate(prgnSrc, xoff, yoff);
pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, prgnSrc);
- REGION_TRANSLATE(pScreen, prgnSrc, -xoff, -yoff);
+ RegionTranslate(prgnSrc, -xoff, -yoff);
} else
exaPrepareAccess(pDrawable, EXA_PREPARE_SRC);
@@ -458,9 +458,9 @@ ExaSrcValidate(DrawablePtr pDrawable, dst = (pExaScr->srcPix == pPix) ? &pExaScr->srcReg :
&pExaScr->maskReg;
- REGION_INIT(pScreen, ®, &box, 1);
- REGION_UNION(pScreen, dst, dst, ®);
- REGION_UNINIT(pScreen, ®);
+ RegionInit(®, &box, 1);
+ RegionUnion(dst, dst, ®);
+ RegionUninit(®);
if (pExaScr->SavedSourceValidate) {
swap(pExaScr, pScreen, SourceValidate);
@@ -495,30 +495,30 @@ ExaPrepareCompositeReg(ScreenPtr pScreen, Bool ret;
- REGION_NULL(pScreen, ®ion);
+ RegionNull(®ion);
if (pSrc->pDrawable) {
pSrcPix = exaGetDrawablePixmap(pSrc->pDrawable);
- REGION_NULL(pScreen, &pExaScr->srcReg);
+ RegionNull(&pExaScr->srcReg);
srcReg = &pExaScr->srcReg;
pExaScr->srcPix = pSrcPix;
if (pSrc != pDst)
- REGION_TRANSLATE(pScreen, pSrc->pCompositeClip,
+ RegionTranslate(pSrc->pCompositeClip,
-pSrc->pDrawable->x,
-pSrc->pDrawable->y);
}
if (pMask && pMask->pDrawable) {
pMaskPix = exaGetDrawablePixmap(pMask->pDrawable);
- REGION_NULL(pScreen, &pExaScr->maskReg);
+ RegionNull(&pExaScr->maskReg);
maskReg = &pExaScr->maskReg;
if (pMask != pDst && pMask != pSrc)
- REGION_TRANSLATE(pScreen, pMask->pCompositeClip,
+ RegionTranslate(pMask->pCompositeClip,
-pMask->pDrawable->x,
-pMask->pDrawable->y);
}
- REGION_TRANSLATE(pScreen, pDst->pCompositeClip,
+ RegionTranslate(pDst->pCompositeClip,
-pDst->pDrawable->x,
-pDst->pDrawable->y);
@@ -531,23 +531,23 @@ ExaPrepareCompositeReg(ScreenPtr pScreen, width, height);
swap(pExaScr, pScreen, SourceValidate);
- REGION_TRANSLATE(pScreen, pDst->pCompositeClip,
+ RegionTranslate(pDst->pCompositeClip,
pDst->pDrawable->x,
pDst->pDrawable->y);
if (pSrc->pDrawable && pSrc != pDst)
- REGION_TRANSLATE(pScreen, pSrc->pCompositeClip,
+ RegionTranslate(pSrc->pCompositeClip,
pSrc->pDrawable->x,
pSrc->pDrawable->y);
if (pMask && pMask->pDrawable && pMask != pDst && pMask != pSrc)
- REGION_TRANSLATE(pScreen, pMask->pCompositeClip,
+ RegionTranslate(pMask->pCompositeClip,
pMask->pDrawable->x,
pMask->pDrawable->y);
if (!ret) {
if (srcReg)
- REGION_UNINIT(pScreen, srcReg);
+ RegionUninit(srcReg);
if (maskReg)
- REGION_UNINIT(pScreen, maskReg);
+ RegionUninit(maskReg);
return FALSE;
}
@@ -577,9 +577,9 @@ ExaPrepareCompositeReg(ScreenPtr pScreen, maskReg);
if (srcReg)
- REGION_UNINIT(pScreen, srcReg);
+ RegionUninit(srcReg);
if (maskReg)
- REGION_UNINIT(pScreen, maskReg);
+ RegionUninit(maskReg);
pDstPix = exaGetDrawablePixmap(pDst->pDrawable);
if (!exaOpReadsDestination(op)) {
@@ -587,7 +587,7 @@ ExaPrepareCompositeReg(ScreenPtr pScreen, int yoff;
exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &xoff, &yoff);
- REGION_TRANSLATE(pScreen, ®ion, pDst->pDrawable->x + xoff,
+ RegionTranslate(®ion, pDst->pDrawable->x + xoff,
pDst->pDrawable->y + yoff);
dstReg = ®ion;
}
@@ -598,7 +598,7 @@ ExaPrepareCompositeReg(ScreenPtr pScreen, dstReg);
pExaScr->prepare_access_reg(pDstPix, EXA_PREPARE_DEST, dstReg);
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
return TRUE;
}
diff --git a/xorg-server/fb/Makefile.am b/xorg-server/fb/Makefile.am index 64e49f345..21ed7b624 100644 --- a/xorg-server/fb/Makefile.am +++ b/xorg-server/fb/Makefile.am @@ -1,56 +1,58 @@ -noinst_LTLIBRARIES = libfb.la libwfb.la - -INCLUDES = \ - -I$(top_srcdir)/hw/xfree86/os-support \ - -I$(top_srcdir)/hw/xfree86/os-support/bus \ - -I$(top_srcdir)/hw/xfree86/common -AM_CFLAGS = $(DIX_CFLAGS) - -if XORG -sdk_HEADERS = fb.h fbrop.h fboverlay.h wfbrename.h fbpict.h -endif - -libfb_la_CFLAGS = $(AM_CFLAGS) - -libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER - -libfb_la_SOURCES = \ - fb.h \ - fb24_32.c \ - fb24_32.h \ - fballpriv.c \ - fbarc.c \ - fbbits.c \ - fbbits.h \ - fbblt.c \ - fbbltone.c \ - fbcopy.c \ - fbfill.c \ - fbfillrect.c \ - fbfillsp.c \ - fbgc.c \ - fbgetsp.c \ - fbglyph.c \ - fbimage.c \ - fbline.c \ - fboverlay.c \ - fboverlay.h \ - fbpict.c \ - fbpict.h \ - fbpixmap.c \ - fbpoint.c \ - fbpush.c \ - fbrop.h \ - fbscreen.c \ - fbseg.c \ - fbsetsp.c \ - fbsolid.c \ - fbstipple.c \ - fbtile.c \ - fbtrap.c \ - fbutil.c \ - fbwindow.c - -libwfb_la_SOURCES = $(libfb_la_SOURCES) - -EXTRA_DIST = fbcmap.c fbcmap_mi.c +noinst_LTLIBRARIES = libfb.la libwfb.la
+
+INCLUDES = \
+ -I$(top_srcdir)/hw/xfree86/os-support \
+ -I$(top_srcdir)/hw/xfree86/os-support/bus \
+ -I$(top_srcdir)/hw/xfree86/common
+AM_CFLAGS = $(DIX_CFLAGS)
+
+if XORG
+sdk_HEADERS = fb.h fbrop.h fboverlay.h wfbrename.h fbpict.h
+endif
+
+libfb_la_CFLAGS = $(AM_CFLAGS)
+libfb_la_LIBADD = $(PIXMAN_LIBS)
+
+libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
+libwfb_la_LIBADD = $(PIXMAN_LIBS)
+
+libfb_la_SOURCES = \
+ fb.h \
+ fb24_32.c \
+ fb24_32.h \
+ fballpriv.c \
+ fbarc.c \
+ fbbits.c \
+ fbbits.h \
+ fbblt.c \
+ fbbltone.c \
+ fbcopy.c \
+ fbfill.c \
+ fbfillrect.c \
+ fbfillsp.c \
+ fbgc.c \
+ fbgetsp.c \
+ fbglyph.c \
+ fbimage.c \
+ fbline.c \
+ fboverlay.c \
+ fboverlay.h \
+ fbpict.c \
+ fbpict.h \
+ fbpixmap.c \
+ fbpoint.c \
+ fbpush.c \
+ fbrop.h \
+ fbscreen.c \
+ fbseg.c \
+ fbsetsp.c \
+ fbsolid.c \
+ fbstipple.c \
+ fbtile.c \
+ fbtrap.c \
+ fbutil.c \
+ fbwindow.c
+
+libwfb_la_SOURCES = $(libfb_la_SOURCES)
+
+EXTRA_DIST = fbcmap.c fbcmap_mi.c
diff --git a/xorg-server/fb/fb.h b/xorg-server/fb/fb.h index 91c91eeb2..b7ac73f95 100644 --- a/xorg-server/fb/fb.h +++ b/xorg-server/fb/fb.h @@ -1,2089 +1,2091 @@ -/* - * - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - - -#ifndef _FB_H_ -#define _FB_H_ - -#include <X11/X.h> -#include <pixman.h> - -#include "scrnintstr.h" -#include "pixmap.h" -#include "pixmapstr.h" -#include "region.h" -#include "gcstruct.h" -#include "colormap.h" -#include "miscstruct.h" -#include "servermd.h" -#include "windowstr.h" -#include "privates.h" -#include "mi.h" -#include "migc.h" -#include "mibstore.h" -#include "picturestr.h" - -#ifdef FB_ACCESS_WRAPPER - -#include "wfbrename.h" -#define FBPREFIX(x) wfb##x -#define WRITE(ptr, val) ((*wfbWriteMemory)((ptr), (val), sizeof(*(ptr)))) -#define READ(ptr) ((*wfbReadMemory)((ptr), sizeof(*(ptr)))) - -#define MEMCPY_WRAPPED(dst, src, size) do { \ - size_t _i; \ - CARD8 *_dst = (CARD8*)(dst), *_src = (CARD8*)(src); \ - for(_i = 0; _i < size; _i++) { \ - WRITE(_dst +_i, READ(_src + _i)); \ - } \ -} while(0) - -#define MEMSET_WRAPPED(dst, val, size) do { \ - size_t _i; \ - CARD8 *_dst = (CARD8*)(dst); \ - for(_i = 0; _i < size; _i++) { \ - WRITE(_dst +_i, (val)); \ - } \ -} while(0) - -#else - -#define FBPREFIX(x) fb##x -#define WRITE(ptr, val) (*(ptr) = (val)) -#define READ(ptr) (*(ptr)) -#define MEMCPY_WRAPPED(dst, src, size) memcpy((dst), (src), (size)) -#define MEMSET_WRAPPED(dst, val, size) memset((dst), (val), (size)) - -#endif - -/* - * This single define controls the basic size of data manipulated - * by this software; it must be log2(sizeof (FbBits) * 8) - */ - -#ifndef FB_SHIFT -#define FB_SHIFT LOG2_BITMAP_PAD -#endif - -#if FB_SHIFT < LOG2_BITMAP_PAD - error FB_SHIFT must be >= LOG2_BITMAP_PAD -#endif - -#define FB_UNIT (1 << FB_SHIFT) -#define FB_HALFUNIT (1 << (FB_SHIFT-1)) -#define FB_MASK (FB_UNIT - 1) -#define FB_ALLONES ((FbBits) -1) - -#if GLYPHPADBYTES != 4 -#error "GLYPHPADBYTES must be 4" -#endif -/* whether to bother to include 24bpp support */ -#ifndef FBNO24BIT -#define FB_24BIT -#endif - -/* - * Unless otherwise instructed, fb includes code to advertise 24bpp - * windows with 32bpp image format for application compatibility - */ - -#ifdef FB_24BIT -#ifndef FBNO24_32 -#define FB_24_32BIT -#endif -#endif - -#define FB_STIP_SHIFT LOG2_BITMAP_PAD -#define FB_STIP_UNIT (1 << FB_STIP_SHIFT) -#define FB_STIP_MASK (FB_STIP_UNIT - 1) -#define FB_STIP_ALLONES ((FbStip) -1) - -#define FB_STIP_ODDSTRIDE(s) (((s) & (FB_MASK >> FB_STIP_SHIFT)) != 0) -#define FB_STIP_ODDPTR(p) ((((long) (p)) & (FB_MASK >> 3)) != 0) - -#define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT))) -#define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT))) - -#define FbFullMask(n) ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1)) - -#if FB_SHIFT == 6 -# ifdef WIN32 -typedef unsigned __int64 FbBits; -# else -# if defined(__alpha__) || defined(__alpha) || \ - defined(ia64) || defined(__ia64__) || \ - defined(__sparc64__) || defined(_LP64) || \ - defined(__s390x__) || \ - defined(amd64) || defined (__amd64__) || \ - defined (__powerpc64__) -typedef unsigned long FbBits; -# else -typedef unsigned long long FbBits; -# endif -# endif -#endif - -#if FB_SHIFT == 5 -typedef CARD32 FbBits; -#endif - -#if FB_SHIFT == 4 -typedef CARD16 FbBits; -#endif - -#if LOG2_BITMAP_PAD == FB_SHIFT -typedef FbBits FbStip; -#else -# if LOG2_BITMAP_PAD == 5 -typedef CARD32 FbStip; -# endif -#endif - -typedef int FbStride; - - -#ifdef FB_DEBUG -extern _X_EXPORT void fbValidateDrawable(DrawablePtr d); -extern _X_EXPORT void fbInitializeDrawable(DrawablePtr d); -extern _X_EXPORT void fbSetBits (FbStip *bits, int stride, FbStip data); -#define FB_HEAD_BITS (FbStip) (0xbaadf00d) -#define FB_TAIL_BITS (FbStip) (0xbaddf0ad) -#else -#define fbValidateDrawable(d) -#define fdInitializeDrawable(d) -#endif - -#include "fbrop.h" - -#if BITMAP_BIT_ORDER == LSBFirst -#define FbScrLeft(x,n) ((x) >> (n)) -#define FbScrRight(x,n) ((x) << (n)) -/* #define FbLeftBits(x,n) ((x) & ((((FbBits) 1) << (n)) - 1)) */ -#define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1)) -#define FbStipMoveLsb(x,s,n) (FbStipRight (x,(s)-(n))) -#define FbPatternOffsetBits 0 -#else -#define FbScrLeft(x,n) ((x) << (n)) -#define FbScrRight(x,n) ((x) >> (n)) -/* #define FbLeftBits(x,n) ((x) >> (FB_UNIT - (n))) */ -#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n))) -#define FbStipMoveLsb(x,s,n) (x) -#define FbPatternOffsetBits (sizeof (FbBits) - 1) -#endif - -#include "micoord.h" - -#define FbStipLeft(x,n) FbScrLeft(x,n) -#define FbStipRight(x,n) FbScrRight(x,n) - -#define FbRotLeft(x,n) FbScrLeft(x,n) | (n ? FbScrRight(x,FB_UNIT-n) : 0) -#define FbRotRight(x,n) FbScrRight(x,n) | (n ? FbScrLeft(x,FB_UNIT-n) : 0) - -#define FbRotStipLeft(x,n) FbStipLeft(x,n) | (n ? FbStipRight(x,FB_STIP_UNIT-n) : 0) -#define FbRotStipRight(x,n) FbStipRight(x,n) | (n ? FbStipLeft(x,FB_STIP_UNIT-n) : 0) - -#define FbLeftMask(x) ( ((x) & FB_MASK) ? \ - FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0) -#define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \ - FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0) - -#define FbLeftStipMask(x) ( ((x) & FB_STIP_MASK) ? \ - FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0) -#define FbRightStipMask(x) ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \ - FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0) - -#define FbBitsMask(x,w) (FbScrRight(FB_ALLONES,(x) & FB_MASK) & \ - FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK)) - -#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \ - FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK)) - - -#define FbMaskBits(x,w,l,n,r) { \ - n = (w); \ - r = FbRightMask((x)+n); \ - l = FbLeftMask(x); \ - if (l) { \ - n -= FB_UNIT - ((x) & FB_MASK); \ - if (n < 0) { \ - n = 0; \ - l &= r; \ - r = 0; \ - } \ - } \ - n >>= FB_SHIFT; \ -} - -#ifdef FBNOPIXADDR -#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) FbMaskBits(x,w,l,n,r) -#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \ - *dst = FbDoMaskRRop(*dst,and,xor,l); \ -} -#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \ - *dst = FbDoMaskRRop(*dst,and,xor,r); \ -} -#else - -#define FbByteMaskInvalid 0x10 - -#define FbPatternOffset(o,t) ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1))) - -#define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o))) -#define FbSelectPatternPart(xor,o,t) ((xor) >> (FbPatternOffset (o,t) << 3)) -#define FbStorePart(dst,off,t,xor) (WRITE(FbPtrOffset(dst,off,t), \ - FbSelectPart(xor,off,t))) -#ifndef FbSelectPart -#define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t) -#endif - -#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \ - n = (w); \ - lb = 0; \ - rb = 0; \ - r = FbRightMask((x)+n); \ - if (r) { \ - /* compute right byte length */ \ - if ((copy) && (((x) + n) & 7) == 0) { \ - rb = (((x) + n) & FB_MASK) >> 3; \ - } else { \ - rb = FbByteMaskInvalid; \ - } \ - } \ - l = FbLeftMask(x); \ - if (l) { \ - /* compute left byte length */ \ - if ((copy) && ((x) & 7) == 0) { \ - lb = ((x) & FB_MASK) >> 3; \ - } else { \ - lb = FbByteMaskInvalid; \ - } \ - /* subtract out the portion painted by leftMask */ \ - n -= FB_UNIT - ((x) & FB_MASK); \ - if (n < 0) { \ - if (lb != FbByteMaskInvalid) { \ - if (rb == FbByteMaskInvalid) { \ - lb = FbByteMaskInvalid; \ - } else if (rb) { \ - lb |= (rb - lb) << (FB_SHIFT - 3); \ - rb = 0; \ - } \ - } \ - n = 0; \ - l &= r; \ - r = 0; \ - }\ - } \ - n >>= FB_SHIFT; \ -} - -#if FB_SHIFT == 6 -#define FbDoLeftMaskByteRRop6Cases(dst,xor) \ - case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ - break; \ - case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ - break; \ - case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 7): \ - FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \ - break; \ - case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ - break; \ - case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ - break; \ - case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 6): \ - FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \ - break; \ - case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ - break; \ - case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 5): \ - FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \ - break; \ - case (sizeof (FbBits) - 4) | (1 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 4) | (2 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ - break; \ - case (sizeof (FbBits) - 4) | (3 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \ - FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 4): \ - FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \ - break; - -#define FbDoRightMaskByteRRop6Cases(dst,xor) \ - case 4: \ - FbStorePart(dst,0,CARD32,xor); \ - break; \ - case 5: \ - FbStorePart(dst,0,CARD32,xor); \ - FbStorePart(dst,4,CARD8,xor); \ - break; \ - case 6: \ - FbStorePart(dst,0,CARD32,xor); \ - FbStorePart(dst,4,CARD16,xor); \ - break; \ - case 7: \ - FbStorePart(dst,0,CARD32,xor); \ - FbStorePart(dst,4,CARD16,xor); \ - FbStorePart(dst,6,CARD8,xor); \ - break; -#else -#define FbDoLeftMaskByteRRop6Cases(dst,xor) -#define FbDoRightMaskByteRRop6Cases(dst,xor) -#endif - -#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \ - switch (lb) { \ - FbDoLeftMaskByteRRop6Cases(dst,xor) \ - case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 3) | (2 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \ - FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \ - break; \ - case (sizeof (FbBits) - 2) | (1 << (FB_SHIFT - 3)): \ - FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \ - break; \ - case sizeof (FbBits) - 3: \ - FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \ - case sizeof (FbBits) - 2: \ - FbStorePart(dst,sizeof (FbBits) - 2,CARD16,xor); \ - break; \ - case sizeof (FbBits) - 1: \ - FbStorePart(dst,sizeof (FbBits) - 1,CARD8,xor); \ - break; \ - default: \ - WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, l)); \ - break; \ - } \ -} - - -#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \ - switch (rb) { \ - case 1: \ - FbStorePart(dst,0,CARD8,xor); \ - break; \ - case 2: \ - FbStorePart(dst,0,CARD16,xor); \ - break; \ - case 3: \ - FbStorePart(dst,0,CARD16,xor); \ - FbStorePart(dst,2,CARD8,xor); \ - break; \ - FbDoRightMaskByteRRop6Cases(dst,xor) \ - default: \ - WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, r)); \ - } \ -} -#endif - -#define FbMaskStip(x,w,l,n,r) { \ - n = (w); \ - r = FbRightStipMask((x)+n); \ - l = FbLeftStipMask(x); \ - if (l) { \ - n -= FB_STIP_UNIT - ((x) & FB_STIP_MASK); \ - if (n < 0) { \ - n = 0; \ - l &= r; \ - r = 0; \ - } \ - } \ - n >>= FB_STIP_SHIFT; \ -} - -/* - * These macros are used to transparently stipple - * in copy mode; the expected usage is with 'n' constant - * so all of the conditional parts collapse into a minimal - * sequence of partial word writes - * - * 'n' is the bytemask of which bytes to store, 'a' is the address - * of the FbBits base unit, 'o' is the offset within that unit - * - * The term "lane" comes from the hardware term "byte-lane" which - */ - -#define FbLaneCase1(n,a,o) \ - if ((n) == 0x01) { \ - WRITE((CARD8 *) ((a)+FbPatternOffset(o,CARD8)), fgxor); \ - } - -#define FbLaneCase2(n,a,o) \ - if ((n) == 0x03) { \ - WRITE((CARD16 *) ((a)+FbPatternOffset(o,CARD16)), fgxor); \ - } else { \ - FbLaneCase1((n)&1,a,o) \ - FbLaneCase1((n)>>1,a,(o)+1) \ - } - -#define FbLaneCase4(n,a,o) \ - if ((n) == 0x0f) { \ - WRITE((CARD32 *) ((a)+FbPatternOffset(o,CARD32)), fgxor); \ - } else { \ - FbLaneCase2((n)&3,a,o) \ - FbLaneCase2((n)>>2,a,(o)+2) \ - } - -#define FbLaneCase8(n,a,o) \ - if ((n) == 0x0ff) { \ - *(FbBits *) ((a)+(o)) = fgxor; \ - } else { \ - FbLaneCase4((n)&15,a,o) \ - FbLaneCase4((n)>>4,a,(o)+4) \ - } - -#if FB_SHIFT == 6 -#define FbLaneCase(n,a) FbLaneCase8(n,(CARD8 *) (a),0) -#endif - -#if FB_SHIFT == 5 -#define FbLaneCase(n,a) FbLaneCase4(n,(CARD8 *) (a),0) -#endif - -/* Rotate a filled pixel value to the specified alignement */ -#define FbRot24(p,b) (FbScrRight(p,b) | FbScrLeft(p,24-(b))) -#define FbRot24Stip(p,b) (FbStipRight(p,b) | FbStipLeft(p,24-(b))) - -/* step a filled pixel value to the next/previous FB_UNIT alignment */ -#define FbNext24Pix(p) (FbRot24(p,(24-FB_UNIT%24))) -#define FbPrev24Pix(p) (FbRot24(p,FB_UNIT%24)) -#define FbNext24Stip(p) (FbRot24(p,(24-FB_STIP_UNIT%24))) -#define FbPrev24Stip(p) (FbRot24(p,FB_STIP_UNIT%24)) - -/* step a rotation value to the next/previous rotation value */ -#if FB_UNIT == 64 -#define FbNext24Rot(r) ((r) == 16 ? 0 : (r) + 8) -#define FbPrev24Rot(r) ((r) == 0 ? 16 : (r) - 8) - -#if IMAGE_BYTE_ORDER == MSBFirst -#define FbFirst24Rot(x) (((x) + 8) % 24) -#else -#define FbFirst24Rot(x) ((x) % 24) -#endif - -#endif - -#if FB_UNIT == 32 -#define FbNext24Rot(r) ((r) == 0 ? 16 : (r) - 8) -#define FbPrev24Rot(r) ((r) == 16 ? 0 : (r) + 8) - -#if IMAGE_BYTE_ORDER == MSBFirst -#define FbFirst24Rot(x) (((x) + 16) % 24) -#else -#define FbFirst24Rot(x) ((x) % 24) -#endif -#endif - -#define FbNext24RotStip(r) ((r) == 0 ? 16 : (r) - 8) -#define FbPrev24RotStip(r) ((r) == 16 ? 0 : (r) + 8) - -/* Whether 24-bit specific code is needed for this filled pixel value */ -#define FbCheck24Pix(p) ((p) == FbNext24Pix(p)) - -/* Macros for dealing with dashing */ - -#define FbDashDeclare \ - unsigned char *__dash, *__firstDash, *__lastDash - -#define FbDashInit(pGC,pPriv,dashOffset,dashlen,even) { \ - (even) = TRUE; \ - __firstDash = (pGC)->dash; \ - __lastDash = __firstDash + (pGC)->numInDashList; \ - (dashOffset) %= (pPriv)->dashLength; \ - \ - __dash = __firstDash; \ - while ((dashOffset) >= ((dashlen) = *__dash)) \ - { \ - (dashOffset) -= (dashlen); \ - (even) = 1-(even); \ - if (++__dash == __lastDash) \ - __dash = __firstDash; \ - } \ - (dashlen) -= (dashOffset); \ -} - -#define FbDashNext(dashlen) { \ - if (++__dash == __lastDash) \ - __dash = __firstDash; \ - (dashlen) = *__dash; \ -} - -/* as numInDashList is always even, this case can skip a test */ - -#define FbDashNextEven(dashlen) { \ - (dashlen) = *++__dash; \ -} - -#define FbDashNextOdd(dashlen) FbDashNext(dashlen) - -#define FbDashStep(dashlen,even) { \ - if (!--(dashlen)) { \ - FbDashNext(dashlen); \ - (even) = 1-(even); \ - } \ -} - -extern _X_EXPORT DevPrivateKey fbGetGCPrivateKey(void); -extern _X_EXPORT DevPrivateKey fbGetWinPrivateKey(void); -extern _X_EXPORT const GCOps fbGCOps; -extern _X_EXPORT const GCFuncs fbGCFuncs; - -#ifdef FB_24_32BIT -#define FB_SCREEN_PRIVATE -#endif - -/* Framebuffer access wrapper */ -typedef FbBits (*ReadMemoryProcPtr)(const void *src, int size); -typedef void (*WriteMemoryProcPtr)(void *dst, FbBits value, int size); -typedef void (*SetupWrapProcPtr)(ReadMemoryProcPtr *pRead, - WriteMemoryProcPtr *pWrite, - DrawablePtr pDraw); -typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw); - -#ifdef FB_ACCESS_WRAPPER - -#define fbPrepareAccess(pDraw) \ - fbGetScreenPrivate((pDraw)->pScreen)->setupWrap( \ - &wfbReadMemory, \ - &wfbWriteMemory, \ - (pDraw)) -#define fbFinishAccess(pDraw) \ - fbGetScreenPrivate((pDraw)->pScreen)->finishWrap(pDraw) - -#else - -#define fbPrepareAccess(pPix) -#define fbFinishAccess(pDraw) - -#endif - - -#ifdef FB_SCREEN_PRIVATE -extern _X_EXPORT DevPrivateKey fbGetScreenPrivateKey(void); - -/* private field of a screen */ -typedef struct { - unsigned char win32bpp; /* window bpp for 32-bpp images */ - unsigned char pix32bpp; /* pixmap bpp for 32-bpp images */ -#ifdef FB_ACCESS_WRAPPER - SetupWrapProcPtr setupWrap; /* driver hook to set pixmap access wrapping */ - FinishWrapProcPtr finishWrap; /* driver hook to clean up pixmap access wrapping */ -#endif -} FbScreenPrivRec, *FbScreenPrivPtr; - -#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \ - dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey())) -#endif - -/* private field of GC */ -typedef struct { - FbBits and, xor; /* reduced rop values */ - FbBits bgand, bgxor; /* for stipples */ - FbBits fg, bg, pm; /* expanded and filled */ - unsigned int dashLength; /* total of all dash elements */ - unsigned char oneRect; /* clip list is single rectangle */ - unsigned char evenStipple; /* stipple is even */ - unsigned char bpp; /* current drawable bpp */ -} FbGCPrivRec, *FbGCPrivPtr; - -#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\ - dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey())) - -#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip) -#define fbGetExpose(pGC) ((pGC)->fExpose) -#define fbGetFreeCompClip(pGC) ((pGC)->freeCompClip) -#define fbGetRotatedPixmap(pGC) ((pGC)->pRotatedPixmap) - -#define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate) -#define fbGetWindowPixmap(pWin) ((PixmapPtr)\ - dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey())) - -#ifdef ROOTLESS -#define __fbPixDrawableX(pPix) ((pPix)->drawable.x) -#define __fbPixDrawableY(pPix) ((pPix)->drawable.y) -#else -#define __fbPixDrawableX(pPix) 0 -#define __fbPixDrawableY(pPix) 0 -#endif - -#ifdef COMPOSITE -#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x) -#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y) -#else -#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix)) -#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix)) -#endif -#define __fbPixOffXPix(pPix) (__fbPixDrawableX(pPix)) -#define __fbPixOffYPix(pPix) (__fbPixDrawableY(pPix)) - -#define fbGetDrawablePixmap(pDrawable, pixmap, xoff, yoff) { \ - if ((pDrawable)->type != DRAWABLE_PIXMAP) { \ - (pixmap) = fbGetWindowPixmap(pDrawable); \ - (xoff) = __fbPixOffXWin(pixmap); \ - (yoff) = __fbPixOffYWin(pixmap); \ - } else { \ - (pixmap) = (PixmapPtr) (pDrawable); \ - (xoff) = __fbPixOffXPix(pixmap); \ - (yoff) = __fbPixOffYPix(pixmap); \ - } \ - fbPrepareAccess(pDrawable); \ -} - -#define fbGetPixmapBitsData(pixmap, pointer, stride, bpp) { \ - (pointer) = (FbBits *) (pixmap)->devPrivate.ptr; \ - (stride) = ((int) (pixmap)->devKind) / sizeof (FbBits); (void)(stride); \ - (bpp) = (pixmap)->drawable.bitsPerPixel; (void)(bpp); \ -} - -#define fbGetPixmapStipData(pixmap, pointer, stride, bpp) { \ - (pointer) = (FbStip *) (pixmap)->devPrivate.ptr; \ - (stride) = ((int) (pixmap)->devKind) / sizeof (FbStip); (void)(stride); \ - (bpp) = (pixmap)->drawable.bitsPerPixel; (void)(bpp); \ -} - -#define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \ - PixmapPtr _pPix; \ - fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff); \ - fbGetPixmapBitsData(_pPix, pointer, stride, bpp); \ -} - -#define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \ - PixmapPtr _pPix; \ - fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff); \ - fbGetPixmapStipData(_pPix, pointer, stride, bpp); \ -} - -/* - * XFree86 empties the root BorderClip when the VT is inactive, - * here's a macro which uses that to disable GetImage and GetSpans - */ - -#define fbWindowEnabled(pWin) \ - REGION_NOTEMPTY((pWin)->drawable.pScreen, \ - &WindowTable[(pWin)->drawable.pScreen->myNum]->borderClip) - -#define fbDrawableEnabled(pDrawable) \ - ((pDrawable)->type == DRAWABLE_PIXMAP ? \ - TRUE : fbWindowEnabled((WindowPtr) pDrawable)) - -#define FbPowerOfTwo(w) (((w) & ((w) - 1)) == 0) -/* - * Accelerated tiles are power of 2 width <= FB_UNIT - */ -#define FbEvenTile(w) ((w) <= FB_UNIT && FbPowerOfTwo(w)) -/* - * Accelerated stipples are power of 2 width and <= FB_UNIT/dstBpp - * with dstBpp a power of 2 as well - */ -#define FbEvenStip(w,bpp) ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp)) - -/* - * fb24_32.c - */ -extern _X_EXPORT void -fb24_32GetSpans(DrawablePtr pDrawable, - int wMax, - DDXPointPtr ppt, - int *pwidth, - int nspans, - char *pchardstStart); - -extern _X_EXPORT void -fb24_32SetSpans (DrawablePtr pDrawable, - GCPtr pGC, - char *src, - DDXPointPtr ppt, - int *pwidth, - int nspans, - int fSorted); - -extern _X_EXPORT void -fb24_32PutZImage (DrawablePtr pDrawable, - RegionPtr pClip, - int alu, - FbBits pm, - int x, - int y, - int width, - int height, - CARD8 *src, - FbStride srcStride); - -extern _X_EXPORT void -fb24_32GetImage (DrawablePtr pDrawable, - int x, - int y, - int w, - int h, - unsigned int format, - unsigned long planeMask, - char *d); - -extern _X_EXPORT void -fb24_32CopyMtoN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure); - -extern _X_EXPORT PixmapPtr -fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel); - -extern _X_EXPORT Bool -fb24_32CreateScreenResources(ScreenPtr pScreen); - -extern _X_EXPORT Bool -fb24_32ModifyPixmapHeader (PixmapPtr pPixmap, - int width, - int height, - int depth, - int bitsPerPixel, - int devKind, - pointer pPixData); - -/* - * fballpriv.c - */ -extern _X_EXPORT DevPrivateKey fbGetWinPrivateKey(void); - -extern _X_EXPORT Bool -fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex); - -/* - * fbarc.c - */ - -extern _X_EXPORT void -fbPolyArc (DrawablePtr pDrawable, - GCPtr pGC, - int narcs, - xArc *parcs); - -/* - * fbbits.c - */ - -extern _X_EXPORT void -fbBresSolid8(DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x, - int y, - int e, - int e1, - int e3, - int len); - -extern _X_EXPORT void -fbBresDash8 (DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x, - int y, - int e, - int e1, - int e3, - int len); - -extern _X_EXPORT void -fbDots8 (FbBits *dst, - FbStride dstStride, - int dstBpp, - BoxPtr pBox, - xPoint *pts, - int npt, - int xorg, - int yorg, - int xoff, - int yoff, - FbBits and, - FbBits xor); - -extern _X_EXPORT void -fbArc8 (FbBits *dst, - FbStride dstStride, - int dstBpp, - xArc *arc, - int dx, - int dy, - FbBits and, - FbBits xor); - -extern _X_EXPORT void -fbGlyph8 (FbBits *dstLine, - FbStride dstStride, - int dstBpp, - FbStip *stipple, - FbBits fg, - int height, - int shift); - -extern _X_EXPORT void -fbPolyline8 (DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr ptsOrig); - -extern _X_EXPORT void -fbPolySegment8 (DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pseg); - -extern _X_EXPORT void -fbBresSolid16(DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x, - int y, - int e, - int e1, - int e3, - int len); - -extern _X_EXPORT void -fbBresDash16(DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x, - int y, - int e, - int e1, - int e3, - int len); - -extern _X_EXPORT void -fbDots16(FbBits *dst, - FbStride dstStride, - int dstBpp, - BoxPtr pBox, - xPoint *pts, - int npt, - int xorg, - int yorg, - int xoff, - int yoff, - FbBits and, - FbBits xor); - -extern _X_EXPORT void -fbArc16(FbBits *dst, - FbStride dstStride, - int dstBpp, - xArc *arc, - int dx, - int dy, - FbBits and, - FbBits xor); - -extern _X_EXPORT void -fbGlyph16(FbBits *dstLine, - FbStride dstStride, - int dstBpp, - FbStip *stipple, - FbBits fg, - int height, - int shift); - -extern _X_EXPORT void -fbPolyline16 (DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr ptsOrig); - -extern _X_EXPORT void -fbPolySegment16 (DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pseg); - - -extern _X_EXPORT void -fbBresSolid24(DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x, - int y, - int e, - int e1, - int e3, - int len); - -extern _X_EXPORT void -fbBresDash24(DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x, - int y, - int e, - int e1, - int e3, - int len); - -extern _X_EXPORT void -fbDots24(FbBits *dst, - FbStride dstStride, - int dstBpp, - BoxPtr pBox, - xPoint *pts, - int npt, - int xorg, - int yorg, - int xoff, - int yoff, - FbBits and, - FbBits xor); - -extern _X_EXPORT void -fbArc24(FbBits *dst, - FbStride dstStride, - int dstBpp, - xArc *arc, - int dx, - int dy, - FbBits and, - FbBits xor); - -extern _X_EXPORT void -fbGlyph24(FbBits *dstLine, - FbStride dstStride, - int dstBpp, - FbStip *stipple, - FbBits fg, - int height, - int shift); - -extern _X_EXPORT void -fbPolyline24 (DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr ptsOrig); - -extern _X_EXPORT void -fbPolySegment24 (DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pseg); - - -extern _X_EXPORT void -fbBresSolid32(DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x, - int y, - int e, - int e1, - int e3, - int len); - -extern _X_EXPORT void -fbBresDash32(DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x, - int y, - int e, - int e1, - int e3, - int len); - -extern _X_EXPORT void -fbDots32(FbBits *dst, - FbStride dstStride, - int dstBpp, - BoxPtr pBox, - xPoint *pts, - int npt, - int xorg, - int yorg, - int xoff, - int yoff, - FbBits and, - FbBits xor); - -extern _X_EXPORT void -fbArc32(FbBits *dst, - FbStride dstStride, - int dstBpp, - xArc *arc, - int dx, - int dy, - FbBits and, - FbBits xor); - -extern _X_EXPORT void -fbGlyph32(FbBits *dstLine, - FbStride dstStride, - int dstBpp, - FbStip *stipple, - FbBits fg, - int height, - int shift); -extern _X_EXPORT void -fbPolyline32 (DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr ptsOrig); - -extern _X_EXPORT void -fbPolySegment32 (DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pseg); - -/* - * fbblt.c - */ -extern _X_EXPORT void -fbBlt (FbBits *src, - FbStride srcStride, - int srcX, - - FbBits *dst, - FbStride dstStride, - int dstX, - - int width, - int height, - - int alu, - FbBits pm, - int bpp, - - Bool reverse, - Bool upsidedown); - -extern _X_EXPORT void -fbBlt24 (FbBits *srcLine, - FbStride srcStride, - int srcX, - - FbBits *dstLine, - FbStride dstStride, - int dstX, - - int width, - int height, - - int alu, - FbBits pm, - - Bool reverse, - Bool upsidedown); - -extern _X_EXPORT void -fbBltStip (FbStip *src, - FbStride srcStride, /* in FbStip units, not FbBits units */ - int srcX, - - FbStip *dst, - FbStride dstStride, /* in FbStip units, not FbBits units */ - int dstX, - - int width, - int height, - - int alu, - FbBits pm, - int bpp); - -/* - * fbbltone.c - */ -extern _X_EXPORT void -fbBltOne (FbStip *src, - FbStride srcStride, - int srcX, - FbBits *dst, - FbStride dstStride, - int dstX, - int dstBpp, - - int width, - int height, - - FbBits fgand, - FbBits fbxor, - FbBits bgand, - FbBits bgxor); - -#ifdef FB_24BIT -extern _X_EXPORT void -fbBltOne24 (FbStip *src, - FbStride srcStride, /* FbStip units per scanline */ - int srcX, /* bit position of source */ - FbBits *dst, - FbStride dstStride, /* FbBits units per scanline */ - int dstX, /* bit position of dest */ - int dstBpp, /* bits per destination unit */ - - int width, /* width in bits of destination */ - int height, /* height in scanlines */ - - FbBits fgand, /* rrop values */ - FbBits fgxor, - FbBits bgand, - FbBits bgxor); -#endif - -extern _X_EXPORT void -fbBltPlane (FbBits *src, - FbStride srcStride, - int srcX, - int srcBpp, - - FbStip *dst, - FbStride dstStride, - int dstX, - - int width, - int height, - - FbStip fgand, - FbStip fgxor, - FbStip bgand, - FbStip bgxor, - Pixel planeMask); - -/* - * fbcmap.c - */ -extern _X_EXPORT int -fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps); - -extern _X_EXPORT void -fbInstallColormap(ColormapPtr pmap); - -extern _X_EXPORT void -fbUninstallColormap(ColormapPtr pmap); - -extern _X_EXPORT void -fbResolveColor(unsigned short *pred, - unsigned short *pgreen, - unsigned short *pblue, - VisualPtr pVisual); - -extern _X_EXPORT Bool -fbInitializeColormap(ColormapPtr pmap); - -extern _X_EXPORT int -fbExpandDirectColors (ColormapPtr pmap, - int ndef, - xColorItem *indefs, - xColorItem *outdefs); - -extern _X_EXPORT Bool -fbCreateDefColormap(ScreenPtr pScreen); - -extern _X_EXPORT void -fbClearVisualTypes(void); - -extern _X_EXPORT Bool -fbHasVisualTypes (int depth); - -extern _X_EXPORT Bool -fbSetVisualTypes (int depth, int visuals, int bitsPerRGB); - -extern _X_EXPORT Bool -fbSetVisualTypesAndMasks (int depth, int visuals, int bitsPerRGB, - Pixel redMask, Pixel greenMask, Pixel blueMask); - -extern _X_EXPORT Bool -fbInitVisuals (VisualPtr *visualp, - DepthPtr *depthp, - int *nvisualp, - int *ndepthp, - int *rootDepthp, - VisualID *defaultVisp, - unsigned long sizes, - int bitsPerRGB); - -/* - * fbcopy.c - */ - -/* Compatibility definition, to be removed at next ABI change. */ -typedef void (*fbCopyProc) (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pDstBox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure); - -extern _X_EXPORT void -fbCopyNtoN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure); - -/* Compatibility wrapper, to be removed at next ABI change. */ -extern _X_EXPORT void -fbCopyRegion (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - RegionPtr pDstRegion, - int dx, - int dy, - fbCopyProc copyProc, - Pixel bitPlane, - void *closure); - -/* Compatibility wrapper, to be removed at next ABI change. */ -extern _X_EXPORT RegionPtr -fbDoCopy (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - int xIn, - int yIn, - int widthSrc, - int heightSrc, - int xOut, - int yOut, - fbCopyProc copyProc, - Pixel bitplane, - void *closure); - -extern _X_EXPORT void -fbCopy1toN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure); - -extern _X_EXPORT void -fbCopyNto1 (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure); - -extern _X_EXPORT RegionPtr -fbCopyArea (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - int xIn, - int yIn, - int widthSrc, - int heightSrc, - int xOut, - int yOut); - -extern _X_EXPORT RegionPtr -fbCopyPlane (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - int xIn, - int yIn, - int widthSrc, - int heightSrc, - int xOut, - int yOut, - unsigned long bitplane); - -/* - * fbfill.c - */ -extern _X_EXPORT void -fbFill (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int width, - int height); - -extern _X_EXPORT void -fbSolidBoxClipped (DrawablePtr pDrawable, - RegionPtr pClip, - int xa, - int ya, - int xb, - int yb, - FbBits and, - FbBits xor); - -/* - * fbfillrect.c - */ -extern _X_EXPORT void -fbPolyFillRect(DrawablePtr pDrawable, - GCPtr pGC, - int nrectInit, - xRectangle *prectInit); - -#define fbPolyFillArc miPolyFillArc - -#define fbFillPolygon miFillPolygon - -/* - * fbfillsp.c - */ -extern _X_EXPORT void -fbFillSpans (DrawablePtr pDrawable, - GCPtr pGC, - int nInit, - DDXPointPtr pptInit, - int *pwidthInit, - int fSorted); - - -/* - * fbgc.c - */ - -extern _X_EXPORT Bool -fbCreateGC(GCPtr pGC); - -extern _X_EXPORT void -fbPadPixmap (PixmapPtr pPixmap); - -extern _X_EXPORT void -fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable); - -/* - * fbgetsp.c - */ -extern _X_EXPORT void -fbGetSpans(DrawablePtr pDrawable, - int wMax, - DDXPointPtr ppt, - int *pwidth, - int nspans, - char *pchardstStart); - -/* - * fbglyph.c - */ - -extern _X_EXPORT Bool -fbGlyphIn (RegionPtr pRegion, - int x, - int y, - int width, - int height); - -extern _X_EXPORT void -fbPolyGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppci, - pointer pglyphBase); - -extern _X_EXPORT void -fbImageGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppci, - pointer pglyphBase); - -/* - * fbimage.c - */ - -extern _X_EXPORT void -fbPutImage (DrawablePtr pDrawable, - GCPtr pGC, - int depth, - int x, - int y, - int w, - int h, - int leftPad, - int format, - char *pImage); - -extern _X_EXPORT void -fbPutZImage (DrawablePtr pDrawable, - RegionPtr pClip, - int alu, - FbBits pm, - int x, - int y, - int width, - int height, - FbStip *src, - FbStride srcStride); - -extern _X_EXPORT void -fbPutXYImage (DrawablePtr pDrawable, - RegionPtr pClip, - FbBits fg, - FbBits bg, - FbBits pm, - int alu, - Bool opaque, - - int x, - int y, - int width, - int height, - - FbStip *src, - FbStride srcStride, - int srcX); - -extern _X_EXPORT void -fbGetImage (DrawablePtr pDrawable, - int x, - int y, - int w, - int h, - unsigned int format, - unsigned long planeMask, - char *d); -/* - * fbline.c - */ - -extern _X_EXPORT void -fbZeroLine (DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr ppt); - -extern _X_EXPORT void -fbZeroSegment (DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pSegs); - -extern _X_EXPORT void -fbPolyLine (DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr ppt); - -extern _X_EXPORT void -fbFixCoordModePrevious (int npt, - DDXPointPtr ppt); - -extern _X_EXPORT void -fbPolySegment (DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pseg); - -#define fbPolyRectangle miPolyRectangle - -/* - * fbpict.c - */ - -extern _X_EXPORT Bool -fbPictureInit (ScreenPtr pScreen, - PictFormatPtr formats, - int nformats); - -/* - * fbpixmap.c - */ - -extern _X_EXPORT PixmapPtr -fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp, - unsigned usage_hint); - -extern _X_EXPORT PixmapPtr -fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth, - unsigned usage_hint); - -extern _X_EXPORT Bool -fbDestroyPixmap (PixmapPtr pPixmap); - -extern _X_EXPORT RegionPtr -fbPixmapToRegion(PixmapPtr pPix); - -/* - * fbpoint.c - */ - -extern _X_EXPORT void -fbDots (FbBits *dstOrig, - FbStride dstStride, - int dstBpp, - BoxPtr pBox, - xPoint *pts, - int npt, - int xorg, - int yorg, - int xoff, - int yoff, - FbBits andOrig, - FbBits xorOrig); - -extern _X_EXPORT void -fbPolyPoint (DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - xPoint *pptInit); - -/* - * fbpush.c - */ -extern _X_EXPORT void -fbPushPattern (DrawablePtr pDrawable, - GCPtr pGC, - - FbStip *src, - FbStride srcStride, - int srcX, - - int x, - int y, - - int width, - int height); - -extern _X_EXPORT void -fbPushFill (DrawablePtr pDrawable, - GCPtr pGC, - - FbStip *src, - FbStride srcStride, - int srcX, - - int x, - int y, - int width, - int height); - -extern _X_EXPORT void -fbPushImage (DrawablePtr pDrawable, - GCPtr pGC, - - FbStip *src, - FbStride srcStride, - int srcX, - - int x, - int y, - int width, - int height); - -extern _X_EXPORT void -fbPushPixels (GCPtr pGC, - PixmapPtr pBitmap, - DrawablePtr pDrawable, - int dx, - int dy, - int xOrg, - int yOrg); - - -/* - * fbscreen.c - */ - -extern _X_EXPORT Bool -fbCloseScreen (int indx, ScreenPtr pScreen); - -extern _X_EXPORT Bool -fbRealizeFont(ScreenPtr pScreen, FontPtr pFont); - -extern _X_EXPORT Bool -fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont); - -extern _X_EXPORT void -fbQueryBestSize (int class, - unsigned short *width, unsigned short *height, - ScreenPtr pScreen); - -extern _X_EXPORT PixmapPtr -_fbGetWindowPixmap (WindowPtr pWindow); - -extern _X_EXPORT void -_fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap); - -extern _X_EXPORT Bool -fbSetupScreen(ScreenPtr pScreen, - pointer pbits, /* pointer to screen bitmap */ - int xsize, /* in pixels */ - int ysize, - int dpix, /* dots per inch */ - int dpiy, - int width, /* pixel width of frame buffer */ - int bpp); /* bits per pixel of frame buffer */ - -extern _X_EXPORT Bool -wfbFinishScreenInit(ScreenPtr pScreen, - pointer pbits, - int xsize, - int ysize, - int dpix, - int dpiy, - int width, - int bpp, - SetupWrapProcPtr setupWrap, - FinishWrapProcPtr finishWrap); - -extern _X_EXPORT Bool -wfbScreenInit(ScreenPtr pScreen, - pointer pbits, - int xsize, - int ysize, - int dpix, - int dpiy, - int width, - int bpp, - SetupWrapProcPtr setupWrap, - FinishWrapProcPtr finishWrap); - -extern _X_EXPORT Bool -fbFinishScreenInit(ScreenPtr pScreen, - pointer pbits, - int xsize, - int ysize, - int dpix, - int dpiy, - int width, - int bpp); - -extern _X_EXPORT Bool -fbScreenInit(ScreenPtr pScreen, - pointer pbits, - int xsize, - int ysize, - int dpix, - int dpiy, - int width, - int bpp); - -/* - * fbseg.c - */ -typedef void FbBres (DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x, - int y, - int e, - int e1, - int e3, - int len); - -extern _X_EXPORT FbBres fbBresSolid, fbBresDash, fbBresFill, fbBresFillDash; -/* - * fbsetsp.c - */ - -extern _X_EXPORT void -fbSetSpans (DrawablePtr pDrawable, - GCPtr pGC, - char *src, - DDXPointPtr ppt, - int *pwidth, - int nspans, - int fSorted); - -extern _X_EXPORT FbBres * -fbSelectBres (DrawablePtr pDrawable, - GCPtr pGC); - -extern _X_EXPORT void -fbBres (DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x, - int y, - int e, - int e1, - int e3, - int len); - -extern _X_EXPORT void -fbSegment (DrawablePtr pDrawable, - GCPtr pGC, - int xa, - int ya, - int xb, - int yb, - Bool drawLast, - int *dashOffset); - - -/* - * fbsolid.c - */ - -extern _X_EXPORT void -fbSolid (FbBits *dst, - FbStride dstStride, - int dstX, - int bpp, - - int width, - int height, - - FbBits and, - FbBits xor); - -#ifdef FB_24BIT -extern _X_EXPORT void -fbSolid24 (FbBits *dst, - FbStride dstStride, - int dstX, - - int width, - int height, - - FbBits and, - FbBits xor); -#endif - -/* - * fbstipple.c - */ - -extern _X_EXPORT void -fbTransparentSpan (FbBits *dst, - FbBits stip, - FbBits fgxor, - int n); - -extern _X_EXPORT void -fbEvenStipple (FbBits *dst, - FbStride dstStride, - int dstX, - int dstBpp, - - int width, - int height, - - FbStip *stip, - FbStride stipStride, - int stipHeight, - - FbBits fgand, - FbBits fgxor, - FbBits bgand, - FbBits bgxor, - - int xRot, - int yRot); - -extern _X_EXPORT void -fbOddStipple (FbBits *dst, - FbStride dstStride, - int dstX, - int dstBpp, - - int width, - int height, - - FbStip *stip, - FbStride stipStride, - int stipWidth, - int stipHeight, - - FbBits fgand, - FbBits fgxor, - FbBits bgand, - FbBits bgxor, - - int xRot, - int yRot); - -extern _X_EXPORT void -fbStipple (FbBits *dst, - FbStride dstStride, - int dstX, - int dstBpp, - - int width, - int height, - - FbStip *stip, - FbStride stipStride, - int stipWidth, - int stipHeight, - Bool even, - - FbBits fgand, - FbBits fgxor, - FbBits bgand, - FbBits bgxor, - - int xRot, - int yRot); - -/* - * fbtile.c - */ - -extern _X_EXPORT void -fbEvenTile (FbBits *dst, - FbStride dstStride, - int dstX, - - int width, - int height, - - FbBits *tile, - FbStride tileStride, - int tileHeight, - - int alu, - FbBits pm, - int xRot, - int yRot); - -extern _X_EXPORT void -fbOddTile (FbBits *dst, - FbStride dstStride, - int dstX, - - int width, - int height, - - FbBits *tile, - FbStride tileStride, - int tileWidth, - int tileHeight, - - int alu, - FbBits pm, - int bpp, - - int xRot, - int yRot); - -extern _X_EXPORT void -fbTile (FbBits *dst, - FbStride dstStride, - int dstX, - - int width, - int height, - - FbBits *tile, - FbStride tileStride, - int tileWidth, - int tileHeight, - - int alu, - FbBits pm, - int bpp, - - int xRot, - int yRot); - -/* - * fbutil.c - */ -extern _X_EXPORT FbBits -fbReplicatePixel (Pixel p, int bpp); - -extern _X_EXPORT void -fbReduceRasterOp (int rop, FbBits fg, FbBits pm, FbBits *andp, FbBits *xorp); - -#ifdef FB_ACCESS_WRAPPER -extern _X_EXPORT ReadMemoryProcPtr wfbReadMemory; -extern _X_EXPORT WriteMemoryProcPtr wfbWriteMemory; -#endif - -/* - * fbwindow.c - */ - -extern _X_EXPORT Bool -fbCreateWindow(WindowPtr pWin); - -extern _X_EXPORT Bool -fbDestroyWindow(WindowPtr pWin); - -extern _X_EXPORT Bool -fbMapWindow(WindowPtr pWindow); - -extern _X_EXPORT Bool -fbPositionWindow(WindowPtr pWin, int x, int y); - -extern _X_EXPORT Bool -fbUnmapWindow(WindowPtr pWindow); - -extern _X_EXPORT void -fbCopyWindowProc (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure); - -extern _X_EXPORT void -fbCopyWindow(WindowPtr pWin, - DDXPointRec ptOldOrg, - RegionPtr prgnSrc); - -extern _X_EXPORT Bool -fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask); - -extern _X_EXPORT void -fbFillRegionSolid (DrawablePtr pDrawable, - RegionPtr pRegion, - FbBits and, - FbBits xor); - -extern _X_EXPORT pixman_image_t * -image_from_pict (PicturePtr pict, - Bool has_clip, - int *xoff, - int *yoff); - -extern _X_EXPORT void free_pixman_pict (PicturePtr, pixman_image_t *); - -#endif /* _FB_H_ */ - +/*
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#ifndef _FB_H_
+#define _FB_H_
+
+#include <X11/X.h>
+#include <pixman.h>
+
+#include "scrnintstr.h"
+#include "pixmap.h"
+#include "pixmapstr.h"
+#include "region.h"
+#include "gcstruct.h"
+#include "colormap.h"
+#include "miscstruct.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "privates.h"
+#include "mi.h"
+#include "migc.h"
+#include "mibstore.h"
+#include "picturestr.h"
+
+#ifdef FB_ACCESS_WRAPPER
+
+#include "wfbrename.h"
+#define FBPREFIX(x) wfb##x
+#define WRITE(ptr, val) ((*wfbWriteMemory)((ptr), (val), sizeof(*(ptr))))
+#define READ(ptr) ((*wfbReadMemory)((ptr), sizeof(*(ptr))))
+
+#define MEMCPY_WRAPPED(dst, src, size) do { \
+ size_t _i; \
+ CARD8 *_dst = (CARD8*)(dst), *_src = (CARD8*)(src); \
+ for(_i = 0; _i < size; _i++) { \
+ WRITE(_dst +_i, READ(_src + _i)); \
+ } \
+} while(0)
+
+#define MEMSET_WRAPPED(dst, val, size) do { \
+ size_t _i; \
+ CARD8 *_dst = (CARD8*)(dst); \
+ for(_i = 0; _i < size; _i++) { \
+ WRITE(_dst +_i, (val)); \
+ } \
+} while(0)
+
+#else
+
+#define FBPREFIX(x) fb##x
+#define WRITE(ptr, val) (*(ptr) = (val))
+#define READ(ptr) (*(ptr))
+#define MEMCPY_WRAPPED(dst, src, size) memcpy((dst), (src), (size))
+#define MEMSET_WRAPPED(dst, val, size) memset((dst), (val), (size))
+
+#endif
+
+/*
+ * This single define controls the basic size of data manipulated
+ * by this software; it must be log2(sizeof (FbBits) * 8)
+ */
+
+#ifndef FB_SHIFT
+#define FB_SHIFT LOG2_BITMAP_PAD
+#endif
+
+#if FB_SHIFT < LOG2_BITMAP_PAD
+ error FB_SHIFT must be >= LOG2_BITMAP_PAD
+#endif
+
+#define FB_UNIT (1 << FB_SHIFT)
+#define FB_HALFUNIT (1 << (FB_SHIFT-1))
+#define FB_MASK (FB_UNIT - 1)
+#define FB_ALLONES ((FbBits) -1)
+
+#if GLYPHPADBYTES != 4
+#error "GLYPHPADBYTES must be 4"
+#endif
+/* whether to bother to include 24bpp support */
+#ifndef FBNO24BIT
+#define FB_24BIT
+#endif
+
+/*
+ * Unless otherwise instructed, fb includes code to advertise 24bpp
+ * windows with 32bpp image format for application compatibility
+ */
+
+#ifdef FB_24BIT
+#ifndef FBNO24_32
+#define FB_24_32BIT
+#endif
+#endif
+
+#define FB_STIP_SHIFT LOG2_BITMAP_PAD
+#define FB_STIP_UNIT (1 << FB_STIP_SHIFT)
+#define FB_STIP_MASK (FB_STIP_UNIT - 1)
+#define FB_STIP_ALLONES ((FbStip) -1)
+
+#define FB_STIP_ODDSTRIDE(s) (((s) & (FB_MASK >> FB_STIP_SHIFT)) != 0)
+#define FB_STIP_ODDPTR(p) ((((long) (p)) & (FB_MASK >> 3)) != 0)
+
+#define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))
+#define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))
+
+#define FbFullMask(n) ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))
+
+#if FB_SHIFT == 6
+# ifdef WIN32
+typedef unsigned __int64 FbBits;
+# else
+# if defined(__alpha__) || defined(__alpha) || \
+ defined(ia64) || defined(__ia64__) || \
+ defined(__sparc64__) || defined(_LP64) || \
+ defined(__s390x__) || \
+ defined(amd64) || defined (__amd64__) || \
+ defined (__powerpc64__)
+typedef unsigned long FbBits;
+# else
+typedef unsigned long long FbBits;
+# endif
+# endif
+#endif
+
+#if FB_SHIFT == 5
+typedef CARD32 FbBits;
+#endif
+
+#if FB_SHIFT == 4
+typedef CARD16 FbBits;
+#endif
+
+#if LOG2_BITMAP_PAD == FB_SHIFT
+typedef FbBits FbStip;
+#else
+# if LOG2_BITMAP_PAD == 5
+typedef CARD32 FbStip;
+# endif
+#endif
+
+typedef int FbStride;
+
+
+#ifdef FB_DEBUG
+extern _X_EXPORT void fbValidateDrawable(DrawablePtr d);
+extern _X_EXPORT void fbInitializeDrawable(DrawablePtr d);
+extern _X_EXPORT void fbSetBits (FbStip *bits, int stride, FbStip data);
+#define FB_HEAD_BITS (FbStip) (0xbaadf00d)
+#define FB_TAIL_BITS (FbStip) (0xbaddf0ad)
+#else
+#define fbValidateDrawable(d)
+#define fdInitializeDrawable(d)
+#endif
+
+#include "fbrop.h"
+
+#if BITMAP_BIT_ORDER == LSBFirst
+#define FbScrLeft(x,n) ((x) >> (n))
+#define FbScrRight(x,n) ((x) << (n))
+/* #define FbLeftBits(x,n) ((x) & ((((FbBits) 1) << (n)) - 1)) */
+#define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1))
+#define FbStipMoveLsb(x,s,n) (FbStipRight (x,(s)-(n)))
+#define FbPatternOffsetBits 0
+#else
+#define FbScrLeft(x,n) ((x) << (n))
+#define FbScrRight(x,n) ((x) >> (n))
+/* #define FbLeftBits(x,n) ((x) >> (FB_UNIT - (n))) */
+#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
+#define FbStipMoveLsb(x,s,n) (x)
+#define FbPatternOffsetBits (sizeof (FbBits) - 1)
+#endif
+
+#include "micoord.h"
+
+#define FbStipLeft(x,n) FbScrLeft(x,n)
+#define FbStipRight(x,n) FbScrRight(x,n)
+
+#define FbRotLeft(x,n) FbScrLeft(x,n) | (n ? FbScrRight(x,FB_UNIT-n) : 0)
+#define FbRotRight(x,n) FbScrRight(x,n) | (n ? FbScrLeft(x,FB_UNIT-n) : 0)
+
+#define FbRotStipLeft(x,n) FbStipLeft(x,n) | (n ? FbStipRight(x,FB_STIP_UNIT-n) : 0)
+#define FbRotStipRight(x,n) FbStipRight(x,n) | (n ? FbStipLeft(x,FB_STIP_UNIT-n) : 0)
+
+#define FbLeftMask(x) ( ((x) & FB_MASK) ? \
+ FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
+#define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \
+ FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
+
+#define FbLeftStipMask(x) ( ((x) & FB_STIP_MASK) ? \
+ FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0)
+#define FbRightStipMask(x) ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \
+ FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0)
+
+#define FbBitsMask(x,w) (FbScrRight(FB_ALLONES,(x) & FB_MASK) & \
+ FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK))
+
+#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \
+ FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))
+
+
+#define FbMaskBits(x,w,l,n,r) { \
+ n = (w); \
+ r = FbRightMask((x)+n); \
+ l = FbLeftMask(x); \
+ if (l) { \
+ n -= FB_UNIT - ((x) & FB_MASK); \
+ if (n < 0) { \
+ n = 0; \
+ l &= r; \
+ r = 0; \
+ } \
+ } \
+ n >>= FB_SHIFT; \
+}
+
+#ifdef FBNOPIXADDR
+#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) FbMaskBits(x,w,l,n,r)
+#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
+ *dst = FbDoMaskRRop(*dst,and,xor,l); \
+}
+#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
+ *dst = FbDoMaskRRop(*dst,and,xor,r); \
+}
+#else
+
+#define FbByteMaskInvalid 0x10
+
+#define FbPatternOffset(o,t) ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1)))
+
+#define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o)))
+#define FbSelectPatternPart(xor,o,t) ((xor) >> (FbPatternOffset (o,t) << 3))
+#define FbStorePart(dst,off,t,xor) (WRITE(FbPtrOffset(dst,off,t), \
+ FbSelectPart(xor,off,t)))
+#ifndef FbSelectPart
+#define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t)
+#endif
+
+#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \
+ n = (w); \
+ lb = 0; \
+ rb = 0; \
+ r = FbRightMask((x)+n); \
+ if (r) { \
+ /* compute right byte length */ \
+ if ((copy) && (((x) + n) & 7) == 0) { \
+ rb = (((x) + n) & FB_MASK) >> 3; \
+ } else { \
+ rb = FbByteMaskInvalid; \
+ } \
+ } \
+ l = FbLeftMask(x); \
+ if (l) { \
+ /* compute left byte length */ \
+ if ((copy) && ((x) & 7) == 0) { \
+ lb = ((x) & FB_MASK) >> 3; \
+ } else { \
+ lb = FbByteMaskInvalid; \
+ } \
+ /* subtract out the portion painted by leftMask */ \
+ n -= FB_UNIT - ((x) & FB_MASK); \
+ if (n < 0) { \
+ if (lb != FbByteMaskInvalid) { \
+ if (rb == FbByteMaskInvalid) { \
+ lb = FbByteMaskInvalid; \
+ } else if (rb) { \
+ lb |= (rb - lb) << (FB_SHIFT - 3); \
+ rb = 0; \
+ } \
+ } \
+ n = 0; \
+ l &= r; \
+ r = 0; \
+ }\
+ } \
+ n >>= FB_SHIFT; \
+}
+
+#if FB_SHIFT == 6
+#define FbDoLeftMaskByteRRop6Cases(dst,xor) \
+ case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 6): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 5): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break; \
+ case (sizeof (FbBits) - 4) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 4) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 4) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 4): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break;
+
+#define FbDoRightMaskByteRRop6Cases(dst,xor) \
+ case 4: \
+ FbStorePart(dst,0,CARD32,xor); \
+ break; \
+ case 5: \
+ FbStorePart(dst,0,CARD32,xor); \
+ FbStorePart(dst,4,CARD8,xor); \
+ break; \
+ case 6: \
+ FbStorePart(dst,0,CARD32,xor); \
+ FbStorePart(dst,4,CARD16,xor); \
+ break; \
+ case 7: \
+ FbStorePart(dst,0,CARD32,xor); \
+ FbStorePart(dst,4,CARD16,xor); \
+ FbStorePart(dst,6,CARD8,xor); \
+ break;
+#else
+#define FbDoLeftMaskByteRRop6Cases(dst,xor)
+#define FbDoRightMaskByteRRop6Cases(dst,xor)
+#endif
+
+#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
+ switch (lb) { \
+ FbDoLeftMaskByteRRop6Cases(dst,xor) \
+ case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 3) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 2) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case sizeof (FbBits) - 3: \
+ FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
+ case sizeof (FbBits) - 2: \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD16,xor); \
+ break; \
+ case sizeof (FbBits) - 1: \
+ FbStorePart(dst,sizeof (FbBits) - 1,CARD8,xor); \
+ break; \
+ default: \
+ WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, l)); \
+ break; \
+ } \
+}
+
+
+#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
+ switch (rb) { \
+ case 1: \
+ FbStorePart(dst,0,CARD8,xor); \
+ break; \
+ case 2: \
+ FbStorePart(dst,0,CARD16,xor); \
+ break; \
+ case 3: \
+ FbStorePart(dst,0,CARD16,xor); \
+ FbStorePart(dst,2,CARD8,xor); \
+ break; \
+ FbDoRightMaskByteRRop6Cases(dst,xor) \
+ default: \
+ WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, r)); \
+ } \
+}
+#endif
+
+#define FbMaskStip(x,w,l,n,r) { \
+ n = (w); \
+ r = FbRightStipMask((x)+n); \
+ l = FbLeftStipMask(x); \
+ if (l) { \
+ n -= FB_STIP_UNIT - ((x) & FB_STIP_MASK); \
+ if (n < 0) { \
+ n = 0; \
+ l &= r; \
+ r = 0; \
+ } \
+ } \
+ n >>= FB_STIP_SHIFT; \
+}
+
+/*
+ * These macros are used to transparently stipple
+ * in copy mode; the expected usage is with 'n' constant
+ * so all of the conditional parts collapse into a minimal
+ * sequence of partial word writes
+ *
+ * 'n' is the bytemask of which bytes to store, 'a' is the address
+ * of the FbBits base unit, 'o' is the offset within that unit
+ *
+ * The term "lane" comes from the hardware term "byte-lane" which
+ */
+
+#define FbLaneCase1(n,a,o) \
+ if ((n) == 0x01) { \
+ WRITE((CARD8 *) ((a)+FbPatternOffset(o,CARD8)), fgxor); \
+ }
+
+#define FbLaneCase2(n,a,o) \
+ if ((n) == 0x03) { \
+ WRITE((CARD16 *) ((a)+FbPatternOffset(o,CARD16)), fgxor); \
+ } else { \
+ FbLaneCase1((n)&1,a,o) \
+ FbLaneCase1((n)>>1,a,(o)+1) \
+ }
+
+#define FbLaneCase4(n,a,o) \
+ if ((n) == 0x0f) { \
+ WRITE((CARD32 *) ((a)+FbPatternOffset(o,CARD32)), fgxor); \
+ } else { \
+ FbLaneCase2((n)&3,a,o) \
+ FbLaneCase2((n)>>2,a,(o)+2) \
+ }
+
+#define FbLaneCase8(n,a,o) \
+ if ((n) == 0x0ff) { \
+ *(FbBits *) ((a)+(o)) = fgxor; \
+ } else { \
+ FbLaneCase4((n)&15,a,o) \
+ FbLaneCase4((n)>>4,a,(o)+4) \
+ }
+
+#if FB_SHIFT == 6
+#define FbLaneCase(n,a) FbLaneCase8(n,(CARD8 *) (a),0)
+#endif
+
+#if FB_SHIFT == 5
+#define FbLaneCase(n,a) FbLaneCase4(n,(CARD8 *) (a),0)
+#endif
+
+/* Rotate a filled pixel value to the specified alignement */
+#define FbRot24(p,b) (FbScrRight(p,b) | FbScrLeft(p,24-(b)))
+#define FbRot24Stip(p,b) (FbStipRight(p,b) | FbStipLeft(p,24-(b)))
+
+/* step a filled pixel value to the next/previous FB_UNIT alignment */
+#define FbNext24Pix(p) (FbRot24(p,(24-FB_UNIT%24)))
+#define FbPrev24Pix(p) (FbRot24(p,FB_UNIT%24))
+#define FbNext24Stip(p) (FbRot24(p,(24-FB_STIP_UNIT%24)))
+#define FbPrev24Stip(p) (FbRot24(p,FB_STIP_UNIT%24))
+
+/* step a rotation value to the next/previous rotation value */
+#if FB_UNIT == 64
+#define FbNext24Rot(r) ((r) == 16 ? 0 : (r) + 8)
+#define FbPrev24Rot(r) ((r) == 0 ? 16 : (r) - 8)
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define FbFirst24Rot(x) (((x) + 8) % 24)
+#else
+#define FbFirst24Rot(x) ((x) % 24)
+#endif
+
+#endif
+
+#if FB_UNIT == 32
+#define FbNext24Rot(r) ((r) == 0 ? 16 : (r) - 8)
+#define FbPrev24Rot(r) ((r) == 16 ? 0 : (r) + 8)
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define FbFirst24Rot(x) (((x) + 16) % 24)
+#else
+#define FbFirst24Rot(x) ((x) % 24)
+#endif
+#endif
+
+#define FbNext24RotStip(r) ((r) == 0 ? 16 : (r) - 8)
+#define FbPrev24RotStip(r) ((r) == 16 ? 0 : (r) + 8)
+
+/* Whether 24-bit specific code is needed for this filled pixel value */
+#define FbCheck24Pix(p) ((p) == FbNext24Pix(p))
+
+/* Macros for dealing with dashing */
+
+#define FbDashDeclare \
+ unsigned char *__dash, *__firstDash, *__lastDash
+
+#define FbDashInit(pGC,pPriv,dashOffset,dashlen,even) { \
+ (even) = TRUE; \
+ __firstDash = (pGC)->dash; \
+ __lastDash = __firstDash + (pGC)->numInDashList; \
+ (dashOffset) %= (pPriv)->dashLength; \
+ \
+ __dash = __firstDash; \
+ while ((dashOffset) >= ((dashlen) = *__dash)) \
+ { \
+ (dashOffset) -= (dashlen); \
+ (even) = 1-(even); \
+ if (++__dash == __lastDash) \
+ __dash = __firstDash; \
+ } \
+ (dashlen) -= (dashOffset); \
+}
+
+#define FbDashNext(dashlen) { \
+ if (++__dash == __lastDash) \
+ __dash = __firstDash; \
+ (dashlen) = *__dash; \
+}
+
+/* as numInDashList is always even, this case can skip a test */
+
+#define FbDashNextEven(dashlen) { \
+ (dashlen) = *++__dash; \
+}
+
+#define FbDashNextOdd(dashlen) FbDashNext(dashlen)
+
+#define FbDashStep(dashlen,even) { \
+ if (!--(dashlen)) { \
+ FbDashNext(dashlen); \
+ (even) = 1-(even); \
+ } \
+}
+
+extern _X_EXPORT DevPrivateKey
+fbGetGCPrivateKey (void);
+
+extern _X_EXPORT DevPrivateKey
+fbGetWinPrivateKey (void);
+
+extern _X_EXPORT const GCOps fbGCOps;
+extern _X_EXPORT const GCFuncs fbGCFuncs;
+
+#ifdef FB_24_32BIT
+#define FB_SCREEN_PRIVATE
+#endif
+
+/* Framebuffer access wrapper */
+typedef FbBits (*ReadMemoryProcPtr)(const void *src, int size);
+typedef void (*WriteMemoryProcPtr)(void *dst, FbBits value, int size);
+typedef void (*SetupWrapProcPtr)(ReadMemoryProcPtr *pRead,
+ WriteMemoryProcPtr *pWrite,
+ DrawablePtr pDraw);
+typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw);
+
+#ifdef FB_ACCESS_WRAPPER
+
+#define fbPrepareAccess(pDraw) \
+ fbGetScreenPrivate((pDraw)->pScreen)->setupWrap( \
+ &wfbReadMemory, \
+ &wfbWriteMemory, \
+ (pDraw))
+#define fbFinishAccess(pDraw) \
+ fbGetScreenPrivate((pDraw)->pScreen)->finishWrap(pDraw)
+
+#else
+
+#define fbPrepareAccess(pPix)
+#define fbFinishAccess(pDraw)
+
+#endif
+
+
+#ifdef FB_SCREEN_PRIVATE
+extern _X_EXPORT DevPrivateKey
+fbGetScreenPrivateKey(void);
+
+/* private field of a screen */
+typedef struct {
+ unsigned char win32bpp; /* window bpp for 32-bpp images */
+ unsigned char pix32bpp; /* pixmap bpp for 32-bpp images */
+#ifdef FB_ACCESS_WRAPPER
+ SetupWrapProcPtr setupWrap; /* driver hook to set pixmap access wrapping */
+ FinishWrapProcPtr finishWrap; /* driver hook to clean up pixmap access wrapping */
+#endif
+} FbScreenPrivRec, *FbScreenPrivPtr;
+
+#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
+#endif
+
+/* private field of GC */
+typedef struct {
+ FbBits and, xor; /* reduced rop values */
+ FbBits bgand, bgxor; /* for stipples */
+ FbBits fg, bg, pm; /* expanded and filled */
+ unsigned int dashLength; /* total of all dash elements */
+ unsigned char oneRect; /* clip list is single rectangle */
+ unsigned char evenStipple; /* stipple is even */
+ unsigned char bpp; /* current drawable bpp */
+} FbGCPrivRec, *FbGCPrivPtr;
+
+#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
+ dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey()))
+
+#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
+#define fbGetExpose(pGC) ((pGC)->fExpose)
+#define fbGetFreeCompClip(pGC) ((pGC)->freeCompClip)
+#define fbGetRotatedPixmap(pGC) ((pGC)->pRotatedPixmap)
+
+#define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate)
+#define fbGetWindowPixmap(pWin) ((PixmapPtr)\
+ dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey()))
+
+#ifdef ROOTLESS
+#define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
+#define __fbPixDrawableY(pPix) ((pPix)->drawable.y)
+#else
+#define __fbPixDrawableX(pPix) 0
+#define __fbPixDrawableY(pPix) 0
+#endif
+
+#ifdef COMPOSITE
+#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x)
+#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y)
+#else
+#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix))
+#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix))
+#endif
+#define __fbPixOffXPix(pPix) (__fbPixDrawableX(pPix))
+#define __fbPixOffYPix(pPix) (__fbPixDrawableY(pPix))
+
+#define fbGetDrawablePixmap(pDrawable, pixmap, xoff, yoff) { \
+ if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
+ (pixmap) = fbGetWindowPixmap(pDrawable); \
+ (xoff) = __fbPixOffXWin(pixmap); \
+ (yoff) = __fbPixOffYWin(pixmap); \
+ } else { \
+ (pixmap) = (PixmapPtr) (pDrawable); \
+ (xoff) = __fbPixOffXPix(pixmap); \
+ (yoff) = __fbPixOffYPix(pixmap); \
+ } \
+ fbPrepareAccess(pDrawable); \
+}
+
+#define fbGetPixmapBitsData(pixmap, pointer, stride, bpp) { \
+ (pointer) = (FbBits *) (pixmap)->devPrivate.ptr; \
+ (stride) = ((int) (pixmap)->devKind) / sizeof (FbBits); (void)(stride); \
+ (bpp) = (pixmap)->drawable.bitsPerPixel; (void)(bpp); \
+}
+
+#define fbGetPixmapStipData(pixmap, pointer, stride, bpp) { \
+ (pointer) = (FbStip *) (pixmap)->devPrivate.ptr; \
+ (stride) = ((int) (pixmap)->devKind) / sizeof (FbStip); (void)(stride); \
+ (bpp) = (pixmap)->drawable.bitsPerPixel; (void)(bpp); \
+}
+
+#define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
+ PixmapPtr _pPix; \
+ fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff); \
+ fbGetPixmapBitsData(_pPix, pointer, stride, bpp); \
+}
+
+#define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
+ PixmapPtr _pPix; \
+ fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff); \
+ fbGetPixmapStipData(_pPix, pointer, stride, bpp); \
+}
+
+/*
+ * XFree86 empties the root BorderClip when the VT is inactive,
+ * here's a macro which uses that to disable GetImage and GetSpans
+ */
+
+#define fbWindowEnabled(pWin) \
+ RegionNotEmpty(&(pWin)->drawable.pScreen->root->borderClip)
+
+#define fbDrawableEnabled(pDrawable) \
+ ((pDrawable)->type == DRAWABLE_PIXMAP ? \
+ TRUE : fbWindowEnabled((WindowPtr) pDrawable))
+
+#define FbPowerOfTwo(w) (((w) & ((w) - 1)) == 0)
+/*
+ * Accelerated tiles are power of 2 width <= FB_UNIT
+ */
+#define FbEvenTile(w) ((w) <= FB_UNIT && FbPowerOfTwo(w))
+/*
+ * Accelerated stipples are power of 2 width and <= FB_UNIT/dstBpp
+ * with dstBpp a power of 2 as well
+ */
+#define FbEvenStip(w,bpp) ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp))
+
+/*
+ * fb24_32.c
+ */
+extern _X_EXPORT void
+fb24_32GetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart);
+
+extern _X_EXPORT void
+fb24_32SetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted);
+
+extern _X_EXPORT void
+fb24_32PutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ CARD8 *src,
+ FbStride srcStride);
+
+extern _X_EXPORT void
+fb24_32GetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d);
+
+extern _X_EXPORT void
+fb24_32CopyMtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT PixmapPtr
+fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel);
+
+extern _X_EXPORT Bool
+fb24_32CreateScreenResources(ScreenPtr pScreen);
+
+extern _X_EXPORT Bool
+fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
+ int width,
+ int height,
+ int depth,
+ int bitsPerPixel,
+ int devKind,
+ pointer pPixData);
+
+/*
+ * fballpriv.c
+ */
+extern _X_EXPORT Bool
+fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex);
+
+/*
+ * fbarc.c
+ */
+
+extern _X_EXPORT void
+fbPolyArc (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs);
+
+/*
+ * fbbits.c
+ */
+
+extern _X_EXPORT void
+fbBresSolid8(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbBresDash8 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbDots8 (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbArc8 (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbGlyph8 (FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+
+extern _X_EXPORT void
+fbPolyline8 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+extern _X_EXPORT void
+fbPolySegment8 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+extern _X_EXPORT void
+fbBresSolid16(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbBresDash16(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbDots16(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbArc16(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbGlyph16(FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+
+extern _X_EXPORT void
+fbPolyline16 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+extern _X_EXPORT void
+fbPolySegment16 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+
+extern _X_EXPORT void
+fbBresSolid24(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbBresDash24(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbDots24(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbArc24(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbGlyph24(FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+
+extern _X_EXPORT void
+fbPolyline24 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+extern _X_EXPORT void
+fbPolySegment24 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+
+extern _X_EXPORT void
+fbBresSolid32(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbBresDash32(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbDots32(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbArc32(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT void
+fbGlyph32(FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+extern _X_EXPORT void
+fbPolyline32 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+extern _X_EXPORT void
+fbPolySegment32 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+/*
+ * fbblt.c
+ */
+extern _X_EXPORT void
+fbBlt (FbBits *src,
+ FbStride srcStride,
+ int srcX,
+
+ FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ Bool reverse,
+ Bool upsidedown);
+
+extern _X_EXPORT void
+fbBlt24 (FbBits *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ FbBits *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+
+ Bool reverse,
+ Bool upsidedown);
+
+extern _X_EXPORT void
+fbBltStip (FbStip *src,
+ FbStride srcStride, /* in FbStip units, not FbBits units */
+ int srcX,
+
+ FbStip *dst,
+ FbStride dstStride, /* in FbStip units, not FbBits units */
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp);
+
+/*
+ * fbbltone.c
+ */
+extern _X_EXPORT void
+fbBltOne (FbStip *src,
+ FbStride srcStride,
+ int srcX,
+ FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbBits fgand,
+ FbBits fbxor,
+ FbBits bgand,
+ FbBits bgxor);
+
+#ifdef FB_24BIT
+extern _X_EXPORT void
+fbBltOne24 (FbStip *src,
+ FbStride srcStride, /* FbStip units per scanline */
+ int srcX, /* bit position of source */
+ FbBits *dst,
+ FbStride dstStride, /* FbBits units per scanline */
+ int dstX, /* bit position of dest */
+ int dstBpp, /* bits per destination unit */
+
+ int width, /* width in bits of destination */
+ int height, /* height in scanlines */
+
+ FbBits fgand, /* rrop values */
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor);
+#endif
+
+extern _X_EXPORT void
+fbBltPlane (FbBits *src,
+ FbStride srcStride,
+ int srcX,
+ int srcBpp,
+
+ FbStip *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbStip fgand,
+ FbStip fgxor,
+ FbStip bgand,
+ FbStip bgxor,
+ Pixel planeMask);
+
+/*
+ * fbcmap.c
+ */
+extern _X_EXPORT int
+fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps);
+
+extern _X_EXPORT void
+fbInstallColormap(ColormapPtr pmap);
+
+extern _X_EXPORT void
+fbUninstallColormap(ColormapPtr pmap);
+
+extern _X_EXPORT void
+fbResolveColor(unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue,
+ VisualPtr pVisual);
+
+extern _X_EXPORT Bool
+fbInitializeColormap(ColormapPtr pmap);
+
+extern _X_EXPORT int
+fbExpandDirectColors (ColormapPtr pmap,
+ int ndef,
+ xColorItem *indefs,
+ xColorItem *outdefs);
+
+extern _X_EXPORT Bool
+fbCreateDefColormap(ScreenPtr pScreen);
+
+extern _X_EXPORT void
+fbClearVisualTypes(void);
+
+extern _X_EXPORT Bool
+fbHasVisualTypes (int depth);
+
+extern _X_EXPORT Bool
+fbSetVisualTypes (int depth, int visuals, int bitsPerRGB);
+
+extern _X_EXPORT Bool
+fbSetVisualTypesAndMasks (int depth, int visuals, int bitsPerRGB,
+ Pixel redMask, Pixel greenMask, Pixel blueMask);
+
+extern _X_EXPORT Bool
+fbInitVisuals (VisualPtr *visualp,
+ DepthPtr *depthp,
+ int *nvisualp,
+ int *ndepthp,
+ int *rootDepthp,
+ VisualID *defaultVisp,
+ unsigned long sizes,
+ int bitsPerRGB);
+
+/*
+ * fbcopy.c
+ */
+
+/* Compatibility definition, to be removed at next ABI change. */
+typedef void (*fbCopyProc) (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pDstBox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT void
+fbCopyNtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+/* Compatibility wrapper, to be removed at next ABI change. */
+extern _X_EXPORT void
+fbCopyRegion (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ RegionPtr pDstRegion,
+ int dx,
+ int dy,
+ fbCopyProc copyProc,
+ Pixel bitPlane,
+ void *closure);
+
+/* Compatibility wrapper, to be removed at next ABI change. */
+extern _X_EXPORT RegionPtr
+fbDoCopy (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut,
+ fbCopyProc copyProc,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT void
+fbCopy1toN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT void
+fbCopyNto1 (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT RegionPtr
+fbCopyArea (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut);
+
+extern _X_EXPORT RegionPtr
+fbCopyPlane (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut,
+ unsigned long bitplane);
+
+/*
+ * fbfill.c
+ */
+extern _X_EXPORT void
+fbFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int width,
+ int height);
+
+extern _X_EXPORT void
+fbSolidBoxClipped (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int xa,
+ int ya,
+ int xb,
+ int yb,
+ FbBits and,
+ FbBits xor);
+
+/*
+ * fbfillrect.c
+ */
+extern _X_EXPORT void
+fbPolyFillRect(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nrectInit,
+ xRectangle *prectInit);
+
+#define fbPolyFillArc miPolyFillArc
+
+#define fbFillPolygon miFillPolygon
+
+/*
+ * fbfillsp.c
+ */
+extern _X_EXPORT void
+fbFillSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nInit,
+ DDXPointPtr pptInit,
+ int *pwidthInit,
+ int fSorted);
+
+
+/*
+ * fbgc.c
+ */
+
+extern _X_EXPORT Bool
+fbCreateGC(GCPtr pGC);
+
+extern _X_EXPORT void
+fbPadPixmap (PixmapPtr pPixmap);
+
+extern _X_EXPORT void
+fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
+
+/*
+ * fbgetsp.c
+ */
+extern _X_EXPORT void
+fbGetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart);
+
+/*
+ * fbglyph.c
+ */
+
+extern _X_EXPORT Bool
+fbGlyphIn (RegionPtr pRegion,
+ int x,
+ int y,
+ int width,
+ int height);
+
+extern _X_EXPORT void
+fbPolyGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase);
+
+extern _X_EXPORT void
+fbImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase);
+
+/*
+ * fbimage.c
+ */
+
+extern _X_EXPORT void
+fbPutImage (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage);
+
+extern _X_EXPORT void
+fbPutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ FbStip *src,
+ FbStride srcStride);
+
+extern _X_EXPORT void
+fbPutXYImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ FbBits fg,
+ FbBits bg,
+ FbBits pm,
+ int alu,
+ Bool opaque,
+
+ int x,
+ int y,
+ int width,
+ int height,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX);
+
+extern _X_EXPORT void
+fbGetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d);
+/*
+ * fbline.c
+ */
+
+extern _X_EXPORT void
+fbZeroLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt);
+
+extern _X_EXPORT void
+fbZeroSegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSegs);
+
+extern _X_EXPORT void
+fbPolyLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt);
+
+extern _X_EXPORT void
+fbFixCoordModePrevious (int npt,
+ DDXPointPtr ppt);
+
+extern _X_EXPORT void
+fbPolySegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+#define fbPolyRectangle miPolyRectangle
+
+/*
+ * fbpict.c
+ */
+
+extern _X_EXPORT Bool
+fbPictureInit (ScreenPtr pScreen,
+ PictFormatPtr formats,
+ int nformats);
+
+/*
+ * fbpixmap.c
+ */
+
+extern _X_EXPORT PixmapPtr
+fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
+ unsigned usage_hint);
+
+extern _X_EXPORT PixmapPtr
+fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth,
+ unsigned usage_hint);
+
+extern _X_EXPORT Bool
+fbDestroyPixmap (PixmapPtr pPixmap);
+
+extern _X_EXPORT RegionPtr
+fbPixmapToRegion(PixmapPtr pPix);
+
+/*
+ * fbpoint.c
+ */
+
+extern _X_EXPORT void
+fbDots (FbBits *dstOrig,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits andOrig,
+ FbBits xorOrig);
+
+extern _X_EXPORT void
+fbPolyPoint (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ xPoint *pptInit);
+
+/*
+ * fbpush.c
+ */
+extern _X_EXPORT void
+fbPushPattern (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+
+ int width,
+ int height);
+
+extern _X_EXPORT void
+fbPushFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+ int width,
+ int height);
+
+extern _X_EXPORT void
+fbPushImage (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+ int width,
+ int height);
+
+extern _X_EXPORT void
+fbPushPixels (GCPtr pGC,
+ PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int dx,
+ int dy,
+ int xOrg,
+ int yOrg);
+
+
+/*
+ * fbscreen.c
+ */
+
+extern _X_EXPORT Bool
+fbCloseScreen (int indx, ScreenPtr pScreen);
+
+extern _X_EXPORT Bool
+fbRealizeFont(ScreenPtr pScreen, FontPtr pFont);
+
+extern _X_EXPORT Bool
+fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
+
+extern _X_EXPORT void
+fbQueryBestSize (int class,
+ unsigned short *width, unsigned short *height,
+ ScreenPtr pScreen);
+
+extern _X_EXPORT PixmapPtr
+_fbGetWindowPixmap (WindowPtr pWindow);
+
+extern _X_EXPORT void
+_fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap);
+
+extern _X_EXPORT Bool
+fbSetupScreen(ScreenPtr pScreen,
+ pointer pbits, /* pointer to screen bitmap */
+ int xsize, /* in pixels */
+ int ysize,
+ int dpix, /* dots per inch */
+ int dpiy,
+ int width, /* pixel width of frame buffer */
+ int bpp); /* bits per pixel of frame buffer */
+
+extern _X_EXPORT Bool
+wfbFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp,
+ SetupWrapProcPtr setupWrap,
+ FinishWrapProcPtr finishWrap);
+
+extern _X_EXPORT Bool
+wfbScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp,
+ SetupWrapProcPtr setupWrap,
+ FinishWrapProcPtr finishWrap);
+
+extern _X_EXPORT Bool
+fbFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp);
+
+extern _X_EXPORT Bool
+fbScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp);
+
+/*
+ * fbseg.c
+ */
+typedef void FbBres (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT FbBres fbBresSolid, fbBresDash, fbBresFill, fbBresFillDash;
+/*
+ * fbsetsp.c
+ */
+
+extern _X_EXPORT void
+fbSetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted);
+
+extern _X_EXPORT FbBres *
+fbSelectBres (DrawablePtr pDrawable,
+ GCPtr pGC);
+
+extern _X_EXPORT void
+fbBres (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+extern _X_EXPORT void
+fbSegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xa,
+ int ya,
+ int xb,
+ int yb,
+ Bool drawLast,
+ int *dashOffset);
+
+
+/*
+ * fbsolid.c
+ */
+
+extern _X_EXPORT void
+fbSolid (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int bpp,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor);
+
+#ifdef FB_24BIT
+extern _X_EXPORT void
+fbSolid24 (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor);
+#endif
+
+/*
+ * fbstipple.c
+ */
+
+extern _X_EXPORT void
+fbTransparentSpan (FbBits *dst,
+ FbBits stip,
+ FbBits fgxor,
+ int n);
+
+extern _X_EXPORT void
+fbEvenStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipHeight,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot);
+
+extern _X_EXPORT void
+fbOddStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipWidth,
+ int stipHeight,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot);
+
+extern _X_EXPORT void
+fbStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipWidth,
+ int stipHeight,
+ Bool even,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot);
+
+/*
+ * fbtile.c
+ */
+
+extern _X_EXPORT void
+fbEvenTile (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ FbStride tileStride,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int xRot,
+ int yRot);
+
+extern _X_EXPORT void
+fbOddTile (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ int xRot,
+ int yRot);
+
+extern _X_EXPORT void
+fbTile (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ int xRot,
+ int yRot);
+
+/*
+ * fbutil.c
+ */
+extern _X_EXPORT FbBits
+fbReplicatePixel (Pixel p, int bpp);
+
+extern _X_EXPORT void
+fbReduceRasterOp (int rop, FbBits fg, FbBits pm, FbBits *andp, FbBits *xorp);
+
+#ifdef FB_ACCESS_WRAPPER
+extern _X_EXPORT ReadMemoryProcPtr wfbReadMemory;
+extern _X_EXPORT WriteMemoryProcPtr wfbWriteMemory;
+#endif
+
+/*
+ * fbwindow.c
+ */
+
+extern _X_EXPORT Bool
+fbCreateWindow(WindowPtr pWin);
+
+extern _X_EXPORT Bool
+fbDestroyWindow(WindowPtr pWin);
+
+extern _X_EXPORT Bool
+fbMapWindow(WindowPtr pWindow);
+
+extern _X_EXPORT Bool
+fbPositionWindow(WindowPtr pWin, int x, int y);
+
+extern _X_EXPORT Bool
+fbUnmapWindow(WindowPtr pWindow);
+
+extern _X_EXPORT void
+fbCopyWindowProc (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT void
+fbCopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+
+extern _X_EXPORT Bool
+fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
+
+extern _X_EXPORT void
+fbFillRegionSolid (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ FbBits and,
+ FbBits xor);
+
+extern _X_EXPORT pixman_image_t *
+image_from_pict (PicturePtr pict,
+ Bool has_clip,
+ int *xoff,
+ int *yoff);
+
+extern _X_EXPORT void free_pixman_pict (PicturePtr, pixman_image_t *);
+
+#endif /* _FB_H_ */
+
diff --git a/xorg-server/fb/fb24_32.c b/xorg-server/fb/fb24_32.c index 1ebd598a8..748a0ec04 100644 --- a/xorg-server/fb/fb24_32.c +++ b/xorg-server/fb/fb24_32.c @@ -1,635 +1,635 @@ -/* - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <string.h> - -#include "fb.h" - -/* X apps don't like 24bpp images, this code exposes 32bpp images */ - -/* - * These two functions do a full CopyArea while reformatting - * the data between 24 and 32bpp. They try to go a bit faster - * by reading/writing aligned CARD32s where it's easy - */ - -#define Get8(a) ((CARD32) READ(a)) - -#if BITMAP_BIT_ORDER == MSBFirst -#define Get24(a) ((Get8(a) << 16) | (Get8((a)+1) << 8) | Get8((a)+2)) -#define Put24(a,p) ((WRITE((a+0), (CARD8) ((p) >> 16))), \ - (WRITE((a+1), (CARD8) ((p) >> 8))), \ - (WRITE((a+2), (CARD8) (p)))) -#else -#define Get24(a) (Get8(a) | (Get8((a)+1) << 8) | (Get8((a)+2)<<16)) -#define Put24(a,p) ((WRITE((a+0), (CARD8) (p))), \ - (WRITE((a+1), (CARD8) ((p) >> 8))), \ - (WRITE((a+2), (CARD8) ((p) >> 16)))) -#endif - -typedef void (*fb24_32BltFunc) (CARD8 *srcLine, - FbStride srcStride, - int srcX, - - CARD8 *dstLine, - FbStride dstStride, - int dstX, - - int width, - int height, - - int alu, - FbBits pm); - -static void -fb24_32BltDown (CARD8 *srcLine, - FbStride srcStride, - int srcX, - - CARD8 *dstLine, - FbStride dstStride, - int dstX, - - int width, - int height, - - int alu, - FbBits pm) -{ - CARD32 *src; - CARD8 *dst; - int w; - Bool destInvarient; - CARD32 pixel, dpixel; - FbDeclareMergeRop (); - - srcLine += srcX * 4; - dstLine += dstX * 3; - - FbInitializeMergeRop(alu, (pm | ~(FbBits) 0xffffff)); - destInvarient = FbDestInvarientMergeRop(); - - while (height--) - { - src = (CARD32 *) srcLine; - dst = dstLine; - srcLine += srcStride; - dstLine += dstStride; - w = width; - if (destInvarient) - { - while (((long) dst & 3) && w) - { - w--; - pixel = READ(src++); - pixel = FbDoDestInvarientMergeRop(pixel); - Put24 (dst, pixel); - dst += 3; - } - /* Do four aligned pixels at a time */ - while (w >= 4) - { - CARD32 s0, s1; - s0 = READ(src++); - s0 = FbDoDestInvarientMergeRop(s0); - s1 = READ(src++); - s1 = FbDoDestInvarientMergeRop(s1); -#if BITMAP_BIT_ORDER == LSBFirst - WRITE((CARD32 *)dst, (s0 & 0xffffff) | (s1 << 24)); -#else - WRITE((CARD32 *)dst, (s0 << 8) | ((s1 & 0xffffff) >> 16)); -#endif - s0 = READ(src++); - s0 = FbDoDestInvarientMergeRop(s0); -#if BITMAP_BIT_ORDER == LSBFirst - WRITE((CARD32 *)(dst+4), ((s1 & 0xffffff) >> 8) | (s0 << 16)); -#else - WRITE((CARD32 *)(dst+4), (s1 << 16) | ((s0 & 0xffffff) >> 8)); -#endif - s1 = READ(src++); - s1 = FbDoDestInvarientMergeRop(s1); -#if BITMAP_BIT_ORDER == LSBFirst - WRITE((CARD32 *)(dst+8), ((s0 & 0xffffff) >> 16) | (s1 << 8)); -#else - WRITE((CARD32 *)(dst+8), (s0 << 24) | (s1 & 0xffffff)); -#endif - dst += 12; - w -= 4; - } - while (w--) - { - pixel = READ(src++); - pixel = FbDoDestInvarientMergeRop(pixel); - Put24 (dst, pixel); - dst += 3; - } - } - else - { - while (w--) - { - pixel = READ(src++); - dpixel = Get24 (dst); - pixel = FbDoMergeRop(pixel, dpixel); - Put24 (dst, pixel); - dst += 3; - } - } - } -} - -static void -fb24_32BltUp (CARD8 *srcLine, - FbStride srcStride, - int srcX, - - CARD8 *dstLine, - FbStride dstStride, - int dstX, - - int width, - int height, - - int alu, - FbBits pm) -{ - CARD8 *src; - CARD32 *dst; - int w; - Bool destInvarient; - CARD32 pixel; - FbDeclareMergeRop (); - - FbInitializeMergeRop(alu, (pm | (~(FbBits) 0xffffff))); - destInvarient = FbDestInvarientMergeRop(); - - srcLine += srcX * 3; - dstLine += dstX * 4; - - while (height--) - { - w = width; - src = srcLine; - dst = (CARD32 *) dstLine; - srcLine += srcStride; - dstLine += dstStride; - if (destInvarient) - { - while (((long) src & 3) && w) - { - w--; - pixel = Get24(src); - src += 3; - WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); - } - /* Do four aligned pixels at a time */ - while (w >= 4) - { - CARD32 s0, s1; - - s0 = READ((CARD32 *)src); -#if BITMAP_BIT_ORDER == LSBFirst - pixel = s0 & 0xffffff; -#else - pixel = s0 >> 8; -#endif - WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); - s1 = READ((CARD32 *)(src+4)); -#if BITMAP_BIT_ORDER == LSBFirst - pixel = (s0 >> 24) | ((s1 << 8) & 0xffffff); -#else - pixel = ((s0 << 16) & 0xffffff) | (s1 >> 16); -#endif - WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); - s0 = READ((CARD32 *)(src+8)); -#if BITMAP_BIT_ORDER == LSBFirst - pixel = (s1 >> 16) | ((s0 << 16) & 0xffffff); -#else - pixel = ((s1 << 8) & 0xffffff) | (s0 >> 24); -#endif - WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); -#if BITMAP_BIT_ORDER == LSBFirst - pixel = s0 >> 8; -#else - pixel = s0 & 0xffffff; -#endif - WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); - src += 12; - w -= 4; - } - while (w) - { - w--; - pixel = Get24(src); - src += 3; - WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); - } - } - else - { - while (w--) - { - pixel = Get24(src); - src += 3; - WRITE(dst, FbDoMergeRop(pixel, READ(dst))); - dst++; - } - } - } -} - -/* - * Spans functions; probably unused. - */ -void -fb24_32GetSpans(DrawablePtr pDrawable, - int wMax, - DDXPointPtr ppt, - int *pwidth, - int nspans, - char *pchardstStart) -{ - FbBits *srcBits; - CARD8 *src; - FbStride srcStride; - int srcBpp; - int srcXoff, srcYoff; - CARD8 *dst; - - fbGetDrawable (pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff); - src = (CARD8 *) srcBits; - srcStride *= sizeof (FbBits); - - while (nspans--) - { - dst = (CARD8 *) pchardstStart; - fb24_32BltUp (src + (ppt->y + srcYoff) * srcStride, srcStride, - ppt->x + srcXoff, - - dst, - 1, - 0, - - *pwidth, - 1, - - GXcopy, - FB_ALLONES); - - pchardstStart += PixmapBytePad(*pwidth, pDrawable->depth); - ppt++; - pwidth++; - } - - fbFinishAccess (pDrawable); -} - -void -fb24_32SetSpans (DrawablePtr pDrawable, - GCPtr pGC, - char *src, - DDXPointPtr ppt, - int *pwidth, - int nspans, - int fSorted) -{ - FbGCPrivPtr pPriv = fbGetGCPrivate (pGC); - RegionPtr pClip = fbGetCompositeClip(pGC); - FbBits *dstBits; - CARD8 *dst, *d, *s; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - BoxPtr pbox; - int n; - int x1, x2; - - fbGetDrawable (pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff); - dst = (CARD8 *) dstBits; - dstStride *= sizeof (FbBits); - while (nspans--) - { - d = dst + (ppt->y + dstYoff) * dstStride; - s = (CARD8 *) src; - n = REGION_NUM_RECTS(pClip); - pbox = REGION_RECTS (pClip); - while (n--) - { - if (pbox->y1 > ppt->y) - break; - if (pbox->y2 > ppt->y) - { - x1 = ppt->x; - x2 = x1 + *pwidth; - if (pbox->x1 > x1) - x1 = pbox->x1; - if (pbox->x2 < x2) - x2 = pbox->x2; - if (x1 < x2) - fb24_32BltDown (s, - 0, - (x1 - ppt->x), - d, - dstStride, - x1 + dstXoff, - - (x2 - x1), - 1, - pGC->alu, - pPriv->pm); - } - } - src += PixmapBytePad (*pwidth, pDrawable->depth); - ppt++; - pwidth++; - } - - fbFinishAccess (pDrawable); -} - -/* - * Clip and put 32bpp Z-format images to a 24bpp drawable - */ -void -fb24_32PutZImage (DrawablePtr pDrawable, - RegionPtr pClip, - int alu, - FbBits pm, - int x, - int y, - int width, - int height, - CARD8 *src, - FbStride srcStride) -{ - FbBits *dstBits; - CARD8 *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - int nbox; - BoxPtr pbox; - int x1, y1, x2, y2; - - fbGetDrawable (pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff); - dstStride *= sizeof(FbBits); - dst = (CARD8 *) dstBits; - - for (nbox = REGION_NUM_RECTS (pClip), - pbox = REGION_RECTS(pClip); - nbox--; - pbox++) - { - x1 = x; - y1 = y; - x2 = x + width; - y2 = y + height; - if (x1 < pbox->x1) - x1 = pbox->x1; - if (y1 < pbox->y1) - y1 = pbox->y1; - if (x2 > pbox->x2) - x2 = pbox->x2; - if (y2 > pbox->y2) - y2 = pbox->y2; - if (x1 >= x2 || y1 >= y2) - continue; - fb24_32BltDown (src + (y1 - y) * srcStride, - srcStride, - (x1 - x), - - dst + (y1 + dstYoff) * dstStride, - dstStride, - x1 + dstXoff, - - (x2 - x1), - (y2 - y1), - - alu, - pm); - } - - fbFinishAccess (pDrawable); -} - -void -fb24_32GetImage (DrawablePtr pDrawable, - int x, - int y, - int w, - int h, - unsigned int format, - unsigned long planeMask, - char *d) -{ - FbBits *srcBits; - CARD8 *src; - FbStride srcStride; - int srcBpp; - int srcXoff, srcYoff; - FbStride dstStride; - FbBits pm; - - fbGetDrawable (pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff); - src = (CARD8 *) srcBits; - srcStride *= sizeof (FbBits); - - x += pDrawable->x; - y += pDrawable->y; - - pm = fbReplicatePixel (planeMask, 32); - dstStride = PixmapBytePad(w, pDrawable->depth); - if (pm != FB_ALLONES) - memset (d, 0, dstStride * h); - fb24_32BltUp (src + (y + srcYoff) * srcStride, srcStride, x + srcXoff, - (CARD8 *) d, dstStride, 0, - w, h, GXcopy, pm); - - fbFinishAccess (pDrawable); -} - -void -fb24_32CopyMtoN (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure) -{ - FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); - FbBits *srcBits; - CARD8 *src; - FbStride srcStride; - int srcBpp; - FbBits *dstBits; - CARD8 *dst; - FbStride dstStride; - int dstBpp; - fb24_32BltFunc blt; - int srcXoff, srcYoff; - int dstXoff, dstYoff; - - fbGetDrawable (pSrcDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff); - src = (CARD8 *) srcBits; - srcStride *= sizeof (FbBits); - fbGetDrawable (pDstDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff); - dst = (CARD8 *) dstBits; - dstStride *= sizeof (FbBits); - if (srcBpp == 24) - blt = fb24_32BltUp; - else - blt = fb24_32BltDown; - - while (nbox--) - { - (*blt) (src + (pbox->y1 + dy + srcYoff) * srcStride, - srcStride, - (pbox->x1 + dx + srcXoff), - - dst + (pbox->y1 + dstYoff) * dstStride, - dstStride, - (pbox->x1 + dstXoff), - - (pbox->x2 - pbox->x1), - (pbox->y2 - pbox->y1), - - pGC->alu, - pPriv->pm); - pbox++; - } - - fbFinishAccess (pSrcDrawable); - fbFinishAccess (pDstDrawable); -} - -PixmapPtr -fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel) -{ - ScreenPtr pScreen = pOldTile->drawable.pScreen; - PixmapPtr pNewTile; - FbBits *old, *new; - FbStride oldStride, newStride; - int oldBpp, newBpp; - fb24_32BltFunc blt; - int oldXoff, oldYoff; - int newXoff, newYoff; - - pNewTile = pScreen->CreatePixmap(pScreen, pOldTile->drawable.width, - pOldTile->drawable.height, - pOldTile->drawable.depth, - pOldTile->usage_hint); - if (!pNewTile) - return 0; - fbGetDrawable (&pOldTile->drawable, - old, oldStride, oldBpp, oldXoff, oldYoff); - fbGetDrawable (&pNewTile->drawable, - new, newStride, newBpp, newXoff, newYoff); - if (oldBpp == 24) - blt = fb24_32BltUp; - else - blt = fb24_32BltDown; - - (*blt) ((CARD8 *) old, - oldStride * sizeof (FbBits), - 0, - - (CARD8 *) new, - newStride * sizeof (FbBits), - 0, - - pOldTile->drawable.width, - pOldTile->drawable.height, - - GXcopy, - FB_ALLONES); - - fbFinishAccess (&pOldTile->drawable); - fbFinishAccess (&pNewTile->drawable); - - return pNewTile; -} - -typedef struct { - pointer pbits; - int width; -} miScreenInitParmsRec, *miScreenInitParmsPtr; - -Bool -fb24_32CreateScreenResources(ScreenPtr pScreen) -{ - miScreenInitParmsPtr pScrInitParms; - int pitch; - Bool retval; - - /* get the pitch before mi destroys it */ - pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate; - pitch = BitmapBytePad(pScrInitParms->width * 24); - - if((retval = miCreateScreenResources(pScreen))) { - /* fix the screen pixmap */ - PixmapPtr pPix = (PixmapPtr)pScreen->devPrivate; - pPix->drawable.bitsPerPixel = 24; - pPix->devKind = pitch; - } - - return retval; -} - -Bool -fb24_32ModifyPixmapHeader (PixmapPtr pPixmap, - int width, - int height, - int depth, - int bitsPerPixel, - int devKind, - pointer pPixData) -{ - int bpp, w; - - if (!pPixmap) - return FALSE; - bpp = bitsPerPixel; - if (bpp <= 0) - bpp = pPixmap->drawable.bitsPerPixel; - if (bpp == 24) - { - if (devKind < 0) - { - w = width; - if (w <= 0) - w = pPixmap->drawable.width; - devKind = BitmapBytePad(w * 24); - } - } - return miModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, - devKind, pPixData); -} +/*
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+
+#include "fb.h"
+
+/* X apps don't like 24bpp images, this code exposes 32bpp images */
+
+/*
+ * These two functions do a full CopyArea while reformatting
+ * the data between 24 and 32bpp. They try to go a bit faster
+ * by reading/writing aligned CARD32s where it's easy
+ */
+
+#define Get8(a) ((CARD32) READ(a))
+
+#if BITMAP_BIT_ORDER == MSBFirst
+#define Get24(a) ((Get8(a) << 16) | (Get8((a)+1) << 8) | Get8((a)+2))
+#define Put24(a,p) ((WRITE((a+0), (CARD8) ((p) >> 16))), \
+ (WRITE((a+1), (CARD8) ((p) >> 8))), \
+ (WRITE((a+2), (CARD8) (p))))
+#else
+#define Get24(a) (Get8(a) | (Get8((a)+1) << 8) | (Get8((a)+2)<<16))
+#define Put24(a,p) ((WRITE((a+0), (CARD8) (p))), \
+ (WRITE((a+1), (CARD8) ((p) >> 8))), \
+ (WRITE((a+2), (CARD8) ((p) >> 16))))
+#endif
+
+typedef void (*fb24_32BltFunc) (CARD8 *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ CARD8 *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm);
+
+static void
+fb24_32BltDown (CARD8 *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ CARD8 *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm)
+{
+ CARD32 *src;
+ CARD8 *dst;
+ int w;
+ Bool destInvarient;
+ CARD32 pixel, dpixel;
+ FbDeclareMergeRop ();
+
+ srcLine += srcX * 4;
+ dstLine += dstX * 3;
+
+ FbInitializeMergeRop(alu, (pm | ~(FbBits) 0xffffff));
+ destInvarient = FbDestInvarientMergeRop();
+
+ while (height--)
+ {
+ src = (CARD32 *) srcLine;
+ dst = dstLine;
+ srcLine += srcStride;
+ dstLine += dstStride;
+ w = width;
+ if (destInvarient)
+ {
+ while (((long) dst & 3) && w)
+ {
+ w--;
+ pixel = READ(src++);
+ pixel = FbDoDestInvarientMergeRop(pixel);
+ Put24 (dst, pixel);
+ dst += 3;
+ }
+ /* Do four aligned pixels at a time */
+ while (w >= 4)
+ {
+ CARD32 s0, s1;
+ s0 = READ(src++);
+ s0 = FbDoDestInvarientMergeRop(s0);
+ s1 = READ(src++);
+ s1 = FbDoDestInvarientMergeRop(s1);
+#if BITMAP_BIT_ORDER == LSBFirst
+ WRITE((CARD32 *)dst, (s0 & 0xffffff) | (s1 << 24));
+#else
+ WRITE((CARD32 *)dst, (s0 << 8) | ((s1 & 0xffffff) >> 16));
+#endif
+ s0 = READ(src++);
+ s0 = FbDoDestInvarientMergeRop(s0);
+#if BITMAP_BIT_ORDER == LSBFirst
+ WRITE((CARD32 *)(dst+4), ((s1 & 0xffffff) >> 8) | (s0 << 16));
+#else
+ WRITE((CARD32 *)(dst+4), (s1 << 16) | ((s0 & 0xffffff) >> 8));
+#endif
+ s1 = READ(src++);
+ s1 = FbDoDestInvarientMergeRop(s1);
+#if BITMAP_BIT_ORDER == LSBFirst
+ WRITE((CARD32 *)(dst+8), ((s0 & 0xffffff) >> 16) | (s1 << 8));
+#else
+ WRITE((CARD32 *)(dst+8), (s0 << 24) | (s1 & 0xffffff));
+#endif
+ dst += 12;
+ w -= 4;
+ }
+ while (w--)
+ {
+ pixel = READ(src++);
+ pixel = FbDoDestInvarientMergeRop(pixel);
+ Put24 (dst, pixel);
+ dst += 3;
+ }
+ }
+ else
+ {
+ while (w--)
+ {
+ pixel = READ(src++);
+ dpixel = Get24 (dst);
+ pixel = FbDoMergeRop(pixel, dpixel);
+ Put24 (dst, pixel);
+ dst += 3;
+ }
+ }
+ }
+}
+
+static void
+fb24_32BltUp (CARD8 *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ CARD8 *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm)
+{
+ CARD8 *src;
+ CARD32 *dst;
+ int w;
+ Bool destInvarient;
+ CARD32 pixel;
+ FbDeclareMergeRop ();
+
+ FbInitializeMergeRop(alu, (pm | (~(FbBits) 0xffffff)));
+ destInvarient = FbDestInvarientMergeRop();
+
+ srcLine += srcX * 3;
+ dstLine += dstX * 4;
+
+ while (height--)
+ {
+ w = width;
+ src = srcLine;
+ dst = (CARD32 *) dstLine;
+ srcLine += srcStride;
+ dstLine += dstStride;
+ if (destInvarient)
+ {
+ while (((long) src & 3) && w)
+ {
+ w--;
+ pixel = Get24(src);
+ src += 3;
+ WRITE(dst++, FbDoDestInvarientMergeRop(pixel));
+ }
+ /* Do four aligned pixels at a time */
+ while (w >= 4)
+ {
+ CARD32 s0, s1;
+
+ s0 = READ((CARD32 *)src);
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = s0 & 0xffffff;
+#else
+ pixel = s0 >> 8;
+#endif
+ WRITE(dst++, FbDoDestInvarientMergeRop(pixel));
+ s1 = READ((CARD32 *)(src+4));
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = (s0 >> 24) | ((s1 << 8) & 0xffffff);
+#else
+ pixel = ((s0 << 16) & 0xffffff) | (s1 >> 16);
+#endif
+ WRITE(dst++, FbDoDestInvarientMergeRop(pixel));
+ s0 = READ((CARD32 *)(src+8));
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = (s1 >> 16) | ((s0 << 16) & 0xffffff);
+#else
+ pixel = ((s1 << 8) & 0xffffff) | (s0 >> 24);
+#endif
+ WRITE(dst++, FbDoDestInvarientMergeRop(pixel));
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = s0 >> 8;
+#else
+ pixel = s0 & 0xffffff;
+#endif
+ WRITE(dst++, FbDoDestInvarientMergeRop(pixel));
+ src += 12;
+ w -= 4;
+ }
+ while (w)
+ {
+ w--;
+ pixel = Get24(src);
+ src += 3;
+ WRITE(dst++, FbDoDestInvarientMergeRop(pixel));
+ }
+ }
+ else
+ {
+ while (w--)
+ {
+ pixel = Get24(src);
+ src += 3;
+ WRITE(dst, FbDoMergeRop(pixel, READ(dst)));
+ dst++;
+ }
+ }
+ }
+}
+
+/*
+ * Spans functions; probably unused.
+ */
+void
+fb24_32GetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart)
+{
+ FbBits *srcBits;
+ CARD8 *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ CARD8 *dst;
+
+ fbGetDrawable (pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff);
+ src = (CARD8 *) srcBits;
+ srcStride *= sizeof (FbBits);
+
+ while (nspans--)
+ {
+ dst = (CARD8 *) pchardstStart;
+ fb24_32BltUp (src + (ppt->y + srcYoff) * srcStride, srcStride,
+ ppt->x + srcXoff,
+
+ dst,
+ 1,
+ 0,
+
+ *pwidth,
+ 1,
+
+ GXcopy,
+ FB_ALLONES);
+
+ pchardstStart += PixmapBytePad(*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+
+ fbFinishAccess (pDrawable);
+}
+
+void
+fb24_32SetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ FbBits *dstBits;
+ CARD8 *dst, *d, *s;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ BoxPtr pbox;
+ int n;
+ int x1, x2;
+
+ fbGetDrawable (pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
+ dst = (CARD8 *) dstBits;
+ dstStride *= sizeof (FbBits);
+ while (nspans--)
+ {
+ d = dst + (ppt->y + dstYoff) * dstStride;
+ s = (CARD8 *) src;
+ n = RegionNumRects(pClip);
+ pbox = RegionRects (pClip);
+ while (n--)
+ {
+ if (pbox->y1 > ppt->y)
+ break;
+ if (pbox->y2 > ppt->y)
+ {
+ x1 = ppt->x;
+ x2 = x1 + *pwidth;
+ if (pbox->x1 > x1)
+ x1 = pbox->x1;
+ if (pbox->x2 < x2)
+ x2 = pbox->x2;
+ if (x1 < x2)
+ fb24_32BltDown (s,
+ 0,
+ (x1 - ppt->x),
+ d,
+ dstStride,
+ x1 + dstXoff,
+
+ (x2 - x1),
+ 1,
+ pGC->alu,
+ pPriv->pm);
+ }
+ }
+ src += PixmapBytePad (*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+
+ fbFinishAccess (pDrawable);
+}
+
+/*
+ * Clip and put 32bpp Z-format images to a 24bpp drawable
+ */
+void
+fb24_32PutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ CARD8 *src,
+ FbStride srcStride)
+{
+ FbBits *dstBits;
+ CARD8 *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int nbox;
+ BoxPtr pbox;
+ int x1, y1, x2, y2;
+
+ fbGetDrawable (pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
+ dstStride *= sizeof(FbBits);
+ dst = (CARD8 *) dstBits;
+
+ for (nbox = RegionNumRects (pClip),
+ pbox = RegionRects(pClip);
+ nbox--;
+ pbox++)
+ {
+ x1 = x;
+ y1 = y;
+ x2 = x + width;
+ y2 = y + height;
+ if (x1 < pbox->x1)
+ x1 = pbox->x1;
+ if (y1 < pbox->y1)
+ y1 = pbox->y1;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ fb24_32BltDown (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x),
+
+ dst + (y1 + dstYoff) * dstStride,
+ dstStride,
+ x1 + dstXoff,
+
+ (x2 - x1),
+ (y2 - y1),
+
+ alu,
+ pm);
+ }
+
+ fbFinishAccess (pDrawable);
+}
+
+void
+fb24_32GetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d)
+{
+ FbBits *srcBits;
+ CARD8 *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbStride dstStride;
+ FbBits pm;
+
+ fbGetDrawable (pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff);
+ src = (CARD8 *) srcBits;
+ srcStride *= sizeof (FbBits);
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ pm = fbReplicatePixel (planeMask, 32);
+ dstStride = PixmapBytePad(w, pDrawable->depth);
+ if (pm != FB_ALLONES)
+ memset (d, 0, dstStride * h);
+ fb24_32BltUp (src + (y + srcYoff) * srcStride, srcStride, x + srcXoff,
+ (CARD8 *) d, dstStride, 0,
+ w, h, GXcopy, pm);
+
+ fbFinishAccess (pDrawable);
+}
+
+void
+fb24_32CopyMtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ FbBits *srcBits;
+ CARD8 *src;
+ FbStride srcStride;
+ int srcBpp;
+ FbBits *dstBits;
+ CARD8 *dst;
+ FbStride dstStride;
+ int dstBpp;
+ fb24_32BltFunc blt;
+ int srcXoff, srcYoff;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff);
+ src = (CARD8 *) srcBits;
+ srcStride *= sizeof (FbBits);
+ fbGetDrawable (pDstDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
+ dst = (CARD8 *) dstBits;
+ dstStride *= sizeof (FbBits);
+ if (srcBpp == 24)
+ blt = fb24_32BltUp;
+ else
+ blt = fb24_32BltDown;
+
+ while (nbox--)
+ {
+ (*blt) (src + (pbox->y1 + dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff),
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff),
+
+ (pbox->x2 - pbox->x1),
+ (pbox->y2 - pbox->y1),
+
+ pGC->alu,
+ pPriv->pm);
+ pbox++;
+ }
+
+ fbFinishAccess (pSrcDrawable);
+ fbFinishAccess (pDstDrawable);
+}
+
+PixmapPtr
+fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel)
+{
+ ScreenPtr pScreen = pOldTile->drawable.pScreen;
+ PixmapPtr pNewTile;
+ FbBits *old, *new;
+ FbStride oldStride, newStride;
+ int oldBpp, newBpp;
+ fb24_32BltFunc blt;
+ int oldXoff, oldYoff;
+ int newXoff, newYoff;
+
+ pNewTile = pScreen->CreatePixmap(pScreen, pOldTile->drawable.width,
+ pOldTile->drawable.height,
+ pOldTile->drawable.depth,
+ pOldTile->usage_hint);
+ if (!pNewTile)
+ return 0;
+ fbGetDrawable (&pOldTile->drawable,
+ old, oldStride, oldBpp, oldXoff, oldYoff);
+ fbGetDrawable (&pNewTile->drawable,
+ new, newStride, newBpp, newXoff, newYoff);
+ if (oldBpp == 24)
+ blt = fb24_32BltUp;
+ else
+ blt = fb24_32BltDown;
+
+ (*blt) ((CARD8 *) old,
+ oldStride * sizeof (FbBits),
+ 0,
+
+ (CARD8 *) new,
+ newStride * sizeof (FbBits),
+ 0,
+
+ pOldTile->drawable.width,
+ pOldTile->drawable.height,
+
+ GXcopy,
+ FB_ALLONES);
+
+ fbFinishAccess (&pOldTile->drawable);
+ fbFinishAccess (&pNewTile->drawable);
+
+ return pNewTile;
+}
+
+typedef struct {
+ pointer pbits;
+ int width;
+} miScreenInitParmsRec, *miScreenInitParmsPtr;
+
+Bool
+fb24_32CreateScreenResources(ScreenPtr pScreen)
+{
+ miScreenInitParmsPtr pScrInitParms;
+ int pitch;
+ Bool retval;
+
+ /* get the pitch before mi destroys it */
+ pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate;
+ pitch = BitmapBytePad(pScrInitParms->width * 24);
+
+ if((retval = miCreateScreenResources(pScreen))) {
+ /* fix the screen pixmap */
+ PixmapPtr pPix = (PixmapPtr)pScreen->devPrivate;
+ pPix->drawable.bitsPerPixel = 24;
+ pPix->devKind = pitch;
+ }
+
+ return retval;
+}
+
+Bool
+fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
+ int width,
+ int height,
+ int depth,
+ int bitsPerPixel,
+ int devKind,
+ pointer pPixData)
+{
+ int bpp, w;
+
+ if (!pPixmap)
+ return FALSE;
+ bpp = bitsPerPixel;
+ if (bpp <= 0)
+ bpp = pPixmap->drawable.bitsPerPixel;
+ if (bpp == 24)
+ {
+ if (devKind < 0)
+ {
+ w = width;
+ if (w <= 0)
+ w = pPixmap->drawable.width;
+ devKind = BitmapBytePad(w * 24);
+ }
+ }
+ return miModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel,
+ devKind, pPixData);
+}
diff --git a/xorg-server/fb/fballpriv.c b/xorg-server/fb/fballpriv.c index 6aee50bce..b4fcb1f4a 100644 --- a/xorg-server/fb/fballpriv.c +++ b/xorg-server/fb/fballpriv.c @@ -27,46 +27,34 @@ #include "fb.h"
#ifdef FB_SCREEN_PRIVATE
-static int fbScreenPrivateKeyIndex;
-static DevPrivateKey fbScreenPrivateKey = &fbScreenPrivateKeyIndex;
-DevPrivateKey fbGetScreenPrivateKey(void)
-{
- return fbScreenPrivateKey;
-}
+static DevPrivateKeyRec fbScreenPrivateKeyRec;
+DevPrivateKey
+fbGetScreenPrivateKey(void) { return &fbScreenPrivateKeyRec; }
#endif
-static int fbGCPrivateKeyIndex;
-static DevPrivateKey fbGCPrivateKey = &fbGCPrivateKeyIndex;
-DevPrivateKey fbGetGCPrivateKey(void)
-{
- return fbGCPrivateKey;
-}
+static DevPrivateKeyRec fbGCPrivateKeyRec;
+DevPrivateKey
+fbGetGCPrivateKey (void) { return &fbGCPrivateKeyRec; }
-static int fbWinPrivateKeyIndex;
-static DevPrivateKey fbWinPrivateKey = &fbWinPrivateKeyIndex;
-DevPrivateKey fbGetWinPrivateKey(void)
-{
- return fbWinPrivateKey;
-}
+static DevPrivateKeyRec fbWinPrivateKeyRec;
+DevPrivateKey
+fbGetWinPrivateKey (void) { return &fbWinPrivateKeyRec; }
Bool
fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
{
if (pGCKey)
- *pGCKey = fbGCPrivateKey;
+ *pGCKey = &fbGCPrivateKeyRec;
- if (!dixRequestPrivate(fbGCPrivateKey, sizeof(FbGCPrivRec)))
+ if (!dixRegisterPrivateKey(&fbGCPrivateKeyRec, PRIVATE_GC, sizeof(FbGCPrivRec)))
return FALSE;
#ifdef FB_SCREEN_PRIVATE
- {
- FbScreenPrivPtr pScreenPriv;
-
- pScreenPriv = (FbScreenPrivPtr) malloc(sizeof (FbScreenPrivRec));
- if (!pScreenPriv)
- return FALSE;
- dixSetPrivate(&pScreen->devPrivates, fbScreenPrivateKey, pScreenPriv);
- }
+ if (!dixRegisterPrivateKey(&fbScreenPrivateKeyRec, PRIVATE_SCREEN, sizeof (FbScreenPrivRec)))
+ return FALSE;
#endif
+ if (!dixRegisterPrivateKey(&fbWinPrivateKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
return TRUE;
}
diff --git a/xorg-server/fb/fbarc.c b/xorg-server/fb/fbarc.c index 3a8a2c56a..1da980255 100644 --- a/xorg-server/fb/fbarc.c +++ b/xorg-server/fb/fbarc.c @@ -1,149 +1,149 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "fb.h" -#include "mizerarc.h" -#include <limits.h> - -typedef void (*FbArc) (FbBits *dst, - FbStride dstStride, - int dstBpp, - xArc *arc, - int dx, - int dy, - FbBits and, - FbBits xor); - -void -fbPolyArc (DrawablePtr pDrawable, - GCPtr pGC, - int narcs, - xArc *parcs) -{ - FbArc arc; - - if (pGC->lineWidth == 0) - { -#ifndef FBNOPIXADDR - arc = 0; - if (pGC->lineStyle == LineSolid && pGC->fillStyle == FillSolid) - { - switch (pDrawable->bitsPerPixel) - { - case 8: arc = fbArc8; break; - case 16: arc = fbArc16; break; -#ifdef FB_24BIT - case 24: arc = fbArc24; break; -#endif - case 32: arc = fbArc32; break; - } - } - if (arc) - { - FbGCPrivPtr pPriv = fbGetGCPrivate (pGC); - FbBits *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - BoxRec box; - int x2, y2; - RegionPtr cclip; - int wrapped = 0; - - cclip = fbGetCompositeClip (pGC); - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); -#ifdef FB_ACCESS_WRAPPER - wrapped = 1; -#else - wrapped = 0; -#endif - while (narcs--) - { - if (miCanZeroArc (parcs)) - { - box.x1 = parcs->x + pDrawable->x; - box.y1 = parcs->y + pDrawable->y; - /* - * Because box.x2 and box.y2 get truncated to 16 bits, and the - * RECT_IN_REGION test treats the resulting number as a signed - * integer, the RECT_IN_REGION test alone can go the wrong way. - * This can result in a server crash because the rendering - * routines in this file deal directly with cpu addresses - * of pixels to be stored, and do not clip or otherwise check - * that all such addresses are within their respective pixmaps. - * So we only allow the RECT_IN_REGION test to be used for - * values that can be expressed correctly in a signed short. - */ - x2 = box.x1 + (int)parcs->width + 1; - box.x2 = x2; - y2 = box.y1 + (int)parcs->height + 1; - box.y2 = y2; - if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) && - (RECT_IN_REGION(pDrawable->pScreen, cclip, &box) == rgnIN) ) { -#ifdef FB_ACCESS_WRAPPER - if (!wrapped) { - fbPrepareAccess (pDrawable); - wrapped = 1; - } -#endif - (*arc) (dst, dstStride, dstBpp, - parcs, pDrawable->x + dstXoff, pDrawable->y + dstYoff, - pPriv->and, pPriv->xor); - } else { -#ifdef FB_ACCESS_WRAPPER - if (wrapped) { - fbFinishAccess (pDrawable); - wrapped = 0; - } -#endif - miZeroPolyArc(pDrawable, pGC, 1, parcs); - } - } - else { -#ifdef FB_ACCESS_WRAPPER - if (wrapped) { - fbFinishAccess (pDrawable); - wrapped = 0; - } -#endif - miPolyArc(pDrawable, pGC, 1, parcs); - } - parcs++; - } -#ifdef FB_ACCESS_WRAPPER - if (wrapped) { - fbFinishAccess (pDrawable); - wrapped = 0; - } -#endif - } - else -#endif - miZeroPolyArc (pDrawable, pGC, narcs, parcs); - } - else - miPolyArc (pDrawable, pGC, narcs, parcs); -} +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "mizerarc.h"
+#include <limits.h>
+
+typedef void (*FbArc) (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+void
+fbPolyArc (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs)
+{
+ FbArc arc;
+
+ if (pGC->lineWidth == 0)
+ {
+#ifndef FBNOPIXADDR
+ arc = 0;
+ if (pGC->lineStyle == LineSolid && pGC->fillStyle == FillSolid)
+ {
+ switch (pDrawable->bitsPerPixel)
+ {
+ case 8: arc = fbArc8; break;
+ case 16: arc = fbArc16; break;
+#ifdef FB_24BIT
+ case 24: arc = fbArc24; break;
+#endif
+ case 32: arc = fbArc32; break;
+ }
+ }
+ if (arc)
+ {
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ BoxRec box;
+ int x2, y2;
+ RegionPtr cclip;
+ int wrapped = 0;
+
+ cclip = fbGetCompositeClip (pGC);
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+#ifdef FB_ACCESS_WRAPPER
+ wrapped = 1;
+#else
+ wrapped = 0;
+#endif
+ while (narcs--)
+ {
+ if (miCanZeroArc (parcs))
+ {
+ box.x1 = parcs->x + pDrawable->x;
+ box.y1 = parcs->y + pDrawable->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int)parcs->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int)parcs->height + 1;
+ box.y2 = y2;
+ if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) &&
+ (RegionContainsRect(cclip, &box) == rgnIN) ) {
+#ifdef FB_ACCESS_WRAPPER
+ if (!wrapped) {
+ fbPrepareAccess (pDrawable);
+ wrapped = 1;
+ }
+#endif
+ (*arc) (dst, dstStride, dstBpp,
+ parcs, pDrawable->x + dstXoff, pDrawable->y + dstYoff,
+ pPriv->and, pPriv->xor);
+ } else {
+#ifdef FB_ACCESS_WRAPPER
+ if (wrapped) {
+ fbFinishAccess (pDrawable);
+ wrapped = 0;
+ }
+#endif
+ miZeroPolyArc(pDrawable, pGC, 1, parcs);
+ }
+ }
+ else {
+#ifdef FB_ACCESS_WRAPPER
+ if (wrapped) {
+ fbFinishAccess (pDrawable);
+ wrapped = 0;
+ }
+#endif
+ miPolyArc(pDrawable, pGC, 1, parcs);
+ }
+ parcs++;
+ }
+#ifdef FB_ACCESS_WRAPPER
+ if (wrapped) {
+ fbFinishAccess (pDrawable);
+ wrapped = 0;
+ }
+#endif
+ }
+ else
+#endif
+ miZeroPolyArc (pDrawable, pGC, narcs, parcs);
+ }
+ else
+ miPolyArc (pDrawable, pGC, narcs, parcs);
+}
diff --git a/xorg-server/fb/fbbits.h b/xorg-server/fb/fbbits.h index 44991f106..77e792fd7 100644 --- a/xorg-server/fb/fbbits.h +++ b/xorg-server/fb/fbbits.h @@ -1,971 +1,971 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * This file defines functions for drawing some primitives using - * underlying datatypes instead of masks - */ - -#define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & 0x80008000) - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifdef BITSMUL -#define MUL BITSMUL -#else -#define MUL 1 -#endif - -#ifdef BITSSTORE -#define STORE(b,x) BITSSTORE(b,x) -#else -#define STORE(b,x) WRITE((b), (x)) -#endif - -#ifdef BITSRROP -#define RROP(b,a,x) BITSRROP(b,a,x) -#else -#define RROP(b,a,x) WRITE((b), FbDoRRop (READ(b), (a), (x))) -#endif - -#ifdef BITSUNIT -#define UNIT BITSUNIT -#define USE_SOLID -#else -#define UNIT BITS -#endif - -/* - * Define the following before including this file: - * - * BRESSOLID name of function for drawing a solid segment - * BRESDASH name of function for drawing a dashed segment - * DOTS name of function for drawing dots - * ARC name of function for drawing a solid arc - * BITS type of underlying unit - */ - -#ifdef BRESSOLID -void -BRESSOLID (DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x1, - int y1, - int e, - int e1, - int e3, - int len) -{ - FbBits *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - FbGCPrivPtr pPriv = fbGetGCPrivate (pGC); - UNIT *bits; - FbStride bitsStride; - FbStride majorStep, minorStep; - BITS xor = (BITS) pPriv->xor; - - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - bits = ((UNIT *) (dst + ((y1 + dstYoff) * dstStride))) + (x1 + dstXoff) * MUL; - bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT)); - if (signdy < 0) - bitsStride = -bitsStride; - if (axis == X_AXIS) - { - majorStep = signdx * MUL; - minorStep = bitsStride; - } - else - { - majorStep = bitsStride; - minorStep = signdx * MUL; - } - while (len--) - { - STORE(bits,xor); - bits += majorStep; - e += e1; - if (e >= 0) - { - bits += minorStep; - e += e3; - } - } - - fbFinishAccess (pDrawable); -} -#endif - -#ifdef BRESDASH -void -BRESDASH (DrawablePtr pDrawable, - GCPtr pGC, - int dashOffset, - int signdx, - int signdy, - int axis, - int x1, - int y1, - int e, - int e1, - int e3, - int len) -{ - FbBits *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - FbGCPrivPtr pPriv = fbGetGCPrivate (pGC); - UNIT *bits; - FbStride bitsStride; - FbStride majorStep, minorStep; - BITS xorfg, xorbg; - FbDashDeclare; - int dashlen; - Bool even; - Bool doOdd; - - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - doOdd = pGC->lineStyle == LineDoubleDash; - xorfg = (BITS) pPriv->xor; - xorbg = (BITS) pPriv->bgxor; - - FbDashInit (pGC, pPriv, dashOffset, dashlen, even); - - bits = ((UNIT *) (dst + ((y1 + dstYoff) * dstStride))) + (x1 + dstXoff) * MUL; - bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT)); - if (signdy < 0) - bitsStride = -bitsStride; - if (axis == X_AXIS) - { - majorStep = signdx * MUL; - minorStep = bitsStride; - } - else - { - majorStep = bitsStride; - minorStep = signdx * MUL; - } - if (dashlen >= len) - dashlen = len; - if (doOdd) - { - if (!even) - goto doubleOdd; - for (;;) - { - len -= dashlen; - while (dashlen--) - { - STORE(bits,xorfg); - bits += majorStep; - if ((e += e1) >= 0) - { - e += e3; - bits += minorStep; - } - } - if (!len) - break; - - FbDashNextEven(dashlen); - - if (dashlen >= len) - dashlen = len; -doubleOdd: - len -= dashlen; - while (dashlen--) - { - STORE(bits,xorbg); - bits += majorStep; - if ((e += e1) >= 0) - { - e += e3; - bits += minorStep; - } - } - if (!len) - break; - - FbDashNextOdd(dashlen); - - if (dashlen >= len) - dashlen = len; - } - } - else - { - if (!even) - goto onOffOdd; - for (;;) - { - len -= dashlen; - while (dashlen--) - { - STORE(bits,xorfg); - bits += majorStep; - if ((e += e1) >= 0) - { - e += e3; - bits += minorStep; - } - } - if (!len) - break; - - FbDashNextEven (dashlen); - - if (dashlen >= len) - dashlen = len; -onOffOdd: - len -= dashlen; - while (dashlen--) - { - bits += majorStep; - if ((e += e1) >= 0) - { - e += e3; - bits += minorStep; - } - } - if (!len) - break; - - FbDashNextOdd (dashlen); - - if (dashlen >= len) - dashlen = len; - } - } - - fbFinishAccess (pDrawable); -} -#endif - -#ifdef DOTS -void -DOTS (FbBits *dst, - FbStride dstStride, - int dstBpp, - BoxPtr pBox, - xPoint *ptsOrig, - int npt, - int xorg, - int yorg, - int xoff, - int yoff, - FbBits and, - FbBits xor) -{ - INT32 *pts = (INT32 *) ptsOrig; - UNIT *bits = (UNIT *) dst; - UNIT *point; - BITS bxor = (BITS) xor; - BITS band = (BITS) and; - FbStride bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT)); - INT32 ul, lr; - INT32 pt; - - ul = coordToInt(pBox->x1 - xorg, pBox->y1 - yorg); - lr = coordToInt(pBox->x2 - xorg - 1, pBox->y2 - yorg - 1); - - bits += bitsStride * (yorg + yoff) + (xorg + xoff) * MUL; - - if (and == 0) - { - while (npt--) - { - pt = *pts++; - if (!isClipped(pt,ul,lr)) - { - point = bits + intToY(pt) * bitsStride + intToX(pt) * MUL; - STORE(point,bxor); - } - } - } - else - { - while (npt--) - { - pt = *pts++; - if (!isClipped(pt,ul,lr)) - { - point = bits + intToY(pt) * bitsStride + intToX(pt) * MUL; - RROP(point,band,bxor); - } - } - } -} -#endif - -#ifdef ARC - -#define ARCCOPY(d) STORE(d,xorBits) -#define ARCRROP(d) RROP(d,andBits,xorBits) - -void -ARC (FbBits *dst, - FbStride dstStride, - int dstBpp, - xArc *arc, - int drawX, - int drawY, - FbBits and, - FbBits xor) -{ - UNIT *bits; - FbStride bitsStride; - miZeroArcRec info; - Bool do360; - int x; - UNIT *yorgp, *yorgop; - BITS andBits, xorBits; - int yoffset, dyoffset; - int y, a, b, d, mask; - int k1, k3, dx, dy; - - bits = (UNIT *) dst; - bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT)); - andBits = (BITS) and; - xorBits = (BITS) xor; - do360 = miZeroArcSetup(arc, &info, TRUE); - yorgp = bits + ((info.yorg + drawY) * bitsStride); - yorgop = bits + ((info.yorgo + drawY) * bitsStride); - info.xorg = (info.xorg + drawX) * MUL; - info.xorgo = (info.xorgo + drawX) * MUL; - MIARCSETUP(); - yoffset = y ? bitsStride : 0; - dyoffset = 0; - mask = info.initialMask; - - if (!(arc->width & 1)) - { - if (andBits == 0) - { - if (mask & 2) - ARCCOPY(yorgp + info.xorgo); - if (mask & 8) - ARCCOPY(yorgop + info.xorgo); - } - else - { - if (mask & 2) - ARCRROP(yorgp + info.xorgo); - if (mask & 8) - ARCRROP(yorgop + info.xorgo); - } - } - if (!info.end.x || !info.end.y) - { - mask = info.end.mask; - info.end = info.altend; - } - if (do360 && (arc->width == arc->height) && !(arc->width & 1)) - { - int xoffset = bitsStride; - UNIT *yorghb = yorgp + (info.h * bitsStride) + info.xorg; - UNIT *yorgohb = yorghb - info.h * MUL; - - yorgp += info.xorg; - yorgop += info.xorg; - yorghb += info.h * MUL; - while (1) - { - if (andBits == 0) - { - ARCCOPY(yorgp + yoffset + x * MUL); - ARCCOPY(yorgp + yoffset - x * MUL); - ARCCOPY(yorgop - yoffset - x * MUL); - ARCCOPY(yorgop - yoffset + x * MUL); - } - else - { - ARCRROP(yorgp + yoffset + x * MUL); - ARCRROP(yorgp + yoffset - x * MUL); - ARCRROP(yorgop - yoffset - x * MUL); - ARCRROP(yorgop - yoffset + x * MUL); - } - if (a < 0) - break; - if (andBits == 0) - { - ARCCOPY(yorghb - xoffset - y * MUL); - ARCCOPY(yorgohb - xoffset + y * MUL); - ARCCOPY(yorgohb + xoffset + y * MUL); - ARCCOPY(yorghb + xoffset - y * MUL); - } - else - { - ARCRROP(yorghb - xoffset - y * MUL); - ARCRROP(yorgohb - xoffset + y * MUL); - ARCRROP(yorgohb + xoffset + y * MUL); - ARCRROP(yorghb + xoffset - y * MUL); - } - xoffset += bitsStride; - MIARCCIRCLESTEP(yoffset += bitsStride;); - } - yorgp -= info.xorg; - yorgop -= info.xorg; - x = info.w; - yoffset = info.h * bitsStride; - } - else if (do360) - { - while (y < info.h || x < info.w) - { - MIARCOCTANTSHIFT(dyoffset = bitsStride;); - if (andBits == 0) - { - ARCCOPY(yorgp + yoffset + info.xorg + x * MUL); - ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL); - ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL); - ARCCOPY(yorgop - yoffset + info.xorg + x * MUL); - } - else - { - ARCRROP(yorgp + yoffset + info.xorg + x * MUL); - ARCRROP(yorgp + yoffset + info.xorgo - x * MUL); - ARCRROP(yorgop - yoffset + info.xorgo - x * MUL); - ARCRROP(yorgop - yoffset + info.xorg + x * MUL); - } - MIARCSTEP(yoffset += dyoffset;, yoffset += bitsStride;); - } - } - else - { - while (y < info.h || x < info.w) - { - MIARCOCTANTSHIFT(dyoffset = bitsStride;); - if ((x == info.start.x) || (y == info.start.y)) - { - mask = info.start.mask; - info.start = info.altstart; - } - if (andBits == 0) - { - if (mask & 1) - ARCCOPY(yorgp + yoffset + info.xorg + x * MUL); - if (mask & 2) - ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL); - if (mask & 4) - ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL); - if (mask & 8) - ARCCOPY(yorgop - yoffset + info.xorg + x * MUL); - } - else - { - if (mask & 1) - ARCRROP(yorgp + yoffset + info.xorg + x * MUL); - if (mask & 2) - ARCRROP(yorgp + yoffset + info.xorgo - x * MUL); - if (mask & 4) - ARCRROP(yorgop - yoffset + info.xorgo - x * MUL); - if (mask & 8) - ARCRROP(yorgop - yoffset + info.xorg + x * MUL); - } - if ((x == info.end.x) || (y == info.end.y)) - { - mask = info.end.mask; - info.end = info.altend; - } - MIARCSTEP(yoffset += dyoffset;, yoffset += bitsStride;); - } - } - if ((x == info.start.x) || (y == info.start.y)) - mask = info.start.mask; - if (andBits == 0) - { - if (mask & 1) - ARCCOPY(yorgp + yoffset + info.xorg + x * MUL); - if (mask & 4) - ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL); - if (arc->height & 1) - { - if (mask & 2) - ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL); - if (mask & 8) - ARCCOPY(yorgop - yoffset + info.xorg + x * MUL); - } - } - else - { - if (mask & 1) - ARCRROP(yorgp + yoffset + info.xorg + x * MUL); - if (mask & 4) - ARCRROP(yorgop - yoffset + info.xorgo - x * MUL); - if (arc->height & 1) - { - if (mask & 2) - ARCRROP(yorgp + yoffset + info.xorgo - x * MUL); - if (mask & 8) - ARCRROP(yorgop - yoffset + info.xorg + x * MUL); - } - } -} -#undef ARCCOPY -#undef ARCRROP -#endif - -#ifdef GLYPH -#if BITMAP_BIT_ORDER == LSBFirst -# define WRITE_ADDR1(n) (n) -# define WRITE_ADDR2(n) (n) -# define WRITE_ADDR4(n) (n) -#else -# define WRITE_ADDR1(n) ((n) ^ 3) -# define WRITE_ADDR2(n) ((n) ^ 2) -# define WRITE_ADDR4(n) ((n)) -#endif - -#define WRITE1(d,n,fg) WRITE(d + WRITE_ADDR1(n), (BITS) (fg)) - -#ifdef BITS2 -# define WRITE2(d,n,fg) WRITE((BITS2 *) &((d)[WRITE_ADDR2(n)]), (BITS2) (fg)) -#else -# define WRITE2(d,n,fg) (WRITE1(d,n,fg), WRITE1(d,(n)+1,fg)) -#endif - -#ifdef BITS4 -# define WRITE4(d,n,fg) WRITE((BITS4 *) &((d)[WRITE_ADDR4(n)]), (BITS4) (fg)) -#else -# define WRITE4(d,n,fg) (WRITE2(d,n,fg), WRITE2(d,(n)+2,fg)) -#endif - -void -GLYPH (FbBits *dstBits, - FbStride dstStride, - int dstBpp, - FbStip *stipple, - FbBits fg, - int x, - int height) -{ - int lshift; - FbStip bits; - BITS *dstLine; - BITS *dst; - int n; - int shift; - - dstLine = (BITS *) dstBits; - dstLine += x & ~3; - dstStride *= (sizeof (FbBits) / sizeof (BITS)); - shift = x & 3; - lshift = 4 - shift; - while (height--) - { - bits = *stipple++; - dst = (BITS *) dstLine; - n = lshift; - while (bits) - { - switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) { - case 0: - break; - case 1: - WRITE1(dst,0,fg); - break; - case 2: - WRITE1(dst,1,fg); - break; - case 3: - WRITE2(dst,0,fg); - break; - case 4: - WRITE1(dst,2,fg); - break; - case 5: - WRITE1(dst,0,fg); - WRITE1(dst,2,fg); - break; - case 6: - WRITE1(dst,1,fg); - WRITE1(dst,2,fg); - break; - case 7: - WRITE2(dst,0,fg); - WRITE1(dst,2,fg); - break; - case 8: - WRITE1(dst,3,fg); - break; - case 9: - WRITE1(dst,0,fg); - WRITE1(dst,3,fg); - break; - case 10: - WRITE1(dst,1,fg); - WRITE1(dst,3,fg); - break; - case 11: - WRITE2(dst,0,fg); - WRITE1(dst,3,fg); - break; - case 12: - WRITE2(dst,2,fg); - break; - case 13: - WRITE1(dst,0,fg); - WRITE2(dst,2,fg); - break; - case 14: - WRITE1(dst,1,fg); - WRITE2(dst,2,fg); - break; - case 15: - WRITE4(dst,0,fg); - break; - } - bits = FbStipLeft (bits, n); - n = 4; - dst += 4; - } - dstLine += dstStride; - } -} -#undef WRITE_ADDR1 -#undef WRITE_ADDR2 -#undef WRITE_ADDR4 -#undef WRITE1 -#undef WRITE2 -#undef WRITE4 - -#endif - -#ifdef POLYLINE -void -POLYLINE (DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr ptsOrig) -{ - INT32 *pts = (INT32 *) ptsOrig; - int xoff = pDrawable->x; - int yoff = pDrawable->y; - unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); - BoxPtr pBox = REGION_EXTENTS (pDrawable->pScreen, fbGetCompositeClip (pGC)); - - FbBits *dst; - int dstStride; - int dstBpp; - int dstXoff, dstYoff; - - UNIT *bits, *bitsBase; - FbStride bitsStride; - BITS xor = fbGetGCPrivate(pGC)->xor; - BITS and = fbGetGCPrivate(pGC)->and; - int dashoffset = 0; - - INT32 ul, lr; - INT32 pt1, pt2; - - int e, e1, e3, len; - int stepmajor, stepminor; - int octant; - - if (mode == CoordModePrevious) - fbFixCoordModePrevious (npt, ptsOrig); - - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT)); - bitsBase = ((UNIT *) dst) + (yoff + dstYoff) * bitsStride + (xoff + dstXoff) * MUL; - ul = coordToInt(pBox->x1 - xoff, pBox->y1 - yoff); - lr = coordToInt(pBox->x2 - xoff - 1, pBox->y2 - yoff - 1); - - pt1 = *pts++; - npt--; - pt2 = *pts++; - npt--; - for (;;) - { - if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr)) - { - fbSegment (pDrawable, pGC, - intToX(pt1) + xoff, intToY(pt1) + yoff, - intToX(pt2) + xoff, intToY(pt2) + yoff, - npt == 0 && pGC->capStyle != CapNotLast, - &dashoffset); - if (!npt) { - fbFinishAccess (pDrawable); - return; - } - pt1 = pt2; - pt2 = *pts++; - npt--; - } - else - { - bits = bitsBase + intToY(pt1) * bitsStride + intToX(pt1) * MUL; - for (;;) - { - CalcLineDeltas (intToX(pt1), intToY(pt1), - intToX(pt2), intToY(pt2), - len, e1, stepmajor, stepminor, 1, bitsStride, - octant); - stepmajor *= MUL; - if (len < e1) - { - e3 = len; - len = e1; - e1 = e3; - - e3 = stepminor; - stepminor = stepmajor; - stepmajor = e3; - SetYMajorOctant(octant); - } - e = -len; - e1 <<= 1; - e3 = e << 1; - FIXUP_ERROR (e, octant, bias); - if (and == 0) - { - while (len--) - { - STORE(bits,xor); - bits += stepmajor; - e += e1; - if (e >= 0) - { - bits += stepminor; - e += e3; - } - } - } - else - { - while (len--) - { - RROP(bits,and,xor); - bits += stepmajor; - e += e1; - if (e >= 0) - { - bits += stepminor; - e += e3; - } - } - } - if (!npt) - { - if (pGC->capStyle != CapNotLast && - pt2 != *((INT32 *) ptsOrig)) - { - RROP(bits,and,xor); - } - fbFinishAccess (pDrawable); - return; - } - pt1 = pt2; - pt2 = *pts++; - --npt; - if (isClipped (pt2, ul, lr)) - break; - } - } - } - - fbFinishAccess (pDrawable); -} -#endif - -#ifdef POLYSEGMENT -void -POLYSEGMENT (DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pseg) -{ - INT32 *pts = (INT32 *) pseg; - int xoff = pDrawable->x; - int yoff = pDrawable->y; - unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); - BoxPtr pBox = REGION_EXTENTS (pDrawable->pScreen, fbGetCompositeClip (pGC)); - - FbBits *dst; - int dstStride; - int dstBpp; - int dstXoff, dstYoff; - - UNIT *bits, *bitsBase; - FbStride bitsStride; - FbBits xorBits = fbGetGCPrivate(pGC)->xor; - FbBits andBits = fbGetGCPrivate(pGC)->and; - BITS xor = xorBits; - BITS and = andBits; - int dashoffset = 0; - - INT32 ul, lr; - INT32 pt1, pt2; - - int e, e1, e3, len; - int stepmajor, stepminor; - int octant; - Bool capNotLast; - - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT)); - bitsBase = ((UNIT *) dst) + (yoff + dstYoff) * bitsStride + (xoff + dstXoff) * MUL; - ul = coordToInt(pBox->x1 - xoff, pBox->y1 - yoff); - lr = coordToInt(pBox->x2 - xoff - 1, pBox->y2 - yoff - 1); - - capNotLast = pGC->capStyle == CapNotLast; - - while (nseg--) - { - pt1 = *pts++; - pt2 = *pts++; - if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr)) - { - fbSegment (pDrawable, pGC, - intToX(pt1) + xoff, intToY(pt1) + yoff, - intToX(pt2) + xoff, intToY(pt2) + yoff, - !capNotLast, &dashoffset); - } - else - { - CalcLineDeltas (intToX(pt1), intToY(pt1), - intToX(pt2), intToY(pt2), - len, e1, stepmajor, stepminor, 1, bitsStride, - octant); - if (e1 == 0 && len > 3 -#if MUL != 1 - && FbCheck24Pix(and) && FbCheck24Pix(xor) -#endif - ) - { - int x1, x2; - FbBits *dstLine; - int dstX, width; - FbBits startmask, endmask; - int nmiddle; - - if (stepmajor < 0) - { - x1 = intToX(pt2); - x2 = intToX(pt1) + 1; - if (capNotLast) - x1++; - } - else - { - x1 = intToX(pt1); - x2 = intToX(pt2); - if (!capNotLast) - x2++; - } - dstX = (x1 + xoff + dstXoff) * (sizeof (UNIT) * 8 * MUL); - width = (x2 - x1) * (sizeof (UNIT) * 8 * MUL); - - dstLine = dst + (intToY(pt1) + yoff + dstYoff) * dstStride; - dstLine += dstX >> FB_SHIFT; - dstX &= FB_MASK; - FbMaskBits (dstX, width, startmask, nmiddle, endmask); - if (startmask) - { - WRITE(dstLine, FbDoMaskRRop (READ(dstLine), andBits, xorBits, startmask)); - dstLine++; - } - if (!andBits) - while (nmiddle--) - WRITE(dstLine++, xorBits); - else - while (nmiddle--) - { - WRITE(dstLine, FbDoRRop (READ(dstLine), andBits, xorBits)); - dstLine++; - } - if (endmask) - WRITE(dstLine, FbDoMaskRRop (READ(dstLine), andBits, xorBits, endmask)); - } - else - { - stepmajor *= MUL; - bits = bitsBase + intToY(pt1) * bitsStride + intToX(pt1) * MUL; - if (len < e1) - { - e3 = len; - len = e1; - e1 = e3; - - e3 = stepminor; - stepminor = stepmajor; - stepmajor = e3; - SetYMajorOctant(octant); - } - e = -len; - e1 <<= 1; - e3 = e << 1; - FIXUP_ERROR (e, octant, bias); - if (!capNotLast) - len++; - if (and == 0) - { - while (len--) - { - STORE(bits,xor); - bits += stepmajor; - e += e1; - if (e >= 0) - { - bits += stepminor; - e += e3; - } - } - } - else - { - while (len--) - { - RROP(bits,and,xor); - bits += stepmajor; - e += e1; - if (e >= 0) - { - bits += stepminor; - e += e3; - } - } - } - } - } - } - - fbFinishAccess (pDrawable); -} -#endif - -#undef MUL -#undef STORE -#undef RROP -#undef UNIT -#undef USE_SOLID - -#undef isClipped +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * This file defines functions for drawing some primitives using
+ * underlying datatypes instead of masks
+ */
+
+#define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & 0x80008000)
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef BITSMUL
+#define MUL BITSMUL
+#else
+#define MUL 1
+#endif
+
+#ifdef BITSSTORE
+#define STORE(b,x) BITSSTORE(b,x)
+#else
+#define STORE(b,x) WRITE((b), (x))
+#endif
+
+#ifdef BITSRROP
+#define RROP(b,a,x) BITSRROP(b,a,x)
+#else
+#define RROP(b,a,x) WRITE((b), FbDoRRop (READ(b), (a), (x)))
+#endif
+
+#ifdef BITSUNIT
+#define UNIT BITSUNIT
+#define USE_SOLID
+#else
+#define UNIT BITS
+#endif
+
+/*
+ * Define the following before including this file:
+ *
+ * BRESSOLID name of function for drawing a solid segment
+ * BRESDASH name of function for drawing a dashed segment
+ * DOTS name of function for drawing dots
+ * ARC name of function for drawing a solid arc
+ * BITS type of underlying unit
+ */
+
+#ifdef BRESSOLID
+void
+BRESSOLID (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ UNIT *bits;
+ FbStride bitsStride;
+ FbStride majorStep, minorStep;
+ BITS xor = (BITS) pPriv->xor;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ bits = ((UNIT *) (dst + ((y1 + dstYoff) * dstStride))) + (x1 + dstXoff) * MUL;
+ bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ if (signdy < 0)
+ bitsStride = -bitsStride;
+ if (axis == X_AXIS)
+ {
+ majorStep = signdx * MUL;
+ minorStep = bitsStride;
+ }
+ else
+ {
+ majorStep = bitsStride;
+ minorStep = signdx * MUL;
+ }
+ while (len--)
+ {
+ STORE(bits,xor);
+ bits += majorStep;
+ e += e1;
+ if (e >= 0)
+ {
+ bits += minorStep;
+ e += e3;
+ }
+ }
+
+ fbFinishAccess (pDrawable);
+}
+#endif
+
+#ifdef BRESDASH
+void
+BRESDASH (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ UNIT *bits;
+ FbStride bitsStride;
+ FbStride majorStep, minorStep;
+ BITS xorfg, xorbg;
+ FbDashDeclare;
+ int dashlen;
+ Bool even;
+ Bool doOdd;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ doOdd = pGC->lineStyle == LineDoubleDash;
+ xorfg = (BITS) pPriv->xor;
+ xorbg = (BITS) pPriv->bgxor;
+
+ FbDashInit (pGC, pPriv, dashOffset, dashlen, even);
+
+ bits = ((UNIT *) (dst + ((y1 + dstYoff) * dstStride))) + (x1 + dstXoff) * MUL;
+ bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ if (signdy < 0)
+ bitsStride = -bitsStride;
+ if (axis == X_AXIS)
+ {
+ majorStep = signdx * MUL;
+ minorStep = bitsStride;
+ }
+ else
+ {
+ majorStep = bitsStride;
+ minorStep = signdx * MUL;
+ }
+ if (dashlen >= len)
+ dashlen = len;
+ if (doOdd)
+ {
+ if (!even)
+ goto doubleOdd;
+ for (;;)
+ {
+ len -= dashlen;
+ while (dashlen--)
+ {
+ STORE(bits,xorfg);
+ bits += majorStep;
+ if ((e += e1) >= 0)
+ {
+ e += e3;
+ bits += minorStep;
+ }
+ }
+ if (!len)
+ break;
+
+ FbDashNextEven(dashlen);
+
+ if (dashlen >= len)
+ dashlen = len;
+doubleOdd:
+ len -= dashlen;
+ while (dashlen--)
+ {
+ STORE(bits,xorbg);
+ bits += majorStep;
+ if ((e += e1) >= 0)
+ {
+ e += e3;
+ bits += minorStep;
+ }
+ }
+ if (!len)
+ break;
+
+ FbDashNextOdd(dashlen);
+
+ if (dashlen >= len)
+ dashlen = len;
+ }
+ }
+ else
+ {
+ if (!even)
+ goto onOffOdd;
+ for (;;)
+ {
+ len -= dashlen;
+ while (dashlen--)
+ {
+ STORE(bits,xorfg);
+ bits += majorStep;
+ if ((e += e1) >= 0)
+ {
+ e += e3;
+ bits += minorStep;
+ }
+ }
+ if (!len)
+ break;
+
+ FbDashNextEven (dashlen);
+
+ if (dashlen >= len)
+ dashlen = len;
+onOffOdd:
+ len -= dashlen;
+ while (dashlen--)
+ {
+ bits += majorStep;
+ if ((e += e1) >= 0)
+ {
+ e += e3;
+ bits += minorStep;
+ }
+ }
+ if (!len)
+ break;
+
+ FbDashNextOdd (dashlen);
+
+ if (dashlen >= len)
+ dashlen = len;
+ }
+ }
+
+ fbFinishAccess (pDrawable);
+}
+#endif
+
+#ifdef DOTS
+void
+DOTS (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *ptsOrig,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor)
+{
+ INT32 *pts = (INT32 *) ptsOrig;
+ UNIT *bits = (UNIT *) dst;
+ UNIT *point;
+ BITS bxor = (BITS) xor;
+ BITS band = (BITS) and;
+ FbStride bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ INT32 ul, lr;
+ INT32 pt;
+
+ ul = coordToInt(pBox->x1 - xorg, pBox->y1 - yorg);
+ lr = coordToInt(pBox->x2 - xorg - 1, pBox->y2 - yorg - 1);
+
+ bits += bitsStride * (yorg + yoff) + (xorg + xoff) * MUL;
+
+ if (and == 0)
+ {
+ while (npt--)
+ {
+ pt = *pts++;
+ if (!isClipped(pt,ul,lr))
+ {
+ point = bits + intToY(pt) * bitsStride + intToX(pt) * MUL;
+ STORE(point,bxor);
+ }
+ }
+ }
+ else
+ {
+ while (npt--)
+ {
+ pt = *pts++;
+ if (!isClipped(pt,ul,lr))
+ {
+ point = bits + intToY(pt) * bitsStride + intToX(pt) * MUL;
+ RROP(point,band,bxor);
+ }
+ }
+ }
+}
+#endif
+
+#ifdef ARC
+
+#define ARCCOPY(d) STORE(d,xorBits)
+#define ARCRROP(d) RROP(d,andBits,xorBits)
+
+void
+ARC (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int drawX,
+ int drawY,
+ FbBits and,
+ FbBits xor)
+{
+ UNIT *bits;
+ FbStride bitsStride;
+ miZeroArcRec info;
+ Bool do360;
+ int x;
+ UNIT *yorgp, *yorgop;
+ BITS andBits, xorBits;
+ int yoffset, dyoffset;
+ int y, a, b, d, mask;
+ int k1, k3, dx, dy;
+
+ bits = (UNIT *) dst;
+ bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ andBits = (BITS) and;
+ xorBits = (BITS) xor;
+ do360 = miZeroArcSetup(arc, &info, TRUE);
+ yorgp = bits + ((info.yorg + drawY) * bitsStride);
+ yorgop = bits + ((info.yorgo + drawY) * bitsStride);
+ info.xorg = (info.xorg + drawX) * MUL;
+ info.xorgo = (info.xorgo + drawX) * MUL;
+ MIARCSETUP();
+ yoffset = y ? bitsStride : 0;
+ dyoffset = 0;
+ mask = info.initialMask;
+
+ if (!(arc->width & 1))
+ {
+ if (andBits == 0)
+ {
+ if (mask & 2)
+ ARCCOPY(yorgp + info.xorgo);
+ if (mask & 8)
+ ARCCOPY(yorgop + info.xorgo);
+ }
+ else
+ {
+ if (mask & 2)
+ ARCRROP(yorgp + info.xorgo);
+ if (mask & 8)
+ ARCRROP(yorgop + info.xorgo);
+ }
+ }
+ if (!info.end.x || !info.end.y)
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ if (do360 && (arc->width == arc->height) && !(arc->width & 1))
+ {
+ int xoffset = bitsStride;
+ UNIT *yorghb = yorgp + (info.h * bitsStride) + info.xorg;
+ UNIT *yorgohb = yorghb - info.h * MUL;
+
+ yorgp += info.xorg;
+ yorgop += info.xorg;
+ yorghb += info.h * MUL;
+ while (1)
+ {
+ if (andBits == 0)
+ {
+ ARCCOPY(yorgp + yoffset + x * MUL);
+ ARCCOPY(yorgp + yoffset - x * MUL);
+ ARCCOPY(yorgop - yoffset - x * MUL);
+ ARCCOPY(yorgop - yoffset + x * MUL);
+ }
+ else
+ {
+ ARCRROP(yorgp + yoffset + x * MUL);
+ ARCRROP(yorgp + yoffset - x * MUL);
+ ARCRROP(yorgop - yoffset - x * MUL);
+ ARCRROP(yorgop - yoffset + x * MUL);
+ }
+ if (a < 0)
+ break;
+ if (andBits == 0)
+ {
+ ARCCOPY(yorghb - xoffset - y * MUL);
+ ARCCOPY(yorgohb - xoffset + y * MUL);
+ ARCCOPY(yorgohb + xoffset + y * MUL);
+ ARCCOPY(yorghb + xoffset - y * MUL);
+ }
+ else
+ {
+ ARCRROP(yorghb - xoffset - y * MUL);
+ ARCRROP(yorgohb - xoffset + y * MUL);
+ ARCRROP(yorgohb + xoffset + y * MUL);
+ ARCRROP(yorghb + xoffset - y * MUL);
+ }
+ xoffset += bitsStride;
+ MIARCCIRCLESTEP(yoffset += bitsStride;);
+ }
+ yorgp -= info.xorg;
+ yorgop -= info.xorg;
+ x = info.w;
+ yoffset = info.h * bitsStride;
+ }
+ else if (do360)
+ {
+ while (y < info.h || x < info.w)
+ {
+ MIARCOCTANTSHIFT(dyoffset = bitsStride;);
+ if (andBits == 0)
+ {
+ ARCCOPY(yorgp + yoffset + info.xorg + x * MUL);
+ ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL);
+ ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL);
+ ARCCOPY(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ else
+ {
+ ARCRROP(yorgp + yoffset + info.xorg + x * MUL);
+ ARCRROP(yorgp + yoffset + info.xorgo - x * MUL);
+ ARCRROP(yorgop - yoffset + info.xorgo - x * MUL);
+ ARCRROP(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ MIARCSTEP(yoffset += dyoffset;, yoffset += bitsStride;);
+ }
+ }
+ else
+ {
+ while (y < info.h || x < info.w)
+ {
+ MIARCOCTANTSHIFT(dyoffset = bitsStride;);
+ if ((x == info.start.x) || (y == info.start.y))
+ {
+ mask = info.start.mask;
+ info.start = info.altstart;
+ }
+ if (andBits == 0)
+ {
+ if (mask & 1)
+ ARCCOPY(yorgp + yoffset + info.xorg + x * MUL);
+ if (mask & 2)
+ ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL);
+ if (mask & 4)
+ ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL);
+ if (mask & 8)
+ ARCCOPY(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ else
+ {
+ if (mask & 1)
+ ARCRROP(yorgp + yoffset + info.xorg + x * MUL);
+ if (mask & 2)
+ ARCRROP(yorgp + yoffset + info.xorgo - x * MUL);
+ if (mask & 4)
+ ARCRROP(yorgop - yoffset + info.xorgo - x * MUL);
+ if (mask & 8)
+ ARCRROP(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ if ((x == info.end.x) || (y == info.end.y))
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ MIARCSTEP(yoffset += dyoffset;, yoffset += bitsStride;);
+ }
+ }
+ if ((x == info.start.x) || (y == info.start.y))
+ mask = info.start.mask;
+ if (andBits == 0)
+ {
+ if (mask & 1)
+ ARCCOPY(yorgp + yoffset + info.xorg + x * MUL);
+ if (mask & 4)
+ ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL);
+ if (arc->height & 1)
+ {
+ if (mask & 2)
+ ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL);
+ if (mask & 8)
+ ARCCOPY(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ }
+ else
+ {
+ if (mask & 1)
+ ARCRROP(yorgp + yoffset + info.xorg + x * MUL);
+ if (mask & 4)
+ ARCRROP(yorgop - yoffset + info.xorgo - x * MUL);
+ if (arc->height & 1)
+ {
+ if (mask & 2)
+ ARCRROP(yorgp + yoffset + info.xorgo - x * MUL);
+ if (mask & 8)
+ ARCRROP(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ }
+}
+#undef ARCCOPY
+#undef ARCRROP
+#endif
+
+#ifdef GLYPH
+#if BITMAP_BIT_ORDER == LSBFirst
+# define WRITE_ADDR1(n) (n)
+# define WRITE_ADDR2(n) (n)
+# define WRITE_ADDR4(n) (n)
+#else
+# define WRITE_ADDR1(n) ((n) ^ 3)
+# define WRITE_ADDR2(n) ((n) ^ 2)
+# define WRITE_ADDR4(n) ((n))
+#endif
+
+#define WRITE1(d,n,fg) WRITE(d + WRITE_ADDR1(n), (BITS) (fg))
+
+#ifdef BITS2
+# define WRITE2(d,n,fg) WRITE((BITS2 *) &((d)[WRITE_ADDR2(n)]), (BITS2) (fg))
+#else
+# define WRITE2(d,n,fg) (WRITE1(d,n,fg), WRITE1(d,(n)+1,fg))
+#endif
+
+#ifdef BITS4
+# define WRITE4(d,n,fg) WRITE((BITS4 *) &((d)[WRITE_ADDR4(n)]), (BITS4) (fg))
+#else
+# define WRITE4(d,n,fg) (WRITE2(d,n,fg), WRITE2(d,(n)+2,fg))
+#endif
+
+void
+GLYPH (FbBits *dstBits,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int x,
+ int height)
+{
+ int lshift;
+ FbStip bits;
+ BITS *dstLine;
+ BITS *dst;
+ int n;
+ int shift;
+
+ dstLine = (BITS *) dstBits;
+ dstLine += x & ~3;
+ dstStride *= (sizeof (FbBits) / sizeof (BITS));
+ shift = x & 3;
+ lshift = 4 - shift;
+ while (height--)
+ {
+ bits = *stipple++;
+ dst = (BITS *) dstLine;
+ n = lshift;
+ while (bits)
+ {
+ switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) {
+ case 0:
+ break;
+ case 1:
+ WRITE1(dst,0,fg);
+ break;
+ case 2:
+ WRITE1(dst,1,fg);
+ break;
+ case 3:
+ WRITE2(dst,0,fg);
+ break;
+ case 4:
+ WRITE1(dst,2,fg);
+ break;
+ case 5:
+ WRITE1(dst,0,fg);
+ WRITE1(dst,2,fg);
+ break;
+ case 6:
+ WRITE1(dst,1,fg);
+ WRITE1(dst,2,fg);
+ break;
+ case 7:
+ WRITE2(dst,0,fg);
+ WRITE1(dst,2,fg);
+ break;
+ case 8:
+ WRITE1(dst,3,fg);
+ break;
+ case 9:
+ WRITE1(dst,0,fg);
+ WRITE1(dst,3,fg);
+ break;
+ case 10:
+ WRITE1(dst,1,fg);
+ WRITE1(dst,3,fg);
+ break;
+ case 11:
+ WRITE2(dst,0,fg);
+ WRITE1(dst,3,fg);
+ break;
+ case 12:
+ WRITE2(dst,2,fg);
+ break;
+ case 13:
+ WRITE1(dst,0,fg);
+ WRITE2(dst,2,fg);
+ break;
+ case 14:
+ WRITE1(dst,1,fg);
+ WRITE2(dst,2,fg);
+ break;
+ case 15:
+ WRITE4(dst,0,fg);
+ break;
+ }
+ bits = FbStipLeft (bits, n);
+ n = 4;
+ dst += 4;
+ }
+ dstLine += dstStride;
+ }
+}
+#undef WRITE_ADDR1
+#undef WRITE_ADDR2
+#undef WRITE_ADDR4
+#undef WRITE1
+#undef WRITE2
+#undef WRITE4
+
+#endif
+
+#ifdef POLYLINE
+void
+POLYLINE (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig)
+{
+ INT32 *pts = (INT32 *) ptsOrig;
+ int xoff = pDrawable->x;
+ int yoff = pDrawable->y;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ BoxPtr pBox = RegionExtents(fbGetCompositeClip (pGC));
+
+ FbBits *dst;
+ int dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ UNIT *bits, *bitsBase;
+ FbStride bitsStride;
+ BITS xor = fbGetGCPrivate(pGC)->xor;
+ BITS and = fbGetGCPrivate(pGC)->and;
+ int dashoffset = 0;
+
+ INT32 ul, lr;
+ INT32 pt1, pt2;
+
+ int e, e1, e3, len;
+ int stepmajor, stepminor;
+ int octant;
+
+ if (mode == CoordModePrevious)
+ fbFixCoordModePrevious (npt, ptsOrig);
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ bitsBase = ((UNIT *) dst) + (yoff + dstYoff) * bitsStride + (xoff + dstXoff) * MUL;
+ ul = coordToInt(pBox->x1 - xoff, pBox->y1 - yoff);
+ lr = coordToInt(pBox->x2 - xoff - 1, pBox->y2 - yoff - 1);
+
+ pt1 = *pts++;
+ npt--;
+ pt2 = *pts++;
+ npt--;
+ for (;;)
+ {
+ if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr))
+ {
+ fbSegment (pDrawable, pGC,
+ intToX(pt1) + xoff, intToY(pt1) + yoff,
+ intToX(pt2) + xoff, intToY(pt2) + yoff,
+ npt == 0 && pGC->capStyle != CapNotLast,
+ &dashoffset);
+ if (!npt) {
+ fbFinishAccess (pDrawable);
+ return;
+ }
+ pt1 = pt2;
+ pt2 = *pts++;
+ npt--;
+ }
+ else
+ {
+ bits = bitsBase + intToY(pt1) * bitsStride + intToX(pt1) * MUL;
+ for (;;)
+ {
+ CalcLineDeltas (intToX(pt1), intToY(pt1),
+ intToX(pt2), intToY(pt2),
+ len, e1, stepmajor, stepminor, 1, bitsStride,
+ octant);
+ stepmajor *= MUL;
+ if (len < e1)
+ {
+ e3 = len;
+ len = e1;
+ e1 = e3;
+
+ e3 = stepminor;
+ stepminor = stepmajor;
+ stepmajor = e3;
+ SetYMajorOctant(octant);
+ }
+ e = -len;
+ e1 <<= 1;
+ e3 = e << 1;
+ FIXUP_ERROR (e, octant, bias);
+ if (and == 0)
+ {
+ while (len--)
+ {
+ STORE(bits,xor);
+ bits += stepmajor;
+ e += e1;
+ if (e >= 0)
+ {
+ bits += stepminor;
+ e += e3;
+ }
+ }
+ }
+ else
+ {
+ while (len--)
+ {
+ RROP(bits,and,xor);
+ bits += stepmajor;
+ e += e1;
+ if (e >= 0)
+ {
+ bits += stepminor;
+ e += e3;
+ }
+ }
+ }
+ if (!npt)
+ {
+ if (pGC->capStyle != CapNotLast &&
+ pt2 != *((INT32 *) ptsOrig))
+ {
+ RROP(bits,and,xor);
+ }
+ fbFinishAccess (pDrawable);
+ return;
+ }
+ pt1 = pt2;
+ pt2 = *pts++;
+ --npt;
+ if (isClipped (pt2, ul, lr))
+ break;
+ }
+ }
+ }
+
+ fbFinishAccess (pDrawable);
+}
+#endif
+
+#ifdef POLYSEGMENT
+void
+POLYSEGMENT (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg)
+{
+ INT32 *pts = (INT32 *) pseg;
+ int xoff = pDrawable->x;
+ int yoff = pDrawable->y;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ BoxPtr pBox = RegionExtents(fbGetCompositeClip (pGC));
+
+ FbBits *dst;
+ int dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ UNIT *bits, *bitsBase;
+ FbStride bitsStride;
+ FbBits xorBits = fbGetGCPrivate(pGC)->xor;
+ FbBits andBits = fbGetGCPrivate(pGC)->and;
+ BITS xor = xorBits;
+ BITS and = andBits;
+ int dashoffset = 0;
+
+ INT32 ul, lr;
+ INT32 pt1, pt2;
+
+ int e, e1, e3, len;
+ int stepmajor, stepminor;
+ int octant;
+ Bool capNotLast;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ bitsBase = ((UNIT *) dst) + (yoff + dstYoff) * bitsStride + (xoff + dstXoff) * MUL;
+ ul = coordToInt(pBox->x1 - xoff, pBox->y1 - yoff);
+ lr = coordToInt(pBox->x2 - xoff - 1, pBox->y2 - yoff - 1);
+
+ capNotLast = pGC->capStyle == CapNotLast;
+
+ while (nseg--)
+ {
+ pt1 = *pts++;
+ pt2 = *pts++;
+ if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr))
+ {
+ fbSegment (pDrawable, pGC,
+ intToX(pt1) + xoff, intToY(pt1) + yoff,
+ intToX(pt2) + xoff, intToY(pt2) + yoff,
+ !capNotLast, &dashoffset);
+ }
+ else
+ {
+ CalcLineDeltas (intToX(pt1), intToY(pt1),
+ intToX(pt2), intToY(pt2),
+ len, e1, stepmajor, stepminor, 1, bitsStride,
+ octant);
+ if (e1 == 0 && len > 3
+#if MUL != 1
+ && FbCheck24Pix(and) && FbCheck24Pix(xor)
+#endif
+ )
+ {
+ int x1, x2;
+ FbBits *dstLine;
+ int dstX, width;
+ FbBits startmask, endmask;
+ int nmiddle;
+
+ if (stepmajor < 0)
+ {
+ x1 = intToX(pt2);
+ x2 = intToX(pt1) + 1;
+ if (capNotLast)
+ x1++;
+ }
+ else
+ {
+ x1 = intToX(pt1);
+ x2 = intToX(pt2);
+ if (!capNotLast)
+ x2++;
+ }
+ dstX = (x1 + xoff + dstXoff) * (sizeof (UNIT) * 8 * MUL);
+ width = (x2 - x1) * (sizeof (UNIT) * 8 * MUL);
+
+ dstLine = dst + (intToY(pt1) + yoff + dstYoff) * dstStride;
+ dstLine += dstX >> FB_SHIFT;
+ dstX &= FB_MASK;
+ FbMaskBits (dstX, width, startmask, nmiddle, endmask);
+ if (startmask)
+ {
+ WRITE(dstLine, FbDoMaskRRop (READ(dstLine), andBits, xorBits, startmask));
+ dstLine++;
+ }
+ if (!andBits)
+ while (nmiddle--)
+ WRITE(dstLine++, xorBits);
+ else
+ while (nmiddle--)
+ {
+ WRITE(dstLine, FbDoRRop (READ(dstLine), andBits, xorBits));
+ dstLine++;
+ }
+ if (endmask)
+ WRITE(dstLine, FbDoMaskRRop (READ(dstLine), andBits, xorBits, endmask));
+ }
+ else
+ {
+ stepmajor *= MUL;
+ bits = bitsBase + intToY(pt1) * bitsStride + intToX(pt1) * MUL;
+ if (len < e1)
+ {
+ e3 = len;
+ len = e1;
+ e1 = e3;
+
+ e3 = stepminor;
+ stepminor = stepmajor;
+ stepmajor = e3;
+ SetYMajorOctant(octant);
+ }
+ e = -len;
+ e1 <<= 1;
+ e3 = e << 1;
+ FIXUP_ERROR (e, octant, bias);
+ if (!capNotLast)
+ len++;
+ if (and == 0)
+ {
+ while (len--)
+ {
+ STORE(bits,xor);
+ bits += stepmajor;
+ e += e1;
+ if (e >= 0)
+ {
+ bits += stepminor;
+ e += e3;
+ }
+ }
+ }
+ else
+ {
+ while (len--)
+ {
+ RROP(bits,and,xor);
+ bits += stepmajor;
+ e += e1;
+ if (e >= 0)
+ {
+ bits += stepminor;
+ e += e3;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ fbFinishAccess (pDrawable);
+}
+#endif
+
+#undef MUL
+#undef STORE
+#undef RROP
+#undef UNIT
+#undef USE_SOLID
+
+#undef isClipped
diff --git a/xorg-server/fb/fbcmap.c b/xorg-server/fb/fbcmap.c index e656c2399..123b7f41d 100644 --- a/xorg-server/fb/fbcmap.c +++ b/xorg-server/fb/fbcmap.c @@ -36,8 +36,8 @@ #error "You should be compiling fbcmap_mi.c instead of fbcmap.c!"
#endif
-static int cmapScrPrivateKeyIndex;
-static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex;
+static DevPrivateKeyRec cmapScrPrivateKeyRec;
+#define cmapScrPrivateKey (&cmapScrPrivateKeyRec)
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))
@@ -48,7 +48,7 @@ fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) /* By the time we are processing requests, we can guarantee that there
* is always a colormap installed */
*pmaps = GetInstalledColormap(pScreen)->mid;
- return (1);
+ return 1;
}
diff --git a/xorg-server/fb/fbfill.c b/xorg-server/fb/fbfill.c index 831b1ce76..664d6a82e 100644 --- a/xorg-server/fb/fbfill.c +++ b/xorg-server/fb/fbfill.c @@ -1,230 +1,230 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "fb.h" - -void -fbFill (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int width, - int height) -{ - FbBits *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); - - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - - switch (pGC->fillStyle) { - case FillSolid: -#ifndef FB_ACCESS_WRAPPER - if (pPriv->and || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp, - x + dstXoff, y + dstYoff, - width, height, - pPriv->xor)) -#endif - fbSolid (dst + (y + dstYoff) * dstStride, - dstStride, - (x + dstXoff) * dstBpp, - dstBpp, - width * dstBpp, height, - pPriv->and, pPriv->xor); - break; - case FillStippled: - case FillOpaqueStippled: { - PixmapPtr pStip = pGC->stipple; - int stipWidth = pStip->drawable.width; - int stipHeight = pStip->drawable.height; - - if (dstBpp == 1) - { - int alu; - FbBits *stip; - FbStride stipStride; - int stipBpp; - int stipXoff, stipYoff; /* XXX assumed to be zero */ - - if (pGC->fillStyle == FillStippled) - alu = FbStipple1Rop(pGC->alu,pGC->fgPixel); - else - alu = FbOpaqueStipple1Rop(pGC->alu,pGC->fgPixel,pGC->bgPixel); - fbGetDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff); - fbTile (dst + (y + dstYoff) * dstStride, - dstStride, - x + dstXoff, - width, height, - stip, - stipStride, - stipWidth, - stipHeight, - alu, - pPriv->pm, - dstBpp, - - (pGC->patOrg.x + pDrawable->x + dstXoff), - pGC->patOrg.y + pDrawable->y - y); - fbFinishAccess (&pStip->drawable); - } - else - { - FbStip *stip; - FbStride stipStride; - int stipBpp; - int stipXoff, stipYoff; /* XXX assumed to be zero */ - FbBits fgand, fgxor, bgand, bgxor; - - fgand = pPriv->and; - fgxor = pPriv->xor; - if (pGC->fillStyle == FillStippled) - { - bgand = fbAnd(GXnoop,(FbBits) 0,FB_ALLONES); - bgxor = fbXor(GXnoop,(FbBits) 0,FB_ALLONES); - } - else - { - bgand = pPriv->bgand; - bgxor = pPriv->bgxor; - } - - fbGetStipDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff); - fbStipple (dst + (y + dstYoff) * dstStride, - dstStride, - (x + dstXoff) * dstBpp, - dstBpp, - width * dstBpp, height, - stip, - stipStride, - stipWidth, - stipHeight, - pPriv->evenStipple, - fgand, fgxor, - bgand, bgxor, - pGC->patOrg.x + pDrawable->x + dstXoff, - pGC->patOrg.y + pDrawable->y - y); - fbFinishAccess (&pStip->drawable); - } - break; - } - case FillTiled: { - PixmapPtr pTile = pGC->tile.pixmap; - FbBits *tile; - FbStride tileStride; - int tileBpp; - int tileWidth; - int tileHeight; - int tileXoff, tileYoff; /* XXX assumed to be zero */ - - fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp, tileXoff, tileYoff); - tileWidth = pTile->drawable.width; - tileHeight = pTile->drawable.height; - fbTile (dst + (y + dstYoff) * dstStride, - dstStride, - (x + dstXoff) * dstBpp, - width * dstBpp, height, - tile, - tileStride, - tileWidth * tileBpp, - tileHeight, - pGC->alu, - pPriv->pm, - dstBpp, - (pGC->patOrg.x + pDrawable->x + dstXoff) * dstBpp, - pGC->patOrg.y + pDrawable->y - y); - fbFinishAccess (&pTile->drawable); - break; - } - } - fbValidateDrawable (pDrawable); - fbFinishAccess (pDrawable); -} - -void -fbSolidBoxClipped (DrawablePtr pDrawable, - RegionPtr pClip, - int x1, - int y1, - int x2, - int y2, - FbBits and, - FbBits xor) -{ - FbBits *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - BoxPtr pbox; - int nbox; - int partX1, partX2, partY1, partY2; - - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - - for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip); - nbox--; - pbox++) - { - partX1 = pbox->x1; - if (partX1 < x1) - partX1 = x1; - - partX2 = pbox->x2; - if (partX2 > x2) - partX2 = x2; - - if (partX2 <= partX1) - continue; - - partY1 = pbox->y1; - if (partY1 < y1) - partY1 = y1; - - partY2 = pbox->y2; - if (partY2 > y2) - partY2 = y2; - - if (partY2 <= partY1) - continue; - -#ifndef FB_ACCESS_WRAPPER - if (and || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp, - partX1 + dstXoff, partY1 + dstYoff, - (partX2 - partX1), (partY2 - partY1), - xor)) -#endif - fbSolid (dst + (partY1 + dstYoff) * dstStride, - dstStride, - (partX1 + dstXoff) * dstBpp, - dstBpp, - - (partX2 - partX1) * dstBpp, - (partY2 - partY1), - and, xor); - } - fbFinishAccess (pDrawable); -} +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ switch (pGC->fillStyle) {
+ case FillSolid:
+#ifndef FB_ACCESS_WRAPPER
+ if (pPriv->and || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp,
+ x + dstXoff, y + dstYoff,
+ width, height,
+ pPriv->xor))
+#endif
+ fbSolid (dst + (y + dstYoff) * dstStride,
+ dstStride,
+ (x + dstXoff) * dstBpp,
+ dstBpp,
+ width * dstBpp, height,
+ pPriv->and, pPriv->xor);
+ break;
+ case FillStippled:
+ case FillOpaqueStippled: {
+ PixmapPtr pStip = pGC->stipple;
+ int stipWidth = pStip->drawable.width;
+ int stipHeight = pStip->drawable.height;
+
+ if (dstBpp == 1)
+ {
+ int alu;
+ FbBits *stip;
+ FbStride stipStride;
+ int stipBpp;
+ int stipXoff, stipYoff; /* XXX assumed to be zero */
+
+ if (pGC->fillStyle == FillStippled)
+ alu = FbStipple1Rop(pGC->alu,pGC->fgPixel);
+ else
+ alu = FbOpaqueStipple1Rop(pGC->alu,pGC->fgPixel,pGC->bgPixel);
+ fbGetDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
+ fbTile (dst + (y + dstYoff) * dstStride,
+ dstStride,
+ x + dstXoff,
+ width, height,
+ stip,
+ stipStride,
+ stipWidth,
+ stipHeight,
+ alu,
+ pPriv->pm,
+ dstBpp,
+
+ (pGC->patOrg.x + pDrawable->x + dstXoff),
+ pGC->patOrg.y + pDrawable->y - y);
+ fbFinishAccess (&pStip->drawable);
+ }
+ else
+ {
+ FbStip *stip;
+ FbStride stipStride;
+ int stipBpp;
+ int stipXoff, stipYoff; /* XXX assumed to be zero */
+ FbBits fgand, fgxor, bgand, bgxor;
+
+ fgand = pPriv->and;
+ fgxor = pPriv->xor;
+ if (pGC->fillStyle == FillStippled)
+ {
+ bgand = fbAnd(GXnoop,(FbBits) 0,FB_ALLONES);
+ bgxor = fbXor(GXnoop,(FbBits) 0,FB_ALLONES);
+ }
+ else
+ {
+ bgand = pPriv->bgand;
+ bgxor = pPriv->bgxor;
+ }
+
+ fbGetStipDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
+ fbStipple (dst + (y + dstYoff) * dstStride,
+ dstStride,
+ (x + dstXoff) * dstBpp,
+ dstBpp,
+ width * dstBpp, height,
+ stip,
+ stipStride,
+ stipWidth,
+ stipHeight,
+ pPriv->evenStipple,
+ fgand, fgxor,
+ bgand, bgxor,
+ pGC->patOrg.x + pDrawable->x + dstXoff,
+ pGC->patOrg.y + pDrawable->y - y);
+ fbFinishAccess (&pStip->drawable);
+ }
+ break;
+ }
+ case FillTiled: {
+ PixmapPtr pTile = pGC->tile.pixmap;
+ FbBits *tile;
+ FbStride tileStride;
+ int tileBpp;
+ int tileWidth;
+ int tileHeight;
+ int tileXoff, tileYoff; /* XXX assumed to be zero */
+
+ fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp, tileXoff, tileYoff);
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+ fbTile (dst + (y + dstYoff) * dstStride,
+ dstStride,
+ (x + dstXoff) * dstBpp,
+ width * dstBpp, height,
+ tile,
+ tileStride,
+ tileWidth * tileBpp,
+ tileHeight,
+ pGC->alu,
+ pPriv->pm,
+ dstBpp,
+ (pGC->patOrg.x + pDrawable->x + dstXoff) * dstBpp,
+ pGC->patOrg.y + pDrawable->y - y);
+ fbFinishAccess (&pTile->drawable);
+ break;
+ }
+ }
+ fbValidateDrawable (pDrawable);
+ fbFinishAccess (pDrawable);
+}
+
+void
+fbSolidBoxClipped (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ FbBits and,
+ FbBits xor)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ BoxPtr pbox;
+ int nbox;
+ int partX1, partX2, partY1, partY2;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ for (nbox = RegionNumRects(pClip), pbox = RegionRects(pClip);
+ nbox--;
+ pbox++)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < x1)
+ partX1 = x1;
+
+ partX2 = pbox->x2;
+ if (partX2 > x2)
+ partX2 = x2;
+
+ if (partX2 <= partX1)
+ continue;
+
+ partY1 = pbox->y1;
+ if (partY1 < y1)
+ partY1 = y1;
+
+ partY2 = pbox->y2;
+ if (partY2 > y2)
+ partY2 = y2;
+
+ if (partY2 <= partY1)
+ continue;
+
+#ifndef FB_ACCESS_WRAPPER
+ if (and || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp,
+ partX1 + dstXoff, partY1 + dstYoff,
+ (partX2 - partX1), (partY2 - partY1),
+ xor))
+#endif
+ fbSolid (dst + (partY1 + dstYoff) * dstStride,
+ dstStride,
+ (partX1 + dstXoff) * dstBpp,
+ dstBpp,
+
+ (partX2 - partX1) * dstBpp,
+ (partY2 - partY1),
+ and, xor);
+ }
+ fbFinishAccess (pDrawable);
+}
diff --git a/xorg-server/fb/fbfillrect.c b/xorg-server/fb/fbfillrect.c index 4e4edb3fd..66ed77fa5 100644 --- a/xorg-server/fb/fbfillrect.c +++ b/xorg-server/fb/fbfillrect.c @@ -1,112 +1,112 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "fb.h" - -void -fbPolyFillRect(DrawablePtr pDrawable, - GCPtr pGC, - int nrect, - xRectangle *prect) -{ - RegionPtr pClip = fbGetCompositeClip(pGC); - register BoxPtr pbox; - BoxPtr pextent; - int extentX1, extentX2, extentY1, extentY2; - int fullX1, fullX2, fullY1, fullY2; - int partX1, partX2, partY1, partY2; - int xorg, yorg; - int n; - - xorg = pDrawable->x; - yorg = pDrawable->y; - - pextent = REGION_EXTENTS(pGC->pScreen, pClip); - extentX1 = pextent->x1; - extentY1 = pextent->y1; - extentX2 = pextent->x2; - extentY2 = pextent->y2; - while (nrect--) - { - fullX1 = prect->x + xorg; - fullY1 = prect->y + yorg; - fullX2 = fullX1 + (int) prect->width; - fullY2 = fullY1 + (int) prect->height; - prect++; - - if (fullX1 < extentX1) - fullX1 = extentX1; - - if (fullY1 < extentY1) - fullY1 = extentY1; - - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullY2 > extentY2) - fullY2 = extentY2; - - if ((fullX1 >= fullX2) || (fullY1 >= fullY2)) - continue; - n = REGION_NUM_RECTS (pClip); - if (n == 1) - { - fbFill (pDrawable, - pGC, - fullX1, fullY1, fullX2-fullX1, fullY2-fullY1); - } - else - { - pbox = REGION_RECTS(pClip); - /* - * clip the rectangle to each box in the clip region - * this is logically equivalent to calling Intersect() - */ - while(n--) - { - partX1 = pbox->x1; - if (partX1 < fullX1) - partX1 = fullX1; - partY1 = pbox->y1; - if (partY1 < fullY1) - partY1 = fullY1; - partX2 = pbox->x2; - if (partX2 > fullX2) - partX2 = fullX2; - partY2 = pbox->y2; - if (partY2 > fullY2) - partY2 = fullY2; - - pbox++; - - if (partX1 < partX2 && partY1 < partY2) - fbFill (pDrawable, pGC, - partX1, partY1, - partX2 - partX1, partY2 - partY1); - } - } - } -} +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbPolyFillRect(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nrect,
+ xRectangle *prect)
+{
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ register BoxPtr pbox;
+ BoxPtr pextent;
+ int extentX1, extentX2, extentY1, extentY2;
+ int fullX1, fullX2, fullY1, fullY2;
+ int partX1, partX2, partY1, partY2;
+ int xorg, yorg;
+ int n;
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+
+ pextent = RegionExtents(pClip);
+ extentX1 = pextent->x1;
+ extentY1 = pextent->y1;
+ extentX2 = pextent->x2;
+ extentY2 = pextent->y2;
+ while (nrect--)
+ {
+ fullX1 = prect->x + xorg;
+ fullY1 = prect->y + yorg;
+ fullX2 = fullX1 + (int) prect->width;
+ fullY2 = fullY1 + (int) prect->height;
+ prect++;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+
+ if (fullY1 < extentY1)
+ fullY1 = extentY1;
+
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullY2 > extentY2)
+ fullY2 = extentY2;
+
+ if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
+ continue;
+ n = RegionNumRects (pClip);
+ if (n == 1)
+ {
+ fbFill (pDrawable,
+ pGC,
+ fullX1, fullY1, fullX2-fullX1, fullY2-fullY1);
+ }
+ else
+ {
+ pbox = RegionRects(pClip);
+ /*
+ * clip the rectangle to each box in the clip region
+ * this is logically equivalent to calling Intersect()
+ */
+ while(n--)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < fullX1)
+ partX1 = fullX1;
+ partY1 = pbox->y1;
+ if (partY1 < fullY1)
+ partY1 = fullY1;
+ partX2 = pbox->x2;
+ if (partX2 > fullX2)
+ partX2 = fullX2;
+ partY2 = pbox->y2;
+ if (partY2 > fullY2)
+ partY2 = fullY2;
+
+ pbox++;
+
+ if (partX1 < partX2 && partY1 < partY2)
+ fbFill (pDrawable, pGC,
+ partX1, partY1,
+ partX2 - partX1, partY2 - partY1);
+ }
+ }
+ }
+}
diff --git a/xorg-server/fb/fbfillsp.c b/xorg-server/fb/fbfillsp.c index 5d2147213..16c33943f 100644 --- a/xorg-server/fb/fbfillsp.c +++ b/xorg-server/fb/fbfillsp.c @@ -1,100 +1,100 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "fb.h" - -void -fbFillSpans (DrawablePtr pDrawable, - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted) -{ - RegionPtr pClip = fbGetCompositeClip(pGC); - BoxPtr pextent, pbox; - int nbox; - int extentX1, extentX2, extentY1, extentY2; - int fullX1, fullX2, fullY1; - int partX1, partX2; - - pextent = REGION_EXTENTS(pGC->pScreen, pClip); - extentX1 = pextent->x1; - extentY1 = pextent->y1; - extentX2 = pextent->x2; - extentY2 = pextent->y2; - while (n--) - { - fullX1 = ppt->x; - fullY1 = ppt->y; - fullX2 = fullX1 + (int) *pwidth; - ppt++; - pwidth++; - - if (fullY1 < extentY1 || extentY2 <= fullY1) - continue; - - if (fullX1 < extentX1) - fullX1 = extentX1; - - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullX1 >= fullX2) - continue; - - nbox = REGION_NUM_RECTS (pClip); - if (nbox == 1) - { - fbFill (pDrawable, - pGC, - fullX1, fullY1, fullX2-fullX1, 1); - } - else - { - pbox = REGION_RECTS(pClip); - while(nbox--) - { - if (pbox->y1 <= fullY1 && fullY1 < pbox->y2) - { - partX1 = pbox->x1; - if (partX1 < fullX1) - partX1 = fullX1; - partX2 = pbox->x2; - if (partX2 > fullX2) - partX2 = fullX2; - if (partX2 > partX1) - { - fbFill (pDrawable, pGC, - partX1, fullY1, - partX2 - partX1, 1); - } - } - pbox++; - } - } - } -} +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbFillSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted)
+{
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ BoxPtr pextent, pbox;
+ int nbox;
+ int extentX1, extentX2, extentY1, extentY2;
+ int fullX1, fullX2, fullY1;
+ int partX1, partX2;
+
+ pextent = RegionExtents(pClip);
+ extentX1 = pextent->x1;
+ extentY1 = pextent->y1;
+ extentX2 = pextent->x2;
+ extentY2 = pextent->y2;
+ while (n--)
+ {
+ fullX1 = ppt->x;
+ fullY1 = ppt->y;
+ fullX2 = fullX1 + (int) *pwidth;
+ ppt++;
+ pwidth++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ nbox = RegionNumRects (pClip);
+ if (nbox == 1)
+ {
+ fbFill (pDrawable,
+ pGC,
+ fullX1, fullY1, fullX2-fullX1, 1);
+ }
+ else
+ {
+ pbox = RegionRects(pClip);
+ while(nbox--)
+ {
+ if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < fullX1)
+ partX1 = fullX1;
+ partX2 = pbox->x2;
+ if (partX2 > fullX2)
+ partX2 = fullX2;
+ if (partX2 > partX1)
+ {
+ fbFill (pDrawable, pGC,
+ partX1, fullY1,
+ partX2 - partX1, 1);
+ }
+ }
+ pbox++;
+ }
+ }
+ }
+}
diff --git a/xorg-server/fb/fbgc.c b/xorg-server/fb/fbgc.c index fda391b14..7b63b889e 100644 --- a/xorg-server/fb/fbgc.c +++ b/xorg-server/fb/fbgc.c @@ -1,319 +1,319 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdlib.h> - -#include "fb.h" - -const GCFuncs fbGCFuncs = { - fbValidateGC, - miChangeGC, - miCopyGC, - miDestroyGC, - miChangeClip, - miDestroyClip, - miCopyClip, -}; - -const GCOps fbGCOps = { - fbFillSpans, - fbSetSpans, - fbPutImage, - fbCopyArea, - fbCopyPlane, - fbPolyPoint, - fbPolyLine, - fbPolySegment, - fbPolyRectangle, - fbPolyArc, - miFillPolygon, - fbPolyFillRect, - fbPolyFillArc, - miPolyText8, - miPolyText16, - miImageText8, - miImageText16, - fbImageGlyphBlt, - fbPolyGlyphBlt, - fbPushPixels -}; - -Bool -fbCreateGC(GCPtr pGC) -{ - pGC->clientClip = NULL; - pGC->clientClipType = CT_NONE; - - pGC->ops = (GCOps *) &fbGCOps; - pGC->funcs = (GCFuncs *) &fbGCFuncs; - - /* fb wants to translate before scan conversion */ - pGC->miTranslate = 1; - - fbGetRotatedPixmap(pGC) = 0; - fbGetExpose(pGC) = 1; - fbGetFreeCompClip(pGC) = 0; - fbGetCompositeClip(pGC) = 0; - fbGetGCPrivate(pGC)->bpp = BitsPerPixel (pGC->depth); - return TRUE; -} - -/* - * Pad pixmap to FB_UNIT bits wide - */ -void -fbPadPixmap (PixmapPtr pPixmap) -{ - int width; - FbBits *bits; - FbBits b; - FbBits mask; - int height; - int w; - int stride; - int bpp; - int xOff, yOff; - - fbGetDrawable (&pPixmap->drawable, bits, stride, bpp, xOff, yOff); - - width = pPixmap->drawable.width * pPixmap->drawable.bitsPerPixel; - height = pPixmap->drawable.height; - mask = FbBitsMask (0, width); - while (height--) - { - b = READ(bits) & mask; - w = width; - while (w < FB_UNIT) - { - b = b | FbScrRight(b, w); - w <<= 1; - } - WRITE(bits, b); - bits += stride; - } - - fbFinishAccess (&pPixmap->drawable); -} - -/* - * Verify that 'bits' repeats every 'len' bits - */ -static Bool -fbBitsRepeat (FbBits bits, int len, int width) -{ - FbBits mask = FbBitsMask(0, len); - FbBits orig = bits & mask; - int i; - - if (width > FB_UNIT) - width = FB_UNIT; - for (i = 0; i < width / len; i++) - { - if ((bits & mask) != orig) - return FALSE; - bits = FbScrLeft(bits,len); - } - return TRUE; -} - -/* - * Check whether an entire bitmap line is a repetition of - * the first 'len' bits - */ -static Bool -fbLineRepeat (FbBits *bits, int len, int width) -{ - FbBits first = bits[0]; - - if (!fbBitsRepeat (first, len, width)) - return FALSE; - width = (width + FB_UNIT-1) >> FB_SHIFT; - bits++; - while (--width) - if (READ(bits) != first) - return FALSE; - return TRUE; -} - -/* - * The even stipple code wants the first FB_UNIT/bpp bits on - * each scanline to represent the entire stipple - */ -static Bool -fbCanEvenStipple (PixmapPtr pStipple, int bpp) -{ - int len = FB_UNIT / bpp; - FbBits *bits; - int stride; - int stip_bpp; - int stipXoff, stipYoff; - int h; - - /* can't even stipple 24bpp drawables */ - if ((bpp & (bpp-1)) != 0) - return FALSE; - /* make sure the stipple width is a multiple of the even stipple width */ - if (pStipple->drawable.width % len != 0) - return FALSE; - fbGetDrawable (&pStipple->drawable, bits, stride, stip_bpp, stipXoff, stipYoff); - h = pStipple->drawable.height; - /* check to see that the stipple repeats horizontally */ - while (h--) - { - if (!fbLineRepeat (bits, len, pStipple->drawable.width)) { - fbFinishAccess (&pStipple->drawable); - return FALSE; - } - bits += stride; - } - fbFinishAccess (&pStipple->drawable); - return TRUE; -} - -void -fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) -{ - FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); - FbBits mask; - - pGC->lastWinOrg.x = pDrawable->x; - pGC->lastWinOrg.y = pDrawable->y; - - /* - * if the client clip is different or moved OR the subwindowMode has - * changed OR the window's clip has changed since the last validation - * we need to recompute the composite clip - */ - - if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) || - (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)) - ) - { - miComputeCompositeClip (pGC, pDrawable); - pPriv->oneRect = REGION_NUM_RECTS(fbGetCompositeClip(pGC)) == 1; - } - -#ifdef FB_24_32BIT - if (pPriv->bpp != pDrawable->bitsPerPixel) - { - changes |= GCStipple|GCForeground|GCBackground|GCPlaneMask; - pPriv->bpp = pDrawable->bitsPerPixel; - } - if ((changes & GCTile) && fbGetRotatedPixmap(pGC)) - { - (*pGC->pScreen->DestroyPixmap) (fbGetRotatedPixmap(pGC)); - fbGetRotatedPixmap(pGC) = 0; - } - - if (pGC->fillStyle == FillTiled) - { - PixmapPtr pOldTile, pNewTile; - - pOldTile = pGC->tile.pixmap; - if (pOldTile->drawable.bitsPerPixel != pDrawable->bitsPerPixel) - { - pNewTile = fbGetRotatedPixmap(pGC); - if (!pNewTile || pNewTile ->drawable.bitsPerPixel != pDrawable->bitsPerPixel) - { - if (pNewTile) - (*pGC->pScreen->DestroyPixmap) (pNewTile); - pNewTile = fb24_32ReformatTile (pOldTile, pDrawable->bitsPerPixel); - } - if (pNewTile) - { - fbGetRotatedPixmap(pGC) = pOldTile; - pGC->tile.pixmap = pNewTile; - changes |= GCTile; - } - } - } -#endif - if (changes & GCTile) - { - if (!pGC->tileIsPixel && - FbEvenTile (pGC->tile.pixmap->drawable.width * - pDrawable->bitsPerPixel)) - fbPadPixmap (pGC->tile.pixmap); - } - if (changes & GCStipple) - { - pPriv->evenStipple = FALSE; - - if (pGC->stipple) { - - /* can we do an even stipple ?? */ - if (FbEvenStip (pGC->stipple->drawable.width, - pDrawable->bitsPerPixel) && - (fbCanEvenStipple (pGC->stipple, pDrawable->bitsPerPixel))) - pPriv->evenStipple = TRUE; - - if (pGC->stipple->drawable.width * pDrawable->bitsPerPixel < FB_UNIT) - fbPadPixmap (pGC->stipple); - } - } - /* - * Recompute reduced rop values - */ - if (changes & (GCForeground|GCBackground|GCPlaneMask|GCFunction)) - { - int s; - FbBits depthMask; - - mask = FbFullMask(pDrawable->bitsPerPixel); - depthMask = FbFullMask(pDrawable->depth); - - pPriv->fg = pGC->fgPixel & mask; - pPriv->bg = pGC->bgPixel & mask; - - if ((pGC->planemask & depthMask) == depthMask) - pPriv->pm = mask; - else - pPriv->pm = pGC->planemask & mask; - - s = pDrawable->bitsPerPixel; - while (s < FB_UNIT) - { - pPriv->fg |= pPriv->fg << s; - pPriv->bg |= pPriv->bg << s; - pPriv->pm |= pPriv->pm << s; - s <<= 1; - } - pPriv->and = fbAnd(pGC->alu, pPriv->fg, pPriv->pm); - pPriv->xor = fbXor(pGC->alu, pPriv->fg, pPriv->pm); - pPriv->bgand = fbAnd(pGC->alu, pPriv->bg, pPriv->pm); - pPriv->bgxor = fbXor(pGC->alu, pPriv->bg, pPriv->pm); - } - if (changes & GCDashList) - { - unsigned short n = pGC->numInDashList; - unsigned char *dash = pGC->dash; - unsigned int dashLength = 0; - - while (n--) - dashLength += (unsigned int ) *dash++; - pPriv->dashLength = dashLength; - } -} +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "fb.h"
+
+const GCFuncs fbGCFuncs = {
+ fbValidateGC,
+ miChangeGC,
+ miCopyGC,
+ miDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip,
+};
+
+const GCOps fbGCOps = {
+ fbFillSpans,
+ fbSetSpans,
+ fbPutImage,
+ fbCopyArea,
+ fbCopyPlane,
+ fbPolyPoint,
+ fbPolyLine,
+ fbPolySegment,
+ fbPolyRectangle,
+ fbPolyArc,
+ miFillPolygon,
+ fbPolyFillRect,
+ fbPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ fbImageGlyphBlt,
+ fbPolyGlyphBlt,
+ fbPushPixels
+};
+
+Bool
+fbCreateGC(GCPtr pGC)
+{
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+
+ pGC->ops = (GCOps *) &fbGCOps;
+ pGC->funcs = (GCFuncs *) &fbGCFuncs;
+
+ /* fb wants to translate before scan conversion */
+ pGC->miTranslate = 1;
+
+ fbGetRotatedPixmap(pGC) = 0;
+ fbGetExpose(pGC) = 1;
+ fbGetFreeCompClip(pGC) = 0;
+ fbGetCompositeClip(pGC) = 0;
+ fbGetGCPrivate(pGC)->bpp = BitsPerPixel (pGC->depth);
+ return TRUE;
+}
+
+/*
+ * Pad pixmap to FB_UNIT bits wide
+ */
+void
+fbPadPixmap (PixmapPtr pPixmap)
+{
+ int width;
+ FbBits *bits;
+ FbBits b;
+ FbBits mask;
+ int height;
+ int w;
+ int stride;
+ int bpp;
+ int xOff, yOff;
+
+ fbGetDrawable (&pPixmap->drawable, bits, stride, bpp, xOff, yOff);
+
+ width = pPixmap->drawable.width * pPixmap->drawable.bitsPerPixel;
+ height = pPixmap->drawable.height;
+ mask = FbBitsMask (0, width);
+ while (height--)
+ {
+ b = READ(bits) & mask;
+ w = width;
+ while (w < FB_UNIT)
+ {
+ b = b | FbScrRight(b, w);
+ w <<= 1;
+ }
+ WRITE(bits, b);
+ bits += stride;
+ }
+
+ fbFinishAccess (&pPixmap->drawable);
+}
+
+/*
+ * Verify that 'bits' repeats every 'len' bits
+ */
+static Bool
+fbBitsRepeat (FbBits bits, int len, int width)
+{
+ FbBits mask = FbBitsMask(0, len);
+ FbBits orig = bits & mask;
+ int i;
+
+ if (width > FB_UNIT)
+ width = FB_UNIT;
+ for (i = 0; i < width / len; i++)
+ {
+ if ((bits & mask) != orig)
+ return FALSE;
+ bits = FbScrLeft(bits,len);
+ }
+ return TRUE;
+}
+
+/*
+ * Check whether an entire bitmap line is a repetition of
+ * the first 'len' bits
+ */
+static Bool
+fbLineRepeat (FbBits *bits, int len, int width)
+{
+ FbBits first = bits[0];
+
+ if (!fbBitsRepeat (first, len, width))
+ return FALSE;
+ width = (width + FB_UNIT-1) >> FB_SHIFT;
+ bits++;
+ while (--width)
+ if (READ(bits) != first)
+ return FALSE;
+ return TRUE;
+}
+
+/*
+ * The even stipple code wants the first FB_UNIT/bpp bits on
+ * each scanline to represent the entire stipple
+ */
+static Bool
+fbCanEvenStipple (PixmapPtr pStipple, int bpp)
+{
+ int len = FB_UNIT / bpp;
+ FbBits *bits;
+ int stride;
+ int stip_bpp;
+ int stipXoff, stipYoff;
+ int h;
+
+ /* can't even stipple 24bpp drawables */
+ if ((bpp & (bpp-1)) != 0)
+ return FALSE;
+ /* make sure the stipple width is a multiple of the even stipple width */
+ if (pStipple->drawable.width % len != 0)
+ return FALSE;
+ fbGetDrawable (&pStipple->drawable, bits, stride, stip_bpp, stipXoff, stipYoff);
+ h = pStipple->drawable.height;
+ /* check to see that the stipple repeats horizontally */
+ while (h--)
+ {
+ if (!fbLineRepeat (bits, len, pStipple->drawable.width)) {
+ fbFinishAccess (&pStipple->drawable);
+ return FALSE;
+ }
+ bits += stride;
+ }
+ fbFinishAccess (&pStipple->drawable);
+ return TRUE;
+}
+
+void
+fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ FbBits mask;
+
+ pGC->lastWinOrg.x = pDrawable->x;
+ pGC->lastWinOrg.y = pDrawable->y;
+
+ /*
+ * if the client clip is different or moved OR the subwindowMode has
+ * changed OR the window's clip has changed since the last validation
+ * we need to recompute the composite clip
+ */
+
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
+ )
+ {
+ miComputeCompositeClip (pGC, pDrawable);
+ pPriv->oneRect = RegionNumRects(fbGetCompositeClip(pGC)) == 1;
+ }
+
+#ifdef FB_24_32BIT
+ if (pPriv->bpp != pDrawable->bitsPerPixel)
+ {
+ changes |= GCStipple|GCForeground|GCBackground|GCPlaneMask;
+ pPriv->bpp = pDrawable->bitsPerPixel;
+ }
+ if ((changes & GCTile) && fbGetRotatedPixmap(pGC))
+ {
+ (*pGC->pScreen->DestroyPixmap) (fbGetRotatedPixmap(pGC));
+ fbGetRotatedPixmap(pGC) = 0;
+ }
+
+ if (pGC->fillStyle == FillTiled)
+ {
+ PixmapPtr pOldTile, pNewTile;
+
+ pOldTile = pGC->tile.pixmap;
+ if (pOldTile->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
+ {
+ pNewTile = fbGetRotatedPixmap(pGC);
+ if (!pNewTile || pNewTile ->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
+ {
+ if (pNewTile)
+ (*pGC->pScreen->DestroyPixmap) (pNewTile);
+ pNewTile = fb24_32ReformatTile (pOldTile, pDrawable->bitsPerPixel);
+ }
+ if (pNewTile)
+ {
+ fbGetRotatedPixmap(pGC) = pOldTile;
+ pGC->tile.pixmap = pNewTile;
+ changes |= GCTile;
+ }
+ }
+ }
+#endif
+ if (changes & GCTile)
+ {
+ if (!pGC->tileIsPixel &&
+ FbEvenTile (pGC->tile.pixmap->drawable.width *
+ pDrawable->bitsPerPixel))
+ fbPadPixmap (pGC->tile.pixmap);
+ }
+ if (changes & GCStipple)
+ {
+ pPriv->evenStipple = FALSE;
+
+ if (pGC->stipple) {
+
+ /* can we do an even stipple ?? */
+ if (FbEvenStip (pGC->stipple->drawable.width,
+ pDrawable->bitsPerPixel) &&
+ (fbCanEvenStipple (pGC->stipple, pDrawable->bitsPerPixel)))
+ pPriv->evenStipple = TRUE;
+
+ if (pGC->stipple->drawable.width * pDrawable->bitsPerPixel < FB_UNIT)
+ fbPadPixmap (pGC->stipple);
+ }
+ }
+ /*
+ * Recompute reduced rop values
+ */
+ if (changes & (GCForeground|GCBackground|GCPlaneMask|GCFunction))
+ {
+ int s;
+ FbBits depthMask;
+
+ mask = FbFullMask(pDrawable->bitsPerPixel);
+ depthMask = FbFullMask(pDrawable->depth);
+
+ pPriv->fg = pGC->fgPixel & mask;
+ pPriv->bg = pGC->bgPixel & mask;
+
+ if ((pGC->planemask & depthMask) == depthMask)
+ pPriv->pm = mask;
+ else
+ pPriv->pm = pGC->planemask & mask;
+
+ s = pDrawable->bitsPerPixel;
+ while (s < FB_UNIT)
+ {
+ pPriv->fg |= pPriv->fg << s;
+ pPriv->bg |= pPriv->bg << s;
+ pPriv->pm |= pPriv->pm << s;
+ s <<= 1;
+ }
+ pPriv->and = fbAnd(pGC->alu, pPriv->fg, pPriv->pm);
+ pPriv->xor = fbXor(pGC->alu, pPriv->fg, pPriv->pm);
+ pPriv->bgand = fbAnd(pGC->alu, pPriv->bg, pPriv->pm);
+ pPriv->bgxor = fbXor(pGC->alu, pPriv->bg, pPriv->pm);
+ }
+ if (changes & GCDashList)
+ {
+ unsigned short n = pGC->numInDashList;
+ unsigned char *dash = pGC->dash;
+ unsigned int dashLength = 0;
+
+ while (n--)
+ dashLength += (unsigned int ) *dash++;
+ pPriv->dashLength = dashLength;
+ }
+}
diff --git a/xorg-server/fb/fbglyph.c b/xorg-server/fb/fbglyph.c index 2c19b742f..51a5ea0a4 100644 --- a/xorg-server/fb/fbglyph.c +++ b/xorg-server/fb/fbglyph.c @@ -1,481 +1,479 @@ -/* - * - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "fb.h" -#include <X11/fonts/fontstruct.h> -#include "dixfontstr.h" - -#define dummyScreen screenInfo.screens[0] - -Bool -fbGlyphIn (RegionPtr pRegion, - int x, - int y, - int width, - int height) -{ - BoxRec box; - BoxPtr pExtents = REGION_EXTENTS (dummyScreen, pRegion); - - /* - * Check extents by hand to avoid 16 bit overflows - */ - if (x < (int) pExtents->x1) - return FALSE; - if ((int) pExtents->x2 < x + width) - return FALSE; - if (y < (int) pExtents->y1) - return FALSE; - if ((int) pExtents->y2 < y + height) - return FALSE; - box.x1 = x; - box.x2 = x + width; - box.y1 = y; - box.y2 = y + height; - return RECT_IN_REGION (dummyScreen, pRegion, &box) == rgnIN; -} - -#ifdef FB_24BIT -#ifndef FBNOPIXADDR - -#define WRITE1(d,n,fg) WRITE((d) + (n), (CARD8) fg) -#define WRITE2(d,n,fg) WRITE((CARD16 *) &(d[n]), (CARD16) fg) -#define WRITE4(d,n,fg) WRITE((CARD32 *) &(d[n]), (CARD32) fg) -#if FB_UNIT == 6 && IMAGE_BYTE_ORDER == LSBFirst -#define WRITE8(d) WRITE((FbBits *) &(d[0]), fg) -#else -#define WRITE8(d) WRITE4(d,0,_ABCA), WRITE4(d,4,_BCAB) -#endif - -/* - * This is a bit tricky, but it's brief. Write 12 bytes worth - * of dest, which is four pixels, at a time. This gives constant - * code for each pattern as they're always aligned the same - * - * a b c d a b c d a b c d bytes - * A B C A B C A B C A B C pixels - * - * f0 f1 f2 - * A B C A B C A B C A B C pixels LSB - * C A B C A B C A B C A B pixels MSB - * - * LSB MSB - * A f0 f1 - * B f1 f2 - * C f2 f0 - * A B f0 f2 - * B C f1 f0 - * C A f2 f1 - * A B C A f0 f1 - * B C A B f1 f2 - * C A B C f2 f0 - */ - -#undef _A -#undef _B -#undef _C -#undef _AB -#undef _BC -#undef _CA -#undef _ABCA -#undef _BCAB -#undef _CABC - -#if IMAGE_BYTE_ORDER == MSBFirst -#define _A f1 -#define _B f2 -#define _C f0 -#define _AB f2 -#define _BC f0 -#define _CA f1 -#define _ABCA f1 -#define _BCAB f2 -#define _CABC f0 -#define CASE(a,b,c,d) ((a << 3) | (b << 2) | (c << 1) | d) -#else -#define _A f0 -#define _B f1 -#define _C f2 -#define _AB f0 -#define _BC f1 -#define _CA f2 -#define _ABCA f0 -#define _BCAB f1 -#define _CABC f2 -#define CASE(a,b,c,d) (a | (b << 1) | (c << 2) | (d << 3)) -#endif - -void -fbGlyph24 (FbBits *dstBits, - FbStride dstStride, - int dstBpp, - FbStip *stipple, - FbBits fg, - int x, - int height) -{ - int lshift; - FbStip bits; - CARD8 *dstLine; - CARD8 *dst; - FbStip f0, f1, f2; - int n; - int shift; - - f0 = fg; - f1 = FbRot24(f0,16); - f2 = FbRot24(f0,8); - - dstLine = (CARD8 *) dstBits; - dstLine += (x & ~3) * 3; - dstStride *= (sizeof (FbBits) / sizeof (CARD8)); - shift = x & 3; - lshift = 4 - shift; - while (height--) - { - bits = READ(stipple++); - n = lshift; - dst = dstLine; - while (bits) - { - switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) { - case CASE(0,0,0,0): - break; - case CASE(1,0,0,0): - WRITE2(dst,0,_AB); - WRITE1(dst,2,_C); - break; - case CASE(0,1,0,0): - WRITE1(dst,3,_A); - WRITE2(dst,4,_BC); - break; - case CASE(1,1,0,0): - WRITE4(dst,0,_ABCA); - WRITE2(dst,4,_BC); - break; - case CASE(0,0,1,0): - WRITE2(dst,6,_AB); - WRITE1(dst,8,_C); - break; - case CASE(1,0,1,0): - WRITE2(dst,0,_AB); - WRITE1(dst,2,_C); - - WRITE2(dst,6,_AB); - WRITE1(dst,8,_C); - break; - case CASE(0,1,1,0): - WRITE1(dst,3,_A); - WRITE4(dst,4,_BCAB); - WRITE1(dst,8,_C); - break; - case CASE(1,1,1,0): - WRITE8(dst); - WRITE1(dst,8,_C); - break; - case CASE(0,0,0,1): - WRITE1(dst,9,_A); - WRITE2(dst,10,_BC); - break; - case CASE(1,0,0,1): - WRITE2(dst,0,_AB); - WRITE1(dst,2,_C); - - WRITE1(dst,9,_A); - WRITE2(dst,10,_BC); - break; - case CASE(0,1,0,1): - WRITE1(dst,3,_A); - WRITE2(dst,4,_BC); - - WRITE1(dst,9,_A); - WRITE2(dst,10,_BC); - break; - case CASE(1,1,0,1): - WRITE4(dst,0,_ABCA); - WRITE2(dst,4,_BC); - - WRITE1(dst,9,_A); - WRITE2(dst,10,_BC); - break; - case CASE(0,0,1,1): - WRITE2(dst,6,_AB); - WRITE4(dst,8,_CABC); - break; - case CASE(1,0,1,1): - WRITE2(dst,0,_AB); - WRITE1(dst,2,_C); - - WRITE2(dst,6,_AB); - WRITE4(dst,8,_CABC); - break; - case CASE(0,1,1,1): - WRITE1(dst,3,_A); - WRITE4(dst,4,_BCAB); - WRITE4(dst,8,_CABC); - break; - case CASE(1,1,1,1): - WRITE8(dst); - WRITE4(dst,8,_CABC); - break; - } - bits = FbStipLeft (bits, n); - n = 4; - dst += 12; - } - dstLine += dstStride; - } -} -#endif -#endif - -void -fbPolyGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppci, - pointer pglyphBase) -{ - FbGCPrivPtr pPriv = fbGetGCPrivate (pGC); - CharInfoPtr pci; - unsigned char *pglyph; /* pointer bits in glyph */ - int gx, gy; - int gWidth, gHeight; /* width and height of glyph */ - FbStride gStride; /* stride of glyph */ -#ifndef FBNOPIXADDR - void (*glyph) (FbBits *, - FbStride, - int, - FbStip *, - FbBits, - int, - int); - FbBits *dst = 0; - FbStride dstStride = 0; - int dstBpp = 0; - int dstXoff = 0, dstYoff = 0; - - glyph = 0; - if (pGC->fillStyle == FillSolid && pPriv->and == 0) - { - dstBpp = pDrawable->bitsPerPixel; - switch (dstBpp) { - case 8: glyph = fbGlyph8; break; - case 16: glyph = fbGlyph16; break; -#ifdef FB_24BIT - case 24: glyph = fbGlyph24; break; -#endif - case 32: glyph = fbGlyph32; break; - } - } -#endif - x += pDrawable->x; - y += pDrawable->y; - - while (nglyph--) - { - pci = *ppci++; - pglyph = FONTGLYPHBITS(pglyphBase, pci); - gWidth = GLYPHWIDTHPIXELS(pci); - gHeight = GLYPHHEIGHTPIXELS(pci); - if (gWidth && gHeight) - { - gx = x + pci->metrics.leftSideBearing; - gy = y - pci->metrics.ascent; -#ifndef FBNOPIXADDR - if (glyph && gWidth <= sizeof (FbStip) * 8 && - fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight)) - { - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - (*glyph) (dst + (gy + dstYoff) * dstStride, - dstStride, - dstBpp, - (FbStip *) pglyph, - pPriv->xor, - gx + dstXoff, - gHeight); - fbFinishAccess (pDrawable); - } - else -#endif - { - gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip); - fbPushImage (pDrawable, - pGC, - - (FbStip *) pglyph, - gStride, - 0, - - gx, - gy, - gWidth, gHeight); - } - } - x += pci->metrics.characterWidth; - } -} - - -void -fbImageGlyphBlt (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppciInit, - pointer pglyphBase) -{ - FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); - CharInfoPtr *ppci; - CharInfoPtr pci; - unsigned char *pglyph; /* pointer bits in glyph */ - int gWidth, gHeight; /* width and height of glyph */ - FbStride gStride; /* stride of glyph */ - Bool opaque; - int n; - int gx, gy; -#ifndef FBNOPIXADDR - void (*glyph) (FbBits *, - FbStride, - int, - FbStip *, - FbBits, - int, - int); - FbBits *dst = 0; - FbStride dstStride = 0; - int dstBpp = 0; - int dstXoff = 0, dstYoff = 0; - - glyph = 0; - if (pPriv->and == 0) - { - dstBpp = pDrawable->bitsPerPixel; - switch (dstBpp) { - case 8: glyph = fbGlyph8; break; - case 16: glyph = fbGlyph16; break; -#ifdef FB_24BIT - case 24: glyph = fbGlyph24; break; -#endif - case 32: glyph = fbGlyph32; break; - } - } -#endif - - x += pDrawable->x; - y += pDrawable->y; - - if (TERMINALFONT (pGC->font) -#ifndef FBNOPIXADDR - && !glyph -#endif - ) - { - opaque = TRUE; - } - else - { - int xBack, widthBack; - int yBack, heightBack; - - ppci = ppciInit; - n = nglyph; - widthBack = 0; - while (n--) - widthBack += (*ppci++)->metrics.characterWidth; - - xBack = x; - if (widthBack < 0) - { - xBack += widthBack; - widthBack = -widthBack; - } - yBack = y - FONTASCENT(pGC->font); - heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); - fbSolidBoxClipped (pDrawable, - fbGetCompositeClip(pGC), - xBack, - yBack, - xBack + widthBack, - yBack + heightBack, - fbAnd(GXcopy,pPriv->bg,pPriv->pm), - fbXor(GXcopy,pPriv->bg,pPriv->pm)); - opaque = FALSE; - } - - ppci = ppciInit; - while (nglyph--) - { - pci = *ppci++; - pglyph = FONTGLYPHBITS(pglyphBase, pci); - gWidth = GLYPHWIDTHPIXELS(pci); - gHeight = GLYPHHEIGHTPIXELS(pci); - if (gWidth && gHeight) - { - gx = x + pci->metrics.leftSideBearing; - gy = y - pci->metrics.ascent; -#ifndef FBNOPIXADDR - if (glyph && gWidth <= sizeof (FbStip) * 8 && - fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight)) - { - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - (*glyph) (dst + (gy + dstYoff) * dstStride, - dstStride, - dstBpp, - (FbStip *) pglyph, - pPriv->fg, - gx + dstXoff, - gHeight); - fbFinishAccess (pDrawable); - } - else -#endif - { - gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip); - fbPutXYImage (pDrawable, - fbGetCompositeClip(pGC), - pPriv->fg, - pPriv->bg, - pPriv->pm, - GXcopy, - opaque, - - gx, - gy, - gWidth, gHeight, - - (FbStip *) pglyph, - gStride, - 0); - } - } - x += pci->metrics.characterWidth; - } -} +/*
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+
+Bool
+fbGlyphIn (RegionPtr pRegion,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ BoxRec box;
+ BoxPtr pExtents = RegionExtents(pRegion);
+
+ /*
+ * Check extents by hand to avoid 16 bit overflows
+ */
+ if (x < (int) pExtents->x1)
+ return FALSE;
+ if ((int) pExtents->x2 < x + width)
+ return FALSE;
+ if (y < (int) pExtents->y1)
+ return FALSE;
+ if ((int) pExtents->y2 < y + height)
+ return FALSE;
+ box.x1 = x;
+ box.x2 = x + width;
+ box.y1 = y;
+ box.y2 = y + height;
+ return RegionContainsRect(pRegion, &box) == rgnIN;
+}
+
+#ifdef FB_24BIT
+#ifndef FBNOPIXADDR
+
+#define WRITE1(d,n,fg) WRITE((d) + (n), (CARD8) fg)
+#define WRITE2(d,n,fg) WRITE((CARD16 *) &(d[n]), (CARD16) fg)
+#define WRITE4(d,n,fg) WRITE((CARD32 *) &(d[n]), (CARD32) fg)
+#if FB_UNIT == 6 && IMAGE_BYTE_ORDER == LSBFirst
+#define WRITE8(d) WRITE((FbBits *) &(d[0]), fg)
+#else
+#define WRITE8(d) WRITE4(d,0,_ABCA), WRITE4(d,4,_BCAB)
+#endif
+
+/*
+ * This is a bit tricky, but it's brief. Write 12 bytes worth
+ * of dest, which is four pixels, at a time. This gives constant
+ * code for each pattern as they're always aligned the same
+ *
+ * a b c d a b c d a b c d bytes
+ * A B C A B C A B C A B C pixels
+ *
+ * f0 f1 f2
+ * A B C A B C A B C A B C pixels LSB
+ * C A B C A B C A B C A B pixels MSB
+ *
+ * LSB MSB
+ * A f0 f1
+ * B f1 f2
+ * C f2 f0
+ * A B f0 f2
+ * B C f1 f0
+ * C A f2 f1
+ * A B C A f0 f1
+ * B C A B f1 f2
+ * C A B C f2 f0
+ */
+
+#undef _A
+#undef _B
+#undef _C
+#undef _AB
+#undef _BC
+#undef _CA
+#undef _ABCA
+#undef _BCAB
+#undef _CABC
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define _A f1
+#define _B f2
+#define _C f0
+#define _AB f2
+#define _BC f0
+#define _CA f1
+#define _ABCA f1
+#define _BCAB f2
+#define _CABC f0
+#define CASE(a,b,c,d) ((a << 3) | (b << 2) | (c << 1) | d)
+#else
+#define _A f0
+#define _B f1
+#define _C f2
+#define _AB f0
+#define _BC f1
+#define _CA f2
+#define _ABCA f0
+#define _BCAB f1
+#define _CABC f2
+#define CASE(a,b,c,d) (a | (b << 1) | (c << 2) | (d << 3))
+#endif
+
+void
+fbGlyph24 (FbBits *dstBits,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int x,
+ int height)
+{
+ int lshift;
+ FbStip bits;
+ CARD8 *dstLine;
+ CARD8 *dst;
+ FbStip f0, f1, f2;
+ int n;
+ int shift;
+
+ f0 = fg;
+ f1 = FbRot24(f0,16);
+ f2 = FbRot24(f0,8);
+
+ dstLine = (CARD8 *) dstBits;
+ dstLine += (x & ~3) * 3;
+ dstStride *= (sizeof (FbBits) / sizeof (CARD8));
+ shift = x & 3;
+ lshift = 4 - shift;
+ while (height--)
+ {
+ bits = READ(stipple++);
+ n = lshift;
+ dst = dstLine;
+ while (bits)
+ {
+ switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) {
+ case CASE(0,0,0,0):
+ break;
+ case CASE(1,0,0,0):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+ break;
+ case CASE(0,1,0,0):
+ WRITE1(dst,3,_A);
+ WRITE2(dst,4,_BC);
+ break;
+ case CASE(1,1,0,0):
+ WRITE4(dst,0,_ABCA);
+ WRITE2(dst,4,_BC);
+ break;
+ case CASE(0,0,1,0):
+ WRITE2(dst,6,_AB);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(1,0,1,0):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+
+ WRITE2(dst,6,_AB);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(0,1,1,0):
+ WRITE1(dst,3,_A);
+ WRITE4(dst,4,_BCAB);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(1,1,1,0):
+ WRITE8(dst);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(0,0,0,1):
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(1,0,0,1):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(0,1,0,1):
+ WRITE1(dst,3,_A);
+ WRITE2(dst,4,_BC);
+
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(1,1,0,1):
+ WRITE4(dst,0,_ABCA);
+ WRITE2(dst,4,_BC);
+
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(0,0,1,1):
+ WRITE2(dst,6,_AB);
+ WRITE4(dst,8,_CABC);
+ break;
+ case CASE(1,0,1,1):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+
+ WRITE2(dst,6,_AB);
+ WRITE4(dst,8,_CABC);
+ break;
+ case CASE(0,1,1,1):
+ WRITE1(dst,3,_A);
+ WRITE4(dst,4,_BCAB);
+ WRITE4(dst,8,_CABC);
+ break;
+ case CASE(1,1,1,1):
+ WRITE8(dst);
+ WRITE4(dst,8,_CABC);
+ break;
+ }
+ bits = FbStipLeft (bits, n);
+ n = 4;
+ dst += 12;
+ }
+ dstLine += dstStride;
+ }
+}
+#endif
+#endif
+
+void
+fbPolyGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ CharInfoPtr pci;
+ unsigned char *pglyph; /* pointer bits in glyph */
+ int gx, gy;
+ int gWidth, gHeight; /* width and height of glyph */
+ FbStride gStride; /* stride of glyph */
+#ifndef FBNOPIXADDR
+ void (*glyph) (FbBits *,
+ FbStride,
+ int,
+ FbStip *,
+ FbBits,
+ int,
+ int);
+ FbBits *dst = 0;
+ FbStride dstStride = 0;
+ int dstBpp = 0;
+ int dstXoff = 0, dstYoff = 0;
+
+ glyph = 0;
+ if (pGC->fillStyle == FillSolid && pPriv->and == 0)
+ {
+ dstBpp = pDrawable->bitsPerPixel;
+ switch (dstBpp) {
+ case 8: glyph = fbGlyph8; break;
+ case 16: glyph = fbGlyph16; break;
+#ifdef FB_24BIT
+ case 24: glyph = fbGlyph24; break;
+#endif
+ case 32: glyph = fbGlyph32; break;
+ }
+ }
+#endif
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ gWidth = GLYPHWIDTHPIXELS(pci);
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gWidth && gHeight)
+ {
+ gx = x + pci->metrics.leftSideBearing;
+ gy = y - pci->metrics.ascent;
+#ifndef FBNOPIXADDR
+ if (glyph && gWidth <= sizeof (FbStip) * 8 &&
+ fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
+ {
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ (*glyph) (dst + (gy + dstYoff) * dstStride,
+ dstStride,
+ dstBpp,
+ (FbStip *) pglyph,
+ pPriv->xor,
+ gx + dstXoff,
+ gHeight);
+ fbFinishAccess (pDrawable);
+ }
+ else
+#endif
+ {
+ gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
+ fbPushImage (pDrawable,
+ pGC,
+
+ (FbStip *) pglyph,
+ gStride,
+ 0,
+
+ gx,
+ gy,
+ gWidth, gHeight);
+ }
+ }
+ x += pci->metrics.characterWidth;
+ }
+}
+
+
+void
+fbImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppciInit,
+ pointer pglyphBase)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ CharInfoPtr *ppci;
+ CharInfoPtr pci;
+ unsigned char *pglyph; /* pointer bits in glyph */
+ int gWidth, gHeight; /* width and height of glyph */
+ FbStride gStride; /* stride of glyph */
+ Bool opaque;
+ int n;
+ int gx, gy;
+#ifndef FBNOPIXADDR
+ void (*glyph) (FbBits *,
+ FbStride,
+ int,
+ FbStip *,
+ FbBits,
+ int,
+ int);
+ FbBits *dst = 0;
+ FbStride dstStride = 0;
+ int dstBpp = 0;
+ int dstXoff = 0, dstYoff = 0;
+
+ glyph = 0;
+ if (pPriv->and == 0)
+ {
+ dstBpp = pDrawable->bitsPerPixel;
+ switch (dstBpp) {
+ case 8: glyph = fbGlyph8; break;
+ case 16: glyph = fbGlyph16; break;
+#ifdef FB_24BIT
+ case 24: glyph = fbGlyph24; break;
+#endif
+ case 32: glyph = fbGlyph32; break;
+ }
+ }
+#endif
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ if (TERMINALFONT (pGC->font)
+#ifndef FBNOPIXADDR
+ && !glyph
+#endif
+ )
+ {
+ opaque = TRUE;
+ }
+ else
+ {
+ int xBack, widthBack;
+ int yBack, heightBack;
+
+ ppci = ppciInit;
+ n = nglyph;
+ widthBack = 0;
+ while (n--)
+ widthBack += (*ppci++)->metrics.characterWidth;
+
+ xBack = x;
+ if (widthBack < 0)
+ {
+ xBack += widthBack;
+ widthBack = -widthBack;
+ }
+ yBack = y - FONTASCENT(pGC->font);
+ heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+ fbSolidBoxClipped (pDrawable,
+ fbGetCompositeClip(pGC),
+ xBack,
+ yBack,
+ xBack + widthBack,
+ yBack + heightBack,
+ fbAnd(GXcopy,pPriv->bg,pPriv->pm),
+ fbXor(GXcopy,pPriv->bg,pPriv->pm));
+ opaque = FALSE;
+ }
+
+ ppci = ppciInit;
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ gWidth = GLYPHWIDTHPIXELS(pci);
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gWidth && gHeight)
+ {
+ gx = x + pci->metrics.leftSideBearing;
+ gy = y - pci->metrics.ascent;
+#ifndef FBNOPIXADDR
+ if (glyph && gWidth <= sizeof (FbStip) * 8 &&
+ fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
+ {
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ (*glyph) (dst + (gy + dstYoff) * dstStride,
+ dstStride,
+ dstBpp,
+ (FbStip *) pglyph,
+ pPriv->fg,
+ gx + dstXoff,
+ gHeight);
+ fbFinishAccess (pDrawable);
+ }
+ else
+#endif
+ {
+ gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pPriv->fg,
+ pPriv->bg,
+ pPriv->pm,
+ GXcopy,
+ opaque,
+
+ gx,
+ gy,
+ gWidth, gHeight,
+
+ (FbStip *) pglyph,
+ gStride,
+ 0);
+ }
+ }
+ x += pci->metrics.characterWidth;
+ }
+}
diff --git a/xorg-server/fb/fbimage.c b/xorg-server/fb/fbimage.c index 2b9ac27c0..0fcb05f7c 100644 --- a/xorg-server/fb/fbimage.c +++ b/xorg-server/fb/fbimage.c @@ -1,368 +1,368 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <string.h> - -#include "fb.h" - -void -fbPutImage (DrawablePtr pDrawable, - GCPtr pGC, - int depth, - int x, - int y, - int w, - int h, - int leftPad, - int format, - char *pImage) -{ - FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); - unsigned long i; - FbStride srcStride; - FbStip *src = (FbStip *) pImage; - - x += pDrawable->x; - y += pDrawable->y; - - switch (format) - { - case XYBitmap: - srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip); - fbPutXYImage (pDrawable, - fbGetCompositeClip(pGC), - pPriv->fg, - pPriv->bg, - pPriv->pm, - pGC->alu, - TRUE, - x, y, w, h, - src, - srcStride, - leftPad); - break; - case XYPixmap: - srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip); - for (i = (unsigned long)1 << (pDrawable->depth - 1); i; i >>= 1) - { - if (i & pGC->planemask) - { - fbPutXYImage (pDrawable, - fbGetCompositeClip(pGC), - FB_ALLONES, - 0, - fbReplicatePixel (i, pDrawable->bitsPerPixel), - pGC->alu, - TRUE, - x, y, w, h, - src, - srcStride, - leftPad); - src += srcStride * h; - } - } - break; - case ZPixmap: -#ifdef FB_24_32BIT - if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth)) - { - srcStride = PixmapBytePad(w, pDrawable->depth); - fb24_32PutZImage (pDrawable, - fbGetCompositeClip(pGC), - pGC->alu, - (FbBits) pGC->planemask, - x, y, w, h, - (CARD8 *) pImage, - srcStride); - } - else -#endif - { - srcStride = PixmapBytePad(w, pDrawable->depth) / sizeof (FbStip); - fbPutZImage (pDrawable, - fbGetCompositeClip(pGC), - pGC->alu, - pPriv->pm, - x, y, w, h, - src, srcStride); - } - } -} - -void -fbPutZImage (DrawablePtr pDrawable, - RegionPtr pClip, - int alu, - FbBits pm, - int x, - int y, - int width, - int height, - FbStip *src, - FbStride srcStride) -{ - FbStip *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - int nbox; - BoxPtr pbox; - int x1, y1, x2, y2; - - fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - - for (nbox = REGION_NUM_RECTS (pClip), - pbox = REGION_RECTS(pClip); - nbox--; - pbox++) - { - x1 = x; - y1 = y; - x2 = x + width; - y2 = y + height; - if (x1 < pbox->x1) - x1 = pbox->x1; - if (y1 < pbox->y1) - y1 = pbox->y1; - if (x2 > pbox->x2) - x2 = pbox->x2; - if (y2 > pbox->y2) - y2 = pbox->y2; - if (x1 >= x2 || y1 >= y2) - continue; - fbBltStip (src + (y1 - y) * srcStride, - srcStride, - (x1 - x) * dstBpp, - - dst + (y1 + dstYoff) * dstStride, - dstStride, - (x1 + dstXoff) * dstBpp, - - (x2 - x1) * dstBpp, - (y2 - y1), - - alu, - pm, - dstBpp); - } - - fbFinishAccess (pDrawable); -} - -void -fbPutXYImage (DrawablePtr pDrawable, - RegionPtr pClip, - FbBits fg, - FbBits bg, - FbBits pm, - int alu, - Bool opaque, - - int x, - int y, - int width, - int height, - - FbStip *src, - FbStride srcStride, - int srcX) -{ - FbBits *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - int nbox; - BoxPtr pbox; - int x1, y1, x2, y2; - FbBits fgand = 0, fgxor = 0, bgand = 0, bgxor = 0; - - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - - if (dstBpp == 1) - { - if (opaque) - alu = FbOpaqueStipple1Rop(alu,fg,bg); - else - alu = FbStipple1Rop(alu,fg); - } - else - { - fgand = fbAnd(alu,fg,pm); - fgxor = fbXor(alu,fg,pm); - if (opaque) - { - bgand = fbAnd(alu,bg,pm); - bgxor = fbXor(alu,bg,pm); - } - else - { - bgand = fbAnd(GXnoop,(FbBits)0,FB_ALLONES); - bgxor = fbXor(GXnoop,(FbBits)0,FB_ALLONES); - } - } - - for (nbox = REGION_NUM_RECTS (pClip), - pbox = REGION_RECTS(pClip); - nbox--; - pbox++) - { - x1 = x; - y1 = y; - x2 = x + width; - y2 = y + height; - if (x1 < pbox->x1) - x1 = pbox->x1; - if (y1 < pbox->y1) - y1 = pbox->y1; - if (x2 > pbox->x2) - x2 = pbox->x2; - if (y2 > pbox->y2) - y2 = pbox->y2; - if (x1 >= x2 || y1 >= y2) - continue; - if (dstBpp == 1) - { - fbBltStip (src + (y1 - y) * srcStride, - srcStride, - (x1 - x) + srcX, - - (FbStip *) (dst + (y1 + dstYoff) * dstStride), - FbBitsStrideToStipStride(dstStride), - (x1 + dstXoff) * dstBpp, - - (x2 - x1) * dstBpp, - (y2 - y1), - - alu, - pm, - dstBpp); - } - else - { - fbBltOne (src + (y1 - y) * srcStride, - srcStride, - (x1 - x) + srcX, - - dst + (y1 + dstYoff) * dstStride, - dstStride, - (x1 + dstXoff) * dstBpp, - dstBpp, - - (x2 - x1) * dstBpp, - (y2 - y1), - - fgand, fgxor, bgand, bgxor); - } - } - - fbFinishAccess (pDrawable); -} - -void -fbGetImage (DrawablePtr pDrawable, - int x, - int y, - int w, - int h, - unsigned int format, - unsigned long planeMask, - char *d) -{ - FbBits *src; - FbStride srcStride; - int srcBpp; - int srcXoff, srcYoff; - FbStip *dst; - FbStride dstStride; - - /* - * XFree86 DDX empties the root borderClip when the VT is - * switched away; this checks for that case - */ - if (!fbDrawableEnabled(pDrawable)) - return; - -#ifdef FB_24_32BIT - if (format == ZPixmap && - pDrawable->bitsPerPixel != BitsPerPixel (pDrawable->depth)) - { - fb24_32GetImage (pDrawable, x, y, w, h, format, planeMask, d); - return; - } -#endif - - fbGetDrawable (pDrawable, src, srcStride, srcBpp, srcXoff, srcYoff); - - x += pDrawable->x; - y += pDrawable->y; - - dst = (FbStip *) d; - if (format == ZPixmap || srcBpp == 1) - { - FbBits pm; - - pm = fbReplicatePixel (planeMask, srcBpp); - dstStride = PixmapBytePad(w, pDrawable->depth); - if (pm != FB_ALLONES) - memset (d, 0, dstStride * h); - dstStride /= sizeof (FbStip); - fbBltStip ((FbStip *) (src + (y + srcYoff) * srcStride), - FbBitsStrideToStipStride(srcStride), - (x + srcXoff) * srcBpp, - - dst, - dstStride, - 0, - - w * srcBpp, h, - - GXcopy, - pm, - srcBpp); - } - else - { - dstStride = BitmapBytePad(w) / sizeof (FbStip); - fbBltPlane (src + (y + srcYoff) * srcStride, - srcStride, - (x + srcXoff) * srcBpp, - srcBpp, - - dst, - dstStride, - 0, - - w * srcBpp, h, - - fbAndStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES), - fbXorStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES), - fbAndStip(GXcopy,0,FB_STIP_ALLONES), - fbXorStip(GXcopy,0,FB_STIP_ALLONES), - planeMask); - } - - fbFinishAccess (pDrawable); -} +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+
+#include "fb.h"
+
+void
+fbPutImage (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ unsigned long i;
+ FbStride srcStride;
+ FbStip *src = (FbStip *) pImage;
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ switch (format)
+ {
+ case XYBitmap:
+ srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip);
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pPriv->fg,
+ pPriv->bg,
+ pPriv->pm,
+ pGC->alu,
+ TRUE,
+ x, y, w, h,
+ src,
+ srcStride,
+ leftPad);
+ break;
+ case XYPixmap:
+ srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip);
+ for (i = (unsigned long)1 << (pDrawable->depth - 1); i; i >>= 1)
+ {
+ if (i & pGC->planemask)
+ {
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ FB_ALLONES,
+ 0,
+ fbReplicatePixel (i, pDrawable->bitsPerPixel),
+ pGC->alu,
+ TRUE,
+ x, y, w, h,
+ src,
+ srcStride,
+ leftPad);
+ src += srcStride * h;
+ }
+ }
+ break;
+ case ZPixmap:
+#ifdef FB_24_32BIT
+ if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
+ {
+ srcStride = PixmapBytePad(w, pDrawable->depth);
+ fb24_32PutZImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pGC->alu,
+ (FbBits) pGC->planemask,
+ x, y, w, h,
+ (CARD8 *) pImage,
+ srcStride);
+ }
+ else
+#endif
+ {
+ srcStride = PixmapBytePad(w, pDrawable->depth) / sizeof (FbStip);
+ fbPutZImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pGC->alu,
+ pPriv->pm,
+ x, y, w, h,
+ src, srcStride);
+ }
+ }
+}
+
+void
+fbPutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ FbStip *src,
+ FbStride srcStride)
+{
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int nbox;
+ BoxPtr pbox;
+ int x1, y1, x2, y2;
+
+ fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ for (nbox = RegionNumRects (pClip),
+ pbox = RegionRects(pClip);
+ nbox--;
+ pbox++)
+ {
+ x1 = x;
+ y1 = y;
+ x2 = x + width;
+ y2 = y + height;
+ if (x1 < pbox->x1)
+ x1 = pbox->x1;
+ if (y1 < pbox->y1)
+ y1 = pbox->y1;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ fbBltStip (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x) * dstBpp,
+
+ dst + (y1 + dstYoff) * dstStride,
+ dstStride,
+ (x1 + dstXoff) * dstBpp,
+
+ (x2 - x1) * dstBpp,
+ (y2 - y1),
+
+ alu,
+ pm,
+ dstBpp);
+ }
+
+ fbFinishAccess (pDrawable);
+}
+
+void
+fbPutXYImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ FbBits fg,
+ FbBits bg,
+ FbBits pm,
+ int alu,
+ Bool opaque,
+
+ int x,
+ int y,
+ int width,
+ int height,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int nbox;
+ BoxPtr pbox;
+ int x1, y1, x2, y2;
+ FbBits fgand = 0, fgxor = 0, bgand = 0, bgxor = 0;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ if (dstBpp == 1)
+ {
+ if (opaque)
+ alu = FbOpaqueStipple1Rop(alu,fg,bg);
+ else
+ alu = FbStipple1Rop(alu,fg);
+ }
+ else
+ {
+ fgand = fbAnd(alu,fg,pm);
+ fgxor = fbXor(alu,fg,pm);
+ if (opaque)
+ {
+ bgand = fbAnd(alu,bg,pm);
+ bgxor = fbXor(alu,bg,pm);
+ }
+ else
+ {
+ bgand = fbAnd(GXnoop,(FbBits)0,FB_ALLONES);
+ bgxor = fbXor(GXnoop,(FbBits)0,FB_ALLONES);
+ }
+ }
+
+ for (nbox = RegionNumRects (pClip),
+ pbox = RegionRects(pClip);
+ nbox--;
+ pbox++)
+ {
+ x1 = x;
+ y1 = y;
+ x2 = x + width;
+ y2 = y + height;
+ if (x1 < pbox->x1)
+ x1 = pbox->x1;
+ if (y1 < pbox->y1)
+ y1 = pbox->y1;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ if (dstBpp == 1)
+ {
+ fbBltStip (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x) + srcX,
+
+ (FbStip *) (dst + (y1 + dstYoff) * dstStride),
+ FbBitsStrideToStipStride(dstStride),
+ (x1 + dstXoff) * dstBpp,
+
+ (x2 - x1) * dstBpp,
+ (y2 - y1),
+
+ alu,
+ pm,
+ dstBpp);
+ }
+ else
+ {
+ fbBltOne (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x) + srcX,
+
+ dst + (y1 + dstYoff) * dstStride,
+ dstStride,
+ (x1 + dstXoff) * dstBpp,
+ dstBpp,
+
+ (x2 - x1) * dstBpp,
+ (y2 - y1),
+
+ fgand, fgxor, bgand, bgxor);
+ }
+ }
+
+ fbFinishAccess (pDrawable);
+}
+
+void
+fbGetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d)
+{
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbStip *dst;
+ FbStride dstStride;
+
+ /*
+ * XFree86 DDX empties the root borderClip when the VT is
+ * switched away; this checks for that case
+ */
+ if (!fbDrawableEnabled(pDrawable))
+ return;
+
+#ifdef FB_24_32BIT
+ if (format == ZPixmap &&
+ pDrawable->bitsPerPixel != BitsPerPixel (pDrawable->depth))
+ {
+ fb24_32GetImage (pDrawable, x, y, w, h, format, planeMask, d);
+ return;
+ }
+#endif
+
+ fbGetDrawable (pDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ dst = (FbStip *) d;
+ if (format == ZPixmap || srcBpp == 1)
+ {
+ FbBits pm;
+
+ pm = fbReplicatePixel (planeMask, srcBpp);
+ dstStride = PixmapBytePad(w, pDrawable->depth);
+ if (pm != FB_ALLONES)
+ memset (d, 0, dstStride * h);
+ dstStride /= sizeof (FbStip);
+ fbBltStip ((FbStip *) (src + (y + srcYoff) * srcStride),
+ FbBitsStrideToStipStride(srcStride),
+ (x + srcXoff) * srcBpp,
+
+ dst,
+ dstStride,
+ 0,
+
+ w * srcBpp, h,
+
+ GXcopy,
+ pm,
+ srcBpp);
+ }
+ else
+ {
+ dstStride = BitmapBytePad(w) / sizeof (FbStip);
+ fbBltPlane (src + (y + srcYoff) * srcStride,
+ srcStride,
+ (x + srcXoff) * srcBpp,
+ srcBpp,
+
+ dst,
+ dstStride,
+ 0,
+
+ w * srcBpp, h,
+
+ fbAndStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES),
+ fbXorStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES),
+ fbAndStip(GXcopy,0,FB_STIP_ALLONES),
+ fbXorStip(GXcopy,0,FB_STIP_ALLONES),
+ planeMask);
+ }
+
+ fbFinishAccess (pDrawable);
+}
diff --git a/xorg-server/fb/fbline.c b/xorg-server/fb/fbline.c index 2cee123ae..66e6d3690 100644 --- a/xorg-server/fb/fbline.c +++ b/xorg-server/fb/fbline.c @@ -1,175 +1,175 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "fb.h" - -void -fbZeroLine (DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr ppt) -{ - int x1, y1, x2, y2; - int x, y; - int dashOffset; - - x = pDrawable->x; - y = pDrawable->y; - x1 = ppt->x; - y1 = ppt->y; - dashOffset = pGC->dashOffset; - while (--npt) - { - ++ppt; - x2 = ppt->x; - y2 = ppt->y; - if (mode == CoordModePrevious) - { - x2 += x1; - y2 += y1; - } - fbSegment (pDrawable, pGC, x1 + x, y1 + y, - x2 + x, y2 + y, - npt == 1 && pGC->capStyle != CapNotLast, - &dashOffset); - x1 = x2; - y1 = y2; - } -} - -void -fbZeroSegment (DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pSegs) -{ - int dashOffset; - int x, y; - Bool drawLast = pGC->capStyle != CapNotLast; - - x = pDrawable->x; - y = pDrawable->y; - while (nseg--) - { - dashOffset = pGC->dashOffset; - fbSegment (pDrawable, pGC, - pSegs->x1 + x, pSegs->y1 + y, - pSegs->x2 + x, pSegs->y2 + y, - drawLast, - &dashOffset); - pSegs++; - } -} - -void -fbFixCoordModePrevious (int npt, - DDXPointPtr ppt) -{ - int x, y; - - x = ppt->x; - y = ppt->y; - npt--; - while (npt--) - { - ppt++; - x = (ppt->x += x); - y = (ppt->y += y); - } -} - -void -fbPolyLine (DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr ppt) -{ - void (*line) (DrawablePtr, GCPtr, int mode, int npt, DDXPointPtr ppt); - - if (pGC->lineWidth == 0) - { - line = fbZeroLine; -#ifndef FBNOPIXADDR - if (pGC->fillStyle == FillSolid && - pGC->lineStyle == LineSolid && - REGION_NUM_RECTS (fbGetCompositeClip(pGC)) == 1) - { - switch (pDrawable->bitsPerPixel) { - case 8: line = fbPolyline8; break; - case 16: line = fbPolyline16; break; -#ifdef FB_24BIT - case 24: line = fbPolyline24; break; -#endif - case 32: line = fbPolyline32; break; - } - } -#endif - } - else - { - if (pGC->lineStyle != LineSolid) - line = miWideDash; - else - line = miWideLine; - } - (*line) (pDrawable, pGC, mode, npt, ppt); -} - -void -fbPolySegment (DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pseg) -{ - void (*seg) (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pseg); - - if (pGC->lineWidth == 0) - { - seg = fbZeroSegment; -#ifndef FBNOPIXADDR - if (pGC->fillStyle == FillSolid && - pGC->lineStyle == LineSolid && - REGION_NUM_RECTS (fbGetCompositeClip(pGC)) == 1) - { - switch (pDrawable->bitsPerPixel) { - case 8: seg = fbPolySegment8; break; - case 16: seg = fbPolySegment16; break; -#ifdef FB_24BIT - case 24: seg = fbPolySegment24; break; -#endif - case 32: seg = fbPolySegment32; break; - } - } -#endif - } - else - { - seg = miPolySegment; - } - (*seg) (pDrawable, pGC, nseg, pseg); -} +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbZeroLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt)
+{
+ int x1, y1, x2, y2;
+ int x, y;
+ int dashOffset;
+
+ x = pDrawable->x;
+ y = pDrawable->y;
+ x1 = ppt->x;
+ y1 = ppt->y;
+ dashOffset = pGC->dashOffset;
+ while (--npt)
+ {
+ ++ppt;
+ x2 = ppt->x;
+ y2 = ppt->y;
+ if (mode == CoordModePrevious)
+ {
+ x2 += x1;
+ y2 += y1;
+ }
+ fbSegment (pDrawable, pGC, x1 + x, y1 + y,
+ x2 + x, y2 + y,
+ npt == 1 && pGC->capStyle != CapNotLast,
+ &dashOffset);
+ x1 = x2;
+ y1 = y2;
+ }
+}
+
+void
+fbZeroSegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSegs)
+{
+ int dashOffset;
+ int x, y;
+ Bool drawLast = pGC->capStyle != CapNotLast;
+
+ x = pDrawable->x;
+ y = pDrawable->y;
+ while (nseg--)
+ {
+ dashOffset = pGC->dashOffset;
+ fbSegment (pDrawable, pGC,
+ pSegs->x1 + x, pSegs->y1 + y,
+ pSegs->x2 + x, pSegs->y2 + y,
+ drawLast,
+ &dashOffset);
+ pSegs++;
+ }
+}
+
+void
+fbFixCoordModePrevious (int npt,
+ DDXPointPtr ppt)
+{
+ int x, y;
+
+ x = ppt->x;
+ y = ppt->y;
+ npt--;
+ while (npt--)
+ {
+ ppt++;
+ x = (ppt->x += x);
+ y = (ppt->y += y);
+ }
+}
+
+void
+fbPolyLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt)
+{
+ void (*line) (DrawablePtr, GCPtr, int mode, int npt, DDXPointPtr ppt);
+
+ if (pGC->lineWidth == 0)
+ {
+ line = fbZeroLine;
+#ifndef FBNOPIXADDR
+ if (pGC->fillStyle == FillSolid &&
+ pGC->lineStyle == LineSolid &&
+ RegionNumRects (fbGetCompositeClip(pGC)) == 1)
+ {
+ switch (pDrawable->bitsPerPixel) {
+ case 8: line = fbPolyline8; break;
+ case 16: line = fbPolyline16; break;
+#ifdef FB_24BIT
+ case 24: line = fbPolyline24; break;
+#endif
+ case 32: line = fbPolyline32; break;
+ }
+ }
+#endif
+ }
+ else
+ {
+ if (pGC->lineStyle != LineSolid)
+ line = miWideDash;
+ else
+ line = miWideLine;
+ }
+ (*line) (pDrawable, pGC, mode, npt, ppt);
+}
+
+void
+fbPolySegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg)
+{
+ void (*seg) (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pseg);
+
+ if (pGC->lineWidth == 0)
+ {
+ seg = fbZeroSegment;
+#ifndef FBNOPIXADDR
+ if (pGC->fillStyle == FillSolid &&
+ pGC->lineStyle == LineSolid &&
+ RegionNumRects (fbGetCompositeClip(pGC)) == 1)
+ {
+ switch (pDrawable->bitsPerPixel) {
+ case 8: seg = fbPolySegment8; break;
+ case 16: seg = fbPolySegment16; break;
+#ifdef FB_24BIT
+ case 24: seg = fbPolySegment24; break;
+#endif
+ case 32: seg = fbPolySegment32; break;
+ }
+ }
+#endif
+ }
+ else
+ {
+ seg = miPolySegment;
+ }
+ (*seg) (pDrawable, pGC, nseg, pseg);
+}
diff --git a/xorg-server/fb/fboverlay.c b/xorg-server/fb/fboverlay.c index f14187cba..d6986e2a8 100644 --- a/xorg-server/fb/fboverlay.c +++ b/xorg-server/fb/fboverlay.c @@ -33,8 +33,8 @@ #include "fboverlay.h"
#include "shmint.h"
-static int fbOverlayScreenPrivateKeyIndex;
-static DevPrivateKey fbOverlayScreenPrivateKey = &fbOverlayScreenPrivateKeyIndex;
+static DevPrivateKeyRec fbOverlayScreenPrivateKeyRec;
+#define fbOverlayScreenPrivateKey (&fbOverlayScreenPrivateKeyRec)
DevPrivateKey fbOverlayGetScreenPrivateKey(void)
{
@@ -75,8 +75,7 @@ fbOverlayCreateWindow(WindowPtr pWin) */
if (!pWin->parent)
{
- REGION_EMPTY (pWin->drawable.pScreen,
- &pScrPriv->layer[i].u.run.region);
+ RegionEmpty(&pScrPriv->layer[i].u.run.region);
}
return TRUE;
}
@@ -93,7 +92,7 @@ fbOverlayCloseScreen (int iScreen, ScreenPtr pScreen) for (i = 0; i < pScrPriv->nlayers; i++)
{
(*pScreen->DestroyPixmap)(pScrPriv->layer[i].u.run.pixmap);
- REGION_UNINIT (pScreen, &pScrPriv->layer[i].u.run.region);
+ RegionUninit(&pScrPriv->layer[i].u.run.region);
}
return TRUE;
}
@@ -147,7 +146,7 @@ fbOverlayCreateScreenResources(ScreenPtr pScreen) pbits))
return FALSE;
pScrPriv->layer[i].u.run.pixmap = pPixmap;
- REGION_INIT(pScreen, &pScrPriv->layer[i].u.run.region, &box, 0);
+ RegionInit(&pScrPriv->layer[i].u.run.region, &box, 0);
}
pScreen->devPrivate = pScrPriv->layer[0].u.run.pixmap;
return TRUE;
@@ -175,37 +174,32 @@ fbOverlayUpdateLayerRegion (ScreenPtr pScreen, int i;
RegionRec rgnNew;
- if (!prgn || !REGION_NOTEMPTY(pScreen, prgn))
+ if (!prgn || !RegionNotEmpty(prgn))
return;
for (i = 0; i < pScrPriv->nlayers; i++)
{
if (i == layer)
{
/* add new piece to this fb */
- REGION_UNION (pScreen,
- &pScrPriv->layer[i].u.run.region,
- &pScrPriv->layer[i].u.run.region,
- prgn);
+ RegionUnion(&pScrPriv->layer[i].u.run.region,
+ &pScrPriv->layer[i].u.run.region,
+ prgn);
}
- else if (REGION_NOTEMPTY (pScreen,
- &pScrPriv->layer[i].u.run.region))
+ else if (RegionNotEmpty(&pScrPriv->layer[i].u.run.region))
{
/* paint new piece with chroma key */
- REGION_NULL (pScreen, &rgnNew);
- REGION_INTERSECT (pScreen,
- &rgnNew,
- prgn,
- &pScrPriv->layer[i].u.run.region);
+ RegionNull(&rgnNew);
+ RegionIntersect(&rgnNew, prgn,
+ &pScrPriv->layer[i].u.run.region);
(*pScrPriv->PaintKey) (&pScrPriv->layer[i].u.run.pixmap->drawable,
&rgnNew,
pScrPriv->layer[i].key,
i);
- REGION_UNINIT(pScreen, &rgnNew);
+ RegionUninit(&rgnNew);
/* remove piece from other fbs */
- REGION_SUBTRACT (pScreen,
- &pScrPriv->layer[i].u.run.region,
- &pScrPriv->layer[i].u.run.region,
- prgn);
+ RegionSubtract(&pScrPriv->layer[i].u.run.region,
+ &pScrPriv->layer[i].u.run.region,
+ prgn);
}
}
}
@@ -219,7 +213,7 @@ fbOverlayCopyWindow(WindowPtr pWin, RegionPtr prgnSrc)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
RegionRec rgnDst;
int dx, dy;
int i;
@@ -232,21 +226,21 @@ fbOverlayCopyWindow(WindowPtr pWin, /*
* Clip to existing bits
*/
- REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
- REGION_NULL (pScreen, &rgnDst);
- REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
- REGION_TRANSLATE(pScreen, &rgnDst, dx, dy);
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionNull(&rgnDst);
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
+ RegionTranslate(&rgnDst, dx, dy);
/*
* Compute the portion of each fb affected by this copy
*/
for (i = 0; i < pScrPriv->nlayers; i++)
{
- REGION_NULL (pScreen, &layerRgn[i]);
- REGION_INTERSECT(pScreen, &layerRgn[i], &rgnDst,
+ RegionNull(&layerRgn[i]);
+ RegionIntersect(&layerRgn[i], &rgnDst,
&pScrPriv->layer[i].u.run.region);
- if (REGION_NOTEMPTY (pScreen, &layerRgn[i]))
+ if (RegionNotEmpty(&layerRgn[i]))
{
- REGION_TRANSLATE(pScreen, &layerRgn[i], -dx, -dy);
+ RegionTranslate(&layerRgn[i], -dx, -dy);
pPixmap = pScrPriv->layer[i].u.run.pixmap;
miCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
0,
@@ -259,12 +253,12 @@ fbOverlayCopyWindow(WindowPtr pWin, */
for (i = 0; i < pScrPriv->nlayers; i++)
{
- if (REGION_NOTEMPTY (pScreen, &layerRgn[i]))
+ if (RegionNotEmpty(&layerRgn[i]))
fbOverlayUpdateLayerRegion (pScreen, i, &layerRgn[i]);
- REGION_UNINIT(pScreen, &layerRgn[i]);
+ RegionUninit(&layerRgn[i]);
}
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
}
void
@@ -348,6 +342,9 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, VisualID defaultVisual;
FbOverlayScrPrivPtr pScrPriv;
+ if (!dixRegisterPrivateKey(&fbOverlayScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
pScrPriv = malloc(sizeof (FbOverlayScrPrivRec));
if (!pScrPriv)
return FALSE;
@@ -416,7 +413,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, pScrPriv->layer[1].u.init.pbits = pbits2;
pScrPriv->layer[1].u.init.width = width2;
pScrPriv->layer[1].u.init.depth = depth2;
-
dixSetPrivate(&pScreen->devPrivates, fbOverlayScreenPrivateKey, pScrPriv);
/* overwrite miCloseScreen with our own */
diff --git a/xorg-server/fb/fbpict.c b/xorg-server/fb/fbpict.c index 896d33ebb..d6dc30d2c 100644 --- a/xorg-server/fb/fbpict.c +++ b/xorg-server/fb/fbpict.c @@ -1,484 +1,484 @@ -/* - * - * Copyright © 2000 SuSE, Inc. - * Copyright © 2007 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <string.h> - -#include "fb.h" - -#include "picturestr.h" -#include "mipict.h" -#include "fbpict.h" - -#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) - -void -fbWalkCompositeRegion (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height, - Bool srcRepeat, - Bool maskRepeat, - CompositeFunc compositeRect) -{ - RegionRec region; - int n; - BoxPtr pbox; - int w, h, w_this, h_this; - int x_msk, y_msk, x_src, y_src, x_dst, y_dst; - - xDst += pDst->pDrawable->x; - yDst += pDst->pDrawable->y; - if (pSrc->pDrawable) - { - xSrc += pSrc->pDrawable->x; - ySrc += pSrc->pDrawable->y; - } - if (pMask && pMask->pDrawable) - { - xMask += pMask->pDrawable->x; - yMask += pMask->pDrawable->y; - } - - if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc, - xMask, yMask, xDst, yDst, width, height)) - return; - - n = REGION_NUM_RECTS (®ion); - pbox = REGION_RECTS (®ion); - while (n--) - { - h = pbox->y2 - pbox->y1; - y_src = pbox->y1 - yDst + ySrc; - y_msk = pbox->y1 - yDst + yMask; - y_dst = pbox->y1; - while (h) - { - h_this = h; - w = pbox->x2 - pbox->x1; - x_src = pbox->x1 - xDst + xSrc; - x_msk = pbox->x1 - xDst + xMask; - x_dst = pbox->x1; - if (maskRepeat) - { - y_msk = mod (y_msk - pMask->pDrawable->y, pMask->pDrawable->height); - if (h_this > pMask->pDrawable->height - y_msk) - h_this = pMask->pDrawable->height - y_msk; - y_msk += pMask->pDrawable->y; - } - if (srcRepeat) - { - y_src = mod (y_src - pSrc->pDrawable->y, pSrc->pDrawable->height); - if (h_this > pSrc->pDrawable->height - y_src) - h_this = pSrc->pDrawable->height - y_src; - y_src += pSrc->pDrawable->y; - } - while (w) - { - w_this = w; - if (maskRepeat) - { - x_msk = mod (x_msk - pMask->pDrawable->x, pMask->pDrawable->width); - if (w_this > pMask->pDrawable->width - x_msk) - w_this = pMask->pDrawable->width - x_msk; - x_msk += pMask->pDrawable->x; - } - if (srcRepeat) - { - x_src = mod (x_src - pSrc->pDrawable->x, pSrc->pDrawable->width); - if (w_this > pSrc->pDrawable->width - x_src) - w_this = pSrc->pDrawable->width - x_src; - x_src += pSrc->pDrawable->x; - } - (*compositeRect) (op, pSrc, pMask, pDst, - x_src, y_src, x_msk, y_msk, x_dst, y_dst, - w_this, h_this); - w -= w_this; - x_src += w_this; - x_msk += w_this; - x_dst += w_this; - } - h -= h_this; - y_src += h_this; - y_msk += h_this; - y_dst += h_this; - } - pbox++; - } - REGION_UNINIT (pDst->pDrawable->pScreen, ®ion); -} - -void -fbComposite (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - pixman_image_t *src, *mask, *dest; - int src_xoff, src_yoff; - int msk_xoff, msk_yoff; - int dst_xoff, dst_yoff; - - miCompositeSourceValidate (pSrc, xSrc - xDst, ySrc - yDst, width, height); - if (pMask) - miCompositeSourceValidate (pMask, xMask - xDst, yMask - yDst, width, height); - - src = image_from_pict (pSrc, FALSE, &src_xoff, &src_yoff); - mask = image_from_pict (pMask, FALSE, &msk_xoff, &msk_yoff); - dest = image_from_pict (pDst, TRUE, &dst_xoff, &dst_yoff); - - if (src && dest && !(pMask && !mask)) - { - pixman_image_composite (op, src, mask, dest, - xSrc + src_xoff, ySrc + src_yoff, - xMask + msk_xoff, yMask + msk_yoff, - xDst + dst_xoff, yDst + dst_yoff, - width, height); - } - - free_pixman_pict (pSrc, src); - free_pixman_pict (pMask, mask); - free_pixman_pict (pDst, dest); -} - -void -fbCompositeGeneral (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - fbComposite (op, pSrc, pMask, pDst, - xSrc, ySrc, xMask, yMask, xDst, yDst, - width, height); -} - -static pixman_image_t * -create_solid_fill_image (PicturePtr pict) -{ - PictSolidFill *solid = &pict->pSourcePict->solidFill; - pixman_color_t color; - CARD32 a, r, g, b; - - a = (solid->color & 0xff000000) >> 24; - r = (solid->color & 0x00ff0000) >> 16; - g = (solid->color & 0x0000ff00) >> 8; - b = (solid->color & 0x000000ff) >> 0; - - color.alpha = (a << 8) | a; - color.red = (r << 8) | r; - color.green = (g << 8) | g; - color.blue = (b << 8) | b; - - return pixman_image_create_solid_fill (&color); -} - -static pixman_image_t * -create_linear_gradient_image (PictGradient *gradient) -{ - PictLinearGradient *linear = (PictLinearGradient *)gradient; - pixman_point_fixed_t p1; - pixman_point_fixed_t p2; - - p1.x = linear->p1.x; - p1.y = linear->p1.y; - p2.x = linear->p2.x; - p2.y = linear->p2.y; - - return pixman_image_create_linear_gradient ( - &p1, &p2, (pixman_gradient_stop_t *)gradient->stops, gradient->nstops); -} - -static pixman_image_t * -create_radial_gradient_image (PictGradient *gradient) -{ - PictRadialGradient *radial = (PictRadialGradient *)gradient; - pixman_point_fixed_t c1; - pixman_point_fixed_t c2; - - c1.x = radial->c1.x; - c1.y = radial->c1.y; - c2.x = radial->c2.x; - c2.y = radial->c2.y; - - return pixman_image_create_radial_gradient ( - &c1, &c2, radial->c1.radius, - radial->c2.radius, - (pixman_gradient_stop_t *)gradient->stops, gradient->nstops); -} - -static pixman_image_t * -create_conical_gradient_image (PictGradient *gradient) -{ - PictConicalGradient *conical = (PictConicalGradient *)gradient; - pixman_point_fixed_t center; - - center.x = conical->center.x; - center.y = conical->center.y; - - return pixman_image_create_conical_gradient ( - ¢er, conical->angle, (pixman_gradient_stop_t *)gradient->stops, - gradient->nstops); -} - -static pixman_image_t * -create_bits_picture (PicturePtr pict, - Bool has_clip, - int *xoff, - int *yoff) -{ - PixmapPtr pixmap; - FbBits *bits; - FbStride stride; - int bpp; - pixman_image_t *image; - - fbGetDrawablePixmap (pict->pDrawable, pixmap, *xoff, *yoff); - fbGetPixmapBitsData(pixmap, bits, stride, bpp); - - image = pixman_image_create_bits ( - pict->format, - pixmap->drawable.width, pixmap->drawable.height, - (uint32_t *)bits, stride * sizeof (FbStride)); - - -#ifdef FB_ACCESS_WRAPPER -#if FB_SHIFT==5 - - pixman_image_set_accessors (image, - (pixman_read_memory_func_t)wfbReadMemory, - (pixman_write_memory_func_t)wfbWriteMemory); - -#else - -#error The pixman library only works when FbBits is 32 bits wide - -#endif -#endif - - /* pCompositeClip is undefined for source pictures, so - * only set the clip region for pictures with drawables - */ - if (has_clip) - { - if (pict->clientClipType != CT_NONE) - pixman_image_set_has_client_clip (image, TRUE); - - if (*xoff || *yoff) - pixman_region_translate (pict->pCompositeClip, *xoff, *yoff); - - pixman_image_set_clip_region (image, pict->pCompositeClip); - - if (*xoff || *yoff) - pixman_region_translate (pict->pCompositeClip, -*xoff, -*yoff); - } - - /* Indexed table */ - if (pict->pFormat->index.devPrivate) - pixman_image_set_indexed (image, pict->pFormat->index.devPrivate); - - /* Add in drawable origin to position within the image */ - *xoff += pict->pDrawable->x; - *yoff += pict->pDrawable->y; - - return image; -} - -static void -set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int *xoff, int *yoff) -{ - pixman_repeat_t repeat; - pixman_filter_t filter; - - if (pict->transform) - { - /* For source images, adjust the transform to account - * for the drawable offset within the pixman image, - * then set the offset to 0 as it will be used - * to compute positions within the transformed image. - */ - if (!has_clip) { - struct pixman_transform adjusted; - - adjusted = *pict->transform; - pixman_transform_translate(&adjusted, - NULL, - pixman_int_to_fixed(*xoff), - pixman_int_to_fixed(*yoff)); - pixman_image_set_transform (image, &adjusted); - *xoff = 0; - *yoff = 0; - } else - pixman_image_set_transform (image, pict->transform); - } - - switch (pict->repeatType) - { - default: - case RepeatNone: - repeat = PIXMAN_REPEAT_NONE; - break; - - case RepeatPad: - repeat = PIXMAN_REPEAT_PAD; - break; - - case RepeatNormal: - repeat = PIXMAN_REPEAT_NORMAL; - break; - - case RepeatReflect: - repeat = PIXMAN_REPEAT_REFLECT; - break; - } - - pixman_image_set_repeat (image, repeat); - - if (pict->alphaMap) - { - int alpha_xoff, alpha_yoff; - pixman_image_t *alpha_map = image_from_pict (pict->alphaMap, FALSE, &alpha_xoff, &alpha_yoff); - - pixman_image_set_alpha_map ( - image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y); - - free_pixman_pict (pict->alphaMap, alpha_map); - } - - pixman_image_set_component_alpha (image, pict->componentAlpha); - - switch (pict->filter) - { - default: - case PictFilterNearest: - case PictFilterFast: - filter = PIXMAN_FILTER_NEAREST; - break; - - case PictFilterBilinear: - case PictFilterGood: - filter = PIXMAN_FILTER_BILINEAR; - break; - - case PictFilterConvolution: - filter = PIXMAN_FILTER_CONVOLUTION; - break; - } - - pixman_image_set_filter (image, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams); - pixman_image_set_source_clipping (image, TRUE); -} - -pixman_image_t * -image_from_pict (PicturePtr pict, Bool has_clip, int *xoff, int *yoff) -{ - pixman_image_t *image = NULL; - - if (!pict) - return NULL; - - if (pict->pDrawable) - { - image = create_bits_picture (pict, has_clip, xoff, yoff); - } - else if (pict->pSourcePict) - { - SourcePict *sp = pict->pSourcePict; - - if (sp->type == SourcePictTypeSolidFill) - { - image = create_solid_fill_image (pict); - } - else - { - PictGradient *gradient = &pict->pSourcePict->gradient; - - if (sp->type == SourcePictTypeLinear) - image = create_linear_gradient_image (gradient); - else if (sp->type == SourcePictTypeRadial) - image = create_radial_gradient_image (gradient); - else if (sp->type == SourcePictTypeConical) - image = create_conical_gradient_image (gradient); - } - *xoff = *yoff = 0; - } - - if (image) - set_image_properties (image, pict, has_clip, xoff, yoff); - - return image; -} - -void -free_pixman_pict (PicturePtr pict, pixman_image_t *image) -{ - if (image && pixman_image_unref (image) && pict->pDrawable) - fbFinishAccess (pict->pDrawable); -} - -Bool -fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) -{ - - PictureScreenPtr ps; - - if (!miPictureInit (pScreen, formats, nformats)) - return FALSE; - ps = GetPictureScreen(pScreen); - ps->Composite = fbComposite; - ps->Glyphs = miGlyphs; - ps->CompositeRects = miCompositeRects; - ps->RasterizeTrapezoid = fbRasterizeTrapezoid; - ps->AddTraps = fbAddTraps; - ps->AddTriangles = fbAddTriangles; - - return TRUE; -} +/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+
+#include "fb.h"
+
+#include "picturestr.h"
+#include "mipict.h"
+#include "fbpict.h"
+
+#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
+
+void
+fbWalkCompositeRegion (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height,
+ Bool srcRepeat,
+ Bool maskRepeat,
+ CompositeFunc compositeRect)
+{
+ RegionRec region;
+ int n;
+ BoxPtr pbox;
+ int w, h, w_this, h_this;
+ int x_msk, y_msk, x_src, y_src, x_dst, y_dst;
+
+ xDst += pDst->pDrawable->x;
+ yDst += pDst->pDrawable->y;
+ if (pSrc->pDrawable)
+ {
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+ }
+ if (pMask && pMask->pDrawable)
+ {
+ xMask += pMask->pDrawable->x;
+ yMask += pMask->pDrawable->y;
+ }
+
+ if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc,
+ xMask, yMask, xDst, yDst, width, height))
+ return;
+
+ n = RegionNumRects (®ion);
+ pbox = RegionRects (®ion);
+ while (n--)
+ {
+ h = pbox->y2 - pbox->y1;
+ y_src = pbox->y1 - yDst + ySrc;
+ y_msk = pbox->y1 - yDst + yMask;
+ y_dst = pbox->y1;
+ while (h)
+ {
+ h_this = h;
+ w = pbox->x2 - pbox->x1;
+ x_src = pbox->x1 - xDst + xSrc;
+ x_msk = pbox->x1 - xDst + xMask;
+ x_dst = pbox->x1;
+ if (maskRepeat)
+ {
+ y_msk = mod (y_msk - pMask->pDrawable->y, pMask->pDrawable->height);
+ if (h_this > pMask->pDrawable->height - y_msk)
+ h_this = pMask->pDrawable->height - y_msk;
+ y_msk += pMask->pDrawable->y;
+ }
+ if (srcRepeat)
+ {
+ y_src = mod (y_src - pSrc->pDrawable->y, pSrc->pDrawable->height);
+ if (h_this > pSrc->pDrawable->height - y_src)
+ h_this = pSrc->pDrawable->height - y_src;
+ y_src += pSrc->pDrawable->y;
+ }
+ while (w)
+ {
+ w_this = w;
+ if (maskRepeat)
+ {
+ x_msk = mod (x_msk - pMask->pDrawable->x, pMask->pDrawable->width);
+ if (w_this > pMask->pDrawable->width - x_msk)
+ w_this = pMask->pDrawable->width - x_msk;
+ x_msk += pMask->pDrawable->x;
+ }
+ if (srcRepeat)
+ {
+ x_src = mod (x_src - pSrc->pDrawable->x, pSrc->pDrawable->width);
+ if (w_this > pSrc->pDrawable->width - x_src)
+ w_this = pSrc->pDrawable->width - x_src;
+ x_src += pSrc->pDrawable->x;
+ }
+ (*compositeRect) (op, pSrc, pMask, pDst,
+ x_src, y_src, x_msk, y_msk, x_dst, y_dst,
+ w_this, h_this);
+ w -= w_this;
+ x_src += w_this;
+ x_msk += w_this;
+ x_dst += w_this;
+ }
+ h -= h_this;
+ y_src += h_this;
+ y_msk += h_this;
+ y_dst += h_this;
+ }
+ pbox++;
+ }
+ RegionUninit(®ion);
+}
+
+void
+fbComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ pixman_image_t *src, *mask, *dest;
+ int src_xoff, src_yoff;
+ int msk_xoff, msk_yoff;
+ int dst_xoff, dst_yoff;
+
+ miCompositeSourceValidate (pSrc, xSrc - xDst, ySrc - yDst, width, height);
+ if (pMask)
+ miCompositeSourceValidate (pMask, xMask - xDst, yMask - yDst, width, height);
+
+ src = image_from_pict (pSrc, FALSE, &src_xoff, &src_yoff);
+ mask = image_from_pict (pMask, FALSE, &msk_xoff, &msk_yoff);
+ dest = image_from_pict (pDst, TRUE, &dst_xoff, &dst_yoff);
+
+ if (src && dest && !(pMask && !mask))
+ {
+ pixman_image_composite (op, src, mask, dest,
+ xSrc + src_xoff, ySrc + src_yoff,
+ xMask + msk_xoff, yMask + msk_yoff,
+ xDst + dst_xoff, yDst + dst_yoff,
+ width, height);
+ }
+
+ free_pixman_pict (pSrc, src);
+ free_pixman_pict (pMask, mask);
+ free_pixman_pict (pDst, dest);
+}
+
+void
+fbCompositeGeneral (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ fbComposite (op, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ width, height);
+}
+
+static pixman_image_t *
+create_solid_fill_image (PicturePtr pict)
+{
+ PictSolidFill *solid = &pict->pSourcePict->solidFill;
+ pixman_color_t color;
+ CARD32 a, r, g, b;
+
+ a = (solid->color & 0xff000000) >> 24;
+ r = (solid->color & 0x00ff0000) >> 16;
+ g = (solid->color & 0x0000ff00) >> 8;
+ b = (solid->color & 0x000000ff) >> 0;
+
+ color.alpha = (a << 8) | a;
+ color.red = (r << 8) | r;
+ color.green = (g << 8) | g;
+ color.blue = (b << 8) | b;
+
+ return pixman_image_create_solid_fill (&color);
+}
+
+static pixman_image_t *
+create_linear_gradient_image (PictGradient *gradient)
+{
+ PictLinearGradient *linear = (PictLinearGradient *)gradient;
+ pixman_point_fixed_t p1;
+ pixman_point_fixed_t p2;
+
+ p1.x = linear->p1.x;
+ p1.y = linear->p1.y;
+ p2.x = linear->p2.x;
+ p2.y = linear->p2.y;
+
+ return pixman_image_create_linear_gradient (
+ &p1, &p2, (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+}
+
+static pixman_image_t *
+create_radial_gradient_image (PictGradient *gradient)
+{
+ PictRadialGradient *radial = (PictRadialGradient *)gradient;
+ pixman_point_fixed_t c1;
+ pixman_point_fixed_t c2;
+
+ c1.x = radial->c1.x;
+ c1.y = radial->c1.y;
+ c2.x = radial->c2.x;
+ c2.y = radial->c2.y;
+
+ return pixman_image_create_radial_gradient (
+ &c1, &c2, radial->c1.radius,
+ radial->c2.radius,
+ (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+}
+
+static pixman_image_t *
+create_conical_gradient_image (PictGradient *gradient)
+{
+ PictConicalGradient *conical = (PictConicalGradient *)gradient;
+ pixman_point_fixed_t center;
+
+ center.x = conical->center.x;
+ center.y = conical->center.y;
+
+ return pixman_image_create_conical_gradient (
+ ¢er, conical->angle, (pixman_gradient_stop_t *)gradient->stops,
+ gradient->nstops);
+}
+
+static pixman_image_t *
+create_bits_picture (PicturePtr pict,
+ Bool has_clip,
+ int *xoff,
+ int *yoff)
+{
+ PixmapPtr pixmap;
+ FbBits *bits;
+ FbStride stride;
+ int bpp;
+ pixman_image_t *image;
+
+ fbGetDrawablePixmap (pict->pDrawable, pixmap, *xoff, *yoff);
+ fbGetPixmapBitsData(pixmap, bits, stride, bpp);
+
+ image = pixman_image_create_bits (
+ pict->format,
+ pixmap->drawable.width, pixmap->drawable.height,
+ (uint32_t *)bits, stride * sizeof (FbStride));
+
+
+#ifdef FB_ACCESS_WRAPPER
+#if FB_SHIFT==5
+
+ pixman_image_set_accessors (image,
+ (pixman_read_memory_func_t)wfbReadMemory,
+ (pixman_write_memory_func_t)wfbWriteMemory);
+
+#else
+
+#error The pixman library only works when FbBits is 32 bits wide
+
+#endif
+#endif
+
+ /* pCompositeClip is undefined for source pictures, so
+ * only set the clip region for pictures with drawables
+ */
+ if (has_clip)
+ {
+ if (pict->clientClipType != CT_NONE)
+ pixman_image_set_has_client_clip (image, TRUE);
+
+ if (*xoff || *yoff)
+ pixman_region_translate (pict->pCompositeClip, *xoff, *yoff);
+
+ pixman_image_set_clip_region (image, pict->pCompositeClip);
+
+ if (*xoff || *yoff)
+ pixman_region_translate (pict->pCompositeClip, -*xoff, -*yoff);
+ }
+
+ /* Indexed table */
+ if (pict->pFormat->index.devPrivate)
+ pixman_image_set_indexed (image, pict->pFormat->index.devPrivate);
+
+ /* Add in drawable origin to position within the image */
+ *xoff += pict->pDrawable->x;
+ *yoff += pict->pDrawable->y;
+
+ return image;
+}
+
+static void
+set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+{
+ pixman_repeat_t repeat;
+ pixman_filter_t filter;
+
+ if (pict->transform)
+ {
+ /* For source images, adjust the transform to account
+ * for the drawable offset within the pixman image,
+ * then set the offset to 0 as it will be used
+ * to compute positions within the transformed image.
+ */
+ if (!has_clip) {
+ struct pixman_transform adjusted;
+
+ adjusted = *pict->transform;
+ pixman_transform_translate(&adjusted,
+ NULL,
+ pixman_int_to_fixed(*xoff),
+ pixman_int_to_fixed(*yoff));
+ pixman_image_set_transform (image, &adjusted);
+ *xoff = 0;
+ *yoff = 0;
+ } else
+ pixman_image_set_transform (image, pict->transform);
+ }
+
+ switch (pict->repeatType)
+ {
+ default:
+ case RepeatNone:
+ repeat = PIXMAN_REPEAT_NONE;
+ break;
+
+ case RepeatPad:
+ repeat = PIXMAN_REPEAT_PAD;
+ break;
+
+ case RepeatNormal:
+ repeat = PIXMAN_REPEAT_NORMAL;
+ break;
+
+ case RepeatReflect:
+ repeat = PIXMAN_REPEAT_REFLECT;
+ break;
+ }
+
+ pixman_image_set_repeat (image, repeat);
+
+ if (pict->alphaMap)
+ {
+ int alpha_xoff, alpha_yoff;
+ pixman_image_t *alpha_map = image_from_pict (pict->alphaMap, FALSE, &alpha_xoff, &alpha_yoff);
+
+ pixman_image_set_alpha_map (
+ image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
+
+ free_pixman_pict (pict->alphaMap, alpha_map);
+ }
+
+ pixman_image_set_component_alpha (image, pict->componentAlpha);
+
+ switch (pict->filter)
+ {
+ default:
+ case PictFilterNearest:
+ case PictFilterFast:
+ filter = PIXMAN_FILTER_NEAREST;
+ break;
+
+ case PictFilterBilinear:
+ case PictFilterGood:
+ filter = PIXMAN_FILTER_BILINEAR;
+ break;
+
+ case PictFilterConvolution:
+ filter = PIXMAN_FILTER_CONVOLUTION;
+ break;
+ }
+
+ pixman_image_set_filter (image, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams);
+ pixman_image_set_source_clipping (image, TRUE);
+}
+
+pixman_image_t *
+image_from_pict (PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+{
+ pixman_image_t *image = NULL;
+
+ if (!pict)
+ return NULL;
+
+ if (pict->pDrawable)
+ {
+ image = create_bits_picture (pict, has_clip, xoff, yoff);
+ }
+ else if (pict->pSourcePict)
+ {
+ SourcePict *sp = pict->pSourcePict;
+
+ if (sp->type == SourcePictTypeSolidFill)
+ {
+ image = create_solid_fill_image (pict);
+ }
+ else
+ {
+ PictGradient *gradient = &pict->pSourcePict->gradient;
+
+ if (sp->type == SourcePictTypeLinear)
+ image = create_linear_gradient_image (gradient);
+ else if (sp->type == SourcePictTypeRadial)
+ image = create_radial_gradient_image (gradient);
+ else if (sp->type == SourcePictTypeConical)
+ image = create_conical_gradient_image (gradient);
+ }
+ *xoff = *yoff = 0;
+ }
+
+ if (image)
+ set_image_properties (image, pict, has_clip, xoff, yoff);
+
+ return image;
+}
+
+void
+free_pixman_pict (PicturePtr pict, pixman_image_t *image)
+{
+ if (image && pixman_image_unref (image) && pict->pDrawable)
+ fbFinishAccess (pict->pDrawable);
+}
+
+Bool
+fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+{
+
+ PictureScreenPtr ps;
+
+ if (!miPictureInit (pScreen, formats, nformats))
+ return FALSE;
+ ps = GetPictureScreen(pScreen);
+ ps->Composite = fbComposite;
+ ps->Glyphs = miGlyphs;
+ ps->CompositeRects = miCompositeRects;
+ ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
+ ps->AddTraps = fbAddTraps;
+ ps->AddTriangles = fbAddTriangles;
+
+ return TRUE;
+}
diff --git a/xorg-server/fb/fbpixmap.c b/xorg-server/fb/fbpixmap.c index 4714ef22e..80d3252d2 100644 --- a/xorg-server/fb/fbpixmap.c +++ b/xorg-server/fb/fbpixmap.c @@ -67,6 +67,7 @@ fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp, pPixmap->devKind = paddedWidth;
pPixmap->refcnt = 1;
pPixmap->devPrivate.ptr = (pointer) ((char *)pPixmap + base + adjust);
+
#ifdef FB_DEBUG
pPixmap->devPrivate.ptr = (void *) ((char *) pPixmap->devPrivate.ptr + paddedWidth);
fbInitializeDrawable (&pPixmap->drawable);
@@ -100,8 +101,7 @@ fbDestroyPixmap (PixmapPtr pPixmap) {
if(--pPixmap->refcnt)
return TRUE;
- dixFreePrivates(pPixmap->devPrivates);
- free(pPixmap);
+ FreePixmap(pPixmap);
return TRUE;
}
@@ -115,8 +115,8 @@ if (((rx1) < (rx2)) && ((ry1) < (ry2)) && \ { \
if ((reg)->data->numRects == (reg)->data->size) \
{ \
- miRectAlloc(reg, 1); \
- fr = REGION_BOXPTR(reg); \
+ RegionRectAlloc(reg, 1); \
+ fr = RegionBoxptr(reg); \
r = fr + (reg)->data->numRects; \
} \
r->x1 = (rx1); \
@@ -153,10 +153,10 @@ fbPixmapToRegion(PixmapPtr pPix) FbBits *pwLine;
int nWidth;
- pReg = REGION_CREATE(pPix->drawable.pScreen, NULL, 1);
+ pReg = RegionCreate(NULL, 1);
if(!pReg)
return NullRegion;
- FirstRect = REGION_BOXPTR(pReg);
+ FirstRect = RegionBoxptr(pReg);
rects = FirstRect;
fbPrepareAccess(&pPix->drawable);
@@ -304,8 +304,8 @@ fbPixmapToRegion(PixmapPtr pPix) pReg->extents.x1 = pReg->extents.x2 = 0;
else
{
- pReg->extents.y1 = REGION_BOXPTR(pReg)->y1;
- pReg->extents.y2 = REGION_END(pReg)->y2;
+ pReg->extents.y1 = RegionBoxptr(pReg)->y1;
+ pReg->extents.y2 = RegionEnd(pReg)->y2;
if (pReg->data->numRects == 1)
{
free(pReg->data);
@@ -315,10 +315,10 @@ fbPixmapToRegion(PixmapPtr pPix) fbFinishAccess(&pPix->drawable);
#ifdef DEBUG
- if (!miValidRegion(pReg))
+ if (!RegionIsValid(pReg))
FatalError("Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__);
#endif
- return(pReg);
+ return pReg;
}
#ifdef FB_DEBUG
diff --git a/xorg-server/fb/fbpoint.c b/xorg-server/fb/fbpoint.c index c0ea8ba5b..d675dbaff 100644 --- a/xorg-server/fb/fbpoint.c +++ b/xorg-server/fb/fbpoint.c @@ -1,162 +1,162 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "fb.h" - -typedef void (*FbDots) (FbBits *dst, - FbStride dstStride, - int dstBpp, - BoxPtr pBox, - xPoint *pts, - int npt, - int xorg, - int yorg, - int xoff, - int yoff, - FbBits and, - FbBits xor); - -void -fbDots (FbBits *dstOrig, - FbStride dstStride, - int dstBpp, - BoxPtr pBox, - xPoint *pts, - int npt, - int xorg, - int yorg, - int xoff, - int yoff, - FbBits andOrig, - FbBits xorOrig) -{ - FbStip *dst = (FbStip *) dstOrig; - int x1, y1, x2, y2; - int x, y; - FbStip *d; - FbStip and = andOrig; - FbStip xor = xorOrig; - - dstStride = FbBitsStrideToStipStride (dstStride); - x1 = pBox->x1; - y1 = pBox->y1; - x2 = pBox->x2; - y2 = pBox->y2; - while (npt--) - { - x = pts->x + xorg; - y = pts->y + yorg; - pts++; - if (x1 <= x && x < x2 && y1 <= y && y < y2) - { - x = (x + xoff) * dstBpp; - d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT); - x &= FB_STIP_MASK; -#ifdef FB_24BIT - if (dstBpp == 24) - { - FbStip leftMask, rightMask; - int n, rot; - FbStip andT, xorT; - - rot = FbFirst24Rot (x); - andT = FbRot24Stip(and,rot); - xorT = FbRot24Stip(xor,rot); - FbMaskStip (x, 24, leftMask, n, rightMask); - if (leftMask) - { - WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask)); - andT = FbNext24Stip(andT); - xorT = FbNext24Stip(xorT); - d++; - } - if (rightMask) - WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, rightMask)); - } - else -#endif - { - FbStip mask; - mask = FbStipMask(x, dstBpp); - WRITE(d, FbDoMaskRRop (READ(d), and, xor, mask)); - } - } - } -} - -void -fbPolyPoint (DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int nptInit, - xPoint *pptInit) -{ - FbGCPrivPtr pPriv = fbGetGCPrivate (pGC); - RegionPtr pClip = fbGetCompositeClip(pGC); - FbBits *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - FbDots dots; - FbBits and, xor; - xPoint *ppt; - int npt; - BoxPtr pBox; - int nBox; - - /* make pointlist origin relative */ - ppt = pptInit; - npt = nptInit; - if (mode == CoordModePrevious) - { - npt--; - while(npt--) - { - ppt++; - ppt->x += (ppt-1)->x; - ppt->y += (ppt-1)->y; - } - } - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - and = pPriv->and; - xor = pPriv->xor; - dots = fbDots; -#ifndef FBNOPIXADDR - switch (dstBpp) { - case 8: dots = fbDots8; break; - case 16: dots = fbDots16; break; -#ifdef FB_24BIT - case 24: dots = fbDots24; break; -#endif - case 32: dots = fbDots32; break; - } -#endif - for (nBox = REGION_NUM_RECTS (pClip), pBox = REGION_RECTS (pClip); - nBox--; pBox++) - (*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit, - pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor); - fbFinishAccess (pDrawable); -} +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+typedef void (*FbDots) (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+void
+fbDots (FbBits *dstOrig,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits andOrig,
+ FbBits xorOrig)
+{
+ FbStip *dst = (FbStip *) dstOrig;
+ int x1, y1, x2, y2;
+ int x, y;
+ FbStip *d;
+ FbStip and = andOrig;
+ FbStip xor = xorOrig;
+
+ dstStride = FbBitsStrideToStipStride (dstStride);
+ x1 = pBox->x1;
+ y1 = pBox->y1;
+ x2 = pBox->x2;
+ y2 = pBox->y2;
+ while (npt--)
+ {
+ x = pts->x + xorg;
+ y = pts->y + yorg;
+ pts++;
+ if (x1 <= x && x < x2 && y1 <= y && y < y2)
+ {
+ x = (x + xoff) * dstBpp;
+ d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT);
+ x &= FB_STIP_MASK;
+#ifdef FB_24BIT
+ if (dstBpp == 24)
+ {
+ FbStip leftMask, rightMask;
+ int n, rot;
+ FbStip andT, xorT;
+
+ rot = FbFirst24Rot (x);
+ andT = FbRot24Stip(and,rot);
+ xorT = FbRot24Stip(xor,rot);
+ FbMaskStip (x, 24, leftMask, n, rightMask);
+ if (leftMask)
+ {
+ WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask));
+ andT = FbNext24Stip(andT);
+ xorT = FbNext24Stip(xorT);
+ d++;
+ }
+ if (rightMask)
+ WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, rightMask));
+ }
+ else
+#endif
+ {
+ FbStip mask;
+ mask = FbStipMask(x, dstBpp);
+ WRITE(d, FbDoMaskRRop (READ(d), and, xor, mask));
+ }
+ }
+ }
+}
+
+void
+fbPolyPoint (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nptInit,
+ xPoint *pptInit)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbDots dots;
+ FbBits and, xor;
+ xPoint *ppt;
+ int npt;
+ BoxPtr pBox;
+ int nBox;
+
+ /* make pointlist origin relative */
+ ppt = pptInit;
+ npt = nptInit;
+ if (mode == CoordModePrevious)
+ {
+ npt--;
+ while(npt--)
+ {
+ ppt++;
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+ }
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ and = pPriv->and;
+ xor = pPriv->xor;
+ dots = fbDots;
+#ifndef FBNOPIXADDR
+ switch (dstBpp) {
+ case 8: dots = fbDots8; break;
+ case 16: dots = fbDots16; break;
+#ifdef FB_24BIT
+ case 24: dots = fbDots24; break;
+#endif
+ case 32: dots = fbDots32; break;
+ }
+#endif
+ for (nBox = RegionNumRects (pClip), pBox = RegionRects (pClip);
+ nBox--; pBox++)
+ (*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit,
+ pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor);
+ fbFinishAccess (pDrawable);
+}
diff --git a/xorg-server/fb/fbpush.c b/xorg-server/fb/fbpush.c index 891572f0d..cfb702483 100644 --- a/xorg-server/fb/fbpush.c +++ b/xorg-server/fb/fbpush.c @@ -1,245 +1,245 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "fb.h" - -void -fbPushPattern (DrawablePtr pDrawable, - GCPtr pGC, - - FbStip *src, - FbStride srcStride, - int srcX, - - int x, - int y, - - int width, - int height) -{ - FbStip *s, bitsMask, bitsMask0, bits; - int xspan; - int w; - int lenspan; - - src += srcX >> FB_STIP_SHIFT; - srcX &= FB_STIP_MASK; - - bitsMask0 = FbStipMask (srcX, 1); - - while (height--) - { - bitsMask = bitsMask0; - w = width; - s = src; - src += srcStride; - bits = READ(s++); - xspan = x; - while (w) - { - if (bits & bitsMask) - { - lenspan = 0; - do - { - lenspan++; - if (lenspan == w) - break; - bitsMask = FbStipRight (bitsMask, 1); - if (!bitsMask) - { - bits = READ(s++); - bitsMask = FbBitsMask(0,1); - } - } while (bits & bitsMask); - fbFill (pDrawable, pGC, xspan, y, lenspan, 1); - xspan += lenspan; - w -= lenspan; - } - else - { - do - { - w--; - xspan++; - if (!w) - break; - bitsMask = FbStipRight (bitsMask, 1); - if (!bitsMask) - { - bits = READ(s++); - bitsMask = FbBitsMask(0,1); - } - } while (!(bits & bitsMask)); - } - } - y++; - } -} - -void -fbPushFill (DrawablePtr pDrawable, - GCPtr pGC, - - FbStip *src, - FbStride srcStride, - int srcX, - - int x, - int y, - int width, - int height) -{ - FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); - - if (pGC->fillStyle == FillSolid) - { - FbBits *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - int dstX; - int dstWidth; - - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - dst = dst + (y + dstYoff) * dstStride; - dstX = (x + dstXoff) * dstBpp; - dstWidth = width * dstBpp; - if (dstBpp == 1) - { - fbBltStip (src, - srcStride, - srcX, - - (FbStip *) dst, - FbBitsStrideToStipStride (dstStride), - dstX, - - dstWidth, - height, - - FbStipple1Rop(pGC->alu,pGC->fgPixel), - pPriv->pm, - dstBpp); - } - else - { - fbBltOne (src, - srcStride, - srcX, - - dst, - dstStride, - dstX, - dstBpp, - - dstWidth, - height, - - pPriv->and, pPriv->xor, - fbAnd(GXnoop,(FbBits) 0,FB_ALLONES), - fbXor(GXnoop,(FbBits) 0,FB_ALLONES)); - } - fbFinishAccess (pDrawable); - } - else - { - fbPushPattern (pDrawable, pGC, src, srcStride, srcX, - x, y, width, height); - } -} - -void -fbPushImage (DrawablePtr pDrawable, - GCPtr pGC, - - FbStip *src, - FbStride srcStride, - int srcX, - - int x, - int y, - int width, - int height) -{ - RegionPtr pClip = fbGetCompositeClip (pGC); - int nbox; - BoxPtr pbox; - int x1, y1, x2, y2; - - for (nbox = REGION_NUM_RECTS (pClip), - pbox = REGION_RECTS(pClip); - nbox--; - pbox++) - { - x1 = x; - y1 = y; - x2 = x + width; - y2 = y + height; - if (x1 < pbox->x1) - x1 = pbox->x1; - if (y1 < pbox->y1) - y1 = pbox->y1; - if (x2 > pbox->x2) - x2 = pbox->x2; - if (y2 > pbox->y2) - y2 = pbox->y2; - if (x1 >= x2 || y1 >= y2) - continue; - fbPushFill (pDrawable, - pGC, - - src + (y1 - y) * srcStride, - srcStride, - srcX + (x1 - x), - - x1, - y1, - x2 - x1, - y2 - y1); - } -} - -void -fbPushPixels (GCPtr pGC, - PixmapPtr pBitmap, - DrawablePtr pDrawable, - int dx, - int dy, - int xOrg, - int yOrg) -{ - FbStip *stip; - FbStride stipStride; - int stipBpp; - int stipXoff, stipYoff; /* Assumed to be zero */ - - fbGetStipDrawable (&pBitmap->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff); - - fbPushImage (pDrawable, pGC, - stip, stipStride, 0, - xOrg, yOrg, dx, dy); -} +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbPushPattern (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+
+ int width,
+ int height)
+{
+ FbStip *s, bitsMask, bitsMask0, bits;
+ int xspan;
+ int w;
+ int lenspan;
+
+ src += srcX >> FB_STIP_SHIFT;
+ srcX &= FB_STIP_MASK;
+
+ bitsMask0 = FbStipMask (srcX, 1);
+
+ while (height--)
+ {
+ bitsMask = bitsMask0;
+ w = width;
+ s = src;
+ src += srcStride;
+ bits = READ(s++);
+ xspan = x;
+ while (w)
+ {
+ if (bits & bitsMask)
+ {
+ lenspan = 0;
+ do
+ {
+ lenspan++;
+ if (lenspan == w)
+ break;
+ bitsMask = FbStipRight (bitsMask, 1);
+ if (!bitsMask)
+ {
+ bits = READ(s++);
+ bitsMask = FbBitsMask(0,1);
+ }
+ } while (bits & bitsMask);
+ fbFill (pDrawable, pGC, xspan, y, lenspan, 1);
+ xspan += lenspan;
+ w -= lenspan;
+ }
+ else
+ {
+ do
+ {
+ w--;
+ xspan++;
+ if (!w)
+ break;
+ bitsMask = FbStipRight (bitsMask, 1);
+ if (!bitsMask)
+ {
+ bits = READ(s++);
+ bitsMask = FbBitsMask(0,1);
+ }
+ } while (!(bits & bitsMask));
+ }
+ }
+ y++;
+ }
+}
+
+void
+fbPushFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+
+ if (pGC->fillStyle == FillSolid)
+ {
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int dstX;
+ int dstWidth;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ dst = dst + (y + dstYoff) * dstStride;
+ dstX = (x + dstXoff) * dstBpp;
+ dstWidth = width * dstBpp;
+ if (dstBpp == 1)
+ {
+ fbBltStip (src,
+ srcStride,
+ srcX,
+
+ (FbStip *) dst,
+ FbBitsStrideToStipStride (dstStride),
+ dstX,
+
+ dstWidth,
+ height,
+
+ FbStipple1Rop(pGC->alu,pGC->fgPixel),
+ pPriv->pm,
+ dstBpp);
+ }
+ else
+ {
+ fbBltOne (src,
+ srcStride,
+ srcX,
+
+ dst,
+ dstStride,
+ dstX,
+ dstBpp,
+
+ dstWidth,
+ height,
+
+ pPriv->and, pPriv->xor,
+ fbAnd(GXnoop,(FbBits) 0,FB_ALLONES),
+ fbXor(GXnoop,(FbBits) 0,FB_ALLONES));
+ }
+ fbFinishAccess (pDrawable);
+ }
+ else
+ {
+ fbPushPattern (pDrawable, pGC, src, srcStride, srcX,
+ x, y, width, height);
+ }
+}
+
+void
+fbPushImage (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ RegionPtr pClip = fbGetCompositeClip (pGC);
+ int nbox;
+ BoxPtr pbox;
+ int x1, y1, x2, y2;
+
+ for (nbox = RegionNumRects (pClip),
+ pbox = RegionRects(pClip);
+ nbox--;
+ pbox++)
+ {
+ x1 = x;
+ y1 = y;
+ x2 = x + width;
+ y2 = y + height;
+ if (x1 < pbox->x1)
+ x1 = pbox->x1;
+ if (y1 < pbox->y1)
+ y1 = pbox->y1;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ fbPushFill (pDrawable,
+ pGC,
+
+ src + (y1 - y) * srcStride,
+ srcStride,
+ srcX + (x1 - x),
+
+ x1,
+ y1,
+ x2 - x1,
+ y2 - y1);
+ }
+}
+
+void
+fbPushPixels (GCPtr pGC,
+ PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int dx,
+ int dy,
+ int xOrg,
+ int yOrg)
+{
+ FbStip *stip;
+ FbStride stipStride;
+ int stipBpp;
+ int stipXoff, stipYoff; /* Assumed to be zero */
+
+ fbGetStipDrawable (&pBitmap->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
+
+ fbPushImage (pDrawable, pGC,
+ stip, stipStride, 0,
+ xOrg, yOrg, dx, dy);
+}
diff --git a/xorg-server/fb/fbscreen.c b/xorg-server/fb/fbscreen.c index 65af64074..f6eda6d64 100644 --- a/xorg-server/fb/fbscreen.c +++ b/xorg-server/fb/fbscreen.c @@ -37,22 +37,19 @@ fbCloseScreen (int index, ScreenPtr pScreen) free(depths);
free(pScreen->visuals);
free(pScreen->devPrivate);
-#ifdef FB_SCREEN_PRIVATE
- free(dixLookupPrivate(&pScreen->devPrivates, fbGetScreenPrivateKey()));
-#endif
return TRUE;
}
Bool
fbRealizeFont(ScreenPtr pScreen, FontPtr pFont)
{
- return (TRUE);
+ return TRUE;
}
Bool
fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
{
- return (TRUE);
+ return TRUE;
}
void
diff --git a/xorg-server/fb/fbseg.c b/xorg-server/fb/fbseg.c index 0236721ab..8a68857f7 100644 --- a/xorg-server/fb/fbseg.c +++ b/xorg-server/fb/fbseg.c @@ -624,8 +624,8 @@ fbSegment (DrawablePtr pDrawable, unsigned int oc1; /* outcode of point 1 */
unsigned int oc2; /* outcode of point 2 */
- nBox = REGION_NUM_RECTS (pClip);
- pBox = REGION_RECTS (pClip);
+ nBox = RegionNumRects (pClip);
+ pBox = RegionRects (pClip);
bres = fbSelectBres (pDrawable, pGC);
diff --git a/xorg-server/fb/fbsetsp.c b/xorg-server/fb/fbsetsp.c index 227ba4c62..ce016453f 100644 --- a/xorg-server/fb/fbsetsp.c +++ b/xorg-server/fb/fbsetsp.c @@ -1,102 +1,102 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "fb.h" - -void -fbSetSpans (DrawablePtr pDrawable, - GCPtr pGC, - char *src, - DDXPointPtr ppt, - int *pwidth, - int nspans, - int fSorted) -{ - FbGCPrivPtr pPriv = fbGetGCPrivate (pGC); - RegionPtr pClip = fbGetCompositeClip(pGC); - FbBits *dst, *d, *s; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - BoxPtr pbox; - int n; - int xoff; - int x1, x2; - -#ifdef FB_24_32BIT - if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth)) - { - fb24_32SetSpans (pDrawable, pGC, src, ppt, pwidth, nspans, fSorted); - return; - } -#endif - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - while (nspans--) - { - d = dst + (ppt->y + dstYoff) * dstStride; - xoff = (int) (((long) src) & (FB_MASK >> 3)); - s = (FbBits *) (src - xoff); - xoff <<= 3; - n = REGION_NUM_RECTS(pClip); - pbox = REGION_RECTS (pClip); - while (n--) - { - if (pbox->y1 > ppt->y) - break; - if (pbox->y2 > ppt->y) - { - x1 = ppt->x; - x2 = x1 + *pwidth; - if (pbox->x1 > x1) - x1 = pbox->x1; - if (pbox->x2 < x2) - x2 = pbox->x2; - if (x1 < x2) - fbBlt ((FbBits *) s, - 0, - (x1 - ppt->x) * dstBpp + xoff, - d, - dstStride, - (x1 + dstXoff) * dstBpp, - - (x2 - x1) * dstBpp, - 1, - pGC->alu, - pPriv->pm, - dstBpp, - - FALSE, - FALSE); - } - } - src += PixmapBytePad (*pwidth, pDrawable->depth); - ppt++; - pwidth++; - } - fbValidateDrawable (pDrawable); - fbFinishAccess (pDrawable); -} - +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbSetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ FbBits *dst, *d, *s;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ BoxPtr pbox;
+ int n;
+ int xoff;
+ int x1, x2;
+
+#ifdef FB_24_32BIT
+ if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
+ {
+ fb24_32SetSpans (pDrawable, pGC, src, ppt, pwidth, nspans, fSorted);
+ return;
+ }
+#endif
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ while (nspans--)
+ {
+ d = dst + (ppt->y + dstYoff) * dstStride;
+ xoff = (int) (((long) src) & (FB_MASK >> 3));
+ s = (FbBits *) (src - xoff);
+ xoff <<= 3;
+ n = RegionNumRects(pClip);
+ pbox = RegionRects (pClip);
+ while (n--)
+ {
+ if (pbox->y1 > ppt->y)
+ break;
+ if (pbox->y2 > ppt->y)
+ {
+ x1 = ppt->x;
+ x2 = x1 + *pwidth;
+ if (pbox->x1 > x1)
+ x1 = pbox->x1;
+ if (pbox->x2 < x2)
+ x2 = pbox->x2;
+ if (x1 < x2)
+ fbBlt ((FbBits *) s,
+ 0,
+ (x1 - ppt->x) * dstBpp + xoff,
+ d,
+ dstStride,
+ (x1 + dstXoff) * dstBpp,
+
+ (x2 - x1) * dstBpp,
+ 1,
+ pGC->alu,
+ pPriv->pm,
+ dstBpp,
+
+ FALSE,
+ FALSE);
+ }
+ }
+ src += PixmapBytePad (*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+ fbValidateDrawable (pDrawable);
+ fbFinishAccess (pDrawable);
+}
+
diff --git a/xorg-server/fb/fbwindow.c b/xorg-server/fb/fbwindow.c index 46c033448..92b23acdb 100644 --- a/xorg-server/fb/fbwindow.c +++ b/xorg-server/fb/fbwindow.c @@ -1,250 +1,250 @@ -/* - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdlib.h> - -#include "fb.h" - -Bool -fbCreateWindow(WindowPtr pWin) -{ - dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), - fbGetScreenPixmap(pWin->drawable.pScreen)); -#ifdef FB_SCREEN_PRIVATE - if (pWin->drawable.bitsPerPixel == 32) - pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp; -#endif - return TRUE; -} - -Bool -fbDestroyWindow(WindowPtr pWin) -{ - return TRUE; -} - -Bool -fbMapWindow(WindowPtr pWindow) -{ - return TRUE; -} - -Bool -fbPositionWindow(WindowPtr pWin, int x, int y) -{ - return TRUE; -} - -Bool -fbUnmapWindow(WindowPtr pWindow) -{ - return TRUE; -} - -void -fbCopyWindowProc (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pbox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure) -{ - FbBits *src; - FbStride srcStride; - int srcBpp; - int srcXoff, srcYoff; - FbBits *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - - fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff); - fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - - while (nbox--) - { - fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride, - srcStride, - (pbox->x1 + dx + srcXoff) * srcBpp, - - dst + (pbox->y1 + dstYoff) * dstStride, - dstStride, - (pbox->x1 + dstXoff) * dstBpp, - - (pbox->x2 - pbox->x1) * dstBpp, - (pbox->y2 - pbox->y1), - - GXcopy, - FB_ALLONES, - dstBpp, - - reverse, - upsidedown); - pbox++; - } - - fbFinishAccess (pDstDrawable); - fbFinishAccess (pSrcDrawable); -} - -void -fbCopyWindow(WindowPtr pWin, - DDXPointRec ptOldOrg, - RegionPtr prgnSrc) -{ - RegionRec rgnDst; - int dx, dy; - - PixmapPtr pPixmap = fbGetWindowPixmap (pWin); - DrawablePtr pDrawable = &pPixmap->drawable; - - dx = ptOldOrg.x - pWin->drawable.x; - dy = ptOldOrg.y - pWin->drawable.y; - REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy); - - REGION_NULL (pWin->drawable.pScreen, &rgnDst); - - REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc); - -#ifdef COMPOSITE - if (pPixmap->screen_x || pPixmap->screen_y) - REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst, - -pPixmap->screen_x, -pPixmap->screen_y); -#endif - - miCopyRegion (pDrawable, pDrawable, - 0, - &rgnDst, dx, dy, fbCopyWindowProc, 0, 0); - - REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); - fbValidateDrawable (&pWin->drawable); -} - -Bool -fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask) -{ - PixmapPtr pPixmap; - - if (mask & CWBackPixmap) - { - if (pWin->backgroundState == BackgroundPixmap) - { - pPixmap = pWin->background.pixmap; -#ifdef FB_24_32BIT - if (pPixmap->drawable.bitsPerPixel != pWin->drawable.bitsPerPixel) - { - pPixmap = fb24_32ReformatTile (pPixmap, - pWin->drawable.bitsPerPixel); - if (pPixmap) - { - (*pWin->drawable.pScreen->DestroyPixmap) (pWin->background.pixmap); - pWin->background.pixmap = pPixmap; - } - } -#endif - if (FbEvenTile (pPixmap->drawable.width * - pPixmap->drawable.bitsPerPixel)) - fbPadPixmap (pPixmap); - } - } - if (mask & CWBorderPixmap) - { - if (pWin->borderIsPixel == FALSE) - { - pPixmap = pWin->border.pixmap; -#ifdef FB_24_32BIT - if (pPixmap->drawable.bitsPerPixel != - pWin->drawable.bitsPerPixel) - { - pPixmap = fb24_32ReformatTile (pPixmap, - pWin->drawable.bitsPerPixel); - if (pPixmap) - { - (*pWin->drawable.pScreen->DestroyPixmap) (pWin->border.pixmap); - pWin->border.pixmap = pPixmap; - } - } -#endif - if (FbEvenTile (pPixmap->drawable.width * - pPixmap->drawable.bitsPerPixel)) - fbPadPixmap (pPixmap); - } - } - return TRUE; -} - -void -fbFillRegionSolid (DrawablePtr pDrawable, - RegionPtr pRegion, - FbBits and, - FbBits xor) -{ - FbBits *dst; - FbStride dstStride; - int dstBpp; - int dstXoff, dstYoff; - int n = REGION_NUM_RECTS(pRegion); - BoxPtr pbox = REGION_RECTS(pRegion); - -#ifndef FB_ACCESS_WRAPPER - int try_mmx = 0; - if (!and) - try_mmx = 1; -#endif - - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - - while (n--) - { -#ifndef FB_ACCESS_WRAPPER - if (!try_mmx || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp, - pbox->x1 + dstXoff, pbox->y1 + dstYoff, - (pbox->x2 - pbox->x1), - (pbox->y2 - pbox->y1), - xor)) - { -#endif - fbSolid (dst + (pbox->y1 + dstYoff) * dstStride, - dstStride, - (pbox->x1 + dstXoff) * dstBpp, - dstBpp, - (pbox->x2 - pbox->x1) * dstBpp, - pbox->y2 - pbox->y1, - and, xor); -#ifndef FB_ACCESS_WRAPPER - } -#endif - fbValidateDrawable (pDrawable); - pbox++; - } - - fbFinishAccess (pDrawable); -} +/*
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "fb.h"
+
+Bool
+fbCreateWindow(WindowPtr pWin)
+{
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(),
+ fbGetScreenPixmap(pWin->drawable.pScreen));
+#ifdef FB_SCREEN_PRIVATE
+ if (pWin->drawable.bitsPerPixel == 32)
+ pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
+#endif
+ return TRUE;
+}
+
+Bool
+fbDestroyWindow(WindowPtr pWin)
+{
+ return TRUE;
+}
+
+Bool
+fbMapWindow(WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+Bool
+fbPositionWindow(WindowPtr pWin, int x, int y)
+{
+ return TRUE;
+}
+
+Bool
+fbUnmapWindow(WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+void
+fbCopyWindowProc (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ while (nbox--)
+ {
+ fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+
+ (pbox->x2 - pbox->x1) * dstBpp,
+ (pbox->y2 - pbox->y1),
+
+ GXcopy,
+ FB_ALLONES,
+ dstBpp,
+
+ reverse,
+ upsidedown);
+ pbox++;
+ }
+
+ fbFinishAccess (pDstDrawable);
+ fbFinishAccess (pSrcDrawable);
+}
+
+void
+fbCopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ RegionRec rgnDst;
+ int dx, dy;
+
+ PixmapPtr pPixmap = fbGetWindowPixmap (pWin);
+ DrawablePtr pDrawable = &pPixmap->drawable;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ RegionTranslate(prgnSrc, -dx, -dy);
+
+ RegionNull(&rgnDst);
+
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
+
+#ifdef COMPOSITE
+ if (pPixmap->screen_x || pPixmap->screen_y)
+ RegionTranslate(&rgnDst,
+ -pPixmap->screen_x, -pPixmap->screen_y);
+#endif
+
+ miCopyRegion (pDrawable, pDrawable,
+ 0,
+ &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
+
+ RegionUninit(&rgnDst);
+ fbValidateDrawable (&pWin->drawable);
+}
+
+Bool
+fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
+{
+ PixmapPtr pPixmap;
+
+ if (mask & CWBackPixmap)
+ {
+ if (pWin->backgroundState == BackgroundPixmap)
+ {
+ pPixmap = pWin->background.pixmap;
+#ifdef FB_24_32BIT
+ if (pPixmap->drawable.bitsPerPixel != pWin->drawable.bitsPerPixel)
+ {
+ pPixmap = fb24_32ReformatTile (pPixmap,
+ pWin->drawable.bitsPerPixel);
+ if (pPixmap)
+ {
+ (*pWin->drawable.pScreen->DestroyPixmap) (pWin->background.pixmap);
+ pWin->background.pixmap = pPixmap;
+ }
+ }
+#endif
+ if (FbEvenTile (pPixmap->drawable.width *
+ pPixmap->drawable.bitsPerPixel))
+ fbPadPixmap (pPixmap);
+ }
+ }
+ if (mask & CWBorderPixmap)
+ {
+ if (pWin->borderIsPixel == FALSE)
+ {
+ pPixmap = pWin->border.pixmap;
+#ifdef FB_24_32BIT
+ if (pPixmap->drawable.bitsPerPixel !=
+ pWin->drawable.bitsPerPixel)
+ {
+ pPixmap = fb24_32ReformatTile (pPixmap,
+ pWin->drawable.bitsPerPixel);
+ if (pPixmap)
+ {
+ (*pWin->drawable.pScreen->DestroyPixmap) (pWin->border.pixmap);
+ pWin->border.pixmap = pPixmap;
+ }
+ }
+#endif
+ if (FbEvenTile (pPixmap->drawable.width *
+ pPixmap->drawable.bitsPerPixel))
+ fbPadPixmap (pPixmap);
+ }
+ }
+ return TRUE;
+}
+
+void
+fbFillRegionSolid (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ FbBits and,
+ FbBits xor)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int n = RegionNumRects(pRegion);
+ BoxPtr pbox = RegionRects(pRegion);
+
+#ifndef FB_ACCESS_WRAPPER
+ int try_mmx = 0;
+ if (!and)
+ try_mmx = 1;
+#endif
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ while (n--)
+ {
+#ifndef FB_ACCESS_WRAPPER
+ if (!try_mmx || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp,
+ pbox->x1 + dstXoff, pbox->y1 + dstYoff,
+ (pbox->x2 - pbox->x1),
+ (pbox->y2 - pbox->y1),
+ xor))
+ {
+#endif
+ fbSolid (dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+ dstBpp,
+ (pbox->x2 - pbox->x1) * dstBpp,
+ pbox->y2 - pbox->y1,
+ and, xor);
+#ifndef FB_ACCESS_WRAPPER
+ }
+#endif
+ fbValidateDrawable (pDrawable);
+ pbox++;
+ }
+
+ fbFinishAccess (pDrawable);
+}
diff --git a/xorg-server/fb/wfbrename.h b/xorg-server/fb/wfbrename.h index 73ee510b9..9c45045e7 100644 --- a/xorg-server/fb/wfbrename.h +++ b/xorg-server/fb/wfbrename.h @@ -1,190 +1,190 @@ -#define fb16Lane wfb16Lane -#define fb24_32CopyMtoN wfb24_32CopyMtoN -#define fb24_32CreateScreenResources wfb24_32CreateScreenResources -#define fb24_32GetImage wfb24_32GetImage -#define fb24_32GetSpans wfb24_32GetSpans -#define fb24_32ModifyPixmapHeader wfb24_32ModifyPixmapHeader -#define fb24_32PutZImage wfb24_32PutZImage -#define fb24_32ReformatTile wfb24_32ReformatTile -#define fb24_32SetSpans wfb24_32SetSpans -#define fb32Lane wfb32Lane -#define fb8Lane wfb8Lane -#define fbAddTraps wfbAddTraps -#define fbAddTriangles wfbAddTriangles -#define fbAllocatePrivates wfbAllocatePrivates -#define fbArc16 wfbArc16 -#define fbArc24 wfbArc24 -#define fbArc32 wfbArc32 -#define fbArc8 wfbArc8 -#define fbBlt wfbBlt -#define fbBlt24 wfbBlt24 -#define fbBltOne wfbBltOne -#define fbBltOne24 wfbBltOne24 -#define fbBltPlane wfbBltPlane -#define fbBltStip wfbBltStip -#define fbBres wfbBres -#define fbBresDash wfbBresDash -#define fbBresDash16 wfbBresDash16 -#define fbBresDash24 wfbBresDash24 -#define fbBresDash32 wfbBresDash32 -#define fbBresDash8 wfbBresDash8 -#define fbBresFill wfbBresFill -#define fbBresFillDash wfbBresFillDash -#define fbBresSolid wfbBresSolid -#define fbBresSolid16 wfbBresSolid16 -#define fbBresSolid24 wfbBresSolid24 -#define fbBresSolid32 wfbBresSolid32 -#define fbBresSolid8 wfbBresSolid8 -#define fbChangeWindowAttributes wfbChangeWindowAttributes -#define fbClearVisualTypes wfbClearVisualTypes -#define fbCloseScreen wfbCloseScreen -#define fbComposite wfbComposite -#define fbCompositeGeneral wfbCompositeGeneral -#define fbCompositeSolidMask_nx1xn wfbCompositeSolidMask_nx1xn -#define fbCompositeSolidMask_nx8888x0565C wfbCompositeSolidMask_nx8888x0565C -#define fbCompositeSolidMask_nx8888x8888C wfbCompositeSolidMask_nx8888x8888C -#define fbCompositeSolidMask_nx8x0565 wfbCompositeSolidMask_nx8x0565 -#define fbCompositeSolidMask_nx8x0888 wfbCompositeSolidMask_nx8x0888 -#define fbCompositeSolidMask_nx8x8888 wfbCompositeSolidMask_nx8x8888 -#define fbCompositeSrc_0565x0565 wfbCompositeSrc_0565x0565 -#define fbCompositeSrc_8888x0565 wfbCompositeSrc_8888x0565 -#define fbCompositeSrc_8888x0888 wfbCompositeSrc_8888x0888 -#define fbCompositeSrc_8888x8888 wfbCompositeSrc_8888x8888 -#define fbCompositeSrcAdd_1000x1000 wfbCompositeSrcAdd_1000x1000 -#define fbCompositeSrcAdd_8000x8000 wfbCompositeSrcAdd_8000x8000 -#define fbCompositeSrcAdd_8888x8888 wfbCompositeSrcAdd_8888x8888 -#define fbCopy1toN wfbCopy1toN -#define fbCopyArea wfbCopyArea -#define fbCopyNto1 wfbCopyNto1 -#define fbCopyNtoN wfbCopyNtoN -#define fbCopyPlane wfbCopyPlane -#define fbCopyRegion wfbCopyRegion -#define fbCopyWindow wfbCopyWindow -#define fbCopyWindowProc wfbCopyWindowProc -#define fbCreateDefColormap wfbCreateDefColormap -#define fbCreateGC wfbCreateGC -#define fbCreatePixmap wfbCreatePixmap -#define fbCreatePixmapBpp wfbCreatePixmapBpp -#define fbCreateWindow wfbCreateWindow -#define fbDestroyPixmap wfbDestroyPixmap -#define fbDestroyWindow wfbDestroyWindow -#define fbDoCopy wfbDoCopy -#define fbDots wfbDots -#define fbDots16 wfbDots16 -#define fbDots24 wfbDots24 -#define fbDots32 wfbDots32 -#define fbDots8 wfbDots8 -#define fbEvenStipple wfbEvenStipple -#define fbEvenTile wfbEvenTile -#define fbExpandDirectColors wfbExpandDirectColors -#define fbFill wfbFill -#define fbFillRegionSolid wfbFillRegionSolid -#define fbFillSpans wfbFillSpans -#define fbFixCoordModePrevious wfbFixCoordModePrevious -#define fbGCFuncs wfbGCFuncs -#define fbGCOps wfbGCOps -#define fbGCPrivateKey wfbGCPrivateKey -#define fbGeneration wfbGeneration -#define fbGetGCPrivateKey wfbGetGCPrivateKey -#define fbGetImage wfbGetImage -#define fbGetScreenPrivateKey wfbGetScreenPrivateKey -#define fbGetSpans wfbGetSpans -#define _fbGetWindowPixmap _wfbGetWindowPixmap -#define fbGetWinPrivateKey wfbGetWinPrivateKey -#define fbGlyph16 wfbGlyph16 -#define fbGlyph24 wfbGlyph24 -#define fbGlyph32 wfbGlyph32 -#define fbGlyph8 wfbGlyph8 -#define fbGlyphIn wfbGlyphIn -#define fbHasVisualTypes wfbHasVisualTypes -#define fbImageGlyphBlt wfbImageGlyphBlt -#define fbIn wfbIn -#define fbInitializeColormap wfbInitializeColormap -#define fbInitVisuals wfbInitVisuals -#define fbInstallColormap wfbInstallColormap -#define fbLaneTable wfbLaneTable -#define fbListInstalledColormaps wfbListInstalledColormaps -#define fbMapWindow wfbMapWindow -#define FbMergeRopBits wFbMergeRopBits -#define fbOddStipple wfbOddStipple -#define fbOddTile wfbOddTile -#define fbOver wfbOver -#define fbOver24 wfbOver24 -#define fbOverlayCloseScreen wfbOverlayCloseScreen -#define fbOverlayCopyWindow wfbOverlayCopyWindow -#define fbOverlayCreateScreenResources wfbOverlayCreateScreenResources -#define fbOverlayCreateWindow wfbOverlayCreateWindow -#define fbOverlayFinishScreenInit wfbOverlayFinishScreenInit -#define fbOverlayGeneration wfbOverlayGeneration -#define fbOverlayGetScreenPrivateKey wfbOverlayGetScreenPrivateKey -#define fbOverlayPaintKey wfbOverlayPaintKey -#define fbOverlayScreenPrivateKey wfbOverlayScreenPrivateKey -#define fbOverlaySetupScreen wfbOverlaySetupScreen -#define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion -#define fbOverlayWindowExposures wfbOverlayWindowExposures -#define fbOverlayWindowLayer wfbOverlayWindowLayer -#define fbPadPixmap wfbPadPixmap -#define fbPictureInit wfbPictureInit -#define fbPixmapToRegion wfbPixmapToRegion -#define fbPolyArc wfbPolyArc -#define fbPolyFillRect wfbPolyFillRect -#define fbPolyGlyphBlt wfbPolyGlyphBlt -#define fbPolyLine wfbPolyLine -#define fbPolyline16 wfbPolyline16 -#define fbPolyline24 wfbPolyline24 -#define fbPolyline32 wfbPolyline32 -#define fbPolyline8 wfbPolyline8 -#define fbPolyPoint wfbPolyPoint -#define fbPolySegment wfbPolySegment -#define fbPolySegment16 wfbPolySegment16 -#define fbPolySegment24 wfbPolySegment24 -#define fbPolySegment32 wfbPolySegment32 -#define fbPolySegment8 wfbPolySegment8 -#define fbPositionWindow wfbPositionWindow -#define fbPushFill wfbPushFill -#define fbPushImage wfbPushImage -#define fbPushPattern wfbPushPattern -#define fbPushPixels wfbPushPixels -#define fbPutImage wfbPutImage -#define fbPutXYImage wfbPutXYImage -#define fbPutZImage wfbPutZImage -#define fbQueryBestSize wfbQueryBestSize -#define fbRasterizeEdges wfbRasterizeEdges -#define fbRasterizeTrapezoid wfbRasterizeTrapezoid -#define fbRealizeFont wfbRealizeFont -#define fbReduceRasterOp wfbReduceRasterOp -#define fbReplicatePixel wfbReplicatePixel -#define fbResolveColor wfbResolveColor -#define fbRestoreAreas wfbRestoreAreas -#define fbSaveAreas wfbSaveAreas -#define fbScreenPrivateKey wfbScreenPrivateKey -#define fbSegment wfbSegment -#define fbSelectBres wfbSelectBres -#define fbSetSpans wfbSetSpans -#define fbSetupScreen wfbSetupScreen -#define fbSetVisualTypes wfbSetVisualTypes -#define fbSetVisualTypesAndMasks wfbSetVisualTypesAndMasks -#define _fbSetWindowPixmap _wfbSetWindowPixmap -#define fbSolid wfbSolid -#define fbSolid24 wfbSolid24 -#define fbSolidBoxClipped wfbSolidBoxClipped -#define fbStipple wfbStipple -#define fbStipple1Bits wfbStipple1Bits -#define fbStipple24Bits wfbStipple24Bits -#define fbStipple2Bits wfbStipple2Bits -#define fbStipple4Bits wfbStipple4Bits -#define fbStipple8Bits wfbStipple8Bits -#define fbStippleTable wfbStippleTable -#define fbTile wfbTile -#define fbTransparentSpan wfbTransparentSpan -#define fbUninstallColormap wfbUninstallColormap -#define fbUnmapWindow wfbUnmapWindow -#define fbUnrealizeFont wfbUnrealizeFont -#define fbValidateGC wfbValidateGC -#define fbWalkCompositeRegion wfbWalkCompositeRegion -#define fbWinPrivateKey wfbWinPrivateKey -#define fbZeroLine wfbZeroLine -#define fbZeroSegment wfbZeroSegment -#define free_pixman_pict wfb_free_pixman_pict -#define image_from_pict wfb_image_from_pict -#define composeFunctions wfbComposeFunctions +#define fb16Lane wfb16Lane
+#define fb24_32CopyMtoN wfb24_32CopyMtoN
+#define fb24_32CreateScreenResources wfb24_32CreateScreenResources
+#define fb24_32GetImage wfb24_32GetImage
+#define fb24_32GetSpans wfb24_32GetSpans
+#define fb24_32ModifyPixmapHeader wfb24_32ModifyPixmapHeader
+#define fb24_32PutZImage wfb24_32PutZImage
+#define fb24_32ReformatTile wfb24_32ReformatTile
+#define fb24_32SetSpans wfb24_32SetSpans
+#define fb32Lane wfb32Lane
+#define fb8Lane wfb8Lane
+#define fbAddTraps wfbAddTraps
+#define fbAddTriangles wfbAddTriangles
+#define fbAllocatePrivates wfbAllocatePrivates
+#define fbArc16 wfbArc16
+#define fbArc24 wfbArc24
+#define fbArc32 wfbArc32
+#define fbArc8 wfbArc8
+#define fbBlt wfbBlt
+#define fbBlt24 wfbBlt24
+#define fbBltOne wfbBltOne
+#define fbBltOne24 wfbBltOne24
+#define fbBltPlane wfbBltPlane
+#define fbBltStip wfbBltStip
+#define fbBres wfbBres
+#define fbBresDash wfbBresDash
+#define fbBresDash16 wfbBresDash16
+#define fbBresDash24 wfbBresDash24
+#define fbBresDash32 wfbBresDash32
+#define fbBresDash8 wfbBresDash8
+#define fbBresFill wfbBresFill
+#define fbBresFillDash wfbBresFillDash
+#define fbBresSolid wfbBresSolid
+#define fbBresSolid16 wfbBresSolid16
+#define fbBresSolid24 wfbBresSolid24
+#define fbBresSolid32 wfbBresSolid32
+#define fbBresSolid8 wfbBresSolid8
+#define fbChangeWindowAttributes wfbChangeWindowAttributes
+#define fbClearVisualTypes wfbClearVisualTypes
+#define fbCloseScreen wfbCloseScreen
+#define fbComposite wfbComposite
+#define fbCompositeGeneral wfbCompositeGeneral
+#define fbCompositeSolidMask_nx1xn wfbCompositeSolidMask_nx1xn
+#define fbCompositeSolidMask_nx8888x0565C wfbCompositeSolidMask_nx8888x0565C
+#define fbCompositeSolidMask_nx8888x8888C wfbCompositeSolidMask_nx8888x8888C
+#define fbCompositeSolidMask_nx8x0565 wfbCompositeSolidMask_nx8x0565
+#define fbCompositeSolidMask_nx8x0888 wfbCompositeSolidMask_nx8x0888
+#define fbCompositeSolidMask_nx8x8888 wfbCompositeSolidMask_nx8x8888
+#define fbCompositeSrc_0565x0565 wfbCompositeSrc_0565x0565
+#define fbCompositeSrc_8888x0565 wfbCompositeSrc_8888x0565
+#define fbCompositeSrc_8888x0888 wfbCompositeSrc_8888x0888
+#define fbCompositeSrc_8888x8888 wfbCompositeSrc_8888x8888
+#define fbCompositeSrcAdd_1000x1000 wfbCompositeSrcAdd_1000x1000
+#define fbCompositeSrcAdd_8000x8000 wfbCompositeSrcAdd_8000x8000
+#define fbCompositeSrcAdd_8888x8888 wfbCompositeSrcAdd_8888x8888
+#define fbCopy1toN wfbCopy1toN
+#define fbCopyArea wfbCopyArea
+#define fbCopyNto1 wfbCopyNto1
+#define fbCopyNtoN wfbCopyNtoN
+#define fbCopyPlane wfbCopyPlane
+#define fbCopyRegion wfbCopyRegion
+#define fbCopyWindow wfbCopyWindow
+#define fbCopyWindowProc wfbCopyWindowProc
+#define fbCreateDefColormap wfbCreateDefColormap
+#define fbCreateGC wfbCreateGC
+#define fbCreatePixmap wfbCreatePixmap
+#define fbCreatePixmapBpp wfbCreatePixmapBpp
+#define fbCreateWindow wfbCreateWindow
+#define fbDestroyPixmap wfbDestroyPixmap
+#define fbDestroyWindow wfbDestroyWindow
+#define fbDoCopy wfbDoCopy
+#define fbDots wfbDots
+#define fbDots16 wfbDots16
+#define fbDots24 wfbDots24
+#define fbDots32 wfbDots32
+#define fbDots8 wfbDots8
+#define fbEvenStipple wfbEvenStipple
+#define fbEvenTile wfbEvenTile
+#define fbExpandDirectColors wfbExpandDirectColors
+#define fbFill wfbFill
+#define fbFillRegionSolid wfbFillRegionSolid
+#define fbFillSpans wfbFillSpans
+#define fbFixCoordModePrevious wfbFixCoordModePrevious
+#define fbGCFuncs wfbGCFuncs
+#define fbGCOps wfbGCOps
+#define fbGCPrivateKeyRec wfbGCPrivateKeyRec
+#define fbGeneration wfbGeneration
+#define fbGetGCPrivateKey wfbGetGCPrivateKey
+#define fbGetImage wfbGetImage
+#define fbGetScreenPrivateKey wfbGetScreenPrivateKey
+#define fbGetSpans wfbGetSpans
+#define _fbGetWindowPixmap _wfbGetWindowPixmap
+#define fbWinPrivateKeyRec wfbWinPrivateKeyRec
+#define fbGetWinPrivateKey wfbGetWinPrivateKey
+#define fbGlyph16 wfbGlyph16
+#define fbGlyph24 wfbGlyph24
+#define fbGlyph32 wfbGlyph32
+#define fbGlyph8 wfbGlyph8
+#define fbGlyphIn wfbGlyphIn
+#define fbHasVisualTypes wfbHasVisualTypes
+#define fbImageGlyphBlt wfbImageGlyphBlt
+#define fbIn wfbIn
+#define fbInitializeColormap wfbInitializeColormap
+#define fbInitVisuals wfbInitVisuals
+#define fbInstallColormap wfbInstallColormap
+#define fbLaneTable wfbLaneTable
+#define fbListInstalledColormaps wfbListInstalledColormaps
+#define fbMapWindow wfbMapWindow
+#define FbMergeRopBits wFbMergeRopBits
+#define fbOddStipple wfbOddStipple
+#define fbOddTile wfbOddTile
+#define fbOver wfbOver
+#define fbOver24 wfbOver24
+#define fbOverlayCloseScreen wfbOverlayCloseScreen
+#define fbOverlayCopyWindow wfbOverlayCopyWindow
+#define fbOverlayCreateScreenResources wfbOverlayCreateScreenResources
+#define fbOverlayCreateWindow wfbOverlayCreateWindow
+#define fbOverlayFinishScreenInit wfbOverlayFinishScreenInit
+#define fbOverlayGeneration wfbOverlayGeneration
+#define fbOverlayGetScreenPrivateKey wfbOverlayGetScreenPrivateKey
+#define fbOverlayPaintKey wfbOverlayPaintKey
+#define fbOverlaySetupScreen wfbOverlaySetupScreen
+#define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion
+#define fbOverlayWindowExposures wfbOverlayWindowExposures
+#define fbOverlayWindowLayer wfbOverlayWindowLayer
+#define fbPadPixmap wfbPadPixmap
+#define fbPictureInit wfbPictureInit
+#define fbPixmapToRegion wfbPixmapToRegion
+#define fbPolyArc wfbPolyArc
+#define fbPolyFillRect wfbPolyFillRect
+#define fbPolyGlyphBlt wfbPolyGlyphBlt
+#define fbPolyLine wfbPolyLine
+#define fbPolyline16 wfbPolyline16
+#define fbPolyline24 wfbPolyline24
+#define fbPolyline32 wfbPolyline32
+#define fbPolyline8 wfbPolyline8
+#define fbPolyPoint wfbPolyPoint
+#define fbPolySegment wfbPolySegment
+#define fbPolySegment16 wfbPolySegment16
+#define fbPolySegment24 wfbPolySegment24
+#define fbPolySegment32 wfbPolySegment32
+#define fbPolySegment8 wfbPolySegment8
+#define fbPositionWindow wfbPositionWindow
+#define fbPushFill wfbPushFill
+#define fbPushImage wfbPushImage
+#define fbPushPattern wfbPushPattern
+#define fbPushPixels wfbPushPixels
+#define fbPutImage wfbPutImage
+#define fbPutXYImage wfbPutXYImage
+#define fbPutZImage wfbPutZImage
+#define fbQueryBestSize wfbQueryBestSize
+#define fbRasterizeEdges wfbRasterizeEdges
+#define fbRasterizeTrapezoid wfbRasterizeTrapezoid
+#define fbRealizeFont wfbRealizeFont
+#define fbReduceRasterOp wfbReduceRasterOp
+#define fbReplicatePixel wfbReplicatePixel
+#define fbResolveColor wfbResolveColor
+#define fbRestoreAreas wfbRestoreAreas
+#define fbSaveAreas wfbSaveAreas
+#define fbScreenPrivateKeyRec wfbScreenPrivateKeyRec
+#define fbSegment wfbSegment
+#define fbSelectBres wfbSelectBres
+#define fbSetSpans wfbSetSpans
+#define fbSetupScreen wfbSetupScreen
+#define fbSetVisualTypes wfbSetVisualTypes
+#define fbSetVisualTypesAndMasks wfbSetVisualTypesAndMasks
+#define _fbSetWindowPixmap _wfbSetWindowPixmap
+#define fbSolid wfbSolid
+#define fbSolid24 wfbSolid24
+#define fbSolidBoxClipped wfbSolidBoxClipped
+#define fbStipple wfbStipple
+#define fbStipple1Bits wfbStipple1Bits
+#define fbStipple24Bits wfbStipple24Bits
+#define fbStipple2Bits wfbStipple2Bits
+#define fbStipple4Bits wfbStipple4Bits
+#define fbStipple8Bits wfbStipple8Bits
+#define fbStippleTable wfbStippleTable
+#define fbTile wfbTile
+#define fbTransparentSpan wfbTransparentSpan
+#define fbUninstallColormap wfbUninstallColormap
+#define fbUnmapWindow wfbUnmapWindow
+#define fbUnrealizeFont wfbUnrealizeFont
+#define fbValidateGC wfbValidateGC
+#define fbWalkCompositeRegion wfbWalkCompositeRegion
+#define fbWinPrivateKeyRec wfbWinPrivateKeyRec
+#define fbZeroLine wfbZeroLine
+#define fbZeroSegment wfbZeroSegment
+#define free_pixman_pict wfb_free_pixman_pict
+#define image_from_pict wfb_image_from_pict
+#define composeFunctions wfbComposeFunctions
diff --git a/xorg-server/fix-miregion b/xorg-server/fix-miregion new file mode 100644 index 000000000..7aea689b7 --- /dev/null +++ b/xorg-server/fix-miregion @@ -0,0 +1,29 @@ +#!/bin/sh
+sed -i \
+-e 's/miRegionCreate\b/RegionCreate/g' \
+-e 's/miRegionInit\b/RegionInit/g' \
+-e 's/miRegionDestroy\b/RegionDestroy/g' \
+-e 's/miRegionUninit\b/RegionUninit/g' \
+-e 's/miRegionCopy\b/RegionCopy/g' \
+-e 's/miIntersect\b/RegionIntersect/g' \
+-e 's/miUnion\b/RegionUnion/g' \
+-e 's/miRegionAppend\b/RegionAppend/g' \
+-e 's/miRegionValidate\b/RegionValidate/g' \
+-e 's/miRectsToRegion\b/RegionFromRects/g' \
+-e 's/miSubtract\b/RegionSubtract/g' \
+-e 's/miInverse\b/RegionInverse/g' \
+-e 's/miRectIn\b/RegionContainsRect/g' \
+-e 's/miTranslateRegion\b/RegionTranslate/g' \
+-e 's/miRegionReset\b/RegionReset/g' \
+-e 's/miRegionBreak\b/RegionBreak/g' \
+-e 's/miPointInRegion\b/RegionContainsPoint/g' \
+-e 's/miRegionEqual\b/RegionEqual/g' \
+-e 's/miRegionNotEmpty\b/RegionNotEmpty/g' \
+-e 's/miRegionEmpty\b/RegionEmpty/g' \
+-e 's/miRegionExtents\b/RegionExtents/g' \
+-e 's/miPrintRegion\b/RegionPrint/g' \
+-e 's/miRectAlloc\b/RegionRectAlloc/g' \
+-e 's/miValidRegion\b/RegionIsValid/g' \
+-e 's/miRegionBroken\b/RegionBroken/g' \
+-e 's/miClipSpans\b/RegionClipSpans/g' \
+"$@"
diff --git a/xorg-server/fix-miregion-private b/xorg-server/fix-miregion-private new file mode 100644 index 000000000..a294c4f96 --- /dev/null +++ b/xorg-server/fix-miregion-private @@ -0,0 +1,14 @@ +#!/bin/sh
+sed -i \
+-e 's/miEmptyBox\b/RegionEmptyBox/g' \
+-e 's/miEmptyData\b/RegionEmptyData/g' \
+-e 's/miBrokenData\b/RegionBrokenData/g' \
+-e 's/miBrokenRegion\b/RegionBrokenRegion/g' \
+-e 's/miCoalesce\b/RegionCoalesce/g' \
+-e 's/miAppendNonO\b/RegionAppendNonO/g' \
+-e 's/miRegionOp\b/RegionOp/g' \
+-e 's/miSetExtents\b/RegionSetExtents/g' \
+-e 's/miIntersectO\b/RegionIntersectO/g' \
+-e 's/miUnionO\b/RegionUnionO/g' \
+-e 's/miSubtractO\b/RegionSubtractO/g' \
+"$@"
diff --git a/xorg-server/fix-patch-whitespace b/xorg-server/fix-patch-whitespace new file mode 100644 index 000000000..417f66fc6 --- /dev/null +++ b/xorg-server/fix-patch-whitespace @@ -0,0 +1,4 @@ +#!/bin/sh
+git diff --check |
+sed -n 's!^\([^:]*\):\([^:]*\):.*!sed -i "\2 s/[ \t]*$//; \2 s/ *\t/\t/g" \1!p' |
+sh
diff --git a/xorg-server/fix-region b/xorg-server/fix-region new file mode 100644 index 000000000..e38022bf6 --- /dev/null +++ b/xorg-server/fix-region @@ -0,0 +1,38 @@ +#!/bin/sh
+sed -i \
+ -e 's/REGION_NIL\b/RegionNil/g' \
+ -e 's/REGION_NAR\b/RegionNar/g' \
+ -e 's/REGION_NUM_RECTS\b/RegionNumRects/g' \
+ -e 's/REGION_SIZE\b/RegionSize/g' \
+ -e 's/REGION_RECTS\b/RegionRects/g' \
+ -e 's/REGION_BOXPTR\b/RegionBoxptr/g' \
+ -e 's/REGION_BOX\b/RegionBox/g' \
+ -e 's/REGION_TOP\b/RegionTop/g' \
+ -e 's/REGION_END\b/RegionEnd/g' \
+ -e 's/REGION_SZOF\b/RegionSizeof/g' \
+ -e 's/REGION_CREATE *([^,]*, */RegionCreate(/g' \
+ -e 's/REGION_COPY *([^,]*, */RegionCopy(/g' \
+ -e 's/REGION_DESTROY *([^,]*, */RegionDestroy(/g' \
+ -e 's/REGION_INTERSECT *([^,]*, */RegionIntersect(/g' \
+ -e 's/REGION_UNION *([^,]*, */RegionUnion(/g' \
+ -e 's/REGION_SUBTRACT *([^,]*, */RegionSubtract(/g' \
+ -e 's/REGION_INVERSE *([^,]*, */RegionInverse(/g' \
+ -e 's/REGION_TRANSLATE *([^,]*, */RegionTranslate(/g' \
+ -e 's/RECT_IN_REGION *([^,]*, */RegionContainsRect(/g' \
+ -e 's/POINT_IN_REGION *([^,]*, */RegionContainsPoint(/g' \
+ -e 's/REGION_EQUAL *([^,]*, */RegionEqual(/g' \
+ -e 's/REGION_APPEND *([^,]*, */RegionAppend(/g' \
+ -e 's/REGION_VALIDATE *([^,]*, */RegionValidate(/g' \
+ -e 's/BITMAP_TO_REGION\b/BitmapToRegion/g' \
+ -e 's/RECTS_TO_REGION *([^,]*, */RegionFromRects(/g' \
+ -e 's/REGION_BREAK *([^,]*, */RegionBreak(/g' \
+ -e 's/REGION_INIT *([^,]*, */RegionInit(/g' \
+ -e 's/REGION_UNINIT *([^,]*, */RegionUninit(/g' \
+ -e 's/REGION_RESET *([^,]*, */RegionReset(/g' \
+ -e 's/REGION_NOTEMPTY *([^,]*, */RegionNotEmpty(/g' \
+ -e 's/REGION_BROKEN *([^,]*, */RegionBroken(/g' \
+ -e 's/REGION_EMPTY *([^,]*, */RegionEmpty(/g' \
+ -e 's/REGION_EXTENTS *([^,]*, */RegionExtents(/g' \
+ -e 's/REGION_NULL *([^,]*, */RegionNull(/g' \
+ -e 's/REGION_NULL$/RegionNull/g' \
+ "$@"
diff --git a/xorg-server/glx/glxcmds.c b/xorg-server/glx/glxcmds.c index 0ec118e97..a4ac2b86b 100644 --- a/xorg-server/glx/glxcmds.c +++ b/xorg-server/glx/glxcmds.c @@ -2435,8 +2435,7 @@ int __glXDisp_ClientInfo(__GLXclientState *cl, GLbyte *pc) cl->GLClientmajorVersion = req->major;
cl->GLClientminorVersion = req->minor;
- if (cl->GLClientextensions)
- free(cl->GLClientextensions);
+ free(cl->GLClientextensions);
buf = (const char *)(req+1);
cl->GLClientextensions = xstrdup(buf);
diff --git a/xorg-server/glx/glxdri.c b/xorg-server/glx/glxdri.c index e9e7ea5a9..73f6051f6 100644 --- a/xorg-server/glx/glxdri.c +++ b/xorg-server/glx/glxdri.c @@ -471,7 +471,7 @@ nooverride: pRegion = NULL;
} else {
pRegion = DamageRegion(driDraw->pDamage);
- if (REGION_NIL(pRegion))
+ if (RegionNil(pRegion))
return Success;
}
@@ -534,8 +534,8 @@ nooverride: int i, numRects;
BoxPtr p;
- numRects = REGION_NUM_RECTS (pRegion);
- p = REGION_RECTS (pRegion);
+ numRects = RegionNumRects (pRegion);
+ p = RegionRects (pRegion);
CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS, 0) );
CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS, 0) );
@@ -835,12 +835,12 @@ static void __glXReportDamage(__DRIdrawable *driDraw, __glXenterServer(GL_FALSE);
- REGION_INIT(pDraw->pScreen, ®ion, (BoxPtr) rects, num_rects);
- REGION_TRANSLATE(pScreen, ®ion, pDraw->x, pDraw->y);
+ RegionInit(®ion, (BoxPtr) rects, num_rects);
+ RegionTranslate(®ion, pDraw->x, pDraw->y);
DamageRegionAppend(pDraw, ®ion);
/* This is wrong, this needs a seperate function. */
DamageRegionProcessPending(pDraw);
- REGION_UNINIT(pDraw->pScreen, ®ion);
+ RegionUninit(®ion);
__glXleaveServer(GL_FALSE);
}
diff --git a/xorg-server/glx/glxdri2.c b/xorg-server/glx/glxdri2.c index 1faefb002..f4cb76383 100644 --- a/xorg-server/glx/glxdri2.c +++ b/xorg-server/glx/glxdri2.c @@ -122,7 +122,7 @@ __glXDRIdrawableCopySubBuffer(__GLXdrawable *drawable, box.y1 = private->height - y - h;
box.x2 = x + w;
box.y2 = private->height - y;
- REGION_INIT(drawable->pDraw->pScreen, ®ion, &box, 0);
+ RegionInit(®ion, &box, 0);
DRI2CopyRegion(drawable->pDraw, ®ion,
DRI2BufferFrontLeft, DRI2BufferBackLeft);
@@ -139,7 +139,7 @@ __glXDRIdrawableWaitX(__GLXdrawable *drawable) box.y1 = 0;
box.x2 = private->width;
box.y2 = private->height;
- REGION_INIT(drawable->pDraw->pScreen, ®ion, &box, 0);
+ RegionInit(®ion, &box, 0);
DRI2CopyRegion(drawable->pDraw, ®ion,
DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
@@ -156,7 +156,7 @@ __glXDRIdrawableWaitGL(__GLXdrawable *drawable) box.y1 = 0;
box.x2 = private->width;
box.y2 = private->height;
- REGION_INIT(drawable->pDraw->pScreen, ®ion, &box, 0);
+ RegionInit(®ion, &box, 0);
DRI2CopyRegion(drawable->pDraw, ®ion,
DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
diff --git a/xorg-server/glx/glxdriswrast.c b/xorg-server/glx/glxdriswrast.c index ed4b373c7..9bc8d3b6e 100644 --- a/xorg-server/glx/glxdriswrast.c +++ b/xorg-server/glx/glxdriswrast.c @@ -341,7 +341,7 @@ __glXDRIscreenCreateDrawable(ClientPtr client, gcvals[0].val = GXcopy;
ChangeGC(NullClient, private->gc, GCFunction, gcvals);
gcvals[1].val = FALSE;
- ChangeGC(NullClient, private->gc, GCFunction | GCGraphicsExposures, gcvals);
+ ChangeGC(NullClient, private->swapgc, GCFunction | GCGraphicsExposures, gcvals);
private->driDrawable =
(*driScreen->swrast->createNewDrawable)(driScreen->driScreen,
diff --git a/xorg-server/glx/glxext.c b/xorg-server/glx/glxext.c index 1f2174e93..e48a90da6 100644 --- a/xorg-server/glx/glxext.c +++ b/xorg-server/glx/glxext.c @@ -69,8 +69,8 @@ RESTYPE __glXSwapBarrierRes; */
xGLXSingleReply __glXReply;
-static int glxClientPrivateKeyIndex;
-static DevPrivateKey glxClientPrivateKey = &glxClientPrivateKeyIndex;
+static DevPrivateKeyRec glxClientPrivateKeyRec;
+#define glxClientPrivateKey (&glxClientPrivateKeyRec)
/*
** Client that called into GLX dispatch.
@@ -211,8 +211,8 @@ GLboolean __glXFreeContext(__GLXcontext *cx) {
if (cx->idExists || cx->isCurrent) return GL_FALSE;
- if (cx->feedbackBuf) free(cx->feedbackBuf);
- if (cx->selectBuf) free(cx->selectBuf);
+ free(cx->feedbackBuf);
+ free(cx->selectBuf);
if (cx == __glXLastContext) {
__glXFlushContextCache();
}
@@ -329,10 +329,10 @@ glxClientCallback (CallbackListPtr *list, }
}
- if (cl->returnBuf) free(cl->returnBuf);
- if (cl->largeCmdBuf) free(cl->largeCmdBuf);
- if (cl->currentContexts) free(cl->currentContexts);
- if (cl->GLClientextensions) free(cl->GLClientextensions);
+ free(cl->returnBuf);
+ free(cl->largeCmdBuf);
+ free(cl->currentContexts);
+ free(cl->GLClientextensions);
break;
default:
@@ -370,7 +370,7 @@ void GlxExtensionInit(void) if (!__glXContextRes || !__glXDrawableRes || !__glXSwapBarrierRes)
return;
- if (!dixRequestPrivate(glxClientPrivateKey, sizeof (__GLXclientState)))
+ if (!dixRegisterPrivateKey(&glxClientPrivateKeyRec, PRIVATE_CLIENT, sizeof (__GLXclientState)))
return;
if (!AddCallback (&ClientStateCallback, glxClientCallback, 0))
return;
diff --git a/xorg-server/glx/glxscreens.c b/xorg-server/glx/glxscreens.c index 1d647596a..3d91e20d2 100644 --- a/xorg-server/glx/glxscreens.c +++ b/xorg-server/glx/glxscreens.c @@ -48,8 +48,8 @@ #include "glxext.h"
#include "protocol-versions.h"
-static int glxScreenPrivateKeyIndex;
-static DevPrivateKey glxScreenPrivateKey = &glxScreenPrivateKeyIndex;
+static DevPrivateKeyRec glxScreenPrivateKeyRec;
+#define glxScreenPrivateKey (&glxScreenPrivateKeyRec)
const char GLServerVersion[] = "1.4";
static const char GLServerExtensions[] =
@@ -356,6 +356,9 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen) __GLXconfig *config;
int i;
+ if (!dixRegisterPrivateKey(&glxScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
pGlxScreen->pScreen = pScreen;
pGlxScreen->GLextensions = xstrdup(GLServerExtensions);
pGlxScreen->GLXvendor = xstrdup(GLXServerVendorName);
diff --git a/xorg-server/glx/single2.c b/xorg-server/glx/single2.c index 4d8aeaa83..d0f0c83bb 100644 --- a/xorg-server/glx/single2.c +++ b/xorg-server/glx/single2.c @@ -276,10 +276,8 @@ char *__glXcombine_strings(const char *cext_string, const char *sext_string) s2 = sext_string;
}
if (!combo_string || !s1) {
- if (combo_string)
- free(combo_string);
- if (s1)
- free(s1);
+ free(combo_string);
+ free(s1);
return NULL;
}
combo_string[0] = '\0';
diff --git a/xorg-server/glx/singlesize.c b/xorg-server/glx/singlesize.c index a9a2be66b..85fa9871c 100644 --- a/xorg-server/glx/singlesize.c +++ b/xorg-server/glx/singlesize.c @@ -1,197 +1,197 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * 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 - * SILICON GRAPHICS, INC. 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 of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#else - -#include "glheader.h" - -#endif - -#include <GL/gl.h> -#include "glxserver.h" -#include "singlesize.h" -#include "indirect_size_get.h" -#include "glapitable.h" -#include "glapi.h" -#include "glthread.h" -#include "dispatch.h" - -/* -** These routines compute the size of variable-size returned parameters. -** Unlike the similar routines that do the same thing for variable-size -** incoming parameters, the samplegl library itself doesn't use these routines. -** Hence, they are located here, in the GLX extension library. -*/ - -GLint __glReadPixels_size(GLenum format, GLenum type, GLint w, GLint h) -{ - return __glXImageSize( format, type, 0, w, h, 1, 0, 0, 0, 0, 4 ); -} - -GLint __glGetMap_size(GLenum target, GLenum query) -{ - GLint k, order=0, majorMinor[2]; - - /* - ** Assume target and query are both valid. - */ - switch (target) { - case GL_MAP1_COLOR_4: - case GL_MAP1_NORMAL: - case GL_MAP1_INDEX: - case GL_MAP1_TEXTURE_COORD_1: - case GL_MAP1_TEXTURE_COORD_2: - case GL_MAP1_TEXTURE_COORD_3: - case GL_MAP1_TEXTURE_COORD_4: - case GL_MAP1_VERTEX_3: - case GL_MAP1_VERTEX_4: - switch (query) { - case GL_COEFF: - k = __glMap1d_size(target); - CALL_GetMapiv( GET_DISPATCH(), (target, GL_ORDER, &order) ); - /* - ** The query above might fail, but then order will be zero anyway. - */ - return (order * k); - case GL_DOMAIN: - return 2; - case GL_ORDER: - return 1; - } - break; - case GL_MAP2_COLOR_4: - case GL_MAP2_NORMAL: - case GL_MAP2_INDEX: - case GL_MAP2_TEXTURE_COORD_1: - case GL_MAP2_TEXTURE_COORD_2: - case GL_MAP2_TEXTURE_COORD_3: - case GL_MAP2_TEXTURE_COORD_4: - case GL_MAP2_VERTEX_3: - case GL_MAP2_VERTEX_4: - switch (query) { - case GL_COEFF: - k = __glMap2d_size(target); - majorMinor[0] = majorMinor[1] = 0; - CALL_GetMapiv( GET_DISPATCH(), (target, GL_ORDER, majorMinor) ); - /* - ** The query above might fail, but then majorMinor will be zeroes - */ - return (majorMinor[0] * majorMinor[1] * k); - case GL_DOMAIN: - return 4; - case GL_ORDER: - return 2; - } - break; - } - return -1; -} - -GLint __glGetMapdv_size(GLenum target, GLenum query) -{ - return __glGetMap_size(target, query); -} - -GLint __glGetMapfv_size(GLenum target, GLenum query) -{ - return __glGetMap_size(target, query); -} - -GLint __glGetMapiv_size(GLenum target, GLenum query) -{ - return __glGetMap_size(target, query); -} - -GLint __glGetPixelMap_size(GLenum map) -{ - GLint size; - GLenum query; - - switch (map) { - case GL_PIXEL_MAP_I_TO_I: - query = GL_PIXEL_MAP_I_TO_I_SIZE; - break; - case GL_PIXEL_MAP_S_TO_S: - query = GL_PIXEL_MAP_S_TO_S_SIZE; - break; - case GL_PIXEL_MAP_I_TO_R: - query = GL_PIXEL_MAP_I_TO_R_SIZE; - break; - case GL_PIXEL_MAP_I_TO_G: - query = GL_PIXEL_MAP_I_TO_G_SIZE; - break; - case GL_PIXEL_MAP_I_TO_B: - query = GL_PIXEL_MAP_I_TO_B_SIZE; - break; - case GL_PIXEL_MAP_I_TO_A: - query = GL_PIXEL_MAP_I_TO_A_SIZE; - break; - case GL_PIXEL_MAP_R_TO_R: - query = GL_PIXEL_MAP_R_TO_R_SIZE; - break; - case GL_PIXEL_MAP_G_TO_G: - query = GL_PIXEL_MAP_G_TO_G_SIZE; - break; - case GL_PIXEL_MAP_B_TO_B: - query = GL_PIXEL_MAP_B_TO_B_SIZE; - break; - case GL_PIXEL_MAP_A_TO_A: - query = GL_PIXEL_MAP_A_TO_A_SIZE; - break; - default: - return -1; - } - CALL_GetIntegerv( GET_DISPATCH(), (query, &size) ); - return size; -} - -GLint __glGetPixelMapfv_size(GLenum map) -{ - return __glGetPixelMap_size(map); -} - -GLint __glGetPixelMapuiv_size(GLenum map) -{ - return __glGetPixelMap_size(map); -} - -GLint __glGetPixelMapusv_size(GLenum map) -{ - return __glGetPixelMap_size(map); -} - -GLint __glGetTexImage_size(GLenum target, GLint level, GLenum format, - GLenum type, GLint width, GLint height, GLint depth) -{ - return __glXImageSize( format, type, target, width, height, depth, - 0, 0, 0, 0, 4 ); -} +/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 of Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#else
+
+#include "glheader.h"
+
+#endif
+
+#include <GL/gl.h>
+#include "glxserver.h"
+#include "singlesize.h"
+#include "indirect_size_get.h"
+#include "glapitable.h"
+#include "glapi.h"
+#include "glthread.h"
+#include "dispatch.h"
+
+/*
+** These routines compute the size of variable-size returned parameters.
+** Unlike the similar routines that do the same thing for variable-size
+** incoming parameters, the samplegl library itself doesn't use these routines.
+** Hence, they are located here, in the GLX extension library.
+*/
+
+GLint __glReadPixels_size(GLenum format, GLenum type, GLint w, GLint h)
+{
+ return __glXImageSize( format, type, 0, w, h, 1, 0, 0, 0, 0, 4 );
+}
+
+GLint __glGetMap_size(GLenum target, GLenum query)
+{
+ GLint k, order=0, majorMinor[2];
+
+ /*
+ ** Assume target and query are both valid.
+ */
+ switch (target) {
+ case GL_MAP1_COLOR_4:
+ case GL_MAP1_NORMAL:
+ case GL_MAP1_INDEX:
+ case GL_MAP1_TEXTURE_COORD_1:
+ case GL_MAP1_TEXTURE_COORD_2:
+ case GL_MAP1_TEXTURE_COORD_3:
+ case GL_MAP1_TEXTURE_COORD_4:
+ case GL_MAP1_VERTEX_3:
+ case GL_MAP1_VERTEX_4:
+ switch (query) {
+ case GL_COEFF:
+ k = __glMap1d_size(target);
+ CALL_GetMapiv( GET_DISPATCH(), (target, GL_ORDER, &order) );
+ /*
+ ** The query above might fail, but then order will be zero anyway.
+ */
+ return order * k;
+ case GL_DOMAIN:
+ return 2;
+ case GL_ORDER:
+ return 1;
+ }
+ break;
+ case GL_MAP2_COLOR_4:
+ case GL_MAP2_NORMAL:
+ case GL_MAP2_INDEX:
+ case GL_MAP2_TEXTURE_COORD_1:
+ case GL_MAP2_TEXTURE_COORD_2:
+ case GL_MAP2_TEXTURE_COORD_3:
+ case GL_MAP2_TEXTURE_COORD_4:
+ case GL_MAP2_VERTEX_3:
+ case GL_MAP2_VERTEX_4:
+ switch (query) {
+ case GL_COEFF:
+ k = __glMap2d_size(target);
+ majorMinor[0] = majorMinor[1] = 0;
+ CALL_GetMapiv( GET_DISPATCH(), (target, GL_ORDER, majorMinor) );
+ /*
+ ** The query above might fail, but then majorMinor will be zeroes
+ */
+ return majorMinor[0] * majorMinor[1] * k;
+ case GL_DOMAIN:
+ return 4;
+ case GL_ORDER:
+ return 2;
+ }
+ break;
+ }
+ return -1;
+}
+
+GLint __glGetMapdv_size(GLenum target, GLenum query)
+{
+ return __glGetMap_size(target, query);
+}
+
+GLint __glGetMapfv_size(GLenum target, GLenum query)
+{
+ return __glGetMap_size(target, query);
+}
+
+GLint __glGetMapiv_size(GLenum target, GLenum query)
+{
+ return __glGetMap_size(target, query);
+}
+
+GLint __glGetPixelMap_size(GLenum map)
+{
+ GLint size;
+ GLenum query;
+
+ switch (map) {
+ case GL_PIXEL_MAP_I_TO_I:
+ query = GL_PIXEL_MAP_I_TO_I_SIZE;
+ break;
+ case GL_PIXEL_MAP_S_TO_S:
+ query = GL_PIXEL_MAP_S_TO_S_SIZE;
+ break;
+ case GL_PIXEL_MAP_I_TO_R:
+ query = GL_PIXEL_MAP_I_TO_R_SIZE;
+ break;
+ case GL_PIXEL_MAP_I_TO_G:
+ query = GL_PIXEL_MAP_I_TO_G_SIZE;
+ break;
+ case GL_PIXEL_MAP_I_TO_B:
+ query = GL_PIXEL_MAP_I_TO_B_SIZE;
+ break;
+ case GL_PIXEL_MAP_I_TO_A:
+ query = GL_PIXEL_MAP_I_TO_A_SIZE;
+ break;
+ case GL_PIXEL_MAP_R_TO_R:
+ query = GL_PIXEL_MAP_R_TO_R_SIZE;
+ break;
+ case GL_PIXEL_MAP_G_TO_G:
+ query = GL_PIXEL_MAP_G_TO_G_SIZE;
+ break;
+ case GL_PIXEL_MAP_B_TO_B:
+ query = GL_PIXEL_MAP_B_TO_B_SIZE;
+ break;
+ case GL_PIXEL_MAP_A_TO_A:
+ query = GL_PIXEL_MAP_A_TO_A_SIZE;
+ break;
+ default:
+ return -1;
+ }
+ CALL_GetIntegerv( GET_DISPATCH(), (query, &size) );
+ return size;
+}
+
+GLint __glGetPixelMapfv_size(GLenum map)
+{
+ return __glGetPixelMap_size(map);
+}
+
+GLint __glGetPixelMapuiv_size(GLenum map)
+{
+ return __glGetPixelMap_size(map);
+}
+
+GLint __glGetPixelMapusv_size(GLenum map)
+{
+ return __glGetPixelMap_size(map);
+}
+
+GLint __glGetTexImage_size(GLenum target, GLint level, GLenum format,
+ GLenum type, GLint width, GLint height, GLint depth)
+{
+ return __glXImageSize( format, type, target, width, height, depth,
+ 0, 0, 0, 0, 4 );
+}
diff --git a/xorg-server/glx/xfont.c b/xorg-server/glx/xfont.c index af0b21831..5f5d7efba 100644 --- a/xorg-server/glx/xfont.c +++ b/xorg-server/glx/xfont.c @@ -101,9 +101,7 @@ static int __glXMakeBitmapFromGlyph(FontPtr font, CharInfoPtr pci) pci->metrics.characterWidth, 0,
allocbuf ? allocbuf : buf) );
- if (allocbuf) {
- free(allocbuf);
- }
+ free(allocbuf);
return Success;
#undef __GL_CHAR_BUF_SIZE
}
diff --git a/xorg-server/hw/dmx/config/dmxparse.c b/xorg-server/hw/dmx/config/dmxparse.c index 28a1835af..f75151eac 100644 --- a/xorg-server/hw/dmx/config/dmxparse.c +++ b/xorg-server/hw/dmx/config/dmxparse.c @@ -1,607 +1,607 @@ -/* - * Copyright 2002 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Rickard E. (Rik) Faith <faith@redhat.com> - * - */ - -/** \file - * - * This file provides support routines and helper functions to be used - * by the DMX configuration file parser. - * - * Because the DMX configuration file parsing should be capable of being - * used in a stand-alone fashion (i.e., independent from the DMX server - * source tree), no dependencies on other DMX routines are made. */ - -#ifdef HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include "dmxparse.h" - -/** A general error logging routine that does not depend on the dmxLog - * functions. */ -void dmxConfigLog(const char *format, ...) -{ - va_list args; - - va_start(args, format); - vprintf(format, args); /* RATS: All calls to dmxConfigLog from - * dmxparse.c and dmxprint.c use a - * trusted format. */ - va_end(args); -} - -void *dmxConfigAlloc(unsigned long bytes) -{ - void *area = calloc(1, bytes); - if (!area) { - dmxConfigLog("dmxConfigAlloc: out of memory\n"); - return NULL; - } - return area; -} - -void *dmxConfigRealloc(void *orig, unsigned long orig_bytes, - unsigned long bytes) -{ - unsigned char *area = realloc(orig, bytes); - if (!area) { - dmxConfigLog("dmxConfigRealloc: out of memory\n"); - return NULL; - } - memset(area + orig_bytes, 0, bytes - orig_bytes); - return area; -} - -const char *dmxConfigCopyString(const char *string, int length) -{ - char *copy; - - if (!length) length = strlen(string); - copy = dmxConfigAlloc(length + 1); - if (length) strncpy(copy, string, length); - copy[length] = '\0'; - return copy; -} - -void dmxConfigFree(void *area) -{ - if (area) free(area); -} - -DMXConfigTokenPtr dmxConfigCreateToken(int token, int line, - const char *comment) -{ - DMXConfigTokenPtr pToken = dmxConfigAlloc(sizeof(*pToken)); - pToken->token = token; - pToken->line = line; - pToken->comment = comment; - return pToken; -} - -void dmxConfigFreeToken(DMXConfigTokenPtr p) -{ - if (!p) return; - dmxConfigFree((void *)p->comment); - dmxConfigFree(p); -} - -DMXConfigStringPtr dmxConfigCreateString(int token, int line, - const char *comment, - const char *string) -{ - DMXConfigStringPtr pString = dmxConfigAlloc(sizeof(*pString)); - - pString->token = token; - pString->line = line; - pString->comment = comment; - pString->string = string; - return pString; -} - -void dmxConfigFreeString(DMXConfigStringPtr p) -{ - DMXConfigStringPtr next; - - if (!p) return; - do { - next = p->next; - dmxConfigFree((void *)p->comment); - dmxConfigFree((void *)p->string); - dmxConfigFree(p); - } while ((p = next)); -} - -DMXConfigNumberPtr dmxConfigCreateNumber(int token, int line, - const char *comment, - int number) -{ - DMXConfigNumberPtr pNumber = dmxConfigAlloc(sizeof(*pNumber)); - - pNumber->token = token; - pNumber->line = line; - pNumber->comment = comment; - pNumber->number = number; - return pNumber; -} - -void dmxConfigFreeNumber(DMXConfigNumberPtr p) -{ - if (!p) return; - dmxConfigFree((void *)p->comment); - dmxConfigFree(p); -} - -DMXConfigPairPtr dmxConfigCreatePair(int token, int line, - const char *comment, - int x, int y, - int xsign, int ysign) -{ - DMXConfigPairPtr pPair = dmxConfigAlloc(sizeof(*pPair)); - - pPair->token = token; - pPair->line = line; - pPair->comment = comment; - pPair->x = x; - pPair->y = y; - pPair->xsign = (xsign < 0) ? -1 : 1; - pPair->ysign = (ysign < 0) ? -1 : 1; - return pPair; -} - -void dmxConfigFreePair(DMXConfigPairPtr p) -{ - if (!p) return; - dmxConfigFree((void *)p->comment); - dmxConfigFree(p); -} - -DMXConfigCommentPtr dmxConfigCreateComment(int token, int line, - const char *comment) -{ - DMXConfigCommentPtr pComment = dmxConfigAlloc(sizeof(*pComment)); - - pComment->token = token; - pComment->line = line; - pComment->comment = comment; - return pComment; -} - -void dmxConfigFreeComment(DMXConfigCommentPtr p) -{ - if (!p) return; - dmxConfigFree((void *)p->comment); - dmxConfigFree(p); -} - -DMXConfigPartDimPtr dmxConfigCreatePartDim(DMXConfigPairPtr pDim, - DMXConfigPairPtr pOffset) -{ - DMXConfigPartDimPtr pPart = dmxConfigAlloc(sizeof(*pPart)); - pPart->dim = pDim; - pPart->offset = pOffset; - return pPart; -} - -void dmxConfigFreePartDim(DMXConfigPartDimPtr p) -{ - if (!p) return; - dmxConfigFreePair(p->dim); - dmxConfigFreePair(p->offset); - dmxConfigFree(p); -} - -DMXConfigFullDimPtr dmxConfigCreateFullDim(DMXConfigPartDimPtr pScrn, - DMXConfigPartDimPtr pRoot) -{ - DMXConfigFullDimPtr pFull = dmxConfigAlloc(sizeof(*pFull)); - pFull->scrn = pScrn; - pFull->root = pRoot; - return pFull; -} - -void dmxConfigFreeFullDim(DMXConfigFullDimPtr p) -{ - if (!p) return; - dmxConfigFreePartDim(p->scrn); - dmxConfigFreePartDim(p->root); - dmxConfigFree(p); -} - -DMXConfigDisplayPtr dmxConfigCreateDisplay(DMXConfigTokenPtr pStart, - DMXConfigStringPtr pName, - DMXConfigFullDimPtr pDim, - DMXConfigPairPtr pOrigin, - DMXConfigTokenPtr pEnd) -{ - DMXConfigDisplayPtr pDisplay = dmxConfigAlloc(sizeof(*pDisplay)); - - pDisplay->start = pStart; - pDisplay->dname = pName; - pDisplay->dim = pDim; - pDisplay->origin = pOrigin; - pDisplay->end = pEnd; - - pDisplay->name = pName ? pName->string : NULL; - pDisplay->rootXOrigin = pOrigin ? pOrigin->x : 0; - pDisplay->rootYOrigin = pOrigin ? pOrigin->y : 0; - - if (pDim && pDim->scrn && pDim->scrn->dim) { - pDisplay->scrnWidth = pDim->scrn->dim->x; - pDisplay->scrnHeight = pDim->scrn->dim->y; - } - if (pDim && pDim->scrn && pDim->scrn->offset) { - pDisplay->scrnX = pDim->scrn->offset->x; - pDisplay->scrnY = pDim->scrn->offset->y; - pDisplay->scrnXSign = pDim->scrn->offset->xsign; - pDisplay->scrnYSign = pDim->scrn->offset->ysign; - } - - if (pDim && pDim->root) { - if (pDim->root->dim) { - pDisplay->rootWidth = pDim->root->dim->x; - pDisplay->rootHeight = pDim->root->dim->y; - } - if (pDim->root->offset) { - pDisplay->rootX = pDim->root->offset->x; - pDisplay->rootY = pDim->root->offset->y; - pDisplay->rootXSign = pDim->root->offset->xsign; - pDisplay->rootYSign = pDim->root->offset->ysign; - } - } else { /* If no root specification, copy width - * and height from scrn -- leave offset - * as zero, since it is relative to - * scrn. */ - pDisplay->rootWidth = pDisplay->scrnWidth; - pDisplay->rootHeight = pDisplay->scrnHeight; - } - - - return pDisplay; -} - -void dmxConfigFreeDisplay(DMXConfigDisplayPtr p) -{ - if (!p) return; - dmxConfigFreeToken(p->start); - dmxConfigFreeString(p->dname); - dmxConfigFreeFullDim(p->dim); - dmxConfigFreeToken(p->end); - dmxConfigFree(p); -} - -DMXConfigWallPtr dmxConfigCreateWall(DMXConfigTokenPtr pStart, - DMXConfigPairPtr pWallDim, - DMXConfigPairPtr pDisplayDim, - DMXConfigStringPtr pNameList, - DMXConfigTokenPtr pEnd) -{ - DMXConfigWallPtr pWall = dmxConfigAlloc(sizeof(*pWall)); - - pWall->start = pStart; - pWall->wallDim = pWallDim; - pWall->displayDim = pDisplayDim; - pWall->nameList = pNameList; - pWall->end = pEnd; - - pWall->width = pDisplayDim ? pDisplayDim->x : 0; - pWall->height = pDisplayDim ? pDisplayDim->y : 0; - pWall->xwall = pWallDim ? pWallDim->x : 0; - pWall->ywall = pWallDim ? pWallDim->y : 0; - - return pWall; -} - -void dmxConfigFreeWall(DMXConfigWallPtr p) -{ - if (!p) return; - dmxConfigFreeToken(p->start); - dmxConfigFreePair(p->wallDim); - dmxConfigFreePair(p->displayDim); - dmxConfigFreeString(p->nameList); - dmxConfigFreeToken(p->end); - dmxConfigFree(p); -} - -DMXConfigOptionPtr dmxConfigCreateOption(DMXConfigTokenPtr pStart, - DMXConfigStringPtr pOption, - DMXConfigTokenPtr pEnd) -{ - int length = 0; - int offset = 0; - DMXConfigStringPtr p; - DMXConfigOptionPtr option = dmxConfigAlloc(sizeof(*option)); - - for (p = pOption; p; p = p->next) { - if (p->string) length += strlen(p->string) + 1; - } - - option->string = dmxConfigAlloc(length + 1); - - for (p = pOption; p; p = p->next) { - if (p->string) { - int len = strlen(p->string); - strncpy(option->string + offset, p->string, len); - offset += len; - if (p->next) option->string[offset++] = ' '; - } - } - option->string[offset] = '\0'; - - option->start = pStart; - option->option = pOption; - option->end = pEnd; - - return option; -} - -void dmxConfigFreeOption(DMXConfigOptionPtr p) -{ - if (!p) return; - if (p->string) free(p->string); - dmxConfigFreeToken(p->start); - dmxConfigFreeString(p->option); - dmxConfigFreeToken(p->end); - dmxConfigFree(p); -} - -const char **dmxConfigLookupParam(DMXConfigParamPtr p, const char *key, - int *argc) -{ - DMXConfigParamPtr pt; - - for (pt = p; pt; pt = pt->next) { - if (pt->argv && !strcasecmp(pt->argv[0], key)) { - *argc = pt->argc; - return pt->argv; - } - } - *argc = 0; - return NULL; -} - -DMXConfigParamPtr dmxConfigCreateParam(DMXConfigTokenPtr pStart, - DMXConfigTokenPtr pOpen, - DMXConfigStringPtr pParam, - DMXConfigTokenPtr pClose, - DMXConfigTokenPtr pEnd) -{ - DMXConfigParamPtr param = dmxConfigAlloc(sizeof(*param)); - DMXConfigStringPtr pt; - - param->argc = 0; - param->argv = NULL; - for (pt = pParam; pt; pt = pt->next) { - if (pt->string) { - param->argv = realloc(param->argv, - (param->argc+2) * sizeof(*param->argv)); - param->argv[param->argc] = pt->string; - ++param->argc; - } - } - if (param->argv) param->argv[param->argc] = NULL; - - param->start = pStart; - param->open = pOpen; - param->param = pParam; - param->close = pClose; - param->end = pEnd; - - return param; -} - -void dmxConfigFreeParam(DMXConfigParamPtr p) -{ - DMXConfigParamPtr next; - - if (!p) return; - do { - next = p->next; - dmxConfigFreeToken(p->start); - dmxConfigFreeToken(p->open); - dmxConfigFreeString(p->param); - dmxConfigFreeToken(p->close); - dmxConfigFreeToken(p->end); - dmxConfigFree(p->argv); - dmxConfigFree(p); - } while ((p = next)); -} - -DMXConfigSubPtr dmxConfigCreateSub(DMXConfigType type, - DMXConfigCommentPtr comment, - DMXConfigDisplayPtr display, - DMXConfigWallPtr wall, - DMXConfigOptionPtr option, - DMXConfigParamPtr param) -{ - DMXConfigSubPtr pSub = dmxConfigAlloc(sizeof(*pSub)); - pSub->type = type; - switch (type) { - case dmxConfigComment: pSub->comment = comment; break; - case dmxConfigDisplay: pSub->display = display; break; - case dmxConfigWall: pSub->wall = wall; break; - case dmxConfigOption: pSub->option = option; break; - case dmxConfigParam: pSub->param = param; break; - default: dmxConfigLog("Type %d not supported in subentry\n", type); break; - } - return pSub; -} - -void dmxConfigFreeSub(DMXConfigSubPtr sub) -{ - DMXConfigSubPtr pt; - - for (pt = sub; pt; pt = pt->next) { - switch (pt->type) { - case dmxConfigComment: dmxConfigFreeComment(pt->comment); break; - case dmxConfigDisplay: dmxConfigFreeDisplay(pt->display); break; - case dmxConfigWall: dmxConfigFreeWall(pt->wall); break; - case dmxConfigOption: dmxConfigFreeOption(pt->option); break; - case dmxConfigParam: dmxConfigFreeParam(pt->param); break; - default: - dmxConfigLog("Type %d not supported in subentry\n", pt->type); - break; - } - } - dmxConfigFree(sub); -} - -DMXConfigSubPtr dmxConfigSubComment(DMXConfigCommentPtr comment) -{ - return dmxConfigCreateSub(dmxConfigComment, comment, NULL, NULL, NULL, - NULL); -} - -DMXConfigSubPtr dmxConfigSubDisplay(DMXConfigDisplayPtr display) -{ - return dmxConfigCreateSub(dmxConfigDisplay, NULL, display, NULL, NULL, - NULL); -} - -DMXConfigSubPtr dmxConfigSubWall(DMXConfigWallPtr wall) -{ - return dmxConfigCreateSub(dmxConfigWall, NULL, NULL, wall, NULL, NULL); -} - -DMXConfigSubPtr dmxConfigSubOption(DMXConfigOptionPtr option) -{ - return dmxConfigCreateSub(dmxConfigOption, NULL, NULL, NULL, option, NULL); -} - -DMXConfigSubPtr dmxConfigSubParam(DMXConfigParamPtr param) -{ - return dmxConfigCreateSub(dmxConfigParam, NULL, NULL, NULL, NULL, param); -} - -extern DMXConfigSubPtr dmxConfigAddSub(DMXConfigSubPtr head, - DMXConfigSubPtr sub) -{ - DMXConfigSubPtr pt; - - if (!head) return sub; - for (pt = head; pt->next; pt = pt->next); - pt->next = sub; - return head; -} - -DMXConfigVirtualPtr dmxConfigCreateVirtual(DMXConfigTokenPtr pStart, - DMXConfigStringPtr pName, - DMXConfigPairPtr pDim, - DMXConfigTokenPtr pOpen, - DMXConfigSubPtr pSubentry, - DMXConfigTokenPtr pClose) -{ - DMXConfigVirtualPtr pVirtual = dmxConfigAlloc(sizeof(*pVirtual)); - - pVirtual->start = pStart; - pVirtual->vname = pName; - pVirtual->dim = pDim; - pVirtual->open = pOpen; - pVirtual->subentry = pSubentry; - pVirtual->close = pClose; - - pVirtual->name = pName ? pName->string : NULL; - pVirtual->width = pDim ? pDim->x : 0; - pVirtual->height = pDim ? pDim->y : 0; - - return pVirtual; -} - -void dmxConfigFreeVirtual(DMXConfigVirtualPtr virtual) -{ - dmxConfigFreeToken(virtual->start); - dmxConfigFreeString(virtual->vname); - dmxConfigFreePair(virtual->dim); - dmxConfigFreeToken(virtual->open); - dmxConfigFreeSub(virtual->subentry); - dmxConfigFreeToken(virtual->close); - dmxConfigFree(virtual); -} - -DMXConfigEntryPtr dmxConfigCreateEntry(DMXConfigType type, - DMXConfigCommentPtr comment, - DMXConfigVirtualPtr virtual) -{ - DMXConfigEntryPtr pEntry = dmxConfigAlloc(sizeof(*pEntry)); - pEntry->type = type; - switch (type) { - case dmxConfigComment: pEntry->comment = comment; break; - case dmxConfigVirtual: pEntry->virtual = virtual; break; - default: dmxConfigLog("Type %d not supported in entry\n", type); break; - } - return pEntry; -} - -void dmxConfigFreeEntry(DMXConfigEntryPtr entry) -{ - DMXConfigEntryPtr pt; - - for (pt = entry; pt; pt = pt->next) { - switch (pt->type) { - case dmxConfigComment: dmxConfigFreeComment(pt->comment); break; - case dmxConfigVirtual: dmxConfigFreeVirtual(pt->virtual); break; - default: - dmxConfigLog("Type %d not supported in entry\n", pt->type); - break; - } - } - dmxConfigFree(entry); -} - -DMXConfigEntryPtr dmxConfigAddEntry(DMXConfigEntryPtr head, - DMXConfigType type, - DMXConfigCommentPtr comment, - DMXConfigVirtualPtr virtual) -{ - DMXConfigEntryPtr child = dmxConfigCreateEntry(type, comment, virtual); - DMXConfigEntryPtr pt; - - if (!head) return child; - - for (pt = head; pt->next; pt = pt->next); - pt->next = child; - - return head; -} - -DMXConfigEntryPtr dmxConfigEntryComment(DMXConfigCommentPtr comment) -{ - return dmxConfigCreateEntry(dmxConfigComment, comment, NULL); -} - -DMXConfigEntryPtr dmxConfigEntryVirtual(DMXConfigVirtualPtr virtual) -{ - return dmxConfigCreateEntry(dmxConfigVirtual, NULL, virtual); -} +/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This file provides support routines and helper functions to be used
+ * by the DMX configuration file parser.
+ *
+ * Because the DMX configuration file parsing should be capable of being
+ * used in a stand-alone fashion (i.e., independent from the DMX server
+ * source tree), no dependencies on other DMX routines are made. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include "dmxparse.h"
+
+/** A general error logging routine that does not depend on the dmxLog
+ * functions. */
+void dmxConfigLog(const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ vprintf(format, args); /* RATS: All calls to dmxConfigLog from
+ * dmxparse.c and dmxprint.c use a
+ * trusted format. */
+ va_end(args);
+}
+
+void *dmxConfigAlloc(unsigned long bytes)
+{
+ void *area = calloc(1, bytes);
+ if (!area) {
+ dmxConfigLog("dmxConfigAlloc: out of memory\n");
+ return NULL;
+ }
+ return area;
+}
+
+void *dmxConfigRealloc(void *orig, unsigned long orig_bytes,
+ unsigned long bytes)
+{
+ unsigned char *area = realloc(orig, bytes);
+ if (!area) {
+ dmxConfigLog("dmxConfigRealloc: out of memory\n");
+ return NULL;
+ }
+ memset(area + orig_bytes, 0, bytes - orig_bytes);
+ return area;
+}
+
+const char *dmxConfigCopyString(const char *string, int length)
+{
+ char *copy;
+
+ if (!length) length = strlen(string);
+ copy = dmxConfigAlloc(length + 1);
+ if (length) strncpy(copy, string, length);
+ copy[length] = '\0';
+ return copy;
+}
+
+void dmxConfigFree(void *area)
+{
+ free(area);
+}
+
+DMXConfigTokenPtr dmxConfigCreateToken(int token, int line,
+ const char *comment)
+{
+ DMXConfigTokenPtr pToken = dmxConfigAlloc(sizeof(*pToken));
+ pToken->token = token;
+ pToken->line = line;
+ pToken->comment = comment;
+ return pToken;
+}
+
+void dmxConfigFreeToken(DMXConfigTokenPtr p)
+{
+ if (!p) return;
+ dmxConfigFree((void *)p->comment);
+ dmxConfigFree(p);
+}
+
+DMXConfigStringPtr dmxConfigCreateString(int token, int line,
+ const char *comment,
+ const char *string)
+{
+ DMXConfigStringPtr pString = dmxConfigAlloc(sizeof(*pString));
+
+ pString->token = token;
+ pString->line = line;
+ pString->comment = comment;
+ pString->string = string;
+ return pString;
+}
+
+void dmxConfigFreeString(DMXConfigStringPtr p)
+{
+ DMXConfigStringPtr next;
+
+ if (!p) return;
+ do {
+ next = p->next;
+ dmxConfigFree((void *)p->comment);
+ dmxConfigFree((void *)p->string);
+ dmxConfigFree(p);
+ } while ((p = next));
+}
+
+DMXConfigNumberPtr dmxConfigCreateNumber(int token, int line,
+ const char *comment,
+ int number)
+{
+ DMXConfigNumberPtr pNumber = dmxConfigAlloc(sizeof(*pNumber));
+
+ pNumber->token = token;
+ pNumber->line = line;
+ pNumber->comment = comment;
+ pNumber->number = number;
+ return pNumber;
+}
+
+void dmxConfigFreeNumber(DMXConfigNumberPtr p)
+{
+ if (!p) return;
+ dmxConfigFree((void *)p->comment);
+ dmxConfigFree(p);
+}
+
+DMXConfigPairPtr dmxConfigCreatePair(int token, int line,
+ const char *comment,
+ int x, int y,
+ int xsign, int ysign)
+{
+ DMXConfigPairPtr pPair = dmxConfigAlloc(sizeof(*pPair));
+
+ pPair->token = token;
+ pPair->line = line;
+ pPair->comment = comment;
+ pPair->x = x;
+ pPair->y = y;
+ pPair->xsign = (xsign < 0) ? -1 : 1;
+ pPair->ysign = (ysign < 0) ? -1 : 1;
+ return pPair;
+}
+
+void dmxConfigFreePair(DMXConfigPairPtr p)
+{
+ if (!p) return;
+ dmxConfigFree((void *)p->comment);
+ dmxConfigFree(p);
+}
+
+DMXConfigCommentPtr dmxConfigCreateComment(int token, int line,
+ const char *comment)
+{
+ DMXConfigCommentPtr pComment = dmxConfigAlloc(sizeof(*pComment));
+
+ pComment->token = token;
+ pComment->line = line;
+ pComment->comment = comment;
+ return pComment;
+}
+
+void dmxConfigFreeComment(DMXConfigCommentPtr p)
+{
+ if (!p) return;
+ dmxConfigFree((void *)p->comment);
+ dmxConfigFree(p);
+}
+
+DMXConfigPartDimPtr dmxConfigCreatePartDim(DMXConfigPairPtr pDim,
+ DMXConfigPairPtr pOffset)
+{
+ DMXConfigPartDimPtr pPart = dmxConfigAlloc(sizeof(*pPart));
+ pPart->dim = pDim;
+ pPart->offset = pOffset;
+ return pPart;
+}
+
+void dmxConfigFreePartDim(DMXConfigPartDimPtr p)
+{
+ if (!p) return;
+ dmxConfigFreePair(p->dim);
+ dmxConfigFreePair(p->offset);
+ dmxConfigFree(p);
+}
+
+DMXConfigFullDimPtr dmxConfigCreateFullDim(DMXConfigPartDimPtr pScrn,
+ DMXConfigPartDimPtr pRoot)
+{
+ DMXConfigFullDimPtr pFull = dmxConfigAlloc(sizeof(*pFull));
+ pFull->scrn = pScrn;
+ pFull->root = pRoot;
+ return pFull;
+}
+
+void dmxConfigFreeFullDim(DMXConfigFullDimPtr p)
+{
+ if (!p) return;
+ dmxConfigFreePartDim(p->scrn);
+ dmxConfigFreePartDim(p->root);
+ dmxConfigFree(p);
+}
+
+DMXConfigDisplayPtr dmxConfigCreateDisplay(DMXConfigTokenPtr pStart,
+ DMXConfigStringPtr pName,
+ DMXConfigFullDimPtr pDim,
+ DMXConfigPairPtr pOrigin,
+ DMXConfigTokenPtr pEnd)
+{
+ DMXConfigDisplayPtr pDisplay = dmxConfigAlloc(sizeof(*pDisplay));
+
+ pDisplay->start = pStart;
+ pDisplay->dname = pName;
+ pDisplay->dim = pDim;
+ pDisplay->origin = pOrigin;
+ pDisplay->end = pEnd;
+
+ pDisplay->name = pName ? pName->string : NULL;
+ pDisplay->rootXOrigin = pOrigin ? pOrigin->x : 0;
+ pDisplay->rootYOrigin = pOrigin ? pOrigin->y : 0;
+
+ if (pDim && pDim->scrn && pDim->scrn->dim) {
+ pDisplay->scrnWidth = pDim->scrn->dim->x;
+ pDisplay->scrnHeight = pDim->scrn->dim->y;
+ }
+ if (pDim && pDim->scrn && pDim->scrn->offset) {
+ pDisplay->scrnX = pDim->scrn->offset->x;
+ pDisplay->scrnY = pDim->scrn->offset->y;
+ pDisplay->scrnXSign = pDim->scrn->offset->xsign;
+ pDisplay->scrnYSign = pDim->scrn->offset->ysign;
+ }
+
+ if (pDim && pDim->root) {
+ if (pDim->root->dim) {
+ pDisplay->rootWidth = pDim->root->dim->x;
+ pDisplay->rootHeight = pDim->root->dim->y;
+ }
+ if (pDim->root->offset) {
+ pDisplay->rootX = pDim->root->offset->x;
+ pDisplay->rootY = pDim->root->offset->y;
+ pDisplay->rootXSign = pDim->root->offset->xsign;
+ pDisplay->rootYSign = pDim->root->offset->ysign;
+ }
+ } else { /* If no root specification, copy width
+ * and height from scrn -- leave offset
+ * as zero, since it is relative to
+ * scrn. */
+ pDisplay->rootWidth = pDisplay->scrnWidth;
+ pDisplay->rootHeight = pDisplay->scrnHeight;
+ }
+
+
+ return pDisplay;
+}
+
+void dmxConfigFreeDisplay(DMXConfigDisplayPtr p)
+{
+ if (!p) return;
+ dmxConfigFreeToken(p->start);
+ dmxConfigFreeString(p->dname);
+ dmxConfigFreeFullDim(p->dim);
+ dmxConfigFreeToken(p->end);
+ dmxConfigFree(p);
+}
+
+DMXConfigWallPtr dmxConfigCreateWall(DMXConfigTokenPtr pStart,
+ DMXConfigPairPtr pWallDim,
+ DMXConfigPairPtr pDisplayDim,
+ DMXConfigStringPtr pNameList,
+ DMXConfigTokenPtr pEnd)
+{
+ DMXConfigWallPtr pWall = dmxConfigAlloc(sizeof(*pWall));
+
+ pWall->start = pStart;
+ pWall->wallDim = pWallDim;
+ pWall->displayDim = pDisplayDim;
+ pWall->nameList = pNameList;
+ pWall->end = pEnd;
+
+ pWall->width = pDisplayDim ? pDisplayDim->x : 0;
+ pWall->height = pDisplayDim ? pDisplayDim->y : 0;
+ pWall->xwall = pWallDim ? pWallDim->x : 0;
+ pWall->ywall = pWallDim ? pWallDim->y : 0;
+
+ return pWall;
+}
+
+void dmxConfigFreeWall(DMXConfigWallPtr p)
+{
+ if (!p) return;
+ dmxConfigFreeToken(p->start);
+ dmxConfigFreePair(p->wallDim);
+ dmxConfigFreePair(p->displayDim);
+ dmxConfigFreeString(p->nameList);
+ dmxConfigFreeToken(p->end);
+ dmxConfigFree(p);
+}
+
+DMXConfigOptionPtr dmxConfigCreateOption(DMXConfigTokenPtr pStart,
+ DMXConfigStringPtr pOption,
+ DMXConfigTokenPtr pEnd)
+{
+ int length = 0;
+ int offset = 0;
+ DMXConfigStringPtr p;
+ DMXConfigOptionPtr option = dmxConfigAlloc(sizeof(*option));
+
+ for (p = pOption; p; p = p->next) {
+ if (p->string) length += strlen(p->string) + 1;
+ }
+
+ option->string = dmxConfigAlloc(length + 1);
+
+ for (p = pOption; p; p = p->next) {
+ if (p->string) {
+ int len = strlen(p->string);
+ strncpy(option->string + offset, p->string, len);
+ offset += len;
+ if (p->next) option->string[offset++] = ' ';
+ }
+ }
+ option->string[offset] = '\0';
+
+ option->start = pStart;
+ option->option = pOption;
+ option->end = pEnd;
+
+ return option;
+}
+
+void dmxConfigFreeOption(DMXConfigOptionPtr p)
+{
+ if (!p) return;
+ free(p->string);
+ dmxConfigFreeToken(p->start);
+ dmxConfigFreeString(p->option);
+ dmxConfigFreeToken(p->end);
+ dmxConfigFree(p);
+}
+
+const char **dmxConfigLookupParam(DMXConfigParamPtr p, const char *key,
+ int *argc)
+{
+ DMXConfigParamPtr pt;
+
+ for (pt = p; pt; pt = pt->next) {
+ if (pt->argv && !strcasecmp(pt->argv[0], key)) {
+ *argc = pt->argc;
+ return pt->argv;
+ }
+ }
+ *argc = 0;
+ return NULL;
+}
+
+DMXConfigParamPtr dmxConfigCreateParam(DMXConfigTokenPtr pStart,
+ DMXConfigTokenPtr pOpen,
+ DMXConfigStringPtr pParam,
+ DMXConfigTokenPtr pClose,
+ DMXConfigTokenPtr pEnd)
+{
+ DMXConfigParamPtr param = dmxConfigAlloc(sizeof(*param));
+ DMXConfigStringPtr pt;
+
+ param->argc = 0;
+ param->argv = NULL;
+ for (pt = pParam; pt; pt = pt->next) {
+ if (pt->string) {
+ param->argv = realloc(param->argv,
+ (param->argc+2) * sizeof(*param->argv));
+ param->argv[param->argc] = pt->string;
+ ++param->argc;
+ }
+ }
+ if (param->argv) param->argv[param->argc] = NULL;
+
+ param->start = pStart;
+ param->open = pOpen;
+ param->param = pParam;
+ param->close = pClose;
+ param->end = pEnd;
+
+ return param;
+}
+
+void dmxConfigFreeParam(DMXConfigParamPtr p)
+{
+ DMXConfigParamPtr next;
+
+ if (!p) return;
+ do {
+ next = p->next;
+ dmxConfigFreeToken(p->start);
+ dmxConfigFreeToken(p->open);
+ dmxConfigFreeString(p->param);
+ dmxConfigFreeToken(p->close);
+ dmxConfigFreeToken(p->end);
+ dmxConfigFree(p->argv);
+ dmxConfigFree(p);
+ } while ((p = next));
+}
+
+DMXConfigSubPtr dmxConfigCreateSub(DMXConfigType type,
+ DMXConfigCommentPtr comment,
+ DMXConfigDisplayPtr display,
+ DMXConfigWallPtr wall,
+ DMXConfigOptionPtr option,
+ DMXConfigParamPtr param)
+{
+ DMXConfigSubPtr pSub = dmxConfigAlloc(sizeof(*pSub));
+ pSub->type = type;
+ switch (type) {
+ case dmxConfigComment: pSub->comment = comment; break;
+ case dmxConfigDisplay: pSub->display = display; break;
+ case dmxConfigWall: pSub->wall = wall; break;
+ case dmxConfigOption: pSub->option = option; break;
+ case dmxConfigParam: pSub->param = param; break;
+ default: dmxConfigLog("Type %d not supported in subentry\n", type); break;
+ }
+ return pSub;
+}
+
+void dmxConfigFreeSub(DMXConfigSubPtr sub)
+{
+ DMXConfigSubPtr pt;
+
+ for (pt = sub; pt; pt = pt->next) {
+ switch (pt->type) {
+ case dmxConfigComment: dmxConfigFreeComment(pt->comment); break;
+ case dmxConfigDisplay: dmxConfigFreeDisplay(pt->display); break;
+ case dmxConfigWall: dmxConfigFreeWall(pt->wall); break;
+ case dmxConfigOption: dmxConfigFreeOption(pt->option); break;
+ case dmxConfigParam: dmxConfigFreeParam(pt->param); break;
+ default:
+ dmxConfigLog("Type %d not supported in subentry\n", pt->type);
+ break;
+ }
+ }
+ dmxConfigFree(sub);
+}
+
+DMXConfigSubPtr dmxConfigSubComment(DMXConfigCommentPtr comment)
+{
+ return dmxConfigCreateSub(dmxConfigComment, comment, NULL, NULL, NULL,
+ NULL);
+}
+
+DMXConfigSubPtr dmxConfigSubDisplay(DMXConfigDisplayPtr display)
+{
+ return dmxConfigCreateSub(dmxConfigDisplay, NULL, display, NULL, NULL,
+ NULL);
+}
+
+DMXConfigSubPtr dmxConfigSubWall(DMXConfigWallPtr wall)
+{
+ return dmxConfigCreateSub(dmxConfigWall, NULL, NULL, wall, NULL, NULL);
+}
+
+DMXConfigSubPtr dmxConfigSubOption(DMXConfigOptionPtr option)
+{
+ return dmxConfigCreateSub(dmxConfigOption, NULL, NULL, NULL, option, NULL);
+}
+
+DMXConfigSubPtr dmxConfigSubParam(DMXConfigParamPtr param)
+{
+ return dmxConfigCreateSub(dmxConfigParam, NULL, NULL, NULL, NULL, param);
+}
+
+extern DMXConfigSubPtr dmxConfigAddSub(DMXConfigSubPtr head,
+ DMXConfigSubPtr sub)
+{
+ DMXConfigSubPtr pt;
+
+ if (!head) return sub;
+ for (pt = head; pt->next; pt = pt->next);
+ pt->next = sub;
+ return head;
+}
+
+DMXConfigVirtualPtr dmxConfigCreateVirtual(DMXConfigTokenPtr pStart,
+ DMXConfigStringPtr pName,
+ DMXConfigPairPtr pDim,
+ DMXConfigTokenPtr pOpen,
+ DMXConfigSubPtr pSubentry,
+ DMXConfigTokenPtr pClose)
+{
+ DMXConfigVirtualPtr pVirtual = dmxConfigAlloc(sizeof(*pVirtual));
+
+ pVirtual->start = pStart;
+ pVirtual->vname = pName;
+ pVirtual->dim = pDim;
+ pVirtual->open = pOpen;
+ pVirtual->subentry = pSubentry;
+ pVirtual->close = pClose;
+
+ pVirtual->name = pName ? pName->string : NULL;
+ pVirtual->width = pDim ? pDim->x : 0;
+ pVirtual->height = pDim ? pDim->y : 0;
+
+ return pVirtual;
+}
+
+void dmxConfigFreeVirtual(DMXConfigVirtualPtr virtual)
+{
+ dmxConfigFreeToken(virtual->start);
+ dmxConfigFreeString(virtual->vname);
+ dmxConfigFreePair(virtual->dim);
+ dmxConfigFreeToken(virtual->open);
+ dmxConfigFreeSub(virtual->subentry);
+ dmxConfigFreeToken(virtual->close);
+ dmxConfigFree(virtual);
+}
+
+DMXConfigEntryPtr dmxConfigCreateEntry(DMXConfigType type,
+ DMXConfigCommentPtr comment,
+ DMXConfigVirtualPtr virtual)
+{
+ DMXConfigEntryPtr pEntry = dmxConfigAlloc(sizeof(*pEntry));
+ pEntry->type = type;
+ switch (type) {
+ case dmxConfigComment: pEntry->comment = comment; break;
+ case dmxConfigVirtual: pEntry->virtual = virtual; break;
+ default: dmxConfigLog("Type %d not supported in entry\n", type); break;
+ }
+ return pEntry;
+}
+
+void dmxConfigFreeEntry(DMXConfigEntryPtr entry)
+{
+ DMXConfigEntryPtr pt;
+
+ for (pt = entry; pt; pt = pt->next) {
+ switch (pt->type) {
+ case dmxConfigComment: dmxConfigFreeComment(pt->comment); break;
+ case dmxConfigVirtual: dmxConfigFreeVirtual(pt->virtual); break;
+ default:
+ dmxConfigLog("Type %d not supported in entry\n", pt->type);
+ break;
+ }
+ }
+ dmxConfigFree(entry);
+}
+
+DMXConfigEntryPtr dmxConfigAddEntry(DMXConfigEntryPtr head,
+ DMXConfigType type,
+ DMXConfigCommentPtr comment,
+ DMXConfigVirtualPtr virtual)
+{
+ DMXConfigEntryPtr child = dmxConfigCreateEntry(type, comment, virtual);
+ DMXConfigEntryPtr pt;
+
+ if (!head) return child;
+
+ for (pt = head; pt->next; pt = pt->next);
+ pt->next = child;
+
+ return head;
+}
+
+DMXConfigEntryPtr dmxConfigEntryComment(DMXConfigCommentPtr comment)
+{
+ return dmxConfigCreateEntry(dmxConfigComment, comment, NULL);
+}
+
+DMXConfigEntryPtr dmxConfigEntryVirtual(DMXConfigVirtualPtr virtual)
+{
+ return dmxConfigCreateEntry(dmxConfigVirtual, NULL, virtual);
+}
diff --git a/xorg-server/hw/dmx/dmx.h b/xorg-server/hw/dmx/dmx.h index fbb8b96ed..ddc11e368 100644 --- a/xorg-server/hw/dmx/dmx.h +++ b/xorg-server/hw/dmx/dmx.h @@ -1,367 +1,390 @@ -/* - * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Kevin E. Martin <kem@redhat.com> - * David H. Dawes <dawes@xfree86.org> - * Rickard E. (Rik) Faith <faith@redhat.com> - * - */ - -/** \file - * Main header file included by all other DMX-related files. - */ - -/** \mainpage - * - <a href="http://dmx.sourceforge.net">DMX Home Page</a> - * - <a href="http://sourceforge.net/projects/dmx">DMX Project Page (on - * Source Forge)</a> - * - <a href="http://dmx.sourceforge.net/dmx.html">Distributed Multihead - * X design</a>, the design document for DMX - * - <a href="http://dmx.sourceforge.net/DMXSpec.txt">Client-to-Server - * DMX Extension to the X Protocol</a> - */ - -#ifndef DMX_H -#define DMX_H - -#if HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#include "gcstruct.h" - -/* Handle client-side include files in one place. */ -#include "dmxclient.h" - -#include "globals.h" -#include "scrnintstr.h" - -#include "picturestr.h" - -#ifdef GLXEXT -#include <GL/glx.h> -#include <GL/glxint.h> -#endif - -typedef enum { - PosNone = -1, - PosAbsolute = 0, - PosRightOf, - PosLeftOf, - PosAbove, - PosBelow, - PosRelative -} PositionType; - -/** Provide the typedef globally, but keep the contents opaque outside - * of the input routines. \see dmxinput.h */ -typedef struct _DMXInputInfo DMXInputInfo; - -/** Provide the typedef globally, but keep the contents opaque outside - * of the XSync statistic routines. \see dmxstat.c */ -typedef struct _DMXStatInfo DMXStatInfo; - -/** Global structure containing information about each backend screen. */ -typedef struct _DMXScreenInfo { - const char *name; /**< Name from command line or config file */ - int index; /**< Index into dmxScreens global */ - - /*---------- Back-end X server information ----------*/ - - Display *beDisplay; /**< Back-end X server's display */ - int beWidth; /**< Width of BE display */ - int beHeight; /**< Height of BE display */ - int beDepth; /**< Depth of BE display */ - int beBPP; /**< Bits per pixel of BE display */ - int beXDPI; /**< Horizontal dots per inch of BE */ - int beYDPI; /**< Vertical dots per inch of BE */ - - int beNumDepths; /**< Number of depths on BE server */ - int *beDepths; /**< Depths from BE server */ - - int beNumPixmapFormats; /**< Number of pixmap formats on BE */ - XPixmapFormatValues *bePixmapFormats; /**< Pixmap formats on BE */ - - int beNumVisuals; /**< Number of visuals on BE */ - XVisualInfo *beVisuals; /**< Visuals from BE server */ - int beDefVisualIndex; /**< Default visual index of BE */ - - int beNumDefColormaps; /**< Number of default colormaps */ - Colormap *beDefColormaps; /**< Default colormaps for DMX server */ - - Pixel beBlackPixel; /**< Default black pixel for BE */ - Pixel beWhitePixel; /**< Default white pixel for BE */ - - /*---------- Screen window information ----------*/ - - Window scrnWin; /**< "Screen" window on backend display */ - int scrnX; /**< X offset of "screen" WRT BE display */ - int scrnY; /**< Y offset of "screen" WRT BE display */ - int scrnWidth; /**< Width of "screen" */ - int scrnHeight; /**< Height of "screen" */ - int scrnXSign; /**< X offset sign of "screen" */ - int scrnYSign; /**< Y offset sign of "screen" */ - - /** Default drawables for "screen" */ - Drawable scrnDefDrawables[MAXFORMATS]; - - struct _DMXScreenInfo *next; /**< List of "screens" on same display */ - struct _DMXScreenInfo *over; /**< List of "screens" that overlap */ - - /*---------- Root window information ----------*/ - - Window rootWin; /**< "Root" window on backend display */ - int rootX; /**< X offset of "root" window WRT "screen"*/ - int rootY; /**< Y offset of "root" window WRT "screen"*/ - int rootWidth; /**< Width of "root" window */ - int rootHeight; /**< Height of "root" window */ - - int rootXOrigin; /**< Global X origin of "root" window */ - int rootYOrigin; /**< Global Y origin of "root" window */ - - /*---------- Shadow framebuffer information ----------*/ - - void *shadow; /**< Shadow framebuffer data (if enabled) */ - XlibGC shadowGC; /**< Default GC used by shadow FB code */ - XImage *shadowFBImage; /**< Screen image used by shadow FB code */ - - /*---------- Other related information ----------*/ - - int shared; /**< Non-zero if another Xdmx is running */ - - Bool WMRunningOnBE; - - Cursor noCursor; - Cursor curCursor; - /* Support for cursors on overlapped - * backend displays. */ - CursorPtr cursor; - int cursorVisible; - int cursorNotShared; /* for overlapping screens on a backend */ - - PositionType where; /**< Relative layout information */ - int whereX; /**< Relative layout information */ - int whereY; /**< Relative layout information */ - int whereRefScreen; /**< Relative layout information */ - - int savedTimeout; /**< Original screen saver timeout */ - int dpmsCapable; /**< Non-zero if backend is DPMS capable */ - int dpmsEnabled; /**< Non-zero if DPMS enabled */ - int dpmsStandby; /**< Original DPMS standby value */ - int dpmsSuspend; /**< Original DPMS suspend value */ - int dpmsOff; /**< Original DPMS off value */ - - DMXStatInfo *stat; /**< Statistics about XSync */ - Bool needsSync; /**< True if an XSync is pending */ - -#ifdef GLXEXT - /** Visual information for glxProxy */ - int numGlxVisuals; - __GLXvisualConfig *glxVisuals; - int glxMajorOpcode; - int glxErrorBase; - - /** FB config information for glxProxy */ - __GLXFBConfig *fbconfigs; - int numFBConfigs; -#endif - - /** Function pointers to wrapped screen - * functions */ - CloseScreenProcPtr CloseScreen; - SaveScreenProcPtr SaveScreen; - - CreateGCProcPtr CreateGC; - - CreateWindowProcPtr CreateWindow; - DestroyWindowProcPtr DestroyWindow; - PositionWindowProcPtr PositionWindow; - ChangeWindowAttributesProcPtr ChangeWindowAttributes; - RealizeWindowProcPtr RealizeWindow; - UnrealizeWindowProcPtr UnrealizeWindow; - RestackWindowProcPtr RestackWindow; - WindowExposuresProcPtr WindowExposures; - CopyWindowProcPtr CopyWindow; - - ResizeWindowProcPtr ResizeWindow; - ReparentWindowProcPtr ReparentWindow; - - ChangeBorderWidthProcPtr ChangeBorderWidth; - - GetImageProcPtr GetImage; - GetSpansProcPtr GetSpans; - - CreatePixmapProcPtr CreatePixmap; - DestroyPixmapProcPtr DestroyPixmap; - BitmapToRegionProcPtr BitmapToRegion; - - RealizeFontProcPtr RealizeFont; - UnrealizeFontProcPtr UnrealizeFont; - - CreateColormapProcPtr CreateColormap; - DestroyColormapProcPtr DestroyColormap; - InstallColormapProcPtr InstallColormap; - StoreColorsProcPtr StoreColors; - - SetShapeProcPtr SetShape; - - CreatePictureProcPtr CreatePicture; - DestroyPictureProcPtr DestroyPicture; - ChangePictureClipProcPtr ChangePictureClip; - DestroyPictureClipProcPtr DestroyPictureClip; - - ChangePictureProcPtr ChangePicture; - ValidatePictureProcPtr ValidatePicture; - - CompositeProcPtr Composite; - GlyphsProcPtr Glyphs; - CompositeRectsProcPtr CompositeRects; - - InitIndexedProcPtr InitIndexed; - CloseIndexedProcPtr CloseIndexed; - UpdateIndexedProcPtr UpdateIndexed; - - TrapezoidsProcPtr Trapezoids; - TrianglesProcPtr Triangles; - TriStripProcPtr TriStrip; - TriFanProcPtr TriFan; -} DMXScreenInfo; - -/* Global variables available to all Xserver/hw/dmx routines. */ -extern int dmxNumScreens; /**< Number of dmxScreens */ -extern DMXScreenInfo *dmxScreens; /**< List of outputs */ -extern int dmxShadowFB; /**< Non-zero if using - * shadow frame-buffer - * (deprecated) */ -extern XErrorEvent dmxLastErrorEvent; /**< Last error that - * occurred */ -extern Bool dmxErrorOccurred; /**< True if an error - * occurred */ -extern Bool dmxOffScreenOpt; /**< True if using off - * screen - * optimizations */ -extern Bool dmxSubdividePrimitives; /**< True if using the - * primitive subdivision - * optimization */ -extern Bool dmxLazyWindowCreation; /**< True if using the - * lazy window creation - * optimization */ -extern Bool dmxUseXKB; /**< True if the XKB - * extension should be - * used with the backend - * servers */ -extern int dmxDepth; /**< Requested depth if - * non-zero */ -#ifdef GLXEXT -extern Bool dmxGLXProxy; /**< True if glxProxy - * support is enabled */ -extern Bool dmxGLXSwapGroupSupport; /**< True if glxProxy - * support for swap - * groups and barriers - * is enabled */ -extern Bool dmxGLXSyncSwap; /**< True if glxProxy - * should force an XSync - * request after each - * swap buffers call */ -extern Bool dmxGLXFinishSwap; /**< True if glxProxy - * should force a - * glFinish request - * after each swap - * buffers call */ -#endif -extern char *dmxFontPath; /**< NULL if no font - * path is set on the - * command line; - * otherwise, a string - * of comma separated - * paths built from the - * command line - * specified font - * paths */ -extern Bool dmxIgnoreBadFontPaths; /**< True if bad font - * paths should be - * ignored during server - * init */ -extern Bool dmxAddRemoveScreens; /**< True if add and - * remove screens support - * is enabled */ - -/** Wrap screen or GC function pointer */ -#define DMX_WRAP(_entry, _newfunc, _saved, _actual) \ -do { \ - (_saved)->_entry = (_actual)->_entry; \ - (_actual)->_entry = (_newfunc); \ -} while (0) - -/** Unwrap screen or GC function pointer */ -#define DMX_UNWRAP(_entry, _saved, _actual) \ -do { \ - (_actual)->_entry = (_saved)->_entry; \ -} while (0) - -/* Define the MAXSCREENSALLOC/FREE macros, when MAXSCREENS patch has not - * been applied to sources. */ -#ifdef MAXSCREENS -#define MAXSCREEN_MAKECONSTSTR1(x) #x -#define MAXSCREEN_MAKECONSTSTR2(x) MAXSCREEN_MAKECONSTSTR1(x) - -#define MAXSCREEN_FAILED_TXT "Failed at [" \ - MAXSCREEN_MAKECONSTSTR2(__LINE__) ":" __FILE__ "] to allocate object: " - -#define _MAXSCREENSALLOCF(o,size,fatal) \ - do { \ - if (!o) { \ - o = calloc((size), sizeof(*(o))); \ - if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \ - } \ - } while (0) -#define _MAXSCREENSALLOCR(o,size,retval) \ - do { \ - if (!o) { \ - o = calloc((size), sizeof(*(o))); \ - if (!o) return retval; \ - } \ - } while (0) - -#define MAXSCREENSFREE(o) \ - do { \ - if (o) free(o); \ - o = NULL; \ - } while (0) - -#define MAXSCREENSALLOC(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 0) -#define MAXSCREENSALLOC_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 1) -#define MAXSCREENSALLOC_RETURN(o,r) _MAXSCREENSALLOCR(o,MAXSCREENS, (r)) -#define MAXSCREENSALLOCPLUSONE(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,0) -#define MAXSCREENSALLOCPLUSONE_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,1) -#define MAXSCREENSCALLOC(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),0) -#define MAXSCREENSCALLOC_FATAL(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),1) -#endif - -#endif /* DMX_H */ +/*
+ * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * David H. Dawes <dawes@xfree86.org>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Main header file included by all other DMX-related files.
+ */
+
+/** \mainpage
+ * - <a href="http://dmx.sourceforge.net">DMX Home Page</a>
+ * - <a href="http://sourceforge.net/projects/dmx">DMX Project Page (on
+ * Source Forge)</a>
+ * - <a href="http://dmx.sourceforge.net/dmx.html">Distributed Multihead
+ * X design</a>, the design document for DMX
+ * - <a href="http://dmx.sourceforge.net/DMXSpec.txt">Client-to-Server
+ * DMX Extension to the X Protocol</a>
+ */
+
+#ifndef DMX_H
+#define DMX_H
+
+#if HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "gcstruct.h"
+
+/* Handle client-side include files in one place. */
+#include "dmxclient.h"
+
+#include "globals.h"
+#include "scrnintstr.h"
+
+#include "picturestr.h"
+
+#ifdef GLXEXT
+#include <GL/glx.h>
+#include <GL/glxint.h>
+#endif
+
+typedef enum {
+ PosNone = -1,
+ PosAbsolute = 0,
+ PosRightOf,
+ PosLeftOf,
+ PosAbove,
+ PosBelow,
+ PosRelative
+} PositionType;
+
+/** Provide the typedef globally, but keep the contents opaque outside
+ * of the input routines. \see dmxinput.h */
+typedef struct _DMXInputInfo DMXInputInfo;
+
+/** Provide the typedef globally, but keep the contents opaque outside
+ * of the XSync statistic routines. \see dmxstat.c */
+typedef struct _DMXStatInfo DMXStatInfo;
+
+/** Global structure containing information about each backend screen. */
+typedef struct _DMXScreenInfo {
+ const char *name; /**< Name from command line or config file */
+ int index; /**< Index into dmxScreens global */
+
+ /*---------- Back-end X server information ----------*/
+
+ Display *beDisplay; /**< Back-end X server's display */
+ int beWidth; /**< Width of BE display */
+ int beHeight; /**< Height of BE display */
+ int beDepth; /**< Depth of BE display */
+ int beBPP; /**< Bits per pixel of BE display */
+ int beXDPI; /**< Horizontal dots per inch of BE */
+ int beYDPI; /**< Vertical dots per inch of BE */
+
+ int beNumDepths; /**< Number of depths on BE server */
+ int *beDepths; /**< Depths from BE server */
+
+ int beNumPixmapFormats; /**< Number of pixmap formats on BE */
+ XPixmapFormatValues *bePixmapFormats; /**< Pixmap formats on BE */
+
+ int beNumVisuals; /**< Number of visuals on BE */
+ XVisualInfo *beVisuals; /**< Visuals from BE server */
+ int beDefVisualIndex; /**< Default visual index of BE */
+
+ int beNumDefColormaps; /**< Number of default colormaps */
+ Colormap *beDefColormaps; /**< Default colormaps for DMX server */
+
+ Pixel beBlackPixel; /**< Default black pixel for BE */
+ Pixel beWhitePixel; /**< Default white pixel for BE */
+
+ /*---------- Screen window information ----------*/
+
+ Window scrnWin; /**< "Screen" window on backend display */
+ int scrnX; /**< X offset of "screen" WRT BE display */
+ int scrnY; /**< Y offset of "screen" WRT BE display */
+ int scrnWidth; /**< Width of "screen" */
+ int scrnHeight; /**< Height of "screen" */
+ int scrnXSign; /**< X offset sign of "screen" */
+ int scrnYSign; /**< Y offset sign of "screen" */
+
+ /** Default drawables for "screen" */
+ Drawable scrnDefDrawables[MAXFORMATS];
+
+ struct _DMXScreenInfo *next; /**< List of "screens" on same display */
+ struct _DMXScreenInfo *over; /**< List of "screens" that overlap */
+
+ /*---------- Root window information ----------*/
+
+ Window rootWin; /**< "Root" window on backend display */
+ int rootX; /**< X offset of "root" window WRT "screen"*/
+ int rootY; /**< Y offset of "root" window WRT "screen"*/
+ int rootWidth; /**< Width of "root" window */
+ int rootHeight; /**< Height of "root" window */
+
+ int rootXOrigin; /**< Global X origin of "root" window */
+ int rootYOrigin; /**< Global Y origin of "root" window */
+
+ /*---------- Shadow framebuffer information ----------*/
+
+ void *shadow; /**< Shadow framebuffer data (if enabled) */
+ XlibGC shadowGC; /**< Default GC used by shadow FB code */
+ XImage *shadowFBImage; /**< Screen image used by shadow FB code */
+
+ /*---------- Other related information ----------*/
+
+ int shared; /**< Non-zero if another Xdmx is running */
+
+ Bool WMRunningOnBE;
+
+ Cursor noCursor;
+ Cursor curCursor;
+ /* Support for cursors on overlapped
+ * backend displays. */
+ CursorPtr cursor;
+ int cursorVisible;
+ int cursorNotShared; /* for overlapping screens on a backend */
+
+ PositionType where; /**< Relative layout information */
+ int whereX; /**< Relative layout information */
+ int whereY; /**< Relative layout information */
+ int whereRefScreen; /**< Relative layout information */
+
+ int savedTimeout; /**< Original screen saver timeout */
+ int dpmsCapable; /**< Non-zero if backend is DPMS capable */
+ int dpmsEnabled; /**< Non-zero if DPMS enabled */
+ int dpmsStandby; /**< Original DPMS standby value */
+ int dpmsSuspend; /**< Original DPMS suspend value */
+ int dpmsOff; /**< Original DPMS off value */
+
+ DMXStatInfo *stat; /**< Statistics about XSync */
+ Bool needsSync; /**< True if an XSync is pending */
+
+#ifdef GLXEXT
+ /** Visual information for glxProxy */
+ int numGlxVisuals;
+ __GLXvisualConfig *glxVisuals;
+ int glxMajorOpcode;
+ int glxErrorBase;
+
+ /** FB config information for glxProxy */
+ __GLXFBConfig *fbconfigs;
+ int numFBConfigs;
+#endif
+
+ /** Function pointers to wrapped screen
+ * functions */
+ CloseScreenProcPtr CloseScreen;
+ SaveScreenProcPtr SaveScreen;
+
+ CreateGCProcPtr CreateGC;
+
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ PositionWindowProcPtr PositionWindow;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ RestackWindowProcPtr RestackWindow;
+ WindowExposuresProcPtr WindowExposures;
+ CopyWindowProcPtr CopyWindow;
+
+ ResizeWindowProcPtr ResizeWindow;
+ ReparentWindowProcPtr ReparentWindow;
+
+ ChangeBorderWidthProcPtr ChangeBorderWidth;
+
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+
+ CreatePixmapProcPtr CreatePixmap;
+ DestroyPixmapProcPtr DestroyPixmap;
+ BitmapToRegionProcPtr BitmapToRegion;
+
+ RealizeFontProcPtr RealizeFont;
+ UnrealizeFontProcPtr UnrealizeFont;
+
+ CreateColormapProcPtr CreateColormap;
+ DestroyColormapProcPtr DestroyColormap;
+ InstallColormapProcPtr InstallColormap;
+ StoreColorsProcPtr StoreColors;
+
+ SetShapeProcPtr SetShape;
+
+ CreatePictureProcPtr CreatePicture;
+ DestroyPictureProcPtr DestroyPicture;
+ ChangePictureClipProcPtr ChangePictureClip;
+ DestroyPictureClipProcPtr DestroyPictureClip;
+
+ ChangePictureProcPtr ChangePicture;
+ ValidatePictureProcPtr ValidatePicture;
+
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+ CompositeRectsProcPtr CompositeRects;
+
+ InitIndexedProcPtr InitIndexed;
+ CloseIndexedProcPtr CloseIndexed;
+ UpdateIndexedProcPtr UpdateIndexed;
+
+ TrapezoidsProcPtr Trapezoids;
+ TrianglesProcPtr Triangles;
+ TriStripProcPtr TriStrip;
+ TriFanProcPtr TriFan;
+} DMXScreenInfo;
+
+/* Global variables available to all Xserver/hw/dmx routines. */
+extern int dmxNumScreens; /**< Number of dmxScreens */
+extern DMXScreenInfo *dmxScreens; /**< List of outputs */
+extern int dmxShadowFB; /**< Non-zero if using
+ * shadow frame-buffer
+ * (deprecated) */
+extern XErrorEvent dmxLastErrorEvent; /**< Last error that
+ * occurred */
+extern Bool dmxErrorOccurred; /**< True if an error
+ * occurred */
+extern Bool dmxOffScreenOpt; /**< True if using off
+ * screen
+ * optimizations */
+extern Bool dmxSubdividePrimitives; /**< True if using the
+ * primitive subdivision
+ * optimization */
+extern Bool dmxLazyWindowCreation; /**< True if using the
+ * lazy window creation
+ * optimization */
+extern Bool dmxUseXKB; /**< True if the XKB
+ * extension should be
+ * used with the backend
+ * servers */
+extern int dmxDepth; /**< Requested depth if
+ * non-zero */
+#ifdef GLXEXT
+extern Bool dmxGLXProxy; /**< True if glxProxy
+ * support is enabled */
+extern Bool dmxGLXSwapGroupSupport; /**< True if glxProxy
+ * support for swap
+ * groups and barriers
+ * is enabled */
+extern Bool dmxGLXSyncSwap; /**< True if glxProxy
+ * should force an XSync
+ * request after each
+ * swap buffers call */
+extern Bool dmxGLXFinishSwap; /**< True if glxProxy
+ * should force a
+ * glFinish request
+ * after each swap
+ * buffers call */
+#endif
+extern char *dmxFontPath; /**< NULL if no font
+ * path is set on the
+ * command line;
+ * otherwise, a string
+ * of comma separated
+ * paths built from the
+ * command line
+ * specified font
+ * paths */
+extern Bool dmxIgnoreBadFontPaths; /**< True if bad font
+ * paths should be
+ * ignored during server
+ * init */
+extern Bool dmxAddRemoveScreens; /**< True if add and
+ * remove screens support
+ * is enabled */
+
+/** Wrap screen or GC function pointer */
+#define DMX_WRAP(_entry, _newfunc, _saved, _actual) \
+do { \
+ (_saved)->_entry = (_actual)->_entry; \
+ (_actual)->_entry = (_newfunc); \
+} while (0)
+
+/** Unwrap screen or GC function pointer */
+#define DMX_UNWRAP(_entry, _saved, _actual) \
+do { \
+ (_actual)->_entry = (_saved)->_entry; \
+} while (0)
+
+/* Define the MAXSCREENSALLOC/FREE macros, when MAXSCREENS patch has not
+ * been applied to sources. */
+#ifdef MAXSCREENS
+#define MAXSCREEN_MAKECONSTSTR1(x) #x
+#define MAXSCREEN_MAKECONSTSTR2(x) MAXSCREEN_MAKECONSTSTR1(x)
+
+#define MAXSCREEN_FAILED_TXT "Failed at [" \
+ MAXSCREEN_MAKECONSTSTR2(__LINE__) ":" __FILE__ "] to allocate object: "
+
+#define _MAXSCREENSALLOCF(o,size,fatal) \
+ do { \
+ if (!o) { \
+ o = calloc((size), sizeof(*(o))); \
+ if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \
+ } \
+ } while (0)
+#define _MAXSCREENSALLOCR(o,size,retval) \
+ do { \
+ if (!o) { \
+ o = calloc((size), sizeof(*(o))); \
+ if (!o) return retval; \
+ } \
+ } while (0)
+
+#define MAXSCREENSFREE(o) \
+ do { \
+ free(o); \
+ o = NULL; \
+ } while (0)
+
+#define MAXSCREENSALLOC(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 0)
+#define MAXSCREENSALLOC_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 1)
+#define MAXSCREENSALLOC_RETURN(o,r) _MAXSCREENSALLOCR(o,MAXSCREENS, (r))
+#define MAXSCREENSALLOCPLUSONE(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,0)
+#define MAXSCREENSALLOCPLUSONE_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,1)
+#define MAXSCREENSCALLOC(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),0)
+#define MAXSCREENSCALLOC_FATAL(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),1)
+#endif
+
+extern DevPrivateKeyRec dmxGCPrivateKeyRec;
+#define dmxGCPrivateKey (&dmxGCPrivateKeyRec) /**< Private index for GCs */
+
+extern DevPrivateKeyRec dmxWinPrivateKeyRec;
+#define dmxWinPrivateKey (&dmxWinPrivateKeyRec) /**< Private index for Windows */
+
+extern DevPrivateKeyRec dmxPixPrivateKeyRec;
+#define dmxPixPrivateKey (&dmxPixPrivateKeyRec) /**< Private index for Pixmaps */
+
+extern int dmxFontPrivateIndex; /**< Private index for Fonts */
+
+extern DevPrivateKeyRec dmxScreenPrivateKeyRec;
+#define dmxScreenPrivateKey (&dmxScreenPrivateKeyRec) /**< Private index for Screens */
+
+extern DevPrivateKeyRec dmxColormapPrivateKeyRec;
+#define dmxColormapPrivateKey (&dmxColormapPrivateKeyRec) /**< Private index for Colormaps */
+
+extern DevPrivateKeyRec dmxPictPrivateKeyRec;
+#define dmxPictPrivateKey (&dmxPictPrivateKeyRec) /**< Private index for Picts */
+
+extern DevPrivateKeyRec dmxGlyphSetPrivateKeyRec;
+#define dmxGlyphSetPrivateKey (&dmxGlyphSetPrivateKeyRec) /**< Private index for GlyphSets */
+
+#endif /* DMX_H */
diff --git a/xorg-server/hw/dmx/dmx_glxvisuals.c b/xorg-server/hw/dmx/dmx_glxvisuals.c index 50a23e30f..dd77bd23a 100644 --- a/xorg-server/hw/dmx/dmx_glxvisuals.c +++ b/xorg-server/hw/dmx/dmx_glxvisuals.c @@ -51,7 +51,7 @@ __GLXvisualConfig *GetGLXVisualConfigs(Display *dpy, int screen, int *nconfigs) int num_good_visuals;
if (!XQueryExtension(dpy, "GLX", &majorOpcode, &dummy, &dummy)) {
- return(NULL);
+ return NULL;
}
/* Send the glXGetVisualConfigs request */
@@ -228,7 +228,7 @@ __GLXvisualConfig *GetGLXVisualConfigs(Display *dpy, int screen, int *nconfigs) SyncHandle();
*nconfigs = nvisuals;
- return( configs );
+ return configs;
}
@@ -500,7 +500,7 @@ GetGLXVisualConfigsFromFBConfigs(__GLXFBConfig *fbconfigs, int nfbconfigs, __GLXvisualConfig *configs = NULL;
int i;
- if (!fbconfigs || !nfbconfigs || !nconfigs) return(NULL);
+ if (!fbconfigs || !nfbconfigs || !nconfigs) return NULL;
*nconfigs = 0;
/* Allocate memory for our config structure */
@@ -596,6 +596,6 @@ GetGLXVisualConfigsFromFBConfigs(__GLXFBConfig *fbconfigs, int nfbconfigs, }
}
- return( configs );
+ return configs;
}
diff --git a/xorg-server/hw/dmx/dmxcmap.c b/xorg-server/hw/dmx/dmxcmap.c index 5a56afda2..1cdc481f0 100644 --- a/xorg-server/hw/dmx/dmxcmap.c +++ b/xorg-server/hw/dmx/dmxcmap.c @@ -75,7 +75,7 @@ Bool dmxBECreateColormap(ColormapPtr pColormap) visual,
(pVisual->class & DynamicClass ?
AllocAll : AllocNone));
- return (pCmapPriv->cmap != 0);
+ return pCmapPriv->cmap != 0;
}
else {
dmxLog(dmxWarning, "dmxBECreateColormap: No visual found\n");
diff --git a/xorg-server/hw/dmx/dmxcmap.h b/xorg-server/hw/dmx/dmxcmap.h index f968f8622..499ca7f66 100644 --- a/xorg-server/hw/dmx/dmxcmap.h +++ b/xorg-server/hw/dmx/dmxcmap.h @@ -1,69 +1,66 @@ -/* - * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Kevin E. Martin <kem@redhat.com> - * - */ - -/** \file - * Header file for colormap support. \see dmxcmap.c. */ - -#ifndef DMXCMAP_H -#define DMXCMAP_H - -#include "colormapst.h" - -/** Colormap private area. */ -typedef struct _dmxColormapPriv { - Colormap cmap; -} dmxColormapPrivRec, *dmxColormapPrivPtr; - - -extern Bool dmxCreateColormap(ColormapPtr pColormap); -extern void dmxDestroyColormap(ColormapPtr pColormap); -extern void dmxInstallColormap(ColormapPtr pColormap); -extern void dmxStoreColors(ColormapPtr pColormap, int ndef, xColorItem *pdef); - -extern Bool dmxCreateDefColormap(ScreenPtr pScreen); - -extern Bool dmxBECreateColormap(ColormapPtr pColormap); -extern Bool dmxBEFreeColormap(ColormapPtr pColormap); - -/** Private index. \see dmxcmap.c \see dmxscrinit.c \see dmxwindow.c */ -extern DevPrivateKey dmxColormapPrivateKey; - -/** Set colormap private structure. */ -#define DMX_SET_COLORMAP_PRIV(_pCMap, _pCMapPriv) \ - dixSetPrivate(&(_pCMap)->devPrivates, dmxColormapPrivateKey, _pCMapPriv) - -/** Get colormap private structure. */ -#define DMX_GET_COLORMAP_PRIV(_pCMap) (dmxColormapPrivPtr) \ - dixLookupPrivate(&(_pCMap)->devPrivates, dmxColormapPrivateKey) - -#endif /* DMXCMAP_H */ +/*
+ * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Header file for colormap support. \see dmxcmap.c. */
+
+#ifndef DMXCMAP_H
+#define DMXCMAP_H
+
+#include "colormapst.h"
+
+/** Colormap private area. */
+typedef struct _dmxColormapPriv {
+ Colormap cmap;
+} dmxColormapPrivRec, *dmxColormapPrivPtr;
+
+
+extern Bool dmxCreateColormap(ColormapPtr pColormap);
+extern void dmxDestroyColormap(ColormapPtr pColormap);
+extern void dmxInstallColormap(ColormapPtr pColormap);
+extern void dmxStoreColors(ColormapPtr pColormap, int ndef, xColorItem *pdef);
+
+extern Bool dmxCreateDefColormap(ScreenPtr pScreen);
+
+extern Bool dmxBECreateColormap(ColormapPtr pColormap);
+extern Bool dmxBEFreeColormap(ColormapPtr pColormap);
+
+/** Set colormap private structure. */
+#define DMX_SET_COLORMAP_PRIV(_pCMap, _pCMapPriv) \
+ dixSetPrivate(&(_pCMap)->devPrivates, dmxColormapPrivateKey, _pCMapPriv)
+
+/** Get colormap private structure. */
+#define DMX_GET_COLORMAP_PRIV(_pCMap) (dmxColormapPrivPtr) \
+ dixLookupPrivate(&(_pCMap)->devPrivates, dmxColormapPrivateKey)
+
+#endif /* DMXCMAP_H */
diff --git a/xorg-server/hw/dmx/dmxcursor.c b/xorg-server/hw/dmx/dmxcursor.c index 2d0243343..19f5a4139 100644 --- a/xorg-server/hw/dmx/dmxcursor.c +++ b/xorg-server/hw/dmx/dmxcursor.c @@ -230,7 +230,7 @@ static int dmxSLFindNext(int *list) /** Make one pass over all the screens and return the number updated. */
static int dmxTryComputeScreenOrigins(int *screensLeft)
{
- ScreenPtr pScreen;
+ ScreenPtr pScreen, refScreen;
DMXScreenInfo *screen;
int i, ref;
int changed = 0;
@@ -239,54 +239,56 @@ static int dmxTryComputeScreenOrigins(int *screensLeft) if (!screensLeft[i])
continue;
screen = &dmxScreens[i];
+ pScreen = screenInfo.screens[i];
switch (screen->where) {
case PosAbsolute:
- dixScreenOrigins[i].x = screen->whereX;
- dixScreenOrigins[i].y = screen->whereY;
+ pScreen->x = screen->whereX;
+ pScreen->y = screen->whereY;
++changed, screensLeft[i] = 0;
break;
case PosRelative:
ref = screen->whereRefScreen;
if (screensLeft[ref])
break;
- dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->whereX;
- dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->whereY;
+ refScreen = screenInfo.screens[ref];
+ pScreen->x = refScreen->x + screen->whereX;
+ pScreen->y = refScreen->y + screen->whereY;
++changed, screensLeft[i] = 0;
break;
case PosRightOf:
ref = screen->whereRefScreen;
if (screensLeft[ref])
break;
- pScreen = screenInfo.screens[ref];
- dixScreenOrigins[i].x = dixScreenOrigins[ref].x + pScreen->width;
- dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ refScreen = screenInfo.screens[ref];
+ pScreen->x = refScreen->x + refScreen->width;
+ pScreen->y = refScreen->y;
++changed, screensLeft[i] = 0;
break;
case PosLeftOf:
ref = screen->whereRefScreen;
if (screensLeft[ref])
break;
- pScreen = screenInfo.screens[i];
- dixScreenOrigins[i].x = dixScreenOrigins[ref].x - pScreen->width;
- dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ refScreen = screenInfo.screens[ref];
+ pScreen->x = refScreen->x - pScreen->width;
+ pScreen->y = refScreen->y;
++changed, screensLeft[i] = 0;
break;
case PosBelow:
ref = screen->whereRefScreen;
if (screensLeft[ref])
break;
- pScreen = screenInfo.screens[ref];
- dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
- dixScreenOrigins[i].y = dixScreenOrigins[ref].y + pScreen->height;
+ refScreen = screenInfo.screens[ref];
+ pScreen->x = refScreen->x;
+ pScreen->y = refScreen->y + refScreen->height;
++changed, screensLeft[i] = 0;
break;
case PosAbove:
ref = screen->whereRefScreen;
if (screensLeft[ref])
break;
- pScreen = screenInfo.screens[i];
- dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
- dixScreenOrigins[i].y = dixScreenOrigins[ref].y - pScreen->height;
+ refScreen = screenInfo.screens[ref];
+ pScreen->x = refScreen->x;
+ pScreen->y = refScreen->y - pScreen->height;
++changed, screensLeft[i] = 0;
break;
case PosNone:
@@ -298,6 +300,7 @@ static int dmxTryComputeScreenOrigins(int *screensLeft) static void dmxComputeScreenOrigins(void)
{
+ ScreenPtr pScreen;
int *screensLeft;
int i, ref;
int minX, minY;
@@ -313,8 +316,9 @@ static void dmxComputeScreenOrigins(void) * guarantees that we will eventually terminate.
*/
ref = dmxScreens[i].whereRefScreen;
- dixScreenOrigins[ref].x = dixScreenOrigins[ref].y = 0;
- screensLeft[ref] = 0;
+ pScreen = screenInfo.screens[ref];
+ pScreen->x = pScreen->y = 0;
+ screensLeft[ref] = 0;
}
}
dmxSLFree(screensLeft);
@@ -322,18 +326,18 @@ static void dmxComputeScreenOrigins(void) /* Justify the topmost and leftmost to
* (0,0). */
- minX = dixScreenOrigins[0].x;
- minY = dixScreenOrigins[0].y;
+ minX = screenInfo.screens[0]->x;
+ minY = screenInfo.screens[0]->y;
for (i = 1; i < dmxNumScreens; i++) { /* Compute minX, minY */
- if (dixScreenOrigins[i].x < minX)
- minX = dixScreenOrigins[i].x;
- if (dixScreenOrigins[i].y < minY)
- minY = dixScreenOrigins[i].y;
+ if (screenInfo.screens[i]->x < minX)
+ minX = screenInfo.screens[i]->x;
+ if (screenInfo.screens[i]->y < minY)
+ minY = screenInfo.screens[i]->y;
}
if (minX || minY) {
for (i = 0; i < dmxNumScreens; i++) {
- dixScreenOrigins[i].x -= minX;
- dixScreenOrigins[i].y -= minY;
+ screenInfo.screens[i]->x -= minX;
+ screenInfo.screens[i]->y -= minY;
}
}
}
@@ -398,8 +402,8 @@ void dmxInitOrigins(void) for (i = 0; i < dmxNumScreens; i++) {
DMXScreenInfo *dmxScreen = &dmxScreens[i];
- dmxScreen->rootXOrigin = dixScreenOrigins[i].x;
- dmxScreen->rootYOrigin = dixScreenOrigins[i].y;
+ dmxScreen->rootXOrigin = screenInfo.screens[i]->x;
+ dmxScreen->rootYOrigin = screenInfo.screens[i]->y;
}
dmxReInitOrigins();
diff --git a/xorg-server/hw/dmx/dmxextension.c b/xorg-server/hw/dmx/dmxextension.c index c8e8dae65..25a10c015 100644 --- a/xorg-server/hw/dmx/dmxextension.c +++ b/xorg-server/hw/dmx/dmxextension.c @@ -1,1616 +1,1616 @@ -/* - * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Author: - * Rickard E. (Rik) Faith <faith@redhat.com> - * Kevin E. Martin <kem@redhat.com> - * - */ - -/** \file - * This file provides the only interface to the X server extension support - * in programs/Xserver/Xext. Those programs should only include dmxext.h - */ - -#ifdef HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#include <stdlib.h> - -#include "dmx.h" -#include "dmxinit.h" -#include "dmxextension.h" -#include "dmxwindow.h" -#include "dmxcb.h" -#include "dmxcursor.h" -#include "dmxpixmap.h" -#include "dmxgc.h" -#include "dmxfont.h" -#include "dmxcmap.h" -#include "dmxpict.h" -#include "dmxinput.h" -#include "dmxsync.h" -#include "dmxscrinit.h" -#include "input/dmxinputinit.h" - -#include "windowstr.h" -#include "inputstr.h" /* For DeviceIntRec */ -#include <X11/extensions/dmxproto.h> /* For DMX_BAD_* */ -#include "cursorstr.h" - -/* The default font is declared in dix/globals.c, but is not included in - * _any_ header files. */ -extern FontPtr defaultFont; - -/** This routine provides information to the DMX protocol extension - * about a particular screen. */ -Bool dmxGetScreenAttributes(int physical, DMXScreenAttributesPtr attr) -{ - DMXScreenInfo *dmxScreen; - - if (physical < 0 || physical >= dmxNumScreens) return FALSE; - - dmxScreen = &dmxScreens[physical]; - attr->displayName = dmxScreen->name; -#ifdef PANORAMIX - attr->logicalScreen = noPanoramiXExtension ? dmxScreen->index : 0; -#else - attr->logicalScreen = dmxScreen->index; -#endif - - attr->screenWindowWidth = dmxScreen->scrnWidth; - attr->screenWindowHeight = dmxScreen->scrnHeight; - attr->screenWindowXoffset = dmxScreen->scrnX; - attr->screenWindowYoffset = dmxScreen->scrnY; - - attr->rootWindowWidth = dmxScreen->rootWidth; - attr->rootWindowHeight = dmxScreen->rootHeight; - attr->rootWindowXoffset = dmxScreen->rootX; - attr->rootWindowYoffset = dmxScreen->rootY; - - attr->rootWindowXorigin = dmxScreen->rootXOrigin; - attr->rootWindowYorigin = dmxScreen->rootYOrigin; - - return TRUE; -} - -/** This routine provides information to the DMX protocol extension - * about a particular window. */ -Bool dmxGetWindowAttributes(WindowPtr pWindow, DMXWindowAttributesPtr attr) -{ - dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow); - - attr->screen = pWindow->drawable.pScreen->myNum; - attr->window = pWinPriv->window; - - attr->pos.x = pWindow->drawable.x; - attr->pos.y = pWindow->drawable.y; - attr->pos.width = pWindow->drawable.width; - attr->pos.height = pWindow->drawable.height; - - if (!pWinPriv->window || pWinPriv->offscreen) { - attr->vis.x = 0; - attr->vis.y = 0; - attr->vis.height = 0; - attr->vis.width = 0; - return pWinPriv->window ? TRUE : FALSE; - } - - /* Compute display-relative coordinates */ - attr->vis.x = pWindow->drawable.x; - attr->vis.y = pWindow->drawable.y; - attr->vis.width = pWindow->drawable.width; - attr->vis.height = pWindow->drawable.height; - - if (attr->pos.x < 0) { - attr->vis.x -= attr->pos.x; - attr->vis.width = attr->pos.x + attr->pos.width - attr->vis.x; - } - if (attr->pos.x + attr->pos.width > pWindow->drawable.pScreen->width) { - if (attr->pos.x < 0) - attr->vis.width = pWindow->drawable.pScreen->width; - else - attr->vis.width = pWindow->drawable.pScreen->width - attr->pos.x; - } - if (attr->pos.y < 0) { - attr->vis.y -= attr->pos.y; - attr->vis.height = attr->pos.y + attr->pos.height - attr->vis.y; - } - if (attr->pos.y + attr->pos.height > pWindow->drawable.pScreen->height) { - if (attr->pos.y < 0) - attr->vis.height = pWindow->drawable.pScreen->height; - else - attr->vis.height = pWindow->drawable.pScreen->height - attr->pos.y; - } - - /* Convert to window-relative coordinates */ - attr->vis.x -= attr->pos.x; - attr->vis.y -= attr->pos.y; - - return TRUE; -} - -void dmxGetDesktopAttributes(DMXDesktopAttributesPtr attr) -{ - attr->width = dmxGlobalWidth; - attr->height = dmxGlobalHeight; - attr->shiftX = 0; /* NOTE: The upper left hand corner of */ - attr->shiftY = 0; /* the desktop is always <0,0>. */ -} - -/** Return the total number of devices, not just #dmxNumInputs. The - * number returned should be the same as that returned by - * XListInputDevices. */ -int dmxGetInputCount(void) -{ - int i, total; - - for (total = i = 0; i < dmxNumInputs; i++) total += dmxInputs[i].numDevs; - return total; -} - -/** Return information about the device with id = \a deviceId. This - * information is primarily for the #ProcDMXGetInputAttributes() - * function, which does not have access to the appropriate data - * structure. */ -int dmxGetInputAttributes(int deviceId, DMXInputAttributesPtr attr) -{ - int i, j; - DMXInputInfo *dmxInput; - - if (deviceId < 0) return -1; - for (i = 0; i < dmxNumInputs; i++) { - dmxInput = &dmxInputs[i]; - for (j = 0; j < dmxInput->numDevs; j++) { - DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j]; - if (deviceId != dmxLocal->pDevice->id) continue; - attr->isCore = !!dmxLocal->isCore; - attr->sendsCore = !!dmxLocal->sendsCore; - attr->detached = !!dmxInput->detached; - attr->physicalScreen = -1; - attr->physicalId = -1; - attr->name = NULL; - switch (dmxLocal->extType) { - case DMX_LOCAL_TYPE_LOCAL: - attr->inputType = 0; - break; - case DMX_LOCAL_TYPE_CONSOLE: - attr->inputType = 1; - attr->name = dmxInput->name; - attr->physicalId = dmxLocal->deviceId; - break; - case DMX_LOCAL_TYPE_BACKEND: - case DMX_LOCAL_TYPE_COMMON: - attr->inputType = 2; - attr->physicalScreen = dmxInput->scrnIdx; - attr->name = dmxInput->name; - attr->physicalId = dmxLocal->deviceId; - break; - } - return 0; /* Success */ - } - } - return -1; /* Failure */ -} - -/** Reinitialized the cursor boundaries. */ -static void dmxAdjustCursorBoundaries(void) -{ - int i; - - dmxReInitOrigins(); - dmxInitOverlap(); - dmxComputeWidthHeight(DMX_NO_RECOMPUTE_BOUNDING_BOX); - dmxConnectionBlockCallback(); - for (i = 0; i < dmxNumInputs; i++) { - DMXInputInfo *dmxInput = &dmxInputs[i]; - if (!dmxInput->detached) dmxInputReInit(dmxInput); - } - - dmxCheckCursor(); - - for (i = 0; i < dmxNumInputs; i++) { - DMXInputInfo *dmxInput = &dmxInputs[i]; - if (!dmxInput->detached) dmxInputLateReInit(dmxInput); - } -} - -/** Add an input with the specified attributes. If the input is added, - * the physical id is returned in \a deviceId. */ -int dmxAddInput(DMXInputAttributesPtr attr, int *id) -{ - int retcode = BadValue; - - if (attr->inputType == 1) /* console */ - retcode = dmxInputAttachConsole(attr->name, attr->sendsCore, id); - else if (attr->inputType == 2) /* backend */ - retcode = dmxInputAttachBackend(attr->physicalScreen, - attr->sendsCore,id); - - if (retcode == Success) { - /* Adjust the cursor boundaries */ - dmxAdjustCursorBoundaries(); - - /* Force completion of the changes */ - dmxSync(NULL, TRUE); - } - - return retcode; -} - -/** Remove the input with physical id \a id. */ -int dmxRemoveInput(int id) -{ - return dmxInputDetachId(id); -} - -/** Return the value of #dmxNumScreens -- the total number of backend - * screens in use (these are logical screens and may be larger than the - * number of backend displays). */ -unsigned long dmxGetNumScreens(void) -{ - return dmxNumScreens; -} - -/** Make sure that #dmxCreateAndRealizeWindow has been called for \a - * pWindow. */ -void dmxForceWindowCreation(WindowPtr pWindow) -{ - dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow); - if (!pWinPriv->window) dmxCreateAndRealizeWindow(pWindow, TRUE); -} - -/** Flush pending syncs for all screens. */ -void dmxFlushPendingSyncs(void) -{ - dmxSync(NULL, TRUE); -} - -/** Update DMX's screen resources to match those of the newly moved - * and/or resized "root" window. */ -void dmxUpdateScreenResources(ScreenPtr pScreen, int x, int y, int w, int h) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; - WindowPtr pRoot = WindowTable[pScreen->myNum]; - WindowPtr pChild; - Bool anyMarked = FALSE; - - /* Handle special case where width and/or height are zero */ - if (w == 0 || h == 0) { - w = 1; - h = 1; - } - - /* Change screen size */ - pScreen->width = w; - pScreen->height = h; - - /* Reset the root window's drawable's size */ - pRoot->drawable.width = w; - pRoot->drawable.height = h; - - /* Set the root window's new winSize and borderSize */ - pRoot->winSize.extents.x1 = 0; - pRoot->winSize.extents.y1 = 0; - pRoot->winSize.extents.x2 = w; - pRoot->winSize.extents.y2 = h; - - pRoot->borderSize.extents.x1 = 0; - pRoot->borderSize.extents.y1 = 0; - pRoot->borderSize.extents.x2 = w; - pRoot->borderSize.extents.y2 = h; - - /* Recompute this screen's mmWidth & mmHeight */ - pScreen->mmWidth = - (w * 254 + dmxScreen->beXDPI * 5) / (dmxScreen->beXDPI * 10); - pScreen->mmHeight = - (h * 254 + dmxScreen->beYDPI * 5) / (dmxScreen->beYDPI * 10); - - /* Recompute this screen's window's clip rects as follows: */ - /* 1. Mark all of root's children's windows */ - for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib) - anyMarked |= pScreen->MarkOverlappedWindows(pChild, pChild, - (WindowPtr *)NULL); - - /* 2. Set the root window's borderClip */ - pRoot->borderClip.extents.x1 = 0; - pRoot->borderClip.extents.y1 = 0; - pRoot->borderClip.extents.x2 = w; - pRoot->borderClip.extents.y2 = h; - - /* 3. Set the root window's clipList */ - if (anyMarked) { - /* If any windows have been marked, set the root window's - * clipList to be broken since it will be recalculated in - * ValidateTree() - */ - REGION_BREAK(pScreen, &pRoot->clipList); - } else { - /* Otherwise, we just set it directly since there are no - * windows visible on this screen - */ - pRoot->clipList.extents.x1 = 0; - pRoot->clipList.extents.y1 = 0; - pRoot->clipList.extents.x2 = w; - pRoot->clipList.extents.y2 = h; - } - - /* 4. Revalidate all clip rects and generate expose events */ - if (anyMarked) { - pScreen->ValidateTree(pRoot, NULL, VTBroken); - pScreen->HandleExposures(pRoot); - if (pScreen->PostValidateTree) - pScreen->PostValidateTree(pRoot, NULL, VTBroken); - } -} - -#ifdef PANORAMIX -#include "panoramiXsrv.h" - -/** Change the "screen" window attributes by resizing the actual window - * on the back-end display (if necessary). */ -static void dmxConfigureScreenWindow(int idx, - int x, int y, int w, int h) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[idx]; - ScreenPtr pScreen = screenInfo.screens[idx]; - - /* Resize "screen" window */ - if (dmxScreen->scrnX != x || - dmxScreen->scrnY != y || - dmxScreen->scrnWidth != w || - dmxScreen->scrnHeight != h) { - dmxResizeScreenWindow(pScreen, x, y, w, h); - } - - /* Change "screen" window values */ - dmxScreen->scrnX = x; - dmxScreen->scrnY = y; - dmxScreen->scrnWidth = w; - dmxScreen->scrnHeight = h; -} - -/** Change the "root" window position and size by resizing the actual - * window on the back-end display (if necessary) and updating all of - * DMX's resources by calling #dmxUpdateScreenResources. */ -static void dmxConfigureRootWindow(int idx, int x, int y, int w, int h) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[idx]; - WindowPtr pRoot = WindowTable[idx]; - - /* NOTE: Either this function or the ones that it calls must handle - * the case where w == 0 || h == 0. Currently, the functions that - * this one calls handle that case. */ - - /* 1. Resize "root" window */ - if (dmxScreen->rootX != x || - dmxScreen->rootY != y || - dmxScreen->rootWidth != w || - dmxScreen->rootHeight != h) { - dmxResizeRootWindow(pRoot, x, y, w, h); - } - - /* 2. Update all of the screen's resources associated with this root - * window */ - if (dmxScreen->rootWidth != w || - dmxScreen->rootHeight != h) { - dmxUpdateScreenResources(screenInfo.screens[idx], x, y, w, h); - } - - /* Change "root" window values */ - dmxScreen->rootX = x; - dmxScreen->rootY = y; - dmxScreen->rootWidth = w; - dmxScreen->rootHeight = h; -} - -/** Change the "root" window's origin by updating DMX's internal data - * structures (dix and Xinerama) to use the new origin and adjust the - * positions of windows that overlap this "root" window. */ -static void dmxSetRootWindowOrigin(int idx, int x, int y) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[idx]; - ScreenPtr pScreen = screenInfo.screens[idx]; - WindowPtr pRoot = WindowTable[idx]; - WindowPtr pChild; - int xoff; - int yoff; - - /* Change "root" window's origin */ - dmxScreen->rootXOrigin = x; - dmxScreen->rootYOrigin = y; - - /* Compute offsets here in case <x,y> has been changed above */ - xoff = x - dixScreenOrigins[idx].x; - yoff = y - dixScreenOrigins[idx].y; - - /* Adjust the root window's position in dixScreenOrigins */ - dixScreenOrigins[idx].x = dmxScreen->rootXOrigin; - dixScreenOrigins[idx].y = dmxScreen->rootYOrigin; - - /* Recalculate the Xinerama regions and data structs */ - XineramaReinitData(pScreen); - - /* Adjust each of the root window's children */ - if (!idx) ReinitializeRootWindow(WindowTable[0], xoff, yoff); - pChild = pRoot->firstChild; - while (pChild) { - /* Adjust child window's position */ - pScreen->MoveWindow(pChild, - pChild->origin.x - wBorderWidth(pChild) - xoff, - pChild->origin.y - wBorderWidth(pChild) - yoff, - pChild->nextSib, - VTMove); - - /* Note that the call to MoveWindow will eventually call - * dmxPositionWindow which will automatically create a - * window if it is now exposed on screen (for lazy window - * creation optimization) and it will properly set the - * offscreen flag. - */ - - pChild = pChild->nextSib; - } -} - -/** Configure the attributes of each "screen" and "root" window. */ -int dmxConfigureScreenWindows(int nscreens, - CARD32 *screens, - DMXScreenAttributesPtr attribs, - int *errorScreen) -{ - int i; - - for (i = 0; i < nscreens; i++) { - DMXScreenAttributesPtr attr = &attribs[i]; - int idx = screens[i]; - DMXScreenInfo *dmxScreen = &dmxScreens[idx]; - - if (errorScreen) *errorScreen = i; - - if (!dmxScreen->beDisplay) return DMX_BAD_VALUE; - - /* Check for illegal values */ - if (idx < 0 || idx >= dmxNumScreens) return BadValue; - - /* The "screen" and "root" windows must have valid sizes */ - if (attr->screenWindowWidth <= 0 || attr->screenWindowHeight <= 0 || - attr->rootWindowWidth < 0 || attr->rootWindowHeight < 0) - return DMX_BAD_VALUE; - - /* The "screen" window must fit entirely within the BE display */ - if (attr->screenWindowXoffset < 0 || - attr->screenWindowYoffset < 0 || - attr->screenWindowXoffset - + attr->screenWindowWidth > (unsigned)dmxScreen->beWidth || - attr->screenWindowYoffset - + attr->screenWindowHeight > (unsigned)dmxScreen->beHeight) - return DMX_BAD_VALUE; - - /* The "root" window must fit entirely within the "screen" window */ - if (attr->rootWindowXoffset < 0 || - attr->rootWindowYoffset < 0 || - attr->rootWindowXoffset - + attr->rootWindowWidth > attr->screenWindowWidth || - attr->rootWindowYoffset - + attr->rootWindowHeight > attr->screenWindowHeight) - return DMX_BAD_VALUE; - - /* The "root" window must not expose unaddressable coordinates */ - if (attr->rootWindowXorigin < 0 || - attr->rootWindowYorigin < 0 || - attr->rootWindowXorigin + attr->rootWindowWidth > 32767 || - attr->rootWindowYorigin + attr->rootWindowHeight > 32767) - return DMX_BAD_VALUE; - - /* The "root" window must fit within the global bounding box */ - if (attr->rootWindowXorigin - + attr->rootWindowWidth > (unsigned)dmxGlobalWidth || - attr->rootWindowYorigin - + attr->rootWindowHeight > (unsigned)dmxGlobalHeight) - return DMX_BAD_VALUE; - - /* FIXME: Handle the rest of the illegal value checking */ - } - - /* No illegal values found */ - if (errorScreen) *errorScreen = 0; - - for (i = 0; i < nscreens; i++) { - DMXScreenAttributesPtr attr = &attribs[i]; - int idx = screens[i]; - DMXScreenInfo *dmxScreen = &dmxScreens[idx]; - - dmxLog(dmxInfo, "Changing screen #%d attributes " - "from %dx%d+%d+%d %dx%d+%d+%d +%d+%d " - "to %dx%d+%d+%d %dx%d+%d+%d +%d+%d\n", - idx, - dmxScreen->scrnWidth, dmxScreen->scrnHeight, - dmxScreen->scrnX, dmxScreen->scrnY, - dmxScreen->rootWidth, dmxScreen->rootHeight, - dmxScreen->rootX, dmxScreen->rootY, - dmxScreen->rootXOrigin, dmxScreen->rootYOrigin, - attr->screenWindowWidth, attr->screenWindowHeight, - attr->screenWindowXoffset, attr->screenWindowYoffset, - attr->rootWindowWidth, attr->rootWindowHeight, - attr->rootWindowXoffset, attr->rootWindowYoffset, - attr->rootWindowXorigin, attr->rootWindowYorigin); - - /* Configure "screen" window */ - dmxConfigureScreenWindow(idx, - attr->screenWindowXoffset, - attr->screenWindowYoffset, - attr->screenWindowWidth, - attr->screenWindowHeight); - - /* Configure "root" window */ - dmxConfigureRootWindow(idx, - attr->rootWindowXoffset, - attr->rootWindowYoffset, - attr->rootWindowWidth, - attr->rootWindowHeight); - - - /* Set "root" window's origin */ - dmxSetRootWindowOrigin(idx, - attr->rootWindowXorigin, - attr->rootWindowYorigin); - } - - /* Adjust the cursor boundaries */ - dmxAdjustCursorBoundaries(); - - /* Force completion of the changes */ - dmxSync(NULL, TRUE); - - return Success; -} - -/** Configure the attributes of the global desktop. */ -int dmxConfigureDesktop(DMXDesktopAttributesPtr attribs) -{ - if (attribs->width <= 0 || attribs->width >= 32767 || - attribs->height <= 0 || attribs->height >= 32767) - return DMX_BAD_VALUE; - - /* If the desktop is shrinking, adjust the "root" windows on each - * "screen" window to only show the visible desktop. Also, handle - * the special case where the desktop shrinks such that the it no - * longer overlaps an portion of a "screen" window. */ - if (attribs->width < dmxGlobalWidth || attribs->height < dmxGlobalHeight) { - int i; - for (i = 0; i < dmxNumScreens; i++) { - DMXScreenInfo *dmxScreen = &dmxScreens[i]; - if (dmxScreen->rootXOrigin - + dmxScreen->rootWidth > attribs->width || - dmxScreen->rootYOrigin - + dmxScreen->rootHeight > attribs->height) { - int w, h; - if ((w = attribs->width - dmxScreen->rootXOrigin) < 0) w = 0; - if ((h = attribs->height - dmxScreen->rootYOrigin) < 0) h = 0; - if (w > dmxScreen->scrnWidth) w = dmxScreen->scrnWidth; - if (h > dmxScreen->scrnHeight) h = dmxScreen->scrnHeight; - if (w > dmxScreen->rootWidth) w = dmxScreen->rootWidth; - if (h > dmxScreen->rootHeight) h = dmxScreen->rootHeight; - dmxConfigureRootWindow(i, - dmxScreen->rootX, - dmxScreen->rootY, - w, h); - } - } - } - - /* Set the global width/height */ - dmxSetWidthHeight(attribs->width, attribs->height); - - /* Handle shift[XY] changes */ - if (attribs->shiftX || attribs->shiftY) { - int i; - for (i = 0; i < dmxNumScreens; i++) { - ScreenPtr pScreen = screenInfo.screens[i]; - WindowPtr pChild = WindowTable[i]->firstChild; - while (pChild) { - /* Adjust child window's position */ - pScreen->MoveWindow(pChild, - pChild->origin.x - wBorderWidth(pChild) - - attribs->shiftX, - pChild->origin.y - wBorderWidth(pChild) - - attribs->shiftY, - pChild->nextSib, - VTMove); - - /* Note that the call to MoveWindow will eventually call - * dmxPositionWindow which will automatically create a - * window if it is now exposed on screen (for lazy - * window creation optimization) and it will properly - * set the offscreen flag. - */ - - pChild = pChild->nextSib; - } - } - } - - /* Update connection block, Xinerama, etc. -- these appears to - * already be handled in dmxConnectionBlockCallback(), which is - * called from dmxAdjustCursorBoundaries() [below]. */ - - /* Adjust the cursor boundaries */ - dmxAdjustCursorBoundaries(); - - /* Force completion of the changes */ - dmxSync(NULL, TRUE); - - return Success; -} -#endif - -/** Create the scratch GCs per depth. */ -static void dmxBECreateScratchGCs(int scrnNum) -{ - ScreenPtr pScreen = screenInfo.screens[scrnNum]; - GCPtr *ppGC = pScreen->GCperDepth; - int i; - - for (i = 0; i <= pScreen->numDepths; i++) - dmxBECreateGC(pScreen, ppGC[i]); -} - -#ifdef PANORAMIX -static Bool FoundPixImage; - -/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs - * to have its image restored. When it is found, see if there is - * another screen with the same image. If so, copy the pixmap image - * from the existing screen to the newly created pixmap. */ -static void dmxBERestorePixmapImage(pointer value, XID id, RESTYPE type, - pointer p) -{ - if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) { - PixmapPtr pDst = (PixmapPtr)p; - int idx = pDst->drawable.pScreen->myNum; - PanoramiXRes *pXinPix = (PanoramiXRes *)value; - PixmapPtr pPix; - int i; - - pPix = (PixmapPtr)LookupIDByType(pXinPix->info[idx].id, RT_PIXMAP); - if (pPix != pDst) return; /* Not a match.... Next! */ - - for (i = 0; i < PanoramiXNumScreens; i++) { - PixmapPtr pSrc; - dmxPixPrivPtr pSrcPriv = NULL; - - if (i == idx) continue; /* Self replication is bad */ - - pSrc = - (PixmapPtr)LookupIDByType(pXinPix->info[i].id, RT_PIXMAP); - pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc); - if (pSrcPriv->pixmap) { - DMXScreenInfo *dmxSrcScreen = &dmxScreens[i]; - DMXScreenInfo *dmxDstScreen = &dmxScreens[idx]; - dmxPixPrivPtr pDstPriv = DMX_GET_PIXMAP_PRIV(pDst); - XImage *img; - int j; - XlibGC gc = NULL; - - /* This should never happen, but just in case.... */ - if (pSrc->drawable.width != pDst->drawable.width || - pSrc->drawable.height != pDst->drawable.height) - return; - - /* Copy from src pixmap to dst pixmap */ - img = XGetImage(dmxSrcScreen->beDisplay, - pSrcPriv->pixmap, - 0, 0, - pSrc->drawable.width, pSrc->drawable.height, - -1, - ZPixmap); - - for (j = 0; j < dmxDstScreen->beNumPixmapFormats; j++) { - if (dmxDstScreen->bePixmapFormats[j].depth == img->depth) { - unsigned long m; - XGCValues v; - - m = GCFunction | GCPlaneMask | GCClipMask; - v.function = GXcopy; - v.plane_mask = AllPlanes; - v.clip_mask = None; - - gc = XCreateGC(dmxDstScreen->beDisplay, - dmxDstScreen->scrnDefDrawables[j], - m, &v); - break; - } - } - - if (gc) { - XPutImage(dmxDstScreen->beDisplay, - pDstPriv->pixmap, - gc, img, 0, 0, 0, 0, - pDst->drawable.width, pDst->drawable.height); - XFreeGC(dmxDstScreen->beDisplay, gc); - FoundPixImage = True; - } else { - dmxLog(dmxWarning, "Could not create GC\n"); - } - - XDestroyImage(img); - return; - } - } - } -} -#endif - -/** Restore the pixmap image either from another screen or from an image - * that was saved when the screen was previously detached. */ -static void dmxBERestorePixmap(PixmapPtr pPixmap) -{ -#ifdef PANORAMIX - int i; - - /* If Xinerama is not active, there's nothing we can do (see comment - * in #else below for more info). */ - if (noPanoramiXExtension) { - dmxLog(dmxWarning, "Cannot restore pixmap image\n"); - return; - } - - FoundPixImage = False; - for (i = currentMaxClients; --i >= 0; ) - if (clients[i]) - FindAllClientResources(clients[i], dmxBERestorePixmapImage, - (pointer)pPixmap); - - /* No corresponding pixmap image was found on other screens, so we - * need to copy it from the saved image when the screen was detached - * (if available). */ - if (!FoundPixImage) { - dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap); - - if (pPixPriv->detachedImage) { - ScreenPtr pScreen = pPixmap->drawable.pScreen; - DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; - XlibGC gc = NULL; - - for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) { - if (dmxScreen->bePixmapFormats[i].depth == - pPixPriv->detachedImage->depth) { - unsigned long m; - XGCValues v; - - m = GCFunction | GCPlaneMask | GCClipMask; - v.function = GXcopy; - v.plane_mask = AllPlanes; - v.clip_mask = None; - - gc = XCreateGC(dmxScreen->beDisplay, - dmxScreen->scrnDefDrawables[i], - m, &v); - break; - } - } - - if (gc) { - XPutImage(dmxScreen->beDisplay, - pPixPriv->pixmap, - gc, - pPixPriv->detachedImage, - 0, 0, 0, 0, - pPixmap->drawable.width, pPixmap->drawable.height); - XFreeGC(dmxScreen->beDisplay, gc); - } else { - dmxLog(dmxWarning, "Cannot restore pixmap image\n"); - } - - XDestroyImage(pPixPriv->detachedImage); - pPixPriv->detachedImage = NULL; - } else { - dmxLog(dmxWarning, "Cannot restore pixmap image\n"); - } - } -#else - /* If Xinerama is not enabled, then there is no other copy of the - * pixmap image that we can restore. Saving all pixmap data is not - * a feasible option since there is no mechanism for updating pixmap - * data when a screen is detached, which means that the data that - * was previously saved would most likely be out of date. */ - dmxLog(dmxWarning, "Cannot restore pixmap image\n"); - return; -#endif -} - -/** Create resources on the back-end server. This function is called - * from #dmxAttachScreen() via the dix layer's FindAllResources - * function. It walks all resources, compares them to the screen - * number passed in as \a n and calls the appropriate DMX function to - * create the associated resource on the back-end server. */ -static void dmxBECreateResources(pointer value, XID id, RESTYPE type, - pointer n) -{ - int scrnNum = (int)n; - ScreenPtr pScreen = screenInfo.screens[scrnNum]; - - if ((type & TypeMask) == (RT_WINDOW & TypeMask)) { - /* Window resources are created below in dmxBECreateWindowTree */ - } else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) { - PixmapPtr pPix = value; - if (pPix->drawable.pScreen->myNum == scrnNum) { - dmxBECreatePixmap(pPix); - dmxBERestorePixmap(pPix); - } - } else if ((type & TypeMask) == (RT_GC & TypeMask)) { - GCPtr pGC = value; - if (pGC->pScreen->myNum == scrnNum) { - /* Create the GC on the back-end server */ - dmxBECreateGC(pScreen, pGC); - /* Create any pixmaps associated with this GC */ - if (!pGC->tileIsPixel) { - dmxBECreatePixmap(pGC->tile.pixmap); - dmxBERestorePixmap(pGC->tile.pixmap); - } - if (pGC->stipple != pScreen->PixmapPerDepth[0]) { - dmxBECreatePixmap(pGC->stipple); - dmxBERestorePixmap(pGC->stipple); - } - if (pGC->font != defaultFont) { - (void)dmxBELoadFont(pScreen, pGC->font); - } - /* Update the GC on the back-end server */ - dmxChangeGC(pGC, -1L); - } - } else if ((type & TypeMask) == (RT_FONT & TypeMask)) { - (void)dmxBELoadFont(pScreen, (FontPtr)value); - } else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) { - dmxBECreateCursor(pScreen, (CursorPtr)value); - } else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) { - ColormapPtr pCmap = value; - if (pCmap->pScreen->myNum == scrnNum) - (void)dmxBECreateColormap((ColormapPtr)value); -#if 0 - /* TODO: Recreate Picture and GlyphSet resources */ - } else if ((type & TypeMask) == (PictureType & TypeMask)) { - /* Picture resources are created when windows are created */ - } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) { - dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value); -#endif - } else { - /* Other resource types??? */ - } -} - -/** Create window hierachy on back-end server. The window tree is - * created in a special order (bottom most subwindow first) so that the - * #dmxCreateNonRootWindow() function does not need to recursively call - * itself to create each window's parents. This is required so that we - * have the opportunity to create each window's border and background - * pixmaps (where appropriate) before the window is created. */ -static void dmxBECreateWindowTree(int idx) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[idx]; - WindowPtr pRoot = WindowTable[idx]; - dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot); - WindowPtr pWin; - - /* Create the pixmaps associated with the root window */ - if (!pRoot->borderIsPixel) { - dmxBECreatePixmap(pRoot->border.pixmap); - dmxBERestorePixmap(pRoot->border.pixmap); - } - if (pRoot->backgroundState == BackgroundPixmap) { - dmxBECreatePixmap(pRoot->background.pixmap); - dmxBERestorePixmap(pRoot->background.pixmap); - } - - /* Create root window first */ - dmxScreen->rootWin = pWinPriv->window = dmxCreateRootWindow(pRoot); - XMapWindow(dmxScreen->beDisplay, dmxScreen->rootWin); - - pWin = pRoot->lastChild; - while (pWin) { - pWinPriv = DMX_GET_WINDOW_PRIV(pWin); - - /* Create the pixmaps regardless of whether or not the - * window is created or not due to lazy window creation. - */ - if (!pWin->borderIsPixel) { - dmxBECreatePixmap(pWin->border.pixmap); - dmxBERestorePixmap(pWin->border.pixmap); - } - if (pWin->backgroundState == BackgroundPixmap) { - dmxBECreatePixmap(pWin->background.pixmap); - dmxBERestorePixmap(pWin->background.pixmap); - } - - /* Reset the window attributes */ - dmxGetDefaultWindowAttributes(pWin, - &pWinPriv->cmap, - &pWinPriv->visual); - - /* Create the window */ - if (pWinPriv->mapped && !pWinPriv->offscreen) - dmxCreateAndRealizeWindow(pWin, TRUE); - - /* Next, create the bottom-most child */ - if (pWin->lastChild) { - pWin = pWin->lastChild; - continue; - } - - /* If the window has no children, move on to the next higher window */ - while (!pWin->prevSib && (pWin != pRoot)) - pWin = pWin->parent; - - if (pWin->prevSib) { - pWin = pWin->prevSib; - continue; - } - - /* When we reach the root window, we are finished */ - if (pWin == pRoot) - break; - } -} - -/* Refresh screen by generating exposure events for all windows */ -static void dmxForceExposures(int idx) -{ - ScreenPtr pScreen = screenInfo.screens[idx]; - WindowPtr pRoot = WindowTable[idx]; - Bool anyMarked = FALSE; - WindowPtr pChild; - - for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib) - anyMarked |= pScreen->MarkOverlappedWindows(pChild, pChild, - (WindowPtr *)NULL); - if (anyMarked) { - /* If any windows have been marked, set the root window's - * clipList to be broken since it will be recalculated in - * ValidateTree() - */ - REGION_BREAK(pScreen, &pRoot->clipList); - pScreen->ValidateTree(pRoot, NULL, VTBroken); - pScreen->HandleExposures(pRoot); - if (pScreen->PostValidateTree) - pScreen->PostValidateTree(pRoot, NULL, VTBroken); - } -} - -/** Compare the new and old screens to see if they are compatible. */ -static Bool dmxCompareScreens(DMXScreenInfo *new, DMXScreenInfo *old) -{ - int i; - - if (new->beWidth != old->beWidth) return FALSE; - if (new->beHeight != old->beHeight) return FALSE; - if (new->beDepth != old->beDepth) return FALSE; - if (new->beBPP != old->beBPP) return FALSE; - - if (new->beNumDepths != old->beNumDepths) return FALSE; - for (i = 0; i < old->beNumDepths; i++) - if (new->beDepths[i] != old->beDepths[i]) return FALSE; - - if (new->beNumPixmapFormats != old->beNumPixmapFormats) return FALSE; - for (i = 0; i < old->beNumPixmapFormats; i++) { - if (new->bePixmapFormats[i].depth != - old->bePixmapFormats[i].depth) return FALSE; - if (new->bePixmapFormats[i].bits_per_pixel != - old->bePixmapFormats[i].bits_per_pixel) return FALSE; - if (new->bePixmapFormats[i].scanline_pad != - old->bePixmapFormats[i].scanline_pad) return FALSE; - } - - if (new->beNumVisuals != old->beNumVisuals) return FALSE; - for (i = 0; i < old->beNumVisuals; i++) { - if (new->beVisuals[i].visualid != - old->beVisuals[i].visualid) return FALSE; - if (new->beVisuals[i].screen != - old->beVisuals[i].screen) return FALSE; - if (new->beVisuals[i].depth != - old->beVisuals[i].depth) return FALSE; - if (new->beVisuals[i].class != - old->beVisuals[i].class) return FALSE; - if (new->beVisuals[i].red_mask != - old->beVisuals[i].red_mask) return FALSE; - if (new->beVisuals[i].green_mask != - old->beVisuals[i].green_mask) return FALSE; - if (new->beVisuals[i].blue_mask != - old->beVisuals[i].blue_mask) return FALSE; - if (new->beVisuals[i].colormap_size != - old->beVisuals[i].colormap_size) return FALSE; - if (new->beVisuals[i].bits_per_rgb != - old->beVisuals[i].bits_per_rgb) return FALSE; - } - - if (new->beDefVisualIndex != old->beDefVisualIndex) return FALSE; - - return TRUE; -} - -/** Restore Render's picture */ -static void dmxBERestoreRenderPict(pointer value, XID id, pointer n) -{ - PicturePtr pPicture = value; /* The picture */ - DrawablePtr pDraw = pPicture->pDrawable; /* The picture's drawable */ - int scrnNum = (int)n; - - if (pDraw->pScreen->myNum != scrnNum) { - /* Picture not on the screen we are restoring*/ - return; - } - - if (pDraw->type == DRAWABLE_PIXMAP) { - PixmapPtr pPixmap = (PixmapPtr)pDraw; - - /* Create and restore the pixmap drawable */ - dmxBECreatePixmap(pPixmap); - dmxBERestorePixmap(pPixmap); - } - - dmxBECreatePicture(pPicture); -} - -/** Restore Render's glyphs */ -static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n) -{ - GlyphSetPtr glyphSet = value; - int scrnNum = (int)n; - dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); - DMXScreenInfo *dmxScreen = &dmxScreens[scrnNum]; - GlyphRefPtr table; - char *images; - Glyph *gids; - XGlyphInfo *glyphs; - char *pos; - int beret; - int len_images = 0; - int i; - int ctr; - - if (glyphPriv->glyphSets[scrnNum]) { - /* Only restore glyphs on the screen we are attaching */ - return; - } - - /* First we must create the glyph set on the backend. */ - if ((beret = dmxBECreateGlyphSet(scrnNum, glyphSet)) != Success) { - dmxLog(dmxWarning, - "\tdmxBERestoreRenderGlyph failed to create glyphset!\n"); - return; - } - - /* Now for the complex part, restore the glyph data */ - table = glyphSet->hash.table; - - /* We need to know how much memory to allocate for this part */ - for (i = 0; i < glyphSet->hash.hashSet->size; i++) { - GlyphRefPtr gr = &table[i]; - GlyphPtr gl = gr->glyph; - - if (!gl || gl == DeletedGlyph) continue; - len_images += gl->size - sizeof(gl->info); - } - - /* Now allocate the memory we need */ - images = calloc(len_images, sizeof(char)); - gids = malloc(glyphSet->hash.tableEntries*sizeof(Glyph)); - glyphs = malloc(glyphSet->hash.tableEntries*sizeof(XGlyphInfo)); - - pos = images; - ctr = 0; - - /* Fill the allocated memory with the proper data */ - for (i = 0; i < glyphSet->hash.hashSet->size; i++) { - GlyphRefPtr gr = &table[i]; - GlyphPtr gl = gr->glyph; - - if (!gl || gl == DeletedGlyph) continue; - - /* First lets put the data into gids */ - gids[ctr] = gr->signature; - - /* Next do the glyphs data structures */ - glyphs[ctr].width = gl->info.width; - glyphs[ctr].height = gl->info.height; - glyphs[ctr].x = gl->info.x; - glyphs[ctr].y = gl->info.y; - glyphs[ctr].xOff = gl->info.xOff; - glyphs[ctr].yOff = gl->info.yOff; - - /* Copy the images from the DIX's data into the buffer */ - memcpy(pos, gl+1, gl->size - sizeof(gl->info)); - pos += gl->size - sizeof(gl->info); - ctr++; - } - - /* Now restore the glyph data */ - XRenderAddGlyphs(dmxScreen->beDisplay, glyphPriv->glyphSets[scrnNum], - gids,glyphs, glyphSet->hash.tableEntries, images, - len_images); - - /* Clean up */ - free(images); - free(gids); - free(glyphs); -} - -/** Reattach previously detached back-end screen. */ -int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr) -{ - ScreenPtr pScreen; - DMXScreenInfo *dmxScreen; - CARD32 scrnNum = idx; - DMXScreenInfo oldDMXScreen; - int i; - - /* Return failure if dynamic addition/removal of screens is disabled */ - if (!dmxAddRemoveScreens) { - dmxLog(dmxWarning, - "Attempting to add a screen, but the AddRemoveScreen\n"); - dmxLog(dmxWarning, - "extension has not been enabled. To enable this extension\n"); - dmxLog(dmxWarning, - "add the \"-addremovescreens\" option either to the command\n"); - dmxLog(dmxWarning, - "line or in the configuration file.\n"); - return 1; - } - - /* Cannot add a screen that does not exist */ - if (idx < 0 || idx >= dmxNumScreens) return 1; - pScreen = screenInfo.screens[idx]; - dmxScreen = &dmxScreens[idx]; - - /* Cannot attach to a screen that is already opened */ - if (dmxScreen->beDisplay) { - dmxLog(dmxWarning, - "Attempting to add screen #%d but a screen already exists\n", - idx); - return 1; - } - - dmxLogOutput(dmxScreen, "Attaching screen #%d\n", idx); - - /* Save old info */ - oldDMXScreen = *dmxScreen; - - /* Copy the name to the new screen */ - dmxScreen->name = strdup(attr->displayName); - - /* Open display and get all of the screen info */ - if (!dmxOpenDisplay(dmxScreen)) { - dmxLog(dmxWarning, - "dmxOpenDisplay: Unable to open display %s\n", - dmxScreen->name); - - /* Restore the old screen */ - *dmxScreen = oldDMXScreen; - return 1; - } - - dmxSetErrorHandler(dmxScreen); - dmxCheckForWM(dmxScreen); - dmxGetScreenAttribs(dmxScreen); - - if (!dmxGetVisualInfo(dmxScreen)) { - dmxLog(dmxWarning, "dmxGetVisualInfo: No matching visuals found\n"); - XFree(dmxScreen->beVisuals); - XCloseDisplay(dmxScreen->beDisplay); - - /* Restore the old screen */ - *dmxScreen = oldDMXScreen; - return 1; - } - - dmxGetColormaps(dmxScreen); - dmxGetPixmapFormats(dmxScreen); - - /* Verify that the screen to be added has the same info as the - * previously added screen. */ - if (!dmxCompareScreens(dmxScreen, &oldDMXScreen)) { - dmxLog(dmxWarning, - "New screen data (%s) does not match previously\n", - dmxScreen->name); - dmxLog(dmxWarning, - "attached screen data (%s)\n", - oldDMXScreen.name); - dmxLog(dmxWarning, - "All data must match in order to attach to screen #%d\n", - idx); - XFree(dmxScreen->beVisuals); - XFree(dmxScreen->beDepths); - XFree(dmxScreen->bePixmapFormats); - XCloseDisplay(dmxScreen->beDisplay); - - /* Restore the old screen */ - *dmxScreen = oldDMXScreen; - return 1; - } - - /* Initialize the BE screen resources */ - dmxBEScreenInit(idx, screenInfo.screens[idx]); - - /* TODO: Handle GLX visual initialization. GLXProxy needs to be - * updated to handle dynamic addition/removal of screens. */ - - /* Create default stipple */ - dmxBECreatePixmap(pScreen->PixmapPerDepth[0]); - dmxBERestorePixmap(pScreen->PixmapPerDepth[0]); - - /* Create the scratch GCs */ - dmxBECreateScratchGCs(idx); - - /* Create the default font */ - (void)dmxBELoadFont(pScreen, defaultFont); - - /* Create all resources that don't depend on windows */ - for (i = currentMaxClients; --i >= 0; ) - if (clients[i]) - FindAllClientResources(clients[i], dmxBECreateResources, - (pointer)idx); - - /* Create window hierarchy (top down) */ - dmxBECreateWindowTree(idx); - - /* Restore the picture state for RENDER */ - for (i = currentMaxClients; --i >= 0; ) - if (clients[i]) - FindClientResourcesByType(clients[i],PictureType, - dmxBERestoreRenderPict,(pointer)idx); - - /* Restore the glyph state for RENDER */ - for (i = currentMaxClients; --i >= 0; ) - if (clients[i]) - FindClientResourcesByType(clients[i],GlyphSetType, - dmxBERestoreRenderGlyph,(pointer)idx); - - /* Refresh screen by generating exposure events for all windows */ - dmxForceExposures(idx); - - dmxSync(&dmxScreens[idx], TRUE); - - /* We used these to compare the old and new screens. They are no - * longer needed since we have a newly attached screen, so we can - * now free the old screen's resources. */ - XFree(oldDMXScreen.beVisuals); - XFree(oldDMXScreen.beDepths); - XFree(oldDMXScreen.bePixmapFormats); - /* TODO: should oldDMXScreen.name be freed?? */ - -#ifdef PANORAMIX - if (!noPanoramiXExtension) - return dmxConfigureScreenWindows(1, &scrnNum, attr, NULL); - else -#endif - return 0; /* Success */ -} - -/* - * Resources that may have state on the BE server and need to be freed: - * - * RT_NONE - * RT_WINDOW - * RT_PIXMAP - * RT_GC - * RT_FONT - * RT_CURSOR - * RT_COLORMAP - * RT_CMAPENTRY - * RT_OTHERCLIENT - * RT_PASSIVEGRAB - * XRT_WINDOW - * XRT_PIXMAP - * XRT_GC - * XRT_COLORMAP - * XRT_PICTURE - * PictureType - * PictFormatType - * GlyphSetType - * ClientType - * EventType - * RT_INPUTCLIENT - * XETrapType - * RTCounter - * RTAwait - * RTAlarmClient - * RT_XKBCLIENT - * RTContext - * TagResType - * StalledResType - * SecurityAuthorizationResType - * RTEventClient - * __glXContextRes - * __glXClientRes - * __glXPixmapRes - * __glXWindowRes - * __glXPbufferRes - */ - -#ifdef PANORAMIX -/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs - * to have its image saved. */ -static void dmxBEFindPixmapImage(pointer value, XID id, RESTYPE type, - pointer p) -{ - if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) { - PixmapPtr pDst = (PixmapPtr)p; - int idx = pDst->drawable.pScreen->myNum; - PanoramiXRes *pXinPix = (PanoramiXRes *)value; - PixmapPtr pPix; - int i; - - pPix = (PixmapPtr)LookupIDByType(pXinPix->info[idx].id, RT_PIXMAP); - if (pPix != pDst) return; /* Not a match.... Next! */ - - for (i = 0; i < PanoramiXNumScreens; i++) { - PixmapPtr pSrc; - dmxPixPrivPtr pSrcPriv = NULL; - - if (i == idx) continue; /* Self replication is bad */ - - pSrc = - (PixmapPtr)LookupIDByType(pXinPix->info[i].id, RT_PIXMAP); - pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc); - if (pSrcPriv->pixmap) { - FoundPixImage = True; - return; - } - } - } -} -#endif - -/** Save the pixmap image only when there is not another screen with - * that pixmap from which the image can be read when the screen is - * reattached. To do this, we first try to find a pixmap on another - * screen corresponding to the one we are trying to save. If we find - * one, then we do not need to save the image data since during - * reattachment, the image data can be read from that other pixmap. - * However, if we do not find one, then we need to save the image data. - * The common case for these are for the default stipple and root - * tile. */ -static void dmxBESavePixmap(PixmapPtr pPixmap) -{ -#ifdef PANORAMIX - int i; - - /* If Xinerama is not active, there's nothing we can do (see comment - * in #else below for more info). */ - if (noPanoramiXExtension) return; - - FoundPixImage = False; - for (i = currentMaxClients; --i >= 0; ) - if (clients[i]) - FindAllClientResources(clients[i], dmxBEFindPixmapImage, - (pointer)pPixmap); - - /* Save the image only if there is no other screens that have a - * pixmap that corresponds to the one we are trying to save. */ - if (!FoundPixImage) { - dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap); - - if (!pPixPriv->detachedImage) { - ScreenPtr pScreen = pPixmap->drawable.pScreen; - DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; - - pPixPriv->detachedImage = XGetImage(dmxScreen->beDisplay, - pPixPriv->pixmap, - 0, 0, - pPixmap->drawable.width, - pPixmap->drawable.height, - -1, - ZPixmap); - if (!pPixPriv->detachedImage) - dmxLog(dmxWarning, "Cannot save pixmap image\n"); - } - } -#else - /* NOTE: The only time there is a pixmap on another screen that - * corresponds to the one we are trying to save is when Xinerama is - * active. Otherwise, the pixmap image data is only stored on a - * single screen, which means that once it is detached, that data is - * lost. We could save the data here, but then that would require - * us to implement the ability for Xdmx to keep the pixmap up to - * date while the screen is detached, which is beyond the scope of - * the current project. */ - return; -#endif -} - -/** Destroy resources on the back-end server. This function is called - * from #dmxDetachScreen() via the dix layer's FindAllResources - * function. It walks all resources, compares them to the screen - * number passed in as \a n and calls the appropriate DMX function to - * free the associated resource on the back-end server. */ -static void dmxBEDestroyResources(pointer value, XID id, RESTYPE type, - pointer n) -{ - int scrnNum = (int)n; - ScreenPtr pScreen = screenInfo.screens[scrnNum]; - - if ((type & TypeMask) == (RT_WINDOW & TypeMask)) { - /* Window resources are destroyed below in dmxBEDestroyWindowTree */ - } else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) { - PixmapPtr pPix = value; - if (pPix->drawable.pScreen->myNum == scrnNum) { - dmxBESavePixmap(pPix); - dmxBEFreePixmap(pPix); - } - } else if ((type & TypeMask) == (RT_GC & TypeMask)) { - GCPtr pGC = value; - if (pGC->pScreen->myNum == scrnNum) - dmxBEFreeGC(pGC); - } else if ((type & TypeMask) == (RT_FONT & TypeMask)) { - dmxBEFreeFont(pScreen, (FontPtr)value); - } else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) { - dmxBEFreeCursor(pScreen, (CursorPtr)value); - } else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) { - ColormapPtr pCmap = value; - if (pCmap->pScreen->myNum == scrnNum) - dmxBEFreeColormap((ColormapPtr)value); - } else if ((type & TypeMask) == (PictureType & TypeMask)) { - PicturePtr pPict = value; - if (pPict->pDrawable->pScreen->myNum == scrnNum) { - /* Free the pixmaps on the backend if needed */ - if (pPict->pDrawable->type == DRAWABLE_PIXMAP) { - PixmapPtr pPixmap = (PixmapPtr)(pPict->pDrawable); - dmxBESavePixmap(pPixmap); - dmxBEFreePixmap(pPixmap); - } - dmxBEFreePicture((PicturePtr)value); - } - } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) { - dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value); - } else { - /* Other resource types??? */ - } -} - -/** Destroy the scratch GCs that are created per depth. */ -static void dmxBEDestroyScratchGCs(int scrnNum) -{ - ScreenPtr pScreen = screenInfo.screens[scrnNum]; - GCPtr *ppGC = pScreen->GCperDepth; - int i; - - for (i = 0; i <= pScreen->numDepths; i++) - dmxBEFreeGC(ppGC[i]); -} - -/** Destroy window hierachy on back-end server. To ensure that all - * XDestroyWindow() calls succeed, they must be performed in a bottom - * up order so that windows are not destroyed before their children. - * XDestroyWindow(), which is called from #dmxBEDestroyWindow(), will - * destroy a window as well as all of it's children. */ -static void dmxBEDestroyWindowTree(int idx) -{ - WindowPtr pWin = WindowTable[idx]; - WindowPtr pChild = pWin; - - while (1) { - if (pChild->firstChild) { - pChild = pChild->firstChild; - continue; - } - - /* Destroy the window */ - dmxBEDestroyWindow(pChild); - - /* Make sure we destroy the window's border and background - * pixmaps if they exist */ - if (!pChild->borderIsPixel) { - dmxBESavePixmap(pChild->border.pixmap); - dmxBEFreePixmap(pChild->border.pixmap); - } - if (pChild->backgroundState == BackgroundPixmap) { - dmxBESavePixmap(pChild->background.pixmap); - dmxBEFreePixmap(pChild->background.pixmap); - } - - while (!pChild->nextSib && (pChild != pWin)) { - pChild = pChild->parent; - dmxBEDestroyWindow(pChild); - if (!pChild->borderIsPixel) { - dmxBESavePixmap(pChild->border.pixmap); - dmxBEFreePixmap(pChild->border.pixmap); - } - if (pChild->backgroundState == BackgroundPixmap) { - dmxBESavePixmap(pChild->background.pixmap); - dmxBEFreePixmap(pChild->background.pixmap); - } - } - - if (pChild == pWin) - break; - - pChild = pChild->nextSib; - } -} - -/** Detach back-end screen. */ -int dmxDetachScreen(int idx) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[idx]; - int i; - - /* Return failure if dynamic addition/removal of screens is disabled */ - if (!dmxAddRemoveScreens) { - dmxLog(dmxWarning, - "Attempting to remove a screen, but the AddRemoveScreen\n"); - dmxLog(dmxWarning, - "extension has not been enabled. To enable this extension\n"); - dmxLog(dmxWarning, - "add the \"-addremovescreens\" option either to the command\n"); - dmxLog(dmxWarning, - "line or in the configuration file.\n"); - return 1; - } - - /* Cannot remove a screen that does not exist */ - if (idx < 0 || idx >= dmxNumScreens) return 1; - - /* Cannot detach from a screen that is not opened */ - if (!dmxScreen->beDisplay) { - dmxLog(dmxWarning, - "Attempting to remove screen #%d but it has not been opened\n", - idx); - return 1; - } - - dmxLogOutput(dmxScreen, "Detaching screen #%d\n", idx); - - /* Detach input */ - dmxInputDetachAll(dmxScreen); - - /* Save all relevant state (TODO) */ - - /* Free all non-window resources related to this screen */ - for (i = currentMaxClients; --i >= 0; ) - if (clients[i]) - FindAllClientResources(clients[i], dmxBEDestroyResources, - (pointer)idx); - - /* Free scratch GCs */ - dmxBEDestroyScratchGCs(idx); - - /* Free window resources related to this screen */ - dmxBEDestroyWindowTree(idx); - - /* Free default stipple */ - dmxBESavePixmap(screenInfo.screens[idx]->PixmapPerDepth[0]); - dmxBEFreePixmap(screenInfo.screens[idx]->PixmapPerDepth[0]); - - /* Free the remaining screen resources and close the screen */ - dmxBECloseScreen(screenInfo.screens[idx]); - - /* Adjust the cursor boundaries (paints detached console window) */ - dmxAdjustCursorBoundaries(); - - return 0; /* Success */ -} +/*
+ * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Author:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides the only interface to the X server extension support
+ * in programs/Xserver/Xext. Those programs should only include dmxext.h
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "dmx.h"
+#include "dmxinit.h"
+#include "dmxextension.h"
+#include "dmxwindow.h"
+#include "dmxcb.h"
+#include "dmxcursor.h"
+#include "dmxpixmap.h"
+#include "dmxgc.h"
+#include "dmxfont.h"
+#include "dmxcmap.h"
+#include "dmxpict.h"
+#include "dmxinput.h"
+#include "dmxsync.h"
+#include "dmxscrinit.h"
+#include "input/dmxinputinit.h"
+
+#include "windowstr.h"
+#include "inputstr.h" /* For DeviceIntRec */
+#include <X11/extensions/dmxproto.h> /* For DMX_BAD_* */
+#include "cursorstr.h"
+
+/* The default font is declared in dix/globals.c, but is not included in
+ * _any_ header files. */
+extern FontPtr defaultFont;
+
+/** This routine provides information to the DMX protocol extension
+ * about a particular screen. */
+Bool dmxGetScreenAttributes(int physical, DMXScreenAttributesPtr attr)
+{
+ DMXScreenInfo *dmxScreen;
+
+ if (physical < 0 || physical >= dmxNumScreens) return FALSE;
+
+ dmxScreen = &dmxScreens[physical];
+ attr->displayName = dmxScreen->name;
+#ifdef PANORAMIX
+ attr->logicalScreen = noPanoramiXExtension ? dmxScreen->index : 0;
+#else
+ attr->logicalScreen = dmxScreen->index;
+#endif
+
+ attr->screenWindowWidth = dmxScreen->scrnWidth;
+ attr->screenWindowHeight = dmxScreen->scrnHeight;
+ attr->screenWindowXoffset = dmxScreen->scrnX;
+ attr->screenWindowYoffset = dmxScreen->scrnY;
+
+ attr->rootWindowWidth = dmxScreen->rootWidth;
+ attr->rootWindowHeight = dmxScreen->rootHeight;
+ attr->rootWindowXoffset = dmxScreen->rootX;
+ attr->rootWindowYoffset = dmxScreen->rootY;
+
+ attr->rootWindowXorigin = dmxScreen->rootXOrigin;
+ attr->rootWindowYorigin = dmxScreen->rootYOrigin;
+
+ return TRUE;
+}
+
+/** This routine provides information to the DMX protocol extension
+ * about a particular window. */
+Bool dmxGetWindowAttributes(WindowPtr pWindow, DMXWindowAttributesPtr attr)
+{
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ attr->screen = pWindow->drawable.pScreen->myNum;
+ attr->window = pWinPriv->window;
+
+ attr->pos.x = pWindow->drawable.x;
+ attr->pos.y = pWindow->drawable.y;
+ attr->pos.width = pWindow->drawable.width;
+ attr->pos.height = pWindow->drawable.height;
+
+ if (!pWinPriv->window || pWinPriv->offscreen) {
+ attr->vis.x = 0;
+ attr->vis.y = 0;
+ attr->vis.height = 0;
+ attr->vis.width = 0;
+ return pWinPriv->window ? TRUE : FALSE;
+ }
+
+ /* Compute display-relative coordinates */
+ attr->vis.x = pWindow->drawable.x;
+ attr->vis.y = pWindow->drawable.y;
+ attr->vis.width = pWindow->drawable.width;
+ attr->vis.height = pWindow->drawable.height;
+
+ if (attr->pos.x < 0) {
+ attr->vis.x -= attr->pos.x;
+ attr->vis.width = attr->pos.x + attr->pos.width - attr->vis.x;
+ }
+ if (attr->pos.x + attr->pos.width > pWindow->drawable.pScreen->width) {
+ if (attr->pos.x < 0)
+ attr->vis.width = pWindow->drawable.pScreen->width;
+ else
+ attr->vis.width = pWindow->drawable.pScreen->width - attr->pos.x;
+ }
+ if (attr->pos.y < 0) {
+ attr->vis.y -= attr->pos.y;
+ attr->vis.height = attr->pos.y + attr->pos.height - attr->vis.y;
+ }
+ if (attr->pos.y + attr->pos.height > pWindow->drawable.pScreen->height) {
+ if (attr->pos.y < 0)
+ attr->vis.height = pWindow->drawable.pScreen->height;
+ else
+ attr->vis.height = pWindow->drawable.pScreen->height - attr->pos.y;
+ }
+
+ /* Convert to window-relative coordinates */
+ attr->vis.x -= attr->pos.x;
+ attr->vis.y -= attr->pos.y;
+
+ return TRUE;
+}
+
+void dmxGetDesktopAttributes(DMXDesktopAttributesPtr attr)
+{
+ attr->width = dmxGlobalWidth;
+ attr->height = dmxGlobalHeight;
+ attr->shiftX = 0; /* NOTE: The upper left hand corner of */
+ attr->shiftY = 0; /* the desktop is always <0,0>. */
+}
+
+/** Return the total number of devices, not just #dmxNumInputs. The
+ * number returned should be the same as that returned by
+ * XListInputDevices. */
+int dmxGetInputCount(void)
+{
+ int i, total;
+
+ for (total = i = 0; i < dmxNumInputs; i++) total += dmxInputs[i].numDevs;
+ return total;
+}
+
+/** Return information about the device with id = \a deviceId. This
+ * information is primarily for the #ProcDMXGetInputAttributes()
+ * function, which does not have access to the appropriate data
+ * structure. */
+int dmxGetInputAttributes(int deviceId, DMXInputAttributesPtr attr)
+{
+ int i, j;
+ DMXInputInfo *dmxInput;
+
+ if (deviceId < 0) return -1;
+ for (i = 0; i < dmxNumInputs; i++) {
+ dmxInput = &dmxInputs[i];
+ for (j = 0; j < dmxInput->numDevs; j++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j];
+ if (deviceId != dmxLocal->pDevice->id) continue;
+ attr->isCore = !!dmxLocal->isCore;
+ attr->sendsCore = !!dmxLocal->sendsCore;
+ attr->detached = !!dmxInput->detached;
+ attr->physicalScreen = -1;
+ attr->physicalId = -1;
+ attr->name = NULL;
+ switch (dmxLocal->extType) {
+ case DMX_LOCAL_TYPE_LOCAL:
+ attr->inputType = 0;
+ break;
+ case DMX_LOCAL_TYPE_CONSOLE:
+ attr->inputType = 1;
+ attr->name = dmxInput->name;
+ attr->physicalId = dmxLocal->deviceId;
+ break;
+ case DMX_LOCAL_TYPE_BACKEND:
+ case DMX_LOCAL_TYPE_COMMON:
+ attr->inputType = 2;
+ attr->physicalScreen = dmxInput->scrnIdx;
+ attr->name = dmxInput->name;
+ attr->physicalId = dmxLocal->deviceId;
+ break;
+ }
+ return 0; /* Success */
+ }
+ }
+ return -1; /* Failure */
+}
+
+/** Reinitialized the cursor boundaries. */
+static void dmxAdjustCursorBoundaries(void)
+{
+ int i;
+
+ dmxReInitOrigins();
+ dmxInitOverlap();
+ dmxComputeWidthHeight(DMX_NO_RECOMPUTE_BOUNDING_BOX);
+ dmxConnectionBlockCallback();
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ if (!dmxInput->detached) dmxInputReInit(dmxInput);
+ }
+
+ dmxCheckCursor();
+
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ if (!dmxInput->detached) dmxInputLateReInit(dmxInput);
+ }
+}
+
+/** Add an input with the specified attributes. If the input is added,
+ * the physical id is returned in \a deviceId. */
+int dmxAddInput(DMXInputAttributesPtr attr, int *id)
+{
+ int retcode = BadValue;
+
+ if (attr->inputType == 1) /* console */
+ retcode = dmxInputAttachConsole(attr->name, attr->sendsCore, id);
+ else if (attr->inputType == 2) /* backend */
+ retcode = dmxInputAttachBackend(attr->physicalScreen,
+ attr->sendsCore,id);
+
+ if (retcode == Success) {
+ /* Adjust the cursor boundaries */
+ dmxAdjustCursorBoundaries();
+
+ /* Force completion of the changes */
+ dmxSync(NULL, TRUE);
+ }
+
+ return retcode;
+}
+
+/** Remove the input with physical id \a id. */
+int dmxRemoveInput(int id)
+{
+ return dmxInputDetachId(id);
+}
+
+/** Return the value of #dmxNumScreens -- the total number of backend
+ * screens in use (these are logical screens and may be larger than the
+ * number of backend displays). */
+unsigned long dmxGetNumScreens(void)
+{
+ return dmxNumScreens;
+}
+
+/** Make sure that #dmxCreateAndRealizeWindow has been called for \a
+ * pWindow. */
+void dmxForceWindowCreation(WindowPtr pWindow)
+{
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ if (!pWinPriv->window) dmxCreateAndRealizeWindow(pWindow, TRUE);
+}
+
+/** Flush pending syncs for all screens. */
+void dmxFlushPendingSyncs(void)
+{
+ dmxSync(NULL, TRUE);
+}
+
+/** Update DMX's screen resources to match those of the newly moved
+ * and/or resized "root" window. */
+void dmxUpdateScreenResources(ScreenPtr pScreen, int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
+ WindowPtr pChild;
+ Bool anyMarked = FALSE;
+
+ /* Handle special case where width and/or height are zero */
+ if (w == 0 || h == 0) {
+ w = 1;
+ h = 1;
+ }
+
+ /* Change screen size */
+ pScreen->width = w;
+ pScreen->height = h;
+
+ /* Reset the root window's drawable's size */
+ pRoot->drawable.width = w;
+ pRoot->drawable.height = h;
+
+ /* Set the root window's new winSize and borderSize */
+ pRoot->winSize.extents.x1 = 0;
+ pRoot->winSize.extents.y1 = 0;
+ pRoot->winSize.extents.x2 = w;
+ pRoot->winSize.extents.y2 = h;
+
+ pRoot->borderSize.extents.x1 = 0;
+ pRoot->borderSize.extents.y1 = 0;
+ pRoot->borderSize.extents.x2 = w;
+ pRoot->borderSize.extents.y2 = h;
+
+ /* Recompute this screen's mmWidth & mmHeight */
+ pScreen->mmWidth =
+ (w * 254 + dmxScreen->beXDPI * 5) / (dmxScreen->beXDPI * 10);
+ pScreen->mmHeight =
+ (h * 254 + dmxScreen->beYDPI * 5) / (dmxScreen->beYDPI * 10);
+
+ /* Recompute this screen's window's clip rects as follows: */
+ /* 1. Mark all of root's children's windows */
+ for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib)
+ anyMarked |= pScreen->MarkOverlappedWindows(pChild, pChild,
+ (WindowPtr *)NULL);
+
+ /* 2. Set the root window's borderClip */
+ pRoot->borderClip.extents.x1 = 0;
+ pRoot->borderClip.extents.y1 = 0;
+ pRoot->borderClip.extents.x2 = w;
+ pRoot->borderClip.extents.y2 = h;
+
+ /* 3. Set the root window's clipList */
+ if (anyMarked) {
+ /* If any windows have been marked, set the root window's
+ * clipList to be broken since it will be recalculated in
+ * ValidateTree()
+ */
+ RegionBreak(&pRoot->clipList);
+ } else {
+ /* Otherwise, we just set it directly since there are no
+ * windows visible on this screen
+ */
+ pRoot->clipList.extents.x1 = 0;
+ pRoot->clipList.extents.y1 = 0;
+ pRoot->clipList.extents.x2 = w;
+ pRoot->clipList.extents.y2 = h;
+ }
+
+ /* 4. Revalidate all clip rects and generate expose events */
+ if (anyMarked) {
+ pScreen->ValidateTree(pRoot, NULL, VTBroken);
+ pScreen->HandleExposures(pRoot);
+ if (pScreen->PostValidateTree)
+ pScreen->PostValidateTree(pRoot, NULL, VTBroken);
+ }
+}
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+
+/** Change the "screen" window attributes by resizing the actual window
+ * on the back-end display (if necessary). */
+static void dmxConfigureScreenWindow(int idx,
+ int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ ScreenPtr pScreen = screenInfo.screens[idx];
+
+ /* Resize "screen" window */
+ if (dmxScreen->scrnX != x ||
+ dmxScreen->scrnY != y ||
+ dmxScreen->scrnWidth != w ||
+ dmxScreen->scrnHeight != h) {
+ dmxResizeScreenWindow(pScreen, x, y, w, h);
+ }
+
+ /* Change "screen" window values */
+ dmxScreen->scrnX = x;
+ dmxScreen->scrnY = y;
+ dmxScreen->scrnWidth = w;
+ dmxScreen->scrnHeight = h;
+}
+
+/** Change the "root" window position and size by resizing the actual
+ * window on the back-end display (if necessary) and updating all of
+ * DMX's resources by calling #dmxUpdateScreenResources. */
+static void dmxConfigureRootWindow(int idx, int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ WindowPtr pRoot = screenInfo.screens[idx]->root;
+
+ /* NOTE: Either this function or the ones that it calls must handle
+ * the case where w == 0 || h == 0. Currently, the functions that
+ * this one calls handle that case. */
+
+ /* 1. Resize "root" window */
+ if (dmxScreen->rootX != x ||
+ dmxScreen->rootY != y ||
+ dmxScreen->rootWidth != w ||
+ dmxScreen->rootHeight != h) {
+ dmxResizeRootWindow(pRoot, x, y, w, h);
+ }
+
+ /* 2. Update all of the screen's resources associated with this root
+ * window */
+ if (dmxScreen->rootWidth != w ||
+ dmxScreen->rootHeight != h) {
+ dmxUpdateScreenResources(screenInfo.screens[idx], x, y, w, h);
+ }
+
+ /* Change "root" window values */
+ dmxScreen->rootX = x;
+ dmxScreen->rootY = y;
+ dmxScreen->rootWidth = w;
+ dmxScreen->rootHeight = h;
+}
+
+/** Change the "root" window's origin by updating DMX's internal data
+ * structures (dix and Xinerama) to use the new origin and adjust the
+ * positions of windows that overlap this "root" window. */
+static void dmxSetRootWindowOrigin(int idx, int x, int y)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ ScreenPtr pScreen = screenInfo.screens[idx];
+ WindowPtr pRoot = pScreen->root;
+ WindowPtr pChild;
+ int xoff;
+ int yoff;
+
+ /* Change "root" window's origin */
+ dmxScreen->rootXOrigin = x;
+ dmxScreen->rootYOrigin = y;
+
+ /* Compute offsets here in case <x,y> has been changed above */
+ xoff = x - pScreen->x;
+ yoff = y - pScreen->y;
+
+ /* Adjust the root window's position */
+ pScreen->x = dmxScreen->rootXOrigin;
+ pScreen->y = dmxScreen->rootYOrigin;
+
+ /* Recalculate the Xinerama regions and data structs */
+ XineramaReinitData(pScreen);
+
+ /* Adjust each of the root window's children */
+ if (!idx) ReinitializeRootWindow(screenInfo.screens[0]->root, xoff, yoff);
+ pChild = pRoot->firstChild;
+ while (pChild) {
+ /* Adjust child window's position */
+ pScreen->MoveWindow(pChild,
+ pChild->origin.x - wBorderWidth(pChild) - xoff,
+ pChild->origin.y - wBorderWidth(pChild) - yoff,
+ pChild->nextSib,
+ VTMove);
+
+ /* Note that the call to MoveWindow will eventually call
+ * dmxPositionWindow which will automatically create a
+ * window if it is now exposed on screen (for lazy window
+ * creation optimization) and it will properly set the
+ * offscreen flag.
+ */
+
+ pChild = pChild->nextSib;
+ }
+}
+
+/** Configure the attributes of each "screen" and "root" window. */
+int dmxConfigureScreenWindows(int nscreens,
+ CARD32 *screens,
+ DMXScreenAttributesPtr attribs,
+ int *errorScreen)
+{
+ int i;
+
+ for (i = 0; i < nscreens; i++) {
+ DMXScreenAttributesPtr attr = &attribs[i];
+ int idx = screens[i];
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+
+ if (errorScreen) *errorScreen = i;
+
+ if (!dmxScreen->beDisplay) return DMX_BAD_VALUE;
+
+ /* Check for illegal values */
+ if (idx < 0 || idx >= dmxNumScreens) return BadValue;
+
+ /* The "screen" and "root" windows must have valid sizes */
+ if (attr->screenWindowWidth <= 0 || attr->screenWindowHeight <= 0 ||
+ attr->rootWindowWidth < 0 || attr->rootWindowHeight < 0)
+ return DMX_BAD_VALUE;
+
+ /* The "screen" window must fit entirely within the BE display */
+ if (attr->screenWindowXoffset < 0 ||
+ attr->screenWindowYoffset < 0 ||
+ attr->screenWindowXoffset
+ + attr->screenWindowWidth > (unsigned)dmxScreen->beWidth ||
+ attr->screenWindowYoffset
+ + attr->screenWindowHeight > (unsigned)dmxScreen->beHeight)
+ return DMX_BAD_VALUE;
+
+ /* The "root" window must fit entirely within the "screen" window */
+ if (attr->rootWindowXoffset < 0 ||
+ attr->rootWindowYoffset < 0 ||
+ attr->rootWindowXoffset
+ + attr->rootWindowWidth > attr->screenWindowWidth ||
+ attr->rootWindowYoffset
+ + attr->rootWindowHeight > attr->screenWindowHeight)
+ return DMX_BAD_VALUE;
+
+ /* The "root" window must not expose unaddressable coordinates */
+ if (attr->rootWindowXorigin < 0 ||
+ attr->rootWindowYorigin < 0 ||
+ attr->rootWindowXorigin + attr->rootWindowWidth > 32767 ||
+ attr->rootWindowYorigin + attr->rootWindowHeight > 32767)
+ return DMX_BAD_VALUE;
+
+ /* The "root" window must fit within the global bounding box */
+ if (attr->rootWindowXorigin
+ + attr->rootWindowWidth > (unsigned)dmxGlobalWidth ||
+ attr->rootWindowYorigin
+ + attr->rootWindowHeight > (unsigned)dmxGlobalHeight)
+ return DMX_BAD_VALUE;
+
+ /* FIXME: Handle the rest of the illegal value checking */
+ }
+
+ /* No illegal values found */
+ if (errorScreen) *errorScreen = 0;
+
+ for (i = 0; i < nscreens; i++) {
+ DMXScreenAttributesPtr attr = &attribs[i];
+ int idx = screens[i];
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+
+ dmxLog(dmxInfo, "Changing screen #%d attributes "
+ "from %dx%d+%d+%d %dx%d+%d+%d +%d+%d "
+ "to %dx%d+%d+%d %dx%d+%d+%d +%d+%d\n",
+ idx,
+ dmxScreen->scrnWidth, dmxScreen->scrnHeight,
+ dmxScreen->scrnX, dmxScreen->scrnY,
+ dmxScreen->rootWidth, dmxScreen->rootHeight,
+ dmxScreen->rootX, dmxScreen->rootY,
+ dmxScreen->rootXOrigin, dmxScreen->rootYOrigin,
+ attr->screenWindowWidth, attr->screenWindowHeight,
+ attr->screenWindowXoffset, attr->screenWindowYoffset,
+ attr->rootWindowWidth, attr->rootWindowHeight,
+ attr->rootWindowXoffset, attr->rootWindowYoffset,
+ attr->rootWindowXorigin, attr->rootWindowYorigin);
+
+ /* Configure "screen" window */
+ dmxConfigureScreenWindow(idx,
+ attr->screenWindowXoffset,
+ attr->screenWindowYoffset,
+ attr->screenWindowWidth,
+ attr->screenWindowHeight);
+
+ /* Configure "root" window */
+ dmxConfigureRootWindow(idx,
+ attr->rootWindowXoffset,
+ attr->rootWindowYoffset,
+ attr->rootWindowWidth,
+ attr->rootWindowHeight);
+
+
+ /* Set "root" window's origin */
+ dmxSetRootWindowOrigin(idx,
+ attr->rootWindowXorigin,
+ attr->rootWindowYorigin);
+ }
+
+ /* Adjust the cursor boundaries */
+ dmxAdjustCursorBoundaries();
+
+ /* Force completion of the changes */
+ dmxSync(NULL, TRUE);
+
+ return Success;
+}
+
+/** Configure the attributes of the global desktop. */
+int dmxConfigureDesktop(DMXDesktopAttributesPtr attribs)
+{
+ if (attribs->width <= 0 || attribs->width >= 32767 ||
+ attribs->height <= 0 || attribs->height >= 32767)
+ return DMX_BAD_VALUE;
+
+ /* If the desktop is shrinking, adjust the "root" windows on each
+ * "screen" window to only show the visible desktop. Also, handle
+ * the special case where the desktop shrinks such that the it no
+ * longer overlaps an portion of a "screen" window. */
+ if (attribs->width < dmxGlobalWidth || attribs->height < dmxGlobalHeight) {
+ int i;
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ if (dmxScreen->rootXOrigin
+ + dmxScreen->rootWidth > attribs->width ||
+ dmxScreen->rootYOrigin
+ + dmxScreen->rootHeight > attribs->height) {
+ int w, h;
+ if ((w = attribs->width - dmxScreen->rootXOrigin) < 0) w = 0;
+ if ((h = attribs->height - dmxScreen->rootYOrigin) < 0) h = 0;
+ if (w > dmxScreen->scrnWidth) w = dmxScreen->scrnWidth;
+ if (h > dmxScreen->scrnHeight) h = dmxScreen->scrnHeight;
+ if (w > dmxScreen->rootWidth) w = dmxScreen->rootWidth;
+ if (h > dmxScreen->rootHeight) h = dmxScreen->rootHeight;
+ dmxConfigureRootWindow(i,
+ dmxScreen->rootX,
+ dmxScreen->rootY,
+ w, h);
+ }
+ }
+ }
+
+ /* Set the global width/height */
+ dmxSetWidthHeight(attribs->width, attribs->height);
+
+ /* Handle shift[XY] changes */
+ if (attribs->shiftX || attribs->shiftY) {
+ int i;
+ for (i = 0; i < dmxNumScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ WindowPtr pChild = pScreen->root->firstChild;
+ while (pChild) {
+ /* Adjust child window's position */
+ pScreen->MoveWindow(pChild,
+ pChild->origin.x - wBorderWidth(pChild)
+ - attribs->shiftX,
+ pChild->origin.y - wBorderWidth(pChild)
+ - attribs->shiftY,
+ pChild->nextSib,
+ VTMove);
+
+ /* Note that the call to MoveWindow will eventually call
+ * dmxPositionWindow which will automatically create a
+ * window if it is now exposed on screen (for lazy
+ * window creation optimization) and it will properly
+ * set the offscreen flag.
+ */
+
+ pChild = pChild->nextSib;
+ }
+ }
+ }
+
+ /* Update connection block, Xinerama, etc. -- these appears to
+ * already be handled in dmxConnectionBlockCallback(), which is
+ * called from dmxAdjustCursorBoundaries() [below]. */
+
+ /* Adjust the cursor boundaries */
+ dmxAdjustCursorBoundaries();
+
+ /* Force completion of the changes */
+ dmxSync(NULL, TRUE);
+
+ return Success;
+}
+#endif
+
+/** Create the scratch GCs per depth. */
+static void dmxBECreateScratchGCs(int scrnNum)
+{
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+ GCPtr *ppGC = pScreen->GCperDepth;
+ int i;
+
+ for (i = 0; i <= pScreen->numDepths; i++)
+ dmxBECreateGC(pScreen, ppGC[i]);
+}
+
+#ifdef PANORAMIX
+static Bool FoundPixImage;
+
+/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs
+ * to have its image restored. When it is found, see if there is
+ * another screen with the same image. If so, copy the pixmap image
+ * from the existing screen to the newly created pixmap. */
+static void dmxBERestorePixmapImage(pointer value, XID id, RESTYPE type,
+ pointer p)
+{
+ if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) {
+ PixmapPtr pDst = (PixmapPtr)p;
+ int idx = pDst->drawable.pScreen->myNum;
+ PanoramiXRes *pXinPix = (PanoramiXRes *)value;
+ PixmapPtr pPix;
+ int i;
+
+ pPix = (PixmapPtr)LookupIDByType(pXinPix->info[idx].id, RT_PIXMAP);
+ if (pPix != pDst) return; /* Not a match.... Next! */
+
+ for (i = 0; i < PanoramiXNumScreens; i++) {
+ PixmapPtr pSrc;
+ dmxPixPrivPtr pSrcPriv = NULL;
+
+ if (i == idx) continue; /* Self replication is bad */
+
+ pSrc =
+ (PixmapPtr)LookupIDByType(pXinPix->info[i].id, RT_PIXMAP);
+ pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
+ if (pSrcPriv->pixmap) {
+ DMXScreenInfo *dmxSrcScreen = &dmxScreens[i];
+ DMXScreenInfo *dmxDstScreen = &dmxScreens[idx];
+ dmxPixPrivPtr pDstPriv = DMX_GET_PIXMAP_PRIV(pDst);
+ XImage *img;
+ int j;
+ XlibGC gc = NULL;
+
+ /* This should never happen, but just in case.... */
+ if (pSrc->drawable.width != pDst->drawable.width ||
+ pSrc->drawable.height != pDst->drawable.height)
+ return;
+
+ /* Copy from src pixmap to dst pixmap */
+ img = XGetImage(dmxSrcScreen->beDisplay,
+ pSrcPriv->pixmap,
+ 0, 0,
+ pSrc->drawable.width, pSrc->drawable.height,
+ -1,
+ ZPixmap);
+
+ for (j = 0; j < dmxDstScreen->beNumPixmapFormats; j++) {
+ if (dmxDstScreen->bePixmapFormats[j].depth == img->depth) {
+ unsigned long m;
+ XGCValues v;
+
+ m = GCFunction | GCPlaneMask | GCClipMask;
+ v.function = GXcopy;
+ v.plane_mask = AllPlanes;
+ v.clip_mask = None;
+
+ gc = XCreateGC(dmxDstScreen->beDisplay,
+ dmxDstScreen->scrnDefDrawables[j],
+ m, &v);
+ break;
+ }
+ }
+
+ if (gc) {
+ XPutImage(dmxDstScreen->beDisplay,
+ pDstPriv->pixmap,
+ gc, img, 0, 0, 0, 0,
+ pDst->drawable.width, pDst->drawable.height);
+ XFreeGC(dmxDstScreen->beDisplay, gc);
+ FoundPixImage = True;
+ } else {
+ dmxLog(dmxWarning, "Could not create GC\n");
+ }
+
+ XDestroyImage(img);
+ return;
+ }
+ }
+ }
+}
+#endif
+
+/** Restore the pixmap image either from another screen or from an image
+ * that was saved when the screen was previously detached. */
+static void dmxBERestorePixmap(PixmapPtr pPixmap)
+{
+#ifdef PANORAMIX
+ int i;
+
+ /* If Xinerama is not active, there's nothing we can do (see comment
+ * in #else below for more info). */
+ if (noPanoramiXExtension) {
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ return;
+ }
+
+ FoundPixImage = False;
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBERestorePixmapImage,
+ (pointer)pPixmap);
+
+ /* No corresponding pixmap image was found on other screens, so we
+ * need to copy it from the saved image when the screen was detached
+ * (if available). */
+ if (!FoundPixImage) {
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
+
+ if (pPixPriv->detachedImage) {
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ XlibGC gc = NULL;
+
+ for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
+ if (dmxScreen->bePixmapFormats[i].depth ==
+ pPixPriv->detachedImage->depth) {
+ unsigned long m;
+ XGCValues v;
+
+ m = GCFunction | GCPlaneMask | GCClipMask;
+ v.function = GXcopy;
+ v.plane_mask = AllPlanes;
+ v.clip_mask = None;
+
+ gc = XCreateGC(dmxScreen->beDisplay,
+ dmxScreen->scrnDefDrawables[i],
+ m, &v);
+ break;
+ }
+ }
+
+ if (gc) {
+ XPutImage(dmxScreen->beDisplay,
+ pPixPriv->pixmap,
+ gc,
+ pPixPriv->detachedImage,
+ 0, 0, 0, 0,
+ pPixmap->drawable.width, pPixmap->drawable.height);
+ XFreeGC(dmxScreen->beDisplay, gc);
+ } else {
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ }
+
+ XDestroyImage(pPixPriv->detachedImage);
+ pPixPriv->detachedImage = NULL;
+ } else {
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ }
+ }
+#else
+ /* If Xinerama is not enabled, then there is no other copy of the
+ * pixmap image that we can restore. Saving all pixmap data is not
+ * a feasible option since there is no mechanism for updating pixmap
+ * data when a screen is detached, which means that the data that
+ * was previously saved would most likely be out of date. */
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ return;
+#endif
+}
+
+/** Create resources on the back-end server. This function is called
+ * from #dmxAttachScreen() via the dix layer's FindAllResources
+ * function. It walks all resources, compares them to the screen
+ * number passed in as \a n and calls the appropriate DMX function to
+ * create the associated resource on the back-end server. */
+static void dmxBECreateResources(pointer value, XID id, RESTYPE type,
+ pointer n)
+{
+ int scrnNum = (int)n;
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+
+ if ((type & TypeMask) == (RT_WINDOW & TypeMask)) {
+ /* Window resources are created below in dmxBECreateWindowTree */
+ } else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) {
+ PixmapPtr pPix = value;
+ if (pPix->drawable.pScreen->myNum == scrnNum) {
+ dmxBECreatePixmap(pPix);
+ dmxBERestorePixmap(pPix);
+ }
+ } else if ((type & TypeMask) == (RT_GC & TypeMask)) {
+ GCPtr pGC = value;
+ if (pGC->pScreen->myNum == scrnNum) {
+ /* Create the GC on the back-end server */
+ dmxBECreateGC(pScreen, pGC);
+ /* Create any pixmaps associated with this GC */
+ if (!pGC->tileIsPixel) {
+ dmxBECreatePixmap(pGC->tile.pixmap);
+ dmxBERestorePixmap(pGC->tile.pixmap);
+ }
+ if (pGC->stipple != pScreen->PixmapPerDepth[0]) {
+ dmxBECreatePixmap(pGC->stipple);
+ dmxBERestorePixmap(pGC->stipple);
+ }
+ if (pGC->font != defaultFont) {
+ (void)dmxBELoadFont(pScreen, pGC->font);
+ }
+ /* Update the GC on the back-end server */
+ dmxChangeGC(pGC, -1L);
+ }
+ } else if ((type & TypeMask) == (RT_FONT & TypeMask)) {
+ (void)dmxBELoadFont(pScreen, (FontPtr)value);
+ } else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) {
+ dmxBECreateCursor(pScreen, (CursorPtr)value);
+ } else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) {
+ ColormapPtr pCmap = value;
+ if (pCmap->pScreen->myNum == scrnNum)
+ (void)dmxBECreateColormap((ColormapPtr)value);
+#if 0
+ /* TODO: Recreate Picture and GlyphSet resources */
+ } else if ((type & TypeMask) == (PictureType & TypeMask)) {
+ /* Picture resources are created when windows are created */
+ } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
+ dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
+#endif
+ } else {
+ /* Other resource types??? */
+ }
+}
+
+/** Create window hierachy on back-end server. The window tree is
+ * created in a special order (bottom most subwindow first) so that the
+ * #dmxCreateNonRootWindow() function does not need to recursively call
+ * itself to create each window's parents. This is required so that we
+ * have the opportunity to create each window's border and background
+ * pixmaps (where appropriate) before the window is created. */
+static void dmxBECreateWindowTree(int idx)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ WindowPtr pRoot = screenInfo.screens[idx]->root;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
+ WindowPtr pWin;
+
+ /* Create the pixmaps associated with the root window */
+ if (!pRoot->borderIsPixel) {
+ dmxBECreatePixmap(pRoot->border.pixmap);
+ dmxBERestorePixmap(pRoot->border.pixmap);
+ }
+ if (pRoot->backgroundState == BackgroundPixmap) {
+ dmxBECreatePixmap(pRoot->background.pixmap);
+ dmxBERestorePixmap(pRoot->background.pixmap);
+ }
+
+ /* Create root window first */
+ dmxScreen->rootWin = pWinPriv->window = dmxCreateRootWindow(pRoot);
+ XMapWindow(dmxScreen->beDisplay, dmxScreen->rootWin);
+
+ pWin = pRoot->lastChild;
+ while (pWin) {
+ pWinPriv = DMX_GET_WINDOW_PRIV(pWin);
+
+ /* Create the pixmaps regardless of whether or not the
+ * window is created or not due to lazy window creation.
+ */
+ if (!pWin->borderIsPixel) {
+ dmxBECreatePixmap(pWin->border.pixmap);
+ dmxBERestorePixmap(pWin->border.pixmap);
+ }
+ if (pWin->backgroundState == BackgroundPixmap) {
+ dmxBECreatePixmap(pWin->background.pixmap);
+ dmxBERestorePixmap(pWin->background.pixmap);
+ }
+
+ /* Reset the window attributes */
+ dmxGetDefaultWindowAttributes(pWin,
+ &pWinPriv->cmap,
+ &pWinPriv->visual);
+
+ /* Create the window */
+ if (pWinPriv->mapped && !pWinPriv->offscreen)
+ dmxCreateAndRealizeWindow(pWin, TRUE);
+
+ /* Next, create the bottom-most child */
+ if (pWin->lastChild) {
+ pWin = pWin->lastChild;
+ continue;
+ }
+
+ /* If the window has no children, move on to the next higher window */
+ while (!pWin->prevSib && (pWin != pRoot))
+ pWin = pWin->parent;
+
+ if (pWin->prevSib) {
+ pWin = pWin->prevSib;
+ continue;
+ }
+
+ /* When we reach the root window, we are finished */
+ if (pWin == pRoot)
+ break;
+ }
+}
+
+/* Refresh screen by generating exposure events for all windows */
+static void dmxForceExposures(int idx)
+{
+ ScreenPtr pScreen = screenInfo.screens[idx];
+ WindowPtr pRoot = pScreen->root;
+ Bool anyMarked = FALSE;
+ WindowPtr pChild;
+
+ for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib)
+ anyMarked |= pScreen->MarkOverlappedWindows(pChild, pChild,
+ (WindowPtr *)NULL);
+ if (anyMarked) {
+ /* If any windows have been marked, set the root window's
+ * clipList to be broken since it will be recalculated in
+ * ValidateTree()
+ */
+ RegionBreak(&pRoot->clipList);
+ pScreen->ValidateTree(pRoot, NULL, VTBroken);
+ pScreen->HandleExposures(pRoot);
+ if (pScreen->PostValidateTree)
+ pScreen->PostValidateTree(pRoot, NULL, VTBroken);
+ }
+}
+
+/** Compare the new and old screens to see if they are compatible. */
+static Bool dmxCompareScreens(DMXScreenInfo *new, DMXScreenInfo *old)
+{
+ int i;
+
+ if (new->beWidth != old->beWidth) return FALSE;
+ if (new->beHeight != old->beHeight) return FALSE;
+ if (new->beDepth != old->beDepth) return FALSE;
+ if (new->beBPP != old->beBPP) return FALSE;
+
+ if (new->beNumDepths != old->beNumDepths) return FALSE;
+ for (i = 0; i < old->beNumDepths; i++)
+ if (new->beDepths[i] != old->beDepths[i]) return FALSE;
+
+ if (new->beNumPixmapFormats != old->beNumPixmapFormats) return FALSE;
+ for (i = 0; i < old->beNumPixmapFormats; i++) {
+ if (new->bePixmapFormats[i].depth !=
+ old->bePixmapFormats[i].depth) return FALSE;
+ if (new->bePixmapFormats[i].bits_per_pixel !=
+ old->bePixmapFormats[i].bits_per_pixel) return FALSE;
+ if (new->bePixmapFormats[i].scanline_pad !=
+ old->bePixmapFormats[i].scanline_pad) return FALSE;
+ }
+
+ if (new->beNumVisuals != old->beNumVisuals) return FALSE;
+ for (i = 0; i < old->beNumVisuals; i++) {
+ if (new->beVisuals[i].visualid !=
+ old->beVisuals[i].visualid) return FALSE;
+ if (new->beVisuals[i].screen !=
+ old->beVisuals[i].screen) return FALSE;
+ if (new->beVisuals[i].depth !=
+ old->beVisuals[i].depth) return FALSE;
+ if (new->beVisuals[i].class !=
+ old->beVisuals[i].class) return FALSE;
+ if (new->beVisuals[i].red_mask !=
+ old->beVisuals[i].red_mask) return FALSE;
+ if (new->beVisuals[i].green_mask !=
+ old->beVisuals[i].green_mask) return FALSE;
+ if (new->beVisuals[i].blue_mask !=
+ old->beVisuals[i].blue_mask) return FALSE;
+ if (new->beVisuals[i].colormap_size !=
+ old->beVisuals[i].colormap_size) return FALSE;
+ if (new->beVisuals[i].bits_per_rgb !=
+ old->beVisuals[i].bits_per_rgb) return FALSE;
+ }
+
+ if (new->beDefVisualIndex != old->beDefVisualIndex) return FALSE;
+
+ return TRUE;
+}
+
+/** Restore Render's picture */
+static void dmxBERestoreRenderPict(pointer value, XID id, pointer n)
+{
+ PicturePtr pPicture = value; /* The picture */
+ DrawablePtr pDraw = pPicture->pDrawable; /* The picture's drawable */
+ int scrnNum = (int)n;
+
+ if (pDraw->pScreen->myNum != scrnNum) {
+ /* Picture not on the screen we are restoring*/
+ return;
+ }
+
+ if (pDraw->type == DRAWABLE_PIXMAP) {
+ PixmapPtr pPixmap = (PixmapPtr)pDraw;
+
+ /* Create and restore the pixmap drawable */
+ dmxBECreatePixmap(pPixmap);
+ dmxBERestorePixmap(pPixmap);
+ }
+
+ dmxBECreatePicture(pPicture);
+}
+
+/** Restore Render's glyphs */
+static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
+{
+ GlyphSetPtr glyphSet = value;
+ int scrnNum = (int)n;
+ dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
+ DMXScreenInfo *dmxScreen = &dmxScreens[scrnNum];
+ GlyphRefPtr table;
+ char *images;
+ Glyph *gids;
+ XGlyphInfo *glyphs;
+ char *pos;
+ int beret;
+ int len_images = 0;
+ int i;
+ int ctr;
+
+ if (glyphPriv->glyphSets[scrnNum]) {
+ /* Only restore glyphs on the screen we are attaching */
+ return;
+ }
+
+ /* First we must create the glyph set on the backend. */
+ if ((beret = dmxBECreateGlyphSet(scrnNum, glyphSet)) != Success) {
+ dmxLog(dmxWarning,
+ "\tdmxBERestoreRenderGlyph failed to create glyphset!\n");
+ return;
+ }
+
+ /* Now for the complex part, restore the glyph data */
+ table = glyphSet->hash.table;
+
+ /* We need to know how much memory to allocate for this part */
+ for (i = 0; i < glyphSet->hash.hashSet->size; i++) {
+ GlyphRefPtr gr = &table[i];
+ GlyphPtr gl = gr->glyph;
+
+ if (!gl || gl == DeletedGlyph) continue;
+ len_images += gl->size - sizeof(gl->info);
+ }
+
+ /* Now allocate the memory we need */
+ images = calloc(len_images, sizeof(char));
+ gids = malloc(glyphSet->hash.tableEntries*sizeof(Glyph));
+ glyphs = malloc(glyphSet->hash.tableEntries*sizeof(XGlyphInfo));
+
+ pos = images;
+ ctr = 0;
+
+ /* Fill the allocated memory with the proper data */
+ for (i = 0; i < glyphSet->hash.hashSet->size; i++) {
+ GlyphRefPtr gr = &table[i];
+ GlyphPtr gl = gr->glyph;
+
+ if (!gl || gl == DeletedGlyph) continue;
+
+ /* First lets put the data into gids */
+ gids[ctr] = gr->signature;
+
+ /* Next do the glyphs data structures */
+ glyphs[ctr].width = gl->info.width;
+ glyphs[ctr].height = gl->info.height;
+ glyphs[ctr].x = gl->info.x;
+ glyphs[ctr].y = gl->info.y;
+ glyphs[ctr].xOff = gl->info.xOff;
+ glyphs[ctr].yOff = gl->info.yOff;
+
+ /* Copy the images from the DIX's data into the buffer */
+ memcpy(pos, gl+1, gl->size - sizeof(gl->info));
+ pos += gl->size - sizeof(gl->info);
+ ctr++;
+ }
+
+ /* Now restore the glyph data */
+ XRenderAddGlyphs(dmxScreen->beDisplay, glyphPriv->glyphSets[scrnNum],
+ gids,glyphs, glyphSet->hash.tableEntries, images,
+ len_images);
+
+ /* Clean up */
+ free(images);
+ free(gids);
+ free(glyphs);
+}
+
+/** Reattach previously detached back-end screen. */
+int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr)
+{
+ ScreenPtr pScreen;
+ DMXScreenInfo *dmxScreen;
+ CARD32 scrnNum = idx;
+ DMXScreenInfo oldDMXScreen;
+ int i;
+
+ /* Return failure if dynamic addition/removal of screens is disabled */
+ if (!dmxAddRemoveScreens) {
+ dmxLog(dmxWarning,
+ "Attempting to add a screen, but the AddRemoveScreen\n");
+ dmxLog(dmxWarning,
+ "extension has not been enabled. To enable this extension\n");
+ dmxLog(dmxWarning,
+ "add the \"-addremovescreens\" option either to the command\n");
+ dmxLog(dmxWarning,
+ "line or in the configuration file.\n");
+ return 1;
+ }
+
+ /* Cannot add a screen that does not exist */
+ if (idx < 0 || idx >= dmxNumScreens) return 1;
+ pScreen = screenInfo.screens[idx];
+ dmxScreen = &dmxScreens[idx];
+
+ /* Cannot attach to a screen that is already opened */
+ if (dmxScreen->beDisplay) {
+ dmxLog(dmxWarning,
+ "Attempting to add screen #%d but a screen already exists\n",
+ idx);
+ return 1;
+ }
+
+ dmxLogOutput(dmxScreen, "Attaching screen #%d\n", idx);
+
+ /* Save old info */
+ oldDMXScreen = *dmxScreen;
+
+ /* Copy the name to the new screen */
+ dmxScreen->name = strdup(attr->displayName);
+
+ /* Open display and get all of the screen info */
+ if (!dmxOpenDisplay(dmxScreen)) {
+ dmxLog(dmxWarning,
+ "dmxOpenDisplay: Unable to open display %s\n",
+ dmxScreen->name);
+
+ /* Restore the old screen */
+ *dmxScreen = oldDMXScreen;
+ return 1;
+ }
+
+ dmxSetErrorHandler(dmxScreen);
+ dmxCheckForWM(dmxScreen);
+ dmxGetScreenAttribs(dmxScreen);
+
+ if (!dmxGetVisualInfo(dmxScreen)) {
+ dmxLog(dmxWarning, "dmxGetVisualInfo: No matching visuals found\n");
+ XFree(dmxScreen->beVisuals);
+ XCloseDisplay(dmxScreen->beDisplay);
+
+ /* Restore the old screen */
+ *dmxScreen = oldDMXScreen;
+ return 1;
+ }
+
+ dmxGetColormaps(dmxScreen);
+ dmxGetPixmapFormats(dmxScreen);
+
+ /* Verify that the screen to be added has the same info as the
+ * previously added screen. */
+ if (!dmxCompareScreens(dmxScreen, &oldDMXScreen)) {
+ dmxLog(dmxWarning,
+ "New screen data (%s) does not match previously\n",
+ dmxScreen->name);
+ dmxLog(dmxWarning,
+ "attached screen data (%s)\n",
+ oldDMXScreen.name);
+ dmxLog(dmxWarning,
+ "All data must match in order to attach to screen #%d\n",
+ idx);
+ XFree(dmxScreen->beVisuals);
+ XFree(dmxScreen->beDepths);
+ XFree(dmxScreen->bePixmapFormats);
+ XCloseDisplay(dmxScreen->beDisplay);
+
+ /* Restore the old screen */
+ *dmxScreen = oldDMXScreen;
+ return 1;
+ }
+
+ /* Initialize the BE screen resources */
+ dmxBEScreenInit(idx, screenInfo.screens[idx]);
+
+ /* TODO: Handle GLX visual initialization. GLXProxy needs to be
+ * updated to handle dynamic addition/removal of screens. */
+
+ /* Create default stipple */
+ dmxBECreatePixmap(pScreen->PixmapPerDepth[0]);
+ dmxBERestorePixmap(pScreen->PixmapPerDepth[0]);
+
+ /* Create the scratch GCs */
+ dmxBECreateScratchGCs(idx);
+
+ /* Create the default font */
+ (void)dmxBELoadFont(pScreen, defaultFont);
+
+ /* Create all resources that don't depend on windows */
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBECreateResources,
+ (pointer)idx);
+
+ /* Create window hierarchy (top down) */
+ dmxBECreateWindowTree(idx);
+
+ /* Restore the picture state for RENDER */
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindClientResourcesByType(clients[i],PictureType,
+ dmxBERestoreRenderPict,(pointer)idx);
+
+ /* Restore the glyph state for RENDER */
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindClientResourcesByType(clients[i],GlyphSetType,
+ dmxBERestoreRenderGlyph,(pointer)idx);
+
+ /* Refresh screen by generating exposure events for all windows */
+ dmxForceExposures(idx);
+
+ dmxSync(&dmxScreens[idx], TRUE);
+
+ /* We used these to compare the old and new screens. They are no
+ * longer needed since we have a newly attached screen, so we can
+ * now free the old screen's resources. */
+ XFree(oldDMXScreen.beVisuals);
+ XFree(oldDMXScreen.beDepths);
+ XFree(oldDMXScreen.bePixmapFormats);
+ /* TODO: should oldDMXScreen.name be freed?? */
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension)
+ return dmxConfigureScreenWindows(1, &scrnNum, attr, NULL);
+ else
+#endif
+ return 0; /* Success */
+}
+
+/*
+ * Resources that may have state on the BE server and need to be freed:
+ *
+ * RT_NONE
+ * RT_WINDOW
+ * RT_PIXMAP
+ * RT_GC
+ * RT_FONT
+ * RT_CURSOR
+ * RT_COLORMAP
+ * RT_CMAPENTRY
+ * RT_OTHERCLIENT
+ * RT_PASSIVEGRAB
+ * XRT_WINDOW
+ * XRT_PIXMAP
+ * XRT_GC
+ * XRT_COLORMAP
+ * XRT_PICTURE
+ * PictureType
+ * PictFormatType
+ * GlyphSetType
+ * ClientType
+ * EventType
+ * RT_INPUTCLIENT
+ * XETrapType
+ * RTCounter
+ * RTAwait
+ * RTAlarmClient
+ * RT_XKBCLIENT
+ * RTContext
+ * TagResType
+ * StalledResType
+ * SecurityAuthorizationResType
+ * RTEventClient
+ * __glXContextRes
+ * __glXClientRes
+ * __glXPixmapRes
+ * __glXWindowRes
+ * __glXPbufferRes
+ */
+
+#ifdef PANORAMIX
+/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs
+ * to have its image saved. */
+static void dmxBEFindPixmapImage(pointer value, XID id, RESTYPE type,
+ pointer p)
+{
+ if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) {
+ PixmapPtr pDst = (PixmapPtr)p;
+ int idx = pDst->drawable.pScreen->myNum;
+ PanoramiXRes *pXinPix = (PanoramiXRes *)value;
+ PixmapPtr pPix;
+ int i;
+
+ pPix = (PixmapPtr)LookupIDByType(pXinPix->info[idx].id, RT_PIXMAP);
+ if (pPix != pDst) return; /* Not a match.... Next! */
+
+ for (i = 0; i < PanoramiXNumScreens; i++) {
+ PixmapPtr pSrc;
+ dmxPixPrivPtr pSrcPriv = NULL;
+
+ if (i == idx) continue; /* Self replication is bad */
+
+ pSrc =
+ (PixmapPtr)LookupIDByType(pXinPix->info[i].id, RT_PIXMAP);
+ pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
+ if (pSrcPriv->pixmap) {
+ FoundPixImage = True;
+ return;
+ }
+ }
+ }
+}
+#endif
+
+/** Save the pixmap image only when there is not another screen with
+ * that pixmap from which the image can be read when the screen is
+ * reattached. To do this, we first try to find a pixmap on another
+ * screen corresponding to the one we are trying to save. If we find
+ * one, then we do not need to save the image data since during
+ * reattachment, the image data can be read from that other pixmap.
+ * However, if we do not find one, then we need to save the image data.
+ * The common case for these are for the default stipple and root
+ * tile. */
+static void dmxBESavePixmap(PixmapPtr pPixmap)
+{
+#ifdef PANORAMIX
+ int i;
+
+ /* If Xinerama is not active, there's nothing we can do (see comment
+ * in #else below for more info). */
+ if (noPanoramiXExtension) return;
+
+ FoundPixImage = False;
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBEFindPixmapImage,
+ (pointer)pPixmap);
+
+ /* Save the image only if there is no other screens that have a
+ * pixmap that corresponds to the one we are trying to save. */
+ if (!FoundPixImage) {
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
+
+ if (!pPixPriv->detachedImage) {
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+
+ pPixPriv->detachedImage = XGetImage(dmxScreen->beDisplay,
+ pPixPriv->pixmap,
+ 0, 0,
+ pPixmap->drawable.width,
+ pPixmap->drawable.height,
+ -1,
+ ZPixmap);
+ if (!pPixPriv->detachedImage)
+ dmxLog(dmxWarning, "Cannot save pixmap image\n");
+ }
+ }
+#else
+ /* NOTE: The only time there is a pixmap on another screen that
+ * corresponds to the one we are trying to save is when Xinerama is
+ * active. Otherwise, the pixmap image data is only stored on a
+ * single screen, which means that once it is detached, that data is
+ * lost. We could save the data here, but then that would require
+ * us to implement the ability for Xdmx to keep the pixmap up to
+ * date while the screen is detached, which is beyond the scope of
+ * the current project. */
+ return;
+#endif
+}
+
+/** Destroy resources on the back-end server. This function is called
+ * from #dmxDetachScreen() via the dix layer's FindAllResources
+ * function. It walks all resources, compares them to the screen
+ * number passed in as \a n and calls the appropriate DMX function to
+ * free the associated resource on the back-end server. */
+static void dmxBEDestroyResources(pointer value, XID id, RESTYPE type,
+ pointer n)
+{
+ int scrnNum = (int)n;
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+
+ if ((type & TypeMask) == (RT_WINDOW & TypeMask)) {
+ /* Window resources are destroyed below in dmxBEDestroyWindowTree */
+ } else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) {
+ PixmapPtr pPix = value;
+ if (pPix->drawable.pScreen->myNum == scrnNum) {
+ dmxBESavePixmap(pPix);
+ dmxBEFreePixmap(pPix);
+ }
+ } else if ((type & TypeMask) == (RT_GC & TypeMask)) {
+ GCPtr pGC = value;
+ if (pGC->pScreen->myNum == scrnNum)
+ dmxBEFreeGC(pGC);
+ } else if ((type & TypeMask) == (RT_FONT & TypeMask)) {
+ dmxBEFreeFont(pScreen, (FontPtr)value);
+ } else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) {
+ dmxBEFreeCursor(pScreen, (CursorPtr)value);
+ } else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) {
+ ColormapPtr pCmap = value;
+ if (pCmap->pScreen->myNum == scrnNum)
+ dmxBEFreeColormap((ColormapPtr)value);
+ } else if ((type & TypeMask) == (PictureType & TypeMask)) {
+ PicturePtr pPict = value;
+ if (pPict->pDrawable->pScreen->myNum == scrnNum) {
+ /* Free the pixmaps on the backend if needed */
+ if (pPict->pDrawable->type == DRAWABLE_PIXMAP) {
+ PixmapPtr pPixmap = (PixmapPtr)(pPict->pDrawable);
+ dmxBESavePixmap(pPixmap);
+ dmxBEFreePixmap(pPixmap);
+ }
+ dmxBEFreePicture((PicturePtr)value);
+ }
+ } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
+ dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
+ } else {
+ /* Other resource types??? */
+ }
+}
+
+/** Destroy the scratch GCs that are created per depth. */
+static void dmxBEDestroyScratchGCs(int scrnNum)
+{
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+ GCPtr *ppGC = pScreen->GCperDepth;
+ int i;
+
+ for (i = 0; i <= pScreen->numDepths; i++)
+ dmxBEFreeGC(ppGC[i]);
+}
+
+/** Destroy window hierachy on back-end server. To ensure that all
+ * XDestroyWindow() calls succeed, they must be performed in a bottom
+ * up order so that windows are not destroyed before their children.
+ * XDestroyWindow(), which is called from #dmxBEDestroyWindow(), will
+ * destroy a window as well as all of it's children. */
+static void dmxBEDestroyWindowTree(int idx)
+{
+ WindowPtr pWin = screenInfo.screens[idx]->root;
+ WindowPtr pChild = pWin;
+
+ while (1) {
+ if (pChild->firstChild) {
+ pChild = pChild->firstChild;
+ continue;
+ }
+
+ /* Destroy the window */
+ dmxBEDestroyWindow(pChild);
+
+ /* Make sure we destroy the window's border and background
+ * pixmaps if they exist */
+ if (!pChild->borderIsPixel) {
+ dmxBESavePixmap(pChild->border.pixmap);
+ dmxBEFreePixmap(pChild->border.pixmap);
+ }
+ if (pChild->backgroundState == BackgroundPixmap) {
+ dmxBESavePixmap(pChild->background.pixmap);
+ dmxBEFreePixmap(pChild->background.pixmap);
+ }
+
+ while (!pChild->nextSib && (pChild != pWin)) {
+ pChild = pChild->parent;
+ dmxBEDestroyWindow(pChild);
+ if (!pChild->borderIsPixel) {
+ dmxBESavePixmap(pChild->border.pixmap);
+ dmxBEFreePixmap(pChild->border.pixmap);
+ }
+ if (pChild->backgroundState == BackgroundPixmap) {
+ dmxBESavePixmap(pChild->background.pixmap);
+ dmxBEFreePixmap(pChild->background.pixmap);
+ }
+ }
+
+ if (pChild == pWin)
+ break;
+
+ pChild = pChild->nextSib;
+ }
+}
+
+/** Detach back-end screen. */
+int dmxDetachScreen(int idx)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ int i;
+
+ /* Return failure if dynamic addition/removal of screens is disabled */
+ if (!dmxAddRemoveScreens) {
+ dmxLog(dmxWarning,
+ "Attempting to remove a screen, but the AddRemoveScreen\n");
+ dmxLog(dmxWarning,
+ "extension has not been enabled. To enable this extension\n");
+ dmxLog(dmxWarning,
+ "add the \"-addremovescreens\" option either to the command\n");
+ dmxLog(dmxWarning,
+ "line or in the configuration file.\n");
+ return 1;
+ }
+
+ /* Cannot remove a screen that does not exist */
+ if (idx < 0 || idx >= dmxNumScreens) return 1;
+
+ /* Cannot detach from a screen that is not opened */
+ if (!dmxScreen->beDisplay) {
+ dmxLog(dmxWarning,
+ "Attempting to remove screen #%d but it has not been opened\n",
+ idx);
+ return 1;
+ }
+
+ dmxLogOutput(dmxScreen, "Detaching screen #%d\n", idx);
+
+ /* Detach input */
+ dmxInputDetachAll(dmxScreen);
+
+ /* Save all relevant state (TODO) */
+
+ /* Free all non-window resources related to this screen */
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBEDestroyResources,
+ (pointer)idx);
+
+ /* Free scratch GCs */
+ dmxBEDestroyScratchGCs(idx);
+
+ /* Free window resources related to this screen */
+ dmxBEDestroyWindowTree(idx);
+
+ /* Free default stipple */
+ dmxBESavePixmap(screenInfo.screens[idx]->PixmapPerDepth[0]);
+ dmxBEFreePixmap(screenInfo.screens[idx]->PixmapPerDepth[0]);
+
+ /* Free the remaining screen resources and close the screen */
+ dmxBECloseScreen(screenInfo.screens[idx]);
+
+ /* Adjust the cursor boundaries (paints detached console window) */
+ dmxAdjustCursorBoundaries();
+
+ return 0; /* Success */
+}
diff --git a/xorg-server/hw/dmx/dmxfont.c b/xorg-server/hw/dmx/dmxfont.c index 3f0264edb..8b57b6f3b 100644 --- a/xorg-server/hw/dmx/dmxfont.c +++ b/xorg-server/hw/dmx/dmxfont.c @@ -108,7 +108,7 @@ static Bool dmxCheckFontPathElement(DMXScreenInfo *dmxScreen, char *fp) dmxSync(dmxScreen, TRUE); /* Must complete before removing handler */
XSetErrorHandler(oldErrorHandler);
- return (dmxFontLastError == 0);
+ return dmxFontLastError == 0;
}
static int dmxSetFontPath(DMXScreenInfo *dmxScreen)
diff --git a/xorg-server/hw/dmx/dmxgc.c b/xorg-server/hw/dmx/dmxgc.c index 82f74b6e6..10e93c110 100644 --- a/xorg-server/hw/dmx/dmxgc.c +++ b/xorg-server/hw/dmx/dmxgc.c @@ -85,7 +85,7 @@ static GCOps dmxGCOps = { /** Initialize the GC on \a pScreen */
Bool dmxInitGC(ScreenPtr pScreen)
{
- if (!dixRequestPrivate(dmxGCPrivateKey, sizeof(dmxGCPrivRec)))
+ if (!dixRegisterPrivateKey(&dmxGCPrivateKeyRec, PRIVATE_GC, sizeof(dmxGCPrivRec)))
return FALSE;
return TRUE;
}
@@ -363,9 +363,9 @@ void dmxChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects) case CT_REGION:
if (dmxScreen->beDisplay) {
- nRects = REGION_NUM_RECTS((RegionPtr)pGC->clientClip);
+ nRects = RegionNumRects((RegionPtr)pGC->clientClip);
pRects = malloc(nRects * sizeof(*pRects));
- pBox = REGION_RECTS((RegionPtr)pGC->clientClip);
+ pBox = RegionRects((RegionPtr)pGC->clientClip);
for (i = 0; i < nRects; i++) {
pRects[i].x = pBox[i].x1;
diff --git a/xorg-server/hw/dmx/dmxgc.h b/xorg-server/hw/dmx/dmxgc.h index 2da3ba85e..43a6296af 100644 --- a/xorg-server/hw/dmx/dmxgc.h +++ b/xorg-server/hw/dmx/dmxgc.h @@ -1,89 +1,86 @@ -/* - * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Kevin E. Martin <kem@redhat.com> - * - */ - -/** \file - * Interface for GC support. \see dmxgc.c */ - -#ifndef DMXGC_H -#define DMXGC_H - -#include "gcstruct.h" - -/** GC private area. */ -typedef struct _dmxGCPriv { - GCOps *ops; - GCFuncs *funcs; - XlibGC gc; - Bool msc; -} dmxGCPrivRec, *dmxGCPrivPtr; - - -extern Bool dmxInitGC(ScreenPtr pScreen); - -extern Bool dmxCreateGC(GCPtr pGC); -extern void dmxValidateGC(GCPtr pGC, unsigned long changes, - DrawablePtr pDrawable); -extern void dmxChangeGC(GCPtr pGC, unsigned long mask); -extern void dmxCopyGC(GCPtr pGCSrc, unsigned long changes, GCPtr pGCDst); -extern void dmxDestroyGC(GCPtr pGC); -extern void dmxChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects); -extern void dmxDestroyClip(GCPtr pGC); -extern void dmxCopyClip(GCPtr pGCDst, GCPtr pGCSrc); - -extern void dmxBECreateGC(ScreenPtr pScreen, GCPtr pGC); -extern Bool dmxBEFreeGC(GCPtr pGC); - -/** Private index. \see dmxgc.c \see dmxscrinit.c */ -extern DevPrivateKey dmxGCPrivateKey; - -/** Get private. */ -#define DMX_GET_GC_PRIV(_pGC) \ - (dmxGCPrivPtr)dixLookupPrivate(&(_pGC)->devPrivates, dmxGCPrivateKey) - -#define DMX_GC_FUNC_PROLOGUE(_pGC) \ -do { \ - dmxGCPrivPtr _pGCPriv = DMX_GET_GC_PRIV(_pGC); \ - DMX_UNWRAP(funcs, _pGCPriv, (_pGC)); \ - if (_pGCPriv->ops) \ - DMX_UNWRAP(ops, _pGCPriv, (_pGC)); \ -} while (0) - -#define DMX_GC_FUNC_EPILOGUE(_pGC) \ -do { \ - dmxGCPrivPtr _pGCPriv = DMX_GET_GC_PRIV(_pGC); \ - DMX_WRAP(funcs, &dmxGCFuncs, _pGCPriv, (_pGC)); \ - if (_pGCPriv->ops) \ - DMX_WRAP(ops, &dmxGCOps, _pGCPriv, (_pGC)); \ -} while (0) - -#endif /* DMXGC_H */ +/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for GC support. \see dmxgc.c */
+
+#ifndef DMXGC_H
+#define DMXGC_H
+
+#include "gcstruct.h"
+
+/** GC private area. */
+typedef struct _dmxGCPriv {
+ GCOps *ops;
+ GCFuncs *funcs;
+ XlibGC gc;
+ Bool msc;
+} dmxGCPrivRec, *dmxGCPrivPtr;
+
+
+extern Bool dmxInitGC(ScreenPtr pScreen);
+
+extern Bool dmxCreateGC(GCPtr pGC);
+extern void dmxValidateGC(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDrawable);
+extern void dmxChangeGC(GCPtr pGC, unsigned long mask);
+extern void dmxCopyGC(GCPtr pGCSrc, unsigned long changes, GCPtr pGCDst);
+extern void dmxDestroyGC(GCPtr pGC);
+extern void dmxChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects);
+extern void dmxDestroyClip(GCPtr pGC);
+extern void dmxCopyClip(GCPtr pGCDst, GCPtr pGCSrc);
+
+extern void dmxBECreateGC(ScreenPtr pScreen, GCPtr pGC);
+extern Bool dmxBEFreeGC(GCPtr pGC);
+
+/** Get private. */
+#define DMX_GET_GC_PRIV(_pGC) \
+ (dmxGCPrivPtr)dixLookupPrivate(&(_pGC)->devPrivates, dmxGCPrivateKey)
+
+#define DMX_GC_FUNC_PROLOGUE(_pGC) \
+do { \
+ dmxGCPrivPtr _pGCPriv = DMX_GET_GC_PRIV(_pGC); \
+ DMX_UNWRAP(funcs, _pGCPriv, (_pGC)); \
+ if (_pGCPriv->ops) \
+ DMX_UNWRAP(ops, _pGCPriv, (_pGC)); \
+} while (0)
+
+#define DMX_GC_FUNC_EPILOGUE(_pGC) \
+do { \
+ dmxGCPrivPtr _pGCPriv = DMX_GET_GC_PRIV(_pGC); \
+ DMX_WRAP(funcs, &dmxGCFuncs, _pGCPriv, (_pGC)); \
+ if (_pGCPriv->ops) \
+ DMX_WRAP(ops, &dmxGCOps, _pGCPriv, (_pGC)); \
+} while (0)
+
+#endif /* DMXGC_H */
diff --git a/xorg-server/hw/dmx/dmxgcops.c b/xorg-server/hw/dmx/dmxgcops.c index 267a306db..02b45a213 100644 --- a/xorg-server/hw/dmx/dmxgcops.c +++ b/xorg-server/hw/dmx/dmxgcops.c @@ -1,603 +1,603 @@ -/* - * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Kevin E. Martin <kem@redhat.com> - * - */ - -/** \file - * This file provides support for GC operations. */ - -#ifdef HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#include "dmx.h" -#include "dmxsync.h" -#include "dmxgc.h" -#include "dmxgcops.h" -#include "dmxwindow.h" -#include "dmxpixmap.h" - -#include "mi.h" -#include "gcstruct.h" -#include "pixmapstr.h" -#include "dixfontstr.h" - -#ifdef PANORAMIX -#include "panoramiXsrv.h" -#endif - -#define DMX_GCOPS_SET_DRAWABLE(_pDraw, _draw) \ -do { \ - if ((_pDraw)->type == DRAWABLE_WINDOW) { \ - dmxWinPrivPtr pWinPriv = \ - DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw)); \ - (_draw) = (Drawable)pWinPriv->window; \ - } else { \ - dmxPixPrivPtr pPixPriv = \ - DMX_GET_PIXMAP_PRIV((PixmapPtr)(_pDraw)); \ - (_draw) = (Drawable)pPixPriv->pixmap; \ - } \ -} while (0) - -#define DMX_GCOPS_OFFSCREEN(_pDraw) \ - (!dmxScreens[(_pDraw)->pScreen->myNum].beDisplay || \ - (dmxOffScreenOpt && \ - (_pDraw)->type == DRAWABLE_WINDOW && \ - (DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw))->offscreen || \ - !DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw))->window))) - -/** Fill spans -- this function should never be called. */ -void dmxFillSpans(DrawablePtr pDrawable, GCPtr pGC, - int nInit, DDXPointPtr pptInit, int *pwidthInit, - int fSorted) -{ - /* Error -- this should never happen! */ -} - -/** Set spans -- this function should never be called. */ -void dmxSetSpans(DrawablePtr pDrawable, GCPtr pGC, - char *psrc, DDXPointPtr ppt, int *pwidth, int nspans, - int fSorted) -{ - /* Error -- this should never happen! */ -} - -/** Transfer \a pBits image to back-end server associated with \a - * pDrawable's screen. If primitive subdivision optimization is - * enabled, then only transfer the sections of \a pBits that are - * visible (i.e., not-clipped) to the back-end server. */ -void dmxPutImage(DrawablePtr pDrawable, GCPtr pGC, - int depth, int x, int y, int w, int h, - int leftPad, int format, char *pBits) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - XImage *img; - - if (DMX_GCOPS_OFFSCREEN(pDrawable)) return; - - img = XCreateImage(dmxScreen->beDisplay, - dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual, - depth, format, leftPad, pBits, w, h, - BitmapPad(dmxScreen->beDisplay), - (format == ZPixmap) ? - PixmapBytePad(w, depth) : BitmapBytePad(w+leftPad)); - - if (img) { - Drawable draw; - - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - if (dmxSubdividePrimitives && pGC->pCompositeClip) { - RegionPtr pSubImages; - RegionPtr pClip; - BoxRec box; - BoxPtr pBox; - int nBox; - - box.x1 = x; - box.y1 = y; - box.x2 = x + w; - box.y2 = y + h; - pSubImages = REGION_CREATE(pGC->pScreen, &box, 1); - - pClip = REGION_CREATE(pGC->pScreen, NullBox, 1); - REGION_COPY(pGC->pScreen, pClip, pGC->pCompositeClip); - REGION_TRANSLATE(pGC->pScreen, pClip, - -pDrawable->x, -pDrawable->y); - REGION_INTERSECT(pGC->pScreen, pSubImages, pSubImages, pClip); - - nBox = REGION_NUM_RECTS(pSubImages); - pBox = REGION_RECTS(pSubImages); - - while (nBox--) { - XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc, img, - pBox->x1 - box.x1, - pBox->y1 - box.y1, - pBox->x1, - pBox->y1, - pBox->x2 - pBox->x1, - pBox->y2 - pBox->y1); - pBox++; - } - REGION_DESTROY(pGC->pScreen, pClip); - REGION_DESTROY(pGC->pScreen, pSubImages); - } else { - XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc, - img, 0, 0, x, y, w, h); - } - XFree(img); /* Use XFree instead of XDestroyImage - * because pBits is passed in from the - * caller. */ - - dmxSync(dmxScreen, FALSE); - } else { - /* Error -- this should not happen! */ - } -} - -/** Copy area from \a pSrc drawable to \a pDst drawable on the back-end - * server associated with \a pSrc drawable's screen. If the offscreen - * optimization is enabled, only copy when both \a pSrc and \a pDst are - * at least partially visible. */ -RegionPtr dmxCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, - int srcx, int srcy, int w, int h, int dstx, int dsty) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pSrc->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable srcDraw, dstDraw; - - if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst)) - return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h, - dstx, dsty, 0L); - - DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw); - DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw); - - XCopyArea(dmxScreen->beDisplay, srcDraw, dstDraw, pGCPriv->gc, - srcx, srcy, w, h, dstx, dsty); - dmxSync(dmxScreen, FALSE); - - return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h, - dstx, dsty, 0L); -} - -/** Copy plane number \a bitPlane from \a pSrc drawable to \a pDst - * drawable on the back-end server associated with \a pSrc drawable's - * screen. If the offscreen optimization is enabled, only copy when - * both \a pSrc and \a pDst are at least partially visible. */ -RegionPtr dmxCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, - int srcx, int srcy, int width, int height, - int dstx, int dsty, unsigned long bitPlane) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pSrc->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable srcDraw, dstDraw; - - if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst)) - return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height, - dstx, dsty, bitPlane); - - DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw); - DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw); - - XCopyPlane(dmxScreen->beDisplay, srcDraw, dstDraw, pGCPriv->gc, - srcx, srcy, width, height, dstx, dsty, bitPlane); - dmxSync(dmxScreen, FALSE); - - return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height, - dstx, dsty, bitPlane); -} - -/** Render list of points, \a pptInit in \a pDrawable on the back-end - * server associated with \a pDrawable's screen. If the offscreen - * optimization is enabled, only draw when \a pDrawable is at least - * partially visible. */ -void dmxPolyPoint(DrawablePtr pDrawable, GCPtr pGC, - int mode, int npt, DDXPointPtr pptInit) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable draw; - - if (DMX_GCOPS_OFFSCREEN(pDrawable)) return; - - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XDrawPoints(dmxScreen->beDisplay, draw, pGCPriv->gc, - (XPoint *)pptInit, npt, mode); - dmxSync(dmxScreen, FALSE); -} - -/** Render list of connected lines, \a pptInit in \a pDrawable on the - * back-end server associated with \a pDrawable's screen. If the - * offscreen optimization is enabled, only draw when \a pDrawable is at - * least partially visible. */ -void dmxPolylines(DrawablePtr pDrawable, GCPtr pGC, - int mode, int npt, DDXPointPtr pptInit) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable draw; - - if (DMX_GCOPS_OFFSCREEN(pDrawable)) return; - - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XDrawLines(dmxScreen->beDisplay, draw, pGCPriv->gc, - (XPoint *)pptInit, npt, mode); - dmxSync(dmxScreen, FALSE); -} - -/** Render list of disjoint segments, \a pSegs in \a pDrawable on the - * back-end server associated with \a pDrawable's screen. If the - * offscreen optimization is enabled, only draw when \a pDrawable is at - * least partially visible. */ -void dmxPolySegment(DrawablePtr pDrawable, GCPtr pGC, - int nseg, xSegment *pSegs) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable draw; - - if (DMX_GCOPS_OFFSCREEN(pDrawable)) return; - - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XDrawSegments(dmxScreen->beDisplay, draw, pGCPriv->gc, - (XSegment *)pSegs, nseg); - dmxSync(dmxScreen, FALSE); -} - -/** Render list of rectangle outlines, \a pRects in \a pDrawable on the - * back-end server associated with \a pDrawable's screen. If the - * offscreen optimization is enabled, only draw when \a pDrawable is at - * least partially visible. */ -void dmxPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, - int nrects, xRectangle *pRects) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable draw; - - if (DMX_GCOPS_OFFSCREEN(pDrawable)) return; - - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XDrawRectangles(dmxScreen->beDisplay, draw, pGCPriv->gc, - (XRectangle *)pRects, nrects); - - dmxSync(dmxScreen, FALSE); -} - -/** Render list of arc outlines, \a parcs in \a pDrawable on the - * back-end server associated with \a pDrawable's screen. If the - * offscreen optimization is enabled, only draw when \a pDrawable is at - * least partially visible. */ -void dmxPolyArc(DrawablePtr pDrawable, GCPtr pGC, - int narcs, xArc *parcs) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable draw; - - if (DMX_GCOPS_OFFSCREEN(pDrawable)) return; - - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XDrawArcs(dmxScreen->beDisplay, draw, pGCPriv->gc, - (XArc *)parcs, narcs); - dmxSync(dmxScreen, FALSE); -} - -/** Render a filled polygons in \a pDrawable on the back-end server - * associated with \a pDrawable's screen. If the offscreen - * optimization is enabled, only draw when \a pDrawable is at least - * partially visible. */ -void dmxFillPolygon(DrawablePtr pDrawable, GCPtr pGC, - int shape, int mode, int count, DDXPointPtr pPts) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable draw; - - if (DMX_GCOPS_OFFSCREEN(pDrawable)) return; - - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XFillPolygon(dmxScreen->beDisplay, draw, pGCPriv->gc, - (XPoint *)pPts, count, shape, mode); - dmxSync(dmxScreen, FALSE); -} - -/** Render list of filled rectangles, \a prectInit in \a pDrawable on - * the back-end server associated with \a pDrawable's screen. If the - * offscreen optimization is enabled, only draw when \a pDrawable is at - * least partially visible. */ -void dmxPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, - int nrectFill, xRectangle *prectInit) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable draw; - - if (DMX_GCOPS_OFFSCREEN(pDrawable)) return; - - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XFillRectangles(dmxScreen->beDisplay, draw, pGCPriv->gc, - (XRectangle *)prectInit, nrectFill); - dmxSync(dmxScreen, FALSE); -} - -/** Render list of filled arcs, \a parcs in \a pDrawable on the back-end - * server associated with \a pDrawable's screen. If the offscreen - * optimization is enabled, only draw when \a pDrawable is at least - * partially visible. */ -void dmxPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, - int narcs, xArc *parcs) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable draw; - - if (DMX_GCOPS_OFFSCREEN(pDrawable)) return; - - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XFillArcs(dmxScreen->beDisplay, draw, pGCPriv->gc, - (XArc *)parcs, narcs); - dmxSync(dmxScreen, FALSE); -} - -/** Render string of 8-bit \a chars (foreground only) in \a pDrawable on - * the back-end server associated with \a pDrawable's screen. If the - * offscreen optimization is enabled, only draw when \a pDrawable is at - * least partially visible. */ -int dmxPolyText8(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, char *chars) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - unsigned long n, i; - int w; - CharInfoPtr charinfo[255]; - Drawable draw; - - GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars, - Linear8Bit, &n, charinfo); - - /* Calculate text width */ - w = 0; - for (i = 0; i < n; i++) w += charinfo[i]->metrics.characterWidth; - - if (n != 0 && !DMX_GCOPS_OFFSCREEN(pDrawable)) { - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XDrawString(dmxScreen->beDisplay, draw, pGCPriv->gc, - x, y, chars, count); - dmxSync(dmxScreen, FALSE); - } - - return x+w; -} - -/** Render string of 16-bit \a chars (foreground only) in \a pDrawable - * on the back-end server associated with \a pDrawable's screen. If - * the offscreen optimization is enabled, only draw when \a pDrawable - * is at least partially visible. */ -int dmxPolyText16(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, unsigned short *chars) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - unsigned long n, i; - int w; - CharInfoPtr charinfo[255]; - Drawable draw; - - GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars, - (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit, - &n, charinfo); - - /* Calculate text width */ - w = 0; - for (i = 0; i < n; i++) w += charinfo[i]->metrics.characterWidth; - - if (n != 0 && !DMX_GCOPS_OFFSCREEN(pDrawable)) { - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XDrawString16(dmxScreen->beDisplay, draw, pGCPriv->gc, - x, y, (XChar2b *)chars, count); - dmxSync(dmxScreen, FALSE); - } - - return x+w; -} - -/** Render string of 8-bit \a chars (both foreground and background) in - * \a pDrawable on the back-end server associated with \a pDrawable's - * screen. If the offscreen optimization is enabled, only draw when \a - * pDrawable is at least partially visible. */ -void dmxImageText8(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, char *chars) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable draw; - - if (DMX_GCOPS_OFFSCREEN(pDrawable)) return; - - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XDrawImageString(dmxScreen->beDisplay, draw, pGCPriv->gc, - x, y, chars, count); - dmxSync(dmxScreen, FALSE); -} - -/** Render string of 16-bit \a chars (both foreground and background) in - * \a pDrawable on the back-end server associated with \a pDrawable's - * screen. If the offscreen optimization is enabled, only draw when \a - * pDrawable is at least partially visible. */ -void dmxImageText16(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, unsigned short *chars) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); - Drawable draw; - - if (DMX_GCOPS_OFFSCREEN(pDrawable)) return; - - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - - XDrawImageString16(dmxScreen->beDisplay, draw, pGCPriv->gc, - x, y, (XChar2b *)chars, count); - dmxSync(dmxScreen, FALSE); -} - -/** Image Glyph Blt -- this function should never be called. */ -void dmxImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, pointer pglyphBase) -{ - /* Error -- this should never happen! */ -} - -/** Poly Glyph Blt -- this function should never be called. */ -void dmxPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, pointer pglyphBase) -{ - /* Error -- this should never happen! */ -} - -/** Push Pixels -- this function should never be called. */ -void dmxPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, - int w, int h, int x, int y) -{ - /* Error -- this should never happen! */ -} - -/********************************************************************** - * Miscellaneous drawing commands - */ - -/** When Xinerama is active, the client pixmaps are always obtained from - * screen 0. When screen 0 is detached, the pixmaps must be obtained - * from any other screen that is not detached. Usually, this is screen - * 1. */ -static DMXScreenInfo *dmxFindAlternatePixmap(DrawablePtr pDrawable, XID *draw) -{ -#ifdef PANORAMIX - PanoramiXRes *pXinPix; - int i; - DMXScreenInfo *dmxScreen; - - if (noPanoramiXExtension) return NULL; - if (pDrawable->type != DRAWABLE_PIXMAP) return NULL; - - if (!(pXinPix = (PanoramiXRes *)LookupIDByType(pDrawable->id, XRT_PIXMAP))) - return NULL; - - for (i = 1; i < PanoramiXNumScreens; i++) { - dmxScreen = &dmxScreens[i]; - if (dmxScreen->beDisplay) { - PixmapPtr pSrc; - dmxPixPrivPtr pSrcPriv; - - pSrc = (PixmapPtr)LookupIDByType(pXinPix->info[i].id, - RT_PIXMAP); - pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc); - if (pSrcPriv->pixmap) { - *draw = pSrcPriv->pixmap; - return dmxScreen; - } - } - } -#endif - return NULL; -} - -/** Get an image from the back-end server associated with \a pDrawable's - * screen. If \a pDrawable is a window, it must be viewable to get an - * image from it. If it is not viewable, then get the image from the - * first ancestor of \a pDrawable that is viewable. If no viewable - * ancestor is found, then simply return without getting an image. */ -void dmxGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, - unsigned int format, unsigned long planeMask, char *pdstLine) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum]; - XImage *img; - Drawable draw; - - /* Cannot get image from unviewable window */ - if (pDrawable->type == DRAWABLE_WINDOW) { - WindowPtr pWindow = (WindowPtr)pDrawable; - if (!pWindow->viewable) { - while (!pWindow->viewable && pWindow->parent) { - sx += pWindow->origin.x - wBorderWidth(pWindow); - sx += pWindow->origin.y - wBorderWidth(pWindow); - pWindow = pWindow->parent; - } - if (!pWindow->viewable) { - return; - } - } - DMX_GCOPS_SET_DRAWABLE(&pWindow->drawable, draw); - if (DMX_GCOPS_OFFSCREEN(&pWindow->drawable)) - return; - } else { - DMX_GCOPS_SET_DRAWABLE(pDrawable, draw); - if (DMX_GCOPS_OFFSCREEN(pDrawable)) { - /* Try to find the pixmap on a non-detached Xinerama screen */ - dmxScreen = dmxFindAlternatePixmap(pDrawable, &draw); - if (!dmxScreen) return; - } - } - - img = XGetImage(dmxScreen->beDisplay, draw, - sx, sy, w, h, planeMask, format); - if (img) { - int len = img->bytes_per_line * img->height; - memmove(pdstLine, img->data, len); - XDestroyImage(img); - } - - dmxSync(dmxScreen, FALSE); -} - -/** Get Spans -- this function should never be called. */ -void dmxGetSpans(DrawablePtr pDrawable, int wMax, - DDXPointPtr ppt, int *pwidth, int nspans, - char *pdstStart) -{ - /* Error -- this should never happen! */ -} +/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides support for GC operations. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxgc.h"
+#include "dmxgcops.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+
+#include "mi.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "dixfontstr.h"
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#endif
+
+#define DMX_GCOPS_SET_DRAWABLE(_pDraw, _draw) \
+do { \
+ if ((_pDraw)->type == DRAWABLE_WINDOW) { \
+ dmxWinPrivPtr pWinPriv = \
+ DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw)); \
+ (_draw) = (Drawable)pWinPriv->window; \
+ } else { \
+ dmxPixPrivPtr pPixPriv = \
+ DMX_GET_PIXMAP_PRIV((PixmapPtr)(_pDraw)); \
+ (_draw) = (Drawable)pPixPriv->pixmap; \
+ } \
+} while (0)
+
+#define DMX_GCOPS_OFFSCREEN(_pDraw) \
+ (!dmxScreens[(_pDraw)->pScreen->myNum].beDisplay || \
+ (dmxOffScreenOpt && \
+ (_pDraw)->type == DRAWABLE_WINDOW && \
+ (DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw))->offscreen || \
+ !DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw))->window)))
+
+/** Fill spans -- this function should never be called. */
+void dmxFillSpans(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit, int *pwidthInit,
+ int fSorted)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Set spans -- this function should never be called. */
+void dmxSetSpans(DrawablePtr pDrawable, GCPtr pGC,
+ char *psrc, DDXPointPtr ppt, int *pwidth, int nspans,
+ int fSorted)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Transfer \a pBits image to back-end server associated with \a
+ * pDrawable's screen. If primitive subdivision optimization is
+ * enabled, then only transfer the sections of \a pBits that are
+ * visible (i.e., not-clipped) to the back-end server. */
+void dmxPutImage(DrawablePtr pDrawable, GCPtr pGC,
+ int depth, int x, int y, int w, int h,
+ int leftPad, int format, char *pBits)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ XImage *img;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ img = XCreateImage(dmxScreen->beDisplay,
+ dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual,
+ depth, format, leftPad, pBits, w, h,
+ BitmapPad(dmxScreen->beDisplay),
+ (format == ZPixmap) ?
+ PixmapBytePad(w, depth) : BitmapBytePad(w+leftPad));
+
+ if (img) {
+ Drawable draw;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ if (dmxSubdividePrimitives && pGC->pCompositeClip) {
+ RegionPtr pSubImages;
+ RegionPtr pClip;
+ BoxRec box;
+ BoxPtr pBox;
+ int nBox;
+
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + w;
+ box.y2 = y + h;
+ pSubImages = RegionCreate(&box, 1);
+
+ pClip = RegionCreate(NullBox, 1);
+ RegionCopy(pClip, pGC->pCompositeClip);
+ RegionTranslate(pClip,
+ -pDrawable->x, -pDrawable->y);
+ RegionIntersect(pSubImages, pSubImages, pClip);
+
+ nBox = RegionNumRects(pSubImages);
+ pBox = RegionRects(pSubImages);
+
+ while (nBox--) {
+ XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc, img,
+ pBox->x1 - box.x1,
+ pBox->y1 - box.y1,
+ pBox->x1,
+ pBox->y1,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ RegionDestroy(pClip);
+ RegionDestroy(pSubImages);
+ } else {
+ XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ img, 0, 0, x, y, w, h);
+ }
+ XFree(img); /* Use XFree instead of XDestroyImage
+ * because pBits is passed in from the
+ * caller. */
+
+ dmxSync(dmxScreen, FALSE);
+ } else {
+ /* Error -- this should not happen! */
+ }
+}
+
+/** Copy area from \a pSrc drawable to \a pDst drawable on the back-end
+ * server associated with \a pSrc drawable's screen. If the offscreen
+ * optimization is enabled, only copy when both \a pSrc and \a pDst are
+ * at least partially visible. */
+RegionPtr dmxCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pSrc->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable srcDraw, dstDraw;
+
+ if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst))
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h,
+ dstx, dsty, 0L);
+
+ DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw);
+ DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw);
+
+ XCopyArea(dmxScreen->beDisplay, srcDraw, dstDraw, pGCPriv->gc,
+ srcx, srcy, w, h, dstx, dsty);
+ dmxSync(dmxScreen, FALSE);
+
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h,
+ dstx, dsty, 0L);
+}
+
+/** Copy plane number \a bitPlane from \a pSrc drawable to \a pDst
+ * drawable on the back-end server associated with \a pSrc drawable's
+ * screen. If the offscreen optimization is enabled, only copy when
+ * both \a pSrc and \a pDst are at least partially visible. */
+RegionPtr dmxCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pSrc->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable srcDraw, dstDraw;
+
+ if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst))
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+
+ DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw);
+ DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw);
+
+ XCopyPlane(dmxScreen->beDisplay, srcDraw, dstDraw, pGCPriv->gc,
+ srcx, srcy, width, height, dstx, dsty, bitPlane);
+ dmxSync(dmxScreen, FALSE);
+
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+}
+
+/** Render list of points, \a pptInit in \a pDrawable on the back-end
+ * server associated with \a pDrawable's screen. If the offscreen
+ * optimization is enabled, only draw when \a pDrawable is at least
+ * partially visible. */
+void dmxPolyPoint(DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawPoints(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XPoint *)pptInit, npt, mode);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of connected lines, \a pptInit in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolylines(DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawLines(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XPoint *)pptInit, npt, mode);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of disjoint segments, \a pSegs in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolySegment(DrawablePtr pDrawable, GCPtr pGC,
+ int nseg, xSegment *pSegs)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawSegments(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XSegment *)pSegs, nseg);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of rectangle outlines, \a pRects in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolyRectangle(DrawablePtr pDrawable, GCPtr pGC,
+ int nrects, xRectangle *pRects)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawRectangles(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XRectangle *)pRects, nrects);
+
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of arc outlines, \a parcs in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolyArc(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawArcs(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XArc *)parcs, narcs);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render a filled polygons in \a pDrawable on the back-end server
+ * associated with \a pDrawable's screen. If the offscreen
+ * optimization is enabled, only draw when \a pDrawable is at least
+ * partially visible. */
+void dmxFillPolygon(DrawablePtr pDrawable, GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr pPts)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XFillPolygon(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XPoint *)pPts, count, shape, mode);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of filled rectangles, \a prectInit in \a pDrawable on
+ * the back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XFillRectangles(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XRectangle *)prectInit, nrectFill);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of filled arcs, \a parcs in \a pDrawable on the back-end
+ * server associated with \a pDrawable's screen. If the offscreen
+ * optimization is enabled, only draw when \a pDrawable is at least
+ * partially visible. */
+void dmxPolyFillArc(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XFillArcs(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XArc *)parcs, narcs);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render string of 8-bit \a chars (foreground only) in \a pDrawable on
+ * the back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+int dmxPolyText8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255];
+ Drawable draw;
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ Linear8Bit, &n, charinfo);
+
+ /* Calculate text width */
+ w = 0;
+ for (i = 0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
+
+ if (n != 0 && !DMX_GCOPS_OFFSCREEN(pDrawable)) {
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawString(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, chars, count);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ return x+w;
+}
+
+/** Render string of 16-bit \a chars (foreground only) in \a pDrawable
+ * on the back-end server associated with \a pDrawable's screen. If
+ * the offscreen optimization is enabled, only draw when \a pDrawable
+ * is at least partially visible. */
+int dmxPolyText16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255];
+ Drawable draw;
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+
+ /* Calculate text width */
+ w = 0;
+ for (i = 0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
+
+ if (n != 0 && !DMX_GCOPS_OFFSCREEN(pDrawable)) {
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawString16(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, (XChar2b *)chars, count);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ return x+w;
+}
+
+/** Render string of 8-bit \a chars (both foreground and background) in
+ * \a pDrawable on the back-end server associated with \a pDrawable's
+ * screen. If the offscreen optimization is enabled, only draw when \a
+ * pDrawable is at least partially visible. */
+void dmxImageText8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawImageString(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, chars, count);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render string of 16-bit \a chars (both foreground and background) in
+ * \a pDrawable on the back-end server associated with \a pDrawable's
+ * screen. If the offscreen optimization is enabled, only draw when \a
+ * pDrawable is at least partially visible. */
+void dmxImageText16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawImageString16(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, (XChar2b *)chars, count);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Image Glyph Blt -- this function should never be called. */
+void dmxImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Poly Glyph Blt -- this function should never be called. */
+void dmxPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Push Pixels -- this function should never be called. */
+void dmxPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
+ int w, int h, int x, int y)
+{
+ /* Error -- this should never happen! */
+}
+
+/**********************************************************************
+ * Miscellaneous drawing commands
+ */
+
+/** When Xinerama is active, the client pixmaps are always obtained from
+ * screen 0. When screen 0 is detached, the pixmaps must be obtained
+ * from any other screen that is not detached. Usually, this is screen
+ * 1. */
+static DMXScreenInfo *dmxFindAlternatePixmap(DrawablePtr pDrawable, XID *draw)
+{
+#ifdef PANORAMIX
+ PanoramiXRes *pXinPix;
+ int i;
+ DMXScreenInfo *dmxScreen;
+
+ if (noPanoramiXExtension) return NULL;
+ if (pDrawable->type != DRAWABLE_PIXMAP) return NULL;
+
+ if (!(pXinPix = (PanoramiXRes *)LookupIDByType(pDrawable->id, XRT_PIXMAP)))
+ return NULL;
+
+ for (i = 1; i < PanoramiXNumScreens; i++) {
+ dmxScreen = &dmxScreens[i];
+ if (dmxScreen->beDisplay) {
+ PixmapPtr pSrc;
+ dmxPixPrivPtr pSrcPriv;
+
+ pSrc = (PixmapPtr)LookupIDByType(pXinPix->info[i].id,
+ RT_PIXMAP);
+ pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
+ if (pSrcPriv->pixmap) {
+ *draw = pSrcPriv->pixmap;
+ return dmxScreen;
+ }
+ }
+ }
+#endif
+ return NULL;
+}
+
+/** Get an image from the back-end server associated with \a pDrawable's
+ * screen. If \a pDrawable is a window, it must be viewable to get an
+ * image from it. If it is not viewable, then get the image from the
+ * first ancestor of \a pDrawable that is viewable. If no viewable
+ * ancestor is found, then simply return without getting an image. */
+void dmxGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
+ unsigned int format, unsigned long planeMask, char *pdstLine)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ XImage *img;
+ Drawable draw;
+
+ /* Cannot get image from unviewable window */
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ WindowPtr pWindow = (WindowPtr)pDrawable;
+ if (!pWindow->viewable) {
+ while (!pWindow->viewable && pWindow->parent) {
+ sx += pWindow->origin.x - wBorderWidth(pWindow);
+ sx += pWindow->origin.y - wBorderWidth(pWindow);
+ pWindow = pWindow->parent;
+ }
+ if (!pWindow->viewable) {
+ return;
+ }
+ }
+ DMX_GCOPS_SET_DRAWABLE(&pWindow->drawable, draw);
+ if (DMX_GCOPS_OFFSCREEN(&pWindow->drawable))
+ return;
+ } else {
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) {
+ /* Try to find the pixmap on a non-detached Xinerama screen */
+ dmxScreen = dmxFindAlternatePixmap(pDrawable, &draw);
+ if (!dmxScreen) return;
+ }
+ }
+
+ img = XGetImage(dmxScreen->beDisplay, draw,
+ sx, sy, w, h, planeMask, format);
+ if (img) {
+ int len = img->bytes_per_line * img->height;
+ memmove(pdstLine, img->data, len);
+ XDestroyImage(img);
+ }
+
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Get Spans -- this function should never be called. */
+void dmxGetSpans(DrawablePtr pDrawable, int wMax,
+ DDXPointPtr ppt, int *pwidth, int nspans,
+ char *pdstStart)
+{
+ /* Error -- this should never happen! */
+}
diff --git a/xorg-server/hw/dmx/dmxinit.c b/xorg-server/hw/dmx/dmxinit.c index 37b302a25..37fe0af21 100644 --- a/xorg-server/hw/dmx/dmxinit.c +++ b/xorg-server/hw/dmx/dmxinit.c @@ -404,7 +404,7 @@ Bool dmxGetVisualInfo(DMXScreenInfo *dmxScreen) dmxLogVisual(dmxScreen, &dmxScreen->beVisuals[i],
(i == dmxScreen->beDefVisualIndex));
- return (dmxScreen->beDefVisualIndex >= 0);
+ return dmxScreen->beDefVisualIndex >= 0;
}
void dmxGetColormaps(DMXScreenInfo *dmxScreen)
@@ -606,8 +606,8 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) dmxScreens[i].stat = NULL;
}
for (i = 0; i < dmxNumInputs; i++) dmxInputFree(&dmxInputs[i]);
- if (dmxScreens) free(dmxScreens);
- if (dmxInputs) free(dmxInputs);
+ free(dmxScreens);
+ free(dmxInputs);
dmxScreens = NULL;
dmxInputs = NULL;
dmxNumScreens = 0;
diff --git a/xorg-server/hw/dmx/dmxpict.c b/xorg-server/hw/dmx/dmxpict.c index c7bcd5b91..18ac85c03 100644 --- a/xorg-server/hw/dmx/dmxpict.c +++ b/xorg-server/hw/dmx/dmxpict.c @@ -145,7 +145,7 @@ Bool dmxPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats) if (!miPictureInit(pScreen, formats, nformats))
return FALSE;
- if (!dixRequestPrivate(dmxPictPrivateKey, sizeof(dmxPictPrivRec)))
+ if (!dixRegisterPrivateKey(&dmxPictPrivateKeyRec, PRIVATE_PICTURE, sizeof(dmxPictPrivRec)))
return FALSE;
ps = GetPictureScreen(pScreen);
@@ -871,8 +871,8 @@ int dmxChangePictureClip(PicturePtr pPicture, int clipType, pPictPriv->pict, 0, 0, None);
} else if (pPicture->clientClip) {
RegionPtr pClip = pPicture->clientClip;
- BoxPtr pBox = REGION_RECTS(pClip);
- int nBox = REGION_NUM_RECTS(pClip);
+ BoxPtr pBox = RegionRects(pClip);
+ int nBox = RegionNumRects(pClip);
XRectangle *pRects;
XRectangle *pRect;
int nRects;
diff --git a/xorg-server/hw/dmx/dmxpict.h b/xorg-server/hw/dmx/dmxpict.h index a81eb7d37..d196f639a 100644 --- a/xorg-server/hw/dmx/dmxpict.h +++ b/xorg-server/hw/dmx/dmxpict.h @@ -1,134 +1,130 @@ -/* - * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Kevin E. Martin <kem@redhat.com> - * - */ - -/** \file - * This file provides access to the externally visible RENDER support - * functions, global variables and macros for DMX. - * - * FIXME: Move function definitions for non-externally visible function - * to .c file. */ - -#ifndef DMXPICT_H -#define DMXPICT_H - -/** Picture private structure */ -typedef struct _dmxPictPriv { - Picture pict; /**< Picture ID from back-end server */ - Mask savedMask; /**< Mask of picture attributes saved for - * lazy window creation. */ -} dmxPictPrivRec, *dmxPictPrivPtr; - - -/** Glyph Set private structure */ -typedef struct _dmxGlyphPriv { - GlyphSet *glyphSets; /**< Glyph Set IDs from back-end server */ -} dmxGlyphPrivRec, *dmxGlyphPrivPtr; - - -extern void dmxInitRender(void); -extern void dmxResetRender(void); - -extern Bool dmxPictureInit(ScreenPtr pScreen, - PictFormatPtr formats, int nformats); - -extern void dmxCreatePictureList(WindowPtr pWindow); -extern Bool dmxDestroyPictureList(WindowPtr pWindow); - -extern int dmxCreatePicture(PicturePtr pPicture); -extern void dmxDestroyPicture(PicturePtr pPicture); -extern int dmxChangePictureClip(PicturePtr pPicture, int clipType, - pointer value, int n); -extern void dmxDestroyPictureClip(PicturePtr pPicture); -extern void dmxChangePicture(PicturePtr pPicture, Mask mask); -extern void dmxValidatePicture(PicturePtr pPicture, Mask mask); -extern void dmxComposite(CARD8 op, - PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, - INT16 xSrc, INT16 ySrc, - INT16 xMask, INT16 yMask, - INT16 xDst, INT16 yDst, - CARD16 width, CARD16 height); -extern void dmxGlyphs(CARD8 op, - PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, - int nlists, GlyphListPtr lists, GlyphPtr *glyphs); -extern void dmxCompositeRects(CARD8 op, - PicturePtr pDst, - xRenderColor *color, - int nRect, xRectangle *rects); -extern Bool dmxInitIndexed(ScreenPtr pScreen, PictFormatPtr pFormat); -extern void dmxCloseIndexed(ScreenPtr pScreen, PictFormatPtr pFormat); -extern void dmxUpdateIndexed(ScreenPtr pScreen, PictFormatPtr pFormat, - int ndef, xColorItem *pdef); -extern void dmxTrapezoids(CARD8 op, - PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, - int ntrap, xTrapezoid *traps); -extern void dmxTriangles(CARD8 op, - PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, - int ntri, xTriangle *tris); -extern void dmxTriStrip(CARD8 op, - PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, - int npoint, xPointFixed *points); -extern void dmxTriFan(CARD8 op, - PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, - int npoint, xPointFixed *points); - -extern int dmxBECreateGlyphSet(int idx, GlyphSetPtr glyphSet); -extern Bool dmxBEFreeGlyphSet(ScreenPtr pScreen, GlyphSetPtr glyphSet); -extern int dmxBECreatePicture(PicturePtr pPicture); -extern Bool dmxBEFreePicture(PicturePtr pPicture); - -extern DevPrivateKey dmxPictPrivateKey; /**< Index for picture private data */ -extern DevPrivateKey dmxGlyphSetPrivateKey; /**< Index for glyphset private data */ - - -/** Get the picture private data given a picture pointer */ -#define DMX_GET_PICT_PRIV(_pPict) \ - (dmxPictPrivPtr)dixLookupPrivate(&(_pPict)->devPrivates, dmxPictPrivateKey) - -/** Set the glyphset private data given a glyphset pointer */ -#define DMX_SET_GLYPH_PRIV(_pGlyph, _pPriv) \ - GlyphSetSetPrivate((_pGlyph), dmxGlyphSetPrivateKey, (_pPriv)) -/** Get the glyphset private data given a glyphset pointer */ -#define DMX_GET_GLYPH_PRIV(_pGlyph) \ - (dmxGlyphPrivPtr)GlyphSetGetPrivate((_pGlyph), dmxGlyphSetPrivateKey) - -#endif /* DMXPICT_H */ +/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides access to the externally visible RENDER support
+ * functions, global variables and macros for DMX.
+ *
+ * FIXME: Move function definitions for non-externally visible function
+ * to .c file. */
+
+#ifndef DMXPICT_H
+#define DMXPICT_H
+
+/** Picture private structure */
+typedef struct _dmxPictPriv {
+ Picture pict; /**< Picture ID from back-end server */
+ Mask savedMask; /**< Mask of picture attributes saved for
+ * lazy window creation. */
+} dmxPictPrivRec, *dmxPictPrivPtr;
+
+
+/** Glyph Set private structure */
+typedef struct _dmxGlyphPriv {
+ GlyphSet *glyphSets; /**< Glyph Set IDs from back-end server */
+} dmxGlyphPrivRec, *dmxGlyphPrivPtr;
+
+
+extern void dmxInitRender(void);
+extern void dmxResetRender(void);
+
+extern Bool dmxPictureInit(ScreenPtr pScreen,
+ PictFormatPtr formats, int nformats);
+
+extern void dmxCreatePictureList(WindowPtr pWindow);
+extern Bool dmxDestroyPictureList(WindowPtr pWindow);
+
+extern int dmxCreatePicture(PicturePtr pPicture);
+extern void dmxDestroyPicture(PicturePtr pPicture);
+extern int dmxChangePictureClip(PicturePtr pPicture, int clipType,
+ pointer value, int n);
+extern void dmxDestroyPictureClip(PicturePtr pPicture);
+extern void dmxChangePicture(PicturePtr pPicture, Mask mask);
+extern void dmxValidatePicture(PicturePtr pPicture, Mask mask);
+extern void dmxComposite(CARD8 op,
+ PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
+ INT16 xSrc, INT16 ySrc,
+ INT16 xMask, INT16 yMask,
+ INT16 xDst, INT16 yDst,
+ CARD16 width, CARD16 height);
+extern void dmxGlyphs(CARD8 op,
+ PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int nlists, GlyphListPtr lists, GlyphPtr *glyphs);
+extern void dmxCompositeRects(CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect, xRectangle *rects);
+extern Bool dmxInitIndexed(ScreenPtr pScreen, PictFormatPtr pFormat);
+extern void dmxCloseIndexed(ScreenPtr pScreen, PictFormatPtr pFormat);
+extern void dmxUpdateIndexed(ScreenPtr pScreen, PictFormatPtr pFormat,
+ int ndef, xColorItem *pdef);
+extern void dmxTrapezoids(CARD8 op,
+ PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int ntrap, xTrapezoid *traps);
+extern void dmxTriangles(CARD8 op,
+ PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int ntri, xTriangle *tris);
+extern void dmxTriStrip(CARD8 op,
+ PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int npoint, xPointFixed *points);
+extern void dmxTriFan(CARD8 op,
+ PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int npoint, xPointFixed *points);
+
+extern int dmxBECreateGlyphSet(int idx, GlyphSetPtr glyphSet);
+extern Bool dmxBEFreeGlyphSet(ScreenPtr pScreen, GlyphSetPtr glyphSet);
+extern int dmxBECreatePicture(PicturePtr pPicture);
+extern Bool dmxBEFreePicture(PicturePtr pPicture);
+
+/** Get the picture private data given a picture pointer */
+#define DMX_GET_PICT_PRIV(_pPict) \
+ (dmxPictPrivPtr)dixLookupPrivate(&(_pPict)->devPrivates, dmxPictPrivateKey)
+
+/** Set the glyphset private data given a glyphset pointer */
+#define DMX_SET_GLYPH_PRIV(_pGlyph, _pPriv) \
+ GlyphSetSetPrivate((_pGlyph), dmxGlyphSetPrivateKey, (_pPriv))
+/** Get the glyphset private data given a glyphset pointer */
+#define DMX_GET_GLYPH_PRIV(_pGlyph) \
+ (dmxGlyphPrivPtr)GlyphSetGetPrivate((_pGlyph), dmxGlyphSetPrivateKey)
+
+#endif /* DMXPICT_H */
diff --git a/xorg-server/hw/dmx/dmxpixmap.c b/xorg-server/hw/dmx/dmxpixmap.c index bcbcc3a88..119dd1134 100644 --- a/xorg-server/hw/dmx/dmxpixmap.c +++ b/xorg-server/hw/dmx/dmxpixmap.c @@ -49,7 +49,7 @@ /** Initialize a private area in \a pScreen for pixmap information. */
Bool dmxInitPixmap(ScreenPtr pScreen)
{
- if (!dixRequestPrivate(dmxPixPrivateKey, sizeof(dmxPixPrivRec)))
+ if (!dixRegisterPrivateKey(&dmxPixPrivateKeyRec, PRIVATE_PIXMAP, sizeof(dmxPixPrivRec)))
return FALSE;
return TRUE;
@@ -174,8 +174,7 @@ Bool dmxDestroyPixmap(PixmapPtr pPixmap) dmxSync(dmxScreen, FALSE);
}
}
- dixFreePrivates(pPixmap->devPrivates);
- free(pPixmap);
+ FreePixmap(pPixmap);
#if 0
if (pScreen->DestroyPixmap)
@@ -190,8 +189,7 @@ Bool dmxDestroyPixmap(PixmapPtr pPixmap) * pPixmap. */
RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap)
{
- ScreenPtr pScreen = pPixmap->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ DMXScreenInfo *dmxScreen = &dmxScreens[pPixmap->drawable.pScreen->myNum];
dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
XImage *ximage;
RegionPtr pReg, pTmpReg;
@@ -201,7 +199,7 @@ RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap) Bool overlap;
if (!dmxScreen->beDisplay) {
- pReg = REGION_CREATE(pScreen, NullBox, 1);
+ pReg = RegionCreate(NullBox, 1);
return pReg;
}
@@ -209,8 +207,8 @@ RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap) pPixmap->drawable.width, pPixmap->drawable.height,
1, XYPixmap);
- pReg = REGION_CREATE(pScreen, NullBox, 1);
- pTmpReg = REGION_CREATE(pScreen, NullBox, 1);
+ pReg = RegionCreate(NullBox, 1);
+ pTmpReg = RegionCreate(NullBox, 1);
if(!pReg || !pTmpReg) {
XDestroyImage(ximage);
return NullRegion;
@@ -229,8 +227,8 @@ RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap) } else if (currentPixel == 0L) {
/* right edge */
Box.x2 = x;
- REGION_RESET(pScreen, pTmpReg, &Box);
- REGION_APPEND(pScreen, pReg, pTmpReg);
+ RegionReset(pTmpReg, &Box);
+ RegionAppend(pReg, pTmpReg);
}
previousPixel = currentPixel;
}
@@ -238,16 +236,16 @@ RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap) if (previousPixel != 0L) {
/* right edge because of the end of pixmap */
Box.x2 = pPixmap->drawable.width;
- REGION_RESET(pScreen, pTmpReg, &Box);
- REGION_APPEND(pScreen, pReg, pTmpReg);
+ RegionReset(pTmpReg, &Box);
+ RegionAppend(pReg, pTmpReg);
}
}
- REGION_DESTROY(pScreen, pTmpReg);
+ RegionDestroy(pTmpReg);
XDestroyImage(ximage);
- REGION_VALIDATE(pScreen, pReg, &overlap);
+ RegionValidate(pReg, &overlap);
dmxSync(dmxScreen, FALSE);
- return(pReg);
+ return pReg;
}
diff --git a/xorg-server/hw/dmx/dmxpixmap.h b/xorg-server/hw/dmx/dmxpixmap.h index 64418340c..a41918ce4 100644 --- a/xorg-server/hw/dmx/dmxpixmap.h +++ b/xorg-server/hw/dmx/dmxpixmap.h @@ -1,67 +1,64 @@ -/* - * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Kevin E. Martin <kem@redhat.com> - * - */ - -/** \file - * Interface for pixmap support. \see dmxpixmap.c */ - -#ifndef DMXPIXMAP_H -#define DMXPIXMAP_H - -#include "pixmapstr.h" - -/** Pixmap private area. */ -typedef struct _dmxPixPriv { - Pixmap pixmap; - XImage *detachedImage; -} dmxPixPrivRec, *dmxPixPrivPtr; - - -extern Bool dmxInitPixmap(ScreenPtr pScreen); - -extern PixmapPtr dmxCreatePixmap(ScreenPtr pScreen, - int width, int height, int depth, - unsigned usage_hint); -extern Bool dmxDestroyPixmap(PixmapPtr pPixmap); -extern RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap); - -extern void dmxBECreatePixmap(PixmapPtr pPixmap); -extern Bool dmxBEFreePixmap(PixmapPtr pPixmap); - -/** Private index. \see dmxpicmap.h \see dmxscrinit.c */ -extern DevPrivateKey dmxPixPrivateKey; - -/** Get pixmap private pointer. */ -#define DMX_GET_PIXMAP_PRIV(_pPix) \ - (dmxPixPrivPtr)dixLookupPrivate(&(_pPix)->devPrivates, dmxPixPrivateKey) - -#endif /* DMXPIXMAP_H */ +/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for pixmap support. \see dmxpixmap.c */
+
+#ifndef DMXPIXMAP_H
+#define DMXPIXMAP_H
+
+#include "pixmapstr.h"
+
+/** Pixmap private area. */
+typedef struct _dmxPixPriv {
+ Pixmap pixmap;
+ XImage *detachedImage;
+} dmxPixPrivRec, *dmxPixPrivPtr;
+
+
+extern Bool dmxInitPixmap(ScreenPtr pScreen);
+
+extern PixmapPtr dmxCreatePixmap(ScreenPtr pScreen,
+ int width, int height, int depth,
+ unsigned usage_hint);
+extern Bool dmxDestroyPixmap(PixmapPtr pPixmap);
+extern RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap);
+
+extern void dmxBECreatePixmap(PixmapPtr pPixmap);
+extern Bool dmxBEFreePixmap(PixmapPtr pPixmap);
+
+/** Get pixmap private pointer. */
+#define DMX_GET_PIXMAP_PRIV(_pPix) \
+ (dmxPixPrivPtr)dixLookupPrivate(&(_pPix)->devPrivates, dmxPixPrivateKey)
+
+#endif /* DMXPIXMAP_H */
diff --git a/xorg-server/hw/dmx/dmxscrinit.c b/xorg-server/hw/dmx/dmxscrinit.c index edb14a23a..7504610bd 100644 --- a/xorg-server/hw/dmx/dmxscrinit.c +++ b/xorg-server/hw/dmx/dmxscrinit.c @@ -65,21 +65,14 @@ static Bool dmxSaveScreen(ScreenPtr pScreen, int what); static unsigned long dmxGeneration;
static unsigned long *dmxCursorGeneration;
-static int dmxGCPrivateKeyIndex;
-DevPrivateKey dmxGCPrivateKey = &dmxGCPrivateKeyIndex; /**< Private index for GCs */
-static int dmxWinPrivateKeyIndex;
-DevPrivateKey dmxWinPrivateKey = &dmxWinPrivateKeyIndex; /**< Private index for Windows */
-static int dmxPixPrivateKeyIndex;
-DevPrivateKey dmxPixPrivateKey = &dmxPixPrivateKeyIndex; /**< Private index for Pixmaps */
+DevPrivateKeyRec dmxGCPrivateKeyRec;
+DevPrivateKeyRec dmxWinPrivateKeyRec;
+DevPrivateKeyRec dmxPixPrivateKeyRec;
int dmxFontPrivateIndex; /**< Private index for Fonts */
-static int dmxScreenPrivateKeyIndex;
-DevPrivateKey dmxScreenPrivateKey = &dmxScreenPrivateKeyIndex; /**< Private index for Screens */
-static int dmxColormapPrivateKeyIndex;
-DevPrivateKey dmxColormapPrivateKey = &dmxColormapPrivateKeyIndex; /**< Private index for Colormaps */
-static int dmxPictPrivateKeyIndex;
-DevPrivateKey dmxPictPrivateKey = &dmxPictPrivateKeyIndex; /**< Private index for Picts */
-static int dmxGlyphSetPrivateKeyIndex;
-DevPrivateKey dmxGlyphSetPrivateKey = &dmxGlyphSetPrivateKeyIndex; /**< Private index for GlyphSets */
+DevPrivateKeyRec dmxScreenPrivateKeyRec;
+DevPrivateKeyRec dmxColormapPrivateKeyRec;
+DevPrivateKeyRec dmxPictPrivateKeyRec;
+DevPrivateKeyRec dmxGlyphSetPrivateKeyRec;
/** Initialize the parts of screen \a idx that require access to the
* back-end server. */
@@ -210,6 +203,13 @@ Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[]) DMXScreenInfo *dmxScreen = &dmxScreens[idx];
int i, j;
+ if (!dixRegisterPrivateKey(&dmxScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&dmxColormapPrivateKeyRec, PRIVATE_COLORMAP, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&dmxGlyphSetPrivateKeyRec, PRIVATE_GLYPHSET, 0))
+ return FALSE;
+
if (dmxGeneration != serverGeneration) {
/* Allocate font private index */
dmxFontPrivateIndex = AllocateFontPrivateIndex();
diff --git a/xorg-server/hw/dmx/dmxscrinit.h b/xorg-server/hw/dmx/dmxscrinit.h index a4642350c..328e33272 100644 --- a/xorg-server/hw/dmx/dmxscrinit.h +++ b/xorg-server/hw/dmx/dmxscrinit.h @@ -1,51 +1,48 @@ -/* - * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Kevin E. Martin <kem@redhat.com> - * David H. Dawes <dawes@xfree86.org> - * - */ - -/** \file - * Interface for screen initialization. \see dmxscrinit.c */ - -#ifndef DMXSCRINIT_H -#define DMXSCRINIT_H - -#include "scrnintstr.h" - -/** Private index. \see dmxscrrinit.c \see input/dmxconcole.c */ -extern DevPrivateKey dmxScreenPrivateKey; - -extern Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[]); - -extern void dmxBEScreenInit(int idx, ScreenPtr pScreen); -extern void dmxBECloseScreen(ScreenPtr pScreen); - -#endif /* DMXSCRINIT_H */ +/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * David H. Dawes <dawes@xfree86.org>
+ *
+ */
+
+/** \file
+ * Interface for screen initialization. \see dmxscrinit.c */
+
+#ifndef DMXSCRINIT_H
+#define DMXSCRINIT_H
+
+#include "scrnintstr.h"
+
+extern Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[]);
+
+extern void dmxBEScreenInit(int idx, ScreenPtr pScreen);
+extern void dmxBECloseScreen(ScreenPtr pScreen);
+
+#endif /* DMXSCRINIT_H */
diff --git a/xorg-server/hw/dmx/dmxshadow.c b/xorg-server/hw/dmx/dmxshadow.c index 461fd085b..e075dec2a 100644 --- a/xorg-server/hw/dmx/dmxshadow.c +++ b/xorg-server/hw/dmx/dmxshadow.c @@ -1,71 +1,71 @@ -/* - * Copyright 2001 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Kevin E. Martin <kem@redhat.com> - * David H. Dawes <dawes@xfree86.org> - * - */ - -#ifdef HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#include "dmx.h" -#include "dmxsync.h" -#include "dmxshadow.h" - -/** \file - * This file provides support for the shadow frame buffer. */ - -/** Update the screen from the shadow frame buffer. */ -void dmxShadowUpdateProc(ScreenPtr pScreen, shadowBufPtr pBuf) -{ - RegionPtr damage = &pBuf->damage; - int nbox = REGION_NUM_RECTS(damage); - BoxPtr pbox = REGION_RECTS(damage); - DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; - - if (!dmxScreen->beDisplay) - return; - - while (nbox--) { - XPutImage(dmxScreen->beDisplay, - dmxScreen->scrnWin, - dmxScreen->shadowGC, - dmxScreen->shadowFBImage, - pbox->x1, pbox->y1, - pbox->x1, pbox->y1, - pbox->x2 - pbox->x1, - pbox->y2 - pbox->y1); - - pbox++; - } - - dmxSync(dmxScreen, FALSE); -} +/*
+ * Copyright 2001 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * David H. Dawes <dawes@xfree86.org>
+ *
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxshadow.h"
+
+/** \file
+ * This file provides support for the shadow frame buffer. */
+
+/** Update the screen from the shadow frame buffer. */
+void dmxShadowUpdateProc(ScreenPtr pScreen, shadowBufPtr pBuf)
+{
+ RegionPtr damage = &pBuf->damage;
+ int nbox = RegionNumRects(damage);
+ BoxPtr pbox = RegionRects(damage);
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+
+ if (!dmxScreen->beDisplay)
+ return;
+
+ while (nbox--) {
+ XPutImage(dmxScreen->beDisplay,
+ dmxScreen->scrnWin,
+ dmxScreen->shadowGC,
+ dmxScreen->shadowFBImage,
+ pbox->x1, pbox->y1,
+ pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+
+ pbox++;
+ }
+
+ dmxSync(dmxScreen, FALSE);
+}
diff --git a/xorg-server/hw/dmx/dmxstat.c b/xorg-server/hw/dmx/dmxstat.c index 41b0eb27c..c08c6f4cd 100644 --- a/xorg-server/hw/dmx/dmxstat.c +++ b/xorg-server/hw/dmx/dmxstat.c @@ -1,221 +1,221 @@ -/* - * Copyright 2002, 2003 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Rickard E. (Rik) Faith <faith@redhat.com> - * - */ - -/** \file - * - * The DMX server code is written to call #dmxSync() whenever an XSync() - * might be necessary. However, since XSync() requires a two way - * communication with the other X server, eliminating unnecessary - * XSync() calls is a key performance optimization. Support for this - * optimization is provided in \a dmxsync.c. This file provides routines - * that evaluate this optimization by counting the number of XSync() - * calls and monitoring their latency. This functionality can be turned - * on using the -stat command-line parameter. */ - -#ifdef HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#include "dmx.h" -#include "dmxstat.h" -#include "dmxlog.h" -#include <X11/Xos.h> /* For sys/time.h */ - -/** Used to compute a running average of value. */ -typedef struct _DMXStatAvg { - int pos; - int count; - unsigned long value[DMX_STAT_LENGTH]; -} DMXStatAvg; - -/** Statistical information about XSync calls. */ -struct _DMXStatInfo { - unsigned long syncCount; - unsigned long oldSyncCount; - - DMXStatAvg usec; - DMXStatAvg pending; - - unsigned long bins[DMX_STAT_BINS]; -}; - -/* Interval in mS between statistic message log entries. */ - int dmxStatInterval; -static int dmxStatDisplays; -static OsTimerPtr dmxStatTimer; - -/** Return the number of microseconds as an unsigned long. - * Unfortunately, this is only useful for intervals < about 4 sec. */ -static unsigned long usec(struct timeval *stop, struct timeval *start) -{ - return (stop->tv_sec - start->tv_sec) * 1000000 - + stop->tv_usec - start->tv_usec; -} - -static unsigned long avg(DMXStatAvg *data, unsigned long *max) -{ - unsigned long sum; - int i; - - *max = 0; - if (!data->count) return 0; - - for (i = 0, sum = 0; i < data->count; i++) { - if (data->value[i] > *max) *max = data->value[i]; - sum += data->value[i]; - } - return sum / data->count; -} - -/** Turn on XSync statistic gathering and printing. Print every \a - * interval seconds, with lines for the first \a displays. If \a - * interval is NULL, 1 will be used. If \a displays is NULL, 0 will be - * used (meaning a line for every display will be printed). Note that - * this function takes string arguments because it will usually be - * called from #ddxProcessArgument in \a dmxinit.c. */ -void dmxStatActivate(const char *interval, const char *displays) -{ - dmxStatInterval = (interval ? atoi(interval) : 1) * 1000; - dmxStatDisplays = (displays ? atoi(displays) : 0); - - if (dmxStatInterval < 1000) dmxStatInterval = 1000; - if (dmxStatDisplays < 0) dmxStatDisplays = 0; -} - -/** Allocate a \a DMXStatInfo structure. */ -DMXStatInfo *dmxStatAlloc(void) -{ - DMXStatInfo *pt = calloc(1, sizeof(*pt)); - return pt; -} - -/** Free the memory used by a \a DMXStatInfo structure. */ -void dmxStatFree(DMXStatInfo *pt) -{ - if (pt) free(pt); -} - -static void dmxStatValue(DMXStatAvg *data, unsigned long value) -{ - if (data->count != DMX_STAT_LENGTH) ++data->count; - if (data->pos >= DMX_STAT_LENGTH-1) data->pos = 0; - data->value[data->pos++] = value; -} - -/** Note that a XSync() was just done on \a dmxScreen with the \a start - * and \a stop times (from gettimeofday()) and the number of - * pending-but-not-yet-processed XSync requests. This routine is called - * from #dmxDoSync in \a dmxsync.c */ -void dmxStatSync(DMXScreenInfo *dmxScreen, - struct timeval *stop, struct timeval *start, - unsigned long pending) -{ - DMXStatInfo *s = dmxScreen->stat; - unsigned long elapsed = usec(stop, start); - unsigned long thresh; - int i; - - ++s->syncCount; - dmxStatValue(&s->usec, elapsed); - dmxStatValue(&s->pending, pending); - - for (i = 0, thresh = DMX_STAT_BIN0; i < DMX_STAT_BINS-1; i++) { - if (elapsed < thresh) { - ++s->bins[i]; - break; - } - thresh *= DMX_STAT_BINMULT; - } - if (i == DMX_STAT_BINS-1) ++s->bins[i]; -} - -/* Actually do the work of printing out the human-readable message. */ -static CARD32 dmxStatCallback(OsTimerPtr timer, CARD32 t, pointer arg) -{ - int i, j; - static int header = 0; - int limit = dmxNumScreens; - - if (!dmxNumScreens) { - header = 0; - return DMX_STAT_INTERVAL; - } - - if (!header++ || !(header % 10)) { - dmxLog(dmxDebug, - " S SyncCount Sync/s avSync mxSync avPend mxPend | " - "<10ms <1s >1s\n"); - } - - if (dmxStatDisplays && dmxStatDisplays < limit) limit = dmxStatDisplays; - for (i = 0; i < limit; i++) { - DMXScreenInfo *dmxScreen = &dmxScreens[i]; - DMXStatInfo *s = dmxScreen->stat; - unsigned long aSync, mSync; - unsigned long aPend, mPend; - - if (!s) continue; - - aSync = avg(&s->usec, &mSync); - aPend = avg(&s->pending, &mPend); - dmxLog(dmxDebug, "%2d %9lu %7lu %6lu %6lu %6lu %6lu |", - i, /* S */ - s->syncCount, /* SyncCount */ - (s->syncCount - - s->oldSyncCount) * 1000 / dmxStatInterval, /* Sync/s */ - aSync, /* us/Sync */ - mSync, /* max/Sync */ - aPend, /* avgPend */ - mPend); /* maxPend */ - for (j = 0; j < DMX_STAT_BINS; j++) - dmxLogCont(dmxDebug, " %5lu", s->bins[j]); - dmxLogCont(dmxDebug, "\n"); - - /* Reset/clear */ - s->oldSyncCount = s->syncCount; - for (j = 0; j < DMX_STAT_BINS; j++) s->bins[j] = 0; - } - return DMX_STAT_INTERVAL; /* Place on queue again */ -} - -/** Try to initialize the statistic gathering and printing routines. - * Initialization only takes place if #dmxStatActivate has already been - * called. We don't need the same generation protection that we used in - * dmxSyncInit because our timer is always on a queue -- hence, server - * generation will always free it. */ -void dmxStatInit(void) -{ - if (dmxStatInterval) - dmxStatTimer = TimerSet(NULL, 0, - dmxStatInterval, dmxStatCallback, NULL); -} +/*
+ * Copyright 2002, 2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * The DMX server code is written to call #dmxSync() whenever an XSync()
+ * might be necessary. However, since XSync() requires a two way
+ * communication with the other X server, eliminating unnecessary
+ * XSync() calls is a key performance optimization. Support for this
+ * optimization is provided in \a dmxsync.c. This file provides routines
+ * that evaluate this optimization by counting the number of XSync()
+ * calls and monitoring their latency. This functionality can be turned
+ * on using the -stat command-line parameter. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxstat.h"
+#include "dmxlog.h"
+#include <X11/Xos.h> /* For sys/time.h */
+
+/** Used to compute a running average of value. */
+typedef struct _DMXStatAvg {
+ int pos;
+ int count;
+ unsigned long value[DMX_STAT_LENGTH];
+} DMXStatAvg;
+
+/** Statistical information about XSync calls. */
+struct _DMXStatInfo {
+ unsigned long syncCount;
+ unsigned long oldSyncCount;
+
+ DMXStatAvg usec;
+ DMXStatAvg pending;
+
+ unsigned long bins[DMX_STAT_BINS];
+};
+
+/* Interval in mS between statistic message log entries. */
+ int dmxStatInterval;
+static int dmxStatDisplays;
+static OsTimerPtr dmxStatTimer;
+
+/** Return the number of microseconds as an unsigned long.
+ * Unfortunately, this is only useful for intervals < about 4 sec. */
+static unsigned long usec(struct timeval *stop, struct timeval *start)
+{
+ return (stop->tv_sec - start->tv_sec) * 1000000
+ + stop->tv_usec - start->tv_usec;
+}
+
+static unsigned long avg(DMXStatAvg *data, unsigned long *max)
+{
+ unsigned long sum;
+ int i;
+
+ *max = 0;
+ if (!data->count) return 0;
+
+ for (i = 0, sum = 0; i < data->count; i++) {
+ if (data->value[i] > *max) *max = data->value[i];
+ sum += data->value[i];
+ }
+ return sum / data->count;
+}
+
+/** Turn on XSync statistic gathering and printing. Print every \a
+ * interval seconds, with lines for the first \a displays. If \a
+ * interval is NULL, 1 will be used. If \a displays is NULL, 0 will be
+ * used (meaning a line for every display will be printed). Note that
+ * this function takes string arguments because it will usually be
+ * called from #ddxProcessArgument in \a dmxinit.c. */
+void dmxStatActivate(const char *interval, const char *displays)
+{
+ dmxStatInterval = (interval ? atoi(interval) : 1) * 1000;
+ dmxStatDisplays = (displays ? atoi(displays) : 0);
+
+ if (dmxStatInterval < 1000) dmxStatInterval = 1000;
+ if (dmxStatDisplays < 0) dmxStatDisplays = 0;
+}
+
+/** Allocate a \a DMXStatInfo structure. */
+DMXStatInfo *dmxStatAlloc(void)
+{
+ DMXStatInfo *pt = calloc(1, sizeof(*pt));
+ return pt;
+}
+
+/** Free the memory used by a \a DMXStatInfo structure. */
+void dmxStatFree(DMXStatInfo *pt)
+{
+ free(pt);
+}
+
+static void dmxStatValue(DMXStatAvg *data, unsigned long value)
+{
+ if (data->count != DMX_STAT_LENGTH) ++data->count;
+ if (data->pos >= DMX_STAT_LENGTH-1) data->pos = 0;
+ data->value[data->pos++] = value;
+}
+
+/** Note that a XSync() was just done on \a dmxScreen with the \a start
+ * and \a stop times (from gettimeofday()) and the number of
+ * pending-but-not-yet-processed XSync requests. This routine is called
+ * from #dmxDoSync in \a dmxsync.c */
+void dmxStatSync(DMXScreenInfo *dmxScreen,
+ struct timeval *stop, struct timeval *start,
+ unsigned long pending)
+{
+ DMXStatInfo *s = dmxScreen->stat;
+ unsigned long elapsed = usec(stop, start);
+ unsigned long thresh;
+ int i;
+
+ ++s->syncCount;
+ dmxStatValue(&s->usec, elapsed);
+ dmxStatValue(&s->pending, pending);
+
+ for (i = 0, thresh = DMX_STAT_BIN0; i < DMX_STAT_BINS-1; i++) {
+ if (elapsed < thresh) {
+ ++s->bins[i];
+ break;
+ }
+ thresh *= DMX_STAT_BINMULT;
+ }
+ if (i == DMX_STAT_BINS-1) ++s->bins[i];
+}
+
+/* Actually do the work of printing out the human-readable message. */
+static CARD32 dmxStatCallback(OsTimerPtr timer, CARD32 t, pointer arg)
+{
+ int i, j;
+ static int header = 0;
+ int limit = dmxNumScreens;
+
+ if (!dmxNumScreens) {
+ header = 0;
+ return DMX_STAT_INTERVAL;
+ }
+
+ if (!header++ || !(header % 10)) {
+ dmxLog(dmxDebug,
+ " S SyncCount Sync/s avSync mxSync avPend mxPend | "
+ "<10ms <1s >1s\n");
+ }
+
+ if (dmxStatDisplays && dmxStatDisplays < limit) limit = dmxStatDisplays;
+ for (i = 0; i < limit; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ DMXStatInfo *s = dmxScreen->stat;
+ unsigned long aSync, mSync;
+ unsigned long aPend, mPend;
+
+ if (!s) continue;
+
+ aSync = avg(&s->usec, &mSync);
+ aPend = avg(&s->pending, &mPend);
+ dmxLog(dmxDebug, "%2d %9lu %7lu %6lu %6lu %6lu %6lu |",
+ i, /* S */
+ s->syncCount, /* SyncCount */
+ (s->syncCount
+ - s->oldSyncCount) * 1000 / dmxStatInterval, /* Sync/s */
+ aSync, /* us/Sync */
+ mSync, /* max/Sync */
+ aPend, /* avgPend */
+ mPend); /* maxPend */
+ for (j = 0; j < DMX_STAT_BINS; j++)
+ dmxLogCont(dmxDebug, " %5lu", s->bins[j]);
+ dmxLogCont(dmxDebug, "\n");
+
+ /* Reset/clear */
+ s->oldSyncCount = s->syncCount;
+ for (j = 0; j < DMX_STAT_BINS; j++) s->bins[j] = 0;
+ }
+ return DMX_STAT_INTERVAL; /* Place on queue again */
+}
+
+/** Try to initialize the statistic gathering and printing routines.
+ * Initialization only takes place if #dmxStatActivate has already been
+ * called. We don't need the same generation protection that we used in
+ * dmxSyncInit because our timer is always on a queue -- hence, server
+ * generation will always free it. */
+void dmxStatInit(void)
+{
+ if (dmxStatInterval)
+ dmxStatTimer = TimerSet(NULL, 0,
+ dmxStatInterval, dmxStatCallback, NULL);
+}
diff --git a/xorg-server/hw/dmx/dmxwindow.c b/xorg-server/hw/dmx/dmxwindow.c index 3466f074f..521f4af7d 100644 --- a/xorg-server/hw/dmx/dmxwindow.c +++ b/xorg-server/hw/dmx/dmxwindow.c @@ -60,7 +60,7 @@ static void dmxDoSetShape(WindowPtr pWindow); /** Initialize the private area for the window functions. */
Bool dmxInitWindow(ScreenPtr pScreen)
{
- if (!dixRequestPrivate(dmxWinPrivateKey, sizeof(dmxWinPrivRec)))
+ if (!dixRegisterPrivateKey(&dmxWinPrivateKeyRec, PRIVATE_WINDOW, sizeof(dmxWinPrivRec)))
return FALSE;
return TRUE;
@@ -940,8 +940,8 @@ static void dmxDoSetShape(WindowPtr pWindow) /* First, set the bounding shape */
if (wBoundingShape(pWindow)) {
- pBox = REGION_RECTS(wBoundingShape(pWindow));
- nRect = nBox = REGION_NUM_RECTS(wBoundingShape(pWindow));
+ pBox = RegionRects(wBoundingShape(pWindow));
+ nRect = nBox = RegionNumRects(wBoundingShape(pWindow));
pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
while (nBox--) {
pRect->x = pBox->x1;
@@ -963,8 +963,8 @@ static void dmxDoSetShape(WindowPtr pWindow) /* Next, set the clip shape */
if (wClipShape(pWindow)) {
- pBox = REGION_RECTS(wClipShape(pWindow));
- nRect = nBox = REGION_NUM_RECTS(wClipShape(pWindow));
+ pBox = RegionRects(wClipShape(pWindow));
+ nRect = nBox = RegionNumRects(wClipShape(pWindow));
pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
while (nBox--) {
pRect->x = pBox->x1;
@@ -991,7 +991,7 @@ static void dmxDoSetShape(WindowPtr pWindow) }
/** Set shape of \a pWindow on the back-end server. */
-void dmxSetShape(WindowPtr pWindow)
+void dmxSetShape(WindowPtr pWindow, int kind)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
@@ -1000,7 +1000,7 @@ void dmxSetShape(WindowPtr pWindow) DMX_UNWRAP(SetShape, dmxScreen, pScreen);
#if 1
if (pScreen->SetShape)
- pScreen->SetShape(pWindow);
+ pScreen->SetShape(pWindow, kind);
#endif
if (pWinPriv->window) {
diff --git a/xorg-server/hw/dmx/dmxwindow.h b/xorg-server/hw/dmx/dmxwindow.h index 740a21f0b..43316d35b 100644 --- a/xorg-server/hw/dmx/dmxwindow.h +++ b/xorg-server/hw/dmx/dmxwindow.h @@ -1,138 +1,135 @@ -/* - * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Kevin E. Martin <kem@redhat.com> - * - */ - -/** \file - * Interface for window support. \see dmxwindow.c */ - -#ifndef DMXWINDOW_H -#define DMXWINDOW_H - -#include "windowstr.h" - -/** Window private area. */ -typedef struct _dmxWinPriv { - Window window; - Bool offscreen; - Bool mapped; - Bool restacked; - unsigned long attribMask; - Colormap cmap; - Visual *visual; - Bool isShaped; - Bool hasPict; -#ifdef GLXEXT - void *swapGroup; - int barrier; - void (*windowDestroyed)(WindowPtr); - void (*windowUnmapped)(WindowPtr); -#endif -} dmxWinPrivRec, *dmxWinPrivPtr; - - -extern Bool dmxInitWindow(ScreenPtr pScreen); - -extern Window dmxCreateRootWindow(WindowPtr pWindow); - -extern void dmxGetDefaultWindowAttributes(WindowPtr pWindow, - Colormap *cmap, - Visual **visual); -extern void dmxCreateAndRealizeWindow(WindowPtr pWindow, Bool doSync); - -extern Bool dmxCreateWindow(WindowPtr pWindow); -extern Bool dmxDestroyWindow(WindowPtr pWindow); -extern Bool dmxPositionWindow(WindowPtr pWindow, int x, int y); -extern Bool dmxChangeWindowAttributes(WindowPtr pWindow, unsigned long mask); -extern Bool dmxRealizeWindow(WindowPtr pWindow); -extern Bool dmxUnrealizeWindow(WindowPtr pWindow); -extern void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib); -extern void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn, - RegionPtr other_exposed); -extern void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, - RegionPtr prgnSrc); - -extern void dmxResizeWindow(WindowPtr pWindow, int x, int y, - unsigned int w, unsigned int h, WindowPtr pSib); -extern void dmxReparentWindow(WindowPtr pWindow, WindowPtr pPriorParent); - -extern void dmxChangeBorderWidth(WindowPtr pWindow, unsigned int width); - -extern void dmxResizeScreenWindow(ScreenPtr pScreen, - int x, int y, int w, int h); -extern void dmxResizeRootWindow(WindowPtr pRoot, - int x, int y, int w, int h); - -extern Bool dmxBEDestroyWindow(WindowPtr pWindow); - -/* Support for shape extension */ -extern void dmxSetShape(WindowPtr pWindow); - -/** Private index. \see dmxwindow.c \see dmxscrinit.c */ -extern DevPrivateKey dmxWinPrivateKey; - -/** Get window private pointer. */ -#define DMX_GET_WINDOW_PRIV(_pWin) ((dmxWinPrivPtr) \ - dixLookupPrivate(&(_pWin)->devPrivates, dmxWinPrivateKey)) - -/* All of these macros are only used in dmxwindow.c */ -#define DMX_WINDOW_FUNC_PROLOGUE(_pGC) \ -do { \ - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(_pGC); \ - DMX_UNWRAP(funcs, pGCPriv, (_pGC)); \ - if (pGCPriv->ops) \ - DMX_UNWRAP(ops, pGCPriv, (_pGC)); \ -} while (0) - -#define DMX_WINDOW_FUNC_EPILOGUE(_pGC) \ -do { \ - dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(_pGC); \ - DMX_WRAP(funcs, &dmxGCFuncs, pGCPriv, (_pGC)); \ - if (pGCPriv->ops) \ - DMX_WRAP(ops, &dmxGCOps, pGCPriv, (_pGC)); \ -} while (0) - -#define DMX_WINDOW_X1(_pWin) \ - ((_pWin)->drawable.x - wBorderWidth(_pWin)) -#define DMX_WINDOW_Y1(_pWin) \ - ((_pWin)->drawable.y - wBorderWidth(_pWin)) -#define DMX_WINDOW_X2(_pWin) \ - ((_pWin)->drawable.x + wBorderWidth(_pWin) + (_pWin)->drawable.width) -#define DMX_WINDOW_Y2(_pWin) \ - ((_pWin)->drawable.y + wBorderWidth(_pWin) + (_pWin)->drawable.height) - -#define DMX_WINDOW_OFFSCREEN(_pWin) \ - (DMX_WINDOW_X1(_pWin) >= (_pWin)->drawable.pScreen->width || \ - DMX_WINDOW_Y1(_pWin) >= (_pWin)->drawable.pScreen->height || \ - DMX_WINDOW_X2(_pWin) <= 0 || \ - DMX_WINDOW_Y2(_pWin) <= 0) - -#endif /* DMXWINDOW_H */ +/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for window support. \see dmxwindow.c */
+
+#ifndef DMXWINDOW_H
+#define DMXWINDOW_H
+
+#include "windowstr.h"
+
+/** Window private area. */
+typedef struct _dmxWinPriv {
+ Window window;
+ Bool offscreen;
+ Bool mapped;
+ Bool restacked;
+ unsigned long attribMask;
+ Colormap cmap;
+ Visual *visual;
+ Bool isShaped;
+ Bool hasPict;
+#ifdef GLXEXT
+ void *swapGroup;
+ int barrier;
+ void (*windowDestroyed)(WindowPtr);
+ void (*windowUnmapped)(WindowPtr);
+#endif
+} dmxWinPrivRec, *dmxWinPrivPtr;
+
+
+extern Bool dmxInitWindow(ScreenPtr pScreen);
+
+extern Window dmxCreateRootWindow(WindowPtr pWindow);
+
+extern void dmxGetDefaultWindowAttributes(WindowPtr pWindow,
+ Colormap *cmap,
+ Visual **visual);
+extern void dmxCreateAndRealizeWindow(WindowPtr pWindow, Bool doSync);
+
+extern Bool dmxCreateWindow(WindowPtr pWindow);
+extern Bool dmxDestroyWindow(WindowPtr pWindow);
+extern Bool dmxPositionWindow(WindowPtr pWindow, int x, int y);
+extern Bool dmxChangeWindowAttributes(WindowPtr pWindow, unsigned long mask);
+extern Bool dmxRealizeWindow(WindowPtr pWindow);
+extern Bool dmxUnrealizeWindow(WindowPtr pWindow);
+extern void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib);
+extern void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn,
+ RegionPtr other_exposed);
+extern void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+
+extern void dmxResizeWindow(WindowPtr pWindow, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib);
+extern void dmxReparentWindow(WindowPtr pWindow, WindowPtr pPriorParent);
+
+extern void dmxChangeBorderWidth(WindowPtr pWindow, unsigned int width);
+
+extern void dmxResizeScreenWindow(ScreenPtr pScreen,
+ int x, int y, int w, int h);
+extern void dmxResizeRootWindow(WindowPtr pRoot,
+ int x, int y, int w, int h);
+
+extern Bool dmxBEDestroyWindow(WindowPtr pWindow);
+
+/* Support for shape extension */
+extern void dmxSetShape(WindowPtr pWindow, int kind);
+
+/** Get window private pointer. */
+#define DMX_GET_WINDOW_PRIV(_pWin) ((dmxWinPrivPtr) \
+ dixLookupPrivate(&(_pWin)->devPrivates, dmxWinPrivateKey))
+
+/* All of these macros are only used in dmxwindow.c */
+#define DMX_WINDOW_FUNC_PROLOGUE(_pGC) \
+do { \
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(_pGC); \
+ DMX_UNWRAP(funcs, pGCPriv, (_pGC)); \
+ if (pGCPriv->ops) \
+ DMX_UNWRAP(ops, pGCPriv, (_pGC)); \
+} while (0)
+
+#define DMX_WINDOW_FUNC_EPILOGUE(_pGC) \
+do { \
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(_pGC); \
+ DMX_WRAP(funcs, &dmxGCFuncs, pGCPriv, (_pGC)); \
+ if (pGCPriv->ops) \
+ DMX_WRAP(ops, &dmxGCOps, pGCPriv, (_pGC)); \
+} while (0)
+
+#define DMX_WINDOW_X1(_pWin) \
+ ((_pWin)->drawable.x - wBorderWidth(_pWin))
+#define DMX_WINDOW_Y1(_pWin) \
+ ((_pWin)->drawable.y - wBorderWidth(_pWin))
+#define DMX_WINDOW_X2(_pWin) \
+ ((_pWin)->drawable.x + wBorderWidth(_pWin) + (_pWin)->drawable.width)
+#define DMX_WINDOW_Y2(_pWin) \
+ ((_pWin)->drawable.y + wBorderWidth(_pWin) + (_pWin)->drawable.height)
+
+#define DMX_WINDOW_OFFSCREEN(_pWin) \
+ (DMX_WINDOW_X1(_pWin) >= (_pWin)->drawable.pScreen->width || \
+ DMX_WINDOW_Y1(_pWin) >= (_pWin)->drawable.pScreen->height || \
+ DMX_WINDOW_X2(_pWin) <= 0 || \
+ DMX_WINDOW_Y2(_pWin) <= 0)
+
+#endif /* DMXWINDOW_H */
diff --git a/xorg-server/hw/dmx/doc/dmx.xml b/xorg-server/hw/dmx/doc/dmx.xml index 06716d1d7..c7eaf1333 100644 --- a/xorg-server/hw/dmx/doc/dmx.xml +++ b/xorg-server/hw/dmx/doc/dmx.xml @@ -1497,9 +1497,7 @@ PanoramiX prefix. <para>The Xinerama extension is registered by calling AddExtension().
</para>
- <para>A local per-screen array of data structures
- (panoramiXdataPtr[])
- is allocated for each physical screen, and GC and Screen private
+ <para>GC and Screen private
indexes are allocated, and both GC and Screen private areas are
allocated for each physical screen. These hold Xinerama-specific
per-GC and per-Screen data. Each screen's CreateGC and CloseScreen
@@ -1509,13 +1507,10 @@ PanoramiX prefix. Xinerama windows, pixmaps and colormaps.
</para>
- <para>A region (XineramaScreenRegions[i]) is initialized for each
- physical screen, and single region (PanoramiXScreenRegion) is
- initialized to be the union of the screen regions. The
- panoramiXdataPtr[] array is also initialized with the size and
- origin of each screen. The relative positioning information for the
- physical screens is taken from the array
- dixScreenOrigins[], which
+ <para>A region (PanoramiXScreenRegion) is
+ initialized to be the union of the screen regions.
+ The relative positioning information for the
+ physical screens is taken from the ScreenRec x and y members, which
the DDX layer must initialize in InitOutput(). The bounds of the
combined screen is also calculated (PanoramiXPixWidth and
PanoramiXPixHeight).
diff --git a/xorg-server/hw/dmx/glxProxy/compsize.c b/xorg-server/hw/dmx/glxProxy/compsize.c index cae8fea3c..3bb562e05 100644 --- a/xorg-server/hw/dmx/glxProxy/compsize.c +++ b/xorg-server/hw/dmx/glxProxy/compsize.c @@ -1,558 +1,558 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * 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 - * SILICON GRAPHICS, INC. 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 of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include <GL/gl.h> - -GLint __glFogiv_size(GLenum pname) -{ - switch (pname) { - case GL_FOG_COLOR: return 4; - case GL_FOG_DENSITY: return 1; - case GL_FOG_END: return 1; - case GL_FOG_MODE: return 1; - case GL_FOG_INDEX: return 1; - case GL_FOG_START: return 1; - default: - return 0; - } -} - -GLint __glFogfv_size(GLenum pname) -{ - return __glFogiv_size(pname); -} - -GLint __glCallLists_size(GLsizei n, GLenum type) -{ - GLint size; - - if (n < 0) return 0; - switch (type) { - case GL_BYTE: size = 1; break; - case GL_UNSIGNED_BYTE: size = 1; break; - case GL_SHORT: size = 2; break; - case GL_UNSIGNED_SHORT: size = 2; break; - case GL_INT: size = 4; break; - case GL_UNSIGNED_INT: size = 4; break; - case GL_FLOAT: size = 4; break; - case GL_2_BYTES: size = 2; break; - case GL_3_BYTES: size = 3; break; - case GL_4_BYTES: size = 4; break; - default: - return 0; - } - return n * size; -} - -GLint __glDrawPixels_size(GLenum format, GLenum type, GLsizei w, GLsizei h) -{ - GLint elements, esize; - - switch (format) { - case GL_COLOR_INDEX: - case GL_STENCIL_INDEX: - case GL_DEPTH_COMPONENT: - elements = 1; - break; - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - elements = 1; - break; - case GL_LUMINANCE_ALPHA: - elements = 2; - break; - case GL_RGB: - elements = 3; - break; - case GL_RGBA: - case GL_ABGR_EXT: - elements = 4; - break; - default: - return 0; - } - switch (type) { - case GL_BITMAP: - if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) { - return (h * ((w+7)/8)); - } else { - return 0; - } - case GL_BYTE: - case GL_UNSIGNED_BYTE: - esize = 1; - break; - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - esize = 1; - elements = 1; - break; - case GL_SHORT: - case GL_UNSIGNED_SHORT: - esize = 2; - break; - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - esize = 2; - elements = 1; - break; - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - esize = 4; - break; - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - esize = 4; - elements = 1; - break; - default: - return 0; - } - return (elements * esize * w * h); -} - -GLint __glBitmap_size(GLsizei w, GLsizei h) -{ - return __glDrawPixels_size(GL_COLOR_INDEX, GL_BITMAP, w, h); -} - -GLint __glTexGendv_size(GLenum e) -{ - switch (e) { - case GL_TEXTURE_GEN_MODE: - return 1; - case GL_OBJECT_PLANE: - case GL_EYE_PLANE: - return 4; - default: - return 0; - } -} - -GLint __glTexGenfv_size(GLenum e) -{ - return __glTexGendv_size(e); -} - -GLint __glTexGeniv_size(GLenum e) -{ - return __glTexGendv_size(e); -} - -GLint __glTexParameterfv_size(GLenum e) -{ - switch (e) { - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_WRAP_R: - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - return 1; - case GL_TEXTURE_BORDER_COLOR: - return 4; - case GL_TEXTURE_PRIORITY: - return 1; - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - case GL_TEXTURE_BASE_LEVEL: - case GL_TEXTURE_MAX_LEVEL: - return 1; - default: - return 0; - } -} - -GLint __glTexParameteriv_size(GLenum e) -{ - return __glTexParameterfv_size(e); -} - -GLint __glTexEnvfv_size(GLenum e) -{ - switch (e) { - case GL_TEXTURE_ENV_MODE: - return 1; - case GL_TEXTURE_ENV_COLOR: - return 4; - default: - return 0; - } -} - -GLint __glTexEnviv_size(GLenum e) -{ - return __glTexEnvfv_size(e); -} - -GLint __glTexImage1D_size(GLenum format, GLenum type, GLsizei w) -{ - GLint elements, esize; - - if (w < 0) return 0; - switch (format) { - case GL_COLOR_INDEX: - elements = 1; - break; - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - elements = 1; - break; - case GL_LUMINANCE_ALPHA: - elements = 2; - break; - case GL_RGB: - elements = 3; - break; - case GL_RGBA: - case GL_ABGR_EXT: - elements = 4; - break; - default: - return 0; - } - switch (type) { - case GL_BITMAP: - if (format == GL_COLOR_INDEX) { - return (w+7)/8; - } else { - return 0; - } - case GL_BYTE: - case GL_UNSIGNED_BYTE: - esize = 1; - break; - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - esize = 1; - elements = 1; - break; - case GL_SHORT: - case GL_UNSIGNED_SHORT: - esize = 2; - break; - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - esize = 2; - elements = 1; - break; - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - esize = 4; - break; - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - esize = 4; - elements = 1; - break; - default: - return 0; - } - return (elements * esize * w); -} - -GLint __glTexImage2D_size(GLenum format, GLenum type, GLsizei w, GLsizei h) -{ - GLint elements, esize; - - if (w < 0) return 0; - if (h < 0) return 0; - switch (format) { - case GL_COLOR_INDEX: - elements = 1; - break; - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - elements = 1; - break; - case GL_LUMINANCE_ALPHA: - elements = 2; - break; - case GL_RGB: - elements = 3; - break; - case GL_RGBA: - case GL_ABGR_EXT: - elements = 4; - break; - default: - return 0; - } - switch (type) { - case GL_BITMAP: - if (format == GL_COLOR_INDEX) { - return (h * ((w+7)/8)); - } else { - return 0; - } - case GL_BYTE: - case GL_UNSIGNED_BYTE: - esize = 1; - break; - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - esize = 1; - elements = 1; - break; - case GL_SHORT: - case GL_UNSIGNED_SHORT: - esize = 2; - break; - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - esize = 2; - elements = 1; - break; - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - esize = 4; - break; - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - esize = 4; - elements = 1; - break; - default: - return 0; - } - return (elements * esize * w * h); -} - -GLint __glTexImage3D_size(GLenum format, GLenum type, GLsizei w, GLsizei h, - GLsizei d) -{ - GLint elements, esize; - - if (w < 0) return 0; - if (h < 0) return 0; - if (d < 0) return 0; - switch (format) { - case GL_COLOR_INDEX: - elements = 1; - break; - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - elements = 1; - break; - case GL_LUMINANCE_ALPHA: - elements = 2; - break; - case GL_RGB: - elements = 3; - break; - case GL_RGBA: - case GL_ABGR_EXT: - elements = 4; - break; - default: - return 0; - } - switch (type) { - case GL_BITMAP: - if (format == GL_COLOR_INDEX) { - return (d * (h * ((w+7)/8))); - } else { - return 0; - } - case GL_BYTE: - case GL_UNSIGNED_BYTE: - esize = 1; - break; - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - esize = 1; - elements = 1; - break; - case GL_SHORT: - case GL_UNSIGNED_SHORT: - esize = 2; - break; - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - esize = 2; - elements = 1; - break; - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - esize = 4; - break; - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - esize = 4; - elements = 1; - break; - default: - return 0; - } - return (elements * esize * w * h * d); -} - -GLint __glLightfv_size(GLenum pname) -{ - switch (pname) { - case GL_SPOT_EXPONENT: return 1; - case GL_SPOT_CUTOFF: return 1; - case GL_AMBIENT: return 4; - case GL_DIFFUSE: return 4; - case GL_SPECULAR: return 4; - case GL_POSITION: return 4; - case GL_SPOT_DIRECTION: return 3; - case GL_CONSTANT_ATTENUATION: return 1; - case GL_LINEAR_ATTENUATION: return 1; - case GL_QUADRATIC_ATTENUATION: return 1; - default: - return 0; - } -} - -GLint __glLightiv_size(GLenum pname) -{ - return __glLightfv_size(pname); -} - -GLint __glLightModelfv_size(GLenum pname) -{ - switch (pname) { - case GL_LIGHT_MODEL_AMBIENT: return 4; - case GL_LIGHT_MODEL_LOCAL_VIEWER: return 1; - case GL_LIGHT_MODEL_TWO_SIDE: return 1; - case GL_LIGHT_MODEL_COLOR_CONTROL: return 1; - default: - return 0; - } -} - -GLint __glLightModeliv_size(GLenum pname) -{ - return __glLightModelfv_size(pname); -} - -GLint __glMaterialfv_size(GLenum pname) -{ - switch (pname) { - case GL_SHININESS: return 1; - case GL_EMISSION: return 4; - case GL_AMBIENT: return 4; - case GL_DIFFUSE: return 4; - case GL_SPECULAR: return 4; - case GL_AMBIENT_AND_DIFFUSE: return 4; - case GL_COLOR_INDEXES: return 3; - default: - return 0; - } -} - -GLint __glMaterialiv_size(GLenum pname) -{ - return __glMaterialfv_size(pname); -} - -GLint __glColorTableParameterfv_size(GLenum pname) -{ - switch (pname) { - case GL_COLOR_TABLE_FORMAT: - case GL_COLOR_TABLE_WIDTH: - case GL_COLOR_TABLE_RED_SIZE: - case GL_COLOR_TABLE_GREEN_SIZE: - case GL_COLOR_TABLE_BLUE_SIZE: - case GL_COLOR_TABLE_ALPHA_SIZE: - case GL_COLOR_TABLE_LUMINANCE_SIZE: - case GL_COLOR_TABLE_INTENSITY_SIZE: - return 1; - case GL_COLOR_TABLE_SCALE: - case GL_COLOR_TABLE_BIAS: - return 4; - default: - return -1; - } -} - -GLint __glColorTableParameteriv_size(GLenum pname) -{ - return __glColorTableParameterfv_size(pname); -} - -GLint __glConvolutionParameterfv_size(GLenum pname) -{ - switch(pname) { - case GL_CONVOLUTION_BORDER_MODE: - return 1; - case GL_CONVOLUTION_BORDER_COLOR: - case GL_CONVOLUTION_FILTER_SCALE: - case GL_CONVOLUTION_FILTER_BIAS: - return 4; - default: /* error: bad enum value */ - return -1; - } -} - -GLint __glConvolutionParameteriv_size(GLenum pname) -{ - return __glConvolutionParameterfv_size(pname); -} +/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 of Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#include <GL/gl.h>
+
+GLint __glFogiv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_FOG_COLOR: return 4;
+ case GL_FOG_DENSITY: return 1;
+ case GL_FOG_END: return 1;
+ case GL_FOG_MODE: return 1;
+ case GL_FOG_INDEX: return 1;
+ case GL_FOG_START: return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glFogfv_size(GLenum pname)
+{
+ return __glFogiv_size(pname);
+}
+
+GLint __glCallLists_size(GLsizei n, GLenum type)
+{
+ GLint size;
+
+ if (n < 0) return 0;
+ switch (type) {
+ case GL_BYTE: size = 1; break;
+ case GL_UNSIGNED_BYTE: size = 1; break;
+ case GL_SHORT: size = 2; break;
+ case GL_UNSIGNED_SHORT: size = 2; break;
+ case GL_INT: size = 4; break;
+ case GL_UNSIGNED_INT: size = 4; break;
+ case GL_FLOAT: size = 4; break;
+ case GL_2_BYTES: size = 2; break;
+ case GL_3_BYTES: size = 3; break;
+ case GL_4_BYTES: size = 4; break;
+ default:
+ return 0;
+ }
+ return n * size;
+}
+
+GLint __glDrawPixels_size(GLenum format, GLenum type, GLsizei w, GLsizei h)
+{
+ GLint elements, esize;
+
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) {
+ return (h * ((w+7)/8));
+ } else {
+ return 0;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return 0;
+ }
+ return elements * esize * w * h;
+}
+
+GLint __glBitmap_size(GLsizei w, GLsizei h)
+{
+ return __glDrawPixels_size(GL_COLOR_INDEX, GL_BITMAP, w, h);
+}
+
+GLint __glTexGendv_size(GLenum e)
+{
+ switch (e) {
+ case GL_TEXTURE_GEN_MODE:
+ return 1;
+ case GL_OBJECT_PLANE:
+ case GL_EYE_PLANE:
+ return 4;
+ default:
+ return 0;
+ }
+}
+
+GLint __glTexGenfv_size(GLenum e)
+{
+ return __glTexGendv_size(e);
+}
+
+GLint __glTexGeniv_size(GLenum e)
+{
+ return __glTexGendv_size(e);
+}
+
+GLint __glTexParameterfv_size(GLenum e)
+{
+ switch (e) {
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ case GL_TEXTURE_WRAP_R:
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ return 1;
+ case GL_TEXTURE_BORDER_COLOR:
+ return 4;
+ case GL_TEXTURE_PRIORITY:
+ return 1;
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glTexParameteriv_size(GLenum e)
+{
+ return __glTexParameterfv_size(e);
+}
+
+GLint __glTexEnvfv_size(GLenum e)
+{
+ switch (e) {
+ case GL_TEXTURE_ENV_MODE:
+ return 1;
+ case GL_TEXTURE_ENV_COLOR:
+ return 4;
+ default:
+ return 0;
+ }
+}
+
+GLint __glTexEnviv_size(GLenum e)
+{
+ return __glTexEnvfv_size(e);
+}
+
+GLint __glTexImage1D_size(GLenum format, GLenum type, GLsizei w)
+{
+ GLint elements, esize;
+
+ if (w < 0) return 0;
+ switch (format) {
+ case GL_COLOR_INDEX:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX) {
+ return (w+7)/8;
+ } else {
+ return 0;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return 0;
+ }
+ return elements * esize * w;
+}
+
+GLint __glTexImage2D_size(GLenum format, GLenum type, GLsizei w, GLsizei h)
+{
+ GLint elements, esize;
+
+ if (w < 0) return 0;
+ if (h < 0) return 0;
+ switch (format) {
+ case GL_COLOR_INDEX:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX) {
+ return (h * ((w+7)/8));
+ } else {
+ return 0;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return 0;
+ }
+ return elements * esize * w * h;
+}
+
+GLint __glTexImage3D_size(GLenum format, GLenum type, GLsizei w, GLsizei h,
+ GLsizei d)
+{
+ GLint elements, esize;
+
+ if (w < 0) return 0;
+ if (h < 0) return 0;
+ if (d < 0) return 0;
+ switch (format) {
+ case GL_COLOR_INDEX:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX) {
+ return (d * (h * ((w+7)/8)));
+ } else {
+ return 0;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return 0;
+ }
+ return elements * esize * w * h * d;
+}
+
+GLint __glLightfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_SPOT_EXPONENT: return 1;
+ case GL_SPOT_CUTOFF: return 1;
+ case GL_AMBIENT: return 4;
+ case GL_DIFFUSE: return 4;
+ case GL_SPECULAR: return 4;
+ case GL_POSITION: return 4;
+ case GL_SPOT_DIRECTION: return 3;
+ case GL_CONSTANT_ATTENUATION: return 1;
+ case GL_LINEAR_ATTENUATION: return 1;
+ case GL_QUADRATIC_ATTENUATION: return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glLightiv_size(GLenum pname)
+{
+ return __glLightfv_size(pname);
+}
+
+GLint __glLightModelfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_LIGHT_MODEL_AMBIENT: return 4;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER: return 1;
+ case GL_LIGHT_MODEL_TWO_SIDE: return 1;
+ case GL_LIGHT_MODEL_COLOR_CONTROL: return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glLightModeliv_size(GLenum pname)
+{
+ return __glLightModelfv_size(pname);
+}
+
+GLint __glMaterialfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_SHININESS: return 1;
+ case GL_EMISSION: return 4;
+ case GL_AMBIENT: return 4;
+ case GL_DIFFUSE: return 4;
+ case GL_SPECULAR: return 4;
+ case GL_AMBIENT_AND_DIFFUSE: return 4;
+ case GL_COLOR_INDEXES: return 3;
+ default:
+ return 0;
+ }
+}
+
+GLint __glMaterialiv_size(GLenum pname)
+{
+ return __glMaterialfv_size(pname);
+}
+
+GLint __glColorTableParameterfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_COLOR_TABLE_FORMAT:
+ case GL_COLOR_TABLE_WIDTH:
+ case GL_COLOR_TABLE_RED_SIZE:
+ case GL_COLOR_TABLE_GREEN_SIZE:
+ case GL_COLOR_TABLE_BLUE_SIZE:
+ case GL_COLOR_TABLE_ALPHA_SIZE:
+ case GL_COLOR_TABLE_LUMINANCE_SIZE:
+ case GL_COLOR_TABLE_INTENSITY_SIZE:
+ return 1;
+ case GL_COLOR_TABLE_SCALE:
+ case GL_COLOR_TABLE_BIAS:
+ return 4;
+ default:
+ return -1;
+ }
+}
+
+GLint __glColorTableParameteriv_size(GLenum pname)
+{
+ return __glColorTableParameterfv_size(pname);
+}
+
+GLint __glConvolutionParameterfv_size(GLenum pname)
+{
+ switch(pname) {
+ case GL_CONVOLUTION_BORDER_MODE:
+ return 1;
+ case GL_CONVOLUTION_BORDER_COLOR:
+ case GL_CONVOLUTION_FILTER_SCALE:
+ case GL_CONVOLUTION_FILTER_BIAS:
+ return 4;
+ default: /* error: bad enum value */
+ return -1;
+ }
+}
+
+GLint __glConvolutionParameteriv_size(GLenum pname)
+{
+ return __glConvolutionParameterfv_size(pname);
+}
diff --git a/xorg-server/hw/dmx/glxProxy/g_renderswap.c b/xorg-server/hw/dmx/glxProxy/g_renderswap.c index 8aab433e8..39316a99b 100644 --- a/xorg-server/hw/dmx/glxProxy/g_renderswap.c +++ b/xorg-server/hw/dmx/glxProxy/g_renderswap.c @@ -64,6 +64,7 @@ void __glXDispSwap_Color3bv(GLbyte *pc) void __glXDispSwap_Color3dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -79,6 +80,7 @@ void __glXDispSwap_Color3dv(GLbyte *pc) void __glXDispSwap_Color3fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
}
@@ -86,6 +88,7 @@ void __glXDispSwap_Color3fv(GLbyte *pc) void __glXDispSwap_Color3iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 3);
@@ -94,6 +97,7 @@ void __glXDispSwap_Color3iv(GLbyte *pc) void __glXDispSwap_Color3sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
@@ -106,6 +110,7 @@ void __glXDispSwap_Color3ubv(GLbyte *pc) void __glXDispSwap_Color3uiv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 3);
}
@@ -113,6 +118,7 @@ void __glXDispSwap_Color3uiv(GLbyte *pc) void __glXDispSwap_Color3usv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
}
@@ -124,6 +130,7 @@ void __glXDispSwap_Color4bv(GLbyte *pc) void __glXDispSwap_Color4dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -138,6 +145,7 @@ void __glXDispSwap_Color4dv(GLbyte *pc) void __glXDispSwap_Color4fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
@@ -146,6 +154,7 @@ void __glXDispSwap_Color4fv(GLbyte *pc) void __glXDispSwap_Color4iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 4);
@@ -154,6 +163,7 @@ void __glXDispSwap_Color4iv(GLbyte *pc) void __glXDispSwap_Color4sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
@@ -167,6 +177,7 @@ void __glXDispSwap_Color4ubv(GLbyte *pc) void __glXDispSwap_Color4uiv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 4);
@@ -175,6 +186,7 @@ void __glXDispSwap_Color4uiv(GLbyte *pc) void __glXDispSwap_Color4usv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
@@ -191,6 +203,7 @@ void __glXDispSwap_End(GLbyte *pc) void __glXDispSwap_Indexdv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -206,6 +219,7 @@ void __glXDispSwap_Indexdv(GLbyte *pc) void __glXDispSwap_Indexfv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 1);
@@ -214,6 +228,7 @@ void __glXDispSwap_Indexfv(GLbyte *pc) void __glXDispSwap_Indexiv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 1);
@@ -222,6 +237,7 @@ void __glXDispSwap_Indexiv(GLbyte *pc) void __glXDispSwap_Indexsv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 1);
@@ -234,6 +250,7 @@ void __glXDispSwap_Normal3bv(GLbyte *pc) void __glXDispSwap_Normal3dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -249,6 +266,7 @@ void __glXDispSwap_Normal3dv(GLbyte *pc) void __glXDispSwap_Normal3fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
@@ -257,6 +275,7 @@ void __glXDispSwap_Normal3fv(GLbyte *pc) void __glXDispSwap_Normal3iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 3);
@@ -265,6 +284,7 @@ void __glXDispSwap_Normal3iv(GLbyte *pc) void __glXDispSwap_Normal3sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
@@ -273,6 +293,7 @@ void __glXDispSwap_Normal3sv(GLbyte *pc) void __glXDispSwap_RasterPos2dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -288,6 +309,7 @@ void __glXDispSwap_RasterPos2dv(GLbyte *pc) void __glXDispSwap_RasterPos2fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
@@ -296,6 +318,7 @@ void __glXDispSwap_RasterPos2fv(GLbyte *pc) void __glXDispSwap_RasterPos2iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 2);
@@ -304,6 +327,7 @@ void __glXDispSwap_RasterPos2iv(GLbyte *pc) void __glXDispSwap_RasterPos2sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
@@ -312,6 +336,7 @@ void __glXDispSwap_RasterPos2sv(GLbyte *pc) void __glXDispSwap_RasterPos3dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -327,6 +352,7 @@ void __glXDispSwap_RasterPos3dv(GLbyte *pc) void __glXDispSwap_RasterPos3fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
@@ -335,6 +361,7 @@ void __glXDispSwap_RasterPos3fv(GLbyte *pc) void __glXDispSwap_RasterPos3iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 3);
@@ -343,6 +370,7 @@ void __glXDispSwap_RasterPos3iv(GLbyte *pc) void __glXDispSwap_RasterPos3sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
@@ -351,6 +379,7 @@ void __glXDispSwap_RasterPos3sv(GLbyte *pc) void __glXDispSwap_RasterPos4dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -366,6 +395,7 @@ void __glXDispSwap_RasterPos4dv(GLbyte *pc) void __glXDispSwap_RasterPos4fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
@@ -374,6 +404,7 @@ void __glXDispSwap_RasterPos4fv(GLbyte *pc) void __glXDispSwap_RasterPos4iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 4);
@@ -382,6 +413,7 @@ void __glXDispSwap_RasterPos4iv(GLbyte *pc) void __glXDispSwap_RasterPos4sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
@@ -390,6 +422,7 @@ void __glXDispSwap_RasterPos4sv(GLbyte *pc) void __glXDispSwap_Rectdv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -406,6 +439,7 @@ void __glXDispSwap_Rectdv(GLbyte *pc) void __glXDispSwap_Rectfv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
__GLX_SWAP_FLOAT_ARRAY(pc + 8, 2);
@@ -415,6 +449,7 @@ void __glXDispSwap_Rectfv(GLbyte *pc) void __glXDispSwap_Rectiv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 2);
__GLX_SWAP_INT_ARRAY(pc + 8, 2);
@@ -424,6 +459,7 @@ void __glXDispSwap_Rectiv(GLbyte *pc) void __glXDispSwap_Rectsv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
__GLX_SWAP_SHORT_ARRAY(pc + 4, 2);
@@ -433,6 +469,7 @@ void __glXDispSwap_Rectsv(GLbyte *pc) void __glXDispSwap_TexCoord1dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -448,6 +485,7 @@ void __glXDispSwap_TexCoord1dv(GLbyte *pc) void __glXDispSwap_TexCoord1fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 1);
@@ -456,6 +494,7 @@ void __glXDispSwap_TexCoord1fv(GLbyte *pc) void __glXDispSwap_TexCoord1iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 1);
@@ -464,6 +503,7 @@ void __glXDispSwap_TexCoord1iv(GLbyte *pc) void __glXDispSwap_TexCoord1sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 1);
@@ -472,6 +512,7 @@ void __glXDispSwap_TexCoord1sv(GLbyte *pc) void __glXDispSwap_TexCoord2dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -487,6 +528,7 @@ void __glXDispSwap_TexCoord2dv(GLbyte *pc) void __glXDispSwap_TexCoord2fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
@@ -495,6 +537,7 @@ void __glXDispSwap_TexCoord2fv(GLbyte *pc) void __glXDispSwap_TexCoord2iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 2);
@@ -503,6 +546,7 @@ void __glXDispSwap_TexCoord2iv(GLbyte *pc) void __glXDispSwap_TexCoord2sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
@@ -511,6 +555,7 @@ void __glXDispSwap_TexCoord2sv(GLbyte *pc) void __glXDispSwap_TexCoord3dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -526,6 +571,7 @@ void __glXDispSwap_TexCoord3dv(GLbyte *pc) void __glXDispSwap_TexCoord3fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
@@ -534,6 +580,7 @@ void __glXDispSwap_TexCoord3fv(GLbyte *pc) void __glXDispSwap_TexCoord3iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 3);
@@ -542,6 +589,7 @@ void __glXDispSwap_TexCoord3iv(GLbyte *pc) void __glXDispSwap_TexCoord3sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
@@ -550,6 +598,7 @@ void __glXDispSwap_TexCoord3sv(GLbyte *pc) void __glXDispSwap_TexCoord4dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -565,6 +614,7 @@ void __glXDispSwap_TexCoord4dv(GLbyte *pc) void __glXDispSwap_TexCoord4fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
@@ -573,6 +623,7 @@ void __glXDispSwap_TexCoord4fv(GLbyte *pc) void __glXDispSwap_TexCoord4iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 4);
@@ -581,6 +632,7 @@ void __glXDispSwap_TexCoord4iv(GLbyte *pc) void __glXDispSwap_TexCoord4sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
@@ -589,6 +641,7 @@ void __glXDispSwap_TexCoord4sv(GLbyte *pc) void __glXDispSwap_Vertex2dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -604,6 +657,7 @@ void __glXDispSwap_Vertex2dv(GLbyte *pc) void __glXDispSwap_Vertex2fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
@@ -612,6 +666,7 @@ void __glXDispSwap_Vertex2fv(GLbyte *pc) void __glXDispSwap_Vertex2iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 2);
@@ -620,6 +675,7 @@ void __glXDispSwap_Vertex2iv(GLbyte *pc) void __glXDispSwap_Vertex2sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
@@ -628,6 +684,7 @@ void __glXDispSwap_Vertex2sv(GLbyte *pc) void __glXDispSwap_Vertex3dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -643,6 +700,7 @@ void __glXDispSwap_Vertex3dv(GLbyte *pc) void __glXDispSwap_Vertex3fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
@@ -651,6 +709,7 @@ void __glXDispSwap_Vertex3fv(GLbyte *pc) void __glXDispSwap_Vertex3iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 3);
@@ -659,6 +718,7 @@ void __glXDispSwap_Vertex3iv(GLbyte *pc) void __glXDispSwap_Vertex3sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
@@ -667,6 +727,7 @@ void __glXDispSwap_Vertex3sv(GLbyte *pc) void __glXDispSwap_Vertex4dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -682,6 +743,7 @@ void __glXDispSwap_Vertex4dv(GLbyte *pc) void __glXDispSwap_Vertex4fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
@@ -690,6 +752,7 @@ void __glXDispSwap_Vertex4fv(GLbyte *pc) void __glXDispSwap_Vertex4iv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY(pc + 0, 4);
@@ -698,6 +761,7 @@ void __glXDispSwap_Vertex4iv(GLbyte *pc) void __glXDispSwap_Vertex4sv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
@@ -706,6 +770,7 @@ void __glXDispSwap_Vertex4sv(GLbyte *pc) void __glXDispSwap_ClipPlane(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -750,6 +815,7 @@ void __glXDispSwap_Fogfv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
pname = *(GLenum *)(pc + 0);
@@ -773,6 +839,7 @@ void __glXDispSwap_Fogiv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
pname = *(GLenum *)(pc + 0);
@@ -814,6 +881,7 @@ void __glXDispSwap_Lightfv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -839,6 +907,7 @@ void __glXDispSwap_Lightiv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -863,6 +932,7 @@ void __glXDispSwap_LightModelfv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
pname = *(GLenum *)(pc + 0);
@@ -886,6 +956,7 @@ void __glXDispSwap_LightModeliv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
pname = *(GLenum *)(pc + 0);
@@ -927,6 +998,7 @@ void __glXDispSwap_Materialfv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -952,6 +1024,7 @@ void __glXDispSwap_Materialiv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -1013,6 +1086,7 @@ void __glXDispSwap_TexParameterfv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -1038,6 +1112,7 @@ void __glXDispSwap_TexParameteriv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -1063,6 +1138,7 @@ void __glXDispSwap_TexEnvfv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -1088,6 +1164,7 @@ void __glXDispSwap_TexEnviv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -1121,6 +1198,7 @@ void __glXDispSwap_TexGendv(GLbyte *pc) GLint cmdlen;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -1154,6 +1232,7 @@ void __glXDispSwap_TexGenfv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -1179,6 +1258,7 @@ void __glXDispSwap_TexGeniv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -1414,6 +1494,7 @@ void __glXDispSwap_MapGrid2f(GLbyte *pc) void __glXDispSwap_EvalCoord1dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -1429,6 +1510,7 @@ void __glXDispSwap_EvalCoord1dv(GLbyte *pc) void __glXDispSwap_EvalCoord1fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 1);
@@ -1437,6 +1519,7 @@ void __glXDispSwap_EvalCoord1fv(GLbyte *pc) void __glXDispSwap_EvalCoord2dv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -1452,6 +1535,7 @@ void __glXDispSwap_EvalCoord2dv(GLbyte *pc) void __glXDispSwap_EvalCoord2fv(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
@@ -1581,6 +1665,7 @@ void __glXDispSwap_PixelMapfv(GLbyte *pc) {
GLint mapsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
mapsize = *(GLint *)(pc + 4);
@@ -1593,6 +1678,7 @@ void __glXDispSwap_PixelMapuiv(GLbyte *pc) {
GLint mapsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
mapsize = *(GLint *)(pc + 4);
@@ -1605,6 +1691,7 @@ void __glXDispSwap_PixelMapusv(GLbyte *pc) {
GLint mapsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
mapsize = *(GLint *)(pc + 4);
@@ -1676,6 +1763,7 @@ void __glXDispSwap_LoadIdentity(GLbyte *pc) void __glXDispSwap_LoadMatrixf(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 16);
@@ -1684,6 +1772,7 @@ void __glXDispSwap_LoadMatrixf(GLbyte *pc) void __glXDispSwap_LoadMatrixd(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -1707,6 +1796,7 @@ void __glXDispSwap_MatrixMode(GLbyte *pc) void __glXDispSwap_MultMatrixf(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_FLOAT_ARRAY(pc + 0, 16);
@@ -1715,6 +1805,7 @@ void __glXDispSwap_MultMatrixf(GLbyte *pc) void __glXDispSwap_MultMatrixd(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -1928,6 +2019,7 @@ void __glXDispSwap_PrioritizeTextures(GLbyte *pc) {
GLsizei n;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
n = *(GLsizei *)(pc + 0);
@@ -1964,6 +2056,7 @@ void __glXDispSwap_ColorTableParameterfv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -1979,6 +2072,7 @@ void __glXDispSwap_ColorTableParameteriv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -2028,6 +2122,7 @@ void __glXDispSwap_ConvolutionParameterfv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -2053,6 +2148,7 @@ void __glXDispSwap_ConvolutionParameteriv(GLbyte *pc) GLenum pname;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
pname = *(GLenum *)(pc + 4);
@@ -2150,6 +2246,7 @@ void __glXDispSwap_ActiveTextureARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord1dvARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -2166,6 +2263,7 @@ void __glXDispSwap_MultiTexCoord1dvARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord1fvARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_FLOAT_ARRAY(pc + 4, 1);
@@ -2175,6 +2273,7 @@ void __glXDispSwap_MultiTexCoord1fvARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord1ivARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_INT_ARRAY(pc + 4, 1);
@@ -2184,6 +2283,7 @@ void __glXDispSwap_MultiTexCoord1ivARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord1svARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_SHORT_ARRAY(pc + 4, 1);
@@ -2193,6 +2293,7 @@ void __glXDispSwap_MultiTexCoord1svARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord2dvARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -2209,6 +2310,7 @@ void __glXDispSwap_MultiTexCoord2dvARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord2fvARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_FLOAT_ARRAY(pc + 4, 2);
@@ -2218,6 +2320,7 @@ void __glXDispSwap_MultiTexCoord2fvARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord2ivARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_INT_ARRAY(pc + 4, 2);
@@ -2227,6 +2330,7 @@ void __glXDispSwap_MultiTexCoord2ivARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord2svARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_SHORT_ARRAY(pc + 4, 2);
@@ -2236,6 +2340,7 @@ void __glXDispSwap_MultiTexCoord2svARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord3dvARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -2252,6 +2357,7 @@ void __glXDispSwap_MultiTexCoord3dvARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord3fvARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_FLOAT_ARRAY(pc + 4, 3);
@@ -2261,6 +2367,7 @@ void __glXDispSwap_MultiTexCoord3fvARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord3ivARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_INT_ARRAY(pc + 4, 3);
@@ -2270,6 +2377,7 @@ void __glXDispSwap_MultiTexCoord3ivARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord3svARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_SHORT_ARRAY(pc + 4, 3);
@@ -2279,6 +2387,7 @@ void __glXDispSwap_MultiTexCoord3svARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord4dvARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
#ifdef __GLX_ALIGN64
@@ -2295,6 +2404,7 @@ void __glXDispSwap_MultiTexCoord4dvARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord4fvARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_FLOAT_ARRAY(pc + 4, 4);
@@ -2304,6 +2414,7 @@ void __glXDispSwap_MultiTexCoord4fvARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord4ivARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_INT_ARRAY(pc + 4, 4);
@@ -2313,6 +2424,7 @@ void __glXDispSwap_MultiTexCoord4ivARB(GLbyte *pc) void __glXDispSwap_MultiTexCoord4svARB(GLbyte *pc)
{
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_SHORT_ARRAY(pc + 4, 4);
diff --git a/xorg-server/hw/dmx/glxProxy/glxcmds.c b/xorg-server/hw/dmx/glxProxy/glxcmds.c index bac4478da..d0e3a9b77 100644 --- a/xorg-server/hw/dmx/glxProxy/glxcmds.c +++ b/xorg-server/hw/dmx/glxProxy/glxcmds.c @@ -80,7 +80,7 @@ Display *GetBackEndDisplay( __GLXclientState *cl, int s ) if (! cl->be_displays[s] ) {
cl->be_displays[s] = XOpenDisplay( DisplayString(dmxScreens[s].beDisplay) );
}
- return( cl->be_displays[s] );
+ return cl->be_displays[s];
}
/*
@@ -628,7 +628,7 @@ int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s) return( cl->be_currentCTag[ (tag-1)*screenInfo.numScreens + s ] );
}
else {
- return( 0 );
+ return 0;
}
}
@@ -2841,6 +2841,7 @@ int __glXGetFBConfigs(__GLXclientState *cl, GLbyte *pc) if (client->swapped) {
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT_ARRAY((int *)buf, 2*numAttribs);
}
WriteToClient(client, 2*numAttribs * __GLX_SIZE_CARD32, (char *)buf);
diff --git a/xorg-server/hw/dmx/glxProxy/glxcmdsswap.c b/xorg-server/hw/dmx/glxProxy/glxcmdsswap.c index b3720f6f6..8a2efaa73 100644 --- a/xorg-server/hw/dmx/glxProxy/glxcmdsswap.c +++ b/xorg-server/hw/dmx/glxProxy/glxcmdsswap.c @@ -1,1050 +1,1059 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * 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 - * SILICON GRAPHICS, INC. 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 of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include "glxserver.h" -#include "glxutil.h" -#include <GL/glxtokens.h> -#include <g_disptab.h> -#include <pixmapstr.h> -#include <windowstr.h> -#include "unpack.h" -#include "glxext.h" -#include "glxvendor.h" - -extern int glxIsExtensionSupported( char *ext ); - -/************************************************************************/ - -/* -** Byteswapping versions of GLX commands. In most cases they just swap -** the incoming arguments and then call the unswapped routine. For commands -** that have replies, a separate swapping routine for the reply is provided; -** it is called at the end of the unswapped routine. -*/ - -int __glXSwapCreateContext(__GLXclientState *cl, GLbyte *pc) -{ - xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->context); - __GLX_SWAP_INT(&req->visual); - __GLX_SWAP_INT(&req->screen); - __GLX_SWAP_INT(&req->shareList); - - return __glXCreateContext(cl, pc); -} - -int __glXSwapCreateNewContext(__GLXclientState *cl, GLbyte *pc) -{ - xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->context); - __GLX_SWAP_INT(&req->fbconfig); - __GLX_SWAP_INT(&req->screen); - __GLX_SWAP_INT(&req->shareList); - - return __glXCreateNewContext(cl, pc); -} - -int __glXSwapCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) -{ - xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->context); - __GLX_SWAP_INT(&req->fbconfig); - __GLX_SWAP_INT(&req->screen); - __GLX_SWAP_INT(&req->shareList); - - return __glXCreateContextWithConfigSGIX(cl, pc); -} - -int __glXSwapQueryMaxSwapBarriersSGIX(__GLXclientState *cl, GLbyte *pc) -{ - xGLXQueryMaxSwapBarriersSGIXReq *req = - (xGLXQueryMaxSwapBarriersSGIXReq *)pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->screen); - - return __glXQueryMaxSwapBarriersSGIX(cl, pc); -} - -int __glXSwapBindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc) -{ - xGLXBindSwapBarrierSGIXReq *req = (xGLXBindSwapBarrierSGIXReq *)pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->drawable); - __GLX_SWAP_INT(&req->barrier); - - return __glXBindSwapBarrierSGIX(cl, pc); -} - -int __glXSwapJoinSwapGroupSGIX(__GLXclientState *cl, GLbyte *pc) -{ - xGLXJoinSwapGroupSGIXReq *req = (xGLXJoinSwapGroupSGIXReq *)pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->drawable); - __GLX_SWAP_INT(&req->member); - - return __glXJoinSwapGroupSGIX(cl, pc); -} - -int __glXSwapDestroyContext(__GLXclientState *cl, GLbyte *pc) -{ - xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->context); - - return __glXDestroyContext(cl, pc); -} - -int __glXSwapMakeCurrent(__GLXclientState *cl, GLbyte *pc) -{ - xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->drawable); - __GLX_SWAP_INT(&req->context); - __GLX_SWAP_INT(&req->oldContextTag); - - return __glXMakeCurrent(cl, pc); -} - -int __glXSwapMakeContextCurrent(__GLXclientState *cl, GLbyte *pc) -{ - xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->drawable); - __GLX_SWAP_INT(&req->readdrawable); - __GLX_SWAP_INT(&req->context); - __GLX_SWAP_INT(&req->oldContextTag); - - return __glXMakeContextCurrent(cl, pc); -} - -int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) -{ - xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->drawable); - __GLX_SWAP_INT(&req->readable); - __GLX_SWAP_INT(&req->context); - __GLX_SWAP_INT(&req->oldContextTag); - - return __glXMakeCurrentReadSGI(cl, pc); -} - -int __glXSwapIsDirect(__GLXclientState *cl, GLbyte *pc) -{ - xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->context); - - return __glXIsDirect(cl, pc); -} - -int __glXSwapQueryVersion(__GLXclientState *cl, GLbyte *pc) -{ - xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->majorVersion); - __GLX_SWAP_INT(&req->minorVersion); - - return __glXQueryVersion(cl, pc); -} - -int __glXSwapWaitGL(__GLXclientState *cl, GLbyte *pc) -{ - xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->contextTag); - - return __glXWaitGL(cl, pc); -} - -int __glXSwapWaitX(__GLXclientState *cl, GLbyte *pc) -{ - xGLXWaitXReq *req = (xGLXWaitXReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->contextTag); - - return __glXWaitX(cl, pc); -} - -int __glXSwapCopyContext(__GLXclientState *cl, GLbyte *pc) -{ - xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->source); - __GLX_SWAP_INT(&req->dest); - __GLX_SWAP_INT(&req->mask); - - return __glXCopyContext(cl, pc); -} - -int __glXSwapGetVisualConfigs(__GLXclientState *cl, GLbyte *pc) -{ - ClientPtr client = cl->client; - xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc; - xGLXGetVisualConfigsReply reply; - __GLXscreenInfo *pGlxScreen; - __GLXvisualConfig *pGlxVisual; - CARD32 buf[__GLX_TOTAL_CONFIG]; - unsigned int screen; - int i, p; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_INT(&req->screen); - screen = req->screen; - if (screen > screenInfo.numScreens) { - /* The client library must send a valid screen number. */ - client->errorValue = screen; - return BadValue; - } - pGlxScreen = &__glXActiveScreens[screen]; - - reply.numVisuals = pGlxScreen->numGLXVisuals; - reply.numProps = __GLX_TOTAL_CONFIG; - reply.length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 * - __GLX_TOTAL_CONFIG) >> 2; - reply.type = X_Reply; - reply.sequenceNumber = client->sequence; - - __GLX_SWAP_SHORT(&reply.sequenceNumber); - __GLX_SWAP_INT(&reply.length); - __GLX_SWAP_INT(&reply.numVisuals); - __GLX_SWAP_INT(&reply.numProps); - WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *)&reply); - - for (i=0; i < pGlxScreen->numVisuals; i++) { - pGlxVisual = &pGlxScreen->pGlxVisual[i]; - if (!pGlxScreen->isGLXvis[i] || pGlxVisual->vid == 0) { - /* not a usable visual */ - continue; - } - p = 0; - buf[p++] = pGlxVisual->vid; - buf[p++] = pGlxVisual->class; - buf[p++] = pGlxVisual->rgba; - - buf[p++] = pGlxVisual->redSize; - buf[p++] = pGlxVisual->greenSize; - buf[p++] = pGlxVisual->blueSize; - buf[p++] = pGlxVisual->alphaSize; - buf[p++] = pGlxVisual->accumRedSize; - buf[p++] = pGlxVisual->accumGreenSize; - buf[p++] = pGlxVisual->accumBlueSize; - buf[p++] = pGlxVisual->accumAlphaSize; - - buf[p++] = pGlxVisual->doubleBuffer; - buf[p++] = pGlxVisual->stereo; - - buf[p++] = pGlxVisual->bufferSize; - buf[p++] = pGlxVisual->depthSize; - buf[p++] = pGlxVisual->stencilSize; - buf[p++] = pGlxVisual->auxBuffers; - buf[p++] = pGlxVisual->level; - /* - ** Add token/value pairs for extensions. - */ - buf[p++] = GLX_VISUAL_CAVEAT_EXT; - buf[p++] = pGlxVisual->visualRating; - buf[p++] = GLX_TRANSPARENT_TYPE_EXT; - buf[p++] = pGlxVisual->transparentPixel; - buf[p++] = GLX_TRANSPARENT_RED_VALUE_EXT; - buf[p++] = pGlxVisual->transparentRed; - buf[p++] = GLX_TRANSPARENT_GREEN_VALUE_EXT; - buf[p++] = pGlxVisual->transparentGreen; - buf[p++] = GLX_TRANSPARENT_BLUE_VALUE_EXT; - buf[p++] = pGlxVisual->transparentBlue; - buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT; - buf[p++] = pGlxVisual->transparentAlpha; - buf[p++] = GLX_TRANSPARENT_INDEX_VALUE_EXT; - buf[p++] = pGlxVisual->transparentIndex; - - __GLX_SWAP_INT_ARRAY(buf, __GLX_TOTAL_CONFIG); - WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG, - (char *)buf); - } - return Success; -} - -int __glXSwapCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) -{ - xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->screen); - __GLX_SWAP_INT(&req->visual); - __GLX_SWAP_INT(&req->pixmap); - __GLX_SWAP_INT(&req->glxpixmap); - - return __glXCreateGLXPixmap(cl, pc); -} - -int __glXSwapCreatePixmap(__GLXclientState *cl, GLbyte *pc) -{ - xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->screen); - __GLX_SWAP_INT(&req->fbconfig); - __GLX_SWAP_INT(&req->pixmap); - __GLX_SWAP_INT(&req->glxpixmap); - __GLX_SWAP_INT(&req->numAttribs); - - return __glXCreatePixmap(cl, pc); -} - -int __glXSwapDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) -{ - xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->glxpixmap); - - return __glXDestroyGLXPixmap(cl, pc); -} - -int __glXSwapSwapBuffers(__GLXclientState *cl, GLbyte *pc) -{ - xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->contextTag); - __GLX_SWAP_INT(&req->drawable); - - return __glXSwapBuffers(cl, pc); -} - -int __glXSwapUseXFont(__GLXclientState *cl, GLbyte *pc) -{ - xGLXUseXFontReq *req = (xGLXUseXFontReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->contextTag); - __GLX_SWAP_INT(&req->font); - __GLX_SWAP_INT(&req->first); - __GLX_SWAP_INT(&req->count); - __GLX_SWAP_INT(&req->listBase); - - return __glXUseXFont(cl, pc); -} - - -int __glXSwapQueryExtensionsString(__GLXclientState *cl, GLbyte *pc) -{ - xGLXQueryExtensionsStringReq *req = NULL; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->screen); - - return __glXQueryExtensionsString(cl, pc); -} - -int __glXSwapQueryServerString(__GLXclientState *cl, GLbyte *pc) -{ - xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *)pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->screen); - __GLX_SWAP_INT(&req->name); - - return __glXQueryServerString(cl, pc); -} - -int __glXSwapClientInfo(__GLXclientState *cl, GLbyte *pc) -{ - xGLXClientInfoReq *req = (xGLXClientInfoReq *)pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->major); - __GLX_SWAP_INT(&req->minor); - __GLX_SWAP_INT(&req->numbytes); - - return __glXClientInfo(cl, pc); -} - -int __glXSwapQueryContextInfoEXT(__GLXclientState *cl, char *pc) -{ - xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->context); - - return __glXQueryContextInfoEXT(cl, (GLbyte *)pc); -} - -/************************************************************************/ - -/* -** Swap replies. -*/ - -void __glXSwapMakeCurrentReply(ClientPtr client, xGLXMakeCurrentReadSGIReply *reply) -{ - __GLX_DECLARE_SWAP_VARIABLES; - __GLX_SWAP_SHORT(&reply->sequenceNumber); - __GLX_SWAP_INT(&reply->length); - __GLX_SWAP_INT(&reply->contextTag); - __GLX_SWAP_INT(&reply->writeVid); - __GLX_SWAP_INT(&reply->writeType); - __GLX_SWAP_INT(&reply->readVid); - __GLX_SWAP_INT(&reply->readType); - WriteToClient(client, sz_xGLXMakeCurrentReadSGIReply, (char *)reply); -} - -void __glXSwapIsDirectReply(ClientPtr client, xGLXIsDirectReply *reply) -{ - __GLX_DECLARE_SWAP_VARIABLES; - __GLX_SWAP_SHORT(&reply->sequenceNumber); - __GLX_SWAP_INT(&reply->length); - WriteToClient(client, sz_xGLXIsDirectReply, (char *)reply); -} - -void __glXSwapQueryVersionReply(ClientPtr client, xGLXQueryVersionReply *reply) -{ - __GLX_DECLARE_SWAP_VARIABLES; - __GLX_SWAP_SHORT(&reply->sequenceNumber); - __GLX_SWAP_INT(&reply->length); - __GLX_SWAP_INT(&reply->majorVersion); - __GLX_SWAP_INT(&reply->minorVersion); - WriteToClient(client, sz_xGLXQueryVersionReply, (char *)reply); -} - -void glxSwapQueryExtensionsStringReply(ClientPtr client, - xGLXQueryExtensionsStringReply *reply, char *buf) -{ - int length = reply->length; - __GLX_DECLARE_SWAP_VARIABLES; - __GLX_SWAP_SHORT(&reply->sequenceNumber); - __GLX_SWAP_INT(&reply->length); - __GLX_SWAP_INT(&reply->n); - WriteToClient(client, sz_xGLXQueryExtensionsStringReply, (char *)reply); - __GLX_SWAP_INT_ARRAY((int *)buf, length); - WriteToClient(client, length << 2, buf); -} - -void glxSwapQueryServerStringReply(ClientPtr client, - xGLXQueryServerStringReply *reply, char *buf) -{ - int length = reply->length; - __GLX_DECLARE_SWAP_VARIABLES; - __GLX_SWAP_SHORT(&reply->sequenceNumber); - __GLX_SWAP_INT(&reply->length); - __GLX_SWAP_INT(&reply->n); - WriteToClient(client, sz_xGLXQueryServerStringReply, (char *)reply); - /** no swap is needed for an array of chars **/ - /* __GLX_SWAP_INT_ARRAY((int *)buf, length); */ - WriteToClient(client, length << 2, buf); -} - -void __glXSwapQueryContextInfoEXTReply(ClientPtr client, xGLXQueryContextInfoEXTReply *reply, int *buf) -{ - int length = reply->length; - __GLX_DECLARE_SWAP_VARIABLES; - __GLX_SWAP_SHORT(&reply->sequenceNumber); - __GLX_SWAP_INT(&reply->length); - __GLX_SWAP_INT(&reply->n); - WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)reply); - __GLX_SWAP_INT_ARRAY((int *)buf, length); - WriteToClient(client, length << 2, (char *)buf); -} - - -void __glXSwapQueryContextReply(ClientPtr client, - xGLXQueryContextReply *reply, int *buf) -{ - int length = reply->length; - __GLX_DECLARE_SWAP_VARIABLES; - __GLX_SWAP_SHORT(&reply->sequenceNumber); - __GLX_SWAP_INT(&reply->length); - __GLX_SWAP_INT(&reply->n); - WriteToClient(client, sz_xGLXQueryContextReply, (char *)reply); - __GLX_SWAP_INT_ARRAY((int *)buf, length); - WriteToClient(client, length << 2, (char *)buf); -} - -void __glXSwapGetDrawableAttributesReply(ClientPtr client, - xGLXGetDrawableAttributesReply *reply, int *buf) -{ - __GLX_DECLARE_SWAP_VARIABLES; - __GLX_SWAP_SHORT(&reply->sequenceNumber); - __GLX_SWAP_INT(&reply->length); - __GLX_SWAP_INT(&reply->numAttribs); - __GLX_SWAP_INT_ARRAY( buf, reply->length ); - WriteToClient(client, sz_xGLXGetDrawableAttributesReply, (char *)reply); - WriteToClient(client, reply->length << 2, (char *)buf); -} - -void __glXSwapQueryMaxSwapBarriersSGIXReply(ClientPtr client, xGLXQueryMaxSwapBarriersSGIXReply *reply) -{ - __GLX_DECLARE_SWAP_VARIABLES; - __GLX_SWAP_SHORT(&reply->sequenceNumber); - __GLX_SWAP_INT(&reply->length); - __GLX_SWAP_INT(&reply->max); - WriteToClient(client, sz_xGLXQueryMaxSwapBarriersSGIXReply, (char *)reply); -} - -/************************************************************************/ - -/* -** Render and Renderlarge are not in the GLX API. They are used by the GLX -** client library to send batches of GL rendering commands. -*/ - -int __glXSwapRender(__GLXclientState *cl, GLbyte *pc) -{ - xGLXRenderReq *req; - int left; - __GLXrenderHeader *hdr; - ClientPtr client = cl->client; - __GLX_DECLARE_SWAP_VARIABLES; - - /* - ** NOTE: much of this code also appears in the nonswapping version of this - ** routine, __glXRender(). Any changes made here should also be - ** duplicated there. - */ - - req = (xGLXRenderReq *) pc; - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->contextTag); - - pc += sz_xGLXRenderReq; - left = (req->length << 2) - sz_xGLXRenderReq; - while (left > 0) { - void (* proc)(GLbyte *); - CARD16 opcode; - - /* - ** Verify that the header length and the overall length agree. - ** Also, each command must be word aligned. - */ - hdr = (__GLXrenderHeader *) pc; - __GLX_SWAP_SHORT(&hdr->length); - __GLX_SWAP_SHORT(&hdr->opcode); - - /* - * call the command procedure to swap any arguments - */ - opcode = hdr->opcode; - if ( (opcode >= __GLX_MIN_RENDER_OPCODE) && - (opcode <= __GLX_MAX_RENDER_OPCODE) ) { - proc = __glXSwapRenderTable[opcode]; -#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT - } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) && - (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) { - int index = opcode - __GLX_MIN_RENDER_OPCODE_EXT; - __GLXRenderSwapInfo *info = &__glXSwapRenderTable_EXT[index]; - if (info->swapfunc) { - proc = info->swapfunc; - } - else { - proc = NULL; - if (info->elem_size == 4 && info->nelems > 0) { - __GLX_SWAP_INT_ARRAY( (int *)(pc + __GLX_RENDER_HDR_SIZE), - info->nelems ); - } - else if (info->elem_size == 2 && info->nelems > 0) { - __GLX_SWAP_SHORT_ARRAY( (short *)(pc + __GLX_RENDER_HDR_SIZE), - info->nelems ); - } - else if (info->elem_size == 8 && info->nelems > 0) { - __GLX_SWAP_DOUBLE_ARRAY( (double *)(pc + __GLX_RENDER_HDR_SIZE), - info->nelems ); - } - } -#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */ - } else { - client->errorValue = 0; - return __glXBadRenderRequest; - } - - if (proc != NULL) - (*proc)(pc + __GLX_RENDER_HDR_SIZE); - - /* - * proceed to the next command - */ - pc += hdr->length; - left -= hdr->length; - } - - return __glXRender( cl, (GLbyte *)req ); -} - -/* -** Execute a large rendering request (one that spans multiple X requests). -*/ -int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc) -{ - ClientPtr client = cl->client; - xGLXRenderLargeReq *req; - __GLXrenderLargeHeader *hdr; - __GLX_DECLARE_SWAP_VARIABLES; - - req = (xGLXRenderLargeReq *) pc; - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->contextTag); - __GLX_SWAP_INT(&req->dataBytes); - __GLX_SWAP_SHORT(&req->requestNumber); - __GLX_SWAP_SHORT(&req->requestTotal); - - pc += sz_xGLXRenderLargeReq; - - if (req->requestNumber == 1) { - void (* proc)(GLbyte *) = NULL; - __GLXRenderSwapInfo *info = NULL; - CARD16 opcode; - - hdr = (__GLXrenderLargeHeader *) pc; - __GLX_SWAP_INT(&hdr->length); - __GLX_SWAP_INT(&hdr->opcode); - - /* - * call the command procedure to swap any arguments - * Note that we are assuming that all arguments that needs to be - * swaped are on the first req only ! - */ - opcode = hdr->opcode; - if ( (opcode >= __GLX_MIN_RENDER_OPCODE) && - (opcode <= __GLX_MAX_RENDER_OPCODE) ) { - proc = __glXSwapRenderTable[opcode]; -#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT - } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) && - (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) { - int index = opcode - __GLX_MIN_RENDER_OPCODE_EXT; - info = &__glXSwapRenderTable_EXT[index]; - if (info->swapfunc) { - proc = info->swapfunc; - } -#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */ - } else { - client->errorValue = 0; - cl->largeCmdRequestsTotal = 0; - return __glXBadLargeRequest; - } - - /* - ** Make enough space in the buffer, then copy the entire request. - */ - if (cl->largeCmdBufSize < hdr->length) { - if (!cl->largeCmdBuf) { - cl->largeCmdBuf = (GLbyte *) __glXMalloc(hdr->length); - } else { - cl->largeCmdBuf = (GLbyte *) __glXRealloc(cl->largeCmdBuf, hdr->length); - } - if (!cl->largeCmdBuf) { - cl->largeCmdRequestsTotal = 0; - return BadAlloc; - } - cl->largeCmdBufSize = hdr->length; - } - memcpy(cl->largeCmdBuf, pc, req->dataBytes); - - cl->largeCmdBytesSoFar = req->dataBytes; - cl->largeCmdBytesTotal = hdr->length; - cl->largeCmdRequestsSoFar = 1; - cl->largeCmdRequestsTotal = req->requestTotal; - cl->largeCmdRequestsSwapProc = proc; - cl->largeCmdMaxReqDataSize = req->dataBytes; - cl->largeCmdRequestsSwap_info = info; - - return Success; - - - } - else if (req->requestNumber < cl->largeCmdRequestsTotal) { - /* - * This is not the first nor last request - just copy the data - */ - if ( cl->largeCmdBytesSoFar + req->dataBytes > cl->largeCmdBytesTotal) { - cl->largeCmdRequestsTotal = 0; - return __glXBadLargeRequest; - } - - memcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar, - pc, req->dataBytes); - - cl->largeCmdBytesSoFar += req->dataBytes; - - if (req->dataBytes > cl->largeCmdMaxReqDataSize) - cl->largeCmdMaxReqDataSize = req->dataBytes; - - return Success; - } - else if (req->requestNumber == cl->largeCmdRequestsTotal) { - /* - * this is the last request - * copy the remainder bytes, call the procedure to swap any - * needed data, and then call to transfer the command to all - * back-end servers - */ - if ( cl->largeCmdBytesSoFar + req->dataBytes > cl->largeCmdBytesTotal) { - cl->largeCmdRequestsTotal = 0; - return __glXBadLargeRequest; - } - - memcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar, - pc, req->dataBytes); - - cl->largeCmdBytesSoFar += req->dataBytes; - - if (req->dataBytes > cl->largeCmdMaxReqDataSize) - cl->largeCmdMaxReqDataSize = req->dataBytes; - - if (cl->largeCmdRequestsSwapProc != NULL) { - (*cl->largeCmdRequestsSwapProc)(cl->largeCmdBuf + __GLX_RENDER_LARGE_HDR_SIZE); - } - else if (cl->largeCmdRequestsSwap_info && - cl->largeCmdRequestsSwap_info->nelems > 0) { - if (cl->largeCmdRequestsSwap_info->elem_size == 4) { - __GLX_SWAP_INT_ARRAY( (int *)(pc + __GLX_RENDER_LARGE_HDR_SIZE), - cl->largeCmdRequestsSwap_info->nelems ); - } - else if (cl->largeCmdRequestsSwap_info->elem_size == 2) { - __GLX_SWAP_SHORT_ARRAY( (short *)(pc + __GLX_RENDER_LARGE_HDR_SIZE), - cl->largeCmdRequestsSwap_info->nelems ); - } - else if (cl->largeCmdRequestsSwap_info->elem_size == 8) { - __GLX_SWAP_DOUBLE_ARRAY( (double *)(pc + __GLX_RENDER_LARGE_HDR_SIZE), - cl->largeCmdRequestsSwap_info->nelems ); - } - } - - cl->largeCmdRequestsTotal = 0; - return( __glXSendLargeCommand(cl, req->contextTag) ); - - } - else { - cl->largeCmdRequestsTotal = 0; - return __glXBadLargeRequest; - } - -} - -/************************************************************************/ - -/* -** No support is provided for the vendor-private requests other than -** allocating these entry points in the dispatch table. -*/ - -int __glXSwapVendorPrivate(__GLXclientState *cl, GLbyte *pc) -{ - xGLXVendorPrivateReq *req; - CARD32 vendorCode; - - __GLX_DECLARE_SWAP_VARIABLES; - - req = (xGLXVendorPrivateReq *) pc; - vendorCode = req->vendorCode; - __GLX_SWAP_INT(&vendorCode); - - - switch( vendorCode ) { - - case X_GLvop_DeleteTexturesEXT: - return __glXVForwardSingleReqSwap( cl, pc ); - break; - - case X_GLXvop_SwapIntervalSGI: - if (glxIsExtensionSupported("SGI_swap_control")) { - return __glXVForwardSingleReqSwap( cl, pc ); - } - else { - return Success; - } - break; - -#if 0 /* glx 1.3 */ - case X_GLXvop_CreateGLXVideoSourceSGIX: - break; - case X_GLXvop_DestroyGLXVideoSourceSGIX: - break; - case X_GLXvop_CreateGLXPixmapWithConfigSGIX: - break; - case X_GLXvop_DestroyGLXPbufferSGIX: - break; - case X_GLXvop_ChangeDrawableAttributesSGIX: - break; -#endif - - case X_GLXvop_JoinSwapGroupSGIX: - return __glXSwapJoinSwapGroupSGIX( cl, pc ); - break; - - case X_GLXvop_BindSwapBarrierSGIX: - return __glXSwapBindSwapBarrierSGIX( cl, pc ); - break; - - case X_GLXvop_CreateContextWithConfigSGIX: - return __glXSwapCreateContextWithConfigSGIX( cl, pc ); - break; - - default: - /* - ** unsupported private request - */ - cl->client->errorValue = req->vendorCode; - return __glXUnsupportedPrivateRequest; - } - -} - -int __glXSwapVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) -{ - xGLXVendorPrivateWithReplyReq *req; - CARD32 vendorCode; - - __GLX_DECLARE_SWAP_VARIABLES; - - req = (xGLXVendorPrivateWithReplyReq *) pc; - vendorCode = req->vendorCode; - __GLX_SWAP_INT(&vendorCode); - - switch( vendorCode ) { - - case X_GLvop_GetConvolutionFilterEXT: - case X_GLvop_GetSeparableFilterEXT: - case X_GLvop_GetHistogramEXT: - case X_GLvop_GetMinmaxEXT: - return( __glXNoSuchSingleOpcode(cl, pc) ); - break; - - case X_GLvop_GetConvolutionParameterfvEXT: - case X_GLvop_GetConvolutionParameterivEXT: - case X_GLvop_GetHistogramParameterivEXT: - case X_GLvop_GetMinmaxParameterfvEXT: - case X_GLvop_GetMinmaxParameterivEXT: - case X_GLvop_GenTexturesEXT: - return( __glXVForwardAllWithReplySwapiv(cl, pc) ); - break; - - case X_GLvop_AreTexturesResidentEXT: - case X_GLvop_IsTextureEXT: - return( __glXVForwardPipe0WithReplySwap(cl, pc) ); - break; - -#if 0 /* glx1.3 */ - case X_GLvop_GetDetailTexFuncSGIS: - case X_GLvop_GetSharpenTexFuncSGIS: - case X_GLvop_GetColorTableSGI: - case X_GLvop_GetColorTableParameterfvSGI: - case X_GLvop_GetColorTableParameterivSGI: - case X_GLvop_GetTexFilterFuncSGIS: - case X_GLvop_GetInstrumentsSGIX: - case X_GLvop_InstrumentsBufferSGIX: - case X_GLvop_PollInstrumentsSGIX: - case X_GLvop_FlushRasterSGIX: - case X_GLXvop_CreateGLXPbufferSGIX: - case X_GLXvop_GetDrawableAttributesSGIX: - case X_GLXvop_QueryHyperpipeNetworkSGIX: - case X_GLXvop_QueryHyperpipeConfigSGIX: - case X_GLXvop_HyperpipeConfigSGIX: - case X_GLXvop_DestroyHyperpipeConfigSGIX: -#endif - case X_GLXvop_QueryMaxSwapBarriersSGIX: - return( __glXSwapQueryMaxSwapBarriersSGIX(cl, pc) ); - break; - - case X_GLXvop_GetFBConfigsSGIX: - return( __glXSwapGetFBConfigsSGIX(cl, pc) ); - break; - - case X_GLXvop_MakeCurrentReadSGI: - return( __glXSwapMakeCurrentReadSGI(cl, pc) ); - break; - - case X_GLXvop_QueryContextInfoEXT: - return( __glXSwapQueryContextInfoEXT(cl,(char *)pc) ); - break; - - default: - /* - ** unsupported private request - */ - cl->client->errorValue = req->vendorCode; - return __glXUnsupportedPrivateRequest; - } - -} - -int __glXSwapGetFBConfigs(__GLXclientState *cl, GLbyte *pc) -{ - xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->screen); - - return __glXGetFBConfigs(cl, pc); -} - -int __glXSwapGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) -{ - xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *)pc; - xGLXGetFBConfigsReq new_req; - - new_req.reqType = req->reqType; - new_req.glxCode = req->glxCode; - new_req.length = req->length; - new_req.screen = req->screen; - - return( __glXSwapGetFBConfigs( cl, (GLbyte *)&new_req ) ); -} - -int __glXSwapCreateWindow(__GLXclientState *cl, GLbyte *pc) -{ - xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->screen); - __GLX_SWAP_INT(&req->fbconfig); - __GLX_SWAP_INT(&req->window); - __GLX_SWAP_INT(&req->glxwindow); - __GLX_SWAP_INT(&req->numAttribs); - - return( __glXCreateWindow( cl, (GLbyte *)pc ) ); -} - -int __glXSwapDestroyWindow(__GLXclientState *cl, GLbyte *pc) -{ - xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->glxwindow); - - return( __glXDestroyWindow( cl, (GLbyte *)pc ) ); -} - -int __glXSwapQueryContext(__GLXclientState *cl, GLbyte *pc) -{ - xGLXQueryContextReq *req = (xGLXQueryContextReq *)pc; - - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->context); - - return( __glXQueryContext(cl, (GLbyte *)pc) ); - -} - -int __glXSwapCreatePbuffer(__GLXclientState *cl, GLbyte *pc) -{ - xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *)pc; - int nattr = req->numAttribs; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->screen); - __GLX_SWAP_INT(&req->fbconfig); - __GLX_SWAP_INT(&req->pbuffer); - __GLX_SWAP_INT(&req->numAttribs); - __GLX_SWAP_INT_ARRAY( (int *)(req+1), nattr*2 ); - - return( __glXCreatePbuffer( cl, pc ) ); -} - -int __glXSwapDestroyPbuffer(__GLXclientState *cl, GLbyte *pc) -{ - xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->pbuffer); - - return( __glXDestroyPbuffer( cl, (GLbyte *)pc ) ); -} - -int __glXSwapGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) -{ - xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->drawable); - - return( __glXGetDrawableAttributes(cl, pc) ); -} - -int __glXSwapChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) -{ - xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *)pc; - __GLX_DECLARE_SWAP_VARIABLES; - - __GLX_SWAP_SHORT(&req->length); - __GLX_SWAP_INT(&req->drawable); - __GLX_SWAP_INT(&req->numAttribs); - __GLX_SWAP_INT_ARRAY( (int *)(req+1), req->numAttribs * 2 ); - - return( __glXChangeDrawableAttributes(cl, pc) ); -} +/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 of Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#include "glxserver.h"
+#include "glxutil.h"
+#include <GL/glxtokens.h>
+#include <g_disptab.h>
+#include <pixmapstr.h>
+#include <windowstr.h>
+#include "unpack.h"
+#include "glxext.h"
+#include "glxvendor.h"
+
+extern int glxIsExtensionSupported( char *ext );
+
+/************************************************************************/
+
+/*
+** Byteswapping versions of GLX commands. In most cases they just swap
+** the incoming arguments and then call the unswapped routine. For commands
+** that have replies, a separate swapping routine for the reply is provided;
+** it is called at the end of the unswapped routine.
+*/
+
+int __glXSwapCreateContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->visual);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->shareList);
+
+ return __glXCreateContext(cl, pc);
+}
+
+int __glXSwapCreateNewContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->shareList);
+
+ return __glXCreateNewContext(cl, pc);
+}
+
+int __glXSwapCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->shareList);
+
+ return __glXCreateContextWithConfigSGIX(cl, pc);
+}
+
+int __glXSwapQueryMaxSwapBarriersSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryMaxSwapBarriersSGIXReq *req =
+ (xGLXQueryMaxSwapBarriersSGIXReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+
+ return __glXQueryMaxSwapBarriersSGIX(cl, pc);
+}
+
+int __glXSwapBindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXBindSwapBarrierSGIXReq *req = (xGLXBindSwapBarrierSGIXReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->barrier);
+
+ return __glXBindSwapBarrierSGIX(cl, pc);
+}
+
+int __glXSwapJoinSwapGroupSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXJoinSwapGroupSGIXReq *req = (xGLXJoinSwapGroupSGIXReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->member);
+
+ return __glXJoinSwapGroupSGIX(cl, pc);
+}
+
+int __glXSwapDestroyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+
+ return __glXDestroyContext(cl, pc);
+}
+
+int __glXSwapMakeCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->oldContextTag);
+
+ return __glXMakeCurrent(cl, pc);
+}
+
+int __glXSwapMakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->readdrawable);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->oldContextTag);
+
+ return __glXMakeContextCurrent(cl, pc);
+}
+
+int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->readable);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->oldContextTag);
+
+ return __glXMakeCurrentReadSGI(cl, pc);
+}
+
+int __glXSwapIsDirect(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+
+ return __glXIsDirect(cl, pc);
+}
+
+int __glXSwapQueryVersion(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->majorVersion);
+ __GLX_SWAP_INT(&req->minorVersion);
+
+ return __glXQueryVersion(cl, pc);
+}
+
+int __glXSwapWaitGL(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ return __glXWaitGL(cl, pc);
+}
+
+int __glXSwapWaitX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitXReq *req = (xGLXWaitXReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ return __glXWaitX(cl, pc);
+}
+
+int __glXSwapCopyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->source);
+ __GLX_SWAP_INT(&req->dest);
+ __GLX_SWAP_INT(&req->mask);
+
+ return __glXCopyContext(cl, pc);
+}
+
+int __glXSwapGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
+ xGLXGetVisualConfigsReply reply;
+ __GLXscreenInfo *pGlxScreen;
+ __GLXvisualConfig *pGlxVisual;
+ CARD32 buf[__GLX_TOTAL_CONFIG];
+ unsigned int screen;
+ int i, p;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&req->screen);
+ screen = req->screen;
+ if (screen > screenInfo.numScreens) {
+ /* The client library must send a valid screen number. */
+ client->errorValue = screen;
+ return BadValue;
+ }
+ pGlxScreen = &__glXActiveScreens[screen];
+
+ reply.numVisuals = pGlxScreen->numGLXVisuals;
+ reply.numProps = __GLX_TOTAL_CONFIG;
+ reply.length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 *
+ __GLX_TOTAL_CONFIG) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numVisuals);
+ __GLX_SWAP_INT(&reply.numProps);
+ WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *)&reply);
+
+ for (i=0; i < pGlxScreen->numVisuals; i++) {
+ pGlxVisual = &pGlxScreen->pGlxVisual[i];
+ if (!pGlxScreen->isGLXvis[i] || pGlxVisual->vid == 0) {
+ /* not a usable visual */
+ continue;
+ }
+ p = 0;
+ buf[p++] = pGlxVisual->vid;
+ buf[p++] = pGlxVisual->class;
+ buf[p++] = pGlxVisual->rgba;
+
+ buf[p++] = pGlxVisual->redSize;
+ buf[p++] = pGlxVisual->greenSize;
+ buf[p++] = pGlxVisual->blueSize;
+ buf[p++] = pGlxVisual->alphaSize;
+ buf[p++] = pGlxVisual->accumRedSize;
+ buf[p++] = pGlxVisual->accumGreenSize;
+ buf[p++] = pGlxVisual->accumBlueSize;
+ buf[p++] = pGlxVisual->accumAlphaSize;
+
+ buf[p++] = pGlxVisual->doubleBuffer;
+ buf[p++] = pGlxVisual->stereo;
+
+ buf[p++] = pGlxVisual->bufferSize;
+ buf[p++] = pGlxVisual->depthSize;
+ buf[p++] = pGlxVisual->stencilSize;
+ buf[p++] = pGlxVisual->auxBuffers;
+ buf[p++] = pGlxVisual->level;
+ /*
+ ** Add token/value pairs for extensions.
+ */
+ buf[p++] = GLX_VISUAL_CAVEAT_EXT;
+ buf[p++] = pGlxVisual->visualRating;
+ buf[p++] = GLX_TRANSPARENT_TYPE_EXT;
+ buf[p++] = pGlxVisual->transparentPixel;
+ buf[p++] = GLX_TRANSPARENT_RED_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentRed;
+ buf[p++] = GLX_TRANSPARENT_GREEN_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentGreen;
+ buf[p++] = GLX_TRANSPARENT_BLUE_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentBlue;
+ buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentAlpha;
+ buf[p++] = GLX_TRANSPARENT_INDEX_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentIndex;
+
+ __GLX_SWAP_INT_ARRAY(buf, __GLX_TOTAL_CONFIG);
+ WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG,
+ (char *)buf);
+ }
+ return Success;
+}
+
+int __glXSwapCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->visual);
+ __GLX_SWAP_INT(&req->pixmap);
+ __GLX_SWAP_INT(&req->glxpixmap);
+
+ return __glXCreateGLXPixmap(cl, pc);
+}
+
+int __glXSwapCreatePixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->pixmap);
+ __GLX_SWAP_INT(&req->glxpixmap);
+ __GLX_SWAP_INT(&req->numAttribs);
+
+ return __glXCreatePixmap(cl, pc);
+}
+
+int __glXSwapDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->glxpixmap);
+
+ return __glXDestroyGLXPixmap(cl, pc);
+}
+
+int __glXSwapSwapBuffers(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(&req->drawable);
+
+ return __glXSwapBuffers(cl, pc);
+}
+
+int __glXSwapUseXFont(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXUseXFontReq *req = (xGLXUseXFontReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(&req->font);
+ __GLX_SWAP_INT(&req->first);
+ __GLX_SWAP_INT(&req->count);
+ __GLX_SWAP_INT(&req->listBase);
+
+ return __glXUseXFont(cl, pc);
+}
+
+
+int __glXSwapQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryExtensionsStringReq *req = NULL;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+
+ return __glXQueryExtensionsString(cl, pc);
+}
+
+int __glXSwapQueryServerString(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->name);
+
+ return __glXQueryServerString(cl, pc);
+}
+
+int __glXSwapClientInfo(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXClientInfoReq *req = (xGLXClientInfoReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->major);
+ __GLX_SWAP_INT(&req->minor);
+ __GLX_SWAP_INT(&req->numbytes);
+
+ return __glXClientInfo(cl, pc);
+}
+
+int __glXSwapQueryContextInfoEXT(__GLXclientState *cl, char *pc)
+{
+ xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+
+ return __glXQueryContextInfoEXT(cl, (GLbyte *)pc);
+}
+
+/************************************************************************/
+
+/*
+** Swap replies.
+*/
+
+void __glXSwapMakeCurrentReply(ClientPtr client, xGLXMakeCurrentReadSGIReply *reply)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->contextTag);
+ __GLX_SWAP_INT(&reply->writeVid);
+ __GLX_SWAP_INT(&reply->writeType);
+ __GLX_SWAP_INT(&reply->readVid);
+ __GLX_SWAP_INT(&reply->readType);
+ WriteToClient(client, sz_xGLXMakeCurrentReadSGIReply, (char *)reply);
+}
+
+void __glXSwapIsDirectReply(ClientPtr client, xGLXIsDirectReply *reply)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ WriteToClient(client, sz_xGLXIsDirectReply, (char *)reply);
+}
+
+void __glXSwapQueryVersionReply(ClientPtr client, xGLXQueryVersionReply *reply)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->majorVersion);
+ __GLX_SWAP_INT(&reply->minorVersion);
+ WriteToClient(client, sz_xGLXQueryVersionReply, (char *)reply);
+}
+
+void glxSwapQueryExtensionsStringReply(ClientPtr client,
+ xGLXQueryExtensionsStringReply *reply, char *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->n);
+ WriteToClient(client, sz_xGLXQueryExtensionsStringReply, (char *)reply);
+ __GLX_SWAP_INT_ARRAY((int *)buf, length);
+ WriteToClient(client, length << 2, buf);
+}
+
+void glxSwapQueryServerStringReply(ClientPtr client,
+ xGLXQueryServerStringReply *reply, char *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->n);
+ WriteToClient(client, sz_xGLXQueryServerStringReply, (char *)reply);
+ /** no swap is needed for an array of chars **/
+ /* __GLX_SWAP_INT_ARRAY((int *)buf, length); */
+ WriteToClient(client, length << 2, buf);
+}
+
+void __glXSwapQueryContextInfoEXTReply(ClientPtr client, xGLXQueryContextInfoEXTReply *reply, int *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->n);
+ WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)reply);
+ __GLX_SWAP_INT_ARRAY((int *)buf, length);
+ WriteToClient(client, length << 2, (char *)buf);
+}
+
+
+void __glXSwapQueryContextReply(ClientPtr client,
+ xGLXQueryContextReply *reply, int *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->n);
+ WriteToClient(client, sz_xGLXQueryContextReply, (char *)reply);
+ __GLX_SWAP_INT_ARRAY((int *)buf, length);
+ WriteToClient(client, length << 2, (char *)buf);
+}
+
+void __glXSwapGetDrawableAttributesReply(ClientPtr client,
+ xGLXGetDrawableAttributesReply *reply, int *buf)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->numAttribs);
+ __GLX_SWAP_INT_ARRAY( buf, reply->length );
+ WriteToClient(client, sz_xGLXGetDrawableAttributesReply, (char *)reply);
+ WriteToClient(client, reply->length << 2, (char *)buf);
+}
+
+void __glXSwapQueryMaxSwapBarriersSGIXReply(ClientPtr client, xGLXQueryMaxSwapBarriersSGIXReply *reply)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->max);
+ WriteToClient(client, sz_xGLXQueryMaxSwapBarriersSGIXReply, (char *)reply);
+}
+
+/************************************************************************/
+
+/*
+** Render and Renderlarge are not in the GLX API. They are used by the GLX
+** client library to send batches of GL rendering commands.
+*/
+
+int __glXSwapRender(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXRenderReq *req;
+ int left;
+ __GLXrenderHeader *hdr;
+ ClientPtr client = cl->client;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ /*
+ ** NOTE: much of this code also appears in the nonswapping version of this
+ ** routine, __glXRender(). Any changes made here should also be
+ ** duplicated there.
+ */
+
+ req = (xGLXRenderReq *) pc;
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ pc += sz_xGLXRenderReq;
+ left = (req->length << 2) - sz_xGLXRenderReq;
+ while (left > 0) {
+ void (* proc)(GLbyte *);
+ CARD16 opcode;
+
+ /*
+ ** Verify that the header length and the overall length agree.
+ ** Also, each command must be word aligned.
+ */
+ hdr = (__GLXrenderHeader *) pc;
+ __GLX_SWAP_SHORT(&hdr->length);
+ __GLX_SWAP_SHORT(&hdr->opcode);
+
+ /*
+ * call the command procedure to swap any arguments
+ */
+ opcode = hdr->opcode;
+ if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE) ) {
+ proc = __glXSwapRenderTable[opcode];
+#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
+ } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
+ int index = opcode - __GLX_MIN_RENDER_OPCODE_EXT;
+ __GLXRenderSwapInfo *info = &__glXSwapRenderTable_EXT[index];
+ if (info->swapfunc) {
+ proc = info->swapfunc;
+ }
+ else {
+ proc = NULL;
+ if (info->elem_size == 4 && info->nelems > 0) {
+ __GLX_SWAP_INT_ARRAY( (int *)(pc + __GLX_RENDER_HDR_SIZE),
+ info->nelems );
+ }
+ else if (info->elem_size == 2 && info->nelems > 0) {
+ __GLX_SWAP_SHORT_ARRAY( (short *)(pc + __GLX_RENDER_HDR_SIZE),
+ info->nelems );
+ }
+ else if (info->elem_size == 8 && info->nelems > 0) {
+ __GLX_SWAP_DOUBLE_ARRAY( (double *)(pc + __GLX_RENDER_HDR_SIZE),
+ info->nelems );
+ }
+ }
+#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
+ } else {
+ client->errorValue = 0;
+ return __glXBadRenderRequest;
+ }
+
+ if (proc != NULL)
+ (*proc)(pc + __GLX_RENDER_HDR_SIZE);
+
+ /*
+ * proceed to the next command
+ */
+ pc += hdr->length;
+ left -= hdr->length;
+ }
+
+ return __glXRender( cl, (GLbyte *)req );
+}
+
+/*
+** Execute a large rendering request (one that spans multiple X requests).
+*/
+int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXRenderLargeReq *req;
+ __GLXrenderLargeHeader *hdr;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ req = (xGLXRenderLargeReq *) pc;
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(&req->dataBytes);
+ __GLX_SWAP_SHORT(&req->requestNumber);
+ __GLX_SWAP_SHORT(&req->requestTotal);
+
+ pc += sz_xGLXRenderLargeReq;
+
+ if (req->requestNumber == 1) {
+ void (* proc)(GLbyte *) = NULL;
+ __GLXRenderSwapInfo *info = NULL;
+ CARD16 opcode;
+
+ hdr = (__GLXrenderLargeHeader *) pc;
+ __GLX_SWAP_INT(&hdr->length);
+ __GLX_SWAP_INT(&hdr->opcode);
+
+ /*
+ * call the command procedure to swap any arguments
+ * Note that we are assuming that all arguments that needs to be
+ * swaped are on the first req only !
+ */
+ opcode = hdr->opcode;
+ if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE) ) {
+ proc = __glXSwapRenderTable[opcode];
+#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
+ } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
+ int index = opcode - __GLX_MIN_RENDER_OPCODE_EXT;
+ info = &__glXSwapRenderTable_EXT[index];
+ if (info->swapfunc) {
+ proc = info->swapfunc;
+ }
+#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
+ } else {
+ client->errorValue = 0;
+ cl->largeCmdRequestsTotal = 0;
+ return __glXBadLargeRequest;
+ }
+
+ /*
+ ** Make enough space in the buffer, then copy the entire request.
+ */
+ if (cl->largeCmdBufSize < hdr->length) {
+ if (!cl->largeCmdBuf) {
+ cl->largeCmdBuf = (GLbyte *) __glXMalloc(hdr->length);
+ } else {
+ cl->largeCmdBuf = (GLbyte *) __glXRealloc(cl->largeCmdBuf, hdr->length);
+ }
+ if (!cl->largeCmdBuf) {
+ cl->largeCmdRequestsTotal = 0;
+ return BadAlloc;
+ }
+ cl->largeCmdBufSize = hdr->length;
+ }
+ memcpy(cl->largeCmdBuf, pc, req->dataBytes);
+
+ cl->largeCmdBytesSoFar = req->dataBytes;
+ cl->largeCmdBytesTotal = hdr->length;
+ cl->largeCmdRequestsSoFar = 1;
+ cl->largeCmdRequestsTotal = req->requestTotal;
+ cl->largeCmdRequestsSwapProc = proc;
+ cl->largeCmdMaxReqDataSize = req->dataBytes;
+ cl->largeCmdRequestsSwap_info = info;
+
+ return Success;
+
+
+ }
+ else if (req->requestNumber < cl->largeCmdRequestsTotal) {
+ /*
+ * This is not the first nor last request - just copy the data
+ */
+ if ( cl->largeCmdBytesSoFar + req->dataBytes > cl->largeCmdBytesTotal) {
+ cl->largeCmdRequestsTotal = 0;
+ return __glXBadLargeRequest;
+ }
+
+ memcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar,
+ pc, req->dataBytes);
+
+ cl->largeCmdBytesSoFar += req->dataBytes;
+
+ if (req->dataBytes > cl->largeCmdMaxReqDataSize)
+ cl->largeCmdMaxReqDataSize = req->dataBytes;
+
+ return Success;
+ }
+ else if (req->requestNumber == cl->largeCmdRequestsTotal) {
+ /*
+ * this is the last request
+ * copy the remainder bytes, call the procedure to swap any
+ * needed data, and then call to transfer the command to all
+ * back-end servers
+ */
+ if ( cl->largeCmdBytesSoFar + req->dataBytes > cl->largeCmdBytesTotal) {
+ cl->largeCmdRequestsTotal = 0;
+ return __glXBadLargeRequest;
+ }
+
+ memcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar,
+ pc, req->dataBytes);
+
+ cl->largeCmdBytesSoFar += req->dataBytes;
+
+ if (req->dataBytes > cl->largeCmdMaxReqDataSize)
+ cl->largeCmdMaxReqDataSize = req->dataBytes;
+
+ if (cl->largeCmdRequestsSwapProc != NULL) {
+ (*cl->largeCmdRequestsSwapProc)(cl->largeCmdBuf + __GLX_RENDER_LARGE_HDR_SIZE);
+ }
+ else if (cl->largeCmdRequestsSwap_info &&
+ cl->largeCmdRequestsSwap_info->nelems > 0) {
+ if (cl->largeCmdRequestsSwap_info->elem_size == 4) {
+ __GLX_SWAP_INT_ARRAY( (int *)(pc + __GLX_RENDER_LARGE_HDR_SIZE),
+ cl->largeCmdRequestsSwap_info->nelems );
+ }
+ else if (cl->largeCmdRequestsSwap_info->elem_size == 2) {
+ __GLX_SWAP_SHORT_ARRAY( (short *)(pc + __GLX_RENDER_LARGE_HDR_SIZE),
+ cl->largeCmdRequestsSwap_info->nelems );
+ }
+ else if (cl->largeCmdRequestsSwap_info->elem_size == 8) {
+ __GLX_SWAP_DOUBLE_ARRAY( (double *)(pc + __GLX_RENDER_LARGE_HDR_SIZE),
+ cl->largeCmdRequestsSwap_info->nelems );
+ }
+ }
+
+ cl->largeCmdRequestsTotal = 0;
+ return( __glXSendLargeCommand(cl, req->contextTag) );
+
+ }
+ else {
+ cl->largeCmdRequestsTotal = 0;
+ return __glXBadLargeRequest;
+ }
+
+}
+
+/************************************************************************/
+
+/*
+** No support is provided for the vendor-private requests other than
+** allocating these entry points in the dispatch table.
+*/
+
+int __glXSwapVendorPrivate(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateReq *req;
+ CARD32 vendorCode;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ req = (xGLXVendorPrivateReq *) pc;
+ vendorCode = req->vendorCode;
+ __GLX_SWAP_INT(&vendorCode);
+
+
+ switch( vendorCode ) {
+
+ case X_GLvop_DeleteTexturesEXT:
+ return __glXVForwardSingleReqSwap( cl, pc );
+ break;
+
+ case X_GLXvop_SwapIntervalSGI:
+ if (glxIsExtensionSupported("SGI_swap_control")) {
+ return __glXVForwardSingleReqSwap( cl, pc );
+ }
+ else {
+ return Success;
+ }
+ break;
+
+#if 0 /* glx 1.3 */
+ case X_GLXvop_CreateGLXVideoSourceSGIX:
+ break;
+ case X_GLXvop_DestroyGLXVideoSourceSGIX:
+ break;
+ case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
+ break;
+ case X_GLXvop_DestroyGLXPbufferSGIX:
+ break;
+ case X_GLXvop_ChangeDrawableAttributesSGIX:
+ break;
+#endif
+
+ case X_GLXvop_JoinSwapGroupSGIX:
+ return __glXSwapJoinSwapGroupSGIX( cl, pc );
+ break;
+
+ case X_GLXvop_BindSwapBarrierSGIX:
+ return __glXSwapBindSwapBarrierSGIX( cl, pc );
+ break;
+
+ case X_GLXvop_CreateContextWithConfigSGIX:
+ return __glXSwapCreateContextWithConfigSGIX( cl, pc );
+ break;
+
+ default:
+ /*
+ ** unsupported private request
+ */
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+ }
+
+}
+
+int __glXSwapVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateWithReplyReq *req;
+ CARD32 vendorCode;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ req = (xGLXVendorPrivateWithReplyReq *) pc;
+ vendorCode = req->vendorCode;
+ __GLX_SWAP_INT(&vendorCode);
+
+ switch( vendorCode ) {
+
+ case X_GLvop_GetConvolutionFilterEXT:
+ case X_GLvop_GetSeparableFilterEXT:
+ case X_GLvop_GetHistogramEXT:
+ case X_GLvop_GetMinmaxEXT:
+ return( __glXNoSuchSingleOpcode(cl, pc) );
+ break;
+
+ case X_GLvop_GetConvolutionParameterfvEXT:
+ case X_GLvop_GetConvolutionParameterivEXT:
+ case X_GLvop_GetHistogramParameterivEXT:
+ case X_GLvop_GetMinmaxParameterfvEXT:
+ case X_GLvop_GetMinmaxParameterivEXT:
+ case X_GLvop_GenTexturesEXT:
+ return( __glXVForwardAllWithReplySwapiv(cl, pc) );
+ break;
+
+ case X_GLvop_AreTexturesResidentEXT:
+ case X_GLvop_IsTextureEXT:
+ return( __glXVForwardPipe0WithReplySwap(cl, pc) );
+ break;
+
+#if 0 /* glx1.3 */
+ case X_GLvop_GetDetailTexFuncSGIS:
+ case X_GLvop_GetSharpenTexFuncSGIS:
+ case X_GLvop_GetColorTableSGI:
+ case X_GLvop_GetColorTableParameterfvSGI:
+ case X_GLvop_GetColorTableParameterivSGI:
+ case X_GLvop_GetTexFilterFuncSGIS:
+ case X_GLvop_GetInstrumentsSGIX:
+ case X_GLvop_InstrumentsBufferSGIX:
+ case X_GLvop_PollInstrumentsSGIX:
+ case X_GLvop_FlushRasterSGIX:
+ case X_GLXvop_CreateGLXPbufferSGIX:
+ case X_GLXvop_GetDrawableAttributesSGIX:
+ case X_GLXvop_QueryHyperpipeNetworkSGIX:
+ case X_GLXvop_QueryHyperpipeConfigSGIX:
+ case X_GLXvop_HyperpipeConfigSGIX:
+ case X_GLXvop_DestroyHyperpipeConfigSGIX:
+#endif
+ case X_GLXvop_QueryMaxSwapBarriersSGIX:
+ return( __glXSwapQueryMaxSwapBarriersSGIX(cl, pc) );
+ break;
+
+ case X_GLXvop_GetFBConfigsSGIX:
+ return( __glXSwapGetFBConfigsSGIX(cl, pc) );
+ break;
+
+ case X_GLXvop_MakeCurrentReadSGI:
+ return( __glXSwapMakeCurrentReadSGI(cl, pc) );
+ break;
+
+ case X_GLXvop_QueryContextInfoEXT:
+ return( __glXSwapQueryContextInfoEXT(cl,(char *)pc) );
+ break;
+
+ default:
+ /*
+ ** unsupported private request
+ */
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+ }
+
+}
+
+int __glXSwapGetFBConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+
+ return __glXGetFBConfigs(cl, pc);
+}
+
+int __glXSwapGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *)pc;
+ xGLXGetFBConfigsReq new_req;
+
+ new_req.reqType = req->reqType;
+ new_req.glxCode = req->glxCode;
+ new_req.length = req->length;
+ new_req.screen = req->screen;
+
+ return( __glXSwapGetFBConfigs( cl, (GLbyte *)&new_req ) );
+}
+
+int __glXSwapCreateWindow(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->window);
+ __GLX_SWAP_INT(&req->glxwindow);
+ __GLX_SWAP_INT(&req->numAttribs);
+
+ return( __glXCreateWindow( cl, (GLbyte *)pc ) );
+}
+
+int __glXSwapDestroyWindow(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->glxwindow);
+
+ return( __glXDestroyWindow( cl, (GLbyte *)pc ) );
+}
+
+int __glXSwapQueryContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryContextReq *req = (xGLXQueryContextReq *)pc;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+
+ return( __glXQueryContext(cl, (GLbyte *)pc) );
+
+}
+
+int __glXSwapCreatePbuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *)pc;
+ int nattr = req->numAttribs;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->pbuffer);
+ __GLX_SWAP_INT(&req->numAttribs);
+ __GLX_SWAP_INT_ARRAY( (int *)(req+1), nattr*2 );
+
+ return( __glXCreatePbuffer( cl, pc ) );
+}
+
+int __glXSwapDestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->pbuffer);
+
+ return( __glXDestroyPbuffer( cl, (GLbyte *)pc ) );
+}
+
+int __glXSwapGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+
+ return( __glXGetDrawableAttributes(cl, pc) );
+}
+
+int __glXSwapChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->numAttribs);
+ __GLX_SWAP_INT_ARRAY( (int *)(req+1), req->numAttribs * 2 );
+
+ return( __glXChangeDrawableAttributes(cl, pc) );
+}
diff --git a/xorg-server/hw/dmx/glxProxy/glxfbconfig.c b/xorg-server/hw/dmx/glxProxy/glxfbconfig.c index c721fdd24..3611cf61e 100644 --- a/xorg-server/hw/dmx/glxProxy/glxfbconfig.c +++ b/xorg-server/hw/dmx/glxProxy/glxfbconfig.c @@ -1,106 +1,106 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * 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 - * SILICON GRAPHICS, INC. 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 of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#include "glxfbconfig.h" - -int AreFBConfigsMatch( __GLXFBConfig *c1, __GLXFBConfig *c2 ) -{ - int match; - - match = ( - (c1->visualType == c2->visualType) && - (c1->transparentType == c2->transparentType) && - (c1->transparentRed == c2->transparentRed) && - (c1->transparentGreen == c2->transparentGreen) && - (c1->transparentBlue == c2->transparentBlue) && - (c1->transparentAlpha == c2->transparentAlpha) && - (c1->transparentIndex == c2->transparentIndex) && - (c1->visualCaveat == c2->visualCaveat) && - (c1->drawableType == c2->drawableType) && - (c1->renderType == c2->renderType) && -#if 0 - (c1->maxPbufferWidth == c2->maxPbufferWidth) && - (c1->maxPbufferHeight == c2->maxPbufferHeight) && - (c1->maxPbufferPixels == c2->maxPbufferPixels) && - (c1->optimalPbufferWidth == c2->optimalPbufferWidth) && - (c1->optimalPbufferHeight == c2->optimalPbufferHeight) && -#endif - (c1->visualSelectGroup == c2->visualSelectGroup) && - (c1->rgbMode == c2->rgbMode) && - (c1->colorIndexMode == c2->colorIndexMode) && - (c1->doubleBufferMode == c2->doubleBufferMode) && - (c1->stereoMode == c2->stereoMode) && - (c1->haveAccumBuffer == c2->haveAccumBuffer) && - (c1->haveDepthBuffer == c2->haveDepthBuffer) && - (c1->haveStencilBuffer == c2->haveStencilBuffer) && - (c1->accumRedBits == c2->accumRedBits) && - (c1->accumGreenBits == c2->accumGreenBits) && - (c1->accumBlueBits == c2->accumBlueBits) && - (c1->accumAlphaBits == c2->accumAlphaBits) && - (c1->depthBits == c2->depthBits) && - (c1->stencilBits == c2->stencilBits) && - (c1->indexBits == c2->indexBits) && - (c1->redBits == c2->redBits) && - (c1->greenBits == c2->greenBits) && - (c1->blueBits == c2->blueBits) && - (c1->alphaBits == c2->alphaBits) && - (c1->redMask == c2->redMask) && - (c1->greenMask == c2->greenMask) && - (c1->blueMask == c2->blueMask) && - (c1->alphaMask == c2->alphaMask) && - (c1->multiSampleSize == c2->multiSampleSize) && - (c1->nMultiSampleBuffers == c2->nMultiSampleBuffers) && - (c1->maxAuxBuffers == c2->maxAuxBuffers) && - (c1->level == c2->level) && - (c1->extendedRange == c2->extendedRange) && - (c1->minRed == c2->minRed) && - (c1->maxRed == c2->maxRed) && - (c1->minGreen == c2->minGreen) && - (c1->maxGreen == c2->maxGreen) && - (c1->minBlue == c2->minBlue) && - (c1->maxBlue == c2->maxBlue) && - (c1->minAlpha == c2->minAlpha) && - (c1->maxAlpha == c2->maxAlpha) - ); - - return( match ); -} - -__GLXFBConfig *FindMatchingFBConfig( __GLXFBConfig *c, __GLXFBConfig *configs, int nconfigs ) -{ - int i; - - for (i=0; i<nconfigs; i++) { - if ( AreFBConfigsMatch( c, configs + i ) ) - return( configs + i ); - } - - return(0); -} +/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 of Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#include "glxfbconfig.h"
+
+int AreFBConfigsMatch( __GLXFBConfig *c1, __GLXFBConfig *c2 )
+{
+ int match;
+
+ match = (
+ (c1->visualType == c2->visualType) &&
+ (c1->transparentType == c2->transparentType) &&
+ (c1->transparentRed == c2->transparentRed) &&
+ (c1->transparentGreen == c2->transparentGreen) &&
+ (c1->transparentBlue == c2->transparentBlue) &&
+ (c1->transparentAlpha == c2->transparentAlpha) &&
+ (c1->transparentIndex == c2->transparentIndex) &&
+ (c1->visualCaveat == c2->visualCaveat) &&
+ (c1->drawableType == c2->drawableType) &&
+ (c1->renderType == c2->renderType) &&
+#if 0
+ (c1->maxPbufferWidth == c2->maxPbufferWidth) &&
+ (c1->maxPbufferHeight == c2->maxPbufferHeight) &&
+ (c1->maxPbufferPixels == c2->maxPbufferPixels) &&
+ (c1->optimalPbufferWidth == c2->optimalPbufferWidth) &&
+ (c1->optimalPbufferHeight == c2->optimalPbufferHeight) &&
+#endif
+ (c1->visualSelectGroup == c2->visualSelectGroup) &&
+ (c1->rgbMode == c2->rgbMode) &&
+ (c1->colorIndexMode == c2->colorIndexMode) &&
+ (c1->doubleBufferMode == c2->doubleBufferMode) &&
+ (c1->stereoMode == c2->stereoMode) &&
+ (c1->haveAccumBuffer == c2->haveAccumBuffer) &&
+ (c1->haveDepthBuffer == c2->haveDepthBuffer) &&
+ (c1->haveStencilBuffer == c2->haveStencilBuffer) &&
+ (c1->accumRedBits == c2->accumRedBits) &&
+ (c1->accumGreenBits == c2->accumGreenBits) &&
+ (c1->accumBlueBits == c2->accumBlueBits) &&
+ (c1->accumAlphaBits == c2->accumAlphaBits) &&
+ (c1->depthBits == c2->depthBits) &&
+ (c1->stencilBits == c2->stencilBits) &&
+ (c1->indexBits == c2->indexBits) &&
+ (c1->redBits == c2->redBits) &&
+ (c1->greenBits == c2->greenBits) &&
+ (c1->blueBits == c2->blueBits) &&
+ (c1->alphaBits == c2->alphaBits) &&
+ (c1->redMask == c2->redMask) &&
+ (c1->greenMask == c2->greenMask) &&
+ (c1->blueMask == c2->blueMask) &&
+ (c1->alphaMask == c2->alphaMask) &&
+ (c1->multiSampleSize == c2->multiSampleSize) &&
+ (c1->nMultiSampleBuffers == c2->nMultiSampleBuffers) &&
+ (c1->maxAuxBuffers == c2->maxAuxBuffers) &&
+ (c1->level == c2->level) &&
+ (c1->extendedRange == c2->extendedRange) &&
+ (c1->minRed == c2->minRed) &&
+ (c1->maxRed == c2->maxRed) &&
+ (c1->minGreen == c2->minGreen) &&
+ (c1->maxGreen == c2->maxGreen) &&
+ (c1->minBlue == c2->minBlue) &&
+ (c1->maxBlue == c2->maxBlue) &&
+ (c1->minAlpha == c2->minAlpha) &&
+ (c1->maxAlpha == c2->maxAlpha)
+ );
+
+ return match;
+}
+
+__GLXFBConfig *FindMatchingFBConfig( __GLXFBConfig *c, __GLXFBConfig *configs, int nconfigs )
+{
+ int i;
+
+ for (i=0; i<nconfigs; i++) {
+ if ( AreFBConfigsMatch( c, configs + i ) )
+ return configs + i;
+ }
+
+ return 0;
+}
diff --git a/xorg-server/hw/dmx/glxProxy/glxscreens.c b/xorg-server/hw/dmx/glxProxy/glxscreens.c index 8cf7b281c..6425a2bfe 100644 --- a/xorg-server/hw/dmx/glxProxy/glxscreens.c +++ b/xorg-server/hw/dmx/glxProxy/glxscreens.c @@ -327,7 +327,7 @@ char *__glXGetServerString( unsigned int name ) break;
}
- return( ret );
+ return ret;
}
@@ -338,10 +338,10 @@ __GLXFBConfig *glxLookupFBConfig( GLXFBConfigID id ) for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
if ( __glXFBConfigs[j]->id == id)
- return( __glXFBConfigs[j] );
+ return __glXFBConfigs[j];
}
- return(NULL);
+ return NULL;
}
__GLXFBConfig *glxLookupFBConfigByVID( VisualID vid )
@@ -350,10 +350,10 @@ __GLXFBConfig *glxLookupFBConfigByVID( VisualID vid ) for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
if ( __glXFBConfigs[j]->associatedVisualId == vid)
- return( __glXFBConfigs[j] );
+ return __glXFBConfigs[j];
}
- return(NULL);
+ return NULL;
}
__GLXFBConfig *glxLookupBackEndFBConfig( GLXFBConfigID id, int screen )
@@ -363,10 +363,10 @@ __GLXFBConfig *glxLookupBackEndFBConfig( GLXFBConfigID id, int screen ) for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
if ( __glXFBConfigs[j]->id == id)
- return( __glXFBConfigs[j+screen+1] );
+ return __glXFBConfigs[j+screen+1];
}
- return(NULL);
+ return NULL;
}
diff --git a/xorg-server/hw/dmx/glxProxy/glxsingle.c b/xorg-server/hw/dmx/glxProxy/glxsingle.c index 8325b4afc..056c74066 100644 --- a/xorg-server/hw/dmx/glxProxy/glxsingle.c +++ b/xorg-server/hw/dmx/glxProxy/glxsingle.c @@ -397,6 +397,7 @@ int __glXForwardSingleReqSwap( __GLXclientState *cl, GLbyte *pc ) {
xGLXSingleReq *req = (xGLXSingleReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
@@ -420,6 +421,7 @@ int __glXForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc ) {
xGLXSingleReq *req = (xGLXSingleReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
@@ -443,6 +445,7 @@ int __glXForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc ) {
xGLXSingleReq *req = (xGLXSingleReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
@@ -467,6 +470,7 @@ int __glXForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc ) {
xGLXSingleReq *req = (xGLXSingleReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
@@ -491,6 +495,7 @@ int __glXForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc ) {
xGLXSingleReq *req = (xGLXSingleReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
@@ -515,6 +520,7 @@ int __glXForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc ) {
xGLXSingleReq *req = (xGLXSingleReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
@@ -539,6 +545,7 @@ int __glXForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc ) {
xGLXSingleReq *req = (xGLXSingleReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
@@ -563,6 +570,7 @@ int __glXForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc ) {
xGLXSingleReq *req = (xGLXSingleReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
@@ -587,6 +595,7 @@ int __glXForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc ) {
xGLXSingleReq *req = (xGLXSingleReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
@@ -659,7 +668,7 @@ static GLint __glReadPixels_size(GLenum format, GLenum type, GLint w, GLint h, }
if (elementbits_return) *elementbits_return = elements;
if (rowbytes_return) *rowbytes_return = rowsize;
- return (rowsize * h);
+ return rowsize * h;
} else {
return -1;
}
@@ -709,7 +718,7 @@ static GLint __glReadPixels_size(GLenum format, GLenum type, GLint w, GLint h, if (elementbits_return) *elementbits_return = esize*elements*8;
if (rowbytes_return) *rowbytes_return = rowsize;
- return (rowsize * h);
+ return rowsize * h;
}
static int intersectRect( int x1, int x2, int y1, int y2,
@@ -725,14 +734,14 @@ static int intersectRect( int x1, int x2, int y1, int y2, if ( (width <= 0) || (height <= 0) ) {
*ix1 = *ix2 = *iy1 = *iy2 = 0;
- return(0);
+ return 0;
}
else {
*ix1 = left;
*ix2 = right;
*iy1 = top;
*iy2 = bottom;
- return( width * height );
+ return width * height;
}
}
@@ -802,7 +811,7 @@ int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc) if (buf_size > 0) {
buf = (char *) malloc( buf_size );
if ( !buf ) {
- return( BadAlloc );
+ return BadAlloc;
}
}
else {
diff --git a/xorg-server/hw/dmx/glxProxy/glxutil.c b/xorg-server/hw/dmx/glxProxy/glxutil.c index 2460ed0dc..ad34eef05 100644 --- a/xorg-server/hw/dmx/glxProxy/glxutil.c +++ b/xorg-server/hw/dmx/glxProxy/glxutil.c @@ -105,7 +105,5 @@ __glXRealloc(void *addr, size_t newSize) void
__glXFree(void *addr)
{
- if (addr) {
- free(addr);
- }
+ free(addr);
}
diff --git a/xorg-server/hw/dmx/glxProxy/glxvendor.c b/xorg-server/hw/dmx/glxProxy/glxvendor.c index f2cea706f..02c8ad73d 100644 --- a/xorg-server/hw/dmx/glxProxy/glxvendor.c +++ b/xorg-server/hw/dmx/glxProxy/glxvendor.c @@ -392,6 +392,7 @@ int __glXVForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc ) {
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->vendorCode);
@@ -416,6 +417,7 @@ int __glXVForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc ) {
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->vendorCode);
@@ -440,6 +442,7 @@ int __glXVForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc ) {
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->vendorCode);
@@ -464,6 +467,7 @@ int __glXVForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc ) {
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->vendorCode);
@@ -488,6 +492,7 @@ int __glXVForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc ) {
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->vendorCode);
@@ -512,6 +517,7 @@ int __glXVForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc ) {
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->vendorCode);
@@ -536,6 +542,7 @@ int __glXVForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc ) {
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->vendorCode);
@@ -560,6 +567,7 @@ int __glXVForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc ) {
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->vendorCode);
diff --git a/xorg-server/hw/dmx/glxProxy/glxvisuals.c b/xorg-server/hw/dmx/glxProxy/glxvisuals.c index 6e30b4edc..aaace39b6 100644 --- a/xorg-server/hw/dmx/glxProxy/glxvisuals.c +++ b/xorg-server/hw/dmx/glxProxy/glxvisuals.c @@ -77,11 +77,11 @@ int glxVisualsMatch( __GLXvisualConfig *v1, __GLXvisualConfig *v2 ) (v1->nMultiSampleBuffers == v2->nMultiSampleBuffers) &&
(v1->visualSelectGroup == v2->visualSelectGroup) ) {
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
@@ -93,12 +93,12 @@ VisualID glxMatchGLXVisualInConfigList( __GLXvisualConfig *pGlxVisual, __GLXvisu if (glxVisualsMatch( pGlxVisual, &configs[i] )) {
- return( configs[i].vid );
+ return configs[i].vid;
}
}
- return(0);
+ return 0;
}
VisualID glxMatchVisualInConfigList( ScreenPtr pScreen, VisualPtr pVisual, __GLXvisualConfig *configs, int nconfigs )
@@ -109,7 +109,7 @@ VisualID glxMatchVisualInConfigList( ScreenPtr pScreen, VisualPtr pVisual, __GLX /* check that the glx extension has been initialized */
if ( !__glXActiveScreens )
- return(0);
+ return 0;
pGlxScreen = &__glXActiveScreens[pScreen->myNum];
pGlxVisual = pGlxScreen->pGlxVisual;
@@ -124,7 +124,7 @@ VisualID glxMatchVisualInConfigList( ScreenPtr pScreen, VisualPtr pVisual, __GLX /*
* the visual is not supported by glx
*/
- return(0);
+ return 0;
}
return( glxMatchGLXVisualInConfigList(pGlxVisual, configs, nconfigs) );
@@ -151,12 +151,12 @@ VisualPtr glxMatchVisual( ScreenPtr pScreen, VisualPtr pVisual, ScreenPtr pMatch */
for (j=0; j<pMatchScreen->numVisuals; j++) {
if (vid == pMatchScreen->visuals[j].vid) {
- return( &pMatchScreen->visuals[j] );
+ return &pMatchScreen->visuals[j];
}
}
}
- return(0);
+ return 0;
}
void glxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
@@ -198,7 +198,7 @@ static VisualID FindClosestVisual( VisualPtr pVisual, int rootDepth, while( pdepth[d].vids[v] != vis->vid ) vis++;
if (vis->class == pVisual->class) {
- return( pdepth[d].vids[v] );
+ return pdepth[d].vids[v];
}
}
}
@@ -216,7 +216,7 @@ static VisualID FindClosestVisual( VisualPtr pVisual, int rootDepth, while( pdepth[d].vids[v] != vis->vid ) vis++;
if (vis->class == pVisual->class) {
- return( pdepth[d].vids[v] );
+ return pdepth[d].vids[v];
}
}
}
@@ -224,7 +224,7 @@ static VisualID FindClosestVisual( VisualPtr pVisual, int rootDepth, /*
* if not found - just take the first visual
*/
- return( pdepth[0].vids[0] );
+ return pdepth[0].vids[0];
}
Bool glxInitVisuals(int *nvisualp, VisualPtr *visualp,
@@ -531,8 +531,7 @@ Bool glxInitVisuals(int *nvisualp, VisualPtr *visualp, __glXFree(pNewVisualConfigs);
/* Free the private list created by DDX HW driver */
- if (visualPrivates)
- free(visualPrivates);
+ free(visualPrivates);
visualPrivates = NULL;
return TRUE;
diff --git a/xorg-server/hw/dmx/glxProxy/render2swap.c b/xorg-server/hw/dmx/glxProxy/render2swap.c index 34122fb36..34fd19624 100644 --- a/xorg-server/hw/dmx/glxProxy/render2swap.c +++ b/xorg-server/hw/dmx/glxProxy/render2swap.c @@ -69,6 +69,7 @@ void __glXDispSwap_Map1f(GLbyte *pc) GLenum target;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_INT(pc + 12);
@@ -99,6 +100,7 @@ void __glXDispSwap_Map2f(GLbyte *pc) GLenum target;
GLint compsize;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 0);
__GLX_SWAP_INT(pc + 12);
@@ -137,6 +139,7 @@ void __glXDispSwap_Map1d(GLbyte *pc) GLenum target;
GLdouble u1, u2, *points;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_DOUBLE(pc + 0);
__GLX_SWAP_DOUBLE(pc + 8);
@@ -179,6 +182,7 @@ void __glXDispSwap_Map2d(GLbyte *pc) GLint uorder, vorder, ustride, vstride, k, compsize;
GLenum target;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_DOUBLE(pc + 0);
__GLX_SWAP_DOUBLE(pc + 8);
@@ -228,6 +232,7 @@ void __glXDispSwap_CallLists(GLbyte *pc) GLenum type;
GLsizei n;
__GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
__GLX_SWAP_INT(pc + 4);
__GLX_SWAP_INT(pc + 0);
diff --git a/xorg-server/hw/dmx/glxProxy/unpack.h b/xorg-server/hw/dmx/glxProxy/unpack.h index 73d0485e3..b89a53411 100644 --- a/xorg-server/hw/dmx/glxProxy/unpack.h +++ b/xorg-server/hw/dmx/glxProxy/unpack.h @@ -138,7 +138,9 @@ extern xGLXSingleReply __glXReply; ** conceivably be replaced with routines that do the job faster.
*/
#define __GLX_DECLARE_SWAP_VARIABLES \
- GLbyte sw; \
+ GLbyte sw
+
+#define __GLX_DECLARE_SWAP_ARRAY_VARIABLES \
GLbyte *swapPC; \
GLbyte *swapEnd
diff --git a/xorg-server/hw/dmx/input/dmxbackend.c b/xorg-server/hw/dmx/input/dmxbackend.c index 55615cf39..35e9e9616 100644 --- a/xorg-server/hw/dmx/input/dmxbackend.c +++ b/xorg-server/hw/dmx/input/dmxbackend.c @@ -1,616 +1,616 @@ -/* - * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * David H. Dawes <dawes@xfree86.org> - * Kevin E. Martin <kem@redhat.com> - * Rickard E. (Rik) Faith <faith@redhat.com> - */ - -/** \file - * These routines support taking input from devices on the backend - * (output) displays. \see dmxcommon.c. */ - -#ifdef HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#define DMX_BACKEND_DEBUG 0 - -#include "dmxinputinit.h" -#include "dmxbackend.h" -#include "dmxcommon.h" -#include "dmxconsole.h" -#include "dmxcursor.h" -#include "dmxprop.h" -#include "dmxsync.h" -#include "dmxcb.h" /* For dmxGlobalWidth and dmxGlobalHeight */ -#include "dmxevents.h" /* For dmxGetGlobalPosition */ -#include "ChkNotMaskEv.h" - -#include "inputstr.h" -#include "input.h" -#include <X11/keysym.h> -#include "mipointer.h" -#include "scrnintstr.h" -#include "windowstr.h" - -/* Private area for backend devices. */ -typedef struct _myPrivate { - DMX_COMMON_PRIVATE; - int myScreen; - DMXScreenInfo *grabbedScreen; - - int lastX, lastY; - int centerX, centerY; - int relative; - int newscreen; - int initialized; - DevicePtr mou, kbd; - int entered; - int offX, offY; -} myPrivate; - -#if DMX_BACKEND_DEBUG -#define DMXDBG0(f) dmxLog(dmxDebug,f) -#define DMXDBG1(f,a) dmxLog(dmxDebug,f,a) -#define DMXDBG2(f,a,b) dmxLog(dmxDebug,f,a,b) -#define DMXDBG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c) -#define DMXDBG4(f,a,b,c,d) dmxLog(dmxDebug,f,a,b,c,d) -#define DMXDBG5(f,a,b,c,d,e) dmxLog(dmxDebug,f,a,b,c,d,e) -#define DMXDBG6(f,a,b,c,d,e,g) dmxLog(dmxDebug,f,a,b,c,d,e,g) -#define DMXDBG7(f,a,b,c,d,e,g,h) dmxLog(dmxDebug,f,a,b,c,d,e,g,h) -#define DMXDBG8(f,a,b,c,d,e,g,h,i) dmxLog(dmxDebug,f,a,b,c,d,e,g,h,i) -#define DMXDBG9(f,a,b,c,d,e,g,h,i,j) dmxLog(dmxDebug,f,a,b,c,d,e,g,h,i,j) -#else -#define DMXDBG0(f) -#define DMXDBG1(f,a) -#define DMXDBG2(f,a,b) -#define DMXDBG3(f,a,b,c) -#define DMXDBG4(f,a,b,c,d) -#define DMXDBG5(f,a,b,c,d,e) -#define DMXDBG6(f,a,b,c,d,e,g) -#define DMXDBG7(f,a,b,c,d,e,g,h) -#define DMXDBG8(f,a,b,c,d,e,g,h,i) -#define DMXDBG9(f,a,b,c,d,e,g,h,i,j) -#endif - -/** Create and return a private data structure. */ -pointer dmxBackendCreatePrivate(DeviceIntPtr pDevice) -{ - GETDMXLOCALFROMPDEVICE; - myPrivate *priv = calloc(1, sizeof(*priv)); - priv->dmxLocal = dmxLocal; - return priv; -} - -/** Destroy the private data structure. No checking is performed to - * verify that the structure was actually created by - * #dmxBackendCreatePrivate. */ -void dmxBackendDestroyPrivate(pointer private) -{ - if (private) free(private); -} - -static void *dmxBackendTestScreen(DMXScreenInfo *dmxScreen, void *closure) -{ - long target = (long)closure; - - if (dmxScreen->index == target) return dmxScreen; - return NULL; -} - -/* Return non-zero if screen and priv->myScreen are on the same physical - * backend display (1 if they are the same screen, 2 if they are - * different screens). Since this is a common operation, the results - * are cached. The cache is invalidated if \a priv is NULL (this should - * be done with each server generation and reconfiguration). */ -static int dmxBackendSameDisplay(myPrivate *priv, long screen) -{ - static myPrivate *oldpriv = NULL; - static int oldscreen = -1; - static int retcode = 0; - - if (priv == oldpriv && screen == oldscreen) return retcode; - if (!priv) { /* Invalidate cache */ - oldpriv = NULL; - oldscreen = -1; - retcode = 0; - return 0; - } - - if (screen == priv->myScreen) retcode = 1; - else if (screen < 0 || screen >= dmxNumScreens) retcode = 0; - else if (dmxPropertyIterate(priv->be, - dmxBackendTestScreen, - (void *)screen)) retcode = 2; - else retcode = 0; - - oldpriv = priv; - oldscreen = screen; - return retcode; -} - -static void *dmxBackendTestEvents(DMXScreenInfo *dmxScreen, void *closure) -{ - XEvent *X = (XEvent *)closure; - - if (XCheckNotMaskEvent(dmxScreen->beDisplay, ExposureMask, X)) - return dmxScreen; - return NULL; -} - -static void *dmxBackendTestMotionEvent(DMXScreenInfo *dmxScreen, void *closure) -{ - XEvent *X = (XEvent *)closure; - - if (XCheckTypedEvent(dmxScreen->beDisplay, MotionNotify, X)) - return dmxScreen; - return NULL; -} - -static DMXScreenInfo *dmxBackendGetEvent(myPrivate *priv, XEvent *X) -{ - DMXScreenInfo *dmxScreen; - - if ((dmxScreen = dmxPropertyIterate(priv->be, dmxBackendTestEvents, X))) - return dmxScreen; - return NULL; -} - -static DMXScreenInfo *dmxBackendPendingMotionEvent(myPrivate *priv, int save) -{ - DMXScreenInfo *dmxScreen; - XEvent N; - - if ((dmxScreen = dmxPropertyIterate(priv->be, - dmxBackendTestMotionEvent, &N))) { - if (save) XPutBackEvent(dmxScreen->beDisplay, &N); - return dmxScreen; - } - return NULL; -} - -static void *dmxBackendTestWindow(DMXScreenInfo *dmxScreen, void *closure) -{ - Window win = (Window)(long)closure; - if (dmxScreen->scrnWin == win) return dmxScreen; - return NULL; -} - -static DMXScreenInfo *dmxBackendFindWindow(myPrivate *priv, Window win) -{ - return dmxPropertyIterate(priv->be, dmxBackendTestWindow, - (void *)(long)win); -} - -/* If the cursor is over a set of overlapping screens and one of those - * screens takes backend input, then we want that particular screen to - * be current, not one of the other ones. */ -static int dmxBackendFindOverlapping(myPrivate *priv, int screen, int x, int y) -{ - DMXScreenInfo *start = &dmxScreens[screen]; - DMXScreenInfo *pt; - - if (!start->over) return screen; - - for (pt = start->over; /* condition at end of loop */; pt = pt->over) { - if (pt->index == priv->myScreen - && dmxOnScreen(x, y, &dmxScreens[pt->index])) return pt->index; - if (pt == start) break; - } - return screen; -} - -/* Return non-zero if \a x and \a y are off \a screen. */ -static int dmxBackendOffscreen(int screen, int x, int y) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[screen]; - - return (!dmxOnScreen(x, y, dmxScreen)); -} - -/** This routine is called from #dmxCoreMotion for each motion - * event. \a x and \a y are global coordinants. */ -void dmxBackendUpdatePosition(pointer private, int x, int y) -{ - GETPRIVFROMPRIVATE; - int screen = miPointerGetScreen(inputInfo.pointer)->myNum; - DMXScreenInfo *dmxScreen = &dmxScreens[priv->myScreen]; - int oldRelative = priv->relative; - int topscreen = dmxBackendFindOverlapping(priv, screen, x, y); - int same = dmxBackendSameDisplay(priv, topscreen); - int offscreen = dmxBackendOffscreen(priv->myScreen, x, y); - int offthis = dmxBackendOffscreen(screen, x, y); - - DMXDBG9("dmxBackendUpdatePosition(%d,%d) my=%d mi=%d rel=%d" - " topscreen=%d same=%d offscreen=%d offthis=%d\n", - x, y, priv->myScreen, screen, priv->relative, - topscreen, same, offscreen, offthis); - - if (offscreen) { - /* If the cursor is off the input screen, it should be moving - * relative unless it is visible on a screen of the same display - * (i.e., one that shares the mouse). */ - if (same == 2 && !offthis) { - if (priv->relative) { - DMXDBG0(" Off screen, but not absolute\n"); - priv->relative = 0; - } - } else { - if (!priv->relative) { - DMXDBG0(" Off screen, but not relative\n"); - priv->relative = 1; - } - } - } else { - if (topscreen != screen) { - DMXDBG2(" Using screen %d instead of %d (from mi)\n", - topscreen, screen); - } - if (same) { - if (priv->relative) { - DMXDBG0(" On screen, but not absolute\n"); - priv->relative = 0; - } - } else { - if (!priv->relative) { - DMXDBG0(" Not on screen, but not relative\n"); - priv->relative = 1; - } - } - } - - if (oldRelative != priv->relative) { - DMXDBG2(" Do switch, relative=%d same=%d\n", - priv->relative, same); - /* Discard all pre-switch events */ - dmxSync(dmxScreen, TRUE); - while (dmxBackendPendingMotionEvent(priv, FALSE)); - - if (dmxInput->console && offscreen) { - /* Our special case is a console window and a backend window - * share a display. In this case, the cursor is either on - * the backend window (taking absolute input), or not (in - * which case the cursor needs to be in the console - * window). */ - if (priv->grabbedScreen) { - DMXDBG2(" *** force ungrab on %s, display=%p\n", - priv->grabbedScreen->name, - priv->grabbedScreen->beDisplay); - XUngrabPointer(priv->grabbedScreen->beDisplay, CurrentTime); - dmxSync(priv->grabbedScreen, TRUE); - priv->grabbedScreen = NULL; - } - DMXDBG0(" Capturing console\n"); - dmxConsoleCapture(dmxInput); - } else { - priv->newscreen = 1; - if (priv->relative && !dmxInput->console) { - DMXDBG5(" Hide cursor; warp from %d,%d to %d,%d on %d\n", - priv->lastX, priv->lastY, priv->centerX, priv->centerY, - priv->myScreen); - dmxConsoleUncapture(dmxInput); - dmxHideCursor(dmxScreen); - priv->lastX = priv->centerX; - priv->lastY = priv->centerY; - XWarpPointer(priv->display, None, priv->window, - 0, 0, 0, 0, priv->lastX, priv->lastY); - dmxSync(dmxScreen, TRUE); - } else { - DMXDBG0(" Check cursor\n"); - dmxCheckCursor(); - } - } - } -} - -/** Get events from the X queue on the backend servers and put the - * events into the DMX event queue. */ -void dmxBackendCollectEvents(DevicePtr pDev, - dmxMotionProcPtr motion, - dmxEnqueueProcPtr enqueue, - dmxCheckSpecialProcPtr checkspecial, - DMXBlockType block) -{ - GETPRIVFROMPDEV; - GETDMXINPUTFROMPRIV; - XEvent X; - DMXScreenInfo *dmxScreen; - int left = 0; - int entered = priv->entered; - int ignoreLeave = 0; - int v[2]; - int retcode; - - while ((dmxScreen = dmxBackendGetEvent(priv, &X))) { - switch (X.type) { - case EnterNotify: - dmxCommonSaveState(priv); - if (entered++) - continue; - priv->entered = 1; - ignoreLeave = 1; - DMXDBG5("dmxBackendCollectEvents: Enter %lu %d,%d; GRAB %s %p\n", - X.xcrossing.root, X.xcrossing.x, X.xcrossing.y, - dmxScreen->name, dmxScreen->beDisplay); - XRaiseWindow(dmxScreen->beDisplay, dmxScreen->scrnWin); - priv->grabbedScreen = dmxScreen; - if ((retcode = XGrabPointer(dmxScreen->beDisplay, - dmxScreen->scrnWin, - True, 0, GrabModeAsync, - GrabModeAsync, None, None, - CurrentTime))) { - dmxLog(dmxError, - "XGrabPointer failed during backend enter (%d)\n", - retcode); - } - break; - case LeaveNotify: - if (ignoreLeave) { - ignoreLeave = 0; - continue; - } - dmxCommonRestoreState(priv); - if (left++) - continue; - DMXDBG7("dmxBackendCollectEvents: Leave %lu %d,%d %d %d %s %s\n", - X.xcrossing.root, X.xcrossing.x, X.xcrossing.y, - X.xcrossing.detail, X.xcrossing.focus, - priv->grabbedScreen ? "UNGRAB" : "", - dmxScreen->name); - if (priv->grabbedScreen) { - XUngrabPointer(priv->grabbedScreen->beDisplay, CurrentTime); - dmxSync(priv->grabbedScreen, TRUE); - priv->grabbedScreen = NULL; - } - break; - case MotionNotify: - DMXDBG9("dmxBackendCollectEvents: MotionNotify %d/%d (mi %d)" - " newscreen=%d: %d %d (e=%d; last=%d,%d)\n", - dmxScreen->index, priv->myScreen, - miPointerCurrentScreen()->myNum, - priv->newscreen, - X.xmotion.x, X.xmotion.y, - entered, priv->lastX, priv->lastY); - if (dmxBackendPendingMotionEvent(priv, TRUE)) - continue; - if (!(dmxScreen = dmxBackendFindWindow(priv, X.xmotion.window))) - dmxLog(dmxFatal, - " Event on non-existant window %lu\n", - X.xmotion.window); - if (!priv->relative || dmxInput->console) { - int newX = X.xmotion.x - dmxScreen->rootX; - int newY = X.xmotion.y - dmxScreen->rootY; - - if (!priv->newscreen) { - int width = dmxScreen->rootWidth; - int height = dmxScreen->rootHeight; - if (!newX) newX = -1; - if (newX == width - 1) newX = width; - if (!newY) newY = -1; - if (newY == height - 1) newY = height; - } - priv->newscreen = 0; - v[0] = dmxScreen->rootXOrigin + newX; - v[1] = dmxScreen->rootYOrigin + newY; - DMXDBG8(" Absolute move: %d,%d (r=%dx%d+%d+%d s=%dx%d)\n", - v[0], v[1], - priv->be->rootWidth, priv->be->rootHeight, - priv->be->rootX, priv->be->rootY, - priv->be->scrnWidth, priv->be->scrnHeight); - motion(priv->mou, v, 0, 2, DMX_ABSOLUTE, block); - priv->entered = 0; - } else { - int newX = priv->lastX - X.xmotion.x; - int newY = priv->lastY - X.xmotion.y; - priv->lastX = X.xmotion.x; - priv->lastY = X.xmotion.y; - v[0] = newX; - v[1] = newY; - DMXDBG2(" Relative move: %d, %d\n", v[0], v[1]); - motion(priv->mou, v, 0, 2, DMX_RELATIVE, block); - } - if (entered && priv->relative) { - DMXDBG4(" **** Relative %d %d instead of absolute %d %d\n", - v[0], v[1], - (dmxScreen->rootXOrigin + X.xmotion.x - - dmxScreen->rootX), - (dmxScreen->rootYOrigin + X.xmotion.y - - dmxScreen->rootY)); - } - break; - - case KeyPress: - case KeyRelease: - enqueue(priv->kbd, X.type, X.xkey.keycode, 0, NULL, block); - break; - case ButtonPress: - case ButtonRelease: - /* fall-through */ - default: - /* Pass the whole event here, because - * this may be an extension event. */ - enqueue(priv->mou, X.type, X.xbutton.button, 0, &X, block); - break; - } - } -} - -/** Called after input events are processed from the DMX queue. No - * event processing actually takes place here, but this is a convenient - * place to update the pointer. */ -void dmxBackendProcessInput(pointer private) -{ - GETPRIVFROMPRIVATE; - - DMXDBG6("dmxBackendProcessInput: myScreen=%d relative=%d" - " last=%d,%d center=%d,%d\n", - priv->myScreen, priv->relative, - priv->lastX, priv->lastY, - priv->centerX, priv->centerY); - - if (priv->relative - && !dmxInput->console - && (priv->lastX != priv->centerX || priv->lastY != priv->centerY)) { - DMXDBG4(" warping pointer from last=%d,%d to center=%d,%d\n", - priv->lastX, priv->lastY, priv->centerX, priv->centerY); - priv->lastX = priv->centerX; - priv->lastY = priv->centerY; - XWarpPointer(priv->display, None, priv->window, - 0, 0, 0, 0, priv->lastX, priv->lastY); - dmxSync(&dmxScreens[priv->myScreen], TRUE); - } -} - -static void dmxBackendComputeCenter(myPrivate *priv) -{ - int centerX; - int centerY; - - centerX = priv->be->rootWidth / 2 + priv->be->rootX; - centerY = priv->be->rootHeight / 2 + priv->be->rootY; - - if (centerX > priv->be->rootWidth) centerX = priv->be->rootWidth - 1; - if (centerY > priv->be->rootHeight) centerY = priv->be->rootHeight - 1; - if (centerX < 1) centerX = 1; - if (centerY < 1) centerY = 1; - - priv->centerX = centerX; - priv->centerY = centerY; -} - -static DMXScreenInfo *dmxBackendInitPrivate(DevicePtr pDev) -{ - GETPRIVFROMPDEV; - DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx]; - DMXScreenInfo *dmxScreen; - int i; - - /* Fill in myPrivate */ - for (i = 0,dmxScreen = &dmxScreens[0]; i<dmxNumScreens; i++,dmxScreen++) { - if (dmxPropertySameDisplay(dmxScreen, dmxInput->name)) { - priv->display = dmxScreen->beDisplay; - priv->window = dmxScreen->scrnWin; - priv->be = dmxScreen; - break; - } - } - - if (i >= dmxNumScreens) - dmxLog(dmxFatal, - "%s is not an existing backend display - cannot initialize\n", - dmxInput->name); - - return dmxScreen; -} - -/** Re-initialized the backend device described by \a pDev (after a - * reconfig). */ -void dmxBackendLateReInit(DevicePtr pDev) -{ - GETPRIVFROMPDEV; - int x, y; - - DMXDBG1("dmxBackendLateReInit miPointerCurrentScreen() = %p\n", - miPointerCurrentScreen()); - - dmxBackendSameDisplay(NULL, 0); /* Invalidate cache */ - dmxBackendInitPrivate(pDev); - dmxBackendComputeCenter(priv); - dmxGetGlobalPosition(&x, &y); - dmxInvalidateGlobalPosition(); /* To force event processing */ - dmxBackendUpdatePosition(priv, x, y); -} - -/** Initialized the backend device described by \a pDev. */ -void dmxBackendInit(DevicePtr pDev) -{ - GETPRIVFROMPDEV; - DMXScreenInfo *dmxScreen; - - dmxBackendSameDisplay(NULL, 0); /* Invalidate cache */ - - if (dmxLocal->type == DMX_LOCAL_MOUSE) priv->mou = pDev; - if (dmxLocal->type == DMX_LOCAL_KEYBOARD) priv->kbd = pDev; - if (priv->initialized++) return; /* Only do once for mouse/keyboard pair */ - - dmxScreen = dmxBackendInitPrivate(pDev); - - /* Finish initialization using computed values or constants. */ - dmxBackendComputeCenter(priv); - priv->eventMask = (EnterWindowMask|LeaveWindowMask); - priv->myScreen = dmxScreen->index; - priv->lastX = priv->centerX; - priv->lastY = priv->centerY; - priv->relative = 0; - priv->newscreen = 0; -} - -/** Get information about the backend pointer (for initialization). */ -void dmxBackendMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info) -{ - const DMXScreenInfo *dmxScreen = dmxBackendInitPrivate(pDev); - - info->buttonClass = 1; - dmxCommonMouGetMap(pDev, info->map, &info->numButtons); - info->valuatorClass = 1; - info->numRelAxes = 2; - info->minval[0] = 0; - info->minval[1] = 0; - info->maxval[0] = dmxScreen->beWidth; - info->maxval[1] = dmxScreen->beHeight; - info->res[0] = 1; - info->minres[0] = 0; - info->maxres[0] = 1; - info->ptrFeedbackClass = 1; -} - -/** Get information about the backend keyboard (for initialization). */ -void dmxBackendKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info) -{ - dmxCommonKbdGetInfo(pDev, info); - info->keyboard = 1; - info->keyClass = 1; - dmxCommonKbdGetMap(pDev, &info->keySyms, info->modMap); - info->freemap = 1; - info->focusClass = 1; - info->kbdFeedbackClass = 1; -} - -/** Process #DMXFunctionType functions. The only function handled here - * is to acknowledge a pending server shutdown. */ -int dmxBackendFunctions(pointer private, DMXFunctionType function) -{ - switch (function) { - case DMX_FUNCTION_TERMINATE: - return 1; - default: - return 0; - } -} +/*
+ * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * David H. Dawes <dawes@xfree86.org>
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ */
+
+/** \file
+ * These routines support taking input from devices on the backend
+ * (output) displays. \see dmxcommon.c. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_BACKEND_DEBUG 0
+
+#include "dmxinputinit.h"
+#include "dmxbackend.h"
+#include "dmxcommon.h"
+#include "dmxconsole.h"
+#include "dmxcursor.h"
+#include "dmxprop.h"
+#include "dmxsync.h"
+#include "dmxcb.h" /* For dmxGlobalWidth and dmxGlobalHeight */
+#include "dmxevents.h" /* For dmxGetGlobalPosition */
+#include "ChkNotMaskEv.h"
+
+#include "inputstr.h"
+#include "input.h"
+#include <X11/keysym.h>
+#include "mipointer.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+/* Private area for backend devices. */
+typedef struct _myPrivate {
+ DMX_COMMON_PRIVATE;
+ int myScreen;
+ DMXScreenInfo *grabbedScreen;
+
+ int lastX, lastY;
+ int centerX, centerY;
+ int relative;
+ int newscreen;
+ int initialized;
+ DevicePtr mou, kbd;
+ int entered;
+ int offX, offY;
+} myPrivate;
+
+#if DMX_BACKEND_DEBUG
+#define DMXDBG0(f) dmxLog(dmxDebug,f)
+#define DMXDBG1(f,a) dmxLog(dmxDebug,f,a)
+#define DMXDBG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define DMXDBG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define DMXDBG4(f,a,b,c,d) dmxLog(dmxDebug,f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e) dmxLog(dmxDebug,f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g) dmxLog(dmxDebug,f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h) dmxLog(dmxDebug,f,a,b,c,d,e,g,h)
+#define DMXDBG8(f,a,b,c,d,e,g,h,i) dmxLog(dmxDebug,f,a,b,c,d,e,g,h,i)
+#define DMXDBG9(f,a,b,c,d,e,g,h,i,j) dmxLog(dmxDebug,f,a,b,c,d,e,g,h,i,j)
+#else
+#define DMXDBG0(f)
+#define DMXDBG1(f,a)
+#define DMXDBG2(f,a,b)
+#define DMXDBG3(f,a,b,c)
+#define DMXDBG4(f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h)
+#define DMXDBG8(f,a,b,c,d,e,g,h,i)
+#define DMXDBG9(f,a,b,c,d,e,g,h,i,j)
+#endif
+
+/** Create and return a private data structure. */
+pointer dmxBackendCreatePrivate(DeviceIntPtr pDevice)
+{
+ GETDMXLOCALFROMPDEVICE;
+ myPrivate *priv = calloc(1, sizeof(*priv));
+ priv->dmxLocal = dmxLocal;
+ return priv;
+}
+
+/** Destroy the private data structure. No checking is performed to
+ * verify that the structure was actually created by
+ * #dmxBackendCreatePrivate. */
+void dmxBackendDestroyPrivate(pointer private)
+{
+ free(private);
+}
+
+static void *dmxBackendTestScreen(DMXScreenInfo *dmxScreen, void *closure)
+{
+ long target = (long)closure;
+
+ if (dmxScreen->index == target) return dmxScreen;
+ return NULL;
+}
+
+/* Return non-zero if screen and priv->myScreen are on the same physical
+ * backend display (1 if they are the same screen, 2 if they are
+ * different screens). Since this is a common operation, the results
+ * are cached. The cache is invalidated if \a priv is NULL (this should
+ * be done with each server generation and reconfiguration). */
+static int dmxBackendSameDisplay(myPrivate *priv, long screen)
+{
+ static myPrivate *oldpriv = NULL;
+ static int oldscreen = -1;
+ static int retcode = 0;
+
+ if (priv == oldpriv && screen == oldscreen) return retcode;
+ if (!priv) { /* Invalidate cache */
+ oldpriv = NULL;
+ oldscreen = -1;
+ retcode = 0;
+ return 0;
+ }
+
+ if (screen == priv->myScreen) retcode = 1;
+ else if (screen < 0 || screen >= dmxNumScreens) retcode = 0;
+ else if (dmxPropertyIterate(priv->be,
+ dmxBackendTestScreen,
+ (void *)screen)) retcode = 2;
+ else retcode = 0;
+
+ oldpriv = priv;
+ oldscreen = screen;
+ return retcode;
+}
+
+static void *dmxBackendTestEvents(DMXScreenInfo *dmxScreen, void *closure)
+{
+ XEvent *X = (XEvent *)closure;
+
+ if (XCheckNotMaskEvent(dmxScreen->beDisplay, ExposureMask, X))
+ return dmxScreen;
+ return NULL;
+}
+
+static void *dmxBackendTestMotionEvent(DMXScreenInfo *dmxScreen, void *closure)
+{
+ XEvent *X = (XEvent *)closure;
+
+ if (XCheckTypedEvent(dmxScreen->beDisplay, MotionNotify, X))
+ return dmxScreen;
+ return NULL;
+}
+
+static DMXScreenInfo *dmxBackendGetEvent(myPrivate *priv, XEvent *X)
+{
+ DMXScreenInfo *dmxScreen;
+
+ if ((dmxScreen = dmxPropertyIterate(priv->be, dmxBackendTestEvents, X)))
+ return dmxScreen;
+ return NULL;
+}
+
+static DMXScreenInfo *dmxBackendPendingMotionEvent(myPrivate *priv, int save)
+{
+ DMXScreenInfo *dmxScreen;
+ XEvent N;
+
+ if ((dmxScreen = dmxPropertyIterate(priv->be,
+ dmxBackendTestMotionEvent, &N))) {
+ if (save) XPutBackEvent(dmxScreen->beDisplay, &N);
+ return dmxScreen;
+ }
+ return NULL;
+}
+
+static void *dmxBackendTestWindow(DMXScreenInfo *dmxScreen, void *closure)
+{
+ Window win = (Window)(long)closure;
+ if (dmxScreen->scrnWin == win) return dmxScreen;
+ return NULL;
+}
+
+static DMXScreenInfo *dmxBackendFindWindow(myPrivate *priv, Window win)
+{
+ return dmxPropertyIterate(priv->be, dmxBackendTestWindow,
+ (void *)(long)win);
+}
+
+/* If the cursor is over a set of overlapping screens and one of those
+ * screens takes backend input, then we want that particular screen to
+ * be current, not one of the other ones. */
+static int dmxBackendFindOverlapping(myPrivate *priv, int screen, int x, int y)
+{
+ DMXScreenInfo *start = &dmxScreens[screen];
+ DMXScreenInfo *pt;
+
+ if (!start->over) return screen;
+
+ for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
+ if (pt->index == priv->myScreen
+ && dmxOnScreen(x, y, &dmxScreens[pt->index])) return pt->index;
+ if (pt == start) break;
+ }
+ return screen;
+}
+
+/* Return non-zero if \a x and \a y are off \a screen. */
+static int dmxBackendOffscreen(int screen, int x, int y)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[screen];
+
+ return (!dmxOnScreen(x, y, dmxScreen));
+}
+
+/** This routine is called from #dmxCoreMotion for each motion
+ * event. \a x and \a y are global coordinants. */
+void dmxBackendUpdatePosition(pointer private, int x, int y)
+{
+ GETPRIVFROMPRIVATE;
+ int screen = miPointerGetScreen(inputInfo.pointer)->myNum;
+ DMXScreenInfo *dmxScreen = &dmxScreens[priv->myScreen];
+ int oldRelative = priv->relative;
+ int topscreen = dmxBackendFindOverlapping(priv, screen, x, y);
+ int same = dmxBackendSameDisplay(priv, topscreen);
+ int offscreen = dmxBackendOffscreen(priv->myScreen, x, y);
+ int offthis = dmxBackendOffscreen(screen, x, y);
+
+ DMXDBG9("dmxBackendUpdatePosition(%d,%d) my=%d mi=%d rel=%d"
+ " topscreen=%d same=%d offscreen=%d offthis=%d\n",
+ x, y, priv->myScreen, screen, priv->relative,
+ topscreen, same, offscreen, offthis);
+
+ if (offscreen) {
+ /* If the cursor is off the input screen, it should be moving
+ * relative unless it is visible on a screen of the same display
+ * (i.e., one that shares the mouse). */
+ if (same == 2 && !offthis) {
+ if (priv->relative) {
+ DMXDBG0(" Off screen, but not absolute\n");
+ priv->relative = 0;
+ }
+ } else {
+ if (!priv->relative) {
+ DMXDBG0(" Off screen, but not relative\n");
+ priv->relative = 1;
+ }
+ }
+ } else {
+ if (topscreen != screen) {
+ DMXDBG2(" Using screen %d instead of %d (from mi)\n",
+ topscreen, screen);
+ }
+ if (same) {
+ if (priv->relative) {
+ DMXDBG0(" On screen, but not absolute\n");
+ priv->relative = 0;
+ }
+ } else {
+ if (!priv->relative) {
+ DMXDBG0(" Not on screen, but not relative\n");
+ priv->relative = 1;
+ }
+ }
+ }
+
+ if (oldRelative != priv->relative) {
+ DMXDBG2(" Do switch, relative=%d same=%d\n",
+ priv->relative, same);
+ /* Discard all pre-switch events */
+ dmxSync(dmxScreen, TRUE);
+ while (dmxBackendPendingMotionEvent(priv, FALSE));
+
+ if (dmxInput->console && offscreen) {
+ /* Our special case is a console window and a backend window
+ * share a display. In this case, the cursor is either on
+ * the backend window (taking absolute input), or not (in
+ * which case the cursor needs to be in the console
+ * window). */
+ if (priv->grabbedScreen) {
+ DMXDBG2(" *** force ungrab on %s, display=%p\n",
+ priv->grabbedScreen->name,
+ priv->grabbedScreen->beDisplay);
+ XUngrabPointer(priv->grabbedScreen->beDisplay, CurrentTime);
+ dmxSync(priv->grabbedScreen, TRUE);
+ priv->grabbedScreen = NULL;
+ }
+ DMXDBG0(" Capturing console\n");
+ dmxConsoleCapture(dmxInput);
+ } else {
+ priv->newscreen = 1;
+ if (priv->relative && !dmxInput->console) {
+ DMXDBG5(" Hide cursor; warp from %d,%d to %d,%d on %d\n",
+ priv->lastX, priv->lastY, priv->centerX, priv->centerY,
+ priv->myScreen);
+ dmxConsoleUncapture(dmxInput);
+ dmxHideCursor(dmxScreen);
+ priv->lastX = priv->centerX;
+ priv->lastY = priv->centerY;
+ XWarpPointer(priv->display, None, priv->window,
+ 0, 0, 0, 0, priv->lastX, priv->lastY);
+ dmxSync(dmxScreen, TRUE);
+ } else {
+ DMXDBG0(" Check cursor\n");
+ dmxCheckCursor();
+ }
+ }
+ }
+}
+
+/** Get events from the X queue on the backend servers and put the
+ * events into the DMX event queue. */
+void dmxBackendCollectEvents(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+ XEvent X;
+ DMXScreenInfo *dmxScreen;
+ int left = 0;
+ int entered = priv->entered;
+ int ignoreLeave = 0;
+ int v[2];
+ int retcode;
+
+ while ((dmxScreen = dmxBackendGetEvent(priv, &X))) {
+ switch (X.type) {
+ case EnterNotify:
+ dmxCommonSaveState(priv);
+ if (entered++)
+ continue;
+ priv->entered = 1;
+ ignoreLeave = 1;
+ DMXDBG5("dmxBackendCollectEvents: Enter %lu %d,%d; GRAB %s %p\n",
+ X.xcrossing.root, X.xcrossing.x, X.xcrossing.y,
+ dmxScreen->name, dmxScreen->beDisplay);
+ XRaiseWindow(dmxScreen->beDisplay, dmxScreen->scrnWin);
+ priv->grabbedScreen = dmxScreen;
+ if ((retcode = XGrabPointer(dmxScreen->beDisplay,
+ dmxScreen->scrnWin,
+ True, 0, GrabModeAsync,
+ GrabModeAsync, None, None,
+ CurrentTime))) {
+ dmxLog(dmxError,
+ "XGrabPointer failed during backend enter (%d)\n",
+ retcode);
+ }
+ break;
+ case LeaveNotify:
+ if (ignoreLeave) {
+ ignoreLeave = 0;
+ continue;
+ }
+ dmxCommonRestoreState(priv);
+ if (left++)
+ continue;
+ DMXDBG7("dmxBackendCollectEvents: Leave %lu %d,%d %d %d %s %s\n",
+ X.xcrossing.root, X.xcrossing.x, X.xcrossing.y,
+ X.xcrossing.detail, X.xcrossing.focus,
+ priv->grabbedScreen ? "UNGRAB" : "",
+ dmxScreen->name);
+ if (priv->grabbedScreen) {
+ XUngrabPointer(priv->grabbedScreen->beDisplay, CurrentTime);
+ dmxSync(priv->grabbedScreen, TRUE);
+ priv->grabbedScreen = NULL;
+ }
+ break;
+ case MotionNotify:
+ DMXDBG9("dmxBackendCollectEvents: MotionNotify %d/%d (mi %d)"
+ " newscreen=%d: %d %d (e=%d; last=%d,%d)\n",
+ dmxScreen->index, priv->myScreen,
+ miPointerCurrentScreen()->myNum,
+ priv->newscreen,
+ X.xmotion.x, X.xmotion.y,
+ entered, priv->lastX, priv->lastY);
+ if (dmxBackendPendingMotionEvent(priv, TRUE))
+ continue;
+ if (!(dmxScreen = dmxBackendFindWindow(priv, X.xmotion.window)))
+ dmxLog(dmxFatal,
+ " Event on non-existant window %lu\n",
+ X.xmotion.window);
+ if (!priv->relative || dmxInput->console) {
+ int newX = X.xmotion.x - dmxScreen->rootX;
+ int newY = X.xmotion.y - dmxScreen->rootY;
+
+ if (!priv->newscreen) {
+ int width = dmxScreen->rootWidth;
+ int height = dmxScreen->rootHeight;
+ if (!newX) newX = -1;
+ if (newX == width - 1) newX = width;
+ if (!newY) newY = -1;
+ if (newY == height - 1) newY = height;
+ }
+ priv->newscreen = 0;
+ v[0] = dmxScreen->rootXOrigin + newX;
+ v[1] = dmxScreen->rootYOrigin + newY;
+ DMXDBG8(" Absolute move: %d,%d (r=%dx%d+%d+%d s=%dx%d)\n",
+ v[0], v[1],
+ priv->be->rootWidth, priv->be->rootHeight,
+ priv->be->rootX, priv->be->rootY,
+ priv->be->scrnWidth, priv->be->scrnHeight);
+ motion(priv->mou, v, 0, 2, DMX_ABSOLUTE, block);
+ priv->entered = 0;
+ } else {
+ int newX = priv->lastX - X.xmotion.x;
+ int newY = priv->lastY - X.xmotion.y;
+ priv->lastX = X.xmotion.x;
+ priv->lastY = X.xmotion.y;
+ v[0] = newX;
+ v[1] = newY;
+ DMXDBG2(" Relative move: %d, %d\n", v[0], v[1]);
+ motion(priv->mou, v, 0, 2, DMX_RELATIVE, block);
+ }
+ if (entered && priv->relative) {
+ DMXDBG4(" **** Relative %d %d instead of absolute %d %d\n",
+ v[0], v[1],
+ (dmxScreen->rootXOrigin + X.xmotion.x
+ - dmxScreen->rootX),
+ (dmxScreen->rootYOrigin + X.xmotion.y
+ - dmxScreen->rootY));
+ }
+ break;
+
+ case KeyPress:
+ case KeyRelease:
+ enqueue(priv->kbd, X.type, X.xkey.keycode, 0, NULL, block);
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ /* fall-through */
+ default:
+ /* Pass the whole event here, because
+ * this may be an extension event. */
+ enqueue(priv->mou, X.type, X.xbutton.button, 0, &X, block);
+ break;
+ }
+ }
+}
+
+/** Called after input events are processed from the DMX queue. No
+ * event processing actually takes place here, but this is a convenient
+ * place to update the pointer. */
+void dmxBackendProcessInput(pointer private)
+{
+ GETPRIVFROMPRIVATE;
+
+ DMXDBG6("dmxBackendProcessInput: myScreen=%d relative=%d"
+ " last=%d,%d center=%d,%d\n",
+ priv->myScreen, priv->relative,
+ priv->lastX, priv->lastY,
+ priv->centerX, priv->centerY);
+
+ if (priv->relative
+ && !dmxInput->console
+ && (priv->lastX != priv->centerX || priv->lastY != priv->centerY)) {
+ DMXDBG4(" warping pointer from last=%d,%d to center=%d,%d\n",
+ priv->lastX, priv->lastY, priv->centerX, priv->centerY);
+ priv->lastX = priv->centerX;
+ priv->lastY = priv->centerY;
+ XWarpPointer(priv->display, None, priv->window,
+ 0, 0, 0, 0, priv->lastX, priv->lastY);
+ dmxSync(&dmxScreens[priv->myScreen], TRUE);
+ }
+}
+
+static void dmxBackendComputeCenter(myPrivate *priv)
+{
+ int centerX;
+ int centerY;
+
+ centerX = priv->be->rootWidth / 2 + priv->be->rootX;
+ centerY = priv->be->rootHeight / 2 + priv->be->rootY;
+
+ if (centerX > priv->be->rootWidth) centerX = priv->be->rootWidth - 1;
+ if (centerY > priv->be->rootHeight) centerY = priv->be->rootHeight - 1;
+ if (centerX < 1) centerX = 1;
+ if (centerY < 1) centerY = 1;
+
+ priv->centerX = centerX;
+ priv->centerY = centerY;
+}
+
+static DMXScreenInfo *dmxBackendInitPrivate(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
+ DMXScreenInfo *dmxScreen;
+ int i;
+
+ /* Fill in myPrivate */
+ for (i = 0,dmxScreen = &dmxScreens[0]; i<dmxNumScreens; i++,dmxScreen++) {
+ if (dmxPropertySameDisplay(dmxScreen, dmxInput->name)) {
+ priv->display = dmxScreen->beDisplay;
+ priv->window = dmxScreen->scrnWin;
+ priv->be = dmxScreen;
+ break;
+ }
+ }
+
+ if (i >= dmxNumScreens)
+ dmxLog(dmxFatal,
+ "%s is not an existing backend display - cannot initialize\n",
+ dmxInput->name);
+
+ return dmxScreen;
+}
+
+/** Re-initialized the backend device described by \a pDev (after a
+ * reconfig). */
+void dmxBackendLateReInit(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ int x, y;
+
+ DMXDBG1("dmxBackendLateReInit miPointerCurrentScreen() = %p\n",
+ miPointerCurrentScreen());
+
+ dmxBackendSameDisplay(NULL, 0); /* Invalidate cache */
+ dmxBackendInitPrivate(pDev);
+ dmxBackendComputeCenter(priv);
+ dmxGetGlobalPosition(&x, &y);
+ dmxInvalidateGlobalPosition(); /* To force event processing */
+ dmxBackendUpdatePosition(priv, x, y);
+}
+
+/** Initialized the backend device described by \a pDev. */
+void dmxBackendInit(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ DMXScreenInfo *dmxScreen;
+
+ dmxBackendSameDisplay(NULL, 0); /* Invalidate cache */
+
+ if (dmxLocal->type == DMX_LOCAL_MOUSE) priv->mou = pDev;
+ if (dmxLocal->type == DMX_LOCAL_KEYBOARD) priv->kbd = pDev;
+ if (priv->initialized++) return; /* Only do once for mouse/keyboard pair */
+
+ dmxScreen = dmxBackendInitPrivate(pDev);
+
+ /* Finish initialization using computed values or constants. */
+ dmxBackendComputeCenter(priv);
+ priv->eventMask = (EnterWindowMask|LeaveWindowMask);
+ priv->myScreen = dmxScreen->index;
+ priv->lastX = priv->centerX;
+ priv->lastY = priv->centerY;
+ priv->relative = 0;
+ priv->newscreen = 0;
+}
+
+/** Get information about the backend pointer (for initialization). */
+void dmxBackendMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ const DMXScreenInfo *dmxScreen = dmxBackendInitPrivate(pDev);
+
+ info->buttonClass = 1;
+ dmxCommonMouGetMap(pDev, info->map, &info->numButtons);
+ info->valuatorClass = 1;
+ info->numRelAxes = 2;
+ info->minval[0] = 0;
+ info->minval[1] = 0;
+ info->maxval[0] = dmxScreen->beWidth;
+ info->maxval[1] = dmxScreen->beHeight;
+ info->res[0] = 1;
+ info->minres[0] = 0;
+ info->maxres[0] = 1;
+ info->ptrFeedbackClass = 1;
+}
+
+/** Get information about the backend keyboard (for initialization). */
+void dmxBackendKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ dmxCommonKbdGetInfo(pDev, info);
+ info->keyboard = 1;
+ info->keyClass = 1;
+ dmxCommonKbdGetMap(pDev, &info->keySyms, info->modMap);
+ info->freemap = 1;
+ info->focusClass = 1;
+ info->kbdFeedbackClass = 1;
+}
+
+/** Process #DMXFunctionType functions. The only function handled here
+ * is to acknowledge a pending server shutdown. */
+int dmxBackendFunctions(pointer private, DMXFunctionType function)
+{
+ switch (function) {
+ case DMX_FUNCTION_TERMINATE:
+ return 1;
+ default:
+ return 0;
+ }
+}
diff --git a/xorg-server/hw/dmx/input/dmxcommon.c b/xorg-server/hw/dmx/input/dmxcommon.c index da5b77893..29c1958ad 100644 --- a/xorg-server/hw/dmx/input/dmxcommon.c +++ b/xorg-server/hw/dmx/input/dmxcommon.c @@ -1,670 +1,669 @@ -/* - * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * David H. Dawes <dawes@xfree86.org> - * Kevin E. Martin <kem@redhat.com> - * Rickard E. (Rik) Faith <faith@redhat.com> - */ - -/** \file - * - * This file implements common routines used by the backend and console - * input devices. - */ - -#ifdef HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#define DMX_STATE_DEBUG 0 - -#include "dmxinputinit.h" -#include "dmxcommon.h" -#include "dmxconsole.h" -#include "dmxprop.h" -#include "dmxsync.h" -#include "dmxmap.h" - -#include "inputstr.h" -#include "input.h" -#include <X11/keysym.h> -#include "mipointer.h" -#include "scrnintstr.h" - -#include <unistd.h> /* For usleep() */ - -#if DMX_STATE_DEBUG -#define DMXDBG0(f) dmxLog(dmxDebug,f) -#else -#define DMXDBG0(f) -#endif - -/** Each device has a private area that is visible only from inside the - * driver code. */ -typedef struct _myPrivate { - DMX_COMMON_PRIVATE; -} myPrivate; - -static void dmxCommonKbdSetAR(Display *display, - unsigned char *old, unsigned char *new) -{ - XKeyboardControl kc; - XKeyboardState ks; - unsigned long mask = KBKey | KBAutoRepeatMode; - int i, j; - int minKeycode, maxKeycode; - - if (!old) { - XGetKeyboardControl(display, &ks); - old = (unsigned char *)ks.auto_repeats; - } - - XDisplayKeycodes(display, &minKeycode, &maxKeycode); - for (i = 1; i < 32; i++) { - if (!old || old[i] != new[i]) { - for (j = 0; j < 8; j++) { - if ((new[i] & (1 << j)) != (old[i] & (1 << j))) { - kc.key = i * 8 + j; - kc.auto_repeat_mode = ((new[i] & (1 << j)) - ? AutoRepeatModeOn - : AutoRepeatModeOff); - if (kc.key >= minKeycode && kc.key <= maxKeycode) - XChangeKeyboardControl(display, mask, &kc); - } - } - } - } -} - -static void dmxCommonKbdSetLeds(Display *display, unsigned long new) -{ - int i; - XKeyboardControl kc; - - for (i = 0; i < 32; i++) { - kc.led = i + 1; - kc.led_mode = (new & (1 << i)) ? LedModeOn : LedModeOff; - XChangeKeyboardControl(display, KBLed | KBLedMode, &kc); - } -} - -static void dmxCommonKbdSetCtrl(Display *display, - KeybdCtrl *old, KeybdCtrl *new) -{ - XKeyboardControl kc; - unsigned long mask = KBKeyClickPercent | KBAutoRepeatMode; - - if (!old - || old->click != new->click - || old->autoRepeat != new->autoRepeat) { - - kc.key_click_percent = new->click; - kc.auto_repeat_mode = new->autoRepeat; - - XChangeKeyboardControl(display, mask, &kc); - } - - dmxCommonKbdSetLeds(display, new->leds); - dmxCommonKbdSetAR(display, old ? old->autoRepeats : NULL, - new->autoRepeats); -} - -static void dmxCommonMouSetCtrl(Display *display, PtrCtrl *old, PtrCtrl *new) -{ - Bool do_accel, do_threshold; - - if (!old - || old->num != new->num - || old->den != new->den - || old->threshold != new->threshold) { - do_accel = (new->num > 0 && new->den > 0); - do_threshold = (new->threshold > 0); - if (do_accel || do_threshold) { - XChangePointerControl(display, do_accel, do_threshold, - new->num, new->den, new->threshold); - } - } -} - -/** Update the keyboard control. */ -void dmxCommonKbdCtrl(DevicePtr pDev, KeybdCtrl *ctrl) -{ - GETPRIVFROMPDEV; - - if (!priv->stateSaved && priv->be) dmxCommonSaveState(priv); - if (!priv->display || !priv->stateSaved) return; - dmxCommonKbdSetCtrl(priv->display, - priv->kctrlset ? &priv->kctrl : NULL, - ctrl); - priv->kctrl = *ctrl; - priv->kctrlset = 1; -} - -/** Update the mouse control. */ -void dmxCommonMouCtrl(DevicePtr pDev, PtrCtrl *ctrl) -{ - GETPRIVFROMPDEV; - - /* Don't set the acceleration for the - * console, because that should be - * controlled by the X server that the - * console is running on. Otherwise, - * the acceleration for the console - * window would be unexpected for the - * scale of the window. */ - if (priv->be) { - dmxCommonMouSetCtrl(priv->display, - priv->mctrlset ? &priv->mctrl : NULL, - ctrl); - priv->mctrl = *ctrl; - priv->mctrlset = 1; - } -} - -/** Sound they keyboard bell. */ -void dmxCommonKbdBell(DevicePtr pDev, int percent, - int volume, int pitch, int duration) -{ - GETPRIVFROMPDEV; - XKeyboardControl kc; - XKeyboardState ks; - unsigned long mask = KBBellPercent | KBBellPitch | KBBellDuration; - - if (!priv->be) XGetKeyboardControl(priv->display, &ks); - kc.bell_percent = volume; - kc.bell_pitch = pitch; - kc.bell_duration = duration; - XChangeKeyboardControl(priv->display, mask, &kc); - XBell(priv->display, percent); - if (!priv->be) { - kc.bell_percent = ks.bell_percent; - kc.bell_pitch = ks.bell_pitch; - kc.bell_duration = ks.bell_duration; - XChangeKeyboardControl(priv->display, mask, &kc); - } -} - -/** Get the keyboard mapping. */ -void dmxCommonKbdGetMap(DevicePtr pDev, KeySymsPtr pKeySyms, CARD8 *pModMap) -{ - GETPRIVFROMPDEV; - int min_keycode; - int max_keycode; - int map_width; - KeySym *keyboard_mapping; - XModifierKeymap *modifier_mapping; - int i, j; - - /* Compute pKeySyms. Cast - * XGetKeyboardMapping because of - * compiler warning on 64-bit machines. - * We assume pointers to 32-bit and - * 64-bit ints are the same. */ - XDisplayKeycodes(priv->display, &min_keycode, &max_keycode); - keyboard_mapping = (KeySym *)XGetKeyboardMapping(priv->display, - min_keycode, - max_keycode - - min_keycode + 1, - &map_width); - pKeySyms->minKeyCode = min_keycode; - pKeySyms->maxKeyCode = max_keycode; - pKeySyms->mapWidth = map_width; - pKeySyms->map = keyboard_mapping; - - - /* Compute pModMap */ - modifier_mapping = XGetModifierMapping(priv->display); - for (i = 0; i < MAP_LENGTH; i++) - pModMap[i] = 0; - for (j = 0; j < 8; j++) { - int max_keypermod = modifier_mapping->max_keypermod; - - for (i = 0; i < max_keypermod; i++) { - CARD8 keycode = modifier_mapping->modifiermap[j*max_keypermod + i]; - if (keycode) - pModMap[keycode] |= 1 << j; - } - } - XFreeModifiermap(modifier_mapping); -} - -/** Fill in the XKEYBOARD parts of the \a info structure for the - * specified \a pDev. */ -void dmxCommonKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info) -{ - GETPRIVFROMPDEV; - GETDMXINPUTFROMPRIV; - char *pt; - - dmxCommonSaveState(priv); - if (priv->xkb) { -#define NAME(x) \ - priv->xkb->names->x ? XGetAtomName(priv->display,priv->xkb->names->x) : NULL - info->names.keycodes = NAME(keycodes); - info->names.types = NAME(types); - info->names.compat = NAME(compat); - info->names.symbols = NAME(symbols); - info->names.geometry = NAME(geometry); - info->freenames = 1; -#undef NAME - dmxLogInput(dmxInput, - "XKEYBOARD: keycodes = %s\n", info->names.keycodes); - dmxLogInput(dmxInput, - "XKEYBOARD: symbols = %s\n", info->names.symbols); - dmxLogInput(dmxInput, - "XKEYBOARD: geometry = %s\n", info->names.geometry); - if ((pt = strchr(info->names.keycodes, '+'))) *pt = '\0'; - } - dmxCommonRestoreState(priv); -} - -/** Turn \a pDev on (i.e., take input from \a pDev). */ -int dmxCommonKbdOn(DevicePtr pDev) -{ - GETPRIVFROMPDEV; - if (priv->be) dmxCommonSaveState(priv); - priv->eventMask |= DMX_KEYBOARD_EVENT_MASK; - XSelectInput(priv->display, priv->window, priv->eventMask); - if (priv->be) - XSetInputFocus(priv->display, priv->window, RevertToPointerRoot, - CurrentTime); - return -1; -} - -/** Turn \a pDev off. */ -void dmxCommonKbdOff(DevicePtr pDev) -{ - GETPRIVFROMPDEV; - priv->eventMask &= ~DMX_KEYBOARD_EVENT_MASK; - XSelectInput(priv->display, priv->window, priv->eventMask); - dmxCommonRestoreState(priv); -} - -/** Turn \a pDev on (i.e., take input from \a pDev). */ -int dmxCommonOthOn(DevicePtr pDev) -{ - GETPRIVFROMPDEV; - GETDMXINPUTFROMPRIV; - XEventClass event_list[DMX_MAX_XINPUT_EVENT_TYPES]; - int event_type[DMX_MAX_XINPUT_EVENT_TYPES]; - int count = 0; - -#define ADD(type) \ - if (count < DMX_MAX_XINPUT_EVENT_TYPES) { \ - type(priv->xi, event_type[count], event_list[count]); \ - if (event_type[count]) { \ - dmxMapInsert(dmxLocal, event_type[count], XI_##type); \ - ++count; \ - } \ - } else { \ - dmxLog(dmxWarning, "More than %d event types for %s\n", \ - DMX_MAX_XINPUT_EVENT_TYPES, dmxInput->name); \ - } - - if (!(priv->xi = XOpenDevice(priv->display, dmxLocal->deviceId))) { - dmxLog(dmxWarning, "Cannot open %s device (id=%d) on %s\n", - dmxLocal->deviceName ? dmxLocal->deviceName : "(unknown)", - dmxLocal->deviceId, dmxInput->name); - return -1; - } - ADD(DeviceKeyPress); - ADD(DeviceKeyRelease); - ADD(DeviceButtonPress); - ADD(DeviceButtonRelease); - ADD(DeviceMotionNotify); - ADD(DeviceFocusIn); - ADD(DeviceFocusOut); - ADD(ProximityIn); - ADD(ProximityOut); - ADD(DeviceStateNotify); - ADD(DeviceMappingNotify); - ADD(ChangeDeviceNotify); - XSelectExtensionEvent(priv->display, priv->window, event_list, count); - - return -1; -} - -/** Turn \a pDev off. */ -void dmxCommonOthOff(DevicePtr pDev) -{ - GETPRIVFROMPDEV; - - if (priv->xi) XCloseDevice(priv->display, priv->xi); - priv->xi = NULL; -} - -/** Fill the \a info structure with information needed to initialize \a - * pDev. */ -void dmxCommonOthGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info) -{ - GETPRIVFROMPDEV; - GETDMXINPUTFROMPRIV; - XExtensionVersion *ext; - XDeviceInfo *devices; - Display *display = priv->display; - int num; - int i, j, k; - int (*handler)(Display *, char *, char *); - - if (!display && !(display = XOpenDisplay(dmxInput->name))) - return; - - /* Print out information about the XInput Extension. */ - handler = XSetExtensionErrorHandler(dmxInputExtensionErrorHandler); - ext = XGetExtensionVersion(display, INAME); - XSetExtensionErrorHandler(handler); - - if (ext && ext != (XExtensionVersion *)NoSuchExtension) { - XFree(ext); - devices = XListInputDevices(display, &num); - for (i = 0; i < num; i++) { - if (devices[i].id == (XID)dmxLocal->deviceId) { - XAnyClassPtr any; - XKeyInfoPtr ki; - XButtonInfoPtr bi; - XValuatorInfoPtr vi; - for (j = 0, any = devices[i].inputclassinfo; - j < devices[i].num_classes; - any = (XAnyClassPtr)((char *)any + any->length), j++) { - switch (any->class) { - case KeyClass: - ki = (XKeyInfoPtr)any; - info->keyboard = 1; - info->keyClass = 1; - info->keySyms.minKeyCode = ki->min_keycode; - info->keySyms.maxKeyCode = ki->max_keycode; - info->kbdFeedbackClass = 1; - break; - case ButtonClass: - bi = (XButtonInfoPtr)any; - info->buttonClass = 1; - info->numButtons = bi->num_buttons; - info->ptrFeedbackClass = 1; - break; - case ValuatorClass: - /* This assume all axes are either - * Absolute or Relative. */ - vi = (XValuatorInfoPtr)any; - info->valuatorClass = 1; - if (vi->mode == Absolute) - info->numAbsAxes = vi->num_axes; - else - info->numRelAxes = vi->num_axes; - for (k = 0; k < vi->num_axes; k++) { - info->res[k] = vi->axes[k].resolution; - info->minres[k] = vi->axes[k].resolution; - info->maxres[k] = vi->axes[k].resolution; - info->minval[k] = vi->axes[k].min_value; - info->maxval[k] = vi->axes[k].max_value; - } - break; - case FeedbackClass: - /* Only keyboard and pointer feedback - * are handled at this time. */ - break; - case ProximityClass: - info->proximityClass = 1; - break; - case FocusClass: - info->focusClass = 1; - break; - case OtherClass: - break; - } - } - } - } - XFreeDeviceList(devices); - } - if (display != priv->display) XCloseDisplay(display); -} - -/** Obtain the mouse button mapping. */ -void dmxCommonMouGetMap(DevicePtr pDev, unsigned char *map, int *nButtons) -{ - GETPRIVFROMPDEV; - int i; - - *nButtons = XGetPointerMapping(priv->display, map, DMX_MAX_BUTTONS); - for (i = 0; i <= *nButtons; i++) map[i] = i; -} - -static void *dmxCommonXSelect(DMXScreenInfo *dmxScreen, void *closure) -{ - myPrivate *priv = closure; - XSelectInput(dmxScreen->beDisplay, dmxScreen->scrnWin, priv->eventMask); - return NULL; -} - -static void *dmxCommonAddEnabledDevice(DMXScreenInfo *dmxScreen, void *closure) -{ - AddEnabledDevice(XConnectionNumber(dmxScreen->beDisplay)); - return NULL; -} - -static void *dmxCommonRemoveEnabledDevice(DMXScreenInfo *dmxScreen, - void *closure) -{ - RemoveEnabledDevice(XConnectionNumber(dmxScreen->beDisplay)); - return NULL; -} - -/** Turn \a pDev on (i.e., take input from \a pDev). */ -int dmxCommonMouOn(DevicePtr pDev) -{ - GETPRIVFROMPDEV; - GETDMXINPUTFROMPRIV; - - priv->eventMask |= DMX_POINTER_EVENT_MASK; - if (dmxShadowFB) { - XWarpPointer(priv->display, priv->window, priv->window, - 0, 0, 0, 0, - priv->initPointerX, - priv->initPointerY); - dmxSync(&dmxScreens[dmxInput->scrnIdx], TRUE); - } - if (!priv->be) { - XSelectInput(priv->display, priv->window, priv->eventMask); - AddEnabledDevice(XConnectionNumber(priv->display)); - } else { - dmxPropertyIterate(priv->be, dmxCommonXSelect, priv); - dmxPropertyIterate(priv->be, dmxCommonAddEnabledDevice, dmxInput); - } - - return -1; -} - -/** Turn \a pDev off. */ -void dmxCommonMouOff(DevicePtr pDev) -{ - GETPRIVFROMPDEV; - GETDMXINPUTFROMPRIV; - - priv->eventMask &= ~DMX_POINTER_EVENT_MASK; - if (!priv->be) { - RemoveEnabledDevice(XConnectionNumber(priv->display)); - XSelectInput(priv->display, priv->window, priv->eventMask); - } else { - dmxPropertyIterate(priv->be, dmxCommonRemoveEnabledDevice, dmxInput); - dmxPropertyIterate(priv->be, dmxCommonXSelect, priv); - } -} - -/** Given the global coordinates \a x and \a y, determine the screen - * with the lowest number on which those coordinates lie. If they are - * not on any screen, return -1. The number returned is an index into - * \a dmxScreenInfo and is between -1 and \a dmxNumScreens - 1, - * inclusive. */ -int dmxFindPointerScreen(int x, int y) -{ - int i; - - for (i = 0; i < dmxNumScreens; i++) { - if (x >= dixScreenOrigins[i].x - && x < dixScreenOrigins[i].x + screenInfo.screens[i]->width - && y >= dixScreenOrigins[i].y - && y < dixScreenOrigins[i].y + screenInfo.screens[i]->height) - return i; - } - return -1; -} - -/** Returns a pointer to the private area for the device that comes just - * prior to \a pDevice in the current \a dmxInput device list. This is - * used as the private area for the current device in some situations - * (e.g., when a keyboard and mouse form a pair that should share the - * same private area). If the requested private area cannot be located, - * then NULL is returned. */ -pointer dmxCommonCopyPrivate(DeviceIntPtr pDevice) -{ - GETDMXLOCALFROMPDEVICE; - DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx]; - int i; - - for (i = 0; i < dmxInput->numDevs; i++) - if (dmxInput->devs[i] == dmxLocal && i) - return dmxInput->devs[i-1]->private; - return NULL; -} - -/** This routine saves and resets some important state for the backend - * and console device drivers: - * - the modifier map is saved and set to 0 (so DMX controls the LEDs) - * - the key click, bell, led, and repeat masks are saved and set to the - * values that DMX claims to be using - * - * This routine and #dmxCommonRestoreState are used when the pointer - * enters and leaves the console window, or when the backend window is - * active or not active (for a full-screen window, this only happens at - * server startup and server shutdown). - */ -void dmxCommonSaveState(pointer private) -{ - GETPRIVFROMPRIVATE; - XKeyboardState ks; - unsigned long i; - XModifierKeymap *modmap; - - if (dmxInput->console) priv = dmxInput->devs[0]->private; - if (!priv->display || priv->stateSaved) return; - DMXDBG0("dmxCommonSaveState\n"); - if (dmxUseXKB && (priv->xkb = XkbAllocKeyboard())) { - if (XkbGetIndicatorMap(priv->display, XkbAllIndicatorsMask, priv->xkb) - || XkbGetNames(priv->display, XkbAllNamesMask, priv->xkb)) { - dmxLogInput(dmxInput, "Could not get XKB information\n"); - XkbFreeKeyboard(priv->xkb, 0, True); - priv->xkb = NULL; - } else { - if (priv->xkb->indicators) { - priv->savedIndicators = *priv->xkb->indicators; - for (i = 0; i < XkbNumIndicators; i++) - if (priv->xkb->indicators->phys_indicators & (1 << i)) { - priv->xkb->indicators->maps[i].flags - = XkbIM_NoAutomatic; - } - XkbSetIndicatorMap(priv->display, ~0, priv->xkb); - } - } - } - - XGetKeyboardControl(priv->display, &ks); - priv->savedKctrl.click = ks.key_click_percent; - priv->savedKctrl.bell = ks.bell_percent; - priv->savedKctrl.bell_pitch = ks.bell_pitch; - priv->savedKctrl.bell_duration = ks.bell_duration; - priv->savedKctrl.leds = ks.led_mask; - priv->savedKctrl.autoRepeat = ks.global_auto_repeat; - for (i = 0; i < 32; i++) - priv->savedKctrl.autoRepeats[i] = ks.auto_repeats[i]; - - dmxCommonKbdSetCtrl(priv->display, &priv->savedKctrl, - &priv->dmxLocal->kctrl); - - priv->savedModMap = XGetModifierMapping(priv->display); - - modmap = XNewModifiermap(0); - XSetModifierMapping(priv->display, modmap); - if (dmxInput->scrnIdx != -1) - dmxSync(&dmxScreens[dmxInput->scrnIdx], TRUE); - XFreeModifiermap(modmap); - - priv->stateSaved = 1; -} - -/** This routine restores all the information saved by #dmxCommonSaveState. */ -void dmxCommonRestoreState(pointer private) -{ - GETPRIVFROMPRIVATE; - int retcode = -1; - CARD32 start; - - if (dmxInput->console) - priv = dmxInput->devs[0]->private; - if (!priv->stateSaved) - return; - priv->stateSaved = 0; - - DMXDBG0("dmxCommonRestoreState\n"); - if (priv->xkb) { - *priv->xkb->indicators = priv->savedIndicators; - XkbSetIndicatorMap(priv->display, ~0, priv->xkb); - XkbFreeKeyboard(priv->xkb, 0, True); - priv->xkb = 0; - } - - for (start = GetTimeInMillis(); GetTimeInMillis() - start < 5000;) { - CARD32 tmp; - - retcode = XSetModifierMapping(priv->display, priv->savedModMap); - if (retcode == MappingSuccess) - break; - if (retcode == MappingBusy) - dmxLogInput(dmxInput, "Keyboard busy, waiting\n"); - else - dmxLogInput(dmxInput, "Keyboard error, waiting\n"); - - /* Don't generate X11 protocol for a bit */ - for (tmp = GetTimeInMillis(); GetTimeInMillis() - tmp < 250;) { - usleep(250); /* This ends up sleeping only until - * the next key press generates an - * interruption. We make the delay - * relatively short in case the user - * pressed they keys quickly. */ - } - - } - if (retcode != MappingSuccess) - dmxLog(dmxWarning, "Unable to restore keyboard modifier state!\n"); - - XFreeModifiermap(priv->savedModMap); - priv->savedModMap = NULL; - - dmxCommonKbdSetCtrl(priv->display, NULL, &priv->savedKctrl); - priv->kctrlset = 0; /* Invalidate copy */ -} +/*
+ * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * David H. Dawes <dawes@xfree86.org>
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ */
+
+/** \file
+ *
+ * This file implements common routines used by the backend and console
+ * input devices.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_STATE_DEBUG 0
+
+#include "dmxinputinit.h"
+#include "dmxcommon.h"
+#include "dmxconsole.h"
+#include "dmxprop.h"
+#include "dmxsync.h"
+#include "dmxmap.h"
+
+#include "inputstr.h"
+#include "input.h"
+#include <X11/keysym.h>
+#include "mipointer.h"
+#include "scrnintstr.h"
+
+#include <unistd.h> /* For usleep() */
+
+#if DMX_STATE_DEBUG
+#define DMXDBG0(f) dmxLog(dmxDebug,f)
+#else
+#define DMXDBG0(f)
+#endif
+
+/** Each device has a private area that is visible only from inside the
+ * driver code. */
+typedef struct _myPrivate {
+ DMX_COMMON_PRIVATE;
+} myPrivate;
+
+static void dmxCommonKbdSetAR(Display *display,
+ unsigned char *old, unsigned char *new)
+{
+ XKeyboardControl kc;
+ XKeyboardState ks;
+ unsigned long mask = KBKey | KBAutoRepeatMode;
+ int i, j;
+ int minKeycode, maxKeycode;
+
+ if (!old) {
+ XGetKeyboardControl(display, &ks);
+ old = (unsigned char *)ks.auto_repeats;
+ }
+
+ XDisplayKeycodes(display, &minKeycode, &maxKeycode);
+ for (i = 1; i < 32; i++) {
+ if (!old || old[i] != new[i]) {
+ for (j = 0; j < 8; j++) {
+ if ((new[i] & (1 << j)) != (old[i] & (1 << j))) {
+ kc.key = i * 8 + j;
+ kc.auto_repeat_mode = ((new[i] & (1 << j))
+ ? AutoRepeatModeOn
+ : AutoRepeatModeOff);
+ if (kc.key >= minKeycode && kc.key <= maxKeycode)
+ XChangeKeyboardControl(display, mask, &kc);
+ }
+ }
+ }
+ }
+}
+
+static void dmxCommonKbdSetLeds(Display *display, unsigned long new)
+{
+ int i;
+ XKeyboardControl kc;
+
+ for (i = 0; i < 32; i++) {
+ kc.led = i + 1;
+ kc.led_mode = (new & (1 << i)) ? LedModeOn : LedModeOff;
+ XChangeKeyboardControl(display, KBLed | KBLedMode, &kc);
+ }
+}
+
+static void dmxCommonKbdSetCtrl(Display *display,
+ KeybdCtrl *old, KeybdCtrl *new)
+{
+ XKeyboardControl kc;
+ unsigned long mask = KBKeyClickPercent | KBAutoRepeatMode;
+
+ if (!old
+ || old->click != new->click
+ || old->autoRepeat != new->autoRepeat) {
+
+ kc.key_click_percent = new->click;
+ kc.auto_repeat_mode = new->autoRepeat;
+
+ XChangeKeyboardControl(display, mask, &kc);
+ }
+
+ dmxCommonKbdSetLeds(display, new->leds);
+ dmxCommonKbdSetAR(display, old ? old->autoRepeats : NULL,
+ new->autoRepeats);
+}
+
+static void dmxCommonMouSetCtrl(Display *display, PtrCtrl *old, PtrCtrl *new)
+{
+ Bool do_accel, do_threshold;
+
+ if (!old
+ || old->num != new->num
+ || old->den != new->den
+ || old->threshold != new->threshold) {
+ do_accel = (new->num > 0 && new->den > 0);
+ do_threshold = (new->threshold > 0);
+ if (do_accel || do_threshold) {
+ XChangePointerControl(display, do_accel, do_threshold,
+ new->num, new->den, new->threshold);
+ }
+ }
+}
+
+/** Update the keyboard control. */
+void dmxCommonKbdCtrl(DevicePtr pDev, KeybdCtrl *ctrl)
+{
+ GETPRIVFROMPDEV;
+
+ if (!priv->stateSaved && priv->be) dmxCommonSaveState(priv);
+ if (!priv->display || !priv->stateSaved) return;
+ dmxCommonKbdSetCtrl(priv->display,
+ priv->kctrlset ? &priv->kctrl : NULL,
+ ctrl);
+ priv->kctrl = *ctrl;
+ priv->kctrlset = 1;
+}
+
+/** Update the mouse control. */
+void dmxCommonMouCtrl(DevicePtr pDev, PtrCtrl *ctrl)
+{
+ GETPRIVFROMPDEV;
+
+ /* Don't set the acceleration for the
+ * console, because that should be
+ * controlled by the X server that the
+ * console is running on. Otherwise,
+ * the acceleration for the console
+ * window would be unexpected for the
+ * scale of the window. */
+ if (priv->be) {
+ dmxCommonMouSetCtrl(priv->display,
+ priv->mctrlset ? &priv->mctrl : NULL,
+ ctrl);
+ priv->mctrl = *ctrl;
+ priv->mctrlset = 1;
+ }
+}
+
+/** Sound they keyboard bell. */
+void dmxCommonKbdBell(DevicePtr pDev, int percent,
+ int volume, int pitch, int duration)
+{
+ GETPRIVFROMPDEV;
+ XKeyboardControl kc;
+ XKeyboardState ks;
+ unsigned long mask = KBBellPercent | KBBellPitch | KBBellDuration;
+
+ if (!priv->be) XGetKeyboardControl(priv->display, &ks);
+ kc.bell_percent = volume;
+ kc.bell_pitch = pitch;
+ kc.bell_duration = duration;
+ XChangeKeyboardControl(priv->display, mask, &kc);
+ XBell(priv->display, percent);
+ if (!priv->be) {
+ kc.bell_percent = ks.bell_percent;
+ kc.bell_pitch = ks.bell_pitch;
+ kc.bell_duration = ks.bell_duration;
+ XChangeKeyboardControl(priv->display, mask, &kc);
+ }
+}
+
+/** Get the keyboard mapping. */
+void dmxCommonKbdGetMap(DevicePtr pDev, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ GETPRIVFROMPDEV;
+ int min_keycode;
+ int max_keycode;
+ int map_width;
+ KeySym *keyboard_mapping;
+ XModifierKeymap *modifier_mapping;
+ int i, j;
+
+ /* Compute pKeySyms. Cast
+ * XGetKeyboardMapping because of
+ * compiler warning on 64-bit machines.
+ * We assume pointers to 32-bit and
+ * 64-bit ints are the same. */
+ XDisplayKeycodes(priv->display, &min_keycode, &max_keycode);
+ keyboard_mapping = (KeySym *)XGetKeyboardMapping(priv->display,
+ min_keycode,
+ max_keycode
+ - min_keycode + 1,
+ &map_width);
+ pKeySyms->minKeyCode = min_keycode;
+ pKeySyms->maxKeyCode = max_keycode;
+ pKeySyms->mapWidth = map_width;
+ pKeySyms->map = keyboard_mapping;
+
+
+ /* Compute pModMap */
+ modifier_mapping = XGetModifierMapping(priv->display);
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = 0;
+ for (j = 0; j < 8; j++) {
+ int max_keypermod = modifier_mapping->max_keypermod;
+
+ for (i = 0; i < max_keypermod; i++) {
+ CARD8 keycode = modifier_mapping->modifiermap[j*max_keypermod + i];
+ if (keycode)
+ pModMap[keycode] |= 1 << j;
+ }
+ }
+ XFreeModifiermap(modifier_mapping);
+}
+
+/** Fill in the XKEYBOARD parts of the \a info structure for the
+ * specified \a pDev. */
+void dmxCommonKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+ char *pt;
+
+ dmxCommonSaveState(priv);
+ if (priv->xkb) {
+#define NAME(x) \
+ priv->xkb->names->x ? XGetAtomName(priv->display,priv->xkb->names->x) : NULL
+ info->names.keycodes = NAME(keycodes);
+ info->names.types = NAME(types);
+ info->names.compat = NAME(compat);
+ info->names.symbols = NAME(symbols);
+ info->names.geometry = NAME(geometry);
+ info->freenames = 1;
+#undef NAME
+ dmxLogInput(dmxInput,
+ "XKEYBOARD: keycodes = %s\n", info->names.keycodes);
+ dmxLogInput(dmxInput,
+ "XKEYBOARD: symbols = %s\n", info->names.symbols);
+ dmxLogInput(dmxInput,
+ "XKEYBOARD: geometry = %s\n", info->names.geometry);
+ if ((pt = strchr(info->names.keycodes, '+'))) *pt = '\0';
+ }
+ dmxCommonRestoreState(priv);
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int dmxCommonKbdOn(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ if (priv->be) dmxCommonSaveState(priv);
+ priv->eventMask |= DMX_KEYBOARD_EVENT_MASK;
+ XSelectInput(priv->display, priv->window, priv->eventMask);
+ if (priv->be)
+ XSetInputFocus(priv->display, priv->window, RevertToPointerRoot,
+ CurrentTime);
+ return -1;
+}
+
+/** Turn \a pDev off. */
+void dmxCommonKbdOff(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ priv->eventMask &= ~DMX_KEYBOARD_EVENT_MASK;
+ XSelectInput(priv->display, priv->window, priv->eventMask);
+ dmxCommonRestoreState(priv);
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int dmxCommonOthOn(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+ XEventClass event_list[DMX_MAX_XINPUT_EVENT_TYPES];
+ int event_type[DMX_MAX_XINPUT_EVENT_TYPES];
+ int count = 0;
+
+#define ADD(type) \
+ if (count < DMX_MAX_XINPUT_EVENT_TYPES) { \
+ type(priv->xi, event_type[count], event_list[count]); \
+ if (event_type[count]) { \
+ dmxMapInsert(dmxLocal, event_type[count], XI_##type); \
+ ++count; \
+ } \
+ } else { \
+ dmxLog(dmxWarning, "More than %d event types for %s\n", \
+ DMX_MAX_XINPUT_EVENT_TYPES, dmxInput->name); \
+ }
+
+ if (!(priv->xi = XOpenDevice(priv->display, dmxLocal->deviceId))) {
+ dmxLog(dmxWarning, "Cannot open %s device (id=%d) on %s\n",
+ dmxLocal->deviceName ? dmxLocal->deviceName : "(unknown)",
+ dmxLocal->deviceId, dmxInput->name);
+ return -1;
+ }
+ ADD(DeviceKeyPress);
+ ADD(DeviceKeyRelease);
+ ADD(DeviceButtonPress);
+ ADD(DeviceButtonRelease);
+ ADD(DeviceMotionNotify);
+ ADD(DeviceFocusIn);
+ ADD(DeviceFocusOut);
+ ADD(ProximityIn);
+ ADD(ProximityOut);
+ ADD(DeviceStateNotify);
+ ADD(DeviceMappingNotify);
+ ADD(ChangeDeviceNotify);
+ XSelectExtensionEvent(priv->display, priv->window, event_list, count);
+
+ return -1;
+}
+
+/** Turn \a pDev off. */
+void dmxCommonOthOff(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+
+ if (priv->xi) XCloseDevice(priv->display, priv->xi);
+ priv->xi = NULL;
+}
+
+/** Fill the \a info structure with information needed to initialize \a
+ * pDev. */
+void dmxCommonOthGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+ XExtensionVersion *ext;
+ XDeviceInfo *devices;
+ Display *display = priv->display;
+ int num;
+ int i, j, k;
+ XextErrorHandler handler;
+
+ if (!display && !(display = XOpenDisplay(dmxInput->name)))
+ return;
+
+ /* Print out information about the XInput Extension. */
+ handler = XSetExtensionErrorHandler(dmxInputExtensionErrorHandler);
+ ext = XGetExtensionVersion(display, INAME);
+ XSetExtensionErrorHandler(handler);
+
+ if (ext && ext != (XExtensionVersion *)NoSuchExtension) {
+ XFree(ext);
+ devices = XListInputDevices(display, &num);
+ for (i = 0; i < num; i++) {
+ if (devices[i].id == (XID)dmxLocal->deviceId) {
+ XAnyClassPtr any;
+ XKeyInfoPtr ki;
+ XButtonInfoPtr bi;
+ XValuatorInfoPtr vi;
+ for (j = 0, any = devices[i].inputclassinfo;
+ j < devices[i].num_classes;
+ any = (XAnyClassPtr)((char *)any + any->length), j++) {
+ switch (any->class) {
+ case KeyClass:
+ ki = (XKeyInfoPtr)any;
+ info->keyboard = 1;
+ info->keyClass = 1;
+ info->keySyms.minKeyCode = ki->min_keycode;
+ info->keySyms.maxKeyCode = ki->max_keycode;
+ info->kbdFeedbackClass = 1;
+ break;
+ case ButtonClass:
+ bi = (XButtonInfoPtr)any;
+ info->buttonClass = 1;
+ info->numButtons = bi->num_buttons;
+ info->ptrFeedbackClass = 1;
+ break;
+ case ValuatorClass:
+ /* This assume all axes are either
+ * Absolute or Relative. */
+ vi = (XValuatorInfoPtr)any;
+ info->valuatorClass = 1;
+ if (vi->mode == Absolute)
+ info->numAbsAxes = vi->num_axes;
+ else
+ info->numRelAxes = vi->num_axes;
+ for (k = 0; k < vi->num_axes; k++) {
+ info->res[k] = vi->axes[k].resolution;
+ info->minres[k] = vi->axes[k].resolution;
+ info->maxres[k] = vi->axes[k].resolution;
+ info->minval[k] = vi->axes[k].min_value;
+ info->maxval[k] = vi->axes[k].max_value;
+ }
+ break;
+ case FeedbackClass:
+ /* Only keyboard and pointer feedback
+ * are handled at this time. */
+ break;
+ case ProximityClass:
+ info->proximityClass = 1;
+ break;
+ case FocusClass:
+ info->focusClass = 1;
+ break;
+ case OtherClass:
+ break;
+ }
+ }
+ }
+ }
+ XFreeDeviceList(devices);
+ }
+ if (display != priv->display) XCloseDisplay(display);
+}
+
+/** Obtain the mouse button mapping. */
+void dmxCommonMouGetMap(DevicePtr pDev, unsigned char *map, int *nButtons)
+{
+ GETPRIVFROMPDEV;
+ int i;
+
+ *nButtons = XGetPointerMapping(priv->display, map, DMX_MAX_BUTTONS);
+ for (i = 0; i <= *nButtons; i++) map[i] = i;
+}
+
+static void *dmxCommonXSelect(DMXScreenInfo *dmxScreen, void *closure)
+{
+ myPrivate *priv = closure;
+ XSelectInput(dmxScreen->beDisplay, dmxScreen->scrnWin, priv->eventMask);
+ return NULL;
+}
+
+static void *dmxCommonAddEnabledDevice(DMXScreenInfo *dmxScreen, void *closure)
+{
+ AddEnabledDevice(XConnectionNumber(dmxScreen->beDisplay));
+ return NULL;
+}
+
+static void *dmxCommonRemoveEnabledDevice(DMXScreenInfo *dmxScreen,
+ void *closure)
+{
+ RemoveEnabledDevice(XConnectionNumber(dmxScreen->beDisplay));
+ return NULL;
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int dmxCommonMouOn(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+
+ priv->eventMask |= DMX_POINTER_EVENT_MASK;
+ if (dmxShadowFB) {
+ XWarpPointer(priv->display, priv->window, priv->window,
+ 0, 0, 0, 0,
+ priv->initPointerX,
+ priv->initPointerY);
+ dmxSync(&dmxScreens[dmxInput->scrnIdx], TRUE);
+ }
+ if (!priv->be) {
+ XSelectInput(priv->display, priv->window, priv->eventMask);
+ AddEnabledDevice(XConnectionNumber(priv->display));
+ } else {
+ dmxPropertyIterate(priv->be, dmxCommonXSelect, priv);
+ dmxPropertyIterate(priv->be, dmxCommonAddEnabledDevice, dmxInput);
+ }
+
+ return -1;
+}
+
+/** Turn \a pDev off. */
+void dmxCommonMouOff(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+
+ priv->eventMask &= ~DMX_POINTER_EVENT_MASK;
+ if (!priv->be) {
+ RemoveEnabledDevice(XConnectionNumber(priv->display));
+ XSelectInput(priv->display, priv->window, priv->eventMask);
+ } else {
+ dmxPropertyIterate(priv->be, dmxCommonRemoveEnabledDevice, dmxInput);
+ dmxPropertyIterate(priv->be, dmxCommonXSelect, priv);
+ }
+}
+
+/** Given the global coordinates \a x and \a y, determine the screen
+ * with the lowest number on which those coordinates lie. If they are
+ * not on any screen, return -1. The number returned is an index into
+ * \a dmxScreenInfo and is between -1 and \a dmxNumScreens - 1,
+ * inclusive. */
+int dmxFindPointerScreen(int x, int y)
+{
+ int i;
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ if (x >= pScreen->x && x < pScreen->x + pScreen->width &&
+ y >= pScreen->y && y < pScreen->y + pScreen->height)
+ return i;
+ }
+ return -1;
+}
+
+/** Returns a pointer to the private area for the device that comes just
+ * prior to \a pDevice in the current \a dmxInput device list. This is
+ * used as the private area for the current device in some situations
+ * (e.g., when a keyboard and mouse form a pair that should share the
+ * same private area). If the requested private area cannot be located,
+ * then NULL is returned. */
+pointer dmxCommonCopyPrivate(DeviceIntPtr pDevice)
+{
+ GETDMXLOCALFROMPDEVICE;
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
+ int i;
+
+ for (i = 0; i < dmxInput->numDevs; i++)
+ if (dmxInput->devs[i] == dmxLocal && i)
+ return dmxInput->devs[i-1]->private;
+ return NULL;
+}
+
+/** This routine saves and resets some important state for the backend
+ * and console device drivers:
+ * - the modifier map is saved and set to 0 (so DMX controls the LEDs)
+ * - the key click, bell, led, and repeat masks are saved and set to the
+ * values that DMX claims to be using
+ *
+ * This routine and #dmxCommonRestoreState are used when the pointer
+ * enters and leaves the console window, or when the backend window is
+ * active or not active (for a full-screen window, this only happens at
+ * server startup and server shutdown).
+ */
+void dmxCommonSaveState(pointer private)
+{
+ GETPRIVFROMPRIVATE;
+ XKeyboardState ks;
+ unsigned long i;
+ XModifierKeymap *modmap;
+
+ if (dmxInput->console) priv = dmxInput->devs[0]->private;
+ if (!priv->display || priv->stateSaved) return;
+ DMXDBG0("dmxCommonSaveState\n");
+ if (dmxUseXKB && (priv->xkb = XkbAllocKeyboard())) {
+ if (XkbGetIndicatorMap(priv->display, XkbAllIndicatorsMask, priv->xkb)
+ || XkbGetNames(priv->display, XkbAllNamesMask, priv->xkb)) {
+ dmxLogInput(dmxInput, "Could not get XKB information\n");
+ XkbFreeKeyboard(priv->xkb, 0, True);
+ priv->xkb = NULL;
+ } else {
+ if (priv->xkb->indicators) {
+ priv->savedIndicators = *priv->xkb->indicators;
+ for (i = 0; i < XkbNumIndicators; i++)
+ if (priv->xkb->indicators->phys_indicators & (1 << i)) {
+ priv->xkb->indicators->maps[i].flags
+ = XkbIM_NoAutomatic;
+ }
+ XkbSetIndicatorMap(priv->display, ~0, priv->xkb);
+ }
+ }
+ }
+
+ XGetKeyboardControl(priv->display, &ks);
+ priv->savedKctrl.click = ks.key_click_percent;
+ priv->savedKctrl.bell = ks.bell_percent;
+ priv->savedKctrl.bell_pitch = ks.bell_pitch;
+ priv->savedKctrl.bell_duration = ks.bell_duration;
+ priv->savedKctrl.leds = ks.led_mask;
+ priv->savedKctrl.autoRepeat = ks.global_auto_repeat;
+ for (i = 0; i < 32; i++)
+ priv->savedKctrl.autoRepeats[i] = ks.auto_repeats[i];
+
+ dmxCommonKbdSetCtrl(priv->display, &priv->savedKctrl,
+ &priv->dmxLocal->kctrl);
+
+ priv->savedModMap = XGetModifierMapping(priv->display);
+
+ modmap = XNewModifiermap(0);
+ XSetModifierMapping(priv->display, modmap);
+ if (dmxInput->scrnIdx != -1)
+ dmxSync(&dmxScreens[dmxInput->scrnIdx], TRUE);
+ XFreeModifiermap(modmap);
+
+ priv->stateSaved = 1;
+}
+
+/** This routine restores all the information saved by #dmxCommonSaveState. */
+void dmxCommonRestoreState(pointer private)
+{
+ GETPRIVFROMPRIVATE;
+ int retcode = -1;
+ CARD32 start;
+
+ if (dmxInput->console)
+ priv = dmxInput->devs[0]->private;
+ if (!priv->stateSaved)
+ return;
+ priv->stateSaved = 0;
+
+ DMXDBG0("dmxCommonRestoreState\n");
+ if (priv->xkb) {
+ *priv->xkb->indicators = priv->savedIndicators;
+ XkbSetIndicatorMap(priv->display, ~0, priv->xkb);
+ XkbFreeKeyboard(priv->xkb, 0, True);
+ priv->xkb = 0;
+ }
+
+ for (start = GetTimeInMillis(); GetTimeInMillis() - start < 5000;) {
+ CARD32 tmp;
+
+ retcode = XSetModifierMapping(priv->display, priv->savedModMap);
+ if (retcode == MappingSuccess)
+ break;
+ if (retcode == MappingBusy)
+ dmxLogInput(dmxInput, "Keyboard busy, waiting\n");
+ else
+ dmxLogInput(dmxInput, "Keyboard error, waiting\n");
+
+ /* Don't generate X11 protocol for a bit */
+ for (tmp = GetTimeInMillis(); GetTimeInMillis() - tmp < 250;) {
+ usleep(250); /* This ends up sleeping only until
+ * the next key press generates an
+ * interruption. We make the delay
+ * relatively short in case the user
+ * pressed they keys quickly. */
+ }
+
+ }
+ if (retcode != MappingSuccess)
+ dmxLog(dmxWarning, "Unable to restore keyboard modifier state!\n");
+
+ XFreeModifiermap(priv->savedModMap);
+ priv->savedModMap = NULL;
+
+ dmxCommonKbdSetCtrl(priv->display, NULL, &priv->savedKctrl);
+ priv->kctrlset = 0; /* Invalidate copy */
+}
diff --git a/xorg-server/hw/dmx/input/dmxconsole.c b/xorg-server/hw/dmx/input/dmxconsole.c index 9542efacd..d4d73f2e8 100644 --- a/xorg-server/hw/dmx/input/dmxconsole.c +++ b/xorg-server/hw/dmx/input/dmxconsole.c @@ -1,1030 +1,1029 @@ -/* - * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * David H. Dawes <dawes@xfree86.org> - * Kevin E. Martin <kem@redhat.com> - * Rickard E. (Rik) Faith <faith@redhat.com> - * - */ - -/** \file - * - * This file implements the console input devices. - */ - -#ifdef HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#define DMX_CONSOLE_DEBUG 0 -#define DMX_WINDOW_DEBUG 0 - -#include "dmxinputinit.h" -#include "dmxevents.h" -#include "dmxconsole.h" -#include "dmxcommon.h" -#include "dmxscrinit.h" -#include "dmxcb.h" -#include "dmxsync.h" - -#include "inputstr.h" -#include "input.h" -#include "mipointer.h" -#include "windowstr.h" - -#define CONSOLE_NUM 3 -#define CONSOLE_DEN 4 -#define DMX_CONSOLE_NAME "DMX Console" -#define DMX_RES_NAME "Xdmx" -#define DMX_RES_CLASS "XDmx" -#define CONSOLE_BG_COLOR "gray75" -#define CONSOLE_FG_COLOR "black" -#define CONSOLE_SCREEN_BG_COLOR "white" -#define CONSOLE_SCREEN_FG_COLOR "black" -#define CONSOLE_SCREEN_DET_COLOR "gray75" -#define CONSOLE_SCREEN_CUR_COLOR "red" - -#if DMX_CONSOLE_DEBUG -#define DMXDBG0(f) dmxLog(dmxDebug,f) -#define DMXDBG1(f,a) dmxLog(dmxDebug,f,a) -#define DMXDBG2(f,a,b) dmxLog(dmxDebug,f,a,b) -#define DMXDBG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c) -#define DMXDBG4(f,a,b,c,d) dmxLog(dmxDebug,f,a,b,c,d) -#define DMXDBG5(f,a,b,c,d,e) dmxLog(dmxDebug,f,a,b,c,d,e) -#define DMXDBG6(f,a,b,c,d,e,g) dmxLog(dmxDebug,f,a,b,c,d,e,g) -#define DMXDBG7(f,a,b,c,d,e,g,h) dmxLog(dmxDebug,f,a,b,c,d,e,g,h) -#else -#define DMXDBG0(f) -#define DMXDBG1(f,a) -#define DMXDBG2(f,a,b) -#define DMXDBG3(f,a,b,c) -#define DMXDBG4(f,a,b,c,d) -#define DMXDBG5(f,a,b,c,d,e) -#define DMXDBG6(f,a,b,c,d,e,g) -#define DMXDBG7(f,a,b,c,d,e,g,h) -#endif - -/* Private area for consoles. */ -typedef struct _myPrivate { - DMX_COMMON_PRIVATE; - int lastX; - int lastY; - int globalX; - int globalY; - int curX; - int curY; - int width; - int height; - int consWidth; - int consHeight; - double xScale; - double yScale; - XlibGC gc, gcDet, gcRev, gcCur; - int grabbed, fine, captured; - Cursor cursorNormal, cursorGrabbed, cursorEmpty; - Pixmap pixmap; - - CloseScreenProcPtr CloseScreen; - struct _myPrivate *next; /* for closing multiple consoles */ - int initialized; - DevicePtr mou, kbd; -} myPrivate; - -static int scalex(myPrivate *priv, int x) -{ - return (int)((x * priv->xScale) + .5); -} - -static int scaley(myPrivate *priv, int y) -{ - return (int)((y * priv->yScale) + .5); -} - -static int unscalex(myPrivate *priv, int x) -{ - return (int)((x / priv->xScale) + .5); -} - -static int unscaley(myPrivate *priv, int y) -{ - return (int)((y / priv->yScale) + .5); -} - -/** Create the private area for \a pDevice. */ -pointer dmxConsoleCreatePrivate(DeviceIntPtr pDevice) -{ - GETDMXLOCALFROMPDEVICE; - myPrivate *priv = calloc(1, sizeof(*priv)); - priv->dmxLocal = dmxLocal; - return priv; -} - -/** If \a private is non-NULL, free its associated memory. */ -void dmxConsoleDestroyPrivate(pointer private) -{ - if (private) free(private); -} - -static void dmxConsoleDrawFineCursor(myPrivate *priv, XRectangle *rect) -{ - int size = 6; - int x, y; - - XDrawLine(priv->display, priv->pixmap, priv->gcCur, - x = scalex(priv, priv->globalX) - size, - scaley(priv, priv->globalY), - scalex(priv, priv->globalX) + size, - scaley(priv, priv->globalY)); - XDrawLine(priv->display, priv->pixmap, priv->gcCur, - scalex(priv, priv->globalX), - y = scaley(priv, priv->globalY) - size, - scalex(priv, priv->globalX), - scaley(priv, priv->globalY) + size); - if (priv->grabbed) { - XDrawLine(priv->display, priv->pixmap, priv->gcCur, - scalex(priv, priv->globalX) - (int)(size / 1.4), - scaley(priv, priv->globalY) - (int)(size / 1.4), - scalex(priv, priv->globalX) + (int)(size / 1.4), - scaley(priv, priv->globalY) + (int)(size / 1.4)); - XDrawLine(priv->display, priv->pixmap, priv->gcCur, - scalex(priv, priv->globalX) - (int)(size / 1.4), - scaley(priv, priv->globalY) + (int)(size / 1.4), - scalex(priv, priv->globalX) + (int)(size / 1.4), - scaley(priv, priv->globalY) - (int)(size / 1.4)); - } - if (rect) { - rect->x = x; - rect->y = y; - rect->width = 2 * size; - rect->height = 2 * size; - } -} - -static void dmxConsoleDrawWindows(pointer private) -{ - GETONLYPRIVFROMPRIVATE; - Display *dpy = priv->display; - int i; - Region whole, used, avail; - XRectangle rect; - - whole = XCreateRegion(); - used = XCreateRegion(); - avail = XCreateRegion(); - rect.x = 0; - rect.y = 0; - rect.width = priv->consWidth; - rect.height = priv->consHeight; - XUnionRectWithRegion(&rect, whole, whole); - - for (i = 0; i < dmxNumScreens; i++) { - WindowPtr pRoot = WindowTable[i]; - WindowPtr pChild; - -#if DMX_WINDOW_DEBUG - dmxLog(dmxDebug, "%lu %p %p %p 2\n", - pRoot->drawable.id, - pRoot->parent, pRoot->firstChild, pRoot->lastChild); -#endif - - for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib) { - if (pChild->mapped - && pChild->realized) { -#if DMX_WINDOW_DEBUG - dmxLog(dmxDebug, " %p %d,%d %dx%d %d %d %d RECTS\n", - pChild, - pChild->drawable.x, - pChild->drawable.y, - pChild->drawable.width, - pChild->drawable.height, - pChild->visibility, - pChild->overrideRedirect, - REGION_NUM_RECTS(&pChild->clipList)); -#endif - rect.x = scalex(priv, pChild->drawable.x - + dixScreenOrigins[i].x); - rect.y = scaley(priv, pChild->drawable.y - + dixScreenOrigins[i].y); - rect.width = scalex(priv, pChild->drawable.width); - rect.height = scaley(priv, pChild->drawable.height); - XDrawRectangle(dpy, priv->pixmap, priv->gc, - rect.x, rect.y, rect.width, rect.height); - XUnionRectWithRegion(&rect, used, used); - XSubtractRegion(whole, used, avail); - XSetRegion(dpy, priv->gc, avail); - } - } -#ifdef PANORAMIX - if (!noPanoramiXExtension) break; /* Screen 0 valid with Xinerama */ -#endif - } - XDestroyRegion(avail); - XDestroyRegion(used); - XDestroyRegion(whole); - XSetClipMask(dpy, priv->gc, None); -} - -static void dmxConsoleDraw(myPrivate *priv, int updateCursor, int update) -{ - GETDMXINPUTFROMPRIV; - Display *dpy = priv->display; - int i; - - XFillRectangle(dpy, priv->pixmap, priv->gc, 0, 0, - priv->consWidth, priv->consHeight); - - for (i = 0; i < dmxNumScreens; i++) { - DMXScreenInfo *dmxScreen = &dmxScreens[i]; - XFillRectangle(dpy, priv->pixmap, - dmxScreen->beDisplay ? priv->gcRev : priv->gcDet, - scalex(priv, dixScreenOrigins[i].x), - scaley(priv, dixScreenOrigins[i].y), - scalex(priv, screenInfo.screens[i]->width), - scaley(priv, screenInfo.screens[i]->height)); - } - for (i = 0; i < dmxNumScreens; i++) { - XDrawRectangle(dpy, priv->pixmap, priv->gc, - scalex(priv, dixScreenOrigins[i].x), - scaley(priv, dixScreenOrigins[i].y), - scalex(priv, screenInfo.screens[i]->width), - scaley(priv, screenInfo.screens[i]->height)); - } - if (dmxInput->windows) dmxConsoleDrawWindows(priv); - if (priv->fine && updateCursor) dmxConsoleDrawFineCursor(priv, 0); - if (update) { - XCopyArea(priv->display, priv->pixmap, priv->window, priv->gc, - 0, 0, priv->consWidth, priv->consHeight, 0, 0); - XSync(priv->display, False); /* Not a backend display */ - } -} - -static void dmxConsoleClearCursor(myPrivate *priv, int x, int y, - XRectangle *rect) -{ - int cw = 14, ch = 14; /* Clear width and height */ - - rect->x = scalex(priv, x) - cw/2; - rect->y = scaley(priv, y) - ch/2; - rect->width = cw; - rect->height = ch; - XSetClipRectangles(priv->display, priv->gc, 0, 0, rect, 1, Unsorted); - XSetClipRectangles(priv->display, priv->gcDet, 0, 0, rect, 1, Unsorted); - XSetClipRectangles(priv->display, priv->gcRev, 0, 0, rect, 1, Unsorted); - dmxConsoleDraw(priv, 0, 0); - XSetClipMask(priv->display, priv->gc, None); - XSetClipMask(priv->display, priv->gcDet, None); - XSetClipMask(priv->display, priv->gcRev, None); -} - - -static void dmxConsoleUpdateFineCursor(myPrivate *priv) -{ - int leave = 0; - XRectangle rects[2]; - - dmxConsoleClearCursor(priv, priv->globalX, priv->globalY, &rects[0]); - if (priv->dmxLocal->sendsCore) { - dmxGetGlobalPosition(&priv->globalX, &priv->globalY); - } else { - priv->globalX = priv->dmxLocal->lastX; - priv->globalY = priv->dmxLocal->lastY; - } - - priv->lastX = scalex(priv, priv->width / 2); - priv->lastY = scaley(priv, priv->height / 2); - - /* Compute new warp position, which may be - outside the window */ - if (priv->globalX < 1 || priv->globalX >= priv->width) { - if (priv->globalX < 1) priv->lastX = 0; - else priv->lastX = scalex(priv, priv->width); - priv->lastY = scaley(priv, priv->globalY); - ++leave; - } - if (priv->globalY < 1 || priv->globalY >= priv->height) { - if (priv->globalY < 1) priv->lastY = 0; - else priv->lastY = scaley(priv, priv->height); - priv->lastX = scalex(priv, priv->globalX); - ++leave; - } - - /* Draw pseudo cursor in window */ - dmxConsoleDrawFineCursor(priv, &rects[1]); - - XSetClipRectangles(priv->display, priv->gc, 0, 0, rects, 2, Unsorted); - XCopyArea(priv->display, priv->pixmap, priv->window, priv->gc, - 0, 0, priv->consWidth, priv->consHeight, 0, 0); - XSetClipMask(priv->display, priv->gc, None); - - DMXDBG2("dmxConsoleUpdateFineCursor: WARP %d %d\n", - priv->lastX, priv->lastY); - XWarpPointer(priv->display, priv->window, priv->window, - 0, 0, 0, 0, priv->lastX, priv->lastY); - XSync(priv->display, False); /* Not a backend display */ - - if (leave) { - XEvent X; - while (XCheckMaskEvent(priv->display, PointerMotionMask, &X)) { - if (X.type == MotionNotify) { - if (X.xmotion.x != priv->lastX || X.xmotion.y != priv->lastY) { - DMXDBG4("Ignoring motion to %d %d after leave frm %d %d\n", - X.xmotion.x, X.xmotion.y, - priv->lastX, priv->lastY); - } - } else { - dmxLog(dmxInfo, "Ignoring event (%d): %s ****************\n", - X.type, dmxEventName(X.type)); - } - } - } - DMXDBG6("dmxConsoleUpdateFineCursor: Warp %d %d on %d %d [%d %d]\n", - priv->lastX, priv->lastY, - scalex(priv, priv->width), - scaley(priv, priv->height), - priv->globalX, priv->globalY); -} - -/** Whenever the window layout (size, position, stacking order) might be - * changed, this routine is called with the \a pWindow that changed and - * the \a type of change. This routine is called in a conservative - * fashion: the actual layout of the windows of the screen might not - * have had any human-visible changes. */ -void dmxConsoleUpdateInfo(pointer private, DMXUpdateType type, - WindowPtr pWindow) -{ - GETONLYPRIVFROMPRIVATE; - dmxConsoleDraw(priv, 1, 1); -} - -static void dmxConsoleMoveAbsolute(myPrivate *priv, int x, int y, - DevicePtr pDev, dmxMotionProcPtr motion, - DMXBlockType block) -{ - int tmpX, tmpY, v[2]; - - tmpX = unscalex(priv, x); - tmpY = unscalex(priv, y); - DMXDBG6("dmxConsoleMoveAbsolute(,%d,%d) %d %d =? %d %d\n", - x, y, tmpX, tmpY, priv->curX, priv->curY); - if (tmpX == priv->curX && tmpY == priv->curY) return; - v[0] = unscalex(priv, x); - v[1] = unscaley(priv, y); - motion(pDev, v, 0, 2, DMX_ABSOLUTE_CONFINED, block); - /* dmxConsoleUpdatePosition gets called here by dmxCoreMotion */ -} - -static void dmxConsoleMoveRelative(myPrivate *priv, int x, int y, - DevicePtr pDev, dmxMotionProcPtr motion, - DMXBlockType block) -{ - int v[2]; - /* Ignore the event generated from * warping back to middle */ - if (x == priv->lastX && y == priv->lastY) return; - v[0] = priv->lastX - x; - v[1] = priv->lastY - y; - motion(pDev, v, 0, 2, DMX_RELATIVE, block); - /* dmxConsoleUpdatePosition gets called here by dmxCoreMotion */ -} - -/** This routine gets called from #dmxCoreMotion for each motion. This - * allows the console's notion of the cursor postion to change when - * another input device actually caused the change. */ -void dmxConsoleUpdatePosition(pointer private, int x, int y) -{ - GETONLYPRIVFROMPRIVATE; - int tmpX, tmpY; - Display *dpy = priv->display; - static unsigned long dmxGeneration = 0; - - - tmpX = scalex(priv, x); - tmpY = scaley(priv, y); - DMXDBG6("dmxConsoleUpdatePosition(,%d,%d) new=%d,%d dims=%d,%d\n", - x, y, tmpX, tmpY, priv->consWidth, priv->consHeight); - - if (priv->fine) dmxConsoleUpdateFineCursor(priv); - if (tmpX != priv->curX || tmpY != priv->curY) { - if (tmpX < 0) tmpX = 0; - if (tmpY < 0) tmpY = 0; - if (tmpX >= priv->consWidth) tmpX = priv->consWidth - 1; - if (tmpY >= priv->consHeight) tmpY = priv->consHeight - 1; - priv->curX = tmpX; - priv->curY = tmpY; - if (!priv->fine) { - DMXDBG2(" WARP B %d %d\n", priv->curX, priv->curY); - XWarpPointer(dpy, priv->window, - priv->window, 0, 0, 0, 0, tmpX, tmpY); - XSync(dpy, False); /* Not a backend display */ - } - } - - if (dmxGeneration != serverGeneration) { - dmxGeneration = serverGeneration; - dmxConsoleDraw(priv, 1, 1); - } -} - -/** Collect all pending events from the console's display. Plase these - * events on the server event queue using the \a motion and \a enqueue - * routines. The \a checkspecial routine is used to check for special - * keys that need handling. \a block tells if signals should be blocked - * when updating the event queue. */ -void dmxConsoleCollectEvents(DevicePtr pDev, - dmxMotionProcPtr motion, - dmxEnqueueProcPtr enqueue, - dmxCheckSpecialProcPtr checkspecial, - DMXBlockType block) -{ - GETPRIVFROMPDEV; - GETDMXINPUTFROMPRIV; - Display *dpy = priv->display; - Window win = priv->window; - int width = priv->width; - int height = priv->height; - XEvent X, N; - XSetWindowAttributes attribs; - static int rInitialized = 0; - static Region r; - XRectangle rect; - static int raising = 0, raiseX, raiseY; /* FIXME */ - - while (XPending(dpy)) { - XNextEvent(dpy, &X); - switch(X.type) { - case VisibilityNotify: - break; - case Expose: - DMXDBG5("dmxConsoleCollectEvents: Expose #%d %d %d %d %d\n", - X.xexpose.count, - X.xexpose.x, X.xexpose.y, - X.xexpose.width, X.xexpose.height); - if (!rInitialized++) r = XCreateRegion(); - rect.x = X.xexpose.x; - rect.y = X.xexpose.y; - rect.width = X.xexpose.width; - rect.height = X.xexpose.height; - XUnionRectWithRegion(&rect, r, r); - if (X.xexpose.count == 0) { - XSetRegion(dpy, priv->gc, r); - XSetRegion(dpy, priv->gcDet, r); - XSetRegion(dpy, priv->gcRev, r); - dmxConsoleDraw(priv, 1, 1); - XSetClipMask(dpy, priv->gc, None); - XSetClipMask(dpy, priv->gcDet, None); - XSetClipMask(dpy, priv->gcRev, None); - XDestroyRegion(r); - rInitialized = 0; - } - break; - case ResizeRequest: - DMXDBG2("dmxConsoleCollectEvents: Resize %d %d\n", - X.xresizerequest.width, X.xresizerequest.height); - priv->consWidth = X.xresizerequest.width; - priv->consHeight = X.xresizerequest.height; - priv->xScale = (double)priv->consWidth / width; - priv->yScale = (double)priv->consHeight / height; - attribs.override_redirect = True; - XChangeWindowAttributes(dpy, win, CWOverrideRedirect, &attribs); - XResizeWindow(dpy, win, priv->consWidth, priv->consHeight); - XFreePixmap(dpy, priv->pixmap); - priv->pixmap = XCreatePixmap(dpy, - RootWindow(dpy, DefaultScreen(dpy)), - priv->consWidth, - priv->consHeight, - DefaultDepth(dpy,DefaultScreen(dpy))); - dmxConsoleDraw(priv, 1, 1); - attribs.override_redirect = False; - XChangeWindowAttributes(dpy, win, CWOverrideRedirect, &attribs); - break; - case LeaveNotify: - DMXDBG4("dmxConsoleCollectEvents: Leave @ %d,%d; r=%d f=%d\n", - X.xcrossing.x, X.xcrossing.y, raising, priv->fine); - if (!priv->captured) dmxCommonRestoreState(priv); - else { - dmxConsoleUncapture(dmxInput); - dmxCommonRestoreState(priv); - } - break; - case EnterNotify: - DMXDBG6("dmxConsoleCollectEvents: Enter %d,%d r=%d f=%d (%d,%d)\n", - X.xcrossing.x, X.xcrossing.y, raising, priv->fine, - priv->curX, priv->curY); - dmxCommonSaveState(priv); - if (raising) { - raising = 0; - dmxConsoleMoveAbsolute(priv, raiseX, raiseY, - priv->mou, motion, block); - } else { - if (priv->fine) { - /* The raise will generate an event near the center, - * which is not where the cursor should be. So we - * save the real position, do the raise, and move - * the cursor here again after the raise generates - * the event. */ - raising = 1; - raiseX = X.xcrossing.x; - raiseY = X.xcrossing.y; - XRaiseWindow(dpy, priv->window); - } - XSync(dpy, False); /* Not a backend display */ - if (!X.xcrossing.x && !X.xcrossing.y) - dmxConsoleMoveAbsolute(priv, priv->curX, priv->curY, - priv->mou, motion, block); - } - break; - case MotionNotify: - if (priv->curX == X.xmotion.x && priv->curY == X.xmotion.y) - continue; - if (XPending(dpy)) { /* do motion compression */ - XPeekEvent(dpy, &N); - if (N.type == MotionNotify) continue; - } - DMXDBG2("dmxConsoleCollectEvents: Motion %d %d\n", - X.xmotion.x, X.xmotion.y); - if (raising) { - raising = 0; - dmxConsoleMoveAbsolute(priv, raiseX, raiseY, - priv->mou, motion, block); - } else { - if (priv->fine) - dmxConsoleMoveRelative(priv, X.xmotion.x, X.xmotion.y, - priv->mou, motion, block); - else - dmxConsoleMoveAbsolute(priv, X.xmotion.x, X.xmotion.y, - priv->mou, motion, block); - } - break; - case KeyPress: - case KeyRelease: - enqueue(priv->kbd, X.type, X.xkey.keycode, 0, NULL, block); - break; - default: - /* Pass the whole event here, because - * this may be an extension event. */ - enqueue(priv->mou, X.type, X.xbutton.button, 0, &X, block); - break; - } - } -} - -static void dmxCloseConsole(myPrivate *priv) -{ - GETDMXINPUTFROMPRIV; - dmxCommonRestoreState(priv); - if (priv->display) { - XFreeGC(priv->display, priv->gc); - XFreeGC(priv->display, priv->gcDet); - XFreeGC(priv->display, priv->gcRev); - XFreeGC(priv->display, priv->gcCur); - if (!dmxInput->console) XCloseDisplay(priv->display); - } - priv->display = NULL; -} - -static Bool dmxCloseConsoleScreen(int idx, ScreenPtr pScreen) -{ - myPrivate *priv, *last; - - for (last = priv = (myPrivate *)dixLookupPrivate(&pScreen->devPrivates, - dmxScreenPrivateKey); - priv; - priv = priv->next) dmxCloseConsole(last = priv); - - DMX_UNWRAP(CloseScreen, last, pScreen); - return pScreen->CloseScreen(idx, pScreen); -} - -static Cursor dmxConsoleCreateEmptyCursor(myPrivate *priv) -{ - char noCursorData[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - Pixmap pixmap; - Cursor cursor; - XColor color, tmpColor; - Display *dpy = priv->display; - - /* Create empty cursor for window */ - pixmap = XCreateBitmapFromData(priv->display, priv->window, - noCursorData, 8, 8); - if (!XAllocNamedColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), - "black", - &color, - &tmpColor)) - dmxLog(dmxFatal, "Cannot allocate color for cursor\n"); - cursor = XCreatePixmapCursor(dpy, pixmap, pixmap, &color, &color, 0, 0); - XFreePixmap(dpy, pixmap); - return cursor; -} - -static void dmxConsoleComputeWidthHeight(myPrivate *priv, - int *width, int *height, - double *xScale, double *yScale, - int *consWidth, int *consHeight) -{ - int screen; - Display *dpy = priv->display; - - *width = 0; - *height = 0; - *xScale = 1.0; - *yScale = 1.0; - - screen = DefaultScreen(dpy); - *consWidth = DisplayWidth(dpy, screen) * CONSOLE_NUM / CONSOLE_DEN; - *consHeight = DisplayHeight(dpy, screen) * CONSOLE_NUM / CONSOLE_DEN; - - if (*consWidth < 1) *consWidth = 1; - if (*consHeight < 1) *consHeight = 1; - -#if 1 - /* Always keep the console size similar - * to the global bounding box. */ - *width = dmxGlobalWidth; - *height = dmxGlobalHeight; -#else - /* Make the console window as big as - * possible by computing the visible - * bounding box. */ - for (i = 0; i < dmxNumScreens; i++) { - if (dixScreenOrigins[i].x+screenInfo.screens[i]->width > *width) - *width = dixScreenOrigins[i].x+screenInfo.screens[i]->width; - - if (dixScreenOrigins[i].y+screenInfo.screens[i]->height > *height) - *height = dixScreenOrigins[i].y+screenInfo.screens[i]->height; - } -#endif - - if ((double)*consWidth / *width < (double)*consHeight / *height) - *xScale = *yScale = (double)*consWidth / *width; - else - *xScale = *yScale = (double)*consHeight / *height; - - *consWidth = scalex(priv, *width); - *consHeight = scaley(priv, *height); - if (*consWidth < 1) *consWidth = 1; - if (*consHeight < 1) *consHeight = 1; -} - -/** Re-initialized the console device described by \a pDev (after a - * reconfig). */ -void dmxConsoleReInit(DevicePtr pDev) -{ - GETPRIVFROMPDEV; - Display *dpy; - - if (!priv || !priv->initialized) return; - dpy = priv->display; - - dmxConsoleComputeWidthHeight(priv, - &priv->width, &priv->height, - &priv->xScale, &priv->yScale, - &priv->consWidth, &priv->consHeight); - XResizeWindow(dpy, priv->window, priv->consWidth, priv->consHeight); - XFreePixmap(dpy, priv->pixmap); - priv->pixmap = XCreatePixmap(dpy, - RootWindow(dpy, DefaultScreen(dpy)), - priv->consWidth, - priv->consHeight, - DefaultDepth(dpy,DefaultScreen(dpy))); - dmxConsoleDraw(priv, 1, 1); -} - -/** Initialized the console device described by \a pDev. */ -void dmxConsoleInit(DevicePtr pDev) -{ - GETPRIVFROMPDEV; - DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx]; - int screen; - unsigned long mask; - XSetWindowAttributes attribs; - Display *dpy; - Window win; - XGCValues gcvals; - XColor color; - XClassHint class_hints; - unsigned long tmp; - - if (dmxLocal->type == DMX_LOCAL_MOUSE) priv->mou = pDev; - if (dmxLocal->type == DMX_LOCAL_KEYBOARD) priv->kbd = pDev; - if (priv->initialized++) return; /* Only do once for mouse/keyboard pair */ - - if (!(dpy = priv->display = XOpenDisplay(dmxInput->name))) - dmxLog(dmxFatal, - "dmxOpenConsole: cannot open console display %s\n", - dmxInput->name); - - /* Set up defaults */ - dmxConsoleComputeWidthHeight(priv, - &priv->width, &priv->height, - &priv->xScale, &priv->yScale, - &priv->consWidth, &priv->consHeight); - - /* Private initialization using computed values or constants. */ - screen = DefaultScreen(dpy); - priv->initPointerX = scalex(priv, priv->width / 2); - priv->initPointerY = scaley(priv, priv->height / 2); - priv->eventMask = (ButtonPressMask - | ButtonReleaseMask - | PointerMotionMask - | EnterWindowMask - | LeaveWindowMask - | KeyPressMask - | KeyReleaseMask - | ExposureMask - | ResizeRedirectMask); - - mask = CWBackPixel | CWEventMask | CWColormap | CWOverrideRedirect; - attribs.colormap = DefaultColormap(dpy, screen); - if (XParseColor(dpy, attribs.colormap, CONSOLE_BG_COLOR, &color) - && XAllocColor(dpy, attribs.colormap, &color)) { - attribs.background_pixel = color.pixel; - } else - attribs.background_pixel = WhitePixel(dpy, screen); - - attribs.event_mask = priv->eventMask; - attribs.override_redirect = False; - - win = priv->window = XCreateWindow(dpy, - RootWindow(dpy, screen), - 0, 0, priv->consWidth, priv->consHeight, - 0, - DefaultDepth(dpy, screen), - InputOutput, - DefaultVisual(dpy, screen), - mask, &attribs); - priv->pixmap = XCreatePixmap(dpy, RootWindow(dpy, screen), - priv->consWidth, priv->consHeight, - DefaultDepth(dpy, screen)); - - /* Set up properties */ - XStoreName(dpy, win, DMX_CONSOLE_NAME); - class_hints.res_name = DMX_RES_NAME; - class_hints.res_class = DMX_RES_CLASS; - XSetClassHint(dpy, win, &class_hints); - - - /* Map the window */ - XMapWindow(dpy, win); - - /* Create cursors */ - priv->cursorNormal = XCreateFontCursor(dpy, XC_circle); - priv->cursorGrabbed = XCreateFontCursor(dpy, XC_spider); - priv->cursorEmpty = dmxConsoleCreateEmptyCursor(priv); - XDefineCursor(dpy, priv->window, priv->cursorNormal); - - /* Create GC */ - mask = (GCFunction | GCPlaneMask | GCClipMask | GCForeground | - GCBackground | GCLineWidth | GCLineStyle | GCCapStyle | - GCFillStyle | GCGraphicsExposures); - gcvals.function = GXcopy; - gcvals.plane_mask = AllPlanes; - gcvals.clip_mask = None; - if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_FG_COLOR, &color) - && XAllocColor(dpy, attribs.colormap, &color)) { - gcvals.foreground = color.pixel; - } else - gcvals.foreground = BlackPixel(dpy, screen); - if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_BG_COLOR, &color) - && XAllocColor(dpy, attribs.colormap, &color)) { - gcvals.background = color.pixel; - } else - gcvals.background = WhitePixel(dpy, screen); - gcvals.line_width = 0; - gcvals.line_style = LineSolid; - gcvals.cap_style = CapNotLast; - gcvals.fill_style = FillSolid; - gcvals.graphics_exposures = False; - - priv->gc = XCreateGC(dpy, win, mask, &gcvals); - - tmp = gcvals.foreground; - if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_DET_COLOR, &color) - && XAllocColor(dpy, attribs.colormap, &color)) { - gcvals.foreground = color.pixel; - } else - gcvals.foreground = BlackPixel(dpy, screen); - priv->gcDet = XCreateGC(dpy, win, mask, &gcvals); - gcvals.foreground = tmp; - - tmp = gcvals.background; - gcvals.background = gcvals.foreground; - gcvals.foreground = tmp; - priv->gcRev = XCreateGC(dpy, win, mask, &gcvals); - - gcvals.background = gcvals.foreground; - if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_CUR_COLOR, &color) - && XAllocColor(dpy, attribs.colormap, &color)) { - gcvals.foreground = color.pixel; - } else - gcvals.foreground = BlackPixel(dpy, screen); - priv->gcCur = XCreateGC(dpy, win, mask, &gcvals); - - dmxConsoleDraw(priv, 1, 1); - - if (dixLookupPrivate(&screenInfo.screens[0]->devPrivates, - dmxScreenPrivateKey)) - priv->next = dixLookupPrivate(&screenInfo.screens[0]->devPrivates, - dmxScreenPrivateKey); - else - DMX_WRAP(CloseScreen, dmxCloseConsoleScreen, - priv, screenInfo.screens[0]); - dixSetPrivate(&screenInfo.screens[0]->devPrivates, dmxScreenPrivateKey, - priv); -} - -/** Fill in the \a info structure for the specified \a pDev. Only used - * for pointers. */ -void dmxConsoleMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info) -{ - GETPRIVFROMPDEV; - - info->buttonClass = 1; - dmxCommonMouGetMap(pDev, info->map, &info->numButtons); - info->valuatorClass = 1; - info->numRelAxes = 2; - info->minval[0] = 0; - info->minval[1] = 0; - /* max possible console window size: */ - info->maxval[0] = DisplayWidth(priv->display, DefaultScreen(priv->display)); - info->maxval[1] = DisplayHeight(priv->display, DefaultScreen(priv->display)); - info->res[0] = 1; - info->minres[0] = 0; - info->maxres[0] = 1; - info->ptrFeedbackClass = 1; -} - -/** Fill in the \a info structure for the specified \a pDev. Only used - * for keyboard. */ -void dmxConsoleKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info) -{ - dmxCommonKbdGetInfo(pDev, info); - info->keyboard = 1; - info->keyClass = 1; - dmxCommonKbdGetMap(pDev, &info->keySyms, info->modMap); - info->freemap = 1; - info->focusClass = 1; - info->kbdFeedbackClass = 1; -} - -/** Handle special console-only keys. */ -int dmxConsoleFunctions(pointer private, DMXFunctionType function) -{ - GETONLYPRIVFROMPRIVATE; - XRectangle rect; - Display *dpy = priv->display; - - switch (function) { - case DMX_FUNCTION_FINE: - if (priv->fine) { - priv->fine = 0; - dmxConsoleClearCursor(priv, priv->globalX, priv->globalY, &rect); - XSetClipRectangles(dpy, priv->gc, 0, 0, &rect, 1, Unsorted); - XCopyArea(dpy, priv->pixmap, priv->window, priv->gc, - 0, 0, priv->consWidth, priv->consHeight, 0, 0); - XSetClipMask(dpy, priv->gc, None); - - XDefineCursor(dpy, priv->window, - priv->grabbed - ? priv->cursorGrabbed - : priv->cursorNormal); - XWarpPointer(dpy, priv->window, priv->window, - 0, 0, 0, 0, - scalex(priv, priv->globalX), - scaley(priv, priv->globalY)); - XSync(dpy, False); /* Not a backend display */ - } else { - priv->fine = 1; - XRaiseWindow(dpy, priv->window); - XDefineCursor(dpy, priv->window, priv->cursorEmpty); - dmxConsoleUpdateFineCursor(priv); - } - return 1; - case DMX_FUNCTION_GRAB: - if (priv->grabbed) { - XUngrabKeyboard(dpy, CurrentTime); - XUngrabPointer(dpy, CurrentTime); - XDefineCursor(dpy, priv->window, - priv->fine - ? priv->cursorEmpty - : priv->cursorNormal); - } else { - if (XGrabPointer(dpy, priv->window, True, - 0, GrabModeAsync, GrabModeAsync, priv->window, - None, CurrentTime)) { - dmxLog(dmxError, "XGrabPointer failed\n"); - return 0; - } - if (XGrabKeyboard(dpy, priv->window, True, - GrabModeAsync, GrabModeAsync, CurrentTime)) { - dmxLog(dmxError, "XGrabKeyboard failed\n"); - XUngrabPointer(dpy, CurrentTime); - return 0; - } - XDefineCursor(dpy, priv->window, - priv->fine - ? priv->cursorEmpty - : priv->cursorGrabbed); - } - priv->grabbed = !priv->grabbed; - if (priv->fine) dmxConsoleUpdateFineCursor(priv); - return 1; - case DMX_FUNCTION_TERMINATE: - return 1; - default: - return 0; - } -} - -static void dmxDump(void) -{ - int i, j; - DMXInputInfo *dmxInput; - XEvent X; - - for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) { - for (j = 0; j < dmxInput->numDevs; j++) { - DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j]; - myPrivate *priv = dmxLocal->private; - while (priv - && priv->display - && XCheckTypedEvent(priv->display, MotionNotify, &X)) { - DMXDBG4("dmxDump: %s/%d threw event away %d %s\n", - dmxInput->name, j, X.type, dmxEventName(X.type)); - } - } - } -} - -/** This routine is used to warp the pointer into the console window - * from anywhere on the screen. It is used when backend and console - * input are both being taken from the same X display. */ -void dmxConsoleCapture(DMXInputInfo *dmxInput) -{ - int i; - XEvent X; - - DMXDBG0("dmxConsoleCapture\n"); - dmxSync(NULL, TRUE); - for (i = 0; i < dmxInput->numDevs; i++) { - DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i]; - myPrivate *priv = dmxLocal->private; - if (dmxLocal->extType != DMX_LOCAL_TYPE_CONSOLE) continue; - if (dmxLocal->type != DMX_LOCAL_MOUSE) continue; - if (priv->captured) continue; - priv->captured = 2; /* Ungrab only after proximal events. */ - XRaiseWindow(priv->display, priv->window); - XSync(priv->display, False); /* Not a backend display */ - while (XCheckTypedEvent(priv->display, MotionNotify, &X)) { - DMXDBG3(" Ignoring motion to %d %d after capture on %s\n", - X.xmotion.x, X.xmotion.y, dmxInput->name); - } - XWarpPointer(priv->display, None, - priv->window, 0, 0, 0, 0, priv->curX, priv->curY); - XSync(priv->display, False); /* Not a backend display */ - dmxDump(); - if (priv->fine) dmxConsoleUpdateFineCursor(priv); - } -} - -/** Undo the capture that was done by #dmxConsoleCapture. */ -void dmxConsoleUncapture(DMXInputInfo *dmxInput) -{ - int i; - - DMXDBG0("dmxConsoleUncapture\n"); - dmxSync(NULL, TRUE); - for (i = 0; i < dmxInput->numDevs; i++) { - DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i]; - myPrivate *priv = dmxLocal->private; - if (dmxLocal->extType != DMX_LOCAL_TYPE_CONSOLE) continue; - if (dmxLocal->type != DMX_LOCAL_MOUSE) continue; - if (!priv->captured) continue; - priv->captured = 0; - XSync(priv->display, False); /* Not a backend display */ - } -} +/*
+ * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * David H. Dawes <dawes@xfree86.org>
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This file implements the console input devices.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_CONSOLE_DEBUG 0
+#define DMX_WINDOW_DEBUG 0
+
+#include "dmxinputinit.h"
+#include "dmxevents.h"
+#include "dmxconsole.h"
+#include "dmxcommon.h"
+#include "dmxscrinit.h"
+#include "dmxcb.h"
+#include "dmxsync.h"
+
+#include "inputstr.h"
+#include "input.h"
+#include "mipointer.h"
+#include "windowstr.h"
+
+#define CONSOLE_NUM 3
+#define CONSOLE_DEN 4
+#define DMX_CONSOLE_NAME "DMX Console"
+#define DMX_RES_NAME "Xdmx"
+#define DMX_RES_CLASS "XDmx"
+#define CONSOLE_BG_COLOR "gray75"
+#define CONSOLE_FG_COLOR "black"
+#define CONSOLE_SCREEN_BG_COLOR "white"
+#define CONSOLE_SCREEN_FG_COLOR "black"
+#define CONSOLE_SCREEN_DET_COLOR "gray75"
+#define CONSOLE_SCREEN_CUR_COLOR "red"
+
+#if DMX_CONSOLE_DEBUG
+#define DMXDBG0(f) dmxLog(dmxDebug,f)
+#define DMXDBG1(f,a) dmxLog(dmxDebug,f,a)
+#define DMXDBG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define DMXDBG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define DMXDBG4(f,a,b,c,d) dmxLog(dmxDebug,f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e) dmxLog(dmxDebug,f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g) dmxLog(dmxDebug,f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h) dmxLog(dmxDebug,f,a,b,c,d,e,g,h)
+#else
+#define DMXDBG0(f)
+#define DMXDBG1(f,a)
+#define DMXDBG2(f,a,b)
+#define DMXDBG3(f,a,b,c)
+#define DMXDBG4(f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h)
+#endif
+
+/* Private area for consoles. */
+typedef struct _myPrivate {
+ DMX_COMMON_PRIVATE;
+ int lastX;
+ int lastY;
+ int globalX;
+ int globalY;
+ int curX;
+ int curY;
+ int width;
+ int height;
+ int consWidth;
+ int consHeight;
+ double xScale;
+ double yScale;
+ XlibGC gc, gcDet, gcRev, gcCur;
+ int grabbed, fine, captured;
+ Cursor cursorNormal, cursorGrabbed, cursorEmpty;
+ Pixmap pixmap;
+
+ CloseScreenProcPtr CloseScreen;
+ struct _myPrivate *next; /* for closing multiple consoles */
+ int initialized;
+ DevicePtr mou, kbd;
+} myPrivate;
+
+static int scalex(myPrivate *priv, int x)
+{
+ return (int)((x * priv->xScale) + .5);
+}
+
+static int scaley(myPrivate *priv, int y)
+{
+ return (int)((y * priv->yScale) + .5);
+}
+
+static int unscalex(myPrivate *priv, int x)
+{
+ return (int)((x / priv->xScale) + .5);
+}
+
+static int unscaley(myPrivate *priv, int y)
+{
+ return (int)((y / priv->yScale) + .5);
+}
+
+/** Create the private area for \a pDevice. */
+pointer dmxConsoleCreatePrivate(DeviceIntPtr pDevice)
+{
+ GETDMXLOCALFROMPDEVICE;
+ myPrivate *priv = calloc(1, sizeof(*priv));
+ priv->dmxLocal = dmxLocal;
+ return priv;
+}
+
+/** If \a private is non-NULL, free its associated memory. */
+void dmxConsoleDestroyPrivate(pointer private)
+{
+ free(private);
+}
+
+static void dmxConsoleDrawFineCursor(myPrivate *priv, XRectangle *rect)
+{
+ int size = 6;
+ int x, y;
+
+ XDrawLine(priv->display, priv->pixmap, priv->gcCur,
+ x = scalex(priv, priv->globalX) - size,
+ scaley(priv, priv->globalY),
+ scalex(priv, priv->globalX) + size,
+ scaley(priv, priv->globalY));
+ XDrawLine(priv->display, priv->pixmap, priv->gcCur,
+ scalex(priv, priv->globalX),
+ y = scaley(priv, priv->globalY) - size,
+ scalex(priv, priv->globalX),
+ scaley(priv, priv->globalY) + size);
+ if (priv->grabbed) {
+ XDrawLine(priv->display, priv->pixmap, priv->gcCur,
+ scalex(priv, priv->globalX) - (int)(size / 1.4),
+ scaley(priv, priv->globalY) - (int)(size / 1.4),
+ scalex(priv, priv->globalX) + (int)(size / 1.4),
+ scaley(priv, priv->globalY) + (int)(size / 1.4));
+ XDrawLine(priv->display, priv->pixmap, priv->gcCur,
+ scalex(priv, priv->globalX) - (int)(size / 1.4),
+ scaley(priv, priv->globalY) + (int)(size / 1.4),
+ scalex(priv, priv->globalX) + (int)(size / 1.4),
+ scaley(priv, priv->globalY) - (int)(size / 1.4));
+ }
+ if (rect) {
+ rect->x = x;
+ rect->y = y;
+ rect->width = 2 * size;
+ rect->height = 2 * size;
+ }
+}
+
+static void dmxConsoleDrawWindows(pointer private)
+{
+ GETONLYPRIVFROMPRIVATE;
+ Display *dpy = priv->display;
+ int i;
+ Region whole, used, avail;
+ XRectangle rect;
+
+ whole = XCreateRegion();
+ used = XCreateRegion();
+ avail = XCreateRegion();
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = priv->consWidth;
+ rect.height = priv->consHeight;
+ XUnionRectWithRegion(&rect, whole, whole);
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ WindowPtr pRoot = pScreen->root;
+ WindowPtr pChild;
+
+#if DMX_WINDOW_DEBUG
+ dmxLog(dmxDebug, "%lu %p %p %p 2\n",
+ pRoot->drawable.id,
+ pRoot->parent, pRoot->firstChild, pRoot->lastChild);
+#endif
+
+ for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib) {
+ if (pChild->mapped
+ && pChild->realized) {
+#if DMX_WINDOW_DEBUG
+ dmxLog(dmxDebug, " %p %d,%d %dx%d %d %d %d RECTS\n",
+ pChild,
+ pChild->drawable.x,
+ pChild->drawable.y,
+ pChild->drawable.width,
+ pChild->drawable.height,
+ pChild->visibility,
+ pChild->overrideRedirect,
+ RegionNumRects(&pChild->clipList));
+#endif
+ rect.x = scalex(priv, pChild->drawable.x + pScreen->x);
+ rect.y = scaley(priv, pChild->drawable.y + pScreen->y);
+ rect.width = scalex(priv, pChild->drawable.width);
+ rect.height = scaley(priv, pChild->drawable.height);
+ XDrawRectangle(dpy, priv->pixmap, priv->gc,
+ rect.x, rect.y, rect.width, rect.height);
+ XUnionRectWithRegion(&rect, used, used);
+ XSubtractRegion(whole, used, avail);
+ XSetRegion(dpy, priv->gc, avail);
+ }
+ }
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) break; /* Screen 0 valid with Xinerama */
+#endif
+ }
+ XDestroyRegion(avail);
+ XDestroyRegion(used);
+ XDestroyRegion(whole);
+ XSetClipMask(dpy, priv->gc, None);
+}
+
+static void dmxConsoleDraw(myPrivate *priv, int updateCursor, int update)
+{
+ GETDMXINPUTFROMPRIV;
+ Display *dpy = priv->display;
+ int i;
+
+ XFillRectangle(dpy, priv->pixmap, priv->gc, 0, 0,
+ priv->consWidth, priv->consHeight);
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ XFillRectangle(dpy, priv->pixmap,
+ dmxScreen->beDisplay ? priv->gcRev : priv->gcDet,
+ scalex(priv, screenInfo.screens[i]->x),
+ scaley(priv, screenInfo.screens[i]->y),
+ scalex(priv, screenInfo.screens[i]->width),
+ scaley(priv, screenInfo.screens[i]->height));
+ }
+ for (i = 0; i < dmxNumScreens; i++) {
+ XDrawRectangle(dpy, priv->pixmap, priv->gc,
+ scalex(priv, screenInfo.screens[i]->x),
+ scaley(priv, screenInfo.screens[i]->y),
+ scalex(priv, screenInfo.screens[i]->width),
+ scaley(priv, screenInfo.screens[i]->height));
+ }
+ if (dmxInput->windows) dmxConsoleDrawWindows(priv);
+ if (priv->fine && updateCursor) dmxConsoleDrawFineCursor(priv, 0);
+ if (update) {
+ XCopyArea(priv->display, priv->pixmap, priv->window, priv->gc,
+ 0, 0, priv->consWidth, priv->consHeight, 0, 0);
+ XSync(priv->display, False); /* Not a backend display */
+ }
+}
+
+static void dmxConsoleClearCursor(myPrivate *priv, int x, int y,
+ XRectangle *rect)
+{
+ int cw = 14, ch = 14; /* Clear width and height */
+
+ rect->x = scalex(priv, x) - cw/2;
+ rect->y = scaley(priv, y) - ch/2;
+ rect->width = cw;
+ rect->height = ch;
+ XSetClipRectangles(priv->display, priv->gc, 0, 0, rect, 1, Unsorted);
+ XSetClipRectangles(priv->display, priv->gcDet, 0, 0, rect, 1, Unsorted);
+ XSetClipRectangles(priv->display, priv->gcRev, 0, 0, rect, 1, Unsorted);
+ dmxConsoleDraw(priv, 0, 0);
+ XSetClipMask(priv->display, priv->gc, None);
+ XSetClipMask(priv->display, priv->gcDet, None);
+ XSetClipMask(priv->display, priv->gcRev, None);
+}
+
+
+static void dmxConsoleUpdateFineCursor(myPrivate *priv)
+{
+ int leave = 0;
+ XRectangle rects[2];
+
+ dmxConsoleClearCursor(priv, priv->globalX, priv->globalY, &rects[0]);
+ if (priv->dmxLocal->sendsCore) {
+ dmxGetGlobalPosition(&priv->globalX, &priv->globalY);
+ } else {
+ priv->globalX = priv->dmxLocal->lastX;
+ priv->globalY = priv->dmxLocal->lastY;
+ }
+
+ priv->lastX = scalex(priv, priv->width / 2);
+ priv->lastY = scaley(priv, priv->height / 2);
+
+ /* Compute new warp position, which may be
+ outside the window */
+ if (priv->globalX < 1 || priv->globalX >= priv->width) {
+ if (priv->globalX < 1) priv->lastX = 0;
+ else priv->lastX = scalex(priv, priv->width);
+ priv->lastY = scaley(priv, priv->globalY);
+ ++leave;
+ }
+ if (priv->globalY < 1 || priv->globalY >= priv->height) {
+ if (priv->globalY < 1) priv->lastY = 0;
+ else priv->lastY = scaley(priv, priv->height);
+ priv->lastX = scalex(priv, priv->globalX);
+ ++leave;
+ }
+
+ /* Draw pseudo cursor in window */
+ dmxConsoleDrawFineCursor(priv, &rects[1]);
+
+ XSetClipRectangles(priv->display, priv->gc, 0, 0, rects, 2, Unsorted);
+ XCopyArea(priv->display, priv->pixmap, priv->window, priv->gc,
+ 0, 0, priv->consWidth, priv->consHeight, 0, 0);
+ XSetClipMask(priv->display, priv->gc, None);
+
+ DMXDBG2("dmxConsoleUpdateFineCursor: WARP %d %d\n",
+ priv->lastX, priv->lastY);
+ XWarpPointer(priv->display, priv->window, priv->window,
+ 0, 0, 0, 0, priv->lastX, priv->lastY);
+ XSync(priv->display, False); /* Not a backend display */
+
+ if (leave) {
+ XEvent X;
+ while (XCheckMaskEvent(priv->display, PointerMotionMask, &X)) {
+ if (X.type == MotionNotify) {
+ if (X.xmotion.x != priv->lastX || X.xmotion.y != priv->lastY) {
+ DMXDBG4("Ignoring motion to %d %d after leave frm %d %d\n",
+ X.xmotion.x, X.xmotion.y,
+ priv->lastX, priv->lastY);
+ }
+ } else {
+ dmxLog(dmxInfo, "Ignoring event (%d): %s ****************\n",
+ X.type, dmxEventName(X.type));
+ }
+ }
+ }
+ DMXDBG6("dmxConsoleUpdateFineCursor: Warp %d %d on %d %d [%d %d]\n",
+ priv->lastX, priv->lastY,
+ scalex(priv, priv->width),
+ scaley(priv, priv->height),
+ priv->globalX, priv->globalY);
+}
+
+/** Whenever the window layout (size, position, stacking order) might be
+ * changed, this routine is called with the \a pWindow that changed and
+ * the \a type of change. This routine is called in a conservative
+ * fashion: the actual layout of the windows of the screen might not
+ * have had any human-visible changes. */
+void dmxConsoleUpdateInfo(pointer private, DMXUpdateType type,
+ WindowPtr pWindow)
+{
+ GETONLYPRIVFROMPRIVATE;
+ dmxConsoleDraw(priv, 1, 1);
+}
+
+static void dmxConsoleMoveAbsolute(myPrivate *priv, int x, int y,
+ DevicePtr pDev, dmxMotionProcPtr motion,
+ DMXBlockType block)
+{
+ int tmpX, tmpY, v[2];
+
+ tmpX = unscalex(priv, x);
+ tmpY = unscalex(priv, y);
+ DMXDBG6("dmxConsoleMoveAbsolute(,%d,%d) %d %d =? %d %d\n",
+ x, y, tmpX, tmpY, priv->curX, priv->curY);
+ if (tmpX == priv->curX && tmpY == priv->curY) return;
+ v[0] = unscalex(priv, x);
+ v[1] = unscaley(priv, y);
+ motion(pDev, v, 0, 2, DMX_ABSOLUTE_CONFINED, block);
+ /* dmxConsoleUpdatePosition gets called here by dmxCoreMotion */
+}
+
+static void dmxConsoleMoveRelative(myPrivate *priv, int x, int y,
+ DevicePtr pDev, dmxMotionProcPtr motion,
+ DMXBlockType block)
+{
+ int v[2];
+ /* Ignore the event generated from * warping back to middle */
+ if (x == priv->lastX && y == priv->lastY) return;
+ v[0] = priv->lastX - x;
+ v[1] = priv->lastY - y;
+ motion(pDev, v, 0, 2, DMX_RELATIVE, block);
+ /* dmxConsoleUpdatePosition gets called here by dmxCoreMotion */
+}
+
+/** This routine gets called from #dmxCoreMotion for each motion. This
+ * allows the console's notion of the cursor postion to change when
+ * another input device actually caused the change. */
+void dmxConsoleUpdatePosition(pointer private, int x, int y)
+{
+ GETONLYPRIVFROMPRIVATE;
+ int tmpX, tmpY;
+ Display *dpy = priv->display;
+ static unsigned long dmxGeneration = 0;
+
+
+ tmpX = scalex(priv, x);
+ tmpY = scaley(priv, y);
+ DMXDBG6("dmxConsoleUpdatePosition(,%d,%d) new=%d,%d dims=%d,%d\n",
+ x, y, tmpX, tmpY, priv->consWidth, priv->consHeight);
+
+ if (priv->fine) dmxConsoleUpdateFineCursor(priv);
+ if (tmpX != priv->curX || tmpY != priv->curY) {
+ if (tmpX < 0) tmpX = 0;
+ if (tmpY < 0) tmpY = 0;
+ if (tmpX >= priv->consWidth) tmpX = priv->consWidth - 1;
+ if (tmpY >= priv->consHeight) tmpY = priv->consHeight - 1;
+ priv->curX = tmpX;
+ priv->curY = tmpY;
+ if (!priv->fine) {
+ DMXDBG2(" WARP B %d %d\n", priv->curX, priv->curY);
+ XWarpPointer(dpy, priv->window,
+ priv->window, 0, 0, 0, 0, tmpX, tmpY);
+ XSync(dpy, False); /* Not a backend display */
+ }
+ }
+
+ if (dmxGeneration != serverGeneration) {
+ dmxGeneration = serverGeneration;
+ dmxConsoleDraw(priv, 1, 1);
+ }
+}
+
+/** Collect all pending events from the console's display. Plase these
+ * events on the server event queue using the \a motion and \a enqueue
+ * routines. The \a checkspecial routine is used to check for special
+ * keys that need handling. \a block tells if signals should be blocked
+ * when updating the event queue. */
+void dmxConsoleCollectEvents(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+ Display *dpy = priv->display;
+ Window win = priv->window;
+ int width = priv->width;
+ int height = priv->height;
+ XEvent X, N;
+ XSetWindowAttributes attribs;
+ static int rInitialized = 0;
+ static Region r;
+ XRectangle rect;
+ static int raising = 0, raiseX, raiseY; /* FIXME */
+
+ while (XPending(dpy)) {
+ XNextEvent(dpy, &X);
+ switch(X.type) {
+ case VisibilityNotify:
+ break;
+ case Expose:
+ DMXDBG5("dmxConsoleCollectEvents: Expose #%d %d %d %d %d\n",
+ X.xexpose.count,
+ X.xexpose.x, X.xexpose.y,
+ X.xexpose.width, X.xexpose.height);
+ if (!rInitialized++) r = XCreateRegion();
+ rect.x = X.xexpose.x;
+ rect.y = X.xexpose.y;
+ rect.width = X.xexpose.width;
+ rect.height = X.xexpose.height;
+ XUnionRectWithRegion(&rect, r, r);
+ if (X.xexpose.count == 0) {
+ XSetRegion(dpy, priv->gc, r);
+ XSetRegion(dpy, priv->gcDet, r);
+ XSetRegion(dpy, priv->gcRev, r);
+ dmxConsoleDraw(priv, 1, 1);
+ XSetClipMask(dpy, priv->gc, None);
+ XSetClipMask(dpy, priv->gcDet, None);
+ XSetClipMask(dpy, priv->gcRev, None);
+ XDestroyRegion(r);
+ rInitialized = 0;
+ }
+ break;
+ case ResizeRequest:
+ DMXDBG2("dmxConsoleCollectEvents: Resize %d %d\n",
+ X.xresizerequest.width, X.xresizerequest.height);
+ priv->consWidth = X.xresizerequest.width;
+ priv->consHeight = X.xresizerequest.height;
+ priv->xScale = (double)priv->consWidth / width;
+ priv->yScale = (double)priv->consHeight / height;
+ attribs.override_redirect = True;
+ XChangeWindowAttributes(dpy, win, CWOverrideRedirect, &attribs);
+ XResizeWindow(dpy, win, priv->consWidth, priv->consHeight);
+ XFreePixmap(dpy, priv->pixmap);
+ priv->pixmap = XCreatePixmap(dpy,
+ RootWindow(dpy, DefaultScreen(dpy)),
+ priv->consWidth,
+ priv->consHeight,
+ DefaultDepth(dpy,DefaultScreen(dpy)));
+ dmxConsoleDraw(priv, 1, 1);
+ attribs.override_redirect = False;
+ XChangeWindowAttributes(dpy, win, CWOverrideRedirect, &attribs);
+ break;
+ case LeaveNotify:
+ DMXDBG4("dmxConsoleCollectEvents: Leave @ %d,%d; r=%d f=%d\n",
+ X.xcrossing.x, X.xcrossing.y, raising, priv->fine);
+ if (!priv->captured) dmxCommonRestoreState(priv);
+ else {
+ dmxConsoleUncapture(dmxInput);
+ dmxCommonRestoreState(priv);
+ }
+ break;
+ case EnterNotify:
+ DMXDBG6("dmxConsoleCollectEvents: Enter %d,%d r=%d f=%d (%d,%d)\n",
+ X.xcrossing.x, X.xcrossing.y, raising, priv->fine,
+ priv->curX, priv->curY);
+ dmxCommonSaveState(priv);
+ if (raising) {
+ raising = 0;
+ dmxConsoleMoveAbsolute(priv, raiseX, raiseY,
+ priv->mou, motion, block);
+ } else {
+ if (priv->fine) {
+ /* The raise will generate an event near the center,
+ * which is not where the cursor should be. So we
+ * save the real position, do the raise, and move
+ * the cursor here again after the raise generates
+ * the event. */
+ raising = 1;
+ raiseX = X.xcrossing.x;
+ raiseY = X.xcrossing.y;
+ XRaiseWindow(dpy, priv->window);
+ }
+ XSync(dpy, False); /* Not a backend display */
+ if (!X.xcrossing.x && !X.xcrossing.y)
+ dmxConsoleMoveAbsolute(priv, priv->curX, priv->curY,
+ priv->mou, motion, block);
+ }
+ break;
+ case MotionNotify:
+ if (priv->curX == X.xmotion.x && priv->curY == X.xmotion.y)
+ continue;
+ if (XPending(dpy)) { /* do motion compression */
+ XPeekEvent(dpy, &N);
+ if (N.type == MotionNotify) continue;
+ }
+ DMXDBG2("dmxConsoleCollectEvents: Motion %d %d\n",
+ X.xmotion.x, X.xmotion.y);
+ if (raising) {
+ raising = 0;
+ dmxConsoleMoveAbsolute(priv, raiseX, raiseY,
+ priv->mou, motion, block);
+ } else {
+ if (priv->fine)
+ dmxConsoleMoveRelative(priv, X.xmotion.x, X.xmotion.y,
+ priv->mou, motion, block);
+ else
+ dmxConsoleMoveAbsolute(priv, X.xmotion.x, X.xmotion.y,
+ priv->mou, motion, block);
+ }
+ break;
+ case KeyPress:
+ case KeyRelease:
+ enqueue(priv->kbd, X.type, X.xkey.keycode, 0, NULL, block);
+ break;
+ default:
+ /* Pass the whole event here, because
+ * this may be an extension event. */
+ enqueue(priv->mou, X.type, X.xbutton.button, 0, &X, block);
+ break;
+ }
+ }
+}
+
+static void dmxCloseConsole(myPrivate *priv)
+{
+ GETDMXINPUTFROMPRIV;
+ dmxCommonRestoreState(priv);
+ if (priv->display) {
+ XFreeGC(priv->display, priv->gc);
+ XFreeGC(priv->display, priv->gcDet);
+ XFreeGC(priv->display, priv->gcRev);
+ XFreeGC(priv->display, priv->gcCur);
+ if (!dmxInput->console) XCloseDisplay(priv->display);
+ }
+ priv->display = NULL;
+}
+
+static Bool dmxCloseConsoleScreen(int idx, ScreenPtr pScreen)
+{
+ myPrivate *priv, *last;
+
+ for (last = priv = (myPrivate *)dixLookupPrivate(&pScreen->devPrivates,
+ dmxScreenPrivateKey);
+ priv;
+ priv = priv->next) dmxCloseConsole(last = priv);
+
+ DMX_UNWRAP(CloseScreen, last, pScreen);
+ return pScreen->CloseScreen(idx, pScreen);
+}
+
+static Cursor dmxConsoleCreateEmptyCursor(myPrivate *priv)
+{
+ char noCursorData[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ Pixmap pixmap;
+ Cursor cursor;
+ XColor color, tmpColor;
+ Display *dpy = priv->display;
+
+ /* Create empty cursor for window */
+ pixmap = XCreateBitmapFromData(priv->display, priv->window,
+ noCursorData, 8, 8);
+ if (!XAllocNamedColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)),
+ "black",
+ &color,
+ &tmpColor))
+ dmxLog(dmxFatal, "Cannot allocate color for cursor\n");
+ cursor = XCreatePixmapCursor(dpy, pixmap, pixmap, &color, &color, 0, 0);
+ XFreePixmap(dpy, pixmap);
+ return cursor;
+}
+
+static void dmxConsoleComputeWidthHeight(myPrivate *priv,
+ int *width, int *height,
+ double *xScale, double *yScale,
+ int *consWidth, int *consHeight)
+{
+ int screen;
+ Display *dpy = priv->display;
+
+ *width = 0;
+ *height = 0;
+ *xScale = 1.0;
+ *yScale = 1.0;
+
+ screen = DefaultScreen(dpy);
+ *consWidth = DisplayWidth(dpy, screen) * CONSOLE_NUM / CONSOLE_DEN;
+ *consHeight = DisplayHeight(dpy, screen) * CONSOLE_NUM / CONSOLE_DEN;
+
+ if (*consWidth < 1) *consWidth = 1;
+ if (*consHeight < 1) *consHeight = 1;
+
+#if 1
+ /* Always keep the console size similar
+ * to the global bounding box. */
+ *width = dmxGlobalWidth;
+ *height = dmxGlobalHeight;
+#else
+ /* Make the console window as big as
+ * possible by computing the visible
+ * bounding box. */
+ for (i = 0; i < dmxNumScreens; i++) {
+ if (screenInfo.screens[i]->x+screenInfo.screens[i]->width > *width)
+ *width = screenInfo.screens[i]->x+screenInfo.screens[i]->width;
+
+ if (screenInfo.screens[i]->y+screenInfo.screens[i]->height > *height)
+ *height = screenInfo.screens[i]->y+screenInfo.screens[i]->height;
+ }
+#endif
+
+ if ((double)*consWidth / *width < (double)*consHeight / *height)
+ *xScale = *yScale = (double)*consWidth / *width;
+ else
+ *xScale = *yScale = (double)*consHeight / *height;
+
+ *consWidth = scalex(priv, *width);
+ *consHeight = scaley(priv, *height);
+ if (*consWidth < 1) *consWidth = 1;
+ if (*consHeight < 1) *consHeight = 1;
+}
+
+/** Re-initialized the console device described by \a pDev (after a
+ * reconfig). */
+void dmxConsoleReInit(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ Display *dpy;
+
+ if (!priv || !priv->initialized) return;
+ dpy = priv->display;
+
+ dmxConsoleComputeWidthHeight(priv,
+ &priv->width, &priv->height,
+ &priv->xScale, &priv->yScale,
+ &priv->consWidth, &priv->consHeight);
+ XResizeWindow(dpy, priv->window, priv->consWidth, priv->consHeight);
+ XFreePixmap(dpy, priv->pixmap);
+ priv->pixmap = XCreatePixmap(dpy,
+ RootWindow(dpy, DefaultScreen(dpy)),
+ priv->consWidth,
+ priv->consHeight,
+ DefaultDepth(dpy,DefaultScreen(dpy)));
+ dmxConsoleDraw(priv, 1, 1);
+}
+
+/** Initialized the console device described by \a pDev. */
+void dmxConsoleInit(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
+ int screen;
+ unsigned long mask;
+ XSetWindowAttributes attribs;
+ Display *dpy;
+ Window win;
+ XGCValues gcvals;
+ XColor color;
+ XClassHint class_hints;
+ unsigned long tmp;
+
+ if (dmxLocal->type == DMX_LOCAL_MOUSE) priv->mou = pDev;
+ if (dmxLocal->type == DMX_LOCAL_KEYBOARD) priv->kbd = pDev;
+ if (priv->initialized++) return; /* Only do once for mouse/keyboard pair */
+
+ if (!(dpy = priv->display = XOpenDisplay(dmxInput->name)))
+ dmxLog(dmxFatal,
+ "dmxOpenConsole: cannot open console display %s\n",
+ dmxInput->name);
+
+ /* Set up defaults */
+ dmxConsoleComputeWidthHeight(priv,
+ &priv->width, &priv->height,
+ &priv->xScale, &priv->yScale,
+ &priv->consWidth, &priv->consHeight);
+
+ /* Private initialization using computed values or constants. */
+ screen = DefaultScreen(dpy);
+ priv->initPointerX = scalex(priv, priv->width / 2);
+ priv->initPointerY = scaley(priv, priv->height / 2);
+ priv->eventMask = (ButtonPressMask
+ | ButtonReleaseMask
+ | PointerMotionMask
+ | EnterWindowMask
+ | LeaveWindowMask
+ | KeyPressMask
+ | KeyReleaseMask
+ | ExposureMask
+ | ResizeRedirectMask);
+
+ mask = CWBackPixel | CWEventMask | CWColormap | CWOverrideRedirect;
+ attribs.colormap = DefaultColormap(dpy, screen);
+ if (XParseColor(dpy, attribs.colormap, CONSOLE_BG_COLOR, &color)
+ && XAllocColor(dpy, attribs.colormap, &color)) {
+ attribs.background_pixel = color.pixel;
+ } else
+ attribs.background_pixel = WhitePixel(dpy, screen);
+
+ attribs.event_mask = priv->eventMask;
+ attribs.override_redirect = False;
+
+ win = priv->window = XCreateWindow(dpy,
+ RootWindow(dpy, screen),
+ 0, 0, priv->consWidth, priv->consHeight,
+ 0,
+ DefaultDepth(dpy, screen),
+ InputOutput,
+ DefaultVisual(dpy, screen),
+ mask, &attribs);
+ priv->pixmap = XCreatePixmap(dpy, RootWindow(dpy, screen),
+ priv->consWidth, priv->consHeight,
+ DefaultDepth(dpy, screen));
+
+ /* Set up properties */
+ XStoreName(dpy, win, DMX_CONSOLE_NAME);
+ class_hints.res_name = DMX_RES_NAME;
+ class_hints.res_class = DMX_RES_CLASS;
+ XSetClassHint(dpy, win, &class_hints);
+
+
+ /* Map the window */
+ XMapWindow(dpy, win);
+
+ /* Create cursors */
+ priv->cursorNormal = XCreateFontCursor(dpy, XC_circle);
+ priv->cursorGrabbed = XCreateFontCursor(dpy, XC_spider);
+ priv->cursorEmpty = dmxConsoleCreateEmptyCursor(priv);
+ XDefineCursor(dpy, priv->window, priv->cursorNormal);
+
+ /* Create GC */
+ mask = (GCFunction | GCPlaneMask | GCClipMask | GCForeground |
+ GCBackground | GCLineWidth | GCLineStyle | GCCapStyle |
+ GCFillStyle | GCGraphicsExposures);
+ gcvals.function = GXcopy;
+ gcvals.plane_mask = AllPlanes;
+ gcvals.clip_mask = None;
+ if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_FG_COLOR, &color)
+ && XAllocColor(dpy, attribs.colormap, &color)) {
+ gcvals.foreground = color.pixel;
+ } else
+ gcvals.foreground = BlackPixel(dpy, screen);
+ if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_BG_COLOR, &color)
+ && XAllocColor(dpy, attribs.colormap, &color)) {
+ gcvals.background = color.pixel;
+ } else
+ gcvals.background = WhitePixel(dpy, screen);
+ gcvals.line_width = 0;
+ gcvals.line_style = LineSolid;
+ gcvals.cap_style = CapNotLast;
+ gcvals.fill_style = FillSolid;
+ gcvals.graphics_exposures = False;
+
+ priv->gc = XCreateGC(dpy, win, mask, &gcvals);
+
+ tmp = gcvals.foreground;
+ if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_DET_COLOR, &color)
+ && XAllocColor(dpy, attribs.colormap, &color)) {
+ gcvals.foreground = color.pixel;
+ } else
+ gcvals.foreground = BlackPixel(dpy, screen);
+ priv->gcDet = XCreateGC(dpy, win, mask, &gcvals);
+ gcvals.foreground = tmp;
+
+ tmp = gcvals.background;
+ gcvals.background = gcvals.foreground;
+ gcvals.foreground = tmp;
+ priv->gcRev = XCreateGC(dpy, win, mask, &gcvals);
+
+ gcvals.background = gcvals.foreground;
+ if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_CUR_COLOR, &color)
+ && XAllocColor(dpy, attribs.colormap, &color)) {
+ gcvals.foreground = color.pixel;
+ } else
+ gcvals.foreground = BlackPixel(dpy, screen);
+ priv->gcCur = XCreateGC(dpy, win, mask, &gcvals);
+
+ dmxConsoleDraw(priv, 1, 1);
+
+ if (dixLookupPrivate(&screenInfo.screens[0]->devPrivates,
+ dmxScreenPrivateKey))
+ priv->next = dixLookupPrivate(&screenInfo.screens[0]->devPrivates,
+ dmxScreenPrivateKey);
+ else
+ DMX_WRAP(CloseScreen, dmxCloseConsoleScreen,
+ priv, screenInfo.screens[0]);
+ dixSetPrivate(&screenInfo.screens[0]->devPrivates, dmxScreenPrivateKey,
+ priv);
+}
+
+/** Fill in the \a info structure for the specified \a pDev. Only used
+ * for pointers. */
+void dmxConsoleMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ GETPRIVFROMPDEV;
+
+ info->buttonClass = 1;
+ dmxCommonMouGetMap(pDev, info->map, &info->numButtons);
+ info->valuatorClass = 1;
+ info->numRelAxes = 2;
+ info->minval[0] = 0;
+ info->minval[1] = 0;
+ /* max possible console window size: */
+ info->maxval[0] = DisplayWidth(priv->display, DefaultScreen(priv->display));
+ info->maxval[1] = DisplayHeight(priv->display, DefaultScreen(priv->display));
+ info->res[0] = 1;
+ info->minres[0] = 0;
+ info->maxres[0] = 1;
+ info->ptrFeedbackClass = 1;
+}
+
+/** Fill in the \a info structure for the specified \a pDev. Only used
+ * for keyboard. */
+void dmxConsoleKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ dmxCommonKbdGetInfo(pDev, info);
+ info->keyboard = 1;
+ info->keyClass = 1;
+ dmxCommonKbdGetMap(pDev, &info->keySyms, info->modMap);
+ info->freemap = 1;
+ info->focusClass = 1;
+ info->kbdFeedbackClass = 1;
+}
+
+/** Handle special console-only keys. */
+int dmxConsoleFunctions(pointer private, DMXFunctionType function)
+{
+ GETONLYPRIVFROMPRIVATE;
+ XRectangle rect;
+ Display *dpy = priv->display;
+
+ switch (function) {
+ case DMX_FUNCTION_FINE:
+ if (priv->fine) {
+ priv->fine = 0;
+ dmxConsoleClearCursor(priv, priv->globalX, priv->globalY, &rect);
+ XSetClipRectangles(dpy, priv->gc, 0, 0, &rect, 1, Unsorted);
+ XCopyArea(dpy, priv->pixmap, priv->window, priv->gc,
+ 0, 0, priv->consWidth, priv->consHeight, 0, 0);
+ XSetClipMask(dpy, priv->gc, None);
+
+ XDefineCursor(dpy, priv->window,
+ priv->grabbed
+ ? priv->cursorGrabbed
+ : priv->cursorNormal);
+ XWarpPointer(dpy, priv->window, priv->window,
+ 0, 0, 0, 0,
+ scalex(priv, priv->globalX),
+ scaley(priv, priv->globalY));
+ XSync(dpy, False); /* Not a backend display */
+ } else {
+ priv->fine = 1;
+ XRaiseWindow(dpy, priv->window);
+ XDefineCursor(dpy, priv->window, priv->cursorEmpty);
+ dmxConsoleUpdateFineCursor(priv);
+ }
+ return 1;
+ case DMX_FUNCTION_GRAB:
+ if (priv->grabbed) {
+ XUngrabKeyboard(dpy, CurrentTime);
+ XUngrabPointer(dpy, CurrentTime);
+ XDefineCursor(dpy, priv->window,
+ priv->fine
+ ? priv->cursorEmpty
+ : priv->cursorNormal);
+ } else {
+ if (XGrabPointer(dpy, priv->window, True,
+ 0, GrabModeAsync, GrabModeAsync, priv->window,
+ None, CurrentTime)) {
+ dmxLog(dmxError, "XGrabPointer failed\n");
+ return 0;
+ }
+ if (XGrabKeyboard(dpy, priv->window, True,
+ GrabModeAsync, GrabModeAsync, CurrentTime)) {
+ dmxLog(dmxError, "XGrabKeyboard failed\n");
+ XUngrabPointer(dpy, CurrentTime);
+ return 0;
+ }
+ XDefineCursor(dpy, priv->window,
+ priv->fine
+ ? priv->cursorEmpty
+ : priv->cursorGrabbed);
+ }
+ priv->grabbed = !priv->grabbed;
+ if (priv->fine) dmxConsoleUpdateFineCursor(priv);
+ return 1;
+ case DMX_FUNCTION_TERMINATE:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static void dmxDump(void)
+{
+ int i, j;
+ DMXInputInfo *dmxInput;
+ XEvent X;
+
+ for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
+ for (j = 0; j < dmxInput->numDevs; j++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j];
+ myPrivate *priv = dmxLocal->private;
+ while (priv
+ && priv->display
+ && XCheckTypedEvent(priv->display, MotionNotify, &X)) {
+ DMXDBG4("dmxDump: %s/%d threw event away %d %s\n",
+ dmxInput->name, j, X.type, dmxEventName(X.type));
+ }
+ }
+ }
+}
+
+/** This routine is used to warp the pointer into the console window
+ * from anywhere on the screen. It is used when backend and console
+ * input are both being taken from the same X display. */
+void dmxConsoleCapture(DMXInputInfo *dmxInput)
+{
+ int i;
+ XEvent X;
+
+ DMXDBG0("dmxConsoleCapture\n");
+ dmxSync(NULL, TRUE);
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i];
+ myPrivate *priv = dmxLocal->private;
+ if (dmxLocal->extType != DMX_LOCAL_TYPE_CONSOLE) continue;
+ if (dmxLocal->type != DMX_LOCAL_MOUSE) continue;
+ if (priv->captured) continue;
+ priv->captured = 2; /* Ungrab only after proximal events. */
+ XRaiseWindow(priv->display, priv->window);
+ XSync(priv->display, False); /* Not a backend display */
+ while (XCheckTypedEvent(priv->display, MotionNotify, &X)) {
+ DMXDBG3(" Ignoring motion to %d %d after capture on %s\n",
+ X.xmotion.x, X.xmotion.y, dmxInput->name);
+ }
+ XWarpPointer(priv->display, None,
+ priv->window, 0, 0, 0, 0, priv->curX, priv->curY);
+ XSync(priv->display, False); /* Not a backend display */
+ dmxDump();
+ if (priv->fine) dmxConsoleUpdateFineCursor(priv);
+ }
+}
+
+/** Undo the capture that was done by #dmxConsoleCapture. */
+void dmxConsoleUncapture(DMXInputInfo *dmxInput)
+{
+ int i;
+
+ DMXDBG0("dmxConsoleUncapture\n");
+ dmxSync(NULL, TRUE);
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i];
+ myPrivate *priv = dmxLocal->private;
+ if (dmxLocal->extType != DMX_LOCAL_TYPE_CONSOLE) continue;
+ if (dmxLocal->type != DMX_LOCAL_MOUSE) continue;
+ if (!priv->captured) continue;
+ priv->captured = 0;
+ XSync(priv->display, False); /* Not a backend display */
+ }
+}
diff --git a/xorg-server/hw/dmx/input/dmxinputinit.c b/xorg-server/hw/dmx/input/dmxinputinit.c index c700a1246..2e062ef79 100644 --- a/xorg-server/hw/dmx/input/dmxinputinit.c +++ b/xorg-server/hw/dmx/input/dmxinputinit.c @@ -570,7 +570,7 @@ static void dmxUpdateWindowInformation(DMXInputInfo *dmxInput, int i;
#ifdef PANORAMIX
- if (!noPanoramiXExtension && pWindow && pWindow->parent != WindowTable[0])
+ if (!noPanoramiXExtension && pWindow && pWindow->parent != screenInfo.screens[0]->root)
return;
#endif
#if DMX_WINDOW_DEBUG
@@ -827,7 +827,7 @@ static void dmxPopulateLocal(DMXInputInfo *dmxInput, dmxArg a) }
}
-int dmxInputExtensionErrorHandler(Display *dsp, char *name, char *reason)
+int dmxInputExtensionErrorHandler(Display *dsp, _Xconst char *name, _Xconst char *reason)
{
return 0;
}
@@ -839,7 +839,7 @@ static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI) Display *display;
int num;
int i, j;
- int (*handler)(Display *, char *, char *);
+ XextErrorHandler handler;
if (!(display = XOpenDisplay(dmxInput->name))) return;
@@ -1084,9 +1084,9 @@ static void dmxInputFreeLocal(DMXLocalInputInfoRec *local) if (local->isCore && local->type == DMX_LOCAL_KEYBOARD)
dmxLocalCoreKeyboard = NULL;
if (local->destroy_private) local->destroy_private(local->private);
- if (local->history) free(local->history);
- if (local->valuators) free(local->valuators);
- if (local->deviceName) free(local->deviceName);
+ free(local->history);
+ free(local->valuators);
+ free(local->deviceName);
local->private = NULL;
local->history = NULL;
local->deviceName = NULL;
@@ -1100,9 +1100,9 @@ void dmxInputFree(DMXInputInfo *dmxInput) if (!dmxInput) return;
- if (dmxInput->keycodes) free(dmxInput->keycodes);
- if (dmxInput->symbols) free(dmxInput->symbols);
- if (dmxInput->geometry) free(dmxInput->geometry);
+ free(dmxInput->keycodes);
+ free(dmxInput->symbols);
+ free(dmxInput->geometry);
for (i = 0; i < dmxInput->numDevs; i++) {
dmxInputFreeLocal(dmxInput->devs[i]);
diff --git a/xorg-server/hw/dmx/input/dmxinputinit.h b/xorg-server/hw/dmx/input/dmxinputinit.h index 2e625cfd4..d23ad7a38 100644 --- a/xorg-server/hw/dmx/input/dmxinputinit.h +++ b/xorg-server/hw/dmx/input/dmxinputinit.h @@ -1,291 +1,291 @@ -/* - * Copyright 2002 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Rickard E. (Rik) Faith <faith@redhat.com> - * - */ - -/** \file - * Interface for low-level input support. \see dmxinputinit.c */ - -#ifndef _DMXINPUTINIT_H_ -#define _DMXINPUTINIT_H_ - -#include "dmx.h" -#include "dmxinput.h" -#include "dmxlog.h" - - -#define DMX_LOCAL_DEFAULT_KEYBOARD "kbd" -#define DMX_LOCAL_DEFAULT_POINTER "ps2" -#define DMX_MAX_BUTTONS 256 -#define DMX_MOTION_SIZE 256 -#define DMX_MAX_VALUATORS 32 -#define DMX_MAX_AXES 32 -#define DMX_MAX_XINPUT_EVENT_TYPES 100 -#define DMX_MAP_ENTRIES 16 /* Must be a power of 2 */ -#define DMX_MAP_MASK (DMX_MAP_ENTRIES - 1) - -typedef enum { - DMX_FUNCTION_GRAB, - DMX_FUNCTION_TERMINATE, - DMX_FUNCTION_FINE -} DMXFunctionType; - -typedef enum { - DMX_LOCAL_HIGHLEVEL, - DMX_LOCAL_KEYBOARD, - DMX_LOCAL_MOUSE, - DMX_LOCAL_OTHER -} DMXLocalInputType; - -typedef enum { - DMX_LOCAL_TYPE_LOCAL, - DMX_LOCAL_TYPE_CONSOLE, - DMX_LOCAL_TYPE_BACKEND, - DMX_LOCAL_TYPE_COMMON -} DMXLocalInputExtType; - -typedef enum { - DMX_RELATIVE, - DMX_ABSOLUTE, - DMX_ABSOLUTE_CONFINED -} DMXMotionType; - -/** Stores information from low-level device that is used to initialize - * the device at the dix level. */ -typedef struct _DMXLocalInitInfo { - int keyboard; /**< Non-zero if the device is a keyboard */ - - int keyClass; /**< Non-zero if keys are present */ - KeySymsRec keySyms; /**< Key symbols */ - int freemap; /**< If non-zero, free keySyms.map */ - CARD8 modMap[MAP_LENGTH]; /**< Modifier map */ - XkbDescPtr xkb; /**< XKB description */ - XkbComponentNamesRec names; /**< XKB component names */ - int freenames; /**< Non-zero if names should be free'd */ - int force; /**< Do not allow command line override */ - - int buttonClass; /**< Non-zero if buttons are present */ - int numButtons; /**< Number of buttons */ - unsigned char map[DMX_MAX_BUTTONS]; /**< Button map */ - - int valuatorClass; /**< Non-zero if valuators are - * present */ - int numRelAxes; /**< Number of relative axes */ - int numAbsAxes; /**< Number of absolute axes */ - int minval[DMX_MAX_AXES]; /**< Minimum values */ - int maxval[DMX_MAX_AXES]; /**< Maximum values */ - int res[DMX_MAX_AXES]; /**< Resolution */ - int minres[DMX_MAX_AXES]; /**< Minimum resolutions */ - int maxres[DMX_MAX_AXES]; /**< Maximum resolutions */ - - int focusClass; /**< Non-zero if device can - * cause focus */ - int proximityClass; /**< Non-zero if device - * causes proximity events */ - int kbdFeedbackClass; /**< Non-zero if device has - * keyboard feedback */ - int ptrFeedbackClass; /**< Non-zero if device has - * pointer feedback */ - int ledFeedbackClass; /**< Non-zero if device has - * LED indicators */ - int belFeedbackClass; /**< Non-zero if device has a - * bell */ - int intFeedbackClass; /**< Non-zero if device has - * integer feedback */ - int strFeedbackClass; /**< Non-zero if device has - * string feedback */ - - int maxSymbols; /**< Maximum symbols */ - int maxSymbolsSupported; /**< Maximum symbols supported */ - KeySym *symbols; /**< Key symbols */ -} DMXLocalInitInfo, *DMXLocalInitInfoPtr; - -typedef pointer (*dmxCreatePrivateProcPtr)(DeviceIntPtr); -typedef void (*dmxDestroyPrivateProcPtr)(pointer); - -typedef void (*dmxInitProcPtr)(DevicePtr); -typedef void (*dmxReInitProcPtr)(DevicePtr); -typedef void (*dmxLateReInitProcPtr)(DevicePtr); -typedef void (*dmxGetInfoProcPtr)(DevicePtr, DMXLocalInitInfoPtr); -typedef int (*dmxOnProcPtr)(DevicePtr); -typedef void (*dmxOffProcPtr)(DevicePtr); -typedef void (*dmxUpdatePositionProcPtr)(pointer, int x, int y); - -typedef void (*dmxVTPreSwitchProcPtr)(pointer); /* Turn I/O Off */ -typedef void (*dmxVTPostSwitchProcPtr)(pointer); /* Turn I/O On */ -typedef void (*dmxVTSwitchReturnProcPtr)(pointer); -typedef int (*dmxVTSwitchProcPtr)(pointer, int vt, - dmxVTSwitchReturnProcPtr, pointer); - -typedef void (*dmxMotionProcPtr)(DevicePtr, - int *valuators, - int firstAxis, - int axesCount, - DMXMotionType type, - DMXBlockType block); -typedef void (*dmxEnqueueProcPtr)(DevicePtr, int type, int detail, - KeySym keySym, XEvent *e, - DMXBlockType block); -typedef int (*dmxCheckSpecialProcPtr)(DevicePtr, KeySym keySym); -typedef void (*dmxCollectEventsProcPtr)(DevicePtr, - dmxMotionProcPtr, - dmxEnqueueProcPtr, - dmxCheckSpecialProcPtr, - DMXBlockType); -typedef void (*dmxProcessInputProcPtr)(pointer); -typedef void (*dmxUpdateInfoProcPtr)(pointer, DMXUpdateType, WindowPtr); -typedef int (*dmxFunctionsProcPtr)(pointer, DMXFunctionType); - -typedef void (*dmxKBCtrlProcPtr)(DevicePtr, KeybdCtrl *ctrl); -typedef void (*dmxMCtrlProcPtr)(DevicePtr, PtrCtrl *ctrl); -typedef void (*dmxKBBellProcPtr)(DevicePtr, int percent, - int volume, int pitch, int duration); - -/** Stores a mapping between the device id on the remote X server and - * the id on the DMX server */ -typedef struct _DMXEventMap { - int remote; /**< Event number on remote X server */ - int server; /**< Event number (unbiased) on DMX server */ -} DMXEventMap; - -/** This is the device-independent structure used by the low-level input - * routines. The contents are not exposed to top-level .c files (except - * dmxextensions.c). \see dmxinput.h \see dmxextensions.c */ -typedef struct _DMXLocalInputInfo { - const char *name; /**< Device name */ - DMXLocalInputType type; /**< Device type */ - DMXLocalInputExtType extType; /**< Extended device type */ - int binding; /**< Count of how many consecutive - * structs are bound to the same - * device */ - - /* Low-level (e.g., keyboard/mouse drivers) */ - - dmxCreatePrivateProcPtr create_private; /**< Create - * device-dependent - * private */ - dmxDestroyPrivateProcPtr destroy_private; /**< Destroy - * device-dependent - * private */ - dmxInitProcPtr init; /**< Initialize device */ - dmxReInitProcPtr reinit; /**< Reinitialize device - * (during a - * reconfiguration) */ - dmxLateReInitProcPtr latereinit; /**< Reinitialize a device - * (called very late - * during a - * reconfiguration) */ - dmxGetInfoProcPtr get_info; /**< Get device information */ - dmxOnProcPtr on; /**< Turn device on */ - dmxOffProcPtr off; /**< Turn device off */ - dmxUpdatePositionProcPtr update_position; /**< Called when another - * device updates the - * cursor position */ - dmxVTPreSwitchProcPtr vt_pre_switch; /**< Called before a VT switch */ - dmxVTPostSwitchProcPtr vt_post_switch; /**< Called after a VT switch */ - dmxVTSwitchProcPtr vt_switch; /**< Causes a VT switch */ - - dmxCollectEventsProcPtr collect_events; /**< Collect and enqueue - * events from the - * device*/ - dmxProcessInputProcPtr process_input; /**< Process event (from - * queue) */ - dmxFunctionsProcPtr functions; - dmxUpdateInfoProcPtr update_info; /**< Update window layout - * information */ - - dmxMCtrlProcPtr mCtrl; /**< Pointer control */ - dmxKBCtrlProcPtr kCtrl; /**< Keyboard control */ - dmxKBBellProcPtr kBell; /**< Bell control */ - - pointer private; /**< Device-dependent private */ - int isCore; /**< Is a DMX core device */ - int sendsCore; /**< Sends DMX core events */ - KeybdCtrl kctrl; /**< Keyboard control */ - PtrCtrl mctrl; /**< Pointer control */ - - DeviceIntPtr pDevice; /**< X-level device */ - int inputIdx; /**< High-level index */ - int lastX, lastY; /**< Last known position; - * for XInput in - * dmxevents.c */ - - int head; /**< XInput motion history - * head */ - int tail; /**< XInput motion history - * tail */ - unsigned long *history; /**< XInput motion history */ - int *valuators; /**< Cache of previous values */ - - /* for XInput ChangePointerDevice */ - int (*savedMotionProc)(DeviceIntPtr, - xTimecoord *, - unsigned long, - unsigned long, - ScreenPtr); - int savedMotionEvents; /**< Saved motion events */ - int savedSendsCore; /**< Saved sends-core flag */ - - DMXEventMap map[DMX_MAP_ENTRIES]; /**< XInput device id map */ - int mapOptimize; /**< XInput device id - * map - * optimization */ - - long deviceId; /**< device id on remote side, - * if any */ - const char *deviceName; /**< devive name on remote - * side, if any */ -} DMXLocalInputInfoRec; - -extern DMXLocalInputInfoPtr dmxLocalCorePointer, dmxLocalCoreKeyboard; - -extern void dmxLocalInitInput(DMXInputInfo *dmxInput); -extern DMXLocalInputInfoPtr dmxInputCopyLocal(DMXInputInfo *dmxInput, - DMXLocalInputInfoPtr s); - -extern void dmxChangePointerControl(DeviceIntPtr pDevice, PtrCtrl *ctrl); -extern void dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice, KeybdCtrl *ctrl); -extern void dmxKeyboardBellProc(int percent, DeviceIntPtr pDevice, - pointer ctrl, int unknown); - -extern int dmxInputExtensionErrorHandler(Display *dsp, char *name, - char *reason); - -extern int dmxInputDetach(DMXInputInfo *dmxInput); -extern void dmxInputDetachAll(DMXScreenInfo *dmxScreen); -extern int dmxInputDetachId(int id); -extern DMXInputInfo *dmxInputLocateId(int id); -extern int dmxInputAttachConsole(const char *name, int isCore, - int *id); -extern int dmxInputAttachBackend(int physicalScreen, int isCore, - int *id); - -#endif +/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for low-level input support. \see dmxinputinit.c */
+
+#ifndef _DMXINPUTINIT_H_
+#define _DMXINPUTINIT_H_
+
+#include "dmx.h"
+#include "dmxinput.h"
+#include "dmxlog.h"
+
+
+#define DMX_LOCAL_DEFAULT_KEYBOARD "kbd"
+#define DMX_LOCAL_DEFAULT_POINTER "ps2"
+#define DMX_MAX_BUTTONS 256
+#define DMX_MOTION_SIZE 256
+#define DMX_MAX_VALUATORS 32
+#define DMX_MAX_AXES 32
+#define DMX_MAX_XINPUT_EVENT_TYPES 100
+#define DMX_MAP_ENTRIES 16 /* Must be a power of 2 */
+#define DMX_MAP_MASK (DMX_MAP_ENTRIES - 1)
+
+typedef enum {
+ DMX_FUNCTION_GRAB,
+ DMX_FUNCTION_TERMINATE,
+ DMX_FUNCTION_FINE
+} DMXFunctionType;
+
+typedef enum {
+ DMX_LOCAL_HIGHLEVEL,
+ DMX_LOCAL_KEYBOARD,
+ DMX_LOCAL_MOUSE,
+ DMX_LOCAL_OTHER
+} DMXLocalInputType;
+
+typedef enum {
+ DMX_LOCAL_TYPE_LOCAL,
+ DMX_LOCAL_TYPE_CONSOLE,
+ DMX_LOCAL_TYPE_BACKEND,
+ DMX_LOCAL_TYPE_COMMON
+} DMXLocalInputExtType;
+
+typedef enum {
+ DMX_RELATIVE,
+ DMX_ABSOLUTE,
+ DMX_ABSOLUTE_CONFINED
+} DMXMotionType;
+
+/** Stores information from low-level device that is used to initialize
+ * the device at the dix level. */
+typedef struct _DMXLocalInitInfo {
+ int keyboard; /**< Non-zero if the device is a keyboard */
+
+ int keyClass; /**< Non-zero if keys are present */
+ KeySymsRec keySyms; /**< Key symbols */
+ int freemap; /**< If non-zero, free keySyms.map */
+ CARD8 modMap[MAP_LENGTH]; /**< Modifier map */
+ XkbDescPtr xkb; /**< XKB description */
+ XkbComponentNamesRec names; /**< XKB component names */
+ int freenames; /**< Non-zero if names should be free'd */
+ int force; /**< Do not allow command line override */
+
+ int buttonClass; /**< Non-zero if buttons are present */
+ int numButtons; /**< Number of buttons */
+ unsigned char map[DMX_MAX_BUTTONS]; /**< Button map */
+
+ int valuatorClass; /**< Non-zero if valuators are
+ * present */
+ int numRelAxes; /**< Number of relative axes */
+ int numAbsAxes; /**< Number of absolute axes */
+ int minval[DMX_MAX_AXES]; /**< Minimum values */
+ int maxval[DMX_MAX_AXES]; /**< Maximum values */
+ int res[DMX_MAX_AXES]; /**< Resolution */
+ int minres[DMX_MAX_AXES]; /**< Minimum resolutions */
+ int maxres[DMX_MAX_AXES]; /**< Maximum resolutions */
+
+ int focusClass; /**< Non-zero if device can
+ * cause focus */
+ int proximityClass; /**< Non-zero if device
+ * causes proximity events */
+ int kbdFeedbackClass; /**< Non-zero if device has
+ * keyboard feedback */
+ int ptrFeedbackClass; /**< Non-zero if device has
+ * pointer feedback */
+ int ledFeedbackClass; /**< Non-zero if device has
+ * LED indicators */
+ int belFeedbackClass; /**< Non-zero if device has a
+ * bell */
+ int intFeedbackClass; /**< Non-zero if device has
+ * integer feedback */
+ int strFeedbackClass; /**< Non-zero if device has
+ * string feedback */
+
+ int maxSymbols; /**< Maximum symbols */
+ int maxSymbolsSupported; /**< Maximum symbols supported */
+ KeySym *symbols; /**< Key symbols */
+} DMXLocalInitInfo, *DMXLocalInitInfoPtr;
+
+typedef pointer (*dmxCreatePrivateProcPtr)(DeviceIntPtr);
+typedef void (*dmxDestroyPrivateProcPtr)(pointer);
+
+typedef void (*dmxInitProcPtr)(DevicePtr);
+typedef void (*dmxReInitProcPtr)(DevicePtr);
+typedef void (*dmxLateReInitProcPtr)(DevicePtr);
+typedef void (*dmxGetInfoProcPtr)(DevicePtr, DMXLocalInitInfoPtr);
+typedef int (*dmxOnProcPtr)(DevicePtr);
+typedef void (*dmxOffProcPtr)(DevicePtr);
+typedef void (*dmxUpdatePositionProcPtr)(pointer, int x, int y);
+
+typedef void (*dmxVTPreSwitchProcPtr)(pointer); /* Turn I/O Off */
+typedef void (*dmxVTPostSwitchProcPtr)(pointer); /* Turn I/O On */
+typedef void (*dmxVTSwitchReturnProcPtr)(pointer);
+typedef int (*dmxVTSwitchProcPtr)(pointer, int vt,
+ dmxVTSwitchReturnProcPtr, pointer);
+
+typedef void (*dmxMotionProcPtr)(DevicePtr,
+ int *valuators,
+ int firstAxis,
+ int axesCount,
+ DMXMotionType type,
+ DMXBlockType block);
+typedef void (*dmxEnqueueProcPtr)(DevicePtr, int type, int detail,
+ KeySym keySym, XEvent *e,
+ DMXBlockType block);
+typedef int (*dmxCheckSpecialProcPtr)(DevicePtr, KeySym keySym);
+typedef void (*dmxCollectEventsProcPtr)(DevicePtr,
+ dmxMotionProcPtr,
+ dmxEnqueueProcPtr,
+ dmxCheckSpecialProcPtr,
+ DMXBlockType);
+typedef void (*dmxProcessInputProcPtr)(pointer);
+typedef void (*dmxUpdateInfoProcPtr)(pointer, DMXUpdateType, WindowPtr);
+typedef int (*dmxFunctionsProcPtr)(pointer, DMXFunctionType);
+
+typedef void (*dmxKBCtrlProcPtr)(DevicePtr, KeybdCtrl *ctrl);
+typedef void (*dmxMCtrlProcPtr)(DevicePtr, PtrCtrl *ctrl);
+typedef void (*dmxKBBellProcPtr)(DevicePtr, int percent,
+ int volume, int pitch, int duration);
+
+/** Stores a mapping between the device id on the remote X server and
+ * the id on the DMX server */
+typedef struct _DMXEventMap {
+ int remote; /**< Event number on remote X server */
+ int server; /**< Event number (unbiased) on DMX server */
+} DMXEventMap;
+
+/** This is the device-independent structure used by the low-level input
+ * routines. The contents are not exposed to top-level .c files (except
+ * dmxextensions.c). \see dmxinput.h \see dmxextensions.c */
+typedef struct _DMXLocalInputInfo {
+ const char *name; /**< Device name */
+ DMXLocalInputType type; /**< Device type */
+ DMXLocalInputExtType extType; /**< Extended device type */
+ int binding; /**< Count of how many consecutive
+ * structs are bound to the same
+ * device */
+
+ /* Low-level (e.g., keyboard/mouse drivers) */
+
+ dmxCreatePrivateProcPtr create_private; /**< Create
+ * device-dependent
+ * private */
+ dmxDestroyPrivateProcPtr destroy_private; /**< Destroy
+ * device-dependent
+ * private */
+ dmxInitProcPtr init; /**< Initialize device */
+ dmxReInitProcPtr reinit; /**< Reinitialize device
+ * (during a
+ * reconfiguration) */
+ dmxLateReInitProcPtr latereinit; /**< Reinitialize a device
+ * (called very late
+ * during a
+ * reconfiguration) */
+ dmxGetInfoProcPtr get_info; /**< Get device information */
+ dmxOnProcPtr on; /**< Turn device on */
+ dmxOffProcPtr off; /**< Turn device off */
+ dmxUpdatePositionProcPtr update_position; /**< Called when another
+ * device updates the
+ * cursor position */
+ dmxVTPreSwitchProcPtr vt_pre_switch; /**< Called before a VT switch */
+ dmxVTPostSwitchProcPtr vt_post_switch; /**< Called after a VT switch */
+ dmxVTSwitchProcPtr vt_switch; /**< Causes a VT switch */
+
+ dmxCollectEventsProcPtr collect_events; /**< Collect and enqueue
+ * events from the
+ * device*/
+ dmxProcessInputProcPtr process_input; /**< Process event (from
+ * queue) */
+ dmxFunctionsProcPtr functions;
+ dmxUpdateInfoProcPtr update_info; /**< Update window layout
+ * information */
+
+ dmxMCtrlProcPtr mCtrl; /**< Pointer control */
+ dmxKBCtrlProcPtr kCtrl; /**< Keyboard control */
+ dmxKBBellProcPtr kBell; /**< Bell control */
+
+ pointer private; /**< Device-dependent private */
+ int isCore; /**< Is a DMX core device */
+ int sendsCore; /**< Sends DMX core events */
+ KeybdCtrl kctrl; /**< Keyboard control */
+ PtrCtrl mctrl; /**< Pointer control */
+
+ DeviceIntPtr pDevice; /**< X-level device */
+ int inputIdx; /**< High-level index */
+ int lastX, lastY; /**< Last known position;
+ * for XInput in
+ * dmxevents.c */
+
+ int head; /**< XInput motion history
+ * head */
+ int tail; /**< XInput motion history
+ * tail */
+ unsigned long *history; /**< XInput motion history */
+ int *valuators; /**< Cache of previous values */
+
+ /* for XInput ChangePointerDevice */
+ int (*savedMotionProc)(DeviceIntPtr,
+ xTimecoord *,
+ unsigned long,
+ unsigned long,
+ ScreenPtr);
+ int savedMotionEvents; /**< Saved motion events */
+ int savedSendsCore; /**< Saved sends-core flag */
+
+ DMXEventMap map[DMX_MAP_ENTRIES]; /**< XInput device id map */
+ int mapOptimize; /**< XInput device id
+ * map
+ * optimization */
+
+ long deviceId; /**< device id on remote side,
+ * if any */
+ const char *deviceName; /**< devive name on remote
+ * side, if any */
+} DMXLocalInputInfoRec;
+
+extern DMXLocalInputInfoPtr dmxLocalCorePointer, dmxLocalCoreKeyboard;
+
+extern void dmxLocalInitInput(DMXInputInfo *dmxInput);
+extern DMXLocalInputInfoPtr dmxInputCopyLocal(DMXInputInfo *dmxInput,
+ DMXLocalInputInfoPtr s);
+
+extern void dmxChangePointerControl(DeviceIntPtr pDevice, PtrCtrl *ctrl);
+extern void dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice, KeybdCtrl *ctrl);
+extern void dmxKeyboardBellProc(int percent, DeviceIntPtr pDevice,
+ pointer ctrl, int unknown);
+
+extern int dmxInputExtensionErrorHandler(Display *dsp, _Xconst char *name,
+ _Xconst char *reason);
+
+extern int dmxInputDetach(DMXInputInfo *dmxInput);
+extern void dmxInputDetachAll(DMXScreenInfo *dmxScreen);
+extern int dmxInputDetachId(int id);
+extern DMXInputInfo *dmxInputLocateId(int id);
+extern int dmxInputAttachConsole(const char *name, int isCore,
+ int *id);
+extern int dmxInputAttachBackend(int physicalScreen, int isCore,
+ int *id);
+
+#endif
diff --git a/xorg-server/hw/dmx/input/lnx-keyboard.c b/xorg-server/hw/dmx/input/lnx-keyboard.c index 11f21e25c..269e84435 100644 --- a/xorg-server/hw/dmx/input/lnx-keyboard.c +++ b/xorg-server/hw/dmx/input/lnx-keyboard.c @@ -368,7 +368,7 @@ pointer kbdLinuxCreatePrivate(DeviceIntPtr pKeyboard) /** Destroy a private structure. */
void kbdLinuxDestroyPrivate(pointer priv)
{
- if (priv) free(priv);
+ free(priv);
}
/** Ring the bell.
diff --git a/xorg-server/hw/dmx/input/lnx-ms.c b/xorg-server/hw/dmx/input/lnx-ms.c index 549df46e2..e6d203c4b 100644 --- a/xorg-server/hw/dmx/input/lnx-ms.c +++ b/xorg-server/hw/dmx/input/lnx-ms.c @@ -1,321 +1,321 @@ -/* Portions of this file were derived from the following files: - * - ********************************************************************** - * - * Xserver/hw/kdrive/linux/ms.c - * - * Copyright (c) 2001 by Juliusz Chroboczek - * Copyright (c) 1999 by Keith Packard - * - * 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 AUTHORS OR COPYRIGHT HOLDERS - * 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. - * - */ - -/* - * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Rickard E. (Rik) Faith <faith@redhat.com> - * - */ - -/** \file - * - * This code implements a low-level device driver for a serial MS mouse. - * The code is derived from code by Juliusz Chroboczek and Keith Packard - * (see the source code for complete references). */ - -#ifdef HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#include "inputstr.h" -#include <X11/Xos.h> -#include <errno.h> -#include <termios.h> - -/*****************************************************************************/ -/* Define some macros to make it easier to move this file to another - * part of the Xserver tree. All calls to the dmx* layer are #defined - * here for the .c file. The .h file will also have to be edited. */ -#include "dmxinputinit.h" -#include "lnx-ms.h" - -#define GETPRIV myPrivate *priv \ - = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private - -#define LOG0(f) dmxLog(dmxDebug,f) -#define LOG1(f,a) dmxLog(dmxDebug,f,a) -#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b) -#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c) -#define FATAL0(f) dmxLog(dmxFatal,f) -#define FATAL1(f,a) dmxLog(dmxFatal,f,a) -#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b) -#define MOTIONPROC dmxMotionProcPtr -#define ENQUEUEPROC dmxEnqueueProcPtr -#define CHECKPROC dmxCheckSpecialProcPtr -#define BLOCK DMXBlockType - -/* End of interface definitions. */ -/*****************************************************************************/ - -/* Private area for MS mouse devices. */ -typedef struct _myPrivate { - DeviceIntPtr pMouse; - int fd; - struct termios tty; - enum { - button1 = 0x0001, - button2 = 0x0002, - button3 = 0x0004, - button4 = 0x0008, - button5 = 0x0010 - } buttons; -} myPrivate; - -static int msLinuxReadBytes(int fd, unsigned char *buf, int len, int min) -{ - int n, tot; - fd_set set; - struct timeval tv; - - tot = 0; - while (len) { - n = read(fd, buf, len); - if (n > 0) { - tot += n; - buf += n; - len -= n; - } - if (tot % min == 0) break; - FD_ZERO(&set); - FD_SET(fd, &set); - tv.tv_sec = 0; - tv.tv_usec = 100 * 1000; - n = select(fd + 1, &set, 0, 0, &tv); - if (n <= 0) break; - } - return tot; -} - -static void msLinuxButton(DevicePtr pDev, ENQUEUEPROC enqueue, int buttons, - BLOCK block) -{ - GETPRIV; - -#define PRESS(b) \ - do { \ - enqueue(pDev, ButtonPress, 0, 0, NULL, block); \ - } while (0) - -#define RELEASE(b) \ - do { \ - enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \ - } while (0) - - if ((buttons & button1) && !(priv->buttons & button1)) PRESS(1); - if (!(buttons & button1) && (priv->buttons & button1)) RELEASE(1); - - if ((buttons & button2) && !(priv->buttons & button2)) PRESS(2); - if (!(buttons & button2) && (priv->buttons & button2)) RELEASE(2); - - if ((buttons & button3) && !(priv->buttons & button3)) PRESS(3); - if (!(buttons & button3) && (priv->buttons & button3)) RELEASE(3); - - if ((buttons & button4) && !(priv->buttons & button4)) PRESS(4); - if (!(buttons & button4) && (priv->buttons & button4)) RELEASE(4); - - if ((buttons & button5) && !(priv->buttons & button5)) PRESS(5); - if (!(buttons & button5) && (priv->buttons & button5)) RELEASE(5); - - priv->buttons = buttons; -} - -/** Read an event from the \a pDev device. If the event is a motion - * event, enqueue it with the \a motion function. Otherwise, check for - * special keys with the \a checkspecial function and enqueue the event - * with the \a enqueue function. The \a block type is passed to the - * functions so that they may block SIGIO handling as appropriate to the - * caller of this function. */ -void msLinuxRead(DevicePtr pDev, - MOTIONPROC motion, - ENQUEUEPROC enqueue, - CHECKPROC checkspecial, - BLOCK block) -{ - GETPRIV; - unsigned char buf[3 * 200]; /* RATS: Use ok */ - unsigned char *b; - int n; - int dx, dy, v[2]; - - while ((n = msLinuxReadBytes(priv->fd, buf, sizeof(buf), 3)) > 0) { - b = buf; - while (n >= 3) { - dx = (char)(((b[0] & 0x03) << 6) | (b[1] & 0x3f)); - dy = (char)(((b[0] & 0x0c) << 4) | (b[2] & 0x3f)); - v[0] = -dx; - v[1] = -dy; - - motion(pDev, v, 0, 2, 1, block); - msLinuxButton(pDev, enqueue, (((b[0] & 0x10) ? button3 : 0) - | ((b[0] & 0x20) ? button1 : 0)), - block); - n -= 3; - b += 3; - } - } -} - -/** Initialize \a pDev. */ -void msLinuxInit(DevicePtr pDev) -{ - GETPRIV; - const char *names[] = { "/dev/serialmouse", "/dev/mouse", NULL }; - int i; - - if (priv->fd >=0) return; - - for (i = 0; names[i]; i++) { - if ((priv->fd = open(names[i], O_RDWR | O_NONBLOCK, 0)) >= 0) break; - } - if (priv->fd < 0) - FATAL1("msLinuxInit: Cannot open mouse port (%s)\n", - strerror(errno)); - - if (!isatty(priv->fd)) - FATAL1("msLinuxInit: Mouse port %s is not a tty\n", names[i]); - - if (tcgetattr(priv->fd, &priv->tty) < 0) - FATAL1("msLinuxInit: tcgetattr failed (%s)\n", strerror(errno)); - - write(priv->fd, "*n", 2); /* 1200 baud */ - usleep(100000); -} - -/** Turn \a pDev on (i.e., take input from \a pDev). */ -int msLinuxOn(DevicePtr pDev) -{ - GETPRIV; - struct termios nTty; - - if (priv->fd < 0) msLinuxInit(pDev); - - nTty = priv->tty; - nTty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR - | IGNCR | ICRNL | IXON | IXOFF); - nTty.c_oflag &= ~OPOST; - nTty.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); - nTty.c_cflag &= ~(CSIZE | PARENB); - nTty.c_cflag |= CS8 | CLOCAL | CSTOPB; - nTty.c_cc[VTIME] = 0; - nTty.c_cc[VMIN] = 1; - cfsetispeed (&nTty, B1200); - cfsetospeed (&nTty, B1200); - if (tcsetattr(priv->fd, TCSANOW, &nTty) < 0) - FATAL1("msLinuxInit: tcsetattr failed (%s)\n", strerror(errno)); - write(priv->fd, "*V", 2); /* 2 button 3 byte protocol */ - return priv->fd; -} - -/** Turn \a pDev off (i.e., stop taking input from \a pDev). */ -void msLinuxOff(DevicePtr pDev) -{ - GETPRIV; - - tcsetattr(priv->fd, TCSANOW, &priv->tty); - close(priv->fd); - priv->fd = -1; -} - -static void msLinuxGetMap(DevicePtr pDev, unsigned char *map, int *nButtons) -{ - int i; - - if (nButtons) *nButtons = 3; - if (map) for (i = 0; i <= *nButtons; i++) map[i] = i; -} - -/** Currently unused hook called prior to an VT switch. */ -void msLinuxVTPreSwitch(pointer p) -{ -} - -/** Currently unused hook called after returning from a VT switch. */ -void msLinuxVTPostSwitch(pointer p) -{ -} - -/** Create a private structure for use within this file. */ -pointer msLinuxCreatePrivate(DeviceIntPtr pMouse) -{ - myPrivate *priv = calloc(1, sizeof(*priv)); - priv->fd = -1; - priv->pMouse = pMouse; - return priv; -} - -/** Destroy a private structure. */ -void msLinuxDestroyPrivate(pointer priv) -{ - if (priv) free(priv); -} - -/** Fill the \a info structure with information needed to initialize \a - * pDev. */ -void msLinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info) -{ - info->buttonClass = 1; - msLinuxGetMap(pDev, info->map, &info->numButtons); - info->valuatorClass = 1; - info->numRelAxes = 2; - info->minval[0] = 0; - info->maxval[0] = 0; - info->res[0] = 1; - info->minres[0] = 0; - info->maxres[0] = 1; - info->ptrFeedbackClass = 1; -} +/* Portions of this file were derived from the following files:
+ *
+ **********************************************************************
+ *
+ * Xserver/hw/kdrive/linux/ms.c
+ *
+ * Copyright (c) 2001 by Juliusz Chroboczek
+ * Copyright (c) 1999 by Keith Packard
+ *
+ * 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 AUTHORS OR COPYRIGHT HOLDERS
+ * 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.
+ *
+ */
+
+/*
+ * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This code implements a low-level device driver for a serial MS mouse.
+ * The code is derived from code by Juliusz Chroboczek and Keith Packard
+ * (see the source code for complete references). */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "inputstr.h"
+#include <X11/Xos.h>
+#include <errno.h>
+#include <termios.h>
+
+/*****************************************************************************/
+/* Define some macros to make it easier to move this file to another
+ * part of the Xserver tree. All calls to the dmx* layer are #defined
+ * here for the .c file. The .h file will also have to be edited. */
+#include "dmxinputinit.h"
+#include "lnx-ms.h"
+
+#define GETPRIV myPrivate *priv \
+ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
+
+#define LOG0(f) dmxLog(dmxDebug,f)
+#define LOG1(f,a) dmxLog(dmxDebug,f,a)
+#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define FATAL0(f) dmxLog(dmxFatal,f)
+#define FATAL1(f,a) dmxLog(dmxFatal,f,a)
+#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
+#define MOTIONPROC dmxMotionProcPtr
+#define ENQUEUEPROC dmxEnqueueProcPtr
+#define CHECKPROC dmxCheckSpecialProcPtr
+#define BLOCK DMXBlockType
+
+/* End of interface definitions. */
+/*****************************************************************************/
+
+/* Private area for MS mouse devices. */
+typedef struct _myPrivate {
+ DeviceIntPtr pMouse;
+ int fd;
+ struct termios tty;
+ enum {
+ button1 = 0x0001,
+ button2 = 0x0002,
+ button3 = 0x0004,
+ button4 = 0x0008,
+ button5 = 0x0010
+ } buttons;
+} myPrivate;
+
+static int msLinuxReadBytes(int fd, unsigned char *buf, int len, int min)
+{
+ int n, tot;
+ fd_set set;
+ struct timeval tv;
+
+ tot = 0;
+ while (len) {
+ n = read(fd, buf, len);
+ if (n > 0) {
+ tot += n;
+ buf += n;
+ len -= n;
+ }
+ if (tot % min == 0) break;
+ FD_ZERO(&set);
+ FD_SET(fd, &set);
+ tv.tv_sec = 0;
+ tv.tv_usec = 100 * 1000;
+ n = select(fd + 1, &set, 0, 0, &tv);
+ if (n <= 0) break;
+ }
+ return tot;
+}
+
+static void msLinuxButton(DevicePtr pDev, ENQUEUEPROC enqueue, int buttons,
+ BLOCK block)
+{
+ GETPRIV;
+
+#define PRESS(b) \
+ do { \
+ enqueue(pDev, ButtonPress, 0, 0, NULL, block); \
+ } while (0)
+
+#define RELEASE(b) \
+ do { \
+ enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \
+ } while (0)
+
+ if ((buttons & button1) && !(priv->buttons & button1)) PRESS(1);
+ if (!(buttons & button1) && (priv->buttons & button1)) RELEASE(1);
+
+ if ((buttons & button2) && !(priv->buttons & button2)) PRESS(2);
+ if (!(buttons & button2) && (priv->buttons & button2)) RELEASE(2);
+
+ if ((buttons & button3) && !(priv->buttons & button3)) PRESS(3);
+ if (!(buttons & button3) && (priv->buttons & button3)) RELEASE(3);
+
+ if ((buttons & button4) && !(priv->buttons & button4)) PRESS(4);
+ if (!(buttons & button4) && (priv->buttons & button4)) RELEASE(4);
+
+ if ((buttons & button5) && !(priv->buttons & button5)) PRESS(5);
+ if (!(buttons & button5) && (priv->buttons & button5)) RELEASE(5);
+
+ priv->buttons = buttons;
+}
+
+/** Read an event from the \a pDev device. If the event is a motion
+ * event, enqueue it with the \a motion function. Otherwise, check for
+ * special keys with the \a checkspecial function and enqueue the event
+ * with the \a enqueue function. The \a block type is passed to the
+ * functions so that they may block SIGIO handling as appropriate to the
+ * caller of this function. */
+void msLinuxRead(DevicePtr pDev,
+ MOTIONPROC motion,
+ ENQUEUEPROC enqueue,
+ CHECKPROC checkspecial,
+ BLOCK block)
+{
+ GETPRIV;
+ unsigned char buf[3 * 200]; /* RATS: Use ok */
+ unsigned char *b;
+ int n;
+ int dx, dy, v[2];
+
+ while ((n = msLinuxReadBytes(priv->fd, buf, sizeof(buf), 3)) > 0) {
+ b = buf;
+ while (n >= 3) {
+ dx = (char)(((b[0] & 0x03) << 6) | (b[1] & 0x3f));
+ dy = (char)(((b[0] & 0x0c) << 4) | (b[2] & 0x3f));
+ v[0] = -dx;
+ v[1] = -dy;
+
+ motion(pDev, v, 0, 2, 1, block);
+ msLinuxButton(pDev, enqueue, (((b[0] & 0x10) ? button3 : 0)
+ | ((b[0] & 0x20) ? button1 : 0)),
+ block);
+ n -= 3;
+ b += 3;
+ }
+ }
+}
+
+/** Initialize \a pDev. */
+void msLinuxInit(DevicePtr pDev)
+{
+ GETPRIV;
+ const char *names[] = { "/dev/serialmouse", "/dev/mouse", NULL };
+ int i;
+
+ if (priv->fd >=0) return;
+
+ for (i = 0; names[i]; i++) {
+ if ((priv->fd = open(names[i], O_RDWR | O_NONBLOCK, 0)) >= 0) break;
+ }
+ if (priv->fd < 0)
+ FATAL1("msLinuxInit: Cannot open mouse port (%s)\n",
+ strerror(errno));
+
+ if (!isatty(priv->fd))
+ FATAL1("msLinuxInit: Mouse port %s is not a tty\n", names[i]);
+
+ if (tcgetattr(priv->fd, &priv->tty) < 0)
+ FATAL1("msLinuxInit: tcgetattr failed (%s)\n", strerror(errno));
+
+ write(priv->fd, "*n", 2); /* 1200 baud */
+ usleep(100000);
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int msLinuxOn(DevicePtr pDev)
+{
+ GETPRIV;
+ struct termios nTty;
+
+ if (priv->fd < 0) msLinuxInit(pDev);
+
+ nTty = priv->tty;
+ nTty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR
+ | IGNCR | ICRNL | IXON | IXOFF);
+ nTty.c_oflag &= ~OPOST;
+ nTty.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
+ nTty.c_cflag &= ~(CSIZE | PARENB);
+ nTty.c_cflag |= CS8 | CLOCAL | CSTOPB;
+ nTty.c_cc[VTIME] = 0;
+ nTty.c_cc[VMIN] = 1;
+ cfsetispeed (&nTty, B1200);
+ cfsetospeed (&nTty, B1200);
+ if (tcsetattr(priv->fd, TCSANOW, &nTty) < 0)
+ FATAL1("msLinuxInit: tcsetattr failed (%s)\n", strerror(errno));
+ write(priv->fd, "*V", 2); /* 2 button 3 byte protocol */
+ return priv->fd;
+}
+
+/** Turn \a pDev off (i.e., stop taking input from \a pDev). */
+void msLinuxOff(DevicePtr pDev)
+{
+ GETPRIV;
+
+ tcsetattr(priv->fd, TCSANOW, &priv->tty);
+ close(priv->fd);
+ priv->fd = -1;
+}
+
+static void msLinuxGetMap(DevicePtr pDev, unsigned char *map, int *nButtons)
+{
+ int i;
+
+ if (nButtons) *nButtons = 3;
+ if (map) for (i = 0; i <= *nButtons; i++) map[i] = i;
+}
+
+/** Currently unused hook called prior to an VT switch. */
+void msLinuxVTPreSwitch(pointer p)
+{
+}
+
+/** Currently unused hook called after returning from a VT switch. */
+void msLinuxVTPostSwitch(pointer p)
+{
+}
+
+/** Create a private structure for use within this file. */
+pointer msLinuxCreatePrivate(DeviceIntPtr pMouse)
+{
+ myPrivate *priv = calloc(1, sizeof(*priv));
+ priv->fd = -1;
+ priv->pMouse = pMouse;
+ return priv;
+}
+
+/** Destroy a private structure. */
+void msLinuxDestroyPrivate(pointer priv)
+{
+ free(priv);
+}
+
+/** Fill the \a info structure with information needed to initialize \a
+ * pDev. */
+void msLinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ info->buttonClass = 1;
+ msLinuxGetMap(pDev, info->map, &info->numButtons);
+ info->valuatorClass = 1;
+ info->numRelAxes = 2;
+ info->minval[0] = 0;
+ info->maxval[0] = 0;
+ info->res[0] = 1;
+ info->minres[0] = 0;
+ info->maxres[0] = 1;
+ info->ptrFeedbackClass = 1;
+}
diff --git a/xorg-server/hw/dmx/input/lnx-ps2.c b/xorg-server/hw/dmx/input/lnx-ps2.c index 70918eef4..f40441fe7 100644 --- a/xorg-server/hw/dmx/input/lnx-ps2.c +++ b/xorg-server/hw/dmx/input/lnx-ps2.c @@ -1,289 +1,289 @@ -/* Portions of this file were derived from the following files: - * - ********************************************************************** - * - * Xserver/hw/kdrive/linux/ps2.c - * - * Copyright (c) 1999 by Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ - -/* - * Copyright 2001,2003 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Rickard E. (Rik) Faith <faith@redhat.com> - * - */ - -/** \file - * - * This code implements a low-level device driver for a serial MS mouse. - * The code is derived from code by Keith Packard (see the source code - * for complete references). */ - -#ifdef HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#include "inputstr.h" -#include <X11/Xos.h> -#include <errno.h> -#include <termios.h> - -/*****************************************************************************/ -/* Define some macros to make it easier to move this file to another - * part of the Xserver tree. All calls to the dmx* layer are #defined - * here for the .c file. The .h file will also have to be edited. */ -#include "dmxinputinit.h" -#include "lnx-ps2.h" - -#define GETPRIV myPrivate *priv \ - = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private - -#define LOG0(f) dmxLog(dmxDebug,f) -#define LOG1(f,a) dmxLog(dmxDebug,f,a) -#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b) -#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c) -#define FATAL0(f) dmxLog(dmxFatal,f) -#define FATAL1(f,a) dmxLog(dmxFatal,f,a) -#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b) -#define MOTIONPROC dmxMotionProcPtr -#define ENQUEUEPROC dmxEnqueueProcPtr -#define CHECKPROC dmxCheckSpecialProcPtr -#define BLOCK DMXBlockType - -/* End of interface definitions. */ -/*****************************************************************************/ - -/* Private area for PS/2 devices. */ -typedef struct _myPrivate { - DeviceIntPtr pMouse; - int fd; - enum { - button1 = 0x0001, - button2 = 0x0002, - button3 = 0x0004, - button4 = 0x0008, - button5 = 0x0010 - } buttons; -} myPrivate; - -static int ps2LinuxReadBytes(int fd, unsigned char *buf, int len, int min) -{ - int n, tot; - fd_set set; - struct timeval tv; - - tot = 0; - while (len) { - n = read(fd, buf, len); - if (n > 0) { - tot += n; - buf += n; - len -= n; - } - if (tot % min == 0) break; - FD_ZERO(&set); - FD_SET(fd, &set); - tv.tv_sec = 0; - tv.tv_usec = 100 * 1000; - n = select(fd + 1, &set, 0, 0, &tv); - if (n <= 0) break; - } - return tot; -} - -static void ps2LinuxButton(DevicePtr pDev, ENQUEUEPROC enqueue, - int buttons, BLOCK block) -{ - GETPRIV; - -#define PRESS(b) \ - do { \ - enqueue(pDev, ButtonPress, 0, 0, NULL, block); \ - } while (0) - -#define RELEASE(b) \ - do { \ - enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \ - } while (0) - - if ((buttons & button1) && !(priv->buttons & button1)) PRESS(1); - if (!(buttons & button1) && (priv->buttons & button1)) RELEASE(1); - - if ((buttons & button2) && !(priv->buttons & button2)) PRESS(2); - if (!(buttons & button2) && (priv->buttons & button2)) RELEASE(2); - - if ((buttons & button3) && !(priv->buttons & button3)) PRESS(3); - if (!(buttons & button3) && (priv->buttons & button3)) RELEASE(3); - - if ((buttons & button4) && !(priv->buttons & button4)) PRESS(4); - if (!(buttons & button4) && (priv->buttons & button4)) RELEASE(4); - - if ((buttons & button5) && !(priv->buttons & button5)) PRESS(5); - if (!(buttons & button5) && (priv->buttons & button5)) RELEASE(5); - - priv->buttons = buttons; -} - -/** Read an event from the \a pDev device. If the event is a motion - * event, enqueue it with the \a motion function. Otherwise, check for - * special keys with the \a checkspecial function and enqueue the event - * with the \a enqueue function. The \a block type is passed to the - * functions so that they may block SIGIO handling as appropriate to the - * caller of this function. */ -void ps2LinuxRead(DevicePtr pDev, MOTIONPROC motion, - ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block) -{ - GETPRIV; - unsigned char buf[3 * 200]; /* RATS: Use ok */ - unsigned char *b; - int n; - int dx, dy, v[2]; - - while ((n = ps2LinuxReadBytes(priv->fd, buf, sizeof(buf), 3)) > 0) { - b = buf; - while (n >= 3) { - dx = b[1] - ((b[0] & 0x10) ? 256 : 0); - dy = -b[2] + ((b[0] & 0x20) ? 256 : 0); - v[0] = -dx; - v[1] = -dy; - - motion(pDev, v, 0, 2, 1, block); - ps2LinuxButton(pDev, enqueue, (((b[0] & 4) ? button2 : 0) - | ((b[0] & 2) ? button3 : 0) - | ((b[0] & 1) ? button1 : 0)), - block); - n -= 3; - b += 3; - } - } -} - -/** Initialize \a pDev. */ -void ps2LinuxInit(DevicePtr pDev) -{ - GETPRIV; - const char *names[] = { "/dev/mouse", "/dev/psaux", NULL }; - int i; - - if (priv->fd >=0) return; - - for (i = 0; names[i]; i++) { - if ((priv->fd = open(names[i], O_RDWR | O_NONBLOCK, 0)) >= 0) break; - } - if (priv->fd < 0) - FATAL1("ps2LinuxInit: Cannot open mouse port (%s)\n", - strerror(errno)); -} - -/** Turn \a pDev on (i.e., take input from \a pDev). */ -int ps2LinuxOn(DevicePtr pDev) -{ - GETPRIV; - - if (priv->fd < 0) ps2LinuxInit(pDev); - return priv->fd; -} - -/** Turn \a pDev off (i.e., stop taking input from \a pDev). */ -void ps2LinuxOff(DevicePtr pDev) -{ - GETPRIV; - - close(priv->fd); - priv->fd = -1; -} - -static void ps2LinuxGetMap(DevicePtr pDev, unsigned char *map, int *nButtons) -{ - int i; - - if (nButtons) *nButtons = 3; - if (map) for (i = 0; i <= *nButtons; i++) map[i] = i; -} - -/** Currently unused hook called prior to an VT switch. */ -void ps2LinuxVTPreSwitch(pointer p) -{ -} - -/** Currently unused hook called after returning from a VT switch. */ -void ps2LinuxVTPostSwitch(pointer p) -{ -} - -/** Create a private structure for use within this file. */ -pointer ps2LinuxCreatePrivate(DeviceIntPtr pMouse) -{ - myPrivate *priv = calloc(1, sizeof(*priv)); - priv->fd = -1; - priv->pMouse = pMouse; - return priv; -} - -/** Destroy a private structure. */ -void ps2LinuxDestroyPrivate(pointer priv) -{ - if (priv) free(priv); -} - -/** Fill the \a info structure with information needed to initialize \a - * pDev. */ -void ps2LinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info) -{ - info->buttonClass = 1; - ps2LinuxGetMap(pDev, info->map, &info->numButtons); - info->valuatorClass = 1; - info->numRelAxes = 2; - info->minval[0] = 0; - info->maxval[0] = 0; - info->res[0] = 1; - info->minres[0] = 0; - info->maxres[0] = 1; - info->ptrFeedbackClass = 1; -} +/* Portions of this file were derived from the following files:
+ *
+ **********************************************************************
+ *
+ * Xserver/hw/kdrive/linux/ps2.c
+ *
+ * Copyright (c) 1999 by Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * Copyright 2001,2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This code implements a low-level device driver for a serial MS mouse.
+ * The code is derived from code by Keith Packard (see the source code
+ * for complete references). */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "inputstr.h"
+#include <X11/Xos.h>
+#include <errno.h>
+#include <termios.h>
+
+/*****************************************************************************/
+/* Define some macros to make it easier to move this file to another
+ * part of the Xserver tree. All calls to the dmx* layer are #defined
+ * here for the .c file. The .h file will also have to be edited. */
+#include "dmxinputinit.h"
+#include "lnx-ps2.h"
+
+#define GETPRIV myPrivate *priv \
+ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
+
+#define LOG0(f) dmxLog(dmxDebug,f)
+#define LOG1(f,a) dmxLog(dmxDebug,f,a)
+#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define FATAL0(f) dmxLog(dmxFatal,f)
+#define FATAL1(f,a) dmxLog(dmxFatal,f,a)
+#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
+#define MOTIONPROC dmxMotionProcPtr
+#define ENQUEUEPROC dmxEnqueueProcPtr
+#define CHECKPROC dmxCheckSpecialProcPtr
+#define BLOCK DMXBlockType
+
+/* End of interface definitions. */
+/*****************************************************************************/
+
+/* Private area for PS/2 devices. */
+typedef struct _myPrivate {
+ DeviceIntPtr pMouse;
+ int fd;
+ enum {
+ button1 = 0x0001,
+ button2 = 0x0002,
+ button3 = 0x0004,
+ button4 = 0x0008,
+ button5 = 0x0010
+ } buttons;
+} myPrivate;
+
+static int ps2LinuxReadBytes(int fd, unsigned char *buf, int len, int min)
+{
+ int n, tot;
+ fd_set set;
+ struct timeval tv;
+
+ tot = 0;
+ while (len) {
+ n = read(fd, buf, len);
+ if (n > 0) {
+ tot += n;
+ buf += n;
+ len -= n;
+ }
+ if (tot % min == 0) break;
+ FD_ZERO(&set);
+ FD_SET(fd, &set);
+ tv.tv_sec = 0;
+ tv.tv_usec = 100 * 1000;
+ n = select(fd + 1, &set, 0, 0, &tv);
+ if (n <= 0) break;
+ }
+ return tot;
+}
+
+static void ps2LinuxButton(DevicePtr pDev, ENQUEUEPROC enqueue,
+ int buttons, BLOCK block)
+{
+ GETPRIV;
+
+#define PRESS(b) \
+ do { \
+ enqueue(pDev, ButtonPress, 0, 0, NULL, block); \
+ } while (0)
+
+#define RELEASE(b) \
+ do { \
+ enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \
+ } while (0)
+
+ if ((buttons & button1) && !(priv->buttons & button1)) PRESS(1);
+ if (!(buttons & button1) && (priv->buttons & button1)) RELEASE(1);
+
+ if ((buttons & button2) && !(priv->buttons & button2)) PRESS(2);
+ if (!(buttons & button2) && (priv->buttons & button2)) RELEASE(2);
+
+ if ((buttons & button3) && !(priv->buttons & button3)) PRESS(3);
+ if (!(buttons & button3) && (priv->buttons & button3)) RELEASE(3);
+
+ if ((buttons & button4) && !(priv->buttons & button4)) PRESS(4);
+ if (!(buttons & button4) && (priv->buttons & button4)) RELEASE(4);
+
+ if ((buttons & button5) && !(priv->buttons & button5)) PRESS(5);
+ if (!(buttons & button5) && (priv->buttons & button5)) RELEASE(5);
+
+ priv->buttons = buttons;
+}
+
+/** Read an event from the \a pDev device. If the event is a motion
+ * event, enqueue it with the \a motion function. Otherwise, check for
+ * special keys with the \a checkspecial function and enqueue the event
+ * with the \a enqueue function. The \a block type is passed to the
+ * functions so that they may block SIGIO handling as appropriate to the
+ * caller of this function. */
+void ps2LinuxRead(DevicePtr pDev, MOTIONPROC motion,
+ ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)
+{
+ GETPRIV;
+ unsigned char buf[3 * 200]; /* RATS: Use ok */
+ unsigned char *b;
+ int n;
+ int dx, dy, v[2];
+
+ while ((n = ps2LinuxReadBytes(priv->fd, buf, sizeof(buf), 3)) > 0) {
+ b = buf;
+ while (n >= 3) {
+ dx = b[1] - ((b[0] & 0x10) ? 256 : 0);
+ dy = -b[2] + ((b[0] & 0x20) ? 256 : 0);
+ v[0] = -dx;
+ v[1] = -dy;
+
+ motion(pDev, v, 0, 2, 1, block);
+ ps2LinuxButton(pDev, enqueue, (((b[0] & 4) ? button2 : 0)
+ | ((b[0] & 2) ? button3 : 0)
+ | ((b[0] & 1) ? button1 : 0)),
+ block);
+ n -= 3;
+ b += 3;
+ }
+ }
+}
+
+/** Initialize \a pDev. */
+void ps2LinuxInit(DevicePtr pDev)
+{
+ GETPRIV;
+ const char *names[] = { "/dev/mouse", "/dev/psaux", NULL };
+ int i;
+
+ if (priv->fd >=0) return;
+
+ for (i = 0; names[i]; i++) {
+ if ((priv->fd = open(names[i], O_RDWR | O_NONBLOCK, 0)) >= 0) break;
+ }
+ if (priv->fd < 0)
+ FATAL1("ps2LinuxInit: Cannot open mouse port (%s)\n",
+ strerror(errno));
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int ps2LinuxOn(DevicePtr pDev)
+{
+ GETPRIV;
+
+ if (priv->fd < 0) ps2LinuxInit(pDev);
+ return priv->fd;
+}
+
+/** Turn \a pDev off (i.e., stop taking input from \a pDev). */
+void ps2LinuxOff(DevicePtr pDev)
+{
+ GETPRIV;
+
+ close(priv->fd);
+ priv->fd = -1;
+}
+
+static void ps2LinuxGetMap(DevicePtr pDev, unsigned char *map, int *nButtons)
+{
+ int i;
+
+ if (nButtons) *nButtons = 3;
+ if (map) for (i = 0; i <= *nButtons; i++) map[i] = i;
+}
+
+/** Currently unused hook called prior to an VT switch. */
+void ps2LinuxVTPreSwitch(pointer p)
+{
+}
+
+/** Currently unused hook called after returning from a VT switch. */
+void ps2LinuxVTPostSwitch(pointer p)
+{
+}
+
+/** Create a private structure for use within this file. */
+pointer ps2LinuxCreatePrivate(DeviceIntPtr pMouse)
+{
+ myPrivate *priv = calloc(1, sizeof(*priv));
+ priv->fd = -1;
+ priv->pMouse = pMouse;
+ return priv;
+}
+
+/** Destroy a private structure. */
+void ps2LinuxDestroyPrivate(pointer priv)
+{
+ free(priv);
+}
+
+/** Fill the \a info structure with information needed to initialize \a
+ * pDev. */
+void ps2LinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ info->buttonClass = 1;
+ ps2LinuxGetMap(pDev, info->map, &info->numButtons);
+ info->valuatorClass = 1;
+ info->numRelAxes = 2;
+ info->minval[0] = 0;
+ info->maxval[0] = 0;
+ info->res[0] = 1;
+ info->minres[0] = 0;
+ info->maxres[0] = 1;
+ info->ptrFeedbackClass = 1;
+}
diff --git a/xorg-server/hw/dmx/input/usb-common.c b/xorg-server/hw/dmx/input/usb-common.c index 95c00b839..c655a2984 100644 --- a/xorg-server/hw/dmx/input/usb-common.c +++ b/xorg-server/hw/dmx/input/usb-common.c @@ -1,381 +1,381 @@ -/* - * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina. - * - * 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 on 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 (including the - * next paragraph) 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 - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * 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. - */ - -/* - * Authors: - * Rickard E. (Rik) Faith <faith@redhat.com> - * - */ - -/** \file - * - * Routines that are common between \a usb-keyboard.c, \a usb-mouse.c, and - * \a usb-other.c */ - -#ifdef HAVE_DMX_CONFIG_H -#include <dmx-config.h> -#endif - -#include "usb-private.h" - -#define USB_COMMON_DEBUG 1 - -/*****************************************************************************/ -/* Define some macros to make it easier to move this file to another - * part of the Xserver tree. All calls to the dmx* layer are #defined - * here for the .c file. The .h file will also have to be edited. */ -#include "usb-mouse.h" - -#define GETPRIV myPrivate *priv \ - = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private - -#define GETNAME ((DMXLocalInputInfoPtr)(pDevice->public.devicePrivate)) \ - ->name - -#define LOG0(f) dmxLog(dmxDebug,f) -#define LOG1(f,a) dmxLog(dmxDebug,f,a) -#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b) -#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c) -#define LOG1INPUT(p,f,a) dmxLogInput(p->dmxInput,f,a) -#define LOG3INPUT(p,f,a,b,c) dmxLogInput(p->dmxInput,f,a,b,c) -#define LOG5INPUT(p,f,a,b,c,d,e) dmxLogInput(p->dmxInput,f,a,b,c,d,e) -#define FATAL0(f) dmxLog(dmxFatal,f) -#define FATAL1(f,a) dmxLog(dmxFatal,f,a) -#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b) -#define MOTIONPROC dmxMotionProcPtr -#define ENQUEUEPROC dmxEnqueueProcPtr -#define CHECKPROC dmxCheckSpecialProcPtr -#define BLOCK DMXBlockType - -/* End of interface definitions. */ -/*****************************************************************************/ - - -/** Read an event from the \a pDev device. If the event is a motion - * event, enqueue it with the \a motion function. Otherwise, enqueue - * the event with the \a enqueue function. The \a block type is passed - * to the functions so that they may block SIGIO handling as appropriate - * to the caller of this function. - * - * Since USB devices return EV_KEY events for buttons and keys, \a - * minButton is used to decide if a Button or Key event should be - * queued.*/ -void usbRead(DevicePtr pDev, - MOTIONPROC motion, - ENQUEUEPROC enqueue, - int minButton, - BLOCK block) -{ - GETPRIV; - struct input_event raw; - int v[DMX_MAX_AXES]; - int axis; - -#define PRESS(b) \ - do { \ - enqueue(pDev, ButtonPress, 0, 0, NULL, block); \ - } while (0) - -#define RELEASE(b) \ - do { \ - enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \ - } while (0) - - while (read(priv->fd, &raw, sizeof(raw)) > 0) { -#if USB_COMMON_DEBUG > 1 - LOG3("USB: type = %d, code = 0x%02x, value = %d\n", - raw.type, raw.code, raw.value); -#endif - switch (raw.type) { - case EV_KEY: - /* raw.value = 1 for first, 2 for repeat */ - if (raw.code > minButton) { - if (raw.value) PRESS((raw.code & 0x0f) + 1); - else RELEASE((raw.code & 0x0f) + 1); - } else { - enqueue(pDev, raw.value ? KeyPress : KeyRelease, - 0, 0, NULL, block); - } - break; - case EV_REL: - switch (raw.code) { - case REL_X: - v[0] = -raw.value; - v[1] = 0; - motion(pDev, v, 0, 2, DMX_RELATIVE, block); - break; - case REL_Y: - v[0] = 0; - v[1] = -raw.value; - motion(pDev, v, 0, 2, DMX_RELATIVE, block); - break; - case REL_WHEEL: - if ((int)raw.value > 0) { - PRESS(4); - RELEASE(4); - } else if ((int)raw.value < 0) { - PRESS(5); - RELEASE(5); - } - break; - default: - memset(v, 0, sizeof(v)); - axis = priv->relmap[raw.code]; - v[axis] = raw.value; - motion(pDev, v, axis, 1, DMX_RELATIVE, block); - } - break; - case EV_ABS: - memset(v, 0, sizeof(v)); - axis = priv->absmap[raw.code]; - v[axis] = raw.value; - motion(pDev, v, axis, 1, DMX_ABSOLUTE, block); - break; - } - } -} - -#define test_bit(bit) (priv->mask[(bit)/8] & (1 << ((bit)%8))) -#define test_bits(bit) (bits[(bit)/8] & (1 << ((bit)%8))) - -static void usbPrint(myPrivate *priv, - const char *filename, const char *devname, int fd) -{ - int j, k; - DeviceIntPtr pDevice = priv->pDevice; - unsigned char bits[KEY_MAX/8 + 1]; /* RATS: Use ok assuming that - * KEY_MAX is greater than - * REL_MAX, ABS_MAX, SND_MAX, and - * LED_MAX. */ - - LOG3INPUT(priv, "%s (%s) using %s\n", pDevice->name, GETNAME, filename); - LOG1INPUT(priv, " %s\n", devname); - for (j = 0; j < EV_MAX; j++) { - if (test_bit(j)) { - const char *type = "unknown"; - char extra[256]; /* FIXME: may cause buffer overflow */ - extra[0] = '\0'; - switch(j) { - case EV_KEY: type = "keys/buttons"; break; - case EV_REL: type = "relative"; - memset(bits, 0, sizeof(bits)); - ioctl(priv->fd, EVIOCGBIT(EV_REL, sizeof(bits)), bits); - for (k = 0; k < REL_MAX; k++) { - if (test_bits(k)) switch (k) { - case REL_X: strcat(extra, " X"); break; - case REL_Y: strcat(extra, " Y"); break; - case REL_Z: strcat(extra, " Z"); break; - case REL_HWHEEL: strcat(extra, " HWheel"); break; - case REL_DIAL: strcat(extra, " Dial"); break; - case REL_WHEEL: strcat(extra, " Wheel"); break; - case REL_MISC: strcat(extra, " Misc"); break; - } - } - break; - case EV_ABS: type = "absolute"; - memset(bits, 0, sizeof(bits)); - ioctl(priv->fd, EVIOCGBIT(EV_ABS, sizeof(bits)), bits); - for (k = 0; k < ABS_MAX; k++) { - if (test_bits(k)) switch (k) { - case ABS_X: strcat(extra," X"); break; - case ABS_Y: strcat(extra," Y"); break; - case ABS_Z: strcat(extra," Z"); break; - case ABS_RX: strcat(extra," RX"); break; - case ABS_RY: strcat(extra," RY"); break; - case ABS_RZ: strcat(extra," RZ"); break; - case ABS_THROTTLE: strcat(extra," Throttle");break; - case ABS_RUDDER: strcat(extra," Rudder"); break; - case ABS_WHEEL: strcat(extra," Wheel"); break; - case ABS_GAS: strcat(extra," Gas"); break; - case ABS_BRAKE: strcat(extra," Break"); break; - case ABS_HAT0X: strcat(extra," Hat0X"); break; - case ABS_HAT0Y: strcat(extra," Hat0Y"); break; - case ABS_HAT1X: strcat(extra," Hat1X"); break; - case ABS_HAT1Y: strcat(extra," Hat1Y"); break; - case ABS_HAT2X: strcat(extra," Hat2X"); break; - case ABS_HAT2Y: strcat(extra," Hat2Y"); break; - case ABS_HAT3X: strcat(extra," Hat3X"); break; - case ABS_HAT3Y: strcat(extra," Hat3Y"); break; - case ABS_PRESSURE: strcat(extra," Pressure");break; - case ABS_DISTANCE: strcat(extra," Distance");break; - case ABS_TILT_X: strcat(extra," TiltX"); break; - case ABS_TILT_Y: strcat(extra," TiltY"); break; - case ABS_MISC: strcat(extra," Misc"); break; - } - } - break; - case EV_MSC: type = "reserved"; break; - case EV_LED: type = "leds"; - memset(bits, 0, sizeof(bits)); - ioctl(priv->fd, EVIOCGBIT(EV_LED, sizeof(bits)), bits); - for (k = 0; k < LED_MAX; k++) { - if (test_bits(k)) switch (k) { - case LED_NUML: strcat(extra," NumLock"); break; - case LED_CAPSL: strcat(extra," CapsLock"); break; - case LED_SCROLLL: strcat(extra," ScrlLock"); break; - case LED_COMPOSE: strcat(extra," Compose"); break; - case LED_KANA: strcat(extra," Kana"); break; - case LED_SLEEP: strcat(extra," Sleep"); break; - case LED_SUSPEND: strcat(extra," Suspend"); break; - case LED_MUTE: strcat(extra," Mute"); break; - case LED_MISC: strcat(extra," Misc"); break; - } - } - break; - case EV_SND: type = "sound"; - memset(bits, 0, sizeof(bits)); - ioctl(priv->fd, EVIOCGBIT(EV_SND, sizeof(bits)), bits); - for (k = 0; k < SND_MAX; k++) { - if (test_bits(k)) switch (k) { - case SND_CLICK: strcat(extra," Click"); break; - case SND_BELL: strcat(extra," Bell"); break; - } - } - break; - case EV_REP: type = "repeat"; break; - case EV_FF: type = "feedback"; break; - } - LOG5INPUT(priv, " Feature 0x%02x = %s%s%s%s\n", j, type, - extra[0] ? " [" : "", - extra[0] ? extra+1 : "", - extra[0] ? "]" : ""); - } - } -} - -/** Initialized \a pDev as a \a usbMouse, \a usbKeyboard, or \a usbOther -device. */ -void usbInit(DevicePtr pDev, usbType type) -{ - GETPRIV; - char name[64]; /* RATS: Only used in XmuSnprintf */ - int i, j, k; - char buf[256] = { 0, }; /* RATS: Use ok */ - int version; - unsigned char bits[KEY_MAX/8 + 1]; /* RATS: Use ok assuming that - * KEY_MAX is greater than - * REL_MAX, ABS_MAX, SND_MAX, and - * LED_MAX. */ - - if (priv->fd >=0) return; - - for (i = 0; i < 32; i++) { - XmuSnprintf(name, sizeof(name), "/dev/input/event%d", i); - if ((priv->fd = open(name, O_RDWR | O_NONBLOCK, 0)) >= 0) { - ioctl(priv->fd, EVIOCGVERSION, &version); - ioctl(priv->fd, EVIOCGNAME(sizeof(buf)), buf); - memset(priv->mask, 0, sizeof(priv->mask)); - ioctl(priv->fd, EVIOCGBIT(0, sizeof(priv->mask)), priv->mask); - - for (j = 0; j < EV_MAX; j++) { - if (test_bit(j)) { - switch(j) { - case EV_REL: - memset(bits, 0, sizeof(bits)); - ioctl(priv->fd, EVIOCGBIT(EV_REL, sizeof(bits)), bits); - for (k = 0; k < REL_MAX; k++) { - if (test_bits(k)) { - if (k == REL_X) priv->relmap[k] = 0; - else if (k == REL_Y) priv->relmap[k] = 1; - else priv->relmap[k] = 2 + priv->numAbs; - ++priv->numRel; - } - } - break; - case EV_ABS: - memset(bits, 0, sizeof(bits)); - ioctl(priv->fd, EVIOCGBIT(EV_ABS, sizeof(bits)), bits); - for (k = 0; k < ABS_MAX; k++) { - if (test_bits(k)) { - priv->absmap[k] = priv->numAbs; - ++priv->numAbs; - } - } - break; - case EV_LED: - memset(bits, 0, sizeof(bits)); - ioctl(priv->fd, EVIOCGBIT(EV_LED, sizeof(bits)), bits); - for (k = 0; k < LED_MAX; k++) { - if (test_bits(k)) ++priv->numLeds; - } - break; - } - } - } - switch (type) { - case usbMouse: - if (test_bit(EV_REL) && test_bit(EV_KEY)) - goto found; - break; - case usbKeyboard: - if (test_bit(EV_KEY) && test_bit(EV_LED) && !test_bit(EV_ABS)) - goto found; - break; - case usbOther: - if (!(test_bit(EV_REL) && test_bit(EV_KEY)) - && !(test_bit(EV_KEY) && test_bit(EV_LED) - && !test_bit(EV_ABS))) - goto found; - break; - } - close(priv->fd); - priv->fd = -1; - } - } - if (priv->fd < 0) - FATAL1("usbInit: Cannot open /dev/input/event* port (%s)\n" - " If you have not done so, you may need to:\n" - " rmmod mousedev; rmmod keybdev\n" - " modprobe evdev\n", - strerror(errno)); - found: - usbPrint(priv, name, buf, priv->fd); -} - -/** Turn \a pDev off (i.e., stop taking input from \a pDev). */ -void usbOff(DevicePtr pDev) -{ - GETPRIV; - - if (priv->fd >= 0) close(priv->fd); - priv->fd = -1; -} - -/** Create a private structure for use within this file. */ -pointer usbCreatePrivate(DeviceIntPtr pDevice) -{ - myPrivate *priv = calloc(1, sizeof(*priv)); - priv->fd = -1; - priv->pDevice = pDevice; - return priv; -} - -/** Destroy a private structure. */ -void usbDestroyPrivate(pointer priv) -{ - if (priv) free(priv); -} +/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * 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 on 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 (including the
+ * next paragraph) 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * Routines that are common between \a usb-keyboard.c, \a usb-mouse.c, and
+ * \a usb-other.c */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "usb-private.h"
+
+#define USB_COMMON_DEBUG 1
+
+/*****************************************************************************/
+/* Define some macros to make it easier to move this file to another
+ * part of the Xserver tree. All calls to the dmx* layer are #defined
+ * here for the .c file. The .h file will also have to be edited. */
+#include "usb-mouse.h"
+
+#define GETPRIV myPrivate *priv \
+ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
+
+#define GETNAME ((DMXLocalInputInfoPtr)(pDevice->public.devicePrivate)) \
+ ->name
+
+#define LOG0(f) dmxLog(dmxDebug,f)
+#define LOG1(f,a) dmxLog(dmxDebug,f,a)
+#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define LOG1INPUT(p,f,a) dmxLogInput(p->dmxInput,f,a)
+#define LOG3INPUT(p,f,a,b,c) dmxLogInput(p->dmxInput,f,a,b,c)
+#define LOG5INPUT(p,f,a,b,c,d,e) dmxLogInput(p->dmxInput,f,a,b,c,d,e)
+#define FATAL0(f) dmxLog(dmxFatal,f)
+#define FATAL1(f,a) dmxLog(dmxFatal,f,a)
+#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
+#define MOTIONPROC dmxMotionProcPtr
+#define ENQUEUEPROC dmxEnqueueProcPtr
+#define CHECKPROC dmxCheckSpecialProcPtr
+#define BLOCK DMXBlockType
+
+/* End of interface definitions. */
+/*****************************************************************************/
+
+
+/** Read an event from the \a pDev device. If the event is a motion
+ * event, enqueue it with the \a motion function. Otherwise, enqueue
+ * the event with the \a enqueue function. The \a block type is passed
+ * to the functions so that they may block SIGIO handling as appropriate
+ * to the caller of this function.
+ *
+ * Since USB devices return EV_KEY events for buttons and keys, \a
+ * minButton is used to decide if a Button or Key event should be
+ * queued.*/
+void usbRead(DevicePtr pDev,
+ MOTIONPROC motion,
+ ENQUEUEPROC enqueue,
+ int minButton,
+ BLOCK block)
+{
+ GETPRIV;
+ struct input_event raw;
+ int v[DMX_MAX_AXES];
+ int axis;
+
+#define PRESS(b) \
+ do { \
+ enqueue(pDev, ButtonPress, 0, 0, NULL, block); \
+ } while (0)
+
+#define RELEASE(b) \
+ do { \
+ enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \
+ } while (0)
+
+ while (read(priv->fd, &raw, sizeof(raw)) > 0) {
+#if USB_COMMON_DEBUG > 1
+ LOG3("USB: type = %d, code = 0x%02x, value = %d\n",
+ raw.type, raw.code, raw.value);
+#endif
+ switch (raw.type) {
+ case EV_KEY:
+ /* raw.value = 1 for first, 2 for repeat */
+ if (raw.code > minButton) {
+ if (raw.value) PRESS((raw.code & 0x0f) + 1);
+ else RELEASE((raw.code & 0x0f) + 1);
+ } else {
+ enqueue(pDev, raw.value ? KeyPress : KeyRelease,
+ 0, 0, NULL, block);
+ }
+ break;
+ case EV_REL:
+ switch (raw.code) {
+ case REL_X:
+ v[0] = -raw.value;
+ v[1] = 0;
+ motion(pDev, v, 0, 2, DMX_RELATIVE, block);
+ break;
+ case REL_Y:
+ v[0] = 0;
+ v[1] = -raw.value;
+ motion(pDev, v, 0, 2, DMX_RELATIVE, block);
+ break;
+ case REL_WHEEL:
+ if ((int)raw.value > 0) {
+ PRESS(4);
+ RELEASE(4);
+ } else if ((int)raw.value < 0) {
+ PRESS(5);
+ RELEASE(5);
+ }
+ break;
+ default:
+ memset(v, 0, sizeof(v));
+ axis = priv->relmap[raw.code];
+ v[axis] = raw.value;
+ motion(pDev, v, axis, 1, DMX_RELATIVE, block);
+ }
+ break;
+ case EV_ABS:
+ memset(v, 0, sizeof(v));
+ axis = priv->absmap[raw.code];
+ v[axis] = raw.value;
+ motion(pDev, v, axis, 1, DMX_ABSOLUTE, block);
+ break;
+ }
+ }
+}
+
+#define test_bit(bit) (priv->mask[(bit)/8] & (1 << ((bit)%8)))
+#define test_bits(bit) (bits[(bit)/8] & (1 << ((bit)%8)))
+
+static void usbPrint(myPrivate *priv,
+ const char *filename, const char *devname, int fd)
+{
+ int j, k;
+ DeviceIntPtr pDevice = priv->pDevice;
+ unsigned char bits[KEY_MAX/8 + 1]; /* RATS: Use ok assuming that
+ * KEY_MAX is greater than
+ * REL_MAX, ABS_MAX, SND_MAX, and
+ * LED_MAX. */
+
+ LOG3INPUT(priv, "%s (%s) using %s\n", pDevice->name, GETNAME, filename);
+ LOG1INPUT(priv, " %s\n", devname);
+ for (j = 0; j < EV_MAX; j++) {
+ if (test_bit(j)) {
+ const char *type = "unknown";
+ char extra[256]; /* FIXME: may cause buffer overflow */
+ extra[0] = '\0';
+ switch(j) {
+ case EV_KEY: type = "keys/buttons"; break;
+ case EV_REL: type = "relative";
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_REL, sizeof(bits)), bits);
+ for (k = 0; k < REL_MAX; k++) {
+ if (test_bits(k)) switch (k) {
+ case REL_X: strcat(extra, " X"); break;
+ case REL_Y: strcat(extra, " Y"); break;
+ case REL_Z: strcat(extra, " Z"); break;
+ case REL_HWHEEL: strcat(extra, " HWheel"); break;
+ case REL_DIAL: strcat(extra, " Dial"); break;
+ case REL_WHEEL: strcat(extra, " Wheel"); break;
+ case REL_MISC: strcat(extra, " Misc"); break;
+ }
+ }
+ break;
+ case EV_ABS: type = "absolute";
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_ABS, sizeof(bits)), bits);
+ for (k = 0; k < ABS_MAX; k++) {
+ if (test_bits(k)) switch (k) {
+ case ABS_X: strcat(extra," X"); break;
+ case ABS_Y: strcat(extra," Y"); break;
+ case ABS_Z: strcat(extra," Z"); break;
+ case ABS_RX: strcat(extra," RX"); break;
+ case ABS_RY: strcat(extra," RY"); break;
+ case ABS_RZ: strcat(extra," RZ"); break;
+ case ABS_THROTTLE: strcat(extra," Throttle");break;
+ case ABS_RUDDER: strcat(extra," Rudder"); break;
+ case ABS_WHEEL: strcat(extra," Wheel"); break;
+ case ABS_GAS: strcat(extra," Gas"); break;
+ case ABS_BRAKE: strcat(extra," Break"); break;
+ case ABS_HAT0X: strcat(extra," Hat0X"); break;
+ case ABS_HAT0Y: strcat(extra," Hat0Y"); break;
+ case ABS_HAT1X: strcat(extra," Hat1X"); break;
+ case ABS_HAT1Y: strcat(extra," Hat1Y"); break;
+ case ABS_HAT2X: strcat(extra," Hat2X"); break;
+ case ABS_HAT2Y: strcat(extra," Hat2Y"); break;
+ case ABS_HAT3X: strcat(extra," Hat3X"); break;
+ case ABS_HAT3Y: strcat(extra," Hat3Y"); break;
+ case ABS_PRESSURE: strcat(extra," Pressure");break;
+ case ABS_DISTANCE: strcat(extra," Distance");break;
+ case ABS_TILT_X: strcat(extra," TiltX"); break;
+ case ABS_TILT_Y: strcat(extra," TiltY"); break;
+ case ABS_MISC: strcat(extra," Misc"); break;
+ }
+ }
+ break;
+ case EV_MSC: type = "reserved"; break;
+ case EV_LED: type = "leds";
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_LED, sizeof(bits)), bits);
+ for (k = 0; k < LED_MAX; k++) {
+ if (test_bits(k)) switch (k) {
+ case LED_NUML: strcat(extra," NumLock"); break;
+ case LED_CAPSL: strcat(extra," CapsLock"); break;
+ case LED_SCROLLL: strcat(extra," ScrlLock"); break;
+ case LED_COMPOSE: strcat(extra," Compose"); break;
+ case LED_KANA: strcat(extra," Kana"); break;
+ case LED_SLEEP: strcat(extra," Sleep"); break;
+ case LED_SUSPEND: strcat(extra," Suspend"); break;
+ case LED_MUTE: strcat(extra," Mute"); break;
+ case LED_MISC: strcat(extra," Misc"); break;
+ }
+ }
+ break;
+ case EV_SND: type = "sound";
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_SND, sizeof(bits)), bits);
+ for (k = 0; k < SND_MAX; k++) {
+ if (test_bits(k)) switch (k) {
+ case SND_CLICK: strcat(extra," Click"); break;
+ case SND_BELL: strcat(extra," Bell"); break;
+ }
+ }
+ break;
+ case EV_REP: type = "repeat"; break;
+ case EV_FF: type = "feedback"; break;
+ }
+ LOG5INPUT(priv, " Feature 0x%02x = %s%s%s%s\n", j, type,
+ extra[0] ? " [" : "",
+ extra[0] ? extra+1 : "",
+ extra[0] ? "]" : "");
+ }
+ }
+}
+
+/** Initialized \a pDev as a \a usbMouse, \a usbKeyboard, or \a usbOther
+device. */
+void usbInit(DevicePtr pDev, usbType type)
+{
+ GETPRIV;
+ char name[64]; /* RATS: Only used in XmuSnprintf */
+ int i, j, k;
+ char buf[256] = { 0, }; /* RATS: Use ok */
+ int version;
+ unsigned char bits[KEY_MAX/8 + 1]; /* RATS: Use ok assuming that
+ * KEY_MAX is greater than
+ * REL_MAX, ABS_MAX, SND_MAX, and
+ * LED_MAX. */
+
+ if (priv->fd >=0) return;
+
+ for (i = 0; i < 32; i++) {
+ XmuSnprintf(name, sizeof(name), "/dev/input/event%d", i);
+ if ((priv->fd = open(name, O_RDWR | O_NONBLOCK, 0)) >= 0) {
+ ioctl(priv->fd, EVIOCGVERSION, &version);
+ ioctl(priv->fd, EVIOCGNAME(sizeof(buf)), buf);
+ memset(priv->mask, 0, sizeof(priv->mask));
+ ioctl(priv->fd, EVIOCGBIT(0, sizeof(priv->mask)), priv->mask);
+
+ for (j = 0; j < EV_MAX; j++) {
+ if (test_bit(j)) {
+ switch(j) {
+ case EV_REL:
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_REL, sizeof(bits)), bits);
+ for (k = 0; k < REL_MAX; k++) {
+ if (test_bits(k)) {
+ if (k == REL_X) priv->relmap[k] = 0;
+ else if (k == REL_Y) priv->relmap[k] = 1;
+ else priv->relmap[k] = 2 + priv->numAbs;
+ ++priv->numRel;
+ }
+ }
+ break;
+ case EV_ABS:
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_ABS, sizeof(bits)), bits);
+ for (k = 0; k < ABS_MAX; k++) {
+ if (test_bits(k)) {
+ priv->absmap[k] = priv->numAbs;
+ ++priv->numAbs;
+ }
+ }
+ break;
+ case EV_LED:
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_LED, sizeof(bits)), bits);
+ for (k = 0; k < LED_MAX; k++) {
+ if (test_bits(k)) ++priv->numLeds;
+ }
+ break;
+ }
+ }
+ }
+ switch (type) {
+ case usbMouse:
+ if (test_bit(EV_REL) && test_bit(EV_KEY))
+ goto found;
+ break;
+ case usbKeyboard:
+ if (test_bit(EV_KEY) && test_bit(EV_LED) && !test_bit(EV_ABS))
+ goto found;
+ break;
+ case usbOther:
+ if (!(test_bit(EV_REL) && test_bit(EV_KEY))
+ && !(test_bit(EV_KEY) && test_bit(EV_LED)
+ && !test_bit(EV_ABS)))
+ goto found;
+ break;
+ }
+ close(priv->fd);
+ priv->fd = -1;
+ }
+ }
+ if (priv->fd < 0)
+ FATAL1("usbInit: Cannot open /dev/input/event* port (%s)\n"
+ " If you have not done so, you may need to:\n"
+ " rmmod mousedev; rmmod keybdev\n"
+ " modprobe evdev\n",
+ strerror(errno));
+ found:
+ usbPrint(priv, name, buf, priv->fd);
+}
+
+/** Turn \a pDev off (i.e., stop taking input from \a pDev). */
+void usbOff(DevicePtr pDev)
+{
+ GETPRIV;
+
+ if (priv->fd >= 0) close(priv->fd);
+ priv->fd = -1;
+}
+
+/** Create a private structure for use within this file. */
+pointer usbCreatePrivate(DeviceIntPtr pDevice)
+{
+ myPrivate *priv = calloc(1, sizeof(*priv));
+ priv->fd = -1;
+ priv->pDevice = pDevice;
+ return priv;
+}
+
+/** Destroy a private structure. */
+void usbDestroyPrivate(pointer priv)
+{
+ free(priv);
+}
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.c b/xorg-server/hw/kdrive/ephyr/ephyr.c index 21c696c20..404f4ca60 100644 --- a/xorg-server/hw/kdrive/ephyr/ephyr.c +++ b/xorg-server/hw/kdrive/ephyr/ephyr.c @@ -346,13 +346,13 @@ ephyrInternalDamageRedisplay (ScreenPtr pScreen) pRegion = DamageRegion (scrpriv->pDamage);
- if (REGION_NOTEMPTY (pScreen, pRegion))
+ if (RegionNotEmpty(pRegion))
{
int nbox;
BoxPtr pbox;
- nbox = REGION_NUM_RECTS (pRegion);
- pbox = REGION_RECTS (pRegion);
+ nbox = RegionNumRects (pRegion);
+ pbox = RegionRects (pRegion);
while (nbox--)
{
@@ -908,10 +908,10 @@ ephyrExposePairedWindow (int a_remote) return;
}
screen = pair->local->drawable.pScreen;
- REGION_NULL (screen, ®);
- REGION_COPY (screen, ®, &pair->local->clipList);
+ RegionNull(®);
+ RegionCopy(®, &pair->local->clipList);
screen->WindowExposures (pair->local, ®, NullRegion);
- REGION_UNINIT (screen, ®);
+ RegionUninit(®);
}
#endif /* XF86DRI */
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c index 3d3d18a39..af411848f 100644 --- a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c +++ b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c @@ -109,10 +109,10 @@ static Bool findWindowPairFromLocal (WindowPtr a_local, static unsigned char DRIReqCode = 0;
-static int ephyrDRIWindowKeyIndex;
-static DevPrivateKey ephyrDRIWindowKey = &ephyrDRIWindowKeyIndex;
-static int ephyrDRIScreenKeyIndex;
-static DevPrivateKey ephyrDRIScreenKey = &ephyrDRIScreenKeyIndex;
+static DevPrivateKeyRec ephyrDRIWindowKeyRec;
+#define ephyrDRIWindowKey (&ephyrDRIWindowKeyRec)
+static DevPrivateKeyRec ephyrDRIScreenKeyRec;
+#define ephyrDRIScreenKey (&ephyrDRIScreenKeyRec)
#define GET_EPHYR_DRI_WINDOW_PRIV(win) ((EphyrDRIWindowPrivPtr) \
dixLookupPrivate(&(win)->devPrivates, ephyrDRIWindowKey))
@@ -418,11 +418,11 @@ ephyrDRIClipNotify (WindowPtr a_win, EPHYR_LOG_ERROR ("failed to get window pair\n") ;
goto out ;
}
- rects = calloc(REGION_NUM_RECTS (&a_win->clipList),
+ rects = calloc(RegionNumRects (&a_win->clipList),
sizeof (EphyrRect)) ;
- for (i=0; i < REGION_NUM_RECTS (&a_win->clipList); i++) {
+ for (i=0; i < RegionNumRects (&a_win->clipList); i++) {
memmove (&rects[i],
- ®ION_RECTS (&a_win->clipList)[i],
+ &RegionRects (&a_win->clipList)[i],
sizeof (EphyrRect)) ;
rects[i].x1 -= a_win->drawable.x;
rects[i].x2 -= a_win->drawable.x;
@@ -436,7 +436,7 @@ ephyrDRIClipNotify (WindowPtr a_win, is_ok = hostx_set_window_bounding_rectangles
(pair->remote,
rects,
- REGION_NUM_RECTS (&a_win->clipList)) ;
+ RegionNumRects (&a_win->clipList)) ;
is_ok = TRUE ;
out:
@@ -1168,12 +1168,12 @@ ProcXF86DRIGetDrawableInfo (register ClientPtr client) return BadMatch ;
}
EPHYR_LOG ("clip list of xephyr gl drawable:\n") ;
- for (i=0; i < REGION_NUM_RECTS (&window->clipList); i++) {
+ for (i=0; i < RegionNumRects (&window->clipList); i++) {
EPHYR_LOG ("x1:%d, y1:%d, x2:%d, y2:%d\n",
- REGION_RECTS (&window->clipList)[i].x1,
- REGION_RECTS (&window->clipList)[i].y1,
- REGION_RECTS (&window->clipList)[i].x2,
- REGION_RECTS (&window->clipList)[i].y2) ;
+ RegionRects (&window->clipList)[i].x1,
+ RegionRects (&window->clipList)[i].y1,
+ RegionRects (&window->clipList)[i].x2,
+ RegionRects (&window->clipList)[i].y2) ;
}
if (!ephyrDRIGetDrawableInfo (stuff->screen,
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrvideo.c b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c index 14213c966..0fd1a63d4 100644 --- a/xorg-server/hw/kdrive/ephyr/ephyrvideo.c +++ b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c @@ -946,8 +946,8 @@ ephyrPutImage (KdScreenInfo *a_info, a_drw_x, a_drw_y, a_drw_w, a_drw_h,
a_src_x, a_src_y, a_src_w, a_src_h,
a_width, a_height, a_buf,
- (EphyrHostBox*)REGION_RECTS (a_clipping_region),
- REGION_NUM_RECTS (a_clipping_region))) {
+ (EphyrHostBox*)RegionRects (a_clipping_region),
+ RegionNumRects (a_clipping_region))) {
EPHYR_LOG_ERROR ("EphyrHostXVPutImage() failed\n") ;
goto out ;
}
@@ -1025,8 +1025,8 @@ ephyrReputImage (KdScreenInfo *a_info, port_priv->src_w, port_priv->src_h,
port_priv->image_width, port_priv->image_height,
port_priv->image_buf,
- (EphyrHostBox*)REGION_RECTS (a_clipping_region),
- REGION_NUM_RECTS (a_clipping_region))) {
+ (EphyrHostBox*)RegionRects (a_clipping_region),
+ RegionNumRects (a_clipping_region))) {
EPHYR_LOG_ERROR ("ephyrHostXVPutImage() failed\n") ;
goto out ;
}
@@ -1064,7 +1064,7 @@ ephyrPutVideo (KdScreenInfo *a_info, dst_box.y2 = a_drw_y + a_drw_h;
if (!DoSimpleClip (&dst_box,
- REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+ RegionExtents(a_clipping_region),
&clipped_area)) {
EPHYR_LOG_ERROR ("failed to simple clip\n") ;
goto out ;
@@ -1115,7 +1115,7 @@ ephyrGetVideo (KdScreenInfo *a_info, dst_box.y2 = a_drw_y + a_drw_h;
if (!DoSimpleClip (&dst_box,
- REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+ RegionExtents(a_clipping_region),
&clipped_area)) {
EPHYR_LOG_ERROR ("failed to simple clip\n") ;
goto out ;
@@ -1166,7 +1166,7 @@ ephyrPutStill (KdScreenInfo *a_info, dst_box.y2 = a_drw_y + a_drw_h;
if (!DoSimpleClip (&dst_box,
- REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+ RegionExtents(a_clipping_region),
&clipped_area)) {
EPHYR_LOG_ERROR ("failed to simple clip\n") ;
goto out ;
@@ -1217,7 +1217,7 @@ ephyrGetStill (KdScreenInfo *a_info, dst_box.y2 = a_drw_y + a_drw_h;
if (!DoSimpleClip (&dst_box,
- REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+ RegionExtents(a_clipping_region),
&clipped_area)) {
EPHYR_LOG_ERROR ("failed to simple clip\n") ;
goto out ;
diff --git a/xorg-server/hw/kdrive/ephyr/hostx.c b/xorg-server/hw/kdrive/ephyr/hostx.c index 7a828eb31..4eb9cc1c0 100644 --- a/xorg-server/hw/kdrive/ephyr/hostx.c +++ b/xorg-server/hw/kdrive/ephyr/hostx.c @@ -1,1494 +1,1494 @@ -/* - * Xephyr - A kdrive X server thats runs in a host X window. - * Authored by Matthew Allum <mallum@o-hand.com> - * - * Copyright 2004 Nokia - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Nokia not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Nokia makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include <kdrive-config.h> -#endif - -/* - * including some server headers (like kdrive-config.h) - * might define the macro _XSERVER64 - * on 64 bits machines. That macro must _NOT_ be defined for Xlib - * client code, otherwise bad things happen. - * So let's undef that macro if necessary. - */ -#ifdef _XSERVER64 -#undef _XSERVER64 -#endif - - -#include "hostx.h" - -#include <stdlib.h> -#include <stdio.h> -#include <unistd.h> -#include <string.h> /* for memset */ -#include <time.h> - -#ifndef _MSC_VER -#include <sys/ipc.h> -#include <sys/shm.h> -#include <sys/time.h> -#endif - -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xatom.h> -#include <X11/keysym.h> -#include <X11/extensions/XShm.h> -#include <X11/extensions/shape.h> -#ifdef XF86DRI -#include <GL/glx.h> -#endif /* XF86DRI */ -#include "ephyrlog.h" - -#ifdef XF86DRI -extern Bool XF86DRIQueryExtension (Display *dpy, - int *event_basep, - int *error_basep); -#endif - -/* - * All xlib calls go here, which gets built as its own .a . - * Mixing kdrive and xlib headers causes all sorts of types - * to get clobbered. - */ - -struct EphyrHostScreen -{ - Window win; - Window win_pre_existing; /* Set via -parent option like xnest */ - Window peer_win; /* Used for GL; should be at most one */ - XImage *ximg; - int win_width, win_height; - int server_depth; - unsigned char *fb_data; /* only used when host bpp != server bpp */ - XShmSegmentInfo shminfo; - - void *info; /* Pointer to the screen this is associated with */ - int mynum; /* Screen number */ -}; - -struct EphyrHostXVars -{ - char *server_dpy_name; - Display *dpy; - int screen; - Visual *visual; - Window winroot; - GC gc; - int depth; - Bool use_host_cursor; - Bool use_fullscreen; - Bool have_shm; - - int n_screens; - struct EphyrHostScreen *screens; - - long damage_debug_msec; - - unsigned long cmap[256]; -}; - -/* memset ( missing> ) instead of below */ -/*static EphyrHostXVars HostX = { "?", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};*/ -static EphyrHostXVars HostX; - -static int HostXWantDamageDebug = 0; - -extern EphyrKeySyms ephyrKeySyms; - -extern int monitorResolution; - -char *ephyrResName = NULL; -int ephyrResNameFromCmd = 0; -char *ephyrTitle = NULL; - -static void -hostx_set_fullscreen_hint(void); - -/* X Error traps */ - -static int trapped_error_code = 0; -static int (*old_error_handler) (Display *d, XErrorEvent *e); - -#define host_depth_matches_server(_vars) (HostX.depth == (_vars)->server_depth) - -static struct EphyrHostScreen * -host_screen_from_screen_info (EphyrScreenInfo *screen) -{ - int i; - - for (i = 0 ; i < HostX.n_screens ; i++) - { - if ( HostX.screens[i].info == screen) - { - return &HostX.screens[i]; - } - } - return NULL; -} - -static int -error_handler(Display *display, - XErrorEvent *error) -{ - trapped_error_code = error->error_code; - return 0; -} - -static void -hostx_errors_trap(void) -{ - trapped_error_code = 0; - old_error_handler = XSetErrorHandler(error_handler); -} - -static int -hostx_errors_untrap(void) -{ - XSetErrorHandler(old_error_handler); - return trapped_error_code; -} - -int -hostx_want_screen_size (EphyrScreenInfo screen, int *width, int *height ) -{ - struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen); - - if (host_screen && - (host_screen->win_pre_existing != None || - HostX.use_fullscreen == True)) - { - *width = host_screen->win_width; - *height = host_screen->win_height; - return 1; - } - - return 0; -} - -void -hostx_add_screen (EphyrScreenInfo screen, - unsigned long win_id, - int screen_num) -{ - int index = HostX.n_screens; - - HostX.n_screens += 1; - HostX.screens = realloc (HostX.screens, - HostX.n_screens * sizeof(struct EphyrHostScreen)); - memset (&HostX.screens[index], 0, sizeof (struct EphyrHostScreen)); - - HostX.screens[index].info = screen; - HostX.screens[index].win_pre_existing = win_id; -} - - -void -hostx_set_display_name (char *name) -{ -#ifdef _MSC_VER - __asm int 3; -#else - HostX.server_dpy_name = strdup (name); -#endif -} - -void -hostx_set_screen_number(EphyrScreenInfo screen, int number) -{ - struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen); - if (host_screen) { - host_screen->mynum = number; - hostx_set_win_title (host_screen->info, "") ; - }} - -void -hostx_set_win_title (EphyrScreenInfo screen, char *extra_text) -{ - struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen); - - if (!host_screen) - return; - - if (ephyrTitle) { - XStoreName(HostX.dpy, host_screen->win, ephyrTitle); - } else { -#define BUF_LEN 256 - char buf[BUF_LEN+1]; - - memset (buf, 0, BUF_LEN+1) ; - snprintf (buf, BUF_LEN, "Xephyr on %s.%d %s", - HostX.server_dpy_name, - host_screen->mynum, - (extra_text != NULL) ? extra_text : ""); - - XStoreName (HostX.dpy, host_screen->win, buf); - } -} - -int -hostx_want_host_cursor (void) -{ - return HostX.use_host_cursor; -} - -void -hostx_use_host_cursor (void) -{ - HostX.use_host_cursor = True; -} - -int -hostx_want_preexisting_window (EphyrScreenInfo screen) -{ - struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen); - - if (host_screen && host_screen->win_pre_existing) - { - return 1; - } - else - { - return 0; - } -} - -void -hostx_use_fullscreen (void) -{ - HostX.use_fullscreen = True; -} - -int -hostx_want_fullscreen (void) -{ - return HostX.use_fullscreen; -} - -static void -hostx_set_fullscreen_hint (void) -{ - Atom atom_WINDOW_STATE, atom_WINDOW_STATE_FULLSCREEN; - int index; - - atom_WINDOW_STATE - = XInternAtom(HostX.dpy, "_NET_WM_STATE", False); - atom_WINDOW_STATE_FULLSCREEN - = XInternAtom(HostX.dpy, "_NET_WM_STATE_FULLSCREEN",False); - - for (index = 0 ; index < HostX.n_screens ; index++) - { - XChangeProperty (HostX.dpy, HostX.screens[index].win, - atom_WINDOW_STATE, XA_ATOM, 32, - PropModeReplace, - (unsigned char *)&atom_WINDOW_STATE_FULLSCREEN, 1); - } -} - - -static void -hostx_toggle_damage_debug (void) -{ - HostXWantDamageDebug ^= 1; -} - -void -hostx_handle_signal (int signum) -{ - hostx_toggle_damage_debug(); - EPHYR_DBG ("Signal caught. Damage Debug:%i\n", - HostXWantDamageDebug); -} - -void -hostx_use_resname (char *name, int fromcmd) -{ - ephyrResName = name; - ephyrResNameFromCmd = fromcmd; -} - -void -hostx_set_title (char *title) -{ - ephyrTitle = title; -} - -int -hostx_init (void) -{ - XSetWindowAttributes attr; - Cursor empty_cursor; - Pixmap cursor_pxm; - XColor col; - int index; - char *tmpstr; - XClassHint *class_hint; - - attr.event_mask = - ButtonPressMask - |ButtonReleaseMask - |PointerMotionMask - |KeyPressMask - |KeyReleaseMask - |ExposureMask; - - EPHYR_DBG("mark"); - - if ((HostX.dpy = XOpenDisplay(getenv("DISPLAY"))) == NULL) - { - fprintf(stderr, "\nXephyr cannot open host display. Is DISPLAY set?\n"); - exit(1); - } - - HostX.screen = DefaultScreen(HostX.dpy); - HostX.winroot = RootWindow(HostX.dpy, HostX.screen); - HostX.gc = XCreateGC(HostX.dpy, HostX.winroot, 0, NULL); - HostX.depth = DefaultDepth(HostX.dpy, HostX.screen); - HostX.visual = DefaultVisual(HostX.dpy, HostX.screen); - - class_hint = XAllocClassHint(); - - for (index = 0 ; index < HostX.n_screens ; index++) - { - struct EphyrHostScreen *host_screen = &HostX.screens[index]; - - host_screen->server_depth = HostX.depth; - if (host_screen->win_pre_existing != None) - { - Status result; - XWindowAttributes prewin_attr; - - /* Get screen size from existing window */ - - hostx_errors_trap(); - - result = XGetWindowAttributes (HostX.dpy, - host_screen->win_pre_existing, - &prewin_attr); - - - if (hostx_errors_untrap() || !result) - { - fprintf (stderr, "\nXephyr -parent window' does not exist!\n"); - exit (1); - } - - host_screen->win_width = prewin_attr.width; - host_screen->win_height = prewin_attr.height; - - host_screen->win = XCreateWindow (HostX.dpy, - host_screen->win_pre_existing, - 0,0, - host_screen->win_width, - host_screen->win_height, - 0, - CopyFromParent, - CopyFromParent, - CopyFromParent, - CWEventMask, - &attr); - } - else - { - host_screen->win = XCreateWindow (HostX.dpy, - HostX.winroot, - 0,0,100,100, /* will resize */ - 0, - CopyFromParent, - CopyFromParent, - CopyFromParent, - CWEventMask, - &attr); - - hostx_set_win_title (host_screen->info, - "(ctrl+shift grabs mouse and keyboard)"); - - if (HostX.use_fullscreen) - { - host_screen->win_width = DisplayWidth(HostX.dpy, HostX.screen); - host_screen->win_height = DisplayHeight(HostX.dpy, HostX.screen); - - hostx_set_fullscreen_hint(); - } - - if (class_hint) - { - tmpstr = getenv("RESOURCE_NAME"); - if (tmpstr && (!ephyrResNameFromCmd)) - ephyrResName = tmpstr; - class_hint->res_name = ephyrResName; - class_hint->res_class = "Xephyr"; - XSetClassHint(hostx_get_display(), host_screen->win, class_hint); - - } - - } - } - - if (class_hint) - XFree(class_hint); - - XParseColor (HostX.dpy, DefaultColormap (HostX.dpy,HostX.screen), - "red", &col); - XAllocColor (HostX.dpy, DefaultColormap (HostX.dpy, HostX.screen), - &col); - XSetForeground (HostX.dpy, HostX.gc, col.pixel); - - if (!hostx_want_host_cursor ()) - { - /* Ditch the cursor, we provide our 'own' */ - cursor_pxm = XCreatePixmap (HostX.dpy, HostX.winroot, 1, 1, 1); - memset (&col, 0, sizeof (col)); - empty_cursor = XCreatePixmapCursor (HostX.dpy, - cursor_pxm, cursor_pxm, - &col, &col, 1, 1); - for ( index = 0 ; index < HostX.n_screens ; index++ ) - { - XDefineCursor (HostX.dpy, - HostX.screens[index].win, - empty_cursor); - } - XFreePixmap (HostX.dpy, cursor_pxm); - } - - for (index = 0 ; index < HostX.n_screens ; index++) - { - HostX.screens[index].ximg = NULL; - } - /* Try to get share memory ximages for a little bit more speed */ - -#ifdef _MSC_VER - __asm int 3; -#else - if (!XShmQueryExtension(HostX.dpy) || getenv("XEPHYR_NO_SHM")) - { - fprintf(stderr, "\nXephyr unable to use SHM XImages\n"); - HostX.have_shm = False; - } - else - { - /* Really really check we have shm - better way ?*/ - XShmSegmentInfo shminfo; - - HostX.have_shm = True; - - shminfo.shmid=shmget(IPC_PRIVATE, 1, IPC_CREAT|0777); - shminfo.shmaddr=shmat(shminfo.shmid,0,0); - shminfo.readOnly=True; - - hostx_errors_trap(); - - XShmAttach(HostX.dpy, &shminfo); - XSync(HostX.dpy, False); - - if (hostx_errors_untrap()) - { - fprintf(stderr, "\nXephyr unable to use SHM XImages\n"); - HostX.have_shm = False; - } - - shmdt(shminfo.shmaddr); - shmctl(shminfo.shmid, IPC_RMID, 0); -} -#endif - - XFlush(HostX.dpy); - - /* Setup the pause time between paints when debugging updates */ - - HostX.damage_debug_msec = 20000; /* 1/50 th of a second */ - - if (getenv ("XEPHYR_PAUSE")) - { - HostX.damage_debug_msec = strtol (getenv ("XEPHYR_PAUSE"), NULL, 0); - EPHYR_DBG ("pause is %li\n", HostX.damage_debug_msec); - } - - return 1; -} - -int -hostx_get_depth (void) -{ - return HostX.depth; -} - -int -hostx_get_server_depth (EphyrScreenInfo screen) -{ - struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen); - - return (host_screen ? host_screen->server_depth : 0); -} - -void -hostx_set_server_depth (EphyrScreenInfo screen, int depth) -{ - struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen); - - if (host_screen) - host_screen->server_depth = depth; -} - -int -hostx_get_bpp (EphyrScreenInfo screen) -{ - struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen); - - if (!host_screen) - return 0; - - if (host_depth_matches_server (host_screen)) - return HostX.visual->bits_per_rgb; - else - return host_screen->server_depth; /*XXX correct ?*/ -} - -void -hostx_get_visual_masks (EphyrScreenInfo screen, - CARD32 *rmsk, - CARD32 *gmsk, - CARD32 *bmsk) -{ - struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen); - - if (!host_screen) - return; - - if (host_depth_matches_server(host_screen)) - { - *rmsk = HostX.visual->red_mask; - *gmsk = HostX.visual->green_mask; - *bmsk = HostX.visual->blue_mask; - } - else if (host_screen->server_depth == 16) - { - /* Assume 16bpp 565 */ - *rmsk = 0xf800; - *gmsk = 0x07e0; - *bmsk = 0x001f; - } - else - { - *rmsk = 0x0; - *gmsk = 0x0; - *bmsk = 0x0; - } -} - -static int -hostx_calculate_color_shift(unsigned long mask) -{ - int shift = 1; - /* count # of bits in mask */ - while ((mask = (mask >> 1))) shift++; - /* cmap entry is an unsigned char so adjust it by size of that */ - shift = shift - sizeof(unsigned char) * 8; - if (shift < 0) shift = 0; - return shift; -} - -void -hostx_set_cmap_entry(unsigned char idx, - unsigned char r, - unsigned char g, - unsigned char b) -{ -/* need to calculate the shifts for RGB because server could be BGR. */ -/* XXX Not sure if this is correct for 8 on 16, but this works for 8 on 24.*/ - static int rshift, bshift, gshift = 0; - static int first_time = 1; - if (first_time) { - first_time = 0; - rshift = hostx_calculate_color_shift(HostX.visual->red_mask); - gshift = hostx_calculate_color_shift(HostX.visual->green_mask); - bshift = hostx_calculate_color_shift(HostX.visual->blue_mask); - } - HostX.cmap[idx] = ((r << rshift) & HostX.visual->red_mask) | - ((g << gshift) & HostX.visual->green_mask) | - ((b << bshift) & HostX.visual->blue_mask); -} - -/** - * hostx_screen_init creates the XImage that will contain the front buffer of - * the ephyr screen, and possibly offscreen memory. - * - * @param width width of the screen - * @param height height of the screen - * @param buffer_height height of the rectangle to be allocated. - * - * hostx_screen_init() creates an XImage, using MIT-SHM if it's available. - * buffer_height can be used to create a larger offscreen buffer, which is used - * by fakexa for storing offscreen pixmap data. - */ -void* -hostx_screen_init (EphyrScreenInfo screen, - int width, int height, - int buffer_height) -{ - int bitmap_pad; - Bool shm_success = False; - XSizeHints *size_hints; - - struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen); - if (!host_screen) - { - fprintf (stderr, "%s: Error in accessing hostx data\n", __FUNCTION__ ); - exit(1); - } - - EPHYR_DBG ("host_screen=%p wxh=%dx%d, buffer_height=%d", - host_screen, width, height, buffer_height); - - if (host_screen->ximg != NULL) - { - /* Free up the image data if previously used - * i.ie called by server reset - */ - - if (HostX.have_shm) - { -#ifdef _MSC_VER - __asm int 3; -#else - XShmDetach(HostX.dpy, &host_screen->shminfo); - XDestroyImage (host_screen->ximg); - shmdt(host_screen->shminfo.shmaddr); - shmctl(host_screen->shminfo.shmid, IPC_RMID, 0); -#endif - } - else - { - if (host_screen->ximg->data) - { - free(host_screen->ximg->data); - host_screen->ximg->data = NULL; - } - - XDestroyImage(host_screen->ximg); - } - } - - if (HostX.have_shm) - { -#ifdef _MSC_VER -__asm int 3; -#else - host_screen->ximg = XShmCreateImage (HostX.dpy, HostX.visual, HostX.depth, - ZPixmap, NULL, &host_screen->shminfo, - width, buffer_height ); - - host_screen->shminfo.shmid = - shmget(IPC_PRIVATE, - host_screen->ximg->bytes_per_line * buffer_height, - IPC_CREAT|0777); - host_screen->ximg->data = shmat(host_screen->shminfo.shmid, 0, 0); - host_screen->shminfo.shmaddr = host_screen->ximg->data; - - if (host_screen->ximg->data == (char *)-1) - { - EPHYR_DBG("Can't attach SHM Segment, falling back to plain XImages"); - HostX.have_shm = False; - XDestroyImage(host_screen->ximg); - shmctl(host_screen->shminfo.shmid, IPC_RMID, 0); - } - else - { - EPHYR_DBG("SHM segment attached %p", host_screen->shminfo.shmaddr); - host_screen->shminfo.readOnly = False; - XShmAttach(HostX.dpy, &host_screen->shminfo); - shm_success = True; - } -#endif - } - - if (!shm_success) - { - bitmap_pad = ( HostX.depth > 16 )? 32 : (( HostX.depth > 8 )? 16 : 8 ); - - EPHYR_DBG("Creating image %dx%d for screen host_screen=%p\n", - width, buffer_height, host_screen ); - host_screen->ximg = XCreateImage (HostX.dpy, - HostX.visual, - HostX.depth, - ZPixmap, 0, 0, - width, - buffer_height, - bitmap_pad, - 0); - - host_screen->ximg->data = - malloc (host_screen->ximg->bytes_per_line * buffer_height); - } - - XResizeWindow (HostX.dpy, host_screen->win, width, height); - - /* Ask the WM to keep our size static */ - size_hints = XAllocSizeHints(); - size_hints->max_width = size_hints->min_width = width; - size_hints->max_height = size_hints->min_height = height; - size_hints->flags = PMinSize|PMaxSize; - XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints); - XFree(size_hints); - - XMapWindow(HostX.dpy, host_screen->win); - - XSync(HostX.dpy, False); - - host_screen->win_width = width; - host_screen->win_height = height; - - if (host_depth_matches_server(host_screen)) - { - EPHYR_DBG("Host matches server"); - return host_screen->ximg->data; - } - else - { - EPHYR_DBG("server bpp %i", host_screen->server_depth>>3); - host_screen->fb_data = malloc(width*buffer_height*(host_screen->server_depth>>3)); - return host_screen->fb_data; - } -} - -static void hostx_paint_debug_rect (struct EphyrHostScreen *host_screen, - int x, int y, - int width, int height); - -void -hostx_paint_rect (EphyrScreenInfo screen, - int sx, int sy, - int dx, int dy, - int width, int height) -{ - struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen); - - EPHYR_DBG ("painting in screen %d\n", host_screen->mynum) ; - - /* - * Copy the image data updated by the shadow layer - * on to the window - */ - - if (HostXWantDamageDebug) - { - hostx_paint_debug_rect(host_screen, dx, dy, width, height); - } - - /* - * If the depth of the ephyr server is less than that of the host, - * the kdrive fb does not point to the ximage data but to a buffer - * ( fb_data ), we shift the various bits from this onto the XImage - * so they match the host. - * - * Note, This code is pretty new ( and simple ) so may break on - * endian issues, 32 bpp host etc. - * Not sure if 8bpp case is right either. - * ... and it will be slower than the matching depth case. - */ - - if (!host_depth_matches_server(host_screen)) - { - int x,y,idx, bytes_per_pixel = (host_screen->server_depth>>3); - unsigned char r,g,b; - unsigned long host_pixel; - - EPHYR_DBG("Unmatched host depth host_screen=%p\n", host_screen); - for (y=sy; y<sy+height; y++) - for (x=sx; x<sx+width; x++) - { - idx = (host_screen->win_width*y*bytes_per_pixel)+(x*bytes_per_pixel); - - switch (host_screen->server_depth) - { - case 16: - { - unsigned short pixel = *(unsigned short*)(host_screen->fb_data+idx); - - r = ((pixel & 0xf800) >> 8); - g = ((pixel & 0x07e0) >> 3); - b = ((pixel & 0x001f) << 3); - - host_pixel = (r << 16) | (g << 8) | (b); - - XPutPixel(host_screen->ximg, x, y, host_pixel); - break; - } - case 8: - { - unsigned char pixel = *(unsigned char*)(host_screen->fb_data+idx); - XPutPixel(host_screen->ximg, x, y, HostX.cmap[pixel]); - break; - } - default: - break; - } - } - } - - if (HostX.have_shm) - { -#ifdef _MSC_VER - __asm int 3; -#else - XShmPutImage (HostX.dpy, host_screen->win, - HostX.gc, host_screen->ximg, - sx, sy, dx, dy, width, height, False); -#endif - } - else - { - XPutImage (HostX.dpy, host_screen->win, HostX.gc, host_screen->ximg, - sx, sy, dx, dy, width, height); - } - - XSync (HostX.dpy, False); -} - -static void -hostx_paint_debug_rect (struct EphyrHostScreen *host_screen, - int x, int y, - int width, int height) -{ -#ifdef _MSC_VER - __asm int 3; -#else - struct timespec tspec; - - tspec.tv_sec = HostX.damage_debug_msec / (1000000); - tspec.tv_nsec = (HostX.damage_debug_msec % 1000000) * 1000; - - EPHYR_DBG("msec: %li tv_sec %li, tv_msec %li", - HostX.damage_debug_msec, tspec.tv_sec, tspec.tv_nsec); - - /* fprintf(stderr, "Xephyr updating: %i+%i %ix%i\n", x, y, width, height); */ - - XFillRectangle (HostX.dpy, host_screen->win, HostX.gc, x, y, width,height); - XSync (HostX.dpy, False); - - /* nanosleep seems to work better than usleep for me... */ - nanosleep(&tspec, NULL); -#endif -} - -void -hostx_load_keymap(void) -{ - XID *keymap; - int host_width, min_keycode, max_keycode, width; - int i,j; - - XDisplayKeycodes (HostX.dpy, &min_keycode, &max_keycode); - - EPHYR_DBG ("min: %d, max: %d", min_keycode, max_keycode); - - keymap = XGetKeyboardMapping (HostX.dpy, - min_keycode, - max_keycode - min_keycode + 1, - &host_width); - - /* Try and copy the hosts keymap into our keymap to avoid loads - * of messing around. - * - * kdrive cannot can have more than 4 keysyms per keycode - * so we only copy at most the first 4 ( xorg has 6 per keycode, XVNC 2 ) - */ - width = (host_width > 4) ? 4 : host_width; - - ephyrKeySyms.map = (CARD32 *)calloc(sizeof(CARD32), - (max_keycode - min_keycode + 1) * - width); - if (!ephyrKeySyms.map) - return; - - for (i=0; i<(max_keycode - min_keycode+1); i++) - for (j=0; j<width; j++) - ephyrKeySyms.map[(i*width)+j] = (CARD32) keymap[(i*host_width) + j]; - - EPHYR_DBG("keymap width, host:%d kdrive:%d", host_width, width); - - ephyrKeySyms.minKeyCode = min_keycode; - ephyrKeySyms.maxKeyCode = max_keycode; - ephyrKeySyms.mapWidth = width; - - XFree(keymap); -} - -static struct EphyrHostScreen * -host_screen_from_window (Window w) -{ - int index = 0; - struct EphyrHostScreen *result = NULL; - - for (index = 0 ; index < HostX.n_screens ; index++) - { - if (HostX.screens[index].win == w || HostX.screens[index].peer_win == w) - { - result = &HostX.screens[index]; - goto out; - } - } - -out: - return result; -} - -int -hostx_get_event(EphyrHostXEvent *ev) -{ - XEvent xev; - static int grabbed_screen = -1; - - if (XPending(HostX.dpy)) - { - XNextEvent(HostX.dpy, &xev); - - switch (xev.type) - { - case Expose: - /* Not so great event compression, but works ok */ - while (XCheckTypedWindowEvent(HostX.dpy, xev.xexpose.window, - Expose, &xev)); - { - struct EphyrHostScreen *host_screen = - host_screen_from_window (xev.xexpose.window); - if (host_screen) - { - hostx_paint_rect (host_screen->info, 0, 0, 0, 0, - host_screen->win_width, - host_screen->win_height); - } - else - { - EPHYR_LOG_ERROR ("failed to get host screen\n"); - ev->type = EPHYR_EV_EXPOSE; - ev->data.expose.window = xev.xexpose.window; - return 1; - } - } - return 0; - - case MotionNotify: - { - struct EphyrHostScreen *host_screen = - host_screen_from_window (xev.xmotion.window); - - ev->type = EPHYR_EV_MOUSE_MOTION; - ev->data.mouse_motion.x = xev.xmotion.x; - ev->data.mouse_motion.y = xev.xmotion.y; - ev->data.mouse_motion.window = xev.xmotion.window; - ev->data.mouse_motion.screen = (host_screen ? host_screen->mynum : -1); - } - return 1; - - case ButtonPress: - ev->type = EPHYR_EV_MOUSE_PRESS; - ev->key_state = xev.xkey.state; - /* - * This is a bit hacky. will break for button 5 ( defined as 0x10 ) - * Check KD_BUTTON defines in kdrive.h - */ - ev->data.mouse_down.button_num = 1<<(xev.xbutton.button-1); - return 1; - - case ButtonRelease: - ev->type = EPHYR_EV_MOUSE_RELEASE; - ev->key_state = xev.xkey.state; - ev->data.mouse_up.button_num = 1<<(xev.xbutton.button-1); - return 1; - - case KeyPress: - { - ev->type = EPHYR_EV_KEY_PRESS; - ev->key_state = xev.xkey.state; - ev->data.key_down.scancode = xev.xkey.keycode; - return 1; - } - case KeyRelease: - - if ((XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_L - || XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_R) - && (xev.xkey.state & ControlMask)) - { - struct EphyrHostScreen *host_screen = - host_screen_from_window (xev.xexpose.window); - - if (grabbed_screen != -1) - { - XUngrabKeyboard (HostX.dpy, CurrentTime); - XUngrabPointer (HostX.dpy, CurrentTime); - grabbed_screen = -1; - hostx_set_win_title (host_screen->info, - "(ctrl+shift grabs mouse and keyboard)"); - } - else - { - /* Attempt grab */ - if (XGrabKeyboard (HostX.dpy, host_screen->win, True, - GrabModeAsync, - GrabModeAsync, - CurrentTime) == 0) - { - if (XGrabPointer (HostX.dpy, host_screen->win, True, - NoEventMask, - GrabModeAsync, - GrabModeAsync, - host_screen->win, None, CurrentTime) == 0) - { - grabbed_screen = host_screen->mynum; - hostx_set_win_title - (host_screen->info, - "(ctrl+shift releases mouse and keyboard)"); - } - else /* Failed pointer grabm ungrab keyboard */ - XUngrabKeyboard (HostX.dpy, CurrentTime); - } - } - } - - /* Still send the release event even if above has happened - * server will get confused with just an up event. - * Maybe it would be better to just block shift+ctrls getting to - * kdrive all togeather. - */ - ev->type = EPHYR_EV_KEY_RELEASE; - ev->key_state = xev.xkey.state; - ev->data.key_up.scancode = xev.xkey.keycode; - return 1; - - default: - break; - - } - } - return 0; -} - -void* -hostx_get_display(void) -{ - return HostX.dpy ; -} - -int -hostx_get_window (int a_screen_number) -{ - if (a_screen_number < 0 || a_screen_number >= HostX.n_screens) { - EPHYR_LOG_ERROR ("bad screen number:%d\n", a_screen_number) ; - return 0; - } - return HostX.screens[a_screen_number].win ; -} - -int -hostx_get_window_attributes (int a_window, EphyrHostWindowAttributes *a_attrs) -{ - XWindowAttributes attrs ; - - memset (&attrs, 0, sizeof (attrs)) ; - - if (!XGetWindowAttributes (hostx_get_display (), - a_window, - &attrs)) { - return FALSE ; - } - a_attrs->x = attrs.x ; - a_attrs->y = attrs.y ; - a_attrs->width = attrs.width ; - a_attrs->height = attrs.height ; - if (attrs.visual) - a_attrs->visualid = attrs.visual->visualid ; - return TRUE ; -} - -int -hostx_get_extension_info (const char *a_ext_name, - int *a_major_opcode, - int *a_first_event, - int *a_first_error) -{ - if (!a_ext_name || !a_major_opcode || !a_first_event || !a_first_error) - return 0 ; - if (!XQueryExtension (HostX.dpy, - a_ext_name, - a_major_opcode, - a_first_event, - a_first_error)) - { - return 0 ; - } - return 1 ; -} - -int -hostx_get_visuals_info (EphyrHostVisualInfo **a_visuals, - int *a_num_entries) -{ - Display *dpy=hostx_get_display () ; - Bool is_ok=False ; - XVisualInfo templ, *visuals=NULL; - EphyrHostVisualInfo *host_visuals=NULL ; - int nb_items=0, i=0; - - EPHYR_RETURN_VAL_IF_FAIL (a_visuals && a_num_entries && dpy, - False) ; - EPHYR_LOG ("enter\n") ; - memset (&templ, 0, sizeof (templ)) ; - visuals = XGetVisualInfo (dpy, VisualNoMask, &templ, &nb_items) ; - if (!visuals) { - EPHYR_LOG_ERROR ("host does not advertise any visual\n") ; - goto out ; - } - EPHYR_LOG ("host advertises %d visuals\n", nb_items) ; - host_visuals = calloc (nb_items, sizeof (EphyrHostVisualInfo)) ; - for (i=0; i<nb_items; i++) { - host_visuals[i].visualid = visuals[i].visualid ; - host_visuals[i].screen = visuals[i].screen ; - host_visuals[i].depth = visuals[i].depth ; - host_visuals[i].class = visuals[i].class ; - host_visuals[i].red_mask = visuals[i].red_mask ; - host_visuals[i].green_mask = visuals[i].green_mask ; - host_visuals[i].blue_mask = visuals[i].blue_mask ; - host_visuals[i].colormap_size = visuals[i].colormap_size ; - host_visuals[i].bits_per_rgb = visuals[i].bits_per_rgb ; - } - *a_visuals = host_visuals ; - *a_num_entries = nb_items; - host_visuals=NULL; - - is_ok = TRUE; -out: - if (visuals) { - XFree (visuals) ; - visuals = NULL; - } - if (host_visuals) { - free (host_visuals) ; - host_visuals = NULL; - } - EPHYR_LOG ("leave\n") ; - return is_ok ; - -} - -int -hostx_create_window (int a_screen_number, - EphyrBox *a_geometry, - int a_visual_id, - int *a_host_peer /*out parameter*/) -{ - Bool is_ok=FALSE ; - Display *dpy=hostx_get_display () ; - XVisualInfo *visual_info=NULL, visual_info_templ; - int visual_mask=VisualIDMask ; - Window win=None ; - int nb_visuals=0, winmask=0; - XSetWindowAttributes attrs; - - EPHYR_RETURN_VAL_IF_FAIL (dpy && a_geometry, FALSE) ; - - EPHYR_LOG ("enter\n") ; - - /*get visual*/ - memset (&visual_info, 0, sizeof (visual_info)) ; - visual_info_templ.visualid = a_visual_id ; - visual_info = XGetVisualInfo (dpy, visual_mask, - &visual_info_templ, - &nb_visuals) ; - if (!visual_info) { - EPHYR_LOG_ERROR ("argh, could not find a remote visual with id:%d\n", - a_visual_id) ; - goto out ; - } - memset (&attrs, 0, sizeof (attrs)) ; - attrs.colormap = XCreateColormap (dpy, - RootWindow (dpy, - visual_info->screen), - visual_info->visual, - AllocNone) ; - attrs.event_mask = ButtonPressMask - |ButtonReleaseMask - |PointerMotionMask - |KeyPressMask - |KeyReleaseMask - |ExposureMask; - winmask = CWColormap|CWEventMask; - - win = XCreateWindow (dpy, hostx_get_window (a_screen_number), - a_geometry->x, a_geometry->y, - a_geometry->width, a_geometry->height, 0, - visual_info->depth, CopyFromParent, - visual_info->visual, winmask, &attrs) ; - if (win == None) { - EPHYR_LOG_ERROR ("failed to create peer window\n") ; - goto out ; - } - if (HostX.screens[a_screen_number].peer_win == None) { - HostX.screens[a_screen_number].peer_win = win; - } else { - EPHYR_LOG_ERROR ("multiple peer windows created for same screen\n") ; - } - XFlush (dpy) ; - XMapWindow (dpy, win) ; - *a_host_peer = win ; - is_ok = TRUE ; -out: - EPHYR_LOG ("leave\n") ; - return is_ok ; -} - -int -hostx_destroy_window (int a_win) -{ - Display *dpy=hostx_get_display () ; - - EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ; - XDestroyWindow (dpy, a_win) ; - XFlush (dpy) ; - return TRUE ; -} - -int -hostx_set_window_geometry (int a_win, EphyrBox *a_geo) -{ - Display *dpy=hostx_get_display (); - - EPHYR_RETURN_VAL_IF_FAIL (dpy && a_geo, FALSE) ; - - EPHYR_LOG ("enter. x,y,w,h:(%d,%d,%d,%d)\n", - a_geo->x, a_geo->y, - a_geo->width, a_geo->height) ; - - XMoveWindow (dpy, a_win, a_geo->x, a_geo->y) ; - XResizeWindow (dpy, a_win, a_geo->width, a_geo->height) ; - EPHYR_LOG ("leave\n") ; - return TRUE; -} - -int -hostx_set_window_bounding_rectangles (int a_window, - EphyrRect *a_rects, - int a_num_rects) -{ - Bool is_ok=FALSE; - Display *dpy=hostx_get_display () ; - int i=0 ; - XRectangle *rects=NULL ; - - EPHYR_RETURN_VAL_IF_FAIL (dpy && a_rects, FALSE) ; - - EPHYR_LOG ("enter. num rects:%d\n", a_num_rects) ; - - rects = calloc (a_num_rects, sizeof (XRectangle)) ; - for (i=0; i<a_num_rects; i++) { - rects[i].x = a_rects[i].x1 ; - rects[i].y = a_rects[i].y1 ; - rects[i].width = abs (a_rects[i].x2 - a_rects[i].x1); - rects[i].height = abs (a_rects[i].y2 - a_rects[i].y1) ; - EPHYR_LOG ("borders clipped to rect[x:%d,y:%d,w:%d,h:%d]\n", - rects[i].x, rects[i].y, - rects[i].width, rects[i].height) ; - } - /*this aways returns 1*/ -#ifdef _MSC_VER - __asm int 3; -#else - XShapeCombineRectangles (dpy, a_window, ShapeBounding, 0, 0, - rects, a_num_rects, ShapeSet, YXBanded) ; -#endif - is_ok = TRUE ; - - if (rects) { - free (rects) ; - rects = NULL ; - } - EPHYR_LOG ("leave\n") ; - return is_ok; -} - -int -hostx_set_window_clipping_rectangles (int a_window, - EphyrRect *a_rects, - int a_num_rects) -{ - Bool is_ok=FALSE; - Display *dpy=hostx_get_display () ; - int i=0 ; - XRectangle *rects=NULL ; - - EPHYR_RETURN_VAL_IF_FAIL (dpy && a_rects, FALSE) ; - - EPHYR_LOG ("enter. num rects:%d\n", a_num_rects) ; - - rects = calloc (a_num_rects, sizeof (XRectangle)) ; - for (i=0; i<a_num_rects; i++) { - rects[i].x = a_rects[i].x1 ; - rects[i].y = a_rects[i].y1 ; - rects[i].width = abs (a_rects[i].x2 - a_rects[i].x1); - rects[i].height = abs (a_rects[i].y2 - a_rects[i].y1) ; - EPHYR_LOG ("clipped to rect[x:%d,y:%d,w:%d,h:%d]\n", - rects[i].x, rects[i].y, - rects[i].width, rects[i].height) ; - } - /*this aways returns 1*/ -#ifdef _MSC_VER - __asm int 3; -#else - XShapeCombineRectangles (dpy, a_window, ShapeClip, 0, 0, - rects, a_num_rects, ShapeSet, YXBanded) ; -#endif - is_ok = TRUE ; - - if (rects) { - free (rects) ; - rects = NULL ; - } - EPHYR_LOG ("leave\n") ; - return is_ok; -} - -int -hostx_has_xshape (void) -{ - int event_base=0, error_base=0 ; -#ifdef _MSC_VER - __asm int 3; -#else - Display *dpy=hostx_get_display () ; - if (!XShapeQueryExtension (dpy, - &event_base, - &error_base)) { - return FALSE ; - } -#endif - return TRUE; -} - -#ifdef XF86DRI -typedef struct { - int is_valid ; - int local_id ; - int remote_id ; -} ResourcePair ; - -#define RESOURCE_PEERS_SIZE 1024*10 -static ResourcePair resource_peers[RESOURCE_PEERS_SIZE] ; - - -int -hostx_allocate_resource_id_peer (int a_local_resource_id, - int *a_remote_resource_id) -{ - int i=0 ; - ResourcePair *peer=NULL ; - Display *dpy=hostx_get_display (); - - /* - * first make sure a resource peer - * does not exist already for - * a_local_resource_id - */ - for (i=0; i<RESOURCE_PEERS_SIZE; i++) { - if (resource_peers[i].is_valid - && resource_peers[i].local_id == a_local_resource_id) { - peer = &resource_peers[i] ; - break ; - } - } - /* - * find one free peer entry, an feed it with - */ - if (!peer) { - for (i=0; i<RESOURCE_PEERS_SIZE; i++) { - if (!resource_peers[i].is_valid) { - peer = &resource_peers[i] ; - break ; - } - } - if (peer) { - peer->remote_id = XAllocID (dpy); - peer->local_id = a_local_resource_id ; - peer->is_valid = TRUE ; - } - } - if (peer) { - *a_remote_resource_id = peer->remote_id ; - return TRUE ; - } - return FALSE ; -} - -int -hostx_get_resource_id_peer (int a_local_resource_id, - int *a_remote_resource_id) -{ - int i=0 ; - ResourcePair *peer=NULL ; - for (i=0; i<RESOURCE_PEERS_SIZE; i++) { - if (resource_peers[i].is_valid - && resource_peers[i].local_id == a_local_resource_id) { - peer = &resource_peers[i] ; - break ; - } - } - if (peer) { - *a_remote_resource_id = peer->remote_id ; - return TRUE ; - } - return FALSE ; -} - -int -hostx_has_dri (void) -{ - int event_base=0, error_base=0 ; - Display *dpy=hostx_get_display () ; - - if (!dpy) - return FALSE ; - - if (!XF86DRIQueryExtension (dpy, - &event_base, - &error_base)) { - return FALSE ; - } - return TRUE ; -} - -int -hostx_has_glx (void) -{ - Display *dpy=hostx_get_display () ; - int event_base=0, error_base=0 ; - - if (!glXQueryExtension (dpy, &event_base, &error_base)) { - return FALSE ; - } - return TRUE ; -} - -#endif /* XF86DRI */ +/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@o-hand.com>
+ *
+ * Copyright 2004 Nokia
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Nokia not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Nokia makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+/*
+ * including some server headers (like kdrive-config.h)
+ * might define the macro _XSERVER64
+ * on 64 bits machines. That macro must _NOT_ be defined for Xlib
+ * client code, otherwise bad things happen.
+ * So let's undef that macro if necessary.
+ */
+#ifdef _XSERVER64
+#undef _XSERVER64
+#endif
+
+
+#include "hostx.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h> /* for memset */
+#include <time.h>
+
+#ifndef _MSC_VER
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/time.h>
+#endif
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/keysym.h>
+#include <X11/extensions/XShm.h>
+#include <X11/extensions/shape.h>
+#ifdef XF86DRI
+#include <GL/glx.h>
+#endif /* XF86DRI */
+#include "ephyrlog.h"
+
+#ifdef XF86DRI
+extern Bool XF86DRIQueryExtension (Display *dpy,
+ int *event_basep,
+ int *error_basep);
+#endif
+
+/*
+ * All xlib calls go here, which gets built as its own .a .
+ * Mixing kdrive and xlib headers causes all sorts of types
+ * to get clobbered.
+ */
+
+struct EphyrHostScreen
+{
+ Window win;
+ Window win_pre_existing; /* Set via -parent option like xnest */
+ Window peer_win; /* Used for GL; should be at most one */
+ XImage *ximg;
+ int win_width, win_height;
+ int server_depth;
+ unsigned char *fb_data; /* only used when host bpp != server bpp */
+ XShmSegmentInfo shminfo;
+
+ void *info; /* Pointer to the screen this is associated with */
+ int mynum; /* Screen number */
+};
+
+struct EphyrHostXVars
+{
+ char *server_dpy_name;
+ Display *dpy;
+ int screen;
+ Visual *visual;
+ Window winroot;
+ GC gc;
+ int depth;
+ Bool use_host_cursor;
+ Bool use_fullscreen;
+ Bool have_shm;
+
+ int n_screens;
+ struct EphyrHostScreen *screens;
+
+ long damage_debug_msec;
+
+ unsigned long cmap[256];
+};
+
+/* memset ( missing> ) instead of below */
+/*static EphyrHostXVars HostX = { "?", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};*/
+static EphyrHostXVars HostX;
+
+static int HostXWantDamageDebug = 0;
+
+extern EphyrKeySyms ephyrKeySyms;
+
+extern int monitorResolution;
+
+char *ephyrResName = NULL;
+int ephyrResNameFromCmd = 0;
+char *ephyrTitle = NULL;
+
+static void
+hostx_set_fullscreen_hint(void);
+
+/* X Error traps */
+
+static int trapped_error_code = 0;
+static int (*old_error_handler) (Display *d, XErrorEvent *e);
+
+#define host_depth_matches_server(_vars) (HostX.depth == (_vars)->server_depth)
+
+static struct EphyrHostScreen *
+host_screen_from_screen_info (EphyrScreenInfo *screen)
+{
+ int i;
+
+ for (i = 0 ; i < HostX.n_screens ; i++)
+ {
+ if ( HostX.screens[i].info == screen)
+ {
+ return &HostX.screens[i];
+ }
+ }
+ return NULL;
+}
+
+static int
+error_handler(Display *display,
+ XErrorEvent *error)
+{
+ trapped_error_code = error->error_code;
+ return 0;
+}
+
+static void
+hostx_errors_trap(void)
+{
+ trapped_error_code = 0;
+ old_error_handler = XSetErrorHandler(error_handler);
+}
+
+static int
+hostx_errors_untrap(void)
+{
+ XSetErrorHandler(old_error_handler);
+ return trapped_error_code;
+}
+
+int
+hostx_want_screen_size (EphyrScreenInfo screen, int *width, int *height )
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ if (host_screen &&
+ (host_screen->win_pre_existing != None ||
+ HostX.use_fullscreen == True))
+ {
+ *width = host_screen->win_width;
+ *height = host_screen->win_height;
+ return 1;
+ }
+
+ return 0;
+}
+
+void
+hostx_add_screen (EphyrScreenInfo screen,
+ unsigned long win_id,
+ int screen_num)
+{
+ int index = HostX.n_screens;
+
+ HostX.n_screens += 1;
+ HostX.screens = realloc (HostX.screens,
+ HostX.n_screens * sizeof(struct EphyrHostScreen));
+ memset (&HostX.screens[index], 0, sizeof (struct EphyrHostScreen));
+
+ HostX.screens[index].info = screen;
+ HostX.screens[index].win_pre_existing = win_id;
+}
+
+
+void
+hostx_set_display_name (char *name)
+{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ HostX.server_dpy_name = strdup (name);
+#endif
+}
+
+void
+hostx_set_screen_number(EphyrScreenInfo screen, int number)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+ if (host_screen) {
+ host_screen->mynum = number;
+ hostx_set_win_title (host_screen->info, "") ;
+ }}
+
+void
+hostx_set_win_title (EphyrScreenInfo screen, char *extra_text)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ if (!host_screen)
+ return;
+
+ if (ephyrTitle) {
+ XStoreName(HostX.dpy, host_screen->win, ephyrTitle);
+ } else {
+#define BUF_LEN 256
+ char buf[BUF_LEN+1];
+
+ memset (buf, 0, BUF_LEN+1) ;
+ snprintf (buf, BUF_LEN, "Xephyr on %s.%d %s",
+ HostX.server_dpy_name,
+ host_screen->mynum,
+ (extra_text != NULL) ? extra_text : "");
+
+ XStoreName (HostX.dpy, host_screen->win, buf);
+ }
+}
+
+int
+hostx_want_host_cursor (void)
+{
+ return HostX.use_host_cursor;
+}
+
+void
+hostx_use_host_cursor (void)
+{
+ HostX.use_host_cursor = True;
+}
+
+int
+hostx_want_preexisting_window (EphyrScreenInfo screen)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ if (host_screen && host_screen->win_pre_existing)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+void
+hostx_use_fullscreen (void)
+{
+ HostX.use_fullscreen = True;
+}
+
+int
+hostx_want_fullscreen (void)
+{
+ return HostX.use_fullscreen;
+}
+
+static void
+hostx_set_fullscreen_hint (void)
+{
+ Atom atom_WINDOW_STATE, atom_WINDOW_STATE_FULLSCREEN;
+ int index;
+
+ atom_WINDOW_STATE
+ = XInternAtom(HostX.dpy, "_NET_WM_STATE", False);
+ atom_WINDOW_STATE_FULLSCREEN
+ = XInternAtom(HostX.dpy, "_NET_WM_STATE_FULLSCREEN",False);
+
+ for (index = 0 ; index < HostX.n_screens ; index++)
+ {
+ XChangeProperty (HostX.dpy, HostX.screens[index].win,
+ atom_WINDOW_STATE, XA_ATOM, 32,
+ PropModeReplace,
+ (unsigned char *)&atom_WINDOW_STATE_FULLSCREEN, 1);
+ }
+}
+
+
+static void
+hostx_toggle_damage_debug (void)
+{
+ HostXWantDamageDebug ^= 1;
+}
+
+void
+hostx_handle_signal (int signum)
+{
+ hostx_toggle_damage_debug();
+ EPHYR_DBG ("Signal caught. Damage Debug:%i\n",
+ HostXWantDamageDebug);
+}
+
+void
+hostx_use_resname (char *name, int fromcmd)
+{
+ ephyrResName = name;
+ ephyrResNameFromCmd = fromcmd;
+}
+
+void
+hostx_set_title (char *title)
+{
+ ephyrTitle = title;
+}
+
+int
+hostx_init (void)
+{
+ XSetWindowAttributes attr;
+ Cursor empty_cursor;
+ Pixmap cursor_pxm;
+ XColor col;
+ int index;
+ char *tmpstr;
+ XClassHint *class_hint;
+
+ attr.event_mask =
+ ButtonPressMask
+ |ButtonReleaseMask
+ |PointerMotionMask
+ |KeyPressMask
+ |KeyReleaseMask
+ |ExposureMask;
+
+ EPHYR_DBG("mark");
+
+ if ((HostX.dpy = XOpenDisplay(getenv("DISPLAY"))) == NULL)
+ {
+ fprintf(stderr, "\nXephyr cannot open host display. Is DISPLAY set?\n");
+ exit(1);
+ }
+
+ HostX.screen = DefaultScreen(HostX.dpy);
+ HostX.winroot = RootWindow(HostX.dpy, HostX.screen);
+ HostX.gc = XCreateGC(HostX.dpy, HostX.winroot, 0, NULL);
+ HostX.depth = DefaultDepth(HostX.dpy, HostX.screen);
+ HostX.visual = DefaultVisual(HostX.dpy, HostX.screen);
+
+ class_hint = XAllocClassHint();
+
+ for (index = 0 ; index < HostX.n_screens ; index++)
+ {
+ struct EphyrHostScreen *host_screen = &HostX.screens[index];
+
+ host_screen->server_depth = HostX.depth;
+ if (host_screen->win_pre_existing != None)
+ {
+ Status result;
+ XWindowAttributes prewin_attr;
+
+ /* Get screen size from existing window */
+
+ hostx_errors_trap();
+
+ result = XGetWindowAttributes (HostX.dpy,
+ host_screen->win_pre_existing,
+ &prewin_attr);
+
+
+ if (hostx_errors_untrap() || !result)
+ {
+ fprintf (stderr, "\nXephyr -parent window' does not exist!\n");
+ exit (1);
+ }
+
+ host_screen->win_width = prewin_attr.width;
+ host_screen->win_height = prewin_attr.height;
+
+ host_screen->win = XCreateWindow (HostX.dpy,
+ host_screen->win_pre_existing,
+ 0,0,
+ host_screen->win_width,
+ host_screen->win_height,
+ 0,
+ CopyFromParent,
+ CopyFromParent,
+ CopyFromParent,
+ CWEventMask,
+ &attr);
+ }
+ else
+ {
+ host_screen->win = XCreateWindow (HostX.dpy,
+ HostX.winroot,
+ 0,0,100,100, /* will resize */
+ 0,
+ CopyFromParent,
+ CopyFromParent,
+ CopyFromParent,
+ CWEventMask,
+ &attr);
+
+ hostx_set_win_title (host_screen->info,
+ "(ctrl+shift grabs mouse and keyboard)");
+
+ if (HostX.use_fullscreen)
+ {
+ host_screen->win_width = DisplayWidth(HostX.dpy, HostX.screen);
+ host_screen->win_height = DisplayHeight(HostX.dpy, HostX.screen);
+
+ hostx_set_fullscreen_hint();
+ }
+
+ if (class_hint)
+ {
+ tmpstr = getenv("RESOURCE_NAME");
+ if (tmpstr && (!ephyrResNameFromCmd))
+ ephyrResName = tmpstr;
+ class_hint->res_name = ephyrResName;
+ class_hint->res_class = "Xephyr";
+ XSetClassHint(hostx_get_display(), host_screen->win, class_hint);
+
+ }
+
+ }
+ }
+
+ if (class_hint)
+ XFree(class_hint);
+
+ XParseColor (HostX.dpy, DefaultColormap (HostX.dpy,HostX.screen),
+ "red", &col);
+ XAllocColor (HostX.dpy, DefaultColormap (HostX.dpy, HostX.screen),
+ &col);
+ XSetForeground (HostX.dpy, HostX.gc, col.pixel);
+
+ if (!hostx_want_host_cursor ())
+ {
+ /* Ditch the cursor, we provide our 'own' */
+ cursor_pxm = XCreatePixmap (HostX.dpy, HostX.winroot, 1, 1, 1);
+ memset (&col, 0, sizeof (col));
+ empty_cursor = XCreatePixmapCursor (HostX.dpy,
+ cursor_pxm, cursor_pxm,
+ &col, &col, 1, 1);
+ for ( index = 0 ; index < HostX.n_screens ; index++ )
+ {
+ XDefineCursor (HostX.dpy,
+ HostX.screens[index].win,
+ empty_cursor);
+ }
+ XFreePixmap (HostX.dpy, cursor_pxm);
+ }
+
+ for (index = 0 ; index < HostX.n_screens ; index++)
+ {
+ HostX.screens[index].ximg = NULL;
+ }
+ /* Try to get share memory ximages for a little bit more speed */
+
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ if (!XShmQueryExtension(HostX.dpy) || getenv("XEPHYR_NO_SHM"))
+ {
+ fprintf(stderr, "\nXephyr unable to use SHM XImages\n");
+ HostX.have_shm = False;
+ }
+ else
+ {
+ /* Really really check we have shm - better way ?*/
+ XShmSegmentInfo shminfo;
+
+ HostX.have_shm = True;
+
+ shminfo.shmid=shmget(IPC_PRIVATE, 1, IPC_CREAT|0777);
+ shminfo.shmaddr=shmat(shminfo.shmid,0,0);
+ shminfo.readOnly=True;
+
+ hostx_errors_trap();
+
+ XShmAttach(HostX.dpy, &shminfo);
+ XSync(HostX.dpy, False);
+
+ if (hostx_errors_untrap())
+ {
+ fprintf(stderr, "\nXephyr unable to use SHM XImages\n");
+ HostX.have_shm = False;
+ }
+
+ shmdt(shminfo.shmaddr);
+ shmctl(shminfo.shmid, IPC_RMID, 0);
+}
+#endif
+
+ XFlush(HostX.dpy);
+
+ /* Setup the pause time between paints when debugging updates */
+
+ HostX.damage_debug_msec = 20000; /* 1/50 th of a second */
+
+ if (getenv ("XEPHYR_PAUSE"))
+ {
+ HostX.damage_debug_msec = strtol (getenv ("XEPHYR_PAUSE"), NULL, 0);
+ EPHYR_DBG ("pause is %li\n", HostX.damage_debug_msec);
+ }
+
+ return 1;
+}
+
+int
+hostx_get_depth (void)
+{
+ return HostX.depth;
+}
+
+int
+hostx_get_server_depth (EphyrScreenInfo screen)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ return host_screen ? host_screen->server_depth : 0;
+}
+
+void
+hostx_set_server_depth (EphyrScreenInfo screen, int depth)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ if (host_screen)
+ host_screen->server_depth = depth;
+}
+
+int
+hostx_get_bpp (EphyrScreenInfo screen)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ if (!host_screen)
+ return 0;
+
+ if (host_depth_matches_server (host_screen))
+ return HostX.visual->bits_per_rgb;
+ else
+ return host_screen->server_depth; /*XXX correct ?*/
+}
+
+void
+hostx_get_visual_masks (EphyrScreenInfo screen,
+ CARD32 *rmsk,
+ CARD32 *gmsk,
+ CARD32 *bmsk)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ if (!host_screen)
+ return;
+
+ if (host_depth_matches_server(host_screen))
+ {
+ *rmsk = HostX.visual->red_mask;
+ *gmsk = HostX.visual->green_mask;
+ *bmsk = HostX.visual->blue_mask;
+ }
+ else if (host_screen->server_depth == 16)
+ {
+ /* Assume 16bpp 565 */
+ *rmsk = 0xf800;
+ *gmsk = 0x07e0;
+ *bmsk = 0x001f;
+ }
+ else
+ {
+ *rmsk = 0x0;
+ *gmsk = 0x0;
+ *bmsk = 0x0;
+ }
+}
+
+static int
+hostx_calculate_color_shift(unsigned long mask)
+{
+ int shift = 1;
+ /* count # of bits in mask */
+ while ((mask = (mask >> 1))) shift++;
+ /* cmap entry is an unsigned char so adjust it by size of that */
+ shift = shift - sizeof(unsigned char) * 8;
+ if (shift < 0) shift = 0;
+ return shift;
+}
+
+void
+hostx_set_cmap_entry(unsigned char idx,
+ unsigned char r,
+ unsigned char g,
+ unsigned char b)
+{
+/* need to calculate the shifts for RGB because server could be BGR. */
+/* XXX Not sure if this is correct for 8 on 16, but this works for 8 on 24.*/
+ static int rshift, bshift, gshift = 0;
+ static int first_time = 1;
+ if (first_time) {
+ first_time = 0;
+ rshift = hostx_calculate_color_shift(HostX.visual->red_mask);
+ gshift = hostx_calculate_color_shift(HostX.visual->green_mask);
+ bshift = hostx_calculate_color_shift(HostX.visual->blue_mask);
+ }
+ HostX.cmap[idx] = ((r << rshift) & HostX.visual->red_mask) |
+ ((g << gshift) & HostX.visual->green_mask) |
+ ((b << bshift) & HostX.visual->blue_mask);
+}
+
+/**
+ * hostx_screen_init creates the XImage that will contain the front buffer of
+ * the ephyr screen, and possibly offscreen memory.
+ *
+ * @param width width of the screen
+ * @param height height of the screen
+ * @param buffer_height height of the rectangle to be allocated.
+ *
+ * hostx_screen_init() creates an XImage, using MIT-SHM if it's available.
+ * buffer_height can be used to create a larger offscreen buffer, which is used
+ * by fakexa for storing offscreen pixmap data.
+ */
+void*
+hostx_screen_init (EphyrScreenInfo screen,
+ int width, int height,
+ int buffer_height)
+{
+ int bitmap_pad;
+ Bool shm_success = False;
+ XSizeHints *size_hints;
+
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+ if (!host_screen)
+ {
+ fprintf (stderr, "%s: Error in accessing hostx data\n", __FUNCTION__ );
+ exit(1);
+ }
+
+ EPHYR_DBG ("host_screen=%p wxh=%dx%d, buffer_height=%d",
+ host_screen, width, height, buffer_height);
+
+ if (host_screen->ximg != NULL)
+ {
+ /* Free up the image data if previously used
+ * i.ie called by server reset
+ */
+
+ if (HostX.have_shm)
+ {
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ XShmDetach(HostX.dpy, &host_screen->shminfo);
+ XDestroyImage (host_screen->ximg);
+ shmdt(host_screen->shminfo.shmaddr);
+ shmctl(host_screen->shminfo.shmid, IPC_RMID, 0);
+#endif
+ }
+ else
+ {
+ if (host_screen->ximg->data)
+ {
+ free(host_screen->ximg->data);
+ host_screen->ximg->data = NULL;
+ }
+
+ XDestroyImage(host_screen->ximg);
+ }
+ }
+
+ if (HostX.have_shm)
+ {
+#ifdef _MSC_VER
+__asm int 3;
+#else
+ host_screen->ximg = XShmCreateImage (HostX.dpy, HostX.visual, HostX.depth,
+ ZPixmap, NULL, &host_screen->shminfo,
+ width, buffer_height );
+
+ host_screen->shminfo.shmid =
+ shmget(IPC_PRIVATE,
+ host_screen->ximg->bytes_per_line * buffer_height,
+ IPC_CREAT|0777);
+ host_screen->ximg->data = shmat(host_screen->shminfo.shmid, 0, 0);
+ host_screen->shminfo.shmaddr = host_screen->ximg->data;
+
+ if (host_screen->ximg->data == (char *)-1)
+ {
+ EPHYR_DBG("Can't attach SHM Segment, falling back to plain XImages");
+ HostX.have_shm = False;
+ XDestroyImage(host_screen->ximg);
+ shmctl(host_screen->shminfo.shmid, IPC_RMID, 0);
+ }
+ else
+ {
+ EPHYR_DBG("SHM segment attached %p", host_screen->shminfo.shmaddr);
+ host_screen->shminfo.readOnly = False;
+ XShmAttach(HostX.dpy, &host_screen->shminfo);
+ shm_success = True;
+ }
+#endif
+ }
+
+ if (!shm_success)
+ {
+ bitmap_pad = ( HostX.depth > 16 )? 32 : (( HostX.depth > 8 )? 16 : 8 );
+
+ EPHYR_DBG("Creating image %dx%d for screen host_screen=%p\n",
+ width, buffer_height, host_screen );
+ host_screen->ximg = XCreateImage (HostX.dpy,
+ HostX.visual,
+ HostX.depth,
+ ZPixmap, 0, 0,
+ width,
+ buffer_height,
+ bitmap_pad,
+ 0);
+
+ host_screen->ximg->data =
+ malloc (host_screen->ximg->bytes_per_line * buffer_height);
+ }
+
+ XResizeWindow (HostX.dpy, host_screen->win, width, height);
+
+ /* Ask the WM to keep our size static */
+ size_hints = XAllocSizeHints();
+ size_hints->max_width = size_hints->min_width = width;
+ size_hints->max_height = size_hints->min_height = height;
+ size_hints->flags = PMinSize|PMaxSize;
+ XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints);
+ XFree(size_hints);
+
+ XMapWindow(HostX.dpy, host_screen->win);
+
+ XSync(HostX.dpy, False);
+
+ host_screen->win_width = width;
+ host_screen->win_height = height;
+
+ if (host_depth_matches_server(host_screen))
+ {
+ EPHYR_DBG("Host matches server");
+ return host_screen->ximg->data;
+ }
+ else
+ {
+ EPHYR_DBG("server bpp %i", host_screen->server_depth>>3);
+ host_screen->fb_data = malloc(width*buffer_height*(host_screen->server_depth>>3));
+ return host_screen->fb_data;
+ }
+}
+
+static void hostx_paint_debug_rect (struct EphyrHostScreen *host_screen,
+ int x, int y,
+ int width, int height);
+
+void
+hostx_paint_rect (EphyrScreenInfo screen,
+ int sx, int sy,
+ int dx, int dy,
+ int width, int height)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ EPHYR_DBG ("painting in screen %d\n", host_screen->mynum) ;
+
+ /*
+ * Copy the image data updated by the shadow layer
+ * on to the window
+ */
+
+ if (HostXWantDamageDebug)
+ {
+ hostx_paint_debug_rect(host_screen, dx, dy, width, height);
+ }
+
+ /*
+ * If the depth of the ephyr server is less than that of the host,
+ * the kdrive fb does not point to the ximage data but to a buffer
+ * ( fb_data ), we shift the various bits from this onto the XImage
+ * so they match the host.
+ *
+ * Note, This code is pretty new ( and simple ) so may break on
+ * endian issues, 32 bpp host etc.
+ * Not sure if 8bpp case is right either.
+ * ... and it will be slower than the matching depth case.
+ */
+
+ if (!host_depth_matches_server(host_screen))
+ {
+ int x,y,idx, bytes_per_pixel = (host_screen->server_depth>>3);
+ unsigned char r,g,b;
+ unsigned long host_pixel;
+
+ EPHYR_DBG("Unmatched host depth host_screen=%p\n", host_screen);
+ for (y=sy; y<sy+height; y++)
+ for (x=sx; x<sx+width; x++)
+ {
+ idx = (host_screen->win_width*y*bytes_per_pixel)+(x*bytes_per_pixel);
+
+ switch (host_screen->server_depth)
+ {
+ case 16:
+ {
+ unsigned short pixel = *(unsigned short*)(host_screen->fb_data+idx);
+
+ r = ((pixel & 0xf800) >> 8);
+ g = ((pixel & 0x07e0) >> 3);
+ b = ((pixel & 0x001f) << 3);
+
+ host_pixel = (r << 16) | (g << 8) | (b);
+
+ XPutPixel(host_screen->ximg, x, y, host_pixel);
+ break;
+ }
+ case 8:
+ {
+ unsigned char pixel = *(unsigned char*)(host_screen->fb_data+idx);
+ XPutPixel(host_screen->ximg, x, y, HostX.cmap[pixel]);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+ if (HostX.have_shm)
+ {
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ XShmPutImage (HostX.dpy, host_screen->win,
+ HostX.gc, host_screen->ximg,
+ sx, sy, dx, dy, width, height, False);
+#endif
+ }
+ else
+ {
+ XPutImage (HostX.dpy, host_screen->win, HostX.gc, host_screen->ximg,
+ sx, sy, dx, dy, width, height);
+ }
+
+ XSync (HostX.dpy, False);
+}
+
+static void
+hostx_paint_debug_rect (struct EphyrHostScreen *host_screen,
+ int x, int y,
+ int width, int height)
+{
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ struct timespec tspec;
+
+ tspec.tv_sec = HostX.damage_debug_msec / (1000000);
+ tspec.tv_nsec = (HostX.damage_debug_msec % 1000000) * 1000;
+
+ EPHYR_DBG("msec: %li tv_sec %li, tv_msec %li",
+ HostX.damage_debug_msec, tspec.tv_sec, tspec.tv_nsec);
+
+ /* fprintf(stderr, "Xephyr updating: %i+%i %ix%i\n", x, y, width, height); */
+
+ XFillRectangle (HostX.dpy, host_screen->win, HostX.gc, x, y, width,height);
+ XSync (HostX.dpy, False);
+
+ /* nanosleep seems to work better than usleep for me... */
+ nanosleep(&tspec, NULL);
+#endif
+}
+
+void
+hostx_load_keymap(void)
+{
+ XID *keymap;
+ int host_width, min_keycode, max_keycode, width;
+ int i,j;
+
+ XDisplayKeycodes (HostX.dpy, &min_keycode, &max_keycode);
+
+ EPHYR_DBG ("min: %d, max: %d", min_keycode, max_keycode);
+
+ keymap = XGetKeyboardMapping (HostX.dpy,
+ min_keycode,
+ max_keycode - min_keycode + 1,
+ &host_width);
+
+ /* Try and copy the hosts keymap into our keymap to avoid loads
+ * of messing around.
+ *
+ * kdrive cannot can have more than 4 keysyms per keycode
+ * so we only copy at most the first 4 ( xorg has 6 per keycode, XVNC 2 )
+ */
+ width = (host_width > 4) ? 4 : host_width;
+
+ ephyrKeySyms.map = (CARD32 *)calloc(sizeof(CARD32),
+ (max_keycode - min_keycode + 1) *
+ width);
+ if (!ephyrKeySyms.map)
+ return;
+
+ for (i=0; i<(max_keycode - min_keycode+1); i++)
+ for (j=0; j<width; j++)
+ ephyrKeySyms.map[(i*width)+j] = (CARD32) keymap[(i*host_width) + j];
+
+ EPHYR_DBG("keymap width, host:%d kdrive:%d", host_width, width);
+
+ ephyrKeySyms.minKeyCode = min_keycode;
+ ephyrKeySyms.maxKeyCode = max_keycode;
+ ephyrKeySyms.mapWidth = width;
+
+ XFree(keymap);
+}
+
+static struct EphyrHostScreen *
+host_screen_from_window (Window w)
+{
+ int index = 0;
+ struct EphyrHostScreen *result = NULL;
+
+ for (index = 0 ; index < HostX.n_screens ; index++)
+ {
+ if (HostX.screens[index].win == w || HostX.screens[index].peer_win == w)
+ {
+ result = &HostX.screens[index];
+ goto out;
+ }
+ }
+
+out:
+ return result;
+}
+
+int
+hostx_get_event(EphyrHostXEvent *ev)
+{
+ XEvent xev;
+ static int grabbed_screen = -1;
+
+ if (XPending(HostX.dpy))
+ {
+ XNextEvent(HostX.dpy, &xev);
+
+ switch (xev.type)
+ {
+ case Expose:
+ /* Not so great event compression, but works ok */
+ while (XCheckTypedWindowEvent(HostX.dpy, xev.xexpose.window,
+ Expose, &xev));
+ {
+ struct EphyrHostScreen *host_screen =
+ host_screen_from_window (xev.xexpose.window);
+ if (host_screen)
+ {
+ hostx_paint_rect (host_screen->info, 0, 0, 0, 0,
+ host_screen->win_width,
+ host_screen->win_height);
+ }
+ else
+ {
+ EPHYR_LOG_ERROR ("failed to get host screen\n");
+ ev->type = EPHYR_EV_EXPOSE;
+ ev->data.expose.window = xev.xexpose.window;
+ return 1;
+ }
+ }
+ return 0;
+
+ case MotionNotify:
+ {
+ struct EphyrHostScreen *host_screen =
+ host_screen_from_window (xev.xmotion.window);
+
+ ev->type = EPHYR_EV_MOUSE_MOTION;
+ ev->data.mouse_motion.x = xev.xmotion.x;
+ ev->data.mouse_motion.y = xev.xmotion.y;
+ ev->data.mouse_motion.window = xev.xmotion.window;
+ ev->data.mouse_motion.screen = (host_screen ? host_screen->mynum : -1);
+ }
+ return 1;
+
+ case ButtonPress:
+ ev->type = EPHYR_EV_MOUSE_PRESS;
+ ev->key_state = xev.xkey.state;
+ /*
+ * This is a bit hacky. will break for button 5 ( defined as 0x10 )
+ * Check KD_BUTTON defines in kdrive.h
+ */
+ ev->data.mouse_down.button_num = 1<<(xev.xbutton.button-1);
+ return 1;
+
+ case ButtonRelease:
+ ev->type = EPHYR_EV_MOUSE_RELEASE;
+ ev->key_state = xev.xkey.state;
+ ev->data.mouse_up.button_num = 1<<(xev.xbutton.button-1);
+ return 1;
+
+ case KeyPress:
+ {
+ ev->type = EPHYR_EV_KEY_PRESS;
+ ev->key_state = xev.xkey.state;
+ ev->data.key_down.scancode = xev.xkey.keycode;
+ return 1;
+ }
+ case KeyRelease:
+
+ if ((XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_L
+ || XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_R)
+ && (xev.xkey.state & ControlMask))
+ {
+ struct EphyrHostScreen *host_screen =
+ host_screen_from_window (xev.xexpose.window);
+
+ if (grabbed_screen != -1)
+ {
+ XUngrabKeyboard (HostX.dpy, CurrentTime);
+ XUngrabPointer (HostX.dpy, CurrentTime);
+ grabbed_screen = -1;
+ hostx_set_win_title (host_screen->info,
+ "(ctrl+shift grabs mouse and keyboard)");
+ }
+ else
+ {
+ /* Attempt grab */
+ if (XGrabKeyboard (HostX.dpy, host_screen->win, True,
+ GrabModeAsync,
+ GrabModeAsync,
+ CurrentTime) == 0)
+ {
+ if (XGrabPointer (HostX.dpy, host_screen->win, True,
+ NoEventMask,
+ GrabModeAsync,
+ GrabModeAsync,
+ host_screen->win, None, CurrentTime) == 0)
+ {
+ grabbed_screen = host_screen->mynum;
+ hostx_set_win_title
+ (host_screen->info,
+ "(ctrl+shift releases mouse and keyboard)");
+ }
+ else /* Failed pointer grabm ungrab keyboard */
+ XUngrabKeyboard (HostX.dpy, CurrentTime);
+ }
+ }
+ }
+
+ /* Still send the release event even if above has happened
+ * server will get confused with just an up event.
+ * Maybe it would be better to just block shift+ctrls getting to
+ * kdrive all togeather.
+ */
+ ev->type = EPHYR_EV_KEY_RELEASE;
+ ev->key_state = xev.xkey.state;
+ ev->data.key_up.scancode = xev.xkey.keycode;
+ return 1;
+
+ default:
+ break;
+
+ }
+ }
+ return 0;
+}
+
+void*
+hostx_get_display(void)
+{
+ return HostX.dpy ;
+}
+
+int
+hostx_get_window (int a_screen_number)
+{
+ if (a_screen_number < 0 || a_screen_number >= HostX.n_screens) {
+ EPHYR_LOG_ERROR ("bad screen number:%d\n", a_screen_number) ;
+ return 0;
+ }
+ return HostX.screens[a_screen_number].win ;
+}
+
+int
+hostx_get_window_attributes (int a_window, EphyrHostWindowAttributes *a_attrs)
+{
+ XWindowAttributes attrs ;
+
+ memset (&attrs, 0, sizeof (attrs)) ;
+
+ if (!XGetWindowAttributes (hostx_get_display (),
+ a_window,
+ &attrs)) {
+ return FALSE ;
+ }
+ a_attrs->x = attrs.x ;
+ a_attrs->y = attrs.y ;
+ a_attrs->width = attrs.width ;
+ a_attrs->height = attrs.height ;
+ if (attrs.visual)
+ a_attrs->visualid = attrs.visual->visualid ;
+ return TRUE ;
+}
+
+int
+hostx_get_extension_info (const char *a_ext_name,
+ int *a_major_opcode,
+ int *a_first_event,
+ int *a_first_error)
+{
+ if (!a_ext_name || !a_major_opcode || !a_first_event || !a_first_error)
+ return 0 ;
+ if (!XQueryExtension (HostX.dpy,
+ a_ext_name,
+ a_major_opcode,
+ a_first_event,
+ a_first_error))
+ {
+ return 0 ;
+ }
+ return 1 ;
+}
+
+int
+hostx_get_visuals_info (EphyrHostVisualInfo **a_visuals,
+ int *a_num_entries)
+{
+ Display *dpy=hostx_get_display () ;
+ Bool is_ok=False ;
+ XVisualInfo templ, *visuals=NULL;
+ EphyrHostVisualInfo *host_visuals=NULL ;
+ int nb_items=0, i=0;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_visuals && a_num_entries && dpy,
+ False) ;
+ EPHYR_LOG ("enter\n") ;
+ memset (&templ, 0, sizeof (templ)) ;
+ visuals = XGetVisualInfo (dpy, VisualNoMask, &templ, &nb_items) ;
+ if (!visuals) {
+ EPHYR_LOG_ERROR ("host does not advertise any visual\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("host advertises %d visuals\n", nb_items) ;
+ host_visuals = calloc (nb_items, sizeof (EphyrHostVisualInfo)) ;
+ for (i=0; i<nb_items; i++) {
+ host_visuals[i].visualid = visuals[i].visualid ;
+ host_visuals[i].screen = visuals[i].screen ;
+ host_visuals[i].depth = visuals[i].depth ;
+ host_visuals[i].class = visuals[i].class ;
+ host_visuals[i].red_mask = visuals[i].red_mask ;
+ host_visuals[i].green_mask = visuals[i].green_mask ;
+ host_visuals[i].blue_mask = visuals[i].blue_mask ;
+ host_visuals[i].colormap_size = visuals[i].colormap_size ;
+ host_visuals[i].bits_per_rgb = visuals[i].bits_per_rgb ;
+ }
+ *a_visuals = host_visuals ;
+ *a_num_entries = nb_items;
+ host_visuals=NULL;
+
+ is_ok = TRUE;
+out:
+ if (visuals) {
+ XFree (visuals) ;
+ visuals = NULL;
+ }
+ if (host_visuals) {
+ free (host_visuals) ;
+ host_visuals = NULL;
+ }
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+
+}
+
+int
+hostx_create_window (int a_screen_number,
+ EphyrBox *a_geometry,
+ int a_visual_id,
+ int *a_host_peer /*out parameter*/)
+{
+ Bool is_ok=FALSE ;
+ Display *dpy=hostx_get_display () ;
+ XVisualInfo *visual_info=NULL, visual_info_templ;
+ int visual_mask=VisualIDMask ;
+ Window win=None ;
+ int nb_visuals=0, winmask=0;
+ XSetWindowAttributes attrs;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy && a_geometry, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ /*get visual*/
+ memset (&visual_info, 0, sizeof (visual_info)) ;
+ visual_info_templ.visualid = a_visual_id ;
+ visual_info = XGetVisualInfo (dpy, visual_mask,
+ &visual_info_templ,
+ &nb_visuals) ;
+ if (!visual_info) {
+ EPHYR_LOG_ERROR ("argh, could not find a remote visual with id:%d\n",
+ a_visual_id) ;
+ goto out ;
+ }
+ memset (&attrs, 0, sizeof (attrs)) ;
+ attrs.colormap = XCreateColormap (dpy,
+ RootWindow (dpy,
+ visual_info->screen),
+ visual_info->visual,
+ AllocNone) ;
+ attrs.event_mask = ButtonPressMask
+ |ButtonReleaseMask
+ |PointerMotionMask
+ |KeyPressMask
+ |KeyReleaseMask
+ |ExposureMask;
+ winmask = CWColormap|CWEventMask;
+
+ win = XCreateWindow (dpy, hostx_get_window (a_screen_number),
+ a_geometry->x, a_geometry->y,
+ a_geometry->width, a_geometry->height, 0,
+ visual_info->depth, CopyFromParent,
+ visual_info->visual, winmask, &attrs) ;
+ if (win == None) {
+ EPHYR_LOG_ERROR ("failed to create peer window\n") ;
+ goto out ;
+ }
+ if (HostX.screens[a_screen_number].peer_win == None) {
+ HostX.screens[a_screen_number].peer_win = win;
+ } else {
+ EPHYR_LOG_ERROR ("multiple peer windows created for same screen\n") ;
+ }
+ XFlush (dpy) ;
+ XMapWindow (dpy, win) ;
+ *a_host_peer = win ;
+ is_ok = TRUE ;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+int
+hostx_destroy_window (int a_win)
+{
+ Display *dpy=hostx_get_display () ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+ XDestroyWindow (dpy, a_win) ;
+ XFlush (dpy) ;
+ return TRUE ;
+}
+
+int
+hostx_set_window_geometry (int a_win, EphyrBox *a_geo)
+{
+ Display *dpy=hostx_get_display ();
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy && a_geo, FALSE) ;
+
+ EPHYR_LOG ("enter. x,y,w,h:(%d,%d,%d,%d)\n",
+ a_geo->x, a_geo->y,
+ a_geo->width, a_geo->height) ;
+
+ XMoveWindow (dpy, a_win, a_geo->x, a_geo->y) ;
+ XResizeWindow (dpy, a_win, a_geo->width, a_geo->height) ;
+ EPHYR_LOG ("leave\n") ;
+ return TRUE;
+}
+
+int
+hostx_set_window_bounding_rectangles (int a_window,
+ EphyrRect *a_rects,
+ int a_num_rects)
+{
+ Bool is_ok=FALSE;
+ Display *dpy=hostx_get_display () ;
+ int i=0 ;
+ XRectangle *rects=NULL ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy && a_rects, FALSE) ;
+
+ EPHYR_LOG ("enter. num rects:%d\n", a_num_rects) ;
+
+ rects = calloc (a_num_rects, sizeof (XRectangle)) ;
+ for (i=0; i<a_num_rects; i++) {
+ rects[i].x = a_rects[i].x1 ;
+ rects[i].y = a_rects[i].y1 ;
+ rects[i].width = abs (a_rects[i].x2 - a_rects[i].x1);
+ rects[i].height = abs (a_rects[i].y2 - a_rects[i].y1) ;
+ EPHYR_LOG ("borders clipped to rect[x:%d,y:%d,w:%d,h:%d]\n",
+ rects[i].x, rects[i].y,
+ rects[i].width, rects[i].height) ;
+ }
+ /*this aways returns 1*/
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ XShapeCombineRectangles (dpy, a_window, ShapeBounding, 0, 0,
+ rects, a_num_rects, ShapeSet, YXBanded) ;
+#endif
+ is_ok = TRUE ;
+
+ if (rects) {
+ free (rects) ;
+ rects = NULL ;
+ }
+ EPHYR_LOG ("leave\n") ;
+ return is_ok;
+}
+
+int
+hostx_set_window_clipping_rectangles (int a_window,
+ EphyrRect *a_rects,
+ int a_num_rects)
+{
+ Bool is_ok=FALSE;
+ Display *dpy=hostx_get_display () ;
+ int i=0 ;
+ XRectangle *rects=NULL ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy && a_rects, FALSE) ;
+
+ EPHYR_LOG ("enter. num rects:%d\n", a_num_rects) ;
+
+ rects = calloc (a_num_rects, sizeof (XRectangle)) ;
+ for (i=0; i<a_num_rects; i++) {
+ rects[i].x = a_rects[i].x1 ;
+ rects[i].y = a_rects[i].y1 ;
+ rects[i].width = abs (a_rects[i].x2 - a_rects[i].x1);
+ rects[i].height = abs (a_rects[i].y2 - a_rects[i].y1) ;
+ EPHYR_LOG ("clipped to rect[x:%d,y:%d,w:%d,h:%d]\n",
+ rects[i].x, rects[i].y,
+ rects[i].width, rects[i].height) ;
+ }
+ /*this aways returns 1*/
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ XShapeCombineRectangles (dpy, a_window, ShapeClip, 0, 0,
+ rects, a_num_rects, ShapeSet, YXBanded) ;
+#endif
+ is_ok = TRUE ;
+
+ if (rects) {
+ free (rects) ;
+ rects = NULL ;
+ }
+ EPHYR_LOG ("leave\n") ;
+ return is_ok;
+}
+
+int
+hostx_has_xshape (void)
+{
+ int event_base=0, error_base=0 ;
+#ifdef _MSC_VER
+ __asm int 3;
+#else
+ Display *dpy=hostx_get_display () ;
+ if (!XShapeQueryExtension (dpy,
+ &event_base,
+ &error_base)) {
+ return FALSE ;
+ }
+#endif
+ return TRUE;
+}
+
+#ifdef XF86DRI
+typedef struct {
+ int is_valid ;
+ int local_id ;
+ int remote_id ;
+} ResourcePair ;
+
+#define RESOURCE_PEERS_SIZE 1024*10
+static ResourcePair resource_peers[RESOURCE_PEERS_SIZE] ;
+
+
+int
+hostx_allocate_resource_id_peer (int a_local_resource_id,
+ int *a_remote_resource_id)
+{
+ int i=0 ;
+ ResourcePair *peer=NULL ;
+ Display *dpy=hostx_get_display ();
+
+ /*
+ * first make sure a resource peer
+ * does not exist already for
+ * a_local_resource_id
+ */
+ for (i=0; i<RESOURCE_PEERS_SIZE; i++) {
+ if (resource_peers[i].is_valid
+ && resource_peers[i].local_id == a_local_resource_id) {
+ peer = &resource_peers[i] ;
+ break ;
+ }
+ }
+ /*
+ * find one free peer entry, an feed it with
+ */
+ if (!peer) {
+ for (i=0; i<RESOURCE_PEERS_SIZE; i++) {
+ if (!resource_peers[i].is_valid) {
+ peer = &resource_peers[i] ;
+ break ;
+ }
+ }
+ if (peer) {
+ peer->remote_id = XAllocID (dpy);
+ peer->local_id = a_local_resource_id ;
+ peer->is_valid = TRUE ;
+ }
+ }
+ if (peer) {
+ *a_remote_resource_id = peer->remote_id ;
+ return TRUE ;
+ }
+ return FALSE ;
+}
+
+int
+hostx_get_resource_id_peer (int a_local_resource_id,
+ int *a_remote_resource_id)
+{
+ int i=0 ;
+ ResourcePair *peer=NULL ;
+ for (i=0; i<RESOURCE_PEERS_SIZE; i++) {
+ if (resource_peers[i].is_valid
+ && resource_peers[i].local_id == a_local_resource_id) {
+ peer = &resource_peers[i] ;
+ break ;
+ }
+ }
+ if (peer) {
+ *a_remote_resource_id = peer->remote_id ;
+ return TRUE ;
+ }
+ return FALSE ;
+}
+
+int
+hostx_has_dri (void)
+{
+ int event_base=0, error_base=0 ;
+ Display *dpy=hostx_get_display () ;
+
+ if (!dpy)
+ return FALSE ;
+
+ if (!XF86DRIQueryExtension (dpy,
+ &event_base,
+ &error_base)) {
+ return FALSE ;
+ }
+ return TRUE ;
+}
+
+int
+hostx_has_glx (void)
+{
+ Display *dpy=hostx_get_display () ;
+ int event_base=0, error_base=0 ;
+
+ if (!glXQueryExtension (dpy, &event_base, &error_base)) {
+ return FALSE ;
+ }
+ return TRUE ;
+}
+
+#endif /* XF86DRI */
diff --git a/xorg-server/hw/kdrive/fake/fake.c b/xorg-server/hw/kdrive/fake/fake.c index 9f2327d94..626b2d25a 100644 --- a/xorg-server/hw/kdrive/fake/fake.c +++ b/xorg-server/hw/kdrive/fake/fake.c @@ -168,8 +168,7 @@ fakeMapFramebuffer (KdScreenInfo *screen) KdSetPointerMatrix (&m);
priv->bytes_per_line = ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
- if (priv->base)
- free (priv->base);
+ free(priv->base);
priv->base = malloc (priv->bytes_per_line * screen->height);
if (scrpriv->shadow)
diff --git a/xorg-server/hw/kdrive/src/kdrive.c b/xorg-server/hw/kdrive/src/kdrive.c index a7db41379..79b13520d 100644 --- a/xorg-server/hw/kdrive/src/kdrive.c +++ b/xorg-server/hw/kdrive/src/kdrive.c @@ -64,8 +64,7 @@ KdDepths kdDepths[] = { #define KD_DEFAULT_BUTTONS 5
-static int kdScreenPrivateKeyIndex;
-DevPrivateKey kdScreenPrivateKey = &kdScreenPrivateKeyIndex;
+DevPrivateKeyRec kdScreenPrivateKeyRec;
unsigned long kdGeneration;
Bool kdVideoTest;
@@ -95,7 +94,7 @@ KdOsFuncs *kdOsFuncs; void
KdSetRootClip (ScreenPtr pScreen, BOOL enable)
{
- WindowPtr pWin = WindowTable[pScreen->myNum];
+ WindowPtr pWin = pScreen->root;
WindowPtr pChild;
Bool WasViewable;
Bool anyMarked = FALSE;
@@ -121,8 +120,8 @@ KdSetRootClip (ScreenPtr pScreen, BOOL enable) {
RegionPtr borderVisible;
- borderVisible = REGION_CREATE(pScreen, NullBox, 1);
- REGION_SUBTRACT(pScreen, borderVisible,
+ borderVisible = RegionCreate(NullBox, 1);
+ RegionSubtract(borderVisible,
&pWin->borderClip, &pWin->winSize);
pWin->valdata->before.borderVisible = borderVisible;
}
@@ -138,15 +137,15 @@ KdSetRootClip (ScreenPtr pScreen, BOOL enable) box.y2 = pScreen->height;
pWin->drawable.width = pScreen->width;
pWin->drawable.height = pScreen->height;
- REGION_INIT (pScreen, &pWin->winSize, &box, 1);
- REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
- REGION_RESET(pScreen, &pWin->borderClip, &box);
- REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ RegionInit(&pWin->winSize, &box, 1);
+ RegionInit(&pWin->borderSize, &box, 1);
+ RegionReset(&pWin->borderClip, &box);
+ RegionBreak(&pWin->clipList);
}
else
{
- REGION_EMPTY(pScreen, &pWin->borderClip);
- REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ RegionEmpty(&pWin->borderClip);
+ RegionBreak(&pWin->clipList);
}
ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
@@ -701,6 +700,9 @@ KdAllocatePrivates (ScreenPtr pScreen) if (kdGeneration != serverGeneration)
kdGeneration = serverGeneration;
+ if (!dixRegisterPrivateKey(&kdScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
pScreenPriv = calloc(1, sizeof (*pScreenPriv));
if (!pScreenPriv)
return FALSE;
@@ -838,8 +840,8 @@ KdCreateWindow (WindowPtr pWin) if (!pScreenPriv->enabled)
{
- REGION_EMPTY (pWin->drawable.pScreen, &pWin->borderClip);
- REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ RegionEmpty(&pWin->borderClip);
+ RegionBreak(&pWin->clipList);
}
}
#endif
@@ -943,9 +945,8 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) pScreenPriv->card = card;
pScreenPriv->bytesPerPixel = screen->fb.bitsPerPixel >> 3;
pScreenPriv->dpmsState = KD_DPMS_NORMAL;
-#ifdef PANORAMIX
- dixScreenOrigins[pScreen->myNum] = screen->origin;
-#endif
+ pScreen->x = screen->origin.x;
+ pScreen->y = screen->origin.y;
if (!monitorResolution)
monitorResolution = 75;
diff --git a/xorg-server/hw/kdrive/src/kdrive.h b/xorg-server/hw/kdrive/src/kdrive.h index 35ce03660..8873662ee 100644 --- a/xorg-server/hw/kdrive/src/kdrive.h +++ b/xorg-server/hw/kdrive/src/kdrive.h @@ -1,626 +1,628 @@ -/* - * Copyright 1999 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _KDRIVE_H_ -#define _KDRIVE_H_ - -#include <stdio.h> -#include <string.h> -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/Xos.h> -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "windowstr.h" -#include "servermd.h" -#include "mibstore.h" -#include "colormapst.h" -#include "gcstruct.h" -#include "input.h" -#include "mipointer.h" -#include "mi.h" -#include "dix.h" -#include "fb.h" -#include "fboverlay.h" -#include "shadow.h" -#include "randrstr.h" -#include "globals.h" - -#include "xkbstr.h" - -#define KD_DPMS_NORMAL 0 -#define KD_DPMS_STANDBY 1 -#define KD_DPMS_SUSPEND 2 -#define KD_DPMS_POWERDOWN 3 -#define KD_DPMS_MAX KD_DPMS_POWERDOWN - -#define Status int - -typedef struct _KdCardInfo { - struct _KdCardFuncs *cfuncs; - void *closure; - void *driver; - struct _KdScreenInfo *screenList; - int selected; - struct _KdCardInfo *next; -} KdCardInfo; - -extern KdCardInfo *kdCardInfo; - -/* - * Configuration information per X screen - */ -typedef struct _KdFrameBuffer { - CARD8 *frameBuffer; - int depth; - int bitsPerPixel; - int pixelStride; - int byteStride; - Bool shadow; - unsigned long visuals; - Pixel redMask, greenMask, blueMask; - void *closure; -} KdFrameBuffer; - -#define RR_Rotate_All (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270) -#define RR_Reflect_All (RR_Reflect_X|RR_Reflect_Y) - -typedef struct _KdScreenInfo { - struct _KdScreenInfo *next; - KdCardInfo *card; - ScreenPtr pScreen; - void *driver; - Rotation randr; /* rotation and reflection */ - int width; - int height; - int rate; - int width_mm; - int height_mm; - int subpixel_order; - Bool dumb; - Bool softCursor; - int mynum; - DDXPointRec origin; - KdFrameBuffer fb; -} KdScreenInfo; - -typedef struct _KdCardFuncs { - Bool (*cardinit) (KdCardInfo *); /* detect and map device */ - Bool (*scrinit) (KdScreenInfo *);/* initialize screen information */ - Bool (*initScreen) (ScreenPtr); /* initialize ScreenRec */ - Bool (*finishInitScreen) (ScreenPtr pScreen); - Bool (*createRes) (ScreenPtr); /* create screen resources */ - void (*preserve) (KdCardInfo *); /* save graphics card state */ - Bool (*enable) (ScreenPtr); /* set up for rendering */ - Bool (*dpms) (ScreenPtr, int); /* set DPMS screen saver */ - void (*disable) (ScreenPtr); /* turn off rendering */ - void (*restore) (KdCardInfo *); /* restore graphics card state */ - void (*scrfini) (KdScreenInfo *);/* close down screen */ - void (*cardfini) (KdCardInfo *); /* close down */ - - Bool (*initCursor) (ScreenPtr); /* detect and map cursor */ - void (*enableCursor) (ScreenPtr); /* enable cursor */ - void (*disableCursor) (ScreenPtr); /* disable cursor */ - void (*finiCursor) (ScreenPtr); /* close down */ - void (*recolorCursor) (ScreenPtr, int, xColorItem *); - - Bool (*initAccel) (ScreenPtr); - void (*enableAccel) (ScreenPtr); - void (*disableAccel) (ScreenPtr); - void (*finiAccel) (ScreenPtr); - - void (*getColors) (ScreenPtr, int, xColorItem *); - void (*putColors) (ScreenPtr, int, xColorItem *); - -} KdCardFuncs; - -#define KD_MAX_PSEUDO_DEPTH 8 -#define KD_MAX_PSEUDO_SIZE (1 << KD_MAX_PSEUDO_DEPTH) - -typedef struct { - KdScreenInfo *screen; - KdCardInfo *card; - - Bool enabled; - Bool closed; - int bytesPerPixel; - - int dpmsState; - - ColormapPtr pInstalledmap; /* current colormap */ - xColorItem systemPalette[KD_MAX_PSEUDO_SIZE];/* saved windows colors */ - - CreateScreenResourcesProcPtr CreateScreenResources; - CloseScreenProcPtr CloseScreen; -} KdPrivScreenRec, *KdPrivScreenPtr; - -typedef enum _kdPointerState { - start, - button_1_pend, - button_1_down, - button_2_down, - button_3_pend, - button_3_down, - synth_2_down_13, - synth_2_down_3, - synth_2_down_1, - num_input_states -} KdPointerState; - -#define KD_MAX_BUTTON 32 - -#define KD_KEYBOARD 1 -#define KD_MOUSE 2 -#define KD_TOUCHSCREEN 3 - -typedef struct _KdPointerInfo KdPointerInfo; - -typedef struct _KdPointerDriver { - char *name; - Status (*Init) (KdPointerInfo *); - Status (*Enable) (KdPointerInfo *); - void (*Disable) (KdPointerInfo *); - void (*Fini) (KdPointerInfo *); - struct _KdPointerDriver *next; -} KdPointerDriver; - -struct _KdPointerInfo { - DeviceIntPtr dixdev; - char *name; - char *path; - char *protocol; - InputOption *options; - int inputClass; - - CARD8 map[KD_MAX_BUTTON + 1]; - int nButtons; - int nAxes; - - Bool emulateMiddleButton; - unsigned long emulationTimeout; - int emulationDx, emulationDy; - - Bool timeoutPending; - KdPointerState mouseState; - Bool eventHeld; - struct { - int type; - int x; - int y; - int z; - int flags; - int absrel; - } heldEvent; - unsigned char buttonState; - Bool transformCoordinates; - int pressureThreshold; - - KdPointerDriver *driver; - void *driverPrivate; - - struct _KdPointerInfo *next; -}; - -extern int KdCurScreen; - -void KdAddPointerDriver (KdPointerDriver *driver); -void KdRemovePointerDriver (KdPointerDriver *driver); -KdPointerInfo *KdNewPointer (void); -void KdFreePointer (KdPointerInfo *); -int KdAddPointer (KdPointerInfo *ki); -int KdAddConfigPointer (char *pointer); -void KdRemovePointer (KdPointerInfo *ki); - - -#define KD_KEY_COUNT 248 -#define KD_MIN_KEYCODE 8 -#define KD_MAX_KEYCODE 255 -#define KD_MAX_WIDTH 4 -#define KD_MAX_LENGTH (KD_MAX_KEYCODE - KD_MIN_KEYCODE + 1) - -typedef struct { - KeySym modsym; - int modbit; -} KdKeySymModsRec; - -typedef struct _KdKeyboardInfo KdKeyboardInfo; - -typedef struct _KdKeyboardDriver { - char *name; - Bool (*Init) (KdKeyboardInfo *); - Bool (*Enable) (KdKeyboardInfo *); - void (*Leds) (KdKeyboardInfo *, int); - void (*Bell) (KdKeyboardInfo *, int, int, int); - void (*Disable) (KdKeyboardInfo *); - void (*Fini) (KdKeyboardInfo *); - struct _KdKeyboardDriver *next; -} KdKeyboardDriver; - -struct _KdKeyboardInfo { - struct _KdKeyboardInfo *next; - DeviceIntPtr dixdev; - void *closure; - char *name; - char *path; - int inputClass; - char *xkbRules; - char *xkbModel; - char *xkbLayout; - char *xkbVariant; - char *xkbOptions; - int LockLed; - - int minScanCode; - int maxScanCode; - - int leds; - int bellPitch; - int bellDuration; - InputOption *options; - - KdKeyboardDriver *driver; - void *driverPrivate; -}; - -void KdAddKeyboardDriver (KdKeyboardDriver *driver); -void KdRemoveKeyboardDriver (KdKeyboardDriver *driver); -KdKeyboardInfo *KdNewKeyboard (void); -void KdFreeKeyboard (KdKeyboardInfo *ki); -int KdAddConfigKeyboard (char *pointer); -int KdAddKeyboard (KdKeyboardInfo *ki); -void KdRemoveKeyboard (KdKeyboardInfo *ki); - -typedef struct _KdOsFuncs { - int (*Init) (void); - void (*Enable) (void); - Bool (*SpecialKey) (KeySym); - void (*Disable) (void); - void (*Fini) (void); - void (*pollEvents) (void); - void (*Bell) (int, int, int); -} KdOsFuncs; - -typedef enum _KdSyncPolarity { - KdSyncNegative, KdSyncPositive -} KdSyncPolarity; - -typedef struct _KdMonitorTiming { - /* label */ - int horizontal; - int vertical; - int rate; - /* pixel clock */ - int clock; /* in KHz */ - /* horizontal timing */ - int hfp; /* front porch */ - int hbp; /* back porch */ - int hblank; /* blanking */ - KdSyncPolarity hpol; /* polarity */ - /* vertical timing */ - int vfp; /* front porch */ - int vbp; /* back porch */ - int vblank; /* blanking */ - KdSyncPolarity vpol; /* polarity */ -} KdMonitorTiming; - -extern const KdMonitorTiming kdMonitorTimings[]; -extern const int kdNumMonitorTimings; - -typedef struct _KdPointerMatrix { - int matrix[2][3]; -} KdPointerMatrix; - -/* - * This is the only completely portable way to - * compute this info. - */ - -#ifndef BitsPerPixel -#define BitsPerPixel(d) (\ - PixmapWidthPaddingInfo[d].notPower2 ? \ - (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \ - ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \ - (PixmapWidthPaddingInfo[d].padRoundUp+1))) -#endif - -extern DevPrivateKey kdScreenPrivateKey; -extern unsigned long kdGeneration; -extern Bool kdEnabled; -extern Bool kdSwitchPending; -extern Bool kdEmulateMiddleButton; -extern Bool kdDisableZaphod; -extern Bool kdAllowZap; -extern int kdVirtualTerminal; -extern char *kdSwitchCmd; -extern KdOsFuncs *kdOsFuncs; - -#define KdGetScreenPriv(pScreen) ((KdPrivScreenPtr) \ - dixLookupPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey)) -#define KdSetScreenPriv(pScreen,v) \ - dixSetPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey, v) -#define KdScreenPriv(pScreen) KdPrivScreenPtr pScreenPriv = KdGetScreenPriv(pScreen) - -/* kcmap.c */ -void -KdSetColormap (ScreenPtr pScreen); - -void -KdEnableColormap (ScreenPtr pScreen); - -void -KdDisableColormap (ScreenPtr pScreen); - -void -KdInstallColormap (ColormapPtr pCmap); - -void -KdUninstallColormap (ColormapPtr pCmap); - -int -KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps); - -void -KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs); - -/* kdrive.c */ -extern miPointerScreenFuncRec kdPointerScreenFuncs; - -void -KdSetRootClip (ScreenPtr pScreen, BOOL enable); - -void -KdDisableScreen (ScreenPtr pScreen); - -void -KdDisableScreens (void); - -Bool -KdEnableScreen (ScreenPtr pScreen); - -void -KdEnableScreens (void); - -void -KdSuspend (void); - -void -KdResume (void); - -void -KdProcessSwitch (void); - -Rotation -KdAddRotation (Rotation a, Rotation b); - -Rotation -KdSubRotation (Rotation a, Rotation b); - -void -KdParseScreen (KdScreenInfo *screen, - char *arg); - -KdPointerInfo * -KdParsePointer (char *arg); - -KdKeyboardInfo * -KdParseKeyboard (char *arg); - -char * -KdParseFindNext (char *cur, char *delim, char *save, char *last); - -void -KdParseRgba (char *rgba); - -void -KdUseMsg (void); - -int -KdProcessArgument (int argc, char **argv, int i); - -void -KdOsInit (KdOsFuncs *pOsFuncs); - -void -KdOsAddInputDrivers (void); - -Bool -KdAllocatePrivates (ScreenPtr pScreen); - -Bool -KdCreateScreenResources (ScreenPtr pScreen); - -Bool -KdCloseScreen (int index, ScreenPtr pScreen); - -Bool -KdSaveScreen (ScreenPtr pScreen, int on); - -Bool -KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv); - -void -KdInitScreen (ScreenInfo *pScreenInfo, - KdScreenInfo *screen, - int argc, - char **argv); - -void -KdInitCard (ScreenInfo *pScreenInfo, - KdCardInfo *card, - int argc, - char **argv); - -void -KdInitOutput (ScreenInfo *pScreenInfo, - int argc, - char **argv); - -void -KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr); - -void -KdBacktrace (int signum); - -/* kinfo.c */ -KdCardInfo * -KdCardInfoAdd (KdCardFuncs *funcs, - void *closure); - -KdCardInfo * -KdCardInfoLast (void); - -void -KdCardInfoDispose (KdCardInfo *ci); - -KdScreenInfo * -KdScreenInfoAdd (KdCardInfo *ci); - -void -KdScreenInfoDispose (KdScreenInfo *si); - - -/* kinput.c */ -void -KdInitInput(void); - -void -KdAddPointerDriver(KdPointerDriver *); - -void -KdAddKeyboardDriver(KdKeyboardDriver *); - -Bool -KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure); - -void -KdUnregisterFds (void *closure, Bool do_close); - -void -KdUnregisterFd (void *closure, int fd, Bool do_close); - -void -KdEnqueueKeyboardEvent(KdKeyboardInfo *ki, unsigned char scan_code, - unsigned char is_up); - -#define KD_BUTTON_1 0x01 -#define KD_BUTTON_2 0x02 -#define KD_BUTTON_3 0x04 -#define KD_BUTTON_4 0x08 -#define KD_BUTTON_5 0x10 -#define KD_BUTTON_8 0x80 -#define KD_MOUSE_DELTA 0x80000000 - -void -KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry, - int rz); - -void -_KdEnqueuePointerEvent(KdPointerInfo *pi, int type, int x, int y, int z, - int b, int absrel, Bool force); - -void -KdReleaseAllKeys (void); - -void -KdSetLed (KdKeyboardInfo *ki, int led, Bool on); - -void -KdSetPointerMatrix (KdPointerMatrix *pointer); - -void -KdComputePointerMatrix (KdPointerMatrix *pointer, Rotation randr, int width, int height); - -void -KdScreenToPointerCoords (int *x, int *y); - -void -KdBlockHandler (int screen, - pointer blockData, - pointer timeout, - pointer readmask); - -void -KdWakeupHandler (int screen, - pointer data, - unsigned long result, - pointer readmask); - -void -KdDisableInput (void); - -void -KdEnableInput (void); - -void -ProcessInputEvents (void); - -void -KdRingBell (KdKeyboardInfo *ki, - int volume, - int pitch, - int duration); - -/* kmode.c */ -const KdMonitorTiming * -KdFindMode (KdScreenInfo *screen, - Bool (*supported) (KdScreenInfo *, - const KdMonitorTiming *)); - -Bool -KdTuneMode (KdScreenInfo *screen, - Bool (*usable) (KdScreenInfo *), - Bool (*supported) (KdScreenInfo *, - const KdMonitorTiming *)); - -#ifdef RANDR -Bool -KdRandRGetInfo (ScreenPtr pScreen, - int randr, - Bool (*supported) (ScreenPtr pScreen, - const KdMonitorTiming *)); - -const KdMonitorTiming * -KdRandRGetTiming (ScreenPtr pScreen, - Bool (*supported) (ScreenPtr pScreen, - const KdMonitorTiming *), - int rate, - RRScreenSizePtr pSize); -#endif - -/* kshadow.c */ -Bool -KdShadowFbAlloc (KdScreenInfo *screen, Bool rotate); - -void -KdShadowFbFree (KdScreenInfo *screen); - -Bool -KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window); - -void -KdShadowUnset (ScreenPtr pScreen); - -/* function prototypes to be implemented by the drivers */ -void -InitCard (char *name); - -#endif /* _KDRIVE_H_ */ +/*
+ * Copyright 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _KDRIVE_H_
+#define _KDRIVE_H_
+
+#include <stdio.h>
+#include <string.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "mibstore.h"
+#include "colormapst.h"
+#include "gcstruct.h"
+#include "input.h"
+#include "mipointer.h"
+#include "mi.h"
+#include "dix.h"
+#include "fb.h"
+#include "fboverlay.h"
+#include "shadow.h"
+#include "randrstr.h"
+#include "globals.h"
+
+#include "xkbstr.h"
+
+#define KD_DPMS_NORMAL 0
+#define KD_DPMS_STANDBY 1
+#define KD_DPMS_SUSPEND 2
+#define KD_DPMS_POWERDOWN 3
+#define KD_DPMS_MAX KD_DPMS_POWERDOWN
+
+#define Status int
+
+typedef struct _KdCardInfo {
+ struct _KdCardFuncs *cfuncs;
+ void *closure;
+ void *driver;
+ struct _KdScreenInfo *screenList;
+ int selected;
+ struct _KdCardInfo *next;
+} KdCardInfo;
+
+extern KdCardInfo *kdCardInfo;
+
+/*
+ * Configuration information per X screen
+ */
+typedef struct _KdFrameBuffer {
+ CARD8 *frameBuffer;
+ int depth;
+ int bitsPerPixel;
+ int pixelStride;
+ int byteStride;
+ Bool shadow;
+ unsigned long visuals;
+ Pixel redMask, greenMask, blueMask;
+ void *closure;
+} KdFrameBuffer;
+
+#define RR_Rotate_All (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270)
+#define RR_Reflect_All (RR_Reflect_X|RR_Reflect_Y)
+
+typedef struct _KdScreenInfo {
+ struct _KdScreenInfo *next;
+ KdCardInfo *card;
+ ScreenPtr pScreen;
+ void *driver;
+ Rotation randr; /* rotation and reflection */
+ int width;
+ int height;
+ int rate;
+ int width_mm;
+ int height_mm;
+ int subpixel_order;
+ Bool dumb;
+ Bool softCursor;
+ int mynum;
+ DDXPointRec origin;
+ KdFrameBuffer fb;
+} KdScreenInfo;
+
+typedef struct _KdCardFuncs {
+ Bool (*cardinit) (KdCardInfo *); /* detect and map device */
+ Bool (*scrinit) (KdScreenInfo *);/* initialize screen information */
+ Bool (*initScreen) (ScreenPtr); /* initialize ScreenRec */
+ Bool (*finishInitScreen) (ScreenPtr pScreen);
+ Bool (*createRes) (ScreenPtr); /* create screen resources */
+ void (*preserve) (KdCardInfo *); /* save graphics card state */
+ Bool (*enable) (ScreenPtr); /* set up for rendering */
+ Bool (*dpms) (ScreenPtr, int); /* set DPMS screen saver */
+ void (*disable) (ScreenPtr); /* turn off rendering */
+ void (*restore) (KdCardInfo *); /* restore graphics card state */
+ void (*scrfini) (KdScreenInfo *);/* close down screen */
+ void (*cardfini) (KdCardInfo *); /* close down */
+
+ Bool (*initCursor) (ScreenPtr); /* detect and map cursor */
+ void (*enableCursor) (ScreenPtr); /* enable cursor */
+ void (*disableCursor) (ScreenPtr); /* disable cursor */
+ void (*finiCursor) (ScreenPtr); /* close down */
+ void (*recolorCursor) (ScreenPtr, int, xColorItem *);
+
+ Bool (*initAccel) (ScreenPtr);
+ void (*enableAccel) (ScreenPtr);
+ void (*disableAccel) (ScreenPtr);
+ void (*finiAccel) (ScreenPtr);
+
+ void (*getColors) (ScreenPtr, int, xColorItem *);
+ void (*putColors) (ScreenPtr, int, xColorItem *);
+
+} KdCardFuncs;
+
+#define KD_MAX_PSEUDO_DEPTH 8
+#define KD_MAX_PSEUDO_SIZE (1 << KD_MAX_PSEUDO_DEPTH)
+
+typedef struct {
+ KdScreenInfo *screen;
+ KdCardInfo *card;
+
+ Bool enabled;
+ Bool closed;
+ int bytesPerPixel;
+
+ int dpmsState;
+
+ ColormapPtr pInstalledmap; /* current colormap */
+ xColorItem systemPalette[KD_MAX_PSEUDO_SIZE];/* saved windows colors */
+
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ CloseScreenProcPtr CloseScreen;
+} KdPrivScreenRec, *KdPrivScreenPtr;
+
+typedef enum _kdPointerState {
+ start,
+ button_1_pend,
+ button_1_down,
+ button_2_down,
+ button_3_pend,
+ button_3_down,
+ synth_2_down_13,
+ synth_2_down_3,
+ synth_2_down_1,
+ num_input_states
+} KdPointerState;
+
+#define KD_MAX_BUTTON 32
+
+#define KD_KEYBOARD 1
+#define KD_MOUSE 2
+#define KD_TOUCHSCREEN 3
+
+typedef struct _KdPointerInfo KdPointerInfo;
+
+typedef struct _KdPointerDriver {
+ char *name;
+ Status (*Init) (KdPointerInfo *);
+ Status (*Enable) (KdPointerInfo *);
+ void (*Disable) (KdPointerInfo *);
+ void (*Fini) (KdPointerInfo *);
+ struct _KdPointerDriver *next;
+} KdPointerDriver;
+
+struct _KdPointerInfo {
+ DeviceIntPtr dixdev;
+ char *name;
+ char *path;
+ char *protocol;
+ InputOption *options;
+ int inputClass;
+
+ CARD8 map[KD_MAX_BUTTON + 1];
+ int nButtons;
+ int nAxes;
+
+ Bool emulateMiddleButton;
+ unsigned long emulationTimeout;
+ int emulationDx, emulationDy;
+
+ Bool timeoutPending;
+ KdPointerState mouseState;
+ Bool eventHeld;
+ struct {
+ int type;
+ int x;
+ int y;
+ int z;
+ int flags;
+ int absrel;
+ } heldEvent;
+ unsigned char buttonState;
+ Bool transformCoordinates;
+ int pressureThreshold;
+
+ KdPointerDriver *driver;
+ void *driverPrivate;
+
+ struct _KdPointerInfo *next;
+};
+
+extern int KdCurScreen;
+
+void KdAddPointerDriver (KdPointerDriver *driver);
+void KdRemovePointerDriver (KdPointerDriver *driver);
+KdPointerInfo *KdNewPointer (void);
+void KdFreePointer (KdPointerInfo *);
+int KdAddPointer (KdPointerInfo *ki);
+int KdAddConfigPointer (char *pointer);
+void KdRemovePointer (KdPointerInfo *ki);
+
+
+#define KD_KEY_COUNT 248
+#define KD_MIN_KEYCODE 8
+#define KD_MAX_KEYCODE 255
+#define KD_MAX_WIDTH 4
+#define KD_MAX_LENGTH (KD_MAX_KEYCODE - KD_MIN_KEYCODE + 1)
+
+typedef struct {
+ KeySym modsym;
+ int modbit;
+} KdKeySymModsRec;
+
+typedef struct _KdKeyboardInfo KdKeyboardInfo;
+
+typedef struct _KdKeyboardDriver {
+ char *name;
+ Bool (*Init) (KdKeyboardInfo *);
+ Bool (*Enable) (KdKeyboardInfo *);
+ void (*Leds) (KdKeyboardInfo *, int);
+ void (*Bell) (KdKeyboardInfo *, int, int, int);
+ void (*Disable) (KdKeyboardInfo *);
+ void (*Fini) (KdKeyboardInfo *);
+ struct _KdKeyboardDriver *next;
+} KdKeyboardDriver;
+
+struct _KdKeyboardInfo {
+ struct _KdKeyboardInfo *next;
+ DeviceIntPtr dixdev;
+ void *closure;
+ char *name;
+ char *path;
+ int inputClass;
+ char *xkbRules;
+ char *xkbModel;
+ char *xkbLayout;
+ char *xkbVariant;
+ char *xkbOptions;
+ int LockLed;
+
+ int minScanCode;
+ int maxScanCode;
+
+ int leds;
+ int bellPitch;
+ int bellDuration;
+ InputOption *options;
+
+ KdKeyboardDriver *driver;
+ void *driverPrivate;
+};
+
+void KdAddKeyboardDriver (KdKeyboardDriver *driver);
+void KdRemoveKeyboardDriver (KdKeyboardDriver *driver);
+KdKeyboardInfo *KdNewKeyboard (void);
+void KdFreeKeyboard (KdKeyboardInfo *ki);
+int KdAddConfigKeyboard (char *pointer);
+int KdAddKeyboard (KdKeyboardInfo *ki);
+void KdRemoveKeyboard (KdKeyboardInfo *ki);
+
+typedef struct _KdOsFuncs {
+ int (*Init) (void);
+ void (*Enable) (void);
+ Bool (*SpecialKey) (KeySym);
+ void (*Disable) (void);
+ void (*Fini) (void);
+ void (*pollEvents) (void);
+ void (*Bell) (int, int, int);
+} KdOsFuncs;
+
+typedef enum _KdSyncPolarity {
+ KdSyncNegative, KdSyncPositive
+} KdSyncPolarity;
+
+typedef struct _KdMonitorTiming {
+ /* label */
+ int horizontal;
+ int vertical;
+ int rate;
+ /* pixel clock */
+ int clock; /* in KHz */
+ /* horizontal timing */
+ int hfp; /* front porch */
+ int hbp; /* back porch */
+ int hblank; /* blanking */
+ KdSyncPolarity hpol; /* polarity */
+ /* vertical timing */
+ int vfp; /* front porch */
+ int vbp; /* back porch */
+ int vblank; /* blanking */
+ KdSyncPolarity vpol; /* polarity */
+} KdMonitorTiming;
+
+extern const KdMonitorTiming kdMonitorTimings[];
+extern const int kdNumMonitorTimings;
+
+typedef struct _KdPointerMatrix {
+ int matrix[2][3];
+} KdPointerMatrix;
+
+/*
+ * This is the only completely portable way to
+ * compute this info.
+ */
+
+#ifndef BitsPerPixel
+#define BitsPerPixel(d) (\
+ PixmapWidthPaddingInfo[d].notPower2 ? \
+ (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
+ ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
+ (PixmapWidthPaddingInfo[d].padRoundUp+1)))
+#endif
+
+extern DevPrivateKeyRec kdScreenPrivateKeyRec;
+#define kdScreenPrivateKey (&kdScreenPrivateKeyRec)
+
+extern unsigned long kdGeneration;
+extern Bool kdEnabled;
+extern Bool kdSwitchPending;
+extern Bool kdEmulateMiddleButton;
+extern Bool kdDisableZaphod;
+extern Bool kdAllowZap;
+extern int kdVirtualTerminal;
+extern char *kdSwitchCmd;
+extern KdOsFuncs *kdOsFuncs;
+
+#define KdGetScreenPriv(pScreen) ((KdPrivScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey))
+#define KdSetScreenPriv(pScreen,v) \
+ dixSetPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey, v)
+#define KdScreenPriv(pScreen) KdPrivScreenPtr pScreenPriv = KdGetScreenPriv(pScreen)
+
+/* kcmap.c */
+void
+KdSetColormap (ScreenPtr pScreen);
+
+void
+KdEnableColormap (ScreenPtr pScreen);
+
+void
+KdDisableColormap (ScreenPtr pScreen);
+
+void
+KdInstallColormap (ColormapPtr pCmap);
+
+void
+KdUninstallColormap (ColormapPtr pCmap);
+
+int
+KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps);
+
+void
+KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs);
+
+/* kdrive.c */
+extern miPointerScreenFuncRec kdPointerScreenFuncs;
+
+void
+KdSetRootClip (ScreenPtr pScreen, BOOL enable);
+
+void
+KdDisableScreen (ScreenPtr pScreen);
+
+void
+KdDisableScreens (void);
+
+Bool
+KdEnableScreen (ScreenPtr pScreen);
+
+void
+KdEnableScreens (void);
+
+void
+KdSuspend (void);
+
+void
+KdResume (void);
+
+void
+KdProcessSwitch (void);
+
+Rotation
+KdAddRotation (Rotation a, Rotation b);
+
+Rotation
+KdSubRotation (Rotation a, Rotation b);
+
+void
+KdParseScreen (KdScreenInfo *screen,
+ char *arg);
+
+KdPointerInfo *
+KdParsePointer (char *arg);
+
+KdKeyboardInfo *
+KdParseKeyboard (char *arg);
+
+char *
+KdParseFindNext (char *cur, char *delim, char *save, char *last);
+
+void
+KdParseRgba (char *rgba);
+
+void
+KdUseMsg (void);
+
+int
+KdProcessArgument (int argc, char **argv, int i);
+
+void
+KdOsInit (KdOsFuncs *pOsFuncs);
+
+void
+KdOsAddInputDrivers (void);
+
+Bool
+KdAllocatePrivates (ScreenPtr pScreen);
+
+Bool
+KdCreateScreenResources (ScreenPtr pScreen);
+
+Bool
+KdCloseScreen (int index, ScreenPtr pScreen);
+
+Bool
+KdSaveScreen (ScreenPtr pScreen, int on);
+
+Bool
+KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv);
+
+void
+KdInitScreen (ScreenInfo *pScreenInfo,
+ KdScreenInfo *screen,
+ int argc,
+ char **argv);
+
+void
+KdInitCard (ScreenInfo *pScreenInfo,
+ KdCardInfo *card,
+ int argc,
+ char **argv);
+
+void
+KdInitOutput (ScreenInfo *pScreenInfo,
+ int argc,
+ char **argv);
+
+void
+KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr);
+
+void
+KdBacktrace (int signum);
+
+/* kinfo.c */
+KdCardInfo *
+KdCardInfoAdd (KdCardFuncs *funcs,
+ void *closure);
+
+KdCardInfo *
+KdCardInfoLast (void);
+
+void
+KdCardInfoDispose (KdCardInfo *ci);
+
+KdScreenInfo *
+KdScreenInfoAdd (KdCardInfo *ci);
+
+void
+KdScreenInfoDispose (KdScreenInfo *si);
+
+
+/* kinput.c */
+void
+KdInitInput(void);
+
+void
+KdAddPointerDriver(KdPointerDriver *);
+
+void
+KdAddKeyboardDriver(KdKeyboardDriver *);
+
+Bool
+KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure);
+
+void
+KdUnregisterFds (void *closure, Bool do_close);
+
+void
+KdUnregisterFd (void *closure, int fd, Bool do_close);
+
+void
+KdEnqueueKeyboardEvent(KdKeyboardInfo *ki, unsigned char scan_code,
+ unsigned char is_up);
+
+#define KD_BUTTON_1 0x01
+#define KD_BUTTON_2 0x02
+#define KD_BUTTON_3 0x04
+#define KD_BUTTON_4 0x08
+#define KD_BUTTON_5 0x10
+#define KD_BUTTON_8 0x80
+#define KD_MOUSE_DELTA 0x80000000
+
+void
+KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
+ int rz);
+
+void
+_KdEnqueuePointerEvent(KdPointerInfo *pi, int type, int x, int y, int z,
+ int b, int absrel, Bool force);
+
+void
+KdReleaseAllKeys (void);
+
+void
+KdSetLed (KdKeyboardInfo *ki, int led, Bool on);
+
+void
+KdSetPointerMatrix (KdPointerMatrix *pointer);
+
+void
+KdComputePointerMatrix (KdPointerMatrix *pointer, Rotation randr, int width, int height);
+
+void
+KdScreenToPointerCoords (int *x, int *y);
+
+void
+KdBlockHandler (int screen,
+ pointer blockData,
+ pointer timeout,
+ pointer readmask);
+
+void
+KdWakeupHandler (int screen,
+ pointer data,
+ unsigned long result,
+ pointer readmask);
+
+void
+KdDisableInput (void);
+
+void
+KdEnableInput (void);
+
+void
+ProcessInputEvents (void);
+
+void
+KdRingBell (KdKeyboardInfo *ki,
+ int volume,
+ int pitch,
+ int duration);
+
+/* kmode.c */
+const KdMonitorTiming *
+KdFindMode (KdScreenInfo *screen,
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *));
+
+Bool
+KdTuneMode (KdScreenInfo *screen,
+ Bool (*usable) (KdScreenInfo *),
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *));
+
+#ifdef RANDR
+Bool
+KdRandRGetInfo (ScreenPtr pScreen,
+ int randr,
+ Bool (*supported) (ScreenPtr pScreen,
+ const KdMonitorTiming *));
+
+const KdMonitorTiming *
+KdRandRGetTiming (ScreenPtr pScreen,
+ Bool (*supported) (ScreenPtr pScreen,
+ const KdMonitorTiming *),
+ int rate,
+ RRScreenSizePtr pSize);
+#endif
+
+/* kshadow.c */
+Bool
+KdShadowFbAlloc (KdScreenInfo *screen, Bool rotate);
+
+void
+KdShadowFbFree (KdScreenInfo *screen);
+
+Bool
+KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window);
+
+void
+KdShadowUnset (ScreenPtr pScreen);
+
+/* function prototypes to be implemented by the drivers */
+void
+InitCard (char *name);
+
+#endif /* _KDRIVE_H_ */
diff --git a/xorg-server/hw/kdrive/src/kxv.c b/xorg-server/hw/kdrive/src/kxv.c index 9fef34d1f..cf960e62b 100644 --- a/xorg-server/hw/kdrive/src/kxv.c +++ b/xorg-server/hw/kdrive/src/kxv.c @@ -103,10 +103,9 @@ static void KdXVClipNotify(WindowPtr pWin, int dx, int dy); /* misc */
static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr*, int);
-static int KdXVWindowKeyIndex;
-DevPrivateKey KdXVWindowKey = &KdXVWindowKeyIndex;
-static int KdXvScreenKeyIndex;
-DevPrivateKey KdXvScreenKey = &KdXvScreenKeyIndex;
+static DevPrivateKeyRec KdXVWindowKeyRec;
+#define KdXVWindowKey (&KdXVWindowKeyRec)
+static DevPrivateKey KdXvScreenKey;
static unsigned long KdXVGeneration = 0;
static unsigned long PortResource = 0;
@@ -199,6 +198,9 @@ KdXVScreenInit( if(!XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
return FALSE;
+ if (!dixRegisterPrivateKey(&KdXVWindowKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
KdXvScreenKey = (*XvGetScreenKeyProc)();
@@ -268,9 +270,9 @@ KdXVFreeAdaptor(XvAdaptorPtr pAdaptor) pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
if(pPriv) {
if(pPriv->clientClip)
- REGION_DESTROY(pAdaptor->pScreen, pPriv->clientClip);
+ RegionDestroy(pPriv->clientClip);
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- REGION_DESTROY(pAdaptor->pScreen, pPriv->pCompositeClip);
+ RegionDestroy(pPriv->pCompositeClip);
free(pPriv);
}
}
@@ -607,18 +609,18 @@ KdXVUpdateCompositeClip(XvPortRecPrivatePtr portPriv) return;
}
- pCompositeClip = REGION_CREATE(pWin->pScreen, NullBox, 1);
- REGION_COPY(pWin->pScreen, pCompositeClip, portPriv->clientClip);
- REGION_TRANSLATE(pWin->pScreen, pCompositeClip,
+ pCompositeClip = RegionCreate(NullBox, 1);
+ RegionCopy(pCompositeClip, portPriv->clientClip);
+ RegionTranslate(pCompositeClip,
portPriv->pDraw->x + portPriv->clipOrg.x,
portPriv->pDraw->y + portPriv->clipOrg.y);
- REGION_INTERSECT(pWin->pScreen, pCompositeClip, pregWin, pCompositeClip);
+ RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
portPriv->pCompositeClip = pCompositeClip;
portPriv->FreeCompositeClip = TRUE;
if(freeCompClip) {
- REGION_DESTROY(pWin->pScreen, pregWin);
+ RegionDestroy(pregWin);
}
}
@@ -633,17 +635,17 @@ KdXVCopyClip( /* copy the new clip if it exists */
if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
if(!portPriv->clientClip)
- portPriv->clientClip = REGION_CREATE(pGC->pScreen, NullBox, 1);
+ portPriv->clientClip = RegionCreate(NullBox, 1);
/* Note: this is in window coordinates */
- REGION_COPY(pGC->pScreen, portPriv->clientClip, pGC->clientClip);
+ RegionCopy(portPriv->clientClip, pGC->clientClip);
} else if(portPriv->clientClip) { /* free the old clientClip */
- REGION_DESTROY(pGC->pScreen, portPriv->clientClip);
+ RegionDestroy(portPriv->clientClip);
portPriv->clientClip = NULL;
}
/* get rid of the old clip list */
if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
- REGION_DESTROY(pWin->pScreen, portPriv->pCompositeClip);
+ RegionDestroy(portPriv->pCompositeClip);
}
portPriv->clipOrg = pGC->clipOrg;
@@ -670,18 +672,18 @@ KdXVRegetVideo(XvPortRecPrivatePtr portPriv) WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
- REGION_INIT(portPriv->pDraw->pScreen, &WinRegion, &WinBox, 1);
- REGION_INIT(portPriv->pDraw->pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(portPriv->pDraw->pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* that's all if it's totally obscured */
- if(!REGION_NOTEMPTY(portPriv->pDraw->pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(portPriv->pDraw->pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->screen, portPriv->pDraw,
@@ -706,8 +708,8 @@ CLIP_VIDEO_BAILOUT: if(!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
- REGION_UNINIT(portPriv->pDraw->pScreen, &WinRegion);
- REGION_UNINIT(portPriv->pDraw->pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -734,9 +736,9 @@ KdXVReputVideo(XvPortRecPrivatePtr portPriv) WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* clip and translate to the viewport */
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -748,21 +750,21 @@ KdXVReputVideo(XvPortRecPrivatePtr portPriv) VPBox.x2 = screen->width;
VPBox.y2 = screen->height;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
/* that's all if it's totally obscured */
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
/* bailout if we have to clip but the hardware doesn't support it */
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -772,7 +774,7 @@ KdXVReputVideo(XvPortRecPrivatePtr portPriv) }
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->screen, portPriv->pDraw,
@@ -796,8 +798,8 @@ CLIP_VIDEO_BAILOUT: if(!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -823,9 +825,9 @@ KdXVReputImage(XvPortRecPrivatePtr portPriv) WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* clip and translate to the viewport */
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -837,21 +839,21 @@ KdXVReputImage(XvPortRecPrivatePtr portPriv) VPBox.x2 = screen->width;
VPBox.y2 = screen->height;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
/* that's all if it's totally obscured */
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
/* bailout if we have to clip but the hardware doesn't support it */
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -861,7 +863,7 @@ KdXVReputImage(XvPortRecPrivatePtr portPriv) }
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->screen, portPriv->pDraw,
@@ -882,8 +884,8 @@ CLIP_VIDEO_BAILOUT: if(!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1021,7 +1023,7 @@ KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) XvPortRecPrivatePtr pPriv;
Bool AreasExposed;
- AreasExposed = (WinPriv && reg1 && REGION_NOTEMPTY(pScreen, reg1));
+ AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
pScreen->WindowExposures = ScreenPriv->WindowExposures;
(*pScreen->WindowExposures)(pWin, reg1, reg2);
@@ -1089,7 +1091,7 @@ KdXVClipNotify(WindowPtr pWin, int dx, int dy) pPriv = WinPriv->PortRec;
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+ RegionDestroy(pPriv->pCompositeClip);
pPriv->pCompositeClip = NULL;
@@ -1171,7 +1173,7 @@ KdXVQueryAdaptors( *p_nAdaptors = pxvs->nAdaptors;
*p_pAdaptors = pxvs->pAdaptors;
- return (Success);
+ return Success;
}
static Bool
@@ -1220,7 +1222,7 @@ KdXVDisable(ScreenPtr pScreen) pPriv->isOn = XV_OFF;
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+ RegionDestroy(pPriv->pCompositeClip);
pPriv->pCompositeClip = NULL;
@@ -1330,9 +1332,9 @@ KdXVPutStill( WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
@@ -1343,23 +1345,23 @@ KdXVPutStill( VPBox.x2 = screen->width;
VPBox.y2 = screen->height;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
if(portPriv->pDraw) {
KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
}
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto PUT_STILL_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -1369,7 +1371,7 @@ KdXVPutStill( }
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutStill)(portPriv->screen, pDraw,
@@ -1398,8 +1400,8 @@ PUT_STILL_BAILOUT: portPriv->isOn = XV_PENDING;
}
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1483,21 +1485,21 @@ KdXVGetStill( WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->pDraw) {
KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
}
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto GET_STILL_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->GetStill)(portPriv->screen, pDraw,
@@ -1513,8 +1515,8 @@ GET_STILL_BAILOUT: portPriv->isOn = XV_PENDING;
}
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1630,9 +1632,9 @@ KdXVPutImage( WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
@@ -1643,23 +1645,23 @@ KdXVPutImage( VPBox.x2 = pScreen->width;
VPBox.y2 = pScreen->height;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
if(portPriv->pDraw) {
KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
}
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto PUT_IMAGE_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -1669,7 +1671,7 @@ KdXVPutImage( }
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutImage)(portPriv->screen, pDraw,
@@ -1698,8 +1700,8 @@ PUT_IMAGE_BAILOUT: portPriv->isOn = XV_PENDING;
}
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1869,8 +1871,8 @@ KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg) GCPtr pGC;
ChangeGCVal val[2];
xRectangle *rects, *r;
- BoxPtr pBox = REGION_RECTS (pRgn);
- int nBox = REGION_NUM_RECTS (pRgn);
+ BoxPtr pBox = RegionRects (pRgn);
+ int nBox = RegionNumRects (pRgn);
rects = malloc(nBox * sizeof (xRectangle));
if (!rects)
@@ -1897,7 +1899,7 @@ KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg) ValidateGC (pDraw, pGC);
(*pGC->ops->PolyFillRect) (pDraw, pGC,
- REGION_NUM_RECTS (pRgn), rects);
+ RegionNumRects (pRgn), rects);
FreeScratchGC (pGC);
bail1:
diff --git a/xorg-server/hw/vfb/InitOutput.c b/xorg-server/hw/vfb/InitOutput.c index 30e68e5d3..0172f4fbf 100644 --- a/xorg-server/hw/vfb/InitOutput.c +++ b/xorg-server/hw/vfb/InitOutput.c @@ -389,8 +389,8 @@ ddxProcessArgument(int argc, char *argv[], int i) return 0;
}
-static int cmapScrPrivateKeyIndex;
-static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex;
+static DevPrivateKeyRec cmapScrPrivateKeyRec;
+#define cmapScrPrivateKey (&cmapScrPrivateKeyRec)
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))
@@ -401,7 +401,7 @@ vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) /* By the time we are processing requests, we can guarantee that there
* is always a colormap installed */
*pmaps = GetInstalledColormap(pScreen)->mid;
- return (1);
+ return 1;
}
@@ -570,7 +570,7 @@ vfbAllocateMmappedFramebuffer(vfbScreenInfoPtr pvfb) /* Extend the file to be the proper size */
- bzero(dummyBuffer, DUMMY_BUFFER_SIZE);
+ memset(dummyBuffer, 0, DUMMY_BUFFER_SIZE);
for (currentFileSize = 0;
currentFileSize < pvfb->sizeInBytes;
currentFileSize += writeThisTime)
@@ -811,6 +811,9 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) int ret;
char *pbits;
+ if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
if (dpix == 0)
dpix = 100;
diff --git a/xorg-server/hw/xfree86/common/xf86.h b/xorg-server/hw/xfree86/common/xf86.h index b7a884b2a..b21bcdf47 100644 --- a/xorg-server/hw/xfree86/common/xf86.h +++ b/xorg-server/hw/xfree86/common/xf86.h @@ -55,9 +55,16 @@ extern _X_EXPORT int xf86DoConfigure;
extern _X_EXPORT int xf86DoShowOptions;
extern _X_EXPORT Bool xf86DoConfigurePass1;
-extern _X_EXPORT DevPrivateKey xf86ScreenKey;
-extern _X_EXPORT DevPrivateKey xf86CreateRootWindowKey;
-extern _X_EXPORT DevPrivateKey xf86PixmapKey;
+
+extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec;
+#define xf86ScreenKey (&xf86ScreenKeyRec)
+
+extern _X_EXPORT DevPrivateKeyRec xf86CreateRootWindowKeyRec;
+#define xf86CreateRootWindowKey (&xf86CreateRootWindowKeyRec)
+
+extern _X_EXPORT DevPrivateKeyRec xf86PixmapKeyRec;
+#define xf86PixmapKey (&xf86PixmapKeyRec)
+
extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
extern _X_EXPORT const unsigned char byte_reversed[256];
extern _X_EXPORT Bool fbSlotClaimed;
diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c index 9f6348681..a00340191 100644 --- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c +++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c @@ -120,8 +120,7 @@ FreeList(const char ***list, int *lines) int i;
for (i = 0; i < *lines; i++) {
- if ((*list)[i])
- free((*list)[i]);
+ free((*list)[i]);
}
free(*list);
*list = NULL;
@@ -186,7 +185,7 @@ xf86AutoConfig(void) if (ret != CONFIG_OK)
xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n");
- return (ret == CONFIG_OK);
+ return ret == CONFIG_OK;
}
static void
@@ -257,7 +256,7 @@ listPossibleVideoDrivers(char *matches[], int nmatches) }
#endif
- xf86PciMatchDriver(matches, nmatches);
+ i = xf86PciMatchDriver(matches, nmatches);
/* Fallback to platform default hardware */
if (i < (nmatches - 1)) {
diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c index 77693d742..bec2343b2 100644 --- a/xorg-server/hw/xfree86/common/xf86Bus.c +++ b/xorg-server/hw/xfree86/common/xf86Bus.c @@ -245,7 +245,7 @@ xf86AllocateEntity(void) xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec));
xf86Entities[xf86NumEntities - 1]->entityPrivates =
xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
- return (xf86NumEntities - 1);
+ return xf86NumEntities - 1;
}
Bool
@@ -257,9 +257,9 @@ xf86IsEntityPrimary(int entityIndex) switch (pEnt->bus.type) {
case BUS_PCI:
- return (pEnt->bus.id.pci == primaryBus.id.pci);
+ return pEnt->bus.id.pci == primaryBus.id.pci;
case BUS_SBUS:
- return (pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum);
+ return pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum;
default:
return FALSE;
}
@@ -342,7 +342,7 @@ xf86FindScreenForEntity(int entityIndex) for (i = 0; i < xf86NumScreens; i++) {
for (j = 0; j < xf86Screens[i]->numEntities; j++) {
if ( xf86Screens[i]->entityList[j] == entityIndex )
- return (xf86Screens[i]);
+ return xf86Screens[i];
}
}
}
@@ -557,7 +557,7 @@ int xf86GetLastScrnFlag(int entityIndex)
{
if(entityIndex < xf86NumEntities) {
- return(xf86Entities[entityIndex]->lastScrnFlag);
+ return xf86Entities[entityIndex]->lastScrnFlag;
} else {
return -1;
}
@@ -654,7 +654,7 @@ xf86AllocateEntityPrivateIndex(void) nprivs = xnfrealloc(pEnt->entityPrivates,
xf86EntityPrivateCount * sizeof(DevUnion));
/* Zero the new private */
- bzero(&nprivs[idx], sizeof(DevUnion));
+ memset(&nprivs[idx], 0, sizeof(DevUnion));
pEnt->entityPrivates = nprivs;
}
return idx;
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c index 33b38930f..0b1c767fb 100644 --- a/xorg-server/hw/xfree86/common/xf86Config.c +++ b/xorg-server/hw/xfree86/common/xf86Config.c @@ -163,7 +163,7 @@ xf86GetPathElem(char **pnt) **pnt = '\0';
*pnt += 1;
}
- return(p1);
+ return p1;
}
/*
@@ -239,7 +239,7 @@ xf86ValidateFontPath(char *path) strcat(out_pnt, path_elem);
out_pnt += strlen(path_elem);
}
- return(tmp_path);
+ return tmp_path;
}
@@ -1252,7 +1252,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) /* 5. Built-in default. */
if (!foundPointer && !xf86Info.allowEmptyInput) {
- bzero(&defPtr, sizeof(defPtr));
+ memset(&defPtr, 0, sizeof(defPtr));
defPtr.inp_identifier = strdup("<default pointer>");
defPtr.inp_driver = strdup("mouse");
confInput = &defPtr;
@@ -1303,7 +1303,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) }
if (!found && !xf86Info.allowEmptyInput) {
xf86Msg(X_INFO, "No default mouse found, adding one\n");
- bzero(&defPtr, sizeof(defPtr));
+ memset(&defPtr, 0, sizeof(defPtr));
defPtr.inp_identifier = strdup("<default pointer>");
defPtr.inp_driver = strdup("mouse");
confInput = &defPtr;
@@ -1392,7 +1392,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) /* 5. Built-in default. */
if (!foundKeyboard && !xf86Info.allowEmptyInput) {
- bzero(&defKbd, sizeof(defKbd));
+ memset(&defKbd, 0, sizeof(defKbd));
defKbd.inp_identifier = strdup("<default keyboard>");
defKbd.inp_driver = strdup("kbd");
confInput = &defKbd;
@@ -1851,7 +1851,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, if (!conf_screen->scrn_monitor) {
XF86ConfMonitorRec defMon;
- bzero(&defMon, sizeof(defMon));
+ memset(&defMon, 0, sizeof(defMon));
defMon.mon_identifier = "<default monitor>";
if (!configMonitor(screenp->monitor, &defMon))
return FALSE;
@@ -2330,6 +2330,7 @@ configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from) inputp->driver = conf_input->inp_driver;
inputp->commonOptions = conf_input->inp_option_lst;
inputp->extraOptions = NULL;
+ inputp->attrs = NULL;
return TRUE;
}
diff --git a/xorg-server/hw/xfree86/common/xf86Cursor.c b/xorg-server/hw/xfree86/common/xf86Cursor.c index 76490e52d..acfa79f10 100644 --- a/xorg-server/hw/xfree86/common/xf86Cursor.c +++ b/xorg-server/hw/xfree86/common/xf86Cursor.c @@ -581,7 +581,7 @@ xf86InitOrigins(void) {
unsigned long screensLeft, prevScreensLeft, mask;
screenLayoutPtr screen;
- ScreenPtr pScreen;
+ ScreenPtr pScreen, refScreen;
int x1, x2, y1, y2, left, right, top, bottom;
int i, j, ref, minX, minY, min, max;
xf86ScreenLayoutPtr pLayout;
@@ -590,7 +590,7 @@ xf86InitOrigins(void) /* need to have this set up with a config file option */
HardEdges = FALSE;
- bzero(xf86ScreenLayout, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
+ memset(xf86ScreenLayout, 0, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1;
@@ -608,6 +608,7 @@ xf86InitOrigins(void) continue;
}
+ pScreen = xf86Screens[i]->pScreen;
switch(screen->where) {
case PosObsolete:
OldStyleConfig = TRUE;
@@ -620,7 +621,7 @@ xf86InitOrigins(void) break;
}
pLayout->left = AddEdge(pLayout->left,
- 0, xf86Screens[i]->pScreen->height,
+ 0, pScreen->height,
xf86Screens[ref]->pScreen->width, 0, ref);
}
if(screen->right) {
@@ -629,7 +630,6 @@ xf86InitOrigins(void) ErrorF("Referenced uninitialized screen in Layout!\n");
break;
}
- pScreen = xf86Screens[i]->pScreen;
pLayout->right = AddEdge(pLayout->right,
0, pScreen->height, -pScreen->width, 0, ref);
}
@@ -640,7 +640,7 @@ xf86InitOrigins(void) break;
}
pLayout->up = AddEdge(pLayout->up,
- 0, xf86Screens[i]->pScreen->width,
+ 0, pScreen->width,
0, xf86Screens[ref]->pScreen->height, ref);
}
if(screen->bottom) {
@@ -649,7 +649,6 @@ xf86InitOrigins(void) ErrorF("Referenced uninitialized screen in Layout!\n");
break;
}
- pScreen = xf86Screens[i]->pScreen;
pLayout->down = AddEdge(pLayout->down,
0, pScreen->width, 0, -pScreen->height, ref);
}
@@ -658,8 +657,8 @@ xf86InitOrigins(void) screen->x = screen->y = 0;
/* FALLTHROUGH */
case PosAbsolute:
- dixScreenOrigins[i].x = screen->x;
- dixScreenOrigins[i].y = screen->y;
+ pScreen->x = screen->x;
+ pScreen->y = screen->y;
screensLeft &= ~(1 << i);
break;
case PosRelative:
@@ -669,8 +668,9 @@ xf86InitOrigins(void) break;
}
if(screensLeft & (1 << ref)) break;
- dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->x;
- dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->y;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x + screen->x;
+ pScreen->y = refScreen->y + screen->y;
screensLeft &= ~(1 << i);
break;
case PosRightOf:
@@ -680,10 +680,9 @@ xf86InitOrigins(void) break;
}
if(screensLeft & (1 << ref)) break;
- pScreen = xf86Screens[ref]->pScreen;
- dixScreenOrigins[i].x =
- dixScreenOrigins[ref].x + pScreen->width;
- dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x + refScreen->width;
+ pScreen->y = refScreen->y;
screensLeft &= ~(1 << i);
break;
case PosLeftOf:
@@ -693,10 +692,9 @@ xf86InitOrigins(void) break;
}
if(screensLeft & (1 << ref)) break;
- pScreen = xf86Screens[i]->pScreen;
- dixScreenOrigins[i].x =
- dixScreenOrigins[ref].x - pScreen->width;
- dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x - pScreen->width;
+ pScreen->y = refScreen->y;
screensLeft &= ~(1 << i);
break;
case PosBelow:
@@ -706,10 +704,9 @@ xf86InitOrigins(void) break;
}
if(screensLeft & (1 << ref)) break;
- pScreen = xf86Screens[ref]->pScreen;
- dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
- dixScreenOrigins[i].y =
- dixScreenOrigins[ref].y + pScreen->height;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x;
+ pScreen->y = refScreen->y + refScreen->height;
screensLeft &= ~(1 << i);
break;
case PosAbove:
@@ -719,10 +716,9 @@ xf86InitOrigins(void) break;
}
if(screensLeft & (1 << ref)) break;
- pScreen = xf86Screens[i]->pScreen;
- dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
- dixScreenOrigins[i].y =
- dixScreenOrigins[ref].y - pScreen->height;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x;
+ pScreen->y = refScreen->y - pScreen->height;
screensLeft &= ~(1 << i);
break;
default:
@@ -741,7 +737,7 @@ xf86InitOrigins(void) while(!((1 << i) & screensLeft)){ i++; }
ref = xf86ConfigLayout.screens[i].refscreen->screennum;
- dixScreenOrigins[ref].x = dixScreenOrigins[ref].y = 0;
+ xf86Screens[ref]->pScreen->x = xf86Screens[ref]->pScreen->y = 0;
screensLeft &= ~(1 << ref);
}
@@ -749,20 +745,20 @@ xf86InitOrigins(void) }
/* justify the topmost and leftmost to (0,0) */
- minX = dixScreenOrigins[0].x;
- minY = dixScreenOrigins[0].y;
+ minX = xf86Screens[0]->pScreen->x;
+ minY = xf86Screens[0]->pScreen->y;
for(i = 1; i < xf86NumScreens; i++) {
- if(dixScreenOrigins[i].x < minX)
- minX = dixScreenOrigins[i].x;
- if(dixScreenOrigins[i].y < minY)
- minY = dixScreenOrigins[i].y;
+ if(xf86Screens[i]->pScreen->x < minX)
+ minX = xf86Screens[i]->pScreen->x;
+ if(xf86Screens[i]->pScreen->y < minY)
+ minY = xf86Screens[i]->pScreen->y;
}
if (minX || minY) {
for(i = 0; i < xf86NumScreens; i++) {
- dixScreenOrigins[i].x -= minX;
- dixScreenOrigins[i].y -= minY;
+ xf86Screens[i]->pScreen->x -= minX;
+ xf86Screens[i]->pScreen->y -= minY;
}
}
@@ -775,18 +771,20 @@ xf86InitOrigins(void) pScreen = xf86Screens[i]->pScreen;
- left = dixScreenOrigins[i].x;
+ left = pScreen->x;
right = left + pScreen->width;
- top = dixScreenOrigins[i].y;
+ top = pScreen->y;
bottom = top + pScreen->height;
for(j = 0; j < xf86NumScreens; j++) {
if(i == j) continue;
- x1 = dixScreenOrigins[j].x;
- x2 = x1 + xf86Screens[j]->pScreen->width;
- y1 = dixScreenOrigins[j].y;
- y2 = y1 + xf86Screens[j]->pScreen->height;
+ refScreen = xf86Screens[j]->pScreen;
+
+ x1 = refScreen->x;
+ x2 = x1 + refScreen->width;
+ y1 = refScreen->y;
+ y2 = y1 + refScreen->height;
if((bottom > y1) && (top < y2)) {
min = y1 - top;
@@ -796,13 +794,13 @@ xf86InitOrigins(void) if(((left - 1) >= x1) && ((left - 1) < x2))
pLayout->left = AddEdge(pLayout->left, min, max,
- dixScreenOrigins[i].x - dixScreenOrigins[j].x,
- dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
if((right >= x1) && (right < x2))
pLayout->right = AddEdge(pLayout->right, min, max,
- dixScreenOrigins[i].x - dixScreenOrigins[j].x,
- dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
}
@@ -814,13 +812,13 @@ xf86InitOrigins(void) if(((top - 1) >= y1) && ((top - 1) < y2))
pLayout->up = AddEdge(pLayout->up, min, max,
- dixScreenOrigins[i].x - dixScreenOrigins[j].x,
- dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
if((bottom >= y1) && (bottom < y2))
pLayout->down = AddEdge(pLayout->down, min, max,
- dixScreenOrigins[i].x - dixScreenOrigins[j].x,
- dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
}
}
}
@@ -850,10 +848,10 @@ xf86ReconfigureLayout(void) for (i = 0; i < MAXSCREENS; i++) {
xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i];
/* we don't have to zero these, xf86InitOrigins() takes care of that */
- if (sl->left) free(sl->left);
- if (sl->right) free(sl->right);
- if (sl->up) free(sl->up);
- if (sl->down) free(sl->down);
+ free(sl->left);
+ free(sl->right);
+ free(sl->up);
+ free(sl->down);
}
xf86InitOrigins();
diff --git a/xorg-server/hw/xfree86/common/xf86DGA.c b/xorg-server/hw/xfree86/common/xf86DGA.c index ac8302169..bc2aa3ba6 100644 --- a/xorg-server/hw/xfree86/common/xf86DGA.c +++ b/xorg-server/hw/xfree86/common/xf86DGA.c @@ -51,8 +51,8 @@ #include "mi.h"
-static int DGAScreenKeyIndex;
-static DevPrivateKey DGAScreenKey;
+static DevPrivateKeyRec DGAScreenKeyRec;
+#define DGAScreenKeyRegistered dixPrivateKeyRegistered(&DGAScreenKeyRec)
static int mieq_installed = 0;
static Bool DGACloseScreen(int i, ScreenPtr pScreen);
@@ -71,7 +71,7 @@ DGACopyModeInfo( int *XDGAEventBase = NULL;
#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \
- dixLookupPrivate(&(pScreen)->devPrivates, DGAScreenKey))
+ dixLookupPrivate(&(pScreen)->devPrivates, &DGAScreenKeyRec))
typedef struct _FakedVisualList{
@@ -118,7 +118,8 @@ DGAInit( if(!modes || num <= 0)
return FALSE;
- DGAScreenKey = &DGAScreenKeyIndex;
+ if (!dixRegisterPrivateKey(&DGAScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
@@ -126,7 +127,7 @@ DGAInit( {
if(!(pScreenPriv = (DGAScreenPtr)malloc(sizeof(DGAScreenRec))))
return FALSE;
- dixSetPrivate(&pScreen->devPrivates, DGAScreenKey, pScreenPriv);
+ dixSetPrivate(&pScreen->devPrivates, &DGAScreenKeyRec, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = DGACloseScreen;
pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
@@ -177,7 +178,7 @@ DGAReInitModes( int i;
/* No DGA? Ignore call (but don't make it look like it failed) */
- if(DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered)
return TRUE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
@@ -347,7 +348,7 @@ xf86SetDGAMode( DGAModePtr pMode = NULL;
/* First check if DGAInit was successful on this screen */
- if (DGAScreenKey == NULL)
+ if (!DGAScreenKeyRegistered)
return BadValue;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if (!pScreenPriv)
@@ -478,7 +479,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode) DGAModePtr pMode;
PixmapPtr pPix;
- if(DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -528,7 +529,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode) Bool
DGAAvailable(int index)
{
- if(DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered)
return FALSE;
if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
@@ -542,7 +543,7 @@ DGAActive(int index) {
DGAScreenPtr pScreenPriv;
- if(DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -563,7 +564,7 @@ DGAShutdown(void) ScrnInfoPtr pScrn;
int i;
- if(DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered)
return;
for(i = 0; i < screenInfo.numScreens; i++) {
@@ -893,7 +894,7 @@ DGAVTSwitch(void) /* Alternatively, this could send events to DGA clients */
- if(DGAScreenKey) {
+ if(DGAScreenKeyRegistered) {
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if(pScreenPriv && pScreenPriv->current)
@@ -910,7 +911,7 @@ DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down) DGAScreenPtr pScreenPriv;
DGAEvent event;
- if(DGAScreenKey == NULL) /* no DGA */
+ if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
if (key_code < 8 || key_code > 255)
@@ -943,7 +944,7 @@ DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy) DGAScreenPtr pScreenPriv;
DGAEvent event;
- if(DGAScreenKey == NULL) /* no DGA */
+ if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -981,7 +982,7 @@ DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down) DGAScreenPtr pScreenPriv;
DGAEvent event;
- if (DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -1009,7 +1010,7 @@ Bool DGAIsDgaEvent (xEvent *e)
{
int coreEquiv;
- if (DGAScreenKey == NULL || XDGAEventBase == 0)
+ if (!DGAScreenKeyRegistered || XDGAEventBase == 0)
return FALSE;
coreEquiv = e->u.u.type - *XDGAEventBase;
if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify)
@@ -1203,7 +1204,7 @@ DGAHandleEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device) DGAScreenPtr pScreenPriv;
/* no DGA */
- if (DGAScreenKey == NULL || XDGAEventBase == 0)
+ if (!DGAScreenKeyRegistered || XDGAEventBase == 0)
return;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
diff --git a/xorg-server/hw/xfree86/common/xf86DPMS.c b/xorg-server/hw/xfree86/common/xf86DPMS.c index 3040cb294..1a8aed306 100644 --- a/xorg-server/hw/xfree86/common/xf86DPMS.c +++ b/xorg-server/hw/xfree86/common/xf86DPMS.c @@ -46,7 +46,7 @@ #ifdef DPMSExtension
-static int DPMSKeyIndex;
+static DevPrivateKeyRec DPMSKeyRec;
static DevPrivateKey DPMSKey;
static Bool DPMSClose(int i, ScreenPtr pScreen);
static int DPMSCount = 0;
@@ -62,10 +62,9 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags) pointer DPMSOpt;
MessageType enabled_from;
- DPMSKey = &DPMSKeyIndex;
+ DPMSKey = &DPMSKeyRec;
- if (!dixSetPrivate(&pScreen->devPrivates, DPMSKey,
- calloc(sizeof(DPMSRec), 1)))
+ if (!dixRegisterPrivateKey(&DPMSKeyRec, PRIVATE_SCREEN, sizeof (DPMSRec)))
return FALSE;
pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
@@ -127,8 +126,6 @@ DPMSClose(int i, ScreenPtr pScreen) xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0);
}
- free(pDPMS);
- dixSetPrivate(&pScreen->devPrivates, DPMSKey, NULL);
if (--DPMSCount == 0)
DPMSKey = NULL;
return pScreen->CloseScreen(i, pScreen);
diff --git a/xorg-server/hw/xfree86/common/xf86Globals.c b/xorg-server/hw/xfree86/common/xf86Globals.c index 8b483f35c..44252c75f 100644 --- a/xorg-server/hw/xfree86/common/xf86Globals.c +++ b/xorg-server/hw/xfree86/common/xf86Globals.c @@ -1,208 +1,204 @@ - -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -/* - * This file contains all the XFree86 global variables. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "os.h" -#include "windowstr.h" -#include "propertyst.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86Parser.h" -#include "xf86Xinput.h" -#include "xf86InPriv.h" -#include "xf86Config.h" - -/* Globals that video drivers may access */ - -/* Index into pScreen.devPrivates */ -static int xf86CreateRootWindowKeyIndex; -DevPrivateKey xf86CreateRootWindowKey = &xf86CreateRootWindowKeyIndex; -/* Index of ScrnInfo in pScreen.devPrivates */ -static int xf86ScreenKeyIndex; -DevPrivateKey xf86ScreenKey = &xf86ScreenKeyIndex; -static int xf86PixmapKeyIndex; -DevPrivateKey xf86PixmapKey = &xf86PixmapKeyIndex; -ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */ -const unsigned char byte_reversed[256] = -{ - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, -}; - -/* Globals that input drivers may access */ -InputInfoPtr xf86InputDevs = NULL; - - -/* Globals that video drivers may not access */ - -xf86InfoRec xf86Info = { - .consoleFd = -1, - .vtno = -1, - .vtSysreq = FALSE, - .lastEventTime = -1, - .vtRequestsPending = FALSE, -#ifdef sun - .vtPendingNum = -1, -#endif - .dontVTSwitch = FALSE, - .dontZap = FALSE, - .dontZoom = FALSE, - .notrapSignals = FALSE, - .caughtSignal = FALSE, - .currentScreen = NULL, -#ifdef CSRG_BASED - .screenFd = -1, - .consType = -1, -#endif - .allowMouseOpenFail = FALSE, - .vidModeEnabled = TRUE, - .vidModeAllowNonLocal = FALSE, - .miscModInDevEnabled = TRUE, - .miscModInDevAllowNonLocal = FALSE, - .pixmap24 = Pix24DontCare, - .pix24From = X_DEFAULT, -#ifdef SUPPORT_PC98 - .pc98 = FALSE, -#endif - .pmFlag = TRUE, - .log = LogNone, - .kbdCustomKeycodes = FALSE, - .disableRandR = FALSE, - .randRFrom = X_DEFAULT, -#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) - .allowEmptyInput = TRUE, - .autoAddDevices = TRUE, - .autoEnableDevices = TRUE -#else - .allowEmptyInput = FALSE, - .autoAddDevices = FALSE, - .autoEnableDevices = FALSE -#endif -}; -const char *xf86ConfigFile = NULL; -const char *xf86ConfigDir = NULL; -const char *xf86ModulePath = DEFAULT_MODULE_PATH; -MessageType xf86ModPathFrom = X_DEFAULT; -const char *xf86LogFile = DEFAULT_LOGPREFIX; -MessageType xf86LogFileFrom = X_DEFAULT; -Bool xf86LogFileWasOpened = FALSE; -serverLayoutRec xf86ConfigLayout = {NULL, }; -confDRIRec xf86ConfigDRI = {0, }; -XF86ConfigPtr xf86configptr = NULL; -Bool xf86Resetting = FALSE; -Bool xf86Initialising = FALSE; -Bool xf86DoConfigure = FALSE; -Bool xf86DoShowOptions = FALSE; -DriverPtr *xf86DriverList = NULL; -int xf86NumDrivers = 0; -InputDriverPtr *xf86InputDriverList = NULL; -int xf86NumInputDrivers = 0; -int xf86NumScreens = 0; - -const char *xf86VisualNames[] = { - "StaticGray", - "GrayScale", - "StaticColor", - "PseudoColor", - "TrueColor", - "DirectColor" -}; - -/* Parameters set only from the command line */ -char *xf86ServerName = "no-name"; -Bool xf86fpFlag = FALSE; -Bool xf86sFlag = FALSE; -Bool xf86bsEnableFlag = FALSE; -Bool xf86bsDisableFlag = FALSE; -Bool xf86silkenMouseDisableFlag = FALSE; -Bool xf86xkbdirFlag = FALSE; -#ifdef HAVE_ACPI -Bool xf86acpiDisableFlag = FALSE; -#endif -char *xf86LayoutName = NULL; -char *xf86ScreenName = NULL; -char *xf86PointerName = NULL; -char *xf86KeyboardName = NULL; -int xf86Verbose = DEFAULT_VERBOSE; -int xf86LogVerbose = DEFAULT_LOG_VERBOSE; -int xf86FbBpp = -1; -Pix24Flags xf86Pix24 = Pix24DontCare; -int xf86Depth = -1; -rgb xf86Weight = {0, 0, 0}; -Bool xf86FlipPixels = FALSE; -Gamma xf86Gamma = {0.0, 0.0, 0.0}; -Bool xf86AllowMouseOpenFail = FALSE; -#ifdef XF86VIDMODE -Bool xf86VidModeDisabled = FALSE; -Bool xf86VidModeAllowNonLocal = FALSE; -#endif -RootWinPropPtr *xf86RegisteredPropertiesTable = NULL; -Bool xf86inSuspend = FALSE; -Bool xorgHWAccess = FALSE; - -struct pci_slot_match xf86IsolateDevice = { - PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0 -}; +
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains all the XFree86 global variables.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Parser.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+#include "xf86Config.h"
+
+/* Globals that video drivers may access */
+
+DevPrivateKeyRec xf86CreateRootWindowKeyRec;
+DevPrivateKeyRec xf86ScreenKeyRec;
+DevPrivateKeyRec xf86PixmapKeyRec;
+
+ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
+const unsigned char byte_reversed[256] =
+{
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+};
+
+/* Globals that input drivers may access */
+InputInfoPtr xf86InputDevs = NULL;
+
+
+/* Globals that video drivers may not access */
+
+xf86InfoRec xf86Info = {
+ .consoleFd = -1,
+ .vtno = -1,
+ .vtSysreq = FALSE,
+ .lastEventTime = -1,
+ .vtRequestsPending = FALSE,
+#ifdef sun
+ .vtPendingNum = -1,
+#endif
+ .dontVTSwitch = FALSE,
+ .dontZap = FALSE,
+ .dontZoom = FALSE,
+ .notrapSignals = FALSE,
+ .caughtSignal = FALSE,
+ .currentScreen = NULL,
+#ifdef CSRG_BASED
+ .screenFd = -1,
+ .consType = -1,
+#endif
+ .allowMouseOpenFail = FALSE,
+ .vidModeEnabled = TRUE,
+ .vidModeAllowNonLocal = FALSE,
+ .miscModInDevEnabled = TRUE,
+ .miscModInDevAllowNonLocal = FALSE,
+ .pixmap24 = Pix24DontCare,
+ .pix24From = X_DEFAULT,
+#ifdef SUPPORT_PC98
+ .pc98 = FALSE,
+#endif
+ .pmFlag = TRUE,
+ .log = LogNone,
+ .kbdCustomKeycodes = FALSE,
+ .disableRandR = FALSE,
+ .randRFrom = X_DEFAULT,
+#if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
+ .allowEmptyInput = TRUE,
+ .autoAddDevices = TRUE,
+ .autoEnableDevices = TRUE
+#else
+ .allowEmptyInput = FALSE,
+ .autoAddDevices = FALSE,
+ .autoEnableDevices = FALSE
+#endif
+};
+const char *xf86ConfigFile = NULL;
+const char *xf86ConfigDir = NULL;
+const char *xf86ModulePath = DEFAULT_MODULE_PATH;
+MessageType xf86ModPathFrom = X_DEFAULT;
+const char *xf86LogFile = DEFAULT_LOGPREFIX;
+MessageType xf86LogFileFrom = X_DEFAULT;
+Bool xf86LogFileWasOpened = FALSE;
+serverLayoutRec xf86ConfigLayout = {NULL, };
+confDRIRec xf86ConfigDRI = {0, };
+XF86ConfigPtr xf86configptr = NULL;
+Bool xf86Resetting = FALSE;
+Bool xf86Initialising = FALSE;
+Bool xf86DoConfigure = FALSE;
+Bool xf86DoShowOptions = FALSE;
+DriverPtr *xf86DriverList = NULL;
+int xf86NumDrivers = 0;
+InputDriverPtr *xf86InputDriverList = NULL;
+int xf86NumInputDrivers = 0;
+int xf86NumScreens = 0;
+
+const char *xf86VisualNames[] = {
+ "StaticGray",
+ "GrayScale",
+ "StaticColor",
+ "PseudoColor",
+ "TrueColor",
+ "DirectColor"
+};
+
+/* Parameters set only from the command line */
+char *xf86ServerName = "no-name";
+Bool xf86fpFlag = FALSE;
+Bool xf86sFlag = FALSE;
+Bool xf86bsEnableFlag = FALSE;
+Bool xf86bsDisableFlag = FALSE;
+Bool xf86silkenMouseDisableFlag = FALSE;
+Bool xf86xkbdirFlag = FALSE;
+#ifdef HAVE_ACPI
+Bool xf86acpiDisableFlag = FALSE;
+#endif
+char *xf86LayoutName = NULL;
+char *xf86ScreenName = NULL;
+char *xf86PointerName = NULL;
+char *xf86KeyboardName = NULL;
+int xf86Verbose = DEFAULT_VERBOSE;
+int xf86LogVerbose = DEFAULT_LOG_VERBOSE;
+int xf86FbBpp = -1;
+Pix24Flags xf86Pix24 = Pix24DontCare;
+int xf86Depth = -1;
+rgb xf86Weight = {0, 0, 0};
+Bool xf86FlipPixels = FALSE;
+Gamma xf86Gamma = {0.0, 0.0, 0.0};
+Bool xf86AllowMouseOpenFail = FALSE;
+#ifdef XF86VIDMODE
+Bool xf86VidModeDisabled = FALSE;
+Bool xf86VidModeAllowNonLocal = FALSE;
+#endif
+RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
+Bool xf86inSuspend = FALSE;
+Bool xorgHWAccess = FALSE;
+
+struct pci_slot_match xf86IsolateDevice = {
+ PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0
+};
diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c index 0fa695a3a..a88a1e758 100644 --- a/xorg-server/hw/xfree86/common/xf86Helper.c +++ b/xorg-server/hw/xfree86/common/xf86Helper.c @@ -234,8 +234,7 @@ xf86DeleteScreen(int scrnIndex, int flags) if (pScrn->drv)
pScrn->drv->refCount--;
- if (pScrn->privates)
- free(pScrn->privates);
+ free(pScrn->privates);
xf86ClearEntityListForScreen(scrnIndex);
@@ -269,7 +268,7 @@ xf86AllocateScrnInfoPrivateIndex(void) nprivs = xnfrealloc(pScr->privates,
xf86ScrnInfoPrivateCount * sizeof(DevUnion));
/* Zero the new private */
- bzero(&nprivs[idx], sizeof(DevUnion));
+ memset(&nprivs[idx], 0, sizeof(DevUnion));
pScr->privates = nprivs;
}
return idx;
@@ -327,8 +326,7 @@ xf86DeleteInput(InputInfoPtr pInp, int flags) /* This should *really* be handled in drv->UnInit(dev) call instead, but
* if the driver forgets about it make sure we free it or at least crash
* with flying colors */
- if (pInp->private)
- free(pInp->private);
+ free(pInp->private);
FreeInputAttributes(pInp->attrs);
@@ -1062,7 +1060,7 @@ xf86SetBlackWhitePixels(ScreenPtr pScreen) static void
xf86SetRootClip (ScreenPtr pScreen, Bool enable)
{
- WindowPtr pWin = WindowTable[pScreen->myNum];
+ WindowPtr pWin = pScreen->root;
WindowPtr pChild;
Bool WasViewable = (Bool)(pWin->viewable);
Bool anyMarked = FALSE;
@@ -1085,8 +1083,8 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable) {
RegionPtr borderVisible;
- borderVisible = REGION_CREATE(pScreen, NullBox, 1);
- REGION_SUBTRACT(pScreen, borderVisible,
+ borderVisible = RegionCreate(NullBox, 1);
+ RegionSubtract(borderVisible,
&pWin->borderClip, &pWin->winSize);
pWin->valdata->before.borderVisible = borderVisible;
}
@@ -1105,18 +1103,18 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable) box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
- REGION_INIT (pScreen, &pWin->winSize, &box, 1);
- REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
+ RegionInit(&pWin->winSize, &box, 1);
+ RegionInit(&pWin->borderSize, &box, 1);
if (WasViewable)
- REGION_RESET(pScreen, &pWin->borderClip, &box);
+ RegionReset(&pWin->borderClip, &box);
pWin->drawable.width = pScreen->width;
pWin->drawable.height = pScreen->height;
- REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ RegionBreak(&pWin->clipList);
}
else
{
- REGION_EMPTY(pScreen, &pWin->borderClip);
- REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ RegionEmpty(&pWin->borderClip);
+ RegionBreak(&pWin->clipList);
}
ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
@@ -1362,7 +1360,7 @@ xf86TokenToString(SymTabPtr table, int token) if (table[i].token < 0)
return NULL;
else
- return(table[i].name);
+ return table[i].name;
}
int
@@ -1376,7 +1374,7 @@ xf86StringToToken(SymTabPtr table, const char *string) for (i = 0; table[i].token >= 0 && xf86NameCmp(string, table[i].name); i++)
;
- return(table[i].token);
+ return table[i].token;
}
/*
@@ -1995,7 +1993,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type, ScrnIndex, property, type, format, len, value);
if (ScrnIndex<0 || ScrnIndex>=xf86NumScreens) {
- return(BadMatch);
+ return BadMatch;
}
if (xf86RegisteredPropertiesTable &&
@@ -2009,7 +2007,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type, if (!pNewProp) {
if ((pNewProp = (RootWinPropPtr)malloc(sizeof(RootWinProp))) == NULL) {
- return(BadAlloc);
+ return BadAlloc;
}
/*
* We will put this property at the end of the list so that
@@ -2017,8 +2015,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type, */
pNewProp->next = NULL;
} else {
- if (pNewProp->name)
- free(pNewProp->name);
+ free(pNewProp->name);
existing = TRUE;
}
@@ -2034,7 +2031,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type, DebugF("creating xf86RegisteredPropertiesTable[] size %d\n",
xf86NumScreens);
if ( NULL==(xf86RegisteredPropertiesTable=(RootWinPropPtr*)xnfcalloc(sizeof(RootWinProp),xf86NumScreens) )) {
- return(BadAlloc);
+ return BadAlloc;
}
for (i=0; i<xf86NumScreens; i++) {
xf86RegisteredPropertiesTable[i] = NULL;
@@ -2059,7 +2056,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type, }
}
DebugF("xf86RegisterRootWindowProperty succeeded\n");
- return(Success);
+ return Success;
}
Bool
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c index ed9aca67c..fd3281b83 100644 --- a/xorg-server/hw/xfree86/common/xf86Init.c +++ b/xorg-server/hw/xfree86/common/xf86Init.c @@ -66,6 +66,7 @@ #include "xf86Priv.h"
#include "xf86Config.h"
#include "xf86_OSlib.h"
+#include "xf86cmap.h"
#include "xorgVersion.h"
#include "xf86Build.h"
#include "mipointer.h"
@@ -202,8 +203,8 @@ xf86PrintBanner(void) struct tm t;
char buf[100];
- bzero(&t, sizeof(t));
- bzero(buf, sizeof(buf));
+ memset(&t, 0, sizeof(t));
+ memset(buf, 0, sizeof(buf));
t.tm_mday = BUILD_DATE % 100;
t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
t.tm_year = BUILD_DATE / 10000 - 1900;
@@ -293,7 +294,7 @@ xf86CreateRootWindow(WindowPtr pWin) }
DebugF("xf86CreateRootWindow() returns %d\n", ret);
- return (ret);
+ return ret;
}
@@ -734,6 +735,15 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) }
#endif /* SCO325 */
+ for (i = 0; i < xf86NumScreens; i++)
+ if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
+ FatalError("Cannot register DDX private keys");
+
+ if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
+ !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0) ||
+ !dixRegisterPrivateKey(&xf86PixmapKeyRec, PRIVATE_PIXMAP, 0))
+ FatalError("Cannot register DDX private keys");
+
for (i = 0; i < xf86NumScreens; i++) {
xf86VGAarbiterLock(xf86Screens[i]);
/*
diff --git a/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c index d1dcb0f94..5b20229a9 100644 --- a/xorg-server/hw/xfree86/common/xf86Option.c +++ b/xorg-server/hw/xfree86/common/xf86Option.c @@ -745,7 +745,7 @@ xf86IsOptionSet(const OptionInfoRec *table, int token) OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
- return (p && p->found);
+ return p && p->found;
}
diff --git a/xorg-server/hw/xfree86/common/xf86RandR.c b/xorg-server/hw/xfree86/common/xf86RandR.c index 1893974e2..3bd15e059 100644 --- a/xorg-server/hw/xfree86/common/xf86RandR.c +++ b/xorg-server/hw/xfree86/common/xf86RandR.c @@ -46,7 +46,7 @@ typedef struct _xf86RandRInfo { Rotation rotation;
} XF86RandRInfoRec, *XF86RandRInfoPtr;
-static int xf86RandRKeyIndex;
+static DevPrivateKeyRec xf86RandRKeyRec;
static DevPrivateKey xf86RandRKey;
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey))
@@ -159,7 +159,7 @@ xf86RandRSetMode (ScreenPtr pScreen, int oldmmHeight = pScreen->mmHeight;
int oldVirtualX = scrp->virtualX;
int oldVirtualY = scrp->virtualY;
- WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
Bool ret = TRUE;
if (pRoot && scrp->vtSema)
@@ -424,7 +424,10 @@ xf86RandRInit (ScreenPtr pScreen) return TRUE;
#endif
- xf86RandRKey = &xf86RandRKeyIndex;
+ xf86RandRKey = &xf86RandRKeyRec;
+
+ if (!dixRegisterPrivateKey(&xf86RandRKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
randrp = malloc(sizeof (XF86RandRInfoRec));
if (!randrp)
diff --git a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c index ac44c5e67..e5fd0fb85 100644 --- a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c +++ b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c @@ -62,10 +62,10 @@ static miPointerSpriteFuncRec VGAarbiterSpriteFuncs = { VGAarbiterDeviceCursorInitialize, VGAarbiterDeviceCursorCleanup
};
-static int VGAarbiterKeyIndex;
-static DevPrivateKey VGAarbiterScreenKey = &VGAarbiterKeyIndex;
-static int VGAarbiterGCIndex;
-static DevPrivateKey VGAarbiterGCKey = &VGAarbiterGCIndex;
+static DevPrivateKeyRec VGAarbiterScreenKeyRec;
+#define VGAarbiterScreenKey (&VGAarbiterScreenKeyRec)
+static DevPrivateKeyRec VGAarbiterGCKeyRec;
+#define VGAarbiterGCKey (&VGAarbiterGCKeyRec)
static int vga_no_arb = 0;
void
@@ -175,9 +175,12 @@ xf86VGAarbiterWrapFunctions(void) pScrn = xf86Screens[pScreen->myNum];
PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
- if (!dixRequestPrivate(VGAarbiterGCKey, sizeof(VGAarbiterGCRec)))
+ if (!dixRegisterPrivateKey(&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec)))
return FALSE;
+ if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec))))
return FALSE;
diff --git a/xorg-server/hw/xfree86/common/xf86VidMode.c b/xorg-server/hw/xfree86/common/xf86VidMode.c index 08f27b8e4..591c338b1 100644 --- a/xorg-server/hw/xfree86/common/xf86VidMode.c +++ b/xorg-server/hw/xfree86/common/xf86VidMode.c @@ -47,7 +47,7 @@ #include "vidmodeproc.h"
#include "xf86cmap.h"
-static int VidModeKeyIndex;
+static DevPrivateKeyRec VidModeKeyRec;
static DevPrivateKey VidModeKey;
static int VidModeCount = 0;
static Bool VidModeClose(int i, ScreenPtr pScreen);
@@ -67,15 +67,17 @@ VidModeExtensionInit(ScreenPtr pScreen) return FALSE;
}
- VidModeKey = &VidModeKeyIndex;
+ VidModeKey = &VidModeKeyRec;
- if (!dixSetPrivate(&pScreen->devPrivates, VidModeKey,
- calloc(sizeof(VidModeRec), 1))) {
- DebugF("xcalloc failed\n");
+ if (!dixRegisterPrivateKey(&VidModeKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
- }
- pVidMode = VMPTR(pScreen);
+ pVidMode = calloc(sizeof(VidModeRec), 1);
+ if (!pVidMode)
+ return FALSE;
+
+ dixSetPrivate(&pScreen->devPrivates, VidModeKey, pVidMode);
+
pVidMode->Flags = 0;
pVidMode->Next = NULL;
pVidMode->CloseScreen = pScreen->CloseScreen;
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c index 2d82ccdbc..845bde87a 100644 --- a/xorg-server/hw/xfree86/common/xf86Xinput.c +++ b/xorg-server/hw/xfree86/common/xf86Xinput.c @@ -80,6 +80,9 @@ #ifdef HAVE_FNMATCH_H
#include <fnmatch.h>
#endif
+#ifdef HAVE_SYS_UTSNAME_H
+#include <sys/utsname.h>
+#endif
#include "extnsionst.h"
@@ -278,9 +281,9 @@ xf86SendDragEvents(DeviceIntPtr device) LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
if (device->button && device->button->buttonsDown > 0)
- return (local->flags & XI86_SEND_DRAG_EVENTS);
+ return local->flags & XI86_SEND_DRAG_EVENTS;
else
- return (TRUE);
+ return TRUE;
}
/***********************************************************************
@@ -497,73 +500,152 @@ AddOtherInputDevices(void) }
/*
- * Classes without any Match statements match all devices. Otherwise, all
- * statements must match.
+ * Get the operating system name from uname and store it statically to avoid
+ * repeating the system call each time MatchOS is checked.
*/
-static Bool
-InputClassMatches(XF86ConfInputClassPtr iclass, InputAttributes *attrs)
+static const char *
+HostOS(void)
{
- char **cur;
- Bool match;
-
- if (iclass->match_product) {
- if (!attrs->product)
- return FALSE;
- /* see if any of the values match */
- for (cur = iclass->match_product, match = FALSE; *cur; cur++)
- if (strstr(attrs->product, *cur)) {
- match = TRUE;
- break;
- }
- if (!match)
- return FALSE;
- }
- if (iclass->match_vendor) {
- if (!attrs->vendor)
- return FALSE;
- /* see if any of the values match */
- for (cur = iclass->match_vendor, match = FALSE; *cur; cur++)
- if (strstr(attrs->vendor, *cur)) {
- match = TRUE;
- break;
- }
- if (!match)
- return FALSE;
+#ifdef HAVE_SYS_UTSNAME_H
+ struct utsname name;
+ static char host_os[sizeof(name.sysname)] = "";
+
+ if (*host_os == '\0') {
+ if (uname(&name) >= 0)
+ strcpy(host_os, name.sysname);
+ else {
+ strncpy(host_os, "unknown", sizeof(host_os));
+ host_os[sizeof(host_os)-1] = '\0';
+ }
}
- if (iclass->match_device) {
- if (!attrs->device)
- return FALSE;
- /* see if any of the values match */
- for (cur = iclass->match_device, match = FALSE; *cur; cur++)
+ return host_os;
+#else
+ return "";
+#endif
+}
+
+static int
+match_substring(const char *attr, const char *pattern)
+{
+ return (strstr(attr, pattern)) ? 0 : -1;
+}
+
+#ifdef HAVE_FNMATCH_H
+static int
+match_pattern(const char *attr, const char *pattern)
+{
+ return fnmatch(pattern, attr, 0);
+}
+#else
+#define match_pattern match_substring
+#endif
+
#ifdef HAVE_FNMATCH_H
- if (fnmatch(*cur, attrs->device, FNM_PATHNAME) == 0) {
+static int
+match_path_pattern(const char *attr, const char *pattern)
+{
+ return fnmatch(pattern, attr, FNM_PATHNAME);
+}
#else
- if (strstr(attrs->device, *cur)) {
+#define match_path_pattern match_substring
#endif
+
+/*
+ * Match an attribute against a list of NULL terminated arrays of patterns.
+ * If a pattern in each list entry is matched, return TRUE.
+ */
+static Bool
+MatchAttrToken(const char *attr, struct list *patterns,
+ int (*compare)(const char *attr, const char *pattern))
+{
+ const xf86MatchGroup *group;
+
+ /* If there are no patterns, accept the match */
+ if (list_is_empty(patterns))
+ return TRUE;
+
+ /* If there are patterns but no attribute, reject the match */
+ if (!attr)
+ return FALSE;
+
+ /*
+ * Otherwise, iterate the list of patterns ensuring each entry has a
+ * match. Each list entry is a separate Match line of the same type.
+ */
+ list_for_each_entry(group, patterns, entry) {
+ char * const *cur;
+ Bool match = FALSE;
+
+ for (cur = group->values; *cur; cur++)
+ if ((*compare)(attr, *cur) == 0) {
match = TRUE;
break;
}
if (!match)
return FALSE;
}
- if (iclass->match_tag) {
+
+ /* All the entries in the list matched the attribute */
+ return TRUE;
+}
+
+/*
+ * Classes without any Match statements match all devices. Otherwise, all
+ * statements must match.
+ */
+static Bool
+InputClassMatches(const XF86ConfInputClassPtr iclass, const IDevPtr idev,
+ const InputAttributes *attrs)
+{
+ /* MatchProduct substring */
+ if (!MatchAttrToken(attrs->product, &iclass->match_product, match_substring))
+ return FALSE;
+
+ /* MatchVendor substring */
+ if (!MatchAttrToken(attrs->vendor, &iclass->match_vendor, match_substring))
+ return FALSE;
+
+ /* MatchDevicePath pattern */
+ if (!MatchAttrToken(attrs->device, &iclass->match_device, match_path_pattern))
+ return FALSE;
+
+ /* MatchOS case-insensitive string */
+ if (!MatchAttrToken(HostOS(), &iclass->match_os, strcasecmp))
+ return FALSE;
+
+ /* MatchPnPID pattern */
+ if (!MatchAttrToken(attrs->pnp_id, &iclass->match_pnpid, match_pattern))
+ return FALSE;
+
+ /* MatchUSBID pattern */
+ if (!MatchAttrToken(attrs->usb_id, &iclass->match_usbid, match_pattern))
+ return FALSE;
+
+ /* MatchDriver string */
+ if (!MatchAttrToken(idev->driver, &iclass->match_driver, strcmp))
+ return FALSE;
+
+ /*
+ * MatchTag string
+ * See if any of the device's tags match any of the MatchTag tokens.
+ */
+ if (!list_is_empty(&iclass->match_tag)) {
+ char * const *tag;
+ Bool match;
+
if (!attrs->tags)
return FALSE;
-
- for (cur = iclass->match_tag, match = FALSE; *cur && !match; cur++) {
- char * const *tag;
- for(tag = attrs->tags; *tag; tag++) {
- if (!strcmp(*tag, *cur)) {
- match = TRUE;
- break;
- }
+ for (tag = attrs->tags, match = FALSE; *tag; tag++) {
+ if (MatchAttrToken(*tag, &iclass->match_tag, strcmp)) {
+ match = TRUE;
+ break;
}
}
-
if (!match)
return FALSE;
}
+ /* MatchIs* booleans */
if (iclass->is_keyboard.set &&
iclass->is_keyboard.val != !!(attrs->flags & ATTR_KEYBOARD))
return FALSE;
@@ -582,6 +664,7 @@ InputClassMatches(XF86ConfInputClassPtr iclass, InputAttributes *attrs) if (iclass->is_touchscreen.set &&
iclass->is_touchscreen.val != !!(attrs->flags & ATTR_TOUCHSCREEN))
return FALSE;
+
return TRUE;
}
@@ -591,37 +674,36 @@ InputClassMatches(XF86ConfInputClassPtr iclass, InputAttributes *attrs) * well as any previous InputClass sections.
*/
static int
-MergeInputClasses(IDevPtr idev, InputAttributes *attrs)
+MergeInputClasses(const IDevPtr idev, const InputAttributes *attrs)
{
XF86ConfInputClassPtr cl;
- XF86OptionPtr classopts, mergedopts = NULL;
- char *classdriver = NULL;
+ XF86OptionPtr classopts;
for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
- if (!InputClassMatches(cl, attrs))
+ if (!InputClassMatches(cl, idev, attrs))
continue;
- /* Collect class options and merge over previous classes */
+ /* Collect class options and driver settings */
+ classopts = xf86optionListDup(cl->option_lst);
+ if (cl->driver) {
+ free(idev->driver);
+ idev->driver = xstrdup(cl->driver);
+ if (!idev->driver) {
+ xf86Msg(X_ERROR, "Failed to allocate memory while merging "
+ "InputClass configuration");
+ return BadAlloc;
+ }
+ classopts = xf86ReplaceStrOption(classopts, "driver",
+ idev->driver);
+ }
+
+ /* Apply options to device with InputClass settings preferred. */
xf86Msg(X_CONFIG, "%s: Applying InputClass \"%s\"\n",
idev->identifier, cl->identifier);
- if (cl->driver)
- classdriver = cl->driver;
- classopts = xf86optionListDup(cl->option_lst);
- mergedopts = xf86optionListMerge(mergedopts, classopts);
+ idev->commonOptions = xf86optionListMerge(idev->commonOptions,
+ classopts);
}
- /* Apply options to device with InputClass settings preferred. */
- if (classdriver) {
- free(idev->driver);
- idev->driver = xstrdup(classdriver);
- if (!idev->driver) {
- xf86Msg(X_ERROR, "Failed to allocate memory while merging "
- "InputClass configuration");
- return BadAlloc;
- }
- mergedopts = xf86ReplaceStrOption(mergedopts, "driver", idev->driver);
- }
- idev->commonOptions = xf86optionListMerge(idev->commonOptions, mergedopts);
return Success;
}
@@ -630,14 +712,14 @@ MergeInputClasses(IDevPtr idev, InputAttributes *attrs) * value of the last matching class and holler when returning TRUE.
*/
static Bool
-IgnoreInputClass(IDevPtr idev, InputAttributes *attrs)
+IgnoreInputClass(const IDevPtr idev, const InputAttributes *attrs)
{
XF86ConfInputClassPtr cl;
Bool ignore = FALSE;
const char *ignore_class;
for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
- if (!InputClassMatches(cl, attrs))
+ if (!InputClassMatches(cl, idev, attrs))
continue;
if (xf86findOption(cl->option_lst, "Ignore")) {
ignore = xf86CheckBoolOption(cl->option_lst, "Ignore", FALSE);
@@ -844,10 +926,8 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, unwind:
if (is_auto && !xf86Info.autoAddDevices)
xf86Msg(X_INFO, "AutoAddDevices is off - not adding device.\n");
- if(idev->driver)
- free(idev->driver);
- if(idev->identifier)
- free(idev->identifier);
+ free(idev->driver);
+ free(idev->identifier);
xf86optionListFree(idev->commonOptions);
free(idev);
return rval;
@@ -1195,7 +1275,7 @@ xf86ScaleAxis(int Cx, if (X < Sxlow)
X = Sxlow;
- return (X);
+ return X;
}
/*
diff --git a/xorg-server/hw/xfree86/common/xf86cmap.c b/xorg-server/hw/xfree86/common/xf86cmap.c index fa0ebc8eb..851843faa 100644 --- a/xorg-server/hw/xfree86/common/xf86cmap.c +++ b/xorg-server/hw/xfree86/common/xf86cmap.c @@ -102,10 +102,11 @@ typedef struct { int overscan;
} CMapColormapRec, *CMapColormapPtr;
-static int CMapScreenKeyIndex;
-static DevPrivateKey CMapScreenKey;
-static int CMapColormapKeyIndex;
-static DevPrivateKey CMapColormapKey = &CMapColormapKeyIndex;
+static DevPrivateKeyRec CMapScreenKeyRec;
+#define CMapScreenKeyRegistered dixPrivateKeyRegistered(&CMapScreenKeyRec)
+#define CMapScreenKey (&CMapScreenKeyRec)
+static DevPrivateKeyRec CMapColormapKeyRec;
+#define CMapColormapKey (&CMapColormapKeyRec)
static void CMapInstallColormap(ColormapPtr);
static void CMapStoreColors(ColormapPtr, int, xColorItem *);
@@ -128,6 +129,18 @@ static void CMapReinstallMap(ColormapPtr); static void CMapUnwrapScreen(ScreenPtr pScreen);
+Bool xf86ColormapAllocatePrivates(ScrnInfoPtr pScrn)
+{
+ /* If we support a better colormap system, then pretend we succeeded. */
+ if (xf86_crtc_supports_gamma(pScrn))
+ return TRUE;
+ if (!dixRegisterPrivateKey(&CMapScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&CMapColormapKeyRec, PRIVATE_COLORMAP, 0))
+ return FALSE;
+ return TRUE;
+}
Bool xf86HandleColormaps(
ScreenPtr pScreen,
@@ -151,8 +164,6 @@ Bool xf86HandleColormaps( if(!maxColors || !sigRGBbits || !loadPalette)
return FALSE;
- CMapScreenKey = &CMapScreenKeyIndex;
-
elements = 1 << sigRGBbits;
if(!(gamma = malloc(elements * sizeof(LOCO))))
@@ -169,7 +180,7 @@ Bool xf86HandleColormaps( return FALSE;
}
- dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv);
+ dixSetPrivate(&pScreen->devPrivates, &CMapScreenKeyRec, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreenPriv->CreateColormap = pScreen->CreateColormap;
@@ -316,7 +327,7 @@ CMapDestroyColormap (ColormapPtr cmap) CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
if(pColPriv) {
- if(pColPriv->colors) free(pColPriv->colors);
+ free(pColPriv->colors);
free(pColPriv);
}
@@ -900,7 +911,7 @@ CMapChangeGamma( CMapLinkPtr pLink;
/* Is this sufficient checking ? */
- if(CMapScreenKey == NULL)
+ if(!CMapScreenKeyRegistered)
return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
@@ -1012,7 +1023,7 @@ xf86ChangeGammaRamp( }
}
- if(CMapScreenKey == NULL)
+ if(!CMapScreenKeyRegistered)
return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
@@ -1080,7 +1091,7 @@ xf86GetGammaRampSize(ScreenPtr pScreen) return crtc->gammaSize;
}
- if(CMapScreenKey == NULL) return 0;
+ if(!CMapScreenKeyRegistered) return 0;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
CMapScreenKey);
@@ -1120,7 +1131,7 @@ xf86GetGammaRamp( }
}
- if(CMapScreenKey == NULL)
+ if(!CMapScreenKeyRegistered)
return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
diff --git a/xorg-server/hw/xfree86/common/xf86cmap.h b/xorg-server/hw/xfree86/common/xf86cmap.h index f15844e59..caa01e8ed 100644 --- a/xorg-server/hw/xfree86/common/xf86cmap.h +++ b/xorg-server/hw/xfree86/common/xf86cmap.h @@ -1,75 +1,79 @@ - -/* - * Copyright (c) 1998-2001 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifndef _XF86CMAP_H -#define _XF86CMAP_H - -#include "xf86str.h" -#include "colormapst.h" - -#define CMAP_PALETTED_TRUECOLOR 0x0000001 -#define CMAP_RELOAD_ON_MODE_SWITCH 0x0000002 -#define CMAP_LOAD_EVEN_IF_OFFSCREEN 0x0000004 - -extern _X_EXPORT Bool xf86HandleColormaps( - ScreenPtr pScreen, - int maxCol, - int sigRGBbits, - xf86LoadPaletteProc *loadPalette, - xf86SetOverscanProc *setOverscan, - unsigned int flags -); - -extern _X_EXPORT int -xf86ChangeGamma( - ScreenPtr pScreen, - Gamma newGamma -); - -extern _X_EXPORT int -xf86ChangeGammaRamp( - ScreenPtr pScreen, - int size, - unsigned short *red, - unsigned short *green, - unsigned short *blue -); - -extern _X_EXPORT int xf86GetGammaRampSize(ScreenPtr pScreen); - -extern _X_EXPORT int -xf86GetGammaRamp( - ScreenPtr pScreen, - int size, - unsigned short *red, - unsigned short *green, - unsigned short *blue -); - -#endif /* _XF86CMAP_H */ - +
+/*
+ * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifndef _XF86CMAP_H
+#define _XF86CMAP_H
+
+#include "xf86str.h"
+#include "colormapst.h"
+
+#define CMAP_PALETTED_TRUECOLOR 0x0000001
+#define CMAP_RELOAD_ON_MODE_SWITCH 0x0000002
+#define CMAP_LOAD_EVEN_IF_OFFSCREEN 0x0000004
+
+extern _X_EXPORT Bool xf86HandleColormaps(
+ ScreenPtr pScreen,
+ int maxCol,
+ int sigRGBbits,
+ xf86LoadPaletteProc *loadPalette,
+ xf86SetOverscanProc *setOverscan,
+ unsigned int flags
+);
+
+extern _X_EXPORT Bool xf86ColormapAllocatePrivates(
+ ScrnInfoPtr pScrn
+);
+
+extern _X_EXPORT int
+xf86ChangeGamma(
+ ScreenPtr pScreen,
+ Gamma newGamma
+);
+
+extern _X_EXPORT int
+xf86ChangeGammaRamp(
+ ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+);
+
+extern _X_EXPORT int xf86GetGammaRampSize(ScreenPtr pScreen);
+
+extern _X_EXPORT int
+xf86GetGammaRamp(
+ ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+);
+
+#endif /* _XF86CMAP_H */
+
diff --git a/xorg-server/hw/xfree86/common/xf86fbman.c b/xorg-server/hw/xfree86/common/xf86fbman.c index 1ca27015f..ccb761a2c 100644 --- a/xorg-server/hw/xfree86/common/xf86fbman.c +++ b/xorg-server/hw/xfree86/common/xf86fbman.c @@ -42,7 +42,7 @@ #define DEBUG
*/
-static int xf86FBManagerKeyIndex;
+static DevPrivateKeyRec xf86FBManagerKeyRec;
static DevPrivateKey xf86FBManagerKey;
Bool xf86RegisterOffscreenManager(
@@ -50,7 +50,11 @@ Bool xf86RegisterOffscreenManager( FBManagerFuncsPtr funcs
){
- xf86FBManagerKey = &xf86FBManagerKeyIndex;
+ xf86FBManagerKey = &xf86FBManagerKeyRec;
+
+ if (!dixRegisterPrivateKey(&xf86FBManagerKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs);
return TRUE;
@@ -60,8 +64,9 @@ Bool xf86RegisterOffscreenManager( Bool
xf86FBManagerRunning(ScreenPtr pScreen)
{
- if(xf86FBManagerKey == NULL)
+ if (xf86FBManagerKey == NULL)
return FALSE;
+
if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey))
return FALSE;
@@ -270,8 +275,8 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen) \************************************************************/
-static int xf86FBScreenKeyIndex;
-static DevPrivateKey xf86FBScreenKey = &xf86FBScreenKeyIndex;
+static DevPrivateKeyRec xf86FBScreenKeyRec;
+#define xf86FBScreenKey (&xf86FBScreenKeyRec)
typedef struct _FBLink {
FBArea area;
@@ -363,8 +368,8 @@ AllocateArea( if(granularity <= 1) granularity = 0;
- boxp = REGION_RECTS(offman->FreeBoxes);
- num = REGION_NUM_RECTS(offman->FreeBoxes);
+ boxp = RegionRects(offman->FreeBoxes);
+ num = RegionNumRects(offman->FreeBoxes);
/* look through the free boxes */
for(i = 0; i < num; i++, boxp++) {
@@ -407,9 +412,9 @@ AllocateArea( /* bye, bye */
(*link->area.RemoveAreaCallback)(&link->area);
- REGION_INIT(pScreen, &NewReg, &(link->area.box), 1);
- REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg);
- REGION_UNINIT(pScreen, &NewReg);
+ RegionInit(&NewReg, &(link->area.box), 1);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
+ RegionUninit(&NewReg);
area = &(link->area);
break;
@@ -427,9 +432,9 @@ AllocateArea( area->RemoveAreaCallback = removeCB;
area->devPrivate.ptr = privData;
- REGION_INIT(pScreen, &NewReg, &(area->box), 1);
- REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg);
- REGION_UNINIT(pScreen, &NewReg);
+ RegionInit(&NewReg, &(area->box), 1);
+ RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
+ RegionUninit(&NewReg);
}
return area;
@@ -477,9 +482,9 @@ localFreeOffscreenArea(FBAreaPtr area) }
/* put the area back into the pool */
- REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1);
- REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
- REGION_UNINIT(pScreen, &FreedRegion);
+ RegionInit(&FreedRegion, &(pLink->area.box), 1);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
+ RegionUninit(&FreedRegion);
if(pLinkPrev)
pLinkPrev->next = pLink->next;
@@ -536,12 +541,12 @@ localResizeOffscreenArea( (resize->box.x2 == OrigArea.x2))
return TRUE;
- REGION_INIT(pScreen, &FreedReg, &OrigArea, 1);
- REGION_INIT(pScreen, &NewReg, &(resize->box), 1);
- REGION_SUBTRACT(pScreen, &FreedReg, &FreedReg, &NewReg);
- REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
- REGION_UNINIT(pScreen, &FreedReg);
- REGION_UNINIT(pScreen, &NewReg);
+ RegionInit(&FreedReg, &OrigArea, 1);
+ RegionInit(&NewReg, &(resize->box), 1);
+ RegionSubtract(&FreedReg, &FreedReg, &NewReg);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+ RegionUninit(&FreedReg);
+ RegionUninit(&NewReg);
SendCallFreeBoxCallbacks(offman);
@@ -551,8 +556,8 @@ localResizeOffscreenArea( /* otherwise we remove the old region */
- REGION_INIT(pScreen, &FreedReg, &OrigArea, 1);
- REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+ RegionInit(&FreedReg, &OrigArea, 1);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
/* remove the old link */
if(pLinkPrev)
@@ -589,8 +594,8 @@ localResizeOffscreenArea( offman->NumUsedAreas--;
} else {
/* reinstate the old region */
- REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
- REGION_UNINIT(pScreen, &FreedReg);
+ RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+ RegionUninit(&FreedReg);
pLink->next = offman->UsedAreas;
offman->UsedAreas = pLink;
@@ -598,7 +603,7 @@ localResizeOffscreenArea( }
- REGION_UNINIT(pScreen, &FreedReg);
+ RegionUninit(&FreedReg);
SendCallFreeBoxCallbacks(offman);
@@ -636,47 +641,47 @@ localQueryLargestOffscreenArea( if(offman->NumUsedAreas) {
FBLinkPtr pLink;
RegionRec tmpRegion;
- newRegion = REGION_CREATE(pScreen, NULL, 1);
- REGION_COPY(pScreen, newRegion, offman->InitialBoxes);
+ newRegion = RegionCreate(NULL, 1);
+ RegionCopy(newRegion, offman->InitialBoxes);
pLink = offman->UsedAreas;
while(pLink) {
if(!pLink->area.RemoveAreaCallback) {
- REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1);
- REGION_SUBTRACT(pScreen, newRegion, newRegion, &tmpRegion);
- REGION_UNINIT(pScreen, &tmpRegion);
+ RegionInit(&tmpRegion, &(pLink->area.box), 1);
+ RegionSubtract(newRegion, newRegion, &tmpRegion);
+ RegionUninit(&tmpRegion);
}
pLink = pLink->next;
}
- nbox = REGION_NUM_RECTS(newRegion);
- pbox = REGION_RECTS(newRegion);
+ nbox = RegionNumRects(newRegion);
+ pbox = RegionRects(newRegion);
break;
}
case 1:
if(offman->NumUsedAreas) {
FBLinkPtr pLink;
RegionRec tmpRegion;
- newRegion = REGION_CREATE(pScreen, NULL, 1);
- REGION_COPY(pScreen, newRegion, offman->FreeBoxes);
+ newRegion = RegionCreate(NULL, 1);
+ RegionCopy(newRegion, offman->FreeBoxes);
pLink = offman->UsedAreas;
while(pLink) {
if(pLink->area.RemoveAreaCallback) {
- REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1);
- REGION_APPEND(pScreen, newRegion, &tmpRegion);
- REGION_UNINIT(pScreen, &tmpRegion);
+ RegionInit(&tmpRegion, &(pLink->area.box), 1);
+ RegionAppend(newRegion, &tmpRegion);
+ RegionUninit(&tmpRegion);
}
pLink = pLink->next;
}
- nbox = REGION_NUM_RECTS(newRegion);
- pbox = REGION_RECTS(newRegion);
+ nbox = RegionNumRects(newRegion);
+ pbox = RegionRects(newRegion);
break;
}
default:
- nbox = REGION_NUM_RECTS(offman->FreeBoxes);
- pbox = REGION_RECTS(offman->FreeBoxes);
+ nbox = RegionNumRects(offman->FreeBoxes);
+ pbox = RegionRects(offman->FreeBoxes);
break;
}
@@ -719,7 +724,7 @@ localQueryLargestOffscreenArea( }
if(newRegion)
- REGION_DESTROY(pScreen, newRegion);
+ RegionDestroy(newRegion);
return TRUE;
}
@@ -741,9 +746,9 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen) if(pLink->area.RemoveAreaCallback) {
(*pLink->area.RemoveAreaCallback)(&pLink->area);
- REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1);
- REGION_APPEND(pScreen, offman->FreeBoxes, &FreedRegion);
- REGION_UNINIT(pScreen, &FreedRegion);
+ RegionInit(&FreedRegion, &(pLink->area.box), 1);
+ RegionAppend(offman->FreeBoxes, &FreedRegion);
+ RegionUninit(&FreedRegion);
if(pPrev)
pPrev->next = pLink->next;
@@ -761,7 +766,7 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen) }
if(anyUsed) {
- REGION_VALIDATE(pScreen, offman->FreeBoxes, &anyUsed);
+ RegionValidate(offman->FreeBoxes, &anyUsed);
SendCallFreeBoxCallbacks(offman);
}
@@ -924,7 +929,7 @@ localAllocateOffscreenLinear( return NULL;
/* No linear available, so try and pinch some from the XY areas */
- extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ extents = RegionExtents(offman->InitialBoxes);
pitch = extents->x2 - extents->x1;
if (gran > 1) {
@@ -1055,7 +1060,7 @@ localResizeOffscreenLinear(FBLinearPtr resize, int length) BoxPtr extents;
int pitch, w, h;
- extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ extents = RegionExtents(offman->InitialBoxes);
pitch = extents->x2 - extents->x1;
if(length < pitch) { /* special case */
@@ -1121,7 +1126,7 @@ localQueryLargestOffscreenLinear( offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
xf86FBScreenKey);
- extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ extents = RegionExtents(offman->InitialBoxes);
if((extents->x2 - extents->x1) == w)
*size = w * h;
return TRUE;
@@ -1171,8 +1176,8 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen) free(tmp2);
}
- REGION_DESTROY(pScreen, offman->InitialBoxes);
- REGION_DESTROY(pScreen, offman->FreeBoxes);
+ RegionDestroy(offman->InitialBoxes);
+ RegionDestroy(offman->FreeBoxes);
free(offman->FreeBoxesUpdateCallback);
free(offman->devPrivates);
@@ -1206,15 +1211,15 @@ xf86InitFBManager( if (FullBox->y2 < FullBox->y1) return FALSE;
if (FullBox->x2 < FullBox->x1) return FALSE;
- REGION_INIT(pScreen, &ScreenRegion, &ScreenBox, 1);
- REGION_INIT(pScreen, &FullRegion, FullBox, 1);
+ RegionInit(&ScreenRegion, &ScreenBox, 1);
+ RegionInit(&FullRegion, FullBox, 1);
- REGION_SUBTRACT(pScreen, &FullRegion, &FullRegion, &ScreenRegion);
+ RegionSubtract(&FullRegion, &FullRegion, &ScreenRegion);
ret = xf86InitFBManagerRegion(pScreen, &FullRegion);
- REGION_UNINIT(pScreen, &ScreenRegion);
- REGION_UNINIT(pScreen, &FullRegion);
+ RegionUninit(&ScreenRegion);
+ RegionUninit(&FullRegion);
return ret;
}
@@ -1249,17 +1254,17 @@ xf86InitFBManagerArea( }
/* Factor out virtual resolution */
- pRegion = RECTS_TO_REGION(pScreen, nRect, Rect, 0);
+ pRegion = RegionFromRects(nRect, Rect, 0);
if (pRegion) {
- if (!REGION_NAR(pRegion)) {
+ if (!RegionNar(pRegion)) {
Rect[2].x = Rect[2].y = 0;
Rect[2].width = pScrn->virtualX;
Rect[2].height = pScrn->virtualY;
- pScreenRegion = RECTS_TO_REGION(pScreen, 1, &Rect[2], 0);
+ pScreenRegion = RegionFromRects(1, &Rect[2], 0);
if (pScreenRegion) {
- if (!REGION_NAR(pScreenRegion)) {
- REGION_SUBTRACT(pScreen, pRegion, pRegion, pScreenRegion);
+ if (!RegionNar(pScreenRegion)) {
+ RegionSubtract(pRegion, pRegion, pScreenRegion);
ret = xf86InitFBManagerRegion(pScreen, pRegion);
@@ -1301,11 +1306,11 @@ xf86InitFBManagerArea( }
}
- REGION_DESTROY(pScreen, pScreenRegion);
+ RegionDestroy(pScreenRegion);
}
}
- REGION_DESTROY(pScreen, pRegion);
+ RegionDestroy(pRegion);
}
return ret;
@@ -1318,9 +1323,12 @@ xf86InitFBManagerRegion( ){
FBManagerPtr offman;
- if(REGION_NIL(FullRegion))
+ if(RegionNil(FullRegion))
return FALSE;
+ if (!dixRegisterPrivateKey(&xf86FBScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
return FALSE;
@@ -1332,11 +1340,11 @@ xf86InitFBManagerRegion( offman->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86FBCloseScreen;
- offman->InitialBoxes = REGION_CREATE(pScreen, NULL, 1);
- offman->FreeBoxes = REGION_CREATE(pScreen, NULL, 1);
+ offman->InitialBoxes = RegionCreate(NULL, 1);
+ offman->FreeBoxes = RegionCreate(NULL, 1);
- REGION_COPY(pScreen, offman->InitialBoxes, FullRegion);
- REGION_COPY(pScreen, offman->FreeBoxes, FullRegion);
+ RegionCopy(offman->InitialBoxes, FullRegion);
+ RegionCopy(offman->FreeBoxes, FullRegion);
offman->pScreen = pScreen;
offman->UsedAreas = NULL;
@@ -1415,7 +1423,7 @@ xf86AllocateLinearOffscreenArea ( offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
xf86FBScreenKey);
- extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ extents = RegionExtents(offman->InitialBoxes);
w = extents->x2 - extents->x1;
if (gran > 1) {
diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c index 8d968dc39..461c7c235 100644 --- a/xorg-server/hw/xfree86/common/xf86pciBus.c +++ b/xorg-server/hw/xfree86/common/xf86pciBus.c @@ -465,7 +465,7 @@ xf86PciAddMatchingDev(DriverPtr drvp) pci_iterator_destroy(iter);
- return (numFound != 0);
+ return numFound != 0;
}
Bool
@@ -1294,7 +1294,11 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip }
#endif /* __linux__ */
-void
+/**
+ * @return The numbers of found devices that match with the current system
+ * drivers.
+ */
+int
xf86PciMatchDriver(char* matches[], int nmatches) {
int i;
struct pci_device * info = NULL;
@@ -1326,4 +1330,6 @@ xf86PciMatchDriver(char* matches[], int nmatches) { if ((info != NULL) && (i < nmatches)) {
i += videoPtrToDriverList(info, &(matches[i]), nmatches - i);
}
+
+ return i;
}
diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.h b/xorg-server/hw/xfree86/common/xf86pciBus.h index c8a2eebdd..bcbb8b822 100644 --- a/xorg-server/hw/xfree86/common/xf86pciBus.h +++ b/xorg-server/hw/xfree86/common/xf86pciBus.h @@ -37,6 +37,6 @@ void xf86PciProbe(void); Bool xf86PciAddMatchingDev(DriverPtr drvp);
Bool xf86PciProbeDev(DriverPtr drvp);
void xf86PciIsolateDevice(char *argument);
-void xf86PciMatchDriver(char* matches[], int nmatches);
+int xf86PciMatchDriver(char* matches[], int nmatches);
#endif /* _XF86_PCI_BUS_H */
diff --git a/xorg-server/hw/xfree86/common/xf86sbusBus.c b/xorg-server/hw/xfree86/common/xf86sbusBus.c index 8df3a6c7a..51e7894db 100644 --- a/xorg-server/hw/xfree86/common/xf86sbusBus.c +++ b/xorg-server/hw/xfree86/common/xf86sbusBus.c @@ -478,8 +478,7 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId, instances[i].claimed = TRUE;
instances[i].dev = dev;
}
- if (promPath)
- free(promPath);
+ free(promPath);
}
DebugF("%s instances found: %d\n", driverName, numClaimedInstances);
@@ -531,7 +530,7 @@ xf86GetSbusInfoForEntity(int entityIndex) for (psdpp = xf86SbusInfo; *psdpp != NULL; psdpp++) {
if (p->bus.id.sbus.fbNum == (*psdpp)->fbNum)
- return (*psdpp);
+ return *psdpp;
}
return NULL;
}
diff --git a/xorg-server/hw/xfree86/common/xf86xv.c b/xorg-server/hw/xfree86/common/xf86xv.c index e35b8d667..6dae62717 100644 --- a/xorg-server/hw/xfree86/common/xf86xv.c +++ b/xorg-server/hw/xfree86/common/xf86xv.c @@ -110,10 +110,11 @@ static void xf86XVAdjustFrame(int index, int x, int y, int flags); static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
-static int XF86XVWindowKeyIndex;
-static DevPrivateKey XF86XVWindowKey = &XF86XVWindowKeyIndex;
-static int XF86XvScreenKeyIndex;
-DevPrivateKey XF86XvScreenKey = &XF86XvScreenKeyIndex;
+static DevPrivateKeyRec XF86XVWindowKeyRec;
+#define XF86XVWindowKey (&XF86XVWindowKeyRec)
+
+DevPrivateKey XF86XvScreenKey;
+
static unsigned long PortResource = 0;
DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL;
@@ -186,8 +187,8 @@ typedef struct { int num;
} OffscreenImageRec;
-static int OffscreenPrivateKeyIndex;
-static DevPrivateKey OffscreenPrivateKey = &OffscreenPrivateKeyIndex;
+static DevPrivateKeyRec OffscreenPrivateKeyRec;
+#define OffscreenPrivateKey (&OffscreenPrivateKeyRec)
#define GetOffscreenImage(pScreen) ((OffscreenImageRec *) dixLookupPrivate(&(pScreen)->devPrivates, OffscreenPrivateKey))
Bool
@@ -198,9 +199,9 @@ xf86XVRegisterOffscreenImages( ){
OffscreenImageRec *OffscreenImage;
/* This function may be called before xf86XVScreenInit, so there's
- * no better place than this to call dixRequestPrivate to ensure we
+ * no better place than this to call dixRegisterPrivateKey to ensure we
* have space reserved. After the first call it is a no-op. */
- if(!dixRequestPrivate(OffscreenPrivateKey, sizeof(OffscreenImageRec)) ||
+ if(!dixRegisterPrivateKey(OffscreenPrivateKey, PRIVATE_SCREEN, sizeof(OffscreenImageRec)) ||
!(OffscreenImage = GetOffscreenImage(pScreen)))
/* Every X.org driver assumes this function always succeeds, so
* just die on allocation failure. */
@@ -251,7 +252,11 @@ xf86XVScreenInit( if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
+ if (!dixRegisterPrivateKey(&XF86XVWindowKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
XF86XvScreenKey = (*XvGetScreenKeyProc)();
+
PortResource = (*XvGetRTPortProc)();
pxvs = GET_XV_SCREEN(pScreen);
@@ -322,9 +327,9 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor) pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
if(pPriv) {
if(pPriv->clientClip)
- REGION_DESTROY(pAdaptor->pScreen, pPriv->clientClip);
+ RegionDestroy(pPriv->clientClip);
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- REGION_DESTROY(pAdaptor->pScreen, pPriv->pCompositeClip);
+ RegionDestroy(pPriv->pCompositeClip);
free(pPriv);
}
}
@@ -636,14 +641,12 @@ xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv) {
RegionPtr pregWin, pCompositeClip;
WindowPtr pWin;
- ScreenPtr pScreen;
Bool freeCompClip = FALSE;
if(portPriv->pCompositeClip)
return;
pWin = (WindowPtr)portPriv->pDraw;
- pScreen = pWin->drawable.pScreen;
/* get window clip list */
if(portPriv->subWindowMode == IncludeInferiors) {
@@ -658,18 +661,18 @@ xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv) return;
}
- pCompositeClip = REGION_CREATE(pScreen, NullBox, 1);
- REGION_COPY(pScreen, pCompositeClip, portPriv->clientClip);
- REGION_TRANSLATE(pScreen, pCompositeClip,
+ pCompositeClip = RegionCreate(NullBox, 1);
+ RegionCopy(pCompositeClip, portPriv->clientClip);
+ RegionTranslate(pCompositeClip,
portPriv->pDraw->x + portPriv->clipOrg.x,
portPriv->pDraw->y + portPriv->clipOrg.y);
- REGION_INTERSECT(pScreen, pCompositeClip, pregWin, pCompositeClip);
+ RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
portPriv->pCompositeClip = pCompositeClip;
portPriv->FreeCompositeClip = TRUE;
if(freeCompClip) {
- REGION_DESTROY(pScreen, pregWin);
+ RegionDestroy(pregWin);
}
}
@@ -684,17 +687,17 @@ xf86XVCopyClip( /* copy the new clip if it exists */
if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
if(!portPriv->clientClip)
- portPriv->clientClip = REGION_CREATE(pScreen, NullBox, 1);
+ portPriv->clientClip = RegionCreate(NullBox, 1);
/* Note: this is in window coordinates */
- REGION_COPY(pScreen, portPriv->clientClip, pGC->clientClip);
+ RegionCopy(portPriv->clientClip, pGC->clientClip);
} else if(portPriv->clientClip) { /* free the old clientClip */
- REGION_DESTROY(pScreen, portPriv->clientClip);
+ RegionDestroy(portPriv->clientClip);
portPriv->clientClip = NULL;
}
/* get rid of the old clip list */
if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
- REGION_DESTROY(pScreen, portPriv->pCompositeClip);
+ RegionDestroy(portPriv->pCompositeClip);
}
portPriv->clipOrg = pGC->clipOrg;
@@ -709,11 +712,9 @@ xf86XVRegetVideo(XvPortRecPrivatePtr portPriv) RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
- ScreenPtr pScreen;
int ret = Success;
Bool clippedAway = FALSE;
- pScreen = portPriv->pDraw->pScreen;
xf86XVUpdateCompositeClip(portPriv);
/* translate the video region to the screen */
@@ -723,18 +724,18 @@ xf86XVRegetVideo(XvPortRecPrivatePtr portPriv) WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* that's all if it's totally obscured */
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->pScrn,
@@ -760,8 +761,8 @@ CLIP_VIDEO_BAILOUT: if(!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -773,12 +774,9 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv) RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
- ScreenPtr pScreen;
int ret = Success;
Bool clippedAway = FALSE;
- pScreen = portPriv->pDraw->pScreen;
-
xf86XVUpdateCompositeClip(portPriv);
/* translate the video region to the screen */
@@ -788,9 +786,9 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv) WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* clip and translate to the viewport */
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -802,21 +800,21 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv) VPBox.x2 = portPriv->pScrn->frameX1 + 1;
VPBox.y2 = portPriv->pScrn->frameY1 + 1;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
/* that's all if it's totally obscured */
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
/* bailout if we have to clip but the hardware doesn't support it */
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -826,7 +824,7 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv) }
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->pScrn,
@@ -851,8 +849,8 @@ CLIP_VIDEO_BAILOUT: if(!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -863,12 +861,9 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv) RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
- ScreenPtr pScreen;
int ret = Success;
Bool clippedAway = FALSE;
- pScreen = portPriv->pDraw->pScreen;
-
xf86XVUpdateCompositeClip(portPriv);
/* translate the video region to the screen */
@@ -878,9 +873,9 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv) WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* clip and translate to the viewport */
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -892,21 +887,21 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv) VPBox.x2 = portPriv->pScrn->frameX1 + 1;
VPBox.y2 = portPriv->pScrn->frameY1 + 1;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
/* that's all if it's totally obscured */
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
/* bailout if we have to clip but the hardware doesn't support it */
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -916,7 +911,7 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv) }
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->pScrn,
@@ -938,8 +933,8 @@ CLIP_VIDEO_BAILOUT: if(!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1060,7 +1055,7 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) XvPortRecPrivatePtr pPriv;
Bool AreasExposed;
- AreasExposed = (WinPriv && reg1 && REGION_NOTEMPTY(pScreen, reg1));
+ AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
pScreen->WindowExposures = ScreenPriv->WindowExposures;
(*pScreen->WindowExposures)(pWin, reg1, reg2);
@@ -1131,7 +1126,7 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) if(!pPriv) goto next;
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+ RegionDestroy(pPriv->pCompositeClip);
pPriv->pCompositeClip = NULL;
@@ -1225,7 +1220,7 @@ xf86XVQueryAdaptors( *p_nAdaptors = pxvs->nAdaptors;
*p_pAdaptors = pxvs->pAdaptors;
- return (Success);
+ return Success;
}
@@ -1268,7 +1263,7 @@ xf86XVLeaveVT(int index, int flags) pPriv->isOn = XV_OFF;
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+ RegionDestroy(pPriv->pCompositeClip);
pPriv->pCompositeClip = NULL;
@@ -1309,7 +1304,7 @@ xf86XVAdjustFrame(int index, int x, int y, int flags) if(!pPriv->type && (pPriv->isOn != XV_OFF)) { /* overlaid still/image */
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+ RegionDestroy(pPriv->pCompositeClip);
pPriv->pCompositeClip = NULL;
@@ -1413,7 +1408,6 @@ xf86XVPutStill( CARD16 drw_w, CARD16 drw_h
){
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- ScreenPtr pScreen;
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
@@ -1425,16 +1419,14 @@ xf86XVPutStill( if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
- pScreen = pDraw->pScreen;
-
WinBox.x1 = pDraw->x + drw_x;
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
@@ -1445,23 +1437,23 @@ xf86XVPutStill( VPBox.x2 = portPriv->pScrn->frameX1 + 1;
VPBox.y2 = portPriv->pScrn->frameY1 + 1;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
if(portPriv->pDraw) {
xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
}
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto PUT_STILL_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -1471,7 +1463,7 @@ xf86XVPutStill( }
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn,
@@ -1500,8 +1492,8 @@ PUT_STILL_BAILOUT: portPriv->isOn = XV_PENDING;
}
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1565,7 +1557,6 @@ xf86XVGetStill( CARD16 drw_w, CARD16 drw_h
){
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- ScreenPtr pScreen;
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
@@ -1577,28 +1568,26 @@ xf86XVGetStill( if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
- pScreen = pDraw->pScreen;
-
WinBox.x1 = pDraw->x + drw_x;
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->pDraw) {
xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
}
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto GET_STILL_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->GetStill)(portPriv->pScrn,
@@ -1615,8 +1604,8 @@ GET_STILL_BAILOUT: portPriv->isOn = XV_PENDING;
}
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1713,7 +1702,6 @@ xf86XVPutImage( CARD16 width, CARD16 height
){
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- ScreenPtr pScreen;
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
@@ -1725,16 +1713,14 @@ xf86XVPutImage( if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
- pScreen = pDraw->pScreen;
-
WinBox.x1 = pDraw->x + drw_x;
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
@@ -1745,9 +1731,9 @@ xf86XVPutImage( VPBox.x2 = portPriv->pScrn->frameX1 + 1;
VPBox.y2 = portPriv->pScrn->frameY1 + 1;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
/* If we are changing windows, unregister our port in the old window */
@@ -1758,14 +1744,14 @@ xf86XVPutImage( ret = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
if(ret != Success) goto PUT_IMAGE_BAILOUT;
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto PUT_IMAGE_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -1775,7 +1761,7 @@ xf86XVPutImage( }
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutImage)(portPriv->pScrn,
@@ -1803,8 +1789,8 @@ PUT_IMAGE_BAILOUT: portPriv->isOn = XV_PENDING;
}
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1834,8 +1820,8 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes) WindowPtr pWin = (WindowPtr)pDraw;
XF86XVWindowPtr pPriv = GET_XF86XV_WINDOW(pWin);
GCPtr pGC = NULL;
- BoxPtr pbox = REGION_RECTS(clipboxes);
- int i, nbox = REGION_NUM_RECTS(clipboxes);
+ BoxPtr pbox = RegionRects(clipboxes);
+ int i, nbox = RegionNumRects(clipboxes);
xRectangle *rects;
if(!xf86Screens[pScreen->myNum]->vtSema) return;
@@ -1860,7 +1846,7 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes) ValidateGC(pDraw, pGC);
}
- REGION_TRANSLATE(pDraw->pScreen, clipboxes, -pDraw->x, -pDraw->y);
+ RegionTranslate(clipboxes, -pDraw->x, -pDraw->y);
rects = malloc(nbox * sizeof(xRectangle));
@@ -1881,10 +1867,10 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes) void
xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
{
- DrawablePtr root = &WindowTable[pScreen->myNum]->drawable;
+ DrawablePtr root = &pScreen->root->drawable;
ChangeGCVal pval[2];
- BoxPtr pbox = REGION_RECTS(clipboxes);
- int i, nbox = REGION_NUM_RECTS(clipboxes);
+ BoxPtr pbox = RegionRects(clipboxes);
+ int i, nbox = RegionNumRects(clipboxes);
xRectangle *rects;
GCPtr gc;
@@ -1921,8 +1907,6 @@ xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes) boundaries in 16.16 fixed point.
*/
-#define DummyScreen screenInfo.screens[0]
-
Bool
xf86XVClipVideoHelper(
BoxPtr dst,
@@ -1936,7 +1920,7 @@ xf86XVClipVideoHelper( ){
double xsw, xdw, ysw, ydw;
INT32 delta;
- BoxPtr extents = REGION_EXTENTS(DummyScreen, reg);
+ BoxPtr extents = RegionExtents(reg);
int diff;
xsw = (*xb - *xa) << 16;
@@ -1998,9 +1982,9 @@ xf86XVClipVideoHelper( (dst->y1 > extents->y1) || (dst->y2 < extents->y2))
{
RegionRec clipReg;
- REGION_INIT(DummyScreen, &clipReg, dst, 1);
- REGION_INTERSECT(DummyScreen, reg, reg, &clipReg);
- REGION_UNINIT(DummyScreen, &clipReg);
+ RegionInit(&clipReg, dst, 1);
+ RegionIntersect(reg, reg, &clipReg);
+ RegionUninit(&clipReg);
}
return TRUE;
}
diff --git a/xorg-server/hw/xfree86/common/xf86xvmc.c b/xorg-server/hw/xfree86/common/xf86xvmc.c index 9cf36f526..5a7f69d8a 100644 --- a/xorg-server/hw/xfree86/common/xf86xvmc.c +++ b/xorg-server/hw/xfree86/common/xf86xvmc.c @@ -55,8 +55,8 @@ typedef struct { XvMCAdaptorPtr dixinfo;
} xf86XvMCScreenRec, *xf86XvMCScreenPtr;
-static int XF86XvMCScreenKeyIndex;
-static DevPrivateKey XF86XvMCScreenKey = &XF86XvMCScreenKeyIndex;
+static DevPrivateKeyRec XF86XvMCScreenKeyRec;
+#define XF86XvMCScreenKey (&XF86XvMCScreenKeyRec)
#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey)
@@ -172,6 +172,9 @@ Bool xf86XvMCScreenInit( if(!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
return FALSE;
+ if (!dixRegisterPrivateKey(&XF86XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
if(!(pScreenPriv = malloc(sizeof(xf86XvMCScreenRec)))) {
free(pAdapt);
return FALSE;
diff --git a/xorg-server/hw/xfree86/common/xisb.c b/xorg-server/hw/xfree86/common/xisb.c index f08327fb3..287a98b53 100644 --- a/xorg-server/hw/xfree86/common/xisb.c +++ b/xorg-server/hw/xfree86/common/xisb.c @@ -69,12 +69,12 @@ XisbNew (int fd, ssize_t size) b = malloc(sizeof (XISBuffer));
if (!b)
- return (NULL);
+ return NULL;
b->buf = malloc((sizeof (unsigned char) * size));
if (!b->buf)
{
free(b);
- return (NULL);
+ return NULL;
}
b->fd = fd;
@@ -83,7 +83,7 @@ XisbNew (int fd, ssize_t size) b->current = 1; /* force it to be past the end to trigger initial read */
b->end = 0;
b->buffer_size = size;
- return (b);
+ return b;
}
void
@@ -103,7 +103,7 @@ XisbRead (XISBuffer *b) if (b->block_duration >= 0)
{
if (xf86WaitForInput (b->fd, b->block_duration) < 1)
- return (-1);
+ return -1;
}
else
{
@@ -119,9 +119,9 @@ XisbRead (XISBuffer *b) switch (ret)
{
case 0:
- return (-1); /* timeout */
+ return -1; /* timeout */
case -1:
- return (-2); /* error */
+ return -2; /* error */
default:
b->end = ret;
b->current = 0;
@@ -132,7 +132,7 @@ XisbRead (XISBuffer *b) ErrorF ("read 0x%02x (%c)\n", b->buf[b->current],
isprint(b->buf[b->current])?b->buf[b->current]:'.');
- return (b->buf[b->current++]);
+ return b->buf[b->current++];
}
/* the only purpose of this function is to provide output tracing */
diff --git a/xorg-server/hw/xfree86/ddc/ddc.c b/xorg-server/hw/xfree86/ddc/ddc.c index ec6465818..3b70ce508 100644 --- a/xorg-server/hw/xfree86/ddc/ddc.c +++ b/xorg-server/hw/xfree86/ddc/ddc.c @@ -53,8 +53,8 @@ find_start(unsigned int *ptr) }
}
for (i=0;i<9;i++)
- if (test[i]) return (i+1);
- return (-1);
+ if (test[i]) return i+1;
+ return -1;
}
static unsigned char *
@@ -75,8 +75,8 @@ find_header(unsigned char *block) if (i==8) break;
ptr++;
}
- if (ptr == end) return (NULL);
- return (ptr);
+ if (ptr == end) return NULL;
+ return ptr;
}
static unsigned char *
@@ -98,7 +98,7 @@ resort(unsigned char *s_block) if (s_ptr == s_end) s_ptr = s_block;
}
free(s_block);
- return (d_new);
+ return d_new;
}
static int
@@ -120,7 +120,7 @@ DDC_checksum(unsigned char *block, int len) /* catch the trivial case where all bytes are 0 */
if (!not_null) return 1;
- return (result&0xFF);
+ return result&0xFF;
}
static unsigned char *
@@ -169,7 +169,7 @@ FetchEDID_DDC1(register ScrnInfoPtr pScrn, *xp = read_DDC(pScrn);
xp++;
} while(--count);
- return (ptr);
+ return ptr;
}
/* test if DDC1 return 0 if not */
@@ -184,7 +184,7 @@ TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC)(ScrnInfoPtr)) /* wait for next retrace */
if (old != read_DDC(pScrn)) break;
} while(count--);
- return (count);
+ return count;
}
/*
diff --git a/xorg-server/hw/xfree86/ddc/interpret_edid.c b/xorg-server/hw/xfree86/ddc/interpret_edid.c index 1a2d2f487..7558206cc 100644 --- a/xorg-server/hw/xfree86/ddc/interpret_edid.c +++ b/xorg-server/hw/xfree86/ddc/interpret_edid.c @@ -183,7 +183,7 @@ xf86InterpretEDID(int scrnIndex, Uchar *block) handle_edid_quirks(m);
encode_aspect_ratio(m);
- return (m);
+ return m;
error:
free(m);
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c index 0b7d62dca..453ade80b 100644 --- a/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c @@ -61,10 +61,11 @@ unsigned char DGAReqCode = 0; int DGAErrorBase;
int DGAEventBase;
-static int DGAScreenPrivateKeyIndex;
-static DevPrivateKey DGAScreenPrivateKey = &DGAScreenPrivateKeyIndex;
-static int DGAClientPrivateKeyIndex;
-static DevPrivateKey DGAClientPrivateKey = &DGAClientPrivateKeyIndex;
+static DevPrivateKeyRec DGAScreenPrivateKeyRec;
+#define DGAScreenPrivateKey (&DGAScreenPrivateKeyRec)
+#define DGAScreenPrivateKeyRegistered (DGAScreenPrivateKeyRec.initialized)
+static DevPrivateKeyRec DGAClientPrivateKeyRec;
+#define DGAClientPrivateKey (&DGAClientPrivateKeyRec)
static int DGACallbackRefCount = 0;
/* This holds the client's version information */
@@ -89,6 +90,12 @@ XFree86DGAExtensionInit(INITARGS) {
ExtensionEntry* extEntry;
+ if (!dixRegisterPrivateKey(&DGAClientPrivateKeyRec, PRIVATE_CLIENT, 0))
+ return;
+
+ if (!dixRegisterPrivateKey(&DGAScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
if ((extEntry = AddExtension(XF86DGANAME,
XF86DGANumberEvents,
XF86DGANumberErrors,
@@ -685,10 +692,10 @@ ProcXF86DGAGetVideoLL(ClientPtr client) rep.sequenceNumber = client->sequence;
if(!DGAAvailable(stuff->screen))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
if(!(num = DGAGetOldDGAMode(stuff->screen)))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
/* get the parameters for the mode that best matches */
DGAGetModeInfo(stuff->screen, &mode, num);
@@ -717,24 +724,24 @@ ProcXF86DGADirectVideo(ClientPtr client) if (stuff->screen > screenInfo.numScreens)
return BadValue;
- owner = DGA_GETCLIENT(stuff->screen);
-
REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq);
if (!DGAAvailable(stuff->screen))
return DGAErrorBase + XF86DGANoDirectVideoMode;
+ owner = DGA_GETCLIENT(stuff->screen);
+
if (owner && owner != client)
return DGAErrorBase + XF86DGANoDirectVideoMode;
if (stuff->enable & XF86DGADirectGraphics) {
if(!(num = DGAGetOldDGAMode(stuff->screen)))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
} else
num = 0;
if(Success != DGASetMode(stuff->screen, num, &mode, &pix))
- return (DGAErrorBase + XF86DGAScreenNotActive);
+ return DGAErrorBase + XF86DGAScreenNotActive;
DGASetInputMode (stuff->screen,
(stuff->enable & XF86DGADirectKeyb) != 0,
@@ -778,10 +785,10 @@ ProcXF86DGAGetViewPortSize(ClientPtr client) rep.sequenceNumber = client->sequence;
if (!DGAAvailable(stuff->screen))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
if(!(num = DGAGetOldDGAMode(stuff->screen)))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
DGAGetModeInfo(stuff->screen, &mode, num);
@@ -806,7 +813,7 @@ ProcXF86DGASetViewPort(ClientPtr client) REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq);
if (!DGAAvailable(stuff->screen))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
if (!DGAActive(stuff->screen))
return DGAErrorBase + XF86DGADirectNotActivated;
@@ -870,7 +877,7 @@ ProcXF86DGAInstallColormap(ClientPtr client) REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq);
if (!DGAActive(stuff->screen))
- return (DGAErrorBase + XF86DGADirectNotActivated);
+ return DGAErrorBase + XF86DGADirectNotActivated;
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP,
client, DixInstallAccess);
@@ -919,7 +926,7 @@ ProcXF86DGAViewPortChanged(ClientPtr client) REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq);
if (!DGAActive(stuff->screen))
- return (DGAErrorBase + XF86DGADirectNotActivated);
+ return DGAErrorBase + XF86DGADirectNotActivated;
rep.type = X_Reply;
rep.length = 0;
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c index f29f5bad2..31bb311b3 100644 --- a/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c @@ -51,8 +51,8 @@ from Kaleb S. KEITHLEY #define DEFAULT_XF86VIDMODE_VERBOSITY 3
static int VidModeErrorBase;
-static int VidModeClientPrivateKeyIndex;
-static DevPrivateKey VidModeClientPrivateKey = &VidModeClientPrivateKeyIndex;
+static DevPrivateKeyRec VidModeClientPrivateKeyRec;
+#define VidModeClientPrivateKey (&VidModeClientPrivateKeyRec)
/* This holds the client's version information */
typedef struct {
@@ -141,8 +141,8 @@ typedef struct _XF86VidModeScreenPrivate { Bool hasWindow;
} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr;
-static int ScreenPrivateKeyIndex;
-static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKeyIndex;
+static DevPrivateKeyRec ScreenPrivateKeyRec;
+#define ScreenPrivateKey (&ScreenPrivateKeyRec)
#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
@@ -169,6 +169,13 @@ XFree86VidModeExtensionInit(void) DEBUG_P("XFree86VidModeExtensionInit");
+ if (!dixRegisterPrivateKey(&VidModeClientPrivateKeyRec, PRIVATE_CLIENT, 0))
+ return;
+#ifdef XF86VIDMODE_EVENTS
+ if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return;
+#endif
+
#ifdef XF86VIDMODE_EVENTS
EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent");
#endif
@@ -177,9 +184,6 @@ XFree86VidModeExtensionInit(void) pScreen = screenInfo.screens[i];
if (VidModeExtensionInit(pScreen))
enabled = TRUE;
-#ifdef XF86VIDMODE_EVENTS
- SetScreenPrivate (pScreen, NULL);
-#endif
}
/* This means that the DDX doesn't want the vidmode extension enabled */
if (!enabled)
@@ -347,7 +351,7 @@ SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced) ev.type = XF86VidModeNotify + XF86VidModeEventBase;
ev.state = state;
ev.timestamp = currentTime.milliseconds;
- ev.root = WindowTable[pScreen->myNum]->drawable.id;
+ ev.root = pScreen->root->drawable.id;
ev.kind = kind;
ev.forced = forced;
WriteEventsToClient (pEv->client, 1, (xEvent *) &ev);
@@ -516,7 +520,7 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client) modecount = VidModeGetNumOfModes(stuff->screen);
if (modecount < 1)
- return (VidModeErrorBase + XF86VidModeExtensionDisabled);
+ return VidModeErrorBase + XF86VidModeExtensionDisabled;
if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
return BadValue;
@@ -1098,8 +1102,7 @@ ProcXF86VidModeValidateModeLine(ClientPtr client) status = VidModeCheckModeForDriver(stuff->screen, modetmp);
status_reply:
- if(modetmp)
- free(modetmp);
+ free(modetmp);
rep.type = X_Reply;
rep.length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply)
diff --git a/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre index bf1adc4e8..1bec1bf27 100644 --- a/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre +++ b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre @@ -1065,35 +1065,85 @@ of the class. If none of the optional entries appear, the .B InputClass
section is generic and will match any input device. If more than one of
these entries appear, they all must match for the configuration to apply.
-The allowed matching entries are shown below.
.PP
+There are two types of match entries used in
+.B InputClass
+sections. The first allows various tokens to be matched against attributes
+of the device. An entry can be constructed to match attributes from different
+devices by separating arguments with a '|' character. Multiple entries of the
+same type may be supplied to add multiple matching conditions on the same
+attribute. For example:
+.PP
+.RS 4
+.nf
+.B "Section \*qInputClass\*q"
+.B " Identifier \*qMy Class\*q"
+.B " # product string must contain example and
+.B " # either gizmo or gadget
+.B " MatchProduct \*qexample\*q
+.B " MatchProduct \*qgizmo|gadget\*q
+.I " ..."
+.B "EndSection"
+.fi
+.RE
.TP 7
.BI "MatchProduct \*q" matchproduct \*q
This entry can be used to check if the substring
.RI \*q matchproduct \*q
-occurs in the device's product name. Multiple substrings can be matched by
-separating arguments with a '|' character.
+occurs in the device's product name.
.TP 7
.BI "MatchVendor \*q" matchvendor \*q
This entry can be used to check if the substring
.RI \*q matchvendor \*q
-occurs in the device's vendor name. Multiple substrings can be matched by
-separating arguments with a '|' character.
+occurs in the device's vendor name.
.TP 7
.BI "MatchDevicePath \*q" matchdevice \*q
This entry can be used to check if the device file matches the
.RI \*q matchdevice \*q
-pathname pattern. Multiple patterns can be matched by separating arguments
-with a '|' character.
+pathname pattern.
+.TP 7
+.BI "MatchOS \*q" matchos \*q
+This entry can be used to check if the operating system matches the
+case-insensitive
+.RI \*q matchos \*q
+string. This entry is only supported on platforms providing the
+.BR uname (2)
+system call.
+.TP 7
+.BI "MatchPnPID \*q" matchpnp \*q
+The device's Plug and Play (PnP) ID can be checked against the
+.RI \*q matchpnp \*q
+shell wildcard pattern.
+.TP 7
+.BI "MatchUSBID \*q" matchusb \*q
+The device's USB ID can be checked against the
+.RI \*q matchusb \*q
+shell wildcard pattern. The ID is constructed as lowercase hexadecimal numbers
+separated by a ':'. This is the same format as the
+.BR lsusb (8)
+program.
+.TP 7
+.BI "MatchDriver \*q" matchdriver \*q
+Check the case-sensitive string
+.RI \*q matchdriver \*q
+against the currently configured driver of the device. Ordering of sections
+using this entry is important since it will not match unless the driver has
+been set by the config backend or a previous
+.B InputClass
+section.
.TP 7
.BI "MatchTag \*q" matchtag \*q
This entry can be used to check if tags assigned by the config backend
matches the
.RI \*q matchtag \*q
-pattern. Multiple patterns can be matched by separating arguments
-with a '|' character. A match is found if at least one of the tags given in
+pattern. A match is found if at least one of the tags given in
.RI \*q matchtag \*q
matches at least one of the tags assigned by the backend.
+.PP
+The second type of entry is used to match device types. These entries take a
+boolean argument similar to
+.B Option
+entries.
.TP 7
.BI "MatchIsKeyboard \*q" bool \*q
.TP 7
@@ -1106,9 +1156,6 @@ matches at least one of the tags assigned by the backend. .BI "MatchIsTouchpad \*q" bool \*q
.TP 7
.BI "MatchIsTouchscreen \*q" bool \*q
-Match device types. These entries take a boolean argument similar to
-.B Option
-entries.
.PP
When an input device has been matched to the
.B InputClass
diff --git a/xorg-server/hw/xfree86/doc/sgml/DESIGN.xml b/xorg-server/hw/xfree86/doc/sgml/DESIGN.xml index ff132a182..52a104cbc 100644 --- a/xorg-server/hw/xfree86/doc/sgml/DESIGN.xml +++ b/xorg-server/hw/xfree86/doc/sgml/DESIGN.xml @@ -118,8 +118,9 @@ routines common to all the X servers in the sample implementation. <title>The xorg.conf File</title>
<para>
-The xorg.conf file format is similar to the old format, with the following
-changes:
+The xorg.conf file format is based on the XF86Config format from XFree86 4.4,
+which is in turn similar to the old XFree86 3.x XF86Config format, with the
+following changes:
</para>
<sect2>
diff --git a/xorg-server/hw/xfree86/dri/dri.c b/xorg-server/hw/xfree86/dri/dri.c index a8b050a94..378731624 100644 --- a/xorg-server/hw/xfree86/dri/dri.c +++ b/xorg-server/hw/xfree86/dri/dri.c @@ -74,10 +74,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
static int DRIEntPrivIndex = -1;
-static int DRIScreenPrivKeyIndex;
-static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKeyIndex;
-static int DRIWindowPrivKeyIndex;
-static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKeyIndex;
+static DevPrivateKeyRec DRIScreenPrivKeyRec;
+#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
+static DevPrivateKeyRec DRIWindowPrivKeyRec;
+#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
static unsigned long DRIGeneration = 0;
static unsigned int DRIDrawableValidationStamp = 0;
@@ -357,6 +357,11 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) if (DRIGeneration != serverGeneration)
DRIGeneration = serverGeneration;
+ if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
@@ -573,10 +578,8 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) {
DRIDrvMsg(pScreen->myNum, X_ERROR,
"[drm] failed to setup DRM signal handler\n");
- if (pDRIPriv->hiddenContextStore)
- free(pDRIPriv->hiddenContextStore);
- if (pDRIPriv->partial3DContextStore)
- free(pDRIPriv->partial3DContextStore);
+ free(pDRIPriv->hiddenContextStore);
+ free(pDRIPriv->partial3DContextStore);
DRIDestroyContextPriv(pDRIContextPriv);
return FALSE;
} else {
@@ -785,7 +788,7 @@ drmServerInfo DRIDRMServerInfo = { Bool
DRIExtensionInit(void)
{
- if (!DRIScreenPrivKey || DRIGeneration != serverGeneration) {
+ if (DRIGeneration != serverGeneration) {
return FALSE;
}
@@ -1157,7 +1160,7 @@ DRIDCNTreeTraversal(WindowPtr pWin, pointer data) ScreenPtr pScreen = pWin->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (REGION_NUM_RECTS(&pWin->clipList) > 0) {
+ if (RegionNumRects(&pWin->clipList) > 0) {
WindowPtr *pDRIWindows = (WindowPtr*)data;
int i = 0;
@@ -1187,7 +1190,7 @@ DRIDriverClipNotify(ScreenPtr pScreen) if (pDRIPriv->nrWindows > 0) {
pDRIPriv->nrWalked = 0;
- TraverseTree(WindowTable[pScreen->myNum], DRIDCNTreeTraversal,
+ TraverseTree(pScreen->root, DRIDCNTreeTraversal,
(pointer)pDRIWindows);
}
@@ -1269,7 +1272,7 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable, pDRIDrawablePriv->pScreen = pScreen;
pDRIDrawablePriv->refCount = 1;
pDRIDrawablePriv->drawableIndex = -1;
- pDRIDrawablePriv->nrects = REGION_NUM_RECTS(&pWin->clipList);
+ pDRIDrawablePriv->nrects = RegionNumRects(&pWin->clipList);
/* save private off of preallocated index */
dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
@@ -1288,8 +1291,8 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable, drmUpdateDrawableInfo(pDRIPriv->drmFD,
pDRIDrawablePriv->hwDrawable,
DRM_DRAWABLE_CLIPRECTS,
- REGION_NUM_RECTS(&pWin->clipList),
- REGION_RECTS(&pWin->clipList));
+ RegionNumRects(&pWin->clipList),
+ RegionRects(&pWin->clipList));
*hHWDrawable = pDRIDrawablePriv->hwDrawable;
}
}
@@ -1502,8 +1505,8 @@ DRIGetDrawableInfo(ScreenPtr pScreen, #endif
*W = (int)(pWin->drawable.width);
*H = (int)(pWin->drawable.height);
- *numClipRects = REGION_NUM_RECTS(&pWin->clipList);
- *pClipRects = (drm_clip_rect_t *)REGION_RECTS(&pWin->clipList);
+ *numClipRects = RegionNumRects(&pWin->clipList);
+ *pClipRects = (drm_clip_rect_t *)RegionRects(&pWin->clipList);
if (!*numClipRects && pDRIPriv->fullscreen) {
/* use fake full-screen clip rect */
@@ -1613,7 +1616,7 @@ DRICreateInfoRec(void) void
DRIDestroyInfoRec(DRIInfoPtr DRIInfo)
{
- if (DRIInfo->busIdString) free(DRIInfo->busIdString);
+ free(DRIInfo->busIdString);
free((char*)DRIInfo);
}
@@ -1883,10 +1886,10 @@ DRITreeTraversal(WindowPtr pWin, pointer data) ScreenPtr pScreen = pWin->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if(REGION_NUM_RECTS(&(pWin->clipList)) > 0) {
+ if(RegionNumRects(&(pWin->clipList)) > 0) {
RegionPtr reg = (RegionPtr)data;
- REGION_UNION(pScreen, reg, reg, &(pWin->clipList));
+ RegionUnion(reg, reg, &(pWin->clipList));
pDRIPriv->nrWalked++;
}
@@ -1932,21 +1935,21 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) if(pDRIPriv->nrWindowsVisible > 0) {
RegionRec reg;
- REGION_NULL(pScreen, ®);
+ RegionNull(®);
pDRIPriv->nrWalked = 0;
TraverseTree(pWin, DRITreeTraversal, (pointer)(®));
- if(REGION_NOTEMPTY(pScreen, ®)) {
- REGION_TRANSLATE(pScreen, ®, ptOldOrg.x - pWin->drawable.x,
+ if(RegionNotEmpty(®)) {
+ RegionTranslate(®, ptOldOrg.x - pWin->drawable.x,
ptOldOrg.y - pWin->drawable.y);
- REGION_INTERSECT(pScreen, ®, ®, prgnSrc);
+ RegionIntersect(®, ®, prgnSrc);
/* The MoveBuffers interface is not ideal */
(*pDRIPriv->pDriverInfo->MoveBuffers)(pWin, ptOldOrg, ®,
pDRIPriv->pDriverInfo->ddxDrawableTableEntry);
}
- REGION_UNINIT(pScreen, ®);
+ RegionUninit(®);
}
/* call lower wrapped functions */
@@ -2122,7 +2125,7 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy) if(!pDRIPriv) return;
if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
- int nrects = REGION_NUM_RECTS(&pWin->clipList);
+ int nrects = RegionNumRects(&pWin->clipList);
if(!pDRIPriv->windowsTouched) {
DRILockTree(pScreen);
@@ -2143,7 +2146,7 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy) drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable,
DRM_DRAWABLE_CLIPRECTS,
- nrects, REGION_RECTS(&pWin->clipList));
+ nrects, RegionRects(&pWin->clipList));
}
/* call lower wrapped functions */
@@ -2368,9 +2371,9 @@ DRIMoveBuffersHelper( BoxRec tmpBox;
int y, nbox;
- extents = REGION_EXTENTS(pScreen, reg);
- nbox = REGION_NUM_RECTS(reg);
- pbox = REGION_RECTS(reg);
+ extents = RegionExtents(reg);
+ nbox = RegionNumRects(reg);
+ pbox = RegionRects(reg);
if((dy > 0) && (dy < (extents->y2 - extents->y1))) {
*ydir = -1;
diff --git a/xorg-server/hw/xfree86/dri/dristruct.h b/xorg-server/hw/xfree86/dri/dristruct.h index fc929c2f9..bbd158e11 100644 --- a/xorg-server/hw/xfree86/dri/dristruct.h +++ b/xorg-server/hw/xfree86/dri/dristruct.h @@ -1,128 +1,129 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -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, sub license, 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 (including the -next paragraph) 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 NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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. - -**************************************************************************/ - -/* - * Authors: - * Jens Owen <jens@tungstengraphics.com> - * - */ - -#ifndef DRI_STRUCT_H -#define DRI_STRUCT_H - -#include "xf86drm.h" -#include "xf86Crtc.h" - - -#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \ - dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey)) -#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \ - dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey)) - -typedef struct _DRIDrawablePrivRec -{ - drm_drawable_t hwDrawable; - int drawableIndex; - ScreenPtr pScreen; - int refCount; - int nrects; -} DRIDrawablePrivRec, *DRIDrawablePrivPtr; - -struct _DRIContextPrivRec -{ - drm_context_t hwContext; - ScreenPtr pScreen; - Bool valid3D; - DRIContextFlags flags; - void** pContextStore; -}; - -#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \ - dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey)) - -#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \ - dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \ - DRIScreenPrivKey)) - -#define DRI_ENT_PRIV(pScrn) \ - ((DRIEntPrivIndex < 0) ? \ - NULL: \ - ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \ - DRIEntPrivIndex)->ptr))) - -typedef struct _DRIScreenPrivRec -{ - Bool directRenderingSupport; - int drmFD; /* File descriptor for /dev/video/? */ - drm_handle_t hSAREA; /* Handle to SAREA, for mapping */ - XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */ - drm_context_t myContext; /* DDX Driver's context */ - DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */ - DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */ - void** hiddenContextStore; /* hidden X context */ - void** partial3DContextStore; /* parital 3D context */ - DRIInfoPtr pDriverInfo; - int nrWindows; - int nrWindowsVisible; - int nrWalked; - drm_clip_rect_t private_buffer_rect; /* management of private buffers */ - DrawablePtr fullscreen; /* pointer to fullscreen drawable */ - drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */ - DRIWrappedFuncsRec wrap; - DestroyWindowProcPtr DestroyWindow; - DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES]; - DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */ - Bool createDummyCtx; - Bool createDummyCtxPriv; - Bool grabbedDRILock; - Bool drmSIGIOHandlerInstalled; - Bool wrapped; - Bool windowsTouched; - int lockRefCount; - drm_handle_t hLSAREA; /* Handle to SAREA containing lock, for mapping */ - XF86DRILSAREAPtr pLSAREA; /* Mapped pointer to SAREA containing lock */ - int* pLockRefCount; - int* pLockingContext; - xf86_crtc_notify_proc_ptr xf86_crtc_notify; -} DRIScreenPrivRec, *DRIScreenPrivPtr; - - -typedef struct _DRIEntPrivRec { - int drmFD; - Bool drmOpened; - Bool sAreaGrabbed; - drm_handle_t hLSAREA; - XF86DRILSAREAPtr pLSAREA; - unsigned long sAreaSize; - int lockRefCount; - int lockingContext; - ScreenPtr resOwner; - Bool keepFDOpen; - int refCount; -} DRIEntPrivRec, *DRIEntPrivPtr; - -#endif /* DRI_STRUCT_H */ +/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+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, sub license, 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 (including the
+next paragraph) 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Jens Owen <jens@tungstengraphics.com>
+ *
+ */
+
+#ifndef DRI_STRUCT_H
+#define DRI_STRUCT_H
+
+#include "xf86drm.h"
+#include "xf86Crtc.h"
+
+
+#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
+#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey))
+
+typedef struct _DRIDrawablePrivRec
+{
+ drm_drawable_t hwDrawable;
+ int drawableIndex;
+ ScreenPtr pScreen;
+ int refCount;
+ int nrects;
+} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
+
+struct _DRIContextPrivRec
+{
+ drm_context_t hwContext;
+ ScreenPtr pScreen;
+ Bool valid3D;
+ DRIContextFlags flags;
+ void** pContextStore;
+};
+
+#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
+ (dixPrivateKeyRegistered(DRIScreenPrivKey) ? \
+ dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey) : NULL))
+
+#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
+ dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
+ DRIScreenPrivKey))
+
+#define DRI_ENT_PRIV(pScrn) \
+ ((DRIEntPrivIndex < 0) ? \
+ NULL: \
+ ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \
+ DRIEntPrivIndex)->ptr)))
+
+typedef struct _DRIScreenPrivRec
+{
+ Bool directRenderingSupport;
+ int drmFD; /* File descriptor for /dev/video/? */
+ drm_handle_t hSAREA; /* Handle to SAREA, for mapping */
+ XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */
+ drm_context_t myContext; /* DDX Driver's context */
+ DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */
+ DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */
+ void** hiddenContextStore; /* hidden X context */
+ void** partial3DContextStore; /* parital 3D context */
+ DRIInfoPtr pDriverInfo;
+ int nrWindows;
+ int nrWindowsVisible;
+ int nrWalked;
+ drm_clip_rect_t private_buffer_rect; /* management of private buffers */
+ DrawablePtr fullscreen; /* pointer to fullscreen drawable */
+ drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */
+ DRIWrappedFuncsRec wrap;
+ DestroyWindowProcPtr DestroyWindow;
+ DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES];
+ DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */
+ Bool createDummyCtx;
+ Bool createDummyCtxPriv;
+ Bool grabbedDRILock;
+ Bool drmSIGIOHandlerInstalled;
+ Bool wrapped;
+ Bool windowsTouched;
+ int lockRefCount;
+ drm_handle_t hLSAREA; /* Handle to SAREA containing lock, for mapping */
+ XF86DRILSAREAPtr pLSAREA; /* Mapped pointer to SAREA containing lock */
+ int* pLockRefCount;
+ int* pLockingContext;
+ xf86_crtc_notify_proc_ptr xf86_crtc_notify;
+} DRIScreenPrivRec, *DRIScreenPrivPtr;
+
+
+typedef struct _DRIEntPrivRec {
+ int drmFD;
+ Bool drmOpened;
+ Bool sAreaGrabbed;
+ drm_handle_t hLSAREA;
+ XF86DRILSAREAPtr pLSAREA;
+ unsigned long sAreaSize;
+ int lockRefCount;
+ int lockingContext;
+ ScreenPtr resOwner;
+ Bool keepFDOpen;
+ int refCount;
+} DRIEntPrivRec, *DRIEntPrivPtr;
+
+#endif /* DRI_STRUCT_H */
diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c index 29c917f21..bb1be358b 100644 --- a/xorg-server/hw/xfree86/dri2/dri2.c +++ b/xorg-server/hw/xfree86/dri2/dri2.c @@ -1,1140 +1,1177 @@ -/* - * Copyright © 2007, 2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kristian Høgsberg (krh@redhat.com) - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <errno.h> -#include <xf86drm.h> -#include "xf86Module.h" -#include "list.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include "dixstruct.h" -#include "dri2.h" -#include "xf86VGAarbiter.h" - -#include "xf86.h" - -CARD8 dri2_major; /* version of DRI2 supported by DDX */ -CARD8 dri2_minor; - -static int dri2ScreenPrivateKeyIndex; -static DevPrivateKey dri2ScreenPrivateKey = &dri2ScreenPrivateKeyIndex; -static int dri2WindowPrivateKeyIndex; -static DevPrivateKey dri2WindowPrivateKey = &dri2WindowPrivateKeyIndex; -static int dri2PixmapPrivateKeyIndex; -static DevPrivateKey dri2PixmapPrivateKey = &dri2PixmapPrivateKeyIndex; -static RESTYPE dri2DrawableRes; - -typedef struct _DRI2Screen *DRI2ScreenPtr; - -typedef struct _DRI2Drawable { - DRI2ScreenPtr dri2_screen; - DrawablePtr drawable; - struct list reference_list; - int width; - int height; - DRI2BufferPtr *buffers; - int bufferCount; - unsigned int swapsPending; - ClientPtr blockedClient; - Bool blockedOnMsc; - int swap_interval; - CARD64 swap_count; - int64_t target_sbc; /* -1 means no SBC wait outstanding */ - CARD64 last_swap_target; /* most recently queued swap target */ - CARD64 last_swap_msc; /* msc at completion of most recent swap */ - CARD64 last_swap_ust; /* ust at completion of most recent swap */ - int swap_limit; /* for N-buffering */ -} DRI2DrawableRec, *DRI2DrawablePtr; - -typedef struct _DRI2Screen { - ScreenPtr screen; - int refcnt; - unsigned int numDrivers; - const char **driverNames; - const char *deviceName; - int fd; - unsigned int lastSequence; - - DRI2CreateBufferProcPtr CreateBuffer; - DRI2DestroyBufferProcPtr DestroyBuffer; - DRI2CopyRegionProcPtr CopyRegion; - DRI2ScheduleSwapProcPtr ScheduleSwap; - DRI2GetMSCProcPtr GetMSC; - DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC; - - HandleExposuresProcPtr HandleExposures; - - ConfigNotifyProcPtr ConfigNotify; -} DRI2ScreenRec; - -static DRI2ScreenPtr -DRI2GetScreen(ScreenPtr pScreen) -{ - return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey); -} - -static DRI2DrawablePtr -DRI2GetDrawable(DrawablePtr pDraw) -{ - WindowPtr pWin; - PixmapPtr pPixmap; - - if (pDraw->type == DRAWABLE_WINDOW) { - pWin = (WindowPtr) pDraw; - return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey); - } else { - pPixmap = (PixmapPtr) pDraw; - return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey); - } -} - -static DRI2DrawablePtr -DRI2AllocateDrawable(DrawablePtr pDraw) -{ - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); - DRI2DrawablePtr pPriv; - CARD64 ust; - WindowPtr pWin; - PixmapPtr pPixmap; - - pPriv = malloc(sizeof *pPriv); - if (pPriv == NULL) - return NULL; - - pPriv->dri2_screen = ds; - pPriv->drawable = pDraw; - pPriv->width = pDraw->width; - pPriv->height = pDraw->height; - pPriv->buffers = NULL; - pPriv->bufferCount = 0; - pPriv->swapsPending = 0; - pPriv->blockedClient = NULL; - pPriv->blockedOnMsc = FALSE; - pPriv->swap_count = 0; - pPriv->target_sbc = -1; - pPriv->swap_interval = 1; - /* Initialize last swap target from DDX if possible */ - if (!ds->GetMSC || !(*ds->GetMSC)(pDraw, &ust, &pPriv->last_swap_target)) - pPriv->last_swap_target = 0; - - pPriv->swap_limit = 1; /* default to double buffering */ - pPriv->last_swap_msc = 0; - pPriv->last_swap_ust = 0; - list_init(&pPriv->reference_list); - - if (pDraw->type == DRAWABLE_WINDOW) { - pWin = (WindowPtr) pDraw; - dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv); - } else { - pPixmap = (PixmapPtr) pDraw; - dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv); - } - - return pPriv; -} - -typedef struct DRI2DrawableRefRec { - XID id; - XID dri2_id; - DRI2InvalidateProcPtr invalidate; - void *priv; - struct list link; -} DRI2DrawableRefRec, *DRI2DrawableRefPtr; - -static DRI2DrawableRefPtr -DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id) -{ - DRI2DrawableRefPtr ref; - - list_for_each_entry(ref, &pPriv->reference_list, link) { - if (ref->id == id) - return ref; - } - - return NULL; -} - -static int -DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id, - DRI2InvalidateProcPtr invalidate, void *priv) -{ - DRI2DrawableRefPtr ref; - - ref = malloc(sizeof *ref); - if (ref == NULL) - return BadAlloc; - - if (!AddResource(dri2_id, dri2DrawableRes, pPriv)) - return BadAlloc; - if (!DRI2LookupDrawableRef(pPriv, id)) - if (!AddResource(id, dri2DrawableRes, pPriv)) - return BadAlloc; - - ref->id = id; - ref->dri2_id = dri2_id; - ref->invalidate = invalidate; - ref->priv = priv; - list_add(&ref->link, &pPriv->reference_list); - - return Success; -} - -int -DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id, - DRI2InvalidateProcPtr invalidate, void *priv) -{ - DRI2DrawablePtr pPriv; - XID dri2_id; - int rc; - - pPriv = DRI2GetDrawable(pDraw); - if (pPriv == NULL) - pPriv = DRI2AllocateDrawable(pDraw); - if (pPriv == NULL) - return BadAlloc; - - dri2_id = FakeClientID(client->index); - rc = DRI2AddDrawableRef(pPriv, id, dri2_id, invalidate, priv); - if (rc != Success) - return rc; - - return Success; -} - -static int DRI2DrawableGone(pointer p, XID id) -{ - DRI2DrawablePtr pPriv = p; - DRI2ScreenPtr ds = pPriv->dri2_screen; - DRI2DrawableRefPtr ref, next; - WindowPtr pWin; - PixmapPtr pPixmap; - DrawablePtr pDraw; - int i; - - list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) { - if (ref->dri2_id == id) { - list_del(&ref->link); - /* If this was the last ref under this X drawable XID, - * unregister the X drawable resource. */ - if (!DRI2LookupDrawableRef(pPriv, ref->id)) - FreeResourceByType(ref->id, dri2DrawableRes, TRUE); - free(ref); - break; - } - - if (ref->id == id) { - list_del(&ref->link); - FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE); - free(ref); - } - } - - if (!list_is_empty(&pPriv->reference_list)) - return Success; - - pDraw = pPriv->drawable; - if (pDraw->type == DRAWABLE_WINDOW) { - pWin = (WindowPtr) pDraw; - dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL); - } else { - pPixmap = (PixmapPtr) pDraw; - dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL); - } - - if (pPriv->buffers != NULL) { - for (i = 0; i < pPriv->bufferCount; i++) - (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]); - - free(pPriv->buffers); - } - - free(pPriv); - - return Success; -} - -static int -find_attachment(DRI2DrawablePtr pPriv, unsigned attachment) -{ - int i; - - if (pPriv->buffers == NULL) { - return -1; - } - - for (i = 0; i < pPriv->bufferCount; i++) { - if ((pPriv->buffers[i] != NULL) - && (pPriv->buffers[i]->attachment == attachment)) { - return i; - } - } - - return -1; -} - -static Bool -allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds, - DRI2DrawablePtr pPriv, - unsigned int attachment, unsigned int format, - int dimensions_match, DRI2BufferPtr *buffer) -{ - int old_buf = find_attachment(pPriv, attachment); - - if ((old_buf < 0) - || !dimensions_match - || (pPriv->buffers[old_buf]->format != format)) { - *buffer = (*ds->CreateBuffer)(pDraw, attachment, format); - return TRUE; - - } else { - *buffer = pPriv->buffers[old_buf]; - pPriv->buffers[old_buf] = NULL; - return FALSE; - } -} - -static void -update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw, - DRI2BufferPtr *buffers, int *out_count, int *width, int *height) -{ - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); - int i; - - if (pPriv->buffers != NULL) { - for (i = 0; i < pPriv->bufferCount; i++) { - if (pPriv->buffers[i] != NULL) { - (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]); - } - } - - free(pPriv->buffers); - } - - pPriv->buffers = buffers; - pPriv->bufferCount = *out_count; - pPriv->width = pDraw->width; - pPriv->height = pDraw->height; - *width = pPriv->width; - *height = pPriv->height; -} - -static DRI2BufferPtr * -do_get_buffers(DrawablePtr pDraw, int *width, int *height, - unsigned int *attachments, int count, int *out_count, - int has_format) -{ - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); - DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw); - DRI2BufferPtr *buffers; - int need_real_front = 0; - int need_fake_front = 0; - int have_fake_front = 0; - int front_format = 0; - int dimensions_match; - int buffers_changed = 0; - int i; - - if (!pPriv) { - *width = pDraw->width; - *height = pDraw->height; - *out_count = 0; - return NULL; - } - - dimensions_match = (pDraw->width == pPriv->width) - && (pDraw->height == pPriv->height); - - buffers = malloc((count + 1) * sizeof(buffers[0])); - - for (i = 0; i < count; i++) { - const unsigned attachment = *(attachments++); - const unsigned format = (has_format) ? *(attachments++) : 0; - - if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment, - format, dimensions_match, - &buffers[i])) - buffers_changed = 1; - - if (buffers[i] == NULL) - goto err_out; - - /* If the drawable is a window and the front-buffer is requested, - * silently add the fake front-buffer to the list of requested - * attachments. The counting logic in the loop accounts for the case - * where the client requests both the fake and real front-buffer. - */ - if (attachment == DRI2BufferBackLeft) { - need_real_front++; - front_format = format; - } - - if (attachment == DRI2BufferFrontLeft) { - need_real_front--; - front_format = format; - - if (pDraw->type == DRAWABLE_WINDOW) { - need_fake_front++; - } - } - - if (pDraw->type == DRAWABLE_WINDOW) { - if (attachment == DRI2BufferFakeFrontLeft) { - need_fake_front--; - have_fake_front = 1; - } - } - } - - if (need_real_front > 0) { - if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft, - front_format, dimensions_match, - &buffers[i])) - buffers_changed = 1; - - if (buffers[i] == NULL) - goto err_out; - i++; - } - - if (need_fake_front > 0) { - if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft, - front_format, dimensions_match, - &buffers[i])) - buffers_changed = 1; - - if (buffers[i] == NULL) - goto err_out; - - i++; - have_fake_front = 1; - } - - *out_count = i; - - update_dri2_drawable_buffers(pPriv, pDraw, buffers, out_count, width, height); - - /* If the client is getting a fake front-buffer, pre-fill it with the - * contents of the real front-buffer. This ensures correct operation of - * applications that call glXWaitX before calling glDrawBuffer. - */ - if (have_fake_front && buffers_changed) { - BoxRec box; - RegionRec region; - - box.x1 = 0; - box.y1 = 0; - box.x2 = pPriv->width; - box.y2 = pPriv->height; - REGION_INIT(pDraw->pScreen, ®ion, &box, 0); - - DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft, - DRI2BufferFrontLeft); - } - - return pPriv->buffers; - -err_out: - - *out_count = 0; - - for (i = 0; i < count; i++) { - if (buffers[i] != NULL) - (*ds->DestroyBuffer)(pDraw, buffers[i]); - } - - free(buffers); - buffers = NULL; - - update_dri2_drawable_buffers(pPriv, pDraw, buffers, out_count, width, height); - - return buffers; -} - -DRI2BufferPtr * -DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, - unsigned int *attachments, int count, int *out_count) -{ - return do_get_buffers(pDraw, width, height, attachments, count, - out_count, FALSE); -} - -DRI2BufferPtr * -DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height, - unsigned int *attachments, int count, int *out_count) -{ - return do_get_buffers(pDraw, width, height, attachments, count, - out_count, TRUE); -} - -static void -DRI2InvalidateDrawable(DrawablePtr pDraw) -{ - DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw); - DRI2DrawableRefPtr ref; - - if (!pPriv) - return; - - list_for_each_entry(ref, &pPriv->reference_list, link) - ref->invalidate(pDraw, ref->priv); -} - -/* - * In the direct rendered case, we throttle the clients that have more - * than their share of outstanding swaps (and thus busy buffers) when a - * new GetBuffers request is received. In the AIGLX case, we allow the - * client to get the new buffers, but throttle when the next GLX request - * comes in (see __glXDRIcontextWait()). - */ -Bool -DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw) -{ - DRI2DrawablePtr pPriv; - - pPriv = DRI2GetDrawable(pDraw); - if (pPriv == NULL) - return FALSE; - - /* Throttle to swap limit */ - if ((pPriv->swapsPending >= pPriv->swap_limit) && - !pPriv->blockedClient) { - ResetCurrentRequest(client); - client->sequence--; - IgnoreClient(client); - pPriv->blockedClient = client; - return TRUE; - } - - return FALSE; -} - -static void -__DRI2BlockClient(ClientPtr client, DRI2DrawablePtr pPriv) -{ - if (pPriv->blockedClient == NULL) { - IgnoreClient(client); - pPriv->blockedClient = client; - } -} - -void -DRI2BlockClient(ClientPtr client, DrawablePtr pDraw) -{ - DRI2DrawablePtr pPriv; - - pPriv = DRI2GetDrawable(pDraw); - if (pPriv == NULL) - return; - - __DRI2BlockClient(client, pPriv); - pPriv->blockedOnMsc = TRUE; -} - -int -DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion, - unsigned int dest, unsigned int src) -{ - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); - DRI2DrawablePtr pPriv; - DRI2BufferPtr pDestBuffer, pSrcBuffer; - int i; - - pPriv = DRI2GetDrawable(pDraw); - if (pPriv == NULL) - return BadDrawable; - - pDestBuffer = NULL; - pSrcBuffer = NULL; - for (i = 0; i < pPriv->bufferCount; i++) - { - if (pPriv->buffers[i]->attachment == dest) - pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i]; - if (pPriv->buffers[i]->attachment == src) - pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i]; - } - if (pSrcBuffer == NULL || pDestBuffer == NULL) - return BadValue; - - (*ds->CopyRegion)(pDraw, pRegion, pDestBuffer, pSrcBuffer); - - return Success; -} - -/* Can this drawable be page flipped? */ -Bool -DRI2CanFlip(DrawablePtr pDraw) -{ - ScreenPtr pScreen = pDraw->pScreen; - WindowPtr pWin, pRoot; - PixmapPtr pWinPixmap, pRootPixmap; - - if (pDraw->type == DRAWABLE_PIXMAP) - return TRUE; - - pRoot = WindowTable[pScreen->myNum]; - pRootPixmap = pScreen->GetWindowPixmap(pRoot); - - pWin = (WindowPtr) pDraw; - pWinPixmap = pScreen->GetWindowPixmap(pWin); - if (pRootPixmap != pWinPixmap) - return FALSE; - if (!REGION_EQUAL(pScreen, &pWin->clipList, &pRoot->winSize)) - return FALSE; - - return TRUE; -} - -/* Can we do a pixmap exchange instead of a blit? */ -Bool -DRI2CanExchange(DrawablePtr pDraw) -{ - return FALSE; -} - -void -DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame, - unsigned int tv_sec, unsigned int tv_usec) -{ - DRI2DrawablePtr pPriv; - - pPriv = DRI2GetDrawable(pDraw); - if (pPriv == NULL) - return; - - ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec, - frame, pPriv->swap_count); - - if (pPriv->blockedClient) - AttendClient(pPriv->blockedClient); - - pPriv->blockedClient = NULL; - pPriv->blockedOnMsc = FALSE; -} - -static void -DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame, - unsigned int tv_sec, unsigned int tv_usec) -{ - ScreenPtr pScreen = pDraw->pScreen; - DRI2DrawablePtr pPriv; - - pPriv = DRI2GetDrawable(pDraw); - if (pPriv == NULL) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: bad drawable\n", __func__); - return; - } - - /* - * Swap completed. - * Wake the client iff: - * - it was waiting on SBC - * - was blocked due to GLX make current - * - was blocked due to swap throttling - * - is not blocked due to an MSC wait - */ - if (pPriv->target_sbc != -1 && - pPriv->target_sbc <= pPriv->swap_count) { - ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec, - frame, pPriv->swap_count); - pPriv->target_sbc = -1; - - AttendClient(pPriv->blockedClient); - pPriv->blockedClient = NULL; - } else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) { - if (pPriv->blockedClient) { - AttendClient(pPriv->blockedClient); - pPriv->blockedClient = NULL; - } - } -} - -void -DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame, - unsigned int tv_sec, unsigned int tv_usec, int type, - DRI2SwapEventPtr swap_complete, void *swap_data) -{ - ScreenPtr pScreen = pDraw->pScreen; - DRI2DrawablePtr pPriv; - CARD64 ust = 0; - BoxRec box; - RegionRec region; - - pPriv = DRI2GetDrawable(pDraw); - if (pPriv == NULL) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: bad drawable\n", __func__); - return; - } - - pPriv->swapsPending--; - pPriv->swap_count++; - - box.x1 = 0; - box.y1 = 0; - box.x2 = pDraw->width; - box.y2 = pDraw->height; - REGION_INIT(pScreen, ®ion, &box, 0); - DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft, - DRI2BufferFrontLeft); - - ust = ((CARD64)tv_sec * 1000000) + tv_usec; - if (swap_complete) - swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count); - - pPriv->last_swap_msc = frame; - pPriv->last_swap_ust = ust; - - DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec); -} - -Bool -DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable) -{ - DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable); - - /* If we're currently waiting for a swap on this drawable, reset - * the request and suspend the client. We only support one - * blocked client per drawable. */ - if ((pPriv->swapsPending) && - pPriv->blockedClient == NULL) { - ResetCurrentRequest(client); - client->sequence--; - __DRI2BlockClient(client, pPriv); - return TRUE; - } - - return FALSE; -} - -int -DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc, - CARD64 divisor, CARD64 remainder, CARD64 *swap_target, - DRI2SwapEventPtr func, void *data) -{ - ScreenPtr pScreen = pDraw->pScreen; - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); - DRI2DrawablePtr pPriv; - DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL; - int ret, i; - - pPriv = DRI2GetDrawable(pDraw); - if (pPriv == NULL) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: bad drawable\n", __func__); - return BadDrawable; - } - - for (i = 0; i < pPriv->bufferCount; i++) { - if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft) - pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i]; - if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft) - pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i]; - } - if (pSrcBuffer == NULL || pDestBuffer == NULL) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: drawable has no back or front?\n", __func__); - return BadDrawable; - } - - /* Old DDX or no swap interval, just blit */ - if (!ds->ScheduleSwap || !pPriv->swap_interval) { - BoxRec box; - RegionRec region; - - box.x1 = 0; - box.y1 = 0; - box.x2 = pDraw->width; - box.y2 = pDraw->height; - REGION_INIT(pScreen, ®ion, &box, 0); - - pPriv->swapsPending++; - - (*ds->CopyRegion)(pDraw, ®ion, pDestBuffer, pSrcBuffer); - DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE, - func, data); - return Success; - } - - /* - * In the simple glXSwapBuffers case, all params will be 0, and we just - * need to schedule a swap for the last swap target + the swap interval. - */ - if (target_msc == 0 && divisor == 0 && remainder == 0) { - /* - * Swap target for this swap is last swap target + swap interval since - * we have to account for the current swap count, interval, and the - * number of pending swaps. - */ - *swap_target = pPriv->last_swap_target + pPriv->swap_interval; - } else { - /* glXSwapBuffersMscOML could have a 0 target_msc, honor it */ - *swap_target = target_msc; - } - - pPriv->swapsPending++; - ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer, - swap_target, divisor, remainder, func, data); - if (!ret) { - pPriv->swapsPending--; /* didn't schedule */ - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: driver failed to schedule swap\n", __func__); - return BadDrawable; - } - - pPriv->last_swap_target = *swap_target; - - /* According to spec, return expected swapbuffers count SBC after this swap - * will complete. - */ - *swap_target = pPriv->swap_count + pPriv->swapsPending; - - DRI2InvalidateDrawable(pDraw); - - return Success; -} - -void -DRI2SwapInterval(DrawablePtr pDrawable, int interval) -{ - ScreenPtr pScreen = pDrawable->pScreen; - DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable); - - if (pPriv == NULL) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: bad drawable\n", __func__); - return; - } - - /* fixme: check against arbitrary max? */ - pPriv->swap_interval = interval; -} - -int -DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc) -{ - ScreenPtr pScreen = pDraw->pScreen; - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); - DRI2DrawablePtr pPriv; - Bool ret; - - pPriv = DRI2GetDrawable(pDraw); - if (pPriv == NULL) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: bad drawable\n", __func__); - return BadDrawable; - } - - if (!ds->GetMSC) { - *ust = 0; - *msc = 0; - *sbc = pPriv->swap_count; - return Success; - } - - /* - * Spec needs to be updated to include unmapped or redirected - * drawables - */ - - ret = (*ds->GetMSC)(pDraw, ust, msc); - if (!ret) - return BadDrawable; - - *sbc = pPriv->swap_count; - - return Success; -} - -int -DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc, - CARD64 divisor, CARD64 remainder) -{ - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); - DRI2DrawablePtr pPriv; - Bool ret; - - pPriv = DRI2GetDrawable(pDraw); - if (pPriv == NULL) - return BadDrawable; - - /* Old DDX just completes immediately */ - if (!ds->ScheduleWaitMSC) { - DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0); - - return Success; - } - - ret = (*ds->ScheduleWaitMSC)(client, pDraw, target_msc, divisor, remainder); - if (!ret) - return BadDrawable; - - return Success; -} - -int -DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc, - CARD64 *ust, CARD64 *msc, CARD64 *sbc) -{ - DRI2DrawablePtr pPriv; - - pPriv = DRI2GetDrawable(pDraw); - if (pPriv == NULL) - return BadDrawable; - - /* target_sbc == 0 means to block until all pending swaps are - * finished. Recalculate target_sbc to get that behaviour. - */ - if (target_sbc == 0) - target_sbc = pPriv->swap_count + pPriv->swapsPending; - - /* If current swap count already >= target_sbc, - * return immediately with (ust, msc, sbc) triplet of - * most recent completed swap. - */ - if (pPriv->swap_count >= target_sbc) { - *sbc = pPriv->swap_count; - *msc = pPriv->last_swap_msc; - *ust = pPriv->last_swap_ust; - return Success; - } - - pPriv->target_sbc = target_sbc; - __DRI2BlockClient(client, pPriv); - - return Success; -} - -Bool -DRI2HasSwapControl(ScreenPtr pScreen) -{ - DRI2ScreenPtr ds = DRI2GetScreen(pScreen); - - return (ds->ScheduleSwap && ds->GetMSC); -} - -Bool -DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd, - const char **driverName, const char **deviceName) -{ - DRI2ScreenPtr ds = DRI2GetScreen(pScreen); - - if (ds == NULL || driverType >= ds->numDrivers || - !ds->driverNames[driverType]) - return FALSE; - - *fd = ds->fd; - *driverName = ds->driverNames[driverType]; - *deviceName = ds->deviceName; - - return TRUE; -} - -Bool -DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic) -{ - DRI2ScreenPtr ds = DRI2GetScreen(pScreen); - - if (ds == NULL || drmAuthMagic(ds->fd, magic)) - return FALSE; - - return TRUE; -} - -static void -DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw, - WindowPtr pSib) -{ - DrawablePtr pDraw = (DrawablePtr)pWin; - ScreenPtr pScreen = pDraw->pScreen; - DRI2ScreenPtr ds = DRI2GetScreen(pScreen); - DRI2DrawablePtr dd = DRI2GetDrawable(pDraw); - - if (ds->ConfigNotify) { - pScreen->ConfigNotify = ds->ConfigNotify; - - (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib); - - ds->ConfigNotify = pScreen->ConfigNotify; - pScreen->ConfigNotify = DRI2ConfigNotify; - } - - if (!dd || (dd->width == w && dd->height == h)) - return; - - DRI2InvalidateDrawable(pDraw); -} - -Bool -DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info) -{ - DRI2ScreenPtr ds; - const char* driverTypeNames[] = { - "DRI", /* DRI2DriverDRI */ - "VDPAU", /* DRI2DriverVDPAU */ - }; - unsigned int i; - CARD8 cur_minor; - - if (info->version < 3) - return FALSE; - - if (!xf86VGAarbiterAllowDRI(pScreen)) { - xf86DrvMsg(pScreen->myNum, X_WARNING, - "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n"); - return FALSE; - } - - ds = calloc(1, sizeof *ds); - if (!ds) - return FALSE; - - ds->screen = pScreen; - ds->fd = info->fd; - ds->deviceName = info->deviceName; - dri2_major = 1; - - ds->CreateBuffer = info->CreateBuffer; - ds->DestroyBuffer = info->DestroyBuffer; - ds->CopyRegion = info->CopyRegion; - - if (info->version >= 4) { - ds->ScheduleSwap = info->ScheduleSwap; - ds->ScheduleWaitMSC = info->ScheduleWaitMSC; - ds->GetMSC = info->GetMSC; - cur_minor = 3; - } else { - cur_minor = 1; - } - - /* Initialize minor if needed and set to minimum provied by DDX */ - if (!dri2_minor || dri2_minor > cur_minor) - dri2_minor = cur_minor; - - if (info->version == 3 || info->numDrivers == 0) { - /* Driver too old: use the old-style driverName field */ - ds->numDrivers = 1; - ds->driverNames = malloc(sizeof(*ds->driverNames)); - if (!ds->driverNames) { - free(ds); - return FALSE; - } - ds->driverNames[0] = info->driverName; - } else { - ds->numDrivers = info->numDrivers; - ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames)); - if (!ds->driverNames) { - free(ds); - return FALSE; - } - memcpy(ds->driverNames, info->driverNames, - info->numDrivers * sizeof(*ds->driverNames)); - } - - dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds); - - ds->ConfigNotify = pScreen->ConfigNotify; - pScreen->ConfigNotify = DRI2ConfigNotify; - - xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n"); - for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) { - if (i < ds->numDrivers && ds->driverNames[i]) { - xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n", - driverTypeNames[i], ds->driverNames[i]); - } - } - - return TRUE; -} - -void -DRI2CloseScreen(ScreenPtr pScreen) -{ - DRI2ScreenPtr ds = DRI2GetScreen(pScreen); - - free(ds->driverNames); - free(ds); - dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL); -} - -extern ExtensionModule dri2ExtensionModule; - -static pointer -DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin) -{ - static Bool setupDone = FALSE; - - dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable"); - - if (!setupDone) - { - setupDone = TRUE; - LoadExtension(&dri2ExtensionModule, FALSE); - } - else - { - if (errmaj) - *errmaj = LDR_ONCEONLY; - } - - return (pointer) 1; -} - -static XF86ModuleVersionInfo DRI2VersRec = -{ - "dri2", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - 1, 2, 0, - ABI_CLASS_EXTENSION, - ABI_EXTENSION_VERSION, - MOD_CLASS_NONE, - { 0, 0, 0, 0 } -}; - -_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL }; - -void -DRI2Version(int *major, int *minor) -{ - if (major != NULL) - *major = DRI2VersRec.majorversion; - - if (minor != NULL) - *minor = DRI2VersRec.minorversion; -} +/*
+ * Copyright © 2007, 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ * Kristian Høgsberg (krh@redhat.com)
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <errno.h>
+#ifdef WITH_LIBDRM
+#include <xf86drm.h>
+#endif
+#include "xf86Module.h"
+#include "list.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "dixstruct.h"
+#include "dri2.h"
+#include "xf86VGAarbiter.h"
+
+#include "xf86.h"
+
+CARD8 dri2_major; /* version of DRI2 supported by DDX */
+CARD8 dri2_minor;
+
+static DevPrivateKeyRec dri2ScreenPrivateKeyRec;
+#define dri2ScreenPrivateKey (&dri2ScreenPrivateKeyRec)
+
+static DevPrivateKeyRec dri2WindowPrivateKeyRec;
+#define dri2WindowPrivateKey (&dri2WindowPrivateKeyRec)
+
+static DevPrivateKeyRec dri2PixmapPrivateKeyRec;
+#define dri2PixmapPrivateKey (&dri2PixmapPrivateKeyRec)
+
+static RESTYPE dri2DrawableRes;
+
+typedef struct _DRI2Screen *DRI2ScreenPtr;
+
+typedef struct _DRI2Drawable {
+ DRI2ScreenPtr dri2_screen;
+ DrawablePtr drawable;
+ struct list reference_list;
+ int width;
+ int height;
+ DRI2BufferPtr *buffers;
+ int bufferCount;
+ unsigned int swapsPending;
+ ClientPtr blockedClient;
+ Bool blockedOnMsc;
+ int swap_interval;
+ CARD64 swap_count;
+ int64_t target_sbc; /* -1 means no SBC wait outstanding */
+ CARD64 last_swap_target; /* most recently queued swap target */
+ CARD64 last_swap_msc; /* msc at completion of most recent swap */
+ CARD64 last_swap_ust; /* ust at completion of most recent swap */
+ int swap_limit; /* for N-buffering */
+} DRI2DrawableRec, *DRI2DrawablePtr;
+
+typedef struct _DRI2Screen {
+ ScreenPtr screen;
+ int refcnt;
+ unsigned int numDrivers;
+ const char **driverNames;
+ const char *deviceName;
+ int fd;
+ unsigned int lastSequence;
+
+ DRI2CreateBufferProcPtr CreateBuffer;
+ DRI2DestroyBufferProcPtr DestroyBuffer;
+ DRI2CopyRegionProcPtr CopyRegion;
+ DRI2ScheduleSwapProcPtr ScheduleSwap;
+ DRI2GetMSCProcPtr GetMSC;
+ DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
+ DRI2AuthMagicProcPtr AuthMagic;
+
+ HandleExposuresProcPtr HandleExposures;
+
+ ConfigNotifyProcPtr ConfigNotify;
+} DRI2ScreenRec;
+
+static DRI2ScreenPtr
+DRI2GetScreen(ScreenPtr pScreen)
+{
+ return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey);
+}
+
+static DRI2DrawablePtr
+DRI2GetDrawable(DrawablePtr pDraw)
+{
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+
+ switch (pDraw->type) {
+ case DRAWABLE_WINDOW:
+ pWin = (WindowPtr) pDraw;
+ return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
+ case DRAWABLE_PIXMAP:
+ pPixmap = (PixmapPtr) pDraw;
+ return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
+ default:
+ return NULL;
+ }
+}
+
+static DRI2DrawablePtr
+DRI2AllocateDrawable(DrawablePtr pDraw)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ CARD64 ust;
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+
+ pPriv = malloc(sizeof *pPriv);
+ if (pPriv == NULL)
+ return NULL;
+
+ pPriv->dri2_screen = ds;
+ pPriv->drawable = pDraw;
+ pPriv->width = pDraw->width;
+ pPriv->height = pDraw->height;
+ pPriv->buffers = NULL;
+ pPriv->bufferCount = 0;
+ pPriv->swapsPending = 0;
+ pPriv->blockedClient = NULL;
+ pPriv->blockedOnMsc = FALSE;
+ pPriv->swap_count = 0;
+ pPriv->target_sbc = -1;
+ pPriv->swap_interval = 1;
+ /* Initialize last swap target from DDX if possible */
+ if (!ds->GetMSC || !(*ds->GetMSC)(pDraw, &ust, &pPriv->last_swap_target))
+ pPriv->last_swap_target = 0;
+
+ pPriv->swap_limit = 1; /* default to double buffering */
+ pPriv->last_swap_msc = 0;
+ pPriv->last_swap_ust = 0;
+ list_init(&pPriv->reference_list);
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr) pDraw;
+ dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
+ } else {
+ pPixmap = (PixmapPtr) pDraw;
+ dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
+ }
+
+ return pPriv;
+}
+
+typedef struct DRI2DrawableRefRec {
+ XID id;
+ XID dri2_id;
+ DRI2InvalidateProcPtr invalidate;
+ void *priv;
+ struct list link;
+} DRI2DrawableRefRec, *DRI2DrawableRefPtr;
+
+static DRI2DrawableRefPtr
+DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id)
+{
+ DRI2DrawableRefPtr ref;
+
+ list_for_each_entry(ref, &pPriv->reference_list, link) {
+ if (ref->id == id)
+ return ref;
+ }
+
+ return NULL;
+}
+
+static int
+DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
+ DRI2InvalidateProcPtr invalidate, void *priv)
+{
+ DRI2DrawableRefPtr ref;
+
+ ref = malloc(sizeof *ref);
+ if (ref == NULL)
+ return BadAlloc;
+
+ if (!AddResource(dri2_id, dri2DrawableRes, pPriv))
+ return BadAlloc;
+ if (!DRI2LookupDrawableRef(pPriv, id))
+ if (!AddResource(id, dri2DrawableRes, pPriv))
+ return BadAlloc;
+
+ ref->id = id;
+ ref->dri2_id = dri2_id;
+ ref->invalidate = invalidate;
+ ref->priv = priv;
+ list_add(&ref->link, &pPriv->reference_list);
+
+ return Success;
+}
+
+int
+DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id,
+ DRI2InvalidateProcPtr invalidate, void *priv)
+{
+ DRI2DrawablePtr pPriv;
+ XID dri2_id;
+ int rc;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ pPriv = DRI2AllocateDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadAlloc;
+
+ dri2_id = FakeClientID(client->index);
+ rc = DRI2AddDrawableRef(pPriv, id, dri2_id, invalidate, priv);
+ if (rc != Success)
+ return rc;
+
+ return Success;
+}
+
+static int DRI2DrawableGone(pointer p, XID id)
+{
+ DRI2DrawablePtr pPriv = p;
+ DRI2ScreenPtr ds = pPriv->dri2_screen;
+ DRI2DrawableRefPtr ref, next;
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+ DrawablePtr pDraw;
+ int i;
+
+ list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) {
+ if (ref->dri2_id == id) {
+ list_del(&ref->link);
+ /* If this was the last ref under this X drawable XID,
+ * unregister the X drawable resource. */
+ if (!DRI2LookupDrawableRef(pPriv, ref->id))
+ FreeResourceByType(ref->id, dri2DrawableRes, TRUE);
+ free(ref);
+ break;
+ }
+
+ if (ref->id == id) {
+ list_del(&ref->link);
+ FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE);
+ free(ref);
+ }
+ }
+
+ if (!list_is_empty(&pPriv->reference_list))
+ return Success;
+
+ pDraw = pPriv->drawable;
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr) pDraw;
+ dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
+ } else {
+ pPixmap = (PixmapPtr) pDraw;
+ dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
+ }
+
+ if (pPriv->buffers != NULL) {
+ for (i = 0; i < pPriv->bufferCount; i++)
+ (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
+
+ free(pPriv->buffers);
+ }
+
+ free(pPriv);
+
+ return Success;
+}
+
+static int
+find_attachment(DRI2DrawablePtr pPriv, unsigned attachment)
+{
+ int i;
+
+ if (pPriv->buffers == NULL) {
+ return -1;
+ }
+
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if ((pPriv->buffers[i] != NULL)
+ && (pPriv->buffers[i]->attachment == attachment)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+static Bool
+allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
+ DRI2DrawablePtr pPriv,
+ unsigned int attachment, unsigned int format,
+ int dimensions_match, DRI2BufferPtr *buffer)
+{
+ int old_buf = find_attachment(pPriv, attachment);
+
+ if ((old_buf < 0)
+ || !dimensions_match
+ || (pPriv->buffers[old_buf]->format != format)) {
+ *buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
+ return TRUE;
+
+ } else {
+ *buffer = pPriv->buffers[old_buf];
+ pPriv->buffers[old_buf] = NULL;
+ return FALSE;
+ }
+}
+
+static void
+update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw,
+ DRI2BufferPtr *buffers, int *out_count, int *width, int *height)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ int i;
+
+ if (pPriv->buffers != NULL) {
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if (pPriv->buffers[i] != NULL) {
+ (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
+ }
+ }
+
+ free(pPriv->buffers);
+ }
+
+ pPriv->buffers = buffers;
+ pPriv->bufferCount = *out_count;
+ pPriv->width = pDraw->width;
+ pPriv->height = pDraw->height;
+ *width = pPriv->width;
+ *height = pPriv->height;
+}
+
+static DRI2BufferPtr *
+do_get_buffers(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count,
+ int has_format)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+ DRI2BufferPtr *buffers;
+ int need_real_front = 0;
+ int need_fake_front = 0;
+ int have_fake_front = 0;
+ int front_format = 0;
+ int dimensions_match;
+ int buffers_changed = 0;
+ int i;
+
+ if (!pPriv) {
+ *width = pDraw->width;
+ *height = pDraw->height;
+ *out_count = 0;
+ return NULL;
+ }
+
+ dimensions_match = (pDraw->width == pPriv->width)
+ && (pDraw->height == pPriv->height);
+
+ buffers = malloc((count + 1) * sizeof(buffers[0]));
+
+ for (i = 0; i < count; i++) {
+ const unsigned attachment = *(attachments++);
+ const unsigned format = (has_format) ? *(attachments++) : 0;
+
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
+ format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
+
+ if (buffers[i] == NULL)
+ goto err_out;
+
+ /* If the drawable is a window and the front-buffer is requested,
+ * silently add the fake front-buffer to the list of requested
+ * attachments. The counting logic in the loop accounts for the case
+ * where the client requests both the fake and real front-buffer.
+ */
+ if (attachment == DRI2BufferBackLeft) {
+ need_real_front++;
+ front_format = format;
+ }
+
+ if (attachment == DRI2BufferFrontLeft) {
+ need_real_front--;
+ front_format = format;
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ need_fake_front++;
+ }
+ }
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ if (attachment == DRI2BufferFakeFrontLeft) {
+ need_fake_front--;
+ have_fake_front = 1;
+ }
+ }
+ }
+
+ if (need_real_front > 0) {
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
+ front_format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
+
+ if (buffers[i] == NULL)
+ goto err_out;
+ i++;
+ }
+
+ if (need_fake_front > 0) {
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
+ front_format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
+
+ if (buffers[i] == NULL)
+ goto err_out;
+
+ i++;
+ have_fake_front = 1;
+ }
+
+ *out_count = i;
+
+ update_dri2_drawable_buffers(pPriv, pDraw, buffers, out_count, width, height);
+
+ /* If the client is getting a fake front-buffer, pre-fill it with the
+ * contents of the real front-buffer. This ensures correct operation of
+ * applications that call glXWaitX before calling glDrawBuffer.
+ */
+ if (have_fake_front && buffers_changed) {
+ BoxRec box;
+ RegionRec region;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pPriv->width;
+ box.y2 = pPriv->height;
+ RegionInit(®ion, &box, 0);
+
+ DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft,
+ DRI2BufferFrontLeft);
+ }
+
+ return pPriv->buffers;
+
+err_out:
+
+ *out_count = 0;
+
+ for (i = 0; i < count; i++) {
+ if (buffers[i] != NULL)
+ (*ds->DestroyBuffer)(pDraw, buffers[i]);
+ }
+
+ free(buffers);
+ buffers = NULL;
+
+ update_dri2_drawable_buffers(pPriv, pDraw, buffers, out_count, width, height);
+
+ return buffers;
+}
+
+DRI2BufferPtr *
+DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count)
+{
+ return do_get_buffers(pDraw, width, height, attachments, count,
+ out_count, FALSE);
+}
+
+DRI2BufferPtr *
+DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count)
+{
+ return do_get_buffers(pDraw, width, height, attachments, count,
+ out_count, TRUE);
+}
+
+static void
+DRI2InvalidateDrawable(DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+ DRI2DrawableRefPtr ref;
+
+ if (!pPriv)
+ return;
+
+ list_for_each_entry(ref, &pPriv->reference_list, link)
+ ref->invalidate(pDraw, ref->priv);
+}
+
+/*
+ * In the direct rendered case, we throttle the clients that have more
+ * than their share of outstanding swaps (and thus busy buffers) when a
+ * new GetBuffers request is received. In the AIGLX case, we allow the
+ * client to get the new buffers, but throttle when the next GLX request
+ * comes in (see __glXDRIcontextWait()).
+ */
+Bool
+DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return FALSE;
+
+ /* Throttle to swap limit */
+ if ((pPriv->swapsPending >= pPriv->swap_limit) &&
+ !pPriv->blockedClient) {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ IgnoreClient(client);
+ pPriv->blockedClient = client;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+__DRI2BlockClient(ClientPtr client, DRI2DrawablePtr pPriv)
+{
+ if (pPriv->blockedClient == NULL) {
+ IgnoreClient(client);
+ pPriv->blockedClient = client;
+ }
+}
+
+void
+DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return;
+
+ __DRI2BlockClient(client, pPriv);
+ pPriv->blockedOnMsc = TRUE;
+}
+
+int
+DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
+ unsigned int dest, unsigned int src)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ DRI2BufferPtr pDestBuffer, pSrcBuffer;
+ int i;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ pDestBuffer = NULL;
+ pSrcBuffer = NULL;
+ for (i = 0; i < pPriv->bufferCount; i++)
+ {
+ if (pPriv->buffers[i]->attachment == dest)
+ pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == src)
+ pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ }
+ if (pSrcBuffer == NULL || pDestBuffer == NULL)
+ return BadValue;
+
+ (*ds->CopyRegion)(pDraw, pRegion, pDestBuffer, pSrcBuffer);
+
+ return Success;
+}
+
+/* Can this drawable be page flipped? */
+Bool
+DRI2CanFlip(DrawablePtr pDraw)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ WindowPtr pWin, pRoot;
+ PixmapPtr pWinPixmap, pRootPixmap;
+
+ if (pDraw->type == DRAWABLE_PIXMAP)
+ return TRUE;
+
+ pRoot = pScreen->root;
+ pRootPixmap = pScreen->GetWindowPixmap(pRoot);
+
+ pWin = (WindowPtr) pDraw;
+ pWinPixmap = pScreen->GetWindowPixmap(pWin);
+ if (pRootPixmap != pWinPixmap)
+ return FALSE;
+ if (!RegionEqual(&pWin->clipList, &pRoot->winSize))
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Can we do a pixmap exchange instead of a blit? */
+Bool
+DRI2CanExchange(DrawablePtr pDraw)
+{
+ return FALSE;
+}
+
+void
+DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return;
+
+ ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
+ frame, pPriv->swap_count);
+
+ if (pPriv->blockedClient)
+ AttendClient(pPriv->blockedClient);
+
+ pPriv->blockedClient = NULL;
+ pPriv->blockedOnMsc = FALSE;
+}
+
+static void
+DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
+ }
+
+ /*
+ * Swap completed.
+ * Wake the client iff:
+ * - it was waiting on SBC
+ * - was blocked due to GLX make current
+ * - was blocked due to swap throttling
+ * - is not blocked due to an MSC wait
+ */
+ if (pPriv->target_sbc != -1 &&
+ pPriv->target_sbc <= pPriv->swap_count) {
+ ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
+ frame, pPriv->swap_count);
+ pPriv->target_sbc = -1;
+
+ AttendClient(pPriv->blockedClient);
+ pPriv->blockedClient = NULL;
+ } else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
+ if (pPriv->blockedClient) {
+ AttendClient(pPriv->blockedClient);
+ pPriv->blockedClient = NULL;
+ }
+ }
+}
+
+void
+DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec, int type,
+ DRI2SwapEventPtr swap_complete, void *swap_data)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2DrawablePtr pPriv;
+ CARD64 ust = 0;
+ BoxRec box;
+ RegionRec region;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
+ }
+
+ pPriv->swapsPending--;
+ pPriv->swap_count++;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pDraw->width;
+ box.y2 = pDraw->height;
+ RegionInit(®ion, &box, 0);
+ DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft,
+ DRI2BufferFrontLeft);
+
+ ust = ((CARD64)tv_sec * 1000000) + tv_usec;
+ if (swap_complete)
+ swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
+
+ pPriv->last_swap_msc = frame;
+ pPriv->last_swap_ust = ust;
+
+ DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
+}
+
+Bool
+DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
+{
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
+
+ /* If we're currently waiting for a swap on this drawable, reset
+ * the request and suspend the client. We only support one
+ * blocked client per drawable. */
+ if ((pPriv->swapsPending) &&
+ pPriv->blockedClient == NULL) {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ __DRI2BlockClient(client, pPriv);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+int
+DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
+ CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
+ DRI2SwapEventPtr func, void *data)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL;
+ int ret, i;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return BadDrawable;
+ }
+
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
+ pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
+ pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ }
+ if (pSrcBuffer == NULL || pDestBuffer == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: drawable has no back or front?\n", __func__);
+ return BadDrawable;
+ }
+
+ /* Old DDX or no swap interval, just blit */
+ if (!ds->ScheduleSwap || !pPriv->swap_interval) {
+ BoxRec box;
+ RegionRec region;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pDraw->width;
+ box.y2 = pDraw->height;
+ RegionInit(®ion, &box, 0);
+
+ pPriv->swapsPending++;
+
+ (*ds->CopyRegion)(pDraw, ®ion, pDestBuffer, pSrcBuffer);
+ DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
+ func, data);
+ return Success;
+ }
+
+ /*
+ * In the simple glXSwapBuffers case, all params will be 0, and we just
+ * need to schedule a swap for the last swap target + the swap interval.
+ */
+ if (target_msc == 0 && divisor == 0 && remainder == 0) {
+ /*
+ * Swap target for this swap is last swap target + swap interval since
+ * we have to account for the current swap count, interval, and the
+ * number of pending swaps.
+ */
+ *swap_target = pPriv->last_swap_target + pPriv->swap_interval;
+ } else {
+ /* glXSwapBuffersMscOML could have a 0 target_msc, honor it */
+ *swap_target = target_msc;
+ }
+
+ pPriv->swapsPending++;
+ ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
+ swap_target, divisor, remainder, func, data);
+ if (!ret) {
+ pPriv->swapsPending--; /* didn't schedule */
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: driver failed to schedule swap\n", __func__);
+ return BadDrawable;
+ }
+
+ pPriv->last_swap_target = *swap_target;
+
+ /* According to spec, return expected swapbuffers count SBC after this swap
+ * will complete.
+ */
+ *swap_target = pPriv->swap_count + pPriv->swapsPending;
+
+ DRI2InvalidateDrawable(pDraw);
+
+ return Success;
+}
+
+void
+DRI2SwapInterval(DrawablePtr pDrawable, int interval)
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
+
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
+ }
+
+ /* fixme: check against arbitrary max? */
+ pPriv->swap_interval = interval;
+}
+
+int
+DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ Bool ret;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return BadDrawable;
+ }
+
+ if (!ds->GetMSC) {
+ *ust = 0;
+ *msc = 0;
+ *sbc = pPriv->swap_count;
+ return Success;
+ }
+
+ /*
+ * Spec needs to be updated to include unmapped or redirected
+ * drawables
+ */
+
+ ret = (*ds->GetMSC)(pDraw, ust, msc);
+ if (!ret)
+ return BadDrawable;
+
+ *sbc = pPriv->swap_count;
+
+ return Success;
+}
+
+int
+DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
+ CARD64 divisor, CARD64 remainder)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ Bool ret;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ /* Old DDX just completes immediately */
+ if (!ds->ScheduleWaitMSC) {
+ DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0);
+
+ return Success;
+ }
+
+ ret = (*ds->ScheduleWaitMSC)(client, pDraw, target_msc, divisor, remainder);
+ if (!ret)
+ return BadDrawable;
+
+ return Success;
+}
+
+int
+DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ /* target_sbc == 0 means to block until all pending swaps are
+ * finished. Recalculate target_sbc to get that behaviour.
+ */
+ if (target_sbc == 0)
+ target_sbc = pPriv->swap_count + pPriv->swapsPending;
+
+ /* If current swap count already >= target_sbc, reply and
+ * return immediately with (ust, msc, sbc) triplet of
+ * most recent completed swap.
+ */
+ if (pPriv->swap_count >= target_sbc) {
+ ProcDRI2WaitMSCReply(client, pPriv->last_swap_ust,
+ pPriv->last_swap_msc, pPriv->swap_count);
+ return Success;
+ }
+
+ pPriv->target_sbc = target_sbc;
+ __DRI2BlockClient(client, pPriv);
+
+ return Success;
+}
+
+Bool
+DRI2HasSwapControl(ScreenPtr pScreen)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ return ds->ScheduleSwap && ds->GetMSC;
+}
+
+Bool
+DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
+ const char **driverName, const char **deviceName)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ if (ds == NULL || driverType >= ds->numDrivers ||
+ !ds->driverNames[driverType])
+ return FALSE;
+
+ *fd = ds->fd;
+ *driverName = ds->driverNames[driverType];
+ *deviceName = ds->deviceName;
+
+ return TRUE;
+}
+
+Bool
+DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ if (ds == NULL || (*ds->AuthMagic)(ds->fd, magic))
+ return FALSE;
+
+ return TRUE;
+}
+
+static int
+DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw,
+ WindowPtr pSib)
+{
+ DrawablePtr pDraw = (DrawablePtr)pWin;
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+ DRI2DrawablePtr dd = DRI2GetDrawable(pDraw);
+ int ret;
+
+ if (ds->ConfigNotify) {
+ pScreen->ConfigNotify = ds->ConfigNotify;
+
+ ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+
+ ds->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = DRI2ConfigNotify;
+ if (ret)
+ return ret;
+ }
+
+ if (!dd || (dd->width == w && dd->height == h))
+ return Success;
+
+ DRI2InvalidateDrawable(pDraw);
+ return Success;
+}
+
+Bool
+DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
+{
+ DRI2ScreenPtr ds;
+ const char* driverTypeNames[] = {
+ "DRI", /* DRI2DriverDRI */
+ "VDPAU", /* DRI2DriverVDPAU */
+ };
+ unsigned int i;
+ CARD8 cur_minor;
+
+ if (info->version < 3)
+ return FALSE;
+
+ if (!xf86VGAarbiterAllowDRI(pScreen)) {
+ xf86DrvMsg(pScreen->myNum, X_WARNING,
+ "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
+ return FALSE;
+ }
+
+ if (!dixRegisterPrivateKey(&dri2ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&dri2WindowPrivateKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&dri2PixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
+ return FALSE;
+
+ ds = calloc(1, sizeof *ds);
+ if (!ds)
+ return FALSE;
+
+ ds->screen = pScreen;
+ ds->fd = info->fd;
+ ds->deviceName = info->deviceName;
+ dri2_major = 1;
+
+ ds->CreateBuffer = info->CreateBuffer;
+ ds->DestroyBuffer = info->DestroyBuffer;
+ ds->CopyRegion = info->CopyRegion;
+
+ if (info->version >= 4) {
+ ds->ScheduleSwap = info->ScheduleSwap;
+ ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
+ ds->GetMSC = info->GetMSC;
+ cur_minor = 3;
+ } else {
+ cur_minor = 1;
+ }
+
+ if (info->version >= 5) {
+ ds->AuthMagic = info->AuthMagic;
+ }
+
+ /*
+ * if the driver doesn't provide an AuthMagic function or the info struct
+ * version is too low, it relies on the old method (using libdrm) or fail
+ */
+ if (!ds->AuthMagic)
+#ifdef WITH_LIBDRM
+ ds->AuthMagic = drmAuthMagic;
+#else
+ goto err_out;
+#endif
+
+ /* Initialize minor if needed and set to minimum provied by DDX */
+ if (!dri2_minor || dri2_minor > cur_minor)
+ dri2_minor = cur_minor;
+
+ if (info->version == 3 || info->numDrivers == 0) {
+ /* Driver too old: use the old-style driverName field */
+ ds->numDrivers = 1;
+ ds->driverNames = malloc(sizeof(*ds->driverNames));
+ if (!ds->driverNames)
+ goto err_out;
+ ds->driverNames[0] = info->driverName;
+ } else {
+ ds->numDrivers = info->numDrivers;
+ ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames));
+ if (!ds->driverNames)
+ goto err_out;
+ memcpy(ds->driverNames, info->driverNames,
+ info->numDrivers * sizeof(*ds->driverNames));
+ }
+
+ dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds);
+
+ ds->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = DRI2ConfigNotify;
+
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
+ for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
+ if (i < ds->numDrivers && ds->driverNames[i]) {
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
+ driverTypeNames[i], ds->driverNames[i]);
+ }
+ }
+
+ return TRUE;
+
+err_out:
+ xf86DrvMsg(pScreen->myNum, X_WARNING,
+ "[DRI2] Initialization failed for info version %d.\n", info->version);
+ free(ds);
+ return FALSE;
+}
+
+void
+DRI2CloseScreen(ScreenPtr pScreen)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ free(ds->driverNames);
+ free(ds);
+ dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
+}
+
+extern ExtensionModule dri2ExtensionModule;
+
+static pointer
+DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
+
+ if (!setupDone)
+ {
+ setupDone = TRUE;
+ LoadExtension(&dri2ExtensionModule, FALSE);
+ }
+ else
+ {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ }
+
+ return (pointer) 1;
+}
+
+static XF86ModuleVersionInfo DRI2VersRec =
+{
+ "dri2",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 2, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_NONE,
+ { 0, 0, 0, 0 }
+};
+
+_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL };
+
+void
+DRI2Version(int *major, int *minor)
+{
+ if (major != NULL)
+ *major = DRI2VersRec.majorversion;
+
+ if (minor != NULL)
+ *minor = DRI2VersRec.minorversion;
+}
diff --git a/xorg-server/hw/xfree86/dri2/dri2.h b/xorg-server/hw/xfree86/dri2/dri2.h index c43aa6a04..afe2083de 100644 --- a/xorg-server/hw/xfree86/dri2/dri2.h +++ b/xorg-server/hw/xfree86/dri2/dri2.h @@ -66,6 +66,8 @@ typedef void (*DRI2CopyRegionProcPtr)(DrawablePtr pDraw, DRI2BufferPtr pSrcBuffer);
typedef void (*DRI2WaitProcPtr)(WindowPtr pWin,
unsigned int sequence);
+typedef int (*DRI2AuthMagicProcPtr)(int fd, uint32_t magic);
+
/**
* Schedule a buffer swap
*
@@ -159,7 +161,7 @@ typedef void (*DRI2InvalidateProcPtr)(DrawablePtr pDraw, /**
* Version of the DRI2InfoRec structure defined in this header
*/
-#define DRI2INFOREC_VERSION 4
+#define DRI2INFOREC_VERSION 5
typedef struct {
unsigned int version; /**< Version of this struct */
@@ -183,6 +185,10 @@ typedef struct { /* array of driver names, indexed by DRI2Driver* driver types */
/* a name of NULL means that driver is not supported */
const char * const *driverNames;
+
+ /* added in version 5 */
+
+ DRI2AuthMagicProcPtr AuthMagic;
} DRI2InfoRec, *DRI2InfoPtr;
extern _X_EXPORT int DRI2EventBase;
@@ -200,7 +206,7 @@ extern _X_EXPORT Bool DRI2Connect(ScreenPtr pScreen, const char **driverName,
const char **deviceName);
-extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic);
+extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, uint32_t magic);
extern _X_EXPORT int DRI2CreateDrawable(ClientPtr client,
DrawablePtr pDraw,
@@ -259,8 +265,7 @@ extern _X_EXPORT int DRI2WaitMSC(ClientPtr client, DrawablePtr pDrawable, extern _X_EXPORT int ProcDRI2WaitMSCReply(ClientPtr client, CARD64 ust,
CARD64 msc, CARD64 sbc);
extern _X_EXPORT int DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw,
- CARD64 target_sbc, CARD64 *ust, CARD64 *msc,
- CARD64 *sbc);
+ CARD64 target_sbc);
extern _X_EXPORT Bool DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw);
extern _X_EXPORT Bool DRI2CanFlip(DrawablePtr pDraw);
diff --git a/xorg-server/hw/xfree86/dri2/dri2ext.c b/xorg-server/hw/xfree86/dri2/dri2ext.c index adbc9647b..6853fab9e 100644 --- a/xorg-server/hw/xfree86/dri2/dri2ext.c +++ b/xorg-server/hw/xfree86/dri2/dri2ext.c @@ -42,7 +42,6 @@ #include "scrnintstr.h"
#include "pixmapstr.h"
#include "extnsionst.h"
-#include "xf86drm.h"
#include "xfixes.h"
#include "dri2.h"
#include "protocol-versions.h"
@@ -56,7 +55,9 @@ static Bool validDrawable(ClientPtr client, XID drawable, Mask access_mode,
DrawablePtr *pDrawable, int *status)
{
- *status = dixLookupDrawable(pDrawable, drawable, client, 0, access_mode);
+ *status = dixLookupDrawable(pDrawable, drawable, client,
+ M_DRAWABLE_WINDOW | M_DRAWABLE_PIXMAP,
+ access_mode);
if (*status != Success) {
client->errorValue = drawable;
return FALSE;
@@ -521,9 +522,8 @@ static int ProcDRI2WaitSBC(ClientPtr client)
{
REQUEST(xDRI2WaitSBCReq);
- xDRI2MSCReply rep;
DrawablePtr pDrawable;
- CARD64 target, ust, msc, sbc;
+ CARD64 target;
int status;
REQUEST_SIZE_MATCH(xDRI2WaitSBCReq);
@@ -533,18 +533,9 @@ ProcDRI2WaitSBC(ClientPtr client) return status;
target = vals_to_card64(stuff->target_sbc_lo, stuff->target_sbc_hi);
- status = DRI2WaitSBC(client, pDrawable, target, &ust, &msc, &sbc);
- if (status != Success)
- return status;
+ status = DRI2WaitSBC(client, pDrawable, target);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- load_msc_reply(&rep, ust, msc, sbc);
-
- WriteToClient(client, sizeof(xDRI2MSCReply), &rep);
-
- return Success;
+ return status;
}
static int
diff --git a/xorg-server/hw/xfree86/exa/examodule.c b/xorg-server/hw/xfree86/exa/examodule.c index 6238582c0..356fd16ca 100644 --- a/xorg-server/hw/xfree86/exa/examodule.c +++ b/xorg-server/hw/xfree86/exa/examodule.c @@ -42,8 +42,8 @@ typedef struct _ExaXorgScreenPrivRec { OptionInfoPtr options;
} ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr;
-static int exaXorgScreenPrivateKeyIndex;
-static DevPrivateKey exaXorgScreenPrivateKey = &exaXorgScreenPrivateKeyIndex;
+static DevPrivateKeyRec exaXorgScreenPrivateKeyRec;
+#define exaXorgScreenPrivateKey (&exaXorgScreenPrivateKeyRec)
typedef enum {
EXAOPT_MIGRATION_HEURISTIC,
@@ -114,6 +114,9 @@ exaDDXDriverInit(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
ExaXorgScreenPrivPtr pScreenPriv;
+ if (!dixRegisterPrivateKey(&exaXorgScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
pScreenPriv = calloc(1, sizeof(ExaXorgScreenPrivRec));
if (pScreenPriv == NULL)
return;
diff --git a/xorg-server/hw/xfree86/fbdevhw/Makefile.am b/xorg-server/hw/xfree86/fbdevhw/Makefile.am index 066352556..076b9741f 100644 --- a/xorg-server/hw/xfree86/fbdevhw/Makefile.am +++ b/xorg-server/hw/xfree86/fbdevhw/Makefile.am @@ -1,28 +1,27 @@ -linuxmoduledir = $(moduledir)/linux -linuxmodule_LTLIBRARIES = libfbdevhw.la - -libfbdevhw_la_LDFLAGS = -avoid-version - -if FBDEVHW -libfbdevhw_la_SOURCES = fbdevhw.c -else -libfbdevhw_la_SOURCES = fbdevhwstub.c -endif - -INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c - -AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) - -sdk_HEADERS = fbdevhw.h - -include $(top_srcdir)/cpprules.in - -drivermandir = $(DRIVER_MAN_DIR) -driverman_DATA = fbdevhw.$(DRIVER_MAN_SUFFIX) -CLEANFILES = $(driverman_DATA) fbdevhw.man - -fbdevhw.$(DRIVER_MAN_SUFFIX): fbdevhw.man - -$(AM_V_at)rm -f fbdevhw.$(DRIVER_MAN_SUFFIX) - $(AM_V_at)$(LN_S) fbdevhw.man fbdevhw.$(DRIVER_MAN_SUFFIX) - -EXTRA_DIST = fbpriv.h fbdevhw.man.pre README +module_LTLIBRARIES = libfbdevhw.la
+
+libfbdevhw_la_LDFLAGS = -avoid-version
+
+if FBDEVHW
+libfbdevhw_la_SOURCES = fbdevhw.c
+else
+libfbdevhw_la_SOURCES = fbdevhwstub.c
+endif
+
+INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c
+
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
+
+sdk_HEADERS = fbdevhw.h
+
+include $(top_srcdir)/cpprules.in
+
+drivermandir = $(DRIVER_MAN_DIR)
+driverman_DATA = fbdevhw.$(DRIVER_MAN_SUFFIX)
+CLEANFILES = $(driverman_DATA) fbdevhw.man
+
+fbdevhw.$(DRIVER_MAN_SUFFIX): fbdevhw.man
+ -$(AM_V_at)rm -f fbdevhw.$(DRIVER_MAN_SUFFIX)
+ $(AM_V_at)$(LN_S) fbdevhw.man fbdevhw.$(DRIVER_MAN_SUFFIX)
+
+EXTRA_DIST = fbpriv.h fbdevhw.man.pre README
diff --git a/xorg-server/hw/xfree86/int10/Makefile.am b/xorg-server/hw/xfree86/int10/Makefile.am index 36d2ad0bb..58e1d0f25 100644 --- a/xorg-server/hw/xfree86/int10/Makefile.am +++ b/xorg-server/hw/xfree86/int10/Makefile.am @@ -1,45 +1,46 @@ -module_LTLIBRARIES = libint10.la - -sdk_HEADERS = xf86int10.h - -EXTRA_CFLAGS = - -libint10_la_LDFLAGS = -avoid-version - -COMMON_SOURCES = \ - helper_exec.c \ - helper_mem.c \ - xf86int10.c \ - xf86int10module.c - -if I386_VIDEO -I386_VIDEO_CFLAGS = -D_PC -endif - -if INT10_VM86 -AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS) -INCLUDES = $(XORG_INCS) -libint10_la_SOURCES = \ - $(COMMON_SOURCES) \ - $(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c \ - $(srcdir)/../os-support/linux/int10/linux.c -endif - -if INT10_X86EMU -AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_X86EMU -DNO_SYS_HEADERS \ - $(XORG_CFLAGS) $(EXTRA_CFLAGS) $(DIX_CFLAGS) -INCLUDES = $(XORG_INCS) -I$(srcdir)/../x86emu -libint10_la_SOURCES = \ - $(COMMON_SOURCES) \ - xf86x86emu.c \ - generic.c \ - x86emu.c -endif - -if INT10_STUB -AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS) -INCLUDES = $(XORG_INCS) -libint10_la_SOURCES = stub.c xf86int10module.c -endif - -EXTRA_DIST = xf86x86emu.h INT10.HOWTO +module_LTLIBRARIES = libint10.la
+
+sdk_HEADERS = xf86int10.h
+
+EXTRA_CFLAGS =
+
+libint10_la_LDFLAGS = -avoid-version
+libint10_la_LIBADD = $(PCIACCESS_LIBS)
+
+COMMON_SOURCES = \
+ helper_exec.c \
+ helper_mem.c \
+ xf86int10.c \
+ xf86int10module.c
+
+if I386_VIDEO
+I386_VIDEO_CFLAGS = -D_PC
+endif
+
+if INT10_VM86
+AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS)
+INCLUDES = $(XORG_INCS)
+libint10_la_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c \
+ $(srcdir)/../os-support/linux/int10/linux.c
+endif
+
+if INT10_X86EMU
+AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_X86EMU -DNO_SYS_HEADERS \
+ $(XORG_CFLAGS) $(EXTRA_CFLAGS) $(DIX_CFLAGS)
+INCLUDES = $(XORG_INCS) -I$(srcdir)/../x86emu
+libint10_la_SOURCES = \
+ $(COMMON_SOURCES) \
+ xf86x86emu.c \
+ generic.c \
+ x86emu.c
+endif
+
+if INT10_STUB
+AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS)
+INCLUDES = $(XORG_INCS)
+libint10_la_SOURCES = stub.c xf86int10module.c
+endif
+
+EXTRA_DIST = xf86x86emu.h INT10.HOWTO
diff --git a/xorg-server/hw/xfree86/loader/loadext.c b/xorg-server/hw/xfree86/loader/loadext.c index 26066856d..8380c300b 100644 --- a/xorg-server/hw/xfree86/loader/loadext.c +++ b/xorg-server/hw/xfree86/loader/loadext.c @@ -163,7 +163,7 @@ get_node(const char *name) for (n = graph; n && n->n_name && strcmp(n->n_name, name);
n = n->n_next) ;
if (n)
- return (n);
+ return n;
n = xnfalloc(sizeof(NODE));
@@ -180,7 +180,7 @@ get_node(const char *name) n->n_prevp = &graph;
graph = n;
- return (n);
+ return n;
}
/*
@@ -285,7 +285,7 @@ find_cycle(NODE * from, NODE * to, int longest_len, int depth) * to be acyclic
*/
if (from->n_flags & (NF_NODEST | NF_MARK | NF_ACYCLIC))
- return (0);
+ return 0;
from->n_flags |= NF_MARK;
for (np = from->n_arcs, i = from->n_narcs; --i >= 0; np++) {
@@ -317,7 +317,7 @@ find_cycle(NODE * from, NODE * to, int longest_len, int depth) }
}
from->n_flags &= ~NF_MARK;
- return (longest_len);
+ return longest_len;
}
/* do topological sort on graph */
@@ -378,10 +378,8 @@ tsort(void) if (n == NULL)
ErrorF("tsort: internal error -- could not find cycle");
}
- if (cycle_buf)
- free(cycle_buf);
- if (longest_cycle)
- free(longest_cycle);
+ free(cycle_buf);
+ free(longest_cycle);
if (graph)
free_nodes(graph);
}
diff --git a/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c index e75ec8f69..171f0521e 100644 --- a/xorg-server/hw/xfree86/loader/loadmod.c +++ b/xorg-server/hw/xfree86/loader/loadmod.c @@ -114,7 +114,7 @@ static char **defaultPathList = NULL; static Bool
PathIsAbsolute(const char *path)
{
- return (*path == '/');
+ return *path == '/';
}
/*
@@ -315,16 +315,14 @@ InitSubdirs(const char **subdirlist) if (**s == '/' || **s == '\\' || strchr(*s, ':') ||
strstr(*s, "..")) {
xf86Msg(X_ERROR, "InitSubdirs: Bad subdir: \"%s\"\n", *s);
- if (tmp_subdirlist)
- free(tmp_subdirlist);
+ free(tmp_subdirlist);
return NULL;
}
}
}
subdirs = malloc((i * 2 + 1) * sizeof(char *));
if (!subdirs) {
- if (tmp_subdirlist)
- free(tmp_subdirlist);
+ free(tmp_subdirlist);
return NULL;
}
i = 0;
@@ -348,8 +346,7 @@ InitSubdirs(const char **subdirlist) while (--i >= 0)
free(subdirs[i]);
free(subdirs);
- if (tmp_subdirlist)
- free(tmp_subdirlist);
+ free(tmp_subdirlist);
return NULL;
}
/* tack on the OS name */
@@ -367,8 +364,7 @@ InitSubdirs(const char **subdirlist) }
subdirs[i] = NULL;
}
- if (tmp_subdirlist)
- free(tmp_subdirlist);
+ free(tmp_subdirlist);
return (const char **)subdirs;
}
@@ -743,7 +739,7 @@ static ModuleDescPtr AddSibling(ModuleDescPtr head, ModuleDescPtr new)
{
new->sib = head;
- return (new);
+ return new;
}
pointer
@@ -793,7 +789,7 @@ NewModuleDesc(const char *name) mdp->TearDownData = NULL;
}
- return (mdp);
+ return mdp;
}
ModuleDescPtr
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c index 5705d7da3..9c5b3c1ad 100644 --- a/xorg-server/hw/xfree86/modes/xf86Crtc.c +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c @@ -157,8 +157,7 @@ xf86CrtcDestroy (xf86CrtcPtr crtc) xf86_config->num_crtc--;
break;
}
- if (crtc->params)
- free(crtc->params);
+ free(crtc->params);
free(crtc->gamma_red);
free(crtc);
}
@@ -382,8 +381,7 @@ done: crtc->transformPresent = saved_transform_present;
}
- if (adjusted_mode->name)
- free(adjusted_mode->name);
+ free(adjusted_mode->name);
free(adjusted_mode);
if (didLock)
@@ -482,8 +480,7 @@ xf86OutputSetMonitor (xf86OutputPtr output) if (!output->name)
return;
- if (output->options)
- free(output->options);
+ free(output->options);
output->options = xnfalloc (sizeof (xf86OutputOptions));
memcpy (output->options, xf86OutputOptions, sizeof (xf86OutputOptions));
@@ -580,7 +577,7 @@ xf86OutputInitialRotation (xf86OutputPtr output) for (i = 0; i < 4; i++)
if (xf86nameCompare (direction[i], rotate_name) == 0)
- return (1 << i);
+ return 1 << i;
return RR_Rotate_0;
}
@@ -1041,8 +1038,8 @@ xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp, if (crtc->enabled)
{
- crtc_width = crtc->x + xf86ModeWidth (&crtc->desiredMode, crtc->desiredRotation);
- crtc_height = crtc->y + xf86ModeHeight (&crtc->desiredMode, crtc->desiredRotation);
+ crtc_width = crtc->desiredX + xf86ModeWidth (&crtc->desiredMode, crtc->desiredRotation);
+ crtc_height = crtc->desiredY + xf86ModeHeight (&crtc->desiredMode, crtc->desiredRotation);
}
if (!canGrow) {
for (o = 0; o < config->num_output; o++)
@@ -2204,7 +2201,7 @@ xf86TargetFallback(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, target_rotation, width, height);
}
- return (target_mode != NULL);
+ return target_mode != NULL;
}
static Bool
@@ -3155,9 +3152,9 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn, &crtc_box);
if (crtc) {
- REGION_INIT (pScreen, &crtc_region_local, &crtc_box, 1);
+ RegionInit(&crtc_region_local, &crtc_box, 1);
crtc_region = &crtc_region_local;
- REGION_INTERSECT (pScreen, crtc_region, crtc_region, reg);
+ RegionIntersect(crtc_region, crtc_region, reg);
}
*crtc_ret = crtc;
}
@@ -3166,7 +3163,7 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn, crtc_region, width, height);
if (crtc_region != reg)
- REGION_UNINIT (pScreen, &crtc_region_local);
+ RegionUninit(&crtc_region_local);
return ret;
}
@@ -3223,7 +3220,7 @@ xf86_crtc_supports_gamma(ScrnInfoPtr pScrn) return FALSE;
crtc = xf86_config->crtc[0];
- return (crtc->funcs->gamma_set != NULL);
+ return crtc->funcs->gamma_set != NULL;
}
return FALSE;
diff --git a/xorg-server/hw/xfree86/modes/xf86DiDGA.c b/xorg-server/hw/xfree86/modes/xf86DiDGA.c index 61c779edc..b2bbefa62 100644 --- a/xorg-server/hw/xfree86/modes/xf86DiDGA.c +++ b/xorg-server/hw/xfree86/modes/xf86DiDGA.c @@ -103,8 +103,7 @@ xf86_dga_get_modes (ScreenPtr pScreen) if (display_mode == scrn->modes)
break;
}
- if (xf86_config->dga_modes)
- free(xf86_config->dga_modes);
+ free(xf86_config->dga_modes);
xf86_config->dga_nmode = num;
xf86_config->dga_modes = modes;
return TRUE;
diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c index 8a4d72bd6..e49387317 100644 --- a/xorg-server/hw/xfree86/modes/xf86RandR12.c +++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c @@ -71,7 +71,7 @@ static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen); static int xf86RandR12Generation;
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
-static int xf86RandR12KeyIndex;
+static DevPrivateKeyRec xf86RandR12KeyRec;
static DevPrivateKey xf86RandR12Key;
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \
dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key))
@@ -517,7 +517,7 @@ xf86RandR12SetMode (ScreenPtr pScreen, int oldHeight = pScreen->height;
int oldmmWidth = pScreen->mmWidth;
int oldmmHeight = pScreen->mmHeight;
- WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
DisplayModePtr currentMode = NULL;
Bool ret = TRUE;
PixmapPtr pspix = NULL;
@@ -685,7 +685,7 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen, XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen);
Bool ret = FALSE;
int c;
@@ -739,7 +739,7 @@ finish: if (pRoot && pScrn->vtSema)
(*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
#if RANDR_12_INTERFACE
- if (xf86RandR12Key && WindowTable[pScreen->myNum] && ret)
+ if (xf86RandR12Key && pScreen->root && ret)
RRScreenSizeNotify (pScreen);
#endif
return ret;
@@ -883,7 +883,9 @@ xf86RandR12Init (ScreenPtr pScreen) xf86RandR12Generation = serverGeneration;
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
- xf86RandR12Key = &xf86RandR12KeyIndex;
+ xf86RandR12Key = &xf86RandR12KeyRec;
+ if (!dixRegisterPrivateKey(&xf86RandR12KeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
#else
xf86RandR12Index = AllocateScreenPrivateIndex();
#endif
diff --git a/xorg-server/hw/xfree86/modes/xf86Rotate.c b/xorg-server/hw/xfree86/modes/xf86Rotate.c index e15c61476..f846d60ea 100644 --- a/xorg-server/hw/xfree86/modes/xf86Rotate.c +++ b/xorg-server/hw/xfree86/modes/xf86Rotate.c @@ -76,13 +76,13 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) {
ScrnInfoPtr scrn = crtc->scrn;
ScreenPtr screen = scrn->pScreen;
- WindowPtr root = WindowTable[screen->myNum];
+ WindowPtr root = screen->root;
PixmapPtr dst_pixmap = crtc->rotatedPixmap;
- PictFormatPtr format = compWindowFormat (WindowTable[screen->myNum]);
+ PictFormatPtr format = compWindowFormat (screen->root);
int error;
PicturePtr src, dst;
- int n = REGION_NUM_RECTS(region);
- BoxPtr b = REGION_RECTS(region);
+ int n = RegionNumRects(region);
+ BoxPtr b = RegionRects(region);
XID include_inferiors = IncludeInferiors;
src = CreatePicture (None,
@@ -167,10 +167,10 @@ xf86CrtcDamageShadow (xf86CrtcPtr crtc) if (damage_box.y1 < 0) damage_box.y1 = 0;
if (damage_box.x2 > pScreen->width) damage_box.x2 = pScreen->width;
if (damage_box.y2 > pScreen->height) damage_box.y2 = pScreen->height;
- REGION_INIT (pScreen, &damage_region, &damage_box, 1);
+ RegionInit(&damage_region, &damage_box, 1);
DamageRegionAppend (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
&damage_region);
- REGION_UNINIT (pScreen, &damage_region);
+ RegionUninit(&damage_region);
crtc->shadowClear = TRUE;
}
@@ -217,7 +217,7 @@ xf86RotateRedisplay(ScreenPtr pScreen) return FALSE;
xf86RotatePrepare (pScreen);
region = DamageRegion(damage);
- if (REGION_NOTEMPTY(pScreen, region))
+ if (RegionNotEmpty(region))
{
int c;
SourceValidateProcPtr SourceValidate;
@@ -240,14 +240,14 @@ xf86RotateRedisplay(ScreenPtr pScreen) RegionRec crtc_damage;
/* compute portion of damage that overlaps crtc */
- REGION_INIT(pScreen, &crtc_damage, &crtc->bounds, 1);
- REGION_INTERSECT (pScreen, &crtc_damage, &crtc_damage, region);
+ RegionInit(&crtc_damage, &crtc->bounds, 1);
+ RegionIntersect(&crtc_damage, &crtc_damage, region);
/* update damaged region */
- if (REGION_NOTEMPTY(pScreen, &crtc_damage))
+ if (RegionNotEmpty(&crtc_damage))
xf86RotateCrtcRedisplay (crtc, &crtc_damage);
- REGION_UNINIT (pScreen, &crtc_damage);
+ RegionUninit(&crtc_damage);
}
}
pScreen->SourceValidate = SourceValidate;
@@ -405,8 +405,7 @@ xf86CrtcRotate (xf86CrtcPtr crtc) */
xf86RotateDestroy (crtc);
crtc->transform_in_use = FALSE;
- if (new_params)
- free(new_params);
+ free(new_params);
new_params = NULL;
new_nparams = 0;
new_filter = NULL;
@@ -506,8 +505,7 @@ xf86CrtcRotate (xf86CrtcPtr crtc) crtc->crtc_to_framebuffer = crtc_to_fb;
crtc->f_crtc_to_framebuffer = f_crtc_to_fb;
crtc->f_framebuffer_to_crtc = f_fb_to_crtc;
- if (crtc->params)
- free(crtc->params);
+ free(crtc->params);
crtc->params = new_params;
crtc->nparams = new_nparams;
crtc->filter = new_filter;
diff --git a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c index 18e1e0b67..7b5d2c7a4 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c +++ b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c @@ -1,719 +1,719 @@ -/* - * Copyright 1992 by Rich Murphey <Rich@Rice.edu> - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Rich Murphey and David Wexelblat - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. Rich Murphey and - * David Wexelblat make no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" - -#include <sys/param.h> -#ifndef __NetBSD__ -# include <sys/sysctl.h> -# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -# include <machine/sysarch.h> -# endif -# else -# include <machine/sysarch.h> -#endif - -#include "xf86Axp.h" - -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#if defined(__NetBSD__) && !defined(MAP_FILE) -#define MAP_FLAGS MAP_SHARED -#else -#define MAP_FLAGS (MAP_FILE | MAP_SHARED) -#endif - -#ifndef MAP_FAILED -#define MAP_FAILED ((caddr_t)-1) -#endif - -axpDevice bsdGetAXP(void); - -#ifndef __NetBSD__ -extern unsigned long dense_base(void); - -static int axpSystem = -1; -static unsigned long hae_thresh; -static unsigned long hae_mask; -static unsigned long bus_base; -static unsigned long sparse_size; - -static unsigned long -memory_base(void) -{ - static unsigned long base = 0; - - if (base == 0) { - size_t len = sizeof(base); - int error; -#ifdef __OpenBSD__ - int mib[3]; - - mib[0] = CTL_MACHDEP; - mib[1] = CPU_CHIPSET; - mib[2] = CPU_CHIPSET_MEM; - - if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0) -#else - if ((error = sysctlbyname("hw.chipset.memory", &base, &len, - 0, 0)) < 0) -#endif - FatalError("xf86MapVidMem: can't find memory\n"); - } - - return base; -} - -static int -has_bwx(void) -{ - static int bwx = 0; - size_t len = sizeof(bwx); - int error; -#ifdef __OpenBSD__ - int mib[3]; - - mib[0] = CTL_MACHDEP; - mib[1] = CPU_CHIPSET; - mib[2] = CPU_CHIPSET_BWX; - - if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0) - return FALSE; - else - return bwx; -#else - if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0) - return FALSE; - else - return bwx; -#endif -} -#else /* __NetBSD__ */ -static unsigned long hae_thresh = (1UL << 24); -static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */ -static struct alpha_bus_window *abw; -static int abw_count = -1; - -static void -init_abw(void) -{ - if (abw_count < 0) { - abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw); - if (abw_count <= 0) - FatalError("init_abw: alpha_bus_getwindows failed\n"); - } -} - -static int -has_bwx(void) -{ - if (abw_count < 0) - init_abw(); - - xf86Msg(X_INFO, "has_bwx = %d\n", - abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */ - return abw[0].abw_abst.abst_flags & ABST_BWX; -} - -static unsigned long -dense_base(void) -{ - if (abw_count < 0) - init_abw(); - - /* XXX check abst_flags for ABST_DENSE just to be safe? */ - xf86Msg(X_INFO, "dense base = %#lx\n", - abw[0].abw_abst.abst_sys_start); /* XXXX */ - return abw[0].abw_abst.abst_sys_start; -} - -static unsigned long -memory_base(void) -{ - if (abw_count < 0) - init_abw(); - - if (abw_count > 1) { - xf86Msg(X_INFO, "memory base = %#lx\n", - abw[1].abw_abst.abst_sys_start); /* XXXX */ - return abw[1].abw_abst.abst_sys_start; - } else if (abw_count == 1) { - /* assume memory_base == dense_base */ - xf86Msg(X_INFO, "memory base = %#lx\n", - abw[0].abw_abst.abst_sys_start); /* XXXX */ - return abw[0].abw_abst.abst_sys_start; - } else { - xf86Msg(X_INFO, "no memory base\n"); /* XXXX */ - return 0; - } -} -#endif /* __NetBSD__ */ - -#define BUS_BASE dense_base() -#define BUS_BASE_BWX memory_base() - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -#ifdef __OpenBSD__ -#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\ - "\tin /etc/sysctl.conf and reboot your machine\n" \ - "\trefer to xf86(4) for details" -#endif - -static Bool useDevMem = FALSE; -static int devMemFd = -1; - -#ifdef HAS_APERTURE_DRV -#define DEV_APERTURE "/dev/xf86" -#endif -#define DEV_MEM "/dev/mem" - -static pointer mapVidMem(int, unsigned long, unsigned long, int); -static void unmapVidMem(int, pointer, unsigned long); -static pointer mapVidMemSparse(int, unsigned long, unsigned long, int); -static void unmapVidMemSparse(int, pointer, unsigned long); - -/* - * Check if /dev/mem can be mmap'd. If it can't print a warning when - * "warn" is TRUE. - */ -static void -checkDevMem(Bool warn) -{ - static Bool devMemChecked = FALSE; - int fd; - pointer base; - - if (devMemChecked) - return; - devMemChecked = TRUE; - -#ifdef HAS_APERTURE_DRV - /* Try the aperture driver first */ - if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) { - /* Try to map a page at the VGA address */ - base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); - - if (base != MAP_FAILED) { - munmap((caddr_t)base, 4096); - devMemFd = fd; - useDevMem = TRUE; - xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n", - DEV_APERTURE); - return; - } else { - if (warn) { - xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", - DEV_APERTURE, strerror(errno)); - } - } - } -#endif - if ((fd = open(DEV_MEM, O_RDWR)) >= 0) { - /* Try to map a page at the VGA address */ - base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); - - if (base != MAP_FAILED) { - munmap((caddr_t)base, 4096); - devMemFd = fd; - useDevMem = TRUE; - return; - } else { - if (warn) { - xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", - DEV_MEM, strerror(errno)); - } - } - } - if (warn) { -#ifndef HAS_APERTURE_DRV - xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n", - DEV_MEM, strerror(errno)); -#else -#ifndef __OpenBSD__ - xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" - "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno)); -#else /* __OpenBSD__ */ - xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" - "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno), - SYSCTL_MSG); -#endif /* __OpenBSD__ */ -#endif - xf86ErrorF("\tlinear framebuffer access unavailable\n"); - } - useDevMem = FALSE; - return; -} - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - checkDevMem(TRUE); - pVidMem->linearSupported = useDevMem; - - if (has_bwx()) { - xf86Msg(X_PROBED,"Machine type has 8/16 bit access\n"); - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; - } else { - xf86Msg(X_PROBED,"Machine needs sparse mapping\n"); - pVidMem->mapMem = mapVidMemSparse; - pVidMem->unmapMem = unmapVidMemSparse; -#ifndef __NetBSD__ - if (axpSystem == -1) - axpSystem = bsdGetAXP(); - hae_thresh = xf86AXPParams[axpSystem].hae_thresh; - hae_mask = xf86AXPParams[axpSystem].hae_mask; - sparse_size = xf86AXPParams[axpSystem].size; -#endif /* __NetBSD__ */ - } - pVidMem->initialised = TRUE; -} - -static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - pointer base; - - checkDevMem(FALSE); - Base = Base & ((1L<<32) - 1); - - if (useDevMem) - { - if (devMemFd < 0) - { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t)0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX); - if (base == MAP_FAILED) - { - FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n", - "xf86MapVidMem", DEV_MEM, Size, Base, - strerror(errno)); - } - return(base); - } - - /* else, mmap /dev/vga */ - if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) - { - FatalError("%s: Address 0x%lx outside allowable range\n", - "xf86MapVidMem", Base); - } - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.screenFd, - (unsigned long)Base + BUS_BASE); - if (base == MAP_FAILED) - { - FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", - strerror(errno)); - } - return(base); -} - -static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - munmap((caddr_t)Base, Size); -} - -/* - * Read BIOS via mmap()ing DEV_MEM - */ - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - unsigned char *ptr; - int psize; - int mlen; - - checkDevMem(TRUE); - if (devMemFd == -1) { - return(-1); - } - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, - MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); - if ((long)ptr == -1) - { - xf86Msg(X_WARNING, - "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", - DEV_MEM, Len, Base, Offset, strerror(errno)); - return(-1); - } -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", - Base, ptr[0] | (ptr[1] << 8)); -#endif - (void)memcpy(Buf, (void *)(ptr + Offset), Len); - (void)munmap((caddr_t)ptr, mlen); -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" - "-> %02x %02x %02x %02x...\n", - Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); -#endif - return(Len); -} - - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) - -extern int ioperm(unsigned long from, unsigned long num, int on); - -Bool -xf86EnableIO() -{ - if (!ioperm(0, 65536, TRUE)) - return TRUE; - return FALSE; -} - -void -xf86DisableIO() -{ - return; -} - -#endif /* __FreeBSD_kernel__ || __OpenBSD__ */ - -#ifdef USE_ALPHA_PIO - -Bool -xf86EnableIO() -{ - alpha_pci_io_enable(1); - return TRUE; -} - -void -xf86DisableIO() -{ - alpha_pci_io_enable(0); -} - -#endif /* USE_ALPHA_PIO */ - -#define vuip volatile unsigned int * - -static unsigned long msb_set = 0; -static pointer memSBase = 0; -static pointer memBase = 0; - -extern int readDense8(pointer Base, register unsigned long Offset); -extern int readDense16(pointer Base, register unsigned long Offset); -extern int readDense32(pointer Base, register unsigned long Offset); -extern void -writeDenseNB8(int Value, pointer Base, register unsigned long Offset); -extern void -writeDenseNB16(int Value, pointer Base, register unsigned long Offset); -extern void -writeDenseNB32(int Value, pointer Base, register unsigned long Offset); -extern void -writeDense8(int Value, pointer Base, register unsigned long Offset); -extern void -writeDense16(int Value, pointer Base, register unsigned long Offset); -extern void -writeDense32(int Value, pointer Base, register unsigned long Offset); - -static int readSparse8(pointer Base, register unsigned long Offset); -static int readSparse16(pointer Base, register unsigned long Offset); -static int readSparse32(pointer Base, register unsigned long Offset); -static void -writeSparseNB8(int Value, pointer Base, register unsigned long Offset); -static void -writeSparseNB16(int Value, pointer Base, register unsigned long Offset); -static void -writeSparseNB32(int Value, pointer Base, register unsigned long Offset); -static void -writeSparse8(int Value, pointer Base, register unsigned long Offset); -static void -writeSparse16(int Value, pointer Base, register unsigned long Offset); -static void -writeSparse32(int Value, pointer Base, register unsigned long Offset); - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -extern int sysarch(int, void *); -#endif - -struct parms { - u_int64_t hae; -}; - -#ifndef __NetBSD__ -static int -sethae(u_int64_t hae) -{ -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#ifndef ALPHA_SETHAE -#define ALPHA_SETHAE 0 -#endif - struct parms p; - p.hae = hae; - return (sysarch(ALPHA_SETHAE, (char *)&p)); -#endif -#ifdef __OpenBSD__ - return -1; -#endif -} -#endif /* __NetBSD__ */ - -static pointer -mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - static Bool was_here = FALSE; - - if (!was_here) { - was_here = TRUE; - - checkDevMem(FALSE); - - xf86WriteMmio8 = writeSparse8; - xf86WriteMmio16 = writeSparse16; - xf86WriteMmio32 = writeSparse32; - xf86WriteMmioNB8 = writeSparseNB8; - xf86WriteMmioNB16 = writeSparseNB16; - xf86WriteMmioNB32 = writeSparseNB32; - xf86ReadMmio8 = readSparse8; - xf86ReadMmio16 = readSparse16; - xf86ReadMmio32 = readSparse32; - - memBase = mmap((caddr_t)0, 0x100000000, - PROT_READ | PROT_WRITE, - MAP_SHARED, devMemFd, - (off_t) BUS_BASE); - memSBase = mmap((caddr_t)0, 0x100000000, - PROT_READ | PROT_WRITE, - MAP_SHARED, devMemFd, - (off_t) BUS_BASE_BWX); - - if (memSBase == MAP_FAILED || memBase == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n", - strerror(errno)); - } - } - return (pointer)((unsigned long)memBase + Base); -} - -static void -unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size) -{ -} - -static int -readSparse8(pointer Base, register unsigned long Offset) -{ - register unsigned long result, shift; - register unsigned long msb; - mem_barrier(); - Offset += (unsigned long)Base - (unsigned long)memBase; - shift = (Offset & 0x3) << 3; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - result = *(vuip) ((unsigned long)memSBase + (Offset << 5)); - result >>= shift; - return 0xffUL & result; -} - -static int -readSparse16(pointer Base, register unsigned long Offset) -{ - register unsigned long result, shift; - register unsigned long msb; - - mem_barrier(); - Offset += (unsigned long)Base - (unsigned long)memBase; - shift = (Offset & 0x2) << 3; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - result = *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))); - result >>= shift; - return 0xffffUL & result; -} - -static int -readSparse32(pointer Base, register unsigned long Offset) -{ - mem_barrier(); - return *(vuip)((unsigned long)Base+(Offset)); -} - -static void -writeSparse8(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int b = Value & 0xffU; - - write_mem_barrier(); - Offset += (unsigned long)Base - (unsigned long)memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101; -} - -static void -writeSparse16(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int w = Value & 0xffffU; - - write_mem_barrier(); - Offset += (unsigned long)Base - (unsigned long)memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) = - w * 0x00010001; - -} - -static void -writeSparse32(int Value, pointer Base, register unsigned long Offset) -{ - write_mem_barrier(); - *(vuip)((unsigned long)Base + (Offset)) = Value; - return; -} - -static void -writeSparseNB8(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int b = Value & 0xffU; - - Offset += (unsigned long)Base - (unsigned long)memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101; -} - -static void -writeSparseNB16(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int w = Value & 0xffffU; - - Offset += (unsigned long)Base - (unsigned long)memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask ; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) = - w * 0x00010001; -} - -static void -writeSparseNB32(int Value, pointer Base, register unsigned long Offset) -{ - *(vuip)((unsigned long)Base + (Offset)) = Value; - return; -} - -void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset) - = writeDense8; -void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset) - = writeDense16; -void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset) - = writeDense32; -void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset) - = writeDenseNB8; -void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset) - = writeDenseNB16; -void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset) - = writeDenseNB32; -int (*xf86ReadMmio8)(pointer Base, unsigned long Offset) - = readDense8; -int (*xf86ReadMmio16)(pointer Base, unsigned long Offset) - = readDense16; -int (*xf86ReadMmio32)(pointer Base, unsigned long Offset) - = readDense32; - +/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#include <sys/param.h>
+#ifndef __NetBSD__
+# include <sys/sysctl.h>
+# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+# include <machine/sysarch.h>
+# endif
+# else
+# include <machine/sysarch.h>
+#endif
+
+#include "xf86Axp.h"
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#if defined(__NetBSD__) && !defined(MAP_FILE)
+#define MAP_FLAGS MAP_SHARED
+#else
+#define MAP_FLAGS (MAP_FILE | MAP_SHARED)
+#endif
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+axpDevice bsdGetAXP(void);
+
+#ifndef __NetBSD__
+extern unsigned long dense_base(void);
+
+static int axpSystem = -1;
+static unsigned long hae_thresh;
+static unsigned long hae_mask;
+static unsigned long bus_base;
+static unsigned long sparse_size;
+
+static unsigned long
+memory_base(void)
+{
+ static unsigned long base = 0;
+
+ if (base == 0) {
+ size_t len = sizeof(base);
+ int error;
+#ifdef __OpenBSD__
+ int mib[3];
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_MEM;
+
+ if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0)
+#else
+ if ((error = sysctlbyname("hw.chipset.memory", &base, &len,
+ 0, 0)) < 0)
+#endif
+ FatalError("xf86MapVidMem: can't find memory\n");
+ }
+
+ return base;
+}
+
+static int
+has_bwx(void)
+{
+ static int bwx = 0;
+ size_t len = sizeof(bwx);
+ int error;
+#ifdef __OpenBSD__
+ int mib[3];
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_BWX;
+
+ if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0)
+ return FALSE;
+ else
+ return bwx;
+#else
+ if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0)
+ return FALSE;
+ else
+ return bwx;
+#endif
+}
+#else /* __NetBSD__ */
+static unsigned long hae_thresh = (1UL << 24);
+static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */
+static struct alpha_bus_window *abw;
+static int abw_count = -1;
+
+static void
+init_abw(void)
+{
+ if (abw_count < 0) {
+ abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw);
+ if (abw_count <= 0)
+ FatalError("init_abw: alpha_bus_getwindows failed\n");
+ }
+}
+
+static int
+has_bwx(void)
+{
+ if (abw_count < 0)
+ init_abw();
+
+ xf86Msg(X_INFO, "has_bwx = %d\n",
+ abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */
+ return abw[0].abw_abst.abst_flags & ABST_BWX;
+}
+
+static unsigned long
+dense_base(void)
+{
+ if (abw_count < 0)
+ init_abw();
+
+ /* XXX check abst_flags for ABST_DENSE just to be safe? */
+ xf86Msg(X_INFO, "dense base = %#lx\n",
+ abw[0].abw_abst.abst_sys_start); /* XXXX */
+ return abw[0].abw_abst.abst_sys_start;
+}
+
+static unsigned long
+memory_base(void)
+{
+ if (abw_count < 0)
+ init_abw();
+
+ if (abw_count > 1) {
+ xf86Msg(X_INFO, "memory base = %#lx\n",
+ abw[1].abw_abst.abst_sys_start); /* XXXX */
+ return abw[1].abw_abst.abst_sys_start;
+ } else if (abw_count == 1) {
+ /* assume memory_base == dense_base */
+ xf86Msg(X_INFO, "memory base = %#lx\n",
+ abw[0].abw_abst.abst_sys_start); /* XXXX */
+ return abw[0].abw_abst.abst_sys_start;
+ } else {
+ xf86Msg(X_INFO, "no memory base\n"); /* XXXX */
+ return 0;
+ }
+}
+#endif /* __NetBSD__ */
+
+#define BUS_BASE dense_base()
+#define BUS_BASE_BWX memory_base()
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+#ifdef __OpenBSD__
+#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\
+ "\tin /etc/sysctl.conf and reboot your machine\n" \
+ "\trefer to xf86(4) for details"
+#endif
+
+static Bool useDevMem = FALSE;
+static int devMemFd = -1;
+
+#ifdef HAS_APERTURE_DRV
+#define DEV_APERTURE "/dev/xf86"
+#endif
+#define DEV_MEM "/dev/mem"
+
+static pointer mapVidMem(int, unsigned long, unsigned long, int);
+static void unmapVidMem(int, pointer, unsigned long);
+static pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
+static void unmapVidMemSparse(int, pointer, unsigned long);
+
+/*
+ * Check if /dev/mem can be mmap'd. If it can't print a warning when
+ * "warn" is TRUE.
+ */
+static void
+checkDevMem(Bool warn)
+{
+ static Bool devMemChecked = FALSE;
+ int fd;
+ pointer base;
+
+ if (devMemChecked)
+ return;
+ devMemChecked = TRUE;
+
+#ifdef HAS_APERTURE_DRV
+ /* Try the aperture driver first */
+ if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED) {
+ munmap((caddr_t)base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
+ DEV_APERTURE);
+ return;
+ } else {
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_APERTURE, strerror(errno));
+ }
+ }
+ }
+#endif
+ if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED) {
+ munmap((caddr_t)base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ return;
+ } else {
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ }
+ }
+ if (warn) {
+#ifndef HAS_APERTURE_DRV
+ xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+#else
+#ifndef __OpenBSD__
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno));
+#else /* __OpenBSD__ */
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno),
+ SYSCTL_MSG);
+#endif /* __OpenBSD__ */
+#endif
+ xf86ErrorF("\tlinear framebuffer access unavailable\n");
+ }
+ useDevMem = FALSE;
+ return;
+}
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ checkDevMem(TRUE);
+ pVidMem->linearSupported = useDevMem;
+
+ if (has_bwx()) {
+ xf86Msg(X_PROBED,"Machine type has 8/16 bit access\n");
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+ } else {
+ xf86Msg(X_PROBED,"Machine needs sparse mapping\n");
+ pVidMem->mapMem = mapVidMemSparse;
+ pVidMem->unmapMem = unmapVidMemSparse;
+#ifndef __NetBSD__
+ if (axpSystem == -1)
+ axpSystem = bsdGetAXP();
+ hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
+ hae_mask = xf86AXPParams[axpSystem].hae_mask;
+ sparse_size = xf86AXPParams[axpSystem].size;
+#endif /* __NetBSD__ */
+ }
+ pVidMem->initialised = TRUE;
+}
+
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+
+ checkDevMem(FALSE);
+ Base = Base & ((1L<<32) - 1);
+
+ if (useDevMem)
+ {
+ if (devMemFd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
+ if (base == MAP_FAILED)
+ {
+ FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n",
+ "xf86MapVidMem", DEV_MEM, Size, Base,
+ strerror(errno));
+ }
+ return base;
+ }
+
+ /* else, mmap /dev/vga */
+ if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
+ {
+ FatalError("%s: Address 0x%lx outside allowable range\n",
+ "xf86MapVidMem", Base);
+ }
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, xf86Info.screenFd,
+ (unsigned long)Base + BUS_BASE);
+ if (base == MAP_FAILED)
+ {
+ FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
+ strerror(errno));
+ }
+ return base;
+}
+
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap((caddr_t)Base, Size);
+}
+
+/*
+ * Read BIOS via mmap()ing DEV_MEM
+ */
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ checkDevMem(TRUE);
+ if (devMemFd == -1) {
+ return -1;
+ }
+
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE);
+ if ((long)ptr == -1)
+ {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
+ DEV_MEM, Len, Base, Offset, strerror(errno));
+ return -1;
+ }
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
+#endif
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
+ "-> %02x %02x %02x %02x...\n",
+ Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
+#endif
+ return Len;
+}
+
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+
+extern int ioperm(unsigned long from, unsigned long num, int on);
+
+Bool
+xf86EnableIO()
+{
+ if (!ioperm(0, 65536, TRUE))
+ return TRUE;
+ return FALSE;
+}
+
+void
+xf86DisableIO()
+{
+ return;
+}
+
+#endif /* __FreeBSD_kernel__ || __OpenBSD__ */
+
+#ifdef USE_ALPHA_PIO
+
+Bool
+xf86EnableIO()
+{
+ alpha_pci_io_enable(1);
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ alpha_pci_io_enable(0);
+}
+
+#endif /* USE_ALPHA_PIO */
+
+#define vuip volatile unsigned int *
+
+static unsigned long msb_set = 0;
+static pointer memSBase = 0;
+static pointer memBase = 0;
+
+extern int readDense8(pointer Base, register unsigned long Offset);
+extern int readDense16(pointer Base, register unsigned long Offset);
+extern int readDense32(pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense8(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense16(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense32(int Value, pointer Base, register unsigned long Offset);
+
+static int readSparse8(pointer Base, register unsigned long Offset);
+static int readSparse16(pointer Base, register unsigned long Offset);
+static int readSparse32(pointer Base, register unsigned long Offset);
+static void
+writeSparseNB8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseNB16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseNB32(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse32(int Value, pointer Base, register unsigned long Offset);
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+extern int sysarch(int, void *);
+#endif
+
+struct parms {
+ u_int64_t hae;
+};
+
+#ifndef __NetBSD__
+static int
+sethae(u_int64_t hae)
+{
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#ifndef ALPHA_SETHAE
+#define ALPHA_SETHAE 0
+#endif
+ struct parms p;
+ p.hae = hae;
+ return (sysarch(ALPHA_SETHAE, (char *)&p));
+#endif
+#ifdef __OpenBSD__
+ return -1;
+#endif
+}
+#endif /* __NetBSD__ */
+
+static pointer
+mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ static Bool was_here = FALSE;
+
+ if (!was_here) {
+ was_here = TRUE;
+
+ checkDevMem(FALSE);
+
+ xf86WriteMmio8 = writeSparse8;
+ xf86WriteMmio16 = writeSparse16;
+ xf86WriteMmio32 = writeSparse32;
+ xf86WriteMmioNB8 = writeSparseNB8;
+ xf86WriteMmioNB16 = writeSparseNB16;
+ xf86WriteMmioNB32 = writeSparseNB32;
+ xf86ReadMmio8 = readSparse8;
+ xf86ReadMmio16 = readSparse16;
+ xf86ReadMmio32 = readSparse32;
+
+ memBase = mmap((caddr_t)0, 0x100000000,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, devMemFd,
+ (off_t) BUS_BASE);
+ memSBase = mmap((caddr_t)0, 0x100000000,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, devMemFd,
+ (off_t) BUS_BASE_BWX);
+
+ if (memSBase == MAP_FAILED || memBase == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
+ strerror(errno));
+ }
+ }
+ return (pointer)((unsigned long)memBase + Base);
+}
+
+static void
+unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size)
+{
+}
+
+static int
+readSparse8(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+ register unsigned long msb;
+ mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ shift = (Offset & 0x3) << 3;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ result = *(vuip) ((unsigned long)memSBase + (Offset << 5));
+ result >>= shift;
+ return 0xffUL & result;
+}
+
+static int
+readSparse16(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+ register unsigned long msb;
+
+ mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ shift = (Offset & 0x2) << 3;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ result = *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2)));
+ result >>= shift;
+ return 0xffffUL & result;
+}
+
+static int
+readSparse32(pointer Base, register unsigned long Offset)
+{
+ mem_barrier();
+ return *(vuip)((unsigned long)Base+(Offset));
+}
+
+static void
+writeSparse8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int b = Value & 0xffU;
+
+ write_mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
+}
+
+static void
+writeSparse16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int w = Value & 0xffffU;
+
+ write_mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
+ w * 0x00010001;
+
+}
+
+static void
+writeSparse32(int Value, pointer Base, register unsigned long Offset)
+{
+ write_mem_barrier();
+ *(vuip)((unsigned long)Base + (Offset)) = Value;
+ return;
+}
+
+static void
+writeSparseNB8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int b = Value & 0xffU;
+
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
+}
+
+static void
+writeSparseNB16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int w = Value & 0xffffU;
+
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask ;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
+ w * 0x00010001;
+}
+
+static void
+writeSparseNB32(int Value, pointer Base, register unsigned long Offset)
+{
+ *(vuip)((unsigned long)Base + (Offset)) = Value;
+ return;
+}
+
+void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset)
+ = writeDense8;
+void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset)
+ = writeDense16;
+void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset)
+ = writeDense32;
+void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB8;
+void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB16;
+void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB32;
+int (*xf86ReadMmio8)(pointer Base, unsigned long Offset)
+ = readDense8;
+int (*xf86ReadMmio16)(pointer Base, unsigned long Offset)
+ = readDense16;
+int (*xf86ReadMmio32)(pointer Base, unsigned long Offset)
+ = readDense32;
+
diff --git a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c index 466a8a0db..10cfee764 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c +++ b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c @@ -1,666 +1,666 @@ -/* - * Copyright 1992 by Rich Murphey <Rich@Rice.edu> - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Rich Murphey and David Wexelblat - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. Rich Murphey and - * David Wexelblat make no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -/* - * The ARM32 code here carries the following copyright: - * - * Copyright 1997 - * Digital Equipment Corporation. All rights reserved. - * This software is furnished under license and may be used and copied only in - * accordance with the following terms and conditions. Subject to these - * conditions, you may download, copy, install, use, modify and distribute - * this software in source and/or binary form. No title or ownership is - * transferred hereby. - * - * 1) Any source code used, modified or distributed must reproduce and retain - * this copyright notice and list of conditions as they appear in the - * source file. - * - * 2) No right is granted to use any trade name, trademark, or logo of Digital - * Equipment Corporation. Neither the "Digital Equipment Corporation" - * name nor any trademark or logo of Digital Equipment Corporation may be - * used to endorse or promote products derived from this software without - * the prior written permission of Digital Equipment Corporation. - * - * 3) This software is provided "AS-IS" and any express or implied warranties, - * including but not limited to, any implied warranties of merchantability, - * fitness for a particular purpose, or non-infringement are disclaimed. - * In no event shall DIGITAL be liable for any damages whatsoever, and in - * particular, DIGITAL shall not be liable for special, indirect, - * consequential, or incidental damages or damages for lost profits, loss - * of revenue or loss of use, whether such damages arise in contract, - * negligence, tort, under statute, in equity, at law or otherwise, even - * if advised of the possibility of such damage. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#ifdef __arm32__ -#include "machine/devmap.h" -struct memAccess -{ - int ioctl; - struct map_info memInfo; - pointer regionVirtBase; - Bool Checked; - Bool OK; -}; - -static pointer xf86MapInfoMap(); -static void xf86MapInfoUnmap(); -static struct memAccess *checkMapInfo(); -extern int vgaPhysLinearBase; - -/* A memAccess structure is needed for each possible region */ -struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL, - FALSE, FALSE }; -struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL, - FALSE, FALSE }; -struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL, - FALSE, FALSE }; -#endif /* __arm32__ */ - -#if defined(__NetBSD__) && !defined(MAP_FILE) -#define MAP_FLAGS MAP_SHARED -#else -#define MAP_FLAGS (MAP_FILE | MAP_SHARED) -#endif - -#ifndef MAP_FAILED -#define MAP_FAILED ((caddr_t)-1) -#endif - - -#define BUS_BASE 0L -#define BUS_BASE_BWX 0L - - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -static Bool useDevMem = FALSE; -static int devMemFd = -1; - -#define DEV_MEM "/dev/mem" - -static pointer mapVidMem(int, unsigned long, unsigned long, int); -static void unmapVidMem(int, pointer, unsigned long); - -/* - * Check if /dev/mem can be mmap'd. If it can't print a warning when - * "warn" is TRUE. - */ -static void -checkDevMem(Bool warn) -{ - static Bool devMemChecked = FALSE; - int fd; - pointer base; - - if (devMemChecked) - return; - devMemChecked = TRUE; - - if ((fd = open(DEV_MEM, O_RDWR)) >= 0) - { - /* Try to map a page at the VGA address */ - base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); - - if (base != MAP_FAILED) - { - munmap((caddr_t)base, 4096); - devMemFd = fd; - useDevMem = TRUE; - return; - } else { - /* This should not happen */ - if (warn) - { - xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", - DEV_MEM, strerror(errno)); - } - useDevMem = FALSE; - return; - } - } - if (warn) - { - xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - useDevMem = FALSE; - return; -} - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - - checkDevMem(TRUE); - pVidMem->linearSupported = useDevMem; - pVidMem->mapMem = armMapVidMem; - pVidMem->unmapVidMem = armUnmapVidMem; - - pVidMem->initialised = TRUE; -} - -static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - pointer base; - - checkDevMem(FALSE); - - if (useDevMem) - { - if (devMemFd < 0) - { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t)0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX); - if (base == MAP_FAILED) - { - FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n", - "xf86MapVidMem", DEV_MEM, Size, Base, - strerror(errno)); - } - return(base); - } - - /* else, mmap /dev/vga */ - if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) - { - FatalError("%s: Address 0x%x outside allowable range\n", - "xf86MapVidMem", Base); - } - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.screenFd, - (unsigned long)Base - 0xA0000); - if (base == MAP_FAILED) - { - FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", - strerror(errno)); - } - return(base); -} - -static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - munmap((caddr_t)Base, Size); -} - -/* - * Read BIOS via mmap()ing DEV_MEM - */ - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - unsigned char *ptr; - int psize; - int mlen; - - checkDevMem(TRUE); - if (devMemFd == -1) { - return(-1); - } - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, - MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); - if ((long)ptr == -1) - { - xf86Msg(X_WARNING, - "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n", - DEV_MEM, Len, Base, Offset, strerror(errno)); - return(-1); - } -#ifdef DEBUG - ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", - Base, ptr[0] | (ptr[1] << 8)); -#endif - (void)memcpy(Buf, (void *)(ptr + Offset), Len); - (void)munmap((caddr_t)ptr, mlen); -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" - "-> %02x %02x %02x %02x...\n", - Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); -#endif - return(Len); -} - - -/* XXX This needs to be updated for the ND */ - -/* -** Find out whether the console driver provides memory mapping information -** for the specified region and return the map_info pointer. Print a warning if required. -*/ -static struct memAccess * -checkMapInfo(Bool warn, int Region) -{ - struct memAccess *memAccP; - - switch (Region) - { - case VGA_REGION: - memAccP = &vgaMemInfo; - break; - - case LINEAR_REGION: - memAccP = &linearMemInfo; - break; - - case MMIO_REGION: - memAccP = &ioMemInfo; - break; - - default: - return NULL; - break; - } - - if(!memAccP->Checked) - { - if(ioctl(xf86Info.screenFd, memAccP->ioctl, &(memAccP->memInfo)) == -1) - { - if(warn) - { - xf86Msg(X_WARNING, - "checkMapInfo: failed to get map info for region %d\n\t(%s)\n", - Region, strerror(errno)); - } - } - else - { - if(memAccP->memInfo.u.map_info_mmap.map_offset - != MAP_INFO_UNKNOWN) - memAccP->OK = TRUE; - } - memAccP->Checked = TRUE; - } - if (memAccP->OK) - { - return memAccP; - } - else - { - return NULL; - } -} - -static pointer -xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size) -{ - struct map_info *mapInfoP = &(memInfoP->memInfo); - - if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) - { - Size = (unsigned long)Base + Size; - } - else - { - Size = mapInfoP->u.map_info_mmap.map_size; - } - - switch(mapInfoP->method) - { - case MAP_MMAP: - /* Need to remap if size is unknown because we may not have - mapped the whole region initially */ - if(memInfoP->regionVirtBase == NULL || - mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) - { - if((memInfoP->regionVirtBase = - mmap((caddr_t)0, - Size, - PROT_READ | PROT_WRITE, - MAP_SHARED, - xf86Info.screenFd, - (unsigned long)mapInfoP->u.map_info_mmap.map_offset)) - == (pointer)-1) - { - FatalError("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n", - mapInfoP->u.map_info_mmap.map_offset, strerror(errno)); - } - if(mapInfoP->u.map_info_mmap.internal_offset > 0) - memInfoP->regionVirtBase += - mapInfoP->u.map_info_mmap.internal_offset; - } - break; - - default: - FatalError("xf86MapInfoMap: Unsuported mapping method\n"); - break; - } - - return (pointer)((int)memInfoP->regionVirtBase + (int)Base); -} - -static void -xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size) -{ - struct map_info *mapInfoP = &(memInfoP->memInfo); - - switch(mapInfoP->method) - { - case MAP_MMAP: - if(memInfoP->regionVirtBase != NULL) - { - if(mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN) - Size = mapInfoP->u.map_info_mmap.map_size; - munmap((caddr_t)memInfoP->regionVirtBase, Size); - memInfoP->regionVirtBase = NULL; - } - break; - default: - FatalError("xf86MapInfoMap: Unsuported mapping method\n"); - break; - } -} - -static pointer -armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - struct memAccess *memInfoP; - - if((memInfoP = checkMapInfo(FALSE, Region)) != NULL) - { - /* - ** xf86 passes in a physical address offset from the start - ** of physical memory, but xf86MapInfoMap expects an - ** offset from the start of the specified region - it gets - ** the physical address of the region from the display driver. - */ - switch(Region) - { - case LINEAR_REGION: - if (vgaPhysLinearBase) - { - Base -= vgaPhysLinearBase; - } - break; - case VGA_REGION: - Base -= 0xA0000; - break; - } - - base = xf86MapInfoMap(memInfoP, Base, Size); - return (base); - } - return mapVidMem(ScreenNum, Base, Size, flags); -} - -static void -armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - struct memAccess *memInfoP; - - if((memInfoP = checkMapInfo(FALSE, Region)) != NULL) - { - xf86MapInfoUnmap(memInfoP, Base, Size); - } - unmapVidMem(ScreenNum, Base, Size); -} - -#ifdef USE_DEV_IO -static int IoFd = -1; - -Bool -xf86EnableIO() -{ - if (IoFd >= 0) - return TRUE; - - if ((IoFd = open("/dev/io", O_RDWR)) == -1) - { - xf86Msg(X_WARNING,"xf86EnableIO: " - "Failed to open /dev/io for extended I/O\n"); - return FALSE; - } - return TRUE; -} - -void -xf86DisableIO() -{ - if (IoFd < 0) - return; - - close(IoFd); - IoFd = -1; - return; -} - -#endif - -#if defined(USE_ARC_MMAP) || defined(__arm32__) - -Bool -xf86EnableIO() -{ - int fd; - pointer base; - - if (ExtendedEnabled) - return TRUE; - - if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { - /* Try to map a page at the pccons I/O space */ - base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0x0000); - - if (base != (pointer)-1) { - IOPortBase = base; - } - else { - xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - return FALSE; - } - } - else { - xf86Msg("EnableIO: failed to open %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - return FALSE; - } - - ExtendedEnabled = TRUE; - - return TRUE; -} - -void -xf86DisableIO() -{ - return; -} - -#endif /* USE_ARC_MMAP */ - -#if 0 -/* - * XXX This is here for reference. It needs to be handled differently for the - * ND. - */ -#if defined(USE_ARC_MMAP) || defined(__arm32__) - -#ifdef USE_ARM32_MMAP -#define DEV_MEM_IOBASE 0x43000000 -#endif - -static Bool ScreenEnabled[MAXSCREENS]; -static Bool ExtendedEnabled = FALSE; -static Bool InitDone = FALSE; - -Bool -xf86EnableIOPorts(ScreenNum) -int ScreenNum; -{ - int i; - int fd; - pointer base; - -#ifdef __arm32__ - struct memAccess *memInfoP; - int *Size; -#endif - - ScreenEnabled[ScreenNum] = TRUE; - - if (ExtendedEnabled) - return TRUE; - -#ifdef USE_ARC_MMAP - if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { - /* Try to map a page at the pccons I/O space */ - base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0x0000); - - if (base != (pointer)-1) { - IOPortBase = base; - } - else { - xf86Msg(X_ERROR, - "EnableIOPorts: failed to mmap %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - } - } - else { - xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - } -#endif - -#ifdef __arm32__ - IOPortBase = (unsigned int)-1; - - if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL) - { - /* - * xf86MapInfoMap maps an offset from the start of video IO - * space (e.g. 0x3B0), but IOPortBase is expected to map to - * physical address 0x000, so subtract the start of video I/O - * space from the result. This is safe for now becase we - * actually mmap the start of the page, then the start of video - * I/O space is added as an internal offset. - */ - IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP, - (caddr_t)0x0, 0L) - - memInfoP->memInfo.u.map_info_mmap.internal_offset; - ExtendedEnabled = TRUE; - return TRUE; - } -#ifdef USE_ARM32_MMAP - checkDevMem(TRUE); - - if (devMemFd >= 0 && useDevMem) - { - base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE, - MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE); - - if (base != (pointer)-1) - IOPortBase = (unsigned int)base; - } - - if (IOPortBase == (unsigned int)-1) - { - xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\ -Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n"); - return FALSE; - } -#else - /* We don't have the IOBASE, so we can't map the address */ - xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\ -Try building the server with USE_ARM32_MMAP defined\n"); - return FALSE; -#endif -#endif - - ExtendedEnabled = TRUE; - - return TRUE; -} - -void -xf86DisableIOPorts(ScreenNum) -int ScreenNum; -{ - int i; -#ifdef __arm32__ - struct memAccess *memInfoP; -#endif - - ScreenEnabled[ScreenNum] = FALSE; - -#ifdef __arm32__ - if((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL) - { - xf86MapInfoUnmap(memInfoP, 0); - } -#endif - -#ifdef USE_ARM32_MMAP - if (!ExtendedEnabled) - return; - - for (i = 0; i < MAXSCREENS; i++) - if (ScreenEnabled[i]) - return; - - munmap((caddr_t)IOPortBase, 0x400); - IOPortBase = (unsigned int)-1; - ExtendedEnabled = FALSE; -#endif - - return; -} - -#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */ -#endif - - +/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * The ARM32 code here carries the following copyright:
+ *
+ * Copyright 1997
+ * Digital Equipment Corporation. All rights reserved.
+ * This software is furnished under license and may be used and copied only in
+ * accordance with the following terms and conditions. Subject to these
+ * conditions, you may download, copy, install, use, modify and distribute
+ * this software in source and/or binary form. No title or ownership is
+ * transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce and retain
+ * this copyright notice and list of conditions as they appear in the
+ * source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or logo of Digital
+ * Equipment Corporation. Neither the "Digital Equipment Corporation"
+ * name nor any trademark or logo of Digital Equipment Corporation may be
+ * used to endorse or promote products derived from this software without
+ * the prior written permission of Digital Equipment Corporation.
+ *
+ * 3) This software is provided "AS-IS" and any express or implied warranties,
+ * including but not limited to, any implied warranties of merchantability,
+ * fitness for a particular purpose, or non-infringement are disclaimed.
+ * In no event shall DIGITAL be liable for any damages whatsoever, and in
+ * particular, DIGITAL shall not be liable for special, indirect,
+ * consequential, or incidental damages or damages for lost profits, loss
+ * of revenue or loss of use, whether such damages arise in contract,
+ * negligence, tort, under statute, in equity, at law or otherwise, even
+ * if advised of the possibility of such damage.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifdef __arm32__
+#include "machine/devmap.h"
+struct memAccess
+{
+ int ioctl;
+ struct map_info memInfo;
+ pointer regionVirtBase;
+ Bool Checked;
+ Bool OK;
+};
+
+static pointer xf86MapInfoMap();
+static void xf86MapInfoUnmap();
+static struct memAccess *checkMapInfo();
+extern int vgaPhysLinearBase;
+
+/* A memAccess structure is needed for each possible region */
+struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL,
+ FALSE, FALSE };
+struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL,
+ FALSE, FALSE };
+struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
+ FALSE, FALSE };
+#endif /* __arm32__ */
+
+#if defined(__NetBSD__) && !defined(MAP_FILE)
+#define MAP_FLAGS MAP_SHARED
+#else
+#define MAP_FLAGS (MAP_FILE | MAP_SHARED)
+#endif
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+
+#define BUS_BASE 0L
+#define BUS_BASE_BWX 0L
+
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static Bool useDevMem = FALSE;
+static int devMemFd = -1;
+
+#define DEV_MEM "/dev/mem"
+
+static pointer mapVidMem(int, unsigned long, unsigned long, int);
+static void unmapVidMem(int, pointer, unsigned long);
+
+/*
+ * Check if /dev/mem can be mmap'd. If it can't print a warning when
+ * "warn" is TRUE.
+ */
+static void
+checkDevMem(Bool warn)
+{
+ static Bool devMemChecked = FALSE;
+ int fd;
+ pointer base;
+
+ if (devMemChecked)
+ return;
+ devMemChecked = TRUE;
+
+ if ((fd = open(DEV_MEM, O_RDWR)) >= 0)
+ {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED)
+ {
+ munmap((caddr_t)base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ return;
+ } else {
+ /* This should not happen */
+ if (warn)
+ {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
+ }
+ }
+ if (warn)
+ {
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
+}
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+
+ checkDevMem(TRUE);
+ pVidMem->linearSupported = useDevMem;
+ pVidMem->mapMem = armMapVidMem;
+ pVidMem->unmapVidMem = armUnmapVidMem;
+
+ pVidMem->initialised = TRUE;
+}
+
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+
+ checkDevMem(FALSE);
+
+ if (useDevMem)
+ {
+ if (devMemFd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
+ if (base == MAP_FAILED)
+ {
+ FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", DEV_MEM, Size, Base,
+ strerror(errno));
+ }
+ return base;
+ }
+
+ /* else, mmap /dev/vga */
+ if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
+ {
+ FatalError("%s: Address 0x%x outside allowable range\n",
+ "xf86MapVidMem", Base);
+ }
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, xf86Info.screenFd,
+ (unsigned long)Base - 0xA0000);
+ if (base == MAP_FAILED)
+ {
+ FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
+ strerror(errno));
+ }
+ return base;
+}
+
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap((caddr_t)Base, Size);
+}
+
+/*
+ * Read BIOS via mmap()ing DEV_MEM
+ */
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ checkDevMem(TRUE);
+ if (devMemFd == -1) {
+ return -1;
+ }
+
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE);
+ if ((long)ptr == -1)
+ {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n",
+ DEV_MEM, Len, Base, Offset, strerror(errno));
+ return -1;
+ }
+#ifdef DEBUG
+ ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
+#endif
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
+ "-> %02x %02x %02x %02x...\n",
+ Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
+#endif
+ return Len;
+}
+
+
+/* XXX This needs to be updated for the ND */
+
+/*
+** Find out whether the console driver provides memory mapping information
+** for the specified region and return the map_info pointer. Print a warning if required.
+*/
+static struct memAccess *
+checkMapInfo(Bool warn, int Region)
+{
+ struct memAccess *memAccP;
+
+ switch (Region)
+ {
+ case VGA_REGION:
+ memAccP = &vgaMemInfo;
+ break;
+
+ case LINEAR_REGION:
+ memAccP = &linearMemInfo;
+ break;
+
+ case MMIO_REGION:
+ memAccP = &ioMemInfo;
+ break;
+
+ default:
+ return NULL;
+ break;
+ }
+
+ if(!memAccP->Checked)
+ {
+ if(ioctl(xf86Info.screenFd, memAccP->ioctl, &(memAccP->memInfo)) == -1)
+ {
+ if(warn)
+ {
+ xf86Msg(X_WARNING,
+ "checkMapInfo: failed to get map info for region %d\n\t(%s)\n",
+ Region, strerror(errno));
+ }
+ }
+ else
+ {
+ if(memAccP->memInfo.u.map_info_mmap.map_offset
+ != MAP_INFO_UNKNOWN)
+ memAccP->OK = TRUE;
+ }
+ memAccP->Checked = TRUE;
+ }
+ if (memAccP->OK)
+ {
+ return memAccP;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+static pointer
+xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size)
+{
+ struct map_info *mapInfoP = &(memInfoP->memInfo);
+
+ if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
+ {
+ Size = (unsigned long)Base + Size;
+ }
+ else
+ {
+ Size = mapInfoP->u.map_info_mmap.map_size;
+ }
+
+ switch(mapInfoP->method)
+ {
+ case MAP_MMAP:
+ /* Need to remap if size is unknown because we may not have
+ mapped the whole region initially */
+ if(memInfoP->regionVirtBase == NULL ||
+ mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
+ {
+ if((memInfoP->regionVirtBase =
+ mmap((caddr_t)0,
+ Size,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ xf86Info.screenFd,
+ (unsigned long)mapInfoP->u.map_info_mmap.map_offset))
+ == (pointer)-1)
+ {
+ FatalError("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n",
+ mapInfoP->u.map_info_mmap.map_offset, strerror(errno));
+ }
+ if(mapInfoP->u.map_info_mmap.internal_offset > 0)
+ memInfoP->regionVirtBase +=
+ mapInfoP->u.map_info_mmap.internal_offset;
+ }
+ break;
+
+ default:
+ FatalError("xf86MapInfoMap: Unsuported mapping method\n");
+ break;
+ }
+
+ return (pointer)((int)memInfoP->regionVirtBase + (int)Base);
+}
+
+static void
+xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size)
+{
+ struct map_info *mapInfoP = &(memInfoP->memInfo);
+
+ switch(mapInfoP->method)
+ {
+ case MAP_MMAP:
+ if(memInfoP->regionVirtBase != NULL)
+ {
+ if(mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN)
+ Size = mapInfoP->u.map_info_mmap.map_size;
+ munmap((caddr_t)memInfoP->regionVirtBase, Size);
+ memInfoP->regionVirtBase = NULL;
+ }
+ break;
+ default:
+ FatalError("xf86MapInfoMap: Unsuported mapping method\n");
+ break;
+ }
+}
+
+static pointer
+armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ struct memAccess *memInfoP;
+
+ if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
+ {
+ /*
+ ** xf86 passes in a physical address offset from the start
+ ** of physical memory, but xf86MapInfoMap expects an
+ ** offset from the start of the specified region - it gets
+ ** the physical address of the region from the display driver.
+ */
+ switch(Region)
+ {
+ case LINEAR_REGION:
+ if (vgaPhysLinearBase)
+ {
+ Base -= vgaPhysLinearBase;
+ }
+ break;
+ case VGA_REGION:
+ Base -= 0xA0000;
+ break;
+ }
+
+ base = xf86MapInfoMap(memInfoP, Base, Size);
+ return base;
+ }
+ return mapVidMem(ScreenNum, Base, Size, flags);
+}
+
+static void
+armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ struct memAccess *memInfoP;
+
+ if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
+ {
+ xf86MapInfoUnmap(memInfoP, Base, Size);
+ }
+ unmapVidMem(ScreenNum, Base, Size);
+}
+
+#ifdef USE_DEV_IO
+static int IoFd = -1;
+
+Bool
+xf86EnableIO()
+{
+ if (IoFd >= 0)
+ return TRUE;
+
+ if ((IoFd = open("/dev/io", O_RDWR)) == -1)
+ {
+ xf86Msg(X_WARNING,"xf86EnableIO: "
+ "Failed to open /dev/io for extended I/O\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ if (IoFd < 0)
+ return;
+
+ close(IoFd);
+ IoFd = -1;
+ return;
+}
+
+#endif
+
+#if defined(USE_ARC_MMAP) || defined(__arm32__)
+
+Bool
+xf86EnableIO()
+{
+ int fd;
+ pointer base;
+
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
+ /* Try to map a page at the pccons I/O space */
+ base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0x0000);
+
+ if (base != (pointer)-1) {
+ IOPortBase = base;
+ }
+ else {
+ xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ return FALSE;
+ }
+ }
+ else {
+ xf86Msg("EnableIO: failed to open %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ return FALSE;
+ }
+
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ return;
+}
+
+#endif /* USE_ARC_MMAP */
+
+#if 0
+/*
+ * XXX This is here for reference. It needs to be handled differently for the
+ * ND.
+ */
+#if defined(USE_ARC_MMAP) || defined(__arm32__)
+
+#ifdef USE_ARM32_MMAP
+#define DEV_MEM_IOBASE 0x43000000
+#endif
+
+static Bool ScreenEnabled[MAXSCREENS];
+static Bool ExtendedEnabled = FALSE;
+static Bool InitDone = FALSE;
+
+Bool
+xf86EnableIOPorts(ScreenNum)
+int ScreenNum;
+{
+ int i;
+ int fd;
+ pointer base;
+
+#ifdef __arm32__
+ struct memAccess *memInfoP;
+ int *Size;
+#endif
+
+ ScreenEnabled[ScreenNum] = TRUE;
+
+ if (ExtendedEnabled)
+ return TRUE;
+
+#ifdef USE_ARC_MMAP
+ if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
+ /* Try to map a page at the pccons I/O space */
+ base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0x0000);
+
+ if (base != (pointer)-1) {
+ IOPortBase = base;
+ }
+ else {
+ xf86Msg(X_ERROR,
+ "EnableIOPorts: failed to mmap %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ }
+ }
+ else {
+ xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ }
+#endif
+
+#ifdef __arm32__
+ IOPortBase = (unsigned int)-1;
+
+ if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL)
+ {
+ /*
+ * xf86MapInfoMap maps an offset from the start of video IO
+ * space (e.g. 0x3B0), but IOPortBase is expected to map to
+ * physical address 0x000, so subtract the start of video I/O
+ * space from the result. This is safe for now becase we
+ * actually mmap the start of the page, then the start of video
+ * I/O space is added as an internal offset.
+ */
+ IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP,
+ (caddr_t)0x0, 0L)
+ - memInfoP->memInfo.u.map_info_mmap.internal_offset;
+ ExtendedEnabled = TRUE;
+ return TRUE;
+ }
+#ifdef USE_ARM32_MMAP
+ checkDevMem(TRUE);
+
+ if (devMemFd >= 0 && useDevMem)
+ {
+ base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE);
+
+ if (base != (pointer)-1)
+ IOPortBase = (unsigned int)base;
+ }
+
+ if (IOPortBase == (unsigned int)-1)
+ {
+ xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
+Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n");
+ return FALSE;
+ }
+#else
+ /* We don't have the IOBASE, so we can't map the address */
+ xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
+Try building the server with USE_ARM32_MMAP defined\n");
+ return FALSE;
+#endif
+#endif
+
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIOPorts(ScreenNum)
+int ScreenNum;
+{
+ int i;
+#ifdef __arm32__
+ struct memAccess *memInfoP;
+#endif
+
+ ScreenEnabled[ScreenNum] = FALSE;
+
+#ifdef __arm32__
+ if((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL)
+ {
+ xf86MapInfoUnmap(memInfoP, 0);
+ }
+#endif
+
+#ifdef USE_ARM32_MMAP
+ if (!ExtendedEnabled)
+ return;
+
+ for (i = 0; i < MAXSCREENS; i++)
+ if (ScreenEnabled[i])
+ return;
+
+ munmap((caddr_t)IOPortBase, 0x400);
+ IOPortBase = (unsigned int)-1;
+ ExtendedEnabled = FALSE;
+#endif
+
+ return;
+}
+
+#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */
+#endif
+
+
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c index 90c9c30b1..15220d743 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c @@ -57,7 +57,7 @@ xf86VTSwitchPending() {
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
- return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+ return xf86Info.vtRequestsPending ? TRUE : FALSE;
}
#endif
return FALSE;
@@ -70,9 +70,9 @@ xf86VTSwitchAway() if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
- return(FALSE);
+ return FALSE;
else
- return(TRUE);
+ return TRUE;
}
#endif
return FALSE;
@@ -85,19 +85,19 @@ xf86VTSwitchTo() if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
- return(FALSE);
+ return FALSE;
else
- return(TRUE);
+ return TRUE;
}
#endif
- return(TRUE);
+ return TRUE;
}
Bool
xf86VTActivate(int vtno)
{
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0) {
- return(FALSE);
+ return FALSE;
}
- return(TRUE);
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c index 7698084ee..62618afd8 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c @@ -1,760 +1,760 @@ -/* - * Copyright 1992 by Rich Murphey <Rich@Rice.edu> - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Rich Murphey and David Wexelblat - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. Rich Murphey and - * David Wexelblat make no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#include <sys/utsname.h> -#include <sys/ioctl.h> -#include <stdlib.h> -#include <errno.h> - -static Bool KeepTty = FALSE; -static int devConsoleFd = -1; -#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) -static int VTnum = -1; -static int initialVT = -1; -static Bool ShareVTs = FALSE; -#endif - -#ifdef PCCONS_SUPPORT -/* Stock 0.1 386bsd pccons console driver interface */ -#ifndef __OpenBSD__ -# define PCCONS_CONSOLE_DEV1 "/dev/ttyv0" -#else -# define PCCONS_CONSOLE_DEV1 "/dev/ttyC0" -#endif -#define PCCONS_CONSOLE_DEV2 "/dev/vga" -#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY -#endif - -#ifdef SYSCONS_SUPPORT -/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */ -#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0" -#define SYSCONS_CONSOLE_DEV2 "/dev/vga" -#define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY -#endif - -#ifdef PCVT_SUPPORT -/* Hellmuth Michaelis' pcvt driver */ -#ifndef __OpenBSD__ -# define PCVT_CONSOLE_DEV "/dev/ttyv0" -#else -# define PCVT_CONSOLE_DEV "/dev/ttyC0" -#endif -#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY -#endif - -#if defined(WSCONS_SUPPORT) && defined(__NetBSD__) -/* NetBSD's new console driver */ -#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0" -#endif - -#ifdef __GLIBC__ -#define setpgrp setpgid -#endif - -#define CHECK_DRIVER_MSG \ - "Check your kernel's console driver configuration and /dev entries" - -static char *supported_drivers[] = { -#ifdef PCCONS_SUPPORT - "pccons (with X support)", -#endif -#ifdef SYSCONS_SUPPORT - "syscons", -#endif -#ifdef PCVT_SUPPORT - "pcvt", -#endif -#ifdef WSCONS_SUPPORT - "wscons", -#endif -}; - - -/* - * Functions to probe for the existance of a supported console driver. - * Any function returns either a valid file descriptor (driver probed - * succesfully), -1 (driver not found), or uses FatalError() if the - * driver was found but proved to not support the required mode to run - * an X server. - */ - -typedef int (*xf86ConsOpen_t)(void); - -#ifdef PCCONS_SUPPORT -static int xf86OpenPccons(void); -#endif /* PCCONS_SUPPORT */ - -#ifdef SYSCONS_SUPPORT -static int xf86OpenSyscons(void); -#endif /* SYSCONS_SUPPORT */ - -#ifdef PCVT_SUPPORT -static int xf86OpenPcvt(void); -#endif /* PCVT_SUPPORT */ - -#ifdef WSCONS_SUPPORT -static int xf86OpenWScons(void); -#endif - -/* - * The sequence of the driver probes is important; start with the - * driver that is best distinguishable, and end with the most generic - * driver. (Otherwise, pcvt would also probe as syscons, and either - * pcvt or syscons might succesfully probe as pccons.) - */ -static xf86ConsOpen_t xf86ConsTab[] = { -#ifdef PCVT_SUPPORT - xf86OpenPcvt, -#endif -#ifdef SYSCONS_SUPPORT - xf86OpenSyscons, -#endif -#ifdef PCCONS_SUPPORT - xf86OpenPccons, -#endif -#ifdef WSCONS_SUPPORT - xf86OpenWScons, -#endif - (xf86ConsOpen_t)NULL -}; - - -void -xf86OpenConsole() -{ - int i, fd = -1; - xf86ConsOpen_t *driver; -#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) - int result; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - struct utsname uts; -#endif - vtmode_t vtmode; -#endif - - if (serverGeneration == 1) - { - /* check if we are run with euid==0 */ - if (geteuid() != 0) - { - FatalError("xf86OpenConsole: Server must be suid root"); - } - - if (!KeepTty) - { - /* - * detaching the controlling tty solves problems of kbd character - * loss. This is not interesting for CO driver, because it is - * exclusive. - */ - setpgrp(0, getpid()); - if ((i = open("/dev/tty",O_RDWR)) >= 0) - { - ioctl(i,TIOCNOTTY,(char *)0); - close(i); - } - } - - /* detect which driver we are running on */ - for (driver = xf86ConsTab; *driver; driver++) - { - if ((fd = (*driver)()) >= 0) - break; - } - - /* Check that a supported console driver was found */ - if (fd < 0) - { - char cons_drivers[80] = {0, }; - for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++) - { - if (i) - { - strcat(cons_drivers, ", "); - } - strcat(cons_drivers, supported_drivers[i]); - } - FatalError( - "%s: No console driver found\n\tSupported drivers: %s\n\t%s", - "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG); - } -#if 0 /* stdin is already closed in OsInit() */ - fclose(stdin); -#endif - xf86Info.consoleFd = fd; - xf86Info.screenFd = fd; - - switch (xf86Info.consType) - { -#ifdef PCCONS_SUPPORT - case PCCONS: - if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0) - { - FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s", - "xf86OpenConsole", strerror(errno), - CHECK_DRIVER_MSG); - } - /* - * Hack to prevent keyboard hanging when syslogd closes - * /dev/console - */ - if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0) - { - xf86Msg(X_WARNING, - "xf86OpenConsole: couldn't open /dev/console (%s)\n", - strerror(errno)); - } - break; -#endif -#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) - case SYSCONS: - /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt - * switching anymore. Here we check for FreeBSD 3.1 and up. - * Add cases for other *BSD that behave the same. - */ -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - uname (&uts); - i = atof(uts.release) * 100; - if (i >= 310) goto acquire_vt; -#endif - /* otherwise fall through */ - case PCVT: -#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000)) - /* - * First activate the #1 VT. This is a hack to allow a server - * to be started while another one is active. There should be - * a better way. - */ - if (initialVT != 1) { - - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0) - { - xf86Msg(X_WARNING, - "xf86OpenConsole: VT_ACTIVATE failed\n"); - } - sleep(1); - } -#endif -acquire_vt: - if (!ShareVTs) { - /* - * now get the VT - */ - SYSCALL(result = - ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno)); - if (result != 0) - { - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); - } - SYSCALL(result = - ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno)); - if (result != 0) - { - xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); - } - - signal(SIGUSR1, xf86VTRequest); - - vtmode.mode = VT_PROCESS; - vtmode.relsig = SIGUSR1; - vtmode.acqsig = SIGUSR1; - vtmode.frsig = SIGUSR1; - if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0) - { - FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed"); - } - #if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) - if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0) - { - FatalError("xf86OpenConsole: KDENABIO failed (%s)", - strerror(errno)); - } - #endif - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) - { - FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed"); - } - } else { /* ShareVTs */ - close(xf86Info.consoleFd); - } - break; -#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ -#ifdef WSCONS_SUPPORT - case WSCONS: - /* Nothing to do */ - break; -#endif - } - } - else - { - /* serverGeneration != 1 */ -#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) - if (!ShareVTs) if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) - { - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) - { - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); - } - } -#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ - } - return; -} - - -#ifdef PCCONS_SUPPORT - -static int -xf86OpenPccons() -{ - int fd = -1; - - if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0)) - >= 0 || - (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0)) - >= 0) - { - if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0) - { - FatalError( - "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s", - "xf86OpenPccons", - strerror(errno), - "Was expecting pccons driver with X support", - CHECK_DRIVER_MSG); - } - xf86Info.consType = PCCONS; - xf86Msg(X_PROBED, "Using pccons driver with X support\n"); - } - return fd; -} - -#endif /* PCCONS_SUPPORT */ - -#ifdef SYSCONS_SUPPORT - -static int -xf86OpenSyscons() -{ - int fd = -1; - vtmode_t vtmode; - char vtname[12]; - struct stat status; - long syscons_version; - MessageType from; - - /* Check for syscons */ - if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0 - || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0) - { - if (ioctl(fd, VT_GETMODE, &vtmode) >= 0) - { - /* Get syscons version */ - if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0) - { - syscons_version = 0; - } - - xf86Info.vtno = VTnum; - from = X_CMDLINE; - -#ifdef VT_GETACTIVE - if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0) - initialVT = -1; -#endif - if (ShareVTs) - xf86Info.vtno = initialVT; - - if (xf86Info.vtno == -1) - { - /* - * For old syscons versions (<0x100), VT_OPENQRY returns - * the current VT rather than the next free VT. In this - * case, the server gets started on the current VT instead - * of the next free VT. - */ - -#if 0 - /* check for the fixed VT_OPENQRY */ - if (syscons_version >= 0x100) - { -#endif - if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) - { - /* No free VTs */ - xf86Info.vtno = -1; - } -#if 0 - } -#endif - - if (xf86Info.vtno == -1) - { - /* - * All VTs are in use. If initialVT was found, use it. - * Otherwise, if stdin is a VT, use that one. - * XXX stdin is already closed, so this won't work. - */ - if (initialVT != -1) - { - xf86Info.vtno = initialVT; - } - else if ((fstat(0, &status) >= 0) - && S_ISCHR(status.st_mode) - && (ioctl(0, VT_GETMODE, &vtmode) >= 0)) - { - /* stdin is a VT */ - xf86Info.vtno = minor(status.st_rdev) + 1; - } - else - { - if (syscons_version >= 0x100) - { - FatalError("%s: Cannot find a free VT", - "xf86OpenSyscons"); - } - /* Should no longer reach here */ - FatalError("%s: %s %s\n\t%s %s", - "xf86OpenSyscons", - "syscons versions prior to 1.0 require", - "either the", - "server's stdin be a VT", - "or the use of the vtxx server option"); - } - } - from = X_PROBED; - } - - close(fd); -#ifndef __OpenBSD__ - sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1); -#else - sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1); -#endif - if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0) - { - FatalError("xf86OpenSyscons: Cannot open %s (%s)", - vtname, strerror(errno)); - } - if (ioctl(fd, VT_GETMODE, &vtmode) < 0) - { - FatalError("xf86OpenSyscons: VT_GETMODE failed"); - } - xf86Info.consType = SYSCONS; - xf86Msg(X_PROBED, "Using syscons driver with X support"); - if (syscons_version >= 0x100) - { - xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8, - syscons_version & 0xFF); - } - else - { - xf86ErrorF(" (version 0.x)\n"); - } - xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno); - } - else - { - /* VT_GETMODE failed, probably not syscons */ - close(fd); - fd = -1; - } - } - return fd; -} - -#endif /* SYSCONS_SUPPORT */ - - -#ifdef PCVT_SUPPORT - -static int -xf86OpenPcvt() -{ - /* This looks much like syscons, since pcvt is API compatible */ - int fd = -1; - vtmode_t vtmode; - char vtname[12], *vtprefix; - struct stat status; - struct pcvtid pcvt_version; - -#ifndef __OpenBSD__ - vtprefix = "/dev/ttyv"; -#else - vtprefix = "/dev/ttyC"; -#endif - - fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0); -#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV - if (fd < 0) - { - fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0); - vtprefix = "/dev/ttyE"; - } -#endif - if (fd >= 0) - { - if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0) - { - if(ioctl(fd, VT_GETMODE, &vtmode) < 0) - { - FatalError("%s: VT_GETMODE failed\n%s%s\n%s", - "xf86OpenPcvt", - "Found pcvt driver but X11 seems to be", - " not supported.", CHECK_DRIVER_MSG); - } - - xf86Info.vtno = VTnum; - - if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0) - initialVT = -1; - - if (xf86Info.vtno == -1) - { - if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) - { - /* No free VTs */ - xf86Info.vtno = -1; - } - - if (xf86Info.vtno == -1) - { - /* - * All VTs are in use. If initialVT was found, use it. - * Otherwise, if stdin is a VT, use that one. - * XXX stdin is already closed, so this won't work. - */ - if (initialVT != -1) - { - xf86Info.vtno = initialVT; - } - else if ((fstat(0, &status) >= 0) - && S_ISCHR(status.st_mode) - && (ioctl(0, VT_GETMODE, &vtmode) >= 0)) - { - /* stdin is a VT */ - xf86Info.vtno = minor(status.st_rdev) + 1; - } - else - { - FatalError("%s: Cannot find a free VT", - "xf86OpenPcvt"); - } - } - } - - close(fd); - sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1); - if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) - { - ErrorF("xf86OpenPcvt: Cannot open %s (%s)", - vtname, strerror(errno)); - xf86Info.vtno = initialVT; - sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1); - if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) { - FatalError("xf86OpenPcvt: Cannot open %s (%s)", - vtname, strerror(errno)); - } - } - if (ioctl(fd, VT_GETMODE, &vtmode) < 0) - { - FatalError("xf86OpenPcvt: VT_GETMODE failed"); - } - xf86Info.consType = PCVT; -#ifdef WSCONS_SUPPORT - xf86Msg(X_PROBED, - "Using wscons driver on %s in pcvt compatibility mode " - "(version %d.%d)\n", vtname, - pcvt_version.rmajor, pcvt_version.rminor); -#else - xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n", - pcvt_version.rmajor, pcvt_version.rminor); -#endif - } - else - { - /* Not pcvt */ - close(fd); - fd = -1; - } - } - return fd; -} - -#endif /* PCVT_SUPPORT */ - -#ifdef WSCONS_SUPPORT - -static int -xf86OpenWScons() -{ - int fd = -1; - int mode = WSDISPLAYIO_MODE_MAPPED; - int i; - char ttyname[16]; - - /* XXX Is this ok? */ - for (i = 0; i < 8; i++) { -#if defined(__NetBSD__) - sprintf(ttyname, "/dev/ttyE%d", i); -#elif defined(__OpenBSD__) - sprintf(ttyname, "/dev/ttyC%x", i); -#endif - if ((fd = open(ttyname, 2)) != -1) - break; - } - if (fd != -1) { - if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) { - FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s", - "xf86OpenConsole", strerror(errno), - CHECK_DRIVER_MSG); - } - xf86Info.consType = WSCONS; - xf86Msg(X_PROBED, "Using wscons driver\n"); - } - return fd; -} - -#endif /* WSCONS_SUPPORT */ - -void -xf86CloseConsole() -{ -#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) - struct vt_mode VT; -#endif - - if (ShareVTs) return; - - switch (xf86Info.consType) - { -#ifdef PCCONS_SUPPORT - case PCCONS: - ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0); - break; -#endif /* PCCONS_SUPPORT */ -#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) - case SYSCONS: - case PCVT: - ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */ - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) - { - VT.mode = VT_AUTO; - ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */ - } -#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) - if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0) - { - xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)", - strerror(errno)); - } -#endif - if (initialVT != -1) - ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT); - break; -#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ -#ifdef WSCONS_SUPPORT - case WSCONS: - { - int mode = WSDISPLAYIO_MODE_EMUL; - ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode); - break; - } -#endif - } - - if (xf86Info.screenFd != xf86Info.consoleFd) - { - close(xf86Info.screenFd); - close(xf86Info.consoleFd); - if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0) - { - xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)", - strerror(errno)); - } - } - close(xf86Info.consoleFd); - if (devConsoleFd >= 0) - close(devConsoleFd); - return; -} - -int -xf86ProcessArgument(int argc, char *argv[], int i) -{ - /* - * Keep server from detaching from controlling tty. This is useful - * when debugging (so the server can receive keyboard signals. - */ - if (!strcmp(argv[i], "-keeptty")) - { - KeepTty = TRUE; - return(1); - } -#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) - if (!strcmp(argv[i], "-sharevts")) - { - ShareVTs = TRUE; - return(1); - } - if ((argv[i][0] == 'v') && (argv[i][1] == 't')) - { - if (sscanf(argv[i], "vt%2d", &VTnum) == 0 || - VTnum < 1 || VTnum > 12) - { - UseMsg(); - VTnum = -1; - return(0); - } - return(1); - } -#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ - return(0); -} - -void -xf86UseMsg() -{ -#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) - ErrorF("vtXX use the specified VT number (1-12)\n"); - ErrorF("-sharevts share VTs with another X server\n"); -#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ - ErrorF("-keeptty "); - ErrorF("don't detach controlling tty (for debugging only)\n"); - return; -} +/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <sys/utsname.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <errno.h>
+
+static Bool KeepTty = FALSE;
+static int devConsoleFd = -1;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+static int VTnum = -1;
+static int initialVT = -1;
+static Bool ShareVTs = FALSE;
+#endif
+
+#ifdef PCCONS_SUPPORT
+/* Stock 0.1 386bsd pccons console driver interface */
+#ifndef __OpenBSD__
+# define PCCONS_CONSOLE_DEV1 "/dev/ttyv0"
+#else
+# define PCCONS_CONSOLE_DEV1 "/dev/ttyC0"
+#endif
+#define PCCONS_CONSOLE_DEV2 "/dev/vga"
+#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#ifdef SYSCONS_SUPPORT
+/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */
+#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0"
+#define SYSCONS_CONSOLE_DEV2 "/dev/vga"
+#define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#ifdef PCVT_SUPPORT
+/* Hellmuth Michaelis' pcvt driver */
+#ifndef __OpenBSD__
+# define PCVT_CONSOLE_DEV "/dev/ttyv0"
+#else
+# define PCVT_CONSOLE_DEV "/dev/ttyC0"
+#endif
+#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#if defined(WSCONS_SUPPORT) && defined(__NetBSD__)
+/* NetBSD's new console driver */
+#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0"
+#endif
+
+#ifdef __GLIBC__
+#define setpgrp setpgid
+#endif
+
+#define CHECK_DRIVER_MSG \
+ "Check your kernel's console driver configuration and /dev entries"
+
+static char *supported_drivers[] = {
+#ifdef PCCONS_SUPPORT
+ "pccons (with X support)",
+#endif
+#ifdef SYSCONS_SUPPORT
+ "syscons",
+#endif
+#ifdef PCVT_SUPPORT
+ "pcvt",
+#endif
+#ifdef WSCONS_SUPPORT
+ "wscons",
+#endif
+};
+
+
+/*
+ * Functions to probe for the existance of a supported console driver.
+ * Any function returns either a valid file descriptor (driver probed
+ * succesfully), -1 (driver not found), or uses FatalError() if the
+ * driver was found but proved to not support the required mode to run
+ * an X server.
+ */
+
+typedef int (*xf86ConsOpen_t)(void);
+
+#ifdef PCCONS_SUPPORT
+static int xf86OpenPccons(void);
+#endif /* PCCONS_SUPPORT */
+
+#ifdef SYSCONS_SUPPORT
+static int xf86OpenSyscons(void);
+#endif /* SYSCONS_SUPPORT */
+
+#ifdef PCVT_SUPPORT
+static int xf86OpenPcvt(void);
+#endif /* PCVT_SUPPORT */
+
+#ifdef WSCONS_SUPPORT
+static int xf86OpenWScons(void);
+#endif
+
+/*
+ * The sequence of the driver probes is important; start with the
+ * driver that is best distinguishable, and end with the most generic
+ * driver. (Otherwise, pcvt would also probe as syscons, and either
+ * pcvt or syscons might succesfully probe as pccons.)
+ */
+static xf86ConsOpen_t xf86ConsTab[] = {
+#ifdef PCVT_SUPPORT
+ xf86OpenPcvt,
+#endif
+#ifdef SYSCONS_SUPPORT
+ xf86OpenSyscons,
+#endif
+#ifdef PCCONS_SUPPORT
+ xf86OpenPccons,
+#endif
+#ifdef WSCONS_SUPPORT
+ xf86OpenWScons,
+#endif
+ (xf86ConsOpen_t)NULL
+};
+
+
+void
+xf86OpenConsole()
+{
+ int i, fd = -1;
+ xf86ConsOpen_t *driver;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ int result;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ struct utsname uts;
+#endif
+ vtmode_t vtmode;
+#endif
+
+ if (serverGeneration == 1)
+ {
+ /* check if we are run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("xf86OpenConsole: Server must be suid root");
+ }
+
+ if (!KeepTty)
+ {
+ /*
+ * detaching the controlling tty solves problems of kbd character
+ * loss. This is not interesting for CO driver, because it is
+ * exclusive.
+ */
+ setpgrp(0, getpid());
+ if ((i = open("/dev/tty",O_RDWR)) >= 0)
+ {
+ ioctl(i,TIOCNOTTY,(char *)0);
+ close(i);
+ }
+ }
+
+ /* detect which driver we are running on */
+ for (driver = xf86ConsTab; *driver; driver++)
+ {
+ if ((fd = (*driver)()) >= 0)
+ break;
+ }
+
+ /* Check that a supported console driver was found */
+ if (fd < 0)
+ {
+ char cons_drivers[80] = {0, };
+ for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++)
+ {
+ if (i)
+ {
+ strcat(cons_drivers, ", ");
+ }
+ strcat(cons_drivers, supported_drivers[i]);
+ }
+ FatalError(
+ "%s: No console driver found\n\tSupported drivers: %s\n\t%s",
+ "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG);
+ }
+#if 0 /* stdin is already closed in OsInit() */
+ fclose(stdin);
+#endif
+ xf86Info.consoleFd = fd;
+ xf86Info.screenFd = fd;
+
+ switch (xf86Info.consType)
+ {
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+ if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0)
+ {
+ FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s",
+ "xf86OpenConsole", strerror(errno),
+ CHECK_DRIVER_MSG);
+ }
+ /*
+ * Hack to prevent keyboard hanging when syslogd closes
+ * /dev/console
+ */
+ if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: couldn't open /dev/console (%s)\n",
+ strerror(errno));
+ }
+ break;
+#endif
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt
+ * switching anymore. Here we check for FreeBSD 3.1 and up.
+ * Add cases for other *BSD that behave the same.
+ */
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ uname (&uts);
+ i = atof(uts.release) * 100;
+ if (i >= 310) goto acquire_vt;
+#endif
+ /* otherwise fall through */
+ case PCVT:
+#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000))
+ /*
+ * First activate the #1 VT. This is a hack to allow a server
+ * to be started while another one is active. There should be
+ * a better way.
+ */
+ if (initialVT != 1) {
+
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ sleep(1);
+ }
+#endif
+acquire_vt:
+ if (!ShareVTs) {
+ /*
+ * now get the VT
+ */
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
+ if (result != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
+ if (result != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ vtmode.mode = VT_PROCESS;
+ vtmode.relsig = SIGUSR1;
+ vtmode.acqsig = SIGUSR1;
+ vtmode.frsig = SIGUSR1;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
+ }
+ #if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+ if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
+ {
+ FatalError("xf86OpenConsole: KDENABIO failed (%s)",
+ strerror(errno));
+ }
+ #endif
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ {
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
+ }
+ } else { /* ShareVTs */
+ close(xf86Info.consoleFd);
+ }
+ break;
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ /* Nothing to do */
+ break;
+#endif
+ }
+ }
+ else
+ {
+ /* serverGeneration != 1 */
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (!ShareVTs) if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
+ {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ }
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ }
+ return;
+}
+
+
+#ifdef PCCONS_SUPPORT
+
+static int
+xf86OpenPccons()
+{
+ int fd = -1;
+
+ if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0))
+ >= 0 ||
+ (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0))
+ >= 0)
+ {
+ if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0)
+ {
+ FatalError(
+ "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s",
+ "xf86OpenPccons",
+ strerror(errno),
+ "Was expecting pccons driver with X support",
+ CHECK_DRIVER_MSG);
+ }
+ xf86Info.consType = PCCONS;
+ xf86Msg(X_PROBED, "Using pccons driver with X support\n");
+ }
+ return fd;
+}
+
+#endif /* PCCONS_SUPPORT */
+
+#ifdef SYSCONS_SUPPORT
+
+static int
+xf86OpenSyscons()
+{
+ int fd = -1;
+ vtmode_t vtmode;
+ char vtname[12];
+ struct stat status;
+ long syscons_version;
+ MessageType from;
+
+ /* Check for syscons */
+ if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0
+ || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0)
+ {
+ if (ioctl(fd, VT_GETMODE, &vtmode) >= 0)
+ {
+ /* Get syscons version */
+ if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0)
+ {
+ syscons_version = 0;
+ }
+
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+
+#ifdef VT_GETACTIVE
+ if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
+ initialVT = -1;
+#endif
+ if (ShareVTs)
+ xf86Info.vtno = initialVT;
+
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * For old syscons versions (<0x100), VT_OPENQRY returns
+ * the current VT rather than the next free VT. In this
+ * case, the server gets started on the current VT instead
+ * of the next free VT.
+ */
+
+#if 0
+ /* check for the fixed VT_OPENQRY */
+ if (syscons_version >= 0x100)
+ {
+#endif
+ if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
+ {
+ /* No free VTs */
+ xf86Info.vtno = -1;
+ }
+#if 0
+ }
+#endif
+
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * All VTs are in use. If initialVT was found, use it.
+ * Otherwise, if stdin is a VT, use that one.
+ * XXX stdin is already closed, so this won't work.
+ */
+ if (initialVT != -1)
+ {
+ xf86Info.vtno = initialVT;
+ }
+ else if ((fstat(0, &status) >= 0)
+ && S_ISCHR(status.st_mode)
+ && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
+ {
+ /* stdin is a VT */
+ xf86Info.vtno = minor(status.st_rdev) + 1;
+ }
+ else
+ {
+ if (syscons_version >= 0x100)
+ {
+ FatalError("%s: Cannot find a free VT",
+ "xf86OpenSyscons");
+ }
+ /* Should no longer reach here */
+ FatalError("%s: %s %s\n\t%s %s",
+ "xf86OpenSyscons",
+ "syscons versions prior to 1.0 require",
+ "either the",
+ "server's stdin be a VT",
+ "or the use of the vtxx server option");
+ }
+ }
+ from = X_PROBED;
+ }
+
+ close(fd);
+#ifndef __OpenBSD__
+ sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1);
+#else
+ sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1);
+#endif
+ if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0)
+ {
+ FatalError("xf86OpenSyscons: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
+ if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenSyscons: VT_GETMODE failed");
+ }
+ xf86Info.consType = SYSCONS;
+ xf86Msg(X_PROBED, "Using syscons driver with X support");
+ if (syscons_version >= 0x100)
+ {
+ xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8,
+ syscons_version & 0xFF);
+ }
+ else
+ {
+ xf86ErrorF(" (version 0.x)\n");
+ }
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+ }
+ else
+ {
+ /* VT_GETMODE failed, probably not syscons */
+ close(fd);
+ fd = -1;
+ }
+ }
+ return fd;
+}
+
+#endif /* SYSCONS_SUPPORT */
+
+
+#ifdef PCVT_SUPPORT
+
+static int
+xf86OpenPcvt()
+{
+ /* This looks much like syscons, since pcvt is API compatible */
+ int fd = -1;
+ vtmode_t vtmode;
+ char vtname[12], *vtprefix;
+ struct stat status;
+ struct pcvtid pcvt_version;
+
+#ifndef __OpenBSD__
+ vtprefix = "/dev/ttyv";
+#else
+ vtprefix = "/dev/ttyC";
+#endif
+
+ fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV
+ if (fd < 0)
+ {
+ fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+ vtprefix = "/dev/ttyE";
+ }
+#endif
+ if (fd >= 0)
+ {
+ if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0)
+ {
+ if(ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("%s: VT_GETMODE failed\n%s%s\n%s",
+ "xf86OpenPcvt",
+ "Found pcvt driver but X11 seems to be",
+ " not supported.", CHECK_DRIVER_MSG);
+ }
+
+ xf86Info.vtno = VTnum;
+
+ if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
+ initialVT = -1;
+
+ if (xf86Info.vtno == -1)
+ {
+ if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
+ {
+ /* No free VTs */
+ xf86Info.vtno = -1;
+ }
+
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * All VTs are in use. If initialVT was found, use it.
+ * Otherwise, if stdin is a VT, use that one.
+ * XXX stdin is already closed, so this won't work.
+ */
+ if (initialVT != -1)
+ {
+ xf86Info.vtno = initialVT;
+ }
+ else if ((fstat(0, &status) >= 0)
+ && S_ISCHR(status.st_mode)
+ && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
+ {
+ /* stdin is a VT */
+ xf86Info.vtno = minor(status.st_rdev) + 1;
+ }
+ else
+ {
+ FatalError("%s: Cannot find a free VT",
+ "xf86OpenPcvt");
+ }
+ }
+ }
+
+ close(fd);
+ sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
+ if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
+ {
+ ErrorF("xf86OpenPcvt: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ xf86Info.vtno = initialVT;
+ sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
+ if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) {
+ FatalError("xf86OpenPcvt: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
+ }
+ if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenPcvt: VT_GETMODE failed");
+ }
+ xf86Info.consType = PCVT;
+#ifdef WSCONS_SUPPORT
+ xf86Msg(X_PROBED,
+ "Using wscons driver on %s in pcvt compatibility mode "
+ "(version %d.%d)\n", vtname,
+ pcvt_version.rmajor, pcvt_version.rminor);
+#else
+ xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
+ pcvt_version.rmajor, pcvt_version.rminor);
+#endif
+ }
+ else
+ {
+ /* Not pcvt */
+ close(fd);
+ fd = -1;
+ }
+ }
+ return fd;
+}
+
+#endif /* PCVT_SUPPORT */
+
+#ifdef WSCONS_SUPPORT
+
+static int
+xf86OpenWScons()
+{
+ int fd = -1;
+ int mode = WSDISPLAYIO_MODE_MAPPED;
+ int i;
+ char ttyname[16];
+
+ /* XXX Is this ok? */
+ for (i = 0; i < 8; i++) {
+#if defined(__NetBSD__)
+ sprintf(ttyname, "/dev/ttyE%d", i);
+#elif defined(__OpenBSD__)
+ sprintf(ttyname, "/dev/ttyC%x", i);
+#endif
+ if ((fd = open(ttyname, 2)) != -1)
+ break;
+ }
+ if (fd != -1) {
+ if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
+ FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s",
+ "xf86OpenConsole", strerror(errno),
+ CHECK_DRIVER_MSG);
+ }
+ xf86Info.consType = WSCONS;
+ xf86Msg(X_PROBED, "Using wscons driver\n");
+ }
+ return fd;
+}
+
+#endif /* WSCONS_SUPPORT */
+
+void
+xf86CloseConsole()
+{
+#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+ struct vt_mode VT;
+#endif
+
+ if (ShareVTs) return;
+
+ switch (xf86Info.consType)
+ {
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+ ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
+ break;
+#endif /* PCCONS_SUPPORT */
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
+ }
+#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+ if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0)
+ {
+ xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)",
+ strerror(errno));
+ }
+#endif
+ if (initialVT != -1)
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
+ break;
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ {
+ int mode = WSDISPLAYIO_MODE_EMUL;
+ ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode);
+ break;
+ }
+#endif
+ }
+
+ if (xf86Info.screenFd != xf86Info.consoleFd)
+ {
+ close(xf86Info.screenFd);
+ close(xf86Info.consoleFd);
+ if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0)
+ {
+ xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)",
+ strerror(errno));
+ }
+ }
+ close(xf86Info.consoleFd);
+ if (devConsoleFd >= 0)
+ close(devConsoleFd);
+ return;
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return 1;
+ }
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (!strcmp(argv[i], "-sharevts"))
+ {
+ ShareVTs = TRUE;
+ return 1;
+ }
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
+ VTnum < 1 || VTnum > 12)
+ {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ return 1;
+ }
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ return 0;
+}
+
+void
+xf86UseMsg()
+{
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ ErrorF("vtXX use the specified VT number (1-12)\n");
+ ErrorF("-sharevts share VTs with another X server\n");
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ return;
+}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c index 0d457193a..9b26fb1dd 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c +++ b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c @@ -246,7 +246,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) "xf86MapVidMem", DEV_MEM, Size, Base,
strerror(errno));
}
- return(base);
+ return base;
}
/* else, mmap /dev/vga */
@@ -266,7 +266,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)",
strerror(errno));
}
- return(base);
+ return base;
}
static void
@@ -289,7 +289,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, checkDevMem(TRUE);
if (devMemFd == -1) {
- return(-1);
+ return -1;
}
psize = getpagesize();
@@ -308,7 +308,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, xf86Msg(X_WARNING, SYSCTL_MSG2);
}
#endif
- return(-1);
+ return -1;
}
#ifdef DEBUG
ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
@@ -321,7 +321,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, "-> %02x %02x %02x %02x...\n",
Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
#endif
- return(Len);
+ return Len;
}
#ifdef USE_I386_IOPL
diff --git a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c index ea520c49e..1dcd77711 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c +++ b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c @@ -1,91 +1,91 @@ -/* - * Copyright 1992 by Rich Murphey <Rich@Rice.edu> - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Rich Murphey and David Wexelblat - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. Rich Murphey and - * David Wexelblat make no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" - -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#ifndef MAP_FAILED -#define MAP_FAILED ((caddr_t)-1) -#endif - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -static pointer sparc64MapVidMem(int, unsigned long, unsigned long, int); -static void sparc64UnmapVidMem(int, pointer, unsigned long); - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - pVidMem->linearSupported = TRUE; - pVidMem->mapMem = sparc64MapVidMem; - pVidMem->unmapMem = sparc64UnmapVidMem; - pVidMem->initialised = TRUE; -} - -static pointer -sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, - int flags) -{ - int fd = xf86Info.screenFd; - pointer base; - -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", - Base, Size, fd); -#endif - - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_SHARED, fd, Base); - if (base == MAP_FAILED) - FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)", - "xf86MapVidMem", Size, Base, strerror(errno)); - return base; -} - -static void -sparc64UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - munmap(Base, Size); -} - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - - return (0); -} +/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static pointer sparc64MapVidMem(int, unsigned long, unsigned long, int);
+static void sparc64UnmapVidMem(int, pointer, unsigned long);
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = sparc64MapVidMem;
+ pVidMem->unmapMem = sparc64UnmapVidMem;
+ pVidMem->initialised = TRUE;
+}
+
+static pointer
+sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size,
+ int flags)
+{
+ int fd = xf86Info.screenFd;
+ pointer base;
+
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d",
+ Base, Size, fd);
+#endif
+
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, fd, Base);
+ if (base == MAP_FAILED)
+ FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ return base;
+}
+
+static void
+sparc64UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap(Base, Size);
+}
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+
+ return 0;
+}
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c index 3fa897366..705bb5ea0 100644 --- a/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c @@ -64,7 +64,7 @@ GARTInit(int screenNum) struct _agp_info agpinf;
if (initDone)
- return (gartFd != -1);
+ return gartFd != -1;
initDone = TRUE;
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c index 297e7a65a..722fbb0c1 100644 --- a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c @@ -1,401 +1,401 @@ -/* - * Copyright 1992 by Orest Zborowski <obz@Kodak.com> - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Orest Zborowski and David Wexelblat - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. Orest Zborowski - * and David Wexelblat make no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#include <sys/stat.h> - -static Bool KeepTty = FALSE; -static int VTnum = -1; -static Bool VTSwitch = TRUE; -static Bool ShareVTs = FALSE; -static int activeVT = -1; - -static int vtPermSave[4]; -static char vtname[11]; -static struct termios tty_attr; /* tty state to restore */ -static int tty_mode; /* kbd mode to restore */ - -static int -saveVtPerms(void) -{ - /* We need to use stat to get permissions. */ - struct stat svtp; - - /* Do them numerically ordered, hard coded tty0 first. */ - if (stat("/dev/tty0", &svtp) != 0) - return 0; - vtPermSave[0] = (int)svtp.st_uid; - vtPermSave[1] = (int)svtp.st_gid; - - /* Now check the console we are dealing with. */ - if (stat(vtname, &svtp) != 0) - return 0; - vtPermSave[2] = (int)svtp.st_uid; - vtPermSave[3] = (int)svtp.st_gid; - - return 1; -} - -static void -restoreVtPerms(void) -{ - if (geteuid() == 0) { - /* Set the terminal permissions back to before we started. */ - (void)chown("/dev/tty0", vtPermSave[0], vtPermSave[1]); - (void)chown(vtname, vtPermSave[2], vtPermSave[3]); - } -} - -static void *console_handler; - -static void -drain_console(int fd, void *closure) -{ - tcflush(fd, TCIOFLUSH); -} - -void -xf86OpenConsole(void) -{ - int i, fd = -1; - struct vt_mode VT; - struct vt_stat vts; - MessageType from = X_PROBED; - char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL }; - char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL }; - - if (serverGeneration == 1) { - - /* when KeepTty check if we're run with euid==0 */ - if (KeepTty && geteuid() != 0) - FatalError("xf86OpenConsole:" - " Server must be suid root for option \"KeepTTY\"\n"); - - /* - * setup the virtual terminal manager - */ - if (VTnum != -1) { - xf86Info.vtno = VTnum; - from = X_CMDLINE; - } else { - - i=0; - while (tty0[i] != NULL) { - if ((fd = open(tty0[i],O_WRONLY,0)) >= 0) - break; - i++; - } - - if (fd < 0) - FatalError( - "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n", - strerror(errno)); - - if (ShareVTs) - { - if (ioctl(fd, VT_GETSTATE, &vts) == 0) - xf86Info.vtno = vts.v_active; - else - FatalError("xf86OpenConsole: Cannot find the current" - " VT (%s)\n", strerror(errno)); - } else { - if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || - (xf86Info.vtno == -1)) - FatalError("xf86OpenConsole: Cannot find a free VT: %s\n", - strerror(errno)); - } - close(fd); - } - - xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno); - - if (!KeepTty) { - pid_t ppid = getppid(); - pid_t ppgid; - ppgid = getpgid(ppid); - - /* - * change to parent process group that pgid != pid so - * that setsid() doesn't fail and we become process - * group leader - */ - if (setpgid(0,ppgid) < 0) - xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n", - strerror(errno)); - - /* become process group leader */ - if ((setsid() < 0)) - xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n", - strerror(errno)); - } - - i=0; - while (vcs[i] != NULL) { - sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */ - if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0) - break; - i++; - } - - if (xf86Info.consoleFd < 0) - FatalError("xf86OpenConsole: Cannot open virtual console" - " %d (%s)\n", xf86Info.vtno, strerror(errno)); - - if (!ShareVTs) - { - /* - * Grab the vt ownership before we overwrite it. - * Hard coded /dev/tty0 into this function as well for below. - */ - if (!saveVtPerms()) - xf86Msg(X_WARNING, - "xf86OpenConsole: Could not save ownership of VT\n"); - - if (geteuid() == 0) { - /* change ownership of the vt */ - if (chown(vtname, getuid(), getgid()) < 0) - xf86Msg(X_WARNING,"xf86OpenConsole: chown %s failed: %s\n", - vtname, strerror(errno)); - - /* - * the current VT device we're running on is not - * "console", we want to grab all consoles too - * - * Why is this needed?? - */ - if (chown("/dev/tty0", getuid(), getgid()) < 0) - xf86Msg(X_WARNING,"xf86OpenConsole: chown /dev/tty0 failed: %s\n", - strerror(errno)); - } - } - - /* - * Linux doesn't switch to an active vt after the last close of a vt, - * so we do this ourselves by remembering which is active now. - */ - if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0) - xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n", - strerror(errno)); - else - activeVT = vts.v_active; - -#if 0 - if (!KeepTty) { - /* - * Detach from the controlling tty to avoid char loss - */ - if ((i = open("/dev/tty",O_RDWR)) >= 0) { - ioctl(i, TIOCNOTTY, 0); - close(i); - } - } -#endif - - if (!ShareVTs) - { - struct termios nTty; - - /* - * now get the VT. This _must_ succeed, or else fail completely. - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0) - FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n", - strerror(errno)); - - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0) - FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n", - strerror(errno)); - - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) - FatalError("xf86OpenConsole: VT_GETMODE failed %s\n", - strerror(errno)); - - signal(SIGUSR1, xf86VTRequest); - - VT.mode = VT_PROCESS; - VT.relsig = SIGUSR1; - VT.acqsig = SIGUSR1; - - if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) - FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n", - strerror(errno)); - - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) - FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n", - strerror(errno)); - - tcgetattr(xf86Info.consoleFd, &tty_attr); - ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode); - - if (ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW) < 0) - FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n", - strerror(errno)); - - nTty = tty_attr; - nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); - nTty.c_oflag = 0; - nTty.c_cflag = CREAD | CS8; - nTty.c_lflag = 0; - nTty.c_cc[VTIME]=0; - nTty.c_cc[VMIN]=1; - cfsetispeed(&nTty, 9600); - cfsetospeed(&nTty, 9600); - tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty); - - /* need to keep the buffer clean, else the kernel gets angry */ - console_handler = xf86AddGeneralHandler(xf86Info.consoleFd, - drain_console, NULL); - - /* we really should have a InitOSInputDevices() function instead - * of Init?$#*&Device(). So I just place it here */ - } - } else { /* serverGeneration != 1 */ - if (!ShareVTs && VTSwitch) - { - /* - * now get the VT - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0) - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed %s\n", - strerror(errno)); - - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0) - xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed %s\n", - strerror(errno)); - } - } -} - -void -xf86CloseConsole(void) -{ - struct vt_mode VT; - - if (ShareVTs) { - close(xf86Info.consoleFd); - return; - } - - if (console_handler) { - xf86RemoveGeneralHandler(console_handler); - console_handler = NULL; - }; - - /* Back to text mode ... */ - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0) - xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n", - strerror(errno)); - - ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode); - tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr); - - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) - xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n", - strerror(errno)); - else { - /* set dflt vt handling */ - VT.mode = VT_AUTO; - if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) - xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n", - strerror(errno)); - } - - if (VTSwitch) - { - /* - * Perform a switch back to the active VT when we were started - */ - if (activeVT >= 0) { - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0) - xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n", - strerror(errno)); - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0) - xf86Msg(X_WARNING, - "xf86CloseConsole: VT_WAITACTIVE failed: %s\n", - strerror(errno)); - activeVT = -1; - } - } - close(xf86Info.consoleFd); /* make the vt-manager happy */ - - restoreVtPerms(); /* restore the permissions */ -} - -int -xf86ProcessArgument(int argc, char *argv[], int i) -{ - /* - * Keep server from detaching from controlling tty. This is useful - * when debugging (so the server can receive keyboard signals. - */ - if (!strcmp(argv[i], "-keeptty")) - { - KeepTty = TRUE; - return(1); - } - if (!strcmp(argv[i], "-novtswitch")) - { - VTSwitch = FALSE; - return(1); - } - if (!strcmp(argv[i], "-sharevts")) - { - ShareVTs = TRUE; - return(1); - } - if ((argv[i][0] == 'v') && (argv[i][1] == 't')) - { - if (sscanf(argv[i], "vt%2d", &VTnum) == 0) - { - UseMsg(); - VTnum = -1; - return(0); - } - return(1); - } - return(0); -} - -void -xf86UseMsg(void) -{ - ErrorF("vtXX use the specified VT number\n"); - ErrorF("-keeptty "); - ErrorF("don't detach controlling tty (for debugging only)\n"); - ErrorF("-novtswitch don't immediately switch to new VT\n"); - ErrorF("-sharevts share VTs with another X server\n"); -} +/*
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Orest Zborowski and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Orest Zborowski
+ * and David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <sys/stat.h>
+
+static Bool KeepTty = FALSE;
+static int VTnum = -1;
+static Bool VTSwitch = TRUE;
+static Bool ShareVTs = FALSE;
+static int activeVT = -1;
+
+static int vtPermSave[4];
+static char vtname[11];
+static struct termios tty_attr; /* tty state to restore */
+static int tty_mode; /* kbd mode to restore */
+
+static int
+saveVtPerms(void)
+{
+ /* We need to use stat to get permissions. */
+ struct stat svtp;
+
+ /* Do them numerically ordered, hard coded tty0 first. */
+ if (stat("/dev/tty0", &svtp) != 0)
+ return 0;
+ vtPermSave[0] = (int)svtp.st_uid;
+ vtPermSave[1] = (int)svtp.st_gid;
+
+ /* Now check the console we are dealing with. */
+ if (stat(vtname, &svtp) != 0)
+ return 0;
+ vtPermSave[2] = (int)svtp.st_uid;
+ vtPermSave[3] = (int)svtp.st_gid;
+
+ return 1;
+}
+
+static void
+restoreVtPerms(void)
+{
+ if (geteuid() == 0) {
+ /* Set the terminal permissions back to before we started. */
+ (void)chown("/dev/tty0", vtPermSave[0], vtPermSave[1]);
+ (void)chown(vtname, vtPermSave[2], vtPermSave[3]);
+ }
+}
+
+static void *console_handler;
+
+static void
+drain_console(int fd, void *closure)
+{
+ tcflush(fd, TCIOFLUSH);
+}
+
+void
+xf86OpenConsole(void)
+{
+ int i, fd = -1;
+ struct vt_mode VT;
+ struct vt_stat vts;
+ MessageType from = X_PROBED;
+ char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
+ char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
+
+ if (serverGeneration == 1) {
+
+ /* when KeepTty check if we're run with euid==0 */
+ if (KeepTty && geteuid() != 0)
+ FatalError("xf86OpenConsole:"
+ " Server must be suid root for option \"KeepTTY\"\n");
+
+ /*
+ * setup the virtual terminal manager
+ */
+ if (VTnum != -1) {
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+ } else {
+
+ i=0;
+ while (tty0[i] != NULL) {
+ if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
+ break;
+ i++;
+ }
+
+ if (fd < 0)
+ FatalError(
+ "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
+ strerror(errno));
+
+ if (ShareVTs)
+ {
+ if (ioctl(fd, VT_GETSTATE, &vts) == 0)
+ xf86Info.vtno = vts.v_active;
+ else
+ FatalError("xf86OpenConsole: Cannot find the current"
+ " VT (%s)\n", strerror(errno));
+ } else {
+ if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+ (xf86Info.vtno == -1))
+ FatalError("xf86OpenConsole: Cannot find a free VT: %s\n",
+ strerror(errno));
+ }
+ close(fd);
+ }
+
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+
+ if (!KeepTty) {
+ pid_t ppid = getppid();
+ pid_t ppgid;
+ ppgid = getpgid(ppid);
+
+ /*
+ * change to parent process group that pgid != pid so
+ * that setsid() doesn't fail and we become process
+ * group leader
+ */
+ if (setpgid(0,ppgid) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
+ strerror(errno));
+
+ /* become process group leader */
+ if ((setsid() < 0))
+ xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
+ strerror(errno));
+ }
+
+ i=0;
+ while (vcs[i] != NULL) {
+ sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
+ if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)
+ break;
+ i++;
+ }
+
+ if (xf86Info.consoleFd < 0)
+ FatalError("xf86OpenConsole: Cannot open virtual console"
+ " %d (%s)\n", xf86Info.vtno, strerror(errno));
+
+ if (!ShareVTs)
+ {
+ /*
+ * Grab the vt ownership before we overwrite it.
+ * Hard coded /dev/tty0 into this function as well for below.
+ */
+ if (!saveVtPerms())
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: Could not save ownership of VT\n");
+
+ if (geteuid() == 0) {
+ /* change ownership of the vt */
+ if (chown(vtname, getuid(), getgid()) < 0)
+ xf86Msg(X_WARNING,"xf86OpenConsole: chown %s failed: %s\n",
+ vtname, strerror(errno));
+
+ /*
+ * the current VT device we're running on is not
+ * "console", we want to grab all consoles too
+ *
+ * Why is this needed??
+ */
+ if (chown("/dev/tty0", getuid(), getgid()) < 0)
+ xf86Msg(X_WARNING,"xf86OpenConsole: chown /dev/tty0 failed: %s\n",
+ strerror(errno));
+ }
+ }
+
+ /*
+ * Linux doesn't switch to an active vt after the last close of a vt,
+ * so we do this ourselves by remembering which is active now.
+ */
+ if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
+ xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n",
+ strerror(errno));
+ else
+ activeVT = vts.v_active;
+
+#if 0
+ if (!KeepTty) {
+ /*
+ * Detach from the controlling tty to avoid char loss
+ */
+ if ((i = open("/dev/tty",O_RDWR)) >= 0) {
+ ioctl(i, TIOCNOTTY, 0);
+ close(i);
+ }
+ }
+#endif
+
+ if (!ShareVTs)
+ {
+ struct termios nTty;
+
+ /*
+ * now get the VT. This _must_ succeed, or else fail completely.
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
+ FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
+ FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
+ strerror(errno));
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n",
+ strerror(errno));
+
+ tcgetattr(xf86Info.consoleFd, &tty_attr);
+ ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode);
+
+ if (ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW) < 0)
+ FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
+ strerror(errno));
+
+ nTty = tty_attr;
+ nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME]=0;
+ nTty.c_cc[VMIN]=1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
+
+ /* need to keep the buffer clean, else the kernel gets angry */
+ console_handler = xf86AddGeneralHandler(xf86Info.consoleFd,
+ drain_console, NULL);
+
+ /* we really should have a InitOSInputDevices() function instead
+ * of Init?$#*&Device(). So I just place it here */
+ }
+ } else { /* serverGeneration != 1 */
+ if (!ShareVTs && VTSwitch)
+ {
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed %s\n",
+ strerror(errno));
+ }
+ }
+}
+
+void
+xf86CloseConsole(void)
+{
+ struct vt_mode VT;
+
+ if (ShareVTs) {
+ close(xf86Info.consoleFd);
+ return;
+ }
+
+ if (console_handler) {
+ xf86RemoveGeneralHandler(console_handler);
+ console_handler = NULL;
+ };
+
+ /* Back to text mode ... */
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
+ strerror(errno));
+
+ ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
+ strerror(errno));
+ else {
+ /* set dflt vt handling */
+ VT.mode = VT_AUTO;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n",
+ strerror(errno));
+ }
+
+ if (VTSwitch)
+ {
+ /*
+ * Perform a switch back to the active VT when we were started
+ */
+ if (activeVT >= 0) {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n",
+ strerror(errno));
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0)
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole: VT_WAITACTIVE failed: %s\n",
+ strerror(errno));
+ activeVT = -1;
+ }
+ }
+ close(xf86Info.consoleFd); /* make the vt-manager happy */
+
+ restoreVtPerms(); /* restore the permissions */
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-novtswitch"))
+ {
+ VTSwitch = FALSE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-sharevts"))
+ {
+ ShareVTs = TRUE;
+ return 1;
+ }
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+ {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+void
+xf86UseMsg(void)
+{
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ ErrorF("-novtswitch don't immediately switch to new VT\n");
+ ErrorF("-sharevts share VTs with another X server\n");
+}
diff --git a/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c b/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c index 9300b13b9..c9ef7d5cd 100644 --- a/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c +++ b/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c @@ -58,7 +58,7 @@ xf86VTRequest(int sig) Bool
xf86VTSwitchPending(void)
{
- return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+ return xf86Info.vtRequestsPending ? TRUE : FALSE;
}
/*
@@ -79,9 +79,9 @@ xf86VTSwitchAway(void) xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_TRUE) < 0) {
- return(FALSE);
+ return FALSE;
} else {
- return(TRUE);
+ return TRUE;
}
}
@@ -97,7 +97,7 @@ xf86VTSwitchTo(void) xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) {
- return(FALSE);
+ return FALSE;
} else {
if (sco_ledstatus >= 0) {
ioctl (xf86Info.consoleFd, KDSETLED, sco_ledstate);
@@ -120,8 +120,8 @@ Bool xf86VTActivate(int vtno)
{
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno - 1) < 0) {
- return(FALSE);
+ return FALSE;
}
- return(TRUE);
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_init.c b/xorg-server/hw/xfree86/os-support/sco/sco_init.c index 5f7db3437..fd4c898dd 100644 --- a/xorg-server/hw/xfree86/os-support/sco/sco_init.c +++ b/xorg-server/hw/xfree86/os-support/sco/sco_init.c @@ -1,294 +1,294 @@ -/* - * Copyright 2001-2005 by J. Kean Johnston <jkj@sco.com> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name J. Kean Johnston not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. J. Kean Johnston makes no - * representations about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* Re-written May 2001 to represent the current state of reality */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -static Bool KeepTty = FALSE; -static int VTnum = -1; -static char vtdevice[48]; -static int sco_console_mode = -1; - -extern Bool mpxLock; - -void -xf86OpenConsole(void) -{ - int i, ioctl_ret; - struct vt_mode VT; - struct vid_info vidinf; - struct sigaction sigvtsw; - char *ttn; - - if (serverGeneration == 1) { - /* check if we're run with euid==0 */ - if (geteuid() != 0) { - FatalError("xf86OpenConsole: Server must be setuid root\n"); - } - - /* If we are run in the background we will get SIGTTOU. Ignore it. */ - OsSignal (SIGTTOU, SIG_IGN); - - /* - * Set up the virtual terminal (multiscreen in SCO parlance). - * For the actual console itself, screens are numbered from - * 1 to (usually) 16. However, it is possible to have a nested - * server, and it is also possible to be on a multi-console - * system such as MaxSpeed or SunRiver. Therefore, we should - * not make any assumptions about the TTY name we are on, and - * instead we rely on ttyname() to give us the real TTY name. - * Previously, we tried to determine the TTY name manually. - * This is wrong. The only time we need to futz with the TTY name - * is if we were given the name of a TTY to run on explicity on - * the command line. - */ - - if (VTnum == -1) { - /* - * No device was specified. We need to query the kernel to see which - * console device we are on (and in fact if we are on a console at all). - */ - ttn = ttyname (1); - - if (ttn == (char *)0) { - FatalError ("xf86OpenConsole: Could not determine TTY name: %s\n", - strerror(errno)); - } - strlcpy (vtdevice, ttn, sizeof(vtdevice)); - } else if (VTnum >= 0) { - snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum); - } - - /* - * Now we can dispose of stdin/stdout - */ - fclose (stdin); - fclose (stdout); - - if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NDELAY, 0)) < 0) { - FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice, - strerror(errno)); - } - - /* - * We make 100% sure we use the correct VT number. This can get ugly - * where there are multi-consoles in use, so we make sure we query - * the kernel for the correct VT number. It knows best, we don't. - */ - vidinf.size = sizeof(vidinf); - if (ioctl (xf86Info.consoleFd, CONS_GETINFO, &vidinf) < 0) { - FatalError ("xf86OpenConsole: %s not a console device " - "or error querying device: %s\n", vtdevice, strerror (errno)); - } - xf86Info.vtno = vidinf.m_num; - VTnum = vidinf.m_num + 1; /* 0-based */ - - ErrorF("(using VT%02d device %s)\n\n", VTnum, vtdevice); - - /* We activate the console just in case its not the one we are on */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) { - ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno)); - } - - /* Disassociate from controling TTY */ - if (!KeepTty) { - setpgrp(); - } - - /* - * Now we get the current mode that the console device is in. We will - * use this later when we close the console device to restore it to - * that same mode. - */ - if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0) { - FatalError("xf86OpenConsole: CONS_GET failed on console (%s)\n", - strerror(errno)); - } - - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) { - FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n", strerror(errno)); - } - - sigvtsw.sa_handler = xf86VTRequest; - sigfillset(&sigvtsw.sa_mask); - sigvtsw.sa_flags = 0; - - /* NOTE: Using sigaction means we dont have to re-arm the signal */ - sigaction(SIGUSR1, &sigvtsw, NULL); - - VT.mode = VT_PROCESS; - VT.relsig = SIGUSR1; - VT.acqsig = SIGUSR1; - VT.frsig = SIGINT; /* Not implemented */ - VT.waitv = 0; - - /* - * The SCO X server tries the following call 5 times. Lets do the same - * thing. It shouldn't really be required but sometimes things take a - * while to settle down when switching screens. *helpless shrug* I know - * its sucks but ... - */ - - ioctl_ret = 0; - for (i = 0; i < 5; i++) { - ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); - if (ioctl_ret >= 0) - break; - usleep(999999); /* Dont use nap() - it forces linking with -lx */ - } - - if (ioctl_ret < 0) { - FatalError("xf86OpenConsole: VT_SETMODE failed (%s)\n", strerror(errno)); - } - - /* - * Convince the console driver we are in graphics mode. - */ - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) { - ErrorF("Failed to set graphics mode (%s)\n", strerror(errno)); - } - } else { /* serverGeneration != 1 */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) { - ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno)); - } - } -} - -/* - * Restore the console to its previous state. This may cause flicker if - * the screen was previous in a graphics mode, because we first set it - * to text mode. This has the advantage of getting the console driver - * to do a soft reset on the card, which really does help settle the - * video card down again after coming out of Xfree86. - */ -void -xf86CloseConsole(void) -{ - struct vt_mode VT; - struct sigaction sigvtsw; - - /* Set text mode (possibly briefly) */ - ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT0); - - /* Restore the original mode */ - if (sco_console_mode != -1) { - ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L); - } - - ioctl(xf86Info.consoleFd, VT_RELDISP, 1); /* Release the display */ - - sigvtsw.sa_handler = SIG_DFL; - sigfillset(&sigvtsw.sa_mask); - sigvtsw.sa_flags = 0; - - sigaction(SIGUSR1, &sigvtsw, NULL); - - VT.mode = VT_AUTO; - VT.waitv = 0; - VT.relsig = SIGUSR1; - VT.acqsig = SIGUSR1; - VT.frsig = SIGINT; - ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* Revert to auto handling */ - - close(xf86Info.consoleFd); /* We're done with the device */ -} - -int -xf86ProcessArgument(int argc, char *argv[], int i) -{ - /* - * Keep server from detaching from controlling tty. This is useful - * when debugging (so the server can receive keyboard signals). - */ - if (!strcmp(argv[i], "-keeptty")) { - KeepTty = TRUE; - return(1); - } - - /* - * By default, the X server wants to bind itself to CPU 0. This makes - * sure that the server has full access to the I/O ports at IOPL 3. - * Some SMP systems have trouble with I/O on CPU's other than 0. If, - * however, you have a system that is well behaved, you can specify - * this argument and let the scheduler decide which CPU the server - * should run on. - */ - if (!strcmp(argv[i], "-nompxlock")) { - mpxLock = FALSE; - return (1); - } - - /* - * Specify the VT number to run on (NOT the device). - */ - if ((argv[i][0] == 'v') && (argv[i][1] == 't')) { - if (sscanf(argv[i], "vt%2d", &VTnum) == 0) { - UseMsg(); - VTnum = -1; - return(0); - } - if (VTnum <= 0) { - UseMsg(); - VTnum = -1; - return(0); - } - return(1); - } - - /* - * Use a device the user specifies. - */ - if (!strcmp(argv[i], "-crt")) { - if (++i > argc) { - UseMsg(); - VTnum = -1; - return(0); - } else { - VTnum = -2; - strlcpy (vtdevice, argv[i], sizeof(vtdevice)); - return(2); - } - } - return(0); -} - -void -xf86UseMsg(void) -{ - ErrorF("vtXX use the specified VT number\n"); - ErrorF("-crt DEVICE use the specified VT device\n"); - ErrorF("-nompxlock dont bind X server to CPU 0\n"); - ErrorF("-keeptty "); - ErrorF("don't detach controlling tty (for debugging only)\n"); -} +/*
+ * Copyright 2001-2005 by J. Kean Johnston <jkj@sco.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Re-written May 2001 to represent the current state of reality */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+static Bool KeepTty = FALSE;
+static int VTnum = -1;
+static char vtdevice[48];
+static int sco_console_mode = -1;
+
+extern Bool mpxLock;
+
+void
+xf86OpenConsole(void)
+{
+ int i, ioctl_ret;
+ struct vt_mode VT;
+ struct vid_info vidinf;
+ struct sigaction sigvtsw;
+ char *ttn;
+
+ if (serverGeneration == 1) {
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0) {
+ FatalError("xf86OpenConsole: Server must be setuid root\n");
+ }
+
+ /* If we are run in the background we will get SIGTTOU. Ignore it. */
+ OsSignal (SIGTTOU, SIG_IGN);
+
+ /*
+ * Set up the virtual terminal (multiscreen in SCO parlance).
+ * For the actual console itself, screens are numbered from
+ * 1 to (usually) 16. However, it is possible to have a nested
+ * server, and it is also possible to be on a multi-console
+ * system such as MaxSpeed or SunRiver. Therefore, we should
+ * not make any assumptions about the TTY name we are on, and
+ * instead we rely on ttyname() to give us the real TTY name.
+ * Previously, we tried to determine the TTY name manually.
+ * This is wrong. The only time we need to futz with the TTY name
+ * is if we were given the name of a TTY to run on explicity on
+ * the command line.
+ */
+
+ if (VTnum == -1) {
+ /*
+ * No device was specified. We need to query the kernel to see which
+ * console device we are on (and in fact if we are on a console at all).
+ */
+ ttn = ttyname (1);
+
+ if (ttn == (char *)0) {
+ FatalError ("xf86OpenConsole: Could not determine TTY name: %s\n",
+ strerror(errno));
+ }
+ strlcpy (vtdevice, ttn, sizeof(vtdevice));
+ } else if (VTnum >= 0) {
+ snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum);
+ }
+
+ /*
+ * Now we can dispose of stdin/stdout
+ */
+ fclose (stdin);
+ fclose (stdout);
+
+ if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NDELAY, 0)) < 0) {
+ FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice,
+ strerror(errno));
+ }
+
+ /*
+ * We make 100% sure we use the correct VT number. This can get ugly
+ * where there are multi-consoles in use, so we make sure we query
+ * the kernel for the correct VT number. It knows best, we don't.
+ */
+ vidinf.size = sizeof(vidinf);
+ if (ioctl (xf86Info.consoleFd, CONS_GETINFO, &vidinf) < 0) {
+ FatalError ("xf86OpenConsole: %s not a console device "
+ "or error querying device: %s\n", vtdevice, strerror (errno));
+ }
+ xf86Info.vtno = vidinf.m_num;
+ VTnum = vidinf.m_num + 1; /* 0-based */
+
+ ErrorF("(using VT%02d device %s)\n\n", VTnum, vtdevice);
+
+ /* We activate the console just in case its not the one we are on */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
+ ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
+ }
+
+ /* Disassociate from controling TTY */
+ if (!KeepTty) {
+ setpgrp();
+ }
+
+ /*
+ * Now we get the current mode that the console device is in. We will
+ * use this later when we close the console device to restore it to
+ * that same mode.
+ */
+ if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0) {
+ FatalError("xf86OpenConsole: CONS_GET failed on console (%s)\n",
+ strerror(errno));
+ }
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) {
+ FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n", strerror(errno));
+ }
+
+ sigvtsw.sa_handler = xf86VTRequest;
+ sigfillset(&sigvtsw.sa_mask);
+ sigvtsw.sa_flags = 0;
+
+ /* NOTE: Using sigaction means we dont have to re-arm the signal */
+ sigaction(SIGUSR1, &sigvtsw, NULL);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ VT.frsig = SIGINT; /* Not implemented */
+ VT.waitv = 0;
+
+ /*
+ * The SCO X server tries the following call 5 times. Lets do the same
+ * thing. It shouldn't really be required but sometimes things take a
+ * while to settle down when switching screens. *helpless shrug* I know
+ * its sucks but ...
+ */
+
+ ioctl_ret = 0;
+ for (i = 0; i < 5; i++) {
+ ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
+ if (ioctl_ret >= 0)
+ break;
+ usleep(999999); /* Dont use nap() - it forces linking with -lx */
+ }
+
+ if (ioctl_ret < 0) {
+ FatalError("xf86OpenConsole: VT_SETMODE failed (%s)\n", strerror(errno));
+ }
+
+ /*
+ * Convince the console driver we are in graphics mode.
+ */
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+ ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
+ }
+ } else { /* serverGeneration != 1 */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
+ ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
+ }
+ }
+}
+
+/*
+ * Restore the console to its previous state. This may cause flicker if
+ * the screen was previous in a graphics mode, because we first set it
+ * to text mode. This has the advantage of getting the console driver
+ * to do a soft reset on the card, which really does help settle the
+ * video card down again after coming out of Xfree86.
+ */
+void
+xf86CloseConsole(void)
+{
+ struct vt_mode VT;
+ struct sigaction sigvtsw;
+
+ /* Set text mode (possibly briefly) */
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT0);
+
+ /* Restore the original mode */
+ if (sco_console_mode != -1) {
+ ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L);
+ }
+
+ ioctl(xf86Info.consoleFd, VT_RELDISP, 1); /* Release the display */
+
+ sigvtsw.sa_handler = SIG_DFL;
+ sigfillset(&sigvtsw.sa_mask);
+ sigvtsw.sa_flags = 0;
+
+ sigaction(SIGUSR1, &sigvtsw, NULL);
+
+ VT.mode = VT_AUTO;
+ VT.waitv = 0;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ VT.frsig = SIGINT;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* Revert to auto handling */
+
+ close(xf86Info.consoleFd); /* We're done with the device */
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals).
+ */
+ if (!strcmp(argv[i], "-keeptty")) {
+ KeepTty = TRUE;
+ return 1;
+ }
+
+ /*
+ * By default, the X server wants to bind itself to CPU 0. This makes
+ * sure that the server has full access to the I/O ports at IOPL 3.
+ * Some SMP systems have trouble with I/O on CPU's other than 0. If,
+ * however, you have a system that is well behaved, you can specify
+ * this argument and let the scheduler decide which CPU the server
+ * should run on.
+ */
+ if (!strcmp(argv[i], "-nompxlock")) {
+ mpxLock = FALSE;
+ return 1;
+ }
+
+ /*
+ * Specify the VT number to run on (NOT the device).
+ */
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0) {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ if (VTnum <= 0) {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ return 1;
+ }
+
+ /*
+ * Use a device the user specifies.
+ */
+ if (!strcmp(argv[i], "-crt")) {
+ if (++i > argc) {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ } else {
+ VTnum = -2;
+ strlcpy (vtdevice, argv[i], sizeof(vtdevice));
+ return 2;
+ }
+ }
+ return 0;
+}
+
+void
+xf86UseMsg(void)
+{
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-crt DEVICE use the specified VT device\n");
+ ErrorF("-nompxlock dont bind X server to CPU 0\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+}
diff --git a/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c b/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c index f3ddb29c9..be47cd681 100644 --- a/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c +++ b/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c @@ -38,23 +38,23 @@ Bool
xf86VTSwitchPending(void)
{
- return(FALSE);
+ return FALSE;
}
Bool
xf86VTSwitchAway(void)
{
- return(FALSE);
+ return FALSE;
}
Bool
xf86VTSwitchTo(void)
{
- return(TRUE);
+ return TRUE;
}
Bool
xf86VTActivate(int vtno)
{
- return(TRUE);
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c b/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c index 34bca7ae2..00bfb7151 100644 --- a/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c +++ b/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c @@ -55,7 +55,7 @@ xf86VTRequest(int sig) Bool
xf86VTSwitchPending(void)
{
- return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+ return xf86Info.vtRequestsPending ? TRUE : FALSE;
}
Bool
@@ -64,14 +64,14 @@ xf86VTSwitchAway(void) xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
{
- return(FALSE);
+ return FALSE;
}
else
{
#ifdef OSSWITCHAWAY
OSSWITCHAWAY;
#endif
- return(TRUE);
+ return TRUE;
}
}
@@ -81,11 +81,11 @@ xf86VTSwitchTo(void) xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
{
- return(FALSE);
+ return FALSE;
}
else
{
- return(TRUE);
+ return TRUE;
}
}
@@ -94,8 +94,8 @@ xf86VTActivate(int vtno) {
#ifdef VT_ACTIVATE
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0) {
- return(FALSE);
+ return FALSE;
}
#endif
- return(TRUE);
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c b/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c index 67a14f5d6..4699fcb88 100644 --- a/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c +++ b/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c @@ -1,75 +1,75 @@ -/* - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of David Wexelblat not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. David Wexelblat makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include <string.h> - -/* - * Read BIOS via /dev/mem. - */ - -#ifndef DEV_MEM -# define DEV_MEM "/dev/mem" -#endif - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - int fd; - -#ifdef __ia64__ - if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0) -#else - if ((fd = open(DEV_MEM, O_RDONLY)) < 0) -#endif - { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - return(-1); - } - - if (lseek(fd, (Base+Offset), SEEK_SET) < 0) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n", - DEV_MEM, strerror(errno)); - close(fd); - return(-1); - } - if (read(fd, Buf, Len) != Len) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n", - DEV_MEM, strerror(errno)); - close(fd); - return(-1); - } - close(fd); - return(Len); -} +/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include <string.h>
+
+/*
+ * Read BIOS via /dev/mem.
+ */
+
+#ifndef DEV_MEM
+# define DEV_MEM "/dev/mem"
+#endif
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ int fd;
+
+#ifdef __ia64__
+ if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0)
+#else
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
+#endif
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return -1;
+ }
+
+ if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n",
+ DEV_MEM, strerror(errno));
+ close(fd);
+ return -1;
+ }
+ if (read(fd, Buf, Len) != Len)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n",
+ DEV_MEM, strerror(errno));
+ close(fd);
+ return -1;
+ }
+ close(fd);
+ return Len;
+}
diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c index 40afd5b8e..a5887f578 100644 --- a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c +++ b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c @@ -1,141 +1,141 @@ -/* - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of David Wexelblat not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. David Wexelblat makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -/* - * Read BIOS via mmap()ing DEV_MEM - */ - -#ifndef __alpha__ -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - int fd; - unsigned char *ptr; - int psize; - int mlen; - - if ((fd = open(DEV_MEM, O_RDONLY)) < 0) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - return(-1); - } - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, - MAP_SHARED, fd, (off_t)Base); - if (ptr == MAP_FAILED) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n", - DEV_MEM, strerror(errno)); - close(fd); - return(-1); - } - DebugF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", - Base, ptr[0] | (ptr[1] << 8)); - (void)memcpy(Buf, (void *)(ptr + Offset), Len); - (void)munmap((caddr_t)ptr, mlen); - (void)close(fd); - return(Len); -} - -#else /* __alpha__ */ - - /* - * We trick "mmap" into mapping BUS memory for us via BUS_BASE, - * which is the KSEG address of the start of the DENSE memory - * area. - */ - - /* - * NOTE: there prolly ought to be more validity checks and all - * re: boundaries and sizes and such... - */ - -#ifdef linux - -extern unsigned long _bus_base(void); -#define BUS_BASE _bus_base() - -#else - -extern u_int64_t dense_base(void); -#define BUS_BASE dense_base() - -#endif - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - caddr_t base; - int fd; - int psize; - int mlen; - - if ((fd = open(DEV_MEM, O_RDONLY)) < 0) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - return(-1); - } - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - base = mmap((caddr_t)0, mlen, PROT_READ, - MAP_SHARED, fd, (off_t)(Base + BUS_BASE)); - - if (base == MAP_FAILED) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n", - DEV_MEM, strerror(errno)); - return(-1); - } - - xf86SlowBCopyFromBus((unsigned char *)(base+Offset), Buf, Len); - - munmap((caddr_t)base, mlen); - close(fd); - return(Len); -} - -#endif /* __alpha__ */ +/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+/*
+ * Read BIOS via mmap()ing DEV_MEM
+ */
+
+#ifndef __alpha__
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ int fd;
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return -1;
+ }
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, fd, (off_t)Base);
+ if (ptr == MAP_FAILED)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n",
+ DEV_MEM, strerror(errno));
+ close(fd);
+ return -1;
+ }
+ DebugF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+ (void)close(fd);
+ return Len;
+}
+
+#else /* __alpha__ */
+
+ /*
+ * We trick "mmap" into mapping BUS memory for us via BUS_BASE,
+ * which is the KSEG address of the start of the DENSE memory
+ * area.
+ */
+
+ /*
+ * NOTE: there prolly ought to be more validity checks and all
+ * re: boundaries and sizes and such...
+ */
+
+#ifdef linux
+
+extern unsigned long _bus_base(void);
+#define BUS_BASE _bus_base()
+
+#else
+
+extern u_int64_t dense_base(void);
+#define BUS_BASE dense_base()
+
+#endif
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ caddr_t base;
+ int fd;
+ int psize;
+ int mlen;
+
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return -1;
+ }
+
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ base = mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, fd, (off_t)(Base + BUS_BASE));
+
+ if (base == MAP_FAILED)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return -1;
+ }
+
+ xf86SlowBCopyFromBus((unsigned char *)(base+Offset), Buf, Len);
+
+ munmap((caddr_t)base, mlen);
+ close(fd);
+ return Len;
+}
+
+#endif /* __alpha__ */
diff --git a/xorg-server/hw/xfree86/os-support/shared/posix_tty.c b/xorg-server/hw/xfree86/os-support/shared/posix_tty.c index 7e2c4a181..97860d0f2 100644 --- a/xorg-server/hw/xfree86/os-support/shared/posix_tty.c +++ b/xorg-server/hw/xfree86/os-support/shared/posix_tty.c @@ -108,7 +108,7 @@ GetBaud (int baudrate) if (baudrate == 460800)
return B460800;
#endif
- return (0);
+ return 0;
}
int
@@ -122,7 +122,7 @@ xf86OpenSerial (pointer options) if (!dev)
{
xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n");
- return (-1);
+ return -1;
}
SYSCALL (fd = open (dev, O_RDWR | O_NONBLOCK));
@@ -132,14 +132,14 @@ xf86OpenSerial (pointer options) "xf86OpenSerial: Cannot open device %s\n\t%s.\n",
dev, strerror (errno));
free(dev);
- return (-1);
+ return -1;
}
if (!isatty (fd))
{
/* Allow non-tty devices to be opened. */
free(dev);
- return (fd);
+ return fd;
}
/* set up default port parameters */
@@ -162,7 +162,7 @@ xf86OpenSerial (pointer options) {
SYSCALL (close (fd));
free(dev);
- return (-1);
+ return -1;
}
SYSCALL (i = fcntl (fd, F_GETFL, 0));
@@ -170,7 +170,7 @@ xf86OpenSerial (pointer options) {
SYSCALL (close (fd));
free(dev);
- return (-1);
+ return -1;
}
i &= ~O_NONBLOCK;
SYSCALL (i = fcntl (fd, F_SETFL, i));
@@ -178,10 +178,10 @@ xf86OpenSerial (pointer options) {
SYSCALL (close (fd));
free(dev);
- return (-1);
+ return -1;
}
free(dev);
- return (fd);
+ return fd;
}
int
@@ -212,7 +212,7 @@ xf86SetSerial (int fd, pointer options) {
xf86Msg (X_ERROR,
"Invalid Option BaudRate value: %d\n", val);
- return (-1);
+ return -1;
}
}
@@ -229,7 +229,7 @@ xf86SetSerial (int fd, pointer options) default:
xf86Msg (X_ERROR,
"Invalid Option StopBits value: %d\n", val);
- return (-1);
+ return -1;
break;
}
}
@@ -257,7 +257,7 @@ xf86SetSerial (int fd, pointer options) default:
xf86Msg (X_ERROR,
"Invalid Option DataBits value: %d\n", val);
- return (-1);
+ return -1;
break;
}
}
@@ -281,7 +281,7 @@ xf86SetSerial (int fd, pointer options) {
xf86Msg (X_ERROR, "Invalid Option Parity value: %s\n",
s);
- return (-1);
+ return -1;
}
}
@@ -317,7 +317,7 @@ xf86SetSerial (int fd, pointer options) {
xf86Msg (X_ERROR,
"Invalid Option FlowControl value: %s\n", s);
- return (-1);
+ return -1;
}
}
@@ -333,7 +333,7 @@ xf86SetSerial (int fd, pointer options) #else
xf86Msg (X_WARNING,
"Option ClearDTR not supported on this OS\n");
- return (-1);
+ return -1;
#endif
xf86MarkOptionUsedByName (options, "ClearDTR");
}
@@ -342,12 +342,12 @@ xf86SetSerial (int fd, pointer options) {
xf86Msg (X_WARNING,
"Option ClearRTS not supported on this OS\n");
- return (-1);
+ return -1;
xf86MarkOptionUsedByName (options, "ClearRTS");
}
SYSCALL (r = tcsetattr (fd, TCSANOW, &t));
- return (r);
+ return r;
}
int
@@ -374,11 +374,11 @@ xf86SetSerialSpeed (int fd, int speed) {
xf86Msg (X_ERROR,
"Invalid Option BaudRate value: %d\n", speed);
- return (-1);
+ return -1;
}
SYSCALL (r = tcsetattr (fd, TCSANOW, &t));
- return (r);
+ return r;
}
int
@@ -393,7 +393,7 @@ xf86ReadSerial (int fd, void *buf, int count) for (i = 1; i < r; i++)
DebugF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i));
DebugF("\n");
- return (r);
+ return r;
}
int
@@ -407,7 +407,7 @@ xf86WriteSerial (int fd, const void *buf, int count) ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i));
DebugF("\n");
SYSCALL (r = write (fd, buf, count));
- return (r);
+ return r;
}
int
@@ -416,7 +416,7 @@ xf86CloseSerial (int fd) int r;
SYSCALL (r = close (fd));
- return (r);
+ return r;
}
int
@@ -442,7 +442,7 @@ xf86WaitForInput (int fd, int timeout) SYSCALL (r = select (FD_SETSIZE, NULL, NULL, NULL, &to));
}
xf86ErrorFVerb (9,"select returned %d\n", r);
- return (r);
+ return r;
}
int
@@ -451,7 +451,7 @@ xf86SerialSendBreak (int fd, int duration) int r;
SYSCALL (r = tcsendbreak (fd, duration));
- return (r);
+ return r;
}
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c b/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c index ee5c7c064..e297f8c49 100644 --- a/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c @@ -66,7 +66,7 @@ xf86VTAcquire(int sig) Bool
xf86VTSwitchPending(void)
{
- return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+ return xf86Info.vtRequestsPending ? TRUE : FALSE;
}
Bool
@@ -81,7 +81,7 @@ xf86VTSwitchAway(void) if (xf86VTPruneDoor) {
xf86VTPruneDoor = 0;
ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
- return (TRUE);
+ return TRUE;
}
vt_door_arg.vt_ev = VT_EV_HOTKEYS;
@@ -94,15 +94,15 @@ xf86VTSwitchAway(void) door_arg.desc_num = 0;
if ((door_fd = open(VT_DAEMON_DOOR_FILE, O_RDONLY)) < 0)
- return (FALSE);
+ return FALSE;
if (door_call(door_fd, &door_arg) != 0) {
close(door_fd);
- return (FALSE);
+ return FALSE;
}
close(door_fd);
- return (TRUE);
+ return TRUE;
}
Bool
@@ -111,11 +111,11 @@ xf86VTSwitchTo(void) xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
{
- return(FALSE);
+ return FALSE;
}
else
{
- return(TRUE);
+ return TRUE;
}
}
@@ -125,13 +125,13 @@ xf86VTActivate(int vtno) struct vt_stat state;
if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &state) < 0)
- return(FALSE);
+ return FALSE;
if ((state.v_state & (1 << vtno)) == 0)
- return(FALSE);
+ return FALSE;
xf86Info.vtRequestsPending = TRUE;
xf86Info.vtPendingNum = vtno;
- return(TRUE);
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_agp.c b/xorg-server/hw/xfree86/os-support/solaris/sun_agp.c index a5fb5c6e6..b85a3c86b 100644 --- a/xorg-server/hw/xfree86/os-support/solaris/sun_agp.c +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_agp.c @@ -78,7 +78,7 @@ static Bool GARTInit(int screenNum)
{
if (initDone)
- return (gartFd != -1);
+ return gartFd != -1;
if (gartFd == -1)
gartFd = open(AGP_DEVICE, O_RDWR);
@@ -115,16 +115,16 @@ xf86GetAGPInfo(int screenNum) if (!GARTInit(screenNum))
return NULL;
- if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
xf86DrvMsg(screenNum, X_ERROR,
- "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
+ "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
+ strerror(errno));
return NULL;
}
- if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
xf86DrvMsg(screenNum, X_ERROR,
- "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
- strerror(errno));
+ "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
return NULL;
}
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c b/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c index 05d17492a..e064c9733 100644 --- a/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c @@ -1,180 +1,180 @@ -/* Copyright 2004-2005 Sun Microsystems, 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 (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <sys/audio.h> -#include <sys/uio.h> -#include <limits.h> -#include <math.h> -#include <poll.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#define BELL_RATE 48000 /* Samples per second */ -#define BELL_HZ 50 /* Fraction of a second i.e. 1/x */ -#define BELL_MS (1000/BELL_HZ) /* MS */ -#define BELL_SAMPLES (BELL_RATE / BELL_HZ) -#define BELL_MIN 3 /* Min # of repeats */ - -#define AUDIO_DEVICE "/dev/audio" - -void -xf86OSRingBell(int loudness, int pitch, int duration) -{ - static short samples[BELL_SAMPLES]; - static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */ - static int lastFreq; - int cnt; - int i; - int written; - int repeats; - int freq; - audio_info_t audioInfo; - struct iovec iov[IOV_MAX]; - int iovcnt; - double ampl, cyclen, phase; - int audioFD; - - if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) { - return; - } - - lastFreq = 0; - bzero(silence, sizeof(silence)); - - audioFD = open(AUDIO_DEVICE, O_WRONLY | O_NONBLOCK); - if (audioFD == -1) { - xf86Msg(X_ERROR, "Bell: cannot open audio device \"%s\": %s\n", - AUDIO_DEVICE, strerror(errno)); - return; - } - - freq = pitch; - freq = min(freq, (BELL_RATE / 2) - 1); - freq = max(freq, 2 * BELL_HZ); - - /* - * Ensure full waves per buffer - */ - freq -= freq % BELL_HZ; - - if (freq != lastFreq) { - lastFreq = freq; - ampl = 16384.0; - - cyclen = (double) freq / (double) BELL_RATE; - phase = 0.0; - - for (i = 0; i < BELL_SAMPLES; i++) { - samples[i] = (short) (ampl * sin(2.0 * M_PI * phase)); - phase += cyclen; - if (phase >= 1.0) - phase -= 1.0; - } - } - - repeats = (duration + (BELL_MS / 2)) / BELL_MS; - repeats = max(repeats, BELL_MIN); - - loudness = max(0, loudness); - loudness = min(loudness, 100); - -#ifdef DEBUG - ErrorF("BELL : freq %d volume %d duration %d repeats %d\n", - freq, loudness, duration, repeats); -#endif - - AUDIO_INITINFO(&audioInfo); - audioInfo.play.encoding = AUDIO_ENCODING_LINEAR; - audioInfo.play.sample_rate = BELL_RATE; - audioInfo.play.channels = 2; - audioInfo.play.precision = 16; - audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100); - - if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){ - xf86Msg(X_ERROR, - "Bell: AUDIO_SETINFO failed on audio device \"%s\": %s\n", - AUDIO_DEVICE, strerror(errno)); - close(audioFD); - return; - } - - iovcnt = 0; - - for (cnt = 0; cnt <= repeats; cnt++) { - if (cnt == repeats) { - /* Insert a bit of silence so that multiple beeps are distinct and - * not compressed into a single tone. - */ - iov[iovcnt].iov_base = (char *) silence; - iov[iovcnt++].iov_len = sizeof(silence); - } else { - iov[iovcnt].iov_base = (char *) samples; - iov[iovcnt++].iov_len = sizeof(samples); - } - if ((iovcnt >= IOV_MAX) || (cnt == repeats)) { - written = writev(audioFD, iov, iovcnt); - - if ((written < ((int)(sizeof(samples) * iovcnt)))) { - /* audio buffer was full! */ - - int naptime; - - if (written == -1) { - if (errno != EAGAIN) { - xf86Msg(X_ERROR, - "Bell: writev failed on audio device \"%s\": %s\n", - AUDIO_DEVICE, strerror(errno)); - close(audioFD); - return; - } - i = iovcnt; - } else { - i = ((sizeof(samples) * iovcnt) - written) - / sizeof(samples); - } - cnt -= i; - - /* sleep a little to allow audio buffer to drain */ - naptime = BELL_MS * i; - poll(NULL, 0, naptime); - - i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples); - iovcnt = 0; - if ((written != -1) && (i > 0)) { - iov[iovcnt].iov_base = ((char *) samples) + i; - iov[iovcnt++].iov_len = sizeof(samples) - i; - } - } else { - iovcnt = 0; - } - } - } - - close(audioFD); - return; -} +/* Copyright 2004-2005 Sun Microsystems, 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 (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/audio.h>
+#include <sys/uio.h>
+#include <limits.h>
+#include <math.h>
+#include <poll.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#define BELL_RATE 48000 /* Samples per second */
+#define BELL_HZ 50 /* Fraction of a second i.e. 1/x */
+#define BELL_MS (1000/BELL_HZ) /* MS */
+#define BELL_SAMPLES (BELL_RATE / BELL_HZ)
+#define BELL_MIN 3 /* Min # of repeats */
+
+#define AUDIO_DEVICE "/dev/audio"
+
+void
+xf86OSRingBell(int loudness, int pitch, int duration)
+{
+ static short samples[BELL_SAMPLES];
+ static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */
+ static int lastFreq;
+ int cnt;
+ int i;
+ int written;
+ int repeats;
+ int freq;
+ audio_info_t audioInfo;
+ struct iovec iov[IOV_MAX];
+ int iovcnt;
+ double ampl, cyclen, phase;
+ int audioFD;
+
+ if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) {
+ return;
+ }
+
+ lastFreq = 0;
+ memset(silence, 0, sizeof(silence));
+
+ audioFD = open(AUDIO_DEVICE, O_WRONLY | O_NONBLOCK);
+ if (audioFD == -1) {
+ xf86Msg(X_ERROR, "Bell: cannot open audio device \"%s\": %s\n",
+ AUDIO_DEVICE, strerror(errno));
+ return;
+ }
+
+ freq = pitch;
+ freq = min(freq, (BELL_RATE / 2) - 1);
+ freq = max(freq, 2 * BELL_HZ);
+
+ /*
+ * Ensure full waves per buffer
+ */
+ freq -= freq % BELL_HZ;
+
+ if (freq != lastFreq) {
+ lastFreq = freq;
+ ampl = 16384.0;
+
+ cyclen = (double) freq / (double) BELL_RATE;
+ phase = 0.0;
+
+ for (i = 0; i < BELL_SAMPLES; i++) {
+ samples[i] = (short) (ampl * sin(2.0 * M_PI * phase));
+ phase += cyclen;
+ if (phase >= 1.0)
+ phase -= 1.0;
+ }
+ }
+
+ repeats = (duration + (BELL_MS / 2)) / BELL_MS;
+ repeats = max(repeats, BELL_MIN);
+
+ loudness = max(0, loudness);
+ loudness = min(loudness, 100);
+
+#ifdef DEBUG
+ ErrorF("BELL : freq %d volume %d duration %d repeats %d\n",
+ freq, loudness, duration, repeats);
+#endif
+
+ AUDIO_INITINFO(&audioInfo);
+ audioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
+ audioInfo.play.sample_rate = BELL_RATE;
+ audioInfo.play.channels = 2;
+ audioInfo.play.precision = 16;
+ audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100);
+
+ if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){
+ xf86Msg(X_ERROR,
+ "Bell: AUDIO_SETINFO failed on audio device \"%s\": %s\n",
+ AUDIO_DEVICE, strerror(errno));
+ close(audioFD);
+ return;
+ }
+
+ iovcnt = 0;
+
+ for (cnt = 0; cnt <= repeats; cnt++) {
+ if (cnt == repeats) {
+ /* Insert a bit of silence so that multiple beeps are distinct and
+ * not compressed into a single tone.
+ */
+ iov[iovcnt].iov_base = (char *) silence;
+ iov[iovcnt++].iov_len = sizeof(silence);
+ } else {
+ iov[iovcnt].iov_base = (char *) samples;
+ iov[iovcnt++].iov_len = sizeof(samples);
+ }
+ if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
+ written = writev(audioFD, iov, iovcnt);
+
+ if ((written < ((int)(sizeof(samples) * iovcnt)))) {
+ /* audio buffer was full! */
+
+ int naptime;
+
+ if (written == -1) {
+ if (errno != EAGAIN) {
+ xf86Msg(X_ERROR,
+ "Bell: writev failed on audio device \"%s\": %s\n",
+ AUDIO_DEVICE, strerror(errno));
+ close(audioFD);
+ return;
+ }
+ i = iovcnt;
+ } else {
+ i = ((sizeof(samples) * iovcnt) - written)
+ / sizeof(samples);
+ }
+ cnt -= i;
+
+ /* sleep a little to allow audio buffer to drain */
+ naptime = BELL_MS * i;
+ poll(NULL, 0, naptime);
+
+ i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples);
+ iovcnt = 0;
+ if ((written != -1) && (i > 0)) {
+ iov[iovcnt].iov_base = ((char *) samples) + i;
+ iov[iovcnt++].iov_len = sizeof(samples) - i;
+ }
+ } else {
+ iovcnt = 0;
+ }
+ }
+ }
+
+ close(audioFD);
+ return;
+}
diff --git a/xorg-server/hw/xfree86/os-support/sysv/sysv_init.c b/xorg-server/hw/xfree86/os-support/sysv/sysv_init.c index 170bb8914..3b94ac135 100644 --- a/xorg-server/hw/xfree86/os-support/sysv/sysv_init.c +++ b/xorg-server/hw/xfree86/os-support/sysv/sysv_init.c @@ -1,252 +1,252 @@ -/* - * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Thomas Roell and David Wexelblat - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. Thomas Roell and - * David Wexelblat makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -static Bool KeepTty = FALSE; -#ifdef SVR4 -static Bool Protect0 = FALSE; -#endif -static int VTnum = -1; - - -void -xf86OpenConsole() -{ - int fd; - struct vt_mode VT; - char vtname1[10],vtname2[10]; - MessageType from = X_PROBED; - - if (serverGeneration == 1) - { - /* check if we're run with euid==0 */ - if (geteuid() != 0) - { - FatalError("xf86OpenConsole: Server must be suid root\n"); - } - -#ifdef SVR4 - /* Protect page 0 to help find NULL dereferencing */ - /* mprotect() doesn't seem to work */ - if (Protect0) - { - int fd = -1; - - if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0) - { - xf86Msg(X_WARNING, - "xf86OpenConsole: cannot open /dev/zero (%s)\n", - strerror(errno)); - } - else - { - if ((int)mmap(0, 0x1000, PROT_NONE, - MAP_FIXED | MAP_SHARED, fd, 0) == -1) - { - xf86Msg(X_WARNING, - "xf86OpenConsole: failed to protect page 0 (%s)\n", - strerror(errno)); - } - close(fd); - } - } -#endif - /* - * setup the virtual terminal manager - */ - if (VTnum != -1) - { - xf86Info.vtno = VTnum; - from = X_CMDLINE; - } - else - { - if ((fd = open("/dev/console",O_WRONLY,0)) < 0) - { - FatalError( - "xf86OpenConsole: Cannot open /dev/console (%s)\n", - strerror(errno)); - } - if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || - (xf86Info.vtno == -1)) - { - FatalError("xf86OpenConsole: Cannot find a free VT\n"); - } - close(fd); - } - xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno); - - sprintf(vtname1,"/dev/vc%02d",xf86Info.vtno); /* ESIX */ - sprintf(vtname2,"/dev/vt%02d",xf86Info.vtno); /* rest of the world */ - - if (!KeepTty) - { - setpgrp(); - } - - if (((xf86Info.consoleFd = open(vtname1, O_RDWR|O_NDELAY, 0)) < 0) && - ((xf86Info.consoleFd = open(vtname2, O_RDWR|O_NDELAY, 0)) < 0)) - { - FatalError("xf86OpenConsole: Cannot open %s (%s) (%s)\n", - vtname2, vtname1, strerror(errno)); - } - - /* change ownership of the vt */ - if (chown(vtname1, getuid(), getgid()) < 0) - { - chown(vtname2, getuid(), getgid()); - } - - /* - * now get the VT - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) - { - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); - } - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) - { - xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); - } - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) - { - FatalError("xf86OpenConsole: VT_GETMODE failed\n"); - } - - signal(SIGUSR1, xf86VTRequest); - - VT.mode = VT_PROCESS; - VT.relsig = SIGUSR1; - VT.acqsig = SIGUSR1; - if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) - { - FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); - } - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) - { - FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n"); - } - } - else - { - /* serverGeneration != 1 */ - /* - * now get the VT - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) - { - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); - } - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) - { - xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); - } - /* - * If the server doesn't have the VT when the reset occurs, - * this is to make sure we don't continue until the activate - * signal is received. - */ - if (!xf86Screens[0]->vtSema) - sleep(5); - } - return; -} - -void -xf86CloseConsole() -{ - struct vt_mode VT; - -#if 0 - ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno); - ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0); -#endif - ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */ - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) - { - VT.mode = VT_AUTO; - ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */ - } - close(xf86Info.consoleFd); /* make the vt-manager happy */ - return; -} - -int -xf86ProcessArgument(int argc, char *argv[], int i) -{ - /* - * Keep server from detaching from controlling tty. This is useful - * when debugging (so the server can receive keyboard signals. - */ - if (!strcmp(argv[i], "-keeptty")) - { - KeepTty = TRUE; - return(1); - } -#ifdef SVR4 - /* - * Undocumented flag to protect page 0 from read/write to help - * catch NULL pointer dereferences. This is purely a debugging - * flag. - */ - if (!strcmp(argv[i], "-protect0")) - { - Protect0 = TRUE; - return(1); - } -#endif - if ((argv[i][0] == 'v') && (argv[i][1] == 't')) - { - if (sscanf(argv[i], "vt%2d", &VTnum) == 0) - { - UseMsg(); - VTnum = -1; - return(0); - } - return(1); - } - return(0); -} - -void -xf86UseMsg() -{ - ErrorF("vtXX use the specified VT number\n"); - ErrorF("-keeptty "); - ErrorF("don't detach controlling tty (for debugging only)\n"); - return; -} +/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Wexelblat makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+static Bool KeepTty = FALSE;
+#ifdef SVR4
+static Bool Protect0 = FALSE;
+#endif
+static int VTnum = -1;
+
+
+void
+xf86OpenConsole()
+{
+ int fd;
+ struct vt_mode VT;
+ char vtname1[10],vtname2[10];
+ MessageType from = X_PROBED;
+
+ if (serverGeneration == 1)
+ {
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+ }
+
+#ifdef SVR4
+ /* Protect page 0 to help find NULL dereferencing */
+ /* mprotect() doesn't seem to work */
+ if (Protect0)
+ {
+ int fd = -1;
+
+ if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ strerror(errno));
+ }
+ else
+ {
+ if ((int)mmap(0, 0x1000, PROT_NONE,
+ MAP_FIXED | MAP_SHARED, fd, 0) == -1)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: failed to protect page 0 (%s)\n",
+ strerror(errno));
+ }
+ close(fd);
+ }
+ }
+#endif
+ /*
+ * setup the virtual terminal manager
+ */
+ if (VTnum != -1)
+ {
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+ }
+ else
+ {
+ if ((fd = open("/dev/console",O_WRONLY,0)) < 0)
+ {
+ FatalError(
+ "xf86OpenConsole: Cannot open /dev/console (%s)\n",
+ strerror(errno));
+ }
+ if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+ (xf86Info.vtno == -1))
+ {
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ }
+ close(fd);
+ }
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+
+ sprintf(vtname1,"/dev/vc%02d",xf86Info.vtno); /* ESIX */
+ sprintf(vtname2,"/dev/vt%02d",xf86Info.vtno); /* rest of the world */
+
+ if (!KeepTty)
+ {
+ setpgrp();
+ }
+
+ if (((xf86Info.consoleFd = open(vtname1, O_RDWR|O_NDELAY, 0)) < 0) &&
+ ((xf86Info.consoleFd = open(vtname2, O_RDWR|O_NDELAY, 0)) < 0))
+ {
+ FatalError("xf86OpenConsole: Cannot open %s (%s) (%s)\n",
+ vtname2, vtname1, strerror(errno));
+ }
+
+ /* change ownership of the vt */
+ if (chown(vtname1, getuid(), getgid()) < 0)
+ {
+ chown(vtname2, getuid(), getgid());
+ }
+
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_GETMODE failed\n");
+ }
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ {
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
+ }
+ }
+ else
+ {
+ /* serverGeneration != 1 */
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+ /*
+ * If the server doesn't have the VT when the reset occurs,
+ * this is to make sure we don't continue until the activate
+ * signal is received.
+ */
+ if (!xf86Screens[0]->vtSema)
+ sleep(5);
+ }
+ return;
+}
+
+void
+xf86CloseConsole()
+{
+ struct vt_mode VT;
+
+#if 0
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno);
+ ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0);
+#endif
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+ }
+ close(xf86Info.consoleFd); /* make the vt-manager happy */
+ return;
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return 1;
+ }
+#ifdef SVR4
+ /*
+ * Undocumented flag to protect page 0 from read/write to help
+ * catch NULL pointer dereferences. This is purely a debugging
+ * flag.
+ */
+ if (!strcmp(argv[i], "-protect0"))
+ {
+ Protect0 = TRUE;
+ return 1;
+ }
+#endif
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+ {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+void
+xf86UseMsg()
+{
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ return;
+}
diff --git a/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c b/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c index 43c30621c..6d5948796 100644 --- a/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c +++ b/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c @@ -1,315 +1,315 @@ -/* - * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Thomas Roell and David Wexelblat - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. Thomas Roell and - * David Wexelblat makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#define _NEED_SYSI86 -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -#ifndef SI86IOPL -#define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL) -#define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0) -#else -#define SET_IOPL() sysi86(SI86IOPL,3) -#define RESET_IOPL() sysi86(SI86IOPL,0) -#endif - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -/* - * XXX Support for SVR3 will need to be reworked if needed. In particular - * the Region parameter is no longer passed, and will need to be dealt - * with internally if required. - * OK, i'll rework that thing ... (clean it up a lot) - * SVR3 Support only with SVR3_MMAPDRV (mr) - * - */ - -#ifdef HAS_SVR3_MMAPDRV -#ifndef MMAP_DEBUG -#define MMAP_DEBUG 3 -#endif - -struct kd_memloc MapDSC; -int mmapFd = -2; - -static int -mmapStat(pointer Base, unsigned long Size) { - - int nmmreg,i=0,region=-1; - mmapinfo_t *ibuf; - - nmmreg = ioctl(mmapFd, GETNMMREG); - - if(nmmreg <= 0) - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "\nNo physical memory mapped currently.\n\n"); - else { - if((ibuf = (mmapinfo_t *)malloc(nmmreg*sizeof(mmapinfo_t))) == NULL) - xf86Msg(X_WARNING, - "Couldn't allocate memory 4 mmapinfo_t\n"); - else { - if(ioctl(mmapFd, GETMMREG, ibuf) != -1) - { - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "# mmapStat: [Size=%x,Base=%x]\n", Size, Base); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "# Physical Address Size Reference Count\n"); - for(i = 0; i < nmmreg; i++) { - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "%-4d 0x%08X %5dk %5d ", - i, ibuf[i].physaddr, ibuf[i].length/1024, ibuf[i].refcnt); - if (ibuf[i].physaddr == Base || ibuf[i].length == Size ) { - xf86MsgVerb(X_INFO, MMAP_DEBUG,"MATCH !!!"); - if (region==-1) region=i; - } - xf86ErrorFVerb(MMAP_DEBUG, "\n"); - } - xf86ErrorFVerb(MMAP_DEBUG, "\n"); - } - free(ibuf); - } - } - if (region == -1 && nmmreg > 0) region=region * i; - return(region); -} -#endif - - -static Bool -linearVidMem() -{ -#ifdef SVR4 - return TRUE; -#elif defined(HAS_SVR3_MMAPDRV) - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "# xf86LinearVidMem: MMAP 2.2.2 called\n"); - - if(mmapFd >= 0) return TRUE; - - if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1) - { - if(ioctl(mmapFd, GETVERSION) < 0x0222) { - xf86Msg(X_WARNING, - "xf86LinearVidMem: MMAP 2.2.2 or above required\n"); - xf86ErrorF("\tlinear memory access disabled\n"); - return FALSE; - } - return TRUE; - } - xf86Msg(X_WARNING, "xf86LinearVidMem: failed to open /dev/mmap (%s)\n", - strerror(errno)); - xf86ErrorF("\tlinear memory access disabled\n"); - return FALSE; -#endif -} - -static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - pointer base; - int fd; - -#if defined(SVR4) - fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); - if (fd < 0) - { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t)0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_SHARED, fd, (off_t)Base); - close(fd); - if (base == MAP_FAILED) - { - FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", - "xf86MapVidMem", Size, Base, strerror(errno)); - } -#else /* SVR4 */ -#ifdef HAS_SVR3_MMAPDRV - - xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86MapVidMem: MMAP 2.2.2 called\n"); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION)); - if (ioctl(mmapFd, GETVERSION) == -1) - { - xf86LinearVidMem(); - } - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION)); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "xf86MapVidMem: Screen: %d\n", ScreenNum); - mmapStat(Base,Size); - /* To force the MMAP driver to provide the address */ - base = (pointer)0; - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "xf86MapVidMem: [s=%x,a=%x]\n", Size, Base); - MapDSC.vaddr = (char *)base; - MapDSC.physaddr = (char *)Base; - MapDSC.length = Size; - MapDSC.ioflg = 1; - if(mmapFd >= 0) - { - if((base = (pointer)ioctl(mmapFd, MAP, &MapDSC)) == (pointer)-1) - { - FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", - "xf86MapVidMem", Size, Base, strerror(errno)); - /* NOTREACHED */ - } - - /* Next time we want the same address! */ - MapDSC.vaddr = (char *)base; - } - - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "MapDSC.vaddr : 0x%x\n", MapDSC.vaddr); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "MapDSC.physaddr: 0x%x\n", MapDSC.physaddr); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "MapDSC.length : %d\n", MapDSC.length); - mmapStat(Base,Size); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "xf86MapVidMem: [s=%x,a=%x,b=%x]\n", Size, Base, base); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "xf86MapVidMem: SUCCEED Mapping FrameBuffer \n"); -#endif /* HAS_SVR3_MMAPDRV */ -#endif /* SVR4 */ - return(base); -} - -/* ARGSUSED */ -static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ -#if defined (SVR4) - munmap(Base, Size); -#else /* SVR4 */ -#ifdef HAS_SVR3_MMAPDRV - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "# xf86UnMapVidMem: UNMapping FrameBuffer\n"); - mmapStat(Base,Size); - ioctl(mmapFd, UNMAPRM , Base); - mmapStat(Base,Size); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "# xf86UnMapVidMem: Screen: %d [v=%x]\n", ScreenNum, Base); -#endif /* HAS_SVR3_MMAPDRV */ -#endif /* SVR4 */ - return; -} - -#if defined(SVR4) && defined(__i386__) && !defined(sun) -/* - * For some SVR4 versions, a 32-bit read is done for the first location - * in each page when the page is first mapped. If this is done while - * memory access is enabled for regions that have read side-effects, - * this can cause unexpected results, including lockups on some hardware. - * This function is called to make sure each page is mapped while it is - * safe to do so. - */ - -/* - * XXX Should get this the correct way (see os/xalloc.c), but since this is - * for one platform I'll be lazy. - */ -#define X_PAGE_SIZE 4096 - -static void -readSideEffects(int ScreenNum, pointer Base, unsigned long Size) -{ - unsigned long base, end, addr; - CARD32 val; - - base = (unsigned long)Base; - end = base + Size; - - for (addr = base; addr < end; addr += X_PAGE_SIZE) - val = *(volatile CARD32 *)addr; -} -#endif - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - pVidMem->linearSupported = linearVidMem(); - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; -#if defined(SVR4) && defined(__i386__) && !defined(sun) - pVidMem->readSideEffects = readSideEffects; -#endif - pVidMem->initialised = TRUE; -} - -/***************************************************************************/ -/* I/O Permissions section */ -/***************************************************************************/ - -static Bool ExtendedEnabled = FALSE; -static Bool InitDone = FALSE; - -Bool -xf86EnableIO() -{ - int i; - - if (ExtendedEnabled) - return TRUE; - - if (SET_IOPL() < 0) - { - xf86Msg(X_WARNING, - "xf86EnableIO: Failed to set IOPL for extended I/O\n"); - return FALSE; - } - ExtendedEnabled = TRUE; - - return TRUE; -} - -void -xf86DisableIO() -{ - if (!ExtendedEnabled) - return; - - RESET_IOPL(); - ExtendedEnabled = FALSE; - - return; -} +/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Wexelblat makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#define _NEED_SYSI86
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#ifndef SI86IOPL
+#define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL)
+#define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0)
+#else
+#define SET_IOPL() sysi86(SI86IOPL,3)
+#define RESET_IOPL() sysi86(SI86IOPL,0)
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+/*
+ * XXX Support for SVR3 will need to be reworked if needed. In particular
+ * the Region parameter is no longer passed, and will need to be dealt
+ * with internally if required.
+ * OK, i'll rework that thing ... (clean it up a lot)
+ * SVR3 Support only with SVR3_MMAPDRV (mr)
+ *
+ */
+
+#ifdef HAS_SVR3_MMAPDRV
+#ifndef MMAP_DEBUG
+#define MMAP_DEBUG 3
+#endif
+
+struct kd_memloc MapDSC;
+int mmapFd = -2;
+
+static int
+mmapStat(pointer Base, unsigned long Size) {
+
+ int nmmreg,i=0,region=-1;
+ mmapinfo_t *ibuf;
+
+ nmmreg = ioctl(mmapFd, GETNMMREG);
+
+ if(nmmreg <= 0)
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "\nNo physical memory mapped currently.\n\n");
+ else {
+ if((ibuf = (mmapinfo_t *)malloc(nmmreg*sizeof(mmapinfo_t))) == NULL)
+ xf86Msg(X_WARNING,
+ "Couldn't allocate memory 4 mmapinfo_t\n");
+ else {
+ if(ioctl(mmapFd, GETMMREG, ibuf) != -1)
+ {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# mmapStat: [Size=%x,Base=%x]\n", Size, Base);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# Physical Address Size Reference Count\n");
+ for(i = 0; i < nmmreg; i++) {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "%-4d 0x%08X %5dk %5d ",
+ i, ibuf[i].physaddr, ibuf[i].length/1024, ibuf[i].refcnt);
+ if (ibuf[i].physaddr == Base || ibuf[i].length == Size ) {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,"MATCH !!!");
+ if (region==-1) region=i;
+ }
+ xf86ErrorFVerb(MMAP_DEBUG, "\n");
+ }
+ xf86ErrorFVerb(MMAP_DEBUG, "\n");
+ }
+ free(ibuf);
+ }
+ }
+ if (region == -1 && nmmreg > 0) region=region * i;
+ return region;
+}
+#endif
+
+
+static Bool
+linearVidMem()
+{
+#ifdef SVR4
+ return TRUE;
+#elif defined(HAS_SVR3_MMAPDRV)
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86LinearVidMem: MMAP 2.2.2 called\n");
+
+ if(mmapFd >= 0) return TRUE;
+
+ if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1)
+ {
+ if(ioctl(mmapFd, GETVERSION) < 0x0222) {
+ xf86Msg(X_WARNING,
+ "xf86LinearVidMem: MMAP 2.2.2 or above required\n");
+ xf86ErrorF("\tlinear memory access disabled\n");
+ return FALSE;
+ }
+ return TRUE;
+ }
+ xf86Msg(X_WARNING, "xf86LinearVidMem: failed to open /dev/mmap (%s)\n",
+ strerror(errno));
+ xf86ErrorF("\tlinear memory access disabled\n");
+ return FALSE;
+#endif
+}
+
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+ int fd;
+
+#if defined(SVR4)
+ fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+ if (fd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, fd, (off_t)Base);
+ close(fd);
+ if (base == MAP_FAILED)
+ {
+ FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ }
+#else /* SVR4 */
+#ifdef HAS_SVR3_MMAPDRV
+
+ xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86MapVidMem: MMAP 2.2.2 called\n");
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION));
+ if (ioctl(mmapFd, GETVERSION) == -1)
+ {
+ xf86LinearVidMem();
+ }
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION));
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: Screen: %d\n", ScreenNum);
+ mmapStat(Base,Size);
+ /* To force the MMAP driver to provide the address */
+ base = (pointer)0;
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: [s=%x,a=%x]\n", Size, Base);
+ MapDSC.vaddr = (char *)base;
+ MapDSC.physaddr = (char *)Base;
+ MapDSC.length = Size;
+ MapDSC.ioflg = 1;
+ if(mmapFd >= 0)
+ {
+ if((base = (pointer)ioctl(mmapFd, MAP, &MapDSC)) == (pointer)-1)
+ {
+ FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ /* NOTREACHED */
+ }
+
+ /* Next time we want the same address! */
+ MapDSC.vaddr = (char *)base;
+ }
+
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.vaddr : 0x%x\n", MapDSC.vaddr);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.physaddr: 0x%x\n", MapDSC.physaddr);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.length : %d\n", MapDSC.length);
+ mmapStat(Base,Size);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: [s=%x,a=%x,b=%x]\n", Size, Base, base);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: SUCCEED Mapping FrameBuffer \n");
+#endif /* HAS_SVR3_MMAPDRV */
+#endif /* SVR4 */
+ return base;
+}
+
+/* ARGSUSED */
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+#if defined (SVR4)
+ munmap(Base, Size);
+#else /* SVR4 */
+#ifdef HAS_SVR3_MMAPDRV
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86UnMapVidMem: UNMapping FrameBuffer\n");
+ mmapStat(Base,Size);
+ ioctl(mmapFd, UNMAPRM , Base);
+ mmapStat(Base,Size);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86UnMapVidMem: Screen: %d [v=%x]\n", ScreenNum, Base);
+#endif /* HAS_SVR3_MMAPDRV */
+#endif /* SVR4 */
+ return;
+}
+
+#if defined(SVR4) && defined(__i386__) && !defined(sun)
+/*
+ * For some SVR4 versions, a 32-bit read is done for the first location
+ * in each page when the page is first mapped. If this is done while
+ * memory access is enabled for regions that have read side-effects,
+ * this can cause unexpected results, including lockups on some hardware.
+ * This function is called to make sure each page is mapped while it is
+ * safe to do so.
+ */
+
+/*
+ * XXX Should get this the correct way (see os/xalloc.c), but since this is
+ * for one platform I'll be lazy.
+ */
+#define X_PAGE_SIZE 4096
+
+static void
+readSideEffects(int ScreenNum, pointer Base, unsigned long Size)
+{
+ unsigned long base, end, addr;
+ CARD32 val;
+
+ base = (unsigned long)Base;
+ end = base + Size;
+
+ for (addr = base; addr < end; addr += X_PAGE_SIZE)
+ val = *(volatile CARD32 *)addr;
+}
+#endif
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = linearVidMem();
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+#if defined(SVR4) && defined(__i386__) && !defined(sun)
+ pVidMem->readSideEffects = readSideEffects;
+#endif
+ pVidMem->initialised = TRUE;
+}
+
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+static Bool ExtendedEnabled = FALSE;
+static Bool InitDone = FALSE;
+
+Bool
+xf86EnableIO()
+{
+ int i;
+
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if (SET_IOPL() < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86EnableIO: Failed to set IOPL for extended I/O\n");
+ return FALSE;
+ }
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ if (!ExtendedEnabled)
+ return;
+
+ RESET_IOPL();
+ ExtendedEnabled = FALSE;
+
+ return;
+}
diff --git a/xorg-server/hw/xfree86/parser/Configint.h b/xorg-server/hw/xfree86/parser/Configint.h index 03509b397..63e510d8f 100644 --- a/xorg-server/hw/xfree86/parser/Configint.h +++ b/xorg-server/hw/xfree86/parser/Configint.h @@ -1,222 +1,222 @@ -/* - * - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2002 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* - * These definitions are used through out the configuration file parser, but - * they should not be visible outside of the parser. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _Configint_h_ -#define _Configint_h_ - -#include <stdio.h> -#include <string.h> -#include <stdarg.h> -#include <stddef.h> -#include "xf86Parser.h" - -typedef enum { PARSE_DECIMAL, PARSE_OCTAL, PARSE_HEX } ParserNumType; - -typedef struct -{ - int num; /* returned number */ - char *str; /* private copy of the return-string */ - double realnum; /* returned number as a real */ - ParserNumType numType; /* used to enforce correct number formatting */ -} -LexRec, *LexPtr; - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#include "configProcs.h" -#include <stdlib.h> - -#define TestFree(a) if (a) { free (a); a = NULL; } - -#define parsePrologue(typeptr,typerec) typeptr ptr; \ -if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return NULL; } - -#define parsePrologueVoid(typeptr,typerec) int token; typeptr ptr; \ -if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return; } - -#define HANDLE_RETURN(f,func)\ -if ((ptr->f=func) == NULL)\ -{\ - CLEANUP (ptr);\ - return (NULL);\ -} - -#define HANDLE_LIST(field,func,type)\ -{\ -type p = func ();\ -if (p == NULL)\ -{\ - CLEANUP (ptr);\ - return (NULL);\ -}\ -else\ -{\ - ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\ -}\ -} - -#define Error(a,b) do { \ - xf86parseError (a, b); CLEANUP (ptr); return NULL; \ - } while (0) - -/* - * These are defines for error messages to promote consistency. - * error messages are preceded by the line number, section and file name, - * so these messages should be about the specific keyword and syntax in error. - * To help limit namespace polution, end each with _MSG. - * limit messages to 70 characters if possible. - */ - -#define BAD_OPTION_MSG \ -"The Option keyword requires 1 or 2 quoted strings to follow it." -#define INVALID_KEYWORD_MSG \ -"\"%s\" is not a valid keyword in this section." -#define INVALID_SECTION_MSG \ -"\"%s\" is not a valid section name." -#define UNEXPECTED_EOF_MSG \ -"Unexpected EOF. Missing EndSection keyword?" -#define QUOTE_MSG \ -"The %s keyword requires a quoted string to follow it." -#define NUMBER_MSG \ -"The %s keyword requires a number to follow it." -#define POSITIVE_INT_MSG \ -"The %s keyword requires a positive integer to follow it." -#define BOOL_MSG \ -"The %s keyword requires a boolean to follow it." -#define ZAXISMAPPING_MSG \ -"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it." -#define AUTOREPEAT_MSG \ -"The AutoRepeat keyword requires 2 numbers (delay and rate) to follow it." -#define XLEDS_MSG \ -"The XLeds keyword requries one or more numbers to follow it." -#define DACSPEED_MSG \ -"The DacSpeed keyword must be followed by a list of up to %d numbers." -#define DISPLAYSIZE_MSG \ -"The DisplaySize keyword must be followed by the width and height in mm." -#define HORIZSYNC_MSG \ -"The HorizSync keyword must be followed by a list of numbers or ranges." -#define VERTREFRESH_MSG \ -"The VertRefresh keyword must be followed by a list of numbers or ranges." -#define VIEWPORT_MSG \ -"The Viewport keyword must be followed by an X and Y value." -#define VIRTUAL_MSG \ -"The Virtual keyword must be followed by a width and height value." -#define WEIGHT_MSG \ -"The Weight keyword must be followed by red, green and blue values." -#define BLACK_MSG \ -"The Black keyword must be followed by red, green and blue values." -#define WHITE_MSG \ -"The White keyword must be followed by red, green and blue values." -#define SCREEN_MSG \ -"The Screen keyword must be followed by an optional number, a screen name\n" \ -"\tin quotes, and optional position/layout information." -#define INVALID_SCR_MSG \ -"Invalid Screen line." -#define INPUTDEV_MSG \ -"The InputDevice keyword must be followed by an input device name in quotes." -#define INACTIVE_MSG \ -"The Inactive keyword must be followed by a Device name in quotes." -#define UNDEFINED_SCREEN_MSG \ -"Undefined Screen \"%s\" referenced by ServerLayout \"%s\"." -#define UNDEFINED_MODES_MSG \ -"Undefined Modes Section \"%s\" referenced by Monitor \"%s\"." -#define UNDEFINED_DEVICE_MSG \ -"Undefined Device \"%s\" referenced by Screen \"%s\"." -#define UNDEFINED_ADAPTOR_MSG \ -"Undefined VideoAdaptor \"%s\" referenced by Screen \"%s\"." -#define ADAPTOR_REF_TWICE_MSG \ -"VideoAdaptor \"%s\" already referenced by Screen \"%s\"." -#define UNDEFINED_DEVICE_LAY_MSG \ -"Undefined Device \"%s\" referenced by ServerLayout \"%s\"." -#define UNDEFINED_INPUT_MSG \ -"Undefined InputDevice \"%s\" referenced by ServerLayout \"%s\"." -#define NO_IDENT_MSG \ -"This section must have an Identifier line." -#define ONLY_ONE_MSG \ -"This section must have only one of either %s line." -#define UNDEFINED_INPUTDRIVER_MSG \ -"InputDevice section \"%s\" must have a Driver line." -#define INVALID_GAMMA_MSG \ -"gamma correction value(s) expected\n either one value or three r/g/b values." -#define GROUP_MSG \ -"The Group keyword must be followed by either a group name in quotes or\n" \ -"\ta numerical group id." -#define MULTIPLE_MSG \ -"Multiple \"%s\" lines." -#define MUST_BE_OCTAL_MSG \ -"The number \"%d\" given in this section must be in octal (0xxx) format." - -/* Warning messages */ -#define OBSOLETE_MSG \ -"Ignoring obsolete keyword \"%s\"." -#define MOVED_TO_FLAGS_MSG \ -"Keyword \"%s\" is now an Option flag in the ServerFlags section." - -#endif /* _Configint_h_ */ +/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2002 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/*
+ * These definitions are used through out the configuration file parser, but
+ * they should not be visible outside of the parser.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _Configint_h_
+#define _Configint_h_
+
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include "xf86Parser.h"
+
+typedef enum { PARSE_DECIMAL, PARSE_OCTAL, PARSE_HEX } ParserNumType;
+
+typedef struct
+{
+ int num; /* returned number */
+ char *str; /* private copy of the return-string */
+ double realnum; /* returned number as a real */
+ ParserNumType numType; /* used to enforce correct number formatting */
+}
+LexRec, *LexPtr;
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#include "configProcs.h"
+#include <stdlib.h>
+
+#define TestFree(a) if (a) { free (a); a = NULL; }
+
+#define parsePrologue(typeptr,typerec) typeptr ptr; \
+if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return NULL; }
+
+#define parsePrologueVoid(typeptr,typerec) int token; typeptr ptr; \
+if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return; }
+
+#define HANDLE_RETURN(f,func)\
+if ((ptr->f=func) == NULL)\
+{\
+ CLEANUP (ptr);\
+ return NULL;\
+}
+
+#define HANDLE_LIST(field,func,type)\
+{\
+type p = func ();\
+if (p == NULL)\
+{\
+ CLEANUP (ptr);\
+ return NULL;\
+}\
+else\
+{\
+ ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\
+}\
+}
+
+#define Error(a,b) do { \
+ xf86parseError (a, b); CLEANUP (ptr); return NULL; \
+ } while (0)
+
+/*
+ * These are defines for error messages to promote consistency.
+ * error messages are preceded by the line number, section and file name,
+ * so these messages should be about the specific keyword and syntax in error.
+ * To help limit namespace polution, end each with _MSG.
+ * limit messages to 70 characters if possible.
+ */
+
+#define BAD_OPTION_MSG \
+"The Option keyword requires 1 or 2 quoted strings to follow it."
+#define INVALID_KEYWORD_MSG \
+"\"%s\" is not a valid keyword in this section."
+#define INVALID_SECTION_MSG \
+"\"%s\" is not a valid section name."
+#define UNEXPECTED_EOF_MSG \
+"Unexpected EOF. Missing EndSection keyword?"
+#define QUOTE_MSG \
+"The %s keyword requires a quoted string to follow it."
+#define NUMBER_MSG \
+"The %s keyword requires a number to follow it."
+#define POSITIVE_INT_MSG \
+"The %s keyword requires a positive integer to follow it."
+#define BOOL_MSG \
+"The %s keyword requires a boolean to follow it."
+#define ZAXISMAPPING_MSG \
+"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it."
+#define AUTOREPEAT_MSG \
+"The AutoRepeat keyword requires 2 numbers (delay and rate) to follow it."
+#define XLEDS_MSG \
+"The XLeds keyword requries one or more numbers to follow it."
+#define DACSPEED_MSG \
+"The DacSpeed keyword must be followed by a list of up to %d numbers."
+#define DISPLAYSIZE_MSG \
+"The DisplaySize keyword must be followed by the width and height in mm."
+#define HORIZSYNC_MSG \
+"The HorizSync keyword must be followed by a list of numbers or ranges."
+#define VERTREFRESH_MSG \
+"The VertRefresh keyword must be followed by a list of numbers or ranges."
+#define VIEWPORT_MSG \
+"The Viewport keyword must be followed by an X and Y value."
+#define VIRTUAL_MSG \
+"The Virtual keyword must be followed by a width and height value."
+#define WEIGHT_MSG \
+"The Weight keyword must be followed by red, green and blue values."
+#define BLACK_MSG \
+"The Black keyword must be followed by red, green and blue values."
+#define WHITE_MSG \
+"The White keyword must be followed by red, green and blue values."
+#define SCREEN_MSG \
+"The Screen keyword must be followed by an optional number, a screen name\n" \
+"\tin quotes, and optional position/layout information."
+#define INVALID_SCR_MSG \
+"Invalid Screen line."
+#define INPUTDEV_MSG \
+"The InputDevice keyword must be followed by an input device name in quotes."
+#define INACTIVE_MSG \
+"The Inactive keyword must be followed by a Device name in quotes."
+#define UNDEFINED_SCREEN_MSG \
+"Undefined Screen \"%s\" referenced by ServerLayout \"%s\"."
+#define UNDEFINED_MODES_MSG \
+"Undefined Modes Section \"%s\" referenced by Monitor \"%s\"."
+#define UNDEFINED_DEVICE_MSG \
+"Undefined Device \"%s\" referenced by Screen \"%s\"."
+#define UNDEFINED_ADAPTOR_MSG \
+"Undefined VideoAdaptor \"%s\" referenced by Screen \"%s\"."
+#define ADAPTOR_REF_TWICE_MSG \
+"VideoAdaptor \"%s\" already referenced by Screen \"%s\"."
+#define UNDEFINED_DEVICE_LAY_MSG \
+"Undefined Device \"%s\" referenced by ServerLayout \"%s\"."
+#define UNDEFINED_INPUT_MSG \
+"Undefined InputDevice \"%s\" referenced by ServerLayout \"%s\"."
+#define NO_IDENT_MSG \
+"This section must have an Identifier line."
+#define ONLY_ONE_MSG \
+"This section must have only one of either %s line."
+#define UNDEFINED_INPUTDRIVER_MSG \
+"InputDevice section \"%s\" must have a Driver line."
+#define INVALID_GAMMA_MSG \
+"gamma correction value(s) expected\n either one value or three r/g/b values."
+#define GROUP_MSG \
+"The Group keyword must be followed by either a group name in quotes or\n" \
+"\ta numerical group id."
+#define MULTIPLE_MSG \
+"Multiple \"%s\" lines."
+#define MUST_BE_OCTAL_MSG \
+"The number \"%d\" given in this section must be in octal (0xxx) format."
+
+/* Warning messages */
+#define OBSOLETE_MSG \
+"Ignoring obsolete keyword \"%s\"."
+#define MOVED_TO_FLAGS_MSG \
+"Keyword \"%s\" is now an Option flag in the ServerFlags section."
+
+#endif /* _Configint_h_ */
diff --git a/xorg-server/hw/xfree86/parser/Device.c b/xorg-server/hw/xfree86/parser/Device.c index 47ece07de..c81aa05d9 100644 --- a/xorg-server/hw/xfree86/parser/Device.c +++ b/xorg-server/hw/xfree86/parser/Device.c @@ -1,371 +1,371 @@ -/* - * - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* View/edit this file with tab stops set to 4 */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86Parser.h" -#include "xf86tokens.h" -#include "Configint.h" - -extern LexRec val; - -static -xf86ConfigSymTabRec DeviceTab[] = -{ - {ENDSECTION, "endsection"}, - {IDENTIFIER, "identifier"}, - {VENDOR, "vendorname"}, - {BOARD, "boardname"}, - {CHIPSET, "chipset"}, - {RAMDAC, "ramdac"}, - {DACSPEED, "dacspeed"}, - {CLOCKS, "clocks"}, - {OPTION, "option"}, - {VIDEORAM, "videoram"}, - {BIOSBASE, "biosbase"}, - {MEMBASE, "membase"}, - {IOBASE, "iobase"}, - {CLOCKCHIP, "clockchip"}, - {CHIPID, "chipid"}, - {CHIPREV, "chiprev"}, - {CARD, "card"}, - {DRIVER, "driver"}, - {BUSID, "busid"}, - {TEXTCLOCKFRQ, "textclockfreq"}, - {IRQ, "irq"}, - {SCREEN, "screen"}, - {-1, ""}, -}; - -#define CLEANUP xf86freeDeviceList - -XF86ConfDevicePtr -xf86parseDeviceSection (void) -{ - int i; - int has_ident = FALSE; - int token; - parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec) - - /* Zero is a valid value for these */ - ptr->dev_chipid = -1; - ptr->dev_chiprev = -1; - ptr->dev_irq = -1; - while ((token = xf86getToken (DeviceTab)) != ENDSECTION) - { - switch (token) - { - case COMMENT: - ptr->dev_comment = xf86addComment(ptr->dev_comment, val.str); - break; - case IDENTIFIER: - if (xf86getSubToken (&(ptr->dev_comment)) != STRING) - Error (QUOTE_MSG, "Identifier"); - if (has_ident == TRUE) - Error (MULTIPLE_MSG, "Identifier"); - ptr->dev_identifier = val.str; - has_ident = TRUE; - break; - case VENDOR: - if (xf86getSubToken (&(ptr->dev_comment)) != STRING) - Error (QUOTE_MSG, "Vendor"); - ptr->dev_vendor = val.str; - break; - case BOARD: - if (xf86getSubToken (&(ptr->dev_comment)) != STRING) - Error (QUOTE_MSG, "Board"); - ptr->dev_board = val.str; - break; - case CHIPSET: - if (xf86getSubToken (&(ptr->dev_comment)) != STRING) - Error (QUOTE_MSG, "Chipset"); - ptr->dev_chipset = val.str; - break; - case CARD: - if (xf86getSubToken (&(ptr->dev_comment)) != STRING) - Error (QUOTE_MSG, "Card"); - ptr->dev_card = val.str; - break; - case DRIVER: - if (xf86getSubToken (&(ptr->dev_comment)) != STRING) - Error (QUOTE_MSG, "Driver"); - ptr->dev_driver = val.str; - break; - case RAMDAC: - if (xf86getSubToken (&(ptr->dev_comment)) != STRING) - Error (QUOTE_MSG, "Ramdac"); - ptr->dev_ramdac = val.str; - break; - case DACSPEED: - for (i = 0; i < CONF_MAXDACSPEEDS; i++) - ptr->dev_dacSpeeds[i] = 0; - if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) - { - Error (DACSPEED_MSG, CONF_MAXDACSPEEDS); - } - else - { - ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5); - for (i = 1; i < CONF_MAXDACSPEEDS; i++) - { - if (xf86getSubToken (&(ptr->dev_comment)) == NUMBER) - ptr->dev_dacSpeeds[i] = (int) - (val.realnum * 1000.0 + 0.5); - else - { - xf86unGetToken (token); - break; - } - } - } - break; - case VIDEORAM: - if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) - Error (NUMBER_MSG, "VideoRam"); - ptr->dev_videoram = val.num; - break; - case BIOSBASE: - if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) - Error (NUMBER_MSG, "BIOSBase"); - ptr->dev_bios_base = val.num; - break; - case MEMBASE: - if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) - Error (NUMBER_MSG, "MemBase"); - ptr->dev_mem_base = val.num; - break; - case IOBASE: - if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) - Error (NUMBER_MSG, "IOBase"); - ptr->dev_io_base = val.num; - break; - case CLOCKCHIP: - if (xf86getSubToken (&(ptr->dev_comment)) != STRING) - Error (QUOTE_MSG, "ClockChip"); - ptr->dev_clockchip = val.str; - break; - case CHIPID: - if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) - Error (NUMBER_MSG, "ChipID"); - ptr->dev_chipid = val.num; - break; - case CHIPREV: - if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) - Error (NUMBER_MSG, "ChipRev"); - ptr->dev_chiprev = val.num; - break; - - case CLOCKS: - token = xf86getSubToken(&(ptr->dev_comment)); - for( i = ptr->dev_clocks; - token == NUMBER && i < CONF_MAXCLOCKS; i++ ) { - ptr->dev_clock[i] = (int)(val.realnum * 1000.0 + 0.5); - token = xf86getSubToken(&(ptr->dev_comment)); - } - ptr->dev_clocks = i; - xf86unGetToken (token); - break; - case TEXTCLOCKFRQ: - if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER) - Error (NUMBER_MSG, "TextClockFreq"); - ptr->dev_textclockfreq = (int)(val.realnum * 1000.0 + 0.5); - break; - case OPTION: - ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst); - break; - case BUSID: - if (xf86getSubToken (&(ptr->dev_comment)) != STRING) - Error (QUOTE_MSG, "BusID"); - ptr->dev_busid = val.str; - break; - case IRQ: - if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) - Error (QUOTE_MSG, "IRQ"); - ptr->dev_irq = val.num; - break; - case SCREEN: - if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) - Error (NUMBER_MSG, "Screen"); - ptr->dev_screen = val.num; - break; - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error (INVALID_KEYWORD_MSG, xf86tokenString ()); - break; - } - } - - if (!has_ident) - Error (NO_IDENT_MSG, NULL); - -#ifdef DEBUG - printf ("Device section parsed\n"); -#endif - - return ptr; -} - -#undef CLEANUP - -void -xf86printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr) -{ - int i; - - while (ptr) - { - fprintf (cf, "Section \"Device\"\n"); - if (ptr->dev_comment) - fprintf (cf, "%s", ptr->dev_comment); - if (ptr->dev_identifier) - fprintf (cf, "\tIdentifier \"%s\"\n", ptr->dev_identifier); - if (ptr->dev_driver) - fprintf (cf, "\tDriver \"%s\"\n", ptr->dev_driver); - if (ptr->dev_vendor) - fprintf (cf, "\tVendorName \"%s\"\n", ptr->dev_vendor); - if (ptr->dev_board) - fprintf (cf, "\tBoardName \"%s\"\n", ptr->dev_board); - if (ptr->dev_chipset) - fprintf (cf, "\tChipSet \"%s\"\n", ptr->dev_chipset); - if (ptr->dev_card) - fprintf (cf, "\tCard \"%s\"\n", ptr->dev_card); - if (ptr->dev_ramdac) - fprintf (cf, "\tRamDac \"%s\"\n", ptr->dev_ramdac); - if (ptr->dev_dacSpeeds[0] > 0 ) { - fprintf (cf, "\tDacSpeed "); - for (i = 0; i < CONF_MAXDACSPEEDS - && ptr->dev_dacSpeeds[i] > 0; i++ ) - fprintf (cf, "%g ", (double) (ptr->dev_dacSpeeds[i])/ 1000.0 ); - fprintf (cf, "\n"); - } - if (ptr->dev_videoram) - fprintf (cf, "\tVideoRam %d\n", ptr->dev_videoram); - if (ptr->dev_bios_base) - fprintf (cf, "\tBiosBase 0x%lx\n", ptr->dev_bios_base); - if (ptr->dev_mem_base) - fprintf (cf, "\tMemBase 0x%lx\n", ptr->dev_mem_base); - if (ptr->dev_io_base) - fprintf (cf, "\tIOBase 0x%lx\n", ptr->dev_io_base); - if (ptr->dev_clockchip) - fprintf (cf, "\tClockChip \"%s\"\n", ptr->dev_clockchip); - if (ptr->dev_chipid != -1) - fprintf (cf, "\tChipId 0x%x\n", ptr->dev_chipid); - if (ptr->dev_chiprev != -1) - fprintf (cf, "\tChipRev 0x%x\n", ptr->dev_chiprev); - - xf86printOptionList(cf, ptr->dev_option_lst, 1); - if (ptr->dev_clocks > 0 ) { - fprintf (cf, "\tClocks "); - for (i = 0; i < ptr->dev_clocks; i++ ) - fprintf (cf, "%.1f ", (double)ptr->dev_clock[i] / 1000.0 ); - fprintf (cf, "\n"); - } - if (ptr->dev_textclockfreq) { - fprintf (cf, "\tTextClockFreq %.1f\n", - (double)ptr->dev_textclockfreq / 1000.0); - } - if (ptr->dev_busid) - fprintf (cf, "\tBusID \"%s\"\n", ptr->dev_busid); - if (ptr->dev_screen > 0) - fprintf (cf, "\tScreen %d\n", ptr->dev_screen); - if (ptr->dev_irq >= 0) - fprintf (cf, "\tIRQ %d\n", ptr->dev_irq); - fprintf (cf, "EndSection\n\n"); - ptr = ptr->list.next; - } -} - -void -xf86freeDeviceList (XF86ConfDevicePtr ptr) -{ - XF86ConfDevicePtr prev; - - while (ptr) - { - TestFree (ptr->dev_identifier); - TestFree (ptr->dev_vendor); - TestFree (ptr->dev_board); - TestFree (ptr->dev_chipset); - TestFree (ptr->dev_card); - TestFree (ptr->dev_driver); - TestFree (ptr->dev_ramdac); - TestFree (ptr->dev_clockchip); - TestFree (ptr->dev_comment); - xf86optionListFree (ptr->dev_option_lst); - - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -XF86ConfDevicePtr -xf86findDevice (const char *ident, XF86ConfDevicePtr p) -{ - while (p) - { - if (xf86nameCompare (ident, p->dev_identifier) == 0) - return (p); - - p = p->list.next; - } - return (NULL); -} +/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static
+xf86ConfigSymTabRec DeviceTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {BOARD, "boardname"},
+ {CHIPSET, "chipset"},
+ {RAMDAC, "ramdac"},
+ {DACSPEED, "dacspeed"},
+ {CLOCKS, "clocks"},
+ {OPTION, "option"},
+ {VIDEORAM, "videoram"},
+ {BIOSBASE, "biosbase"},
+ {MEMBASE, "membase"},
+ {IOBASE, "iobase"},
+ {CLOCKCHIP, "clockchip"},
+ {CHIPID, "chipid"},
+ {CHIPREV, "chiprev"},
+ {CARD, "card"},
+ {DRIVER, "driver"},
+ {BUSID, "busid"},
+ {TEXTCLOCKFRQ, "textclockfreq"},
+ {IRQ, "irq"},
+ {SCREEN, "screen"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeDeviceList
+
+XF86ConfDevicePtr
+xf86parseDeviceSection (void)
+{
+ int i;
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
+
+ /* Zero is a valid value for these */
+ ptr->dev_chipid = -1;
+ ptr->dev_chiprev = -1;
+ ptr->dev_irq = -1;
+ while ((token = xf86getToken (DeviceTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->dev_comment = xf86addComment(ptr->dev_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->dev_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Vendor");
+ ptr->dev_vendor = val.str;
+ break;
+ case BOARD:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Board");
+ ptr->dev_board = val.str;
+ break;
+ case CHIPSET:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Chipset");
+ ptr->dev_chipset = val.str;
+ break;
+ case CARD:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Card");
+ ptr->dev_card = val.str;
+ break;
+ case DRIVER:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ ptr->dev_driver = val.str;
+ break;
+ case RAMDAC:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Ramdac");
+ ptr->dev_ramdac = val.str;
+ break;
+ case DACSPEED:
+ for (i = 0; i < CONF_MAXDACSPEEDS; i++)
+ ptr->dev_dacSpeeds[i] = 0;
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ {
+ Error (DACSPEED_MSG, CONF_MAXDACSPEEDS);
+ }
+ else
+ {
+ ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5);
+ for (i = 1; i < CONF_MAXDACSPEEDS; i++)
+ {
+ if (xf86getSubToken (&(ptr->dev_comment)) == NUMBER)
+ ptr->dev_dacSpeeds[i] = (int)
+ (val.realnum * 1000.0 + 0.5);
+ else
+ {
+ xf86unGetToken (token);
+ break;
+ }
+ }
+ }
+ break;
+ case VIDEORAM:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "VideoRam");
+ ptr->dev_videoram = val.num;
+ break;
+ case BIOSBASE:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "BIOSBase");
+ ptr->dev_bios_base = val.num;
+ break;
+ case MEMBASE:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "MemBase");
+ ptr->dev_mem_base = val.num;
+ break;
+ case IOBASE:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "IOBase");
+ ptr->dev_io_base = val.num;
+ break;
+ case CLOCKCHIP:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "ClockChip");
+ ptr->dev_clockchip = val.str;
+ break;
+ case CHIPID:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "ChipID");
+ ptr->dev_chipid = val.num;
+ break;
+ case CHIPREV:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "ChipRev");
+ ptr->dev_chiprev = val.num;
+ break;
+
+ case CLOCKS:
+ token = xf86getSubToken(&(ptr->dev_comment));
+ for( i = ptr->dev_clocks;
+ token == NUMBER && i < CONF_MAXCLOCKS; i++ ) {
+ ptr->dev_clock[i] = (int)(val.realnum * 1000.0 + 0.5);
+ token = xf86getSubToken(&(ptr->dev_comment));
+ }
+ ptr->dev_clocks = i;
+ xf86unGetToken (token);
+ break;
+ case TEXTCLOCKFRQ:
+ if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER)
+ Error (NUMBER_MSG, "TextClockFreq");
+ ptr->dev_textclockfreq = (int)(val.realnum * 1000.0 + 0.5);
+ break;
+ case OPTION:
+ ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
+ break;
+ case BUSID:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "BusID");
+ ptr->dev_busid = val.str;
+ break;
+ case IRQ:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (QUOTE_MSG, "IRQ");
+ ptr->dev_irq = val.num;
+ break;
+ case SCREEN:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Screen");
+ ptr->dev_screen = val.num;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Device section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr)
+{
+ int i;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"Device\"\n");
+ if (ptr->dev_comment)
+ fprintf (cf, "%s", ptr->dev_comment);
+ if (ptr->dev_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->dev_identifier);
+ if (ptr->dev_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->dev_driver);
+ if (ptr->dev_vendor)
+ fprintf (cf, "\tVendorName \"%s\"\n", ptr->dev_vendor);
+ if (ptr->dev_board)
+ fprintf (cf, "\tBoardName \"%s\"\n", ptr->dev_board);
+ if (ptr->dev_chipset)
+ fprintf (cf, "\tChipSet \"%s\"\n", ptr->dev_chipset);
+ if (ptr->dev_card)
+ fprintf (cf, "\tCard \"%s\"\n", ptr->dev_card);
+ if (ptr->dev_ramdac)
+ fprintf (cf, "\tRamDac \"%s\"\n", ptr->dev_ramdac);
+ if (ptr->dev_dacSpeeds[0] > 0 ) {
+ fprintf (cf, "\tDacSpeed ");
+ for (i = 0; i < CONF_MAXDACSPEEDS
+ && ptr->dev_dacSpeeds[i] > 0; i++ )
+ fprintf (cf, "%g ", (double) (ptr->dev_dacSpeeds[i])/ 1000.0 );
+ fprintf (cf, "\n");
+ }
+ if (ptr->dev_videoram)
+ fprintf (cf, "\tVideoRam %d\n", ptr->dev_videoram);
+ if (ptr->dev_bios_base)
+ fprintf (cf, "\tBiosBase 0x%lx\n", ptr->dev_bios_base);
+ if (ptr->dev_mem_base)
+ fprintf (cf, "\tMemBase 0x%lx\n", ptr->dev_mem_base);
+ if (ptr->dev_io_base)
+ fprintf (cf, "\tIOBase 0x%lx\n", ptr->dev_io_base);
+ if (ptr->dev_clockchip)
+ fprintf (cf, "\tClockChip \"%s\"\n", ptr->dev_clockchip);
+ if (ptr->dev_chipid != -1)
+ fprintf (cf, "\tChipId 0x%x\n", ptr->dev_chipid);
+ if (ptr->dev_chiprev != -1)
+ fprintf (cf, "\tChipRev 0x%x\n", ptr->dev_chiprev);
+
+ xf86printOptionList(cf, ptr->dev_option_lst, 1);
+ if (ptr->dev_clocks > 0 ) {
+ fprintf (cf, "\tClocks ");
+ for (i = 0; i < ptr->dev_clocks; i++ )
+ fprintf (cf, "%.1f ", (double)ptr->dev_clock[i] / 1000.0 );
+ fprintf (cf, "\n");
+ }
+ if (ptr->dev_textclockfreq) {
+ fprintf (cf, "\tTextClockFreq %.1f\n",
+ (double)ptr->dev_textclockfreq / 1000.0);
+ }
+ if (ptr->dev_busid)
+ fprintf (cf, "\tBusID \"%s\"\n", ptr->dev_busid);
+ if (ptr->dev_screen > 0)
+ fprintf (cf, "\tScreen %d\n", ptr->dev_screen);
+ if (ptr->dev_irq >= 0)
+ fprintf (cf, "\tIRQ %d\n", ptr->dev_irq);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeDeviceList (XF86ConfDevicePtr ptr)
+{
+ XF86ConfDevicePtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->dev_identifier);
+ TestFree (ptr->dev_vendor);
+ TestFree (ptr->dev_board);
+ TestFree (ptr->dev_chipset);
+ TestFree (ptr->dev_card);
+ TestFree (ptr->dev_driver);
+ TestFree (ptr->dev_ramdac);
+ TestFree (ptr->dev_clockchip);
+ TestFree (ptr->dev_comment);
+ xf86optionListFree (ptr->dev_option_lst);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+XF86ConfDevicePtr
+xf86findDevice (const char *ident, XF86ConfDevicePtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->dev_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
diff --git a/xorg-server/hw/xfree86/parser/Flags.c b/xorg-server/hw/xfree86/parser/Flags.c index 699f15ceb..b6ffc1538 100644 --- a/xorg-server/hw/xfree86/parser/Flags.c +++ b/xorg-server/hw/xfree86/parser/Flags.c @@ -1,516 +1,515 @@ -/* - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* View/edit this file with tab stops set to 4 */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86Parser.h" -#include "xf86tokens.h" -#include "Configint.h" -#include <math.h> -#include <X11/Xfuncproto.h> - -extern LexRec val; - -static xf86ConfigSymTabRec ServerFlagsTab[] = -{ - {ENDSECTION, "endsection"}, - {NOTRAPSIGNALS, "notrapsignals"}, - {DONTZAP, "dontzap"}, - {DONTZOOM, "dontzoom"}, - {DISABLEVIDMODE, "disablevidmodeextension"}, - {ALLOWNONLOCAL, "allownonlocalxvidtune"}, - {DISABLEMODINDEV, "disablemodindev"}, - {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"}, - {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"}, - {OPTION, "option"}, - {BLANKTIME, "blanktime"}, - {STANDBYTIME, "standbytime"}, - {SUSPENDTIME, "suspendtime"}, - {OFFTIME, "offtime"}, - {DEFAULTLAYOUT, "defaultserverlayout"}, - {-1, ""}, -}; - -#define CLEANUP xf86freeFlags - -XF86ConfFlagsPtr -xf86parseFlagsSection (void) -{ - int token; - parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec) - - while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION) - { - int hasvalue = FALSE; - int strvalue = FALSE; - int tokentype; - switch (token) - { - case COMMENT: - ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str); - break; - /* - * these old keywords are turned into standard generic options. - * we fall through here on purpose - */ - case DEFAULTLAYOUT: - strvalue = TRUE; - case BLANKTIME: - case STANDBYTIME: - case SUSPENDTIME: - case OFFTIME: - hasvalue = TRUE; - case NOTRAPSIGNALS: - case DONTZAP: - case DONTZOOM: - case DISABLEVIDMODE: - case ALLOWNONLOCAL: - case DISABLEMODINDEV: - case MODINDEVALLOWNONLOCAL: - case ALLOWMOUSEOPENFAIL: - { - int i = 0; - while (ServerFlagsTab[i].token != -1) - { - char *tmp; - - if (ServerFlagsTab[i].token == token) - { - char *valstr = NULL; - /* can't use strdup because it calls malloc */ - tmp = strdup (ServerFlagsTab[i].name); - if (hasvalue) - { - tokentype = xf86getSubToken(&(ptr->flg_comment)); - if (strvalue) { - if (tokentype != STRING) - Error (QUOTE_MSG, tmp); - valstr = val.str; - } else { - if (tokentype != NUMBER) - Error (NUMBER_MSG, tmp); - valstr = malloc(16); - if (valstr) - sprintf(valstr, "%d", val.num); - } - } - ptr->flg_option_lst = xf86addNewOption - (ptr->flg_option_lst, tmp, valstr); - } - i++; - } - } - break; - case OPTION: - ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst); - break; - - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error (INVALID_KEYWORD_MSG, xf86tokenString ()); - break; - } - } - -#ifdef DEBUG - printf ("Flags section parsed\n"); -#endif - - return ptr; -} - -#undef CLEANUP - -void -xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags) -{ - XF86OptionPtr p; - - if ((!flags) || (!flags->flg_option_lst)) - return; - p = flags->flg_option_lst; - fprintf (f, "Section \"ServerFlags\"\n"); - if (flags->flg_comment) - fprintf (f, "%s", flags->flg_comment); - xf86printOptionList(f, p, 1); - fprintf (f, "EndSection\n\n"); -} - -static XF86OptionPtr -addNewOption2 (XF86OptionPtr head, char *name, char *val, int used) -{ - XF86OptionPtr new, old = NULL; - - /* Don't allow duplicates, free old strings */ - if (head != NULL && (old = xf86findOption(head, name)) != NULL) { - new = old; - free(new->opt_name); - free(new->opt_val); - } - else - new = calloc (1, sizeof (XF86OptionRec)); - new->opt_name = name; - new->opt_val = val; - new->opt_used = used; - - if (old) - return head; - return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new)); -} - -XF86OptionPtr -xf86addNewOption (XF86OptionPtr head, char *name, char *val) -{ - return addNewOption2(head, name, val, 0); -} - -void -xf86freeFlags (XF86ConfFlagsPtr flags) -{ - if (flags == NULL) - return; - xf86optionListFree (flags->flg_option_lst); - TestFree(flags->flg_comment); - free (flags); -} - -XF86OptionPtr -xf86optionListDup (XF86OptionPtr opt) -{ - XF86OptionPtr newopt = NULL; - char *val; - - while (opt) - { - val = opt->opt_val ? strdup(opt->opt_val) : NULL; - newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val); - newopt->opt_used = opt->opt_used; - if (opt->opt_comment) - newopt->opt_comment = strdup(opt->opt_comment); - opt = opt->list.next; - } - return newopt; -} - -void -xf86optionListFree (XF86OptionPtr opt) -{ - XF86OptionPtr prev; - - while (opt) - { - TestFree (opt->opt_name); - TestFree (opt->opt_val); - TestFree (opt->opt_comment); - prev = opt; - opt = opt->list.next; - free (prev); - } -} - -char * -xf86optionName(XF86OptionPtr opt) -{ - if (opt) - return opt->opt_name; - return 0; -} - -char * -xf86optionValue(XF86OptionPtr opt) -{ - if (opt) - return opt->opt_val; - return 0; -} - -XF86OptionPtr -xf86newOption(char *name, char *value) -{ - XF86OptionPtr opt; - - opt = calloc(1, sizeof (XF86OptionRec)); - if (!opt) - return NULL; - - opt->opt_used = 0; - opt->list.next = 0; - opt->opt_name = name; - opt->opt_val = value; - - return opt; -} - -XF86OptionPtr -xf86nextOption(XF86OptionPtr list) -{ - if (!list) - return NULL; - return list->list.next; -} - -/* - * this function searches the given option list for the named option and - * returns a pointer to the option rec if found. If not found, it returns - * NULL - */ - -XF86OptionPtr -xf86findOption (XF86OptionPtr list, const char *name) -{ - while (list) - { - if (xf86nameCompare (list->opt_name, name) == 0) - return (list); - list = list->list.next; - } - return (NULL); -} - -/* - * this function searches the given option list for the named option. If - * found and the option has a parameter, a pointer to the parameter is - * returned. If the option does not have a parameter an empty string is - * returned. If the option is not found, a NULL is returned. - */ - -char * -xf86findOptionValue (XF86OptionPtr list, const char *name) -{ - XF86OptionPtr p = xf86findOption (list, name); - - if (p) - { - if (p->opt_val) - return (p->opt_val); - else - return ""; - } - return (NULL); -} - -XF86OptionPtr -xf86optionListCreate( const char **options, int count, int used ) -{ - XF86OptionPtr p = NULL; - char *t1, *t2; - int i; - - if (count == -1) - { - for (count = 0; options[count]; count++) - ; - } - if( (count % 2) != 0 ) - { - fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" ); - return (NULL); - } - for (i = 0; i < count; i += 2) - { - /* can't use strdup because it calls malloc */ - t1 = malloc (sizeof (char) * - (strlen (options[i]) + 1)); - strcpy (t1, options[i]); - t2 = malloc (sizeof (char) * - (strlen (options[i + 1]) + 1)); - strcpy (t2, options[i + 1]); - p = addNewOption2 (p, t1, t2, used); - } - - return (p); -} - -/* the 2 given lists are merged. If an option with the same name is present in - * both, the option from the user list - specified in the second argument - - * is used. The end result is a single valid list of options. Duplicates - * are freed, and the original lists are no longer guaranteed to be complete. - */ -XF86OptionPtr -xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail) -{ - XF86OptionPtr a, b, ap = NULL, bp = NULL; - - a = tail; - b = head; - while (tail && b) { - if (xf86nameCompare (a->opt_name, b->opt_name) == 0) { - if (b == head) - head = a; - else - bp->list.next = a; - if (a == tail) - tail = a->list.next; - else - ap->list.next = a->list.next; - a->list.next = b->list.next; - b->list.next = NULL; - xf86optionListFree (b); - b = a->list.next; - bp = a; - a = tail; - ap = NULL; - } else { - ap = a; - if (!(a = a->list.next)) { - a = tail; - bp = b; - b = b->list.next; - ap = NULL; - } - } - } - - if (head) { - for (a = head; a->list.next; a = a->list.next) - ; - a->list.next = tail; - } else - head = tail; - - return (head); -} - -char * -xf86uLongToString(unsigned long i) -{ - char *s; - int l; - - l = ceil(log10((double)i) + 2.5); - s = malloc(l); - if (!s) - return NULL; - sprintf(s, "%lu", i); - return s; -} - -XF86OptionPtr -xf86parseOption(XF86OptionPtr head) -{ - XF86OptionPtr option, cnew, old; - char *name, *comment = NULL; - int token; - - if ((token = xf86getSubToken(&comment)) != STRING) { - xf86parseError(BAD_OPTION_MSG, NULL); - if (comment) - free(comment); - return (head); - } - - name = val.str; - if ((token = xf86getSubToken(&comment)) == STRING) { - option = xf86newOption(name, val.str); - option->opt_comment = comment; - if ((token = xf86getToken(NULL)) == COMMENT) - option->opt_comment = xf86addComment(option->opt_comment, val.str); - else - xf86unGetToken(token); - } - else { - option = xf86newOption(name, NULL); - option->opt_comment = comment; - if (token == COMMENT) - option->opt_comment = xf86addComment(option->opt_comment, val.str); - else - xf86unGetToken(token); - } - - old = NULL; - - /* Don't allow duplicates */ - if (head != NULL && (old = xf86findOption(head, name)) != NULL) { - cnew = old; - free(option->opt_name); - TestFree(option->opt_val); - TestFree(option->opt_comment); - free(option); - } - else - cnew = option; - - if (old == NULL) - return ((XF86OptionPtr)xf86addListItem((glp)head, (glp)cnew)); - - return (head); -} - -void -xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs) -{ - int i; - - if (!list) - return; - while (list) { - for (i = 0; i < tabs; i++) - fputc('\t', fp); - if (list->opt_val) - fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name, list->opt_val); - else - fprintf(fp, "Option \"%s\"", list->opt_name); - if (list->opt_comment) - fprintf(fp, "%s", list->opt_comment); - else - fputc('\n', fp); - list = list->list.next; - } -} +/*
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+#include <math.h>
+#include <X11/Xfuncproto.h>
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec ServerFlagsTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {NOTRAPSIGNALS, "notrapsignals"},
+ {DONTZAP, "dontzap"},
+ {DONTZOOM, "dontzoom"},
+ {DISABLEVIDMODE, "disablevidmodeextension"},
+ {ALLOWNONLOCAL, "allownonlocalxvidtune"},
+ {DISABLEMODINDEV, "disablemodindev"},
+ {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"},
+ {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"},
+ {OPTION, "option"},
+ {BLANKTIME, "blanktime"},
+ {STANDBYTIME, "standbytime"},
+ {SUSPENDTIME, "suspendtime"},
+ {OFFTIME, "offtime"},
+ {DEFAULTLAYOUT, "defaultserverlayout"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeFlags
+
+XF86ConfFlagsPtr
+xf86parseFlagsSection (void)
+{
+ int token;
+ parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
+
+ while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION)
+ {
+ int hasvalue = FALSE;
+ int strvalue = FALSE;
+ int tokentype;
+ switch (token)
+ {
+ case COMMENT:
+ ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str);
+ break;
+ /*
+ * these old keywords are turned into standard generic options.
+ * we fall through here on purpose
+ */
+ case DEFAULTLAYOUT:
+ strvalue = TRUE;
+ case BLANKTIME:
+ case STANDBYTIME:
+ case SUSPENDTIME:
+ case OFFTIME:
+ hasvalue = TRUE;
+ case NOTRAPSIGNALS:
+ case DONTZAP:
+ case DONTZOOM:
+ case DISABLEVIDMODE:
+ case ALLOWNONLOCAL:
+ case DISABLEMODINDEV:
+ case MODINDEVALLOWNONLOCAL:
+ case ALLOWMOUSEOPENFAIL:
+ {
+ int i = 0;
+ while (ServerFlagsTab[i].token != -1)
+ {
+ char *tmp;
+
+ if (ServerFlagsTab[i].token == token)
+ {
+ char *valstr = NULL;
+ /* can't use strdup because it calls malloc */
+ tmp = strdup (ServerFlagsTab[i].name);
+ if (hasvalue)
+ {
+ tokentype = xf86getSubToken(&(ptr->flg_comment));
+ if (strvalue) {
+ if (tokentype != STRING)
+ Error (QUOTE_MSG, tmp);
+ valstr = val.str;
+ } else {
+ if (tokentype != NUMBER)
+ Error (NUMBER_MSG, tmp);
+ valstr = malloc(16);
+ if (valstr)
+ sprintf(valstr, "%d", val.num);
+ }
+ }
+ ptr->flg_option_lst = xf86addNewOption
+ (ptr->flg_option_lst, tmp, valstr);
+ }
+ i++;
+ }
+ }
+ break;
+ case OPTION:
+ ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("Flags section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags)
+{
+ XF86OptionPtr p;
+
+ if ((!flags) || (!flags->flg_option_lst))
+ return;
+ p = flags->flg_option_lst;
+ fprintf (f, "Section \"ServerFlags\"\n");
+ if (flags->flg_comment)
+ fprintf (f, "%s", flags->flg_comment);
+ xf86printOptionList(f, p, 1);
+ fprintf (f, "EndSection\n\n");
+}
+
+static XF86OptionPtr
+addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
+{
+ XF86OptionPtr new, old = NULL;
+
+ /* Don't allow duplicates, free old strings */
+ if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
+ new = old;
+ free(new->opt_name);
+ free(new->opt_val);
+ }
+ else
+ new = calloc (1, sizeof (XF86OptionRec));
+ new->opt_name = name;
+ new->opt_val = val;
+ new->opt_used = used;
+
+ if (old)
+ return head;
+ return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
+}
+
+XF86OptionPtr
+xf86addNewOption (XF86OptionPtr head, char *name, char *val)
+{
+ return addNewOption2(head, name, val, 0);
+}
+
+void
+xf86freeFlags (XF86ConfFlagsPtr flags)
+{
+ if (flags == NULL)
+ return;
+ xf86optionListFree (flags->flg_option_lst);
+ TestFree(flags->flg_comment);
+ free (flags);
+}
+
+XF86OptionPtr
+xf86optionListDup (XF86OptionPtr opt)
+{
+ XF86OptionPtr newopt = NULL;
+ char *val;
+
+ while (opt)
+ {
+ val = opt->opt_val ? strdup(opt->opt_val) : NULL;
+ newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val);
+ newopt->opt_used = opt->opt_used;
+ if (opt->opt_comment)
+ newopt->opt_comment = strdup(opt->opt_comment);
+ opt = opt->list.next;
+ }
+ return newopt;
+}
+
+void
+xf86optionListFree (XF86OptionPtr opt)
+{
+ XF86OptionPtr prev;
+
+ while (opt)
+ {
+ TestFree (opt->opt_name);
+ TestFree (opt->opt_val);
+ TestFree (opt->opt_comment);
+ prev = opt;
+ opt = opt->list.next;
+ free (prev);
+ }
+}
+
+char *
+xf86optionName(XF86OptionPtr opt)
+{
+ if (opt)
+ return opt->opt_name;
+ return 0;
+}
+
+char *
+xf86optionValue(XF86OptionPtr opt)
+{
+ if (opt)
+ return opt->opt_val;
+ return 0;
+}
+
+XF86OptionPtr
+xf86newOption(char *name, char *value)
+{
+ XF86OptionPtr opt;
+
+ opt = calloc(1, sizeof (XF86OptionRec));
+ if (!opt)
+ return NULL;
+
+ opt->opt_used = 0;
+ opt->list.next = 0;
+ opt->opt_name = name;
+ opt->opt_val = value;
+
+ return opt;
+}
+
+XF86OptionPtr
+xf86nextOption(XF86OptionPtr list)
+{
+ if (!list)
+ return NULL;
+ return list->list.next;
+}
+
+/*
+ * this function searches the given option list for the named option and
+ * returns a pointer to the option rec if found. If not found, it returns
+ * NULL
+ */
+
+XF86OptionPtr
+xf86findOption (XF86OptionPtr list, const char *name)
+{
+ while (list)
+ {
+ if (xf86nameCompare (list->opt_name, name) == 0)
+ return list;
+ list = list->list.next;
+ }
+ return NULL;
+}
+
+/*
+ * this function searches the given option list for the named option. If
+ * found and the option has a parameter, a pointer to the parameter is
+ * returned. If the option does not have a parameter an empty string is
+ * returned. If the option is not found, a NULL is returned.
+ */
+
+char *
+xf86findOptionValue (XF86OptionPtr list, const char *name)
+{
+ XF86OptionPtr p = xf86findOption (list, name);
+
+ if (p)
+ {
+ if (p->opt_val)
+ return p->opt_val;
+ else
+ return "";
+ }
+ return NULL;
+}
+
+XF86OptionPtr
+xf86optionListCreate( const char **options, int count, int used )
+{
+ XF86OptionPtr p = NULL;
+ char *t1, *t2;
+ int i;
+
+ if (count == -1)
+ {
+ for (count = 0; options[count]; count++)
+ ;
+ }
+ if( (count % 2) != 0 )
+ {
+ fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" );
+ return NULL;
+ }
+ for (i = 0; i < count; i += 2)
+ {
+ /* can't use strdup because it calls malloc */
+ t1 = malloc (sizeof (char) *
+ (strlen (options[i]) + 1));
+ strcpy (t1, options[i]);
+ t2 = malloc (sizeof (char) *
+ (strlen (options[i + 1]) + 1));
+ strcpy (t2, options[i + 1]);
+ p = addNewOption2 (p, t1, t2, used);
+ }
+
+ return p;
+}
+
+/* the 2 given lists are merged. If an option with the same name is present in
+ * both, the option from the user list - specified in the second argument -
+ * is used. The end result is a single valid list of options. Duplicates
+ * are freed, and the original lists are no longer guaranteed to be complete.
+ */
+XF86OptionPtr
+xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail)
+{
+ XF86OptionPtr a, b, ap = NULL, bp = NULL;
+
+ a = tail;
+ b = head;
+ while (tail && b) {
+ if (xf86nameCompare (a->opt_name, b->opt_name) == 0) {
+ if (b == head)
+ head = a;
+ else
+ bp->list.next = a;
+ if (a == tail)
+ tail = a->list.next;
+ else
+ ap->list.next = a->list.next;
+ a->list.next = b->list.next;
+ b->list.next = NULL;
+ xf86optionListFree (b);
+ b = a->list.next;
+ bp = a;
+ a = tail;
+ ap = NULL;
+ } else {
+ ap = a;
+ if (!(a = a->list.next)) {
+ a = tail;
+ bp = b;
+ b = b->list.next;
+ ap = NULL;
+ }
+ }
+ }
+
+ if (head) {
+ for (a = head; a->list.next; a = a->list.next)
+ ;
+ a->list.next = tail;
+ } else
+ head = tail;
+
+ return head;
+}
+
+char *
+xf86uLongToString(unsigned long i)
+{
+ char *s;
+ int l;
+
+ l = ceil(log10((double)i) + 2.5);
+ s = malloc(l);
+ if (!s)
+ return NULL;
+ sprintf(s, "%lu", i);
+ return s;
+}
+
+XF86OptionPtr
+xf86parseOption(XF86OptionPtr head)
+{
+ XF86OptionPtr option, cnew, old;
+ char *name, *comment = NULL;
+ int token;
+
+ if ((token = xf86getSubToken(&comment)) != STRING) {
+ xf86parseError(BAD_OPTION_MSG, NULL);
+ free(comment);
+ return head;
+ }
+
+ name = val.str;
+ if ((token = xf86getSubToken(&comment)) == STRING) {
+ option = xf86newOption(name, val.str);
+ option->opt_comment = comment;
+ if ((token = xf86getToken(NULL)) == COMMENT)
+ option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ else
+ xf86unGetToken(token);
+ }
+ else {
+ option = xf86newOption(name, NULL);
+ option->opt_comment = comment;
+ if (token == COMMENT)
+ option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ else
+ xf86unGetToken(token);
+ }
+
+ old = NULL;
+
+ /* Don't allow duplicates */
+ if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
+ cnew = old;
+ free(option->opt_name);
+ TestFree(option->opt_val);
+ TestFree(option->opt_comment);
+ free(option);
+ }
+ else
+ cnew = option;
+
+ if (old == NULL)
+ return ((XF86OptionPtr)xf86addListItem((glp)head, (glp)cnew));
+
+ return head;
+}
+
+void
+xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs)
+{
+ int i;
+
+ if (!list)
+ return;
+ while (list) {
+ for (i = 0; i < tabs; i++)
+ fputc('\t', fp);
+ if (list->opt_val)
+ fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name, list->opt_val);
+ else
+ fprintf(fp, "Option \"%s\"", list->opt_name);
+ if (list->opt_comment)
+ fprintf(fp, "%s", list->opt_comment);
+ else
+ fputc('\n', fp);
+ list = list->list.next;
+ }
+}
diff --git a/xorg-server/hw/xfree86/parser/Input.c b/xorg-server/hw/xfree86/parser/Input.c index 8c8e46fb4..8adbee9ae 100644 --- a/xorg-server/hw/xfree86/parser/Input.c +++ b/xorg-server/hw/xfree86/parser/Input.c @@ -1,210 +1,210 @@ -/* - * - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* View/edit this file with tab stops set to 4 */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86Parser.h" -#include "xf86tokens.h" -#include "Configint.h" - -extern LexRec val; - -static -xf86ConfigSymTabRec InputTab[] = -{ - {ENDSECTION, "endsection"}, - {IDENTIFIER, "identifier"}, - {OPTION, "option"}, - {DRIVER, "driver"}, - {-1, ""}, -}; - -#define CLEANUP xf86freeInputList - -XF86ConfInputPtr -xf86parseInputSection (void) -{ - int has_ident = FALSE; - int token; - parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) - - while ((token = xf86getToken (InputTab)) != ENDSECTION) - { - switch (token) - { - case COMMENT: - ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str); - break; - case IDENTIFIER: - if (xf86getSubToken (&(ptr->inp_comment)) != STRING) - Error (QUOTE_MSG, "Identifier"); - if (has_ident == TRUE) - Error (MULTIPLE_MSG, "Identifier"); - ptr->inp_identifier = val.str; - has_ident = TRUE; - break; - case DRIVER: - if (xf86getSubToken (&(ptr->inp_comment)) != STRING) - Error (QUOTE_MSG, "Driver"); - if (strcmp(val.str, "keyboard") == 0) - ptr->inp_driver = "kbd"; - else - ptr->inp_driver = val.str; - break; - case OPTION: - ptr->inp_option_lst = xf86parseOption(ptr->inp_option_lst); - break; - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error (INVALID_KEYWORD_MSG, xf86tokenString ()); - break; - } - } - - if (!has_ident) - Error (NO_IDENT_MSG, NULL); - -#ifdef DEBUG - printf ("InputDevice section parsed\n"); -#endif - - return ptr; -} - -#undef CLEANUP - -void -xf86printInputSection (FILE * cf, XF86ConfInputPtr ptr) -{ - while (ptr) - { - fprintf (cf, "Section \"InputDevice\"\n"); - if (ptr->inp_comment) - fprintf (cf, "%s", ptr->inp_comment); - if (ptr->inp_identifier) - fprintf (cf, "\tIdentifier \"%s\"\n", ptr->inp_identifier); - if (ptr->inp_driver) - fprintf (cf, "\tDriver \"%s\"\n", ptr->inp_driver); - xf86printOptionList(cf, ptr->inp_option_lst, 1); - fprintf (cf, "EndSection\n\n"); - ptr = ptr->list.next; - } -} - -void -xf86freeInputList (XF86ConfInputPtr ptr) -{ - XF86ConfInputPtr prev; - - while (ptr) - { - TestFree (ptr->inp_identifier); - TestFree (ptr->inp_driver); - TestFree (ptr->inp_comment); - xf86optionListFree (ptr->inp_option_lst); - - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -int -xf86validateInput (XF86ConfigPtr p) -{ - XF86ConfInputPtr input = p->conf_input_lst; - - while (input) { - if (!input->inp_driver) { - xf86validationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier); - return (FALSE); - } - input = input->list.next; - } - return (TRUE); -} - -XF86ConfInputPtr -xf86findInput (const char *ident, XF86ConfInputPtr p) -{ - while (p) - { - if (xf86nameCompare (ident, p->inp_identifier) == 0) - return (p); - - p = p->list.next; - } - return (NULL); -} - -XF86ConfInputPtr -xf86findInputByDriver (const char *driver, XF86ConfInputPtr p) -{ - while (p) - { - if (xf86nameCompare (driver, p->inp_driver) == 0) - return (p); - - p = p->list.next; - } - return (NULL); -} - +/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static
+xf86ConfigSymTabRec InputTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {DRIVER, "driver"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeInputList
+
+XF86ConfInputPtr
+xf86parseInputSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
+
+ while ((token = xf86getToken (InputTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->inp_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case DRIVER:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ if (strcmp(val.str, "keyboard") == 0)
+ ptr->inp_driver = "kbd";
+ else
+ ptr->inp_driver = val.str;
+ break;
+ case OPTION:
+ ptr->inp_option_lst = xf86parseOption(ptr->inp_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("InputDevice section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printInputSection (FILE * cf, XF86ConfInputPtr ptr)
+{
+ while (ptr)
+ {
+ fprintf (cf, "Section \"InputDevice\"\n");
+ if (ptr->inp_comment)
+ fprintf (cf, "%s", ptr->inp_comment);
+ if (ptr->inp_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->inp_identifier);
+ if (ptr->inp_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->inp_driver);
+ xf86printOptionList(cf, ptr->inp_option_lst, 1);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeInputList (XF86ConfInputPtr ptr)
+{
+ XF86ConfInputPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->inp_identifier);
+ TestFree (ptr->inp_driver);
+ TestFree (ptr->inp_comment);
+ xf86optionListFree (ptr->inp_option_lst);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+int
+xf86validateInput (XF86ConfigPtr p)
+{
+ XF86ConfInputPtr input = p->conf_input_lst;
+
+ while (input) {
+ if (!input->inp_driver) {
+ xf86validationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier);
+ return FALSE;
+ }
+ input = input->list.next;
+ }
+ return TRUE;
+}
+
+XF86ConfInputPtr
+xf86findInput (const char *ident, XF86ConfInputPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->inp_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
+XF86ConfInputPtr
+xf86findInputByDriver (const char *driver, XF86ConfInputPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (driver, p->inp_driver) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
diff --git a/xorg-server/hw/xfree86/parser/InputClass.c b/xorg-server/hw/xfree86/parser/InputClass.c index 7fb2866cd..85161c38a 100644 --- a/xorg-server/hw/xfree86/parser/InputClass.c +++ b/xorg-server/hw/xfree86/parser/InputClass.c @@ -1,288 +1,401 @@ -/* - * Copyright (c) 2009 Dan Nicholson - * - * 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 AUTHORS OR COPYRIGHT - * HOLDERS 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. - */ - -/* View/edit this file with tab stops set to 4 */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <string.h> -#include "os.h" -#include "xf86Parser.h" -#include "xf86tokens.h" -#include "Configint.h" - -extern LexRec val; - -static -xf86ConfigSymTabRec InputClassTab[] = -{ - {ENDSECTION, "endsection"}, - {IDENTIFIER, "identifier"}, - {OPTION, "option"}, - {DRIVER, "driver"}, - {MATCH_PRODUCT, "matchproduct"}, - {MATCH_VENDOR, "matchvendor"}, - {MATCH_DEVICE_PATH, "matchdevicepath"}, - {MATCH_TAG, "matchtag"}, - {MATCH_IS_KEYBOARD, "matchiskeyboard"}, - {MATCH_IS_POINTER, "matchispointer"}, - {MATCH_IS_JOYSTICK, "matchisjoystick"}, - {MATCH_IS_TABLET, "matchistablet"}, - {MATCH_IS_TOUCHPAD, "matchistouchpad"}, - {MATCH_IS_TOUCHSCREEN, "matchistouchscreen"}, - {-1, ""}, -}; - -#define CLEANUP xf86freeInputClassList - -#define TOKEN_SEP "|" - -XF86ConfInputClassPtr -xf86parseInputClassSection(void) -{ - int has_ident = FALSE; - int token; - - parsePrologue(XF86ConfInputClassPtr, XF86ConfInputClassRec) - - while ((token = xf86getToken(InputClassTab)) != ENDSECTION) { - switch (token) { - case COMMENT: - ptr->comment = xf86addComment(ptr->comment, val.str); - break; - case IDENTIFIER: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "Identifier"); - if (has_ident == TRUE) - Error(MULTIPLE_MSG, "Identifier"); - ptr->identifier = val.str; - has_ident = TRUE; - break; - case DRIVER: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "Driver"); - if (strcmp(val.str, "keyboard") == 0) - ptr->driver = "kbd"; - else - ptr->driver = val.str; - break; - case OPTION: - ptr->option_lst = xf86parseOption(ptr->option_lst); - break; - case MATCH_PRODUCT: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "MatchProduct"); - ptr->match_product = xstrtokenize(val.str, TOKEN_SEP); - break; - case MATCH_VENDOR: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "MatchVendor"); - ptr->match_vendor = xstrtokenize(val.str, TOKEN_SEP); - break; - case MATCH_DEVICE_PATH: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "MatchDevicePath"); - ptr->match_device = xstrtokenize(val.str, TOKEN_SEP); - break; - case MATCH_TAG: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "MatchTag"); - ptr->match_tag = xstrtokenize(val.str, TOKEN_SEP); - break; - case MATCH_IS_KEYBOARD: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "MatchIsKeyboard"); - ptr->is_keyboard.set = xf86getBoolValue(&ptr->is_keyboard.val, - val.str); - if (!ptr->is_keyboard.set) - Error(BOOL_MSG, "MatchIsKeyboard"); - break; - case MATCH_IS_POINTER: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "MatchIsPointer"); - ptr->is_pointer.set = xf86getBoolValue(&ptr->is_pointer.val, - val.str); - if (!ptr->is_pointer.set) - Error(BOOL_MSG, "MatchIsPointer"); - break; - case MATCH_IS_JOYSTICK: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "MatchIsJoystick"); - ptr->is_joystick.set = xf86getBoolValue(&ptr->is_joystick.val, - val.str); - if (!ptr->is_joystick.set) - Error(BOOL_MSG, "MatchIsJoystick"); - break; - case MATCH_IS_TABLET: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "MatchIsTablet"); - ptr->is_tablet.set = xf86getBoolValue(&ptr->is_tablet.val, - val.str); - if (!ptr->is_tablet.set) - Error(BOOL_MSG, "MatchIsTablet"); - break; - case MATCH_IS_TOUCHPAD: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "MatchIsTouchpad"); - ptr->is_touchpad.set = xf86getBoolValue(&ptr->is_touchpad.val, - val.str); - if (!ptr->is_touchpad.set) - Error(BOOL_MSG, "MatchIsTouchpad"); - break; - case MATCH_IS_TOUCHSCREEN: - if (xf86getSubToken(&(ptr->comment)) != STRING) - Error(QUOTE_MSG, "MatchIsTouchscreen"); - ptr->is_touchscreen.set = xf86getBoolValue(&ptr->is_touchscreen.val, - val.str); - if (!ptr->is_touchscreen.set) - Error(BOOL_MSG, "MatchIsTouchscreen"); - break; - case EOF_TOKEN: - Error(UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error(INVALID_KEYWORD_MSG, xf86tokenString ()); - break; - } - } - - if (!has_ident) - Error(NO_IDENT_MSG, NULL); - -#ifdef DEBUG - printf("InputClass section parsed\n"); -#endif - - return ptr; -} - -void -xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr ptr) -{ - char **list; - - while (ptr) { - fprintf(cf, "Section \"InputClass\"\n"); - if (ptr->comment) - fprintf(cf, "%s", ptr->comment); - if (ptr->identifier) - fprintf(cf, "\tIdentifier \"%s\"\n", ptr->identifier); - if (ptr->driver) - fprintf(cf, "\tDriver \"%s\"\n", ptr->driver); - if (ptr->match_product) { - fprintf(cf, "\tMatchProduct \""); - for (list = ptr->match_product; *list; list++) - fprintf(cf, "%s%s", - list == ptr->match_product ? "" : TOKEN_SEP, - *list); - fprintf(cf, "\"\n"); - } - if (ptr->match_vendor) { - fprintf(cf, "\tMatchVendor \""); - for (list = ptr->match_vendor; *list; list++) - fprintf(cf, "%s%s", - list == ptr->match_vendor ? "" : TOKEN_SEP, - *list); - fprintf(cf, "\"\n"); - } - if (ptr->match_device) { - fprintf(cf, "\tMatchDevicePath \""); - for (list = ptr->match_device; *list; list++) - fprintf(cf, "%s%s", - list == ptr->match_device ? "" : TOKEN_SEP, - *list); - fprintf(cf, "\"\n"); - } - if (ptr->match_tag) { - fprintf(cf, "\tMatchTag \""); - for (list = ptr->match_tag; *list; list++) - fprintf(cf, "%s%s", - list == ptr->match_tag ? "" : TOKEN_SEP, - *list); - fprintf(cf, "\"\n"); - } - if (ptr->is_keyboard.set) - fprintf(cf, "\tIsKeyboard \"%s\"\n", - ptr->is_keyboard.val ? "yes" : "no"); - if (ptr->is_pointer.set) - fprintf(cf, "\tIsPointer \"%s\"\n", - ptr->is_pointer.val ? "yes" : "no"); - if (ptr->is_joystick.set) - fprintf(cf, "\tIsJoystick \"%s\"\n", - ptr->is_joystick.val ? "yes" : "no"); - if (ptr->is_tablet.set) - fprintf(cf, "\tIsTablet \"%s\"\n", - ptr->is_tablet.val ? "yes" : "no"); - if (ptr->is_touchpad.set) - fprintf(cf, "\tIsTouchpad \"%s\"\n", - ptr->is_touchpad.val ? "yes" : "no"); - if (ptr->is_touchscreen.set) - fprintf(cf, "\tIsTouchscreen \"%s\"\n", - ptr->is_touchscreen.val ? "yes" : "no"); - xf86printOptionList(cf, ptr->option_lst, 1); - fprintf(cf, "EndSection\n\n"); - ptr = ptr->list.next; - } -} - -void -xf86freeInputClassList (XF86ConfInputClassPtr ptr) -{ - XF86ConfInputClassPtr prev; - char **list; - - while (ptr) { - TestFree(ptr->identifier); - TestFree(ptr->driver); - if (ptr->match_product) { - for (list = ptr->match_product; *list; list++) - free(*list); - free(ptr->match_product); - } - if (ptr->match_vendor) { - for (list = ptr->match_vendor; *list; list++) - free(*list); - free(ptr->match_vendor); - } - if (ptr->match_device) { - for (list = ptr->match_device; *list; list++) - free(*list); - free(ptr->match_device); - } - if (ptr->match_tag) { - for (list = ptr->match_tag; *list; list++) - free(*list); - free(ptr->match_tag); - } - TestFree(ptr->comment); - xf86optionListFree(ptr->option_lst); - - prev = ptr; - ptr = ptr->list.next; - free(prev); - } -} +/*
+ * Copyright (c) 2009 Dan Nicholson
+ *
+ * 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 AUTHORS OR COPYRIGHT
+ * HOLDERS 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.
+ */
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <string.h>
+#include "os.h"
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static
+xf86ConfigSymTabRec InputClassTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {DRIVER, "driver"},
+ {MATCH_PRODUCT, "matchproduct"},
+ {MATCH_VENDOR, "matchvendor"},
+ {MATCH_DEVICE_PATH, "matchdevicepath"},
+ {MATCH_OS, "matchos"},
+ {MATCH_PNPID, "matchpnpid"},
+ {MATCH_USBID, "matchusbid"},
+ {MATCH_DRIVER, "matchdriver"},
+ {MATCH_TAG, "matchtag"},
+ {MATCH_IS_KEYBOARD, "matchiskeyboard"},
+ {MATCH_IS_POINTER, "matchispointer"},
+ {MATCH_IS_JOYSTICK, "matchisjoystick"},
+ {MATCH_IS_TABLET, "matchistablet"},
+ {MATCH_IS_TOUCHPAD, "matchistouchpad"},
+ {MATCH_IS_TOUCHSCREEN, "matchistouchscreen"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeInputClassList
+
+#define TOKEN_SEP "|"
+
+static void
+add_group_entry(struct list *head, char **values)
+{
+ xf86MatchGroup *group;
+
+ group = malloc(sizeof(*group));
+ if (group) {
+ group->values = values;
+ list_add(&group->entry, head);
+ }
+}
+
+XF86ConfInputClassPtr
+xf86parseInputClassSection(void)
+{
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfInputClassPtr, XF86ConfInputClassRec)
+
+ /* Initialize MatchGroup lists */
+ list_init(&ptr->match_product);
+ list_init(&ptr->match_vendor);
+ list_init(&ptr->match_device);
+ list_init(&ptr->match_os);
+ list_init(&ptr->match_pnpid);
+ list_init(&ptr->match_usbid);
+ list_init(&ptr->match_driver);
+ list_init(&ptr->match_tag);
+
+ while ((token = xf86getToken(InputClassTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->comment = xf86addComment(ptr->comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ ptr->identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case DRIVER:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "Driver");
+ if (strcmp(val.str, "keyboard") == 0)
+ ptr->driver = "kbd";
+ else
+ ptr->driver = val.str;
+ break;
+ case OPTION:
+ ptr->option_lst = xf86parseOption(ptr->option_lst);
+ break;
+ case MATCH_PRODUCT:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchProduct");
+ add_group_entry(&ptr->match_product,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_VENDOR:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchVendor");
+ add_group_entry(&ptr->match_vendor,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_DEVICE_PATH:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchDevicePath");
+ add_group_entry(&ptr->match_device,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_OS:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchOS");
+ add_group_entry(&ptr->match_os,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_PNPID:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchPnPID");
+ add_group_entry(&ptr->match_pnpid,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_USBID:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchUSBID");
+ add_group_entry(&ptr->match_usbid,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_DRIVER:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchDriver");
+ add_group_entry(&ptr->match_driver,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_TAG:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchTag");
+ add_group_entry(&ptr->match_tag,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_IS_KEYBOARD:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsKeyboard");
+ ptr->is_keyboard.set = xf86getBoolValue(&ptr->is_keyboard.val,
+ val.str);
+ if (!ptr->is_keyboard.set)
+ Error(BOOL_MSG, "MatchIsKeyboard");
+ break;
+ case MATCH_IS_POINTER:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsPointer");
+ ptr->is_pointer.set = xf86getBoolValue(&ptr->is_pointer.val,
+ val.str);
+ if (!ptr->is_pointer.set)
+ Error(BOOL_MSG, "MatchIsPointer");
+ break;
+ case MATCH_IS_JOYSTICK:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsJoystick");
+ ptr->is_joystick.set = xf86getBoolValue(&ptr->is_joystick.val,
+ val.str);
+ if (!ptr->is_joystick.set)
+ Error(BOOL_MSG, "MatchIsJoystick");
+ break;
+ case MATCH_IS_TABLET:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsTablet");
+ ptr->is_tablet.set = xf86getBoolValue(&ptr->is_tablet.val,
+ val.str);
+ if (!ptr->is_tablet.set)
+ Error(BOOL_MSG, "MatchIsTablet");
+ break;
+ case MATCH_IS_TOUCHPAD:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsTouchpad");
+ ptr->is_touchpad.set = xf86getBoolValue(&ptr->is_touchpad.val,
+ val.str);
+ if (!ptr->is_touchpad.set)
+ Error(BOOL_MSG, "MatchIsTouchpad");
+ break;
+ case MATCH_IS_TOUCHSCREEN:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsTouchscreen");
+ ptr->is_touchscreen.set = xf86getBoolValue(&ptr->is_touchscreen.val,
+ val.str);
+ if (!ptr->is_touchscreen.set)
+ Error(BOOL_MSG, "MatchIsTouchscreen");
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error(NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf("InputClass section parsed\n");
+#endif
+
+ return ptr;
+}
+
+void
+xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr ptr)
+{
+ const xf86MatchGroup *group;
+ char * const *cur;
+
+ while (ptr) {
+ fprintf(cf, "Section \"InputClass\"\n");
+ if (ptr->comment)
+ fprintf(cf, "%s", ptr->comment);
+ if (ptr->identifier)
+ fprintf(cf, "\tIdentifier \"%s\"\n", ptr->identifier);
+ if (ptr->driver)
+ fprintf(cf, "\tDriver \"%s\"\n", ptr->driver);
+
+ list_for_each_entry(group, &ptr->match_product, entry) {
+ fprintf(cf, "\tMatchProduct \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_vendor, entry) {
+ fprintf(cf, "\tMatchVendor \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_device, entry) {
+ fprintf(cf, "\tMatchDevicePath \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_os, entry) {
+ fprintf(cf, "\tMatchOS \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_pnpid, entry) {
+ fprintf(cf, "\tMatchPnPID \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_usbid, entry) {
+ fprintf(cf, "\tMatchUSBID \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_driver, entry) {
+ fprintf(cf, "\tMatchDriver \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_tag, entry) {
+ fprintf(cf, "\tMatchTag \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+
+ if (ptr->is_keyboard.set)
+ fprintf(cf, "\tIsKeyboard \"%s\"\n",
+ ptr->is_keyboard.val ? "yes" : "no");
+ if (ptr->is_pointer.set)
+ fprintf(cf, "\tIsPointer \"%s\"\n",
+ ptr->is_pointer.val ? "yes" : "no");
+ if (ptr->is_joystick.set)
+ fprintf(cf, "\tIsJoystick \"%s\"\n",
+ ptr->is_joystick.val ? "yes" : "no");
+ if (ptr->is_tablet.set)
+ fprintf(cf, "\tIsTablet \"%s\"\n",
+ ptr->is_tablet.val ? "yes" : "no");
+ if (ptr->is_touchpad.set)
+ fprintf(cf, "\tIsTouchpad \"%s\"\n",
+ ptr->is_touchpad.val ? "yes" : "no");
+ if (ptr->is_touchscreen.set)
+ fprintf(cf, "\tIsTouchscreen \"%s\"\n",
+ ptr->is_touchscreen.val ? "yes" : "no");
+ xf86printOptionList(cf, ptr->option_lst, 1);
+ fprintf(cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeInputClassList (XF86ConfInputClassPtr ptr)
+{
+ XF86ConfInputClassPtr prev;
+
+ while (ptr) {
+ xf86MatchGroup *group, *next;
+ char **list;
+
+ TestFree(ptr->identifier);
+ TestFree(ptr->driver);
+
+ list_for_each_entry_safe(group, next, &ptr->match_product, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_vendor, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_device, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_os, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_pnpid, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_usbid, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_driver, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_tag, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+
+ TestFree(ptr->comment);
+ xf86optionListFree(ptr->option_lst);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
+}
diff --git a/xorg-server/hw/xfree86/parser/Layout.c b/xorg-server/hw/xfree86/parser/Layout.c index 00c1e7d09..60e83390f 100644 --- a/xorg-server/hw/xfree86/parser/Layout.c +++ b/xorg-server/hw/xfree86/parser/Layout.c @@ -1,558 +1,558 @@ -/* - * - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* View/edit this file with tab stops set to 4 */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86Parser.h" -#include "xf86tokens.h" -#include "Configint.h" -#include <string.h> - - -/* Needed for auto server layout */ -extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt); - -extern LexRec val; - -static xf86ConfigSymTabRec LayoutTab[] = -{ - {ENDSECTION, "endsection"}, - {SCREEN, "screen"}, - {IDENTIFIER, "identifier"}, - {INACTIVE, "inactive"}, - {INPUTDEVICE, "inputdevice"}, - {OPTION, "option"}, - {-1, ""}, -}; - -static xf86ConfigSymTabRec AdjTab[] = -{ - {RIGHTOF, "rightof"}, - {LEFTOF, "leftof"}, - {ABOVE, "above"}, - {BELOW, "below"}, - {RELATIVE, "relative"}, - {ABSOLUTE, "absolute"}, - {-1, ""}, -}; - -#define CLEANUP xf86freeLayoutList - -XF86ConfLayoutPtr -xf86parseLayoutSection (void) -{ - int has_ident = FALSE; - int token; - parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec) - - while ((token = xf86getToken (LayoutTab)) != ENDSECTION) - { - switch (token) - { - case COMMENT: - ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str); - break; - case IDENTIFIER: - if (xf86getSubToken (&(ptr->lay_comment)) != STRING) - Error (QUOTE_MSG, "Identifier"); - if (has_ident == TRUE) - Error (MULTIPLE_MSG, "Identifier"); - ptr->lay_identifier = val.str; - has_ident = TRUE; - break; - case INACTIVE: - { - XF86ConfInactivePtr iptr; - - iptr = calloc (1, sizeof (XF86ConfInactiveRec)); - iptr->list.next = NULL; - if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { - free (iptr); - Error (INACTIVE_MSG, NULL); - } - iptr->inactive_device_str = val.str; - ptr->lay_inactive_lst = (XF86ConfInactivePtr) - xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr); - } - break; - case SCREEN: - { - XF86ConfAdjacencyPtr aptr; - int absKeyword = 0; - - aptr = calloc (1, sizeof (XF86ConfAdjacencyRec)); - aptr->list.next = NULL; - aptr->adj_scrnum = -1; - aptr->adj_where = CONF_ADJ_OBSOLETE; - aptr->adj_x = 0; - aptr->adj_y = 0; - aptr->adj_refscreen = NULL; - if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER) - aptr->adj_scrnum = val.num; - else - xf86unGetToken (token); - token = xf86getSubToken(&(ptr->lay_comment)); - if (token != STRING) { - free(aptr); - Error (SCREEN_MSG, NULL); - } - aptr->adj_screen_str = val.str; - - token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab); - switch (token) - { - case RIGHTOF: - aptr->adj_where = CONF_ADJ_RIGHTOF; - break; - case LEFTOF: - aptr->adj_where = CONF_ADJ_LEFTOF; - break; - case ABOVE: - aptr->adj_where = CONF_ADJ_ABOVE; - break; - case BELOW: - aptr->adj_where = CONF_ADJ_BELOW; - break; - case RELATIVE: - aptr->adj_where = CONF_ADJ_RELATIVE; - break; - case ABSOLUTE: - aptr->adj_where = CONF_ADJ_ABSOLUTE; - absKeyword = 1; - break; - case EOF_TOKEN: - free(aptr); - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - xf86unGetToken (token); - token = xf86getSubToken(&(ptr->lay_comment)); - if (token == STRING) - aptr->adj_where = CONF_ADJ_OBSOLETE; - else - aptr->adj_where = CONF_ADJ_ABSOLUTE; - } - switch (aptr->adj_where) - { - case CONF_ADJ_ABSOLUTE: - if (absKeyword) - token = xf86getSubToken(&(ptr->lay_comment)); - if (token == NUMBER) - { - aptr->adj_x = val.num; - token = xf86getSubToken(&(ptr->lay_comment)); - if (token != NUMBER) { - free(aptr); - Error(INVALID_SCR_MSG, NULL); - } - aptr->adj_y = val.num; - } else { - if (absKeyword) { - free(aptr); - Error(INVALID_SCR_MSG, NULL); - } else - xf86unGetToken (token); - } - break; - case CONF_ADJ_RIGHTOF: - case CONF_ADJ_LEFTOF: - case CONF_ADJ_ABOVE: - case CONF_ADJ_BELOW: - case CONF_ADJ_RELATIVE: - token = xf86getSubToken(&(ptr->lay_comment)); - if (token != STRING) { - free(aptr); - Error(INVALID_SCR_MSG, NULL); - } - aptr->adj_refscreen = val.str; - if (aptr->adj_where == CONF_ADJ_RELATIVE) - { - token = xf86getSubToken(&(ptr->lay_comment)); - if (token != NUMBER) { - free(aptr); - Error(INVALID_SCR_MSG, NULL); - } - aptr->adj_x = val.num; - token = xf86getSubToken(&(ptr->lay_comment)); - if (token != NUMBER) { - free(aptr); - Error(INVALID_SCR_MSG, NULL); - } - aptr->adj_y = val.num; - } - break; - case CONF_ADJ_OBSOLETE: - /* top */ - aptr->adj_top_str = val.str; - - /* bottom */ - if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { - free(aptr); - Error (SCREEN_MSG, NULL); - } - aptr->adj_bottom_str = val.str; - - /* left */ - if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { - free(aptr); - Error (SCREEN_MSG, NULL); - } - aptr->adj_left_str = val.str; - - /* right */ - if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { - free(aptr); - Error (SCREEN_MSG, NULL); - } - aptr->adj_right_str = val.str; - - } - ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr) - xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr); - } - break; - case INPUTDEVICE: - { - XF86ConfInputrefPtr iptr; - - iptr = calloc (1, sizeof (XF86ConfInputrefRec)); - iptr->list.next = NULL; - iptr->iref_option_lst = NULL; - if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { - free(iptr); - Error (INPUTDEV_MSG, NULL); - } - iptr->iref_inputdev_str = val.str; - while ((token = xf86getSubToken (&(ptr->lay_comment))) == STRING) - { - iptr->iref_option_lst = - xf86addNewOption (iptr->iref_option_lst, val.str, NULL); - } - xf86unGetToken (token); - ptr->lay_input_lst = (XF86ConfInputrefPtr) - xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); - } - break; - case OPTION: - ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst); - break; - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error (INVALID_KEYWORD_MSG, xf86tokenString ()); - break; - } - } - - if (!has_ident) - Error (NO_IDENT_MSG, NULL); - -#ifdef DEBUG - printf ("Layout section parsed\n"); -#endif - - return ptr; -} - -#undef CLEANUP - -void -xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr) -{ - XF86ConfAdjacencyPtr aptr; - XF86ConfInactivePtr iptr; - XF86ConfInputrefPtr inptr; - XF86OptionPtr optr; - - while (ptr) - { - fprintf (cf, "Section \"ServerLayout\"\n"); - if (ptr->lay_comment) - fprintf (cf, "%s", ptr->lay_comment); - if (ptr->lay_identifier) - fprintf (cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier); - - for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next) - { - fprintf (cf, "\tScreen "); - if (aptr->adj_scrnum >= 0) - fprintf (cf, "%2d", aptr->adj_scrnum); - else - fprintf (cf, " "); - fprintf (cf, " \"%s\"", aptr->adj_screen_str); - switch(aptr->adj_where) - { - case CONF_ADJ_OBSOLETE: - fprintf (cf, " \"%s\"", aptr->adj_top_str); - fprintf (cf, " \"%s\"", aptr->adj_bottom_str); - fprintf (cf, " \"%s\"", aptr->adj_right_str); - fprintf (cf, " \"%s\"\n", aptr->adj_left_str); - break; - case CONF_ADJ_ABSOLUTE: - if (aptr->adj_x != -1) - fprintf (cf, " %d %d\n", aptr->adj_x, aptr->adj_y); - else - fprintf (cf, "\n"); - break; - case CONF_ADJ_RIGHTOF: - fprintf (cf, " RightOf \"%s\"\n", aptr->adj_refscreen); - break; - case CONF_ADJ_LEFTOF: - fprintf (cf, " LeftOf \"%s\"\n", aptr->adj_refscreen); - break; - case CONF_ADJ_ABOVE: - fprintf (cf, " Above \"%s\"\n", aptr->adj_refscreen); - break; - case CONF_ADJ_BELOW: - fprintf (cf, " Below \"%s\"\n", aptr->adj_refscreen); - break; - case CONF_ADJ_RELATIVE: - fprintf (cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen, - aptr->adj_x, aptr->adj_y); - break; - } - } - for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next) - fprintf (cf, "\tInactive \"%s\"\n", iptr->inactive_device_str); - for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next) - { - fprintf (cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str); - for (optr = inptr->iref_option_lst; optr; optr = optr->list.next) - { - fprintf(cf, " \"%s\"", optr->opt_name); - } - fprintf(cf, "\n"); - } - xf86printOptionList(cf, ptr->lay_option_lst, 1); - fprintf (cf, "EndSection\n\n"); - ptr = ptr->list.next; - } -} - -static void -xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr) -{ - XF86ConfAdjacencyPtr prev; - - while (ptr) - { - TestFree (ptr->adj_screen_str); - TestFree (ptr->adj_top_str); - TestFree (ptr->adj_bottom_str); - TestFree (ptr->adj_left_str); - TestFree (ptr->adj_right_str); - - prev = ptr; - ptr = ptr->list.next; - free (prev); - } - -} - -static void -xf86freeInputrefList (XF86ConfInputrefPtr ptr) -{ - XF86ConfInputrefPtr prev; - - while (ptr) - { - TestFree (ptr->iref_inputdev_str); - xf86optionListFree (ptr->iref_option_lst); - prev = ptr; - ptr = ptr->list.next; - free (prev); - } - -} - -void -xf86freeLayoutList (XF86ConfLayoutPtr ptr) -{ - XF86ConfLayoutPtr prev; - - while (ptr) - { - TestFree (ptr->lay_identifier); - TestFree (ptr->lay_comment); - xf86freeAdjacencyList (ptr->lay_adjacency_lst); - xf86freeInputrefList (ptr->lay_input_lst); - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -int -xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout) -{ - int count = 0; - XF86ConfInputPtr input = config->conf_input_lst; - XF86ConfInputrefPtr inptr; - - /* add all AutoServerLayout devices to the server layout */ - while (input) - { - if (xf86CheckBoolOption(input->inp_option_lst, "AutoServerLayout", FALSE)) - { - XF86ConfInputrefPtr iref = layout->lay_input_lst; - - /* avoid duplicates if referenced but lists AutoServerLayout too */ - while (iref) - { - if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0) - break; - iref = iref->list.next; - } - - if (!iref) - { - XF86ConfInputrefPtr iptr; - iptr = calloc(1, sizeof(XF86ConfInputrefRec)); - iptr->iref_inputdev_str = input->inp_identifier; - layout->lay_input_lst = (XF86ConfInputrefPtr) - xf86addListItem((glp)layout->lay_input_lst, (glp)iptr); - count++; - } - } - input = input->list.next; - } - - inptr = layout->lay_input_lst; - while (inptr) - { - input = xf86findInput (inptr->iref_inputdev_str, - config->conf_input_lst); - if (!input) - { - xf86validationError (UNDEFINED_INPUT_MSG, - inptr->iref_inputdev_str, layout->lay_identifier); - return -1; - } - else - inptr->iref_inputdev = input; - inptr = inptr->list.next; - } - - return count; -} - -int -xf86validateLayout (XF86ConfigPtr p) -{ - XF86ConfLayoutPtr layout = p->conf_layout_lst; - XF86ConfAdjacencyPtr adj; - XF86ConfInactivePtr iptr; - XF86ConfScreenPtr screen; - XF86ConfDevicePtr device; - - while (layout) - { - adj = layout->lay_adjacency_lst; - while (adj) - { - /* the first one can't be "" but all others can */ - screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst); - if (!screen) - { - xf86validationError (UNDEFINED_SCREEN_MSG, - adj->adj_screen_str, layout->lay_identifier); - return (FALSE); - } - else - adj->adj_screen = screen; - - adj = adj->list.next; - } - iptr = layout->lay_inactive_lst; - while (iptr) - { - device = xf86findDevice (iptr->inactive_device_str, - p->conf_device_lst); - if (!device) - { - xf86validationError (UNDEFINED_DEVICE_LAY_MSG, - iptr->inactive_device_str, layout->lay_identifier); - return (FALSE); - } - else - iptr->inactive_device = device; - iptr = iptr->list.next; - } - - if (xf86layoutAddInputDevices(p, layout) == -1) - return FALSE; - - layout = layout->list.next; - } - return (TRUE); -} - -XF86ConfLayoutPtr -xf86findLayout (const char *name, XF86ConfLayoutPtr list) -{ - while (list) - { - if (xf86nameCompare (list->lay_identifier, name) == 0) - return (list); - list = list->list.next; - } - return (NULL); -} - +/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+#include <string.h>
+
+
+/* Needed for auto server layout */
+extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec LayoutTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {SCREEN, "screen"},
+ {IDENTIFIER, "identifier"},
+ {INACTIVE, "inactive"},
+ {INPUTDEVICE, "inputdevice"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec AdjTab[] =
+{
+ {RIGHTOF, "rightof"},
+ {LEFTOF, "leftof"},
+ {ABOVE, "above"},
+ {BELOW, "below"},
+ {RELATIVE, "relative"},
+ {ABSOLUTE, "absolute"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeLayoutList
+
+XF86ConfLayoutPtr
+xf86parseLayoutSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
+
+ while ((token = xf86getToken (LayoutTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->lay_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case INACTIVE:
+ {
+ XF86ConfInactivePtr iptr;
+
+ iptr = calloc (1, sizeof (XF86ConfInactiveRec));
+ iptr->list.next = NULL;
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free (iptr);
+ Error (INACTIVE_MSG, NULL);
+ }
+ iptr->inactive_device_str = val.str;
+ ptr->lay_inactive_lst = (XF86ConfInactivePtr)
+ xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr);
+ }
+ break;
+ case SCREEN:
+ {
+ XF86ConfAdjacencyPtr aptr;
+ int absKeyword = 0;
+
+ aptr = calloc (1, sizeof (XF86ConfAdjacencyRec));
+ aptr->list.next = NULL;
+ aptr->adj_scrnum = -1;
+ aptr->adj_where = CONF_ADJ_OBSOLETE;
+ aptr->adj_x = 0;
+ aptr->adj_y = 0;
+ aptr->adj_refscreen = NULL;
+ if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER)
+ aptr->adj_scrnum = val.num;
+ else
+ xf86unGetToken (token);
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_screen_str = val.str;
+
+ token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
+ switch (token)
+ {
+ case RIGHTOF:
+ aptr->adj_where = CONF_ADJ_RIGHTOF;
+ break;
+ case LEFTOF:
+ aptr->adj_where = CONF_ADJ_LEFTOF;
+ break;
+ case ABOVE:
+ aptr->adj_where = CONF_ADJ_ABOVE;
+ break;
+ case BELOW:
+ aptr->adj_where = CONF_ADJ_BELOW;
+ break;
+ case RELATIVE:
+ aptr->adj_where = CONF_ADJ_RELATIVE;
+ break;
+ case ABSOLUTE:
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ absKeyword = 1;
+ break;
+ case EOF_TOKEN:
+ free(aptr);
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ xf86unGetToken (token);
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token == STRING)
+ aptr->adj_where = CONF_ADJ_OBSOLETE;
+ else
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ }
+ switch (aptr->adj_where)
+ {
+ case CONF_ADJ_ABSOLUTE:
+ if (absKeyword)
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token == NUMBER)
+ {
+ aptr->adj_x = val.num;
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_y = val.num;
+ } else {
+ if (absKeyword) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ } else
+ xf86unGetToken (token);
+ }
+ break;
+ case CONF_ADJ_RIGHTOF:
+ case CONF_ADJ_LEFTOF:
+ case CONF_ADJ_ABOVE:
+ case CONF_ADJ_BELOW:
+ case CONF_ADJ_RELATIVE:
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != STRING) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_refscreen = val.str;
+ if (aptr->adj_where == CONF_ADJ_RELATIVE)
+ {
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_x = val.num;
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_y = val.num;
+ }
+ break;
+ case CONF_ADJ_OBSOLETE:
+ /* top */
+ aptr->adj_top_str = val.str;
+
+ /* bottom */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_bottom_str = val.str;
+
+ /* left */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_left_str = val.str;
+
+ /* right */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_right_str = val.str;
+
+ }
+ ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
+ xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr);
+ }
+ break;
+ case INPUTDEVICE:
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = calloc (1, sizeof (XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(iptr);
+ Error (INPUTDEV_MSG, NULL);
+ }
+ iptr->iref_inputdev_str = val.str;
+ while ((token = xf86getSubToken (&(ptr->lay_comment))) == STRING)
+ {
+ iptr->iref_option_lst =
+ xf86addNewOption (iptr->iref_option_lst, val.str, NULL);
+ }
+ xf86unGetToken (token);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+ break;
+ case OPTION:
+ ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Layout section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr)
+{
+ XF86ConfAdjacencyPtr aptr;
+ XF86ConfInactivePtr iptr;
+ XF86ConfInputrefPtr inptr;
+ XF86OptionPtr optr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"ServerLayout\"\n");
+ if (ptr->lay_comment)
+ fprintf (cf, "%s", ptr->lay_comment);
+ if (ptr->lay_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier);
+
+ for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next)
+ {
+ fprintf (cf, "\tScreen ");
+ if (aptr->adj_scrnum >= 0)
+ fprintf (cf, "%2d", aptr->adj_scrnum);
+ else
+ fprintf (cf, " ");
+ fprintf (cf, " \"%s\"", aptr->adj_screen_str);
+ switch(aptr->adj_where)
+ {
+ case CONF_ADJ_OBSOLETE:
+ fprintf (cf, " \"%s\"", aptr->adj_top_str);
+ fprintf (cf, " \"%s\"", aptr->adj_bottom_str);
+ fprintf (cf, " \"%s\"", aptr->adj_right_str);
+ fprintf (cf, " \"%s\"\n", aptr->adj_left_str);
+ break;
+ case CONF_ADJ_ABSOLUTE:
+ if (aptr->adj_x != -1)
+ fprintf (cf, " %d %d\n", aptr->adj_x, aptr->adj_y);
+ else
+ fprintf (cf, "\n");
+ break;
+ case CONF_ADJ_RIGHTOF:
+ fprintf (cf, " RightOf \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_LEFTOF:
+ fprintf (cf, " LeftOf \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_ABOVE:
+ fprintf (cf, " Above \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_BELOW:
+ fprintf (cf, " Below \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_RELATIVE:
+ fprintf (cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen,
+ aptr->adj_x, aptr->adj_y);
+ break;
+ }
+ }
+ for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next)
+ fprintf (cf, "\tInactive \"%s\"\n", iptr->inactive_device_str);
+ for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next)
+ {
+ fprintf (cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str);
+ for (optr = inptr->iref_option_lst; optr; optr = optr->list.next)
+ {
+ fprintf(cf, " \"%s\"", optr->opt_name);
+ }
+ fprintf(cf, "\n");
+ }
+ xf86printOptionList(cf, ptr->lay_option_lst, 1);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+static void
+xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr)
+{
+ XF86ConfAdjacencyPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->adj_screen_str);
+ TestFree (ptr->adj_top_str);
+ TestFree (ptr->adj_bottom_str);
+ TestFree (ptr->adj_left_str);
+ TestFree (ptr->adj_right_str);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+
+}
+
+static void
+xf86freeInputrefList (XF86ConfInputrefPtr ptr)
+{
+ XF86ConfInputrefPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->iref_inputdev_str);
+ xf86optionListFree (ptr->iref_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+
+}
+
+void
+xf86freeLayoutList (XF86ConfLayoutPtr ptr)
+{
+ XF86ConfLayoutPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->lay_identifier);
+ TestFree (ptr->lay_comment);
+ xf86freeAdjacencyList (ptr->lay_adjacency_lst);
+ xf86freeInputrefList (ptr->lay_input_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+int
+xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout)
+{
+ int count = 0;
+ XF86ConfInputPtr input = config->conf_input_lst;
+ XF86ConfInputrefPtr inptr;
+
+ /* add all AutoServerLayout devices to the server layout */
+ while (input)
+ {
+ if (xf86CheckBoolOption(input->inp_option_lst, "AutoServerLayout", FALSE))
+ {
+ XF86ConfInputrefPtr iref = layout->lay_input_lst;
+
+ /* avoid duplicates if referenced but lists AutoServerLayout too */
+ while (iref)
+ {
+ if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0)
+ break;
+ iref = iref->list.next;
+ }
+
+ if (!iref)
+ {
+ XF86ConfInputrefPtr iptr;
+ iptr = calloc(1, sizeof(XF86ConfInputrefRec));
+ iptr->iref_inputdev_str = input->inp_identifier;
+ layout->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem((glp)layout->lay_input_lst, (glp)iptr);
+ count++;
+ }
+ }
+ input = input->list.next;
+ }
+
+ inptr = layout->lay_input_lst;
+ while (inptr)
+ {
+ input = xf86findInput (inptr->iref_inputdev_str,
+ config->conf_input_lst);
+ if (!input)
+ {
+ xf86validationError (UNDEFINED_INPUT_MSG,
+ inptr->iref_inputdev_str, layout->lay_identifier);
+ return -1;
+ }
+ else
+ inptr->iref_inputdev = input;
+ inptr = inptr->list.next;
+ }
+
+ return count;
+}
+
+int
+xf86validateLayout (XF86ConfigPtr p)
+{
+ XF86ConfLayoutPtr layout = p->conf_layout_lst;
+ XF86ConfAdjacencyPtr adj;
+ XF86ConfInactivePtr iptr;
+ XF86ConfScreenPtr screen;
+ XF86ConfDevicePtr device;
+
+ while (layout)
+ {
+ adj = layout->lay_adjacency_lst;
+ while (adj)
+ {
+ /* the first one can't be "" but all others can */
+ screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst);
+ if (!screen)
+ {
+ xf86validationError (UNDEFINED_SCREEN_MSG,
+ adj->adj_screen_str, layout->lay_identifier);
+ return FALSE;
+ }
+ else
+ adj->adj_screen = screen;
+
+ adj = adj->list.next;
+ }
+ iptr = layout->lay_inactive_lst;
+ while (iptr)
+ {
+ device = xf86findDevice (iptr->inactive_device_str,
+ p->conf_device_lst);
+ if (!device)
+ {
+ xf86validationError (UNDEFINED_DEVICE_LAY_MSG,
+ iptr->inactive_device_str, layout->lay_identifier);
+ return FALSE;
+ }
+ else
+ iptr->inactive_device = device;
+ iptr = iptr->list.next;
+ }
+
+ if (xf86layoutAddInputDevices(p, layout) == -1)
+ return FALSE;
+
+ layout = layout->list.next;
+ }
+ return TRUE;
+}
+
+XF86ConfLayoutPtr
+xf86findLayout (const char *name, XF86ConfLayoutPtr list)
+{
+ while (list)
+ {
+ if (xf86nameCompare (list->lay_identifier, name) == 0)
+ return list;
+ list = list->list.next;
+ }
+ return NULL;
+}
+
diff --git a/xorg-server/hw/xfree86/parser/Monitor.c b/xorg-server/hw/xfree86/parser/Monitor.c index 50de091fc..8ad7c2e79 100644 --- a/xorg-server/hw/xfree86/parser/Monitor.c +++ b/xorg-server/hw/xfree86/parser/Monitor.c @@ -1,904 +1,904 @@ -/* - * - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* View/edit this file with tab stops set to 4 */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86Parser.h" -#include "xf86tokens.h" -#include "Configint.h" - -extern LexRec val; - -static xf86ConfigSymTabRec MonitorTab[] = -{ - {ENDSECTION, "endsection"}, - {IDENTIFIER, "identifier"}, - {VENDOR, "vendorname"}, - {MODEL, "modelname"}, - {USEMODES, "usemodes"}, - {MODELINE, "modeline"}, - {DISPLAYSIZE, "displaysize"}, - {HORIZSYNC, "horizsync"}, - {VERTREFRESH, "vertrefresh"}, - {MODE, "mode"}, - {GAMMA, "gamma"}, - {OPTION, "option"}, - {-1, ""}, -}; - -static xf86ConfigSymTabRec ModesTab[] = -{ - {ENDSECTION, "endsection"}, - {IDENTIFIER, "identifier"}, - {MODELINE, "modeline"}, - {MODE, "mode"}, - {-1, ""}, -}; - -static xf86ConfigSymTabRec TimingTab[] = -{ - {TT_INTERLACE, "interlace"}, - {TT_PHSYNC, "+hsync"}, - {TT_NHSYNC, "-hsync"}, - {TT_PVSYNC, "+vsync"}, - {TT_NVSYNC, "-vsync"}, - {TT_CSYNC, "composite"}, - {TT_PCSYNC, "+csync"}, - {TT_NCSYNC, "-csync"}, - {TT_DBLSCAN, "doublescan"}, - {TT_HSKEW, "hskew"}, - {TT_BCAST, "bcast"}, - {TT_VSCAN, "vscan"}, - {TT_CUSTOM, "CUSTOM"}, - {-1, ""}, -}; - -static xf86ConfigSymTabRec ModeTab[] = -{ - {DOTCLOCK, "dotclock"}, - {HTIMINGS, "htimings"}, - {VTIMINGS, "vtimings"}, - {FLAGS, "flags"}, - {HSKEW, "hskew"}, - {BCAST, "bcast"}, - {VSCAN, "vscan"}, - {ENDMODE, "endmode"}, - {-1, ""}, -}; - -#define CLEANUP xf86freeModeLineList - -static void -xf86freeModeLineList (XF86ConfModeLinePtr ptr) -{ - XF86ConfModeLinePtr prev; - while (ptr) - { - TestFree (ptr->ml_identifier); - TestFree (ptr->ml_comment); - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -static XF86ConfModeLinePtr -xf86parseModeLine (void) -{ - int token; - parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec) - - /* Identifier */ - if (xf86getSubToken (&(ptr->ml_comment)) != STRING) - Error ("ModeLine identifier expected", NULL); - ptr->ml_identifier = val.str; - - /* DotClock */ - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error ("ModeLine dotclock expected", NULL); - ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5); - - /* HDisplay */ - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error ("ModeLine Hdisplay expected", NULL); - ptr->ml_hdisplay = val.num; - - /* HSyncStart */ - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error ("ModeLine HSyncStart expected", NULL); - ptr->ml_hsyncstart = val.num; - - /* HSyncEnd */ - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error ("ModeLine HSyncEnd expected", NULL); - ptr->ml_hsyncend = val.num; - - /* HTotal */ - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error ("ModeLine HTotal expected", NULL); - ptr->ml_htotal = val.num; - - /* VDisplay */ - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error ("ModeLine Vdisplay expected", NULL); - ptr->ml_vdisplay = val.num; - - /* VSyncStart */ - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error ("ModeLine VSyncStart expected", NULL); - ptr->ml_vsyncstart = val.num; - - /* VSyncEnd */ - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error ("ModeLine VSyncEnd expected", NULL); - ptr->ml_vsyncend = val.num; - - /* VTotal */ - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error ("ModeLine VTotal expected", NULL); - ptr->ml_vtotal = val.num; - - token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab); - while ((token == TT_INTERLACE) || (token == TT_PHSYNC) || - (token == TT_NHSYNC) || (token == TT_PVSYNC) || - (token == TT_NVSYNC) || (token == TT_CSYNC) || - (token == TT_PCSYNC) || (token == TT_NCSYNC) || - (token == TT_DBLSCAN) || (token == TT_HSKEW) || - (token == TT_VSCAN) || (token == TT_BCAST)) - { - switch (token) - { - - case TT_INTERLACE: - ptr->ml_flags |= XF86CONF_INTERLACE; - break; - case TT_PHSYNC: - ptr->ml_flags |= XF86CONF_PHSYNC; - break; - case TT_NHSYNC: - ptr->ml_flags |= XF86CONF_NHSYNC; - break; - case TT_PVSYNC: - ptr->ml_flags |= XF86CONF_PVSYNC; - break; - case TT_NVSYNC: - ptr->ml_flags |= XF86CONF_NVSYNC; - break; - case TT_CSYNC: - ptr->ml_flags |= XF86CONF_CSYNC; - break; - case TT_PCSYNC: - ptr->ml_flags |= XF86CONF_PCSYNC; - break; - case TT_NCSYNC: - ptr->ml_flags |= XF86CONF_NCSYNC; - break; - case TT_DBLSCAN: - ptr->ml_flags |= XF86CONF_DBLSCAN; - break; - case TT_HSKEW: - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error (NUMBER_MSG, "Hskew"); - ptr->ml_hskew = val.num; - ptr->ml_flags |= XF86CONF_HSKEW; - break; - case TT_BCAST: - ptr->ml_flags |= XF86CONF_BCAST; - break; - case TT_VSCAN: - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error (NUMBER_MSG, "Vscan"); - ptr->ml_vscan = val.num; - ptr->ml_flags |= XF86CONF_VSCAN; - break; - case TT_CUSTOM: - ptr->ml_flags |= XF86CONF_CUSTOM; - break; - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error (INVALID_KEYWORD_MSG, xf86tokenString ()); - break; - } - token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab); - } - xf86unGetToken (token); - -#ifdef DEBUG - printf ("ModeLine parsed\n"); -#endif - return (ptr); -} - -static XF86ConfModeLinePtr -xf86parseVerboseMode (void) -{ - int token, token2; - int had_dotclock = 0, had_htimings = 0, had_vtimings = 0; - parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec) - - if (xf86getSubToken (&(ptr->ml_comment)) != STRING) - Error ("Mode name expected", NULL); - ptr->ml_identifier = val.str; - while ((token = xf86getToken (ModeTab)) != ENDMODE) - { - switch (token) - { - case COMMENT: - ptr->ml_comment = xf86addComment(ptr->ml_comment, val.str); - break; - case DOTCLOCK: - if ((token = xf86getSubToken (&(ptr->ml_comment))) != NUMBER) - Error (NUMBER_MSG, "DotClock"); - ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5); - had_dotclock = 1; - break; - case HTIMINGS: - if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) - ptr->ml_hdisplay = val.num; - else - Error ("Horizontal display expected", NULL); - - if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) - ptr->ml_hsyncstart = val.num; - else - Error ("Horizontal sync start expected", NULL); - - if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) - ptr->ml_hsyncend = val.num; - else - Error ("Horizontal sync end expected", NULL); - - if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) - ptr->ml_htotal = val.num; - else - Error ("Horizontal total expected", NULL); - had_htimings = 1; - break; - case VTIMINGS: - if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) - ptr->ml_vdisplay = val.num; - else - Error ("Vertical display expected", NULL); - - if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) - ptr->ml_vsyncstart = val.num; - else - Error ("Vertical sync start expected", NULL); - - if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) - ptr->ml_vsyncend = val.num; - else - Error ("Vertical sync end expected", NULL); - - if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) - ptr->ml_vtotal = val.num; - else - Error ("Vertical total expected", NULL); - had_vtimings = 1; - break; - case FLAGS: - token = xf86getSubToken (&(ptr->ml_comment)); - if (token != STRING) - Error (QUOTE_MSG, "Flags"); - while (token == STRING) - { - token2 = xf86getStringToken (TimingTab); - switch (token2) - { - case TT_INTERLACE: - ptr->ml_flags |= XF86CONF_INTERLACE; - break; - case TT_PHSYNC: - ptr->ml_flags |= XF86CONF_PHSYNC; - break; - case TT_NHSYNC: - ptr->ml_flags |= XF86CONF_NHSYNC; - break; - case TT_PVSYNC: - ptr->ml_flags |= XF86CONF_PVSYNC; - break; - case TT_NVSYNC: - ptr->ml_flags |= XF86CONF_NVSYNC; - break; - case TT_CSYNC: - ptr->ml_flags |= XF86CONF_CSYNC; - break; - case TT_PCSYNC: - ptr->ml_flags |= XF86CONF_PCSYNC; - break; - case TT_NCSYNC: - ptr->ml_flags |= XF86CONF_NCSYNC; - break; - case TT_DBLSCAN: - ptr->ml_flags |= XF86CONF_DBLSCAN; - break; - case TT_CUSTOM: - ptr->ml_flags |= XF86CONF_CUSTOM; - break; - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error ("Unknown flag string", NULL); - break; - } - token = xf86getSubToken (&(ptr->ml_comment)); - } - xf86unGetToken (token); - break; - case HSKEW: - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error ("Horizontal skew expected", NULL); - ptr->ml_flags |= XF86CONF_HSKEW; - ptr->ml_hskew = val.num; - break; - case VSCAN: - if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) - Error ("Vertical scan count expected", NULL); - ptr->ml_flags |= XF86CONF_VSCAN; - ptr->ml_vscan = val.num; - break; - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error ("Unexepcted token in verbose \"Mode\" entry\n", NULL); - } - } - if (!had_dotclock) - Error ("the dotclock is missing", NULL); - if (!had_htimings) - Error ("the horizontal timings are missing", NULL); - if (!had_vtimings) - Error ("the vertical timings are missing", NULL); - -#ifdef DEBUG - printf ("Verbose Mode parsed\n"); -#endif - return (ptr); -} - -#undef CLEANUP - -#define CLEANUP xf86freeMonitorList - -XF86ConfMonitorPtr -xf86parseMonitorSection (void) -{ - int has_ident = FALSE; - int token; - parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec) - - while ((token = xf86getToken (MonitorTab)) != ENDSECTION) - { - switch (token) - { - case COMMENT: - ptr->mon_comment = xf86addComment(ptr->mon_comment, val.str); - break; - case IDENTIFIER: - if (xf86getSubToken (&(ptr->mon_comment)) != STRING) - Error (QUOTE_MSG, "Identifier"); - if (has_ident == TRUE) - Error (MULTIPLE_MSG, "Identifier"); - ptr->mon_identifier = val.str; - has_ident = TRUE; - break; - case VENDOR: - if (xf86getSubToken (&(ptr->mon_comment)) != STRING) - Error (QUOTE_MSG, "Vendor"); - ptr->mon_vendor = val.str; - break; - case MODEL: - if (xf86getSubToken (&(ptr->mon_comment)) != STRING) - Error (QUOTE_MSG, "ModelName"); - ptr->mon_modelname = val.str; - break; - case MODE: - HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode, - XF86ConfModeLinePtr); - break; - case MODELINE: - HANDLE_LIST (mon_modeline_lst, xf86parseModeLine, - XF86ConfModeLinePtr); - break; - case DISPLAYSIZE: - if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) - Error (DISPLAYSIZE_MSG, NULL); - ptr->mon_width = val.realnum; - if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) - Error (DISPLAYSIZE_MSG, NULL); - ptr->mon_height = val.realnum; - break; - - case HORIZSYNC: - if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) - Error (HORIZSYNC_MSG, NULL); - do { - if (ptr->mon_n_hsync >= CONF_MAX_HSYNC) - Error ("Sorry. Too many horizontal sync intervals.", NULL); - ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum; - switch (token = xf86getSubToken (&(ptr->mon_comment))) - { - case COMMA: - ptr->mon_hsync[ptr->mon_n_hsync].hi = - ptr->mon_hsync[ptr->mon_n_hsync].lo; - break; - case DASH: - if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER || - (float)val.realnum < ptr->mon_hsync[ptr->mon_n_hsync].lo) - Error (HORIZSYNC_MSG, NULL); - ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum; - if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA) - break; - ptr->mon_n_hsync++; - goto HorizDone; - default: - /* We cannot currently know if a '\n' was found, - * or this is a real error - */ - ptr->mon_hsync[ptr->mon_n_hsync].hi = - ptr->mon_hsync[ptr->mon_n_hsync].lo; - ptr->mon_n_hsync++; - goto HorizDone; - } - ptr->mon_n_hsync++; - } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER); -HorizDone: - xf86unGetToken (token); - break; - - case VERTREFRESH: - if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) - Error (VERTREFRESH_MSG, NULL); - do { - ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum; - switch (token = xf86getSubToken (&(ptr->mon_comment))) - { - case COMMA: - ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = - ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo; - break; - case DASH: - if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER || - (float)val.realnum < ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo) - Error (VERTREFRESH_MSG, NULL); - ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum; - if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA) - break; - ptr->mon_n_vrefresh++; - goto VertDone; - default: - /* We cannot currently know if a '\n' was found, - * or this is a real error - */ - ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = - ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo; - ptr->mon_n_vrefresh++; - goto VertDone; - } - if (ptr->mon_n_vrefresh >= CONF_MAX_VREFRESH) - Error ("Sorry. Too many vertical refresh intervals.", NULL); - ptr->mon_n_vrefresh++; - } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER); -VertDone: - xf86unGetToken (token); - break; - - case GAMMA: - if( xf86getSubToken (&(ptr->mon_comment)) != NUMBER ) - { - Error (INVALID_GAMMA_MSG, NULL); - } - else - { - ptr->mon_gamma_red = ptr->mon_gamma_green = - ptr->mon_gamma_blue = val.realnum; - if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER ) - { - ptr->mon_gamma_green = val.realnum; - if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER ) - { - ptr->mon_gamma_blue = val.realnum; - } - else - { - Error (INVALID_GAMMA_MSG, NULL); - } - } - else - xf86unGetToken (token); - } - break; - case OPTION: - ptr->mon_option_lst = xf86parseOption(ptr->mon_option_lst); - break; - case USEMODES: - { - XF86ConfModesLinkPtr mptr; - - if ((token = xf86getSubToken (&(ptr->mon_comment))) != STRING) - Error (QUOTE_MSG, "UseModes"); - - /* add to the end of the list of modes sections - referenced here */ - mptr = calloc (1, sizeof (XF86ConfModesLinkRec)); - mptr->list.next = NULL; - mptr->ml_modes_str = val.str; - mptr->ml_modes = NULL; - ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr) - xf86addListItem((GenericListPtr)ptr->mon_modes_sect_lst, - (GenericListPtr)mptr); - } - break; - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ()); - CLEANUP (ptr); - return NULL; - break; - } - } - - if (!has_ident) - Error (NO_IDENT_MSG, NULL); - -#ifdef DEBUG - printf ("Monitor section parsed\n"); -#endif - return ptr; -} - -#undef CLEANUP -#define CLEANUP xf86freeModesList - -XF86ConfModesPtr -xf86parseModesSection (void) -{ - int has_ident = FALSE; - int token; - parsePrologue (XF86ConfModesPtr, XF86ConfModesRec) - - while ((token = xf86getToken (ModesTab)) != ENDSECTION) - { - switch (token) - { - case COMMENT: - ptr->modes_comment = xf86addComment(ptr->modes_comment, val.str); - break; - case IDENTIFIER: - if (xf86getSubToken (&(ptr->modes_comment)) != STRING) - Error (QUOTE_MSG, "Identifier"); - if (has_ident == TRUE) - Error (MULTIPLE_MSG, "Identifier"); - ptr->modes_identifier = val.str; - has_ident = TRUE; - break; - case MODE: - HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode, - XF86ConfModeLinePtr); - break; - case MODELINE: - HANDLE_LIST (mon_modeline_lst, xf86parseModeLine, - XF86ConfModeLinePtr); - break; - default: - xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ()); - CLEANUP (ptr); - return NULL; - break; - } - } - - if (!has_ident) - Error (NO_IDENT_MSG, NULL); - -#ifdef DEBUG - printf ("Modes section parsed\n"); -#endif - return ptr; -} - -#undef CLEANUP - -void -xf86printMonitorSection (FILE * cf, XF86ConfMonitorPtr ptr) -{ - int i; - XF86ConfModeLinePtr mlptr; - XF86ConfModesLinkPtr mptr; - - while (ptr) - { - mptr = ptr->mon_modes_sect_lst; - fprintf (cf, "Section \"Monitor\"\n"); - if (ptr->mon_comment) - fprintf (cf, "%s", ptr->mon_comment); - if (ptr->mon_identifier) - fprintf (cf, "\tIdentifier \"%s\"\n", ptr->mon_identifier); - if (ptr->mon_vendor) - fprintf (cf, "\tVendorName \"%s\"\n", ptr->mon_vendor); - if (ptr->mon_modelname) - fprintf (cf, "\tModelName \"%s\"\n", ptr->mon_modelname); - while (mptr) { - fprintf (cf, "\tUseModes \"%s\"\n", mptr->ml_modes_str); - mptr = mptr->list.next; - } - if (ptr->mon_width) - fprintf (cf, "\tDisplaySize %d\t%d\n", - ptr->mon_width, - ptr->mon_height); - for (i = 0; i < ptr->mon_n_hsync; i++) - { - fprintf (cf, "\tHorizSync %2.1f - %2.1f\n", - ptr->mon_hsync[i].lo, - ptr->mon_hsync[i].hi); - } - for (i = 0; i < ptr->mon_n_vrefresh; i++) - { - fprintf (cf, "\tVertRefresh %2.1f - %2.1f\n", - ptr->mon_vrefresh[i].lo, - ptr->mon_vrefresh[i].hi); - } - if (ptr->mon_gamma_red) { - if (ptr->mon_gamma_red == ptr->mon_gamma_green - && ptr->mon_gamma_red == ptr->mon_gamma_blue) - { - fprintf (cf, "\tGamma %.4g\n", - ptr->mon_gamma_red); - } else { - fprintf (cf, "\tGamma %.4g %.4g %.4g\n", - ptr->mon_gamma_red, - ptr->mon_gamma_green, - ptr->mon_gamma_blue); - } - } - for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next) - { - fprintf (cf, "\tModeLine \"%s\" %2.1f ", - mlptr->ml_identifier, mlptr->ml_clock / 1000.0); - fprintf (cf, "%d %d %d %d %d %d %d %d", - mlptr->ml_hdisplay, mlptr->ml_hsyncstart, - mlptr->ml_hsyncend, mlptr->ml_htotal, - mlptr->ml_vdisplay, mlptr->ml_vsyncstart, - mlptr->ml_vsyncend, mlptr->ml_vtotal); - if (mlptr->ml_flags & XF86CONF_PHSYNC) - fprintf (cf, " +hsync"); - if (mlptr->ml_flags & XF86CONF_NHSYNC) - fprintf (cf, " -hsync"); - if (mlptr->ml_flags & XF86CONF_PVSYNC) - fprintf (cf, " +vsync"); - if (mlptr->ml_flags & XF86CONF_NVSYNC) - fprintf (cf, " -vsync"); - if (mlptr->ml_flags & XF86CONF_INTERLACE) - fprintf (cf, " interlace"); - if (mlptr->ml_flags & XF86CONF_CSYNC) - fprintf (cf, " composite"); - if (mlptr->ml_flags & XF86CONF_PCSYNC) - fprintf (cf, " +csync"); - if (mlptr->ml_flags & XF86CONF_NCSYNC) - fprintf (cf, " -csync"); - if (mlptr->ml_flags & XF86CONF_DBLSCAN) - fprintf (cf, " doublescan"); - if (mlptr->ml_flags & XF86CONF_HSKEW) - fprintf (cf, " hskew %d", mlptr->ml_hskew); - if (mlptr->ml_flags & XF86CONF_BCAST) - fprintf (cf, " bcast"); - fprintf (cf, "\n"); - } - xf86printOptionList(cf, ptr->mon_option_lst, 1); - fprintf (cf, "EndSection\n\n"); - ptr = ptr->list.next; - } -} - -void -xf86printModesSection (FILE * cf, XF86ConfModesPtr ptr) -{ - XF86ConfModeLinePtr mlptr; - - while (ptr) - { - fprintf (cf, "Section \"Modes\"\n"); - if (ptr->modes_comment) - fprintf (cf, "%s", ptr->modes_comment); - if (ptr->modes_identifier) - fprintf (cf, "\tIdentifier \"%s\"\n", ptr->modes_identifier); - for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next) - { - fprintf (cf, "\tModeLine \"%s\" %2.1f ", - mlptr->ml_identifier, mlptr->ml_clock / 1000.0); - fprintf (cf, "%d %d %d %d %d %d %d %d", - mlptr->ml_hdisplay, mlptr->ml_hsyncstart, - mlptr->ml_hsyncend, mlptr->ml_htotal, - mlptr->ml_vdisplay, mlptr->ml_vsyncstart, - mlptr->ml_vsyncend, mlptr->ml_vtotal); - if (mlptr->ml_flags & XF86CONF_PHSYNC) - fprintf (cf, " +hsync"); - if (mlptr->ml_flags & XF86CONF_NHSYNC) - fprintf (cf, " -hsync"); - if (mlptr->ml_flags & XF86CONF_PVSYNC) - fprintf (cf, " +vsync"); - if (mlptr->ml_flags & XF86CONF_NVSYNC) - fprintf (cf, " -vsync"); - if (mlptr->ml_flags & XF86CONF_INTERLACE) - fprintf (cf, " interlace"); - if (mlptr->ml_flags & XF86CONF_CSYNC) - fprintf (cf, " composite"); - if (mlptr->ml_flags & XF86CONF_PCSYNC) - fprintf (cf, " +csync"); - if (mlptr->ml_flags & XF86CONF_NCSYNC) - fprintf (cf, " -csync"); - if (mlptr->ml_flags & XF86CONF_DBLSCAN) - fprintf (cf, " doublescan"); - if (mlptr->ml_flags & XF86CONF_HSKEW) - fprintf (cf, " hskew %d", mlptr->ml_hskew); - if (mlptr->ml_flags & XF86CONF_VSCAN) - fprintf (cf, " vscan %d", mlptr->ml_vscan); - if (mlptr->ml_flags & XF86CONF_BCAST) - fprintf (cf, " bcast"); - if (mlptr->ml_comment) - fprintf (cf, "%s", mlptr->ml_comment); - else - fprintf (cf, "\n"); - } - fprintf (cf, "EndSection\n\n"); - ptr = ptr->list.next; - } -} - -void -xf86freeMonitorList (XF86ConfMonitorPtr ptr) -{ - XF86ConfMonitorPtr prev; - - while (ptr) - { - TestFree (ptr->mon_identifier); - TestFree (ptr->mon_vendor); - TestFree (ptr->mon_modelname); - TestFree (ptr->mon_comment); - xf86optionListFree (ptr->mon_option_lst); - xf86freeModeLineList (ptr->mon_modeline_lst); - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -void -xf86freeModesList (XF86ConfModesPtr ptr) -{ - XF86ConfModesPtr prev; - - while (ptr) - { - TestFree (ptr->modes_identifier); - TestFree (ptr->modes_comment); - xf86freeModeLineList (ptr->mon_modeline_lst); - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -XF86ConfMonitorPtr -xf86findMonitor (const char *ident, XF86ConfMonitorPtr p) -{ - while (p) - { - if (xf86nameCompare (ident, p->mon_identifier) == 0) - return (p); - - p = p->list.next; - } - return (NULL); -} - -XF86ConfModesPtr -xf86findModes (const char *ident, XF86ConfModesPtr p) -{ - while (p) - { - if (xf86nameCompare (ident, p->modes_identifier) == 0) - return (p); - - p = p->list.next; - } - return (NULL); -} - -XF86ConfModeLinePtr -xf86findModeLine (const char *ident, XF86ConfModeLinePtr p) -{ - while (p) - { - if (xf86nameCompare (ident, p->ml_identifier) == 0) - return (p); - - p = p->list.next; - } - return (NULL); -} - -int -xf86validateMonitor (XF86ConfigPtr p, XF86ConfScreenPtr screen) -{ - XF86ConfMonitorPtr monitor = screen->scrn_monitor; - XF86ConfModesLinkPtr modeslnk = monitor->mon_modes_sect_lst; - XF86ConfModesPtr modes; - while(modeslnk) - { - modes = xf86findModes (modeslnk->ml_modes_str, p->conf_modes_lst); - if (!modes) - { - xf86validationError (UNDEFINED_MODES_MSG, - modeslnk->ml_modes_str, - screen->scrn_identifier); - return (FALSE); - } - modeslnk->ml_modes = modes; - modeslnk = modeslnk->list.next; - } - return (TRUE); -} +/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec MonitorTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {MODEL, "modelname"},
+ {USEMODES, "usemodes"},
+ {MODELINE, "modeline"},
+ {DISPLAYSIZE, "displaysize"},
+ {HORIZSYNC, "horizsync"},
+ {VERTREFRESH, "vertrefresh"},
+ {MODE, "mode"},
+ {GAMMA, "gamma"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec ModesTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {MODELINE, "modeline"},
+ {MODE, "mode"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec TimingTab[] =
+{
+ {TT_INTERLACE, "interlace"},
+ {TT_PHSYNC, "+hsync"},
+ {TT_NHSYNC, "-hsync"},
+ {TT_PVSYNC, "+vsync"},
+ {TT_NVSYNC, "-vsync"},
+ {TT_CSYNC, "composite"},
+ {TT_PCSYNC, "+csync"},
+ {TT_NCSYNC, "-csync"},
+ {TT_DBLSCAN, "doublescan"},
+ {TT_HSKEW, "hskew"},
+ {TT_BCAST, "bcast"},
+ {TT_VSCAN, "vscan"},
+ {TT_CUSTOM, "CUSTOM"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec ModeTab[] =
+{
+ {DOTCLOCK, "dotclock"},
+ {HTIMINGS, "htimings"},
+ {VTIMINGS, "vtimings"},
+ {FLAGS, "flags"},
+ {HSKEW, "hskew"},
+ {BCAST, "bcast"},
+ {VSCAN, "vscan"},
+ {ENDMODE, "endmode"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeModeLineList
+
+static void
+xf86freeModeLineList (XF86ConfModeLinePtr ptr)
+{
+ XF86ConfModeLinePtr prev;
+ while (ptr)
+ {
+ TestFree (ptr->ml_identifier);
+ TestFree (ptr->ml_comment);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+static XF86ConfModeLinePtr
+xf86parseModeLine (void)
+{
+ int token;
+ parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)
+
+ /* Identifier */
+ if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
+ Error ("ModeLine identifier expected", NULL);
+ ptr->ml_identifier = val.str;
+
+ /* DotClock */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine dotclock expected", NULL);
+ ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
+
+ /* HDisplay */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine Hdisplay expected", NULL);
+ ptr->ml_hdisplay = val.num;
+
+ /* HSyncStart */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine HSyncStart expected", NULL);
+ ptr->ml_hsyncstart = val.num;
+
+ /* HSyncEnd */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine HSyncEnd expected", NULL);
+ ptr->ml_hsyncend = val.num;
+
+ /* HTotal */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine HTotal expected", NULL);
+ ptr->ml_htotal = val.num;
+
+ /* VDisplay */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine Vdisplay expected", NULL);
+ ptr->ml_vdisplay = val.num;
+
+ /* VSyncStart */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine VSyncStart expected", NULL);
+ ptr->ml_vsyncstart = val.num;
+
+ /* VSyncEnd */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine VSyncEnd expected", NULL);
+ ptr->ml_vsyncend = val.num;
+
+ /* VTotal */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine VTotal expected", NULL);
+ ptr->ml_vtotal = val.num;
+
+ token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
+ while ((token == TT_INTERLACE) || (token == TT_PHSYNC) ||
+ (token == TT_NHSYNC) || (token == TT_PVSYNC) ||
+ (token == TT_NVSYNC) || (token == TT_CSYNC) ||
+ (token == TT_PCSYNC) || (token == TT_NCSYNC) ||
+ (token == TT_DBLSCAN) || (token == TT_HSKEW) ||
+ (token == TT_VSCAN) || (token == TT_BCAST))
+ {
+ switch (token)
+ {
+
+ case TT_INTERLACE:
+ ptr->ml_flags |= XF86CONF_INTERLACE;
+ break;
+ case TT_PHSYNC:
+ ptr->ml_flags |= XF86CONF_PHSYNC;
+ break;
+ case TT_NHSYNC:
+ ptr->ml_flags |= XF86CONF_NHSYNC;
+ break;
+ case TT_PVSYNC:
+ ptr->ml_flags |= XF86CONF_PVSYNC;
+ break;
+ case TT_NVSYNC:
+ ptr->ml_flags |= XF86CONF_NVSYNC;
+ break;
+ case TT_CSYNC:
+ ptr->ml_flags |= XF86CONF_CSYNC;
+ break;
+ case TT_PCSYNC:
+ ptr->ml_flags |= XF86CONF_PCSYNC;
+ break;
+ case TT_NCSYNC:
+ ptr->ml_flags |= XF86CONF_NCSYNC;
+ break;
+ case TT_DBLSCAN:
+ ptr->ml_flags |= XF86CONF_DBLSCAN;
+ break;
+ case TT_HSKEW:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Hskew");
+ ptr->ml_hskew = val.num;
+ ptr->ml_flags |= XF86CONF_HSKEW;
+ break;
+ case TT_BCAST:
+ ptr->ml_flags |= XF86CONF_BCAST;
+ break;
+ case TT_VSCAN:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Vscan");
+ ptr->ml_vscan = val.num;
+ ptr->ml_flags |= XF86CONF_VSCAN;
+ break;
+ case TT_CUSTOM:
+ ptr->ml_flags |= XF86CONF_CUSTOM;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
+ }
+ xf86unGetToken (token);
+
+#ifdef DEBUG
+ printf ("ModeLine parsed\n");
+#endif
+ return ptr;
+}
+
+static XF86ConfModeLinePtr
+xf86parseVerboseMode (void)
+{
+ int token, token2;
+ int had_dotclock = 0, had_htimings = 0, had_vtimings = 0;
+ parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)
+
+ if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
+ Error ("Mode name expected", NULL);
+ ptr->ml_identifier = val.str;
+ while ((token = xf86getToken (ModeTab)) != ENDMODE)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->ml_comment = xf86addComment(ptr->ml_comment, val.str);
+ break;
+ case DOTCLOCK:
+ if ((token = xf86getSubToken (&(ptr->ml_comment))) != NUMBER)
+ Error (NUMBER_MSG, "DotClock");
+ ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
+ had_dotclock = 1;
+ break;
+ case HTIMINGS:
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hdisplay = val.num;
+ else
+ Error ("Horizontal display expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hsyncstart = val.num;
+ else
+ Error ("Horizontal sync start expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hsyncend = val.num;
+ else
+ Error ("Horizontal sync end expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_htotal = val.num;
+ else
+ Error ("Horizontal total expected", NULL);
+ had_htimings = 1;
+ break;
+ case VTIMINGS:
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vdisplay = val.num;
+ else
+ Error ("Vertical display expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vsyncstart = val.num;
+ else
+ Error ("Vertical sync start expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vsyncend = val.num;
+ else
+ Error ("Vertical sync end expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vtotal = val.num;
+ else
+ Error ("Vertical total expected", NULL);
+ had_vtimings = 1;
+ break;
+ case FLAGS:
+ token = xf86getSubToken (&(ptr->ml_comment));
+ if (token != STRING)
+ Error (QUOTE_MSG, "Flags");
+ while (token == STRING)
+ {
+ token2 = xf86getStringToken (TimingTab);
+ switch (token2)
+ {
+ case TT_INTERLACE:
+ ptr->ml_flags |= XF86CONF_INTERLACE;
+ break;
+ case TT_PHSYNC:
+ ptr->ml_flags |= XF86CONF_PHSYNC;
+ break;
+ case TT_NHSYNC:
+ ptr->ml_flags |= XF86CONF_NHSYNC;
+ break;
+ case TT_PVSYNC:
+ ptr->ml_flags |= XF86CONF_PVSYNC;
+ break;
+ case TT_NVSYNC:
+ ptr->ml_flags |= XF86CONF_NVSYNC;
+ break;
+ case TT_CSYNC:
+ ptr->ml_flags |= XF86CONF_CSYNC;
+ break;
+ case TT_PCSYNC:
+ ptr->ml_flags |= XF86CONF_PCSYNC;
+ break;
+ case TT_NCSYNC:
+ ptr->ml_flags |= XF86CONF_NCSYNC;
+ break;
+ case TT_DBLSCAN:
+ ptr->ml_flags |= XF86CONF_DBLSCAN;
+ break;
+ case TT_CUSTOM:
+ ptr->ml_flags |= XF86CONF_CUSTOM;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error ("Unknown flag string", NULL);
+ break;
+ }
+ token = xf86getSubToken (&(ptr->ml_comment));
+ }
+ xf86unGetToken (token);
+ break;
+ case HSKEW:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("Horizontal skew expected", NULL);
+ ptr->ml_flags |= XF86CONF_HSKEW;
+ ptr->ml_hskew = val.num;
+ break;
+ case VSCAN:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("Vertical scan count expected", NULL);
+ ptr->ml_flags |= XF86CONF_VSCAN;
+ ptr->ml_vscan = val.num;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error ("Unexepcted token in verbose \"Mode\" entry\n", NULL);
+ }
+ }
+ if (!had_dotclock)
+ Error ("the dotclock is missing", NULL);
+ if (!had_htimings)
+ Error ("the horizontal timings are missing", NULL);
+ if (!had_vtimings)
+ Error ("the vertical timings are missing", NULL);
+
+#ifdef DEBUG
+ printf ("Verbose Mode parsed\n");
+#endif
+ return ptr;
+}
+
+#undef CLEANUP
+
+#define CLEANUP xf86freeMonitorList
+
+XF86ConfMonitorPtr
+xf86parseMonitorSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+ while ((token = xf86getToken (MonitorTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->mon_comment = xf86addComment(ptr->mon_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->mon_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
+ Error (QUOTE_MSG, "Vendor");
+ ptr->mon_vendor = val.str;
+ break;
+ case MODEL:
+ if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
+ Error (QUOTE_MSG, "ModelName");
+ ptr->mon_modelname = val.str;
+ break;
+ case MODE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode,
+ XF86ConfModeLinePtr);
+ break;
+ case MODELINE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseModeLine,
+ XF86ConfModeLinePtr);
+ break;
+ case DISPLAYSIZE:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (DISPLAYSIZE_MSG, NULL);
+ ptr->mon_width = val.realnum;
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (DISPLAYSIZE_MSG, NULL);
+ ptr->mon_height = val.realnum;
+ break;
+
+ case HORIZSYNC:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (HORIZSYNC_MSG, NULL);
+ do {
+ if (ptr->mon_n_hsync >= CONF_MAX_HSYNC)
+ Error ("Sorry. Too many horizontal sync intervals.", NULL);
+ ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum;
+ switch (token = xf86getSubToken (&(ptr->mon_comment)))
+ {
+ case COMMA:
+ ptr->mon_hsync[ptr->mon_n_hsync].hi =
+ ptr->mon_hsync[ptr->mon_n_hsync].lo;
+ break;
+ case DASH:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
+ (float)val.realnum < ptr->mon_hsync[ptr->mon_n_hsync].lo)
+ Error (HORIZSYNC_MSG, NULL);
+ ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum;
+ if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
+ break;
+ ptr->mon_n_hsync++;
+ goto HorizDone;
+ default:
+ /* We cannot currently know if a '\n' was found,
+ * or this is a real error
+ */
+ ptr->mon_hsync[ptr->mon_n_hsync].hi =
+ ptr->mon_hsync[ptr->mon_n_hsync].lo;
+ ptr->mon_n_hsync++;
+ goto HorizDone;
+ }
+ ptr->mon_n_hsync++;
+ } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
+HorizDone:
+ xf86unGetToken (token);
+ break;
+
+ case VERTREFRESH:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (VERTREFRESH_MSG, NULL);
+ do {
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum;
+ switch (token = xf86getSubToken (&(ptr->mon_comment)))
+ {
+ case COMMA:
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
+ break;
+ case DASH:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
+ (float)val.realnum < ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo)
+ Error (VERTREFRESH_MSG, NULL);
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum;
+ if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
+ break;
+ ptr->mon_n_vrefresh++;
+ goto VertDone;
+ default:
+ /* We cannot currently know if a '\n' was found,
+ * or this is a real error
+ */
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
+ ptr->mon_n_vrefresh++;
+ goto VertDone;
+ }
+ if (ptr->mon_n_vrefresh >= CONF_MAX_VREFRESH)
+ Error ("Sorry. Too many vertical refresh intervals.", NULL);
+ ptr->mon_n_vrefresh++;
+ } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
+VertDone:
+ xf86unGetToken (token);
+ break;
+
+ case GAMMA:
+ if( xf86getSubToken (&(ptr->mon_comment)) != NUMBER )
+ {
+ Error (INVALID_GAMMA_MSG, NULL);
+ }
+ else
+ {
+ ptr->mon_gamma_red = ptr->mon_gamma_green =
+ ptr->mon_gamma_blue = val.realnum;
+ if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
+ {
+ ptr->mon_gamma_green = val.realnum;
+ if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
+ {
+ ptr->mon_gamma_blue = val.realnum;
+ }
+ else
+ {
+ Error (INVALID_GAMMA_MSG, NULL);
+ }
+ }
+ else
+ xf86unGetToken (token);
+ }
+ break;
+ case OPTION:
+ ptr->mon_option_lst = xf86parseOption(ptr->mon_option_lst);
+ break;
+ case USEMODES:
+ {
+ XF86ConfModesLinkPtr mptr;
+
+ if ((token = xf86getSubToken (&(ptr->mon_comment))) != STRING)
+ Error (QUOTE_MSG, "UseModes");
+
+ /* add to the end of the list of modes sections
+ referenced here */
+ mptr = calloc (1, sizeof (XF86ConfModesLinkRec));
+ mptr->list.next = NULL;
+ mptr->ml_modes_str = val.str;
+ mptr->ml_modes = NULL;
+ ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr)
+ xf86addListItem((GenericListPtr)ptr->mon_modes_sect_lst,
+ (GenericListPtr)mptr);
+ }
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
+ CLEANUP (ptr);
+ return NULL;
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Monitor section parsed\n");
+#endif
+ return ptr;
+}
+
+#undef CLEANUP
+#define CLEANUP xf86freeModesList
+
+XF86ConfModesPtr
+xf86parseModesSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfModesPtr, XF86ConfModesRec)
+
+ while ((token = xf86getToken (ModesTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->modes_comment = xf86addComment(ptr->modes_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->modes_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->modes_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case MODE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode,
+ XF86ConfModeLinePtr);
+ break;
+ case MODELINE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseModeLine,
+ XF86ConfModeLinePtr);
+ break;
+ default:
+ xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
+ CLEANUP (ptr);
+ return NULL;
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Modes section parsed\n");
+#endif
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printMonitorSection (FILE * cf, XF86ConfMonitorPtr ptr)
+{
+ int i;
+ XF86ConfModeLinePtr mlptr;
+ XF86ConfModesLinkPtr mptr;
+
+ while (ptr)
+ {
+ mptr = ptr->mon_modes_sect_lst;
+ fprintf (cf, "Section \"Monitor\"\n");
+ if (ptr->mon_comment)
+ fprintf (cf, "%s", ptr->mon_comment);
+ if (ptr->mon_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->mon_identifier);
+ if (ptr->mon_vendor)
+ fprintf (cf, "\tVendorName \"%s\"\n", ptr->mon_vendor);
+ if (ptr->mon_modelname)
+ fprintf (cf, "\tModelName \"%s\"\n", ptr->mon_modelname);
+ while (mptr) {
+ fprintf (cf, "\tUseModes \"%s\"\n", mptr->ml_modes_str);
+ mptr = mptr->list.next;
+ }
+ if (ptr->mon_width)
+ fprintf (cf, "\tDisplaySize %d\t%d\n",
+ ptr->mon_width,
+ ptr->mon_height);
+ for (i = 0; i < ptr->mon_n_hsync; i++)
+ {
+ fprintf (cf, "\tHorizSync %2.1f - %2.1f\n",
+ ptr->mon_hsync[i].lo,
+ ptr->mon_hsync[i].hi);
+ }
+ for (i = 0; i < ptr->mon_n_vrefresh; i++)
+ {
+ fprintf (cf, "\tVertRefresh %2.1f - %2.1f\n",
+ ptr->mon_vrefresh[i].lo,
+ ptr->mon_vrefresh[i].hi);
+ }
+ if (ptr->mon_gamma_red) {
+ if (ptr->mon_gamma_red == ptr->mon_gamma_green
+ && ptr->mon_gamma_red == ptr->mon_gamma_blue)
+ {
+ fprintf (cf, "\tGamma %.4g\n",
+ ptr->mon_gamma_red);
+ } else {
+ fprintf (cf, "\tGamma %.4g %.4g %.4g\n",
+ ptr->mon_gamma_red,
+ ptr->mon_gamma_green,
+ ptr->mon_gamma_blue);
+ }
+ }
+ for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next)
+ {
+ fprintf (cf, "\tModeLine \"%s\" %2.1f ",
+ mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
+ fprintf (cf, "%d %d %d %d %d %d %d %d",
+ mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
+ mlptr->ml_hsyncend, mlptr->ml_htotal,
+ mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
+ mlptr->ml_vsyncend, mlptr->ml_vtotal);
+ if (mlptr->ml_flags & XF86CONF_PHSYNC)
+ fprintf (cf, " +hsync");
+ if (mlptr->ml_flags & XF86CONF_NHSYNC)
+ fprintf (cf, " -hsync");
+ if (mlptr->ml_flags & XF86CONF_PVSYNC)
+ fprintf (cf, " +vsync");
+ if (mlptr->ml_flags & XF86CONF_NVSYNC)
+ fprintf (cf, " -vsync");
+ if (mlptr->ml_flags & XF86CONF_INTERLACE)
+ fprintf (cf, " interlace");
+ if (mlptr->ml_flags & XF86CONF_CSYNC)
+ fprintf (cf, " composite");
+ if (mlptr->ml_flags & XF86CONF_PCSYNC)
+ fprintf (cf, " +csync");
+ if (mlptr->ml_flags & XF86CONF_NCSYNC)
+ fprintf (cf, " -csync");
+ if (mlptr->ml_flags & XF86CONF_DBLSCAN)
+ fprintf (cf, " doublescan");
+ if (mlptr->ml_flags & XF86CONF_HSKEW)
+ fprintf (cf, " hskew %d", mlptr->ml_hskew);
+ if (mlptr->ml_flags & XF86CONF_BCAST)
+ fprintf (cf, " bcast");
+ fprintf (cf, "\n");
+ }
+ xf86printOptionList(cf, ptr->mon_option_lst, 1);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86printModesSection (FILE * cf, XF86ConfModesPtr ptr)
+{
+ XF86ConfModeLinePtr mlptr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"Modes\"\n");
+ if (ptr->modes_comment)
+ fprintf (cf, "%s", ptr->modes_comment);
+ if (ptr->modes_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->modes_identifier);
+ for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next)
+ {
+ fprintf (cf, "\tModeLine \"%s\" %2.1f ",
+ mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
+ fprintf (cf, "%d %d %d %d %d %d %d %d",
+ mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
+ mlptr->ml_hsyncend, mlptr->ml_htotal,
+ mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
+ mlptr->ml_vsyncend, mlptr->ml_vtotal);
+ if (mlptr->ml_flags & XF86CONF_PHSYNC)
+ fprintf (cf, " +hsync");
+ if (mlptr->ml_flags & XF86CONF_NHSYNC)
+ fprintf (cf, " -hsync");
+ if (mlptr->ml_flags & XF86CONF_PVSYNC)
+ fprintf (cf, " +vsync");
+ if (mlptr->ml_flags & XF86CONF_NVSYNC)
+ fprintf (cf, " -vsync");
+ if (mlptr->ml_flags & XF86CONF_INTERLACE)
+ fprintf (cf, " interlace");
+ if (mlptr->ml_flags & XF86CONF_CSYNC)
+ fprintf (cf, " composite");
+ if (mlptr->ml_flags & XF86CONF_PCSYNC)
+ fprintf (cf, " +csync");
+ if (mlptr->ml_flags & XF86CONF_NCSYNC)
+ fprintf (cf, " -csync");
+ if (mlptr->ml_flags & XF86CONF_DBLSCAN)
+ fprintf (cf, " doublescan");
+ if (mlptr->ml_flags & XF86CONF_HSKEW)
+ fprintf (cf, " hskew %d", mlptr->ml_hskew);
+ if (mlptr->ml_flags & XF86CONF_VSCAN)
+ fprintf (cf, " vscan %d", mlptr->ml_vscan);
+ if (mlptr->ml_flags & XF86CONF_BCAST)
+ fprintf (cf, " bcast");
+ if (mlptr->ml_comment)
+ fprintf (cf, "%s", mlptr->ml_comment);
+ else
+ fprintf (cf, "\n");
+ }
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeMonitorList (XF86ConfMonitorPtr ptr)
+{
+ XF86ConfMonitorPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->mon_identifier);
+ TestFree (ptr->mon_vendor);
+ TestFree (ptr->mon_modelname);
+ TestFree (ptr->mon_comment);
+ xf86optionListFree (ptr->mon_option_lst);
+ xf86freeModeLineList (ptr->mon_modeline_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+void
+xf86freeModesList (XF86ConfModesPtr ptr)
+{
+ XF86ConfModesPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->modes_identifier);
+ TestFree (ptr->modes_comment);
+ xf86freeModeLineList (ptr->mon_modeline_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+XF86ConfMonitorPtr
+xf86findMonitor (const char *ident, XF86ConfMonitorPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->mon_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
+XF86ConfModesPtr
+xf86findModes (const char *ident, XF86ConfModesPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->modes_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
+XF86ConfModeLinePtr
+xf86findModeLine (const char *ident, XF86ConfModeLinePtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->ml_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
+int
+xf86validateMonitor (XF86ConfigPtr p, XF86ConfScreenPtr screen)
+{
+ XF86ConfMonitorPtr monitor = screen->scrn_monitor;
+ XF86ConfModesLinkPtr modeslnk = monitor->mon_modes_sect_lst;
+ XF86ConfModesPtr modes;
+ while(modeslnk)
+ {
+ modes = xf86findModes (modeslnk->ml_modes_str, p->conf_modes_lst);
+ if (!modes)
+ {
+ xf86validationError (UNDEFINED_MODES_MSG,
+ modeslnk->ml_modes_str,
+ screen->scrn_identifier);
+ return FALSE;
+ }
+ modeslnk->ml_modes = modes;
+ modeslnk = modeslnk->list.next;
+ }
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/parser/Screen.c b/xorg-server/hw/xfree86/parser/Screen.c index b3b004df6..b5667a79e 100644 --- a/xorg-server/hw/xfree86/parser/Screen.c +++ b/xorg-server/hw/xfree86/parser/Screen.c @@ -1,569 +1,569 @@ -/* - * - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* View/edit this file with tab stops set to 4 */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86Parser.h" -#include "xf86tokens.h" -#include "Configint.h" - -extern LexRec val; - -static xf86ConfigSymTabRec DisplayTab[] = -{ - {ENDSUBSECTION, "endsubsection"}, - {MODES, "modes"}, - {VIEWPORT, "viewport"}, - {VIRTUAL, "virtual"}, - {VISUAL, "visual"}, - {BLACK_TOK, "black"}, - {WHITE_TOK, "white"}, - {DEPTH, "depth"}, - {BPP, "fbbpp"}, - {WEIGHT, "weight"}, - {OPTION, "option"}, - {-1, ""}, -}; - -#define CLEANUP xf86freeDisplayList - -static XF86ConfDisplayPtr -xf86parseDisplaySubSection (void) -{ - int token; - parsePrologue (XF86ConfDisplayPtr, XF86ConfDisplayRec) - - ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1; - ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1; - ptr->disp_frameX0 = ptr->disp_frameY0 = -1; - while ((token = xf86getToken (DisplayTab)) != ENDSUBSECTION) - { - switch (token) - { - case COMMENT: - ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str); - break; - case VIEWPORT: - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (VIEWPORT_MSG, NULL); - ptr->disp_frameX0 = val.num; - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (VIEWPORT_MSG, NULL); - ptr->disp_frameY0 = val.num; - break; - case VIRTUAL: - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (VIRTUAL_MSG, NULL); - ptr->disp_virtualX = val.num; - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (VIRTUAL_MSG, NULL); - ptr->disp_virtualY = val.num; - break; - case DEPTH: - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (NUMBER_MSG, "Display"); - ptr->disp_depth = val.num; - break; - case BPP: - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (NUMBER_MSG, "Display"); - ptr->disp_bpp = val.num; - break; - case VISUAL: - if (xf86getSubToken (&(ptr->disp_comment)) != STRING) - Error (QUOTE_MSG, "Display"); - ptr->disp_visual = val.str; - break; - case WEIGHT: - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (WEIGHT_MSG, NULL); - ptr->disp_weight.red = val.num; - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (WEIGHT_MSG, NULL); - ptr->disp_weight.green = val.num; - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (WEIGHT_MSG, NULL); - ptr->disp_weight.blue = val.num; - break; - case BLACK_TOK: - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (BLACK_MSG, NULL); - ptr->disp_black.red = val.num; - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (BLACK_MSG, NULL); - ptr->disp_black.green = val.num; - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (BLACK_MSG, NULL); - ptr->disp_black.blue = val.num; - break; - case WHITE_TOK: - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (WHITE_MSG, NULL); - ptr->disp_white.red = val.num; - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (WHITE_MSG, NULL); - ptr->disp_white.green = val.num; - if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) - Error (WHITE_MSG, NULL); - ptr->disp_white.blue = val.num; - break; - case MODES: - { - XF86ModePtr mptr; - - while ((token = xf86getSubTokenWithTab (&(ptr->disp_comment), DisplayTab)) == STRING) - { - mptr = calloc (1, sizeof (XF86ModeRec)); - mptr->mode_name = val.str; - mptr->list.next = NULL; - ptr->disp_mode_lst = (XF86ModePtr) - xf86addListItem ((glp) ptr->disp_mode_lst, (glp) mptr); - } - xf86unGetToken (token); - } - break; - case OPTION: - ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst); - break; - - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error (INVALID_KEYWORD_MSG, xf86tokenString ()); - break; - } - } - -#ifdef DEBUG - printf ("Display subsection parsed\n"); -#endif - - return ptr; -} - -#undef CLEANUP - -static xf86ConfigSymTabRec ScreenTab[] = -{ - {ENDSECTION, "endsection"}, - {IDENTIFIER, "identifier"}, - {OBSDRIVER, "driver"}, - {MDEVICE, "device"}, - {MONITOR, "monitor"}, - {VIDEOADAPTOR, "videoadaptor"}, - {SCREENNO, "screenno"}, - {SUBSECTION, "subsection"}, - {DEFAULTDEPTH, "defaultcolordepth"}, - {DEFAULTDEPTH, "defaultdepth"}, - {DEFAULTBPP, "defaultbpp"}, - {DEFAULTFBBPP, "defaultfbbpp"}, - {VIRTUAL, "virtual"}, - {OPTION, "option"}, - {-1, ""}, -}; - -#define CLEANUP xf86freeScreenList -XF86ConfScreenPtr -xf86parseScreenSection (void) -{ - int has_ident = FALSE; - int has_driver= FALSE; - int token; - - parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec) - - while ((token = xf86getToken (ScreenTab)) != ENDSECTION) - { - switch (token) - { - case COMMENT: - ptr->scrn_comment = xf86addComment(ptr->scrn_comment, val.str); - break; - case IDENTIFIER: - if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) - Error (QUOTE_MSG, "Identifier"); - ptr->scrn_identifier = val.str; - if (has_ident || has_driver) - Error (ONLY_ONE_MSG,"Identifier or Driver"); - has_ident = TRUE; - break; - case OBSDRIVER: - if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) - Error (QUOTE_MSG, "Driver"); - ptr->scrn_obso_driver = val.str; - if (has_ident || has_driver) - Error (ONLY_ONE_MSG,"Identifier or Driver"); - has_driver = TRUE; - break; - case DEFAULTDEPTH: - if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) - Error (NUMBER_MSG, "DefaultDepth"); - ptr->scrn_defaultdepth = val.num; - break; - case DEFAULTBPP: - if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) - Error (NUMBER_MSG, "DefaultBPP"); - ptr->scrn_defaultbpp = val.num; - break; - case DEFAULTFBBPP: - if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) - Error (NUMBER_MSG, "DefaultFbBPP"); - ptr->scrn_defaultfbbpp = val.num; - break; - case MDEVICE: - if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) - Error (QUOTE_MSG, "Device"); - ptr->scrn_device_str = val.str; - break; - case MONITOR: - if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) - Error (QUOTE_MSG, "Monitor"); - ptr->scrn_monitor_str = val.str; - break; - case VIDEOADAPTOR: - { - XF86ConfAdaptorLinkPtr aptr; - - if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) - Error (QUOTE_MSG, "VideoAdaptor"); - - /* Don't allow duplicates */ - for (aptr = ptr->scrn_adaptor_lst; aptr; - aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next) - if (xf86nameCompare (val.str, aptr->al_adaptor_str) == 0) - break; - - if (aptr == NULL) - { - aptr = calloc (1, sizeof (XF86ConfAdaptorLinkRec)); - aptr->list.next = NULL; - aptr->al_adaptor_str = val.str; - ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr) - xf86addListItem ((glp) ptr->scrn_adaptor_lst, (glp) aptr); - } - } - break; - case VIRTUAL: - if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) - Error (VIRTUAL_MSG, NULL); - ptr->scrn_virtualX = val.num; - if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) - Error (VIRTUAL_MSG, NULL); - ptr->scrn_virtualY = val.num; - break; - case OPTION: - ptr->scrn_option_lst = xf86parseOption(ptr->scrn_option_lst); - break; - case SUBSECTION: - if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) - Error (QUOTE_MSG, "SubSection"); - { - free(val.str); - HANDLE_LIST (scrn_display_lst, xf86parseDisplaySubSection, - XF86ConfDisplayPtr); - } - break; - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error (INVALID_KEYWORD_MSG, xf86tokenString ()); - break; - } - } - - if (!has_ident && !has_driver) - Error (NO_IDENT_MSG, NULL); - -#ifdef DEBUG - printf ("Screen section parsed\n"); -#endif - - return ptr; -} - -void -xf86printScreenSection (FILE * cf, XF86ConfScreenPtr ptr) -{ - XF86ConfAdaptorLinkPtr aptr; - XF86ConfDisplayPtr dptr; - XF86ModePtr mptr; - - while (ptr) - { - fprintf (cf, "Section \"Screen\"\n"); - if (ptr->scrn_comment) - fprintf (cf, "%s", ptr->scrn_comment); - if (ptr->scrn_identifier) - fprintf (cf, "\tIdentifier \"%s\"\n", ptr->scrn_identifier); - if (ptr->scrn_obso_driver) - fprintf (cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver); - if (ptr->scrn_device_str) - fprintf (cf, "\tDevice \"%s\"\n", ptr->scrn_device_str); - if (ptr->scrn_monitor_str) - fprintf (cf, "\tMonitor \"%s\"\n", ptr->scrn_monitor_str); - if (ptr->scrn_defaultdepth) - fprintf (cf, "\tDefaultDepth %d\n", - ptr->scrn_defaultdepth); - if (ptr->scrn_defaultbpp) - fprintf (cf, "\tDefaultBPP %d\n", - ptr->scrn_defaultbpp); - if (ptr->scrn_defaultfbbpp) - fprintf (cf, "\tDefaultFbBPP %d\n", - ptr->scrn_defaultfbbpp); - xf86printOptionList(cf, ptr->scrn_option_lst, 1); - for (aptr = ptr->scrn_adaptor_lst; aptr; aptr = aptr->list.next) - { - fprintf (cf, "\tVideoAdaptor \"%s\"\n", aptr->al_adaptor_str); - } - if (ptr->scrn_virtualX && ptr->scrn_virtualY) - fprintf (cf, "\tVirtual %d %d\n", - ptr->scrn_virtualX, - ptr->scrn_virtualY); - for (dptr = ptr->scrn_display_lst; dptr; dptr = dptr->list.next) - { - fprintf (cf, "\tSubSection \"Display\"\n"); - if (dptr->disp_comment) - fprintf (cf, "%s", dptr->disp_comment); - if (dptr->disp_frameX0 >= 0 || dptr->disp_frameY0 >= 0) - { - fprintf (cf, "\t\tViewport %d %d\n", - dptr->disp_frameX0, dptr->disp_frameY0); - } - if (dptr->disp_virtualX != 0 || dptr->disp_virtualY != 0) - { - fprintf (cf, "\t\tVirtual %d %d\n", - dptr->disp_virtualX, dptr->disp_virtualY); - } - if (dptr->disp_depth) - { - fprintf (cf, "\t\tDepth %d\n", dptr->disp_depth); - } - if (dptr->disp_bpp) - { - fprintf (cf, "\t\tFbBPP %d\n", dptr->disp_bpp); - } - if (dptr->disp_visual) - { - fprintf (cf, "\t\tVisual \"%s\"\n", dptr->disp_visual); - } - if (dptr->disp_weight.red != 0) - { - fprintf (cf, "\t\tWeight %d %d %d\n", - dptr->disp_weight.red, dptr->disp_weight.green, dptr->disp_weight.blue); - } - if (dptr->disp_black.red != -1) - { - fprintf (cf, "\t\tBlack 0x%04x 0x%04x 0x%04x\n", - dptr->disp_black.red, dptr->disp_black.green, dptr->disp_black.blue); - } - if (dptr->disp_white.red != -1) - { - fprintf (cf, "\t\tWhite 0x%04x 0x%04x 0x%04x\n", - dptr->disp_white.red, dptr->disp_white.green, dptr->disp_white.blue); - } - if (dptr->disp_mode_lst) - { - fprintf (cf, "\t\tModes "); - } - for (mptr = dptr->disp_mode_lst; mptr; mptr = mptr->list.next) - { - fprintf (cf, " \"%s\"", mptr->mode_name); - } - if (dptr->disp_mode_lst) - { - fprintf (cf, "\n"); - } - xf86printOptionList(cf, dptr->disp_option_lst, 2); - fprintf (cf, "\tEndSubSection\n"); - } - fprintf (cf, "EndSection\n\n"); - ptr = ptr->list.next; - } - -} - -void -xf86freeScreenList (XF86ConfScreenPtr ptr) -{ - XF86ConfScreenPtr prev; - - while (ptr) - { - TestFree (ptr->scrn_identifier); - TestFree (ptr->scrn_monitor_str); - TestFree (ptr->scrn_device_str); - TestFree (ptr->scrn_comment); - xf86optionListFree (ptr->scrn_option_lst); - xf86freeAdaptorLinkList (ptr->scrn_adaptor_lst); - xf86freeDisplayList (ptr->scrn_display_lst); - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -void -xf86freeAdaptorLinkList (XF86ConfAdaptorLinkPtr ptr) -{ - XF86ConfAdaptorLinkPtr prev; - - while (ptr) - { - TestFree (ptr->al_adaptor_str); - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -void -xf86freeDisplayList (XF86ConfDisplayPtr ptr) -{ - XF86ConfDisplayPtr prev; - - while (ptr) - { - xf86freeModeList (ptr->disp_mode_lst); - xf86optionListFree (ptr->disp_option_lst); - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -void -xf86freeModeList (XF86ModePtr ptr) -{ - XF86ModePtr prev; - - while (ptr) - { - TestFree (ptr->mode_name); - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -int -xf86validateScreen (XF86ConfigPtr p) -{ - XF86ConfScreenPtr screen = p->conf_screen_lst; - XF86ConfMonitorPtr monitor; - XF86ConfAdaptorLinkPtr adaptor; - - while (screen) - { - if (screen->scrn_obso_driver && !screen->scrn_identifier) - screen->scrn_identifier = screen->scrn_obso_driver; - - monitor = xf86findMonitor (screen->scrn_monitor_str, p->conf_monitor_lst); - if (screen->scrn_monitor_str) - { - if (monitor) - { - screen->scrn_monitor = monitor; - if (!xf86validateMonitor(p, screen)) - return (FALSE); - } - } - - screen->scrn_device= xf86findDevice (screen->scrn_device_str, p->conf_device_lst); - - adaptor = screen->scrn_adaptor_lst; - while (adaptor) - { - adaptor->al_adaptor = xf86findVideoAdaptor (adaptor->al_adaptor_str, p->conf_videoadaptor_lst); - if (!adaptor->al_adaptor) - { - xf86validationError (UNDEFINED_ADAPTOR_MSG, adaptor->al_adaptor_str, screen->scrn_identifier); - return (FALSE); - } - else if (adaptor->al_adaptor->va_fwdref) - { - xf86validationError (ADAPTOR_REF_TWICE_MSG, adaptor->al_adaptor_str, - adaptor->al_adaptor->va_fwdref); - return (FALSE); - } - - adaptor->al_adaptor->va_fwdref = strdup(screen->scrn_identifier); - adaptor = adaptor->list.next; - } - - screen = screen->list.next; - } - - return (TRUE); -} - -XF86ConfScreenPtr -xf86findScreen (const char *ident, XF86ConfScreenPtr p) -{ - while (p) - { - if (xf86nameCompare (ident, p->scrn_identifier) == 0) - return (p); - - p = p->list.next; - } - return (NULL); -} - +/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec DisplayTab[] =
+{
+ {ENDSUBSECTION, "endsubsection"},
+ {MODES, "modes"},
+ {VIEWPORT, "viewport"},
+ {VIRTUAL, "virtual"},
+ {VISUAL, "visual"},
+ {BLACK_TOK, "black"},
+ {WHITE_TOK, "white"},
+ {DEPTH, "depth"},
+ {BPP, "fbbpp"},
+ {WEIGHT, "weight"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeDisplayList
+
+static XF86ConfDisplayPtr
+xf86parseDisplaySubSection (void)
+{
+ int token;
+ parsePrologue (XF86ConfDisplayPtr, XF86ConfDisplayRec)
+
+ ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1;
+ ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1;
+ ptr->disp_frameX0 = ptr->disp_frameY0 = -1;
+ while ((token = xf86getToken (DisplayTab)) != ENDSUBSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str);
+ break;
+ case VIEWPORT:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIEWPORT_MSG, NULL);
+ ptr->disp_frameX0 = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIEWPORT_MSG, NULL);
+ ptr->disp_frameY0 = val.num;
+ break;
+ case VIRTUAL:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIRTUAL_MSG, NULL);
+ ptr->disp_virtualX = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIRTUAL_MSG, NULL);
+ ptr->disp_virtualY = val.num;
+ break;
+ case DEPTH:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Display");
+ ptr->disp_depth = val.num;
+ break;
+ case BPP:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Display");
+ ptr->disp_bpp = val.num;
+ break;
+ case VISUAL:
+ if (xf86getSubToken (&(ptr->disp_comment)) != STRING)
+ Error (QUOTE_MSG, "Display");
+ ptr->disp_visual = val.str;
+ break;
+ case WEIGHT:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WEIGHT_MSG, NULL);
+ ptr->disp_weight.red = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WEIGHT_MSG, NULL);
+ ptr->disp_weight.green = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WEIGHT_MSG, NULL);
+ ptr->disp_weight.blue = val.num;
+ break;
+ case BLACK_TOK:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (BLACK_MSG, NULL);
+ ptr->disp_black.red = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (BLACK_MSG, NULL);
+ ptr->disp_black.green = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (BLACK_MSG, NULL);
+ ptr->disp_black.blue = val.num;
+ break;
+ case WHITE_TOK:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WHITE_MSG, NULL);
+ ptr->disp_white.red = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WHITE_MSG, NULL);
+ ptr->disp_white.green = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WHITE_MSG, NULL);
+ ptr->disp_white.blue = val.num;
+ break;
+ case MODES:
+ {
+ XF86ModePtr mptr;
+
+ while ((token = xf86getSubTokenWithTab (&(ptr->disp_comment), DisplayTab)) == STRING)
+ {
+ mptr = calloc (1, sizeof (XF86ModeRec));
+ mptr->mode_name = val.str;
+ mptr->list.next = NULL;
+ ptr->disp_mode_lst = (XF86ModePtr)
+ xf86addListItem ((glp) ptr->disp_mode_lst, (glp) mptr);
+ }
+ xf86unGetToken (token);
+ }
+ break;
+ case OPTION:
+ ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("Display subsection parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+static xf86ConfigSymTabRec ScreenTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OBSDRIVER, "driver"},
+ {MDEVICE, "device"},
+ {MONITOR, "monitor"},
+ {VIDEOADAPTOR, "videoadaptor"},
+ {SCREENNO, "screenno"},
+ {SUBSECTION, "subsection"},
+ {DEFAULTDEPTH, "defaultcolordepth"},
+ {DEFAULTDEPTH, "defaultdepth"},
+ {DEFAULTBPP, "defaultbpp"},
+ {DEFAULTFBBPP, "defaultfbbpp"},
+ {VIRTUAL, "virtual"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeScreenList
+XF86ConfScreenPtr
+xf86parseScreenSection (void)
+{
+ int has_ident = FALSE;
+ int has_driver= FALSE;
+ int token;
+
+ parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
+
+ while ((token = xf86getToken (ScreenTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->scrn_comment = xf86addComment(ptr->scrn_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ ptr->scrn_identifier = val.str;
+ if (has_ident || has_driver)
+ Error (ONLY_ONE_MSG,"Identifier or Driver");
+ has_ident = TRUE;
+ break;
+ case OBSDRIVER:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ ptr->scrn_obso_driver = val.str;
+ if (has_ident || has_driver)
+ Error (ONLY_ONE_MSG,"Identifier or Driver");
+ has_driver = TRUE;
+ break;
+ case DEFAULTDEPTH:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (NUMBER_MSG, "DefaultDepth");
+ ptr->scrn_defaultdepth = val.num;
+ break;
+ case DEFAULTBPP:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (NUMBER_MSG, "DefaultBPP");
+ ptr->scrn_defaultbpp = val.num;
+ break;
+ case DEFAULTFBBPP:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (NUMBER_MSG, "DefaultFbBPP");
+ ptr->scrn_defaultfbbpp = val.num;
+ break;
+ case MDEVICE:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Device");
+ ptr->scrn_device_str = val.str;
+ break;
+ case MONITOR:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Monitor");
+ ptr->scrn_monitor_str = val.str;
+ break;
+ case VIDEOADAPTOR:
+ {
+ XF86ConfAdaptorLinkPtr aptr;
+
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "VideoAdaptor");
+
+ /* Don't allow duplicates */
+ for (aptr = ptr->scrn_adaptor_lst; aptr;
+ aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next)
+ if (xf86nameCompare (val.str, aptr->al_adaptor_str) == 0)
+ break;
+
+ if (aptr == NULL)
+ {
+ aptr = calloc (1, sizeof (XF86ConfAdaptorLinkRec));
+ aptr->list.next = NULL;
+ aptr->al_adaptor_str = val.str;
+ ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr)
+ xf86addListItem ((glp) ptr->scrn_adaptor_lst, (glp) aptr);
+ }
+ }
+ break;
+ case VIRTUAL:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (VIRTUAL_MSG, NULL);
+ ptr->scrn_virtualX = val.num;
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (VIRTUAL_MSG, NULL);
+ ptr->scrn_virtualY = val.num;
+ break;
+ case OPTION:
+ ptr->scrn_option_lst = xf86parseOption(ptr->scrn_option_lst);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "SubSection");
+ {
+ free(val.str);
+ HANDLE_LIST (scrn_display_lst, xf86parseDisplaySubSection,
+ XF86ConfDisplayPtr);
+ }
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident && !has_driver)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Screen section parsed\n");
+#endif
+
+ return ptr;
+}
+
+void
+xf86printScreenSection (FILE * cf, XF86ConfScreenPtr ptr)
+{
+ XF86ConfAdaptorLinkPtr aptr;
+ XF86ConfDisplayPtr dptr;
+ XF86ModePtr mptr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"Screen\"\n");
+ if (ptr->scrn_comment)
+ fprintf (cf, "%s", ptr->scrn_comment);
+ if (ptr->scrn_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->scrn_identifier);
+ if (ptr->scrn_obso_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver);
+ if (ptr->scrn_device_str)
+ fprintf (cf, "\tDevice \"%s\"\n", ptr->scrn_device_str);
+ if (ptr->scrn_monitor_str)
+ fprintf (cf, "\tMonitor \"%s\"\n", ptr->scrn_monitor_str);
+ if (ptr->scrn_defaultdepth)
+ fprintf (cf, "\tDefaultDepth %d\n",
+ ptr->scrn_defaultdepth);
+ if (ptr->scrn_defaultbpp)
+ fprintf (cf, "\tDefaultBPP %d\n",
+ ptr->scrn_defaultbpp);
+ if (ptr->scrn_defaultfbbpp)
+ fprintf (cf, "\tDefaultFbBPP %d\n",
+ ptr->scrn_defaultfbbpp);
+ xf86printOptionList(cf, ptr->scrn_option_lst, 1);
+ for (aptr = ptr->scrn_adaptor_lst; aptr; aptr = aptr->list.next)
+ {
+ fprintf (cf, "\tVideoAdaptor \"%s\"\n", aptr->al_adaptor_str);
+ }
+ if (ptr->scrn_virtualX && ptr->scrn_virtualY)
+ fprintf (cf, "\tVirtual %d %d\n",
+ ptr->scrn_virtualX,
+ ptr->scrn_virtualY);
+ for (dptr = ptr->scrn_display_lst; dptr; dptr = dptr->list.next)
+ {
+ fprintf (cf, "\tSubSection \"Display\"\n");
+ if (dptr->disp_comment)
+ fprintf (cf, "%s", dptr->disp_comment);
+ if (dptr->disp_frameX0 >= 0 || dptr->disp_frameY0 >= 0)
+ {
+ fprintf (cf, "\t\tViewport %d %d\n",
+ dptr->disp_frameX0, dptr->disp_frameY0);
+ }
+ if (dptr->disp_virtualX != 0 || dptr->disp_virtualY != 0)
+ {
+ fprintf (cf, "\t\tVirtual %d %d\n",
+ dptr->disp_virtualX, dptr->disp_virtualY);
+ }
+ if (dptr->disp_depth)
+ {
+ fprintf (cf, "\t\tDepth %d\n", dptr->disp_depth);
+ }
+ if (dptr->disp_bpp)
+ {
+ fprintf (cf, "\t\tFbBPP %d\n", dptr->disp_bpp);
+ }
+ if (dptr->disp_visual)
+ {
+ fprintf (cf, "\t\tVisual \"%s\"\n", dptr->disp_visual);
+ }
+ if (dptr->disp_weight.red != 0)
+ {
+ fprintf (cf, "\t\tWeight %d %d %d\n",
+ dptr->disp_weight.red, dptr->disp_weight.green, dptr->disp_weight.blue);
+ }
+ if (dptr->disp_black.red != -1)
+ {
+ fprintf (cf, "\t\tBlack 0x%04x 0x%04x 0x%04x\n",
+ dptr->disp_black.red, dptr->disp_black.green, dptr->disp_black.blue);
+ }
+ if (dptr->disp_white.red != -1)
+ {
+ fprintf (cf, "\t\tWhite 0x%04x 0x%04x 0x%04x\n",
+ dptr->disp_white.red, dptr->disp_white.green, dptr->disp_white.blue);
+ }
+ if (dptr->disp_mode_lst)
+ {
+ fprintf (cf, "\t\tModes ");
+ }
+ for (mptr = dptr->disp_mode_lst; mptr; mptr = mptr->list.next)
+ {
+ fprintf (cf, " \"%s\"", mptr->mode_name);
+ }
+ if (dptr->disp_mode_lst)
+ {
+ fprintf (cf, "\n");
+ }
+ xf86printOptionList(cf, dptr->disp_option_lst, 2);
+ fprintf (cf, "\tEndSubSection\n");
+ }
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+
+}
+
+void
+xf86freeScreenList (XF86ConfScreenPtr ptr)
+{
+ XF86ConfScreenPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->scrn_identifier);
+ TestFree (ptr->scrn_monitor_str);
+ TestFree (ptr->scrn_device_str);
+ TestFree (ptr->scrn_comment);
+ xf86optionListFree (ptr->scrn_option_lst);
+ xf86freeAdaptorLinkList (ptr->scrn_adaptor_lst);
+ xf86freeDisplayList (ptr->scrn_display_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+void
+xf86freeAdaptorLinkList (XF86ConfAdaptorLinkPtr ptr)
+{
+ XF86ConfAdaptorLinkPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->al_adaptor_str);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+void
+xf86freeDisplayList (XF86ConfDisplayPtr ptr)
+{
+ XF86ConfDisplayPtr prev;
+
+ while (ptr)
+ {
+ xf86freeModeList (ptr->disp_mode_lst);
+ xf86optionListFree (ptr->disp_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+void
+xf86freeModeList (XF86ModePtr ptr)
+{
+ XF86ModePtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->mode_name);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+int
+xf86validateScreen (XF86ConfigPtr p)
+{
+ XF86ConfScreenPtr screen = p->conf_screen_lst;
+ XF86ConfMonitorPtr monitor;
+ XF86ConfAdaptorLinkPtr adaptor;
+
+ while (screen)
+ {
+ if (screen->scrn_obso_driver && !screen->scrn_identifier)
+ screen->scrn_identifier = screen->scrn_obso_driver;
+
+ monitor = xf86findMonitor (screen->scrn_monitor_str, p->conf_monitor_lst);
+ if (screen->scrn_monitor_str)
+ {
+ if (monitor)
+ {
+ screen->scrn_monitor = monitor;
+ if (!xf86validateMonitor(p, screen))
+ return FALSE;
+ }
+ }
+
+ screen->scrn_device= xf86findDevice (screen->scrn_device_str, p->conf_device_lst);
+
+ adaptor = screen->scrn_adaptor_lst;
+ while (adaptor)
+ {
+ adaptor->al_adaptor = xf86findVideoAdaptor (adaptor->al_adaptor_str, p->conf_videoadaptor_lst);
+ if (!adaptor->al_adaptor)
+ {
+ xf86validationError (UNDEFINED_ADAPTOR_MSG, adaptor->al_adaptor_str, screen->scrn_identifier);
+ return FALSE;
+ }
+ else if (adaptor->al_adaptor->va_fwdref)
+ {
+ xf86validationError (ADAPTOR_REF_TWICE_MSG, adaptor->al_adaptor_str,
+ adaptor->al_adaptor->va_fwdref);
+ return FALSE;
+ }
+
+ adaptor->al_adaptor->va_fwdref = strdup(screen->scrn_identifier);
+ adaptor = adaptor->list.next;
+ }
+
+ screen = screen->list.next;
+ }
+
+ return TRUE;
+}
+
+XF86ConfScreenPtr
+xf86findScreen (const char *ident, XF86ConfScreenPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->scrn_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
diff --git a/xorg-server/hw/xfree86/parser/Video.c b/xorg-server/hw/xfree86/parser/Video.c index beeb43e4f..40a909707 100644 --- a/xorg-server/hw/xfree86/parser/Video.c +++ b/xorg-server/hw/xfree86/parser/Video.c @@ -1,296 +1,296 @@ -/* - * - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -/* View/edit this file with tab stops set to 4 */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86Parser.h" -#include "xf86tokens.h" -#include "Configint.h" - -extern LexRec val; - -static xf86ConfigSymTabRec VideoPortTab[] = -{ - {ENDSUBSECTION, "endsubsection"}, - {IDENTIFIER, "identifier"}, - {OPTION, "option"}, - {-1, ""}, -}; - -#define CLEANUP xf86freeVideoPortList - -static void -xf86freeVideoPortList (XF86ConfVideoPortPtr ptr) -{ - XF86ConfVideoPortPtr prev; - - while (ptr) - { - TestFree (ptr->vp_identifier); - TestFree (ptr->vp_comment); - xf86optionListFree (ptr->vp_option_lst); - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -static XF86ConfVideoPortPtr -xf86parseVideoPortSubSection (void) -{ - int has_ident = FALSE; - int token; - parsePrologue (XF86ConfVideoPortPtr, XF86ConfVideoPortRec) - - while ((token = xf86getToken (VideoPortTab)) != ENDSUBSECTION) - { - switch (token) - { - case COMMENT: - ptr->vp_comment = xf86addComment(ptr->vp_comment, val.str); - break; - case IDENTIFIER: - if (xf86getSubToken (&(ptr->vp_comment)) != STRING) - Error (QUOTE_MSG, "Identifier"); - if (has_ident == TRUE) - Error (MULTIPLE_MSG, "Identifier"); - ptr->vp_identifier = val.str; - has_ident = TRUE; - break; - case OPTION: - ptr->vp_option_lst = xf86parseOption(ptr->vp_option_lst); - break; - - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error (INVALID_KEYWORD_MSG, xf86tokenString ()); - break; - } - } - -#ifdef DEBUG - printf ("VideoPort subsection parsed\n"); -#endif - - return ptr; -} - -#undef CLEANUP - -static xf86ConfigSymTabRec VideoAdaptorTab[] = -{ - {ENDSECTION, "endsection"}, - {IDENTIFIER, "identifier"}, - {VENDOR, "vendorname"}, - {BOARD, "boardname"}, - {BUSID, "busid"}, - {DRIVER, "driver"}, - {OPTION, "option"}, - {SUBSECTION, "subsection"}, - {-1, ""}, -}; - -#define CLEANUP xf86freeVideoAdaptorList - -XF86ConfVideoAdaptorPtr -xf86parseVideoAdaptorSection (void) -{ - int has_ident = FALSE; - int token; - - parsePrologue (XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec) - - while ((token = xf86getToken (VideoAdaptorTab)) != ENDSECTION) - { - switch (token) - { - case COMMENT: - ptr->va_comment = xf86addComment(ptr->va_comment, val.str); - break; - case IDENTIFIER: - if (xf86getSubToken (&(ptr->va_comment)) != STRING) - Error (QUOTE_MSG, "Identifier"); - ptr->va_identifier = val.str; - if (has_ident == TRUE) - Error (MULTIPLE_MSG, "Identifier"); - has_ident = TRUE; - break; - case VENDOR: - if (xf86getSubToken (&(ptr->va_comment)) != STRING) - Error (QUOTE_MSG, "Vendor"); - ptr->va_vendor = val.str; - break; - case BOARD: - if (xf86getSubToken (&(ptr->va_comment)) != STRING) - Error (QUOTE_MSG, "Board"); - ptr->va_board = val.str; - break; - case BUSID: - if (xf86getSubToken (&(ptr->va_comment)) != STRING) - Error (QUOTE_MSG, "BusID"); - ptr->va_busid = val.str; - break; - case DRIVER: - if (xf86getSubToken (&(ptr->va_comment)) != STRING) - Error (QUOTE_MSG, "Driver"); - ptr->va_driver = val.str; - break; - case OPTION: - ptr->va_option_lst = xf86parseOption(ptr->va_option_lst); - break; - case SUBSECTION: - if (xf86getSubToken (&(ptr->va_comment)) != STRING) - Error (QUOTE_MSG, "SubSection"); - { - HANDLE_LIST (va_port_lst, xf86parseVideoPortSubSection, - XF86ConfVideoPortPtr); - } - break; - - case EOF_TOKEN: - Error (UNEXPECTED_EOF_MSG, NULL); - break; - default: - Error (INVALID_KEYWORD_MSG, xf86tokenString ()); - break; - } - } - - if (!has_ident) - Error (NO_IDENT_MSG, NULL); - -#ifdef DEBUG - printf ("VideoAdaptor section parsed\n"); -#endif - - return ptr; -} - -void -xf86printVideoAdaptorSection (FILE * cf, XF86ConfVideoAdaptorPtr ptr) -{ - XF86ConfVideoPortPtr pptr; - - while (ptr) - { - fprintf (cf, "Section \"VideoAdaptor\"\n"); - if (ptr->va_comment) - fprintf (cf, "%s", ptr->va_comment); - if (ptr->va_identifier) - fprintf (cf, "\tIdentifier \"%s\"\n", ptr->va_identifier); - if (ptr->va_vendor) - fprintf (cf, "\tVendorName \"%s\"\n", ptr->va_vendor); - if (ptr->va_board) - fprintf (cf, "\tBoardName \"%s\"\n", ptr->va_board); - if (ptr->va_busid) - fprintf (cf, "\tBusID \"%s\"\n", ptr->va_busid); - if (ptr->va_driver) - fprintf (cf, "\tDriver \"%s\"\n", ptr->va_driver); - xf86printOptionList(cf, ptr->va_option_lst, 1); - for (pptr = ptr->va_port_lst; pptr; pptr = pptr->list.next) - { - fprintf (cf, "\tSubSection \"VideoPort\"\n"); - if (pptr->vp_comment) - fprintf (cf, "%s", pptr->vp_comment); - if (pptr->vp_identifier) - fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vp_identifier); - xf86printOptionList(cf, pptr->vp_option_lst, 2); - fprintf (cf, "\tEndSubSection\n"); - } - fprintf (cf, "EndSection\n\n"); - ptr = ptr->list.next; - } - -} - -void -xf86freeVideoAdaptorList (XF86ConfVideoAdaptorPtr ptr) -{ - XF86ConfVideoAdaptorPtr prev; - - while (ptr) - { - TestFree (ptr->va_identifier); - TestFree (ptr->va_vendor); - TestFree (ptr->va_board); - TestFree (ptr->va_busid); - TestFree (ptr->va_driver); - TestFree (ptr->va_fwdref); - TestFree (ptr->va_comment); - xf86freeVideoPortList (ptr->va_port_lst); - xf86optionListFree (ptr->va_option_lst); - prev = ptr; - ptr = ptr->list.next; - free (prev); - } -} - -XF86ConfVideoAdaptorPtr -xf86findVideoAdaptor (const char *ident, XF86ConfVideoAdaptorPtr p) -{ - while (p) - { - if (xf86nameCompare (ident, p->va_identifier) == 0) - return (p); - - p = p->list.next; - } - return (NULL); -} +/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec VideoPortTab[] =
+{
+ {ENDSUBSECTION, "endsubsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeVideoPortList
+
+static void
+xf86freeVideoPortList (XF86ConfVideoPortPtr ptr)
+{
+ XF86ConfVideoPortPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->vp_identifier);
+ TestFree (ptr->vp_comment);
+ xf86optionListFree (ptr->vp_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+static XF86ConfVideoPortPtr
+xf86parseVideoPortSubSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfVideoPortPtr, XF86ConfVideoPortRec)
+
+ while ((token = xf86getToken (VideoPortTab)) != ENDSUBSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->vp_comment = xf86addComment(ptr->vp_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->vp_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->vp_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case OPTION:
+ ptr->vp_option_lst = xf86parseOption(ptr->vp_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("VideoPort subsection parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+static xf86ConfigSymTabRec VideoAdaptorTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {BOARD, "boardname"},
+ {BUSID, "busid"},
+ {DRIVER, "driver"},
+ {OPTION, "option"},
+ {SUBSECTION, "subsection"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeVideoAdaptorList
+
+XF86ConfVideoAdaptorPtr
+xf86parseVideoAdaptorSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue (XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec)
+
+ while ((token = xf86getToken (VideoAdaptorTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->va_comment = xf86addComment(ptr->va_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ ptr->va_identifier = val.str;
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Vendor");
+ ptr->va_vendor = val.str;
+ break;
+ case BOARD:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Board");
+ ptr->va_board = val.str;
+ break;
+ case BUSID:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "BusID");
+ ptr->va_busid = val.str;
+ break;
+ case DRIVER:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ ptr->va_driver = val.str;
+ break;
+ case OPTION:
+ ptr->va_option_lst = xf86parseOption(ptr->va_option_lst);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "SubSection");
+ {
+ HANDLE_LIST (va_port_lst, xf86parseVideoPortSubSection,
+ XF86ConfVideoPortPtr);
+ }
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("VideoAdaptor section parsed\n");
+#endif
+
+ return ptr;
+}
+
+void
+xf86printVideoAdaptorSection (FILE * cf, XF86ConfVideoAdaptorPtr ptr)
+{
+ XF86ConfVideoPortPtr pptr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"VideoAdaptor\"\n");
+ if (ptr->va_comment)
+ fprintf (cf, "%s", ptr->va_comment);
+ if (ptr->va_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->va_identifier);
+ if (ptr->va_vendor)
+ fprintf (cf, "\tVendorName \"%s\"\n", ptr->va_vendor);
+ if (ptr->va_board)
+ fprintf (cf, "\tBoardName \"%s\"\n", ptr->va_board);
+ if (ptr->va_busid)
+ fprintf (cf, "\tBusID \"%s\"\n", ptr->va_busid);
+ if (ptr->va_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->va_driver);
+ xf86printOptionList(cf, ptr->va_option_lst, 1);
+ for (pptr = ptr->va_port_lst; pptr; pptr = pptr->list.next)
+ {
+ fprintf (cf, "\tSubSection \"VideoPort\"\n");
+ if (pptr->vp_comment)
+ fprintf (cf, "%s", pptr->vp_comment);
+ if (pptr->vp_identifier)
+ fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vp_identifier);
+ xf86printOptionList(cf, pptr->vp_option_lst, 2);
+ fprintf (cf, "\tEndSubSection\n");
+ }
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+
+}
+
+void
+xf86freeVideoAdaptorList (XF86ConfVideoAdaptorPtr ptr)
+{
+ XF86ConfVideoAdaptorPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->va_identifier);
+ TestFree (ptr->va_vendor);
+ TestFree (ptr->va_board);
+ TestFree (ptr->va_busid);
+ TestFree (ptr->va_driver);
+ TestFree (ptr->va_fwdref);
+ TestFree (ptr->va_comment);
+ xf86freeVideoPortList (ptr->va_port_lst);
+ xf86optionListFree (ptr->va_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+XF86ConfVideoAdaptorPtr
+xf86findVideoAdaptor (const char *ident, XF86ConfVideoAdaptorPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->va_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
diff --git a/xorg-server/hw/xfree86/parser/read.c b/xorg-server/hw/xfree86/parser/read.c index 4e42b24f0..715626c53 100644 --- a/xorg-server/hw/xfree86/parser/read.c +++ b/xorg-server/hw/xfree86/parser/read.c @@ -1,318 +1,318 @@ -/* - * - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* View/edit this file with tab stops set to 4 */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86Parser.h" -#include "xf86tokens.h" -#include "Configint.h" - -extern LexRec val; - -static xf86ConfigSymTabRec TopLevelTab[] = -{ - {SECTION, "section"}, - {-1, ""}, -}; - -#define CLEANUP xf86freeConfig - -/* - * This function resolves name references and reports errors if the named - * objects cannot be found. - */ -static int -xf86validateConfig (XF86ConfigPtr p) -{ - if (!xf86validateScreen (p)) - return FALSE; - if (!xf86validateInput (p)) - return FALSE; - if (!xf86validateLayout (p)) - return FALSE; - - return (TRUE); -} - -XF86ConfigPtr -xf86readConfigFile (void) -{ - int token; - XF86ConfigPtr ptr = NULL; - - if ((ptr = calloc (1, sizeof (XF86ConfigRec))) == NULL) - { - return NULL; - } - - while ((token = xf86getToken (TopLevelTab)) != EOF_TOKEN) - { - switch (token) - { - case COMMENT: - ptr->conf_comment = xf86addComment(ptr->conf_comment, val.str); - break; - case SECTION: - if (xf86getSubToken (&(ptr->conf_comment)) != STRING) - { - xf86parseError (QUOTE_MSG, "Section"); - CLEANUP (ptr); - return (NULL); - } - xf86setSection (val.str); - if (xf86nameCompare (val.str, "files") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_RETURN (conf_files, xf86parseFilesSection ()); - } - else if (xf86nameCompare (val.str, "serverflags") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_RETURN (conf_flags, xf86parseFlagsSection ()); - } - else if (xf86nameCompare (val.str, "pointer") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_LIST (conf_input_lst, xf86parsePointerSection, - XF86ConfInputPtr); - } - else if (xf86nameCompare (val.str, "videoadaptor") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_LIST (conf_videoadaptor_lst, xf86parseVideoAdaptorSection, - XF86ConfVideoAdaptorPtr); - } - else if (xf86nameCompare (val.str, "device") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_LIST (conf_device_lst, xf86parseDeviceSection, - XF86ConfDevicePtr); - } - else if (xf86nameCompare (val.str, "monitor") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_LIST (conf_monitor_lst, xf86parseMonitorSection, - XF86ConfMonitorPtr); - } - else if (xf86nameCompare (val.str, "modes") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_LIST (conf_modes_lst, xf86parseModesSection, - XF86ConfModesPtr); - } - else if (xf86nameCompare (val.str, "screen") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_LIST (conf_screen_lst, xf86parseScreenSection, - XF86ConfScreenPtr); - } - else if (xf86nameCompare(val.str, "inputdevice") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_LIST (conf_input_lst, xf86parseInputSection, - XF86ConfInputPtr); - } - else if (xf86nameCompare(val.str, "inputclass") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_LIST (conf_inputclass_lst, - xf86parseInputClassSection, - XF86ConfInputClassPtr); - } - else if (xf86nameCompare (val.str, "module") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_RETURN (conf_modules, xf86parseModuleSection ()); - } - else if (xf86nameCompare (val.str, "serverlayout") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_LIST (conf_layout_lst, xf86parseLayoutSection, - XF86ConfLayoutPtr); - } - else if (xf86nameCompare (val.str, "vendor") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_LIST (conf_vendor_lst, xf86parseVendorSection, - XF86ConfVendorPtr); - } - else if (xf86nameCompare (val.str, "dri") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_RETURN (conf_dri, xf86parseDRISection ()); - } - else if (xf86nameCompare (val.str, "extensions") == 0) - { - free(val.str); - val.str = NULL; - HANDLE_RETURN (conf_extensions, xf86parseExtensionsSection ()); - } - else - { - free(val.str); - val.str = NULL; - Error (INVALID_SECTION_MSG, xf86tokenString ()); - } - break; - default: - free(val.str); - val.str = NULL; - Error (INVALID_KEYWORD_MSG, xf86tokenString ()); - } - } - - if (xf86validateConfig (ptr)) - return (ptr); - else - { - CLEANUP (ptr); - return (NULL); - } -} - -#undef CLEANUP - -/* - * adds an item to the end of the linked list. Any record whose first field - * is a GenericListRec can be cast to this type and used with this function. - * A pointer to the head of the list is returned to handle the addition of - * the first item. - */ -GenericListPtr -xf86addListItem (GenericListPtr head, GenericListPtr new) -{ - GenericListPtr p = head; - GenericListPtr last = NULL; - - while (p) - { - last = p; - p = p->next; - } - - if (last) - { - last->next = new; - return (head); - } - else - return (new); -} - -/* - * Test if one chained list contains the other. - * In this case both list have the same endpoint (provided they don't loop) - */ -int -xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2) -{ - GenericListPtr p = list_1; - GenericListPtr last_1 = NULL, last_2 = NULL; - - while (p) { - last_1 = p; - p = p->next; - } - - p = list_2; - while (p) { - last_2 = p; - p = p->next; - } - - return (!(last_1 == last_2)); -} - -void -xf86freeConfig (XF86ConfigPtr p) -{ - if (p == NULL) - return; - - xf86freeFiles (p->conf_files); - xf86freeModules (p->conf_modules); - xf86freeFlags (p->conf_flags); - xf86freeMonitorList (p->conf_monitor_lst); - xf86freeModesList (p->conf_modes_lst); - xf86freeVideoAdaptorList (p->conf_videoadaptor_lst); - xf86freeDeviceList (p->conf_device_lst); - xf86freeScreenList (p->conf_screen_lst); - xf86freeLayoutList (p->conf_layout_lst); - xf86freeInputList (p->conf_input_lst); - xf86freeVendorList (p->conf_vendor_lst); - xf86freeDRI (p->conf_dri); - xf86freeExtensions (p->conf_extensions); - TestFree(p->conf_comment); - - free (p); -} +/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec TopLevelTab[] =
+{
+ {SECTION, "section"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeConfig
+
+/*
+ * This function resolves name references and reports errors if the named
+ * objects cannot be found.
+ */
+static int
+xf86validateConfig (XF86ConfigPtr p)
+{
+ if (!xf86validateScreen (p))
+ return FALSE;
+ if (!xf86validateInput (p))
+ return FALSE;
+ if (!xf86validateLayout (p))
+ return FALSE;
+
+ return TRUE;
+}
+
+XF86ConfigPtr
+xf86readConfigFile (void)
+{
+ int token;
+ XF86ConfigPtr ptr = NULL;
+
+ if ((ptr = calloc (1, sizeof (XF86ConfigRec))) == NULL)
+ {
+ return NULL;
+ }
+
+ while ((token = xf86getToken (TopLevelTab)) != EOF_TOKEN)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->conf_comment = xf86addComment(ptr->conf_comment, val.str);
+ break;
+ case SECTION:
+ if (xf86getSubToken (&(ptr->conf_comment)) != STRING)
+ {
+ xf86parseError (QUOTE_MSG, "Section");
+ CLEANUP (ptr);
+ return NULL;
+ }
+ xf86setSection (val.str);
+ if (xf86nameCompare (val.str, "files") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_files, xf86parseFilesSection ());
+ }
+ else if (xf86nameCompare (val.str, "serverflags") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_flags, xf86parseFlagsSection ());
+ }
+ else if (xf86nameCompare (val.str, "pointer") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_input_lst, xf86parsePointerSection,
+ XF86ConfInputPtr);
+ }
+ else if (xf86nameCompare (val.str, "videoadaptor") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_videoadaptor_lst, xf86parseVideoAdaptorSection,
+ XF86ConfVideoAdaptorPtr);
+ }
+ else if (xf86nameCompare (val.str, "device") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_device_lst, xf86parseDeviceSection,
+ XF86ConfDevicePtr);
+ }
+ else if (xf86nameCompare (val.str, "monitor") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_monitor_lst, xf86parseMonitorSection,
+ XF86ConfMonitorPtr);
+ }
+ else if (xf86nameCompare (val.str, "modes") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_modes_lst, xf86parseModesSection,
+ XF86ConfModesPtr);
+ }
+ else if (xf86nameCompare (val.str, "screen") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_screen_lst, xf86parseScreenSection,
+ XF86ConfScreenPtr);
+ }
+ else if (xf86nameCompare(val.str, "inputdevice") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_input_lst, xf86parseInputSection,
+ XF86ConfInputPtr);
+ }
+ else if (xf86nameCompare(val.str, "inputclass") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_inputclass_lst,
+ xf86parseInputClassSection,
+ XF86ConfInputClassPtr);
+ }
+ else if (xf86nameCompare (val.str, "module") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_modules, xf86parseModuleSection ());
+ }
+ else if (xf86nameCompare (val.str, "serverlayout") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_layout_lst, xf86parseLayoutSection,
+ XF86ConfLayoutPtr);
+ }
+ else if (xf86nameCompare (val.str, "vendor") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_vendor_lst, xf86parseVendorSection,
+ XF86ConfVendorPtr);
+ }
+ else if (xf86nameCompare (val.str, "dri") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_dri, xf86parseDRISection ());
+ }
+ else if (xf86nameCompare (val.str, "extensions") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_extensions, xf86parseExtensionsSection ());
+ }
+ else
+ {
+ free(val.str);
+ val.str = NULL;
+ Error (INVALID_SECTION_MSG, xf86tokenString ());
+ }
+ break;
+ default:
+ free(val.str);
+ val.str = NULL;
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ }
+ }
+
+ if (xf86validateConfig (ptr))
+ return ptr;
+ else
+ {
+ CLEANUP (ptr);
+ return NULL;
+ }
+}
+
+#undef CLEANUP
+
+/*
+ * adds an item to the end of the linked list. Any record whose first field
+ * is a GenericListRec can be cast to this type and used with this function.
+ * A pointer to the head of the list is returned to handle the addition of
+ * the first item.
+ */
+GenericListPtr
+xf86addListItem (GenericListPtr head, GenericListPtr new)
+{
+ GenericListPtr p = head;
+ GenericListPtr last = NULL;
+
+ while (p)
+ {
+ last = p;
+ p = p->next;
+ }
+
+ if (last)
+ {
+ last->next = new;
+ return head;
+ }
+ else
+ return new;
+}
+
+/*
+ * Test if one chained list contains the other.
+ * In this case both list have the same endpoint (provided they don't loop)
+ */
+int
+xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2)
+{
+ GenericListPtr p = list_1;
+ GenericListPtr last_1 = NULL, last_2 = NULL;
+
+ while (p) {
+ last_1 = p;
+ p = p->next;
+ }
+
+ p = list_2;
+ while (p) {
+ last_2 = p;
+ p = p->next;
+ }
+
+ return (!(last_1 == last_2));
+}
+
+void
+xf86freeConfig (XF86ConfigPtr p)
+{
+ if (p == NULL)
+ return;
+
+ xf86freeFiles (p->conf_files);
+ xf86freeModules (p->conf_modules);
+ xf86freeFlags (p->conf_flags);
+ xf86freeMonitorList (p->conf_monitor_lst);
+ xf86freeModesList (p->conf_modes_lst);
+ xf86freeVideoAdaptorList (p->conf_videoadaptor_lst);
+ xf86freeDeviceList (p->conf_device_lst);
+ xf86freeScreenList (p->conf_screen_lst);
+ xf86freeLayoutList (p->conf_layout_lst);
+ xf86freeInputList (p->conf_input_lst);
+ xf86freeVendorList (p->conf_vendor_lst);
+ xf86freeDRI (p->conf_dri);
+ xf86freeExtensions (p->conf_extensions);
+ TestFree(p->conf_comment);
+
+ free (p);
+}
diff --git a/xorg-server/hw/xfree86/parser/scan.c b/xorg-server/hw/xfree86/parser/scan.c index 06710d55a..99e1288a5 100644 --- a/xorg-server/hw/xfree86/parser/scan.c +++ b/xorg-server/hw/xfree86/parser/scan.c @@ -1,1247 +1,1232 @@ -/* - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* View/edit this file with tab stops set to 4 */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <dirent.h> -#include <unistd.h> -#include <stdarg.h> -#include <X11/Xdefs.h> -#include <X11/Xfuncproto.h> - -#if defined(_POSIX_SOURCE) -#include <limits.h> -#else -#define _POSIX_SOURCE -#include <limits.h> -#undef _POSIX_SOURCE -#endif /* _POSIX_SOURCE */ - -#if !defined(PATH_MAX) -#if defined(MAXPATHLEN) -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif /* MAXPATHLEN */ -#endif /* !PATH_MAX */ - -#if !defined(MAXHOSTNAMELEN) -#define MAXHOSTNAMELEN 32 -#endif /* !MAXHOSTNAMELEN */ - -#include "Configint.h" -#include "xf86tokens.h" - -#define CONFIG_BUF_LEN 1024 -#define CONFIG_MAX_FILES 64 - -static int StringToToken (char *, xf86ConfigSymTabRec *); - -static struct { - FILE *file; - char *path; -} configFiles[CONFIG_MAX_FILES]; -static const char **builtinConfig = NULL; -static int builtinIndex = 0; -static int configPos = 0; /* current readers position */ -static int configLineNo = 0; /* linenumber */ -static char *configBuf, *configRBuf; /* buffer for lines */ -static char *configPath; /* path to config file */ -static char *configDirPath; /* path to config dir */ -static char *configSection = NULL; /* name of current section being parsed */ -static int numFiles = 0; /* number of config files */ -static int curFileIndex = 0; /* index of current config file */ -static int pushToken = LOCK_TOKEN; -static int eol_seen = 0; /* private state to handle comments */ -LexRec val; - -/* - * xf86strToUL -- - * - * A portable, but restricted, version of strtoul(). It only understands - * hex, octal, and decimal. But it's good enough for our needs. - */ -static unsigned int -xf86strToUL (char *str) -{ - int base = 10; - char *p = str; - unsigned int tot = 0; - - if (*p == '0') - { - p++; - if ((*p == 'x') || (*p == 'X')) - { - p++; - base = 16; - } - else - base = 8; - } - while (*p) - { - if ((*p >= '0') && (*p <= ((base == 8) ? '7' : '9'))) - { - tot = tot * base + (*p - '0'); - } - else if ((base == 16) && (*p >= 'a') && (*p <= 'f')) - { - tot = tot * base + 10 + (*p - 'a'); - } - else if ((base == 16) && (*p >= 'A') && (*p <= 'F')) - { - tot = tot * base + 10 + (*p - 'A'); - } - else - { - return (tot); - } - p++; - } - return (tot); -} - -/* - * xf86getNextLine -- - * - * read from the configFiles FILE stream until we encounter a new - * line; this is effectively just a big wrapper for fgets(3). - * - * xf86getToken() assumes that we will read up to the next - * newline; we need to grow configBuf and configRBuf as needed to - * support that. - */ - -static char* -xf86getNextLine(void) -{ - static int configBufLen = CONFIG_BUF_LEN; - char *tmpConfigBuf, *tmpConfigRBuf; - int c, i, pos = 0, eolFound = 0; - char *ret = NULL; - - /* - * reallocate the string if it was grown last time (i.e., is no - * longer CONFIG_BUF_LEN); we malloc the new strings first, so - * that if either of the mallocs fail, we can fall back on the - * existing buffer allocations - */ - - if (configBufLen != CONFIG_BUF_LEN) { - - tmpConfigBuf = malloc(CONFIG_BUF_LEN); - tmpConfigRBuf = malloc(CONFIG_BUF_LEN); - - if (!tmpConfigBuf || !tmpConfigRBuf) { - - /* - * at least one of the mallocs failed; keep the old buffers - * and free any partial allocations - */ - - free(tmpConfigBuf); - free(tmpConfigRBuf); - - } else { - - /* - * malloc succeeded; free the old buffers and use the new - * buffers - */ - - configBufLen = CONFIG_BUF_LEN; - - free(configBuf); - free(configRBuf); - - configBuf = tmpConfigBuf; - configRBuf = tmpConfigRBuf; - } - } - - /* read in another block of chars */ - - do { - ret = fgets(configBuf + pos, configBufLen - pos - 1, - configFiles[curFileIndex].file); - - if (!ret) { - /* - * if the file doesn't end in a newline, add one - * and trigger another read - */ - if (pos != 0) { - strcpy(&configBuf[pos], "\n"); - ret = configBuf; - } else - break; - } - - /* search for EOL in the new block of chars */ - - for (i = pos; i < (configBufLen - 1); i++) { - c = configBuf[i]; - - if (c == '\0') break; - - if ((c == '\n') || (c == '\r')) { - eolFound = 1; - break; - } - } - - /* - * if we didn't find EOL, then grow the string and - * read in more - */ - - if (!eolFound) { - - tmpConfigBuf = realloc(configBuf, configBufLen + CONFIG_BUF_LEN); - tmpConfigRBuf = realloc(configRBuf, configBufLen + CONFIG_BUF_LEN); - - if (!tmpConfigBuf || !tmpConfigRBuf) { - - /* - * at least one of the reallocations failed; use the - * new allocation that succeeded, but we have to - * fallback to the previous configBufLen size and use - * the string we have, even though we don't have an - * EOL - */ - - if (tmpConfigBuf) configBuf = tmpConfigBuf; - if (tmpConfigRBuf) configRBuf = tmpConfigRBuf; - - break; - - } else { - - /* reallocation succeeded */ - - configBuf = tmpConfigBuf; - configRBuf = tmpConfigRBuf; - pos = i; - configBufLen += CONFIG_BUF_LEN; - } - } - - } while (!eolFound); - - return (ret); -} - -/* - * xf86getToken -- - * Read next Token from the config file. Handle the global variable - * pushToken. - */ -int -xf86getToken (xf86ConfigSymTabRec * tab) -{ - int c, i; - - /* - * First check whether pushToken has a different value than LOCK_TOKEN. - * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the - * oth * case the next token must be read from the input. - */ - if (pushToken == EOF_TOKEN) - return (EOF_TOKEN); - else if (pushToken == LOCK_TOKEN) - { - /* - * eol_seen is only set for the first token after a newline. - */ - eol_seen = 0; - - c = configBuf[configPos]; - - /* - * Get start of next Token. EOF is handled, - * whitespaces are skipped. - */ - -again: - if (!c) - { - char *ret; - if (numFiles > 0) - ret = xf86getNextLine(); - else { - if (builtinConfig[builtinIndex] == NULL) - ret = NULL; - else { - ret = strncpy(configBuf, builtinConfig[builtinIndex], - CONFIG_BUF_LEN); - builtinIndex++; - } - } - if (ret == NULL) - { - /* - * if necessary, move to the next file and - * read the first line - */ - if (curFileIndex + 1 < numFiles) { - curFileIndex++; - configLineNo = 0; - goto again; - } - else - return (pushToken = EOF_TOKEN); - } - configLineNo++; - configPos = 0; - eol_seen = 1; - } - - i = 0; - for (;;) { - c = configBuf[configPos++]; - configRBuf[i++] = c; - switch (c) { - case ' ': - case '\t': - case '\r': - continue; - case '\n': - i = 0; - continue; - } - break; - } - if (c == '\0') - goto again; - - if (c == '#') - { - do - { - configRBuf[i++] = (c = configBuf[configPos++]); - } - while ((c != '\n') && (c != '\r') && (c != '\0')); - configRBuf[i] = '\0'; - /* XXX no private copy. - * Use xf86addComment when setting a comment. - */ - val.str = configRBuf; - return (COMMENT); - } - - /* GJA -- handle '-' and ',' * Be careful: "-hsync" is a keyword. */ - else if ((c == ',') && !isalpha (configBuf[configPos])) - { - return COMMA; - } - else if ((c == '-') && !isalpha (configBuf[configPos])) - { - return DASH; - } - - /* - * Numbers are returned immediately ... - */ - if (isdigit (c)) - { - int base; - - if (c == '0') - if ((configBuf[configPos] == 'x') || - (configBuf[configPos] == 'X')) - { - base = 16; - val.numType = PARSE_HEX; - } - else - { - base = 8; - val.numType = PARSE_OCTAL; - } - else - { - base = 10; - val.numType = PARSE_DECIMAL; - } - - configRBuf[0] = c; - i = 1; - while (isdigit (c = configBuf[configPos++]) || - (c == '.') || (c == 'x') || (c == 'X') || - ((base == 16) && (((c >= 'a') && (c <= 'f')) || - ((c >= 'A') && (c <= 'F'))))) - configRBuf[i++] = c; - configPos--; /* GJA -- one too far */ - configRBuf[i] = '\0'; - val.num = xf86strToUL (configRBuf); - val.realnum = atof (configRBuf); - return (NUMBER); - } - - /* - * All Strings START with a \" ... - */ - else if (c == '\"') - { - i = -1; - do - { - configRBuf[++i] = (c = configBuf[configPos++]); - } - while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0')); - configRBuf[i] = '\0'; - val.str = malloc (strlen (configRBuf) + 1); - strcpy (val.str, configRBuf); /* private copy ! */ - return (STRING); - } - - /* - * ... and now we MUST have a valid token. The search is - * handled later along with the pushed tokens. - */ - else - { - configRBuf[0] = c; - i = 0; - do - { - configRBuf[++i] = (c = configBuf[configPos++]); - } - while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') && (c != '\0') && (c != '#')); - --configPos; - configRBuf[i] = '\0'; - i = 0; - } - - } - else - { - - /* - * Here we deal with pushed tokens. Reinitialize pushToken again. If - * the pushed token was NUMBER || STRING return them again ... - */ - int temp = pushToken; - pushToken = LOCK_TOKEN; - - if (temp == COMMA || temp == DASH) - return (temp); - if (temp == NUMBER || temp == STRING) - return (temp); - } - - /* - * Joop, at last we have to lookup the token ... - */ - if (tab) - { - i = 0; - while (tab[i].token != -1) - if (xf86nameCompare (configRBuf, tab[i].name) == 0) - return (tab[i].token); - else - i++; - } - - return (ERROR_TOKEN); /* Error catcher */ -} - -int -xf86getSubToken (char **comment) -{ - int token; - - for (;;) { - token = xf86getToken(NULL); - if (token == COMMENT) { - if (comment) - *comment = xf86addComment(*comment, val.str); - } - else - return (token); - } - /*NOTREACHED*/ -} - -int -xf86getSubTokenWithTab (char **comment, xf86ConfigSymTabRec *tab) -{ - int token; - - for (;;) { - token = xf86getToken(tab); - if (token == COMMENT) { - if (comment) - *comment = xf86addComment(*comment, val.str); - } - else - return (token); - } - /*NOTREACHED*/ -} - -void -xf86unGetToken (int token) -{ - pushToken = token; -} - -char * -xf86tokenString (void) -{ - return configRBuf; -} - -int -xf86pathIsAbsolute(const char *path) -{ - if (path && path[0] == '/') - return 1; - return 0; -} - -/* A path is "safe" if it is relative and if it contains no ".." elements. */ -int -xf86pathIsSafe(const char *path) -{ - if (xf86pathIsAbsolute(path)) - return 0; - - /* Compare with ".." */ - if (!strcmp(path, "..")) - return 0; - - /* Look for leading "../" */ - if (!strncmp(path, "../", 3)) - return 0; - - /* Look for trailing "/.." */ - if ((strlen(path) > 3) && !strcmp(path + strlen(path) - 3, "/..")) - return 0; - - /* Look for "/../" */ - if (strstr(path, "/../")) - return 0; - - return 1; -} - -/* - * This function substitutes the following escape sequences: - * - * %A cmdline argument as an absolute path (must be absolute to match) - * %R cmdline argument as a relative path - * %S cmdline argument as a "safe" path (relative, and no ".." elements) - * %X default config file name ("xorg.conf") - * %H hostname - * %E config file environment ($XORGCONFIG) as an absolute path - * %F config file environment ($XORGCONFIG) as a relative path - * %G config file environment ($XORGCONFIG) as a safe path - * %P projroot - * %C sysconfdir - * %D datadir - * %M major version number - * %% % - */ - -#ifndef XCONFIGFILE -#define XCONFIGFILE "xorg.conf" -#endif -#ifndef XCONFIGDIR -#define XCONFIGDIR "xorg.conf.d" -#endif -#ifndef XCONFIGSUFFIX -#define XCONFIGSUFFIX ".conf" -#endif -#ifndef PROJECTROOT -#define PROJECTROOT "/usr/X11R6" -#endif -#ifndef SYSCONFDIR -#define SYSCONFDIR PROJECTROOT "/etc" -#endif -#ifndef DATADIR -#define DATADIR PROJECTROOT "/share" -#endif -#ifndef XCONFENV -#define XCONFENV "XORGCONFIG" -#endif -#define XFREE86CFGFILE "XF86Config" -#ifndef XF86_VERSION_MAJOR -#ifdef XVERSION -#if XVERSION > 40000000 -#define XF86_VERSION_MAJOR (XVERSION / 10000000) -#else -#define XF86_VERSION_MAJOR (XVERSION / 1000) -#endif -#else -#define XF86_VERSION_MAJOR 4 -#endif -#endif - -#define BAIL_OUT do { \ - free(result); \ - return NULL; \ - } while (0) - -#define CHECK_LENGTH do { \ - if (l > PATH_MAX) { \ - BAIL_OUT; \ - } \ - } while (0) - -#define APPEND_STR(s) do { \ - if (strlen(s) + l > PATH_MAX) { \ - BAIL_OUT; \ - } else { \ - strcpy(result + l, s); \ - l += strlen(s); \ - } \ - } while (0) - -static char * -DoSubstitution(const char *template, const char *cmdline, const char *projroot, - int *cmdlineUsed, int *envUsed, - const char *XConfigFile) -{ - char *result; - int i, l; - static const char *env = NULL; - static char *hostname = NULL; - static char majorvers[3] = ""; - - if (!template) - return NULL; - - if (cmdlineUsed) - *cmdlineUsed = 0; - if (envUsed) - *envUsed = 0; - - result = malloc(PATH_MAX + 1); - l = 0; - for (i = 0; template[i]; i++) { - if (template[i] != '%') { - result[l++] = template[i]; - CHECK_LENGTH; - } else { - switch (template[++i]) { - case 'A': - if (cmdline && xf86pathIsAbsolute(cmdline)) { - APPEND_STR(cmdline); - if (cmdlineUsed) - *cmdlineUsed = 1; - } else - BAIL_OUT; - break; - case 'R': - if (cmdline && !xf86pathIsAbsolute(cmdline)) { - APPEND_STR(cmdline); - if (cmdlineUsed) - *cmdlineUsed = 1; - } else - BAIL_OUT; - break; - case 'S': - if (cmdline && xf86pathIsSafe(cmdline)) { - APPEND_STR(cmdline); - if (cmdlineUsed) - *cmdlineUsed = 1; - } else - BAIL_OUT; - break; - case 'X': - APPEND_STR(XConfigFile); - break; - case 'H': - if (!hostname) { - if ((hostname = malloc(MAXHOSTNAMELEN + 1))) { - if (gethostname(hostname, MAXHOSTNAMELEN) == 0) { - hostname[MAXHOSTNAMELEN] = '\0'; - } else { - free(hostname); - hostname = NULL; - } - } - } - if (hostname) - APPEND_STR(hostname); - break; - case 'E': - if (!env) - env = getenv(XCONFENV); - if (env && xf86pathIsAbsolute(env)) { - APPEND_STR(env); - if (envUsed) - *envUsed = 1; - } else - BAIL_OUT; - break; - case 'F': - if (!env) - env = getenv(XCONFENV); - if (env && !xf86pathIsAbsolute(env)) { - APPEND_STR(env); - if (envUsed) - *envUsed = 1; - } else - BAIL_OUT; - break; - case 'G': - if (!env) - env = getenv(XCONFENV); - if (env && xf86pathIsSafe(env)) { - APPEND_STR(env); - if (envUsed) - *envUsed = 1; - } else - BAIL_OUT; - break; - case 'P': - if (projroot && xf86pathIsAbsolute(projroot)) - APPEND_STR(projroot); - else - BAIL_OUT; - break; - case 'C': - APPEND_STR(SYSCONFDIR); - break; - case 'D': - APPEND_STR(DATADIR); - break; - case 'M': - if (!majorvers[0]) { - if (XF86_VERSION_MAJOR < 0 || XF86_VERSION_MAJOR > 99) { - fprintf(stderr, "XF86_VERSION_MAJOR is out of range\n"); - BAIL_OUT; - } else - sprintf(majorvers, "%d", XF86_VERSION_MAJOR); - } - APPEND_STR(majorvers); - break; - case '%': - result[l++] = '%'; - CHECK_LENGTH; - break; - default: - fprintf(stderr, "invalid escape %%%c found in path template\n", - template[i]); - BAIL_OUT; - break; - } - } - } -#ifdef DEBUG - fprintf(stderr, "Converted `%s' to `%s'\n", template, result); -#endif - return result; -} - -/* - * Given some searching parameters, locate and open the xorg config file. - */ -static char * -OpenConfigFile(const char *path, const char *cmdline, const char *projroot, - const char *confname) -{ - char *filepath = NULL; - char *pathcopy; - const char *template; - int cmdlineUsed = 0; - FILE *file = NULL; - - pathcopy = strdup(path); - for (template = strtok(pathcopy, ","); template && !file; - template = strtok(NULL, ",")) { - filepath = DoSubstitution(template, cmdline, projroot, - &cmdlineUsed, NULL, confname); - if (!filepath) - continue; - if (cmdline && !cmdlineUsed) { - free(filepath); - filepath = NULL; - continue; - } - file = fopen(filepath, "r"); - if (!file) { - free(filepath); - filepath = NULL; - } - } - - if (file) { - configFiles[numFiles].file = file; - configFiles[numFiles].path = strdup(filepath); - numFiles++; - } - return filepath; -} - -/* - * Match non-hidden files in the xorg config directory with a .conf - * suffix. This filter is passed to scandir(3). - */ -static int -ConfigFilter(const struct dirent *de) -{ - const char *name = de->d_name; - size_t len; - size_t suflen = strlen(XCONFIGSUFFIX); - - if (!name || name[0] == '.') - return 0; - len = strlen(name); - if(len <= suflen) - return 0; - if (strcmp(&name[len-suflen], XCONFIGSUFFIX) != 0) - return 0; - return 1; -} - -static Bool -AddConfigDirFiles(const char *dirpath, struct dirent **list, int num) -{ - int i; - Bool openedFile = FALSE; - Bool warnOnce = FALSE; - - for (i = 0; i < num; i++) { - char *path; - FILE *file; - - if (numFiles >= CONFIG_MAX_FILES) { - if (!warnOnce) { - ErrorF("Maximum number of configuration " - "files opened\n"); - warnOnce = TRUE; - } - free(list[i]); - continue; - } - - path = malloc(PATH_MAX + 1); - snprintf(path, PATH_MAX + 1, "%s/%s", dirpath, - list[i]->d_name); - free(list[i]); - file = fopen(path, "r"); - if (!file) { - free(path); - continue; - } - openedFile = TRUE; - - configFiles[numFiles].file = file; - configFiles[numFiles].path = path; - numFiles++; - } - - return openedFile; -} - -/* - * Given some searching parameters, locate and open the xorg config - * directory. The directory does not need to contain config files. - */ -static char * -OpenConfigDir(const char *path, const char *cmdline, const char *projroot, - const char *confname) -{ - char *dirpath, *pathcopy; - const char *template; - Bool found = FALSE; - int cmdlineUsed = 0; - - pathcopy = strdup(path); - for (template = strtok(pathcopy, ","); template && !found; - template = strtok(NULL, ",")) { - struct dirent **list = NULL; - int num; - - dirpath = DoSubstitution(template, cmdline, projroot, - &cmdlineUsed, NULL, confname); - if (!dirpath) - continue; - if (cmdline && !cmdlineUsed) { - free(dirpath); - dirpath = NULL; - continue; - } - - /* match files named *.conf */ - num = scandir(dirpath, &list, ConfigFilter, alphasort); - found = AddConfigDirFiles(dirpath, list, num); - if (!found) { - free(dirpath); - dirpath = NULL; - if (list) - free(list); - } - } - - return dirpath; -} - -/* - * xf86initConfigFiles -- Setup global variables and buffers. - */ -void -xf86initConfigFiles(void) -{ - curFileIndex = 0; - configPos = 0; - configLineNo = 0; - pushToken = LOCK_TOKEN; - - configBuf = malloc(CONFIG_BUF_LEN); - configRBuf = malloc(CONFIG_BUF_LEN); - configBuf[0] = '\0'; /* sanity ... */ -} - -/* - * xf86openConfigFile -- - * - * This function take a config file search path (optional), a command-line - * specified file name (optional) and the ProjectRoot path (optional) and - * locates and opens a config file based on that information. If a - * command-line file name is specified, then this function fails if none - * of the located files. - * - * The return value is a pointer to the actual name of the file that was - * opened. When no file is found, the return value is NULL. - * - * The escape sequences allowed in the search path are defined above. - * - */ - -#ifndef DEFAULT_CONF_PATH -#define DEFAULT_CONF_PATH "/etc/X11/%S," \ - "%P/etc/X11/%S," \ - "/etc/X11/%G," \ - "%P/etc/X11/%G," \ - "/etc/X11/%X-%M," \ - "/etc/X11/%X," \ - "/etc/%X," \ - "%P/etc/X11/%X.%H," \ - "%P/etc/X11/%X-%M," \ - "%P/etc/X11/%X," \ - "%P/lib/X11/%X.%H," \ - "%P/lib/X11/%X-%M," \ - "%P/lib/X11/%X" -#endif - -const char * -xf86openConfigFile(const char *path, const char *cmdline, const char *projroot) -{ - if (!path || !path[0]) - path = DEFAULT_CONF_PATH; - if (!projroot || !projroot[0]) - projroot = PROJECTROOT; - - /* Search for a config file or a fallback */ - configPath = OpenConfigFile(path, cmdline, projroot, XCONFIGFILE); - if (!configPath) - configPath = OpenConfigFile(path, cmdline, projroot, - XFREE86CFGFILE); - return configPath; -} - -/* - * xf86openConfigDirFiles -- - * - * This function take a config directory search path (optional), a - * command-line specified directory name (optional) and the ProjectRoot path - * (optional) and locates and opens a config directory based on that - * information. If a command-line name is specified, then this function - * fails if it is not found. - * - * The return value is a pointer to the actual name of the direcoty that was - * opened. When no directory is found, the return value is NULL. - * - * The escape sequences allowed in the search path are defined above. - * - */ -const char * -xf86openConfigDirFiles(const char *path, const char *cmdline, - const char *projroot) -{ - if (!path || !path[0]) - path = DEFAULT_CONF_PATH; - if (!projroot || !projroot[0]) - projroot = PROJECTROOT; - - /* Search for the multiconf directory */ - configDirPath = OpenConfigDir(path, cmdline, projroot, XCONFIGDIR); - return configDirPath; -} - -void -xf86closeConfigFile (void) -{ - int i; - - free (configPath); - configPath = NULL; - free (configDirPath); - configDirPath = NULL; - free (configRBuf); - configRBuf = NULL; - free (configBuf); - configBuf = NULL; - - if (numFiles == 0) { - builtinConfig = NULL; - builtinIndex = 0; - } - for (i = 0; i < numFiles; i++) { - fclose(configFiles[i].file); - configFiles[i].file = NULL; - free(configFiles[i].path); - configFiles[i].path = NULL; - } - numFiles = 0; -} - -void -xf86setBuiltinConfig(const char *config[]) -{ - builtinConfig = config; -} - -void -xf86parseError (char *format,...) -{ - va_list ap; - char *filename = numFiles ? configFiles[curFileIndex].path : - "<builtin configuration>"; - - ErrorF ("Parse error on line %d of section %s in file %s\n\t", - configLineNo, configSection, filename); - va_start (ap, format); - VErrorF (format, ap); - va_end (ap); - - ErrorF ("\n"); -} - -void -xf86validationError (char *format,...) -{ - va_list ap; - char *filename = numFiles ? configFiles[curFileIndex].path : - "<builtin configuration>"; - - ErrorF ("Data incomplete in file %s\n\t", filename); - va_start (ap, format); - VErrorF (format, ap); - va_end (ap); - - ErrorF ("\n"); -} - -void -xf86setSection (char *section) -{ - if (configSection) - free(configSection); - configSection = malloc(strlen (section) + 1); - strcpy (configSection, section); -} - -/* - * xf86getToken -- - * Lookup a string if it is actually a token in disguise. - */ -int -xf86getStringToken (xf86ConfigSymTabRec * tab) -{ - return StringToToken (val.str, tab); -} - -static int -StringToToken (char *str, xf86ConfigSymTabRec * tab) -{ - int i; - - for (i = 0; tab[i].token != -1; i++) - { - if (!xf86nameCompare (tab[i].name, str)) - return tab[i].token; - } - return (ERROR_TOKEN); -} - - -/* - * Compare two names. The characters '_', ' ', and '\t' are ignored - * in the comparison. - */ -int -xf86nameCompare (const char *s1, const char *s2) -{ - char c1, c2; - - if (!s1 || *s1 == 0) { - if (!s2 || *s2 == 0) - return (0); - else - return (1); - } - - while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') - s1++; - while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') - s2++; - c1 = (isupper (*s1) ? tolower (*s1) : *s1); - c2 = (isupper (*s2) ? tolower (*s2) : *s2); - while (c1 == c2) - { - if (c1 == '\0') - return (0); - s1++; - s2++; - while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') - s1++; - while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') - s2++; - c1 = (isupper (*s1) ? tolower (*s1) : *s1); - c2 = (isupper (*s2) ? tolower (*s2) : *s2); - } - return (c1 - c2); -} - -char * -xf86addComment(char *cur, char *add) -{ - char *str; - int len, curlen, iscomment, hasnewline = 0, endnewline; - - if (add == NULL || add[0] == '\0') - return (cur); - - if (cur) { - curlen = strlen(cur); - if (curlen) - hasnewline = cur[curlen - 1] == '\n'; - eol_seen = 0; - } - else - curlen = 0; - - str = add; - iscomment = 0; - while (*str) { - if (*str != ' ' && *str != '\t') - break; - ++str; - } - iscomment = (*str == '#'); - - len = strlen(add); - endnewline = add[len - 1] == '\n'; - len += 1 + iscomment + (!hasnewline) + (!endnewline) + eol_seen; - - if ((str = realloc(cur, len + curlen)) == NULL) - return (cur); - - cur = str; - - if (eol_seen || (curlen && !hasnewline)) - cur[curlen++] = '\n'; - if (!iscomment) - cur[curlen++] = '#'; - strcpy(cur + curlen, add); - if (!endnewline) - strcat(cur, "\n"); - - return (cur); -} - -Bool -xf86getBoolValue(Bool *val, const char *str) -{ - if (!val || !str) - return FALSE; - if (*str == '\0') { - *val = TRUE; - } else { - if (xf86nameCompare(str, "1") == 0) - *val = TRUE; - else if (xf86nameCompare(str, "on") == 0) - *val = TRUE; - else if (xf86nameCompare(str, "true") == 0) - *val = TRUE; - else if (xf86nameCompare(str, "yes") == 0) - *val = TRUE; - else if (xf86nameCompare(str, "0") == 0) - *val = FALSE; - else if (xf86nameCompare(str, "off") == 0) - *val = FALSE; - else if (xf86nameCompare(str, "false") == 0) - *val = FALSE; - else if (xf86nameCompare(str, "no") == 0) - *val = FALSE; - else - return FALSE; - } - return TRUE; -} +/*
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <X11/Xdefs.h>
+#include <X11/Xfuncproto.h>
+
+#if defined(_POSIX_SOURCE)
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif /* _POSIX_SOURCE */
+
+#if !defined(PATH_MAX)
+#if defined(MAXPATHLEN)
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif /* MAXPATHLEN */
+#endif /* !PATH_MAX */
+
+#if !defined(MAXHOSTNAMELEN)
+#define MAXHOSTNAMELEN 32
+#endif /* !MAXHOSTNAMELEN */
+
+#include "Configint.h"
+#include "xf86tokens.h"
+
+#define CONFIG_BUF_LEN 1024
+#define CONFIG_MAX_FILES 64
+
+static int StringToToken (char *, xf86ConfigSymTabRec *);
+
+static struct {
+ FILE *file;
+ char *path;
+} configFiles[CONFIG_MAX_FILES];
+static const char **builtinConfig = NULL;
+static int builtinIndex = 0;
+static int configPos = 0; /* current readers position */
+static int configLineNo = 0; /* linenumber */
+static char *configBuf, *configRBuf; /* buffer for lines */
+static char *configPath; /* path to config file */
+static char *configDirPath; /* path to config dir */
+static char *configSection = NULL; /* name of current section being parsed */
+static int numFiles = 0; /* number of config files */
+static int curFileIndex = 0; /* index of current config file */
+static int pushToken = LOCK_TOKEN;
+static int eol_seen = 0; /* private state to handle comments */
+LexRec val;
+
+/*
+ * xf86strToUL --
+ *
+ * A portable, but restricted, version of strtoul(). It only understands
+ * hex, octal, and decimal. But it's good enough for our needs.
+ */
+static unsigned int
+xf86strToUL (char *str)
+{
+ int base = 10;
+ char *p = str;
+ unsigned int tot = 0;
+
+ if (*p == '0')
+ {
+ p++;
+ if ((*p == 'x') || (*p == 'X'))
+ {
+ p++;
+ base = 16;
+ }
+ else
+ base = 8;
+ }
+ while (*p)
+ {
+ if ((*p >= '0') && (*p <= ((base == 8) ? '7' : '9')))
+ {
+ tot = tot * base + (*p - '0');
+ }
+ else if ((base == 16) && (*p >= 'a') && (*p <= 'f'))
+ {
+ tot = tot * base + 10 + (*p - 'a');
+ }
+ else if ((base == 16) && (*p >= 'A') && (*p <= 'F'))
+ {
+ tot = tot * base + 10 + (*p - 'A');
+ }
+ else
+ {
+ return tot;
+ }
+ p++;
+ }
+ return tot;
+}
+
+/*
+ * xf86getNextLine --
+ *
+ * read from the configFiles FILE stream until we encounter a new
+ * line; this is effectively just a big wrapper for fgets(3).
+ *
+ * xf86getToken() assumes that we will read up to the next
+ * newline; we need to grow configBuf and configRBuf as needed to
+ * support that.
+ */
+
+static char*
+xf86getNextLine(void)
+{
+ static int configBufLen = CONFIG_BUF_LEN;
+ char *tmpConfigBuf, *tmpConfigRBuf;
+ int c, i, pos = 0, eolFound = 0;
+ char *ret = NULL;
+
+ /*
+ * reallocate the string if it was grown last time (i.e., is no
+ * longer CONFIG_BUF_LEN); we malloc the new strings first, so
+ * that if either of the mallocs fail, we can fall back on the
+ * existing buffer allocations
+ */
+
+ if (configBufLen != CONFIG_BUF_LEN) {
+
+ tmpConfigBuf = malloc(CONFIG_BUF_LEN);
+ tmpConfigRBuf = malloc(CONFIG_BUF_LEN);
+
+ if (!tmpConfigBuf || !tmpConfigRBuf) {
+
+ /*
+ * at least one of the mallocs failed; keep the old buffers
+ * and free any partial allocations
+ */
+
+ free(tmpConfigBuf);
+ free(tmpConfigRBuf);
+
+ } else {
+
+ /*
+ * malloc succeeded; free the old buffers and use the new
+ * buffers
+ */
+
+ configBufLen = CONFIG_BUF_LEN;
+
+ free(configBuf);
+ free(configRBuf);
+
+ configBuf = tmpConfigBuf;
+ configRBuf = tmpConfigRBuf;
+ }
+ }
+
+ /* read in another block of chars */
+
+ do {
+ ret = fgets(configBuf + pos, configBufLen - pos - 1,
+ configFiles[curFileIndex].file);
+
+ if (!ret) {
+ /*
+ * if the file doesn't end in a newline, add one
+ * and trigger another read
+ */
+ if (pos != 0) {
+ strcpy(&configBuf[pos], "\n");
+ ret = configBuf;
+ } else
+ break;
+ }
+
+ /* search for EOL in the new block of chars */
+
+ for (i = pos; i < (configBufLen - 1); i++) {
+ c = configBuf[i];
+
+ if (c == '\0') break;
+
+ if ((c == '\n') || (c == '\r')) {
+ eolFound = 1;
+ break;
+ }
+ }
+
+ /*
+ * if we didn't find EOL, then grow the string and
+ * read in more
+ */
+
+ if (!eolFound) {
+
+ tmpConfigBuf = realloc(configBuf, configBufLen + CONFIG_BUF_LEN);
+ tmpConfigRBuf = realloc(configRBuf, configBufLen + CONFIG_BUF_LEN);
+
+ if (!tmpConfigBuf || !tmpConfigRBuf) {
+
+ /*
+ * at least one of the reallocations failed; use the
+ * new allocation that succeeded, but we have to
+ * fallback to the previous configBufLen size and use
+ * the string we have, even though we don't have an
+ * EOL
+ */
+
+ if (tmpConfigBuf) configBuf = tmpConfigBuf;
+ if (tmpConfigRBuf) configRBuf = tmpConfigRBuf;
+
+ break;
+
+ } else {
+
+ /* reallocation succeeded */
+
+ configBuf = tmpConfigBuf;
+ configRBuf = tmpConfigRBuf;
+ pos = i;
+ configBufLen += CONFIG_BUF_LEN;
+ }
+ }
+
+ } while (!eolFound);
+
+ return ret;
+}
+
+/*
+ * xf86getToken --
+ * Read next Token from the config file. Handle the global variable
+ * pushToken.
+ */
+int
+xf86getToken (xf86ConfigSymTabRec * tab)
+{
+ int c, i;
+
+ /*
+ * First check whether pushToken has a different value than LOCK_TOKEN.
+ * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the
+ * oth * case the next token must be read from the input.
+ */
+ if (pushToken == EOF_TOKEN)
+ return EOF_TOKEN;
+ else if (pushToken == LOCK_TOKEN)
+ {
+ /*
+ * eol_seen is only set for the first token after a newline.
+ */
+ eol_seen = 0;
+
+ c = configBuf[configPos];
+
+ /*
+ * Get start of next Token. EOF is handled,
+ * whitespaces are skipped.
+ */
+
+again:
+ if (!c)
+ {
+ char *ret;
+ if (numFiles > 0)
+ ret = xf86getNextLine();
+ else {
+ if (builtinConfig[builtinIndex] == NULL)
+ ret = NULL;
+ else {
+ ret = strncpy(configBuf, builtinConfig[builtinIndex],
+ CONFIG_BUF_LEN);
+ builtinIndex++;
+ }
+ }
+ if (ret == NULL)
+ {
+ /*
+ * if necessary, move to the next file and
+ * read the first line
+ */
+ if (curFileIndex + 1 < numFiles) {
+ curFileIndex++;
+ configLineNo = 0;
+ goto again;
+ }
+ else
+ return pushToken = EOF_TOKEN;
+ }
+ configLineNo++;
+ configPos = 0;
+ eol_seen = 1;
+ }
+
+ i = 0;
+ for (;;) {
+ c = configBuf[configPos++];
+ configRBuf[i++] = c;
+ switch (c) {
+ case ' ':
+ case '\t':
+ case '\r':
+ continue;
+ case '\n':
+ i = 0;
+ continue;
+ }
+ break;
+ }
+ if (c == '\0')
+ goto again;
+
+ if (c == '#')
+ {
+ do
+ {
+ configRBuf[i++] = (c = configBuf[configPos++]);
+ }
+ while ((c != '\n') && (c != '\r') && (c != '\0'));
+ configRBuf[i] = '\0';
+ /* XXX no private copy.
+ * Use xf86addComment when setting a comment.
+ */
+ val.str = configRBuf;
+ return COMMENT;
+ }
+
+ /* GJA -- handle '-' and ',' * Be careful: "-hsync" is a keyword. */
+ else if ((c == ',') && !isalpha (configBuf[configPos]))
+ {
+ return COMMA;
+ }
+ else if ((c == '-') && !isalpha (configBuf[configPos]))
+ {
+ return DASH;
+ }
+
+ /*
+ * Numbers are returned immediately ...
+ */
+ if (isdigit (c))
+ {
+ int base;
+
+ if (c == '0')
+ if ((configBuf[configPos] == 'x') ||
+ (configBuf[configPos] == 'X'))
+ {
+ base = 16;
+ val.numType = PARSE_HEX;
+ }
+ else
+ {
+ base = 8;
+ val.numType = PARSE_OCTAL;
+ }
+ else
+ {
+ base = 10;
+ val.numType = PARSE_DECIMAL;
+ }
+
+ configRBuf[0] = c;
+ i = 1;
+ while (isdigit (c = configBuf[configPos++]) ||
+ (c == '.') || (c == 'x') || (c == 'X') ||
+ ((base == 16) && (((c >= 'a') && (c <= 'f')) ||
+ ((c >= 'A') && (c <= 'F')))))
+ configRBuf[i++] = c;
+ configPos--; /* GJA -- one too far */
+ configRBuf[i] = '\0';
+ val.num = xf86strToUL (configRBuf);
+ val.realnum = atof (configRBuf);
+ return NUMBER;
+ }
+
+ /*
+ * All Strings START with a \" ...
+ */
+ else if (c == '\"')
+ {
+ i = -1;
+ do
+ {
+ configRBuf[++i] = (c = configBuf[configPos++]);
+ }
+ while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0'));
+ configRBuf[i] = '\0';
+ val.str = malloc (strlen (configRBuf) + 1);
+ strcpy (val.str, configRBuf); /* private copy ! */
+ return STRING;
+ }
+
+ /*
+ * ... and now we MUST have a valid token. The search is
+ * handled later along with the pushed tokens.
+ */
+ else
+ {
+ configRBuf[0] = c;
+ i = 0;
+ do
+ {
+ configRBuf[++i] = (c = configBuf[configPos++]);
+ }
+ while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') && (c != '\0') && (c != '#'));
+ --configPos;
+ configRBuf[i] = '\0';
+ i = 0;
+ }
+
+ }
+ else
+ {
+
+ /*
+ * Here we deal with pushed tokens. Reinitialize pushToken again. If
+ * the pushed token was NUMBER || STRING return them again ...
+ */
+ int temp = pushToken;
+ pushToken = LOCK_TOKEN;
+
+ if (temp == COMMA || temp == DASH)
+ return temp;
+ if (temp == NUMBER || temp == STRING)
+ return temp;
+ }
+
+ /*
+ * Joop, at last we have to lookup the token ...
+ */
+ if (tab)
+ {
+ i = 0;
+ while (tab[i].token != -1)
+ if (xf86nameCompare (configRBuf, tab[i].name) == 0)
+ return tab[i].token;
+ else
+ i++;
+ }
+
+ return ERROR_TOKEN; /* Error catcher */
+}
+
+int
+xf86getSubToken (char **comment)
+{
+ int token;
+
+ for (;;) {
+ token = xf86getToken(NULL);
+ if (token == COMMENT) {
+ if (comment)
+ *comment = xf86addComment(*comment, val.str);
+ }
+ else
+ return token;
+ }
+ /*NOTREACHED*/
+}
+
+int
+xf86getSubTokenWithTab (char **comment, xf86ConfigSymTabRec *tab)
+{
+ int token;
+
+ for (;;) {
+ token = xf86getToken(tab);
+ if (token == COMMENT) {
+ if (comment)
+ *comment = xf86addComment(*comment, val.str);
+ }
+ else
+ return token;
+ }
+ /*NOTREACHED*/
+}
+
+void
+xf86unGetToken (int token)
+{
+ pushToken = token;
+}
+
+char *
+xf86tokenString (void)
+{
+ return configRBuf;
+}
+
+int
+xf86pathIsAbsolute(const char *path)
+{
+ if (path && path[0] == '/')
+ return 1;
+ return 0;
+}
+
+/* A path is "safe" if it is relative and if it contains no ".." elements. */
+int
+xf86pathIsSafe(const char *path)
+{
+ if (xf86pathIsAbsolute(path))
+ return 0;
+
+ /* Compare with ".." */
+ if (!strcmp(path, ".."))
+ return 0;
+
+ /* Look for leading "../" */
+ if (!strncmp(path, "../", 3))
+ return 0;
+
+ /* Look for trailing "/.." */
+ if ((strlen(path) > 3) && !strcmp(path + strlen(path) - 3, "/.."))
+ return 0;
+
+ /* Look for "/../" */
+ if (strstr(path, "/../"))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * This function substitutes the following escape sequences:
+ *
+ * %A cmdline argument as an absolute path (must be absolute to match)
+ * %R cmdline argument as a relative path
+ * %S cmdline argument as a "safe" path (relative, and no ".." elements)
+ * %X default config file name ("xorg.conf")
+ * %H hostname
+ * %E config file environment ($XORGCONFIG) as an absolute path
+ * %F config file environment ($XORGCONFIG) as a relative path
+ * %G config file environment ($XORGCONFIG) as a safe path
+ * %P projroot
+ * %C sysconfdir
+ * %D datadir
+ * %M config file format version number
+ * %% %
+ */
+
+#ifndef XCONFIGFILE
+#define XCONFIGFILE "xorg.conf"
+#endif
+#ifndef XCONFIGDIR
+#define XCONFIGDIR "xorg.conf.d"
+#endif
+#ifndef XCONFIGSUFFIX
+#define XCONFIGSUFFIX ".conf"
+#endif
+#ifndef PROJECTROOT
+#define PROJECTROOT "/usr/X11R6"
+#endif
+#ifndef SYSCONFDIR
+#define SYSCONFDIR PROJECTROOT "/etc"
+#endif
+#ifndef DATADIR
+#define DATADIR PROJECTROOT "/share"
+#endif
+#ifndef XCONFENV
+#define XCONFENV "XORGCONFIG"
+#endif
+/* xorg.conf is based on XF86Config version 4. If we ever break
+ compatibility of the xorg.conf syntax, we'll bump this version number. */
+#ifndef CONFIG_FILE_VERSION
+#define CONFIG_FILE_VERSION 4
+#endif
+
+#define BAIL_OUT do { \
+ free(result); \
+ return NULL; \
+ } while (0)
+
+#define CHECK_LENGTH do { \
+ if (l > PATH_MAX) { \
+ BAIL_OUT; \
+ } \
+ } while (0)
+
+#define APPEND_STR(s) do { \
+ if (strlen(s) + l > PATH_MAX) { \
+ BAIL_OUT; \
+ } else { \
+ strcpy(result + l, s); \
+ l += strlen(s); \
+ } \
+ } while (0)
+
+static char *
+DoSubstitution(const char *template, const char *cmdline, const char *projroot,
+ int *cmdlineUsed, int *envUsed,
+ const char *XConfigFile)
+{
+ char *result;
+ int i, l;
+ static const char *env = NULL;
+ static char *hostname = NULL;
+ static char majorvers[3] = "";
+
+ if (!template)
+ return NULL;
+
+ if (cmdlineUsed)
+ *cmdlineUsed = 0;
+ if (envUsed)
+ *envUsed = 0;
+
+ result = malloc(PATH_MAX + 1);
+ l = 0;
+ for (i = 0; template[i]; i++) {
+ if (template[i] != '%') {
+ result[l++] = template[i];
+ CHECK_LENGTH;
+ } else {
+ switch (template[++i]) {
+ case 'A':
+ if (cmdline && xf86pathIsAbsolute(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'R':
+ if (cmdline && !xf86pathIsAbsolute(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'S':
+ if (cmdline && xf86pathIsSafe(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'X':
+ APPEND_STR(XConfigFile);
+ break;
+ case 'H':
+ if (!hostname) {
+ if ((hostname = malloc(MAXHOSTNAMELEN + 1))) {
+ if (gethostname(hostname, MAXHOSTNAMELEN) == 0) {
+ hostname[MAXHOSTNAMELEN] = '\0';
+ } else {
+ free(hostname);
+ hostname = NULL;
+ }
+ }
+ }
+ if (hostname)
+ APPEND_STR(hostname);
+ break;
+ case 'E':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && xf86pathIsAbsolute(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'F':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && !xf86pathIsAbsolute(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'G':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && xf86pathIsSafe(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'P':
+ if (projroot && xf86pathIsAbsolute(projroot))
+ APPEND_STR(projroot);
+ else
+ BAIL_OUT;
+ break;
+ case 'C':
+ APPEND_STR(SYSCONFDIR);
+ break;
+ case 'D':
+ APPEND_STR(DATADIR);
+ break;
+ case 'M':
+ if (!majorvers[0]) {
+ snprintf(majorvers, sizeof(majorvers),
+ "%d", CONFIG_FILE_VERSION);
+ }
+ APPEND_STR(majorvers);
+ break;
+ case '%':
+ result[l++] = '%';
+ CHECK_LENGTH;
+ break;
+ default:
+ fprintf(stderr, "invalid escape %%%c found in path template\n",
+ template[i]);
+ BAIL_OUT;
+ break;
+ }
+ }
+ }
+#ifdef DEBUG
+ fprintf(stderr, "Converted `%s' to `%s'\n", template, result);
+#endif
+ return result;
+}
+
+/*
+ * Given some searching parameters, locate and open the xorg config file.
+ */
+static char *
+OpenConfigFile(const char *path, const char *cmdline, const char *projroot,
+ const char *confname)
+{
+ char *filepath = NULL;
+ char *pathcopy;
+ const char *template;
+ int cmdlineUsed = 0;
+ FILE *file = NULL;
+
+ pathcopy = strdup(path);
+ for (template = strtok(pathcopy, ","); template && !file;
+ template = strtok(NULL, ",")) {
+ filepath = DoSubstitution(template, cmdline, projroot,
+ &cmdlineUsed, NULL, confname);
+ if (!filepath)
+ continue;
+ if (cmdline && !cmdlineUsed) {
+ free(filepath);
+ filepath = NULL;
+ continue;
+ }
+ file = fopen(filepath, "r");
+ if (!file) {
+ free(filepath);
+ filepath = NULL;
+ }
+ }
+
+ if (file) {
+ configFiles[numFiles].file = file;
+ configFiles[numFiles].path = strdup(filepath);
+ numFiles++;
+ }
+ return filepath;
+}
+
+/*
+ * Match non-hidden files in the xorg config directory with a .conf
+ * suffix. This filter is passed to scandir(3).
+ */
+static int
+ConfigFilter(const struct dirent *de)
+{
+ const char *name = de->d_name;
+ size_t len;
+ size_t suflen = strlen(XCONFIGSUFFIX);
+
+ if (!name || name[0] == '.')
+ return 0;
+ len = strlen(name);
+ if(len <= suflen)
+ return 0;
+ if (strcmp(&name[len-suflen], XCONFIGSUFFIX) != 0)
+ return 0;
+ return 1;
+}
+
+static Bool
+AddConfigDirFiles(const char *dirpath, struct dirent **list, int num)
+{
+ int i;
+ Bool openedFile = FALSE;
+ Bool warnOnce = FALSE;
+
+ for (i = 0; i < num; i++) {
+ char *path;
+ FILE *file;
+
+ if (numFiles >= CONFIG_MAX_FILES) {
+ if (!warnOnce) {
+ ErrorF("Maximum number of configuration "
+ "files opened\n");
+ warnOnce = TRUE;
+ }
+ free(list[i]);
+ continue;
+ }
+
+ path = malloc(PATH_MAX + 1);
+ snprintf(path, PATH_MAX + 1, "%s/%s", dirpath,
+ list[i]->d_name);
+ free(list[i]);
+ file = fopen(path, "r");
+ if (!file) {
+ free(path);
+ continue;
+ }
+ openedFile = TRUE;
+
+ configFiles[numFiles].file = file;
+ configFiles[numFiles].path = path;
+ numFiles++;
+ }
+
+ return openedFile;
+}
+
+/*
+ * Given some searching parameters, locate and open the xorg config
+ * directory. The directory does not need to contain config files.
+ */
+static char *
+OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
+ const char *confname)
+{
+ char *dirpath, *pathcopy;
+ const char *template;
+ Bool found = FALSE;
+ int cmdlineUsed = 0;
+
+ pathcopy = strdup(path);
+ for (template = strtok(pathcopy, ","); template && !found;
+ template = strtok(NULL, ",")) {
+ struct dirent **list = NULL;
+ int num;
+
+ dirpath = DoSubstitution(template, cmdline, projroot,
+ &cmdlineUsed, NULL, confname);
+ if (!dirpath)
+ continue;
+ if (cmdline && !cmdlineUsed) {
+ free(dirpath);
+ dirpath = NULL;
+ continue;
+ }
+
+ /* match files named *.conf */
+ num = scandir(dirpath, &list, ConfigFilter, alphasort);
+ found = AddConfigDirFiles(dirpath, list, num);
+ if (!found) {
+ free(dirpath);
+ dirpath = NULL;
+ free(list);
+ }
+ }
+
+ return dirpath;
+}
+
+/*
+ * xf86initConfigFiles -- Setup global variables and buffers.
+ */
+void
+xf86initConfigFiles(void)
+{
+ curFileIndex = 0;
+ configPos = 0;
+ configLineNo = 0;
+ pushToken = LOCK_TOKEN;
+
+ configBuf = malloc(CONFIG_BUF_LEN);
+ configRBuf = malloc(CONFIG_BUF_LEN);
+ configBuf[0] = '\0'; /* sanity ... */
+}
+
+/*
+ * xf86openConfigFile --
+ *
+ * This function take a config file search path (optional), a command-line
+ * specified file name (optional) and the ProjectRoot path (optional) and
+ * locates and opens a config file based on that information. If a
+ * command-line file name is specified, then this function fails if none
+ * of the located files.
+ *
+ * The return value is a pointer to the actual name of the file that was
+ * opened. When no file is found, the return value is NULL.
+ *
+ * The escape sequences allowed in the search path are defined above.
+ *
+ */
+
+#ifndef DEFAULT_CONF_PATH
+#define DEFAULT_CONF_PATH "/etc/X11/%S," \
+ "%P/etc/X11/%S," \
+ "/etc/X11/%G," \
+ "%P/etc/X11/%G," \
+ "/etc/X11/%X-%M," \
+ "/etc/X11/%X," \
+ "/etc/%X," \
+ "%P/etc/X11/%X.%H," \
+ "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," \
+ "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
+
+const char *
+xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
+{
+ if (!path || !path[0])
+ path = DEFAULT_CONF_PATH;
+ if (!projroot || !projroot[0])
+ projroot = PROJECTROOT;
+
+ /* Search for a config file */
+ configPath = OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
+ return configPath;
+}
+
+/*
+ * xf86openConfigDirFiles --
+ *
+ * This function take a config directory search path (optional), a
+ * command-line specified directory name (optional) and the ProjectRoot path
+ * (optional) and locates and opens a config directory based on that
+ * information. If a command-line name is specified, then this function
+ * fails if it is not found.
+ *
+ * The return value is a pointer to the actual name of the direcoty that was
+ * opened. When no directory is found, the return value is NULL.
+ *
+ * The escape sequences allowed in the search path are defined above.
+ *
+ */
+const char *
+xf86openConfigDirFiles(const char *path, const char *cmdline,
+ const char *projroot)
+{
+ if (!path || !path[0])
+ path = DEFAULT_CONF_PATH;
+ if (!projroot || !projroot[0])
+ projroot = PROJECTROOT;
+
+ /* Search for the multiconf directory */
+ configDirPath = OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
+ return configDirPath;
+}
+
+void
+xf86closeConfigFile (void)
+{
+ int i;
+
+ free (configPath);
+ configPath = NULL;
+ free (configDirPath);
+ configDirPath = NULL;
+ free (configRBuf);
+ configRBuf = NULL;
+ free (configBuf);
+ configBuf = NULL;
+
+ if (numFiles == 0) {
+ builtinConfig = NULL;
+ builtinIndex = 0;
+ }
+ for (i = 0; i < numFiles; i++) {
+ fclose(configFiles[i].file);
+ configFiles[i].file = NULL;
+ free(configFiles[i].path);
+ configFiles[i].path = NULL;
+ }
+ numFiles = 0;
+}
+
+void
+xf86setBuiltinConfig(const char *config[])
+{
+ builtinConfig = config;
+}
+
+void
+xf86parseError (char *format,...)
+{
+ va_list ap;
+ char *filename = numFiles ? configFiles[curFileIndex].path :
+ "<builtin configuration>";
+
+ ErrorF ("Parse error on line %d of section %s in file %s\n\t",
+ configLineNo, configSection, filename);
+ va_start (ap, format);
+ VErrorF (format, ap);
+ va_end (ap);
+
+ ErrorF ("\n");
+}
+
+void
+xf86validationError (char *format,...)
+{
+ va_list ap;
+ char *filename = numFiles ? configFiles[curFileIndex].path :
+ "<builtin configuration>";
+
+ ErrorF ("Data incomplete in file %s\n\t", filename);
+ va_start (ap, format);
+ VErrorF (format, ap);
+ va_end (ap);
+
+ ErrorF ("\n");
+}
+
+void
+xf86setSection (char *section)
+{
+ free(configSection);
+ configSection = malloc(strlen (section) + 1);
+ strcpy (configSection, section);
+}
+
+/*
+ * xf86getToken --
+ * Lookup a string if it is actually a token in disguise.
+ */
+int
+xf86getStringToken (xf86ConfigSymTabRec * tab)
+{
+ return StringToToken (val.str, tab);
+}
+
+static int
+StringToToken (char *str, xf86ConfigSymTabRec * tab)
+{
+ int i;
+
+ for (i = 0; tab[i].token != -1; i++)
+ {
+ if (!xf86nameCompare (tab[i].name, str))
+ return tab[i].token;
+ }
+ return ERROR_TOKEN;
+}
+
+
+/*
+ * Compare two names. The characters '_', ' ', and '\t' are ignored
+ * in the comparison.
+ */
+int
+xf86nameCompare (const char *s1, const char *s2)
+{
+ char c1, c2;
+
+ if (!s1 || *s1 == 0) {
+ if (!s2 || *s2 == 0)
+ return 0;
+ else
+ return 1;
+ }
+
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ while (c1 == c2)
+ {
+ if (c1 == '\0')
+ return 0;
+ s1++;
+ s2++;
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ }
+ return c1 - c2;
+}
+
+char *
+xf86addComment(char *cur, char *add)
+{
+ char *str;
+ int len, curlen, iscomment, hasnewline = 0, endnewline;
+
+ if (add == NULL || add[0] == '\0')
+ return cur;
+
+ if (cur) {
+ curlen = strlen(cur);
+ if (curlen)
+ hasnewline = cur[curlen - 1] == '\n';
+ eol_seen = 0;
+ }
+ else
+ curlen = 0;
+
+ str = add;
+ iscomment = 0;
+ while (*str) {
+ if (*str != ' ' && *str != '\t')
+ break;
+ ++str;
+ }
+ iscomment = (*str == '#');
+
+ len = strlen(add);
+ endnewline = add[len - 1] == '\n';
+ len += 1 + iscomment + (!hasnewline) + (!endnewline) + eol_seen;
+
+ if ((str = realloc(cur, len + curlen)) == NULL)
+ return cur;
+
+ cur = str;
+
+ if (eol_seen || (curlen && !hasnewline))
+ cur[curlen++] = '\n';
+ if (!iscomment)
+ cur[curlen++] = '#';
+ strcpy(cur + curlen, add);
+ if (!endnewline)
+ strcat(cur, "\n");
+
+ return cur;
+}
+
+Bool
+xf86getBoolValue(Bool *val, const char *str)
+{
+ if (!val || !str)
+ return FALSE;
+ if (*str == '\0') {
+ *val = TRUE;
+ } else {
+ if (xf86nameCompare(str, "1") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "on") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "true") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "yes") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "0") == 0)
+ *val = FALSE;
+ else if (xf86nameCompare(str, "off") == 0)
+ *val = FALSE;
+ else if (xf86nameCompare(str, "false") == 0)
+ *val = FALSE;
+ else if (xf86nameCompare(str, "no") == 0)
+ *val = FALSE;
+ else
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/parser/xf86Parser.h b/xorg-server/hw/xfree86/parser/xf86Parser.h index d79544a20..d35bbab27 100644 --- a/xorg-server/hw/xfree86/parser/xf86Parser.h +++ b/xorg-server/hw/xfree86/parser/xf86Parser.h @@ -1,518 +1,530 @@ -/* - * - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* - * This file contains the external interfaces for the XFree86 configuration - * file parser. - */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _xf86Parser_h_ -#define _xf86Parser_h_ - -#include <X11/Xdefs.h> -#include "xf86Optrec.h" - -#define HAVE_PARSER_DECLS - -typedef struct -{ - char *file_logfile; - char *file_modulepath; - char *file_fontpath; - char *file_comment; - char *file_xkbdir; -} -XF86ConfFilesRec, *XF86ConfFilesPtr; - -/* Values for load_type */ -#define XF86_LOAD_MODULE 0 -#define XF86_LOAD_DRIVER 1 -#define XF86_DISABLE_MODULE 2 - -typedef struct -{ - GenericListRec list; - int load_type; - char *load_name; - XF86OptionPtr load_opt; - char *load_comment; - int ignore; -} -XF86LoadRec, *XF86LoadPtr; - -typedef struct -{ - XF86LoadPtr mod_load_lst; - XF86LoadPtr mod_disable_lst; - char *mod_comment; -} -XF86ConfModuleRec, *XF86ConfModulePtr; - -#define CONF_IMPLICIT_KEYBOARD "Implicit Core Keyboard" - -#define CONF_IMPLICIT_POINTER "Implicit Core Pointer" - -#define XF86CONF_PHSYNC 0x0001 -#define XF86CONF_NHSYNC 0x0002 -#define XF86CONF_PVSYNC 0x0004 -#define XF86CONF_NVSYNC 0x0008 -#define XF86CONF_INTERLACE 0x0010 -#define XF86CONF_DBLSCAN 0x0020 -#define XF86CONF_CSYNC 0x0040 -#define XF86CONF_PCSYNC 0x0080 -#define XF86CONF_NCSYNC 0x0100 -#define XF86CONF_HSKEW 0x0200 /* hskew provided */ -#define XF86CONF_BCAST 0x0400 -#define XF86CONF_CUSTOM 0x0800 /* timing numbers customized by editor */ -#define XF86CONF_VSCAN 0x1000 - -typedef struct -{ - GenericListRec list; - char *ml_identifier; - int ml_clock; - int ml_hdisplay; - int ml_hsyncstart; - int ml_hsyncend; - int ml_htotal; - int ml_vdisplay; - int ml_vsyncstart; - int ml_vsyncend; - int ml_vtotal; - int ml_vscan; - int ml_flags; - int ml_hskew; - char *ml_comment; -} -XF86ConfModeLineRec, *XF86ConfModeLinePtr; - -typedef struct -{ - GenericListRec list; - char *vp_identifier; - XF86OptionPtr vp_option_lst; - char *vp_comment; -} -XF86ConfVideoPortRec, *XF86ConfVideoPortPtr; - -typedef struct -{ - GenericListRec list; - char *va_identifier; - char *va_vendor; - char *va_board; - char *va_busid; - char *va_driver; - XF86OptionPtr va_option_lst; - XF86ConfVideoPortPtr va_port_lst; - char *va_fwdref; - char *va_comment; -} -XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr; - -#define CONF_MAX_HSYNC 8 -#define CONF_MAX_VREFRESH 8 - -typedef struct -{ - float hi, lo; -} -parser_range; - -typedef struct -{ - int red, green, blue; -} -parser_rgb; - -typedef struct -{ - GenericListRec list; - char *modes_identifier; - XF86ConfModeLinePtr mon_modeline_lst; - char *modes_comment; -} -XF86ConfModesRec, *XF86ConfModesPtr; - -typedef struct -{ - GenericListRec list; - char *ml_modes_str; - XF86ConfModesPtr ml_modes; -} -XF86ConfModesLinkRec, *XF86ConfModesLinkPtr; - -typedef struct -{ - GenericListRec list; - char *mon_identifier; - char *mon_vendor; - char *mon_modelname; - int mon_width; /* in mm */ - int mon_height; /* in mm */ - XF86ConfModeLinePtr mon_modeline_lst; - int mon_n_hsync; - parser_range mon_hsync[CONF_MAX_HSYNC]; - int mon_n_vrefresh; - parser_range mon_vrefresh[CONF_MAX_VREFRESH]; - float mon_gamma_red; - float mon_gamma_green; - float mon_gamma_blue; - XF86OptionPtr mon_option_lst; - XF86ConfModesLinkPtr mon_modes_sect_lst; - char *mon_comment; -} -XF86ConfMonitorRec, *XF86ConfMonitorPtr; - -#define CONF_MAXDACSPEEDS 4 -#define CONF_MAXCLOCKS 128 - -typedef struct -{ - GenericListRec list; - char *dev_identifier; - char *dev_vendor; - char *dev_board; - char *dev_chipset; - char *dev_busid; - char *dev_card; - char *dev_driver; - char *dev_ramdac; - int dev_dacSpeeds[CONF_MAXDACSPEEDS]; - int dev_videoram; - int dev_textclockfreq; - unsigned long dev_bios_base; - unsigned long dev_mem_base; - unsigned long dev_io_base; - char *dev_clockchip; - int dev_clocks; - int dev_clock[CONF_MAXCLOCKS]; - int dev_chipid; - int dev_chiprev; - int dev_irq; - int dev_screen; - XF86OptionPtr dev_option_lst; - char *dev_comment; -} -XF86ConfDeviceRec, *XF86ConfDevicePtr; - -typedef struct -{ - GenericListRec list; - char *mode_name; -} -XF86ModeRec, *XF86ModePtr; - -typedef struct -{ - GenericListRec list; - int disp_frameX0; - int disp_frameY0; - int disp_virtualX; - int disp_virtualY; - int disp_depth; - int disp_bpp; - char *disp_visual; - parser_rgb disp_weight; - parser_rgb disp_black; - parser_rgb disp_white; - XF86ModePtr disp_mode_lst; - XF86OptionPtr disp_option_lst; - char *disp_comment; -} -XF86ConfDisplayRec, *XF86ConfDisplayPtr; - -typedef struct -{ - XF86OptionPtr flg_option_lst; - char *flg_comment; -} -XF86ConfFlagsRec, *XF86ConfFlagsPtr; - -typedef struct -{ - GenericListRec list; - char *al_adaptor_str; - XF86ConfVideoAdaptorPtr al_adaptor; -} -XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr; - -typedef struct -{ - GenericListRec list; - char *scrn_identifier; - char *scrn_obso_driver; - int scrn_defaultdepth; - int scrn_defaultbpp; - int scrn_defaultfbbpp; - char *scrn_monitor_str; - XF86ConfMonitorPtr scrn_monitor; - char *scrn_device_str; - XF86ConfDevicePtr scrn_device; - XF86ConfAdaptorLinkPtr scrn_adaptor_lst; - XF86ConfDisplayPtr scrn_display_lst; - XF86OptionPtr scrn_option_lst; - char *scrn_comment; - int scrn_virtualX, scrn_virtualY; -} -XF86ConfScreenRec, *XF86ConfScreenPtr; - -typedef struct -{ - GenericListRec list; - char *inp_identifier; - char *inp_driver; - XF86OptionPtr inp_option_lst; - char *inp_comment; -} -XF86ConfInputRec, *XF86ConfInputPtr; - -typedef struct -{ - GenericListRec list; - XF86ConfInputPtr iref_inputdev; - char *iref_inputdev_str; - XF86OptionPtr iref_option_lst; -} -XF86ConfInputrefRec, *XF86ConfInputrefPtr; - -typedef struct -{ - Bool set; - Bool val; -} -xf86TriState; - -typedef struct -{ - GenericListRec list; - char *identifier; - char *driver; - char **match_product; - char **match_vendor; - char **match_device; - char **match_tag; - xf86TriState is_keyboard; - xf86TriState is_pointer; - xf86TriState is_joystick; - xf86TriState is_tablet; - xf86TriState is_touchpad; - xf86TriState is_touchscreen; - XF86OptionPtr option_lst; - char *comment; -} -XF86ConfInputClassRec, *XF86ConfInputClassPtr; - -/* Values for adj_where */ -#define CONF_ADJ_OBSOLETE -1 -#define CONF_ADJ_ABSOLUTE 0 -#define CONF_ADJ_RIGHTOF 1 -#define CONF_ADJ_LEFTOF 2 -#define CONF_ADJ_ABOVE 3 -#define CONF_ADJ_BELOW 4 -#define CONF_ADJ_RELATIVE 5 - -typedef struct -{ - GenericListRec list; - int adj_scrnum; - XF86ConfScreenPtr adj_screen; - char *adj_screen_str; - XF86ConfScreenPtr adj_top; - char *adj_top_str; - XF86ConfScreenPtr adj_bottom; - char *adj_bottom_str; - XF86ConfScreenPtr adj_left; - char *adj_left_str; - XF86ConfScreenPtr adj_right; - char *adj_right_str; - int adj_where; - int adj_x; - int adj_y; - char *adj_refscreen; -} -XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr; - -typedef struct -{ - GenericListRec list; - char *inactive_device_str; - XF86ConfDevicePtr inactive_device; -} -XF86ConfInactiveRec, *XF86ConfInactivePtr; - -typedef struct -{ - GenericListRec list; - char *lay_identifier; - XF86ConfAdjacencyPtr lay_adjacency_lst; - XF86ConfInactivePtr lay_inactive_lst; - XF86ConfInputrefPtr lay_input_lst; - XF86OptionPtr lay_option_lst; - char *lay_comment; -} -XF86ConfLayoutRec, *XF86ConfLayoutPtr; - -typedef struct -{ - GenericListRec list; - char *vs_name; - char *vs_identifier; - XF86OptionPtr vs_option_lst; - char *vs_comment; -} -XF86ConfVendSubRec, *XF86ConfVendSubPtr; - -typedef struct -{ - GenericListRec list; - char *vnd_identifier; - XF86OptionPtr vnd_option_lst; - XF86ConfVendSubPtr vnd_sub_lst; - char *vnd_comment; -} -XF86ConfVendorRec, *XF86ConfVendorPtr; - -typedef struct -{ - GenericListRec list; - int buf_count; - int buf_size; - char *buf_flags; - char *buf_comment; -} -XF86ConfBuffersRec, *XF86ConfBuffersPtr; - -typedef struct -{ - char *dri_group_name; - int dri_group; - int dri_mode; - XF86ConfBuffersPtr dri_buffers_lst; - char *dri_comment; -} -XF86ConfDRIRec, *XF86ConfDRIPtr; - -typedef struct -{ - XF86OptionPtr ext_option_lst; - char *extensions_comment; -} -XF86ConfExtensionsRec, *XF86ConfExtensionsPtr; - -typedef struct -{ - XF86ConfFilesPtr conf_files; - XF86ConfModulePtr conf_modules; - XF86ConfFlagsPtr conf_flags; - XF86ConfVideoAdaptorPtr conf_videoadaptor_lst; - XF86ConfModesPtr conf_modes_lst; - XF86ConfMonitorPtr conf_monitor_lst; - XF86ConfDevicePtr conf_device_lst; - XF86ConfScreenPtr conf_screen_lst; - XF86ConfInputPtr conf_input_lst; - XF86ConfInputClassPtr conf_inputclass_lst; - XF86ConfLayoutPtr conf_layout_lst; - XF86ConfVendorPtr conf_vendor_lst; - XF86ConfDRIPtr conf_dri; - XF86ConfExtensionsPtr conf_extensions; - char *conf_comment; -} -XF86ConfigRec, *XF86ConfigPtr; - -typedef struct -{ - int token; /* id of the token */ - char *name; /* pointer to the LOWERCASED name */ -} -xf86ConfigSymTabRec, *xf86ConfigSymTabPtr; - -/* - * prototypes for public functions - */ -extern void xf86initConfigFiles(void); -extern const char *xf86openConfigFile(const char *path, const char *cmdline, - const char *projroot); -extern const char *xf86openConfigDirFiles(const char *path, const char *cmdline, - const char *projroot); -extern void xf86setBuiltinConfig(const char *config[]); -extern XF86ConfigPtr xf86readConfigFile(void); -extern void xf86closeConfigFile(void); -extern void xf86freeConfig(XF86ConfigPtr p); -extern int xf86writeConfigFile(const char *, XF86ConfigPtr); -extern _X_EXPORT XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p); -extern _X_EXPORT XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list); -extern _X_EXPORT XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p); -extern _X_EXPORT XF86ConfModesPtr xf86findModes(const char *ident, XF86ConfModesPtr p); -extern _X_EXPORT XF86ConfModeLinePtr xf86findModeLine(const char *ident, XF86ConfModeLinePtr p); -extern _X_EXPORT XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p); -extern _X_EXPORT XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p); -extern _X_EXPORT XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p); -extern _X_EXPORT XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident, - XF86ConfVideoAdaptorPtr p); -extern int xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout); - -extern _X_EXPORT GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new); -extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2); - -extern _X_EXPORT int xf86pathIsAbsolute(const char *path); -extern _X_EXPORT int xf86pathIsSafe(const char *path); -extern _X_EXPORT char *xf86addComment(char *cur, char *add); -extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str); - -#endif /* _xf86Parser_h_ */ +/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/*
+ * This file contains the external interfaces for the XFree86 configuration
+ * file parser.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _xf86Parser_h_
+#define _xf86Parser_h_
+
+#include <X11/Xdefs.h>
+#include "xf86Optrec.h"
+#include "list.h"
+
+#define HAVE_PARSER_DECLS
+
+typedef struct
+{
+ char *file_logfile;
+ char *file_modulepath;
+ char *file_fontpath;
+ char *file_comment;
+ char *file_xkbdir;
+}
+XF86ConfFilesRec, *XF86ConfFilesPtr;
+
+/* Values for load_type */
+#define XF86_LOAD_MODULE 0
+#define XF86_LOAD_DRIVER 1
+#define XF86_DISABLE_MODULE 2
+
+typedef struct
+{
+ GenericListRec list;
+ int load_type;
+ char *load_name;
+ XF86OptionPtr load_opt;
+ char *load_comment;
+ int ignore;
+}
+XF86LoadRec, *XF86LoadPtr;
+
+typedef struct
+{
+ XF86LoadPtr mod_load_lst;
+ XF86LoadPtr mod_disable_lst;
+ char *mod_comment;
+}
+XF86ConfModuleRec, *XF86ConfModulePtr;
+
+#define CONF_IMPLICIT_KEYBOARD "Implicit Core Keyboard"
+
+#define CONF_IMPLICIT_POINTER "Implicit Core Pointer"
+
+#define XF86CONF_PHSYNC 0x0001
+#define XF86CONF_NHSYNC 0x0002
+#define XF86CONF_PVSYNC 0x0004
+#define XF86CONF_NVSYNC 0x0008
+#define XF86CONF_INTERLACE 0x0010
+#define XF86CONF_DBLSCAN 0x0020
+#define XF86CONF_CSYNC 0x0040
+#define XF86CONF_PCSYNC 0x0080
+#define XF86CONF_NCSYNC 0x0100
+#define XF86CONF_HSKEW 0x0200 /* hskew provided */
+#define XF86CONF_BCAST 0x0400
+#define XF86CONF_CUSTOM 0x0800 /* timing numbers customized by editor */
+#define XF86CONF_VSCAN 0x1000
+
+typedef struct
+{
+ GenericListRec list;
+ char *ml_identifier;
+ int ml_clock;
+ int ml_hdisplay;
+ int ml_hsyncstart;
+ int ml_hsyncend;
+ int ml_htotal;
+ int ml_vdisplay;
+ int ml_vsyncstart;
+ int ml_vsyncend;
+ int ml_vtotal;
+ int ml_vscan;
+ int ml_flags;
+ int ml_hskew;
+ char *ml_comment;
+}
+XF86ConfModeLineRec, *XF86ConfModeLinePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *vp_identifier;
+ XF86OptionPtr vp_option_lst;
+ char *vp_comment;
+}
+XF86ConfVideoPortRec, *XF86ConfVideoPortPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *va_identifier;
+ char *va_vendor;
+ char *va_board;
+ char *va_busid;
+ char *va_driver;
+ XF86OptionPtr va_option_lst;
+ XF86ConfVideoPortPtr va_port_lst;
+ char *va_fwdref;
+ char *va_comment;
+}
+XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr;
+
+#define CONF_MAX_HSYNC 8
+#define CONF_MAX_VREFRESH 8
+
+typedef struct
+{
+ float hi, lo;
+}
+parser_range;
+
+typedef struct
+{
+ int red, green, blue;
+}
+parser_rgb;
+
+typedef struct
+{
+ GenericListRec list;
+ char *modes_identifier;
+ XF86ConfModeLinePtr mon_modeline_lst;
+ char *modes_comment;
+}
+XF86ConfModesRec, *XF86ConfModesPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *ml_modes_str;
+ XF86ConfModesPtr ml_modes;
+}
+XF86ConfModesLinkRec, *XF86ConfModesLinkPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *mon_identifier;
+ char *mon_vendor;
+ char *mon_modelname;
+ int mon_width; /* in mm */
+ int mon_height; /* in mm */
+ XF86ConfModeLinePtr mon_modeline_lst;
+ int mon_n_hsync;
+ parser_range mon_hsync[CONF_MAX_HSYNC];
+ int mon_n_vrefresh;
+ parser_range mon_vrefresh[CONF_MAX_VREFRESH];
+ float mon_gamma_red;
+ float mon_gamma_green;
+ float mon_gamma_blue;
+ XF86OptionPtr mon_option_lst;
+ XF86ConfModesLinkPtr mon_modes_sect_lst;
+ char *mon_comment;
+}
+XF86ConfMonitorRec, *XF86ConfMonitorPtr;
+
+#define CONF_MAXDACSPEEDS 4
+#define CONF_MAXCLOCKS 128
+
+typedef struct
+{
+ GenericListRec list;
+ char *dev_identifier;
+ char *dev_vendor;
+ char *dev_board;
+ char *dev_chipset;
+ char *dev_busid;
+ char *dev_card;
+ char *dev_driver;
+ char *dev_ramdac;
+ int dev_dacSpeeds[CONF_MAXDACSPEEDS];
+ int dev_videoram;
+ int dev_textclockfreq;
+ unsigned long dev_bios_base;
+ unsigned long dev_mem_base;
+ unsigned long dev_io_base;
+ char *dev_clockchip;
+ int dev_clocks;
+ int dev_clock[CONF_MAXCLOCKS];
+ int dev_chipid;
+ int dev_chiprev;
+ int dev_irq;
+ int dev_screen;
+ XF86OptionPtr dev_option_lst;
+ char *dev_comment;
+}
+XF86ConfDeviceRec, *XF86ConfDevicePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *mode_name;
+}
+XF86ModeRec, *XF86ModePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ int disp_frameX0;
+ int disp_frameY0;
+ int disp_virtualX;
+ int disp_virtualY;
+ int disp_depth;
+ int disp_bpp;
+ char *disp_visual;
+ parser_rgb disp_weight;
+ parser_rgb disp_black;
+ parser_rgb disp_white;
+ XF86ModePtr disp_mode_lst;
+ XF86OptionPtr disp_option_lst;
+ char *disp_comment;
+}
+XF86ConfDisplayRec, *XF86ConfDisplayPtr;
+
+typedef struct
+{
+ XF86OptionPtr flg_option_lst;
+ char *flg_comment;
+}
+XF86ConfFlagsRec, *XF86ConfFlagsPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *al_adaptor_str;
+ XF86ConfVideoAdaptorPtr al_adaptor;
+}
+XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *scrn_identifier;
+ char *scrn_obso_driver;
+ int scrn_defaultdepth;
+ int scrn_defaultbpp;
+ int scrn_defaultfbbpp;
+ char *scrn_monitor_str;
+ XF86ConfMonitorPtr scrn_monitor;
+ char *scrn_device_str;
+ XF86ConfDevicePtr scrn_device;
+ XF86ConfAdaptorLinkPtr scrn_adaptor_lst;
+ XF86ConfDisplayPtr scrn_display_lst;
+ XF86OptionPtr scrn_option_lst;
+ char *scrn_comment;
+ int scrn_virtualX, scrn_virtualY;
+}
+XF86ConfScreenRec, *XF86ConfScreenPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *inp_identifier;
+ char *inp_driver;
+ XF86OptionPtr inp_option_lst;
+ char *inp_comment;
+}
+XF86ConfInputRec, *XF86ConfInputPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ XF86ConfInputPtr iref_inputdev;
+ char *iref_inputdev_str;
+ XF86OptionPtr iref_option_lst;
+}
+XF86ConfInputrefRec, *XF86ConfInputrefPtr;
+
+typedef struct
+{
+ Bool set;
+ Bool val;
+}
+xf86TriState;
+
+typedef struct
+{
+ struct list entry;
+ char **values;
+}
+xf86MatchGroup;
+
+typedef struct
+{
+ GenericListRec list;
+ char *identifier;
+ char *driver;
+ struct list match_product;
+ struct list match_vendor;
+ struct list match_device;
+ struct list match_os;
+ struct list match_pnpid;
+ struct list match_usbid;
+ struct list match_driver;
+ struct list match_tag;
+ xf86TriState is_keyboard;
+ xf86TriState is_pointer;
+ xf86TriState is_joystick;
+ xf86TriState is_tablet;
+ xf86TriState is_touchpad;
+ xf86TriState is_touchscreen;
+ XF86OptionPtr option_lst;
+ char *comment;
+}
+XF86ConfInputClassRec, *XF86ConfInputClassPtr;
+
+/* Values for adj_where */
+#define CONF_ADJ_OBSOLETE -1
+#define CONF_ADJ_ABSOLUTE 0
+#define CONF_ADJ_RIGHTOF 1
+#define CONF_ADJ_LEFTOF 2
+#define CONF_ADJ_ABOVE 3
+#define CONF_ADJ_BELOW 4
+#define CONF_ADJ_RELATIVE 5
+
+typedef struct
+{
+ GenericListRec list;
+ int adj_scrnum;
+ XF86ConfScreenPtr adj_screen;
+ char *adj_screen_str;
+ XF86ConfScreenPtr adj_top;
+ char *adj_top_str;
+ XF86ConfScreenPtr adj_bottom;
+ char *adj_bottom_str;
+ XF86ConfScreenPtr adj_left;
+ char *adj_left_str;
+ XF86ConfScreenPtr adj_right;
+ char *adj_right_str;
+ int adj_where;
+ int adj_x;
+ int adj_y;
+ char *adj_refscreen;
+}
+XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *inactive_device_str;
+ XF86ConfDevicePtr inactive_device;
+}
+XF86ConfInactiveRec, *XF86ConfInactivePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *lay_identifier;
+ XF86ConfAdjacencyPtr lay_adjacency_lst;
+ XF86ConfInactivePtr lay_inactive_lst;
+ XF86ConfInputrefPtr lay_input_lst;
+ XF86OptionPtr lay_option_lst;
+ char *lay_comment;
+}
+XF86ConfLayoutRec, *XF86ConfLayoutPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *vs_name;
+ char *vs_identifier;
+ XF86OptionPtr vs_option_lst;
+ char *vs_comment;
+}
+XF86ConfVendSubRec, *XF86ConfVendSubPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *vnd_identifier;
+ XF86OptionPtr vnd_option_lst;
+ XF86ConfVendSubPtr vnd_sub_lst;
+ char *vnd_comment;
+}
+XF86ConfVendorRec, *XF86ConfVendorPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ int buf_count;
+ int buf_size;
+ char *buf_flags;
+ char *buf_comment;
+}
+XF86ConfBuffersRec, *XF86ConfBuffersPtr;
+
+typedef struct
+{
+ char *dri_group_name;
+ int dri_group;
+ int dri_mode;
+ XF86ConfBuffersPtr dri_buffers_lst;
+ char *dri_comment;
+}
+XF86ConfDRIRec, *XF86ConfDRIPtr;
+
+typedef struct
+{
+ XF86OptionPtr ext_option_lst;
+ char *extensions_comment;
+}
+XF86ConfExtensionsRec, *XF86ConfExtensionsPtr;
+
+typedef struct
+{
+ XF86ConfFilesPtr conf_files;
+ XF86ConfModulePtr conf_modules;
+ XF86ConfFlagsPtr conf_flags;
+ XF86ConfVideoAdaptorPtr conf_videoadaptor_lst;
+ XF86ConfModesPtr conf_modes_lst;
+ XF86ConfMonitorPtr conf_monitor_lst;
+ XF86ConfDevicePtr conf_device_lst;
+ XF86ConfScreenPtr conf_screen_lst;
+ XF86ConfInputPtr conf_input_lst;
+ XF86ConfInputClassPtr conf_inputclass_lst;
+ XF86ConfLayoutPtr conf_layout_lst;
+ XF86ConfVendorPtr conf_vendor_lst;
+ XF86ConfDRIPtr conf_dri;
+ XF86ConfExtensionsPtr conf_extensions;
+ char *conf_comment;
+}
+XF86ConfigRec, *XF86ConfigPtr;
+
+typedef struct
+{
+ int token; /* id of the token */
+ char *name; /* pointer to the LOWERCASED name */
+}
+xf86ConfigSymTabRec, *xf86ConfigSymTabPtr;
+
+/*
+ * prototypes for public functions
+ */
+extern void xf86initConfigFiles(void);
+extern const char *xf86openConfigFile(const char *path, const char *cmdline,
+ const char *projroot);
+extern const char *xf86openConfigDirFiles(const char *path, const char *cmdline,
+ const char *projroot);
+extern void xf86setBuiltinConfig(const char *config[]);
+extern XF86ConfigPtr xf86readConfigFile(void);
+extern void xf86closeConfigFile(void);
+extern void xf86freeConfig(XF86ConfigPtr p);
+extern int xf86writeConfigFile(const char *, XF86ConfigPtr);
+extern _X_EXPORT XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p);
+extern _X_EXPORT XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list);
+extern _X_EXPORT XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p);
+extern _X_EXPORT XF86ConfModesPtr xf86findModes(const char *ident, XF86ConfModesPtr p);
+extern _X_EXPORT XF86ConfModeLinePtr xf86findModeLine(const char *ident, XF86ConfModeLinePtr p);
+extern _X_EXPORT XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p);
+extern _X_EXPORT XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p);
+extern _X_EXPORT XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p);
+extern _X_EXPORT XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident,
+ XF86ConfVideoAdaptorPtr p);
+extern int xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout);
+
+extern _X_EXPORT GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new);
+extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2);
+
+extern _X_EXPORT int xf86pathIsAbsolute(const char *path);
+extern _X_EXPORT int xf86pathIsSafe(const char *path);
+extern _X_EXPORT char *xf86addComment(char *cur, char *add);
+extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str);
+
+#endif /* _xf86Parser_h_ */
diff --git a/xorg-server/hw/xfree86/parser/xf86tokens.h b/xorg-server/hw/xfree86/parser/xf86tokens.h index cb600704b..3bea43d15 100644 --- a/xorg-server/hw/xfree86/parser/xf86tokens.h +++ b/xorg-server/hw/xfree86/parser/xf86tokens.h @@ -1,291 +1,295 @@ -/* - * - * Copyright (c) 1997 Metro Link Incorporated - * - * 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 X CONSORTIUM 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 of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ -/* - * Copyright (c) 1997-2003 by The XFree86 Project, Inc. - * - * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _xf86_tokens_h -#define _xf86_tokens_h - -/* Undefine symbols that some OSs might define */ -#undef IOBASE - -/* - * Each token should have a unique value regardless of the section - * it is used in. - */ - -typedef enum { - /* errno-style tokens */ - OBSOLETE_TOKEN = -5, - EOF_TOKEN = -4, - LOCK_TOKEN = -3, - ERROR_TOKEN = -2, - - /* value type tokens */ - NUMBER = 1, - STRING, - - /* Tokens that can appear in many sections */ - SECTION, - SUBSECTION, - ENDSECTION, - ENDSUBSECTION, - IDENTIFIER, - VENDOR, - DASH, - COMMA, - OPTION, - COMMENT, - - /* Frequency units */ - HRZ, - KHZ, - MHZ, - - /* File tokens */ - FONTPATH, - MODULEPATH, - LOGFILEPATH, - XKBDIR, - - /* Server Flag tokens. These are deprecated in favour of generic Options */ - NOTRAPSIGNALS, - DONTZAP, - DONTZOOM, - DISABLEVIDMODE, - ALLOWNONLOCAL, - DISABLEMODINDEV, - MODINDEVALLOWNONLOCAL, - ALLOWMOUSEOPENFAIL, - BLANKTIME, - STANDBYTIME, - SUSPENDTIME, - OFFTIME, - DEFAULTLAYOUT, - - /* Monitor tokens */ - MODEL, - MODELINE, - DISPLAYSIZE, - HORIZSYNC, - VERTREFRESH, - MODE, - GAMMA, - USEMODES, - - /* Modes tokens */ - /* no new ones */ - - /* Mode tokens */ - DOTCLOCK, - HTIMINGS, - VTIMINGS, - FLAGS, - HSKEW, - BCAST, - VSCAN, - ENDMODE, - - /* Screen tokens */ - OBSDRIVER, - MDEVICE, - MONITOR, - SCREENNO, - DEFAULTDEPTH, - DEFAULTBPP, - DEFAULTFBBPP, - - /* VideoAdaptor tokens */ - VIDEOADAPTOR, - - /* Mode timing tokens */ - TT_INTERLACE, - TT_PHSYNC, - TT_NHSYNC, - TT_PVSYNC, - TT_NVSYNC, - TT_CSYNC, - TT_PCSYNC, - TT_NCSYNC, - TT_DBLSCAN, - TT_HSKEW, - TT_BCAST, - TT_VSCAN, - TT_CUSTOM, - - /* Module tokens */ - LOAD, - LOAD_DRIVER, - DISABLE, - - /* Device tokens */ - DRIVER, - CHIPSET, - CLOCKS, - VIDEORAM, - BOARD, - IOBASE, - RAMDAC, - DACSPEED, - BIOSBASE, - MEMBASE, - CLOCKCHIP, - CHIPID, - CHIPREV, - CARD, - BUSID, - TEXTCLOCKFRQ, - IRQ, - - /* Keyboard tokens */ - AUTOREPEAT, - XLEDS, - KPROTOCOL, - XKBKEYMAP, - XKBCOMPAT, - XKBTYPES, - XKBKEYCODES, - XKBGEOMETRY, - XKBSYMBOLS, - XKBDISABLE, - PANIX106, - XKBRULES, - XKBMODEL, - XKBLAYOUT, - XKBVARIANT, - XKBOPTIONS, - /* The next two have become ServerFlags options */ - VTSYSREQ, - /* Obsolete keyboard tokens */ - SERVERNUM, - LEFTALT, - RIGHTALT, - SCROLLLOCK_TOK, - RIGHTCTL, - /* arguments for the above obsolete tokens */ - CONF_KM_META, - CONF_KM_COMPOSE, - CONF_KM_MODESHIFT, - CONF_KM_MODELOCK, - CONF_KM_SCROLLLOCK, - CONF_KM_CONTROL, - - /* Pointer tokens */ - EMULATE3, - BAUDRATE, - SAMPLERATE, - PRESOLUTION, - CLEARDTR, - CLEARRTS, - CHORDMIDDLE, - PROTOCOL, - PDEVICE, - EM3TIMEOUT, - DEVICE_NAME, - ALWAYSCORE, - PBUTTONS, - ZAXISMAPPING, - - /* Pointer Z axis mapping tokens */ - XAXIS, - YAXIS, - - /* Display tokens */ - MODES, - VIEWPORT, - VIRTUAL, - VISUAL, - BLACK_TOK, - WHITE_TOK, - DEPTH, - BPP, - WEIGHT, - - /* Layout Tokens */ - SCREEN, - INACTIVE, - INPUTDEVICE, - - /* Adjaceny Tokens */ - RIGHTOF, - LEFTOF, - ABOVE, - BELOW, - RELATIVE, - ABSOLUTE, - - /* Vendor Tokens */ - VENDORNAME, - - /* DRI Tokens */ - GROUP, - BUFFERS, - - /* InputClass Tokens */ - MATCH_PRODUCT, - MATCH_VENDOR, - MATCH_DEVICE_PATH, - MATCH_TAG, - MATCH_IS_KEYBOARD, - MATCH_IS_POINTER, - MATCH_IS_JOYSTICK, - MATCH_IS_TABLET, - MATCH_IS_TOUCHPAD, - MATCH_IS_TOUCHSCREEN -} ParserTokens; - -#endif /* _xf86_tokens_h */ +/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * 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 X CONSORTIUM 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 of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * 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 COPYRIGHT HOLDER(S) OR AUTHOR(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 of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _xf86_tokens_h
+#define _xf86_tokens_h
+
+/* Undefine symbols that some OSs might define */
+#undef IOBASE
+
+/*
+ * Each token should have a unique value regardless of the section
+ * it is used in.
+ */
+
+typedef enum {
+ /* errno-style tokens */
+ OBSOLETE_TOKEN = -5,
+ EOF_TOKEN = -4,
+ LOCK_TOKEN = -3,
+ ERROR_TOKEN = -2,
+
+ /* value type tokens */
+ NUMBER = 1,
+ STRING,
+
+ /* Tokens that can appear in many sections */
+ SECTION,
+ SUBSECTION,
+ ENDSECTION,
+ ENDSUBSECTION,
+ IDENTIFIER,
+ VENDOR,
+ DASH,
+ COMMA,
+ OPTION,
+ COMMENT,
+
+ /* Frequency units */
+ HRZ,
+ KHZ,
+ MHZ,
+
+ /* File tokens */
+ FONTPATH,
+ MODULEPATH,
+ LOGFILEPATH,
+ XKBDIR,
+
+ /* Server Flag tokens. These are deprecated in favour of generic Options */
+ NOTRAPSIGNALS,
+ DONTZAP,
+ DONTZOOM,
+ DISABLEVIDMODE,
+ ALLOWNONLOCAL,
+ DISABLEMODINDEV,
+ MODINDEVALLOWNONLOCAL,
+ ALLOWMOUSEOPENFAIL,
+ BLANKTIME,
+ STANDBYTIME,
+ SUSPENDTIME,
+ OFFTIME,
+ DEFAULTLAYOUT,
+
+ /* Monitor tokens */
+ MODEL,
+ MODELINE,
+ DISPLAYSIZE,
+ HORIZSYNC,
+ VERTREFRESH,
+ MODE,
+ GAMMA,
+ USEMODES,
+
+ /* Modes tokens */
+ /* no new ones */
+
+ /* Mode tokens */
+ DOTCLOCK,
+ HTIMINGS,
+ VTIMINGS,
+ FLAGS,
+ HSKEW,
+ BCAST,
+ VSCAN,
+ ENDMODE,
+
+ /* Screen tokens */
+ OBSDRIVER,
+ MDEVICE,
+ MONITOR,
+ SCREENNO,
+ DEFAULTDEPTH,
+ DEFAULTBPP,
+ DEFAULTFBBPP,
+
+ /* VideoAdaptor tokens */
+ VIDEOADAPTOR,
+
+ /* Mode timing tokens */
+ TT_INTERLACE,
+ TT_PHSYNC,
+ TT_NHSYNC,
+ TT_PVSYNC,
+ TT_NVSYNC,
+ TT_CSYNC,
+ TT_PCSYNC,
+ TT_NCSYNC,
+ TT_DBLSCAN,
+ TT_HSKEW,
+ TT_BCAST,
+ TT_VSCAN,
+ TT_CUSTOM,
+
+ /* Module tokens */
+ LOAD,
+ LOAD_DRIVER,
+ DISABLE,
+
+ /* Device tokens */
+ DRIVER,
+ CHIPSET,
+ CLOCKS,
+ VIDEORAM,
+ BOARD,
+ IOBASE,
+ RAMDAC,
+ DACSPEED,
+ BIOSBASE,
+ MEMBASE,
+ CLOCKCHIP,
+ CHIPID,
+ CHIPREV,
+ CARD,
+ BUSID,
+ TEXTCLOCKFRQ,
+ IRQ,
+
+ /* Keyboard tokens */
+ AUTOREPEAT,
+ XLEDS,
+ KPROTOCOL,
+ XKBKEYMAP,
+ XKBCOMPAT,
+ XKBTYPES,
+ XKBKEYCODES,
+ XKBGEOMETRY,
+ XKBSYMBOLS,
+ XKBDISABLE,
+ PANIX106,
+ XKBRULES,
+ XKBMODEL,
+ XKBLAYOUT,
+ XKBVARIANT,
+ XKBOPTIONS,
+ /* The next two have become ServerFlags options */
+ VTSYSREQ,
+ /* Obsolete keyboard tokens */
+ SERVERNUM,
+ LEFTALT,
+ RIGHTALT,
+ SCROLLLOCK_TOK,
+ RIGHTCTL,
+ /* arguments for the above obsolete tokens */
+ CONF_KM_META,
+ CONF_KM_COMPOSE,
+ CONF_KM_MODESHIFT,
+ CONF_KM_MODELOCK,
+ CONF_KM_SCROLLLOCK,
+ CONF_KM_CONTROL,
+
+ /* Pointer tokens */
+ EMULATE3,
+ BAUDRATE,
+ SAMPLERATE,
+ PRESOLUTION,
+ CLEARDTR,
+ CLEARRTS,
+ CHORDMIDDLE,
+ PROTOCOL,
+ PDEVICE,
+ EM3TIMEOUT,
+ DEVICE_NAME,
+ ALWAYSCORE,
+ PBUTTONS,
+ ZAXISMAPPING,
+
+ /* Pointer Z axis mapping tokens */
+ XAXIS,
+ YAXIS,
+
+ /* Display tokens */
+ MODES,
+ VIEWPORT,
+ VIRTUAL,
+ VISUAL,
+ BLACK_TOK,
+ WHITE_TOK,
+ DEPTH,
+ BPP,
+ WEIGHT,
+
+ /* Layout Tokens */
+ SCREEN,
+ INACTIVE,
+ INPUTDEVICE,
+
+ /* Adjaceny Tokens */
+ RIGHTOF,
+ LEFTOF,
+ ABOVE,
+ BELOW,
+ RELATIVE,
+ ABSOLUTE,
+
+ /* Vendor Tokens */
+ VENDORNAME,
+
+ /* DRI Tokens */
+ GROUP,
+ BUFFERS,
+
+ /* InputClass Tokens */
+ MATCH_PRODUCT,
+ MATCH_VENDOR,
+ MATCH_DEVICE_PATH,
+ MATCH_OS,
+ MATCH_PNPID,
+ MATCH_USBID,
+ MATCH_DRIVER,
+ MATCH_TAG,
+ MATCH_IS_KEYBOARD,
+ MATCH_IS_POINTER,
+ MATCH_IS_JOYSTICK,
+ MATCH_IS_TABLET,
+ MATCH_IS_TOUCHPAD,
+ MATCH_IS_TOUCHSCREEN
+} ParserTokens;
+
+#endif /* _xf86_tokens_h */
diff --git a/xorg-server/hw/xfree86/ramdac/IBM.c b/xorg-server/hw/xfree86/ramdac/IBM.c index 2d9fe4d8f..3a477d7be 100644 --- a/xorg-server/hw/xfree86/ramdac/IBM.c +++ b/xorg-server/hw/xfree86/ramdac/IBM.c @@ -1,639 +1,639 @@ -/* - * Copyright 1998 by Alan Hourihane, Wigan, England. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - * - * IBM RAMDAC routines. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86.h" -#include "xf86_OSproc.h" - -#include "xf86Cursor.h" - -#define INIT_IBM_RAMDAC_INFO -#include "IBMPriv.h" -#include "xf86RamDacPriv.h" - -#define INITIALFREQERR 100000 - -unsigned long -IBMramdac640CalculateMNPCForClock( - unsigned long RefClock, /* In 100Hz units */ - unsigned long ReqClock, /* In 100Hz units */ - char IsPixClock, /* boolean, is this the pixel or the sys clock */ - unsigned long MinClock, /* Min VCO rating */ - unsigned long MaxClock, /* Max VCO rating */ - unsigned long *rM, /* M Out */ - unsigned long *rN, /* N Out */ - unsigned long *rP, /* Min P In, P Out */ - unsigned long *rC /* C Out */ -) -{ - unsigned long M, N, P, iP = *rP; - unsigned long IntRef, VCO, Clock; - long freqErr, lowestFreqErr = INITIALFREQERR; - unsigned long ActualClock = 0; - - for (N = 0; N <= 63; N++) - { - IntRef = RefClock / (N + 1); - if (IntRef < 10000) - break; /* IntRef needs to be >= 1MHz */ - for (M = 2; M <= 127; M++) - { - VCO = IntRef * (M + 1); - if ((VCO < MinClock) || (VCO > MaxClock)) - continue; - for (P = iP; P <= 4; P++) - { - if (P != 0) - Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P); - else - Clock = (RefClock * (M + 1)) / (N + 1); - - freqErr = (Clock - ReqClock); - - if (freqErr < 0) - { - /* PixelClock gets rounded up always so monitor reports - correct frequency. */ - if (IsPixClock) - continue; - freqErr = -freqErr; - } - - if (freqErr < lowestFreqErr) - { - *rM = M; - *rN = N; - *rP = P; - *rC = (VCO <= 1280000 ? 1 : 2); - ActualClock = Clock; - - lowestFreqErr = freqErr; - /* Return if we found an exact match */ - if (freqErr == 0) - return (ActualClock); - } - } - } - } - - return (ActualClock); -} - -unsigned long -IBMramdac526CalculateMNPCForClock( - unsigned long RefClock, /* In 100Hz units */ - unsigned long ReqClock, /* In 100Hz units */ - char IsPixClock, /* boolean, is this the pixel or the sys clock */ - unsigned long MinClock, /* Min VCO rating */ - unsigned long MaxClock, /* Max VCO rating */ - unsigned long *rM, /* M Out */ - unsigned long *rN, /* N Out */ - unsigned long *rP, /* Min P In, P Out */ - unsigned long *rC /* C Out */ -) -{ - unsigned long M, N, P, iP = *rP; - unsigned long IntRef, VCO, Clock; - long freqErr, lowestFreqErr = INITIALFREQERR; - unsigned long ActualClock = 0; - - for (N = 0; N <= 63; N++) - { - IntRef = RefClock / (N + 1); - if (IntRef < 10000) - break; /* IntRef needs to be >= 1MHz */ - for (M = 0; M <= 63; M++) - { - VCO = IntRef * (M + 1); - if ((VCO < MinClock) || (VCO > MaxClock)) - continue; - for (P = iP; P <= 4; P++) - { - if (P) - Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P); - else - Clock = VCO; - - freqErr = (Clock - ReqClock); - - if (freqErr < 0) - { - /* PixelClock gets rounded up always so monitor reports - correct frequency. */ - if (IsPixClock) - continue; - freqErr = -freqErr; - } - - if (freqErr < lowestFreqErr) - { - *rM = M; - *rN = N; - *rP = P; - *rC = (VCO <= 1280000 ? 1 : 2); - ActualClock = Clock; - - lowestFreqErr = freqErr; - /* Return if we found an exact match */ - if (freqErr == 0) - return (ActualClock); - } - } - } - } - - return (ActualClock); -} - -void -IBMramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr, - RamDacRegRecPtr ramdacReg) -{ - int i, maxreg, dacreg; - - switch (ramdacPtr->RamDacType) { - case IBM640_RAMDAC: - maxreg = 0x300; - dacreg = 1024; - break; - default: - maxreg = 0x100; - dacreg = 768; - break; - } - - /* Here we pass a short, so that we can evaluate a mask too */ - /* So that the mask is the high byte and the data the low byte */ - for (i=0;i<maxreg;i++) - (*ramdacPtr->WriteDAC) - (pScrn, i, (ramdacReg->DacRegs[i] & 0xFF00) >> 8, - ramdacReg->DacRegs[i]); - - (*ramdacPtr->WriteAddress)(pScrn, 0); - for (i=0;i<dacreg;i++) - (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]); -} - -void -IBMramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr, - RamDacRegRecPtr ramdacReg) -{ - int i, maxreg, dacreg; - - switch (ramdacPtr->RamDacType) { - case IBM640_RAMDAC: - maxreg = 0x300; - dacreg = 1024; - break; - default: - maxreg = 0x100; - dacreg = 768; - break; - } - - (*ramdacPtr->ReadAddress)(pScrn, 0); - for (i=0;i<dacreg;i++) - ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn); - - for (i=0;i<maxreg;i++) - ramdacReg->DacRegs[i] = (*ramdacPtr->ReadDAC)(pScrn, i); -} - -RamDacHelperRecPtr -IBMramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/* , RamDacRecPtr ramdacPtr*/) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - RamDacHelperRecPtr ramdacHelperPtr = NULL; - Bool RamDacIsSupported = FALSE; - int IBMramdac_ID = -1; - int i; - unsigned char id, rev, id2, rev2; - - /* read ID and revision */ - rev = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev); - id = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id); - - /* check if ID and revision are read only */ - (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, IBMRGB_rev); - (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, IBMRGB_id); - rev2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev); - id2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id); - - switch (id) { - case 0x30: - if (rev == 0xc0) IBMramdac_ID = IBM624_RAMDAC; - if (rev == 0x80) IBMramdac_ID = IBM624DB_RAMDAC; - break; - case 0x12: - if (rev == 0x1c) IBMramdac_ID = IBM640_RAMDAC; - break; - case 0x01: - IBMramdac_ID = IBM525_RAMDAC; - break; - case 0x02: - if (rev == 0xf0) IBMramdac_ID = IBM524_RAMDAC; - if (rev == 0xe0) IBMramdac_ID = IBM524A_RAMDAC; - if (rev == 0xc0) IBMramdac_ID = IBM526_RAMDAC; - if (rev == 0x80) IBMramdac_ID = IBM526DB_RAMDAC; - break; - } - - if (id == 1 || id == 2) { - if (id == id2 && rev == rev2) { /* IBM RGB52x found */ - /* check for 128bit VRAM -> RGB528 */ - if (((*ramdacPtr->ReadDAC)(pScrn, IBMRGB_misc1) & 0x03) == 0x03) { - IBMramdac_ID = IBM528_RAMDAC; /* 128bit DAC found */ - if (rev == 0xe0) - IBMramdac_ID = IBM528A_RAMDAC; - } - } - } - - (*ramdacPtr->WriteDAC)(pScrn, rev, 0, IBMRGB_rev); - (*ramdacPtr->WriteDAC)(pScrn, id, 0, IBMRGB_id); - - if (IBMramdac_ID == -1) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Cannot determine IBM RAMDAC type, aborting\n"); - return NULL; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Attached RAMDAC is %s\n", IBMramdacDeviceInfo[IBMramdac_ID&0xFFFF].DeviceName); - } - - for (i=0;ramdacs[i].token != -1;i++) { - if (ramdacs[i].token == IBMramdac_ID) - RamDacIsSupported = TRUE; - } - - if (!RamDacIsSupported) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "This IBM RAMDAC is NOT supported by this driver, aborting\n"); - return NULL; - } - - ramdacHelperPtr = RamDacHelperCreateInfoRec(); - switch (IBMramdac_ID) { - case IBM526_RAMDAC: - case IBM526DB_RAMDAC: - ramdacHelperPtr->SetBpp = IBMramdac526SetBpp; - ramdacHelperPtr->HWCursorInit = IBMramdac526HWCursorInit; - break; - case IBM640_RAMDAC: - ramdacHelperPtr->SetBpp = IBMramdac640SetBpp; - ramdacHelperPtr->HWCursorInit = IBMramdac640HWCursorInit; - break; - } - ramdacPtr->RamDacType = IBMramdac_ID; - ramdacHelperPtr->RamDacType = IBMramdac_ID; - ramdacHelperPtr->Save = IBMramdacSave; - ramdacHelperPtr->Restore = IBMramdacRestore; - - return ramdacHelperPtr; -} - -void -IBMramdac526SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg) -{ - ramdacReg->DacRegs[IBMRGB_key_control] = 0x00; /* Disable Chroma Key */ - - switch (pScrn->bitsPerPixel) { - case 32: - ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_32BPP; - ramdacReg->DacRegs[IBMRGB_32bpp] = B32_DCOL_DIRECT; - ramdacReg->DacRegs[IBMRGB_24bpp] = 0; - ramdacReg->DacRegs[IBMRGB_16bpp] = 0; - ramdacReg->DacRegs[IBMRGB_8bpp] = 0; - if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { - ramdacReg->DacRegs[IBMRGB_key_control] = 0x01; /* Enable Key */ - ramdacReg->DacRegs[IBMRGB_key] = 0xFF; - ramdacReg->DacRegs[IBMRGB_key_mask] = 0xFF; - } - break; - case 24: - ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_24BPP; - ramdacReg->DacRegs[IBMRGB_32bpp] = 0; - ramdacReg->DacRegs[IBMRGB_24bpp] = B24_DCOL_DIRECT; - ramdacReg->DacRegs[IBMRGB_16bpp] = 0; - ramdacReg->DacRegs[IBMRGB_8bpp] = 0; - break; - case 16: - if (pScrn->depth == 16) { - ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP; - ramdacReg->DacRegs[IBMRGB_32bpp] = 0; - ramdacReg->DacRegs[IBMRGB_24bpp] = 0; - ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR | - B16_CONTIGUOUS | B16_565; - ramdacReg->DacRegs[IBMRGB_8bpp] = 0; - } else { - ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP; - ramdacReg->DacRegs[IBMRGB_32bpp] = 0; - ramdacReg->DacRegs[IBMRGB_24bpp] = 0; - ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR | - B16_CONTIGUOUS | B16_555; - ramdacReg->DacRegs[IBMRGB_8bpp] = 0; - } - break; - case 8: - ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_8BPP; - ramdacReg->DacRegs[IBMRGB_32bpp] = 0; - ramdacReg->DacRegs[IBMRGB_24bpp] = 0; - ramdacReg->DacRegs[IBMRGB_16bpp] = 0; - ramdacReg->DacRegs[IBMRGB_8bpp] = B8_DCOL_INDIRECT; - break; - case 4: - ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_4BPP; - ramdacReg->DacRegs[IBMRGB_32bpp] = 0; - ramdacReg->DacRegs[IBMRGB_24bpp] = 0; - ramdacReg->DacRegs[IBMRGB_16bpp] = 0; - ramdacReg->DacRegs[IBMRGB_8bpp] = 0; - } -} - -IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void) { - return IBMramdac526SetBpp; -} - -void -IBMramdac640SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg) -{ - unsigned char bpp = 0x00; - unsigned char overlaybpp = 0x00; - unsigned char offset = 0x00; - unsigned char dispcont = 0x44; - - ramdacReg->DacRegs[RGB640_SER_WID_03_00] = 0x00; - ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x00; - ramdacReg->DacRegs[RGB640_DIAGS] = 0x07; - - switch (pScrn->depth) { - case 8: - ramdacReg->DacRegs[RGB640_SER_07_00] = 0x00; - ramdacReg->DacRegs[RGB640_SER_15_08] = 0x00; - ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00; - ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00; - ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_16_1; /*16:1 Mux*/ - ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */ - bpp = 0x03; - break; - case 15: - ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10; - ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11; - ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00; - ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00; - ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/ - ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */ - bpp = 0x0E; - break; - case 16: - ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10; - ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11; - ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00; - ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00; - ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/ - ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */ - bpp = 0x05; - break; - case 24: - ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30; - ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31; - ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32; - ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33; - ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/ - ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */ - bpp = 0x09; - if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { - ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x04; - ramdacReg->DacRegs[RGB640_CHROMA_KEY0] = 0xFF; - ramdacReg->DacRegs[RGB640_CHROMA_MASK0] = 0xFF; - offset = 0x04; - overlaybpp = 0x04; - dispcont = 0x48; - } - break; - case 30: /* 10 bit dac */ - ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30; - ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31; - ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32; - ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33; - ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/ - ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PSIZE10 | - IBM640_PCLK_8; /* pll / 8 */ - bpp = 0x0D; - break; - } - - { - int i; - for (i=0x100;i<0x140;i+=4) { - /* Initialize FrameBuffer Window Attribute Table */ - ramdacReg->DacRegs[i+0] = bpp; - ramdacReg->DacRegs[i+1] = offset; - ramdacReg->DacRegs[i+2] = 0x00; - ramdacReg->DacRegs[i+3] = 0x00; - /* Initialize Overlay Window Attribute Table */ - ramdacReg->DacRegs[i+0x100] = overlaybpp; - ramdacReg->DacRegs[i+0x101] = 0x00; - ramdacReg->DacRegs[i+0x102] = 0x00; - ramdacReg->DacRegs[i+0x103] = dispcont; - } - } -} - -static void -IBMramdac526ShowCursor(ScrnInfoPtr pScrn) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - /* Enable cursor - X11 mode */ - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x07); -} - -static void -IBMramdac640ShowCursor(ScrnInfoPtr pScrn) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - /* Enable cursor - mode2 (x11 mode) */ - (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x0B); - (*ramdacPtr->WriteDAC)(pScrn, RGB640_CROSSHAIR_CONTROL, 0x00, 0x00); -} - -static void -IBMramdac526HideCursor(ScrnInfoPtr pScrn) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - /* Disable cursor - X11 mode */ - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x24); -} - -static void -IBMramdac640HideCursor(ScrnInfoPtr pScrn) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - /* Disable cursor - mode2 (x11 mode) */ - (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x08); -} - -static void -IBMramdac526SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - x += 64; - y += 64; - - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_x, 0x00, 0x3f); - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_y, 0x00, 0x3f); - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xl, 0x00, x & 0xff); - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xh, 0x00, (x>>8) & 0xf); - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yl, 0x00, y & 0xff); - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yh, 0x00, (y>>8) & 0xf); -} - -static void -IBMramdac640SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - x += 64; - y += 64; - - (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETX, 0x00, 0x3f); - (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETY, 0x00, 0x3f); - (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_LOW, 0x00, x & 0xff); - (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_HIGH, 0x00, (x>>8) & 0xf); - (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_LOW, 0x00, y & 0xff); - (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_HIGH, 0x00, (y>>8) & 0xf); -} - -static void -IBMramdac526SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_r, 0x00, bg >> 16); - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_g, 0x00, bg >> 8); - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_b, 0x00, bg); - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_r, 0x00, fg >> 16); - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_g, 0x00, fg >> 8); - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_b, 0x00, fg); -} - -static void -IBMramdac640SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_COL0, 0x00, 0); - (*ramdacPtr->WriteData)(pScrn, fg>>16); - (*ramdacPtr->WriteData)(pScrn, fg>>8); - (*ramdacPtr->WriteData)(pScrn, fg); - (*ramdacPtr->WriteData)(pScrn, bg>>16); - (*ramdacPtr->WriteData)(pScrn, bg>>8); - (*ramdacPtr->WriteData)(pScrn, bg); - (*ramdacPtr->WriteData)(pScrn, fg>>16); - (*ramdacPtr->WriteData)(pScrn, fg>>8); - (*ramdacPtr->WriteData)(pScrn, fg); - (*ramdacPtr->WriteData)(pScrn, bg>>16); - (*ramdacPtr->WriteData)(pScrn, bg>>8); - (*ramdacPtr->WriteData)(pScrn, bg); -} - -static void -IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - int i; - /* - * Output the cursor data. The realize function has put the planes into - * their correct order, so we can just blast this out. - */ - for (i = 0; i < 1024; i++) - (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_array + i, 0x00, (*src++)); -} - -static void -IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - int i; - /* - * Output the cursor data. The realize function has put the planes into - * their correct order, so we can just blast this out. - */ - for (i = 0; i < 1024; i++) - (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_WRITE + i, 0x00, (*src++)); -} - -static Bool -IBMramdac526UseHWCursor(ScreenPtr pScr, CursorPtr pCurs) -{ - return TRUE; -} - -static Bool -IBMramdac640UseHWCursor(ScreenPtr pScr, CursorPtr pCurs) -{ - return TRUE; -} - -void -IBMramdac526HWCursorInit(xf86CursorInfoPtr infoPtr) -{ - infoPtr->MaxWidth = 64; - infoPtr->MaxHeight = 64; - infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | - HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | - HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1; - infoPtr->SetCursorColors = IBMramdac526SetCursorColors; - infoPtr->SetCursorPosition = IBMramdac526SetCursorPosition; - infoPtr->LoadCursorImage = IBMramdac526LoadCursorImage; - infoPtr->HideCursor = IBMramdac526HideCursor; - infoPtr->ShowCursor = IBMramdac526ShowCursor; - infoPtr->UseHWCursor = IBMramdac526UseHWCursor; -} - -void -IBMramdac640HWCursorInit(xf86CursorInfoPtr infoPtr) -{ - infoPtr->MaxWidth = 64; - infoPtr->MaxHeight = 64; - infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | - HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | - HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1; - infoPtr->SetCursorColors = IBMramdac640SetCursorColors; - infoPtr->SetCursorPosition = IBMramdac640SetCursorPosition; - infoPtr->LoadCursorImage = IBMramdac640LoadCursorImage; - infoPtr->HideCursor = IBMramdac640HideCursor; - infoPtr->ShowCursor = IBMramdac640ShowCursor; - infoPtr->UseHWCursor = IBMramdac640UseHWCursor; -} +/*
+ * Copyright 1998 by Alan Hourihane, Wigan, England.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ * IBM RAMDAC routines.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "xf86Cursor.h"
+
+#define INIT_IBM_RAMDAC_INFO
+#include "IBMPriv.h"
+#include "xf86RamDacPriv.h"
+
+#define INITIALFREQERR 100000
+
+unsigned long
+IBMramdac640CalculateMNPCForClock(
+ unsigned long RefClock, /* In 100Hz units */
+ unsigned long ReqClock, /* In 100Hz units */
+ char IsPixClock, /* boolean, is this the pixel or the sys clock */
+ unsigned long MinClock, /* Min VCO rating */
+ unsigned long MaxClock, /* Max VCO rating */
+ unsigned long *rM, /* M Out */
+ unsigned long *rN, /* N Out */
+ unsigned long *rP, /* Min P In, P Out */
+ unsigned long *rC /* C Out */
+)
+{
+ unsigned long M, N, P, iP = *rP;
+ unsigned long IntRef, VCO, Clock;
+ long freqErr, lowestFreqErr = INITIALFREQERR;
+ unsigned long ActualClock = 0;
+
+ for (N = 0; N <= 63; N++)
+ {
+ IntRef = RefClock / (N + 1);
+ if (IntRef < 10000)
+ break; /* IntRef needs to be >= 1MHz */
+ for (M = 2; M <= 127; M++)
+ {
+ VCO = IntRef * (M + 1);
+ if ((VCO < MinClock) || (VCO > MaxClock))
+ continue;
+ for (P = iP; P <= 4; P++)
+ {
+ if (P != 0)
+ Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P);
+ else
+ Clock = (RefClock * (M + 1)) / (N + 1);
+
+ freqErr = (Clock - ReqClock);
+
+ if (freqErr < 0)
+ {
+ /* PixelClock gets rounded up always so monitor reports
+ correct frequency. */
+ if (IsPixClock)
+ continue;
+ freqErr = -freqErr;
+ }
+
+ if (freqErr < lowestFreqErr)
+ {
+ *rM = M;
+ *rN = N;
+ *rP = P;
+ *rC = (VCO <= 1280000 ? 1 : 2);
+ ActualClock = Clock;
+
+ lowestFreqErr = freqErr;
+ /* Return if we found an exact match */
+ if (freqErr == 0)
+ return ActualClock;
+ }
+ }
+ }
+ }
+
+ return ActualClock;
+}
+
+unsigned long
+IBMramdac526CalculateMNPCForClock(
+ unsigned long RefClock, /* In 100Hz units */
+ unsigned long ReqClock, /* In 100Hz units */
+ char IsPixClock, /* boolean, is this the pixel or the sys clock */
+ unsigned long MinClock, /* Min VCO rating */
+ unsigned long MaxClock, /* Max VCO rating */
+ unsigned long *rM, /* M Out */
+ unsigned long *rN, /* N Out */
+ unsigned long *rP, /* Min P In, P Out */
+ unsigned long *rC /* C Out */
+)
+{
+ unsigned long M, N, P, iP = *rP;
+ unsigned long IntRef, VCO, Clock;
+ long freqErr, lowestFreqErr = INITIALFREQERR;
+ unsigned long ActualClock = 0;
+
+ for (N = 0; N <= 63; N++)
+ {
+ IntRef = RefClock / (N + 1);
+ if (IntRef < 10000)
+ break; /* IntRef needs to be >= 1MHz */
+ for (M = 0; M <= 63; M++)
+ {
+ VCO = IntRef * (M + 1);
+ if ((VCO < MinClock) || (VCO > MaxClock))
+ continue;
+ for (P = iP; P <= 4; P++)
+ {
+ if (P)
+ Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P);
+ else
+ Clock = VCO;
+
+ freqErr = (Clock - ReqClock);
+
+ if (freqErr < 0)
+ {
+ /* PixelClock gets rounded up always so monitor reports
+ correct frequency. */
+ if (IsPixClock)
+ continue;
+ freqErr = -freqErr;
+ }
+
+ if (freqErr < lowestFreqErr)
+ {
+ *rM = M;
+ *rN = N;
+ *rP = P;
+ *rC = (VCO <= 1280000 ? 1 : 2);
+ ActualClock = Clock;
+
+ lowestFreqErr = freqErr;
+ /* Return if we found an exact match */
+ if (freqErr == 0)
+ return ActualClock;
+ }
+ }
+ }
+ }
+
+ return ActualClock;
+}
+
+void
+IBMramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i, maxreg, dacreg;
+
+ switch (ramdacPtr->RamDacType) {
+ case IBM640_RAMDAC:
+ maxreg = 0x300;
+ dacreg = 1024;
+ break;
+ default:
+ maxreg = 0x100;
+ dacreg = 768;
+ break;
+ }
+
+ /* Here we pass a short, so that we can evaluate a mask too */
+ /* So that the mask is the high byte and the data the low byte */
+ for (i=0;i<maxreg;i++)
+ (*ramdacPtr->WriteDAC)
+ (pScrn, i, (ramdacReg->DacRegs[i] & 0xFF00) >> 8,
+ ramdacReg->DacRegs[i]);
+
+ (*ramdacPtr->WriteAddress)(pScrn, 0);
+ for (i=0;i<dacreg;i++)
+ (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]);
+}
+
+void
+IBMramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i, maxreg, dacreg;
+
+ switch (ramdacPtr->RamDacType) {
+ case IBM640_RAMDAC:
+ maxreg = 0x300;
+ dacreg = 1024;
+ break;
+ default:
+ maxreg = 0x100;
+ dacreg = 768;
+ break;
+ }
+
+ (*ramdacPtr->ReadAddress)(pScrn, 0);
+ for (i=0;i<dacreg;i++)
+ ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn);
+
+ for (i=0;i<maxreg;i++)
+ ramdacReg->DacRegs[i] = (*ramdacPtr->ReadDAC)(pScrn, i);
+}
+
+RamDacHelperRecPtr
+IBMramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/* , RamDacRecPtr ramdacPtr*/)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ RamDacHelperRecPtr ramdacHelperPtr = NULL;
+ Bool RamDacIsSupported = FALSE;
+ int IBMramdac_ID = -1;
+ int i;
+ unsigned char id, rev, id2, rev2;
+
+ /* read ID and revision */
+ rev = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev);
+ id = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id);
+
+ /* check if ID and revision are read only */
+ (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, IBMRGB_rev);
+ (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, IBMRGB_id);
+ rev2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev);
+ id2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id);
+
+ switch (id) {
+ case 0x30:
+ if (rev == 0xc0) IBMramdac_ID = IBM624_RAMDAC;
+ if (rev == 0x80) IBMramdac_ID = IBM624DB_RAMDAC;
+ break;
+ case 0x12:
+ if (rev == 0x1c) IBMramdac_ID = IBM640_RAMDAC;
+ break;
+ case 0x01:
+ IBMramdac_ID = IBM525_RAMDAC;
+ break;
+ case 0x02:
+ if (rev == 0xf0) IBMramdac_ID = IBM524_RAMDAC;
+ if (rev == 0xe0) IBMramdac_ID = IBM524A_RAMDAC;
+ if (rev == 0xc0) IBMramdac_ID = IBM526_RAMDAC;
+ if (rev == 0x80) IBMramdac_ID = IBM526DB_RAMDAC;
+ break;
+ }
+
+ if (id == 1 || id == 2) {
+ if (id == id2 && rev == rev2) { /* IBM RGB52x found */
+ /* check for 128bit VRAM -> RGB528 */
+ if (((*ramdacPtr->ReadDAC)(pScrn, IBMRGB_misc1) & 0x03) == 0x03) {
+ IBMramdac_ID = IBM528_RAMDAC; /* 128bit DAC found */
+ if (rev == 0xe0)
+ IBMramdac_ID = IBM528A_RAMDAC;
+ }
+ }
+ }
+
+ (*ramdacPtr->WriteDAC)(pScrn, rev, 0, IBMRGB_rev);
+ (*ramdacPtr->WriteDAC)(pScrn, id, 0, IBMRGB_id);
+
+ if (IBMramdac_ID == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Cannot determine IBM RAMDAC type, aborting\n");
+ return NULL;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Attached RAMDAC is %s\n", IBMramdacDeviceInfo[IBMramdac_ID&0xFFFF].DeviceName);
+ }
+
+ for (i=0;ramdacs[i].token != -1;i++) {
+ if (ramdacs[i].token == IBMramdac_ID)
+ RamDacIsSupported = TRUE;
+ }
+
+ if (!RamDacIsSupported) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "This IBM RAMDAC is NOT supported by this driver, aborting\n");
+ return NULL;
+ }
+
+ ramdacHelperPtr = RamDacHelperCreateInfoRec();
+ switch (IBMramdac_ID) {
+ case IBM526_RAMDAC:
+ case IBM526DB_RAMDAC:
+ ramdacHelperPtr->SetBpp = IBMramdac526SetBpp;
+ ramdacHelperPtr->HWCursorInit = IBMramdac526HWCursorInit;
+ break;
+ case IBM640_RAMDAC:
+ ramdacHelperPtr->SetBpp = IBMramdac640SetBpp;
+ ramdacHelperPtr->HWCursorInit = IBMramdac640HWCursorInit;
+ break;
+ }
+ ramdacPtr->RamDacType = IBMramdac_ID;
+ ramdacHelperPtr->RamDacType = IBMramdac_ID;
+ ramdacHelperPtr->Save = IBMramdacSave;
+ ramdacHelperPtr->Restore = IBMramdacRestore;
+
+ return ramdacHelperPtr;
+}
+
+void
+IBMramdac526SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ ramdacReg->DacRegs[IBMRGB_key_control] = 0x00; /* Disable Chroma Key */
+
+ switch (pScrn->bitsPerPixel) {
+ case 32:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_32BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = B32_DCOL_DIRECT;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[IBMRGB_key_control] = 0x01; /* Enable Key */
+ ramdacReg->DacRegs[IBMRGB_key] = 0xFF;
+ ramdacReg->DacRegs[IBMRGB_key_mask] = 0xFF;
+ }
+ break;
+ case 24:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_24BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = B24_DCOL_DIRECT;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ break;
+ case 16:
+ if (pScrn->depth == 16) {
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR |
+ B16_CONTIGUOUS | B16_565;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ } else {
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR |
+ B16_CONTIGUOUS | B16_555;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ }
+ break;
+ case 8:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_8BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = B8_DCOL_INDIRECT;
+ break;
+ case 4:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_4BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ }
+}
+
+IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void) {
+ return IBMramdac526SetBpp;
+}
+
+void
+IBMramdac640SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ unsigned char bpp = 0x00;
+ unsigned char overlaybpp = 0x00;
+ unsigned char offset = 0x00;
+ unsigned char dispcont = 0x44;
+
+ ramdacReg->DacRegs[RGB640_SER_WID_03_00] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x00;
+ ramdacReg->DacRegs[RGB640_DIAGS] = 0x07;
+
+ switch (pScrn->depth) {
+ case 8:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_16_1; /*16:1 Mux*/
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x03;
+ break;
+ case 15:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x0E;
+ break;
+ case 16:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x05;
+ break;
+ case 24:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x09;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x04;
+ ramdacReg->DacRegs[RGB640_CHROMA_KEY0] = 0xFF;
+ ramdacReg->DacRegs[RGB640_CHROMA_MASK0] = 0xFF;
+ offset = 0x04;
+ overlaybpp = 0x04;
+ dispcont = 0x48;
+ }
+ break;
+ case 30: /* 10 bit dac */
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PSIZE10 |
+ IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x0D;
+ break;
+ }
+
+ {
+ int i;
+ for (i=0x100;i<0x140;i+=4) {
+ /* Initialize FrameBuffer Window Attribute Table */
+ ramdacReg->DacRegs[i+0] = bpp;
+ ramdacReg->DacRegs[i+1] = offset;
+ ramdacReg->DacRegs[i+2] = 0x00;
+ ramdacReg->DacRegs[i+3] = 0x00;
+ /* Initialize Overlay Window Attribute Table */
+ ramdacReg->DacRegs[i+0x100] = overlaybpp;
+ ramdacReg->DacRegs[i+0x101] = 0x00;
+ ramdacReg->DacRegs[i+0x102] = 0x00;
+ ramdacReg->DacRegs[i+0x103] = dispcont;
+ }
+ }
+}
+
+static void
+IBMramdac526ShowCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Enable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x07);
+}
+
+static void
+IBMramdac640ShowCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Enable cursor - mode2 (x11 mode) */
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x0B);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CROSSHAIR_CONTROL, 0x00, 0x00);
+}
+
+static void
+IBMramdac526HideCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Disable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x24);
+}
+
+static void
+IBMramdac640HideCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Disable cursor - mode2 (x11 mode) */
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x08);
+}
+
+static void
+IBMramdac526SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ x += 64;
+ y += 64;
+
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_x, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_y, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xl, 0x00, x & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xh, 0x00, (x>>8) & 0xf);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yl, 0x00, y & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yh, 0x00, (y>>8) & 0xf);
+}
+
+static void
+IBMramdac640SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ x += 64;
+ y += 64;
+
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETX, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETY, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_LOW, 0x00, x & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_HIGH, 0x00, (x>>8) & 0xf);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_LOW, 0x00, y & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_HIGH, 0x00, (y>>8) & 0xf);
+}
+
+static void
+IBMramdac526SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_r, 0x00, bg >> 16);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_g, 0x00, bg >> 8);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_b, 0x00, bg);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_r, 0x00, fg >> 16);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_g, 0x00, fg >> 8);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_b, 0x00, fg);
+}
+
+static void
+IBMramdac640SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_COL0, 0x00, 0);
+ (*ramdacPtr->WriteData)(pScrn, fg>>16);
+ (*ramdacPtr->WriteData)(pScrn, fg>>8);
+ (*ramdacPtr->WriteData)(pScrn, fg);
+ (*ramdacPtr->WriteData)(pScrn, bg>>16);
+ (*ramdacPtr->WriteData)(pScrn, bg>>8);
+ (*ramdacPtr->WriteData)(pScrn, bg);
+ (*ramdacPtr->WriteData)(pScrn, fg>>16);
+ (*ramdacPtr->WriteData)(pScrn, fg>>8);
+ (*ramdacPtr->WriteData)(pScrn, fg);
+ (*ramdacPtr->WriteData)(pScrn, bg>>16);
+ (*ramdacPtr->WriteData)(pScrn, bg>>8);
+ (*ramdacPtr->WriteData)(pScrn, bg);
+}
+
+static void
+IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ int i;
+ /*
+ * Output the cursor data. The realize function has put the planes into
+ * their correct order, so we can just blast this out.
+ */
+ for (i = 0; i < 1024; i++)
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_array + i, 0x00, (*src++));
+}
+
+static void
+IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ int i;
+ /*
+ * Output the cursor data. The realize function has put the planes into
+ * their correct order, so we can just blast this out.
+ */
+ for (i = 0; i < 1024; i++)
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_WRITE + i, 0x00, (*src++));
+}
+
+static Bool
+IBMramdac526UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+{
+ return TRUE;
+}
+
+static Bool
+IBMramdac640UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+{
+ return TRUE;
+}
+
+void
+IBMramdac526HWCursorInit(xf86CursorInfoPtr infoPtr)
+{
+ infoPtr->MaxWidth = 64;
+ infoPtr->MaxHeight = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1;
+ infoPtr->SetCursorColors = IBMramdac526SetCursorColors;
+ infoPtr->SetCursorPosition = IBMramdac526SetCursorPosition;
+ infoPtr->LoadCursorImage = IBMramdac526LoadCursorImage;
+ infoPtr->HideCursor = IBMramdac526HideCursor;
+ infoPtr->ShowCursor = IBMramdac526ShowCursor;
+ infoPtr->UseHWCursor = IBMramdac526UseHWCursor;
+}
+
+void
+IBMramdac640HWCursorInit(xf86CursorInfoPtr infoPtr)
+{
+ infoPtr->MaxWidth = 64;
+ infoPtr->MaxHeight = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1;
+ infoPtr->SetCursorColors = IBMramdac640SetCursorColors;
+ infoPtr->SetCursorPosition = IBMramdac640SetCursorPosition;
+ infoPtr->LoadCursorImage = IBMramdac640LoadCursorImage;
+ infoPtr->HideCursor = IBMramdac640HideCursor;
+ infoPtr->ShowCursor = IBMramdac640ShowCursor;
+ infoPtr->UseHWCursor = IBMramdac640UseHWCursor;
+}
diff --git a/xorg-server/hw/xfree86/ramdac/TI.c b/xorg-server/hw/xfree86/ramdac/TI.c index 1c541d76b..f189fed25 100644 --- a/xorg-server/hw/xfree86/ramdac/TI.c +++ b/xorg-server/hw/xfree86/ramdac/TI.c @@ -1,717 +1,717 @@ -/* - * Copyright 1998 by Alan Hourihane, Wigan, England. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - * - * Modified from IBM.c to support TI RAMDAC routines - * by Jens Owen, <jens@tungstengraphics.com>. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86.h" -#include "xf86_OSproc.h" - -#include "xf86Cursor.h" - -#define INIT_TI_RAMDAC_INFO -#include "TIPriv.h" -#include "xf86RamDacPriv.h" - -/* The following values are in kHz */ -#define TI_MIN_VCO_FREQ 110000 -#define TI_MAX_VCO_FREQ 220000 - -unsigned long -TIramdacCalculateMNPForClock( - unsigned long RefClock, /* In 100Hz units */ - unsigned long ReqClock, /* In 100Hz units */ - char IsPixClock, /* boolean, is this the pixel or the sys clock */ - unsigned long MinClock, /* Min VCO rating */ - unsigned long MaxClock, /* Max VCO rating */ - unsigned long *rM, /* M Out */ - unsigned long *rN, /* N Out */ - unsigned long *rP /* Min P In, P Out */ -) -{ - unsigned long n, p; - unsigned long best_m = 0, best_n = 0; - double VCO, IntRef = (double)RefClock; - double m_err, inc_m, calc_m; - unsigned long ActualClock; - - /* Make sure that MinClock <= ReqClock <= MaxClock */ - if ( ReqClock < MinClock) - ReqClock = MinClock; - if ( ReqClock > MaxClock ) - ReqClock = MaxClock; - - /* - * ActualClock = VCO / 2 ^ p - * Choose p so that TI_MIN_VCO_FREQ <= VCO <= TI_MAX_VCO_FREQ - * Note that since TI_MAX_VCO_FREQ = 2 * TI_MIN_VCO_FREQ - * we don't have to bother checking for this maximum limit. - */ - VCO = (double)ReqClock; - for ( p = 0; p < 3 && VCO < TI_MIN_VCO_FREQ; ( p )++ ) - VCO *= 2.0; - - /* - * We avoid doing multiplications by ( 65 - n ), - * and add an increment instead - this keeps any error small. - */ - inc_m = VCO / ( IntRef * 8.0 ); - - /* Initial value of calc_m for the loop */ - calc_m = inc_m + inc_m + inc_m; - - /* Initial amount of error for an integer - impossibly large */ - m_err = 2.0; - - /* Search for the closest INTEGER value of ( 65 - m ) */ - for ( n = 3; n <= 25; ( n )++, calc_m += inc_m ) { - - /* Ignore values of ( 65 - m ) which we can't use */ - if ( calc_m < 3.0 || calc_m > 64.0 ) - continue; - - /* - * Pick the closest INTEGER (has smallest fractional part). - * The optimizer should clean this up for us. - */ - if (( calc_m - ( int ) calc_m ) < m_err ) { - m_err = calc_m - ( int ) calc_m; - best_m = ( int ) calc_m; - best_n = n; - } - } - - /* 65 - ( 65 - x ) = x */ - *rM = 65 - best_m; - *rN = 65 - best_n; - *rP = p; - - /* Now all the calculations can be completed */ - VCO = 8.0 * IntRef * best_m / best_n; - ActualClock = VCO / ( 1 << p ); - - DebugF( "f_out=%ld f_vco=%.1f n=%d m=%d p=%d\n", - ActualClock, VCO, *rN, *rM, *rP); - - return (ActualClock); -} - -void -TIramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr, - RamDacRegRecPtr ramdacReg) -{ - int i; - unsigned long status; - - /* Here we pass a short, so that we can evaluate a mask too - * So that the mask is the high byte and the data the low byte - * Order is important - */ - TIRESTORE(TIDAC_latch_ctrl); - TIRESTORE(TIDAC_true_color_ctrl); - TIRESTORE(TIDAC_multiplex_ctrl); - TIRESTORE(TIDAC_clock_select); - TIRESTORE(TIDAC_palette_page); - TIRESTORE(TIDAC_general_ctrl); - TIRESTORE(TIDAC_misc_ctrl); - /* 0x2A & 0x2B are reserved */ - TIRESTORE(TIDAC_key_over_low); - TIRESTORE(TIDAC_key_over_high); - TIRESTORE(TIDAC_key_red_low); - TIRESTORE(TIDAC_key_red_high); - TIRESTORE(TIDAC_key_green_low); - TIRESTORE(TIDAC_key_green_high); - TIRESTORE(TIDAC_key_blue_low); - TIRESTORE(TIDAC_key_blue_high); - TIRESTORE(TIDAC_key_ctrl); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x30); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x38); - TIRESTORE(TIDAC_clock_ctrl); - TIRESTORE(TIDAC_sense_test); - TIRESTORE(TIDAC_ind_curs_ctrl); - - /* only restore clocks if they were valid to begin with */ - - if (ramdacReg->DacRegs[TIDAC_PIXEL_VALID]) { - /* Reset pixel clock */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, 0x3c); - - /* Restore N, M & P values for pixel clocks */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, - ramdacReg->DacRegs[TIDAC_PIXEL_N]); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, - ramdacReg->DacRegs[TIDAC_PIXEL_M]); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, - ramdacReg->DacRegs[TIDAC_PIXEL_P]); - - /* wait for pixel clock to lock */ - i = 1000000; - do { - status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data); - } while ((!(status & 0x40)) && (--i)); - if (!(status & 0x40)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Pixel clock setup timed out\n"); - return; - } - } - - if (ramdacReg->DacRegs[TIDAC_LOOP_VALID]) { - /* Reset loop clock */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, 0x70); - - /* Restore N, M & P values for pixel clocks */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, - ramdacReg->DacRegs[TIDAC_LOOP_N]); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, - ramdacReg->DacRegs[TIDAC_LOOP_M]); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, - ramdacReg->DacRegs[TIDAC_LOOP_P]); - - /* wait for loop clock to lock */ - i = 1000000; - do { - status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data); - } while ((!(status & 0x40)) && (--i)); - if (!(status & 0x40)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Loop clock setup timed out\n"); - return; - } - } - - /* restore palette */ - (*ramdacPtr->WriteAddress)(pScrn, 0); -#ifndef NOT_DONE - for (i=0;i<768;i++) - (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]); -#else - (*ramdacPtr->WriteData)(pScrn, 0); - (*ramdacPtr->WriteData)(pScrn, 0); - (*ramdacPtr->WriteData)(pScrn, 0); - for (i=0;i<765;i++) - (*ramdacPtr->WriteData)(pScrn, 0xff); -#endif -} - -void -TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr, - RamDacRegRecPtr ramdacReg) -{ - int i; - - (*ramdacPtr->ReadAddress)(pScrn, 0); - for (i=0;i<768;i++) - ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn); - - /* Read back N,M and P values for pixel clock */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0); - ramdacReg->DacRegs[TIDAC_PIXEL_N] = - (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11); - ramdacReg->DacRegs[TIDAC_PIXEL_M] = - (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22); - ramdacReg->DacRegs[TIDAC_PIXEL_P] = - (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data); - - /* Read back N,M and P values for loop clock */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0); - ramdacReg->DacRegs[TIDAC_LOOP_N] = - (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11); - ramdacReg->DacRegs[TIDAC_LOOP_M] = - (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22); - ramdacReg->DacRegs[TIDAC_LOOP_P] = - (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data); - - /* Order is important */ - TISAVE(TIDAC_latch_ctrl); - TISAVE(TIDAC_true_color_ctrl); - TISAVE(TIDAC_multiplex_ctrl); - TISAVE(TIDAC_clock_select); - TISAVE(TIDAC_palette_page); - TISAVE(TIDAC_general_ctrl); - TISAVE(TIDAC_misc_ctrl); - /* 0x2A & 0x2B are reserved */ - TISAVE(TIDAC_key_over_low); - TISAVE(TIDAC_key_over_high); - TISAVE(TIDAC_key_red_low); - TISAVE(TIDAC_key_red_high); - TISAVE(TIDAC_key_green_low); - TISAVE(TIDAC_key_green_high); - TISAVE(TIDAC_key_blue_low); - TISAVE(TIDAC_key_blue_high); - TISAVE(TIDAC_key_ctrl); - TISAVE(TIDAC_clock_ctrl); - TISAVE(TIDAC_sense_test); - TISAVE(TIDAC_ind_curs_ctrl); -} - -RamDacHelperRecPtr -TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - RamDacHelperRecPtr ramdacHelperPtr = NULL; - Bool RamDacIsSupported = FALSE; - int TIramdac_ID = -1; - int i; - unsigned char id, rev, rev2, id2; - - /* read ID and revision */ - rev = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev); - id = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id); - - /* check if ID and revision are read only */ - (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, TIDAC_rev); - (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, TIDAC_id); - rev2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev); - id2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id); - - switch (id) { - case TIDAC_TVP_3030_ID: - if (id == id2 && rev == rev2) /* check for READ ONLY */ - TIramdac_ID = TI3030_RAMDAC; - break; - case TIDAC_TVP_3026_ID: - if (id == id2 && rev == rev2) /* check for READ ONLY */ - TIramdac_ID = TI3026_RAMDAC; - break; - } - - (*ramdacPtr->WriteDAC)(pScrn, rev, 0, TIDAC_rev); - (*ramdacPtr->WriteDAC)(pScrn, id, 0, TIDAC_id); - - if (TIramdac_ID == -1) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Cannot determine TI RAMDAC type, aborting\n"); - return NULL; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Attached RAMDAC is %s\n", TIramdacDeviceInfo[TIramdac_ID&0xFFFF].DeviceName); - } - - for (i=0;ramdacs[i].token != -1;i++) { - if (ramdacs[i].token == TIramdac_ID) - RamDacIsSupported = TRUE; - } - - if (!RamDacIsSupported) { - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "This TI RAMDAC is NOT supported by this driver, aborting\n"); - return NULL; - } - - ramdacHelperPtr = RamDacHelperCreateInfoRec(); - switch (TIramdac_ID) { - case TI3030_RAMDAC: - ramdacHelperPtr->SetBpp = TIramdac3030SetBpp; - ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit; - break; - case TI3026_RAMDAC: - ramdacHelperPtr->SetBpp = TIramdac3026SetBpp; - ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit; - break; - } - ramdacPtr->RamDacType = TIramdac_ID; - ramdacHelperPtr->RamDacType = TIramdac_ID; - ramdacHelperPtr->Save = TIramdacSave; - ramdacHelperPtr->Restore = TIramdacRestore; - - return ramdacHelperPtr; -} - -void -TIramdac3026SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg) -{ - switch (pScrn->bitsPerPixel) { - case 32: - /* order is important */ - ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46; - ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5c; - ramdacReg->DacRegs[TIDAC_clock_select] = 0x05; - ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; - ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; - ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C; - /* 0x2A & 0x2B are reserved */ - ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; - ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; - ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; - if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06; - ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C; - ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01; - } - ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; - break; - case 24: - /* order is important */ - ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56; - ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58; - ramdacReg->DacRegs[TIDAC_clock_select] = 0x25; - ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; - ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00; - ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C; - /* 0x2A & 0x2B are reserved */ - ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; - ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; - ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; - ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; - break; - case 16: - /* order is important */ -#if 0 - /* Matrox driver uses this */ - ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07; -#else - ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; -#endif - if (pScrn->depth == 16) { - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45; - } else { - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44; - } -#if 0 - /* Matrox driver uses this */ - ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50; - ramdacReg->DacRegs[TIDAC_clock_select] = 0x15; - ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; - ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00; -#else - ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x54; - ramdacReg->DacRegs[TIDAC_clock_select] = 0x05; - ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; - ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; -#endif - ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C; - /* 0x2A & 0x2B are reserved */ - ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; - ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; - ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; - ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; - break; - case 8: - /* order is important */ - ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80; - ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4c; - ramdacReg->DacRegs[TIDAC_clock_select] = 0x05; - ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; - ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; - ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C; - /* 0x2A & 0x2B are reserved */ - ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00; - ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; - ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00; - ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; - ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; - break; - } -} - -void -TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg) -{ - switch (pScrn->bitsPerPixel) { - case 32: - /* order is important */ - ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46; - ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5D; - ramdacReg->DacRegs[TIDAC_clock_select] = 0x05; - ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; - ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; - ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C; - /* 0x2A & 0x2B are reserved */ - ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; - ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; - ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; - if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06; - ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C; - ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01; - } - ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; - break; - case 24: - /* order is important */ - ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56; - ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58; - ramdacReg->DacRegs[TIDAC_clock_select] = 0x25; - ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; - ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00; - ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C; - /* 0x2A & 0x2B are reserved */ - ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; - ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; - ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; - ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; - break; - case 16: - /* order is important */ -#if 0 - /* Matrox driver uses this */ - ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07; -#else - ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; -#endif - if (pScrn->depth == 16) { - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45; - } else { - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44; - } -#if 0 - /* Matrox driver uses this */ - ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50; - ramdacReg->DacRegs[TIDAC_clock_select] = 0x15; - ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; - ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00; -#else - ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x55; - ramdacReg->DacRegs[TIDAC_clock_select] = 0x85; - ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; - ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; -#endif - ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C; - /* 0x2A & 0x2B are reserved */ - ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; - ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; - ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; - ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; - break; - case 8: - /* order is important */ - ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; - ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80; - ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4d; - ramdacReg->DacRegs[TIDAC_clock_select] = 0x05; - ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; - ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; - ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C; - /* 0x2A & 0x2B are reserved */ - ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; - ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00; - ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; - ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00; - ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; - ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; - break; - } -} - -static void -TIramdacShowCursor(ScrnInfoPtr pScrn) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - /* Enable cursor - X11 mode */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x03); -} - -static void -TIramdacHideCursor(ScrnInfoPtr pScrn) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - /* Disable cursor - X11 mode */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00); -} - -static void -TIramdacSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - x += 64; - y += 64; - - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XLOW, 0, x & 0xff); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XHIGH, 0, (x >> 8) & 0x0f); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YLOW, 0, y & 0xff); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YHIGH, 0, (y >> 8) & 0x0f); -} - -static void -TIramdacSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - - /* Background color */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 1); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x00ff0000) >> 16)); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x0000ff00) >> 8)); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (bg&0x000000ff) ); - - /* Foreground color */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 2); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x00ff0000) >> 16)); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x0000ff00) >> 8)); - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (fg&0x000000ff) ); -} - -static void -TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) -{ - RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); - int i = 1024; - - /* reset A9,A8 */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00); - /* reset cursor RAM load address A7..A0 */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_INDEX, 0x00, 0x00); - - while(i--) { - /* NOT_DONE: might need a delay here */ - (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_RAM_DATA, 0, *(src++)); - } -} - -static Bool -TIramdacUseHWCursor(ScreenPtr pScr, CursorPtr pCurs) -{ - return TRUE; -} - -void -TIramdacHWCursorInit(xf86CursorInfoPtr infoPtr) -{ - infoPtr->MaxWidth = 64; - infoPtr->MaxHeight = 64; - infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST | - HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | - HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED; - infoPtr->SetCursorColors = TIramdacSetCursorColors; - infoPtr->SetCursorPosition = TIramdacSetCursorPosition; - infoPtr->LoadCursorImage = TIramdacLoadCursorImage; - infoPtr->HideCursor = TIramdacHideCursor; - infoPtr->ShowCursor = TIramdacShowCursor; - infoPtr->UseHWCursor = TIramdacUseHWCursor; -} - -void TIramdacLoadPalette( - ScrnInfoPtr pScrn, - int numColors, - int *indices, - LOCO *colors, - VisualPtr pVisual -){ - RamDacRecPtr hwp = RAMDACSCRPTR(pScrn); - int i, index, shift; - - if (pScrn->depth == 16) { - for(i = 0; i < numColors; i++) { - index = indices[i]; - (*hwp->WriteAddress)(pScrn, index << 2); - (*hwp->WriteData)(pScrn, colors[index >> 1].red); - (*hwp->WriteData)(pScrn, colors[index].green); - (*hwp->WriteData)(pScrn, colors[index >> 1].blue); - - if(index <= 31) { - (*hwp->WriteAddress)(pScrn, index << 3); - (*hwp->WriteData)(pScrn, colors[index].red); - (*hwp->WriteData)(pScrn, colors[(index << 1) + 1].green); - (*hwp->WriteData)(pScrn, colors[index].blue); - } - } -} else { - shift = (pScrn->depth == 15) ? 3 : 0; - - for(i = 0; i < numColors; i++) { - index = indices[i]; - (*hwp->WriteAddress)(pScrn, index << shift); - (*hwp->WriteData)(pScrn, colors[index].red); - (*hwp->WriteData)(pScrn, colors[index].green); - (*hwp->WriteData)(pScrn, colors[index].blue); - } -} -} - -TIramdacLoadPaletteProc *TIramdacLoadPaletteWeak(void) { - return TIramdacLoadPalette; -} +/*
+ * Copyright 1998 by Alan Hourihane, Wigan, England.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ * Modified from IBM.c to support TI RAMDAC routines
+ * by Jens Owen, <jens@tungstengraphics.com>.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "xf86Cursor.h"
+
+#define INIT_TI_RAMDAC_INFO
+#include "TIPriv.h"
+#include "xf86RamDacPriv.h"
+
+/* The following values are in kHz */
+#define TI_MIN_VCO_FREQ 110000
+#define TI_MAX_VCO_FREQ 220000
+
+unsigned long
+TIramdacCalculateMNPForClock(
+ unsigned long RefClock, /* In 100Hz units */
+ unsigned long ReqClock, /* In 100Hz units */
+ char IsPixClock, /* boolean, is this the pixel or the sys clock */
+ unsigned long MinClock, /* Min VCO rating */
+ unsigned long MaxClock, /* Max VCO rating */
+ unsigned long *rM, /* M Out */
+ unsigned long *rN, /* N Out */
+ unsigned long *rP /* Min P In, P Out */
+)
+{
+ unsigned long n, p;
+ unsigned long best_m = 0, best_n = 0;
+ double VCO, IntRef = (double)RefClock;
+ double m_err, inc_m, calc_m;
+ unsigned long ActualClock;
+
+ /* Make sure that MinClock <= ReqClock <= MaxClock */
+ if ( ReqClock < MinClock)
+ ReqClock = MinClock;
+ if ( ReqClock > MaxClock )
+ ReqClock = MaxClock;
+
+ /*
+ * ActualClock = VCO / 2 ^ p
+ * Choose p so that TI_MIN_VCO_FREQ <= VCO <= TI_MAX_VCO_FREQ
+ * Note that since TI_MAX_VCO_FREQ = 2 * TI_MIN_VCO_FREQ
+ * we don't have to bother checking for this maximum limit.
+ */
+ VCO = (double)ReqClock;
+ for ( p = 0; p < 3 && VCO < TI_MIN_VCO_FREQ; ( p )++ )
+ VCO *= 2.0;
+
+ /*
+ * We avoid doing multiplications by ( 65 - n ),
+ * and add an increment instead - this keeps any error small.
+ */
+ inc_m = VCO / ( IntRef * 8.0 );
+
+ /* Initial value of calc_m for the loop */
+ calc_m = inc_m + inc_m + inc_m;
+
+ /* Initial amount of error for an integer - impossibly large */
+ m_err = 2.0;
+
+ /* Search for the closest INTEGER value of ( 65 - m ) */
+ for ( n = 3; n <= 25; ( n )++, calc_m += inc_m ) {
+
+ /* Ignore values of ( 65 - m ) which we can't use */
+ if ( calc_m < 3.0 || calc_m > 64.0 )
+ continue;
+
+ /*
+ * Pick the closest INTEGER (has smallest fractional part).
+ * The optimizer should clean this up for us.
+ */
+ if (( calc_m - ( int ) calc_m ) < m_err ) {
+ m_err = calc_m - ( int ) calc_m;
+ best_m = ( int ) calc_m;
+ best_n = n;
+ }
+ }
+
+ /* 65 - ( 65 - x ) = x */
+ *rM = 65 - best_m;
+ *rN = 65 - best_n;
+ *rP = p;
+
+ /* Now all the calculations can be completed */
+ VCO = 8.0 * IntRef * best_m / best_n;
+ ActualClock = VCO / ( 1 << p );
+
+ DebugF( "f_out=%ld f_vco=%.1f n=%d m=%d p=%d\n",
+ ActualClock, VCO, *rN, *rM, *rP);
+
+ return ActualClock;
+}
+
+void
+TIramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i;
+ unsigned long status;
+
+ /* Here we pass a short, so that we can evaluate a mask too
+ * So that the mask is the high byte and the data the low byte
+ * Order is important
+ */
+ TIRESTORE(TIDAC_latch_ctrl);
+ TIRESTORE(TIDAC_true_color_ctrl);
+ TIRESTORE(TIDAC_multiplex_ctrl);
+ TIRESTORE(TIDAC_clock_select);
+ TIRESTORE(TIDAC_palette_page);
+ TIRESTORE(TIDAC_general_ctrl);
+ TIRESTORE(TIDAC_misc_ctrl);
+ /* 0x2A & 0x2B are reserved */
+ TIRESTORE(TIDAC_key_over_low);
+ TIRESTORE(TIDAC_key_over_high);
+ TIRESTORE(TIDAC_key_red_low);
+ TIRESTORE(TIDAC_key_red_high);
+ TIRESTORE(TIDAC_key_green_low);
+ TIRESTORE(TIDAC_key_green_high);
+ TIRESTORE(TIDAC_key_blue_low);
+ TIRESTORE(TIDAC_key_blue_high);
+ TIRESTORE(TIDAC_key_ctrl);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x30);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x38);
+ TIRESTORE(TIDAC_clock_ctrl);
+ TIRESTORE(TIDAC_sense_test);
+ TIRESTORE(TIDAC_ind_curs_ctrl);
+
+ /* only restore clocks if they were valid to begin with */
+
+ if (ramdacReg->DacRegs[TIDAC_PIXEL_VALID]) {
+ /* Reset pixel clock */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, 0x3c);
+
+ /* Restore N, M & P values for pixel clocks */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
+ ramdacReg->DacRegs[TIDAC_PIXEL_N]);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
+ ramdacReg->DacRegs[TIDAC_PIXEL_M]);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
+ ramdacReg->DacRegs[TIDAC_PIXEL_P]);
+
+ /* wait for pixel clock to lock */
+ i = 1000000;
+ do {
+ status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
+ } while ((!(status & 0x40)) && (--i));
+ if (!(status & 0x40)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Pixel clock setup timed out\n");
+ return;
+ }
+ }
+
+ if (ramdacReg->DacRegs[TIDAC_LOOP_VALID]) {
+ /* Reset loop clock */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, 0x70);
+
+ /* Restore N, M & P values for pixel clocks */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
+ ramdacReg->DacRegs[TIDAC_LOOP_N]);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
+ ramdacReg->DacRegs[TIDAC_LOOP_M]);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
+ ramdacReg->DacRegs[TIDAC_LOOP_P]);
+
+ /* wait for loop clock to lock */
+ i = 1000000;
+ do {
+ status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
+ } while ((!(status & 0x40)) && (--i));
+ if (!(status & 0x40)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Loop clock setup timed out\n");
+ return;
+ }
+ }
+
+ /* restore palette */
+ (*ramdacPtr->WriteAddress)(pScrn, 0);
+#ifndef NOT_DONE
+ for (i=0;i<768;i++)
+ (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]);
+#else
+ (*ramdacPtr->WriteData)(pScrn, 0);
+ (*ramdacPtr->WriteData)(pScrn, 0);
+ (*ramdacPtr->WriteData)(pScrn, 0);
+ for (i=0;i<765;i++)
+ (*ramdacPtr->WriteData)(pScrn, 0xff);
+#endif
+}
+
+void
+TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i;
+
+ (*ramdacPtr->ReadAddress)(pScrn, 0);
+ for (i=0;i<768;i++)
+ ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn);
+
+ /* Read back N,M and P values for pixel clock */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
+ ramdacReg->DacRegs[TIDAC_PIXEL_N] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11);
+ ramdacReg->DacRegs[TIDAC_PIXEL_M] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
+ ramdacReg->DacRegs[TIDAC_PIXEL_P] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
+
+ /* Read back N,M and P values for loop clock */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
+ ramdacReg->DacRegs[TIDAC_LOOP_N] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11);
+ ramdacReg->DacRegs[TIDAC_LOOP_M] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
+ ramdacReg->DacRegs[TIDAC_LOOP_P] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
+
+ /* Order is important */
+ TISAVE(TIDAC_latch_ctrl);
+ TISAVE(TIDAC_true_color_ctrl);
+ TISAVE(TIDAC_multiplex_ctrl);
+ TISAVE(TIDAC_clock_select);
+ TISAVE(TIDAC_palette_page);
+ TISAVE(TIDAC_general_ctrl);
+ TISAVE(TIDAC_misc_ctrl);
+ /* 0x2A & 0x2B are reserved */
+ TISAVE(TIDAC_key_over_low);
+ TISAVE(TIDAC_key_over_high);
+ TISAVE(TIDAC_key_red_low);
+ TISAVE(TIDAC_key_red_high);
+ TISAVE(TIDAC_key_green_low);
+ TISAVE(TIDAC_key_green_high);
+ TISAVE(TIDAC_key_blue_low);
+ TISAVE(TIDAC_key_blue_high);
+ TISAVE(TIDAC_key_ctrl);
+ TISAVE(TIDAC_clock_ctrl);
+ TISAVE(TIDAC_sense_test);
+ TISAVE(TIDAC_ind_curs_ctrl);
+}
+
+RamDacHelperRecPtr
+TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ RamDacHelperRecPtr ramdacHelperPtr = NULL;
+ Bool RamDacIsSupported = FALSE;
+ int TIramdac_ID = -1;
+ int i;
+ unsigned char id, rev, rev2, id2;
+
+ /* read ID and revision */
+ rev = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev);
+ id = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id);
+
+ /* check if ID and revision are read only */
+ (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, TIDAC_rev);
+ (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, TIDAC_id);
+ rev2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev);
+ id2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id);
+
+ switch (id) {
+ case TIDAC_TVP_3030_ID:
+ if (id == id2 && rev == rev2) /* check for READ ONLY */
+ TIramdac_ID = TI3030_RAMDAC;
+ break;
+ case TIDAC_TVP_3026_ID:
+ if (id == id2 && rev == rev2) /* check for READ ONLY */
+ TIramdac_ID = TI3026_RAMDAC;
+ break;
+ }
+
+ (*ramdacPtr->WriteDAC)(pScrn, rev, 0, TIDAC_rev);
+ (*ramdacPtr->WriteDAC)(pScrn, id, 0, TIDAC_id);
+
+ if (TIramdac_ID == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Cannot determine TI RAMDAC type, aborting\n");
+ return NULL;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Attached RAMDAC is %s\n", TIramdacDeviceInfo[TIramdac_ID&0xFFFF].DeviceName);
+ }
+
+ for (i=0;ramdacs[i].token != -1;i++) {
+ if (ramdacs[i].token == TIramdac_ID)
+ RamDacIsSupported = TRUE;
+ }
+
+ if (!RamDacIsSupported) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "This TI RAMDAC is NOT supported by this driver, aborting\n");
+ return NULL;
+ }
+
+ ramdacHelperPtr = RamDacHelperCreateInfoRec();
+ switch (TIramdac_ID) {
+ case TI3030_RAMDAC:
+ ramdacHelperPtr->SetBpp = TIramdac3030SetBpp;
+ ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
+ break;
+ case TI3026_RAMDAC:
+ ramdacHelperPtr->SetBpp = TIramdac3026SetBpp;
+ ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
+ break;
+ }
+ ramdacPtr->RamDacType = TIramdac_ID;
+ ramdacHelperPtr->RamDacType = TIramdac_ID;
+ ramdacHelperPtr->Save = TIramdacSave;
+ ramdacHelperPtr->Restore = TIramdacRestore;
+
+ return ramdacHelperPtr;
+}
+
+void
+TIramdac3026SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ switch (pScrn->bitsPerPixel) {
+ case 32:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5c;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01;
+ }
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 24:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x25;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 16:
+ /* order is important */
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07;
+#else
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+#endif
+ if (pScrn->depth == 16) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45;
+ } else {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44;
+ }
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x15;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+#else
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x54;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+#endif
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 8:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4c;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ }
+}
+
+void
+TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ switch (pScrn->bitsPerPixel) {
+ case 32:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5D;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01;
+ }
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 24:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x25;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 16:
+ /* order is important */
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07;
+#else
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+#endif
+ if (pScrn->depth == 16) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45;
+ } else {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44;
+ }
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x15;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+#else
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x55;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x85;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+#endif
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 8:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4d;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ }
+}
+
+static void
+TIramdacShowCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Enable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x03);
+}
+
+static void
+TIramdacHideCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Disable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00);
+}
+
+static void
+TIramdacSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ x += 64;
+ y += 64;
+
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XLOW, 0, x & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XHIGH, 0, (x >> 8) & 0x0f);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YLOW, 0, y & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YHIGH, 0, (y >> 8) & 0x0f);
+}
+
+static void
+TIramdacSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Background color */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 1);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x00ff0000) >> 16));
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x0000ff00) >> 8));
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (bg&0x000000ff) );
+
+ /* Foreground color */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 2);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x00ff0000) >> 16));
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x0000ff00) >> 8));
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (fg&0x000000ff) );
+}
+
+static void
+TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ int i = 1024;
+
+ /* reset A9,A8 */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00);
+ /* reset cursor RAM load address A7..A0 */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_INDEX, 0x00, 0x00);
+
+ while(i--) {
+ /* NOT_DONE: might need a delay here */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_RAM_DATA, 0, *(src++));
+ }
+}
+
+static Bool
+TIramdacUseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+{
+ return TRUE;
+}
+
+void
+TIramdacHWCursorInit(xf86CursorInfoPtr infoPtr)
+{
+ infoPtr->MaxWidth = 64;
+ infoPtr->MaxHeight = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
+ HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
+ infoPtr->SetCursorColors = TIramdacSetCursorColors;
+ infoPtr->SetCursorPosition = TIramdacSetCursorPosition;
+ infoPtr->LoadCursorImage = TIramdacLoadCursorImage;
+ infoPtr->HideCursor = TIramdacHideCursor;
+ infoPtr->ShowCursor = TIramdacShowCursor;
+ infoPtr->UseHWCursor = TIramdacUseHWCursor;
+}
+
+void TIramdacLoadPalette(
+ ScrnInfoPtr pScrn,
+ int numColors,
+ int *indices,
+ LOCO *colors,
+ VisualPtr pVisual
+){
+ RamDacRecPtr hwp = RAMDACSCRPTR(pScrn);
+ int i, index, shift;
+
+ if (pScrn->depth == 16) {
+ for(i = 0; i < numColors; i++) {
+ index = indices[i];
+ (*hwp->WriteAddress)(pScrn, index << 2);
+ (*hwp->WriteData)(pScrn, colors[index >> 1].red);
+ (*hwp->WriteData)(pScrn, colors[index].green);
+ (*hwp->WriteData)(pScrn, colors[index >> 1].blue);
+
+ if(index <= 31) {
+ (*hwp->WriteAddress)(pScrn, index << 3);
+ (*hwp->WriteData)(pScrn, colors[index].red);
+ (*hwp->WriteData)(pScrn, colors[(index << 1) + 1].green);
+ (*hwp->WriteData)(pScrn, colors[index].blue);
+ }
+ }
+} else {
+ shift = (pScrn->depth == 15) ? 3 : 0;
+
+ for(i = 0; i < numColors; i++) {
+ index = indices[i];
+ (*hwp->WriteAddress)(pScrn, index << shift);
+ (*hwp->WriteData)(pScrn, colors[index].red);
+ (*hwp->WriteData)(pScrn, colors[index].green);
+ (*hwp->WriteData)(pScrn, colors[index].blue);
+ }
+}
+}
+
+TIramdacLoadPaletteProc *TIramdacLoadPaletteWeak(void) {
+ return TIramdacLoadPalette;
+}
diff --git a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c index 91b5795c3..421e35b51 100644 --- a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c +++ b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c @@ -18,8 +18,7 @@ #include "inputstr.h"
extern InputInfo inputInfo;
-static int xf86CursorScreenKeyIndex;
-DevPrivateKey xf86CursorScreenKey = &xf86CursorScreenKeyIndex;
+DevPrivateKeyRec xf86CursorScreenKeyRec;
/* sprite functions */
@@ -65,6 +64,9 @@ xf86InitCursor( if (!xf86InitHardwareCursor(pScreen, infoPtr))
return FALSE;
+ if (!dixRegisterPrivateKey(&xf86CursorScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
ScreenPriv = calloc(1, sizeof(xf86CursorScreenRec));
if (!ScreenPriv)
return FALSE;
diff --git a/xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h b/xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h index 32be9c2f3..76e714b32 100644 --- a/xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h +++ b/xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h @@ -1,50 +1,51 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _XF86CURSORPRIV_H -#define _XF86CURSORPRIV_H - -#include "xf86Cursor.h" -#include "mipointrst.h" - -typedef struct { - Bool SWCursor; - Bool isUp; - Bool showTransparent; - short HotX; - short HotY; - short x; - short y; - CursorPtr CurrentCursor, CursorToRestore; - xf86CursorInfoPtr CursorInfoPtr; - CloseScreenProcPtr CloseScreen; - RecolorCursorProcPtr RecolorCursor; - InstallColormapProcPtr InstallColormap; - QueryBestSizeProcPtr QueryBestSize; - miPointerSpriteFuncPtr spriteFuncs; - Bool PalettedCursor; - ColormapPtr pInstalledMap; - Bool (*SwitchMode)(int, DisplayModePtr,int); - xf86EnableDisableFBAccessProc *EnableDisableFBAccess; - CursorPtr SavedCursor; - - /* Number of requests to force HW cursor */ - int ForceHWCursorCount; - Bool HWCursorForced; - - pointer transparentData; -} xf86CursorScreenRec, *xf86CursorScreenPtr; - -void xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y); -void xf86SetTransparentCursor(ScreenPtr pScreen); -void xf86MoveCursor(ScreenPtr pScreen, int x, int y); -void xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed); -Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr); - -CARD32 xf86ReverseBitOrder(CARD32 data); - -extern _X_EXPORT DevPrivateKey xf86CursorScreenKey; - -#endif /* _XF86CURSORPRIV_H */ +
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _XF86CURSORPRIV_H
+#define _XF86CURSORPRIV_H
+
+#include "xf86Cursor.h"
+#include "mipointrst.h"
+
+typedef struct {
+ Bool SWCursor;
+ Bool isUp;
+ Bool showTransparent;
+ short HotX;
+ short HotY;
+ short x;
+ short y;
+ CursorPtr CurrentCursor, CursorToRestore;
+ xf86CursorInfoPtr CursorInfoPtr;
+ CloseScreenProcPtr CloseScreen;
+ RecolorCursorProcPtr RecolorCursor;
+ InstallColormapProcPtr InstallColormap;
+ QueryBestSizeProcPtr QueryBestSize;
+ miPointerSpriteFuncPtr spriteFuncs;
+ Bool PalettedCursor;
+ ColormapPtr pInstalledMap;
+ Bool (*SwitchMode)(int, DisplayModePtr,int);
+ xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
+ CursorPtr SavedCursor;
+
+ /* Number of requests to force HW cursor */
+ int ForceHWCursorCount;
+ Bool HWCursorForced;
+
+ pointer transparentData;
+} xf86CursorScreenRec, *xf86CursorScreenPtr;
+
+void xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y);
+void xf86SetTransparentCursor(ScreenPtr pScreen);
+void xf86MoveCursor(ScreenPtr pScreen, int x, int y);
+void xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed);
+Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr);
+
+CARD32 xf86ReverseBitOrder(CARD32 data);
+
+extern _X_EXPORT DevPrivateKeyRec xf86CursorScreenKeyRec;
+#define xf86CursorScreenKey (&xf86CursorScreenKeyRec)
+
+#endif /* _XF86CURSORPRIV_H */
diff --git a/xorg-server/hw/xfree86/ramdac/xf86RamDac.c b/xorg-server/hw/xfree86/ramdac/xf86RamDac.c index 25d450c07..a170444a9 100644 --- a/xorg-server/hw/xfree86/ramdac/xf86RamDac.c +++ b/xorg-server/hw/xfree86/ramdac/xf86RamDac.c @@ -82,7 +82,7 @@ RamDacInit(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPriv) ((RamDacScreenRecPtr) (pScrn)->privates[RamDacGetScreenIndex()].ptr);
ramdacScrPtr->RamDacRec = ramdacPriv;
- return(TRUE);
+ return TRUE;
}
void
@@ -132,12 +132,10 @@ RamDacFreeRec(ScrnInfoPtr pScrn) ramdacScrPtr = ((RamDacScreenRecPtr)
(pScrn)->privates[RamDacGetScreenIndex()].ptr);
- if (ramdacHWPtr)
- free(ramdacHWPtr);
+ free(ramdacHWPtr);
ramdacHWPtr = NULL;
- if (ramdacScrPtr)
- free(ramdacScrPtr);
+ free(ramdacScrPtr);
ramdacScrPtr = NULL;
}
diff --git a/xorg-server/hw/xfree86/shadowfb/shadow.c b/xorg-server/hw/xfree86/shadowfb/shadow.c index 9e847f4d2..4c7551de9 100644 --- a/xorg-server/hw/xfree86/shadowfb/shadow.c +++ b/xorg-server/hw/xfree86/shadowfb/shadow.c @@ -84,11 +84,11 @@ typedef struct { GCFuncs *funcs;
} ShadowGCRec, *ShadowGCPtr;
+static DevPrivateKeyRec ShadowScreenKeyRec;
+#define ShadowScreenKey (&ShadowScreenKeyRec)
-static int ShadowScreenKeyIndex;
-static DevPrivateKey ShadowScreenKey = &ShadowScreenKeyIndex;
-static int ShadowGCKeyIndex;
-static DevPrivateKey ShadowGCKey = &ShadowGCKeyIndex;
+static DevPrivateKeyRec ShadowGCKeyRec;
+#define ShadowGCKey (&ShadowGCKeyRec)
#define GET_SCREEN_PRIVATE(pScreen) \
(ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey)
@@ -162,7 +162,10 @@ ShadowFBInit2 ( if(!preRefreshArea && !postRefreshArea) return FALSE;
- if(!dixRequestPrivate(ShadowGCKey, sizeof(ShadowGCRec)))
+ if (!dixRegisterPrivateKey(&ShadowScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if(!dixRegisterPrivateKey(&ShadowGCKeyRec, PRIVATE_GC, sizeof(ShadowGCRec)))
return FALSE;
if(!(pPriv = (ShadowScreenPtr)malloc(sizeof(ShadowScreenRec))))
@@ -272,18 +275,18 @@ ShadowCopyWindow( RegionRec rgnDst;
if (pPriv->vtSema) {
- REGION_NULL(pWin->drawable.pScreen, &rgnDst);
- REGION_COPY(pWin->drawable.pScreen, &rgnDst, prgn);
+ RegionNull(&rgnDst);
+ RegionCopy(&rgnDst, prgn);
- REGION_TRANSLATE(pWin->drawable.pScreen, &rgnDst,
+ RegionTranslate(&rgnDst,
pWin->drawable.x - ptOldOrg.x,
pWin->drawable.y - ptOldOrg.y);
- REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, &rgnDst);
- if ((num = REGION_NUM_RECTS(&rgnDst))) {
+ RegionIntersect(&rgnDst, &pWin->borderClip, &rgnDst);
+ if ((num = RegionNumRects(&rgnDst))) {
if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, num, REGION_RECTS(&rgnDst));
+ (*pPriv->preRefresh)(pPriv->pScrn, num, RegionRects(&rgnDst));
} else {
- REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
}
}
@@ -293,8 +296,8 @@ ShadowCopyWindow( if (num) {
if (pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, num, REGION_RECTS(&rgnDst));
- REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+ (*pPriv->postRefresh)(pPriv->pScrn, num, RegionRects(&rgnDst));
+ RegionUninit(&rgnDst);
}
}
@@ -1353,38 +1356,32 @@ ShadowFontToBox(BoxPtr BB, DrawablePtr pDrawable, GCPtr pGC, int x, int y, }
right += pFont->info.maxbounds.rightSideBearing;
BB->x1 =
- max(pDrawable->x + x - left, (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->x1);
+ max(pDrawable->x + x - left,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x1);
BB->y1 =
max(pDrawable->y + y - ascent,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->y1);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y1);
BB->x2 =
min(pDrawable->x + x + right,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->x2);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x2);
BB->y2 =
min(pDrawable->y + y + descent,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->y2);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y2);
} else {
ShadowTextExtent(pFont, count, chars, wide ? (FONTLASTROW(pFont) == 0)
? Linear16Bit : TwoD16Bit : Linear8Bit, BB);
BB->x1 =
- max(pDrawable->x + x + BB->x1, (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->x1);
+ max(pDrawable->x + x + BB->x1,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x1);
BB->y1 =
max(pDrawable->y + y + BB->y1,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->y1);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y1);
BB->x2 =
min(pDrawable->x + x + BB->x2,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->x2);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x2);
BB->y2 =
min(pDrawable->y + y + BB->y2,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->y2);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y2);
}
}
diff --git a/xorg-server/hw/xfree86/utils/gtf/gtf.c b/xorg-server/hw/xfree86/utils/gtf/gtf.c index 8ce93276a..840626c66 100644 --- a/xorg-server/hw/xfree86/utils/gtf/gtf.c +++ b/xorg-server/hw/xfree86/utils/gtf/gtf.c @@ -1,741 +1,741 @@ -/* gtf.c Generate mode timings using the GTF Timing Standard - * - * gcc gtf.c -o gtf -lm -Wall - * - * Copyright (c) 2001, Andy Ritger aritger@nvidia.com - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * o Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * o Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * o Neither the name of NVIDIA nor the names of its contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT - * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - * - * This program is based on the Generalized Timing Formula(GTF TM) - * Standard Version: 1.0, Revision: 1.0 - * - * The GTF Document contains the following Copyright information: - * - * Copyright (c) 1994, 1995, 1996 - Video Electronics Standards - * Association. Duplication of this document within VESA member - * companies for review purposes is permitted. All other rights - * reserved. - * - * While every precaution has been taken in the preparation - * of this standard, the Video Electronics Standards Association and - * its contributors assume no responsibility for errors or omissions, - * and make no warranties, expressed or implied, of functionality - * of suitability for any purpose. The sample code contained within - * this standard may be used without restriction. - * - * - * - * The GTF EXCEL(TM) SPREADSHEET, a sample (and the definitive) - * implementation of the GTF Timing Standard, is available at: - * - * ftp://ftp.vesa.org/pub/GTF/GTF_V1R1.xls - * - * - * - * This program takes a desired resolution and vertical refresh rate, - * and computes mode timings according to the GTF Timing Standard. - * These mode timings can then be formatted as an XServer modeline - * or a mode description for use by fbset(8). - * - * - * - * NOTES: - * - * The GTF allows for computation of "margins" (the visible border - * surrounding the addressable video); on most non-overscan type - * systems, the margin period is zero. I've implemented the margin - * computations but not enabled it because 1) I don't really have - * any experience with this, and 2) neither XServer modelines nor - * fbset fb.modes provide an obvious way for margin timings to be - * included in their mode descriptions (needs more investigation). - * - * The GTF provides for computation of interlaced mode timings; - * I've implemented the computations but not enabled them, yet. - * I should probably enable and test this at some point. - * - * - * - * TODO: - * - * o Add support for interlaced modes. - * - * o Implement the other portions of the GTF: compute mode timings - * given either the desired pixel clock or the desired horizontal - * frequency. - * - * o It would be nice if this were more general purpose to do things - * outside the scope of the GTF: like generate double scan mode - * timings, for example. - * - * o Printing digits to the right of the decimal point when the - * digits are 0 annoys me. - * - * o Error checking. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -# include <xorg-config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#define MARGIN_PERCENT 1.8 /* % of active vertical image */ -#define CELL_GRAN 8.0 /* assumed character cell granularity */ -#define MIN_PORCH 1 /* minimum front porch */ -#define V_SYNC_RQD 3 /* width of vsync in lines */ -#define H_SYNC_PERCENT 8.0 /* width of hsync as % of total line */ -#define MIN_VSYNC_PLUS_BP 550.0 /* min time of vsync + back porch (microsec) */ -#define M 600.0 /* blanking formula gradient */ -#define C 40.0 /* blanking formula offset */ -#define K 128.0 /* blanking formula scaling factor */ -#define J 20.0 /* blanking formula scaling factor */ - -/* C' and M' are part of the Blanking Duty Cycle computation */ - -#define C_PRIME (((C - J) * K/256.0) + J) -#define M_PRIME (K/256.0 * M) - - -/* struct definitions */ - -typedef struct __mode -{ - int hr, hss, hse, hfl; - int vr, vss, vse, vfl; - float pclk, h_freq, v_freq; -} mode; - - -typedef struct __options -{ - int x, y; - int xorgmode, fbmode; - float v_freq; -} options; - - - - -/* prototypes */ - -void print_value(int n, char *name, float val); -void print_xf86_mode (mode *m); -void print_fb_mode (mode *m); -mode *vert_refresh (int h_pixels, int v_lines, float freq, - int interlaced, int margins); -options *parse_command_line (int argc, char *argv[]); - - - - -/* - * print_value() - print the result of the named computation; this is - * useful when comparing against the GTF EXCEL spreadsheet. - */ - -int global_verbose = 0; - -void print_value(int n, char *name, float val) -{ - if (global_verbose) { - printf("%2d: %-27s: %15f\n", n, name, val); - } -} - - - -/* print_xf86_mode() - print the XServer modeline, given mode timings. */ - -void print_xf86_mode (mode *m) -{ - printf ("\n"); - printf (" # %dx%d @ %.2f Hz (GTF) hsync: %.2f kHz; pclk: %.2f MHz\n", - m->hr, m->vr, m->v_freq, m->h_freq, m->pclk); - - printf (" Modeline \"%dx%d_%.2f\" %.2f" - " %d %d %d %d" - " %d %d %d %d" - " -HSync +Vsync\n\n", - m->hr, m->vr, m->v_freq, m->pclk, - m->hr, m->hss, m->hse, m->hfl, - m->vr, m->vss, m->vse, m->vfl); - -} - - - -/* - * print_fb_mode() - print a mode description in fbset(8) format; - * see the fb.modes(8) manpage. The timing description used in - * this is rather odd; they use "left and right margin" to refer - * to the portion of the hblank before and after the sync pulse - * by conceptually wrapping the portion of the blank after the pulse - * to infront of the visible region; ie: - * - * - * Timing description I'm accustomed to: - * - * - * - * <--------1--------> <--2--> <--3--> <--4--> - * _________ - * |-------------------|_______| |_______ - * - * R SS SE FL - * - * 1: visible image - * 2: blank before sync (aka front porch) - * 3: sync pulse - * 4: blank after sync (aka back porch) - * R: Resolution - * SS: Sync Start - * SE: Sync End - * FL: Frame Length - * - * - * But the fb.modes format is: - * - * - * <--4--> <--------1--------> <--2--> <--3--> - * _________ - * _______|-------------------|_______| | - * - * The fb.modes(8) manpage refers to <4> and <2> as the left and - * right "margin" (as well as upper and lower margin in the vertical - * direction) -- note that this has nothing to do with the term - * "margin" used in the GTF Timing Standard. - * - * XXX always prints the 32 bit mode -- should I provide a command - * line option to specify the bpp? It's simple enough for a user - * to edit the mode description after it's generated. - */ - -void print_fb_mode (mode *m) -{ - printf ("\n"); - printf ("mode \"%dx%d %.2fHz 32bit (GTF)\"\n", - m->hr, m->vr, m->v_freq); - printf (" # PCLK: %.2f MHz, H: %.2f kHz, V: %.2f Hz\n", - m->pclk, m->h_freq, m->v_freq); - printf (" geometry %d %d %d %d 32\n", - m->hr, m->vr, m->hr, m->vr); - printf (" timings %d %d %d %d %d %d %d\n", - (int) rint(1000000.0/m->pclk),/* pixclock in picoseconds */ - m->hfl - m->hse, /* left margin (in pixels) */ - m->hss - m->hr, /* right margin (in pixels) */ - m->vfl - m->vse, /* upper margin (in pixel lines) */ - m->vss - m->vr, /* lower margin (in pixel lines) */ - m->hse - m->hss, /* horizontal sync length (pixels) */ - m->vse - m->vss); /* vert sync length (pixel lines) */ - printf (" hsync low\n"); - printf (" vsync high\n"); - printf ("endmode\n\n"); - -} - - - - -/* - * vert_refresh() - as defined by the GTF Timing Standard, compute the - * Stage 1 Parameters using the vertical refresh frequency. In other - * words: input a desired resolution and desired refresh rate, and - * output the GTF mode timings. - * - * XXX All the code is in place to compute interlaced modes, but I don't - * feel like testing it right now. - * - * XXX margin computations are implemented but not tested (nor used by - * XServer of fbset mode descriptions, from what I can tell). - */ - -mode *vert_refresh (int h_pixels, int v_lines, float freq, - int interlaced, int margins) -{ - float h_pixels_rnd; - float v_lines_rnd; - float v_field_rate_rqd; - float top_margin; - float bottom_margin; - float interlace; - float h_period_est; - float vsync_plus_bp; - float v_back_porch; - float total_v_lines; - float v_field_rate_est; - float h_period; - float v_field_rate; - float v_frame_rate; - float left_margin; - float right_margin; - float total_active_pixels; - float ideal_duty_cycle; - float h_blank; - float total_pixels; - float pixel_freq; - float h_freq; - - float h_sync; - float h_front_porch; - float v_odd_front_porch_lines; - - mode *m = (mode*) malloc (sizeof (mode)); - - - /* 1. In order to give correct results, the number of horizontal - * pixels requested is first processed to ensure that it is divisible - * by the character size, by rounding it to the nearest character - * cell boundary: - * - * [H PIXELS RND] = ((ROUND([H PIXELS]/[CELL GRAN RND],0))*[CELLGRAN RND]) - */ - - h_pixels_rnd = rint((float) h_pixels / CELL_GRAN) * CELL_GRAN; - - print_value(1, "[H PIXELS RND]", h_pixels_rnd); - - - /* 2. If interlace is requested, the number of vertical lines assumed - * by the calculation must be halved, as the computation calculates - * the number of vertical lines per field. In either case, the - * number of lines is rounded to the nearest integer. - * - * [V LINES RND] = IF([INT RQD?]="y", ROUND([V LINES]/2,0), - * ROUND([V LINES],0)) - */ - - v_lines_rnd = interlaced ? - rint((float) v_lines) / 2.0 : - rint((float) v_lines); - - print_value(2, "[V LINES RND]", v_lines_rnd); - - - /* 3. Find the frame rate required: - * - * [V FIELD RATE RQD] = IF([INT RQD?]="y", [I/P FREQ RQD]*2, - * [I/P FREQ RQD]) - */ - - v_field_rate_rqd = interlaced ? (freq * 2.0) : (freq); - - print_value(3, "[V FIELD RATE RQD]", v_field_rate_rqd); - - - /* 4. Find number of lines in Top margin: - * - * [TOP MARGIN (LINES)] = IF([MARGINS RQD?]="Y", - * ROUND(([MARGIN%]/100*[V LINES RND]),0), - * 0) - */ - - top_margin = margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0); - - print_value(4, "[TOP MARGIN (LINES)]", top_margin); - - - /* 5. Find number of lines in Bottom margin: - * - * [BOT MARGIN (LINES)] = IF([MARGINS RQD?]="Y", - * ROUND(([MARGIN%]/100*[V LINES RND]),0), - * 0) - */ - - bottom_margin = margins ? rint(MARGIN_PERCENT/100.0 * v_lines_rnd) : (0.0); - - print_value(5, "[BOT MARGIN (LINES)]", bottom_margin); - - - /* 6. If interlace is required, then set variable [INTERLACE]=0.5: - * - * [INTERLACE]=(IF([INT RQD?]="y",0.5,0)) - */ - - interlace = interlaced ? 0.5 : 0.0; - - print_value(6, "[INTERLACE]", interlace); - - - /* 7. Estimate the Horizontal period - * - * [H PERIOD EST] = ((1/[V FIELD RATE RQD]) - [MIN VSYNC+BP]/1000000) / - * ([V LINES RND] + (2*[TOP MARGIN (LINES)]) + - * [MIN PORCH RND]+[INTERLACE]) * 1000000 - */ - - h_period_est = (((1.0/v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP/1000000.0)) - / (v_lines_rnd + (2*top_margin) + MIN_PORCH + interlace) - * 1000000.0); - - print_value(7, "[H PERIOD EST]", h_period_est); - - - /* 8. Find the number of lines in V sync + back porch: - * - * [V SYNC+BP] = ROUND(([MIN VSYNC+BP]/[H PERIOD EST]),0) - */ - - vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP/h_period_est); - - print_value(8, "[V SYNC+BP]", vsync_plus_bp); - - - /* 9. Find the number of lines in V back porch alone: - * - * [V BACK PORCH] = [V SYNC+BP] - [V SYNC RND] - * - * XXX is "[V SYNC RND]" a typo? should be [V SYNC RQD]? - */ - - v_back_porch = vsync_plus_bp - V_SYNC_RQD; - - print_value(9, "[V BACK PORCH]", v_back_porch); - - - /* 10. Find the total number of lines in Vertical field period: - * - * [TOTAL V LINES] = [V LINES RND] + [TOP MARGIN (LINES)] + - * [BOT MARGIN (LINES)] + [V SYNC+BP] + [INTERLACE] + - * [MIN PORCH RND] - */ - - total_v_lines = v_lines_rnd + top_margin + bottom_margin + vsync_plus_bp + - interlace + MIN_PORCH; - - print_value(10, "[TOTAL V LINES]", total_v_lines); - - - /* 11. Estimate the Vertical field frequency: - * - * [V FIELD RATE EST] = 1 / [H PERIOD EST] / [TOTAL V LINES] * 1000000 - */ - - v_field_rate_est = 1.0 / h_period_est / total_v_lines * 1000000.0; - - print_value(11, "[V FIELD RATE EST]", v_field_rate_est); - - - /* 12. Find the actual horizontal period: - * - * [H PERIOD] = [H PERIOD EST] / ([V FIELD RATE RQD] / [V FIELD RATE EST]) - */ - - h_period = h_period_est / (v_field_rate_rqd / v_field_rate_est); - - print_value(12, "[H PERIOD]", h_period); - - - /* 13. Find the actual Vertical field frequency: - * - * [V FIELD RATE] = 1 / [H PERIOD] / [TOTAL V LINES] * 1000000 - */ - - v_field_rate = 1.0 / h_period / total_v_lines * 1000000.0; - - print_value(13, "[V FIELD RATE]", v_field_rate); - - - /* 14. Find the Vertical frame frequency: - * - * [V FRAME RATE] = (IF([INT RQD?]="y", [V FIELD RATE]/2, [V FIELD RATE])) - */ - - v_frame_rate = interlaced ? v_field_rate / 2.0 : v_field_rate; - - print_value(14, "[V FRAME RATE]", v_frame_rate); - - - /* 15. Find number of pixels in left margin: - * - * [LEFT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y", - * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 / - * [CELL GRAN RND]),0)) * [CELL GRAN RND], - * 0)) - */ - - left_margin = margins ? - rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN : - 0.0; - - print_value(15, "[LEFT MARGIN (PIXELS)]", left_margin); - - - /* 16. Find number of pixels in right margin: - * - * [RIGHT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y", - * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 / - * [CELL GRAN RND]),0)) * [CELL GRAN RND], - * 0)) - */ - - right_margin = margins ? - rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN : - 0.0; - - print_value(16, "[RIGHT MARGIN (PIXELS)]", right_margin); - - - /* 17. Find total number of active pixels in image and left and right - * margins: - * - * [TOTAL ACTIVE PIXELS] = [H PIXELS RND] + [LEFT MARGIN (PIXELS)] + - * [RIGHT MARGIN (PIXELS)] - */ - - total_active_pixels = h_pixels_rnd + left_margin + right_margin; - - print_value(17, "[TOTAL ACTIVE PIXELS]", total_active_pixels); - - - /* 18. Find the ideal blanking duty cycle from the blanking duty cycle - * equation: - * - * [IDEAL DUTY CYCLE] = [C'] - ([M']*[H PERIOD]/1000) - */ - - ideal_duty_cycle = C_PRIME - (M_PRIME * h_period / 1000.0); - - print_value(18, "[IDEAL DUTY CYCLE]", ideal_duty_cycle); - - - /* 19. Find the number of pixels in the blanking time to the nearest - * double character cell: - * - * [H BLANK (PIXELS)] = (ROUND(([TOTAL ACTIVE PIXELS] * - * [IDEAL DUTY CYCLE] / - * (100-[IDEAL DUTY CYCLE]) / - * (2*[CELL GRAN RND])), 0)) - * * (2*[CELL GRAN RND]) - */ - - h_blank = rint(total_active_pixels * - ideal_duty_cycle / - (100.0 - ideal_duty_cycle) / - (2.0 * CELL_GRAN)) * (2.0 * CELL_GRAN); - - print_value(19, "[H BLANK (PIXELS)]", h_blank); - - - /* 20. Find total number of pixels: - * - * [TOTAL PIXELS] = [TOTAL ACTIVE PIXELS] + [H BLANK (PIXELS)] - */ - - total_pixels = total_active_pixels + h_blank; - - print_value(20, "[TOTAL PIXELS]", total_pixels); - - - /* 21. Find pixel clock frequency: - * - * [PIXEL FREQ] = [TOTAL PIXELS] / [H PERIOD] - */ - - pixel_freq = total_pixels / h_period; - - print_value(21, "[PIXEL FREQ]", pixel_freq); - - - /* 22. Find horizontal frequency: - * - * [H FREQ] = 1000 / [H PERIOD] - */ - - h_freq = 1000.0 / h_period; - - print_value(22, "[H FREQ]", h_freq); - - - - /* Stage 1 computations are now complete; I should really pass - the results to another function and do the Stage 2 - computations, but I only need a few more values so I'll just - append the computations here for now */ - - - - /* 17. Find the number of pixels in the horizontal sync period: - * - * [H SYNC (PIXELS)] =(ROUND(([H SYNC%] / 100 * [TOTAL PIXELS] / - * [CELL GRAN RND]),0))*[CELL GRAN RND] - */ - - h_sync = rint(H_SYNC_PERCENT/100.0 * total_pixels / CELL_GRAN) * CELL_GRAN; - - print_value(17, "[H SYNC (PIXELS)]", h_sync); - - - /* 18. Find the number of pixels in the horizontal front porch period: - * - * [H FRONT PORCH (PIXELS)] = ([H BLANK (PIXELS)]/2)-[H SYNC (PIXELS)] - */ - - h_front_porch = (h_blank / 2.0) - h_sync; - - print_value(18, "[H FRONT PORCH (PIXELS)]", h_front_porch); - - - /* 36. Find the number of lines in the odd front porch period: - * - * [V ODD FRONT PORCH(LINES)]=([MIN PORCH RND]+[INTERLACE]) - */ - - v_odd_front_porch_lines = MIN_PORCH + interlace; - - print_value(36, "[V ODD FRONT PORCH(LINES)]", v_odd_front_porch_lines); - - - /* finally, pack the results in the mode struct */ - - m->hr = (int) (h_pixels_rnd); - m->hss = (int) (h_pixels_rnd + h_front_porch); - m->hse = (int) (h_pixels_rnd + h_front_porch + h_sync); - m->hfl = (int) (total_pixels); - - m->vr = (int) (v_lines_rnd); - m->vss = (int) (v_lines_rnd + v_odd_front_porch_lines); - m->vse = (int) (int) (v_lines_rnd + v_odd_front_porch_lines + V_SYNC_RQD); - m->vfl = (int) (total_v_lines); - - m->pclk = pixel_freq; - m->h_freq = h_freq; - m->v_freq = freq; - - return (m); - -} - - - - -/* - * parse_command_line() - parse the command line and return an - * alloced structure containing the results. On error print usage - * and return NULL. - */ - -options *parse_command_line (int argc, char *argv[]) -{ - int n; - - options *o = (options *) calloc (1, sizeof (options)); - - if (argc < 4) goto bad_option; - - o->x = atoi (argv[1]); - o->y = atoi (argv[2]); - o->v_freq = atof (argv[3]); - - /* XXX should check for errors in the above */ - - n = 4; - - while (n < argc) { - if ((strcmp (argv[n], "-v") == 0) || - (strcmp (argv[n], "--verbose") == 0)) { - global_verbose = 1; - } else if ((strcmp (argv[n], "-f") == 0) || - (strcmp (argv[n], "--fbmode") == 0)) { - o->fbmode = 1; - } else if ((strcmp (argv[n], "-x") == 0) || - (strcmp (argv[n], "--xorgmode") == 0) || - (strcmp (argv[n], "--xf86mode") == 0)) { - o->xorgmode = 1; - } else { - goto bad_option; - } - - n++; - } - - /* if neither xorgmode nor fbmode were requested, default to - xorgmode */ - - if (!o->fbmode && !o->xorgmode) o->xorgmode = 1; - - return (o); - - bad_option: - - fprintf (stderr, "\n"); - fprintf (stderr, "usage: %s x y refresh [-v|--verbose] " - "[-f|--fbmode] [-x|--xorgmode]\n", argv[0]); - - fprintf (stderr, "\n"); - - fprintf (stderr, " x : the desired horizontal " - "resolution (required)\n"); - fprintf (stderr, " y : the desired vertical " - "resolution (required)\n"); - fprintf (stderr, " refresh : the desired refresh " - "rate (required)\n"); - fprintf (stderr, " -v|--verbose : enable verbose printouts " - "(traces each step of the computation)\n"); - fprintf (stderr, " -f|--fbmode : output an fbset(8)-style mode " - "description\n"); - fprintf (stderr, " -x|--xorgmode : output an "__XSERVERNAME__"-style mode " - "description (this is the default\n" - " if no mode description is requested)\n"); - - fprintf (stderr, "\n"); - - free (o); - return (NULL); - -} - - - -int main (int argc, char *argv[]) -{ - mode *m; - options *o; - - o = parse_command_line (argc, argv); - if (!o) exit (1); - - m = vert_refresh (o->x, o->y, o->v_freq, 0, 0); - if (!m) exit (1); - - if (o->xorgmode) - print_xf86_mode(m); - - if (o->fbmode) - print_fb_mode(m); - - return 0; - -} +/* gtf.c Generate mode timings using the GTF Timing Standard
+ *
+ * gcc gtf.c -o gtf -lm -Wall
+ *
+ * Copyright (c) 2001, Andy Ritger aritger@nvidia.com
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * o Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * o Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * o Neither the name of NVIDIA nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ *
+ * This program is based on the Generalized Timing Formula(GTF TM)
+ * Standard Version: 1.0, Revision: 1.0
+ *
+ * The GTF Document contains the following Copyright information:
+ *
+ * Copyright (c) 1994, 1995, 1996 - Video Electronics Standards
+ * Association. Duplication of this document within VESA member
+ * companies for review purposes is permitted. All other rights
+ * reserved.
+ *
+ * While every precaution has been taken in the preparation
+ * of this standard, the Video Electronics Standards Association and
+ * its contributors assume no responsibility for errors or omissions,
+ * and make no warranties, expressed or implied, of functionality
+ * of suitability for any purpose. The sample code contained within
+ * this standard may be used without restriction.
+ *
+ *
+ *
+ * The GTF EXCEL(TM) SPREADSHEET, a sample (and the definitive)
+ * implementation of the GTF Timing Standard, is available at:
+ *
+ * ftp://ftp.vesa.org/pub/GTF/GTF_V1R1.xls
+ *
+ *
+ *
+ * This program takes a desired resolution and vertical refresh rate,
+ * and computes mode timings according to the GTF Timing Standard.
+ * These mode timings can then be formatted as an XServer modeline
+ * or a mode description for use by fbset(8).
+ *
+ *
+ *
+ * NOTES:
+ *
+ * The GTF allows for computation of "margins" (the visible border
+ * surrounding the addressable video); on most non-overscan type
+ * systems, the margin period is zero. I've implemented the margin
+ * computations but not enabled it because 1) I don't really have
+ * any experience with this, and 2) neither XServer modelines nor
+ * fbset fb.modes provide an obvious way for margin timings to be
+ * included in their mode descriptions (needs more investigation).
+ *
+ * The GTF provides for computation of interlaced mode timings;
+ * I've implemented the computations but not enabled them, yet.
+ * I should probably enable and test this at some point.
+ *
+ *
+ *
+ * TODO:
+ *
+ * o Add support for interlaced modes.
+ *
+ * o Implement the other portions of the GTF: compute mode timings
+ * given either the desired pixel clock or the desired horizontal
+ * frequency.
+ *
+ * o It would be nice if this were more general purpose to do things
+ * outside the scope of the GTF: like generate double scan mode
+ * timings, for example.
+ *
+ * o Printing digits to the right of the decimal point when the
+ * digits are 0 annoys me.
+ *
+ * o Error checking.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+# include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#define MARGIN_PERCENT 1.8 /* % of active vertical image */
+#define CELL_GRAN 8.0 /* assumed character cell granularity */
+#define MIN_PORCH 1 /* minimum front porch */
+#define V_SYNC_RQD 3 /* width of vsync in lines */
+#define H_SYNC_PERCENT 8.0 /* width of hsync as % of total line */
+#define MIN_VSYNC_PLUS_BP 550.0 /* min time of vsync + back porch (microsec) */
+#define M 600.0 /* blanking formula gradient */
+#define C 40.0 /* blanking formula offset */
+#define K 128.0 /* blanking formula scaling factor */
+#define J 20.0 /* blanking formula scaling factor */
+
+/* C' and M' are part of the Blanking Duty Cycle computation */
+
+#define C_PRIME (((C - J) * K/256.0) + J)
+#define M_PRIME (K/256.0 * M)
+
+
+/* struct definitions */
+
+typedef struct __mode
+{
+ int hr, hss, hse, hfl;
+ int vr, vss, vse, vfl;
+ float pclk, h_freq, v_freq;
+} mode;
+
+
+typedef struct __options
+{
+ int x, y;
+ int xorgmode, fbmode;
+ float v_freq;
+} options;
+
+
+
+
+/* prototypes */
+
+void print_value(int n, char *name, float val);
+void print_xf86_mode (mode *m);
+void print_fb_mode (mode *m);
+mode *vert_refresh (int h_pixels, int v_lines, float freq,
+ int interlaced, int margins);
+options *parse_command_line (int argc, char *argv[]);
+
+
+
+
+/*
+ * print_value() - print the result of the named computation; this is
+ * useful when comparing against the GTF EXCEL spreadsheet.
+ */
+
+int global_verbose = 0;
+
+void print_value(int n, char *name, float val)
+{
+ if (global_verbose) {
+ printf("%2d: %-27s: %15f\n", n, name, val);
+ }
+}
+
+
+
+/* print_xf86_mode() - print the XServer modeline, given mode timings. */
+
+void print_xf86_mode (mode *m)
+{
+ printf ("\n");
+ printf (" # %dx%d @ %.2f Hz (GTF) hsync: %.2f kHz; pclk: %.2f MHz\n",
+ m->hr, m->vr, m->v_freq, m->h_freq, m->pclk);
+
+ printf (" Modeline \"%dx%d_%.2f\" %.2f"
+ " %d %d %d %d"
+ " %d %d %d %d"
+ " -HSync +Vsync\n\n",
+ m->hr, m->vr, m->v_freq, m->pclk,
+ m->hr, m->hss, m->hse, m->hfl,
+ m->vr, m->vss, m->vse, m->vfl);
+
+}
+
+
+
+/*
+ * print_fb_mode() - print a mode description in fbset(8) format;
+ * see the fb.modes(8) manpage. The timing description used in
+ * this is rather odd; they use "left and right margin" to refer
+ * to the portion of the hblank before and after the sync pulse
+ * by conceptually wrapping the portion of the blank after the pulse
+ * to infront of the visible region; ie:
+ *
+ *
+ * Timing description I'm accustomed to:
+ *
+ *
+ *
+ * <--------1--------> <--2--> <--3--> <--4-->
+ * _________
+ * |-------------------|_______| |_______
+ *
+ * R SS SE FL
+ *
+ * 1: visible image
+ * 2: blank before sync (aka front porch)
+ * 3: sync pulse
+ * 4: blank after sync (aka back porch)
+ * R: Resolution
+ * SS: Sync Start
+ * SE: Sync End
+ * FL: Frame Length
+ *
+ *
+ * But the fb.modes format is:
+ *
+ *
+ * <--4--> <--------1--------> <--2--> <--3-->
+ * _________
+ * _______|-------------------|_______| |
+ *
+ * The fb.modes(8) manpage refers to <4> and <2> as the left and
+ * right "margin" (as well as upper and lower margin in the vertical
+ * direction) -- note that this has nothing to do with the term
+ * "margin" used in the GTF Timing Standard.
+ *
+ * XXX always prints the 32 bit mode -- should I provide a command
+ * line option to specify the bpp? It's simple enough for a user
+ * to edit the mode description after it's generated.
+ */
+
+void print_fb_mode (mode *m)
+{
+ printf ("\n");
+ printf ("mode \"%dx%d %.2fHz 32bit (GTF)\"\n",
+ m->hr, m->vr, m->v_freq);
+ printf (" # PCLK: %.2f MHz, H: %.2f kHz, V: %.2f Hz\n",
+ m->pclk, m->h_freq, m->v_freq);
+ printf (" geometry %d %d %d %d 32\n",
+ m->hr, m->vr, m->hr, m->vr);
+ printf (" timings %d %d %d %d %d %d %d\n",
+ (int) rint(1000000.0/m->pclk),/* pixclock in picoseconds */
+ m->hfl - m->hse, /* left margin (in pixels) */
+ m->hss - m->hr, /* right margin (in pixels) */
+ m->vfl - m->vse, /* upper margin (in pixel lines) */
+ m->vss - m->vr, /* lower margin (in pixel lines) */
+ m->hse - m->hss, /* horizontal sync length (pixels) */
+ m->vse - m->vss); /* vert sync length (pixel lines) */
+ printf (" hsync low\n");
+ printf (" vsync high\n");
+ printf ("endmode\n\n");
+
+}
+
+
+
+
+/*
+ * vert_refresh() - as defined by the GTF Timing Standard, compute the
+ * Stage 1 Parameters using the vertical refresh frequency. In other
+ * words: input a desired resolution and desired refresh rate, and
+ * output the GTF mode timings.
+ *
+ * XXX All the code is in place to compute interlaced modes, but I don't
+ * feel like testing it right now.
+ *
+ * XXX margin computations are implemented but not tested (nor used by
+ * XServer of fbset mode descriptions, from what I can tell).
+ */
+
+mode *vert_refresh (int h_pixels, int v_lines, float freq,
+ int interlaced, int margins)
+{
+ float h_pixels_rnd;
+ float v_lines_rnd;
+ float v_field_rate_rqd;
+ float top_margin;
+ float bottom_margin;
+ float interlace;
+ float h_period_est;
+ float vsync_plus_bp;
+ float v_back_porch;
+ float total_v_lines;
+ float v_field_rate_est;
+ float h_period;
+ float v_field_rate;
+ float v_frame_rate;
+ float left_margin;
+ float right_margin;
+ float total_active_pixels;
+ float ideal_duty_cycle;
+ float h_blank;
+ float total_pixels;
+ float pixel_freq;
+ float h_freq;
+
+ float h_sync;
+ float h_front_porch;
+ float v_odd_front_porch_lines;
+
+ mode *m = (mode*) malloc (sizeof (mode));
+
+
+ /* 1. In order to give correct results, the number of horizontal
+ * pixels requested is first processed to ensure that it is divisible
+ * by the character size, by rounding it to the nearest character
+ * cell boundary:
+ *
+ * [H PIXELS RND] = ((ROUND([H PIXELS]/[CELL GRAN RND],0))*[CELLGRAN RND])
+ */
+
+ h_pixels_rnd = rint((float) h_pixels / CELL_GRAN) * CELL_GRAN;
+
+ print_value(1, "[H PIXELS RND]", h_pixels_rnd);
+
+
+ /* 2. If interlace is requested, the number of vertical lines assumed
+ * by the calculation must be halved, as the computation calculates
+ * the number of vertical lines per field. In either case, the
+ * number of lines is rounded to the nearest integer.
+ *
+ * [V LINES RND] = IF([INT RQD?]="y", ROUND([V LINES]/2,0),
+ * ROUND([V LINES],0))
+ */
+
+ v_lines_rnd = interlaced ?
+ rint((float) v_lines) / 2.0 :
+ rint((float) v_lines);
+
+ print_value(2, "[V LINES RND]", v_lines_rnd);
+
+
+ /* 3. Find the frame rate required:
+ *
+ * [V FIELD RATE RQD] = IF([INT RQD?]="y", [I/P FREQ RQD]*2,
+ * [I/P FREQ RQD])
+ */
+
+ v_field_rate_rqd = interlaced ? (freq * 2.0) : (freq);
+
+ print_value(3, "[V FIELD RATE RQD]", v_field_rate_rqd);
+
+
+ /* 4. Find number of lines in Top margin:
+ *
+ * [TOP MARGIN (LINES)] = IF([MARGINS RQD?]="Y",
+ * ROUND(([MARGIN%]/100*[V LINES RND]),0),
+ * 0)
+ */
+
+ top_margin = margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0);
+
+ print_value(4, "[TOP MARGIN (LINES)]", top_margin);
+
+
+ /* 5. Find number of lines in Bottom margin:
+ *
+ * [BOT MARGIN (LINES)] = IF([MARGINS RQD?]="Y",
+ * ROUND(([MARGIN%]/100*[V LINES RND]),0),
+ * 0)
+ */
+
+ bottom_margin = margins ? rint(MARGIN_PERCENT/100.0 * v_lines_rnd) : (0.0);
+
+ print_value(5, "[BOT MARGIN (LINES)]", bottom_margin);
+
+
+ /* 6. If interlace is required, then set variable [INTERLACE]=0.5:
+ *
+ * [INTERLACE]=(IF([INT RQD?]="y",0.5,0))
+ */
+
+ interlace = interlaced ? 0.5 : 0.0;
+
+ print_value(6, "[INTERLACE]", interlace);
+
+
+ /* 7. Estimate the Horizontal period
+ *
+ * [H PERIOD EST] = ((1/[V FIELD RATE RQD]) - [MIN VSYNC+BP]/1000000) /
+ * ([V LINES RND] + (2*[TOP MARGIN (LINES)]) +
+ * [MIN PORCH RND]+[INTERLACE]) * 1000000
+ */
+
+ h_period_est = (((1.0/v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP/1000000.0))
+ / (v_lines_rnd + (2*top_margin) + MIN_PORCH + interlace)
+ * 1000000.0);
+
+ print_value(7, "[H PERIOD EST]", h_period_est);
+
+
+ /* 8. Find the number of lines in V sync + back porch:
+ *
+ * [V SYNC+BP] = ROUND(([MIN VSYNC+BP]/[H PERIOD EST]),0)
+ */
+
+ vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP/h_period_est);
+
+ print_value(8, "[V SYNC+BP]", vsync_plus_bp);
+
+
+ /* 9. Find the number of lines in V back porch alone:
+ *
+ * [V BACK PORCH] = [V SYNC+BP] - [V SYNC RND]
+ *
+ * XXX is "[V SYNC RND]" a typo? should be [V SYNC RQD]?
+ */
+
+ v_back_porch = vsync_plus_bp - V_SYNC_RQD;
+
+ print_value(9, "[V BACK PORCH]", v_back_porch);
+
+
+ /* 10. Find the total number of lines in Vertical field period:
+ *
+ * [TOTAL V LINES] = [V LINES RND] + [TOP MARGIN (LINES)] +
+ * [BOT MARGIN (LINES)] + [V SYNC+BP] + [INTERLACE] +
+ * [MIN PORCH RND]
+ */
+
+ total_v_lines = v_lines_rnd + top_margin + bottom_margin + vsync_plus_bp +
+ interlace + MIN_PORCH;
+
+ print_value(10, "[TOTAL V LINES]", total_v_lines);
+
+
+ /* 11. Estimate the Vertical field frequency:
+ *
+ * [V FIELD RATE EST] = 1 / [H PERIOD EST] / [TOTAL V LINES] * 1000000
+ */
+
+ v_field_rate_est = 1.0 / h_period_est / total_v_lines * 1000000.0;
+
+ print_value(11, "[V FIELD RATE EST]", v_field_rate_est);
+
+
+ /* 12. Find the actual horizontal period:
+ *
+ * [H PERIOD] = [H PERIOD EST] / ([V FIELD RATE RQD] / [V FIELD RATE EST])
+ */
+
+ h_period = h_period_est / (v_field_rate_rqd / v_field_rate_est);
+
+ print_value(12, "[H PERIOD]", h_period);
+
+
+ /* 13. Find the actual Vertical field frequency:
+ *
+ * [V FIELD RATE] = 1 / [H PERIOD] / [TOTAL V LINES] * 1000000
+ */
+
+ v_field_rate = 1.0 / h_period / total_v_lines * 1000000.0;
+
+ print_value(13, "[V FIELD RATE]", v_field_rate);
+
+
+ /* 14. Find the Vertical frame frequency:
+ *
+ * [V FRAME RATE] = (IF([INT RQD?]="y", [V FIELD RATE]/2, [V FIELD RATE]))
+ */
+
+ v_frame_rate = interlaced ? v_field_rate / 2.0 : v_field_rate;
+
+ print_value(14, "[V FRAME RATE]", v_frame_rate);
+
+
+ /* 15. Find number of pixels in left margin:
+ *
+ * [LEFT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y",
+ * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 /
+ * [CELL GRAN RND]),0)) * [CELL GRAN RND],
+ * 0))
+ */
+
+ left_margin = margins ?
+ rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
+ 0.0;
+
+ print_value(15, "[LEFT MARGIN (PIXELS)]", left_margin);
+
+
+ /* 16. Find number of pixels in right margin:
+ *
+ * [RIGHT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y",
+ * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 /
+ * [CELL GRAN RND]),0)) * [CELL GRAN RND],
+ * 0))
+ */
+
+ right_margin = margins ?
+ rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
+ 0.0;
+
+ print_value(16, "[RIGHT MARGIN (PIXELS)]", right_margin);
+
+
+ /* 17. Find total number of active pixels in image and left and right
+ * margins:
+ *
+ * [TOTAL ACTIVE PIXELS] = [H PIXELS RND] + [LEFT MARGIN (PIXELS)] +
+ * [RIGHT MARGIN (PIXELS)]
+ */
+
+ total_active_pixels = h_pixels_rnd + left_margin + right_margin;
+
+ print_value(17, "[TOTAL ACTIVE PIXELS]", total_active_pixels);
+
+
+ /* 18. Find the ideal blanking duty cycle from the blanking duty cycle
+ * equation:
+ *
+ * [IDEAL DUTY CYCLE] = [C'] - ([M']*[H PERIOD]/1000)
+ */
+
+ ideal_duty_cycle = C_PRIME - (M_PRIME * h_period / 1000.0);
+
+ print_value(18, "[IDEAL DUTY CYCLE]", ideal_duty_cycle);
+
+
+ /* 19. Find the number of pixels in the blanking time to the nearest
+ * double character cell:
+ *
+ * [H BLANK (PIXELS)] = (ROUND(([TOTAL ACTIVE PIXELS] *
+ * [IDEAL DUTY CYCLE] /
+ * (100-[IDEAL DUTY CYCLE]) /
+ * (2*[CELL GRAN RND])), 0))
+ * * (2*[CELL GRAN RND])
+ */
+
+ h_blank = rint(total_active_pixels *
+ ideal_duty_cycle /
+ (100.0 - ideal_duty_cycle) /
+ (2.0 * CELL_GRAN)) * (2.0 * CELL_GRAN);
+
+ print_value(19, "[H BLANK (PIXELS)]", h_blank);
+
+
+ /* 20. Find total number of pixels:
+ *
+ * [TOTAL PIXELS] = [TOTAL ACTIVE PIXELS] + [H BLANK (PIXELS)]
+ */
+
+ total_pixels = total_active_pixels + h_blank;
+
+ print_value(20, "[TOTAL PIXELS]", total_pixels);
+
+
+ /* 21. Find pixel clock frequency:
+ *
+ * [PIXEL FREQ] = [TOTAL PIXELS] / [H PERIOD]
+ */
+
+ pixel_freq = total_pixels / h_period;
+
+ print_value(21, "[PIXEL FREQ]", pixel_freq);
+
+
+ /* 22. Find horizontal frequency:
+ *
+ * [H FREQ] = 1000 / [H PERIOD]
+ */
+
+ h_freq = 1000.0 / h_period;
+
+ print_value(22, "[H FREQ]", h_freq);
+
+
+
+ /* Stage 1 computations are now complete; I should really pass
+ the results to another function and do the Stage 2
+ computations, but I only need a few more values so I'll just
+ append the computations here for now */
+
+
+
+ /* 17. Find the number of pixels in the horizontal sync period:
+ *
+ * [H SYNC (PIXELS)] =(ROUND(([H SYNC%] / 100 * [TOTAL PIXELS] /
+ * [CELL GRAN RND]),0))*[CELL GRAN RND]
+ */
+
+ h_sync = rint(H_SYNC_PERCENT/100.0 * total_pixels / CELL_GRAN) * CELL_GRAN;
+
+ print_value(17, "[H SYNC (PIXELS)]", h_sync);
+
+
+ /* 18. Find the number of pixels in the horizontal front porch period:
+ *
+ * [H FRONT PORCH (PIXELS)] = ([H BLANK (PIXELS)]/2)-[H SYNC (PIXELS)]
+ */
+
+ h_front_porch = (h_blank / 2.0) - h_sync;
+
+ print_value(18, "[H FRONT PORCH (PIXELS)]", h_front_porch);
+
+
+ /* 36. Find the number of lines in the odd front porch period:
+ *
+ * [V ODD FRONT PORCH(LINES)]=([MIN PORCH RND]+[INTERLACE])
+ */
+
+ v_odd_front_porch_lines = MIN_PORCH + interlace;
+
+ print_value(36, "[V ODD FRONT PORCH(LINES)]", v_odd_front_porch_lines);
+
+
+ /* finally, pack the results in the mode struct */
+
+ m->hr = (int) (h_pixels_rnd);
+ m->hss = (int) (h_pixels_rnd + h_front_porch);
+ m->hse = (int) (h_pixels_rnd + h_front_porch + h_sync);
+ m->hfl = (int) (total_pixels);
+
+ m->vr = (int) (v_lines_rnd);
+ m->vss = (int) (v_lines_rnd + v_odd_front_porch_lines);
+ m->vse = (int) (int) (v_lines_rnd + v_odd_front_porch_lines + V_SYNC_RQD);
+ m->vfl = (int) (total_v_lines);
+
+ m->pclk = pixel_freq;
+ m->h_freq = h_freq;
+ m->v_freq = freq;
+
+ return m;
+
+}
+
+
+
+
+/*
+ * parse_command_line() - parse the command line and return an
+ * alloced structure containing the results. On error print usage
+ * and return NULL.
+ */
+
+options *parse_command_line (int argc, char *argv[])
+{
+ int n;
+
+ options *o = (options *) calloc (1, sizeof (options));
+
+ if (argc < 4) goto bad_option;
+
+ o->x = atoi (argv[1]);
+ o->y = atoi (argv[2]);
+ o->v_freq = atof (argv[3]);
+
+ /* XXX should check for errors in the above */
+
+ n = 4;
+
+ while (n < argc) {
+ if ((strcmp (argv[n], "-v") == 0) ||
+ (strcmp (argv[n], "--verbose") == 0)) {
+ global_verbose = 1;
+ } else if ((strcmp (argv[n], "-f") == 0) ||
+ (strcmp (argv[n], "--fbmode") == 0)) {
+ o->fbmode = 1;
+ } else if ((strcmp (argv[n], "-x") == 0) ||
+ (strcmp (argv[n], "--xorgmode") == 0) ||
+ (strcmp (argv[n], "--xf86mode") == 0)) {
+ o->xorgmode = 1;
+ } else {
+ goto bad_option;
+ }
+
+ n++;
+ }
+
+ /* if neither xorgmode nor fbmode were requested, default to
+ xorgmode */
+
+ if (!o->fbmode && !o->xorgmode) o->xorgmode = 1;
+
+ return o;
+
+ bad_option:
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "usage: %s x y refresh [-v|--verbose] "
+ "[-f|--fbmode] [-x|--xorgmode]\n", argv[0]);
+
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, " x : the desired horizontal "
+ "resolution (required)\n");
+ fprintf (stderr, " y : the desired vertical "
+ "resolution (required)\n");
+ fprintf (stderr, " refresh : the desired refresh "
+ "rate (required)\n");
+ fprintf (stderr, " -v|--verbose : enable verbose printouts "
+ "(traces each step of the computation)\n");
+ fprintf (stderr, " -f|--fbmode : output an fbset(8)-style mode "
+ "description\n");
+ fprintf (stderr, " -x|--xorgmode : output an "__XSERVERNAME__"-style mode "
+ "description (this is the default\n"
+ " if no mode description is requested)\n");
+
+ fprintf (stderr, "\n");
+
+ free (o);
+ return NULL;
+
+}
+
+
+
+int main (int argc, char *argv[])
+{
+ mode *m;
+ options *o;
+
+ o = parse_command_line (argc, argv);
+ if (!o) exit (1);
+
+ m = vert_refresh (o->x, o->y, o->v_freq, 0, 0);
+ if (!m) exit (1);
+
+ if (o->xorgmode)
+ print_xf86_mode(m);
+
+ if (o->fbmode)
+ print_fb_mode(m);
+
+ return 0;
+
+}
diff --git a/xorg-server/hw/xfree86/vbe/vbe.c b/xorg-server/hw/xfree86/vbe/vbe.c index 21fe0c812..11b1f25eb 100644 --- a/xorg-server/hw/xfree86/vbe/vbe.c +++ b/xorg-server/hw/xfree86/vbe/vbe.c @@ -345,7 +345,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe) char *str;
CARD16 major, *modes;
- bzero(pVbe->memory, sizeof(VbeInfoBlock));
+ memset(pVbe->memory, 0, sizeof(VbeInfoBlock));
/*
Input:
@@ -370,7 +370,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe) xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (NULL);
+ return NULL;
block = calloc(sizeof(VbeInfoBlock), 1);
block->VESASignature[0] = ((char*)pVbe->memory)[0];
@@ -418,7 +418,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe) memcpy(&block->OemData, ((char*)pVbe->memory) + 256, 256);
}
- return (block);
+ return block;
}
void
@@ -493,10 +493,10 @@ VBEGetVBEMode(vbeInfoPtr pVbe, int *mode) if (R16(pVbe->pInt10->ax) == 0x4f) {
*mode = R16(pVbe->pInt10->bx);
- return (TRUE);
+ return TRUE;
}
- return (FALSE);
+ return FALSE;
}
VbeModeInfoBlock *
@@ -504,7 +504,7 @@ VBEGetModeInfo(vbeInfoPtr pVbe, int mode) {
VbeModeInfoBlock *block = NULL;
- bzero(pVbe->memory, sizeof(VbeModeInfoBlock));
+ memset(pVbe->memory, 0, sizeof(VbeModeInfoBlock));
/*
Input:
@@ -525,7 +525,7 @@ VBEGetModeInfo(vbeInfoPtr pVbe, int mode) pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (NULL);
+ return NULL;
block = calloc(sizeof(VbeModeInfoBlock), 1);
@@ -591,7 +591,7 @@ VBEGetModeInfo(vbeInfoPtr pVbe, int mode) else
memcpy(&block->PhysBasePtr, ((char*)pVbe->memory) + 40, 216);
- return (block);
+ return block;
}
void
@@ -657,7 +657,7 @@ VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function, pVbe->pInt10->cx = 0x000f;
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (FALSE);
+ return FALSE;
if (function == MODE_SAVE) {
int npages = (R16(pVbe->pInt10->bx) * 64) / 4096 + 1;
@@ -665,7 +665,7 @@ VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function, real_mode_pages)) == NULL) {
xf86DrvMsg(screen, X_ERROR,
"Cannot allocate memory to save SVGA state.\n");
- return (FALSE);
+ return FALSE;
}
}
*size = pVbe->pInt10->bx * 64;
@@ -716,9 +716,9 @@ VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window) xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (FALSE);
+ return FALSE;
- return (TRUE);
+ return TRUE;
}
Bool
@@ -726,7 +726,7 @@ VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command, int width, int *pixels, int *bytes, int *max)
{
if (command < SCANWID_SET || command > SCANWID_GET_MAX)
- return (FALSE);
+ return FALSE;
/*
Input:
@@ -755,7 +755,7 @@ VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command, xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (FALSE);
+ return FALSE;
if (command == SCANWID_GET || command == SCANWID_GET_MAX) {
if (pixels)
@@ -766,7 +766,7 @@ VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command, *max = R16(pVbe->pInt10->dx);
}
- return (TRUE);
+ return TRUE;
}
Bool
@@ -780,9 +780,9 @@ VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace) xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (FALSE);
+ return FALSE;
- return (TRUE);
+ return TRUE;
}
Bool
@@ -794,12 +794,12 @@ VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y) xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (FALSE);
+ return FALSE;
*x = pVbe->pInt10->cx;
*y = pVbe->pInt10->dx;
- return (TRUE);
+ return TRUE;
}
int
@@ -827,7 +827,7 @@ VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits) xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (0);
+ return 0;
return (bits != 0 ? bits : (pVbe->pInt10->bx >> 8) & 0x00ff);
}
@@ -878,15 +878,15 @@ VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num, xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (NULL);
+ return NULL;
if (set)
- return (data);
+ return data;
data = malloc(num * sizeof(CARD32));
memcpy(data, pVbe->memory, num * sizeof(CARD32));
- return (data);
+ return data;
}
VBEpmi *
@@ -915,14 +915,14 @@ VBEGetVBEpmi(vbeInfoPtr pVbe) xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (NULL);
+ return NULL;
pmi = malloc(sizeof(VBEpmi));
pmi->seg_tbl = R16(pVbe->pInt10->es);
pmi->tbl_off = R16(pVbe->pInt10->di);
pmi->tbl_len = R16(pVbe->pInt10->cx);
- return (pmi);
+ return pmi;
}
#if 0
@@ -1034,9 +1034,9 @@ VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock) xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (0);
+ return 0;
- return (pVbe->pInt10->cx);
+ return pVbe->pInt10->cx;
}
Bool
diff --git a/xorg-server/hw/xfree86/vgahw/vgaCmap.c b/xorg-server/hw/xfree86/vgahw/vgaCmap.c index e337b42c0..a65bb5e86 100644 --- a/xorg-server/hw/xfree86/vgahw/vgaCmap.c +++ b/xorg-server/hw/xfree86/vgahw/vgaCmap.c @@ -51,7 +51,7 @@ vgaListInstalledColormaps(pScreen, pmaps) * is always a colormap installed */
*pmaps = GetInstalledmiColormap(pScreen)->mid;
- return(1);
+ return 1;
}
int
@@ -63,7 +63,7 @@ vgaGetInstalledColormaps(pScreen, pmaps) * is always a colormap installed */
*pmaps = GetInstalledmiColormap(pScreen);
- return(1);
+ return 1;
}
int vgaCheckColorMap(ColormapPtr pmap)
diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.c b/xorg-server/hw/xfree86/vgahw/vgaHW.c index 396a3cc62..7b1c95e62 100644 --- a/xorg-server/hw/xfree86/vgahw/vgaHW.c +++ b/xorg-server/hw/xfree86/vgahw/vgaHW.c @@ -658,7 +658,7 @@ vgaHWSaveScreen(ScreenPtr pScreen, int mode) if ((pScrn != NULL) && pScrn->vtSema) {
vgaHWBlankScreen(pScrn, on);
}
- return (TRUE);
+ return TRUE;
}
@@ -1351,7 +1351,7 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode) regp->Attribute[19] = 0x00;
regp->Attribute[20] = 0x00;
- return(TRUE);
+ return TRUE;
}
/*
@@ -1479,8 +1479,7 @@ vgaHWGetHWRecPrivate(void) static void
vgaHWFreeRegs(vgaRegPtr regp)
{
- if (regp->CRTC)
- free(regp->CRTC);
+ free(regp->CRTC);
regp->CRTC =
regp->Sequencer =
diff --git a/xorg-server/hw/xfree86/xaa/xaaBitBlt.c b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c index b1fda1cd6..cc7e810ca 100644 --- a/xorg-server/hw/xfree86/xaa/xaaBitBlt.c +++ b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c @@ -118,8 +118,8 @@ XAABitBlt( fastExpose = 0;
}
} else {
- REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
- REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
+ RegionInit(&rgnDst, &fastBox, 1);
+ RegionIntersect(&rgnDst, &rgnDst, prgnSrcClip);
}
dstx += pDstDrawable->x;
@@ -128,9 +128,9 @@ XAABitBlt( if (pDstDrawable->type == DRAWABLE_WINDOW) {
if (!((WindowPtr)pDstDrawable)->realized) {
if (!fastClip)
- REGION_UNINIT(pGC->pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if (freeSrcClip)
- REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ RegionDestroy(prgnSrcClip);
return NULL;
}
}
@@ -153,8 +153,8 @@ XAABitBlt( blown region and call intersect */
cclip = pGC->pCompositeClip;
- if (REGION_NUM_RECTS(cclip) == 1) {
- BoxPtr pBox = REGION_RECTS(cclip);
+ if (RegionNumRects(cclip) == 1) {
+ BoxPtr pBox = RegionRects(cclip);
if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;
if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;
@@ -163,37 +163,37 @@ XAABitBlt( /* Check to see if the region is empty */
if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) {
- REGION_NULL(pGC->pScreen, &rgnDst);
+ RegionNull(&rgnDst);
} else {
- REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ RegionInit(&rgnDst, &fastBox, 1);
}
} else {
/* We must turn off fastClip now, since we must create
a full blown region. It is intersected with the
composite clip below. */
fastClip = 0;
- REGION_INIT(pGC->pScreen, &rgnDst, &fastBox,1);
+ RegionInit(&rgnDst, &fastBox,1);
}
} else {
- REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+ RegionTranslate(&rgnDst, -dx, -dy);
}
if (!fastClip) {
- REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst,
+ RegionIntersect(&rgnDst, &rgnDst,
pGC->pCompositeClip);
}
/* Do bit blitting */
- numRects = REGION_NUM_RECTS(&rgnDst);
+ numRects = RegionNumRects(&rgnDst);
if (numRects && width && height) {
if(!(pptSrc = (DDXPointPtr)malloc(numRects *
sizeof(DDXPointRec)))) {
- REGION_UNINIT(pGC->pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if (freeSrcClip)
- REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ RegionDestroy(prgnSrcClip);
return NULL;
}
- pbox = REGION_RECTS(&rgnDst);
+ pbox = RegionRects(&rgnDst);
ppt = pptSrc;
for (i = numRects; --i >= 0; pbox++, ppt++) {
ppt->x = pbox->x1 + dx;
@@ -214,8 +214,8 @@ XAABitBlt( (int)origSource.height,
origDest.x, origDest.y, bitPlane);
}
- REGION_UNINIT(pGC->pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if (freeSrcClip)
- REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ RegionDestroy(prgnSrcClip);
return prgnExposed;
}
diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyArea.c b/xorg-server/hw/xfree86/xaa/xaaCpyArea.c index eefd8d38d..5e594633d 100644 --- a/xorg-server/hw/xfree86/xaa/xaaCpyArea.c +++ b/xorg-server/hw/xfree86/xaa/xaaCpyArea.c @@ -95,8 +95,8 @@ XAADoBitBlt( ((pSrc->type == DRAWABLE_WINDOW) &&
(pDst->type == DRAWABLE_WINDOW)));
- pbox = REGION_RECTS(prgnDst);
- nbox = REGION_NUM_RECTS(prgnDst);
+ pbox = RegionRects(prgnDst);
+ nbox = RegionNumRects(prgnDst);
pboxNew1 = NULL;
pptNew1 = NULL;
@@ -148,8 +148,8 @@ XAADoBitBlt( pboxNew2 = (BoxPtr)malloc(sizeof(BoxRec) * nbox);
pptNew2 = (DDXPointPtr)malloc(sizeof(DDXPointRec) * nbox);
if(!pboxNew2 || !pptNew2) {
- if (pptNew2) free(pptNew2);
- if (pboxNew2) free(pboxNew2);
+ free(pptNew2);
+ free(pboxNew2);
if (pboxNew1) {
free(pptNew1);
free(pboxNew1);
@@ -204,8 +204,8 @@ XAADoImageWrite( int srcwidth;
unsigned char* psrcBase; /* start of image */
unsigned char* srcPntr; /* index into the image */
- BoxPtr pbox = REGION_RECTS(prgnDst);
- int nbox = REGION_NUM_RECTS(prgnDst);
+ BoxPtr pbox = RegionRects(prgnDst);
+ int nbox = RegionNumRects(prgnDst);
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
int Bpp = pSrc->bitsPerPixel >> 3;
@@ -233,8 +233,8 @@ XAADoImageRead( int dstwidth;
unsigned char* pdstBase; /* start of image */
unsigned char* dstPntr; /* index into the image */
- BoxPtr pbox = REGION_RECTS(prgnDst);
- int nbox = REGION_NUM_RECTS(prgnDst);
+ BoxPtr pbox = RegionRects(prgnDst);
+ int nbox = RegionNumRects(prgnDst);
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
int Bpp = pSrc->bitsPerPixel >> 3; /* wouldn't get here unless both
src and dst have same bpp */
diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c b/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c index 358cb6fb2..2d036c936 100644 --- a/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c +++ b/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c @@ -76,8 +76,8 @@ XAACopyPlane1toNColorExpand( DDXPointPtr pptSrc )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- BoxPtr pbox = REGION_RECTS(rgnDst);
- int numrects = REGION_NUM_RECTS(rgnDst);
+ BoxPtr pbox = RegionRects(rgnDst);
+ int numrects = RegionNumRects(rgnDst);
unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
int srcwidth = ((PixmapPtr)pSrc)->devKind;
@@ -101,8 +101,8 @@ XAACopyPlaneNtoNColorExpand( DDXPointPtr pptSrc
){
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- BoxPtr pbox = REGION_RECTS(rgnDst);
- int numrects = REGION_NUM_RECTS(rgnDst);
+ BoxPtr pbox = RegionRects(rgnDst);
+ int numrects = RegionNumRects(rgnDst);
unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
unsigned char *data, *srcPtr, *dataPtr;
int srcwidth = ((PixmapPtr)pSrc)->devKind;
@@ -168,14 +168,14 @@ XAAPushPixelsSolidColorExpansion( int xOrg, int yOrg )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip);
+ int MaxBoxes = RegionNumRects(pGC->pCompositeClip);
BoxPtr pbox, pClipBoxes;
int nboxes, srcx, srcy;
xRectangle TheRect;
unsigned char *src = pBitMap->devPrivate.ptr;
int srcwidth = pBitMap->devKind;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
TheRect.x = xOrg;
diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyWin.c b/xorg-server/hw/xfree86/xaa/xaaCpyWin.c index 34f460f24..d8608b095 100644 --- a/xorg-server/hw/xfree86/xaa/xaaCpyWin.c +++ b/xorg-server/hw/xfree86/xaa/xaaCpyWin.c @@ -47,20 +47,20 @@ XAACopyWindow( return;
}
- pwinRoot = WindowTable[pScreen->myNum];
+ pwinRoot = pScreen->root;
- REGION_NULL(pScreen, &rgnDst);
+ RegionNull(&rgnDst);
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
- REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
- REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
- pbox = REGION_RECTS(&rgnDst);
- nbox = REGION_NUM_RECTS(&rgnDst);
+ pbox = RegionRects(&rgnDst);
+ nbox = RegionNumRects(&rgnDst);
if(!nbox ||
!(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
return;
}
ppt = pptSrc;
@@ -78,5 +78,5 @@ XAACopyWindow( &(infoRec->ScratchGC), &rgnDst, pptSrc);
free(pptSrc);
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
}
diff --git a/xorg-server/hw/xfree86/xaa/xaaDashLine.c b/xorg-server/hw/xfree86/xaa/xaaDashLine.c index 63233e05d..adae2e583 100644 --- a/xorg-server/hw/xfree86/xaa/xaaDashLine.c +++ b/xorg-server/hw/xfree86/xaa/xaaDashLine.c @@ -1,334 +1,334 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdlib.h> - -#include <X11/X.h> -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "miline.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" - - -void -#ifdef POLYSEGMENT -XAAPolySegmentDashed( - DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pSeg -#else -XAAPolyLinesDashed( - DrawablePtr pDrawable, - GCPtr pGC, - int mode, /* Origin or Previous */ - int npt, /* number of points */ - DDXPointPtr pptInit -#endif -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, - XAAGetGCKey()); - BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip); - int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip); - unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); - int xorg = pDrawable->x; - int yorg = pDrawable->y; - int nbox; - BoxPtr pbox; -#ifndef POLYSEGMENT - DDXPointPtr ppt; -#endif - unsigned int oc1, oc2; - int dmin, dmaj, e, octant; - int x1, x2, y1, y2, tmp, len, offset; - int PatternLength, PatternOffset; - - if(!nboxInit) - return; - - if (infoRec->DashedLineFlags & LINE_LIMIT_COORDS) { - int minValX = infoRec->DashedLineLimits.x1; - int maxValX = infoRec->DashedLineLimits.x2; - int minValY = infoRec->DashedLineLimits.y1; - int maxValY = infoRec->DashedLineLimits.y2; -#ifdef POLYSEGMENT - int n = nseg; - xSegment *s = pSeg; - - while (n--) -#else - int n = npt; - int xorgtmp = xorg; - int yorgtmp = yorg; - - ppt = pptInit; - x2 = ppt->x + xorgtmp; - y2 = ppt->y + yorgtmp; - while (--n) -#endif - { -#ifdef POLYSEGMENT - x1 = s->x1 + xorg; - y1 = s->y1 + yorg; - x2 = s->x2 + xorg; - y2 = s->y2 + yorg; - s++; -#else - x1 = x2; - y1 = y2; - ++ppt; - if (mode == CoordModePrevious) { - xorgtmp = x1; - yorgtmp = y1; - } - x2 = ppt->x + xorgtmp; - y2 = ppt->y + yorgtmp; -#endif - if (x1 > maxValX || x1 < minValX || - x2 > maxValX || x2 < minValX || - y1 > maxValY || y1 < minValY || - y2 > maxValY || y2 < minValY) { -#ifdef POLYSEGMENT - XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg); -#else - XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit); -#endif - return; - } - } - } - - PatternLength = pGCPriv->DashLength; - PatternOffset = pGC->dashOffset % PatternLength; - - (*infoRec->SetupForDashedLine)(infoRec->pScrn, pGC->fgPixel, - (pGC->lineStyle == LineDoubleDash) ? pGC->bgPixel : -1, - pGC->alu, pGC->planemask, PatternLength, pGCPriv->DashPattern); - - -#ifdef POLYSEGMENT - while (nseg--) -#else - ppt = pptInit; - x2 = ppt->x + xorg; - y2 = ppt->y + yorg; - while(--npt) -#endif - { - nbox = nboxInit; - pbox = pboxInit; - -#ifdef POLYSEGMENT - x1 = pSeg->x1 + xorg; - y1 = pSeg->y1 + yorg; - x2 = pSeg->x2 + xorg; - y2 = pSeg->y2 + yorg; - pSeg++; -#else - x1 = x2; - y1 = y2; - ++ppt; - if (mode == CoordModePrevious) { - xorg = x1; - yorg = y1; - } - x2 = ppt->x + xorg; - y2 = ppt->y + yorg; -#endif - - - if (infoRec->SubsequentDashedBresenhamLine) { - if((dmaj = x2 - x1) < 0) { - dmaj = -dmaj; - octant = XDECREASING; - } else octant = 0; - - if((dmin = y2 - y1) < 0) { - dmin = -dmin; - octant |= YDECREASING; - } - - if(dmin >= dmaj){ - tmp = dmin; dmin = dmaj; dmaj = tmp; - octant |= YMAJOR; - } - - e = -dmaj - ((bias >> octant) & 1); - len = dmaj; - dmin <<= 1; - dmaj <<= 1; - } else { /* Muffle compiler */ - dmin = dmaj = e = octant = len = 0; - } - - while(nbox--) { - oc1 = oc2 = 0; - OUTCODES(oc1, x1, y1, pbox); - OUTCODES(oc2, x2, y2, pbox); - if (!(oc1 | oc2)) { /* uncliped */ - if(infoRec->SubsequentDashedTwoPointLine) { - (*infoRec->SubsequentDashedTwoPointLine)( - infoRec->pScrn, x1, y1, x2, y2, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? 0 : -#endif - OMIT_LAST, PatternOffset); - } else { - (*infoRec->SubsequentDashedBresenhamLine)( - infoRec->pScrn, x1, y1, dmaj, dmin, e, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? (len+1) : -#endif - len, octant, PatternOffset); - } - break; - } else if (oc1 & oc2) { /* completely clipped */ - pbox++; - } else if (infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE) { - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1); - - if(infoRec->SubsequentDashedBresenhamLine) { - (*infoRec->SubsequentDashedBresenhamLine)( - infoRec->pScrn, x1, y1, dmaj, dmin, e, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? (len+1) : -#endif - len, octant, PatternOffset); - } else { - (*infoRec->SubsequentDashedTwoPointLine)( - infoRec->pScrn, x1, y1, x2, y2, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? 0 : -#endif - OMIT_LAST, PatternOffset - ); - } - (*infoRec->DisableClipping)(infoRec->pScrn); - pbox++; - } else { - int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; - int clip1 = 0, clip2 = 0; - int err, adx, ady; - - if(octant & YMAJOR) { - ady = dmaj >> 1; - adx = dmin >> 1; - } else { - ady = dmin >> 1; - adx = dmaj >> 1; - } - - if (miZeroClipLine(pbox->x1, pbox->y1, - pbox->x2 - 1, pbox->y2 - 1, - &new_x1, &new_y1, &new_x2, &new_y2, - adx, ady, &clip1, &clip2, - octant, bias, oc1, oc2) == -1) - { - pbox++; - continue; - } - - if (octant & YMAJOR) - len = abs(new_y2 - new_y1); - else - len = abs(new_x2 - new_x1); -#ifdef POLYSEGMENT - if (clip2 != 0 || pGC->capStyle != CapNotLast) - len++; -#else - len += (clip2 != 0); -#endif - if (len) { - int abserr, clipdx, clipdy; - /* unwind bresenham error term to first point */ - if (clip1) { - clipdx = abs(new_x1 - x1); - clipdy = abs(new_y1 - y1); - - if (octant & YMAJOR) - err = e + clipdy*dmin - clipdx*dmaj; - else - err = e + clipdx*dmin - clipdy*dmaj; - } else - err = e; - -#define range infoRec->DashedBresenhamLineErrorTermBits - abserr = abs(err); - while((abserr & range) || - (dmaj & range) || - (dmin & range)) { - dmin >>= 1; - dmaj >>= 1; - abserr >>= 1; - err /= 2; - } - - if(octant & YMAJOR) - offset = abs(new_y1 - y1); - else - offset = abs(new_x1 - x1); - - offset += PatternOffset; - offset %= PatternLength; - - (*infoRec->SubsequentDashedBresenhamLine)( - infoRec->pScrn, new_x1, new_y1, - dmaj, dmin, err, len, octant, offset); - } - pbox++; - } - } /* while (nbox--) */ -#ifndef POLYSEGMENT - len = abs(y2 - y1); - tmp = abs(x2 - x1); - PatternOffset += (len > tmp) ? len : tmp; - PatternOffset %= PatternLength; -#endif - } /* while (nline--) */ - -#ifndef POLYSEGMENT - /* paint the last point if the end style isn't CapNotLast. - (Assume that a projecting, butt, or round cap that is one - pixel wide is the same as the single pixel of the endpoint.) - */ - - if ((pGC->capStyle != CapNotLast) && - ((ppt->x + xorg != pptInit->x + pDrawable->x) || - (ppt->y + yorg != pptInit->y + pDrawable->y) || - (ppt == pptInit + 1))) - { - nbox = nboxInit; - pbox = pboxInit; - while (nbox--) { - if ((x2 >= pbox->x1) && (y2 >= pbox->y1) && - (x2 < pbox->x2) && (y2 < pbox->y2)) - { - if(infoRec->SubsequentDashedTwoPointLine) { - (*infoRec->SubsequentDashedTwoPointLine)( - infoRec->pScrn, x2, y2, x2, y2, 0, - PatternOffset); - } else { - (*infoRec->SubsequentDashedBresenhamLine)( - infoRec->pScrn, x2, y2, 2, 0, -1, - 1, 0, PatternOffset); - } - break; - } else - pbox++; - } - } -#endif - - SET_SYNC_FLAG(infoRec); -} - +
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <X11/X.h>
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "miline.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+
+void
+#ifdef POLYSEGMENT
+XAAPolySegmentDashed(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg
+#else
+XAAPolyLinesDashed(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode, /* Origin or Previous */
+ int npt, /* number of points */
+ DDXPointPtr pptInit
+#endif
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
+ BoxPtr pboxInit = RegionRects(pGC->pCompositeClip);
+ int nboxInit = RegionNumRects(pGC->pCompositeClip);
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int xorg = pDrawable->x;
+ int yorg = pDrawable->y;
+ int nbox;
+ BoxPtr pbox;
+#ifndef POLYSEGMENT
+ DDXPointPtr ppt;
+#endif
+ unsigned int oc1, oc2;
+ int dmin, dmaj, e, octant;
+ int x1, x2, y1, y2, tmp, len, offset;
+ int PatternLength, PatternOffset;
+
+ if(!nboxInit)
+ return;
+
+ if (infoRec->DashedLineFlags & LINE_LIMIT_COORDS) {
+ int minValX = infoRec->DashedLineLimits.x1;
+ int maxValX = infoRec->DashedLineLimits.x2;
+ int minValY = infoRec->DashedLineLimits.y1;
+ int maxValY = infoRec->DashedLineLimits.y2;
+#ifdef POLYSEGMENT
+ int n = nseg;
+ xSegment *s = pSeg;
+
+ while (n--)
+#else
+ int n = npt;
+ int xorgtmp = xorg;
+ int yorgtmp = yorg;
+
+ ppt = pptInit;
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+ while (--n)
+#endif
+ {
+#ifdef POLYSEGMENT
+ x1 = s->x1 + xorg;
+ y1 = s->y1 + yorg;
+ x2 = s->x2 + xorg;
+ y2 = s->y2 + yorg;
+ s++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorgtmp = x1;
+ yorgtmp = y1;
+ }
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+#endif
+ if (x1 > maxValX || x1 < minValX ||
+ x2 > maxValX || x2 < minValX ||
+ y1 > maxValY || y1 < minValY ||
+ y2 > maxValY || y2 < minValY) {
+#ifdef POLYSEGMENT
+ XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg);
+#else
+ XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit);
+#endif
+ return;
+ }
+ }
+ }
+
+ PatternLength = pGCPriv->DashLength;
+ PatternOffset = pGC->dashOffset % PatternLength;
+
+ (*infoRec->SetupForDashedLine)(infoRec->pScrn, pGC->fgPixel,
+ (pGC->lineStyle == LineDoubleDash) ? pGC->bgPixel : -1,
+ pGC->alu, pGC->planemask, PatternLength, pGCPriv->DashPattern);
+
+
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+
+ if (infoRec->SubsequentDashedBresenhamLine) {
+ if((dmaj = x2 - x1) < 0) {
+ dmaj = -dmaj;
+ octant = XDECREASING;
+ } else octant = 0;
+
+ if((dmin = y2 - y1) < 0) {
+ dmin = -dmin;
+ octant |= YDECREASING;
+ }
+
+ if(dmin >= dmaj){
+ tmp = dmin; dmin = dmaj; dmaj = tmp;
+ octant |= YMAJOR;
+ }
+
+ e = -dmaj - ((bias >> octant) & 1);
+ len = dmaj;
+ dmin <<= 1;
+ dmaj <<= 1;
+ } else { /* Muffle compiler */
+ dmin = dmaj = e = octant = len = 0;
+ }
+
+ while(nbox--) {
+ oc1 = oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if (!(oc1 | oc2)) { /* uncliped */
+ if(infoRec->SubsequentDashedTwoPointLine) {
+ (*infoRec->SubsequentDashedTwoPointLine)(
+ infoRec->pScrn, x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? 0 :
+#endif
+ OMIT_LAST, PatternOffset);
+ } else {
+ (*infoRec->SubsequentDashedBresenhamLine)(
+ infoRec->pScrn, x1, y1, dmaj, dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? (len+1) :
+#endif
+ len, octant, PatternOffset);
+ }
+ break;
+ } else if (oc1 & oc2) { /* completely clipped */
+ pbox++;
+ } else if (infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE) {
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1);
+
+ if(infoRec->SubsequentDashedBresenhamLine) {
+ (*infoRec->SubsequentDashedBresenhamLine)(
+ infoRec->pScrn, x1, y1, dmaj, dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? (len+1) :
+#endif
+ len, octant, PatternOffset);
+ } else {
+ (*infoRec->SubsequentDashedTwoPointLine)(
+ infoRec->pScrn, x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? 0 :
+#endif
+ OMIT_LAST, PatternOffset
+ );
+ }
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+ pbox++;
+ } else {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int err, adx, ady;
+
+ if(octant & YMAJOR) {
+ ady = dmaj >> 1;
+ adx = dmin >> 1;
+ } else {
+ ady = dmin >> 1;
+ adx = dmaj >> 1;
+ }
+
+ if (miZeroClipLine(pbox->x1, pbox->y1,
+ pbox->x2 - 1, pbox->y2 - 1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+
+ if (octant & YMAJOR)
+ len = abs(new_y2 - new_y1);
+ else
+ len = abs(new_x2 - new_x1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len) {
+ int abserr, clipdx, clipdy;
+ /* unwind bresenham error term to first point */
+ if (clip1) {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+
+ if (octant & YMAJOR)
+ err = e + clipdy*dmin - clipdx*dmaj;
+ else
+ err = e + clipdx*dmin - clipdy*dmaj;
+ } else
+ err = e;
+
+#define range infoRec->DashedBresenhamLineErrorTermBits
+ abserr = abs(err);
+ while((abserr & range) ||
+ (dmaj & range) ||
+ (dmin & range)) {
+ dmin >>= 1;
+ dmaj >>= 1;
+ abserr >>= 1;
+ err /= 2;
+ }
+
+ if(octant & YMAJOR)
+ offset = abs(new_y1 - y1);
+ else
+ offset = abs(new_x1 - x1);
+
+ offset += PatternOffset;
+ offset %= PatternLength;
+
+ (*infoRec->SubsequentDashedBresenhamLine)(
+ infoRec->pScrn, new_x1, new_y1,
+ dmaj, dmin, err, len, octant, offset);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+#ifndef POLYSEGMENT
+ len = abs(y2 - y1);
+ tmp = abs(x2 - x1);
+ PatternOffset += (len > tmp) ? len : tmp;
+ PatternOffset %= PatternLength;
+#endif
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--) {
+ if ((x2 >= pbox->x1) && (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) && (y2 < pbox->y2))
+ {
+ if(infoRec->SubsequentDashedTwoPointLine) {
+ (*infoRec->SubsequentDashedTwoPointLine)(
+ infoRec->pScrn, x2, y2, x2, y2, 0,
+ PatternOffset);
+ } else {
+ (*infoRec->SubsequentDashedBresenhamLine)(
+ infoRec->pScrn, x2, y2, 2, 0, -1,
+ 1, 0, PatternOffset);
+ }
+ break;
+ } else
+ pbox++;
+ }
+ }
+#endif
+
+ SET_SYNC_FLAG(infoRec);
+}
+
diff --git a/xorg-server/hw/xfree86/xaa/xaaFillArc.c b/xorg-server/hw/xfree86/xaa/xaaFillArc.c index d83922ce0..824d2af1d 100644 --- a/xorg-server/hw/xfree86/xaa/xaaFillArc.c +++ b/xorg-server/hw/xfree86/xaa/xaaFillArc.c @@ -1,213 +1,213 @@ -/* - * Copyright 1996 The XFree86 Project - * - * 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 - * HARM HANEMAAYER 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. - * - * Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net). - */ - -/* - * Filled solid arcs, based on cfbfillarc.c. - * - * Fill arc using calls to low-level span fill. Because the math for - * each span can be done concurrently with the drawing of the span - * with a graphics coprocessor operation, this is faster than just - * using miPolyFillArc, which first calculates all the spans and then - * calls FillSpans. - * - * Clipped arcs are dispatched to FillSpans. - */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <limits.h> - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include <X11/X.h> -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" -#include "mifillarc.h" -#include "mi.h" - -/* - * This is based on the integer-math versions from mi. Perhaps on a - * Pentium, the floating-point (double)-math version is faster. - */ - -static void -XAAFillEllipseSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - register int x, y, e; - int yk, xk, ym, xm, dx, dy, xorg, yorg; - int slw; - miFillArcRec info; - - (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, - pGC->planemask); - - miFillArcSetup(arc, &info); - MIFILLARCSETUP(); - if (pGC->miTranslate) - { - xorg += pDraw->x; - yorg += pDraw->y; - } - while (y > 0) - { - MIFILLARCSTEP(slw); - if (slw > 0) { - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, xorg - x, - yorg - y, slw, 1); - if (miFillArcLower(slw)) - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, - xorg - x, yorg + y + dy, slw, 1); - } - } - - SET_SYNC_FLAG(infoRec); -} - - -#define ADDSPAN(l,r) \ - if (r >= l) \ - (*infoRec->SubsequentSolidFillRect)( \ - infoRec->pScrn, l, ya, r - l + 1, 1); - -#define ADDSLICESPANS(flip) \ - if (!flip) \ - { \ - ADDSPAN(xl, xr); \ - } \ - else \ - { \ - xc = xorg - x; \ - ADDSPAN(xc, xr); \ - xc += slw - 1; \ - ADDSPAN(xl, xc); \ - } - -static void -XAAFillArcSliceSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int yk, xk, ym, xm, dx, dy, xorg, yorg, slw; - register int x, y, e; - miFillArcRec info; - miArcSliceRec slice; - int ya, xl, xr, xc; - - (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, - pGC->planemask); - - miFillArcSetup(arc, &info); - miFillArcSliceSetup(arc, &slice, pGC); - MIFILLARCSETUP(); - slw = arc->height; - if (slice.flip_top || slice.flip_bot) - slw += (arc->height >> 1) + 1; - if (pGC->miTranslate) - { - xorg += pDraw->x; - yorg += pDraw->y; - slice.edge1.x += pDraw->x; - slice.edge2.x += pDraw->x; - } - while (y > 0) - { - MIFILLARCSTEP(slw); - MIARCSLICESTEP(slice.edge1); - MIARCSLICESTEP(slice.edge2); - if (miFillSliceUpper(slice)) - { - ya = yorg - y; - MIARCSLICEUPPER(xl, xr, slice, slw); - - ADDSLICESPANS(slice.flip_top); - } - if (miFillSliceLower(slice)) - { - ya = yorg + y + dy; - MIARCSLICELOWER(xl, xr, slice, slw); - ADDSLICESPANS(slice.flip_bot); - } - } - - SET_SYNC_FLAG(infoRec); -} - - -void -XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs) -{ - register xArc *arc; - register int i; - int x2, y2; - BoxRec box; - RegionPtr cclip; - - cclip = pGC->pCompositeClip; - - if(!REGION_NUM_RECTS(cclip)) - return; - - for (arc = parcs, i = narcs; --i >= 0; arc++) - { - if (miFillArcEmpty(arc)) - continue; - if (miCanFillArc(arc)) - { - box.x1 = arc->x + pDraw->x; - box.y1 = arc->y + pDraw->y; - /* - * Because box.x2 and box.y2 get truncated to 16 bits, and the - * RECT_IN_REGION test treats the resulting number as a signed - * integer, the RECT_IN_REGION test alone can go the wrong way. - * This can result in a server crash because the rendering - * routines in this file deal directly with cpu addresses - * of pixels to be stored, and do not clip or otherwise check - * that all such addresses are within their respective pixmaps. - * So we only allow the RECT_IN_REGION test to be used for - * values that can be expressed correctly in a signed short. - */ - x2 = box.x1 + (int)arc->width + 1; - box.x2 = x2; - y2 = box.y1 + (int)arc->height + 1; - box.y2 = y2; - if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) && - (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) ) - { - if ((arc->angle2 >= FULLCIRCLE) || - (arc->angle2 <= -FULLCIRCLE)) - XAAFillEllipseSolid(pDraw, pGC, arc); - else - XAAFillArcSliceSolid(pDraw, pGC, arc); - continue; - } - } - miPolyFillArc(pDraw, pGC, 1, arc); - } -} +/*
+ * Copyright 1996 The XFree86 Project
+ *
+ * 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
+ * HARM HANEMAAYER 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.
+ *
+ * Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
+ */
+
+/*
+ * Filled solid arcs, based on cfbfillarc.c.
+ *
+ * Fill arc using calls to low-level span fill. Because the math for
+ * each span can be done concurrently with the drawing of the span
+ * with a graphics coprocessor operation, this is faster than just
+ * using miPolyFillArc, which first calculates all the spans and then
+ * calls FillSpans.
+ *
+ * Clipped arcs are dispatched to FillSpans.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <limits.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "mifillarc.h"
+#include "mi.h"
+
+/*
+ * This is based on the integer-math versions from mi. Perhaps on a
+ * Pentium, the floating-point (double)-math version is faster.
+ */
+
+static void
+XAAFillEllipseSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ register int x, y, e;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg;
+ int slw;
+ miFillArcRec info;
+
+ (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ miFillArcSetup(arc, &info);
+ MIFILLARCSETUP();
+ if (pGC->miTranslate)
+ {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ }
+ while (y > 0)
+ {
+ MIFILLARCSTEP(slw);
+ if (slw > 0) {
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, xorg - x,
+ yorg - y, slw, 1);
+ if (miFillArcLower(slw))
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
+ xorg - x, yorg + y + dy, slw, 1);
+ }
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+#define ADDSPAN(l,r) \
+ if (r >= l) \
+ (*infoRec->SubsequentSolidFillRect)( \
+ infoRec->pScrn, l, ya, r - l + 1, 1);
+
+#define ADDSLICESPANS(flip) \
+ if (!flip) \
+ { \
+ ADDSPAN(xl, xr); \
+ } \
+ else \
+ { \
+ xc = xorg - x; \
+ ADDSPAN(xc, xr); \
+ xc += slw - 1; \
+ ADDSPAN(xl, xc); \
+ }
+
+static void
+XAAFillArcSliceSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+ register int x, y, e;
+ miFillArcRec info;
+ miArcSliceRec slice;
+ int ya, xl, xr, xc;
+
+ (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ miFillArcSetup(arc, &info);
+ miFillArcSliceSetup(arc, &slice, pGC);
+ MIFILLARCSETUP();
+ slw = arc->height;
+ if (slice.flip_top || slice.flip_bot)
+ slw += (arc->height >> 1) + 1;
+ if (pGC->miTranslate)
+ {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ slice.edge1.x += pDraw->x;
+ slice.edge2.x += pDraw->x;
+ }
+ while (y > 0)
+ {
+ MIFILLARCSTEP(slw);
+ MIARCSLICESTEP(slice.edge1);
+ MIARCSLICESTEP(slice.edge2);
+ if (miFillSliceUpper(slice))
+ {
+ ya = yorg - y;
+ MIARCSLICEUPPER(xl, xr, slice, slw);
+
+ ADDSLICESPANS(slice.flip_top);
+ }
+ if (miFillSliceLower(slice))
+ {
+ ya = yorg + y + dy;
+ MIARCSLICELOWER(xl, xr, slice, slw);
+ ADDSLICESPANS(slice.flip_bot);
+ }
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+void
+XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
+{
+ register xArc *arc;
+ register int i;
+ int x2, y2;
+ BoxRec box;
+ RegionPtr cclip;
+
+ cclip = pGC->pCompositeClip;
+
+ if(!RegionNumRects(cclip))
+ return;
+
+ for (arc = parcs, i = narcs; --i >= 0; arc++)
+ {
+ if (miFillArcEmpty(arc))
+ continue;
+ if (miCanFillArc(arc))
+ {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int)arc->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int)arc->height + 1;
+ box.y2 = y2;
+ if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) &&
+ (RegionContainsRect(cclip, &box) == rgnIN) )
+ {
+ if ((arc->angle2 >= FULLCIRCLE) ||
+ (arc->angle2 <= -FULLCIRCLE))
+ XAAFillEllipseSolid(pDraw, pGC, arc);
+ else
+ XAAFillArcSliceSolid(pDraw, pGC, arc);
+ continue;
+ }
+ }
+ miPolyFillArc(pDraw, pGC, 1, arc);
+ }
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaFillPoly.c b/xorg-server/hw/xfree86/xaa/xaaFillPoly.c index 6f11e35ff..b8347b336 100644 --- a/xorg-server/hw/xfree86/xaa/xaaFillPoly.c +++ b/xorg-server/hw/xfree86/xaa/xaaFillPoly.c @@ -1,962 +1,962 @@ - -/* - * Copyright 1996 The XFree86 Project - * - * 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 - * HARM HANEMAAYER 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. - * - */ - -/* - * Written by Mark Vojkovich. Loosly based on an original version - * written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net) which - * only did solid rectangles and didn't have trapezoid support. - * - */ - - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include <X11/X.h> -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "xf86str.h" -#include "mi.h" -#include "micoord.h" - -#include "xaa.h" -#include "xaalocal.h" - -#define POLY_USE_MI 0 -#define POLY_FULLY_CLIPPED 1 -#define POLY_IS_EASY 2 - - -#define Setup(c,x,vertex,dx,dy,e,sign,step,DX) {\ - x = intToX(vertex); \ - if ((dy = intToY(c) - y)) { \ - DX = dx = intToX(c) - x; \ - step = 0; \ - if (dx >= 0) \ - { \ - e = 0; \ - sign = 1; \ - if (dx >= dy) {\ - step = dx / dy; \ - dx %= dy; \ - } \ - } \ - else \ - { \ - e = 1 - dy; \ - sign = -1; \ - dx = -dx; \ - if (dx >= dy) { \ - step = - (dx / dy); \ - dx %= dy; \ - } \ - } \ - } \ - x += origin; \ - vertex = c; \ -} - -#define Step(x,dx,dy,e,sign,step) {\ - x += step; \ - if ((e += dx) > 0) \ - { \ - x += sign; \ - e -= dy; \ - } \ -} - -#define FixError(x, dx, dy, e, sign, step, h) { \ - e += (h) * dx; \ - x += (h) * step; \ - if(e > 0) { \ - x += e * sign/dy; \ - e %= dy; \ - if(e) { \ - x += sign; \ - e -= dy; \ - } \ - } \ -} - - -/* - XAAIsEasyPoly - - - Checks CoordModeOrigin one rect polygons to see if we need - to use Mi. - Returns: POLY_USE_MI, POLY_FULLY_CLIPPED or POLY_IS_EASY - as well as the pointer to the "top" point and the y - extents. -*/ - -int -XAAIsEasyPolygon( - DDXPointPtr ptsIn, - int count, - BoxPtr extents, - int origin, - DDXPointPtr *topPoint, /* return */ - int *topY, int *bottomY, /* return */ - int shape -){ - int c = 0, vertex1, vertex2; - - *topY = 32767; - *bottomY = 0; - - origin -= (origin & 0x8000) << 1; - vertex1 = extents->x1 - origin; - vertex2 = extents->x2 - origin /* - 0x00010001 */; - /* I think this was an error in cfb ^ */ - - if (shape == Convex) { - while (count--) { - c = *((int*)ptsIn); - if (((c - vertex1) | (vertex2 - c)) & 0x80008000) - return POLY_USE_MI; - - c = intToY(c); - if (c < *topY) { - *topY = c; - *topPoint = ptsIn; - } - ptsIn++; - if (c > *bottomY) *bottomY = c; - } - } else { - int yFlip = 0; - int dx2, dx1, x1, x2; - - x2 = x1 = -1; - dx2 = dx1 = 1; - - while (count--) { - c = *((int*)ptsIn); - if (((c - vertex1) | (vertex2 - c)) & 0x80008000) - return POLY_USE_MI; - c = intToY(c); - if (c < *topY) { - *topY = c; - *topPoint = ptsIn; - } - ptsIn++; - if (c > *bottomY) *bottomY = c; - if (c == x1) - continue; - if (dx1 > 0) { - if (x2 < 0) x2 = c; - else dx2 = dx1 = (c - x1) >> 31; - } else if ((c - x1) >> 31 != dx1) { - dx1 = ~dx1; - yFlip++; - } - x1 = c; - } - x1 = (x2 - c) >> 31; - if (x1 != dx1) yFlip++; - if (x1 != dx2) yFlip++; - if (yFlip != 2) { - if(*topY == *bottomY) - return POLY_FULLY_CLIPPED; - else - return POLY_USE_MI; - } - } - if (*topY == *bottomY) - return POLY_FULLY_CLIPPED; - - return POLY_IS_EASY; -} - -void -XAAFillPolygonSolid( - DrawablePtr pDraw, - GCPtr pGC, - int shape, - int mode, - int count, - DDXPointPtr ptsIn -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int origin, vertex1, vertex2; - int *vertex1p, *vertex2p, *endp; - int x1 = 0, x2 = 0; - int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; - int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0; - int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0; - int c, y, maxy, h, yoffset; - DDXPointPtr topPoint; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - if (mode == CoordModePrevious) { - register DDXPointPtr ppt = ptsIn + 1; - - for (origin = 1; origin < count; origin++, ppt++) { - ppt->x += (ppt-1)->x; - ppt->y += (ppt-1)->y; - } - mode = CoordModeOrigin; - } - - if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - origin = coordToInt(pDraw->x, pDraw->y); - - switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, - origin, &topPoint, &y, &maxy, shape) ) { - case POLY_USE_MI: - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - case POLY_FULLY_CLIPPED: - return; - } - - endp = (int*)ptsIn + count; - vertex2p = vertex1p = (int *)topPoint; - origin = pDraw->x; - yoffset = pDraw->y; - vertex2 = vertex1 = *vertex2p++; - if (vertex2p == endp) - vertex2p = (int *) ptsIn; - - (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, - pGC->planemask); - - while(1) { - if (y == intToY(vertex1)) { - do { - if (vertex1p == (int *) ptsIn) - vertex1p = endp; - c = *--vertex1p; - Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1) - } while (y >= intToY(vertex1)); - h = dy1; - } else { - Step(x1,dx1,dy1,e1,sign1,step1) - h = intToY(vertex1) - y; - } - if (y == intToY(vertex2)) { - do { - c = *vertex2p++; - if (vertex2p == endp) - vertex2p = (int *) ptsIn; - Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2) - } while (y >= intToY(vertex2)); - if (dy2 < h) - h = dy2; - } else { - Step(x2,dx2,dy2,e2,sign2,step2) - if ((c = (intToY(vertex2) - y)) < h) - h = c; - } - - /* fill spans for this segment */ - if(DX1 | DX2) { - if(infoRec->SubsequentSolidFillTrap && (h > 6)) { - if(x1 == x2) { - while(x1 == x2) { - y++; - if (!--h) break; - Step(x1,dx1,dy1,e1,sign1,step1) - Step(x2,dx2,dy2,e2,sign2,step2) - } - if(y == maxy) break; - if(!h) continue; - } - - if(x1 < x2) - (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, - y + yoffset, h, - x1, DX1, dy1, e1, - x2 - 1, DX2, dy2, e2); - else - (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, - y + yoffset, h, - x2, DX2, dy2, e2, - x1 - 1, DX1, dy1, e1); - y += h; - if(--h) { - FixError(x1,dx1,dy1,e1,sign1,step1,h); - FixError(x2,dx2,dy2,e2,sign2,step2,h); - h = 0; - } - } else { - while(1) { - if (x2 > x1) - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, - x1, y + yoffset, x2 - x1, 1); - else if (x1 > x2) - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, - x2, y + yoffset, x1 - x2, 1); - y++; - if (!--h) break; - Step(x1,dx1,dy1,e1,sign1,step1) - Step(x2,dx2,dy2,e2,sign2,step2) - } - } - } else { - if (x2 > x1) - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, - x1, y + yoffset, x2 - x1, h); - else if (x1 > x2) - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, - x2, y + yoffset, x1 - x2, h); - - y += h; - h = 0; - } - if (y == maxy) break; - } - SET_SYNC_FLAG(infoRec); -} - - - - -void -XAAFillPolygonHelper( - ScrnInfoPtr pScrn, - DDXPointPtr ptsIn, - int count, - DDXPointPtr topPoint, - int y, - int maxy, - int origin, - RectFuncPtr RectFunc, - TrapFuncPtr TrapFunc, - int xorg, - int yorg, - XAACacheInfoPtr pCache -){ - int *vertex1p, *vertex2p, *endp; - int vertex1, vertex2; - int x1 = 0, x2 = 0; - int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; - int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0; - int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0; - int c, h, yoffset; - - - endp = (int*)ptsIn + count; - vertex2p = vertex1p = (int *)topPoint; - yoffset = intToY(origin); - origin = intToX(origin); - vertex2 = vertex1 = *vertex2p++; - if (vertex2p == endp) - vertex2p = (int *)ptsIn; - - while(1) { - if (y == intToY(vertex1)) { - do { - if (vertex1p == (int *) ptsIn) - vertex1p = endp; - c = *--vertex1p; - Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1) - } while (y >= intToY(vertex1)); - h = dy1; - } else { - Step(x1,dx1,dy1,e1,sign1,step1) - h = intToY(vertex1) - y; - } - if (y == intToY(vertex2)) { - do { - c = *vertex2p++; - if (vertex2p == endp) - vertex2p = (int *) ptsIn; - Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2) - } while (y >= intToY(vertex2)); - if (dy2 < h) - h = dy2; - } else { - Step(x2,dx2,dy2,e2,sign2,step2) - if ((c = (intToY(vertex2) - y)) < h) - h = c; - } - - /* fill spans for this segment */ - if(DX1 | DX2) { - if(TrapFunc && (h > 6)) { - if(x1 == x2) { - while(x1 == x2) { - y++; - if (!--h) break; - Step(x1,dx1,dy1,e1,sign1,step1) - Step(x2,dx2,dy2,e2,sign2,step2) - } - if(y == maxy) break; - if(!h) continue; - } - - if(x1 < x2) - (*TrapFunc)(pScrn, y + yoffset, h, - x1, DX1, dy1, e1, - x2 - 1, DX2, dy2, e2, xorg, yorg, pCache); - else - (*TrapFunc)(pScrn, y + yoffset, h, - x2, DX2, dy2, e2, - x1 - 1, DX1, dy1, e1, xorg, yorg, pCache); - y += h; - if(--h) { - FixError(x1,dx1,dy1,e1,sign1,step1,h); - FixError(x2,dx2,dy2,e2,sign2,step2,h); - h = 0; - } - } else { - while(1) { - if (x2 > x1) - (*RectFunc)(pScrn, - x1, y + yoffset, x2 - x1, 1, xorg, yorg, pCache); - else if (x1 > x2) - (*RectFunc)(pScrn, - x2, y + yoffset, x1 - x2, 1, xorg, yorg, pCache); - y++; - if (!--h) break; - Step(x1,dx1,dy1,e1,sign1,step1) - Step(x2,dx2,dy2,e2,sign2,step2) - } - } - } else { - if (x2 > x1) - (*RectFunc)(pScrn, - x1, y + yoffset, x2 - x1, h, xorg, yorg, pCache); - else if (x1 > x2) - (*RectFunc)(pScrn, - x2, y + yoffset, x1 - x2, h, xorg, yorg, pCache); - - y += h; - h = 0; - } - if (y == maxy) break; - } -} - - /*****************\ - | Solid Helpers | - \*****************/ - -static void -SolidTrapHelper( - ScrnInfoPtr pScrn, - int y, int h, - int x1, int dx1, int dy1, int e1, - int x2, int dx2, int dy2, int e2, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SubsequentSolidFillTrap) (pScrn, - y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2); -} - -static void -SolidRectHelper ( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h); -} - - - /*********************\ - | Mono 8x8 Patterns | - \*********************/ - -static void -Mono8x8PatternTrapHelper_ScreenOrigin( - ScrnInfoPtr pScrn, - int y, int h, - int x1, int dx1, int dy1, int e1, - int x2, int dx2, int dy2, int e2, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SubsequentMono8x8PatternFillTrap) (pScrn, xorg, yorg, - y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2); -} - -static void -Mono8x8PatternRectHelper_ScreenOrigin ( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg, - x, y, w, h); -} - -static void -Mono8x8PatternRectHelper ( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - xorg = (x - xorg) & 0x07; - yorg = (y - yorg) & 0x07; - - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS) { - int patx = pCache->pat0; - int paty = pCache->pat1; - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } else { - int slot = (yorg << 3) + xorg; - xorg = pCache->x + pCache->offsets[slot].x; - yorg = pCache->y + pCache->offsets[slot].y; - } - } - - - (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg, - x, y, w, h); -} - - - - /****************\ - | Cache Expand | - \****************/ - - -static void -CacheExpandRectHelper ( - ScrnInfoPtr pScrn, - int X, int Y, int Width, int Height, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, phaseY, phaseX, skipleft, w, blit_w, blit_h; - int cacheWidth; - - cacheWidth = (pCache->w * pScrn->bitsPerPixel) / - infoRec->CacheColorExpandDensity; - - phaseY = (Y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - phaseX = (X - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - - while(1) { - w = Width; skipleft = phaseX; x = X; - blit_h = pCache->h - phaseY; - if(blit_h > Height) blit_h = Height; - - while(1) { - blit_w = cacheWidth - skipleft; - if(blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenColorExpandFill)( - pScrn, x, Y, blit_w, blit_h, - pCache->x, pCache->y + phaseY, skipleft); - w -= blit_w; - if(!w) break; - x += blit_w; - skipleft = (skipleft + blit_w) % pCache->orig_w; - } - Height -= blit_h; - if(!Height) break; - Y += blit_h; - phaseY = (phaseY + blit_h) % pCache->orig_h; - } -} - - - - /**************\ - | Cache Blit | - \**************/ - - -static void -CacheBltRectHelper ( - ScrnInfoPtr pScrn, - int X, int Y, int Width, int Height, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, phaseY, phaseX, skipleft, w, blit_w, blit_h; - - phaseY = (Y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - phaseX = (X - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - - while(1) { - w = Width; skipleft = phaseX; x = X; - blit_h = pCache->h - phaseY; - if(blit_h > Height) blit_h = Height; - - while(1) { - blit_w = pCache->w - skipleft; - if(blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, - pCache->x + skipleft, pCache->y + phaseY, - x, Y, blit_w, blit_h); - w -= blit_w; - if(!w) break; - x += blit_w; - skipleft = (skipleft + blit_w) % pCache->orig_w; - } - Height -= blit_h; - if(!Height) break; - Y += blit_h; - phaseY = (phaseY + blit_h) % pCache->orig_h; - } -} - - - /**********************\ - | Stippled Polygons | - \**********************/ - - -void -XAAFillPolygonStippled( - DrawablePtr pDraw, - GCPtr pGC, - int shape, - int mode, - int count, - DDXPointPtr ptsIn -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); - int origin, type, patx, paty, fg, bg; - int y, maxy, xorg, yorg; - DDXPointPtr topPoint; - XAACacheInfoPtr pCache = NULL; - RectFuncPtr RectFunc = NULL; - TrapFuncPtr TrapFunc = NULL; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - if (mode == CoordModePrevious) { - register DDXPointPtr ppt = ptsIn + 1; - - for (origin = 1; origin < count; origin++, ppt++) { - ppt->x += (ppt-1)->x; - ppt->y += (ppt-1)->y; - } - mode = CoordModeOrigin; - } - - if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - - if(pGC->fillStyle == FillStippled) { - type = (*infoRec->StippledFillChooser)(pGC); - fg = pGC->fgPixel; bg = -1; - } else { - type = (*infoRec->OpaqueStippledFillChooser)(pGC); - fg = pGC->fgPixel; bg = pGC->bgPixel; - } - - - if(!type) { - (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - if((type == DO_COLOR_EXPAND) || (type == DO_COLOR_8x8)) { - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - origin = pDraw->x; - - switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, - origin, &topPoint, &y, &maxy, shape) ) { - case POLY_USE_MI: - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - case POLY_FULLY_CLIPPED: - return; - } - - xorg = (pDraw->x + pGC->patOrg.x); - yorg = (pDraw->y + pGC->patOrg.y); - - - if((fg == bg) && (bg != -1) && infoRec->SetupForSolidFill) { - - (*infoRec->SetupForSolidFill)(infoRec->pScrn, fg, - pGC->alu, pGC->planemask); - - RectFunc = SolidRectHelper; - TrapFunc = infoRec->SubsequentSolidFillTrap ? SolidTrapHelper : NULL; - } else - switch(type) { - case DO_MONO_8x8: - patx = pPriv->pattern0; paty = pPriv->pattern1; - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_SCREEN_ORIGIN) { - xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07; - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS) { - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) { - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } - } else { - XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)( - infoRec->pScrn, patx, paty); - patx = pCache->x; paty = pCache->y; - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - patx += pCache->offsets[slot].x; - paty += pCache->offsets[slot].y; - xorg = patx; yorg = paty; - } - } - RectFunc = Mono8x8PatternRectHelper_ScreenOrigin; - if(infoRec->SubsequentMono8x8PatternFillTrap) - TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin; - } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */ - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS)){ - pCache = (*infoRec->CacheMono8x8Pattern)( - infoRec->pScrn, patx, paty); - patx = pCache->x; paty = pCache->y; - } else { - pCache = &(infoRec->ScratchCacheInfoRec); - pCache->pat0 = patx; - pCache->pat1 = paty; - } - RectFunc = Mono8x8PatternRectHelper; - } - - (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn, - patx, paty, fg, bg, pGC->alu, pGC->planemask); - break; - case DO_CACHE_EXPAND: - pCache = (*infoRec->CacheMonoStipple)(infoRec->pScrn, pGC->stipple); - - (*infoRec->SetupForScreenToScreenColorExpandFill)( - infoRec->pScrn, fg, bg, pGC->alu, pGC->planemask); - - RectFunc = CacheExpandRectHelper; - break; - case DO_CACHE_BLT: - pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, - fg, bg); - (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, - pGC->alu, pGC->planemask, pCache->trans_color); - - RectFunc = CacheBltRectHelper; - break; - default: - return; - } - - - XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint, - y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache); - - SET_SYNC_FLAG(infoRec); -} - - - - - /*******************\ - | Tiled Polygons | - \*******************/ - - -void -XAAFillPolygonTiled( - DrawablePtr pDraw, - GCPtr pGC, - int shape, - int mode, - int count, - DDXPointPtr ptsIn -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); - int origin, type, patx, paty; - int y, maxy, xorg, yorg; - DDXPointPtr topPoint; - XAACacheInfoPtr pCache = NULL; - RectFuncPtr RectFunc = NULL; - TrapFuncPtr TrapFunc = NULL; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - if (mode == CoordModePrevious) { - register DDXPointPtr ppt = ptsIn + 1; - - for (origin = 1; origin < count; origin++, ppt++) { - ppt->x += (ppt-1)->x; - ppt->y += (ppt-1)->y; - } - mode = CoordModeOrigin; - } - - if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - - type = (*infoRec->TiledFillChooser)(pGC); - - if(!type || (type == DO_IMAGE_WRITE)) { - (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - if(type == DO_COLOR_8x8) { - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - origin = pDraw->x; - - switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, - origin, &topPoint, &y, &maxy, shape) ) { - case POLY_USE_MI: - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - case POLY_FULLY_CLIPPED: - return; - } - - xorg = (pDraw->x + pGC->patOrg.x); - yorg = (pDraw->y + pGC->patOrg.y); - - switch(type) { - case DO_MONO_8x8: - patx = pPriv->pattern0; paty = pPriv->pattern1; - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_SCREEN_ORIGIN) { - xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07; - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS) { - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) { - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } - } else { - XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)( - infoRec->pScrn, patx, paty); - patx = pCache->x; paty = pCache->y; - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - patx += pCache->offsets[slot].x; - paty += pCache->offsets[slot].y; - xorg = patx; yorg = paty; - } - } - RectFunc = Mono8x8PatternRectHelper_ScreenOrigin; - if(infoRec->SubsequentMono8x8PatternFillTrap) - TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin; - } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */ - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS)){ - pCache = (*infoRec->CacheMono8x8Pattern)( - infoRec->pScrn, patx, paty); - patx = pCache->x; paty = pCache->y; - } - else { - pCache = &(infoRec->ScratchCacheInfoRec); - pCache->pat0 = patx; - pCache->pat1 = paty; - } - RectFunc = Mono8x8PatternRectHelper; - } - - (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn, - patx, paty, pPriv->fg, pPriv->bg, pGC->alu, pGC->planemask); - break; - case DO_CACHE_BLT: - pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); - (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, - pGC->alu, pGC->planemask, -1); - - RectFunc = CacheBltRectHelper; - break; - case DO_PIXMAP_COPY: - pCache = &(infoRec->ScratchCacheInfoRec); - pCache->x = pPriv->offscreenArea->box.x1; - pCache->y = pPriv->offscreenArea->box.y1; - pCache->w = pCache->orig_w = - pPriv->offscreenArea->box.x2 - pCache->x; - pCache->h = pCache->orig_h = - pPriv->offscreenArea->box.y2 - pCache->y; - - (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, - pGC->alu, pGC->planemask, -1); - - RectFunc = CacheBltRectHelper; - break; - default: - return; - } - - XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint, - y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache); - - SET_SYNC_FLAG(infoRec); -} - - +
+/*
+ * Copyright 1996 The XFree86 Project
+ *
+ * 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
+ * HARM HANEMAAYER 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.
+ *
+ */
+
+/*
+ * Written by Mark Vojkovich. Loosly based on an original version
+ * written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net) which
+ * only did solid rectangles and didn't have trapezoid support.
+ *
+ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "mi.h"
+#include "micoord.h"
+
+#include "xaa.h"
+#include "xaalocal.h"
+
+#define POLY_USE_MI 0
+#define POLY_FULLY_CLIPPED 1
+#define POLY_IS_EASY 2
+
+
+#define Setup(c,x,vertex,dx,dy,e,sign,step,DX) {\
+ x = intToX(vertex); \
+ if ((dy = intToY(c) - y)) { \
+ DX = dx = intToX(c) - x; \
+ step = 0; \
+ if (dx >= 0) \
+ { \
+ e = 0; \
+ sign = 1; \
+ if (dx >= dy) {\
+ step = dx / dy; \
+ dx %= dy; \
+ } \
+ } \
+ else \
+ { \
+ e = 1 - dy; \
+ sign = -1; \
+ dx = -dx; \
+ if (dx >= dy) { \
+ step = - (dx / dy); \
+ dx %= dy; \
+ } \
+ } \
+ } \
+ x += origin; \
+ vertex = c; \
+}
+
+#define Step(x,dx,dy,e,sign,step) {\
+ x += step; \
+ if ((e += dx) > 0) \
+ { \
+ x += sign; \
+ e -= dy; \
+ } \
+}
+
+#define FixError(x, dx, dy, e, sign, step, h) { \
+ e += (h) * dx; \
+ x += (h) * step; \
+ if(e > 0) { \
+ x += e * sign/dy; \
+ e %= dy; \
+ if(e) { \
+ x += sign; \
+ e -= dy; \
+ } \
+ } \
+}
+
+
+/*
+ XAAIsEasyPoly -
+
+ Checks CoordModeOrigin one rect polygons to see if we need
+ to use Mi.
+ Returns: POLY_USE_MI, POLY_FULLY_CLIPPED or POLY_IS_EASY
+ as well as the pointer to the "top" point and the y
+ extents.
+*/
+
+int
+XAAIsEasyPolygon(
+ DDXPointPtr ptsIn,
+ int count,
+ BoxPtr extents,
+ int origin,
+ DDXPointPtr *topPoint, /* return */
+ int *topY, int *bottomY, /* return */
+ int shape
+){
+ int c = 0, vertex1, vertex2;
+
+ *topY = 32767;
+ *bottomY = 0;
+
+ origin -= (origin & 0x8000) << 1;
+ vertex1 = extents->x1 - origin;
+ vertex2 = extents->x2 - origin /* - 0x00010001 */;
+ /* I think this was an error in cfb ^ */
+
+ if (shape == Convex) {
+ while (count--) {
+ c = *((int*)ptsIn);
+ if (((c - vertex1) | (vertex2 - c)) & 0x80008000)
+ return POLY_USE_MI;
+
+ c = intToY(c);
+ if (c < *topY) {
+ *topY = c;
+ *topPoint = ptsIn;
+ }
+ ptsIn++;
+ if (c > *bottomY) *bottomY = c;
+ }
+ } else {
+ int yFlip = 0;
+ int dx2, dx1, x1, x2;
+
+ x2 = x1 = -1;
+ dx2 = dx1 = 1;
+
+ while (count--) {
+ c = *((int*)ptsIn);
+ if (((c - vertex1) | (vertex2 - c)) & 0x80008000)
+ return POLY_USE_MI;
+ c = intToY(c);
+ if (c < *topY) {
+ *topY = c;
+ *topPoint = ptsIn;
+ }
+ ptsIn++;
+ if (c > *bottomY) *bottomY = c;
+ if (c == x1)
+ continue;
+ if (dx1 > 0) {
+ if (x2 < 0) x2 = c;
+ else dx2 = dx1 = (c - x1) >> 31;
+ } else if ((c - x1) >> 31 != dx1) {
+ dx1 = ~dx1;
+ yFlip++;
+ }
+ x1 = c;
+ }
+ x1 = (x2 - c) >> 31;
+ if (x1 != dx1) yFlip++;
+ if (x1 != dx2) yFlip++;
+ if (yFlip != 2) {
+ if(*topY == *bottomY)
+ return POLY_FULLY_CLIPPED;
+ else
+ return POLY_USE_MI;
+ }
+ }
+ if (*topY == *bottomY)
+ return POLY_FULLY_CLIPPED;
+
+ return POLY_IS_EASY;
+}
+
+void
+XAAFillPolygonSolid(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr ptsIn
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int origin, vertex1, vertex2;
+ int *vertex1p, *vertex2p, *endp;
+ int x1 = 0, x2 = 0;
+ int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
+ int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0;
+ int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0;
+ int c, y, maxy, h, yoffset;
+ DDXPointPtr topPoint;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if (mode == CoordModePrevious) {
+ register DDXPointPtr ppt = ptsIn + 1;
+
+ for (origin = 1; origin < count; origin++, ppt++) {
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+ mode = CoordModeOrigin;
+ }
+
+ if (RegionNumRects(pGC->pCompositeClip) != 1) {
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ origin = coordToInt(pDraw->x, pDraw->y);
+
+ switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
+ origin, &topPoint, &y, &maxy, shape) ) {
+ case POLY_USE_MI:
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ case POLY_FULLY_CLIPPED:
+ return;
+ }
+
+ endp = (int*)ptsIn + count;
+ vertex2p = vertex1p = (int *)topPoint;
+ origin = pDraw->x;
+ yoffset = pDraw->y;
+ vertex2 = vertex1 = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+
+ (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ while(1) {
+ if (y == intToY(vertex1)) {
+ do {
+ if (vertex1p == (int *) ptsIn)
+ vertex1p = endp;
+ c = *--vertex1p;
+ Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1)
+ } while (y >= intToY(vertex1));
+ h = dy1;
+ } else {
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ h = intToY(vertex1) - y;
+ }
+ if (y == intToY(vertex2)) {
+ do {
+ c = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+ Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2)
+ } while (y >= intToY(vertex2));
+ if (dy2 < h)
+ h = dy2;
+ } else {
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ if ((c = (intToY(vertex2) - y)) < h)
+ h = c;
+ }
+
+ /* fill spans for this segment */
+ if(DX1 | DX2) {
+ if(infoRec->SubsequentSolidFillTrap && (h > 6)) {
+ if(x1 == x2) {
+ while(x1 == x2) {
+ y++;
+ if (!--h) break;
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ if(y == maxy) break;
+ if(!h) continue;
+ }
+
+ if(x1 < x2)
+ (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn,
+ y + yoffset, h,
+ x1, DX1, dy1, e1,
+ x2 - 1, DX2, dy2, e2);
+ else
+ (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn,
+ y + yoffset, h,
+ x2, DX2, dy2, e2,
+ x1 - 1, DX1, dy1, e1);
+ y += h;
+ if(--h) {
+ FixError(x1,dx1,dy1,e1,sign1,step1,h);
+ FixError(x2,dx2,dy2,e2,sign2,step2,h);
+ h = 0;
+ }
+ } else {
+ while(1) {
+ if (x2 > x1)
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
+ x1, y + yoffset, x2 - x1, 1);
+ else if (x1 > x2)
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
+ x2, y + yoffset, x1 - x2, 1);
+ y++;
+ if (!--h) break;
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ }
+ } else {
+ if (x2 > x1)
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
+ x1, y + yoffset, x2 - x1, h);
+ else if (x1 > x2)
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
+ x2, y + yoffset, x1 - x2, h);
+
+ y += h;
+ h = 0;
+ }
+ if (y == maxy) break;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+
+void
+XAAFillPolygonHelper(
+ ScrnInfoPtr pScrn,
+ DDXPointPtr ptsIn,
+ int count,
+ DDXPointPtr topPoint,
+ int y,
+ int maxy,
+ int origin,
+ RectFuncPtr RectFunc,
+ TrapFuncPtr TrapFunc,
+ int xorg,
+ int yorg,
+ XAACacheInfoPtr pCache
+){
+ int *vertex1p, *vertex2p, *endp;
+ int vertex1, vertex2;
+ int x1 = 0, x2 = 0;
+ int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
+ int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0;
+ int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0;
+ int c, h, yoffset;
+
+
+ endp = (int*)ptsIn + count;
+ vertex2p = vertex1p = (int *)topPoint;
+ yoffset = intToY(origin);
+ origin = intToX(origin);
+ vertex2 = vertex1 = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *)ptsIn;
+
+ while(1) {
+ if (y == intToY(vertex1)) {
+ do {
+ if (vertex1p == (int *) ptsIn)
+ vertex1p = endp;
+ c = *--vertex1p;
+ Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1)
+ } while (y >= intToY(vertex1));
+ h = dy1;
+ } else {
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ h = intToY(vertex1) - y;
+ }
+ if (y == intToY(vertex2)) {
+ do {
+ c = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+ Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2)
+ } while (y >= intToY(vertex2));
+ if (dy2 < h)
+ h = dy2;
+ } else {
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ if ((c = (intToY(vertex2) - y)) < h)
+ h = c;
+ }
+
+ /* fill spans for this segment */
+ if(DX1 | DX2) {
+ if(TrapFunc && (h > 6)) {
+ if(x1 == x2) {
+ while(x1 == x2) {
+ y++;
+ if (!--h) break;
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ if(y == maxy) break;
+ if(!h) continue;
+ }
+
+ if(x1 < x2)
+ (*TrapFunc)(pScrn, y + yoffset, h,
+ x1, DX1, dy1, e1,
+ x2 - 1, DX2, dy2, e2, xorg, yorg, pCache);
+ else
+ (*TrapFunc)(pScrn, y + yoffset, h,
+ x2, DX2, dy2, e2,
+ x1 - 1, DX1, dy1, e1, xorg, yorg, pCache);
+ y += h;
+ if(--h) {
+ FixError(x1,dx1,dy1,e1,sign1,step1,h);
+ FixError(x2,dx2,dy2,e2,sign2,step2,h);
+ h = 0;
+ }
+ } else {
+ while(1) {
+ if (x2 > x1)
+ (*RectFunc)(pScrn,
+ x1, y + yoffset, x2 - x1, 1, xorg, yorg, pCache);
+ else if (x1 > x2)
+ (*RectFunc)(pScrn,
+ x2, y + yoffset, x1 - x2, 1, xorg, yorg, pCache);
+ y++;
+ if (!--h) break;
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ }
+ } else {
+ if (x2 > x1)
+ (*RectFunc)(pScrn,
+ x1, y + yoffset, x2 - x1, h, xorg, yorg, pCache);
+ else if (x1 > x2)
+ (*RectFunc)(pScrn,
+ x2, y + yoffset, x1 - x2, h, xorg, yorg, pCache);
+
+ y += h;
+ h = 0;
+ }
+ if (y == maxy) break;
+ }
+}
+
+ /*****************\
+ | Solid Helpers |
+ \*****************/
+
+static void
+SolidTrapHelper(
+ ScrnInfoPtr pScrn,
+ int y, int h,
+ int x1, int dx1, int dy1, int e1,
+ int x2, int dx2, int dy2, int e2,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentSolidFillTrap) (pScrn,
+ y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2);
+}
+
+static void
+SolidRectHelper (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
+}
+
+
+ /*********************\
+ | Mono 8x8 Patterns |
+ \*********************/
+
+static void
+Mono8x8PatternTrapHelper_ScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int y, int h,
+ int x1, int dx1, int dy1, int e1,
+ int x2, int dx2, int dy2, int e2,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentMono8x8PatternFillTrap) (pScrn, xorg, yorg,
+ y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2);
+}
+
+static void
+Mono8x8PatternRectHelper_ScreenOrigin (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg,
+ x, y, w, h);
+}
+
+static void
+Mono8x8PatternRectHelper (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ xorg = (x - xorg) & 0x07;
+ yorg = (y - yorg) & 0x07;
+
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ int patx = pCache->pat0;
+ int paty = pCache->pat1;
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ } else {
+ int slot = (yorg << 3) + xorg;
+ xorg = pCache->x + pCache->offsets[slot].x;
+ yorg = pCache->y + pCache->offsets[slot].y;
+ }
+ }
+
+
+ (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg,
+ x, y, w, h);
+}
+
+
+
+ /****************\
+ | Cache Expand |
+ \****************/
+
+
+static void
+CacheExpandRectHelper (
+ ScrnInfoPtr pScrn,
+ int X, int Y, int Width, int Height,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, phaseY, phaseX, skipleft, w, blit_w, blit_h;
+ int cacheWidth;
+
+ cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
+ infoRec->CacheColorExpandDensity;
+
+ phaseY = (Y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+ phaseX = (X - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+
+ while(1) {
+ w = Width; skipleft = phaseX; x = X;
+ blit_h = pCache->h - phaseY;
+ if(blit_h > Height) blit_h = Height;
+
+ while(1) {
+ blit_w = cacheWidth - skipleft;
+ if(blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenColorExpandFill)(
+ pScrn, x, Y, blit_w, blit_h,
+ pCache->x, pCache->y + phaseY, skipleft);
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ Height -= blit_h;
+ if(!Height) break;
+ Y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+}
+
+
+
+ /**************\
+ | Cache Blit |
+ \**************/
+
+
+static void
+CacheBltRectHelper (
+ ScrnInfoPtr pScrn,
+ int X, int Y, int Width, int Height,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, phaseY, phaseX, skipleft, w, blit_w, blit_h;
+
+ phaseY = (Y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+ phaseX = (X - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+
+ while(1) {
+ w = Width; skipleft = phaseX; x = X;
+ blit_h = pCache->h - phaseY;
+ if(blit_h > Height) blit_h = Height;
+
+ while(1) {
+ blit_w = pCache->w - skipleft;
+ if(blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
+ pCache->x + skipleft, pCache->y + phaseY,
+ x, Y, blit_w, blit_h);
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ Height -= blit_h;
+ if(!Height) break;
+ Y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+}
+
+
+ /**********************\
+ | Stippled Polygons |
+ \**********************/
+
+
+void
+XAAFillPolygonStippled(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr ptsIn
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ int origin, type, patx, paty, fg, bg;
+ int y, maxy, xorg, yorg;
+ DDXPointPtr topPoint;
+ XAACacheInfoPtr pCache = NULL;
+ RectFuncPtr RectFunc = NULL;
+ TrapFuncPtr TrapFunc = NULL;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if (mode == CoordModePrevious) {
+ register DDXPointPtr ppt = ptsIn + 1;
+
+ for (origin = 1; origin < count; origin++, ppt++) {
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+ mode = CoordModeOrigin;
+ }
+
+ if (RegionNumRects(pGC->pCompositeClip) != 1) {
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+
+ if(pGC->fillStyle == FillStippled) {
+ type = (*infoRec->StippledFillChooser)(pGC);
+ fg = pGC->fgPixel; bg = -1;
+ } else {
+ type = (*infoRec->OpaqueStippledFillChooser)(pGC);
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ }
+
+
+ if(!type) {
+ (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ if((type == DO_COLOR_EXPAND) || (type == DO_COLOR_8x8)) {
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ origin = pDraw->x;
+
+ switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
+ origin, &topPoint, &y, &maxy, shape) ) {
+ case POLY_USE_MI:
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ case POLY_FULLY_CLIPPED:
+ return;
+ }
+
+ xorg = (pDraw->x + pGC->patOrg.x);
+ yorg = (pDraw->y + pGC->patOrg.y);
+
+
+ if((fg == bg) && (bg != -1) && infoRec->SetupForSolidFill) {
+
+ (*infoRec->SetupForSolidFill)(infoRec->pScrn, fg,
+ pGC->alu, pGC->planemask);
+
+ RectFunc = SolidRectHelper;
+ TrapFunc = infoRec->SubsequentSolidFillTrap ? SolidTrapHelper : NULL;
+ } else
+ switch(type) {
+ case DO_MONO_8x8:
+ patx = pPriv->pattern0; paty = pPriv->pattern1;
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_SCREEN_ORIGIN) {
+ xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07;
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ }
+ } else {
+ XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)(
+ infoRec->pScrn, patx, paty);
+ patx = pCache->x; paty = pCache->y;
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx; yorg = paty;
+ }
+ }
+ RectFunc = Mono8x8PatternRectHelper_ScreenOrigin;
+ if(infoRec->SubsequentMono8x8PatternFillTrap)
+ TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin;
+ } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS)){
+ pCache = (*infoRec->CacheMono8x8Pattern)(
+ infoRec->pScrn, patx, paty);
+ patx = pCache->x; paty = pCache->y;
+ } else {
+ pCache = &(infoRec->ScratchCacheInfoRec);
+ pCache->pat0 = patx;
+ pCache->pat1 = paty;
+ }
+ RectFunc = Mono8x8PatternRectHelper;
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn,
+ patx, paty, fg, bg, pGC->alu, pGC->planemask);
+ break;
+ case DO_CACHE_EXPAND:
+ pCache = (*infoRec->CacheMonoStipple)(infoRec->pScrn, pGC->stipple);
+
+ (*infoRec->SetupForScreenToScreenColorExpandFill)(
+ infoRec->pScrn, fg, bg, pGC->alu, pGC->planemask);
+
+ RectFunc = CacheExpandRectHelper;
+ break;
+ case DO_CACHE_BLT:
+ pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
+ fg, bg);
+ (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
+ pGC->alu, pGC->planemask, pCache->trans_color);
+
+ RectFunc = CacheBltRectHelper;
+ break;
+ default:
+ return;
+ }
+
+
+ XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint,
+ y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+
+ /*******************\
+ | Tiled Polygons |
+ \*******************/
+
+
+void
+XAAFillPolygonTiled(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr ptsIn
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+ int origin, type, patx, paty;
+ int y, maxy, xorg, yorg;
+ DDXPointPtr topPoint;
+ XAACacheInfoPtr pCache = NULL;
+ RectFuncPtr RectFunc = NULL;
+ TrapFuncPtr TrapFunc = NULL;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if (mode == CoordModePrevious) {
+ register DDXPointPtr ppt = ptsIn + 1;
+
+ for (origin = 1; origin < count; origin++, ppt++) {
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+ mode = CoordModeOrigin;
+ }
+
+ if (RegionNumRects(pGC->pCompositeClip) != 1) {
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+
+ type = (*infoRec->TiledFillChooser)(pGC);
+
+ if(!type || (type == DO_IMAGE_WRITE)) {
+ (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ if(type == DO_COLOR_8x8) {
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ origin = pDraw->x;
+
+ switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
+ origin, &topPoint, &y, &maxy, shape) ) {
+ case POLY_USE_MI:
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ case POLY_FULLY_CLIPPED:
+ return;
+ }
+
+ xorg = (pDraw->x + pGC->patOrg.x);
+ yorg = (pDraw->y + pGC->patOrg.y);
+
+ switch(type) {
+ case DO_MONO_8x8:
+ patx = pPriv->pattern0; paty = pPriv->pattern1;
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_SCREEN_ORIGIN) {
+ xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07;
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ }
+ } else {
+ XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)(
+ infoRec->pScrn, patx, paty);
+ patx = pCache->x; paty = pCache->y;
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx; yorg = paty;
+ }
+ }
+ RectFunc = Mono8x8PatternRectHelper_ScreenOrigin;
+ if(infoRec->SubsequentMono8x8PatternFillTrap)
+ TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin;
+ } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS)){
+ pCache = (*infoRec->CacheMono8x8Pattern)(
+ infoRec->pScrn, patx, paty);
+ patx = pCache->x; paty = pCache->y;
+ }
+ else {
+ pCache = &(infoRec->ScratchCacheInfoRec);
+ pCache->pat0 = patx;
+ pCache->pat1 = paty;
+ }
+ RectFunc = Mono8x8PatternRectHelper;
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn,
+ patx, paty, pPriv->fg, pPriv->bg, pGC->alu, pGC->planemask);
+ break;
+ case DO_CACHE_BLT:
+ pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
+ (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
+ pGC->alu, pGC->planemask, -1);
+
+ RectFunc = CacheBltRectHelper;
+ break;
+ case DO_PIXMAP_COPY:
+ pCache = &(infoRec->ScratchCacheInfoRec);
+ pCache->x = pPriv->offscreenArea->box.x1;
+ pCache->y = pPriv->offscreenArea->box.y1;
+ pCache->w = pCache->orig_w =
+ pPriv->offscreenArea->box.x2 - pCache->x;
+ pCache->h = pCache->orig_h =
+ pPriv->offscreenArea->box.y2 - pCache->y;
+
+ (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
+ pGC->alu, pGC->planemask, -1);
+
+ RectFunc = CacheBltRectHelper;
+ break;
+ default:
+ return;
+ }
+
+ XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint,
+ y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
diff --git a/xorg-server/hw/xfree86/xaa/xaaFillRect.c b/xorg-server/hw/xfree86/xaa/xaaFillRect.c index 0b83ef3ee..724ff37a2 100644 --- a/xorg-server/hw/xfree86/xaa/xaaFillRect.c +++ b/xorg-server/hw/xfree86/xaa/xaaFillRect.c @@ -1,1095 +1,1095 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include <X11/X.h> -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" - - -static void XAARenderSolidRects(GCPtr, int, BoxPtr, int, int); -static void XAARenderColor8x8Rects(GCPtr, int, BoxPtr, int, int); -static void XAARenderMono8x8Rects(GCPtr, int, BoxPtr, int, int); -static void XAARenderColorExpandRects(GCPtr, int, BoxPtr, int, int); -static void XAARenderCacheExpandRects(GCPtr, int, BoxPtr, int, int); -static void XAARenderCacheBltRects(GCPtr, int, BoxPtr, int, int); -static void XAARenderImageWriteRects(GCPtr, int, BoxPtr, int, int); -static void XAARenderPixmapCopyRects(GCPtr, int, BoxPtr, int, int); - -void -XAAPolyFillRect( - DrawablePtr pDraw, - GCPtr pGC, - int nrectFill, /* number of rectangles to fill */ - xRectangle *prectInit /* Pointer to first rectangle to fill */ -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int xorg = pDraw->x; - int yorg = pDraw->y; - int type = 0; - ClipAndRenderRectsFunc function; - - if((nrectFill <= 0) || !pGC->planemask) - return; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - switch(pGC->fillStyle) { - case FillSolid: - type = DO_SOLID; - break; - case FillStippled: - type = (*infoRec->StippledFillChooser)(pGC); - break; - case FillOpaqueStippled: - if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSolidRects && - CHECK_PLANEMASK(pGC,infoRec->FillSolidRectsFlags) && - CHECK_ROP(pGC,infoRec->FillSolidRectsFlags) && - CHECK_ROPSRC(pGC,infoRec->FillSolidRectsFlags) && - CHECK_FG(pGC,infoRec->FillSolidRectsFlags)) - type = DO_SOLID; - else - type = (*infoRec->OpaqueStippledFillChooser)(pGC); - break; - case FillTiled: - type = (*infoRec->TiledFillChooser)(pGC); - break; - } - - switch(type) { - case DO_SOLID: - function = XAARenderSolidRects; - break; - case DO_COLOR_8x8: - function = XAARenderColor8x8Rects; - break; - case DO_MONO_8x8: - function = XAARenderMono8x8Rects; - break; - case DO_CACHE_BLT: - function = XAARenderCacheBltRects; - break; - case DO_COLOR_EXPAND: - function = XAARenderColorExpandRects; - break; - case DO_CACHE_EXPAND: - function = XAARenderCacheExpandRects; - break; - case DO_IMAGE_WRITE: - function = XAARenderImageWriteRects; - break; - case DO_PIXMAP_COPY: - function = XAARenderPixmapCopyRects; - break; - default: - (*XAAFallbackOps.PolyFillRect)(pDraw, pGC, nrectFill, prectInit); - return; - } - - if(xorg | yorg) { - int n = nrectFill; - xRectangle *prect = prectInit; - - while(n--) { - prect->x += xorg; - prect->y += yorg; - prect++; - } - } - - - XAAClipAndRenderRects(pGC, function, nrectFill, prectInit, xorg, yorg); -} - - - - /*********************\ - | Solid Rects | - \*********************/ - -static void -XAARenderSolidRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - - (*infoRec->FillSolidRects) (infoRec->pScrn, - pGC->fgPixel, pGC->alu, pGC->planemask, nboxes, pClipBoxes); -} - - - /************************\ - | Mono 8x8 Rects | - \************************/ - -static void -XAARenderMono8x8Rects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAPixmapPtr pPriv; - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - case FillTiled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); - fg = pPriv->fg; bg = pPriv->bg; - break; - default: /* Muffle compiler */ - pPriv = NULL; /* Kaboom */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillMono8x8PatternRects) (infoRec->pScrn, - fg, bg, pGC->alu, pGC->planemask, - nboxes, pClipBoxes, pPriv->pattern0, pPriv->pattern1, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); -} - - /*************************\ - | Color 8x8 Rects | - \*************************/ - -static void -XAARenderColor8x8Rects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache; - PixmapPtr pPix; - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - pPix = pGC->stipple; - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - pPix = pGC->stipple; - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - case FillTiled: - pPix = pGC->tile.pixmap; - fg = -1; bg = -1; - break; - default: /* Muffle compiler */ - pPix = NULL; - fg = -1; bg = -1; - break; - } - - pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg); - (*infoRec->FillColor8x8PatternRects) (infoRec->pScrn, - pGC->alu, pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache); -} - - - /****************************\ - | Color Expand Rects | - \****************************/ - -static void -XAARenderColorExpandRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - default: /* Muffle compiler */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillColorExpandRects) (infoRec->pScrn, fg, bg, - pGC->alu, pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pGC->stipple); -} - - - /*************************\ - | Cache Blt Rects | - \*************************/ - -static void -XAARenderCacheBltRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache; - - switch(pGC->fillStyle) { - case FillStippled: - pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, - pGC->fgPixel, -1); - break; - case FillOpaqueStippled: - pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, - pGC->fgPixel, pGC->bgPixel); - break; - case FillTiled: - pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); - break; - default: /* Muffle compiler */ - pCache = NULL; - break; - } - - (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu, - pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache); -} - - - /****************************\ - | Cache Expand Rects | - \****************************/ - -static void -XAARenderCacheExpandRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - default: /* Muffle compiler */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillCacheExpandRects) (infoRec->pScrn, fg, bg, - pGC->alu, pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pGC->stipple); -} - - - - /***************************\ - | Image Write Rects | - \***************************/ - -static void -XAARenderImageWriteRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - - (*infoRec->FillImageWriteRects) (infoRec->pScrn, pGC->alu, - pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pGC->tile.pixmap); -} - - - - /***************************\ - | Pixmap Copy Rects | - \***************************/ - -static void -XAARenderPixmapCopyRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec); - XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); - - pCache->x = pPriv->offscreenArea->box.x1; - pCache->y = pPriv->offscreenArea->box.y1; - pCache->w = pCache->orig_w = - pPriv->offscreenArea->box.x2 - pCache->x; - pCache->h = pCache->orig_h = - pPriv->offscreenArea->box.y2 - pCache->y; - pCache->trans_color = -1; - - (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu, - pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pCache); -} - - - - /************\ - | Solid | - \************/ - -void -XAAFillSolidRects( - ScrnInfoPtr pScrn, - int fg, int rop, - unsigned int planemask, - int nBox, /* number of rectangles to fill */ - BoxPtr pBox /* Pointer to first rectangle to fill */ -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask); - while(nBox--) { - (*infoRec->SubsequentSolidFillRect)(pScrn, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - pBox++; - } - SET_SYNC_FLAG(infoRec); -} - - - - - /*********************\ - | 8x8 Mono Patterns | - \*********************/ - - -void -XAAFillMono8x8PatternRectsScreenOrigin( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int pattern0, int pattern1, - int xorigin, int yorigin -) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pattern0, paty = pattern1; - int xorg = (-xorigin) & 0x07; - int yorg = (-yorigin) & 0x07; - - - if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) { - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } - } else { - XAACacheInfoPtr pCache = - (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); - patx = pCache->x; paty = pCache->y; - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - patx += pCache->offsets[slot].x; - paty += pCache->offsets[slot].y; - xorg = patx; yorg = paty; - } - } - - (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, - fg, bg, rop, planemask); - - while(nBox--) { - (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, - xorg, yorg, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - pBox++; - } - SET_SYNC_FLAG(infoRec); -} - -void -XAAFillMono8x8PatternRects( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int pattern0, int pattern1, - int xorigin, int yorigin -) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pattern0, paty = pattern1; - int xorg, yorg; - XAACacheInfoPtr pCache = NULL; - - - if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){ - pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); - patx = pCache->x; paty = pCache->y; - } - - - (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, - fg, bg, rop, planemask); - - - while(nBox--) { - xorg = (pBox->x1 - xorigin) & 0x07; - yorg = (pBox->y1 - yorigin) & 0x07; - - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS) { - patx = pattern0; paty = pattern1; - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } else { - int slot = (yorg << 3) + xorg; - xorg = patx + pCache->offsets[slot].x; - yorg = paty + pCache->offsets[slot].y; - } - } - - (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, - xorg, yorg, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - pBox++; - } - - SET_SYNC_FLAG(infoRec); -} - - - /**********************\ - | 8x8 Color Patterns | - \**********************/ - - -void -XAAFillColor8x8PatternRectsScreenOrigin( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int xorigin, int yorigin, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pCache->x, paty = pCache->y; - int xorg = (-xorigin) & 0x07; - int yorg = (-yorigin) & 0x07; - - if(!(infoRec->Color8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - paty += pCache->offsets[slot].y; - patx += pCache->offsets[slot].x; - xorg = patx; yorg = paty; - } - - (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty, - rop, planemask, pCache->trans_color); - - while(nBox--) { - (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, - xorg, yorg, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - pBox++; - } - SET_SYNC_FLAG(infoRec); -} - -void -XAAFillColor8x8PatternRects( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int xorigin, int yorigin, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int xorg, yorg; - - (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y, - rop, planemask, pCache->trans_color); - - while(nBox--) { - xorg = (pBox->x1 - xorigin) & 0x07; - yorg = (pBox->y1 - yorigin) & 0x07; - - if(!(infoRec->Color8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - yorg = pCache->y + pCache->offsets[slot].y; - xorg = pCache->x + pCache->offsets[slot].x; - } - - (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, - xorg, yorg, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - pBox++; - } - - SET_SYNC_FLAG(infoRec); -} - - - /***************\ - | Cache Blits | - \***************/ - -void -XAAFillCacheBltRects( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h; - - (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask, - pCache->trans_color); - - while(nBox--) { - y = pBox->y1; - phaseY = (y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - phaseX = (pBox->x1 - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - height = pBox->y2 - y; - width = pBox->x2 - pBox->x1; - -#if 0 - if (rop == GXcopy) { - while(1) { - w = width; skipleft = phaseX; x = pBox->x1; - blit_h = pCache->h - phaseY; - if(blit_h > height) blit_h = height; - - while(1) { - blit_w = pCache->w - skipleft; - if(blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, - pCache->x + skipleft, pCache->y + phaseY, - x, y, blit_w, blit_h); - w -= blit_w; - if(!w) break; - x += blit_w; - skipleft = (skipleft + blit_w) % pCache->orig_w; - if(blit_w >= pCache->orig_w) break; - } - - /* Expand horizontally */ - if (w) { - skipleft -= phaseX; - if (skipleft < 0) skipleft += pCache->orig_w; - blit_w = x - pBox->x1 - skipleft; - while(w) { - if (blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, - pBox->x1 + skipleft, y, x, y, blit_w, blit_h); - w -= blit_w; - x += blit_w; - blit_w <<= 1; - } - } - - height -= blit_h; - if(!height) break; - y += blit_h; - phaseY = (phaseY + blit_h) % pCache->orig_h; - if(blit_h >= pCache->orig_h) break; - } - - /* Expand vertically */ - if (height) { - blit_w = pBox->x2 - pBox->x1; - phaseY -= (pBox->y1 - yorg) % pCache->orig_h; - if (phaseY < 0) phaseY += pCache->orig_h; - blit_h = y - pBox->y1 - phaseY; - while(height) { - if (blit_h > height) blit_h = height; - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pBox->x1, - pBox->y1 + phaseY, pBox->x1, y, blit_w, blit_h); - height -= blit_h; - y += blit_h; - blit_h <<= 1; - } - } - } else -#endif - { - while(1) { - w = width; skipleft = phaseX; x = pBox->x1; - blit_h = pCache->h - phaseY; - if(blit_h > height) blit_h = height; - - while(1) { - blit_w = pCache->w - skipleft; - if(blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, - pCache->x + skipleft, pCache->y + phaseY, - x, y, blit_w, blit_h); - w -= blit_w; - if(!w) break; - x += blit_w; - skipleft = (skipleft + blit_w) % pCache->orig_w; - } - height -= blit_h; - if(!height) break; - y += blit_h; - phaseY = (phaseY + blit_h) % pCache->orig_h; - } - } - pBox++; - } - - SET_SYNC_FLAG(infoRec); -} - - - - - /*******************\ - | Cache Expansion | - \*******************/ - - - -void -XAAFillCacheExpandRects( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int xorg, int yorg, - PixmapPtr pPix -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h; - int cacheWidth; - XAACacheInfoPtr pCache; - - pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix); - - cacheWidth = (pCache->w * pScrn->bitsPerPixel) / - infoRec->CacheColorExpandDensity; - - (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop, - planemask); - - while(nBox--) { - y = pBox->y1; - phaseY = (y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - phaseX = (pBox->x1 - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - height = pBox->y2 - y; - width = pBox->x2 - pBox->x1; - - while(1) { - w = width; skipleft = phaseX; x = pBox->x1; - blit_h = pCache->h - phaseY; - if(blit_h > height) blit_h = height; - - while(1) { - blit_w = cacheWidth - skipleft; - if(blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenColorExpandFill)( - pScrn, x, y, blit_w, blit_h, - pCache->x, pCache->y + phaseY, skipleft); - w -= blit_w; - if(!w) break; - x += blit_w; - skipleft = (skipleft + blit_w) % pCache->orig_w; - } - height -= blit_h; - if(!height) break; - y += blit_h; - phaseY = (phaseY + blit_h) % pCache->orig_h; - } - pBox++; - } - - SET_SYNC_FLAG(infoRec); -} - - - /******************\ - | Image Writes | - \******************/ - - - -/* This requires all LEFT_EDGE clipping. You get too many problems - with reading past the edge of the pattern otherwise */ - -static void -WriteColumn( - ScrnInfoPtr pScrn, - unsigned char *pSrc, - int x, int y, int w, int h, - int xoff, int yoff, - int pHeight, - int srcwidth, - int Bpp -) { - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - unsigned char *src; - Bool PlusOne = FALSE; - int skipleft, dwords; - - pSrc += (Bpp * xoff); - - if((skipleft = (long)pSrc & 0x03L)) { - if(Bpp == 3) - skipleft = 4 - skipleft; - else - skipleft /= Bpp; - - x -= skipleft; - w += skipleft; - - if(Bpp == 3) - pSrc -= 3 * skipleft; - else /* is this Alpha friendly ? */ - pSrc = (unsigned char*)((long)pSrc & ~0x03L); - } - - src = pSrc + (yoff * srcwidth); - - dwords = bytes_to_int32(w * Bpp); - - if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) && - ((dwords * h) & 0x01)) { - PlusOne = TRUE; - } - - (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, skipleft); - - if(dwords > infoRec->ImageWriteRange) { - while(h--) { - XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase, - (CARD32*)src, dwords); - src += srcwidth; - yoff++; - if(yoff >= pHeight) { - yoff = 0; - src = pSrc; - } - } - } else { - if(srcwidth == (dwords << 2)) { - int maxLines = infoRec->ImageWriteRange/dwords; - int step; - - while(h) { - step = pHeight - yoff; - if(step > maxLines) step = maxLines; - if(step > h) step = h; - - XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, - (CARD32*)src, dwords * step); - - src += (srcwidth * step); - yoff += step; - if(yoff >= pHeight) { - yoff = 0; - src = pSrc; - } - h -= step; - } - } else { - while(h--) { - XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, - (CARD32*)src, dwords); - src += srcwidth; - yoff++; - if(yoff >= pHeight) { - yoff = 0; - src = pSrc; - } - } - } - } - - if(PlusOne) { - CARD32* base = (CARD32*)infoRec->ImageWriteBase; - *base = 0x00000000; - } -} - -void -XAAFillImageWriteRects( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int xorg, int yorg, - PixmapPtr pPix -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, phaseY, phaseX, height, width, blit_w; - int pHeight = pPix->drawable.height; - int pWidth = pPix->drawable.width; - int Bpp = pPix->drawable.bitsPerPixel >> 3; - int srcwidth = pPix->devKind; - - (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, -1, - pPix->drawable.bitsPerPixel, pPix->drawable.depth); - - while(nBox--) { - x = pBox->x1; - phaseY = (pBox->y1 - yorg) % pHeight; - if(phaseY < 0) phaseY += pHeight; - phaseX = (x - xorg) % pWidth; - if(phaseX < 0) phaseX += pWidth; - height = pBox->y2 - pBox->y1; - width = pBox->x2 - x; - - while(1) { - blit_w = pWidth - phaseX; - if(blit_w > width) blit_w = width; - - WriteColumn(pScrn, pPix->devPrivate.ptr, x, pBox->y1, - blit_w, height, phaseX, phaseY, pHeight, srcwidth, Bpp); - - width -= blit_w; - if(!width) break; - x += blit_w; - phaseX = (phaseX + blit_w) % pWidth; - } - pBox++; - } - - if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE) - (*infoRec->Sync)(pScrn); - else SET_SYNC_FLAG(infoRec); -} - - - /*************\ - | Utilities | - \*************/ - - -void -XAAClipAndRenderRects( - GCPtr pGC, - ClipAndRenderRectsFunc BoxFunc, - int nrectFill, - xRectangle *prect, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int Right, Bottom, MaxBoxes; - BoxPtr pextent, pboxClipped, pboxClippedBase; - - MaxBoxes = infoRec->PreAllocSize/sizeof(BoxRec); - pboxClippedBase = (BoxPtr)infoRec->PreAllocMem; - pboxClipped = pboxClippedBase; - - if (REGION_NUM_RECTS(pGC->pCompositeClip) == 1) { - pextent = REGION_RECTS(pGC->pCompositeClip); - while (nrectFill--) { - pboxClipped->x1 = max(pextent->x1, prect->x); - pboxClipped->y1 = max(pextent->y1, prect->y); - - Right = (int)prect->x + (int)prect->width; - pboxClipped->x2 = min(pextent->x2, Right); - - Bottom = (int)prect->y + (int)prect->height; - pboxClipped->y2 = min(pextent->y2, Bottom); - - prect++; - if ((pboxClipped->x1 < pboxClipped->x2) && - (pboxClipped->y1 < pboxClipped->y2)) { - pboxClipped++; - if(pboxClipped >= (pboxClippedBase + MaxBoxes)) { - (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg); - pboxClipped = pboxClippedBase; - } - } - } - } else { - pextent = REGION_EXTENTS(pGC->pScreen, pGC->pCompositeClip); - while (nrectFill--) { - int n; - BoxRec box, *pbox; - - box.x1 = max(pextent->x1, prect->x); - box.y1 = max(pextent->y1, prect->y); - - Right = (int)prect->x + (int)prect->width; - box.x2 = min(pextent->x2, Right); - - Bottom = (int)prect->y + (int)prect->height; - box.y2 = min(pextent->y2, Bottom); - - prect++; - - if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) - continue; - - n = REGION_NUM_RECTS (pGC->pCompositeClip); - pbox = REGION_RECTS(pGC->pCompositeClip); - - /* clip the rectangle to each box in the clip region - this is logically equivalent to calling Intersect() - */ - while(n--) { - pboxClipped->x1 = max(box.x1, pbox->x1); - pboxClipped->y1 = max(box.y1, pbox->y1); - pboxClipped->x2 = min(box.x2, pbox->x2); - pboxClipped->y2 = min(box.y2, pbox->y2); - pbox++; - - /* see if clipping left anything */ - if(pboxClipped->x1 < pboxClipped->x2 && - pboxClipped->y1 < pboxClipped->y2) { - pboxClipped++; - if(pboxClipped >= (pboxClippedBase + MaxBoxes)) { - (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg); - pboxClipped = pboxClippedBase; - } - } - } - } - } - - if(pboxClipped != pboxClippedBase) - (*BoxFunc)(pGC, pboxClipped - pboxClippedBase, pboxClippedBase, - xorg, yorg); -} - - -int -XAAGetRectClipBoxes( - GCPtr pGC, - BoxPtr pboxClippedBase, - int nrectFill, - xRectangle *prectInit -){ - int Right, Bottom; - BoxPtr pextent, pboxClipped = pboxClippedBase; - xRectangle *prect = prectInit; - RegionPtr prgnClip = pGC->pCompositeClip; - - if (REGION_NUM_RECTS(prgnClip) == 1) { - pextent = REGION_RECTS(prgnClip); - while (nrectFill--) { - pboxClipped->x1 = max(pextent->x1, prect->x); - pboxClipped->y1 = max(pextent->y1, prect->y); - - Right = (int)prect->x + (int)prect->width; - pboxClipped->x2 = min(pextent->x2, Right); - - Bottom = (int)prect->y + (int)prect->height; - pboxClipped->y2 = min(pextent->y2, Bottom); - - prect++; - if ((pboxClipped->x1 < pboxClipped->x2) && - (pboxClipped->y1 < pboxClipped->y2)) { - pboxClipped++; - } - } - } else { - pextent = REGION_EXTENTS(pGC->pScreen, prgnClip); - while (nrectFill--) { - int n; - BoxRec box, *pbox; - - box.x1 = max(pextent->x1, prect->x); - box.y1 = max(pextent->y1, prect->y); - - Right = (int)prect->x + (int)prect->width; - box.x2 = min(pextent->x2, Right); - - Bottom = (int)prect->y + (int)prect->height; - box.y2 = min(pextent->y2, Bottom); - - prect++; - - if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) - continue; - - n = REGION_NUM_RECTS (prgnClip); - pbox = REGION_RECTS(prgnClip); - - /* clip the rectangle to each box in the clip region - this is logically equivalent to calling Intersect() - */ - while(n--) { - pboxClipped->x1 = max(box.x1, pbox->x1); - pboxClipped->y1 = max(box.y1, pbox->y1); - pboxClipped->x2 = min(box.x2, pbox->x2); - pboxClipped->y2 = min(box.y2, pbox->y2); - pbox++; - - /* see if clipping left anything */ - if(pboxClipped->x1 < pboxClipped->x2 && - pboxClipped->y1 < pboxClipped->y2) { - pboxClipped++; - } - } - } - } - - return(pboxClipped - pboxClippedBase); -} - +
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+
+static void XAARenderSolidRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderColor8x8Rects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderMono8x8Rects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderColorExpandRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderCacheExpandRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderCacheBltRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderImageWriteRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderPixmapCopyRects(GCPtr, int, BoxPtr, int, int);
+
+void
+XAAPolyFillRect(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nrectFill, /* number of rectangles to fill */
+ xRectangle *prectInit /* Pointer to first rectangle to fill */
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int xorg = pDraw->x;
+ int yorg = pDraw->y;
+ int type = 0;
+ ClipAndRenderRectsFunc function;
+
+ if((nrectFill <= 0) || !pGC->planemask)
+ return;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ switch(pGC->fillStyle) {
+ case FillSolid:
+ type = DO_SOLID;
+ break;
+ case FillStippled:
+ type = (*infoRec->StippledFillChooser)(pGC);
+ break;
+ case FillOpaqueStippled:
+ if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSolidRects &&
+ CHECK_PLANEMASK(pGC,infoRec->FillSolidRectsFlags) &&
+ CHECK_ROP(pGC,infoRec->FillSolidRectsFlags) &&
+ CHECK_ROPSRC(pGC,infoRec->FillSolidRectsFlags) &&
+ CHECK_FG(pGC,infoRec->FillSolidRectsFlags))
+ type = DO_SOLID;
+ else
+ type = (*infoRec->OpaqueStippledFillChooser)(pGC);
+ break;
+ case FillTiled:
+ type = (*infoRec->TiledFillChooser)(pGC);
+ break;
+ }
+
+ switch(type) {
+ case DO_SOLID:
+ function = XAARenderSolidRects;
+ break;
+ case DO_COLOR_8x8:
+ function = XAARenderColor8x8Rects;
+ break;
+ case DO_MONO_8x8:
+ function = XAARenderMono8x8Rects;
+ break;
+ case DO_CACHE_BLT:
+ function = XAARenderCacheBltRects;
+ break;
+ case DO_COLOR_EXPAND:
+ function = XAARenderColorExpandRects;
+ break;
+ case DO_CACHE_EXPAND:
+ function = XAARenderCacheExpandRects;
+ break;
+ case DO_IMAGE_WRITE:
+ function = XAARenderImageWriteRects;
+ break;
+ case DO_PIXMAP_COPY:
+ function = XAARenderPixmapCopyRects;
+ break;
+ default:
+ (*XAAFallbackOps.PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
+ return;
+ }
+
+ if(xorg | yorg) {
+ int n = nrectFill;
+ xRectangle *prect = prectInit;
+
+ while(n--) {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+
+ XAAClipAndRenderRects(pGC, function, nrectFill, prectInit, xorg, yorg);
+}
+
+
+
+ /*********************\
+ | Solid Rects |
+ \*********************/
+
+static void
+XAARenderSolidRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ (*infoRec->FillSolidRects) (infoRec->pScrn,
+ pGC->fgPixel, pGC->alu, pGC->planemask, nboxes, pClipBoxes);
+}
+
+
+ /************************\
+ | Mono 8x8 Rects |
+ \************************/
+
+static void
+XAARenderMono8x8Rects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv;
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+ fg = pPriv->fg; bg = pPriv->bg;
+ break;
+ default: /* Muffle compiler */
+ pPriv = NULL; /* Kaboom */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillMono8x8PatternRects) (infoRec->pScrn,
+ fg, bg, pGC->alu, pGC->planemask,
+ nboxes, pClipBoxes, pPriv->pattern0, pPriv->pattern1,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
+}
+
+ /*************************\
+ | Color 8x8 Rects |
+ \*************************/
+
+static void
+XAARenderColor8x8Rects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+ PixmapPtr pPix;
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPix = pGC->tile.pixmap;
+ fg = -1; bg = -1;
+ break;
+ default: /* Muffle compiler */
+ pPix = NULL;
+ fg = -1; bg = -1;
+ break;
+ }
+
+ pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg);
+ (*infoRec->FillColor8x8PatternRects) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache);
+}
+
+
+ /****************************\
+ | Color Expand Rects |
+ \****************************/
+
+static void
+XAARenderColorExpandRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillColorExpandRects) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pGC->stipple);
+}
+
+
+ /*************************\
+ | Cache Blt Rects |
+ \*************************/
+
+static void
+XAARenderCacheBltRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, -1);
+ break;
+ case FillOpaqueStippled:
+ pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, pGC->bgPixel);
+ break;
+ case FillTiled:
+ pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
+ break;
+ default: /* Muffle compiler */
+ pCache = NULL;
+ break;
+ }
+
+ (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu,
+ pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache);
+}
+
+
+ /****************************\
+ | Cache Expand Rects |
+ \****************************/
+
+static void
+XAARenderCacheExpandRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillCacheExpandRects) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pGC->stipple);
+}
+
+
+
+ /***************************\
+ | Image Write Rects |
+ \***************************/
+
+static void
+XAARenderImageWriteRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ (*infoRec->FillImageWriteRects) (infoRec->pScrn, pGC->alu,
+ pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pGC->tile.pixmap);
+}
+
+
+
+ /***************************\
+ | Pixmap Copy Rects |
+ \***************************/
+
+static void
+XAARenderPixmapCopyRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+
+ pCache->x = pPriv->offscreenArea->box.x1;
+ pCache->y = pPriv->offscreenArea->box.y1;
+ pCache->w = pCache->orig_w =
+ pPriv->offscreenArea->box.x2 - pCache->x;
+ pCache->h = pCache->orig_h =
+ pPriv->offscreenArea->box.y2 - pCache->y;
+ pCache->trans_color = -1;
+
+ (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu,
+ pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pCache);
+}
+
+
+
+ /************\
+ | Solid |
+ \************/
+
+void
+XAAFillSolidRects(
+ ScrnInfoPtr pScrn,
+ int fg, int rop,
+ unsigned int planemask,
+ int nBox, /* number of rectangles to fill */
+ BoxPtr pBox /* Pointer to first rectangle to fill */
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask);
+ while(nBox--) {
+ (*infoRec->SubsequentSolidFillRect)(pScrn, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+
+ /*********************\
+ | 8x8 Mono Patterns |
+ \*********************/
+
+
+void
+XAAFillMono8x8PatternRectsScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int pattern0, int pattern1,
+ int xorigin, int yorigin
+)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+
+ if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ }
+ } else {
+ XAACacheInfoPtr pCache =
+ (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
+ patx = pCache->x; paty = pCache->y;
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx; yorg = paty;
+ }
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+ while(nBox--) {
+ (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
+ xorg, yorg, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAFillMono8x8PatternRects(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int pattern0, int pattern1,
+ int xorigin, int yorigin
+)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg, yorg;
+ XAACacheInfoPtr pCache = NULL;
+
+
+ if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){
+ pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
+ patx = pCache->x; paty = pCache->y;
+ }
+
+
+ (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+
+ while(nBox--) {
+ xorg = (pBox->x1 - xorigin) & 0x07;
+ yorg = (pBox->y1 - yorigin) & 0x07;
+
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ patx = pattern0; paty = pattern1;
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ } else {
+ int slot = (yorg << 3) + xorg;
+ xorg = patx + pCache->offsets[slot].x;
+ yorg = paty + pCache->offsets[slot].y;
+ }
+ }
+
+ (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
+ xorg, yorg, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+ /**********************\
+ | 8x8 Color Patterns |
+ \**********************/
+
+
+void
+XAAFillColor8x8PatternRectsScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorigin, int yorigin,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pCache->x, paty = pCache->y;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+ if(!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ paty += pCache->offsets[slot].y;
+ patx += pCache->offsets[slot].x;
+ xorg = patx; yorg = paty;
+ }
+
+ (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty,
+ rop, planemask, pCache->trans_color);
+
+ while(nBox--) {
+ (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
+ xorg, yorg, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAFillColor8x8PatternRects(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorigin, int yorigin,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int xorg, yorg;
+
+ (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y,
+ rop, planemask, pCache->trans_color);
+
+ while(nBox--) {
+ xorg = (pBox->x1 - xorigin) & 0x07;
+ yorg = (pBox->y1 - yorigin) & 0x07;
+
+ if(!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ yorg = pCache->y + pCache->offsets[slot].y;
+ xorg = pCache->x + pCache->offsets[slot].x;
+ }
+
+ (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
+ xorg, yorg, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+ /***************\
+ | Cache Blits |
+ \***************/
+
+void
+XAAFillCacheBltRects(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h;
+
+ (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask,
+ pCache->trans_color);
+
+ while(nBox--) {
+ y = pBox->y1;
+ phaseY = (y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+ phaseX = (pBox->x1 - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+ height = pBox->y2 - y;
+ width = pBox->x2 - pBox->x1;
+
+#if 0
+ if (rop == GXcopy) {
+ while(1) {
+ w = width; skipleft = phaseX; x = pBox->x1;
+ blit_h = pCache->h - phaseY;
+ if(blit_h > height) blit_h = height;
+
+ while(1) {
+ blit_w = pCache->w - skipleft;
+ if(blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
+ pCache->x + skipleft, pCache->y + phaseY,
+ x, y, blit_w, blit_h);
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ if(blit_w >= pCache->orig_w) break;
+ }
+
+ /* Expand horizontally */
+ if (w) {
+ skipleft -= phaseX;
+ if (skipleft < 0) skipleft += pCache->orig_w;
+ blit_w = x - pBox->x1 - skipleft;
+ while(w) {
+ if (blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
+ pBox->x1 + skipleft, y, x, y, blit_w, blit_h);
+ w -= blit_w;
+ x += blit_w;
+ blit_w <<= 1;
+ }
+ }
+
+ height -= blit_h;
+ if(!height) break;
+ y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ if(blit_h >= pCache->orig_h) break;
+ }
+
+ /* Expand vertically */
+ if (height) {
+ blit_w = pBox->x2 - pBox->x1;
+ phaseY -= (pBox->y1 - yorg) % pCache->orig_h;
+ if (phaseY < 0) phaseY += pCache->orig_h;
+ blit_h = y - pBox->y1 - phaseY;
+ while(height) {
+ if (blit_h > height) blit_h = height;
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pBox->x1,
+ pBox->y1 + phaseY, pBox->x1, y, blit_w, blit_h);
+ height -= blit_h;
+ y += blit_h;
+ blit_h <<= 1;
+ }
+ }
+ } else
+#endif
+ {
+ while(1) {
+ w = width; skipleft = phaseX; x = pBox->x1;
+ blit_h = pCache->h - phaseY;
+ if(blit_h > height) blit_h = height;
+
+ while(1) {
+ blit_w = pCache->w - skipleft;
+ if(blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
+ pCache->x + skipleft, pCache->y + phaseY,
+ x, y, blit_w, blit_h);
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ height -= blit_h;
+ if(!height) break;
+ y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+ }
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+
+ /*******************\
+ | Cache Expansion |
+ \*******************/
+
+
+
+void
+XAAFillCacheExpandRects(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h;
+ int cacheWidth;
+ XAACacheInfoPtr pCache;
+
+ pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix);
+
+ cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
+ infoRec->CacheColorExpandDensity;
+
+ (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop,
+ planemask);
+
+ while(nBox--) {
+ y = pBox->y1;
+ phaseY = (y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+ phaseX = (pBox->x1 - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+ height = pBox->y2 - y;
+ width = pBox->x2 - pBox->x1;
+
+ while(1) {
+ w = width; skipleft = phaseX; x = pBox->x1;
+ blit_h = pCache->h - phaseY;
+ if(blit_h > height) blit_h = height;
+
+ while(1) {
+ blit_w = cacheWidth - skipleft;
+ if(blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenColorExpandFill)(
+ pScrn, x, y, blit_w, blit_h,
+ pCache->x, pCache->y + phaseY, skipleft);
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ height -= blit_h;
+ if(!height) break;
+ y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+ /******************\
+ | Image Writes |
+ \******************/
+
+
+
+/* This requires all LEFT_EDGE clipping. You get too many problems
+ with reading past the edge of the pattern otherwise */
+
+static void
+WriteColumn(
+ ScrnInfoPtr pScrn,
+ unsigned char *pSrc,
+ int x, int y, int w, int h,
+ int xoff, int yoff,
+ int pHeight,
+ int srcwidth,
+ int Bpp
+) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ unsigned char *src;
+ Bool PlusOne = FALSE;
+ int skipleft, dwords;
+
+ pSrc += (Bpp * xoff);
+
+ if((skipleft = (long)pSrc & 0x03L)) {
+ if(Bpp == 3)
+ skipleft = 4 - skipleft;
+ else
+ skipleft /= Bpp;
+
+ x -= skipleft;
+ w += skipleft;
+
+ if(Bpp == 3)
+ pSrc -= 3 * skipleft;
+ else /* is this Alpha friendly ? */
+ pSrc = (unsigned char*)((long)pSrc & ~0x03L);
+ }
+
+ src = pSrc + (yoff * srcwidth);
+
+ dwords = bytes_to_int32(w * Bpp);
+
+ if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) &&
+ ((dwords * h) & 0x01)) {
+ PlusOne = TRUE;
+ }
+
+ (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, skipleft);
+
+ if(dwords > infoRec->ImageWriteRange) {
+ while(h--) {
+ XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase,
+ (CARD32*)src, dwords);
+ src += srcwidth;
+ yoff++;
+ if(yoff >= pHeight) {
+ yoff = 0;
+ src = pSrc;
+ }
+ }
+ } else {
+ if(srcwidth == (dwords << 2)) {
+ int maxLines = infoRec->ImageWriteRange/dwords;
+ int step;
+
+ while(h) {
+ step = pHeight - yoff;
+ if(step > maxLines) step = maxLines;
+ if(step > h) step = h;
+
+ XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
+ (CARD32*)src, dwords * step);
+
+ src += (srcwidth * step);
+ yoff += step;
+ if(yoff >= pHeight) {
+ yoff = 0;
+ src = pSrc;
+ }
+ h -= step;
+ }
+ } else {
+ while(h--) {
+ XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
+ (CARD32*)src, dwords);
+ src += srcwidth;
+ yoff++;
+ if(yoff >= pHeight) {
+ yoff = 0;
+ src = pSrc;
+ }
+ }
+ }
+ }
+
+ if(PlusOne) {
+ CARD32* base = (CARD32*)infoRec->ImageWriteBase;
+ *base = 0x00000000;
+ }
+}
+
+void
+XAAFillImageWriteRects(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, phaseY, phaseX, height, width, blit_w;
+ int pHeight = pPix->drawable.height;
+ int pWidth = pPix->drawable.width;
+ int Bpp = pPix->drawable.bitsPerPixel >> 3;
+ int srcwidth = pPix->devKind;
+
+ (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, -1,
+ pPix->drawable.bitsPerPixel, pPix->drawable.depth);
+
+ while(nBox--) {
+ x = pBox->x1;
+ phaseY = (pBox->y1 - yorg) % pHeight;
+ if(phaseY < 0) phaseY += pHeight;
+ phaseX = (x - xorg) % pWidth;
+ if(phaseX < 0) phaseX += pWidth;
+ height = pBox->y2 - pBox->y1;
+ width = pBox->x2 - x;
+
+ while(1) {
+ blit_w = pWidth - phaseX;
+ if(blit_w > width) blit_w = width;
+
+ WriteColumn(pScrn, pPix->devPrivate.ptr, x, pBox->y1,
+ blit_w, height, phaseX, phaseY, pHeight, srcwidth, Bpp);
+
+ width -= blit_w;
+ if(!width) break;
+ x += blit_w;
+ phaseX = (phaseX + blit_w) % pWidth;
+ }
+ pBox++;
+ }
+
+ if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE)
+ (*infoRec->Sync)(pScrn);
+ else SET_SYNC_FLAG(infoRec);
+}
+
+
+ /*************\
+ | Utilities |
+ \*************/
+
+
+void
+XAAClipAndRenderRects(
+ GCPtr pGC,
+ ClipAndRenderRectsFunc BoxFunc,
+ int nrectFill,
+ xRectangle *prect,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int Right, Bottom, MaxBoxes;
+ BoxPtr pextent, pboxClipped, pboxClippedBase;
+
+ MaxBoxes = infoRec->PreAllocSize/sizeof(BoxRec);
+ pboxClippedBase = (BoxPtr)infoRec->PreAllocMem;
+ pboxClipped = pboxClippedBase;
+
+ if (RegionNumRects(pGC->pCompositeClip) == 1) {
+ pextent = RegionRects(pGC->pCompositeClip);
+ while (nrectFill--) {
+ pboxClipped->x1 = max(pextent->x1, prect->x);
+ pboxClipped->y1 = max(pextent->y1, prect->y);
+
+ Right = (int)prect->x + (int)prect->width;
+ pboxClipped->x2 = min(pextent->x2, Right);
+
+ Bottom = (int)prect->y + (int)prect->height;
+ pboxClipped->y2 = min(pextent->y2, Bottom);
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2)) {
+ pboxClipped++;
+ if(pboxClipped >= (pboxClippedBase + MaxBoxes)) {
+ (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg);
+ pboxClipped = pboxClippedBase;
+ }
+ }
+ }
+ } else {
+ pextent = RegionExtents(pGC->pCompositeClip);
+ while (nrectFill--) {
+ int n;
+ BoxRec box, *pbox;
+
+ box.x1 = max(pextent->x1, prect->x);
+ box.y1 = max(pextent->y1, prect->y);
+
+ Right = (int)prect->x + (int)prect->width;
+ box.x2 = min(pextent->x2, Right);
+
+ Bottom = (int)prect->y + (int)prect->height;
+ box.y2 = min(pextent->y2, Bottom);
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = RegionNumRects (pGC->pCompositeClip);
+ pbox = RegionRects(pGC->pCompositeClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--) {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2) {
+ pboxClipped++;
+ if(pboxClipped >= (pboxClippedBase + MaxBoxes)) {
+ (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg);
+ pboxClipped = pboxClippedBase;
+ }
+ }
+ }
+ }
+ }
+
+ if(pboxClipped != pboxClippedBase)
+ (*BoxFunc)(pGC, pboxClipped - pboxClippedBase, pboxClippedBase,
+ xorg, yorg);
+}
+
+
+int
+XAAGetRectClipBoxes(
+ GCPtr pGC,
+ BoxPtr pboxClippedBase,
+ int nrectFill,
+ xRectangle *prectInit
+){
+ int Right, Bottom;
+ BoxPtr pextent, pboxClipped = pboxClippedBase;
+ xRectangle *prect = prectInit;
+ RegionPtr prgnClip = pGC->pCompositeClip;
+
+ if (RegionNumRects(prgnClip) == 1) {
+ pextent = RegionRects(prgnClip);
+ while (nrectFill--) {
+ pboxClipped->x1 = max(pextent->x1, prect->x);
+ pboxClipped->y1 = max(pextent->y1, prect->y);
+
+ Right = (int)prect->x + (int)prect->width;
+ pboxClipped->x2 = min(pextent->x2, Right);
+
+ Bottom = (int)prect->y + (int)prect->height;
+ pboxClipped->y2 = min(pextent->y2, Bottom);
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2)) {
+ pboxClipped++;
+ }
+ }
+ } else {
+ pextent = RegionExtents(prgnClip);
+ while (nrectFill--) {
+ int n;
+ BoxRec box, *pbox;
+
+ box.x1 = max(pextent->x1, prect->x);
+ box.y1 = max(pextent->y1, prect->y);
+
+ Right = (int)prect->x + (int)prect->width;
+ box.x2 = min(pextent->x2, Right);
+
+ Bottom = (int)prect->y + (int)prect->height;
+ box.y2 = min(pextent->y2, Bottom);
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = RegionNumRects (prgnClip);
+ pbox = RegionRects(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--) {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2) {
+ pboxClipped++;
+ }
+ }
+ }
+ }
+
+ return pboxClipped - pboxClippedBase;
+}
+
diff --git a/xorg-server/hw/xfree86/xaa/xaaGC.c b/xorg-server/hw/xfree86/xaa/xaaGC.c index d029d982b..4bd3750cb 100644 --- a/xorg-server/hw/xfree86/xaa/xaaGC.c +++ b/xorg-server/hw/xfree86/xaa/xaaGC.c @@ -243,8 +243,7 @@ XAADestroyGC(GCPtr pGC) if(pGCPriv->XAAOps != &XAAFallbackOps)
free(pGCPriv->XAAOps);
- if(pGCPriv->DashPattern)
- free(pGCPriv->DashPattern);
+ free(pGCPriv->DashPattern);
(*pGC->funcs->DestroyGC)(pGC);
XAA_GC_FUNC_EPILOGUE (pGC);
diff --git a/xorg-server/hw/xfree86/xaa/xaaImage.c b/xorg-server/hw/xfree86/xaa/xaaImage.c index c8d98c7d0..1967c5e0e 100644 --- a/xorg-server/hw/xfree86/xaa/xaaImage.c +++ b/xorg-server/hw/xfree86/xaa/xaaImage.c @@ -406,7 +406,7 @@ XAAPutImage( Bool depthBug = FALSE;
if(!w || !h) return;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
depthBug = XAA_DEPTH_BUG(pGC);
@@ -431,7 +431,7 @@ XAAPutImage( !(infoRec->WriteBitmapFlags & NO_PLANEMASK) &&
!(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))){
- int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip);
+ int MaxBoxes = RegionNumRects(pGC->pCompositeClip);
BoxPtr pbox, pClipBoxes;
int nboxes, srcx, srcy, srcwidth;
xRectangle TheRect;
diff --git a/xorg-server/hw/xfree86/xaa/xaaInit.c b/xorg-server/hw/xfree86/xaa/xaaInit.c index 58efb6a82..a4b235acf 100644 --- a/xorg-server/hw/xfree86/xaa/xaaInit.c +++ b/xorg-server/hw/xfree86/xaa/xaaInit.c @@ -42,12 +42,12 @@ static int XAASetDGAMode(int index, int num, DGADevicePtr devRet); static void XAAEnableDisableFBAccess (int index, Bool enable);
static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask);
-static int XAAScreenKeyIndex;
-static DevPrivateKey XAAScreenKey = &XAAScreenKeyIndex;
-static int XAAGCKeyIndex;
-static DevPrivateKey XAAGCKey = &XAAGCKeyIndex;
-static int XAAPixmapKeyIndex;
-static DevPrivateKey XAAPixmapKey = &XAAPixmapKeyIndex;
+static DevPrivateKeyRec XAAScreenKeyRec;
+#define XAAScreenKey (&XAAScreenKeyRec)
+static DevPrivateKeyRec XAAGCKeyRec;
+#define XAAGCKey (&XAAGCKeyRec)
+static DevPrivateKeyRec XAAPixmapKeyRec;
+#define XAAPixmapKey (&XAAPixmapKeyRec)
DevPrivateKey XAAGetScreenKey(void) {
return XAAScreenKey;
@@ -84,11 +84,9 @@ XAADestroyInfoRec(XAAInfoRecPtr infoRec) if(infoRec->ClosePixmapCache)
(*infoRec->ClosePixmapCache)(infoRec->pScrn->pScreen);
- if(infoRec->PreAllocMem)
- free(infoRec->PreAllocMem);
+ free(infoRec->PreAllocMem);
- if(infoRec->PixmapCachePrivate)
- free(infoRec->PixmapCachePrivate);
+ free(infoRec->PixmapCachePrivate);
free(infoRec);
}
@@ -106,10 +104,13 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec) if (!infoRec)
return TRUE;
- if (!dixRequestPrivate(XAAGCKey, sizeof(XAAGCRec)))
+ if (!dixRegisterPrivateKey(&XAAGCKeyRec, PRIVATE_GC, sizeof(XAAGCRec)))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&XAAPixmapKeyRec, PRIVATE_PIXMAP, sizeof(XAAPixmapRec)))
return FALSE;
- if (!dixRequestPrivate(XAAPixmapKey, sizeof(XAAPixmapRec)))
+ if (!dixRegisterPrivateKey(&XAAScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!(pScreenPriv = malloc(sizeof(XAAScreenRec))))
diff --git a/xorg-server/hw/xfree86/xaa/xaaLine.c b/xorg-server/hw/xfree86/xaa/xaaLine.c index 7469de179..d94f1f4e0 100644 --- a/xorg-server/hw/xfree86/xaa/xaaLine.c +++ b/xorg-server/hw/xfree86/xaa/xaaLine.c @@ -1,394 +1,394 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdlib.h> - -#include <X11/X.h> -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "miline.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" - - -void -#ifdef POLYSEGMENT -XAAPolySegment( - DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pSeg -#else -XAAPolyLines( - DrawablePtr pDrawable, - GCPtr pGC, - int mode, /* Origin or Previous */ - int npt, /* number of points */ - DDXPointPtr pptInit -#endif -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip); - int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip); - unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); - int xorg = pDrawable->x; - int yorg = pDrawable->y; - int nbox; - BoxPtr pbox; -#ifndef POLYSEGMENT - DDXPointPtr ppt; -#endif - int x1, x2, y1, y2, tmp, len; - - if(!nboxInit) - return; - - if (infoRec->SolidLineFlags & LINE_LIMIT_COORDS) { - int minValX = infoRec->SolidLineLimits.x1; - int maxValX = infoRec->SolidLineLimits.x2; - int minValY = infoRec->SolidLineLimits.y1; - int maxValY = infoRec->SolidLineLimits.y2; -#ifdef POLYSEGMENT - int n = nseg; - xSegment *s = pSeg; - - while (n--) -#else - int n = npt; - int xorgtmp = xorg; - int yorgtmp = yorg; - - ppt = pptInit; - x2 = ppt->x + xorgtmp; - y2 = ppt->y + yorgtmp; - while (--n) -#endif - { -#ifdef POLYSEGMENT - x1 = s->x1 + xorg; - y1 = s->y1 + yorg; - x2 = s->x2 + xorg; - y2 = s->y2 + yorg; - s++; -#else - x1 = x2; - y1 = y2; - ++ppt; - if (mode == CoordModePrevious) { - xorgtmp = x1; - yorgtmp = y1; - } - x2 = ppt->x + xorgtmp; - y2 = ppt->y + yorgtmp; -#endif - if (x1 > maxValX || x1 < minValX || - x2 > maxValX || x2 < minValX || - y1 > maxValY || y1 < minValY || - y2 > maxValY || y2 < minValY) { -#ifdef POLYSEGMENT - XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg); -#else - XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit); -#endif - return; - } - } - } - - (*infoRec->SetupForSolidLine)(infoRec->pScrn, pGC->fgPixel, - pGC->alu, pGC->planemask); - -#ifdef POLYSEGMENT - while (nseg--) -#else - ppt = pptInit; - x2 = ppt->x + xorg; - y2 = ppt->y + yorg; - while(--npt) -#endif - { - nbox = nboxInit; - pbox = pboxInit; - -#ifdef POLYSEGMENT - x1 = pSeg->x1 + xorg; - y1 = pSeg->y1 + yorg; - x2 = pSeg->x2 + xorg; - y2 = pSeg->y2 + yorg; - pSeg++; -#else - x1 = x2; - y1 = y2; - ++ppt; - if (mode == CoordModePrevious) { - xorg = x1; - yorg = y1; - } - x2 = ppt->x + xorg; - y2 = ppt->y + yorg; -#endif - - if (x1 == x2) { /* vertical line */ - /* make the line go top to bottom of screen, keeping - endpoint semantics - */ - if (y1 > y2) { - tmp = y2; - y2 = y1 + 1; - y1 = tmp + 1; -#ifdef POLYSEGMENT - if (pGC->capStyle != CapNotLast) y1--; -#endif - } -#ifdef POLYSEGMENT - else if (pGC->capStyle != CapNotLast) y2++; -#endif - /* get to first band that might contain part of line */ - while(nbox && (pbox->y2 <= y1)) { - pbox++; - nbox--; - } - - /* stop when lower edge of box is beyond end of line */ - while(nbox && (y2 >= pbox->y1)) { - if ((x1 >= pbox->x1) && (x1 < pbox->x2)) { - tmp = max(y1, pbox->y1); - len = min(y2, pbox->y2) - tmp; - if (len) (*infoRec->SubsequentSolidHorVertLine)( - infoRec->pScrn, x1, tmp, len, DEGREES_270); - } - nbox--; - pbox++; - } -#ifndef POLYSEGMENT - y2 = ppt->y + yorg; -#endif - } else if (y1 == y2) { /* horizontal line */ - /* force line from left to right, keeping endpoint semantics */ - if (x1 > x2) { - tmp = x2; - x2 = x1 + 1; - x1 = tmp + 1; -#ifdef POLYSEGMENT - if (pGC->capStyle != CapNotLast) x1--; -#endif - } -#ifdef POLYSEGMENT - else if (pGC->capStyle != CapNotLast) x2++; -#endif - - /* find the correct band */ - while(nbox && (pbox->y2 <= y1)) { - pbox++; - nbox--; - } - - /* try to draw the line, if we haven't gone beyond it */ - if (nbox && (pbox->y1 <= y1)) { - int orig_y = pbox->y1; - /* when we leave this band, we're done */ - while(nbox && (orig_y == pbox->y1)) { - if (pbox->x2 <= x1) { - /* skip boxes until one might contain start point */ - nbox--; - pbox++; - continue; - } - - /* stop if left of box is beyond right of line */ - if (pbox->x1 >= x2) { - nbox = 0; - break; - } - - tmp = max(x1, pbox->x1); - len = min(x2, pbox->x2) - tmp; - if (len) (*infoRec->SubsequentSolidHorVertLine)( - infoRec->pScrn, tmp, y1, len, DEGREES_0); - nbox--; - pbox++; - } - } -#ifndef POLYSEGMENT - x2 = ppt->x + xorg; -#endif - } else{ /* sloped line */ - unsigned int oc1, oc2; - int dmin, dmaj, e, octant; - - if (infoRec->SubsequentSolidBresenhamLine) { - if((dmaj = x2 - x1) < 0) { - dmaj = -dmaj; - octant = XDECREASING; - } else octant = 0; - - if((dmin = y2 - y1) < 0) { - dmin = -dmin; - octant |= YDECREASING; - } - - if(dmin >= dmaj){ - tmp = dmin; dmin = dmaj; dmaj = tmp; - octant |= YMAJOR; - } - - e = -dmaj - ((bias >> octant) & 1); - len = dmaj; - dmin <<= 1; - dmaj <<= 1; - } else { /* Muffle compiler */ - dmin = dmaj = e = octant = len = 0; - } - - while(nbox--) { - oc1 = oc2 = 0; - OUTCODES(oc1, x1, y1, pbox); - OUTCODES(oc2, x2, y2, pbox); - if (!(oc1 | oc2)) { /* unclipped */ - if(infoRec->SubsequentSolidTwoPointLine) { - (*infoRec->SubsequentSolidTwoPointLine)( - infoRec->pScrn, x1, y1, x2, y2, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? 0 : -#endif - OMIT_LAST - ); - } else { - (*infoRec->SubsequentSolidBresenhamLine)( - infoRec->pScrn, x1, y1, dmaj, dmin, e, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? (len+1) : -#endif - len, octant); - } - break; - } else if (oc1 & oc2) { /* completely clipped */ - pbox++; - } else if (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE) { - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1); - - if(infoRec->SubsequentSolidBresenhamLine) { - (*infoRec->SubsequentSolidBresenhamLine)( - infoRec->pScrn, x1, y1, dmaj, dmin, e, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? (len+1) : -#endif - len, octant); - } else { - (*infoRec->SubsequentSolidTwoPointLine)( - infoRec->pScrn, x1, y1, x2, y2, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? 0 : -#endif - OMIT_LAST - ); - } - (*infoRec->DisableClipping)(infoRec->pScrn); - pbox++; - } else { - int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; - int clip1 = 0, clip2 = 0; - int err, adx, ady; - - if(octant & YMAJOR) { - ady = dmaj >> 1; - adx = dmin >> 1; - } else { - ady = dmin >> 1; - adx = dmaj >> 1; - } - - if (miZeroClipLine(pbox->x1, pbox->y1, - pbox->x2 - 1, pbox->y2 - 1, - &new_x1, &new_y1, &new_x2, &new_y2, - adx, ady, &clip1, &clip2, - octant, bias, oc1, oc2) == -1) - { - pbox++; - continue; - } - - if (octant & YMAJOR) - len = abs(new_y2 - new_y1); - else - len = abs(new_x2 - new_x1); -#ifdef POLYSEGMENT - if (clip2 != 0 || pGC->capStyle != CapNotLast) - len++; -#else - len += (clip2 != 0); -#endif - if (len) { - int abserr, clipdx, clipdy; - /* unwind bresenham error term to first point */ - if (clip1) { - clipdx = abs(new_x1 - x1); - clipdy = abs(new_y1 - y1); - - if (octant & YMAJOR) - err = e + clipdy*dmin - clipdx*dmaj; - else - err = e + clipdx*dmin - clipdy*dmaj; - } else - err = e; - -#define range infoRec->SolidBresenhamLineErrorTermBits - abserr = abs(err); - while((abserr & range) || - (dmaj & range) || - (dmin & range)) { - dmin >>= 1; - dmaj >>= 1; - abserr >>= 1; - err /= 2; - } - - (*infoRec->SubsequentSolidBresenhamLine)( - infoRec->pScrn, new_x1, new_y1, - dmaj, dmin, err, len, octant); - } - pbox++; - } - } /* while (nbox--) */ - } /* sloped line */ - } /* while (nline--) */ - -#ifndef POLYSEGMENT - /* paint the last point if the end style isn't CapNotLast. - (Assume that a projecting, butt, or round cap that is one - pixel wide is the same as the single pixel of the endpoint.) - */ - - if ((pGC->capStyle != CapNotLast) && - ((ppt->x + xorg != pptInit->x + pDrawable->x) || - (ppt->y + yorg != pptInit->y + pDrawable->y) || - (ppt == pptInit + 1))) - { - nbox = nboxInit; - pbox = pboxInit; - while (nbox--) - { - if ((x2 >= pbox->x1) && (y2 >= pbox->y1) && - (x2 < pbox->x2) && (y2 < pbox->y2)) - { - (*infoRec->SubsequentSolidHorVertLine)( - infoRec->pScrn, x2, y2, 1, DEGREES_0); - break; - } - else - pbox++; - } - } -#endif - - SET_SYNC_FLAG(infoRec); -} - +
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <X11/X.h>
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "miline.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+
+void
+#ifdef POLYSEGMENT
+XAAPolySegment(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg
+#else
+XAAPolyLines(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode, /* Origin or Previous */
+ int npt, /* number of points */
+ DDXPointPtr pptInit
+#endif
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ BoxPtr pboxInit = RegionRects(pGC->pCompositeClip);
+ int nboxInit = RegionNumRects(pGC->pCompositeClip);
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int xorg = pDrawable->x;
+ int yorg = pDrawable->y;
+ int nbox;
+ BoxPtr pbox;
+#ifndef POLYSEGMENT
+ DDXPointPtr ppt;
+#endif
+ int x1, x2, y1, y2, tmp, len;
+
+ if(!nboxInit)
+ return;
+
+ if (infoRec->SolidLineFlags & LINE_LIMIT_COORDS) {
+ int minValX = infoRec->SolidLineLimits.x1;
+ int maxValX = infoRec->SolidLineLimits.x2;
+ int minValY = infoRec->SolidLineLimits.y1;
+ int maxValY = infoRec->SolidLineLimits.y2;
+#ifdef POLYSEGMENT
+ int n = nseg;
+ xSegment *s = pSeg;
+
+ while (n--)
+#else
+ int n = npt;
+ int xorgtmp = xorg;
+ int yorgtmp = yorg;
+
+ ppt = pptInit;
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+ while (--n)
+#endif
+ {
+#ifdef POLYSEGMENT
+ x1 = s->x1 + xorg;
+ y1 = s->y1 + yorg;
+ x2 = s->x2 + xorg;
+ y2 = s->y2 + yorg;
+ s++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorgtmp = x1;
+ yorgtmp = y1;
+ }
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+#endif
+ if (x1 > maxValX || x1 < minValX ||
+ x2 > maxValX || x2 < minValX ||
+ y1 > maxValY || y1 < minValY ||
+ y2 > maxValY || y2 < minValY) {
+#ifdef POLYSEGMENT
+ XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg);
+#else
+ XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit);
+#endif
+ return;
+ }
+ }
+ }
+
+ (*infoRec->SetupForSolidLine)(infoRec->pScrn, pGC->fgPixel,
+ pGC->alu, pGC->planemask);
+
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ if (x1 == x2) { /* vertical line */
+ /* make the line go top to bottom of screen, keeping
+ endpoint semantics
+ */
+ if (y1 > y2) {
+ tmp = y2;
+ y2 = y1 + 1;
+ y1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast) y1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast) y2++;
+#endif
+ /* get to first band that might contain part of line */
+ while(nbox && (pbox->y2 <= y1)) {
+ pbox++;
+ nbox--;
+ }
+
+ /* stop when lower edge of box is beyond end of line */
+ while(nbox && (y2 >= pbox->y1)) {
+ if ((x1 >= pbox->x1) && (x1 < pbox->x2)) {
+ tmp = max(y1, pbox->y1);
+ len = min(y2, pbox->y2) - tmp;
+ if (len) (*infoRec->SubsequentSolidHorVertLine)(
+ infoRec->pScrn, x1, tmp, len, DEGREES_270);
+ }
+ nbox--;
+ pbox++;
+ }
+#ifndef POLYSEGMENT
+ y2 = ppt->y + yorg;
+#endif
+ } else if (y1 == y2) { /* horizontal line */
+ /* force line from left to right, keeping endpoint semantics */
+ if (x1 > x2) {
+ tmp = x2;
+ x2 = x1 + 1;
+ x1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast) x1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast) x2++;
+#endif
+
+ /* find the correct band */
+ while(nbox && (pbox->y2 <= y1)) {
+ pbox++;
+ nbox--;
+ }
+
+ /* try to draw the line, if we haven't gone beyond it */
+ if (nbox && (pbox->y1 <= y1)) {
+ int orig_y = pbox->y1;
+ /* when we leave this band, we're done */
+ while(nbox && (orig_y == pbox->y1)) {
+ if (pbox->x2 <= x1) {
+ /* skip boxes until one might contain start point */
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ /* stop if left of box is beyond right of line */
+ if (pbox->x1 >= x2) {
+ nbox = 0;
+ break;
+ }
+
+ tmp = max(x1, pbox->x1);
+ len = min(x2, pbox->x2) - tmp;
+ if (len) (*infoRec->SubsequentSolidHorVertLine)(
+ infoRec->pScrn, tmp, y1, len, DEGREES_0);
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ x2 = ppt->x + xorg;
+#endif
+ } else{ /* sloped line */
+ unsigned int oc1, oc2;
+ int dmin, dmaj, e, octant;
+
+ if (infoRec->SubsequentSolidBresenhamLine) {
+ if((dmaj = x2 - x1) < 0) {
+ dmaj = -dmaj;
+ octant = XDECREASING;
+ } else octant = 0;
+
+ if((dmin = y2 - y1) < 0) {
+ dmin = -dmin;
+ octant |= YDECREASING;
+ }
+
+ if(dmin >= dmaj){
+ tmp = dmin; dmin = dmaj; dmaj = tmp;
+ octant |= YMAJOR;
+ }
+
+ e = -dmaj - ((bias >> octant) & 1);
+ len = dmaj;
+ dmin <<= 1;
+ dmaj <<= 1;
+ } else { /* Muffle compiler */
+ dmin = dmaj = e = octant = len = 0;
+ }
+
+ while(nbox--) {
+ oc1 = oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if (!(oc1 | oc2)) { /* unclipped */
+ if(infoRec->SubsequentSolidTwoPointLine) {
+ (*infoRec->SubsequentSolidTwoPointLine)(
+ infoRec->pScrn, x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? 0 :
+#endif
+ OMIT_LAST
+ );
+ } else {
+ (*infoRec->SubsequentSolidBresenhamLine)(
+ infoRec->pScrn, x1, y1, dmaj, dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? (len+1) :
+#endif
+ len, octant);
+ }
+ break;
+ } else if (oc1 & oc2) { /* completely clipped */
+ pbox++;
+ } else if (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE) {
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1);
+
+ if(infoRec->SubsequentSolidBresenhamLine) {
+ (*infoRec->SubsequentSolidBresenhamLine)(
+ infoRec->pScrn, x1, y1, dmaj, dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? (len+1) :
+#endif
+ len, octant);
+ } else {
+ (*infoRec->SubsequentSolidTwoPointLine)(
+ infoRec->pScrn, x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? 0 :
+#endif
+ OMIT_LAST
+ );
+ }
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+ pbox++;
+ } else {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int err, adx, ady;
+
+ if(octant & YMAJOR) {
+ ady = dmaj >> 1;
+ adx = dmin >> 1;
+ } else {
+ ady = dmin >> 1;
+ adx = dmaj >> 1;
+ }
+
+ if (miZeroClipLine(pbox->x1, pbox->y1,
+ pbox->x2 - 1, pbox->y2 - 1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+
+ if (octant & YMAJOR)
+ len = abs(new_y2 - new_y1);
+ else
+ len = abs(new_x2 - new_x1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len) {
+ int abserr, clipdx, clipdy;
+ /* unwind bresenham error term to first point */
+ if (clip1) {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+
+ if (octant & YMAJOR)
+ err = e + clipdy*dmin - clipdx*dmaj;
+ else
+ err = e + clipdx*dmin - clipdy*dmaj;
+ } else
+ err = e;
+
+#define range infoRec->SolidBresenhamLineErrorTermBits
+ abserr = abs(err);
+ while((abserr & range) ||
+ (dmaj & range) ||
+ (dmin & range)) {
+ dmin >>= 1;
+ dmaj >>= 1;
+ abserr >>= 1;
+ err /= 2;
+ }
+
+ (*infoRec->SubsequentSolidBresenhamLine)(
+ infoRec->pScrn, new_x1, new_y1,
+ dmaj, dmin, err, len, octant);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+ } /* sloped line */
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--)
+ {
+ if ((x2 >= pbox->x1) && (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) && (y2 < pbox->y2))
+ {
+ (*infoRec->SubsequentSolidHorVertLine)(
+ infoRec->pScrn, x2, y2, 1, DEGREES_0);
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+#endif
+
+ SET_SYNC_FLAG(infoRec);
+}
+
diff --git a/xorg-server/hw/xfree86/xaa/xaaLineMisc.c b/xorg-server/hw/xfree86/xaa/xaaLineMisc.c index 3e5330fd3..44048674e 100644 --- a/xorg-server/hw/xfree86/xaa/xaaLineMisc.c +++ b/xorg-server/hw/xfree86/xaa/xaaLineMisc.c @@ -74,8 +74,7 @@ XAAComputeDash(GCPtr pGC) int shift, value, direction;
Bool set;
- if(pGCPriv->DashPattern)
- free(pGCPriv->DashPattern);
+ free(pGCPriv->DashPattern);
pGCPriv->DashPattern = NULL;
pGCPriv->DashLength = 0;
diff --git a/xorg-server/hw/xfree86/xaa/xaaNonTEText.c b/xorg-server/hw/xfree86/xaa/xaaNonTEText.c index eb798a82b..519bda0e7 100644 --- a/xorg-server/hw/xfree86/xaa/xaaNonTEText.c +++ b/xorg-server/hw/xfree86/xaa/xaaNonTEText.c @@ -82,7 +82,7 @@ XAAPolyText8NonTEColorExpansion( infoRec->CharInfo);
}
- return (x + width);
+ return x + width;
}
@@ -112,7 +112,7 @@ XAAPolyText16NonTEColorExpansion( infoRec->CharInfo);
}
- return (x + width);
+ return x + width;
}
@@ -128,7 +128,7 @@ XAAImageText8NonTEColorExpansion( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
(*pGC->font->get_glyphs)(pGC->font, (unsigned long)count,
@@ -153,7 +153,7 @@ XAAImageText16NonTEColorExpansion( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
(*pGC->font->get_glyphs)(
@@ -188,7 +188,7 @@ XAAImageGlyphBltNonTEColorExpansion( ){
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
ImageGlyphBltNonTEColorExpansion(
@@ -208,7 +208,7 @@ XAAPolyGlyphBltNonTEColorExpansion( ){
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
PolyGlyphBltNonTEColorExpansion(
@@ -368,8 +368,8 @@ ImageGlyphBltNonTEColorExpansion( int skippix, skipglyph, width, n, i;
int Left, Right, Top, Bottom;
int LeftEdge, RightEdge, ytop, ybot;
- int nbox = REGION_NUM_RECTS(cclip);
- BoxPtr pbox = REGION_RECTS(cclip);
+ int nbox = RegionNumRects(cclip);
+ BoxPtr pbox = RegionRects(cclip);
Bool AlreadySetup = FALSE;
width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font);
@@ -405,8 +405,8 @@ ImageGlyphBltNonTEColorExpansion( nbox--; pbox++;
}
- nbox = REGION_NUM_RECTS(cclip);
- pbox = REGION_RECTS(cclip);
+ nbox = RegionNumRects(cclip);
+ pbox = RegionRects(cclip);
if(infoRec->WriteBitmap && (nglyph > 1) &&
((FONTMAXBOUNDS(font, rightSideBearing) -
@@ -477,8 +477,8 @@ PolyGlyphBltNonTEColorExpansion( int skippix, skipglyph, width, n, i;
int Left, Right, Top, Bottom;
int LeftEdge, RightEdge;
- int nbox = REGION_NUM_RECTS(cclip);
- BoxPtr pbox = REGION_RECTS(cclip);
+ int nbox = RegionNumRects(cclip);
+ BoxPtr pbox = RegionRects(cclip);
width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font);
diff --git a/xorg-server/hw/xfree86/xaa/xaaOverlay.c b/xorg-server/hw/xfree86/xaa/xaaOverlay.c index b7122a58f..176a2d891 100644 --- a/xorg-server/hw/xfree86/xaa/xaaOverlay.c +++ b/xorg-server/hw/xfree86/xaa/xaaOverlay.c @@ -54,23 +54,23 @@ XAACopyWindow8_32( return;
}
- pwinRoot = WindowTable[pScreen->myNum];
+ pwinRoot = pScreen->root;
if(doUnderlay)
freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip);
- REGION_NULL(pScreen, &rgnDst);
+ RegionNull(&rgnDst);
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
- REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
- REGION_INTERSECT(pScreen, &rgnDst, borderClip, prgnSrc);
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionIntersect(&rgnDst, borderClip, prgnSrc);
- pbox = REGION_RECTS(&rgnDst);
- nbox = REGION_NUM_RECTS(&rgnDst);
+ pbox = RegionRects(&rgnDst);
+ nbox = RegionNumRects(&rgnDst);
if(!nbox ||
!(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
return;
}
ppt = pptSrc;
@@ -88,9 +88,9 @@ XAACopyWindow8_32( &(infoRec->ScratchGC), &rgnDst, pptSrc);
free(pptSrc);
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if(freeReg)
- REGION_DESTROY(pScreen, borderClip);
+ RegionDestroy(borderClip);
}
static void
diff --git a/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c b/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c index 4548935fd..309ec9fa4 100644 --- a/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c +++ b/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c @@ -151,8 +151,8 @@ typedef struct { int (*TiledFillChooser)(GCPtr);
} XAAOverlayRec, *XAAOverlayPtr;
-static int XAAOverlayKeyIndex;
-static DevPrivateKey XAAOverlayKey = &XAAOverlayKeyIndex;
+static DevPrivateKeyRec XAAOverlayKeyRec;
+#define XAAOverlayKey (&XAAOverlayKeyRec)
#define GET_OVERLAY_PRIV(pScreen) \
(XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey)
@@ -173,6 +173,9 @@ XAAInitDualFramebufferOverlay( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
XAAOverlayPtr pOverPriv;
+ if (!dixRegisterPrivateKey(&XAAOverlayKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
if(!(pOverPriv = malloc(sizeof(XAAOverlayRec))))
return FALSE;
@@ -324,7 +327,7 @@ XAAOverCopyWindow( RegionRec rgnDst;
BoxPtr pbox;
int i, nbox, dx, dy;
- WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
if (!pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) {
@@ -341,18 +344,18 @@ XAAOverCopyWindow( infoRec->ScratchGC.alu = GXcopy;
infoRec->ScratchGC.planemask = ~0;
- REGION_NULL(pScreen, &rgnDst);
+ RegionNull(&rgnDst);
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
- REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
- REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
- nbox = REGION_NUM_RECTS(&rgnDst);
+ nbox = RegionNumRects(&rgnDst);
if(nbox &&
(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
- pbox = REGION_RECTS(&rgnDst);
+ pbox = RegionRects(&rgnDst);
for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
ppt->x = pbox->x1 + dx;
ppt->y = pbox->y1 + dy;
@@ -371,18 +374,18 @@ XAAOverCopyWindow( free(pptSrc);
}
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if(pWin->drawable.depth == 8) {
- REGION_NULL(pScreen, &rgnDst);
+ RegionNull(&rgnDst);
miSegregateChildren(pWin, &rgnDst, pScrn->depth);
- if(REGION_NOTEMPTY(pScreen, &rgnDst)) {
- REGION_INTERSECT(pScreen, &rgnDst, &rgnDst, prgnSrc);
- nbox = REGION_NUM_RECTS(&rgnDst);
+ if(RegionNotEmpty(&rgnDst)) {
+ RegionIntersect(&rgnDst, &rgnDst, prgnSrc);
+ nbox = RegionNumRects(&rgnDst);
if(nbox &&
(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))){
- pbox = REGION_RECTS(&rgnDst);
+ pbox = RegionRects(&rgnDst);
for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
ppt->x = pbox->x1 + dx;
ppt->y = pbox->y1 + dy;
@@ -394,7 +397,7 @@ XAAOverCopyWindow( free(pptSrc);
}
}
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
}
}
@@ -409,13 +412,13 @@ XAAOverWindowExposures( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
if((pWin->drawable.bitsPerPixel != 8) && infoRec->pScrn->vtSema) {
- if(REGION_NUM_RECTS(pReg) && infoRec->FillSolidRects) {
+ if(RegionNumRects(pReg) && infoRec->FillSolidRects) {
XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen);
SWITCH_DEPTH(8);
(*infoRec->FillSolidRects)(infoRec->pScrn,
infoRec->pScrn->colorKey, GXcopy, ~0,
- REGION_NUM_RECTS(pReg), REGION_RECTS(pReg));
+ RegionNumRects(pReg), RegionRects(pReg));
miWindowExposures(pWin, pReg, pOtherReg);
return;
} else if(infoRec->NeedToSync) {
diff --git a/xorg-server/hw/xfree86/xaa/xaaPCache.c b/xorg-server/hw/xfree86/xaa/xaaPCache.c index 62726d539..ff3f9ef56 100644 --- a/xorg-server/hw/xfree86/xaa/xaaPCache.c +++ b/xorg-server/hw/xfree86/xaa/xaaPCache.c @@ -144,18 +144,12 @@ FreePixmapCachePrivate(XAAPixmapCachePrivatePtr pPriv) {
if(!pPriv) return;
- if(pPriv->Info512)
- free(pPriv->Info512);
- if(pPriv->Info256)
- free(pPriv->Info256);
- if(pPriv->Info128)
- free(pPriv->Info128);
- if(pPriv->InfoColor)
- free(pPriv->InfoColor);
- if(pPriv->InfoMono)
- free(pPriv->InfoMono);
- if(pPriv->InfoPartial)
- free(pPriv->InfoPartial);
+ free(pPriv->Info512);
+ free(pPriv->Info256);
+ free(pPriv->Info128);
+ free(pPriv->InfoColor);
+ free(pPriv->InfoMono);
+ free(pPriv->InfoPartial);
free(pPriv);
}
@@ -639,8 +633,8 @@ XAAInitPixmapCache( ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
XAAInfoRecPtr infoRec = (XAAInfoRecPtr)data;
XAAPixmapCachePrivatePtr pCachePriv;
- BoxPtr pBox = REGION_RECTS(areas);
- int nBox = REGION_NUM_RECTS(areas);
+ BoxPtr pBox = RegionRects(areas);
+ int nBox = RegionNumRects(areas);
int Num512, Num256, Num128, NumPartial, NumColor, NumMono;
int Target512, Target256;
CacheLinkPtr List512, List256, List128, ListPartial, ListColor, ListMono;
diff --git a/xorg-server/hw/xfree86/xaa/xaaPict.c b/xorg-server/hw/xfree86/xaa/xaaPict.c index b66291458..1ad75835b 100644 --- a/xorg-server/hw/xfree86/xaa/xaaPict.c +++ b/xorg-server/hw/xfree86/xaa/xaaPict.c @@ -215,7 +215,7 @@ XAADoComposite ( BoxPtr pbox;
int nbox, w, h;
- if(!REGION_NUM_RECTS(pDst->pCompositeClip))
+ if(!RegionNumRects(pDst->pCompositeClip))
return TRUE;
if(!infoRec->pScrn->vtSema || !DRAWABLE_IS_ON_CARD(pDst->pDrawable))
@@ -273,8 +273,8 @@ XAADoComposite ( width, height))
return TRUE;
- nbox = REGION_NUM_RECTS(®ion);
- pbox = REGION_RECTS(®ion);
+ nbox = RegionNumRects(®ion);
+ pbox = RegionRects(®ion);
if(!nbox)
return TRUE;
@@ -298,7 +298,7 @@ XAADoComposite ( }
/* WriteBitmap sets the Sync flag */
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
return TRUE;
}
@@ -340,11 +340,11 @@ XAADoComposite ( width, height))
return TRUE;
- nbox = REGION_NUM_RECTS(®ion);
- pbox = REGION_RECTS(®ion);
+ nbox = RegionNumRects(®ion);
+ pbox = RegionRects(®ion);
if(!nbox) {
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
return TRUE;
}
@@ -355,7 +355,7 @@ XAADoComposite ( ((PixmapPtr)(pMask->pDrawable))->devKind,
w, h, flags))
{
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
return FALSE;
}
@@ -371,7 +371,7 @@ XAADoComposite ( }
SET_SYNC_FLAG(infoRec);
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
return TRUE;
}
} else {
@@ -409,11 +409,11 @@ XAADoComposite ( width, height))
return TRUE;
- nbox = REGION_NUM_RECTS(®ion);
- pbox = REGION_RECTS(®ion);
+ nbox = RegionNumRects(®ion);
+ pbox = RegionRects(®ion);
if(!nbox) {
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
return TRUE;
}
@@ -423,7 +423,7 @@ XAADoComposite ( ((PixmapPtr)(pSrc->pDrawable))->devKind,
w, h, flags))
{
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
return FALSE;
}
@@ -440,7 +440,7 @@ XAADoComposite ( }
SET_SYNC_FLAG(infoRec);
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
return TRUE;
}
@@ -476,16 +476,16 @@ XAACompositeSrcCopy (PicturePtr pSrc, width, height))
return;
- nbox = REGION_NUM_RECTS(®ion);
- pbox = REGION_RECTS(®ion);
+ nbox = RegionNumRects(®ion);
+ pbox = RegionRects(®ion);
if(!nbox) {
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
return;
}
pptSrc = malloc(sizeof(DDXPointRec) * nbox);
if (!pptSrc) {
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
return;
}
xoff = xSrc - xDst;
@@ -502,7 +502,7 @@ XAACompositeSrcCopy (PicturePtr pSrc, pptSrc);
free(pptSrc);
- REGION_UNINIT(pScreen, ®ion);
+ RegionUninit(®ion);
return;
}
@@ -588,7 +588,7 @@ XAADoGlyphs (CARD8 op, ScreenPtr pScreen = pDst->pDrawable->pScreen;
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- if(!REGION_NUM_RECTS(pDst->pCompositeClip))
+ if(!RegionNumRects(pDst->pCompositeClip))
return TRUE;
if(!infoRec->pScrn->vtSema ||
diff --git a/xorg-server/hw/xfree86/xaa/xaaRect.c b/xorg-server/hw/xfree86/xaa/xaaRect.c index 0a7e174b7..988dbf608 100644 --- a/xorg-server/hw/xfree86/xaa/xaaRect.c +++ b/xorg-server/hw/xfree86/xaa/xaaRect.c @@ -1,136 +1,136 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include <X11/X.h> -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" - -/* - Much of this file based on code by - Harm Hanemaayer (H.Hanemaayer@inter.nl.net). -*/ - - -void -XAAPolyRectangleThinSolid( - DrawablePtr pDrawable, - GCPtr pGC, - int nRectsInit, - xRectangle *pRectsInit ) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int nClipRects; /* number of clip rectangles */ - BoxPtr pClipRects; /* points to the list of clip rects */ - int xOrigin; /* Drawables x origin */ - int yOrigin; /* Drawables x origin */ - xRectangle *pRect; /* list of rects */ - int nRects; /* running count of number of rects */ - int origX1, origY1; /* original rectangle's U/L corner */ - int origX2, origY2; /* original rectangle's L/R corner */ - int clippedX1; /* clipped rectangle's left x */ - int clippedY1; /* clipped rectangle's top y */ - int clippedX2; /* clipped rectangle's right x */ - int clippedY2; /* clipped rectangle's bottom y */ - int clipXMin; /* upper left corner of clip rect */ - int clipYMin; /* upper left corner of clip rect */ - int clipXMax; /* lower right corner of clip rect */ - int clipYMax; /* lower right corner of clip rect */ - int width, height; /* width and height of rect */ - - nClipRects = REGION_NUM_RECTS(pGC->pCompositeClip); - pClipRects = REGION_RECTS(pGC->pCompositeClip); - - if(!nClipRects) return; - - xOrigin = pDrawable->x; - yOrigin = pDrawable->y; - - - (*infoRec->SetupForSolidLine)(infoRec->pScrn, - pGC->fgPixel, pGC->alu, pGC->planemask); - - - for ( ; nClipRects > 0; - nClipRects--, pClipRects++ ) - { - clipYMin = pClipRects->y1; - clipYMax = pClipRects->y2 - 1; - clipXMin = pClipRects->x1; - clipXMax = pClipRects->x2 - 1; - - for (pRect = pRectsInit, nRects = nRectsInit; - nRects > 0; - nRects--, pRect++ ) - { - /* translate rectangle data over to the drawable */ - origX1 = pRect->x + xOrigin; - origY1 = pRect->y + yOrigin; - origX2 = origX1 + pRect->width; - origY2 = origY1 + pRect->height; - - /* reject entire rectangle if completely outside clip rect */ - if ((origX1 > clipXMax) || (origX2 < clipXMin) || - (origY1 > clipYMax) || (origY2 < clipYMin)) - continue; - - /* clip the rectangle */ - clippedX1 = max (origX1, clipXMin); - clippedX2 = min (origX2, clipXMax); - clippedY1 = max (origY1, clipYMin); - clippedY2 = min (origY2, clipYMax); - - width = clippedX2 - clippedX1 + 1; - - if (origY1 >= clipYMin) { - (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, - clippedX1, clippedY1, width, DEGREES_0); - - /* don't overwrite corner */ - clippedY1++; - } - - if ((origY2 <= clipYMax) && (origY1 != origY2)) { - (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, - clippedX1, clippedY2, width, DEGREES_0); - - /* don't overwrite corner */ - clippedY2--; - } - - if (clippedY2 < clippedY1) continue; - - height = clippedY2 - clippedY1 + 1; - - /* draw vertical edges using lines if not clipped out */ - if (origX1 >= clipXMin) - (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, - clippedX1, clippedY1, height, DEGREES_270); - - if ((origX2 <= clipXMax) && (origX2 != origX1)) - (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, - clippedX2, clippedY1, height, DEGREES_270); - } - } - - SET_SYNC_FLAG(infoRec); -} - - - - - - - - - - - +
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+/*
+ Much of this file based on code by
+ Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
+*/
+
+
+void
+XAAPolyRectangleThinSolid(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRectsInit,
+ xRectangle *pRectsInit )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int nClipRects; /* number of clip rectangles */
+ BoxPtr pClipRects; /* points to the list of clip rects */
+ int xOrigin; /* Drawables x origin */
+ int yOrigin; /* Drawables x origin */
+ xRectangle *pRect; /* list of rects */
+ int nRects; /* running count of number of rects */
+ int origX1, origY1; /* original rectangle's U/L corner */
+ int origX2, origY2; /* original rectangle's L/R corner */
+ int clippedX1; /* clipped rectangle's left x */
+ int clippedY1; /* clipped rectangle's top y */
+ int clippedX2; /* clipped rectangle's right x */
+ int clippedY2; /* clipped rectangle's bottom y */
+ int clipXMin; /* upper left corner of clip rect */
+ int clipYMin; /* upper left corner of clip rect */
+ int clipXMax; /* lower right corner of clip rect */
+ int clipYMax; /* lower right corner of clip rect */
+ int width, height; /* width and height of rect */
+
+ nClipRects = RegionNumRects(pGC->pCompositeClip);
+ pClipRects = RegionRects(pGC->pCompositeClip);
+
+ if(!nClipRects) return;
+
+ xOrigin = pDrawable->x;
+ yOrigin = pDrawable->y;
+
+
+ (*infoRec->SetupForSolidLine)(infoRec->pScrn,
+ pGC->fgPixel, pGC->alu, pGC->planemask);
+
+
+ for ( ; nClipRects > 0;
+ nClipRects--, pClipRects++ )
+ {
+ clipYMin = pClipRects->y1;
+ clipYMax = pClipRects->y2 - 1;
+ clipXMin = pClipRects->x1;
+ clipXMax = pClipRects->x2 - 1;
+
+ for (pRect = pRectsInit, nRects = nRectsInit;
+ nRects > 0;
+ nRects--, pRect++ )
+ {
+ /* translate rectangle data over to the drawable */
+ origX1 = pRect->x + xOrigin;
+ origY1 = pRect->y + yOrigin;
+ origX2 = origX1 + pRect->width;
+ origY2 = origY1 + pRect->height;
+
+ /* reject entire rectangle if completely outside clip rect */
+ if ((origX1 > clipXMax) || (origX2 < clipXMin) ||
+ (origY1 > clipYMax) || (origY2 < clipYMin))
+ continue;
+
+ /* clip the rectangle */
+ clippedX1 = max (origX1, clipXMin);
+ clippedX2 = min (origX2, clipXMax);
+ clippedY1 = max (origY1, clipYMin);
+ clippedY2 = min (origY2, clipYMax);
+
+ width = clippedX2 - clippedX1 + 1;
+
+ if (origY1 >= clipYMin) {
+ (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
+ clippedX1, clippedY1, width, DEGREES_0);
+
+ /* don't overwrite corner */
+ clippedY1++;
+ }
+
+ if ((origY2 <= clipYMax) && (origY1 != origY2)) {
+ (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
+ clippedX1, clippedY2, width, DEGREES_0);
+
+ /* don't overwrite corner */
+ clippedY2--;
+ }
+
+ if (clippedY2 < clippedY1) continue;
+
+ height = clippedY2 - clippedY1 + 1;
+
+ /* draw vertical edges using lines if not clipped out */
+ if (origX1 >= clipXMin)
+ (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
+ clippedX1, clippedY1, height, DEGREES_270);
+
+ if ((origX2 <= clipXMax) && (origX2 != origX1))
+ (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
+ clippedX2, clippedY1, height, DEGREES_270);
+ }
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xorg-server/hw/xfree86/xaa/xaaSpans.c b/xorg-server/hw/xfree86/xaa/xaaSpans.c index 46d6d0740..1e6ef3a18 100644 --- a/xorg-server/hw/xfree86/xaa/xaaSpans.c +++ b/xorg-server/hw/xfree86/xaa/xaaSpans.c @@ -1,882 +1,882 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include <X11/X.h> -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "xf86str.h" -#include "mi.h" -#include "mispans.h" -#include "xaa.h" -#include "xaalocal.h" - - -static void XAARenderSolidSpans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderColor8x8Spans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderMono8x8Spans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderCacheBltSpans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderColorExpandSpans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderCacheExpandSpans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderPixmapCopySpans( - GCPtr, int, DDXPointPtr, int*, int, int, int); - -void -XAAFillSpans( - DrawablePtr pDraw, - GC *pGC, - int nInit, /* number of spans to fill */ - DDXPointPtr pptInit, /* pointer to list of start points */ - int *pwidthInit, /* pointer to list of n widths */ - int fSorted -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int type = 0; - ClipAndRenderSpansFunc function; - Bool fastClip = FALSE; - - if((nInit <= 0) || !pGC->planemask) - return; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - switch(pGC->fillStyle) { - case FillSolid: - type = DO_SOLID; - break; - case FillStippled: - type = (*infoRec->StippledFillChooser)(pGC); - break; - case FillOpaqueStippled: - if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSpansSolid && - CHECK_PLANEMASK(pGC,infoRec->FillSpansSolidFlags) && - CHECK_ROP(pGC,infoRec->FillSpansSolidFlags) && - CHECK_ROPSRC(pGC,infoRec->FillSpansSolidFlags) && - CHECK_FG(pGC,infoRec->FillSpansSolidFlags)) - type = DO_SOLID; - else - type = (*infoRec->OpaqueStippledFillChooser)(pGC); - break; - case FillTiled: - type = (*infoRec->TiledFillChooser)(pGC); - break; - } - - switch(type) { - case DO_SOLID: - function = XAARenderSolidSpans; - if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) - fastClip = TRUE; - break; - case DO_COLOR_8x8: - function = XAARenderColor8x8Spans; - if(infoRec->ClippingFlags & HARDWARE_CLIP_COLOR_8x8_FILL) - fastClip = TRUE; - break; - case DO_MONO_8x8: - function = XAARenderMono8x8Spans; - if(infoRec->ClippingFlags & HARDWARE_CLIP_MONO_8x8_FILL) - fastClip = TRUE; - break; - case DO_CACHE_BLT: - function = XAARenderCacheBltSpans; - if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY) - fastClip = TRUE; - break; - case DO_COLOR_EXPAND: - function = XAARenderColorExpandSpans; - break; - case DO_CACHE_EXPAND: - function = XAARenderCacheExpandSpans; - if(infoRec->ClippingFlags & - HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND) - fastClip = TRUE; - break; - case DO_PIXMAP_COPY: - function = XAARenderPixmapCopySpans; - if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY) - fastClip = TRUE; - break; - case DO_IMAGE_WRITE: - default: - (*XAAFallbackOps.FillSpans)(pDraw, pGC, nInit, pptInit, - pwidthInit, fSorted); - return; - } - - - if((nInit < 10) || (REGION_NUM_RECTS(pGC->pCompositeClip) != 1)) - fastClip = FALSE; - - if(fastClip) { - infoRec->ClipBox = &pGC->pCompositeClip->extents; - (*function)(pGC, nInit, pptInit, pwidthInit, fSorted, - pDraw->x, pDraw->y); - infoRec->ClipBox = NULL; - } else - XAAClipAndRenderSpans(pGC, pptInit, pwidthInit, nInit, fSorted, - function, pDraw->x, pDraw->y); -} - - - /*********************\ - | Solid Spans | - \*********************/ - - -static void -XAARenderSolidSpans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - - (*infoRec->FillSolidSpans) (infoRec->pScrn, pGC->fgPixel, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted); -} - - - /************************\ - | Mono 8x8 Spans | - \************************/ - - -static void -XAARenderMono8x8Spans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAPixmapPtr pPriv; - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - case FillTiled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); - fg = pPriv->fg; bg = pPriv->bg; - break; - default: /* Muffle compiler */ - pPriv = NULL; /* Kaboom */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillMono8x8PatternSpans) (infoRec->pScrn, - fg, bg, pGC->alu, pGC->planemask, - n, ppt, pwidth, fSorted, pPriv->pattern0, pPriv->pattern1, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); -} - - - /*************************\ - | Color 8x8 Spans | - \*************************/ - - -static void -XAARenderColor8x8Spans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache; - PixmapPtr pPix; - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - pPix = pGC->stipple; - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - pPix = pGC->stipple; - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - case FillTiled: - pPix = pGC->tile.pixmap; - fg = -1; bg = -1; - break; - default: /* Muffle compiler */ - pPix = NULL; - fg = -1; bg = -1; - break; - } - - pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg); - - (*infoRec->FillColor8x8PatternSpans) (infoRec->pScrn, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, - (yorg + pGC->patOrg.x), (xorg + pGC->patOrg.y)); -} - - - /****************************\ - | Color Expand Spans | - \****************************/ - - -static void -XAARenderColorExpandSpans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - default: /* Muffle compiler */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillColorExpandSpans) (infoRec->pScrn, fg, bg, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pGC->stipple); - -} - - - /*************************\ - | Cache Blt Spans | - \*************************/ - - -static void -XAARenderCacheBltSpans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache; - - switch(pGC->fillStyle) { - case FillStippled: - pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, - pGC->fgPixel, -1); - break; - case FillOpaqueStippled: - pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, - pGC->fgPixel, pGC->bgPixel); - break; - case FillTiled: - pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); - break; - default: /* Muffle compiler */ - pCache = NULL; - break; - } - - (*infoRec->FillCacheBltSpans) (infoRec->pScrn, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); - -} - - - /****************************\ - | Cache Expand Spans | - \****************************/ - - -static void -XAARenderCacheExpandSpans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - default: /* Muffle compiler */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillCacheExpandSpans) (infoRec->pScrn, fg, bg, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pGC->stipple); -} - - - /***************************\ - | Pixmap Copy Spans | - \***************************/ - - -static void -XAARenderPixmapCopySpans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec); - XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); - - pCache->x = pPriv->offscreenArea->box.x1; - pCache->y = pPriv->offscreenArea->box.y1; - pCache->w = pCache->orig_w = - pPriv->offscreenArea->box.x2 - pCache->x; - pCache->h = pCache->orig_h = - pPriv->offscreenArea->box.y2 - pCache->y; - pCache->trans_color = -1; - - (*infoRec->FillCacheBltSpans) (infoRec->pScrn, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); -} - - - - - - /****************\ - | Solid | - \****************/ - - -void -XAAFillSolidSpans( - ScrnInfoPtr pScrn, - int fg, int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, int fSorted -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - if (*pwidth > 0) - (*infoRec->SubsequentSolidFillRect)(pScrn, ppt->x, ppt->y, - *pwidth, 1); - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - /***************\ - | Mono 8x8 | - \***************/ - - -void -XAAFillMono8x8PatternSpansScreenOrigin( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, int fSorted, - int pattern0, int pattern1, - int xorigin, int yorigin -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pattern0, paty = pattern1; - int xorg = (-xorigin) & 0x07; - int yorg = (-yorigin) & 0x07; - - - if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) { - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } - } else { - XAACacheInfoPtr pCache = - (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); - patx = pCache->x; paty = pCache->y; - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - patx += pCache->offsets[slot].x; - paty += pCache->offsets[slot].y; - xorg = patx; yorg = paty; - } - } - - (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, - fg, bg, rop, planemask); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, - xorg, yorg, ppt->x, ppt->y, *pwidth, 1); - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - -void -XAAFillMono8x8PatternSpans( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, int fSorted, - int pattern0, int pattern1, - int xorigin, int yorigin -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pattern0, paty = pattern1; - int xorg, yorg, slot; - XAACacheInfoPtr pCache = NULL; - - - if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){ - pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); - patx = pCache->x; paty = pCache->y; - } - - (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, - fg, bg, rop, planemask); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - xorg = (ppt->x - xorigin) & 0x07; - yorg = (ppt->y - yorigin) & 0x07; - - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS) { - patx = pattern0; paty = pattern1; - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } else { - slot = (yorg << 3) + xorg; - xorg = patx + pCache->offsets[slot].x; - yorg = paty + pCache->offsets[slot].y; - } - } - - (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, - xorg, yorg, ppt->x, ppt->y, *pwidth, 1); - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - - - /****************\ - | Color 8x8 | - \****************/ - - -void -XAAFillColor8x8PatternSpansScreenOrigin( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, int fSorted, - XAACacheInfoPtr pCache, - int xorigin, int yorigin -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pCache->x, paty = pCache->y; - int xorg = (-xorigin) & 0x07; - int yorg = (-yorigin) & 0x07; - - - if(!(infoRec->Color8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - paty += pCache->offsets[slot].y; - patx += pCache->offsets[slot].x; - xorg = patx; yorg = paty; - } - - (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty, - rop, planemask, pCache->trans_color); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, - xorg, yorg, ppt->x, ppt->y, *pwidth, 1); - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - -void -XAAFillColor8x8PatternSpans( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, int fSorted, - XAACacheInfoPtr pCache, - int xorigin, int yorigin -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int xorg, yorg, slot; - - (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y, - rop, planemask, pCache->trans_color); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - xorg = (ppt->x - xorigin) & 0x07; - yorg = (ppt->y - yorigin) & 0x07; - - if(!(infoRec->Color8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - slot = (yorg << 3) + xorg; - yorg = pCache->y + pCache->offsets[slot].y; - xorg = pCache->x + pCache->offsets[slot].x; - } - - (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, - xorg, yorg, ppt->x, ppt->y, *pwidth, 1); - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - /*****************\ - | Cache Blit | - \*****************/ - - -void -XAAFillCacheBltSpans( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - XAACacheInfoPtr pCache, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, w, phaseX, phaseY, blit_w; - - (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask, - pCache->trans_color); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - x = ppt->x; - w = *pwidth; - phaseX = (x - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - phaseY = (ppt->y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - - while(1) { - blit_w = pCache->w - phaseX; - if(blit_w > w) blit_w = w; - - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, - pCache->x + phaseX, pCache->y + phaseY, - x, ppt->y, blit_w, 1); - - w -= blit_w; - if(!w) break; - x += blit_w; - phaseX = (phaseX + blit_w) % pCache->orig_w; - } - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - - /****************\ - | Cache Expand | - \****************/ - - -void -XAAFillCacheExpandSpans( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg, - PixmapPtr pPix -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, w, phaseX, phaseY, blit_w, cacheWidth; - XAACacheInfoPtr pCache; - - pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix); - - cacheWidth = (pCache->w * pScrn->bitsPerPixel) / - infoRec->CacheColorExpandDensity; - - (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop, - planemask); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - x = ppt->x; - w = *pwidth; - phaseX = (x - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - phaseY = (ppt->y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - - while(1) { - blit_w = cacheWidth - phaseX; - if(blit_w > w) blit_w = w; - - (*infoRec->SubsequentScreenToScreenColorExpandFill)( - pScrn, x, ppt->y, blit_w, 1, - pCache->x, pCache->y + phaseY, phaseX); - - w -= blit_w; - if(!w) break; - x += blit_w; - phaseX = (phaseX + blit_w) % pCache->orig_w; - } - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - - -void -XAAClipAndRenderSpans( - GCPtr pGC, - DDXPointPtr ppt, - int *pwidth, - int nspans, - int fSorted, - ClipAndRenderSpansFunc func, - int xorg, - int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - DDXPointPtr pptNew, pptBase; - int *pwidthBase, *pwidthNew; - int Right, numRects, MaxBoxes; - - MaxBoxes = infoRec->PreAllocSize/(sizeof(DDXPointRec) + sizeof(int)); - pptBase = (DDXPointRec*)infoRec->PreAllocMem; - pwidthBase = (int*)(&pptBase[MaxBoxes]); - - pptNew = pptBase; - pwidthNew = pwidthBase; - - numRects = REGION_NUM_RECTS(pGC->pCompositeClip); - - if(numRects == 1) { - BoxPtr pextent = REGION_RECTS(pGC->pCompositeClip); - - while(nspans--) { - if ((pextent->y1 <= ppt->y) && (ppt->y < pextent->y2)) { - pptNew->x = max(pextent->x1, ppt->x); - Right = ppt->x + *pwidth; - *pwidthNew = min(pextent->x2, Right) - pptNew->x; - - if (*pwidthNew > 0) { - pptNew->y = ppt->y; - pptNew++; - pwidthNew++; - - if(pptNew >= (pptBase + MaxBoxes)) { - (*func)(pGC, MaxBoxes, pptBase, pwidthBase, fSorted, - xorg, yorg); - pptNew = pptBase; - pwidthNew = pwidthBase; - } - } - } - ppt++; - pwidth++; - } - } else if (numRects) { - BoxPtr pbox; - int nbox; - - while(nspans--) { - nbox = numRects; - pbox = REGION_RECTS(pGC->pCompositeClip); - - /* find the first band */ - while(nbox && (pbox->y2 <= ppt->y)) { - pbox++; - nbox--; - } - - if(nbox && (pbox->y1 <= ppt->y)) { - int orig_y = pbox->y1; - Right = ppt->x + *pwidth; - while(nbox && (orig_y == pbox->y1)) { - if(pbox->x2 <= ppt->x) { - nbox--; - pbox++; - continue; - } - - if(pbox->x1 >= Right) { - nbox = 0; - break; - } - - pptNew->x = max(pbox->x1, ppt->x); - *pwidthNew = min(pbox->x2, Right) - pptNew->x; - if(*pwidthNew > 0) { - pptNew->y = ppt->y; - pptNew++; - pwidthNew++; - - if(pptNew >= (pptBase + MaxBoxes)) { - (*func)(pGC, MaxBoxes, pptBase, pwidthBase, - fSorted, xorg, yorg); - pptNew = pptBase; - pwidthNew = pwidthBase; - } - } - pbox++; - nbox--; - } - } - ppt++; - pwidth++; - } - } - - if(pptNew != pptBase) - (*func)(pGC, pptNew - pptBase, pptBase, pwidthBase, fSorted, - xorg, yorg); -} +
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "mi.h"
+#include "mispans.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+
+static void XAARenderSolidSpans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderColor8x8Spans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderMono8x8Spans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderCacheBltSpans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderColorExpandSpans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderCacheExpandSpans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderPixmapCopySpans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+
+void
+XAAFillSpans(
+ DrawablePtr pDraw,
+ GC *pGC,
+ int nInit, /* number of spans to fill */
+ DDXPointPtr pptInit, /* pointer to list of start points */
+ int *pwidthInit, /* pointer to list of n widths */
+ int fSorted
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int type = 0;
+ ClipAndRenderSpansFunc function;
+ Bool fastClip = FALSE;
+
+ if((nInit <= 0) || !pGC->planemask)
+ return;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ switch(pGC->fillStyle) {
+ case FillSolid:
+ type = DO_SOLID;
+ break;
+ case FillStippled:
+ type = (*infoRec->StippledFillChooser)(pGC);
+ break;
+ case FillOpaqueStippled:
+ if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSpansSolid &&
+ CHECK_PLANEMASK(pGC,infoRec->FillSpansSolidFlags) &&
+ CHECK_ROP(pGC,infoRec->FillSpansSolidFlags) &&
+ CHECK_ROPSRC(pGC,infoRec->FillSpansSolidFlags) &&
+ CHECK_FG(pGC,infoRec->FillSpansSolidFlags))
+ type = DO_SOLID;
+ else
+ type = (*infoRec->OpaqueStippledFillChooser)(pGC);
+ break;
+ case FillTiled:
+ type = (*infoRec->TiledFillChooser)(pGC);
+ break;
+ }
+
+ switch(type) {
+ case DO_SOLID:
+ function = XAARenderSolidSpans;
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL)
+ fastClip = TRUE;
+ break;
+ case DO_COLOR_8x8:
+ function = XAARenderColor8x8Spans;
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_COLOR_8x8_FILL)
+ fastClip = TRUE;
+ break;
+ case DO_MONO_8x8:
+ function = XAARenderMono8x8Spans;
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_MONO_8x8_FILL)
+ fastClip = TRUE;
+ break;
+ case DO_CACHE_BLT:
+ function = XAARenderCacheBltSpans;
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY)
+ fastClip = TRUE;
+ break;
+ case DO_COLOR_EXPAND:
+ function = XAARenderColorExpandSpans;
+ break;
+ case DO_CACHE_EXPAND:
+ function = XAARenderCacheExpandSpans;
+ if(infoRec->ClippingFlags &
+ HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND)
+ fastClip = TRUE;
+ break;
+ case DO_PIXMAP_COPY:
+ function = XAARenderPixmapCopySpans;
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY)
+ fastClip = TRUE;
+ break;
+ case DO_IMAGE_WRITE:
+ default:
+ (*XAAFallbackOps.FillSpans)(pDraw, pGC, nInit, pptInit,
+ pwidthInit, fSorted);
+ return;
+ }
+
+
+ if((nInit < 10) || (RegionNumRects(pGC->pCompositeClip) != 1))
+ fastClip = FALSE;
+
+ if(fastClip) {
+ infoRec->ClipBox = &pGC->pCompositeClip->extents;
+ (*function)(pGC, nInit, pptInit, pwidthInit, fSorted,
+ pDraw->x, pDraw->y);
+ infoRec->ClipBox = NULL;
+ } else
+ XAAClipAndRenderSpans(pGC, pptInit, pwidthInit, nInit, fSorted,
+ function, pDraw->x, pDraw->y);
+}
+
+
+ /*********************\
+ | Solid Spans |
+ \*********************/
+
+
+static void
+XAARenderSolidSpans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ (*infoRec->FillSolidSpans) (infoRec->pScrn, pGC->fgPixel,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted);
+}
+
+
+ /************************\
+ | Mono 8x8 Spans |
+ \************************/
+
+
+static void
+XAARenderMono8x8Spans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv;
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+ fg = pPriv->fg; bg = pPriv->bg;
+ break;
+ default: /* Muffle compiler */
+ pPriv = NULL; /* Kaboom */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillMono8x8PatternSpans) (infoRec->pScrn,
+ fg, bg, pGC->alu, pGC->planemask,
+ n, ppt, pwidth, fSorted, pPriv->pattern0, pPriv->pattern1,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
+}
+
+
+ /*************************\
+ | Color 8x8 Spans |
+ \*************************/
+
+
+static void
+XAARenderColor8x8Spans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+ PixmapPtr pPix;
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPix = pGC->tile.pixmap;
+ fg = -1; bg = -1;
+ break;
+ default: /* Muffle compiler */
+ pPix = NULL;
+ fg = -1; bg = -1;
+ break;
+ }
+
+ pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg);
+
+ (*infoRec->FillColor8x8PatternSpans) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
+ (yorg + pGC->patOrg.x), (xorg + pGC->patOrg.y));
+}
+
+
+ /****************************\
+ | Color Expand Spans |
+ \****************************/
+
+
+static void
+XAARenderColorExpandSpans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillColorExpandSpans) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pGC->stipple);
+
+}
+
+
+ /*************************\
+ | Cache Blt Spans |
+ \*************************/
+
+
+static void
+XAARenderCacheBltSpans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, -1);
+ break;
+ case FillOpaqueStippled:
+ pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, pGC->bgPixel);
+ break;
+ case FillTiled:
+ pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
+ break;
+ default: /* Muffle compiler */
+ pCache = NULL;
+ break;
+ }
+
+ (*infoRec->FillCacheBltSpans) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
+
+}
+
+
+ /****************************\
+ | Cache Expand Spans |
+ \****************************/
+
+
+static void
+XAARenderCacheExpandSpans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillCacheExpandSpans) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pGC->stipple);
+}
+
+
+ /***************************\
+ | Pixmap Copy Spans |
+ \***************************/
+
+
+static void
+XAARenderPixmapCopySpans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+
+ pCache->x = pPriv->offscreenArea->box.x1;
+ pCache->y = pPriv->offscreenArea->box.y1;
+ pCache->w = pCache->orig_w =
+ pPriv->offscreenArea->box.x2 - pCache->x;
+ pCache->h = pCache->orig_h =
+ pPriv->offscreenArea->box.y2 - pCache->y;
+ pCache->trans_color = -1;
+
+ (*infoRec->FillCacheBltSpans) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
+}
+
+
+
+
+
+ /****************\
+ | Solid |
+ \****************/
+
+
+void
+XAAFillSolidSpans(
+ ScrnInfoPtr pScrn,
+ int fg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ if (*pwidth > 0)
+ (*infoRec->SubsequentSolidFillRect)(pScrn, ppt->x, ppt->y,
+ *pwidth, 1);
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /***************\
+ | Mono 8x8 |
+ \***************/
+
+
+void
+XAAFillMono8x8PatternSpansScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ int pattern0, int pattern1,
+ int xorigin, int yorigin
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+
+ if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ }
+ } else {
+ XAACacheInfoPtr pCache =
+ (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
+ patx = pCache->x; paty = pCache->y;
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx; yorg = paty;
+ }
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
+ xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+void
+XAAFillMono8x8PatternSpans(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ int pattern0, int pattern1,
+ int xorigin, int yorigin
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg, yorg, slot;
+ XAACacheInfoPtr pCache = NULL;
+
+
+ if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){
+ pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
+ patx = pCache->x; paty = pCache->y;
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ xorg = (ppt->x - xorigin) & 0x07;
+ yorg = (ppt->y - yorigin) & 0x07;
+
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ patx = pattern0; paty = pattern1;
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ } else {
+ slot = (yorg << 3) + xorg;
+ xorg = patx + pCache->offsets[slot].x;
+ yorg = paty + pCache->offsets[slot].y;
+ }
+ }
+
+ (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
+ xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+ /****************\
+ | Color 8x8 |
+ \****************/
+
+
+void
+XAAFillColor8x8PatternSpansScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ XAACacheInfoPtr pCache,
+ int xorigin, int yorigin
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pCache->x, paty = pCache->y;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+
+ if(!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ paty += pCache->offsets[slot].y;
+ patx += pCache->offsets[slot].x;
+ xorg = patx; yorg = paty;
+ }
+
+ (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty,
+ rop, planemask, pCache->trans_color);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
+ xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+void
+XAAFillColor8x8PatternSpans(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ XAACacheInfoPtr pCache,
+ int xorigin, int yorigin
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int xorg, yorg, slot;
+
+ (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y,
+ rop, planemask, pCache->trans_color);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ xorg = (ppt->x - xorigin) & 0x07;
+ yorg = (ppt->y - yorigin) & 0x07;
+
+ if(!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ slot = (yorg << 3) + xorg;
+ yorg = pCache->y + pCache->offsets[slot].y;
+ xorg = pCache->x + pCache->offsets[slot].x;
+ }
+
+ (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
+ xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /*****************\
+ | Cache Blit |
+ \*****************/
+
+
+void
+XAAFillCacheBltSpans(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ XAACacheInfoPtr pCache,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, w, phaseX, phaseY, blit_w;
+
+ (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask,
+ pCache->trans_color);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ x = ppt->x;
+ w = *pwidth;
+ phaseX = (x - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+ phaseY = (ppt->y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+
+ while(1) {
+ blit_w = pCache->w - phaseX;
+ if(blit_w > w) blit_w = w;
+
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
+ pCache->x + phaseX, pCache->y + phaseY,
+ x, ppt->y, blit_w, 1);
+
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ phaseX = (phaseX + blit_w) % pCache->orig_w;
+ }
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+ /****************\
+ | Cache Expand |
+ \****************/
+
+
+void
+XAAFillCacheExpandSpans(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, w, phaseX, phaseY, blit_w, cacheWidth;
+ XAACacheInfoPtr pCache;
+
+ pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix);
+
+ cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
+ infoRec->CacheColorExpandDensity;
+
+ (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop,
+ planemask);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ x = ppt->x;
+ w = *pwidth;
+ phaseX = (x - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+ phaseY = (ppt->y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+
+ while(1) {
+ blit_w = cacheWidth - phaseX;
+ if(blit_w > w) blit_w = w;
+
+ (*infoRec->SubsequentScreenToScreenColorExpandFill)(
+ pScrn, x, ppt->y, blit_w, 1,
+ pCache->x, pCache->y + phaseY, phaseX);
+
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ phaseX = (phaseX + blit_w) % pCache->orig_w;
+ }
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+void
+XAAClipAndRenderSpans(
+ GCPtr pGC,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted,
+ ClipAndRenderSpansFunc func,
+ int xorg,
+ int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ DDXPointPtr pptNew, pptBase;
+ int *pwidthBase, *pwidthNew;
+ int Right, numRects, MaxBoxes;
+
+ MaxBoxes = infoRec->PreAllocSize/(sizeof(DDXPointRec) + sizeof(int));
+ pptBase = (DDXPointRec*)infoRec->PreAllocMem;
+ pwidthBase = (int*)(&pptBase[MaxBoxes]);
+
+ pptNew = pptBase;
+ pwidthNew = pwidthBase;
+
+ numRects = RegionNumRects(pGC->pCompositeClip);
+
+ if(numRects == 1) {
+ BoxPtr pextent = RegionRects(pGC->pCompositeClip);
+
+ while(nspans--) {
+ if ((pextent->y1 <= ppt->y) && (ppt->y < pextent->y2)) {
+ pptNew->x = max(pextent->x1, ppt->x);
+ Right = ppt->x + *pwidth;
+ *pwidthNew = min(pextent->x2, Right) - pptNew->x;
+
+ if (*pwidthNew > 0) {
+ pptNew->y = ppt->y;
+ pptNew++;
+ pwidthNew++;
+
+ if(pptNew >= (pptBase + MaxBoxes)) {
+ (*func)(pGC, MaxBoxes, pptBase, pwidthBase, fSorted,
+ xorg, yorg);
+ pptNew = pptBase;
+ pwidthNew = pwidthBase;
+ }
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ } else if (numRects) {
+ BoxPtr pbox;
+ int nbox;
+
+ while(nspans--) {
+ nbox = numRects;
+ pbox = RegionRects(pGC->pCompositeClip);
+
+ /* find the first band */
+ while(nbox && (pbox->y2 <= ppt->y)) {
+ pbox++;
+ nbox--;
+ }
+
+ if(nbox && (pbox->y1 <= ppt->y)) {
+ int orig_y = pbox->y1;
+ Right = ppt->x + *pwidth;
+ while(nbox && (orig_y == pbox->y1)) {
+ if(pbox->x2 <= ppt->x) {
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ if(pbox->x1 >= Right) {
+ nbox = 0;
+ break;
+ }
+
+ pptNew->x = max(pbox->x1, ppt->x);
+ *pwidthNew = min(pbox->x2, Right) - pptNew->x;
+ if(*pwidthNew > 0) {
+ pptNew->y = ppt->y;
+ pptNew++;
+ pwidthNew++;
+
+ if(pptNew >= (pptBase + MaxBoxes)) {
+ (*func)(pGC, MaxBoxes, pptBase, pwidthBase,
+ fSorted, xorg, yorg);
+ pptNew = pptBase;
+ pwidthNew = pwidthBase;
+ }
+ }
+ pbox++;
+ nbox--;
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ }
+
+ if(pptNew != pptBase)
+ (*func)(pGC, pptNew - pptBase, pptBase, pwidthBase, fSorted,
+ xorg, yorg);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaStateChange.c b/xorg-server/hw/xfree86/xaa/xaaStateChange.c index 9c98a32f2..4eb15125b 100644 --- a/xorg-server/hw/xfree86/xaa/xaaStateChange.c +++ b/xorg-server/hw/xfree86/xaa/xaaStateChange.c @@ -272,8 +272,8 @@ typedef struct _XAAStateWrapRec { int width, int height, int flags);
} XAAStateWrapRec, *XAAStateWrapPtr;
-static int XAAStateKeyIndex;
-static DevPrivateKey XAAStateKey = &XAAStateKeyIndex;
+static DevPrivateKeyRec XAAStateKeyRec;
+#define XAAStateKey (&XAAStateKeyRec)
/* Wrap functions start here */
#define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\
@@ -1500,6 +1500,7 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec) XAAStateWrapPtr pStatePriv;
int i = 0;
+ if (!dixRegisterPrivateKey(&XAAStateKeyRec, PRIVATE_SCREEN, 0)) return FALSE;
if(!(pStatePriv = malloc(sizeof(XAAStateWrapRec)))) return FALSE;
dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv);
pStatePriv->RestoreAccelState = infoRec->RestoreAccelState;
diff --git a/xorg-server/hw/xfree86/xaa/xaaTEText.c b/xorg-server/hw/xfree86/xaa/xaaTEText.c index 1e28d3103..2cc5fc1e6 100644 --- a/xorg-server/hw/xfree86/xaa/xaaTEText.c +++ b/xorg-server/hw/xfree86/xaa/xaaTEText.c @@ -110,7 +110,7 @@ XAAImageText8TEColorExpansion( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
(*pGC->font->get_glyphs)(pGC->font, (unsigned long)count,
@@ -134,7 +134,7 @@ XAAImageText16TEColorExpansion( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
(*pGC->font->get_glyphs)(
@@ -169,7 +169,7 @@ XAAImageGlyphBltTEColorExpansion( {
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
XAAGlyphBltTEColorExpansion(
@@ -189,7 +189,7 @@ XAAPolyGlyphBltTEColorExpansion( {
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
XAAGlyphBltTEColorExpansion(
@@ -229,8 +229,8 @@ XAAGlyphBltTEColorExpansion( int skippix, skipglyphs;
int Left, Right, Top, Bottom;
int LeftEdge, RightEdge, ytop, ybot;
- int nbox = REGION_NUM_RECTS(cclip);
- BoxPtr pbox = REGION_RECTS(cclip);
+ int nbox = RegionNumRects(cclip);
+ BoxPtr pbox = RegionRects(cclip);
unsigned int **glyphs = NULL;
int glyphWidth = FONTMAXBOUNDS(font, characterWidth);
@@ -299,8 +299,7 @@ XAAGlyphBltTEColorExpansion( skippix, ytop - Top, glyphs + skipglyphs, glyphWidth,
fg, bg, rop, planemask);
- if (fallbackBits)
- free(fallbackBits);
+ free(fallbackBits);
}
nbox--; pbox++;
diff --git a/xorg-server/hw/xfree86/xaa/xaaWideLine.c b/xorg-server/hw/xfree86/xaa/xaaWideLine.c index a684d6676..f73e04f17 100644 --- a/xorg-server/hw/xfree86/xaa/xaaWideLine.c +++ b/xorg-server/hw/xfree86/xaa/xaaWideLine.c @@ -1,921 +1,921 @@ -/* - -XAAPolylinesWideSolid does not maintain a span list and subsequently does -not follow the "touch-each-pixel-once" rules for wide lines and arcs. -This means it can only be used in the case where we have -miSpansEasyRop(pGC->alu). Since we clip spans on the fly, we -limited usage of this function to one rect situations. This -function is used only for solid lines. - - Adapted from miWideLine by Mark Vojkovich (mvojkovi@ucsd.edu) -Original mi code written by Keith Packard. - -*/ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <math.h> - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include <X11/X.h> -#include "windowstr.h" -#include "gcstruct.h" -#include "regionstr.h" -#include "miwideline.h" -#include "mi.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" - -#define DRAW_POINT(pScrn, x, y) \ - if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); \ - else XAAPointHelper(pScrn, x, y) - -#define FILL_RECT(pScrn, x, y, w, h) \ - if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); \ - else XAAFillRectHelper(pScrn, x, y, w, h) - -#define FILL_SPAN(pScrn, x, y, w) \ - if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, 1); \ - else XAASpanHelper(pScrn, x, y, w) - - -#define CLIPSTEPEDGE(edgey,edge,edgeleft) \ - if (ybase == edgey) { \ - if (edgeleft) { \ - if (edge->x > xcl) \ - xcl = edge->x; \ - } else { \ - if (edge->x < xcr) \ - xcr = edge->x; \ - } \ - edgey++; \ - edge->x += edge->stepx; \ - edge->e += edge->dx; \ - if (edge->e > 0) { \ - edge->x += edge->signdx; \ - edge->e -= edge->dy; \ - } \ - } - -static void -XAAPointHelper(ScrnInfoPtr pScrn, int x, int y) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - BoxPtr extents = infoRec->ClipBox; - - if((x >= extents->x1) && (x < extents->x2) && - (y >= extents->y1) && (y < extents->y2)) - (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); -} - -static void -XAAFillRectHelper(ScrnInfoPtr pScrn, int x1, int y1, int dx, int dy) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - BoxPtr extents = infoRec->ClipBox; - int x2 = x1 + dx; - int y2 = y1 + dy; - - if(x1 < extents->x1) x1 = extents->x1; - if(x2 >= extents->x2) x2 = extents->x2; - if((dx = x2 - x1)<1) return; - if(y1 < extents->y1) y1 = extents->y1; - if(y2 >= extents->y2) y2 = extents->y2; - if((dy = y2 - y1)<1) return; - - (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y1, dx, dy); -} - - -static void -XAASpanHelper(ScrnInfoPtr pScrn, int x1, int y, int width) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - BoxPtr extents = infoRec->ClipBox; - int x2; - - if((y < extents->y1) || (y >= extents->y2)) return; - - x2 = x1 + width; - if(x1 < extents->x1) x1 = extents->x1; - if(x2 > extents->x2) x2 = extents->x2; - width = x2 - x1; - - if(width > 0) - (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y, width, 1); - -} - -#define FixError(x, dx, dy, e, sign, step, h) { \ - e += (h) * dx; \ - x += (h) * step; \ - if(e > 0) { \ - x += e * sign/dy; \ - e %= dy; \ - if(e) { \ - x += sign; \ - e -= dy; \ - } \ - } \ -} - - -static void -XAAFillPolyHelper ( - GCPtr pGC, - int y, /* start y coordinate */ - int overall_height, /* height of entire segment */ - PolyEdgePtr left, PolyEdgePtr right, - int left_count, int right_count ) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - BoxPtr extents = infoRec->ClipBox; - int left_x, left_e, left_stepx, left_signdx, left_dy, left_dx; - int right_x, right_e, right_stepx, right_signdx, right_dy, right_dx; - int height, left_height, right_height; - int xorg; - Bool hardClip; - - if((y >= extents->y2) || ((y + overall_height) <= extents->y1)) - return; - - /* Muffle compiler */ - left_x = left_e = left_stepx = left_signdx = left_dy = left_dx = 0; - right_x = right_e = right_stepx = right_signdx = right_dy = right_dx = 0; - - left_height = right_height = 0; - xorg = 0; - - hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - - while ((left_count || left_height) && (right_count || right_height)) { - if (!left_height && left_count) { - left_height = left->height; - left_x = left->x + xorg; - left_stepx = left->stepx; - left_signdx = left->signdx; - left_e = left->e; - left_dy = left->dy; - left_dx = left->dx; - left_count--; - left++; - } - if (!right_height && right_count) { - right_height = right->height; - right_x = right->x + xorg + 1; - right_stepx = right->stepx; - right_signdx = right->signdx; - right_e = right->e; - right_dy = right->dy; - right_dx = right->dx; - right_count--; - right++; - } - - height = (left_height > right_height) ? right_height : left_height; - - left_height -= height; - right_height -= height; - - if(hardClip && infoRec->SubsequentSolidFillTrap && (height > 6)) { - int right_DX, left_DX; - - right_DX = (right_dx * right_signdx) + (right_stepx * right_dy); - left_DX = (left_dx * left_signdx) + (left_stepx * left_dy); - - (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, y, height, - left_x, left_DX, left_dy, left_e, - right_x - 1, right_DX, right_dy, right_e); - - FixError(left_x, left_dx, left_dy, left_e, left_signdx, - left_stepx, height); - FixError(right_x, right_dx, right_dy, right_e, right_signdx, - right_stepx, height); - y += height; - continue; - } - - while (height--) { - if(right_x > left_x) { - FILL_SPAN(infoRec->pScrn, left_x, y, right_x - left_x); - } - y++; - - left_x += left_stepx; - left_e += left_dx; - if (left_e > 0) { - left_x += left_signdx; - left_e -= left_dy; - } - right_x += right_stepx; - right_e += right_dx; - if (right_e > 0) { - right_x += right_signdx; - right_e -= right_dy; - } - - } - } -} - - - -static void -XAAWideSegment ( - GCPtr pGC, - int x1, int y1, int x2, int y2, - Bool projectLeft, Bool projectRight, - LineFacePtr leftFace, LineFacePtr rightFace ) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - double l, L, r; - double xa, ya; - double projectXoff, projectYoff; - double k; - double maxy; - int x, y; - int dx, dy; - int finaly; - PolyEdgePtr left, right; - PolyEdgePtr top, bottom; - int lefty, righty, topy, bottomy; - int signdx; - PolyEdgeRec lefts[2], rights[2]; - LineFacePtr tface; - int lw = pGC->lineWidth; - Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - - /* draw top-to-bottom always */ - if ((y2 < y1) || ((y2 == y1) && (x2 < x1))) { - x = x1; - x1 = x2; - x2 = x; - - y = y1; - y1 = y2; - y2 = y; - - x = projectLeft; - projectLeft = projectRight; - projectRight = x; - - tface = leftFace; - leftFace = rightFace; - rightFace = tface; - } - - dy = y2 - y1; - signdx = 1; - dx = x2 - x1; - if (dx < 0) - signdx = -1; - - leftFace->x = x1; - leftFace->y = y1; - leftFace->dx = dx; - leftFace->dy = dy; - - rightFace->x = x2; - rightFace->y = y2; - rightFace->dx = -dx; - rightFace->dy = -dy; - - if (!dy) { - rightFace->xa = 0; - rightFace->ya = (double) lw / 2.0; - rightFace->k = -(double) (lw * dx) / 2.0; - leftFace->xa = 0; - leftFace->ya = -rightFace->ya; - leftFace->k = rightFace->k; - x = x1; - if (projectLeft) - x -= (lw >> 1); - y = y1 - (lw >> 1); - dx = x2 - x; - if (projectRight) - dx += ((lw + 1) >> 1); - dy = lw; - FILL_RECT(infoRec->pScrn, x, y, dx, dy); - } else if (!dx) { - leftFace->xa = (double) lw / 2.0; - leftFace->ya = 0; - leftFace->k = (double) (lw * dy) / 2.0; - rightFace->xa = -leftFace->xa; - rightFace->ya = 0; - rightFace->k = leftFace->k; - y = y1; - if (projectLeft) - y -= lw >> 1; - x = x1 - (lw >> 1); - dy = y2 - y; - if (projectRight) - dy += ((lw + 1) >> 1); - dx = lw; - FILL_RECT(infoRec->pScrn, x, y, dx, dy); - } else { - l = ((double) lw) / 2.0; - L = sqrt((double)(dx*dx + dy*dy)); - - if (dx < 0) { - right = &rights[1]; - left = &lefts[0]; - top = &rights[0]; - bottom = &lefts[1]; - } else { - right = &rights[0]; - left = &lefts[1]; - top = &lefts[0]; - bottom = &rights[1]; - } - r = l / L; - - /* coord of upper bound at integral y */ - ya = -r * dx; - xa = r * dy; - - projectXoff = -ya; - projectYoff = xa; - - /* xa * dy - ya * dx */ - k = l * L; - - leftFace->xa = xa; - leftFace->ya = ya; - leftFace->k = k; - rightFace->xa = -xa; - rightFace->ya = -ya; - rightFace->k = k; - - if (projectLeft) - righty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff, - k, dx, dy, x1, y1, 0, right); - else - righty = miPolyBuildEdge (xa, ya, - k, dx, dy, x1, y1, 0, right); - - /* coord of lower bound at integral y */ - ya = -ya; - xa = -xa; - - /* xa * dy - ya * dx */ - k = - k; - - if (projectLeft) - lefty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff, - k, dx, dy, x1, y1, 1, left); - else - lefty = miPolyBuildEdge (xa, ya, - k, dx, dy, x1, y1, 1, left); - - /* coord of top face at integral y */ - - if (signdx > 0) { - ya = -ya; - xa = -xa; - } - - if (projectLeft) { - double xap = xa - projectXoff; - double yap = ya - projectYoff; - topy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy, - -dy, dx, x1, y1, dx > 0, top); - } - else - topy = miPolyBuildEdge(xa, ya, 0.0, - -dy, dx, x1, y1, dx > 0, top); - - /* coord of bottom face at integral y */ - - if (projectRight) { - double xap = xa + projectXoff; - double yap = ya + projectYoff; - bottomy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy, - -dy, dx, x2, y2, dx < 0, bottom); - maxy = -ya + projectYoff; - } else { - bottomy = miPolyBuildEdge (xa, ya, 0.0, - -dy, dx, x2, y2, dx < 0, bottom); - maxy = -ya; - } - - finaly = ICEIL (maxy) + y2; - - if (dx < 0) { - left->height = bottomy - lefty; - right->height = finaly - righty; - top->height = righty - topy; - } else { - right->height = bottomy - righty; - left->height = finaly - lefty; - top->height = lefty - topy; - } - bottom->height = finaly - bottomy; - XAAFillPolyHelper (pGC, topy, - bottom->height + bottomy - topy, lefts, rights, 2, 2); - } -} - - -static void -XAALineArcI (GCPtr pGC, int xorg, int yorg) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int x, y, e, ex; - int slw = pGC->lineWidth; - Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - - y = (slw >> 1) + 1; - if (slw & 1) - e = - ((y << 2) + 3); - else - e = - (y << 3); - ex = -4; - x = 0; - while (y) { - e += (y << 3) - 4; - while (e >= 0) { - x++; - e += (ex = -((x << 3) + 4)); - } - y--; - slw = (x << 1) + 1; - if ((e == ex) && (slw > 1)) - slw--; - - FILL_SPAN(infoRec->pScrn, xorg - x, yorg - y, slw); - - if ((y != 0) && ((slw > 1) || (e != ex))) { - FILL_SPAN(infoRec->pScrn, xorg - x, yorg + y, slw); - } - } -} - - -static void -XAALineArcD ( - GCPtr pGC, - double xorg, - double yorg, - PolyEdgePtr edge1, - int edgey1, - Bool edgeleft1, - PolyEdgePtr edge2, - int edgey2, - Bool edgeleft2 ) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - double radius, x0, y0, el, er, yk, xlk, xrk, k; - int xbase, ybase, y, boty, xl, xr, xcl, xcr; - int ymin, ymax; - Bool edge1IsMin, edge2IsMin; - int ymin1, ymin2; - Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - - - xbase = floor(xorg); - x0 = xorg - xbase; - ybase = ICEIL (yorg); - y0 = yorg - ybase; - - xlk = x0 + x0 + 1.0; - xrk = x0 + x0 - 1.0; - yk = y0 + y0 - 1.0; - radius = ((double)pGC->lineWidth) / 2.0; - y = floor(radius - y0 + 1.0); - ybase -= y; - ymin = ybase; - ymax = 65536; - edge1IsMin = FALSE; - ymin1 = edgey1; - if (edge1->dy >= 0) { - if (!edge1->dy) { - if (edgeleft1) - edge1IsMin = TRUE; - else - ymax = edgey1; - edgey1 = 65536; - } else if ((edge1->signdx < 0) == edgeleft1) - edge1IsMin = TRUE; - } - edge2IsMin = FALSE; - ymin2 = edgey2; - if (edge2->dy >= 0) { - if (!edge2->dy) { - if (edgeleft2) - edge2IsMin = TRUE; - else - ymax = edgey2; - edgey2 = 65536; - } else if ((edge2->signdx < 0) == edgeleft2) - edge2IsMin = TRUE; - } - if (edge1IsMin) { - ymin = ymin1; - if (edge2IsMin && (ymin1 > ymin2)) - ymin = ymin2; - } else if (edge2IsMin) - ymin = ymin2; - el = radius * radius - ((y + y0) * (y + y0)) - (x0 * x0); - er = el + xrk; - xl = 1; - xr = 0; - if (x0 < 0.5) { - xl = 0; - el -= xlk; - } - boty = (y0 < -0.5) ? 1 : 0; - if (ybase + y - boty > ymax) - boty = ymax - ybase - y; - while (y > boty) { - k = (y << 1) + yk; - er += k; - while (er > 0.0) { - xr++; - er += xrk - (xr << 1); - } - el += k; - while (el >= 0.0) { - xl--; - el += (xl << 1) - xlk; - } - y--; - ybase++; - if (ybase < ymin) - continue; - xcl = xl + xbase; - xcr = xr + xbase; - CLIPSTEPEDGE(edgey1, edge1, edgeleft1); - CLIPSTEPEDGE(edgey2, edge2, edgeleft2); - if(xcr >= xcl) { - FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1); - } - } - er = xrk - (xr << 1) - er; - el = (xl << 1) - xlk - el; - boty = floor(-y0 - radius + 1.0); - if (ybase + y - boty > ymax) - boty = ymax - ybase - y; - while (y > boty) { - k = (y << 1) + yk; - er -= k; - while ((er >= 0.0) && (xr >= 0)) { - xr--; - er += xrk - (xr << 1); - } - el -= k; - while ((el > 0.0) && (xl <= 0)) { - xl++; - el += (xl << 1) - xlk; - } - y--; - ybase++; - if (ybase < ymin) - continue; - xcl = xl + xbase; - xcr = xr + xbase; - CLIPSTEPEDGE(edgey1, edge1, edgeleft1); - CLIPSTEPEDGE(edgey2, edge2, edgeleft2); - if(xcr >= xcl) { - FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1); - } - } -} - - -static void -XAALineArc ( - GCPtr pGC, - LineFacePtr leftFace, - LineFacePtr rightFace, - double xorg, - double yorg, - Bool isInt ) -{ - int xorgi, yorgi; - PolyEdgeRec edge1, edge2; - int edgey1, edgey2; - Bool edgeleft1, edgeleft2; - - if (isInt) { - xorgi = leftFace ? leftFace->x : rightFace->x; - yorgi = leftFace ? leftFace->y : rightFace->y; - } else { /* Muffle compiler */ - xorgi = yorgi = 0; - } - edgey1 = 65536; - edgey2 = 65536; - edge1.x = 0; /* not used, keep memory checkers happy */ - edge1.dy = -1; - edge2.x = 0; /* not used, keep memory checkers happy */ - edge2.dy = -1; - edgeleft1 = FALSE; - edgeleft2 = FALSE; - - if ((pGC->lineWidth > 2) && - ((pGC->capStyle == CapRound && pGC->joinStyle != JoinRound) || - (pGC->joinStyle == JoinRound && pGC->capStyle == CapButt))) { - if (isInt) { - xorg = (double) xorgi; - yorg = (double) yorgi; - } - - if (leftFace && rightFace) - miRoundJoinClip (leftFace, rightFace, &edge1, &edge2, - &edgey1, &edgey2, &edgeleft1, &edgeleft2); - else if (leftFace) - edgey1 = miRoundCapClip (leftFace, isInt, &edge1, &edgeleft1); - else if (rightFace) - edgey2 = miRoundCapClip (rightFace, isInt, &edge2, &edgeleft2); - - isInt = FALSE; - } - - if (isInt) { - if(pGC->lineWidth == 1) { - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - DRAW_POINT(infoRec->pScrn, xorgi, yorgi); - } else - XAALineArcI(pGC, xorgi, yorgi); - } else - XAALineArcD(pGC, xorg, yorg, &edge1, edgey1, edgeleft1, - &edge2, edgey2, edgeleft2); - -} - - -static void -XAALineJoin ( - GCPtr pGC, - LineFacePtr pLeft, - LineFacePtr pRight ) -{ - double mx = 0, my = 0; - double denom = 0; - PolyVertexRec vertices[4]; - PolySlopeRec slopes[4]; - int edgecount; - PolyEdgeRec left[4], right[4]; - int nleft, nright; - int y, height; - int swapslopes; - int joinStyle = pGC->joinStyle; - int lw = pGC->lineWidth; - - if (lw == 1) { - /* Lines going in the same direction have no join */ - if ((pLeft->dx >= 0) == (pRight->dx <= 0)) - return; - if (joinStyle != JoinRound) { - denom = - pLeft->dx * (double)pRight->dy + pRight->dx * - (double)pLeft->dy; - if (denom == 0.0) - return; /* no join to draw */ - } - if (joinStyle != JoinMiter) { - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - DRAW_POINT(infoRec->pScrn, pLeft->x, pLeft->y); - return; - } - } else { - if (joinStyle == JoinRound) { - XAALineArc(pGC, pLeft, pRight,(double)0.0, (double)0.0, TRUE); - return; - } - denom = - pLeft->dx * (double)pRight->dy + pRight->dx * - (double)pLeft->dy; - if (denom == 0.0) - return; /* no join to draw */ - } - - swapslopes = 0; - if (denom > 0) { - pLeft->xa = -pLeft->xa; - pLeft->ya = -pLeft->ya; - pLeft->dx = -pLeft->dx; - pLeft->dy = -pLeft->dy; - } else { - swapslopes = 1; - pRight->xa = -pRight->xa; - pRight->ya = -pRight->ya; - pRight->dx = -pRight->dx; - pRight->dy = -pRight->dy; - } - - vertices[0].x = pRight->xa; - vertices[0].y = pRight->ya; - slopes[0].dx = -pRight->dy; - slopes[0].dy = pRight->dx; - slopes[0].k = 0; - - vertices[1].x = 0; - vertices[1].y = 0; - slopes[1].dx = pLeft->dy; - slopes[1].dy = -pLeft->dx; - slopes[1].k = 0; - - vertices[2].x = pLeft->xa; - vertices[2].y = pLeft->ya; - - if (joinStyle == JoinMiter) { - my = (pLeft->dy * (pRight->xa * pRight->dy - pRight->ya * pRight->dx) - - pRight->dy * (pLeft->xa * pLeft->dy - pLeft->ya * pLeft->dx ))/ - denom; - if (pLeft->dy != 0) - mx = pLeft->xa + (my - pLeft->ya) * - (double) pLeft->dx / (double) pLeft->dy; - else - mx = pRight->xa + (my - pRight->ya) * - (double) pRight->dx / (double) pRight->dy; - - /* check miter limit */ - if ((mx * mx + my * my) * 4 > SQSECANT * lw * lw) - joinStyle = JoinBevel; - } - - if (joinStyle == JoinMiter) { - slopes[2].dx = pLeft->dx; - slopes[2].dy = pLeft->dy; - slopes[2].k = pLeft->k; - if (swapslopes) { - slopes[2].dx = -slopes[2].dx; - slopes[2].dy = -slopes[2].dy; - slopes[2].k = -slopes[2].k; - } - vertices[3].x = mx; - vertices[3].y = my; - slopes[3].dx = pRight->dx; - slopes[3].dy = pRight->dy; - slopes[3].k = pRight->k; - if (swapslopes) { - slopes[3].dx = -slopes[3].dx; - slopes[3].dy = -slopes[3].dy; - slopes[3].k = -slopes[3].k; - } - edgecount = 4; - } else { - double scale, dx, dy, adx, ady; - - adx = dx = pRight->xa - pLeft->xa; - ady = dy = pRight->ya - pLeft->ya; - if (adx < 0) - adx = -adx; - if (ady < 0) - ady = -ady; - scale = ady; - if (adx > ady) - scale = adx; - slopes[2].dx = (dx * 65536) / scale; - slopes[2].dy = (dy * 65536) / scale; - slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy - - (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0; - edgecount = 3; - } - - y = miPolyBuildPoly (vertices, slopes, edgecount, pLeft->x, pLeft->y, - left, right, &nleft, &nright, &height); - XAAFillPolyHelper(pGC, y, height, left, right, nleft, nright); -} - - -void -XAAPolylinesWideSolid ( - DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr pPts ) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int x1, y1, x2, y2; - Bool projectLeft, projectRight; - LineFaceRec leftFace, rightFace, prevRightFace, firstFace; - int first = TRUE; - Bool somethingDrawn = FALSE; - Bool selfJoin = FALSE; - int xorg = pDrawable->x; - int yorg = pDrawable->y; - Bool hardClip = FALSE; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - if(REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { - miWideLine(pDrawable, pGC, mode, npt, pPts); - return; - } - - x2 = pPts->x; - y2 = pPts->y; - if (npt > 1) { - if (mode == CoordModePrevious) { - int nptTmp; - register DDXPointPtr pPtsTmp; - - x1 = x2; - y1 = y2; - nptTmp = npt; - pPtsTmp = pPts + 1; - while (--nptTmp) { - x1 += pPtsTmp->x; - y1 += pPtsTmp->y; - ++pPtsTmp; - } - if ((x2 == x1) && (y2 == y1)) - selfJoin = TRUE; - } else if ((x2 == pPts[npt-1].x) && (y2 == pPts[npt-1].y)) - selfJoin = TRUE; - } - - projectLeft = ((pGC->capStyle == CapProjecting) && !selfJoin); - projectRight = FALSE; - - (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, - pGC->planemask); - - infoRec->ClipBox = &pGC->pCompositeClip->extents; - - if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) { - hardClip = TRUE; - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - } - - x2 += xorg; - y2 += yorg; - while (--npt) { - x1 = x2; - y1 = y2; - ++pPts; - x2 = pPts->x; - y2 = pPts->y; - if (mode == CoordModePrevious) { - x2 += x1; - y2 += y1; - } else { - x2 += xorg; - y2 += yorg; - } - if ((x1 != x2) || (y1 != y2)) { - somethingDrawn = TRUE; - if ((npt == 1) && (pGC->capStyle == CapProjecting) && !selfJoin) - projectRight = TRUE; - XAAWideSegment(pGC, x1, y1, x2, y2, - projectLeft, projectRight, &leftFace, &rightFace); - if (first) { - if (selfJoin) - firstFace = leftFace; - else if (pGC->capStyle == CapRound) { - if (pGC->lineWidth == 1) { - DRAW_POINT(infoRec->pScrn, x1, y1); - } else - XAALineArc(pGC,&leftFace, (LineFacePtr) NULL, - (double)0.0, (double)0.0,TRUE); - } - } else - XAALineJoin (pGC, &leftFace, &prevRightFace); - - prevRightFace = rightFace; - first = FALSE; - projectLeft = FALSE; - } - if (npt == 1 && somethingDrawn) { - if (selfJoin) - XAALineJoin (pGC, &firstFace, &rightFace); - else if (pGC->capStyle == CapRound) { - if (pGC->lineWidth == 1) { - DRAW_POINT(infoRec->pScrn, x2, y2); - } else - XAALineArc (pGC, (LineFacePtr) NULL, &rightFace, - (double)0.0, (double)0.0,TRUE); - } - } - } - /* handle crock where all points are coincedent */ - if (!somethingDrawn) { - projectLeft = (pGC->capStyle == CapProjecting); - XAAWideSegment (pGC, x2, y2, x2, y2, projectLeft, projectLeft, - &leftFace, &rightFace); - if (pGC->capStyle == CapRound) { - XAALineArc (pGC, &leftFace, (LineFacePtr) NULL, - (double)0.0, (double)0.0, TRUE); - rightFace.dx = -1; /* sleezy hack to make it work */ - XAALineArc (pGC, (LineFacePtr) NULL, &rightFace, - (double)0.0, (double)0.0, TRUE); - } - } - - infoRec->ClipBox = NULL; - if(hardClip) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} +/*
+
+XAAPolylinesWideSolid does not maintain a span list and subsequently does
+not follow the "touch-each-pixel-once" rules for wide lines and arcs.
+This means it can only be used in the case where we have
+miSpansEasyRop(pGC->alu). Since we clip spans on the fly, we
+limited usage of this function to one rect situations. This
+function is used only for solid lines.
+
+ Adapted from miWideLine by Mark Vojkovich (mvojkovi@ucsd.edu)
+Original mi code written by Keith Packard.
+
+*/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <math.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "regionstr.h"
+#include "miwideline.h"
+#include "mi.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+#define DRAW_POINT(pScrn, x, y) \
+ if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); \
+ else XAAPointHelper(pScrn, x, y)
+
+#define FILL_RECT(pScrn, x, y, w, h) \
+ if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); \
+ else XAAFillRectHelper(pScrn, x, y, w, h)
+
+#define FILL_SPAN(pScrn, x, y, w) \
+ if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, 1); \
+ else XAASpanHelper(pScrn, x, y, w)
+
+
+#define CLIPSTEPEDGE(edgey,edge,edgeleft) \
+ if (ybase == edgey) { \
+ if (edgeleft) { \
+ if (edge->x > xcl) \
+ xcl = edge->x; \
+ } else { \
+ if (edge->x < xcr) \
+ xcr = edge->x; \
+ } \
+ edgey++; \
+ edge->x += edge->stepx; \
+ edge->e += edge->dx; \
+ if (edge->e > 0) { \
+ edge->x += edge->signdx; \
+ edge->e -= edge->dy; \
+ } \
+ }
+
+static void
+XAAPointHelper(ScrnInfoPtr pScrn, int x, int y)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ BoxPtr extents = infoRec->ClipBox;
+
+ if((x >= extents->x1) && (x < extents->x2) &&
+ (y >= extents->y1) && (y < extents->y2))
+ (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1);
+}
+
+static void
+XAAFillRectHelper(ScrnInfoPtr pScrn, int x1, int y1, int dx, int dy)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ BoxPtr extents = infoRec->ClipBox;
+ int x2 = x1 + dx;
+ int y2 = y1 + dy;
+
+ if(x1 < extents->x1) x1 = extents->x1;
+ if(x2 >= extents->x2) x2 = extents->x2;
+ if((dx = x2 - x1)<1) return;
+ if(y1 < extents->y1) y1 = extents->y1;
+ if(y2 >= extents->y2) y2 = extents->y2;
+ if((dy = y2 - y1)<1) return;
+
+ (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y1, dx, dy);
+}
+
+
+static void
+XAASpanHelper(ScrnInfoPtr pScrn, int x1, int y, int width)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ BoxPtr extents = infoRec->ClipBox;
+ int x2;
+
+ if((y < extents->y1) || (y >= extents->y2)) return;
+
+ x2 = x1 + width;
+ if(x1 < extents->x1) x1 = extents->x1;
+ if(x2 > extents->x2) x2 = extents->x2;
+ width = x2 - x1;
+
+ if(width > 0)
+ (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y, width, 1);
+
+}
+
+#define FixError(x, dx, dy, e, sign, step, h) { \
+ e += (h) * dx; \
+ x += (h) * step; \
+ if(e > 0) { \
+ x += e * sign/dy; \
+ e %= dy; \
+ if(e) { \
+ x += sign; \
+ e -= dy; \
+ } \
+ } \
+}
+
+
+static void
+XAAFillPolyHelper (
+ GCPtr pGC,
+ int y, /* start y coordinate */
+ int overall_height, /* height of entire segment */
+ PolyEdgePtr left, PolyEdgePtr right,
+ int left_count, int right_count )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ BoxPtr extents = infoRec->ClipBox;
+ int left_x, left_e, left_stepx, left_signdx, left_dy, left_dx;
+ int right_x, right_e, right_stepx, right_signdx, right_dy, right_dx;
+ int height, left_height, right_height;
+ int xorg;
+ Bool hardClip;
+
+ if((y >= extents->y2) || ((y + overall_height) <= extents->y1))
+ return;
+
+ /* Muffle compiler */
+ left_x = left_e = left_stepx = left_signdx = left_dy = left_dx = 0;
+ right_x = right_e = right_stepx = right_signdx = right_dy = right_dx = 0;
+
+ left_height = right_height = 0;
+ xorg = 0;
+
+ hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ while ((left_count || left_height) && (right_count || right_height)) {
+ if (!left_height && left_count) {
+ left_height = left->height;
+ left_x = left->x + xorg;
+ left_stepx = left->stepx;
+ left_signdx = left->signdx;
+ left_e = left->e;
+ left_dy = left->dy;
+ left_dx = left->dx;
+ left_count--;
+ left++;
+ }
+ if (!right_height && right_count) {
+ right_height = right->height;
+ right_x = right->x + xorg + 1;
+ right_stepx = right->stepx;
+ right_signdx = right->signdx;
+ right_e = right->e;
+ right_dy = right->dy;
+ right_dx = right->dx;
+ right_count--;
+ right++;
+ }
+
+ height = (left_height > right_height) ? right_height : left_height;
+
+ left_height -= height;
+ right_height -= height;
+
+ if(hardClip && infoRec->SubsequentSolidFillTrap && (height > 6)) {
+ int right_DX, left_DX;
+
+ right_DX = (right_dx * right_signdx) + (right_stepx * right_dy);
+ left_DX = (left_dx * left_signdx) + (left_stepx * left_dy);
+
+ (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, y, height,
+ left_x, left_DX, left_dy, left_e,
+ right_x - 1, right_DX, right_dy, right_e);
+
+ FixError(left_x, left_dx, left_dy, left_e, left_signdx,
+ left_stepx, height);
+ FixError(right_x, right_dx, right_dy, right_e, right_signdx,
+ right_stepx, height);
+ y += height;
+ continue;
+ }
+
+ while (height--) {
+ if(right_x > left_x) {
+ FILL_SPAN(infoRec->pScrn, left_x, y, right_x - left_x);
+ }
+ y++;
+
+ left_x += left_stepx;
+ left_e += left_dx;
+ if (left_e > 0) {
+ left_x += left_signdx;
+ left_e -= left_dy;
+ }
+ right_x += right_stepx;
+ right_e += right_dx;
+ if (right_e > 0) {
+ right_x += right_signdx;
+ right_e -= right_dy;
+ }
+
+ }
+ }
+}
+
+
+
+static void
+XAAWideSegment (
+ GCPtr pGC,
+ int x1, int y1, int x2, int y2,
+ Bool projectLeft, Bool projectRight,
+ LineFacePtr leftFace, LineFacePtr rightFace )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ double l, L, r;
+ double xa, ya;
+ double projectXoff, projectYoff;
+ double k;
+ double maxy;
+ int x, y;
+ int dx, dy;
+ int finaly;
+ PolyEdgePtr left, right;
+ PolyEdgePtr top, bottom;
+ int lefty, righty, topy, bottomy;
+ int signdx;
+ PolyEdgeRec lefts[2], rights[2];
+ LineFacePtr tface;
+ int lw = pGC->lineWidth;
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ /* draw top-to-bottom always */
+ if ((y2 < y1) || ((y2 == y1) && (x2 < x1))) {
+ x = x1;
+ x1 = x2;
+ x2 = x;
+
+ y = y1;
+ y1 = y2;
+ y2 = y;
+
+ x = projectLeft;
+ projectLeft = projectRight;
+ projectRight = x;
+
+ tface = leftFace;
+ leftFace = rightFace;
+ rightFace = tface;
+ }
+
+ dy = y2 - y1;
+ signdx = 1;
+ dx = x2 - x1;
+ if (dx < 0)
+ signdx = -1;
+
+ leftFace->x = x1;
+ leftFace->y = y1;
+ leftFace->dx = dx;
+ leftFace->dy = dy;
+
+ rightFace->x = x2;
+ rightFace->y = y2;
+ rightFace->dx = -dx;
+ rightFace->dy = -dy;
+
+ if (!dy) {
+ rightFace->xa = 0;
+ rightFace->ya = (double) lw / 2.0;
+ rightFace->k = -(double) (lw * dx) / 2.0;
+ leftFace->xa = 0;
+ leftFace->ya = -rightFace->ya;
+ leftFace->k = rightFace->k;
+ x = x1;
+ if (projectLeft)
+ x -= (lw >> 1);
+ y = y1 - (lw >> 1);
+ dx = x2 - x;
+ if (projectRight)
+ dx += ((lw + 1) >> 1);
+ dy = lw;
+ FILL_RECT(infoRec->pScrn, x, y, dx, dy);
+ } else if (!dx) {
+ leftFace->xa = (double) lw / 2.0;
+ leftFace->ya = 0;
+ leftFace->k = (double) (lw * dy) / 2.0;
+ rightFace->xa = -leftFace->xa;
+ rightFace->ya = 0;
+ rightFace->k = leftFace->k;
+ y = y1;
+ if (projectLeft)
+ y -= lw >> 1;
+ x = x1 - (lw >> 1);
+ dy = y2 - y;
+ if (projectRight)
+ dy += ((lw + 1) >> 1);
+ dx = lw;
+ FILL_RECT(infoRec->pScrn, x, y, dx, dy);
+ } else {
+ l = ((double) lw) / 2.0;
+ L = sqrt((double)(dx*dx + dy*dy));
+
+ if (dx < 0) {
+ right = &rights[1];
+ left = &lefts[0];
+ top = &rights[0];
+ bottom = &lefts[1];
+ } else {
+ right = &rights[0];
+ left = &lefts[1];
+ top = &lefts[0];
+ bottom = &rights[1];
+ }
+ r = l / L;
+
+ /* coord of upper bound at integral y */
+ ya = -r * dx;
+ xa = r * dy;
+
+ projectXoff = -ya;
+ projectYoff = xa;
+
+ /* xa * dy - ya * dx */
+ k = l * L;
+
+ leftFace->xa = xa;
+ leftFace->ya = ya;
+ leftFace->k = k;
+ rightFace->xa = -xa;
+ rightFace->ya = -ya;
+ rightFace->k = k;
+
+ if (projectLeft)
+ righty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
+ k, dx, dy, x1, y1, 0, right);
+ else
+ righty = miPolyBuildEdge (xa, ya,
+ k, dx, dy, x1, y1, 0, right);
+
+ /* coord of lower bound at integral y */
+ ya = -ya;
+ xa = -xa;
+
+ /* xa * dy - ya * dx */
+ k = - k;
+
+ if (projectLeft)
+ lefty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
+ k, dx, dy, x1, y1, 1, left);
+ else
+ lefty = miPolyBuildEdge (xa, ya,
+ k, dx, dy, x1, y1, 1, left);
+
+ /* coord of top face at integral y */
+
+ if (signdx > 0) {
+ ya = -ya;
+ xa = -xa;
+ }
+
+ if (projectLeft) {
+ double xap = xa - projectXoff;
+ double yap = ya - projectYoff;
+ topy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
+ -dy, dx, x1, y1, dx > 0, top);
+ }
+ else
+ topy = miPolyBuildEdge(xa, ya, 0.0,
+ -dy, dx, x1, y1, dx > 0, top);
+
+ /* coord of bottom face at integral y */
+
+ if (projectRight) {
+ double xap = xa + projectXoff;
+ double yap = ya + projectYoff;
+ bottomy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
+ -dy, dx, x2, y2, dx < 0, bottom);
+ maxy = -ya + projectYoff;
+ } else {
+ bottomy = miPolyBuildEdge (xa, ya, 0.0,
+ -dy, dx, x2, y2, dx < 0, bottom);
+ maxy = -ya;
+ }
+
+ finaly = ICEIL (maxy) + y2;
+
+ if (dx < 0) {
+ left->height = bottomy - lefty;
+ right->height = finaly - righty;
+ top->height = righty - topy;
+ } else {
+ right->height = bottomy - righty;
+ left->height = finaly - lefty;
+ top->height = lefty - topy;
+ }
+ bottom->height = finaly - bottomy;
+ XAAFillPolyHelper (pGC, topy,
+ bottom->height + bottomy - topy, lefts, rights, 2, 2);
+ }
+}
+
+
+static void
+XAALineArcI (GCPtr pGC, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int x, y, e, ex;
+ int slw = pGC->lineWidth;
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ y = (slw >> 1) + 1;
+ if (slw & 1)
+ e = - ((y << 2) + 3);
+ else
+ e = - (y << 3);
+ ex = -4;
+ x = 0;
+ while (y) {
+ e += (y << 3) - 4;
+ while (e >= 0) {
+ x++;
+ e += (ex = -((x << 3) + 4));
+ }
+ y--;
+ slw = (x << 1) + 1;
+ if ((e == ex) && (slw > 1))
+ slw--;
+
+ FILL_SPAN(infoRec->pScrn, xorg - x, yorg - y, slw);
+
+ if ((y != 0) && ((slw > 1) || (e != ex))) {
+ FILL_SPAN(infoRec->pScrn, xorg - x, yorg + y, slw);
+ }
+ }
+}
+
+
+static void
+XAALineArcD (
+ GCPtr pGC,
+ double xorg,
+ double yorg,
+ PolyEdgePtr edge1,
+ int edgey1,
+ Bool edgeleft1,
+ PolyEdgePtr edge2,
+ int edgey2,
+ Bool edgeleft2 )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ double radius, x0, y0, el, er, yk, xlk, xrk, k;
+ int xbase, ybase, y, boty, xl, xr, xcl, xcr;
+ int ymin, ymax;
+ Bool edge1IsMin, edge2IsMin;
+ int ymin1, ymin2;
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+
+ xbase = floor(xorg);
+ x0 = xorg - xbase;
+ ybase = ICEIL (yorg);
+ y0 = yorg - ybase;
+
+ xlk = x0 + x0 + 1.0;
+ xrk = x0 + x0 - 1.0;
+ yk = y0 + y0 - 1.0;
+ radius = ((double)pGC->lineWidth) / 2.0;
+ y = floor(radius - y0 + 1.0);
+ ybase -= y;
+ ymin = ybase;
+ ymax = 65536;
+ edge1IsMin = FALSE;
+ ymin1 = edgey1;
+ if (edge1->dy >= 0) {
+ if (!edge1->dy) {
+ if (edgeleft1)
+ edge1IsMin = TRUE;
+ else
+ ymax = edgey1;
+ edgey1 = 65536;
+ } else if ((edge1->signdx < 0) == edgeleft1)
+ edge1IsMin = TRUE;
+ }
+ edge2IsMin = FALSE;
+ ymin2 = edgey2;
+ if (edge2->dy >= 0) {
+ if (!edge2->dy) {
+ if (edgeleft2)
+ edge2IsMin = TRUE;
+ else
+ ymax = edgey2;
+ edgey2 = 65536;
+ } else if ((edge2->signdx < 0) == edgeleft2)
+ edge2IsMin = TRUE;
+ }
+ if (edge1IsMin) {
+ ymin = ymin1;
+ if (edge2IsMin && (ymin1 > ymin2))
+ ymin = ymin2;
+ } else if (edge2IsMin)
+ ymin = ymin2;
+ el = radius * radius - ((y + y0) * (y + y0)) - (x0 * x0);
+ er = el + xrk;
+ xl = 1;
+ xr = 0;
+ if (x0 < 0.5) {
+ xl = 0;
+ el -= xlk;
+ }
+ boty = (y0 < -0.5) ? 1 : 0;
+ if (ybase + y - boty > ymax)
+ boty = ymax - ybase - y;
+ while (y > boty) {
+ k = (y << 1) + yk;
+ er += k;
+ while (er > 0.0) {
+ xr++;
+ er += xrk - (xr << 1);
+ }
+ el += k;
+ while (el >= 0.0) {
+ xl--;
+ el += (xl << 1) - xlk;
+ }
+ y--;
+ ybase++;
+ if (ybase < ymin)
+ continue;
+ xcl = xl + xbase;
+ xcr = xr + xbase;
+ CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
+ CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
+ if(xcr >= xcl) {
+ FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1);
+ }
+ }
+ er = xrk - (xr << 1) - er;
+ el = (xl << 1) - xlk - el;
+ boty = floor(-y0 - radius + 1.0);
+ if (ybase + y - boty > ymax)
+ boty = ymax - ybase - y;
+ while (y > boty) {
+ k = (y << 1) + yk;
+ er -= k;
+ while ((er >= 0.0) && (xr >= 0)) {
+ xr--;
+ er += xrk - (xr << 1);
+ }
+ el -= k;
+ while ((el > 0.0) && (xl <= 0)) {
+ xl++;
+ el += (xl << 1) - xlk;
+ }
+ y--;
+ ybase++;
+ if (ybase < ymin)
+ continue;
+ xcl = xl + xbase;
+ xcr = xr + xbase;
+ CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
+ CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
+ if(xcr >= xcl) {
+ FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1);
+ }
+ }
+}
+
+
+static void
+XAALineArc (
+ GCPtr pGC,
+ LineFacePtr leftFace,
+ LineFacePtr rightFace,
+ double xorg,
+ double yorg,
+ Bool isInt )
+{
+ int xorgi, yorgi;
+ PolyEdgeRec edge1, edge2;
+ int edgey1, edgey2;
+ Bool edgeleft1, edgeleft2;
+
+ if (isInt) {
+ xorgi = leftFace ? leftFace->x : rightFace->x;
+ yorgi = leftFace ? leftFace->y : rightFace->y;
+ } else { /* Muffle compiler */
+ xorgi = yorgi = 0;
+ }
+ edgey1 = 65536;
+ edgey2 = 65536;
+ edge1.x = 0; /* not used, keep memory checkers happy */
+ edge1.dy = -1;
+ edge2.x = 0; /* not used, keep memory checkers happy */
+ edge2.dy = -1;
+ edgeleft1 = FALSE;
+ edgeleft2 = FALSE;
+
+ if ((pGC->lineWidth > 2) &&
+ ((pGC->capStyle == CapRound && pGC->joinStyle != JoinRound) ||
+ (pGC->joinStyle == JoinRound && pGC->capStyle == CapButt))) {
+ if (isInt) {
+ xorg = (double) xorgi;
+ yorg = (double) yorgi;
+ }
+
+ if (leftFace && rightFace)
+ miRoundJoinClip (leftFace, rightFace, &edge1, &edge2,
+ &edgey1, &edgey2, &edgeleft1, &edgeleft2);
+ else if (leftFace)
+ edgey1 = miRoundCapClip (leftFace, isInt, &edge1, &edgeleft1);
+ else if (rightFace)
+ edgey2 = miRoundCapClip (rightFace, isInt, &edge2, &edgeleft2);
+
+ isInt = FALSE;
+ }
+
+ if (isInt) {
+ if(pGC->lineWidth == 1) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+ DRAW_POINT(infoRec->pScrn, xorgi, yorgi);
+ } else
+ XAALineArcI(pGC, xorgi, yorgi);
+ } else
+ XAALineArcD(pGC, xorg, yorg, &edge1, edgey1, edgeleft1,
+ &edge2, edgey2, edgeleft2);
+
+}
+
+
+static void
+XAALineJoin (
+ GCPtr pGC,
+ LineFacePtr pLeft,
+ LineFacePtr pRight )
+{
+ double mx = 0, my = 0;
+ double denom = 0;
+ PolyVertexRec vertices[4];
+ PolySlopeRec slopes[4];
+ int edgecount;
+ PolyEdgeRec left[4], right[4];
+ int nleft, nright;
+ int y, height;
+ int swapslopes;
+ int joinStyle = pGC->joinStyle;
+ int lw = pGC->lineWidth;
+
+ if (lw == 1) {
+ /* Lines going in the same direction have no join */
+ if ((pLeft->dx >= 0) == (pRight->dx <= 0))
+ return;
+ if (joinStyle != JoinRound) {
+ denom = - pLeft->dx * (double)pRight->dy + pRight->dx *
+ (double)pLeft->dy;
+ if (denom == 0.0)
+ return; /* no join to draw */
+ }
+ if (joinStyle != JoinMiter) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+ DRAW_POINT(infoRec->pScrn, pLeft->x, pLeft->y);
+ return;
+ }
+ } else {
+ if (joinStyle == JoinRound) {
+ XAALineArc(pGC, pLeft, pRight,(double)0.0, (double)0.0, TRUE);
+ return;
+ }
+ denom = - pLeft->dx * (double)pRight->dy + pRight->dx *
+ (double)pLeft->dy;
+ if (denom == 0.0)
+ return; /* no join to draw */
+ }
+
+ swapslopes = 0;
+ if (denom > 0) {
+ pLeft->xa = -pLeft->xa;
+ pLeft->ya = -pLeft->ya;
+ pLeft->dx = -pLeft->dx;
+ pLeft->dy = -pLeft->dy;
+ } else {
+ swapslopes = 1;
+ pRight->xa = -pRight->xa;
+ pRight->ya = -pRight->ya;
+ pRight->dx = -pRight->dx;
+ pRight->dy = -pRight->dy;
+ }
+
+ vertices[0].x = pRight->xa;
+ vertices[0].y = pRight->ya;
+ slopes[0].dx = -pRight->dy;
+ slopes[0].dy = pRight->dx;
+ slopes[0].k = 0;
+
+ vertices[1].x = 0;
+ vertices[1].y = 0;
+ slopes[1].dx = pLeft->dy;
+ slopes[1].dy = -pLeft->dx;
+ slopes[1].k = 0;
+
+ vertices[2].x = pLeft->xa;
+ vertices[2].y = pLeft->ya;
+
+ if (joinStyle == JoinMiter) {
+ my = (pLeft->dy * (pRight->xa * pRight->dy - pRight->ya * pRight->dx) -
+ pRight->dy * (pLeft->xa * pLeft->dy - pLeft->ya * pLeft->dx ))/
+ denom;
+ if (pLeft->dy != 0)
+ mx = pLeft->xa + (my - pLeft->ya) *
+ (double) pLeft->dx / (double) pLeft->dy;
+ else
+ mx = pRight->xa + (my - pRight->ya) *
+ (double) pRight->dx / (double) pRight->dy;
+
+ /* check miter limit */
+ if ((mx * mx + my * my) * 4 > SQSECANT * lw * lw)
+ joinStyle = JoinBevel;
+ }
+
+ if (joinStyle == JoinMiter) {
+ slopes[2].dx = pLeft->dx;
+ slopes[2].dy = pLeft->dy;
+ slopes[2].k = pLeft->k;
+ if (swapslopes) {
+ slopes[2].dx = -slopes[2].dx;
+ slopes[2].dy = -slopes[2].dy;
+ slopes[2].k = -slopes[2].k;
+ }
+ vertices[3].x = mx;
+ vertices[3].y = my;
+ slopes[3].dx = pRight->dx;
+ slopes[3].dy = pRight->dy;
+ slopes[3].k = pRight->k;
+ if (swapslopes) {
+ slopes[3].dx = -slopes[3].dx;
+ slopes[3].dy = -slopes[3].dy;
+ slopes[3].k = -slopes[3].k;
+ }
+ edgecount = 4;
+ } else {
+ double scale, dx, dy, adx, ady;
+
+ adx = dx = pRight->xa - pLeft->xa;
+ ady = dy = pRight->ya - pLeft->ya;
+ if (adx < 0)
+ adx = -adx;
+ if (ady < 0)
+ ady = -ady;
+ scale = ady;
+ if (adx > ady)
+ scale = adx;
+ slopes[2].dx = (dx * 65536) / scale;
+ slopes[2].dy = (dy * 65536) / scale;
+ slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy -
+ (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0;
+ edgecount = 3;
+ }
+
+ y = miPolyBuildPoly (vertices, slopes, edgecount, pLeft->x, pLeft->y,
+ left, right, &nleft, &nright, &height);
+ XAAFillPolyHelper(pGC, y, height, left, right, nleft, nright);
+}
+
+
+void
+XAAPolylinesWideSolid (
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr pPts )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int x1, y1, x2, y2;
+ Bool projectLeft, projectRight;
+ LineFaceRec leftFace, rightFace, prevRightFace, firstFace;
+ int first = TRUE;
+ Bool somethingDrawn = FALSE;
+ Bool selfJoin = FALSE;
+ int xorg = pDrawable->x;
+ int yorg = pDrawable->y;
+ Bool hardClip = FALSE;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if(RegionNumRects(pGC->pCompositeClip) != 1) {
+ miWideLine(pDrawable, pGC, mode, npt, pPts);
+ return;
+ }
+
+ x2 = pPts->x;
+ y2 = pPts->y;
+ if (npt > 1) {
+ if (mode == CoordModePrevious) {
+ int nptTmp;
+ register DDXPointPtr pPtsTmp;
+
+ x1 = x2;
+ y1 = y2;
+ nptTmp = npt;
+ pPtsTmp = pPts + 1;
+ while (--nptTmp) {
+ x1 += pPtsTmp->x;
+ y1 += pPtsTmp->y;
+ ++pPtsTmp;
+ }
+ if ((x2 == x1) && (y2 == y1))
+ selfJoin = TRUE;
+ } else if ((x2 == pPts[npt-1].x) && (y2 == pPts[npt-1].y))
+ selfJoin = TRUE;
+ }
+
+ projectLeft = ((pGC->capStyle == CapProjecting) && !selfJoin);
+ projectRight = FALSE;
+
+ (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ infoRec->ClipBox = &pGC->pCompositeClip->extents;
+
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) {
+ hardClip = TRUE;
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+ }
+
+ x2 += xorg;
+ y2 += yorg;
+ while (--npt) {
+ x1 = x2;
+ y1 = y2;
+ ++pPts;
+ x2 = pPts->x;
+ y2 = pPts->y;
+ if (mode == CoordModePrevious) {
+ x2 += x1;
+ y2 += y1;
+ } else {
+ x2 += xorg;
+ y2 += yorg;
+ }
+ if ((x1 != x2) || (y1 != y2)) {
+ somethingDrawn = TRUE;
+ if ((npt == 1) && (pGC->capStyle == CapProjecting) && !selfJoin)
+ projectRight = TRUE;
+ XAAWideSegment(pGC, x1, y1, x2, y2,
+ projectLeft, projectRight, &leftFace, &rightFace);
+ if (first) {
+ if (selfJoin)
+ firstFace = leftFace;
+ else if (pGC->capStyle == CapRound) {
+ if (pGC->lineWidth == 1) {
+ DRAW_POINT(infoRec->pScrn, x1, y1);
+ } else
+ XAALineArc(pGC,&leftFace, (LineFacePtr) NULL,
+ (double)0.0, (double)0.0,TRUE);
+ }
+ } else
+ XAALineJoin (pGC, &leftFace, &prevRightFace);
+
+ prevRightFace = rightFace;
+ first = FALSE;
+ projectLeft = FALSE;
+ }
+ if (npt == 1 && somethingDrawn) {
+ if (selfJoin)
+ XAALineJoin (pGC, &firstFace, &rightFace);
+ else if (pGC->capStyle == CapRound) {
+ if (pGC->lineWidth == 1) {
+ DRAW_POINT(infoRec->pScrn, x2, y2);
+ } else
+ XAALineArc (pGC, (LineFacePtr) NULL, &rightFace,
+ (double)0.0, (double)0.0,TRUE);
+ }
+ }
+ }
+ /* handle crock where all points are coincedent */
+ if (!somethingDrawn) {
+ projectLeft = (pGC->capStyle == CapProjecting);
+ XAAWideSegment (pGC, x2, y2, x2, y2, projectLeft, projectLeft,
+ &leftFace, &rightFace);
+ if (pGC->capStyle == CapRound) {
+ XAALineArc (pGC, &leftFace, (LineFacePtr) NULL,
+ (double)0.0, (double)0.0, TRUE);
+ rightFace.dx = -1; /* sleezy hack to make it work */
+ XAALineArc (pGC, (LineFacePtr) NULL, &rightFace,
+ (double)0.0, (double)0.0, TRUE);
+ }
+ }
+
+ infoRec->ClipBox = NULL;
+ if(hardClip)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaWrapper.c b/xorg-server/hw/xfree86/xaa/xaaWrapper.c index f709d0b35..09644c9ac 100644 --- a/xorg-server/hw/xfree86/xaa/xaaWrapper.c +++ b/xorg-server/hw/xfree86/xaa/xaaWrapper.c @@ -125,10 +125,10 @@ typedef struct _xaaWrapperGCPriv { #define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC)
-static int xaaWrapperScrPrivateKeyIndex;
-static DevPrivateKey xaaWrapperScrPrivateKey = &xaaWrapperScrPrivateKeyIndex;
-static int xaaWrapperGCPrivateKeyIndex;
-static DevPrivateKey xaaWrapperGCPrivateKey = &xaaWrapperGCPrivateKeyIndex;
+static DevPrivateKeyRec xaaWrapperScrPrivateKeyRec;
+#define xaaWrapperScrPrivateKey (&xaaWrapperScrPrivateKeyRec)
+static DevPrivateKeyRec xaaWrapperGCPrivateKeyRec;
+#define xaaWrapperGCPrivateKey (&xaaWrapperGCPrivateKeyRec)
static Bool
xaaWrapperCreateScreenResources(ScreenPtr pScreen)
@@ -268,7 +268,10 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f xaaWrapperScrPrivPtr pScrPriv;
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
- if (!dixRequestPrivate(xaaWrapperGCPrivateKey, sizeof(xaaWrapperGCPrivRec)))
+ if (!dixRegisterPrivateKey(&xaaWrapperGCPrivateKeyRec, PRIVATE_GC, sizeof(xaaWrapperGCPrivRec)))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&xaaWrapperScrPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
pScrPriv = (xaaWrapperScrPrivPtr) malloc(sizeof (xaaWrapperScrPrivRec));
diff --git a/xorg-server/hw/xfree86/xaa/xaawrap.h b/xorg-server/hw/xfree86/xaa/xaawrap.h index 86ba003d6..1b7595e95 100644 --- a/xorg-server/hw/xfree86/xaa/xaawrap.h +++ b/xorg-server/hw/xfree86/xaa/xaawrap.h @@ -1,79 +1,79 @@ - -#define XAA_SCREEN_PROLOGUE(pScreen, field)\ - ((pScreen)->field = \ - ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) - -#define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\ - ((pScreen)->field = wrapper) - - -#define XAA_GC_FUNC_PROLOGUE(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ - (pGC)->funcs = pGCPriv->wrapFuncs;\ - if(pGCPriv->flags)\ - (pGC)->ops = pGCPriv->wrapOps - -#define XAA_GC_FUNC_EPILOGUE(pGC)\ - pGCPriv->wrapFuncs = (pGC)->funcs;\ - (pGC)->funcs = &XAAGCFuncs;\ - if(pGCPriv->flags) {\ - pGCPriv->wrapOps = (pGC)->ops;\ - (pGC)->ops = (pGCPriv->flags & OPS_ARE_ACCEL) ? pGCPriv->XAAOps :\ - &XAAPixmapOps;\ - } - - -#define XAA_GC_OP_PROLOGUE(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ - GCFuncs *oldFuncs = pGC->funcs;\ - pGC->funcs = pGCPriv->wrapFuncs;\ - pGC->ops = pGCPriv->wrapOps - -#define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ - GCFuncs *oldFuncs = pGC->funcs;\ - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) return; \ - pGC->funcs = pGCPriv->wrapFuncs;\ - pGC->ops = pGCPriv->wrapOps - - -#define XAA_GC_OP_EPILOGUE(pGC)\ - pGCPriv->wrapOps = pGC->ops;\ - pGC->funcs = oldFuncs;\ - pGC->ops = pGCPriv->XAAOps - - -#define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\ - XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ - XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\ - GCFuncs *oldFuncs = pGC->funcs;\ - pGC->funcs = pGCPriv->wrapFuncs;\ - pGC->ops = pGCPriv->wrapOps; \ - SYNC_CHECK(pGC) - -#define XAA_PIXMAP_OP_EPILOGUE(pGC)\ - pGCPriv->wrapOps = pGC->ops;\ - pGC->funcs = oldFuncs;\ - pGC->ops = &XAAPixmapOps;\ - pixPriv->flags |= DIRTY - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#define XAA_RENDER_PROLOGUE(pScreen,field)\ - (GetPictureScreen(pScreen)->field = \ - ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) - -#define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\ - (GetPictureScreen(pScreen)->field = wrapper) - -/* This also works fine for drawables */ - -#define SYNC_CHECK(pGC) {\ - XAAInfoRecPtr infoRec =\ -((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec; \ - if(infoRec->NeedToSync) {\ - (*infoRec->Sync)(infoRec->pScrn);\ - infoRec->NeedToSync = FALSE;\ - }} +
+#define XAA_SCREEN_PROLOGUE(pScreen, field)\
+ ((pScreen)->field = \
+ ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field)
+
+#define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\
+ ((pScreen)->field = wrapper)
+
+
+#define XAA_GC_FUNC_PROLOGUE(pGC)\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
+ (pGC)->funcs = pGCPriv->wrapFuncs;\
+ if(pGCPriv->flags)\
+ (pGC)->ops = pGCPriv->wrapOps
+
+#define XAA_GC_FUNC_EPILOGUE(pGC)\
+ pGCPriv->wrapFuncs = (pGC)->funcs;\
+ (pGC)->funcs = &XAAGCFuncs;\
+ if(pGCPriv->flags) {\
+ pGCPriv->wrapOps = (pGC)->ops;\
+ (pGC)->ops = (pGCPriv->flags & OPS_ARE_ACCEL) ? pGCPriv->XAAOps :\
+ &XAAPixmapOps;\
+ }
+
+
+#define XAA_GC_OP_PROLOGUE(pGC)\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
+ GCFuncs *oldFuncs = pGC->funcs;\
+ pGC->funcs = pGCPriv->wrapFuncs;\
+ pGC->ops = pGCPriv->wrapOps
+
+#define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
+ GCFuncs *oldFuncs = pGC->funcs;\
+ if(!RegionNumRects(pGC->pCompositeClip)) return; \
+ pGC->funcs = pGCPriv->wrapFuncs;\
+ pGC->ops = pGCPriv->wrapOps
+
+
+#define XAA_GC_OP_EPILOGUE(pGC)\
+ pGCPriv->wrapOps = pGC->ops;\
+ pGC->funcs = oldFuncs;\
+ pGC->ops = pGCPriv->XAAOps
+
+
+#define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
+ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\
+ GCFuncs *oldFuncs = pGC->funcs;\
+ pGC->funcs = pGCPriv->wrapFuncs;\
+ pGC->ops = pGCPriv->wrapOps; \
+ SYNC_CHECK(pGC)
+
+#define XAA_PIXMAP_OP_EPILOGUE(pGC)\
+ pGCPriv->wrapOps = pGC->ops;\
+ pGC->funcs = oldFuncs;\
+ pGC->ops = &XAAPixmapOps;\
+ pixPriv->flags |= DIRTY
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#define XAA_RENDER_PROLOGUE(pScreen,field)\
+ (GetPictureScreen(pScreen)->field = \
+ ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field)
+
+#define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\
+ (GetPictureScreen(pScreen)->field = wrapper)
+
+/* This also works fine for drawables */
+
+#define SYNC_CHECK(pGC) {\
+ XAAInfoRecPtr infoRec =\
+((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec; \
+ if(infoRec->NeedToSync) {\
+ (*infoRec->Sync)(infoRec->pScrn);\
+ infoRec->NeedToSync = FALSE;\
+ }}
diff --git a/xorg-server/hw/xnest/Color.c b/xorg-server/hw/xnest/Color.c index 985b5ad95..bb215fc45 100644 --- a/xorg-server/hw/xnest/Color.c +++ b/xorg-server/hw/xnest/Color.c @@ -34,8 +34,8 @@ is" without express or implied warranty. #include "XNWindow.h"
#include "Args.h"
-static int cmapScrPrivateKeyIndex;
-static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex;
+static DevPrivateKeyRec cmapScrPrivateKeyRec;
+#define cmapScrPrivateKey (&cmapScrPrivateKeyRec)
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))
@@ -214,8 +214,7 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen) free(icws.cmapIDs);
if (!xnestSameInstalledColormapWindows(icws.windows, icws.numWindows)) {
- if (xnestOldInstalledColormapWindows)
- free(xnestOldInstalledColormapWindows);
+ free(xnestOldInstalledColormapWindows);
#ifdef _XSERVER64
{
@@ -264,14 +263,13 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen) #endif /* DUMB_WINDOW_MANAGERS */
}
else
- if (icws.windows) free(icws.windows);
+ free(icws.windows);
}
void
xnestSetScreenSaverColormapWindow(ScreenPtr pScreen)
{
- if (xnestOldInstalledColormapWindows)
- free(xnestOldInstalledColormapWindows);
+ free(xnestOldInstalledColormapWindows);
#ifdef _XSERVER64
{
@@ -469,6 +467,9 @@ xnestCreateDefaultColormap(ScreenPtr pScreen) unsigned short zero = 0, ones = 0xFFFF;
Pixel wp, bp;
+ if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
for (pVisual = pScreen->visuals;
pVisual->vid != pScreen->rootVisual;
pVisual++);
diff --git a/xorg-server/hw/xnest/Drawable.h b/xorg-server/hw/xnest/Drawable.h index d94916ecd..7f742cb1f 100644 --- a/xorg-server/hw/xnest/Drawable.h +++ b/xorg-server/hw/xnest/Drawable.h @@ -1,26 +1,26 @@ -/* - -Copyright 1993 by Davor Matic - -Permission to use, copy, modify, distribute, and sell this software -and its documentation for any purpose is hereby granted without fee, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation. Davor Matic makes no representations about -the suitability of this software for any purpose. It is provided "as -is" without express or implied warranty. - -*/ - -#ifndef XNESTDRAWABLE_H -#define XNESTDRAWABLE_H - -#include "XNWindow.h" -#include "XNPixmap.h" - -#define xnestDrawable(pDrawable) \ - ((pDrawable)->type == DRAWABLE_WINDOW ? \ - xnestWindow((WindowPtr)pDrawable) : \ - xnestPixmap((PixmapPtr)pDrawable)) - -#endif /* XNESTDRAWABLE_H */ +/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifndef XNESTDRAWABLE_H
+#define XNESTDRAWABLE_H
+
+#include "XNWindow.h"
+#include "XNPixmap.h"
+
+#define xnestDrawable(pDrawable) \
+ (WindowDrawable((pDrawable)->type) ? \
+ xnestWindow((WindowPtr)pDrawable) : \
+ xnestPixmap((PixmapPtr)pDrawable))
+
+#endif /* XNESTDRAWABLE_H */
diff --git a/xorg-server/hw/xnest/Events.c b/xorg-server/hw/xnest/Events.c index 277718ba3..88970bbe0 100644 --- a/xorg-server/hw/xnest/Events.c +++ b/xorg-server/hw/xnest/Events.c @@ -1,227 +1,227 @@ -/* - -Copyright 1993 by Davor Matic - -Permission to use, copy, modify, distribute, and sell this software -and its documentation for any purpose is hereby granted without fee, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation. Davor Matic makes no representations about -the suitability of this software for any purpose. It is provided "as -is" without express or implied warranty. - -*/ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "screenint.h" -#include "input.h" -#include "misc.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include "servermd.h" -#include "inputstr.h" - -#include "mi.h" - -#include "Xnest.h" - -#include "Args.h" -#include "Color.h" -#include "Display.h" -#include "Screen.h" -#include "XNWindow.h" -#include "Events.h" -#include "Keyboard.h" -#include "Pointer.h" -#include "mipointer.h" - -CARD32 lastEventTime = 0; - -extern EventList *xnestEvents; - -void -ProcessInputEvents(void) -{ - mieqProcessInputEvents(); -} - -int -TimeSinceLastInputEvent(void) -{ - if (lastEventTime == 0) - lastEventTime = GetTimeInMillis(); - return GetTimeInMillis() - lastEventTime; -} - -void -SetTimeSinceLastInputEvent(void) -{ - lastEventTime = GetTimeInMillis(); -} - -static Bool -xnestExposurePredicate(Display *display, XEvent *event, char *args) -{ - return (event->type == Expose || event->type == ProcessedExpose); -} - -static Bool -xnestNotExposurePredicate(Display *display, XEvent *event, char *args) -{ - return !xnestExposurePredicate(display, event, args); -} - -void -xnestCollectExposures(void) -{ - XEvent X; - WindowPtr pWin; - RegionRec Rgn; - BoxRec Box; - - while (XCheckIfEvent(xnestDisplay, &X, xnestExposurePredicate, NULL)) { - pWin = xnestWindowPtr(X.xexpose.window); - - if (pWin && X.xexpose.width && X.xexpose.height) { - Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + X.xexpose.x; - Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + X.xexpose.y; - Box.x2 = Box.x1 + X.xexpose.width; - Box.y2 = Box.y1 + X.xexpose.height; - - REGION_INIT(pWin->drawable.pScreen, &Rgn, &Box, 1); - - miSendExposures(pWin, &Rgn, Box.x2, Box.y2); - } - } -} - -void -xnestQueueKeyEvent(int type, unsigned int keycode) -{ - int i, n; - - GetEventList(&xnestEvents); - lastEventTime = GetTimeInMillis(); - n = GetKeyboardEvents(xnestEvents, xnestKeyboardDevice, type, keycode); - for (i = 0; i < n; i++) - mieqEnqueue(xnestKeyboardDevice, (InternalEvent*)(xnestEvents + i)->event); -} - -void -xnestCollectEvents(void) -{ - XEvent X; - int i, n, valuators[2]; - ScreenPtr pScreen; - GetEventList(&xnestEvents); - - while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) { - switch (X.type) { - case KeyPress: - xnestUpdateModifierState(X.xkey.state); - xnestQueueKeyEvent(KeyPress, X.xkey.keycode); - break; - - case KeyRelease: - xnestUpdateModifierState(X.xkey.state); - xnestQueueKeyEvent(KeyRelease, X.xkey.keycode); - break; - - case ButtonPress: - xnestUpdateModifierState(X.xkey.state); - lastEventTime = GetTimeInMillis(); - n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonPress, - X.xbutton.button, POINTER_RELATIVE, 0, 0, NULL); - for (i = 0; i < n; i++) - mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event); - break; - - case ButtonRelease: - xnestUpdateModifierState(X.xkey.state); - lastEventTime = GetTimeInMillis(); - n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonRelease, - X.xbutton.button, POINTER_RELATIVE, 0, 0, NULL); - for (i = 0; i < n; i++) - mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event); - break; - - case MotionNotify: - valuators[0] = X.xmotion.x; - valuators[1] = X.xmotion.y; - lastEventTime = GetTimeInMillis(); - n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify, - 0, POINTER_ABSOLUTE, 0, 2, valuators); - for (i = 0; i < n; i++) - mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event); - break; - - case FocusIn: - if (X.xfocus.detail != NotifyInferior) { - pScreen = xnestScreen(X.xfocus.window); - if (pScreen) - xnestDirectInstallColormaps(pScreen); - } - break; - - case FocusOut: - if (X.xfocus.detail != NotifyInferior) { - pScreen = xnestScreen(X.xfocus.window); - if (pScreen) - xnestDirectUninstallColormaps(pScreen); - } - break; - - case KeymapNotify: - break; - - case EnterNotify: - if (X.xcrossing.detail != NotifyInferior) { - pScreen = xnestScreen(X.xcrossing.window); - if (pScreen) { - NewCurrentScreen(inputInfo.pointer, pScreen, X.xcrossing.x, X.xcrossing.y); - valuators[0] = X.xcrossing.x; - valuators[1] = X.xcrossing.y; - lastEventTime = GetTimeInMillis(); - n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify, - 0, POINTER_ABSOLUTE, 0, 2, valuators); - for (i = 0; i < n; i++) - mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event); - xnestDirectInstallColormaps(pScreen); - } - } - break; - - case LeaveNotify: - if (X.xcrossing.detail != NotifyInferior) { - pScreen = xnestScreen(X.xcrossing.window); - if (pScreen) { - xnestDirectUninstallColormaps(pScreen); - } - } - break; - - case DestroyNotify: - if (xnestParentWindow != (Window) 0 && - X.xdestroywindow.window == xnestParentWindow) - exit (0); - break; - - case CirculateNotify: - case ConfigureNotify: - case GravityNotify: - case MapNotify: - case ReparentNotify: - case UnmapNotify: - break; - - default: - ErrorF("xnest warning: unhandled event\n"); - break; - } - } -} +/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "input.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "inputstr.h"
+
+#include "mi.h"
+
+#include "Xnest.h"
+
+#include "Args.h"
+#include "Color.h"
+#include "Display.h"
+#include "Screen.h"
+#include "XNWindow.h"
+#include "Events.h"
+#include "Keyboard.h"
+#include "Pointer.h"
+#include "mipointer.h"
+
+CARD32 lastEventTime = 0;
+
+extern EventList *xnestEvents;
+
+void
+ProcessInputEvents(void)
+{
+ mieqProcessInputEvents();
+}
+
+int
+TimeSinceLastInputEvent(void)
+{
+ if (lastEventTime == 0)
+ lastEventTime = GetTimeInMillis();
+ return GetTimeInMillis() - lastEventTime;
+}
+
+void
+SetTimeSinceLastInputEvent(void)
+{
+ lastEventTime = GetTimeInMillis();
+}
+
+static Bool
+xnestExposurePredicate(Display *display, XEvent *event, char *args)
+{
+ return event->type == Expose || event->type == ProcessedExpose;
+}
+
+static Bool
+xnestNotExposurePredicate(Display *display, XEvent *event, char *args)
+{
+ return !xnestExposurePredicate(display, event, args);
+}
+
+void
+xnestCollectExposures(void)
+{
+ XEvent X;
+ WindowPtr pWin;
+ RegionRec Rgn;
+ BoxRec Box;
+
+ while (XCheckIfEvent(xnestDisplay, &X, xnestExposurePredicate, NULL)) {
+ pWin = xnestWindowPtr(X.xexpose.window);
+
+ if (pWin && X.xexpose.width && X.xexpose.height) {
+ Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + X.xexpose.x;
+ Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + X.xexpose.y;
+ Box.x2 = Box.x1 + X.xexpose.width;
+ Box.y2 = Box.y1 + X.xexpose.height;
+
+ RegionInit(&Rgn, &Box, 1);
+
+ miSendExposures(pWin, &Rgn, Box.x2, Box.y2);
+ }
+ }
+}
+
+void
+xnestQueueKeyEvent(int type, unsigned int keycode)
+{
+ int i, n;
+
+ GetEventList(&xnestEvents);
+ lastEventTime = GetTimeInMillis();
+ n = GetKeyboardEvents(xnestEvents, xnestKeyboardDevice, type, keycode);
+ for (i = 0; i < n; i++)
+ mieqEnqueue(xnestKeyboardDevice, (InternalEvent*)(xnestEvents + i)->event);
+}
+
+void
+xnestCollectEvents(void)
+{
+ XEvent X;
+ int i, n, valuators[2];
+ ScreenPtr pScreen;
+ GetEventList(&xnestEvents);
+
+ while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
+ switch (X.type) {
+ case KeyPress:
+ xnestUpdateModifierState(X.xkey.state);
+ xnestQueueKeyEvent(KeyPress, X.xkey.keycode);
+ break;
+
+ case KeyRelease:
+ xnestUpdateModifierState(X.xkey.state);
+ xnestQueueKeyEvent(KeyRelease, X.xkey.keycode);
+ break;
+
+ case ButtonPress:
+ xnestUpdateModifierState(X.xkey.state);
+ lastEventTime = GetTimeInMillis();
+ n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonPress,
+ X.xbutton.button, POINTER_RELATIVE, 0, 0, NULL);
+ for (i = 0; i < n; i++)
+ mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ break;
+
+ case ButtonRelease:
+ xnestUpdateModifierState(X.xkey.state);
+ lastEventTime = GetTimeInMillis();
+ n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonRelease,
+ X.xbutton.button, POINTER_RELATIVE, 0, 0, NULL);
+ for (i = 0; i < n; i++)
+ mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ break;
+
+ case MotionNotify:
+ valuators[0] = X.xmotion.x;
+ valuators[1] = X.xmotion.y;
+ lastEventTime = GetTimeInMillis();
+ n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
+ 0, POINTER_ABSOLUTE, 0, 2, valuators);
+ for (i = 0; i < n; i++)
+ mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ break;
+
+ case FocusIn:
+ if (X.xfocus.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xfocus.window);
+ if (pScreen)
+ xnestDirectInstallColormaps(pScreen);
+ }
+ break;
+
+ case FocusOut:
+ if (X.xfocus.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xfocus.window);
+ if (pScreen)
+ xnestDirectUninstallColormaps(pScreen);
+ }
+ break;
+
+ case KeymapNotify:
+ break;
+
+ case EnterNotify:
+ if (X.xcrossing.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xcrossing.window);
+ if (pScreen) {
+ NewCurrentScreen(inputInfo.pointer, pScreen, X.xcrossing.x, X.xcrossing.y);
+ valuators[0] = X.xcrossing.x;
+ valuators[1] = X.xcrossing.y;
+ lastEventTime = GetTimeInMillis();
+ n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
+ 0, POINTER_ABSOLUTE, 0, 2, valuators);
+ for (i = 0; i < n; i++)
+ mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+ xnestDirectInstallColormaps(pScreen);
+ }
+ }
+ break;
+
+ case LeaveNotify:
+ if (X.xcrossing.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xcrossing.window);
+ if (pScreen) {
+ xnestDirectUninstallColormaps(pScreen);
+ }
+ }
+ break;
+
+ case DestroyNotify:
+ if (xnestParentWindow != (Window) 0 &&
+ X.xdestroywindow.window == xnestParentWindow)
+ exit (0);
+ break;
+
+ case CirculateNotify:
+ case ConfigureNotify:
+ case GravityNotify:
+ case MapNotify:
+ case ReparentNotify:
+ case UnmapNotify:
+ break;
+
+ default:
+ ErrorF("xnest warning: unhandled event\n");
+ break;
+ }
+ }
+}
diff --git a/xorg-server/hw/xnest/GC.c b/xorg-server/hw/xnest/GC.c index 9df015728..3c0074cc9 100644 --- a/xorg-server/hw/xnest/GC.c +++ b/xorg-server/hw/xnest/GC.c @@ -35,8 +35,7 @@ is" without express or implied warranty. #include "XNFont.h"
#include "Color.h"
-static int xnestGCPrivateKeyIndex;
-DevPrivateKey xnestGCPrivateKey = &xnestGCPrivateKeyIndex;
+DevPrivateKeyRec xnestGCPrivateKeyRec;
static GCFuncs xnestFuncs = {
xnestValidateGC,
@@ -210,10 +209,10 @@ xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects) break;
case CT_REGION:
- nRects = REGION_NUM_RECTS((RegionPtr)pValue);
+ nRects = RegionNumRects((RegionPtr)pValue);
size = nRects * sizeof(*pRects);
pRects = (XRectangle *) malloc(size);
- pBox = REGION_RECTS((RegionPtr)pValue);
+ pBox = RegionRects((RegionPtr)pValue);
for (i = nRects; i-- > 0; ) {
pRects[i].x = pBox[i].x1;
pRects[i].y = pBox[i].y1;
@@ -277,7 +276,7 @@ xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects) * other parts of server can only deal with CT_NONE,
* CT_PIXMAP and CT_REGION client clips.
*/
- pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nRects,
+ pGC->clientClip = (pointer) RegionFromRects(nRects,
(xRectangle *)pValue, type);
free(pValue);
pValue = pGC->clientClip;
@@ -313,7 +312,7 @@ xnestDestroyClipHelper(GCPtr pGC) break;
case CT_REGION:
- REGION_DESTROY(pGC->pScreen, pGC->clientClip);
+ RegionDestroy(pGC->clientClip);
break;
}
}
@@ -331,8 +330,8 @@ xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc) break;
case CT_REGION:
- pRgn = REGION_CREATE(pGCDst->pScreen, NULL, 1);
- REGION_COPY(pGCDst->pScreen, pRgn, pGCSrc->clientClip);
+ pRgn = RegionCreate(NULL, 1);
+ RegionCopy(pRgn, pGCSrc->clientClip);
xnestChangeClip(pGCDst, CT_REGION, pRgn, 0);
break;
}
diff --git a/xorg-server/hw/xnest/GCOps.c b/xorg-server/hw/xnest/GCOps.c index ad9668ec1..d19ec6710 100644 --- a/xorg-server/hw/xnest/GCOps.c +++ b/xorg-server/hw/xnest/GCOps.c @@ -1,327 +1,327 @@ -/* - -Copyright 1993 by Davor Matic - -Permission to use, copy, modify, distribute, and sell this software -and its documentation for any purpose is hereby granted without fee, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation. Davor Matic makes no representations about -the suitability of this software for any purpose. It is provided "as -is" without express or implied warranty. - -*/ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "regionstr.h" -#include <X11/fonts/fontstruct.h> -#include "gcstruct.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "region.h" -#include "servermd.h" - -#include "Xnest.h" - -#include "Display.h" -#include "Screen.h" -#include "XNGC.h" -#include "XNFont.h" -#include "GCOps.h" -#include "Drawable.h" -#include "Visual.h" - -void -xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, xPoint *pPoints, - int *pWidths, int fSorted) -{ - ErrorF("xnest warning: function xnestFillSpans not implemented\n"); -} - -void -xnestSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pSrc, - xPoint *pPoints, int *pWidths, int nSpans, int fSorted) -{ - ErrorF("xnest warning: function xnestSetSpans not implemented\n"); -} - -void -xnestGetSpans(DrawablePtr pDrawable, int maxWidth, DDXPointPtr pPoints, - int *pWidths, int nSpans, char *pBuffer) -{ - ErrorF("xnest warning: function xnestGetSpans not implemented\n"); -} - -void -xnestQueryBestSize(int class, unsigned short *pWidth, unsigned short *pHeight, - ScreenPtr pScreen) -{ - unsigned int width, height; - - width = *pWidth; - height = *pHeight; - - XQueryBestSize(xnestDisplay, class, - xnestDefaultWindows[pScreen->myNum], - width, height, &width, &height); - - *pWidth = width; - *pHeight = height; -} - -void -xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, - int w, int h, int leftPad, int format, char *pImage) -{ - XImage *ximage; - - ximage = XCreateImage(xnestDisplay, xnestDefaultVisual(pDrawable->pScreen), - depth, format, leftPad, (char *)pImage, - w, h, BitmapPad(xnestDisplay), - (format == ZPixmap) ? - PixmapBytePad(w, depth) : BitmapBytePad(w+leftPad)); - - if (ximage) { - XPutImage(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - ximage, 0, 0, x, y, w, h); - XFree(ximage); - } -} - -void -xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h, - unsigned int format, unsigned long planeMask, - char *pImage) -{ - XImage *ximage; - int length; - - ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable), - x, y, w, h, planeMask, format); - - if (ximage) { - length = ximage->bytes_per_line * ximage->height; - - memmove(pImage, ximage->data, length); - - XDestroyImage(ximage); - } -} - -static Bool -xnestBitBlitPredicate(Display *display, XEvent *event, char *args) -{ - return (event->type == GraphicsExpose || event->type == NoExpose); -} - -static RegionPtr -xnestBitBlitHelper(GCPtr pGC) -{ - if (!pGC->graphicsExposures) - return NullRegion; - else { - XEvent event; - RegionPtr pReg, pTmpReg; - BoxRec Box; - Bool pending, overlap; - - pReg = REGION_CREATE(pGC->pScreen, NULL, 1); - pTmpReg = REGION_CREATE(pGC->pScreen, NULL, 1); - if(!pReg || !pTmpReg) return NullRegion; - - pending = True; - while (pending) { - XIfEvent(xnestDisplay, &event, xnestBitBlitPredicate, NULL); - - switch (event.type) { - case NoExpose: - pending = False; - break; - - case GraphicsExpose: - Box.x1 = event.xgraphicsexpose.x; - Box.y1 = event.xgraphicsexpose.y; - Box.x2 = event.xgraphicsexpose.x + event.xgraphicsexpose.width; - Box.y2 = event.xgraphicsexpose.y + event.xgraphicsexpose.height; - REGION_RESET(pGC->pScreen, pTmpReg, &Box); - REGION_APPEND(pGC->pScreen, pReg, pTmpReg); - pending = event.xgraphicsexpose.count; - break; - } - } - - REGION_DESTROY(pGC->pScreen, pTmpReg); - REGION_VALIDATE(pGC->pScreen, pReg, &overlap); - return(pReg); - } -} - -RegionPtr -xnestCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, - GCPtr pGC, int srcx, int srcy, int width, int height, - int dstx, int dsty) -{ - XCopyArea(xnestDisplay, - xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable), - xnestGC(pGC), srcx, srcy, width, height, dstx, dsty); - - return xnestBitBlitHelper(pGC); -} - -RegionPtr -xnestCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, - GCPtr pGC, int srcx, int srcy, int width, int height, - int dstx, int dsty, unsigned long plane) -{ - XCopyPlane(xnestDisplay, - xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable), - xnestGC(pGC), srcx, srcy, width, height, dstx, dsty, plane); - - return xnestBitBlitHelper(pGC); -} - -void -xnestPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints, - DDXPointPtr pPoints) -{ - XDrawPoints(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XPoint *)pPoints, nPoints, mode); -} - -void -xnestPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints, - DDXPointPtr pPoints) -{ - XDrawLines(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XPoint *)pPoints, nPoints, mode); -} - -void -xnestPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSegments, - xSegment *pSegments) -{ - XDrawSegments(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XSegment *)pSegments, nSegments); -} - -void -xnestPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nRectangles, - xRectangle *pRectangles) -{ - XDrawRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XRectangle *)pRectangles, nRectangles); -} - -void -xnestPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs) -{ - XDrawArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XArc *)pArcs, nArcs); -} - -void -xnestFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, int mode, - int nPoints, DDXPointPtr pPoints) -{ - XFillPolygon(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XPoint *)pPoints, nPoints, shape, mode); -} - -void -xnestPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nRectangles, - xRectangle *pRectangles) -{ - XFillRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XRectangle *)pRectangles, nRectangles); -} - -void -xnestPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs) -{ - XFillArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XArc *)pArcs, nArcs); -} - -int -xnestPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - char *string) -{ - int width; - - XDrawString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - x, y, string, count); - - width = XTextWidth(xnestFontStruct(pGC->font), string, count); - - return width + x; -} - -int -xnestPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - unsigned short *string) -{ - int width; - - XDrawString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - x, y, (XChar2b *)string, count); - - width = XTextWidth16(xnestFontStruct(pGC->font), (XChar2b *)string, count); - - return width + x; -} - -void -xnestImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - char *string) -{ - XDrawImageString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - x, y, string, count); -} - -void -xnestImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - unsigned short *string) -{ - XDrawImageString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - x, y, (XChar2b *)string, count); -} - -void -xnestImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, - unsigned int nGlyphs, CharInfoPtr *pCharInfo, - pointer pGlyphBase) -{ - ErrorF("xnest warning: function xnestImageGlyphBlt not implemented\n"); -} - -void -xnestPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, - unsigned int nGlyphs, CharInfoPtr *pCharInfo, - pointer pGlyphBase) -{ - ErrorF("xnest warning: function xnestPolyGlyphBlt not implemented\n"); -} - -void -xnestPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDst, - int width, int height, int x, int y) -{ - /* only works for solid bitmaps */ - if (pGC->fillStyle == FillSolid) - { - XSetStipple (xnestDisplay, xnestGC(pGC), xnestPixmap(pBitmap)); - XSetTSOrigin (xnestDisplay, xnestGC(pGC), x, y); - XSetFillStyle (xnestDisplay, xnestGC(pGC), FillStippled); - XFillRectangle (xnestDisplay, xnestDrawable(pDst), - xnestGC(pGC), x, y, width, height); - XSetFillStyle (xnestDisplay, xnestGC(pGC), FillSolid); - } - else - ErrorF("xnest warning: function xnestPushPixels not implemented\n"); -} +/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "regionstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "region.h"
+#include "servermd.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "XNGC.h"
+#include "XNFont.h"
+#include "GCOps.h"
+#include "Drawable.h"
+#include "Visual.h"
+
+void
+xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, xPoint *pPoints,
+ int *pWidths, int fSorted)
+{
+ ErrorF("xnest warning: function xnestFillSpans not implemented\n");
+}
+
+void
+xnestSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pSrc,
+ xPoint *pPoints, int *pWidths, int nSpans, int fSorted)
+{
+ ErrorF("xnest warning: function xnestSetSpans not implemented\n");
+}
+
+void
+xnestGetSpans(DrawablePtr pDrawable, int maxWidth, DDXPointPtr pPoints,
+ int *pWidths, int nSpans, char *pBuffer)
+{
+ ErrorF("xnest warning: function xnestGetSpans not implemented\n");
+}
+
+void
+xnestQueryBestSize(int class, unsigned short *pWidth, unsigned short *pHeight,
+ ScreenPtr pScreen)
+{
+ unsigned int width, height;
+
+ width = *pWidth;
+ height = *pHeight;
+
+ XQueryBestSize(xnestDisplay, class,
+ xnestDefaultWindows[pScreen->myNum],
+ width, height, &width, &height);
+
+ *pWidth = width;
+ *pHeight = height;
+}
+
+void
+xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, char *pImage)
+{
+ XImage *ximage;
+
+ ximage = XCreateImage(xnestDisplay, xnestDefaultVisual(pDrawable->pScreen),
+ depth, format, leftPad, (char *)pImage,
+ w, h, BitmapPad(xnestDisplay),
+ (format == ZPixmap) ?
+ PixmapBytePad(w, depth) : BitmapBytePad(w+leftPad));
+
+ if (ximage) {
+ XPutImage(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ ximage, 0, 0, x, y, w, h);
+ XFree(ximage);
+ }
+}
+
+void
+xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask,
+ char *pImage)
+{
+ XImage *ximage;
+ int length;
+
+ ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable),
+ x, y, w, h, planeMask, format);
+
+ if (ximage) {
+ length = ximage->bytes_per_line * ximage->height;
+
+ memmove(pImage, ximage->data, length);
+
+ XDestroyImage(ximage);
+ }
+}
+
+static Bool
+xnestBitBlitPredicate(Display *display, XEvent *event, char *args)
+{
+ return event->type == GraphicsExpose || event->type == NoExpose;
+}
+
+static RegionPtr
+xnestBitBlitHelper(GCPtr pGC)
+{
+ if (!pGC->graphicsExposures)
+ return NullRegion;
+ else {
+ XEvent event;
+ RegionPtr pReg, pTmpReg;
+ BoxRec Box;
+ Bool pending, overlap;
+
+ pReg = RegionCreate(NULL, 1);
+ pTmpReg = RegionCreate(NULL, 1);
+ if(!pReg || !pTmpReg) return NullRegion;
+
+ pending = True;
+ while (pending) {
+ XIfEvent(xnestDisplay, &event, xnestBitBlitPredicate, NULL);
+
+ switch (event.type) {
+ case NoExpose:
+ pending = False;
+ break;
+
+ case GraphicsExpose:
+ Box.x1 = event.xgraphicsexpose.x;
+ Box.y1 = event.xgraphicsexpose.y;
+ Box.x2 = event.xgraphicsexpose.x + event.xgraphicsexpose.width;
+ Box.y2 = event.xgraphicsexpose.y + event.xgraphicsexpose.height;
+ RegionReset(pTmpReg, &Box);
+ RegionAppend(pReg, pTmpReg);
+ pending = event.xgraphicsexpose.count;
+ break;
+ }
+ }
+
+ RegionDestroy(pTmpReg);
+ RegionValidate(pReg, &overlap);
+ return pReg;
+ }
+}
+
+RegionPtr
+xnestCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty)
+{
+ XCopyArea(xnestDisplay,
+ xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable),
+ xnestGC(pGC), srcx, srcy, width, height, dstx, dsty);
+
+ return xnestBitBlitHelper(pGC);
+}
+
+RegionPtr
+xnestCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long plane)
+{
+ XCopyPlane(xnestDisplay,
+ xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable),
+ xnestGC(pGC), srcx, srcy, width, height, dstx, dsty, plane);
+
+ return xnestBitBlitHelper(pGC);
+}
+
+void
+xnestPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints,
+ DDXPointPtr pPoints)
+{
+ XDrawPoints(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XPoint *)pPoints, nPoints, mode);
+}
+
+void
+xnestPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints,
+ DDXPointPtr pPoints)
+{
+ XDrawLines(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XPoint *)pPoints, nPoints, mode);
+}
+
+void
+xnestPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSegments,
+ xSegment *pSegments)
+{
+ XDrawSegments(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XSegment *)pSegments, nSegments);
+}
+
+void
+xnestPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nRectangles,
+ xRectangle *pRectangles)
+{
+ XDrawRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XRectangle *)pRectangles, nRectangles);
+}
+
+void
+xnestPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs)
+{
+ XDrawArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XArc *)pArcs, nArcs);
+}
+
+void
+xnestFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, int mode,
+ int nPoints, DDXPointPtr pPoints)
+{
+ XFillPolygon(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XPoint *)pPoints, nPoints, shape, mode);
+}
+
+void
+xnestPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nRectangles,
+ xRectangle *pRectangles)
+{
+ XFillRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XRectangle *)pRectangles, nRectangles);
+}
+
+void
+xnestPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs)
+{
+ XFillArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XArc *)pArcs, nArcs);
+}
+
+int
+xnestPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ char *string)
+{
+ int width;
+
+ XDrawString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ x, y, string, count);
+
+ width = XTextWidth(xnestFontStruct(pGC->font), string, count);
+
+ return width + x;
+}
+
+int
+xnestPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ unsigned short *string)
+{
+ int width;
+
+ XDrawString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ x, y, (XChar2b *)string, count);
+
+ width = XTextWidth16(xnestFontStruct(pGC->font), (XChar2b *)string, count);
+
+ return width + x;
+}
+
+void
+xnestImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ char *string)
+{
+ XDrawImageString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ x, y, string, count);
+}
+
+void
+xnestImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ unsigned short *string)
+{
+ XDrawImageString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ x, y, (XChar2b *)string, count);
+}
+
+void
+xnestImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nGlyphs, CharInfoPtr *pCharInfo,
+ pointer pGlyphBase)
+{
+ ErrorF("xnest warning: function xnestImageGlyphBlt not implemented\n");
+}
+
+void
+xnestPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nGlyphs, CharInfoPtr *pCharInfo,
+ pointer pGlyphBase)
+{
+ ErrorF("xnest warning: function xnestPolyGlyphBlt not implemented\n");
+}
+
+void
+xnestPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDst,
+ int width, int height, int x, int y)
+{
+ /* only works for solid bitmaps */
+ if (pGC->fillStyle == FillSolid)
+ {
+ XSetStipple (xnestDisplay, xnestGC(pGC), xnestPixmap(pBitmap));
+ XSetTSOrigin (xnestDisplay, xnestGC(pGC), x, y);
+ XSetFillStyle (xnestDisplay, xnestGC(pGC), FillStippled);
+ XFillRectangle (xnestDisplay, xnestDrawable(pDst),
+ xnestGC(pGC), x, y, width, height);
+ XSetFillStyle (xnestDisplay, xnestGC(pGC), FillSolid);
+ }
+ else
+ ErrorF("xnest warning: function xnestPushPixels not implemented\n");
+}
diff --git a/xorg-server/hw/xnest/Pixmap.c b/xorg-server/hw/xnest/Pixmap.c index cd2245b46..da81a1d06 100644 --- a/xorg-server/hw/xnest/Pixmap.c +++ b/xorg-server/hw/xnest/Pixmap.c @@ -33,8 +33,7 @@ is" without express or implied warranty. #include "Screen.h"
#include "XNPixmap.h"
-static int xnestPixmapPrivateKeyIndex;
-DevPrivateKey xnestPixmapPrivateKey = &xnestPixmapPrivateKeyIndex;
+DevPrivateKeyRec xnestPixmapPrivateKeyRec;
PixmapPtr
xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
@@ -42,7 +41,7 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, {
PixmapPtr pPixmap;
- pPixmap = AllocatePixmap(pScreen, sizeof(xnestPrivPixmap));
+ pPixmap = AllocatePixmap(pScreen, 0);
if (!pPixmap)
return NullPixmap;
pPixmap->drawable.type = DRAWABLE_PIXMAP;
@@ -59,8 +58,6 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, pPixmap->refcnt = 1;
pPixmap->devKind = PixmapBytePad(width, depth);
pPixmap->usage_hint = usage_hint;
- dixSetPrivate(&pPixmap->devPrivates, xnestPixmapPrivateKey,
- (char *)pPixmap + pScreen->totalPixmapSize);
if (width && height)
xnestPixmapPriv(pPixmap)->pixmap =
XCreatePixmap(xnestDisplay,
@@ -78,8 +75,7 @@ xnestDestroyPixmap(PixmapPtr pPixmap) if(--pPixmap->refcnt)
return TRUE;
XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
- dixFreePrivates(pPixmap->devPrivates);
- free(pPixmap);
+ FreePixmap(pPixmap);
return TRUE;
}
@@ -97,8 +93,8 @@ xnestPixmapToRegion(PixmapPtr pPixmap) pPixmap->drawable.width, pPixmap->drawable.height,
1, XYPixmap);
- pReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
- pTmpReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
+ pReg = RegionCreate(NULL, 1);
+ pTmpReg = RegionCreate(NULL, 1);
if(!pReg || !pTmpReg) {
XDestroyImage(ximage);
return NullRegion;
@@ -118,8 +114,8 @@ xnestPixmapToRegion(PixmapPtr pPixmap) else if (currentPixel == 0L) {
/* right edge */
Box.x2 = x;
- REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
- REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
+ RegionReset(pTmpReg, &Box);
+ RegionAppend(pReg, pTmpReg);
}
previousPixel = currentPixel;
}
@@ -127,15 +123,15 @@ xnestPixmapToRegion(PixmapPtr pPixmap) if (previousPixel != 0L) {
/* right edge because of the end of pixmap */
Box.x2 = pPixmap->drawable.width;
- REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
- REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
+ RegionReset(pTmpReg, &Box);
+ RegionAppend(pReg, pTmpReg);
}
}
- REGION_DESTROY(pPixmap->drawable.pScreen, pTmpReg);
+ RegionDestroy(pTmpReg);
XDestroyImage(ximage);
- REGION_VALIDATE(pPixmap->drawable.pScreen, pReg, &overlap);
+ RegionValidate(pReg, &overlap);
- return(pReg);
+ return pReg;
}
diff --git a/xorg-server/hw/xnest/Screen.c b/xorg-server/hw/xnest/Screen.c index d25666508..cf225d0ab 100644 --- a/xorg-server/hw/xnest/Screen.c +++ b/xorg-server/hw/xnest/Screen.c @@ -45,8 +45,7 @@ is" without express or implied warranty. Window xnestDefaultWindows[MAXSCREENS];
Window xnestScreenSaverWindows[MAXSCREENS];
-static int xnestCursorScreenKeyIndex;
-DevPrivateKey xnestCursorScreenKey = &xnestCursorScreenKeyIndex;
+DevPrivateKeyRec xnestCursorScreenKeyRec;
ScreenPtr
xnestScreen(Window window)
@@ -146,10 +145,14 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) int rootDepth;
miPointerScreenPtr PointPriv;
- if (!dixRequestPrivate(xnestWindowPrivateKey, sizeof(xnestPrivWin)))
- return False;
- if (!dixRequestPrivate(xnestGCPrivateKey, sizeof(xnestPrivGC)))
- return False;
+ if (!dixRegisterPrivateKey(&xnestWindowPrivateKeyRec, PRIVATE_WINDOW, sizeof(xnestPrivWin)))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&xnestGCPrivateKeyRec, PRIVATE_GC, sizeof(xnestPrivGC)))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&xnestPixmapPrivateKeyRec, PRIVATE_PIXMAP, sizeof (xnestPrivPixmap)))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&xnestCursorScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
visuals = (VisualPtr)malloc(xnestNumVisuals * sizeof(VisualRec));
numVisuals = 0;
diff --git a/xorg-server/hw/xnest/Window.c b/xorg-server/hw/xnest/Window.c index 48c870fac..7ef3d8b96 100644 --- a/xorg-server/hw/xnest/Window.c +++ b/xorg-server/hw/xnest/Window.c @@ -1,526 +1,519 @@ -/* - -Copyright 1993 by Davor Matic - -Permission to use, copy, modify, distribute, and sell this software -and its documentation for any purpose is hereby granted without fee, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation. Davor Matic makes no representations about -the suitability of this software for any purpose. It is provided "as -is" without express or implied warranty. - -*/ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "gcstruct.h" -#include "window.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "colormapst.h" -#include "scrnintstr.h" -#include "region.h" - -#include "mi.h" - -#include "Xnest.h" - -#include "Display.h" -#include "Screen.h" -#include "XNGC.h" -#include "Drawable.h" -#include "Color.h" -#include "Visual.h" -#include "Events.h" -#include "Args.h" - -static int xnestWindowPrivateKeyIndex; -DevPrivateKey xnestWindowPrivateKey = &xnestWindowPrivateKeyIndex; - -static int -xnestFindWindowMatch(WindowPtr pWin, pointer ptr) -{ - xnestWindowMatch *wm = (xnestWindowMatch *)ptr; - if (wm->window == xnestWindow(pWin)) { - wm->pWin = pWin; - return WT_STOPWALKING; - } - else - return WT_WALKCHILDREN; -} - -WindowPtr -xnestWindowPtr(Window window) -{ - xnestWindowMatch wm; - int i; - - wm.pWin = NullWindow; - wm.window = window; - - for (i = 0; i < xnestNumScreens; i++) { - WalkTree(screenInfo.screens[i], xnestFindWindowMatch, (pointer) &wm); - if (wm.pWin) break; - } - - return wm.pWin; -} - -Bool -xnestCreateWindow(WindowPtr pWin) -{ - unsigned long mask; - XSetWindowAttributes attributes; - Visual *visual; - ColormapPtr pCmap; - - if (pWin->drawable.class == InputOnly) { - mask = 0L; - visual = CopyFromParent; - } - else { - mask = CWEventMask | CWBackingStore; - attributes.event_mask = ExposureMask; - attributes.backing_store = NotUseful; - - if (pWin->parent) { - if (pWin->optional && pWin->optional->visual != wVisual(pWin->parent)) { - visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin)); - mask |= CWColormap; - if (pWin->optional->colormap) { - dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin), - RT_COLORMAP, serverClient, DixUseAccess); - attributes.colormap = xnestColormap(pCmap); - } - else - attributes.colormap = xnestDefaultVisualColormap(visual); - } - else - visual = CopyFromParent; - } - else { /* root windows have their own colormaps at creation time */ - visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin)); - dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin), - RT_COLORMAP, serverClient, DixUseAccess); - mask |= CWColormap; - attributes.colormap = xnestColormap(pCmap); - } - } - - xnestWindowPriv(pWin)->window = XCreateWindow(xnestDisplay, - xnestWindowParent(pWin), - pWin->origin.x - - wBorderWidth(pWin), - pWin->origin.y - - wBorderWidth(pWin), - pWin->drawable.width, - pWin->drawable.height, - pWin->borderWidth, - pWin->drawable.depth, - pWin->drawable.class, - visual, - mask, &attributes); - xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin); - xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin); - xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin); - xnestWindowPriv(pWin)->width = pWin->drawable.width; - xnestWindowPriv(pWin)->height = pWin->drawable.height; - xnestWindowPriv(pWin)->border_width = pWin->borderWidth; - xnestWindowPriv(pWin)->sibling_above = None; - if (pWin->nextSib) - xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin); - xnestWindowPriv(pWin)->bounding_shape = - REGION_CREATE(pWin->drawable.pScreen, NULL, 1); - xnestWindowPriv(pWin)->clip_shape = - REGION_CREATE(pWin->drawable.pScreen, NULL, 1); - - if (!pWin->parent) /* only the root window will have the right colormap */ - xnestSetInstalledColormapWindows(pWin->drawable.pScreen); - - return True; -} - -Bool -xnestDestroyWindow(WindowPtr pWin) -{ - if (pWin->nextSib) - xnestWindowPriv(pWin->nextSib)->sibling_above = - xnestWindowPriv(pWin)->sibling_above; - REGION_DESTROY(pWin->drawable.pScreen, - xnestWindowPriv(pWin)->bounding_shape); - REGION_DESTROY(pWin->drawable.pScreen, - xnestWindowPriv(pWin)->clip_shape); - XDestroyWindow(xnestDisplay, xnestWindow(pWin)); - xnestWindowPriv(pWin)->window = None; - - if (pWin->optional && pWin->optional->colormap && pWin->parent) - xnestSetInstalledColormapWindows(pWin->drawable.pScreen); - - return True; -} - -Bool -xnestPositionWindow(WindowPtr pWin, int x, int y) -{ - xnestConfigureWindow(pWin, - CWParent | - CWX | CWY | - CWWidth | CWHeight | - CWBorderWidth); - - return True; -} - -void -xnestConfigureWindow(WindowPtr pWin, unsigned int mask) -{ - unsigned int valuemask; - XWindowChanges values; - - if (mask & CWParent && - xnestWindowPriv(pWin)->parent != xnestWindowParent(pWin)) { - XReparentWindow(xnestDisplay, xnestWindow(pWin), - xnestWindowParent(pWin), - pWin->origin.x - wBorderWidth(pWin), - pWin->origin.y - wBorderWidth(pWin)); - xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin); - xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin); - xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin); - xnestWindowPriv(pWin)->sibling_above = None; - if (pWin->nextSib) - xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin); - } - - valuemask = 0; - - if (mask & CWX && - xnestWindowPriv(pWin)->x != pWin->origin.x - wBorderWidth(pWin)) { - valuemask |= CWX; - values.x = - xnestWindowPriv(pWin)->x = - pWin->origin.x - wBorderWidth(pWin); - } - - if (mask & CWY && - xnestWindowPriv(pWin)->y != pWin->origin.y - wBorderWidth(pWin)) { - valuemask |= CWY; - values.y = - xnestWindowPriv(pWin)->y = - pWin->origin.y - wBorderWidth(pWin); - } - - if (mask & CWWidth && - xnestWindowPriv(pWin)->width != pWin->drawable.width) { - valuemask |= CWWidth; - values.width = - xnestWindowPriv(pWin)->width = - pWin->drawable.width; - } - - if (mask & CWHeight && - xnestWindowPriv(pWin)->height != pWin->drawable.height) { - valuemask |= CWHeight; - values.height = - xnestWindowPriv(pWin)->height = - pWin->drawable.height; - } - - if (mask & CWBorderWidth && - xnestWindowPriv(pWin)->border_width != pWin->borderWidth) { - valuemask |= CWBorderWidth; - values.border_width = - xnestWindowPriv(pWin)->border_width = - pWin->borderWidth; - } - - if (valuemask) - XConfigureWindow(xnestDisplay, xnestWindow(pWin), valuemask, &values); - - if (mask & CWStackingOrder && - xnestWindowPriv(pWin)->sibling_above != xnestWindowSiblingAbove(pWin)) { - WindowPtr pSib; - - /* find the top sibling */ - for (pSib = pWin; pSib->prevSib != NullWindow; pSib = pSib->prevSib); - - /* the top sibling */ - valuemask = CWStackMode; - values.stack_mode = Above; - XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, &values); - xnestWindowPriv(pSib)->sibling_above = None; - - /* the rest of siblings */ - for (pSib = pSib->nextSib; pSib != NullWindow; pSib = pSib->nextSib) { - valuemask = CWSibling | CWStackMode; - values.sibling = xnestWindowSiblingAbove(pSib); - values.stack_mode = Below; - XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, &values); - xnestWindowPriv(pSib)->sibling_above = xnestWindowSiblingAbove(pSib); - } - } -} - -Bool -xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask) -{ - XSetWindowAttributes attributes; - - if (mask & CWBackPixmap) - switch (pWin->backgroundState) { - case None: - attributes.background_pixmap = None; - break; - - case ParentRelative: - attributes.background_pixmap = ParentRelative; - break; - - case BackgroundPixmap: - attributes.background_pixmap = xnestPixmap(pWin->background.pixmap); - break; - - case BackgroundPixel: - mask &= ~CWBackPixmap; - break; - } - - if (mask & CWBackPixel) { - if (pWin->backgroundState == BackgroundPixel) - attributes.background_pixel = xnestPixel(pWin->background.pixel); - else - mask &= ~CWBackPixel; - } - - if (mask & CWBorderPixmap) { - if (pWin->borderIsPixel) - mask &= ~CWBorderPixmap; - else - attributes.border_pixmap = xnestPixmap(pWin->border.pixmap); - } - - if (mask & CWBorderPixel) { - if (pWin->borderIsPixel) - attributes.border_pixel = xnestPixel(pWin->border.pixel); - else - mask &= ~CWBorderPixel; - } - - if (mask & CWBitGravity) - attributes.bit_gravity = pWin->bitGravity; - - if (mask & CWWinGravity) /* dix does this for us */ - mask &= ~CWWinGravity; - - if (mask & CWBackingStore) /* this is really not useful */ - mask &= ~CWBackingStore; - - if (mask & CWBackingPlanes) /* this is really not useful */ - mask &= ~CWBackingPlanes; - - if (mask & CWBackingPixel) /* this is really not useful */ - mask &= ~CWBackingPixel; - - if (mask & CWOverrideRedirect) - attributes.override_redirect = pWin->overrideRedirect; - - if (mask & CWSaveUnder) /* this is really not useful */ - mask &= ~CWSaveUnder; - - if (mask & CWEventMask) /* events are handled elsewhere */ - mask &= ~CWEventMask; - - if (mask & CWDontPropagate) /* events are handled elsewhere */ - mask &= ~CWDontPropagate; - - if (mask & CWColormap) { - ColormapPtr pCmap; - - dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin), RT_COLORMAP, - serverClient, DixUseAccess); - - attributes.colormap = xnestColormap(pCmap); - - xnestSetInstalledColormapWindows(pWin->drawable.pScreen); - } - - if (mask & CWCursor) /* this is handeled in cursor code */ - mask &= ~CWCursor; - - if (mask) - XChangeWindowAttributes(xnestDisplay, xnestWindow(pWin), - mask, &attributes); - - return True; -} - -Bool -xnestRealizeWindow(WindowPtr pWin) -{ - xnestConfigureWindow(pWin, CWStackingOrder); - xnestShapeWindow(pWin); - XMapWindow(xnestDisplay, xnestWindow(pWin)); - - return True; -} - -Bool -xnestUnrealizeWindow(WindowPtr pWin) -{ - XUnmapWindow(xnestDisplay, xnestWindow(pWin)); - - return True; -} - -void -xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion) -{ -} - -void -xnestClipNotify(WindowPtr pWin, int dx, int dy) -{ - xnestConfigureWindow(pWin, CWStackingOrder); - xnestShapeWindow(pWin); -} - -static Bool -xnestWindowExposurePredicate(Display *display, XEvent *event, XPointer ptr) -{ - return (event->type == Expose && event->xexpose.window == *(Window *)ptr); -} - -void -xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_exposed) -{ - XEvent event; - Window window; - BoxRec Box; - - XSync(xnestDisplay, False); - - window = xnestWindow(pWin); - - while (XCheckIfEvent(xnestDisplay, &event, - xnestWindowExposurePredicate, (char *)&window)) { - - Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + event.xexpose.x; - Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + event.xexpose.y; - Box.x2 = Box.x1 + event.xexpose.width; - Box.y2 = Box.y1 + event.xexpose.height; - - event.xexpose.type = ProcessedExpose; - - if (RECT_IN_REGION(pWin->drawable.pScreen, pRgn, &Box) != rgnIN) - XPutBackEvent(xnestDisplay, &event); - } - - miWindowExposures(pWin, pRgn, other_exposed); -} - -void -xnestSetShape(WindowPtr pWin) -{ - xnestShapeWindow(pWin); - miSetShape(pWin); -} - -static Bool -xnestRegionEqual(RegionPtr pReg1, RegionPtr pReg2) -{ - BoxPtr pBox1, pBox2; - unsigned int n1, n2; - - if (pReg1 == pReg2) return True; - - if (pReg1 == NullRegion || pReg2 == NullRegion) return False; - - pBox1 = REGION_RECTS(pReg1); - n1 = REGION_NUM_RECTS(pReg1); - - pBox2 = REGION_RECTS(pReg2); - n2 = REGION_NUM_RECTS(pReg2); - - if (n1 != n2) return False; - - if (pBox1 == pBox2) return True; - - if (memcmp(pBox1, pBox2, n1 * sizeof(BoxRec))) return False; - - return True; -} - -void -xnestShapeWindow(WindowPtr pWin) -{ - Region reg; - BoxPtr pBox; - XRectangle rect; - int i; - - if (!xnestRegionEqual(xnestWindowPriv(pWin)->bounding_shape, - wBoundingShape(pWin))) { - - if (wBoundingShape(pWin)) { - REGION_COPY(pWin->drawable.pScreen, - xnestWindowPriv(pWin)->bounding_shape, wBoundingShape(pWin)); - - reg = XCreateRegion(); - pBox = REGION_RECTS(xnestWindowPriv(pWin)->bounding_shape); - for (i = 0; - i < REGION_NUM_RECTS(xnestWindowPriv(pWin)->bounding_shape); - i++) { - rect.x = pBox[i].x1; - rect.y = pBox[i].y1; - rect.width = pBox[i].x2 - pBox[i].x1; - rect.height = pBox[i].y2 - pBox[i].y1; - XUnionRectWithRegion(&rect, reg, reg); - } - XShapeCombineRegion(xnestDisplay, xnestWindow(pWin), - ShapeBounding, 0, 0, reg, ShapeSet); - XDestroyRegion(reg); - } - else { - REGION_EMPTY(pWin->drawable.pScreen, - xnestWindowPriv(pWin)->bounding_shape); - - XShapeCombineMask(xnestDisplay, xnestWindow(pWin), - ShapeBounding, 0, 0, None, ShapeSet); - } - } - - if (!xnestRegionEqual(xnestWindowPriv(pWin)->clip_shape, - wClipShape(pWin))) { - - if (wClipShape(pWin)) { - REGION_COPY(pWin->drawable.pScreen, - xnestWindowPriv(pWin)->clip_shape, wClipShape(pWin)); - - reg = XCreateRegion(); - pBox = REGION_RECTS(xnestWindowPriv(pWin)->clip_shape); - for (i = 0; - i < REGION_NUM_RECTS(xnestWindowPriv(pWin)->clip_shape); - i++) { - rect.x = pBox[i].x1; - rect.y = pBox[i].y1; - rect.width = pBox[i].x2 - pBox[i].x1; - rect.height = pBox[i].y2 - pBox[i].y1; - XUnionRectWithRegion(&rect, reg, reg); - } - XShapeCombineRegion(xnestDisplay, xnestWindow(pWin), - ShapeClip, 0, 0, reg, ShapeSet); - XDestroyRegion(reg); - } - else { - REGION_EMPTY(pWin->drawable.pScreen, - xnestWindowPriv(pWin)->clip_shape); - - XShapeCombineMask(xnestDisplay, xnestWindow(pWin), - ShapeClip, 0, 0, None, ShapeSet); - } - } -} +/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "gcstruct.h"
+#include "window.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "colormapst.h"
+#include "scrnintstr.h"
+#include "region.h"
+
+#include "mi.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "XNGC.h"
+#include "Drawable.h"
+#include "Color.h"
+#include "Visual.h"
+#include "Events.h"
+#include "Args.h"
+
+DevPrivateKeyRec xnestWindowPrivateKeyRec;
+
+static int
+xnestFindWindowMatch(WindowPtr pWin, pointer ptr)
+{
+ xnestWindowMatch *wm = (xnestWindowMatch *)ptr;
+ if (wm->window == xnestWindow(pWin)) {
+ wm->pWin = pWin;
+ return WT_STOPWALKING;
+ }
+ else
+ return WT_WALKCHILDREN;
+}
+
+WindowPtr
+xnestWindowPtr(Window window)
+{
+ xnestWindowMatch wm;
+ int i;
+
+ wm.pWin = NullWindow;
+ wm.window = window;
+
+ for (i = 0; i < xnestNumScreens; i++) {
+ WalkTree(screenInfo.screens[i], xnestFindWindowMatch, (pointer) &wm);
+ if (wm.pWin) break;
+ }
+
+ return wm.pWin;
+}
+
+Bool
+xnestCreateWindow(WindowPtr pWin)
+{
+ unsigned long mask;
+ XSetWindowAttributes attributes;
+ Visual *visual;
+ ColormapPtr pCmap;
+
+ if (pWin->drawable.class == InputOnly) {
+ mask = 0L;
+ visual = CopyFromParent;
+ }
+ else {
+ mask = CWEventMask | CWBackingStore;
+ attributes.event_mask = ExposureMask;
+ attributes.backing_store = NotUseful;
+
+ if (pWin->parent) {
+ if (pWin->optional && pWin->optional->visual != wVisual(pWin->parent)) {
+ visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin));
+ mask |= CWColormap;
+ if (pWin->optional->colormap) {
+ dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin),
+ RT_COLORMAP, serverClient, DixUseAccess);
+ attributes.colormap = xnestColormap(pCmap);
+ }
+ else
+ attributes.colormap = xnestDefaultVisualColormap(visual);
+ }
+ else
+ visual = CopyFromParent;
+ }
+ else { /* root windows have their own colormaps at creation time */
+ visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin));
+ dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin),
+ RT_COLORMAP, serverClient, DixUseAccess);
+ mask |= CWColormap;
+ attributes.colormap = xnestColormap(pCmap);
+ }
+ }
+
+ xnestWindowPriv(pWin)->window = XCreateWindow(xnestDisplay,
+ xnestWindowParent(pWin),
+ pWin->origin.x -
+ wBorderWidth(pWin),
+ pWin->origin.y -
+ wBorderWidth(pWin),
+ pWin->drawable.width,
+ pWin->drawable.height,
+ pWin->borderWidth,
+ pWin->drawable.depth,
+ pWin->drawable.class,
+ visual,
+ mask, &attributes);
+ xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin);
+ xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin);
+ xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin);
+ xnestWindowPriv(pWin)->width = pWin->drawable.width;
+ xnestWindowPriv(pWin)->height = pWin->drawable.height;
+ xnestWindowPriv(pWin)->border_width = pWin->borderWidth;
+ xnestWindowPriv(pWin)->sibling_above = None;
+ if (pWin->nextSib)
+ xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin);
+ xnestWindowPriv(pWin)->bounding_shape =
+ RegionCreate(NULL, 1);
+ xnestWindowPriv(pWin)->clip_shape =
+ RegionCreate(NULL, 1);
+
+ if (!pWin->parent) /* only the root window will have the right colormap */
+ xnestSetInstalledColormapWindows(pWin->drawable.pScreen);
+
+ return True;
+}
+
+Bool
+xnestDestroyWindow(WindowPtr pWin)
+{
+ if (pWin->nextSib)
+ xnestWindowPriv(pWin->nextSib)->sibling_above =
+ xnestWindowPriv(pWin)->sibling_above;
+ RegionDestroy(xnestWindowPriv(pWin)->bounding_shape);
+ RegionDestroy(xnestWindowPriv(pWin)->clip_shape);
+ XDestroyWindow(xnestDisplay, xnestWindow(pWin));
+ xnestWindowPriv(pWin)->window = None;
+
+ if (pWin->optional && pWin->optional->colormap && pWin->parent)
+ xnestSetInstalledColormapWindows(pWin->drawable.pScreen);
+
+ return True;
+}
+
+Bool
+xnestPositionWindow(WindowPtr pWin, int x, int y)
+{
+ xnestConfigureWindow(pWin,
+ CWParent |
+ CWX | CWY |
+ CWWidth | CWHeight |
+ CWBorderWidth);
+
+ return True;
+}
+
+void
+xnestConfigureWindow(WindowPtr pWin, unsigned int mask)
+{
+ unsigned int valuemask;
+ XWindowChanges values;
+
+ if (mask & CWParent &&
+ xnestWindowPriv(pWin)->parent != xnestWindowParent(pWin)) {
+ XReparentWindow(xnestDisplay, xnestWindow(pWin),
+ xnestWindowParent(pWin),
+ pWin->origin.x - wBorderWidth(pWin),
+ pWin->origin.y - wBorderWidth(pWin));
+ xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin);
+ xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin);
+ xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin);
+ xnestWindowPriv(pWin)->sibling_above = None;
+ if (pWin->nextSib)
+ xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin);
+ }
+
+ valuemask = 0;
+
+ if (mask & CWX &&
+ xnestWindowPriv(pWin)->x != pWin->origin.x - wBorderWidth(pWin)) {
+ valuemask |= CWX;
+ values.x =
+ xnestWindowPriv(pWin)->x =
+ pWin->origin.x - wBorderWidth(pWin);
+ }
+
+ if (mask & CWY &&
+ xnestWindowPriv(pWin)->y != pWin->origin.y - wBorderWidth(pWin)) {
+ valuemask |= CWY;
+ values.y =
+ xnestWindowPriv(pWin)->y =
+ pWin->origin.y - wBorderWidth(pWin);
+ }
+
+ if (mask & CWWidth &&
+ xnestWindowPriv(pWin)->width != pWin->drawable.width) {
+ valuemask |= CWWidth;
+ values.width =
+ xnestWindowPriv(pWin)->width =
+ pWin->drawable.width;
+ }
+
+ if (mask & CWHeight &&
+ xnestWindowPriv(pWin)->height != pWin->drawable.height) {
+ valuemask |= CWHeight;
+ values.height =
+ xnestWindowPriv(pWin)->height =
+ pWin->drawable.height;
+ }
+
+ if (mask & CWBorderWidth &&
+ xnestWindowPriv(pWin)->border_width != pWin->borderWidth) {
+ valuemask |= CWBorderWidth;
+ values.border_width =
+ xnestWindowPriv(pWin)->border_width =
+ pWin->borderWidth;
+ }
+
+ if (valuemask)
+ XConfigureWindow(xnestDisplay, xnestWindow(pWin), valuemask, &values);
+
+ if (mask & CWStackingOrder &&
+ xnestWindowPriv(pWin)->sibling_above != xnestWindowSiblingAbove(pWin)) {
+ WindowPtr pSib;
+
+ /* find the top sibling */
+ for (pSib = pWin; pSib->prevSib != NullWindow; pSib = pSib->prevSib);
+
+ /* the top sibling */
+ valuemask = CWStackMode;
+ values.stack_mode = Above;
+ XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, &values);
+ xnestWindowPriv(pSib)->sibling_above = None;
+
+ /* the rest of siblings */
+ for (pSib = pSib->nextSib; pSib != NullWindow; pSib = pSib->nextSib) {
+ valuemask = CWSibling | CWStackMode;
+ values.sibling = xnestWindowSiblingAbove(pSib);
+ values.stack_mode = Below;
+ XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, &values);
+ xnestWindowPriv(pSib)->sibling_above = xnestWindowSiblingAbove(pSib);
+ }
+ }
+}
+
+Bool
+xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
+{
+ XSetWindowAttributes attributes;
+
+ if (mask & CWBackPixmap)
+ switch (pWin->backgroundState) {
+ case None:
+ attributes.background_pixmap = None;
+ break;
+
+ case ParentRelative:
+ attributes.background_pixmap = ParentRelative;
+ break;
+
+ case BackgroundPixmap:
+ attributes.background_pixmap = xnestPixmap(pWin->background.pixmap);
+ break;
+
+ case BackgroundPixel:
+ mask &= ~CWBackPixmap;
+ break;
+ }
+
+ if (mask & CWBackPixel) {
+ if (pWin->backgroundState == BackgroundPixel)
+ attributes.background_pixel = xnestPixel(pWin->background.pixel);
+ else
+ mask &= ~CWBackPixel;
+ }
+
+ if (mask & CWBorderPixmap) {
+ if (pWin->borderIsPixel)
+ mask &= ~CWBorderPixmap;
+ else
+ attributes.border_pixmap = xnestPixmap(pWin->border.pixmap);
+ }
+
+ if (mask & CWBorderPixel) {
+ if (pWin->borderIsPixel)
+ attributes.border_pixel = xnestPixel(pWin->border.pixel);
+ else
+ mask &= ~CWBorderPixel;
+ }
+
+ if (mask & CWBitGravity)
+ attributes.bit_gravity = pWin->bitGravity;
+
+ if (mask & CWWinGravity) /* dix does this for us */
+ mask &= ~CWWinGravity;
+
+ if (mask & CWBackingStore) /* this is really not useful */
+ mask &= ~CWBackingStore;
+
+ if (mask & CWBackingPlanes) /* this is really not useful */
+ mask &= ~CWBackingPlanes;
+
+ if (mask & CWBackingPixel) /* this is really not useful */
+ mask &= ~CWBackingPixel;
+
+ if (mask & CWOverrideRedirect)
+ attributes.override_redirect = pWin->overrideRedirect;
+
+ if (mask & CWSaveUnder) /* this is really not useful */
+ mask &= ~CWSaveUnder;
+
+ if (mask & CWEventMask) /* events are handled elsewhere */
+ mask &= ~CWEventMask;
+
+ if (mask & CWDontPropagate) /* events are handled elsewhere */
+ mask &= ~CWDontPropagate;
+
+ if (mask & CWColormap) {
+ ColormapPtr pCmap;
+
+ dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin), RT_COLORMAP,
+ serverClient, DixUseAccess);
+
+ attributes.colormap = xnestColormap(pCmap);
+
+ xnestSetInstalledColormapWindows(pWin->drawable.pScreen);
+ }
+
+ if (mask & CWCursor) /* this is handeled in cursor code */
+ mask &= ~CWCursor;
+
+ if (mask)
+ XChangeWindowAttributes(xnestDisplay, xnestWindow(pWin),
+ mask, &attributes);
+
+ return True;
+}
+
+Bool
+xnestRealizeWindow(WindowPtr pWin)
+{
+ xnestConfigureWindow(pWin, CWStackingOrder);
+ xnestShapeWindow(pWin);
+ XMapWindow(xnestDisplay, xnestWindow(pWin));
+
+ return True;
+}
+
+Bool
+xnestUnrealizeWindow(WindowPtr pWin)
+{
+ XUnmapWindow(xnestDisplay, xnestWindow(pWin));
+
+ return True;
+}
+
+void
+xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion)
+{
+}
+
+void
+xnestClipNotify(WindowPtr pWin, int dx, int dy)
+{
+ xnestConfigureWindow(pWin, CWStackingOrder);
+ xnestShapeWindow(pWin);
+}
+
+static Bool
+xnestWindowExposurePredicate(Display *display, XEvent *event, XPointer ptr)
+{
+ return (event->type == Expose && event->xexpose.window == *(Window *)ptr);
+}
+
+void
+xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_exposed)
+{
+ XEvent event;
+ Window window;
+ BoxRec Box;
+
+ XSync(xnestDisplay, False);
+
+ window = xnestWindow(pWin);
+
+ while (XCheckIfEvent(xnestDisplay, &event,
+ xnestWindowExposurePredicate, (char *)&window)) {
+
+ Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + event.xexpose.x;
+ Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + event.xexpose.y;
+ Box.x2 = Box.x1 + event.xexpose.width;
+ Box.y2 = Box.y1 + event.xexpose.height;
+
+ event.xexpose.type = ProcessedExpose;
+
+ if (RegionContainsRect(pRgn, &Box) != rgnIN)
+ XPutBackEvent(xnestDisplay, &event);
+ }
+
+ miWindowExposures(pWin, pRgn, other_exposed);
+}
+
+void
+xnestSetShape(WindowPtr pWin, int kind)
+{
+ xnestShapeWindow(pWin);
+ miSetShape(pWin, kind);
+}
+
+static Bool
+xnestRegionEqual(RegionPtr pReg1, RegionPtr pReg2)
+{
+ BoxPtr pBox1, pBox2;
+ unsigned int n1, n2;
+
+ if (pReg1 == pReg2) return True;
+
+ if (pReg1 == NullRegion || pReg2 == NullRegion) return False;
+
+ pBox1 = RegionRects(pReg1);
+ n1 = RegionNumRects(pReg1);
+
+ pBox2 = RegionRects(pReg2);
+ n2 = RegionNumRects(pReg2);
+
+ if (n1 != n2) return False;
+
+ if (pBox1 == pBox2) return True;
+
+ if (memcmp(pBox1, pBox2, n1 * sizeof(BoxRec))) return False;
+
+ return True;
+}
+
+void
+xnestShapeWindow(WindowPtr pWin)
+{
+ Region reg;
+ BoxPtr pBox;
+ XRectangle rect;
+ int i;
+
+ if (!xnestRegionEqual(xnestWindowPriv(pWin)->bounding_shape,
+ wBoundingShape(pWin))) {
+
+ if (wBoundingShape(pWin)) {
+ RegionCopy(xnestWindowPriv(pWin)->bounding_shape, wBoundingShape(pWin));
+
+ reg = XCreateRegion();
+ pBox = RegionRects(xnestWindowPriv(pWin)->bounding_shape);
+ for (i = 0;
+ i < RegionNumRects(xnestWindowPriv(pWin)->bounding_shape);
+ i++) {
+ rect.x = pBox[i].x1;
+ rect.y = pBox[i].y1;
+ rect.width = pBox[i].x2 - pBox[i].x1;
+ rect.height = pBox[i].y2 - pBox[i].y1;
+ XUnionRectWithRegion(&rect, reg, reg);
+ }
+ XShapeCombineRegion(xnestDisplay, xnestWindow(pWin),
+ ShapeBounding, 0, 0, reg, ShapeSet);
+ XDestroyRegion(reg);
+ }
+ else {
+ RegionEmpty(xnestWindowPriv(pWin)->bounding_shape);
+
+ XShapeCombineMask(xnestDisplay, xnestWindow(pWin),
+ ShapeBounding, 0, 0, None, ShapeSet);
+ }
+ }
+
+ if (!xnestRegionEqual(xnestWindowPriv(pWin)->clip_shape,
+ wClipShape(pWin))) {
+
+ if (wClipShape(pWin)) {
+ RegionCopy(xnestWindowPriv(pWin)->clip_shape, wClipShape(pWin));
+
+ reg = XCreateRegion();
+ pBox = RegionRects(xnestWindowPriv(pWin)->clip_shape);
+ for (i = 0;
+ i < RegionNumRects(xnestWindowPriv(pWin)->clip_shape);
+ i++) {
+ rect.x = pBox[i].x1;
+ rect.y = pBox[i].y1;
+ rect.width = pBox[i].x2 - pBox[i].x1;
+ rect.height = pBox[i].y2 - pBox[i].y1;
+ XUnionRectWithRegion(&rect, reg, reg);
+ }
+ XShapeCombineRegion(xnestDisplay, xnestWindow(pWin),
+ ShapeClip, 0, 0, reg, ShapeSet);
+ XDestroyRegion(reg);
+ }
+ else {
+ RegionEmpty(xnestWindowPriv(pWin)->clip_shape);
+
+ XShapeCombineMask(xnestDisplay, xnestWindow(pWin),
+ ShapeClip, 0, 0, None, ShapeSet);
+ }
+ }
+}
diff --git a/xorg-server/hw/xnest/XNCursor.h b/xorg-server/hw/xnest/XNCursor.h index ab2c3b1e6..c50b79d1d 100644 --- a/xorg-server/hw/xnest/XNCursor.h +++ b/xorg-server/hw/xnest/XNCursor.h @@ -1,58 +1,59 @@ -/* - -Copyright 1993 by Davor Matic - -Permission to use, copy, modify, distribute, and sell this software -and its documentation for any purpose is hereby granted without fee, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation. Davor Matic makes no representations about -the suitability of this software for any purpose. It is provided "as -is" without express or implied warranty. - -*/ - -#ifndef XNESTCURSOR_H -#define XNESTCURSOR_H - -#include "mipointrst.h" - -typedef struct { - miPointerSpriteFuncPtr spriteFuncs; -} xnestCursorFuncRec, *xnestCursorFuncPtr; - -extern DevPrivateKey xnestCursorScreenKey; -extern xnestCursorFuncRec xnestCursorFuncs; - -typedef struct { - Cursor cursor; -} xnestPrivCursor; - -#define xnestGetCursorPriv(pCursor, pScreen) ((xnestPrivCursor *) \ - dixLookupPrivate(&(pCursor)->devPrivates, CursorScreenKey(pScreen))) - -#define xnestSetCursorPriv(pCursor, pScreen, v) \ - dixSetPrivate(&(pCursor)->devPrivates, CursorScreenKey(pScreen), v) - -#define xnestCursor(pCursor, pScreen) \ - (xnestGetCursorPriv(pCursor, pScreen)->cursor) - -Bool xnestRealizeCursor(DeviceIntPtr pDev, - ScreenPtr pScreen, - CursorPtr pCursor); -Bool xnestUnrealizeCursor(DeviceIntPtr pDev, - ScreenPtr pScreen, - CursorPtr pCursor); -void xnestRecolorCursor(ScreenPtr pScreen, - CursorPtr pCursor, - Bool displayed); -void xnestSetCursor (DeviceIntPtr pDev, - ScreenPtr pScreen, - CursorPtr pCursor, - int x, int y); -void xnestMoveCursor (DeviceIntPtr pDev, - ScreenPtr pScreen, - int x, int y); -Bool xnestDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen); -void xnestDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen); -#endif /* XNESTCURSOR_H */ +/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifndef XNESTCURSOR_H
+#define XNESTCURSOR_H
+
+#include "mipointrst.h"
+
+typedef struct {
+ miPointerSpriteFuncPtr spriteFuncs;
+} xnestCursorFuncRec, *xnestCursorFuncPtr;
+
+extern DevPrivateKeyRec xnestCursorScreenKeyRec;
+#define xnestCursorScreenKey (&xnestCursorScreenKeyRec)
+extern xnestCursorFuncRec xnestCursorFuncs;
+
+typedef struct {
+ Cursor cursor;
+} xnestPrivCursor;
+
+#define xnestGetCursorPriv(pCursor, pScreen) ((xnestPrivCursor *) \
+ dixLookupPrivate(&(pCursor)->devPrivates, CursorScreenKey(pScreen)))
+
+#define xnestSetCursorPriv(pCursor, pScreen, v) \
+ dixSetPrivate(&(pCursor)->devPrivates, CursorScreenKey(pScreen), v)
+
+#define xnestCursor(pCursor, pScreen) \
+ (xnestGetCursorPriv(pCursor, pScreen)->cursor)
+
+Bool xnestRealizeCursor(DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor);
+Bool xnestUnrealizeCursor(DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor);
+void xnestRecolorCursor(ScreenPtr pScreen,
+ CursorPtr pCursor,
+ Bool displayed);
+void xnestSetCursor (DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ int x, int y);
+void xnestMoveCursor (DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ int x, int y);
+Bool xnestDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen);
+void xnestDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
+#endif /* XNESTCURSOR_H */
diff --git a/xorg-server/hw/xnest/XNGC.h b/xorg-server/hw/xnest/XNGC.h index 19535fe3a..2eb89533d 100644 --- a/xorg-server/hw/xnest/XNGC.h +++ b/xorg-server/hw/xnest/XNGC.h @@ -1,42 +1,43 @@ -/* - -Copyright 1993 by Davor Matic - -Permission to use, copy, modify, distribute, and sell this software -and its documentation for any purpose is hereby granted without fee, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation. Davor Matic makes no representations about -the suitability of this software for any purpose. It is provided "as -is" without express or implied warranty. - -*/ - -#ifndef XNESTGC_H -#define XNESTGC_H - -/* This file uses the GC definition form Xlib.h as XlibGC. */ - -typedef struct { - XlibGC gc; - int nClipRects; -} xnestPrivGC; - -extern DevPrivateKey xnestGCPrivateKey; - -#define xnestGCPriv(pGC) ((xnestPrivGC *) \ - dixLookupPrivate(&(pGC)->devPrivates, xnestGCPrivateKey)) - -#define xnestGC(pGC) (xnestGCPriv(pGC)->gc) - -Bool xnestCreateGC(GCPtr pGC); -void xnestValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable); -void xnestChangeGC(GCPtr pGC, unsigned long mask); -void xnestCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); -void xnestDestroyGC(GCPtr pGC); -void xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects); -void xnestDestroyClip(GCPtr pGC); -void xnestDestroyClipHelper(GCPtr pGC); -void xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc); - -#endif /* XNESTGC_H */ +/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifndef XNESTGC_H
+#define XNESTGC_H
+
+/* This file uses the GC definition form Xlib.h as XlibGC. */
+
+typedef struct {
+ XlibGC gc;
+ int nClipRects;
+} xnestPrivGC;
+
+extern DevPrivateKeyRec xnestGCPrivateKeyRec;
+#define xnestGCPrivateKey (&xnestGCPrivateKeyRec)
+
+#define xnestGCPriv(pGC) ((xnestPrivGC *) \
+ dixLookupPrivate(&(pGC)->devPrivates, xnestGCPrivateKey))
+
+#define xnestGC(pGC) (xnestGCPriv(pGC)->gc)
+
+Bool xnestCreateGC(GCPtr pGC);
+void xnestValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
+void xnestChangeGC(GCPtr pGC, unsigned long mask);
+void xnestCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
+void xnestDestroyGC(GCPtr pGC);
+void xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects);
+void xnestDestroyClip(GCPtr pGC);
+void xnestDestroyClipHelper(GCPtr pGC);
+void xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc);
+
+#endif /* XNESTGC_H */
diff --git a/xorg-server/hw/xnest/XNPixmap.h b/xorg-server/hw/xnest/XNPixmap.h index 614827587..0d7c6b61e 100644 --- a/xorg-server/hw/xnest/XNPixmap.h +++ b/xorg-server/hw/xnest/XNPixmap.h @@ -1,36 +1,37 @@ -/* - -Copyright 1993 by Davor Matic - -Permission to use, copy, modify, distribute, and sell this software -and its documentation for any purpose is hereby granted without fee, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation. Davor Matic makes no representations about -the suitability of this software for any purpose. It is provided "as -is" without express or implied warranty. - -*/ - -#ifndef XNESTPIXMAP_H -#define XNESTPIXMAP_H - -extern DevPrivateKey xnestPixmapPrivateKey; - -typedef struct { - Pixmap pixmap; -} xnestPrivPixmap; - -#define xnestPixmapPriv(pPixmap) ((xnestPrivPixmap *) \ - dixLookupPrivate(&(pPixmap)->devPrivates, xnestPixmapPrivateKey)) - -#define xnestPixmap(pPixmap) (xnestPixmapPriv(pPixmap)->pixmap) - -#define xnestSharePixmap(pPixmap) ((pPixmap)->refcnt++) - -PixmapPtr xnestCreatePixmap(ScreenPtr pScreen, int width, int height, - int depth, unsigned usage_hint); -Bool xnestDestroyPixmap(PixmapPtr pPixmap); -RegionPtr xnestPixmapToRegion(PixmapPtr pPixmap); - -#endif /* XNESTPIXMAP_H */ +/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifndef XNESTPIXMAP_H
+#define XNESTPIXMAP_H
+
+extern DevPrivateKeyRec xnestPixmapPrivateKeyRec;
+#define xnestPixmapPrivateKey (&xnestPixmapPrivateKeyRec)
+
+typedef struct {
+ Pixmap pixmap;
+} xnestPrivPixmap;
+
+#define xnestPixmapPriv(pPixmap) ((xnestPrivPixmap *) \
+ dixLookupPrivate(&(pPixmap)->devPrivates, xnestPixmapPrivateKey))
+
+#define xnestPixmap(pPixmap) (xnestPixmapPriv(pPixmap)->pixmap)
+
+#define xnestSharePixmap(pPixmap) ((pPixmap)->refcnt++)
+
+PixmapPtr xnestCreatePixmap(ScreenPtr pScreen, int width, int height,
+ int depth, unsigned usage_hint);
+Bool xnestDestroyPixmap(PixmapPtr pPixmap);
+RegionPtr xnestPixmapToRegion(PixmapPtr pPixmap);
+
+#endif /* XNESTPIXMAP_H */
diff --git a/xorg-server/hw/xnest/XNWindow.h b/xorg-server/hw/xnest/XNWindow.h index b59d86a97..c620767aa 100644 --- a/xorg-server/hw/xnest/XNWindow.h +++ b/xorg-server/hw/xnest/XNWindow.h @@ -1,72 +1,73 @@ -/* - -Copyright 1993 by Davor Matic - -Permission to use, copy, modify, distribute, and sell this software -and its documentation for any purpose is hereby granted without fee, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation. Davor Matic makes no representations about -the suitability of this software for any purpose. It is provided "as -is" without express or implied warranty. - -*/ - -#ifndef XNESTWINDOW_H -#define XNESTWINDOW_H - -typedef struct { - Window window; - Window parent; - int x; - int y; - unsigned int width; - unsigned int height; - unsigned int border_width; - Window sibling_above; - RegionPtr bounding_shape; - RegionPtr clip_shape; -} xnestPrivWin; - -typedef struct { - WindowPtr pWin; - Window window; -} xnestWindowMatch; - -extern DevPrivateKey xnestWindowPrivateKey; - -#define xnestWindowPriv(pWin) ((xnestPrivWin *) \ - dixLookupPrivate(&(pWin)->devPrivates, xnestWindowPrivateKey)) - -#define xnestWindow(pWin) (xnestWindowPriv(pWin)->window) - -#define xnestWindowParent(pWin) \ - ((pWin)->parent ? \ - xnestWindow((pWin)->parent) : \ - xnestDefaultWindows[pWin->drawable.pScreen->myNum]) - -#define xnestWindowSiblingAbove(pWin) \ - ((pWin)->prevSib ? xnestWindow((pWin)->prevSib) : None) - -#define xnestWindowSiblingBelow(pWin) \ - ((pWin)->nextSib ? xnestWindow((pWin)->nextSib) : None) - -#define CWParent CWSibling -#define CWStackingOrder CWStackMode - -WindowPtr xnestWindowPtr(Window window); -Bool xnestCreateWindow(WindowPtr pWin); -Bool xnestDestroyWindow(WindowPtr pWin); -Bool xnestPositionWindow(WindowPtr pWin, int x, int y); -void xnestConfigureWindow(WindowPtr pWin, unsigned int mask); -Bool xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask); -Bool xnestRealizeWindow(WindowPtr pWin); -Bool xnestUnrealizeWindow(WindowPtr pWin); -void xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion); -void xnestClipNotify(WindowPtr pWin, int dx, int dy); -void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn, - RegionPtr other_exposed); -void xnestSetShape(WindowPtr pWin); -void xnestShapeWindow(WindowPtr pWin); - -#endif /* XNESTWINDOW_H */ +/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifndef XNESTWINDOW_H
+#define XNESTWINDOW_H
+
+typedef struct {
+ Window window;
+ Window parent;
+ int x;
+ int y;
+ unsigned int width;
+ unsigned int height;
+ unsigned int border_width;
+ Window sibling_above;
+ RegionPtr bounding_shape;
+ RegionPtr clip_shape;
+} xnestPrivWin;
+
+typedef struct {
+ WindowPtr pWin;
+ Window window;
+} xnestWindowMatch;
+
+extern DevPrivateKeyRec xnestWindowPrivateKeyRec;
+#define xnestWindowPrivateKey (&xnestWindowPrivateKeyRec)
+
+#define xnestWindowPriv(pWin) ((xnestPrivWin *) \
+ dixLookupPrivate(&(pWin)->devPrivates, xnestWindowPrivateKey))
+
+#define xnestWindow(pWin) (xnestWindowPriv(pWin)->window)
+
+#define xnestWindowParent(pWin) \
+ ((pWin)->parent ? \
+ xnestWindow((pWin)->parent) : \
+ xnestDefaultWindows[pWin->drawable.pScreen->myNum])
+
+#define xnestWindowSiblingAbove(pWin) \
+ ((pWin)->prevSib ? xnestWindow((pWin)->prevSib) : None)
+
+#define xnestWindowSiblingBelow(pWin) \
+ ((pWin)->nextSib ? xnestWindow((pWin)->nextSib) : None)
+
+#define CWParent CWSibling
+#define CWStackingOrder CWStackMode
+
+WindowPtr xnestWindowPtr(Window window);
+Bool xnestCreateWindow(WindowPtr pWin);
+Bool xnestDestroyWindow(WindowPtr pWin);
+Bool xnestPositionWindow(WindowPtr pWin, int x, int y);
+void xnestConfigureWindow(WindowPtr pWin, unsigned int mask);
+Bool xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
+Bool xnestRealizeWindow(WindowPtr pWin);
+Bool xnestUnrealizeWindow(WindowPtr pWin);
+void xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion);
+void xnestClipNotify(WindowPtr pWin, int dx, int dy);
+void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn,
+ RegionPtr other_exposed);
+void xnestSetShape(WindowPtr pWin, int kind);
+void xnestShapeWindow(WindowPtr pWin);
+
+#endif /* XNESTWINDOW_H */
diff --git a/xorg-server/hw/xquartz/applewm.c b/xorg-server/hw/xquartz/applewm.c index 64851e791..054fff776 100644 --- a/xorg-server/hw/xquartz/applewm.c +++ b/xorg-server/hw/xquartz/applewm.c @@ -140,10 +140,8 @@ AppleWMSetScreenOrigin( {
int32_t data[2];
- data[0] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].x
- + darwinMainScreenX);
- data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
- + darwinMainScreenY);
+ data[0] = pWin->drawable.pScreen->x + darwinMainScreenX;
+ data[1] = pWin->drawable.pScreen->y + darwinMainScreenY;
dixChangeWindowProperty(serverClient, pWin, xa_native_screen_origin(),
XA_INTEGER, 32, PropModeReplace, 2, data, TRUE);
diff --git a/xorg-server/hw/xquartz/darwin.c b/xorg-server/hw/xquartz/darwin.c index ed9543eb2..7814967b8 100644 --- a/xorg-server/hw/xquartz/darwin.c +++ b/xorg-server/hw/xquartz/darwin.c @@ -84,8 +84,7 @@ FILE *debug_log_fp = NULL; * X server shared global variables
*/
int darwinScreensFound = 0;
-static int darwinScreenKeyIndex;
-DevPrivateKey darwinScreenKey = &darwinScreenKeyIndex;
+DevPrivateKeyRec darwinScreenKeyRec;
io_connect_t darwinParamConnect = 0;
int darwinEventReadFD = -1;
int darwinEventWriteFD = -1;
@@ -185,6 +184,9 @@ static Bool DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv Bool ret;
DarwinFramebufferPtr dfb;
+ if (!dixRegisterPrivateKey(&darwinScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
// reset index of found screens for each server generation
if (index == 0) {
foundIndex = 0;
@@ -262,8 +264,8 @@ static Bool DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv return FALSE;
}
- dixScreenOrigins[index].x = dfb->x;
- dixScreenOrigins[index].y = dfb->y;
+ pScreen->x = dfb->x;
+ pScreen->y = dfb->y;
/* ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
index, dfb->width, dfb->height, dfb->x, dfb->y); */
@@ -526,16 +528,16 @@ DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo) {
int i, left, top;
- left = dixScreenOrigins[0].x;
- top = dixScreenOrigins[0].y;
+ left = pScreenInfo->screens[0]->x;
+ top = pScreenInfo->screens[0]->y;
/* Find leftmost screen. If there's a tie, take the topmost of the two. */
for (i = 1; i < pScreenInfo->numScreens; i++) {
- if (dixScreenOrigins[i].x < left ||
- (dixScreenOrigins[i].x == left && dixScreenOrigins[i].y < top))
+ if (pScreenInfo->screens[i]->x < left ||
+ (pScreenInfo->screens[i]->x == left && pScreenInfo->screens[i]->y < top))
{
- left = dixScreenOrigins[i].x;
- top = dixScreenOrigins[i].y;
+ left = pScreenInfo->screens[i]->x;
+ top = pScreenInfo->screens[i]->y;
}
}
@@ -551,10 +553,10 @@ DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo) if (darwinMainScreenX != 0 || darwinMainScreenY != 0) {
for (i = 0; i < pScreenInfo->numScreens; i++) {
- dixScreenOrigins[i].x -= darwinMainScreenX;
- dixScreenOrigins[i].y -= darwinMainScreenY;
+ pScreenInfo->screens[i]->x -= darwinMainScreenX;
+ pScreenInfo->screens[i]->y -= darwinMainScreenY;
DEBUG_LOG("Screen %d placed at X11 coordinate (%d,%d).\n",
- i, dixScreenOrigins[i].x, dixScreenOrigins[i].y);
+ i, pScreenInfo->screens[i]->x, pScreenInfo->screens[i]->y);
}
}
}
@@ -793,7 +795,7 @@ void AbortDDX( void ) void
xf86SetRootClip (ScreenPtr pScreen, int enable)
{
- WindowPtr pWin = WindowTable[pScreen->myNum];
+ WindowPtr pWin = pScreen->root;
WindowPtr pChild;
Bool WasViewable = (Bool)(pWin->viewable);
Bool anyMarked = TRUE;
@@ -817,8 +819,8 @@ xf86SetRootClip (ScreenPtr pScreen, int enable) {
RegionPtr borderVisible;
- borderVisible = REGION_CREATE(pScreen, NullBox, 1);
- REGION_SUBTRACT(pScreen, borderVisible,
+ borderVisible = RegionCreate(NullBox, 1);
+ RegionSubtract(borderVisible,
&pWin->borderClip, &pWin->winSize);
pWin->valdata->before.borderVisible = borderVisible;
}
@@ -837,13 +839,13 @@ xf86SetRootClip (ScreenPtr pScreen, int enable) box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
- REGION_RESET(pScreen, &pWin->borderClip, &box);
- REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ RegionReset(&pWin->borderClip, &box);
+ RegionBreak(&pWin->clipList);
}
else
{
- REGION_EMPTY(pScreen, &pWin->borderClip);
- REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ RegionEmpty(&pWin->borderClip);
+ RegionBreak(&pWin->clipList);
}
ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
@@ -852,8 +854,8 @@ xf86SetRootClip (ScreenPtr pScreen, int enable) {
if (pWin->backStorage)
{
- pOldClip = REGION_CREATE(pScreen, NullBox, 1);
- REGION_COPY(pScreen, pOldClip, &pWin->clipList);
+ pOldClip = RegionCreate(NullBox, 1);
+ RegionCopy(pOldClip, &pWin->clipList);
}
if (pWin->firstChild)
@@ -882,7 +884,7 @@ xf86SetRootClip (ScreenPtr pScreen, int enable) (pWin, 0, 0, pOldClip,
pWin->drawable.x, pWin->drawable.y);
if (WasViewable)
- REGION_DESTROY(pScreen, pOldClip);
+ RegionDestroy(pOldClip);
if (bsExposed)
{
RegionPtr valExposed = NullRegion;
@@ -891,8 +893,8 @@ xf86SetRootClip (ScreenPtr pScreen, int enable) valExposed = &pWin->valdata->after.exposed;
(*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
if (valExposed)
- REGION_EMPTY(pScreen, valExposed);
- REGION_DESTROY(pScreen, bsExposed);
+ RegionEmpty(valExposed);
+ RegionDestroy(bsExposed);
}
}
if (WasViewable)
diff --git a/xorg-server/hw/xquartz/darwin.h b/xorg-server/hw/xquartz/darwin.h index 6209b5ef1..7cd4336cd 100644 --- a/xorg-server/hw/xquartz/darwin.h +++ b/xorg-server/hw/xquartz/darwin.h @@ -50,7 +50,8 @@ void xf86SetRootClip (ScreenPtr pScreen, int enable); /*
* Global variables from darwin.c
*/
-extern DevPrivateKey darwinScreenKey; // index into pScreen.devPrivates
+extern DevPrivateKeyRec darwinScreenKeyRec;
+#define darwinScreenKey (&darwinScreenKeyRec)
extern int darwinScreensFound;
extern io_connect_t darwinParamConnect;
extern int darwinEventReadFD;
diff --git a/xorg-server/hw/xquartz/darwinEvents.c b/xorg-server/hw/xquartz/darwinEvents.c index 421efcedf..db3f5b24e 100644 --- a/xorg-server/hw/xquartz/darwinEvents.c +++ b/xorg-server/hw/xquartz/darwinEvents.c @@ -1,576 +1,576 @@ -/* -Darwin event queue and event handling - -Copyright 2007-2008 Apple Inc. -Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved. -Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved. - -This file is based on mieq.c by Keith Packard, -which contains the following copyright: -Copyright 1990, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - */ - -#include "sanitizedCarbon.h" - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> -#include <X11/Xproto.h> -#include "misc.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "inputstr.h" -#include "eventstr.h" -#include "mi.h" -#include "scrnintstr.h" -#include "mipointer.h" -#include "os.h" - -#include "darwin.h" -#include "quartz.h" -#include "quartzKeyboard.h" -#include "darwinEvents.h" - -#include <sys/types.h> -#include <sys/uio.h> -#include <unistd.h> -#include <pthread.h> -#include <errno.h> - -#include <IOKit/hidsystem/IOLLEvent.h> - -/* Fake button press/release for scroll wheel move. */ -#define SCROLLWHEELUPFAKE 4 -#define SCROLLWHEELDOWNFAKE 5 -#define SCROLLWHEELLEFTFAKE 6 -#define SCROLLWHEELRIGHTFAKE 7 - -#include <X11/extensions/applewmconst.h> -#include "applewmExt.h" - -/* FIXME: Abstract this better */ -extern Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev); - -int darwin_all_modifier_flags = 0; // last known modifier state -int darwin_all_modifier_mask = 0; -int darwin_x11_modifier_mask = 0; - -#define FD_ADD_MAX 128 -static int fd_add[FD_ADD_MAX]; -int fd_add_count = 0; -static pthread_mutex_t fd_add_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t fd_add_ready_cond = PTHREAD_COND_INITIALIZER; -static pthread_t fd_add_tid = NULL; - -static EventListPtr darwinEvents = NULL; - -static pthread_mutex_t mieq_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER; - -/*** Pthread Magics ***/ -static pthread_t create_thread(void *func, void *arg) { - pthread_attr_t attr; - pthread_t tid; - - pthread_attr_init (&attr); - pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM); - pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); - pthread_create (&tid, &attr, func, arg); - pthread_attr_destroy (&attr); - - return tid; -} - -void darwinEvents_lock(void); -void darwinEvents_lock(void) { - int err; - if((err = pthread_mutex_lock(&mieq_lock))) { - ErrorF("%s:%s:%d: Failed to lock mieq_lock: %d\n", - __FILE__, __FUNCTION__, __LINE__, err); - spewCallStack(); - } - if(darwinEvents == NULL) { - pthread_cond_wait(&mieq_ready_cond, &mieq_lock); - } -} - -void darwinEvents_unlock(void); -void darwinEvents_unlock(void) { - int err; - if((err = pthread_mutex_unlock(&mieq_lock))) { - ErrorF("%s:%s:%d: Failed to unlock mieq_lock: %d\n", - __FILE__, __FUNCTION__, __LINE__, err); - spewCallStack(); - } -} - -/* - * DarwinPressModifierKey - * Press or release the given modifier key (one of NX_MODIFIERKEY_* constants) - */ -static void DarwinPressModifierKey(int pressed, int key) { - int keycode = DarwinModifierNXKeyToNXKeycode(key, 0); - - if (keycode == 0) { - ErrorF("DarwinPressModifierKey bad keycode: key=%d\n", key); - return; - } - - DarwinSendKeyboardEvents(pressed, keycode); -} - -/* - * DarwinUpdateModifiers - * Send events to update the modifier state. - */ - -static int darwin_x11_modifier_mask_list[] = { -#ifdef NX_DEVICELCMDKEYMASK - NX_DEVICELCTLKEYMASK, NX_DEVICERCTLKEYMASK, - NX_DEVICELSHIFTKEYMASK, NX_DEVICERSHIFTKEYMASK, - NX_DEVICELCMDKEYMASK, NX_DEVICERCMDKEYMASK, - NX_DEVICELALTKEYMASK, NX_DEVICERALTKEYMASK, -#else - NX_CONTROLMASK, NX_SHIFTMASK, NX_COMMANDMASK, NX_ALTERNATEMASK, -#endif - NX_ALPHASHIFTMASK, - 0 -}; - -static int darwin_all_modifier_mask_additions[] = { NX_SECONDARYFNMASK, }; - -static void DarwinUpdateModifiers( - int pressed, // KeyPress or KeyRelease - int flags ) // modifier flags that have changed -{ - int *f; - int key; - - /* Capslock is special. This mask is the state of capslock (on/off), - * not the state of the button. Hopefully we can find a better solution. - */ - if(NX_ALPHASHIFTMASK & flags) { - DarwinPressModifierKey(KeyPress, NX_MODIFIERKEY_ALPHALOCK); - DarwinPressModifierKey(KeyRelease, NX_MODIFIERKEY_ALPHALOCK); - } - - for(f=darwin_x11_modifier_mask_list; *f; f++) - if(*f & flags && *f != NX_ALPHASHIFTMASK) { - key = DarwinModifierNXMaskToNXKey(*f); - if(key == -1) - ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n", *f); - else - DarwinPressModifierKey(pressed, key); - } -} - -/* Generic handler for Xquartz-specifc events. When possible, these should - be moved into their own individual functions and set as handlers using - mieqSetHandler. */ - -static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) { - XQuartzEvent *e = &(ie->xquartz_event); - - TA_SERVER(); - - switch(e->subtype) { - case kXquartzControllerNotify: - DEBUG_LOG("kXquartzControllerNotify\n"); - AppleWMSendEvent(AppleWMControllerNotify, - AppleWMControllerNotifyMask, - e->data[0], - e->data[1]); - break; - - case kXquartzPasteboardNotify: - DEBUG_LOG("kXquartzPasteboardNotify\n"); - AppleWMSendEvent(AppleWMPasteboardNotify, - AppleWMPasteboardNotifyMask, - e->data[0], - e->data[1]); - break; - - case kXquartzActivate: - DEBUG_LOG("kXquartzActivate\n"); - QuartzShow(); - AppleWMSendEvent(AppleWMActivationNotify, - AppleWMActivationNotifyMask, - AppleWMIsActive, 0); - break; - - case kXquartzDeactivate: - DEBUG_LOG("kXquartzDeactivate\n"); - AppleWMSendEvent(AppleWMActivationNotify, - AppleWMActivationNotifyMask, - AppleWMIsInactive, 0); - QuartzHide(); - break; - - case kXquartzReloadPreferences: - DEBUG_LOG("kXquartzReloadPreferences\n"); - AppleWMSendEvent(AppleWMActivationNotify, - AppleWMActivationNotifyMask, - AppleWMReloadPreferences, 0); - break; - - case kXquartzToggleFullscreen: - DEBUG_LOG("kXquartzToggleFullscreen\n"); - if (quartzEnableRootless) - QuartzSetFullscreen(!quartzHasRoot); - else if (quartzHasRoot) - QuartzHide(); - else - QuartzShow(); - break; - - case kXquartzSetRootless: - DEBUG_LOG("kXquartzSetRootless\n"); - QuartzSetRootless(e->data[0]); - if (!quartzEnableRootless && !quartzHasRoot) - QuartzHide(); - break; - - case kXquartzSetRootClip: - QuartzSetRootClip((Bool)e->data[0]); - break; - - case kXquartzQuit: - GiveUp(0); - break; - - case kXquartzSpaceChanged: - DEBUG_LOG("kXquartzSpaceChanged\n"); - QuartzSpaceChanged(e->data[0]); - break; - - case kXquartzListenOnOpenFD: - ErrorF("Calling ListenOnOpenFD() for new fd: %d\n", (int)e->data[0]); - ListenOnOpenFD((int)e->data[0], 1); - break; - - case kXquartzReloadKeymap: - DarwinKeyboardReloadHandler(); - break; - - case kXquartzDisplayChanged: - QuartzUpdateScreens(); - break; - - default: - if(!QuartzModeEventHandler(screenNum, e, dev)) - ErrorF("Unknown application defined event type %d.\n", e->subtype); - } -} - -void DarwinListenOnOpenFD(int fd) { - ErrorF("DarwinListenOnOpenFD: %d\n", fd); - - pthread_mutex_lock(&fd_add_lock); - if(fd_add_count < FD_ADD_MAX) - fd_add[fd_add_count++] = fd; - else - ErrorF("FD Addition buffer at max. Dropping fd addition request.\n"); - - pthread_cond_broadcast(&fd_add_ready_cond); - pthread_mutex_unlock(&fd_add_lock); -} - -static void DarwinProcessFDAdditionQueue_thread(void *args) { - pthread_mutex_lock(&fd_add_lock); - while(true) { - while(fd_add_count) { - DarwinSendDDXEvent(kXquartzListenOnOpenFD, 1, fd_add[--fd_add_count]); - } - pthread_cond_wait(&fd_add_ready_cond, &fd_add_lock); - } -} - -Bool DarwinEQInit(void) { - int *p; - - for(p=darwin_x11_modifier_mask_list, darwin_all_modifier_mask=0; *p; p++) { - darwin_x11_modifier_mask |= *p; - } - - for(p=darwin_all_modifier_mask_additions, darwin_all_modifier_mask= darwin_x11_modifier_mask; *p; p++) { - darwin_all_modifier_mask |= *p; - } - - mieqInit(); - mieqSetHandler(ET_XQuartz, DarwinEventHandler); - - /* Note that this *could* cause a potential async issue, since we're checking - * darwinEvents without holding the lock, but darwinEvents is only ever set - * here, so I don't bother. - */ - if (!darwinEvents) { - darwinEvents = InitEventList(GetMaximumEventsNum());; - - if (!darwinEvents) - FatalError("Couldn't allocate event buffer\n"); - - darwinEvents_lock(); - pthread_cond_broadcast(&mieq_ready_cond); - darwinEvents_unlock(); - } - - if(!fd_add_tid) - fd_add_tid = create_thread(DarwinProcessFDAdditionQueue_thread, NULL); - - return TRUE; -} - -/* - * ProcessInputEvents - * Read and process events from the event queue until it is empty. - */ -void ProcessInputEvents(void) { - char nullbyte; - int x = sizeof(nullbyte); - - TA_SERVER(); - - mieqProcessInputEvents(); - - // Empty the signaling pipe - while (x == sizeof(nullbyte)) { - x = read(darwinEventReadFD, &nullbyte, sizeof(nullbyte)); - } -} - -/* Sends a null byte down darwinEventWriteFD, which will cause the - Dispatch() event loop to check out event queue */ -static void DarwinPokeEQ(void) { - char nullbyte=0; - // <daniels> oh, i ... er ... christ. - write(darwinEventWriteFD, &nullbyte, sizeof(nullbyte)); -} - -/* Convert from Appkit pointer input values to X input values: - * Note: pointer_x and pointer_y are relative to the upper-left of primary - * display. - */ -static void DarwinPrepareValuators(DeviceIntPtr pDev, int *valuators, ScreenPtr screen, - float pointer_x, float pointer_y, - float pressure, float tilt_x, float tilt_y) { - /* Fix offset between darwin and X screens */ - pointer_x -= darwinMainScreenX + dixScreenOrigins[screen->myNum].x; - pointer_y -= darwinMainScreenY + dixScreenOrigins[screen->myNum].y; - - if(pointer_x < 0.0) - pointer_x = 0.0; - - if(pointer_y < 0.0) - pointer_y = 0.0; - - if(pDev == darwinPointer) { - valuators[0] = pointer_x; - valuators[1] = pointer_y; - valuators[2] = 0; - valuators[3] = 0; - valuators[4] = 0; - } else { - /* Setup our array of values */ - valuators[0] = XQUARTZ_VALUATOR_LIMIT * (pointer_x / (float)screenInfo.screens[0]->width); - valuators[1] = XQUARTZ_VALUATOR_LIMIT * (pointer_y / (float)screenInfo.screens[0]->height); - valuators[2] = XQUARTZ_VALUATOR_LIMIT * pressure; - valuators[3] = XQUARTZ_VALUATOR_LIMIT * tilt_x; - valuators[4] = XQUARTZ_VALUATOR_LIMIT * tilt_y; - } - //DEBUG_LOG("Pointer (%f, %f), Valuators: {%d,%d,%d,%d,%d}\n", pointer_x, pointer_y, - // valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]); -} - -void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y, - float pressure, float tilt_x, float tilt_y) { - static int darwinFakeMouseButtonDown = 0; - int i, num_events; - ScreenPtr screen; - int valuators[5]; - - //DEBUG_LOG("x=%f, y=%f, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y); - - if(!darwinEvents) { - DEBUG_LOG("DarwinSendPointerEvents called before darwinEvents was initialized\n"); - return; - } - - screen = miPointerGetScreen(pDev); - if(!screen) { - DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n"); - return; - } - - /* Handle fake click */ - if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) { - if(darwinFakeMouseButtonDown != 0) { - /* We're currently "down" with another button, so release it first */ - DarwinSendPointerEvents(pDev, ButtonRelease, darwinFakeMouseButtonDown, pointer_x, pointer_y, pressure, tilt_x, tilt_y); - darwinFakeMouseButtonDown=0; - } - if (darwin_all_modifier_flags & darwinFakeMouse2Mask) { - ev_button = 2; - darwinFakeMouseButtonDown = 2; - DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse2Mask); - } else if (darwin_all_modifier_flags & darwinFakeMouse3Mask) { - ev_button = 3; - darwinFakeMouseButtonDown = 3; - DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask); - } - } - - if (ev_type == ButtonRelease && ev_button == 1) { - if(darwinFakeMouseButtonDown) { - ev_button = darwinFakeMouseButtonDown; - } - - if(darwinFakeMouseButtonDown == 2) { - DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse2Mask); - } else if(darwinFakeMouseButtonDown == 3) { - DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask); - } - - darwinFakeMouseButtonDown = 0; - } - - DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y); - darwinEvents_lock(); { - num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button, - POINTER_ABSOLUTE, 0, pDev==darwinTabletCurrent?5:2, valuators); - for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event); - if(num_events > 0) DarwinPokeEQ(); - } darwinEvents_unlock(); -} - -void DarwinSendKeyboardEvents(int ev_type, int keycode) { - int i, num_events; - - if(!darwinEvents) { - DEBUG_LOG("DarwinSendKeyboardEvents called before darwinEvents was initialized\n"); - return; - } - - darwinEvents_lock(); { - num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE); - for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard, (InternalEvent*)darwinEvents[i].event); - if(num_events > 0) DarwinPokeEQ(); - } darwinEvents_unlock(); -} - -void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) { - int i, num_events; - ScreenPtr screen; - DeviceIntPtr pDev = darwinTabletCurrent; - int valuators[5]; - - DEBUG_LOG("DarwinSendProximityEvents(%d, %f, %f)\n", ev_type, pointer_x, pointer_y); - - if(!darwinEvents) { - DEBUG_LOG("DarwinSendProximityEvents called before darwinEvents was initialized\n"); - return; - } - - screen = miPointerGetScreen(pDev); - if(!screen) { - DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n"); - return; - } - - DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, 0.0f, 0.0f, 0.0f); - darwinEvents_lock(); { - num_events = GetProximityEvents(darwinEvents, pDev, ev_type, - 0, 5, valuators); - for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event); - if(num_events > 0) DarwinPokeEQ(); - } darwinEvents_unlock(); -} - - -/* Send the appropriate number of button clicks to emulate scroll wheel */ -void DarwinSendScrollEvents(float count_x, float count_y, - float pointer_x, float pointer_y, - float pressure, float tilt_x, float tilt_y) { - int sign_x, sign_y; - if(!darwinEvents) { - DEBUG_LOG("DarwinSendScrollEvents called before darwinEvents was initialized\n"); - return; - } - - sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE; - sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE; - count_x = fabs(count_x); - count_y = fabs(count_y); - - while ((count_x > 0.0f) || (count_y > 0.0f)) { - if (count_x > 0.0f) { - DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y); - DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y); - count_x = count_x - 1.0f; - } - if (count_y > 0.0f) { - DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y); - DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y); - count_y = count_y - 1.0f; - } - } -} - -/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to - reflect changing modifier flags (alt, control, meta, etc) */ -void DarwinUpdateModKeys(int flags) { - DarwinUpdateModifiers(KeyRelease, darwin_all_modifier_flags & ~flags & darwin_x11_modifier_mask); - DarwinUpdateModifiers(KeyPress, ~darwin_all_modifier_flags & flags & darwin_x11_modifier_mask); - darwin_all_modifier_flags = flags; -} - -/* - * DarwinSendDDXEvent - * Send the X server thread a message by placing it on the event queue. - */ -void DarwinSendDDXEvent(int type, int argc, ...) { - XQuartzEvent e; - int i; - va_list args; - - memset(&e, 0, sizeof(e)); - e.header = ET_Internal; - e.type = ET_XQuartz; - e.length = sizeof(e); - e.time = GetTimeInMillis(); - e.subtype = type; - - if (argc > 0 && argc < XQUARTZ_EVENT_MAXARGS) { - va_start (args, argc); - for (i = 0; i < argc; i++) - e.data[i] = (uint32_t) va_arg (args, uint32_t); - va_end (args); - } - - darwinEvents_lock(); { - mieqEnqueue(NULL, (InternalEvent*)&e); - DarwinPokeEQ(); - } darwinEvents_unlock(); -} +/*
+Darwin event queue and event handling
+
+Copyright 2007-2008 Apple Inc.
+Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
+
+This file is based on mieq.c by Keith Packard,
+which contains the following copyright:
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+
+#include "sanitizedCarbon.h"
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "inputstr.h"
+#include "eventstr.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "mipointer.h"
+#include "os.h"
+
+#include "darwin.h"
+#include "quartz.h"
+#include "quartzKeyboard.h"
+#include "darwinEvents.h"
+
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <errno.h>
+
+#include <IOKit/hidsystem/IOLLEvent.h>
+
+/* Fake button press/release for scroll wheel move. */
+#define SCROLLWHEELUPFAKE 4
+#define SCROLLWHEELDOWNFAKE 5
+#define SCROLLWHEELLEFTFAKE 6
+#define SCROLLWHEELRIGHTFAKE 7
+
+#include <X11/extensions/applewmconst.h>
+#include "applewmExt.h"
+
+/* FIXME: Abstract this better */
+extern Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev);
+
+int darwin_all_modifier_flags = 0; // last known modifier state
+int darwin_all_modifier_mask = 0;
+int darwin_x11_modifier_mask = 0;
+
+#define FD_ADD_MAX 128
+static int fd_add[FD_ADD_MAX];
+int fd_add_count = 0;
+static pthread_mutex_t fd_add_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t fd_add_ready_cond = PTHREAD_COND_INITIALIZER;
+static pthread_t fd_add_tid = NULL;
+
+static EventListPtr darwinEvents = NULL;
+
+static pthread_mutex_t mieq_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER;
+
+/*** Pthread Magics ***/
+static pthread_t create_thread(void *func, void *arg) {
+ pthread_attr_t attr;
+ pthread_t tid;
+
+ pthread_attr_init (&attr);
+ pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ pthread_create (&tid, &attr, func, arg);
+ pthread_attr_destroy (&attr);
+
+ return tid;
+}
+
+void darwinEvents_lock(void);
+void darwinEvents_lock(void) {
+ int err;
+ if((err = pthread_mutex_lock(&mieq_lock))) {
+ ErrorF("%s:%s:%d: Failed to lock mieq_lock: %d\n",
+ __FILE__, __FUNCTION__, __LINE__, err);
+ spewCallStack();
+ }
+ if(darwinEvents == NULL) {
+ pthread_cond_wait(&mieq_ready_cond, &mieq_lock);
+ }
+}
+
+void darwinEvents_unlock(void);
+void darwinEvents_unlock(void) {
+ int err;
+ if((err = pthread_mutex_unlock(&mieq_lock))) {
+ ErrorF("%s:%s:%d: Failed to unlock mieq_lock: %d\n",
+ __FILE__, __FUNCTION__, __LINE__, err);
+ spewCallStack();
+ }
+}
+
+/*
+ * DarwinPressModifierKey
+ * Press or release the given modifier key (one of NX_MODIFIERKEY_* constants)
+ */
+static void DarwinPressModifierKey(int pressed, int key) {
+ int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
+
+ if (keycode == 0) {
+ ErrorF("DarwinPressModifierKey bad keycode: key=%d\n", key);
+ return;
+ }
+
+ DarwinSendKeyboardEvents(pressed, keycode);
+}
+
+/*
+ * DarwinUpdateModifiers
+ * Send events to update the modifier state.
+ */
+
+static int darwin_x11_modifier_mask_list[] = {
+#ifdef NX_DEVICELCMDKEYMASK
+ NX_DEVICELCTLKEYMASK, NX_DEVICERCTLKEYMASK,
+ NX_DEVICELSHIFTKEYMASK, NX_DEVICERSHIFTKEYMASK,
+ NX_DEVICELCMDKEYMASK, NX_DEVICERCMDKEYMASK,
+ NX_DEVICELALTKEYMASK, NX_DEVICERALTKEYMASK,
+#else
+ NX_CONTROLMASK, NX_SHIFTMASK, NX_COMMANDMASK, NX_ALTERNATEMASK,
+#endif
+ NX_ALPHASHIFTMASK,
+ 0
+};
+
+static int darwin_all_modifier_mask_additions[] = { NX_SECONDARYFNMASK, };
+
+static void DarwinUpdateModifiers(
+ int pressed, // KeyPress or KeyRelease
+ int flags ) // modifier flags that have changed
+{
+ int *f;
+ int key;
+
+ /* Capslock is special. This mask is the state of capslock (on/off),
+ * not the state of the button. Hopefully we can find a better solution.
+ */
+ if(NX_ALPHASHIFTMASK & flags) {
+ DarwinPressModifierKey(KeyPress, NX_MODIFIERKEY_ALPHALOCK);
+ DarwinPressModifierKey(KeyRelease, NX_MODIFIERKEY_ALPHALOCK);
+ }
+
+ for(f=darwin_x11_modifier_mask_list; *f; f++)
+ if(*f & flags && *f != NX_ALPHASHIFTMASK) {
+ key = DarwinModifierNXMaskToNXKey(*f);
+ if(key == -1)
+ ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n", *f);
+ else
+ DarwinPressModifierKey(pressed, key);
+ }
+}
+
+/* Generic handler for Xquartz-specifc events. When possible, these should
+ be moved into their own individual functions and set as handlers using
+ mieqSetHandler. */
+
+static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) {
+ XQuartzEvent *e = &(ie->xquartz_event);
+
+ TA_SERVER();
+
+ switch(e->subtype) {
+ case kXquartzControllerNotify:
+ DEBUG_LOG("kXquartzControllerNotify\n");
+ AppleWMSendEvent(AppleWMControllerNotify,
+ AppleWMControllerNotifyMask,
+ e->data[0],
+ e->data[1]);
+ break;
+
+ case kXquartzPasteboardNotify:
+ DEBUG_LOG("kXquartzPasteboardNotify\n");
+ AppleWMSendEvent(AppleWMPasteboardNotify,
+ AppleWMPasteboardNotifyMask,
+ e->data[0],
+ e->data[1]);
+ break;
+
+ case kXquartzActivate:
+ DEBUG_LOG("kXquartzActivate\n");
+ QuartzShow();
+ AppleWMSendEvent(AppleWMActivationNotify,
+ AppleWMActivationNotifyMask,
+ AppleWMIsActive, 0);
+ break;
+
+ case kXquartzDeactivate:
+ DEBUG_LOG("kXquartzDeactivate\n");
+ AppleWMSendEvent(AppleWMActivationNotify,
+ AppleWMActivationNotifyMask,
+ AppleWMIsInactive, 0);
+ QuartzHide();
+ break;
+
+ case kXquartzReloadPreferences:
+ DEBUG_LOG("kXquartzReloadPreferences\n");
+ AppleWMSendEvent(AppleWMActivationNotify,
+ AppleWMActivationNotifyMask,
+ AppleWMReloadPreferences, 0);
+ break;
+
+ case kXquartzToggleFullscreen:
+ DEBUG_LOG("kXquartzToggleFullscreen\n");
+ if (quartzEnableRootless)
+ QuartzSetFullscreen(!quartzHasRoot);
+ else if (quartzHasRoot)
+ QuartzHide();
+ else
+ QuartzShow();
+ break;
+
+ case kXquartzSetRootless:
+ DEBUG_LOG("kXquartzSetRootless\n");
+ QuartzSetRootless(e->data[0]);
+ if (!quartzEnableRootless && !quartzHasRoot)
+ QuartzHide();
+ break;
+
+ case kXquartzSetRootClip:
+ QuartzSetRootClip((Bool)e->data[0]);
+ break;
+
+ case kXquartzQuit:
+ GiveUp(0);
+ break;
+
+ case kXquartzSpaceChanged:
+ DEBUG_LOG("kXquartzSpaceChanged\n");
+ QuartzSpaceChanged(e->data[0]);
+ break;
+
+ case kXquartzListenOnOpenFD:
+ ErrorF("Calling ListenOnOpenFD() for new fd: %d\n", (int)e->data[0]);
+ ListenOnOpenFD((int)e->data[0], 1);
+ break;
+
+ case kXquartzReloadKeymap:
+ DarwinKeyboardReloadHandler();
+ break;
+
+ case kXquartzDisplayChanged:
+ QuartzUpdateScreens();
+ break;
+
+ default:
+ if(!QuartzModeEventHandler(screenNum, e, dev))
+ ErrorF("Unknown application defined event type %d.\n", e->subtype);
+ }
+}
+
+void DarwinListenOnOpenFD(int fd) {
+ ErrorF("DarwinListenOnOpenFD: %d\n", fd);
+
+ pthread_mutex_lock(&fd_add_lock);
+ if(fd_add_count < FD_ADD_MAX)
+ fd_add[fd_add_count++] = fd;
+ else
+ ErrorF("FD Addition buffer at max. Dropping fd addition request.\n");
+
+ pthread_cond_broadcast(&fd_add_ready_cond);
+ pthread_mutex_unlock(&fd_add_lock);
+}
+
+static void DarwinProcessFDAdditionQueue_thread(void *args) {
+ pthread_mutex_lock(&fd_add_lock);
+ while(true) {
+ while(fd_add_count) {
+ DarwinSendDDXEvent(kXquartzListenOnOpenFD, 1, fd_add[--fd_add_count]);
+ }
+ pthread_cond_wait(&fd_add_ready_cond, &fd_add_lock);
+ }
+}
+
+Bool DarwinEQInit(void) {
+ int *p;
+
+ for(p=darwin_x11_modifier_mask_list, darwin_all_modifier_mask=0; *p; p++) {
+ darwin_x11_modifier_mask |= *p;
+ }
+
+ for(p=darwin_all_modifier_mask_additions, darwin_all_modifier_mask= darwin_x11_modifier_mask; *p; p++) {
+ darwin_all_modifier_mask |= *p;
+ }
+
+ mieqInit();
+ mieqSetHandler(ET_XQuartz, DarwinEventHandler);
+
+ /* Note that this *could* cause a potential async issue, since we're checking
+ * darwinEvents without holding the lock, but darwinEvents is only ever set
+ * here, so I don't bother.
+ */
+ if (!darwinEvents) {
+ darwinEvents = InitEventList(GetMaximumEventsNum());;
+
+ if (!darwinEvents)
+ FatalError("Couldn't allocate event buffer\n");
+
+ darwinEvents_lock();
+ pthread_cond_broadcast(&mieq_ready_cond);
+ darwinEvents_unlock();
+ }
+
+ if(!fd_add_tid)
+ fd_add_tid = create_thread(DarwinProcessFDAdditionQueue_thread, NULL);
+
+ return TRUE;
+}
+
+/*
+ * ProcessInputEvents
+ * Read and process events from the event queue until it is empty.
+ */
+void ProcessInputEvents(void) {
+ char nullbyte;
+ int x = sizeof(nullbyte);
+
+ TA_SERVER();
+
+ mieqProcessInputEvents();
+
+ // Empty the signaling pipe
+ while (x == sizeof(nullbyte)) {
+ x = read(darwinEventReadFD, &nullbyte, sizeof(nullbyte));
+ }
+}
+
+/* Sends a null byte down darwinEventWriteFD, which will cause the
+ Dispatch() event loop to check out event queue */
+static void DarwinPokeEQ(void) {
+ char nullbyte=0;
+ // <daniels> oh, i ... er ... christ.
+ write(darwinEventWriteFD, &nullbyte, sizeof(nullbyte));
+}
+
+/* Convert from Appkit pointer input values to X input values:
+ * Note: pointer_x and pointer_y are relative to the upper-left of primary
+ * display.
+ */
+static void DarwinPrepareValuators(DeviceIntPtr pDev, int *valuators, ScreenPtr screen,
+ float pointer_x, float pointer_y,
+ float pressure, float tilt_x, float tilt_y) {
+ /* Fix offset between darwin and X screens */
+ pointer_x -= darwinMainScreenX + screen->x;
+ pointer_y -= darwinMainScreenY + screen->y;
+
+ if(pointer_x < 0.0)
+ pointer_x = 0.0;
+
+ if(pointer_y < 0.0)
+ pointer_y = 0.0;
+
+ if(pDev == darwinPointer) {
+ valuators[0] = pointer_x;
+ valuators[1] = pointer_y;
+ valuators[2] = 0;
+ valuators[3] = 0;
+ valuators[4] = 0;
+ } else {
+ /* Setup our array of values */
+ valuators[0] = XQUARTZ_VALUATOR_LIMIT * (pointer_x / (float)screenInfo.screens[0]->width);
+ valuators[1] = XQUARTZ_VALUATOR_LIMIT * (pointer_y / (float)screenInfo.screens[0]->height);
+ valuators[2] = XQUARTZ_VALUATOR_LIMIT * pressure;
+ valuators[3] = XQUARTZ_VALUATOR_LIMIT * tilt_x;
+ valuators[4] = XQUARTZ_VALUATOR_LIMIT * tilt_y;
+ }
+ //DEBUG_LOG("Pointer (%f, %f), Valuators: {%d,%d,%d,%d,%d}\n", pointer_x, pointer_y,
+ // valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
+}
+
+void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y,
+ float pressure, float tilt_x, float tilt_y) {
+ static int darwinFakeMouseButtonDown = 0;
+ int i, num_events;
+ ScreenPtr screen;
+ int valuators[5];
+
+ //DEBUG_LOG("x=%f, y=%f, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+
+ if(!darwinEvents) {
+ DEBUG_LOG("DarwinSendPointerEvents called before darwinEvents was initialized\n");
+ return;
+ }
+
+ screen = miPointerGetScreen(pDev);
+ if(!screen) {
+ DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
+ return;
+ }
+
+ /* Handle fake click */
+ if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
+ if(darwinFakeMouseButtonDown != 0) {
+ /* We're currently "down" with another button, so release it first */
+ DarwinSendPointerEvents(pDev, ButtonRelease, darwinFakeMouseButtonDown, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ darwinFakeMouseButtonDown=0;
+ }
+ if (darwin_all_modifier_flags & darwinFakeMouse2Mask) {
+ ev_button = 2;
+ darwinFakeMouseButtonDown = 2;
+ DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse2Mask);
+ } else if (darwin_all_modifier_flags & darwinFakeMouse3Mask) {
+ ev_button = 3;
+ darwinFakeMouseButtonDown = 3;
+ DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask);
+ }
+ }
+
+ if (ev_type == ButtonRelease && ev_button == 1) {
+ if(darwinFakeMouseButtonDown) {
+ ev_button = darwinFakeMouseButtonDown;
+ }
+
+ if(darwinFakeMouseButtonDown == 2) {
+ DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse2Mask);
+ } else if(darwinFakeMouseButtonDown == 3) {
+ DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask);
+ }
+
+ darwinFakeMouseButtonDown = 0;
+ }
+
+ DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ darwinEvents_lock(); {
+ num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button,
+ POINTER_ABSOLUTE, 0, pDev==darwinTabletCurrent?5:2, valuators);
+ for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event);
+ if(num_events > 0) DarwinPokeEQ();
+ } darwinEvents_unlock();
+}
+
+void DarwinSendKeyboardEvents(int ev_type, int keycode) {
+ int i, num_events;
+
+ if(!darwinEvents) {
+ DEBUG_LOG("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
+ return;
+ }
+
+ darwinEvents_lock(); {
+ num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
+ for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard, (InternalEvent*)darwinEvents[i].event);
+ if(num_events > 0) DarwinPokeEQ();
+ } darwinEvents_unlock();
+}
+
+void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) {
+ int i, num_events;
+ ScreenPtr screen;
+ DeviceIntPtr pDev = darwinTabletCurrent;
+ int valuators[5];
+
+ DEBUG_LOG("DarwinSendProximityEvents(%d, %f, %f)\n", ev_type, pointer_x, pointer_y);
+
+ if(!darwinEvents) {
+ DEBUG_LOG("DarwinSendProximityEvents called before darwinEvents was initialized\n");
+ return;
+ }
+
+ screen = miPointerGetScreen(pDev);
+ if(!screen) {
+ DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
+ return;
+ }
+
+ DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, 0.0f, 0.0f, 0.0f);
+ darwinEvents_lock(); {
+ num_events = GetProximityEvents(darwinEvents, pDev, ev_type,
+ 0, 5, valuators);
+ for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event);
+ if(num_events > 0) DarwinPokeEQ();
+ } darwinEvents_unlock();
+}
+
+
+/* Send the appropriate number of button clicks to emulate scroll wheel */
+void DarwinSendScrollEvents(float count_x, float count_y,
+ float pointer_x, float pointer_y,
+ float pressure, float tilt_x, float tilt_y) {
+ int sign_x, sign_y;
+ if(!darwinEvents) {
+ DEBUG_LOG("DarwinSendScrollEvents called before darwinEvents was initialized\n");
+ return;
+ }
+
+ sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
+ sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
+ count_x = fabs(count_x);
+ count_y = fabs(count_y);
+
+ while ((count_x > 0.0f) || (count_y > 0.0f)) {
+ if (count_x > 0.0f) {
+ DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ count_x = count_x - 1.0f;
+ }
+ if (count_y > 0.0f) {
+ DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ count_y = count_y - 1.0f;
+ }
+ }
+}
+
+/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
+ reflect changing modifier flags (alt, control, meta, etc) */
+void DarwinUpdateModKeys(int flags) {
+ DarwinUpdateModifiers(KeyRelease, darwin_all_modifier_flags & ~flags & darwin_x11_modifier_mask);
+ DarwinUpdateModifiers(KeyPress, ~darwin_all_modifier_flags & flags & darwin_x11_modifier_mask);
+ darwin_all_modifier_flags = flags;
+}
+
+/*
+ * DarwinSendDDXEvent
+ * Send the X server thread a message by placing it on the event queue.
+ */
+void DarwinSendDDXEvent(int type, int argc, ...) {
+ XQuartzEvent e;
+ int i;
+ va_list args;
+
+ memset(&e, 0, sizeof(e));
+ e.header = ET_Internal;
+ e.type = ET_XQuartz;
+ e.length = sizeof(e);
+ e.time = GetTimeInMillis();
+ e.subtype = type;
+
+ if (argc > 0 && argc < XQUARTZ_EVENT_MAXARGS) {
+ va_start (args, argc);
+ for (i = 0; i < argc; i++)
+ e.data[i] = (uint32_t) va_arg (args, uint32_t);
+ va_end (args);
+ }
+
+ darwinEvents_lock(); {
+ mieqEnqueue(NULL, (InternalEvent*)&e);
+ DarwinPokeEQ();
+ } darwinEvents_unlock();
+}
diff --git a/xorg-server/hw/xquartz/darwinXinput.c b/xorg-server/hw/xquartz/darwinXinput.c index 54ba2032a..958c7cdd4 100644 --- a/xorg-server/hw/xquartz/darwinXinput.c +++ b/xorg-server/hw/xquartz/darwinXinput.c @@ -210,14 +210,14 @@ ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev, DEBUG_LOG("ChangeDeviceControl(%p, %p, %p)\n", client, dev, control);
switch (control->control) {
case DEVICE_RESOLUTION:
- return (BadMatch);
+ return BadMatch;
case DEVICE_ABS_CALIB:
case DEVICE_ABS_AREA:
- return (BadMatch);
+ return BadMatch;
case DEVICE_CORE:
- return (BadMatch);
+ return BadMatch;
default:
- return (BadMatch);
+ return BadMatch;
}
}
diff --git a/xorg-server/hw/xquartz/mach-startup/bundle-main.c b/xorg-server/hw/xquartz/mach-startup/bundle-main.c index 63a185fc8..6dc7f9094 100644 --- a/xorg-server/hw/xquartz/mach-startup/bundle-main.c +++ b/xorg-server/hw/xquartz/mach-startup/bundle-main.c @@ -1,692 +1,692 @@ -/* main.c -- X application launcher - - Copyright (c) 2007 Jeremy Huddleston - Copyright (c) 2007 Apple Inc - - 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. */ - -#include <CoreFoundation/CoreFoundation.h> -#include <AvailabilityMacros.h> - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/Xlib.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <pthread.h> -#include <stdbool.h> -#include <signal.h> - -#include <sys/socket.h> -#include <sys/un.h> - -#include <sys/time.h> -#include <fcntl.h> - -#include <mach/mach.h> -#include <mach/mach_error.h> -#include <servers/bootstrap.h> -#include "mach_startup.h" -#include "mach_startupServer.h" - -#include "launchd_fd.h" -/* From darwinEvents.c ... but don't want to pull in all the server cruft */ -void DarwinListenOnOpenFD(int fd); - -extern int noPanoramiXExtension; - -#define DEFAULT_CLIENT X11BINDIR "/xterm" -#define DEFAULT_STARTX X11BINDIR "/startx" -#define DEFAULT_SHELL "/bin/sh" - -#ifndef BUILD_DATE -#define BUILD_DATE "" -#endif -#ifndef XSERVER_VERSION -#define XSERVER_VERSION "?" -#endif - -static char __crashreporter_info_buff__[4096] = {0}; -static const char *__crashreporter_info__ = &__crashreporter_info_buff__[0]; -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 -// This is actually a toolchain requirement, but I'm not sure the correct check, -// but it should be fine to just only include it for Leopard and later. This line -// just tells the linker to never strip this symbol (such as for space optimization) -asm (".desc ___crashreporter_info__, 0x10"); -#endif - -static const char *__crashreporter_info__base = "X.Org X Server " XSERVER_VERSION " Build Date: " BUILD_DATE; - -static char *launchd_id_prefix = NULL; -static char *server_bootstrap_name = NULL; - -#define DEBUG 1 - -/* This is in quartzStartup.c */ -int server_main(int argc, char **argv, char **envp); - -static int execute(const char *command); -static char *command_from_prefs(const char *key, const char *default_value); - -/*** Pthread Magics ***/ -static pthread_t create_thread(void *func, void *arg) { - pthread_attr_t attr; - pthread_t tid; - - pthread_attr_init (&attr); - pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM); - pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); - pthread_create (&tid, &attr, func, arg); - pthread_attr_destroy (&attr); - - return tid; -} - -/*** Mach-O IPC Stuffs ***/ - -union MaxMsgSize { - union __RequestUnion__mach_startup_subsystem req; - union __ReplyUnion__mach_startup_subsystem rep; -}; - -static mach_port_t checkin_or_register(char *bname) { - kern_return_t kr; - mach_port_t mp; - - /* If we're started by launchd or the old mach_init */ - kr = bootstrap_check_in(bootstrap_port, bname, &mp); - if (kr == KERN_SUCCESS) - return mp; - - /* We probably were not started by launchd or the old mach_init */ - kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp); - if (kr != KERN_SUCCESS) { - fprintf(stderr, "mach_port_allocate(): %s\n", mach_error_string(kr)); - exit(EXIT_FAILURE); - } - - kr = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND); - if (kr != KERN_SUCCESS) { - fprintf(stderr, "mach_port_insert_right(): %s\n", mach_error_string(kr)); - exit(EXIT_FAILURE); - } - - kr = bootstrap_register(bootstrap_port, bname, mp); - if (kr != KERN_SUCCESS) { - fprintf(stderr, "bootstrap_register(): %s\n", mach_error_string(kr)); - exit(EXIT_FAILURE); - } - - return mp; -} - -/*** $DISPLAY handoff ***/ -static int accept_fd_handoff(int connected_fd) { - int launchd_fd; - - char databuf[] = "display"; - struct iovec iov[1]; - - union { - struct cmsghdr hdr; - char bytes[CMSG_SPACE(sizeof(int))]; - } buf; - - struct msghdr msg; - struct cmsghdr *cmsg; - - iov[0].iov_base = databuf; - iov[0].iov_len = sizeof(databuf); - - msg.msg_iov = iov; - msg.msg_iovlen = 1; - msg.msg_control = buf.bytes; - msg.msg_controllen = sizeof(buf); - msg.msg_name = 0; - msg.msg_namelen = 0; - msg.msg_flags = 0; - - cmsg = CMSG_FIRSTHDR (&msg); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(sizeof(int)); - - msg.msg_controllen = cmsg->cmsg_len; - - *((int*)CMSG_DATA(cmsg)) = -1; - - if(recvmsg(connected_fd, &msg, 0) < 0) { - fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", strerror(errno)); - return -1; - } - - launchd_fd = *((int*)CMSG_DATA(cmsg)); - - return launchd_fd; -} - -typedef struct { - int fd; - string_t filename; -} socket_handoff_t; - -/* This thread accepts an incoming connection and hands off the file - * descriptor for the new connection to accept_fd_handoff() - */ -static void socket_handoff_thread(void *arg) { - socket_handoff_t *handoff_data = (socket_handoff_t *)arg; - int launchd_fd = -1; - int connected_fd; - unsigned remain; - - /* Now actually get the passed file descriptor from this connection - * If we encounter an error, keep listening. - */ - while(launchd_fd == -1) { - connected_fd = accept(handoff_data->fd, NULL, NULL); - if(connected_fd == -1) { - fprintf(stderr, "X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno)); - sleep(2); - continue; - } - - launchd_fd = accept_fd_handoff(connected_fd); - if(launchd_fd == -1) - fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n"); - - close(connected_fd); - } - - close(handoff_data->fd); - unlink(handoff_data->filename); - free(handoff_data); - - /* TODO: Clean up this race better... giving xinitrc time to run... need to wait for 1.5 branch: - * - * From ajax: - * There's already an internal callback chain for setting selection [in 1.5] - * ownership. See the CallSelectionCallback at the bottom of - * ProcSetSelectionOwner, and xfixes/select.c for an example of how to hook - * into it. - */ - - remain = 3000000; - fprintf(stderr, "X11.app: Received new $DISPLAY fd: %d ... sleeping to allow xinitrc to catchup.\n", launchd_fd); - while((remain = usleep(remain)) > 0); - - fprintf(stderr, "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd); - DarwinListenOnOpenFD(launchd_fd); -} - -static int create_socket(char *filename_out) { - struct sockaddr_un servaddr_un; - struct sockaddr *servaddr; - socklen_t servaddr_len; - int ret_fd; - size_t try, try_max; - - for(try=0, try_max=5; try < try_max; try++) { - tmpnam(filename_out); - - /* Setup servaddr_un */ - memset (&servaddr_un, 0, sizeof (struct sockaddr_un)); - servaddr_un.sun_family = AF_UNIX; - strlcpy(servaddr_un.sun_path, filename_out, sizeof(servaddr_un.sun_path)); - - servaddr = (struct sockaddr *) &servaddr_un; - servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename_out); - - ret_fd = socket(PF_UNIX, SOCK_STREAM, 0); - if(ret_fd == -1) { - fprintf(stderr, "X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno)); - continue; - } - - if(bind(ret_fd, servaddr, servaddr_len) != 0) { - fprintf(stderr, "X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno)); - close(ret_fd); - return 0; - } - - if(listen(ret_fd, 10) != 0) { - fprintf(stderr, "X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno)); - close(ret_fd); - return 0; - } - -#ifdef DEBUG - fprintf(stderr, "X11.app: Listening on socket for fd handoff: (%d) %s\n", ret_fd, filename_out); -#endif - - return ret_fd; - } - - return 0; -} - -static int launchd_socket_handed_off = 0; - -kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename) { - socket_handoff_t *handoff_data; - - launchd_socket_handed_off = 1; - - handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t)); - if(!handoff_data) { - fprintf(stderr, "X11.app: Error allocating memory for handoff_data\n"); - return KERN_FAILURE; - } - - handoff_data->fd = create_socket(handoff_data->filename); - if(!handoff_data->fd) { - free(handoff_data); - return KERN_FAILURE; - } - - strlcpy(filename, handoff_data->filename, STRING_T_SIZE); - - create_thread(socket_handoff_thread, handoff_data); - -#ifdef DEBUG - fprintf(stderr, "X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n"); -#endif - - return KERN_SUCCESS; -} - -kern_return_t do_request_pid(mach_port_t port, int *my_pid) { - *my_pid = getpid(); - return KERN_SUCCESS; -} - -/*** Server Startup ***/ -kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv, - mach_msg_type_number_t argvCnt, - string_array_t envp, - mach_msg_type_number_t envpCnt) { - /* And now back to char ** */ - char **_argv = alloca((argvCnt + 1) * sizeof(char *)); - char **_envp = alloca((envpCnt + 1) * sizeof(char *)); - size_t i; - - /* If we didn't get handed a launchd DISPLAY socket, we should - * unset DISPLAY or we can run into problems with pbproxy - */ - if(!launchd_socket_handed_off) { - fprintf(stderr, "X11.app: No launchd socket handed off, unsetting DISPLAY\n"); - unsetenv("DISPLAY"); - } - - if(!_argv || !_envp) { - return KERN_FAILURE; - } - - fprintf(stderr, "X11.app: do_start_x11_server(): argc=%d\n", argvCnt); - for(i=0; i < argvCnt; i++) { - _argv[i] = argv[i]; - fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]); - } - _argv[argvCnt] = NULL; - - for(i=0; i < envpCnt; i++) { - _envp[i] = envp[i]; - } - _envp[envpCnt] = NULL; - - if(server_main(argvCnt, _argv, _envp) == 0) - return KERN_SUCCESS; - else - return KERN_FAILURE; -} - -static int startup_trigger(int argc, char **argv, char **envp) { - Display *display; - const char *s; - - /* Take care of the case where we're called like a normal DDX */ - if(argc > 1 && argv[1][0] == ':') { - size_t i; - kern_return_t kr; - mach_port_t mp; - string_array_t newenvp; - string_array_t newargv; - - /* We need to count envp */ - int envpc; - for(envpc=0; envp[envpc]; envpc++); - - /* We have fixed-size string lengths due to limitations in IPC, - * so we need to copy our argv and envp. - */ - newargv = (string_array_t)alloca(argc * sizeof(string_t)); - newenvp = (string_array_t)alloca(envpc * sizeof(string_t)); - - if(!newargv || !newenvp) { - fprintf(stderr, "Memory allocation failure\n"); - exit(EXIT_FAILURE); - } - - for(i=0; i < argc; i++) { - strlcpy(newargv[i], argv[i], STRING_T_SIZE); - } - for(i=0; i < envpc; i++) { - strlcpy(newenvp[i], envp[i], STRING_T_SIZE); - } - - kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp); - if (kr != KERN_SUCCESS) { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 - fprintf(stderr, "bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr)); -#else - fprintf(stderr, "bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr); -#endif - exit(EXIT_FAILURE); - } - - kr = start_x11_server(mp, newargv, argc, newenvp, envpc); - if (kr != KERN_SUCCESS) { - fprintf(stderr, "start_x11_server: %s\n", mach_error_string(kr)); - exit(EXIT_FAILURE); - } - exit(EXIT_SUCCESS); - } - - /* If we have a process serial number and it's our only arg, act as if - * the user double clicked the app bundle: launch app_to_run if possible - */ - if(argc == 1 || (argc == 2 && !strncmp(argv[1], "-psn_", 5))) { - /* Now, try to open a display, if so, run the launcher */ - display = XOpenDisplay(NULL); - if(display) { - /* Could open the display, start the launcher */ - XCloseDisplay(display); - - return execute(command_from_prefs("app_to_run", DEFAULT_CLIENT)); - } - } - - /* Start the server */ - if((s = getenv("DISPLAY"))) { - fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s); - unsetenv("DISPLAY"); - } else { - fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n"); - } - return execute(command_from_prefs("startx_script", DEFAULT_STARTX)); -} - -/** Setup the environment we want our child processes to inherit */ -static void ensure_path(const char *dir) { - char buf[1024], *temp; - - /* Make sure /usr/X11/bin is in the $PATH */ - temp = getenv("PATH"); - if(temp == NULL || temp[0] == 0) { - snprintf(buf, sizeof(buf), "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s", dir); - setenv("PATH", buf, TRUE); - } else if(strnstr(temp, X11BINDIR, sizeof(temp)) == NULL) { - snprintf(buf, sizeof(buf), "%s:%s", temp, dir); - setenv("PATH", buf, TRUE); - } -} - -static void setup_env(void) { - char *temp; - const char *pds = NULL; - const char *disp = getenv("DISPLAY"); - size_t len; - - /* Pass on our prefs domain to startx and its inheritors (mainly for - * quartz-wm and the Xquartz stub's MachIPC) - */ - CFBundleRef bundle = CFBundleGetMainBundle(); - if(bundle) { - CFStringRef pd = CFBundleGetIdentifier(bundle); - if(pd) { - pds = CFStringGetCStringPtr(pd, 0); - } - } - - /* fallback to hardcoded value if we can't discover it */ - if(!pds) { - pds = LAUNCHD_ID_PREFIX".X11"; - } - - server_bootstrap_name = malloc(sizeof(char) * (strlen(pds) + 1)); - if(!server_bootstrap_name) { - fprintf(stderr, "X11.app: Memory allocation error.\n"); - exit(1); - } - strcpy(server_bootstrap_name, pds); - setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1); - - len = strlen(server_bootstrap_name); - launchd_id_prefix = malloc(sizeof(char) * (len - 3)); - if(!launchd_id_prefix) { - fprintf(stderr, "X11.app: Memory allocation error.\n"); - exit(1); - } - strlcpy(launchd_id_prefix, server_bootstrap_name, len - 3); - - /* We need to unset DISPLAY if it is not our socket */ - if(disp) { - /* s = basename(disp) */ - const char *d, *s; - for(s = NULL, d = disp; *d; d++) { - if(*d == '/') - s = d + 1; - } - - if(s && *s) { - if(strcmp(launchd_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) { - fprintf(stderr, "X11.app: Detected old style launchd DISPLAY, please update xinit.\n"); - } else { - temp = (char *)malloc(sizeof(char) * len); - if(!temp) { - fprintf(stderr, "X11.app: Memory allocation error creating space for socket name test.\n"); - exit(1); - } - strlcpy(temp, launchd_id_prefix, len); - strlcat(temp, ":0", len); - - if(strcmp(temp, s) != 0) { - /* If we don't have a match, unset it. */ - fprintf(stderr, "X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, launchd_id_prefix); - unsetenv("DISPLAY"); - } - free(temp); - } - } else { - /* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */ - fprintf(stderr, "X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n"); - unsetenv("DISPLAY"); - } - } - - /* Make sure PATH is right */ - ensure_path(X11BINDIR); - - /* cd $HOME */ - temp = getenv("HOME"); - if(temp != NULL && temp[0] != '\0') - chdir(temp); -} - -/*** Main ***/ -int main(int argc, char **argv, char **envp) { - Bool listenOnly = FALSE; - int i; - mach_msg_size_t mxmsgsz = sizeof(union MaxMsgSize) + MAX_TRAILER_SIZE; - mach_port_t mp; - kern_return_t kr; - - /* Setup our environment for our children */ - setup_env(); - - /* The server must not run the PanoramiX operations. */ - noPanoramiXExtension = TRUE; - - /* Setup the initial crasherporter info */ - strlcpy(__crashreporter_info_buff__, __crashreporter_info__base, sizeof(__crashreporter_info_buff__)); - - fprintf(stderr, "X11.app: main(): argc=%d\n", argc); - for(i=0; i < argc; i++) { - fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]); - if(!strcmp(argv[i], "--listenonly")) { - listenOnly = TRUE; - } - } - - mp = checkin_or_register(server_bootstrap_name); - if(mp == MACH_PORT_NULL) { - fprintf(stderr, "NULL mach service: %s", server_bootstrap_name); - return EXIT_FAILURE; - } - - /* Check if we need to do something other than listen, and make another - * thread handle it. - */ - if(!listenOnly) { - pid_t child1, child2; - int status; - - /* Do the fork-twice trick to avoid having to reap zombies */ - child1 = fork(); - switch (child1) { - case -1: /* error */ - break; - - case 0: /* child1 */ - child2 = fork(); - - switch (child2) { - int max_files, i; - - case -1: /* error */ - break; - - case 0: /* child2 */ - /* close all open files except for standard streams */ - max_files = sysconf(_SC_OPEN_MAX); - for(i = 3; i < max_files; i++) - close(i); - - /* ensure stdin is on /dev/null */ - close(0); - open("/dev/null", O_RDONLY); - - return startup_trigger(argc, argv, envp); - - default: /* parent (child1) */ - _exit(0); - } - break; - - default: /* parent */ - waitpid(child1, &status, 0); - } - } - - /* Main event loop */ - fprintf(stderr, "Waiting for startup parameters via Mach IPC.\n"); - kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0); - if (kr != KERN_SUCCESS) { - fprintf(stderr, "%s.X11(mp): %s\n", LAUNCHD_ID_PREFIX, mach_error_string(kr)); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} - -static int execute(const char *command) { - const char *newargv[4]; - const char **p; - - newargv[0] = command_from_prefs("login_shell", DEFAULT_SHELL); - newargv[1] = "-c"; - newargv[2] = command; - newargv[3] = NULL; - - fprintf(stderr, "X11.app: Launching %s:\n", command); - for(p=newargv; *p; p++) { - fprintf(stderr, "\targv[%ld] = %s\n", (long int)(p - newargv), *p); - } - - execvp (newargv[0], (char * const *) newargv); - perror ("X11.app: Couldn't exec."); - return(1); -} - -static char *command_from_prefs(const char *key, const char *default_value) { - char *command = NULL; - - CFStringRef cfKey; - CFPropertyListRef PlistRef; - - if(!key) - return NULL; - - cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII); - - if(!cfKey) - return NULL; - - PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication); - - if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) { - CFStringRef cfDefaultValue = CFStringCreateWithCString(NULL, default_value, kCFStringEncodingASCII); - int len = strlen(default_value) + 1; - - if(!cfDefaultValue) - goto command_from_prefs_out; - - CFPreferencesSetAppValue(cfKey, cfDefaultValue, kCFPreferencesCurrentApplication); - CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication); - CFRelease(cfDefaultValue); - - command = (char *)malloc(len * sizeof(char)); - if(!command) - goto command_from_prefs_out; - strcpy(command, default_value); - } else { - int len = CFStringGetLength((CFStringRef)PlistRef) + 1; - command = (char *)malloc(len * sizeof(char)); - if(!command) - goto command_from_prefs_out; - CFStringGetCString((CFStringRef)PlistRef, command, len, kCFStringEncodingASCII); - } - -command_from_prefs_out: - if (PlistRef) - CFRelease(PlistRef); - if(cfKey) - CFRelease(cfKey); - return command; -} +/* main.c -- X application launcher
+
+ Copyright (c) 2007 Jeremy Huddleston
+ Copyright (c) 2007 Apple Inc
+
+ 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. */
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <AvailabilityMacros.h>
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <signal.h>
+
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <sys/time.h>
+#include <fcntl.h>
+
+#include <mach/mach.h>
+#include <mach/mach_error.h>
+#include <servers/bootstrap.h>
+#include "mach_startup.h"
+#include "mach_startupServer.h"
+
+#include "launchd_fd.h"
+/* From darwinEvents.c ... but don't want to pull in all the server cruft */
+void DarwinListenOnOpenFD(int fd);
+
+extern int noPanoramiXExtension;
+
+#define DEFAULT_CLIENT X11BINDIR "/xterm"
+#define DEFAULT_STARTX X11BINDIR "/startx"
+#define DEFAULT_SHELL "/bin/sh"
+
+#ifndef BUILD_DATE
+#define BUILD_DATE ""
+#endif
+#ifndef XSERVER_VERSION
+#define XSERVER_VERSION "?"
+#endif
+
+static char __crashreporter_info_buff__[4096] = {0};
+static const char *__crashreporter_info__ = &__crashreporter_info_buff__[0];
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+// This is actually a toolchain requirement, but I'm not sure the correct check,
+// but it should be fine to just only include it for Leopard and later. This line
+// just tells the linker to never strip this symbol (such as for space optimization)
+asm (".desc ___crashreporter_info__, 0x10");
+#endif
+
+static const char *__crashreporter_info__base = "X.Org X Server " XSERVER_VERSION " Build Date: " BUILD_DATE;
+
+static char *launchd_id_prefix = NULL;
+static char *server_bootstrap_name = NULL;
+
+#define DEBUG 1
+
+/* This is in quartzStartup.c */
+int server_main(int argc, char **argv, char **envp);
+
+static int execute(const char *command);
+static char *command_from_prefs(const char *key, const char *default_value);
+
+/*** Pthread Magics ***/
+static pthread_t create_thread(void *func, void *arg) {
+ pthread_attr_t attr;
+ pthread_t tid;
+
+ pthread_attr_init (&attr);
+ pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ pthread_create (&tid, &attr, func, arg);
+ pthread_attr_destroy (&attr);
+
+ return tid;
+}
+
+/*** Mach-O IPC Stuffs ***/
+
+union MaxMsgSize {
+ union __RequestUnion__mach_startup_subsystem req;
+ union __ReplyUnion__mach_startup_subsystem rep;
+};
+
+static mach_port_t checkin_or_register(char *bname) {
+ kern_return_t kr;
+ mach_port_t mp;
+
+ /* If we're started by launchd or the old mach_init */
+ kr = bootstrap_check_in(bootstrap_port, bname, &mp);
+ if (kr == KERN_SUCCESS)
+ return mp;
+
+ /* We probably were not started by launchd or the old mach_init */
+ kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp);
+ if (kr != KERN_SUCCESS) {
+ fprintf(stderr, "mach_port_allocate(): %s\n", mach_error_string(kr));
+ exit(EXIT_FAILURE);
+ }
+
+ kr = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND);
+ if (kr != KERN_SUCCESS) {
+ fprintf(stderr, "mach_port_insert_right(): %s\n", mach_error_string(kr));
+ exit(EXIT_FAILURE);
+ }
+
+ kr = bootstrap_register(bootstrap_port, bname, mp);
+ if (kr != KERN_SUCCESS) {
+ fprintf(stderr, "bootstrap_register(): %s\n", mach_error_string(kr));
+ exit(EXIT_FAILURE);
+ }
+
+ return mp;
+}
+
+/*** $DISPLAY handoff ***/
+static int accept_fd_handoff(int connected_fd) {
+ int launchd_fd;
+
+ char databuf[] = "display";
+ struct iovec iov[1];
+
+ union {
+ struct cmsghdr hdr;
+ char bytes[CMSG_SPACE(sizeof(int))];
+ } buf;
+
+ struct msghdr msg;
+ struct cmsghdr *cmsg;
+
+ iov[0].iov_base = databuf;
+ iov[0].iov_len = sizeof(databuf);
+
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+ msg.msg_control = buf.bytes;
+ msg.msg_controllen = sizeof(buf);
+ msg.msg_name = 0;
+ msg.msg_namelen = 0;
+ msg.msg_flags = 0;
+
+ cmsg = CMSG_FIRSTHDR (&msg);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(int));
+
+ msg.msg_controllen = cmsg->cmsg_len;
+
+ *((int*)CMSG_DATA(cmsg)) = -1;
+
+ if(recvmsg(connected_fd, &msg, 0) < 0) {
+ fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", strerror(errno));
+ return -1;
+ }
+
+ launchd_fd = *((int*)CMSG_DATA(cmsg));
+
+ return launchd_fd;
+}
+
+typedef struct {
+ int fd;
+ string_t filename;
+} socket_handoff_t;
+
+/* This thread accepts an incoming connection and hands off the file
+ * descriptor for the new connection to accept_fd_handoff()
+ */
+static void socket_handoff_thread(void *arg) {
+ socket_handoff_t *handoff_data = (socket_handoff_t *)arg;
+ int launchd_fd = -1;
+ int connected_fd;
+ unsigned remain;
+
+ /* Now actually get the passed file descriptor from this connection
+ * If we encounter an error, keep listening.
+ */
+ while(launchd_fd == -1) {
+ connected_fd = accept(handoff_data->fd, NULL, NULL);
+ if(connected_fd == -1) {
+ fprintf(stderr, "X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno));
+ sleep(2);
+ continue;
+ }
+
+ launchd_fd = accept_fd_handoff(connected_fd);
+ if(launchd_fd == -1)
+ fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n");
+
+ close(connected_fd);
+ }
+
+ close(handoff_data->fd);
+ unlink(handoff_data->filename);
+ free(handoff_data);
+
+ /* TODO: Clean up this race better... giving xinitrc time to run... need to wait for 1.5 branch:
+ *
+ * From ajax:
+ * There's already an internal callback chain for setting selection [in 1.5]
+ * ownership. See the CallSelectionCallback at the bottom of
+ * ProcSetSelectionOwner, and xfixes/select.c for an example of how to hook
+ * into it.
+ */
+
+ remain = 3000000;
+ fprintf(stderr, "X11.app: Received new $DISPLAY fd: %d ... sleeping to allow xinitrc to catchup.\n", launchd_fd);
+ while((remain = usleep(remain)) > 0);
+
+ fprintf(stderr, "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd);
+ DarwinListenOnOpenFD(launchd_fd);
+}
+
+static int create_socket(char *filename_out) {
+ struct sockaddr_un servaddr_un;
+ struct sockaddr *servaddr;
+ socklen_t servaddr_len;
+ int ret_fd;
+ size_t try, try_max;
+
+ for(try=0, try_max=5; try < try_max; try++) {
+ tmpnam(filename_out);
+
+ /* Setup servaddr_un */
+ memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
+ servaddr_un.sun_family = AF_UNIX;
+ strlcpy(servaddr_un.sun_path, filename_out, sizeof(servaddr_un.sun_path));
+
+ servaddr = (struct sockaddr *) &servaddr_un;
+ servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename_out);
+
+ ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
+ if(ret_fd == -1) {
+ fprintf(stderr, "X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno));
+ continue;
+ }
+
+ if(bind(ret_fd, servaddr, servaddr_len) != 0) {
+ fprintf(stderr, "X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno));
+ close(ret_fd);
+ return 0;
+ }
+
+ if(listen(ret_fd, 10) != 0) {
+ fprintf(stderr, "X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno));
+ close(ret_fd);
+ return 0;
+ }
+
+#ifdef DEBUG
+ fprintf(stderr, "X11.app: Listening on socket for fd handoff: (%d) %s\n", ret_fd, filename_out);
+#endif
+
+ return ret_fd;
+ }
+
+ return 0;
+}
+
+static int launchd_socket_handed_off = 0;
+
+kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename) {
+ socket_handoff_t *handoff_data;
+
+ launchd_socket_handed_off = 1;
+
+ handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t));
+ if(!handoff_data) {
+ fprintf(stderr, "X11.app: Error allocating memory for handoff_data\n");
+ return KERN_FAILURE;
+ }
+
+ handoff_data->fd = create_socket(handoff_data->filename);
+ if(!handoff_data->fd) {
+ free(handoff_data);
+ return KERN_FAILURE;
+ }
+
+ strlcpy(filename, handoff_data->filename, STRING_T_SIZE);
+
+ create_thread(socket_handoff_thread, handoff_data);
+
+#ifdef DEBUG
+ fprintf(stderr, "X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n");
+#endif
+
+ return KERN_SUCCESS;
+}
+
+kern_return_t do_request_pid(mach_port_t port, int *my_pid) {
+ *my_pid = getpid();
+ return KERN_SUCCESS;
+}
+
+/*** Server Startup ***/
+kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
+ mach_msg_type_number_t argvCnt,
+ string_array_t envp,
+ mach_msg_type_number_t envpCnt) {
+ /* And now back to char ** */
+ char **_argv = alloca((argvCnt + 1) * sizeof(char *));
+ char **_envp = alloca((envpCnt + 1) * sizeof(char *));
+ size_t i;
+
+ /* If we didn't get handed a launchd DISPLAY socket, we should
+ * unset DISPLAY or we can run into problems with pbproxy
+ */
+ if(!launchd_socket_handed_off) {
+ fprintf(stderr, "X11.app: No launchd socket handed off, unsetting DISPLAY\n");
+ unsetenv("DISPLAY");
+ }
+
+ if(!_argv || !_envp) {
+ return KERN_FAILURE;
+ }
+
+ fprintf(stderr, "X11.app: do_start_x11_server(): argc=%d\n", argvCnt);
+ for(i=0; i < argvCnt; i++) {
+ _argv[i] = argv[i];
+ fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
+ }
+ _argv[argvCnt] = NULL;
+
+ for(i=0; i < envpCnt; i++) {
+ _envp[i] = envp[i];
+ }
+ _envp[envpCnt] = NULL;
+
+ if(server_main(argvCnt, _argv, _envp) == 0)
+ return KERN_SUCCESS;
+ else
+ return KERN_FAILURE;
+}
+
+static int startup_trigger(int argc, char **argv, char **envp) {
+ Display *display;
+ const char *s;
+
+ /* Take care of the case where we're called like a normal DDX */
+ if(argc > 1 && argv[1][0] == ':') {
+ size_t i;
+ kern_return_t kr;
+ mach_port_t mp;
+ string_array_t newenvp;
+ string_array_t newargv;
+
+ /* We need to count envp */
+ int envpc;
+ for(envpc=0; envp[envpc]; envpc++);
+
+ /* We have fixed-size string lengths due to limitations in IPC,
+ * so we need to copy our argv and envp.
+ */
+ newargv = (string_array_t)alloca(argc * sizeof(string_t));
+ newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
+
+ if(!newargv || !newenvp) {
+ fprintf(stderr, "Memory allocation failure\n");
+ exit(EXIT_FAILURE);
+ }
+
+ for(i=0; i < argc; i++) {
+ strlcpy(newargv[i], argv[i], STRING_T_SIZE);
+ }
+ for(i=0; i < envpc; i++) {
+ strlcpy(newenvp[i], envp[i], STRING_T_SIZE);
+ }
+
+ kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
+ if (kr != KERN_SUCCESS) {
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ fprintf(stderr, "bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr));
+#else
+ fprintf(stderr, "bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr);
+#endif
+ exit(EXIT_FAILURE);
+ }
+
+ kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
+ if (kr != KERN_SUCCESS) {
+ fprintf(stderr, "start_x11_server: %s\n", mach_error_string(kr));
+ exit(EXIT_FAILURE);
+ }
+ exit(EXIT_SUCCESS);
+ }
+
+ /* If we have a process serial number and it's our only arg, act as if
+ * the user double clicked the app bundle: launch app_to_run if possible
+ */
+ if(argc == 1 || (argc == 2 && !strncmp(argv[1], "-psn_", 5))) {
+ /* Now, try to open a display, if so, run the launcher */
+ display = XOpenDisplay(NULL);
+ if(display) {
+ /* Could open the display, start the launcher */
+ XCloseDisplay(display);
+
+ return execute(command_from_prefs("app_to_run", DEFAULT_CLIENT));
+ }
+ }
+
+ /* Start the server */
+ if((s = getenv("DISPLAY"))) {
+ fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s);
+ unsetenv("DISPLAY");
+ } else {
+ fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
+ }
+ return execute(command_from_prefs("startx_script", DEFAULT_STARTX));
+}
+
+/** Setup the environment we want our child processes to inherit */
+static void ensure_path(const char *dir) {
+ char buf[1024], *temp;
+
+ /* Make sure /usr/X11/bin is in the $PATH */
+ temp = getenv("PATH");
+ if(temp == NULL || temp[0] == 0) {
+ snprintf(buf, sizeof(buf), "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s", dir);
+ setenv("PATH", buf, TRUE);
+ } else if(strnstr(temp, X11BINDIR, sizeof(temp)) == NULL) {
+ snprintf(buf, sizeof(buf), "%s:%s", temp, dir);
+ setenv("PATH", buf, TRUE);
+ }
+}
+
+static void setup_env(void) {
+ char *temp;
+ const char *pds = NULL;
+ const char *disp = getenv("DISPLAY");
+ size_t len;
+
+ /* Pass on our prefs domain to startx and its inheritors (mainly for
+ * quartz-wm and the Xquartz stub's MachIPC)
+ */
+ CFBundleRef bundle = CFBundleGetMainBundle();
+ if(bundle) {
+ CFStringRef pd = CFBundleGetIdentifier(bundle);
+ if(pd) {
+ pds = CFStringGetCStringPtr(pd, 0);
+ }
+ }
+
+ /* fallback to hardcoded value if we can't discover it */
+ if(!pds) {
+ pds = LAUNCHD_ID_PREFIX".X11";
+ }
+
+ server_bootstrap_name = malloc(sizeof(char) * (strlen(pds) + 1));
+ if(!server_bootstrap_name) {
+ fprintf(stderr, "X11.app: Memory allocation error.\n");
+ exit(1);
+ }
+ strcpy(server_bootstrap_name, pds);
+ setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1);
+
+ len = strlen(server_bootstrap_name);
+ launchd_id_prefix = malloc(sizeof(char) * (len - 3));
+ if(!launchd_id_prefix) {
+ fprintf(stderr, "X11.app: Memory allocation error.\n");
+ exit(1);
+ }
+ strlcpy(launchd_id_prefix, server_bootstrap_name, len - 3);
+
+ /* We need to unset DISPLAY if it is not our socket */
+ if(disp) {
+ /* s = basename(disp) */
+ const char *d, *s;
+ for(s = NULL, d = disp; *d; d++) {
+ if(*d == '/')
+ s = d + 1;
+ }
+
+ if(s && *s) {
+ if(strcmp(launchd_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) {
+ fprintf(stderr, "X11.app: Detected old style launchd DISPLAY, please update xinit.\n");
+ } else {
+ temp = (char *)malloc(sizeof(char) * len);
+ if(!temp) {
+ fprintf(stderr, "X11.app: Memory allocation error creating space for socket name test.\n");
+ exit(1);
+ }
+ strlcpy(temp, launchd_id_prefix, len);
+ strlcat(temp, ":0", len);
+
+ if(strcmp(temp, s) != 0) {
+ /* If we don't have a match, unset it. */
+ fprintf(stderr, "X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, launchd_id_prefix);
+ unsetenv("DISPLAY");
+ }
+ free(temp);
+ }
+ } else {
+ /* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */
+ fprintf(stderr, "X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n");
+ unsetenv("DISPLAY");
+ }
+ }
+
+ /* Make sure PATH is right */
+ ensure_path(X11BINDIR);
+
+ /* cd $HOME */
+ temp = getenv("HOME");
+ if(temp != NULL && temp[0] != '\0')
+ chdir(temp);
+}
+
+/*** Main ***/
+int main(int argc, char **argv, char **envp) {
+ Bool listenOnly = FALSE;
+ int i;
+ mach_msg_size_t mxmsgsz = sizeof(union MaxMsgSize) + MAX_TRAILER_SIZE;
+ mach_port_t mp;
+ kern_return_t kr;
+
+ /* Setup our environment for our children */
+ setup_env();
+
+ /* The server must not run the PanoramiX operations. */
+ noPanoramiXExtension = TRUE;
+
+ /* Setup the initial crasherporter info */
+ strlcpy(__crashreporter_info_buff__, __crashreporter_info__base, sizeof(__crashreporter_info_buff__));
+
+ fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
+ for(i=0; i < argc; i++) {
+ fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
+ if(!strcmp(argv[i], "--listenonly")) {
+ listenOnly = TRUE;
+ }
+ }
+
+ mp = checkin_or_register(server_bootstrap_name);
+ if(mp == MACH_PORT_NULL) {
+ fprintf(stderr, "NULL mach service: %s", server_bootstrap_name);
+ return EXIT_FAILURE;
+ }
+
+ /* Check if we need to do something other than listen, and make another
+ * thread handle it.
+ */
+ if(!listenOnly) {
+ pid_t child1, child2;
+ int status;
+
+ /* Do the fork-twice trick to avoid having to reap zombies */
+ child1 = fork();
+ switch (child1) {
+ case -1: /* error */
+ break;
+
+ case 0: /* child1 */
+ child2 = fork();
+
+ switch (child2) {
+ int max_files, i;
+
+ case -1: /* error */
+ break;
+
+ case 0: /* child2 */
+ /* close all open files except for standard streams */
+ max_files = sysconf(_SC_OPEN_MAX);
+ for(i = 3; i < max_files; i++)
+ close(i);
+
+ /* ensure stdin is on /dev/null */
+ close(0);
+ open("/dev/null", O_RDONLY);
+
+ return startup_trigger(argc, argv, envp);
+
+ default: /* parent (child1) */
+ _exit(0);
+ }
+ break;
+
+ default: /* parent */
+ waitpid(child1, &status, 0);
+ }
+ }
+
+ /* Main event loop */
+ fprintf(stderr, "Waiting for startup parameters via Mach IPC.\n");
+ kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
+ if (kr != KERN_SUCCESS) {
+ fprintf(stderr, "%s.X11(mp): %s\n", LAUNCHD_ID_PREFIX, mach_error_string(kr));
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
+
+static int execute(const char *command) {
+ const char *newargv[4];
+ const char **p;
+
+ newargv[0] = command_from_prefs("login_shell", DEFAULT_SHELL);
+ newargv[1] = "-c";
+ newargv[2] = command;
+ newargv[3] = NULL;
+
+ fprintf(stderr, "X11.app: Launching %s:\n", command);
+ for(p=newargv; *p; p++) {
+ fprintf(stderr, "\targv[%ld] = %s\n", (long int)(p - newargv), *p);
+ }
+
+ execvp (newargv[0], (char * const *) newargv);
+ perror ("X11.app: Couldn't exec.");
+ return 1;
+}
+
+static char *command_from_prefs(const char *key, const char *default_value) {
+ char *command = NULL;
+
+ CFStringRef cfKey;
+ CFPropertyListRef PlistRef;
+
+ if(!key)
+ return NULL;
+
+ cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII);
+
+ if(!cfKey)
+ return NULL;
+
+ PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
+
+ if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
+ CFStringRef cfDefaultValue = CFStringCreateWithCString(NULL, default_value, kCFStringEncodingASCII);
+ int len = strlen(default_value) + 1;
+
+ if(!cfDefaultValue)
+ goto command_from_prefs_out;
+
+ CFPreferencesSetAppValue(cfKey, cfDefaultValue, kCFPreferencesCurrentApplication);
+ CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+ CFRelease(cfDefaultValue);
+
+ command = (char *)malloc(len * sizeof(char));
+ if(!command)
+ goto command_from_prefs_out;
+ strcpy(command, default_value);
+ } else {
+ int len = CFStringGetLength((CFStringRef)PlistRef) + 1;
+ command = (char *)malloc(len * sizeof(char));
+ if(!command)
+ goto command_from_prefs_out;
+ CFStringGetCString((CFStringRef)PlistRef, command, len, kCFStringEncodingASCII);
+ }
+
+command_from_prefs_out:
+ if (PlistRef)
+ CFRelease(PlistRef);
+ if(cfKey)
+ CFRelease(cfKey);
+ return command;
+}
diff --git a/xorg-server/hw/xquartz/pseudoramiX.c b/xorg-server/hw/xquartz/pseudoramiX.c index 1a357528c..ded242d07 100644 --- a/xorg-server/hw/xquartz/pseudoramiX.c +++ b/xorg-server/hw/xquartz/pseudoramiX.c @@ -255,9 +255,9 @@ static int ProcPseudoramiXGetScreenSize(ClientPtr client) rep.sequenceNumber = client->sequence;
/* screen dimensions */
rep.width = pseudoramiXScreens[stuff->screen].w;
- // was panoramiXdataPtr[stuff->screen].width;
+ // was screenInfo.screens[stuff->screen]->width;
rep.height = pseudoramiXScreens[stuff->screen].h;
- // was panoramiXdataPtr[stuff->screen].height;
+ // was screenInfo.screens[stuff->screen]->height;
if (client->swapped) {
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
diff --git a/xorg-server/hw/xquartz/quartz.c b/xorg-server/hw/xquartz/quartz.c index e073b0586..c7a4d018a 100644 --- a/xorg-server/hw/xquartz/quartz.c +++ b/xorg-server/hw/xquartz/quartz.c @@ -73,8 +73,7 @@ int quartzUseAGL = 1; int quartzEnableKeyEquivalents = 1;
int quartzServerVisible = FALSE;
int quartzServerQuitting = FALSE;
-static int quartzScreenKeyIndex;
-DevPrivateKey quartzScreenKey = &quartzScreenKeyIndex;
+DevPrivateKeyRec quartzScreenKeyRec;
int aquaMenuBarHeight = 0;
QuartzModeProcsPtr quartzProcs = NULL;
const char *quartzOpenGLBundle = NULL;
@@ -167,6 +166,9 @@ void QuartzInitOutput( FatalError("Could not register block and wakeup handlers.");
}
+ if (!dixRegisterPrivateKey(&quartzScreenKeyRec, PRIVATE_SCREEN, 0))
+ FatalError("Failed to alloc quartz screen private.\n");
+
#if defined(RANDR) && !defined(FAKE_RANDR)
if(!QuartzRandRInit(pScreen))
FatalError("Failed to init RandR extension.\n");
@@ -259,8 +261,8 @@ void QuartzUpdateScreens(void) { PseudoramiXResetScreens();
quartzProcs->AddPseudoramiXScreens(&x, &y, &width, &height);
- dixScreenOrigins[pScreen->myNum].x = x;
- dixScreenOrigins[pScreen->myNum].y = y;
+ pScreen->x = x;
+ pScreen->y = y;
pScreen->mmWidth = pScreen->mmWidth * ((double) width / pScreen->width);
pScreen->mmHeight = pScreen->mmHeight * ((double) height / pScreen->height);
pScreen->width = width;
@@ -269,14 +271,14 @@ void QuartzUpdateScreens(void) { DarwinAdjustScreenOrigins(&screenInfo);
quartzProcs->UpdateScreen(pScreen);
- /* DarwinAdjustScreenOrigins or UpdateScreen may change dixScreenOrigins,
+ /* DarwinAdjustScreenOrigins or UpdateScreen may change pScreen->x/y,
* so use it rather than x/y
*/
- sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX;
- sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
+ sx = pScreen->x + darwinMainScreenX;
+ sy = pScreen->y + darwinMainScreenY;
/* Adjust the root window. */
- pRoot = WindowTable[pScreen->myNum];
+ pRoot = pScreen->root;
AppleWMSetScreenOrigin(pRoot);
pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
@@ -292,7 +294,7 @@ void QuartzUpdateScreens(void) { inputInfo.pointer->spriteInfo->sprite->physLimits = bounds;
inputInfo.pointer->spriteInfo->sprite->hotLimits = bounds;
- DEBUG_LOG("Root Window: %dx%d @ (%d, %d) darwinMainScreen (%d, %d) xy (%d, %d) dixScreenOrigins (%d, %d)\n", width, height, x - sx, y - sy, darwinMainScreenX, darwinMainScreenY, x, y, dixScreenOrigins[pScreen->myNum].x, dixScreenOrigins[pScreen->myNum].y);
+ DEBUG_LOG("Root Window: %dx%d @ (%d, %d) darwinMainScreen (%d, %d) xy (%d, %d) dixScreenOrigins (%d, %d)\n", width, height, x - sx, y - sy, darwinMainScreenX, darwinMainScreenY, x, y, pScreen->x, pScreen->y);
/* Send an event for the root reconfigure */
e.u.u.type = ConfigureNotify;
diff --git a/xorg-server/hw/xquartz/quartzCommon.h b/xorg-server/hw/xquartz/quartzCommon.h index 8ab70f22a..12ed4057e 100644 --- a/xorg-server/hw/xquartz/quartzCommon.h +++ b/xorg-server/hw/xquartz/quartzCommon.h @@ -1,85 +1,86 @@ -/* - * quartzCommon.h - * - * Common definitions used internally by all Quartz modes - * - * This file should be included before any X11 or IOKit headers - * so that it can avoid symbol conflicts. - * - * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker. - * 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. - */ - -#ifndef _QUARTZCOMMON_H -#define _QUARTZCOMMON_H - -#include <X11/Xdefs.h> -#include "privates.h" - -// Quartz specific per screen storage structure -typedef struct { - // List of CoreGraphics displays that this X11 screen covers. - // This is more than one CG display for video mirroring and - // rootless PseudoramiX mode. - // No CG display will be covered by more than one X11 screen. - int displayCount; - CGDirectDisplayID *displayIDs; -} QuartzScreenRec, *QuartzScreenPtr; - -#define QUARTZ_PRIV(pScreen) \ - ((QuartzScreenPtr)dixLookupPrivate(&pScreen->devPrivates, quartzScreenKey)) - -// Data stored at startup for Cocoa front end -extern int quartzEventWriteFD; - -// User preferences used by Quartz modes -extern int quartzUseSysBeep; -extern int focusOnNewWindow; -extern int quartzUseAGL; -extern int quartzEnableKeyEquivalents; -extern int quartzFullscreenDisableHotkeys; -extern int quartzOptionSendsAlt; - -// Other shared data -extern int quartzServerVisible; -extern int quartzServerQuitting; -extern DevPrivateKey quartzScreenKey; -extern int aquaMenuBarHeight; - -// Name of GLX bundle for native OpenGL -extern const char *quartzOpenGLBundle; - -void QuartzReadPreferences(void); -void QuartzMessageMainThread(unsigned msg, void *data, unsigned length); -void QuartzMessageServerThread(int type, int argc, ...); -void QuartzSetWindowMenu(int nitems, const char **items, - const char *shortcuts); -void QuartzFSCapture(void); -void QuartzFSRelease(void); -int QuartzFSUseQDCursor(int depth); -void QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask); -void QuartzWakeupHandler(pointer blockData, int result, pointer pReadmask); - -#endif /* _QUARTZCOMMON_H */ +/*
+ * quartzCommon.h
+ *
+ * Common definitions used internally by all Quartz modes
+ *
+ * This file should be included before any X11 or IOKit headers
+ * so that it can avoid symbol conflicts.
+ *
+ * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker.
+ * 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.
+ */
+
+#ifndef _QUARTZCOMMON_H
+#define _QUARTZCOMMON_H
+
+#include <X11/Xdefs.h>
+#include "privates.h"
+
+// Quartz specific per screen storage structure
+typedef struct {
+ // List of CoreGraphics displays that this X11 screen covers.
+ // This is more than one CG display for video mirroring and
+ // rootless PseudoramiX mode.
+ // No CG display will be covered by more than one X11 screen.
+ int displayCount;
+ CGDirectDisplayID *displayIDs;
+} QuartzScreenRec, *QuartzScreenPtr;
+
+#define QUARTZ_PRIV(pScreen) \
+ ((QuartzScreenPtr)dixLookupPrivate(&pScreen->devPrivates, quartzScreenKey))
+
+// Data stored at startup for Cocoa front end
+extern int quartzEventWriteFD;
+
+// User preferences used by Quartz modes
+extern int quartzUseSysBeep;
+extern int focusOnNewWindow;
+extern int quartzUseAGL;
+extern int quartzEnableKeyEquivalents;
+extern int quartzFullscreenDisableHotkeys;
+extern int quartzOptionSendsAlt;
+
+// Other shared data
+extern int quartzServerVisible;
+extern int quartzServerQuitting;
+extern DevPrivateKeyRec quartzScreenKeyRec;
+#define quartzScreenKey (&quartzScreenKeyRec)
+extern int aquaMenuBarHeight;
+
+// Name of GLX bundle for native OpenGL
+extern const char *quartzOpenGLBundle;
+
+void QuartzReadPreferences(void);
+void QuartzMessageMainThread(unsigned msg, void *data, unsigned length);
+void QuartzMessageServerThread(int type, int argc, ...);
+void QuartzSetWindowMenu(int nitems, const char **items,
+ const char *shortcuts);
+void QuartzFSCapture(void);
+void QuartzFSRelease(void);
+int QuartzFSUseQDCursor(int depth);
+void QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask);
+void QuartzWakeupHandler(pointer blockData, int result, pointer pReadmask);
+
+#endif /* _QUARTZCOMMON_H */
diff --git a/xorg-server/hw/xquartz/quartzKeyboard.c b/xorg-server/hw/xquartz/quartzKeyboard.c index 745333f03..8ea198cd5 100644 --- a/xorg-server/hw/xquartz/quartzKeyboard.c +++ b/xorg-server/hw/xquartz/quartzKeyboard.c @@ -1,850 +1,858 @@ -/* - quartzKeyboard.c: Keyboard support for Xquartz - - Copyright (c) 2003-2008 Apple Inc. - Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved. - Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved. - - Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com> - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "sanitizedCarbon.h" - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#define HACK_MISSING 1 -#define HACK_KEYPAD 1 -#define HACK_BLACKLIST 1 - -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> -#include <sys/stat.h> -#include <AvailabilityMacros.h> - -#include "quartzCommon.h" -#include "darwin.h" -#include "darwinEvents.h" - -#include "quartzKeyboard.h" -#include "quartzAudio.h" - -#include "X11Application.h" - -#include "threadSafety.h" - -#ifdef NDEBUG -#undef NDEBUG -#include <assert.h> -#define NDEBUG 1 -#else -#include <assert.h> -#endif -#include <pthread.h> - -#include "xkbsrv.h" -#include "exevents.h" -#include "X11/keysym.h" -#include "keysym2ucs.h" - -extern void -CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master); - -enum { - MOD_COMMAND = 256, - MOD_SHIFT = 512, - MOD_OPTION = 2048, - MOD_CONTROL = 4096, -}; - -#define UKEYSYM(u) ((u) | 0x01000000) - -#if HACK_MISSING -/* Table of keycode->keysym mappings we use to fallback on for important - keys that are often not in the Unicode mapping. */ - -const static struct { - unsigned short keycode; - KeySym keysym; -} known_keys[] = { - {55, XK_Meta_L}, - {56, XK_Shift_L}, - {57, XK_Caps_Lock}, - {58, XK_Alt_L}, - {59, XK_Control_L}, - - {60, XK_Shift_R}, - {61, XK_Alt_R}, - {62, XK_Control_R}, - {63, XK_Meta_R}, - - {122, XK_F1}, - {120, XK_F2}, - {99, XK_F3}, - {118, XK_F4}, - {96, XK_F5}, - {97, XK_F6}, - {98, XK_F7}, - {100, XK_F8}, - {101, XK_F9}, - {109, XK_F10}, - {103, XK_F11}, - {111, XK_F12}, - {105, XK_F13}, - {107, XK_F14}, - {113, XK_F15}, -}; -#endif - -#if HACK_KEYPAD -/* Table of keycode->old,new-keysym mappings we use to fixup the numeric - keypad entries. */ - -const static struct { - unsigned short keycode; - KeySym normal, keypad; -} known_numeric_keys[] = { - {65, XK_period, XK_KP_Decimal}, - {67, XK_asterisk, XK_KP_Multiply}, - {69, XK_plus, XK_KP_Add}, - {75, XK_slash, XK_KP_Divide}, - {76, 0x01000003, XK_KP_Enter}, - {78, XK_minus, XK_KP_Subtract}, - {81, XK_equal, XK_KP_Equal}, - {82, XK_0, XK_KP_0}, - {83, XK_1, XK_KP_1}, - {84, XK_2, XK_KP_2}, - {85, XK_3, XK_KP_3}, - {86, XK_4, XK_KP_4}, - {87, XK_5, XK_KP_5}, - {88, XK_6, XK_KP_6}, - {89, XK_7, XK_KP_7}, - {91, XK_8, XK_KP_8}, - {92, XK_9, XK_KP_9}, -}; -#endif - -#if HACK_BLACKLIST -/* <rdar://problem/7824370> wine notepad produces wrong characters on shift+arrow - * http://xquartz.macosforge.org/trac/ticket/295 - * http://developer.apple.com/legacy/mac/library/documentation/mac/Text/Text-579.html - * - * legacy Mac keycodes for arrow keys that shift-modify to math symbols - */ -const static unsigned short keycode_blacklist[] = {66, 70, 72, 77}; -#endif - -/* Table mapping normal keysyms to their dead equivalents. - FIXME: all the unicode keysyms (apart from circumflex) were guessed. */ - -const static struct { - KeySym normal, dead; -} dead_keys[] = { - {XK_grave, XK_dead_grave}, - {XK_apostrophe, XK_dead_acute}, /* US:"=" on a Czech keyboard */ - {XK_acute, XK_dead_acute}, - {UKEYSYM (0x384), XK_dead_acute}, /* US:";" on a Greek keyboard */ -// {XK_Greek_accentdieresis, XK_dead_diaeresis}, /* US:"opt+;" on a Greek keyboard ... replace with dead_accentdieresis if there is one */ - {XK_asciicircum, XK_dead_circumflex}, - {UKEYSYM (0x2c6), XK_dead_circumflex}, /* MODIFIER LETTER CIRCUMFLEX ACCENT */ - {XK_asciitilde, XK_dead_tilde}, - {UKEYSYM (0x2dc), XK_dead_tilde}, /* SMALL TILDE */ - {XK_macron, XK_dead_macron}, - {XK_breve, XK_dead_breve}, - {XK_abovedot, XK_dead_abovedot}, - {XK_diaeresis, XK_dead_diaeresis}, - {UKEYSYM (0x2da), XK_dead_abovering}, /* DOT ABOVE */ - {XK_doubleacute, XK_dead_doubleacute}, - {XK_caron, XK_dead_caron}, - {XK_cedilla, XK_dead_cedilla}, - {XK_ogonek, XK_dead_ogonek}, - {UKEYSYM (0x269), XK_dead_iota}, /* LATIN SMALL LETTER IOTA */ - {UKEYSYM (0x2ec), XK_dead_voiced_sound}, /* MODIFIER LETTER VOICING */ -/* {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */ - {UKEYSYM (0x323), XK_dead_belowdot}, /* COMBINING DOT BELOW */ - {UKEYSYM (0x309), XK_dead_hook}, /* COMBINING HOOK ABOVE */ - {UKEYSYM (0x31b), XK_dead_horn}, /* COMBINING HORN */ -}; - -typedef struct darwinKeyboardInfo_struct { - CARD8 modMap[MAP_LENGTH]; - KeySym keyMap[MAP_LENGTH * GLYPHS_PER_KEY]; - unsigned char modifierKeycodes[32][2]; -} darwinKeyboardInfo; - -darwinKeyboardInfo keyInfo; -pthread_mutex_t keyInfo_mutex = PTHREAD_MUTEX_INITIALIZER; - -static void DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl *ctrl) { - // FIXME: to be implemented - // keyclick, bell volume / pitch, autorepead, LED's -} - -//----------------------------------------------------------------------------- -// Utility functions to help parse Darwin keymap -//----------------------------------------------------------------------------- - -/* - * DarwinBuildModifierMaps - * Use the keyMap field of keyboard info structure to populate - * the modMap and modifierKeycodes fields. - */ -static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) { - int i; - KeySym *k; - - memset(info->modMap, NoSymbol, sizeof(info->modMap)); - memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes)); - - for (i = 0; i < NUM_KEYCODES; i++) { - k = info->keyMap + i * GLYPHS_PER_KEY; - - switch (*k) { - case XK_Shift_L: - info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i; - info->modMap[MIN_KEYCODE + i] = ShiftMask; - break; - - case XK_Shift_R: -#ifdef NX_MODIFIERKEY_RSHIFT - info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i; -#else - info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i; -#endif - info->modMap[MIN_KEYCODE + i] = ShiftMask; - break; - - case XK_Control_L: - info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i; - info->modMap[MIN_KEYCODE + i] = ControlMask; - break; - - case XK_Control_R: -#ifdef NX_MODIFIERKEY_RCONTROL - info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i; -#else - info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i; -#endif - info->modMap[MIN_KEYCODE + i] = ControlMask; - break; - - case XK_Caps_Lock: - info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i; - info->modMap[MIN_KEYCODE + i] = LockMask; - break; - - case XK_Alt_L: - info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i; - info->modMap[MIN_KEYCODE + i] = Mod1Mask; - if(!quartzOptionSendsAlt) - *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor. - break; - - case XK_Alt_R: -#ifdef NX_MODIFIERKEY_RALTERNATE - info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i; -#else - info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i; -#endif - if(!quartzOptionSendsAlt) - *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor. - info->modMap[MIN_KEYCODE + i] = Mod1Mask; - break; - - case XK_Mode_switch: - ErrorF("DarwinBuildModifierMaps: XK_Mode_switch encountered, unable to determine side.\n"); - info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i; -#ifdef NX_MODIFIERKEY_RALTERNATE - info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i; -#endif - info->modMap[MIN_KEYCODE + i] = Mod1Mask; - break; - - case XK_Meta_L: - info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i; - info->modMap[MIN_KEYCODE + i] = Mod2Mask; - break; - - case XK_Meta_R: -#ifdef NX_MODIFIERKEY_RCOMMAND - info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i; -#else - info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i; -#endif - info->modMap[MIN_KEYCODE + i] = Mod2Mask; - break; - - case XK_Num_Lock: - info->modMap[MIN_KEYCODE + i] = Mod3Mask; - break; - } - } -} - -/* - * DarwinKeyboardInit - * Get the Darwin keyboard map and compute an equivalent - * X keyboard map and modifier map. Set the new keyboard - * device structure. - */ -void DarwinKeyboardInit(DeviceIntPtr pDev) { - // Open a shared connection to the HID System. - // Note that the Event Status Driver is really just a wrapper - // for a kIOHIDParamConnectType connection. - assert(darwinParamConnect = NXOpenEventStatus()); - - InitKeyboardDeviceStruct(pDev, NULL, NULL, DarwinChangeKeyboardControl); - - DarwinKeyboardReloadHandler(); - - CopyKeyClass(pDev, inputInfo.keyboard); -} - -/* Set the repeat rates based on global preferences and keycodes for modifiers. - * Precondition: Has the keyInfo_mutex lock. - */ -static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue, int keyRepeatValue) { - if(initialKeyRepeatValue == 300000) { // off - /* Turn off repeats globally */ - XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOff); - } else { - int i; - XkbControlsPtr ctrl; - XkbControlsRec old; - - /* Turn on repeats globally */ - XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOn); - - /* Setup the bit mask for individual key repeats */ - ctrl = pDev->key->xkbInfo->desc->ctrls; - old= *ctrl; - - ctrl->repeat_delay = initialKeyRepeatValue * 15; - ctrl->repeat_interval = keyRepeatValue * 15; - - /* Turn off key-repeat for modifier keys, on for others */ - /* First set them all on */ - for(i=0; i < XkbPerKeyBitArraySize; i++) - ctrl->per_key_repeat[i] = -1; - - /* Now turn off the modifiers */ - for(i=0; i < 32; i++) { - unsigned char keycode; - - keycode = keyInfo.modifierKeycodes[i][0]; - if(keycode) - ClearBit(ctrl->per_key_repeat, keycode + MIN_KEYCODE); - - keycode = keyInfo.modifierKeycodes[i][1]; - if(keycode) - ClearBit(ctrl->per_key_repeat, keycode + MIN_KEYCODE); - } - - /* Hurray for data duplication */ - if (pDev->kbdfeed) - memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize); - - //fprintf(stderr, "per_key_repeat =\n"); - //for(i=0; i < XkbPerKeyBitArraySize; i++) - // fprintf(stderr, "%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n"); - - /* And now we notify the puppies about the changes */ - XkbDDXChangeControls(pDev, &old, ctrl); - } -} - -void DarwinKeyboardReloadHandler(void) { - KeySymsRec keySyms; - CFIndex initialKeyRepeatValue, keyRepeatValue; - BOOL ok; - DeviceIntPtr pDev; - const char *xmodmap = PROJECTROOT "/bin/xmodmap"; - const char *sysmodmap = PROJECTROOT "/lib/X11/xinit/.Xmodmap"; - const char *homedir = getenv("HOME"); - char usermodmap[PATH_MAX], cmd[PATH_MAX]; - - DEBUG_LOG("DarwinKeyboardReloadHandler\n"); - - /* Get our key repeat settings from GlobalPreferences */ - (void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences")); - - initialKeyRepeatValue = CFPreferencesGetAppIntegerValue(CFSTR("InitialKeyRepeat"), CFSTR(".GlobalPreferences"), &ok); - if(!ok) - initialKeyRepeatValue = 35; - - keyRepeatValue = CFPreferencesGetAppIntegerValue(CFSTR("KeyRepeat"), CFSTR(".GlobalPreferences"), &ok); - if(!ok) - keyRepeatValue = 6; - - pthread_mutex_lock(&keyInfo_mutex); { - /* Initialize our keySyms */ - keySyms.map = keyInfo.keyMap; - keySyms.mapWidth = GLYPHS_PER_KEY; - keySyms.minKeyCode = MIN_KEYCODE; - keySyms.maxKeyCode = MAX_KEYCODE; - - // TODO: We should build the entire XkbDescRec and use XkbCopyKeymap - /* Apply the mappings to darwinKeyboard */ - XkbApplyMappingChange(darwinKeyboard, &keySyms, keySyms.minKeyCode, - keySyms.maxKeyCode - keySyms.minKeyCode + 1, - keyInfo.modMap, serverClient); - DarwinKeyboardSetRepeat(darwinKeyboard, initialKeyRepeatValue, keyRepeatValue); - - /* Apply the mappings to the core keyboard */ - for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { - if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) { - XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode, - keySyms.maxKeyCode - keySyms.minKeyCode + 1, - keyInfo.modMap, serverClient); - DarwinKeyboardSetRepeat(pDev, initialKeyRepeatValue, keyRepeatValue); - } - } - } pthread_mutex_unlock(&keyInfo_mutex); - - /* Check for system .Xmodmap */ - if (access(xmodmap, F_OK) == 0) { - if (access(sysmodmap, F_OK) == 0) { - snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, sysmodmap); - X11ApplicationLaunchClient(cmd); - } - } - - /* Check for user's local .Xmodmap */ - if (homedir != NULL) { - snprintf (usermodmap, sizeof(usermodmap), "%s/.Xmodmap", homedir); - if (access(usermodmap, F_OK) == 0) { - snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, usermodmap); - X11ApplicationLaunchClient(cmd); - } - } -} - -//----------------------------------------------------------------------------- -// Modifier translation functions -// -// There are three different ways to specify a Mac modifier key: -// keycode - specifies hardware key, read from keymapping -// key - NX_MODIFIERKEY_*, really an index -// mask - NX_*MASK, mask for modifier flags in event record -// Left and right side have different keycodes but the same key and mask. -//----------------------------------------------------------------------------- - -/* - * DarwinModifierNXKeyToNXKeycode - * Return the keycode for an NX_MODIFIERKEY_* modifier. - * side = 0 for left or 1 for right. - * Returns 0 if key+side is not a known modifier. - */ -int DarwinModifierNXKeyToNXKeycode(int key, int side) { - int retval; - pthread_mutex_lock(&keyInfo_mutex); - retval = keyInfo.modifierKeycodes[key][side]; - pthread_mutex_unlock(&keyInfo_mutex); - - return retval; -} - -/* - * DarwinModifierNXKeycodeToNXKey - * Returns -1 if keycode+side is not a modifier key - * outSide may be NULL, else it gets 0 for left and 1 for right. - */ -int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) { - int key, side; - - keycode += MIN_KEYCODE; - - // search modifierKeycodes for this keycode+side - pthread_mutex_lock(&keyInfo_mutex); - for (key = 0; key < NX_NUMMODIFIERS; key++) { - for (side = 0; side <= 1; side++) { - if (keyInfo.modifierKeycodes[key][side] == keycode) break; - } - } - pthread_mutex_unlock(&keyInfo_mutex); - - if (key == NX_NUMMODIFIERS) { - return -1; - } - if (outSide) *outSide = side; - - return key; -} - -/* - * DarwinModifierNXMaskToNXKey - * Returns -1 if mask is not a known modifier mask. - */ -int DarwinModifierNXMaskToNXKey(int mask) { - switch (mask) { - case NX_ALPHASHIFTMASK: return NX_MODIFIERKEY_ALPHALOCK; - case NX_SHIFTMASK: return NX_MODIFIERKEY_SHIFT; -#ifdef NX_DEVICELSHIFTKEYMASK - case NX_DEVICELSHIFTKEYMASK: return NX_MODIFIERKEY_SHIFT; - case NX_DEVICERSHIFTKEYMASK: return NX_MODIFIERKEY_RSHIFT; -#endif - case NX_CONTROLMASK: return NX_MODIFIERKEY_CONTROL; -#ifdef NX_DEVICELCTLKEYMASK - case NX_DEVICELCTLKEYMASK: return NX_MODIFIERKEY_CONTROL; - case NX_DEVICERCTLKEYMASK: return NX_MODIFIERKEY_RCONTROL; -#endif - case NX_ALTERNATEMASK: return NX_MODIFIERKEY_ALTERNATE; -#ifdef NX_DEVICELALTKEYMASK - case NX_DEVICELALTKEYMASK: return NX_MODIFIERKEY_ALTERNATE; - case NX_DEVICERALTKEYMASK: return NX_MODIFIERKEY_RALTERNATE; -#endif - case NX_COMMANDMASK: return NX_MODIFIERKEY_COMMAND; -#ifdef NX_DEVICELCMDKEYMASK - case NX_DEVICELCMDKEYMASK: return NX_MODIFIERKEY_COMMAND; - case NX_DEVICERCMDKEYMASK: return NX_MODIFIERKEY_RCOMMAND; -#endif - case NX_NUMERICPADMASK: return NX_MODIFIERKEY_NUMERICPAD; - case NX_HELPMASK: return NX_MODIFIERKEY_HELP; - case NX_SECONDARYFNMASK: return NX_MODIFIERKEY_SECONDARYFN; - } - return -1; -} - -/* - * DarwinModifierNXKeyToNXMask - * Returns 0 if key is not a known modifier key. - */ -int DarwinModifierNXKeyToNXMask(int key) { - switch (key) { - case NX_MODIFIERKEY_ALPHALOCK: return NX_ALPHASHIFTMASK; -#ifdef NX_DEVICELSHIFTKEYMASK - case NX_MODIFIERKEY_SHIFT: return NX_DEVICELSHIFTKEYMASK; - case NX_MODIFIERKEY_RSHIFT: return NX_DEVICERSHIFTKEYMASK; - case NX_MODIFIERKEY_CONTROL: return NX_DEVICELCTLKEYMASK; - case NX_MODIFIERKEY_RCONTROL: return NX_DEVICERCTLKEYMASK; - case NX_MODIFIERKEY_ALTERNATE: return NX_DEVICELALTKEYMASK; - case NX_MODIFIERKEY_RALTERNATE: return NX_DEVICERALTKEYMASK; - case NX_MODIFIERKEY_COMMAND: return NX_DEVICELCMDKEYMASK; - case NX_MODIFIERKEY_RCOMMAND: return NX_DEVICERCMDKEYMASK; -#else - case NX_MODIFIERKEY_SHIFT: return NX_SHIFTMASK; - case NX_MODIFIERKEY_CONTROL: return NX_CONTROLMASK; - case NX_MODIFIERKEY_ALTERNATE: return NX_ALTERNATEMASK; - case NX_MODIFIERKEY_COMMAND: return NX_COMMANDMASK; -#endif - case NX_MODIFIERKEY_NUMERICPAD: return NX_NUMERICPADMASK; - case NX_MODIFIERKEY_HELP: return NX_HELPMASK; - case NX_MODIFIERKEY_SECONDARYFN: return NX_SECONDARYFNMASK; - } - return 0; -} - -/* - * DarwinModifierStringToNXMask - * Returns 0 if string is not a known modifier. - */ -int DarwinModifierStringToNXMask(const char *str, int separatelr) { -#ifdef NX_DEVICELSHIFTKEYMASK - if(separatelr) { - if (!strcasecmp(str, "shift")) return NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK; - if (!strcasecmp(str, "control")) return NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK; - if (!strcasecmp(str, "option")) return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK; - if (!strcasecmp(str, "alt")) return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK; - if (!strcasecmp(str, "command")) return NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK; - if (!strcasecmp(str, "lshift")) return NX_DEVICELSHIFTKEYMASK; - if (!strcasecmp(str, "rshift")) return NX_DEVICERSHIFTKEYMASK; - if (!strcasecmp(str, "lcontrol")) return NX_DEVICELCTLKEYMASK; - if (!strcasecmp(str, "rcontrol")) return NX_DEVICERCTLKEYMASK; - if (!strcasecmp(str, "loption")) return NX_DEVICELALTKEYMASK; - if (!strcasecmp(str, "roption")) return NX_DEVICERALTKEYMASK; - if (!strcasecmp(str, "lalt")) return NX_DEVICELALTKEYMASK; - if (!strcasecmp(str, "ralt")) return NX_DEVICERALTKEYMASK; - if (!strcasecmp(str, "lcommand")) return NX_DEVICELCMDKEYMASK; - if (!strcasecmp(str, "rcommand")) return NX_DEVICERCMDKEYMASK; - } else { -#endif - if (!strcasecmp(str, "shift")) return NX_SHIFTMASK; - if (!strcasecmp(str, "control")) return NX_CONTROLMASK; - if (!strcasecmp(str, "option")) return NX_ALTERNATEMASK; - if (!strcasecmp(str, "alt")) return NX_ALTERNATEMASK; - if (!strcasecmp(str, "command")) return NX_COMMANDMASK; - if (!strcasecmp(str, "lshift")) return NX_SHIFTMASK; - if (!strcasecmp(str, "rshift")) return NX_SHIFTMASK; - if (!strcasecmp(str, "lcontrol")) return NX_CONTROLMASK; - if (!strcasecmp(str, "rcontrol")) return NX_CONTROLMASK; - if (!strcasecmp(str, "loption")) return NX_ALTERNATEMASK; - if (!strcasecmp(str, "roption")) return NX_ALTERNATEMASK; - if (!strcasecmp(str, "lalt")) return NX_ALTERNATEMASK; - if (!strcasecmp(str, "ralt")) return NX_ALTERNATEMASK; - if (!strcasecmp(str, "lcommand")) return NX_COMMANDMASK; - if (!strcasecmp(str, "rcommand")) return NX_COMMANDMASK; -#ifdef NX_DEVICELSHIFTKEYMASK - } -#endif - if (!strcasecmp(str, "lock")) return NX_ALPHASHIFTMASK; - if (!strcasecmp(str, "fn")) return NX_SECONDARYFNMASK; - if (!strcasecmp(str, "help")) return NX_HELPMASK; - if (!strcasecmp(str, "numlock")) return NX_NUMERICPADMASK; - return 0; -} - -/* - * LegalModifier - * This allows the ddx layer to prevent some keys from being remapped - * as modifier keys. - */ -Bool LegalModifier(unsigned int key, DeviceIntPtr pDev) -{ - return 1; -} - -static inline UniChar macroman2ucs(unsigned char c) { - /* Precalculated table mapping MacRoman-128 to Unicode. Generated - by creating single element CFStringRefs then extracting the - first character. */ - - static const unsigned short table[128] = { - 0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1, - 0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8, - 0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3, - 0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc, - 0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6, 0xdf, - 0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6, 0xd8, - 0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202, 0x2211, - 0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6, 0xf8, - 0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206, 0xab, - 0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152, 0x153, - 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7, 0x25ca, - 0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02, - 0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca, 0xc1, - 0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4, - 0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc, - 0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7, - }; - - if (c < 128) return c; - else return table[c - 128]; -} - -static KeySym make_dead_key(KeySym in) { - int i; - - for (i = 0; i < sizeof (dead_keys) / sizeof (dead_keys[0]); i++) - if (dead_keys[i].normal == in) return dead_keys[i].dead; - - return in; -} - -static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) { -#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 - KeyboardLayoutRef key_layout; - int is_uchr = 1; -#endif - const void *chr_data = NULL; - int num_keycodes = NUM_KEYCODES; - UInt32 keyboard_type = LMGetKbdType(); - int i, j; - OSStatus err; - KeySym *k; - CFDataRef currentKeyLayoutDataRef = NULL; - -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 - TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource(); - - if (currentKeyLayoutRef) { - currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData); - if (currentKeyLayoutDataRef) - chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef); - } -#endif - -#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 - if (chr_data == NULL) { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 - ErrorF("X11.app: Error detected in determining keyboard layout. If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n"); - ErrorF("X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n", - (unsigned)keyboard_type, currentKeyLayoutRef, currentKeyLayoutDataRef, chr_data); -#endif - - KLGetCurrentKeyboardLayout (&key_layout); - KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data); - -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 - if(chr_data != NULL) { - ErrorF("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n"); - } -#endif - } - - if (chr_data == NULL) { - ErrorF("X11.app: Debug Info: kKLuchrData failed, trying kKLKCHRData.\n"); - ErrorF("If you are using a 3rd party keyboard layout, please see http://xquartz.macosforge.org/trac/ticket/154\n"); - KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data); - is_uchr = 0; - num_keycodes = 128; - -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 - if(chr_data != NULL) { - ErrorF("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n"); - } -#endif - } -#endif - -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 - if(currentKeyLayoutRef) - CFRelease(currentKeyLayoutRef); -#endif - - if (chr_data == NULL) { - ErrorF ( "Couldn't get uchr or kchr resource\n"); - return FALSE; - } - - /* Scan the keycode range for the Unicode character that each - key produces in the four shift states. Then convert that to - an X11 keysym (which may just the bit that says "this is - Unicode" if it can't find the real symbol.) */ - - /* KeyTranslate is not available on 64-bit platforms; UCKeyTranslate - must be used instead. */ - - for (i = 0; i < num_keycodes; i++) { - static const int mods[4] = {0, MOD_SHIFT, MOD_OPTION, - MOD_OPTION | MOD_SHIFT}; - - k = info->keyMap + i * GLYPHS_PER_KEY; - - for (j = 0; j < 4; j++) { -#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 - if (is_uchr) { -#endif - UniChar s[8]; - UniCharCount len; - UInt32 dead_key_state = 0, extra_dead = 0; - - err = UCKeyTranslate (chr_data, i, kUCKeyActionDown, - mods[j] >> 8, keyboard_type, 0, - &dead_key_state, 8, &len, s); - if (err != noErr) continue; - - if (len == 0 && dead_key_state != 0) { - /* Found a dead key. Work out which one it is, but - remembering that it's dead. */ - err = UCKeyTranslate (chr_data, i, kUCKeyActionDown, - mods[j] >> 8, keyboard_type, - kUCKeyTranslateNoDeadKeysMask, - &extra_dead, 8, &len, s); - if (err != noErr) continue; - } - - /* Not sure why 0x0010 is there. - * 0x0000 - <rdar://problem/7793566> 'Unicode Hex Input' ... - */ - if (len > 0 && s[0] != 0x0010 && s[0] != 0x0000) { - k[j] = ucs2keysym (s[0]); - if (dead_key_state != 0) k[j] = make_dead_key (k[j]); - } -#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 - } else { // kchr - UInt32 c, state = 0, state2 = 0; - UInt16 code; - - code = i | mods[j]; - c = KeyTranslate (chr_data, code, &state); - - /* Dead keys are only processed on key-down, so ask - to translate those events. When we find a dead key, - translating the matching key up event will give - us the actual dead character. */ - - if (state != 0) - c = KeyTranslate (chr_data, code | 128, &state2); - - /* Characters seem to be in MacRoman encoding. */ - - if (c != 0 && c != 0x0010) { - k[j] = ucs2keysym (macroman2ucs (c & 255)); - - if (state != 0) k[j] = make_dead_key (k[j]); - } - } -#endif - } - - if (k[3] == k[2]) k[3] = NoSymbol; - if (k[1] == k[0]) k[1] = NoSymbol; - if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol; - if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] = NoSymbol; - } - -#if HACK_MISSING - /* Fix up some things that are normally missing.. */ - - for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) { - k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY; - - if ( k[0] == NoSymbol && k[1] == NoSymbol - && k[2] == NoSymbol && k[3] == NoSymbol) - k[0] = known_keys[i].keysym; - } -#endif - -#if HACK_KEYPAD - /* And some more things. We find the right symbols for the numeric - keypad, but not the KP_ keysyms. So try to convert known keycodes. */ - for (i = 0; i < sizeof (known_numeric_keys) / sizeof (known_numeric_keys[0]); i++) { - k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY; - - if (k[0] == known_numeric_keys[i].normal) - k[0] = known_numeric_keys[i].keypad; - } -#endif - -#if HACK_BLACKLIST - for (i = 0; i < sizeof (keycode_blacklist) / sizeof (keycode_blacklist[0]); i++) { - k = info->keyMap + keycode_blacklist[i] * GLYPHS_PER_KEY; - k[0] = k[1] = k[2] = k[3] = NoSymbol; - } -#endif - - DarwinBuildModifierMaps(info); - - return TRUE; -} - -Bool QuartsResyncKeymap(Bool sendDDXEvent) { - Bool retval; - /* Update keyInfo */ - pthread_mutex_lock(&keyInfo_mutex); - memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap)); - retval = QuartzReadSystemKeymap(&keyInfo); - pthread_mutex_unlock(&keyInfo_mutex); - - /* Tell server thread to deal with new keyInfo */ - if(sendDDXEvent) - DarwinSendDDXEvent(kXquartzReloadKeymap, 0); - - return retval; -} +/*
+ quartzKeyboard.c: Keyboard support for Xquartz
+
+ Copyright (c) 2003-2008 Apple Inc.
+ Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+ Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+
+ Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "sanitizedCarbon.h"
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#define HACK_MISSING 1
+#define HACK_KEYPAD 1
+#define HACK_BLACKLIST 1
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <AvailabilityMacros.h>
+
+#include "quartzCommon.h"
+#include "darwin.h"
+#include "darwinEvents.h"
+
+#include "quartzKeyboard.h"
+#include "quartzAudio.h"
+
+#include "X11Application.h"
+
+#include "threadSafety.h"
+
+#ifdef NDEBUG
+#undef NDEBUG
+#include <assert.h>
+#define NDEBUG 1
+#else
+#include <assert.h>
+#endif
+#include <pthread.h>
+
+#include "xkbsrv.h"
+#include "exevents.h"
+#include "X11/keysym.h"
+#include "keysym2ucs.h"
+
+extern void
+CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master);
+
+enum {
+ MOD_COMMAND = 256,
+ MOD_SHIFT = 512,
+ MOD_OPTION = 2048,
+ MOD_CONTROL = 4096,
+};
+
+#define UKEYSYM(u) ((u) | 0x01000000)
+
+#if HACK_MISSING
+/* Table of keycode->keysym mappings we use to fallback on for important
+ keys that are often not in the Unicode mapping. */
+
+const static struct {
+ unsigned short keycode;
+ KeySym keysym;
+} known_keys[] = {
+ {55, XK_Meta_L},
+ {56, XK_Shift_L},
+ {57, XK_Caps_Lock},
+ {58, XK_Alt_L},
+ {59, XK_Control_L},
+
+ {60, XK_Shift_R},
+ {61, XK_Alt_R},
+ {62, XK_Control_R},
+ {63, XK_Meta_R},
+
+ {122, XK_F1},
+ {120, XK_F2},
+ {99, XK_F3},
+ {118, XK_F4},
+ {96, XK_F5},
+ {97, XK_F6},
+ {98, XK_F7},
+ {100, XK_F8},
+ {101, XK_F9},
+ {109, XK_F10},
+ {103, XK_F11},
+ {111, XK_F12},
+ {105, XK_F13},
+ {107, XK_F14},
+ {113, XK_F15},
+};
+#endif
+
+#if HACK_KEYPAD
+/* Table of keycode->old,new-keysym mappings we use to fixup the numeric
+ keypad entries. */
+
+const static struct {
+ unsigned short keycode;
+ KeySym normal, keypad;
+} known_numeric_keys[] = {
+ {65, XK_period, XK_KP_Decimal},
+ {67, XK_asterisk, XK_KP_Multiply},
+ {69, XK_plus, XK_KP_Add},
+ {75, XK_slash, XK_KP_Divide},
+ {76, 0x01000003, XK_KP_Enter},
+ {78, XK_minus, XK_KP_Subtract},
+ {81, XK_equal, XK_KP_Equal},
+ {82, XK_0, XK_KP_0},
+ {83, XK_1, XK_KP_1},
+ {84, XK_2, XK_KP_2},
+ {85, XK_3, XK_KP_3},
+ {86, XK_4, XK_KP_4},
+ {87, XK_5, XK_KP_5},
+ {88, XK_6, XK_KP_6},
+ {89, XK_7, XK_KP_7},
+ {91, XK_8, XK_KP_8},
+ {92, XK_9, XK_KP_9},
+};
+#endif
+
+#if HACK_BLACKLIST
+/* <rdar://problem/7824370> wine notepad produces wrong characters on shift+arrow
+ * http://xquartz.macosforge.org/trac/ticket/295
+ * http://developer.apple.com/legacy/mac/library/documentation/mac/Text/Text-579.html
+ *
+ * legacy Mac keycodes for arrow keys that shift-modify to math symbols
+ */
+const static unsigned short keycode_blacklist[] = {66, 70, 72, 77};
+#endif
+
+/* Table mapping normal keysyms to their dead equivalents.
+ FIXME: all the unicode keysyms (apart from circumflex) were guessed. */
+
+const static struct {
+ KeySym normal, dead;
+} dead_keys[] = {
+ {XK_grave, XK_dead_grave},
+ {XK_apostrophe, XK_dead_acute}, /* US:"=" on a Czech keyboard */
+ {XK_acute, XK_dead_acute},
+ {UKEYSYM (0x384), XK_dead_acute}, /* US:";" on a Greek keyboard */
+// {XK_Greek_accentdieresis, XK_dead_diaeresis}, /* US:"opt+;" on a Greek keyboard ... replace with dead_accentdieresis if there is one */
+ {XK_asciicircum, XK_dead_circumflex},
+ {UKEYSYM (0x2c6), XK_dead_circumflex}, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
+ {XK_asciitilde, XK_dead_tilde},
+ {UKEYSYM (0x2dc), XK_dead_tilde}, /* SMALL TILDE */
+ {XK_macron, XK_dead_macron},
+ {XK_breve, XK_dead_breve},
+ {XK_abovedot, XK_dead_abovedot},
+ {XK_diaeresis, XK_dead_diaeresis},
+ {UKEYSYM (0x2da), XK_dead_abovering}, /* DOT ABOVE */
+ {XK_doubleacute, XK_dead_doubleacute},
+ {XK_caron, XK_dead_caron},
+ {XK_cedilla, XK_dead_cedilla},
+ {XK_ogonek, XK_dead_ogonek},
+ {UKEYSYM (0x269), XK_dead_iota}, /* LATIN SMALL LETTER IOTA */
+ {UKEYSYM (0x2ec), XK_dead_voiced_sound}, /* MODIFIER LETTER VOICING */
+/* {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */
+ {UKEYSYM (0x323), XK_dead_belowdot}, /* COMBINING DOT BELOW */
+ {UKEYSYM (0x309), XK_dead_hook}, /* COMBINING HOOK ABOVE */
+ {UKEYSYM (0x31b), XK_dead_horn}, /* COMBINING HORN */
+};
+
+typedef struct darwinKeyboardInfo_struct {
+ CARD8 modMap[MAP_LENGTH];
+ KeySym keyMap[MAP_LENGTH * GLYPHS_PER_KEY];
+ unsigned char modifierKeycodes[32][2];
+} darwinKeyboardInfo;
+
+darwinKeyboardInfo keyInfo;
+pthread_mutex_t keyInfo_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static void DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl *ctrl) {
+ // FIXME: to be implemented
+ // keyclick, bell volume / pitch, autorepead, LED's
+}
+
+//-----------------------------------------------------------------------------
+// Utility functions to help parse Darwin keymap
+//-----------------------------------------------------------------------------
+
+/*
+ * DarwinBuildModifierMaps
+ * Use the keyMap field of keyboard info structure to populate
+ * the modMap and modifierKeycodes fields.
+ */
+static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
+ int i;
+ KeySym *k;
+
+ memset(info->modMap, NoSymbol, sizeof(info->modMap));
+ memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
+
+ for (i = 0; i < NUM_KEYCODES; i++) {
+ k = info->keyMap + i * GLYPHS_PER_KEY;
+
+ switch (*k) {
+ case XK_Shift_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+ info->modMap[MIN_KEYCODE + i] = ShiftMask;
+ break;
+
+ case XK_Shift_R:
+#ifdef NX_MODIFIERKEY_RSHIFT
+ info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+ info->modMap[MIN_KEYCODE + i] = ControlMask;
+ break;
+
+ case XK_Control_R:
+#ifdef NX_MODIFIERKEY_RCONTROL
+ info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i;
+ info->modMap[MIN_KEYCODE + i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ if(!quartzOptionSendsAlt)
+ *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+ break;
+
+ case XK_Alt_R:
+#ifdef NX_MODIFIERKEY_RALTERNATE
+ info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+#endif
+ if(!quartzOptionSendsAlt)
+ *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ break;
+
+ case XK_Mode_switch:
+ ErrorF("DarwinBuildModifierMaps: XK_Mode_switch encountered, unable to determine side.\n");
+ info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+#ifdef NX_MODIFIERKEY_RALTERNATE
+ info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ break;
+
+ case XK_Meta_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+ info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+ break;
+
+ case XK_Meta_R:
+#ifdef NX_MODIFIERKEY_RCOMMAND
+ info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+ break;
+
+ case XK_Num_Lock:
+ info->modMap[MIN_KEYCODE + i] = Mod3Mask;
+ break;
+ }
+ }
+}
+
+/*
+ * DarwinKeyboardInit
+ * Get the Darwin keyboard map and compute an equivalent
+ * X keyboard map and modifier map. Set the new keyboard
+ * device structure.
+ */
+void DarwinKeyboardInit(DeviceIntPtr pDev) {
+ // Open a shared connection to the HID System.
+ // Note that the Event Status Driver is really just a wrapper
+ // for a kIOHIDParamConnectType connection.
+ assert(darwinParamConnect = NXOpenEventStatus());
+
+ InitKeyboardDeviceStruct(pDev, NULL, NULL, DarwinChangeKeyboardControl);
+
+ DarwinKeyboardReloadHandler();
+
+ CopyKeyClass(pDev, inputInfo.keyboard);
+}
+
+/* Set the repeat rates based on global preferences and keycodes for modifiers.
+ * Precondition: Has the keyInfo_mutex lock.
+ */
+static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue, int keyRepeatValue) {
+ if(initialKeyRepeatValue == 300000) { // off
+ /* Turn off repeats globally */
+ XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOff);
+ } else {
+ int i;
+ XkbControlsPtr ctrl;
+ XkbControlsRec old;
+
+ /* Turn on repeats globally */
+ XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOn);
+
+ /* Setup the bit mask for individual key repeats */
+ ctrl = pDev->key->xkbInfo->desc->ctrls;
+ old= *ctrl;
+
+ ctrl->repeat_delay = initialKeyRepeatValue * 15;
+ ctrl->repeat_interval = keyRepeatValue * 15;
+
+ /* Turn off key-repeat for modifier keys, on for others */
+ /* First set them all on */
+ for(i=0; i < XkbPerKeyBitArraySize; i++)
+ ctrl->per_key_repeat[i] = -1;
+
+ /* Now turn off the modifiers */
+ for(i=0; i < 32; i++) {
+ unsigned char keycode;
+
+ keycode = keyInfo.modifierKeycodes[i][0];
+ if(keycode)
+ ClearBit(ctrl->per_key_repeat, keycode + MIN_KEYCODE);
+
+ keycode = keyInfo.modifierKeycodes[i][1];
+ if(keycode)
+ ClearBit(ctrl->per_key_repeat, keycode + MIN_KEYCODE);
+ }
+
+ /* Hurray for data duplication */
+ if (pDev->kbdfeed)
+ memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize);
+
+ //fprintf(stderr, "per_key_repeat =\n");
+ //for(i=0; i < XkbPerKeyBitArraySize; i++)
+ // fprintf(stderr, "%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n");
+
+ /* And now we notify the puppies about the changes */
+ XkbDDXChangeControls(pDev, &old, ctrl);
+ }
+}
+
+void DarwinKeyboardReloadHandler(void) {
+ KeySymsRec keySyms;
+ CFIndex initialKeyRepeatValue, keyRepeatValue;
+ BOOL ok;
+ DeviceIntPtr pDev;
+ const char *xmodmap = PROJECTROOT "/bin/xmodmap";
+ const char *sysmodmap = PROJECTROOT "/lib/X11/xinit/.Xmodmap";
+ const char *homedir = getenv("HOME");
+ char usermodmap[PATH_MAX], cmd[PATH_MAX];
+
+ DEBUG_LOG("DarwinKeyboardReloadHandler\n");
+
+ /* Get our key repeat settings from GlobalPreferences */
+ (void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
+
+ initialKeyRepeatValue = CFPreferencesGetAppIntegerValue(CFSTR("InitialKeyRepeat"), CFSTR(".GlobalPreferences"), &ok);
+ if(!ok)
+ initialKeyRepeatValue = 35;
+
+ keyRepeatValue = CFPreferencesGetAppIntegerValue(CFSTR("KeyRepeat"), CFSTR(".GlobalPreferences"), &ok);
+ if(!ok)
+ keyRepeatValue = 6;
+
+ pthread_mutex_lock(&keyInfo_mutex); {
+ /* Initialize our keySyms */
+ keySyms.map = keyInfo.keyMap;
+ keySyms.mapWidth = GLYPHS_PER_KEY;
+ keySyms.minKeyCode = MIN_KEYCODE;
+ keySyms.maxKeyCode = MAX_KEYCODE;
+
+ // TODO: We should build the entire XkbDescRec and use XkbCopyKeymap
+ /* Apply the mappings to darwinKeyboard */
+ XkbApplyMappingChange(darwinKeyboard, &keySyms, keySyms.minKeyCode,
+ keySyms.maxKeyCode - keySyms.minKeyCode + 1,
+ keyInfo.modMap, serverClient);
+ DarwinKeyboardSetRepeat(darwinKeyboard, initialKeyRepeatValue, keyRepeatValue);
+
+ /* Apply the mappings to the core keyboard */
+ for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
+ if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
+ XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode,
+ keySyms.maxKeyCode - keySyms.minKeyCode + 1,
+ keyInfo.modMap, serverClient);
+ DarwinKeyboardSetRepeat(pDev, initialKeyRepeatValue, keyRepeatValue);
+ }
+ }
+ } pthread_mutex_unlock(&keyInfo_mutex);
+
+ /* Modify with xmodmap */
+ if (access(xmodmap, F_OK) == 0) {
+ /* Check for system .Xmodmap */
+ if (access(sysmodmap, F_OK) == 0) {
+ if(snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, sysmodmap) < sizeof(cmd)) {
+ X11ApplicationLaunchClient(cmd);
+ } else {
+ ErrorF("X11.app: Unable to create / execute xmodmap command line");
+ }
+ }
+
+ /* Check for user's local .Xmodmap */
+ if ((homedir != NULL) && (snprintf (usermodmap, sizeof(usermodmap), "%s/.Xmodmap", homedir) < sizeof(usermodmap))) {
+ if (access(usermodmap, F_OK) == 0) {
+ if(snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, usermodmap) < sizeof(cmd)) {
+ X11ApplicationLaunchClient(cmd);
+ } else {
+ ErrorF("X11.app: Unable to create / execute xmodmap command line");
+ }
+ }
+ } else {
+ ErrorF("X11.app: Unable to determine path to user's .Xmodmap");
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Modifier translation functions
+//
+// There are three different ways to specify a Mac modifier key:
+// keycode - specifies hardware key, read from keymapping
+// key - NX_MODIFIERKEY_*, really an index
+// mask - NX_*MASK, mask for modifier flags in event record
+// Left and right side have different keycodes but the same key and mask.
+//-----------------------------------------------------------------------------
+
+/*
+ * DarwinModifierNXKeyToNXKeycode
+ * Return the keycode for an NX_MODIFIERKEY_* modifier.
+ * side = 0 for left or 1 for right.
+ * Returns 0 if key+side is not a known modifier.
+ */
+int DarwinModifierNXKeyToNXKeycode(int key, int side) {
+ int retval;
+ pthread_mutex_lock(&keyInfo_mutex);
+ retval = keyInfo.modifierKeycodes[key][side];
+ pthread_mutex_unlock(&keyInfo_mutex);
+
+ return retval;
+}
+
+/*
+ * DarwinModifierNXKeycodeToNXKey
+ * Returns -1 if keycode+side is not a modifier key
+ * outSide may be NULL, else it gets 0 for left and 1 for right.
+ */
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
+ int key, side;
+
+ keycode += MIN_KEYCODE;
+
+ // search modifierKeycodes for this keycode+side
+ pthread_mutex_lock(&keyInfo_mutex);
+ for (key = 0; key < NX_NUMMODIFIERS; key++) {
+ for (side = 0; side <= 1; side++) {
+ if (keyInfo.modifierKeycodes[key][side] == keycode) break;
+ }
+ }
+ pthread_mutex_unlock(&keyInfo_mutex);
+
+ if (key == NX_NUMMODIFIERS) {
+ return -1;
+ }
+ if (outSide) *outSide = side;
+
+ return key;
+}
+
+/*
+ * DarwinModifierNXMaskToNXKey
+ * Returns -1 if mask is not a known modifier mask.
+ */
+int DarwinModifierNXMaskToNXKey(int mask) {
+ switch (mask) {
+ case NX_ALPHASHIFTMASK: return NX_MODIFIERKEY_ALPHALOCK;
+ case NX_SHIFTMASK: return NX_MODIFIERKEY_SHIFT;
+#ifdef NX_DEVICELSHIFTKEYMASK
+ case NX_DEVICELSHIFTKEYMASK: return NX_MODIFIERKEY_SHIFT;
+ case NX_DEVICERSHIFTKEYMASK: return NX_MODIFIERKEY_RSHIFT;
+#endif
+ case NX_CONTROLMASK: return NX_MODIFIERKEY_CONTROL;
+#ifdef NX_DEVICELCTLKEYMASK
+ case NX_DEVICELCTLKEYMASK: return NX_MODIFIERKEY_CONTROL;
+ case NX_DEVICERCTLKEYMASK: return NX_MODIFIERKEY_RCONTROL;
+#endif
+ case NX_ALTERNATEMASK: return NX_MODIFIERKEY_ALTERNATE;
+#ifdef NX_DEVICELALTKEYMASK
+ case NX_DEVICELALTKEYMASK: return NX_MODIFIERKEY_ALTERNATE;
+ case NX_DEVICERALTKEYMASK: return NX_MODIFIERKEY_RALTERNATE;
+#endif
+ case NX_COMMANDMASK: return NX_MODIFIERKEY_COMMAND;
+#ifdef NX_DEVICELCMDKEYMASK
+ case NX_DEVICELCMDKEYMASK: return NX_MODIFIERKEY_COMMAND;
+ case NX_DEVICERCMDKEYMASK: return NX_MODIFIERKEY_RCOMMAND;
+#endif
+ case NX_NUMERICPADMASK: return NX_MODIFIERKEY_NUMERICPAD;
+ case NX_HELPMASK: return NX_MODIFIERKEY_HELP;
+ case NX_SECONDARYFNMASK: return NX_MODIFIERKEY_SECONDARYFN;
+ }
+ return -1;
+}
+
+/*
+ * DarwinModifierNXKeyToNXMask
+ * Returns 0 if key is not a known modifier key.
+ */
+int DarwinModifierNXKeyToNXMask(int key) {
+ switch (key) {
+ case NX_MODIFIERKEY_ALPHALOCK: return NX_ALPHASHIFTMASK;
+#ifdef NX_DEVICELSHIFTKEYMASK
+ case NX_MODIFIERKEY_SHIFT: return NX_DEVICELSHIFTKEYMASK;
+ case NX_MODIFIERKEY_RSHIFT: return NX_DEVICERSHIFTKEYMASK;
+ case NX_MODIFIERKEY_CONTROL: return NX_DEVICELCTLKEYMASK;
+ case NX_MODIFIERKEY_RCONTROL: return NX_DEVICERCTLKEYMASK;
+ case NX_MODIFIERKEY_ALTERNATE: return NX_DEVICELALTKEYMASK;
+ case NX_MODIFIERKEY_RALTERNATE: return NX_DEVICERALTKEYMASK;
+ case NX_MODIFIERKEY_COMMAND: return NX_DEVICELCMDKEYMASK;
+ case NX_MODIFIERKEY_RCOMMAND: return NX_DEVICERCMDKEYMASK;
+#else
+ case NX_MODIFIERKEY_SHIFT: return NX_SHIFTMASK;
+ case NX_MODIFIERKEY_CONTROL: return NX_CONTROLMASK;
+ case NX_MODIFIERKEY_ALTERNATE: return NX_ALTERNATEMASK;
+ case NX_MODIFIERKEY_COMMAND: return NX_COMMANDMASK;
+#endif
+ case NX_MODIFIERKEY_NUMERICPAD: return NX_NUMERICPADMASK;
+ case NX_MODIFIERKEY_HELP: return NX_HELPMASK;
+ case NX_MODIFIERKEY_SECONDARYFN: return NX_SECONDARYFNMASK;
+ }
+ return 0;
+}
+
+/*
+ * DarwinModifierStringToNXMask
+ * Returns 0 if string is not a known modifier.
+ */
+int DarwinModifierStringToNXMask(const char *str, int separatelr) {
+#ifdef NX_DEVICELSHIFTKEYMASK
+ if(separatelr) {
+ if (!strcasecmp(str, "shift")) return NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK;
+ if (!strcasecmp(str, "control")) return NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK;
+ if (!strcasecmp(str, "option")) return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str, "alt")) return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str, "command")) return NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK;
+ if (!strcasecmp(str, "lshift")) return NX_DEVICELSHIFTKEYMASK;
+ if (!strcasecmp(str, "rshift")) return NX_DEVICERSHIFTKEYMASK;
+ if (!strcasecmp(str, "lcontrol")) return NX_DEVICELCTLKEYMASK;
+ if (!strcasecmp(str, "rcontrol")) return NX_DEVICERCTLKEYMASK;
+ if (!strcasecmp(str, "loption")) return NX_DEVICELALTKEYMASK;
+ if (!strcasecmp(str, "roption")) return NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str, "lalt")) return NX_DEVICELALTKEYMASK;
+ if (!strcasecmp(str, "ralt")) return NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str, "lcommand")) return NX_DEVICELCMDKEYMASK;
+ if (!strcasecmp(str, "rcommand")) return NX_DEVICERCMDKEYMASK;
+ } else {
+#endif
+ if (!strcasecmp(str, "shift")) return NX_SHIFTMASK;
+ if (!strcasecmp(str, "control")) return NX_CONTROLMASK;
+ if (!strcasecmp(str, "option")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "alt")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "command")) return NX_COMMANDMASK;
+ if (!strcasecmp(str, "lshift")) return NX_SHIFTMASK;
+ if (!strcasecmp(str, "rshift")) return NX_SHIFTMASK;
+ if (!strcasecmp(str, "lcontrol")) return NX_CONTROLMASK;
+ if (!strcasecmp(str, "rcontrol")) return NX_CONTROLMASK;
+ if (!strcasecmp(str, "loption")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "roption")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "lalt")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "ralt")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "lcommand")) return NX_COMMANDMASK;
+ if (!strcasecmp(str, "rcommand")) return NX_COMMANDMASK;
+#ifdef NX_DEVICELSHIFTKEYMASK
+ }
+#endif
+ if (!strcasecmp(str, "lock")) return NX_ALPHASHIFTMASK;
+ if (!strcasecmp(str, "fn")) return NX_SECONDARYFNMASK;
+ if (!strcasecmp(str, "help")) return NX_HELPMASK;
+ if (!strcasecmp(str, "numlock")) return NX_NUMERICPADMASK;
+ return 0;
+}
+
+/*
+ * LegalModifier
+ * This allows the ddx layer to prevent some keys from being remapped
+ * as modifier keys.
+ */
+Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
+{
+ return 1;
+}
+
+static inline UniChar macroman2ucs(unsigned char c) {
+ /* Precalculated table mapping MacRoman-128 to Unicode. Generated
+ by creating single element CFStringRefs then extracting the
+ first character. */
+
+ static const unsigned short table[128] = {
+ 0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1,
+ 0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8,
+ 0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3,
+ 0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc,
+ 0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6, 0xdf,
+ 0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6, 0xd8,
+ 0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202, 0x2211,
+ 0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6, 0xf8,
+ 0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206, 0xab,
+ 0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152, 0x153,
+ 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7, 0x25ca,
+ 0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
+ 0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca, 0xc1,
+ 0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4,
+ 0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc,
+ 0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
+ };
+
+ if (c < 128) return c;
+ else return table[c - 128];
+}
+
+static KeySym make_dead_key(KeySym in) {
+ int i;
+
+ for (i = 0; i < sizeof (dead_keys) / sizeof (dead_keys[0]); i++)
+ if (dead_keys[i].normal == in) return dead_keys[i].dead;
+
+ return in;
+}
+
+static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
+#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+ KeyboardLayoutRef key_layout;
+ int is_uchr = 1;
+#endif
+ const void *chr_data = NULL;
+ int num_keycodes = NUM_KEYCODES;
+ UInt32 keyboard_type = LMGetKbdType();
+ int i, j;
+ OSStatus err;
+ KeySym *k;
+ CFDataRef currentKeyLayoutDataRef = NULL;
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
+
+ if (currentKeyLayoutRef) {
+ currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
+ if (currentKeyLayoutDataRef)
+ chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
+ }
+#endif
+
+#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+ if (chr_data == NULL) {
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ ErrorF("X11.app: Error detected in determining keyboard layout. If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n");
+ ErrorF("X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
+ (unsigned)keyboard_type, currentKeyLayoutRef, currentKeyLayoutDataRef, chr_data);
+#endif
+
+ KLGetCurrentKeyboardLayout (&key_layout);
+ KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ if(chr_data != NULL) {
+ ErrorF("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
+ }
+#endif
+ }
+
+ if (chr_data == NULL) {
+ ErrorF("X11.app: Debug Info: kKLuchrData failed, trying kKLKCHRData.\n");
+ ErrorF("If you are using a 3rd party keyboard layout, please see http://xquartz.macosforge.org/trac/ticket/154\n");
+ KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
+ is_uchr = 0;
+ num_keycodes = 128;
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ if(chr_data != NULL) {
+ ErrorF("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
+ }
+#endif
+ }
+#endif
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ if(currentKeyLayoutRef)
+ CFRelease(currentKeyLayoutRef);
+#endif
+
+ if (chr_data == NULL) {
+ ErrorF ( "Couldn't get uchr or kchr resource\n");
+ return FALSE;
+ }
+
+ /* Scan the keycode range for the Unicode character that each
+ key produces in the four shift states. Then convert that to
+ an X11 keysym (which may just the bit that says "this is
+ Unicode" if it can't find the real symbol.) */
+
+ /* KeyTranslate is not available on 64-bit platforms; UCKeyTranslate
+ must be used instead. */
+
+ for (i = 0; i < num_keycodes; i++) {
+ static const int mods[4] = {0, MOD_SHIFT, MOD_OPTION,
+ MOD_OPTION | MOD_SHIFT};
+
+ k = info->keyMap + i * GLYPHS_PER_KEY;
+
+ for (j = 0; j < 4; j++) {
+#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+ if (is_uchr) {
+#endif
+ UniChar s[8];
+ UniCharCount len;
+ UInt32 dead_key_state = 0, extra_dead = 0;
+
+ err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
+ mods[j] >> 8, keyboard_type, 0,
+ &dead_key_state, 8, &len, s);
+ if (err != noErr) continue;
+
+ if (len == 0 && dead_key_state != 0) {
+ /* Found a dead key. Work out which one it is, but
+ remembering that it's dead. */
+ err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
+ mods[j] >> 8, keyboard_type,
+ kUCKeyTranslateNoDeadKeysMask,
+ &extra_dead, 8, &len, s);
+ if (err != noErr) continue;
+ }
+
+ /* Not sure why 0x0010 is there.
+ * 0x0000 - <rdar://problem/7793566> 'Unicode Hex Input' ...
+ */
+ if (len > 0 && s[0] != 0x0010 && s[0] != 0x0000) {
+ k[j] = ucs2keysym (s[0]);
+ if (dead_key_state != 0) k[j] = make_dead_key (k[j]);
+ }
+#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+ } else { // kchr
+ UInt32 c, state = 0, state2 = 0;
+ UInt16 code;
+
+ code = i | mods[j];
+ c = KeyTranslate (chr_data, code, &state);
+
+ /* Dead keys are only processed on key-down, so ask
+ to translate those events. When we find a dead key,
+ translating the matching key up event will give
+ us the actual dead character. */
+
+ if (state != 0)
+ c = KeyTranslate (chr_data, code | 128, &state2);
+
+ /* Characters seem to be in MacRoman encoding. */
+
+ if (c != 0 && c != 0x0010) {
+ k[j] = ucs2keysym (macroman2ucs (c & 255));
+
+ if (state != 0) k[j] = make_dead_key (k[j]);
+ }
+ }
+#endif
+ }
+
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+ if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] = NoSymbol;
+ }
+
+#if HACK_MISSING
+ /* Fix up some things that are normally missing.. */
+
+ for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) {
+ k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
+
+ if ( k[0] == NoSymbol && k[1] == NoSymbol
+ && k[2] == NoSymbol && k[3] == NoSymbol)
+ k[0] = known_keys[i].keysym;
+ }
+#endif
+
+#if HACK_KEYPAD
+ /* And some more things. We find the right symbols for the numeric
+ keypad, but not the KP_ keysyms. So try to convert known keycodes. */
+ for (i = 0; i < sizeof (known_numeric_keys) / sizeof (known_numeric_keys[0]); i++) {
+ k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
+
+ if (k[0] == known_numeric_keys[i].normal)
+ k[0] = known_numeric_keys[i].keypad;
+ }
+#endif
+
+#if HACK_BLACKLIST
+ for (i = 0; i < sizeof (keycode_blacklist) / sizeof (keycode_blacklist[0]); i++) {
+ k = info->keyMap + keycode_blacklist[i] * GLYPHS_PER_KEY;
+ k[0] = k[1] = k[2] = k[3] = NoSymbol;
+ }
+#endif
+
+ DarwinBuildModifierMaps(info);
+
+ return TRUE;
+}
+
+Bool QuartsResyncKeymap(Bool sendDDXEvent) {
+ Bool retval;
+ /* Update keyInfo */
+ pthread_mutex_lock(&keyInfo_mutex);
+ memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
+ retval = QuartzReadSystemKeymap(&keyInfo);
+ pthread_mutex_unlock(&keyInfo_mutex);
+
+ /* Tell server thread to deal with new keyInfo */
+ if(sendDDXEvent)
+ DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
+
+ return retval;
+}
diff --git a/xorg-server/hw/xquartz/xpr/dri.c b/xorg-server/hw/xquartz/xpr/dri.c index 363809d0d..252c2bb4c 100644 --- a/xorg-server/hw/xquartz/xpr/dri.c +++ b/xorg-server/hw/xquartz/xpr/dri.c @@ -74,14 +74,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <AvailabilityMacros.h>
-static int DRIScreenPrivKeyIndex;
-static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKeyIndex;
-static int DRIWindowPrivKeyIndex;
-static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKeyIndex;
-static int DRIPixmapPrivKeyIndex;
-static DevPrivateKey DRIPixmapPrivKey = &DRIPixmapPrivKeyIndex;
-static int DRIPixmapBufferPrivKeyIndex;
-static DevPrivateKey DRIPixmapBufferPrivKey = &DRIPixmapBufferPrivKeyIndex;
+static DevPrivateKeyRec DRIScreenPrivKeyRec;
+#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
+static DevPrivateKeyRec DRIWindowPrivKeyRec;
+#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
+static DevPrivateKeyRec DRIPixmapPrivKeyRec;
+#define DRIPixmapPrivKey (&DRIPixmapPrivKeyRec)
+static DevPrivateKeyRec DRIPixmapBufferPrivKeyRec;
+#define DRIPixmapBufferPrivKey (&DRIPixmapBufferPrivKeyRec)
static RESTYPE DRIDrawablePrivResType;
@@ -205,6 +205,15 @@ DRIScreenInit(ScreenPtr pScreen) DRIScreenPrivPtr pDRIPriv;
int i;
+ if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&DRIPixmapPrivKeyRec, PRIVATE_PIXMAP, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&DRIPixmapBufferPrivKeyRec, PRIVATE_PIXMAP, 0))
+ return FALSE;
+
pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
@@ -280,7 +289,7 @@ DRIExtensionInit(void) DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete,
"DRIDrawable");
- return (DRIDrawablePrivResType != 0);
+ return DRIDrawablePrivResType != 0;
}
void
@@ -347,8 +356,8 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw) wc.height = pWin->drawable.height + 2 * pWin->borderWidth;
wc.bit_gravity = XP_GRAVITY_NONE;
- wc.shape_nrects = REGION_NUM_RECTS(&pWin->clipList);
- wc.shape_rects = REGION_RECTS(&pWin->clipList);
+ wc.shape_nrects = RegionNumRects(&pWin->clipList);
+ wc.shape_rects = RegionRects(&pWin->clipList);
wc.shape_tx = - (pTopWin->drawable.x - pTopWin->borderWidth);
wc.shape_ty = - (pTopWin->drawable.y - pTopWin->borderWidth);
diff --git a/xorg-server/hw/xquartz/xpr/driWrap.c b/xorg-server/hw/xquartz/xpr/driWrap.c index 2e23cbbf5..37cb8cf5a 100644 --- a/xorg-server/hw/xquartz/xpr/driWrap.c +++ b/xorg-server/hw/xquartz/xpr/driWrap.c @@ -55,11 +55,11 @@ typedef struct { DevUnion devPrivate;
} DRISavedDrawableState;
-static int driGCKeyIndex;
-static DevPrivateKey driGCKey = &driGCKeyIndex;
+static DevPrivateKeyRec driGCKeyRec;
+#define driGCKey (&driGCKeyRec)
-static int driWrapScreenKeyIndex;
-static DevPrivateKey driWrapScreenKey = &driWrapScreenKeyIndex;
+static DevPrivateKeyRec driWrapScreenKeyRec;
+#define driWrapScreenKey (&driWrapScreenKeyRec)
static GCOps driGCOps;
@@ -527,21 +527,15 @@ Bool DRIWrapInit(ScreenPtr pScreen) {
DRIWrapScreenRec *pScreenPriv;
- if(!dixRequestPrivate(driGCKey, sizeof(DRIGCRec)))
+ if(!dixRegisterPrivateKey(&driGCKeyRec, PRIVATE_GC, sizeof(DRIGCRec)))
return FALSE;
- if(!dixRequestPrivate(driWrapScreenKey, sizeof(DRIWrapScreenRec)))
- return FALSE;
-
- pScreenPriv = malloc(sizeof(*pScreenPriv));
-
- if(NULL == pScreenPriv)
+ if(!dixRegisterPrivateKey(&driWrapScreenKeyRec, PRIVATE_SCREEN, sizeof(DRIWrapScreenRec)))
return FALSE;
+ pScreenPriv = dixGetPrivateAddr(&pScreen->devPrivates, &driWrapScreenKeyRec);
pScreenPriv->CreateGC = pScreen->CreateGC;
pScreen->CreateGC = DRICreateGC;
- dixSetPrivate(&pScreen->devPrivates, driWrapScreenKey, pScreenPriv);
-
return TRUE;
}
diff --git a/xorg-server/hw/xquartz/xpr/xprCursor.c b/xorg-server/hw/xquartz/xpr/xprCursor.c index df9eef95e..9c7890647 100644 --- a/xorg-server/hw/xquartz/xpr/xprCursor.c +++ b/xorg-server/hw/xquartz/xpr/xprCursor.c @@ -57,13 +57,12 @@ typedef struct { miPointerSpriteFuncPtr spriteFuncs;
} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
-static int darwinCursorScreenKeyIndex;
-static DevPrivateKey darwinCursorScreenKey = &darwinCursorScreenKeyIndex;
+static DevPrivateKeyRec darwinCursorScreenKeyRec;
+#define darwinCursorScreenKey (&darwinCursorScreenKeyRec)
#define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \
dixLookupPrivate(&pScreen->devPrivates, darwinCursorScreenKey))
-
static Bool
load_cursor(CursorPtr src, int screen)
{
@@ -296,8 +295,8 @@ QuartzWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) {
int sx, sy;
- sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX;
- sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
+ sx = pScreen->x + darwinMainScreenX;
+ sy = pScreen->y + darwinMainScreenY;
CGWarpMouseCursorPosition(CGPointMake(sx + x, sy + y));
}
@@ -360,6 +359,9 @@ QuartzInitCursor(ScreenPtr pScreen) if (!miDCInitialize(pScreen, &quartzScreenFuncsRec))
return FALSE;
+ if (!dixRegisterPrivateKey(&darwinCursorScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
ScreenPriv = calloc(1, sizeof(QuartzCursorScreenRec));
if (ScreenPriv == NULL)
return FALSE;
diff --git a/xorg-server/hw/xquartz/xpr/xprFrame.c b/xorg-server/hw/xquartz/xpr/xprFrame.c index 53dde7acc..52925339f 100644 --- a/xorg-server/hw/xquartz/xpr/xprFrame.c +++ b/xorg-server/hw/xquartz/xpr/xprFrame.c @@ -1,640 +1,640 @@ -/* - * Xplugin rootless implementation frame functions - * - * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. - * Copyright (c) 2003 Torrey T. Lyons. 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 - -#include "xpr.h" -#include "rootlessCommon.h" -#include <Xplugin.h> -#include "x-hash.h" -#include "x-list.h" -#include "applewmExt.h" - -#include "propertyst.h" -#include "dix.h" -#include <X11/Xatom.h> -#include "windowstr.h" -#include "quartz.h" - -#include "threadSafety.h" - -#include <pthread.h> - -#define DEFINE_ATOM_HELPER(func,atom_name) \ -static Atom func (void) { \ - static int generation; \ - static Atom atom; \ - if (generation != serverGeneration) { \ - generation = serverGeneration; \ - atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \ - } \ - return atom; \ -} - -DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID") - -/* Maps xp_window_id -> RootlessWindowRec */ -static x_hash_table *window_hash; -static pthread_mutex_t window_hash_mutex; - -/* Prototypes for static functions */ -static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, - int newX, int newY, RegionPtr pShape); -static void xprDestroyFrame(RootlessFrameID wid); -static void xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY); -static void xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, - int newX, int newY, unsigned int newW, unsigned int newH, - unsigned int gravity); -static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid); -static void xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape); -static void xprUnmapFrame(RootlessFrameID wid); -static void xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow); -static void xprStopDrawing(RootlessFrameID wid, Bool flush); -static void xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage); -static void xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects, - int shift_x, int shift_y); -static void xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin); -static Bool xprDoReorderWindow(RootlessWindowPtr pFrame); -static void xprHideWindow(RootlessFrameID wid); -static void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen); -static void xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects, - int dx, int dy); - - -static inline xp_error -xprConfigureWindow(xp_window_id id, unsigned int mask, - const xp_window_changes *values) -{ - TA_SERVER(); - - return xp_configure_window(id, mask, values); -} - - -static void -xprSetNativeProperty(RootlessWindowPtr pFrame) -{ - xp_error err; - unsigned int native_id; - long data; - - TA_SERVER(); - - err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id); - if (err == Success) - { - /* FIXME: move this to AppleWM extension */ - - data = native_id; - dixChangeWindowProperty(serverClient, pFrame->win, xa_native_window_id(), - XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE); - } -} - -static xp_error -xprColormapCallback(void *data, int first_color, int n_colors, uint32_t *colors) -{ - return (RootlessResolveColormap (data, first_color, n_colors, colors) ? XP_Success : XP_BadMatch); -} - -/* - * Create and display a new frame. - */ -static Bool -xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, - int newX, int newY, RegionPtr pShape) -{ - WindowPtr pWin = pFrame->win; - xp_window_changes wc; - unsigned int mask = 0; - xp_error err; - - TA_SERVER(); - - wc.x = newX; - wc.y = newY; - wc.width = pFrame->width; - wc.height = pFrame->height; - wc.bit_gravity = XP_GRAVITY_NONE; - mask |= XP_BOUNDS; - - if (pWin->drawable.depth == 8) - { - wc.depth = XP_DEPTH_INDEX8; - wc.colormap = xprColormapCallback; - wc.colormap_data = pScreen; - mask |= XP_COLORMAP; - } - else if (pWin->drawable.depth == 15) - wc.depth = XP_DEPTH_RGB555; - else if (pWin->drawable.depth == 24) - wc.depth = XP_DEPTH_ARGB8888; - else - wc.depth = XP_DEPTH_NIL; - mask |= XP_DEPTH; - - if (pShape != NULL) - { - wc.shape_nrects = REGION_NUM_RECTS(pShape); - wc.shape_rects = REGION_RECTS(pShape); - wc.shape_tx = wc.shape_ty = 0; - mask |= XP_SHAPE; - } - - pFrame->level = !IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels; - - if(quartzEnableRootless) - wc.window_level = normal_window_levels[pFrame->level]; - else - wc.window_level = rooted_window_levels[pFrame->level]; - mask |= XP_WINDOW_LEVEL; - - err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid); - - if (err != Success) - { - return FALSE; - } - - if (window_hash == NULL) - { - window_hash = x_hash_table_new(NULL, NULL, NULL, NULL); - pthread_mutex_init(&window_hash_mutex, NULL); - } - - pthread_mutex_lock(&window_hash_mutex); - x_hash_table_insert(window_hash, pFrame->wid, pFrame); - pthread_mutex_unlock(&window_hash_mutex); - - xprSetNativeProperty(pFrame); - - return TRUE; -} - - -/* - * Destroy a frame. - */ -static void -xprDestroyFrame(RootlessFrameID wid) -{ - TA_SERVER(); - - pthread_mutex_lock(&window_hash_mutex); - x_hash_table_remove(window_hash, wid); - pthread_mutex_unlock(&window_hash_mutex); - - xp_destroy_window(x_cvt_vptr_to_uint(wid)); -} - - -/* - * Move a frame on screen. - */ -static void -xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY) -{ - xp_window_changes wc; - - TA_SERVER(); - - wc.x = newX; - wc.y = newY; - // ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY); - xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_ORIGIN, &wc); -} - - -/* - * Resize and move a frame. - */ -static void -xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, - int newX, int newY, unsigned int newW, unsigned int newH, - unsigned int gravity) -{ - xp_window_changes wc; - - TA_SERVER(); - - wc.x = newX; - wc.y = newY; - wc.width = newW; - wc.height = newH; - wc.bit_gravity = gravity; - - /* It's unlikely that being async will save us anything here. - But it can't hurt. */ - - xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_BOUNDS, &wc); -} - - -/* - * Change frame stacking. - */ -static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) { - xp_window_changes wc; - unsigned int mask = XP_STACKING; - - TA_SERVER(); - - /* Stack frame below nextWid it if it exists, or raise - frame above everything otherwise. */ - - if(nextWid == NULL) { - wc.stack_mode = XP_MAPPED_ABOVE; - wc.sibling = 0; - } else { - wc.stack_mode = XP_MAPPED_BELOW; - wc.sibling = x_cvt_vptr_to_uint(nextWid); - } - - if(window_hash) { - RootlessWindowRec *winRec = x_hash_table_lookup(window_hash, wid, NULL); - - if(winRec) { - if(quartzEnableRootless) - wc.window_level = normal_window_levels[winRec->level]; - else - wc.window_level = rooted_window_levels[winRec->level]; - mask |= XP_WINDOW_LEVEL; - } - } - - xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc); -} - - -/* - * Change the frame's shape. - */ -static void -xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape) -{ - xp_window_changes wc; - - TA_SERVER(); - - if (pShape != NULL) - { - wc.shape_nrects = REGION_NUM_RECTS(pShape); - wc.shape_rects = REGION_RECTS(pShape); - } - else - { - wc.shape_nrects = -1; - wc.shape_rects = NULL; - } - - wc.shape_tx = wc.shape_ty = 0; - - xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_SHAPE, &wc); -} - - -/* - * Unmap a frame. - */ -static void -xprUnmapFrame(RootlessFrameID wid) -{ - xp_window_changes wc; - - TA_SERVER(); - - wc.stack_mode = XP_UNMAPPED; - wc.sibling = 0; - - xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_STACKING, &wc); -} - - -/* - * Start drawing to a frame. - * Prepare for direct access to its backing buffer. - */ -static void -xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow) -{ - void *data[2]; - unsigned int rowbytes[2]; - xp_error err; - - TA_SERVER(); - - err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, NULL); - if (err != Success) - FatalError("Could not lock window %i for drawing.", (int)x_cvt_vptr_to_uint(wid)); - - *pixelData = data[0]; - *bytesPerRow = rowbytes[0]; -} - - -/* - * Stop drawing to a frame. - */ -static void -xprStopDrawing(RootlessFrameID wid, Bool flush) -{ - TA_SERVER(); - - xp_unlock_window(x_cvt_vptr_to_uint(wid), flush); -} - - -/* - * Flush drawing updates to the screen. - */ -static void -xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage) -{ - TA_SERVER(); - - xp_flush_window(x_cvt_vptr_to_uint(wid)); -} - - -/* - * Mark damaged rectangles as requiring redisplay to screen. - */ -static void -xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects, - int shift_x, int shift_y) -{ - TA_SERVER(); - - xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y); -} - - -/* - * Called after the window associated with a frame has been switched - * to a new top-level parent. - */ -static void -xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin) -{ - DeleteProperty(serverClient, oldWin, xa_native_window_id()); - - TA_SERVER(); - - xprSetNativeProperty(pFrame); -} - - -/* - * Called to check if the frame should be reordered when it is restacked. - */ -static Bool xprDoReorderWindow(RootlessWindowPtr pFrame) -{ - WindowPtr pWin = pFrame->win; - - TA_SERVER(); - - return AppleWMDoReorderWindow(pWin); -} - - -/* - * Copy area in frame to another part of frame. - * Used to accelerate scrolling. - */ -static void -xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects, - int dx, int dy) -{ - TA_SERVER(); - - xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid), - dstNrects, dstRects, dx, dy); -} - - -static RootlessFrameProcsRec xprRootlessProcs = { - xprCreateFrame, - xprDestroyFrame, - xprMoveFrame, - xprResizeFrame, - xprRestackFrame, - xprReshapeFrame, - xprUnmapFrame, - xprStartDrawing, - xprStopDrawing, - xprUpdateRegion, - xprDamageRects, - xprSwitchWindow, - xprDoReorderWindow, - xprHideWindow, - xprUpdateColormap, - xp_copy_bytes, - xp_fill_bytes, - xp_composite_pixels, - xprCopyWindow -}; - - -/* - * Initialize XPR implementation - */ -Bool -xprInit(ScreenPtr pScreen) -{ - RootlessInit(pScreen, &xprRootlessProcs); - - TA_SERVER(); - - rootless_CopyBytes_threshold = xp_copy_bytes_threshold; - rootless_FillBytes_threshold = xp_fill_bytes_threshold; - rootless_CompositePixels_threshold = xp_composite_area_threshold; - rootless_CopyWindow_threshold = xp_scroll_area_threshold; - - return TRUE; -} - - -/* - * Given the id of a physical window, try to find the top-level (or root) - * X window that it represents. - */ -WindowPtr -xprGetXWindow(xp_window_id wid) -{ - RootlessWindowRec *winRec; - - if (window_hash == NULL) - return NULL; - - winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); - - return winRec != NULL ? winRec->win : NULL; -} - -#ifdef UNUSED_CODE -/* - * Given the id of a physical window, try to find the top-level (or root) - * X window that it represents. - */ -WindowPtr -xprGetXWindowFromAppKit(int windowNumber) -{ - RootlessWindowRec *winRec; - Bool ret; - xp_window_id wid; - - if (window_hash == NULL) - return FALSE; - - /* need to lock, since this function can be called by any thread */ - - pthread_mutex_lock(&window_hash_mutex); - - if (xp_lookup_native_window(windowNumber, &wid)) - ret = xprGetXWindow(wid) != NULL; - else - ret = FALSE; - - pthread_mutex_unlock(&window_hash_mutex); - - if (!ret) return NULL; - winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); - - return winRec != NULL ? winRec->win : NULL; -} -#endif - -/* - * The windowNumber is an AppKit window number. Returns TRUE if xpr is - * displaying a window with that number. - */ -Bool -xprIsX11Window(void *nsWindow, int windowNumber) -{ - Bool ret; - xp_window_id wid; - - if (window_hash == NULL) - return FALSE; - - /* need to lock, since this function can be called by any thread */ - - pthread_mutex_lock(&window_hash_mutex); - - if (xp_lookup_native_window(windowNumber, &wid)) - ret = xprGetXWindow(wid) != NULL; - else - ret = FALSE; - - pthread_mutex_unlock(&window_hash_mutex); - - return ret; -} - - -/* - * xprHideWindows - * Hide or unhide all top level windows. This is called for application hide/ - * unhide events if the window manager is not Apple-WM aware. Xplugin windows - * do not hide or unhide themselves. - */ -void -xprHideWindows(Bool hide) -{ - int screen; - WindowPtr pRoot, pWin; - - TA_SERVER(); - - for (screen = 0; screen < screenInfo.numScreens; screen++) { - RootlessFrameID prevWid = NULL; - pRoot = WindowTable[screenInfo.screens[screen]->myNum]; - - for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) { - RootlessWindowRec *winRec = WINREC(pWin); - - if (winRec != NULL) { - if (hide) { - xprUnmapFrame(winRec->wid); - } else { - BoxRec box; - - xprRestackFrame(winRec->wid, prevWid); - prevWid = winRec->wid; - - box.x1 = 0; - box.y1 = 0; - box.x2 = winRec->width; - box.y2 = winRec->height; - - xprDamageRects(winRec->wid, 1, &box, 0, 0); - RootlessQueueRedisplay(screenInfo.screens[screen]); - } - } - } - } -} - -// XXX: identical to x_cvt_vptr_to_uint ? -#define MAKE_WINDOW_ID(x) ((xp_window_id)((size_t)(x))) - -Bool no_configure_window; - -static inline int -configure_window (xp_window_id id, unsigned int mask, - const xp_window_changes *values) -{ - if (!no_configure_window) - return xp_configure_window (id, mask, values); - else - return XP_Success; -} - - -static -void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen) -{ - /* This is how we tell xp that the colormap may have changed. */ - xp_window_changes wc; - wc.colormap = xprColormapCallback; - wc.colormap_data = pScreen; - - configure_window(MAKE_WINDOW_ID(wid), XP_COLORMAP, &wc); -} - -static -void xprHideWindow(RootlessFrameID wid) -{ - xp_window_changes wc; - wc.stack_mode = XP_UNMAPPED; - wc.sibling = 0; - configure_window(MAKE_WINDOW_ID(wid), XP_STACKING, &wc); -} +/*
+ * Xplugin rootless implementation frame functions
+ *
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003 Torrey T. Lyons. 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
+
+#include "xpr.h"
+#include "rootlessCommon.h"
+#include <Xplugin.h>
+#include "x-hash.h"
+#include "x-list.h"
+#include "applewmExt.h"
+
+#include "propertyst.h"
+#include "dix.h"
+#include <X11/Xatom.h>
+#include "windowstr.h"
+#include "quartz.h"
+
+#include "threadSafety.h"
+
+#include <pthread.h>
+
+#define DEFINE_ATOM_HELPER(func,atom_name) \
+static Atom func (void) { \
+ static int generation; \
+ static Atom atom; \
+ if (generation != serverGeneration) { \
+ generation = serverGeneration; \
+ atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \
+ } \
+ return atom; \
+}
+
+DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
+
+/* Maps xp_window_id -> RootlessWindowRec */
+static x_hash_table *window_hash;
+static pthread_mutex_t window_hash_mutex;
+
+/* Prototypes for static functions */
+static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape);
+static void xprDestroyFrame(RootlessFrameID wid);
+static void xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
+static void xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity);
+static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid);
+static void xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape);
+static void xprUnmapFrame(RootlessFrameID wid);
+static void xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow);
+static void xprStopDrawing(RootlessFrameID wid, Bool flush);
+static void xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage);
+static void xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
+ int shift_x, int shift_y);
+static void xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin);
+static Bool xprDoReorderWindow(RootlessWindowPtr pFrame);
+static void xprHideWindow(RootlessFrameID wid);
+static void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen);
+static void xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
+ int dx, int dy);
+
+
+static inline xp_error
+xprConfigureWindow(xp_window_id id, unsigned int mask,
+ const xp_window_changes *values)
+{
+ TA_SERVER();
+
+ return xp_configure_window(id, mask, values);
+}
+
+
+static void
+xprSetNativeProperty(RootlessWindowPtr pFrame)
+{
+ xp_error err;
+ unsigned int native_id;
+ long data;
+
+ TA_SERVER();
+
+ err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id);
+ if (err == Success)
+ {
+ /* FIXME: move this to AppleWM extension */
+
+ data = native_id;
+ dixChangeWindowProperty(serverClient, pFrame->win, xa_native_window_id(),
+ XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE);
+ }
+}
+
+static xp_error
+xprColormapCallback(void *data, int first_color, int n_colors, uint32_t *colors)
+{
+ return (RootlessResolveColormap (data, first_color, n_colors, colors) ? XP_Success : XP_BadMatch);
+}
+
+/*
+ * Create and display a new frame.
+ */
+static Bool
+xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape)
+{
+ WindowPtr pWin = pFrame->win;
+ xp_window_changes wc;
+ unsigned int mask = 0;
+ xp_error err;
+
+ TA_SERVER();
+
+ wc.x = newX;
+ wc.y = newY;
+ wc.width = pFrame->width;
+ wc.height = pFrame->height;
+ wc.bit_gravity = XP_GRAVITY_NONE;
+ mask |= XP_BOUNDS;
+
+ if (pWin->drawable.depth == 8)
+ {
+ wc.depth = XP_DEPTH_INDEX8;
+ wc.colormap = xprColormapCallback;
+ wc.colormap_data = pScreen;
+ mask |= XP_COLORMAP;
+ }
+ else if (pWin->drawable.depth == 15)
+ wc.depth = XP_DEPTH_RGB555;
+ else if (pWin->drawable.depth == 24)
+ wc.depth = XP_DEPTH_ARGB8888;
+ else
+ wc.depth = XP_DEPTH_NIL;
+ mask |= XP_DEPTH;
+
+ if (pShape != NULL)
+ {
+ wc.shape_nrects = RegionNumRects(pShape);
+ wc.shape_rects = RegionRects(pShape);
+ wc.shape_tx = wc.shape_ty = 0;
+ mask |= XP_SHAPE;
+ }
+
+ pFrame->level = !IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels;
+
+ if(quartzEnableRootless)
+ wc.window_level = normal_window_levels[pFrame->level];
+ else
+ wc.window_level = rooted_window_levels[pFrame->level];
+ mask |= XP_WINDOW_LEVEL;
+
+ err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid);
+
+ if (err != Success)
+ {
+ return FALSE;
+ }
+
+ if (window_hash == NULL)
+ {
+ window_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
+ pthread_mutex_init(&window_hash_mutex, NULL);
+ }
+
+ pthread_mutex_lock(&window_hash_mutex);
+ x_hash_table_insert(window_hash, pFrame->wid, pFrame);
+ pthread_mutex_unlock(&window_hash_mutex);
+
+ xprSetNativeProperty(pFrame);
+
+ return TRUE;
+}
+
+
+/*
+ * Destroy a frame.
+ */
+static void
+xprDestroyFrame(RootlessFrameID wid)
+{
+ TA_SERVER();
+
+ pthread_mutex_lock(&window_hash_mutex);
+ x_hash_table_remove(window_hash, wid);
+ pthread_mutex_unlock(&window_hash_mutex);
+
+ xp_destroy_window(x_cvt_vptr_to_uint(wid));
+}
+
+
+/*
+ * Move a frame on screen.
+ */
+static void
+xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
+{
+ xp_window_changes wc;
+
+ TA_SERVER();
+
+ wc.x = newX;
+ wc.y = newY;
+ // ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY);
+ xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_ORIGIN, &wc);
+}
+
+
+/*
+ * Resize and move a frame.
+ */
+static void
+xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity)
+{
+ xp_window_changes wc;
+
+ TA_SERVER();
+
+ wc.x = newX;
+ wc.y = newY;
+ wc.width = newW;
+ wc.height = newH;
+ wc.bit_gravity = gravity;
+
+ /* It's unlikely that being async will save us anything here.
+ But it can't hurt. */
+
+ xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_BOUNDS, &wc);
+}
+
+
+/*
+ * Change frame stacking.
+ */
+static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
+ xp_window_changes wc;
+ unsigned int mask = XP_STACKING;
+
+ TA_SERVER();
+
+ /* Stack frame below nextWid it if it exists, or raise
+ frame above everything otherwise. */
+
+ if(nextWid == NULL) {
+ wc.stack_mode = XP_MAPPED_ABOVE;
+ wc.sibling = 0;
+ } else {
+ wc.stack_mode = XP_MAPPED_BELOW;
+ wc.sibling = x_cvt_vptr_to_uint(nextWid);
+ }
+
+ if(window_hash) {
+ RootlessWindowRec *winRec = x_hash_table_lookup(window_hash, wid, NULL);
+
+ if(winRec) {
+ if(quartzEnableRootless)
+ wc.window_level = normal_window_levels[winRec->level];
+ else
+ wc.window_level = rooted_window_levels[winRec->level];
+ mask |= XP_WINDOW_LEVEL;
+ }
+ }
+
+ xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc);
+}
+
+
+/*
+ * Change the frame's shape.
+ */
+static void
+xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
+{
+ xp_window_changes wc;
+
+ TA_SERVER();
+
+ if (pShape != NULL)
+ {
+ wc.shape_nrects = RegionNumRects(pShape);
+ wc.shape_rects = RegionRects(pShape);
+ }
+ else
+ {
+ wc.shape_nrects = -1;
+ wc.shape_rects = NULL;
+ }
+
+ wc.shape_tx = wc.shape_ty = 0;
+
+ xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_SHAPE, &wc);
+}
+
+
+/*
+ * Unmap a frame.
+ */
+static void
+xprUnmapFrame(RootlessFrameID wid)
+{
+ xp_window_changes wc;
+
+ TA_SERVER();
+
+ wc.stack_mode = XP_UNMAPPED;
+ wc.sibling = 0;
+
+ xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_STACKING, &wc);
+}
+
+
+/*
+ * Start drawing to a frame.
+ * Prepare for direct access to its backing buffer.
+ */
+static void
+xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
+{
+ void *data[2];
+ unsigned int rowbytes[2];
+ xp_error err;
+
+ TA_SERVER();
+
+ err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, NULL);
+ if (err != Success)
+ FatalError("Could not lock window %i for drawing.", (int)x_cvt_vptr_to_uint(wid));
+
+ *pixelData = data[0];
+ *bytesPerRow = rowbytes[0];
+}
+
+
+/*
+ * Stop drawing to a frame.
+ */
+static void
+xprStopDrawing(RootlessFrameID wid, Bool flush)
+{
+ TA_SERVER();
+
+ xp_unlock_window(x_cvt_vptr_to_uint(wid), flush);
+}
+
+
+/*
+ * Flush drawing updates to the screen.
+ */
+static void
+xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
+{
+ TA_SERVER();
+
+ xp_flush_window(x_cvt_vptr_to_uint(wid));
+}
+
+
+/*
+ * Mark damaged rectangles as requiring redisplay to screen.
+ */
+static void
+xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
+ int shift_x, int shift_y)
+{
+ TA_SERVER();
+
+ xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y);
+}
+
+
+/*
+ * Called after the window associated with a frame has been switched
+ * to a new top-level parent.
+ */
+static void
+xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
+{
+ DeleteProperty(serverClient, oldWin, xa_native_window_id());
+
+ TA_SERVER();
+
+ xprSetNativeProperty(pFrame);
+}
+
+
+/*
+ * Called to check if the frame should be reordered when it is restacked.
+ */
+static Bool xprDoReorderWindow(RootlessWindowPtr pFrame)
+{
+ WindowPtr pWin = pFrame->win;
+
+ TA_SERVER();
+
+ return AppleWMDoReorderWindow(pWin);
+}
+
+
+/*
+ * Copy area in frame to another part of frame.
+ * Used to accelerate scrolling.
+ */
+static void
+xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
+ int dx, int dy)
+{
+ TA_SERVER();
+
+ xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid),
+ dstNrects, dstRects, dx, dy);
+}
+
+
+static RootlessFrameProcsRec xprRootlessProcs = {
+ xprCreateFrame,
+ xprDestroyFrame,
+ xprMoveFrame,
+ xprResizeFrame,
+ xprRestackFrame,
+ xprReshapeFrame,
+ xprUnmapFrame,
+ xprStartDrawing,
+ xprStopDrawing,
+ xprUpdateRegion,
+ xprDamageRects,
+ xprSwitchWindow,
+ xprDoReorderWindow,
+ xprHideWindow,
+ xprUpdateColormap,
+ xp_copy_bytes,
+ xp_fill_bytes,
+ xp_composite_pixels,
+ xprCopyWindow
+};
+
+
+/*
+ * Initialize XPR implementation
+ */
+Bool
+xprInit(ScreenPtr pScreen)
+{
+ RootlessInit(pScreen, &xprRootlessProcs);
+
+ TA_SERVER();
+
+ rootless_CopyBytes_threshold = xp_copy_bytes_threshold;
+ rootless_FillBytes_threshold = xp_fill_bytes_threshold;
+ rootless_CompositePixels_threshold = xp_composite_area_threshold;
+ rootless_CopyWindow_threshold = xp_scroll_area_threshold;
+
+ return TRUE;
+}
+
+
+/*
+ * Given the id of a physical window, try to find the top-level (or root)
+ * X window that it represents.
+ */
+WindowPtr
+xprGetXWindow(xp_window_id wid)
+{
+ RootlessWindowRec *winRec;
+
+ if (window_hash == NULL)
+ return NULL;
+
+ winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
+
+ return winRec != NULL ? winRec->win : NULL;
+}
+
+#ifdef UNUSED_CODE
+/*
+ * Given the id of a physical window, try to find the top-level (or root)
+ * X window that it represents.
+ */
+WindowPtr
+xprGetXWindowFromAppKit(int windowNumber)
+{
+ RootlessWindowRec *winRec;
+ Bool ret;
+ xp_window_id wid;
+
+ if (window_hash == NULL)
+ return FALSE;
+
+ /* need to lock, since this function can be called by any thread */
+
+ pthread_mutex_lock(&window_hash_mutex);
+
+ if (xp_lookup_native_window(windowNumber, &wid))
+ ret = xprGetXWindow(wid) != NULL;
+ else
+ ret = FALSE;
+
+ pthread_mutex_unlock(&window_hash_mutex);
+
+ if (!ret) return NULL;
+ winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
+
+ return winRec != NULL ? winRec->win : NULL;
+}
+#endif
+
+/*
+ * The windowNumber is an AppKit window number. Returns TRUE if xpr is
+ * displaying a window with that number.
+ */
+Bool
+xprIsX11Window(void *nsWindow, int windowNumber)
+{
+ Bool ret;
+ xp_window_id wid;
+
+ if (window_hash == NULL)
+ return FALSE;
+
+ /* need to lock, since this function can be called by any thread */
+
+ pthread_mutex_lock(&window_hash_mutex);
+
+ if (xp_lookup_native_window(windowNumber, &wid))
+ ret = xprGetXWindow(wid) != NULL;
+ else
+ ret = FALSE;
+
+ pthread_mutex_unlock(&window_hash_mutex);
+
+ return ret;
+}
+
+
+/*
+ * xprHideWindows
+ * Hide or unhide all top level windows. This is called for application hide/
+ * unhide events if the window manager is not Apple-WM aware. Xplugin windows
+ * do not hide or unhide themselves.
+ */
+void
+xprHideWindows(Bool hide)
+{
+ int screen;
+ WindowPtr pRoot, pWin;
+
+ TA_SERVER();
+
+ for (screen = 0; screen < screenInfo.numScreens; screen++) {
+ RootlessFrameID prevWid = NULL;
+ pRoot = screenInfo.screens[screen]->root;
+
+ for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
+ RootlessWindowRec *winRec = WINREC(pWin);
+
+ if (winRec != NULL) {
+ if (hide) {
+ xprUnmapFrame(winRec->wid);
+ } else {
+ BoxRec box;
+
+ xprRestackFrame(winRec->wid, prevWid);
+ prevWid = winRec->wid;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = winRec->width;
+ box.y2 = winRec->height;
+
+ xprDamageRects(winRec->wid, 1, &box, 0, 0);
+ RootlessQueueRedisplay(screenInfo.screens[screen]);
+ }
+ }
+ }
+ }
+}
+
+// XXX: identical to x_cvt_vptr_to_uint ?
+#define MAKE_WINDOW_ID(x) ((xp_window_id)((size_t)(x)))
+
+Bool no_configure_window;
+
+static inline int
+configure_window (xp_window_id id, unsigned int mask,
+ const xp_window_changes *values)
+{
+ if (!no_configure_window)
+ return xp_configure_window (id, mask, values);
+ else
+ return XP_Success;
+}
+
+
+static
+void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen)
+{
+ /* This is how we tell xp that the colormap may have changed. */
+ xp_window_changes wc;
+ wc.colormap = xprColormapCallback;
+ wc.colormap_data = pScreen;
+
+ configure_window(MAKE_WINDOW_ID(wid), XP_COLORMAP, &wc);
+}
+
+static
+void xprHideWindow(RootlessFrameID wid)
+{
+ xp_window_changes wc;
+ wc.stack_mode = XP_UNMAPPED;
+ wc.sibling = 0;
+ configure_window(MAKE_WINDOW_ID(wid), XP_STACKING, &wc);
+}
diff --git a/xorg-server/hw/xquartz/xpr/xprScreen.c b/xorg-server/hw/xquartz/xpr/xprScreen.c index bc68f7923..d4fef8e0a 100644 --- a/xorg-server/hw/xquartz/xpr/xprScreen.c +++ b/xorg-server/hw/xquartz/xpr/xprScreen.c @@ -397,7 +397,7 @@ xprUpdateScreen(ScreenPtr pScreen) rootlessGlobalOffsetX = darwinMainScreenX;
rootlessGlobalOffsetY = darwinMainScreenY;
- AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]);
+ AppleWMSetScreenOrigin(pScreen->root);
RootlessRepositionWindows(pScreen);
RootlessUpdateScreenPixmap(pScreen);
@@ -416,7 +416,7 @@ xprInitInput(int argc, char **argv) rootlessGlobalOffsetY = darwinMainScreenY;
for (i = 0; i < screenInfo.numScreens; i++)
- AppleWMSetScreenOrigin(WindowTable[i]);
+ AppleWMSetScreenOrigin(screenInfo.screens[i]->root);
}
/*
diff --git a/xorg-server/hw/xwin/win.h b/xorg-server/hw/xwin/win.h index d0a41f9ea..3649fe830 100644 --- a/xorg-server/hw/xwin/win.h +++ b/xorg-server/hw/xwin/win.h @@ -596,11 +596,17 @@ extern DWORD g_dwEvents; #ifdef HAS_DEVWINDOWS
extern int g_fdMessageQueue;
#endif
-extern DevPrivateKey g_iScreenPrivateKey;
-extern DevPrivateKey g_iCmapPrivateKey;
-extern DevPrivateKey g_iGCPrivateKey;
-extern DevPrivateKey g_iPixmapPrivateKey;
-extern DevPrivateKey g_iWindowPrivateKey;
+extern DevPrivateKeyRec g_iScreenPrivateKeyRec;
+#define g_iScreenPrivateKey (&g_iScreenPrivateKeyRec)
+extern DevPrivateKeyRec g_iCmapPrivateKeyRec;
+#define g_iCmapPrivateKey (&g_iCmapPrivateKeyRec)
+extern DevPrivateKeyRec g_iGCPrivateKeyRec;
+#define g_iGCPrivateKey (&g_iGCPrivateKeyRec)
+extern DevPrivateKeyRec g_iPixmapPrivateKeyRec;
+#define g_iPixmapPrivateKey (&g_iPixmapPrivateKeyRec)
+extern DevPrivateKeyRec g_iWindowPrivateKeyRec;
+#define g_iWindowPrivateKey (&g_iWindowPrivateKeyRec)
+
extern unsigned long g_ulServerGeneration;
extern DWORD g_dwEnginesSupported;
extern HINSTANCE g_hInstance;
@@ -1175,7 +1181,7 @@ Bool winMapWindowRootless (WindowPtr pWindow);
void
-winSetShapeRootless (WindowPtr pWindow);
+winSetShapeRootless (WindowPtr pWindow, int kind);
/*
@@ -1197,7 +1203,7 @@ void winReshapeMultiWindow (WindowPtr pWin);
void
-winSetShapeMultiWindow (WindowPtr pWindow);
+winSetShapeMultiWindow (WindowPtr pWindow, int kind);
void
winUpdateRgnMultiWindow (WindowPtr pWindow);
diff --git a/xorg-server/hw/xwin/winallpriv.c b/xorg-server/hw/xwin/winallpriv.c index 3413ece53..604c5f673 100644 --- a/xorg-server/hw/xwin/winallpriv.c +++ b/xorg-server/hw/xwin/winallpriv.c @@ -1,164 +1,164 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Keith Packard, MIT X Consortium - * Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - - -/* See Porting Layer Definition - p. 58 */ -/* - * Allocate indexes for the privates that we use. - * Allocate memory directly for the screen privates. - * Reserve space in GCs and Pixmaps for our privates. - * Colormap privates are handled in winAllocateCmapPrivates () - */ - -Bool -winAllocatePrivates (ScreenPtr pScreen) -{ - winPrivScreenPtr pScreenPriv; - - winDebug ("winAllocateScreenPrivates - g_ulServerGeneration: %d " - "serverGeneration: %d\n", - g_ulServerGeneration, serverGeneration); - - /* We need a new slot for our privates if the screen gen has changed */ - if (g_ulServerGeneration != serverGeneration) - { - g_ulServerGeneration = serverGeneration; - } - - /* Allocate memory for the screen private structure */ - pScreenPriv = (winPrivScreenPtr) malloc (sizeof (winPrivScreenRec)); - if (!pScreenPriv) - { - ErrorF ("winAllocateScreenPrivates - malloc () failed\n"); - return FALSE; - } - - /* Initialize the memory of the private structure */ - ZeroMemory (pScreenPriv, sizeof (winPrivScreenRec)); - - /* Intialize private structure members */ - pScreenPriv->fActive = TRUE; - - /* Save the screen private pointer */ - winSetScreenPriv (pScreen, pScreenPriv); - - /* Reserve GC memory for our privates */ - if (!dixRequestPrivate(g_iGCPrivateKey, sizeof (winPrivGCRec))) - { - ErrorF ("winAllocatePrivates - AllocateGCPrivate () failed\n"); - return FALSE; - } - - /* Reserve Pixmap memory for our privates */ - if (!dixRequestPrivate(g_iPixmapPrivateKey, sizeof (winPrivPixmapRec))) - { - ErrorF ("winAllocatePrivates - AllocatePixmapPrivates () failed\n"); - return FALSE; - } - - /* Reserve Window memory for our privates */ - if (!dixRequestPrivate(g_iWindowPrivateKey, sizeof (winPrivWinRec))) - { - ErrorF ("winAllocatePrivates () - AllocateWindowPrivates () failed\n"); - return FALSE; - } - - return TRUE; -} - - -/* - * Colormap privates may be allocated after the default colormap has - * already been created for some screens. This initialization procedure - * is called for each default colormap that is found. - */ - -Bool -winInitCmapPrivates (ColormapPtr pcmap, int index) -{ - winDebug ("winInitCmapPrivates\n"); - - /* - * I see no way that this function can do anything useful - * with only a ColormapPtr. We don't have the index for - * our dev privates yet, so we can't really initialize - * anything. Perhaps I am misunderstanding the purpose - * of this function. - */ - /* That's definitely true. - * I therefore changed the API and added the index as argument. - */ - return TRUE; -} - - -/* - * Allocate memory for our colormap privates - */ - -Bool -winAllocateCmapPrivates (ColormapPtr pCmap) -{ - winPrivCmapPtr pCmapPriv; - static unsigned long s_ulPrivateGeneration = 0; - - winDebug ("winAllocateCmapPrivates\n"); - - /* Get a new privates index when the server generation changes */ - if (s_ulPrivateGeneration != serverGeneration) - { - /* Save the new server generation */ - s_ulPrivateGeneration = serverGeneration; - } - - /* Allocate memory for our private structure */ - pCmapPriv = (winPrivCmapPtr) malloc (sizeof (winPrivCmapRec)); - if (!pCmapPriv) - { - ErrorF ("winAllocateCmapPrivates - malloc () failed\n"); - return FALSE; - } - - /* Initialize the memory of the private structure */ - ZeroMemory (pCmapPriv, sizeof (winPrivCmapRec)); - - /* Save the cmap private pointer */ - winSetCmapPriv (pCmap, pCmapPriv); - - winDebug ("winAllocateCmapPrivates - Returning\n"); - - return TRUE; -} +/*
+ *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Keith Packard, MIT X Consortium
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/* See Porting Layer Definition - p. 58 */
+/*
+ * Allocate indexes for the privates that we use.
+ * Allocate memory directly for the screen privates.
+ * Reserve space in GCs and Pixmaps for our privates.
+ * Colormap privates are handled in winAllocateCmapPrivates ()
+ */
+
+Bool
+winAllocatePrivates (ScreenPtr pScreen)
+{
+ winPrivScreenPtr pScreenPriv;
+
+ winDebug ("winAllocateScreenPrivates - g_ulServerGeneration: %d "
+ "serverGeneration: %d\n",
+ g_ulServerGeneration, serverGeneration);
+
+ /* We need a new slot for our privates if the screen gen has changed */
+ if (g_ulServerGeneration != serverGeneration)
+ {
+ g_ulServerGeneration = serverGeneration;
+ }
+
+ /* Allocate memory for the screen private structure */
+ pScreenPriv = (winPrivScreenPtr) malloc (sizeof (winPrivScreenRec));
+ if (!pScreenPriv)
+ {
+ ErrorF ("winAllocateScreenPrivates - malloc () failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the memory of the private structure */
+ ZeroMemory (pScreenPriv, sizeof (winPrivScreenRec));
+
+ /* Intialize private structure members */
+ pScreenPriv->fActive = TRUE;
+
+ /* Save the screen private pointer */
+ winSetScreenPriv (pScreen, pScreenPriv);
+
+ /* Reserve GC memory for our privates */
+ if (!dixRegisterPrivateKey(g_iGCPrivateKey, PRIVATE_GC, sizeof (winPrivGCRec)))
+ {
+ ErrorF ("winAllocatePrivates - AllocateGCPrivate () failed\n");
+ return FALSE;
+ }
+
+ /* Reserve Pixmap memory for our privates */
+ if (!dixRegisterPrivateKey(g_iPixmapPrivateKey, PRIVATE_PIXMAP, sizeof (winPrivPixmapRec)))
+ {
+ ErrorF ("winAllocatePrivates - AllocatePixmapPrivates () failed\n");
+ return FALSE;
+ }
+
+ /* Reserve Window memory for our privates */
+ if (!dixRegisterPrivateKey(g_iWindowPrivateKey, PRIVATE_WINDOW, sizeof (winPrivWinRec)))
+ {
+ ErrorF ("winAllocatePrivates () - AllocateWindowPrivates () failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap privates may be allocated after the default colormap has
+ * already been created for some screens. This initialization procedure
+ * is called for each default colormap that is found.
+ */
+
+Bool
+winInitCmapPrivates (ColormapPtr pcmap, int index)
+{
+ winDebug ("winInitCmapPrivates\n");
+
+ /*
+ * I see no way that this function can do anything useful
+ * with only a ColormapPtr. We don't have the index for
+ * our dev privates yet, so we can't really initialize
+ * anything. Perhaps I am misunderstanding the purpose
+ * of this function.
+ */
+ /* That's definitely true.
+ * I therefore changed the API and added the index as argument.
+ */
+ return TRUE;
+}
+
+
+/*
+ * Allocate memory for our colormap privates
+ */
+
+Bool
+winAllocateCmapPrivates (ColormapPtr pCmap)
+{
+ winPrivCmapPtr pCmapPriv;
+ static unsigned long s_ulPrivateGeneration = 0;
+
+ winDebug ("winAllocateCmapPrivates\n");
+
+ /* Get a new privates index when the server generation changes */
+ if (s_ulPrivateGeneration != serverGeneration)
+ {
+ /* Save the new server generation */
+ s_ulPrivateGeneration = serverGeneration;
+ }
+
+ /* Allocate memory for our private structure */
+ pCmapPriv = (winPrivCmapPtr) malloc (sizeof (winPrivCmapRec));
+ if (!pCmapPriv)
+ {
+ ErrorF ("winAllocateCmapPrivates - malloc () failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the memory of the private structure */
+ ZeroMemory (pCmapPriv, sizeof (winPrivCmapRec));
+
+ /* Save the cmap private pointer */
+ winSetCmapPriv (pCmap, pCmapPriv);
+
+ winDebug ("winAllocateCmapPrivates - Returning\n");
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winclipboardxevents.c b/xorg-server/hw/xwin/winclipboardxevents.c index d7fa8ffd7..a3d333d80 100644 --- a/xorg-server/hw/xwin/winclipboardxevents.c +++ b/xorg-server/hw/xwin/winclipboardxevents.c @@ -426,8 +426,7 @@ winClipboardFlushXEvents (HWND hwnd, xtpText.value = NULL;
xtpText.nitems = 0;
}
- if (pszConvertData)
- free (pszConvertData);
+ free(pszConvertData);
if (hGlobal && pszGlobalData)
GlobalUnlock (hGlobal);
@@ -792,10 +791,8 @@ winClipboardFlushXEvents (HWND hwnd, xtpText.value = NULL;
xtpText.nitems = 0;
}
- if (pszConvertData)
- free (pszConvertData);
- if (pwszUnicodeStr)
- free (pwszUnicodeStr);
+ free(pszConvertData);
+ free(pwszUnicodeStr);
if (hGlobal && pszGlobalData)
GlobalUnlock (hGlobal);
if (fSetClipboardData && g_fUnicodeSupport)
diff --git a/xorg-server/hw/xwin/winconfig.c b/xorg-server/hw/xwin/winconfig.c index fffd3e813..89a57eada 100644 --- a/xorg-server/hw/xwin/winconfig.c +++ b/xorg-server/hw/xwin/winconfig.c @@ -727,7 +727,7 @@ winNameCompare (const char *s1, const char *s2) c1 = (isupper (*s1) ? tolower (*s1) : *s1);
c2 = (isupper (*s2) ? tolower (*s2) : *s2);
}
- return (c1 - c2);
+ return c1 - c2;
}
@@ -762,11 +762,11 @@ winFindOptionValue (XF86OptionPtr list, const char *name) if (list)
{
if (list->opt_val)
- return (list->opt_val);
+ return list->opt_val;
else
return "";
}
- return (NULL);
+ return NULL;
}
diff --git a/xorg-server/hw/xwin/winerror.c b/xorg-server/hw/xwin/winerror.c index 2e706009c..b6b780ec4 100644 --- a/xorg-server/hw/xwin/winerror.c +++ b/xorg-server/hw/xwin/winerror.c @@ -162,9 +162,7 @@ winMessageBoxF (const char *pszError, UINT uType, ...) MB_OK | uType);
winMessageBoxF_Cleanup:
- if (pszErrorF)
- free(pszErrorF);
- if (pszMsgBox)
- free(pszMsgBox);
+ free(pszErrorF);
+ free(pszMsgBox);
#undef MESSAGEBOXF
}
diff --git a/xorg-server/hw/xwin/winfillsp.c b/xorg-server/hw/xwin/winfillsp.c index 702f34f96..ef427a3f1 100644 --- a/xorg-server/hw/xwin/winfillsp.c +++ b/xorg-server/hw/xwin/winfillsp.c @@ -1,866 +1,866 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Harold L Hunt II - * Alan Hourihane <alanh@fairlite.demon.co.uk> - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - - -extern void ROP16(HDC hdc, int rop); - -#define TRANSLATE_COLOR(color) \ -{ \ - if (pDrawable->depth == 15) \ - color = ((color & 0x1F) << 19) | ((color & 0x03E0) << 6) | \ - ((color & 0xF800) >> 8); \ - else if (pDrawable->depth == 16) \ - color = ((color & 0x1F) << 19) | ((color & 0x07E0) << 5) | \ - ((color & 0xF800) >> 8); \ - else if (pDrawable->depth == 24 || pDrawable->depth == 32) \ - color = ((color & 0xFF) << 16) | (color & 0xFF00) | \ - ((color & 0xFF0000) >> 16); \ -} - -/* See Porting Layer Definition - p. 54 */ -void -winFillSpansNativeGDI (DrawablePtr pDrawable, - GCPtr pGC, - int iSpans, - DDXPointPtr pPoints, - int *piWidths, - int fSorted) -{ - winGCPriv(pGC); - HBITMAP hbmpOrig = NULL, hbmpOrigStipple = NULL; - HBITMAP hPenOrig = NULL; - HBITMAP hBitmap = NULL; - PixmapPtr pPixmap = NULL; - winPrivPixmapPtr pPixmapPriv = NULL; - PixmapPtr pStipple = NULL; - winPrivPixmapPtr pStipplePriv = NULL; - PixmapPtr pTile = NULL; - winPrivPixmapPtr pTilePriv = NULL; - HDC hdcStipple = NULL, hdcTile = NULL; - HPEN hPen = NULL; - int iX; - int fg, bg; - RegionPtr pClip = pGC->pCompositeClip; - BoxPtr pextent, pbox; - int nbox; - int extentX1, extentX2, extentY1, extentY2; - int fullX1, fullX2, fullY1; - HRGN hrgn = NULL, combined = NULL; - - nbox = REGION_NUM_RECTS (pClip); - pbox = REGION_RECTS (pClip); - - if (!nbox) return; - - combined = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2); - nbox--; pbox++; - - while (nbox--) - { - hrgn = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2); - CombineRgn (combined, combined, hrgn, RGN_OR); - DeleteObject (hrgn); - hrgn = NULL; - pbox++; - } - - pextent = REGION_EXTENTS (pGC->pScreen, pClip); - extentX1 = pextent->x1; - extentY1 = pextent->y1; - extentX2 = pextent->x2; - extentY2 = pextent->y2; - - /* Branch on the type of drawable we have */ - switch (pDrawable->type) - { - case DRAWABLE_PIXMAP: - - SelectClipRgn (pGCPriv->hdcMem, combined); - DeleteObject (combined); - combined = NULL; - - /* Get a pixmap pointer from the drawable pointer, and fetch privates */ - pPixmap = (PixmapPtr) pDrawable; - pPixmapPriv = winGetPixmapPriv (pPixmap); - - /* Select the drawable pixmap into memory hdc */ - hbmpOrig = SelectObject (pGCPriv->hdcMem, pPixmapPriv->hBitmap); - if (hbmpOrig == NULL) - FatalError ("winFillSpans - DRAWABLE_PIXMAP - " - "SelectObject () failed on\n\tpPixmapPriv->hBitmap: " - "%08x\n", (unsigned int) pPixmapPriv->hBitmap); - - /* Branch on the fill type */ - switch (pGC->fillStyle) - { - case FillSolid: - - ROP16 (pGCPriv->hdcMem, pGC->alu); - - if (pDrawable->depth == 1) - { - if (pGC->fgPixel == 0) - hPenOrig = SelectObject (pGCPriv->hdcMem, - GetStockObject (BLACK_PEN)); - else - hPenOrig = SelectObject (pGCPriv->hdcMem, - GetStockObject (WHITE_PEN)); - } - else - { - fg = pGC->fgPixel; - TRANSLATE_COLOR (fg); - hPen = CreatePen (PS_SOLID, 0, fg); - hPenOrig = SelectObject (pGCPriv->hdcMem, hPen); - } - - while (iSpans--) - { - fullX1 = pPoints->x; - fullY1 = pPoints->y; - fullX2 = fullX1 + (int) *piWidths; - pPoints++; - piWidths++; - - if (fullY1 < extentY1 || extentY2 <= fullY1) - continue; - - if (fullX1 < extentX1) - fullX1 = extentX1; - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullX1 >= fullX2) - continue; - - MoveToEx (pGCPriv->hdcMem, fullX1, fullY1, NULL); - LineTo (pGCPriv->hdcMem, fullX2, fullY1); - } - - SetROP2 (pGCPriv->hdcMem, R2_COPYPEN); - - /* Give back the Pen */ - SelectObject (pGCPriv->hdcMem, hPenOrig); - - if (pDrawable->depth != 1) - DeleteObject (hPen); - break; - - case FillOpaqueStippled: - - pStipple = pGC->stipple; - pStipplePriv = winGetPixmapPriv (pStipple); - - /* Create a device-dependent bitmap for the stipple */ - hBitmap = CreateDIBitmap (pGCPriv->hdcMem, - (BITMAPINFOHEADER *)pStipplePriv->pbmih, - CBM_INIT, - pStipplePriv->pbBits, - (BITMAPINFO *)pStipplePriv->pbmih, - DIB_RGB_COLORS); - - /* Create a memory DC to hold the stipple */ - hdcStipple = CreateCompatibleDC (pGCPriv->hdcMem); - - /* Select the stipple bitmap into the stipple DC */ - hbmpOrigStipple = SelectObject (hdcStipple, hBitmap); - if (hbmpOrigStipple == NULL) - FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - " - "SelectObject () failed on hbmpOrigStipple\n"); - - /* Make a temporary copy of the foreground and background colors */ - bg = pGC->bgPixel; - fg = pGC->fgPixel; - - /* Translate the depth-dependent colors to Win32 COLORREFs */ - TRANSLATE_COLOR (fg); - TRANSLATE_COLOR (bg); - SetTextColor (pGCPriv->hdcMem, fg); - SetBkColor (pGCPriv->hdcMem, bg); - - while (iSpans--) - { - int width = pStipple->drawable.width; - fullX1 = pPoints->x; - fullY1 = pPoints->y; - fullX2 = fullX1 + (int) *piWidths; - pPoints++; - piWidths++; - - if (fullY1 < extentY1 || extentY2 <= fullY1) - continue; - - if (fullX1 < extentX1) - fullX1 = extentX1; - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullX1 >= fullX2) - continue; - - for (iX = fullX1; iX < fullX2; iX += width) - { - int xoffset; - - if ((iX + pStipple->drawable.width) > fullX2) - width = fullX2 - iX; - else - width = pStipple->drawable.width; - - if (iX == fullX1) - xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width; - else - xoffset = 0; - - if (xoffset + width > pStipple->drawable.width) - width = pStipple->drawable.width - xoffset; - - BitBlt (pGCPriv->hdcMem, - iX, fullY1, - width, 1, - hdcStipple, - xoffset, - (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height, - g_copyROP[pGC->alu]); - } - } - - /* Clear the stipple HDC */ - SelectObject (hdcStipple, hbmpOrigStipple); - DeleteDC (hdcStipple); - - /* Delete the device dependent stipple bitmap */ - DeleteObject (hBitmap); - - break; - case FillStippled: - - pStipple = pGC->stipple; - pStipplePriv = winGetPixmapPriv (pStipple); - - /* Create a device-dependent bitmap for the stipple */ - hBitmap = CreateDIBitmap (pGCPriv->hdcMem, - (BITMAPINFOHEADER *)pStipplePriv->pbmih, - CBM_INIT, - pStipplePriv->pbBits, - (BITMAPINFO *)pStipplePriv->pbmih, - DIB_RGB_COLORS); - - /* Create a memory DC to hold the stipple */ - hdcStipple = CreateCompatibleDC (pGCPriv->hdcMem); - - /* Select the stipple bitmap into the stipple DC */ - hbmpOrigStipple = SelectObject (hdcStipple, hBitmap); - if (hbmpOrigStipple == NULL) - FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - " - "SelectObject () failed on hbmpOrigStipple\n"); - - /* Make a temporary copy of the foreground and background colors */ - bg = pGC->bgPixel; - fg = pGC->fgPixel; - - /* Translate the depth-dependent colors to Win32 COLORREFs */ - TRANSLATE_COLOR (fg); - TRANSLATE_COLOR (bg); - - /* this is fudgy, we should only invert on the last one - * We need to get the black/white pixels right in the - * colormap. But yeah ! it's working.. - */ - if (pGC->bgPixel != -1 && pGC->fgPixel != -1) - { - SetTextColor (pGCPriv->hdcMem, fg); - SetBkColor (pGCPriv->hdcMem, bg); - BitBlt (hdcStipple, - 0, 0, - pStipple->drawable.width, pStipple->drawable.height, - hdcStipple, - 0, 0, - 0x330008); - } - else if (pGC->bgPixel == -1) - { - SetTextColor (pGCPriv->hdcMem, fg); - SetBkMode (pGCPriv->hdcMem, TRANSPARENT); - BitBlt (hdcStipple, - 0, 0, - pStipple->drawable.width, pStipple->drawable.height, - hdcStipple, - 0, 0, - 0x330008); - } - else if (pGC->fgPixel == -1) - { - SetTextColor (pGCPriv->hdcMem, bg); - SetBkMode (pGCPriv->hdcMem, TRANSPARENT); -#if 0 - BitBlt (hdcStipple, - 0, 0, - pStipple->drawable.width, pStipple->drawable.height, - hdcStipple, - 0, 0, - 0x330008); -#endif - } - - while (iSpans--) - { - int width = pStipple->drawable.width; - fullX1 = pPoints->x; - fullY1 = pPoints->y; - fullX2 = fullX1 + (int) *piWidths; - pPoints++; - piWidths++; - - if (fullY1 < extentY1 || extentY2 <= fullY1) - continue; - - if (fullX1 < extentX1) - fullX1 = extentX1; - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullX1 >= fullX2) - continue; - - for (iX = fullX1; iX < fullX2; iX += width) - { - int xoffset; - - if ((iX + pStipple->drawable.width) > fullX2) - width = fullX2 - iX; - else - width = pStipple->drawable.width; - - if (iX == fullX1) - xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width; - else - xoffset = 0; - - if (xoffset + width > pStipple->drawable.width) - width = pStipple->drawable.width - xoffset; - - BitBlt (pGCPriv->hdcMem, - iX, fullY1, - width, 1, - hdcStipple, - xoffset, - (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height, - g_copyROP[pGC->alu]); - } - } - - /* Clear the stipple HDC */ - SelectObject (hdcStipple, hbmpOrigStipple); - DeleteDC (hdcStipple); - - /* Delete the device dependent stipple bitmap */ - DeleteObject (hBitmap); - - /* Restore the background mode */ - SetBkMode (pGCPriv->hdcMem, OPAQUE); - break; - - case FillTiled: - - /* Get a pixmap pointer from the tile pointer, and fetch privates */ - pTile = (PixmapPtr) pGC->tile.pixmap; - pTilePriv = winGetPixmapPriv (pTile); - - /* Create a memory DC to hold the tile */ - hdcTile = CreateCompatibleDC (pGCPriv->hdcMem); - - /* Select the tile into a DC */ - hbmpOrig = SelectObject (hdcTile, pTilePriv->hBitmap); - if (hbmpOrig == NULL) - FatalError ("winFillSpans - DRAWABLE_PIXMAP - FillTiled - " - "SelectObject () failed on pTilePriv->hBitmap\n"); - - while (iSpans--) - { - int width = pTile->drawable.width; - fullX1 = pPoints->x; - fullY1 = pPoints->y; - fullX2 = fullX1 + (int) *piWidths; - pPoints++; - piWidths++; - - if (fullY1 < extentY1 || extentY2 <= fullY1) - continue; - - if (fullX1 < extentX1) - fullX1 = extentX1; - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullX1 >= fullX2) - continue; - - for (iX = fullX1; iX < fullX2; iX += width) - { - int xoffset; - - if ((iX + pTile->drawable.width) > fullX2) - width = fullX2 - iX; - else - width = pTile->drawable.width; - - if (iX == fullX1) - xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pTile->drawable.width) - pTile->drawable.width)) % pTile->drawable.width; - else - xoffset = 0; - - if (xoffset + width > pTile->drawable.width) - width = pTile->drawable.width - xoffset; - - BitBlt (pGCPriv->hdcMem, - iX, fullY1, - width, 1, - hdcTile, - xoffset, - (fullY1 - (pDrawable->y + (pGC->patOrg.y % pTile->drawable.height) - pTile->drawable.height)) % pTile->drawable.height, - g_copyROP[pGC->alu]); - } - } - - /* Push the tile pixmap out of the memory HDC */ - SelectObject (hdcTile, hbmpOrig); - - /* Delete the tile */ - DeleteDC (hdcTile); - break; - - default: - ErrorF ("winFillSpans - DRAWABLE_PIXMAP - Unknown fillStyle\n"); - break; - } - - /* Reset clip region */ - SelectClipRgn (pGCPriv->hdcMem, NULL); - - /* Push the drawable pixmap out of the GC HDC */ - SelectObject (pGCPriv->hdcMem, hbmpOrig); - break; - - case DRAWABLE_WINDOW: - - SelectClipRgn (pGCPriv->hdc, combined); - DeleteObject (combined); - combined = NULL; - - /* Branch on fill style */ - switch (pGC->fillStyle) - { - case FillSolid: - - ROP16 (pGCPriv->hdc, pGC->alu); - - if (pDrawable->depth == 1) - { - if (pGC->fgPixel == 0) - hPenOrig = SelectObject (pGCPriv->hdc, - GetStockObject (BLACK_PEN)); - else - hPenOrig = SelectObject (pGCPriv->hdc, - GetStockObject (WHITE_PEN)); - } - else - { - fg = pGC->fgPixel; - TRANSLATE_COLOR (fg); - hPen = CreatePen (PS_SOLID, 0, fg); - hPenOrig = SelectObject (pGCPriv->hdc, hPen); - } - - while (iSpans--) - { - fullX1 = pPoints->x; - fullY1 = pPoints->y; - fullX2 = fullX1 + (int) *piWidths; - pPoints++; - piWidths++; - - if (fullY1 < extentY1 || extentY2 <= fullY1) - continue; - - if (fullX1 < extentX1) - fullX1 = extentX1; - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullX1 >= fullX2) - continue; - - MoveToEx (pGCPriv->hdc, fullX1, fullY1, NULL); - LineTo (pGCPriv->hdc, fullX2, fullY1); - } - - SetROP2 (pGCPriv->hdc, R2_COPYPEN); - - /* Give back the Brush */ - SelectObject (pGCPriv->hdc, hPenOrig); - - if (pDrawable->depth != 1) - DeleteObject (hPen); - break; - - case FillOpaqueStippled: - - pStipple = pGC->stipple; - pStipplePriv = winGetPixmapPriv (pStipple); - - /* Create a device-dependent bitmap for the stipple */ - hBitmap = CreateDIBitmap (pGCPriv->hdc, - (BITMAPINFOHEADER *)pStipplePriv->pbmih, - CBM_INIT, - pStipplePriv->pbBits, - (BITMAPINFO *)pStipplePriv->pbmih, - DIB_RGB_COLORS); - - /* Create a memory DC to hold the stipple */ - hdcStipple = CreateCompatibleDC (pGCPriv->hdc); - - /* Select the stipple bitmap into the stipple DC */ - hbmpOrigStipple = SelectObject (hdcStipple, hBitmap); - if (hbmpOrigStipple == NULL) - FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - " - "SelectObject () failed on hbmpOrigStipple\n"); - - /* Make a temporary copy of the foreground and background colors */ - bg = pGC->bgPixel; - fg = pGC->fgPixel; - - /* Translate the depth-dependent colors to Win32 COLORREFs */ - TRANSLATE_COLOR (fg); - TRANSLATE_COLOR (bg); - SetTextColor (pGCPriv->hdc, fg); - SetBkColor (pGCPriv->hdc, bg); - - while (iSpans--) - { - int width = pStipple->drawable.width; - fullX1 = pPoints->x; - fullY1 = pPoints->y; - fullX2 = fullX1 + (int) *piWidths; - pPoints++; - piWidths++; - - if (fullY1 < extentY1 || extentY2 <= fullY1) - continue; - - if (fullX1 < extentX1) - fullX1 = extentX1; - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullX1 >= fullX2) - continue; - - for (iX = fullX1; iX < fullX2; iX += width) - { - int xoffset; - - if ((iX + pStipple->drawable.width) > fullX2) - width = fullX2 - iX; - else - width = pStipple->drawable.width; - - if (iX == fullX1) - xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width; - else - xoffset = 0; - - if (xoffset + width > pStipple->drawable.width) - width = pStipple->drawable.width - xoffset; - - BitBlt (pGCPriv->hdc, - iX, fullY1, - width, 1, - hdcStipple, - xoffset, - (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height, - g_copyROP[pGC->alu]); - } - } - - /* Clear the stipple HDC */ - SelectObject (hdcStipple, hbmpOrigStipple); - DeleteDC (hdcStipple); - - /* Delete the device dependent stipple bitmap */ - DeleteObject (hBitmap); - - break; - - case FillStippled: - pStipple = pGC->stipple; - pStipplePriv = winGetPixmapPriv (pStipple); - - /* Create a device-dependent bitmap for the stipple */ - hBitmap = CreateDIBitmap (pGCPriv->hdcMem, - (BITMAPINFOHEADER *)pStipplePriv->pbmih, - CBM_INIT, - pStipplePriv->pbBits, - (BITMAPINFO *)pStipplePriv->pbmih, - DIB_RGB_COLORS); - - /* Create a memory DC to hold the stipple */ - hdcStipple = CreateCompatibleDC (pGCPriv->hdc); - - /* Select the stipple bitmap into the stipple DC */ - hbmpOrigStipple = SelectObject (hdcStipple, hBitmap); - if (hbmpOrigStipple == NULL) - FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - " - "SelectObject () failed on hbmpOrigStipple\n"); - - /* Make a temporary copy of the foreground and background colors */ - bg = pGC->bgPixel; - fg = pGC->fgPixel; - - /* Translate the depth-dependent colors to Win32 COLORREFs */ - TRANSLATE_COLOR (fg); - TRANSLATE_COLOR (bg); - - /* this is fudgy, we should only invert on the last one - * We need to get the black/white pixels right in the - * colormap. But yeah ! it's working.. - */ - if (pGC->bgPixel != -1 && pGC->fgPixel != -1) - { - SetTextColor (pGCPriv->hdc, fg); - SetBkColor (pGCPriv->hdc, bg); - BitBlt (hdcStipple, - 0, 0, - pStipple->drawable.width, pStipple->drawable.height, - hdcStipple, - 0,0, - 0x330008); - } - else if (pGC->bgPixel == -1) - { - SetTextColor (pGCPriv->hdc, fg); - SetBkMode (pGCPriv->hdc, TRANSPARENT); - BitBlt (hdcStipple, - 0, 0, - pStipple->drawable.width, pStipple->drawable.height, - hdcStipple, - 0,0, - 0x330008); - } - else if (pGC->fgPixel == -1) - { - SetTextColor (pGCPriv->hdc, bg); - SetBkMode (pGCPriv->hdc, TRANSPARENT); -#if 0 - BitBlt (hdcStipple, - 0, 0, - pStipple->drawable.width, pStipple->drawable.height, - hdcStipple, - 0, 0, - 0x330008); -#endif - } - - while (iSpans--) - { - int width = pStipple->drawable.width; - fullX1 = pPoints->x; - fullY1 = pPoints->y; - fullX2 = fullX1 + (int) *piWidths; - pPoints++; - piWidths++; - - if (fullY1 < extentY1 || extentY2 <= fullY1) - continue; - - if (fullX1 < extentX1) - fullX1 = extentX1; - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullX1 >= fullX2) - continue; - - for (iX = fullX1; iX < fullX2; iX += width) - { - int xoffset; - - if ((iX + pStipple->drawable.width) > fullX2) - width = fullX2 - iX; - else - width = pStipple->drawable.width; - - if (iX == fullX1) - xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width; - else - xoffset = 0; - - if (xoffset + width > pStipple->drawable.width) - width = pStipple->drawable.width - xoffset; - - BitBlt (pGCPriv->hdc, - iX, fullY1, - width, 1, - hdcStipple, - xoffset, - (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height, - g_copyROP[pGC->alu]); - } - } - - /* Clear the stipple HDC */ - SelectObject (hdcStipple, hbmpOrigStipple); - DeleteDC (hdcStipple); - - /* Delete the device dependent stipple bitmap */ - DeleteObject (hBitmap); - - /* Restore the background mode */ - SetBkMode (pGCPriv->hdc, OPAQUE); - break; - - case FillTiled: - - /* Get a pixmap pointer from the tile pointer, and fetch privates */ - pTile = (PixmapPtr) pGC->tile.pixmap; - pTilePriv = winGetPixmapPriv (pTile); - - /* Select the tile into a DC */ - hbmpOrig = SelectObject (pGCPriv->hdcMem, pTilePriv->hBitmap); - if (hbmpOrig == NULL) - FatalError ("winFillSpans - DRAWABLE_WINDOW - FillTiled - " - "SelectObject () failed on pTilePriv->hBitmap\n"); - - while (iSpans--) - { - int width = pTile->drawable.width; - fullX1 = pPoints->x; - fullY1 = pPoints->y; - fullX2 = fullX1 + (int) *piWidths; - pPoints++; - piWidths++; - - if (fullY1 < extentY1 || extentY2 <= fullY1) - continue; - - if (fullX1 < extentX1) - fullX1 = extentX1; - if (fullX2 > extentX2) - fullX2 = extentX2; - - if (fullX1 >= fullX2) - continue; - - for (iX = fullX1; iX < fullX2; iX += width) - { - int xoffset; - - if ((iX + pTile->drawable.width) > fullX2) - width = fullX2 - iX; - else - width = pTile->drawable.width; - - if (iX == fullX1) - xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pTile->drawable.width) - pTile->drawable.width)) % pTile->drawable.width; - else - xoffset = 0; - - if (xoffset + width > pTile->drawable.width) - width = pTile->drawable.width - xoffset; - - BitBlt (pGCPriv->hdc, - iX, fullY1, - width, 1, - pGCPriv->hdcMem, - xoffset, - (fullY1 - (pDrawable->y + (pGC->patOrg.y % pTile->drawable.height) - pTile->drawable.height)) % pTile->drawable.height, - g_copyROP[pGC->alu]); - } - } - - /* Push the tile pixmap out of the memory HDC */ - SelectObject (pGCPriv->hdcMem, hbmpOrig); - break; - - default: - ErrorF ("winFillSpans - DRAWABLE_WINDOW - Unknown fillStyle\n"); - break; - } - - /* Reset clip region */ - SelectClipRgn (pGCPriv->hdc, NULL); - break; - - case UNDRAWABLE_WINDOW: - /* UNDRAWABLE_WINDOW doesn't appear to get called when running xterm */ - switch (pGC->fillStyle) - { - case FillSolid: - ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - FillSolid - " - "Unimplemented\n"); - break; - - case FillStippled: - ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - FillStippled - " - "Unimplemented\n"); - break; - - case FillTiled: - ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - FillTiled - " - "Unimplemented\n"); - break; - - case FillOpaqueStippled: - ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - OpaqueStippled - " - "Unimplemented\n"); - break; - - default: - ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - Unknown fillStyle\n"); - break; - } - break; - - case DRAWABLE_BUFFER: - /* DRAWABLE_BUFFER seems to be undocumented. */ - ErrorF ("winFillSpans - DRAWABLE_BUFFER - Unimplemented\n"); - break; - - default: - ErrorF ("winFillSpans - Unknown drawable type\n"); - break; - } -} +/*
+ *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+extern void ROP16(HDC hdc, int rop);
+
+#define TRANSLATE_COLOR(color) \
+{ \
+ if (pDrawable->depth == 15) \
+ color = ((color & 0x1F) << 19) | ((color & 0x03E0) << 6) | \
+ ((color & 0xF800) >> 8); \
+ else if (pDrawable->depth == 16) \
+ color = ((color & 0x1F) << 19) | ((color & 0x07E0) << 5) | \
+ ((color & 0xF800) >> 8); \
+ else if (pDrawable->depth == 24 || pDrawable->depth == 32) \
+ color = ((color & 0xFF) << 16) | (color & 0xFF00) | \
+ ((color & 0xFF0000) >> 16); \
+}
+
+/* See Porting Layer Definition - p. 54 */
+void
+winFillSpansNativeGDI (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int iSpans,
+ DDXPointPtr pPoints,
+ int *piWidths,
+ int fSorted)
+{
+ winGCPriv(pGC);
+ HBITMAP hbmpOrig = NULL, hbmpOrigStipple = NULL;
+ HBITMAP hPenOrig = NULL;
+ HBITMAP hBitmap = NULL;
+ PixmapPtr pPixmap = NULL;
+ winPrivPixmapPtr pPixmapPriv = NULL;
+ PixmapPtr pStipple = NULL;
+ winPrivPixmapPtr pStipplePriv = NULL;
+ PixmapPtr pTile = NULL;
+ winPrivPixmapPtr pTilePriv = NULL;
+ HDC hdcStipple = NULL, hdcTile = NULL;
+ HPEN hPen = NULL;
+ int iX;
+ int fg, bg;
+ RegionPtr pClip = pGC->pCompositeClip;
+ BoxPtr pextent, pbox;
+ int nbox;
+ int extentX1, extentX2, extentY1, extentY2;
+ int fullX1, fullX2, fullY1;
+ HRGN hrgn = NULL, combined = NULL;
+
+ nbox = RegionNumRects (pClip);
+ pbox = RegionRects (pClip);
+
+ if (!nbox) return;
+
+ combined = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ nbox--; pbox++;
+
+ while (nbox--)
+ {
+ hrgn = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ CombineRgn (combined, combined, hrgn, RGN_OR);
+ DeleteObject (hrgn);
+ hrgn = NULL;
+ pbox++;
+ }
+
+ pextent = RegionExtents(pClip);
+ extentX1 = pextent->x1;
+ extentY1 = pextent->y1;
+ extentX2 = pextent->x2;
+ extentY2 = pextent->y2;
+
+ /* Branch on the type of drawable we have */
+ switch (pDrawable->type)
+ {
+ case DRAWABLE_PIXMAP:
+
+ SelectClipRgn (pGCPriv->hdcMem, combined);
+ DeleteObject (combined);
+ combined = NULL;
+
+ /* Get a pixmap pointer from the drawable pointer, and fetch privates */
+ pPixmap = (PixmapPtr) pDrawable;
+ pPixmapPriv = winGetPixmapPriv (pPixmap);
+
+ /* Select the drawable pixmap into memory hdc */
+ hbmpOrig = SelectObject (pGCPriv->hdcMem, pPixmapPriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError ("winFillSpans - DRAWABLE_PIXMAP - "
+ "SelectObject () failed on\n\tpPixmapPriv->hBitmap: "
+ "%08x\n", (unsigned int) pPixmapPriv->hBitmap);
+
+ /* Branch on the fill type */
+ switch (pGC->fillStyle)
+ {
+ case FillSolid:
+
+ ROP16 (pGCPriv->hdcMem, pGC->alu);
+
+ if (pDrawable->depth == 1)
+ {
+ if (pGC->fgPixel == 0)
+ hPenOrig = SelectObject (pGCPriv->hdcMem,
+ GetStockObject (BLACK_PEN));
+ else
+ hPenOrig = SelectObject (pGCPriv->hdcMem,
+ GetStockObject (WHITE_PEN));
+ }
+ else
+ {
+ fg = pGC->fgPixel;
+ TRANSLATE_COLOR (fg);
+ hPen = CreatePen (PS_SOLID, 0, fg);
+ hPenOrig = SelectObject (pGCPriv->hdcMem, hPen);
+ }
+
+ while (iSpans--)
+ {
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ MoveToEx (pGCPriv->hdcMem, fullX1, fullY1, NULL);
+ LineTo (pGCPriv->hdcMem, fullX2, fullY1);
+ }
+
+ SetROP2 (pGCPriv->hdcMem, R2_COPYPEN);
+
+ /* Give back the Pen */
+ SelectObject (pGCPriv->hdcMem, hPenOrig);
+
+ if (pDrawable->depth != 1)
+ DeleteObject (hPen);
+ break;
+
+ case FillOpaqueStippled:
+
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv (pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap (pGCPriv->hdcMem,
+ (BITMAPINFOHEADER *)pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *)pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC (pGCPriv->hdcMem);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR (fg);
+ TRANSLATE_COLOR (bg);
+ SetTextColor (pGCPriv->hdcMem, fg);
+ SetBkColor (pGCPriv->hdcMem, bg);
+
+ while (iSpans--)
+ {
+ int width = pStipple->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdcMem,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject (hdcStipple, hbmpOrigStipple);
+ DeleteDC (hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject (hBitmap);
+
+ break;
+ case FillStippled:
+
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv (pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap (pGCPriv->hdcMem,
+ (BITMAPINFOHEADER *)pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *)pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC (pGCPriv->hdcMem);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR (fg);
+ TRANSLATE_COLOR (bg);
+
+ /* this is fudgy, we should only invert on the last one
+ * We need to get the black/white pixels right in the
+ * colormap. But yeah ! it's working..
+ */
+ if (pGC->bgPixel != -1 && pGC->fgPixel != -1)
+ {
+ SetTextColor (pGCPriv->hdcMem, fg);
+ SetBkColor (pGCPriv->hdcMem, bg);
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0, 0,
+ 0x330008);
+ }
+ else if (pGC->bgPixel == -1)
+ {
+ SetTextColor (pGCPriv->hdcMem, fg);
+ SetBkMode (pGCPriv->hdcMem, TRANSPARENT);
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0, 0,
+ 0x330008);
+ }
+ else if (pGC->fgPixel == -1)
+ {
+ SetTextColor (pGCPriv->hdcMem, bg);
+ SetBkMode (pGCPriv->hdcMem, TRANSPARENT);
+#if 0
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0, 0,
+ 0x330008);
+#endif
+ }
+
+ while (iSpans--)
+ {
+ int width = pStipple->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdcMem,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject (hdcStipple, hbmpOrigStipple);
+ DeleteDC (hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject (hBitmap);
+
+ /* Restore the background mode */
+ SetBkMode (pGCPriv->hdcMem, OPAQUE);
+ break;
+
+ case FillTiled:
+
+ /* Get a pixmap pointer from the tile pointer, and fetch privates */
+ pTile = (PixmapPtr) pGC->tile.pixmap;
+ pTilePriv = winGetPixmapPriv (pTile);
+
+ /* Create a memory DC to hold the tile */
+ hdcTile = CreateCompatibleDC (pGCPriv->hdcMem);
+
+ /* Select the tile into a DC */
+ hbmpOrig = SelectObject (hdcTile, pTilePriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError ("winFillSpans - DRAWABLE_PIXMAP - FillTiled - "
+ "SelectObject () failed on pTilePriv->hBitmap\n");
+
+ while (iSpans--)
+ {
+ int width = pTile->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pTile->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pTile->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pTile->drawable.width) - pTile->drawable.width)) % pTile->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pTile->drawable.width)
+ width = pTile->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdcMem,
+ iX, fullY1,
+ width, 1,
+ hdcTile,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pTile->drawable.height) - pTile->drawable.height)) % pTile->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Push the tile pixmap out of the memory HDC */
+ SelectObject (hdcTile, hbmpOrig);
+
+ /* Delete the tile */
+ DeleteDC (hdcTile);
+ break;
+
+ default:
+ ErrorF ("winFillSpans - DRAWABLE_PIXMAP - Unknown fillStyle\n");
+ break;
+ }
+
+ /* Reset clip region */
+ SelectClipRgn (pGCPriv->hdcMem, NULL);
+
+ /* Push the drawable pixmap out of the GC HDC */
+ SelectObject (pGCPriv->hdcMem, hbmpOrig);
+ break;
+
+ case DRAWABLE_WINDOW:
+
+ SelectClipRgn (pGCPriv->hdc, combined);
+ DeleteObject (combined);
+ combined = NULL;
+
+ /* Branch on fill style */
+ switch (pGC->fillStyle)
+ {
+ case FillSolid:
+
+ ROP16 (pGCPriv->hdc, pGC->alu);
+
+ if (pDrawable->depth == 1)
+ {
+ if (pGC->fgPixel == 0)
+ hPenOrig = SelectObject (pGCPriv->hdc,
+ GetStockObject (BLACK_PEN));
+ else
+ hPenOrig = SelectObject (pGCPriv->hdc,
+ GetStockObject (WHITE_PEN));
+ }
+ else
+ {
+ fg = pGC->fgPixel;
+ TRANSLATE_COLOR (fg);
+ hPen = CreatePen (PS_SOLID, 0, fg);
+ hPenOrig = SelectObject (pGCPriv->hdc, hPen);
+ }
+
+ while (iSpans--)
+ {
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ MoveToEx (pGCPriv->hdc, fullX1, fullY1, NULL);
+ LineTo (pGCPriv->hdc, fullX2, fullY1);
+ }
+
+ SetROP2 (pGCPriv->hdc, R2_COPYPEN);
+
+ /* Give back the Brush */
+ SelectObject (pGCPriv->hdc, hPenOrig);
+
+ if (pDrawable->depth != 1)
+ DeleteObject (hPen);
+ break;
+
+ case FillOpaqueStippled:
+
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv (pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap (pGCPriv->hdc,
+ (BITMAPINFOHEADER *)pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *)pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC (pGCPriv->hdc);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR (fg);
+ TRANSLATE_COLOR (bg);
+ SetTextColor (pGCPriv->hdc, fg);
+ SetBkColor (pGCPriv->hdc, bg);
+
+ while (iSpans--)
+ {
+ int width = pStipple->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdc,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject (hdcStipple, hbmpOrigStipple);
+ DeleteDC (hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject (hBitmap);
+
+ break;
+
+ case FillStippled:
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv (pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap (pGCPriv->hdcMem,
+ (BITMAPINFOHEADER *)pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *)pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC (pGCPriv->hdc);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR (fg);
+ TRANSLATE_COLOR (bg);
+
+ /* this is fudgy, we should only invert on the last one
+ * We need to get the black/white pixels right in the
+ * colormap. But yeah ! it's working..
+ */
+ if (pGC->bgPixel != -1 && pGC->fgPixel != -1)
+ {
+ SetTextColor (pGCPriv->hdc, fg);
+ SetBkColor (pGCPriv->hdc, bg);
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0,0,
+ 0x330008);
+ }
+ else if (pGC->bgPixel == -1)
+ {
+ SetTextColor (pGCPriv->hdc, fg);
+ SetBkMode (pGCPriv->hdc, TRANSPARENT);
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0,0,
+ 0x330008);
+ }
+ else if (pGC->fgPixel == -1)
+ {
+ SetTextColor (pGCPriv->hdc, bg);
+ SetBkMode (pGCPriv->hdc, TRANSPARENT);
+#if 0
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0, 0,
+ 0x330008);
+#endif
+ }
+
+ while (iSpans--)
+ {
+ int width = pStipple->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdc,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject (hdcStipple, hbmpOrigStipple);
+ DeleteDC (hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject (hBitmap);
+
+ /* Restore the background mode */
+ SetBkMode (pGCPriv->hdc, OPAQUE);
+ break;
+
+ case FillTiled:
+
+ /* Get a pixmap pointer from the tile pointer, and fetch privates */
+ pTile = (PixmapPtr) pGC->tile.pixmap;
+ pTilePriv = winGetPixmapPriv (pTile);
+
+ /* Select the tile into a DC */
+ hbmpOrig = SelectObject (pGCPriv->hdcMem, pTilePriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError ("winFillSpans - DRAWABLE_WINDOW - FillTiled - "
+ "SelectObject () failed on pTilePriv->hBitmap\n");
+
+ while (iSpans--)
+ {
+ int width = pTile->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pTile->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pTile->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pTile->drawable.width) - pTile->drawable.width)) % pTile->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pTile->drawable.width)
+ width = pTile->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdc,
+ iX, fullY1,
+ width, 1,
+ pGCPriv->hdcMem,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pTile->drawable.height) - pTile->drawable.height)) % pTile->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Push the tile pixmap out of the memory HDC */
+ SelectObject (pGCPriv->hdcMem, hbmpOrig);
+ break;
+
+ default:
+ ErrorF ("winFillSpans - DRAWABLE_WINDOW - Unknown fillStyle\n");
+ break;
+ }
+
+ /* Reset clip region */
+ SelectClipRgn (pGCPriv->hdc, NULL);
+ break;
+
+ case UNDRAWABLE_WINDOW:
+ /* UNDRAWABLE_WINDOW doesn't appear to get called when running xterm */
+ switch (pGC->fillStyle)
+ {
+ case FillSolid:
+ ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - FillSolid - "
+ "Unimplemented\n");
+ break;
+
+ case FillStippled:
+ ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - FillStippled - "
+ "Unimplemented\n");
+ break;
+
+ case FillTiled:
+ ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - FillTiled - "
+ "Unimplemented\n");
+ break;
+
+ case FillOpaqueStippled:
+ ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - OpaqueStippled - "
+ "Unimplemented\n");
+ break;
+
+ default:
+ ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - Unknown fillStyle\n");
+ break;
+ }
+ break;
+
+ case DRAWABLE_BUFFER:
+ /* DRAWABLE_BUFFER seems to be undocumented. */
+ ErrorF ("winFillSpans - DRAWABLE_BUFFER - Unimplemented\n");
+ break;
+
+ default:
+ ErrorF ("winFillSpans - Unknown drawable type\n");
+ break;
+ }
+}
diff --git a/xorg-server/hw/xwin/wingc.c b/xorg-server/hw/xwin/wingc.c index 61ba78a54..5f8b2905e 100644 --- a/xorg-server/hw/xwin/wingc.c +++ b/xorg-server/hw/xwin/wingc.c @@ -1,167 +1,167 @@ -/* - *Copyright (C) 2001-2004 Harold L Hunt II 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 HAROLD L HUNT II 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 of Harold L Hunt II - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from Harold L Hunt II. - * - * Authors: Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - -void -winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg); - - -/* - * Local prototypes - */ - -static void -winValidateGCNativeGDI (GCPtr pGC, - unsigned long changes, - DrawablePtr pDrawable); - -static void -winDestroyGCNativeGDI (GCPtr pGC); - -const GCFuncs winGCFuncs = { - winValidateGCNativeGDI, - miChangeGC, - miCopyGC, - winDestroyGCNativeGDI, - miChangeClip, - miDestroyClip, - miCopyClip, -}; - -/* Drawing Primitives */ -const GCOps winGCOps = { - winFillSpansNativeGDI, - winSetSpansNativeGDI, - miPutImage, - miCopyArea, - miCopyPlane, - miPolyPoint, - winPolyLineNativeGDI, - miPolySegment, - miPolyRectangle, - miPolyArc, - miFillPolygon, - miPolyFillRect, - miPolyFillArc, - miPolyText8, - miPolyText16, - miImageText8, - miImageText16, - miImageGlyphBlt, - miPolyGlyphBlt, - miPushPixels, -}; - - -/* See Porting Layer Definition - p. 45 */ -/* See mfb/mfbgc.c - mfbCreateGC() */ -/* See Strategies for Porting - pp. 15, 16 */ -Bool -winCreateGCNativeGDI (GCPtr pGC) -{ - winPrivGCPtr pGCPriv = NULL; - winPrivScreenPtr pScreenPriv = NULL; - - winDebug ("winCreateGCNativeGDI - depth: %d\n", - pGC->depth); - - pGC->clientClip = NULL; - pGC->clientClipType = CT_NONE; - pGC->freeCompClip = FALSE; - pGC->pCompositeClip = 0; - - pGC->ops = (GCOps *) &winGCOps; - pGC->funcs = (GCFuncs *) &winGCFuncs; - - /* We want all coordinates passed to spans functions to be screen relative */ - pGC->miTranslate = TRUE; - - /* Allocate privates for this GC */ - pGCPriv = winGetGCPriv (pGC); - if (pGCPriv == NULL) - { - ErrorF ("winCreateGCNativeGDI () - Privates pointer was NULL\n"); - return FALSE; - } - - /* Create a new screen DC for the display window */ - pScreenPriv = winGetScreenPriv (pGC->pScreen); - pGCPriv->hdc = GetDC (pScreenPriv->hwndScreen); - - /* Allocate a memory DC for the GC */ - pGCPriv->hdcMem = CreateCompatibleDC (pGCPriv->hdc); - - return TRUE; -} - -static void -winValidateGCNativeGDI (GCPtr pGC, - unsigned long ulChanges, - DrawablePtr pDrawable) -{ - if ((ulChanges & (GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode)) - || (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))) - { - miComputeCompositeClip (pGC, pDrawable); - } -} - - -/* See Porting Layer Definition - p. 46 */ -static void -winDestroyGCNativeGDI (GCPtr pGC) -{ - winGCPriv(pGC); - winScreenPriv(pGC->pScreen); - - if (pGC->freeCompClip) - REGION_DESTROY (pGC->pScreen, pGC->pCompositeClip); - - /* Free the memory DC */ - if (pGCPriv->hdcMem != NULL) - { - DeleteDC (pGCPriv->hdcMem); - pGCPriv->hdcMem = NULL; - } - - /* Release the screen DC for the display window */ - if (pGCPriv->hdc != NULL) - { - ReleaseDC (pScreenPriv->hwndScreen, pGCPriv->hdc); - pGCPriv->hdc = NULL; - } - - /* Invalidate the GC privates pointer */ - winSetGCPriv (pGC, NULL); -} +/*
+ *Copyright (C) 2001-2004 Harold L Hunt II 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 HAROLD L HUNT II 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 of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+void
+winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg);
+
+
+/*
+ * Local prototypes
+ */
+
+static void
+winValidateGCNativeGDI (GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDrawable);
+
+static void
+winDestroyGCNativeGDI (GCPtr pGC);
+
+const GCFuncs winGCFuncs = {
+ winValidateGCNativeGDI,
+ miChangeGC,
+ miCopyGC,
+ winDestroyGCNativeGDI,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip,
+};
+
+/* Drawing Primitives */
+const GCOps winGCOps = {
+ winFillSpansNativeGDI,
+ winSetSpansNativeGDI,
+ miPutImage,
+ miCopyArea,
+ miCopyPlane,
+ miPolyPoint,
+ winPolyLineNativeGDI,
+ miPolySegment,
+ miPolyRectangle,
+ miPolyArc,
+ miFillPolygon,
+ miPolyFillRect,
+ miPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ miImageGlyphBlt,
+ miPolyGlyphBlt,
+ miPushPixels,
+};
+
+
+/* See Porting Layer Definition - p. 45 */
+/* See mfb/mfbgc.c - mfbCreateGC() */
+/* See Strategies for Porting - pp. 15, 16 */
+Bool
+winCreateGCNativeGDI (GCPtr pGC)
+{
+ winPrivGCPtr pGCPriv = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+
+ winDebug ("winCreateGCNativeGDI - depth: %d\n",
+ pGC->depth);
+
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+ pGC->freeCompClip = FALSE;
+ pGC->pCompositeClip = 0;
+
+ pGC->ops = (GCOps *) &winGCOps;
+ pGC->funcs = (GCFuncs *) &winGCFuncs;
+
+ /* We want all coordinates passed to spans functions to be screen relative */
+ pGC->miTranslate = TRUE;
+
+ /* Allocate privates for this GC */
+ pGCPriv = winGetGCPriv (pGC);
+ if (pGCPriv == NULL)
+ {
+ ErrorF ("winCreateGCNativeGDI () - Privates pointer was NULL\n");
+ return FALSE;
+ }
+
+ /* Create a new screen DC for the display window */
+ pScreenPriv = winGetScreenPriv (pGC->pScreen);
+ pGCPriv->hdc = GetDC (pScreenPriv->hwndScreen);
+
+ /* Allocate a memory DC for the GC */
+ pGCPriv->hdcMem = CreateCompatibleDC (pGCPriv->hdc);
+
+ return TRUE;
+}
+
+static void
+winValidateGCNativeGDI (GCPtr pGC,
+ unsigned long ulChanges,
+ DrawablePtr pDrawable)
+{
+ if ((ulChanges & (GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode))
+ || (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)))
+ {
+ miComputeCompositeClip (pGC, pDrawable);
+ }
+}
+
+
+/* See Porting Layer Definition - p. 46 */
+static void
+winDestroyGCNativeGDI (GCPtr pGC)
+{
+ winGCPriv(pGC);
+ winScreenPriv(pGC->pScreen);
+
+ if (pGC->freeCompClip)
+ RegionDestroy(pGC->pCompositeClip);
+
+ /* Free the memory DC */
+ if (pGCPriv->hdcMem != NULL)
+ {
+ DeleteDC (pGCPriv->hdcMem);
+ pGCPriv->hdcMem = NULL;
+ }
+
+ /* Release the screen DC for the display window */
+ if (pGCPriv->hdc != NULL)
+ {
+ ReleaseDC (pScreenPriv->hwndScreen, pGCPriv->hdc);
+ pGCPriv->hdc = NULL;
+ }
+
+ /* Invalidate the GC privates pointer */
+ winSetGCPriv (pGC, NULL);
+}
diff --git a/xorg-server/hw/xwin/winglobals.c b/xorg-server/hw/xwin/winglobals.c index 09b75031e..b698270b7 100644 --- a/xorg-server/hw/xwin/winglobals.c +++ b/xorg-server/hw/xwin/winglobals.c @@ -1,144 +1,146 @@ -/* - *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved. - *Copyright (C) Colin Harrison 2005-2008 - * - *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 HAROLD L HUNT II 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 of Harold L Hunt II - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from Harold L Hunt II. - * - * Authors: Harold L Hunt II - * Colin Harrison - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - - -/* - * General global variables - */ - -int g_iNumScreens = 0; -winScreenInfo * g_ScreenInfo = 0; -#ifdef HAS_DEVWINDOWS -int g_fdMessageQueue = WIN_FD_INVALID; -#endif -static int g_iScreenPrivateKeyIndex; -DevPrivateKey g_iScreenPrivateKey = &g_iScreenPrivateKeyIndex; -static int g_iCmapPrivateKeyIndex; -DevPrivateKey g_iCmapPrivateKey = &g_iCmapPrivateKeyIndex; -static int g_iGCPrivateKeyIndex; -DevPrivateKey g_iGCPrivateKey = &g_iGCPrivateKeyIndex; -static int g_iPixmapPrivateKeyIndex; -DevPrivateKey g_iPixmapPrivateKey = &g_iPixmapPrivateKeyIndex; -static int g_iWindowPrivateKeyIndex; -DevPrivateKey g_iWindowPrivateKey = &g_iWindowPrivateKeyIndex; -unsigned long g_ulServerGeneration = 0; -DWORD g_dwEnginesSupported = 0; -HINSTANCE g_hInstance = 0; -HWND g_hDlgDepthChange = NULL; -HWND g_hDlgExit = NULL; -HWND g_hDlgAbout = NULL; -const char * g_pszQueryHost = NULL; -Bool g_fXdmcpEnabled = FALSE; -Bool g_fAuthEnabled = FALSE; -HICON g_hIconX = NULL; -HICON g_hSmallIconX = NULL; -#ifndef RELOCATE_PROJECTROOT -const char * g_pszLogFile = DEFAULT_LOGDIR "/XWin.%s.log"; -#else -const char * g_pszLogFile = "XWin.log"; -Bool g_fLogFileChanged = FALSE; -#endif -int g_iLogVerbose = 2; -Bool g_fLogInited = FALSE; -char * g_pszCommandLine = NULL; -Bool g_fSilentFatalError = FALSE; -DWORD g_dwCurrentThreadID = 0; -Bool g_fKeyboardHookLL = FALSE; -HHOOK g_hhookKeyboardLL = NULL; -HWND g_hwndKeyboardFocus = NULL; -Bool g_fNoHelpMessageBox = FALSE; -Bool g_fSoftwareCursor = FALSE; -Bool g_fSilentDupError = FALSE; -Bool g_fNativeGl = FALSE; - -/* - * Global variables for dynamically loaded libraries and - * their function pointers - */ - -HMODULE g_hmodDirectDraw = NULL; -FARPROC g_fpDirectDrawCreate = NULL; -FARPROC g_fpDirectDrawCreateClipper = NULL; - -HMODULE g_hmodCommonControls = NULL; -FARPROC g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA; - - -#ifdef XWIN_CLIPBOARD -/* - * Wrapped DIX functions - */ -winDispatchProcPtr winProcEstablishConnectionOrig = NULL; -winDispatchProcPtr winProcQueryTreeOrig = NULL; -winDispatchProcPtr winProcSetSelectionOwnerOrig = NULL; - - -/* - * Clipboard variables - */ - -Bool g_fUnicodeClipboard = TRUE; -Bool g_fClipboard = TRUE; -Bool g_fClipboardLaunched = FALSE; -Bool g_fClipboardStarted = FALSE; -pthread_t g_ptClipboardProc; -HWND g_hwndClipboard = NULL; -void *g_pClipboardDisplay = NULL; -Window g_iClipboardWindow = None; -Atom g_atomLastOwnedSelection = None; -#endif - - -/* - * Re-initialize global variables that are invalidated - * by a server reset. - */ - -void -winInitializeGlobals (void) -{ - g_dwCurrentThreadID = GetCurrentThreadId (); - g_hwndKeyboardFocus = NULL; -#ifdef XWIN_CLIPBOARD - g_fClipboardLaunched = FALSE; - g_fClipboardStarted = FALSE; - g_iClipboardWindow = None; - g_pClipboardDisplay = NULL; - g_atomLastOwnedSelection = None; - g_hwndClipboard = NULL; -#endif -} +/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
+ *
+ *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 HAROLD L HUNT II 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 of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ * Colin Harrison
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * General global variables
+ */
+
+int g_iNumScreens = 0;
+winScreenInfo * g_ScreenInfo = 0;
+#ifdef HAS_DEVWINDOWS
+int g_fdMessageQueue = WIN_FD_INVALID;
+#endif
+DevPrivateKeyRec g_iScreenPrivateKeyRec;
+DevPrivateKeyRec g_iCmapPrivateKeyRec;
+DevPrivateKeyRec g_iGCPrivateKeyRec;
+DevPrivateKeyRec g_iPixmapPrivateKeyRec;
+DevPrivateKeyRec g_iWindowPrivateKeyRec;
+unsigned long g_ulServerGeneration = 0;
+DWORD g_dwEnginesSupported = 0;
+HINSTANCE g_hInstance = 0;
+HWND g_hDlgDepthChange = NULL;
+HWND g_hDlgExit = NULL;
+HWND g_hDlgAbout = NULL;
+const char * g_pszQueryHost = NULL;
+Bool g_fXdmcpEnabled = FALSE;
+Bool g_fAuthEnabled = FALSE;
+HICON g_hIconX = NULL;
+HICON g_hSmallIconX = NULL;
+#ifndef RELOCATE_PROJECTROOT
+const char * g_pszLogFile = DEFAULT_LOGDIR "/XWin.%s.log";
+#else
+const char * g_pszLogFile = "XWin.log";
+Bool g_fLogFileChanged = FALSE;
+#endif
+int g_iLogVerbose = 2;
+Bool g_fLogInited = FALSE;
+char * g_pszCommandLine = NULL;
+Bool g_fSilentFatalError = FALSE;
+DWORD g_dwCurrentThreadID = 0;
+Bool g_fKeyboardHookLL = FALSE;
+HHOOK g_hhookKeyboardLL = NULL;
+HWND g_hwndKeyboardFocus = NULL;
+Bool g_fNoHelpMessageBox = FALSE;
+Bool g_fSoftwareCursor = FALSE;
+Bool g_fSilentDupError = FALSE;
+Bool g_fNativeGl = FALSE;
+
+/*
+ * Global variables for dynamically loaded libraries and
+ * their function pointers
+ */
+
+HMODULE g_hmodDirectDraw = NULL;
+FARPROC g_fpDirectDrawCreate = NULL;
+FARPROC g_fpDirectDrawCreateClipper = NULL;
+
+HMODULE g_hmodCommonControls = NULL;
+FARPROC g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
+
+
+#ifdef XWIN_CLIPBOARD
+/*
+ * Wrapped DIX functions
+ */
+winDispatchProcPtr winProcEstablishConnectionOrig = NULL;
+winDispatchProcPtr winProcQueryTreeOrig = NULL;
+winDispatchProcPtr winProcSetSelectionOwnerOrig = NULL;
+
+
+/*
+ * Clipboard variables
+ */
+
+Bool g_fUnicodeClipboard = TRUE;
+Bool g_fClipboard = TRUE;
+Bool g_fClipboardLaunched = FALSE;
+Bool g_fClipboardStarted = FALSE;
+pthread_t g_ptClipboardProc;
+HWND g_hwndClipboard = NULL;
+void *g_pClipboardDisplay = NULL;
+Window g_iClipboardWindow = None;
+Atom g_atomLastOwnedSelection = None;
+#endif
+
+
+/*
+ * Re-initialize global variables that are invalidated
+ * by a server reset.
+ */
+
+void
+winInitializeGlobals (void)
+{
+ if (!dixRegisterPrivateKey(&g_iScreenPrivateKeyRec, PRIVATE_SCREEN, 0) ||
+ !dixRegisterPrivateKey(&g_iCmapPrivateKeyRec, PRIVATE_COLORMAP, 0) ||
+ !dixRegisterPrivateKey(&g_iGCPrivateKeyRec, PRIVATE_GC, 0) ||
+ !dixRegisterPrivateKey(&g_iPixmapPrivateKeyRec, PRIVATE_PIXMAP, 0) ||
+ !dixRegisterPrivateKey(&g_iWindowPrivateKeyRec, PRIVATE_WINDOW, 0)) {
+ FatalError("cannot register private key");
+ }
+ g_dwCurrentThreadID = GetCurrentThreadId ();
+ g_hwndKeyboardFocus = NULL;
+#ifdef XWIN_CLIPBOARD
+ g_fClipboardLaunched = FALSE;
+ g_fClipboardStarted = FALSE;
+ g_iClipboardWindow = None;
+ g_pClipboardDisplay = NULL;
+ g_atomLastOwnedSelection = None;
+ g_hwndClipboard = NULL;
+#endif
+}
diff --git a/xorg-server/hw/xwin/winkeybd.c b/xorg-server/hw/xwin/winkeybd.c index bbfeba553..e69edf7c0 100644 --- a/xorg-server/hw/xwin/winkeybd.c +++ b/xorg-server/hw/xwin/winkeybd.c @@ -1,529 +1,529 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - */ - - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include "winkeybd.h" -#include "winconfig.h" -#include "winmsg.h" - -#include "xkbsrv.h" - -static Bool g_winKeyState[NUM_KEYCODES]; - -/* - * Local prototypes - */ - -static void -winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt, - pointer pCtrl, int iClass); - -static void -winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl); - - -/* - * Translate a Windows WM_[SYS]KEY(UP/DOWN) message - * into an ASCII scan code. - * - * We do this ourselves, rather than letting Windows handle it, - * because Windows tends to munge the handling of special keys, - * like AltGr on European keyboards. - */ - -void -winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode) -{ - int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1]; - int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2]; - int iParam = HIWORD (lParam); - int iParamScanCode = LOBYTE (iParam); - -/* WM_ key messages faked by Vista speech recognition (WSR) don't have a - * scan code. - * - * Vocola 3 (Rick Mohr's supplement to WSR) uses - * System.Windows.Forms.SendKeys.SendWait(), which appears always to give a - * scan code of 1 - */ - if (iParamScanCode <= 1) - { - if (VK_PRIOR <= wParam && wParam <= VK_DOWN) - /* Trigger special case table to translate to extended - * keycode, otherwise if num_lock is on, we can get keypad - * numbers instead of navigation keys. */ - iParam |= KF_EXTENDED; - else - iParamScanCode = MapVirtualKeyEx(wParam, - /*MAPVK_VK_TO_VSC*/0, - GetKeyboardLayout(0)); - } - - /* Branch on special extended, special non-extended, or normal key */ - if ((iParam & KF_EXTENDED) && iKeyFixupEx) - *piScanCode = iKeyFixupEx; - else if (iKeyFixup) - *piScanCode = iKeyFixup; - else if (wParam == 0 && iParamScanCode == 0x70) - *piScanCode = KEY_HKTG; - else - switch (iParamScanCode) - { - case 0x70: - *piScanCode = KEY_HKTG; - break; - case 0x73: - *piScanCode = KEY_BSlash2; - break; - default: - *piScanCode = iParamScanCode; - break; - } -} - -/* Ring the keyboard bell (system speaker on PCs) */ -static void -winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt, - pointer pCtrl, int iClass) -{ - /* - * We can't use Beep () here because it uses the PC speaker - * on NT/2000. MessageBeep (MB_OK) will play the default system - * sound on systems with a sound card or it will beep the PC speaker - * on systems that do not have a sound card. - */ - MessageBeep (MB_OK); -} - - -/* Change some keyboard configuration parameters */ -static void -winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl) -{ -} - - -/* - * See Porting Layer Definition - p. 18 - * winKeybdProc is known as a DeviceProc. - */ - -int -winKeybdProc (DeviceIntPtr pDeviceInt, int iState) -{ - DevicePtr pDevice = (DevicePtr) pDeviceInt; - XkbSrvInfoPtr xkbi; - XkbControlsPtr ctrl; - - switch (iState) - { - case DEVICE_INIT: - winConfigKeyboard (pDeviceInt); - - /* FIXME: Maybe we should use winGetKbdLeds () here? */ - defaultKeyboardControl.leds = g_winInfo.keyboard.leds; - - winDebug("Rules = \"%s\" Model = \"%s\" Layout = \"%s\"" - " Variant = \"%s\" Options = \"%s\"\n", - g_winInfo.xkb.rules ? g_winInfo.xkb.rules : "none", - g_winInfo.xkb.model ? g_winInfo.xkb.model : "none", - g_winInfo.xkb.layout ? g_winInfo.xkb.layout : "none", - g_winInfo.xkb.variant ? g_winInfo.xkb.variant : "none", - g_winInfo.xkb.options ? g_winInfo.xkb.options : "none"); - - InitKeyboardDeviceStruct (pDeviceInt, - &g_winInfo.xkb, - winKeybdBell, - winKeybdCtrl); - - xkbi = pDeviceInt->key->xkbInfo; - if ((xkbi != NULL) && (xkbi->desc != NULL)) - { - ctrl = xkbi->desc->ctrls; - ctrl->repeat_delay = g_winInfo.keyboard.delay; - ctrl->repeat_interval = 1000/g_winInfo.keyboard.rate; - } - else - { - winDebug ("winKeybdProc - Error initializing keyboard AutoRepeat\n"); - } - - XkbSetExtension(pDeviceInt, ProcessKeyboardEvent); - break; - - case DEVICE_ON: - pDevice->on = TRUE; - - // immediately copy the state of this keyboard device to the VCK - // (which otherwise happens lazily after the first keypress) - CopyKeyClass(pDeviceInt, inputInfo.keyboard); - break; - - case DEVICE_CLOSE: - case DEVICE_OFF: - pDevice->on = FALSE; - break; - } - - return Success; -} - - -/* - * Detect current mode key states upon server startup. - * - * Simulate a press and release of any key that is currently - * toggled. - */ - -void -winInitializeModeKeyStates (void) -{ - /* Restore NumLock */ - if (GetKeyState (VK_NUMLOCK) & 0x0001) - { - winSendKeyEvent (KEY_NumLock, TRUE); - winSendKeyEvent (KEY_NumLock, FALSE); - } - - /* Restore CapsLock */ - if (GetKeyState (VK_CAPITAL) & 0x0001) - { - winSendKeyEvent (KEY_CapsLock, TRUE); - winSendKeyEvent (KEY_CapsLock, FALSE); - } - - /* Restore ScrollLock */ - if (GetKeyState (VK_SCROLL) & 0x0001) - { - winSendKeyEvent (KEY_ScrollLock, TRUE); - winSendKeyEvent (KEY_ScrollLock, FALSE); - } - - /* Restore KanaLock */ - if (GetKeyState (VK_KANA) & 0x0001) - { - winSendKeyEvent (KEY_HKTG, TRUE); - winSendKeyEvent (KEY_HKTG, FALSE); - } -} - - -/* - * Upon regaining the keyboard focus we must - * resynchronize our internal mode key states - * with the actual state of the keys. - */ - -void -winRestoreModeKeyStates (void) -{ - DWORD dwKeyState; - BOOL processEvents = TRUE; - unsigned short internalKeyStates; - - /* X server is being initialized */ - if (!inputInfo.keyboard) - return; - - /* Only process events if the rootwindow is mapped. The keyboard events - * will cause segfaults otherwise */ - if (WindowTable && WindowTable[0] && WindowTable[0]->mapped == FALSE) - processEvents = FALSE; - - /* Force to process all pending events in the mi event queue */ - if (processEvents) - mieqProcessInputEvents (); - - /* Read the mode key states of our X server */ - /* (stored in the virtual core keyboard) */ - internalKeyStates = XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state); - winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates); - - /* - * NOTE: The C XOR operator, ^, will not work here because it is - * a bitwise operator, not a logical operator. C does not - * have a logical XOR operator, so we use a macro instead. - */ - - /* Has the key state changed? */ - dwKeyState = GetKeyState (VK_NUMLOCK) & 0x0001; - if (WIN_XOR (internalKeyStates & NumLockMask, dwKeyState)) - { - winSendKeyEvent (KEY_NumLock, TRUE); - winSendKeyEvent (KEY_NumLock, FALSE); - } - - /* Has the key state changed? */ - dwKeyState = GetKeyState (VK_CAPITAL) & 0x0001; - if (WIN_XOR (internalKeyStates & LockMask, dwKeyState)) - { - winSendKeyEvent (KEY_CapsLock, TRUE); - winSendKeyEvent (KEY_CapsLock, FALSE); - } - - /* Has the key state changed? */ - dwKeyState = GetKeyState (VK_SCROLL) & 0x0001; - if (WIN_XOR (internalKeyStates & ScrollLockMask, dwKeyState)) - { - winSendKeyEvent (KEY_ScrollLock, TRUE); - winSendKeyEvent (KEY_ScrollLock, FALSE); - } - - /* Has the key state changed? */ - dwKeyState = GetKeyState (VK_KANA) & 0x0001; - if (WIN_XOR (internalKeyStates & KanaMask, dwKeyState)) - { - winSendKeyEvent (KEY_HKTG, TRUE); - winSendKeyEvent (KEY_HKTG, FALSE); - } -} - - -/* - * Look for the lovely fake Control_L press/release generated by Windows - * when AltGr is pressed/released on a non-U.S. keyboard. - */ - -Bool -winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam) -{ - MSG msgNext; - LONG lTime; - Bool fReturn; - - /* - * Fake Ctrl_L presses will be followed by an Alt_R keypress - * with the same timestamp as the Ctrl_L press. - */ - if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN) - && wParam == VK_CONTROL - && (HIWORD (lParam) & KF_EXTENDED) == 0) - { - /* Got a Ctrl_L press */ - - /* Get time of current message */ - lTime = GetMessageTime (); - - /* Look for fake Ctrl_L preceeding an Alt_R press. */ - fReturn = PeekMessage (&msgNext, NULL, - WM_KEYDOWN, WM_SYSKEYDOWN, - PM_NOREMOVE); - - /* - * Try again if the first call fails. - * NOTE: This usually happens when TweakUI is enabled. - */ - if (!fReturn) - { - /* Voodoo to make sure that the Alt_R message has posted */ - Sleep (0); - - /* Look for fake Ctrl_L preceeding an Alt_R press. */ - fReturn = PeekMessage (&msgNext, NULL, - WM_KEYDOWN, WM_SYSKEYDOWN, - PM_NOREMOVE); - } - if (msgNext.message != WM_KEYDOWN && msgNext.message != WM_SYSKEYDOWN) - fReturn = 0; - - /* Is next press an Alt_R with the same timestamp? */ - if (fReturn && msgNext.wParam == VK_MENU - && msgNext.time == lTime - && (HIWORD (msgNext.lParam) & KF_EXTENDED)) - { - /* - * Next key press is Alt_R with same timestamp as current - * Ctrl_L message. Therefore, this Ctrl_L press is a fake - * event, so discard it. - */ - return TRUE; - } - } - - /* - * Fake Ctrl_L releases will be followed by an Alt_R release - * with the same timestamp as the Ctrl_L release. - */ - if ((message == WM_KEYUP || message == WM_SYSKEYUP) - && wParam == VK_CONTROL - && (HIWORD (lParam) & KF_EXTENDED) == 0) - { - /* Got a Ctrl_L release */ - - /* Get time of current message */ - lTime = GetMessageTime (); - - /* Look for fake Ctrl_L release preceeding an Alt_R release. */ - fReturn = PeekMessage (&msgNext, NULL, - WM_KEYUP, WM_SYSKEYUP, - PM_NOREMOVE); - - /* - * Try again if the first call fails. - * NOTE: This usually happens when TweakUI is enabled. - */ - if (!fReturn) - { - /* Voodoo to make sure that the Alt_R message has posted */ - Sleep (0); - - /* Look for fake Ctrl_L release preceeding an Alt_R release. */ - fReturn = PeekMessage (&msgNext, NULL, - WM_KEYUP, WM_SYSKEYUP, - PM_NOREMOVE); - } - - if (msgNext.message != WM_KEYUP && msgNext.message != WM_SYSKEYUP) - fReturn = 0; - - /* Is next press an Alt_R with the same timestamp? */ - if (fReturn - && (msgNext.message == WM_KEYUP - || msgNext.message == WM_SYSKEYUP) - && msgNext.wParam == VK_MENU - && msgNext.time == lTime - && (HIWORD (msgNext.lParam) & KF_EXTENDED)) - { - /* - * Next key release is Alt_R with same timestamp as current - * Ctrl_L message. Therefore, this Ctrl_L release is a fake - * event, so discard it. - */ - return TRUE; - } - } - - /* Not a fake control left press/release */ - return FALSE; -} - - -/* - * Lift any modifier keys that are pressed - */ - -void -winKeybdReleaseKeys (void) -{ - int i; - -#ifdef HAS_DEVWINDOWS - /* Verify that the mi input system has been initialized */ - if (g_fdMessageQueue == WIN_FD_INVALID) - return; -#endif - - /* Loop through all keys */ - for (i = 0; i < NUM_KEYCODES; ++i) - { - /* Pop key if pressed */ - if (g_winKeyState[i]) - winSendKeyEvent (i, FALSE); - - /* Reset pressed flag for keys */ - g_winKeyState[i] = FALSE; - } -} - - -/* - * Take a raw X key code and send an up or down event for it. - * - * Thanks to VNC for inspiration, though it is a simple function. - */ - -void -winSendKeyEvent (DWORD dwKey, Bool fDown) -{ - EventListPtr events; - int i, nevents; - - /* - * When alt-tabing between screens we can get phantom key up messages - * Here we only pass them through it we think we should! - */ - if (g_winKeyState[dwKey] == FALSE && fDown == FALSE) return; - - /* Update the keyState map */ - g_winKeyState[dwKey] = fDown; - - GetEventList(&events); - nevents = GetKeyboardEvents(events, g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE); - - for (i = 0; i < nevents; i++) - mieqEnqueue(g_pwinKeyboard, (InternalEvent*)events[i].event); - - winDebug("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n", - dwKey, fDown, nevents); -} - -BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam) -{ - switch (wParam) - { - case VK_CONTROL: - if ((lParam & 0x1ff0000) == 0x11d0000 && g_winKeyState[KEY_RCtrl]) - return TRUE; - if ((lParam & 0x1ff0000) == 0x01d0000 && g_winKeyState[KEY_LCtrl]) - return TRUE; - break; - case VK_SHIFT: - if ((lParam & 0x1ff0000) == 0x0360000 && g_winKeyState[KEY_ShiftR]) - return TRUE; - if ((lParam & 0x1ff0000) == 0x02a0000 && g_winKeyState[KEY_ShiftL]) - return TRUE; - break; - default: - return TRUE; - } - return FALSE; -} - -/* Only on shift release message is sent even if both are pressed. - * Fix this here - */ -void winFixShiftKeys (int iScanCode) -{ - if (GetKeyState (VK_SHIFT) & 0x8000) - return; - - if (iScanCode == KEY_ShiftL && g_winKeyState[KEY_ShiftR]) - winSendKeyEvent (KEY_ShiftR, FALSE); - if (iScanCode == KEY_ShiftR && g_winKeyState[KEY_ShiftL]) - winSendKeyEvent (KEY_ShiftL, FALSE); -} +/*
+ *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winkeybd.h"
+#include "winconfig.h"
+#include "winmsg.h"
+
+#include "xkbsrv.h"
+
+static Bool g_winKeyState[NUM_KEYCODES];
+
+/*
+ * Local prototypes
+ */
+
+static void
+winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
+ pointer pCtrl, int iClass);
+
+static void
+winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl);
+
+
+/*
+ * Translate a Windows WM_[SYS]KEY(UP/DOWN) message
+ * into an ASCII scan code.
+ *
+ * We do this ourselves, rather than letting Windows handle it,
+ * because Windows tends to munge the handling of special keys,
+ * like AltGr on European keyboards.
+ */
+
+void
+winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode)
+{
+ int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
+ int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
+ int iParam = HIWORD (lParam);
+ int iParamScanCode = LOBYTE (iParam);
+
+/* WM_ key messages faked by Vista speech recognition (WSR) don't have a
+ * scan code.
+ *
+ * Vocola 3 (Rick Mohr's supplement to WSR) uses
+ * System.Windows.Forms.SendKeys.SendWait(), which appears always to give a
+ * scan code of 1
+ */
+ if (iParamScanCode <= 1)
+ {
+ if (VK_PRIOR <= wParam && wParam <= VK_DOWN)
+ /* Trigger special case table to translate to extended
+ * keycode, otherwise if num_lock is on, we can get keypad
+ * numbers instead of navigation keys. */
+ iParam |= KF_EXTENDED;
+ else
+ iParamScanCode = MapVirtualKeyEx(wParam,
+ /*MAPVK_VK_TO_VSC*/0,
+ GetKeyboardLayout(0));
+ }
+
+ /* Branch on special extended, special non-extended, or normal key */
+ if ((iParam & KF_EXTENDED) && iKeyFixupEx)
+ *piScanCode = iKeyFixupEx;
+ else if (iKeyFixup)
+ *piScanCode = iKeyFixup;
+ else if (wParam == 0 && iParamScanCode == 0x70)
+ *piScanCode = KEY_HKTG;
+ else
+ switch (iParamScanCode)
+ {
+ case 0x70:
+ *piScanCode = KEY_HKTG;
+ break;
+ case 0x73:
+ *piScanCode = KEY_BSlash2;
+ break;
+ default:
+ *piScanCode = iParamScanCode;
+ break;
+ }
+}
+
+/* Ring the keyboard bell (system speaker on PCs) */
+static void
+winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
+ pointer pCtrl, int iClass)
+{
+ /*
+ * We can't use Beep () here because it uses the PC speaker
+ * on NT/2000. MessageBeep (MB_OK) will play the default system
+ * sound on systems with a sound card or it will beep the PC speaker
+ * on systems that do not have a sound card.
+ */
+ MessageBeep (MB_OK);
+}
+
+
+/* Change some keyboard configuration parameters */
+static void
+winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl)
+{
+}
+
+
+/*
+ * See Porting Layer Definition - p. 18
+ * winKeybdProc is known as a DeviceProc.
+ */
+
+int
+winKeybdProc (DeviceIntPtr pDeviceInt, int iState)
+{
+ DevicePtr pDevice = (DevicePtr) pDeviceInt;
+ XkbSrvInfoPtr xkbi;
+ XkbControlsPtr ctrl;
+
+ switch (iState)
+ {
+ case DEVICE_INIT:
+ winConfigKeyboard (pDeviceInt);
+
+ /* FIXME: Maybe we should use winGetKbdLeds () here? */
+ defaultKeyboardControl.leds = g_winInfo.keyboard.leds;
+
+ winDebug("Rules = \"%s\" Model = \"%s\" Layout = \"%s\""
+ " Variant = \"%s\" Options = \"%s\"\n",
+ g_winInfo.xkb.rules ? g_winInfo.xkb.rules : "none",
+ g_winInfo.xkb.model ? g_winInfo.xkb.model : "none",
+ g_winInfo.xkb.layout ? g_winInfo.xkb.layout : "none",
+ g_winInfo.xkb.variant ? g_winInfo.xkb.variant : "none",
+ g_winInfo.xkb.options ? g_winInfo.xkb.options : "none");
+
+ InitKeyboardDeviceStruct (pDeviceInt,
+ &g_winInfo.xkb,
+ winKeybdBell,
+ winKeybdCtrl);
+
+ xkbi = pDeviceInt->key->xkbInfo;
+ if ((xkbi != NULL) && (xkbi->desc != NULL))
+ {
+ ctrl = xkbi->desc->ctrls;
+ ctrl->repeat_delay = g_winInfo.keyboard.delay;
+ ctrl->repeat_interval = 1000/g_winInfo.keyboard.rate;
+ }
+ else
+ {
+ winDebug ("winKeybdProc - Error initializing keyboard AutoRepeat\n");
+ }
+
+ XkbSetExtension(pDeviceInt, ProcessKeyboardEvent);
+ break;
+
+ case DEVICE_ON:
+ pDevice->on = TRUE;
+
+ // immediately copy the state of this keyboard device to the VCK
+ // (which otherwise happens lazily after the first keypress)
+ CopyKeyClass(pDeviceInt, inputInfo.keyboard);
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pDevice->on = FALSE;
+ break;
+ }
+
+ return Success;
+}
+
+
+/*
+ * Detect current mode key states upon server startup.
+ *
+ * Simulate a press and release of any key that is currently
+ * toggled.
+ */
+
+void
+winInitializeModeKeyStates (void)
+{
+ /* Restore NumLock */
+ if (GetKeyState (VK_NUMLOCK) & 0x0001)
+ {
+ winSendKeyEvent (KEY_NumLock, TRUE);
+ winSendKeyEvent (KEY_NumLock, FALSE);
+ }
+
+ /* Restore CapsLock */
+ if (GetKeyState (VK_CAPITAL) & 0x0001)
+ {
+ winSendKeyEvent (KEY_CapsLock, TRUE);
+ winSendKeyEvent (KEY_CapsLock, FALSE);
+ }
+
+ /* Restore ScrollLock */
+ if (GetKeyState (VK_SCROLL) & 0x0001)
+ {
+ winSendKeyEvent (KEY_ScrollLock, TRUE);
+ winSendKeyEvent (KEY_ScrollLock, FALSE);
+ }
+
+ /* Restore KanaLock */
+ if (GetKeyState (VK_KANA) & 0x0001)
+ {
+ winSendKeyEvent (KEY_HKTG, TRUE);
+ winSendKeyEvent (KEY_HKTG, FALSE);
+ }
+}
+
+
+/*
+ * Upon regaining the keyboard focus we must
+ * resynchronize our internal mode key states
+ * with the actual state of the keys.
+ */
+
+void
+winRestoreModeKeyStates (void)
+{
+ DWORD dwKeyState;
+ BOOL processEvents = TRUE;
+ unsigned short internalKeyStates;
+
+ /* X server is being initialized */
+ if (!inputInfo.keyboard)
+ return;
+
+ /* Only process events if the rootwindow is mapped. The keyboard events
+ * will cause segfaults otherwise */
+ if (screenInfo.screens[0]->root && screenInfo.screens[0]->root->mapped == FALSE)
+ processEvents = FALSE;
+
+ /* Force to process all pending events in the mi event queue */
+ if (processEvents)
+ mieqProcessInputEvents ();
+
+ /* Read the mode key states of our X server */
+ /* (stored in the virtual core keyboard) */
+ internalKeyStates = XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
+ winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
+
+ /*
+ * NOTE: The C XOR operator, ^, will not work here because it is
+ * a bitwise operator, not a logical operator. C does not
+ * have a logical XOR operator, so we use a macro instead.
+ */
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_NUMLOCK) & 0x0001;
+ if (WIN_XOR (internalKeyStates & NumLockMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_NumLock, TRUE);
+ winSendKeyEvent (KEY_NumLock, FALSE);
+ }
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_CAPITAL) & 0x0001;
+ if (WIN_XOR (internalKeyStates & LockMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_CapsLock, TRUE);
+ winSendKeyEvent (KEY_CapsLock, FALSE);
+ }
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_SCROLL) & 0x0001;
+ if (WIN_XOR (internalKeyStates & ScrollLockMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_ScrollLock, TRUE);
+ winSendKeyEvent (KEY_ScrollLock, FALSE);
+ }
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_KANA) & 0x0001;
+ if (WIN_XOR (internalKeyStates & KanaMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_HKTG, TRUE);
+ winSendKeyEvent (KEY_HKTG, FALSE);
+ }
+}
+
+
+/*
+ * Look for the lovely fake Control_L press/release generated by Windows
+ * when AltGr is pressed/released on a non-U.S. keyboard.
+ */
+
+Bool
+winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam)
+{
+ MSG msgNext;
+ LONG lTime;
+ Bool fReturn;
+
+ /*
+ * Fake Ctrl_L presses will be followed by an Alt_R keypress
+ * with the same timestamp as the Ctrl_L press.
+ */
+ if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
+ && wParam == VK_CONTROL
+ && (HIWORD (lParam) & KF_EXTENDED) == 0)
+ {
+ /* Got a Ctrl_L press */
+
+ /* Get time of current message */
+ lTime = GetMessageTime ();
+
+ /* Look for fake Ctrl_L preceeding an Alt_R press. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYDOWN, WM_SYSKEYDOWN,
+ PM_NOREMOVE);
+
+ /*
+ * Try again if the first call fails.
+ * NOTE: This usually happens when TweakUI is enabled.
+ */
+ if (!fReturn)
+ {
+ /* Voodoo to make sure that the Alt_R message has posted */
+ Sleep (0);
+
+ /* Look for fake Ctrl_L preceeding an Alt_R press. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYDOWN, WM_SYSKEYDOWN,
+ PM_NOREMOVE);
+ }
+ if (msgNext.message != WM_KEYDOWN && msgNext.message != WM_SYSKEYDOWN)
+ fReturn = 0;
+
+ /* Is next press an Alt_R with the same timestamp? */
+ if (fReturn && msgNext.wParam == VK_MENU
+ && msgNext.time == lTime
+ && (HIWORD (msgNext.lParam) & KF_EXTENDED))
+ {
+ /*
+ * Next key press is Alt_R with same timestamp as current
+ * Ctrl_L message. Therefore, this Ctrl_L press is a fake
+ * event, so discard it.
+ */
+ return TRUE;
+ }
+ }
+
+ /*
+ * Fake Ctrl_L releases will be followed by an Alt_R release
+ * with the same timestamp as the Ctrl_L release.
+ */
+ if ((message == WM_KEYUP || message == WM_SYSKEYUP)
+ && wParam == VK_CONTROL
+ && (HIWORD (lParam) & KF_EXTENDED) == 0)
+ {
+ /* Got a Ctrl_L release */
+
+ /* Get time of current message */
+ lTime = GetMessageTime ();
+
+ /* Look for fake Ctrl_L release preceeding an Alt_R release. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYUP, WM_SYSKEYUP,
+ PM_NOREMOVE);
+
+ /*
+ * Try again if the first call fails.
+ * NOTE: This usually happens when TweakUI is enabled.
+ */
+ if (!fReturn)
+ {
+ /* Voodoo to make sure that the Alt_R message has posted */
+ Sleep (0);
+
+ /* Look for fake Ctrl_L release preceeding an Alt_R release. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYUP, WM_SYSKEYUP,
+ PM_NOREMOVE);
+ }
+
+ if (msgNext.message != WM_KEYUP && msgNext.message != WM_SYSKEYUP)
+ fReturn = 0;
+
+ /* Is next press an Alt_R with the same timestamp? */
+ if (fReturn
+ && (msgNext.message == WM_KEYUP
+ || msgNext.message == WM_SYSKEYUP)
+ && msgNext.wParam == VK_MENU
+ && msgNext.time == lTime
+ && (HIWORD (msgNext.lParam) & KF_EXTENDED))
+ {
+ /*
+ * Next key release is Alt_R with same timestamp as current
+ * Ctrl_L message. Therefore, this Ctrl_L release is a fake
+ * event, so discard it.
+ */
+ return TRUE;
+ }
+ }
+
+ /* Not a fake control left press/release */
+ return FALSE;
+}
+
+
+/*
+ * Lift any modifier keys that are pressed
+ */
+
+void
+winKeybdReleaseKeys (void)
+{
+ int i;
+
+#ifdef HAS_DEVWINDOWS
+ /* Verify that the mi input system has been initialized */
+ if (g_fdMessageQueue == WIN_FD_INVALID)
+ return;
+#endif
+
+ /* Loop through all keys */
+ for (i = 0; i < NUM_KEYCODES; ++i)
+ {
+ /* Pop key if pressed */
+ if (g_winKeyState[i])
+ winSendKeyEvent (i, FALSE);
+
+ /* Reset pressed flag for keys */
+ g_winKeyState[i] = FALSE;
+ }
+}
+
+
+/*
+ * Take a raw X key code and send an up or down event for it.
+ *
+ * Thanks to VNC for inspiration, though it is a simple function.
+ */
+
+void
+winSendKeyEvent (DWORD dwKey, Bool fDown)
+{
+ EventListPtr events;
+ int i, nevents;
+
+ /*
+ * When alt-tabing between screens we can get phantom key up messages
+ * Here we only pass them through it we think we should!
+ */
+ if (g_winKeyState[dwKey] == FALSE && fDown == FALSE) return;
+
+ /* Update the keyState map */
+ g_winKeyState[dwKey] = fDown;
+
+ GetEventList(&events);
+ nevents = GetKeyboardEvents(events, g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE);
+
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(g_pwinKeyboard, (InternalEvent*)events[i].event);
+
+ winDebug("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n",
+ dwKey, fDown, nevents);
+}
+
+BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam)
+{
+ switch (wParam)
+ {
+ case VK_CONTROL:
+ if ((lParam & 0x1ff0000) == 0x11d0000 && g_winKeyState[KEY_RCtrl])
+ return TRUE;
+ if ((lParam & 0x1ff0000) == 0x01d0000 && g_winKeyState[KEY_LCtrl])
+ return TRUE;
+ break;
+ case VK_SHIFT:
+ if ((lParam & 0x1ff0000) == 0x0360000 && g_winKeyState[KEY_ShiftR])
+ return TRUE;
+ if ((lParam & 0x1ff0000) == 0x02a0000 && g_winKeyState[KEY_ShiftL])
+ return TRUE;
+ break;
+ default:
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/* Only on shift release message is sent even if both are pressed.
+ * Fix this here
+ */
+void winFixShiftKeys (int iScanCode)
+{
+ if (GetKeyState (VK_SHIFT) & 0x8000)
+ return;
+
+ if (iScanCode == KEY_ShiftL && g_winKeyState[KEY_ShiftR])
+ winSendKeyEvent (KEY_ShiftR, FALSE);
+ if (iScanCode == KEY_ShiftR && g_winKeyState[KEY_ShiftL])
+ winSendKeyEvent (KEY_ShiftL, FALSE);
+}
diff --git a/xorg-server/hw/xwin/winmultiwindowshape.c b/xorg-server/hw/xwin/winmultiwindowshape.c index 32a3f16e6..9219bb708 100644 --- a/xorg-server/hw/xwin/winmultiwindowshape.c +++ b/xorg-server/hw/xwin/winmultiwindowshape.c @@ -1,218 +1,215 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Kensuke Matsuzaki - * Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include "win.h" - - -/* - * winSetShapeMultiWindow - See Porting Layer Definition - p. 42 - */ - -void -winSetShapeMultiWindow (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - winScreenPriv(pScreen); - - winDebug ("winSetShapeMultiWindow - pWin: %08x\n", pWin); - - WIN_UNWRAP(SetShape); - (*pScreen->SetShape)(pWin); - WIN_WRAP(SetShape, winSetShapeMultiWindow); - - /* Update the Windows window's shape */ - winReshapeMultiWindow (pWin); - winUpdateRgnMultiWindow (pWin); - - return; -} - - -/* - * winUpdateRgnMultiWindow - Local function to update a Windows window region - */ - -void -winUpdateRgnMultiWindow (WindowPtr pWin) -{ - SetWindowRgn (winGetWindowPriv(pWin)->hWnd, - winGetWindowPriv(pWin)->hRgn, TRUE); - - /* The system now owns the region specified by the region handle and will delete it when it is no longer needed. */ - winGetWindowPriv(pWin)->hRgn = NULL; -} - - -/* - * winReshapeMultiWindow - Computes the composite clipping region for a window - */ - -void -winReshapeMultiWindow (WindowPtr pWin) -{ - int nRects; - RegionRec rrNewShape; - BoxPtr pShape, pRects, pEnd; - HRGN hRgn, hRgnRect; - winWindowPriv(pWin); - - winDebug ("winReshape ()\n"); - - /* Bail if the window is the root window */ - if (pWin->parent == NULL) - return; - - /* Bail if the window is not top level */ - if (pWin->parent->parent != NULL) - return; - - /* Bail if Windows window handle is invalid */ - if (pWinPriv->hWnd == NULL) - return; - - /* Free any existing window region stored in the window privates */ - if (pWinPriv->hRgn != NULL) - { - DeleteObject (pWinPriv->hRgn); - pWinPriv->hRgn = NULL; - } - - /* Bail if the window has no bounding region defined */ - if (!wBoundingShape (pWin)) - return; - - REGION_NULL(pWin->drawable.pScreen, &rrNewShape); - REGION_COPY(pWin->drawable.pScreen, &rrNewShape, wBoundingShape(pWin)); - REGION_TRANSLATE(pWin->drawable.pScreen, - &rrNewShape, - pWin->borderWidth, - pWin->borderWidth); - - nRects = REGION_NUM_RECTS(&rrNewShape); - pShape = REGION_RECTS(&rrNewShape); - - /* Don't do anything if there are no rectangles in the region */ - if (nRects > 0) - { - RECT rcClient; - RECT rcWindow; - int iOffsetX, iOffsetY; - - /* Get client rectangle */ - if (!GetClientRect (pWinPriv->hWnd, &rcClient)) - { - ErrorF ("winReshape - GetClientRect failed, bailing: %d\n", - (int) GetLastError ()); - return; - } - - /* Translate client rectangle coords to screen coords */ - /* NOTE: Only transforms top and left members */ - ClientToScreen (pWinPriv->hWnd, (LPPOINT) &rcClient); - - /* Get window rectangle */ - if (!GetWindowRect (pWinPriv->hWnd, &rcWindow)) - { - ErrorF ("winReshape - GetWindowRect failed, bailing: %d\n", - (int) GetLastError ()); - return; - } - - /* Calculate offset from window upper-left to client upper-left */ - iOffsetX = rcClient.left - rcWindow.left; - iOffsetY = rcClient.top - rcWindow.top; - - /* Create initial Windows region for title bar */ - /* FIXME: Mean, nasty, ugly hack!!! */ - hRgn = CreateRectRgn (0, 0, rcWindow.right, iOffsetY); - if (hRgn == NULL) - { - ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) " - "failed: %d\n", - 0, 0, (int) rcWindow.right, iOffsetY, (int) GetLastError ()); - } - - /* Loop through all rectangles in the X region */ - for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++) - { - /* Create a Windows region for the X rectangle */ - hRgnRect = CreateRectRgn (pRects->x1 + iOffsetX, - pRects->y1 + iOffsetY, - pRects->x2 + iOffsetX, - pRects->y2 + iOffsetY); - if (hRgnRect == NULL) - { - ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) " - "failed: %d\n" - "\tx1: %d x2: %d xOff: %d y1: %d y2: %d yOff: %d\n", - pRects->x1 + iOffsetX, - pRects->y1 + iOffsetY, - pRects->x2 + iOffsetX, - pRects->y2 + iOffsetY, - (int) GetLastError (), - pRects->x1, pRects->x2, iOffsetX, - pRects->y1, pRects->y2, iOffsetY); - } - - /* Merge the Windows region with the accumulated region */ - if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR) - { - ErrorF ("winReshape - CombineRgn () failed: %d\n", - (int) GetLastError ()); - } - - /* Delete the temporary Windows region */ - DeleteObject (hRgnRect); - } - - /* Save a handle to the composite region in the window privates */ - pWinPriv->hRgn = hRgn; - } - - REGION_UNINIT(pWin->drawable.pScreen, &rrNewShape); - - return; -} - -void -winShapeRgnUpdateMultiwindow(HWND hwnd) -{ - WindowPtr pWin = GetProp (hwnd, WIN_WINDOW_PROP); - if (pWin) - { - winReshapeMultiWindow(pWin); - winUpdateRgnMultiWindow(pWin); - } -} +/*
+ *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+
+#include "win.h"
+
+
+/*
+ * winSetShapeMultiWindow - See Porting Layer Definition - p. 42
+ */
+
+void
+winSetShapeMultiWindow (WindowPtr pWin, int kind)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winScreenPriv(pScreen);
+
+ winDebug ("winSetShapeMultiWindow - pWin: %08x kind: %i\n", pWin, kind);
+
+ WIN_UNWRAP(SetShape);
+ (*pScreen->SetShape)(pWin, kind);
+ WIN_WRAP(SetShape, winSetShapeMultiWindow);
+
+ /* Update the Windows window's shape */
+ winReshapeMultiWindow (pWin);
+ winUpdateRgnMultiWindow (pWin);
+
+ return;
+}
+
+
+/*
+ * winUpdateRgnMultiWindow - Local function to update a Windows window region
+ */
+
+void
+winUpdateRgnMultiWindow (WindowPtr pWin)
+{
+ SetWindowRgn (winGetWindowPriv(pWin)->hWnd,
+ winGetWindowPriv(pWin)->hRgn, TRUE);
+
+ /* The system now owns the region specified by the region handle and will delete it when it is no longer needed. */
+ winGetWindowPriv(pWin)->hRgn = NULL;
+}
+
+
+/*
+ * winReshapeMultiWindow - Computes the composite clipping region for a window
+ */
+
+void
+winReshapeMultiWindow (WindowPtr pWin)
+{
+ int nRects;
+ RegionRec rrNewShape;
+ BoxPtr pShape, pRects, pEnd;
+ HRGN hRgn, hRgnRect;
+ winWindowPriv(pWin);
+
+ winDebug ("winReshape ()\n");
+
+ /* Bail if the window is the root window */
+ if (pWin->parent == NULL)
+ return;
+
+ /* Bail if the window is not top level */
+ if (pWin->parent->parent != NULL)
+ return;
+
+ /* Bail if Windows window handle is invalid */
+ if (pWinPriv->hWnd == NULL)
+ return;
+
+ /* Free any existing window region stored in the window privates */
+ if (pWinPriv->hRgn != NULL)
+ {
+ DeleteObject (pWinPriv->hRgn);
+ pWinPriv->hRgn = NULL;
+ }
+
+ /* Bail if the window has no bounding region defined */
+ if (!wBoundingShape (pWin))
+ return;
+
+ RegionNull(&rrNewShape);
+ RegionCopy(&rrNewShape, wBoundingShape(pWin));
+ RegionTranslate(&rrNewShape, pWin->borderWidth, pWin->borderWidth);
+
+ nRects = RegionNumRects(&rrNewShape);
+ pShape = RegionRects(&rrNewShape);
+
+ /* Don't do anything if there are no rectangles in the region */
+ if (nRects > 0)
+ {
+ RECT rcClient;
+ RECT rcWindow;
+ int iOffsetX, iOffsetY;
+
+ /* Get client rectangle */
+ if (!GetClientRect (pWinPriv->hWnd, &rcClient))
+ {
+ ErrorF ("winReshape - GetClientRect failed, bailing: %d\n",
+ (int) GetLastError ());
+ return;
+ }
+
+ /* Translate client rectangle coords to screen coords */
+ /* NOTE: Only transforms top and left members */
+ ClientToScreen (pWinPriv->hWnd, (LPPOINT) &rcClient);
+
+ /* Get window rectangle */
+ if (!GetWindowRect (pWinPriv->hWnd, &rcWindow))
+ {
+ ErrorF ("winReshape - GetWindowRect failed, bailing: %d\n",
+ (int) GetLastError ());
+ return;
+ }
+
+ /* Calculate offset from window upper-left to client upper-left */
+ iOffsetX = rcClient.left - rcWindow.left;
+ iOffsetY = rcClient.top - rcWindow.top;
+
+ /* Create initial Windows region for title bar */
+ /* FIXME: Mean, nasty, ugly hack!!! */
+ hRgn = CreateRectRgn (0, 0, rcWindow.right, iOffsetY);
+ if (hRgn == NULL)
+ {
+ ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n",
+ 0, 0, (int) rcWindow.right, iOffsetY, (int) GetLastError ());
+ }
+
+ /* Loop through all rectangles in the X region */
+ for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++)
+ {
+ /* Create a Windows region for the X rectangle */
+ hRgnRect = CreateRectRgn (pRects->x1 + iOffsetX,
+ pRects->y1 + iOffsetY,
+ pRects->x2 + iOffsetX,
+ pRects->y2 + iOffsetY);
+ if (hRgnRect == NULL)
+ {
+ ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n"
+ "\tx1: %d x2: %d xOff: %d y1: %d y2: %d yOff: %d\n",
+ pRects->x1 + iOffsetX,
+ pRects->y1 + iOffsetY,
+ pRects->x2 + iOffsetX,
+ pRects->y2 + iOffsetY,
+ (int) GetLastError (),
+ pRects->x1, pRects->x2, iOffsetX,
+ pRects->y1, pRects->y2, iOffsetY);
+ }
+
+ /* Merge the Windows region with the accumulated region */
+ if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
+ {
+ ErrorF ("winReshape - CombineRgn () failed: %d\n",
+ (int) GetLastError ());
+ }
+
+ /* Delete the temporary Windows region */
+ DeleteObject (hRgnRect);
+ }
+
+ /* Save a handle to the composite region in the window privates */
+ pWinPriv->hRgn = hRgn;
+ }
+
+ RegionUninit(&rrNewShape);
+
+ return;
+}
+
+void
+winShapeRgnUpdateMultiwindow(HWND hwnd)
+{
+ WindowPtr pWin = GetProp (hwnd, WIN_WINDOW_PROP);
+ if (pWin)
+ {
+ winReshapeMultiWindow(pWin);
+ winUpdateRgnMultiWindow(pWin);
+ }
+}
diff --git a/xorg-server/hw/xwin/winprefs.c b/xorg-server/hw/xwin/winprefs.c index 3becb436a..4d34e41a1 100644 --- a/xorg-server/hw/xwin/winprefs.c +++ b/xorg-server/hw/xwin/winprefs.c @@ -1,875 +1,871 @@ -/* - * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * Copyright (C) Colin Harrison 2005-2008 - * - * 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 XFREE86 PROJECT 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 of the XFree86 Project - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * from the XFree86 Project. - * - * Authors: Earle F. Philhower, III - * Colin Harrison - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include <stdio.h> -#include <stdlib.h> -#ifdef __CYGWIN__ -#include <sys/resource.h> -#endif -#include "win.h" - -#include <X11/Xwindows.h> -#include <shellapi.h> - -#include "winprefs.h" -#include "winmultiwindowclass.h" - -/* Where will the custom menu commands start counting from? */ -#define STARTMENUID WM_USER - -/* External global variables */ -#ifdef XWIN_MULTIWINDOW -extern DWORD g_dwCurrentThreadID; -#endif - -extern const char *winGetBaseDir(void); - -extern const char *g_pszLogFile; - -/* From winmultiwindowflex.l, the real parser */ -extern void parse_file (FILE *fp); - -/* From winprefyacc.y, the pref structure loaded by the parser */ -extern WINPREFS pref; - -/* The global X default icon */ -extern HICON g_hIconX; -extern HICON g_hSmallIconX; - -/* Currently in use command ID, incremented each new menu item created */ -static int g_cmdid = STARTMENUID; - - -/* Defined in DIX */ -extern char *display; - -/* Local function to handle comma-ified icon names */ -static HICON -LoadImageComma (char *fname, int sx, int sy, int flags); - - -/* - * Creates or appends a menu from a MENUPARSED structure - */ -static HMENU -MakeMenu (char *name, - HMENU editMenu, - int editItem) -{ - int i; - int item; - MENUPARSED *m; - HMENU hmenu, hsub; - - for (i=0; i<pref.menuItems; i++) - { - if (!strcmp(name, pref.menu[i].menuName)) - break; - } - - /* Didn't find a match, bummer */ - if (i==pref.menuItems) - { - ErrorF("MakeMenu: Can't find menu %s\n", name); - return NULL; - } - - m = &(pref.menu[i]); - - if (editMenu) - { - hmenu = editMenu; - item = editItem; - } - else - { - hmenu = CreatePopupMenu(); - if (!hmenu) - { - ErrorF("MakeMenu: Unable to CreatePopupMenu() %s\n", name); - return NULL; - } - item = 0; - } - - /* Add the menu items */ - for (i=0; i<m->menuItems; i++) - { - /* Only assign IDs one time... */ - if ( m->menuItem[i].commandID == 0 ) - m->menuItem[i].commandID = g_cmdid++; - - switch (m->menuItem[i].cmd) - { - case CMD_EXEC: - case CMD_ALWAYSONTOP: - case CMD_RELOAD: - InsertMenu (hmenu, - item, - MF_BYPOSITION|MF_ENABLED|MF_STRING, - m->menuItem[i].commandID, - m->menuItem[i].text); - break; - - case CMD_SEPARATOR: - InsertMenu (hmenu, - item, - MF_BYPOSITION|MF_SEPARATOR, - 0, - NULL); - break; - - case CMD_MENU: - /* Recursive! */ - hsub = MakeMenu (m->menuItem[i].param, 0, 0); - if (hsub) - InsertMenu (hmenu, - item, - MF_BYPOSITION|MF_POPUP|MF_ENABLED|MF_STRING, - (UINT_PTR)hsub, - m->menuItem[i].text); - break; - } - - /* If item==-1 (means to add at end of menu) don't increment) */ - if (item>=0) - item++; - } - - return hmenu; -} - - -#ifdef XWIN_MULTIWINDOW -/* - * Callback routine that is executed once per window class. - * Removes or creates custom window settings depending on LPARAM - */ -static wBOOL CALLBACK -ReloadEnumWindowsProc (HWND hwnd, LPARAM lParam) -{ - HICON hicon; - Window wid; - - if (!hwnd) { - ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n"); - return FALSE; - } - - /* It's our baby, either clean or dirty it */ - if (lParam==FALSE) - { - /* Reset the window's icon to undefined. */ - hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0); - - /* If the old icon is generated on-the-fly, get rid of it, will regen */ - winDestroyIcon (hicon); - - /* Same for the small icon */ - hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0); - winDestroyIcon (hicon); - - /* Remove any menu additions; bRevert=TRUE destroys any modified menus */ - GetSystemMenu (hwnd, TRUE); - - /* This window is now clean of our taint (but with undefined icons) */ - } - else - { - /* winUpdateIcon() will set the icon default, dynamic, or from xwinrc */ - wid = (Window)GetProp (hwnd, WIN_WID_PROP); - if (wid) - winUpdateIcon (wid); - - /* Update the system menu for this window */ - SetupSysMenu ((unsigned long)hwnd); - - /* That was easy... */ - } - - return TRUE; -} -#endif - - -/* - * Removes any custom icons in classes, custom menus, etc. - * Frees all members in pref structure. - * Reloads the preferences file. - * Set custom icons and menus again. - */ -static void -ReloadPrefs (void) -{ - int i; - -#ifdef XWIN_MULTIWINDOW - /* First, iterate over all windows, deleting their icons and custom menus. - * This is really only needed because winDestroyIcon() will try to - * destroy the old global icons, which will have changed. - * It is probably better to set a windows USER_DATA to flag locally defined - * icons, and use that to accurately know when to destroy old icons. - */ - EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE); -#endif - - /* Now, free/clear all info from our prefs structure */ - for (i=0; i<pref.menuItems; i++) - free (pref.menu[i].menuItem); - free (pref.menu); - pref.menu = NULL; - pref.menuItems = 0; - - pref.rootMenuName[0] = 0; - - free (pref.sysMenu); - pref.sysMenuItems = 0; - - pref.defaultSysMenuName[0] = 0; - pref.defaultSysMenuPos = 0; - - pref.iconDirectory[0] = 0; - pref.defaultIconName[0] = 0; - pref.trayIconName[0] = 0; - - for (i=0; i<pref.iconItems; i++) - if (pref.icon[i].hicon) - DestroyIcon ((HICON)pref.icon[i].hicon); - free (pref.icon); - pref.icon = NULL; - pref.iconItems = 0; - - /* Free global default X icon */ - if (g_hIconX) - DestroyIcon (g_hIconX); - if (g_hSmallIconX) - DestroyIcon (g_hSmallIconX); - - /* Reset the custom command IDs */ - g_cmdid = STARTMENUID; - - /* Load the updated resource file */ - LoadPreferences(); - - g_hIconX = NULL; - g_hSmallIconX = NULL; - -#ifdef XWIN_MULTIWINDOW - winInitGlobalIcons(); -#endif - -#ifdef XWIN_MULTIWINDOW - /* Rebuild the icons and menus */ - EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, TRUE); -#endif - - /* Whew, done */ -} - -/* - * Check/uncheck the ALWAYSONTOP items in this menu - */ -void -HandleCustomWM_INITMENU(unsigned long hwndIn, - unsigned long hmenuIn) -{ - HWND hwnd; - HMENU hmenu; - DWORD dwExStyle; - int i, j; - - hwnd = (HWND)hwndIn; - hmenu = (HMENU)hmenuIn; - if (!hwnd || !hmenu) - return; - - if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) - dwExStyle = MF_BYCOMMAND | MF_CHECKED; - else - dwExStyle = MF_BYCOMMAND | MF_UNCHECKED; - - for (i=0; i<pref.menuItems; i++) - for (j=0; j<pref.menu[i].menuItems; j++) - if (pref.menu[i].menuItem[j].cmd==CMD_ALWAYSONTOP) - CheckMenuItem (hmenu, pref.menu[i].menuItem[j].commandID, dwExStyle ); - -} - -/* - * Searches for the custom WM_COMMAND command ID and performs action. - * Return TRUE if command is proccessed, FALSE otherwise. - */ -Bool -HandleCustomWM_COMMAND (unsigned long hwndIn, - int command) -{ - HWND hwnd; - int i, j; - MENUPARSED *m; - DWORD dwExStyle; - - hwnd = (HWND)hwndIn; - - if (!command) - return FALSE; - - for (i=0; i<pref.menuItems; i++) - { - m = &(pref.menu[i]); - for (j=0; j<m->menuItems; j++) - { - if (command==m->menuItem[j].commandID) - { - /* Match! */ - switch(m->menuItem[j].cmd) - { -#ifdef __CYGWIN__ - case CMD_EXEC: - if (fork()==0) - { - struct rlimit rl; - unsigned long i; - - /* Close any open descriptors except for STD* */ - getrlimit (RLIMIT_NOFILE, &rl); - for (i = STDERR_FILENO+1; i < rl.rlim_cur; i++) - close(i); - - /* Disassociate any TTYs */ - setsid(); - - execl ("/bin/sh", - "/bin/sh", - "-c", - m->menuItem[j].param, - NULL); - exit (0); - } - else - return TRUE; - break; -#else - case CMD_EXEC: - { - /* Start process without console window */ - STARTUPINFO start; - PROCESS_INFORMATION child; - - memset (&start, 0, sizeof (start)); - start.cb = sizeof (start); - //start.dwFlags = STARTF_USESHOWWINDOW; - //start.wShowWindow = SW_HIDE; - - memset (&child, 0, sizeof (child)); - - if (CreateProcess (NULL, m->menuItem[j].param, NULL, NULL, FALSE, 0, - NULL, NULL, &start, &child)) - { - CloseHandle (child.hThread); - CloseHandle (child.hProcess); - } - else - MessageBox(NULL, m->menuItem[j].param, "VcXsrv Exec Command Error!", MB_OK | MB_ICONEXCLAMATION); - } - return TRUE; -#endif - case CMD_ALWAYSONTOP: - if (!hwnd) - return FALSE; - - /* Get extended window style */ - dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE); - - /* Handle topmost windows */ - if (dwExStyle & WS_EX_TOPMOST) - SetWindowPos (hwnd, - HWND_NOTOPMOST, - 0, 0, - 0, 0, - SWP_NOSIZE | SWP_NOMOVE); - else - SetWindowPos (hwnd, - HWND_TOPMOST, - 0, 0, - 0, 0, - SWP_NOSIZE | SWP_NOMOVE); -#if XWIN_MULTIWINDOW - /* Reflect the changed Z order */ - winReorderWindowsMultiWindow (); -#endif - return TRUE; - - case CMD_RELOAD: - ReloadPrefs(); - return TRUE; - - default: - return FALSE; - } - } /* match */ - } /* for j */ - } /* for i */ - - return FALSE; -} - - -#ifdef XWIN_MULTIWINDOW -/* - * Add the default or a custom menu depending on the class match - */ -void -SetupSysMenu (unsigned long hwndIn) -{ - HWND hwnd; - HMENU sys; - int i; - WindowPtr pWin; - char *res_name, *res_class; - - hwnd = (HWND)hwndIn; - if (!hwnd) - return; - - pWin = GetProp (hwnd, WIN_WINDOW_PROP); - - sys = GetSystemMenu (hwnd, FALSE); - if (!sys) - return; - - if (pWin) - { - /* First see if there's a class match... */ - if (winMultiWindowGetClassHint (pWin, &res_name, &res_class)) - { - for (i=0; i<pref.sysMenuItems; i++) - { - if (!strcmp(pref.sysMenu[i].match, res_name) || - !strcmp(pref.sysMenu[i].match, res_class) ) - { - free(res_name); - free(res_class); - - MakeMenu (pref.sysMenu[i].menuName, sys, - pref.sysMenu[i].menuPos==AT_START?0:-1); - return; - } - } - - /* No match, just free alloc'd strings */ - free(res_name); - free(res_class); - } /* Found wm_class */ - } /* if pwin */ - - /* Fallback to system default */ - if (pref.defaultSysMenuName[0]) - { - if (pref.defaultSysMenuPos==AT_START) - MakeMenu (pref.defaultSysMenuName, sys, 0); - else - MakeMenu (pref.defaultSysMenuName, sys, -1); - } -} -#endif - - -/* - * Possibly add a menu to the toolbar icon - */ -void -SetupRootMenu (unsigned long hmenuRoot) -{ - HMENU root; - - root = (HMENU)hmenuRoot; - if (!root) - return; - - if (pref.rootMenuName[0]) - { - MakeMenu(pref.rootMenuName, root, 0); - } -} - - -/* - * Check for and return an overridden default ICON specified in the prefs - */ -HICON -winOverrideDefaultIcon(int size) -{ - HICON hicon; - - if (pref.defaultIconName[0]) - { - hicon = LoadImageComma (pref.defaultIconName, size, size, 0); - if (hicon==NULL) - ErrorF ("winOverrideDefaultIcon: LoadImageComma(%s) failed\n", - pref.defaultIconName); - - return hicon; - } - - return 0; -} - - -/* - * Return the HICON to use in the taskbar notification area - */ -HICON -winTaskbarIcon(void) -{ - HICON hicon; - - hicon = 0; - /* First try and load an overridden, if success then return it */ - if (pref.trayIconName[0]) - { - hicon = LoadImageComma (pref.trayIconName, - GetSystemMetrics (SM_CXSMICON), - GetSystemMetrics (SM_CYSMICON), - 0 ); - } - - /* Otherwise return the default */ - if (!hicon) - hicon = (HICON) LoadImage (g_hInstance, - MAKEINTRESOURCE(IDI_XWIN), - IMAGE_ICON, - GetSystemMetrics (SM_CXSMICON), - GetSystemMetrics (SM_CYSMICON), - 0); - - return hicon; -} - - -/* - * Parse a filename to extract an icon: - * If fname is exactly ",nnn" then extract icon from our resource - * else if it is "file,nnn" then extract icon nnn from that file - * else try to load it as an .ico file and if that fails return NULL - */ -static HICON -LoadImageComma (char *fname, int sx, int sy, int flags) -{ - HICON hicon; - int index; - char file[PATH_MAX+NAME_MAX+2]; - - /* Some input error checking */ - if (!fname || !fname[0]) - return NULL; - - index = 0; - hicon = NULL; - - if (fname[0]==',') - { - /* It's the XWIN.EXE resource they want */ - index = atoi (fname+1); - hicon = LoadImage (g_hInstance, - MAKEINTRESOURCE(index), - IMAGE_ICON, - sx, - sy, - flags); - } - else - { - file[0] = 0; - /* Prepend path if not given a "X:\" filename */ - if ( !(fname[0] && fname[1]==':' && fname[2]=='\\') ) - { - strcpy (file, pref.iconDirectory); - if (pref.iconDirectory[0]) - if (fname[strlen(fname)-1]!='\\') - strcat (file, "\\"); - } - strcat (file, fname); - - if (strrchr (file, ',')) - { - /* Specified as <fname>,<index> */ - - *(strrchr (file, ',')) = 0; /* End string at comma */ - index = atoi (strrchr (fname, ',') + 1); - hicon = ExtractIcon (g_hInstance, file, index); - } - else - { - /* Just an .ico file... */ - - hicon = (HICON)LoadImage (NULL, - file, - IMAGE_ICON, - sx, - sy, - LR_LOADFROMFILE|flags); - } - } - return hicon; -} - -/* - * Check for a match of the window class to one specified in the - * ICONS{} section in the prefs file, and load the icon from a file - */ -HICON -winOverrideIcon (unsigned long longWin) -{ - WindowPtr pWin = (WindowPtr) longWin; - char *res_name, *res_class; - int i; - HICON hicon; - char *wmName; - - if (pWin==NULL) - return 0; - - /* If we can't find the class, we can't override from default! */ - if (!winMultiWindowGetClassHint (pWin, &res_name, &res_class)) - return 0; - - winMultiWindowGetWMName (pWin, &wmName); - - for (i=0; i<pref.iconItems; i++) { - if (!strcmp(pref.icon[i].match, res_name) || - !strcmp(pref.icon[i].match, res_class) || - (wmName && strstr(wmName, pref.icon[i].match))) - { - free (res_name); - free (res_class); - if (wmName) - free (wmName); - - if (pref.icon[i].hicon) - return pref.icon[i].hicon; - - hicon = LoadImageComma (pref.icon[i].iconFile, 0, 0, LR_DEFAULTSIZE); - if (hicon==NULL) - ErrorF ("winOverrideIcon: LoadImageComma(%s) failed\n", - pref.icon[i].iconFile); - - pref.icon[i].hicon = hicon; - return hicon; - } - } - - /* Didn't find the icon, fail gracefully */ - free (res_name); - free (res_class); - if (wmName) - free (wmName); - - return 0; -} - - -/* - * Should we free this icon or leave it in memory (is it part of our - * ICONS{} overrides)? - */ -int -winIconIsOverride(unsigned hiconIn) -{ - HICON hicon; - int i; - - hicon = (HICON)hiconIn; - - if (!hicon) - return 0; - - for (i=0; i<pref.iconItems; i++) - if ((HICON)pref.icon[i].hicon == hicon) - return 1; - - return 0; -} - - - -/* - * Try and open ~/.XWinrc and system.XWinrc - * Load it into prefs structure for use by other functions - */ -void -LoadPreferences (void) -{ - char *home; - char fname[PATH_MAX+NAME_MAX+2]; - FILE *prefFile; - char szDisplay[512]; - char *szEnvDisplay; - int i, j; - char param[PARAM_MAX+1]; - char *srcParam, *dstParam; - - /* First, clear all preference settings */ - memset (&pref, 0, sizeof(pref)); - prefFile = NULL; - - /* Now try and find a ~/.xwinrc file */ - home = getenv ("HOME"); - if (home) - { - strcpy (fname, home); - if (fname[strlen(fname)-1]!='/') - strcat (fname, "/"); - strcat (fname, ".XWinrc"); - - prefFile = fopen (fname, "r"); - if (prefFile) - { - winDebug ("winPrefsLoadPreferences: %s\n", fname); - } - } - - /* No home file found, check system default */ - if (!prefFile) - { - char buffer[MAX_PATH]; -#ifdef RELOCATE_PROJECTROOT - snprintf(buffer, sizeof(buffer), "%s\\system.XWinrc", winGetBaseDir()); -#else - strncpy(buffer, SYSCONFDIR"/X11/system.XWinrc", sizeof(buffer)); -#endif - buffer[sizeof(buffer)-1] = 0; - prefFile = fopen (buffer, "r"); - if (prefFile) - { - winDebug ("winPrefsLoadPreferences: %s\n", buffer); - } - } - - /* If we could open it, then read the settings and close it */ - if (prefFile) - { - parse_file (prefFile); - fclose (prefFile); - } - - /* Setup a DISPLAY environment variable, need to allocate on heap */ - /* because putenv doesn't copy the argument... Always use screen 0 */ - winGetDisplayName(szDisplay, 0); - szEnvDisplay = (char *)(malloc(strlen(szDisplay)+9/*strlen("DISPLAY=")+1*/)); - snprintf(szEnvDisplay, 512, "DISPLAY=%s", szDisplay); - putenv (szEnvDisplay); - - /* Replace any "%display%" in menu commands with display string */ - for (i=0; i<pref.menuItems; i++) - { - for (j=0; j<pref.menu[i].menuItems; j++) - { - if (pref.menu[i].menuItem[j].cmd==CMD_EXEC) - { - srcParam = pref.menu[i].menuItem[j].param; - dstParam = param; - while (*srcParam) { - if (!strncmp(srcParam, "%display%", 9)) - { - memcpy (dstParam, szDisplay, strlen(szDisplay)); - dstParam += strlen(szDisplay); - srcParam += 9; - } - else if (!strncmp(srcParam, "%logfile%", 9)) - { - memcpy (dstParam, g_pszLogFile, strlen(g_pszLogFile)); - dstParam += strlen(g_pszLogFile); - srcParam += 9; - } - else - { - *dstParam = *srcParam; - dstParam++; - srcParam++; - } - } - *dstParam = 0; - strcpy (pref.menu[i].menuItem[j].param, param); - } /* cmd==cmd_exec */ - } /* for all menuitems */ - } /* for all menus */ - -} - - -/* - * Check for a match of the window class to one specified in the - * STYLES{} section in the prefs file, and return the style type - */ -unsigned long -winOverrideStyle (unsigned long longpWin) -{ - WindowPtr pWin = (WindowPtr) longpWin; - char *res_name, *res_class; - int i; - char *wmName; - - if (pWin==NULL) - return STYLE_NONE; - - /* If we can't find the class, we can't override from default! */ - if (!winMultiWindowGetClassHint (pWin, &res_name, &res_class)) - return STYLE_NONE; - - winMultiWindowGetWMName (pWin, &wmName); - - for (i=0; i<pref.styleItems; i++) { - if (!strcmp(pref.style[i].match, res_name) || - !strcmp(pref.style[i].match, res_class) || - (wmName && strstr(wmName, pref.style[i].match))) - { - free (res_name); - free (res_class); - if (wmName) - free (wmName); - - if (pref.style[i].type) - return pref.style[i].type; - } - } - - /* Didn't find the style, fail gracefully */ - free (res_name); - free (res_class); - if (wmName) - free (wmName); - - return STYLE_NONE; -} +/*
+ * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ * Copyright (C) Colin Harrison 2005-2008
+ *
+ * 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 XFREE86 PROJECT 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 of the XFree86 Project
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from the XFree86 Project.
+ *
+ * Authors: Earle F. Philhower, III
+ * Colin Harrison
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef __CYGWIN__
+#include <sys/resource.h>
+#endif
+#include "win.h"
+
+#include <X11/Xwindows.h>
+#include <shellapi.h>
+
+#include "winprefs.h"
+#include "winmultiwindowclass.h"
+
+/* Where will the custom menu commands start counting from? */
+#define STARTMENUID WM_USER
+
+/* External global variables */
+#ifdef XWIN_MULTIWINDOW
+extern DWORD g_dwCurrentThreadID;
+#endif
+
+extern const char *winGetBaseDir(void);
+
+extern const char *g_pszLogFile;
+
+/* From winmultiwindowflex.l, the real parser */
+extern void parse_file (FILE *fp);
+
+/* From winprefyacc.y, the pref structure loaded by the parser */
+extern WINPREFS pref;
+
+/* The global X default icon */
+extern HICON g_hIconX;
+extern HICON g_hSmallIconX;
+
+/* Currently in use command ID, incremented each new menu item created */
+static int g_cmdid = STARTMENUID;
+
+
+/* Defined in DIX */
+extern char *display;
+
+/* Local function to handle comma-ified icon names */
+static HICON
+LoadImageComma (char *fname, int sx, int sy, int flags);
+
+
+/*
+ * Creates or appends a menu from a MENUPARSED structure
+ */
+static HMENU
+MakeMenu (char *name,
+ HMENU editMenu,
+ int editItem)
+{
+ int i;
+ int item;
+ MENUPARSED *m;
+ HMENU hmenu, hsub;
+
+ for (i=0; i<pref.menuItems; i++)
+ {
+ if (!strcmp(name, pref.menu[i].menuName))
+ break;
+ }
+
+ /* Didn't find a match, bummer */
+ if (i==pref.menuItems)
+ {
+ ErrorF("MakeMenu: Can't find menu %s\n", name);
+ return NULL;
+ }
+
+ m = &(pref.menu[i]);
+
+ if (editMenu)
+ {
+ hmenu = editMenu;
+ item = editItem;
+ }
+ else
+ {
+ hmenu = CreatePopupMenu();
+ if (!hmenu)
+ {
+ ErrorF("MakeMenu: Unable to CreatePopupMenu() %s\n", name);
+ return NULL;
+ }
+ item = 0;
+ }
+
+ /* Add the menu items */
+ for (i=0; i<m->menuItems; i++)
+ {
+ /* Only assign IDs one time... */
+ if ( m->menuItem[i].commandID == 0 )
+ m->menuItem[i].commandID = g_cmdid++;
+
+ switch (m->menuItem[i].cmd)
+ {
+ case CMD_EXEC:
+ case CMD_ALWAYSONTOP:
+ case CMD_RELOAD:
+ InsertMenu (hmenu,
+ item,
+ MF_BYPOSITION|MF_ENABLED|MF_STRING,
+ m->menuItem[i].commandID,
+ m->menuItem[i].text);
+ break;
+
+ case CMD_SEPARATOR:
+ InsertMenu (hmenu,
+ item,
+ MF_BYPOSITION|MF_SEPARATOR,
+ 0,
+ NULL);
+ break;
+
+ case CMD_MENU:
+ /* Recursive! */
+ hsub = MakeMenu (m->menuItem[i].param, 0, 0);
+ if (hsub)
+ InsertMenu (hmenu,
+ item,
+ MF_BYPOSITION|MF_POPUP|MF_ENABLED|MF_STRING,
+ (UINT_PTR)hsub,
+ m->menuItem[i].text);
+ break;
+ }
+
+ /* If item==-1 (means to add at end of menu) don't increment) */
+ if (item>=0)
+ item++;
+ }
+
+ return hmenu;
+}
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * Callback routine that is executed once per window class.
+ * Removes or creates custom window settings depending on LPARAM
+ */
+static wBOOL CALLBACK
+ReloadEnumWindowsProc (HWND hwnd, LPARAM lParam)
+{
+ HICON hicon;
+ Window wid;
+
+ if (!hwnd) {
+ ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n");
+ return FALSE;
+ }
+
+ /* It's our baby, either clean or dirty it */
+ if (lParam==FALSE)
+ {
+ /* Reset the window's icon to undefined. */
+ hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0);
+
+ /* If the old icon is generated on-the-fly, get rid of it, will regen */
+ winDestroyIcon (hicon);
+
+ /* Same for the small icon */
+ hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0);
+ winDestroyIcon (hicon);
+
+ /* Remove any menu additions; bRevert=TRUE destroys any modified menus */
+ GetSystemMenu (hwnd, TRUE);
+
+ /* This window is now clean of our taint (but with undefined icons) */
+ }
+ else
+ {
+ /* winUpdateIcon() will set the icon default, dynamic, or from xwinrc */
+ wid = (Window)GetProp (hwnd, WIN_WID_PROP);
+ if (wid)
+ winUpdateIcon (wid);
+
+ /* Update the system menu for this window */
+ SetupSysMenu ((unsigned long)hwnd);
+
+ /* That was easy... */
+ }
+
+ return TRUE;
+}
+#endif
+
+
+/*
+ * Removes any custom icons in classes, custom menus, etc.
+ * Frees all members in pref structure.
+ * Reloads the preferences file.
+ * Set custom icons and menus again.
+ */
+static void
+ReloadPrefs (void)
+{
+ int i;
+
+#ifdef XWIN_MULTIWINDOW
+ /* First, iterate over all windows, deleting their icons and custom menus.
+ * This is really only needed because winDestroyIcon() will try to
+ * destroy the old global icons, which will have changed.
+ * It is probably better to set a windows USER_DATA to flag locally defined
+ * icons, and use that to accurately know when to destroy old icons.
+ */
+ EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE);
+#endif
+
+ /* Now, free/clear all info from our prefs structure */
+ for (i=0; i<pref.menuItems; i++)
+ free (pref.menu[i].menuItem);
+ free (pref.menu);
+ pref.menu = NULL;
+ pref.menuItems = 0;
+
+ pref.rootMenuName[0] = 0;
+
+ free (pref.sysMenu);
+ pref.sysMenuItems = 0;
+
+ pref.defaultSysMenuName[0] = 0;
+ pref.defaultSysMenuPos = 0;
+
+ pref.iconDirectory[0] = 0;
+ pref.defaultIconName[0] = 0;
+ pref.trayIconName[0] = 0;
+
+ for (i=0; i<pref.iconItems; i++)
+ if (pref.icon[i].hicon)
+ DestroyIcon ((HICON)pref.icon[i].hicon);
+ free (pref.icon);
+ pref.icon = NULL;
+ pref.iconItems = 0;
+
+ /* Free global default X icon */
+ if (g_hIconX)
+ DestroyIcon (g_hIconX);
+ if (g_hSmallIconX)
+ DestroyIcon (g_hSmallIconX);
+
+ /* Reset the custom command IDs */
+ g_cmdid = STARTMENUID;
+
+ /* Load the updated resource file */
+ LoadPreferences();
+
+ g_hIconX = NULL;
+ g_hSmallIconX = NULL;
+
+#ifdef XWIN_MULTIWINDOW
+ winInitGlobalIcons();
+#endif
+
+#ifdef XWIN_MULTIWINDOW
+ /* Rebuild the icons and menus */
+ EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, TRUE);
+#endif
+
+ /* Whew, done */
+}
+
+/*
+ * Check/uncheck the ALWAYSONTOP items in this menu
+ */
+void
+HandleCustomWM_INITMENU(unsigned long hwndIn,
+ unsigned long hmenuIn)
+{
+ HWND hwnd;
+ HMENU hmenu;
+ DWORD dwExStyle;
+ int i, j;
+
+ hwnd = (HWND)hwndIn;
+ hmenu = (HMENU)hmenuIn;
+ if (!hwnd || !hmenu)
+ return;
+
+ if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
+ dwExStyle = MF_BYCOMMAND | MF_CHECKED;
+ else
+ dwExStyle = MF_BYCOMMAND | MF_UNCHECKED;
+
+ for (i=0; i<pref.menuItems; i++)
+ for (j=0; j<pref.menu[i].menuItems; j++)
+ if (pref.menu[i].menuItem[j].cmd==CMD_ALWAYSONTOP)
+ CheckMenuItem (hmenu, pref.menu[i].menuItem[j].commandID, dwExStyle );
+
+}
+
+/*
+ * Searches for the custom WM_COMMAND command ID and performs action.
+ * Return TRUE if command is proccessed, FALSE otherwise.
+ */
+Bool
+HandleCustomWM_COMMAND (unsigned long hwndIn,
+ int command)
+{
+ HWND hwnd;
+ int i, j;
+ MENUPARSED *m;
+ DWORD dwExStyle;
+
+ hwnd = (HWND)hwndIn;
+
+ if (!command)
+ return FALSE;
+
+ for (i=0; i<pref.menuItems; i++)
+ {
+ m = &(pref.menu[i]);
+ for (j=0; j<m->menuItems; j++)
+ {
+ if (command==m->menuItem[j].commandID)
+ {
+ /* Match! */
+ switch(m->menuItem[j].cmd)
+ {
+#ifdef __CYGWIN__
+ case CMD_EXEC:
+ if (fork()==0)
+ {
+ struct rlimit rl;
+ unsigned long i;
+
+ /* Close any open descriptors except for STD* */
+ getrlimit (RLIMIT_NOFILE, &rl);
+ for (i = STDERR_FILENO+1; i < rl.rlim_cur; i++)
+ close(i);
+
+ /* Disassociate any TTYs */
+ setsid();
+
+ execl ("/bin/sh",
+ "/bin/sh",
+ "-c",
+ m->menuItem[j].param,
+ NULL);
+ exit (0);
+ }
+ else
+ return TRUE;
+ break;
+#else
+ case CMD_EXEC:
+ {
+ /* Start process without console window */
+ STARTUPINFO start;
+ PROCESS_INFORMATION child;
+
+ memset (&start, 0, sizeof (start));
+ start.cb = sizeof (start);
+ //start.dwFlags = STARTF_USESHOWWINDOW;
+ //start.wShowWindow = SW_HIDE;
+
+ memset (&child, 0, sizeof (child));
+
+ if (CreateProcess (NULL, m->menuItem[j].param, NULL, NULL, FALSE, 0,
+ NULL, NULL, &start, &child))
+ {
+ CloseHandle (child.hThread);
+ CloseHandle (child.hProcess);
+ }
+ else
+ MessageBox(NULL, m->menuItem[j].param, "VcXsrv Exec Command Error!", MB_OK | MB_ICONEXCLAMATION);
+ }
+ return TRUE;
+#endif
+ case CMD_ALWAYSONTOP:
+ if (!hwnd)
+ return FALSE;
+
+ /* Get extended window style */
+ dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
+
+ /* Handle topmost windows */
+ if (dwExStyle & WS_EX_TOPMOST)
+ SetWindowPos (hwnd,
+ HWND_NOTOPMOST,
+ 0, 0,
+ 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE);
+ else
+ SetWindowPos (hwnd,
+ HWND_TOPMOST,
+ 0, 0,
+ 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE);
+#if XWIN_MULTIWINDOW
+ /* Reflect the changed Z order */
+ winReorderWindowsMultiWindow ();
+#endif
+ return TRUE;
+
+ case CMD_RELOAD:
+ ReloadPrefs();
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+ } /* match */
+ } /* for j */
+ } /* for i */
+
+ return FALSE;
+}
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * Add the default or a custom menu depending on the class match
+ */
+void
+SetupSysMenu (unsigned long hwndIn)
+{
+ HWND hwnd;
+ HMENU sys;
+ int i;
+ WindowPtr pWin;
+ char *res_name, *res_class;
+
+ hwnd = (HWND)hwndIn;
+ if (!hwnd)
+ return;
+
+ pWin = GetProp (hwnd, WIN_WINDOW_PROP);
+
+ sys = GetSystemMenu (hwnd, FALSE);
+ if (!sys)
+ return;
+
+ if (pWin)
+ {
+ /* First see if there's a class match... */
+ if (winMultiWindowGetClassHint (pWin, &res_name, &res_class))
+ {
+ for (i=0; i<pref.sysMenuItems; i++)
+ {
+ if (!strcmp(pref.sysMenu[i].match, res_name) ||
+ !strcmp(pref.sysMenu[i].match, res_class) )
+ {
+ free(res_name);
+ free(res_class);
+
+ MakeMenu (pref.sysMenu[i].menuName, sys,
+ pref.sysMenu[i].menuPos==AT_START?0:-1);
+ return;
+ }
+ }
+
+ /* No match, just free alloc'd strings */
+ free(res_name);
+ free(res_class);
+ } /* Found wm_class */
+ } /* if pwin */
+
+ /* Fallback to system default */
+ if (pref.defaultSysMenuName[0])
+ {
+ if (pref.defaultSysMenuPos==AT_START)
+ MakeMenu (pref.defaultSysMenuName, sys, 0);
+ else
+ MakeMenu (pref.defaultSysMenuName, sys, -1);
+ }
+}
+#endif
+
+
+/*
+ * Possibly add a menu to the toolbar icon
+ */
+void
+SetupRootMenu (unsigned long hmenuRoot)
+{
+ HMENU root;
+
+ root = (HMENU)hmenuRoot;
+ if (!root)
+ return;
+
+ if (pref.rootMenuName[0])
+ {
+ MakeMenu(pref.rootMenuName, root, 0);
+ }
+}
+
+
+/*
+ * Check for and return an overridden default ICON specified in the prefs
+ */
+HICON
+winOverrideDefaultIcon(int size)
+{
+ HICON hicon;
+
+ if (pref.defaultIconName[0])
+ {
+ hicon = LoadImageComma (pref.defaultIconName, size, size, 0);
+ if (hicon==NULL)
+ ErrorF ("winOverrideDefaultIcon: LoadImageComma(%s) failed\n",
+ pref.defaultIconName);
+
+ return hicon;
+ }
+
+ return 0;
+}
+
+
+/*
+ * Return the HICON to use in the taskbar notification area
+ */
+HICON
+winTaskbarIcon(void)
+{
+ HICON hicon;
+
+ hicon = 0;
+ /* First try and load an overridden, if success then return it */
+ if (pref.trayIconName[0])
+ {
+ hicon = LoadImageComma (pref.trayIconName,
+ GetSystemMetrics (SM_CXSMICON),
+ GetSystemMetrics (SM_CYSMICON),
+ 0 );
+ }
+
+ /* Otherwise return the default */
+ if (!hicon)
+ hicon = (HICON) LoadImage (g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN),
+ IMAGE_ICON,
+ GetSystemMetrics (SM_CXSMICON),
+ GetSystemMetrics (SM_CYSMICON),
+ 0);
+
+ return hicon;
+}
+
+
+/*
+ * Parse a filename to extract an icon:
+ * If fname is exactly ",nnn" then extract icon from our resource
+ * else if it is "file,nnn" then extract icon nnn from that file
+ * else try to load it as an .ico file and if that fails return NULL
+ */
+static HICON
+LoadImageComma (char *fname, int sx, int sy, int flags)
+{
+ HICON hicon;
+ int index;
+ char file[PATH_MAX+NAME_MAX+2];
+
+ /* Some input error checking */
+ if (!fname || !fname[0])
+ return NULL;
+
+ index = 0;
+ hicon = NULL;
+
+ if (fname[0]==',')
+ {
+ /* It's the XWIN.EXE resource they want */
+ index = atoi (fname+1);
+ hicon = LoadImage (g_hInstance,
+ MAKEINTRESOURCE(index),
+ IMAGE_ICON,
+ sx,
+ sy,
+ flags);
+ }
+ else
+ {
+ file[0] = 0;
+ /* Prepend path if not given a "X:\" filename */
+ if ( !(fname[0] && fname[1]==':' && fname[2]=='\\') )
+ {
+ strcpy (file, pref.iconDirectory);
+ if (pref.iconDirectory[0])
+ if (fname[strlen(fname)-1]!='\\')
+ strcat (file, "\\");
+ }
+ strcat (file, fname);
+
+ if (strrchr (file, ','))
+ {
+ /* Specified as <fname>,<index> */
+
+ *(strrchr (file, ',')) = 0; /* End string at comma */
+ index = atoi (strrchr (fname, ',') + 1);
+ hicon = ExtractIcon (g_hInstance, file, index);
+ }
+ else
+ {
+ /* Just an .ico file... */
+
+ hicon = (HICON)LoadImage (NULL,
+ file,
+ IMAGE_ICON,
+ sx,
+ sy,
+ LR_LOADFROMFILE|flags);
+ }
+ }
+ return hicon;
+}
+
+/*
+ * Check for a match of the window class to one specified in the
+ * ICONS{} section in the prefs file, and load the icon from a file
+ */
+HICON
+winOverrideIcon (unsigned long longWin)
+{
+ WindowPtr pWin = (WindowPtr) longWin;
+ char *res_name, *res_class;
+ int i;
+ HICON hicon;
+ char *wmName;
+
+ if (pWin==NULL)
+ return 0;
+
+ /* If we can't find the class, we can't override from default! */
+ if (!winMultiWindowGetClassHint (pWin, &res_name, &res_class))
+ return 0;
+
+ winMultiWindowGetWMName (pWin, &wmName);
+
+ for (i=0; i<pref.iconItems; i++) {
+ if (!strcmp(pref.icon[i].match, res_name) ||
+ !strcmp(pref.icon[i].match, res_class) ||
+ (wmName && strstr(wmName, pref.icon[i].match)))
+ {
+ free (res_name);
+ free (res_class);
+ free(wmName);
+
+ if (pref.icon[i].hicon)
+ return pref.icon[i].hicon;
+
+ hicon = LoadImageComma (pref.icon[i].iconFile, 0, 0, LR_DEFAULTSIZE);
+ if (hicon==NULL)
+ ErrorF ("winOverrideIcon: LoadImageComma(%s) failed\n",
+ pref.icon[i].iconFile);
+
+ pref.icon[i].hicon = hicon;
+ return hicon;
+ }
+ }
+
+ /* Didn't find the icon, fail gracefully */
+ free (res_name);
+ free (res_class);
+ free(wmName);
+
+ return 0;
+}
+
+
+/*
+ * Should we free this icon or leave it in memory (is it part of our
+ * ICONS{} overrides)?
+ */
+int
+winIconIsOverride(unsigned hiconIn)
+{
+ HICON hicon;
+ int i;
+
+ hicon = (HICON)hiconIn;
+
+ if (!hicon)
+ return 0;
+
+ for (i=0; i<pref.iconItems; i++)
+ if ((HICON)pref.icon[i].hicon == hicon)
+ return 1;
+
+ return 0;
+}
+
+
+
+/*
+ * Try and open ~/.XWinrc and system.XWinrc
+ * Load it into prefs structure for use by other functions
+ */
+void
+LoadPreferences (void)
+{
+ char *home;
+ char fname[PATH_MAX+NAME_MAX+2];
+ FILE *prefFile;
+ char szDisplay[512];
+ char *szEnvDisplay;
+ int i, j;
+ char param[PARAM_MAX+1];
+ char *srcParam, *dstParam;
+
+ /* First, clear all preference settings */
+ memset (&pref, 0, sizeof(pref));
+ prefFile = NULL;
+
+ /* Now try and find a ~/.xwinrc file */
+ home = getenv ("HOME");
+ if (home)
+ {
+ strcpy (fname, home);
+ if (fname[strlen(fname)-1]!='/')
+ strcat (fname, "/");
+ strcat (fname, ".XWinrc");
+
+ prefFile = fopen (fname, "r");
+ if (prefFile)
+ {
+ winDebug ("winPrefsLoadPreferences: %s\n", fname);
+ }
+ }
+
+ /* No home file found, check system default */
+ if (!prefFile)
+ {
+ char buffer[MAX_PATH];
+#ifdef RELOCATE_PROJECTROOT
+ snprintf(buffer, sizeof(buffer), "%s\\system.XWinrc", winGetBaseDir());
+#else
+ strncpy(buffer, SYSCONFDIR"/X11/system.XWinrc", sizeof(buffer));
+#endif
+ buffer[sizeof(buffer)-1] = 0;
+ prefFile = fopen (buffer, "r");
+ if (prefFile)
+ {
+ winDebug ("winPrefsLoadPreferences: %s\n", buffer);
+ }
+ }
+
+ /* If we could open it, then read the settings and close it */
+ if (prefFile)
+ {
+ parse_file (prefFile);
+ fclose (prefFile);
+ }
+
+ /* Setup a DISPLAY environment variable, need to allocate on heap */
+ /* because putenv doesn't copy the argument... Always use screen 0 */
+ winGetDisplayName(szDisplay, 0);
+ szEnvDisplay = (char *)(malloc(strlen(szDisplay)+9/*strlen("DISPLAY=")+1*/));
+ snprintf(szEnvDisplay, 512, "DISPLAY=%s", szDisplay);
+ putenv (szEnvDisplay);
+
+ /* Replace any "%display%" in menu commands with display string */
+ for (i=0; i<pref.menuItems; i++)
+ {
+ for (j=0; j<pref.menu[i].menuItems; j++)
+ {
+ if (pref.menu[i].menuItem[j].cmd==CMD_EXEC)
+ {
+ srcParam = pref.menu[i].menuItem[j].param;
+ dstParam = param;
+ while (*srcParam) {
+ if (!strncmp(srcParam, "%display%", 9))
+ {
+ memcpy (dstParam, szDisplay, strlen(szDisplay));
+ dstParam += strlen(szDisplay);
+ srcParam += 9;
+ }
+ else if (!strncmp(srcParam, "%logfile%", 9))
+ {
+ memcpy (dstParam, g_pszLogFile, strlen(g_pszLogFile));
+ dstParam += strlen(g_pszLogFile);
+ srcParam += 9;
+ }
+ else
+ {
+ *dstParam = *srcParam;
+ dstParam++;
+ srcParam++;
+ }
+ }
+ *dstParam = 0;
+ strcpy (pref.menu[i].menuItem[j].param, param);
+ } /* cmd==cmd_exec */
+ } /* for all menuitems */
+ } /* for all menus */
+
+}
+
+
+/*
+ * Check for a match of the window class to one specified in the
+ * STYLES{} section in the prefs file, and return the style type
+ */
+unsigned long
+winOverrideStyle (unsigned long longpWin)
+{
+ WindowPtr pWin = (WindowPtr) longpWin;
+ char *res_name, *res_class;
+ int i;
+ char *wmName;
+
+ if (pWin==NULL)
+ return STYLE_NONE;
+
+ /* If we can't find the class, we can't override from default! */
+ if (!winMultiWindowGetClassHint (pWin, &res_name, &res_class))
+ return STYLE_NONE;
+
+ winMultiWindowGetWMName (pWin, &wmName);
+
+ for (i=0; i<pref.styleItems; i++) {
+ if (!strcmp(pref.style[i].match, res_name) ||
+ !strcmp(pref.style[i].match, res_class) ||
+ (wmName && strstr(wmName, pref.style[i].match)))
+ {
+ free (res_name);
+ free (res_class);
+ free(wmName);
+
+ if (pref.style[i].type)
+ return pref.style[i].type;
+ }
+ }
+
+ /* Didn't find the style, fail gracefully */
+ free (res_name);
+ free (res_class);
+ free(wmName);
+
+ return STYLE_NONE;
+}
diff --git a/xorg-server/hw/xwin/winscrinit.c b/xorg-server/hw/xwin/winscrinit.c index 501a999a4..5273460a4 100644 --- a/xorg-server/hw/xwin/winscrinit.c +++ b/xorg-server/hw/xwin/winscrinit.c @@ -1,775 +1,775 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - * Kensuke Matsuzaki - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include "winmsg.h" - - -#ifdef XWIN_MULTIWINDOWEXTWM -static RootlessFrameProcsRec -winMWExtWMProcs = { - winMWExtWMCreateFrame, - winMWExtWMDestroyFrame, - - winMWExtWMMoveFrame, - winMWExtWMResizeFrame, - winMWExtWMRestackFrame, - winMWExtWMReshapeFrame, - winMWExtWMUnmapFrame, - - winMWExtWMStartDrawing, - winMWExtWMStopDrawing, - winMWExtWMUpdateRegion, -#ifndef ROOTLESS_TRACK_DAMAGE - winMWExtWMDamageRects, -#endif - winMWExtWMRootlessSwitchWindow, - NULL,//winMWExtWMDoReorderWindow, - NULL,//winMWExtWMHideWindow, - NULL,//winMWExtWMUpdateColorMap, - - NULL,//winMWExtWMCopyBytes, - NULL,//winMWExtWMFillBytes, - NULL,//winMWExtWMCompositePixels, - winMWExtWMCopyWindow -}; -#endif - - -/* - * References to external symbols - */ - -extern Bool g_fSoftwareCursor; - - -/* - * Prototypes - */ - -Bool -winRandRInit (ScreenPtr pScreen); - - -/* - * Local functions - */ - -static Bool -winSaveScreen (ScreenPtr pScreen, int on); - - -/* - * Determine what type of screen we are initializing - * and call the appropriate procedure to intiailize - * that type of screen. - */ - -Bool -winScreenInit (int index, - ScreenPtr pScreen, - int argc, char **argv) -{ - winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index]; - winPrivScreenPtr pScreenPriv; - HDC hdc; - - winDebug ("winScreenInit - dwWidth: %ld dwHeight: %ld\n", - pScreenInfo->dwWidth, pScreenInfo->dwHeight); - - /* Allocate privates for this screen */ - if (!winAllocatePrivates (pScreen)) - { - ErrorF ("winScreenInit - Couldn't allocate screen privates\n"); - return FALSE; - } - - /* Get a pointer to the privates structure that was allocated */ - pScreenPriv = winGetScreenPriv (pScreen); - - /* Save a pointer to this screen in the screen info structure */ - pScreenInfo->pScreen = pScreen; - - /* Save a pointer to the screen info in the screen privates structure */ - /* This allows us to get back to the screen info from a screen pointer */ - pScreenPriv->pScreenInfo = pScreenInfo; - - /* - * Determine which engine to use. - * - * NOTE: This is done once per screen because each screen possibly has - * a preferred engine specified on the command line. - */ - if (!winSetEngine (pScreen)) - { - ErrorF ("winScreenInit - winSetEngine () failed\n"); - return FALSE; - } - - /* Adjust the video mode for our engine type */ - if (pScreenPriv->pwinAdjustVideoMode && !(*pScreenPriv->pwinAdjustVideoMode) (pScreen)) - { - ErrorF ("winScreenInit - winAdjustVideoMode () failed\n"); - return FALSE; - } - - /* Check for supported display depth */ - if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1)))) - { - ErrorF ("winScreenInit - Unsupported display depth: %d\n" \ - "Change your Windows display depth to 15, 16, 24, or 32 bits " - "per pixel.\n", - (int) pScreenInfo->dwBPP); - ErrorF ("winScreenInit - Supported depths: %08x\n", - WIN_SUPPORTED_BPPS); -#if WIN_CHECK_DEPTH - return FALSE; -#endif - } - - /* - * Check that all monitors have the same display depth if we are using - * multiple monitors - */ - if (pScreenInfo->fMultipleMonitors - && !GetSystemMetrics (SM_SAMEDISPLAYFORMAT)) - { - ErrorF ("winScreenInit - Monitors do not all have same pixel format / " - "display depth.\n" - "Using primary display only.\n"); - pScreenInfo->fMultipleMonitors = FALSE; - } - - /* Create display window */ - if (pScreenPriv->pwinCreateBoundingWindow && !(*pScreenPriv->pwinCreateBoundingWindow) (pScreen)) - { - ErrorF ("winScreenInit - pwinCreateBoundingWindow () " - "failed\n"); - return FALSE; - } - - /* Get a device context */ - hdc = GetDC (pScreenPriv->hwndScreen); - - /* Store the initial height, width, and depth of the display */ - /* Are we using multiple monitors? */ - if (pScreenInfo->fMultipleMonitors) - { - pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN); - pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN); - - /* - * In this case, some of the defaults set in - * winInitializeScreenDefaults() are not correct ... - */ - if (!pScreenInfo->fUserGaveHeightAndWidth) - { - pScreenInfo->dwWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN); - pScreenInfo->dwHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN); - pScreenInfo->dwWidth_mm = (pScreenInfo->dwWidth / - WIN_DEFAULT_DPI) * 25.4; - pScreenInfo->dwHeight_mm = (pScreenInfo->dwHeight / - WIN_DEFAULT_DPI) * 25.4; - } - } - else - { - pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN); - pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN); - } - - /* Save the original bits per pixel */ - pScreenPriv->dwLastWindowsBitsPixel = GetDeviceCaps (hdc, BITSPIXEL); - - /* Release the device context */ - ReleaseDC (pScreenPriv->hwndScreen, hdc); - - /* Clear the visuals list */ - miClearVisualTypes (); - - /* Set the padded screen width */ - pScreenInfo->dwPaddedWidth = PixmapBytePad (pScreenInfo->dwWidth, - pScreenInfo->dwBPP); - - /* Call the engine dependent screen initialization procedure */ - if (pScreenPriv->pwinFinishScreenInit && !((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv))) - { - ErrorF ("winScreenInit - winFinishScreenInit () failed\n"); - return FALSE; - } - - if (!g_fSoftwareCursor) - winInitCursor(pScreen); -#ifdef WINDBG - else - winDebug("winScreenInit - Using software cursor\n"); -#endif - - /* - Note the screen origin in a normalized coordinate space where (0,0) is at the top left - of the native virtual desktop area - */ - dixScreenOrigins[index].x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN); - dixScreenOrigins[index].y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN); - - winDebug("Screen %d added at virtual desktop coordinate (%d,%d).\n", - index, dixScreenOrigins[index].x, dixScreenOrigins[index].y); - winDebug ("winScreenInit - returning\n"); - - return TRUE; -} - -static Bool -winCreateScreenResources(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - Bool result; - - result = pScreenPriv->pwinCreateScreenResources(pScreen); - - /* Now the screen bitmap has been wrapped in a pixmap, - add that to the Shadow framebuffer */ - if (!shadowAdd(pScreen, pScreen->devPrivate, - pScreenPriv->pwinShadowUpdate, NULL, 0, 0)) - { - ErrorF ("winCreateScreenResources - shadowAdd () failed\n"); - return FALSE; - } - - return result; -} - -/* See Porting Layer Definition - p. 20 */ -Bool -winFinishScreenInitFB (int index, - ScreenPtr pScreen, - int argc, char **argv) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - VisualPtr pVisual = NULL; - char *pbits = NULL; -#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) - int iReturn; -#endif - - /* Create framebuffer */ - if (!(*pScreenPriv->pwinAllocateFB) (pScreen)) - { - ErrorF ("winFinishScreenInitFB - Could not allocate framebuffer\n"); - return FALSE; - } - - /* - * Grab the number of bits that are used to represent color in each pixel. - */ - if (pScreenInfo->dwBPP == 8) - pScreenInfo->dwDepth = 8; - else - pScreenInfo->dwDepth = winCountBits (pScreenPriv->dwRedMask) - + winCountBits (pScreenPriv->dwGreenMask) - + winCountBits (pScreenPriv->dwBlueMask); - - winDebug ("winFinishScreenInitFB - Masks: %08x %08x %08x\n", - (unsigned int) pScreenPriv->dwRedMask, - (unsigned int) pScreenPriv->dwGreenMask, - (unsigned int) pScreenPriv->dwBlueMask); - - /* Init visuals */ - if (!(*pScreenPriv->pwinInitVisuals) (pScreen)) - { - ErrorF ("winFinishScreenInitFB - winInitVisuals failed\n"); - return FALSE; - } - - /* Setup a local variable to point to the framebuffer */ - pbits = pScreenInfo->pfb; - - /* Apparently we need this for the render extension */ - miSetPixmapDepths (); - - /* Start fb initialization */ - if (!fbSetupScreen (pScreen, - pScreenInfo->pfb, - pScreenInfo->dwWidth, pScreenInfo->dwHeight, - monitorResolution, monitorResolution, - pScreenInfo->dwStride, - pScreenInfo->dwBPP)) - { - ErrorF ("winFinishScreenInitFB - fbSetupScreen failed\n"); - return FALSE; - } - - /* Override default colormap routines if visual class is dynamic */ - if (pScreenInfo->dwDepth == 8 - && (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI - || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL - && pScreenInfo->fFullScreen) - || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD - && pScreenInfo->fFullScreen))) - { - winSetColormapFunctions (pScreen); - - /* - * NOTE: Setting whitePixel to 255 causes Magic 7.1 to allocate its - * own colormap, as it cannot allocate 7 planes in the default - * colormap. Setting whitePixel to 1 allows Magic to get 7 - * planes in the default colormap, so it doesn't create its - * own colormap. This latter situation is highly desireable, - * as it keeps the Magic window viewable when switching to - * other X clients that use the default colormap. - */ - pScreen->blackPixel = 0; - pScreen->whitePixel = 1; - } - - /* Place our save screen function */ - pScreen->SaveScreen = winSaveScreen; - - /* Finish fb initialization */ - if (!fbFinishScreenInit (pScreen, - pScreenInfo->pfb, - pScreenInfo->dwWidth, pScreenInfo->dwHeight, - monitorResolution, monitorResolution, - pScreenInfo->dwStride, - pScreenInfo->dwBPP)) - { - ErrorF ("winFinishScreenInitFB - fbFinishScreenInit failed\n"); - return FALSE; - } - - /* Save a pointer to the root visual */ - for (pVisual = pScreen->visuals; - pVisual->vid != pScreen->rootVisual; - pVisual++); - pScreenPriv->pRootVisual = pVisual; - - /* - * Setup points to the block and wakeup handlers. Pass a pointer - * to the current screen as pWakeupdata. - */ - pScreen->BlockHandler = winBlockHandler; - pScreen->WakeupHandler = winWakeupHandler; - pScreen->blockData = pScreen; - pScreen->wakeupData = pScreen; - - /* Render extension initialization, calls miPictureInit */ - if (!fbPictureInit (pScreen, NULL, 0)) - { - ErrorF ("winFinishScreenInitFB - fbPictureInit () failed\n"); - return FALSE; - } - -#ifdef RANDR - /* Initialize resize and rotate support */ - if (!winRandRInit (pScreen)) - { - ErrorF ("winFinishScreenInitFB - winRandRInit () failed\n"); - return FALSE; - } -#endif - - /* - * Backing store support should reduce network traffic and increase - * performance. - */ - miInitializeBackingStore (pScreen); - - /* KDrive does miDCInitialize right after miInitializeBackingStore */ - /* Setup the cursor routines */ - winDebug ("winFinishScreenInitFB - Calling miDCInitialize ()\n"); - miDCInitialize (pScreen, &g_winPointerCursorFuncs); - - /* KDrive does winCreateDefColormap right after miDCInitialize */ - /* Create a default colormap */ - winDebug ("winFinishScreenInitFB - Calling winCreateDefColormap ()\n"); - if (!winCreateDefColormap (pScreen)) - { - ErrorF ("winFinishScreenInitFB - Could not create colormap\n"); - return FALSE; - } - - /* Initialize the shadow framebuffer layer */ - if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI - || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD - || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL) -#ifdef XWIN_MULTIWINDOWEXTWM - && !pScreenInfo->fMWExtWM -#endif - ) - { - winDebug ("winFinishScreenInitFB - Calling shadowSetup ()\n"); - if (!shadowSetup(pScreen)) - { - ErrorF ("winFinishScreenInitFB - shadowSetup () failed\n"); - return FALSE; - } - - /* Wrap CreateScreenResources so we can add the screen pixmap - to the Shadow framebuffer after it's been created */ - pScreenPriv->pwinCreateScreenResources = pScreen->CreateScreenResources; - pScreen->CreateScreenResources = winCreateScreenResources; - } - -#ifdef XWIN_MULTIWINDOWEXTWM - /* Handle multi-window external window manager mode */ - if (pScreenInfo->fMWExtWM) - { - winDebug ("winScreenInit - MultiWindowExtWM - Calling RootlessInit\n"); - - RootlessInit(pScreen, &winMWExtWMProcs); - - winDebug ("winScreenInit - MultiWindowExtWM - RootlessInit returned\n"); - - rootless_CopyBytes_threshold = 0; - rootless_FillBytes_threshold = 0; - rootless_CompositePixels_threshold = 0; - /* FIXME: How many? Profiling needed? */ - rootless_CopyWindow_threshold = 1; - - winWindowsWMExtensionInit (); - } -#endif - - /* Handle rootless mode */ - if (pScreenInfo->fRootless) - { - /* Define the WRAP macro temporarily for local use */ -#define WRAP(a) \ - if (pScreen->a) { \ - pScreenPriv->a = pScreen->a; \ - } else { \ - ErrorF("null screen fn " #a "\n"); \ - pScreenPriv->a = NULL; \ - } - - /* Save a pointer to each lower-level window procedure */ - WRAP(CreateWindow); - WRAP(DestroyWindow); - WRAP(RealizeWindow); - WRAP(UnrealizeWindow); - WRAP(PositionWindow); - WRAP(ChangeWindowAttributes); - WRAP(SetShape); - - /* Assign rootless window procedures to be top level procedures */ - pScreen->CreateWindow = winCreateWindowRootless; - pScreen->DestroyWindow = winDestroyWindowRootless; - pScreen->PositionWindow = winPositionWindowRootless; - /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesRootless;*/ - pScreen->RealizeWindow = winMapWindowRootless; - pScreen->UnrealizeWindow = winUnmapWindowRootless; - pScreen->SetShape = winSetShapeRootless; - - /* Undefine the WRAP macro, as it is not needed elsewhere */ -#undef WRAP - } - - -#ifdef XWIN_MULTIWINDOW - /* Handle multi window mode */ - else if (pScreenInfo->fMultiWindow) - { - /* Define the WRAP macro temporarily for local use */ -#define WRAP(a) \ - if (pScreen->a) { \ - pScreenPriv->a = pScreen->a; \ - } else { \ - ErrorF("null screen fn " #a "\n"); \ - pScreenPriv->a = NULL; \ - } - - /* Save a pointer to each lower-level window procedure */ - WRAP(CreateWindow); - WRAP(DestroyWindow); - WRAP(RealizeWindow); - WRAP(UnrealizeWindow); - WRAP(PositionWindow); - WRAP(ChangeWindowAttributes); - WRAP(ReparentWindow); - WRAP(RestackWindow); - WRAP(ResizeWindow); - WRAP(MoveWindow); - WRAP(CopyWindow); - WRAP(SetShape); - - /* Assign multi-window window procedures to be top level procedures */ - pScreen->CreateWindow = winCreateWindowMultiWindow; - pScreen->DestroyWindow = winDestroyWindowMultiWindow; - pScreen->PositionWindow = winPositionWindowMultiWindow; - /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesMultiWindow;*/ - pScreen->RealizeWindow = winMapWindowMultiWindow; - pScreen->UnrealizeWindow = winUnmapWindowMultiWindow; - pScreen->ReparentWindow = winReparentWindowMultiWindow; - pScreen->RestackWindow = winRestackWindowMultiWindow; - pScreen->ResizeWindow = winResizeWindowMultiWindow; - pScreen->MoveWindow = winMoveWindowMultiWindow; - pScreen->CopyWindow = winCopyWindowMultiWindow; - pScreen->SetShape = winSetShapeMultiWindow; - - /* Undefine the WRAP macro, as it is not needed elsewhere */ -#undef WRAP - } -#endif - - /* Wrap either fb's or shadow's CloseScreen with our CloseScreen */ - pScreenPriv->CloseScreen = pScreen->CloseScreen; - pScreen->CloseScreen = pScreenPriv->pwinCloseScreen; - -#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) - /* Create a mutex for modules in separate threads to wait for */ - iReturn = pthread_mutex_init (&pScreenPriv->pmServerStarted, NULL); - if (iReturn != 0) - { - ErrorF ("winFinishScreenInitFB - pthread_mutex_init () failed: %d\n", - iReturn); - return FALSE; - } - - /* Own the mutex for modules in separate threads */ - iReturn = pthread_mutex_lock (&pScreenPriv->pmServerStarted); - if (iReturn != 0) - { - ErrorF ("winFinishScreenInitFB - pthread_mutex_lock () failed: %d\n", - iReturn); - return FALSE; - } - - /* Set the ServerStarted flag to false */ - pScreenPriv->fServerStarted = FALSE; -#endif - -#ifdef XWIN_MULTIWINDOWEXTWM - pScreenPriv->fRestacking = FALSE; -#endif - -#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - if (FALSE -#ifdef XWIN_MULTIWINDOW - || pScreenInfo->fMultiWindow -#endif -#ifdef XWIN_MULTIWINDOWEXTWM - || pScreenInfo->fInternalWM -#endif - ) - { - winDebug ("winFinishScreenInitFB - Calling winInitWM.\n"); - - /* Initialize multi window mode */ - if (!winInitWM (&pScreenPriv->pWMInfo, - &pScreenPriv->ptWMProc, - &pScreenPriv->ptXMsgProc, - &pScreenPriv->pmServerStarted, - pScreenInfo->dwScreen, - (HWND)&pScreenPriv->hwndScreen, -#ifdef XWIN_MULTIWINDOWEXTWM - pScreenInfo->fInternalWM || -#endif - FALSE)) - { - ErrorF ("winFinishScreenInitFB - winInitWM () failed.\n"); - return FALSE; - } - } -#endif - - /* Tell the server that we are enabled */ - pScreenPriv->fEnabled = TRUE; - - /* Tell the server that we have a valid depth */ - pScreenPriv->fBadDepth = FALSE; - - winDebug ("winFinishScreenInitFB - returning\n"); - - return TRUE; -} - -#ifdef XWIN_NATIVEGDI -/* See Porting Layer Definition - p. 20 */ - -Bool -winFinishScreenInitNativeGDI (int index, - ScreenPtr pScreen, - int argc, char **argv) -{ - winScreenPriv(pScreen); - winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index]; - VisualPtr pVisuals = NULL; - DepthPtr pDepths = NULL; - VisualID rootVisual = 0; - int nVisuals = 0, nDepths = 0, nRootDepth = 0; - - /* Ignore user input (mouse, keyboard) */ - pScreenInfo->fIgnoreInput = FALSE; - - /* Get device contexts for the screen and shadow bitmap */ - pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen); - if (pScreenPriv->hdcScreen == NULL) - FatalError ("winFinishScreenInitNativeGDI - Couldn't get a DC\n"); - - /* Init visuals */ - if (!(*pScreenPriv->pwinInitVisuals) (pScreen)) - { - ErrorF ("winFinishScreenInitNativeGDI - pwinInitVisuals failed\n"); - return FALSE; - } - - /* Initialize the mi visuals */ - if (!miInitVisuals (&pVisuals, &pDepths, &nVisuals, &nDepths, &nRootDepth, - &rootVisual, - ((unsigned long)1 << (pScreenInfo->dwDepth - 1)), 8, - TrueColor)) - { - ErrorF ("winFinishScreenInitNativeGDI - miInitVisuals () failed\n"); - return FALSE; - } - - /* Initialize the CloseScreen procedure pointer */ - pScreen->CloseScreen = NULL; - - /* Initialize the mi code */ - if (!miScreenInit (pScreen, - NULL, /* No framebuffer */ - pScreenInfo->dwWidth, pScreenInfo->dwHeight, - monitorResolution, monitorResolution, - pScreenInfo->dwStride, - nRootDepth, nDepths, pDepths, rootVisual, - nVisuals, pVisuals)) - { - ErrorF ("winFinishScreenInitNativeGDI - miScreenInit failed\n"); - return FALSE; - } - - pScreen->defColormap = FakeClientID(0); - - /* - * Register our block and wakeup handlers; these procedures - * process messages in our Windows message queue; specifically, - * they process mouse and keyboard input. - */ - pScreen->BlockHandler = winBlockHandler; - pScreen->WakeupHandler = winWakeupHandler; - pScreen->blockData = pScreen; - pScreen->wakeupData = pScreen; - - /* Place our save screen function */ - pScreen->SaveScreen = winSaveScreen; - - /* Pixmaps */ - pScreen->CreatePixmap = winCreatePixmapNativeGDI; - pScreen->DestroyPixmap = winDestroyPixmapNativeGDI; - - /* Other Screen Routines */ - pScreen->QueryBestSize = winQueryBestSizeNativeGDI; - pScreen->SaveScreen = winSaveScreen; - pScreen->GetImage = miGetImage; - pScreen->GetSpans = winGetSpansNativeGDI; - - /* Window Procedures */ - pScreen->CreateWindow = winCreateWindowNativeGDI; - pScreen->DestroyWindow = winDestroyWindowNativeGDI; - pScreen->PositionWindow = winPositionWindowNativeGDI; - /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesNativeGDI;*/ - pScreen->RealizeWindow = winMapWindowNativeGDI; - pScreen->UnrealizeWindow = winUnmapWindowNativeGDI; - - /* Paint window */ - pScreen->CopyWindow = winCopyWindowNativeGDI; - - /* Fonts */ - pScreen->RealizeFont = winRealizeFontNativeGDI; - pScreen->UnrealizeFont = winUnrealizeFontNativeGDI; - - /* GC */ - pScreen->CreateGC = winCreateGCNativeGDI; - - /* Colormap Routines */ - pScreen->CreateColormap = miInitializeColormap; - pScreen->DestroyColormap = (DestroyColormapProcPtr) (void (*)(void)) NoopDDA; - pScreen->InstallColormap = miInstallColormap; - pScreen->UninstallColormap = miUninstallColormap; - pScreen->ListInstalledColormaps = miListInstalledColormaps; - pScreen->StoreColors = (StoreColorsProcPtr) (void (*)(void)) NoopDDA; - pScreen->ResolveColor = miResolveColor; - - /* Bitmap */ - pScreen->BitmapToRegion = winPixmapToRegionNativeGDI; - - winDebug ("winFinishScreenInitNativeGDI - calling miDCInitialize\n"); - - /* Set the default white and black pixel positions */ - pScreen->whitePixel = pScreen->blackPixel = (Pixel) 0; - - /* Initialize the cursor */ - if (!miDCInitialize (pScreen, &g_winPointerCursorFuncs)) - { - ErrorF ("winFinishScreenInitNativeGDI - miDCInitialize failed\n"); - return FALSE; - } - - /* Create a default colormap */ - if (!miCreateDefColormap (pScreen)) - { - ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () " - "failed\n"); - return FALSE; - } - - winDebug ("winFinishScreenInitNativeGDI - miCreateDefColormap () " - "returned\n"); - - /* mi doesn't use a CloseScreen procedure, so no need to wrap */ - pScreen->CloseScreen = pScreenPriv->pwinCloseScreen; - - /* Tell the server that we are enabled */ - pScreenPriv->fEnabled = TRUE; - - winDebug ("winFinishScreenInitNativeGDI - Successful addition of " - "screen %08x\n", - (unsigned int) pScreen); - - return TRUE; -} -#endif - - -/* See Porting Layer Definition - p. 33 */ -static Bool -winSaveScreen (ScreenPtr pScreen, int on) -{ - return TRUE; -} +/*
+ *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ * Kensuke Matsuzaki
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+static RootlessFrameProcsRec
+winMWExtWMProcs = {
+ winMWExtWMCreateFrame,
+ winMWExtWMDestroyFrame,
+
+ winMWExtWMMoveFrame,
+ winMWExtWMResizeFrame,
+ winMWExtWMRestackFrame,
+ winMWExtWMReshapeFrame,
+ winMWExtWMUnmapFrame,
+
+ winMWExtWMStartDrawing,
+ winMWExtWMStopDrawing,
+ winMWExtWMUpdateRegion,
+#ifndef ROOTLESS_TRACK_DAMAGE
+ winMWExtWMDamageRects,
+#endif
+ winMWExtWMRootlessSwitchWindow,
+ NULL,//winMWExtWMDoReorderWindow,
+ NULL,//winMWExtWMHideWindow,
+ NULL,//winMWExtWMUpdateColorMap,
+
+ NULL,//winMWExtWMCopyBytes,
+ NULL,//winMWExtWMFillBytes,
+ NULL,//winMWExtWMCompositePixels,
+ winMWExtWMCopyWindow
+};
+#endif
+
+
+/*
+ * References to external symbols
+ */
+
+extern Bool g_fSoftwareCursor;
+
+
+/*
+ * Prototypes
+ */
+
+Bool
+winRandRInit (ScreenPtr pScreen);
+
+
+/*
+ * Local functions
+ */
+
+static Bool
+winSaveScreen (ScreenPtr pScreen, int on);
+
+
+/*
+ * Determine what type of screen we are initializing
+ * and call the appropriate procedure to intiailize
+ * that type of screen.
+ */
+
+Bool
+winScreenInit (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv)
+{
+ winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
+ winPrivScreenPtr pScreenPriv;
+ HDC hdc;
+
+ winDebug ("winScreenInit - dwWidth: %ld dwHeight: %ld\n",
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight);
+
+ /* Allocate privates for this screen */
+ if (!winAllocatePrivates (pScreen))
+ {
+ ErrorF ("winScreenInit - Couldn't allocate screen privates\n");
+ return FALSE;
+ }
+
+ /* Get a pointer to the privates structure that was allocated */
+ pScreenPriv = winGetScreenPriv (pScreen);
+
+ /* Save a pointer to this screen in the screen info structure */
+ pScreenInfo->pScreen = pScreen;
+
+ /* Save a pointer to the screen info in the screen privates structure */
+ /* This allows us to get back to the screen info from a screen pointer */
+ pScreenPriv->pScreenInfo = pScreenInfo;
+
+ /*
+ * Determine which engine to use.
+ *
+ * NOTE: This is done once per screen because each screen possibly has
+ * a preferred engine specified on the command line.
+ */
+ if (!winSetEngine (pScreen))
+ {
+ ErrorF ("winScreenInit - winSetEngine () failed\n");
+ return FALSE;
+ }
+
+ /* Adjust the video mode for our engine type */
+ if (pScreenPriv->pwinAdjustVideoMode && !(*pScreenPriv->pwinAdjustVideoMode) (pScreen))
+ {
+ ErrorF ("winScreenInit - winAdjustVideoMode () failed\n");
+ return FALSE;
+ }
+
+ /* Check for supported display depth */
+ if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1))))
+ {
+ ErrorF ("winScreenInit - Unsupported display depth: %d\n" \
+ "Change your Windows display depth to 15, 16, 24, or 32 bits "
+ "per pixel.\n",
+ (int) pScreenInfo->dwBPP);
+ ErrorF ("winScreenInit - Supported depths: %08x\n",
+ WIN_SUPPORTED_BPPS);
+#if WIN_CHECK_DEPTH
+ return FALSE;
+#endif
+ }
+
+ /*
+ * Check that all monitors have the same display depth if we are using
+ * multiple monitors
+ */
+ if (pScreenInfo->fMultipleMonitors
+ && !GetSystemMetrics (SM_SAMEDISPLAYFORMAT))
+ {
+ ErrorF ("winScreenInit - Monitors do not all have same pixel format / "
+ "display depth.\n"
+ "Using primary display only.\n");
+ pScreenInfo->fMultipleMonitors = FALSE;
+ }
+
+ /* Create display window */
+ if (pScreenPriv->pwinCreateBoundingWindow && !(*pScreenPriv->pwinCreateBoundingWindow) (pScreen))
+ {
+ ErrorF ("winScreenInit - pwinCreateBoundingWindow () "
+ "failed\n");
+ return FALSE;
+ }
+
+ /* Get a device context */
+ hdc = GetDC (pScreenPriv->hwndScreen);
+
+ /* Store the initial height, width, and depth of the display */
+ /* Are we using multiple monitors? */
+ if (pScreenInfo->fMultipleMonitors)
+ {
+ pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+ pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+
+ /*
+ * In this case, some of the defaults set in
+ * winInitializeScreenDefaults() are not correct ...
+ */
+ if (!pScreenInfo->fUserGaveHeightAndWidth)
+ {
+ pScreenInfo->dwWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+ pScreenInfo->dwHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+ pScreenInfo->dwWidth_mm = (pScreenInfo->dwWidth /
+ WIN_DEFAULT_DPI) * 25.4;
+ pScreenInfo->dwHeight_mm = (pScreenInfo->dwHeight /
+ WIN_DEFAULT_DPI) * 25.4;
+ }
+ }
+ else
+ {
+ pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN);
+ pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN);
+ }
+
+ /* Save the original bits per pixel */
+ pScreenPriv->dwLastWindowsBitsPixel = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* Release the device context */
+ ReleaseDC (pScreenPriv->hwndScreen, hdc);
+
+ /* Clear the visuals list */
+ miClearVisualTypes ();
+
+ /* Set the padded screen width */
+ pScreenInfo->dwPaddedWidth = PixmapBytePad (pScreenInfo->dwWidth,
+ pScreenInfo->dwBPP);
+
+ /* Call the engine dependent screen initialization procedure */
+ if (pScreenPriv->pwinFinishScreenInit && !((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv)))
+ {
+ ErrorF ("winScreenInit - winFinishScreenInit () failed\n");
+ return FALSE;
+ }
+
+ if (!g_fSoftwareCursor)
+ winInitCursor(pScreen);
+#ifdef WINDBG
+ else
+ winDebug("winScreenInit - Using software cursor\n");
+#endif
+
+ /*
+ Note the screen origin in a normalized coordinate space where (0,0) is at the top left
+ of the native virtual desktop area
+ */
+ pScreen->x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
+ pScreen->y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ winDebug("Screen %d added at virtual desktop coordinate (%d,%d).\n",
+ index, pScreen->x, pScreen->y);
+ winDebug ("winScreenInit - returning\n");
+
+ return TRUE;
+}
+
+static Bool
+winCreateScreenResources(ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ Bool result;
+
+ result = pScreenPriv->pwinCreateScreenResources(pScreen);
+
+ /* Now the screen bitmap has been wrapped in a pixmap,
+ add that to the Shadow framebuffer */
+ if (!shadowAdd(pScreen, pScreen->devPrivate,
+ pScreenPriv->pwinShadowUpdate, NULL, 0, 0))
+ {
+ ErrorF ("winCreateScreenResources - shadowAdd () failed\n");
+ return FALSE;
+ }
+
+ return result;
+}
+
+/* See Porting Layer Definition - p. 20 */
+Bool
+winFinishScreenInitFB (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ VisualPtr pVisual = NULL;
+ char *pbits = NULL;
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ int iReturn;
+#endif
+
+ /* Create framebuffer */
+ if (!(*pScreenPriv->pwinAllocateFB) (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - Could not allocate framebuffer\n");
+ return FALSE;
+ }
+
+ /*
+ * Grab the number of bits that are used to represent color in each pixel.
+ */
+ if (pScreenInfo->dwBPP == 8)
+ pScreenInfo->dwDepth = 8;
+ else
+ pScreenInfo->dwDepth = winCountBits (pScreenPriv->dwRedMask)
+ + winCountBits (pScreenPriv->dwGreenMask)
+ + winCountBits (pScreenPriv->dwBlueMask);
+
+ winDebug ("winFinishScreenInitFB - Masks: %08x %08x %08x\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask);
+
+ /* Init visuals */
+ if (!(*pScreenPriv->pwinInitVisuals) (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - winInitVisuals failed\n");
+ return FALSE;
+ }
+
+ /* Setup a local variable to point to the framebuffer */
+ pbits = pScreenInfo->pfb;
+
+ /* Apparently we need this for the render extension */
+ miSetPixmapDepths ();
+
+ /* Start fb initialization */
+ if (!fbSetupScreen (pScreen,
+ pScreenInfo->pfb,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride,
+ pScreenInfo->dwBPP))
+ {
+ ErrorF ("winFinishScreenInitFB - fbSetupScreen failed\n");
+ return FALSE;
+ }
+
+ /* Override default colormap routines if visual class is dynamic */
+ if (pScreenInfo->dwDepth == 8
+ && (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
+ || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
+ && pScreenInfo->fFullScreen)
+ || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ && pScreenInfo->fFullScreen)))
+ {
+ winSetColormapFunctions (pScreen);
+
+ /*
+ * NOTE: Setting whitePixel to 255 causes Magic 7.1 to allocate its
+ * own colormap, as it cannot allocate 7 planes in the default
+ * colormap. Setting whitePixel to 1 allows Magic to get 7
+ * planes in the default colormap, so it doesn't create its
+ * own colormap. This latter situation is highly desireable,
+ * as it keeps the Magic window viewable when switching to
+ * other X clients that use the default colormap.
+ */
+ pScreen->blackPixel = 0;
+ pScreen->whitePixel = 1;
+ }
+
+ /* Place our save screen function */
+ pScreen->SaveScreen = winSaveScreen;
+
+ /* Finish fb initialization */
+ if (!fbFinishScreenInit (pScreen,
+ pScreenInfo->pfb,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride,
+ pScreenInfo->dwBPP))
+ {
+ ErrorF ("winFinishScreenInitFB - fbFinishScreenInit failed\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the root visual */
+ for (pVisual = pScreen->visuals;
+ pVisual->vid != pScreen->rootVisual;
+ pVisual++);
+ pScreenPriv->pRootVisual = pVisual;
+
+ /*
+ * Setup points to the block and wakeup handlers. Pass a pointer
+ * to the current screen as pWakeupdata.
+ */
+ pScreen->BlockHandler = winBlockHandler;
+ pScreen->WakeupHandler = winWakeupHandler;
+ pScreen->blockData = pScreen;
+ pScreen->wakeupData = pScreen;
+
+ /* Render extension initialization, calls miPictureInit */
+ if (!fbPictureInit (pScreen, NULL, 0))
+ {
+ ErrorF ("winFinishScreenInitFB - fbPictureInit () failed\n");
+ return FALSE;
+ }
+
+#ifdef RANDR
+ /* Initialize resize and rotate support */
+ if (!winRandRInit (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - winRandRInit () failed\n");
+ return FALSE;
+ }
+#endif
+
+ /*
+ * Backing store support should reduce network traffic and increase
+ * performance.
+ */
+ miInitializeBackingStore (pScreen);
+
+ /* KDrive does miDCInitialize right after miInitializeBackingStore */
+ /* Setup the cursor routines */
+ winDebug ("winFinishScreenInitFB - Calling miDCInitialize ()\n");
+ miDCInitialize (pScreen, &g_winPointerCursorFuncs);
+
+ /* KDrive does winCreateDefColormap right after miDCInitialize */
+ /* Create a default colormap */
+ winDebug ("winFinishScreenInitFB - Calling winCreateDefColormap ()\n");
+ if (!winCreateDefColormap (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - Could not create colormap\n");
+ return FALSE;
+ }
+
+ /* Initialize the shadow framebuffer layer */
+ if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
+ || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)
+#ifdef XWIN_MULTIWINDOWEXTWM
+ && !pScreenInfo->fMWExtWM
+#endif
+ )
+ {
+ winDebug ("winFinishScreenInitFB - Calling shadowSetup ()\n");
+ if (!shadowSetup(pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - shadowSetup () failed\n");
+ return FALSE;
+ }
+
+ /* Wrap CreateScreenResources so we can add the screen pixmap
+ to the Shadow framebuffer after it's been created */
+ pScreenPriv->pwinCreateScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = winCreateScreenResources;
+ }
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ /* Handle multi-window external window manager mode */
+ if (pScreenInfo->fMWExtWM)
+ {
+ winDebug ("winScreenInit - MultiWindowExtWM - Calling RootlessInit\n");
+
+ RootlessInit(pScreen, &winMWExtWMProcs);
+
+ winDebug ("winScreenInit - MultiWindowExtWM - RootlessInit returned\n");
+
+ rootless_CopyBytes_threshold = 0;
+ rootless_FillBytes_threshold = 0;
+ rootless_CompositePixels_threshold = 0;
+ /* FIXME: How many? Profiling needed? */
+ rootless_CopyWindow_threshold = 1;
+
+ winWindowsWMExtensionInit ();
+ }
+#endif
+
+ /* Handle rootless mode */
+ if (pScreenInfo->fRootless)
+ {
+ /* Define the WRAP macro temporarily for local use */
+#define WRAP(a) \
+ if (pScreen->a) { \
+ pScreenPriv->a = pScreen->a; \
+ } else { \
+ ErrorF("null screen fn " #a "\n"); \
+ pScreenPriv->a = NULL; \
+ }
+
+ /* Save a pointer to each lower-level window procedure */
+ WRAP(CreateWindow);
+ WRAP(DestroyWindow);
+ WRAP(RealizeWindow);
+ WRAP(UnrealizeWindow);
+ WRAP(PositionWindow);
+ WRAP(ChangeWindowAttributes);
+ WRAP(SetShape);
+
+ /* Assign rootless window procedures to be top level procedures */
+ pScreen->CreateWindow = winCreateWindowRootless;
+ pScreen->DestroyWindow = winDestroyWindowRootless;
+ pScreen->PositionWindow = winPositionWindowRootless;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesRootless;*/
+ pScreen->RealizeWindow = winMapWindowRootless;
+ pScreen->UnrealizeWindow = winUnmapWindowRootless;
+ pScreen->SetShape = winSetShapeRootless;
+
+ /* Undefine the WRAP macro, as it is not needed elsewhere */
+#undef WRAP
+ }
+
+
+#ifdef XWIN_MULTIWINDOW
+ /* Handle multi window mode */
+ else if (pScreenInfo->fMultiWindow)
+ {
+ /* Define the WRAP macro temporarily for local use */
+#define WRAP(a) \
+ if (pScreen->a) { \
+ pScreenPriv->a = pScreen->a; \
+ } else { \
+ ErrorF("null screen fn " #a "\n"); \
+ pScreenPriv->a = NULL; \
+ }
+
+ /* Save a pointer to each lower-level window procedure */
+ WRAP(CreateWindow);
+ WRAP(DestroyWindow);
+ WRAP(RealizeWindow);
+ WRAP(UnrealizeWindow);
+ WRAP(PositionWindow);
+ WRAP(ChangeWindowAttributes);
+ WRAP(ReparentWindow);
+ WRAP(RestackWindow);
+ WRAP(ResizeWindow);
+ WRAP(MoveWindow);
+ WRAP(CopyWindow);
+ WRAP(SetShape);
+
+ /* Assign multi-window window procedures to be top level procedures */
+ pScreen->CreateWindow = winCreateWindowMultiWindow;
+ pScreen->DestroyWindow = winDestroyWindowMultiWindow;
+ pScreen->PositionWindow = winPositionWindowMultiWindow;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesMultiWindow;*/
+ pScreen->RealizeWindow = winMapWindowMultiWindow;
+ pScreen->UnrealizeWindow = winUnmapWindowMultiWindow;
+ pScreen->ReparentWindow = winReparentWindowMultiWindow;
+ pScreen->RestackWindow = winRestackWindowMultiWindow;
+ pScreen->ResizeWindow = winResizeWindowMultiWindow;
+ pScreen->MoveWindow = winMoveWindowMultiWindow;
+ pScreen->CopyWindow = winCopyWindowMultiWindow;
+ pScreen->SetShape = winSetShapeMultiWindow;
+
+ /* Undefine the WRAP macro, as it is not needed elsewhere */
+#undef WRAP
+ }
+#endif
+
+ /* Wrap either fb's or shadow's CloseScreen with our CloseScreen */
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Create a mutex for modules in separate threads to wait for */
+ iReturn = pthread_mutex_init (&pScreenPriv->pmServerStarted, NULL);
+ if (iReturn != 0)
+ {
+ ErrorF ("winFinishScreenInitFB - pthread_mutex_init () failed: %d\n",
+ iReturn);
+ return FALSE;
+ }
+
+ /* Own the mutex for modules in separate threads */
+ iReturn = pthread_mutex_lock (&pScreenPriv->pmServerStarted);
+ if (iReturn != 0)
+ {
+ ErrorF ("winFinishScreenInitFB - pthread_mutex_lock () failed: %d\n",
+ iReturn);
+ return FALSE;
+ }
+
+ /* Set the ServerStarted flag to false */
+ pScreenPriv->fServerStarted = FALSE;
+#endif
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ pScreenPriv->fRestacking = FALSE;
+#endif
+
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (FALSE
+#ifdef XWIN_MULTIWINDOW
+ || pScreenInfo->fMultiWindow
+#endif
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || pScreenInfo->fInternalWM
+#endif
+ )
+ {
+ winDebug ("winFinishScreenInitFB - Calling winInitWM.\n");
+
+ /* Initialize multi window mode */
+ if (!winInitWM (&pScreenPriv->pWMInfo,
+ &pScreenPriv->ptWMProc,
+ &pScreenPriv->ptXMsgProc,
+ &pScreenPriv->pmServerStarted,
+ pScreenInfo->dwScreen,
+ (HWND)&pScreenPriv->hwndScreen,
+#ifdef XWIN_MULTIWINDOWEXTWM
+ pScreenInfo->fInternalWM ||
+#endif
+ FALSE))
+ {
+ ErrorF ("winFinishScreenInitFB - winInitWM () failed.\n");
+ return FALSE;
+ }
+ }
+#endif
+
+ /* Tell the server that we are enabled */
+ pScreenPriv->fEnabled = TRUE;
+
+ /* Tell the server that we have a valid depth */
+ pScreenPriv->fBadDepth = FALSE;
+
+ winDebug ("winFinishScreenInitFB - returning\n");
+
+ return TRUE;
+}
+
+#ifdef XWIN_NATIVEGDI
+/* See Porting Layer Definition - p. 20 */
+
+Bool
+winFinishScreenInitNativeGDI (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv)
+{
+ winScreenPriv(pScreen);
+ winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
+ VisualPtr pVisuals = NULL;
+ DepthPtr pDepths = NULL;
+ VisualID rootVisual = 0;
+ int nVisuals = 0, nDepths = 0, nRootDepth = 0;
+
+ /* Ignore user input (mouse, keyboard) */
+ pScreenInfo->fIgnoreInput = FALSE;
+
+ /* Get device contexts for the screen and shadow bitmap */
+ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+ if (pScreenPriv->hdcScreen == NULL)
+ FatalError ("winFinishScreenInitNativeGDI - Couldn't get a DC\n");
+
+ /* Init visuals */
+ if (!(*pScreenPriv->pwinInitVisuals) (pScreen))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - pwinInitVisuals failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the mi visuals */
+ if (!miInitVisuals (&pVisuals, &pDepths, &nVisuals, &nDepths, &nRootDepth,
+ &rootVisual,
+ ((unsigned long)1 << (pScreenInfo->dwDepth - 1)), 8,
+ TrueColor))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miInitVisuals () failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the CloseScreen procedure pointer */
+ pScreen->CloseScreen = NULL;
+
+ /* Initialize the mi code */
+ if (!miScreenInit (pScreen,
+ NULL, /* No framebuffer */
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride,
+ nRootDepth, nDepths, pDepths, rootVisual,
+ nVisuals, pVisuals))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miScreenInit failed\n");
+ return FALSE;
+ }
+
+ pScreen->defColormap = FakeClientID(0);
+
+ /*
+ * Register our block and wakeup handlers; these procedures
+ * process messages in our Windows message queue; specifically,
+ * they process mouse and keyboard input.
+ */
+ pScreen->BlockHandler = winBlockHandler;
+ pScreen->WakeupHandler = winWakeupHandler;
+ pScreen->blockData = pScreen;
+ pScreen->wakeupData = pScreen;
+
+ /* Place our save screen function */
+ pScreen->SaveScreen = winSaveScreen;
+
+ /* Pixmaps */
+ pScreen->CreatePixmap = winCreatePixmapNativeGDI;
+ pScreen->DestroyPixmap = winDestroyPixmapNativeGDI;
+
+ /* Other Screen Routines */
+ pScreen->QueryBestSize = winQueryBestSizeNativeGDI;
+ pScreen->SaveScreen = winSaveScreen;
+ pScreen->GetImage = miGetImage;
+ pScreen->GetSpans = winGetSpansNativeGDI;
+
+ /* Window Procedures */
+ pScreen->CreateWindow = winCreateWindowNativeGDI;
+ pScreen->DestroyWindow = winDestroyWindowNativeGDI;
+ pScreen->PositionWindow = winPositionWindowNativeGDI;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesNativeGDI;*/
+ pScreen->RealizeWindow = winMapWindowNativeGDI;
+ pScreen->UnrealizeWindow = winUnmapWindowNativeGDI;
+
+ /* Paint window */
+ pScreen->CopyWindow = winCopyWindowNativeGDI;
+
+ /* Fonts */
+ pScreen->RealizeFont = winRealizeFontNativeGDI;
+ pScreen->UnrealizeFont = winUnrealizeFontNativeGDI;
+
+ /* GC */
+ pScreen->CreateGC = winCreateGCNativeGDI;
+
+ /* Colormap Routines */
+ pScreen->CreateColormap = miInitializeColormap;
+ pScreen->DestroyColormap = (DestroyColormapProcPtr) (void (*)(void)) NoopDDA;
+ pScreen->InstallColormap = miInstallColormap;
+ pScreen->UninstallColormap = miUninstallColormap;
+ pScreen->ListInstalledColormaps = miListInstalledColormaps;
+ pScreen->StoreColors = (StoreColorsProcPtr) (void (*)(void)) NoopDDA;
+ pScreen->ResolveColor = miResolveColor;
+
+ /* Bitmap */
+ pScreen->BitmapToRegion = winPixmapToRegionNativeGDI;
+
+ winDebug ("winFinishScreenInitNativeGDI - calling miDCInitialize\n");
+
+ /* Set the default white and black pixel positions */
+ pScreen->whitePixel = pScreen->blackPixel = (Pixel) 0;
+
+ /* Initialize the cursor */
+ if (!miDCInitialize (pScreen, &g_winPointerCursorFuncs))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miDCInitialize failed\n");
+ return FALSE;
+ }
+
+ /* Create a default colormap */
+ if (!miCreateDefColormap (pScreen))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () "
+ "failed\n");
+ return FALSE;
+ }
+
+ winDebug ("winFinishScreenInitNativeGDI - miCreateDefColormap () "
+ "returned\n");
+
+ /* mi doesn't use a CloseScreen procedure, so no need to wrap */
+ pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
+
+ /* Tell the server that we are enabled */
+ pScreenPriv->fEnabled = TRUE;
+
+ winDebug ("winFinishScreenInitNativeGDI - Successful addition of "
+ "screen %08x\n",
+ (unsigned int) pScreen);
+
+ return TRUE;
+}
+#endif
+
+
+/* See Porting Layer Definition - p. 33 */
+static Bool
+winSaveScreen (ScreenPtr pScreen, int on)
+{
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winsetsp.c b/xorg-server/hw/xwin/winsetsp.c index 674e147d4..d1803489a 100644 --- a/xorg-server/hw/xwin/winsetsp.c +++ b/xorg-server/hw/xwin/winsetsp.c @@ -1,191 +1,191 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Harold L Hunt II - * Alan Hourihane <alanh@fairlite.demon.co.uk> - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - -typedef struct mybitmap -{ +/*
+ *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+typedef struct mybitmap
+{
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[256]; /* Maximum palette used in case of 8-bit per pixel */
-} mybitmap_t; - -/* See Porting Layer Definition - p. 55 */ -void -winSetSpansNativeGDI (DrawablePtr pDrawable, - GCPtr pGC, - char *pSrcs, - DDXPointPtr pPoints, - int *piWidths, - int iSpans, - int fSorted) -{ - winGCPriv(pGC); - PixmapPtr pPixmap = NULL; - winPrivPixmapPtr pPixmapPriv = NULL; - HBITMAP hbmpOrig = NULL; - mybitmap_t bmi; - HRGN hrgn = NULL, combined = NULL; - int nbox; - BoxPtr pbox; - - nbox = REGION_NUM_RECTS (pGC->pCompositeClip); - pbox = REGION_RECTS (pGC->pCompositeClip); - - if (!nbox) return; - - combined = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2); - nbox--; pbox++; - while (nbox--) - { - hrgn = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2); - CombineRgn (combined, combined, hrgn, RGN_OR); - DeleteObject (hrgn); - hrgn = NULL; - pbox++; - } - - /* Branch on the drawable type */ - switch (pDrawable->type) - { - case DRAWABLE_PIXMAP: - - SelectClipRgn (pGCPriv->hdcMem, combined); - DeleteObject (combined); - combined = NULL; - - pPixmap = (PixmapPtr) pDrawable; - pPixmapPriv = winGetPixmapPriv (pPixmap); - - /* Select the drawable pixmap into a DC */ - hbmpOrig = SelectObject (pGCPriv->hdcMem, pPixmapPriv->hBitmap); - if (hbmpOrig == NULL) - FatalError ("winSetSpans - DRAWABLE_PIXMAP - SelectObject () " - "failed on pPixmapPriv->hBitmap\n"); - - while (iSpans--) - { - ZeroMemory (&bmi, sizeof (mybitmap_t)); - bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER); - bmi.bmiHeader.biWidth = *piWidths; - bmi.bmiHeader.biHeight = 1; - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biBitCount = pDrawable->depth; - bmi.bmiHeader.biCompression = BI_RGB; - - /* Setup color table for mono DIBs */ - if (pDrawable->depth == 1) - { - bmi.bmiColors[1].rgbBlue = 255; - bmi.bmiColors[1].rgbGreen = 255; - bmi.bmiColors[1].rgbRed = 255; - } - - StretchDIBits (pGCPriv->hdcMem, - pPoints->x, pPoints->y, - *piWidths, 1, - 0, 0, - *piWidths, 1, - pSrcs, - (BITMAPINFO*)&bmi, - DIB_RGB_COLORS, - g_copyROP[pGC->alu]); - - pSrcs += PixmapBytePad (*piWidths, pDrawable->depth); - pPoints++; - piWidths++; - } - - /* Reset the clip region */ - SelectClipRgn (pGCPriv->hdcMem, NULL); - - /* Push the drawable pixmap out of the GC HDC */ - SelectObject (pGCPriv->hdcMem, hbmpOrig); - break; - - case DRAWABLE_WINDOW: - - SelectClipRgn (pGCPriv->hdc, combined); - DeleteObject (combined); - combined = NULL; - - while (iSpans--) - { - ZeroMemory (&bmi, sizeof (mybitmap_t)); - bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER); - bmi.bmiHeader.biWidth = *piWidths; - bmi.bmiHeader.biHeight = 1; - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biBitCount = pDrawable->depth; - bmi.bmiHeader.biCompression = BI_RGB; - - /* Setup color table for mono DIBs */ - if (pDrawable->depth == 1) - { - bmi.bmiColors[1].rgbBlue = 255; - bmi.bmiColors[1].rgbGreen = 255; - bmi.bmiColors[1].rgbRed = 255; - } - - StretchDIBits (pGCPriv->hdc, - pPoints->x, pPoints->y, - *piWidths, 1, - 0, 0, - *piWidths, 1, - pSrcs, - (BITMAPINFO *) &bmi, - DIB_RGB_COLORS, - g_copyROP[pGC->alu]); - - pSrcs += PixmapBytePad (*piWidths, pDrawable->depth); - pPoints++; - piWidths++; - } - - /* Reset the clip region */ - SelectClipRgn (pGCPriv->hdc, NULL); - break; - - case UNDRAWABLE_WINDOW: - FatalError ("\nwinSetSpansNativeGDI - UNDRAWABLE_WINDOW\n\n"); - break; - - case DRAWABLE_BUFFER: - FatalError ("\nwinSetSpansNativeGDI - DRAWABLE_BUFFER\n\n"); - break; - - default: - FatalError ("\nwinSetSpansNativeGDI - Unknown drawable type\n\n"); - break; - } -} +} mybitmap_t;
+
+/* See Porting Layer Definition - p. 55 */
+void
+winSetSpansNativeGDI (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pSrcs,
+ DDXPointPtr pPoints,
+ int *piWidths,
+ int iSpans,
+ int fSorted)
+{
+ winGCPriv(pGC);
+ PixmapPtr pPixmap = NULL;
+ winPrivPixmapPtr pPixmapPriv = NULL;
+ HBITMAP hbmpOrig = NULL;
+ mybitmap_t bmi;
+ HRGN hrgn = NULL, combined = NULL;
+ int nbox;
+ BoxPtr pbox;
+
+ nbox = RegionNumRects (pGC->pCompositeClip);
+ pbox = RegionRects (pGC->pCompositeClip);
+
+ if (!nbox) return;
+
+ combined = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ nbox--; pbox++;
+ while (nbox--)
+ {
+ hrgn = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ CombineRgn (combined, combined, hrgn, RGN_OR);
+ DeleteObject (hrgn);
+ hrgn = NULL;
+ pbox++;
+ }
+
+ /* Branch on the drawable type */
+ switch (pDrawable->type)
+ {
+ case DRAWABLE_PIXMAP:
+
+ SelectClipRgn (pGCPriv->hdcMem, combined);
+ DeleteObject (combined);
+ combined = NULL;
+
+ pPixmap = (PixmapPtr) pDrawable;
+ pPixmapPriv = winGetPixmapPriv (pPixmap);
+
+ /* Select the drawable pixmap into a DC */
+ hbmpOrig = SelectObject (pGCPriv->hdcMem, pPixmapPriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError ("winSetSpans - DRAWABLE_PIXMAP - SelectObject () "
+ "failed on pPixmapPriv->hBitmap\n");
+
+ while (iSpans--)
+ {
+ ZeroMemory (&bmi, sizeof (mybitmap_t));
+ bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = *piWidths;
+ bmi.bmiHeader.biHeight = 1;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = pDrawable->depth;
+ bmi.bmiHeader.biCompression = BI_RGB;
+
+ /* Setup color table for mono DIBs */
+ if (pDrawable->depth == 1)
+ {
+ bmi.bmiColors[1].rgbBlue = 255;
+ bmi.bmiColors[1].rgbGreen = 255;
+ bmi.bmiColors[1].rgbRed = 255;
+ }
+
+ StretchDIBits (pGCPriv->hdcMem,
+ pPoints->x, pPoints->y,
+ *piWidths, 1,
+ 0, 0,
+ *piWidths, 1,
+ pSrcs,
+ (BITMAPINFO*)&bmi,
+ DIB_RGB_COLORS,
+ g_copyROP[pGC->alu]);
+
+ pSrcs += PixmapBytePad (*piWidths, pDrawable->depth);
+ pPoints++;
+ piWidths++;
+ }
+
+ /* Reset the clip region */
+ SelectClipRgn (pGCPriv->hdcMem, NULL);
+
+ /* Push the drawable pixmap out of the GC HDC */
+ SelectObject (pGCPriv->hdcMem, hbmpOrig);
+ break;
+
+ case DRAWABLE_WINDOW:
+
+ SelectClipRgn (pGCPriv->hdc, combined);
+ DeleteObject (combined);
+ combined = NULL;
+
+ while (iSpans--)
+ {
+ ZeroMemory (&bmi, sizeof (mybitmap_t));
+ bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = *piWidths;
+ bmi.bmiHeader.biHeight = 1;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = pDrawable->depth;
+ bmi.bmiHeader.biCompression = BI_RGB;
+
+ /* Setup color table for mono DIBs */
+ if (pDrawable->depth == 1)
+ {
+ bmi.bmiColors[1].rgbBlue = 255;
+ bmi.bmiColors[1].rgbGreen = 255;
+ bmi.bmiColors[1].rgbRed = 255;
+ }
+
+ StretchDIBits (pGCPriv->hdc,
+ pPoints->x, pPoints->y,
+ *piWidths, 1,
+ 0, 0,
+ *piWidths, 1,
+ pSrcs,
+ (BITMAPINFO *) &bmi,
+ DIB_RGB_COLORS,
+ g_copyROP[pGC->alu]);
+
+ pSrcs += PixmapBytePad (*piWidths, pDrawable->depth);
+ pPoints++;
+ piWidths++;
+ }
+
+ /* Reset the clip region */
+ SelectClipRgn (pGCPriv->hdc, NULL);
+ break;
+
+ case UNDRAWABLE_WINDOW:
+ FatalError ("\nwinSetSpansNativeGDI - UNDRAWABLE_WINDOW\n\n");
+ break;
+
+ case DRAWABLE_BUFFER:
+ FatalError ("\nwinSetSpansNativeGDI - DRAWABLE_BUFFER\n\n");
+ break;
+
+ default:
+ FatalError ("\nwinSetSpansNativeGDI - Unknown drawable type\n\n");
+ break;
+ }
+}
diff --git a/xorg-server/hw/xwin/winshaddd.c b/xorg-server/hw/xwin/winshaddd.c index 4d82ef714..4644a8493 100644 --- a/xorg-server/hw/xwin/winshaddd.c +++ b/xorg-server/hw/xwin/winshaddd.c @@ -1,1413 +1,1413 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - - -/* - * External symbols - */ - -extern HWND g_hDlgExit; -extern const char *g_pszLogFile; - - - -/* - * Local prototypes - */ - -static Bool -winAllocateFBShadowDD (ScreenPtr pScreen); - -static void -winShadowUpdateDD (ScreenPtr pScreen, - shadowBufPtr pBuf); - -static Bool -winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen); - -static Bool -winInitVisualsShadowDD (ScreenPtr pScreen); - -static Bool -winAdjustVideoModeShadowDD (ScreenPtr pScreen); - -static Bool -winBltExposedRegionsShadowDD (ScreenPtr pScreen); - -static Bool -winActivateAppShadowDD (ScreenPtr pScreen); - -static Bool -winRedrawScreenShadowDD (ScreenPtr pScreen); - -static Bool -winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen); - -static Bool -winInstallColormapShadowDD (ColormapPtr pColormap); - -static Bool -winStoreColorsShadowDD (ColormapPtr pmap, - int ndef, - xColorItem *pdefs); - -static Bool -winCreateColormapShadowDD (ColormapPtr pColormap); - -static Bool -winDestroyColormapShadowDD (ColormapPtr pColormap); - -static Bool -winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen); - -static Bool -winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen); - - -/* - * Create the primary surface and attach the clipper. - * Used for both the initial surface creation and during - * WM_DISPLAYCHANGE messages. - */ - -static Bool -winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - HRESULT ddrval = DD_OK; - DDSURFACEDESC ddsd; - - /* Describe the primary surface */ - ZeroMemory (&ddsd, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); - ddsd.dwFlags = DDSD_CAPS; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - - /* Create the primary surface */ - ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2, - &ddsd, - &pScreenPriv->pddsPrimary, - NULL); - if (FAILED (ddrval)) - { - ErrorF ("winCreatePrimarySurfaceShadowDD - Could not create primary " - "surface: %08x\n", (unsigned int) ddrval); - return FALSE; - } - - winDebug ("winCreatePrimarySurfaceShadowDD - Created primary surface\n"); - - /* - * Attach a clipper to the primary surface that will clip our blits to our - * display window. - */ - ddrval = IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary, - pScreenPriv->pddcPrimary); - if (FAILED (ddrval)) - { - ErrorF ("winCreatePrimarySurfaceShadowDD - Primary attach clipper " - "failed: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - - winDebug ("winCreatePrimarySurfaceShadowDD - Attached clipper to " - "primary surface\n"); - - /* Everything was correct */ - return TRUE; -} - - -/* - * Detach the clipper and release the primary surface. - * Called from WM_DISPLAYCHANGE. - */ - -static Bool -winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - - winDebug ("winReleasePrimarySurfaceShadowDD - Hello\n"); - - /* Release the primary surface and clipper, if they exist */ - if (pScreenPriv->pddsPrimary) - { - /* - * Detach the clipper from the primary surface. - * NOTE: We do this explicity for clarity. The Clipper is not released. - */ - IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary, - NULL); - - winDebug ("winReleasePrimarySurfaceShadowDD - Detached clipper\n"); - - /* Release the primary surface */ - IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary); - pScreenPriv->pddsPrimary = NULL; - } - - winDebug ("winReleasePrimarySurfaceShadowDD - Released primary surface\n"); - - return TRUE; -} - - -/* - * Create a DirectDraw surface for the shadow framebuffer; also create - * a primary surface object so we can blit to the display. - * - * Install a DirectDraw clipper on our primary surface object - * that clips our blits to the unobscured client area of our display window. - */ - -static Bool -winAllocateFBShadowDD (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - HRESULT ddrval = DD_OK; - DDSURFACEDESC ddsd; - DDSURFACEDESC *pddsdShadow = NULL; - - winDebug ("winAllocateFBShadowDD\n"); - - /* Create a clipper */ - ddrval = (*g_fpDirectDrawCreateClipper) (0, - &pScreenPriv->pddcPrimary, - NULL); - if (FAILED (ddrval)) - { - ErrorF ("winAllocateFBShadowDD - Could not create clipper: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - - winDebug ("winAllocateFBShadowDD - Created a clipper\n"); - - /* Get a device context for the screen */ - pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen); - - /* Attach the clipper to our display window */ - ddrval = IDirectDrawClipper_SetHWnd (pScreenPriv->pddcPrimary, - 0, - pScreenPriv->hwndScreen); - if (FAILED (ddrval)) - { - ErrorF ("winAllocateFBShadowDD - Clipper not attached to " - "window: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - - winDebug ("winAllocateFBShadowDD - Attached clipper to window\n"); - - /* Create a DirectDraw object, store the address at lpdd */ - ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL); - if (FAILED (ddrval)) - { - ErrorF ("winAllocateFBShadowDD - Could not start DirectDraw: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - - winDebug ("winAllocateFBShadowDD () - Created and initialized DD\n"); - - /* Get a DirectDraw2 interface pointer */ - ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd, - &IID_IDirectDraw2, - (LPVOID*) &pScreenPriv->pdd2); - if (FAILED (ddrval)) - { - ErrorF ("winAllocateFBShadowDD - Failed DD2 query: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - - /* Are we full screen? */ - if (pScreenInfo->fFullScreen) - { - DDSURFACEDESC ddsdCurrent; - DWORD dwRefreshRateCurrent = 0; - HDC hdc = NULL; - - /* Set the cooperative level to full screen */ - ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2, - pScreenPriv->hwndScreen, - DDSCL_EXCLUSIVE - | DDSCL_FULLSCREEN); - if (FAILED (ddrval)) - { - ErrorF ("winAllocateFBShadowDD - Could not set " - "cooperative level: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - - /* - * We only need to get the current refresh rate for comparison - * if a refresh rate has been passed on the command line. - */ - if (pScreenInfo->dwRefreshRate != 0) - { - ZeroMemory (&ddsdCurrent, sizeof (ddsdCurrent)); - ddsdCurrent.dwSize = sizeof (ddsdCurrent); - - /* Get information about current display settings */ - ddrval = IDirectDraw2_GetDisplayMode (pScreenPriv->pdd2, - &ddsdCurrent); - if (FAILED (ddrval)) - { - ErrorF ("winAllocateFBShadowDD - Could not get current " - "refresh rate: %08x. Continuing.\n", - (unsigned int) ddrval); - dwRefreshRateCurrent = 0; - } - else - { - /* Grab the current refresh rate */ - dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate; - } - } - - /* Clean up the refresh rate */ - if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate) - { - /* - * Refresh rate is non-specified or equal to current. - */ - pScreenInfo->dwRefreshRate = 0; - } - - /* Grab a device context for the screen */ - hdc = GetDC (NULL); - if (hdc == NULL) - { - ErrorF ("winAllocateFBShadowDD - GetDC () failed\n"); - return FALSE; - } - - /* Only change the video mode when different than current mode */ - if (!pScreenInfo->fMultipleMonitors - && (pScreenInfo->dwWidth != GetSystemMetrics (SM_CXSCREEN) - || pScreenInfo->dwHeight != GetSystemMetrics (SM_CYSCREEN) - || pScreenInfo->dwBPP != GetDeviceCaps (hdc, BITSPIXEL) - || pScreenInfo->dwRefreshRate != 0)) - { - winDebug ("winAllocateFBShadowDD - Changing video mode\n"); - - /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */ - ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2, - pScreenInfo->dwWidth, - pScreenInfo->dwHeight, - pScreenInfo->dwBPP, - pScreenInfo->dwRefreshRate, - 0); - if (FAILED (ddrval)) - { - ErrorF ("winAllocateFBShadowDD - Could not set "\ - "full screen display mode: %08x\n", - (unsigned int) ddrval); - ErrorF ("winAllocateFBShadowDD - Using default driver refresh rate\n"); - ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2, - pScreenInfo->dwWidth, - pScreenInfo->dwHeight, - pScreenInfo->dwBPP, - 0, - 0); - if (FAILED(ddrval)) - { - ErrorF ("winAllocateFBShadowDD - Could not set default refresh rate " - "full screen display mode: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - } - } - else - { - winDebug ("winAllocateFBShadowDD - Not changing video mode\n"); - } - - /* Release our DC */ - ReleaseDC (NULL, hdc); - hdc = NULL; - } - else - { - /* Set the cooperative level for windowed mode */ - ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2, - pScreenPriv->hwndScreen, - DDSCL_NORMAL); - if (FAILED (ddrval)) - { - ErrorF ("winAllocateFBShadowDD - Could not set "\ - "cooperative level: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - } - - /* Create the primary surface */ - if (!winCreatePrimarySurfaceShadowDD (pScreen)) - { - ErrorF ("winAllocateFBShadowDD - winCreatePrimarySurfaceShadowDD " - "failed\n"); - return FALSE; - } - - /* Describe the shadow surface to be created */ - /* NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface, - * as drawing, locking, and unlocking take forever - * with video memory surfaces. In addition, - * video memory is a somewhat scarce resource, - * so you shouldn't be allocating video memory when - * you have the option of using system memory instead. - */ - ZeroMemory (&ddsd, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; - ddsd.dwHeight = pScreenInfo->dwHeight; - ddsd.dwWidth = pScreenInfo->dwWidth; - - /* Create the shadow surface */ - ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2, - &ddsd, - &pScreenPriv->pddsShadow, - NULL); - if (FAILED (ddrval)) - { - ErrorF ("winAllocateFBShadowDD - Could not create shadow "\ - "surface: %08x\n", (unsigned int) ddrval); - return FALSE; - } - - winDebug ("winAllocateFBShadowDD - Created shadow\n"); - - /* Allocate a DD surface description for our screen privates */ - pddsdShadow = pScreenPriv->pddsdShadow = malloc (sizeof (DDSURFACEDESC)); - if (pddsdShadow == NULL) - { - ErrorF ("winAllocateFBShadowDD - Could not allocate surface "\ - "description memory\n"); - return FALSE; - } - ZeroMemory (pddsdShadow, sizeof (*pddsdShadow)); - pddsdShadow->dwSize = sizeof (*pddsdShadow); - - winDebug ("winAllocateFBShadowDD - Locking shadow\n"); - - /* Lock the shadow surface */ - ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow, - NULL, - pddsdShadow, - DDLOCK_WAIT, - NULL); - if (FAILED (ddrval) || pddsdShadow->lpSurface == NULL) - { - ErrorF ("winAllocateFBShadowDD - Could not lock shadow "\ - "surface: %08x\n", (unsigned int) ddrval); - return FALSE; - } - - winDebug ("winAllocateFBShadowDD - Locked shadow\n"); - - /* We don't know how to deal with anything other than RGB */ - if (!(pddsdShadow->ddpfPixelFormat.dwFlags & DDPF_RGB)) - { - ErrorF ("winAllocateFBShadowDD - Color format other than RGB\n"); - return FALSE; - } - - /* Grab the pitch from the surface desc */ - pScreenInfo->dwStride = (pddsdShadow->u1.lPitch * 8) - / pScreenInfo->dwBPP; - - /* Save the pointer to our surface memory */ - pScreenInfo->pfb = pddsdShadow->lpSurface; - - /* Grab the color depth and masks from the surface description */ - pScreenPriv->dwRedMask = pddsdShadow->ddpfPixelFormat.u2.dwRBitMask; - pScreenPriv->dwGreenMask = pddsdShadow->ddpfPixelFormat.u3.dwGBitMask; - pScreenPriv->dwBlueMask = pddsdShadow->ddpfPixelFormat.u4.dwBBitMask; - - winDebug ("winAllocateFBShadowDD - Returning\n"); - - return TRUE; -} - - -/* - * Transfer the damaged regions of the shadow framebuffer to the display. - */ - -static void -winShadowUpdateDD (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - RegionPtr damage = shadowDamage(pBuf); - HRESULT ddrval = DD_OK; - RECT rcDest, rcSrc; - POINT ptOrigin; - DWORD dwBox = REGION_NUM_RECTS (damage); - BoxPtr pBox = REGION_RECTS (damage); - HRGN hrgnTemp = NULL, hrgnCombined = NULL; - - /* - * Return immediately if the app is not active - * and we are fullscreen, or if we have a bad display depth - */ - if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen) - || pScreenPriv->fBadDepth) return; - - /* Get the origin of the window in the screen coords */ - ptOrigin.x = pScreenInfo->dwXOffset; - ptOrigin.y = pScreenInfo->dwYOffset; - MapWindowPoints (pScreenPriv->hwndScreen, - HWND_DESKTOP, - (LPPOINT)&ptOrigin, 1); - - /* Unlock the shadow surface, so we can blit */ - ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL); - if (FAILED (ddrval)) - { - ErrorF ("winShadowUpdateDD - Unlock failed\n"); - return; - } - - /* - * Handle small regions with multiple blits, - * handle large regions by creating a clipping region and - * doing a single blit constrained to that clipping region. - */ - if (pScreenInfo->dwClipUpdatesNBoxes == 0 - || dwBox < pScreenInfo->dwClipUpdatesNBoxes) - { - /* Loop through all boxes in the damaged region */ - while (dwBox--) - { - /* Assign damage box to source rectangle */ - rcSrc.left = pBox->x1; - rcSrc.top = pBox->y1; - rcSrc.right = pBox->x2; - rcSrc.bottom = pBox->y2; - - /* Calculate destination rectange */ - rcDest.left = ptOrigin.x + rcSrc.left; - rcDest.top = ptOrigin.y + rcSrc.top; - rcDest.right = ptOrigin.x + rcSrc.right; - rcDest.bottom = ptOrigin.y + rcSrc.bottom; - - /* Blit the damaged areas */ - ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary, - &rcDest, - pScreenPriv->pddsShadow, - &rcSrc, - DDBLT_WAIT, - NULL); - - /* Get a pointer to the next box */ - ++pBox; - } - } - else - { - BoxPtr pBoxExtents = REGION_EXTENTS (pScreen, damage); - - /* Compute a GDI region from the damaged region */ - hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2); - dwBox--; - pBox++; - while (dwBox--) - { - hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2); - CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR); - DeleteObject (hrgnTemp); - pBox++; - } - - /* Install the GDI region as a clipping region */ - SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined); - DeleteObject (hrgnCombined); - hrgnCombined = NULL; - - /* Calculating a bounding box for the source is easy */ - rcSrc.left = pBoxExtents->x1; - rcSrc.top = pBoxExtents->y1; - rcSrc.right = pBoxExtents->x2; - rcSrc.bottom = pBoxExtents->y2; - - /* Calculating a bounding box for the destination is trickier */ - rcDest.left = ptOrigin.x + rcSrc.left; - rcDest.top = ptOrigin.y + rcSrc.top; - rcDest.right = ptOrigin.x + rcSrc.right; - rcDest.bottom = ptOrigin.y + rcSrc.bottom; - - /* Our Blt should be clipped to the invalidated region */ - ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary, - &rcDest, - pScreenPriv->pddsShadow, - &rcSrc, - DDBLT_WAIT, - NULL); - - /* Reset the clip region */ - SelectClipRgn (pScreenPriv->hdcScreen, NULL); - } - - /* Relock the shadow surface */ - ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow, - NULL, - pScreenPriv->pddsdShadow, - DDLOCK_WAIT, - NULL); - if (FAILED (ddrval)) - { - ErrorF ("winShadowUpdateDD - Lock failed\n"); - return; - } - - /* Has our memory pointer changed? */ - if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface) - { - extern const char *g_pszLogFile; - ErrorF ("winShadowUpdateDD - Memory location of the shadow " - "surface has changed, trying to update the root window " - "pixmap header to point to the new address. If you get " - "this message and "PROJECT_NAME" freezes or crashes " - "after this message then send a problem report and your " - "%s file to " BUILDERADDR "\n", g_pszLogFile); - - /* Location of shadow framebuffer has changed */ - pScreenInfo->pfb = pScreenPriv->pddsdShadow->lpSurface; - - /* Update the screen pixmap */ - if (!(*pScreen->ModifyPixmapHeader)(pScreen->devPrivate, - pScreen->width, - pScreen->height, - pScreen->rootDepth, - BitsPerPixel (pScreen->rootDepth), - PixmapBytePad (pScreenInfo->dwStride, - pScreenInfo->dwBPP), - pScreenInfo->pfb)) - { - ErrorF ("winShadowUpdateDD - Bits changed, could not " - "notify fb.\n"); - return; - } - } -} - - -/* - * Call the wrapped CloseScreen function. - * - * Free our resources and private structures. - */ - -static Bool -winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - Bool fReturn; - - winDebug ("winCloseScreenShadowDD - Freeing screen resources\n"); - - /* Flag that the screen is closed */ - pScreenPriv->fClosed = TRUE; - pScreenPriv->fActive = FALSE; - - /* Call the wrapped CloseScreen procedure */ - WIN_UNWRAP(CloseScreen); - fReturn = (*pScreen->CloseScreen) (nIndex, pScreen); - - /* Free the screen DC */ - ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen); - - /* Delete the window property */ - RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP); - - /* Free the shadow surface, if there is one */ - if (pScreenPriv->pddsShadow) - { - IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL); - IDirectDrawSurface2_Release (pScreenPriv->pddsShadow); - pScreenPriv->pddsShadow = NULL; - } - - /* Detach the clipper from the primary surface and release the clipper. */ - if (pScreenPriv->pddcPrimary) - { - /* Detach the clipper */ - IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary, - NULL); - - /* Release the clipper object */ - IDirectDrawClipper_Release (pScreenPriv->pddcPrimary); - pScreenPriv->pddcPrimary = NULL; - } - - /* Release the primary surface, if there is one */ - if (pScreenPriv->pddsPrimary) - { - IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary); - pScreenPriv->pddsPrimary = NULL; - } - - /* Free the DirectDraw2 object, if there is one */ - if (pScreenPriv->pdd2) - { - IDirectDraw2_RestoreDisplayMode (pScreenPriv->pdd2); - IDirectDraw2_Release (pScreenPriv->pdd2); - pScreenPriv->pdd2 = NULL; - } - - /* Free the DirectDraw object, if there is one */ - if (pScreenPriv->pdd) - { - IDirectDraw_Release (pScreenPriv->pdd); - pScreenPriv->pdd = NULL; - } - - /* Delete tray icon, if we have one */ - if (!pScreenInfo->fNoTrayIcon) - winDeleteNotifyIcon (pScreenPriv); - - /* Free the exit confirmation dialog box, if it exists */ - if (g_hDlgExit != NULL) - { - DestroyWindow (g_hDlgExit); - g_hDlgExit = NULL; - } - - /* Kill our window */ - if (pScreenPriv->hwndScreen) - { - DestroyWindow (pScreenPriv->hwndScreen); - pScreenPriv->hwndScreen = NULL; - } - -#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) - /* Destroy the thread startup mutex */ - pthread_mutex_destroy (&pScreenPriv->pmServerStarted); -#endif - - /* Kill our screeninfo's pointer to the screen */ - pScreenInfo->pScreen = NULL; - - /* Invalidate the ScreenInfo's fb pointer */ - pScreenInfo->pfb = NULL; - - /* Free the screen privates for this screen */ - free ((pointer) pScreenPriv); - - return fReturn; -} - - -/* - * Tell mi what sort of visuals we need. - * - * Generally we only need one visual, as our screen can only - * handle one format at a time, I believe. You may want - * to verify that last sentence. - */ - -static Bool -winInitVisualsShadowDD (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - DWORD dwRedBits, dwGreenBits, dwBlueBits; - - /* Count the number of ones in each color mask */ - dwRedBits = winCountBits (pScreenPriv->dwRedMask); - dwGreenBits = winCountBits (pScreenPriv->dwGreenMask); - dwBlueBits = winCountBits (pScreenPriv->dwBlueMask); - - /* Store the maximum number of ones in a color mask as the bitsPerRGB */ - if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0) - pScreenPriv->dwBitsPerRGB = 8; - else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits) - pScreenPriv->dwBitsPerRGB = dwRedBits; - else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits) - pScreenPriv->dwBitsPerRGB = dwGreenBits; - else - pScreenPriv->dwBitsPerRGB = dwBlueBits; - - winDebug ("winInitVisualsShadowDD - Masks %08x %08x %08x BPRGB %d d %d " - "bpp %d\n", - (unsigned int) pScreenPriv->dwRedMask, - (unsigned int) pScreenPriv->dwGreenMask, - (unsigned int) pScreenPriv->dwBlueMask, - (int) pScreenPriv->dwBitsPerRGB, - (int) pScreenInfo->dwDepth, - (int) pScreenInfo->dwBPP); - - /* Create a single visual according to the Windows screen depth */ - switch (pScreenInfo->dwDepth) - { - case 24: - case 16: - case 15: -#if defined(XFree86Server) - /* Create the real visual */ - if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth, - TrueColorMask, - pScreenPriv->dwBitsPerRGB, - TrueColor, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) - { - ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks " - "failed for TrueColor\n"); - return FALSE; - } - -#ifdef XWIN_EMULATEPSEUDO - if (!pScreenInfo->fEmulatePseudo) - break; - - /* Setup a pseudocolor visual */ - if (!miSetVisualTypesAndMasks (8, - PseudoColorMask, - 8, - -1, - 0, - 0, - 0)) - { - ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks " - "failed for PseudoColor\n"); - return FALSE; - } -#endif -#else /* XFree86Server */ - /* Create the real visual */ - if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth, - TrueColorMask, - pScreenPriv->dwBitsPerRGB, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) - { - ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks " - "failed for TrueColor\n"); - return FALSE; - } - -#ifdef XWIN_EMULATEPSEUDO - if (!pScreenInfo->fEmulatePseudo) - break; - - /* Setup a pseudocolor visual */ - if (!fbSetVisualTypesAndMasks (8, - PseudoColorMask, - 8, - 0, - 0, - 0)) - { - ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks " - "failed for PseudoColor\n"); - return FALSE; - } -#endif -#endif /* XFree86Server */ - break; - - case 8: -#if defined(XFree86Server) - if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth, - pScreenInfo->fFullScreen - ? PseudoColorMask : StaticColorMask, - pScreenPriv->dwBitsPerRGB, - pScreenInfo->fFullScreen - ? PseudoColor : StaticColor, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) - { - ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks " - "failed\n"); - return FALSE; - } -#else /* XFree86Server */ - if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth, - pScreenInfo->fFullScreen - ? PseudoColorMask : StaticColorMask, - pScreenPriv->dwBitsPerRGB, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) - { - ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks " - "failed\n"); - return FALSE; - } -#endif /* XFree86Server */ - break; - - default: - ErrorF ("winInitVisualsShadowDD - Unknown screen depth\n"); - return FALSE; - } - - winDebug ("winInitVisualsShadowDD - Returning\n"); - - return TRUE; -} - - -/* - * Adjust the user proposed video mode - */ - -static Bool -winAdjustVideoModeShadowDD (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - HDC hdc = NULL; - DWORD dwBPP; - - /* We're in serious trouble if we can't get a DC */ - hdc = GetDC (NULL); - if (hdc == NULL) - { - ErrorF ("winAdjustVideoModeShadowDD - GetDC () failed\n"); - return FALSE; - } - - /* Query GDI for current display depth */ - dwBPP = GetDeviceCaps (hdc, BITSPIXEL); - - /* DirectDraw can only change the depth in fullscreen mode */ - if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP) - { - /* No -depth parameter passed, let the user know the depth being used */ - winDebug ("winAdjustVideoModeShadowDD - Using Windows display " - "depth of %d bits per pixel\n", (int) dwBPP); - - /* Use GDI's depth */ - pScreenInfo->dwBPP = dwBPP; - } - else if (pScreenInfo->fFullScreen - && pScreenInfo->dwBPP != dwBPP) - { - /* FullScreen, and GDI depth differs from -depth parameter */ - winDebug ("winAdjustVideoModeShadowDD - FullScreen, using command line " - "bpp: %d\n", (int) pScreenInfo->dwBPP); - } - else if (dwBPP != pScreenInfo->dwBPP) - { - /* Windowed, and GDI depth differs from -depth parameter */ - winDebug ("winAdjustVideoModeShadowDD - Windowed, command line bpp: " - "%d, using bpp: %d\n", (int) pScreenInfo->dwBPP, (int) dwBPP); - - /* We'll use GDI's depth */ - pScreenInfo->dwBPP = dwBPP; - } - - /* See if the shadow bitmap will be larger than the DIB size limit */ - if (pScreenInfo->dwWidth * pScreenInfo->dwHeight * pScreenInfo->dwBPP - >= WIN_DIB_MAXIMUM_SIZE) - { - ErrorF ("winAdjustVideoModeShadowDD - Requested DirectDraw surface " - "will be larger than %d MB. The surface may fail to be " - "allocated on Windows 95, 98, or Me, due to a %d MB limit in " - "DIB size. This limit does not apply to Windows NT/2000, and " - "this message may be ignored on those platforms.\n", - WIN_DIB_MAXIMUM_SIZE_MB, WIN_DIB_MAXIMUM_SIZE_MB); - } - - /* Release our DC */ - ReleaseDC (NULL, hdc); - return TRUE; -} - - -/* - * Blt exposed regions to the screen - */ - -static Bool -winBltExposedRegionsShadowDD (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - RECT rcSrc, rcDest; - POINT ptOrigin; - HDC hdcUpdate = NULL; - PAINTSTRUCT ps; - HRESULT ddrval = DD_OK; - Bool fReturn = TRUE; - Bool fLocked = TRUE; - int i; - - /* BeginPaint gives us an hdc that clips to the invalidated region */ - hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps); - if (hdcUpdate == NULL) - { - ErrorF ("winBltExposedRegionsShadowDD - BeginPaint () returned " - "a NULL device context handle. Aborting blit attempt.\n"); - return FALSE; - } - - /* Unlock the shadow surface, so we can blit */ - ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL); - if (FAILED (ddrval)) - { - fReturn = FALSE; - goto winBltExposedRegionsShadowDD_Exit; - } - else - { - /* Flag that we have unlocked the shadow surface */ - fLocked = FALSE; - } - - /* Get the origin of the window in the screen coords */ - ptOrigin.x = pScreenInfo->dwXOffset; - ptOrigin.y = pScreenInfo->dwYOffset; - - MapWindowPoints (pScreenPriv->hwndScreen, - HWND_DESKTOP, - (LPPOINT)&ptOrigin, 1); - rcDest.left = ptOrigin.x; - rcDest.right = ptOrigin.x + pScreenInfo->dwWidth; - rcDest.top = ptOrigin.y; - rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight; - - /* Source can be enter shadow surface, as Blt should clip */ - rcSrc.left = 0; - rcSrc.top = 0; - rcSrc.right = pScreenInfo->dwWidth; - rcSrc.bottom = pScreenInfo->dwHeight; - - /* Try to regain the primary surface and blit again if we've lost it */ - for (i = 0; i <= WIN_REGAIN_SURFACE_RETRIES; ++i) - { - /* Our Blt should be clipped to the invalidated region */ - ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary, - &rcDest, - pScreenPriv->pddsShadow, - &rcSrc, - DDBLT_WAIT, - NULL); - if (ddrval == DDERR_SURFACELOST) - { - /* Surface was lost */ - ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt " - "reported that the primary surface was lost, " - "trying to restore, retry: %d\n", i + 1); - - /* Try to restore the surface, once */ - ddrval = IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary); - ErrorF ("winBltExposedRegionsShadowDD - " - "IDirectDrawSurface2_Restore returned: "); - if (ddrval == DD_OK) - ErrorF ("DD_OK\n"); - else if (ddrval == DDERR_WRONGMODE) - ErrorF ("DDERR_WRONGMODE\n"); - else if (ddrval == DDERR_INCOMPATIBLEPRIMARY) - ErrorF ("DDERR_INCOMPATIBLEPRIMARY\n"); - else if (ddrval == DDERR_UNSUPPORTED) - ErrorF ("DDERR_UNSUPPORTED\n"); - else if (ddrval == DDERR_INVALIDPARAMS) - ErrorF ("DDERR_INVALIDPARAMS\n"); - else if (ddrval == DDERR_INVALIDOBJECT) - ErrorF ("DDERR_INVALIDOBJECT\n"); - else - ErrorF ("unknown error: %08x\n", (unsigned int) ddrval); - - /* Loop around to try the blit one more time */ - continue; - } - else if (FAILED (ddrval)) - { - fReturn = FALSE; - ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt " - "failed, but surface not lost: %08x %d\n", - (unsigned int) ddrval, (int) ddrval); - goto winBltExposedRegionsShadowDD_Exit; - } - else - { - /* Success, stop looping */ - break; - } - } - - /* Relock the shadow surface */ - ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow, - NULL, - pScreenPriv->pddsdShadow, - DDLOCK_WAIT, - NULL); - if (FAILED (ddrval)) - { - fReturn = FALSE; - ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Lock " - "failed\n"); - goto winBltExposedRegionsShadowDD_Exit; - } - else - { - /* Indicate that we have relocked the shadow surface */ - fLocked = TRUE; - } - - /* Has our memory pointer changed? */ - if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface) - winUpdateFBPointer (pScreen, - pScreenPriv->pddsdShadow->lpSurface); - - winBltExposedRegionsShadowDD_Exit: - /* EndPaint frees the DC */ - if (hdcUpdate != NULL) - EndPaint (pScreenPriv->hwndScreen, &ps); - - /* - * Relock the surface if it is not locked. We don't care if locking fails, - * as it will cause the server to shutdown within a few more operations. - */ - if (!fLocked) - { - IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow, - NULL, - pScreenPriv->pddsdShadow, - DDLOCK_WAIT, - NULL); - - /* Has our memory pointer changed? */ - if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface) - winUpdateFBPointer (pScreen, - pScreenPriv->pddsdShadow->lpSurface); - - fLocked = TRUE; - } - return fReturn; -} - - -/* - * Do any engine-specific appliation-activation processing - */ - -static Bool -winActivateAppShadowDD (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - - /* - * Do we have a surface? - * Are we active? - * Are we fullscreen? - */ - if (pScreenPriv != NULL - && pScreenPriv->pddsPrimary != NULL - && pScreenPriv->fActive) - { - /* Primary surface was lost, restore it */ - IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary); - } - - return TRUE; -} - - -/* - * Reblit the shadow framebuffer to the screen. - */ - -static Bool -winRedrawScreenShadowDD (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - HRESULT ddrval = DD_OK; - RECT rcSrc, rcDest; - POINT ptOrigin; - - /* Get the origin of the window in the screen coords */ - ptOrigin.x = pScreenInfo->dwXOffset; - ptOrigin.y = pScreenInfo->dwYOffset; - MapWindowPoints (pScreenPriv->hwndScreen, - HWND_DESKTOP, - (LPPOINT)&ptOrigin, 1); - rcDest.left = ptOrigin.x; - rcDest.right = ptOrigin.x + pScreenInfo->dwWidth; - rcDest.top = ptOrigin.y; - rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight; - - /* Source can be entire shadow surface, as Blt should clip for us */ - rcSrc.left = 0; - rcSrc.top = 0; - rcSrc.right = pScreenInfo->dwWidth; - rcSrc.bottom = pScreenInfo->dwHeight; - - /* Redraw the whole window, to take account for the new colors */ - ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary, - &rcDest, - pScreenPriv->pddsShadow, - &rcSrc, - DDBLT_WAIT, - NULL); - if (FAILED (ddrval)) - { - ErrorF ("winRedrawScreenShadowDD - IDirectDrawSurface_Blt () " - "failed: %08x\n", - (unsigned int) ddrval); - } - - return TRUE; -} - - -/* - * Realize the currently installed colormap - */ - -static Bool -winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen) -{ - return TRUE; -} - - -/* - * Install the specified colormap - */ - -static Bool -winInstallColormapShadowDD (ColormapPtr pColormap) -{ - ScreenPtr pScreen = pColormap->pScreen; - winScreenPriv(pScreen); - winCmapPriv(pColormap); - HRESULT ddrval = DD_OK; - - /* Install the DirectDraw palette on the primary surface */ - ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary, - pCmapPriv->lpDDPalette); - if (FAILED (ddrval)) - { - ErrorF ("winInstallColormapShadowDD - Failed installing the " - "DirectDraw palette.\n"); - return FALSE; - } - - /* Save a pointer to the newly installed colormap */ - pScreenPriv->pcmapInstalled = pColormap; - - return TRUE; -} - - -/* - * Store the specified colors in the specified colormap - */ - -static Bool -winStoreColorsShadowDD (ColormapPtr pColormap, - int ndef, - xColorItem *pdefs) -{ - ScreenPtr pScreen = pColormap->pScreen; - winScreenPriv(pScreen); - winCmapPriv(pColormap); - ColormapPtr curpmap = pScreenPriv->pcmapInstalled; - HRESULT ddrval = DD_OK; - - /* Put the X colormap entries into the Windows logical palette */ - ddrval = IDirectDrawPalette_SetEntries (pCmapPriv->lpDDPalette, - 0, - pdefs[0].pixel, - ndef, - pCmapPriv->peColors - + pdefs[0].pixel); - if (FAILED (ddrval)) - { - ErrorF ("winStoreColorsShadowDD - SetEntries () failed\n"); - return FALSE; - } - - /* Don't install the DirectDraw palette if the colormap is not installed */ - if (pColormap != curpmap) - { - return TRUE; - } - - if (!winInstallColormapShadowDD (pColormap)) - { - ErrorF ("winStoreColorsShadowDD - Failed installing colormap\n"); - return FALSE; - } - - return TRUE; -} - - -/* - * Colormap initialization procedure - */ - -static Bool -winCreateColormapShadowDD (ColormapPtr pColormap) -{ - HRESULT ddrval = DD_OK; - ScreenPtr pScreen = pColormap->pScreen; - winScreenPriv(pScreen); - winCmapPriv(pColormap); - - /* Create a DirectDraw palette */ - ddrval = IDirectDraw2_CreatePalette (pScreenPriv->pdd, - DDPCAPS_8BIT | DDPCAPS_ALLOW256, - pCmapPriv->peColors, - &pCmapPriv->lpDDPalette, - NULL); - if (FAILED (ddrval)) - { - ErrorF ("winCreateColormapShadowDD - CreatePalette failed\n"); - return FALSE; - } - - return TRUE; -} - - -/* - * Colormap destruction procedure - */ - -static Bool -winDestroyColormapShadowDD (ColormapPtr pColormap) -{ - winScreenPriv(pColormap->pScreen); - winCmapPriv(pColormap); - HRESULT ddrval = DD_OK; - - /* - * Is colormap to be destroyed the default? - * - * Non-default colormaps should have had winUninstallColormap - * called on them before we get here. The default colormap - * will not have had winUninstallColormap called on it. Thus, - * we need to handle the default colormap in a special way. - */ - if (pColormap->flags & IsDefault) - { - winDebug ("winDestroyColormapShadowDD - Destroying default " - "colormap\n"); - - /* - * FIXME: Walk the list of all screens, popping the default - * palette out of each screen device context. - */ - - /* Pop the palette out of the primary surface */ - ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary, - NULL); - if (FAILED (ddrval)) - { - ErrorF ("winDestroyColormapShadowDD - Failed freeing the " - "default colormap DirectDraw palette.\n"); - return FALSE; - } - - /* Clear our private installed colormap pointer */ - pScreenPriv->pcmapInstalled = NULL; - } - - /* Release the palette */ - IDirectDrawPalette_Release (pCmapPriv->lpDDPalette); - - /* Invalidate the colormap privates */ - pCmapPriv->lpDDPalette = NULL; - - return TRUE; -} - - -/* - * Set engine specific functions - */ - -Bool -winSetEngineFunctionsShadowDD (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Set our pointers */ - pScreenPriv->pwinAllocateFB = winAllocateFBShadowDD; - pScreenPriv->pwinShadowUpdate = winShadowUpdateDD; - pScreenPriv->pwinCloseScreen = winCloseScreenShadowDD; - pScreenPriv->pwinInitVisuals = winInitVisualsShadowDD; - pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDD; - if (pScreenInfo->fFullScreen) - pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen; - else - pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed; - pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB; - pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDD; - pScreenPriv->pwinActivateApp = winActivateAppShadowDD; - pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDD; - pScreenPriv->pwinRealizeInstalledPalette - = winRealizeInstalledPaletteShadowDD; - pScreenPriv->pwinInstallColormap = winInstallColormapShadowDD; - pScreenPriv->pwinStoreColors = winStoreColorsShadowDD; - pScreenPriv->pwinCreateColormap = winCreateColormapShadowDD; - pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDD; - pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA; - pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDD; - pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDD; -#ifdef XWIN_MULTIWINDOW - pScreenPriv->pwinFinishCreateWindowsWindow = - (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA; -#endif - - return TRUE; -} +/*
+ *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * External symbols
+ */
+
+extern HWND g_hDlgExit;
+extern const char *g_pszLogFile;
+
+
+
+/*
+ * Local prototypes
+ */
+
+static Bool
+winAllocateFBShadowDD (ScreenPtr pScreen);
+
+static void
+winShadowUpdateDD (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+static Bool
+winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsShadowDD (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModeShadowDD (ScreenPtr pScreen);
+
+static Bool
+winBltExposedRegionsShadowDD (ScreenPtr pScreen);
+
+static Bool
+winActivateAppShadowDD (ScreenPtr pScreen);
+
+static Bool
+winRedrawScreenShadowDD (ScreenPtr pScreen);
+
+static Bool
+winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen);
+
+static Bool
+winInstallColormapShadowDD (ColormapPtr pColormap);
+
+static Bool
+winStoreColorsShadowDD (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs);
+
+static Bool
+winCreateColormapShadowDD (ColormapPtr pColormap);
+
+static Bool
+winDestroyColormapShadowDD (ColormapPtr pColormap);
+
+static Bool
+winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen);
+
+static Bool
+winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen);
+
+
+/*
+ * Create the primary surface and attach the clipper.
+ * Used for both the initial surface creation and during
+ * WM_DISPLAYCHANGE messages.
+ */
+
+static Bool
+winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC ddsd;
+
+ /* Describe the primary surface */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
+ &ddsd,
+ &pScreenPriv->pddsPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreatePrimarySurfaceShadowDD - Could not create primary "
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winCreatePrimarySurfaceShadowDD - Created primary surface\n");
+
+ /*
+ * Attach a clipper to the primary surface that will clip our blits to our
+ * display window.
+ */
+ ddrval = IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
+ pScreenPriv->pddcPrimary);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreatePrimarySurfaceShadowDD - Primary attach clipper "
+ "failed: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winCreatePrimarySurfaceShadowDD - Attached clipper to "
+ "primary surface\n");
+
+ /* Everything was correct */
+ return TRUE;
+}
+
+
+/*
+ * Detach the clipper and release the primary surface.
+ * Called from WM_DISPLAYCHANGE.
+ */
+
+static Bool
+winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ winDebug ("winReleasePrimarySurfaceShadowDD - Hello\n");
+
+ /* Release the primary surface and clipper, if they exist */
+ if (pScreenPriv->pddsPrimary)
+ {
+ /*
+ * Detach the clipper from the primary surface.
+ * NOTE: We do this explicity for clarity. The Clipper is not released.
+ */
+ IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
+ NULL);
+
+ winDebug ("winReleasePrimarySurfaceShadowDD - Detached clipper\n");
+
+ /* Release the primary surface */
+ IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
+ pScreenPriv->pddsPrimary = NULL;
+ }
+
+ winDebug ("winReleasePrimarySurfaceShadowDD - Released primary surface\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Create a DirectDraw surface for the shadow framebuffer; also create
+ * a primary surface object so we can blit to the display.
+ *
+ * Install a DirectDraw clipper on our primary surface object
+ * that clips our blits to the unobscured client area of our display window.
+ */
+
+static Bool
+winAllocateFBShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC ddsd;
+ DDSURFACEDESC *pddsdShadow = NULL;
+
+ winDebug ("winAllocateFBShadowDD\n");
+
+ /* Create a clipper */
+ ddrval = (*g_fpDirectDrawCreateClipper) (0,
+ &pScreenPriv->pddcPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not create clipper: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDD - Created a clipper\n");
+
+ /* Get a device context for the screen */
+ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+
+ /* Attach the clipper to our display window */
+ ddrval = IDirectDrawClipper_SetHWnd (pScreenPriv->pddcPrimary,
+ 0,
+ pScreenPriv->hwndScreen);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Clipper not attached to "
+ "window: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDD - Attached clipper to window\n");
+
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not start DirectDraw: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDD () - Created and initialized DD\n");
+
+ /* Get a DirectDraw2 interface pointer */
+ ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
+ &IID_IDirectDraw2,
+ (LPVOID*) &pScreenPriv->pdd2);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /* Are we full screen? */
+ if (pScreenInfo->fFullScreen)
+ {
+ DDSURFACEDESC ddsdCurrent;
+ DWORD dwRefreshRateCurrent = 0;
+ HDC hdc = NULL;
+
+ /* Set the cooperative level to full screen */
+ ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_EXCLUSIVE
+ | DDSCL_FULLSCREEN);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not set "
+ "cooperative level: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /*
+ * We only need to get the current refresh rate for comparison
+ * if a refresh rate has been passed on the command line.
+ */
+ if (pScreenInfo->dwRefreshRate != 0)
+ {
+ ZeroMemory (&ddsdCurrent, sizeof (ddsdCurrent));
+ ddsdCurrent.dwSize = sizeof (ddsdCurrent);
+
+ /* Get information about current display settings */
+ ddrval = IDirectDraw2_GetDisplayMode (pScreenPriv->pdd2,
+ &ddsdCurrent);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not get current "
+ "refresh rate: %08x. Continuing.\n",
+ (unsigned int) ddrval);
+ dwRefreshRateCurrent = 0;
+ }
+ else
+ {
+ /* Grab the current refresh rate */
+ dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
+ }
+ }
+
+ /* Clean up the refresh rate */
+ if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate)
+ {
+ /*
+ * Refresh rate is non-specified or equal to current.
+ */
+ pScreenInfo->dwRefreshRate = 0;
+ }
+
+ /* Grab a device context for the screen */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDD - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Only change the video mode when different than current mode */
+ if (!pScreenInfo->fMultipleMonitors
+ && (pScreenInfo->dwWidth != GetSystemMetrics (SM_CXSCREEN)
+ || pScreenInfo->dwHeight != GetSystemMetrics (SM_CYSCREEN)
+ || pScreenInfo->dwBPP != GetDeviceCaps (hdc, BITSPIXEL)
+ || pScreenInfo->dwRefreshRate != 0))
+ {
+ winDebug ("winAllocateFBShadowDD - Changing video mode\n");
+
+ /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */
+ ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ pScreenInfo->dwRefreshRate,
+ 0);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not set "\
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ ErrorF ("winAllocateFBShadowDD - Using default driver refresh rate\n");
+ ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ 0,
+ 0);
+ if (FAILED(ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not set default refresh rate "
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+ }
+ else
+ {
+ winDebug ("winAllocateFBShadowDD - Not changing video mode\n");
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+ }
+ else
+ {
+ /* Set the cooperative level for windowed mode */
+ ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_NORMAL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not set "\
+ "cooperative level: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+
+ /* Create the primary surface */
+ if (!winCreatePrimarySurfaceShadowDD (pScreen))
+ {
+ ErrorF ("winAllocateFBShadowDD - winCreatePrimarySurfaceShadowDD "
+ "failed\n");
+ return FALSE;
+ }
+
+ /* Describe the shadow surface to be created */
+ /* NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
+ * as drawing, locking, and unlocking take forever
+ * with video memory surfaces. In addition,
+ * video memory is a somewhat scarce resource,
+ * so you shouldn't be allocating video memory when
+ * you have the option of using system memory instead.
+ */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
+ ddsd.dwHeight = pScreenInfo->dwHeight;
+ ddsd.dwWidth = pScreenInfo->dwWidth;
+
+ /* Create the shadow surface */
+ ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
+ &ddsd,
+ &pScreenPriv->pddsShadow,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not create shadow "\
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDD - Created shadow\n");
+
+ /* Allocate a DD surface description for our screen privates */
+ pddsdShadow = pScreenPriv->pddsdShadow = malloc (sizeof (DDSURFACEDESC));
+ if (pddsdShadow == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not allocate surface "\
+ "description memory\n");
+ return FALSE;
+ }
+ ZeroMemory (pddsdShadow, sizeof (*pddsdShadow));
+ pddsdShadow->dwSize = sizeof (*pddsdShadow);
+
+ winDebug ("winAllocateFBShadowDD - Locking shadow\n");
+
+ /* Lock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+ if (FAILED (ddrval) || pddsdShadow->lpSurface == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not lock shadow "\
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDD - Locked shadow\n");
+
+ /* We don't know how to deal with anything other than RGB */
+ if (!(pddsdShadow->ddpfPixelFormat.dwFlags & DDPF_RGB))
+ {
+ ErrorF ("winAllocateFBShadowDD - Color format other than RGB\n");
+ return FALSE;
+ }
+
+ /* Grab the pitch from the surface desc */
+ pScreenInfo->dwStride = (pddsdShadow->u1.lPitch * 8)
+ / pScreenInfo->dwBPP;
+
+ /* Save the pointer to our surface memory */
+ pScreenInfo->pfb = pddsdShadow->lpSurface;
+
+ /* Grab the color depth and masks from the surface description */
+ pScreenPriv->dwRedMask = pddsdShadow->ddpfPixelFormat.u2.dwRBitMask;
+ pScreenPriv->dwGreenMask = pddsdShadow->ddpfPixelFormat.u3.dwGBitMask;
+ pScreenPriv->dwBlueMask = pddsdShadow->ddpfPixelFormat.u4.dwBBitMask;
+
+ winDebug ("winAllocateFBShadowDD - Returning\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Transfer the damaged regions of the shadow framebuffer to the display.
+ */
+
+static void
+winShadowUpdateDD (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RegionPtr damage = shadowDamage(pBuf);
+ HRESULT ddrval = DD_OK;
+ RECT rcDest, rcSrc;
+ POINT ptOrigin;
+ DWORD dwBox = RegionNumRects (damage);
+ BoxPtr pBox = RegionRects (damage);
+ HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+
+ /*
+ * Return immediately if the app is not active
+ * and we are fullscreen, or if we have a bad display depth
+ */
+ if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
+ || pScreenPriv->fBadDepth) return;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+
+ /* Unlock the shadow surface, so we can blit */
+ ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winShadowUpdateDD - Unlock failed\n");
+ return;
+ }
+
+ /*
+ * Handle small regions with multiple blits,
+ * handle large regions by creating a clipping region and
+ * doing a single blit constrained to that clipping region.
+ */
+ if (pScreenInfo->dwClipUpdatesNBoxes == 0
+ || dwBox < pScreenInfo->dwClipUpdatesNBoxes)
+ {
+ /* Loop through all boxes in the damaged region */
+ while (dwBox--)
+ {
+ /* Assign damage box to source rectangle */
+ rcSrc.left = pBox->x1;
+ rcSrc.top = pBox->y1;
+ rcSrc.right = pBox->x2;
+ rcSrc.bottom = pBox->y2;
+
+ /* Calculate destination rectange */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Blit the damaged areas */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+
+ /* Get a pointer to the next box */
+ ++pBox;
+ }
+ }
+ else
+ {
+ BoxPtr pBoxExtents = RegionExtents(damage);
+
+ /* Compute a GDI region from the damaged region */
+ hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ dwBox--;
+ pBox++;
+ while (dwBox--)
+ {
+ hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
+ DeleteObject (hrgnTemp);
+ pBox++;
+ }
+
+ /* Install the GDI region as a clipping region */
+ SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
+ DeleteObject (hrgnCombined);
+ hrgnCombined = NULL;
+
+ /* Calculating a bounding box for the source is easy */
+ rcSrc.left = pBoxExtents->x1;
+ rcSrc.top = pBoxExtents->y1;
+ rcSrc.right = pBoxExtents->x2;
+ rcSrc.bottom = pBoxExtents->y2;
+
+ /* Calculating a bounding box for the destination is trickier */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+
+ /* Reset the clip region */
+ SelectClipRgn (pScreenPriv->hdcScreen, NULL);
+ }
+
+ /* Relock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winShadowUpdateDD - Lock failed\n");
+ return;
+ }
+
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ {
+ extern const char *g_pszLogFile;
+ ErrorF ("winShadowUpdateDD - Memory location of the shadow "
+ "surface has changed, trying to update the root window "
+ "pixmap header to point to the new address. If you get "
+ "this message and "PROJECT_NAME" freezes or crashes "
+ "after this message then send a problem report and your "
+ "%s file to " BUILDERADDR "\n", g_pszLogFile);
+
+ /* Location of shadow framebuffer has changed */
+ pScreenInfo->pfb = pScreenPriv->pddsdShadow->lpSurface;
+
+ /* Update the screen pixmap */
+ if (!(*pScreen->ModifyPixmapHeader)(pScreen->devPrivate,
+ pScreen->width,
+ pScreen->height,
+ pScreen->rootDepth,
+ BitsPerPixel (pScreen->rootDepth),
+ PixmapBytePad (pScreenInfo->dwStride,
+ pScreenInfo->dwBPP),
+ pScreenInfo->pfb))
+ {
+ ErrorF ("winShadowUpdateDD - Bits changed, could not "
+ "notify fb.\n");
+ return;
+ }
+ }
+}
+
+
+/*
+ * Call the wrapped CloseScreen function.
+ *
+ * Free our resources and private structures.
+ */
+
+static Bool
+winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+ winDebug ("winCloseScreenShadowDD - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ /* Free the screen DC */
+ ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ /* Free the shadow surface, if there is one */
+ if (pScreenPriv->pddsShadow)
+ {
+ IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
+ IDirectDrawSurface2_Release (pScreenPriv->pddsShadow);
+ pScreenPriv->pddsShadow = NULL;
+ }
+
+ /* Detach the clipper from the primary surface and release the clipper. */
+ if (pScreenPriv->pddcPrimary)
+ {
+ /* Detach the clipper */
+ IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
+ NULL);
+
+ /* Release the clipper object */
+ IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
+ pScreenPriv->pddcPrimary = NULL;
+ }
+
+ /* Release the primary surface, if there is one */
+ if (pScreenPriv->pddsPrimary)
+ {
+ IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
+ pScreenPriv->pddsPrimary = NULL;
+ }
+
+ /* Free the DirectDraw2 object, if there is one */
+ if (pScreenPriv->pdd2)
+ {
+ IDirectDraw2_RestoreDisplayMode (pScreenPriv->pdd2);
+ IDirectDraw2_Release (pScreenPriv->pdd2);
+ pScreenPriv->pdd2 = NULL;
+ }
+
+ /* Free the DirectDraw object, if there is one */
+ if (pScreenPriv->pdd)
+ {
+ IDirectDraw_Release (pScreenPriv->pdd);
+ pScreenPriv->pdd = NULL;
+ }
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon (pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen)
+ {
+ DestroyWindow (pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
+ }
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Destroy the thread startup mutex */
+ pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
+#endif
+
+ /* Kill our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
+
+ /* Free the screen privates for this screen */
+ free ((pointer) pScreenPriv);
+
+ return fReturn;
+}
+
+
+/*
+ * Tell mi what sort of visuals we need.
+ *
+ * Generally we only need one visual, as our screen can only
+ * handle one format at a time, I believe. You may want
+ * to verify that last sentence.
+ */
+
+static Bool
+winInitVisualsShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Count the number of ones in each color mask */
+ dwRedBits = winCountBits (pScreenPriv->dwRedMask);
+ dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
+ dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
+
+ /* Store the maximum number of ones in a color mask as the bitsPerRGB */
+ if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
+ pScreenPriv->dwBitsPerRGB = 8;
+ else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ winDebug ("winInitVisualsShadowDD - Masks %08x %08x %08x BPRGB %d d %d "
+ "bpp %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB,
+ (int) pScreenInfo->dwDepth,
+ (int) pScreenInfo->dwBPP);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ case 16:
+ case 15:
+#if defined(XFree86Server)
+ /* Create the real visual */
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ TrueColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!miSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ -1,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+#else /* XFree86Server */
+ /* Create the real visual */
+ if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!fbSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+#endif /* XFree86Server */
+ break;
+
+ case 8:
+#if defined(XFree86Server)
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ pScreenInfo->fFullScreen
+ ? PseudoColorMask : StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenInfo->fFullScreen
+ ? PseudoColor : StaticColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+#else /* XFree86Server */
+ if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ pScreenInfo->fFullScreen
+ ? PseudoColorMask : StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+#endif /* XFree86Server */
+ break;
+
+ default:
+ ErrorF ("winInitVisualsShadowDD - Unknown screen depth\n");
+ return FALSE;
+ }
+
+ winDebug ("winInitVisualsShadowDD - Returning\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Adjust the user proposed video mode
+ */
+
+static Bool
+winAdjustVideoModeShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ /* We're in serious trouble if we can't get a DC */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModeShadowDD - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* DirectDraw can only change the depth in fullscreen mode */
+ if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
+ {
+ /* No -depth parameter passed, let the user know the depth being used */
+ winDebug ("winAdjustVideoModeShadowDD - Using Windows display "
+ "depth of %d bits per pixel\n", (int) dwBPP);
+
+ /* Use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+ else if (pScreenInfo->fFullScreen
+ && pScreenInfo->dwBPP != dwBPP)
+ {
+ /* FullScreen, and GDI depth differs from -depth parameter */
+ winDebug ("winAdjustVideoModeShadowDD - FullScreen, using command line "
+ "bpp: %d\n", (int) pScreenInfo->dwBPP);
+ }
+ else if (dwBPP != pScreenInfo->dwBPP)
+ {
+ /* Windowed, and GDI depth differs from -depth parameter */
+ winDebug ("winAdjustVideoModeShadowDD - Windowed, command line bpp: "
+ "%d, using bpp: %d\n", (int) pScreenInfo->dwBPP, (int) dwBPP);
+
+ /* We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+
+ /* See if the shadow bitmap will be larger than the DIB size limit */
+ if (pScreenInfo->dwWidth * pScreenInfo->dwHeight * pScreenInfo->dwBPP
+ >= WIN_DIB_MAXIMUM_SIZE)
+ {
+ ErrorF ("winAdjustVideoModeShadowDD - Requested DirectDraw surface "
+ "will be larger than %d MB. The surface may fail to be "
+ "allocated on Windows 95, 98, or Me, due to a %d MB limit in "
+ "DIB size. This limit does not apply to Windows NT/2000, and "
+ "this message may be ignored on those platforms.\n",
+ WIN_DIB_MAXIMUM_SIZE_MB, WIN_DIB_MAXIMUM_SIZE_MB);
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+ return TRUE;
+}
+
+
+/*
+ * Blt exposed regions to the screen
+ */
+
+static Bool
+winBltExposedRegionsShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+ HDC hdcUpdate = NULL;
+ PAINTSTRUCT ps;
+ HRESULT ddrval = DD_OK;
+ Bool fReturn = TRUE;
+ Bool fLocked = TRUE;
+ int i;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
+ if (hdcUpdate == NULL)
+ {
+ ErrorF ("winBltExposedRegionsShadowDD - BeginPaint () returned "
+ "a NULL device context handle. Aborting blit attempt.\n");
+ return FALSE;
+ }
+
+ /* Unlock the shadow surface, so we can blit */
+ ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
+ if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+ else
+ {
+ /* Flag that we have unlocked the shadow surface */
+ fLocked = FALSE;
+ }
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be enter shadow surface, as Blt should clip */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Try to regain the primary surface and blit again if we've lost it */
+ for (i = 0; i <= WIN_REGAIN_SURFACE_RETRIES; ++i)
+ {
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (ddrval == DDERR_SURFACELOST)
+ {
+ /* Surface was lost */
+ ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
+ "reported that the primary surface was lost, "
+ "trying to restore, retry: %d\n", i + 1);
+
+ /* Try to restore the surface, once */
+ ddrval = IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
+ ErrorF ("winBltExposedRegionsShadowDD - "
+ "IDirectDrawSurface2_Restore returned: ");
+ if (ddrval == DD_OK)
+ ErrorF ("DD_OK\n");
+ else if (ddrval == DDERR_WRONGMODE)
+ ErrorF ("DDERR_WRONGMODE\n");
+ else if (ddrval == DDERR_INCOMPATIBLEPRIMARY)
+ ErrorF ("DDERR_INCOMPATIBLEPRIMARY\n");
+ else if (ddrval == DDERR_UNSUPPORTED)
+ ErrorF ("DDERR_UNSUPPORTED\n");
+ else if (ddrval == DDERR_INVALIDPARAMS)
+ ErrorF ("DDERR_INVALIDPARAMS\n");
+ else if (ddrval == DDERR_INVALIDOBJECT)
+ ErrorF ("DDERR_INVALIDOBJECT\n");
+ else
+ ErrorF ("unknown error: %08x\n", (unsigned int) ddrval);
+
+ /* Loop around to try the blit one more time */
+ continue;
+ }
+ else if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
+ "failed, but surface not lost: %08x %d\n",
+ (unsigned int) ddrval, (int) ddrval);
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+ else
+ {
+ /* Success, stop looping */
+ break;
+ }
+ }
+
+ /* Relock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Lock "
+ "failed\n");
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+ else
+ {
+ /* Indicate that we have relocked the shadow surface */
+ fLocked = TRUE;
+ }
+
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ winUpdateFBPointer (pScreen,
+ pScreenPriv->pddsdShadow->lpSurface);
+
+ winBltExposedRegionsShadowDD_Exit:
+ /* EndPaint frees the DC */
+ if (hdcUpdate != NULL)
+ EndPaint (pScreenPriv->hwndScreen, &ps);
+
+ /*
+ * Relock the surface if it is not locked. We don't care if locking fails,
+ * as it will cause the server to shutdown within a few more operations.
+ */
+ if (!fLocked)
+ {
+ IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ winUpdateFBPointer (pScreen,
+ pScreenPriv->pddsdShadow->lpSurface);
+
+ fLocked = TRUE;
+ }
+ return fReturn;
+}
+
+
+/*
+ * Do any engine-specific appliation-activation processing
+ */
+
+static Bool
+winActivateAppShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ /*
+ * Do we have a surface?
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->pddsPrimary != NULL
+ && pScreenPriv->fActive)
+ {
+ /* Primary surface was lost, restore it */
+ IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Reblit the shadow framebuffer to the screen.
+ */
+
+static Bool
+winRedrawScreenShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be entire shadow surface, as Blt should clip for us */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Redraw the whole window, to take account for the new colors */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winRedrawScreenShadowDD - IDirectDrawSurface_Blt () "
+ "failed: %08x\n",
+ (unsigned int) ddrval);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Realize the currently installed colormap
+ */
+
+static Bool
+winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+
+/*
+ * Install the specified colormap
+ */
+
+static Bool
+winInstallColormapShadowDD (ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /* Install the DirectDraw palette on the primary surface */
+ ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
+ pCmapPriv->lpDDPalette);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winInstallColormapShadowDD - Failed installing the "
+ "DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+
+ return TRUE;
+}
+
+
+/*
+ * Store the specified colors in the specified colormap
+ */
+
+static Bool
+winStoreColorsShadowDD (ColormapPtr pColormap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+ HRESULT ddrval = DD_OK;
+
+ /* Put the X colormap entries into the Windows logical palette */
+ ddrval = IDirectDrawPalette_SetEntries (pCmapPriv->lpDDPalette,
+ 0,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->peColors
+ + pdefs[0].pixel);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winStoreColorsShadowDD - SetEntries () failed\n");
+ return FALSE;
+ }
+
+ /* Don't install the DirectDraw palette if the colormap is not installed */
+ if (pColormap != curpmap)
+ {
+ return TRUE;
+ }
+
+ if (!winInstallColormapShadowDD (pColormap))
+ {
+ ErrorF ("winStoreColorsShadowDD - Failed installing colormap\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap initialization procedure
+ */
+
+static Bool
+winCreateColormapShadowDD (ColormapPtr pColormap)
+{
+ HRESULT ddrval = DD_OK;
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+
+ /* Create a DirectDraw palette */
+ ddrval = IDirectDraw2_CreatePalette (pScreenPriv->pdd,
+ DDPCAPS_8BIT | DDPCAPS_ALLOW256,
+ pCmapPriv->peColors,
+ &pCmapPriv->lpDDPalette,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreateColormapShadowDD - CreatePalette failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap destruction procedure
+ */
+
+static Bool
+winDestroyColormapShadowDD (ColormapPtr pColormap)
+{
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /*
+ * Is colormap to be destroyed the default?
+ *
+ * Non-default colormaps should have had winUninstallColormap
+ * called on them before we get here. The default colormap
+ * will not have had winUninstallColormap called on it. Thus,
+ * we need to handle the default colormap in a special way.
+ */
+ if (pColormap->flags & IsDefault)
+ {
+ winDebug ("winDestroyColormapShadowDD - Destroying default "
+ "colormap\n");
+
+ /*
+ * FIXME: Walk the list of all screens, popping the default
+ * palette out of each screen device context.
+ */
+
+ /* Pop the palette out of the primary surface */
+ ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winDestroyColormapShadowDD - Failed freeing the "
+ "default colormap DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Clear our private installed colormap pointer */
+ pScreenPriv->pcmapInstalled = NULL;
+ }
+
+ /* Release the palette */
+ IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
+
+ /* Invalidate the colormap privates */
+ pCmapPriv->lpDDPalette = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Set engine specific functions
+ */
+
+Bool
+winSetEngineFunctionsShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBShadowDD;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateDD;
+ pScreenPriv->pwinCloseScreen = winCloseScreenShadowDD;
+ pScreenPriv->pwinInitVisuals = winInitVisualsShadowDD;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDD;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDD;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowDD;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDD;
+ pScreenPriv->pwinRealizeInstalledPalette
+ = winRealizeInstalledPaletteShadowDD;
+ pScreenPriv->pwinInstallColormap = winInstallColormapShadowDD;
+ pScreenPriv->pwinStoreColors = winStoreColorsShadowDD;
+ pScreenPriv->pwinCreateColormap = winCreateColormapShadowDD;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDD;
+ pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDD;
+ pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDD;
+#ifdef XWIN_MULTIWINDOW
+ pScreenPriv->pwinFinishCreateWindowsWindow =
+ (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
+#endif
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winshadddnl.c b/xorg-server/hw/xwin/winshadddnl.c index af7b989df..95fb0e6fc 100644 --- a/xorg-server/hw/xwin/winshadddnl.c +++ b/xorg-server/hw/xwin/winshadddnl.c @@ -583,8 +583,8 @@ winShadowUpdateDDNL (ScreenPtr pScreen, HRESULT ddrval = DD_OK;
RECT rcDest, rcSrc;
POINT ptOrigin;
- DWORD dwBox = REGION_NUM_RECTS (damage);
- BoxPtr pBox = REGION_RECTS (damage);
+ DWORD dwBox = RegionNumRects (damage);
+ BoxPtr pBox = RegionRects (damage);
HRGN hrgnTemp = NULL, hrgnCombined = NULL;
/*
@@ -659,7 +659,7 @@ winShadowUpdateDDNL (ScreenPtr pScreen, }
else
{
- BoxPtr pBoxExtents = REGION_EXTENTS (pScreen, damage);
+ BoxPtr pBoxExtents = RegionExtents(damage);
/* Compute a GDI region from the damaged region */
hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
diff --git a/xorg-server/hw/xwin/winshadgdi.c b/xorg-server/hw/xwin/winshadgdi.c index fbc15abb3..09135c702 100644 --- a/xorg-server/hw/xwin/winshadgdi.c +++ b/xorg-server/hw/xwin/winshadgdi.c @@ -1,1302 +1,1302 @@ -/* - *Copyright (C) 2001-2004 Harold L Hunt II 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 HAROLD L HUNT II 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 of Harold L Hunt II - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from Harold L Hunt II. - * - * Authors: Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - - -/* - * External symbols - */ - -#ifdef XWIN_MULTIWINDOW -extern DWORD g_dwCurrentThreadID; -#endif -extern HWND g_hDlgExit; - - -/* - * Local function prototypes - */ - -#ifdef XWIN_MULTIWINDOW -static wBOOL CALLBACK -winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam); - -static wBOOL CALLBACK -winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam); -#endif - -static Bool -winAllocateFBShadowGDI (ScreenPtr pScreen); - -static void -winShadowUpdateGDI (ScreenPtr pScreen, - shadowBufPtr pBuf); - -static Bool -winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen); - -static Bool -winInitVisualsShadowGDI (ScreenPtr pScreen); - -static Bool -winAdjustVideoModeShadowGDI (ScreenPtr pScreen); - -static Bool -winBltExposedRegionsShadowGDI (ScreenPtr pScreen); - -static Bool -winActivateAppShadowGDI (ScreenPtr pScreen); - -static Bool -winRedrawScreenShadowGDI (ScreenPtr pScreen); - -static Bool -winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen); - -static Bool -winInstallColormapShadowGDI (ColormapPtr pColormap); - -static Bool -winStoreColorsShadowGDI (ColormapPtr pmap, - int ndef, - xColorItem *pdefs); - -static Bool -winCreateColormapShadowGDI (ColormapPtr pColormap); - -static Bool -winDestroyColormapShadowGDI (ColormapPtr pColormap); - - -/* - * Internal function to get the DIB format that is compatible with the screen - */ - -static -Bool -winQueryScreenDIBFormat (ScreenPtr pScreen, BITMAPINFOHEADER *pbmih) -{ - winScreenPriv(pScreen); - HBITMAP hbmp; -#ifdef WINDBG - LPDWORD pdw = NULL; -#endif - - /* Create a memory bitmap compatible with the screen */ - hbmp = CreateCompatibleBitmap (pScreenPriv->hdcScreen, 1, 1); - if (hbmp == NULL) - { - ErrorF ("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n"); - return FALSE; - } - - /* Initialize our bitmap info header */ - ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD)); - pbmih->biSize = sizeof (BITMAPINFOHEADER); - - /* Get the biBitCount */ - if (!GetDIBits (pScreenPriv->hdcScreen, - hbmp, - 0, 1, - NULL, - (BITMAPINFO*) pbmih, - DIB_RGB_COLORS)) - { - ErrorF ("winQueryScreenDIBFormat - First call to GetDIBits failed\n"); - DeleteObject (hbmp); - return FALSE; - } - -#ifdef WINDBG - /* Get a pointer to bitfields */ - pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER)); - - winDebug ("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n", - pdw[0], pdw[1], pdw[2]); -#endif - - /* Get optimal color table, or the optimal bitfields */ - if (!GetDIBits (pScreenPriv->hdcScreen, - hbmp, - 0, 1, - NULL, - (BITMAPINFO*)pbmih, - DIB_RGB_COLORS)) - { - ErrorF ("winQueryScreenDIBFormat - Second call to GetDIBits " - "failed\n"); - DeleteObject (hbmp); - return FALSE; - } - - /* Free memory */ - DeleteObject (hbmp); - - return TRUE; -} - - -/* - * Internal function to determine the GDI bits per rgb and bit masks - */ - -static -Bool -winQueryRGBBitsAndMasks (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - BITMAPINFOHEADER *pbmih = NULL; - Bool fReturn = TRUE; - LPDWORD pdw = NULL; - DWORD dwRedBits, dwGreenBits, dwBlueBits; - - /* Color masks for 8 bpp are standardized */ - if (GetDeviceCaps (pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE) - { - /* - * RGB BPP for 8 bit palletes is always 8 - * and the color masks are always 0. - */ - pScreenPriv->dwBitsPerRGB = 8; - pScreenPriv->dwRedMask = 0x0L; - pScreenPriv->dwGreenMask = 0x0L; - pScreenPriv->dwBlueMask = 0x0L; - return TRUE; - } - - /* Color masks for 24 bpp are standardized */ - if (GetDeviceCaps (pScreenPriv->hdcScreen, PLANES) - * GetDeviceCaps (pScreenPriv->hdcScreen, BITSPIXEL) == 24) - { - winDebug ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) " - "returned 24 for the screen. Using default 24bpp masks.\n"); - - /* 8 bits per primary color */ - pScreenPriv->dwBitsPerRGB = 8; - - /* Set screen privates masks */ - pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED; - pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN; - pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE; - - return TRUE; - } - - /* Allocate a bitmap header and color table */ - pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER) - + 256 * sizeof (RGBQUAD)); - if (pbmih == NULL) - { - ErrorF ("winQueryRGBBitsAndMasks - malloc failed\n"); - return FALSE; - } - - /* Get screen description */ - if (winQueryScreenDIBFormat (pScreen, pbmih)) - { - /* Get a pointer to bitfields */ - pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER)); - -#ifdef WINDBG - winDebug ("%s - Masks: %08x %08x %08x\n", __FUNCTION__, - pdw[0], pdw[1], pdw[2]); - winDebug ("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__, - pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount, pbmih->biPlanes); - winDebug ("%s - Compression: %d %s\n", __FUNCTION__, - pbmih->biCompression, - (pbmih->biCompression == BI_RGB?"(BI_RGB)": - (pbmih->biCompression == BI_RLE8?"(BI_RLE8)": - (pbmih->biCompression == BI_RLE4?"(BI_RLE4)": - (pbmih->biCompression == BI_BITFIELDS?"(BI_BITFIELDS)":"" - ))))); -#endif - - /* Handle BI_RGB case, which is returned by Wine */ - if (pbmih->biCompression == BI_RGB) - { - dwRedBits = 5; - dwGreenBits = 5; - dwBlueBits = 5; - - pScreenPriv->dwBitsPerRGB = 5; - - /* Set screen privates masks */ - pScreenPriv->dwRedMask = 0x7c00; - pScreenPriv->dwGreenMask = 0x03e0; - pScreenPriv->dwBlueMask = 0x001f; - } - else - { - /* Count the number of bits in each mask */ - dwRedBits = winCountBits (pdw[0]); - dwGreenBits = winCountBits (pdw[1]); - dwBlueBits = winCountBits (pdw[2]); - - /* Find maximum bits per red, green, blue */ - if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits) - pScreenPriv->dwBitsPerRGB = dwRedBits; - else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits) - pScreenPriv->dwBitsPerRGB = dwGreenBits; - else - pScreenPriv->dwBitsPerRGB = dwBlueBits; - - /* Set screen privates masks */ - pScreenPriv->dwRedMask = pdw[0]; - pScreenPriv->dwGreenMask = pdw[1]; - pScreenPriv->dwBlueMask = pdw[2]; - } - } - else - { - ErrorF ("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n"); - free (pbmih); - fReturn = FALSE; - } - - /* Free memory */ - free (pbmih); - - return fReturn; -} - - -#ifdef XWIN_MULTIWINDOW -/* - * Redraw all ---? - */ - -static wBOOL CALLBACK -winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam) -{ - if (hwnd == (HWND)lParam) - return TRUE; - InvalidateRect (hwnd, NULL, FALSE); - UpdateWindow (hwnd); - return TRUE; -} - -static wBOOL CALLBACK -winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam) -{ - BoxPtr pDamage = (BoxPtr)lParam; - RECT rcClient, rcDamage, rcRedraw; - POINT topLeft, bottomRight; - - if (IsIconic (hwnd)) - return TRUE; /* Don't care minimized windows */ - - /* Convert the damaged area from Screen coords to Client coords */ - topLeft.x = pDamage->x1; topLeft.y = pDamage->y1; - bottomRight.x = pDamage->x2; bottomRight.y = pDamage->y2; - topLeft.x += GetSystemMetrics (SM_XVIRTUALSCREEN); - bottomRight.x += GetSystemMetrics (SM_XVIRTUALSCREEN); - topLeft.y += GetSystemMetrics (SM_YVIRTUALSCREEN); - bottomRight.y += GetSystemMetrics (SM_YVIRTUALSCREEN); - ScreenToClient (hwnd, &topLeft); - ScreenToClient (hwnd, &bottomRight); - SetRect (&rcDamage, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); - - GetClientRect (hwnd, &rcClient); - - if (IntersectRect (&rcRedraw, &rcClient, &rcDamage)) - { - InvalidateRect (hwnd, &rcRedraw, FALSE); - UpdateWindow (hwnd); - } - return TRUE; -} -#endif - - -/* - * Allocate a DIB for the shadow framebuffer GDI server - */ - -static Bool -winAllocateFBShadowGDI (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - BITMAPINFOHEADER *pbmih = NULL; - DIBSECTION dibsection; - Bool fReturn = TRUE; - - /* Get device contexts for the screen and shadow bitmap */ - pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen); - pScreenPriv->hdcShadow = CreateCompatibleDC (pScreenPriv->hdcScreen); - - /* Allocate bitmap info header */ - pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER) - + 256 * sizeof (RGBQUAD)); - if (pbmih == NULL) - { - ErrorF ("winAllocateFBShadowGDI - malloc () failed\n"); - return FALSE; - } - - /* Query the screen format */ - fReturn = winQueryScreenDIBFormat (pScreen, pbmih); - - /* Describe shadow bitmap to be created */ - pbmih->biWidth = pScreenInfo->dwWidth; - pbmih->biHeight = -pScreenInfo->dwHeight; - - winDebug ("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d " - "depth: %d\n", - (int) pbmih->biWidth, (int) -pbmih->biHeight, pbmih->biBitCount); - - /* Create a DI shadow bitmap with a bit pointer */ - pScreenPriv->hbmpShadow = CreateDIBSection (pScreenPriv->hdcScreen, - (BITMAPINFO *) pbmih, - DIB_RGB_COLORS, - (VOID**) &pScreenInfo->pfb, - NULL, - 0); - if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL) - { - winW32Error ("winAllocateFBShadowGDI - CreateDIBSection failed:"); - return FALSE; - } - else - { - winDebug ("winAllocateFBShadowGDI - Shadow buffer allocated\n"); - } - - /* Get information about the bitmap that was allocated */ - GetObject (pScreenPriv->hbmpShadow, - sizeof (dibsection), - &dibsection); - - /* Print information about bitmap allocated */ - winDebug ("winAllocateFBShadowGDI - Dibsection width: %d height: %d " - "depth: %d size image: %d\n", - (int) dibsection.dsBmih.biWidth, (int) dibsection.dsBmih.biHeight, - dibsection.dsBmih.biBitCount, - (int) dibsection.dsBmih.biSizeImage); - - /* Select the shadow bitmap into the shadow DC */ - SelectObject (pScreenPriv->hdcShadow, - pScreenPriv->hbmpShadow); - - winDebug ("winAllocateFBShadowGDI - Attempting a shadow blit\n"); - - /* Do a test blit from the shadow to the screen, I think */ - fReturn = BitBlt (pScreenPriv->hdcScreen, - 0, 0, - pScreenInfo->dwWidth, pScreenInfo->dwHeight, - pScreenPriv->hdcShadow, - 0, 0, - SRCCOPY); - if (fReturn) - { - winDebug ("winAllocateFBShadowGDI - Shadow blit success\n"); - } - else - { - winW32Error ("winAllocateFBShadowGDI - Shadow blit failure\n"); - /* ago: ignore this error. The blit fails with wine, but does not - * cause any problems later. */ - - fReturn = TRUE; - } - - /* Look for height weirdness */ - if (dibsection.dsBmih.biHeight < 0) - { - dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight; - } - - /* Set screeninfo stride */ - pScreenInfo->dwStride = ((dibsection.dsBmih.biSizeImage - / dibsection.dsBmih.biHeight) - * 8) / pScreenInfo->dwBPP; - - winDebug ("winAllocateFBShadowGDI - Created shadow stride: %d\n", - (int) pScreenInfo->dwStride); - - /* See if the shadow bitmap will be larger than the DIB size limit */ - if (pScreenInfo->dwWidth * pScreenInfo->dwHeight * pScreenInfo->dwBPP - >= WIN_DIB_MAXIMUM_SIZE) - { - ErrorF ("winAllocateFBShadowGDI - Requested DIB (bitmap) " - "will be larger than %d MB. The surface may fail to be " - "allocated on Windows 95, 98, or Me, due to a %d MB limit in " - "DIB size. This limit does not apply to Windows NT/2000, and " - "this message may be ignored on those platforms.\n", - WIN_DIB_MAXIMUM_SIZE_MB, WIN_DIB_MAXIMUM_SIZE_MB); - } - - /* Determine our color masks */ - if (!winQueryRGBBitsAndMasks (pScreen)) - { - ErrorF ("winAllocateFBShadowGDI - winQueryRGBBitsAndMasks failed\n"); - return FALSE; - } - -#ifdef XWIN_MULTIWINDOW - /* Redraw all windows */ - if (pScreenInfo->fMultiWindow) - EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0); -#endif - - return fReturn; -} - - -/* - * Blit the damaged regions of the shadow fb to the screen - */ - -static void -winShadowUpdateGDI (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - RegionPtr damage = shadowDamage(pBuf); - DWORD dwBox = REGION_NUM_RECTS (damage); - BoxPtr pBox = REGION_RECTS (damage); - int x, y, w, h; - HRGN hrgnTemp = NULL, hrgnCombined = NULL; -#ifdef XWIN_UPDATESTATS - static DWORD s_dwNonUnitRegions = 0; - static DWORD s_dwTotalUpdates = 0; - static DWORD s_dwTotalBoxes = 0; -#endif - BoxPtr pBoxExtents = REGION_EXTENTS (pScreen, damage); - - /* - * Return immediately if the app is not active - * and we are fullscreen, or if we have a bad display depth - */ - if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen) - || pScreenPriv->fBadDepth) return; - -#ifdef XWIN_UPDATESTATS - ++s_dwTotalUpdates; - s_dwTotalBoxes += dwBox; - - if (dwBox != 1) - { - ++s_dwNonUnitRegions; - winDebug ("winShadowUpdatGDI - dwBox: %d\n", dwBox); - } - - if ((s_dwTotalUpdates % 100) == 0) - { - winDebug ("winShadowUpdateGDI - %d%% non-unity regions, avg boxes: %d " - "nu: %d tu: %d\n", - (s_dwNonUnitRegions * 100) / s_dwTotalUpdates, - s_dwTotalBoxes / s_dwTotalUpdates, - s_dwNonUnitRegions, s_dwTotalUpdates); - } -#endif /* XWIN_UPDATESTATS */ - - /* - * Handle small regions with multiple blits, - * handle large regions by creating a clipping region and - * doing a single blit constrained to that clipping region. - */ - if (!pScreenInfo->fMultiWindow && - (pScreenInfo->dwClipUpdatesNBoxes == 0 || - dwBox < pScreenInfo->dwClipUpdatesNBoxes)) - { - /* Loop through all boxes in the damaged region */ - while (dwBox--) - { - /* - * Calculate x offset, y offset, width, and height for - * current damage box - */ - x = pBox->x1; - y = pBox->y1; - w = pBox->x2 - pBox->x1; - h = pBox->y2 - pBox->y1; - - BitBlt (pScreenPriv->hdcScreen, - x, y, - w, h, - pScreenPriv->hdcShadow, - x, y, - SRCCOPY); - - /* Get a pointer to the next box */ - ++pBox; - } - } - else if (!pScreenInfo->fMultiWindow) - { - /* Compute a GDI region from the damaged region */ - hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2); - dwBox--; - pBox++; - while (dwBox--) - { - hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2); - CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR); - DeleteObject (hrgnTemp); - pBox++; - } - - /* Install the GDI region as a clipping region */ - SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined); - DeleteObject (hrgnCombined); - hrgnCombined = NULL; - - /* - * Blit the shadow buffer to the screen, - * constrained to the clipping region. - */ - BitBlt (pScreenPriv->hdcScreen, - pBoxExtents->x1, pBoxExtents->y1, - pBoxExtents->x2 - pBoxExtents->x1, - pBoxExtents->y2 - pBoxExtents->y1, - pScreenPriv->hdcShadow, - pBoxExtents->x1, pBoxExtents->y1, - SRCCOPY); - - /* Reset the clip region */ - SelectClipRgn (pScreenPriv->hdcScreen, NULL); - } - -#ifdef XWIN_MULTIWINDOW - /* Redraw all multiwindow windows */ - if (pScreenInfo->fMultiWindow) - EnumThreadWindows (g_dwCurrentThreadID, - winRedrawDamagedWindowShadowGDI, - (LPARAM)pBoxExtents); -#endif -} - - -/* See Porting Layer Definition - p. 33 */ -/* - * We wrap whatever CloseScreen procedure was specified by fb; - * a pointer to said procedure is stored in our privates. - */ - -static Bool -winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - Bool fReturn; - - winDebug ("winCloseScreenShadowGDI - Freeing screen resources\n"); - - /* Flag that the screen is closed */ - pScreenPriv->fClosed = TRUE; - pScreenPriv->fActive = FALSE; - - /* Call the wrapped CloseScreen procedure */ - WIN_UNWRAP(CloseScreen); - fReturn = (*pScreen->CloseScreen) (nIndex, pScreen); - - /* Delete the window property */ - RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP); - - /* Free the shadow DC; which allows the bitmap to be freed */ - DeleteDC (pScreenPriv->hdcShadow); - - /* Free the shadow bitmap */ - DeleteObject (pScreenPriv->hbmpShadow); - - /* Free the screen DC */ - ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen); - - /* Delete tray icon, if we have one */ - if (!pScreenInfo->fNoTrayIcon) - winDeleteNotifyIcon (pScreenPriv); - - /* Free the exit confirmation dialog box, if it exists */ - if (g_hDlgExit != NULL) - { - DestroyWindow (g_hDlgExit); - g_hDlgExit = NULL; - } - - /* Kill our window */ - if (pScreenPriv->hwndScreen) - { - DestroyWindow (pScreenPriv->hwndScreen); - pScreenPriv->hwndScreen = NULL; - } - -#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) - /* Destroy the thread startup mutex */ - pthread_mutex_destroy (&pScreenPriv->pmServerStarted); -#endif - - /* Invalidate our screeninfo's pointer to the screen */ - pScreenInfo->pScreen = NULL; - - /* Invalidate the ScreenInfo's fb pointer */ - pScreenInfo->pfb = NULL; - - /* Free the screen privates for this screen */ - free ((pointer) pScreenPriv); - - return fReturn; -} - - -/* - * Tell mi what sort of visuals we need. - * - * Generally we only need one visual, as our screen can only - * handle one format at a time, I believe. You may want - * to verify that last sentence. - */ - -static Bool -winInitVisualsShadowGDI (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Display debugging information */ - winDebug ("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d " - "bpp %d\n", - (unsigned int) pScreenPriv->dwRedMask, - (unsigned int) pScreenPriv->dwGreenMask, - (unsigned int) pScreenPriv->dwBlueMask, - (int) pScreenPriv->dwBitsPerRGB, - (int) pScreenInfo->dwDepth, - (int) pScreenInfo->dwBPP); - - /* Create a single visual according to the Windows screen depth */ - switch (pScreenInfo->dwDepth) - { - case 24: - case 16: - case 15: -#if defined(XFree86Server) - /* Setup the real visual */ - if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth, - TrueColorMask, - pScreenPriv->dwBitsPerRGB, - -1, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) - { - ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks " - "failed\n"); - return FALSE; - } - -#ifdef XWIN_EMULATEPSEUDO - if (!pScreenInfo->fEmulatePseudo) - break; - - /* Setup a pseudocolor visual */ - if (!miSetVisualTypesAndMasks (8, - PseudoColorMask, - 8, - -1, - 0, - 0, - 0)) - { - ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks " - "failed for PseudoColor\n"); - return FALSE; - } -#endif -#else /* XFree86Server */ - /* Setup the real visual */ - if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth, - TrueColorMask, - pScreenPriv->dwBitsPerRGB, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) - { - ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks " - "failed for TrueColor\n"); - return FALSE; - } - -#ifdef XWIN_EMULATEPSEUDO - if (!pScreenInfo->fEmulatePseudo) - break; - - /* Setup a pseudocolor visual */ - if (!fbSetVisualTypesAndMasks (8, - PseudoColorMask, - 8, - 0, - 0, - 0)) - { - ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks " - "failed for PseudoColor\n"); - return FALSE; - } -#endif -#endif /* XFree86Server */ - break; - - case 8: -#if defined(XFree86Server) - if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth, - PseudoColorMask, - pScreenPriv->dwBitsPerRGB, - PseudoColor, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) - { - ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks " - "failed\n"); - return FALSE; - } -#else /* XFree86Server */ - if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth, - PseudoColorMask, - pScreenPriv->dwBitsPerRGB, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) - { - ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks " - "failed\n"); - return FALSE; - } -#endif - break; - - default: - ErrorF ("winInitVisualsShadowGDI - Unknown screen depth\n"); - return FALSE; - } - - winDebug ("winInitVisualsShadowGDI - Returning\n"); - - return TRUE; -} - - -/* - * Adjust the proposed video mode - */ - -static Bool -winAdjustVideoModeShadowGDI (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - HDC hdc; - DWORD dwBPP; - - hdc = GetDC (NULL); - - /* We're in serious trouble if we can't get a DC */ - if (hdc == NULL) - { - ErrorF ("winAdjustVideoModeShadowGDI - GetDC () failed\n"); - return FALSE; - } - - /* Query GDI for current display depth */ - dwBPP = GetDeviceCaps (hdc, BITSPIXEL); - - /* GDI cannot change the screen depth */ - if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP) - { - /* No -depth parameter passed, let the user know the depth being used */ - winDebug ("winAdjustVideoModeShadowGDI - Using Windows display " - "depth of %d bits per pixel\n", (int) dwBPP); - - /* Use GDI's depth */ - pScreenInfo->dwBPP = dwBPP; - } - else if (dwBPP != pScreenInfo->dwBPP) - { - /* Warn user if GDI depth is different than -depth parameter */ - winDebug ("winAdjustVideoModeShadowGDI - Command line bpp: %d, "\ - "using bpp: %d\n", (int) pScreenInfo->dwBPP, (int) dwBPP); - - /* We'll use GDI's depth */ - pScreenInfo->dwBPP = dwBPP; - } - - /* Release our DC */ - ReleaseDC (NULL, hdc); - hdc = NULL; - - return TRUE; -} - - -/* - * Blt exposed regions to the screen - */ - -static Bool -winBltExposedRegionsShadowGDI (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - winPrivCmapPtr pCmapPriv = NULL; - HDC hdcUpdate; - PAINTSTRUCT ps; - - /* BeginPaint gives us an hdc that clips to the invalidated region */ - hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps); - - /* Realize the palette, if we have one */ - if (pScreenPriv->pcmapInstalled != NULL) - { - pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled); - - SelectPalette (hdcUpdate, pCmapPriv->hPalette, FALSE); - RealizePalette (hdcUpdate); - } - - /* Our BitBlt will be clipped to the invalidated region */ - BitBlt (hdcUpdate, - 0, 0, - pScreenInfo->dwWidth, pScreenInfo->dwHeight, - pScreenPriv->hdcShadow, - 0, 0, - SRCCOPY); - - /* EndPaint frees the DC */ - EndPaint (pScreenPriv->hwndScreen, &ps); - -#ifdef XWIN_MULTIWINDOW - /* Redraw all windows */ - if (pScreenInfo->fMultiWindow) - EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, - (LPARAM)pScreenPriv->hwndScreen); -#endif - - return TRUE; -} - - -/* - * Do any engine-specific appliation-activation processing - */ - -static Bool -winActivateAppShadowGDI (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* - * 2004/04/12 - Harold - We perform the restoring or minimizing - * manually for ShadowGDI in fullscreen modes so that this engine - * will perform just like ShadowDD and ShadowDDNL in fullscreen mode; - * if we do not do this then our fullscreen window will appear in the - * z-order when it is deactivated and it can be uncovered by resizing - * or minimizing another window that is on top of it, which is not how - * the DirectDraw engines work. Therefore we keep this code here to - * make sure that all engines work the same in fullscreen mode. - */ - - /* - * Are we active? - * Are we fullscreen? - */ - if (pScreenPriv->fActive - && pScreenInfo->fFullScreen) - { - /* - * Activating, attempt to bring our window - * to the top of the display - */ - ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE); - } - else if (!pScreenPriv->fActive - && pScreenInfo->fFullScreen) - { - /* - * Deactivating, stuff our window onto the - * task bar. - */ - ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE); - } - - return TRUE; -} - - -/* - * Reblit the shadow framebuffer to the screen. - */ - -static Bool -winRedrawScreenShadowGDI (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Redraw the whole window, to take account for the new colors */ - BitBlt (pScreenPriv->hdcScreen, - 0, 0, - pScreenInfo->dwWidth, pScreenInfo->dwHeight, - pScreenPriv->hdcShadow, - 0, 0, - SRCCOPY); - -#ifdef XWIN_MULTIWINDOW - /* Redraw all windows */ - if (pScreenInfo->fMultiWindow) - EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0); -#endif - - return TRUE; -} - - - -/* - * Realize the currently installed colormap - */ - -static Bool -winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winPrivCmapPtr pCmapPriv = NULL; - - winDebug ("winRealizeInstalledPaletteShadowGDI\n"); - - /* Don't do anything if there is not a colormap */ - if (pScreenPriv->pcmapInstalled == NULL) - { - winDebug ("winRealizeInstalledPaletteShadowGDI - No colormap " - "installed\n"); - return TRUE; - } - - pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled); - - /* Realize our palette for the screen */ - if (RealizePalette (pScreenPriv->hdcScreen) == GDI_ERROR) - { - ErrorF ("winRealizeInstalledPaletteShadowGDI - RealizePalette () " - "failed\n"); - return FALSE; - } - - /* Set the DIB color table */ - if (SetDIBColorTable (pScreenPriv->hdcShadow, - 0, - WIN_NUM_PALETTE_ENTRIES, - pCmapPriv->rgbColors) == 0) - { - ErrorF ("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () " - "failed\n"); - return FALSE; - } - - return TRUE; -} - - -/* - * Install the specified colormap - */ - -static Bool -winInstallColormapShadowGDI (ColormapPtr pColormap) -{ - ScreenPtr pScreen = pColormap->pScreen; - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - winCmapPriv(pColormap); - - /* - * Tell Windows to install the new colormap - */ - if (SelectPalette (pScreenPriv->hdcScreen, - pCmapPriv->hPalette, - FALSE) == NULL) - { - ErrorF ("winInstallColormapShadowGDI - SelectPalette () failed\n"); - return FALSE; - } - - /* Realize the palette */ - if (GDI_ERROR == RealizePalette (pScreenPriv->hdcScreen)) - { - ErrorF ("winInstallColormapShadowGDI - RealizePalette () failed\n"); - return FALSE; - } - - /* Set the DIB color table */ - if (SetDIBColorTable (pScreenPriv->hdcShadow, - 0, - WIN_NUM_PALETTE_ENTRIES, - pCmapPriv->rgbColors) == 0) - { - ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n"); - return FALSE; - } - - /* Redraw the whole window, to take account for the new colors */ - BitBlt (pScreenPriv->hdcScreen, - 0, 0, - pScreenInfo->dwWidth, pScreenInfo->dwHeight, - pScreenPriv->hdcShadow, - 0, 0, - SRCCOPY); - - /* Save a pointer to the newly installed colormap */ - pScreenPriv->pcmapInstalled = pColormap; - -#ifdef XWIN_MULTIWINDOW - /* Redraw all windows */ - if (pScreenInfo->fMultiWindow) - EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0); -#endif - - return TRUE; -} - - -/* - * Store the specified colors in the specified colormap - */ - -static Bool -winStoreColorsShadowGDI (ColormapPtr pColormap, - int ndef, - xColorItem *pdefs) -{ - ScreenPtr pScreen = pColormap->pScreen; - winScreenPriv(pScreen); - winCmapPriv(pColormap); - ColormapPtr curpmap = pScreenPriv->pcmapInstalled; - - /* Put the X colormap entries into the Windows logical palette */ - if (SetPaletteEntries (pCmapPriv->hPalette, - pdefs[0].pixel, - ndef, - pCmapPriv->peColors + pdefs[0].pixel) == 0) - { - ErrorF ("winStoreColorsShadowGDI - SetPaletteEntries () failed\n"); - return FALSE; - } - - /* Don't install the Windows palette if the colormap is not installed */ - if (pColormap != curpmap) - { - return TRUE; - } - - /* Try to install the newly modified colormap */ - if (!winInstallColormapShadowGDI (pColormap)) - { - ErrorF ("winInstallColormapShadowGDI - winInstallColormapShadowGDI " - "failed\n"); - return FALSE; - } - -#if 0 - /* Tell Windows that the palette has changed */ - RealizePalette (pScreenPriv->hdcScreen); - - /* Set the DIB color table */ - if (SetDIBColorTable (pScreenPriv->hdcShadow, - pdefs[0].pixel, - ndef, - pCmapPriv->rgbColors + pdefs[0].pixel) == 0) - { - ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n"); - return FALSE; - } - - /* Save a pointer to the newly installed colormap */ - pScreenPriv->pcmapInstalled = pColormap; -#endif - - return TRUE; -} - - -/* - * Colormap initialization procedure - */ - -static Bool -winCreateColormapShadowGDI (ColormapPtr pColormap) -{ - LPLOGPALETTE lpPaletteNew = NULL; - DWORD dwEntriesMax; - VisualPtr pVisual; - HPALETTE hpalNew = NULL; - winCmapPriv(pColormap); - - /* Get a pointer to the visual that the colormap belongs to */ - pVisual = pColormap->pVisual; - - /* Get the maximum number of palette entries for this visual */ - dwEntriesMax = pVisual->ColormapEntries; - - /* Allocate a Windows logical color palette with max entries */ - lpPaletteNew = malloc (sizeof (LOGPALETTE) - + (dwEntriesMax - 1) * sizeof (PALETTEENTRY)); - if (lpPaletteNew == NULL) - { - ErrorF ("winCreateColormapShadowGDI - Couldn't allocate palette " - "with %d entries\n", - (int) dwEntriesMax); - return FALSE; - } - - /* Zero out the colormap */ - ZeroMemory (lpPaletteNew, sizeof (LOGPALETTE) - + (dwEntriesMax - 1) * sizeof (PALETTEENTRY)); - - /* Set the logical palette structure */ - lpPaletteNew->palVersion = 0x0300; - lpPaletteNew->palNumEntries = dwEntriesMax; - - /* Tell Windows to create the palette */ - hpalNew = CreatePalette (lpPaletteNew); - if (hpalNew == NULL) - { - ErrorF ("winCreateColormapShadowGDI - CreatePalette () failed\n"); - free (lpPaletteNew); - return FALSE; - } - - /* Save the Windows logical palette handle in the X colormaps' privates */ - pCmapPriv->hPalette = hpalNew; - - /* Free the palette initialization memory */ - free (lpPaletteNew); - - return TRUE; -} - - -/* - * Colormap destruction procedure - */ - -static Bool -winDestroyColormapShadowGDI (ColormapPtr pColormap) -{ - winScreenPriv(pColormap->pScreen); - winCmapPriv(pColormap); - - /* - * Is colormap to be destroyed the default? - * - * Non-default colormaps should have had winUninstallColormap - * called on them before we get here. The default colormap - * will not have had winUninstallColormap called on it. Thus, - * we need to handle the default colormap in a special way. - */ - if (pColormap->flags & IsDefault) - { - winDebug ("winDestroyColormapShadowGDI - Destroying default " - "colormap\n"); - - /* - * FIXME: Walk the list of all screens, popping the default - * palette out of each screen device context. - */ - - /* Pop the palette out of the device context */ - SelectPalette (pScreenPriv->hdcScreen, - GetStockObject (DEFAULT_PALETTE), - FALSE); - - /* Clear our private installed colormap pointer */ - pScreenPriv->pcmapInstalled = NULL; - } - - /* Try to delete the logical palette */ - if (DeleteObject (pCmapPriv->hPalette) == 0) - { - ErrorF ("winDestroyColormap - DeleteObject () failed\n"); - return FALSE; - } - - /* Invalidate the colormap privates */ - pCmapPriv->hPalette = NULL; - - return TRUE; -} - - -/* - * Set engine specific funtions - */ - -Bool -winSetEngineFunctionsShadowGDI (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Set our pointers */ - pScreenPriv->pwinAllocateFB = winAllocateFBShadowGDI; - pScreenPriv->pwinShadowUpdate = winShadowUpdateGDI; - pScreenPriv->pwinCloseScreen = winCloseScreenShadowGDI; - pScreenPriv->pwinInitVisuals = winInitVisualsShadowGDI; - pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowGDI; - if (pScreenInfo->fFullScreen) - pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen; - else - pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed; - pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB; - pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowGDI; - pScreenPriv->pwinActivateApp = winActivateAppShadowGDI; - pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowGDI; - pScreenPriv->pwinRealizeInstalledPalette = - winRealizeInstalledPaletteShadowGDI; - pScreenPriv->pwinInstallColormap = winInstallColormapShadowGDI; - pScreenPriv->pwinStoreColors = winStoreColorsShadowGDI; - pScreenPriv->pwinCreateColormap = winCreateColormapShadowGDI; - pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowGDI; - pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA; - pScreenPriv->pwinCreatePrimarySurface - = (winCreatePrimarySurfaceProcPtr) (void (*)(void))NoopDDA; - pScreenPriv->pwinReleasePrimarySurface - = (winReleasePrimarySurfaceProcPtr) (void (*)(void))NoopDDA; -#ifdef XWIN_MULTIWINDOW - pScreenPriv->pwinFinishCreateWindowsWindow = - (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA; -#endif - - return TRUE; -} +/*
+ *Copyright (C) 2001-2004 Harold L Hunt II 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 HAROLD L HUNT II 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 of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * External symbols
+ */
+
+#ifdef XWIN_MULTIWINDOW
+extern DWORD g_dwCurrentThreadID;
+#endif
+extern HWND g_hDlgExit;
+
+
+/*
+ * Local function prototypes
+ */
+
+#ifdef XWIN_MULTIWINDOW
+static wBOOL CALLBACK
+winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam);
+
+static wBOOL CALLBACK
+winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam);
+#endif
+
+static Bool
+winAllocateFBShadowGDI (ScreenPtr pScreen);
+
+static void
+winShadowUpdateGDI (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+static Bool
+winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModeShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winBltExposedRegionsShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winActivateAppShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winRedrawScreenShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winInstallColormapShadowGDI (ColormapPtr pColormap);
+
+static Bool
+winStoreColorsShadowGDI (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs);
+
+static Bool
+winCreateColormapShadowGDI (ColormapPtr pColormap);
+
+static Bool
+winDestroyColormapShadowGDI (ColormapPtr pColormap);
+
+
+/*
+ * Internal function to get the DIB format that is compatible with the screen
+ */
+
+static
+Bool
+winQueryScreenDIBFormat (ScreenPtr pScreen, BITMAPINFOHEADER *pbmih)
+{
+ winScreenPriv(pScreen);
+ HBITMAP hbmp;
+#ifdef WINDBG
+ LPDWORD pdw = NULL;
+#endif
+
+ /* Create a memory bitmap compatible with the screen */
+ hbmp = CreateCompatibleBitmap (pScreenPriv->hdcScreen, 1, 1);
+ if (hbmp == NULL)
+ {
+ ErrorF ("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n");
+ return FALSE;
+ }
+
+ /* Initialize our bitmap info header */
+ ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
+ pbmih->biSize = sizeof (BITMAPINFOHEADER);
+
+ /* Get the biBitCount */
+ if (!GetDIBits (pScreenPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*) pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winQueryScreenDIBFormat - First call to GetDIBits failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+#ifdef WINDBG
+ /* Get a pointer to bitfields */
+ pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+
+ winDebug ("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n",
+ pdw[0], pdw[1], pdw[2]);
+#endif
+
+ /* Get optimal color table, or the optimal bitfields */
+ if (!GetDIBits (pScreenPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*)pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winQueryScreenDIBFormat - Second call to GetDIBits "
+ "failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+ /* Free memory */
+ DeleteObject (hbmp);
+
+ return TRUE;
+}
+
+
+/*
+ * Internal function to determine the GDI bits per rgb and bit masks
+ */
+
+static
+Bool
+winQueryRGBBitsAndMasks (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ BITMAPINFOHEADER *pbmih = NULL;
+ Bool fReturn = TRUE;
+ LPDWORD pdw = NULL;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Color masks for 8 bpp are standardized */
+ if (GetDeviceCaps (pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE)
+ {
+ /*
+ * RGB BPP for 8 bit palletes is always 8
+ * and the color masks are always 0.
+ */
+ pScreenPriv->dwBitsPerRGB = 8;
+ pScreenPriv->dwRedMask = 0x0L;
+ pScreenPriv->dwGreenMask = 0x0L;
+ pScreenPriv->dwBlueMask = 0x0L;
+ return TRUE;
+ }
+
+ /* Color masks for 24 bpp are standardized */
+ if (GetDeviceCaps (pScreenPriv->hdcScreen, PLANES)
+ * GetDeviceCaps (pScreenPriv->hdcScreen, BITSPIXEL) == 24)
+ {
+ winDebug ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
+ "returned 24 for the screen. Using default 24bpp masks.\n");
+
+ /* 8 bits per primary color */
+ pScreenPriv->dwBitsPerRGB = 8;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED;
+ pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN;
+ pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE;
+
+ return TRUE;
+ }
+
+ /* Allocate a bitmap header and color table */
+ pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ + 256 * sizeof (RGBQUAD));
+ if (pbmih == NULL)
+ {
+ ErrorF ("winQueryRGBBitsAndMasks - malloc failed\n");
+ return FALSE;
+ }
+
+ /* Get screen description */
+ if (winQueryScreenDIBFormat (pScreen, pbmih))
+ {
+ /* Get a pointer to bitfields */
+ pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+
+#ifdef WINDBG
+ winDebug ("%s - Masks: %08x %08x %08x\n", __FUNCTION__,
+ pdw[0], pdw[1], pdw[2]);
+ winDebug ("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__,
+ pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount, pbmih->biPlanes);
+ winDebug ("%s - Compression: %d %s\n", __FUNCTION__,
+ pbmih->biCompression,
+ (pbmih->biCompression == BI_RGB?"(BI_RGB)":
+ (pbmih->biCompression == BI_RLE8?"(BI_RLE8)":
+ (pbmih->biCompression == BI_RLE4?"(BI_RLE4)":
+ (pbmih->biCompression == BI_BITFIELDS?"(BI_BITFIELDS)":""
+ )))));
+#endif
+
+ /* Handle BI_RGB case, which is returned by Wine */
+ if (pbmih->biCompression == BI_RGB)
+ {
+ dwRedBits = 5;
+ dwGreenBits = 5;
+ dwBlueBits = 5;
+
+ pScreenPriv->dwBitsPerRGB = 5;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = 0x7c00;
+ pScreenPriv->dwGreenMask = 0x03e0;
+ pScreenPriv->dwBlueMask = 0x001f;
+ }
+ else
+ {
+ /* Count the number of bits in each mask */
+ dwRedBits = winCountBits (pdw[0]);
+ dwGreenBits = winCountBits (pdw[1]);
+ dwBlueBits = winCountBits (pdw[2]);
+
+ /* Find maximum bits per red, green, blue */
+ if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = pdw[0];
+ pScreenPriv->dwGreenMask = pdw[1];
+ pScreenPriv->dwBlueMask = pdw[2];
+ }
+ }
+ else
+ {
+ ErrorF ("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n");
+ free (pbmih);
+ fReturn = FALSE;
+ }
+
+ /* Free memory */
+ free (pbmih);
+
+ return fReturn;
+}
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * Redraw all ---?
+ */
+
+static wBOOL CALLBACK
+winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam)
+{
+ if (hwnd == (HWND)lParam)
+ return TRUE;
+ InvalidateRect (hwnd, NULL, FALSE);
+ UpdateWindow (hwnd);
+ return TRUE;
+}
+
+static wBOOL CALLBACK
+winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam)
+{
+ BoxPtr pDamage = (BoxPtr)lParam;
+ RECT rcClient, rcDamage, rcRedraw;
+ POINT topLeft, bottomRight;
+
+ if (IsIconic (hwnd))
+ return TRUE; /* Don't care minimized windows */
+
+ /* Convert the damaged area from Screen coords to Client coords */
+ topLeft.x = pDamage->x1; topLeft.y = pDamage->y1;
+ bottomRight.x = pDamage->x2; bottomRight.y = pDamage->y2;
+ topLeft.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
+ bottomRight.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
+ topLeft.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
+ bottomRight.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
+ ScreenToClient (hwnd, &topLeft);
+ ScreenToClient (hwnd, &bottomRight);
+ SetRect (&rcDamage, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
+
+ GetClientRect (hwnd, &rcClient);
+
+ if (IntersectRect (&rcRedraw, &rcClient, &rcDamage))
+ {
+ InvalidateRect (hwnd, &rcRedraw, FALSE);
+ UpdateWindow (hwnd);
+ }
+ return TRUE;
+}
+#endif
+
+
+/*
+ * Allocate a DIB for the shadow framebuffer GDI server
+ */
+
+static Bool
+winAllocateFBShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ BITMAPINFOHEADER *pbmih = NULL;
+ DIBSECTION dibsection;
+ Bool fReturn = TRUE;
+
+ /* Get device contexts for the screen and shadow bitmap */
+ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+ pScreenPriv->hdcShadow = CreateCompatibleDC (pScreenPriv->hdcScreen);
+
+ /* Allocate bitmap info header */
+ pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ + 256 * sizeof (RGBQUAD));
+ if (pbmih == NULL)
+ {
+ ErrorF ("winAllocateFBShadowGDI - malloc () failed\n");
+ return FALSE;
+ }
+
+ /* Query the screen format */
+ fReturn = winQueryScreenDIBFormat (pScreen, pbmih);
+
+ /* Describe shadow bitmap to be created */
+ pbmih->biWidth = pScreenInfo->dwWidth;
+ pbmih->biHeight = -pScreenInfo->dwHeight;
+
+ winDebug ("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d "
+ "depth: %d\n",
+ (int) pbmih->biWidth, (int) -pbmih->biHeight, pbmih->biBitCount);
+
+ /* Create a DI shadow bitmap with a bit pointer */
+ pScreenPriv->hbmpShadow = CreateDIBSection (pScreenPriv->hdcScreen,
+ (BITMAPINFO *) pbmih,
+ DIB_RGB_COLORS,
+ (VOID**) &pScreenInfo->pfb,
+ NULL,
+ 0);
+ if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL)
+ {
+ winW32Error ("winAllocateFBShadowGDI - CreateDIBSection failed:");
+ return FALSE;
+ }
+ else
+ {
+ winDebug ("winAllocateFBShadowGDI - Shadow buffer allocated\n");
+ }
+
+ /* Get information about the bitmap that was allocated */
+ GetObject (pScreenPriv->hbmpShadow,
+ sizeof (dibsection),
+ &dibsection);
+
+ /* Print information about bitmap allocated */
+ winDebug ("winAllocateFBShadowGDI - Dibsection width: %d height: %d "
+ "depth: %d size image: %d\n",
+ (int) dibsection.dsBmih.biWidth, (int) dibsection.dsBmih.biHeight,
+ dibsection.dsBmih.biBitCount,
+ (int) dibsection.dsBmih.biSizeImage);
+
+ /* Select the shadow bitmap into the shadow DC */
+ SelectObject (pScreenPriv->hdcShadow,
+ pScreenPriv->hbmpShadow);
+
+ winDebug ("winAllocateFBShadowGDI - Attempting a shadow blit\n");
+
+ /* Do a test blit from the shadow to the screen, I think */
+ fReturn = BitBlt (pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+ if (fReturn)
+ {
+ winDebug ("winAllocateFBShadowGDI - Shadow blit success\n");
+ }
+ else
+ {
+ winW32Error ("winAllocateFBShadowGDI - Shadow blit failure\n");
+ /* ago: ignore this error. The blit fails with wine, but does not
+ * cause any problems later. */
+
+ fReturn = TRUE;
+ }
+
+ /* Look for height weirdness */
+ if (dibsection.dsBmih.biHeight < 0)
+ {
+ dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
+ }
+
+ /* Set screeninfo stride */
+ pScreenInfo->dwStride = ((dibsection.dsBmih.biSizeImage
+ / dibsection.dsBmih.biHeight)
+ * 8) / pScreenInfo->dwBPP;
+
+ winDebug ("winAllocateFBShadowGDI - Created shadow stride: %d\n",
+ (int) pScreenInfo->dwStride);
+
+ /* See if the shadow bitmap will be larger than the DIB size limit */
+ if (pScreenInfo->dwWidth * pScreenInfo->dwHeight * pScreenInfo->dwBPP
+ >= WIN_DIB_MAXIMUM_SIZE)
+ {
+ ErrorF ("winAllocateFBShadowGDI - Requested DIB (bitmap) "
+ "will be larger than %d MB. The surface may fail to be "
+ "allocated on Windows 95, 98, or Me, due to a %d MB limit in "
+ "DIB size. This limit does not apply to Windows NT/2000, and "
+ "this message may be ignored on those platforms.\n",
+ WIN_DIB_MAXIMUM_SIZE_MB, WIN_DIB_MAXIMUM_SIZE_MB);
+ }
+
+ /* Determine our color masks */
+ if (!winQueryRGBBitsAndMasks (pScreen))
+ {
+ ErrorF ("winAllocateFBShadowGDI - winQueryRGBBitsAndMasks failed\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+#endif
+
+ return fReturn;
+}
+
+
+/*
+ * Blit the damaged regions of the shadow fb to the screen
+ */
+
+static void
+winShadowUpdateGDI (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RegionPtr damage = shadowDamage(pBuf);
+ DWORD dwBox = RegionNumRects (damage);
+ BoxPtr pBox = RegionRects (damage);
+ int x, y, w, h;
+ HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+#ifdef XWIN_UPDATESTATS
+ static DWORD s_dwNonUnitRegions = 0;
+ static DWORD s_dwTotalUpdates = 0;
+ static DWORD s_dwTotalBoxes = 0;
+#endif
+ BoxPtr pBoxExtents = RegionExtents(damage);
+
+ /*
+ * Return immediately if the app is not active
+ * and we are fullscreen, or if we have a bad display depth
+ */
+ if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
+ || pScreenPriv->fBadDepth) return;
+
+#ifdef XWIN_UPDATESTATS
+ ++s_dwTotalUpdates;
+ s_dwTotalBoxes += dwBox;
+
+ if (dwBox != 1)
+ {
+ ++s_dwNonUnitRegions;
+ winDebug ("winShadowUpdatGDI - dwBox: %d\n", dwBox);
+ }
+
+ if ((s_dwTotalUpdates % 100) == 0)
+ {
+ winDebug ("winShadowUpdateGDI - %d%% non-unity regions, avg boxes: %d "
+ "nu: %d tu: %d\n",
+ (s_dwNonUnitRegions * 100) / s_dwTotalUpdates,
+ s_dwTotalBoxes / s_dwTotalUpdates,
+ s_dwNonUnitRegions, s_dwTotalUpdates);
+ }
+#endif /* XWIN_UPDATESTATS */
+
+ /*
+ * Handle small regions with multiple blits,
+ * handle large regions by creating a clipping region and
+ * doing a single blit constrained to that clipping region.
+ */
+ if (!pScreenInfo->fMultiWindow &&
+ (pScreenInfo->dwClipUpdatesNBoxes == 0 ||
+ dwBox < pScreenInfo->dwClipUpdatesNBoxes))
+ {
+ /* Loop through all boxes in the damaged region */
+ while (dwBox--)
+ {
+ /*
+ * Calculate x offset, y offset, width, and height for
+ * current damage box
+ */
+ x = pBox->x1;
+ y = pBox->y1;
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+
+ BitBlt (pScreenPriv->hdcScreen,
+ x, y,
+ w, h,
+ pScreenPriv->hdcShadow,
+ x, y,
+ SRCCOPY);
+
+ /* Get a pointer to the next box */
+ ++pBox;
+ }
+ }
+ else if (!pScreenInfo->fMultiWindow)
+ {
+ /* Compute a GDI region from the damaged region */
+ hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ dwBox--;
+ pBox++;
+ while (dwBox--)
+ {
+ hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
+ DeleteObject (hrgnTemp);
+ pBox++;
+ }
+
+ /* Install the GDI region as a clipping region */
+ SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
+ DeleteObject (hrgnCombined);
+ hrgnCombined = NULL;
+
+ /*
+ * Blit the shadow buffer to the screen,
+ * constrained to the clipping region.
+ */
+ BitBlt (pScreenPriv->hdcScreen,
+ pBoxExtents->x1, pBoxExtents->y1,
+ pBoxExtents->x2 - pBoxExtents->x1,
+ pBoxExtents->y2 - pBoxExtents->y1,
+ pScreenPriv->hdcShadow,
+ pBoxExtents->x1, pBoxExtents->y1,
+ SRCCOPY);
+
+ /* Reset the clip region */
+ SelectClipRgn (pScreenPriv->hdcScreen, NULL);
+ }
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all multiwindow windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows (g_dwCurrentThreadID,
+ winRedrawDamagedWindowShadowGDI,
+ (LPARAM)pBoxExtents);
+#endif
+}
+
+
+/* See Porting Layer Definition - p. 33 */
+/*
+ * We wrap whatever CloseScreen procedure was specified by fb;
+ * a pointer to said procedure is stored in our privates.
+ */
+
+static Bool
+winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+ winDebug ("winCloseScreenShadowGDI - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ /* Free the shadow DC; which allows the bitmap to be freed */
+ DeleteDC (pScreenPriv->hdcShadow);
+
+ /* Free the shadow bitmap */
+ DeleteObject (pScreenPriv->hbmpShadow);
+
+ /* Free the screen DC */
+ ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon (pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen)
+ {
+ DestroyWindow (pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
+ }
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Destroy the thread startup mutex */
+ pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
+#endif
+
+ /* Invalidate our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
+
+ /* Free the screen privates for this screen */
+ free ((pointer) pScreenPriv);
+
+ return fReturn;
+}
+
+
+/*
+ * Tell mi what sort of visuals we need.
+ *
+ * Generally we only need one visual, as our screen can only
+ * handle one format at a time, I believe. You may want
+ * to verify that last sentence.
+ */
+
+static Bool
+winInitVisualsShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Display debugging information */
+ winDebug ("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d "
+ "bpp %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB,
+ (int) pScreenInfo->dwDepth,
+ (int) pScreenInfo->dwBPP);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ case 16:
+ case 15:
+#if defined(XFree86Server)
+ /* Setup the real visual */
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ -1,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!miSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ -1,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+#else /* XFree86Server */
+ /* Setup the real visual */
+ if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!fbSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+#endif /* XFree86Server */
+ break;
+
+ case 8:
+#if defined(XFree86Server)
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ PseudoColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ PseudoColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+#else /* XFree86Server */
+ if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ PseudoColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+#endif
+ break;
+
+ default:
+ ErrorF ("winInitVisualsShadowGDI - Unknown screen depth\n");
+ return FALSE;
+ }
+
+ winDebug ("winInitVisualsShadowGDI - Returning\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Adjust the proposed video mode
+ */
+
+static Bool
+winAdjustVideoModeShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc;
+ DWORD dwBPP;
+
+ hdc = GetDC (NULL);
+
+ /* We're in serious trouble if we can't get a DC */
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModeShadowGDI - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* GDI cannot change the screen depth */
+ if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
+ {
+ /* No -depth parameter passed, let the user know the depth being used */
+ winDebug ("winAdjustVideoModeShadowGDI - Using Windows display "
+ "depth of %d bits per pixel\n", (int) dwBPP);
+
+ /* Use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+ else if (dwBPP != pScreenInfo->dwBPP)
+ {
+ /* Warn user if GDI depth is different than -depth parameter */
+ winDebug ("winAdjustVideoModeShadowGDI - Command line bpp: %d, "\
+ "using bpp: %d\n", (int) pScreenInfo->dwBPP, (int) dwBPP);
+
+ /* We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Blt exposed regions to the screen
+ */
+
+static Bool
+winBltExposedRegionsShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winPrivCmapPtr pCmapPriv = NULL;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
+
+ /* Realize the palette, if we have one */
+ if (pScreenPriv->pcmapInstalled != NULL)
+ {
+ pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
+
+ SelectPalette (hdcUpdate, pCmapPriv->hPalette, FALSE);
+ RealizePalette (hdcUpdate);
+ }
+
+ /* Our BitBlt will be clipped to the invalidated region */
+ BitBlt (hdcUpdate,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+
+ /* EndPaint frees the DC */
+ EndPaint (pScreenPriv->hwndScreen, &ps);
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI,
+ (LPARAM)pScreenPriv->hwndScreen);
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Do any engine-specific appliation-activation processing
+ */
+
+static Bool
+winActivateAppShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /*
+ * 2004/04/12 - Harold - We perform the restoring or minimizing
+ * manually for ShadowGDI in fullscreen modes so that this engine
+ * will perform just like ShadowDD and ShadowDDNL in fullscreen mode;
+ * if we do not do this then our fullscreen window will appear in the
+ * z-order when it is deactivated and it can be uncovered by resizing
+ * or minimizing another window that is on top of it, which is not how
+ * the DirectDraw engines work. Therefore we keep this code here to
+ * make sure that all engines work the same in fullscreen mode.
+ */
+
+ /*
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv->fActive
+ && pScreenInfo->fFullScreen)
+ {
+ /*
+ * Activating, attempt to bring our window
+ * to the top of the display
+ */
+ ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
+ }
+ else if (!pScreenPriv->fActive
+ && pScreenInfo->fFullScreen)
+ {
+ /*
+ * Deactivating, stuff our window onto the
+ * task bar.
+ */
+ ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Reblit the shadow framebuffer to the screen.
+ */
+
+static Bool
+winRedrawScreenShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Redraw the whole window, to take account for the new colors */
+ BitBlt (pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+#endif
+
+ return TRUE;
+}
+
+
+
+/*
+ * Realize the currently installed colormap
+ */
+
+static Bool
+winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winPrivCmapPtr pCmapPriv = NULL;
+
+ winDebug ("winRealizeInstalledPaletteShadowGDI\n");
+
+ /* Don't do anything if there is not a colormap */
+ if (pScreenPriv->pcmapInstalled == NULL)
+ {
+ winDebug ("winRealizeInstalledPaletteShadowGDI - No colormap "
+ "installed\n");
+ return TRUE;
+ }
+
+ pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
+
+ /* Realize our palette for the screen */
+ if (RealizePalette (pScreenPriv->hdcScreen) == GDI_ERROR)
+ {
+ ErrorF ("winRealizeInstalledPaletteShadowGDI - RealizePalette () "
+ "failed\n");
+ return FALSE;
+ }
+
+ /* Set the DIB color table */
+ if (SetDIBColorTable (pScreenPriv->hdcShadow,
+ 0,
+ WIN_NUM_PALETTE_ENTRIES,
+ pCmapPriv->rgbColors) == 0)
+ {
+ ErrorF ("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () "
+ "failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Install the specified colormap
+ */
+
+static Bool
+winInstallColormapShadowGDI (ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winCmapPriv(pColormap);
+
+ /*
+ * Tell Windows to install the new colormap
+ */
+ if (SelectPalette (pScreenPriv->hdcScreen,
+ pCmapPriv->hPalette,
+ FALSE) == NULL)
+ {
+ ErrorF ("winInstallColormapShadowGDI - SelectPalette () failed\n");
+ return FALSE;
+ }
+
+ /* Realize the palette */
+ if (GDI_ERROR == RealizePalette (pScreenPriv->hdcScreen))
+ {
+ ErrorF ("winInstallColormapShadowGDI - RealizePalette () failed\n");
+ return FALSE;
+ }
+
+ /* Set the DIB color table */
+ if (SetDIBColorTable (pScreenPriv->hdcShadow,
+ 0,
+ WIN_NUM_PALETTE_ENTRIES,
+ pCmapPriv->rgbColors) == 0)
+ {
+ ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
+ return FALSE;
+ }
+
+ /* Redraw the whole window, to take account for the new colors */
+ BitBlt (pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Store the specified colors in the specified colormap
+ */
+
+static Bool
+winStoreColorsShadowGDI (ColormapPtr pColormap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+
+ /* Put the X colormap entries into the Windows logical palette */
+ if (SetPaletteEntries (pCmapPriv->hPalette,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->peColors + pdefs[0].pixel) == 0)
+ {
+ ErrorF ("winStoreColorsShadowGDI - SetPaletteEntries () failed\n");
+ return FALSE;
+ }
+
+ /* Don't install the Windows palette if the colormap is not installed */
+ if (pColormap != curpmap)
+ {
+ return TRUE;
+ }
+
+ /* Try to install the newly modified colormap */
+ if (!winInstallColormapShadowGDI (pColormap))
+ {
+ ErrorF ("winInstallColormapShadowGDI - winInstallColormapShadowGDI "
+ "failed\n");
+ return FALSE;
+ }
+
+#if 0
+ /* Tell Windows that the palette has changed */
+ RealizePalette (pScreenPriv->hdcScreen);
+
+ /* Set the DIB color table */
+ if (SetDIBColorTable (pScreenPriv->hdcShadow,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->rgbColors + pdefs[0].pixel) == 0)
+ {
+ ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap initialization procedure
+ */
+
+static Bool
+winCreateColormapShadowGDI (ColormapPtr pColormap)
+{
+ LPLOGPALETTE lpPaletteNew = NULL;
+ DWORD dwEntriesMax;
+ VisualPtr pVisual;
+ HPALETTE hpalNew = NULL;
+ winCmapPriv(pColormap);
+
+ /* Get a pointer to the visual that the colormap belongs to */
+ pVisual = pColormap->pVisual;
+
+ /* Get the maximum number of palette entries for this visual */
+ dwEntriesMax = pVisual->ColormapEntries;
+
+ /* Allocate a Windows logical color palette with max entries */
+ lpPaletteNew = malloc (sizeof (LOGPALETTE)
+ + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
+ if (lpPaletteNew == NULL)
+ {
+ ErrorF ("winCreateColormapShadowGDI - Couldn't allocate palette "
+ "with %d entries\n",
+ (int) dwEntriesMax);
+ return FALSE;
+ }
+
+ /* Zero out the colormap */
+ ZeroMemory (lpPaletteNew, sizeof (LOGPALETTE)
+ + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
+
+ /* Set the logical palette structure */
+ lpPaletteNew->palVersion = 0x0300;
+ lpPaletteNew->palNumEntries = dwEntriesMax;
+
+ /* Tell Windows to create the palette */
+ hpalNew = CreatePalette (lpPaletteNew);
+ if (hpalNew == NULL)
+ {
+ ErrorF ("winCreateColormapShadowGDI - CreatePalette () failed\n");
+ free (lpPaletteNew);
+ return FALSE;
+ }
+
+ /* Save the Windows logical palette handle in the X colormaps' privates */
+ pCmapPriv->hPalette = hpalNew;
+
+ /* Free the palette initialization memory */
+ free (lpPaletteNew);
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap destruction procedure
+ */
+
+static Bool
+winDestroyColormapShadowGDI (ColormapPtr pColormap)
+{
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+
+ /*
+ * Is colormap to be destroyed the default?
+ *
+ * Non-default colormaps should have had winUninstallColormap
+ * called on them before we get here. The default colormap
+ * will not have had winUninstallColormap called on it. Thus,
+ * we need to handle the default colormap in a special way.
+ */
+ if (pColormap->flags & IsDefault)
+ {
+ winDebug ("winDestroyColormapShadowGDI - Destroying default "
+ "colormap\n");
+
+ /*
+ * FIXME: Walk the list of all screens, popping the default
+ * palette out of each screen device context.
+ */
+
+ /* Pop the palette out of the device context */
+ SelectPalette (pScreenPriv->hdcScreen,
+ GetStockObject (DEFAULT_PALETTE),
+ FALSE);
+
+ /* Clear our private installed colormap pointer */
+ pScreenPriv->pcmapInstalled = NULL;
+ }
+
+ /* Try to delete the logical palette */
+ if (DeleteObject (pCmapPriv->hPalette) == 0)
+ {
+ ErrorF ("winDestroyColormap - DeleteObject () failed\n");
+ return FALSE;
+ }
+
+ /* Invalidate the colormap privates */
+ pCmapPriv->hPalette = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Set engine specific funtions
+ */
+
+Bool
+winSetEngineFunctionsShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBShadowGDI;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateGDI;
+ pScreenPriv->pwinCloseScreen = winCloseScreenShadowGDI;
+ pScreenPriv->pwinInitVisuals = winInitVisualsShadowGDI;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowGDI;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowGDI;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowGDI;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowGDI;
+ pScreenPriv->pwinRealizeInstalledPalette =
+ winRealizeInstalledPaletteShadowGDI;
+ pScreenPriv->pwinInstallColormap = winInstallColormapShadowGDI;
+ pScreenPriv->pwinStoreColors = winStoreColorsShadowGDI;
+ pScreenPriv->pwinCreateColormap = winCreateColormapShadowGDI;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowGDI;
+ pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinCreatePrimarySurface
+ = (winCreatePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinReleasePrimarySurface
+ = (winReleasePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
+#ifdef XWIN_MULTIWINDOW
+ pScreenPriv->pwinFinishCreateWindowsWindow =
+ (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
+#endif
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winvideo.c b/xorg-server/hw/xwin/winvideo.c index 42f46f405..998a3face 100644 --- a/xorg-server/hw/xwin/winvideo.c +++ b/xorg-server/hw/xwin/winvideo.c @@ -185,7 +185,7 @@ winSetupImageVideo (ScreenPtr pScreen) #if 0
/* gotta uninit this someplace */
- REGION_NULL(pScreen, &pPriv->clip);
+ RegionNull(&pPriv->clip);
#endif
#if 0
diff --git a/xorg-server/hw/xwin/winwin32rootless.c b/xorg-server/hw/xwin/winwin32rootless.c index f76363e43..85a932f75 100644 --- a/xorg-server/hw/xwin/winwin32rootless.c +++ b/xorg-server/hw/xwin/winwin32rootless.c @@ -1,982 +1,982 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Kensuke Matsuzaki - * Earle F. Philhower, III - * Harold L Hunt II - */ -/* - * Look at hw/darwin/quartz/xpr/xprFrame.c and hw/darwin/quartz/cr/crFrame.c - */ -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include <winuser.h> -#define _WINDOWSWM_SERVER_ -#include <X11/extensions/windowswmstr.h> -#include "dixevents.h" -#include "winmultiwindowclass.h" -#include "winprefs.h" -#include <X11/Xatom.h> - - -/* - * Constant defines - */ - -#ifndef ULW_COLORKEY -#define ULW_COLORKEY 0x00000001 -#endif -#ifndef ULW_ALPHA -#define ULW_ALPHA 0x00000002 -#endif -#ifndef ULW_OPAQUE -#define ULW_OPAQUE 0x00000004 -#endif -#define AC_SRC_ALPHA 0x01 - -/* - * Local function - */ - -DEFINE_ATOM_HELPER(AtmWindowsWmNativeHwnd, WINDOWSWM_NATIVE_HWND) -static void -winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame); - -/* - * Global variables - */ - -Bool g_fNoConfigureWindow = FALSE; - -/* - * Internal function to get the DIB format that is compatible with the screen - * Fixme: Share code with winshadgdi.c - */ - -static -Bool -winMWExtWMQueryDIBFormat (win32RootlessWindowPtr pRLWinPriv, BITMAPINFOHEADER *pbmih) -{ - HBITMAP hbmp; -#if CYGMULTIWINDOW_DEBUG - LPDWORD pdw = NULL; -#endif - - /* Create a memory bitmap compatible with the screen */ - hbmp = CreateCompatibleBitmap (pRLWinPriv->hdcScreen, 1, 1); - if (hbmp == NULL) - { - ErrorF ("winMWExtWMQueryDIBFormat - CreateCompatibleBitmap failed\n"); - return FALSE; - } - - /* Initialize our bitmap info header */ - ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD)); - pbmih->biSize = sizeof (BITMAPINFOHEADER); - - /* Get the biBitCount */ - if (!GetDIBits (pRLWinPriv->hdcScreen, - hbmp, - 0, 1, - NULL, - (BITMAPINFO*) pbmih, - DIB_RGB_COLORS)) - { - ErrorF ("winMWExtWMQueryDIBFormat - First call to GetDIBits failed\n"); - DeleteObject (hbmp); - return FALSE; - } - -#if CYGMULTIWINDOW_DEBUG - /* Get a pointer to bitfields */ - pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER)); - - winDebug ("winMWExtWMQueryDIBFormat - First call masks: %08x %08x %08x\n", - (unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]); -#endif - - /* Get optimal color table, or the optimal bitfields */ - if (!GetDIBits (pRLWinPriv->hdcScreen, - hbmp, - 0, 1, - NULL, - (BITMAPINFO*)pbmih, - DIB_RGB_COLORS)) - { - ErrorF ("winMWExtWMQueryDIBFormat - Second call to GetDIBits " - "failed\n"); - DeleteObject (hbmp); - return FALSE; - } - - /* Free memory */ - DeleteObject (hbmp); - - return TRUE; -} - -static HRGN -winMWExtWMCreateRgnFromRegion (RegionPtr pShape) -{ - int nRects; - BoxPtr pRects, pEnd; - HRGN hRgn, hRgnRect; - - if (pShape == NULL) return NULL; - - nRects = REGION_NUM_RECTS(pShape); - pRects = REGION_RECTS(pShape); - - hRgn = CreateRectRgn (0, 0, 0, 0); - if (hRgn == NULL) - { - ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) " - "failed: %d\n", - 0, 0, 0, 0, (int) GetLastError ()); - } - - /* Loop through all rectangles in the X region */ - for (pEnd = pRects + nRects; pRects < pEnd; pRects++) - { - /* Create a Windows region for the X rectangle */ - hRgnRect = CreateRectRgn (pRects->x1, - pRects->y1, - pRects->x2, - pRects->y2); - if (hRgnRect == NULL) - { - ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) " - "failed: %d\n", - pRects->x1, - pRects->y1, - pRects->x2, - pRects->y2, - (int) GetLastError ()); - } - - /* Merge the Windows region with the accumulated region */ - if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR) - { - ErrorF ("winReshape - CombineRgn () failed: %d\n", - (int) GetLastError ()); - } - - /* Delete the temporary Windows region */ - DeleteObject (hRgnRect); - } - - return hRgn; -} - -static void -InitWin32RootlessEngine (win32RootlessWindowPtr pRLWinPriv) -{ - pRLWinPriv->hdcScreen = GetDC (pRLWinPriv->hWnd); - pRLWinPriv->hdcShadow = CreateCompatibleDC (pRLWinPriv->hdcScreen); - pRLWinPriv->hbmpShadow = NULL; - - /* Allocate bitmap info header */ - pRLWinPriv->pbmihShadow = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER) - + 256 * sizeof (RGBQUAD)); - if (pRLWinPriv->pbmihShadow == NULL) - { - ErrorF ("InitWin32RootlessEngine - malloc () failed\n"); - return; - } - - /* Query the screen format */ - winMWExtWMQueryDIBFormat (pRLWinPriv, - pRLWinPriv->pbmihShadow); -} - -Bool -winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen, - int newX, int newY, RegionPtr pShape) -{ -#define CLASS_NAME_LENGTH 512 - Bool fResult = TRUE; - win32RootlessWindowPtr pRLWinPriv; - WNDCLASSEX wc; - char pszClass[CLASS_NAME_LENGTH], pszWindowID[12]; - HICON hIcon; - HICON hIconSmall; - char *res_name, *res_class, *res_role; - static int s_iWindowID = 0; - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMCreateFrame %d %d - %d %d\n", - newX, newY, pFrame->width, pFrame->height); -#endif - - pRLWinPriv = (win32RootlessWindowPtr) malloc (sizeof (win32RootlessWindowRec)); - pRLWinPriv->pFrame = pFrame; - pRLWinPriv->pfb = NULL; - pRLWinPriv->hbmpShadow = NULL; - pRLWinPriv->hdcShadow = NULL; - pRLWinPriv->hdcScreen = NULL; - pRLWinPriv->pbmihShadow = NULL; - pRLWinPriv->fResized = TRUE; - pRLWinPriv->fClose = FALSE; - pRLWinPriv->fRestackingNow = FALSE; - pRLWinPriv->fDestroyed = FALSE; - pRLWinPriv->fMovingOrSizing = FALSE; - - // Store the implementation private frame ID - pFrame->wid = (RootlessFrameID) pRLWinPriv; - - winSelectIcons(pFrame->win, &hIcon, &hIconSmall); - - /* Set standard class name prefix so we can identify window easily */ - strncpy (pszClass, WINDOW_CLASS_X, sizeof(pszClass)); - - if (winMultiWindowGetClassHint (pFrame->win, &res_name, &res_class)) - { - strncat (pszClass, "-", 1); - strncat (pszClass, res_name, CLASS_NAME_LENGTH - strlen (pszClass)); - strncat (pszClass, "-", 1); - strncat (pszClass, res_class, CLASS_NAME_LENGTH - strlen (pszClass)); - - /* Check if a window class is provided by the WM_WINDOW_ROLE property, - * if not use the WM_CLASS information. - * For further information see: - * http://tronche.com/gui/x/icccm/sec-5.html - */ - if (winMultiWindowGetWindowRole (pFrame->win, &res_role) ) - { - strcat (pszClass, "-"); - strcat (pszClass, res_role); - free (res_role); - } - - free (res_name); - free (res_class); - } - - /* Add incrementing window ID to make unique class name */ - snprintf (pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++); - pszWindowID[sizeof(pszWindowID)-1] = 0; - strcat (pszClass, pszWindowID); - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winCreateWindowsWindow - Creating class: %s\n", pszClass); -#endif - - /* Setup our window class */ - wc.cbSize = sizeof(wc); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = winMWExtWMWindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = g_hInstance; - wc.hIcon = hIcon; - wc.hIconSm = hIconSmall; - wc.hCursor = 0; - wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); - wc.lpszMenuName = NULL; - wc.lpszClassName = pszClass; - RegisterClassEx (&wc); - - /* Create the window */ - g_fNoConfigureWindow = TRUE; - pRLWinPriv->hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */ - pszClass, /* Class name */ - WINDOW_TITLE_X, /* Window name */ - WS_POPUP | WS_CLIPCHILDREN, - newX, /* Horizontal position */ - newY, /* Vertical position */ - pFrame->width, /* Right edge */ - pFrame->height, /* Bottom edge */ - (HWND) NULL, /* No parent or owner window */ - (HMENU) NULL, /* No menu */ - GetModuleHandle (NULL), /* Instance handle */ - pRLWinPriv); /* ScreenPrivates */ - if (pRLWinPriv->hWnd == NULL) - { - ErrorF ("winMWExtWMCreateFrame - CreateWindowExA () failed: %d\n", - (int) GetLastError ()); - fResult = FALSE; - } - - winDebug ("winMWExtWMCreateFrame - ShowWindow\n"); - - //ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE); - g_fNoConfigureWindow = FALSE; - - if (pShape != NULL) - { - winMWExtWMReshapeFrame (pFrame->wid, pShape); - } - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMCreateFrame - (%08x) %08x\n", - (int) pFrame->wid, (int) pRLWinPriv->hWnd); -#if 0 - { - WindowPtr pWin2 = NULL; - win32RootlessWindowPtr pRLWinPriv2 = NULL; - - /* Check if the Windows window property for our X window pointer is valid */ - if ((pWin2 = (WindowPtr)GetProp (pRLWinPriv->hWnd, WIN_WINDOW_PROP)) != NULL) - { - pRLWinPriv2 = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin2, FALSE); - } - winDebug ("winMWExtWMCreateFrame2 (%08x) %08x\n", - pRLWinPriv2, pRLWinPriv2->hWnd); - if (pRLWinPriv != pRLWinPriv2 || pRLWinPriv->hWnd != pRLWinPriv2->hWnd) - { - winDebug ("Error param missmatch\n"); - } - } -#endif -#endif - - winMWExtWMSetNativeProperty (pFrame); - - return fResult; -} - -void -winMWExtWMDestroyFrame (RootlessFrameID wid) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; - HICON hiconClass; - HICON hiconSmClass; - HMODULE hInstance; - int iReturn; - char pszClass[CLASS_NAME_LENGTH]; - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMDestroyFrame (%08x) %08x\n", - (int) pRLWinPriv, (int) pRLWinPriv->hWnd); -#if 0 - { - WindowPtr pWin2 = NULL; - win32RootlessWindowPtr pRLWinPriv2 = NULL; - - /* Check if the Windows window property for our X window pointer is valid */ - if ((pWin2 = (WindowPtr)GetProp (pRLWinPriv->hWnd, WIN_WINDOW_PROP)) != NULL) - { - pRLWinPriv2 = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin2, FALSE); - } - winDebug ("winMWExtWMDestroyFrame2 (%08x) %08x\n", - pRLWinPriv2, pRLWinPriv2->hWnd); - if (pRLWinPriv != pRLWinPriv2 || pRLWinPriv->hWnd != pRLWinPriv2->hWnd) - { - winDebug ("Error param missmatch\n"); - *(int*)0 = 1;//raise exseption - } - } -#endif -#endif - - /* Store the info we need to destroy after this window is gone */ - hInstance = (HINSTANCE) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HMODULE); - hiconClass = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICON); - hiconSmClass = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICONSM); - iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH); - - pRLWinPriv->fClose = TRUE; - pRLWinPriv->fDestroyed = TRUE; - - /* Destroy the Windows window */ - DestroyWindow (pRLWinPriv->hWnd); - - /* Only if we were able to get the name */ - if (iReturn) - { -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMDestroyFrame - Unregistering %s: ", pszClass); -#endif - iReturn = UnregisterClass (pszClass, hInstance); - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMDestroyFramew - %d Deleting Icon: ", iReturn); -#endif - - winDestroyIcon(hiconClass); - winDestroyIcon(hiconSmClass); - } - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMDestroyFrame - done\n"); -#endif -} - -void -winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int iNewX, int iNewY) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; - RECT rcNew; - DWORD dwExStyle; - DWORD dwStyle; - int iX, iY, iWidth, iHeight; - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMMoveFrame (%08x) (%d %d)\n", (int) pRLWinPriv, iNewX, iNewY); -#endif - - /* Get the Windows window style and extended style */ - dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE); - dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE); - - /* Get the X and Y location of the X window */ - iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN); - iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN); - - /* Get the height and width of the X window */ - iWidth = pRLWinPriv->pFrame->width; - iHeight = pRLWinPriv->pFrame->height; - - /* Store the origin, height, and width in a rectangle structure */ - SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight); - -#ifdef CYGMULTIWINDOW_DEBUG - winDebug("\tWindow {%d, %d, %d, %d}, {%d, %d}\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top); -#endif - /* - * Calculate the required size of the Windows window rectangle, - * given the size of the Windows window client area. - */ - AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle); - -#ifdef CYGMULTIWINDOW_DEBUG - winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top); -#endif - g_fNoConfigureWindow = TRUE; - SetWindowPos (pRLWinPriv->hWnd, NULL, rcNew.left, rcNew.top, 0, 0, - SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); - g_fNoConfigureWindow = FALSE; -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMMoveFrame (%08x) done\n", (int) pRLWinPriv); -#endif -} - -void -winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen, - int iNewX, int iNewY, - unsigned int uiNewWidth, unsigned int uiNewHeight, - unsigned int uiGravity) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; - RECT rcNew; - RECT rcOld; - DWORD dwExStyle; - DWORD dwStyle; - int iX, iY; - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMResizeFrame (%08x) (%d %d)-(%d %d)\n", - (int) pRLWinPriv, iNewX, iNewY, uiNewWidth, uiNewHeight); -#endif - - pRLWinPriv->fResized = TRUE; - - /* Get the Windows window style and extended style */ - dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE); - dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE); - - /* Get the X and Y location of the X window */ - iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN); - iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN); - - /* Store the origin, height, and width in a rectangle structure */ - SetRect (&rcNew, iX, iY, iX + uiNewWidth, iY + uiNewHeight); - - /* - * Calculate the required size of the Windows window rectangle, - * given the size of the Windows window client area. - */ - AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle); - - /* Get a rectangle describing the old Windows window */ - GetWindowRect (pRLWinPriv->hWnd, &rcOld); - - /* Check if the old rectangle and new rectangle are the same */ - if (!EqualRect (&rcNew, &rcOld)) - { - - g_fNoConfigureWindow = TRUE; - MoveWindow (pRLWinPriv->hWnd, - rcNew.left, rcNew.top, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, - TRUE); - g_fNoConfigureWindow = FALSE; - } -} - -void -winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; - win32RootlessWindowPtr pRLNextWinPriv = (win32RootlessWindowPtr) nextWid; - winScreenPriv(pRLWinPriv->pFrame->win->drawable.pScreen); - winScreenInfo *pScreenInfo = NULL; - DWORD dwCurrentProcessID = GetCurrentProcessId (); - DWORD dwWindowProcessID = 0; - HWND hWnd; - Bool fFirst = TRUE; - Bool fNeedRestack = TRUE; -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMRestackFrame (%08x)\n", (int) pRLWinPriv); -#endif - - if (pScreenPriv->fRestacking) return; - - if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo; - - pRLWinPriv->fRestackingNow = TRUE; - - /* Show window */ - if(!IsWindowVisible (pRLWinPriv->hWnd)) - ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE); - - if (pRLNextWinPriv == NULL) - { -#if CYGMULTIWINDOW_DEBUG - winDebug ("Win %08x is top\n", pRLWinPriv); -#endif - pScreenPriv->widTop = wid; - SetWindowPos (pRLWinPriv->hWnd, HWND_TOP, - 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); - } - else if (winIsInternalWMRunning(pScreenInfo)) - { - /* using mulwinidow wm */ -#if CYGMULTIWINDOW_DEBUG - winDebug ("Win %08x is not top\n", pRLWinPriv); -#endif - for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDPREV); - fNeedRestack && hWnd != NULL; - hWnd = GetNextWindow (hWnd, GW_HWNDPREV)) - { - GetWindowThreadProcessId (hWnd, &dwWindowProcessID); - - if ((dwWindowProcessID == dwCurrentProcessID) - && GetProp (hWnd, WIN_WINDOW_PROP)) - { - if (hWnd == pRLNextWinPriv->hWnd) - { - /* Enable interleave X window and Windows window */ - if (!fFirst) - { -#if CYGMULTIWINDOW_DEBUG - winDebug ("raise: Insert after Win %08x\n", pRLNextWinPriv); -#endif - SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd, - 0, 0, 0, 0, - SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); - } - else - { -#if CYGMULTIWINDOW_DEBUG - winDebug ("No change\n"); -#endif - } - fNeedRestack = FALSE; - break; - } - if (fFirst) fFirst = FALSE; - } - } - - for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDNEXT); - fNeedRestack && hWnd != NULL; - hWnd = GetNextWindow (hWnd, GW_HWNDNEXT)) - { - GetWindowThreadProcessId (hWnd, &dwWindowProcessID); - - if ((dwWindowProcessID == dwCurrentProcessID) - && GetProp (hWnd, WIN_WINDOW_PROP)) - { - if (hWnd == pRLNextWinPriv->hWnd) - { -#if CYGMULTIWINDOW_DEBUG - winDebug ("lower: Insert after Win %08x\n", pRLNextWinPriv); -#endif - SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd, - 0, 0, 0, 0, - SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); - fNeedRestack = FALSE; - break; - } - } - } - } - else - { - /* using general wm like twm, wmaker etc. - Interleave X window and Windows window will cause problem. */ - SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd, - 0, 0, 0, 0, - SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); -#if 0 -#endif - } -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMRestackFrame - done (%08x)\n", (int) pRLWinPriv); -#endif - - pRLWinPriv->fRestackingNow = FALSE; -} - -void -winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; - HRGN hRgn, hRgnWindow, hRgnClient; - RECT rcWindow, rcClient; -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMReshapeFrame (%08x)\n", (int) pRLWinPriv); -#endif - - hRgn = winMWExtWMCreateRgnFromRegion (pShape); - - /* Create region for non-client area */ - GetWindowRect (pRLWinPriv->hWnd, &rcWindow); - GetClientRect (pRLWinPriv->hWnd, &rcClient); - MapWindowPoints (pRLWinPriv->hWnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2); - OffsetRgn (hRgn, rcClient.left - rcWindow.left, rcClient.top - rcWindow.top); - OffsetRect (&rcClient, -rcWindow.left, -rcWindow.top); - OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top); - hRgnWindow = CreateRectRgnIndirect (&rcWindow); - hRgnClient = CreateRectRgnIndirect (&rcClient); - CombineRgn (hRgnWindow, hRgnWindow, hRgnClient, RGN_DIFF); - CombineRgn (hRgn, hRgnWindow, hRgn, RGN_OR); - - - SetWindowRgn (pRLWinPriv->hWnd, hRgn, TRUE); - - DeleteObject (hRgnWindow); - DeleteObject (hRgnClient); -} - -void -winMWExtWMUnmapFrame (RootlessFrameID wid) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMUnmapFrame (%08x)\n", (int) pRLWinPriv); -#endif - - g_fNoConfigureWindow = TRUE; - //ShowWindow (pRLWinPriv->hWnd, SW_MINIMIZE); - ShowWindow (pRLWinPriv->hWnd, SW_HIDE); - g_fNoConfigureWindow = FALSE; -} - -/* - * Fixme: Code sharing with winshadgdi.c and other engine support - */ -void -winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; - winPrivScreenPtr pScreenPriv = NULL; - winScreenInfo *pScreenInfo = NULL; - ScreenPtr pScreen = NULL; - DIBSECTION dibsection; - Bool fReturn = TRUE; - HDC hdcNew; - HBITMAP hbmpNew; -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMStartDrawing (%08x) %08x\n", (int) pRLWinPriv, pRLWinPriv->fDestroyed); -#endif - - if (!pRLWinPriv->fDestroyed) - { - pScreen = pRLWinPriv->pFrame->win->drawable.pScreen; - if (pScreen) pScreenPriv = winGetScreenPriv(pScreen); - if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo; - -#if CYGMULTIWINDOW_DEBUG - winDebug ("\tpScreenPriv %08X\n", (int) pScreenPriv); - winDebug ("\tpScreenInfo %08X\n", (int) pScreenInfo); - winDebug ("\t(%d, %d)\n", (int)pRLWinPriv->pFrame->width, - (int) pRLWinPriv->pFrame->height); -#endif - if (pRLWinPriv->hdcScreen == NULL) - { - InitWin32RootlessEngine (pRLWinPriv); - } - - if (pRLWinPriv->fResized) - { - /* width * bpp must be multiple of 4 to match 32bit alignment */ - int stridesize; - int misalignment; - - pRLWinPriv->pbmihShadow->biWidth = pRLWinPriv->pFrame->width; - pRLWinPriv->pbmihShadow->biHeight = -pRLWinPriv->pFrame->height; - - stridesize = pRLWinPriv->pFrame->width * (pScreenInfo->dwBPP >> 3); - misalignment = stridesize & 3; - if (misalignment != 0) - { - stridesize += 4 - misalignment; - pRLWinPriv->pbmihShadow->biWidth = stridesize / (pScreenInfo->dwBPP >> 3); - winDebug("\tresizing to %d (was %d)\n", - pRLWinPriv->pbmihShadow->biWidth, pRLWinPriv->pFrame->width); - } - - hdcNew = CreateCompatibleDC (pRLWinPriv->hdcScreen); - /* Create a DI shadow bitmap with a bit pointer */ - hbmpNew = CreateDIBSection (pRLWinPriv->hdcScreen, - (BITMAPINFO *) pRLWinPriv->pbmihShadow, - DIB_RGB_COLORS, - (VOID**) &pRLWinPriv->pfb, - NULL, - 0); - if (hbmpNew == NULL || pRLWinPriv->pfb == NULL) - { - ErrorF ("winMWExtWMStartDrawing - CreateDIBSection failed\n"); - //return FALSE; - } - else - { -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMStartDrawing - Shadow buffer allocated\n"); -#endif - } - - /* Get information about the bitmap that was allocated */ - GetObject (hbmpNew, sizeof (dibsection), &dibsection); - -#if CYGMULTIWINDOW_DEBUG - /* Print information about bitmap allocated */ - winDebug ("winMWExtWMStartDrawing - Dibsection width: %d height: %d " - "depth: %d size image: %d\n", - (unsigned int)dibsection.dsBmih.biWidth, - (unsigned int)dibsection.dsBmih.biHeight, - (unsigned int)dibsection.dsBmih.biBitCount, - (unsigned int)dibsection.dsBmih.biSizeImage); -#endif - - /* Select the shadow bitmap into the shadow DC */ - SelectObject (hdcNew, hbmpNew); - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMStartDrawing - Attempting a shadow blit\n"); -#endif - - /* Blit from the old shadow to the new shadow */ - fReturn = BitBlt (hdcNew, - 0, 0, - pRLWinPriv->pFrame->width, pRLWinPriv->pFrame->height, - pRLWinPriv->hdcShadow, - 0, 0, - SRCCOPY); - if (fReturn) - { - winDebug ("winMWExtWMStartDrawing - Shadow blit success\n"); - } - else - { - ErrorF ("winMWExtWMStartDrawing - Shadow blit failure\n"); - } - - /* Look for height weirdness */ - if (dibsection.dsBmih.biHeight < 0) - { - /* FIXME: Figure out why biHeight is sometimes negative */ - ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - " - "biHeight still negative: %d\n", - (int) dibsection.dsBmih.biHeight); - ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - " - "Flipping biHeight sign\n"); - dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight; - } - - pRLWinPriv->dwWidthBytes = dibsection.dsBm.bmWidthBytes; - - winDebug ("winMWExtWMStartDrawing - bytesPerRow: %d\n", - (unsigned int)dibsection.dsBm.bmWidthBytes); - - /* Free the old shadow bitmap */ - DeleteObject (pRLWinPriv->hdcShadow); - DeleteObject (pRLWinPriv->hbmpShadow); - - pRLWinPriv->hdcShadow = hdcNew; - pRLWinPriv->hbmpShadow = hbmpNew; - - pRLWinPriv->fResized = FALSE; - winDebug ("winMWExtWMStartDrawing - 0x%08x %d\n", - (unsigned int)pRLWinPriv->pfb, - (unsigned int)dibsection.dsBm.bmWidthBytes); - } - } - else - { - ErrorF ("winMWExtWMStartDrawing - Already window was destroyed \n"); - } - winDebug ("winMWExtWMStartDrawing - done (0x%08x) 0x%08x %d\n", - (int) pRLWinPriv, - (unsigned int)pRLWinPriv->pfb, (unsigned int)pRLWinPriv->dwWidthBytes); - *pixelData = pRLWinPriv->pfb; - *bytesPerRow = pRLWinPriv->dwWidthBytes; -} - -void -winMWExtWMStopDrawing (RootlessFrameID wid, Bool fFlush) -{ -} - -void -winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; - if (!g_fNoConfigureWindow) UpdateWindow (pRLWinPriv->hWnd); -} - -void -winMWExtWMDamageRects (RootlessFrameID wid, int nCount, const BoxRec *pRects, - int shift_x, int shift_y) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; - const BoxRec *pEnd; - winDebug ("winMWExtWMDamageRects (%08x, %d, %08x, %d, %d)\n", - pRLWinPriv, nCount, pRects, shift_x, shift_y); - - for (pEnd = pRects + nCount; pRects < pEnd; pRects++) { - RECT rcDmg; - rcDmg.left = pRects->x1 + shift_x; - rcDmg.top = pRects->y1 + shift_y; - rcDmg.right = pRects->x2 + shift_x; - rcDmg.bottom = pRects->y2 + shift_y; - - InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE); - } -} - -void -winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid; - winDebug ("winMWExtWMRootlessSwitchWindow (%08x) %08x\n", - (int) pRLWinPriv, (int) pRLWinPriv->hWnd); - pRLWinPriv->pFrame = pFrame; - pRLWinPriv->fResized = TRUE; - - /* Set the window extended style flags */ - SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW); - - /* Set the window standard style flags */ - SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE, - WS_POPUP | WS_CLIPCHILDREN); - - DeleteProperty (serverClient, oldWin, AtmWindowsWmNativeHwnd ()); - winMWExtWMSetNativeProperty (pFrame); -} - -void -winMWExtWMCopyBytes (unsigned int width, unsigned int height, - const void *src, unsigned int srcRowBytes, - void *dst, unsigned int dstRowBytes) -{ - winDebug ("winMWExtWMCopyBytes - Not implemented\n"); -} - -void -winMWExtWMFillBytes (unsigned int width, unsigned int height, unsigned int value, - void *dst, unsigned int dstRowBytes) -{ - winDebug ("winMWExtWMFillBytes - Not implemented\n"); -} - -int -winMWExtWMCompositePixels (unsigned int width, unsigned int height, unsigned int function, - void *src[2], unsigned int srcRowBytes[2], - void *mask, unsigned int maskRowBytes, - void *dst[2], unsigned int dstRowBytes[2]) -{ - winDebug ("winMWExtWMCompositePixels - Not implemented\n"); - return 0; -} - - -void -winMWExtWMCopyWindow (RootlessFrameID wid, int nDstRects, const BoxRec *pDstRects, - int nDx, int nDy) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; - const BoxRec *pEnd; - RECT rcDmg; - winDebug ("winMWExtWMCopyWindow (%08x, %d, %08x, %d, %d)\n", - (int) pRLWinPriv, nDstRects, (int) pDstRects, nDx, nDy); - - for (pEnd = pDstRects + nDstRects; pDstRects < pEnd; pDstRects++) - { - winDebug ("BitBlt (%d, %d, %d, %d) (%d, %d)\n", - pDstRects->x1, pDstRects->y1, - pDstRects->x2 - pDstRects->x1, - pDstRects->y2 - pDstRects->y1, - pDstRects->x1 + nDx, - pDstRects->y1 + nDy); - - if (!BitBlt (pRLWinPriv->hdcShadow, - pDstRects->x1, pDstRects->y1, - pDstRects->x2 - pDstRects->x1, - pDstRects->y2 - pDstRects->y1, - pRLWinPriv->hdcShadow, - pDstRects->x1 + nDx, pDstRects->y1 + nDy, - SRCCOPY)) - { - ErrorF ("winMWExtWMCopyWindow - BitBlt failed.\n"); - } - - rcDmg.left = pDstRects->x1; - rcDmg.top = pDstRects->y1; - rcDmg.right = pDstRects->x2; - rcDmg.bottom = pDstRects->y2; - - InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE); - } - winDebug ("winMWExtWMCopyWindow - done\n"); -} - - -/* - * winMWExtWMSetNativeProperty - */ - -static void -winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame) -{ - win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid; - long lData; - - /* FIXME: move this to WindowsWM extension */ - - lData = (long) pRLWinPriv->hWnd; - dixChangeWindowProperty(serverClient, pFrame->win, AtmWindowsWmNativeHwnd(), - XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE); -} +/*
+ *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Earle F. Philhower, III
+ * Harold L Hunt II
+ */
+/*
+ * Look at hw/darwin/quartz/xpr/xprFrame.c and hw/darwin/quartz/cr/crFrame.c
+ */
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include <winuser.h>
+#define _WINDOWSWM_SERVER_
+#include <X11/extensions/windowswmstr.h>
+#include "dixevents.h"
+#include "winmultiwindowclass.h"
+#include "winprefs.h"
+#include <X11/Xatom.h>
+
+
+/*
+ * Constant defines
+ */
+
+#ifndef ULW_COLORKEY
+#define ULW_COLORKEY 0x00000001
+#endif
+#ifndef ULW_ALPHA
+#define ULW_ALPHA 0x00000002
+#endif
+#ifndef ULW_OPAQUE
+#define ULW_OPAQUE 0x00000004
+#endif
+#define AC_SRC_ALPHA 0x01
+
+/*
+ * Local function
+ */
+
+DEFINE_ATOM_HELPER(AtmWindowsWmNativeHwnd, WINDOWSWM_NATIVE_HWND)
+static void
+winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame);
+
+/*
+ * Global variables
+ */
+
+Bool g_fNoConfigureWindow = FALSE;
+
+/*
+ * Internal function to get the DIB format that is compatible with the screen
+ * Fixme: Share code with winshadgdi.c
+ */
+
+static
+Bool
+winMWExtWMQueryDIBFormat (win32RootlessWindowPtr pRLWinPriv, BITMAPINFOHEADER *pbmih)
+{
+ HBITMAP hbmp;
+#if CYGMULTIWINDOW_DEBUG
+ LPDWORD pdw = NULL;
+#endif
+
+ /* Create a memory bitmap compatible with the screen */
+ hbmp = CreateCompatibleBitmap (pRLWinPriv->hdcScreen, 1, 1);
+ if (hbmp == NULL)
+ {
+ ErrorF ("winMWExtWMQueryDIBFormat - CreateCompatibleBitmap failed\n");
+ return FALSE;
+ }
+
+ /* Initialize our bitmap info header */
+ ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
+ pbmih->biSize = sizeof (BITMAPINFOHEADER);
+
+ /* Get the biBitCount */
+ if (!GetDIBits (pRLWinPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*) pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winMWExtWMQueryDIBFormat - First call to GetDIBits failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ /* Get a pointer to bitfields */
+ pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+
+ winDebug ("winMWExtWMQueryDIBFormat - First call masks: %08x %08x %08x\n",
+ (unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]);
+#endif
+
+ /* Get optimal color table, or the optimal bitfields */
+ if (!GetDIBits (pRLWinPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*)pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winMWExtWMQueryDIBFormat - Second call to GetDIBits "
+ "failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+ /* Free memory */
+ DeleteObject (hbmp);
+
+ return TRUE;
+}
+
+static HRGN
+winMWExtWMCreateRgnFromRegion (RegionPtr pShape)
+{
+ int nRects;
+ BoxPtr pRects, pEnd;
+ HRGN hRgn, hRgnRect;
+
+ if (pShape == NULL) return NULL;
+
+ nRects = RegionNumRects(pShape);
+ pRects = RegionRects(pShape);
+
+ hRgn = CreateRectRgn (0, 0, 0, 0);
+ if (hRgn == NULL)
+ {
+ ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n",
+ 0, 0, 0, 0, (int) GetLastError ());
+ }
+
+ /* Loop through all rectangles in the X region */
+ for (pEnd = pRects + nRects; pRects < pEnd; pRects++)
+ {
+ /* Create a Windows region for the X rectangle */
+ hRgnRect = CreateRectRgn (pRects->x1,
+ pRects->y1,
+ pRects->x2,
+ pRects->y2);
+ if (hRgnRect == NULL)
+ {
+ ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n",
+ pRects->x1,
+ pRects->y1,
+ pRects->x2,
+ pRects->y2,
+ (int) GetLastError ());
+ }
+
+ /* Merge the Windows region with the accumulated region */
+ if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
+ {
+ ErrorF ("winReshape - CombineRgn () failed: %d\n",
+ (int) GetLastError ());
+ }
+
+ /* Delete the temporary Windows region */
+ DeleteObject (hRgnRect);
+ }
+
+ return hRgn;
+}
+
+static void
+InitWin32RootlessEngine (win32RootlessWindowPtr pRLWinPriv)
+{
+ pRLWinPriv->hdcScreen = GetDC (pRLWinPriv->hWnd);
+ pRLWinPriv->hdcShadow = CreateCompatibleDC (pRLWinPriv->hdcScreen);
+ pRLWinPriv->hbmpShadow = NULL;
+
+ /* Allocate bitmap info header */
+ pRLWinPriv->pbmihShadow = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ + 256 * sizeof (RGBQUAD));
+ if (pRLWinPriv->pbmihShadow == NULL)
+ {
+ ErrorF ("InitWin32RootlessEngine - malloc () failed\n");
+ return;
+ }
+
+ /* Query the screen format */
+ winMWExtWMQueryDIBFormat (pRLWinPriv,
+ pRLWinPriv->pbmihShadow);
+}
+
+Bool
+winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape)
+{
+#define CLASS_NAME_LENGTH 512
+ Bool fResult = TRUE;
+ win32RootlessWindowPtr pRLWinPriv;
+ WNDCLASSEX wc;
+ char pszClass[CLASS_NAME_LENGTH], pszWindowID[12];
+ HICON hIcon;
+ HICON hIconSmall;
+ char *res_name, *res_class, *res_role;
+ static int s_iWindowID = 0;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMCreateFrame %d %d - %d %d\n",
+ newX, newY, pFrame->width, pFrame->height);
+#endif
+
+ pRLWinPriv = (win32RootlessWindowPtr) malloc (sizeof (win32RootlessWindowRec));
+ pRLWinPriv->pFrame = pFrame;
+ pRLWinPriv->pfb = NULL;
+ pRLWinPriv->hbmpShadow = NULL;
+ pRLWinPriv->hdcShadow = NULL;
+ pRLWinPriv->hdcScreen = NULL;
+ pRLWinPriv->pbmihShadow = NULL;
+ pRLWinPriv->fResized = TRUE;
+ pRLWinPriv->fClose = FALSE;
+ pRLWinPriv->fRestackingNow = FALSE;
+ pRLWinPriv->fDestroyed = FALSE;
+ pRLWinPriv->fMovingOrSizing = FALSE;
+
+ // Store the implementation private frame ID
+ pFrame->wid = (RootlessFrameID) pRLWinPriv;
+
+ winSelectIcons(pFrame->win, &hIcon, &hIconSmall);
+
+ /* Set standard class name prefix so we can identify window easily */
+ strncpy (pszClass, WINDOW_CLASS_X, sizeof(pszClass));
+
+ if (winMultiWindowGetClassHint (pFrame->win, &res_name, &res_class))
+ {
+ strncat (pszClass, "-", 1);
+ strncat (pszClass, res_name, CLASS_NAME_LENGTH - strlen (pszClass));
+ strncat (pszClass, "-", 1);
+ strncat (pszClass, res_class, CLASS_NAME_LENGTH - strlen (pszClass));
+
+ /* Check if a window class is provided by the WM_WINDOW_ROLE property,
+ * if not use the WM_CLASS information.
+ * For further information see:
+ * http://tronche.com/gui/x/icccm/sec-5.html
+ */
+ if (winMultiWindowGetWindowRole (pFrame->win, &res_role) )
+ {
+ strcat (pszClass, "-");
+ strcat (pszClass, res_role);
+ free (res_role);
+ }
+
+ free (res_name);
+ free (res_class);
+ }
+
+ /* Add incrementing window ID to make unique class name */
+ snprintf (pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++);
+ pszWindowID[sizeof(pszWindowID)-1] = 0;
+ strcat (pszClass, pszWindowID);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winCreateWindowsWindow - Creating class: %s\n", pszClass);
+#endif
+
+ /* Setup our window class */
+ wc.cbSize = sizeof(wc);
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = winMWExtWMWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = g_hInstance;
+ wc.hIcon = hIcon;
+ wc.hIconSm = hIconSmall;
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = pszClass;
+ RegisterClassEx (&wc);
+
+ /* Create the window */
+ g_fNoConfigureWindow = TRUE;
+ pRLWinPriv->hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */
+ pszClass, /* Class name */
+ WINDOW_TITLE_X, /* Window name */
+ WS_POPUP | WS_CLIPCHILDREN,
+ newX, /* Horizontal position */
+ newY, /* Vertical position */
+ pFrame->width, /* Right edge */
+ pFrame->height, /* Bottom edge */
+ (HWND) NULL, /* No parent or owner window */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle (NULL), /* Instance handle */
+ pRLWinPriv); /* ScreenPrivates */
+ if (pRLWinPriv->hWnd == NULL)
+ {
+ ErrorF ("winMWExtWMCreateFrame - CreateWindowExA () failed: %d\n",
+ (int) GetLastError ());
+ fResult = FALSE;
+ }
+
+ winDebug ("winMWExtWMCreateFrame - ShowWindow\n");
+
+ //ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
+ g_fNoConfigureWindow = FALSE;
+
+ if (pShape != NULL)
+ {
+ winMWExtWMReshapeFrame (pFrame->wid, pShape);
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMCreateFrame - (%08x) %08x\n",
+ (int) pFrame->wid, (int) pRLWinPriv->hWnd);
+#if 0
+ {
+ WindowPtr pWin2 = NULL;
+ win32RootlessWindowPtr pRLWinPriv2 = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pWin2 = (WindowPtr)GetProp (pRLWinPriv->hWnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ pRLWinPriv2 = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin2, FALSE);
+ }
+ winDebug ("winMWExtWMCreateFrame2 (%08x) %08x\n",
+ pRLWinPriv2, pRLWinPriv2->hWnd);
+ if (pRLWinPriv != pRLWinPriv2 || pRLWinPriv->hWnd != pRLWinPriv2->hWnd)
+ {
+ winDebug ("Error param missmatch\n");
+ }
+ }
+#endif
+#endif
+
+ winMWExtWMSetNativeProperty (pFrame);
+
+ return fResult;
+}
+
+void
+winMWExtWMDestroyFrame (RootlessFrameID wid)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ HICON hiconClass;
+ HICON hiconSmClass;
+ HMODULE hInstance;
+ int iReturn;
+ char pszClass[CLASS_NAME_LENGTH];
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMDestroyFrame (%08x) %08x\n",
+ (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
+#if 0
+ {
+ WindowPtr pWin2 = NULL;
+ win32RootlessWindowPtr pRLWinPriv2 = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pWin2 = (WindowPtr)GetProp (pRLWinPriv->hWnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ pRLWinPriv2 = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin2, FALSE);
+ }
+ winDebug ("winMWExtWMDestroyFrame2 (%08x) %08x\n",
+ pRLWinPriv2, pRLWinPriv2->hWnd);
+ if (pRLWinPriv != pRLWinPriv2 || pRLWinPriv->hWnd != pRLWinPriv2->hWnd)
+ {
+ winDebug ("Error param missmatch\n");
+ *(int*)0 = 1;//raise exseption
+ }
+ }
+#endif
+#endif
+
+ /* Store the info we need to destroy after this window is gone */
+ hInstance = (HINSTANCE) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HMODULE);
+ hiconClass = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICON);
+ hiconSmClass = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICONSM);
+ iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH);
+
+ pRLWinPriv->fClose = TRUE;
+ pRLWinPriv->fDestroyed = TRUE;
+
+ /* Destroy the Windows window */
+ DestroyWindow (pRLWinPriv->hWnd);
+
+ /* Only if we were able to get the name */
+ if (iReturn)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMDestroyFrame - Unregistering %s: ", pszClass);
+#endif
+ iReturn = UnregisterClass (pszClass, hInstance);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMDestroyFramew - %d Deleting Icon: ", iReturn);
+#endif
+
+ winDestroyIcon(hiconClass);
+ winDestroyIcon(hiconSmClass);
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMDestroyFrame - done\n");
+#endif
+}
+
+void
+winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int iNewX, int iNewY)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ RECT rcNew;
+ DWORD dwExStyle;
+ DWORD dwStyle;
+ int iX, iY, iWidth, iHeight;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMMoveFrame (%08x) (%d %d)\n", (int) pRLWinPriv, iNewX, iNewY);
+#endif
+
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
+
+ /* Get the X and Y location of the X window */
+ iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Get the height and width of the X window */
+ iWidth = pRLWinPriv->pFrame->width;
+ iHeight = pRLWinPriv->pFrame->height;
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
+
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tWindow {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
+
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
+ g_fNoConfigureWindow = TRUE;
+ SetWindowPos (pRLWinPriv->hWnd, NULL, rcNew.left, rcNew.top, 0, 0,
+ SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
+ g_fNoConfigureWindow = FALSE;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMMoveFrame (%08x) done\n", (int) pRLWinPriv);
+#endif
+}
+
+void
+winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen,
+ int iNewX, int iNewY,
+ unsigned int uiNewWidth, unsigned int uiNewHeight,
+ unsigned int uiGravity)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ RECT rcNew;
+ RECT rcOld;
+ DWORD dwExStyle;
+ DWORD dwStyle;
+ int iX, iY;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMResizeFrame (%08x) (%d %d)-(%d %d)\n",
+ (int) pRLWinPriv, iNewX, iNewY, uiNewWidth, uiNewHeight);
+#endif
+
+ pRLWinPriv->fResized = TRUE;
+
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
+
+ /* Get the X and Y location of the X window */
+ iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, iX, iY, iX + uiNewWidth, iY + uiNewHeight);
+
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
+
+ /* Get a rectangle describing the old Windows window */
+ GetWindowRect (pRLWinPriv->hWnd, &rcOld);
+
+ /* Check if the old rectangle and new rectangle are the same */
+ if (!EqualRect (&rcNew, &rcOld))
+ {
+
+ g_fNoConfigureWindow = TRUE;
+ MoveWindow (pRLWinPriv->hWnd,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ TRUE);
+ g_fNoConfigureWindow = FALSE;
+ }
+}
+
+void
+winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ win32RootlessWindowPtr pRLNextWinPriv = (win32RootlessWindowPtr) nextWid;
+ winScreenPriv(pRLWinPriv->pFrame->win->drawable.pScreen);
+ winScreenInfo *pScreenInfo = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+ HWND hWnd;
+ Bool fFirst = TRUE;
+ Bool fNeedRestack = TRUE;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackFrame (%08x)\n", (int) pRLWinPriv);
+#endif
+
+ if (pScreenPriv->fRestacking) return;
+
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+
+ pRLWinPriv->fRestackingNow = TRUE;
+
+ /* Show window */
+ if(!IsWindowVisible (pRLWinPriv->hWnd))
+ ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
+
+ if (pRLNextWinPriv == NULL)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("Win %08x is top\n", pRLWinPriv);
+#endif
+ pScreenPriv->widTop = wid;
+ SetWindowPos (pRLWinPriv->hWnd, HWND_TOP,
+ 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ }
+ else if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* using mulwinidow wm */
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("Win %08x is not top\n", pRLWinPriv);
+#endif
+ for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDPREV);
+ fNeedRestack && hWnd != NULL;
+ hWnd = GetNextWindow (hWnd, GW_HWNDPREV))
+ {
+ GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hWnd, WIN_WINDOW_PROP))
+ {
+ if (hWnd == pRLNextWinPriv->hWnd)
+ {
+ /* Enable interleave X window and Windows window */
+ if (!fFirst)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("raise: Insert after Win %08x\n", pRLNextWinPriv);
+#endif
+ SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ }
+ else
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("No change\n");
+#endif
+ }
+ fNeedRestack = FALSE;
+ break;
+ }
+ if (fFirst) fFirst = FALSE;
+ }
+ }
+
+ for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDNEXT);
+ fNeedRestack && hWnd != NULL;
+ hWnd = GetNextWindow (hWnd, GW_HWNDNEXT))
+ {
+ GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hWnd, WIN_WINDOW_PROP))
+ {
+ if (hWnd == pRLNextWinPriv->hWnd)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("lower: Insert after Win %08x\n", pRLNextWinPriv);
+#endif
+ SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ fNeedRestack = FALSE;
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ /* using general wm like twm, wmaker etc.
+ Interleave X window and Windows window will cause problem. */
+ SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+#if 0
+#endif
+ }
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackFrame - done (%08x)\n", (int) pRLWinPriv);
+#endif
+
+ pRLWinPriv->fRestackingNow = FALSE;
+}
+
+void
+winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ HRGN hRgn, hRgnWindow, hRgnClient;
+ RECT rcWindow, rcClient;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMReshapeFrame (%08x)\n", (int) pRLWinPriv);
+#endif
+
+ hRgn = winMWExtWMCreateRgnFromRegion (pShape);
+
+ /* Create region for non-client area */
+ GetWindowRect (pRLWinPriv->hWnd, &rcWindow);
+ GetClientRect (pRLWinPriv->hWnd, &rcClient);
+ MapWindowPoints (pRLWinPriv->hWnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
+ OffsetRgn (hRgn, rcClient.left - rcWindow.left, rcClient.top - rcWindow.top);
+ OffsetRect (&rcClient, -rcWindow.left, -rcWindow.top);
+ OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
+ hRgnWindow = CreateRectRgnIndirect (&rcWindow);
+ hRgnClient = CreateRectRgnIndirect (&rcClient);
+ CombineRgn (hRgnWindow, hRgnWindow, hRgnClient, RGN_DIFF);
+ CombineRgn (hRgn, hRgnWindow, hRgn, RGN_OR);
+
+
+ SetWindowRgn (pRLWinPriv->hWnd, hRgn, TRUE);
+
+ DeleteObject (hRgnWindow);
+ DeleteObject (hRgnClient);
+}
+
+void
+winMWExtWMUnmapFrame (RootlessFrameID wid)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMUnmapFrame (%08x)\n", (int) pRLWinPriv);
+#endif
+
+ g_fNoConfigureWindow = TRUE;
+ //ShowWindow (pRLWinPriv->hWnd, SW_MINIMIZE);
+ ShowWindow (pRLWinPriv->hWnd, SW_HIDE);
+ g_fNoConfigureWindow = FALSE;
+}
+
+/*
+ * Fixme: Code sharing with winshadgdi.c and other engine support
+ */
+void
+winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+ ScreenPtr pScreen = NULL;
+ DIBSECTION dibsection;
+ Bool fReturn = TRUE;
+ HDC hdcNew;
+ HBITMAP hbmpNew;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMStartDrawing (%08x) %08x\n", (int) pRLWinPriv, pRLWinPriv->fDestroyed);
+#endif
+
+ if (!pRLWinPriv->fDestroyed)
+ {
+ pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tpScreenPriv %08X\n", (int) pScreenPriv);
+ winDebug ("\tpScreenInfo %08X\n", (int) pScreenInfo);
+ winDebug ("\t(%d, %d)\n", (int)pRLWinPriv->pFrame->width,
+ (int) pRLWinPriv->pFrame->height);
+#endif
+ if (pRLWinPriv->hdcScreen == NULL)
+ {
+ InitWin32RootlessEngine (pRLWinPriv);
+ }
+
+ if (pRLWinPriv->fResized)
+ {
+ /* width * bpp must be multiple of 4 to match 32bit alignment */
+ int stridesize;
+ int misalignment;
+
+ pRLWinPriv->pbmihShadow->biWidth = pRLWinPriv->pFrame->width;
+ pRLWinPriv->pbmihShadow->biHeight = -pRLWinPriv->pFrame->height;
+
+ stridesize = pRLWinPriv->pFrame->width * (pScreenInfo->dwBPP >> 3);
+ misalignment = stridesize & 3;
+ if (misalignment != 0)
+ {
+ stridesize += 4 - misalignment;
+ pRLWinPriv->pbmihShadow->biWidth = stridesize / (pScreenInfo->dwBPP >> 3);
+ winDebug("\tresizing to %d (was %d)\n",
+ pRLWinPriv->pbmihShadow->biWidth, pRLWinPriv->pFrame->width);
+ }
+
+ hdcNew = CreateCompatibleDC (pRLWinPriv->hdcScreen);
+ /* Create a DI shadow bitmap with a bit pointer */
+ hbmpNew = CreateDIBSection (pRLWinPriv->hdcScreen,
+ (BITMAPINFO *) pRLWinPriv->pbmihShadow,
+ DIB_RGB_COLORS,
+ (VOID**) &pRLWinPriv->pfb,
+ NULL,
+ 0);
+ if (hbmpNew == NULL || pRLWinPriv->pfb == NULL)
+ {
+ ErrorF ("winMWExtWMStartDrawing - CreateDIBSection failed\n");
+ //return FALSE;
+ }
+ else
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMStartDrawing - Shadow buffer allocated\n");
+#endif
+ }
+
+ /* Get information about the bitmap that was allocated */
+ GetObject (hbmpNew, sizeof (dibsection), &dibsection);
+
+#if CYGMULTIWINDOW_DEBUG
+ /* Print information about bitmap allocated */
+ winDebug ("winMWExtWMStartDrawing - Dibsection width: %d height: %d "
+ "depth: %d size image: %d\n",
+ (unsigned int)dibsection.dsBmih.biWidth,
+ (unsigned int)dibsection.dsBmih.biHeight,
+ (unsigned int)dibsection.dsBmih.biBitCount,
+ (unsigned int)dibsection.dsBmih.biSizeImage);
+#endif
+
+ /* Select the shadow bitmap into the shadow DC */
+ SelectObject (hdcNew, hbmpNew);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMStartDrawing - Attempting a shadow blit\n");
+#endif
+
+ /* Blit from the old shadow to the new shadow */
+ fReturn = BitBlt (hdcNew,
+ 0, 0,
+ pRLWinPriv->pFrame->width, pRLWinPriv->pFrame->height,
+ pRLWinPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+ if (fReturn)
+ {
+ winDebug ("winMWExtWMStartDrawing - Shadow blit success\n");
+ }
+ else
+ {
+ ErrorF ("winMWExtWMStartDrawing - Shadow blit failure\n");
+ }
+
+ /* Look for height weirdness */
+ if (dibsection.dsBmih.biHeight < 0)
+ {
+ /* FIXME: Figure out why biHeight is sometimes negative */
+ ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
+ "biHeight still negative: %d\n",
+ (int) dibsection.dsBmih.biHeight);
+ ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
+ "Flipping biHeight sign\n");
+ dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
+ }
+
+ pRLWinPriv->dwWidthBytes = dibsection.dsBm.bmWidthBytes;
+
+ winDebug ("winMWExtWMStartDrawing - bytesPerRow: %d\n",
+ (unsigned int)dibsection.dsBm.bmWidthBytes);
+
+ /* Free the old shadow bitmap */
+ DeleteObject (pRLWinPriv->hdcShadow);
+ DeleteObject (pRLWinPriv->hbmpShadow);
+
+ pRLWinPriv->hdcShadow = hdcNew;
+ pRLWinPriv->hbmpShadow = hbmpNew;
+
+ pRLWinPriv->fResized = FALSE;
+ winDebug ("winMWExtWMStartDrawing - 0x%08x %d\n",
+ (unsigned int)pRLWinPriv->pfb,
+ (unsigned int)dibsection.dsBm.bmWidthBytes);
+ }
+ }
+ else
+ {
+ ErrorF ("winMWExtWMStartDrawing - Already window was destroyed \n");
+ }
+ winDebug ("winMWExtWMStartDrawing - done (0x%08x) 0x%08x %d\n",
+ (int) pRLWinPriv,
+ (unsigned int)pRLWinPriv->pfb, (unsigned int)pRLWinPriv->dwWidthBytes);
+ *pixelData = pRLWinPriv->pfb;
+ *bytesPerRow = pRLWinPriv->dwWidthBytes;
+}
+
+void
+winMWExtWMStopDrawing (RootlessFrameID wid, Bool fFlush)
+{
+}
+
+void
+winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ if (!g_fNoConfigureWindow) UpdateWindow (pRLWinPriv->hWnd);
+}
+
+void
+winMWExtWMDamageRects (RootlessFrameID wid, int nCount, const BoxRec *pRects,
+ int shift_x, int shift_y)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ const BoxRec *pEnd;
+ winDebug ("winMWExtWMDamageRects (%08x, %d, %08x, %d, %d)\n",
+ pRLWinPriv, nCount, pRects, shift_x, shift_y);
+
+ for (pEnd = pRects + nCount; pRects < pEnd; pRects++) {
+ RECT rcDmg;
+ rcDmg.left = pRects->x1 + shift_x;
+ rcDmg.top = pRects->y1 + shift_y;
+ rcDmg.right = pRects->x2 + shift_x;
+ rcDmg.bottom = pRects->y2 + shift_y;
+
+ InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
+ }
+}
+
+void
+winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
+ winDebug ("winMWExtWMRootlessSwitchWindow (%08x) %08x\n",
+ (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
+ pRLWinPriv->pFrame = pFrame;
+ pRLWinPriv->fResized = TRUE;
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
+
+ /* Set the window standard style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_CLIPCHILDREN);
+
+ DeleteProperty (serverClient, oldWin, AtmWindowsWmNativeHwnd ());
+ winMWExtWMSetNativeProperty (pFrame);
+}
+
+void
+winMWExtWMCopyBytes (unsigned int width, unsigned int height,
+ const void *src, unsigned int srcRowBytes,
+ void *dst, unsigned int dstRowBytes)
+{
+ winDebug ("winMWExtWMCopyBytes - Not implemented\n");
+}
+
+void
+winMWExtWMFillBytes (unsigned int width, unsigned int height, unsigned int value,
+ void *dst, unsigned int dstRowBytes)
+{
+ winDebug ("winMWExtWMFillBytes - Not implemented\n");
+}
+
+int
+winMWExtWMCompositePixels (unsigned int width, unsigned int height, unsigned int function,
+ void *src[2], unsigned int srcRowBytes[2],
+ void *mask, unsigned int maskRowBytes,
+ void *dst[2], unsigned int dstRowBytes[2])
+{
+ winDebug ("winMWExtWMCompositePixels - Not implemented\n");
+ return 0;
+}
+
+
+void
+winMWExtWMCopyWindow (RootlessFrameID wid, int nDstRects, const BoxRec *pDstRects,
+ int nDx, int nDy)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ const BoxRec *pEnd;
+ RECT rcDmg;
+ winDebug ("winMWExtWMCopyWindow (%08x, %d, %08x, %d, %d)\n",
+ (int) pRLWinPriv, nDstRects, (int) pDstRects, nDx, nDy);
+
+ for (pEnd = pDstRects + nDstRects; pDstRects < pEnd; pDstRects++)
+ {
+ winDebug ("BitBlt (%d, %d, %d, %d) (%d, %d)\n",
+ pDstRects->x1, pDstRects->y1,
+ pDstRects->x2 - pDstRects->x1,
+ pDstRects->y2 - pDstRects->y1,
+ pDstRects->x1 + nDx,
+ pDstRects->y1 + nDy);
+
+ if (!BitBlt (pRLWinPriv->hdcShadow,
+ pDstRects->x1, pDstRects->y1,
+ pDstRects->x2 - pDstRects->x1,
+ pDstRects->y2 - pDstRects->y1,
+ pRLWinPriv->hdcShadow,
+ pDstRects->x1 + nDx, pDstRects->y1 + nDy,
+ SRCCOPY))
+ {
+ ErrorF ("winMWExtWMCopyWindow - BitBlt failed.\n");
+ }
+
+ rcDmg.left = pDstRects->x1;
+ rcDmg.top = pDstRects->y1;
+ rcDmg.right = pDstRects->x2;
+ rcDmg.bottom = pDstRects->y2;
+
+ InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
+ }
+ winDebug ("winMWExtWMCopyWindow - done\n");
+}
+
+
+/*
+ * winMWExtWMSetNativeProperty
+ */
+
+static void
+winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
+ long lData;
+
+ /* FIXME: move this to WindowsWM extension */
+
+ lData = (long) pRLWinPriv->hWnd;
+ dixChangeWindowProperty(serverClient, pFrame->win, AtmWindowsWmNativeHwnd(),
+ XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE);
+}
diff --git a/xorg-server/hw/xwin/winwin32rootlesswindow.c b/xorg-server/hw/xwin/winwin32rootlesswindow.c index 3a49ead69..60e1f8bea 100644 --- a/xorg-server/hw/xwin/winwin32rootlesswindow.c +++ b/xorg-server/hw/xwin/winwin32rootlesswindow.c @@ -1,476 +1,476 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Kensuke Matsuzaki - * Earle F. Philhower, III - * Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include "winprefs.h" - -#if 0 -/* - * winMWExtWMReorderWindows - */ - -void -winMWExtWMReorderWindows (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - HWND hwnd = NULL; - win32RootlessWindowPtr pRLWin = NULL; - win32RootlessWindowPtr pRLWinSib = NULL; - DWORD dwCurrentProcessID = GetCurrentProcessId (); - DWORD dwWindowProcessID = 0; - XID vlist[2]; - -#if CYGMULTIWINDOW_DEBUG && FALSE - winDebug ("winMWExtWMReorderWindows\n"); -#endif - - pScreenPriv->fRestacking = TRUE; - - if (pScreenPriv->fWindowOrderChanged) - { -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMReorderWindows - Need to restack\n"); -#endif - hwnd = GetTopWindow (NULL); - - while (hwnd) - { - GetWindowThreadProcessId (hwnd, &dwWindowProcessID); - - if ((dwWindowProcessID == dwCurrentProcessID) - && GetProp (hwnd, WIN_WINDOW_PROP)) - { - pRLWinSib = pRLWin; - pRLWin = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP); - - if (pRLWinSib) - { - vlist[0] = pRLWinSib->pFrame->win->drawable.id; - vlist[1] = Below; - - ConfigureWindow (pRLWin->pFrame->win, CWSibling | CWStackMode, - vlist, wClient(pRLWin->pFrame->win)); - } - else - { - /* 1st window - raise to the top */ - vlist[0] = Above; - - ConfigureWindow (pRLWin->pFrame->win, CWStackMode, - vlist, wClient(pRLWin->pFrame->win)); - } - } - hwnd = GetNextWindow (hwnd, GW_HWNDNEXT); - } - } - - pScreenPriv->fRestacking = FALSE; - pScreenPriv->fWindowOrderChanged = FALSE; -} -#endif - - -/* - * winMWExtWMMoveXWindow - */ - -void -winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y) -{ - CARD32 *vlist = malloc(sizeof(CARD32)*2); - - vlist[0] = x; - vlist[1] = y; - ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin)); - free(vlist); -} - - -/* - * winMWExtWMResizeXWindow - */ - -void -winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h) -{ - CARD32 *vlist = malloc(sizeof(CARD32)*2); - - vlist[0] = w; - vlist[1] = h; - ConfigureWindow (pWin, CWWidth | CWHeight, vlist, wClient(pWin)); - free(vlist); -} - - -/* - * winMWExtWMMoveResizeXWindow - */ - -void -winMWExtWMMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h) -{ - CARD32 *vlist = malloc(sizeof(long)*4); - - vlist[0] = x; - vlist[1] = y; - vlist[2] = w; - vlist[3] = h; - - ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight, vlist, wClient(pWin)); - free(vlist); -} - - -/* - * winMWExtWMUpdateIcon - * Change the Windows window icon - */ - -void -winMWExtWMUpdateIcon (Window id) -{ - WindowPtr pWin; - HICON hIcon, hiconOld; - - dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess); - hIcon = winOverrideIcon ((unsigned long)pWin); - - if (!hIcon) - hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON)); - - if (hIcon) - { - win32RootlessWindowPtr pRLWinPriv - = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE); - - if (pRLWinPriv->hWnd) - { - - hiconOld = (HICON) SendMessage (pRLWinPriv->hWnd, - WM_SETICON, ICON_BIG, (LPARAM) hIcon); - winDestroyIcon(hiconOld); - } - hIcon=NULL; - } -} - - -/* - * winMWExtWMDecorateWindow - Update window style. Called by EnumWindows. - */ - -wBOOL CALLBACK -winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam) -{ - win32RootlessWindowPtr pRLWinPriv = NULL; - ScreenPtr pScreen = NULL; - winPrivScreenPtr pScreenPriv = NULL; - winScreenInfo *pScreenInfo = NULL; - - /* Check if the Windows window property for our X window pointer is valid */ - if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL) - { - pScreen = pRLWinPriv->pFrame->win->drawable.pScreen; - if (pScreen) pScreenPriv = winGetScreenPriv(pScreen); - if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo; - if (pRLWinPriv && pScreenInfo) winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo); - } - return TRUE; -} - - -/* - * winMWExtWMUpdateWindowDecoration - Update window style. - */ - -void -winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv, - winScreenInfoPtr pScreenInfo) -{ - Bool fDecorate = FALSE; - DWORD dwExStyle = 0; - DWORD dwStyle = 0; - WINDOWPLACEMENT wndPlace; - UINT showCmd = 0; - - wndPlace.length = sizeof (WINDOWPLACEMENT); - - /* Get current window placement */ - GetWindowPlacement (pRLWinPriv->hWnd, &wndPlace); - - if (winIsInternalWMRunning(pScreenInfo)) - { - if (!pRLWinPriv->pFrame->win->overrideRedirect) - fDecorate = TRUE; - } -#if 0 - if (wndPlace.showCmd == SW_HIDE) - return;//showCmd = SWP_HIDEWINDOW; - else - showCmd = SWP_SHOWWINDOW; -#else - if (wndPlace.showCmd == SW_HIDE) - return; - - if (IsWindowVisible (pRLWinPriv->hWnd)) - showCmd = SWP_SHOWWINDOW; -#endif - - showCmd |= SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER; - - winDebug ("winMWExtWMUpdateWindowDecoration %08x %s\n", - (int)pRLWinPriv, fDecorate?"Decorate":"Bare"); - - /* Get the standard and extended window style information */ - dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE); - dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE); - - if (fDecorate) - { - RECT rcNew; - int iDx, iDy; - winWMMessageRec wmMsg; - winScreenPriv(pScreenInfo->pScreen); - - /* */ - if (!(dwExStyle & WS_EX_APPWINDOW)) - { - winDebug ("\tBare=>Decorate\n"); - /* Setup a rectangle with the X window position and size */ - SetRect (&rcNew, - pRLWinPriv->pFrame->x, - pRLWinPriv->pFrame->y, - pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width, - pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height); - -#ifdef CYGMULTIWINDOW_DEBUG - winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top); -#endif - /* */ - AdjustWindowRectEx (&rcNew, - WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW, - FALSE, - WS_EX_APPWINDOW); - -#ifdef CYGMULTIWINDOW_DEBUG - winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top); -#endif - /* Calculate position deltas */ - iDx = pRLWinPriv->pFrame->x - rcNew.left; - iDy = pRLWinPriv->pFrame->y - rcNew.top; - - /* Calculate new rectangle */ - rcNew.left += iDx; - rcNew.right += iDx; - rcNew.top += iDy; - rcNew.bottom += iDy; - - /* Set the window extended style flags */ - SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW); - - /* Set the window standard style flags */ - SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE, - WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW); - -#ifdef CYGMULTIWINDOW_DEBUG - winDebug("\tWindowStyle: %08x %08x\n", - WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW, - WS_EX_APPWINDOW); -#endif - /* Position the Windows window */ -#ifdef CYGMULTIWINDOW_DEBUG - winDebug("\tMoved {%d, %d, %d, %d}, {%d, %d}\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top); -#endif - SetWindowPos (pRLWinPriv->hWnd, NULL, - rcNew.left, rcNew.top, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, - showCmd); - - - wmMsg.hwndWindow = pRLWinPriv->hWnd; - wmMsg.iWindow = (Window)pRLWinPriv->pFrame->win->drawable.id; - wmMsg.msg = WM_WM_NAME_EVENT; - winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg); - - winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv , - wBoundingShape(pRLWinPriv->pFrame->win)); - } - } - else - { - RECT rcNew; - - /* */ - if (dwExStyle & WS_EX_APPWINDOW) - { - winDebug ("\tDecorate=>Bare\n"); - /* Setup a rectangle with the X window position and size */ - SetRect (&rcNew, - pRLWinPriv->pFrame->x, - pRLWinPriv->pFrame->y, - pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width, - pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height); -#if 0 - /* */ - AdjustWindowRectEx (&rcNew, - WS_POPUP | WS_CLIPCHILDREN, - FALSE, - WS_EX_TOOLWINDOW); - - /* Calculate position deltas */ - iDx = pRLWinPriv->pFrame->x - rcNew.left; - iDy = pRLWinPriv->pFrame->y - rcNew.top; - - /* Calculate new rectangle */ - rcNew.left += iDx; - rcNew.right += iDx; - rcNew.top += iDy; - rcNew.bottom += iDy; -#endif - - /* Hide window temporary to remove from taskbar. */ - ShowWindow( pRLWinPriv->hWnd, SW_HIDE ); - - /* Set the window extended style flags */ - SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW); - - /* Set the window standard style flags */ - SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE, - WS_POPUP | WS_CLIPCHILDREN); - - /* Position the Windows window */ - SetWindowPos (pRLWinPriv->hWnd, NULL, - rcNew.left, rcNew.top, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, - showCmd); - - winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv , - wBoundingShape(pRLWinPriv->pFrame->win)); - } - } -} - - -/* - * winIsInternalWMRunning (winScreenInfoPtr pScreenInfo) - */ -Bool -winIsInternalWMRunning (winScreenInfoPtr pScreenInfo) -{ - return pScreenInfo->fInternalWM && !pScreenInfo->fAnotherWMRunning; -} - - -/* - * winMWExtWMRestackWindows - */ - -void -winMWExtWMRestackWindows (ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - WindowPtr pRoot = WindowTable[pScreen->myNum]; - WindowPtr pWin = NULL; - WindowPtr pWinPrev = NULL; - win32RootlessWindowPtr pRLWin = NULL; - win32RootlessWindowPtr pRLWinPrev = NULL; - int nWindow = 0; - HDWP hWinPosInfo = NULL; - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMRestackWindows\n"); -#endif - - pScreenPriv->fRestacking = TRUE; - - if (pRoot != NULL) - { - for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) - nWindow ++; - - hWinPosInfo = BeginDeferWindowPos(nWindow); - - for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) - { - if (pWin->realized) - { - UINT uFlags; - - pRLWin = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE); - if (pRLWin == NULL) continue; - - if (pWinPrev) - pRLWinPrev = (win32RootlessWindowPtr) RootlessFrameForWindow (pWinPrev, FALSE); - - uFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW; - if (pRLWinPrev != NULL) uFlags |= SWP_NOACTIVATE; - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMRestackWindows - DeferWindowPos (%08x, %08x)\n", - pRLWin->hWnd, - pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP); -#endif - hWinPosInfo = DeferWindowPos (hWinPosInfo, pRLWin->hWnd, - pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP, - 0, 0, 0, 0, - uFlags); - if (hWinPosInfo == NULL) - { - ErrorF ("winMWExtWMRestackWindows - DeferWindowPos () failed: %d\n", - (int) GetLastError ()); - return; - } - pWinPrev = pWin; - } - } - if (!EndDeferWindowPos (hWinPosInfo)) - { - ErrorF ("winMWExtWMRestackWindows - EndDeferWindowPos () failed: %d\n", - (int) GetLastError ()); - return; - } - } - -#if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMRestackWindows - done\n"); -#endif - pScreenPriv->fRestacking = FALSE; -} +/*
+ *Copyright (C) 1994-2000 The XFree86 Project, 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 XFREE86 PROJECT 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 of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Earle F. Philhower, III
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winprefs.h"
+
+#if 0
+/*
+ * winMWExtWMReorderWindows
+ */
+
+void
+winMWExtWMReorderWindows (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ HWND hwnd = NULL;
+ win32RootlessWindowPtr pRLWin = NULL;
+ win32RootlessWindowPtr pRLWinSib = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+ XID vlist[2];
+
+#if CYGMULTIWINDOW_DEBUG && FALSE
+ winDebug ("winMWExtWMReorderWindows\n");
+#endif
+
+ pScreenPriv->fRestacking = TRUE;
+
+ if (pScreenPriv->fWindowOrderChanged)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMReorderWindows - Need to restack\n");
+#endif
+ hwnd = GetTopWindow (NULL);
+
+ while (hwnd)
+ {
+ GetWindowThreadProcessId (hwnd, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hwnd, WIN_WINDOW_PROP))
+ {
+ pRLWinSib = pRLWin;
+ pRLWin = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP);
+
+ if (pRLWinSib)
+ {
+ vlist[0] = pRLWinSib->pFrame->win->drawable.id;
+ vlist[1] = Below;
+
+ ConfigureWindow (pRLWin->pFrame->win, CWSibling | CWStackMode,
+ vlist, wClient(pRLWin->pFrame->win));
+ }
+ else
+ {
+ /* 1st window - raise to the top */
+ vlist[0] = Above;
+
+ ConfigureWindow (pRLWin->pFrame->win, CWStackMode,
+ vlist, wClient(pRLWin->pFrame->win));
+ }
+ }
+ hwnd = GetNextWindow (hwnd, GW_HWNDNEXT);
+ }
+ }
+
+ pScreenPriv->fRestacking = FALSE;
+ pScreenPriv->fWindowOrderChanged = FALSE;
+}
+#endif
+
+
+/*
+ * winMWExtWMMoveXWindow
+ */
+
+void
+winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y)
+{
+ CARD32 *vlist = malloc(sizeof(CARD32)*2);
+
+ vlist[0] = x;
+ vlist[1] = y;
+ ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin));
+ free(vlist);
+}
+
+
+/*
+ * winMWExtWMResizeXWindow
+ */
+
+void
+winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h)
+{
+ CARD32 *vlist = malloc(sizeof(CARD32)*2);
+
+ vlist[0] = w;
+ vlist[1] = h;
+ ConfigureWindow (pWin, CWWidth | CWHeight, vlist, wClient(pWin));
+ free(vlist);
+}
+
+
+/*
+ * winMWExtWMMoveResizeXWindow
+ */
+
+void
+winMWExtWMMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h)
+{
+ CARD32 *vlist = malloc(sizeof(long)*4);
+
+ vlist[0] = x;
+ vlist[1] = y;
+ vlist[2] = w;
+ vlist[3] = h;
+
+ ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight, vlist, wClient(pWin));
+ free(vlist);
+}
+
+
+/*
+ * winMWExtWMUpdateIcon
+ * Change the Windows window icon
+ */
+
+void
+winMWExtWMUpdateIcon (Window id)
+{
+ WindowPtr pWin;
+ HICON hIcon, hiconOld;
+
+ dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess);
+ hIcon = winOverrideIcon ((unsigned long)pWin);
+
+ if (!hIcon)
+ hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
+
+ if (hIcon)
+ {
+ win32RootlessWindowPtr pRLWinPriv
+ = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+
+ if (pRLWinPriv->hWnd)
+ {
+
+ hiconOld = (HICON) SendMessage (pRLWinPriv->hWnd,
+ WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+ winDestroyIcon(hiconOld);
+ }
+ hIcon=NULL;
+ }
+}
+
+
+/*
+ * winMWExtWMDecorateWindow - Update window style. Called by EnumWindows.
+ */
+
+wBOOL CALLBACK
+winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam)
+{
+ win32RootlessWindowPtr pRLWinPriv = NULL;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+ if (pRLWinPriv && pScreenInfo) winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
+ }
+ return TRUE;
+}
+
+
+/*
+ * winMWExtWMUpdateWindowDecoration - Update window style.
+ */
+
+void
+winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
+ winScreenInfoPtr pScreenInfo)
+{
+ Bool fDecorate = FALSE;
+ DWORD dwExStyle = 0;
+ DWORD dwStyle = 0;
+ WINDOWPLACEMENT wndPlace;
+ UINT showCmd = 0;
+
+ wndPlace.length = sizeof (WINDOWPLACEMENT);
+
+ /* Get current window placement */
+ GetWindowPlacement (pRLWinPriv->hWnd, &wndPlace);
+
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ if (!pRLWinPriv->pFrame->win->overrideRedirect)
+ fDecorate = TRUE;
+ }
+#if 0
+ if (wndPlace.showCmd == SW_HIDE)
+ return;//showCmd = SWP_HIDEWINDOW;
+ else
+ showCmd = SWP_SHOWWINDOW;
+#else
+ if (wndPlace.showCmd == SW_HIDE)
+ return;
+
+ if (IsWindowVisible (pRLWinPriv->hWnd))
+ showCmd = SWP_SHOWWINDOW;
+#endif
+
+ showCmd |= SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER;
+
+ winDebug ("winMWExtWMUpdateWindowDecoration %08x %s\n",
+ (int)pRLWinPriv, fDecorate?"Decorate":"Bare");
+
+ /* Get the standard and extended window style information */
+ dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
+
+ if (fDecorate)
+ {
+ RECT rcNew;
+ int iDx, iDy;
+ winWMMessageRec wmMsg;
+ winScreenPriv(pScreenInfo->pScreen);
+
+ /* */
+ if (!(dwExStyle & WS_EX_APPWINDOW))
+ {
+ winDebug ("\tBare=>Decorate\n");
+ /* Setup a rectangle with the X window position and size */
+ SetRect (&rcNew,
+ pRLWinPriv->pFrame->x,
+ pRLWinPriv->pFrame->y,
+ pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
+ pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
+
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
+ /* */
+ AdjustWindowRectEx (&rcNew,
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
+ FALSE,
+ WS_EX_APPWINDOW);
+
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
+ /* Calculate position deltas */
+ iDx = pRLWinPriv->pFrame->x - rcNew.left;
+ iDy = pRLWinPriv->pFrame->y - rcNew.top;
+
+ /* Calculate new rectangle */
+ rcNew.left += iDx;
+ rcNew.right += iDx;
+ rcNew.top += iDy;
+ rcNew.bottom += iDy;
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
+
+ /* Set the window standard style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW);
+
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tWindowStyle: %08x %08x\n",
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
+ WS_EX_APPWINDOW);
+#endif
+ /* Position the Windows window */
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tMoved {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
+ SetWindowPos (pRLWinPriv->hWnd, NULL,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ showCmd);
+
+
+ wmMsg.hwndWindow = pRLWinPriv->hWnd;
+ wmMsg.iWindow = (Window)pRLWinPriv->pFrame->win->drawable.id;
+ wmMsg.msg = WM_WM_NAME_EVENT;
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+
+ winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv ,
+ wBoundingShape(pRLWinPriv->pFrame->win));
+ }
+ }
+ else
+ {
+ RECT rcNew;
+
+ /* */
+ if (dwExStyle & WS_EX_APPWINDOW)
+ {
+ winDebug ("\tDecorate=>Bare\n");
+ /* Setup a rectangle with the X window position and size */
+ SetRect (&rcNew,
+ pRLWinPriv->pFrame->x,
+ pRLWinPriv->pFrame->y,
+ pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
+ pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
+#if 0
+ /* */
+ AdjustWindowRectEx (&rcNew,
+ WS_POPUP | WS_CLIPCHILDREN,
+ FALSE,
+ WS_EX_TOOLWINDOW);
+
+ /* Calculate position deltas */
+ iDx = pRLWinPriv->pFrame->x - rcNew.left;
+ iDy = pRLWinPriv->pFrame->y - rcNew.top;
+
+ /* Calculate new rectangle */
+ rcNew.left += iDx;
+ rcNew.right += iDx;
+ rcNew.top += iDy;
+ rcNew.bottom += iDy;
+#endif
+
+ /* Hide window temporary to remove from taskbar. */
+ ShowWindow( pRLWinPriv->hWnd, SW_HIDE );
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
+
+ /* Set the window standard style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_CLIPCHILDREN);
+
+ /* Position the Windows window */
+ SetWindowPos (pRLWinPriv->hWnd, NULL,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ showCmd);
+
+ winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv ,
+ wBoundingShape(pRLWinPriv->pFrame->win));
+ }
+ }
+}
+
+
+/*
+ * winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
+ */
+Bool
+winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
+{
+ return pScreenInfo->fInternalWM && !pScreenInfo->fAnotherWMRunning;
+}
+
+
+/*
+ * winMWExtWMRestackWindows
+ */
+
+void
+winMWExtWMRestackWindows (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ WindowPtr pRoot = pScreen->root;
+ WindowPtr pWin = NULL;
+ WindowPtr pWinPrev = NULL;
+ win32RootlessWindowPtr pRLWin = NULL;
+ win32RootlessWindowPtr pRLWinPrev = NULL;
+ int nWindow = 0;
+ HDWP hWinPosInfo = NULL;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackWindows\n");
+#endif
+
+ pScreenPriv->fRestacking = TRUE;
+
+ if (pRoot != NULL)
+ {
+ for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
+ nWindow ++;
+
+ hWinPosInfo = BeginDeferWindowPos(nWindow);
+
+ for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
+ {
+ if (pWin->realized)
+ {
+ UINT uFlags;
+
+ pRLWin = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+ if (pRLWin == NULL) continue;
+
+ if (pWinPrev)
+ pRLWinPrev = (win32RootlessWindowPtr) RootlessFrameForWindow (pWinPrev, FALSE);
+
+ uFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW;
+ if (pRLWinPrev != NULL) uFlags |= SWP_NOACTIVATE;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackWindows - DeferWindowPos (%08x, %08x)\n",
+ pRLWin->hWnd,
+ pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP);
+#endif
+ hWinPosInfo = DeferWindowPos (hWinPosInfo, pRLWin->hWnd,
+ pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP,
+ 0, 0, 0, 0,
+ uFlags);
+ if (hWinPosInfo == NULL)
+ {
+ ErrorF ("winMWExtWMRestackWindows - DeferWindowPos () failed: %d\n",
+ (int) GetLastError ());
+ return;
+ }
+ pWinPrev = pWin;
+ }
+ }
+ if (!EndDeferWindowPos (hWinPosInfo))
+ {
+ ErrorF ("winMWExtWMRestackWindows - EndDeferWindowPos () failed: %d\n",
+ (int) GetLastError ());
+ return;
+ }
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackWindows - done\n");
+#endif
+ pScreenPriv->fRestacking = FALSE;
+}
diff --git a/xorg-server/hw/xwin/winwindow.c b/xorg-server/hw/xwin/winwindow.c index 8156671cd..117a04b00 100644 --- a/xorg-server/hw/xwin/winwindow.c +++ b/xorg-server/hw/xwin/winwindow.c @@ -135,25 +135,25 @@ winCopyWindowNativeGDI (WindowPtr pWin, winScreenPriv(pScreen);
/* Get a pointer to the root window */
- pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+ pwinRoot = pWin->drawable.pScreen->root;
/* Create a region for the destination */
- prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+ prgnDst = RegionCreate(NULL, 1);
/* Calculate the shift from the source to the destination */
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
/* Translate the region from the destination to the source? */
- REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
- REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip,
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionIntersect(prgnDst, &pWin->borderClip,
prgnSrc);
/* Get a pointer to the first box in the region to be copied */
- pBox = REGION_RECTS(prgnDst);
+ pBox = RegionRects(prgnDst);
/* Get the number of boxes in the region */
- nbox = REGION_NUM_RECTS(prgnDst);
+ nbox = RegionNumRects(prgnDst);
/* Allocate source points for each box */
if(!(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec))))
@@ -170,7 +170,7 @@ winCopyWindowNativeGDI (WindowPtr pWin, }
/* Setup loop pointers again */
- pBoxDst = REGION_RECTS(prgnDst);
+ pBoxDst = RegionRects(prgnDst);
ppt = pptSrc;
/* BitBlt each source to the destination point */
@@ -186,7 +186,7 @@ winCopyWindowNativeGDI (WindowPtr pWin, /* Cleanup the regions, etc. */
free(pptSrc);
- REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
+ RegionDestroy(prgnDst);
}
@@ -413,15 +413,15 @@ winMapWindowRootless (WindowPtr pWin) void
-winSetShapeRootless (WindowPtr pWin)
+winSetShapeRootless (WindowPtr pWin, int kind)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
winScreenPriv(pScreen);
- winDebug ("winSetShapeRootless (%p)\n", pWin);
+ winDebug ("winSetShapeRootless (%p, %i)\n", pWin, kind);
WIN_UNWRAP(SetShape);
- (*pScreen->SetShape)(pWin);
+ (*pScreen->SetShape)(pWin, kind);
WIN_WRAP(SetShape, winSetShapeRootless);
winReshapeRootless (pWin);
@@ -522,7 +522,6 @@ void winReshapeRootless (WindowPtr pWin)
{
int nRects;
- /* ScreenPtr pScreen = pWin->drawable.pScreen;*/
RegionRec rrNewShape;
BoxPtr pShape, pRects, pEnd;
HRGN hRgn, hRgnRect;
@@ -549,13 +548,13 @@ winReshapeRootless (WindowPtr pWin) if (!wBoundingShape (pWin))
return;
- REGION_NULL(pScreen, &rrNewShape);
- REGION_COPY(pScreen, &rrNewShape, wBoundingShape(pWin));
- REGION_TRANSLATE(pScreen, &rrNewShape, pWin->borderWidth,
+ RegionNull(&rrNewShape);
+ RegionCopy(&rrNewShape, wBoundingShape(pWin));
+ RegionTranslate(&rrNewShape, pWin->borderWidth,
pWin->borderWidth);
- nRects = REGION_NUM_RECTS(&rrNewShape);
- pShape = REGION_RECTS(&rrNewShape);
+ nRects = RegionNumRects(&rrNewShape);
+ pShape = RegionRects(&rrNewShape);
if (nRects > 0)
{
@@ -587,7 +586,7 @@ winReshapeRootless (WindowPtr pWin) pWinPriv->hRgn = hRgn;
}
- REGION_UNINIT(pScreen, &rrNewShape);
+ RegionUninit(&rrNewShape);
return;
}
diff --git a/xorg-server/hw/xwin/winwindowswm.c b/xorg-server/hw/xwin/winwindowswm.c index c8f2a7073..0d262c1ea 100644 --- a/xorg-server/hw/xwin/winwindowswm.c +++ b/xorg-server/hw/xwin/winwindowswm.c @@ -414,7 +414,6 @@ ProcWindowsWMFrameDraw (register ClientPtr client) RECT rcNew;
int nCmdShow, rc;
RegionRec newShape;
- ScreenPtr pScreen;
REQUEST_SIZE_MATCH (xWindowsWMFrameDrawReq);
@@ -476,15 +475,14 @@ ProcWindowsWMFrameDraw (register ClientPtr client) if (wBoundingShape(pWin) != NULL)
{
- pScreen = pWin->drawable.pScreen;
/* wBoundingShape is relative to *inner* origin of window.
Translate by borderWidth to get the outside-relative position. */
- REGION_NULL(pScreen, &newShape);
- REGION_COPY(pScreen, &newShape, wBoundingShape(pWin));
- REGION_TRANSLATE(pScreen, &newShape, pWin->borderWidth, pWin->borderWidth);
+ RegionNull(&newShape);
+ RegionCopy(&newShape, wBoundingShape(pWin));
+ RegionTranslate(&newShape, pWin->borderWidth, pWin->borderWidth);
winMWExtWMReshapeFrame (pRLWinPriv, &newShape);
- REGION_UNINIT(pScreen, &newShape);
+ RegionUninit(&newShape);
}
winDebug ("ProcWindowsWMFrameDraw - done\n");
diff --git a/xorg-server/include/cursor.h b/xorg-server/include/cursor.h index dadedfd1d..39d829769 100644 --- a/xorg-server/include/cursor.h +++ b/xorg-server/include/cursor.h @@ -1,139 +1,140 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - -#ifndef CURSOR_H -#define CURSOR_H - -#include "misc.h" -#include "screenint.h" -#include "window.h" - -#define NullCursor ((CursorPtr)NULL) - -/* Provide support for alpha composited cursors */ -#define ARGB_CURSOR - -struct _DeviceIntRec; - -typedef struct _Cursor *CursorPtr; -typedef struct _CursorMetric *CursorMetricPtr; - -extern _X_EXPORT int cursorScreenDevPriv[MAXSCREENS]; -#define CursorScreenKey(pScreen) (cursorScreenDevPriv + (pScreen)->myNum) - -extern _X_EXPORT CursorPtr rootCursor; - -extern _X_EXPORT int FreeCursor( - pointer /*pCurs*/, - XID /*cid*/); - -extern _X_EXPORT int AllocARGBCursor( - unsigned char* /*psrcbits*/, - unsigned char* /*pmaskbits*/, - CARD32* /*argb*/, - CursorMetricPtr /*cm*/, - unsigned /*foreRed*/, - unsigned /*foreGreen*/, - unsigned /*foreBlue*/, - unsigned /*backRed*/, - unsigned /*backGreen*/, - unsigned /*backBlue*/, - CursorPtr* /*ppCurs*/, - ClientPtr /*client*/, - XID /*cid*/); - -extern _X_EXPORT int AllocGlyphCursor( - Font /*source*/, - unsigned int /*sourceChar*/, - Font /*mask*/, - unsigned int /*maskChar*/, - unsigned /*foreRed*/, - unsigned /*foreGreen*/, - unsigned /*foreBlue*/, - unsigned /*backRed*/, - unsigned /*backGreen*/, - unsigned /*backBlue*/, - CursorPtr* /*ppCurs*/, - ClientPtr /*client*/, - XID /*cid*/); - -extern _X_EXPORT CursorPtr CreateRootCursor( - char* /*pfilename*/, - unsigned int /*glyph*/); - -extern _X_EXPORT int ServerBitsFromGlyph( - FontPtr /*pfont*/, - unsigned int /*ch*/, - CursorMetricPtr /*cm*/, - unsigned char ** /*ppbits*/); - -extern _X_EXPORT Bool CursorMetricsFromGlyph( - FontPtr /*pfont*/, - unsigned /*ch*/, - CursorMetricPtr /*cm*/); - -extern _X_EXPORT void CheckCursorConfinement( - WindowPtr /*pWin*/); - -extern _X_EXPORT void NewCurrentScreen( - struct _DeviceIntRec* /*pDev*/, - ScreenPtr /*newScreen*/, - int /*x*/, - int /*y*/); - -extern _X_EXPORT Bool PointerConfinedToScreen(struct _DeviceIntRec* /* pDev */); - -extern _X_EXPORT void GetSpritePosition( - struct _DeviceIntRec* /* pDev */, - int * /*px*/, - int * /*py*/); - -#ifdef PANORAMIX -extern _X_EXPORT int XineramaGetCursorScreen(struct _DeviceIntRec* pDev); -#endif /* PANORAMIX */ - -#endif /* CURSOR_H */ +/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef CURSOR_H
+#define CURSOR_H
+
+#include "misc.h"
+#include "screenint.h"
+#include "window.h"
+#include "privates.h"
+
+#define NullCursor ((CursorPtr)NULL)
+
+/* Provide support for alpha composited cursors */
+#define ARGB_CURSOR
+
+struct _DeviceIntRec;
+
+typedef struct _Cursor *CursorPtr;
+typedef struct _CursorMetric *CursorMetricPtr;
+
+extern _X_EXPORT DevPrivateKeyRec cursorScreenDevPriv[MAXSCREENS];
+#define CursorScreenKey(pScreen) (cursorScreenDevPriv + (pScreen)->myNum)
+
+extern _X_EXPORT CursorPtr rootCursor;
+
+extern _X_EXPORT int FreeCursor(
+ pointer /*pCurs*/,
+ XID /*cid*/);
+
+extern _X_EXPORT int AllocARGBCursor(
+ unsigned char* /*psrcbits*/,
+ unsigned char* /*pmaskbits*/,
+ CARD32* /*argb*/,
+ CursorMetricPtr /*cm*/,
+ unsigned /*foreRed*/,
+ unsigned /*foreGreen*/,
+ unsigned /*foreBlue*/,
+ unsigned /*backRed*/,
+ unsigned /*backGreen*/,
+ unsigned /*backBlue*/,
+ CursorPtr* /*ppCurs*/,
+ ClientPtr /*client*/,
+ XID /*cid*/);
+
+extern _X_EXPORT int AllocGlyphCursor(
+ Font /*source*/,
+ unsigned int /*sourceChar*/,
+ Font /*mask*/,
+ unsigned int /*maskChar*/,
+ unsigned /*foreRed*/,
+ unsigned /*foreGreen*/,
+ unsigned /*foreBlue*/,
+ unsigned /*backRed*/,
+ unsigned /*backGreen*/,
+ unsigned /*backBlue*/,
+ CursorPtr* /*ppCurs*/,
+ ClientPtr /*client*/,
+ XID /*cid*/);
+
+extern _X_EXPORT CursorPtr CreateRootCursor(
+ char* /*pfilename*/,
+ unsigned int /*glyph*/);
+
+extern _X_EXPORT int ServerBitsFromGlyph(
+ FontPtr /*pfont*/,
+ unsigned int /*ch*/,
+ CursorMetricPtr /*cm*/,
+ unsigned char ** /*ppbits*/);
+
+extern _X_EXPORT Bool CursorMetricsFromGlyph(
+ FontPtr /*pfont*/,
+ unsigned /*ch*/,
+ CursorMetricPtr /*cm*/);
+
+extern _X_EXPORT void CheckCursorConfinement(
+ WindowPtr /*pWin*/);
+
+extern _X_EXPORT void NewCurrentScreen(
+ struct _DeviceIntRec* /*pDev*/,
+ ScreenPtr /*newScreen*/,
+ int /*x*/,
+ int /*y*/);
+
+extern _X_EXPORT Bool PointerConfinedToScreen(struct _DeviceIntRec* /* pDev */);
+
+extern _X_EXPORT void GetSpritePosition(
+ struct _DeviceIntRec* /* pDev */,
+ int * /*px*/,
+ int * /*py*/);
+
+#ifdef PANORAMIX
+extern _X_EXPORT int XineramaGetCursorScreen(struct _DeviceIntRec* pDev);
+#endif /* PANORAMIX */
+
+#endif /* CURSOR_H */
diff --git a/xorg-server/include/cursorstr.h b/xorg-server/include/cursorstr.h index 3ff56e2bf..b082cb911 100644 --- a/xorg-server/include/cursorstr.h +++ b/xorg-server/include/cursorstr.h @@ -1,95 +1,99 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - -#ifndef CURSORSTRUCT_H -#define CURSORSTRUCT_H - -#include "cursor.h" -#include "privates.h" -/* - * device-independent cursor storage - */ - -/* - * source and mask point directly to the bits, which are in the server-defined - * bitmap format. - */ -typedef struct _CursorBits { - unsigned char *source; /* points to bits */ - unsigned char *mask; /* points to bits */ - Bool emptyMask; /* all zeros mask */ - unsigned short width, height, xhot, yhot; /* metrics */ - int refcnt; /* can be shared */ - PrivateRec *devPrivates; /* set by pScr->RealizeCursor*/ -#ifdef ARGB_CURSOR - CARD32 *argb; /* full-color alpha blended */ -#endif -} CursorBits, *CursorBitsPtr; - -typedef struct _Cursor { - CursorBitsPtr bits; - unsigned short foreRed, foreGreen, foreBlue; /* device-independent color */ - unsigned short backRed, backGreen, backBlue; /* device-independent color */ - int refcnt; - PrivateRec *devPrivates; /* set by pScr->RealizeCursor*/ - XID id; -#ifdef XFIXES - CARD32 serialNumber; - Atom name; -#endif -} CursorRec; - -typedef struct _CursorMetric { - unsigned short width, height, xhot, yhot; -} CursorMetricRec; - -typedef struct { - int x, y; - ScreenPtr pScreen; -} HotSpot; - -#endif /* CURSORSTRUCT_H */ +/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef CURSORSTRUCT_H
+#define CURSORSTRUCT_H
+
+#include "cursor.h"
+#include "privates.h"
+/*
+ * device-independent cursor storage
+ */
+
+/*
+ * source and mask point directly to the bits, which are in the server-defined
+ * bitmap format.
+ */
+typedef struct _CursorBits {
+ unsigned char *source; /* points to bits */
+ unsigned char *mask; /* points to bits */
+ Bool emptyMask; /* all zeros mask */
+ unsigned short width, height, xhot, yhot; /* metrics */
+ int refcnt; /* can be shared */
+ PrivateRec *devPrivates; /* set by pScr->RealizeCursor*/
+#ifdef ARGB_CURSOR
+ CARD32 *argb; /* full-color alpha blended */
+#endif
+} CursorBits, *CursorBitsPtr;
+
+#define CURSOR_BITS_SIZE (sizeof(CursorBits) + dixPrivatesSize(PRIVATE_CURSOR_BITS))
+
+typedef struct _Cursor {
+ CursorBitsPtr bits;
+ unsigned short foreRed, foreGreen, foreBlue; /* device-independent color */
+ unsigned short backRed, backGreen, backBlue; /* device-independent color */
+ int refcnt;
+ PrivateRec *devPrivates; /* set by pScr->RealizeCursor*/
+ XID id;
+#ifdef XFIXES
+ CARD32 serialNumber;
+ Atom name;
+#endif
+} CursorRec;
+
+#define CURSOR_REC_SIZE (sizeof(CursorRec) + dixPrivatesSize(PRIVATE_CURSOR))
+
+typedef struct _CursorMetric {
+ unsigned short width, height, xhot, yhot;
+} CursorMetricRec;
+
+typedef struct {
+ int x, y;
+ ScreenPtr pScreen;
+} HotSpot;
+
+#endif /* CURSORSTRUCT_H */
diff --git a/xorg-server/include/dix-config.h.in b/xorg-server/include/dix-config.h.in index 7759aac6a..63a770f1e 100644 --- a/xorg-server/include/dix-config.h.in +++ b/xorg-server/include/dix-config.h.in @@ -1,443 +1,446 @@ -/* dix-config.h.in: not at all generated. -*- c -*- */ - -#ifndef _DIX_CONFIG_H_ -#define _DIX_CONFIG_H_ - -/* Support BigRequests extension */ -#undef BIGREQS - -/* Builder address */ -#undef BUILDERADDR - -/* Operating System Name */ -#undef OSNAME - -/* Operating System Vendor */ -#undef OSVENDOR - -/* Builder string */ -#undef BUILDERSTRING - -/* Default font path */ -#undef COMPILEDDEFAULTFONTPATH - -/* Miscellaneous server configuration files path */ -#undef SERVER_MISC_CONFIG_PATH - -/* Support Composite Extension */ -#undef COMPOSITE - -/* Support Damage extension */ -#undef DAMAGE - -/* Build for darwin with Quartz support */ -#undef DARWIN_WITH_QUARTZ - -/* Use OsVendorVErrorF */ -#undef DDXOSVERRORF - -/* Use ddxBeforeReset */ -#undef DDXBEFORERESET - -/* Build DPMS extension */ -#undef DPMSExtension - -/* Build GLX extension */ -#undef GLXEXT - -/* Build GLX DRI loader */ -#undef GLX_DRI - -/* Path to DRI drivers */ -#undef DRI_DRIVER_PATH - -/* Support XDM-AUTH*-1 */ -#undef HASXDMAUTH - -/* Define to 1 if you have the `getdtablesize' function. */ -#undef HAS_GETDTABLESIZE - -/* Define to 1 if you have the `getifaddrs' function. */ -#undef HAS_GETIFADDRS - -/* Define to 1 if you have the `getpeereid' function. */ -#undef HAS_GETPEEREID - -/* Define to 1 if you have the `getpeerucred' function. */ -#undef HAS_GETPEERUCRED - -/* Define to 1 if you have the `mmap' function. */ -#undef HAS_MMAP - -/* Support SHM */ -#undef HAS_SHM - -/* Have the 'strlcpy' function */ -#undef HAS_STRLCPY - -/* Define to 1 if you have the <asm/mtrr.h> header file. */ -#undef HAVE_ASM_MTRR_H - -/* Has backtrace support */ -#undef HAVE_BACKTRACE - -/* Define to 1 if you have the <byteswap.h> header file. */ -#undef HAVE_BYTESWAP_H - -/* Define to 1 if you have cbrt */ -#undef HAVE_CBRT - -/* Define to 1 if you have the <dbm.h> header file. */ -#undef HAVE_DBM_H - -/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. - */ -#undef HAVE_DIRENT_H - -/* Define to 1 if you have the <dlfcn.h> header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ -#undef HAVE_DOPRNT - -/* Have execinfo.h */ -#undef HAVE_EXECINFO_H - -/* Define to 1 if you have the <fcntl.h> header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the `geteuid' function. */ -#undef HAVE_GETEUID - -/* Define to 1 if you have the `getisax' function. */ -#undef HAVE_GETISAX - -/* Define to 1 if you have the `getuid' function. */ -#undef HAVE_GETUID - -/* Define to 1 if you have the `getzoneid' function. */ -#undef HAVE_GETZONEID - -/* Define to 1 if you have the <inttypes.h> header file. */ -#undef HAVE_INTTYPES_H - -/* Have Quartz */ -#undef XQUARTZ - -/* Support application updating through sparkle. */ -#undef XQUARTZ_SPARKLE - -/* Prefix to use for launchd identifiers */ -#undef LAUNCHD_ID_PREFIX - -/* Build a standalone xpbproxy */ -#undef STANDALONE_XPBPROXY - -/* Define to 1 if you have the `m' library (-lm). */ -#undef HAVE_LIBM - -/* Define to 1 if you have the `link' function. */ -#undef HAVE_LINK - -/* Define to 1 if you have the <linux/agpgart.h> header file. */ -#undef HAVE_LINUX_AGPGART_H - -/* Define to 1 if you have the <linux/apm_bios.h> header file. */ -#undef HAVE_LINUX_APM_BIOS_H - -/* Define to 1 if you have the <linux/fb.h> header file. */ -#undef HAVE_LINUX_FB_H - -/* Define to 1 if you have the `mkstemp' function. */ -#undef HAVE_MKSTEMP - -/* Define to 1 if you have the <ndbm.h> header file. */ -#undef HAVE_NDBM_H - -/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ -#undef HAVE_NDIR_H - -/* Define to 1 if you have the <rpcsvc/dbm.h> header file. */ -#undef HAVE_RPCSVC_DBM_H - -/* Define to use libc SHA1 functions */ -#undef HAVE_SHA1_IN_LIBC - -/* Define to use CommonCrypto SHA1 functions */ -#undef HAVE_SHA1_IN_COMMONCRYPTO - -/* Define to use libmd SHA1 functions */ -#undef HAVE_SHA1_IN_LIBMD - -/* Define to use libgcrypt SHA1 functions */ -#undef HAVE_SHA1_IN_LIBGCRYPT - -/* Define to use libsha1 for SHA1 */ -#undef HAVE_SHA1_IN_LIBSHA1 - -/* Define to 1 if you have the `shmctl64' function. */ -#undef HAVE_SHMCTL64 - -/* Define to 1 if you have the <stdint.h> header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the <stdlib.h> header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strchr' function. */ -#undef HAVE_STRCHR - -/* Define to 1 if you have the <strings.h> header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the <string.h> header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strrchr' function. */ -#undef HAVE_STRRCHR - -/* Define to 1 if you have the `strtol' function. */ -#undef HAVE_STRTOL - -/* Define to 1 if SYSV IPC is available */ -#undef HAVE_SYSV_IPC - -/* Define to 1 if you have the <sys/agpio.h> header file. */ -#undef HAVE_SYS_AGPIO_H - -/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. - */ -#undef HAVE_SYS_DIR_H - -/* Define to 1 if you have the <sys/io.h> header file. */ -#undef HAVE_SYS_IO_H - -/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. - */ -#undef HAVE_SYS_NDIR_H - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the <sys/types.h> header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the <sys/vm86.h> header file. */ -#undef HAVE_SYS_VM86_H - -/* Define to 1 if you have the <tslib.h> header file. */ -#undef HAVE_TSLIB_H - -/* Define to 1 if you have the <unistd.h> header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the <fnmatch.h> header file. */ -#undef HAVE_FNMATCH_H - -/* Have /dev/urandom */ -#undef HAVE_URANDOM - -/* Define to 1 if you have the `vprintf' function. */ -#undef HAVE_VPRINTF - -/* Support IPv6 for TCP connections */ -#undef IPv6 - -/* Support os-specific local connections */ -#undef LOCALCONN - -/* Support MIT-SHM Extension */ -#undef MITSHM - -/* Enable some debugging code */ -#undef DEBUG - -/* Name of package */ -#undef PACKAGE - -/* Internal define for Xinerama */ -#undef PANORAMIX - -/* Overall prefix */ -#undef PROJECTROOT - -/* Support RANDR extension */ -#undef RANDR - -/* Support Record extension */ -#undef XRECORD - -/* Support RENDER extension */ -#undef RENDER - -/* Support X resource extension */ -#undef RES - -/* Support MIT-SCREEN-SAVER extension */ -#undef SCREENSAVER - -/* Support Secure RPC ("SUN-DES-1") authentication for X11 clients */ -#undef SECURE_RPC - -/* Support SHAPE extension */ -#undef SHAPE - -/* Define to 1 on systems derived from System V Release 4 */ -#undef SVR4 - -/* Support TCP socket connections */ -#undef TCPCONN - -/* Enable touchscreen support */ -#undef TOUCHSCREEN - -/* Support tslib touchscreen abstraction library */ -#undef TSLIB - -/* Support UNIX socket connections */ -#undef UNIXCONN - -/* Define to use byteswap macros from <sys/endian.h> */ -#undef USE_SYS_ENDIAN_H - -/* unaligned word accesses behave as expected */ -#undef WORKING_UNALIGNED_INT - -/* Build X string registry */ -#undef XREGISTRY - -/* Build X-ACE extension */ -#undef XACE - -/* Build SELinux extension */ -#undef XSELINUX - -/* Support XCMisc extension */ -#undef XCMISC - -/* Build Security extension */ -#undef XCSECURITY - -/* Support Xdmcp */ -#undef XDMCP - -/* Build XFree86 BigFont extension */ -#undef XF86BIGFONT - -/* Support XFree86 Video Mode extension */ -#undef XF86VIDMODE - -/* Support XFixes extension */ -#undef XFIXES - -/* Build XDGA support */ -#undef XFreeXDGA - -/* Support Xinerama extension */ -#undef XINERAMA - -/* Vendor release */ -#undef XORG_RELEASE - -/* Current Xorg version */ -#undef XORG_VERSION_CURRENT - -/* Xorg release date */ -#undef XORG_DATE - -/* Build Xv Extension */ -#undef XvExtension - -/* Build XvMC Extension */ -#undef XvMCExtension - -/* Support XSync extension */ -#undef XSYNC - -/* Support XTest extension */ -#undef XTEST - -/* Support Xv extension */ -#undef XV - -/* Support DRI extension */ -#undef XF86DRI - -/* Build DRI2 extension */ -#undef DRI2 - -/* Build DBE support */ -#undef DBE - -/* Vendor name */ -#undef XVENDORNAME - -/* Enable GNU and other extensions to the C environment for GLIBC */ -#undef _GNU_SOURCE - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `int' if <sys/types.h> does not define. */ -#undef pid_t - -/* Build Rootless code */ -#undef ROOTLESS - -/* Define to 1 if unsigned long is 64 bits. */ -#undef _XSERVER64 - -/* System is BSD-like */ -#undef CSRG_BASED - -/* Define to 1 if `struct sockaddr_in' has a `sin_len' member */ -#undef BSD44SOCKETS - -/* Support D-Bus */ -#undef HAVE_DBUS - -/* Use libudev for input hotplug */ -#undef CONFIG_UDEV - -/* Use D-Bus for input hotplug */ -#undef CONFIG_NEED_DBUS - -/* Support the D-Bus hotplug API */ -#undef CONFIG_DBUS_API - -/* Support HAL for hotplug */ -#undef CONFIG_HAL - -/* Have a monotonic clock from clock_gettime() */ -#undef MONOTONIC_CLOCK - -/* Define to 1 if the DTrace Xserver provider probes should be built in */ -#undef XSERVER_DTRACE - -/* Define to 16-bit byteswap macro */ -#undef bswap_16 - -/* Define to 32-bit byteswap macro */ -#undef bswap_32 - -/* Define to 64-bit byteswap macro */ -#undef bswap_64 - -/* Need the strcasecmp function. */ -#undef NEED_STRCASECMP - -/* Need the strncasecmp function. */ -#undef NEED_STRNCASECMP - -/* Need the strcasestr function. */ -#undef NEED_STRCASESTR - -/* Define to 1 if you have the `ffs' function. */ -#undef HAVE_FFS - -/* Correctly set _XSERVER64 for OSX fat binaries */ -#ifdef __APPLE__ -#include "dix-config-apple-verbatim.h" -#endif - -#endif /* _DIX_CONFIG_H_ */ +/* dix-config.h.in: not at all generated. -*- c -*- */
+
+#ifndef _DIX_CONFIG_H_
+#define _DIX_CONFIG_H_
+
+/* Support BigRequests extension */
+#undef BIGREQS
+
+/* Builder address */
+#undef BUILDERADDR
+
+/* Operating System Name */
+#undef OSNAME
+
+/* Operating System Vendor */
+#undef OSVENDOR
+
+/* Builder string */
+#undef BUILDERSTRING
+
+/* Default font path */
+#undef COMPILEDDEFAULTFONTPATH
+
+/* Miscellaneous server configuration files path */
+#undef SERVER_MISC_CONFIG_PATH
+
+/* Support Composite Extension */
+#undef COMPOSITE
+
+/* Support Damage extension */
+#undef DAMAGE
+
+/* Build for darwin with Quartz support */
+#undef DARWIN_WITH_QUARTZ
+
+/* Use OsVendorVErrorF */
+#undef DDXOSVERRORF
+
+/* Use ddxBeforeReset */
+#undef DDXBEFORERESET
+
+/* Build DPMS extension */
+#undef DPMSExtension
+
+/* Build GLX extension */
+#undef GLXEXT
+
+/* Build GLX DRI loader */
+#undef GLX_DRI
+
+/* Path to DRI drivers */
+#undef DRI_DRIVER_PATH
+
+/* Support XDM-AUTH*-1 */
+#undef HASXDMAUTH
+
+/* Define to 1 if you have the `getdtablesize' function. */
+#undef HAS_GETDTABLESIZE
+
+/* Define to 1 if you have the `getifaddrs' function. */
+#undef HAS_GETIFADDRS
+
+/* Define to 1 if you have the `getpeereid' function. */
+#undef HAS_GETPEEREID
+
+/* Define to 1 if you have the `getpeerucred' function. */
+#undef HAS_GETPEERUCRED
+
+/* Define to 1 if you have the `mmap' function. */
+#undef HAS_MMAP
+
+/* Support SHM */
+#undef HAS_SHM
+
+/* Have the 'strlcpy' function */
+#undef HAS_STRLCPY
+
+/* Define to 1 if you have the <asm/mtrr.h> header file. */
+#undef HAVE_ASM_MTRR_H
+
+/* Has backtrace support */
+#undef HAVE_BACKTRACE
+
+/* Define to 1 if you have the <byteswap.h> header file. */
+#undef HAVE_BYTESWAP_H
+
+/* Define to 1 if you have cbrt */
+#undef HAVE_CBRT
+
+/* Define to 1 if you have the <dbm.h> header file. */
+#undef HAVE_DBM_H
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+#undef HAVE_DOPRNT
+
+/* Have execinfo.h */
+#undef HAVE_EXECINFO_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the `geteuid' function. */
+#undef HAVE_GETEUID
+
+/* Define to 1 if you have the `getisax' function. */
+#undef HAVE_GETISAX
+
+/* Define to 1 if you have the `getuid' function. */
+#undef HAVE_GETUID
+
+/* Define to 1 if you have the `getzoneid' function. */
+#undef HAVE_GETZONEID
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Have Quartz */
+#undef XQUARTZ
+
+/* Support application updating through sparkle. */
+#undef XQUARTZ_SPARKLE
+
+/* Prefix to use for launchd identifiers */
+#undef LAUNCHD_ID_PREFIX
+
+/* Build a standalone xpbproxy */
+#undef STANDALONE_XPBPROXY
+
+/* Define to 1 if you have the `m' library (-lm). */
+#undef HAVE_LIBM
+
+/* Define to 1 if you have the `link' function. */
+#undef HAVE_LINK
+
+/* Define to 1 if you have the <linux/agpgart.h> header file. */
+#undef HAVE_LINUX_AGPGART_H
+
+/* Define to 1 if you have the <linux/apm_bios.h> header file. */
+#undef HAVE_LINUX_APM_BIOS_H
+
+/* Define to 1 if you have the <linux/fb.h> header file. */
+#undef HAVE_LINUX_FB_H
+
+/* Define to 1 if you have the `mkstemp' function. */
+#undef HAVE_MKSTEMP
+
+/* Define to 1 if you have the <ndbm.h> header file. */
+#undef HAVE_NDBM_H
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#undef HAVE_NDIR_H
+
+/* Define to 1 if you have the <rpcsvc/dbm.h> header file. */
+#undef HAVE_RPCSVC_DBM_H
+
+/* Define to use libc SHA1 functions */
+#undef HAVE_SHA1_IN_LIBC
+
+/* Define to use CommonCrypto SHA1 functions */
+#undef HAVE_SHA1_IN_COMMONCRYPTO
+
+/* Define to use libmd SHA1 functions */
+#undef HAVE_SHA1_IN_LIBMD
+
+/* Define to use libgcrypt SHA1 functions */
+#undef HAVE_SHA1_IN_LIBGCRYPT
+
+/* Define to use libsha1 for SHA1 */
+#undef HAVE_SHA1_IN_LIBSHA1
+
+/* Define to 1 if you have the `shmctl64' function. */
+#undef HAVE_SHMCTL64
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strchr' function. */
+#undef HAVE_STRCHR
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strrchr' function. */
+#undef HAVE_STRRCHR
+
+/* Define to 1 if you have the `strtol' function. */
+#undef HAVE_STRTOL
+
+/* Define to 1 if SYSV IPC is available */
+#undef HAVE_SYSV_IPC
+
+/* Define to 1 if you have the <sys/agpio.h> header file. */
+#undef HAVE_SYS_AGPIO_H
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/io.h> header file. */
+#undef HAVE_SYS_IO_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_NDIR_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <sys/utsname.h> header file. */
+#undef HAVE_SYS_UTSNAME_H
+
+/* Define to 1 if you have the <sys/vm86.h> header file. */
+#undef HAVE_SYS_VM86_H
+
+/* Define to 1 if you have the <tslib.h> header file. */
+#undef HAVE_TSLIB_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the <fnmatch.h> header file. */
+#undef HAVE_FNMATCH_H
+
+/* Have /dev/urandom */
+#undef HAVE_URANDOM
+
+/* Define to 1 if you have the `vprintf' function. */
+#undef HAVE_VPRINTF
+
+/* Support IPv6 for TCP connections */
+#undef IPv6
+
+/* Support os-specific local connections */
+#undef LOCALCONN
+
+/* Support MIT-SHM Extension */
+#undef MITSHM
+
+/* Enable some debugging code */
+#undef DEBUG
+
+/* Name of package */
+#undef PACKAGE
+
+/* Internal define for Xinerama */
+#undef PANORAMIX
+
+/* Overall prefix */
+#undef PROJECTROOT
+
+/* Support RANDR extension */
+#undef RANDR
+
+/* Support Record extension */
+#undef XRECORD
+
+/* Support RENDER extension */
+#undef RENDER
+
+/* Support X resource extension */
+#undef RES
+
+/* Support MIT-SCREEN-SAVER extension */
+#undef SCREENSAVER
+
+/* Support Secure RPC ("SUN-DES-1") authentication for X11 clients */
+#undef SECURE_RPC
+
+/* Support SHAPE extension */
+#undef SHAPE
+
+/* Define to 1 on systems derived from System V Release 4 */
+#undef SVR4
+
+/* Support TCP socket connections */
+#undef TCPCONN
+
+/* Enable touchscreen support */
+#undef TOUCHSCREEN
+
+/* Support tslib touchscreen abstraction library */
+#undef TSLIB
+
+/* Support UNIX socket connections */
+#undef UNIXCONN
+
+/* Define to use byteswap macros from <sys/endian.h> */
+#undef USE_SYS_ENDIAN_H
+
+/* unaligned word accesses behave as expected */
+#undef WORKING_UNALIGNED_INT
+
+/* Build X string registry */
+#undef XREGISTRY
+
+/* Build X-ACE extension */
+#undef XACE
+
+/* Build SELinux extension */
+#undef XSELINUX
+
+/* Support XCMisc extension */
+#undef XCMISC
+
+/* Build Security extension */
+#undef XCSECURITY
+
+/* Support Xdmcp */
+#undef XDMCP
+
+/* Build XFree86 BigFont extension */
+#undef XF86BIGFONT
+
+/* Support XFree86 Video Mode extension */
+#undef XF86VIDMODE
+
+/* Support XFixes extension */
+#undef XFIXES
+
+/* Build XDGA support */
+#undef XFreeXDGA
+
+/* Support Xinerama extension */
+#undef XINERAMA
+
+/* Vendor release */
+#undef XORG_RELEASE
+
+/* Current Xorg version */
+#undef XORG_VERSION_CURRENT
+
+/* Xorg release date */
+#undef XORG_DATE
+
+/* Build Xv Extension */
+#undef XvExtension
+
+/* Build XvMC Extension */
+#undef XvMCExtension
+
+/* Support XSync extension */
+#undef XSYNC
+
+/* Support XTest extension */
+#undef XTEST
+
+/* Support Xv extension */
+#undef XV
+
+/* Support DRI extension */
+#undef XF86DRI
+
+/* Build DRI2 extension */
+#undef DRI2
+
+/* Build DBE support */
+#undef DBE
+
+/* Vendor name */
+#undef XVENDORNAME
+
+/* Enable GNU and other extensions to the C environment for GLIBC */
+#undef _GNU_SOURCE
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef pid_t
+
+/* Build Rootless code */
+#undef ROOTLESS
+
+/* Define to 1 if unsigned long is 64 bits. */
+#undef _XSERVER64
+
+/* System is BSD-like */
+#undef CSRG_BASED
+
+/* Define to 1 if `struct sockaddr_in' has a `sin_len' member */
+#undef BSD44SOCKETS
+
+/* Support D-Bus */
+#undef HAVE_DBUS
+
+/* Use libudev for input hotplug */
+#undef CONFIG_UDEV
+
+/* Use D-Bus for input hotplug */
+#undef CONFIG_NEED_DBUS
+
+/* Support the D-Bus hotplug API */
+#undef CONFIG_DBUS_API
+
+/* Support HAL for hotplug */
+#undef CONFIG_HAL
+
+/* Have a monotonic clock from clock_gettime() */
+#undef MONOTONIC_CLOCK
+
+/* Define to 1 if the DTrace Xserver provider probes should be built in */
+#undef XSERVER_DTRACE
+
+/* Define to 16-bit byteswap macro */
+#undef bswap_16
+
+/* Define to 32-bit byteswap macro */
+#undef bswap_32
+
+/* Define to 64-bit byteswap macro */
+#undef bswap_64
+
+/* Need the strcasecmp function. */
+#undef NEED_STRCASECMP
+
+/* Need the strncasecmp function. */
+#undef NEED_STRNCASECMP
+
+/* Need the strcasestr function. */
+#undef NEED_STRCASESTR
+
+/* Define to 1 if you have the `ffs' function. */
+#undef HAVE_FFS
+
+/* Correctly set _XSERVER64 for OSX fat binaries */
+#ifdef __APPLE__
+#include "dix-config-apple-verbatim.h"
+#endif
+
+#endif /* _DIX_CONFIG_H_ */
diff --git a/xorg-server/include/dix.h b/xorg-server/include/dix.h index 254ddb3f4..e5a0d5c51 100644 --- a/xorg-server/include/dix.h +++ b/xorg-server/include/dix.h @@ -83,7 +83,7 @@ SOFTWARE. if (!LegalNewID(id,client)) \
{\
client->errorValue = id;\
- return(BadIDChoice);\
+ return BadIDChoice;\
}
#define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, mode)\
@@ -95,7 +95,7 @@ SOFTWARE. if (rc != Success)\
return rc;\
if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen))\
- return (BadMatch);\
+ return BadMatch;\
}\
if (pGC->serialNumber != pDraw->serialNumber)\
ValidateGC(pDraw, pGC);
diff --git a/xorg-server/include/globals.h b/xorg-server/include/globals.h index 9c804ee52..a528d4c31 100644 --- a/xorg-server/include/globals.h +++ b/xorg-server/include/globals.h @@ -1,126 +1,123 @@ - -#ifndef _XSERV_GLOBAL_H_ -#define _XSERV_GLOBAL_H_ - -#include "window.h" /* for WindowPtr */ - -/* Global X server variables that are visible to mi, dix, os, and ddx */ - -extern _X_EXPORT CARD32 defaultScreenSaverTime; -extern _X_EXPORT CARD32 defaultScreenSaverInterval; -extern _X_EXPORT CARD32 ScreenSaverTime; -extern _X_EXPORT CARD32 ScreenSaverInterval; - -#ifdef SCREENSAVER -extern _X_EXPORT Bool screenSaverSuspended; -#endif - -extern _X_EXPORT char *defaultFontPath; -extern _X_EXPORT int monitorResolution; -extern _X_EXPORT int defaultColorVisualClass; - -extern _X_EXPORT WindowPtr WindowTable[MAXSCREENS]; -extern _X_EXPORT int GrabInProgress; -extern _X_EXPORT Bool noTestExtensions; - -extern _X_EXPORT DDXPointRec dixScreenOrigins[MAXSCREENS]; - -extern _X_EXPORT char *ConnectionInfo; - -#ifdef DPMSExtension -extern _X_EXPORT CARD32 DPMSStandbyTime; -extern _X_EXPORT CARD32 DPMSSuspendTime; -extern _X_EXPORT CARD32 DPMSOffTime; -extern _X_EXPORT CARD16 DPMSPowerLevel; -extern _X_EXPORT Bool DPMSEnabled; -extern _X_EXPORT Bool DPMSDisabledSwitch; -extern _X_EXPORT Bool DPMSCapableFlag; -#endif - -#ifdef PANORAMIX -extern _X_EXPORT Bool PanoramiXExtensionDisabledHack; -#endif - -extern _X_EXPORT Bool noCompositeExtension; - -#ifdef DAMAGE -extern _X_EXPORT Bool noDamageExtension; -#endif - -#ifdef DBE -extern _X_EXPORT Bool noDbeExtension; -#endif - -#ifdef DPMSExtension -extern _X_EXPORT Bool noDPMSExtension; -#endif - -#ifdef GLXEXT -extern _X_EXPORT Bool noGlxExtension; -#endif - -#ifdef SCREENSAVER -extern _X_EXPORT Bool noScreenSaverExtension; -#endif - -#ifdef MITSHM -extern _X_EXPORT Bool noMITShmExtension; -#endif - -#ifdef RANDR -extern _X_EXPORT Bool noRRExtension; -#endif - -extern _X_EXPORT Bool noRenderExtension; - -#ifdef XCSECURITY -extern _X_EXPORT Bool noSecurityExtension; -#endif - -#ifdef RES -extern _X_EXPORT Bool noResExtension; -#endif - -#ifdef XF86BIGFONT -extern _X_EXPORT Bool noXFree86BigfontExtension; -#endif - -#ifdef XFreeXDGA -extern _X_EXPORT Bool noXFree86DGAExtension; -#endif - -#ifdef XF86DRI -extern _X_EXPORT Bool noXFree86DRIExtension; -#endif - -#ifdef XF86VIDMODE -extern _X_EXPORT Bool noXFree86VidModeExtension; -#endif - -#ifdef XFIXES -extern _X_EXPORT Bool noXFixesExtension; -#endif - -#ifdef PANORAMIX -extern _X_EXPORT Bool noPanoramiXExtension; -#endif - -#ifdef XSELINUX -extern _X_EXPORT Bool noSELinuxExtension; - -#define SELINUX_MODE_DEFAULT 0 -#define SELINUX_MODE_DISABLED 1 -#define SELINUX_MODE_PERMISSIVE 2 -#define SELINUX_MODE_ENFORCING 3 -extern _X_EXPORT int selinuxEnforcingState; -#endif - -#ifdef XV -extern _X_EXPORT Bool noXvExtension; -#endif - -#ifdef DRI2 -extern _X_EXPORT Bool noDRI2Extension; -#endif - -#endif /* !_XSERV_GLOBAL_H_ */ +
+#ifndef _XSERV_GLOBAL_H_
+#define _XSERV_GLOBAL_H_
+
+#include "window.h" /* for WindowPtr */
+
+/* Global X server variables that are visible to mi, dix, os, and ddx */
+
+extern _X_EXPORT CARD32 defaultScreenSaverTime;
+extern _X_EXPORT CARD32 defaultScreenSaverInterval;
+extern _X_EXPORT CARD32 ScreenSaverTime;
+extern _X_EXPORT CARD32 ScreenSaverInterval;
+
+#ifdef SCREENSAVER
+extern _X_EXPORT Bool screenSaverSuspended;
+#endif
+
+extern _X_EXPORT char *defaultFontPath;
+extern _X_EXPORT int monitorResolution;
+extern _X_EXPORT int defaultColorVisualClass;
+
+extern _X_EXPORT int GrabInProgress;
+extern _X_EXPORT Bool noTestExtensions;
+
+extern _X_EXPORT char *ConnectionInfo;
+
+#ifdef DPMSExtension
+extern _X_EXPORT CARD32 DPMSStandbyTime;
+extern _X_EXPORT CARD32 DPMSSuspendTime;
+extern _X_EXPORT CARD32 DPMSOffTime;
+extern _X_EXPORT CARD16 DPMSPowerLevel;
+extern _X_EXPORT Bool DPMSEnabled;
+extern _X_EXPORT Bool DPMSDisabledSwitch;
+extern _X_EXPORT Bool DPMSCapableFlag;
+#endif
+
+#ifdef PANORAMIX
+extern _X_EXPORT Bool PanoramiXExtensionDisabledHack;
+#endif
+
+extern _X_EXPORT Bool noCompositeExtension;
+
+#ifdef DAMAGE
+extern _X_EXPORT Bool noDamageExtension;
+#endif
+
+#ifdef DBE
+extern _X_EXPORT Bool noDbeExtension;
+#endif
+
+#ifdef DPMSExtension
+extern _X_EXPORT Bool noDPMSExtension;
+#endif
+
+#ifdef GLXEXT
+extern _X_EXPORT Bool noGlxExtension;
+#endif
+
+#ifdef SCREENSAVER
+extern _X_EXPORT Bool noScreenSaverExtension;
+#endif
+
+#ifdef MITSHM
+extern _X_EXPORT Bool noMITShmExtension;
+#endif
+
+#ifdef RANDR
+extern _X_EXPORT Bool noRRExtension;
+#endif
+
+extern _X_EXPORT Bool noRenderExtension;
+
+#ifdef XCSECURITY
+extern _X_EXPORT Bool noSecurityExtension;
+#endif
+
+#ifdef RES
+extern _X_EXPORT Bool noResExtension;
+#endif
+
+#ifdef XF86BIGFONT
+extern _X_EXPORT Bool noXFree86BigfontExtension;
+#endif
+
+#ifdef XFreeXDGA
+extern _X_EXPORT Bool noXFree86DGAExtension;
+#endif
+
+#ifdef XF86DRI
+extern _X_EXPORT Bool noXFree86DRIExtension;
+#endif
+
+#ifdef XF86VIDMODE
+extern _X_EXPORT Bool noXFree86VidModeExtension;
+#endif
+
+#ifdef XFIXES
+extern _X_EXPORT Bool noXFixesExtension;
+#endif
+
+#ifdef PANORAMIX
+extern _X_EXPORT Bool noPanoramiXExtension;
+#endif
+
+#ifdef XSELINUX
+extern _X_EXPORT Bool noSELinuxExtension;
+
+#define SELINUX_MODE_DEFAULT 0
+#define SELINUX_MODE_DISABLED 1
+#define SELINUX_MODE_PERMISSIVE 2
+#define SELINUX_MODE_ENFORCING 3
+extern _X_EXPORT int selinuxEnforcingState;
+#endif
+
+#ifdef XV
+extern _X_EXPORT Bool noXvExtension;
+#endif
+
+#ifdef DRI2
+extern _X_EXPORT Bool noDRI2Extension;
+#endif
+
+#endif /* !_XSERV_GLOBAL_H_ */
diff --git a/xorg-server/include/input.h b/xorg-server/include/input.h index b0979b4df..e96a44d50 100644 --- a/xorg-server/include/input.h +++ b/xorg-server/include/input.h @@ -215,6 +215,8 @@ typedef struct _InputAttributes { char *product;
char *vendor;
char *device;
+ char *pnp_id;
+ char *usb_id;
char **tags; /* null-terminated */
uint32_t flags;
} InputAttributes;
diff --git a/xorg-server/include/inputstr.h b/xorg-server/include/inputstr.h index fa21c7b3a..c37f30073 100644 --- a/xorg-server/include/inputstr.h +++ b/xorg-server/include/inputstr.h @@ -49,6 +49,7 @@ SOFTWARE. #ifndef INPUTSTRUCT_H
#define INPUTSTRUCT_H
+#include <pixman.h>
#include "input.h"
#include "window.h"
#include "dixstruct.h"
@@ -550,6 +551,12 @@ typedef struct _DeviceIntRec { XIPropertyPtr properties;
XIPropertyHandlerPtr handlers; /* NULL-terminated */
} properties;
+
+ /* coordinate transformation matrix for absolute input devices */
+ struct pixman_f_transform transform;
+
+ /* XTest related master device id */
+ int xtest_master_id;
} DeviceIntRec;
typedef struct {
diff --git a/xorg-server/include/misc.h b/xorg-server/include/misc.h index 847864ce9..7a9566d26 100644 --- a/xorg-server/include/misc.h +++ b/xorg-server/include/misc.h @@ -80,6 +80,10 @@ OF THIS SOFTWARE. #include <stddef.h>
+#ifdef _MSC_VER
+#define inline __inline
+#endif
+
#ifndef MAXSCREENS
#define MAXSCREENS 16
#endif
diff --git a/xorg-server/include/pixmap.h b/xorg-server/include/pixmap.h index 55a9c818a..9761ce48c 100644 --- a/xorg-server/include/pixmap.h +++ b/xorg-server/include/pixmap.h @@ -1,118 +1,121 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - -#ifndef PIXMAP_H -#define PIXMAP_H - -#include "misc.h" -#include "screenint.h" - -/* types for Drawable */ -#define DRAWABLE_WINDOW 0 -#define DRAWABLE_PIXMAP 1 -#define UNDRAWABLE_WINDOW 2 -#define DRAWABLE_BUFFER 3 - -/* corresponding type masks for dixLookupDrawable() */ -#define M_DRAWABLE_WINDOW (1<<0) -#define M_DRAWABLE_PIXMAP (1<<1) -#define M_UNDRAWABLE_WINDOW (1<<2) -#define M_DRAWABLE_BUFFER (1<<3) -#define M_ANY (-1) -#define M_WINDOW (M_DRAWABLE_WINDOW|M_UNDRAWABLE_WINDOW) -#define M_DRAWABLE (M_DRAWABLE_WINDOW|M_DRAWABLE_PIXMAP|M_DRAWABLE_BUFFER) -#define M_UNDRAWABLE (M_UNDRAWABLE_WINDOW) - -/* flags to PaintWindow() */ -#define PW_BACKGROUND 0 -#define PW_BORDER 1 - -#define NullPixmap ((PixmapPtr)0) - -typedef struct _Drawable *DrawablePtr; -typedef struct _Pixmap *PixmapPtr; - -typedef union _PixUnion { - PixmapPtr pixmap; - unsigned long pixel; -} PixUnion; - -#define SamePixUnion(a,b,isPixel)\ - ((isPixel) ? (a).pixel == (b).pixel : (a).pixmap == (b).pixmap) - -#define EqualPixUnion(as, a, bs, b) \ - ((as) == (bs) && (SamePixUnion (a, b, as))) - -#define OnScreenDrawable(type) \ - ((type == DRAWABLE_WINDOW) || (type == DRAWABLE_BUFFER)) - -#define WindowDrawable(type) \ - ((type == DRAWABLE_WINDOW) || (type == UNDRAWABLE_WINDOW)) - -extern _X_EXPORT PixmapPtr GetScratchPixmapHeader( - ScreenPtr /*pScreen*/, - int /*width*/, - int /*height*/, - int /*depth*/, - int /*bitsPerPixel*/, - int /*devKind*/, - pointer /*pPixData*/); - -extern _X_EXPORT void FreeScratchPixmapHeader( - PixmapPtr /*pPixmap*/); - -extern _X_EXPORT Bool CreateScratchPixmapsForScreen( - int /*scrnum*/); - -extern _X_EXPORT void FreeScratchPixmapsForScreen( - int /*scrnum*/); - -extern _X_EXPORT PixmapPtr AllocatePixmap( - ScreenPtr /*pScreen*/, - int /*pixDataSize*/); - -#endif /* PIXMAP_H */ +/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef PIXMAP_H
+#define PIXMAP_H
+
+#include "misc.h"
+#include "screenint.h"
+
+/* types for Drawable */
+#define DRAWABLE_WINDOW 0
+#define DRAWABLE_PIXMAP 1
+#define UNDRAWABLE_WINDOW 2
+#define DRAWABLE_BUFFER 3
+
+/* corresponding type masks for dixLookupDrawable() */
+#define M_DRAWABLE_WINDOW (1<<0)
+#define M_DRAWABLE_PIXMAP (1<<1)
+#define M_UNDRAWABLE_WINDOW (1<<2)
+#define M_DRAWABLE_BUFFER (1<<3)
+#define M_ANY (-1)
+#define M_WINDOW (M_DRAWABLE_WINDOW|M_UNDRAWABLE_WINDOW)
+#define M_DRAWABLE (M_DRAWABLE_WINDOW|M_DRAWABLE_PIXMAP|M_DRAWABLE_BUFFER)
+#define M_UNDRAWABLE (M_UNDRAWABLE_WINDOW)
+
+/* flags to PaintWindow() */
+#define PW_BACKGROUND 0
+#define PW_BORDER 1
+
+#define NullPixmap ((PixmapPtr)0)
+
+typedef struct _Drawable *DrawablePtr;
+typedef struct _Pixmap *PixmapPtr;
+
+typedef union _PixUnion {
+ PixmapPtr pixmap;
+ unsigned long pixel;
+} PixUnion;
+
+#define SamePixUnion(a,b,isPixel)\
+ ((isPixel) ? (a).pixel == (b).pixel : (a).pixmap == (b).pixmap)
+
+#define EqualPixUnion(as, a, bs, b) \
+ ((as) == (bs) && (SamePixUnion (a, b, as)))
+
+#define OnScreenDrawable(type) \
+ ((type == DRAWABLE_WINDOW) || (type == DRAWABLE_BUFFER))
+
+#define WindowDrawable(type) \
+ ((type == DRAWABLE_WINDOW) || (type == UNDRAWABLE_WINDOW))
+
+extern _X_EXPORT PixmapPtr GetScratchPixmapHeader(
+ ScreenPtr /*pScreen*/,
+ int /*width*/,
+ int /*height*/,
+ int /*depth*/,
+ int /*bitsPerPixel*/,
+ int /*devKind*/,
+ pointer /*pPixData*/);
+
+extern _X_EXPORT void FreeScratchPixmapHeader(
+ PixmapPtr /*pPixmap*/);
+
+extern _X_EXPORT Bool CreateScratchPixmapsForScreen(
+ int /*scrnum*/);
+
+extern _X_EXPORT void FreeScratchPixmapsForScreen(
+ int /*scrnum*/);
+
+extern _X_EXPORT PixmapPtr AllocatePixmap(
+ ScreenPtr /*pScreen*/,
+ int /*pixDataSize*/);
+
+extern _X_EXPORT void FreePixmap(
+ PixmapPtr /*pPixmap*/);
+
+#endif /* PIXMAP_H */
diff --git a/xorg-server/include/privates.h b/xorg-server/include/privates.h index cbb08887f..2774776ab 100644 --- a/xorg-server/include/privates.h +++ b/xorg-server/include/privates.h @@ -12,125 +12,257 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef PRIVATES_H
#define PRIVATES_H 1
-#include "dix.h"
-#include "resource.h"
+#include <X11/Xdefs.h>
+#include <X11/Xosdefs.h>
+#include <X11/Xfuncproto.h>
+#include "misc.h"
/*****************************************************************
* STUFF FOR PRIVATES
*****************************************************************/
-typedef int *DevPrivateKey;
-struct _Private;
-typedef struct _Private PrivateRec;
+typedef struct _Private PrivateRec, *PrivatePtr;
+
+typedef enum {
+ /* XSELinux uses the same private keys for numerous objects */
+ PRIVATE_XSELINUX,
+
+ /* Otherwise, you get a private in just the requested structure
+ */
+ /* These can have objects created before all of the keys are registered */
+ PRIVATE_SCREEN,
+ PRIVATE_EXTENSION,
+ PRIVATE_COLORMAP,
+
+ /* These cannot have any objects before all relevant keys are registered */
+ PRIVATE_DEVICE,
+ PRIVATE_CLIENT,
+ PRIVATE_PROPERTY,
+ PRIVATE_SELECTION,
+ PRIVATE_WINDOW,
+ PRIVATE_PIXMAP,
+ PRIVATE_GC,
+ PRIVATE_CURSOR,
+ PRIVATE_CURSOR_BITS,
+
+ /* extension privates */
+ PRIVATE_DBE_WINDOW,
+ PRIVATE_DAMAGE,
+ PRIVATE_GLYPH,
+ PRIVATE_GLYPHSET,
+ PRIVATE_PICTURE,
+
+ /* last private type */
+ PRIVATE_LAST,
+} DevPrivateType;
+
+typedef struct _DevPrivateKeyRec {
+ int offset;
+ int size;
+ Bool initialized;
+ Bool allocated;
+ DevPrivateType type;
+ struct _DevPrivateKeyRec *next;
+} DevPrivateKeyRec, *DevPrivateKey;
/*
- * Request pre-allocated private space for your driver/module. This function
- * increases the amount of space allocated automatically when dixLookupPrivate
- * is called on a PrivateRec that does not yet have a value associated with
- * 'key'.
- *
- * This function will only increase the reserved size: if a size was previously
- * requested, then dixRequestPrivate causes later calls to dixLookupPrivate to
- * allocate the maximum of the old size and 'size'. Requested sizes are reset
- * to 0 by dixResetPrivates, which is called before each server generation.
- *
- * If dixRequestPrivate is not called with a nonzero size for 'key', then the
- * module responsible for 'key' must manage the associated pointer itself with
- * dixSetPrivate.
- *
- * dixRequestPrivate returns FALSE if it cannot store the requested size.
+ * Let drivers know how to initialize private keys
*/
-extern _X_EXPORT int
-dixRequestPrivate(const DevPrivateKey key, unsigned size);
+
+#define HAS_DEVPRIVATEKEYREC 1
+#define HAS_DIXREGISTERPRIVATEKEY 1
/*
- * Allocates space for an association of 'key' with a value in 'privates'.
+ * Register a new private index for the private type.
*
- * If a nonzero size was requested with dixRequestPrivate, then
- * dixAllocatePrivate also allocates the requested amount of memory and
- * associates the pointer to that memory with 'key' in 'privates'. The
- * allocated memory is initialized to zero. This memory can only be freed by
- * dixFreePrivates.
+ * This initializes the specified key and optionally requests pre-allocated
+ * private space for your driver/module. If you request no extra space, you
+ * may set and get a single pointer value using this private key. Otherwise,
+ * you can get the address of the extra space and store whatever data you like
+ * there.
*
- * If dixRequestPrivate was never called with a nonzero size, then
- * dixAllocatePrivate associates NULL with 'key' in 'privates'.
+ * You may call dixRegisterPrivate more than once on the same key, but the
+ * size and type must match or the server will abort.
*
- * dixAllocatePrivate returns a pointer to the value associated with 'key' in
- * 'privates', unless a memory allocation fails, in which case it returns NULL.
+ * dixRegisterPrivateIndex returns FALSE if it fails to allocate memory
+ * during its operation.
*/
-extern _X_EXPORT pointer *
-dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key);
+extern _X_EXPORT Bool
+dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size);
/*
- * Look up a private pointer.
+ * Check whether a private key has been registered
+ */
+static inline Bool
+dixPrivateKeyRegistered(DevPrivateKey key)
+{
+ return key->initialized;
+}
+
+/*
+ * Allocate a new private key.
*
- * If no value is currently associated with 'key' in 'privates', then
- * dixLookupPrivate calls dixAllocatePrivate and returns the resulting
- * associated value.
+ * This manages the storage of the key object itself, freeing it when the
+ * privates system is restarted at server reset time. All other keys
+ * are expected to be statically allocated as the privates must be
+ * reset after all objects have been freed
+ */
+extern _X_EXPORT DevPrivateKey
+dixCreatePrivateKey(DevPrivateType type, unsigned size);
+
+/*
+ * Get the address of the private storage.
*
- * dixLookupPrivate returns NULL if a memory allocation fails.
+ * For keys with pre-defined storage, this gets the base of that storage
+ * Otherwise, it returns the place where the private pointer is stored.
*/
-extern _X_EXPORT pointer
-dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key);
+static inline void *
+dixGetPrivateAddr(PrivatePtr *privates, const DevPrivateKey key)
+{
+ assert(key->initialized);
+ return (char *) (*privates) + key->offset;
+}
/*
- * Look up the address of a private pointer. If 'key' is not associated with a
- * value in 'privates', then dixLookupPrivateAddr calls dixAllocatePrivate and
- * returns a pointer to the resulting associated value.
+ * Fetch a private pointer stored in the object
*
- * dixLookupPrivateAddr returns NULL if 'key' was not previously associated in
- * 'privates' and a memory allocation fails.
+ * Returns the pointer stored with dixSetPrivate.
+ * This must only be used with keys that have
+ * no pre-defined storage
*/
-extern _X_EXPORT pointer *
-dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key);
+static inline void *
+dixGetPrivate(PrivatePtr *privates, const DevPrivateKey key)
+{
+ assert (key->size == 0);
+ return *(void **) dixGetPrivateAddr(privates, key);
+}
/*
* Associate 'val' with 'key' in 'privates' so that later calls to
* dixLookupPrivate(privates, key) will return 'val'.
+ */
+static inline void
+dixSetPrivate(PrivatePtr *privates, const DevPrivateKey key, pointer val)
+{
+ assert (key->size == 0);
+ *(pointer *) dixGetPrivateAddr(privates, key) = val;
+}
+
+#include "dix.h"
+#include "resource.h"
+
+/*
+ * Lookup a pointer to the private record.
*
- * dixSetPrivate returns FALSE if a memory allocation fails.
+ * For privates with defined storage, return the address of the
+ * storage. For privates without defined storage, return the pointer
+ * contents
*/
-extern _X_EXPORT int
-dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val);
+static inline pointer
+dixLookupPrivate(PrivatePtr *privates, const DevPrivateKey key)
+{
+ if (key->size)
+ return dixGetPrivateAddr(privates, key);
+ else
+ return dixGetPrivate(privates, key);
+}
+
+/*
+ * Look up the address of the pointer to the storage
+ *
+ * This returns the place where the private pointer is stored,
+ * which is only valid for privates without predefined storage.
+ */
+static inline pointer *
+dixLookupPrivateAddr(PrivatePtr *privates, const DevPrivateKey key)
+{
+ assert (key->size == 0);
+ return dixGetPrivateAddr(privates, key);
+}
/*
- * Unassociates all keys from 'privates' and frees all private data automatically
- * allocated via dixRequestPrivate.
+ * Allocates private data separately from main object.
+ *
+ * For objects created during server initialization, this allows those
+ * privates to be re-allocated as new private keys are registered.
+ *
+ * This includes screens, the serverClient, default colormaps and
+ * extensions entries.
+ */
+extern _X_EXPORT Bool
+dixAllocatePrivates(PrivatePtr *privates, DevPrivateType type);
+
+/*
+ * Frees separately allocated private data
*/
extern _X_EXPORT void
-dixFreePrivates(PrivateRec *privates);
+dixFreePrivates(PrivatePtr privates, DevPrivateType type);
/*
- * Resets the privates subsystem. dixResetPrivates is called from the main loop
- * before each server generation. This function must only be called by main().
+ * Initialize privates by zeroing them
*/
-extern _X_EXPORT int
-dixResetPrivates(void);
+extern _X_EXPORT void
+_dixInitPrivates(PrivatePtr *privates, void *addr, DevPrivateType type);
+
+#define dixInitPrivates(o, v, type) _dixInitPrivates(&(o)->devPrivates, (v), type);
/*
- * These next two functions are necessary because the position of
- * the devPrivates field varies by structure and calling code might
- * only know the resource type, not the structure definition.
+ * Clean up privates
*/
+extern _X_EXPORT void
+_dixFiniPrivates(PrivatePtr privates, DevPrivateType type);
+
+#define dixFiniPrivates(o,t) _dixFiniPrivates((o)->devPrivates,t)
/*
- * Looks up the offset where the devPrivates field is located.
- * Returns -1 if no offset has been registered for the resource type.
+ * Allocates private data at object creation time. Required
+ * for almost all objects, except for the list described
+ * above for dixAllocatePrivates.
+ */
+extern _X_EXPORT void *
+_dixAllocateObjectWithPrivates(unsigned size, unsigned clear, unsigned offset, DevPrivateType type);
+
+#define dixAllocateObjectWithPrivates(t, type) (t *) _dixAllocateObjectWithPrivates(sizeof(t), sizeof(t), offsetof(t, devPrivates), type)
+
+extern _X_EXPORT void
+_dixFreeObjectWithPrivates(void *object, PrivatePtr privates, DevPrivateType type);
+
+#define dixFreeObjectWithPrivates(o,t) _dixFreeObjectWithPrivates(o, (o)->devPrivates, t)
+
+/*
+ * Return size of privates for the specified type
*/
extern _X_EXPORT int
-dixLookupPrivateOffset(RESTYPE type);
+dixPrivatesSize(DevPrivateType type);
+
+/*
+ * Dump out private stats to ErrorF
+ */
+extern void
+dixPrivateUsage(void);
+
+/*
+ * Resets the privates subsystem. dixResetPrivates is called from the main loop
+ * before each server generation. This function must only be called by main().
+ */
+extern _X_EXPORT void
+dixResetPrivates(void);
/*
- * Specifies the offset where the devPrivates field is located.
- * A negative value indicates no devPrivates field is available.
+ * Looks up the offset where the devPrivates field is located.
+ *
+ * Returns -1 if the specified resource has no dev privates.
+ * The position of the devPrivates field varies by structure
+ * and calling code might only know the resource type, not the
+ * structure definition.
*/
extern _X_EXPORT int
-dixRegisterPrivateOffset(RESTYPE type, int offset);
+dixLookupPrivateOffset(RESTYPE type);
/*
* Convenience macro for adding an offset to an object pointer
* when making a call to one of the devPrivates functions
*/
-#define DEVPRIV_AT(ptr, offset) ((PrivateRec **)((char *)ptr + offset))
+#define DEVPRIV_AT(ptr, offset) ((PrivatePtr *)((char *)(ptr) + offset))
#endif /* PRIVATES_H */
diff --git a/xorg-server/include/regionstr.h b/xorg-server/include/regionstr.h index d67873295..92f4ca9f2 100644 --- a/xorg-server/include/regionstr.h +++ b/xorg-server/include/regionstr.h @@ -66,228 +66,305 @@ typedef struct pixman_region16 RegionRec, *RegionPtr; typedef struct pixman_region16_data RegDataRec, *RegDataPtr;
-extern _X_EXPORT BoxRec miEmptyBox;
-extern _X_EXPORT RegDataRec miEmptyData;
-extern _X_EXPORT RegDataRec miBrokenData;
+extern _X_EXPORT BoxRec RegionEmptyBox;
+extern _X_EXPORT RegDataRec RegionEmptyData;
+extern _X_EXPORT RegDataRec RegionBrokenData;
+static inline Bool RegionNil(RegionPtr reg) {
+ return ((reg)->data && !(reg)->data->numRects);
+}
-#define REGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
/* not a region */
-#define REGION_NAR(reg) ((reg)->data == &miBrokenData)
-#define REGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1)
-#define REGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0)
-#define REGION_RECTS(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
- : &(reg)->extents)
-#define REGION_BOXPTR(reg) ((BoxPtr)((reg)->data + 1))
-#define REGION_BOX(reg,i) (®ION_BOXPTR(reg)[i])
-#define REGION_TOP(reg) REGION_BOX(reg, (reg)->data->numRects)
-#define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1)
-#define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
-
-#define REGION_CREATE(_pScreen, _rect, _size) \
- miRegionCreate(_rect, _size)
-
-#define REGION_COPY(_pScreen, dst, src) \
- miRegionCopy(dst, src)
-
-#define REGION_DESTROY(_pScreen, _pReg) \
- miRegionDestroy(_pReg)
-
-#define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
- miIntersect(newReg, reg1, reg2)
-
-#define REGION_UNION(_pScreen, newReg, reg1, reg2) \
- miUnion(newReg, reg1, reg2)
-
-#define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
- miSubtract(newReg, reg1, reg2)
-
-#define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
- miInverse(newReg, reg1, invRect)
-
-#define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
- miTranslateRegion(_pReg, _x, _y)
-
-#define RECT_IN_REGION(_pScreen, _pReg, prect) \
- miRectIn(_pReg, prect)
-
-#define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
- miPointInRegion(_pReg, _x, _y, prect)
-
-#define REGION_APPEND(_pScreen, dstrgn, rgn) \
- miRegionAppend(dstrgn, rgn)
-
-#define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
- miRegionValidate(badreg, pOverlap)
-
-#define BITMAP_TO_REGION(_pScreen, pPix) \
- (*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
-
-#define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
- miRectsToRegion(nrects, prect, ctype)
-
-#define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
- miRegionEqual(_pReg1, _pReg2)
-
-#define REGION_BREAK(_pScreen, _pReg) \
- miRegionBreak(_pReg)
-
-#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
-{ \
- if ((_rect) != NULL) \
- { \
- (_pReg)->extents = *(_rect); \
- (_pReg)->data = (RegDataPtr)NULL; \
- } \
- else \
- { \
- (_pReg)->extents = miEmptyBox; \
- if (((_size) > 1) && ((_pReg)->data = \
- (RegDataPtr)malloc(REGION_SZOF(_size)))) \
- { \
- (_pReg)->data->size = (_size); \
- (_pReg)->data->numRects = 0; \
- } \
- else \
- (_pReg)->data = &miEmptyData; \
- } \
- }
-
-
-#define REGION_UNINIT(_pScreen, _pReg) \
-{ \
- if ((_pReg)->data && (_pReg)->data->size) { \
- free((_pReg)->data); \
- (_pReg)->data = NULL; \
- } \
+
+static inline Bool RegionNar(RegionPtr reg) {
+ return ((reg)->data == &RegionBrokenData);
}
-#define REGION_RESET(_pScreen, _pReg, _pBox) \
-{ \
- (_pReg)->extents = *(_pBox); \
- REGION_UNINIT(_pScreen, _pReg); \
- (_pReg)->data = (RegDataPtr)NULL; \
+static inline int RegionNumRects(RegionPtr reg) {
+ return ((reg)->data ? (reg)->data->numRects : 1);
}
-#define REGION_NOTEMPTY(_pScreen, _pReg) \
- !REGION_NIL(_pReg)
+static inline int RegionSize(RegionPtr reg) {
+ return ((reg)->data ? (reg)->data->size : 0);
+}
-#define REGION_BROKEN(_pScreen, _pReg) \
- REGION_NAR(_pReg)
+static inline BoxPtr RegionRects(RegionPtr reg) {
+ return ((reg)->data ? (BoxPtr)((reg)->data + 1) : &(reg)->extents);
+}
-#define REGION_EMPTY(_pScreen, _pReg) \
-{ \
- REGION_UNINIT(_pScreen, _pReg); \
- (_pReg)->extents.x2 = (_pReg)->extents.x1; \
- (_pReg)->extents.y2 = (_pReg)->extents.y1; \
- (_pReg)->data = &miEmptyData; \
+static inline BoxPtr RegionBoxptr(RegionPtr reg) {
+ return ((BoxPtr)((reg)->data + 1));
}
-#define REGION_EXTENTS(_pScreen, _pReg) \
- (&(_pReg)->extents)
+static inline BoxPtr RegionBox(RegionPtr reg, int i) {
+ return (&RegionBoxptr(reg)[i]);
+}
-#define REGION_NULL(_pScreen, _pReg) \
-{ \
- (_pReg)->extents = miEmptyBox; \
- (_pReg)->data = &miEmptyData; \
+static inline BoxPtr RegionTop(RegionPtr reg) {
+ return RegionBox(reg, (reg)->data->numRects);
}
-#ifndef REGION_NULL
-#define REGION_NULL(_pScreen, _pReg) \
- REGION_INIT(_pScreen, _pReg, NullBox, 1)
-#endif
+static inline BoxPtr RegionEnd(RegionPtr reg) {
+ return RegionBox(reg, (reg)->data->numRects - 1);
+}
-/* moved from mi.h */
+static inline size_t RegionSizeof(int n) {
+ return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)));
+}
-extern _X_EXPORT void InitRegions (void);
+static inline void RegionInit(RegionPtr _pReg, BoxPtr _rect, int _size)
+{
+ if ((_rect) != NULL)
+ {
+ (_pReg)->extents = *(_rect);
+ (_pReg)->data = (RegDataPtr)NULL;
+ }
+ else
+ {
+ (_pReg)->extents = RegionEmptyBox;
+ if (((_size) > 1) && ((_pReg)->data =
+ (RegDataPtr)malloc(RegionSizeof(_size))))
+ {
+ (_pReg)->data->size = (_size);
+ (_pReg)->data->numRects = 0;
+ }
+ else
+ (_pReg)->data = &RegionEmptyData;
+ }
+}
-extern _X_EXPORT RegionPtr miRegionCreate(
- BoxPtr /*rect*/,
- int /*size*/);
+static inline void RegionUninit(RegionPtr _pReg)
+{
+ if ((_pReg)->data && (_pReg)->data->size) {
+ free((_pReg)->data);
+ (_pReg)->data = NULL;
+ }
+}
+
+static inline void RegionReset(RegionPtr _pReg, BoxPtr _pBox)
+{
+ (_pReg)->extents = *(_pBox);
+ RegionUninit(_pReg);
+ (_pReg)->data = (RegDataPtr)NULL;
+}
+
+static inline Bool RegionNotEmpty(RegionPtr _pReg) {
+ return !RegionNil(_pReg);
+}
+
+static inline Bool RegionBroken(RegionPtr _pReg) {
+ return RegionNar(_pReg);
+}
+
+static inline void RegionEmpty(RegionPtr _pReg)
+{
+ RegionUninit(_pReg);
+ (_pReg)->extents.x2 = (_pReg)->extents.x1;
+ (_pReg)->extents.y2 = (_pReg)->extents.y1;
+ (_pReg)->data = &RegionEmptyData;
+}
+
+static inline BoxPtr RegionExtents(RegionPtr _pReg)
+{
+ return (&(_pReg)->extents);
+}
-extern _X_EXPORT void miRegionInit(
- RegionPtr /*pReg*/,
+static inline void RegionNull(RegionPtr _pReg)
+{
+ (_pReg)->extents = RegionEmptyBox;
+ (_pReg)->data = &RegionEmptyData;
+}
+
+extern _X_EXPORT void InitRegions(void);
+
+extern _X_EXPORT RegionPtr RegionCreate(
BoxPtr /*rect*/,
int /*size*/);
-extern _X_EXPORT void miRegionDestroy(
+extern _X_EXPORT void RegionDestroy(
RegionPtr /*pReg*/);
-extern _X_EXPORT void miRegionUninit(
- RegionPtr /*pReg*/);
-
-extern _X_EXPORT Bool miRegionCopy(
- RegionPtr /*dst*/,
- RegionPtr /*src*/);
+static inline Bool
+RegionCopy(RegionPtr dst, RegionPtr src)
+{
+ return pixman_region_copy (dst, src);
+}
-extern _X_EXPORT Bool miIntersect(
- RegionPtr /*newReg*/,
- RegionPtr /*reg1*/,
- RegionPtr /*reg2*/);
+static inline Bool
+RegionIntersect(
+ RegionPtr newReg, /* destination Region */
+ RegionPtr reg1,
+ RegionPtr reg2 /* source regions */
+ )
+{
+ return pixman_region_intersect (newReg, reg1, reg2);
+}
-extern _X_EXPORT Bool miUnion(
- RegionPtr /*newReg*/,
- RegionPtr /*reg1*/,
- RegionPtr /*reg2*/);
+static inline Bool
+RegionUnion(
+ RegionPtr newReg, /* destination Region */
+ RegionPtr reg1,
+ RegionPtr reg2 /* source regions */
+ )
+{
+ return pixman_region_union (newReg, reg1, reg2);
+}
-extern _X_EXPORT Bool miRegionAppend(
+extern _X_EXPORT Bool RegionAppend(
RegionPtr /*dstrgn*/,
RegionPtr /*rgn*/);
-extern _X_EXPORT Bool miRegionValidate(
+extern _X_EXPORT Bool RegionValidate(
RegionPtr /*badreg*/,
Bool * /*pOverlap*/);
-extern _X_EXPORT RegionPtr miRectsToRegion(
+extern _X_EXPORT RegionPtr RegionFromRects(
int /*nrects*/,
xRectanglePtr /*prect*/,
int /*ctype*/);
-extern _X_EXPORT Bool miSubtract(
- RegionPtr /*regD*/,
- RegionPtr /*regM*/,
- RegionPtr /*regS*/);
+/*-
+ *-----------------------------------------------------------------------
+ * Subtract --
+ * Subtract regS from regM and leave the result in regD.
+ * S stands for subtrahend, M for minuend and D for difference.
+ *
+ * Results:
+ * TRUE if successful.
+ *
+ * Side Effects:
+ * regD is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+static inline Bool
+RegionSubtract(RegionPtr regD, RegionPtr regM, RegionPtr regS)
+{
+ return pixman_region_subtract (regD, regM, regS);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * Inverse --
+ * Take a region and a box and return a region that is everything
+ * in the box but not in the region. The careful reader will note
+ * that this is the same as subtracting the region from the box...
+ *
+ * Results:
+ * TRUE.
+ *
+ * Side Effects:
+ * newReg is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
-extern _X_EXPORT Bool miInverse(
- RegionPtr /*newReg*/,
- RegionPtr /*reg1*/,
- BoxPtr /*invRect*/);
+static inline Bool
+RegionInverse(
+ RegionPtr newReg, /* Destination region */
+ RegionPtr reg1, /* Region to invert */
+ BoxPtr invRect /* Bounding box for inversion */
+ )
+{
+ return pixman_region_inverse (newReg, reg1, invRect);
+}
-extern _X_EXPORT int miRectIn(
- RegionPtr /*region*/,
- BoxPtr /*prect*/);
+static inline int
+RegionContainsRect(RegionPtr region, BoxPtr prect)
+{
+ return pixman_region_contains_rectangle (region, prect);
+}
-extern _X_EXPORT void miTranslateRegion(
- RegionPtr /*pReg*/,
- int /*x*/,
- int /*y*/);
+/* TranslateRegion(pReg, x, y)
+ translates in place
+*/
-extern _X_EXPORT void miRegionReset(
- RegionPtr /*pReg*/,
- BoxPtr /*pBox*/);
+static inline void
+RegionTranslate(RegionPtr pReg, int x, int y)
+{
+ pixman_region_translate (pReg, x, y);
+}
-extern _X_EXPORT Bool miRegionBreak(
+extern _X_EXPORT Bool RegionBreak(
RegionPtr /*pReg*/);
-extern _X_EXPORT Bool miPointInRegion(
- RegionPtr /*pReg*/,
- int /*x*/,
- int /*y*/,
- BoxPtr /*box*/);
-
-extern _X_EXPORT Bool miRegionEqual(
- RegionPtr /*pReg1*/,
- RegionPtr /*pReg2*/);
+static inline Bool
+RegionContainsPoint(
+ RegionPtr pReg,
+ int x,
+ int y,
+ BoxPtr box /* "return" value */
+ )
+{
+ return pixman_region_contains_point (pReg, x, y, box);
+}
-extern _X_EXPORT Bool miRegionNotEmpty(
- RegionPtr /*pReg*/);
+static inline Bool
+RegionEqual(RegionPtr reg1, RegionPtr reg2)
+{
+ return pixman_region_equal (reg1, reg2);
+}
-extern _X_EXPORT void miRegionEmpty(
- RegionPtr /*pReg*/);
+extern _X_EXPORT Bool RegionRectAlloc(
+ RegionPtr /*pRgn*/,
+ int /*n*/
+);
-extern _X_EXPORT BoxPtr miRegionExtents(
- RegionPtr /*pReg*/);
+#ifdef DEBUG
+extern _X_EXPORT Bool RegionIsValid(
+ RegionPtr /*prgn*/
+);
+#endif
-extern _X_EXPORT void miPrintRegion(
+extern _X_EXPORT void RegionPrint(
RegionPtr /*pReg*/);
+extern _X_EXPORT int RegionClipSpans(
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ DDXPointPtr /*pptNew*/,
+ int * /*pwidthNew*/,
+ int /*fSorted*/
+);
+
+#define INCLUDE_LEGACY_REGION_DEFINES
+#ifdef INCLUDE_LEGACY_REGION_DEFINES
+
+#define REGION_NIL RegionNil
+#define REGION_NAR RegionNar
+#define REGION_NUM_RECTS RegionNumRects
+#define REGION_SIZE RegionSize
+#define REGION_RECTS RegionRects
+#define REGION_BOXPTR RegionBoxptr
+#define REGION_BOX RegionBox
+#define REGION_TOP RegionTop
+#define REGION_END RegionEnd
+#define REGION_SZOF RegionSizeof
+#define BITMAP_TO_REGION BitmapToRegion
+#define REGION_CREATE(pScreen, r, s) RegionCreate(r,s)
+#define REGION_COPY(pScreen, d, r) RegionCopy(d, r)
+#define REGION_DESTROY(pScreen, r) RegionDestroy(r)
+#define REGION_INTERSECT(pScreen, res, r1, r2) RegionIntersect(res, r1, r2)
+#define REGION_UNION(pScreen, res, r1, r2) RegionUnion(res, r1, r2)
+#define REGION_SUBTRACT(pScreen, res, r1, r2) RegionSubtract(res, r1, r2)
+#define REGION_INVERSE(pScreen, n, r, b) RegionInverse(n, r, b)
+#define REGION_TRANSLATE(pScreen, r, x, y) RegionTranslate(r, x, y)
+#define RECT_IN_REGION(pScreen, r, b) RegionContainsRect(r, b)
+#define POINT_IN_REGION(pScreen, r, x, y, b) RegionContainsPoint(r, x, y, b)
+#define REGION_EQUAL(pScreen, r1, r2) RegionEqual(r1, r2)
+#define REGION_APPEND(pScreen, d, r) RegionAppend(d, r)
+#define REGION_VALIDATE(pScreen, r, o) RegionValidate(r, o)
+#define RECTS_TO_REGION(pScreen, n, r, c) RegionFromRects(n, r, c)
+#define REGION_BREAK(pScreen, r) RegionBreak(r)
+#define REGION_INIT(pScreen, r, b, s) RegionInit(r, b, s)
+#define REGION_UNINIT(pScreen, r) RegionUninit(r)
+#define REGION_RESET(pScreen, r, b) RegionReset(r, b)
+#define REGION_NOTEMPTY(pScreen, r) RegionNotEmpty(r)
+#define REGION_BROKEN(pScreen, r) RegionBroken(r)
+#define REGION_EMPTY(pScreen, r) RegionEmpty(r)
+#define REGION_EXTENTS(pScreen, r) RegionExtents(r)
+#define REGION_NULL(pScreen, r) RegionNull(r)
+
+#endif /* INCLUDE_LEGACY_REGION_DEFINES */
#endif /* REGIONSTRUCT_H */
diff --git a/xorg-server/include/scrnintstr.h b/xorg-server/include/scrnintstr.h index 705dff3ec..a39dd6107 100644 --- a/xorg-server/include/scrnintstr.h +++ b/xorg-server/include/scrnintstr.h @@ -82,6 +82,16 @@ typedef struct _Depth { VisualID *vids; /* block of visual ids for this depth */
} DepthRec;
+typedef struct _ScreenSaverStuff {
+ WindowPtr pWindow;
+ XID wid;
+ char blanked;
+ Bool (*ExternalScreenSaver)(
+ ScreenPtr /*pScreen*/,
+ int /*xstate*/,
+ Bool /*force*/);
+} ScreenSaverStuffRec;
+
/*
* There is a typedef for each screen function pointer so that code that
@@ -386,7 +396,7 @@ typedef void (* PostChangeSaveUnderProcPtr)( WindowPtr /*pLayerWin*/,
WindowPtr /*firstChild*/);
-typedef void (* ConfigNotifyProcPtr)(
+typedef int (* ConfigNotifyProcPtr)(
WindowPtr /*pWin*/,
int /*x*/,
int /*y*/,
@@ -423,7 +433,8 @@ typedef void (* ReparentWindowProcPtr)( WindowPtr /*pPriorParent*/);
typedef void (* SetShapeProcPtr)(
- WindowPtr /*pWin*/);
+ WindowPtr /*pWin*/,
+ int /* kind */);
typedef void (* ChangeBorderWidthProcPtr)(
WindowPtr /*pWin*/,
@@ -449,7 +460,7 @@ typedef void (* DeviceCursorCleanupProcPtr)( typedef struct _Screen {
int myNum; /* index of this instance in Screens[] */
ATOM id;
- short width, height;
+ short x, y, width, height;
short mmWidth, mmHeight;
short numDepths;
unsigned char rootDepth;
@@ -471,6 +482,8 @@ typedef struct _Screen { pointer devPrivate;
short numVisuals;
VisualPtr visuals;
+ WindowPtr root;
+ ScreenSaverStuffRec screensaver;
/* Random screen procedures */
@@ -594,6 +607,10 @@ typedef struct _Screen { DeviceCursorCleanupProcPtr DeviceCursorCleanup;
} ScreenRec;
+static inline RegionPtr BitmapToRegion(ScreenPtr _pScreen, PixmapPtr pPix) {
+ return (*(_pScreen)->BitmapToRegion)(pPix); /* no mi version?! */
+}
+
typedef struct _ScreenInfo {
int imageByteOrder;
int bitmapScanlineUnit;
diff --git a/xorg-server/include/windowstr.h b/xorg-server/include/windowstr.h index 94e04ead2..b86b39bc2 100644 --- a/xorg-server/include/windowstr.h +++ b/xorg-server/include/windowstr.h @@ -1,227 +1,218 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - -#ifndef WINDOWSTRUCT_H -#define WINDOWSTRUCT_H - -#include "window.h" -#include "pixmapstr.h" -#include "regionstr.h" -#include "cursor.h" -#include "property.h" -#include "resource.h" /* for ROOT_WINDOW_ID_BASE */ -#include "dix.h" -#include "privates.h" -#include "miscstruct.h" -#include <X11/Xprotostr.h> -#include "opaque.h" - -#define GuaranteeNothing 0 -#define GuaranteeVisBack 1 - -#define SameBackground(as, a, bs, b) \ - ((as) == (bs) && ((as) == None || \ - (as) == ParentRelative || \ - SamePixUnion(a,b,as == BackgroundPixel))) - -#define SameBorder(as, a, bs, b) \ - EqualPixUnion(as, a, bs, b) - -/* used as NULL-terminated list */ -typedef struct _DevCursorNode { - CursorPtr cursor; - DeviceIntPtr dev; - struct _DevCursorNode* next; -} DevCursNodeRec, *DevCursNodePtr, *DevCursorList; - -typedef struct _WindowOpt { - VisualID visual; /* default: same as parent */ - CursorPtr cursor; /* default: window.cursorNone */ - Colormap colormap; /* default: same as parent */ - Mask dontPropagateMask; /* default: window.dontPropagate */ - Mask otherEventMasks; /* default: 0 */ - struct _OtherClients *otherClients; /* default: NULL */ - struct _GrabRec *passiveGrabs; /* default: NULL */ - PropertyPtr userProps; /* default: NULL */ - unsigned long backingBitPlanes; /* default: ~0L */ - unsigned long backingPixel; /* default: 0 */ - RegionPtr boundingShape; /* default: NULL */ - RegionPtr clipShape; /* default: NULL */ - RegionPtr inputShape; /* default: NULL */ - struct _OtherInputMasks *inputMasks; /* default: NULL */ - DevCursorList deviceCursors; /* default: NULL */ -} WindowOptRec, *WindowOptPtr; - -#define BackgroundPixel 2L -#define BackgroundPixmap 3L - -/* - * The redirectDraw field can have one of three values: - * - * RedirectDrawNone - * A normal window; painted into the same pixmap as the parent - * and clipping parent and siblings to its geometry. These - * windows get a clip list equal to the intersection of their - * geometry with the parent geometry, minus the geometry - * of overlapping None and Clipped siblings. - * RedirectDrawAutomatic - * A redirected window which clips parent and sibling drawing. - * Contents for these windows are manage inside the server. - * These windows get an internal clip list equal to their - * geometry. - * RedirectDrawManual - * A redirected window which does not clip parent and sibling - * drawing; the window must be represented within the parent - * geometry by the client performing the redirection management. - * Contents for these windows are managed outside the server. - * These windows get an internal clip list equal to their - * geometry. - */ - -#define RedirectDrawNone 0 -#define RedirectDrawAutomatic 1 -#define RedirectDrawManual 2 - -typedef struct _Window { - DrawableRec drawable; - PrivateRec *devPrivates; - WindowPtr parent; /* ancestor chain */ - WindowPtr nextSib; /* next lower sibling */ - WindowPtr prevSib; /* next higher sibling */ - WindowPtr firstChild; /* top-most child */ - WindowPtr lastChild; /* bottom-most child */ - RegionRec clipList; /* clipping rectangle for output */ - RegionRec borderClip; /* NotClippedByChildren + border */ - union _Validate *valdata; - RegionRec winSize; - RegionRec borderSize; - DDXPointRec origin; /* position relative to parent */ - unsigned short borderWidth; - unsigned long deliverableEvents; /* all masks from all clients */ - Mask eventMask; /* mask from the creating client */ - PixUnion background; - PixUnion border; - pointer backStorage; /* null when BS disabled */ - WindowOptPtr optional; - unsigned backgroundState:2; /* None, Relative, Pixel, Pixmap */ - unsigned borderIsPixel:1; - unsigned cursorIsNone:1; /* else real cursor (might inherit) */ - unsigned backingStore:2; - unsigned saveUnder:1; - unsigned DIXsaveUnder:1; - unsigned bitGravity:4; - unsigned winGravity:4; - unsigned overrideRedirect:1; - unsigned visibility:2; - unsigned mapped:1; - unsigned realized:1; /* ancestors are all mapped */ - unsigned viewable:1; /* realized && InputOutput */ - unsigned dontPropagate:3;/* index into DontPropagateMasks */ - unsigned forcedBS:1; /* system-supplied backingStore */ - unsigned redirectDraw:2; /* COMPOSITE rendering redirect */ - unsigned forcedBG:1; /* must have an opaque background */ -#ifdef ROOTLESS - unsigned rootlessUnhittable:1; /* doesn't hit-test */ -#endif -} WindowRec; - -/* - * Ok, a bunch of macros for accessing the optional record - * fields (or filling the appropriate default value) - */ - -extern _X_EXPORT Mask DontPropagateMasks[]; - -#define wTrackParent(w,field) ((w)->optional ? \ - (w)->optional->field \ - : FindWindowWithOptional(w)->optional->field) -#define wUseDefault(w,field,def) ((w)->optional ? \ - (w)->optional->field \ - : def) - -#define wVisual(w) wTrackParent(w, visual) -#define wCursor(w) ((w)->cursorIsNone ? None : wTrackParent(w, cursor)) -#define wColormap(w) ((w)->drawable.class == InputOnly ? None : wTrackParent(w, colormap)) -#define wDontPropagateMask(w) wUseDefault(w, dontPropagateMask, DontPropagateMasks[(w)->dontPropagate]) -#define wOtherEventMasks(w) wUseDefault(w, otherEventMasks, 0) -#define wOtherClients(w) wUseDefault(w, otherClients, NULL) -#define wOtherInputMasks(w) wUseDefault(w, inputMasks, NULL) -#define wPassiveGrabs(w) wUseDefault(w, passiveGrabs, NULL) -#define wUserProps(w) wUseDefault(w, userProps, NULL) -#define wBackingBitPlanes(w) wUseDefault(w, backingBitPlanes, ~0L) -#define wBackingPixel(w) wUseDefault(w, backingPixel, 0) -#define wBoundingShape(w) wUseDefault(w, boundingShape, NULL) -#define wClipShape(w) wUseDefault(w, clipShape, NULL) -#define wInputShape(w) wUseDefault(w, inputShape, NULL) -#define wClient(w) (clients[CLIENT_ID((w)->drawable.id)]) -#define wBorderWidth(w) ((int) (w)->borderWidth) - -/* true when w needs a border drawn. */ - -#define HasBorder(w) ((w)->borderWidth || wClipShape(w)) - -typedef struct _ScreenSaverStuff { - WindowPtr pWindow; - XID wid; - char blanked; - Bool (*ExternalScreenSaver)( - ScreenPtr /*pScreen*/, - int /*xstate*/, - Bool /*force*/); -} ScreenSaverStuffRec, *ScreenSaverStuffPtr; - -#define SCREEN_IS_BLANKED 0 -#define SCREEN_ISNT_SAVED 1 -#define SCREEN_IS_TILED 2 -#define SCREEN_IS_BLACK 3 - -#define HasSaverWindow(i) (savedScreenInfo[i].pWindow != NullWindow) - -extern _X_EXPORT int screenIsSaved; -extern _X_EXPORT ScreenSaverStuffRec savedScreenInfo[MAXSCREENS]; - -#endif /* WINDOWSTRUCT_H */ +/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef WINDOWSTRUCT_H
+#define WINDOWSTRUCT_H
+
+#include "window.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "cursor.h"
+#include "property.h"
+#include "resource.h" /* for ROOT_WINDOW_ID_BASE */
+#include "dix.h"
+#include "privates.h"
+#include "miscstruct.h"
+#include <X11/Xprotostr.h>
+#include "opaque.h"
+
+#define GuaranteeNothing 0
+#define GuaranteeVisBack 1
+
+#define SameBackground(as, a, bs, b) \
+ ((as) == (bs) && ((as) == None || \
+ (as) == ParentRelative || \
+ SamePixUnion(a,b,as == BackgroundPixel)))
+
+#define SameBorder(as, a, bs, b) \
+ EqualPixUnion(as, a, bs, b)
+
+/* used as NULL-terminated list */
+typedef struct _DevCursorNode {
+ CursorPtr cursor;
+ DeviceIntPtr dev;
+ struct _DevCursorNode* next;
+} DevCursNodeRec, *DevCursNodePtr, *DevCursorList;
+
+typedef struct _WindowOpt {
+ VisualID visual; /* default: same as parent */
+ CursorPtr cursor; /* default: window.cursorNone */
+ Colormap colormap; /* default: same as parent */
+ Mask dontPropagateMask; /* default: window.dontPropagate */
+ Mask otherEventMasks; /* default: 0 */
+ struct _OtherClients *otherClients; /* default: NULL */
+ struct _GrabRec *passiveGrabs; /* default: NULL */
+ PropertyPtr userProps; /* default: NULL */
+ unsigned long backingBitPlanes; /* default: ~0L */
+ unsigned long backingPixel; /* default: 0 */
+ RegionPtr boundingShape; /* default: NULL */
+ RegionPtr clipShape; /* default: NULL */
+ RegionPtr inputShape; /* default: NULL */
+ struct _OtherInputMasks *inputMasks; /* default: NULL */
+ DevCursorList deviceCursors; /* default: NULL */
+} WindowOptRec, *WindowOptPtr;
+
+#define BackgroundPixel 2L
+#define BackgroundPixmap 3L
+
+/*
+ * The redirectDraw field can have one of three values:
+ *
+ * RedirectDrawNone
+ * A normal window; painted into the same pixmap as the parent
+ * and clipping parent and siblings to its geometry. These
+ * windows get a clip list equal to the intersection of their
+ * geometry with the parent geometry, minus the geometry
+ * of overlapping None and Clipped siblings.
+ * RedirectDrawAutomatic
+ * A redirected window which clips parent and sibling drawing.
+ * Contents for these windows are manage inside the server.
+ * These windows get an internal clip list equal to their
+ * geometry.
+ * RedirectDrawManual
+ * A redirected window which does not clip parent and sibling
+ * drawing; the window must be represented within the parent
+ * geometry by the client performing the redirection management.
+ * Contents for these windows are managed outside the server.
+ * These windows get an internal clip list equal to their
+ * geometry.
+ */
+
+#define RedirectDrawNone 0
+#define RedirectDrawAutomatic 1
+#define RedirectDrawManual 2
+
+typedef struct _Window {
+ DrawableRec drawable;
+ PrivateRec *devPrivates;
+ WindowPtr parent; /* ancestor chain */
+ WindowPtr nextSib; /* next lower sibling */
+ WindowPtr prevSib; /* next higher sibling */
+ WindowPtr firstChild; /* top-most child */
+ WindowPtr lastChild; /* bottom-most child */
+ RegionRec clipList; /* clipping rectangle for output */
+ RegionRec borderClip; /* NotClippedByChildren + border */
+ union _Validate *valdata;
+ RegionRec winSize;
+ RegionRec borderSize;
+ DDXPointRec origin; /* position relative to parent */
+ unsigned short borderWidth;
+ unsigned long deliverableEvents; /* all masks from all clients */
+ Mask eventMask; /* mask from the creating client */
+ PixUnion background;
+ PixUnion border;
+ pointer backStorage; /* null when BS disabled */
+ WindowOptPtr optional;
+ unsigned backgroundState:2; /* None, Relative, Pixel, Pixmap */
+ unsigned borderIsPixel:1;
+ unsigned cursorIsNone:1; /* else real cursor (might inherit) */
+ unsigned backingStore:2;
+ unsigned saveUnder:1;
+ unsigned DIXsaveUnder:1;
+ unsigned bitGravity:4;
+ unsigned winGravity:4;
+ unsigned overrideRedirect:1;
+ unsigned visibility:2;
+ unsigned mapped:1;
+ unsigned realized:1; /* ancestors are all mapped */
+ unsigned viewable:1; /* realized && InputOutput */
+ unsigned dontPropagate:3;/* index into DontPropagateMasks */
+ unsigned forcedBS:1; /* system-supplied backingStore */
+ unsigned redirectDraw:2; /* COMPOSITE rendering redirect */
+ unsigned forcedBG:1; /* must have an opaque background */
+#ifdef ROOTLESS
+ unsigned rootlessUnhittable:1; /* doesn't hit-test */
+#endif
+} WindowRec;
+
+/*
+ * Ok, a bunch of macros for accessing the optional record
+ * fields (or filling the appropriate default value)
+ */
+
+extern _X_EXPORT Mask DontPropagateMasks[];
+
+#define wTrackParent(w,field) ((w)->optional ? \
+ (w)->optional->field \
+ : FindWindowWithOptional(w)->optional->field)
+#define wUseDefault(w,field,def) ((w)->optional ? \
+ (w)->optional->field \
+ : def)
+
+#define wVisual(w) wTrackParent(w, visual)
+#define wCursor(w) ((w)->cursorIsNone ? None : wTrackParent(w, cursor))
+#define wColormap(w) ((w)->drawable.class == InputOnly ? None : wTrackParent(w, colormap))
+#define wDontPropagateMask(w) wUseDefault(w, dontPropagateMask, DontPropagateMasks[(w)->dontPropagate])
+#define wOtherEventMasks(w) wUseDefault(w, otherEventMasks, 0)
+#define wOtherClients(w) wUseDefault(w, otherClients, NULL)
+#define wOtherInputMasks(w) wUseDefault(w, inputMasks, NULL)
+#define wPassiveGrabs(w) wUseDefault(w, passiveGrabs, NULL)
+#define wUserProps(w) wUseDefault(w, userProps, NULL)
+#define wBackingBitPlanes(w) wUseDefault(w, backingBitPlanes, ~0L)
+#define wBackingPixel(w) wUseDefault(w, backingPixel, 0)
+#define wBoundingShape(w) wUseDefault(w, boundingShape, NULL)
+#define wClipShape(w) wUseDefault(w, clipShape, NULL)
+#define wInputShape(w) wUseDefault(w, inputShape, NULL)
+#define wClient(w) (clients[CLIENT_ID((w)->drawable.id)])
+#define wBorderWidth(w) ((int) (w)->borderWidth)
+
+/* true when w needs a border drawn. */
+
+#define HasBorder(w) ((w)->borderWidth || wClipShape(w))
+
+typedef struct _ScreenSaverStuff *ScreenSaverStuffPtr;
+
+#define SCREEN_IS_BLANKED 0
+#define SCREEN_ISNT_SAVED 1
+#define SCREEN_IS_TILED 2
+#define SCREEN_IS_BLACK 3
+
+#define HasSaverWindow(pScreen) (pScreen->screensaver.pWindow != NullWindow)
+
+extern _X_EXPORT int screenIsSaved;
+
+#endif /* WINDOWSTRUCT_H */
diff --git a/xorg-server/include/xkbsrv.h b/xorg-server/include/xkbsrv.h index 7a93ccfcd..2648ff51a 100644 --- a/xorg-server/include/xkbsrv.h +++ b/xorg-server/include/xkbsrv.h @@ -275,7 +275,9 @@ typedef struct device->public.realInputProc = oldprocs->realInputProc; \
device->unwrapProc = oldprocs->unwrapProc;
-extern DevPrivateKey xkbDevicePrivateKey;
+extern _X_EXPORT DevPrivateKeyRec xkbDevicePrivateKeyRec;
+#define xkbDevicePrivateKey (&xkbDevicePrivateKeyRec)
+
#define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr)dixLookupPrivate(&(dev)->devPrivates, xkbDevicePrivateKey))
extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer);
@@ -319,6 +321,8 @@ extern _X_EXPORT int XkbProcessArguments( int /* i */
);
+extern _X_EXPORT Bool XkbInitPrivates(void);
+
extern _X_EXPORT void XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc);
extern _X_EXPORT void XkbFreeCompatMap(
diff --git a/xorg-server/include/xorg-config.h.in b/xorg-server/include/xorg-config.h.in index 8946a6538..f2494af78 100644 --- a/xorg-server/include/xorg-config.h.in +++ b/xorg-server/include/xorg-config.h.in @@ -1,142 +1,145 @@ -/* xorg-config.h.in: not at all generated. -*- c -*- - * - * This file differs from xorg-server.h.in in that -server is installed - * with the rest of the SDK for external drivers/modules to use, whereas - * -config is for internal use only (i.e. building the DDX). - * - */ - -#ifndef _XORG_CONFIG_H_ -#define _XORG_CONFIG_H_ - -#include <dix-config.h> -#include <xkb-config.h> - -/* Building Xorg server. */ -#undef XORGSERVER - -/* Current X.Org version. */ -#undef XORG_VERSION_CURRENT - -/* Name of X server. */ -#undef __XSERVERNAME__ - -/* URL to go to for support. */ -#undef __VENDORDWEBSUPPORT__ - -/* Built-in output drivers. */ -#undef DRIVERS - -/* Built-in input drivers. */ -#undef IDRIVERS - -/* Path to configuration file. */ -#undef XF86CONFIGFILE - -/* Path to configuration file. */ -#undef __XCONFIGFILE__ - -/* Name of configuration directory. */ -#undef __XCONFIGDIR__ - -/* Path to loadable modules. */ -#undef DEFAULT_MODULE_PATH - -/* Path to installed libraries. */ -#undef DEFAULT_LIBRARY_PATH - -/* Path to server log file. */ -#undef DEFAULT_LOGPREFIX - -/* Building DRI-capable DDX. */ -#undef XF86DRI - -/* Build DRI2 extension */ -#undef DRI2 - -/* Define to 1 if you have the <stropts.h> header file. */ -#undef HAVE_STROPTS_H - -/* Define to 1 if you have the <sys/kd.h> header file. */ -#undef HAVE_SYS_KD_H - -/* Define to 1 if you have the <sys/vt.h> header file. */ -#undef HAVE_SYS_VT_H - -/* Define to 1 if you have the `walkcontext' function (used on Solaris for - xorg_backtrace in hw/xfree86/common/xf86Events.c */ -#undef HAVE_WALKCONTEXT - -/* Define to 1 if unsigned long is 64 bits. */ -#undef _XSERVER64 - -/* Building vgahw module */ -#undef WITH_VGAHW - -/* Define to 1 if NetBSD built-in MTRR support is available */ -#undef HAS_MTRR_BUILTIN - -/* Define to 1 if BSD MTRR support is available */ -#undef HAS_MTRR_SUPPORT - -/* NetBSD PIO alpha IO */ -#undef USE_ALPHA_PIO - -/* BSD AMD64 iopl */ -#undef USE_AMD64_IOPL - -/* BSD /dev/io */ -#undef USE_DEV_IO - -/* BSD i386 iopl */ -#undef USE_I386_IOPL - -/* System is BSD-like */ -#undef CSRG_BASED - -/* System has PC console */ -#undef PCCONS_SUPPORT - -/* System has PCVT console */ -#undef PCVT_SUPPORT - -/* System has syscons console */ -#undef SYSCONS_SUPPORT - -/* System has wscons console */ -#undef WSCONS_SUPPORT - -/* System has /dev/xf86 aperture driver */ -#undef HAS_APERTURE_DRV - -/* Has backtrace support */ -#undef HAVE_BACKTRACE - -/* Name of the period field in struct kbd_repeat */ -#undef LNX_KBD_PERIOD_NAME - -/* Have execinfo.h */ -#undef HAVE_EXECINFO_H - -/* Have pci_system_init_dev_mem() */ -#undef HAVE_PCI_SYSTEM_INIT_DEV_MEM - -/* Define to 1 if you have the `pci_device_is_boot_vga' function. */ -#undef HAVE_PCI_DEVICE_IS_BOOT_VGA - -/* Have pci_enable_device */ -#undef HAVE_PCI_DEVICE_ENABLE - -/* Define to 1 if you have the `pci_device_vgaarb_init' function. */ -#undef HAVE_PCI_DEVICE_VGAARB_INIT - -/* Path to text files containing PCI IDs */ -#undef PCI_TXT_IDS_PATH - -/* Use SIGIO handlers for input device events by default */ -#undef USE_SIGIO_BY_DEFAULT - -/* Support PC98 */ -#undef SUPPORT_PC98 - -#endif /* _XORG_CONFIG_H_ */ +/* xorg-config.h.in: not at all generated. -*- c -*-
+ *
+ * This file differs from xorg-server.h.in in that -server is installed
+ * with the rest of the SDK for external drivers/modules to use, whereas
+ * -config is for internal use only (i.e. building the DDX).
+ *
+ */
+
+#ifndef _XORG_CONFIG_H_
+#define _XORG_CONFIG_H_
+
+#include <dix-config.h>
+#include <xkb-config.h>
+
+/* Building Xorg server. */
+#undef XORGSERVER
+
+/* Current X.Org version. */
+#undef XORG_VERSION_CURRENT
+
+/* Name of X server. */
+#undef __XSERVERNAME__
+
+/* URL to go to for support. */
+#undef __VENDORDWEBSUPPORT__
+
+/* Built-in output drivers. */
+#undef DRIVERS
+
+/* Built-in input drivers. */
+#undef IDRIVERS
+
+/* Path to configuration file. */
+#undef XF86CONFIGFILE
+
+/* Path to configuration file. */
+#undef __XCONFIGFILE__
+
+/* Name of configuration directory. */
+#undef __XCONFIGDIR__
+
+/* Path to loadable modules. */
+#undef DEFAULT_MODULE_PATH
+
+/* Path to installed libraries. */
+#undef DEFAULT_LIBRARY_PATH
+
+/* Path to server log file. */
+#undef DEFAULT_LOGPREFIX
+
+/* Building DRI-capable DDX. */
+#undef XF86DRI
+
+/* Build DRI2 extension */
+#undef DRI2
+
+/* Define to 1 if you have the <stropts.h> header file. */
+#undef HAVE_STROPTS_H
+
+/* Define to 1 if you have the <sys/kd.h> header file. */
+#undef HAVE_SYS_KD_H
+
+/* Define to 1 if you have the <sys/vt.h> header file. */
+#undef HAVE_SYS_VT_H
+
+/* Define to 1 if you have the `walkcontext' function (used on Solaris for
+ xorg_backtrace in hw/xfree86/common/xf86Events.c */
+#undef HAVE_WALKCONTEXT
+
+/* Define to 1 if unsigned long is 64 bits. */
+#undef _XSERVER64
+
+/* Building vgahw module */
+#undef WITH_VGAHW
+
+/* Define to 1 if NetBSD built-in MTRR support is available */
+#undef HAS_MTRR_BUILTIN
+
+/* Define to 1 if BSD MTRR support is available */
+#undef HAS_MTRR_SUPPORT
+
+/* NetBSD PIO alpha IO */
+#undef USE_ALPHA_PIO
+
+/* BSD AMD64 iopl */
+#undef USE_AMD64_IOPL
+
+/* BSD /dev/io */
+#undef USE_DEV_IO
+
+/* BSD i386 iopl */
+#undef USE_I386_IOPL
+
+/* System is BSD-like */
+#undef CSRG_BASED
+
+/* System has PC console */
+#undef PCCONS_SUPPORT
+
+/* System has PCVT console */
+#undef PCVT_SUPPORT
+
+/* System has syscons console */
+#undef SYSCONS_SUPPORT
+
+/* System has wscons console */
+#undef WSCONS_SUPPORT
+
+/* System has /dev/xf86 aperture driver */
+#undef HAS_APERTURE_DRV
+
+/* Has backtrace support */
+#undef HAVE_BACKTRACE
+
+/* Name of the period field in struct kbd_repeat */
+#undef LNX_KBD_PERIOD_NAME
+
+/* Have execinfo.h */
+#undef HAVE_EXECINFO_H
+
+/* Have pci_system_init_dev_mem() */
+#undef HAVE_PCI_SYSTEM_INIT_DEV_MEM
+
+/* Define to 1 if you have the `pci_device_is_boot_vga' function. */
+#undef HAVE_PCI_DEVICE_IS_BOOT_VGA
+
+/* Have pci_enable_device */
+#undef HAVE_PCI_DEVICE_ENABLE
+
+/* Define to 1 if you have the `pci_device_vgaarb_init' function. */
+#undef HAVE_PCI_DEVICE_VGAARB_INIT
+
+/* Path to text files containing PCI IDs */
+#undef PCI_TXT_IDS_PATH
+
+/* Use SIGIO handlers for input device events by default */
+#undef USE_SIGIO_BY_DEFAULT
+
+/* Support PC98 */
+#undef SUPPORT_PC98
+
+/* Build with libdrm support */
+#undef WITH_LIBDRM
+
+#endif /* _XORG_CONFIG_H_ */
diff --git a/xorg-server/include/xserver-properties.h b/xorg-server/include/xserver-properties.h index 30e8efb68..d3dc976fd 100644 --- a/xorg-server/include/xserver-properties.h +++ b/xorg-server/include/xserver-properties.h @@ -1,184 +1,191 @@ -/* - * Copyright 2008 Red Hat, Inc. - * - * 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 - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * them Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) 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 MERCHANTIBILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS 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. - */ - - -/* Properties managed by the server. */ - -#ifndef _XSERVER_PROPERTIES_H_ -#define _XSERVER_PROPERTIES_H_ - -/* Type for a 4 byte float. Storage format IEEE 754 in client's default - * byte-ordering. */ -#define XATOM_FLOAT "FLOAT" - -/* BOOL. 0 - device disabled, 1 - device enabled */ -#define XI_PROP_ENABLED "Device Enabled" -/* BOOL. If present, device is a virtual XTEST device */ -#define XI_PROP_XTEST_DEVICE "XTEST Device" - -/* Pointer acceleration properties */ -/* INTEGER of any format */ -#define ACCEL_PROP_PROFILE_NUMBER "Device Accel Profile" -/* FLOAT, format 32 */ -#define ACCEL_PROP_CONSTANT_DECELERATION "Device Accel Constant Deceleration" -/* FLOAT, format 32 */ -#define ACCEL_PROP_ADAPTIVE_DECELERATION "Device Accel Adaptive Deceleration" -/* FLOAT, format 32 */ -#define ACCEL_PROP_VELOCITY_SCALING "Device Accel Velocity Scaling" - - -/* Axis labels */ -#define AXIS_LABEL_PROP "Axis Labels" - -#define AXIS_LABEL_PROP_REL_X "Rel X" -#define AXIS_LABEL_PROP_REL_Y "Rel Y" -#define AXIS_LABEL_PROP_REL_Z "Rel Z" -#define AXIS_LABEL_PROP_REL_RX "Rel Rotary X" -#define AXIS_LABEL_PROP_REL_RY "Rel Rotary Y" -#define AXIS_LABEL_PROP_REL_RZ "Rel Rotary Z" -#define AXIS_LABEL_PROP_REL_HWHEEL "Rel Horiz Wheel" -#define AXIS_LABEL_PROP_REL_DIAL "Rel Dial" -#define AXIS_LABEL_PROP_REL_WHEEL "Rel Vert Wheel" -#define AXIS_LABEL_PROP_REL_MISC "Rel Misc" - -/* - * Absolute axes - */ - -#define AXIS_LABEL_PROP_ABS_X "Abs X" -#define AXIS_LABEL_PROP_ABS_Y "Abs Y" -#define AXIS_LABEL_PROP_ABS_Z "Abs Z" -#define AXIS_LABEL_PROP_ABS_RX "Abs Rotary X" -#define AXIS_LABEL_PROP_ABS_RY "Abs Rotary Y" -#define AXIS_LABEL_PROP_ABS_RZ "Abs Rotary Z" -#define AXIS_LABEL_PROP_ABS_THROTTLE "Abs Throttle" -#define AXIS_LABEL_PROP_ABS_RUDDER "Abs Rudder" -#define AXIS_LABEL_PROP_ABS_WHEEL "Abs Wheel" -#define AXIS_LABEL_PROP_ABS_GAS "Abs Gas" -#define AXIS_LABEL_PROP_ABS_BRAKE "Abs Brake" -#define AXIS_LABEL_PROP_ABS_HAT0X "Abs Hat 0 X" -#define AXIS_LABEL_PROP_ABS_HAT0Y "Abs Hat 0 Y" -#define AXIS_LABEL_PROP_ABS_HAT1X "Abs Hat 1 X" -#define AXIS_LABEL_PROP_ABS_HAT1Y "Abs Hat 1 Y" -#define AXIS_LABEL_PROP_ABS_HAT2X "Abs Hat 2 X" -#define AXIS_LABEL_PROP_ABS_HAT2Y "Abs Hat 2 Y" -#define AXIS_LABEL_PROP_ABS_HAT3X "Abs Hat 3 X" -#define AXIS_LABEL_PROP_ABS_HAT3Y "Abs Hat 3 Y" -#define AXIS_LABEL_PROP_ABS_PRESSURE "Abs Pressure" -#define AXIS_LABEL_PROP_ABS_DISTANCE "Abs Distance" -#define AXIS_LABEL_PROP_ABS_TILT_X "Abs Tilt X" -#define AXIS_LABEL_PROP_ABS_TILT_Y "Abs Tilt Y" -#define AXIS_LABEL_PROP_ABS_TOOL_WIDTH "Abs Tool Width" -#define AXIS_LABEL_PROP_ABS_VOLUME "Abs Volume" -#define AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR "Abs MT Touch Major" -#define AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR "Abs MT Touch Minor" -#define AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR "Abs MT Width Major" -#define AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR "Abs MT Width Minor" -#define AXIS_LABEL_PROP_ABS_MT_ORIENTATION "Abs MT Orientation" -#define AXIS_LABEL_PROP_ABS_MT_POSITION_X "Abs MT Position X" -#define AXIS_LABEL_PROP_ABS_MT_POSITION_Y "Abs MT Position Y" -#define AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE "Abs MT Tool Type" -#define AXIS_LABEL_PROP_ABS_MT_BLOB_ID "Abs MT Blob ID" -#define AXIS_LABEL_PROP_ABS_MT_TRACKING_ID "Abs MT Tracking ID" -#define AXIS_LABEL_PROP_ABS_MT_PRESSURE "Abs MT Pressure" -#define AXIS_LABEL_PROP_ABS_MISC "Abs Misc" - -/* Button names */ -#define BTN_LABEL_PROP "Button Labels" - -/* Default label */ -#define BTN_LABEL_PROP_BTN_UNKNOWN "Button Unknown" -/* Wheel buttons */ -#define BTN_LABEL_PROP_BTN_WHEEL_UP "Button Wheel Up" -#define BTN_LABEL_PROP_BTN_WHEEL_DOWN "Button Wheel Down" -#define BTN_LABEL_PROP_BTN_HWHEEL_LEFT "Button Horiz Wheel Left" -#define BTN_LABEL_PROP_BTN_HWHEEL_RIGHT "Button Horiz Wheel Right" - -/* The following are from linux/input.h */ -#define BTN_LABEL_PROP_BTN_0 "Button 0" -#define BTN_LABEL_PROP_BTN_1 "Button 1" -#define BTN_LABEL_PROP_BTN_2 "Button 2" -#define BTN_LABEL_PROP_BTN_3 "Button 3" -#define BTN_LABEL_PROP_BTN_4 "Button 4" -#define BTN_LABEL_PROP_BTN_5 "Button 5" -#define BTN_LABEL_PROP_BTN_6 "Button 6" -#define BTN_LABEL_PROP_BTN_7 "Button 7" -#define BTN_LABEL_PROP_BTN_8 "Button 8" -#define BTN_LABEL_PROP_BTN_9 "Button 9" - -#define BTN_LABEL_PROP_BTN_LEFT "Button Left" -#define BTN_LABEL_PROP_BTN_RIGHT "Button Right" -#define BTN_LABEL_PROP_BTN_MIDDLE "Button Middle" -#define BTN_LABEL_PROP_BTN_SIDE "Button Side" -#define BTN_LABEL_PROP_BTN_EXTRA "Button Extra" -#define BTN_LABEL_PROP_BTN_FORWARD "Button Forward" -#define BTN_LABEL_PROP_BTN_BACK "Button Back" -#define BTN_LABEL_PROP_BTN_TASK "Button Task" - -#define BTN_LABEL_PROP_BTN_TRIGGER "Button Trigger" -#define BTN_LABEL_PROP_BTN_THUMB "Button Thumb" -#define BTN_LABEL_PROP_BTN_THUMB2 "Button Thumb2" -#define BTN_LABEL_PROP_BTN_TOP "Button Top" -#define BTN_LABEL_PROP_BTN_TOP2 "Button Top2" -#define BTN_LABEL_PROP_BTN_PINKIE "Button Pinkie" -#define BTN_LABEL_PROP_BTN_BASE "Button Base" -#define BTN_LABEL_PROP_BTN_BASE2 "Button Base2" -#define BTN_LABEL_PROP_BTN_BASE3 "Button Base3" -#define BTN_LABEL_PROP_BTN_BASE4 "Button Base4" -#define BTN_LABEL_PROP_BTN_BASE5 "Button Base5" -#define BTN_LABEL_PROP_BTN_BASE6 "Button Base6" -#define BTN_LABEL_PROP_BTN_DEAD "Button Dead" - -#define BTN_LABEL_PROP_BTN_A "Button A" -#define BTN_LABEL_PROP_BTN_B "Button B" -#define BTN_LABEL_PROP_BTN_C "Button C" -#define BTN_LABEL_PROP_BTN_X "Button X" -#define BTN_LABEL_PROP_BTN_Y "Button Y" -#define BTN_LABEL_PROP_BTN_Z "Button Z" -#define BTN_LABEL_PROP_BTN_TL "Button T Left" -#define BTN_LABEL_PROP_BTN_TR "Button T Right" -#define BTN_LABEL_PROP_BTN_TL2 "Button T Left2" -#define BTN_LABEL_PROP_BTN_TR2 "Button T Right2" -#define BTN_LABEL_PROP_BTN_SELECT "Button Select" -#define BTN_LABEL_PROP_BTN_START "Button Start" -#define BTN_LABEL_PROP_BTN_MODE "Button Mode" -#define BTN_LABEL_PROP_BTN_THUMBL "Button Thumb Left" -#define BTN_LABEL_PROP_BTN_THUMBR "Button Thumb Right" - -#define BTN_LABEL_PROP_BTN_TOOL_PEN "Button Tool Pen" -#define BTN_LABEL_PROP_BTN_TOOL_RUBBER "Button Tool Rubber" -#define BTN_LABEL_PROP_BTN_TOOL_BRUSH "Button Tool Brush" -#define BTN_LABEL_PROP_BTN_TOOL_PENCIL "Button Tool Pencil" -#define BTN_LABEL_PROP_BTN_TOOL_AIRBRUSH "Button Tool Airbrush" -#define BTN_LABEL_PROP_BTN_TOOL_FINGER "Button Tool Finger" -#define BTN_LABEL_PROP_BTN_TOOL_MOUSE "Button Tool Mouse" -#define BTN_LABEL_PROP_BTN_TOOL_LENS "Button Tool Lens" -#define BTN_LABEL_PROP_BTN_TOUCH "Button Touch" -#define BTN_LABEL_PROP_BTN_STYLUS "Button Stylus" -#define BTN_LABEL_PROP_BTN_STYLUS2 "Button Stylus2" -#define BTN_LABEL_PROP_BTN_TOOL_DOUBLETAP "Button Tool Doubletap" -#define BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP "Button Tool Tripletap" - -#define BTN_LABEL_PROP_BTN_GEAR_DOWN "Button Gear down" -#define BTN_LABEL_PROP_BTN_GEAR_UP "Button Gear up" - -#endif +/*
+ * Copyright 2008 Red Hat, Inc.
+ *
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * them Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) 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 MERCHANTIBILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS 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.
+ */
+
+
+/* Properties managed by the server. */
+
+#ifndef _XSERVER_PROPERTIES_H_
+#define _XSERVER_PROPERTIES_H_
+
+/* Type for a 4 byte float. Storage format IEEE 754 in client's default
+ * byte-ordering. */
+#define XATOM_FLOAT "FLOAT"
+
+/* BOOL. 0 - device disabled, 1 - device enabled */
+#define XI_PROP_ENABLED "Device Enabled"
+/* BOOL. If present, device is a virtual XTEST device */
+#define XI_PROP_XTEST_DEVICE "XTEST Device"
+
+/* Coordinate transformation matrix for absolute input devices
+ * FLOAT, 9 values in row-major order, coordinates in 0..1 range:
+ * [c0 c1 c2] [x]
+ * [c3 c4 c5] * [y]
+ * [c6 c7 c8] [1] */
+#define XI_PROP_TRANSFORM "Coordinate Transformation Matrix"
+
+/* Pointer acceleration properties */
+/* INTEGER of any format */
+#define ACCEL_PROP_PROFILE_NUMBER "Device Accel Profile"
+/* FLOAT, format 32 */
+#define ACCEL_PROP_CONSTANT_DECELERATION "Device Accel Constant Deceleration"
+/* FLOAT, format 32 */
+#define ACCEL_PROP_ADAPTIVE_DECELERATION "Device Accel Adaptive Deceleration"
+/* FLOAT, format 32 */
+#define ACCEL_PROP_VELOCITY_SCALING "Device Accel Velocity Scaling"
+
+
+/* Axis labels */
+#define AXIS_LABEL_PROP "Axis Labels"
+
+#define AXIS_LABEL_PROP_REL_X "Rel X"
+#define AXIS_LABEL_PROP_REL_Y "Rel Y"
+#define AXIS_LABEL_PROP_REL_Z "Rel Z"
+#define AXIS_LABEL_PROP_REL_RX "Rel Rotary X"
+#define AXIS_LABEL_PROP_REL_RY "Rel Rotary Y"
+#define AXIS_LABEL_PROP_REL_RZ "Rel Rotary Z"
+#define AXIS_LABEL_PROP_REL_HWHEEL "Rel Horiz Wheel"
+#define AXIS_LABEL_PROP_REL_DIAL "Rel Dial"
+#define AXIS_LABEL_PROP_REL_WHEEL "Rel Vert Wheel"
+#define AXIS_LABEL_PROP_REL_MISC "Rel Misc"
+
+/*
+ * Absolute axes
+ */
+
+#define AXIS_LABEL_PROP_ABS_X "Abs X"
+#define AXIS_LABEL_PROP_ABS_Y "Abs Y"
+#define AXIS_LABEL_PROP_ABS_Z "Abs Z"
+#define AXIS_LABEL_PROP_ABS_RX "Abs Rotary X"
+#define AXIS_LABEL_PROP_ABS_RY "Abs Rotary Y"
+#define AXIS_LABEL_PROP_ABS_RZ "Abs Rotary Z"
+#define AXIS_LABEL_PROP_ABS_THROTTLE "Abs Throttle"
+#define AXIS_LABEL_PROP_ABS_RUDDER "Abs Rudder"
+#define AXIS_LABEL_PROP_ABS_WHEEL "Abs Wheel"
+#define AXIS_LABEL_PROP_ABS_GAS "Abs Gas"
+#define AXIS_LABEL_PROP_ABS_BRAKE "Abs Brake"
+#define AXIS_LABEL_PROP_ABS_HAT0X "Abs Hat 0 X"
+#define AXIS_LABEL_PROP_ABS_HAT0Y "Abs Hat 0 Y"
+#define AXIS_LABEL_PROP_ABS_HAT1X "Abs Hat 1 X"
+#define AXIS_LABEL_PROP_ABS_HAT1Y "Abs Hat 1 Y"
+#define AXIS_LABEL_PROP_ABS_HAT2X "Abs Hat 2 X"
+#define AXIS_LABEL_PROP_ABS_HAT2Y "Abs Hat 2 Y"
+#define AXIS_LABEL_PROP_ABS_HAT3X "Abs Hat 3 X"
+#define AXIS_LABEL_PROP_ABS_HAT3Y "Abs Hat 3 Y"
+#define AXIS_LABEL_PROP_ABS_PRESSURE "Abs Pressure"
+#define AXIS_LABEL_PROP_ABS_DISTANCE "Abs Distance"
+#define AXIS_LABEL_PROP_ABS_TILT_X "Abs Tilt X"
+#define AXIS_LABEL_PROP_ABS_TILT_Y "Abs Tilt Y"
+#define AXIS_LABEL_PROP_ABS_TOOL_WIDTH "Abs Tool Width"
+#define AXIS_LABEL_PROP_ABS_VOLUME "Abs Volume"
+#define AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR "Abs MT Touch Major"
+#define AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR "Abs MT Touch Minor"
+#define AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR "Abs MT Width Major"
+#define AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR "Abs MT Width Minor"
+#define AXIS_LABEL_PROP_ABS_MT_ORIENTATION "Abs MT Orientation"
+#define AXIS_LABEL_PROP_ABS_MT_POSITION_X "Abs MT Position X"
+#define AXIS_LABEL_PROP_ABS_MT_POSITION_Y "Abs MT Position Y"
+#define AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE "Abs MT Tool Type"
+#define AXIS_LABEL_PROP_ABS_MT_BLOB_ID "Abs MT Blob ID"
+#define AXIS_LABEL_PROP_ABS_MT_TRACKING_ID "Abs MT Tracking ID"
+#define AXIS_LABEL_PROP_ABS_MT_PRESSURE "Abs MT Pressure"
+#define AXIS_LABEL_PROP_ABS_MISC "Abs Misc"
+
+/* Button names */
+#define BTN_LABEL_PROP "Button Labels"
+
+/* Default label */
+#define BTN_LABEL_PROP_BTN_UNKNOWN "Button Unknown"
+/* Wheel buttons */
+#define BTN_LABEL_PROP_BTN_WHEEL_UP "Button Wheel Up"
+#define BTN_LABEL_PROP_BTN_WHEEL_DOWN "Button Wheel Down"
+#define BTN_LABEL_PROP_BTN_HWHEEL_LEFT "Button Horiz Wheel Left"
+#define BTN_LABEL_PROP_BTN_HWHEEL_RIGHT "Button Horiz Wheel Right"
+
+/* The following are from linux/input.h */
+#define BTN_LABEL_PROP_BTN_0 "Button 0"
+#define BTN_LABEL_PROP_BTN_1 "Button 1"
+#define BTN_LABEL_PROP_BTN_2 "Button 2"
+#define BTN_LABEL_PROP_BTN_3 "Button 3"
+#define BTN_LABEL_PROP_BTN_4 "Button 4"
+#define BTN_LABEL_PROP_BTN_5 "Button 5"
+#define BTN_LABEL_PROP_BTN_6 "Button 6"
+#define BTN_LABEL_PROP_BTN_7 "Button 7"
+#define BTN_LABEL_PROP_BTN_8 "Button 8"
+#define BTN_LABEL_PROP_BTN_9 "Button 9"
+
+#define BTN_LABEL_PROP_BTN_LEFT "Button Left"
+#define BTN_LABEL_PROP_BTN_RIGHT "Button Right"
+#define BTN_LABEL_PROP_BTN_MIDDLE "Button Middle"
+#define BTN_LABEL_PROP_BTN_SIDE "Button Side"
+#define BTN_LABEL_PROP_BTN_EXTRA "Button Extra"
+#define BTN_LABEL_PROP_BTN_FORWARD "Button Forward"
+#define BTN_LABEL_PROP_BTN_BACK "Button Back"
+#define BTN_LABEL_PROP_BTN_TASK "Button Task"
+
+#define BTN_LABEL_PROP_BTN_TRIGGER "Button Trigger"
+#define BTN_LABEL_PROP_BTN_THUMB "Button Thumb"
+#define BTN_LABEL_PROP_BTN_THUMB2 "Button Thumb2"
+#define BTN_LABEL_PROP_BTN_TOP "Button Top"
+#define BTN_LABEL_PROP_BTN_TOP2 "Button Top2"
+#define BTN_LABEL_PROP_BTN_PINKIE "Button Pinkie"
+#define BTN_LABEL_PROP_BTN_BASE "Button Base"
+#define BTN_LABEL_PROP_BTN_BASE2 "Button Base2"
+#define BTN_LABEL_PROP_BTN_BASE3 "Button Base3"
+#define BTN_LABEL_PROP_BTN_BASE4 "Button Base4"
+#define BTN_LABEL_PROP_BTN_BASE5 "Button Base5"
+#define BTN_LABEL_PROP_BTN_BASE6 "Button Base6"
+#define BTN_LABEL_PROP_BTN_DEAD "Button Dead"
+
+#define BTN_LABEL_PROP_BTN_A "Button A"
+#define BTN_LABEL_PROP_BTN_B "Button B"
+#define BTN_LABEL_PROP_BTN_C "Button C"
+#define BTN_LABEL_PROP_BTN_X "Button X"
+#define BTN_LABEL_PROP_BTN_Y "Button Y"
+#define BTN_LABEL_PROP_BTN_Z "Button Z"
+#define BTN_LABEL_PROP_BTN_TL "Button T Left"
+#define BTN_LABEL_PROP_BTN_TR "Button T Right"
+#define BTN_LABEL_PROP_BTN_TL2 "Button T Left2"
+#define BTN_LABEL_PROP_BTN_TR2 "Button T Right2"
+#define BTN_LABEL_PROP_BTN_SELECT "Button Select"
+#define BTN_LABEL_PROP_BTN_START "Button Start"
+#define BTN_LABEL_PROP_BTN_MODE "Button Mode"
+#define BTN_LABEL_PROP_BTN_THUMBL "Button Thumb Left"
+#define BTN_LABEL_PROP_BTN_THUMBR "Button Thumb Right"
+
+#define BTN_LABEL_PROP_BTN_TOOL_PEN "Button Tool Pen"
+#define BTN_LABEL_PROP_BTN_TOOL_RUBBER "Button Tool Rubber"
+#define BTN_LABEL_PROP_BTN_TOOL_BRUSH "Button Tool Brush"
+#define BTN_LABEL_PROP_BTN_TOOL_PENCIL "Button Tool Pencil"
+#define BTN_LABEL_PROP_BTN_TOOL_AIRBRUSH "Button Tool Airbrush"
+#define BTN_LABEL_PROP_BTN_TOOL_FINGER "Button Tool Finger"
+#define BTN_LABEL_PROP_BTN_TOOL_MOUSE "Button Tool Mouse"
+#define BTN_LABEL_PROP_BTN_TOOL_LENS "Button Tool Lens"
+#define BTN_LABEL_PROP_BTN_TOUCH "Button Touch"
+#define BTN_LABEL_PROP_BTN_STYLUS "Button Stylus"
+#define BTN_LABEL_PROP_BTN_STYLUS2 "Button Stylus2"
+#define BTN_LABEL_PROP_BTN_TOOL_DOUBLETAP "Button Tool Doubletap"
+#define BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP "Button Tool Tripletap"
+
+#define BTN_LABEL_PROP_BTN_GEAR_DOWN "Button Gear down"
+#define BTN_LABEL_PROP_BTN_GEAR_UP "Button Gear up"
+
+#endif
diff --git a/xorg-server/mi/Makefile.am b/xorg-server/mi/Makefile.am index f22dde9a2..8ec45ecd8 100644 --- a/xorg-server/mi/Makefile.am +++ b/xorg-server/mi/Makefile.am @@ -1,67 +1,66 @@ -noinst_LTLIBRARIES = libmi.la - -if XORG -sdk_HEADERS = micmap.h miline.h mipointer.h mi.h mibstore.h \ - migc.h mipointrst.h mizerarc.h micoord.h mifillarc.h \ - mispans.h miwideline.h mistruct.h mifpoly.h mioverlay.h -endif - -AM_CFLAGS = $(DIX_CFLAGS) - -libmi_la_SOURCES = \ - mi.h \ - miarc.c \ - mibitblt.c \ - mibstore.c \ - mibstore.h \ - mibstorest.h \ - micmap.c \ - micmap.h \ - micoord.h \ - micopy.c \ - micursor.c \ - midash.c \ - midispcur.c \ - mieq.c \ - miexpose.c \ - mifillarc.c \ - mifillarc.h \ - mifillrct.c \ - mifpolycon.c \ - mifpoly.h \ - migc.c \ - migc.h \ - miglblt.c \ - miline.h \ - mioverlay.c \ - mioverlay.h \ - mipointer.c \ - mipointer.h \ - mipointrst.h \ - mipoly.c \ - mipoly.h \ - mipolycon.c \ - mipolygen.c \ - mipolypnt.c \ - mipolyrect.c \ - mipolyseg.c \ - mipolytext.c \ - mipolyutil.c \ - mipushpxl.c \ - miregion.c \ - miscanfill.h \ - miscrinit.c \ - mispans.c \ - mispans.h \ - misprite.c \ - misprite.h \ - mistruct.h \ - mivaltree.c \ - mivalidate.h \ - miwideline.c \ - miwideline.h \ - miwindow.c \ - mizerarc.c \ - mizerarc.h \ - mizerclip.c \ - mizerline.c +noinst_LTLIBRARIES = libmi.la
+
+if XORG
+sdk_HEADERS = micmap.h miline.h mipointer.h mi.h mibstore.h \
+ migc.h mipointrst.h mizerarc.h micoord.h mifillarc.h \
+ mispans.h miwideline.h mistruct.h mifpoly.h mioverlay.h
+endif
+
+AM_CFLAGS = $(DIX_CFLAGS)
+
+libmi_la_SOURCES = \
+ mi.h \
+ miarc.c \
+ mibitblt.c \
+ mibstore.c \
+ mibstore.h \
+ mibstorest.h \
+ micmap.c \
+ micmap.h \
+ micoord.h \
+ micopy.c \
+ micursor.c \
+ midash.c \
+ midispcur.c \
+ mieq.c \
+ miexpose.c \
+ mifillarc.c \
+ mifillarc.h \
+ mifillrct.c \
+ mifpolycon.c \
+ mifpoly.h \
+ migc.c \
+ migc.h \
+ miglblt.c \
+ miline.h \
+ mioverlay.c \
+ mioverlay.h \
+ mipointer.c \
+ mipointer.h \
+ mipointrst.h \
+ mipoly.c \
+ mipoly.h \
+ mipolycon.c \
+ mipolygen.c \
+ mipolypnt.c \
+ mipolyrect.c \
+ mipolyseg.c \
+ mipolytext.c \
+ mipolyutil.c \
+ mipushpxl.c \
+ miscanfill.h \
+ miscrinit.c \
+ mispans.c \
+ mispans.h \
+ misprite.c \
+ misprite.h \
+ mistruct.h \
+ mivaltree.c \
+ mivalidate.h \
+ miwideline.c \
+ miwideline.h \
+ miwindow.c \
+ mizerarc.c \
+ mizerarc.h \
+ mizerclip.c \
+ mizerline.c
diff --git a/xorg-server/mi/makefile b/xorg-server/mi/makefile index dff435cd5..c0a986f79 100644 --- a/xorg-server/mi/makefile +++ b/xorg-server/mi/makefile @@ -24,7 +24,6 @@ CSRCS=miarc.c \ mipolytext.c \ mipolyutil.c \ mipushpxl.c \ - miregion.c \ miscrinit.c \ mispans.c \ misprite.c \ diff --git a/xorg-server/mi/mi.h b/xorg-server/mi/mi.h index 812edce94..eca65f20e 100644 --- a/xorg-server/mi/mi.h +++ b/xorg-server/mi/mi.h @@ -1,620 +1,603 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - -#ifndef MI_H -#define MI_H -#include <X11/X.h> -#include "region.h" -#include "validate.h" -#include "window.h" -#include "gc.h" -#include <X11/fonts/font.h> -#include "input.h" -#include "cursor.h" -#include "privates.h" -#include "colormap.h" -#include "events.h" - -#define MiBits CARD32 - -typedef struct _miDash *miDashPtr; -#define EVEN_DASH 0 -#define ODD_DASH ~0 - -/* miarc.c */ - -extern _X_EXPORT void miPolyArc( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*narcs*/, - xArc * /*parcs*/ -); - -/* mibitblt.c */ - -extern _X_EXPORT RegionPtr miCopyArea( - DrawablePtr /*pSrcDrawable*/, - DrawablePtr /*pDstDrawable*/, - GCPtr /*pGC*/, - int /*xIn*/, - int /*yIn*/, - int /*widthSrc*/, - int /*heightSrc*/, - int /*xOut*/, - int /*yOut*/ -); - -extern _X_EXPORT RegionPtr miCopyPlane( - DrawablePtr /*pSrcDrawable*/, - DrawablePtr /*pDstDrawable*/, - GCPtr /*pGC*/, - int /*srcx*/, - int /*srcy*/, - int /*width*/, - int /*height*/, - int /*dstx*/, - int /*dsty*/, - unsigned long /*bitPlane*/ -); - -extern _X_EXPORT void miGetImage( - DrawablePtr /*pDraw*/, - int /*sx*/, - int /*sy*/, - int /*w*/, - int /*h*/, - unsigned int /*format*/, - unsigned long /*planeMask*/, - char * /*pdstLine*/ -); - -extern _X_EXPORT void miPutImage( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*depth*/, - int /*x*/, - int /*y*/, - int /*w*/, - int /*h*/, - int /*leftPad*/, - int /*format*/, - char * /*pImage*/ -); - -/* micopy.c */ - -#define miGetCompositeClip(pGC) ((pGC)->pCompositeClip) - -typedef void (*miCopyProc) (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - BoxPtr pDstBox, - int nbox, - int dx, - int dy, - Bool reverse, - Bool upsidedown, - Pixel bitplane, - void *closure); - -extern _X_EXPORT void -miCopyRegion (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - RegionPtr pDstRegion, - int dx, - int dy, - miCopyProc copyProc, - Pixel bitPlane, - void *closure); - -extern _X_EXPORT RegionPtr -miDoCopy (DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - int xIn, - int yIn, - int widthSrc, - int heightSrc, - int xOut, - int yOut, - miCopyProc copyProc, - Pixel bitplane, - void *closure); - -/* micursor.c */ - -extern _X_EXPORT void miRecolorCursor( - DeviceIntPtr /* pDev */, - ScreenPtr /*pScr*/, - CursorPtr /*pCurs*/, - Bool /*displayed*/ -); - -/* midash.c */ - -extern _X_EXPORT void miStepDash( - int /*dist*/, - int * /*pDashIndex*/, - unsigned char * /*pDash*/, - int /*numInDashList*/, - int * /*pDashOffset*/ -); - -/* mieq.c */ - - -#ifndef INPUT_H -typedef struct _DeviceRec *DevicePtr; -#endif - -extern _X_EXPORT Bool mieqInit( - void -); - -extern _X_EXPORT void mieqFini(void); - -extern _X_EXPORT void mieqEnqueue( - DeviceIntPtr /*pDev*/, - InternalEvent* /*e*/ -); - -extern _X_EXPORT void mieqSwitchScreen( - DeviceIntPtr /* pDev */, - ScreenPtr /*pScreen*/, - Bool /*fromDIX*/ -); - -extern _X_EXPORT void mieqProcessDeviceEvent( - DeviceIntPtr /* dev*/, - InternalEvent* /* event */, - ScreenPtr /* screen*/ -); - -extern _X_EXPORT void mieqProcessInputEvents( - void -); - -extern DeviceIntPtr CopyGetMasterEvent( - DeviceIntPtr /* sdev */, - InternalEvent* /* original */, - InternalEvent* /* copy */ -); - -/** - * Custom input event handler. If you need to process input events in some - * other way than the default path, register an input event handler for the - * given internal event type. - */ -typedef void (*mieqHandler)(int screen, InternalEvent* event, DeviceIntPtr dev); -void _X_EXPORT mieqSetHandler(int event, mieqHandler handler); - -/* miexpose.c */ - -extern _X_EXPORT RegionPtr miHandleExposures( - DrawablePtr /*pSrcDrawable*/, - DrawablePtr /*pDstDrawable*/, - GCPtr /*pGC*/, - int /*srcx*/, - int /*srcy*/, - int /*width*/, - int /*height*/, - int /*dstx*/, - int /*dsty*/, - unsigned long /*plane*/ -); - -extern _X_EXPORT void miSendGraphicsExpose( - ClientPtr /*client*/, - RegionPtr /*pRgn*/, - XID /*drawable*/, - int /*major*/, - int /*minor*/ -); - -extern _X_EXPORT void miSendExposures( - WindowPtr /*pWin*/, - RegionPtr /*pRgn*/, - int /*dx*/, - int /*dy*/ -); - -extern _X_EXPORT void miWindowExposures( - WindowPtr /*pWin*/, - RegionPtr /*prgn*/, - RegionPtr /*other_exposed*/ -); - -extern _X_EXPORT void miPaintWindow( - WindowPtr /*pWin*/, - RegionPtr /*prgn*/, - int /*what*/ -); - -extern _X_EXPORT void miClearDrawable( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/ -); - -/* mifillrct.c */ - -extern _X_EXPORT void miPolyFillRect( - DrawablePtr /*pDrawable*/, - GCPtr /*pGC*/, - int /*nrectFill*/, - xRectangle * /*prectInit*/ -); - -/* miglblt.c */ - -extern _X_EXPORT void miPolyGlyphBlt( - DrawablePtr /*pDrawable*/, - GCPtr /*pGC*/, - int /*x*/, - int /*y*/, - unsigned int /*nglyph*/, - CharInfoPtr * /*ppci*/, - pointer /*pglyphBase*/ -); - -extern _X_EXPORT void miImageGlyphBlt( - DrawablePtr /*pDrawable*/, - GCPtr /*pGC*/, - int /*x*/, - int /*y*/, - unsigned int /*nglyph*/, - CharInfoPtr * /*ppci*/, - pointer /*pglyphBase*/ -); - -/* mipoly.c */ - -extern _X_EXPORT void miFillPolygon( - DrawablePtr /*dst*/, - GCPtr /*pgc*/, - int /*shape*/, - int /*mode*/, - int /*count*/, - DDXPointPtr /*pPts*/ -); - -/* mipolycon.c */ - -extern _X_EXPORT Bool miFillConvexPoly( - DrawablePtr /*dst*/, - GCPtr /*pgc*/, - int /*count*/, - DDXPointPtr /*ptsIn*/ -); - -/* mipolygen.c */ - -extern _X_EXPORT Bool miFillGeneralPoly( - DrawablePtr /*dst*/, - GCPtr /*pgc*/, - int /*count*/, - DDXPointPtr /*ptsIn*/ -); - -/* mipolypnt.c */ - -extern _X_EXPORT void miPolyPoint( - DrawablePtr /*pDrawable*/, - GCPtr /*pGC*/, - int /*mode*/, - int /*npt*/, - xPoint * /*pptInit*/ -); - -/* mipolyrect.c */ - -extern _X_EXPORT void miPolyRectangle( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*nrects*/, - xRectangle * /*pRects*/ -); - -/* mipolyseg.c */ - -extern _X_EXPORT void miPolySegment( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*nseg*/, - xSegment * /*pSegs*/ -); - -/* mipolytext.c */ - -extern _X_EXPORT int miPolyText8( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*x*/, - int /*y*/, - int /*count*/, - char * /*chars*/ -); - -extern _X_EXPORT int miPolyText16( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*x*/, - int /*y*/, - int /*count*/, - unsigned short * /*chars*/ -); - -extern _X_EXPORT void miImageText8( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*x*/, - int /*y*/, - int /*count*/, - char * /*chars*/ -); - -extern _X_EXPORT void miImageText16( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*x*/, - int /*y*/, - int /*count*/, - unsigned short * /*chars*/ -); - -/* mipushpxl.c */ - -extern _X_EXPORT void miPushPixels( - GCPtr /*pGC*/, - PixmapPtr /*pBitMap*/, - DrawablePtr /*pDrawable*/, - int /*dx*/, - int /*dy*/, - int /*xOrg*/, - int /*yOrg*/ -); - -/* miregion.c */ - -/* see also region.h */ - -extern _X_EXPORT Bool miRectAlloc( - RegionPtr /*pRgn*/, - int /*n*/ -); - -#ifdef DEBUG -extern _X_EXPORT Bool miValidRegion( - RegionPtr /*prgn*/ -); -#endif - -extern _X_EXPORT Bool miRegionBroken(RegionPtr pReg); - -/* miscrinit.c */ - -extern _X_EXPORT Bool miModifyPixmapHeader( - PixmapPtr /*pPixmap*/, - int /*width*/, - int /*height*/, - int /*depth*/, - int /*bitsPerPixel*/, - int /*devKind*/, - pointer /*pPixData*/ -); - -extern _X_EXPORT Bool miCreateScreenResources( - ScreenPtr /*pScreen*/ -); - -extern _X_EXPORT Bool miScreenDevPrivateInit( - ScreenPtr /*pScreen*/, - int /*width*/, - pointer /*pbits*/ -); - -extern _X_EXPORT Bool miScreenInit( - ScreenPtr /*pScreen*/, - pointer /*pbits*/, - int /*xsize*/, - int /*ysize*/, - int /*dpix*/, - int /*dpiy*/, - int /*width*/, - int /*rootDepth*/, - int /*numDepths*/, - DepthPtr /*depths*/, - VisualID /*rootVisual*/, - int /*numVisuals*/, - VisualPtr /*visuals*/ -); - -extern _X_EXPORT DevPrivateKey miAllocateGCPrivateIndex( - void -); - -/* mivaltree.c */ - -extern _X_EXPORT int miShapedWindowIn( - ScreenPtr /*pScreen*/, - RegionPtr /*universe*/, - RegionPtr /*bounding*/, - BoxPtr /*rect*/, - int /*x*/, - int /*y*/ -); - -typedef void -(*SetRedirectBorderClipProcPtr) (WindowPtr pWindow, RegionPtr pRegion); - -typedef RegionPtr -(*GetRedirectBorderClipProcPtr) (WindowPtr pWindow); - -extern _X_EXPORT void -miRegisterRedirectBorderClipProc (SetRedirectBorderClipProcPtr setBorderClip, - GetRedirectBorderClipProcPtr getBorderClip); - -extern _X_EXPORT int miValidateTree( - WindowPtr /*pParent*/, - WindowPtr /*pChild*/, - VTKind /*kind*/ -); - -extern _X_EXPORT void miWideLine( - DrawablePtr /*pDrawable*/, - GCPtr /*pGC*/, - int /*mode*/, - int /*npt*/, - DDXPointPtr /*pPts*/ -); - -extern _X_EXPORT void miWideDash( - DrawablePtr /*pDrawable*/, - GCPtr /*pGC*/, - int /*mode*/, - int /*npt*/, - DDXPointPtr /*pPts*/ -); - -/* miwindow.c */ - -extern _X_EXPORT void miClearToBackground( - WindowPtr /*pWin*/, - int /*x*/, - int /*y*/, - int /*w*/, - int /*h*/, - Bool /*generateExposures*/ -); - -extern _X_EXPORT void miMarkWindow( - WindowPtr /*pWin*/ -); - -extern _X_EXPORT Bool miMarkOverlappedWindows( - WindowPtr /*pWin*/, - WindowPtr /*pFirst*/, - WindowPtr * /*ppLayerWin*/ -); - -extern _X_EXPORT void miHandleValidateExposures( - WindowPtr /*pWin*/ -); - -extern _X_EXPORT void miMoveWindow( - WindowPtr /*pWin*/, - int /*x*/, - int /*y*/, - WindowPtr /*pNextSib*/, - VTKind /*kind*/ -); - -extern _X_EXPORT void miSlideAndSizeWindow( - WindowPtr /*pWin*/, - int /*x*/, - int /*y*/, - unsigned int /*w*/, - unsigned int /*h*/, - WindowPtr /*pSib*/ -); - -extern _X_EXPORT WindowPtr miGetLayerWindow( - WindowPtr /*pWin*/ -); - -extern _X_EXPORT void miSetShape( - WindowPtr /*pWin*/ -); - -extern _X_EXPORT void miChangeBorderWidth( - WindowPtr /*pWin*/, - unsigned int /*width*/ -); - -extern _X_EXPORT void miMarkUnrealizedWindow( - WindowPtr /*pChild*/, - WindowPtr /*pWin*/, - Bool /*fromConfigure*/ -); - -extern _X_EXPORT void miSegregateChildren(WindowPtr pWin, RegionPtr pReg, int depth); - -/* mizerarc.c */ - -extern _X_EXPORT void miZeroPolyArc( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*narcs*/, - xArc * /*parcs*/ -); - -/* mizerline.c */ - -extern _X_EXPORT void miZeroLine( - DrawablePtr /*dst*/, - GCPtr /*pgc*/, - int /*mode*/, - int /*nptInit*/, - DDXPointRec * /*pptInit*/ -); - -extern _X_EXPORT void miZeroDashLine( - DrawablePtr /*dst*/, - GCPtr /*pgc*/, - int /*mode*/, - int /*nptInit*/, - DDXPointRec * /*pptInit*/ -); - -extern _X_EXPORT void miPolyFillArc( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*narcs*/, - xArc * /*parcs*/ -); - -#endif /* MI_H */ +/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef MI_H
+#define MI_H
+#include <X11/X.h>
+#include "region.h"
+#include "validate.h"
+#include "window.h"
+#include "gc.h"
+#include <X11/fonts/font.h>
+#include "input.h"
+#include "cursor.h"
+#include "privates.h"
+#include "colormap.h"
+#include "events.h"
+
+#define MiBits CARD32
+
+typedef struct _miDash *miDashPtr;
+#define EVEN_DASH 0
+#define ODD_DASH ~0
+
+/* miarc.c */
+
+extern _X_EXPORT void miPolyArc(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+/* mibitblt.c */
+
+extern _X_EXPORT RegionPtr miCopyArea(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr /*pGC*/,
+ int /*xIn*/,
+ int /*yIn*/,
+ int /*widthSrc*/,
+ int /*heightSrc*/,
+ int /*xOut*/,
+ int /*yOut*/
+);
+
+extern _X_EXPORT RegionPtr miCopyPlane(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*bitPlane*/
+);
+
+extern _X_EXPORT void miGetImage(
+ DrawablePtr /*pDraw*/,
+ int /*sx*/,
+ int /*sy*/,
+ int /*w*/,
+ int /*h*/,
+ unsigned int /*format*/,
+ unsigned long /*planeMask*/,
+ char * /*pdstLine*/
+);
+
+extern _X_EXPORT void miPutImage(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*depth*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ int /*leftPad*/,
+ int /*format*/,
+ char * /*pImage*/
+);
+
+/* micopy.c */
+
+#define miGetCompositeClip(pGC) ((pGC)->pCompositeClip)
+
+typedef void (*miCopyProc) (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pDstBox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT void
+miCopyRegion (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ RegionPtr pDstRegion,
+ int dx,
+ int dy,
+ miCopyProc copyProc,
+ Pixel bitPlane,
+ void *closure);
+
+extern _X_EXPORT RegionPtr
+miDoCopy (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut,
+ miCopyProc copyProc,
+ Pixel bitplane,
+ void *closure);
+
+/* micursor.c */
+
+extern _X_EXPORT void miRecolorCursor(
+ DeviceIntPtr /* pDev */,
+ ScreenPtr /*pScr*/,
+ CursorPtr /*pCurs*/,
+ Bool /*displayed*/
+);
+
+/* midash.c */
+
+extern _X_EXPORT void miStepDash(
+ int /*dist*/,
+ int * /*pDashIndex*/,
+ unsigned char * /*pDash*/,
+ int /*numInDashList*/,
+ int * /*pDashOffset*/
+);
+
+/* mieq.c */
+
+
+#ifndef INPUT_H
+typedef struct _DeviceRec *DevicePtr;
+#endif
+
+extern _X_EXPORT Bool mieqInit(
+ void
+);
+
+extern _X_EXPORT void mieqFini(void);
+
+extern _X_EXPORT void mieqEnqueue(
+ DeviceIntPtr /*pDev*/,
+ InternalEvent* /*e*/
+);
+
+extern _X_EXPORT void mieqSwitchScreen(
+ DeviceIntPtr /* pDev */,
+ ScreenPtr /*pScreen*/,
+ Bool /*fromDIX*/
+);
+
+extern _X_EXPORT void mieqProcessDeviceEvent(
+ DeviceIntPtr /* dev*/,
+ InternalEvent* /* event */,
+ ScreenPtr /* screen*/
+);
+
+extern _X_EXPORT void mieqProcessInputEvents(
+ void
+);
+
+extern DeviceIntPtr CopyGetMasterEvent(
+ DeviceIntPtr /* sdev */,
+ InternalEvent* /* original */,
+ InternalEvent* /* copy */
+);
+
+/**
+ * Custom input event handler. If you need to process input events in some
+ * other way than the default path, register an input event handler for the
+ * given internal event type.
+ */
+typedef void (*mieqHandler)(int screen, InternalEvent* event, DeviceIntPtr dev);
+void _X_EXPORT mieqSetHandler(int event, mieqHandler handler);
+
+/* miexpose.c */
+
+extern _X_EXPORT RegionPtr miHandleExposures(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*plane*/
+);
+
+extern _X_EXPORT void miSendGraphicsExpose(
+ ClientPtr /*client*/,
+ RegionPtr /*pRgn*/,
+ XID /*drawable*/,
+ int /*major*/,
+ int /*minor*/
+);
+
+extern _X_EXPORT void miSendExposures(
+ WindowPtr /*pWin*/,
+ RegionPtr /*pRgn*/,
+ int /*dx*/,
+ int /*dy*/
+);
+
+extern _X_EXPORT void miWindowExposures(
+ WindowPtr /*pWin*/,
+ RegionPtr /*prgn*/,
+ RegionPtr /*other_exposed*/
+);
+
+extern _X_EXPORT void miPaintWindow(
+ WindowPtr /*pWin*/,
+ RegionPtr /*prgn*/,
+ int /*what*/
+);
+
+extern _X_EXPORT void miClearDrawable(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/
+);
+
+/* mifillrct.c */
+
+extern _X_EXPORT void miPolyFillRect(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nrectFill*/,
+ xRectangle * /*prectInit*/
+);
+
+/* miglblt.c */
+
+extern _X_EXPORT void miPolyGlyphBlt(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+
+extern _X_EXPORT void miImageGlyphBlt(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+
+/* mipoly.c */
+
+extern _X_EXPORT void miFillPolygon(
+ DrawablePtr /*dst*/,
+ GCPtr /*pgc*/,
+ int /*shape*/,
+ int /*mode*/,
+ int /*count*/,
+ DDXPointPtr /*pPts*/
+);
+
+/* mipolycon.c */
+
+extern _X_EXPORT Bool miFillConvexPoly(
+ DrawablePtr /*dst*/,
+ GCPtr /*pgc*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+
+/* mipolygen.c */
+
+extern _X_EXPORT Bool miFillGeneralPoly(
+ DrawablePtr /*dst*/,
+ GCPtr /*pgc*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+
+/* mipolypnt.c */
+
+extern _X_EXPORT void miPolyPoint(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ xPoint * /*pptInit*/
+);
+
+/* mipolyrect.c */
+
+extern _X_EXPORT void miPolyRectangle(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*nrects*/,
+ xRectangle * /*pRects*/
+);
+
+/* mipolyseg.c */
+
+extern _X_EXPORT void miPolySegment(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegs*/
+);
+
+/* mipolytext.c */
+
+extern _X_EXPORT int miPolyText8(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char * /*chars*/
+);
+
+extern _X_EXPORT int miPolyText16(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ unsigned short * /*chars*/
+);
+
+extern _X_EXPORT void miImageText8(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char * /*chars*/
+);
+
+extern _X_EXPORT void miImageText16(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ unsigned short * /*chars*/
+);
+
+/* mipushpxl.c */
+
+extern _X_EXPORT void miPushPixels(
+ GCPtr /*pGC*/,
+ PixmapPtr /*pBitMap*/,
+ DrawablePtr /*pDrawable*/,
+ int /*dx*/,
+ int /*dy*/,
+ int /*xOrg*/,
+ int /*yOrg*/
+);
+
+/* miscrinit.c */
+
+extern _X_EXPORT Bool miModifyPixmapHeader(
+ PixmapPtr /*pPixmap*/,
+ int /*width*/,
+ int /*height*/,
+ int /*depth*/,
+ int /*bitsPerPixel*/,
+ int /*devKind*/,
+ pointer /*pPixData*/
+);
+
+extern _X_EXPORT Bool miCreateScreenResources(
+ ScreenPtr /*pScreen*/
+);
+
+extern _X_EXPORT Bool miScreenDevPrivateInit(
+ ScreenPtr /*pScreen*/,
+ int /*width*/,
+ pointer /*pbits*/
+);
+
+extern _X_EXPORT Bool miScreenInit(
+ ScreenPtr /*pScreen*/,
+ pointer /*pbits*/,
+ int /*xsize*/,
+ int /*ysize*/,
+ int /*dpix*/,
+ int /*dpiy*/,
+ int /*width*/,
+ int /*rootDepth*/,
+ int /*numDepths*/,
+ DepthPtr /*depths*/,
+ VisualID /*rootVisual*/,
+ int /*numVisuals*/,
+ VisualPtr /*visuals*/
+);
+
+extern _X_EXPORT DevPrivateKey miAllocateGCPrivateIndex(
+ void
+);
+
+/* mivaltree.c */
+
+extern _X_EXPORT int miShapedWindowIn(
+ RegionPtr /*universe*/,
+ RegionPtr /*bounding*/,
+ BoxPtr /*rect*/,
+ int /*x*/,
+ int /*y*/
+);
+
+typedef void
+(*SetRedirectBorderClipProcPtr) (WindowPtr pWindow, RegionPtr pRegion);
+
+typedef RegionPtr
+(*GetRedirectBorderClipProcPtr) (WindowPtr pWindow);
+
+extern _X_EXPORT void
+miRegisterRedirectBorderClipProc (SetRedirectBorderClipProcPtr setBorderClip,
+ GetRedirectBorderClipProcPtr getBorderClip);
+
+extern _X_EXPORT int miValidateTree(
+ WindowPtr /*pParent*/,
+ WindowPtr /*pChild*/,
+ VTKind /*kind*/
+);
+
+extern _X_EXPORT void miWideLine(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pPts*/
+);
+
+extern _X_EXPORT void miWideDash(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pPts*/
+);
+
+/* miwindow.c */
+
+extern _X_EXPORT void miClearToBackground(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ Bool /*generateExposures*/
+);
+
+extern _X_EXPORT void miMarkWindow(
+ WindowPtr /*pWin*/
+);
+
+extern _X_EXPORT Bool miMarkOverlappedWindows(
+ WindowPtr /*pWin*/,
+ WindowPtr /*pFirst*/,
+ WindowPtr * /*ppLayerWin*/
+);
+
+extern _X_EXPORT void miHandleValidateExposures(
+ WindowPtr /*pWin*/
+);
+
+extern _X_EXPORT void miMoveWindow(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/,
+ WindowPtr /*pNextSib*/,
+ VTKind /*kind*/
+);
+
+extern _X_EXPORT void miSlideAndSizeWindow(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*w*/,
+ unsigned int /*h*/,
+ WindowPtr /*pSib*/
+);
+
+extern _X_EXPORT WindowPtr miGetLayerWindow(
+ WindowPtr /*pWin*/
+);
+
+extern _X_EXPORT void miSetShape(
+ WindowPtr /*pWin*/,
+ int /*kind*/
+);
+
+extern _X_EXPORT void miChangeBorderWidth(
+ WindowPtr /*pWin*/,
+ unsigned int /*width*/
+);
+
+extern _X_EXPORT void miMarkUnrealizedWindow(
+ WindowPtr /*pChild*/,
+ WindowPtr /*pWin*/,
+ Bool /*fromConfigure*/
+);
+
+extern _X_EXPORT void miSegregateChildren(WindowPtr pWin, RegionPtr pReg, int depth);
+
+/* mizerarc.c */
+
+extern _X_EXPORT void miZeroPolyArc(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+/* mizerline.c */
+
+extern _X_EXPORT void miZeroLine(
+ DrawablePtr /*dst*/,
+ GCPtr /*pgc*/,
+ int /*mode*/,
+ int /*nptInit*/,
+ DDXPointRec * /*pptInit*/
+);
+
+extern _X_EXPORT void miZeroDashLine(
+ DrawablePtr /*dst*/,
+ GCPtr /*pgc*/,
+ int /*mode*/,
+ int /*nptInit*/,
+ DDXPointRec * /*pptInit*/
+);
+
+extern _X_EXPORT void miPolyFillArc(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+#endif /* MI_H */
diff --git a/xorg-server/mi/miarc.c b/xorg-server/mi/miarc.c index d9a28d058..06fc4085b 100644 --- a/xorg-server/mi/miarc.c +++ b/xorg-server/mi/miarc.c @@ -1565,7 +1565,7 @@ miGetArcPts( cdt = 2 * miDcos(dt);
if (!(poly = (SppPointPtr) realloc((pointer)*ppPts,
(cpt + count) * sizeof(SppPointRec))))
- return(0);
+ return 0;
*ppPts = poly;
xc = parc->width/2.0; /* store half width and half height */
@@ -1602,7 +1602,7 @@ miGetArcPts( poly[cpt +i -1].y = (miDsin(st + et) * parc->height/2.0 + yc);
}
- return(count);
+ return count;
}
struct arcData {
@@ -3085,10 +3085,8 @@ fillSpans ( (*pGC->ops->FillSpans) (pDrawable, pGC, i, xSpans, xWidths, TRUE);
}
disposeFinalSpans ();
- if (xSpans)
- free(xSpans);
- if (xWidths)
- free(xWidths);
+ free(xSpans);
+ free(xWidths);
finalMiny = 0;
finalMaxy = -1;
finalSize = 0;
@@ -3139,9 +3137,9 @@ realFindSpan (int y) free(finalSpans);
}
if ((i = finalMiny - newMiny) > 0)
- bzero ((char *)newSpans, i * sizeof (struct finalSpan *));
+ memset((char *)newSpans, 0, i * sizeof (struct finalSpan *));
if ((i = newMaxy - finalMaxy) > 0)
- bzero ((char *)(newSpans + newSize - i),
+ memset((char *)(newSpans + newSize - i), 0,
i * sizeof (struct finalSpan *));
finalSpans = newSpans;
finalMaxy = newMaxy;
diff --git a/xorg-server/mi/mibitblt.c b/xorg-server/mi/mibitblt.c index b1e188d5a..3374ae385 100644 --- a/xorg-server/mi/mibitblt.c +++ b/xorg-server/mi/mibitblt.c @@ -116,7 +116,7 @@ miCopyArea(DrawablePtr pSrcDrawable, box.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
box.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
- prgnSrcClip = REGION_CREATE(pGC->pScreen, &box, 1);
+ prgnSrcClip = RegionCreate(&box, 1);
realSrcClip = 1;
}
else
@@ -145,17 +145,14 @@ miCopyArea(DrawablePtr pSrcDrawable, pptFirst = ppt = malloc(heightSrc * sizeof(DDXPointRec));
pwidthFirst = pwidth = malloc(heightSrc * sizeof(unsigned int));
- numRects = REGION_NUM_RECTS(prgnSrcClip);
- boxes = REGION_RECTS(prgnSrcClip);
+ numRects = RegionNumRects(prgnSrcClip);
+ boxes = RegionRects(prgnSrcClip);
ordering = malloc(numRects * sizeof(unsigned int));
if(!pptFirst || !pwidthFirst || !ordering)
{
- if (ordering)
- free(ordering);
- if (pwidthFirst)
- free(pwidthFirst);
- if (pptFirst)
- free(pptFirst);
+ free(ordering);
+ free(pwidthFirst);
+ free(pptFirst);
return NULL;
}
@@ -259,7 +256,7 @@ miCopyArea(DrawablePtr pSrcDrawable, prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
widthSrc, heightSrc, xOut, yOut, (unsigned long)0);
if(realSrcClip)
- REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ RegionDestroy(prgnSrcClip);
free(ordering);
free(pwidthFirst);
@@ -382,7 +379,7 @@ miGetPlane( pOut += delta;
}
}
- return(result);
+ return result;
}
@@ -433,8 +430,8 @@ miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc, pwidth = pwidthFirst = malloc(h * sizeof(int));
if(!pptFirst || !pwidthFirst)
{
- if (pwidthFirst) free(pwidthFirst);
- if (pptFirst) free(pptFirst);
+ free(pwidthFirst);
+ free(pptFirst);
FreeScratchGC(pGCT);
return;
}
@@ -443,9 +440,9 @@ miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc, to destroy what it's sent. note that this means we don't
have to free prgnSrcClip ourselves.
*/
- prgnSrcClip = REGION_CREATE(pGCT->pScreen, NULL, 0);
- REGION_COPY(pGCT->pScreen, prgnSrcClip, prgnSrc);
- REGION_TRANSLATE(pGCT->pScreen, prgnSrcClip, srcx, 0);
+ prgnSrcClip = RegionCreate(NULL, 0);
+ RegionCopy(prgnSrcClip, prgnSrc);
+ RegionTranslate(prgnSrcClip, srcx, 0);
(*pGCT->funcs->ChangeClip)(pGCT, CT_REGION, prgnSrcClip, 0);
ValidateGC((DrawablePtr)pPixmap, pGCT);
@@ -578,7 +575,7 @@ miCopyPlane( DrawablePtr pSrcDrawable, box.x2 = box.x1;
if (box.y1 > box.y2)
box.y2 = box.y1;
- prgnSrc = REGION_CREATE(pGC->pScreen, &box, 1);
+ prgnSrc = RegionCreate(&box, 1);
if (pSrcDrawable->type != DRAWABLE_PIXMAP) {
/* clip to visible drawable */
@@ -586,15 +583,15 @@ miCopyPlane( DrawablePtr pSrcDrawable, if (pGC->subWindowMode == IncludeInferiors)
{
RegionPtr clipList = NotClippedByChildren ((WindowPtr) pSrcDrawable);
- REGION_INTERSECT(pGC->pScreen, prgnSrc, prgnSrc, clipList);
- REGION_DESTROY(pGC->pScreen, clipList);
+ RegionIntersect(prgnSrc, prgnSrc, clipList);
+ RegionDestroy(clipList);
} else
- REGION_INTERSECT(pGC->pScreen, prgnSrc, prgnSrc,
+ RegionIntersect(prgnSrc, prgnSrc,
&((WindowPtr)pSrcDrawable)->clipList);
}
- box = *REGION_EXTENTS(pGC->pScreen, prgnSrc);
- REGION_TRANSLATE(pGC->pScreen, prgnSrc, -box.x1, -box.y1);
+ box = *RegionExtents(prgnSrc);
+ RegionTranslate(prgnSrc, -box.x1, -box.y1);
if ((box.x2 > box.x1) && (box.y2 > box.y1))
{
@@ -618,7 +615,7 @@ miCopyPlane( DrawablePtr pSrcDrawable, }
prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, srcx, srcy,
width, height, dstx, dsty, bitPlane);
- REGION_DESTROY(pGC->pScreen, prgnSrc);
+ RegionDestroy(prgnSrc);
return prgnExposed;
}
@@ -761,11 +758,11 @@ miPutImage( DrawablePtr pDraw, GCPtr pGC, int depth, box.y1 = 0;
box.x2 = w;
box.y2 = h;
- prgnSrc = REGION_CREATE(pGC->pScreen, &box, 1);
+ prgnSrc = RegionCreate(&box, 1);
miOpqStipDrawable(pDraw, pGC, prgnSrc, (MiBits *) pImage,
leftPad, w, h, x, y);
- REGION_DESTROY(pGC->pScreen, prgnSrc);
+ RegionDestroy(prgnSrc);
break;
case XYPixmap:
@@ -801,10 +798,8 @@ miPutImage( DrawablePtr pDraw, GCPtr pGC, int depth, pwidth = pwidthFirst = malloc(h * sizeof(int));
if(!pptFirst || !pwidthFirst)
{
- if (pwidthFirst)
- free(pwidthFirst);
- if (pptFirst)
- free(pptFirst);
+ free(pwidthFirst);
+ free(pptFirst);
return;
}
if (pGC->miTranslate)
diff --git a/xorg-server/mi/micmap.c b/xorg-server/mi/micmap.c index 33dc2de51..456b7621d 100644 --- a/xorg-server/mi/micmap.c +++ b/xorg-server/mi/micmap.c @@ -40,15 +40,14 @@ #include "globals.h"
#include "micmap.h"
-static int micmapScrPrivateKeyIndex;
-DevPrivateKey micmapScrPrivateKey = &micmapScrPrivateKeyIndex;
+DevPrivateKeyRec micmapScrPrivateKeyRec;
int
miListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
{
if (GetInstalledmiColormap(pScreen)) {
*pmaps = GetInstalledmiColormap(pScreen)->mid;
- return (1);
+ return 1;
}
return 0;
}
@@ -311,6 +310,9 @@ miCreateDefColormap(ScreenPtr pScreen) ColormapPtr cmap;
int alloctype;
+ if (!dixRegisterPrivateKey(&micmapScrPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
for (pVisual = pScreen->visuals;
pVisual->vid != pScreen->rootVisual;
pVisual++)
diff --git a/xorg-server/mi/micmap.h b/xorg-server/mi/micmap.h index 8ad94b9dd..dcfcfd47f 100644 --- a/xorg-server/mi/micmap.h +++ b/xorg-server/mi/micmap.h @@ -1,63 +1,63 @@ - -#include "colormapst.h" - -#ifndef _MICMAP_H_ -#define _MICMAP_H_ - -#define GetInstalledmiColormap(s) \ - ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, micmapScrPrivateKey)) -#define SetInstalledmiColormap(s,c) \ - (dixSetPrivate(&(s)->devPrivates, micmapScrPrivateKey, c)) - -extern _X_EXPORT DevPrivateKey micmapScrPrivateKey; - - -typedef Bool (* miInitVisualsProcPtr)(VisualPtr *, DepthPtr *, int *, int *, - int *, VisualID *, unsigned long, int, - int); - -extern _X_EXPORT int miListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps); -extern _X_EXPORT void miInstallColormap(ColormapPtr pmap); -extern _X_EXPORT void miUninstallColormap(ColormapPtr pmap); - -extern _X_EXPORT void miResolveColor(unsigned short *, unsigned short *, unsigned short *, - VisualPtr); -extern _X_EXPORT Bool miInitializeColormap(ColormapPtr); -extern _X_EXPORT int miExpandDirectColors(ColormapPtr, int, xColorItem *, xColorItem *); -extern _X_EXPORT Bool miCreateDefColormap(ScreenPtr); -extern _X_EXPORT void miClearVisualTypes(void); -extern _X_EXPORT Bool miSetVisualTypes(int, int, int, int); -extern _X_EXPORT Bool miSetPixmapDepths(void); -extern _X_EXPORT Bool miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, - int preferredCVC, - Pixel redMask, Pixel greenMask, Pixel blueMask); -extern _X_EXPORT int miGetDefaultVisualMask(int); -extern _X_EXPORT Bool miInitVisuals(VisualPtr *, DepthPtr *, int *, int *, int *, VisualID *, - unsigned long, int, int); - -#define MAX_PSEUDO_DEPTH 10 -#define MIN_TRUE_DEPTH 6 - -#define StaticGrayMask (1 << StaticGray) -#define GrayScaleMask (1 << GrayScale) -#define StaticColorMask (1 << StaticColor) -#define PseudoColorMask (1 << PseudoColor) -#define TrueColorMask (1 << TrueColor) -#define DirectColorMask (1 << DirectColor) - -#define ALL_VISUALS (StaticGrayMask|\ - GrayScaleMask|\ - StaticColorMask|\ - PseudoColorMask|\ - TrueColorMask|\ - DirectColorMask) - -#define LARGE_VISUALS (TrueColorMask|\ - DirectColorMask) - -#define SMALL_VISUALS (StaticGrayMask|\ - GrayScaleMask|\ - StaticColorMask|\ - PseudoColorMask) - -#endif /* _MICMAP_H_ */ +
+#include "colormapst.h"
+
+#ifndef _MICMAP_H_
+#define _MICMAP_H_
+
+#define GetInstalledmiColormap(s) \
+ ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, micmapScrPrivateKey))
+#define SetInstalledmiColormap(s,c) \
+ (dixSetPrivate(&(s)->devPrivates, micmapScrPrivateKey, c))
+
+extern _X_EXPORT DevPrivateKeyRec micmapScrPrivateKeyRec;
+#define micmapScrPrivateKey (&micmapScrPrivateKeyRec)
+
+typedef Bool (* miInitVisualsProcPtr)(VisualPtr *, DepthPtr *, int *, int *,
+ int *, VisualID *, unsigned long, int,
+ int);
+
+extern _X_EXPORT int miListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps);
+extern _X_EXPORT void miInstallColormap(ColormapPtr pmap);
+extern _X_EXPORT void miUninstallColormap(ColormapPtr pmap);
+
+extern _X_EXPORT void miResolveColor(unsigned short *, unsigned short *, unsigned short *,
+ VisualPtr);
+extern _X_EXPORT Bool miInitializeColormap(ColormapPtr);
+extern _X_EXPORT int miExpandDirectColors(ColormapPtr, int, xColorItem *, xColorItem *);
+extern _X_EXPORT Bool miCreateDefColormap(ScreenPtr);
+extern _X_EXPORT void miClearVisualTypes(void);
+extern _X_EXPORT Bool miSetVisualTypes(int, int, int, int);
+extern _X_EXPORT Bool miSetPixmapDepths(void);
+extern _X_EXPORT Bool miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB,
+ int preferredCVC,
+ Pixel redMask, Pixel greenMask, Pixel blueMask);
+extern _X_EXPORT int miGetDefaultVisualMask(int);
+extern _X_EXPORT Bool miInitVisuals(VisualPtr *, DepthPtr *, int *, int *, int *, VisualID *,
+ unsigned long, int, int);
+
+#define MAX_PSEUDO_DEPTH 10
+#define MIN_TRUE_DEPTH 6
+
+#define StaticGrayMask (1 << StaticGray)
+#define GrayScaleMask (1 << GrayScale)
+#define StaticColorMask (1 << StaticColor)
+#define PseudoColorMask (1 << PseudoColor)
+#define TrueColorMask (1 << TrueColor)
+#define DirectColorMask (1 << DirectColor)
+
+#define ALL_VISUALS (StaticGrayMask|\
+ GrayScaleMask|\
+ StaticColorMask|\
+ PseudoColorMask|\
+ TrueColorMask|\
+ DirectColorMask)
+
+#define LARGE_VISUALS (TrueColorMask|\
+ DirectColorMask)
+
+#define SMALL_VISUALS (StaticGrayMask|\
+ GrayScaleMask|\
+ StaticColorMask|\
+ PseudoColorMask)
+
+#endif /* _MICMAP_H_ */
diff --git a/xorg-server/mi/micopy.c b/xorg-server/mi/micopy.c index 9d5c5ce5e..da52bc659 100644 --- a/xorg-server/mi/micopy.c +++ b/xorg-server/mi/micopy.c @@ -49,8 +49,8 @@ miCopyRegion (DrawablePtr pSrcDrawable, int nbox;
BoxPtr pboxNew1, pboxNew2, pboxBase, pboxNext, pboxTmp;
- pbox = REGION_RECTS(pDstRegion);
- nbox = REGION_NUM_RECTS(pDstRegion);
+ pbox = RegionRects(pDstRegion);
+ nbox = RegionNumRects(pDstRegion);
/* XXX we have to err on the side of safety when both are windows,
* because we don't know if IncludeInferiors is being used.
@@ -108,8 +108,7 @@ miCopyRegion (DrawablePtr pSrcDrawable, pboxNew2 = (BoxPtr)malloc(sizeof(BoxRec) * nbox);
if(!pboxNew2)
{
- if (pboxNew1)
- free(pboxNew1);
+ free(pboxNew1);
return;
}
pboxBase = pboxNext = pbox;
@@ -143,10 +142,8 @@ miCopyRegion (DrawablePtr pSrcDrawable, dx, dy,
reverse, upsidedown, bitPlane, closure);
- if (pboxNew1)
- free(pboxNew1);
- if (pboxNew2)
- free(pboxNew2);
+ free(pboxNew1);
+ free(pboxNew2);
}
RegionPtr
@@ -209,8 +206,7 @@ miDoCopy (DrawablePtr pSrcDrawable, * VT is inactive, make sure the region isn't empty
*/
if (!((WindowPtr) pSrcDrawable)->parent &&
- REGION_NOTEMPTY (pSrcDrawable->pScreen,
- &((WindowPtr) pSrcDrawable)->borderClip))
+ RegionNotEmpty(&((WindowPtr) pSrcDrawable)->borderClip))
{
/*
* special case bitblt from root window in
@@ -291,9 +287,9 @@ miDoCopy (DrawablePtr pSrcDrawable, blown region and call intersect */
cclip = miGetCompositeClip(pGC);
- if (REGION_NUM_RECTS(cclip) == 1)
+ if (RegionNumRects(cclip) == 1)
{
- BoxPtr pBox = REGION_RECTS(cclip);
+ BoxPtr pBox = RegionRects(cclip);
if (box_x1 < pBox->x1) box_x1 = pBox->x1;
if (box_x2 > pBox->x2) box_x2 = pBox->x2;
@@ -306,7 +302,7 @@ miDoCopy (DrawablePtr pSrcDrawable, /* Check to see if the region is empty */
if (box_x1 >= box_x2 || box_y1 >= box_y2)
{
- REGION_NULL(pGC->pScreen, &rgnDst);
+ RegionNull(&rgnDst);
}
else
{
@@ -315,25 +311,25 @@ miDoCopy (DrawablePtr pSrcDrawable, box.y1 = box_y1;
box.x2 = box_x2;
box.y2 = box_y2;
- REGION_INIT(pGC->pScreen, &rgnDst, &box, 1);
+ RegionInit(&rgnDst, &box, 1);
}
/* Clip against complex source if needed */
if (!fastSrc)
{
- REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
- REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+ RegionIntersect(&rgnDst, &rgnDst, prgnSrcClip);
+ RegionTranslate(&rgnDst, -dx, -dy);
}
/* Clip against complex dest if needed */
if (!fastDst)
{
- REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst,
+ RegionIntersect(&rgnDst, &rgnDst,
miGetCompositeClip(pGC));
}
/* Do bit blitting */
- numRects = REGION_NUM_RECTS(&rgnDst);
+ numRects = RegionNumRects(&rgnDst);
if (numRects && widthSrc && heightSrc)
miCopyRegion (pSrcDrawable, pDstDrawable, pGC,
&rgnDst, dx, dy, copyProc, bitPlane, closure);
@@ -347,8 +343,8 @@ miDoCopy (DrawablePtr pSrcDrawable, xOut - pDstDrawable->x,
yOut - pDstDrawable->y,
(unsigned long) bitPlane);
- REGION_UNINIT(pGC->pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if (freeSrcClip)
- REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ RegionDestroy(prgnSrcClip);
return prgnExposed;
}
diff --git a/xorg-server/mi/midispcur.c b/xorg-server/mi/midispcur.c index d56080488..7d79042f4 100644 --- a/xorg-server/mi/midispcur.c +++ b/xorg-server/mi/midispcur.c @@ -54,40 +54,40 @@ in this Software without prior written authorization from The Open Group. # include "inputstr.h"
/* per-screen private data */
-static int miDCScreenKeyIndex;
-static DevPrivateKey miDCScreenKey = &miDCScreenKeyIndex;
+static DevPrivateKeyRec miDCScreenKeyRec;
+#define miDCScreenKey (&miDCScreenKeyRec)
static Bool miDCCloseScreen(int index, ScreenPtr pScreen);
-/* per device per-screen private data */
-static int miDCSpriteKeyIndex[MAXSCREENS];
-static DevPrivateKey miDCSpriteKey = miDCSpriteKeyIndex;
-
+/* per device private data */
typedef struct {
GCPtr pSourceGC, pMaskGC;
GCPtr pSaveGC, pRestoreGC;
- GCPtr pMoveGC;
- GCPtr pPixSourceGC, pPixMaskGC;
- PixmapPtr pSave, pTemp;
+ PixmapPtr pSave;
#ifdef ARGB_CURSOR
PicturePtr pRootPicture;
- PicturePtr pTempPicture;
#endif
} miDCBufferRec, *miDCBufferPtr;
-#define MIDCBUFFER(dev, screen) \
+#define miGetDCDevice(dev, screen) \
((DevHasCursor(dev)) ? \
- (miDCBufferPtr)dixLookupPrivate(&dev->devPrivates, miDCSpriteKey + (screen)->myNum) : \
- (miDCBufferPtr)dixLookupPrivate(&dev->u.master->devPrivates, miDCSpriteKey + (screen)->myNum))
+ (miDCBufferPtr)dixLookupPrivate(&dev->devPrivates, miDCDeviceKey(screen)) : \
+ (miDCBufferPtr)dixLookupPrivate(&dev->u.master->devPrivates, miDCDeviceKey(screen)))
/*
* The core pointer buffer will point to the index of the virtual core pointer
* in the pCursorBuffers array.
*/
typedef struct {
- CloseScreenProcPtr CloseScreen;
+ CloseScreenProcPtr CloseScreen;
+ DevPrivateKey device_key;
+ DevPrivateKey cursor_bits_key;
} miDCScreenRec, *miDCScreenPtr;
+#define miGetDCScreen(s) ((miDCScreenPtr)(dixLookupPrivate(&(s)->devPrivates, miDCScreenKey)))
+#define miDCDeviceKey(s) (miGetDCScreen(s)->device_key)
+#define miDCCursorBitsKey(s) (miGetDCScreen(s)->cursor_bits_key)
+
/* per-cursor per-screen private data */
typedef struct {
PixmapPtr sourceBits; /* source bits */
@@ -102,11 +102,19 @@ miDCInitialize (ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs) {
miDCScreenPtr pScreenPriv;
+ if (!dixRegisterPrivateKey(&miDCScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
pScreenPriv = malloc(sizeof (miDCScreenRec));
if (!pScreenPriv)
return FALSE;
-
+ pScreenPriv->cursor_bits_key = dixCreatePrivateKey(PRIVATE_CURSOR_BITS, 0);
+ pScreenPriv->device_key = dixCreatePrivateKey(PRIVATE_DEVICE, 0);
+ if (!pScreenPriv->cursor_bits_key || !pScreenPriv->device_key) {
+ free(pScreenPriv);
+ return FALSE;
+ }
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = miDCCloseScreen;
@@ -136,7 +144,7 @@ Bool miDCRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
{
if (pCursor->bits->refcnt <= 1)
- dixSetPrivate(&pCursor->bits->devPrivates, CursorScreenKey(pScreen), NULL);
+ dixSetPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey(pScreen), NULL);
return TRUE;
}
@@ -235,7 +243,7 @@ miDCRealize (ScreenPtr pScreen, CursorPtr pCursor) free((pointer) pPriv);
return NULL;
}
- dixSetPrivate(&pCursor->bits->devPrivates, CursorScreenKey(pScreen), pPriv);
+ dixSetPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey(pScreen), pPriv);
return pPriv;
}
pPriv->pPicture = 0;
@@ -253,7 +261,7 @@ miDCRealize (ScreenPtr pScreen, CursorPtr pCursor) free((pointer) pPriv);
return NULL;
}
- dixSetPrivate(&pCursor->bits->devPrivates, CursorScreenKey(pScreen), pPriv);
+ dixSetPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey(pScreen), pPriv);
/* create the two sets of bits, clipping as appropriate */
@@ -298,7 +306,7 @@ miDCUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) miDCCursorPtr pPriv;
pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
- CursorScreenKey(pScreen));
+ miDCCursorBitsKey(pScreen));
if (pPriv && (pCursor->bits->refcnt <= 1))
{
if (pPriv->sourceBits)
@@ -310,7 +318,7 @@ miDCUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) FreePicture (pPriv->pPicture, 0);
#endif
free((pointer) pPriv);
- dixSetPrivate(&pCursor->bits->devPrivates, CursorScreenKey(pScreen), NULL);
+ dixSetPrivate(&pCursor->bits->devPrivates, miDCCursorBitsKey(pScreen), NULL);
}
return TRUE;
}
@@ -399,7 +407,7 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, WindowPtr pWin;
pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
- CursorScreenKey(pScreen));
+ miDCCursorBitsKey(pScreen));
if (!pPriv)
{
pPriv = miDCRealize(pScreen, pCursor);
@@ -408,8 +416,8 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, }
pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
miDCScreenKey);
- pWin = WindowTable[pScreen->myNum];
- pBuffer = MIDCBUFFER(pDev, pScreen);
+ pWin = pScreen->root;
+ pBuffer = miGetDCDevice(pDev, pScreen);
#ifdef ARGB_CURSOR
if (pPriv->pPicture)
@@ -448,10 +456,10 @@ miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen, pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
miDCScreenKey);
- pBuffer = MIDCBUFFER(pDev, pScreen);
+ pBuffer = miGetDCDevice(pDev, pScreen);
pSave = pBuffer->pSave;
- pWin = WindowTable[pScreen->myNum];
+ pWin = pScreen->root;
if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h)
{
if (pSave)
@@ -482,10 +490,10 @@ miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen, pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
miDCScreenKey);
- pBuffer = MIDCBUFFER(pDev, pScreen);
+ pBuffer = miGetDCDevice(pDev, pScreen);
pSave = pBuffer->pSave;
- pWin = WindowTable[pScreen->myNum];
+ pWin = pScreen->root;
if (!pSave)
return FALSE;
@@ -498,243 +506,10 @@ miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen, }
Bool
-miDCChangeSave (DeviceIntPtr pDev, ScreenPtr pScreen,
- int x, int y, int w, int h, int dx, int dy)
-{
- miDCScreenPtr pScreenPriv;
- miDCBufferPtr pBuffer;
- PixmapPtr pSave;
- WindowPtr pWin;
- GCPtr pGC;
- int sourcex, sourcey, destx, desty, copyw, copyh;
-
- pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- miDCScreenKey);
- pBuffer = MIDCBUFFER(pDev, pScreen);
-
- pSave = pBuffer->pSave;
- pWin = WindowTable[pScreen->myNum];
- /*
- * restore the bits which are about to get trashed
- */
- if (!pSave)
- return FALSE;
-
- pGC = pBuffer->pRestoreGC;
- if (pWin->drawable.serialNumber != pGC->serialNumber)
- ValidateGC ((DrawablePtr) pWin, pGC);
- /*
- * copy the old bits to the screen.
- */
- if (dy > 0)
- {
- (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
- 0, h - dy, w, dy, x + dx, y + h);
- }
- else if (dy < 0)
- {
- (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
- 0, 0, w, -dy, x + dx, y + dy);
- }
- if (dy >= 0)
- {
- desty = y + dy;
- sourcey = 0;
- copyh = h - dy;
- }
- else
- {
- desty = y;
- sourcey = - dy;
- copyh = h + dy;
- }
- if (dx > 0)
- {
- (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
- w - dx, sourcey, dx, copyh, x + w, desty);
- }
- else if (dx < 0)
- {
- (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
- 0, sourcey, -dx, copyh, x + dx, desty);
- }
-
- pGC = pBuffer->pSaveGC;
- if (pSave->drawable.serialNumber != pGC->serialNumber)
- ValidateGC ((DrawablePtr) pSave, pGC);
- /*
- * move the bits that are still valid within the pixmap
- */
- if (dx >= 0)
- {
- sourcex = 0;
- destx = dx;
- copyw = w - dx;
- }
- else
- {
- destx = 0;
- sourcex = - dx;
- copyw = w + dx;
- }
- if (dy >= 0)
- {
- sourcey = 0;
- desty = dy;
- copyh = h - dy;
- }
- else
- {
- desty = 0;
- sourcey = -dy;
- copyh = h + dy;
- }
- (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pSave, pGC,
- sourcex, sourcey, copyw, copyh, destx, desty);
- /*
- * copy the new bits from the screen into the remaining areas of the
- * pixmap
- */
- if (dy > 0)
- {
- (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
- x, y, w, dy, 0, 0);
- }
- else if (dy < 0)
- {
- (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
- x, y + h + dy, w, -dy, 0, h + dy);
- }
- if (dy >= 0)
- {
- desty = dy;
- sourcey = y + dy;
- copyh = h - dy;
- }
- else
- {
- desty = 0;
- sourcey = y;
- copyh = h + dy;
- }
- if (dx > 0)
- {
- (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
- x, sourcey, dx, copyh, 0, desty);
- }
- else if (dx < 0)
- {
- (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
- x + w + dx, sourcey, -dx, copyh, w + dx, desty);
- }
- return TRUE;
-}
-
-Bool
-miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
- int x, int y, int w, int h, int dx, int dy,
- unsigned long source, unsigned long mask)
-{
- miDCCursorPtr pPriv;
- miDCScreenPtr pScreenPriv;
- miDCBufferPtr pBuffer;
- int status;
- WindowPtr pWin;
- GCPtr pGC;
- XID gcval = FALSE;
- PixmapPtr pTemp;
-
- pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
- CursorScreenKey(pScreen));
- if (!pPriv)
- {
- pPriv = miDCRealize(pScreen, pCursor);
- if (!pPriv)
- return FALSE;
- }
- pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- miDCScreenKey);
- pWin = WindowTable[pScreen->myNum];
- pBuffer = MIDCBUFFER(pDev, pScreen);
-
- pTemp = pBuffer->pTemp;
- if (!pTemp ||
- pTemp->drawable.width != pBuffer->pSave->drawable.width ||
- pTemp->drawable.height != pBuffer->pSave->drawable.height)
- {
- if (pTemp)
- (*pScreen->DestroyPixmap) (pTemp);
-#ifdef ARGB_CURSOR
- if (pBuffer->pTempPicture)
- {
- FreePicture (pBuffer->pTempPicture, 0);
- pBuffer->pTempPicture = 0;
- }
-#endif
- pBuffer->pTemp = pTemp = (*pScreen->CreatePixmap)
- (pScreen, w, h, pBuffer->pSave->drawable.depth, 0);
- if (!pTemp)
- return FALSE;
- }
- if (!pBuffer->pMoveGC)
- {
- pBuffer->pMoveGC = CreateGC ((DrawablePtr)pTemp,
- GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
- if (!pBuffer->pMoveGC)
- return FALSE;
- }
- /*
- * copy the saved area to a temporary pixmap
- */
- pGC = pBuffer->pMoveGC;
- if (pGC->serialNumber != pTemp->drawable.serialNumber)
- ValidateGC ((DrawablePtr) pTemp, pGC);
- (*pGC->ops->CopyArea)((DrawablePtr)pBuffer->pSave,
- (DrawablePtr)pTemp, pGC, 0, 0, w, h, 0, 0);
-
- /*
- * draw the cursor in the temporary pixmap
- */
-#ifdef ARGB_CURSOR
- if (pPriv->pPicture)
- {
- if (!EnsurePicture(pBuffer->pTempPicture, &pTemp->drawable, pWin))
- return FALSE;
- CompositePicture (PictOpOver,
- pPriv->pPicture,
- NULL,
- pBuffer->pTempPicture,
- 0, 0, 0, 0,
- dx, dy,
- pCursor->bits->width,
- pCursor->bits->height);
- }
- else
-#endif
- {
- miDCPutBits ((DrawablePtr)pTemp, pPriv,
- pBuffer->pPixSourceGC, pBuffer->pPixMaskGC,
- dx, dy, pCursor->bits->width, pCursor->bits->height,
- source, mask);
- }
-
- pGC = pBuffer->pRestoreGC;
- if (pWin->drawable.serialNumber != pGC->serialNumber)
- ValidateGC ((DrawablePtr) pWin, pGC);
-
- (*pGC->ops->CopyArea) ((DrawablePtr) pTemp, (DrawablePtr) pWin,
- pGC,
- 0, 0, w, h, x, y);
- return TRUE;
-}
-
-Bool
miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
{
miDCBufferPtr pBuffer;
WindowPtr pWin;
- XID gcval = FALSE;
- int status;
int i;
if (!DevHasCursor(pDev))
@@ -748,8 +523,8 @@ miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) if (!pBuffer)
goto failure;
- dixSetPrivate(&pDev->devPrivates, miDCSpriteKey + pScreen->myNum, pBuffer);
- pWin = WindowTable[pScreen->myNum];
+ dixSetPrivate(&pDev->devPrivates, miDCDeviceKey(pScreen), pBuffer);
+ pWin = pScreen->root;
pBuffer->pSourceGC = miDCMakeGC(pWin);
if (!pBuffer->pSourceGC)
@@ -767,28 +542,12 @@ miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) if (!pBuffer->pRestoreGC)
goto failure;
- pBuffer->pMoveGC = CreateGC ((DrawablePtr)pWin,
- GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
- if (!pBuffer->pMoveGC)
- goto failure;
-
- pBuffer->pPixSourceGC = CreateGC ((DrawablePtr)pWin,
- GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
- if (!pBuffer->pPixSourceGC)
- goto failure;
-
- pBuffer->pPixMaskGC = CreateGC ((DrawablePtr)pWin,
- GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
- if (!pBuffer->pPixMaskGC)
- goto failure;
-
#ifdef ARGB_CURSOR
pBuffer->pRootPicture = NULL;
- pBuffer->pTempPicture = NULL;
#endif
- // these get (re)allocated lazily depending on the cursor size
- pBuffer->pSave = pBuffer->pTemp = NULL;
+ /* (re)allocated lazily depending on the cursor size */
+ pBuffer->pSave = NULL;
}
return TRUE;
@@ -812,7 +571,7 @@ miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) {
pScreen = screenInfo.screens[i];
- pBuffer = MIDCBUFFER(pDev, pScreen);
+ pBuffer = miGetDCDevice(pDev, pScreen);
if (pBuffer)
{
@@ -820,15 +579,17 @@ miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) if (pBuffer->pMaskGC) FreeGC(pBuffer->pMaskGC, (GContext) 0);
if (pBuffer->pSaveGC) FreeGC(pBuffer->pSaveGC, (GContext) 0);
if (pBuffer->pRestoreGC) FreeGC(pBuffer->pRestoreGC, (GContext) 0);
- if (pBuffer->pMoveGC) FreeGC(pBuffer->pMoveGC, (GContext) 0);
- if (pBuffer->pPixSourceGC) FreeGC(pBuffer->pPixSourceGC, (GContext) 0);
- if (pBuffer->pPixMaskGC) FreeGC(pBuffer->pPixMaskGC, (GContext) 0);
+
+#ifdef ARGB_CURSOR
+ /* If a pRootPicture was allocated for a root window, it
+ * is freed when that root window is destroyed, so don't
+ * free it again here. */
+#endif
if (pBuffer->pSave) (*pScreen->DestroyPixmap)(pBuffer->pSave);
- if (pBuffer->pTemp) (*pScreen->DestroyPixmap)(pBuffer->pTemp);
free(pBuffer);
- dixSetPrivate(&pDev->devPrivates, miDCSpriteKey + pScreen->myNum, NULL);
+ dixSetPrivate(&pDev->devPrivates, miDCDeviceKey(pScreen), NULL);
}
}
}
diff --git a/xorg-server/mi/miexpose.c b/xorg-server/mi/miexpose.c index 2fc19f6ec..89f45016d 100644 --- a/xorg-server/mi/miexpose.c +++ b/xorg-server/mi/miexpose.c @@ -131,7 +131,6 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, int srcx, int srcy, int width, int height,
int dstx, int dsty, unsigned long plane)
{
- ScreenPtr pscr;
RegionPtr prgnSrcClip; /* drawable-relative source clip */
RegionRec rgnSrcRec;
RegionPtr prgnDstClip; /* drawable-relative dest clip */
@@ -148,9 +147,6 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, BoxRec expBox;
Bool extents;
- /* This prevents warning about pscr not being used. */
- pGC->pScreen = pscr = pGC->pScreen;
-
/* avoid work if we can */
if (!pGC->graphicsExposures &&
(pDstDrawable->type == DRAWABLE_PIXMAP) &&
@@ -175,21 +171,21 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, if (pGC->subWindowMode == IncludeInferiors)
{
prgnSrcClip = NotClippedByChildren (pSrcWin);
- if ((RECT_IN_REGION(pscr, prgnSrcClip, &TsrcBox)) == rgnIN)
+ if ((RegionContainsRect(prgnSrcClip, &TsrcBox)) == rgnIN)
{
- REGION_DESTROY(pscr, prgnSrcClip);
+ RegionDestroy(prgnSrcClip);
return NULL;
}
}
else
{
- if ((RECT_IN_REGION(pscr, &pSrcWin->clipList, &TsrcBox)) == rgnIN)
+ if ((RegionContainsRect(&pSrcWin->clipList, &TsrcBox)) == rgnIN)
return NULL;
prgnSrcClip = &rgnSrcRec;
- REGION_NULL(pscr, prgnSrcClip);
- REGION_COPY(pscr, prgnSrcClip, &pSrcWin->clipList);
+ RegionNull(prgnSrcClip);
+ RegionCopy(prgnSrcClip, &pSrcWin->clipList);
}
- REGION_TRANSLATE(pscr, prgnSrcClip,
+ RegionTranslate(prgnSrcClip,
-pSrcDrawable->x, -pSrcDrawable->y);
}
else
@@ -206,7 +202,7 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, box.x2 = pSrcDrawable->width;
box.y2 = pSrcDrawable->height;
prgnSrcClip = &rgnSrcRec;
- REGION_INIT(pscr, prgnSrcClip, &box, 1);
+ RegionInit(prgnSrcClip, &box, 1);
pSrcWin = NULL;
}
@@ -223,11 +219,11 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, else
{
prgnDstClip = &rgnDstRec;
- REGION_NULL(pscr, prgnDstClip);
- REGION_COPY(pscr, prgnDstClip,
+ RegionNull(prgnDstClip);
+ RegionCopy(prgnDstClip,
&((WindowPtr)pDstDrawable)->clipList);
}
- REGION_TRANSLATE(pscr, prgnDstClip,
+ RegionTranslate(prgnDstClip,
-pDstDrawable->x, -pDstDrawable->y);
}
else
@@ -239,24 +235,24 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, box.x2 = pDstDrawable->width;
box.y2 = pDstDrawable->height;
prgnDstClip = &rgnDstRec;
- REGION_INIT(pscr, prgnDstClip, &box, 1);
+ RegionInit(prgnDstClip, &box, 1);
}
/* drawable-relative source region */
- REGION_INIT(pscr, &rgnExposed, &srcBox, 1);
+ RegionInit(&rgnExposed, &srcBox, 1);
/* now get the hidden parts of the source box*/
- REGION_SUBTRACT(pscr, &rgnExposed, &rgnExposed, prgnSrcClip);
+ RegionSubtract(&rgnExposed, &rgnExposed, prgnSrcClip);
/* move them over the destination */
- REGION_TRANSLATE(pscr, &rgnExposed, dstx-srcx, dsty-srcy);
+ RegionTranslate(&rgnExposed, dstx-srcx, dsty-srcy);
/* intersect with visible areas of dest */
- REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, prgnDstClip);
+ RegionIntersect(&rgnExposed, &rgnExposed, prgnDstClip);
/* intersect with client clip region. */
if (pGC->clientClipType == CT_REGION)
- REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, pGC->clientClip);
+ RegionIntersect(&rgnExposed, &rgnExposed, pGC->clientClip);
/*
* If we have LOTS of rectangles, we decide to take the extents
@@ -266,7 +262,7 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, * for windows.
*/
extents = pGC->graphicsExposures &&
- (REGION_NUM_RECTS(&rgnExposed) > RECTLIMIT) &&
+ (RegionNumRects(&rgnExposed) > RECTLIMIT) &&
(pDstDrawable->type != DRAWABLE_PIXMAP);
if (pSrcWin)
{
@@ -278,13 +274,13 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, * exposed region will undo all our work!
*/
if (extents && pSrcWin && region &&
- (RECT_IN_REGION(pscr, region, &srcBox) != rgnIN))
+ (RegionContainsRect(region, &srcBox) != rgnIN))
extents = FALSE;
}
if (extents)
{
- expBox = *REGION_EXTENTS(pscr, &rgnExposed);
- REGION_RESET(pscr, &rgnExposed, &expBox);
+ expBox = *RegionExtents(&rgnExposed);
+ RegionReset(&rgnExposed, &expBox);
}
if ((pDstDrawable->type != DRAWABLE_PIXMAP) &&
(((WindowPtr)pDstDrawable)->backgroundState != None))
@@ -292,52 +288,52 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, WindowPtr pWin = (WindowPtr)pDstDrawable;
/* make the exposed area screen-relative */
- REGION_TRANSLATE(pscr, &rgnExposed,
+ RegionTranslate(&rgnExposed,
pDstDrawable->x, pDstDrawable->y);
if (extents)
{
/* miPaintWindow doesn't clip, so we have to */
- REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, &pWin->clipList);
+ RegionIntersect(&rgnExposed, &rgnExposed, &pWin->clipList);
}
miPaintWindow((WindowPtr)pDstDrawable, &rgnExposed, PW_BACKGROUND);
if (extents)
{
- REGION_RESET(pscr, &rgnExposed, &expBox);
+ RegionReset(&rgnExposed, &expBox);
}
else
- REGION_TRANSLATE(pscr, &rgnExposed,
+ RegionTranslate(&rgnExposed,
-pDstDrawable->x, -pDstDrawable->y);
}
if (prgnDstClip == &rgnDstRec)
{
- REGION_UNINIT(pscr, prgnDstClip);
+ RegionUninit(prgnDstClip);
}
else if (prgnDstClip != prgnSrcClip)
{
- REGION_DESTROY(pscr, prgnDstClip);
+ RegionDestroy(prgnDstClip);
}
if (prgnSrcClip == &rgnSrcRec)
{
- REGION_UNINIT(pscr, prgnSrcClip);
+ RegionUninit(prgnSrcClip);
}
else
{
- REGION_DESTROY(pscr, prgnSrcClip);
+ RegionDestroy(prgnSrcClip);
}
if (pGC->graphicsExposures)
{
/* don't look */
- RegionPtr exposed = REGION_CREATE(pscr, NullBox, 0);
+ RegionPtr exposed = RegionCreate(NullBox, 0);
*exposed = rgnExposed;
return exposed;
}
else
{
- REGION_UNINIT(pscr, &rgnExposed);
+ RegionUninit(&rgnExposed);
return NULL;
}
}
@@ -348,7 +344,7 @@ void miSendGraphicsExpose (ClientPtr client, RegionPtr pRgn, XID drawable,
int major, int minor)
{
- if (pRgn && !REGION_NIL(pRgn))
+ if (pRgn && !RegionNil(pRgn))
{
xEvent *pEvent;
xEvent *pe;
@@ -356,8 +352,8 @@ miSendGraphicsExpose (ClientPtr client, RegionPtr pRgn, XID drawable, int i;
int numRects;
- numRects = REGION_NUM_RECTS(pRgn);
- pBox = REGION_RECTS(pRgn);
+ numRects = RegionNumRects(pRgn);
+ pBox = RegionRects(pRgn);
if(!(pEvent = malloc(numRects * sizeof(xEvent))))
return;
pe = pEvent;
@@ -401,8 +397,8 @@ miSendExposures( WindowPtr pWin, RegionPtr pRgn, int dx, int dy) xEvent *pEvent, *pe;
int i;
- pBox = REGION_RECTS(pRgn);
- numRects = REGION_NUM_RECTS(pRgn);
+ pBox = RegionRects(pRgn);
+ numRects = RegionNumRects(pRgn);
if(!(pEvent = calloc(1, numRects * sizeof(xEvent))))
return;
@@ -424,9 +420,9 @@ miSendExposures( WindowPtr pWin, RegionPtr pRgn, int dx, int dy) XID realWin = 0;
if(!pWin->parent) {
- x = panoramiXdataPtr[scrnum].x;
- y = panoramiXdataPtr[scrnum].y;
- pWin = WindowTable[0];
+ x = screenInfo.screens[scrnum]->x;
+ y = screenInfo.screens[scrnum]->y;
+ pWin = screenInfo.screens[0]->root;
realWin = pWin->drawable.id;
} else if (scrnum) {
PanoramiXRes *win;
@@ -457,8 +453,8 @@ void miWindowExposures( WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed)
{
RegionPtr exposures = prgn;
- if ((prgn && !REGION_NIL(prgn)) ||
- (exposures && !REGION_NIL(exposures)) || other_exposed)
+ if ((prgn && !RegionNil(prgn)) ||
+ (exposures && !RegionNil(exposures)) || other_exposed)
{
RegionRec expRec;
int clientInterested;
@@ -471,15 +467,15 @@ miWindowExposures( WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed) {
if (exposures)
{
- REGION_UNION(pWin->drawable.pScreen, other_exposed,
+ RegionUnion(other_exposed,
exposures,
other_exposed);
if (exposures != prgn)
- REGION_DESTROY(pWin->drawable.pScreen, exposures);
+ RegionDestroy(exposures);
}
exposures = other_exposed;
}
- if (clientInterested && exposures && (REGION_NUM_RECTS(exposures) > RECTLIMIT))
+ if (clientInterested && exposures && (RegionNumRects(exposures) > RECTLIMIT))
{
/*
* If we have LOTS of rectangles, we decide to take the extents
@@ -489,34 +485,34 @@ miWindowExposures( WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed) */
BoxRec box;
- box = *REGION_EXTENTS( pWin->drawable.pScreen, exposures);
+ box = *RegionExtents(exposures);
if (exposures == prgn) {
exposures = &expRec;
- REGION_INIT( pWin->drawable.pScreen, exposures, &box, 1);
- REGION_RESET( pWin->drawable.pScreen, prgn, &box);
+ RegionInit(exposures, &box, 1);
+ RegionReset(prgn, &box);
} else {
- REGION_RESET( pWin->drawable.pScreen, exposures, &box);
- REGION_UNION( pWin->drawable.pScreen, prgn, prgn, exposures);
+ RegionReset(exposures, &box);
+ RegionUnion(prgn, prgn, exposures);
}
/* miPaintWindow doesn't clip, so we have to */
- REGION_INTERSECT( pWin->drawable.pScreen, prgn, prgn, &pWin->clipList);
+ RegionIntersect(prgn, prgn, &pWin->clipList);
}
- if (prgn && !REGION_NIL(prgn))
+ if (prgn && !RegionNil(prgn))
miPaintWindow(pWin, prgn, PW_BACKGROUND);
- if (clientInterested && exposures && !REGION_NIL(exposures))
+ if (clientInterested && exposures && !RegionNil(exposures))
miSendExposures(pWin, exposures,
pWin->drawable.x, pWin->drawable.y);
if (exposures == &expRec)
{
- REGION_UNINIT( pWin->drawable.pScreen, exposures);
+ RegionUninit(exposures);
}
else if (exposures && exposures != prgn && exposures != other_exposed)
- REGION_DESTROY( pWin->drawable.pScreen, exposures);
+ RegionDestroy(exposures);
if (prgn)
- REGION_EMPTY( pWin->drawable.pScreen, prgn);
+ RegionEmpty(prgn);
}
else if (exposures && exposures != prgn)
- REGION_DESTROY( pWin->drawable.pScreen, exposures);
+ RegionDestroy(exposures);
}
#ifdef ROOTLESS
@@ -647,7 +643,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
}
- prect = malloc(REGION_NUM_RECTS(prgn) * sizeof(xRectangle));
+ prect = malloc(RegionNumRects(prgn) * sizeof(xRectangle));
if (!prect)
return;
@@ -661,8 +657,8 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) ChangeGC (NullClient, pGC, gcmask, gcval);
ValidateGC (drawable, pGC);
- numRects = REGION_NUM_RECTS(prgn);
- pbox = REGION_RECTS(prgn);
+ numRects = RegionNumRects(prgn);
+ pbox = RegionRects(prgn);
for (i= numRects; --i >= 0; pbox++, prect++)
{
prect->x = pbox->x1 - draw_x_off;
diff --git a/xorg-server/mi/mifillrct.c b/xorg-server/mi/mifillrct.c index a97e5ced3..f2ca4c432 100644 --- a/xorg-server/mi/mifillrct.c +++ b/xorg-server/mi/mifillrct.c @@ -111,8 +111,8 @@ miPolyFillRect( pwFirst = malloc(maxheight * sizeof(int));
if(!pptFirst || !pwFirst)
{
- if (pwFirst) free(pwFirst);
- if (pptFirst) free(pptFirst);
+ free(pwFirst);
+ free(pptFirst);
return;
}
diff --git a/xorg-server/mi/mifpolycon.c b/xorg-server/mi/mifpolycon.c index 8411a1570..9d776201c 100644 --- a/xorg-server/mi/mifpolycon.c +++ b/xorg-server/mi/mifpolycon.c @@ -122,9 +122,9 @@ miFillSppPoly( if(!ptsOut || !width || !Marked)
{
- if (Marked) free(Marked);
- if (width) free(width);
- if (ptsOut) free(ptsOut);
+ free(Marked);
+ free(width);
+ free(ptsOut);
return;
}
@@ -276,5 +276,5 @@ GetFPolyYBounds( *by = ICEIL(ymin + yFtrans);
*ty = ICEIL(ymax + yFtrans - 1);
- return(ptMin-ptsStart);
+ return ptMin-ptsStart;
}
diff --git a/xorg-server/mi/migc.c b/xorg-server/mi/migc.c index e42f29810..50abefcea 100644 --- a/xorg-server/mi/migc.c +++ b/xorg-server/mi/migc.c @@ -50,7 +50,7 @@ miDestroyGC(GCPtr pGC) if (pGC->pRotatedPixmap)
(*pGC->pScreen->DestroyPixmap) (pGC->pRotatedPixmap);
if (pGC->freeCompClip)
- REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
+ RegionDestroy(pGC->pCompositeClip);
}
void
@@ -68,7 +68,7 @@ miDestroyClip(GCPtr pGC) * we know we'll never have a list of rectangles, since ChangeClip
* immediately turns them into a region
*/
- REGION_DESTROY(pGC->pScreen, pGC->clientClip);
+ RegionDestroy(pGC->clientClip);
}
pGC->clientClip = NULL;
pGC->clientClipType = CT_NONE;
@@ -81,7 +81,7 @@ miChangeClip( GCPtr pGC, int type, pointer pvalue, int nrects) if (type == CT_PIXMAP)
{
/* convert the pixmap to a region */
- pGC->clientClip = (pointer) BITMAP_TO_REGION(pGC->pScreen,
+ pGC->clientClip = (pointer) BitmapToRegion(pGC->pScreen,
(PixmapPtr) pvalue);
(*pGC->pScreen->DestroyPixmap) (pvalue);
}
@@ -92,7 +92,7 @@ miChangeClip( GCPtr pGC, int type, pointer pvalue, int nrects) }
else if (type != CT_NONE)
{
- pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nrects,
+ pGC->clientClip = (pointer) RegionFromRects(nrects,
(xRectangle *) pvalue,
type);
free(pvalue);
@@ -116,9 +116,8 @@ miCopyClip(GCPtr pgcDst, GCPtr pgcSrc) pgcSrc->clientClip, 0);
break;
case CT_REGION:
- prgnNew = REGION_CREATE(pgcSrc->pScreen, NULL, 1);
- REGION_COPY(pgcDst->pScreen, prgnNew,
- (RegionPtr) (pgcSrc->clientClip));
+ prgnNew = RegionCreate(NULL, 1);
+ RegionCopy(prgnNew, (RegionPtr) (pgcSrc->clientClip));
(*pgcDst->funcs->ChangeClip) (pgcDst, CT_REGION, (pointer) prgnNew, 0);
break;
}
@@ -134,11 +133,6 @@ miCopyGC(GCPtr pGCSrc, unsigned long changes, GCPtr pGCDst) void
miComputeCompositeClip( GCPtr pGC, DrawablePtr pDrawable)
{
- ScreenPtr pScreen;
-
- /* This prevents warnings about pScreen not being used. */
- pGC->pScreen = pScreen = pGC->pScreen;
-
if (pDrawable->type == DRAWABLE_WINDOW)
{
WindowPtr pWin = (WindowPtr) pDrawable;
@@ -167,7 +161,7 @@ miComputeCompositeClip( GCPtr pGC, DrawablePtr pDrawable) if (pGC->clientClipType == CT_NONE)
{
if (freeCompClip)
- REGION_DESTROY(pScreen, pGC->pCompositeClip);
+ RegionDestroy(pGC->pCompositeClip);
pGC->pCompositeClip = pregWin;
pGC->freeCompClip = freeTmpClip;
}
@@ -182,30 +176,30 @@ miComputeCompositeClip( GCPtr pGC, DrawablePtr pDrawable) * clip. if neither is real, create a new region.
*/
- REGION_TRANSLATE(pScreen, pGC->clientClip,
+ RegionTranslate(pGC->clientClip,
pDrawable->x + pGC->clipOrg.x,
pDrawable->y + pGC->clipOrg.y);
if (freeCompClip)
{
- REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ RegionIntersect(pGC->pCompositeClip,
pregWin, pGC->clientClip);
if (freeTmpClip)
- REGION_DESTROY(pScreen, pregWin);
+ RegionDestroy(pregWin);
}
else if (freeTmpClip)
{
- REGION_INTERSECT(pScreen, pregWin, pregWin, pGC->clientClip);
+ RegionIntersect(pregWin, pregWin, pGC->clientClip);
pGC->pCompositeClip = pregWin;
}
else
{
- pGC->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
- REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+ pGC->pCompositeClip = RegionCreate(NullBox, 0);
+ RegionIntersect(pGC->pCompositeClip,
pregWin, pGC->clientClip);
}
pGC->freeCompClip = TRUE;
- REGION_TRANSLATE(pScreen, pGC->clientClip,
+ RegionTranslate(pGC->clientClip,
-(pDrawable->x + pGC->clipOrg.x),
-(pDrawable->y + pGC->clipOrg.y));
}
@@ -223,31 +217,31 @@ miComputeCompositeClip( GCPtr pGC, DrawablePtr pDrawable) if (pGC->freeCompClip)
{
- REGION_RESET(pScreen, pGC->pCompositeClip, &pixbounds);
+ RegionReset(pGC->pCompositeClip, &pixbounds);
}
else
{
pGC->freeCompClip = TRUE;
- pGC->pCompositeClip = REGION_CREATE(pScreen, &pixbounds, 1);
+ pGC->pCompositeClip = RegionCreate(&pixbounds, 1);
}
if (pGC->clientClipType == CT_REGION)
{
if(pDrawable->x || pDrawable->y) {
- REGION_TRANSLATE(pScreen, pGC->clientClip,
+ RegionTranslate(pGC->clientClip,
pDrawable->x + pGC->clipOrg.x,
pDrawable->y + pGC->clipOrg.y);
- REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+ RegionIntersect(pGC->pCompositeClip,
pGC->pCompositeClip, pGC->clientClip);
- REGION_TRANSLATE(pScreen, pGC->clientClip,
+ RegionTranslate(pGC->clientClip,
-(pDrawable->x + pGC->clipOrg.x),
-(pDrawable->y + pGC->clipOrg.y));
} else {
- REGION_TRANSLATE(pScreen, pGC->pCompositeClip,
+ RegionTranslate(pGC->pCompositeClip,
-pGC->clipOrg.x, -pGC->clipOrg.y);
- REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+ RegionIntersect(pGC->pCompositeClip,
pGC->pCompositeClip, pGC->clientClip);
- REGION_TRANSLATE(pScreen, pGC->pCompositeClip,
+ RegionTranslate(pGC->pCompositeClip,
pGC->clipOrg.x, pGC->clipOrg.y);
}
}
diff --git a/xorg-server/mi/miline.h b/xorg-server/mi/miline.h index b5f706dbf..0f2fc3374 100644 --- a/xorg-server/mi/miline.h +++ b/xorg-server/mi/miline.h @@ -1,172 +1,173 @@ - -/* - -Copyright 1994, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifndef MILINE_H - -#include "screenint.h" -#include "privates.h" - -/* - * Public definitions used for configuring basic pixelization aspects - * of the sample implementation line-drawing routines provided in - * {mfb,mi,cfb*} at run-time. - */ - -#define XDECREASING 4 -#define YDECREASING 2 -#define YMAJOR 1 - -#define OCTANT1 (1 << (YDECREASING)) -#define OCTANT2 (1 << (YDECREASING|YMAJOR)) -#define OCTANT3 (1 << (XDECREASING|YDECREASING|YMAJOR)) -#define OCTANT4 (1 << (XDECREASING|YDECREASING)) -#define OCTANT5 (1 << (XDECREASING)) -#define OCTANT6 (1 << (XDECREASING|YMAJOR)) -#define OCTANT7 (1 << (YMAJOR)) -#define OCTANT8 (1 << (0)) - -#define XMAJOROCTANTS (OCTANT1 | OCTANT4 | OCTANT5 | OCTANT8) - -#define DEFAULTZEROLINEBIAS (OCTANT2 | OCTANT3 | OCTANT4 | OCTANT5) - -/* - * Devices can configure the rendering of routines in mi, mfb, and cfb* - * by specifying a thin line bias to be applied to a particular screen - * using the following function. The bias parameter is an OR'ing of - * the appropriate OCTANT constants defined above to indicate which - * octants to bias a line to prefer an axial step when the Bresenham - * error term is exactly zero. The octants are mapped as follows: - * - * \ | / - * \ 3 | 2 / - * \ | / - * 4 \ | / 1 - * \|/ - * ----------- - * /|\ - * 5 / | \ 8 - * / | \ - * / 6 | 7 \ - * / | \ - * - * For more information, see "Ambiguities in Incremental Line Rastering," - * Jack E. Bresenham, IEEE CG&A, May 1987. - */ - -extern _X_EXPORT void miSetZeroLineBias( - ScreenPtr /* pScreen */, - unsigned int /* bias */ -); - -/* - * Private definitions needed for drawing thin (zero width) lines - * Used by the mi, mfb, and all cfb* components. - */ - -#define X_AXIS 0 -#define Y_AXIS 1 - -#define OUT_LEFT 0x08 -#define OUT_RIGHT 0x04 -#define OUT_ABOVE 0x02 -#define OUT_BELOW 0x01 - -#define OUTCODES(_result, _x, _y, _pbox) \ - if ( (_x) < (_pbox)->x1) (_result) |= OUT_LEFT; \ - else if ( (_x) >= (_pbox)->x2) (_result) |= OUT_RIGHT; \ - if ( (_y) < (_pbox)->y1) (_result) |= OUT_ABOVE; \ - else if ( (_y) >= (_pbox)->y2) (_result) |= OUT_BELOW; - -#define MIOUTCODES(outcode, x, y, xmin, ymin, xmax, ymax) \ -{\ - if (x < xmin) outcode |= OUT_LEFT;\ - if (x > xmax) outcode |= OUT_RIGHT;\ - if (y < ymin) outcode |= OUT_ABOVE;\ - if (y > ymax) outcode |= OUT_BELOW;\ -} - -#define SWAPINT(i, j) \ -{ int _t = i; i = j; j = _t; } - -#define SWAPPT(i, j) \ -{ DDXPointRec _t; _t = i; i = j; j = _t; } - -#define SWAPINT_PAIR(x1, y1, x2, y2)\ -{ int t = x1; x1 = x2; x2 = t;\ - t = y1; y1 = y2; y2 = t;\ -} - -#define miGetZeroLineBias(_pScreen) ((unsigned long) (unsigned long*)\ - dixLookupPrivate(&(_pScreen)->devPrivates, miZeroLineScreenKey)) - -#define CalcLineDeltas(_x1,_y1,_x2,_y2,_adx,_ady,_sx,_sy,_SX,_SY,_octant) \ - (_octant) = 0; \ - (_sx) = (_SX); \ - if (((_adx) = (_x2) - (_x1)) < 0) { \ - (_adx) = -(_adx); \ - (_sx = -(_sx)); \ - (_octant) |= XDECREASING; \ - } \ - (_sy) = (_SY); \ - if (((_ady) = (_y2) - (_y1)) < 0) { \ - (_ady) = -(_ady); \ - (_sy = -(_sy)); \ - (_octant) |= YDECREASING; \ - } - -#define SetYMajorOctant(_octant) ((_octant) |= YMAJOR) - -#define FIXUP_ERROR(_e, _octant, _bias) \ - (_e) -= (((_bias) >> (_octant)) & 1) - -#define IsXMajorOctant(_octant) (!((_octant) & YMAJOR)) -#define IsYMajorOctant(_octant) ((_octant) & YMAJOR) -#define IsXDecreasingOctant(_octant) ((_octant) & XDECREASING) -#define IsYDecreasingOctant(_octant) ((_octant) & YDECREASING) - -extern _X_EXPORT DevPrivateKey miZeroLineScreenKey; - -extern _X_EXPORT int miZeroClipLine( - int /*xmin*/, - int /*ymin*/, - int /*xmax*/, - int /*ymax*/, - int * /*new_x1*/, - int * /*new_y1*/, - int * /*new_x2*/, - int * /*new_y2*/, - unsigned int /*adx*/, - unsigned int /*ady*/, - int * /*pt1_clipped*/, - int * /*pt2_clipped*/, - int /*octant*/, - unsigned int /*bias*/, - int /*oc1*/, - int /*oc2*/ -); - -#endif /* MILINE_H */ +
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifndef MILINE_H
+
+#include "screenint.h"
+#include "privates.h"
+
+/*
+ * Public definitions used for configuring basic pixelization aspects
+ * of the sample implementation line-drawing routines provided in
+ * {mfb,mi,cfb*} at run-time.
+ */
+
+#define XDECREASING 4
+#define YDECREASING 2
+#define YMAJOR 1
+
+#define OCTANT1 (1 << (YDECREASING))
+#define OCTANT2 (1 << (YDECREASING|YMAJOR))
+#define OCTANT3 (1 << (XDECREASING|YDECREASING|YMAJOR))
+#define OCTANT4 (1 << (XDECREASING|YDECREASING))
+#define OCTANT5 (1 << (XDECREASING))
+#define OCTANT6 (1 << (XDECREASING|YMAJOR))
+#define OCTANT7 (1 << (YMAJOR))
+#define OCTANT8 (1 << (0))
+
+#define XMAJOROCTANTS (OCTANT1 | OCTANT4 | OCTANT5 | OCTANT8)
+
+#define DEFAULTZEROLINEBIAS (OCTANT2 | OCTANT3 | OCTANT4 | OCTANT5)
+
+/*
+ * Devices can configure the rendering of routines in mi, mfb, and cfb*
+ * by specifying a thin line bias to be applied to a particular screen
+ * using the following function. The bias parameter is an OR'ing of
+ * the appropriate OCTANT constants defined above to indicate which
+ * octants to bias a line to prefer an axial step when the Bresenham
+ * error term is exactly zero. The octants are mapped as follows:
+ *
+ * \ | /
+ * \ 3 | 2 /
+ * \ | /
+ * 4 \ | / 1
+ * \|/
+ * -----------
+ * /|\
+ * 5 / | \ 8
+ * / | \
+ * / 6 | 7 \
+ * / | \
+ *
+ * For more information, see "Ambiguities in Incremental Line Rastering,"
+ * Jack E. Bresenham, IEEE CG&A, May 1987.
+ */
+
+extern _X_EXPORT void miSetZeroLineBias(
+ ScreenPtr /* pScreen */,
+ unsigned int /* bias */
+);
+
+/*
+ * Private definitions needed for drawing thin (zero width) lines
+ * Used by the mi, mfb, and all cfb* components.
+ */
+
+#define X_AXIS 0
+#define Y_AXIS 1
+
+#define OUT_LEFT 0x08
+#define OUT_RIGHT 0x04
+#define OUT_ABOVE 0x02
+#define OUT_BELOW 0x01
+
+#define OUTCODES(_result, _x, _y, _pbox) \
+ if ( (_x) < (_pbox)->x1) (_result) |= OUT_LEFT; \
+ else if ( (_x) >= (_pbox)->x2) (_result) |= OUT_RIGHT; \
+ if ( (_y) < (_pbox)->y1) (_result) |= OUT_ABOVE; \
+ else if ( (_y) >= (_pbox)->y2) (_result) |= OUT_BELOW;
+
+#define MIOUTCODES(outcode, x, y, xmin, ymin, xmax, ymax) \
+{\
+ if (x < xmin) outcode |= OUT_LEFT;\
+ if (x > xmax) outcode |= OUT_RIGHT;\
+ if (y < ymin) outcode |= OUT_ABOVE;\
+ if (y > ymax) outcode |= OUT_BELOW;\
+}
+
+#define SWAPINT(i, j) \
+{ int _t = i; i = j; j = _t; }
+
+#define SWAPPT(i, j) \
+{ DDXPointRec _t; _t = i; i = j; j = _t; }
+
+#define SWAPINT_PAIR(x1, y1, x2, y2)\
+{ int t = x1; x1 = x2; x2 = t;\
+ t = y1; y1 = y2; y2 = t;\
+}
+
+#define miGetZeroLineBias(_pScreen) ((unsigned long) (unsigned long*)\
+ dixLookupPrivate(&(_pScreen)->devPrivates, miZeroLineScreenKey))
+
+#define CalcLineDeltas(_x1,_y1,_x2,_y2,_adx,_ady,_sx,_sy,_SX,_SY,_octant) \
+ (_octant) = 0; \
+ (_sx) = (_SX); \
+ if (((_adx) = (_x2) - (_x1)) < 0) { \
+ (_adx) = -(_adx); \
+ (_sx = -(_sx)); \
+ (_octant) |= XDECREASING; \
+ } \
+ (_sy) = (_SY); \
+ if (((_ady) = (_y2) - (_y1)) < 0) { \
+ (_ady) = -(_ady); \
+ (_sy = -(_sy)); \
+ (_octant) |= YDECREASING; \
+ }
+
+#define SetYMajorOctant(_octant) ((_octant) |= YMAJOR)
+
+#define FIXUP_ERROR(_e, _octant, _bias) \
+ (_e) -= (((_bias) >> (_octant)) & 1)
+
+#define IsXMajorOctant(_octant) (!((_octant) & YMAJOR))
+#define IsYMajorOctant(_octant) ((_octant) & YMAJOR)
+#define IsXDecreasingOctant(_octant) ((_octant) & XDECREASING)
+#define IsYDecreasingOctant(_octant) ((_octant) & YDECREASING)
+
+extern _X_EXPORT DevPrivateKeyRec miZeroLineScreenKeyRec;
+#define miZeroLineScreenKey (&miZeroLineScreenKeyRec)
+
+extern _X_EXPORT int miZeroClipLine(
+ int /*xmin*/,
+ int /*ymin*/,
+ int /*xmax*/,
+ int /*ymax*/,
+ int * /*new_x1*/,
+ int * /*new_y1*/,
+ int * /*new_x2*/,
+ int * /*new_y2*/,
+ unsigned int /*adx*/,
+ unsigned int /*ady*/,
+ int * /*pt1_clipped*/,
+ int * /*pt2_clipped*/,
+ int /*octant*/,
+ unsigned int /*bias*/,
+ int /*oc1*/,
+ int /*oc2*/
+);
+
+#endif /* MILINE_H */
diff --git a/xorg-server/mi/mioverlay.c b/xorg-server/mi/mioverlay.c index 934de61fc..78f5d787b 100644 --- a/xorg-server/mi/mioverlay.c +++ b/xorg-server/mi/mioverlay.c @@ -9,6 +9,7 @@ #include <X11/X.h>
#include "scrnintstr.h"
+#include <X11/extensions/shapeproto.h>
#include "validate.h"
#include "windowstr.h"
#include "mi.h"
@@ -58,10 +59,10 @@ typedef struct { Bool copyUnderlay;
} miOverlayScreenRec, *miOverlayScreenPtr;
-static int miOverlayWindowKeyKeyIndex;
-static DevPrivateKey miOverlayWindowKey = &miOverlayWindowKeyKeyIndex;
-static int miOverlayScreenKeyIndex;
-static DevPrivateKey miOverlayScreenKey = &miOverlayScreenKeyIndex;
+static DevPrivateKeyRec miOverlayWindowKeyRec;
+#define miOverlayWindowKey (&miOverlayWindowKeyRec)
+static DevPrivateKeyRec miOverlayScreenKeyRec;
+#define miOverlayScreenKey (&miOverlayScreenKeyRec)
static void RebuildTree(WindowPtr);
static Bool HasUnderlayChildren(WindowPtr);
@@ -86,7 +87,7 @@ static void miOverlayResizeWindow(WindowPtr, int, int, unsigned int, unsigned int, WindowPtr);
static void miOverlayClearToBackground(WindowPtr, int, int, int, int, Bool);
-static void miOverlaySetShape(WindowPtr);
+static void miOverlaySetShape(WindowPtr, int);
static void miOverlayChangeBorderWidth(WindowPtr, unsigned int);
#define MIOVERLAY_GET_SCREEN_PRIVATE(pScreen) ((miOverlayScreenPtr) \
@@ -116,7 +117,10 @@ miInitOverlay( if(!inOverlayFunc || !transFunc) return FALSE;
- if(!dixRequestPrivate(miOverlayWindowKey, sizeof(miOverlayWindowRec)))
+ if(!dixRegisterPrivateKey(&miOverlayWindowKeyRec, PRIVATE_WINDOW, sizeof(miOverlayWindowRec)))
+ return FALSE;
+
+ if(!dixRegisterPrivateKey(&miOverlayScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if(!(pScreenPriv = malloc(sizeof(miOverlayScreenRec))))
@@ -204,8 +208,8 @@ miOverlayCreateWindow(WindowPtr pWin) pTree->visibility = VisibilityNotViewable;
pWinPriv->tree = pTree;
if(pWin->parent) {
- REGION_NULL(pScreen, &(pTree->borderClip));
- REGION_NULL(pScreen, &(pTree->clipList));
+ RegionNull(&(pTree->borderClip));
+ RegionNull(&(pTree->clipList));
RebuildTree(pWin);
} else {
BoxRec fullBox;
@@ -213,8 +217,8 @@ miOverlayCreateWindow(WindowPtr pWin) fullBox.y1 = 0;
fullBox.x2 = pScreen->width;
fullBox.y2 = pScreen->height;
- REGION_INIT(pScreen, &(pTree->borderClip), &fullBox, 1);
- REGION_INIT(pScreen, &(pTree->clipList), &fullBox, 1);
+ RegionInit(&(pTree->borderClip), &fullBox, 1);
+ RegionInit(&(pTree->clipList), &fullBox, 1);
}
} else free(pTree);
}
@@ -242,8 +246,8 @@ miOverlayDestroyWindow(WindowPtr pWin) else if(pTree->parent)
pTree->parent->lastChild = pTree->prevSib;
- REGION_UNINIT(pScreen, &(pTree->borderClip));
- REGION_UNINIT(pScreen, &(pTree->clipList));
+ RegionUninit(&(pTree->borderClip));
+ RegionUninit(&(pTree->clipList));
free(pTree);
}
@@ -309,7 +313,7 @@ miOverlayReparentWindow(WindowPtr pWin, WindowPtr pPriorParent) {
if(IN_UNDERLAY(pWin) || HasUnderlayChildren(pWin)) {
/* This could probably be more optimal */
- RebuildTree(WindowTable[pWin->drawable.pScreen->myNum]->firstChild);
+ RebuildTree(pWin->drawable.pScreen->root->firstChild);
}
}
@@ -329,7 +333,6 @@ miOverlayMarkOverlappedWindows( WindowPtr pFirst,
WindowPtr *pLayerWin
){
- ScreenPtr pScreen = pWin->drawable.pScreen;
WindowPtr pChild, pLast;
Bool overMarked, underMarked, doUnderlay, markAll;
miOverlayTreePtr pTree = NULL, tLast, tChild;
@@ -341,7 +344,7 @@ miOverlayMarkOverlappedWindows( doUnderlay = (IN_UNDERLAY(pWin) || HasUnderlayChildren(pWin));
- box = REGION_EXTENTS(pScreen, &pWin->borderSize);
+ box = RegionExtents(&pWin->borderSize);
if((pChild = pFirst)) {
pLast = pChild->parent->lastChild;
@@ -352,13 +355,13 @@ miOverlayMarkOverlappedWindows( pTree = MIOVERLAY_GET_WINDOW_TREE(pChild);
if(pChild->viewable) {
- if (REGION_BROKEN (pScreen, &pChild->winSize))
+ if (RegionBroken(&pChild->winSize))
SetWinSize (pChild);
- if (REGION_BROKEN (pScreen, &pChild->borderSize))
+ if (RegionBroken(&pChild->borderSize))
SetBorderSize (pChild);
if (markAll ||
- RECT_IN_REGION(pScreen, &pChild->borderSize, box))
+ RegionContainsRect(&pChild->borderSize, box))
{
MARK_OVERLAY(pChild);
overMarked = TRUE;
@@ -413,12 +416,12 @@ miOverlayMarkOverlappedWindows( while(1) {
if(tChild->pWin->viewable) {
- if (REGION_BROKEN (pScreen, &tChild->pWin->winSize))
+ if (RegionBroken(&tChild->pWin->winSize))
SetWinSize (tChild->pWin);
- if (REGION_BROKEN (pScreen, &tChild->pWin->borderSize))
+ if (RegionBroken(&tChild->pWin->borderSize))
SetBorderSize (tChild->pWin);
- if(RECT_IN_REGION(pScreen, &(tChild->pWin->borderSize), box))
+ if(RegionContainsRect(&(tChild->pWin->borderSize), box))
{
MARK_UNDERLAY(tChild->pWin);
underMarked = TRUE;
@@ -440,11 +443,12 @@ miOverlayMarkOverlappedWindows( }
if(underMarked) {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
MARK_UNDERLAY(pTree->parent->pWin);
MIOVERLAY_GET_SCREEN_PRIVATE(pScreen)->underlayMarked = TRUE;
}
- return (underMarked || overMarked);
+ return underMarked || overMarked;
}
@@ -476,7 +480,7 @@ miOverlayComputeClips( borderSize.y2 = dy;
oldVis = tParent->visibility;
- switch (RECT_IN_REGION( pScreen, universe, &borderSize)) {
+ switch (RegionContainsRect(universe, &borderSize)) {
case rgnIN:
newVis = VisibilityUnobscured;
break;
@@ -486,7 +490,7 @@ miOverlayComputeClips( RegionPtr pBounding;
if ((pBounding = wBoundingShape (pParent))) {
- switch (miShapedWindowIn (pScreen, universe, pBounding,
+ switch (miShapedWindowIn (universe, pBounding,
&borderSize,
pParent->drawable.x,
pParent->drawable.y))
@@ -524,8 +528,8 @@ miOverlayComputeClips( while (1) {
if (tChild->pWin->viewable) {
if (tChild->visibility != VisibilityFullyObscured) {
- REGION_TRANSLATE( pScreen, &tChild->borderClip, dx, dy);
- REGION_TRANSLATE( pScreen, &tChild->clipList, dx, dy);
+ RegionTranslate(&tChild->borderClip, dx, dy);
+ RegionTranslate(&tChild->clipList, dx, dy);
tChild->pWin->drawable.serialNumber =
NEXT_SERIAL_NUMBER;
@@ -533,14 +537,13 @@ miOverlayComputeClips( (* pScreen->ClipNotify) (tChild->pWin, dx, dy);
}
if (tChild->valdata) {
- REGION_NULL(pScreen, &tChild->valdata->borderExposed);
+ RegionNull(&tChild->valdata->borderExposed);
if (HasParentRelativeBorder(tChild->pWin)){
- REGION_SUBTRACT(pScreen,
- &tChild->valdata->borderExposed,
- &tChild->borderClip,
- &tChild->pWin->winSize);
+ RegionSubtract(&tChild->valdata->borderExposed,
+ &tChild->borderClip,
+ &tChild->pWin->winSize);
}
- REGION_NULL(pScreen, &tChild->valdata->exposed);
+ RegionNull(&tChild->valdata->exposed);
}
if (tChild->firstChild) {
tChild = tChild->firstChild;
@@ -558,50 +561,50 @@ miOverlayComputeClips( /* fall through */
default:
if (dx || dy) {
- REGION_TRANSLATE( pScreen, &tParent->borderClip, dx, dy);
- REGION_TRANSLATE( pScreen, &tParent->clipList, dx, dy);
+ RegionTranslate(&tParent->borderClip, dx, dy);
+ RegionTranslate(&tParent->clipList, dx, dy);
}
break;
case VTBroken:
- REGION_EMPTY (pScreen, &tParent->borderClip);
- REGION_EMPTY (pScreen, &tParent->clipList);
+ RegionEmpty(&tParent->borderClip);
+ RegionEmpty(&tParent->clipList);
break;
}
borderVisible = tParent->valdata->borderVisible;
- REGION_NULL(pScreen, &tParent->valdata->borderExposed);
- REGION_NULL(pScreen, &tParent->valdata->exposed);
+ RegionNull(&tParent->valdata->borderExposed);
+ RegionNull(&tParent->valdata->exposed);
if (HasBorder (pParent)) {
if (borderVisible) {
- REGION_SUBTRACT( pScreen, exposed, universe, borderVisible);
- REGION_DESTROY( pScreen, borderVisible);
+ RegionSubtract(exposed, universe, borderVisible);
+ RegionDestroy(borderVisible);
} else
- REGION_SUBTRACT( pScreen, exposed, universe, &tParent->borderClip);
+ RegionSubtract(exposed, universe, &tParent->borderClip);
if (HasParentRelativeBorder(pParent) && (dx || dy))
- REGION_SUBTRACT( pScreen, &tParent->valdata->borderExposed,
+ RegionSubtract(&tParent->valdata->borderExposed,
universe, &pParent->winSize);
else
- REGION_SUBTRACT( pScreen, &tParent->valdata->borderExposed,
+ RegionSubtract(&tParent->valdata->borderExposed,
exposed, &pParent->winSize);
- REGION_COPY( pScreen, &tParent->borderClip, universe);
- REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize);
+ RegionCopy(&tParent->borderClip, universe);
+ RegionIntersect(universe, universe, &pParent->winSize);
}
else
- REGION_COPY( pScreen, &tParent->borderClip, universe);
+ RegionCopy(&tParent->borderClip, universe);
if ((tChild = tParent->firstChild) && pParent->mapped) {
- REGION_NULL(pScreen, &childUniverse);
- REGION_NULL(pScreen, &childUnion);
+ RegionNull(&childUniverse);
+ RegionNull(&childUnion);
for (; tChild; tChild = tChild->nextSib) {
if (tChild->pWin->viewable)
- REGION_APPEND( pScreen, &childUnion, &tChild->pWin->borderSize);
+ RegionAppend(&childUnion, &tChild->pWin->borderSize);
}
- REGION_VALIDATE( pScreen, &childUnion, &overlap);
+ RegionValidate(&childUnion, &overlap);
for (tChild = tParent->firstChild;
tChild;
@@ -609,31 +612,31 @@ miOverlayComputeClips( {
if (tChild->pWin->viewable) {
if (tChild->valdata) {
- REGION_INTERSECT( pScreen, &childUniverse, universe,
+ RegionIntersect(&childUniverse, universe,
&tChild->pWin->borderSize);
miOverlayComputeClips (tChild->pWin, &childUniverse,
kind, exposed);
}
if (overlap)
- REGION_SUBTRACT( pScreen, universe, universe,
+ RegionSubtract(universe, universe,
&tChild->pWin->borderSize);
}
}
if (!overlap)
- REGION_SUBTRACT( pScreen, universe, universe, &childUnion);
- REGION_UNINIT( pScreen, &childUnion);
- REGION_UNINIT( pScreen, &childUniverse);
+ RegionSubtract(universe, universe, &childUnion);
+ RegionUninit(&childUnion);
+ RegionUninit(&childUniverse);
}
if (oldVis == VisibilityFullyObscured ||
oldVis == VisibilityNotViewable)
{
- REGION_COPY( pScreen, &tParent->valdata->exposed, universe);
+ RegionCopy(&tParent->valdata->exposed, universe);
}
else if (newVis != VisibilityFullyObscured &&
newVis != VisibilityNotViewable)
{
- REGION_SUBTRACT( pScreen, &tParent->valdata->exposed,
+ RegionSubtract(&tParent->valdata->exposed,
universe, &tParent->clipList);
}
@@ -711,14 +714,14 @@ miOverlayMarkUnrealizedWindow( if ((pChild != pWin) || fromConfigure) {
miOverlayTreePtr pTree;
- REGION_EMPTY(pChild->drawable.pScreen, &pChild->clipList);
+ RegionEmpty(&pChild->clipList);
if (pChild->drawable.pScreen->ClipNotify)
(* pChild->drawable.pScreen->ClipNotify)(pChild, 0, 0);
- REGION_EMPTY(pChild->drawable.pScreen, &pChild->borderClip);
+ RegionEmpty(&pChild->borderClip);
if((pTree = MIOVERLAY_GET_WINDOW_TREE(pChild))) {
if(pTree->valdata != (miOverlayValDataPtr)UnmapValData) {
- REGION_EMPTY(pChild->drawable.pScreen, &pTree->clipList);
- REGION_EMPTY(pChild->drawable.pScreen, &pTree->borderClip);
+ RegionEmpty(&pTree->clipList);
+ RegionEmpty(&pTree->borderClip);
}
}
}
@@ -743,9 +746,9 @@ miOverlayValidateTree( if (!pChild) pChild = pParent->firstChild;
- REGION_NULL(pScreen, &totalClip);
- REGION_NULL(pScreen, &childClip);
- REGION_NULL(pScreen, &exposed);
+ RegionNull(&totalClip);
+ RegionNull(&childClip);
+ RegionNull(&exposed);
newParent = pParent;
@@ -759,52 +762,52 @@ miOverlayValidateTree( else
tChild = tParent->firstChild;
- if (REGION_BROKEN (pScreen, &tParent->clipList) &&
- !REGION_BROKEN (pScreen, &tParent->borderClip))
+ if (RegionBroken(&tParent->clipList) &&
+ !RegionBroken(&tParent->borderClip))
{
kind = VTBroken;
- REGION_COPY (pScreen, &totalClip, &tParent->borderClip);
- REGION_INTERSECT (pScreen, &totalClip, &totalClip,
+ RegionCopy(&totalClip, &tParent->borderClip);
+ RegionIntersect(&totalClip, &totalClip,
&tParent->pWin->winSize);
for (tWin = tParent->firstChild; tWin != tChild; tWin = tWin->nextSib) {
if (tWin->pWin->viewable)
- REGION_SUBTRACT (pScreen, &totalClip, &totalClip,
+ RegionSubtract(&totalClip, &totalClip,
&tWin->pWin->borderSize);
}
- REGION_EMPTY (pScreen, &tParent->clipList);
+ RegionEmpty(&tParent->clipList);
} else {
for(tWin = tChild; tWin; tWin = tWin->nextSib) {
if(tWin->valdata)
- REGION_APPEND(pScreen, &totalClip, &tWin->borderClip);
+ RegionAppend(&totalClip, &tWin->borderClip);
}
- REGION_VALIDATE(pScreen, &totalClip, &overlap);
+ RegionValidate(&totalClip, &overlap);
}
if(kind != VTStack)
- REGION_UNION(pScreen, &totalClip, &totalClip, &tParent->clipList);
+ RegionUnion(&totalClip, &totalClip, &tParent->clipList);
for(tWin = tChild; tWin; tWin = tWin->nextSib) {
if(tWin->valdata) {
if(tWin->pWin->viewable) {
- REGION_INTERSECT(pScreen, &childClip, &totalClip,
+ RegionIntersect(&childClip, &totalClip,
&tWin->pWin->borderSize);
miOverlayComputeClips(tWin->pWin, &childClip, kind, &exposed);
- REGION_SUBTRACT(pScreen, &totalClip, &totalClip,
+ RegionSubtract(&totalClip, &totalClip,
&tWin->pWin->borderSize);
} else { /* Means we are unmapping */
- REGION_EMPTY(pScreen, &tWin->clipList);
- REGION_EMPTY( pScreen, &tWin->borderClip);
+ RegionEmpty(&tWin->clipList);
+ RegionEmpty(&tWin->borderClip);
tWin->valdata = NULL;
}
}
}
- REGION_UNINIT(pScreen, &childClip);
+ RegionUninit(&childClip);
if(!((*pPriv->InOverlay)(newParent))) {
- REGION_NULL(pScreen, &tParent->valdata->exposed);
- REGION_NULL(pScreen, &tParent->valdata->borderExposed);
+ RegionNull(&tParent->valdata->exposed);
+ RegionNull(&tParent->valdata->borderExposed);
}
switch (kind) {
@@ -812,18 +815,18 @@ miOverlayValidateTree( break;
default:
if(!((*pPriv->InOverlay)(newParent)))
- REGION_SUBTRACT(pScreen, &tParent->valdata->exposed, &totalClip,
+ RegionSubtract(&tParent->valdata->exposed, &totalClip,
&tParent->clipList);
/* fall through */
case VTMap:
- REGION_COPY( pScreen, &tParent->clipList, &totalClip);
+ RegionCopy(&tParent->clipList, &totalClip);
if(!((*pPriv->InOverlay)(newParent)))
newParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
break;
}
- REGION_UNINIT( pScreen, &totalClip);
- REGION_UNINIT( pScreen, &exposed);
+ RegionUninit(&totalClip);
+ RegionUninit(&exposed);
SKIP_UNDERLAY:
@@ -856,14 +859,14 @@ miOverlayHandleExposures(WindowPtr pWin) while (1) {
if((mival = pTree->valdata)) {
if(!((*pPriv->InOverlay)(pTree->pWin))) {
- if (REGION_NOTEMPTY(pScreen, &mival->borderExposed)) {
+ if (RegionNotEmpty(&mival->borderExposed)) {
miPaintWindow(pTree->pWin, &mival->borderExposed,
PW_BORDER);
}
- REGION_UNINIT(pScreen, &mival->borderExposed);
+ RegionUninit(&mival->borderExposed);
(*WindowExposures)(pTree->pWin,&mival->exposed,NullRegion);
- REGION_UNINIT(pScreen, &mival->exposed);
+ RegionUninit(&mival->exposed);
}
free(mival);
pTree->valdata = NULL;
@@ -885,24 +888,24 @@ miOverlayHandleExposures(WindowPtr pWin) while (1) {
if ( (val = pChild->valdata) ) {
if(!((*pPriv->InOverlay)(pChild))) {
- REGION_UNION(pScreen, &val->after.exposed, &val->after.exposed,
+ RegionUnion(&val->after.exposed, &val->after.exposed,
&val->after.borderExposed);
- if (REGION_NOTEMPTY(pScreen, &val->after.exposed)) {
+ if (RegionNotEmpty(&val->after.exposed)) {
(*(MIOVERLAY_GET_SCREEN_PRIVATE(pScreen)->MakeTransparent))(
pScreen,
- REGION_NUM_RECTS(&val->after.exposed),
- REGION_RECTS(&val->after.exposed));
+ RegionNumRects(&val->after.exposed),
+ RegionRects(&val->after.exposed));
}
} else {
- if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed)) {
+ if (RegionNotEmpty(&val->after.borderExposed)) {
miPaintWindow(pChild, &val->after.borderExposed,
PW_BORDER);
}
(*WindowExposures)(pChild, &val->after.exposed, NullRegion);
}
- REGION_UNINIT(pScreen, &val->after.borderExposed);
- REGION_UNINIT(pScreen, &val->after.exposed);
+ RegionUninit(&val->after.borderExposed);
+ RegionUninit(&val->after.exposed);
free(val);
pChild->valdata = NULL;
if (pChild->firstChild)
@@ -943,13 +946,13 @@ miOverlayMoveWindow( oldpt.x = pWin->drawable.x;
oldpt.y = pWin->drawable.y;
if (WasViewable) {
- REGION_NULL(pScreen, &overReg);
- REGION_NULL(pScreen, &underReg);
+ RegionNull(&overReg);
+ RegionNull(&underReg);
if(pTree) {
- REGION_COPY(pScreen, &overReg, &pWin->borderClip);
- REGION_COPY(pScreen, &underReg, &pTree->borderClip);
+ RegionCopy(&overReg, &pWin->borderClip);
+ RegionCopy(&underReg, &pTree->borderClip);
} else {
- REGION_COPY(pScreen, &overReg, &pWin->borderClip);
+ RegionCopy(&overReg, &pWin->borderClip);
CollectUnderlayChildrenRegions(pWin, &underReg);
}
(*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
@@ -974,16 +977,16 @@ miOverlayMoveWindow( (*pScreen->ValidateTree)(pWin->parent, NullWindow, kind);
- if(REGION_NOTEMPTY(pScreen, &underReg)) {
+ if(RegionNotEmpty(&underReg)) {
pPriv->copyUnderlay = TRUE;
(* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, &underReg);
}
- REGION_UNINIT(pScreen, &underReg);
- if(REGION_NOTEMPTY(pScreen, &overReg)) {
+ RegionUninit(&underReg);
+ if(RegionNotEmpty(&overReg)) {
pPriv->copyUnderlay = FALSE;
(* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, &overReg);
}
- REGION_UNINIT(pScreen, &overReg);
+ RegionUninit(&overReg);
(*pScreen->HandleExposures)(pWin->parent);
if (pScreen->PostValidateTree)
@@ -1004,10 +1007,9 @@ miOverlayWindowExposures( RegionPtr other_exposed
){
RegionPtr exposures = prgn;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- if ((prgn && !REGION_NIL(prgn)) ||
- (exposures && !REGION_NIL(exposures)) || other_exposed)
+ if ((prgn && !RegionNil(prgn)) ||
+ (exposures && !RegionNil(exposures)) || other_exposed)
{
RegionRec expRec;
int clientInterested;
@@ -1016,51 +1018,52 @@ miOverlayWindowExposures( ExposureMask;
if (other_exposed) {
if (exposures) {
- REGION_UNION(pScreen, other_exposed, exposures, other_exposed);
+ RegionUnion(other_exposed, exposures, other_exposed);
if (exposures != prgn)
- REGION_DESTROY(pScreen, exposures);
+ RegionDestroy(exposures);
}
exposures = other_exposed;
}
if (clientInterested && exposures &&
- (REGION_NUM_RECTS(exposures) > RECTLIMIT))
+ (RegionNumRects(exposures) > RECTLIMIT))
{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
BoxRec box;
- box = *REGION_EXTENTS(pScreen, exposures);
+ box = *RegionExtents(exposures);
if (exposures == prgn) {
exposures = &expRec;
- REGION_INIT(pScreen, exposures, &box, 1);
- REGION_RESET(pScreen, prgn, &box);
+ RegionInit(exposures, &box, 1);
+ RegionReset(prgn, &box);
} else {
- REGION_RESET(pScreen, exposures, &box);
- REGION_UNION(pScreen, prgn, prgn, exposures);
+ RegionReset(exposures, &box);
+ RegionUnion(prgn, prgn, exposures);
}
/* This is the only reason why we are replacing mi's version
of this file */
if(!((*pPriv->InOverlay)(pWin))) {
miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
- REGION_INTERSECT(pScreen, prgn, prgn, &pTree->clipList);
+ RegionIntersect(prgn, prgn, &pTree->clipList);
} else
- REGION_INTERSECT(pScreen, prgn, prgn, &pWin->clipList);
+ RegionIntersect(prgn, prgn, &pWin->clipList);
}
- if (prgn && !REGION_NIL(prgn))
+ if (prgn && !RegionNil(prgn))
miPaintWindow(pWin, prgn, PW_BACKGROUND);
- if (clientInterested && exposures && !REGION_NIL(exposures))
+ if (clientInterested && exposures && !RegionNil(exposures))
miSendExposures(pWin, exposures,
pWin->drawable.x, pWin->drawable.y);
if (exposures == &expRec) {
- REGION_UNINIT(pScreen, exposures);
+ RegionUninit(exposures);
}
else if (exposures && exposures != prgn && exposures != other_exposed)
- REGION_DESTROY(pScreen, exposures);
+ RegionDestroy(exposures);
if (prgn)
- REGION_EMPTY(pScreen, prgn);
+ RegionEmpty(prgn);
}
else if (exposures && exposures != prgn)
- REGION_DESTROY(pScreen, exposures);
+ RegionDestroy(exposures);
}
@@ -1074,34 +1077,30 @@ miOverlayRecomputeExposures ( WindowPtr pWin,
pointer value
){
- ScreenPtr pScreen;
miOverlayTwoRegions *pValid = (miOverlayTwoRegions*)value;
miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
- /* This prevents warning about pScreen not being used. */
- pWin->drawable.pScreen = pScreen = pWin->drawable.pScreen;
-
if (pWin->valdata) {
/*
* compute exposed regions of this window
*/
- REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+ RegionSubtract(&pWin->valdata->after.exposed,
&pWin->clipList, pValid->over);
/*
* compute exposed regions of the border
*/
- REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+ RegionSubtract(&pWin->valdata->after.borderExposed,
&pWin->borderClip, &pWin->winSize);
- REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+ RegionSubtract(&pWin->valdata->after.borderExposed,
&pWin->valdata->after.borderExposed, pValid->over);
}
if(pTree && pTree->valdata) {
- REGION_SUBTRACT(pScreen, &pTree->valdata->exposed,
+ RegionSubtract(&pTree->valdata->exposed,
&pTree->clipList, pValid->under);
- REGION_SUBTRACT(pScreen, &pTree->valdata->borderExposed,
+ RegionSubtract(&pTree->valdata->borderExposed,
&pTree->borderClip, &pWin->winSize);
- REGION_SUBTRACT(pScreen, &pTree->valdata->borderExposed,
+ RegionSubtract(&pTree->valdata->borderExposed,
&pTree->valdata->borderExposed, pValid->under);
} else if (!pWin->valdata)
return WT_NOMATCH;
@@ -1157,11 +1156,11 @@ miOverlayResizeWindow( /*
* save the visible region of the window
*/
- oldRegion = REGION_CREATE(pScreen, NullBox, 1);
- REGION_COPY(pScreen, oldRegion, &pWin->winSize);
+ oldRegion = RegionCreate(NullBox, 1);
+ RegionCopy(oldRegion, &pWin->winSize);
if(doUnderlay) {
- oldRegion2 = REGION_CREATE(pScreen, NullBox, 1);
- REGION_COPY(pScreen, oldRegion2, &pWin->winSize);
+ oldRegion2 = RegionCreate(NullBox, 1);
+ RegionCopy(oldRegion2, &pWin->winSize);
}
/*
@@ -1173,16 +1172,16 @@ miOverlayResizeWindow( g = pChild->winGravity;
if (g != UnmapGravity) {
if (!gravitate[g])
- gravitate[g] = REGION_CREATE(pScreen, NullBox, 1);
- REGION_UNION(pScreen, gravitate[g],
+ gravitate[g] = RegionCreate(NullBox, 1);
+ RegionUnion(gravitate[g],
gravitate[g], &pChild->borderClip);
if(doUnderlay) {
if (!gravitate2[g])
- gravitate2[g] = REGION_CREATE(pScreen, NullBox, 0);
+ gravitate2[g] = RegionCreate(NullBox, 0);
if((tChild = MIOVERLAY_GET_WINDOW_TREE(pChild))) {
- REGION_UNION(pScreen, gravitate2[g],
+ RegionUnion(gravitate2[g],
gravitate2[g], &tChild->borderClip);
} else
CollectUnderlayChildrenRegions(pChild, gravitate2[g]);
@@ -1196,11 +1195,11 @@ miOverlayResizeWindow( oldWinClip = oldWinClip2 = NULL;
if (pWin->bitGravity != ForgetGravity) {
- oldWinClip = REGION_CREATE(pScreen, NullBox, 1);
- REGION_COPY(pScreen, oldWinClip, &pWin->clipList);
+ oldWinClip = RegionCreate(NullBox, 1);
+ RegionCopy(oldWinClip, &pWin->clipList);
if(pTree) {
- oldWinClip2 = REGION_CREATE(pScreen, NullBox, 1);
- REGION_COPY(pScreen, oldWinClip2, &pTree->clipList);
+ oldWinClip2 = RegionCreate(NullBox, 1);
+ RegionCopy(oldWinClip2, &pTree->clipList);
}
}
/*
@@ -1216,26 +1215,26 @@ miOverlayResizeWindow( if ((pWin->drawable.height != h || pWin->drawable.width != w) &&
HasBorder (pWin))
{
- borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+ borderVisible = RegionCreate(NullBox, 1);
if(pTree)
- borderVisible2 = REGION_CREATE(pScreen, NullBox, 1);
+ borderVisible2 = RegionCreate(NullBox, 1);
/* for tiled borders, we punt and draw the whole thing */
if (pWin->borderIsPixel || !moved)
{
if (shrunk || moved)
- REGION_SUBTRACT(pScreen, borderVisible,
+ RegionSubtract(borderVisible,
&pWin->borderClip,
&pWin->winSize);
else
- REGION_COPY(pScreen, borderVisible,
+ RegionCopy(borderVisible,
&pWin->borderClip);
if(pTree) {
if (shrunk || moved)
- REGION_SUBTRACT(pScreen, borderVisible,
+ RegionSubtract(borderVisible,
&pTree->borderClip,
&pWin->winSize);
else
- REGION_COPY(pScreen, borderVisible,
+ RegionCopy(borderVisible,
&pTree->borderClip);
}
}
@@ -1262,7 +1261,7 @@ miOverlayResizeWindow( pFirstChange = MoveWindowInStack(pWin, pSib);
if (WasViewable) {
- pRegion = REGION_CREATE(pScreen, NullBox, 1);
+ pRegion = RegionCreate(NullBox, 1);
(*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, NULL);
@@ -1277,9 +1276,9 @@ miOverlayResizeWindow( * the entire window is trashed unless bitGravity
* recovers portions of it
*/
- REGION_COPY(pScreen, &pWin->valdata->after.exposed, &pWin->clipList);
+ RegionCopy(&pWin->valdata->after.exposed, &pWin->clipList);
if(pTree)
- REGION_COPY(pScreen, &pTree->valdata->exposed, &pTree->clipList);
+ RegionCopy(&pTree->valdata->exposed, &pTree->clipList);
}
GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
@@ -1307,20 +1306,20 @@ miOverlayResizeWindow( dx = (oldx - nx) - offx;
dy = (oldy - ny) - offy;
if (dx || dy) {
- REGION_TRANSLATE(pScreen, &pWin->winSize, dx, dy);
+ RegionTranslate(&pWin->winSize, dx, dy);
offx += dx;
offy += dy;
}
if(gravitate[g])
- REGION_INTERSECT(pScreen, gravitate[g], gravitate[g],
+ RegionIntersect(gravitate[g], gravitate[g],
&pWin->winSize);
if(gravitate2[g])
- REGION_INTERSECT(pScreen, gravitate2[g], gravitate2[g],
+ RegionIntersect(gravitate2[g], gravitate2[g],
&pWin->winSize);
}
/* get winSize back where it belongs */
if (offx || offy)
- REGION_TRANSLATE(pScreen, &pWin->winSize, -offx, -offy);
+ RegionTranslate(&pWin->winSize, -offx, -offy);
}
/*
* add screen bits to the appropriate bucket
@@ -1328,22 +1327,22 @@ miOverlayResizeWindow( if (oldWinClip2)
{
- REGION_COPY(pScreen, pRegion, oldWinClip2);
- REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy);
- REGION_INTERSECT(pScreen, oldWinClip2, pRegion, &pTree->clipList);
+ RegionCopy(pRegion, oldWinClip2);
+ RegionTranslate(pRegion, nx - oldx, ny - oldy);
+ RegionIntersect(oldWinClip2, pRegion, &pTree->clipList);
for (g = pWin->bitGravity + 1; g <= StaticGravity; g++) {
if (gravitate2[g])
- REGION_SUBTRACT(pScreen, oldWinClip2, oldWinClip2,
+ RegionSubtract(oldWinClip2, oldWinClip2,
gravitate2[g]);
}
- REGION_TRANSLATE(pScreen, oldWinClip2, oldx - nx, oldy - ny);
+ RegionTranslate(oldWinClip2, oldx - nx, oldy - ny);
g = pWin->bitGravity;
if (!gravitate2[g])
gravitate2[g] = oldWinClip2;
else {
- REGION_UNION(pScreen,gravitate2[g],gravitate2[g],oldWinClip2);
- REGION_DESTROY(pScreen, oldWinClip2);
+ RegionUnion(gravitate2[g],gravitate2[g],oldWinClip2);
+ RegionDestroy(oldWinClip2);
}
}
@@ -1352,9 +1351,9 @@ miOverlayResizeWindow( /*
* clip to new clipList
*/
- REGION_COPY(pScreen, pRegion, oldWinClip);
- REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy);
- REGION_INTERSECT(pScreen, oldWinClip, pRegion, &pWin->clipList);
+ RegionCopy(pRegion, oldWinClip);
+ RegionTranslate(pRegion, nx - oldx, ny - oldy);
+ RegionIntersect(oldWinClip, pRegion, &pWin->clipList);
/*
* don't step on any gravity bits which will be copied after this
* region. Note -- this assumes that the regions will be copied
@@ -1362,16 +1361,16 @@ miOverlayResizeWindow( */
for (g = pWin->bitGravity + 1; g <= StaticGravity; g++) {
if (gravitate[g])
- REGION_SUBTRACT(pScreen, oldWinClip, oldWinClip,
+ RegionSubtract(oldWinClip, oldWinClip,
gravitate[g]);
}
- REGION_TRANSLATE(pScreen, oldWinClip, oldx - nx, oldy - ny);
+ RegionTranslate(oldWinClip, oldx - nx, oldy - ny);
g = pWin->bitGravity;
if (!gravitate[g])
gravitate[g] = oldWinClip;
else {
- REGION_UNION(pScreen, gravitate[g], gravitate[g], oldWinClip);
- REGION_DESTROY(pScreen, oldWinClip);
+ RegionUnion(gravitate[g], gravitate[g], oldWinClip);
+ RegionDestroy(oldWinClip);
}
}
@@ -1395,23 +1394,23 @@ miOverlayResizeWindow( /* only copy the remaining useful bits */
if(gravitate[g])
- REGION_INTERSECT(pScreen, gravitate[g],
+ RegionIntersect(gravitate[g],
gravitate[g], oldRegion);
if(gravitate2[g])
- REGION_INTERSECT(pScreen, gravitate2[g],
+ RegionIntersect(gravitate2[g],
gravitate2[g], oldRegion2);
/* clip to not overwrite already copied areas */
if (destClip && gravitate[g]) {
- REGION_TRANSLATE(pScreen, destClip, oldpt.x - x, oldpt.y - y);
- REGION_SUBTRACT(pScreen, gravitate[g], gravitate[g], destClip);
- REGION_TRANSLATE(pScreen, destClip, x - oldpt.x, y - oldpt.y);
+ RegionTranslate(destClip, oldpt.x - x, oldpt.y - y);
+ RegionSubtract(gravitate[g], gravitate[g], destClip);
+ RegionTranslate(destClip, x - oldpt.x, y - oldpt.y);
}
if (destClip2 && gravitate2[g]) {
- REGION_TRANSLATE(pScreen, destClip2, oldpt.x - x, oldpt.y - y);
- REGION_SUBTRACT(pScreen,gravitate2[g],gravitate2[g],destClip2);
- REGION_TRANSLATE(pScreen, destClip2, x - oldpt.x, y - oldpt.y);
+ RegionTranslate(destClip2, oldpt.x - x, oldpt.y - y);
+ RegionSubtract(gravitate2[g],gravitate2[g],destClip2);
+ RegionTranslate(destClip2, x - oldpt.x, y - oldpt.y);
}
/* and move those bits */
@@ -1419,22 +1418,20 @@ miOverlayResizeWindow( if (oldpt.x != x || oldpt.y != y) {
if(gravitate2[g]) {
pPriv->copyUnderlay = TRUE;
- (*pWin->drawable.pScreen->CopyWindow)(
- pWin, oldpt, gravitate2[g]);
+ (*pScreen->CopyWindow)(pWin, oldpt, gravitate2[g]);
}
if(gravitate[g]) {
pPriv->copyUnderlay = FALSE;
- (*pWin->drawable.pScreen->CopyWindow)(
- pWin, oldpt, gravitate[g]);
+ (*pScreen->CopyWindow)(pWin, oldpt, gravitate[g]);
}
}
/* remove any overwritten bits from the remaining useful bits */
if(gravitate[g])
- REGION_SUBTRACT(pScreen, oldRegion, oldRegion, gravitate[g]);
+ RegionSubtract(oldRegion, oldRegion, gravitate[g]);
if(gravitate2[g])
- REGION_SUBTRACT(pScreen, oldRegion2, oldRegion2, gravitate2[g]);
+ RegionSubtract(oldRegion2, oldRegion2, gravitate2[g]);
/*
* recompute exposed regions of child windows
@@ -1459,38 +1456,38 @@ miOverlayResizeWindow( if (g == pWin->bitGravity) {
if(gravitate[g])
- REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+ RegionSubtract(&pWin->valdata->after.exposed,
&pWin->valdata->after.exposed, gravitate[g]);
if(gravitate2[g] && pTree)
- REGION_SUBTRACT(pScreen, &pTree->valdata->exposed,
+ RegionSubtract(&pTree->valdata->exposed,
&pTree->valdata->exposed, gravitate2[g]);
}
if(gravitate[g]) {
if (!destClip)
destClip = gravitate[g];
else {
- REGION_UNION(pScreen, destClip, destClip, gravitate[g]);
- REGION_DESTROY(pScreen, gravitate[g]);
+ RegionUnion(destClip, destClip, gravitate[g]);
+ RegionDestroy(gravitate[g]);
}
}
if(gravitate2[g]) {
if (!destClip2)
destClip2 = gravitate2[g];
else {
- REGION_UNION(pScreen, destClip2, destClip2, gravitate2[g]);
- REGION_DESTROY(pScreen, gravitate2[g]);
+ RegionUnion(destClip2, destClip2, gravitate2[g]);
+ RegionDestroy(gravitate2[g]);
}
}
}
- REGION_DESTROY(pScreen, pRegion);
- REGION_DESTROY(pScreen, oldRegion);
+ RegionDestroy(pRegion);
+ RegionDestroy(oldRegion);
if(doUnderlay)
- REGION_DESTROY(pScreen, oldRegion2);
+ RegionDestroy(oldRegion2);
if (destClip)
- REGION_DESTROY(pScreen, destClip);
+ RegionDestroy(destClip);
if (destClip2)
- REGION_DESTROY(pScreen, destClip2);
+ RegionDestroy(destClip2);
(*pScreen->HandleExposures)(pWin->parent);
if (pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(pWin->parent, pFirstChange, VTOther);
@@ -1501,53 +1498,55 @@ miOverlayResizeWindow( static void
-miOverlaySetShape(WindowPtr pWin)
+miOverlaySetShape(WindowPtr pWin, int kind)
{
- Bool WasViewable = (Bool)(pWin->viewable);
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- if (WasViewable) {
- (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
-
- if (HasBorder (pWin)) {
- RegionPtr borderVisible;
-
- borderVisible = REGION_CREATE(pScreen, NullBox, 1);
- REGION_SUBTRACT(pScreen, borderVisible,
- &pWin->borderClip, &pWin->winSize);
- pWin->valdata->before.borderVisible = borderVisible;
- pWin->valdata->before.resized = TRUE;
- if(IN_UNDERLAY(pWin)) {
- miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
- RegionPtr borderVisible2;
-
- borderVisible2 = REGION_CREATE(pScreen, NULL, 1);
- REGION_SUBTRACT(pScreen, borderVisible2,
- &pTree->borderClip, &pWin->winSize);
- pTree->valdata->borderVisible = borderVisible2;
- }
- }
- }
+ Bool WasViewable = (Bool)(pWin->viewable);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ if (kind != ShapeInput) {
+ if (WasViewable) {
+ (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
+
+ if (HasBorder (pWin)) {
+ RegionPtr borderVisible;
+
+ borderVisible = RegionCreate(NullBox, 1);
+ RegionSubtract(borderVisible,
+ &pWin->borderClip, &pWin->winSize);
+ pWin->valdata->before.borderVisible = borderVisible;
+ pWin->valdata->before.resized = TRUE;
+ if(IN_UNDERLAY(pWin)) {
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+ RegionPtr borderVisible2;
+
+ borderVisible2 = RegionCreate(NULL, 1);
+ RegionSubtract(borderVisible2,
+ &pTree->borderClip, &pWin->winSize);
+ pTree->valdata->borderVisible = borderVisible2;
+ }
+ }
+ }
- SetWinSize (pWin);
- SetBorderSize (pWin);
+ SetWinSize (pWin);
+ SetBorderSize (pWin);
- ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
+ ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
- if (WasViewable) {
- (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
+ if (WasViewable) {
+ (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
- (*pScreen->ValidateTree)(pWin->parent, NullWindow, VTOther);
- }
+ (*pScreen->ValidateTree)(pWin->parent, NullWindow, VTOther);
+ }
- if (WasViewable) {
- (*pScreen->HandleExposures)(pWin->parent);
- if (pScreen->PostValidateTree)
- (*pScreen->PostValidateTree)(pWin->parent, NullWindow, VTOther);
+ if (WasViewable) {
+ (*pScreen->HandleExposures)(pWin->parent);
+ if (pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pWin->parent, NullWindow, VTOther);
+ }
}
if (pWin->realized)
- WindowsRestructured ();
+ WindowsRestructured ();
CheckCursorConfinement(pWin);
}
@@ -1580,16 +1579,16 @@ miOverlayChangeBorderWidth( if (HadBorder) {
RegionPtr borderVisible;
- borderVisible = REGION_CREATE(pScreen, NULL, 1);
- REGION_SUBTRACT(pScreen, borderVisible,
+ borderVisible = RegionCreate(NULL, 1);
+ RegionSubtract(borderVisible,
&pWin->borderClip, &pWin->winSize);
pWin->valdata->before.borderVisible = borderVisible;
if(IN_UNDERLAY(pWin)) {
miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
RegionPtr borderVisible2;
- borderVisible2 = REGION_CREATE(pScreen, NULL, 1);
- REGION_SUBTRACT(pScreen, borderVisible2,
+ borderVisible2 = RegionCreate(NULL, 1);
+ RegionSubtract(borderVisible2,
&pTree->borderClip, &pWin->winSize);
pTree->valdata->borderVisible = borderVisible2;
}
@@ -1611,7 +1610,7 @@ miOverlayChangeBorderWidth( void
miOverlaySetRootClip(ScreenPtr pScreen, Bool enable)
{
- WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pRoot);
MARK_UNDERLAY(pRoot);
@@ -1624,11 +1623,11 @@ miOverlaySetRootClip(ScreenPtr pScreen, Bool enable) box.x2 = pScreen->width;
box.y2 = pScreen->height;
- REGION_RESET(pScreen, &pTree->borderClip, &box);
+ RegionReset(&pTree->borderClip, &box);
} else
- REGION_EMPTY(pScreen, &pTree->borderClip);
+ RegionEmpty(&pTree->borderClip);
- REGION_BREAK(pScreen, &pTree->clipList);
+ RegionBreak(&pTree->clipList);
}
static void
@@ -1663,7 +1662,7 @@ miOverlayClearToBackground( clipList = ((*pScreenPriv->InOverlay)(pWin)) ? &pWin->clipList :
&pTree->clipList;
- extents = REGION_EXTENTS(pScreen, clipList);
+ extents = RegionExtents(clipList);
if (x1 < extents->x1) x1 = extents->x1;
if (x2 > extents->x2) x2 = extents->x2;
@@ -1676,16 +1675,16 @@ miOverlayClearToBackground( box.x1 = x1; box.x2 = x2;
box.y1 = y1; box.y2 = y2;
- REGION_INIT(pScreen, ®, &box, 1);
+ RegionInit(®, &box, 1);
- REGION_INTERSECT(pScreen, ®, ®, clipList);
+ RegionIntersect(®, ®, clipList);
if (generateExposures)
(*pScreen->WindowExposures)(pWin, ®, pBSReg);
else if (pWin->backgroundState != None)
miPaintWindow(pWin, ®, PW_BACKGROUND);
- REGION_UNINIT(pScreen, ®);
+ RegionUninit(®);
if (pBSReg)
- REGION_DESTROY(pScreen, pBSReg);
+ RegionDestroy(pBSReg);
}
@@ -1728,7 +1727,6 @@ miOverlayCopyUnderlay(ScreenPtr pScreen) void
miOverlayComputeCompositeClip(GCPtr pGC, WindowPtr pWin)
{
- ScreenPtr pScreen = pGC->pScreen;
miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
RegionPtr pregWin;
Bool freeTmpClip, freeCompClip;
@@ -1739,12 +1737,12 @@ miOverlayComputeCompositeClip(GCPtr pGC, WindowPtr pWin) }
if (pGC->subWindowMode == IncludeInferiors) {
- pregWin = REGION_CREATE(pScreen, NullBox, 1);
+ pregWin = RegionCreate(NullBox, 1);
freeTmpClip = TRUE;
if (pWin->parent || (screenIsSaved != SCREEN_SAVER_ON) ||
- !HasSaverWindow (pScreen->myNum))
+ !HasSaverWindow (pGC->pScreen))
{
- REGION_INTERSECT(pScreen,pregWin,&pTree->borderClip,&pWin->winSize);
+ RegionIntersect(pregWin,&pTree->borderClip,&pWin->winSize);
}
} else {
pregWin = &pTree->clipList;
@@ -1753,29 +1751,29 @@ miOverlayComputeCompositeClip(GCPtr pGC, WindowPtr pWin) freeCompClip = pGC->freeCompClip;
if (pGC->clientClipType == CT_NONE) {
if (freeCompClip)
- REGION_DESTROY(pScreen, pGC->pCompositeClip);
+ RegionDestroy(pGC->pCompositeClip);
pGC->pCompositeClip = pregWin;
pGC->freeCompClip = freeTmpClip;
} else {
- REGION_TRANSLATE(pScreen, pGC->clientClip,
+ RegionTranslate(pGC->clientClip,
pWin->drawable.x + pGC->clipOrg.x,
pWin->drawable.y + pGC->clipOrg.y);
if (freeCompClip) {
- REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ RegionIntersect(pGC->pCompositeClip,
pregWin, pGC->clientClip);
if (freeTmpClip)
- REGION_DESTROY(pScreen, pregWin);
+ RegionDestroy(pregWin);
} else if (freeTmpClip) {
- REGION_INTERSECT(pScreen, pregWin, pregWin, pGC->clientClip);
+ RegionIntersect(pregWin, pregWin, pGC->clientClip);
pGC->pCompositeClip = pregWin;
} else {
- pGC->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
- REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+ pGC->pCompositeClip = RegionCreate(NullBox, 0);
+ RegionIntersect(pGC->pCompositeClip,
pregWin, pGC->clientClip);
}
pGC->freeCompClip = TRUE;
- REGION_TRANSLATE(pScreen, pGC->clientClip,
+ RegionTranslate(pGC->clientClip,
-(pWin->drawable.x + pGC->clipOrg.x),
-(pWin->drawable.y + pGC->clipOrg.y));
}
@@ -1793,7 +1791,7 @@ miOverlayCollectUnderlayRegions( return FALSE;
}
- *region = REGION_CREATE(pWin->drawable.pScreen, NullBox, 0);
+ *region = RegionCreate(NullBox, 0);
CollectUnderlayChildrenRegions(pWin, *region);
@@ -1914,7 +1912,7 @@ CollectUnderlayChildrenRegions(WindowPtr pWin, RegionPtr pReg) while(1) {
if((pTree = MIOVERLAY_GET_WINDOW_TREE(pChild))) {
- REGION_APPEND(pScreen, pReg, &pTree->borderClip);
+ RegionAppend(pReg, &pTree->borderClip);
hasUnderlay = TRUE;
} else
if(pChild->firstChild) {
@@ -1932,7 +1930,7 @@ CollectUnderlayChildrenRegions(WindowPtr pWin, RegionPtr pReg) if(hasUnderlay) {
Bool overlap;
- REGION_VALIDATE(pScreen, pReg, &overlap);
+ RegionValidate(pReg, &overlap);
}
return hasUnderlay;
diff --git a/xorg-server/mi/mipointer.c b/xorg-server/mi/mipointer.c index 069a38bd8..4b9ce0fa5 100644 --- a/xorg-server/mi/mipointer.c +++ b/xorg-server/mi/mipointer.c @@ -40,15 +40,13 @@ in this Software without prior written authorization from The Open Group. # include "dixstruct.h"
# include "inputstr.h"
-static int miPointerScreenKeyIndex;
-DevPrivateKey miPointerScreenKey = &miPointerScreenKeyIndex;
+DevPrivateKeyRec miPointerScreenKeyRec;
#define GetScreenPrivate(s) ((miPointerScreenPtr) \
dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey))
#define SetupScreen(s) miPointerScreenPtr pScreenPriv = GetScreenPrivate(s)
-static int miPointerPrivKeyIndex;
-static DevPrivateKey miPointerPrivKey = &miPointerPrivKeyIndex;
+DevPrivateKeyRec miPointerPrivKeyRec;
#define MIPOINTER(dev) \
((!IsMaster(dev) && !dev->u.master) ? \
@@ -86,6 +84,12 @@ miPointerInitialize (ScreenPtr pScreen, {
miPointerScreenPtr pScreenPriv;
+ if (!dixRegisterPrivateKey(&miPointerScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&miPointerPrivKeyRec, PRIVATE_DEVICE, 0))
+ return FALSE;
+
pScreenPriv = malloc(sizeof (miPointerScreenRec));
if (!pScreenPriv)
return FALSE;
diff --git a/xorg-server/mi/mipointer.h b/xorg-server/mi/mipointer.h index 22575ea21..c48001267 100644 --- a/xorg-server/mi/mipointer.h +++ b/xorg-server/mi/mipointer.h @@ -1,144 +1,148 @@ -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. -*/ - -#ifndef MIPOINTER_H -#define MIPOINTER_H - -#include "cursor.h" -#include "input.h" -#include "privates.h" - -typedef struct _miPointerSpriteFuncRec { - Bool (*RealizeCursor)( - DeviceIntPtr /* pDev */, - ScreenPtr /* pScr */, - CursorPtr /* pCurs */ - ); - Bool (*UnrealizeCursor)( - DeviceIntPtr /* pDev */, - ScreenPtr /* pScr */, - CursorPtr /* pCurs */ - ); - void (*SetCursor)( - DeviceIntPtr /* pDev */, - ScreenPtr /* pScr */, - CursorPtr /* pCurs */, - int /* x */, - int /* y */ - ); - void (*MoveCursor)( - DeviceIntPtr /* pDev */, - ScreenPtr /* pScr */, - int /* x */, - int /* y */ - ); - Bool (*DeviceCursorInitialize)( - DeviceIntPtr /* pDev */, - ScreenPtr /* pScr */ - ); - void (*DeviceCursorCleanup)( - DeviceIntPtr /* pDev */, - ScreenPtr /* pScr */ - ); -} miPointerSpriteFuncRec, *miPointerSpriteFuncPtr; - -typedef struct _miPointerScreenFuncRec { - Bool (*CursorOffScreen)( - ScreenPtr* /* ppScr */, - int* /* px */, - int* /* py */ - ); - void (*CrossScreen)( - ScreenPtr /* pScr */, - int /* entering */ - ); - void (*WarpCursor)( - DeviceIntPtr /*pDev*/, - ScreenPtr /* pScr */, - int /* x */, - int /* y */ - ); - void (*EnqueueEvent)( - DeviceIntPtr /* pDev */, - InternalEvent* /* event */ - ); - void (*NewEventScreen)( - DeviceIntPtr /* pDev */, - ScreenPtr /* pScr */, - Bool /* fromDIX */ - ); -} miPointerScreenFuncRec, *miPointerScreenFuncPtr; - -extern _X_EXPORT Bool miDCInitialize( - ScreenPtr /*pScreen*/, - miPointerScreenFuncPtr /*screenFuncs*/ -); - -extern _X_EXPORT Bool miPointerInitialize( - ScreenPtr /*pScreen*/, - miPointerSpriteFuncPtr /*spriteFuncs*/, - miPointerScreenFuncPtr /*screenFuncs*/, - Bool /*waitForUpdate*/ -); - -extern _X_EXPORT void miPointerWarpCursor( - DeviceIntPtr /*pDev*/, - ScreenPtr /*pScreen*/, - int /*x*/, - int /*y*/ -); - -/* Deprecated in favour of miPointerGetScreen. */ -extern _X_EXPORT ScreenPtr miPointerCurrentScreen( - void -) _X_DEPRECATED; - -extern _X_EXPORT ScreenPtr miPointerGetScreen( - DeviceIntPtr pDev); -extern _X_EXPORT void miPointerSetScreen( - DeviceIntPtr pDev, - int screen_num, - int x, - int y); - -/* Returns the current cursor position. */ -extern _X_EXPORT void miPointerGetPosition( - DeviceIntPtr pDev, - int *x, - int *y); - -/* Moves the cursor to the specified position. May clip the co-ordinates: - * x and y are modified in-place. */ -extern _X_EXPORT void miPointerSetPosition( - DeviceIntPtr pDev, - int *x, - int *y); - -extern _X_EXPORT void miPointerUpdateSprite( - DeviceIntPtr pDev); - -extern _X_EXPORT DevPrivateKey miPointerScreenKey; - -#endif /* MIPOINTER_H */ +/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+
+#ifndef MIPOINTER_H
+#define MIPOINTER_H
+
+#include "cursor.h"
+#include "input.h"
+#include "privates.h"
+
+typedef struct _miPointerSpriteFuncRec {
+ Bool (*RealizeCursor)(
+ DeviceIntPtr /* pDev */,
+ ScreenPtr /* pScr */,
+ CursorPtr /* pCurs */
+ );
+ Bool (*UnrealizeCursor)(
+ DeviceIntPtr /* pDev */,
+ ScreenPtr /* pScr */,
+ CursorPtr /* pCurs */
+ );
+ void (*SetCursor)(
+ DeviceIntPtr /* pDev */,
+ ScreenPtr /* pScr */,
+ CursorPtr /* pCurs */,
+ int /* x */,
+ int /* y */
+ );
+ void (*MoveCursor)(
+ DeviceIntPtr /* pDev */,
+ ScreenPtr /* pScr */,
+ int /* x */,
+ int /* y */
+ );
+ Bool (*DeviceCursorInitialize)(
+ DeviceIntPtr /* pDev */,
+ ScreenPtr /* pScr */
+ );
+ void (*DeviceCursorCleanup)(
+ DeviceIntPtr /* pDev */,
+ ScreenPtr /* pScr */
+ );
+} miPointerSpriteFuncRec, *miPointerSpriteFuncPtr;
+
+typedef struct _miPointerScreenFuncRec {
+ Bool (*CursorOffScreen)(
+ ScreenPtr* /* ppScr */,
+ int* /* px */,
+ int* /* py */
+ );
+ void (*CrossScreen)(
+ ScreenPtr /* pScr */,
+ int /* entering */
+ );
+ void (*WarpCursor)(
+ DeviceIntPtr /*pDev*/,
+ ScreenPtr /* pScr */,
+ int /* x */,
+ int /* y */
+ );
+ void (*EnqueueEvent)(
+ DeviceIntPtr /* pDev */,
+ InternalEvent* /* event */
+ );
+ void (*NewEventScreen)(
+ DeviceIntPtr /* pDev */,
+ ScreenPtr /* pScr */,
+ Bool /* fromDIX */
+ );
+} miPointerScreenFuncRec, *miPointerScreenFuncPtr;
+
+extern _X_EXPORT Bool miDCInitialize(
+ ScreenPtr /*pScreen*/,
+ miPointerScreenFuncPtr /*screenFuncs*/
+);
+
+extern _X_EXPORT Bool miPointerInitialize(
+ ScreenPtr /*pScreen*/,
+ miPointerSpriteFuncPtr /*spriteFuncs*/,
+ miPointerScreenFuncPtr /*screenFuncs*/,
+ Bool /*waitForUpdate*/
+);
+
+extern _X_EXPORT void miPointerWarpCursor(
+ DeviceIntPtr /*pDev*/,
+ ScreenPtr /*pScreen*/,
+ int /*x*/,
+ int /*y*/
+);
+
+/* Deprecated in favour of miPointerGetScreen. */
+extern _X_EXPORT ScreenPtr miPointerCurrentScreen(
+ void
+) _X_DEPRECATED;
+
+extern _X_EXPORT ScreenPtr miPointerGetScreen(
+ DeviceIntPtr pDev);
+extern _X_EXPORT void miPointerSetScreen(
+ DeviceIntPtr pDev,
+ int screen_num,
+ int x,
+ int y);
+
+/* Returns the current cursor position. */
+extern _X_EXPORT void miPointerGetPosition(
+ DeviceIntPtr pDev,
+ int *x,
+ int *y);
+
+/* Moves the cursor to the specified position. May clip the co-ordinates:
+ * x and y are modified in-place. */
+extern _X_EXPORT void miPointerSetPosition(
+ DeviceIntPtr pDev,
+ int *x,
+ int *y);
+
+extern _X_EXPORT void miPointerUpdateSprite(
+ DeviceIntPtr pDev);
+
+extern _X_EXPORT DevPrivateKeyRec miPointerPrivKeyRec;
+#define miPointerPrivKey (&miPointerPrivKeyRec)
+
+extern _X_EXPORT DevPrivateKeyRec miPointerScreenKeyRec;
+#define miPointerScreenKey (&miPointerScreenKeyRec)
+
+#endif /* MIPOINTER_H */
diff --git a/xorg-server/mi/mipolycon.c b/xorg-server/mi/mipolycon.c index 170b2aa1a..7c9b47747 100644 --- a/xorg-server/mi/mipolycon.c +++ b/xorg-server/mi/mipolycon.c @@ -104,14 +104,14 @@ miFillConvexPoly( dy = ymax - ymin + 1;
if ((count < 3) || (dy < 0))
- return(TRUE);
+ return TRUE;
ptsOut = FirstPoint = malloc(sizeof(DDXPointRec)*dy);
width = FirstWidth = malloc(sizeof(int) * dy);
if(!FirstPoint || !FirstWidth)
{
- if (FirstWidth) free(FirstWidth);
- if (FirstPoint) free(FirstPoint);
- return(FALSE);
+ free(FirstWidth);
+ free(FirstPoint);
+ return FALSE;
}
nextleft = nextright = imin;
@@ -177,7 +177,7 @@ miFillConvexPoly( {
free(FirstWidth);
free(FirstPoint);
- return(TRUE);
+ return TRUE;
}
while (i-- > 0)
{
@@ -212,7 +212,7 @@ miFillConvexPoly( 1);
free(FirstWidth);
free(FirstPoint);
- return(TRUE);
+ return TRUE;
}
@@ -243,5 +243,5 @@ getPolyYBounds(DDXPointPtr pts, int n, int *by, int *ty) *by = ymin;
*ty = ymax;
- return(ptMin-ptsStart);
+ return ptMin-ptsStart;
}
diff --git a/xorg-server/mi/mipolygen.c b/xorg-server/mi/mipolygen.c index 3dbf68960..ce65ca370 100644 --- a/xorg-server/mi/mipolygen.c +++ b/xorg-server/mi/mipolygen.c @@ -90,16 +90,16 @@ miFillGeneralPoly( int fixWAET = 0;
if (count < 3)
- return(TRUE);
+ return TRUE;
if(!(pETEs = malloc(sizeof(EdgeTableEntry) * count)))
- return(FALSE);
+ return FALSE;
ptsOut = FirstPoint;
width = FirstWidth;
if (!miCreateETandAET(count, ptsIn, &ET, &AET, pETEs, &SLLBlock))
{
free(pETEs);
- return(FALSE);
+ return FALSE;
}
pSLL = ET.scanlines.next;
@@ -226,5 +226,5 @@ miFillGeneralPoly( (*pgc->ops->FillSpans)(dst, pgc, nPts, FirstPoint, FirstWidth, 1);
free(pETEs);
miFreeStorage(SLLBlock.next);
- return(TRUE);
+ return TRUE;
}
diff --git a/xorg-server/mi/mipolyutil.c b/xorg-server/mi/mipolyutil.c index fe0d9e5bf..e17fb52e4 100644 --- a/xorg-server/mi/mipolyutil.c +++ b/xorg-server/mi/mipolyutil.c @@ -365,7 +365,7 @@ miInsertionSort(EdgeTableEntry *AET) changed = 1;
}
}
- return(changed);
+ return changed;
}
/*
diff --git a/xorg-server/mi/miscrinit.c b/xorg-server/mi/miscrinit.c index 2af17672b..60a983e65 100644 --- a/xorg-server/mi/miscrinit.c +++ b/xorg-server/mi/miscrinit.c @@ -292,21 +292,25 @@ miScreenInit( return miScreenDevPrivateInit(pScreen, width, pbits);
}
-static int privateKeyIndex;
-static DevPrivateKey privateKey = &privateKeyIndex;
+static DevPrivateKeyRec privateKeyRec;
+#define privateKey (&privateKeyRec)
DevPrivateKey
miAllocateGCPrivateIndex(void)
{
+ if (!dixRegisterPrivateKey(&privateKeyRec, PRIVATE_GC, 0))
+ return NULL;
return privateKey;
}
-static int miZeroLineScreenKeyIndex;
-DevPrivateKey miZeroLineScreenKey = &miZeroLineScreenKeyIndex;
+DevPrivateKeyRec miZeroLineScreenKeyRec;
void
miSetZeroLineBias(ScreenPtr pScreen, unsigned int bias)
{
+ if (!dixRegisterPrivateKey(&miZeroLineScreenKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
dixSetPrivate(&pScreen->devPrivates, miZeroLineScreenKey,
(unsigned long *)(unsigned long)bias);
}
diff --git a/xorg-server/mi/mispans.c b/xorg-server/mi/mispans.c index 7b332ee34..ccf2a723e 100644 --- a/xorg-server/mi/mispans.c +++ b/xorg-server/mi/mispans.c @@ -410,10 +410,8 @@ void miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup *spanGroup) if (!yspans || !ysizes)
{
- if (yspans)
- free(yspans);
- if (ysizes)
- free(ysizes);
+ free(yspans);
+ free(ysizes);
miDisposeSpanGroup (spanGroup);
return;
}
@@ -492,10 +490,8 @@ void miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup *spanGroup) }
free(yspans);
free(ysizes);
- if (points)
- free(points);
- if (widths)
- free(widths);
+ free(points);
+ free(widths);
return;
}
count = 0;
diff --git a/xorg-server/mi/mispans.h b/xorg-server/mi/mispans.h index 8151415cc..5a5f5d2b6 100644 --- a/xorg-server/mi/mispans.h +++ b/xorg-server/mi/mispans.h @@ -1,102 +1,92 @@ -/*********************************************************** - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1989 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - -#ifndef MISPANS_H -#define MISPANS_H - -typedef struct { - int count; /* number of spans */ - DDXPointPtr points; /* pointer to list of start points */ - int *widths; /* pointer to list of widths */ -} Spans; - -typedef struct { - int size; /* Total number of *Spans allocated */ - int count; /* Number of *Spans actually in group */ - Spans *group; /* List of Spans */ - int ymin, ymax; /* Min, max y values encountered */ -} SpanGroup; - -/* Initialize SpanGroup. MUST BE DONE before use. */ -extern _X_EXPORT void miInitSpanGroup( - SpanGroup * /*spanGroup*/ -); - -/* Add a Spans to a SpanGroup. The spans MUST BE in y-sorted order */ -extern _X_EXPORT void miAppendSpans( - SpanGroup * /*spanGroup*/, - SpanGroup * /*otherGroup*/, - Spans * /*spans*/ -); - -/* Paint a span group, insuring that each pixel is painted at most once */ -extern _X_EXPORT void miFillUniqueSpanGroup( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - SpanGroup * /*spanGroup*/ -); - -/* Free up data in a span group. MUST BE DONE or you'll suffer memory leaks */ -extern _X_EXPORT void miFreeSpanGroup( - SpanGroup * /*spanGroup*/ -); - -extern _X_EXPORT int miClipSpans( - RegionPtr /*prgnDst*/, - DDXPointPtr /*ppt*/, - int * /*pwidth*/, - int /*nspans*/, - DDXPointPtr /*pptNew*/, - int * /*pwidthNew*/, - int /*fSorted*/ -); - -/* Rops which must use span groups */ -#define miSpansCarefulRop(rop) (((rop) & 0xc) == 0x8 || ((rop) & 0x3) == 0x2) -#define miSpansEasyRop(rop) (!miSpansCarefulRop(rop)) - -#endif /* MISPANS_H */ +/***********************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef MISPANS_H
+#define MISPANS_H
+
+typedef struct {
+ int count; /* number of spans */
+ DDXPointPtr points; /* pointer to list of start points */
+ int *widths; /* pointer to list of widths */
+} Spans;
+
+typedef struct {
+ int size; /* Total number of *Spans allocated */
+ int count; /* Number of *Spans actually in group */
+ Spans *group; /* List of Spans */
+ int ymin, ymax; /* Min, max y values encountered */
+} SpanGroup;
+
+/* Initialize SpanGroup. MUST BE DONE before use. */
+extern _X_EXPORT void miInitSpanGroup(
+ SpanGroup * /*spanGroup*/
+);
+
+/* Add a Spans to a SpanGroup. The spans MUST BE in y-sorted order */
+extern _X_EXPORT void miAppendSpans(
+ SpanGroup * /*spanGroup*/,
+ SpanGroup * /*otherGroup*/,
+ Spans * /*spans*/
+);
+
+/* Paint a span group, insuring that each pixel is painted at most once */
+extern _X_EXPORT void miFillUniqueSpanGroup(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ SpanGroup * /*spanGroup*/
+);
+
+/* Free up data in a span group. MUST BE DONE or you'll suffer memory leaks */
+extern _X_EXPORT void miFreeSpanGroup(
+ SpanGroup * /*spanGroup*/
+);
+
+/* Rops which must use span groups */
+#define miSpansCarefulRop(rop) (((rop) & 0xc) == 0x8 || ((rop) & 0x3) == 0x2)
+#define miSpansEasyRop(rop) (!miSpansCarefulRop(rop))
+
+#endif /* MISPANS_H */
diff --git a/xorg-server/mi/misprite.c b/xorg-server/mi/misprite.c index 7dce00672..64eed4bd3 100644 --- a/xorg-server/mi/misprite.c +++ b/xorg-server/mi/misprite.c @@ -182,10 +182,10 @@ miSpriteIsDown(miCursorInfoPtr pDevCursor) * screen wrappers
*/
-static int miSpriteScreenKeyIndex;
-static DevPrivateKey miSpriteScreenKey = &miSpriteScreenKeyIndex;
-static int miSpriteDevPrivatesKeyIndex;
-static DevPrivateKey miSpriteDevPrivatesKey = &miSpriteDevPrivatesKeyIndex;
+static DevPrivateKeyRec miSpriteScreenKeyRec;
+#define miSpriteScreenKey (&miSpriteScreenKeyRec)
+static DevPrivateKeyRec miSpriteDevPrivatesKeyRec;
+#define miSpriteDevPrivatesKey (&miSpriteDevPrivatesKeyRec)
static Bool miSpriteCloseScreen(int i, ScreenPtr pScreen);
static void miSpriteGetImage(DrawablePtr pDrawable, int sx, int sy,
@@ -268,7 +268,7 @@ miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure) if (pCursorInfo->isUp &&
pCursorInfo->pScreen == pScreen &&
- miRectIn(pRegion, &pCursorInfo->saved) != rgnOUT)
+ RegionContainsRect(pRegion, &pCursorInfo->saved) != rgnOUT)
{
SPRITE_DEBUG(("Damage remove\n"));
miSpriteRemoveCursor (pDev, pScreen);
@@ -293,6 +293,12 @@ miSpriteInitialize (ScreenPtr pScreen, if (!DamageSetup (pScreen))
return FALSE;
+ if (!dixRegisterPrivateKey(&miSpriteScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&miSpriteDevPrivatesKeyRec, PRIVATE_DEVICE, 0))
+ return FALSE;
+
pScreenPriv = malloc(sizeof (miSpriteScreenRec));
if (!pScreenPriv)
return FALSE;
@@ -523,7 +529,7 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) * Damage will take care of destination check
*/
if (pCursorInfo && pCursorInfo->isUp && pCursorInfo->pScreen == pScreen &&
- miRectIn(prgnSrc, &pCursorInfo->saved) != rgnOUT)
+ RegionContainsRect(prgnSrc, &pCursorInfo->saved) != rgnOUT)
{
SPRITE_DEBUG (("CopyWindow remove\n"));
miSpriteRemoveCursor (pDev, pScreen);
@@ -801,73 +807,9 @@ miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, miSpriteFindColors (pPointer, pScreen);
}
if (pPointer->isUp) {
-#if 0
- /* FIXME: Disabled for MPX, should be rewritten */
- int sx, sy;
- /*
- * check to see if the old saved region
- * encloses the new sprite, in which case we use
- * the flicker-free MoveCursor primitive.
- */
- sx = pointer->x - (int)pCursor->bits->xhot;
- sy = pointer->y - (int)pCursor->bits->yhot;
- if (sx + (int) pCursor->bits->width >= pointer->saved.x1 &&
- sx < pointer->saved.x2 &&
- sy + (int) pCursor->bits->height >= pointer->saved.y1 &&
- sy < pointer->saved.y2 &&
- (int) pCursor->bits->width + (2 * SPRITE_PAD) ==
- pointer->saved.x2 - pointer->saved.x1 &&
- (int) pCursor->bits->height + (2 * SPRITE_PAD) ==
- pointer->saved.y2 - pointer->saved.y1
- )
- {
- DamageDrawInternal (pScreen, TRUE);
- miSpriteIsDown(pCursorInfo);
- if (!(sx >= pointer->saved.x1 &&
- sx + (int)pCursor->bits->width < pointer->saved.x2
- && sy >= pointer->saved.y1 &&
- sy + (int)pCursor->bits->height <
- pointer->saved.y2))
- {
- int oldx1, oldy1, dx, dy;
-
- oldx1 = pointer->saved.x1;
- oldy1 = pointer->saved.y1;
- dx = oldx1 - (sx - SPRITE_PAD);
- dy = oldy1 - (sy - SPRITE_PAD);
- pointer->saved.x1 -= dx;
- pointer->saved.y1 -= dy;
- pointer->saved.x2 -= dx;
- pointer->saved.y2 -= dy;
- (void) miDCChangeSave(pScreen,
- pointer->saved.x1,
- pointer->saved.y1,
- pointer->saved.x2 -
- pointer->saved.x1,
- pointer->saved.y2 -
- pointer->saved.y1,
- dx, dy);
- }
- (void) miDCMoveCursor(pScreen, pCursor,
- pointer->saved.x1,
- pointer->saved.y1,
- pointer->saved.x2 -
- pointer->saved.x1,
- pointer->saved.y2 -
- pointer->saved.y1,
- sx - pointer->saved.x1,
- sy - pointer->saved.y1,
- pointer->colors[SOURCE_COLOR].pixel,
- pointer->colors[MASK_COLOR].pixel);
- miSpriteIsUp(pCursorInfo);
- DamageDrawInternal (pScreen, FALSE);
- }
- else
-#endif
- {
- SPRITE_DEBUG (("SetCursor remove %d\n", pDev->id));
- miSpriteRemoveCursor (pDev, pScreen);
- }
+ /* TODO: reimplement flicker-free MoveCursor */
+ SPRITE_DEBUG (("SetCursor remove %d\n", pDev->id));
+ miSpriteRemoveCursor (pDev, pScreen);
}
if (!pPointer->isUp && pPointer->pCursor)
diff --git a/xorg-server/mi/misprite.h b/xorg-server/mi/misprite.h index 6dbc48460..635a6fad7 100644 --- a/xorg-server/mi/misprite.h +++ b/xorg-server/mi/misprite.h @@ -46,12 +46,5 @@ extern Bool miDCSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, int w, int h);
extern Bool miDCRestoreUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
int x, int y, int w, int h);
-extern Bool miDCMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
- CursorPtr pCursor, int x, int y,
- int w, int h, int dx, int dy,
- unsigned long source, unsigned long mask);
-extern Bool miDCChangeSave(DeviceIntPtr pDev, ScreenPtr pScreen,
- int x, int y, int w, int h,
- int dx, int dy);
extern Bool miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen);
extern void miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
diff --git a/xorg-server/mi/mivaltree.c b/xorg-server/mi/mivaltree.c index cfcdab756..36ec8e60a 100644 --- a/xorg-server/mi/mivaltree.c +++ b/xorg-server/mi/mivaltree.c @@ -1,815 +1,813 @@ -/* - * mivaltree.c -- - * Functions for recalculating window clip lists. Main function - * is miValidateTree. - * - -Copyright 1987, 1988, 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - * - * Copyright 1987, 1988, 1989 by - * Digital Equipment Corporation, Maynard, Massachusetts, - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Digital not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * - * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR - * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - ******************************************************************/ - -/* The panoramix components contained the following notice */ -/***************************************************************** - -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. - -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. - -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 -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. - -******************************************************************/ - - - /* - * Aug '86: Susan Angebranndt -- original code - * July '87: Adam de Boor -- substantially modified and commented - * Summer '89: Joel McCormack -- so fast you wouldn't believe it possible. - * In particular, much improved code for window mapping and - * circulating. - * Bob Scheifler -- avoid miComputeClips for unmapped windows, - * valdata changes - */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include "scrnintstr.h" -#include "validate.h" -#include "windowstr.h" -#include "mi.h" -#include "regionstr.h" -#include "mivalidate.h" - -#include "globals.h" - -/* - * Compute the visibility of a shaped window - */ -int -miShapedWindowIn (ScreenPtr pScreen, RegionPtr universe, RegionPtr bounding, - BoxPtr rect, int x, int y) -{ - BoxRec box; - BoxPtr boundBox; - int nbox; - Bool someIn, someOut; - int t, x1, y1, x2, y2; - - nbox = REGION_NUM_RECTS (bounding); - boundBox = REGION_RECTS (bounding); - someIn = someOut = FALSE; - x1 = rect->x1; - y1 = rect->y1; - x2 = rect->x2; - y2 = rect->y2; - while (nbox--) - { - if ((t = boundBox->x1 + x) < x1) - t = x1; - box.x1 = t; - if ((t = boundBox->y1 + y) < y1) - t = y1; - box.y1 = t; - if ((t = boundBox->x2 + x) > x2) - t = x2; - box.x2 = t; - if ((t = boundBox->y2 + y) > y2) - t = y2; - box.y2 = t; - if (box.x1 > box.x2) - box.x2 = box.x1; - if (box.y1 > box.y2) - box.y2 = box.y1; - switch (RECT_IN_REGION(pScreen, universe, &box)) - { - case rgnIN: - if (someOut) - return rgnPART; - someIn = TRUE; - break; - case rgnOUT: - if (someIn) - return rgnPART; - someOut = TRUE; - break; - default: - return rgnPART; - } - boundBox++; - } - if (someIn) - return rgnIN; - return rgnOUT; -} - -static GetRedirectBorderClipProcPtr miGetRedirectBorderClipProc; -static SetRedirectBorderClipProcPtr miSetRedirectBorderClipProc; - -void -miRegisterRedirectBorderClipProc (SetRedirectBorderClipProcPtr setBorderClip, - GetRedirectBorderClipProcPtr getBorderClip) -{ - miSetRedirectBorderClipProc = setBorderClip; - miGetRedirectBorderClipProc = getBorderClip; -} - -/* - * Manual redirected windows are treated as transparent; they do not obscure - * siblings or parent windows - */ - -#ifdef COMPOSITE -#define TreatAsTransparent(w) ((w)->redirectDraw == RedirectDrawManual) -#else -#define TreatAsTransparent(w) FALSE -#endif - -#define HasParentRelativeBorder(w) (!(w)->borderIsPixel && \ - HasBorder(w) && \ - (w)->backgroundState == ParentRelative) - - -/* - *----------------------------------------------------------------------- - * miComputeClips -- - * Recompute the clipList, borderClip, exposed and borderExposed - * regions for pParent and its children. Only viewable windows are - * taken into account. - * - * Results: - * None. - * - * Side Effects: - * clipList, borderClip, exposed and borderExposed are altered. - * A VisibilityNotify event may be generated on the parent window. - * - *----------------------------------------------------------------------- - */ -static void -miComputeClips ( - WindowPtr pParent, - ScreenPtr pScreen, - RegionPtr universe, - VTKind kind, - RegionPtr exposed ) /* for intermediate calculations */ -{ - int dx, - dy; - RegionRec childUniverse; - WindowPtr pChild; - int oldVis, newVis; - BoxRec borderSize; - RegionRec childUnion; - Bool overlap; - RegionPtr borderVisible; - Bool resized; - /* - * Figure out the new visibility of this window. - * The extent of the universe should be the same as the extent of - * the borderSize region. If the window is unobscured, this rectangle - * will be completely inside the universe (the universe will cover it - * completely). If the window is completely obscured, none of the - * universe will cover the rectangle. - */ - borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent); - borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent); - dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent); - if (dx > 32767) - dx = 32767; - borderSize.x2 = dx; - dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent); - if (dy > 32767) - dy = 32767; - borderSize.y2 = dy; - -#ifdef COMPOSITE - /* - * In redirected drawing case, reset universe to borderSize - */ - if (pParent->redirectDraw != RedirectDrawNone) - { - if (miSetRedirectBorderClipProc) - { - if (TreatAsTransparent (pParent)) - REGION_EMPTY (pScreen, universe); - (*miSetRedirectBorderClipProc) (pParent, universe); - } - REGION_COPY(pScreen, universe, &pParent->borderSize); - } -#endif - - oldVis = pParent->visibility; - switch (RECT_IN_REGION( pScreen, universe, &borderSize)) - { - case rgnIN: - newVis = VisibilityUnobscured; - break; - case rgnPART: - newVis = VisibilityPartiallyObscured; - { - RegionPtr pBounding; - - if ((pBounding = wBoundingShape (pParent))) - { - switch (miShapedWindowIn (pScreen, universe, pBounding, - &borderSize, - pParent->drawable.x, - pParent->drawable.y)) - { - case rgnIN: - newVis = VisibilityUnobscured; - break; - case rgnOUT: - newVis = VisibilityFullyObscured; - break; - } - } - } - break; - default: - newVis = VisibilityFullyObscured; - break; - } - pParent->visibility = newVis; - if (oldVis != newVis && - ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask)) - SendVisibilityNotify(pParent); - - dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x; - dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y; - - /* - * avoid computations when dealing with simple operations - */ - - switch (kind) { - case VTMap: - case VTStack: - case VTUnmap: - break; - case VTMove: - if ((oldVis == newVis) && - ((oldVis == VisibilityFullyObscured) || - (oldVis == VisibilityUnobscured))) - { - pChild = pParent; - while (1) - { - if (pChild->viewable) - { - if (pChild->visibility != VisibilityFullyObscured) - { - REGION_TRANSLATE( pScreen, &pChild->borderClip, - dx, dy); - REGION_TRANSLATE( pScreen, &pChild->clipList, - dx, dy); - pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER; - if (pScreen->ClipNotify) - (* pScreen->ClipNotify) (pChild, dx, dy); - - } - if (pChild->valdata) - { - REGION_NULL(pScreen, - &pChild->valdata->after.borderExposed); - if (HasParentRelativeBorder(pChild)) - { - REGION_SUBTRACT(pScreen, - &pChild->valdata->after.borderExposed, - &pChild->borderClip, - &pChild->winSize); - } - REGION_NULL(pScreen, &pChild->valdata->after.exposed); - } - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - } - while (!pChild->nextSib && (pChild != pParent)) - pChild = pChild->parent; - if (pChild == pParent) - break; - pChild = pChild->nextSib; - } - return; - } - /* fall through */ - default: - /* - * To calculate exposures correctly, we have to translate the old - * borderClip and clipList regions to the window's new location so there - * is a correspondence between pieces of the new and old clipping regions. - */ - if (dx || dy) - { - /* - * We translate the old clipList because that will be exposed or copied - * if gravity is right. - */ - REGION_TRANSLATE( pScreen, &pParent->borderClip, dx, dy); - REGION_TRANSLATE( pScreen, &pParent->clipList, dx, dy); - } - break; - case VTBroken: - REGION_EMPTY (pScreen, &pParent->borderClip); - REGION_EMPTY (pScreen, &pParent->clipList); - break; - } - - borderVisible = pParent->valdata->before.borderVisible; - resized = pParent->valdata->before.resized; - REGION_NULL(pScreen, &pParent->valdata->after.borderExposed); - REGION_NULL(pScreen, &pParent->valdata->after.exposed); - - /* - * Since the borderClip must not be clipped by the children, we do - * the border exposure first... - * - * 'universe' is the window's borderClip. To figure the exposures, remove - * the area that used to be exposed from the new. - * This leaves a region of pieces that weren't exposed before. - */ - - if (HasBorder (pParent)) - { - if (borderVisible) - { - /* - * when the border changes shape, the old visible portions - * of the border will be saved by DIX in borderVisible -- - * use that region and destroy it - */ - REGION_SUBTRACT( pScreen, exposed, universe, borderVisible); - REGION_DESTROY( pScreen, borderVisible); - } - else - { - REGION_SUBTRACT( pScreen, exposed, universe, &pParent->borderClip); - } - if (HasParentRelativeBorder(pParent) && (dx || dy)) - REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed, - universe, - &pParent->winSize); - else - REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed, - exposed, &pParent->winSize); - - REGION_COPY( pScreen, &pParent->borderClip, universe); - - /* - * To get the right clipList for the parent, and to make doubly sure - * that no child overlaps the parent's border, we remove the parent's - * border from the universe before proceeding. - */ - - REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize); - } - else - REGION_COPY( pScreen, &pParent->borderClip, universe); - - if ((pChild = pParent->firstChild) && pParent->mapped) - { - REGION_NULL(pScreen, &childUniverse); - REGION_NULL(pScreen, &childUnion); - if ((pChild->drawable.y < pParent->lastChild->drawable.y) || - ((pChild->drawable.y == pParent->lastChild->drawable.y) && - (pChild->drawable.x < pParent->lastChild->drawable.x))) - { - for (; pChild; pChild = pChild->nextSib) - { - if (pChild->viewable && !TreatAsTransparent(pChild)) - REGION_APPEND( pScreen, &childUnion, &pChild->borderSize); - } - } - else - { - for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib) - { - if (pChild->viewable && !TreatAsTransparent(pChild)) - REGION_APPEND( pScreen, &childUnion, &pChild->borderSize); - } - } - REGION_VALIDATE( pScreen, &childUnion, &overlap); - - for (pChild = pParent->firstChild; - pChild; - pChild = pChild->nextSib) - { - if (pChild->viewable) { - /* - * If the child is viewable, we want to remove its extents - * from the current universe, but we only re-clip it if - * it's been marked. - */ - if (pChild->valdata) { - /* - * Figure out the new universe from the child's - * perspective and recurse. - */ - REGION_INTERSECT( pScreen, &childUniverse, - universe, - &pChild->borderSize); - miComputeClips (pChild, pScreen, &childUniverse, kind, - exposed); - } - /* - * Once the child has been processed, we remove its extents - * from the current universe, thus denying its space to any - * other sibling. - */ - if (overlap && !TreatAsTransparent (pChild)) - REGION_SUBTRACT( pScreen, universe, universe, - &pChild->borderSize); - } - } - if (!overlap) - REGION_SUBTRACT( pScreen, universe, universe, &childUnion); - REGION_UNINIT( pScreen, &childUnion); - REGION_UNINIT( pScreen, &childUniverse); - } /* if any children */ - - /* - * 'universe' now contains the new clipList for the parent window. - * - * To figure the exposure of the window we subtract the old clip from the - * new, just as for the border. - */ - - if (oldVis == VisibilityFullyObscured || - oldVis == VisibilityNotViewable) - { - REGION_COPY( pScreen, &pParent->valdata->after.exposed, universe); - } - else if (newVis != VisibilityFullyObscured && - newVis != VisibilityNotViewable) - { - REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed, - universe, &pParent->clipList); - } - - /* HACK ALERT - copying contents of regions, instead of regions */ - { - RegionRec tmp; - - tmp = pParent->clipList; - pParent->clipList = *universe; - *universe = tmp; - } - -#ifdef NOTDEF - REGION_COPY( pScreen, &pParent->clipList, universe); -#endif - - pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER; - - if (pScreen->ClipNotify) - (* pScreen->ClipNotify) (pParent, dx, dy); -} - -static void -miTreeObscured( - WindowPtr pParent ) -{ - WindowPtr pChild; - int oldVis; - - pChild = pParent; - while (1) - { - if (pChild->viewable) - { - oldVis = pChild->visibility; - if (oldVis != (pChild->visibility = VisibilityFullyObscured) && - ((pChild->eventMask | wOtherEventMasks(pChild)) & VisibilityChangeMask)) - SendVisibilityNotify(pChild); - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - } - while (!pChild->nextSib && (pChild != pParent)) - pChild = pChild->parent; - if (pChild == pParent) - break; - pChild = pChild->nextSib; - } -} - -/* - *----------------------------------------------------------------------- - * miValidateTree -- - * Recomputes the clip list for pParent and all its inferiors. - * - * Results: - * Always returns 1. - * - * Side Effects: - * The clipList, borderClip, exposed, and borderExposed regions for - * each marked window are altered. - * - * Notes: - * This routine assumes that all affected windows have been marked - * (valdata created) and their winSize and borderSize regions - * adjusted to correspond to their new positions. The borderClip and - * clipList regions should not have been touched. - * - * The top-most level is treated differently from all lower levels - * because pParent is unchanged. For the top level, we merge the - * regions taken up by the marked children back into the clipList - * for pParent, thus forming a region from which the marked children - * can claim their areas. For lower levels, where the old clipList - * and borderClip are invalid, we can't do this and have to do the - * extra operations done in miComputeClips, but this is much faster - * e.g. when only one child has moved... - * - *----------------------------------------------------------------------- - */ -/*ARGSUSED*/ -int -miValidateTree ( - WindowPtr pParent, /* Parent to validate */ - WindowPtr pChild, /* First child of pParent that was - * affected */ - VTKind kind /* What kind of configuration caused call */ - ) -{ - RegionRec totalClip; /* Total clipping region available to - * the marked children. pParent's clipList - * merged with the borderClips of all - * the marked children. */ - RegionRec childClip; /* The new borderClip for the current - * child */ - RegionRec childUnion; /* the space covered by borderSize for - * all marked children */ - RegionRec exposed; /* For intermediate calculations */ - ScreenPtr pScreen; - WindowPtr pWin; - Bool overlap; - int viewvals; - Bool forward; - - pScreen = pParent->drawable.pScreen; - if (pChild == NullWindow) - pChild = pParent->firstChild; - - REGION_NULL(pScreen, &childClip); - REGION_NULL(pScreen, &exposed); - - /* - * compute the area of the parent window occupied - * by the marked children + the parent itself. This - * is the area which can be divied up among the marked - * children in their new configuration. - */ - REGION_NULL(pScreen, &totalClip); - viewvals = 0; - if (REGION_BROKEN (pScreen, &pParent->clipList) && - !REGION_BROKEN (pScreen, &pParent->borderClip)) - { - kind = VTBroken; - /* - * When rebuilding clip lists after out of memory, - * assume everything is busted. - */ - forward = TRUE; - REGION_COPY (pScreen, &totalClip, &pParent->borderClip); - REGION_INTERSECT (pScreen, &totalClip, &totalClip, &pParent->winSize); - - for (pWin = pParent->firstChild; pWin != pChild; pWin = pWin->nextSib) - { - if (pWin->viewable && !TreatAsTransparent (pWin)) - REGION_SUBTRACT (pScreen, &totalClip, &totalClip, &pWin->borderSize); - } - for (pWin = pChild; pWin; pWin = pWin->nextSib) - if (pWin->valdata && pWin->viewable) - viewvals++; - - REGION_EMPTY (pScreen, &pParent->clipList); - } - else - { - if ((pChild->drawable.y < pParent->lastChild->drawable.y) || - ((pChild->drawable.y == pParent->lastChild->drawable.y) && - (pChild->drawable.x < pParent->lastChild->drawable.x))) - { - forward = TRUE; - for (pWin = pChild; pWin; pWin = pWin->nextSib) - { - if (pWin->valdata) - { - RegionPtr pBorderClip = &pWin->borderClip; -#ifdef COMPOSITE - if (pWin->redirectDraw != RedirectDrawNone && miGetRedirectBorderClipProc) - pBorderClip = (*miGetRedirectBorderClipProc)(pWin); -#endif - REGION_APPEND( pScreen, &totalClip, pBorderClip ); - if (pWin->viewable) - viewvals++; - } - } - } - else - { - forward = FALSE; - pWin = pParent->lastChild; - while (1) - { - if (pWin->valdata) - { - RegionPtr pBorderClip = &pWin->borderClip; -#ifdef COMPOSITE - if (pWin->redirectDraw != RedirectDrawNone && miGetRedirectBorderClipProc) - pBorderClip = (*miGetRedirectBorderClipProc)(pWin); -#endif - REGION_APPEND( pScreen, &totalClip, pBorderClip ); - if (pWin->viewable) - viewvals++; - } - if (pWin == pChild) - break; - pWin = pWin->prevSib; - } - } - REGION_VALIDATE( pScreen, &totalClip, &overlap); - } - - /* - * Now go through the children of the root and figure their new - * borderClips from the totalClip, passing that off to miComputeClips - * to handle recursively. Once that's done, we remove the child - * from the totalClip to clip any siblings below it. - */ - - overlap = TRUE; - if (kind != VTStack) - { - REGION_UNION( pScreen, &totalClip, &totalClip, &pParent->clipList); - if (viewvals > 1) - { - /* - * precompute childUnion to discover whether any of them - * overlap. This seems redundant, but performance studies - * have demonstrated that the cost of this loop is - * lower than the cost of multiple Subtracts in the - * loop below. - */ - REGION_NULL(pScreen, &childUnion); - if (forward) - { - for (pWin = pChild; pWin; pWin = pWin->nextSib) - if (pWin->valdata && pWin->viewable && !TreatAsTransparent (pWin)) - REGION_APPEND( pScreen, &childUnion, - &pWin->borderSize); - } - else - { - pWin = pParent->lastChild; - while (1) - { - if (pWin->valdata && pWin->viewable && !TreatAsTransparent (pWin)) - REGION_APPEND( pScreen, &childUnion, - &pWin->borderSize); - if (pWin == pChild) - break; - pWin = pWin->prevSib; - } - } - REGION_VALIDATE(pScreen, &childUnion, &overlap); - if (overlap) - REGION_UNINIT(pScreen, &childUnion); - } - } - - for (pWin = pChild; - pWin != NullWindow; - pWin = pWin->nextSib) - { - if (pWin->viewable) { - if (pWin->valdata) { - REGION_INTERSECT( pScreen, &childClip, - &totalClip, - &pWin->borderSize); - miComputeClips (pWin, pScreen, &childClip, kind, &exposed); - if (overlap && !TreatAsTransparent (pWin)) - { - REGION_SUBTRACT( pScreen, &totalClip, - &totalClip, - &pWin->borderSize); - } - } else if (pWin->visibility == VisibilityNotViewable) { - miTreeObscured(pWin); - } - } else { - if (pWin->valdata) { - REGION_EMPTY( pScreen, &pWin->clipList); - if (pScreen->ClipNotify) - (* pScreen->ClipNotify) (pWin, 0, 0); - REGION_EMPTY( pScreen, &pWin->borderClip); - pWin->valdata = NULL; - } - } - } - - REGION_UNINIT( pScreen, &childClip); - if (!overlap) - { - REGION_SUBTRACT(pScreen, &totalClip, &totalClip, &childUnion); - REGION_UNINIT(pScreen, &childUnion); - } - - REGION_NULL(pScreen, &pParent->valdata->after.exposed); - REGION_NULL(pScreen, &pParent->valdata->after.borderExposed); - - /* - * each case below is responsible for updating the - * clipList and serial number for the parent window - */ - - switch (kind) { - case VTStack: - break; - default: - /* - * totalClip contains the new clipList for the parent. Figure out - * exposures and obscures as per miComputeClips and reset the parent's - * clipList. - */ - REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed, - &totalClip, &pParent->clipList); - /* fall through */ - case VTMap: - REGION_COPY( pScreen, &pParent->clipList, &totalClip); - pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER; - break; - } - - REGION_UNINIT( pScreen, &totalClip); - REGION_UNINIT( pScreen, &exposed); - if (pScreen->ClipNotify) - (*pScreen->ClipNotify) (pParent, 0, 0); - return (1); -} +/*
+ * mivaltree.c --
+ * Functions for recalculating window clip lists. Main function
+ * is miValidateTree.
+ *
+
+Copyright 1987, 1988, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+ *
+ * Copyright 1987, 1988, 1989 by
+ * Digital Equipment Corporation, Maynard, Massachusetts,
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ ******************************************************************/
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+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.
+
+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
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+
+ /*
+ * Aug '86: Susan Angebranndt -- original code
+ * July '87: Adam de Boor -- substantially modified and commented
+ * Summer '89: Joel McCormack -- so fast you wouldn't believe it possible.
+ * In particular, much improved code for window mapping and
+ * circulating.
+ * Bob Scheifler -- avoid miComputeClips for unmapped windows,
+ * valdata changes
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "regionstr.h"
+#include "mivalidate.h"
+
+#include "globals.h"
+
+/*
+ * Compute the visibility of a shaped window
+ */
+int
+miShapedWindowIn (RegionPtr universe, RegionPtr bounding,
+ BoxPtr rect, int x, int y)
+{
+ BoxRec box;
+ BoxPtr boundBox;
+ int nbox;
+ Bool someIn, someOut;
+ int t, x1, y1, x2, y2;
+
+ nbox = RegionNumRects (bounding);
+ boundBox = RegionRects (bounding);
+ someIn = someOut = FALSE;
+ x1 = rect->x1;
+ y1 = rect->y1;
+ x2 = rect->x2;
+ y2 = rect->y2;
+ while (nbox--)
+ {
+ if ((t = boundBox->x1 + x) < x1)
+ t = x1;
+ box.x1 = t;
+ if ((t = boundBox->y1 + y) < y1)
+ t = y1;
+ box.y1 = t;
+ if ((t = boundBox->x2 + x) > x2)
+ t = x2;
+ box.x2 = t;
+ if ((t = boundBox->y2 + y) > y2)
+ t = y2;
+ box.y2 = t;
+ if (box.x1 > box.x2)
+ box.x2 = box.x1;
+ if (box.y1 > box.y2)
+ box.y2 = box.y1;
+ switch (RegionContainsRect(universe, &box))
+ {
+ case rgnIN:
+ if (someOut)
+ return rgnPART;
+ someIn = TRUE;
+ break;
+ case rgnOUT:
+ if (someIn)
+ return rgnPART;
+ someOut = TRUE;
+ break;
+ default:
+ return rgnPART;
+ }
+ boundBox++;
+ }
+ if (someIn)
+ return rgnIN;
+ return rgnOUT;
+}
+
+static GetRedirectBorderClipProcPtr miGetRedirectBorderClipProc;
+static SetRedirectBorderClipProcPtr miSetRedirectBorderClipProc;
+
+void
+miRegisterRedirectBorderClipProc (SetRedirectBorderClipProcPtr setBorderClip,
+ GetRedirectBorderClipProcPtr getBorderClip)
+{
+ miSetRedirectBorderClipProc = setBorderClip;
+ miGetRedirectBorderClipProc = getBorderClip;
+}
+
+/*
+ * Manual redirected windows are treated as transparent; they do not obscure
+ * siblings or parent windows
+ */
+
+#ifdef COMPOSITE
+#define TreatAsTransparent(w) ((w)->redirectDraw == RedirectDrawManual)
+#else
+#define TreatAsTransparent(w) FALSE
+#endif
+
+#define HasParentRelativeBorder(w) (!(w)->borderIsPixel && \
+ HasBorder(w) && \
+ (w)->backgroundState == ParentRelative)
+
+
+/*
+ *-----------------------------------------------------------------------
+ * miComputeClips --
+ * Recompute the clipList, borderClip, exposed and borderExposed
+ * regions for pParent and its children. Only viewable windows are
+ * taken into account.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * clipList, borderClip, exposed and borderExposed are altered.
+ * A VisibilityNotify event may be generated on the parent window.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miComputeClips (
+ WindowPtr pParent,
+ ScreenPtr pScreen,
+ RegionPtr universe,
+ VTKind kind,
+ RegionPtr exposed ) /* for intermediate calculations */
+{
+ int dx,
+ dy;
+ RegionRec childUniverse;
+ WindowPtr pChild;
+ int oldVis, newVis;
+ BoxRec borderSize;
+ RegionRec childUnion;
+ Bool overlap;
+ RegionPtr borderVisible;
+ Bool resized;
+ /*
+ * Figure out the new visibility of this window.
+ * The extent of the universe should be the same as the extent of
+ * the borderSize region. If the window is unobscured, this rectangle
+ * will be completely inside the universe (the universe will cover it
+ * completely). If the window is completely obscured, none of the
+ * universe will cover the rectangle.
+ */
+ borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent);
+ borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent);
+ dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent);
+ if (dx > 32767)
+ dx = 32767;
+ borderSize.x2 = dx;
+ dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent);
+ if (dy > 32767)
+ dy = 32767;
+ borderSize.y2 = dy;
+
+#ifdef COMPOSITE
+ /*
+ * In redirected drawing case, reset universe to borderSize
+ */
+ if (pParent->redirectDraw != RedirectDrawNone)
+ {
+ if (miSetRedirectBorderClipProc)
+ {
+ if (TreatAsTransparent (pParent))
+ RegionEmpty(universe);
+ (*miSetRedirectBorderClipProc) (pParent, universe);
+ }
+ RegionCopy(universe, &pParent->borderSize);
+ }
+#endif
+
+ oldVis = pParent->visibility;
+ switch (RegionContainsRect(universe, &borderSize))
+ {
+ case rgnIN:
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnPART:
+ newVis = VisibilityPartiallyObscured;
+ {
+ RegionPtr pBounding;
+
+ if ((pBounding = wBoundingShape (pParent)))
+ {
+ switch (miShapedWindowIn (universe, pBounding,
+ &borderSize,
+ pParent->drawable.x,
+ pParent->drawable.y))
+ {
+ case rgnIN:
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnOUT:
+ newVis = VisibilityFullyObscured;
+ break;
+ }
+ }
+ }
+ break;
+ default:
+ newVis = VisibilityFullyObscured;
+ break;
+ }
+ pParent->visibility = newVis;
+ if (oldVis != newVis &&
+ ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask))
+ SendVisibilityNotify(pParent);
+
+ dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x;
+ dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y;
+
+ /*
+ * avoid computations when dealing with simple operations
+ */
+
+ switch (kind) {
+ case VTMap:
+ case VTStack:
+ case VTUnmap:
+ break;
+ case VTMove:
+ if ((oldVis == newVis) &&
+ ((oldVis == VisibilityFullyObscured) ||
+ (oldVis == VisibilityUnobscured)))
+ {
+ pChild = pParent;
+ while (1)
+ {
+ if (pChild->viewable)
+ {
+ if (pChild->visibility != VisibilityFullyObscured)
+ {
+ RegionTranslate(&pChild->borderClip,
+ dx, dy);
+ RegionTranslate(&pChild->clipList,
+ dx, dy);
+ pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pChild, dx, dy);
+
+ }
+ if (pChild->valdata)
+ {
+ RegionNull(&pChild->valdata->after.borderExposed);
+ if (HasParentRelativeBorder(pChild))
+ {
+ RegionSubtract(&pChild->valdata->after.borderExposed,
+ &pChild->borderClip,
+ &pChild->winSize);
+ }
+ RegionNull(&pChild->valdata->after.exposed);
+ }
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pParent))
+ pChild = pChild->parent;
+ if (pChild == pParent)
+ break;
+ pChild = pChild->nextSib;
+ }
+ return;
+ }
+ /* fall through */
+ default:
+ /*
+ * To calculate exposures correctly, we have to translate the old
+ * borderClip and clipList regions to the window's new location so there
+ * is a correspondence between pieces of the new and old clipping regions.
+ */
+ if (dx || dy)
+ {
+ /*
+ * We translate the old clipList because that will be exposed or copied
+ * if gravity is right.
+ */
+ RegionTranslate(&pParent->borderClip, dx, dy);
+ RegionTranslate(&pParent->clipList, dx, dy);
+ }
+ break;
+ case VTBroken:
+ RegionEmpty(&pParent->borderClip);
+ RegionEmpty(&pParent->clipList);
+ break;
+ }
+
+ borderVisible = pParent->valdata->before.borderVisible;
+ resized = pParent->valdata->before.resized;
+ RegionNull(&pParent->valdata->after.borderExposed);
+ RegionNull(&pParent->valdata->after.exposed);
+
+ /*
+ * Since the borderClip must not be clipped by the children, we do
+ * the border exposure first...
+ *
+ * 'universe' is the window's borderClip. To figure the exposures, remove
+ * the area that used to be exposed from the new.
+ * This leaves a region of pieces that weren't exposed before.
+ */
+
+ if (HasBorder (pParent))
+ {
+ if (borderVisible)
+ {
+ /*
+ * when the border changes shape, the old visible portions
+ * of the border will be saved by DIX in borderVisible --
+ * use that region and destroy it
+ */
+ RegionSubtract(exposed, universe, borderVisible);
+ RegionDestroy(borderVisible);
+ }
+ else
+ {
+ RegionSubtract(exposed, universe, &pParent->borderClip);
+ }
+ if (HasParentRelativeBorder(pParent) && (dx || dy))
+ RegionSubtract(&pParent->valdata->after.borderExposed,
+ universe,
+ &pParent->winSize);
+ else
+ RegionSubtract(&pParent->valdata->after.borderExposed,
+ exposed, &pParent->winSize);
+
+ RegionCopy(&pParent->borderClip, universe);
+
+ /*
+ * To get the right clipList for the parent, and to make doubly sure
+ * that no child overlaps the parent's border, we remove the parent's
+ * border from the universe before proceeding.
+ */
+
+ RegionIntersect(universe, universe, &pParent->winSize);
+ }
+ else
+ RegionCopy(&pParent->borderClip, universe);
+
+ if ((pChild = pParent->firstChild) && pParent->mapped)
+ {
+ RegionNull(&childUniverse);
+ RegionNull(&childUnion);
+ if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
+ ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
+ (pChild->drawable.x < pParent->lastChild->drawable.x)))
+ {
+ for (; pChild; pChild = pChild->nextSib)
+ {
+ if (pChild->viewable && !TreatAsTransparent(pChild))
+ RegionAppend(&childUnion, &pChild->borderSize);
+ }
+ }
+ else
+ {
+ for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib)
+ {
+ if (pChild->viewable && !TreatAsTransparent(pChild))
+ RegionAppend(&childUnion, &pChild->borderSize);
+ }
+ }
+ RegionValidate(&childUnion, &overlap);
+
+ for (pChild = pParent->firstChild;
+ pChild;
+ pChild = pChild->nextSib)
+ {
+ if (pChild->viewable) {
+ /*
+ * If the child is viewable, we want to remove its extents
+ * from the current universe, but we only re-clip it if
+ * it's been marked.
+ */
+ if (pChild->valdata) {
+ /*
+ * Figure out the new universe from the child's
+ * perspective and recurse.
+ */
+ RegionIntersect(&childUniverse,
+ universe,
+ &pChild->borderSize);
+ miComputeClips (pChild, pScreen, &childUniverse, kind,
+ exposed);
+ }
+ /*
+ * Once the child has been processed, we remove its extents
+ * from the current universe, thus denying its space to any
+ * other sibling.
+ */
+ if (overlap && !TreatAsTransparent (pChild))
+ RegionSubtract(universe, universe,
+ &pChild->borderSize);
+ }
+ }
+ if (!overlap)
+ RegionSubtract(universe, universe, &childUnion);
+ RegionUninit(&childUnion);
+ RegionUninit(&childUniverse);
+ } /* if any children */
+
+ /*
+ * 'universe' now contains the new clipList for the parent window.
+ *
+ * To figure the exposure of the window we subtract the old clip from the
+ * new, just as for the border.
+ */
+
+ if (oldVis == VisibilityFullyObscured ||
+ oldVis == VisibilityNotViewable)
+ {
+ RegionCopy(&pParent->valdata->after.exposed, universe);
+ }
+ else if (newVis != VisibilityFullyObscured &&
+ newVis != VisibilityNotViewable)
+ {
+ RegionSubtract(&pParent->valdata->after.exposed,
+ universe, &pParent->clipList);
+ }
+
+ /* HACK ALERT - copying contents of regions, instead of regions */
+ {
+ RegionRec tmp;
+
+ tmp = pParent->clipList;
+ pParent->clipList = *universe;
+ *universe = tmp;
+ }
+
+#ifdef NOTDEF
+ RegionCopy(&pParent->clipList, universe);
+#endif
+
+ pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pParent, dx, dy);
+}
+
+static void
+miTreeObscured(
+ WindowPtr pParent )
+{
+ WindowPtr pChild;
+ int oldVis;
+
+ pChild = pParent;
+ while (1)
+ {
+ if (pChild->viewable)
+ {
+ oldVis = pChild->visibility;
+ if (oldVis != (pChild->visibility = VisibilityFullyObscured) &&
+ ((pChild->eventMask | wOtherEventMasks(pChild)) & VisibilityChangeMask))
+ SendVisibilityNotify(pChild);
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pParent))
+ pChild = pChild->parent;
+ if (pChild == pParent)
+ break;
+ pChild = pChild->nextSib;
+ }
+}
+
+/*
+ *-----------------------------------------------------------------------
+ * miValidateTree --
+ * Recomputes the clip list for pParent and all its inferiors.
+ *
+ * Results:
+ * Always returns 1.
+ *
+ * Side Effects:
+ * The clipList, borderClip, exposed, and borderExposed regions for
+ * each marked window are altered.
+ *
+ * Notes:
+ * This routine assumes that all affected windows have been marked
+ * (valdata created) and their winSize and borderSize regions
+ * adjusted to correspond to their new positions. The borderClip and
+ * clipList regions should not have been touched.
+ *
+ * The top-most level is treated differently from all lower levels
+ * because pParent is unchanged. For the top level, we merge the
+ * regions taken up by the marked children back into the clipList
+ * for pParent, thus forming a region from which the marked children
+ * can claim their areas. For lower levels, where the old clipList
+ * and borderClip are invalid, we can't do this and have to do the
+ * extra operations done in miComputeClips, but this is much faster
+ * e.g. when only one child has moved...
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+int
+miValidateTree (
+ WindowPtr pParent, /* Parent to validate */
+ WindowPtr pChild, /* First child of pParent that was
+ * affected */
+ VTKind kind /* What kind of configuration caused call */
+ )
+{
+ RegionRec totalClip; /* Total clipping region available to
+ * the marked children. pParent's clipList
+ * merged with the borderClips of all
+ * the marked children. */
+ RegionRec childClip; /* The new borderClip for the current
+ * child */
+ RegionRec childUnion; /* the space covered by borderSize for
+ * all marked children */
+ RegionRec exposed; /* For intermediate calculations */
+ ScreenPtr pScreen;
+ WindowPtr pWin;
+ Bool overlap;
+ int viewvals;
+ Bool forward;
+
+ pScreen = pParent->drawable.pScreen;
+ if (pChild == NullWindow)
+ pChild = pParent->firstChild;
+
+ RegionNull(&childClip);
+ RegionNull(&exposed);
+
+ /*
+ * compute the area of the parent window occupied
+ * by the marked children + the parent itself. This
+ * is the area which can be divied up among the marked
+ * children in their new configuration.
+ */
+ RegionNull(&totalClip);
+ viewvals = 0;
+ if (RegionBroken(&pParent->clipList) &&
+ !RegionBroken(&pParent->borderClip))
+ {
+ kind = VTBroken;
+ /*
+ * When rebuilding clip lists after out of memory,
+ * assume everything is busted.
+ */
+ forward = TRUE;
+ RegionCopy(&totalClip, &pParent->borderClip);
+ RegionIntersect(&totalClip, &totalClip, &pParent->winSize);
+
+ for (pWin = pParent->firstChild; pWin != pChild; pWin = pWin->nextSib)
+ {
+ if (pWin->viewable && !TreatAsTransparent (pWin))
+ RegionSubtract(&totalClip, &totalClip, &pWin->borderSize);
+ }
+ for (pWin = pChild; pWin; pWin = pWin->nextSib)
+ if (pWin->valdata && pWin->viewable)
+ viewvals++;
+
+ RegionEmpty(&pParent->clipList);
+ }
+ else
+ {
+ if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
+ ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
+ (pChild->drawable.x < pParent->lastChild->drawable.x)))
+ {
+ forward = TRUE;
+ for (pWin = pChild; pWin; pWin = pWin->nextSib)
+ {
+ if (pWin->valdata)
+ {
+ RegionPtr pBorderClip = &pWin->borderClip;
+#ifdef COMPOSITE
+ if (pWin->redirectDraw != RedirectDrawNone && miGetRedirectBorderClipProc)
+ pBorderClip = (*miGetRedirectBorderClipProc)(pWin);
+#endif
+ RegionAppend(&totalClip, pBorderClip );
+ if (pWin->viewable)
+ viewvals++;
+ }
+ }
+ }
+ else
+ {
+ forward = FALSE;
+ pWin = pParent->lastChild;
+ while (1)
+ {
+ if (pWin->valdata)
+ {
+ RegionPtr pBorderClip = &pWin->borderClip;
+#ifdef COMPOSITE
+ if (pWin->redirectDraw != RedirectDrawNone && miGetRedirectBorderClipProc)
+ pBorderClip = (*miGetRedirectBorderClipProc)(pWin);
+#endif
+ RegionAppend(&totalClip, pBorderClip );
+ if (pWin->viewable)
+ viewvals++;
+ }
+ if (pWin == pChild)
+ break;
+ pWin = pWin->prevSib;
+ }
+ }
+ RegionValidate(&totalClip, &overlap);
+ }
+
+ /*
+ * Now go through the children of the root and figure their new
+ * borderClips from the totalClip, passing that off to miComputeClips
+ * to handle recursively. Once that's done, we remove the child
+ * from the totalClip to clip any siblings below it.
+ */
+
+ overlap = TRUE;
+ if (kind != VTStack)
+ {
+ RegionUnion(&totalClip, &totalClip, &pParent->clipList);
+ if (viewvals > 1)
+ {
+ /*
+ * precompute childUnion to discover whether any of them
+ * overlap. This seems redundant, but performance studies
+ * have demonstrated that the cost of this loop is
+ * lower than the cost of multiple Subtracts in the
+ * loop below.
+ */
+ RegionNull(&childUnion);
+ if (forward)
+ {
+ for (pWin = pChild; pWin; pWin = pWin->nextSib)
+ if (pWin->valdata && pWin->viewable && !TreatAsTransparent (pWin))
+ RegionAppend(&childUnion,
+ &pWin->borderSize);
+ }
+ else
+ {
+ pWin = pParent->lastChild;
+ while (1)
+ {
+ if (pWin->valdata && pWin->viewable && !TreatAsTransparent (pWin))
+ RegionAppend(&childUnion,
+ &pWin->borderSize);
+ if (pWin == pChild)
+ break;
+ pWin = pWin->prevSib;
+ }
+ }
+ RegionValidate(&childUnion, &overlap);
+ if (overlap)
+ RegionUninit(&childUnion);
+ }
+ }
+
+ for (pWin = pChild;
+ pWin != NullWindow;
+ pWin = pWin->nextSib)
+ {
+ if (pWin->viewable) {
+ if (pWin->valdata) {
+ RegionIntersect(&childClip,
+ &totalClip,
+ &pWin->borderSize);
+ miComputeClips (pWin, pScreen, &childClip, kind, &exposed);
+ if (overlap && !TreatAsTransparent (pWin))
+ {
+ RegionSubtract(&totalClip,
+ &totalClip,
+ &pWin->borderSize);
+ }
+ } else if (pWin->visibility == VisibilityNotViewable) {
+ miTreeObscured(pWin);
+ }
+ } else {
+ if (pWin->valdata) {
+ RegionEmpty(&pWin->clipList);
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pWin, 0, 0);
+ RegionEmpty(&pWin->borderClip);
+ pWin->valdata = NULL;
+ }
+ }
+ }
+
+ RegionUninit(&childClip);
+ if (!overlap)
+ {
+ RegionSubtract(&totalClip, &totalClip, &childUnion);
+ RegionUninit(&childUnion);
+ }
+
+ RegionNull(&pParent->valdata->after.exposed);
+ RegionNull(&pParent->valdata->after.borderExposed);
+
+ /*
+ * each case below is responsible for updating the
+ * clipList and serial number for the parent window
+ */
+
+ switch (kind) {
+ case VTStack:
+ break;
+ default:
+ /*
+ * totalClip contains the new clipList for the parent. Figure out
+ * exposures and obscures as per miComputeClips and reset the parent's
+ * clipList.
+ */
+ RegionSubtract(&pParent->valdata->after.exposed,
+ &totalClip, &pParent->clipList);
+ /* fall through */
+ case VTMap:
+ RegionCopy(&pParent->clipList, &totalClip);
+ pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ break;
+ }
+
+ RegionUninit(&totalClip);
+ RegionUninit(&exposed);
+ if (pScreen->ClipNotify)
+ (*pScreen->ClipNotify) (pParent, 0, 0);
+ return 1;
+}
diff --git a/xorg-server/mi/miwideline.c b/xorg-server/mi/miwideline.c index 18b82cdcb..869142382 100644 --- a/xorg-server/mi/miwideline.c +++ b/xorg-server/mi/miwideline.c @@ -721,7 +721,7 @@ miLineArcI ( *--bwids = slw;
}
}
- return (pGC->lineWidth);
+ return pGC->lineWidth;
}
#define CLIPSTEPEDGE(edgey,edge,edgeleft) \
@@ -915,7 +915,7 @@ miLineArcD ( *wids++ = xcr - xcl + 1;
}
}
- return (pts - points);
+ return pts - points;
}
static int
diff --git a/xorg-server/mi/miwindow.c b/xorg-server/mi/miwindow.c index 479085787..6c1b59e23 100644 --- a/xorg-server/mi/miwindow.c +++ b/xorg-server/mi/miwindow.c @@ -50,6 +50,7 @@ SOFTWARE. #endif
#include <X11/X.h>
+#include <X11/extensions/shape.h>
#include "regionstr.h"
#include "region.h"
#include "mi.h"
@@ -66,7 +67,6 @@ miClearToBackground(WindowPtr pWin, BoxRec box;
RegionRec reg;
RegionPtr pBSReg = NullRegion;
- ScreenPtr pScreen;
BoxPtr extents;
int x1, y1, x2, y2;
@@ -110,17 +110,16 @@ miClearToBackground(WindowPtr pWin, box.y1 = y1;
box.y2 = y2;
- pScreen = pWin->drawable.pScreen;
- REGION_INIT(pScreen, ®, &box, 1);
+ RegionInit(®, &box, 1);
- REGION_INTERSECT(pScreen, ®, ®, &pWin->clipList);
+ RegionIntersect(®, ®, &pWin->clipList);
if (generateExposures)
- (*pScreen->WindowExposures)(pWin, ®, pBSReg);
+ (*pWin->drawable.pScreen->WindowExposures)(pWin, ®, pBSReg);
else if (pWin->backgroundState != None)
miPaintWindow(pWin, ®, PW_BACKGROUND);
- REGION_UNINIT(pScreen, ®);
+ RegionUninit(®);
if (pBSReg)
- REGION_DESTROY(pScreen, pBSReg);
+ RegionDestroy(pBSReg);
}
void
@@ -145,9 +144,6 @@ miMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst, WindowPtr *ppLayerWin) WindowPtr pChild, pLast;
Bool anyMarked = FALSE;
MarkWindowProcPtr MarkWindow = pWin->drawable.pScreen->MarkWindow;
- ScreenPtr pScreen;
-
- pScreen = pWin->drawable.pScreen;
/* single layered systems are easy */
if (ppLayerWin) *ppLayerWin = pWin;
@@ -163,9 +159,9 @@ miMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst, WindowPtr *ppLayerWin) {
if (pChild->viewable)
{
- if (REGION_BROKEN (pScreen, &pChild->winSize))
+ if (RegionBroken(&pChild->winSize))
SetWinSize (pChild);
- if (REGION_BROKEN (pScreen, &pChild->borderSize))
+ if (RegionBroken(&pChild->borderSize))
SetBorderSize (pChild);
(* MarkWindow)(pChild);
if (pChild->firstChild)
@@ -185,17 +181,17 @@ miMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst, WindowPtr *ppLayerWin) }
if ( (pChild = pFirst) )
{
- box = REGION_EXTENTS(pChild->drawable.pScreen, &pWin->borderSize);
+ box = RegionExtents(&pWin->borderSize);
pLast = pChild->parent->lastChild;
while (1)
{
if (pChild->viewable)
{
- if (REGION_BROKEN (pScreen, &pChild->winSize))
+ if (RegionBroken(&pChild->winSize))
SetWinSize (pChild);
- if (REGION_BROKEN (pScreen, &pChild->borderSize))
+ if (RegionBroken(&pChild->borderSize))
SetBorderSize (pChild);
- if (RECT_IN_REGION(pScreen, &pChild->borderSize, box))
+ if (RegionContainsRect(&pChild->borderSize, box))
{
(* MarkWindow)(pChild);
anyMarked = TRUE;
@@ -229,22 +225,19 @@ miHandleValidateExposures(WindowPtr pWin) {
WindowPtr pChild;
ValidatePtr val;
- ScreenPtr pScreen;
WindowExposuresProcPtr WindowExposures;
- pScreen = pWin->drawable.pScreen;
-
pChild = pWin;
WindowExposures = pChild->drawable.pScreen->WindowExposures;
while (1)
{
if ( (val = pChild->valdata) )
{
- if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed))
+ if (RegionNotEmpty(&val->after.borderExposed))
miPaintWindow(pChild, &val->after.borderExposed, PW_BORDER);
- REGION_UNINIT(pScreen, &val->after.borderExposed);
+ RegionUninit(&val->after.borderExposed);
(*WindowExposures)(pChild, &val->after.exposed, NullRegion);
- REGION_UNINIT(pScreen, &val->after.exposed);
+ RegionUninit(&val->after.exposed);
free(val);
pChild->valdata = NULL;
if (pChild->firstChild)
@@ -284,8 +277,8 @@ miMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pNextSib, VTKind kind) oldpt.y = pWin->drawable.y;
if (WasViewable)
{
- oldRegion = REGION_CREATE(pScreen, NullBox, 1);
- REGION_COPY(pScreen, oldRegion, &pWin->borderClip);
+ oldRegion = RegionCreate(NullBox, 1);
+ RegionCopy(oldRegion, &pWin->borderClip);
anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
}
pWin->origin.x = x + (int)bw;
@@ -316,7 +309,7 @@ miMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pNextSib, VTKind kind) {
(*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, kind);
(* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, oldRegion);
- REGION_DESTROY(pScreen, oldRegion);
+ RegionDestroy(oldRegion);
/* XXX need to retile border if ParentRelative origin */
(*pScreen->HandleExposures)(pLayerWin->parent);
}
@@ -338,7 +331,6 @@ miRecomputeExposures ( WindowPtr pWin,
pointer value) /* must conform to VisitWindowProcPtr */
{
- ScreenPtr pScreen;
RegionPtr pValid = (RegionPtr)value;
if (pWin->valdata)
@@ -352,18 +344,17 @@ miRecomputeExposures ( if (pWin->redirectDraw != RedirectDrawNone)
return WT_DONTWALKCHILDREN;
#endif
- pScreen = pWin->drawable.pScreen;
/*
* compute exposed regions of this window
*/
- REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+ RegionSubtract(&pWin->valdata->after.exposed,
&pWin->clipList, pValid);
/*
* compute exposed regions of the border
*/
- REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+ RegionSubtract(&pWin->valdata->after.borderExposed,
&pWin->borderClip, &pWin->winSize);
- REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+ RegionSubtract(&pWin->valdata->after.borderExposed,
&pWin->valdata->after.borderExposed, pValid);
return WT_WALKCHILDREN;
}
@@ -415,8 +406,8 @@ miSlideAndSizeWindow(WindowPtr pWin, /*
* save the visible region of the window
*/
- oldRegion = REGION_CREATE(pScreen, NullBox, 1);
- REGION_COPY(pScreen, oldRegion, &pWin->winSize);
+ oldRegion = RegionCreate(NullBox, 1);
+ RegionCopy(oldRegion, &pWin->winSize);
/*
* categorize child windows into regions to be moved
@@ -429,8 +420,8 @@ miSlideAndSizeWindow(WindowPtr pWin, if (g != UnmapGravity)
{
if (!gravitate[g])
- gravitate[g] = REGION_CREATE(pScreen, NullBox, 1);
- REGION_UNION(pScreen, gravitate[g],
+ gravitate[g] = RegionCreate(NullBox, 1);
+ RegionUnion(gravitate[g],
gravitate[g], &pChild->borderClip);
}
else
@@ -445,8 +436,8 @@ miSlideAndSizeWindow(WindowPtr pWin, oldWinClip = NULL;
if (pWin->bitGravity != ForgetGravity)
{
- oldWinClip = REGION_CREATE(pScreen, NullBox, 1);
- REGION_COPY(pScreen, oldWinClip, &pWin->clipList);
+ oldWinClip = RegionCreate(NullBox, 1);
+ RegionCopy(oldWinClip, &pWin->clipList);
}
/*
* if the window is changing size, borderExposed
@@ -461,16 +452,16 @@ miSlideAndSizeWindow(WindowPtr pWin, if ((pWin->drawable.height != h || pWin->drawable.width != w) &&
HasBorder (pWin))
{
- borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+ borderVisible = RegionCreate(NullBox, 1);
/* for tiled borders, we punt and draw the whole thing */
if (pWin->borderIsPixel || !moved)
{
if (shrunk || moved)
- REGION_SUBTRACT(pScreen, borderVisible,
+ RegionSubtract(borderVisible,
&pWin->borderClip,
&pWin->winSize);
else
- REGION_COPY(pScreen, borderVisible,
+ RegionCopy(borderVisible,
&pWin->borderClip);
}
}
@@ -497,7 +488,7 @@ miSlideAndSizeWindow(WindowPtr pWin, if (WasViewable)
{
- pRegion = REGION_CREATE(pScreen, NullBox, 1);
+ pRegion = RegionCreate(NullBox, 1);
if (pLayerWin == pWin)
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange,
@@ -519,7 +510,7 @@ miSlideAndSizeWindow(WindowPtr pWin, * the entire window is trashed unless bitGravity
* recovers portions of it
*/
- REGION_COPY(pScreen, &pWin->valdata->after.exposed, &pWin->clipList);
+ RegionCopy(&pWin->valdata->after.exposed, &pWin->clipList);
}
GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
@@ -548,16 +539,16 @@ miSlideAndSizeWindow(WindowPtr pWin, dy = (oldy - ny) - offy;
if (dx || dy)
{
- REGION_TRANSLATE(pScreen, &pWin->winSize, dx, dy);
+ RegionTranslate(&pWin->winSize, dx, dy);
offx += dx;
offy += dy;
}
- REGION_INTERSECT(pScreen, gravitate[g], gravitate[g],
+ RegionIntersect(gravitate[g], gravitate[g],
&pWin->winSize);
}
/* get winSize back where it belongs */
if (offx || offy)
- REGION_TRANSLATE(pScreen, &pWin->winSize, -offx, -offy);
+ RegionTranslate(&pWin->winSize, -offx, -offy);
}
/*
* add screen bits to the appropriate bucket
@@ -568,9 +559,9 @@ miSlideAndSizeWindow(WindowPtr pWin, /*
* clip to new clipList
*/
- REGION_COPY(pScreen, pRegion, oldWinClip);
- REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy);
- REGION_INTERSECT(pScreen, oldWinClip, pRegion, &pWin->clipList);
+ RegionCopy(pRegion, oldWinClip);
+ RegionTranslate(pRegion, nx - oldx, ny - oldy);
+ RegionIntersect(oldWinClip, pRegion, &pWin->clipList);
/*
* don't step on any gravity bits which will be copied after this
* region. Note -- this assumes that the regions will be copied
@@ -579,17 +570,17 @@ miSlideAndSizeWindow(WindowPtr pWin, for (g = pWin->bitGravity + 1; g <= StaticGravity; g++)
{
if (gravitate[g])
- REGION_SUBTRACT(pScreen, oldWinClip, oldWinClip,
+ RegionSubtract(oldWinClip, oldWinClip,
gravitate[g]);
}
- REGION_TRANSLATE(pScreen, oldWinClip, oldx - nx, oldy - ny);
+ RegionTranslate(oldWinClip, oldx - nx, oldy - ny);
g = pWin->bitGravity;
if (!gravitate[g])
gravitate[g] = oldWinClip;
else
{
- REGION_UNION(pScreen, gravitate[g], gravitate[g], oldWinClip);
- REGION_DESTROY(pScreen, oldWinClip);
+ RegionUnion(gravitate[g], gravitate[g], oldWinClip);
+ RegionDestroy(oldWinClip);
}
}
@@ -613,14 +604,14 @@ miSlideAndSizeWindow(WindowPtr pWin, /* only copy the remaining useful bits */
- REGION_INTERSECT(pScreen, gravitate[g], gravitate[g], oldRegion);
+ RegionIntersect(gravitate[g], gravitate[g], oldRegion);
/* clip to not overwrite already copied areas */
if (destClip) {
- REGION_TRANSLATE(pScreen, destClip, oldpt.x - x, oldpt.y - y);
- REGION_SUBTRACT(pScreen, gravitate[g], gravitate[g], destClip);
- REGION_TRANSLATE(pScreen, destClip, x - oldpt.x, y - oldpt.y);
+ RegionTranslate(destClip, oldpt.x - x, oldpt.y - y);
+ RegionSubtract(gravitate[g], gravitate[g], destClip);
+ RegionTranslate(destClip, x - oldpt.x, y - oldpt.y);
}
/* and move those bits */
@@ -636,7 +627,7 @@ miSlideAndSizeWindow(WindowPtr pWin, /* remove any overwritten bits from the remaining useful bits */
- REGION_SUBTRACT(pScreen, oldRegion, oldRegion, gravitate[g]);
+ RegionSubtract(oldRegion, oldRegion, gravitate[g]);
/*
* recompute exposed regions of child windows
@@ -646,7 +637,7 @@ miSlideAndSizeWindow(WindowPtr pWin, {
if (pChild->winGravity != g)
continue;
- REGION_INTERSECT(pScreen, pRegion,
+ RegionIntersect(pRegion,
&pChild->borderClip, gravitate[g]);
TraverseTree (pChild, miRecomputeExposures, (pointer)pRegion);
}
@@ -657,21 +648,21 @@ miSlideAndSizeWindow(WindowPtr pWin, */
if (g == pWin->bitGravity)
- REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+ RegionSubtract(&pWin->valdata->after.exposed,
&pWin->valdata->after.exposed, gravitate[g]);
if (!destClip)
destClip = gravitate[g];
else
{
- REGION_UNION(pScreen, destClip, destClip, gravitate[g]);
- REGION_DESTROY(pScreen, gravitate[g]);
+ RegionUnion(destClip, destClip, gravitate[g]);
+ RegionDestroy(gravitate[g]);
}
}
- REGION_DESTROY(pScreen, oldRegion);
- REGION_DESTROY(pScreen, pRegion);
+ RegionDestroy(oldRegion);
+ RegionDestroy(pRegion);
if (destClip)
- REGION_DESTROY(pScreen, destClip);
+ RegionDestroy(destClip);
if (anyMarked)
(*pScreen->HandleExposures)(pLayerWin->parent);
if (anyMarked && pScreen->PostValidateTree)
@@ -696,56 +687,59 @@ miGetLayerWindow(WindowPtr pWin) */
void
-miSetShape(WindowPtr pWin)
+miSetShape(WindowPtr pWin, int kind)
{
- Bool WasViewable = (Bool)(pWin->viewable);
- ScreenPtr pScreen = pWin->drawable.pScreen;
- Bool anyMarked = FALSE;
+ Bool WasViewable = (Bool)(pWin->viewable);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ Bool anyMarked = FALSE;
WindowPtr pLayerWin;
- if (WasViewable)
- {
- anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
- &pLayerWin);
- if (pWin->valdata)
- {
- if (HasBorder (pWin))
- {
- RegionPtr borderVisible;
-
- borderVisible = REGION_CREATE(pScreen, NullBox, 1);
- REGION_SUBTRACT(pScreen, borderVisible,
- &pWin->borderClip, &pWin->winSize);
- pWin->valdata->before.borderVisible = borderVisible;
- }
- pWin->valdata->before.resized = TRUE;
- }
- }
-
- SetWinSize (pWin);
- SetBorderSize (pWin);
-
- ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
-
- if (WasViewable)
- {
- anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
- NULL);
-
-
- if (anyMarked)
- (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, VTOther);
- }
-
- if (WasViewable)
- {
- if (anyMarked)
- (*pScreen->HandleExposures)(pLayerWin->parent);
- if (anyMarked && pScreen->PostValidateTree)
- (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, VTOther);
+ if (kind != ShapeInput) {
+ if (WasViewable)
+ {
+ anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+ &pLayerWin);
+ if (pWin->valdata)
+ {
+ if (HasBorder (pWin))
+ {
+ RegionPtr borderVisible;
+
+ borderVisible = RegionCreate(NullBox, 1);
+ RegionSubtract(borderVisible,
+ &pWin->borderClip, &pWin->winSize);
+ pWin->valdata->before.borderVisible = borderVisible;
+ }
+ pWin->valdata->before.resized = TRUE;
+ }
+ }
+
+ SetWinSize (pWin);
+ SetBorderSize (pWin);
+
+ ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
+
+ if (WasViewable)
+ {
+ anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+ NULL);
+
+ if (anyMarked)
+ (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow,
+ VTOther);
+ }
+
+ if (WasViewable)
+ {
+ if (anyMarked)
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+ if (anyMarked && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow,
+ VTOther);
+ }
}
if (pWin->realized)
- WindowsRestructured ();
+ WindowsRestructured ();
CheckCursorConfinement(pWin);
}
@@ -785,8 +779,8 @@ miChangeBorderWidth(WindowPtr pWin, unsigned int width) if (pWin->valdata && HadBorder)
{
RegionPtr borderVisible;
- borderVisible = REGION_CREATE(pScreen, NULL, 1);
- REGION_SUBTRACT(pScreen, borderVisible,
+ borderVisible = RegionCreate(NULL, 1);
+ RegionSubtract(borderVisible,
&pWin->borderClip, &pWin->winSize);
pWin->valdata->before.borderVisible = borderVisible;
}
@@ -810,25 +804,22 @@ miMarkUnrealizedWindow(WindowPtr pChild, WindowPtr pWin, Bool fromConfigure) {
if ((pChild != pWin) || fromConfigure)
{
- REGION_EMPTY(pChild->drawable.pScreen, &pChild->clipList);
+ RegionEmpty(&pChild->clipList);
if (pChild->drawable.pScreen->ClipNotify)
(* pChild->drawable.pScreen->ClipNotify)(pChild, 0, 0);
- REGION_EMPTY(pChild->drawable.pScreen, &pChild->borderClip);
+ RegionEmpty(&pChild->borderClip);
}
}
void
miSegregateChildren(WindowPtr pWin, RegionPtr pReg, int depth)
{
- ScreenPtr pScreen;
WindowPtr pChild;
- pScreen = pWin->drawable.pScreen;
-
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
{
if (pChild->drawable.depth == depth)
- REGION_UNION(pScreen, pReg, pReg, &pChild->borderClip);
+ RegionUnion(pReg, pReg, &pChild->borderClip);
if (pChild->firstChild)
miSegregateChildren(pChild, pReg, depth);
diff --git a/xorg-server/miext/cw/cw.c b/xorg-server/miext/cw/cw.c index 72a90c699..e4b264771 100644 --- a/xorg-server/miext/cw/cw.c +++ b/xorg-server/miext/cw/cw.c @@ -43,14 +43,11 @@ #define CW_ASSERT(x) do {} while (0)
#endif
-static int cwGCKeyIndex;
-DevPrivateKey cwGCKey = &cwGCKeyIndex;
-static int cwScreenKeyIndex;
-DevPrivateKey cwScreenKey = &cwScreenKeyIndex;
-static int cwWindowKeyIndex;
-DevPrivateKey cwWindowKey = &cwWindowKeyIndex;
-static int cwPictureKeyIndex;
-DevPrivateKey cwPictureKey = &cwPictureKeyIndex;
+DevPrivateKeyRec cwGCKeyRec;
+DevPrivateKeyRec cwScreenKeyRec;
+DevPrivateKeyRec cwWindowKeyRec;
+DevPrivateKeyRec cwPictureKeyRec;
+
extern GCOps cwGCOps;
static Bool
@@ -191,8 +188,8 @@ cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable) ChangeGCVal vals[2];
RegionPtr pCompositeClip;
- pCompositeClip = REGION_CREATE (pScreen, NULL, 0);
- REGION_COPY (pScreen, pCompositeClip, pGC->pCompositeClip);
+ pCompositeClip = RegionCreate(NULL, 0);
+ RegionCopy(pCompositeClip, pGC->pCompositeClip);
/* Either the drawable has changed, or the clip list in the drawable has
* changed. Copy the new clip list over and set the new translated
@@ -328,7 +325,7 @@ cwCreateGC(GCPtr pGC) ScreenPtr pScreen = pGC->pScreen;
Bool ret;
- bzero(pPriv, sizeof(cwGCRec));
+ memset(pPriv, 0, sizeof(cwGCRec));
SCREEN_PROLOGUE(pScreen, CreateGC);
if ( (ret = (*pScreen->CreateGC)(pGC)) )
@@ -403,7 +400,7 @@ cwCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
- pExtents = REGION_EXTENTS(pScreen, prgnSrc);
+ pExtents = RegionExtents(prgnSrc);
pBackingPixmap = (PixmapPtr) cwGetBackingDrawable((DrawablePtr)pWin,
&x_off, &y_off);
@@ -416,15 +413,15 @@ cwCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) dst_y = src_y - dy;
/* Translate region (as required by API) */
- REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
+ RegionTranslate(prgnSrc, -dx, -dy);
pGC = GetScratchGC(pBackingPixmap->drawable.depth, pScreen);
/*
* Copy region to GC as clip, aligning as dest clip
*/
- pClip = REGION_CREATE (pScreen, NULL, 0);
- REGION_INTERSECT(pScreen, pClip, &pWin->borderClip, prgnSrc);
- REGION_TRANSLATE(pScreen, pClip,
+ pClip = RegionCreate(NULL, 0);
+ RegionIntersect(pClip, &pWin->borderClip, prgnSrc);
+ RegionTranslate(pClip,
-pBackingPixmap->screen_x,
-pBackingPixmap->screen_y);
@@ -477,7 +474,16 @@ miInitializeCompositeWrapper(ScreenPtr pScreen) cwScreenPtr pScreenPriv;
Bool has_render = GetPictureScreenIfSet(pScreen) != NULL;
- if (!dixRequestPrivate(cwGCKey, sizeof(cwGCRec)))
+ if (!dixRegisterPrivateKey(&cwScreenKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
+ if (!dixRegisterPrivateKey(&cwGCKeyRec, PRIVATE_GC, sizeof(cwGCRec)))
+ return;
+
+ if (!dixRegisterPrivateKey(&cwWindowKeyRec, PRIVATE_WINDOW, 0))
+ return;
+
+ if (!dixRegisterPrivateKey(&cwPictureKeyRec, PRIVATE_PICTURE, 0))
return;
pScreenPriv = malloc(sizeof(cwScreenRec));
diff --git a/xorg-server/miext/cw/cw.h b/xorg-server/miext/cw/cw.h index 79051dfa2..555111c67 100644 --- a/xorg-server/miext/cw/cw.h +++ b/xorg-server/miext/cw/cw.h @@ -1,166 +1,171 @@ -/* - * Copyright © 2004 Eric Anholt - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Eric Anholt not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Eric Anholt makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "gcstruct.h" -#include "picturestr.h" -#include "privates.h" - -/* - * One of these structures is allocated per GC that gets used with a window with - * backing pixmap. - */ - -typedef struct { - GCPtr pBackingGC; /* Copy of the GC but with graphicsExposures - * set FALSE and the clientClip set to - * clip output to the valid regions of the - * backing pixmap. */ - unsigned long serialNumber; /* clientClip computed time */ - unsigned long stateChanges; /* changes in parent gc since last copy */ - GCOps *wrapOps; /* wrapped ops */ - GCFuncs *wrapFuncs; /* wrapped funcs */ -} cwGCRec, *cwGCPtr; - -extern _X_EXPORT DevPrivateKey cwGCKey; - -#define getCwGC(pGC) ((cwGCPtr)dixLookupPrivate(&(pGC)->devPrivates, cwGCKey)) -#define setCwGC(pGC,p) dixSetPrivate(&(pGC)->devPrivates, cwGCKey, p) - -/* - * One of these structures is allocated per Picture that gets used with a - * window with a backing pixmap - */ - -typedef struct { - PicturePtr pBackingPicture; - unsigned long serialNumber; - unsigned long stateChanges; -} cwPictureRec, *cwPicturePtr; - -#define getCwPicture(pPicture) (pPicture->pDrawable ? \ - (cwPicturePtr)dixLookupPrivate(&(pPicture)->devPrivates, cwPictureKey) : 0) -#define setCwPicture(pPicture,p) dixSetPrivate(&(pPicture)->devPrivates, cwPictureKey, p) - -extern _X_EXPORT DevPrivateKey cwPictureKey; -extern _X_EXPORT DevPrivateKey cwWindowKey; - -#define cwWindowPrivate(pWin) dixLookupPrivate(&(pWin)->devPrivates, cwWindowKey) -#define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow)) -#define setCwPixmap(pWindow,pPixmap) \ - dixSetPrivate(&(pWindow)->devPrivates, cwWindowKey, pPixmap) - -#define cwDrawableIsRedirWindow(pDraw) \ - ((pDraw)->type == DRAWABLE_WINDOW && \ - getCwPixmap((WindowPtr) (pDraw)) != NULL) - -typedef struct { - /* - * screen func wrappers - */ - CloseScreenProcPtr CloseScreen; - GetImageProcPtr GetImage; - GetSpansProcPtr GetSpans; - CreateGCProcPtr CreateGC; - - CopyWindowProcPtr CopyWindow; - - GetWindowPixmapProcPtr GetWindowPixmap; - SetWindowPixmapProcPtr SetWindowPixmap; - - DestroyPictureProcPtr DestroyPicture; - ChangePictureClipProcPtr ChangePictureClip; - DestroyPictureClipProcPtr DestroyPictureClip; - - ChangePictureProcPtr ChangePicture; - ValidatePictureProcPtr ValidatePicture; - - CompositeProcPtr Composite; - CompositeRectsProcPtr CompositeRects; - - TrapezoidsProcPtr Trapezoids; - TrianglesProcPtr Triangles; - TriStripProcPtr TriStrip; - TriFanProcPtr TriFan; - - RasterizeTrapezoidProcPtr RasterizeTrapezoid; -} cwScreenRec, *cwScreenPtr; - -extern _X_EXPORT DevPrivateKey cwScreenKey; - -#define getCwScreen(pScreen) ((cwScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, cwScreenKey)) -#define setCwScreen(pScreen,p) dixSetPrivate(&(pScreen)->devPrivates, cwScreenKey, p) - -#define CW_OFFSET_XYPOINTS(ppt, npt) do { \ - DDXPointPtr _ppt = (DDXPointPtr)(ppt); \ - int _i; \ - for (_i = 0; _i < npt; _i++) { \ - _ppt[_i].x += dst_off_x; \ - _ppt[_i].y += dst_off_y; \ - } \ -} while (0) - -#define CW_OFFSET_RECTS(prect, nrect) do { \ - int _i; \ - for (_i = 0; _i < nrect; _i++) { \ - (prect)[_i].x += dst_off_x; \ - (prect)[_i].y += dst_off_y; \ - } \ -} while (0) - -#define CW_OFFSET_ARCS(parc, narc) do { \ - int _i; \ - for (_i = 0; _i < narc; _i++) { \ - (parc)[_i].x += dst_off_x; \ - (parc)[_i].y += dst_off_y; \ - } \ -} while (0) - -#define CW_OFFSET_XY_DST(x, y) do { \ - (x) = (x) + dst_off_x; \ - (y) = (y) + dst_off_y; \ -} while (0) - -#define CW_OFFSET_XY_SRC(x, y) do { \ - (x) = (x) + src_off_x; \ - (y) = (y) + src_off_y; \ -} while (0) - -/* cw.c */ -extern _X_EXPORT DrawablePtr -cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off); - -/* cw_render.c */ - -extern _X_EXPORT void -cwInitializeRender (ScreenPtr pScreen); - -extern _X_EXPORT void -cwFiniRender (ScreenPtr pScreen); - -/* cw.c */ - -extern _X_EXPORT void -miInitializeCompositeWrapper(ScreenPtr pScreen); +/*
+ * Copyright © 2004 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "gcstruct.h"
+#include "picturestr.h"
+#include "privates.h"
+
+/*
+ * One of these structures is allocated per GC that gets used with a window with
+ * backing pixmap.
+ */
+
+typedef struct {
+ GCPtr pBackingGC; /* Copy of the GC but with graphicsExposures
+ * set FALSE and the clientClip set to
+ * clip output to the valid regions of the
+ * backing pixmap. */
+ unsigned long serialNumber; /* clientClip computed time */
+ unsigned long stateChanges; /* changes in parent gc since last copy */
+ GCOps *wrapOps; /* wrapped ops */
+ GCFuncs *wrapFuncs; /* wrapped funcs */
+} cwGCRec, *cwGCPtr;
+
+extern _X_EXPORT DevPrivateKeyRec cwGCKeyRec;
+#define cwGCKey (&cwGCKeyRec)
+
+#define getCwGC(pGC) ((cwGCPtr)dixLookupPrivate(&(pGC)->devPrivates, cwGCKey))
+#define setCwGC(pGC,p) dixSetPrivate(&(pGC)->devPrivates, cwGCKey, p)
+
+/*
+ * One of these structures is allocated per Picture that gets used with a
+ * window with a backing pixmap
+ */
+
+typedef struct {
+ PicturePtr pBackingPicture;
+ unsigned long serialNumber;
+ unsigned long stateChanges;
+} cwPictureRec, *cwPicturePtr;
+
+extern _X_EXPORT DevPrivateKeyRec cwPictureKeyRec;
+#define cwPictureKey (&cwPictureKeyRec)
+
+#define getCwPicture(pPicture) (pPicture->pDrawable ? \
+ (cwPicturePtr)dixLookupPrivate(&(pPicture)->devPrivates, cwPictureKey) : 0)
+#define setCwPicture(pPicture,p) dixSetPrivate(&(pPicture)->devPrivates, cwPictureKey, p)
+
+extern _X_EXPORT DevPrivateKeyRec cwWindowKeyRec;
+#define cwWindowKey (&cwWindowKeyRec)
+
+#define cwWindowPrivate(pWin) dixLookupPrivate(&(pWin)->devPrivates, cwWindowKey)
+#define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow))
+#define setCwPixmap(pWindow,pPixmap) \
+ dixSetPrivate(&(pWindow)->devPrivates, cwWindowKey, pPixmap)
+
+#define cwDrawableIsRedirWindow(pDraw) \
+ ((pDraw)->type == DRAWABLE_WINDOW && \
+ getCwPixmap((WindowPtr) (pDraw)) != NULL)
+
+typedef struct {
+ /*
+ * screen func wrappers
+ */
+ CloseScreenProcPtr CloseScreen;
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+ CreateGCProcPtr CreateGC;
+
+ CopyWindowProcPtr CopyWindow;
+
+ GetWindowPixmapProcPtr GetWindowPixmap;
+ SetWindowPixmapProcPtr SetWindowPixmap;
+
+ DestroyPictureProcPtr DestroyPicture;
+ ChangePictureClipProcPtr ChangePictureClip;
+ DestroyPictureClipProcPtr DestroyPictureClip;
+
+ ChangePictureProcPtr ChangePicture;
+ ValidatePictureProcPtr ValidatePicture;
+
+ CompositeProcPtr Composite;
+ CompositeRectsProcPtr CompositeRects;
+
+ TrapezoidsProcPtr Trapezoids;
+ TrianglesProcPtr Triangles;
+ TriStripProcPtr TriStrip;
+ TriFanProcPtr TriFan;
+
+ RasterizeTrapezoidProcPtr RasterizeTrapezoid;
+} cwScreenRec, *cwScreenPtr;
+
+extern _X_EXPORT DevPrivateKeyRec cwScreenKeyRec;
+#define cwScreenKey (&cwScreenKeyRec)
+
+#define getCwScreen(pScreen) ((cwScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, cwScreenKey))
+#define setCwScreen(pScreen,p) dixSetPrivate(&(pScreen)->devPrivates, cwScreenKey, p)
+
+#define CW_OFFSET_XYPOINTS(ppt, npt) do { \
+ DDXPointPtr _ppt = (DDXPointPtr)(ppt); \
+ int _i; \
+ for (_i = 0; _i < npt; _i++) { \
+ _ppt[_i].x += dst_off_x; \
+ _ppt[_i].y += dst_off_y; \
+ } \
+} while (0)
+
+#define CW_OFFSET_RECTS(prect, nrect) do { \
+ int _i; \
+ for (_i = 0; _i < nrect; _i++) { \
+ (prect)[_i].x += dst_off_x; \
+ (prect)[_i].y += dst_off_y; \
+ } \
+} while (0)
+
+#define CW_OFFSET_ARCS(parc, narc) do { \
+ int _i; \
+ for (_i = 0; _i < narc; _i++) { \
+ (parc)[_i].x += dst_off_x; \
+ (parc)[_i].y += dst_off_y; \
+ } \
+} while (0)
+
+#define CW_OFFSET_XY_DST(x, y) do { \
+ (x) = (x) + dst_off_x; \
+ (y) = (y) + dst_off_y; \
+} while (0)
+
+#define CW_OFFSET_XY_SRC(x, y) do { \
+ (x) = (x) + src_off_x; \
+ (y) = (y) + src_off_y; \
+} while (0)
+
+/* cw.c */
+extern _X_EXPORT DrawablePtr
+cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off);
+
+/* cw_render.c */
+
+extern _X_EXPORT void
+cwInitializeRender (ScreenPtr pScreen);
+
+extern _X_EXPORT void
+cwFiniRender (ScreenPtr pScreen);
+
+/* cw.c */
+
+extern _X_EXPORT void
+miInitializeCompositeWrapper(ScreenPtr pScreen);
diff --git a/xorg-server/miext/damage/damage.c b/xorg-server/miext/damage/damage.c index d1be437c2..50b73850b 100644 --- a/xorg-server/miext/damage/damage.c +++ b/xorg-server/miext/damage/damage.c @@ -70,21 +70,21 @@ #define pixmapDamage(pPixmap) damagePixPriv(pPixmap)
-static int damageScrPrivateKeyIndex;
-static DevPrivateKey damageScrPrivateKey = &damageScrPrivateKeyIndex;
-static int damagePixPrivateKeyIndex;
-static DevPrivateKey damagePixPrivateKey = &damagePixPrivateKeyIndex;
-static int damageGCPrivateKeyIndex;
-static DevPrivateKey damageGCPrivateKey = &damageGCPrivateKeyIndex;
-static int damageWinPrivateKeyIndex;
-static DevPrivateKey damageWinPrivateKey = &damageWinPrivateKeyIndex;
+static DevPrivateKeyRec damageScrPrivateKeyRec;
+#define damageScrPrivateKey (&damageScrPrivateKeyRec)
+static DevPrivateKeyRec damagePixPrivateKeyRec;
+#define damagePixPrivateKey (&damagePixPrivateKeyRec)
+static DevPrivateKeyRec damageGCPrivateKeyRec;
+#define damageGCPrivateKey (&damageGCPrivateKeyRec)
+static DevPrivateKeyRec damageWinPrivateKeyRec;
+#define damageWinPrivateKey (&damageWinPrivateKeyRec)
static DamagePtr *
getDrawableDamageRef (DrawablePtr pDrawable)
{
PixmapPtr pPixmap;
- if (pDrawable->type == DRAWABLE_WINDOW)
+ if (WindowDrawable(pDrawable->type))
{
ScreenPtr pScreen = pDrawable->pScreen;
@@ -129,40 +129,40 @@ damageReportDamage (DamagePtr pDamage, RegionPtr pDamageRegion) switch (pDamage->damageLevel) {
case DamageReportRawRegion:
- REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+ RegionUnion(&pDamage->damage, &pDamage->damage,
pDamageRegion);
(*pDamage->damageReport) (pDamage, pDamageRegion, pDamage->closure);
break;
case DamageReportDeltaRegion:
- REGION_NULL (pScreen, &tmpRegion);
- REGION_SUBTRACT (pScreen, &tmpRegion, pDamageRegion, &pDamage->damage);
- if (REGION_NOTEMPTY (pScreen, &tmpRegion)) {
- REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+ RegionNull(&tmpRegion);
+ RegionSubtract(&tmpRegion, pDamageRegion, &pDamage->damage);
+ if (RegionNotEmpty(&tmpRegion)) {
+ RegionUnion(&pDamage->damage, &pDamage->damage,
pDamageRegion);
(*pDamage->damageReport) (pDamage, &tmpRegion, pDamage->closure);
}
- REGION_UNINIT(pScreen, &tmpRegion);
+ RegionUninit(&tmpRegion);
break;
case DamageReportBoundingBox:
- tmpBox = *REGION_EXTENTS (pScreen, &pDamage->damage);
- REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+ tmpBox = *RegionExtents(&pDamage->damage);
+ RegionUnion(&pDamage->damage, &pDamage->damage,
pDamageRegion);
- if (!BOX_SAME (&tmpBox, REGION_EXTENTS (pScreen, &pDamage->damage))) {
+ if (!BOX_SAME (&tmpBox, RegionExtents(&pDamage->damage))) {
(*pDamage->damageReport) (pDamage, &pDamage->damage,
pDamage->closure);
}
break;
case DamageReportNonEmpty:
- was_empty = !REGION_NOTEMPTY(pScreen, &pDamage->damage);
- REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+ was_empty = !RegionNotEmpty(&pDamage->damage);
+ RegionUnion(&pDamage->damage, &pDamage->damage,
pDamageRegion);
- if (was_empty && REGION_NOTEMPTY(pScreen, &pDamage->damage)) {
+ if (was_empty && RegionNotEmpty(&pDamage->damage)) {
(*pDamage->damageReport) (pDamage, &pDamage->damage,
pDamage->closure);
}
break;
case DamageReportNone:
- REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+ RegionUnion(&pDamage->damage, &pDamage->damage,
pDamageRegion);
break;
}
@@ -175,30 +175,30 @@ damageReportDamagePostRendering (DamagePtr pDamage, RegionPtr pOldDamage, Region RegionRec tmpRegion, newDamage;
Bool was_empty;
- REGION_UNION(pScreem, &newDamage, pOldDamage, pDamageRegion);
+ RegionUnion(&newDamage, pOldDamage, pDamageRegion);
switch (pDamage->damageLevel) {
case DamageReportRawRegion:
(*pDamage->damageReportPostRendering) (pDamage, pDamageRegion, pDamage->closure);
break;
case DamageReportDeltaRegion:
- REGION_NULL (pScreen, &tmpRegion);
- REGION_SUBTRACT (pScreen, &tmpRegion, pDamageRegion, pOldDamage);
- if (REGION_NOTEMPTY (pScreen, &tmpRegion)) {
+ RegionNull(&tmpRegion);
+ RegionSubtract(&tmpRegion, pDamageRegion, pOldDamage);
+ if (RegionNotEmpty(&tmpRegion)) {
(*pDamage->damageReportPostRendering) (pDamage, &tmpRegion, pDamage->closure);
}
- REGION_UNINIT(pScreen, &tmpRegion);
+ RegionUninit(&tmpRegion);
break;
case DamageReportBoundingBox:
- tmpBox = *REGION_EXTENTS (pScreen, pOldDamage);
- if (!BOX_SAME (&tmpBox, REGION_EXTENTS (pScreen, &newDamage))) {
+ tmpBox = *RegionExtents(pOldDamage);
+ if (!BOX_SAME (&tmpBox, RegionExtents(&newDamage))) {
(*pDamage->damageReportPostRendering) (pDamage, &newDamage,
pDamage->closure);
}
break;
case DamageReportNonEmpty:
- was_empty = !REGION_NOTEMPTY(pScreen, pOldDamage);
- if (was_empty && REGION_NOTEMPTY(pScreen, &newDamage)) {
+ was_empty = !RegionNotEmpty(pOldDamage);
+ if (was_empty && RegionNotEmpty(&newDamage)) {
(*pDamage->damageReportPostRendering) (pDamage, &newDamage,
pDamage->closure);
}
@@ -207,7 +207,7 @@ damageReportDamagePostRendering (DamagePtr pDamage, RegionPtr pOldDamage, Region break;
}
- REGION_UNINIT(pScreen, &newDamage);
+ RegionUninit(&newDamage);
}
#if DAMAGE_DEBUG_ENABLE
@@ -233,7 +233,7 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, #endif
/* short circuit for empty regions */
- if (!REGION_NOTEMPTY(pScreen, pRegion))
+ if (!RegionNotEmpty(pRegion))
return;
#ifdef COMPOSITE
@@ -248,7 +248,7 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, screen_y = ((PixmapPtr) pDrawable)->screen_y - pDrawable->y;
}
if (screen_x || screen_y)
- REGION_TRANSLATE (pScreen, pRegion, screen_x, screen_y);
+ RegionTranslate(pRegion, screen_x, screen_y);
#endif
if (pDrawable->type == DRAWABLE_WINDOW &&
@@ -256,22 +256,22 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, {
if (subWindowMode == ClipByChildren)
{
- REGION_INTERSECT(pScreen, pRegion, pRegion,
+ RegionIntersect(pRegion, pRegion,
&((WindowPtr)(pDrawable))->clipList);
}
else if (subWindowMode == IncludeInferiors)
{
RegionPtr pTempRegion =
NotClippedByChildren((WindowPtr)(pDrawable));
- REGION_INTERSECT(pScreen, pRegion, pRegion, pTempRegion);
- REGION_DESTROY(pScreen, pTempRegion);
+ RegionIntersect(pRegion, pRegion, pTempRegion);
+ RegionDestroy(pTempRegion);
}
/* If subWindowMode is set to an invalid value, don't perform
* any drawable-based clipping. */
}
- REGION_NULL (pScreen, &clippedRec);
+ RegionNull(&clippedRec);
for (; pDamage; pDamage = pNext)
{
pNext = pDamage->pNext;
@@ -300,7 +300,7 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, * Need to move everyone to screen coordinates
* XXX what about off-screen pixmaps with non-zero x/y?
*/
- if (pDamage->pDrawable->type != DRAWABLE_WINDOW)
+ if (!WindowDrawable(pDamage->pDrawable->type))
{
draw_x += ((PixmapPtr) pDamage->pDrawable)->screen_x;
draw_y += ((PixmapPtr) pDamage->pDrawable)->screen_y;
@@ -316,7 +316,7 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, {
pDamageRegion = &clippedRec;
if (pDamage->pDrawable->type == DRAWABLE_WINDOW) {
- REGION_INTERSECT (pScreen, pDamageRegion, pRegion,
+ RegionIntersect(pDamageRegion, pRegion,
&((WindowPtr)(pDamage->pDrawable))->borderClip);
} else {
BoxRec box;
@@ -324,14 +324,14 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, box.y1 = draw_y;
box.x2 = draw_x + pDamage->pDrawable->width;
box.y2 = draw_y + pDamage->pDrawable->height;
- REGION_INIT(pScreen, &pixClip, &box, 1);
- REGION_INTERSECT (pScreen, pDamageRegion, pRegion, &pixClip);
- REGION_UNINIT(pScreen, &pixClip);
+ RegionInit(&pixClip, &box, 1);
+ RegionIntersect(pDamageRegion, pRegion, &pixClip);
+ RegionUninit(&pixClip);
}
/*
* Short circuit empty results
*/
- if (!REGION_NOTEMPTY(pScreen, pDamageRegion))
+ if (!RegionNotEmpty(pDamageRegion))
continue;
}
@@ -346,23 +346,23 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, * Move region to target coordinate space
*/
if (draw_x || draw_y)
- REGION_TRANSLATE (pScreen, pDamageRegion, -draw_x, -draw_y);
+ RegionTranslate(pDamageRegion, -draw_x, -draw_y);
/* Store damage region if needed after submission. */
if (pDamage->reportAfter || pDamage->damageMarker)
- REGION_UNION(pScreen, &pDamage->pendingDamage,
+ RegionUnion(&pDamage->pendingDamage,
&pDamage->pendingDamage, pDamageRegion);
/* Duplicate current damage if needed. */
if (pDamage->damageMarker)
- REGION_COPY(pScreen, &pDamage->backupDamage, &pDamage->damage);
+ RegionCopy(&pDamage->backupDamage, &pDamage->damage);
/* Report damage now, if desired. */
if (!pDamage->reportAfter) {
if (pDamage->damageReport)
damageReportDamage (pDamage, pDamageRegion);
else
- REGION_UNION(pScreen, &pDamage->damage,
+ RegionUnion(&pDamage->damage,
&pDamage->damage, pDamageRegion);
}
@@ -370,14 +370,14 @@ damageRegionAppend (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, * translate original region back
*/
if (pDamageRegion == pRegion && (draw_x || draw_y))
- REGION_TRANSLATE (pScreen, pDamageRegion, draw_x, draw_y);
+ RegionTranslate(pDamageRegion, draw_x, draw_y);
}
#ifdef COMPOSITE
if (screen_x || screen_y)
- REGION_TRANSLATE (pScreen, pRegion, -screen_x, -screen_y);
+ RegionTranslate(pRegion, -screen_x, -screen_y);
#endif
- REGION_UNINIT (pScreen, &clippedRec);
+ RegionUninit(&clippedRec);
}
static void
@@ -395,14 +395,14 @@ damageRegionProcessPending (DrawablePtr pDrawable) if (pDamage->damageReport)
damageReportDamage (pDamage, &pDamage->pendingDamage);
else
- REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+ RegionUnion(&pDamage->damage, &pDamage->damage,
&pDamage->pendingDamage);
}
if (pDamage->reportAfter || pDamage->damageMarker)
- REGION_EMPTY (pScreen, &pDamage->pendingDamage);
+ RegionEmpty(&pDamage->pendingDamage);
if (pDamage->damageMarker)
- REGION_EMPTY (pScreen, &pDamage->backupDamage);
+ RegionEmpty(&pDamage->backupDamage);
}
}
@@ -418,13 +418,13 @@ damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, int subWindowMode) {
RegionRec region;
- REGION_INIT (pDrawable->pScreen, ®ion, pBox, 1);
+ RegionInit(®ion, pBox, 1);
#if DAMAGE_DEBUG_ENABLE
_damageRegionAppend (pDrawable, ®ion, TRUE, subWindowMode, where);
#else
damageRegionAppend (pDrawable, ®ion, TRUE, subWindowMode);
#endif
- REGION_UNINIT (pDrawable->pScreen, ®ion);
+ RegionUninit(®ion);
}
static void damageValidateGC(GCPtr, unsigned long, DrawablePtr);
@@ -593,8 +593,7 @@ damageDestroyClip(GCPtr pGC) #define checkGCDamage(d,g) (getDrawableDamage(d) && \
(!g->pCompositeClip ||\
- REGION_NOTEMPTY(d->pScreen, \
- g->pCompositeClip)))
+ RegionNotEmpty(g->pCompositeClip)))
#define TRIM_PICTURE_BOX(box, pDst) { \
BoxPtr extents = &pDst->pCompositeClip->extents;\
@@ -605,7 +604,7 @@ damageDestroyClip(GCPtr pGC) }
#define checkPictureDamage(p) (getDrawableDamage(p->pDrawable) && \
- REGION_NOTEMPTY(pScreen, p->pCompositeClip))
+ RegionNotEmpty(p->pCompositeClip))
static void
damageComposite (CARD8 op,
@@ -1763,9 +1762,9 @@ damageCopyWindow(WindowPtr pWindow, * The region comes in source relative, but the damage occurs
* at the destination location. Translate back and forth.
*/
- REGION_TRANSLATE (pScreen, prgnSrc, dx, dy);
+ RegionTranslate(prgnSrc, dx, dy);
damageRegionAppend (&pWindow->drawable, prgnSrc, FALSE, -1);
- REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy);
+ RegionTranslate(prgnSrc, -dx, -dy);
}
unwrap (pScrPriv, pScreen, CopyWindow);
(*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc);
@@ -1884,10 +1883,19 @@ DamageSetup (ScreenPtr pScreen) miDamageCreate, miDamageRegister, miDamageUnregister, miDamageDestroy
};
+ if (!dixRegisterPrivateKey(&damageScrPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
if (dixLookupPrivate(&pScreen->devPrivates, damageScrPrivateKey))
return TRUE;
- if (!dixRequestPrivate(damageGCPrivateKey, sizeof(DamageGCPrivRec)))
+ if (!dixRegisterPrivateKey(&damageGCPrivateKeyRec, PRIVATE_GC, sizeof(DamageGCPrivRec)))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&damagePixPrivateKeyRec, PRIVATE_PIXMAP, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&damageWinPrivateKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
pScrPriv = malloc(sizeof (DamageScrPrivRec));
@@ -1926,13 +1934,13 @@ DamageCreate (DamageReportFunc damageReport, damageScrPriv(pScreen);
DamagePtr pDamage;
- pDamage = malloc(sizeof (DamageRec));
+ pDamage = dixAllocateObjectWithPrivates(DamageRec, PRIVATE_DAMAGE);
if (!pDamage)
return 0;
pDamage->pNext = 0;
pDamage->pNextWin = 0;
- REGION_NULL(pScreen, &pDamage->damage);
- REGION_NULL(pScreen, &pDamage->pendingDamage);
+ RegionNull(&pDamage->damage);
+ RegionNull(&pDamage->pendingDamage);
pDamage->damageLevel = damageLevel;
pDamage->isInternal = isInternal;
@@ -1946,7 +1954,6 @@ DamageCreate (DamageReportFunc damageReport, pDamage->damageDestroy = damageDestroy;
pDamage->damageMarker = NULL;
pDamage->pScreen = pScreen;
- pDamage->devPrivates = NULL;
(*pScrPriv->funcs.Create) (pDamage);
@@ -2050,11 +2057,9 @@ DamageDestroy (DamagePtr pDamage) if (pDamage->damageDestroy)
(*pDamage->damageDestroy) (pDamage, pDamage->closure);
(*pScrPriv->funcs.Destroy) (pDamage);
- dixFreePrivates(pDamage->devPrivates);
- pDamage->devPrivates = NULL;
- REGION_UNINIT (pScreen, &pDamage->damage);
- REGION_UNINIT (pScreen, &pDamage->pendingDamage);
- free(pDamage);
+ RegionUninit(&pDamage->damage);
+ RegionUninit(&pDamage->pendingDamage);
+ dixFreeObjectWithPrivates(pDamage, PRIVATE_DAMAGE);
}
Bool
@@ -2065,7 +2070,7 @@ DamageSubtract (DamagePtr pDamage, RegionRec pixmapClip;
DrawablePtr pDrawable = pDamage->pDrawable;
- REGION_SUBTRACT (pDrawable->pScreen, &pDamage->damage, &pDamage->damage, pRegion);
+ RegionSubtract(&pDamage->damage, &pDamage->damage, pRegion);
if (pDrawable)
{
if (pDrawable->type == DRAWABLE_WINDOW)
@@ -2078,22 +2083,22 @@ DamageSubtract (DamagePtr pDamage, box.y1 = pDrawable->y;
box.x2 = pDrawable->x + pDrawable->width;
box.y2 = pDrawable->y + pDrawable->height;
- REGION_INIT (pDrawable->pScreen, &pixmapClip, &box, 1);
+ RegionInit(&pixmapClip, &box, 1);
pClip = &pixmapClip;
}
- REGION_TRANSLATE (pDrawable->pScreen, &pDamage->damage, pDrawable->x, pDrawable->y);
- REGION_INTERSECT (pDrawable->pScreen, &pDamage->damage, &pDamage->damage, pClip);
- REGION_TRANSLATE (pDrawable->pScreen, &pDamage->damage, -pDrawable->x, -pDrawable->y);
+ RegionTranslate(&pDamage->damage, pDrawable->x, pDrawable->y);
+ RegionIntersect(&pDamage->damage, &pDamage->damage, pClip);
+ RegionTranslate(&pDamage->damage, -pDrawable->x, -pDrawable->y);
if (pDrawable->type != DRAWABLE_WINDOW)
- REGION_UNINIT(pDrawable->pScreen, &pixmapClip);
+ RegionUninit(&pixmapClip);
}
- return REGION_NOTEMPTY (pDrawable->pScreen, &pDamage->damage);
+ return RegionNotEmpty(&pDamage->damage);
}
void
DamageEmpty (DamagePtr pDamage)
{
- REGION_EMPTY (pDamage->pDrawable->pScreen, &pDamage->damage);
+ RegionEmpty(&pDamage->damage);
}
RegionPtr
diff --git a/xorg-server/miext/rootless/rootlessCommon.c b/xorg-server/miext/rootless/rootlessCommon.c index b96422b76..e97a53725 100644 --- a/xorg-server/miext/rootless/rootlessCommon.c +++ b/xorg-server/miext/rootless/rootlessCommon.c @@ -1,483 +1,484 @@ -/* - * Common rootless definitions and code - */ -/* - * 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 - -#include <stddef.h> /* For NULL */ -#include <limits.h> /* For CHAR_BIT */ - -#include "rootlessCommon.h" -#include "colormapst.h" - -unsigned int rootless_CopyBytes_threshold = 0; -unsigned int rootless_FillBytes_threshold = 0; -unsigned int rootless_CompositePixels_threshold = 0; -unsigned int rootless_CopyWindow_threshold = 0; -#ifdef ROOTLESS_GLOBAL_COORDS -int rootlessGlobalOffsetX = 0; -int rootlessGlobalOffsetY = 0; -#endif - -RegionRec rootlessHugeRoot = {{-32767, -32767, 32767, 32767}, NULL}; - -/* Following macro from miregion.c */ - -/* true iff two Boxes overlap */ -#define EXTENTCHECK(r1,r2) \ - (!( ((r1)->x2 <= (r2)->x1) || \ - ((r1)->x1 >= (r2)->x2) || \ - ((r1)->y2 <= (r2)->y1) || \ - ((r1)->y1 >= (r2)->y2) ) ) - - -/* - * TopLevelParent - * Returns the top-level parent of pWindow. - * The root is the top-level parent of itself, even though the root is - * not otherwise considered to be a top-level window. - */ -WindowPtr -TopLevelParent(WindowPtr pWindow) -{ - WindowPtr top; - - if (IsRoot(pWindow)) - return pWindow; - - top = pWindow; - while (top && ! IsTopLevel(top)) - top = top->parent; - - return top; -} - - -/* - * IsFramedWindow - * Returns TRUE if this window is visible inside a frame - * (e.g. it is visible and has a top-level or root parent) - */ -Bool -IsFramedWindow(WindowPtr pWin) -{ - WindowPtr top; - - if (!pWin->realized) - return FALSE; - top = TopLevelParent(pWin); - - return (top && WINREC(top)); -} - -Bool -RootlessResolveColormap (ScreenPtr pScreen, int first_color, - int n_colors, uint32_t *colors) -{ - int last, i; - ColormapPtr map; - - map = RootlessGetColormap (pScreen); - if (map == NULL || map->class != PseudoColor) return FALSE; - - last = min (map->pVisual->ColormapEntries, first_color + n_colors); - for (i = max (0, first_color); i < last; i++) { - Entry *ent = map->red + i; - uint16_t red, green, blue; - - if (!ent->refcnt) continue; - if (ent->fShared) { - red = ent->co.shco.red->color; - green = ent->co.shco.green->color; - blue = ent->co.shco.blue->color; - } else { - red = ent->co.local.red; - green = ent->co.local.green; - blue = ent->co.local.blue; - } - - colors[i - first_color] = (0xFF000000UL - | ((uint32_t) red & 0xff00) << 8 - | (green & 0xff00) - | (blue >> 8)); - } - - return TRUE; -} - - -/* - * RootlessStartDrawing - * Prepare a window for direct access to its backing buffer. - * Each top-level parent has a Pixmap representing its backing buffer, - * which all of its children inherit. - */ -void RootlessStartDrawing(WindowPtr pWindow) -{ - ScreenPtr pScreen = pWindow->drawable.pScreen; - WindowPtr top = TopLevelParent(pWindow); - RootlessWindowRec *winRec; - PixmapPtr curPixmap; - - if (top == NULL) - return; - winRec = WINREC(top); - if (winRec == NULL) - return; - - // Make sure the window's top-level parent is prepared for drawing. - if (!winRec->is_drawing) { - int bw = wBorderWidth(top); - - SCREENREC(pScreen)->imp->StartDrawing(winRec->wid, &winRec->pixelData, - &winRec->bytesPerRow); - - winRec->pixmap = - GetScratchPixmapHeader(pScreen, winRec->width, winRec->height, - top->drawable.depth, - top->drawable.bitsPerPixel, - winRec->bytesPerRow, - winRec->pixelData); - SetPixmapBaseToScreen(winRec->pixmap, - top->drawable.x - bw, top->drawable.y - bw); - - winRec->is_drawing = TRUE; - } - - curPixmap = pScreen->GetWindowPixmap(pWindow); - if (curPixmap == winRec->pixmap) - { - RL_DEBUG_MSG("Window %p already has winRec->pixmap %p; not pushing\n", pWindow, winRec->pixmap); - } - else - { - PixmapPtr oldPixmap = dixLookupPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey); - if (oldPixmap != NULL) - { - if (oldPixmap == curPixmap) - RL_DEBUG_MSG("Window %p's curPixmap %p is the same as its oldPixmap; strange\n", pWindow, curPixmap); - else - RL_DEBUG_MSG("Window %p's existing oldPixmap %p being lost!\n", pWindow, oldPixmap); - } - dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, curPixmap); - pScreen->SetWindowPixmap(pWindow, winRec->pixmap); - } -} - - -/* - * RootlessStopDrawing - * Stop drawing to a window's backing buffer. If flush is true, - * damaged regions are flushed to the screen. - */ -static int RestorePreDrawingPixmapVisitor(WindowPtr pWindow, pointer data) -{ - RootlessWindowRec *winRec = (RootlessWindowRec*)data; - ScreenPtr pScreen = pWindow->drawable.pScreen; - PixmapPtr exPixmap = pScreen->GetWindowPixmap(pWindow); - PixmapPtr oldPixmap = dixLookupPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey); - if (oldPixmap == NULL) - { - if (exPixmap == winRec->pixmap) - RL_DEBUG_MSG("Window %p appears to be in drawing mode (ex-pixmap %p equals winRec->pixmap, which is being freed) but has no oldPixmap!\n", pWindow, exPixmap); - } - else - { - if (exPixmap != winRec->pixmap) - RL_DEBUG_MSG("Window %p appears to be in drawing mode (oldPixmap %p) but ex-pixmap %p not winRec->pixmap %p!\n", pWindow, oldPixmap, exPixmap, winRec->pixmap); - if (oldPixmap == winRec->pixmap) - RL_DEBUG_MSG("Window %p's oldPixmap %p is winRec->pixmap, which has just been freed!\n", pWindow, oldPixmap); - pScreen->SetWindowPixmap(pWindow, oldPixmap); - dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, NULL); - } - return WT_WALKCHILDREN; -} - -void RootlessStopDrawing(WindowPtr pWindow, Bool flush) -{ - ScreenPtr pScreen = pWindow->drawable.pScreen; - WindowPtr top = TopLevelParent(pWindow); - RootlessWindowRec *winRec; - - if (top == NULL) - return; - winRec = WINREC(top); - if (winRec == NULL) - return; - - if (winRec->is_drawing) { - SCREENREC(pScreen)->imp->StopDrawing(winRec->wid, flush); - - FreeScratchPixmapHeader(winRec->pixmap); - TraverseTree(top, RestorePreDrawingPixmapVisitor, (pointer)winRec); - winRec->pixmap = NULL; - - winRec->is_drawing = FALSE; - } - else if (flush) { - SCREENREC(pScreen)->imp->UpdateRegion(winRec->wid, NULL); - } - - if (flush && winRec->is_reorder_pending) { - winRec->is_reorder_pending = FALSE; - RootlessReorderWindow(pWindow); - } -} - - -/* - * RootlessDamageRegion - * Mark a damaged region as requiring redisplay to screen. - * pRegion is in GLOBAL coordinates. - */ -void -RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion) -{ - ScreenPtr pScreen = pWindow->drawable.pScreen; - RootlessWindowRec *winRec; - RegionRec clipped; - WindowPtr pTop; - BoxPtr b1, b2; - - RL_DEBUG_MSG("Damaged win 0x%x ", pWindow); - - pTop = TopLevelParent(pWindow); - if (pTop == NULL) - return; - - winRec = WINREC(pTop); - if (winRec == NULL) - return; - - /* We need to intersect the drawn region with the clip of the window - to avoid marking places we didn't actually draw (which can cause - problems when the window has an extra client-side backing store) - - But this is a costly operation and since we'll normally just be - drawing inside the clip, go to some lengths to avoid the general - case intersection. */ - - b1 = REGION_EXTENTS(pScreen, &pWindow->borderClip); - b2 = REGION_EXTENTS(pScreen, pRegion); - - if (EXTENTCHECK(b1, b2)) { - /* Regions may overlap. */ - - if (REGION_NUM_RECTS(pRegion) == 1) { - int in; - - /* Damaged region only has a single rect, so we can - just compare that against the region */ - - in = RECT_IN_REGION(pScreen, &pWindow->borderClip, - REGION_RECTS (pRegion)); - if (in == rgnIN) { - /* clip totally contains pRegion */ - -#ifdef ROOTLESS_TRACK_DAMAGE - REGION_UNION(pScreen, &winRec->damage, - &winRec->damage, (pRegion)); -#else - SCREENREC(pScreen)->imp->DamageRects(winRec->wid, - REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - -winRec->x, -winRec->y); -#endif - - RootlessQueueRedisplay(pTop->drawable.pScreen); - goto out; - } - else if (in == rgnOUT) { - /* clip doesn't contain pRegion */ - - goto out; - } - } - - /* clip overlaps pRegion, need to intersect */ - - REGION_NULL(pScreen, &clipped); - REGION_INTERSECT(pScreen, &clipped, &pWindow->borderClip, pRegion); - -#ifdef ROOTLESS_TRACK_DAMAGE - REGION_UNION(pScreen, &winRec->damage, - &winRec->damage, (pRegion)); -#else - SCREENREC(pScreen)->imp->DamageRects(winRec->wid, - REGION_NUM_RECTS(&clipped), - REGION_RECTS(&clipped), - -winRec->x, -winRec->y); -#endif - - REGION_UNINIT(pScreen, &clipped); - - RootlessQueueRedisplay(pTop->drawable.pScreen); - } - -out: -#ifdef ROOTLESSDEBUG - { - BoxRec *box = REGION_RECTS(pRegion), *end; - int numBox = REGION_NUM_RECTS(pRegion); - - for (end = box+numBox; box < end; box++) { - RL_DEBUG_MSG("Damage rect: %i, %i, %i, %i\n", - box->x1, box->x2, box->y1, box->y2); - } - } -#endif - return; -} - - -/* - * RootlessDamageBox - * Mark a damaged box as requiring redisplay to screen. - * pRegion is in GLOBAL coordinates. - */ -void -RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox) -{ - RegionRec region; - - REGION_INIT(pWindow->drawable.pScreen, ®ion, pBox, 1); - - RootlessDamageRegion(pWindow, ®ion); - - REGION_UNINIT(pWindow->drawable.pScreen, ®ion); /* no-op */ -} - - -/* - * RootlessDamageRect - * Mark a damaged rectangle as requiring redisplay to screen. - * (x, y, w, h) is in window-local coordinates. - */ -void -RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h) -{ - BoxRec box; - RegionRec region; - - x += pWindow->drawable.x; - y += pWindow->drawable.y; - - box.x1 = x; - box.x2 = x + w; - box.y1 = y; - box.y2 = y + h; - - REGION_INIT(pWindow->drawable.pScreen, ®ion, &box, 1); - - RootlessDamageRegion(pWindow, ®ion); - - REGION_UNINIT(pWindow->drawable.pScreen, ®ion); /* no-op */ -} - - -/* - * RootlessRedisplay - * Stop drawing and redisplay the damaged region of a window. - */ -void -RootlessRedisplay(WindowPtr pWindow) -{ -#ifdef ROOTLESS_TRACK_DAMAGE - - RootlessWindowRec *winRec = WINREC(pWindow); - ScreenPtr pScreen = pWindow->drawable.pScreen; - - RootlessStopDrawing(pWindow, FALSE); - - if (REGION_NOTEMPTY(pScreen, &winRec->damage)) { - RL_DEBUG_MSG("Redisplay Win 0x%x, %i x %i @ (%i, %i)\n", - pWindow, winRec->width, winRec->height, - winRec->x, winRec->y); - - // move region to window local coords - REGION_TRANSLATE(pScreen, &winRec->damage, - -winRec->x, -winRec->y); - - SCREENREC(pScreen)->imp->UpdateRegion(winRec->wid, &winRec->damage); - - REGION_EMPTY(pScreen, &winRec->damage); - } - -#else /* !ROOTLESS_TRACK_DAMAGE */ - - RootlessStopDrawing(pWindow, TRUE); - -#endif -} - - -/* - * RootlessRepositionWindows - * Reposition all windows on a screen to their correct positions. - */ -void -RootlessRepositionWindows(ScreenPtr pScreen) -{ - WindowPtr root = WindowTable[pScreen->myNum]; - WindowPtr win; - - if (root != NULL) { - RootlessRepositionWindow(root); - - for (win = root->firstChild; win; win = win->nextSib) { - if (WINREC(win) != NULL) - RootlessRepositionWindow(win); - } - } -} - - -/* - * RootlessRedisplayScreen - * Walk every window on a screen and redisplay the damaged regions. - */ -void -RootlessRedisplayScreen(ScreenPtr pScreen) -{ - WindowPtr root = WindowTable[pScreen->myNum]; - - if (root != NULL) { - WindowPtr win; - - RootlessRedisplay(root); - for (win = root->firstChild; win; win = win->nextSib) { - if (WINREC(win) != NULL) { - RootlessRedisplay(win); - } - } - } -} +/*
+ * Common rootless definitions and code
+ */
+/*
+ * 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
+
+#include <stddef.h> /* For NULL */
+#include <limits.h> /* For CHAR_BIT */
+
+#include "rootlessCommon.h"
+#include "colormapst.h"
+
+unsigned int rootless_CopyBytes_threshold = 0;
+unsigned int rootless_FillBytes_threshold = 0;
+unsigned int rootless_CompositePixels_threshold = 0;
+unsigned int rootless_CopyWindow_threshold = 0;
+#ifdef ROOTLESS_GLOBAL_COORDS
+int rootlessGlobalOffsetX = 0;
+int rootlessGlobalOffsetY = 0;
+#endif
+
+RegionRec rootlessHugeRoot = {{-32767, -32767, 32767, 32767}, NULL};
+
+/* Following macro from miregion.c */
+
+/* true iff two Boxes overlap */
+#define EXTENTCHECK(r1,r2) \
+ (!( ((r1)->x2 <= (r2)->x1) || \
+ ((r1)->x1 >= (r2)->x2) || \
+ ((r1)->y2 <= (r2)->y1) || \
+ ((r1)->y1 >= (r2)->y2) ) )
+
+
+/*
+ * TopLevelParent
+ * Returns the top-level parent of pWindow.
+ * The root is the top-level parent of itself, even though the root is
+ * not otherwise considered to be a top-level window.
+ */
+WindowPtr
+TopLevelParent(WindowPtr pWindow)
+{
+ WindowPtr top;
+
+ if (IsRoot(pWindow))
+ return pWindow;
+
+ top = pWindow;
+ while (top && ! IsTopLevel(top))
+ top = top->parent;
+
+ return top;
+}
+
+
+/*
+ * IsFramedWindow
+ * Returns TRUE if this window is visible inside a frame
+ * (e.g. it is visible and has a top-level or root parent)
+ */
+Bool
+IsFramedWindow(WindowPtr pWin)
+{
+ WindowPtr top;
+
+ if (!pWin->realized)
+ return FALSE;
+ top = TopLevelParent(pWin);
+
+ return (top && WINREC(top));
+}
+
+Bool
+RootlessResolveColormap (ScreenPtr pScreen, int first_color,
+ int n_colors, uint32_t *colors)
+{
+ int last, i;
+ ColormapPtr map;
+
+ map = RootlessGetColormap (pScreen);
+ if (map == NULL || map->class != PseudoColor) return FALSE;
+
+ last = min (map->pVisual->ColormapEntries, first_color + n_colors);
+ for (i = max (0, first_color); i < last; i++) {
+ Entry *ent = map->red + i;
+ uint16_t red, green, blue;
+
+ if (!ent->refcnt) continue;
+ if (ent->fShared) {
+ red = ent->co.shco.red->color;
+ green = ent->co.shco.green->color;
+ blue = ent->co.shco.blue->color;
+ } else {
+ red = ent->co.local.red;
+ green = ent->co.local.green;
+ blue = ent->co.local.blue;
+ }
+
+ colors[i - first_color] = (0xFF000000UL
+ | ((uint32_t) red & 0xff00) << 8
+ | (green & 0xff00)
+ | (blue >> 8));
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * RootlessStartDrawing
+ * Prepare a window for direct access to its backing buffer.
+ * Each top-level parent has a Pixmap representing its backing buffer,
+ * which all of its children inherit.
+ */
+void RootlessStartDrawing(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ WindowPtr top = TopLevelParent(pWindow);
+ RootlessWindowRec *winRec;
+ PixmapPtr curPixmap;
+
+ if (top == NULL)
+ return;
+ winRec = WINREC(top);
+ if (winRec == NULL)
+ return;
+
+ // Make sure the window's top-level parent is prepared for drawing.
+ if (!winRec->is_drawing) {
+ int bw = wBorderWidth(top);
+
+ SCREENREC(pScreen)->imp->StartDrawing(winRec->wid, &winRec->pixelData,
+ &winRec->bytesPerRow);
+
+ winRec->pixmap =
+ GetScratchPixmapHeader(pScreen, winRec->width, winRec->height,
+ top->drawable.depth,
+ top->drawable.bitsPerPixel,
+ winRec->bytesPerRow,
+ winRec->pixelData);
+ SetPixmapBaseToScreen(winRec->pixmap,
+ top->drawable.x - bw, top->drawable.y - bw);
+
+ winRec->is_drawing = TRUE;
+ }
+
+ curPixmap = pScreen->GetWindowPixmap(pWindow);
+ if (curPixmap == winRec->pixmap)
+ {
+ RL_DEBUG_MSG("Window %p already has winRec->pixmap %p; not pushing\n", pWindow, winRec->pixmap);
+ }
+ else
+ {
+ PixmapPtr oldPixmap = dixLookupPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey);
+ if (oldPixmap != NULL)
+ {
+ if (oldPixmap == curPixmap)
+ RL_DEBUG_MSG("Window %p's curPixmap %p is the same as its oldPixmap; strange\n", pWindow, curPixmap);
+ else
+ RL_DEBUG_MSG("Window %p's existing oldPixmap %p being lost!\n", pWindow, oldPixmap);
+ }
+ dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, curPixmap);
+ pScreen->SetWindowPixmap(pWindow, winRec->pixmap);
+ }
+}
+
+
+/*
+ * RootlessStopDrawing
+ * Stop drawing to a window's backing buffer. If flush is true,
+ * damaged regions are flushed to the screen.
+ */
+static int RestorePreDrawingPixmapVisitor(WindowPtr pWindow, pointer data)
+{
+ RootlessWindowRec *winRec = (RootlessWindowRec*)data;
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ PixmapPtr exPixmap = pScreen->GetWindowPixmap(pWindow);
+ PixmapPtr oldPixmap = dixLookupPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey);
+ if (oldPixmap == NULL)
+ {
+ if (exPixmap == winRec->pixmap)
+ RL_DEBUG_MSG("Window %p appears to be in drawing mode (ex-pixmap %p equals winRec->pixmap, which is being freed) but has no oldPixmap!\n", pWindow, exPixmap);
+ }
+ else
+ {
+ if (exPixmap != winRec->pixmap)
+ RL_DEBUG_MSG("Window %p appears to be in drawing mode (oldPixmap %p) but ex-pixmap %p not winRec->pixmap %p!\n", pWindow, oldPixmap, exPixmap, winRec->pixmap);
+ if (oldPixmap == winRec->pixmap)
+ RL_DEBUG_MSG("Window %p's oldPixmap %p is winRec->pixmap, which has just been freed!\n", pWindow, oldPixmap);
+ pScreen->SetWindowPixmap(pWindow, oldPixmap);
+ dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, NULL);
+ }
+ return WT_WALKCHILDREN;
+}
+
+void RootlessStopDrawing(WindowPtr pWindow, Bool flush)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ WindowPtr top = TopLevelParent(pWindow);
+ RootlessWindowRec *winRec;
+
+ if (top == NULL)
+ return;
+ winRec = WINREC(top);
+ if (winRec == NULL)
+ return;
+
+ if (winRec->is_drawing) {
+ SCREENREC(pScreen)->imp->StopDrawing(winRec->wid, flush);
+
+ FreeScratchPixmapHeader(winRec->pixmap);
+ TraverseTree(top, RestorePreDrawingPixmapVisitor, (pointer)winRec);
+ winRec->pixmap = NULL;
+
+ winRec->is_drawing = FALSE;
+ }
+ else if (flush) {
+ SCREENREC(pScreen)->imp->UpdateRegion(winRec->wid, NULL);
+ }
+
+ if (flush && winRec->is_reorder_pending) {
+ winRec->is_reorder_pending = FALSE;
+ RootlessReorderWindow(pWindow);
+ }
+}
+
+
+/*
+ * RootlessDamageRegion
+ * Mark a damaged region as requiring redisplay to screen.
+ * pRegion is in GLOBAL coordinates.
+ */
+void
+RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion)
+{
+ RootlessWindowRec *winRec;
+ RegionRec clipped;
+ WindowPtr pTop;
+ BoxPtr b1, b2;
+
+ RL_DEBUG_MSG("Damaged win 0x%x ", pWindow);
+
+ pTop = TopLevelParent(pWindow);
+ if (pTop == NULL)
+ return;
+
+ winRec = WINREC(pTop);
+ if (winRec == NULL)
+ return;
+
+ /* We need to intersect the drawn region with the clip of the window
+ to avoid marking places we didn't actually draw (which can cause
+ problems when the window has an extra client-side backing store)
+
+ But this is a costly operation and since we'll normally just be
+ drawing inside the clip, go to some lengths to avoid the general
+ case intersection. */
+
+ b1 = RegionExtents(&pWindow->borderClip);
+ b2 = RegionExtents(pRegion);
+
+ if (EXTENTCHECK(b1, b2)) {
+ /* Regions may overlap. */
+
+ if (RegionNumRects(pRegion) == 1) {
+ int in;
+
+ /* Damaged region only has a single rect, so we can
+ just compare that against the region */
+
+ in = RegionContainsRect(&pWindow->borderClip,
+ RegionRects (pRegion));
+ if (in == rgnIN) {
+ /* clip totally contains pRegion */
+
+#ifdef ROOTLESS_TRACK_DAMAGE
+ RegionUnion(&winRec->damage,
+ &winRec->damage, (pRegion));
+#else
+ SCREENREC(pWindow->drawable.pScreen)->imp->
+ DamageRects(winRec->wid,
+ RegionNumRects(pRegion),
+ RegionRects(pRegion),
+ -winRec->x, -winRec->y);
+#endif
+
+ RootlessQueueRedisplay(pTop->drawable.pScreen);
+ goto out;
+ }
+ else if (in == rgnOUT) {
+ /* clip doesn't contain pRegion */
+
+ goto out;
+ }
+ }
+
+ /* clip overlaps pRegion, need to intersect */
+
+ RegionNull(&clipped);
+ RegionIntersect(&clipped, &pWindow->borderClip, pRegion);
+
+#ifdef ROOTLESS_TRACK_DAMAGE
+ RegionUnion(&winRec->damage,
+ &winRec->damage, (pRegion));
+#else
+ SCREENREC(pWindow->drawable.pScreen)->imp->
+ DamageRects(winRec->wid,
+ RegionNumRects(&clipped),
+ RegionRects(&clipped),
+ -winRec->x, -winRec->y);
+#endif
+
+ RegionUninit(&clipped);
+
+ RootlessQueueRedisplay(pTop->drawable.pScreen);
+ }
+
+out:
+#ifdef ROOTLESSDEBUG
+ {
+ BoxRec *box = RegionRects(pRegion), *end;
+ int numBox = RegionNumRects(pRegion);
+
+ for (end = box+numBox; box < end; box++) {
+ RL_DEBUG_MSG("Damage rect: %i, %i, %i, %i\n",
+ box->x1, box->x2, box->y1, box->y2);
+ }
+ }
+#endif
+ return;
+}
+
+
+/*
+ * RootlessDamageBox
+ * Mark a damaged box as requiring redisplay to screen.
+ * pRegion is in GLOBAL coordinates.
+ */
+void
+RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox)
+{
+ RegionRec region;
+
+ RegionInit(®ion, pBox, 1);
+
+ RootlessDamageRegion(pWindow, ®ion);
+
+ RegionUninit(®ion); /* no-op */
+}
+
+
+/*
+ * RootlessDamageRect
+ * Mark a damaged rectangle as requiring redisplay to screen.
+ * (x, y, w, h) is in window-local coordinates.
+ */
+void
+RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h)
+{
+ BoxRec box;
+ RegionRec region;
+
+ x += pWindow->drawable.x;
+ y += pWindow->drawable.y;
+
+ box.x1 = x;
+ box.x2 = x + w;
+ box.y1 = y;
+ box.y2 = y + h;
+
+ RegionInit(®ion, &box, 1);
+
+ RootlessDamageRegion(pWindow, ®ion);
+
+ RegionUninit(®ion); /* no-op */
+}
+
+
+/*
+ * RootlessRedisplay
+ * Stop drawing and redisplay the damaged region of a window.
+ */
+void
+RootlessRedisplay(WindowPtr pWindow)
+{
+#ifdef ROOTLESS_TRACK_DAMAGE
+
+ RootlessWindowRec *winRec = WINREC(pWindow);
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+
+ RootlessStopDrawing(pWindow, FALSE);
+
+ if (RegionNotEmpty(&winRec->damage)) {
+ RL_DEBUG_MSG("Redisplay Win 0x%x, %i x %i @ (%i, %i)\n",
+ pWindow, winRec->width, winRec->height,
+ winRec->x, winRec->y);
+
+ // move region to window local coords
+ RegionTranslate(&winRec->damage,
+ -winRec->x, -winRec->y);
+
+ SCREENREC(pScreen)->imp->UpdateRegion(winRec->wid, &winRec->damage);
+
+ RegionEmpty(&winRec->damage);
+ }
+
+#else /* !ROOTLESS_TRACK_DAMAGE */
+
+ RootlessStopDrawing(pWindow, TRUE);
+
+#endif
+}
+
+
+/*
+ * RootlessRepositionWindows
+ * Reposition all windows on a screen to their correct positions.
+ */
+void
+RootlessRepositionWindows(ScreenPtr pScreen)
+{
+ WindowPtr root = pScreen->root;
+ WindowPtr win;
+
+ if (root != NULL) {
+ RootlessRepositionWindow(root);
+
+ for (win = root->firstChild; win; win = win->nextSib) {
+ if (WINREC(win) != NULL)
+ RootlessRepositionWindow(win);
+ }
+ }
+}
+
+
+/*
+ * RootlessRedisplayScreen
+ * Walk every window on a screen and redisplay the damaged regions.
+ */
+void
+RootlessRedisplayScreen(ScreenPtr pScreen)
+{
+ WindowPtr root = pScreen->root;
+
+ if (root != NULL) {
+ WindowPtr win;
+
+ RootlessRedisplay(root);
+ for (win = root->firstChild; win; win = win->nextSib) {
+ if (WINREC(win) != NULL) {
+ RootlessRedisplay(win);
+ }
+ }
+ }
+}
diff --git a/xorg-server/miext/rootless/rootlessCommon.h b/xorg-server/miext/rootless/rootlessCommon.h index f44c4e8cf..893ca9825 100644 --- a/xorg-server/miext/rootless/rootlessCommon.h +++ b/xorg-server/miext/rootless/rootlessCommon.h @@ -1,283 +1,290 @@ -/* - * Common internal rootless definitions and code - */ -/* - * Copyright (c) 2001 Greg Parker. All Rights Reserved. - * Copyright (c) 2002-2004 Torrey T. Lyons. 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 - -#include <stdint.h> -#ifndef _ROOTLESSCOMMON_H -#define _ROOTLESSCOMMON_H - -#include "misc.h" -#include "rootless.h" -#include "fb.h" - -#include "scrnintstr.h" - -#include "picturestr.h" - - -// Debug output, or not. -#ifdef ROOTLESSDEBUG -#define RL_DEBUG_MSG ErrorF -#else -#define RL_DEBUG_MSG(a, ...) -#endif - - -// Global variables -extern DevPrivateKey rootlessGCPrivateKey; -extern DevPrivateKey rootlessScreenPrivateKey; -extern DevPrivateKey rootlessWindowPrivateKey; -extern DevPrivateKey rootlessWindowOldPixmapPrivateKey; - - -// RootlessGCRec: private per-gc data -typedef struct { - GCFuncs *originalFuncs; - GCOps *originalOps; -} RootlessGCRec; - - -// RootlessScreenRec: per-screen private data -typedef struct _RootlessScreenRec { - // Rootless implementation functions - RootlessFrameProcsPtr imp; - - // Wrapped screen functions - CreateScreenResourcesProcPtr CreateScreenResources; - CloseScreenProcPtr CloseScreen; - - CreateWindowProcPtr CreateWindow; - DestroyWindowProcPtr DestroyWindow; - RealizeWindowProcPtr RealizeWindow; - UnrealizeWindowProcPtr UnrealizeWindow; - MoveWindowProcPtr MoveWindow; - ResizeWindowProcPtr ResizeWindow; - RestackWindowProcPtr RestackWindow; - ReparentWindowProcPtr ReparentWindow; - ChangeBorderWidthProcPtr ChangeBorderWidth; - PositionWindowProcPtr PositionWindow; - ChangeWindowAttributesProcPtr ChangeWindowAttributes; - - CreateGCProcPtr CreateGC; - CopyWindowProcPtr CopyWindow; - GetImageProcPtr GetImage; - SourceValidateProcPtr SourceValidate; - - MarkOverlappedWindowsProcPtr MarkOverlappedWindows; - ValidateTreeProcPtr ValidateTree; - - SetShapeProcPtr SetShape; - - CompositeProcPtr Composite; - GlyphsProcPtr Glyphs; - - InstallColormapProcPtr InstallColormap; - UninstallColormapProcPtr UninstallColormap; - StoreColorsProcPtr StoreColors; - - void *pixmap_data; - unsigned int pixmap_data_size; - - ColormapPtr colormap; - - void *redisplay_timer; - unsigned int redisplay_timer_set :1; - unsigned int redisplay_queued :1; - unsigned int redisplay_expired :1; - unsigned int colormap_changed :1; -} RootlessScreenRec, *RootlessScreenPtr; - -// "Definition of the Porting Layer for the X11 Sample Server" says -// unwrap and rewrap of screen functions is unnecessary, but -// screen->CreateGC changes after a call to cfbCreateGC. - -#define SCREEN_UNWRAP(screen, fn) \ - screen->fn = SCREENREC(screen)->fn; - -#define SCREEN_WRAP(screen, fn) \ - SCREENREC(screen)->fn = screen->fn; \ - screen->fn = Rootless##fn - - -// Accessors for screen and window privates - -#define SCREENREC(pScreen) ((RootlessScreenRec *) \ - dixLookupPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey)) - -#define SETSCREENREC(pScreen, v) \ - dixSetPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey, v) - -#define WINREC(pWin) ((RootlessWindowRec *) \ - dixLookupPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey)) - -#define SETWINREC(pWin, v) \ - dixSetPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey, v) - -// Call a rootless implementation function. -// Many rootless implementation functions are allowed to be NULL. -#define CallFrameProc(pScreen, proc, params) \ - if (SCREENREC(pScreen)->frameProcs.proc) { \ - RL_DEBUG_MSG("calling frame proc " #proc " "); \ - SCREENREC(pScreen)->frameProcs.proc params; \ - } - - -// BoxRec manipulators -// Copied from shadowfb - -#define TRIM_BOX(box, pGC) { \ - BoxPtr extents = &pGC->pCompositeClip->extents;\ - if(box.x1 < extents->x1) box.x1 = extents->x1; \ - if(box.x2 > extents->x2) box.x2 = extents->x2; \ - if(box.y1 < extents->y1) box.y1 = extents->y1; \ - if(box.y2 > extents->y2) box.y2 = extents->y2; \ -} - -#define TRANSLATE_BOX(box, pDraw) { \ - box.x1 += pDraw->x; \ - box.x2 += pDraw->x; \ - box.y1 += pDraw->y; \ - box.y2 += pDraw->y; \ -} - -#define TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC) { \ - TRANSLATE_BOX(box, pDraw); \ - TRIM_BOX(box, pGC); \ -} - -#define BOX_NOT_EMPTY(box) \ - (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0)) - - -// HUGE_ROOT and NORMAL_ROOT -// We don't want to clip windows to the edge of the screen. -// HUGE_ROOT temporarily makes the root window really big. -// This is needed as a wrapper around any function that calls -// SetWinSize or SetBorderSize which clip a window against its -// parents, including the root. - -extern RegionRec rootlessHugeRoot; - -#define HUGE_ROOT(pWin) \ - do { \ - WindowPtr w = pWin; \ - while (w->parent) \ - w = w->parent; \ - saveRoot = w->winSize; \ - w->winSize = rootlessHugeRoot; \ - } while (0) - -#define NORMAL_ROOT(pWin) \ - do { \ - WindowPtr w = pWin; \ - while (w->parent) \ - w = w->parent; \ - w->winSize = saveRoot; \ - } while (0) - - -// Returns TRUE if this window is a top-level window (i.e. child of the root) -// The root is not a top-level window. -#define IsTopLevel(pWin) \ - ((pWin) && (pWin)->parent && !(pWin)->parent->parent) - -// Returns TRUE if this window is a root window -#define IsRoot(pWin) \ - ((pWin) == WindowTable[(pWin)->drawable.pScreen->myNum]) - - -/* - * SetPixmapBaseToScreen - * Move the given pixmap's base address to where pixel (0, 0) - * would be if the pixmap's actual data started at (x, y). - * Can't access the bits before the first word of the drawable's data in - * rootless mode, so make sure our base address is always 32-bit aligned. - */ -#define SetPixmapBaseToScreen(pix, _x, _y) { \ - PixmapPtr _pPix = (PixmapPtr) (pix); \ - _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \ - ((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \ - (int)(_y) * _pPix->devKind); \ - if (_pPix->drawable.bitsPerPixel != FB_UNIT) { \ - size_t _diff = ((size_t) _pPix->devPrivate.ptr) & \ - (FB_UNIT / CHAR_BIT - 1); \ - _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \ - _diff; \ - _pPix->drawable.x = _diff / \ - (_pPix->drawable.bitsPerPixel / CHAR_BIT); \ - } \ -} - - -// Returns TRUE if this window is visible inside a frame -// (e.g. it is visible and has a top-level or root parent) -Bool IsFramedWindow(WindowPtr pWin); - -// Routines that cause regions to get redrawn. -// DamageRegion and DamageRect are in global coordinates. -// DamageBox is in window-local coordinates. -void RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion); -void RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h); -void RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox); -void RootlessRedisplay(WindowPtr pWindow); -void RootlessRedisplayScreen(ScreenPtr pScreen); - -void RootlessQueueRedisplay(ScreenPtr pScreen); - -/* Return the colormap currently installed on the given screen. */ -ColormapPtr RootlessGetColormap (ScreenPtr pScreen); - -/* Convert colormap to ARGB. */ -Bool RootlessResolveColormap (ScreenPtr pScreen, int first_color, - int n_colors, uint32_t *colors); - -void RootlessFlushWindowColormap (WindowPtr pWin); -void RootlessFlushScreenColormaps (ScreenPtr pScreen); - -// Move a window to its proper location on the screen. -void RootlessRepositionWindow(WindowPtr pWin); - -// Move the window to it's correct place in the physical stacking order. -void RootlessReorderWindow(WindowPtr pWin); - -void RootlessScreenExpose (ScreenPtr pScreen); -void RootlessHideAllWindows (void); -void RootlessShowAllWindows (void); -void RootlessUpdateRooted (Bool state); - -void RootlessEnableRoot (ScreenPtr pScreen); -void RootlessDisableRoot (ScreenPtr pScreen); - -void RootlessSetPixmapOfAncestors(WindowPtr pWin); - -#endif /* _ROOTLESSCOMMON_H */ +/*
+ * Common internal rootless definitions and code
+ */
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2002-2004 Torrey T. Lyons. 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
+
+#include <stdint.h>
+#ifndef _ROOTLESSCOMMON_H
+#define _ROOTLESSCOMMON_H
+
+#include "misc.h"
+#include "rootless.h"
+#include "fb.h"
+
+#include "scrnintstr.h"
+
+#include "picturestr.h"
+
+
+// Debug output, or not.
+#ifdef ROOTLESSDEBUG
+#define RL_DEBUG_MSG ErrorF
+#else
+#define RL_DEBUG_MSG(a, ...)
+#endif
+
+
+// Global variables
+extern DevPrivateKeyRec rootlessGCPrivateKeyRec;
+#define rootlessGCPrivateKey (&rootlessGCPrivateKeyRec)
+
+extern DevPrivateKeyRec rootlessScreenPrivateKeyRec;
+#define rootlessScreenPrivateKey (&rootlessScreenPrivateKeyRec)
+
+extern DevPrivateKeyRec rootlessWindowPrivateKeyRec;
+#define rootlessWindowPrivateKey (&rootlessWindowPrivateKeyRec)
+
+extern DevPrivateKeyRec rootlessWindowOldPixmapPrivateKeyRec;
+#define rootlessWindowOldPixmapPrivateKey (&rootlessWindowOldPixmapPrivateKeyRec)
+
+
+// RootlessGCRec: private per-gc data
+typedef struct {
+ GCFuncs *originalFuncs;
+ GCOps *originalOps;
+} RootlessGCRec;
+
+
+// RootlessScreenRec: per-screen private data
+typedef struct _RootlessScreenRec {
+ // Rootless implementation functions
+ RootlessFrameProcsPtr imp;
+
+ // Wrapped screen functions
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ CloseScreenProcPtr CloseScreen;
+
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ MoveWindowProcPtr MoveWindow;
+ ResizeWindowProcPtr ResizeWindow;
+ RestackWindowProcPtr RestackWindow;
+ ReparentWindowProcPtr ReparentWindow;
+ ChangeBorderWidthProcPtr ChangeBorderWidth;
+ PositionWindowProcPtr PositionWindow;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+
+ CreateGCProcPtr CreateGC;
+ CopyWindowProcPtr CopyWindow;
+ GetImageProcPtr GetImage;
+ SourceValidateProcPtr SourceValidate;
+
+ MarkOverlappedWindowsProcPtr MarkOverlappedWindows;
+ ValidateTreeProcPtr ValidateTree;
+
+ SetShapeProcPtr SetShape;
+
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+
+ InstallColormapProcPtr InstallColormap;
+ UninstallColormapProcPtr UninstallColormap;
+ StoreColorsProcPtr StoreColors;
+
+ void *pixmap_data;
+ unsigned int pixmap_data_size;
+
+ ColormapPtr colormap;
+
+ void *redisplay_timer;
+ unsigned int redisplay_timer_set :1;
+ unsigned int redisplay_queued :1;
+ unsigned int redisplay_expired :1;
+ unsigned int colormap_changed :1;
+} RootlessScreenRec, *RootlessScreenPtr;
+
+// "Definition of the Porting Layer for the X11 Sample Server" says
+// unwrap and rewrap of screen functions is unnecessary, but
+// screen->CreateGC changes after a call to cfbCreateGC.
+
+#define SCREEN_UNWRAP(screen, fn) \
+ screen->fn = SCREENREC(screen)->fn;
+
+#define SCREEN_WRAP(screen, fn) \
+ SCREENREC(screen)->fn = screen->fn; \
+ screen->fn = Rootless##fn
+
+
+// Accessors for screen and window privates
+
+#define SCREENREC(pScreen) ((RootlessScreenRec *) \
+ dixLookupPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey))
+
+#define SETSCREENREC(pScreen, v) \
+ dixSetPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey, v)
+
+#define WINREC(pWin) ((RootlessWindowRec *) \
+ dixLookupPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey))
+
+#define SETWINREC(pWin, v) \
+ dixSetPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey, v)
+
+// Call a rootless implementation function.
+// Many rootless implementation functions are allowed to be NULL.
+#define CallFrameProc(pScreen, proc, params) \
+ if (SCREENREC(pScreen)->frameProcs.proc) { \
+ RL_DEBUG_MSG("calling frame proc " #proc " "); \
+ SCREENREC(pScreen)->frameProcs.proc params; \
+ }
+
+
+// BoxRec manipulators
+// Copied from shadowfb
+
+#define TRIM_BOX(box, pGC) { \
+ BoxPtr extents = &pGC->pCompositeClip->extents;\
+ if(box.x1 < extents->x1) box.x1 = extents->x1; \
+ if(box.x2 > extents->x2) box.x2 = extents->x2; \
+ if(box.y1 < extents->y1) box.y1 = extents->y1; \
+ if(box.y2 > extents->y2) box.y2 = extents->y2; \
+}
+
+#define TRANSLATE_BOX(box, pDraw) { \
+ box.x1 += pDraw->x; \
+ box.x2 += pDraw->x; \
+ box.y1 += pDraw->y; \
+ box.y2 += pDraw->y; \
+}
+
+#define TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC) { \
+ TRANSLATE_BOX(box, pDraw); \
+ TRIM_BOX(box, pGC); \
+}
+
+#define BOX_NOT_EMPTY(box) \
+ (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
+
+
+// HUGE_ROOT and NORMAL_ROOT
+// We don't want to clip windows to the edge of the screen.
+// HUGE_ROOT temporarily makes the root window really big.
+// This is needed as a wrapper around any function that calls
+// SetWinSize or SetBorderSize which clip a window against its
+// parents, including the root.
+
+extern RegionRec rootlessHugeRoot;
+
+#define HUGE_ROOT(pWin) \
+ do { \
+ WindowPtr w = pWin; \
+ while (w->parent) \
+ w = w->parent; \
+ saveRoot = w->winSize; \
+ w->winSize = rootlessHugeRoot; \
+ } while (0)
+
+#define NORMAL_ROOT(pWin) \
+ do { \
+ WindowPtr w = pWin; \
+ while (w->parent) \
+ w = w->parent; \
+ w->winSize = saveRoot; \
+ } while (0)
+
+
+// Returns TRUE if this window is a top-level window (i.e. child of the root)
+// The root is not a top-level window.
+#define IsTopLevel(pWin) \
+ ((pWin) && (pWin)->parent && !(pWin)->parent->parent)
+
+// Returns TRUE if this window is a root window
+#define IsRoot(pWin) \
+ ((pWin) == (pWin)->drawable.pScreen->root)
+
+
+/*
+ * SetPixmapBaseToScreen
+ * Move the given pixmap's base address to where pixel (0, 0)
+ * would be if the pixmap's actual data started at (x, y).
+ * Can't access the bits before the first word of the drawable's data in
+ * rootless mode, so make sure our base address is always 32-bit aligned.
+ */
+#define SetPixmapBaseToScreen(pix, _x, _y) { \
+ PixmapPtr _pPix = (PixmapPtr) (pix); \
+ _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
+ ((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \
+ (int)(_y) * _pPix->devKind); \
+ if (_pPix->drawable.bitsPerPixel != FB_UNIT) { \
+ size_t _diff = ((size_t) _pPix->devPrivate.ptr) & \
+ (FB_UNIT / CHAR_BIT - 1); \
+ _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
+ _diff; \
+ _pPix->drawable.x = _diff / \
+ (_pPix->drawable.bitsPerPixel / CHAR_BIT); \
+ } \
+}
+
+
+// Returns TRUE if this window is visible inside a frame
+// (e.g. it is visible and has a top-level or root parent)
+Bool IsFramedWindow(WindowPtr pWin);
+
+// Routines that cause regions to get redrawn.
+// DamageRegion and DamageRect are in global coordinates.
+// DamageBox is in window-local coordinates.
+void RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion);
+void RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h);
+void RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox);
+void RootlessRedisplay(WindowPtr pWindow);
+void RootlessRedisplayScreen(ScreenPtr pScreen);
+
+void RootlessQueueRedisplay(ScreenPtr pScreen);
+
+/* Return the colormap currently installed on the given screen. */
+ColormapPtr RootlessGetColormap (ScreenPtr pScreen);
+
+/* Convert colormap to ARGB. */
+Bool RootlessResolveColormap (ScreenPtr pScreen, int first_color,
+ int n_colors, uint32_t *colors);
+
+void RootlessFlushWindowColormap (WindowPtr pWin);
+void RootlessFlushScreenColormaps (ScreenPtr pScreen);
+
+// Move a window to its proper location on the screen.
+void RootlessRepositionWindow(WindowPtr pWin);
+
+// Move the window to it's correct place in the physical stacking order.
+void RootlessReorderWindow(WindowPtr pWin);
+
+void RootlessScreenExpose (ScreenPtr pScreen);
+void RootlessHideAllWindows (void);
+void RootlessShowAllWindows (void);
+void RootlessUpdateRooted (Bool state);
+
+void RootlessEnableRoot (ScreenPtr pScreen);
+void RootlessDisableRoot (ScreenPtr pScreen);
+
+void RootlessSetPixmapOfAncestors(WindowPtr pWin);
+
+#endif /* _ROOTLESSCOMMON_H */
diff --git a/xorg-server/miext/rootless/rootlessGC.c b/xorg-server/miext/rootless/rootlessGC.c index 5167f0ebe..cafd48aba 100644 --- a/xorg-server/miext/rootless/rootlessGC.c +++ b/xorg-server/miext/rootless/rootlessGC.c @@ -1,1500 +1,1500 @@ -/* - * Graphics Context support 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 - -#include <stddef.h> /* For NULL */ -#include "mi.h" -#include "scrnintstr.h" -#include "gcstruct.h" -#include "pixmapstr.h" -#include "windowstr.h" -#include "dixfontstr.h" -#include "mivalidate.h" -#include "fb.h" - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#include "rootlessCommon.h" - -#ifdef _MSC_VER -#define inline __inline -#endif - -// GC functions -static void RootlessValidateGC(GCPtr pGC, unsigned long changes, - DrawablePtr pDrawable); -static void RootlessChangeGC(GCPtr pGC, unsigned long mask); -static void RootlessCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); -static void RootlessDestroyGC(GCPtr pGC); -static void RootlessChangeClip(GCPtr pGC, int type, pointer pvalue, - int nrects); -static void RootlessDestroyClip(GCPtr pGC); -static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc); - -Bool RootlessCreateGC(GCPtr pGC); - -GCFuncs rootlessGCFuncs = { - RootlessValidateGC, - RootlessChangeGC, - RootlessCopyGC, - RootlessDestroyGC, - RootlessChangeClip, - RootlessDestroyClip, - RootlessCopyClip, -}; - -// GC operations -static void RootlessFillSpans(DrawablePtr dst, GCPtr pGC, int nInit, - DDXPointPtr pptInit, int *pwidthInit, - int sorted); -static void RootlessSetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc, - DDXPointPtr pptInit, int *pwidthInit, - int nspans, int sorted); -static void RootlessPutImage(DrawablePtr dst, GCPtr pGC, - int depth, int x, int y, int w, int h, - int leftPad, int format, char *pBits); -static RegionPtr RootlessCopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC, - int srcx, int srcy, int w, int h, - int dstx, int dsty); -static RegionPtr RootlessCopyPlane(DrawablePtr pSrc, DrawablePtr dst, - GCPtr pGC, int srcx, int srcy, - int w, int h, int dstx, int dsty, - unsigned long plane); -static void RootlessPolyPoint(DrawablePtr dst, GCPtr pGC, - int mode, int npt, DDXPointPtr pptInit); -static void RootlessPolylines(DrawablePtr dst, GCPtr pGC, - int mode, int npt, DDXPointPtr pptInit); -static void RootlessPolySegment(DrawablePtr dst, GCPtr pGC, - int nseg, xSegment *pSeg); -static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC, - int nRects, xRectangle *pRects); -static void RootlessPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs); -static void RootlessFillPolygon(DrawablePtr dst, GCPtr pGC, - int shape, int mode, int count, - DDXPointPtr pptInit); -static void RootlessPolyFillRect(DrawablePtr dst, GCPtr pGC, - int nRectsInit, xRectangle *pRectsInit); -static void RootlessPolyFillArc(DrawablePtr dst, GCPtr pGC, - int narcsInit, xArc *parcsInit); -static int RootlessPolyText8(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, char *chars); -static int RootlessPolyText16(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, unsigned short *chars); -static void RootlessImageText8(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, char *chars); -static void RootlessImageText16(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, unsigned short *chars); -static void RootlessImageGlyphBlt(DrawablePtr dst, GCPtr pGC, - int x, int y, unsigned int nglyphInit, - CharInfoPtr *ppciInit, pointer unused); -static void RootlessPolyGlyphBlt(DrawablePtr dst, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, pointer pglyphBase); -static void RootlessPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst, - int dx, int dy, int xOrg, int yOrg); - - -static GCOps rootlessGCOps = { - RootlessFillSpans, - RootlessSetSpans, - RootlessPutImage, - RootlessCopyArea, - RootlessCopyPlane, - RootlessPolyPoint, - RootlessPolylines, - RootlessPolySegment, - RootlessPolyRectangle, - RootlessPolyArc, - RootlessFillPolygon, - RootlessPolyFillRect, - RootlessPolyFillArc, - RootlessPolyText8, - RootlessPolyText16, - RootlessImageText8, - RootlessImageText16, - RootlessImageGlyphBlt, - RootlessPolyGlyphBlt, - RootlessPushPixels -}; - -/* - There are two issues we must contend with when drawing. These are - controlled with ROOTLESS_PROTECT_ALPHA and RootlessAccelInit(). - - If ROOTLESS_PROTECT_ALPHA is set, we have to make sure that the alpha - channel of the on screen windows is always opaque. fb makes this harder - than it would otherwise be by noticing that a planemask of 0x00ffffff - includes all bits when depth==24, and so it "optimizes" the planemask to - 0xffffffff. We work around this by temporarily setting depth=bpp while - changing the GC. - - So the normal situation (in 32 bit mode) is that the planemask is - 0x00ffffff and thus fb leaves the alpha channel alone. The rootless - implementation is responsible for setting the alpha channel opaque - initially. - - Unfortunately drawing with a planemask that doesn't have all bits set - normally causes fb to fall off its fastest paths when blitting and - filling. So we try to recognize when we can relax the planemask back to - 0xffffffff, and do that for the duration of the drawing operation, - setting the alpha channel in fg/bg pixels to opaque at the same time. We - can do this when drawing op is GXcopy. We can also do this when copying - from another window since its alpha channel must also be opaque. - - The other issue to consider is that the rootless implementation may - provide accelerated drawing functions if RootlessAccelInit() is called.For - some drawing primitives we swap in rootless acceleration functions, which - use the accelerated drawing functions where possible. - - Where both alpha protection and acceleration is used, it is even a bigger - win to relax the planemask to all ones because most accelerated drawing - functions can only be used in this case. However, even if we can't set - the planemask to all ones, we can still use the accelerated - CompositePixels function for GXcopy if it is a forward copy. This is - mainly intended for copying from pixmaps to windows. The CompositePixels - operation used sets alpha to 0xFF during the copy. - - The three macros below are used to implement this, potentially accelerated - drawing ops look something like this: - - OP { - GC_SAVE(gc); - GCOP_UNWRAP(gc); - - ... - - if (canAccelxxx(..) && otherwise-suitable) - GC_UNSET_PM(gc, dst); - - gc->funcs->OP(gc, ...); - - GC_RESTORE(gc, dst); - GCOP_WRAP(gc); - } - - */ - -#define GC_SAVE(pGC) \ - unsigned long _save_fg = (pGC)->fgPixel; \ - unsigned long _save_bg = (pGC)->bgPixel; \ - unsigned long _save_pm = (pGC)->planemask; \ - Bool _changed = FALSE - -#define GC_RESTORE(pGC, pDraw) \ - do { \ - if (_changed) { \ - unsigned int depth = (pDraw)->depth; \ - (pGC)->fgPixel = _save_fg; \ - (pGC)->bgPixel = _save_bg; \ - (pGC)->planemask = _save_pm; \ - (pDraw)->depth = (pDraw)->bitsPerPixel; \ - VALIDATE_GC(pGC, GCForeground | GCBackground | \ - GCPlaneMask, pDraw); \ - (pDraw)->depth = depth; \ - } \ - } while (0) - -#define GC_UNSET_PM(pGC, pDraw) \ - do { \ - unsigned int mask = RootlessAlphaMask ((pDraw)->bitsPerPixel); \ - if (((pGC)->planemask & mask) != mask) { \ - unsigned int depth = (pDraw)->depth; \ - (pGC)->fgPixel |= mask; \ - (pGC)->bgPixel |= mask; \ - (pGC)->planemask |= mask; \ - (pDraw)->depth = (pDraw)->bitsPerPixel; \ - VALIDATE_GC(pGC, GCForeground | \ - GCBackground | GCPlaneMask, pDraw); \ - (pDraw)->depth = depth; \ - _changed = TRUE; \ - } \ - } while (0) - -#define VALIDATE_GC(pGC, changes, pDrawable) \ - do { \ - pGC->funcs->ValidateGC(pGC, changes, pDrawable); \ - if (((WindowPtr) pDrawable)->viewable) { \ - gcrec->originalOps = pGC->ops; \ - } \ - } while(0) - -static RootlessWindowRec * -canAccelBlit (DrawablePtr pDraw, GCPtr pGC) -{ - WindowPtr pTop; - RootlessWindowRec *winRec; - unsigned int pm; - - if (pGC->alu != GXcopy) - return NULL; - - if (pDraw->type != DRAWABLE_WINDOW) - return NULL; - - pm = ~RootlessAlphaMask(pDraw->bitsPerPixel); - if ((pGC->planemask & pm) != pm) - return NULL; - - pTop = TopLevelParent((WindowPtr) pDraw); - if (pTop == NULL) - return NULL; - - winRec = WINREC(pTop); - if (winRec == NULL) - return NULL; - - return winRec; -} - -static inline RootlessWindowRec * -canAccelFill(DrawablePtr pDraw, GCPtr pGC) -{ - if (pGC->fillStyle != FillSolid) - return NULL; - - return canAccelBlit(pDraw, pGC); -} - -static unsigned int -boxBytes(DrawablePtr pDraw, BoxRec *box) -{ - unsigned int pixels; - - pixels = (box->x2 - box->x1) * (box->y2 - box->y1); - - return pixels * (pDraw->bitsPerPixel >> 3); -} - - -/* - * Screen function to create a graphics context - */ -Bool -RootlessCreateGC(GCPtr pGC) -{ - RootlessGCRec *gcrec; - RootlessScreenRec *s; - Bool result; - - SCREEN_UNWRAP(pGC->pScreen, CreateGC); - s = SCREENREC(pGC->pScreen); - result = s->CreateGC(pGC); - - gcrec = (RootlessGCRec *) - dixLookupPrivate(&pGC->devPrivates, rootlessGCPrivateKey); - gcrec->originalOps = NULL; // don't wrap ops yet - gcrec->originalFuncs = pGC->funcs; - pGC->funcs = &rootlessGCFuncs; - - SCREEN_WRAP(pGC->pScreen, CreateGC); - return result; -} - - -/* - * GC funcs - * - * These wrap lower level GC funcs. - * ValidateGC wraps the GC ops iff dest is viewable. - * All the others just unwrap and call. - */ - -// GCFUNC_UNRAP assumes funcs have been wrapped and -// does not assume ops have been wrapped -#define GCFUNC_UNWRAP(pGC) \ - RootlessGCRec *gcrec = (RootlessGCRec *) \ - dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \ - (pGC)->funcs = gcrec->originalFuncs; \ - if (gcrec->originalOps) { \ - (pGC)->ops = gcrec->originalOps; \ -} - -#define GCFUNC_WRAP(pGC) \ - gcrec->originalFuncs = (pGC)->funcs; \ - (pGC)->funcs = &rootlessGCFuncs; \ - if (gcrec->originalOps) { \ - gcrec->originalOps = (pGC)->ops; \ - (pGC)->ops = &rootlessGCOps; \ -} - - -static void -RootlessValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) -{ - GCFUNC_UNWRAP(pGC); - - gcrec->originalOps = NULL; - - if (pDrawable->type == DRAWABLE_WINDOW) - { -#ifdef ROOTLESS_PROTECT_ALPHA - unsigned int depth = pDrawable->depth; - - // We force a planemask so fb doesn't overwrite the alpha channel. - // Left to its own devices, fb will optimize away the planemask. - pDrawable->depth = pDrawable->bitsPerPixel; - pGC->planemask &= ~RootlessAlphaMask(pDrawable->bitsPerPixel); - VALIDATE_GC(pGC, changes | GCPlaneMask, pDrawable); - pDrawable->depth = depth; -#else - VALIDATE_GC(pGC, changes, pDrawable); -#endif - } else { - pGC->funcs->ValidateGC(pGC, changes, pDrawable); - } - - GCFUNC_WRAP(pGC); -} - -static void RootlessChangeGC(GCPtr pGC, unsigned long mask) -{ - GCFUNC_UNWRAP(pGC); - pGC->funcs->ChangeGC(pGC, mask); - GCFUNC_WRAP(pGC); -} - -static void RootlessCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) -{ - GCFUNC_UNWRAP(pGCDst); - pGCDst->funcs->CopyGC(pGCSrc, mask, pGCDst); - GCFUNC_WRAP(pGCDst); -} - -static void RootlessDestroyGC(GCPtr pGC) -{ - GCFUNC_UNWRAP(pGC); - pGC->funcs->DestroyGC(pGC); - GCFUNC_WRAP(pGC); -} - -static void RootlessChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects) -{ - GCFUNC_UNWRAP(pGC); - pGC->funcs->ChangeClip(pGC, type, pvalue, nrects); - GCFUNC_WRAP(pGC); -} - -static void RootlessDestroyClip(GCPtr pGC) -{ - GCFUNC_UNWRAP(pGC); - pGC->funcs->DestroyClip(pGC); - GCFUNC_WRAP(pGC); -} - -static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc) -{ - GCFUNC_UNWRAP(pgcDst); - pgcDst->funcs->CopyClip(pgcDst, pgcSrc); - GCFUNC_WRAP(pgcDst); -} - - -/* - * GC ops - * - * We can't use shadowfb because shadowfb assumes one pixmap - * and our root window is a special case. - * However, much of this code is copied from shadowfb. - */ - -// assumes both funcs and ops are wrapped -#define GCOP_UNWRAP(pGC) \ - RootlessGCRec *gcrec = (RootlessGCRec *) \ - dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \ - GCFuncs *saveFuncs = pGC->funcs; \ - (pGC)->funcs = gcrec->originalFuncs; \ - (pGC)->ops = gcrec->originalOps; - -#define GCOP_WRAP(pGC) \ - gcrec->originalOps = (pGC)->ops; \ - (pGC)->funcs = saveFuncs; \ - (pGC)->ops = &rootlessGCOps; - -static void -RootlessFillSpans(DrawablePtr dst, GCPtr pGC, int nInit, - DDXPointPtr pptInit, int *pwidthInit, int sorted) -{ - GC_SAVE(pGC); - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("fill spans start "); - - if (nInit <= 0) { - pGC->ops->FillSpans(dst, pGC, nInit, pptInit, pwidthInit, sorted); - } else { - DDXPointPtr ppt = pptInit; - int *pwidth = pwidthInit; - int i = nInit; - BoxRec box; - - box.x1 = ppt->x; - box.x2 = box.x1 + *pwidth; - box.y2 = box.y1 = ppt->y; - - while (--i) { - ppt++; - pwidth++; - if (box.x1 > ppt->x) - box.x1 = ppt->x; - if (box.x2 < (ppt->x + *pwidth)) - box.x2 = ppt->x + *pwidth; - if (box.y1 > ppt->y) - box.y1 = ppt->y; - else if (box.y2 < ppt->y) - box.y2 = ppt->y; - } - - box.y2++; - - RootlessStartDrawing((WindowPtr) dst); - - if (canAccelFill(dst, pGC) && - boxBytes(dst, &box) >= rootless_FillBytes_threshold) - { - GC_UNSET_PM(pGC, dst); - } - - pGC->ops->FillSpans(dst, pGC, nInit, pptInit, pwidthInit, sorted); - - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } - - GC_RESTORE(pGC, dst); - GCOP_WRAP(pGC); - RL_DEBUG_MSG("fill spans end\n"); -} - -static void -RootlessSetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc, - DDXPointPtr pptInit, int *pwidthInit, - int nspans, int sorted) -{ - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("set spans start "); - - if (nspans <= 0) { - pGC->ops->SetSpans(dst, pGC, pSrc, pptInit, pwidthInit, - nspans, sorted); - } else { - DDXPointPtr ppt = pptInit; - int *pwidth = pwidthInit; - int i = nspans; - BoxRec box; - - box.x1 = ppt->x; - box.x2 = box.x1 + *pwidth; - box.y2 = box.y1 = ppt->y; - - while (--i) { - ppt++; - pwidth++; - if (box.x1 > ppt->x) - box.x1 = ppt->x; - if (box.x2 < (ppt->x + *pwidth)) - box.x2 = ppt->x + *pwidth; - if (box.y1 > ppt->y) - box.y1 = ppt->y; - else if (box.y2 < ppt->y) - box.y2 = ppt->y; - } - - box.y2++; - - RootlessStartDrawing((WindowPtr) dst); - pGC->ops->SetSpans(dst, pGC, pSrc, pptInit, pwidthInit, - nspans, sorted); - - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } - GCOP_WRAP(pGC); - RL_DEBUG_MSG("set spans end\n"); -} - -static void -RootlessPutImage(DrawablePtr dst, GCPtr pGC, - int depth, int x, int y, int w, int h, - int leftPad, int format, char *pBits) -{ - BoxRec box; - - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("put image start "); - - RootlessStartDrawing((WindowPtr) dst); - pGC->ops->PutImage(dst, pGC, depth, x,y,w,h, leftPad, format, pBits); - - box.x1 = x + dst->x; - box.x2 = box.x1 + w; - box.y1 = y + dst->y; - box.y2 = box.y1 + h; - - TRIM_BOX(box, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - - GCOP_WRAP(pGC); - RL_DEBUG_MSG("put image end\n"); -} - -/* changed area is *dest* rect */ -static RegionPtr -RootlessCopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC, - int srcx, int srcy, int w, int h, - int dstx, int dsty) -{ - RegionPtr result; - BoxRec box; - - GC_SAVE(pGC); - GCOP_UNWRAP(pGC); - - RL_DEBUG_MSG("copy area start (src 0x%x, dst 0x%x)", pSrc, dst); - - if (pSrc->type == DRAWABLE_WINDOW && IsFramedWindow((WindowPtr)pSrc)) { - unsigned int bytes; - - /* If both source and dest are windows, and we're doing - a simple copy operation, we can remove the alpha-protecting - planemask (since source has opaque alpha as well) */ - - bytes = w * h * (pSrc->depth >> 3); - - if (bytes >= rootless_CopyBytes_threshold && canAccelBlit(pSrc, pGC)) - { - GC_UNSET_PM(pGC, dst); - } - - RootlessStartDrawing((WindowPtr) pSrc); - } - RootlessStartDrawing((WindowPtr) dst); - result = pGC->ops->CopyArea(pSrc, dst, pGC, srcx, srcy, w, h, dstx, dsty); - - box.x1 = dstx + dst->x; - box.x2 = box.x1 + w; - box.y1 = dsty + dst->y; - box.y2 = box.y1 + h; - - TRIM_BOX(box, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - - GC_RESTORE(pGC, dst); - GCOP_WRAP(pGC); - RL_DEBUG_MSG("copy area end\n"); - return result; -} - -/* changed area is *dest* rect */ -static RegionPtr RootlessCopyPlane(DrawablePtr pSrc, DrawablePtr dst, - GCPtr pGC, int srcx, int srcy, - int w, int h, int dstx, int dsty, - unsigned long plane) -{ - RegionPtr result; - BoxRec box; - - GCOP_UNWRAP(pGC); - - RL_DEBUG_MSG("copy plane start "); - - if (pSrc->type == DRAWABLE_WINDOW && IsFramedWindow((WindowPtr)pSrc)) { - RootlessStartDrawing((WindowPtr) pSrc); - } - RootlessStartDrawing((WindowPtr) dst); - result = pGC->ops->CopyPlane(pSrc, dst, pGC, srcx, srcy, w, h, - dstx, dsty, plane); - - box.x1 = dstx + dst->x; - box.x2 = box.x1 + w; - box.y1 = dsty + dst->y; - box.y2 = box.y1 + h; - - TRIM_BOX(box, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - - GCOP_WRAP(pGC); - RL_DEBUG_MSG("copy plane end\n"); - return result; -} - -// Options for size of changed area: -// 0 = box per point -// 1 = big box around all points -// 2 = accumulate point in 20 pixel radius -#define ROOTLESS_CHANGED_AREA 1 -#define abs(a) ((a) > 0 ? (a) : -(a)) - -/* changed area is box around all points */ -static void RootlessPolyPoint(DrawablePtr dst, GCPtr pGC, - int mode, int npt, DDXPointPtr pptInit) -{ - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("polypoint start "); - - RootlessStartDrawing((WindowPtr) dst); - pGC->ops->PolyPoint(dst, pGC, mode, npt, pptInit); - - if (npt > 0) { -#if ROOTLESS_CHANGED_AREA==0 - // box per point - BoxRec box; - - while (npt) { - box.x1 = pptInit->x; - box.y1 = pptInit->y; - box.x2 = box.x1 + 1; - box.y2 = box.y1 + 1; - - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - - npt--; - pptInit++; - } - -#elif ROOTLESS_CHANGED_AREA==1 - // one big box - BoxRec box; - - box.x2 = box.x1 = pptInit->x; - box.y2 = box.y1 = pptInit->y; - while (--npt) { - pptInit++; - if (box.x1 > pptInit->x) - box.x1 = pptInit->x; - else if (box.x2 < pptInit->x) - box.x2 = pptInit->x; - if (box.y1 > pptInit->y) - box.y1 = pptInit->y; - else if (box.y2 < pptInit->y) - box.y2 = pptInit->y; - } - - box.x2++; - box.y2++; - - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - -#elif ROOTLESS_CHANGED_AREA==2 - // clever(?) method: accumulate point in 20-pixel radius - BoxRec box; - int firstx, firsty; - - box.x2 = box.x1 = firstx = pptInit->x; - box.y2 = box.y1 = firsty = pptInit->y; - while (--npt) { - pptInit++; - if (abs(pptInit->x - firstx) > 20 || - abs(pptInit->y - firsty) > 20) { - box.x2++; - box.y2++; - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - box.x2 = box.x1 = firstx = pptInit->x; - box.y2 = box.y1 = firsty = pptInit->y; - } else { - if (box.x1 > pptInit->x) box.x1 = pptInit->x; - else if (box.x2 < pptInit->x) box.x2 = pptInit->x; - if (box.y1 > pptInit->y) box.y1 = pptInit->y; - else if (box.y2 < pptInit->y) box.y2 = pptInit->y; - } - } - box.x2++; - box.y2++; - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox((WindowPtr) dst, &box); -#endif /* ROOTLESS_CHANGED_AREA */ - } - - GCOP_WRAP(pGC); - RL_DEBUG_MSG("polypoint end\n"); -} - -#undef ROOTLESS_CHANGED_AREA - -/* changed area is box around each line */ -static void RootlessPolylines(DrawablePtr dst, GCPtr pGC, - int mode, int npt, DDXPointPtr pptInit) -{ - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("poly lines start "); - - RootlessStartDrawing((WindowPtr) dst); - pGC->ops->Polylines(dst, pGC, mode, npt, pptInit); - - if (npt > 0) { - BoxRec box; - int extra = pGC->lineWidth >> 1; - - box.x2 = box.x1 = pptInit->x; - box.y2 = box.y1 = pptInit->y; - - if (npt > 1) { - if (pGC->joinStyle == JoinMiter) - extra = 6 * pGC->lineWidth; - else if (pGC->capStyle == CapProjecting) - extra = pGC->lineWidth; - } - - if (mode == CoordModePrevious) { - int x = box.x1; - int y = box.y1; - - while (--npt) { - pptInit++; - x += pptInit->x; - y += pptInit->y; - if (box.x1 > x) - box.x1 = x; - else if (box.x2 < x) - box.x2 = x; - if (box.y1 > y) - box.y1 = y; - else if (box.y2 < y) - box.y2 = y; - } - } else { - while (--npt) { - pptInit++; - if (box.x1 > pptInit->x) - box.x1 = pptInit->x; - else if (box.x2 < pptInit->x) - box.x2 = pptInit->x; - if (box.y1 > pptInit->y) - box.y1 = pptInit->y; - else if (box.y2 < pptInit->y) - box.y2 = pptInit->y; - } - } - - box.x2++; - box.y2++; - - if (extra) { - box.x1 -= extra; - box.x2 += extra; - box.y1 -= extra; - box.y2 += extra; - } - - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } - - GCOP_WRAP(pGC); - RL_DEBUG_MSG("poly lines end\n"); -} - -/* changed area is box around each line segment */ -static void RootlessPolySegment(DrawablePtr dst, GCPtr pGC, - int nseg, xSegment *pSeg) -{ - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("poly segment start (win 0x%x)", dst); - - RootlessStartDrawing((WindowPtr) dst); - pGC->ops->PolySegment(dst, pGC, nseg, pSeg); - - if (nseg > 0) { - BoxRec box; - int extra = pGC->lineWidth; - - if (pGC->capStyle != CapProjecting) - extra >>= 1; - - if (pSeg->x2 > pSeg->x1) { - box.x1 = pSeg->x1; - box.x2 = pSeg->x2; - } else { - box.x2 = pSeg->x1; - box.x1 = pSeg->x2; - } - - if (pSeg->y2 > pSeg->y1) { - box.y1 = pSeg->y1; - box.y2 = pSeg->y2; - } else { - box.y2 = pSeg->y1; - box.y1 = pSeg->y2; - } - - while (--nseg) { - pSeg++; - if (pSeg->x2 > pSeg->x1) { - if (pSeg->x1 < box.x1) box.x1 = pSeg->x1; - if (pSeg->x2 > box.x2) box.x2 = pSeg->x2; - } else { - if (pSeg->x2 < box.x1) box.x1 = pSeg->x2; - if (pSeg->x1 > box.x2) box.x2 = pSeg->x1; - } - if (pSeg->y2 > pSeg->y1) { - if (pSeg->y1 < box.y1) box.y1 = pSeg->y1; - if (pSeg->y2 > box.y2) box.y2 = pSeg->y2; - } else { - if (pSeg->y2 < box.y1) box.y1 = pSeg->y2; - if (pSeg->y1 > box.y2) box.y2 = pSeg->y1; - } - } - - box.x2++; - box.y2++; - - if (extra) { - box.x1 -= extra; - box.x2 += extra; - box.y1 -= extra; - box.y2 += extra; - } - - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } - - GCOP_WRAP(pGC); - RL_DEBUG_MSG("poly segment end\n"); -} - -/* changed area is box around each line (not entire rects) */ -static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC, - int nRects, xRectangle *pRects) -{ - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("poly rectangle start "); - - RootlessStartDrawing((WindowPtr) dst); - pGC->ops->PolyRectangle(dst, pGC, nRects, pRects); - - if (nRects > 0) { - BoxRec box; - int offset1, offset2, offset3; - - offset2 = pGC->lineWidth; - if (!offset2) offset2 = 1; - offset1 = offset2 >> 1; - offset3 = offset2 - offset1; - - while (nRects--) { - box.x1 = pRects->x - offset1; - box.y1 = pRects->y - offset1; - box.x2 = box.x1 + pRects->width + offset2; - box.y2 = box.y1 + offset2; - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - - box.x1 = pRects->x - offset1; - box.y1 = pRects->y + offset3; - box.x2 = box.x1 + offset2; - box.y2 = box.y1 + pRects->height - offset2; - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - - box.x1 = pRects->x + pRects->width - offset1; - box.y1 = pRects->y + offset3; - box.x2 = box.x1 + offset2; - box.y2 = box.y1 + pRects->height - offset2; - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - - box.x1 = pRects->x - offset1; - box.y1 = pRects->y + pRects->height - offset1; - box.x2 = box.x1 + pRects->width + offset2; - box.y2 = box.y1 + offset2; - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - - pRects++; - } - } - - GCOP_WRAP(pGC); - RL_DEBUG_MSG("poly rectangle end\n"); -} - - -/* changed area is box around each arc (assumes all arcs are 360 degrees) */ -static void RootlessPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs) -{ - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("poly arc start "); - - RootlessStartDrawing((WindowPtr) dst); - pGC->ops->PolyArc(dst, pGC, narcs, parcs); - - if (narcs > 0) { - int extra = pGC->lineWidth >> 1; - BoxRec box; - - box.x1 = parcs->x; - box.x2 = box.x1 + parcs->width; - box.y1 = parcs->y; - box.y2 = box.y1 + parcs->height; - - /* should I break these up instead ? */ - - while (--narcs) { - parcs++; - if (box.x1 > parcs->x) - box.x1 = parcs->x; - if (box.x2 < (parcs->x + parcs->width)) - box.x2 = parcs->x + parcs->width; - if (box.y1 > parcs->y) - box.y1 = parcs->y; - if (box.y2 < (parcs->y + parcs->height)) - box.y2 = parcs->y + parcs->height; - } - - if (extra) { - box.x1 -= extra; - box.x2 += extra; - box.y1 -= extra; - box.y2 += extra; - } - - box.x2++; - box.y2++; - - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } - - GCOP_WRAP(pGC); - RL_DEBUG_MSG("poly arc end\n"); -} - - -/* changed area is box around each poly */ -static void RootlessFillPolygon(DrawablePtr dst, GCPtr pGC, - int shape, int mode, int count, - DDXPointPtr pptInit) -{ - GC_SAVE(pGC); - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("fill poly start (win 0x%x, fillStyle 0x%x)", dst, - pGC->fillStyle); - - if (count <= 2) { - pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pptInit); - } else { - DDXPointPtr ppt = pptInit; - int i = count; - BoxRec box; - - box.x2 = box.x1 = ppt->x; - box.y2 = box.y1 = ppt->y; - - if (mode != CoordModeOrigin) { - int x = box.x1; - int y = box.y1; - - while (--i) { - ppt++; - x += ppt->x; - y += ppt->y; - if (box.x1 > x) - box.x1 = x; - else if (box.x2 < x) - box.x2 = x; - if (box.y1 > y) - box.y1 = y; - else if (box.y2 < y) - box.y2 = y; - } - } else { - while (--i) { - ppt++; - if (box.x1 > ppt->x) - box.x1 = ppt->x; - else if (box.x2 < ppt->x) - box.x2 = ppt->x; - if (box.y1 > ppt->y) - box.y1 = ppt->y; - else if (box.y2 < ppt->y) - box.y2 = ppt->y; - } - } - - box.x2++; - box.y2++; - - RootlessStartDrawing((WindowPtr) dst); - - if (canAccelFill(dst, pGC) && - boxBytes(dst, &box) >= rootless_FillBytes_threshold) - { - GC_UNSET_PM(pGC, dst); - } - - pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pptInit); - - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } - - GC_RESTORE(pGC, dst); - GCOP_WRAP(pGC); - RL_DEBUG_MSG("fill poly end\n"); -} - -/* changed area is the rects */ -static void RootlessPolyFillRect(DrawablePtr dst, GCPtr pGC, - int nRectsInit, xRectangle *pRectsInit) -{ - GC_SAVE(pGC); - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("fill rect start (win 0x%x, fillStyle 0x%x)", dst, - pGC->fillStyle); - - if (nRectsInit <= 0) { - pGC->ops->PolyFillRect(dst, pGC, nRectsInit, pRectsInit); - } else { - BoxRec box; - xRectangle *pRects = pRectsInit; - int nRects = nRectsInit; - - box.x1 = pRects->x; - box.x2 = box.x1 + pRects->width; - box.y1 = pRects->y; - box.y2 = box.y1 + pRects->height; - - while (--nRects) { - pRects++; - if (box.x1 > pRects->x) - box.x1 = pRects->x; - if (box.x2 < (pRects->x + pRects->width)) - box.x2 = pRects->x + pRects->width; - if (box.y1 > pRects->y) - box.y1 = pRects->y; - if (box.y2 < (pRects->y + pRects->height)) - box.y2 = pRects->y + pRects->height; - } - - RootlessStartDrawing((WindowPtr) dst); - - if (canAccelFill(dst, pGC) && - boxBytes(dst, &box) >= rootless_FillBytes_threshold) - { - GC_UNSET_PM(pGC, dst); - } - - pGC->ops->PolyFillRect(dst, pGC, nRectsInit, pRectsInit); - - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } - - GC_RESTORE(pGC, dst); - GCOP_WRAP(pGC); - RL_DEBUG_MSG("fill rect end\n"); -} - - -/* changed area is box around each arc (assuming arcs are all 360 degrees) */ -static void RootlessPolyFillArc(DrawablePtr dst, GCPtr pGC, - int narcsInit, xArc *parcsInit) -{ - GC_SAVE(pGC); - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("fill arc start "); - - if (narcsInit > 0) { - BoxRec box; - int narcs = narcsInit; - xArc *parcs = parcsInit; - - box.x1 = parcs->x; - box.x2 = box.x1 + parcs->width; - box.y1 = parcs->y; - box.y2 = box.y1 + parcs->height; - - /* should I break these up instead ? */ - - while (--narcs) { - parcs++; - if (box.x1 > parcs->x) - box.x1 = parcs->x; - if (box.x2 < (parcs->x + parcs->width)) - box.x2 = parcs->x + parcs->width; - if (box.y1 > parcs->y) - box.y1 = parcs->y; - if (box.y2 < (parcs->y + parcs->height)) - box.y2 = parcs->y + parcs->height; - } - - RootlessStartDrawing((WindowPtr) dst); - - if (canAccelFill(dst, pGC) && - boxBytes(dst, &box) >= rootless_FillBytes_threshold) - { - GC_UNSET_PM(pGC, dst); - } - - pGC->ops->PolyFillArc(dst, pGC, narcsInit, parcsInit); - - TRIM_AND_TRANSLATE_BOX(box, dst, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } else { - pGC->ops->PolyFillArc(dst, pGC, narcsInit, parcsInit); - } - - GC_RESTORE(pGC, dst); - GCOP_WRAP(pGC); - RL_DEBUG_MSG("fill arc end\n"); -} - - -static void RootlessImageText8(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, char *chars) -{ - GC_SAVE(pGC); - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("imagetext8 start "); - - if (count > 0) { - int top, bot, Min, Max; - BoxRec box; - - top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font)); - bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font)); - - Min = count * FONTMINBOUNDS(pGC->font, characterWidth); - if (Min > 0) Min = 0; - Max = count * FONTMAXBOUNDS(pGC->font, characterWidth); - if (Max < 0) Max = 0; - - /* ugh */ - box.x1 = dst->x + x + Min + - FONTMINBOUNDS(pGC->font, leftSideBearing); - box.x2 = dst->x + x + Max + - FONTMAXBOUNDS(pGC->font, rightSideBearing); - - box.y1 = dst->y + y - top; - box.y2 = dst->y + y + bot; - - RootlessStartDrawing((WindowPtr) dst); - - if (canAccelFill(dst, pGC) && - boxBytes(dst, &box) >= rootless_FillBytes_threshold) - { - GC_UNSET_PM(pGC, dst); - } - - pGC->ops->ImageText8(dst, pGC, x, y, count, chars); - - TRIM_BOX(box, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } else { - pGC->ops->ImageText8(dst, pGC, x, y, count, chars); - } - - GC_RESTORE(pGC, dst); - GCOP_WRAP(pGC); - RL_DEBUG_MSG("imagetext8 end\n"); -} - -static int RootlessPolyText8(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, char *chars) -{ - int width; // the result, sorta - - GCOP_UNWRAP(pGC); - - RL_DEBUG_MSG("polytext8 start "); - - RootlessStartDrawing((WindowPtr) dst); - width = pGC->ops->PolyText8(dst, pGC, x, y, count, chars); - width -= x; - - if (width > 0) { - BoxRec box; - - /* ugh */ - box.x1 = dst->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing); - box.x2 = dst->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing); - - if (count > 1) { - if (width > 0) box.x2 += width; - else box.x1 += width; - } - - box.y1 = dst->y + y - FONTMAXBOUNDS(pGC->font, ascent); - box.y2 = dst->y + y + FONTMAXBOUNDS(pGC->font, descent); - - TRIM_BOX(box, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } - - GCOP_WRAP(pGC); - RL_DEBUG_MSG("polytext8 end\n"); - return (width + x); -} - -static void RootlessImageText16(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, unsigned short *chars) -{ - GC_SAVE(pGC); - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("imagetext16 start "); - - if (count > 0) { - int top, bot, Min, Max; - BoxRec box; - - top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font)); - bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font)); - - Min = count * FONTMINBOUNDS(pGC->font, characterWidth); - if (Min > 0) Min = 0; - Max = count * FONTMAXBOUNDS(pGC->font, characterWidth); - if (Max < 0) Max = 0; - - /* ugh */ - box.x1 = dst->x + x + Min + - FONTMINBOUNDS(pGC->font, leftSideBearing); - box.x2 = dst->x + x + Max + - FONTMAXBOUNDS(pGC->font, rightSideBearing); - - box.y1 = dst->y + y - top; - box.y2 = dst->y + y + bot; - - RootlessStartDrawing((WindowPtr) dst); - - if (canAccelFill(dst, pGC) && - boxBytes(dst, &box) >= rootless_FillBytes_threshold) - { - GC_UNSET_PM(pGC, dst); - } - - pGC->ops->ImageText16(dst, pGC, x, y, count, chars); - - TRIM_BOX(box, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } else { - pGC->ops->ImageText16(dst, pGC, x, y, count, chars); - } - - GC_RESTORE(pGC, dst); - GCOP_WRAP(pGC); - RL_DEBUG_MSG("imagetext16 end\n"); -} - -static int RootlessPolyText16(DrawablePtr dst, GCPtr pGC, - int x, int y, int count, unsigned short *chars) -{ - int width; // the result, sorta - - GCOP_UNWRAP(pGC); - - RL_DEBUG_MSG("polytext16 start "); - - RootlessStartDrawing((WindowPtr) dst); - width = pGC->ops->PolyText16(dst, pGC, x, y, count, chars); - width -= x; - - if (width > 0) { - BoxRec box; - - /* ugh */ - box.x1 = dst->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing); - box.x2 = dst->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing); - - if (count > 1) { - if (width > 0) box.x2 += width; - else box.x1 += width; - } - - box.y1 = dst->y + y - FONTMAXBOUNDS(pGC->font, ascent); - box.y2 = dst->y + y + FONTMAXBOUNDS(pGC->font, descent); - - TRIM_BOX(box, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } - - GCOP_WRAP(pGC); - RL_DEBUG_MSG("polytext16 end\n"); - return width + x; -} - -static void RootlessImageGlyphBlt(DrawablePtr dst, GCPtr pGC, - int x, int y, unsigned int nglyphInit, - CharInfoPtr *ppciInit, pointer unused) -{ - GC_SAVE(pGC); - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("imageglyph start "); - - if (nglyphInit > 0) { - int top, bot, width = 0; - BoxRec box; - unsigned int nglyph = nglyphInit; - CharInfoPtr *ppci = ppciInit; - - top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font)); - bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font)); - - box.x1 = ppci[0]->metrics.leftSideBearing; - if (box.x1 > 0) box.x1 = 0; - box.x2 = ppci[nglyph - 1]->metrics.rightSideBearing - - ppci[nglyph - 1]->metrics.characterWidth; - if (box.x2 < 0) box.x2 = 0; - - box.x2 += dst->x + x; - box.x1 += dst->x + x; - - while (nglyph--) { - width += (*ppci)->metrics.characterWidth; - ppci++; - } - - if (width > 0) - box.x2 += width; - else - box.x1 += width; - - box.y1 = dst->y + y - top; - box.y2 = dst->y + y + bot; - - RootlessStartDrawing((WindowPtr) dst); - - if (canAccelFill(dst, pGC) && - boxBytes(dst, &box) >= rootless_FillBytes_threshold) - { - GC_UNSET_PM(pGC, dst); - } - - pGC->ops->ImageGlyphBlt(dst, pGC, x, y, nglyphInit, ppciInit, unused); - - TRIM_BOX(box, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } else { - pGC->ops->ImageGlyphBlt(dst, pGC, x, y, nglyphInit, ppciInit, unused); - } - - GC_RESTORE(pGC, dst); - GCOP_WRAP(pGC); - RL_DEBUG_MSG("imageglyph end\n"); -} - -static void RootlessPolyGlyphBlt(DrawablePtr dst, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, pointer pglyphBase) -{ - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("polyglyph start "); - - RootlessStartDrawing((WindowPtr) dst); - pGC->ops->PolyGlyphBlt(dst, pGC, x, y, nglyph, ppci, pglyphBase); - - if (nglyph > 0) { - BoxRec box; - - /* ugh */ - box.x1 = dst->x + x + ppci[0]->metrics.leftSideBearing; - box.x2 = dst->x + x + ppci[nglyph - 1]->metrics.rightSideBearing; - - if (nglyph > 1) { - int width = 0; - - while (--nglyph) { - width += (*ppci)->metrics.characterWidth; - ppci++; - } - - if (width > 0) box.x2 += width; - else box.x1 += width; - } - - box.y1 = dst->y + y - FONTMAXBOUNDS(pGC->font, ascent); - box.y2 = dst->y + y + FONTMAXBOUNDS(pGC->font, descent); - - TRIM_BOX(box, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - } - - GCOP_WRAP(pGC); - RL_DEBUG_MSG("polyglyph end\n"); -} - - -/* changed area is in dest */ -static void -RootlessPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst, - int dx, int dy, int xOrg, int yOrg) -{ - BoxRec box; - - GCOP_UNWRAP(pGC); - RL_DEBUG_MSG("push pixels start "); - - RootlessStartDrawing((WindowPtr) dst); - pGC->ops->PushPixels(pGC, pBitMap, dst, dx, dy, xOrg, yOrg); - - box.x1 = xOrg + dst->x; - box.x2 = box.x1 + dx; - box.y1 = yOrg + dst->y; - box.y2 = box.y1 + dy; - - TRIM_BOX(box, pGC); - if (BOX_NOT_EMPTY(box)) - RootlessDamageBox ((WindowPtr) dst, &box); - - GCOP_WRAP(pGC); - RL_DEBUG_MSG("push pixels end\n"); -} +/*
+ * Graphics Context support 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
+
+#include <stddef.h> /* For NULL */
+#include "mi.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "dixfontstr.h"
+#include "mivalidate.h"
+#include "fb.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "rootlessCommon.h"
+
+#ifdef _MSC_VER
+#define inline __inline
+#endif
+
+// GC functions
+static void RootlessValidateGC(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDrawable);
+static void RootlessChangeGC(GCPtr pGC, unsigned long mask);
+static void RootlessCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
+static void RootlessDestroyGC(GCPtr pGC);
+static void RootlessChangeClip(GCPtr pGC, int type, pointer pvalue,
+ int nrects);
+static void RootlessDestroyClip(GCPtr pGC);
+static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
+
+Bool RootlessCreateGC(GCPtr pGC);
+
+GCFuncs rootlessGCFuncs = {
+ RootlessValidateGC,
+ RootlessChangeGC,
+ RootlessCopyGC,
+ RootlessDestroyGC,
+ RootlessChangeClip,
+ RootlessDestroyClip,
+ RootlessCopyClip,
+};
+
+// GC operations
+static void RootlessFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
+ DDXPointPtr pptInit, int *pwidthInit,
+ int sorted);
+static void RootlessSetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc,
+ DDXPointPtr pptInit, int *pwidthInit,
+ int nspans, int sorted);
+static void RootlessPutImage(DrawablePtr dst, GCPtr pGC,
+ int depth, int x, int y, int w, int h,
+ int leftPad, int format, char *pBits);
+static RegionPtr RootlessCopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
+ int srcx, int srcy, int w, int h,
+ int dstx, int dsty);
+static RegionPtr RootlessCopyPlane(DrawablePtr pSrc, DrawablePtr dst,
+ GCPtr pGC, int srcx, int srcy,
+ int w, int h, int dstx, int dsty,
+ unsigned long plane);
+static void RootlessPolyPoint(DrawablePtr dst, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit);
+static void RootlessPolylines(DrawablePtr dst, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit);
+static void RootlessPolySegment(DrawablePtr dst, GCPtr pGC,
+ int nseg, xSegment *pSeg);
+static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC,
+ int nRects, xRectangle *pRects);
+static void RootlessPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs);
+static void RootlessFillPolygon(DrawablePtr dst, GCPtr pGC,
+ int shape, int mode, int count,
+ DDXPointPtr pptInit);
+static void RootlessPolyFillRect(DrawablePtr dst, GCPtr pGC,
+ int nRectsInit, xRectangle *pRectsInit);
+static void RootlessPolyFillArc(DrawablePtr dst, GCPtr pGC,
+ int narcsInit, xArc *parcsInit);
+static int RootlessPolyText8(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, char *chars);
+static int RootlessPolyText16(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+static void RootlessImageText8(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, char *chars);
+static void RootlessImageText16(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+static void RootlessImageGlyphBlt(DrawablePtr dst, GCPtr pGC,
+ int x, int y, unsigned int nglyphInit,
+ CharInfoPtr *ppciInit, pointer unused);
+static void RootlessPolyGlyphBlt(DrawablePtr dst, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase);
+static void RootlessPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst,
+ int dx, int dy, int xOrg, int yOrg);
+
+
+static GCOps rootlessGCOps = {
+ RootlessFillSpans,
+ RootlessSetSpans,
+ RootlessPutImage,
+ RootlessCopyArea,
+ RootlessCopyPlane,
+ RootlessPolyPoint,
+ RootlessPolylines,
+ RootlessPolySegment,
+ RootlessPolyRectangle,
+ RootlessPolyArc,
+ RootlessFillPolygon,
+ RootlessPolyFillRect,
+ RootlessPolyFillArc,
+ RootlessPolyText8,
+ RootlessPolyText16,
+ RootlessImageText8,
+ RootlessImageText16,
+ RootlessImageGlyphBlt,
+ RootlessPolyGlyphBlt,
+ RootlessPushPixels
+};
+
+/*
+ There are two issues we must contend with when drawing. These are
+ controlled with ROOTLESS_PROTECT_ALPHA and RootlessAccelInit().
+
+ If ROOTLESS_PROTECT_ALPHA is set, we have to make sure that the alpha
+ channel of the on screen windows is always opaque. fb makes this harder
+ than it would otherwise be by noticing that a planemask of 0x00ffffff
+ includes all bits when depth==24, and so it "optimizes" the planemask to
+ 0xffffffff. We work around this by temporarily setting depth=bpp while
+ changing the GC.
+
+ So the normal situation (in 32 bit mode) is that the planemask is
+ 0x00ffffff and thus fb leaves the alpha channel alone. The rootless
+ implementation is responsible for setting the alpha channel opaque
+ initially.
+
+ Unfortunately drawing with a planemask that doesn't have all bits set
+ normally causes fb to fall off its fastest paths when blitting and
+ filling. So we try to recognize when we can relax the planemask back to
+ 0xffffffff, and do that for the duration of the drawing operation,
+ setting the alpha channel in fg/bg pixels to opaque at the same time. We
+ can do this when drawing op is GXcopy. We can also do this when copying
+ from another window since its alpha channel must also be opaque.
+
+ The other issue to consider is that the rootless implementation may
+ provide accelerated drawing functions if RootlessAccelInit() is called.For
+ some drawing primitives we swap in rootless acceleration functions, which
+ use the accelerated drawing functions where possible.
+
+ Where both alpha protection and acceleration is used, it is even a bigger
+ win to relax the planemask to all ones because most accelerated drawing
+ functions can only be used in this case. However, even if we can't set
+ the planemask to all ones, we can still use the accelerated
+ CompositePixels function for GXcopy if it is a forward copy. This is
+ mainly intended for copying from pixmaps to windows. The CompositePixels
+ operation used sets alpha to 0xFF during the copy.
+
+ The three macros below are used to implement this, potentially accelerated
+ drawing ops look something like this:
+
+ OP {
+ GC_SAVE(gc);
+ GCOP_UNWRAP(gc);
+
+ ...
+
+ if (canAccelxxx(..) && otherwise-suitable)
+ GC_UNSET_PM(gc, dst);
+
+ gc->funcs->OP(gc, ...);
+
+ GC_RESTORE(gc, dst);
+ GCOP_WRAP(gc);
+ }
+
+ */
+
+#define GC_SAVE(pGC) \
+ unsigned long _save_fg = (pGC)->fgPixel; \
+ unsigned long _save_bg = (pGC)->bgPixel; \
+ unsigned long _save_pm = (pGC)->planemask; \
+ Bool _changed = FALSE
+
+#define GC_RESTORE(pGC, pDraw) \
+ do { \
+ if (_changed) { \
+ unsigned int depth = (pDraw)->depth; \
+ (pGC)->fgPixel = _save_fg; \
+ (pGC)->bgPixel = _save_bg; \
+ (pGC)->planemask = _save_pm; \
+ (pDraw)->depth = (pDraw)->bitsPerPixel; \
+ VALIDATE_GC(pGC, GCForeground | GCBackground | \
+ GCPlaneMask, pDraw); \
+ (pDraw)->depth = depth; \
+ } \
+ } while (0)
+
+#define GC_UNSET_PM(pGC, pDraw) \
+ do { \
+ unsigned int mask = RootlessAlphaMask ((pDraw)->bitsPerPixel); \
+ if (((pGC)->planemask & mask) != mask) { \
+ unsigned int depth = (pDraw)->depth; \
+ (pGC)->fgPixel |= mask; \
+ (pGC)->bgPixel |= mask; \
+ (pGC)->planemask |= mask; \
+ (pDraw)->depth = (pDraw)->bitsPerPixel; \
+ VALIDATE_GC(pGC, GCForeground | \
+ GCBackground | GCPlaneMask, pDraw); \
+ (pDraw)->depth = depth; \
+ _changed = TRUE; \
+ } \
+ } while (0)
+
+#define VALIDATE_GC(pGC, changes, pDrawable) \
+ do { \
+ pGC->funcs->ValidateGC(pGC, changes, pDrawable); \
+ if (((WindowPtr) pDrawable)->viewable) { \
+ gcrec->originalOps = pGC->ops; \
+ } \
+ } while(0)
+
+static RootlessWindowRec *
+canAccelBlit (DrawablePtr pDraw, GCPtr pGC)
+{
+ WindowPtr pTop;
+ RootlessWindowRec *winRec;
+ unsigned int pm;
+
+ if (pGC->alu != GXcopy)
+ return NULL;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return NULL;
+
+ pm = ~RootlessAlphaMask(pDraw->bitsPerPixel);
+ if ((pGC->planemask & pm) != pm)
+ return NULL;
+
+ pTop = TopLevelParent((WindowPtr) pDraw);
+ if (pTop == NULL)
+ return NULL;
+
+ winRec = WINREC(pTop);
+ if (winRec == NULL)
+ return NULL;
+
+ return winRec;
+}
+
+static inline RootlessWindowRec *
+canAccelFill(DrawablePtr pDraw, GCPtr pGC)
+{
+ if (pGC->fillStyle != FillSolid)
+ return NULL;
+
+ return canAccelBlit(pDraw, pGC);
+}
+
+static unsigned int
+boxBytes(DrawablePtr pDraw, BoxRec *box)
+{
+ unsigned int pixels;
+
+ pixels = (box->x2 - box->x1) * (box->y2 - box->y1);
+
+ return pixels * (pDraw->bitsPerPixel >> 3);
+}
+
+
+/*
+ * Screen function to create a graphics context
+ */
+Bool
+RootlessCreateGC(GCPtr pGC)
+{
+ RootlessGCRec *gcrec;
+ RootlessScreenRec *s;
+ Bool result;
+
+ SCREEN_UNWRAP(pGC->pScreen, CreateGC);
+ s = SCREENREC(pGC->pScreen);
+ result = s->CreateGC(pGC);
+
+ gcrec = (RootlessGCRec *)
+ dixLookupPrivate(&pGC->devPrivates, rootlessGCPrivateKey);
+ gcrec->originalOps = NULL; // don't wrap ops yet
+ gcrec->originalFuncs = pGC->funcs;
+ pGC->funcs = &rootlessGCFuncs;
+
+ SCREEN_WRAP(pGC->pScreen, CreateGC);
+ return result;
+}
+
+
+/*
+ * GC funcs
+ *
+ * These wrap lower level GC funcs.
+ * ValidateGC wraps the GC ops iff dest is viewable.
+ * All the others just unwrap and call.
+ */
+
+// GCFUNC_UNRAP assumes funcs have been wrapped and
+// does not assume ops have been wrapped
+#define GCFUNC_UNWRAP(pGC) \
+ RootlessGCRec *gcrec = (RootlessGCRec *) \
+ dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \
+ (pGC)->funcs = gcrec->originalFuncs; \
+ if (gcrec->originalOps) { \
+ (pGC)->ops = gcrec->originalOps; \
+}
+
+#define GCFUNC_WRAP(pGC) \
+ gcrec->originalFuncs = (pGC)->funcs; \
+ (pGC)->funcs = &rootlessGCFuncs; \
+ if (gcrec->originalOps) { \
+ gcrec->originalOps = (pGC)->ops; \
+ (pGC)->ops = &rootlessGCOps; \
+}
+
+
+static void
+RootlessValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
+{
+ GCFUNC_UNWRAP(pGC);
+
+ gcrec->originalOps = NULL;
+
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+#ifdef ROOTLESS_PROTECT_ALPHA
+ unsigned int depth = pDrawable->depth;
+
+ // We force a planemask so fb doesn't overwrite the alpha channel.
+ // Left to its own devices, fb will optimize away the planemask.
+ pDrawable->depth = pDrawable->bitsPerPixel;
+ pGC->planemask &= ~RootlessAlphaMask(pDrawable->bitsPerPixel);
+ VALIDATE_GC(pGC, changes | GCPlaneMask, pDrawable);
+ pDrawable->depth = depth;
+#else
+ VALIDATE_GC(pGC, changes, pDrawable);
+#endif
+ } else {
+ pGC->funcs->ValidateGC(pGC, changes, pDrawable);
+ }
+
+ GCFUNC_WRAP(pGC);
+}
+
+static void RootlessChangeGC(GCPtr pGC, unsigned long mask)
+{
+ GCFUNC_UNWRAP(pGC);
+ pGC->funcs->ChangeGC(pGC, mask);
+ GCFUNC_WRAP(pGC);
+}
+
+static void RootlessCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
+{
+ GCFUNC_UNWRAP(pGCDst);
+ pGCDst->funcs->CopyGC(pGCSrc, mask, pGCDst);
+ GCFUNC_WRAP(pGCDst);
+}
+
+static void RootlessDestroyGC(GCPtr pGC)
+{
+ GCFUNC_UNWRAP(pGC);
+ pGC->funcs->DestroyGC(pGC);
+ GCFUNC_WRAP(pGC);
+}
+
+static void RootlessChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
+{
+ GCFUNC_UNWRAP(pGC);
+ pGC->funcs->ChangeClip(pGC, type, pvalue, nrects);
+ GCFUNC_WRAP(pGC);
+}
+
+static void RootlessDestroyClip(GCPtr pGC)
+{
+ GCFUNC_UNWRAP(pGC);
+ pGC->funcs->DestroyClip(pGC);
+ GCFUNC_WRAP(pGC);
+}
+
+static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+ GCFUNC_UNWRAP(pgcDst);
+ pgcDst->funcs->CopyClip(pgcDst, pgcSrc);
+ GCFUNC_WRAP(pgcDst);
+}
+
+
+/*
+ * GC ops
+ *
+ * We can't use shadowfb because shadowfb assumes one pixmap
+ * and our root window is a special case.
+ * However, much of this code is copied from shadowfb.
+ */
+
+// assumes both funcs and ops are wrapped
+#define GCOP_UNWRAP(pGC) \
+ RootlessGCRec *gcrec = (RootlessGCRec *) \
+ dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \
+ GCFuncs *saveFuncs = pGC->funcs; \
+ (pGC)->funcs = gcrec->originalFuncs; \
+ (pGC)->ops = gcrec->originalOps;
+
+#define GCOP_WRAP(pGC) \
+ gcrec->originalOps = (pGC)->ops; \
+ (pGC)->funcs = saveFuncs; \
+ (pGC)->ops = &rootlessGCOps;
+
+static void
+RootlessFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
+ DDXPointPtr pptInit, int *pwidthInit, int sorted)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("fill spans start ");
+
+ if (nInit <= 0) {
+ pGC->ops->FillSpans(dst, pGC, nInit, pptInit, pwidthInit, sorted);
+ } else {
+ DDXPointPtr ppt = pptInit;
+ int *pwidth = pwidthInit;
+ int i = nInit;
+ BoxRec box;
+
+ box.x1 = ppt->x;
+ box.x2 = box.x1 + *pwidth;
+ box.y2 = box.y1 = ppt->y;
+
+ while (--i) {
+ ppt++;
+ pwidth++;
+ if (box.x1 > ppt->x)
+ box.x1 = ppt->x;
+ if (box.x2 < (ppt->x + *pwidth))
+ box.x2 = ppt->x + *pwidth;
+ if (box.y1 > ppt->y)
+ box.y1 = ppt->y;
+ else if (box.y2 < ppt->y)
+ box.y2 = ppt->y;
+ }
+
+ box.y2++;
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->FillSpans(dst, pGC, nInit, pptInit, pwidthInit, sorted);
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("fill spans end\n");
+}
+
+static void
+RootlessSetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc,
+ DDXPointPtr pptInit, int *pwidthInit,
+ int nspans, int sorted)
+{
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("set spans start ");
+
+ if (nspans <= 0) {
+ pGC->ops->SetSpans(dst, pGC, pSrc, pptInit, pwidthInit,
+ nspans, sorted);
+ } else {
+ DDXPointPtr ppt = pptInit;
+ int *pwidth = pwidthInit;
+ int i = nspans;
+ BoxRec box;
+
+ box.x1 = ppt->x;
+ box.x2 = box.x1 + *pwidth;
+ box.y2 = box.y1 = ppt->y;
+
+ while (--i) {
+ ppt++;
+ pwidth++;
+ if (box.x1 > ppt->x)
+ box.x1 = ppt->x;
+ if (box.x2 < (ppt->x + *pwidth))
+ box.x2 = ppt->x + *pwidth;
+ if (box.y1 > ppt->y)
+ box.y1 = ppt->y;
+ else if (box.y2 < ppt->y)
+ box.y2 = ppt->y;
+ }
+
+ box.y2++;
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->SetSpans(dst, pGC, pSrc, pptInit, pwidthInit,
+ nspans, sorted);
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("set spans end\n");
+}
+
+static void
+RootlessPutImage(DrawablePtr dst, GCPtr pGC,
+ int depth, int x, int y, int w, int h,
+ int leftPad, int format, char *pBits)
+{
+ BoxRec box;
+
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("put image start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PutImage(dst, pGC, depth, x,y,w,h, leftPad, format, pBits);
+
+ box.x1 = x + dst->x;
+ box.x2 = box.x1 + w;
+ box.y1 = y + dst->y;
+ box.y2 = box.y1 + h;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("put image end\n");
+}
+
+/* changed area is *dest* rect */
+static RegionPtr
+RootlessCopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
+ int srcx, int srcy, int w, int h,
+ int dstx, int dsty)
+{
+ RegionPtr result;
+ BoxRec box;
+
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+
+ RL_DEBUG_MSG("copy area start (src 0x%x, dst 0x%x)", pSrc, dst);
+
+ if (pSrc->type == DRAWABLE_WINDOW && IsFramedWindow((WindowPtr)pSrc)) {
+ unsigned int bytes;
+
+ /* If both source and dest are windows, and we're doing
+ a simple copy operation, we can remove the alpha-protecting
+ planemask (since source has opaque alpha as well) */
+
+ bytes = w * h * (pSrc->depth >> 3);
+
+ if (bytes >= rootless_CopyBytes_threshold && canAccelBlit(pSrc, pGC))
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ RootlessStartDrawing((WindowPtr) pSrc);
+ }
+ RootlessStartDrawing((WindowPtr) dst);
+ result = pGC->ops->CopyArea(pSrc, dst, pGC, srcx, srcy, w, h, dstx, dsty);
+
+ box.x1 = dstx + dst->x;
+ box.x2 = box.x1 + w;
+ box.y1 = dsty + dst->y;
+ box.y2 = box.y1 + h;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("copy area end\n");
+ return result;
+}
+
+/* changed area is *dest* rect */
+static RegionPtr RootlessCopyPlane(DrawablePtr pSrc, DrawablePtr dst,
+ GCPtr pGC, int srcx, int srcy,
+ int w, int h, int dstx, int dsty,
+ unsigned long plane)
+{
+ RegionPtr result;
+ BoxRec box;
+
+ GCOP_UNWRAP(pGC);
+
+ RL_DEBUG_MSG("copy plane start ");
+
+ if (pSrc->type == DRAWABLE_WINDOW && IsFramedWindow((WindowPtr)pSrc)) {
+ RootlessStartDrawing((WindowPtr) pSrc);
+ }
+ RootlessStartDrawing((WindowPtr) dst);
+ result = pGC->ops->CopyPlane(pSrc, dst, pGC, srcx, srcy, w, h,
+ dstx, dsty, plane);
+
+ box.x1 = dstx + dst->x;
+ box.x2 = box.x1 + w;
+ box.y1 = dsty + dst->y;
+ box.y2 = box.y1 + h;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("copy plane end\n");
+ return result;
+}
+
+// Options for size of changed area:
+// 0 = box per point
+// 1 = big box around all points
+// 2 = accumulate point in 20 pixel radius
+#define ROOTLESS_CHANGED_AREA 1
+#define abs(a) ((a) > 0 ? (a) : -(a))
+
+/* changed area is box around all points */
+static void RootlessPolyPoint(DrawablePtr dst, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit)
+{
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("polypoint start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PolyPoint(dst, pGC, mode, npt, pptInit);
+
+ if (npt > 0) {
+#if ROOTLESS_CHANGED_AREA==0
+ // box per point
+ BoxRec box;
+
+ while (npt) {
+ box.x1 = pptInit->x;
+ box.y1 = pptInit->y;
+ box.x2 = box.x1 + 1;
+ box.y2 = box.y1 + 1;
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ npt--;
+ pptInit++;
+ }
+
+#elif ROOTLESS_CHANGED_AREA==1
+ // one big box
+ BoxRec box;
+
+ box.x2 = box.x1 = pptInit->x;
+ box.y2 = box.y1 = pptInit->y;
+ while (--npt) {
+ pptInit++;
+ if (box.x1 > pptInit->x)
+ box.x1 = pptInit->x;
+ else if (box.x2 < pptInit->x)
+ box.x2 = pptInit->x;
+ if (box.y1 > pptInit->y)
+ box.y1 = pptInit->y;
+ else if (box.y2 < pptInit->y)
+ box.y2 = pptInit->y;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+#elif ROOTLESS_CHANGED_AREA==2
+ // clever(?) method: accumulate point in 20-pixel radius
+ BoxRec box;
+ int firstx, firsty;
+
+ box.x2 = box.x1 = firstx = pptInit->x;
+ box.y2 = box.y1 = firsty = pptInit->y;
+ while (--npt) {
+ pptInit++;
+ if (abs(pptInit->x - firstx) > 20 ||
+ abs(pptInit->y - firsty) > 20) {
+ box.x2++;
+ box.y2++;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ box.x2 = box.x1 = firstx = pptInit->x;
+ box.y2 = box.y1 = firsty = pptInit->y;
+ } else {
+ if (box.x1 > pptInit->x) box.x1 = pptInit->x;
+ else if (box.x2 < pptInit->x) box.x2 = pptInit->x;
+ if (box.y1 > pptInit->y) box.y1 = pptInit->y;
+ else if (box.y2 < pptInit->y) box.y2 = pptInit->y;
+ }
+ }
+ box.x2++;
+ box.y2++;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox((WindowPtr) dst, &box);
+#endif /* ROOTLESS_CHANGED_AREA */
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("polypoint end\n");
+}
+
+#undef ROOTLESS_CHANGED_AREA
+
+/* changed area is box around each line */
+static void RootlessPolylines(DrawablePtr dst, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit)
+{
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("poly lines start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->Polylines(dst, pGC, mode, npt, pptInit);
+
+ if (npt > 0) {
+ BoxRec box;
+ int extra = pGC->lineWidth >> 1;
+
+ box.x2 = box.x1 = pptInit->x;
+ box.y2 = box.y1 = pptInit->y;
+
+ if (npt > 1) {
+ if (pGC->joinStyle == JoinMiter)
+ extra = 6 * pGC->lineWidth;
+ else if (pGC->capStyle == CapProjecting)
+ extra = pGC->lineWidth;
+ }
+
+ if (mode == CoordModePrevious) {
+ int x = box.x1;
+ int y = box.y1;
+
+ while (--npt) {
+ pptInit++;
+ x += pptInit->x;
+ y += pptInit->y;
+ if (box.x1 > x)
+ box.x1 = x;
+ else if (box.x2 < x)
+ box.x2 = x;
+ if (box.y1 > y)
+ box.y1 = y;
+ else if (box.y2 < y)
+ box.y2 = y;
+ }
+ } else {
+ while (--npt) {
+ pptInit++;
+ if (box.x1 > pptInit->x)
+ box.x1 = pptInit->x;
+ else if (box.x2 < pptInit->x)
+ box.x2 = pptInit->x;
+ if (box.y1 > pptInit->y)
+ box.y1 = pptInit->y;
+ else if (box.y2 < pptInit->y)
+ box.y2 = pptInit->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if (extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("poly lines end\n");
+}
+
+/* changed area is box around each line segment */
+static void RootlessPolySegment(DrawablePtr dst, GCPtr pGC,
+ int nseg, xSegment *pSeg)
+{
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("poly segment start (win 0x%x)", dst);
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PolySegment(dst, pGC, nseg, pSeg);
+
+ if (nseg > 0) {
+ BoxRec box;
+ int extra = pGC->lineWidth;
+
+ if (pGC->capStyle != CapProjecting)
+ extra >>= 1;
+
+ if (pSeg->x2 > pSeg->x1) {
+ box.x1 = pSeg->x1;
+ box.x2 = pSeg->x2;
+ } else {
+ box.x2 = pSeg->x1;
+ box.x1 = pSeg->x2;
+ }
+
+ if (pSeg->y2 > pSeg->y1) {
+ box.y1 = pSeg->y1;
+ box.y2 = pSeg->y2;
+ } else {
+ box.y2 = pSeg->y1;
+ box.y1 = pSeg->y2;
+ }
+
+ while (--nseg) {
+ pSeg++;
+ if (pSeg->x2 > pSeg->x1) {
+ if (pSeg->x1 < box.x1) box.x1 = pSeg->x1;
+ if (pSeg->x2 > box.x2) box.x2 = pSeg->x2;
+ } else {
+ if (pSeg->x2 < box.x1) box.x1 = pSeg->x2;
+ if (pSeg->x1 > box.x2) box.x2 = pSeg->x1;
+ }
+ if (pSeg->y2 > pSeg->y1) {
+ if (pSeg->y1 < box.y1) box.y1 = pSeg->y1;
+ if (pSeg->y2 > box.y2) box.y2 = pSeg->y2;
+ } else {
+ if (pSeg->y2 < box.y1) box.y1 = pSeg->y2;
+ if (pSeg->y1 > box.y2) box.y2 = pSeg->y1;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if (extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("poly segment end\n");
+}
+
+/* changed area is box around each line (not entire rects) */
+static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC,
+ int nRects, xRectangle *pRects)
+{
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("poly rectangle start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PolyRectangle(dst, pGC, nRects, pRects);
+
+ if (nRects > 0) {
+ BoxRec box;
+ int offset1, offset2, offset3;
+
+ offset2 = pGC->lineWidth;
+ if (!offset2) offset2 = 1;
+ offset1 = offset2 >> 1;
+ offset3 = offset2 - offset1;
+
+ while (nRects--) {
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y - offset1;
+ box.x2 = box.x1 + pRects->width + offset2;
+ box.y2 = box.y1 + offset2;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y + offset3;
+ box.x2 = box.x1 + offset2;
+ box.y2 = box.y1 + pRects->height - offset2;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ box.x1 = pRects->x + pRects->width - offset1;
+ box.y1 = pRects->y + offset3;
+ box.x2 = box.x1 + offset2;
+ box.y2 = box.y1 + pRects->height - offset2;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y + pRects->height - offset1;
+ box.x2 = box.x1 + pRects->width + offset2;
+ box.y2 = box.y1 + offset2;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ pRects++;
+ }
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("poly rectangle end\n");
+}
+
+
+/* changed area is box around each arc (assumes all arcs are 360 degrees) */
+static void RootlessPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs)
+{
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("poly arc start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PolyArc(dst, pGC, narcs, parcs);
+
+ if (narcs > 0) {
+ int extra = pGC->lineWidth >> 1;
+ BoxRec box;
+
+ box.x1 = parcs->x;
+ box.x2 = box.x1 + parcs->width;
+ box.y1 = parcs->y;
+ box.y2 = box.y1 + parcs->height;
+
+ /* should I break these up instead ? */
+
+ while (--narcs) {
+ parcs++;
+ if (box.x1 > parcs->x)
+ box.x1 = parcs->x;
+ if (box.x2 < (parcs->x + parcs->width))
+ box.x2 = parcs->x + parcs->width;
+ if (box.y1 > parcs->y)
+ box.y1 = parcs->y;
+ if (box.y2 < (parcs->y + parcs->height))
+ box.y2 = parcs->y + parcs->height;
+ }
+
+ if (extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("poly arc end\n");
+}
+
+
+/* changed area is box around each poly */
+static void RootlessFillPolygon(DrawablePtr dst, GCPtr pGC,
+ int shape, int mode, int count,
+ DDXPointPtr pptInit)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("fill poly start (win 0x%x, fillStyle 0x%x)", dst,
+ pGC->fillStyle);
+
+ if (count <= 2) {
+ pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pptInit);
+ } else {
+ DDXPointPtr ppt = pptInit;
+ int i = count;
+ BoxRec box;
+
+ box.x2 = box.x1 = ppt->x;
+ box.y2 = box.y1 = ppt->y;
+
+ if (mode != CoordModeOrigin) {
+ int x = box.x1;
+ int y = box.y1;
+
+ while (--i) {
+ ppt++;
+ x += ppt->x;
+ y += ppt->y;
+ if (box.x1 > x)
+ box.x1 = x;
+ else if (box.x2 < x)
+ box.x2 = x;
+ if (box.y1 > y)
+ box.y1 = y;
+ else if (box.y2 < y)
+ box.y2 = y;
+ }
+ } else {
+ while (--i) {
+ ppt++;
+ if (box.x1 > ppt->x)
+ box.x1 = ppt->x;
+ else if (box.x2 < ppt->x)
+ box.x2 = ppt->x;
+ if (box.y1 > ppt->y)
+ box.y1 = ppt->y;
+ else if (box.y2 < ppt->y)
+ box.y2 = ppt->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pptInit);
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("fill poly end\n");
+}
+
+/* changed area is the rects */
+static void RootlessPolyFillRect(DrawablePtr dst, GCPtr pGC,
+ int nRectsInit, xRectangle *pRectsInit)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("fill rect start (win 0x%x, fillStyle 0x%x)", dst,
+ pGC->fillStyle);
+
+ if (nRectsInit <= 0) {
+ pGC->ops->PolyFillRect(dst, pGC, nRectsInit, pRectsInit);
+ } else {
+ BoxRec box;
+ xRectangle *pRects = pRectsInit;
+ int nRects = nRectsInit;
+
+ box.x1 = pRects->x;
+ box.x2 = box.x1 + pRects->width;
+ box.y1 = pRects->y;
+ box.y2 = box.y1 + pRects->height;
+
+ while (--nRects) {
+ pRects++;
+ if (box.x1 > pRects->x)
+ box.x1 = pRects->x;
+ if (box.x2 < (pRects->x + pRects->width))
+ box.x2 = pRects->x + pRects->width;
+ if (box.y1 > pRects->y)
+ box.y1 = pRects->y;
+ if (box.y2 < (pRects->y + pRects->height))
+ box.y2 = pRects->y + pRects->height;
+ }
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->PolyFillRect(dst, pGC, nRectsInit, pRectsInit);
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("fill rect end\n");
+}
+
+
+/* changed area is box around each arc (assuming arcs are all 360 degrees) */
+static void RootlessPolyFillArc(DrawablePtr dst, GCPtr pGC,
+ int narcsInit, xArc *parcsInit)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("fill arc start ");
+
+ if (narcsInit > 0) {
+ BoxRec box;
+ int narcs = narcsInit;
+ xArc *parcs = parcsInit;
+
+ box.x1 = parcs->x;
+ box.x2 = box.x1 + parcs->width;
+ box.y1 = parcs->y;
+ box.y2 = box.y1 + parcs->height;
+
+ /* should I break these up instead ? */
+
+ while (--narcs) {
+ parcs++;
+ if (box.x1 > parcs->x)
+ box.x1 = parcs->x;
+ if (box.x2 < (parcs->x + parcs->width))
+ box.x2 = parcs->x + parcs->width;
+ if (box.y1 > parcs->y)
+ box.y1 = parcs->y;
+ if (box.y2 < (parcs->y + parcs->height))
+ box.y2 = parcs->y + parcs->height;
+ }
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->PolyFillArc(dst, pGC, narcsInit, parcsInit);
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ } else {
+ pGC->ops->PolyFillArc(dst, pGC, narcsInit, parcsInit);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("fill arc end\n");
+}
+
+
+static void RootlessImageText8(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, char *chars)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("imagetext8 start ");
+
+ if (count > 0) {
+ int top, bot, Min, Max;
+ BoxRec box;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+ if (Min > 0) Min = 0;
+ Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
+ if (Max < 0) Max = 0;
+
+ /* ugh */
+ box.x1 = dst->x + x + Min +
+ FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = dst->x + x + Max +
+ FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ box.y1 = dst->y + y - top;
+ box.y2 = dst->y + y + bot;
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->ImageText8(dst, pGC, x, y, count, chars);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ } else {
+ pGC->ops->ImageText8(dst, pGC, x, y, count, chars);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("imagetext8 end\n");
+}
+
+static int RootlessPolyText8(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, char *chars)
+{
+ int width; // the result, sorta
+
+ GCOP_UNWRAP(pGC);
+
+ RL_DEBUG_MSG("polytext8 start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ width = pGC->ops->PolyText8(dst, pGC, x, y, count, chars);
+ width -= x;
+
+ if (width > 0) {
+ BoxRec box;
+
+ /* ugh */
+ box.x1 = dst->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = dst->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ if (count > 1) {
+ if (width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = dst->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = dst->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("polytext8 end\n");
+ return width + x;
+}
+
+static void RootlessImageText16(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("imagetext16 start ");
+
+ if (count > 0) {
+ int top, bot, Min, Max;
+ BoxRec box;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+ if (Min > 0) Min = 0;
+ Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
+ if (Max < 0) Max = 0;
+
+ /* ugh */
+ box.x1 = dst->x + x + Min +
+ FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = dst->x + x + Max +
+ FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ box.y1 = dst->y + y - top;
+ box.y2 = dst->y + y + bot;
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->ImageText16(dst, pGC, x, y, count, chars);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ } else {
+ pGC->ops->ImageText16(dst, pGC, x, y, count, chars);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("imagetext16 end\n");
+}
+
+static int RootlessPolyText16(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ int width; // the result, sorta
+
+ GCOP_UNWRAP(pGC);
+
+ RL_DEBUG_MSG("polytext16 start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ width = pGC->ops->PolyText16(dst, pGC, x, y, count, chars);
+ width -= x;
+
+ if (width > 0) {
+ BoxRec box;
+
+ /* ugh */
+ box.x1 = dst->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = dst->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ if (count > 1) {
+ if (width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = dst->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = dst->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("polytext16 end\n");
+ return width + x;
+}
+
+static void RootlessImageGlyphBlt(DrawablePtr dst, GCPtr pGC,
+ int x, int y, unsigned int nglyphInit,
+ CharInfoPtr *ppciInit, pointer unused)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("imageglyph start ");
+
+ if (nglyphInit > 0) {
+ int top, bot, width = 0;
+ BoxRec box;
+ unsigned int nglyph = nglyphInit;
+ CharInfoPtr *ppci = ppciInit;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ box.x1 = ppci[0]->metrics.leftSideBearing;
+ if (box.x1 > 0) box.x1 = 0;
+ box.x2 = ppci[nglyph - 1]->metrics.rightSideBearing -
+ ppci[nglyph - 1]->metrics.characterWidth;
+ if (box.x2 < 0) box.x2 = 0;
+
+ box.x2 += dst->x + x;
+ box.x1 += dst->x + x;
+
+ while (nglyph--) {
+ width += (*ppci)->metrics.characterWidth;
+ ppci++;
+ }
+
+ if (width > 0)
+ box.x2 += width;
+ else
+ box.x1 += width;
+
+ box.y1 = dst->y + y - top;
+ box.y2 = dst->y + y + bot;
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->ImageGlyphBlt(dst, pGC, x, y, nglyphInit, ppciInit, unused);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ } else {
+ pGC->ops->ImageGlyphBlt(dst, pGC, x, y, nglyphInit, ppciInit, unused);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("imageglyph end\n");
+}
+
+static void RootlessPolyGlyphBlt(DrawablePtr dst, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("polyglyph start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PolyGlyphBlt(dst, pGC, x, y, nglyph, ppci, pglyphBase);
+
+ if (nglyph > 0) {
+ BoxRec box;
+
+ /* ugh */
+ box.x1 = dst->x + x + ppci[0]->metrics.leftSideBearing;
+ box.x2 = dst->x + x + ppci[nglyph - 1]->metrics.rightSideBearing;
+
+ if (nglyph > 1) {
+ int width = 0;
+
+ while (--nglyph) {
+ width += (*ppci)->metrics.characterWidth;
+ ppci++;
+ }
+
+ if (width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = dst->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = dst->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("polyglyph end\n");
+}
+
+
+/* changed area is in dest */
+static void
+RootlessPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst,
+ int dx, int dy, int xOrg, int yOrg)
+{
+ BoxRec box;
+
+ GCOP_UNWRAP(pGC);
+ RL_DEBUG_MSG("push pixels start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PushPixels(pGC, pBitMap, dst, dx, dy, xOrg, yOrg);
+
+ box.x1 = xOrg + dst->x;
+ box.x2 = box.x1 + dx;
+ box.y1 = yOrg + dst->y;
+ box.y2 = box.y1 + dy;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("push pixels end\n");
+}
diff --git a/xorg-server/miext/rootless/rootlessScreen.c b/xorg-server/miext/rootless/rootlessScreen.c index 6f9341d85..fd396e464 100644 --- a/xorg-server/miext/rootless/rootlessScreen.c +++ b/xorg-server/miext/rootless/rootlessScreen.c @@ -62,15 +62,10 @@ extern int RootlessMiValidateTree(WindowPtr pRoot, WindowPtr pChild, extern Bool RootlessCreateGC(GCPtr pGC);
// Initialize globals
-static int rootlessGCPrivateKeyIndex;
-DevPrivateKey rootlessGCPrivateKey = &rootlessGCPrivateKeyIndex;
-static int rootlessScreenPrivateKeyIndex;
-DevPrivateKey rootlessScreenPrivateKey = &rootlessScreenPrivateKeyIndex;
-static int rootlessWindowPrivateKeyIndex;
-DevPrivateKey rootlessWindowPrivateKey = &rootlessWindowPrivateKeyIndex;
-static int rootlessWindowOldPixmapPrivateKeyIndex;
-DevPrivateKey rootlessWindowOldPixmapPrivateKey = &rootlessWindowOldPixmapPrivateKeyIndex;
-
+DevPrivateKeyRec rootlessGCPrivateKeyRec;
+DevPrivateKeyRec rootlessScreenPrivateKeyRec;
+DevPrivateKeyRec rootlessWindowPrivateKeyRec;
+DevPrivateKeyRec rootlessWindowOldPixmapPrivateKeyRec;
/*
* RootlessUpdateScreenPixmap
@@ -441,9 +436,9 @@ RootlessMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst, pChild = pWin;
while (1) {
if (pChild->viewable) {
- if (REGION_BROKEN (pScreen, &pChild->winSize))
+ if (RegionBroken(&pChild->winSize))
SetWinSize (pChild);
- if (REGION_BROKEN (pScreen, &pChild->borderSize))
+ if (RegionBroken(&pChild->borderSize))
SetBorderSize (pChild);
(* MarkWindow)(pChild);
if (pChild->firstChild) {
@@ -493,7 +488,7 @@ static void expose_1 (WindowPtr pWin) { void
RootlessScreenExpose (ScreenPtr pScreen)
{
- expose_1 (WindowTable[pScreen->myNum]);
+ expose_1 (pScreen->root);
}
@@ -637,8 +632,13 @@ RootlessAllocatePrivates(ScreenPtr pScreen) {
RootlessScreenRec *s;
- // no allocation needed for screen privates
- if (!dixRequestPrivate(rootlessGCPrivateKey, sizeof(RootlessGCRec)))
+ 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))
return FALSE;
s = malloc(sizeof(RootlessScreenRec));
diff --git a/xorg-server/miext/rootless/rootlessValTree.c b/xorg-server/miext/rootless/rootlessValTree.c index 0ee4919e1..6154e9d40 100644 --- a/xorg-server/miext/rootless/rootlessValTree.c +++ b/xorg-server/miext/rootless/rootlessValTree.c @@ -1,640 +1,635 @@ -/* - * Calculate window clip lists for rootless mode - * - * This file is very closely based on mivaltree.c. - */ - -/* - * mivaltree.c -- - * Functions for recalculating window clip lists. Main function - * is miValidateTree. - * - -Copyright 1987, 1988, 1989, 1998 The Open Group - -All Rights Reserved. - -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 -OPEN GROUP 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 of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - * - * Copyright 1987, 1988, 1989 by - * Digital Equipment Corporation, Maynard, Massachusetts, - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Digital not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * - * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR - * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - ******************************************************************/ - -/* The panoramix components contained the following notice */ -/***************************************************************** - -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. - -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. - -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 -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. - -******************************************************************/ - /* - * Aug '86: Susan Angebranndt -- original code - * July '87: Adam de Boor -- substantially modified and commented - * Summer '89: Joel McCormack -- so fast you wouldn't believe it possible. - * In particular, much improved code for window mapping and - * circulating. - * Bob Scheifler -- avoid miComputeClips for unmapped windows, - * valdata changes - */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stddef.h> /* For NULL */ -#include <X11/X.h> -#include "scrnintstr.h" -#include "validate.h" -#include "windowstr.h" -#include "mi.h" -#include "regionstr.h" -#include "mivalidate.h" - -#include "globals.h" - -int RootlessShapedWindowIn (ScreenPtr pScreen, RegionPtr universe, - RegionPtr bounding, BoxPtr rect, int x, int y); - -int RootlessMiValidateTree (WindowPtr pRoot, WindowPtr pChild, VTKind kind); - -/* - * Compute the visibility of a shaped window - */ -int -RootlessShapedWindowIn (ScreenPtr pScreen, RegionPtr universe, - RegionPtr bounding, BoxPtr rect, int x, int y) -{ - BoxRec box; - register BoxPtr boundBox; - int nbox; - Bool someIn, someOut; - register int t, x1, y1, x2, y2; - - nbox = REGION_NUM_RECTS (bounding); - boundBox = REGION_RECTS (bounding); - someIn = someOut = FALSE; - x1 = rect->x1; - y1 = rect->y1; - x2 = rect->x2; - y2 = rect->y2; - while (nbox--) - { - if ((t = boundBox->x1 + x) < x1) - t = x1; - box.x1 = t; - if ((t = boundBox->y1 + y) < y1) - t = y1; - box.y1 = t; - if ((t = boundBox->x2 + x) > x2) - t = x2; - box.x2 = t; - if ((t = boundBox->y2 + y) > y2) - t = y2; - box.y2 = t; - if (box.x1 > box.x2) - box.x2 = box.x1; - if (box.y1 > box.y2) - box.y2 = box.y1; - switch (RECT_IN_REGION(pScreen, universe, &box)) - { - case rgnIN: - if (someOut) - return rgnPART; - someIn = TRUE; - break; - case rgnOUT: - if (someIn) - return rgnPART; - someOut = TRUE; - break; - default: - return rgnPART; - } - boundBox++; - } - if (someIn) - return rgnIN; - return rgnOUT; -} - -#define HasParentRelativeBorder(w) (!(w)->borderIsPixel && \ - HasBorder(w) && \ - (w)->backgroundState == ParentRelative) - - -/* - *----------------------------------------------------------------------- - * RootlessComputeClips -- - * Recompute the clipList, borderClip, exposed and borderExposed - * regions for pParent and its children. Only viewable windows are - * taken into account. - * - * Results: - * None. - * - * Side Effects: - * clipList, borderClip, exposed and borderExposed are altered. - * A VisibilityNotify event may be generated on the parent window. - * - *----------------------------------------------------------------------- - */ -static void -RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen, - RegionPtr universe, VTKind kind, RegionPtr exposed) -{ - int dx, - dy; - RegionRec childUniverse; - register WindowPtr pChild; - int oldVis, newVis; - BoxRec borderSize; - RegionRec childUnion; - Bool overlap; - RegionPtr borderVisible; - Bool resized; - /* - * Figure out the new visibility of this window. - * The extent of the universe should be the same as the extent of - * the borderSize region. If the window is unobscured, this rectangle - * will be completely inside the universe (the universe will cover it - * completely). If the window is completely obscured, none of the - * universe will cover the rectangle. - */ - borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent); - borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent); - dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent); - if (dx > 32767) - dx = 32767; - borderSize.x2 = dx; - dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent); - if (dy > 32767) - dy = 32767; - borderSize.y2 = dy; - - oldVis = pParent->visibility; - switch (RECT_IN_REGION( pScreen, universe, &borderSize)) - { - case rgnIN: - newVis = VisibilityUnobscured; - break; - case rgnPART: - newVis = VisibilityPartiallyObscured; - { - RegionPtr pBounding; - - if ((pBounding = wBoundingShape (pParent))) - { - switch (RootlessShapedWindowIn (pScreen, universe, - pBounding, &borderSize, - pParent->drawable.x, - pParent->drawable.y)) - { - case rgnIN: - newVis = VisibilityUnobscured; - break; - case rgnOUT: - newVis = VisibilityFullyObscured; - break; - } - } - } - break; - default: - newVis = VisibilityFullyObscured; - break; - } - - pParent->visibility = newVis; - if (oldVis != newVis && - ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask)) - SendVisibilityNotify(pParent); - - dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x; - dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y; - - /* - * avoid computations when dealing with simple operations - */ - - switch (kind) { - case VTMap: - case VTStack: - case VTUnmap: - break; - case VTMove: - if ((oldVis == newVis) && - ((oldVis == VisibilityFullyObscured) || - (oldVis == VisibilityUnobscured))) - { - pChild = pParent; - while (1) - { - if (pChild->viewable) - { - if (pChild->visibility != VisibilityFullyObscured) - { - REGION_TRANSLATE( pScreen, &pChild->borderClip, - dx, dy); - REGION_TRANSLATE( pScreen, &pChild->clipList, - dx, dy); - pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER; - if (pScreen->ClipNotify) - (* pScreen->ClipNotify) (pChild, dx, dy); - - } - if (pChild->valdata) - { - REGION_NULL(pScreen, - &pChild->valdata->after.borderExposed); - if (HasParentRelativeBorder(pChild)) - { - REGION_SUBTRACT(pScreen, - &pChild->valdata->after.borderExposed, - &pChild->borderClip, - &pChild->winSize); - } - REGION_NULL(pScreen, &pChild->valdata->after.exposed); - } - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - } - while (!pChild->nextSib && (pChild != pParent)) - pChild = pChild->parent; - if (pChild == pParent) - break; - pChild = pChild->nextSib; - } - return; - } - /* fall through */ - default: - /* - * To calculate exposures correctly, we have to translate the old - * borderClip and clipList regions to the window's new location so there - * is a correspondence between pieces of the new and old clipping regions. - */ - if (dx || dy) - { - /* - * We translate the old clipList because that will be exposed or copied - * if gravity is right. - */ - REGION_TRANSLATE( pScreen, &pParent->borderClip, dx, dy); - REGION_TRANSLATE( pScreen, &pParent->clipList, dx, dy); - } - break; - case VTBroken: - REGION_EMPTY (pScreen, &pParent->borderClip); - REGION_EMPTY (pScreen, &pParent->clipList); - break; - } - - borderVisible = pParent->valdata->before.borderVisible; - resized = pParent->valdata->before.resized; - REGION_NULL(pScreen, &pParent->valdata->after.borderExposed); - REGION_NULL(pScreen, &pParent->valdata->after.exposed); - - /* - * Since the borderClip must not be clipped by the children, we do - * the border exposure first... - * - * 'universe' is the window's borderClip. To figure the exposures, remove - * the area that used to be exposed from the new. - * This leaves a region of pieces that weren't exposed before. - */ - - if (HasBorder (pParent)) - { - if (borderVisible) - { - /* - * when the border changes shape, the old visible portions - * of the border will be saved by DIX in borderVisible -- - * use that region and destroy it - */ - REGION_SUBTRACT( pScreen, exposed, universe, borderVisible); - REGION_DESTROY( pScreen, borderVisible); - } - else - { - REGION_SUBTRACT( pScreen, exposed, universe, &pParent->borderClip); - } - if (HasParentRelativeBorder(pParent) && (dx || dy)) { - REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed, - universe, - &pParent->winSize); - } else { - REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed, - exposed, &pParent->winSize); - } - - REGION_COPY( pScreen, &pParent->borderClip, universe); - - /* - * To get the right clipList for the parent, and to make doubly sure - * that no child overlaps the parent's border, we remove the parent's - * border from the universe before proceeding. - */ - - REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize); - } - else - REGION_COPY( pScreen, &pParent->borderClip, universe); - - if ((pChild = pParent->firstChild) && pParent->mapped) - { - REGION_NULL(pScreen, &childUniverse); - REGION_NULL(pScreen, &childUnion); - if ((pChild->drawable.y < pParent->lastChild->drawable.y) || - ((pChild->drawable.y == pParent->lastChild->drawable.y) && - (pChild->drawable.x < pParent->lastChild->drawable.x))) - { - for (; pChild; pChild = pChild->nextSib) - { - if (pChild->viewable) - REGION_APPEND( pScreen, &childUnion, &pChild->borderSize); - } - } - else - { - for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib) - { - if (pChild->viewable) - REGION_APPEND( pScreen, &childUnion, &pChild->borderSize); - } - } - REGION_VALIDATE( pScreen, &childUnion, &overlap); - - for (pChild = pParent->firstChild; - pChild; - pChild = pChild->nextSib) - { - if (pChild->viewable) { - /* - * If the child is viewable, we want to remove its extents - * from the current universe, but we only re-clip it if - * it's been marked. - */ - if (pChild->valdata) { - /* - * Figure out the new universe from the child's - * perspective and recurse. - */ - REGION_INTERSECT( pScreen, &childUniverse, - universe, - &pChild->borderSize); - RootlessComputeClips (pChild, pScreen, &childUniverse, - kind, exposed); - } - /* - * Once the child has been processed, we remove its extents - * from the current universe, thus denying its space to any - * other sibling. - */ - if (overlap) - REGION_SUBTRACT( pScreen, universe, universe, - &pChild->borderSize); - } - } - if (!overlap) - REGION_SUBTRACT( pScreen, universe, universe, &childUnion); - REGION_UNINIT( pScreen, &childUnion); - REGION_UNINIT( pScreen, &childUniverse); - } /* if any children */ - - /* - * 'universe' now contains the new clipList for the parent window. - * - * To figure the exposure of the window we subtract the old clip from the - * new, just as for the border. - */ - - if (oldVis == VisibilityFullyObscured || - oldVis == VisibilityNotViewable) - { - REGION_COPY( pScreen, &pParent->valdata->after.exposed, universe); - } - else if (newVis != VisibilityFullyObscured && - newVis != VisibilityNotViewable) - { - REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed, - universe, &pParent->clipList); - } - - /* - * One last thing: backing storage. We have to try to save what parts of - * the window are about to be obscured. We can just subtract the universe - * from the old clipList and get the areas that were in the old but aren't - * in the new and, hence, are about to be obscured. - */ - if (pParent->backStorage && !resized) - { - REGION_SUBTRACT( pScreen, exposed, &pParent->clipList, universe); - (* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy); - } - - /* HACK ALERT - copying contents of regions, instead of regions */ - { - RegionRec tmp; - - tmp = pParent->clipList; - pParent->clipList = *universe; - *universe = tmp; - } - -#ifdef NOTDEF - REGION_COPY( pScreen, &pParent->clipList, universe); -#endif - - pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER; - - if (pScreen->ClipNotify) - (* pScreen->ClipNotify) (pParent, dx, dy); -} - -static void -RootlessTreeObscured(WindowPtr pParent) -{ - register WindowPtr pChild; - register int oldVis; - - pChild = pParent; - while (1) - { - if (pChild->viewable) - { - oldVis = pChild->visibility; - if (oldVis != (pChild->visibility = VisibilityFullyObscured) && - ((pChild->eventMask | wOtherEventMasks(pChild)) & VisibilityChangeMask)) - SendVisibilityNotify(pChild); - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - } - while (!pChild->nextSib && (pChild != pParent)) - pChild = pChild->parent; - if (pChild == pParent) - break; - pChild = pChild->nextSib; - } -} - -/* - *----------------------------------------------------------------------- - * RootlessMiValidateTree -- - * Recomputes the clip list for pParent and all its inferiors. - * - * Results: - * Always returns 1. - * - * Side Effects: - * The clipList, borderClip, exposed, and borderExposed regions for - * each marked window are altered. - * - * Notes: - * This routine assumes that all affected windows have been marked - * (valdata created) and their winSize and borderSize regions - * adjusted to correspond to their new positions. The borderClip and - * clipList regions should not have been touched. - * - * The top-most level is treated differently from all lower levels - * because pParent is unchanged. For the top level, we merge the - * regions taken up by the marked children back into the clipList - * for pParent, thus forming a region from which the marked children - * can claim their areas. For lower levels, where the old clipList - * and borderClip are invalid, we can't do this and have to do the - * extra operations done in miComputeClips, but this is much faster - * e.g. when only one child has moved... - * - *----------------------------------------------------------------------- - */ -/* - Quartz version: used for validate from root in rootless mode. - We need to make sure top-level windows don't clip each other, - and that top-level windows aren't clipped to the root window. -*/ -/*ARGSUSED*/ -// fixme this is ugly -// Xprint/ValTree.c doesn't work, but maybe that method can? -int -RootlessMiValidateTree (WindowPtr pRoot, /* Parent to validate */ - WindowPtr pChild, /* First child of pRoot that was - * affected */ - VTKind kind /* What kind of configuration caused call */) -{ - RegionRec childClip; /* The new borderClip for the current - * child */ - RegionRec exposed; /* For intermediate calculations */ - register ScreenPtr pScreen; - register WindowPtr pWin; - - pScreen = pRoot->drawable.pScreen; - if (pChild == NullWindow) - pChild = pRoot->firstChild; - - REGION_NULL(pScreen, &childClip); - REGION_NULL(pScreen, &exposed); - - if (REGION_BROKEN (pScreen, &pRoot->clipList) && - !REGION_BROKEN (pScreen, &pRoot->borderClip)) - { - // fixme this might not work, but hopefully doesn't happen anyway. - kind = VTBroken; - REGION_EMPTY (pScreen, &pRoot->clipList); - ErrorF("ValidateTree: BUSTED!\n"); - } - - /* - * Recursively compute the clips for all children of the root. - * They don't clip against each other or the root itself, so - * childClip is always reset to that child's size. - */ - - for (pWin = pChild; - pWin != NullWindow; - pWin = pWin->nextSib) - { - if (pWin->viewable) { - if (pWin->valdata) { - REGION_COPY( pScreen, &childClip, &pWin->borderSize); - RootlessComputeClips (pWin, pScreen, &childClip, kind, &exposed); - } else if (pWin->visibility == VisibilityNotViewable) { - RootlessTreeObscured(pWin); - } - } else { - if (pWin->valdata) { - REGION_EMPTY( pScreen, &pWin->clipList); - if (pScreen->ClipNotify) - (* pScreen->ClipNotify) (pWin, 0, 0); - REGION_EMPTY( pScreen, &pWin->borderClip); - pWin->valdata = NULL; - } - } - } - - REGION_UNINIT(pScreen, &childClip); - - /* The root is never clipped by its children, so nothing on the root - is ever exposed by moving or mapping its children. */ - REGION_NULL(pScreen, &pRoot->valdata->after.exposed); - REGION_NULL(pScreen, &pRoot->valdata->after.borderExposed); - - return 1; -} +/*
+ * Calculate window clip lists for rootless mode
+ *
+ * This file is very closely based on mivaltree.c.
+ */
+
+/*
+ * mivaltree.c --
+ * Functions for recalculating window clip lists. Main function
+ * is miValidateTree.
+ *
+
+Copyright 1987, 1988, 1989, 1998 The Open Group
+
+All Rights Reserved.
+
+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
+OPEN GROUP 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 of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+ *
+ * Copyright 1987, 1988, 1989 by
+ * Digital Equipment Corporation, Maynard, Massachusetts,
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ ******************************************************************/
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+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.
+
+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
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+ /*
+ * Aug '86: Susan Angebranndt -- original code
+ * July '87: Adam de Boor -- substantially modified and commented
+ * Summer '89: Joel McCormack -- so fast you wouldn't believe it possible.
+ * In particular, much improved code for window mapping and
+ * circulating.
+ * Bob Scheifler -- avoid miComputeClips for unmapped windows,
+ * valdata changes
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stddef.h> /* For NULL */
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "regionstr.h"
+#include "mivalidate.h"
+
+#include "globals.h"
+
+int RootlessMiValidateTree (WindowPtr pRoot, WindowPtr pChild, VTKind kind);
+
+/*
+ * Compute the visibility of a shaped window
+ */
+static int
+RootlessShapedWindowIn (RegionPtr universe,
+ RegionPtr bounding, BoxPtr rect, int x, int y)
+{
+ BoxRec box;
+ register BoxPtr boundBox;
+ int nbox;
+ Bool someIn, someOut;
+ register int t, x1, y1, x2, y2;
+
+ nbox = RegionNumRects (bounding);
+ boundBox = RegionRects (bounding);
+ someIn = someOut = FALSE;
+ x1 = rect->x1;
+ y1 = rect->y1;
+ x2 = rect->x2;
+ y2 = rect->y2;
+ while (nbox--)
+ {
+ if ((t = boundBox->x1 + x) < x1)
+ t = x1;
+ box.x1 = t;
+ if ((t = boundBox->y1 + y) < y1)
+ t = y1;
+ box.y1 = t;
+ if ((t = boundBox->x2 + x) > x2)
+ t = x2;
+ box.x2 = t;
+ if ((t = boundBox->y2 + y) > y2)
+ t = y2;
+ box.y2 = t;
+ if (box.x1 > box.x2)
+ box.x2 = box.x1;
+ if (box.y1 > box.y2)
+ box.y2 = box.y1;
+ switch (RegionContainsRect(universe, &box))
+ {
+ case rgnIN:
+ if (someOut)
+ return rgnPART;
+ someIn = TRUE;
+ break;
+ case rgnOUT:
+ if (someIn)
+ return rgnPART;
+ someOut = TRUE;
+ break;
+ default:
+ return rgnPART;
+ }
+ boundBox++;
+ }
+ if (someIn)
+ return rgnIN;
+ return rgnOUT;
+}
+
+#define HasParentRelativeBorder(w) (!(w)->borderIsPixel && \
+ HasBorder(w) && \
+ (w)->backgroundState == ParentRelative)
+
+
+/*
+ *-----------------------------------------------------------------------
+ * RootlessComputeClips --
+ * Recompute the clipList, borderClip, exposed and borderExposed
+ * regions for pParent and its children. Only viewable windows are
+ * taken into account.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * clipList, borderClip, exposed and borderExposed are altered.
+ * A VisibilityNotify event may be generated on the parent window.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
+ RegionPtr universe, VTKind kind, RegionPtr exposed)
+{
+ int dx,
+ dy;
+ RegionRec childUniverse;
+ register WindowPtr pChild;
+ int oldVis, newVis;
+ BoxRec borderSize;
+ RegionRec childUnion;
+ Bool overlap;
+ RegionPtr borderVisible;
+ Bool resized;
+ /*
+ * Figure out the new visibility of this window.
+ * The extent of the universe should be the same as the extent of
+ * the borderSize region. If the window is unobscured, this rectangle
+ * will be completely inside the universe (the universe will cover it
+ * completely). If the window is completely obscured, none of the
+ * universe will cover the rectangle.
+ */
+ borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent);
+ borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent);
+ dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent);
+ if (dx > 32767)
+ dx = 32767;
+ borderSize.x2 = dx;
+ dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent);
+ if (dy > 32767)
+ dy = 32767;
+ borderSize.y2 = dy;
+
+ oldVis = pParent->visibility;
+ switch (RegionContainsRect(universe, &borderSize))
+ {
+ case rgnIN:
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnPART:
+ newVis = VisibilityPartiallyObscured;
+ {
+ RegionPtr pBounding;
+
+ if ((pBounding = wBoundingShape (pParent)))
+ {
+ switch (RootlessShapedWindowIn (universe,
+ pBounding, &borderSize,
+ pParent->drawable.x,
+ pParent->drawable.y))
+ {
+ case rgnIN:
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnOUT:
+ newVis = VisibilityFullyObscured;
+ break;
+ }
+ }
+ }
+ break;
+ default:
+ newVis = VisibilityFullyObscured;
+ break;
+ }
+
+ pParent->visibility = newVis;
+ if (oldVis != newVis &&
+ ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask))
+ SendVisibilityNotify(pParent);
+
+ dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x;
+ dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y;
+
+ /*
+ * avoid computations when dealing with simple operations
+ */
+
+ switch (kind) {
+ case VTMap:
+ case VTStack:
+ case VTUnmap:
+ break;
+ case VTMove:
+ if ((oldVis == newVis) &&
+ ((oldVis == VisibilityFullyObscured) ||
+ (oldVis == VisibilityUnobscured)))
+ {
+ pChild = pParent;
+ while (1)
+ {
+ if (pChild->viewable)
+ {
+ if (pChild->visibility != VisibilityFullyObscured)
+ {
+ RegionTranslate(&pChild->borderClip,
+ dx, dy);
+ RegionTranslate(&pChild->clipList,
+ dx, dy);
+ pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pChild, dx, dy);
+
+ }
+ if (pChild->valdata)
+ {
+ RegionNull(&pChild->valdata->after.borderExposed);
+ if (HasParentRelativeBorder(pChild))
+ {
+ RegionSubtract(&pChild->valdata->after.borderExposed,
+ &pChild->borderClip,
+ &pChild->winSize);
+ }
+ RegionNull(&pChild->valdata->after.exposed);
+ }
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pParent))
+ pChild = pChild->parent;
+ if (pChild == pParent)
+ break;
+ pChild = pChild->nextSib;
+ }
+ return;
+ }
+ /* fall through */
+ default:
+ /*
+ * To calculate exposures correctly, we have to translate the old
+ * borderClip and clipList regions to the window's new location so there
+ * is a correspondence between pieces of the new and old clipping regions.
+ */
+ if (dx || dy)
+ {
+ /*
+ * We translate the old clipList because that will be exposed or copied
+ * if gravity is right.
+ */
+ RegionTranslate(&pParent->borderClip, dx, dy);
+ RegionTranslate(&pParent->clipList, dx, dy);
+ }
+ break;
+ case VTBroken:
+ RegionEmpty(&pParent->borderClip);
+ RegionEmpty(&pParent->clipList);
+ break;
+ }
+
+ borderVisible = pParent->valdata->before.borderVisible;
+ resized = pParent->valdata->before.resized;
+ RegionNull(&pParent->valdata->after.borderExposed);
+ RegionNull(&pParent->valdata->after.exposed);
+
+ /*
+ * Since the borderClip must not be clipped by the children, we do
+ * the border exposure first...
+ *
+ * 'universe' is the window's borderClip. To figure the exposures, remove
+ * the area that used to be exposed from the new.
+ * This leaves a region of pieces that weren't exposed before.
+ */
+
+ if (HasBorder (pParent))
+ {
+ if (borderVisible)
+ {
+ /*
+ * when the border changes shape, the old visible portions
+ * of the border will be saved by DIX in borderVisible --
+ * use that region and destroy it
+ */
+ RegionSubtract(exposed, universe, borderVisible);
+ RegionDestroy(borderVisible);
+ }
+ else
+ {
+ RegionSubtract(exposed, universe, &pParent->borderClip);
+ }
+ if (HasParentRelativeBorder(pParent) && (dx || dy)) {
+ RegionSubtract(&pParent->valdata->after.borderExposed,
+ universe,
+ &pParent->winSize);
+ } else {
+ RegionSubtract(&pParent->valdata->after.borderExposed,
+ exposed, &pParent->winSize);
+ }
+
+ RegionCopy(&pParent->borderClip, universe);
+
+ /*
+ * To get the right clipList for the parent, and to make doubly sure
+ * that no child overlaps the parent's border, we remove the parent's
+ * border from the universe before proceeding.
+ */
+
+ RegionIntersect(universe, universe, &pParent->winSize);
+ }
+ else
+ RegionCopy(&pParent->borderClip, universe);
+
+ if ((pChild = pParent->firstChild) && pParent->mapped)
+ {
+ RegionNull(&childUniverse);
+ RegionNull(&childUnion);
+ if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
+ ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
+ (pChild->drawable.x < pParent->lastChild->drawable.x)))
+ {
+ for (; pChild; pChild = pChild->nextSib)
+ {
+ if (pChild->viewable)
+ RegionAppend(&childUnion, &pChild->borderSize);
+ }
+ }
+ else
+ {
+ for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib)
+ {
+ if (pChild->viewable)
+ RegionAppend(&childUnion, &pChild->borderSize);
+ }
+ }
+ RegionValidate(&childUnion, &overlap);
+
+ for (pChild = pParent->firstChild;
+ pChild;
+ pChild = pChild->nextSib)
+ {
+ if (pChild->viewable) {
+ /*
+ * If the child is viewable, we want to remove its extents
+ * from the current universe, but we only re-clip it if
+ * it's been marked.
+ */
+ if (pChild->valdata) {
+ /*
+ * Figure out the new universe from the child's
+ * perspective and recurse.
+ */
+ RegionIntersect(&childUniverse,
+ universe,
+ &pChild->borderSize);
+ RootlessComputeClips (pChild, pScreen, &childUniverse,
+ kind, exposed);
+ }
+ /*
+ * Once the child has been processed, we remove its extents
+ * from the current universe, thus denying its space to any
+ * other sibling.
+ */
+ if (overlap)
+ RegionSubtract(universe, universe,
+ &pChild->borderSize);
+ }
+ }
+ if (!overlap)
+ RegionSubtract(universe, universe, &childUnion);
+ RegionUninit(&childUnion);
+ RegionUninit(&childUniverse);
+ } /* if any children */
+
+ /*
+ * 'universe' now contains the new clipList for the parent window.
+ *
+ * To figure the exposure of the window we subtract the old clip from the
+ * new, just as for the border.
+ */
+
+ if (oldVis == VisibilityFullyObscured ||
+ oldVis == VisibilityNotViewable)
+ {
+ RegionCopy(&pParent->valdata->after.exposed, universe);
+ }
+ else if (newVis != VisibilityFullyObscured &&
+ newVis != VisibilityNotViewable)
+ {
+ RegionSubtract(&pParent->valdata->after.exposed,
+ universe, &pParent->clipList);
+ }
+
+ /*
+ * One last thing: backing storage. We have to try to save what parts of
+ * the window are about to be obscured. We can just subtract the universe
+ * from the old clipList and get the areas that were in the old but aren't
+ * in the new and, hence, are about to be obscured.
+ */
+ if (pParent->backStorage && !resized)
+ {
+ RegionSubtract(exposed, &pParent->clipList, universe);
+ (* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy);
+ }
+
+ /* HACK ALERT - copying contents of regions, instead of regions */
+ {
+ RegionRec tmp;
+
+ tmp = pParent->clipList;
+ pParent->clipList = *universe;
+ *universe = tmp;
+ }
+
+#ifdef NOTDEF
+ RegionCopy(&pParent->clipList, universe);
+#endif
+
+ pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pParent, dx, dy);
+}
+
+static void
+RootlessTreeObscured(WindowPtr pParent)
+{
+ register WindowPtr pChild;
+ register int oldVis;
+
+ pChild = pParent;
+ while (1)
+ {
+ if (pChild->viewable)
+ {
+ oldVis = pChild->visibility;
+ if (oldVis != (pChild->visibility = VisibilityFullyObscured) &&
+ ((pChild->eventMask | wOtherEventMasks(pChild)) & VisibilityChangeMask))
+ SendVisibilityNotify(pChild);
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pParent))
+ pChild = pChild->parent;
+ if (pChild == pParent)
+ break;
+ pChild = pChild->nextSib;
+ }
+}
+
+/*
+ *-----------------------------------------------------------------------
+ * RootlessMiValidateTree --
+ * Recomputes the clip list for pParent and all its inferiors.
+ *
+ * Results:
+ * Always returns 1.
+ *
+ * Side Effects:
+ * The clipList, borderClip, exposed, and borderExposed regions for
+ * each marked window are altered.
+ *
+ * Notes:
+ * This routine assumes that all affected windows have been marked
+ * (valdata created) and their winSize and borderSize regions
+ * adjusted to correspond to their new positions. The borderClip and
+ * clipList regions should not have been touched.
+ *
+ * The top-most level is treated differently from all lower levels
+ * because pParent is unchanged. For the top level, we merge the
+ * regions taken up by the marked children back into the clipList
+ * for pParent, thus forming a region from which the marked children
+ * can claim their areas. For lower levels, where the old clipList
+ * and borderClip are invalid, we can't do this and have to do the
+ * extra operations done in miComputeClips, but this is much faster
+ * e.g. when only one child has moved...
+ *
+ *-----------------------------------------------------------------------
+ */
+/*
+ Quartz version: used for validate from root in rootless mode.
+ We need to make sure top-level windows don't clip each other,
+ and that top-level windows aren't clipped to the root window.
+*/
+/*ARGSUSED*/
+// fixme this is ugly
+// Xprint/ValTree.c doesn't work, but maybe that method can?
+int
+RootlessMiValidateTree (WindowPtr pRoot, /* Parent to validate */
+ WindowPtr pChild, /* First child of pRoot that was
+ * affected */
+ VTKind kind /* What kind of configuration caused call */)
+{
+ RegionRec childClip; /* The new borderClip for the current
+ * child */
+ RegionRec exposed; /* For intermediate calculations */
+ register ScreenPtr pScreen;
+ register WindowPtr pWin;
+
+ pScreen = pRoot->drawable.pScreen;
+ if (pChild == NullWindow)
+ pChild = pRoot->firstChild;
+
+ RegionNull(&childClip);
+ RegionNull(&exposed);
+
+ if (RegionBroken(&pRoot->clipList) &&
+ !RegionBroken(&pRoot->borderClip))
+ {
+ // fixme this might not work, but hopefully doesn't happen anyway.
+ kind = VTBroken;
+ RegionEmpty(&pRoot->clipList);
+ ErrorF("ValidateTree: BUSTED!\n");
+ }
+
+ /*
+ * Recursively compute the clips for all children of the root.
+ * They don't clip against each other or the root itself, so
+ * childClip is always reset to that child's size.
+ */
+
+ for (pWin = pChild;
+ pWin != NullWindow;
+ pWin = pWin->nextSib)
+ {
+ if (pWin->viewable) {
+ if (pWin->valdata) {
+ RegionCopy(&childClip, &pWin->borderSize);
+ RootlessComputeClips (pWin, pScreen, &childClip, kind, &exposed);
+ } else if (pWin->visibility == VisibilityNotViewable) {
+ RootlessTreeObscured(pWin);
+ }
+ } else {
+ if (pWin->valdata) {
+ RegionEmpty(&pWin->clipList);
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pWin, 0, 0);
+ RegionEmpty(&pWin->borderClip);
+ pWin->valdata = NULL;
+ }
+ }
+ }
+
+ RegionUninit(&childClip);
+
+ /* The root is never clipped by its children, so nothing on the root
+ is ever exposed by moving or mapping its children. */
+ RegionNull(&pRoot->valdata->after.exposed);
+ RegionNull(&pRoot->valdata->after.borderExposed);
+
+ return 1;
+}
diff --git a/xorg-server/miext/rootless/rootlessWindow.c b/xorg-server/miext/rootless/rootlessWindow.c index a78757086..723d2b491 100644 --- a/xorg-server/miext/rootless/rootlessWindow.c +++ b/xorg-server/miext/rootless/rootlessWindow.c @@ -59,9 +59,9 @@ extern int darwinMainScreenX, darwinMainScreenY; #ifdef ROOTLESS_GLOBAL_COORDS
#define SCREEN_TO_GLOBAL_X \
- (dixScreenOrigins[pScreen->myNum].x + rootlessGlobalOffsetX)
+ (pScreen->x + rootlessGlobalOffsetX)
#define SCREEN_TO_GLOBAL_Y \
- (dixScreenOrigins[pScreen->myNum].y + rootlessGlobalOffsetY)
+ (pScreen->y + rootlessGlobalOffsetY)
#else
#define SCREEN_TO_GLOBAL_X 0
#define SCREEN_TO_GLOBAL_Y 0
@@ -115,8 +115,8 @@ void RootlessNativeWindowMoved (WindowPtr pWin) { if (xp_get_window_bounds (MAKE_WINDOW_ID(winRec->wid), &bounds) != Success) return;
- sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX;
- sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY;
+ sx = pWin->drawable.pScreen->x + darwinMainScreenX;
+ sy = pWin->drawable.pScreen->y + darwinMainScreenY;
/* Fake up a ConfigureWindow packet to resize the window to the current bounds. */
vlist[0] = (INT16) bounds.x1 - sx;
@@ -185,12 +185,10 @@ RootlessCreateWindow(WindowPtr pWin) static void
RootlessDestroyFrame(WindowPtr pWin, RootlessWindowPtr winRec)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- SCREENREC(pScreen)->imp->DestroyFrame(winRec->wid);
+ SCREENREC(pWin->drawable.pScreen)->imp->DestroyFrame(winRec->wid);
#ifdef ROOTLESS_TRACK_DAMAGE
- REGION_UNINIT(pScreen, &winRec->damage);
+ RegionUninit(&winRec->damage);
#endif
free(winRec);
@@ -224,23 +222,15 @@ RootlessDestroyWindow(WindowPtr pWin) static Bool
RootlessGetShape(WindowPtr pWin, RegionPtr pShape)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- /*
- * Avoid a warning.
- * REGION_NULL and the other macros don't actually seem to use pScreen.
- */
- (void)pScreen;
-
if (wBoundingShape(pWin) == NULL)
return FALSE;
/* wBoundingShape is relative to *inner* origin of window.
Translate by borderWidth to get the outside-relative position. */
- REGION_NULL(pScreen, pShape);
- REGION_COPY(pScreen, pShape, wBoundingShape(pWin));
- REGION_TRANSLATE(pScreen, pShape, pWin->borderWidth, pWin->borderWidth);
+ RegionNull(pShape);
+ RegionCopy(pShape, wBoundingShape(pWin));
+ RegionTranslate(pShape, pWin->borderWidth, pWin->borderWidth);
return TRUE;
}
@@ -253,7 +243,6 @@ RootlessGetShape(WindowPtr pWin, RegionPtr pShape) static void RootlessReshapeFrame(WindowPtr pWin)
{
RootlessWindowRec *winRec = WINREC(pWin);
- ScreenPtr pScreen = pWin->drawable.pScreen;
RegionRec newShape;
RegionPtr pShape;
@@ -272,7 +261,7 @@ static void RootlessReshapeFrame(WindowPtr pWin) RL_DEBUG_MSG("reshaping...");
if (pShape != NULL) {
RL_DEBUG_MSG("numrects %d, extents %d %d %d %d ",
- REGION_NUM_RECTS(&newShape),
+ RegionNumRects(&newShape),
newShape.extents.x1, newShape.extents.y1,
newShape.extents.x2, newShape.extents.y2);
} else {
@@ -280,10 +269,10 @@ static void RootlessReshapeFrame(WindowPtr pWin) }
#endif
- SCREENREC(pScreen)->imp->ReshapeFrame(winRec->wid, pShape);
+ SCREENREC(pWin->drawable.pScreen)->imp->ReshapeFrame(winRec->wid, pShape);
if (pShape != NULL)
- REGION_UNINIT(pScreen, &newShape);
+ RegionUninit(&newShape);
}
@@ -294,12 +283,12 @@ static void RootlessReshapeFrame(WindowPtr pWin) * shaped when the window is framed.
*/
void
-RootlessSetShape(WindowPtr pWin)
+RootlessSetShape(WindowPtr pWin, int kind)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
SCREEN_UNWRAP(pScreen, SetShape);
- pScreen->SetShape(pWin);
+ pScreen->SetShape(pWin, kind);
SCREEN_WRAP(pScreen, SetShape);
RootlessReshapeFrame(pWin);
@@ -361,8 +350,8 @@ RootlessPositionWindow(WindowPtr pWin, int x, int y) #ifdef ROOTLESS_TRACK_DAMAGE
// Move damaged region to correspond to new window position
- if (REGION_NOTEMPTY(pScreen, &winRec->damage)) {
- REGION_TRANSLATE(pScreen, &winRec->damage,
+ if (RegionNotEmpty(&winRec->damage)) {
+ RegionTranslate(&winRec->damage,
x - bw - winRec->x,
y - bw - winRec->y);
}
@@ -400,7 +389,7 @@ RootlessInitializeFrame(WindowPtr pWin, RootlessWindowRec *winRec) winRec->borderWidth = bw;
#ifdef ROOTLESS_TRACK_DAMAGE
- REGION_NULL(pScreen, &winRec->damage);
+ RegionNull(&winRec->damage);
#endif
}
@@ -463,7 +452,7 @@ RootlessEnsureFrame(WindowPtr pWin) RootlessFlushWindowColormap(pWin);
if (pShape != NULL)
- REGION_UNINIT(pScreen, &shape);
+ RegionUninit(&shape);
return winRec;
}
@@ -679,7 +668,7 @@ RootlessNoCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RL_DEBUG_MSG("ROOTLESSNOCOPYWINDOW ");
- REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+ RegionTranslate(prgnSrc, -dx, -dy);
}
@@ -711,9 +700,9 @@ RootlessResizeCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
- REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
- REGION_NULL(pScreen, &rgnDst);
- REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionNull(&rgnDst);
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
if (gResizeDeathCount == 1) {
/* Simple case, we only have a single source pixmap. */
@@ -730,21 +719,21 @@ RootlessResizeCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, intersect the destination with each source and copy those bits. */
for (i = 0; i < gResizeDeathCount; i++) {
- REGION_INIT(pScreen, &clip, gResizeDeathBounds + 0, 1);
- REGION_NULL(pScreen, &clipped);
- REGION_INTERSECT(pScreen, &rgnDst, &clip, &clipped);
+ RegionInit(&clip, gResizeDeathBounds + 0, 1);
+ RegionNull(&clipped);
+ RegionIntersect(&rgnDst, &clip, &clipped);
fbCopyRegion(&gResizeDeathPix[i]->drawable,
&pScreen->GetWindowPixmap(pWin)->drawable, 0,
&clipped, dx, dy, fbCopyWindowProc, 0, 0);
- REGION_UNINIT(pScreen, &clipped);
- REGION_UNINIT(pScreen, &clip);
+ RegionUninit(&clipped);
+ RegionUninit(&clip);
}
}
/* Don't update - resize will update everything */
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
fbValidateDrawable(&pWin->drawable);
@@ -774,12 +763,12 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
- REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
+ RegionTranslate(prgnSrc, -dx, -dy);
- REGION_NULL(pScreen, &rgnDst);
- REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+ RegionNull(&rgnDst);
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
- extents = REGION_EXTENTS(pScreen, &rgnDst);
+ extents = RegionExtents(&rgnDst);
area = (extents->x2 - extents->x1) * (extents->y2 - extents->y1);
/* If the area exceeds threshold, use the implementation's
@@ -803,13 +792,13 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) }
/* Move region to window local coords */
- REGION_TRANSLATE(pScreen, &rgnDst, -winRec->x, -winRec->y);
+ RegionTranslate(&rgnDst, -winRec->x, -winRec->y);
RootlessStopDrawing(pWin, FALSE);
SCREENREC(pScreen)->imp->CopyWindow(winRec->wid,
- REGION_NUM_RECTS(&rgnDst),
- REGION_RECTS(&rgnDst),
+ RegionNumRects(&rgnDst),
+ RegionRects(&rgnDst),
dx, dy);
}
else {
@@ -823,7 +812,7 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) }
out:
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
fbValidateDrawable(&pWin->drawable);
SCREEN_WRAP(pScreen, CopyWindow);
@@ -1326,11 +1315,11 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y, box.x1 = x; box.y1 = y;
box.x2 = x + w; box.y2 = y + h;
- REGION_UNINIT(pScreen, &pWin->winSize);
- REGION_INIT(pScreen, &pWin->winSize, &box, 1);
- REGION_COPY(pScreen, &pWin->borderSize, &pWin->winSize);
- REGION_COPY(pScreen, &pWin->clipList, &pWin->winSize);
- REGION_COPY(pScreen, &pWin->borderClip, &pWin->winSize);
+ RegionUninit(&pWin->winSize);
+ RegionInit(&pWin->winSize, &box, 1);
+ RegionCopy(&pWin->borderSize, &pWin->winSize);
+ RegionCopy(&pWin->clipList, &pWin->winSize);
+ RegionCopy(&pWin->borderClip, &pWin->winSize);
miSendExposures(pWin, &pWin->borderClip,
pWin->drawable.x, pWin->drawable.y);
@@ -1523,7 +1512,7 @@ RootlessOrderAllWindows (void) RL_DEBUG_MSG("RootlessOrderAllWindows() ");
for (i = 0; i < screenInfo.numScreens; i++) {
if (screenInfo.screens[i] == NULL) continue;
- pWin = WindowTable[i];
+ pWin = screenInfo.screens[i]->root;
if (pWin == NULL) continue;
for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib) {
@@ -1539,7 +1528,7 @@ void RootlessEnableRoot (ScreenPtr pScreen)
{
WindowPtr pRoot;
- pRoot = WindowTable[pScreen->myNum];
+ pRoot = pScreen->root;
RootlessEnsureFrame (pRoot);
(*pScreen->ClearToBackground) (pRoot, 0, 0, 0, 0, TRUE);
@@ -1552,7 +1541,7 @@ RootlessDisableRoot (ScreenPtr pScreen) WindowPtr pRoot;
RootlessWindowRec *winRec;
- pRoot = WindowTable[pScreen->myNum];
+ pRoot = pScreen->root;
winRec = WINREC (pRoot);
if (NULL == winRec)
@@ -1578,8 +1567,10 @@ RootlessHideAllWindows (void) for (i = 0; i < screenInfo.numScreens; i++)
{
pScreen = screenInfo.screens[i];
- pWin = WindowTable[i];
- if (pScreen == NULL || pWin == NULL)
+ if (pScreen == NULL)
+ continue;
+ pWin = pScreen->root;
+ if (pWin == NULL)
continue;
for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib)
@@ -1615,8 +1606,10 @@ RootlessShowAllWindows (void) for (i = 0; i < screenInfo.numScreens; i++)
{
pScreen = screenInfo.screens[i];
- pWin = WindowTable[i];
- if (pScreen == NULL || pWin == NULL)
+ if (pScreen == NULL)
+ continue;
+ pWin = pScreen->root;
+ if (pWin == NULL)
continue;
for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib)
diff --git a/xorg-server/miext/rootless/rootlessWindow.h b/xorg-server/miext/rootless/rootlessWindow.h index ca104a4d7..2da96e661 100644 --- a/xorg-server/miext/rootless/rootlessWindow.h +++ b/xorg-server/miext/rootless/rootlessWindow.h @@ -1,60 +1,60 @@ -/* - * Rootless window management - */ -/* - * Copyright (c) 2001 Greg Parker. 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 - -#ifndef _ROOTLESSWINDOW_H -#define _ROOTLESSWINDOW_H - -#include "rootlessCommon.h" - -Bool RootlessCreateWindow(WindowPtr pWin); -Bool RootlessDestroyWindow(WindowPtr pWin); - -void RootlessSetShape(WindowPtr pWin); - -Bool RootlessChangeWindowAttributes(WindowPtr pWin, unsigned long vmask); -Bool RootlessPositionWindow(WindowPtr pWin, int x, int y); -Bool RootlessRealizeWindow(WindowPtr pWin); -Bool RootlessUnrealizeWindow(WindowPtr pWin); -void RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib); -void RootlessCopyWindow(WindowPtr pWin,DDXPointRec ptOldOrg,RegionPtr prgnSrc); -void RootlessMoveWindow(WindowPtr pWin,int x,int y,WindowPtr pSib,VTKind kind); -void RootlessResizeWindow(WindowPtr pWin, int x, int y, - unsigned int w, unsigned int h, WindowPtr pSib); -void RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent); -void RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width); -#ifdef __APPLE__ -void RootlessNativeWindowMoved (WindowPtr pWin); -void RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state); -#endif - -#endif +/*
+ * Rootless window management
+ */
+/*
+ * Copyright (c) 2001 Greg Parker. 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
+
+#ifndef _ROOTLESSWINDOW_H
+#define _ROOTLESSWINDOW_H
+
+#include "rootlessCommon.h"
+
+Bool RootlessCreateWindow(WindowPtr pWin);
+Bool RootlessDestroyWindow(WindowPtr pWin);
+
+void RootlessSetShape(WindowPtr pWin, int kind);
+
+Bool RootlessChangeWindowAttributes(WindowPtr pWin, unsigned long vmask);
+Bool RootlessPositionWindow(WindowPtr pWin, int x, int y);
+Bool RootlessRealizeWindow(WindowPtr pWin);
+Bool RootlessUnrealizeWindow(WindowPtr pWin);
+void RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib);
+void RootlessCopyWindow(WindowPtr pWin,DDXPointRec ptOldOrg,RegionPtr prgnSrc);
+void RootlessMoveWindow(WindowPtr pWin,int x,int y,WindowPtr pSib,VTKind kind);
+void RootlessResizeWindow(WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib);
+void RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent);
+void RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width);
+#ifdef __APPLE__
+void RootlessNativeWindowMoved (WindowPtr pWin);
+void RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state);
+#endif
+
+#endif
diff --git a/xorg-server/miext/shadow/shadow.c b/xorg-server/miext/shadow/shadow.c index 2dcee60b1..7bc1d9ca0 100644 --- a/xorg-server/miext/shadow/shadow.c +++ b/xorg-server/miext/shadow/shadow.c @@ -36,8 +36,8 @@ #include "gcstruct.h"
#include "shadow.h"
-static int shadowScrPrivateKeyIndex;
-DevPrivateKey shadowScrPrivateKey = &shadowScrPrivateKeyIndex;
+static DevPrivateKeyRec shadowScrPrivateKeyRec;
+#define shadowScrPrivateKey (&shadowScrPrivateKeyRec)
#define wrap(priv, real, mem) {\
priv->mem = real->mem; \
@@ -57,7 +57,7 @@ shadowRedisplay(ScreenPtr pScreen) if (!pBuf || !pBuf->pDamage || !pBuf->update)
return;
pRegion = DamageRegion(pBuf->pDamage);
- if (REGION_NOTEMPTY(pScreen, pRegion)) {
+ if (RegionNotEmpty(pRegion)) {
(*pBuf->update)(pScreen, pBuf);
DamageEmpty(pBuf->pDamage);
}
@@ -103,7 +103,7 @@ shadowCloseScreen(int i, ScreenPtr pScreen) shadowRemove(pScreen, pBuf->pPixmap);
DamageDestroy(pBuf->pDamage);
#ifdef BACKWARDS_COMPATIBILITY
- REGION_UNINIT(pScreen, &pBuf->damage); /* bc */
+ RegionUninit(&pBuf->damage); /* bc */
#endif
if (pBuf->pPixmap)
pScreen->DestroyPixmap(pBuf->pPixmap);
@@ -121,13 +121,13 @@ shadowReportFunc(DamagePtr pDamage, RegionPtr pRegion, void *closure) /* Register the damaged region, use DamageReportNone below when we
* want to break BC below... */
- REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage, pRegion);
+ RegionUnion(&pDamage->damage, &pDamage->damage, pRegion);
/*
* BC hack. In 7.0 and earlier several drivers would inspect the
* 'damage' member directly, so we have to keep it existing.
*/
- REGION_COPY(pScreen, &pBuf->damage, pRegion);
+ RegionCopy(&pBuf->damage, pRegion);
}
#endif
@@ -136,6 +136,9 @@ shadowSetup(ScreenPtr pScreen) {
shadowBufPtr pBuf;
+ if (!dixRegisterPrivateKey(&shadowScrPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
if (!DamageSetup(pScreen))
return FALSE;
@@ -166,7 +169,7 @@ shadowSetup(ScreenPtr pScreen) pBuf->closure = 0;
pBuf->randr = 0;
#ifdef BACKWARDS_COMPATIBILITY
- REGION_NULL(pScreen, &pBuf->damage); /* bc */
+ RegionNull(&pBuf->damage); /* bc */
#endif
dixSetPrivate(&pScreen->devPrivates, shadowScrPrivateKey, pBuf);
diff --git a/xorg-server/miext/shadow/shpacked.c b/xorg-server/miext/shadow/shpacked.c index 6736162e2..9bc869a8d 100644 --- a/xorg-server/miext/shadow/shpacked.c +++ b/xorg-server/miext/shadow/shpacked.c @@ -1,118 +1,118 @@ -/* - * - * Copyright © 2000 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdlib.h> - -#include <X11/X.h> -#include "scrnintstr.h" -#include "windowstr.h" -#include <X11/fonts/font.h> -#include "dixfontstr.h" -#include <X11/fonts/fontstruct.h> -#include "mi.h" -#include "regionstr.h" -#include "globals.h" -#include "gcstruct.h" -#include "shadow.h" -#include "fb.h" - -void -shadowUpdatePacked (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - RegionPtr damage = shadowDamage (pBuf); - PixmapPtr pShadow = pBuf->pPixmap; - int nbox = REGION_NUM_RECTS (damage); - BoxPtr pbox = REGION_RECTS (damage); - FbBits *shaBase, *shaLine, *sha; - FbStride shaStride; - int scrBase, scrLine, scr; - int shaBpp; - int shaXoff, shaYoff; /* XXX assumed to be zero */ - int x, y, w, h, width; - int i; - FbBits *winBase = NULL, *win; - CARD32 winSize; - - fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); - while (nbox--) - { - x = pbox->x1 * shaBpp; - y = pbox->y1; - w = (pbox->x2 - pbox->x1) * shaBpp; - h = pbox->y2 - pbox->y1; - - scrLine = (x >> FB_SHIFT); - shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); - - x &= FB_MASK; - w = (w + x + FB_MASK) >> FB_SHIFT; - - while (h--) - { - winSize = 0; - scrBase = 0; - width = w; - scr = scrLine; - sha = shaLine; - while (width) { - /* how much remains in this window */ - i = scrBase + winSize - scr; - if (i <= 0 || scr < scrBase) - { - winBase = (FbBits *) (*pBuf->window) (pScreen, - y, - scr * sizeof (FbBits), - SHADOW_WINDOW_WRITE, - &winSize, - pBuf->closure); - if(!winBase) - return; - scrBase = scr; - winSize /= sizeof (FbBits); - i = winSize; - } - win = winBase + (scr - scrBase); - if (i > width) - i = width; - width -= i; - scr += i; -#define PickBit(a,i) (((a) >> (i)) & 1) - while (i--) - *win++ = *sha++; - } - shaLine += shaStride; - y++; - } - pbox++; - } -} - -shadowUpdateProc -shadowUpdatePackedWeak(void) { - return shadowUpdatePacked; -} +/*
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+#include "fb.h"
+
+void
+shadowUpdatePacked (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = shadowDamage (pBuf);
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = RegionNumRects (damage);
+ BoxPtr pbox = RegionRects (damage);
+ FbBits *shaBase, *shaLine, *sha;
+ FbStride shaStride;
+ int scrBase, scrLine, scr;
+ int shaBpp;
+ int shaXoff, shaYoff; /* XXX assumed to be zero */
+ int x, y, w, h, width;
+ int i;
+ FbBits *winBase = NULL, *win;
+ CARD32 winSize;
+
+ fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff);
+ while (nbox--)
+ {
+ x = pbox->x1 * shaBpp;
+ y = pbox->y1;
+ w = (pbox->x2 - pbox->x1) * shaBpp;
+ h = pbox->y2 - pbox->y1;
+
+ scrLine = (x >> FB_SHIFT);
+ shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
+
+ x &= FB_MASK;
+ w = (w + x + FB_MASK) >> FB_SHIFT;
+
+ while (h--)
+ {
+ winSize = 0;
+ scrBase = 0;
+ width = w;
+ scr = scrLine;
+ sha = shaLine;
+ while (width) {
+ /* how much remains in this window */
+ i = scrBase + winSize - scr;
+ if (i <= 0 || scr < scrBase)
+ {
+ winBase = (FbBits *) (*pBuf->window) (pScreen,
+ y,
+ scr * sizeof (FbBits),
+ SHADOW_WINDOW_WRITE,
+ &winSize,
+ pBuf->closure);
+ if(!winBase)
+ return;
+ scrBase = scr;
+ winSize /= sizeof (FbBits);
+ i = winSize;
+ }
+ win = winBase + (scr - scrBase);
+ if (i > width)
+ i = width;
+ width -= i;
+ scr += i;
+#define PickBit(a,i) (((a) >> (i)) & 1)
+ while (i--)
+ *win++ = *sha++;
+ }
+ shaLine += shaStride;
+ y++;
+ }
+ pbox++;
+ }
+}
+
+shadowUpdateProc
+shadowUpdatePackedWeak(void) {
+ return shadowUpdatePacked;
+}
diff --git a/xorg-server/miext/shadow/shplanar.c b/xorg-server/miext/shadow/shplanar.c index b5983dc73..381eba986 100644 --- a/xorg-server/miext/shadow/shplanar.c +++ b/xorg-server/miext/shadow/shplanar.c @@ -1,180 +1,180 @@ -/* - * - * Copyright © 2000 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdlib.h> - -#include <X11/X.h> -#include "scrnintstr.h" -#include "windowstr.h" -#include <X11/fonts/font.h> -#include "dixfontstr.h" -#include <X11/fonts/fontstruct.h> -#include "mi.h" -#include "regionstr.h" -#include "globals.h" -#include "gcstruct.h" -#include "shadow.h" -#include "fb.h" - -/* - * 32 4-bit pixels per write - */ - -#define PL_SHIFT 7 -#define PL_UNIT (1 << PL_SHIFT) -#define PL_MASK (PL_UNIT - 1) - -/* - * 32->8 conversion: - * - * 7 6 5 4 3 2 1 0 - * A B C D E F G H - * - * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 - * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 - * m . . . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A - * m1 G . . . F . . . E . . . D . . . C . . . B . . . A . . . . . . . m << (7 - (p)) - * m2 . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A . . (m >> (p)) << 2 - * m3 G E C A m1 & 0x80808080 - * m4 H F D B m2 & 0x40404040 - * m5 G H E F C D A B m3 | m4 - * m6 G H E F C D G H A B E F m5 | (m5 >> 20) - * m7 G H E F C D G H A B C D E F G H m6 | (m6 >> 10) - */ - -#if 0 -#define GetBits(p,o,d) {\ - m = sha[o]; \ - m1 = m << (7 - (p)); \ - m2 = (m >> (p)) << 2; \ - m3 = m1 & 0x80808080; \ - m4 = m2 & 0x40404040; \ - m5 = m3 | m4; \ - m6 = m5 | (m5 >> 20); \ - d = m6 | (m6 >> 10); \ -} -#else -#define GetBits(p,o,d) {\ - m = sha[o]; \ - m5 = ((m << (7 - (p))) & 0x80808080) | (((m >> (p)) << 2) & 0x40404040); \ - m6 = m5 | (m5 >> 20); \ - d = m6 | (m6 >> 10); \ -} -#endif - -void -shadowUpdatePlanar4 (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - RegionPtr damage = shadowDamage (pBuf); - PixmapPtr pShadow = pBuf->pPixmap; - int nbox = REGION_NUM_RECTS (damage); - BoxPtr pbox = REGION_RECTS (damage); - CARD32 *shaBase, *shaLine, *sha; - FbStride shaStride; - int scrBase, scrLine, scr; - int shaBpp; - int shaXoff, shaYoff; /* XXX assumed to be zero */ - int x, y, w, h, width; - int i; - CARD32 *winBase = NULL, *win; - CARD32 winSize; - int plane; - CARD32 m,m5,m6; - CARD8 s1, s2, s3, s4; - - fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); - while (nbox--) - { - x = (pbox->x1) * shaBpp; - y = (pbox->y1); - w = (pbox->x2 - pbox->x1) * shaBpp; - h = pbox->y2 - pbox->y1; - - w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT; - x &= ~PL_MASK; - - scrLine = (x >> PL_SHIFT); - shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); - - while (h--) - { - for (plane = 0; plane < 4; plane++) - { - width = w; - scr = scrLine; - sha = shaLine; - winSize = 0; - scrBase = 0; - while (width) { - /* how much remains in this window */ - i = scrBase + winSize - scr; - if (i <= 0 || scr < scrBase) - { - winBase = (CARD32 *) (*pBuf->window) (pScreen, - y, - (scr << 4) | (plane), - SHADOW_WINDOW_WRITE, - &winSize, - pBuf->closure); - if(!winBase) - return; - winSize >>= 2; - scrBase = scr; - i = winSize; - } - win = winBase + (scr - scrBase); - if (i > width) - i = width; - width -= i; - scr += i; - - while (i--) - { - GetBits(plane,0,s1); - GetBits(plane,1,s2); - GetBits(plane,2,s3); - GetBits(plane,3,s4); - *win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24); - sha += 4; - } - } - } - shaLine += shaStride; - y++; - } - pbox++; - } -} - -shadowUpdateProc shadowUpdatePlanar4Weak(void) { - return shadowUpdatePlanar4; -} - -shadowUpdateProc shadowUpdatePlanar4x8Weak(void) { - return shadowUpdatePlanar4x8; -} +/*
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+#include "fb.h"
+
+/*
+ * 32 4-bit pixels per write
+ */
+
+#define PL_SHIFT 7
+#define PL_UNIT (1 << PL_SHIFT)
+#define PL_MASK (PL_UNIT - 1)
+
+/*
+ * 32->8 conversion:
+ *
+ * 7 6 5 4 3 2 1 0
+ * A B C D E F G H
+ *
+ * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * m . . . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A
+ * m1 G . . . F . . . E . . . D . . . C . . . B . . . A . . . . . . . m << (7 - (p))
+ * m2 . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A . . (m >> (p)) << 2
+ * m3 G E C A m1 & 0x80808080
+ * m4 H F D B m2 & 0x40404040
+ * m5 G H E F C D A B m3 | m4
+ * m6 G H E F C D G H A B E F m5 | (m5 >> 20)
+ * m7 G H E F C D G H A B C D E F G H m6 | (m6 >> 10)
+ */
+
+#if 0
+#define GetBits(p,o,d) {\
+ m = sha[o]; \
+ m1 = m << (7 - (p)); \
+ m2 = (m >> (p)) << 2; \
+ m3 = m1 & 0x80808080; \
+ m4 = m2 & 0x40404040; \
+ m5 = m3 | m4; \
+ m6 = m5 | (m5 >> 20); \
+ d = m6 | (m6 >> 10); \
+}
+#else
+#define GetBits(p,o,d) {\
+ m = sha[o]; \
+ m5 = ((m << (7 - (p))) & 0x80808080) | (((m >> (p)) << 2) & 0x40404040); \
+ m6 = m5 | (m5 >> 20); \
+ d = m6 | (m6 >> 10); \
+}
+#endif
+
+void
+shadowUpdatePlanar4 (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = shadowDamage (pBuf);
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = RegionNumRects (damage);
+ BoxPtr pbox = RegionRects (damage);
+ CARD32 *shaBase, *shaLine, *sha;
+ FbStride shaStride;
+ int scrBase, scrLine, scr;
+ int shaBpp;
+ int shaXoff, shaYoff; /* XXX assumed to be zero */
+ int x, y, w, h, width;
+ int i;
+ CARD32 *winBase = NULL, *win;
+ CARD32 winSize;
+ int plane;
+ CARD32 m,m5,m6;
+ CARD8 s1, s2, s3, s4;
+
+ fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff);
+ while (nbox--)
+ {
+ x = (pbox->x1) * shaBpp;
+ y = (pbox->y1);
+ w = (pbox->x2 - pbox->x1) * shaBpp;
+ h = pbox->y2 - pbox->y1;
+
+ w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT;
+ x &= ~PL_MASK;
+
+ scrLine = (x >> PL_SHIFT);
+ shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
+
+ while (h--)
+ {
+ for (plane = 0; plane < 4; plane++)
+ {
+ width = w;
+ scr = scrLine;
+ sha = shaLine;
+ winSize = 0;
+ scrBase = 0;
+ while (width) {
+ /* how much remains in this window */
+ i = scrBase + winSize - scr;
+ if (i <= 0 || scr < scrBase)
+ {
+ winBase = (CARD32 *) (*pBuf->window) (pScreen,
+ y,
+ (scr << 4) | (plane),
+ SHADOW_WINDOW_WRITE,
+ &winSize,
+ pBuf->closure);
+ if(!winBase)
+ return;
+ winSize >>= 2;
+ scrBase = scr;
+ i = winSize;
+ }
+ win = winBase + (scr - scrBase);
+ if (i > width)
+ i = width;
+ width -= i;
+ scr += i;
+
+ while (i--)
+ {
+ GetBits(plane,0,s1);
+ GetBits(plane,1,s2);
+ GetBits(plane,2,s3);
+ GetBits(plane,3,s4);
+ *win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+ sha += 4;
+ }
+ }
+ }
+ shaLine += shaStride;
+ y++;
+ }
+ pbox++;
+ }
+}
+
+shadowUpdateProc shadowUpdatePlanar4Weak(void) {
+ return shadowUpdatePlanar4;
+}
+
+shadowUpdateProc shadowUpdatePlanar4x8Weak(void) {
+ return shadowUpdatePlanar4x8;
+}
diff --git a/xorg-server/miext/shadow/shplanar8.c b/xorg-server/miext/shadow/shplanar8.c index 6d8defa58..640da5e6f 100644 --- a/xorg-server/miext/shadow/shplanar8.c +++ b/xorg-server/miext/shadow/shplanar8.c @@ -1,175 +1,175 @@ -/* - * - * Copyright © 2000 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdlib.h> - -#include <X11/X.h> -#include "scrnintstr.h" -#include "windowstr.h" -#include <X11/fonts/font.h> -#include "dixfontstr.h" -#include <X11/fonts/fontstruct.h> -#include "mi.h" -#include "regionstr.h" -#include "globals.h" -#include "gcstruct.h" -#include "shadow.h" -#include "fb.h" - -/* - * Expose 8bpp depth 4 - */ - -/* - * 32->8 conversion: - * - * 7 6 5 4 3 2 1 0 - * A B C D E F G H - * - * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 - * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 - * m1 D x x x x x x x C x x x x x x x B x x x x x x x A x x x x x x x sha[0] << (7-(p)) - * m2 x x x x H x x x x x x x G x x x x x x x F x x x x x x x E x x x sha[1] << (3-(p)) - * m3 D C B A m1 & 0x80808080 - * m4 H G F E m2 & 0x08080808 - * m5 D H C G B F A E m3 | m4 - * m6 D H C G B F m5 >> 9 - * m7 D H C D G H B C F G A B E F m5 | m6 - * m8 D H C D G H m7 >> 18 - * m9 D H C D G H B C D F G H A B C D E F G H m7 | m8 - */ - -#define PL_SHIFT 8 -#define PL_UNIT (1 << PL_SHIFT) -#define PL_MASK (PL_UNIT - 1) - -#if 0 -#define GetBits(p,o,d) { \ - CARD32 m1,m2,m3,m4,m5,m6,m7,m8; \ - m1 = sha[o] << (7 - (p)); \ - m2 = sha[(o)+1] << (3 - (p)); \ - m3 = m1 & 0x80808080; \ - m4 = m2 & 0x08080808; \ - m5 = m3 | m4; \ - m6 = m5 >> 9; \ - m7 = m5 | m6; \ - m8 = m7 >> 18; \ - d = m7 | m8; \ -} -#else -#define GetBits(p,o,d) { \ - CARD32 m5,m7; \ - m5 = ((sha[o] << (7 - (p))) & 0x80808080) | ((sha[(o)+1] << (3 - (p))) & 0x08080808); \ - m7 = m5 | (m5 >> 9); \ - d = m7 | (m7 >> 18); \ -} -#endif - -void -shadowUpdatePlanar4x8 (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - RegionPtr damage = shadowDamage (pBuf); - PixmapPtr pShadow = pBuf->pPixmap; - int nbox = REGION_NUM_RECTS (damage); - BoxPtr pbox = REGION_RECTS (damage); - CARD32 *shaBase, *shaLine, *sha; - CARD8 s1, s2, s3, s4; - FbStride shaStride; - int scrBase, scrLine, scr; - int shaBpp; - int shaXoff, shaYoff; /* XXX assumed to be zero */ - int x, y, w, h, width; - int i; - CARD32 *winBase = NULL, *win; - CARD32 winSize; - int plane; - - fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); - while (nbox--) - { - x = pbox->x1 * shaBpp; - y = pbox->y1; - w = (pbox->x2 - pbox->x1) * shaBpp; - h = pbox->y2 - pbox->y1; - - w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT; - x &= ~PL_MASK; - - scrLine = (x >> PL_SHIFT); - shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); - - while (h--) - { - for (plane = 0; plane < 4; plane++) - { - width = w; - scr = scrLine; - sha = shaLine; - winSize = 0; - scrBase = 0; - while (width) { - /* how much remains in this window */ - i = scrBase + winSize - scr; - if (i <= 0 || scr < scrBase) - { - winBase = (CARD32 *) (*pBuf->window) (pScreen, - y, - (scr << 4) | (plane), - SHADOW_WINDOW_WRITE, - &winSize, - pBuf->closure); - if(!winBase) - return; - winSize >>= 2; - scrBase = scr; - i = winSize; - } - win = winBase + (scr - scrBase); - if (i > width) - i = width; - width -= i; - scr += i; - - while (i--) - { - GetBits(plane,0,s1); - GetBits(plane,2,s2); - GetBits(plane,4,s3); - GetBits(plane,6,s4); - *win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24); - sha += 8; - } - } - } - shaLine += shaStride; - y++; - } - pbox++; - } -} - +/*
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+#include "fb.h"
+
+/*
+ * Expose 8bpp depth 4
+ */
+
+/*
+ * 32->8 conversion:
+ *
+ * 7 6 5 4 3 2 1 0
+ * A B C D E F G H
+ *
+ * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * m1 D x x x x x x x C x x x x x x x B x x x x x x x A x x x x x x x sha[0] << (7-(p))
+ * m2 x x x x H x x x x x x x G x x x x x x x F x x x x x x x E x x x sha[1] << (3-(p))
+ * m3 D C B A m1 & 0x80808080
+ * m4 H G F E m2 & 0x08080808
+ * m5 D H C G B F A E m3 | m4
+ * m6 D H C G B F m5 >> 9
+ * m7 D H C D G H B C F G A B E F m5 | m6
+ * m8 D H C D G H m7 >> 18
+ * m9 D H C D G H B C D F G H A B C D E F G H m7 | m8
+ */
+
+#define PL_SHIFT 8
+#define PL_UNIT (1 << PL_SHIFT)
+#define PL_MASK (PL_UNIT - 1)
+
+#if 0
+#define GetBits(p,o,d) { \
+ CARD32 m1,m2,m3,m4,m5,m6,m7,m8; \
+ m1 = sha[o] << (7 - (p)); \
+ m2 = sha[(o)+1] << (3 - (p)); \
+ m3 = m1 & 0x80808080; \
+ m4 = m2 & 0x08080808; \
+ m5 = m3 | m4; \
+ m6 = m5 >> 9; \
+ m7 = m5 | m6; \
+ m8 = m7 >> 18; \
+ d = m7 | m8; \
+}
+#else
+#define GetBits(p,o,d) { \
+ CARD32 m5,m7; \
+ m5 = ((sha[o] << (7 - (p))) & 0x80808080) | ((sha[(o)+1] << (3 - (p))) & 0x08080808); \
+ m7 = m5 | (m5 >> 9); \
+ d = m7 | (m7 >> 18); \
+}
+#endif
+
+void
+shadowUpdatePlanar4x8 (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = shadowDamage (pBuf);
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = RegionNumRects (damage);
+ BoxPtr pbox = RegionRects (damage);
+ CARD32 *shaBase, *shaLine, *sha;
+ CARD8 s1, s2, s3, s4;
+ FbStride shaStride;
+ int scrBase, scrLine, scr;
+ int shaBpp;
+ int shaXoff, shaYoff; /* XXX assumed to be zero */
+ int x, y, w, h, width;
+ int i;
+ CARD32 *winBase = NULL, *win;
+ CARD32 winSize;
+ int plane;
+
+ fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff);
+ while (nbox--)
+ {
+ x = pbox->x1 * shaBpp;
+ y = pbox->y1;
+ w = (pbox->x2 - pbox->x1) * shaBpp;
+ h = pbox->y2 - pbox->y1;
+
+ w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT;
+ x &= ~PL_MASK;
+
+ scrLine = (x >> PL_SHIFT);
+ shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
+
+ while (h--)
+ {
+ for (plane = 0; plane < 4; plane++)
+ {
+ width = w;
+ scr = scrLine;
+ sha = shaLine;
+ winSize = 0;
+ scrBase = 0;
+ while (width) {
+ /* how much remains in this window */
+ i = scrBase + winSize - scr;
+ if (i <= 0 || scr < scrBase)
+ {
+ winBase = (CARD32 *) (*pBuf->window) (pScreen,
+ y,
+ (scr << 4) | (plane),
+ SHADOW_WINDOW_WRITE,
+ &winSize,
+ pBuf->closure);
+ if(!winBase)
+ return;
+ winSize >>= 2;
+ scrBase = scr;
+ i = winSize;
+ }
+ win = winBase + (scr - scrBase);
+ if (i > width)
+ i = width;
+ width -= i;
+ scr += i;
+
+ while (i--)
+ {
+ GetBits(plane,0,s1);
+ GetBits(plane,2,s2);
+ GetBits(plane,4,s3);
+ GetBits(plane,6,s4);
+ *win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+ sha += 8;
+ }
+ }
+ }
+ shaLine += shaStride;
+ y++;
+ }
+ pbox++;
+ }
+}
+
diff --git a/xorg-server/miext/shadow/shrotate.c b/xorg-server/miext/shadow/shrotate.c index 673cd76b5..13e9682ba 100644 --- a/xorg-server/miext/shadow/shrotate.c +++ b/xorg-server/miext/shadow/shrotate.c @@ -1,313 +1,313 @@ -/* - * - * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include "scrnintstr.h" -#include "windowstr.h" -#include <X11/fonts/font.h> -#include "dixfontstr.h" -#include <X11/fonts/fontstruct.h> -#include "mi.h" -#include "regionstr.h" -#include "globals.h" -#include "gcstruct.h" -#include "shadow.h" -#include "fb.h" - -/* - * These indicate which way the source (shadow) is scanned when - * walking the screen in a particular direction - */ - -#define LEFT_TO_RIGHT 1 -#define RIGHT_TO_LEFT -1 -#define TOP_TO_BOTTOM 2 -#define BOTTOM_TO_TOP -2 - -void -shadowUpdateRotatePacked (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - RegionPtr damage = shadowDamage (pBuf); - PixmapPtr pShadow = pBuf->pPixmap; - int nbox = REGION_NUM_RECTS (damage); - BoxPtr pbox = REGION_RECTS (damage); - FbBits *shaBits; - FbStride shaStride; - int shaBpp; - int shaXoff, shaYoff; - int box_x1, box_x2, box_y1, box_y2; - int sha_x1 = 0, sha_y1 = 0; - int scr_x1 = 0, scr_x2 = 0, scr_y1 = 0, scr_y2 = 0, scr_w, scr_h; - int scr_x, scr_y; - int w; - int pixelsPerBits; - int pixelsMask; - FbStride shaStepOverY = 0, shaStepDownY = 0; - FbStride shaStepOverX = 0, shaStepDownX = 0; - FbBits *shaLine, *sha; - int shaHeight = pShadow->drawable.height; - int shaWidth = pShadow->drawable.width; - FbBits shaMask; - int shaFirstShift, shaShift; - int o_x_dir; - int o_y_dir; - int x_dir; - int y_dir; - - fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff); - pixelsPerBits = (sizeof (FbBits) * 8) / shaBpp; - pixelsMask = ~(pixelsPerBits - 1); - shaMask = FbBitsMask (FB_UNIT-shaBpp, shaBpp); - /* - * Compute rotation related constants to walk the shadow - */ - o_x_dir = LEFT_TO_RIGHT; - o_y_dir = TOP_TO_BOTTOM; - if (pBuf->randr & SHADOW_REFLECT_X) - o_x_dir = -o_x_dir; - if (pBuf->randr & SHADOW_REFLECT_Y) - o_y_dir = -o_y_dir; - switch (pBuf->randr & (SHADOW_ROTATE_ALL)) { - case SHADOW_ROTATE_0: /* upper left shadow -> upper left screen */ - default: - x_dir = o_x_dir; - y_dir = o_y_dir; - break; - case SHADOW_ROTATE_90: /* upper right shadow -> upper left screen */ - x_dir = o_y_dir; - y_dir = -o_x_dir; - break; - case SHADOW_ROTATE_180: /* lower right shadow -> upper left screen */ - x_dir = -o_x_dir; - y_dir = -o_y_dir; - break; - case SHADOW_ROTATE_270: /* lower left shadow -> upper left screen */ - x_dir = -o_y_dir; - y_dir = o_x_dir; - break; - } - switch (x_dir) { - case LEFT_TO_RIGHT: - shaStepOverX = shaBpp; - shaStepOverY = 0; - break; - case TOP_TO_BOTTOM: - shaStepOverX = 0; - shaStepOverY = shaStride; - break; - case RIGHT_TO_LEFT: - shaStepOverX = -shaBpp; - shaStepOverY = 0; - break; - case BOTTOM_TO_TOP: - shaStepOverX = 0; - shaStepOverY = -shaStride; - break; - } - switch (y_dir) { - case TOP_TO_BOTTOM: - shaStepDownX = 0; - shaStepDownY = shaStride; - break; - case RIGHT_TO_LEFT: - shaStepDownX = -shaBpp; - shaStepDownY = 0; - break; - case BOTTOM_TO_TOP: - shaStepDownX = 0; - shaStepDownY = -shaStride; - break; - case LEFT_TO_RIGHT: - shaStepDownX = shaBpp; - shaStepDownY = 0; - break; - } - - while (nbox--) - { - box_x1 = pbox->x1; - box_y1 = pbox->y1; - box_x2 = pbox->x2; - box_y2 = pbox->y2; - pbox++; - - /* - * Compute screen and shadow locations for this box - */ - switch (x_dir) { - case LEFT_TO_RIGHT: - scr_x1 = box_x1 & pixelsMask; - scr_x2 = (box_x2 + pixelsPerBits - 1) & pixelsMask; - - sha_x1 = scr_x1; - break; - case TOP_TO_BOTTOM: - scr_x1 = box_y1 & pixelsMask; - scr_x2 = (box_y2 + pixelsPerBits - 1) & pixelsMask; - - sha_y1 = scr_x1; - break; - case RIGHT_TO_LEFT: - scr_x1 = (shaWidth - box_x2) & pixelsMask; - scr_x2 = (shaWidth - box_x1 + pixelsPerBits - 1) & pixelsMask; - - sha_x1 = (shaWidth - scr_x1 - 1); - break; - case BOTTOM_TO_TOP: - scr_x1 = (shaHeight - box_y2) & pixelsMask; - scr_x2 = (shaHeight - box_y1 + pixelsPerBits - 1) & pixelsMask; - - sha_y1 = (shaHeight - scr_x1 - 1); - break; - } - switch (y_dir) { - case TOP_TO_BOTTOM: - scr_y1 = box_y1; - scr_y2 = box_y2; - - sha_y1 = scr_y1; - break; - case RIGHT_TO_LEFT: - scr_y1 = (shaWidth - box_x2); - scr_y2 = (shaWidth - box_x1); - - sha_x1 = box_x2 - 1; - break; - case BOTTOM_TO_TOP: - scr_y1 = shaHeight - box_y2; - scr_y2 = shaHeight - box_y1; - - sha_y1 = box_y2 - 1; - break; - case LEFT_TO_RIGHT: - scr_y1 = box_x1; - scr_y2 = box_x2; - - sha_x1 = box_x1; - break; - } - scr_w = ((scr_x2 - scr_x1) * shaBpp) >> FB_SHIFT; - scr_h = scr_y2 - scr_y1; - scr_y = scr_y1; - - /* shift amount for first pixel on screen */ - shaFirstShift = FB_UNIT - ((sha_x1 * shaBpp) & FB_MASK) - shaBpp; - - /* pointer to shadow data first placed on screen */ - shaLine = (shaBits + - sha_y1 * shaStride + - ((sha_x1 * shaBpp) >> FB_SHIFT)); - - /* - * Copy the bits, always write across the physical frame buffer - * to take advantage of write combining. - */ - while (scr_h--) - { - int p; - FbBits bits; - FbBits *win; - int i; - CARD32 winSize; - - sha = shaLine; - shaShift = shaFirstShift; - w = scr_w; - scr_x = scr_x1 * shaBpp >> FB_SHIFT; - - while (w) - { - /* - * Map some of this line - */ - win = (FbBits *) (*pBuf->window) (pScreen, - scr_y, - scr_x << 2, - SHADOW_WINDOW_WRITE, - &winSize, - pBuf->closure); - i = (winSize >> 2); - if (i > w) - i = w; - w -= i; - scr_x += i; - /* - * Copy the portion of the line mapped - */ - while (i--) - { - bits = 0; - p = pixelsPerBits; - /* - * Build one word of output from multiple inputs - * - * Note that for 90/270 rotations, this will walk - * down the shadow hitting each scanline once. - * This is probably not very efficient. - */ - while (p--) - { - bits = FbScrLeft(bits, shaBpp); - bits |= FbScrRight (*sha, shaShift) & shaMask; - - shaShift -= shaStepOverX; - if (shaShift >= FB_UNIT) - { - shaShift -= FB_UNIT; - sha--; - } - else if (shaShift < 0) - { - shaShift += FB_UNIT; - sha++; - } - sha += shaStepOverY; - } - *win++ = bits; - } - } - scr_y++; - shaFirstShift -= shaStepDownX; - if (shaFirstShift >= FB_UNIT) - { - shaFirstShift -= FB_UNIT; - shaLine--; - } - else if (shaFirstShift < 0) - { - shaFirstShift += FB_UNIT; - shaLine++; - } - shaLine += shaStepDownY; - } - } -} - -shadowUpdateProc shadowUpdateRotatePackedWeak(void) { - return shadowUpdateRotatePacked; -} +/*
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+#include "fb.h"
+
+/*
+ * These indicate which way the source (shadow) is scanned when
+ * walking the screen in a particular direction
+ */
+
+#define LEFT_TO_RIGHT 1
+#define RIGHT_TO_LEFT -1
+#define TOP_TO_BOTTOM 2
+#define BOTTOM_TO_TOP -2
+
+void
+shadowUpdateRotatePacked (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = shadowDamage (pBuf);
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = RegionNumRects (damage);
+ BoxPtr pbox = RegionRects (damage);
+ FbBits *shaBits;
+ FbStride shaStride;
+ int shaBpp;
+ int shaXoff, shaYoff;
+ int box_x1, box_x2, box_y1, box_y2;
+ int sha_x1 = 0, sha_y1 = 0;
+ int scr_x1 = 0, scr_x2 = 0, scr_y1 = 0, scr_y2 = 0, scr_w, scr_h;
+ int scr_x, scr_y;
+ int w;
+ int pixelsPerBits;
+ int pixelsMask;
+ FbStride shaStepOverY = 0, shaStepDownY = 0;
+ FbStride shaStepOverX = 0, shaStepDownX = 0;
+ FbBits *shaLine, *sha;
+ int shaHeight = pShadow->drawable.height;
+ int shaWidth = pShadow->drawable.width;
+ FbBits shaMask;
+ int shaFirstShift, shaShift;
+ int o_x_dir;
+ int o_y_dir;
+ int x_dir;
+ int y_dir;
+
+ fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff);
+ pixelsPerBits = (sizeof (FbBits) * 8) / shaBpp;
+ pixelsMask = ~(pixelsPerBits - 1);
+ shaMask = FbBitsMask (FB_UNIT-shaBpp, shaBpp);
+ /*
+ * Compute rotation related constants to walk the shadow
+ */
+ o_x_dir = LEFT_TO_RIGHT;
+ o_y_dir = TOP_TO_BOTTOM;
+ if (pBuf->randr & SHADOW_REFLECT_X)
+ o_x_dir = -o_x_dir;
+ if (pBuf->randr & SHADOW_REFLECT_Y)
+ o_y_dir = -o_y_dir;
+ switch (pBuf->randr & (SHADOW_ROTATE_ALL)) {
+ case SHADOW_ROTATE_0: /* upper left shadow -> upper left screen */
+ default:
+ x_dir = o_x_dir;
+ y_dir = o_y_dir;
+ break;
+ case SHADOW_ROTATE_90: /* upper right shadow -> upper left screen */
+ x_dir = o_y_dir;
+ y_dir = -o_x_dir;
+ break;
+ case SHADOW_ROTATE_180: /* lower right shadow -> upper left screen */
+ x_dir = -o_x_dir;
+ y_dir = -o_y_dir;
+ break;
+ case SHADOW_ROTATE_270: /* lower left shadow -> upper left screen */
+ x_dir = -o_y_dir;
+ y_dir = o_x_dir;
+ break;
+ }
+ switch (x_dir) {
+ case LEFT_TO_RIGHT:
+ shaStepOverX = shaBpp;
+ shaStepOverY = 0;
+ break;
+ case TOP_TO_BOTTOM:
+ shaStepOverX = 0;
+ shaStepOverY = shaStride;
+ break;
+ case RIGHT_TO_LEFT:
+ shaStepOverX = -shaBpp;
+ shaStepOverY = 0;
+ break;
+ case BOTTOM_TO_TOP:
+ shaStepOverX = 0;
+ shaStepOverY = -shaStride;
+ break;
+ }
+ switch (y_dir) {
+ case TOP_TO_BOTTOM:
+ shaStepDownX = 0;
+ shaStepDownY = shaStride;
+ break;
+ case RIGHT_TO_LEFT:
+ shaStepDownX = -shaBpp;
+ shaStepDownY = 0;
+ break;
+ case BOTTOM_TO_TOP:
+ shaStepDownX = 0;
+ shaStepDownY = -shaStride;
+ break;
+ case LEFT_TO_RIGHT:
+ shaStepDownX = shaBpp;
+ shaStepDownY = 0;
+ break;
+ }
+
+ while (nbox--)
+ {
+ box_x1 = pbox->x1;
+ box_y1 = pbox->y1;
+ box_x2 = pbox->x2;
+ box_y2 = pbox->y2;
+ pbox++;
+
+ /*
+ * Compute screen and shadow locations for this box
+ */
+ switch (x_dir) {
+ case LEFT_TO_RIGHT:
+ scr_x1 = box_x1 & pixelsMask;
+ scr_x2 = (box_x2 + pixelsPerBits - 1) & pixelsMask;
+
+ sha_x1 = scr_x1;
+ break;
+ case TOP_TO_BOTTOM:
+ scr_x1 = box_y1 & pixelsMask;
+ scr_x2 = (box_y2 + pixelsPerBits - 1) & pixelsMask;
+
+ sha_y1 = scr_x1;
+ break;
+ case RIGHT_TO_LEFT:
+ scr_x1 = (shaWidth - box_x2) & pixelsMask;
+ scr_x2 = (shaWidth - box_x1 + pixelsPerBits - 1) & pixelsMask;
+
+ sha_x1 = (shaWidth - scr_x1 - 1);
+ break;
+ case BOTTOM_TO_TOP:
+ scr_x1 = (shaHeight - box_y2) & pixelsMask;
+ scr_x2 = (shaHeight - box_y1 + pixelsPerBits - 1) & pixelsMask;
+
+ sha_y1 = (shaHeight - scr_x1 - 1);
+ break;
+ }
+ switch (y_dir) {
+ case TOP_TO_BOTTOM:
+ scr_y1 = box_y1;
+ scr_y2 = box_y2;
+
+ sha_y1 = scr_y1;
+ break;
+ case RIGHT_TO_LEFT:
+ scr_y1 = (shaWidth - box_x2);
+ scr_y2 = (shaWidth - box_x1);
+
+ sha_x1 = box_x2 - 1;
+ break;
+ case BOTTOM_TO_TOP:
+ scr_y1 = shaHeight - box_y2;
+ scr_y2 = shaHeight - box_y1;
+
+ sha_y1 = box_y2 - 1;
+ break;
+ case LEFT_TO_RIGHT:
+ scr_y1 = box_x1;
+ scr_y2 = box_x2;
+
+ sha_x1 = box_x1;
+ break;
+ }
+ scr_w = ((scr_x2 - scr_x1) * shaBpp) >> FB_SHIFT;
+ scr_h = scr_y2 - scr_y1;
+ scr_y = scr_y1;
+
+ /* shift amount for first pixel on screen */
+ shaFirstShift = FB_UNIT - ((sha_x1 * shaBpp) & FB_MASK) - shaBpp;
+
+ /* pointer to shadow data first placed on screen */
+ shaLine = (shaBits +
+ sha_y1 * shaStride +
+ ((sha_x1 * shaBpp) >> FB_SHIFT));
+
+ /*
+ * Copy the bits, always write across the physical frame buffer
+ * to take advantage of write combining.
+ */
+ while (scr_h--)
+ {
+ int p;
+ FbBits bits;
+ FbBits *win;
+ int i;
+ CARD32 winSize;
+
+ sha = shaLine;
+ shaShift = shaFirstShift;
+ w = scr_w;
+ scr_x = scr_x1 * shaBpp >> FB_SHIFT;
+
+ while (w)
+ {
+ /*
+ * Map some of this line
+ */
+ win = (FbBits *) (*pBuf->window) (pScreen,
+ scr_y,
+ scr_x << 2,
+ SHADOW_WINDOW_WRITE,
+ &winSize,
+ pBuf->closure);
+ i = (winSize >> 2);
+ if (i > w)
+ i = w;
+ w -= i;
+ scr_x += i;
+ /*
+ * Copy the portion of the line mapped
+ */
+ while (i--)
+ {
+ bits = 0;
+ p = pixelsPerBits;
+ /*
+ * Build one word of output from multiple inputs
+ *
+ * Note that for 90/270 rotations, this will walk
+ * down the shadow hitting each scanline once.
+ * This is probably not very efficient.
+ */
+ while (p--)
+ {
+ bits = FbScrLeft(bits, shaBpp);
+ bits |= FbScrRight (*sha, shaShift) & shaMask;
+
+ shaShift -= shaStepOverX;
+ if (shaShift >= FB_UNIT)
+ {
+ shaShift -= FB_UNIT;
+ sha--;
+ }
+ else if (shaShift < 0)
+ {
+ shaShift += FB_UNIT;
+ sha++;
+ }
+ sha += shaStepOverY;
+ }
+ *win++ = bits;
+ }
+ }
+ scr_y++;
+ shaFirstShift -= shaStepDownX;
+ if (shaFirstShift >= FB_UNIT)
+ {
+ shaFirstShift -= FB_UNIT;
+ shaLine--;
+ }
+ else if (shaFirstShift < 0)
+ {
+ shaFirstShift += FB_UNIT;
+ shaLine++;
+ }
+ shaLine += shaStepDownY;
+ }
+ }
+}
+
+shadowUpdateProc shadowUpdateRotatePackedWeak(void) {
+ return shadowUpdateRotatePacked;
+}
diff --git a/xorg-server/miext/shadow/shrotpack.h b/xorg-server/miext/shadow/shrotpack.h index 015a98595..1a8af6200 100644 --- a/xorg-server/miext/shadow/shrotpack.h +++ b/xorg-server/miext/shadow/shrotpack.h @@ -1,187 +1,187 @@ -/* - * - * Copyright © 2000 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * Thanks to Daniel Chemko <dchemko@intrinsyc.com> for making the 90 and 180 - * orientations work. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdlib.h> - -#include <X11/X.h> -#include "scrnintstr.h" -#include "windowstr.h" -#include <X11/fonts/font.h> -#include "dixfontstr.h" -#include <X11/fonts/fontstruct.h> -#include "mi.h" -#include "regionstr.h" -#include "globals.h" -#include "gcstruct.h" -#include "shadow.h" -#include "fb.h" - -#define DANDEBUG 0 - -#if ROTATE == 270 - -#define SCRLEFT(x,y,w,h) (pScreen->height - ((y) + (h))) -#define SCRY(x,y,w,h) (x) -#define SCRWIDTH(x,y,w,h) (h) -#define FIRSTSHA(x,y,w,h) (((y) + (h) - 1) * shaStride + (x)) -#define STEPDOWN(x,y,w,h) ((w)--) -#define NEXTY(x,y,w,h) ((x)++) -#define SHASTEPX(stride) -(stride) -#define SHASTEPY(stride) (1) - -#elif ROTATE == 90 - -#define SCRLEFT(x,y,w,h) (y) -#define SCRY(x,y,w,h) (pScreen->width - ((x) + (w)) - 1) -#define SCRWIDTH(x,y,w,h) (h) -#define FIRSTSHA(x,y,w,h) ((y) * shaStride + (x + w - 1)) -#define STEPDOWN(x,y,w,h) ((w)--) -#define NEXTY(x,y,w,h) ((void)(x)) -#define SHASTEPX(stride) (stride) -#define SHASTEPY(stride) (-1) - -#elif ROTATE == 180 - -#define SCRLEFT(x,y,w,h) (pScreen->width - ((x) + (w))) -#define SCRY(x,y,w,h) (pScreen->height - ((y) + (h)) - 1) -#define SCRWIDTH(x,y,w,h) (w) -#define FIRSTSHA(x,y,w,h) ((y + h - 1) * shaStride + (x + w - 1)) -#define STEPDOWN(x,y,w,h) ((h)--) -#define NEXTY(x,y,w,h) ((void)(y)) -#define SHASTEPX(stride) (-1) -#define SHASTEPY(stride) -(stride) - -#else - -#define SCRLEFT(x,y,w,h) (x) -#define SCRY(x,y,w,h) (y) -#define SCRWIDTH(x,y,w,h) (w) -#define FIRSTSHA(x,y,w,h) ((y) * shaStride + (x)) -#define STEPDOWN(x,y,w,h) ((h)--) -#define NEXTY(x,y,w,h) ((y)++) -#define SHASTEPX(stride) (1) -#define SHASTEPY(stride) (stride) - -#endif - -void -FUNC (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - RegionPtr damage = shadowDamage (pBuf); - PixmapPtr pShadow = pBuf->pPixmap; - int nbox = REGION_NUM_RECTS (damage); - BoxPtr pbox = REGION_RECTS (damage); - FbBits *shaBits; - Data *shaBase, *shaLine, *sha; - FbStride shaStride; - int scrBase, scrLine, scr; - int shaBpp; - int shaXoff, shaYoff; /* XXX assumed to be zero */ - int x, y, w, h, width; - int i; - Data *winBase = NULL, *win; - CARD32 winSize; - - fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff); - shaBase = (Data *) shaBits; - shaStride = shaStride * sizeof (FbBits) / sizeof (Data); -#if (DANDEBUG > 1) - ErrorF ("-> Entering Shadow Update:\r\n |- Origins: pShadow=%x, pScreen=%x, damage=%x\r\n |- Metrics: shaStride=%d, shaBase=%x, shaBpp=%d\r\n | \n", pShadow, pScreen, damage, shaStride, shaBase, shaBpp); -#endif - while (nbox--) - { - x = pbox->x1; - y = pbox->y1; - w = (pbox->x2 - pbox->x1); - h = pbox->y2 - pbox->y1; - -#if (DANDEBUG > 2) - ErrorF (" |-> Redrawing box - Metrics: X=%d, Y=%d, Width=%d, Height=%d\n", x, y, w, h); -#endif - scrLine = SCRLEFT(x,y,w,h); - shaLine = shaBase + FIRSTSHA(x,y,w,h); - - while (STEPDOWN(x,y,w,h)) - { - winSize = 0; - scrBase = 0; - width = SCRWIDTH(x,y,w,h); - scr = scrLine; - sha = shaLine; -#if (DANDEBUG > 3) - ErrorF (" | |-> StepDown - Metrics: width=%d, scr=%x, sha=%x\n", width, scr, sha); -#endif - while (width) - { - /* how much remains in this window */ - i = scrBase + winSize - scr; - if (i <= 0 || scr < scrBase) - { - winBase = (Data *) (*pBuf->window) (pScreen, - SCRY(x,y,w,h), - scr * sizeof (Data), - SHADOW_WINDOW_WRITE, - &winSize, - pBuf->closure); - if(!winBase) - return; - scrBase = scr; - winSize /= sizeof (Data); - i = winSize; -#if(DANDEBUG > 4) - ErrorF (" | | |-> Starting New Line - Metrics: winBase=%x, scrBase=%x, winSize=%d\r\n | | | Xstride=%d, Ystride=%d, w=%d h=%d\n", winBase, scrBase, winSize, SHASTEPX(shaStride), SHASTEPY(shaStride), w, h); -#endif - } - win = winBase + (scr - scrBase); - if (i > width) - i = width; - width -= i; - scr += i; -#if(DANDEBUG > 5) - ErrorF (" | | |-> Writing Line - Metrics: win=%x, sha=%x\n", win, sha); -#endif - while (i--) - { -#if(DANDEBUG > 6) - ErrorF (" | | |-> Writing Pixel - Metrics: win=%x, sha=%d, remaining=%d\n", win, sha, i); -#endif - *win++ = *sha; - sha += SHASTEPX(shaStride); - } /* i */ - } /* width */ - shaLine += SHASTEPY(shaStride); - NEXTY(x,y,w,h); - } /* STEPDOWN */ - pbox++; - } /* nbox */ -} +/*
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Thanks to Daniel Chemko <dchemko@intrinsyc.com> for making the 90 and 180
+ * orientations work.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+#include "fb.h"
+
+#define DANDEBUG 0
+
+#if ROTATE == 270
+
+#define SCRLEFT(x,y,w,h) (pScreen->height - ((y) + (h)))
+#define SCRY(x,y,w,h) (x)
+#define SCRWIDTH(x,y,w,h) (h)
+#define FIRSTSHA(x,y,w,h) (((y) + (h) - 1) * shaStride + (x))
+#define STEPDOWN(x,y,w,h) ((w)--)
+#define NEXTY(x,y,w,h) ((x)++)
+#define SHASTEPX(stride) -(stride)
+#define SHASTEPY(stride) (1)
+
+#elif ROTATE == 90
+
+#define SCRLEFT(x,y,w,h) (y)
+#define SCRY(x,y,w,h) (pScreen->width - ((x) + (w)) - 1)
+#define SCRWIDTH(x,y,w,h) (h)
+#define FIRSTSHA(x,y,w,h) ((y) * shaStride + (x + w - 1))
+#define STEPDOWN(x,y,w,h) ((w)--)
+#define NEXTY(x,y,w,h) ((void)(x))
+#define SHASTEPX(stride) (stride)
+#define SHASTEPY(stride) (-1)
+
+#elif ROTATE == 180
+
+#define SCRLEFT(x,y,w,h) (pScreen->width - ((x) + (w)))
+#define SCRY(x,y,w,h) (pScreen->height - ((y) + (h)) - 1)
+#define SCRWIDTH(x,y,w,h) (w)
+#define FIRSTSHA(x,y,w,h) ((y + h - 1) * shaStride + (x + w - 1))
+#define STEPDOWN(x,y,w,h) ((h)--)
+#define NEXTY(x,y,w,h) ((void)(y))
+#define SHASTEPX(stride) (-1)
+#define SHASTEPY(stride) -(stride)
+
+#else
+
+#define SCRLEFT(x,y,w,h) (x)
+#define SCRY(x,y,w,h) (y)
+#define SCRWIDTH(x,y,w,h) (w)
+#define FIRSTSHA(x,y,w,h) ((y) * shaStride + (x))
+#define STEPDOWN(x,y,w,h) ((h)--)
+#define NEXTY(x,y,w,h) ((y)++)
+#define SHASTEPX(stride) (1)
+#define SHASTEPY(stride) (stride)
+
+#endif
+
+void
+FUNC (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = shadowDamage (pBuf);
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = RegionNumRects (damage);
+ BoxPtr pbox = RegionRects (damage);
+ FbBits *shaBits;
+ Data *shaBase, *shaLine, *sha;
+ FbStride shaStride;
+ int scrBase, scrLine, scr;
+ int shaBpp;
+ int shaXoff, shaYoff; /* XXX assumed to be zero */
+ int x, y, w, h, width;
+ int i;
+ Data *winBase = NULL, *win;
+ CARD32 winSize;
+
+ fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff);
+ shaBase = (Data *) shaBits;
+ shaStride = shaStride * sizeof (FbBits) / sizeof (Data);
+#if (DANDEBUG > 1)
+ ErrorF ("-> Entering Shadow Update:\r\n |- Origins: pShadow=%x, pScreen=%x, damage=%x\r\n |- Metrics: shaStride=%d, shaBase=%x, shaBpp=%d\r\n | \n", pShadow, pScreen, damage, shaStride, shaBase, shaBpp);
+#endif
+ while (nbox--)
+ {
+ x = pbox->x1;
+ y = pbox->y1;
+ w = (pbox->x2 - pbox->x1);
+ h = pbox->y2 - pbox->y1;
+
+#if (DANDEBUG > 2)
+ ErrorF (" |-> Redrawing box - Metrics: X=%d, Y=%d, Width=%d, Height=%d\n", x, y, w, h);
+#endif
+ scrLine = SCRLEFT(x,y,w,h);
+ shaLine = shaBase + FIRSTSHA(x,y,w,h);
+
+ while (STEPDOWN(x,y,w,h))
+ {
+ winSize = 0;
+ scrBase = 0;
+ width = SCRWIDTH(x,y,w,h);
+ scr = scrLine;
+ sha = shaLine;
+#if (DANDEBUG > 3)
+ ErrorF (" | |-> StepDown - Metrics: width=%d, scr=%x, sha=%x\n", width, scr, sha);
+#endif
+ while (width)
+ {
+ /* how much remains in this window */
+ i = scrBase + winSize - scr;
+ if (i <= 0 || scr < scrBase)
+ {
+ winBase = (Data *) (*pBuf->window) (pScreen,
+ SCRY(x,y,w,h),
+ scr * sizeof (Data),
+ SHADOW_WINDOW_WRITE,
+ &winSize,
+ pBuf->closure);
+ if(!winBase)
+ return;
+ scrBase = scr;
+ winSize /= sizeof (Data);
+ i = winSize;
+#if(DANDEBUG > 4)
+ ErrorF (" | | |-> Starting New Line - Metrics: winBase=%x, scrBase=%x, winSize=%d\r\n | | | Xstride=%d, Ystride=%d, w=%d h=%d\n", winBase, scrBase, winSize, SHASTEPX(shaStride), SHASTEPY(shaStride), w, h);
+#endif
+ }
+ win = winBase + (scr - scrBase);
+ if (i > width)
+ i = width;
+ width -= i;
+ scr += i;
+#if(DANDEBUG > 5)
+ ErrorF (" | | |-> Writing Line - Metrics: win=%x, sha=%x\n", win, sha);
+#endif
+ while (i--)
+ {
+#if(DANDEBUG > 6)
+ ErrorF (" | | |-> Writing Pixel - Metrics: win=%x, sha=%d, remaining=%d\n", win, sha, i);
+#endif
+ *win++ = *sha;
+ sha += SHASTEPX(shaStride);
+ } /* i */
+ } /* width */
+ shaLine += SHASTEPY(shaStride);
+ NEXTY(x,y,w,h);
+ } /* STEPDOWN */
+ pbox++;
+ } /* nbox */
+}
diff --git a/xorg-server/miext/shadow/shrotpackYX.h b/xorg-server/miext/shadow/shrotpackYX.h index 8ef70f167..7005b1457 100644 --- a/xorg-server/miext/shadow/shrotpackYX.h +++ b/xorg-server/miext/shadow/shrotpackYX.h @@ -1,160 +1,160 @@ -/* - * Copyright © 2004 Philip Blundell - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Philip Blundell not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Philip Blundell makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * PHILIP BLUNDELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL PHILIP BLUNDELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include <X11/X.h> -#include "scrnintstr.h" -#include "windowstr.h" -#include "dixfontstr.h" -#include "mi.h" -#include "regionstr.h" -#include "globals.h" -#include "gcstruct.h" -#include "shadow.h" -#include "fb.h" - -#if ROTATE == 270 - -#define WINSTEPX(stride) (stride) -#define WINSTART(x,y) (((pScreen->height - 1) - y) + (x * winStride)) -#define WINSTEPY() -1 - -#elif ROTATE == 90 - -#define WINSTEPX(stride) (-stride) -#define WINSTEPY() 1 -#define WINSTART(x,y) (((pScreen->width - 1 - x) * winStride) + y) - -#else - -#error This rotation is not supported here - -#endif - -#ifdef __arm__ -#define PREFETCH -#endif - -void -FUNC (ScreenPtr pScreen, - shadowBufPtr pBuf); - -void -FUNC (ScreenPtr pScreen, - shadowBufPtr pBuf) -{ - RegionPtr damage = shadowDamage(pBuf); - PixmapPtr pShadow = pBuf->pPixmap; - int nbox = REGION_NUM_RECTS (damage); - BoxPtr pbox = REGION_RECTS (damage); - FbBits *shaBits; - Data *shaBase, *shaLine, *sha; - FbStride shaStride, winStride; - int shaBpp; - int shaXoff, shaYoff; /* XXX assumed to be zero */ - int x, y, w, h; - Data *winBase, *win, *winLine; - CARD32 winSize; - - fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff); - shaBase = (Data *) shaBits; - shaStride = shaStride * sizeof (FbBits) / sizeof (Data); - - winBase = (Data *) (*pBuf->window) (pScreen, 0, 0, - SHADOW_WINDOW_WRITE, - &winSize, pBuf->closure); - winStride = (Data *) (*pBuf->window) (pScreen, 1, 0, - SHADOW_WINDOW_WRITE, - &winSize, pBuf->closure) - winBase; - - while (nbox--) - { - x = pbox->x1; - y = pbox->y1; - w = (pbox->x2 - pbox->x1); - h = pbox->y2 - pbox->y1; - - shaLine = shaBase + (y * shaStride) + x; -#ifdef PREFETCH - __builtin_prefetch (shaLine); -#endif - winLine = winBase + WINSTART(x, y); - - while (h--) - { - sha = shaLine; - win = winLine; - - while (sha < (shaLine + w - 16)) - { -#ifdef PREFETCH - __builtin_prefetch (sha + shaStride); -#endif - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - *win = *sha++; - win += WINSTEPX(winStride); - } - - while (sha < (shaLine + w)) - { - *win = *sha++; - win += WINSTEPX(winStride); - } - - y++; - shaLine += shaStride; - winLine += WINSTEPY(); - } - pbox++; - } /* nbox */ -} +/*
+ * Copyright © 2004 Philip Blundell
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Philip Blundell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Philip Blundell makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * PHILIP BLUNDELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL PHILIP BLUNDELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "dixfontstr.h"
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+#include "fb.h"
+
+#if ROTATE == 270
+
+#define WINSTEPX(stride) (stride)
+#define WINSTART(x,y) (((pScreen->height - 1) - y) + (x * winStride))
+#define WINSTEPY() -1
+
+#elif ROTATE == 90
+
+#define WINSTEPX(stride) (-stride)
+#define WINSTEPY() 1
+#define WINSTART(x,y) (((pScreen->width - 1 - x) * winStride) + y)
+
+#else
+
+#error This rotation is not supported here
+
+#endif
+
+#ifdef __arm__
+#define PREFETCH
+#endif
+
+void
+FUNC (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+FUNC (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = shadowDamage(pBuf);
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = RegionNumRects (damage);
+ BoxPtr pbox = RegionRects (damage);
+ FbBits *shaBits;
+ Data *shaBase, *shaLine, *sha;
+ FbStride shaStride, winStride;
+ int shaBpp;
+ int shaXoff, shaYoff; /* XXX assumed to be zero */
+ int x, y, w, h;
+ Data *winBase, *win, *winLine;
+ CARD32 winSize;
+
+ fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff);
+ shaBase = (Data *) shaBits;
+ shaStride = shaStride * sizeof (FbBits) / sizeof (Data);
+
+ winBase = (Data *) (*pBuf->window) (pScreen, 0, 0,
+ SHADOW_WINDOW_WRITE,
+ &winSize, pBuf->closure);
+ winStride = (Data *) (*pBuf->window) (pScreen, 1, 0,
+ SHADOW_WINDOW_WRITE,
+ &winSize, pBuf->closure) - winBase;
+
+ while (nbox--)
+ {
+ x = pbox->x1;
+ y = pbox->y1;
+ w = (pbox->x2 - pbox->x1);
+ h = pbox->y2 - pbox->y1;
+
+ shaLine = shaBase + (y * shaStride) + x;
+#ifdef PREFETCH
+ __builtin_prefetch (shaLine);
+#endif
+ winLine = winBase + WINSTART(x, y);
+
+ while (h--)
+ {
+ sha = shaLine;
+ win = winLine;
+
+ while (sha < (shaLine + w - 16))
+ {
+#ifdef PREFETCH
+ __builtin_prefetch (sha + shaStride);
+#endif
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ }
+
+ while (sha < (shaLine + w))
+ {
+ *win = *sha++;
+ win += WINSTEPX(winStride);
+ }
+
+ y++;
+ shaLine += shaStride;
+ winLine += WINSTEPY();
+ }
+ pbox++;
+ } /* nbox */
+}
diff --git a/xorg-server/os/access.c b/xorg-server/os/access.c index 2a0ea01cd..862d98a96 100644 --- a/xorg-server/os/access.c +++ b/xorg-server/os/access.c @@ -311,7 +311,7 @@ ifioctl (int fd, int cmd, char *arg) struct strioctl ioc;
int ret;
- bzero((char *) &ioc, sizeof(ioc));
+ memset((char *) &ioc, 0, sizeof(ioc));
ioc.ic_cmd = cmd;
ioc.ic_timout = 0;
if (cmd == SIOCGIFCONF)
@@ -329,7 +329,7 @@ ifioctl (int fd, int cmd, char *arg) #ifdef SVR4
((struct ifconf *) arg)->ifc_len = ioc.ic_len;
#endif
- return(ret);
+ return ret;
}
#else /* Case sun, SCO325 and others */
#define ifioctl ioctl
@@ -1038,7 +1038,7 @@ ResetHosts (char *display) len = sizeof(saddr.sa);
if (ConvertAddr (&saddr.sa, &len, (pointer *)&addr) == FamilyDECnet)
{
- bzero ((char *) &dnaddr, sizeof (dnaddr));
+ memset((char *) &dnaddr, 0, sizeof (dnaddr));
dnaddr.a_len = np->n_length;
acopy (np->n_addr, dnaddr.a_addr, np->n_length);
dnaddrp = &dnaddr;
@@ -1343,13 +1343,13 @@ AddHost (ClientPtr client, if ((len = CheckAddr (family, pAddr, length)) < 0)
{
client->errorValue = length;
- return (BadValue);
+ return BadValue;
}
break;
case FamilyLocal:
default:
client->errorValue = family;
- return (BadValue);
+ return BadValue;
}
if (NewHost (family, pAddr, len, FALSE))
return Success;
@@ -1441,13 +1441,13 @@ RemoveHost ( if ((len = CheckAddr (family, pAddr, length)) < 0)
{
client->errorValue = length;
- return(BadValue);
+ return BadValue;
}
break;
case FamilyLocal:
default:
client->errorValue = family;
- return(BadValue);
+ return BadValue;
}
for (prev = &validhosts;
(host = *prev) && (!addrEqual (family, pAddr, len, host));
@@ -1458,7 +1458,7 @@ RemoveHost ( *prev = host->next;
FreeHost (host);
}
- return (Success);
+ return Success;
}
/* Get all hosts in the access control list */
@@ -1486,7 +1486,7 @@ GetHosts ( *data = ptr = malloc(n);
if (!ptr)
{
- return(BadAlloc);
+ return BadAlloc;
}
for (host = validhosts; host; host = host->next)
{
@@ -1502,7 +1502,7 @@ GetHosts ( }
*pnHosts = nHosts;
*pLen = n;
- return(Success);
+ return Success;
}
/* Check for valid address family and length, and return address length. */
@@ -1555,7 +1555,7 @@ CheckAddr ( default:
len = -1;
}
- return (len);
+ return len;
}
/* Check if a host is not in the access control list.
@@ -1572,7 +1572,7 @@ InvalidHost ( register HOST *selfhost, *host;
if (!AccessEnabled) /* just let them in */
- return(0);
+ return 0;
family = ConvertAddr (saddr, &len, (pointer *)&addr);
if (family == -1)
return 1;
@@ -1600,15 +1600,15 @@ InvalidHost ( {
if ((host->family == FamilyServerInterpreted)) {
if (siAddrMatch (family, addr, len, host, client)) {
- return (0);
+ return 0;
}
} else {
if (addrEqual (family, addr, len, host))
- return (0);
+ return 0;
}
}
- return (1);
+ return 1;
}
static int
@@ -1618,7 +1618,7 @@ ConvertAddr ( pointer *addr)
{
if (*len == 0)
- return (FamilyLocal);
+ return FamilyLocal;
switch (saddr->sa_family)
{
case AF_UNSPEC:
diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c index f35a2f66a..5cbca81bd 100644 --- a/xorg-server/os/connection.c +++ b/xorg-server/os/connection.c @@ -190,7 +190,7 @@ struct _ct_node *ct_head[256]; void InitConnectionTranslation(void)
{
- bzero(ct_head, sizeof(ct_head));
+ memset(ct_head, 0, sizeof(ct_head));
}
int GetConnectionTranslation(int conn)
@@ -274,7 +274,7 @@ lookup_trans_conn (int fd) return ListenTransConns[i];
}
- return (NULL);
+ return NULL;
}
int
diff --git a/xorg-server/os/io.c b/xorg-server/os/io.c index bf7fe0401..8cd25398b 100644 --- a/xorg-server/os/io.c +++ b/xorg-server/os/io.c @@ -508,7 +508,7 @@ InsertFakeRequest(ClientPtr client, char *data, int count) ibuf = (char *)realloc(oci->buffer, gotnow + count);
if (!ibuf)
- return(FALSE);
+ return FALSE;
oci->size = gotnow + count;
oci->buffer = ibuf;
oci->bufptr = ibuf + oci->bufcnt - gotnow;
@@ -529,7 +529,7 @@ InsertFakeRequest(ClientPtr client, char *data, int count) FD_SET(fd, &ClientsWithInput);
else
YieldControlNoInput(fd);
- return(TRUE);
+ return TRUE;
}
/*****************************************************************
@@ -706,7 +706,7 @@ WriteToClient (ClientPtr who, int count, const void *__buf) Bool multicount = FALSE;
#endif
if (!count || !who || who == serverClient || who->clientGone)
- return(0);
+ return 0;
oc = who->osPrivate;
oco = oc->output;
#ifdef DEBUG_COMMUNICATION
@@ -826,7 +826,7 @@ WriteToClient (ClientPtr who, int count, const void *__buf) FD_SET(oc->fd, &OutputPending);
memmove((char *)oco->buf + oco->count, buf, count);
oco->count += count + padBytes;
- return(count);
+ return count;
}
/********************
@@ -949,7 +949,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount) oc->trans_conn = NULL;
MarkClientException(who);
oco->count = 0;
- return(-1);
+ return -1;
}
oco->size = notWritten + BUFSIZE;
oco->buf = obuf;
@@ -982,7 +982,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount) }
MarkClientException(who);
oco->count = 0;
- return(-1);
+ return -1;
}
}
diff --git a/xorg-server/os/strcasecmp.c b/xorg-server/os/strcasecmp.c index ca1051dc1..c95bc5220 100644 --- a/xorg-server/os/strcasecmp.c +++ b/xorg-server/os/strcasecmp.c @@ -1,70 +1,70 @@ -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <ctype.h> -#include "dix.h" - -#ifdef NEED_STRCASECMP -int -xstrcasecmp(const char *str1, const char *str2) -{ - const u_char *us1 = (const u_char *)str1, *us2 = (const u_char *)str2; - - while (tolower(*us1) == tolower(*us2)) { - if (*us1++ == '\0') - return (0); - us2++; - } - - return (tolower(*us1) - tolower(*us2)); -} -#endif - -#ifdef NEED_STRNCASECMP -int -xstrncasecmp(const char *s1, const char *s2, size_t n) -{ - if (n != 0) { - const u_char *us1 = (const u_char *)s1, *us2 = (const u_char *)s2; - - do { - if (tolower(*us1) != tolower(*us2++)) - return (tolower(*us1) - tolower(*--us2)); - if (*us1++ == '\0') - break; - } while (--n != 0); - } - - return 0; -} -#endif +/*
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <ctype.h>
+#include "dix.h"
+
+#ifdef NEED_STRCASECMP
+int
+xstrcasecmp(const char *str1, const char *str2)
+{
+ const u_char *us1 = (const u_char *)str1, *us2 = (const u_char *)str2;
+
+ while (tolower(*us1) == tolower(*us2)) {
+ if (*us1++ == '\0')
+ return 0;
+ us2++;
+ }
+
+ return (tolower(*us1) - tolower(*us2));
+}
+#endif
+
+#ifdef NEED_STRNCASECMP
+int
+xstrncasecmp(const char *s1, const char *s2, size_t n)
+{
+ if (n != 0) {
+ const u_char *us1 = (const u_char *)s1, *us2 = (const u_char *)s2;
+
+ do {
+ if (tolower(*us1) != tolower(*us2++))
+ return (tolower(*us1) - tolower(*--us2));
+ if (*us1++ == '\0')
+ break;
+ } while (--n != 0);
+ }
+
+ return 0;
+}
+#endif
diff --git a/xorg-server/os/strcasestr.c b/xorg-server/os/strcasestr.c index b3d45495c..75f220fd3 100644 --- a/xorg-server/os/strcasestr.c +++ b/xorg-server/os/strcasestr.c @@ -1,64 +1,64 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <ctype.h> -#include <string.h> -#include "dix.h" - -/* - * Find the first occurrence of find in s, ignore case. - */ -#ifdef NEED_STRCASESTR -char * -xstrcasestr(const char *s, const char *find) -{ - char c, sc; - size_t len; - - if ((c = *find++) != 0) { - c = tolower((unsigned char)c); - len = strlen(find); - do { - do { - if ((sc = *s++) == 0) - return (NULL); - } while ((char)tolower((unsigned char)sc) != c); - } while (strncasecmp(s, find, len) != 0); - s--; - } - return ((char *)s); -} -#endif +/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <ctype.h>
+#include <string.h>
+#include "dix.h"
+
+/*
+ * Find the first occurrence of find in s, ignore case.
+ */
+#ifdef NEED_STRCASESTR
+char *
+xstrcasestr(const char *s, const char *find)
+{
+ char c, sc;
+ size_t len;
+
+ if ((c = *find++) != 0) {
+ c = tolower((unsigned char)c);
+ len = strlen(find);
+ do {
+ do {
+ if ((sc = *s++) == 0)
+ return NULL;
+ } while ((char)tolower((unsigned char)sc) != c);
+ } while (strncasecmp(s, find, len) != 0);
+ s--;
+ }
+ return ((char *)s);
+}
+#endif
diff --git a/xorg-server/os/strlcpy.c b/xorg-server/os/strlcpy.c index aa9d042e0..647adb5e9 100644 --- a/xorg-server/os/strlcpy.c +++ b/xorg-server/os/strlcpy.c @@ -1,54 +1,54 @@ -/* - * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE - * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <sys/types.h> -#include <string.h> -#include "os.h" - -/* - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. - */ -size_t -strlcpy(char *dst, const char *src, size_t siz) -{ - register char *d = dst; - register const char *s = src; - register size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ -} +/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
+ * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h>
+#include <string.h>
+#include "os.h"
+
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+ register char *d = dst;
+ register const char *s = src;
+ register size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0) {
+ do {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return s - src - 1; /* count does not include NUL */
+}
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c index a55ecf8f0..d8ca6c822 100644 --- a/xorg-server/os/utils.c +++ b/xorg-server/os/utils.c @@ -565,12 +565,12 @@ void UseMsg(void) static int
VerifyDisplayName(const char *d)
{
- if ( d == (char *)0 ) return( 0 ); /* null */
- if ( *d == '\0' ) return( 0 ); /* empty */
- if ( *d == '-' ) return( 0 ); /* could be confused for an option */
- if ( *d == '.' ) return( 0 ); /* must not equal "." or ".." */
- if ( strchr(d, '/') != (char *)0 ) return( 0 ); /* very important!!! */
- return( 1 );
+ if ( d == (char *)0 ) return 0; /* null */
+ if ( *d == '\0' ) return 0; /* empty */
+ if ( *d == '-' ) return 0; /* could be confused for an option */
+ if ( *d == '.' ) return 0; /* must not equal "." or ".." */
+ if ( strchr(d, '/') != (char *)0 ) return 0; /* very important!!! */
+ return 1;
}
/*
@@ -996,7 +996,7 @@ set_font_authorizations(char **authorizations, int *authlen, pointer client) gethostname(hname, 1024);
#if defined(IPv6) && defined(AF_INET6)
- bzero(&hints, sizeof(hints));
+ memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
if (getaddrinfo(hname, NULL, &hints, &ai) == 0) {
hnameptr = ai->ai_canonname;
@@ -1195,7 +1195,7 @@ SmartScheduleInit (void) if (SmartScheduleDisable)
return TRUE;
- bzero ((char *) &act, sizeof(struct sigaction));
+ memset((char *) &act, 0, sizeof(struct sigaction));
/* Set up the timer signal function */
act.sa_handler = SmartScheduleTimer;
@@ -1301,7 +1301,7 @@ System(char *command) int status;
if (!command)
- return(1);
+ return 1;
#ifdef SIGCHLD
csig = signal(SIGCHLD, SIG_DFL);
diff --git a/xorg-server/os/xdmauth.c b/xorg-server/os/xdmauth.c index b58d1d7cc..13da77a37 100644 --- a/xorg-server/os/xdmauth.c +++ b/xorg-server/os/xdmauth.c @@ -139,7 +139,7 @@ HexToBinary (const char *in, char *out, int len) void
XdmAuthenticationInit (const char *cookie, int cookie_len)
{
- bzero (privateKey.data, 8);
+ memset(privateKey.data, 0, 8);
if (!strncmp (cookie, "0x", 2) || !strncmp (cookie, "0X", 2))
{
if (cookie_len > 2 + 2 * 8)
diff --git a/xorg-server/os/xdmcp.c b/xorg-server/os/xdmcp.c index 6b0dd73c1..901a91d41 100644 --- a/xorg-server/os/xdmcp.c +++ b/xorg-server/os/xdmcp.c @@ -256,48 +256,48 @@ XdmcpOptions(int argc, char **argv, int i) get_manager_by_name(argc, argv, i++);
XDM_INIT_STATE = XDM_QUERY;
AccessUsingXdmcp ();
- return (i + 1);
+ return i + 1;
}
if (strcmp(argv[i], "-broadcast") == 0) {
XDM_INIT_STATE = XDM_BROADCAST;
AccessUsingXdmcp ();
- return (i + 1);
+ return i + 1;
}
#if defined(IPv6) && defined(AF_INET6)
if (strcmp(argv[i], "-multicast") == 0) {
i = get_mcast_options(argc, argv, ++i);
XDM_INIT_STATE = XDM_MULTICAST;
AccessUsingXdmcp ();
- return (i + 1);
+ return i + 1;
}
#endif
if (strcmp(argv[i], "-indirect") == 0) {
get_manager_by_name(argc, argv, i++);
XDM_INIT_STATE = XDM_INDIRECT;
AccessUsingXdmcp ();
- return (i + 1);
+ return i + 1;
}
if (strcmp(argv[i], "-port") == 0) {
if (++i == argc) {
FatalError("Xserver: missing port number in command line\n");
}
xdm_udp_port = (unsigned short) atoi(argv[i]);
- return (i + 1);
+ return i + 1;
}
if (strcmp(argv[i], "-from") == 0) {
get_fromaddr_by_name(argc, argv, ++i);
- return (i + 1);
+ return i + 1;
}
if (strcmp(argv[i], "-once") == 0) {
OneSession = TRUE;
- return (i + 1);
+ return i + 1;
}
if (strcmp(argv[i], "-class") == 0) {
if (++i == argc) {
FatalError("Xserver: missing class name in command line\n");
}
defaultDisplayClass = argv[i];
- return (i + 1);
+ return i + 1;
}
#ifdef HASXDMAUTH
if (strcmp(argv[i], "-cookie") == 0) {
@@ -305,7 +305,7 @@ XdmcpOptions(int argc, char **argv, int i) FatalError("Xserver: missing cookie data in command line\n");
}
xdmAuthCookie = argv[i];
- return (i + 1);
+ return i + 1;
}
#endif
if (strcmp(argv[i], "-displayID") == 0) {
@@ -313,9 +313,9 @@ XdmcpOptions(int argc, char **argv, int i) FatalError("Xserver: missing displayID in command line\n");
}
XdmcpRegisterManufacturerDisplayID (argv[i], strlen (argv[i]));
- return (i + 1);
+ return i + 1;
}
- return (i);
+ return i;
}
/*
@@ -343,7 +343,7 @@ XdmcpRegisterBroadcastAddress (const struct sockaddr_in *addr) if (NumBroadcastAddresses >= MAX_BROADCAST)
return;
bcast = &BroadcastAddresses[NumBroadcastAddresses++];
- bzero (bcast, sizeof (struct sockaddr_in));
+ memset(bcast, 0, sizeof (struct sockaddr_in));
#ifdef BSD44SOCKETS
bcast->sin_len = addr->sin_len;
#endif
@@ -1488,7 +1488,7 @@ get_addr_by_name( char *pport = portstr;
int gaierr;
- bzero(&hints, sizeof(hints));
+ memset(&hints, 0, sizeof(hints));
hints.ai_socktype = socktype;
if (port == 0) {
@@ -1621,7 +1621,7 @@ get_mcast_options(int argc, char **argv, int i) } else {
FatalError("Xserver: port out of range: %d\n", xdm_udp_port);
}
- bzero(&hints, sizeof(hints));
+ memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_DGRAM;
if ((gaierr = getaddrinfo(address, portstr, &hints, &firstai)) == 0) {
diff --git a/xorg-server/randr/randr.c b/xorg-server/randr/randr.c index b843f588d..e816461d8 100644 --- a/xorg-server/randr/randr.c +++ b/xorg-server/randr/randr.c @@ -54,11 +54,9 @@ static int SProcRRDispatch (ClientPtr pClient); int RREventBase;
int RRErrorBase;
RESTYPE RRClientType, RREventType; /* resource types for event masks */
-static int RRClientPrivateKeyIndex;
-DevPrivateKey RRClientPrivateKey = &RRClientPrivateKeyIndex;
+DevPrivateKeyRec RRClientPrivateKeyRec;
-static int rrPrivKeyIndex;
-DevPrivateKey rrPrivKey = &rrPrivKeyIndex;
+DevPrivateKeyRec rrPrivKeyRec;
static void
RRClientCallback (CallbackListPtr *list,
@@ -215,6 +213,9 @@ Bool RRInit (void) return FALSE;
RRGeneration = serverGeneration;
}
+ if (!dixRegisterPrivateKey(&rrPrivKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
return TRUE;
}
@@ -329,9 +330,9 @@ RRExtensionInit (void) if (RRNScreens == 0) return;
- if (!dixRequestPrivate(RRClientPrivateKey,
- sizeof (RRClientRec) +
- screenInfo.numScreens * sizeof (RRTimesRec)))
+ if (!dixRegisterPrivateKey(&RRClientPrivateKeyRec, PRIVATE_CLIENT,
+ sizeof (RRClientRec) +
+ screenInfo.numScreens * sizeof (RRTimesRec)))
return;
if (!AddCallback (&ClientStateCallback, RRClientCallback, 0))
return;
diff --git a/xorg-server/randr/randrstr.h b/xorg-server/randr/randrstr.h index aa938d651..45c2a5043 100644 --- a/xorg-server/randr/randrstr.h +++ b/xorg-server/randr/randrstr.h @@ -299,7 +299,8 @@ typedef struct _rrScrPriv { #endif
} rrScrPrivRec, *rrScrPrivPtr;
-extern _X_EXPORT DevPrivateKey rrPrivKey;
+extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec;
+#define rrPrivKey (&rrPrivKeyRec)
#define rrGetScrPriv(pScr) ((rrScrPrivPtr)dixLookupPrivate(&(pScr)->devPrivates, rrPrivKey))
#define rrScrPriv(pScr) rrScrPrivPtr pScrPriv = rrGetScrPriv(pScr)
@@ -335,7 +336,8 @@ typedef struct _RRClient { } RRClientRec, *RRClientPtr;
extern _X_EXPORT RESTYPE RRClientType, RREventType; /* resource types for event masks */
-extern _X_EXPORT DevPrivateKey RRClientPrivateKey;
+extern _X_EXPORT DevPrivateKeyRec RRClientPrivateKeyRec;
+#define RRClientPrivateKey (&RRClientPrivateKeyRec)
extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType;
#define VERIFY_RR_OUTPUT(id, ptr, a)\
diff --git a/xorg-server/randr/rrcrtc.c b/xorg-server/randr/rrcrtc.c index 45166cbff..a23c824c3 100644 --- a/xorg-server/randr/rrcrtc.c +++ b/xorg-server/randr/rrcrtc.c @@ -190,8 +190,7 @@ RRCrtcNotify (RRCrtcPtr crtc, }
else
{
- if (crtc->outputs)
- free(crtc->outputs);
+ free(crtc->outputs);
newoutputs = NULL;
}
crtc->outputs = newoutputs;
@@ -440,8 +439,7 @@ RRCrtcDestroyResource (pointer value, XID pid) }
}
}
- if (crtc->gammaRed)
- free(crtc->gammaRed);
+ free(crtc->gammaRed);
if (crtc->mode)
RRModeDestroy (crtc->mode);
free(crtc);
@@ -563,8 +561,7 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc, }
else
gamma = NULL;
- if (crtc->gammaRed)
- free(crtc->gammaRed);
+ free(crtc->gammaRed);
crtc->gammaRed = gamma;
crtc->gammaGreen = gamma + size;
crtc->gammaBlue = gamma + size*2;
@@ -805,8 +802,7 @@ ProcRRSetCrtcConfig (ClientPtr client) RROutputType, client, DixSetAttrAccess);
if (rc != Success)
{
- if (outputs)
- free(outputs);
+ free(outputs);
return rc;
}
/* validate crtc for this output */
@@ -815,8 +811,7 @@ ProcRRSetCrtcConfig (ClientPtr client) break;
if (j == outputs[i]->numCrtcs)
{
- if (outputs)
- free(outputs);
+ free(outputs);
return BadMatch;
}
/* validate mode for this output */
@@ -830,8 +825,7 @@ ProcRRSetCrtcConfig (ClientPtr client) }
if (j == outputs[i]->numModes + outputs[i]->numUserModes)
{
- if (outputs)
- free(outputs);
+ free(outputs);
return BadMatch;
}
}
@@ -850,8 +844,7 @@ ProcRRSetCrtcConfig (ClientPtr client) }
if (k == outputs[i]->numClones)
{
- if (outputs)
- free(outputs);
+ free(outputs);
return BadMatch;
}
}
@@ -870,19 +863,6 @@ ProcRRSetCrtcConfig (ClientPtr client) goto sendReply;
}
-#if 0
- /*
- * if the client's config timestamp is not the same as the last config
- * timestamp, then the config information isn't up-to-date and
- * can't even be validated
- */
- if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0)
- {
- rep.status = RRSetConfigInvalidConfigTime;
- goto sendReply;
- }
-#endif
-
/*
* Validate requested rotation
*/
@@ -900,8 +880,7 @@ ProcRRSetCrtcConfig (ClientPtr client) * Invalid rotation
*/
client->errorValue = stuff->rotation;
- if (outputs)
- free(outputs);
+ free(outputs);
return BadValue;
}
@@ -913,8 +892,7 @@ ProcRRSetCrtcConfig (ClientPtr client) * requested rotation or reflection not supported by screen
*/
client->errorValue = stuff->rotation;
- if (outputs)
- free(outputs);
+ free(outputs);
return BadMatch;
}
@@ -943,32 +921,20 @@ ProcRRSetCrtcConfig (ClientPtr client) if (stuff->x + source_width > pScreen->width)
{
client->errorValue = stuff->x;
- if (outputs)
- free(outputs);
+ free(outputs);
return BadValue;
}
if (stuff->y + source_height > pScreen->height)
{
client->errorValue = stuff->y;
- if (outputs)
- free(outputs);
+ free(outputs);
return BadValue;
}
}
#endif
}
- /*
- * Make sure the requested set-time is not older than
- * the last set-time
- */
- if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0)
- {
- rep.status = RRSetConfigInvalidTime;
- goto sendReply;
- }
-
if (!RRCrtcSet (crtc, mode, stuff->x, stuff->y,
rotation, numOutputs, outputs))
{
@@ -979,8 +945,7 @@ ProcRRSetCrtcConfig (ClientPtr client) pScrPriv->lastSetTime = time;
sendReply:
- if (outputs)
- free(outputs);
+ free(outputs);
rep.type = X_Reply;
/* rep.status has already been filled in */
@@ -1100,16 +1065,6 @@ ProcRRSetPanning (ClientPtr client) time = ClientTimeToServerTime(stuff->timestamp);
- /*
- * Make sure the requested set-time is not older than
- * the last set-time
- */
- if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0)
- {
- rep.status = RRSetConfigInvalidTime;
- goto sendReply;
- }
-
if (!pScrPriv->rrGetPanning)
return RRErrorBase + BadRRCrtc;
diff --git a/xorg-server/randr/rroutput.c b/xorg-server/randr/rroutput.c index ed88e6511..757f6f23c 100644 --- a/xorg-server/randr/rroutput.c +++ b/xorg-server/randr/rroutput.c @@ -139,8 +139,7 @@ RROutputSetClones (RROutputPtr output, }
else
newClones = NULL;
- if (output->clones)
- free(output->clones);
+ free(output->clones);
memcpy (newClones, clones, numClones * sizeof (RROutputPtr));
output->clones = newClones;
output->numClones = numClones;
@@ -285,8 +284,7 @@ RROutputSetCrtcs (RROutputPtr output, }
else
newCrtcs = NULL;
- if (output->crtcs)
- free(output->crtcs);
+ free(output->crtcs);
memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr));
output->crtcs = newCrtcs;
output->numCrtcs = numCrtcs;
@@ -407,13 +405,10 @@ RROutputDestroyResource (pointer value, XID pid) for (m = 0; m < output->numUserModes; m++)
RRModeDestroy (output->userModes[m]);
- if (output->userModes)
- free(output->userModes);
+ free(output->userModes);
- if (output->crtcs)
- free(output->crtcs);
- if (output->clones)
- free(output->clones);
+ free(output->crtcs);
+ free(output->clones);
RRDeleteAllOutputProperties (output);
free(output);
return 1;
diff --git a/xorg-server/randr/rrproperty.c b/xorg-server/randr/rrproperty.c index 898730eef..dd0caa0b3 100644 --- a/xorg-server/randr/rrproperty.c +++ b/xorg-server/randr/rrproperty.c @@ -53,27 +53,39 @@ static void RRDeliverPropertyEvent(ScreenPtr pScreen, xEvent *event) WalkTree(pScreen, DeliverPropertyEvent, event);
}
+static void
+RRDestroyOutputProperty (RRPropertyPtr prop)
+{
+ free(prop->valid_values);
+ free(prop->current.data);
+ free(prop->pending.data);
+ free(prop);
+}
+
+static void
+RRDeleteProperty(RROutputRec *output, RRPropertyRec *prop)
+{
+ xRROutputPropertyNotifyEvent event;
+ event.type = RREventBase + RRNotify;
+ event.subCode = RRNotify_OutputProperty;
+ event.output = output->id;
+ event.state = PropertyDelete;
+ event.atom = prop->propertyName;
+ event.timestamp = currentTime.milliseconds;
+
+ RRDeliverPropertyEvent(output->pScreen, (xEvent *)&event);
+
+ RRDestroyOutputProperty(prop);
+}
+
void
-RRDeleteAllOutputProperties (RROutputPtr output)
+RRDeleteAllOutputProperties(RROutputPtr output)
{
RRPropertyPtr prop, next;
- xRROutputPropertyNotifyEvent event;
- for (prop = output->properties; prop; prop = next)
- {
+ for (prop = output->properties; prop; prop = next) {
next = prop->next;
- event.type = RREventBase + RRNotify;
- event.subCode = RRNotify_OutputProperty;
- event.output = output->id;
- event.state = PropertyDelete;
- event.atom = prop->propertyName;
- event.timestamp = currentTime.milliseconds;
- RRDeliverPropertyEvent (output->pScreen, (xEvent *)&event);
- if (prop->current.data)
- free(prop->current.data);
- if (prop->pending.data)
- free(prop->pending.data);
- free(prop);
+ RRDeleteProperty(output, prop);
}
}
@@ -106,41 +118,17 @@ RRCreateOutputProperty (Atom property) return prop;
}
-static void
-RRDestroyOutputProperty (RRPropertyPtr prop)
-{
- if (prop->valid_values)
- free(prop->valid_values);
- if (prop->current.data)
- free(prop->current.data);
- if (prop->pending.data)
- free(prop->pending.data);
- if (prop->valid_values)
- free(prop->valid_values);
- free(prop);
-}
-
void
-RRDeleteOutputProperty (RROutputPtr output, Atom property)
+RRDeleteOutputProperty(RROutputPtr output, Atom property)
{
- RRPropertyPtr prop, *prev;
- xRROutputPropertyNotifyEvent event;
+ RRPropertyRec *prop, **prev;
for (prev = &output->properties; (prop = *prev); prev = &(prop->next))
- if (prop->propertyName == property)
- break;
- if (prop)
- {
- *prev = prop->next;
- event.type = RREventBase + RRNotify;
- event.subCode = RRNotify_OutputProperty;
- event.output = output->id;
- event.state = PropertyDelete;
- event.atom = prop->propertyName;
- event.timestamp = currentTime.milliseconds;
- RRDeliverPropertyEvent (output->pScreen, (xEvent *)&event);
- RRDestroyOutputProperty (prop);
- }
+ if (prop->propertyName == property) {
+ *prev = prop->next;
+ RRDeleteProperty(output, prop);
+ return;
+ }
}
int
@@ -166,7 +154,7 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, {
prop = RRCreateOutputProperty (property);
if (!prop)
- return(BadAlloc);
+ return BadAlloc;
add = TRUE;
mode = PropModeReplace;
}
@@ -181,9 +169,9 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, "PropModeReplace" since they will be written over. */
if ((format != prop_value->format) && (mode != PropModeReplace))
- return(BadMatch);
+ return BadMatch;
if ((prop_value->type != type) && (mode != PropModeReplace))
- return(BadMatch);
+ return BadMatch;
new_value = *prop_value;
if (mode == PropModeReplace)
total_len = len;
@@ -232,12 +220,10 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, !pScrPriv->rrOutputSetProperty(output->pScreen, output,
prop->propertyName, &new_value))
{
- if (new_value.data)
- free(new_value.data);
- return (BadValue);
+ free(new_value.data);
+ return BadValue;
}
- if (prop_value->data)
- free(prop_value->data);
+ free(prop_value->data);
*prop_value = new_value;
}
@@ -265,7 +251,7 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, event.timestamp = currentTime.milliseconds;
RRDeliverPropertyEvent (output->pScreen, (xEvent *)&event);
}
- return(Success);
+ return Success;
}
Bool
@@ -355,10 +341,10 @@ RRConfigureOutputProperty (RROutputPtr output, Atom property, {
prop = RRCreateOutputProperty (property);
if (!prop)
- return(BadAlloc);
+ return BadAlloc;
add = TRUE;
} else if (prop->immutable && !immutable)
- return(BadAccess);
+ return BadAccess;
/*
* ranges must have even number of values
@@ -378,8 +364,7 @@ RRConfigureOutputProperty (RROutputPtr output, Atom property, */
if (prop->is_pending && !pending)
{
- if (prop->pending.data)
- free(prop->pending.data);
+ free(prop->pending.data);
RRInitOutputPropertyValue (&prop->pending);
}
@@ -387,8 +372,7 @@ RRConfigureOutputProperty (RROutputPtr output, Atom property, prop->range = range;
prop->immutable = immutable;
prop->num_valid = num_values;
- if (prop->valid_values)
- free(prop->valid_values);
+ free(prop->valid_values);
prop->valid_values = new_values;
if (add) {
@@ -417,7 +401,7 @@ ProcRRListOutputProperties (ClientPtr client) numProps++;
if (numProps)
if(!(pAtoms = (Atom *)malloc(numProps * sizeof(Atom))))
- return(BadAlloc);
+ return BadAlloc;
rep.type = X_Reply;
rep.length = bytes_to_int32(numProps * sizeof(Atom));
@@ -546,12 +530,12 @@ ProcRRChangeOutputProperty (ClientPtr client) if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
- return(BadAtom);
+ return BadAtom;
}
if (!ValidAtom(stuff->type))
{
client->errorValue = stuff->type;
- return(BadAtom);
+ return BadAtom;
}
err = RRChangeOutputProperty(output, stuff->property,
@@ -576,7 +560,7 @@ ProcRRDeleteOutputProperty (ClientPtr client) if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
- return (BadAtom);
+ return BadAtom;
}
@@ -604,17 +588,17 @@ ProcRRGetOutputProperty (ClientPtr client) if (!ValidAtom(stuff->property))
{
client->errorValue = stuff->property;
- return(BadAtom);
+ return BadAtom;
}
if ((stuff->delete != xTrue) && (stuff->delete != xFalse))
{
client->errorValue = stuff->delete;
- return(BadValue);
+ return BadValue;
}
if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type))
{
client->errorValue = stuff->type;
- return(BadAtom);
+ return BadAtom;
}
for (prev = &output->properties; (prop = *prev); prev = &prop->next)
diff --git a/xorg-server/randr/rrscreen.c b/xorg-server/randr/rrscreen.c index c9e88eb4d..f8631cee3 100644 --- a/xorg-server/randr/rrscreen.c +++ b/xorg-server/randr/rrscreen.c @@ -78,7 +78,7 @@ RREditConnectionInfo (ScreenPtr pScreen) void
RRSendConfigNotify (ScreenPtr pScreen)
{
- WindowPtr pWin = WindowTable[pScreen->myNum];
+ WindowPtr pWin = pScreen->root;
xEvent event;
event.u.u.type = ConfigureNotify;
@@ -102,7 +102,7 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) rrScrPriv (pScreen);
xRRScreenChangeNotifyEvent se;
RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
- WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
se.type = RRScreenChangeNotify + RREventBase;
se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0);
@@ -625,7 +625,7 @@ ProcRRGetScreenInfo (ClientPtr client) rep.setOfRotations = RR_Rotate_0;
rep.sequenceNumber = client->sequence;
rep.length = 0;
- rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
+ rep.root = pWin->drawable.pScreen->root->drawable.id;
rep.timestamp = currentTime.milliseconds;
rep.configTimestamp = currentTime.milliseconds;
rep.nSizes = 0;
@@ -654,7 +654,7 @@ ProcRRGetScreenInfo (ClientPtr client) rep.setOfRotations = output->crtc->rotations;
rep.sequenceNumber = client->sequence;
rep.length = 0;
- rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
+ rep.root = pWin->drawable.pScreen->root->drawable.id;
rep.timestamp = pScrPriv->lastSetTime.milliseconds;
rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
rep.rotation = output->crtc->rotation;
@@ -956,8 +956,7 @@ ProcRRSetScreenConfig (ClientPtr client) sendReply:
- if (pData)
- free(pData);
+ free(pData);
rep.type = X_Reply;
/* rep.status has already been filled in */
@@ -966,7 +965,7 @@ sendReply: rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;
rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds;
- rep.root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
+ rep.root = pDraw->pScreen->root->drawable.id;
if (client->swapped)
{
diff --git a/xorg-server/randr/rrtransform.c b/xorg-server/randr/rrtransform.c index 6740e4825..03c5c97ba 100644 --- a/xorg-server/randr/rrtransform.c +++ b/xorg-server/randr/rrtransform.c @@ -37,8 +37,7 @@ RRTransformInit (RRTransformPtr transform) void
RRTransformFini (RRTransformPtr transform)
{
- if (transform->params)
- free(transform->params);
+ free(transform->params);
}
Bool
@@ -82,8 +81,7 @@ RRTransformSetFilter (RRTransformPtr dst, }
else
new_params = NULL;
- if (dst->params)
- free(dst->params);
+ free(dst->params);
dst->filter = filter;
dst->params = new_params;
dst->nparams = nparams;
diff --git a/xorg-server/randr/rrxinerama.c b/xorg-server/randr/rrxinerama.c index 374789374..1dee6ca22 100644 --- a/xorg-server/randr/rrxinerama.c +++ b/xorg-server/randr/rrxinerama.c @@ -216,7 +216,7 @@ ProcRRXineramaGetScreenSize(ClientPtr client) return rc;
pScreen = pWin->drawable.pScreen;
- pRoot = WindowTable[pScreen->myNum];
+ pRoot = pScreen->root;
rep.type = X_Reply;
rep.length = 0;
diff --git a/xorg-server/record/record.c b/xorg-server/record/record.c index a2698d1f3..17159fca4 100644 --- a/xorg-server/record/record.c +++ b/xorg-server/record/record.c @@ -43,6 +43,7 @@ and Jim Haggerty of Metheus. #include "swaprep.h"
#include "inputstr.h"
#include "eventconvert.h"
+#include "scrnintstr.h"
#include <stdio.h>
@@ -166,8 +167,8 @@ typedef struct { ProcFunctionPtr recordVector[256];
} RecordClientPrivateRec, *RecordClientPrivatePtr;
-static int RecordClientPrivateKeyIndex;
-static DevPrivateKey RecordClientPrivateKey = &RecordClientPrivateKeyIndex;
+static DevPrivateKeyRec RecordClientPrivateKeyRec;
+#define RecordClientPrivateKey (&RecordClientPrivateKeyRec)
/* RecordClientPrivatePtr RecordClientPrivate(ClientPtr)
* gets the client private of the given client. Syntactic sugar.
@@ -755,11 +756,11 @@ RecordSendProtocolEvents(RecordClientsAndProtocolPtr pRCAP, int scr = XineramaGetCursorScreen(inputInfo.pointer);
memcpy(&shiftedEvent, pev, sizeof(xEvent));
shiftedEvent.u.keyButtonPointer.rootX +=
- panoramiXdataPtr[scr].x -
- panoramiXdataPtr[0].x;
+ screenInfo.screens[scr]->x -
+ screenInfo.screens[0]->x;
shiftedEvent.u.keyButtonPointer.rootY +=
- panoramiXdataPtr[scr].y -
- panoramiXdataPtr[0].y;
+ screenInfo.screens[scr]->y -
+ screenInfo.screens[0]->y;
pEvToRecord = &shiftedEvent;
}
#endif /* PANORAMIX */
@@ -1494,7 +1495,7 @@ RecordAllocIntervals(SetInfoPtr psi, int nIntervals) malloc(nIntervals * sizeof(RecordSetInterval));
if (!psi->intervals)
return BadAlloc;
- bzero(psi->intervals, nIntervals * sizeof(RecordSetInterval));
+ memset(psi->intervals, 0, nIntervals * sizeof(RecordSetInterval));
psi->size = nIntervals;
return Success;
} /* end RecordAllocIntervals */
@@ -1668,7 +1669,7 @@ RecordRegisterClients(RecordContextPtr pContext, ClientPtr client, xRecordRegist err = BadAlloc;
goto bailout;
}
- bzero(si, sizeof(SetInfoRec) * maxSets);
+ memset(si, 0, sizeof(SetInfoRec) * maxSets);
/* theoretically you must do this because NULL may not be all-bits-zero */
for (i = 0; i < maxSets; i++)
@@ -1867,8 +1868,7 @@ bailout: if (si)
{
for (i = 0; i < maxSets; i++)
- if (si[i].intervals)
- free(si[i].intervals);
+ free(si[i].intervals);
free(si);
}
if (pCanonClients && pCanonClients != (XID *)&stuff[1])
@@ -1954,8 +1954,7 @@ ProcRecordCreateContext(ClientPtr client) err = BadAlloc;
}
bailout:
- if (pContext)
- free(pContext);
+ free(pContext);
return err;
} /* ProcRecordCreateContext */
@@ -2052,7 +2051,7 @@ RecordAllocRanges(GetContextRangeInfoPtr pri, int nRanges) pri->pRanges = pNewRange;
pri->size = newsize;
- bzero(&pri->pRanges[pri->size - SZINCR], SZINCR * sizeof(xRecordRange));
+ memset(&pri->pRanges[pri->size - SZINCR], 0, SZINCR * sizeof(xRecordRange));
if (pri->nRanges < nRanges)
pri->nRanges = nRanges;
return Success;
@@ -2351,7 +2350,7 @@ ProcRecordGetContext(ClientPtr client) bailout:
for (i = 0; i < nRCAPs; i++)
{
- if (pRangeInfo[i].pRanges) free(pRangeInfo[i].pRanges);
+ free(pRangeInfo[i].pRanges);
}
free(pRangeInfo);
return err;
diff --git a/xorg-server/record/set.c b/xorg-server/record/set.c index 12f0d1267..d4bb4f2cc 100644 --- a/xorg-server/record/set.c +++ b/xorg-server/record/set.c @@ -360,7 +360,7 @@ IntervalListCreateSet(RecordSetInterval *pIntervals, int nIntervals, memcpy(&prls[1], stackIntervals, nIntervals * sizeof(RecordSetInterval));
prls->nIntervals = nIntervals;
bailout:
- if (stackIntervals) free(stackIntervals);
+ free(stackIntervals);
return (RecordSetPtr)prls;
}
diff --git a/xorg-server/render/animcur.c b/xorg-server/render/animcur.c index 13f09d387..505c65c18 100644 --- a/xorg-server/render/animcur.c +++ b/xorg-server/render/animcur.c @@ -76,11 +76,11 @@ static CursorBits animCursorBits = { empty, empty, 2, 1, 1, 0, 0, 1
};
-static int AnimCurScreenPrivateKeyIndex;
-static DevPrivateKey AnimCurScreenPrivateKey = &AnimCurScreenPrivateKeyIndex;
+static DevPrivateKeyRec AnimCurScreenPrivateKeyRec;
+#define AnimCurScreenPrivateKey (&AnimCurScreenPrivateKeyRec)
#define IsAnimCur(c) ((c) && ((c)->bits == &animCursorBits))
-#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
+#define GetAnimCur(c) ((AnimCurPtr) ((((char *)(c) + CURSOR_REC_SIZE))))
#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p)
@@ -322,6 +322,9 @@ AnimCurInit (ScreenPtr pScreen) {
AnimCurScreenPtr as;
+ if (!dixRegisterPrivateKey(&AnimCurScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
as = (AnimCurScreenPtr) malloc(sizeof (AnimCurScreenRec));
if (!as)
return FALSE;
@@ -354,11 +357,12 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp if (IsAnimCur (cursors[i]))
return BadMatch;
- pCursor = (CursorPtr) malloc(sizeof (CursorRec) +
- sizeof (AnimCurRec) +
- ncursor * sizeof (AnimCurElt));
+ pCursor = (CursorPtr) calloc(CURSOR_REC_SIZE +
+ sizeof (AnimCurRec) +
+ ncursor * sizeof (AnimCurElt), 1);
if (!pCursor)
return BadAlloc;
+ dixInitPrivates(pCursor, pCursor + 1, PRIVATE_CURSOR);
pCursor->bits = &animCursorBits;
pCursor->refcnt = 1;
@@ -371,13 +375,12 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp pCursor->backBlue = cursors[0]->backBlue;
pCursor->id = cid;
- pCursor->devPrivates = NULL;
/* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, pCursor,
RT_NONE, NULL, DixCreateAccess);
if (rc != Success) {
- dixFreePrivates(pCursor->devPrivates);
+ dixFiniPrivates(pCursor, PRIVATE_CURSOR);
free(pCursor);
return rc;
}
diff --git a/xorg-server/render/glyph.c b/xorg-server/render/glyph.c index b147331c8..ab20da625 100644 --- a/xorg-server/render/glyph.c +++ b/xorg-server/render/glyph.c @@ -84,19 +84,13 @@ static const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 }; static GlyphHashRec globalGlyphs[GlyphFormatNum];
-static void
-FreeGlyphPrivates (GlyphPtr glyph)
-{
- dixFreePrivates(glyph->devPrivates);
- glyph->devPrivates = NULL;
-}
-
void
GlyphUninit (ScreenPtr pScreen)
{
PictureScreenPtr ps = GetPictureScreen (pScreen);
GlyphPtr glyph;
int fdepth, i;
+ int scrno = pScreen->myNum;
for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
{
@@ -108,8 +102,12 @@ GlyphUninit (ScreenPtr pScreen) glyph = globalGlyphs[fdepth].table[i].glyph;
if (glyph && glyph != DeletedGlyph)
{
+ if (GlyphPicture(glyph)[scrno])
+ {
+ FreePicture ((pointer) GlyphPicture (glyph)[scrno], 0);
+ GlyphPicture(glyph)[scrno] = NULL;
+ }
(*ps->UnrealizeGlyph) (pScreen, glyph);
- FreeGlyphPrivates(glyph);
}
}
}
@@ -301,8 +299,7 @@ FreeGlyph (GlyphPtr glyph, int format) }
FreeGlyphPicture(glyph);
- FreeGlyphPrivates(glyph);
- free(glyph);
+ dixFreeObjectWithPrivates(glyph, PRIVATE_GLYPH);
}
}
@@ -320,8 +317,7 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) if (gr->glyph && gr->glyph != DeletedGlyph && gr->glyph != glyph)
{
FreeGlyphPicture(glyph);
- FreeGlyphPrivates(glyph);
- free(glyph);
+ dixFreeObjectWithPrivates(glyph, PRIVATE_GLYPH);
glyph = gr->glyph;
}
else if (gr->glyph != glyph)
@@ -379,15 +375,17 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth) int size;
GlyphPtr glyph;
int i;
+ int head_size;
- size = screenInfo.numScreens * sizeof (PicturePtr);
- glyph = (GlyphPtr) malloc(size + sizeof (GlyphRec));
+ head_size = sizeof (GlyphRec) + screenInfo.numScreens * sizeof (PicturePtr);
+ size = (head_size + dixPrivatesSize(PRIVATE_GLYPH));
+ glyph = (GlyphPtr) malloc (size);
if (!glyph)
return 0;
glyph->refcnt = 0;
glyph->size = size + sizeof (xGlyphInfo);
glyph->info = *gi;
- glyph->devPrivates = NULL;
+ dixInitPrivates(glyph, (char *) glyph + head_size, PRIVATE_GLYPH);
for (i = 0; i < screenInfo.numScreens; i++)
{
@@ -411,8 +409,7 @@ bail: (*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
}
- FreeGlyphPrivates(glyph);
- free(glyph);
+ dixFreeObjectWithPrivates(glyph, PRIVATE_GLYPH);
return 0;
}
@@ -481,7 +478,6 @@ GlyphSetPtr AllocateGlyphSet (int fdepth, PictFormatPtr format)
{
GlyphSetPtr glyphSet;
- int size;
if (!globalGlyphs[fdepth].hashSet)
{
@@ -489,8 +485,7 @@ AllocateGlyphSet (int fdepth, PictFormatPtr format) return FALSE;
}
- size = sizeof (GlyphSetRec);
- glyphSet = calloc(1, size);
+ glyphSet = dixAllocateObjectWithPrivates(GlyphSetRec, PRIVATE_GLYPHSET);
if (!glyphSet)
return FALSE;
@@ -532,8 +527,7 @@ FreeGlyphSet (pointer value, else
ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE);
free(table);
- dixFreePrivates(glyphSet->devPrivates);
- free(glyphSet);
+ dixFreeObjectWithPrivates(glyphSet, PRIVATE_GLYPHSET);
}
return Success;
}
diff --git a/xorg-server/render/mipict.c b/xorg-server/render/mipict.c index 9051de5c1..fa4ad7f37 100644 --- a/xorg-server/render/mipict.c +++ b/xorg-server/render/mipict.c @@ -47,7 +47,7 @@ void miDestroyPicture (PicturePtr pPicture)
{
if (pPicture->freeCompClip)
- REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->pCompositeClip);
+ RegionDestroy(pPicture->pCompositeClip);
}
void
@@ -64,7 +64,7 @@ miDestroyPictureClip (PicturePtr pPicture) * we know we'll never have a list of rectangles, since ChangeClip
* immediately turns them into a region
*/
- REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->clientClip);
+ RegionDestroy(pPicture->clientClip);
break;
}
pPicture->clientClip = NULL;
@@ -85,7 +85,7 @@ miChangePictureClip (PicturePtr pPicture, switch (type) {
case CT_PIXMAP:
/* convert the pixmap to a region */
- clientClip = (pointer) BITMAP_TO_REGION(pScreen, (PixmapPtr) value);
+ clientClip = (pointer) BitmapToRegion(pScreen, (PixmapPtr) value);
if (!clientClip)
return BadAlloc;
clientClipType = CT_REGION;
@@ -100,7 +100,7 @@ miChangePictureClip (PicturePtr pPicture, clientClipType = CT_NONE;
break;
default:
- clientClip = (pointer) RECTS_TO_REGION(pScreen, n,
+ clientClip = (pointer) RegionFromRects(n,
(xRectangle *) value,
type);
if (!clientClip)
@@ -160,7 +160,7 @@ miValidatePicture (PicturePtr pPicture, if (pPicture->clientClipType == CT_NONE)
{
if (freeCompClip)
- REGION_DESTROY(pScreen, pPicture->pCompositeClip);
+ RegionDestroy(pPicture->pCompositeClip);
pPicture->pCompositeClip = pregWin;
pPicture->freeCompClip = freeTmpClip;
}
@@ -175,30 +175,30 @@ miValidatePicture (PicturePtr pPicture, * clip. if neither is real, create a new region.
*/
- REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ RegionTranslate(pPicture->clientClip,
pDrawable->x + pPicture->clipOrigin.x,
pDrawable->y + pPicture->clipOrigin.y);
if (freeCompClip)
{
- REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ RegionIntersect(pPicture->pCompositeClip,
pregWin, pPicture->clientClip);
if (freeTmpClip)
- REGION_DESTROY(pScreen, pregWin);
+ RegionDestroy(pregWin);
}
else if (freeTmpClip)
{
- REGION_INTERSECT(pScreen, pregWin, pregWin, pPicture->clientClip);
+ RegionIntersect(pregWin, pregWin, pPicture->clientClip);
pPicture->pCompositeClip = pregWin;
}
else
{
- pPicture->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
- REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ pPicture->pCompositeClip = RegionCreate(NullBox, 0);
+ RegionIntersect(pPicture->pCompositeClip,
pregWin, pPicture->clientClip);
}
pPicture->freeCompClip = TRUE;
- REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ RegionTranslate(pPicture->clientClip,
-(pDrawable->x + pPicture->clipOrigin.x),
-(pDrawable->y + pPicture->clipOrigin.y));
}
@@ -216,31 +216,31 @@ miValidatePicture (PicturePtr pPicture, if (pPicture->freeCompClip)
{
- REGION_RESET(pScreen, pPicture->pCompositeClip, &pixbounds);
+ RegionReset(pPicture->pCompositeClip, &pixbounds);
}
else
{
pPicture->freeCompClip = TRUE;
- pPicture->pCompositeClip = REGION_CREATE(pScreen, &pixbounds, 1);
+ pPicture->pCompositeClip = RegionCreate(&pixbounds, 1);
}
if (pPicture->clientClipType == CT_REGION)
{
if(pDrawable->x || pDrawable->y) {
- REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ RegionTranslate(pPicture->clientClip,
pDrawable->x + pPicture->clipOrigin.x,
pDrawable->y + pPicture->clipOrigin.y);
- REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ RegionIntersect(pPicture->pCompositeClip,
pPicture->pCompositeClip, pPicture->clientClip);
- REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ RegionTranslate(pPicture->clientClip,
-(pDrawable->x + pPicture->clipOrigin.x),
-(pDrawable->y + pPicture->clipOrigin.y));
} else {
- REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
+ RegionTranslate(pPicture->pCompositeClip,
-pPicture->clipOrigin.x, -pPicture->clipOrigin.y);
- REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ RegionIntersect(pPicture->pCompositeClip,
pPicture->pCompositeClip, pPicture->clientClip);
- REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
+ RegionTranslate(pPicture->pCompositeClip,
pPicture->clipOrigin.x, pPicture->clipOrigin.y);
}
}
@@ -321,7 +321,7 @@ miClipPictureSrc (RegionPtr pRegion, pPicture->clipOrigin.x + dx,
pPicture->clipOrigin.y + dy);
- result = REGION_INTERSECT (pScreen, pRegion, pRegion, pPicture->clientClip);
+ result = RegionIntersect(pRegion, pRegion, pPicture->clientClip);
pixman_region_translate ( pPicture->clientClip,
- (pPicture->clipOrigin.x + dx),
diff --git a/xorg-server/render/mirect.c b/xorg-server/render/mirect.c index 70bdf63f6..d0becd578 100644 --- a/xorg-server/render/mirect.c +++ b/xorg-server/render/mirect.c @@ -42,7 +42,6 @@ miColorRects (PicturePtr pDst, int xoff,
int yoff)
{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
CARD32 pixel;
GCPtr pGC;
ChangeGCVal tmpval[5];
@@ -51,7 +50,7 @@ miColorRects (PicturePtr pDst, miRenderColorToPixel (pDst->pFormat, color, &pixel);
- pGC = GetScratchGC (pDst->pDrawable->depth, pScreen);
+ pGC = GetScratchGC (pDst->pDrawable->depth, pDst->pDrawable->pScreen);
if (!pGC)
return;
tmpval[0].val = GXcopy;
@@ -64,8 +63,8 @@ miColorRects (PicturePtr pDst, tmpval[4].val = pDst->clipOrigin.y - yoff;
mask |= GCClipXOrigin|GCClipYOrigin;
- pClip = REGION_CREATE (pScreen, NULL, 1);
- REGION_COPY (pScreen, pClip,
+ pClip = RegionCreate(NULL, 1);
+ RegionCopy(pClip,
(RegionPtr) pClipPict->clientClip);
(*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
}
diff --git a/xorg-server/render/picture.c b/xorg-server/render/picture.c index a67a95888..17b1a2714 100644 --- a/xorg-server/render/picture.c +++ b/xorg-server/render/picture.c @@ -42,10 +42,8 @@ #include "picturestr.h"
#include "xace.h"
-static int PictureScreenPrivateKeyIndex;
-DevPrivateKey PictureScreenPrivateKey = &PictureScreenPrivateKeyIndex;
-static int PictureWindowPrivateKeyIndex;
-DevPrivateKey PictureWindowPrivateKey = &PictureWindowPrivateKeyIndex;
+DevPrivateKeyRec PictureScreenPrivateKeyRec;
+DevPrivateKeyRec PictureWindowPrivateKeyRec;
static int PictureGeneration;
RESTYPE PictureType;
RESTYPE PictFormatType;
@@ -628,6 +626,12 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) return FALSE;
PictureGeneration = serverGeneration;
}
+ if (!dixRegisterPrivateKey(&PictureScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&PictureWindowPrivateKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
if (!formats)
{
formats = PictureCreateDefaultFormats (pScreen, &nformats);
@@ -753,7 +757,7 @@ CreatePicture (Picture pid, PicturePtr pPicture;
PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen);
- pPicture = (PicturePtr)malloc(sizeof(PictureRec));
+ pPicture = dixAllocateObjectWithPrivates(PictureRec, PRIVATE_PICTURE);
if (!pPicture)
{
*error = BadAlloc;
@@ -764,7 +768,6 @@ CreatePicture (Picture pid, pPicture->pDrawable = pDrawable;
pPicture->pFormat = pFormat;
pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24);
- pPicture->devPrivates = NULL;
/* security creation/labeling check */
*error = XaceHook(XACE_RESOURCE_ACCESS, client, pid, PictureType, pPicture,
@@ -896,12 +899,11 @@ static void initGradient(SourcePictPtr pGradient, int stopCount, static PicturePtr createSourcePicture(void)
{
PicturePtr pPicture;
- pPicture = (PicturePtr) malloc(sizeof(PictureRec));
+ pPicture = dixAllocateObjectWithPrivates(PictureRec, PRIVATE_PICTURE);
pPicture->pDrawable = 0;
pPicture->pFormat = 0;
pPicture->pNext = 0;
pPicture->format = PICT_a8r8g8b8;
- pPicture->devPrivates = 0;
SetPictureToDefaults(pPicture);
return pPicture;
@@ -1298,8 +1300,7 @@ SetPictureClipRects (PicturePtr pPicture, RegionPtr clientClip;
int result;
- clientClip = RECTS_TO_REGION(pScreen,
- nRect, rects, CT_UNSORTED);
+ clientClip = RegionFromRects(nRect, rects, CT_UNSORTED);
if (!clientClip)
return BadAlloc;
result =(*ps->ChangePictureClip) (pPicture, CT_REGION,
@@ -1329,14 +1330,13 @@ SetPictureClipRegion (PicturePtr pPicture, if (pRegion)
{
type = CT_REGION;
- clientClip = REGION_CREATE (pScreen,
- REGION_EXTENTS(pScreen, pRegion),
- REGION_NUM_RECTS(pRegion));
+ clientClip = RegionCreate(RegionExtents(pRegion),
+ RegionNumRects(pRegion));
if (!clientClip)
return BadAlloc;
- if (!REGION_COPY (pSCreen, clientClip, pRegion))
+ if (!RegionCopy(clientClip, pRegion))
{
- REGION_DESTROY (pScreen, clientClip);
+ RegionDestroy(clientClip);
return BadAlloc;
}
}
@@ -1462,9 +1462,9 @@ CopyPicture (PicturePtr pSrc, RegionPtr clientClip;
RegionPtr srcClientClip = (RegionPtr)pSrc->clientClip;
- clientClip = REGION_CREATE(pSrc->pDrawable->pScreen,
- REGION_EXTENTS(pSrc->pDrawable->pScreen, srcClientClip),
- REGION_NUM_RECTS(srcClientClip));
+ clientClip = RegionCreate(
+ RegionExtents(srcClientClip),
+ RegionNumRects(srcClientClip));
(*ps->ChangePictureClip)(pDst, CT_REGION, clientClip, 0);
}
break;
@@ -1524,8 +1524,7 @@ FreePicture (pointer value, if (--pPicture->refcnt == 0)
{
- if (pPicture->transform)
- free(pPicture->transform);
+ free(pPicture->transform);
if (pPicture->pSourcePict)
{
@@ -1566,8 +1565,7 @@ FreePicture (pointer value, (*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable);
}
}
- dixFreePrivates(pPicture->devPrivates);
- free(pPicture);
+ dixFreeObjectWithPrivates(pPicture, PRIVATE_PICTURE);
}
return Success;
}
diff --git a/xorg-server/render/picture.h b/xorg-server/render/picture.h index 8bd38b98e..461bbf01b 100644 --- a/xorg-server/render/picture.h +++ b/xorg-server/render/picture.h @@ -1,232 +1,231 @@ -/* - * - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#ifndef _PICTURE_H_ -#define _PICTURE_H_ - -#include "privates.h" - -#include <pixman.h> - -typedef struct _DirectFormat *DirectFormatPtr; -typedef struct _PictFormat *PictFormatPtr; -typedef struct _Picture *PicturePtr; - -/* - * While the protocol is generous in format support, the - * sample implementation allows only packed RGB and GBR - * representations for data to simplify software rendering, - */ -#define PICT_FORMAT(bpp,type,a,r,g,b) PIXMAN_FORMAT(bpp, type, a, r, g, b) - -/* - * gray/color formats use a visual index instead of argb - */ -#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \ - ((type) << 16) | \ - ((vi))) - -#define PICT_FORMAT_BPP(f) PIXMAN_FORMAT_BPP(f) -#define PICT_FORMAT_TYPE(f) PIXMAN_FORMAT_TYPE(f) -#define PICT_FORMAT_A(f) PIXMAN_FORMAT_A(f) -#define PICT_FORMAT_R(f) PIXMAN_FORMAT_R(f) -#define PICT_FORMAT_G(f) PIXMAN_FORMAT_G(f) -#define PICT_FORMAT_B(f) PIXMAN_FORMAT_B(f) -#define PICT_FORMAT_RGB(f) PIXMAN_FORMAT_RGB(f) -#define PICT_FORMAT_VIS(f) PIXMAN_FORMAT_VIS(f) - -#define PICT_TYPE_OTHER PIXMAN_TYPE_OTHER -#define PICT_TYPE_A PIXMAN_TYPE_A -#define PICT_TYPE_ARGB PIXMAN_TYPE_ARGB -#define PICT_TYPE_ABGR PIXMAN_TYPE_ABGR -#define PICT_TYPE_COLOR PIXMAN_TYPE_COLOR -#define PICT_TYPE_GRAY PIXMAN_TYPE_GRAY -#define PICT_TYPE_BGRA PIXMAN_TYPE_BGRA - -#define PICT_FORMAT_COLOR(f) PIXMAN_FORMAT_COLOR(f) - -/* 32bpp formats */ -typedef enum _PictFormatShort { - PICT_a2r10g10b10 = PIXMAN_a2r10g10b10, - PICT_x2r10g10b10 = PIXMAN_x2r10g10b10, - PICT_a2b10g10r10 = PIXMAN_a2b10g10r10, - PICT_x2b10g10r10 = PIXMAN_x2b10g10r10, - - PICT_a8r8g8b8 = PIXMAN_a8r8g8b8, - PICT_x8r8g8b8 = PIXMAN_x8r8g8b8, - PICT_a8b8g8r8 = PIXMAN_a8b8g8r8, - PICT_x8b8g8r8 = PIXMAN_x8b8g8r8, - PICT_b8g8r8a8 = PIXMAN_b8g8r8a8, - PICT_b8g8r8x8 = PIXMAN_b8g8r8x8, - -/* 24bpp formats */ - PICT_r8g8b8 = PIXMAN_r8g8b8, - PICT_b8g8r8 = PIXMAN_b8g8r8, - -/* 16bpp formats */ - PICT_r5g6b5 = PIXMAN_r5g6b5, - PICT_b5g6r5 = PIXMAN_b5g6r5, - - PICT_a1r5g5b5 = PIXMAN_a1r5g5b5, - PICT_x1r5g5b5 = PIXMAN_x1r5g5b5, - PICT_a1b5g5r5 = PIXMAN_a1b5g5r5, - PICT_x1b5g5r5 = PIXMAN_x1b5g5r5, - PICT_a4r4g4b4 = PIXMAN_a4r4g4b4, - PICT_x4r4g4b4 = PIXMAN_x4r4g4b4, - PICT_a4b4g4r4 = PIXMAN_a4b4g4r4, - PICT_x4b4g4r4 = PIXMAN_x4b4g4r4, - -/* 8bpp formats */ - PICT_a8 = PIXMAN_a8, - PICT_r3g3b2 = PIXMAN_r3g3b2, - PICT_b2g3r3 = PIXMAN_b2g3r3, - PICT_a2r2g2b2 = PIXMAN_a2r2g2b2, - PICT_a2b2g2r2 = PIXMAN_a2b2g2r2, - - PICT_c8 = PIXMAN_c8, - PICT_g8 = PIXMAN_g8, - - PICT_x4a4 = PIXMAN_x4a4, - - PICT_x4c4 = PIXMAN_x4c4, - PICT_x4g4 = PIXMAN_x4g4, - -/* 4bpp formats */ - PICT_a4 = PIXMAN_a4, - PICT_r1g2b1 = PIXMAN_r1g2b1, - PICT_b1g2r1 = PIXMAN_b1g2r1, - PICT_a1r1g1b1 = PIXMAN_a1r1g1b1, - PICT_a1b1g1r1 = PIXMAN_a1b1g1r1, - - PICT_c4 = PIXMAN_c4, - PICT_g4 = PIXMAN_g4, - -/* 1bpp formats */ - PICT_a1 = PIXMAN_a1, - - PICT_g1 = PIXMAN_g1 -} PictFormatShort; - -/* - * For dynamic indexed visuals (GrayScale and PseudoColor), these control the - * selection of colors allocated for drawing to Pictures. The default - * policy depends on the size of the colormap: - * - * Size Default Policy - * ---------------------------- - * < 64 PolicyMono - * < 256 PolicyGray - * 256 PolicyColor (only on PseudoColor) - * - * The actual allocation code lives in miindex.c, and so is - * austensibly server dependent, but that code does: - * - * PolicyMono Allocate no additional colors, use black and white - * PolicyGray Allocate 13 gray levels (11 cells used) - * PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used) - * PolicyAll Allocate as big a cube as possible, fill with gray (all) - * - * Here's a picture to help understand how many colors are - * actually allocated (this is just the gray ramp): - * - * gray level - * all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff - * b/w 0000 ffff - * 4x4x4 5555 aaaa - * extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa - * - * The default colormap supplies two gray levels (black/white), the - * 4x4x4 cube allocates another two and nine more are allocated to fill - * in the 13 levels. When the 4x4x4 cube is not allocated, a total of - * 11 cells are allocated. - */ - -#define PictureCmapPolicyInvalid -1 -#define PictureCmapPolicyDefault 0 -#define PictureCmapPolicyMono 1 -#define PictureCmapPolicyGray 2 -#define PictureCmapPolicyColor 3 -#define PictureCmapPolicyAll 4 - -extern _X_EXPORT int PictureCmapPolicy; - -extern _X_EXPORT int PictureParseCmapPolicy (const char *name); - -extern _X_EXPORT int RenderErrBase; -extern _X_EXPORT DevPrivateKey RenderClientPrivateKey; - -/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */ - -typedef pixman_fixed_32_32_t xFixed_32_32; - -typedef pixman_fixed_48_16_t xFixed_48_16; - -#define MAX_FIXED_48_16 pixman_max_fixed_48_16 -#define MIN_FIXED_48_16 pixman_min_fixed_48_16 - -typedef pixman_fixed_1_31_t xFixed_1_31; -typedef pixman_fixed_1_16_t xFixed_1_16; -typedef pixman_fixed_16_16_t xFixed_16_16; - -/* - * An unadorned "xFixed" is the same as xFixed_16_16, - * (since it's quite common in the code) - */ -typedef pixman_fixed_t xFixed; -#define XFIXED_BITS 16 - -#define xFixedToInt(f) pixman_fixed_to_int(f) -#define IntToxFixed(i) pixman_int_to_fixed(i) -#define xFixedE pixman_fixed_e -#define xFixed1 pixman_fixed_1 -#define xFixed1MinusE pixman_fixed_1_minus_e -#define xFixedFrac(f) pixman_fixed_frac(f) -#define xFixedFloor(f) pixman_fixed_floor(f) -#define xFixedCeil(f) pixman_fixed_ceil(f) - -#define xFixedFraction(f) pixman_fixed_fraction(f) -#define xFixedMod2(f) pixman_fixed_mod2(f) - -/* whether 't' is a well defined not obviously empty trapezoid */ -#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \ - (t)->right.p1.y != (t)->right.p2.y && \ - (int) ((t)->bottom - (t)->top) > 0) - -/* - * Standard NTSC luminance conversions: - * - * y = r * 0.299 + g * 0.587 + b * 0.114 - * - * Approximate this for a bit more speed: - * - * y = (r * 153 + g * 301 + b * 58) / 512 - * - * This gives 17 bits of luminance; to get 15 bits, lop the low two - */ - -#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \ - (((s) >> 8) & 0xff) * 301 + \ - (((s) ) & 0xff) * 58) >> 2) - -#endif /* _PICTURE_H_ */ +/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _PICTURE_H_
+#define _PICTURE_H_
+
+#include "privates.h"
+
+#include <pixman.h>
+
+typedef struct _DirectFormat *DirectFormatPtr;
+typedef struct _PictFormat *PictFormatPtr;
+typedef struct _Picture *PicturePtr;
+
+/*
+ * While the protocol is generous in format support, the
+ * sample implementation allows only packed RGB and GBR
+ * representations for data to simplify software rendering,
+ */
+#define PICT_FORMAT(bpp,type,a,r,g,b) PIXMAN_FORMAT(bpp, type, a, r, g, b)
+
+/*
+ * gray/color formats use a visual index instead of argb
+ */
+#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \
+ ((type) << 16) | \
+ ((vi)))
+
+#define PICT_FORMAT_BPP(f) PIXMAN_FORMAT_BPP(f)
+#define PICT_FORMAT_TYPE(f) PIXMAN_FORMAT_TYPE(f)
+#define PICT_FORMAT_A(f) PIXMAN_FORMAT_A(f)
+#define PICT_FORMAT_R(f) PIXMAN_FORMAT_R(f)
+#define PICT_FORMAT_G(f) PIXMAN_FORMAT_G(f)
+#define PICT_FORMAT_B(f) PIXMAN_FORMAT_B(f)
+#define PICT_FORMAT_RGB(f) PIXMAN_FORMAT_RGB(f)
+#define PICT_FORMAT_VIS(f) PIXMAN_FORMAT_VIS(f)
+
+#define PICT_TYPE_OTHER PIXMAN_TYPE_OTHER
+#define PICT_TYPE_A PIXMAN_TYPE_A
+#define PICT_TYPE_ARGB PIXMAN_TYPE_ARGB
+#define PICT_TYPE_ABGR PIXMAN_TYPE_ABGR
+#define PICT_TYPE_COLOR PIXMAN_TYPE_COLOR
+#define PICT_TYPE_GRAY PIXMAN_TYPE_GRAY
+#define PICT_TYPE_BGRA PIXMAN_TYPE_BGRA
+
+#define PICT_FORMAT_COLOR(f) PIXMAN_FORMAT_COLOR(f)
+
+/* 32bpp formats */
+typedef enum _PictFormatShort {
+ PICT_a2r10g10b10 = PIXMAN_a2r10g10b10,
+ PICT_x2r10g10b10 = PIXMAN_x2r10g10b10,
+ PICT_a2b10g10r10 = PIXMAN_a2b10g10r10,
+ PICT_x2b10g10r10 = PIXMAN_x2b10g10r10,
+
+ PICT_a8r8g8b8 = PIXMAN_a8r8g8b8,
+ PICT_x8r8g8b8 = PIXMAN_x8r8g8b8,
+ PICT_a8b8g8r8 = PIXMAN_a8b8g8r8,
+ PICT_x8b8g8r8 = PIXMAN_x8b8g8r8,
+ PICT_b8g8r8a8 = PIXMAN_b8g8r8a8,
+ PICT_b8g8r8x8 = PIXMAN_b8g8r8x8,
+
+/* 24bpp formats */
+ PICT_r8g8b8 = PIXMAN_r8g8b8,
+ PICT_b8g8r8 = PIXMAN_b8g8r8,
+
+/* 16bpp formats */
+ PICT_r5g6b5 = PIXMAN_r5g6b5,
+ PICT_b5g6r5 = PIXMAN_b5g6r5,
+
+ PICT_a1r5g5b5 = PIXMAN_a1r5g5b5,
+ PICT_x1r5g5b5 = PIXMAN_x1r5g5b5,
+ PICT_a1b5g5r5 = PIXMAN_a1b5g5r5,
+ PICT_x1b5g5r5 = PIXMAN_x1b5g5r5,
+ PICT_a4r4g4b4 = PIXMAN_a4r4g4b4,
+ PICT_x4r4g4b4 = PIXMAN_x4r4g4b4,
+ PICT_a4b4g4r4 = PIXMAN_a4b4g4r4,
+ PICT_x4b4g4r4 = PIXMAN_x4b4g4r4,
+
+/* 8bpp formats */
+ PICT_a8 = PIXMAN_a8,
+ PICT_r3g3b2 = PIXMAN_r3g3b2,
+ PICT_b2g3r3 = PIXMAN_b2g3r3,
+ PICT_a2r2g2b2 = PIXMAN_a2r2g2b2,
+ PICT_a2b2g2r2 = PIXMAN_a2b2g2r2,
+
+ PICT_c8 = PIXMAN_c8,
+ PICT_g8 = PIXMAN_g8,
+
+ PICT_x4a4 = PIXMAN_x4a4,
+
+ PICT_x4c4 = PIXMAN_x4c4,
+ PICT_x4g4 = PIXMAN_x4g4,
+
+/* 4bpp formats */
+ PICT_a4 = PIXMAN_a4,
+ PICT_r1g2b1 = PIXMAN_r1g2b1,
+ PICT_b1g2r1 = PIXMAN_b1g2r1,
+ PICT_a1r1g1b1 = PIXMAN_a1r1g1b1,
+ PICT_a1b1g1r1 = PIXMAN_a1b1g1r1,
+
+ PICT_c4 = PIXMAN_c4,
+ PICT_g4 = PIXMAN_g4,
+
+/* 1bpp formats */
+ PICT_a1 = PIXMAN_a1,
+
+ PICT_g1 = PIXMAN_g1
+} PictFormatShort;
+
+/*
+ * For dynamic indexed visuals (GrayScale and PseudoColor), these control the
+ * selection of colors allocated for drawing to Pictures. The default
+ * policy depends on the size of the colormap:
+ *
+ * Size Default Policy
+ * ----------------------------
+ * < 64 PolicyMono
+ * < 256 PolicyGray
+ * 256 PolicyColor (only on PseudoColor)
+ *
+ * The actual allocation code lives in miindex.c, and so is
+ * austensibly server dependent, but that code does:
+ *
+ * PolicyMono Allocate no additional colors, use black and white
+ * PolicyGray Allocate 13 gray levels (11 cells used)
+ * PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used)
+ * PolicyAll Allocate as big a cube as possible, fill with gray (all)
+ *
+ * Here's a picture to help understand how many colors are
+ * actually allocated (this is just the gray ramp):
+ *
+ * gray level
+ * all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff
+ * b/w 0000 ffff
+ * 4x4x4 5555 aaaa
+ * extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa
+ *
+ * The default colormap supplies two gray levels (black/white), the
+ * 4x4x4 cube allocates another two and nine more are allocated to fill
+ * in the 13 levels. When the 4x4x4 cube is not allocated, a total of
+ * 11 cells are allocated.
+ */
+
+#define PictureCmapPolicyInvalid -1
+#define PictureCmapPolicyDefault 0
+#define PictureCmapPolicyMono 1
+#define PictureCmapPolicyGray 2
+#define PictureCmapPolicyColor 3
+#define PictureCmapPolicyAll 4
+
+extern _X_EXPORT int PictureCmapPolicy;
+
+extern _X_EXPORT int PictureParseCmapPolicy (const char *name);
+
+extern _X_EXPORT int RenderErrBase;
+
+/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
+
+typedef pixman_fixed_32_32_t xFixed_32_32;
+
+typedef pixman_fixed_48_16_t xFixed_48_16;
+
+#define MAX_FIXED_48_16 pixman_max_fixed_48_16
+#define MIN_FIXED_48_16 pixman_min_fixed_48_16
+
+typedef pixman_fixed_1_31_t xFixed_1_31;
+typedef pixman_fixed_1_16_t xFixed_1_16;
+typedef pixman_fixed_16_16_t xFixed_16_16;
+
+/*
+ * An unadorned "xFixed" is the same as xFixed_16_16,
+ * (since it's quite common in the code)
+ */
+typedef pixman_fixed_t xFixed;
+#define XFIXED_BITS 16
+
+#define xFixedToInt(f) pixman_fixed_to_int(f)
+#define IntToxFixed(i) pixman_int_to_fixed(i)
+#define xFixedE pixman_fixed_e
+#define xFixed1 pixman_fixed_1
+#define xFixed1MinusE pixman_fixed_1_minus_e
+#define xFixedFrac(f) pixman_fixed_frac(f)
+#define xFixedFloor(f) pixman_fixed_floor(f)
+#define xFixedCeil(f) pixman_fixed_ceil(f)
+
+#define xFixedFraction(f) pixman_fixed_fraction(f)
+#define xFixedMod2(f) pixman_fixed_mod2(f)
+
+/* whether 't' is a well defined not obviously empty trapezoid */
+#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \
+ (t)->right.p1.y != (t)->right.p2.y && \
+ (int) ((t)->bottom - (t)->top) > 0)
+
+/*
+ * Standard NTSC luminance conversions:
+ *
+ * y = r * 0.299 + g * 0.587 + b * 0.114
+ *
+ * Approximate this for a bit more speed:
+ *
+ * y = (r * 153 + g * 301 + b * 58) / 512
+ *
+ * This gives 17 bits of luminance; to get 15 bits, lop the low two
+ */
+
+#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
+ (((s) >> 8) & 0xff) * 301 + \
+ (((s) ) & 0xff) * 58) >> 2)
+
+#endif /* _PICTURE_H_ */
diff --git a/xorg-server/render/picturestr.h b/xorg-server/render/picturestr.h index 7d04deacf..ca6d5868b 100644 --- a/xorg-server/render/picturestr.h +++ b/xorg-server/render/picturestr.h @@ -396,14 +396,18 @@ typedef struct _PictureScreen { } PictureScreenRec, *PictureScreenPtr;
-extern _X_EXPORT DevPrivateKey PictureScreenPrivateKey;
-extern _X_EXPORT DevPrivateKey PictureWindowPrivateKey;
+extern _X_EXPORT DevPrivateKeyRec PictureScreenPrivateKeyRec;
+#define PictureScreenPrivateKey (&PictureScreenPrivateKeyRec)
+
+extern _X_EXPORT DevPrivateKeyRec PictureWindowPrivateKeyRec;
+#define PictureWindowPrivateKey (&PictureWindowPrivateKeyRec)
+
extern _X_EXPORT RESTYPE PictureType;
extern _X_EXPORT RESTYPE PictFormatType;
extern _X_EXPORT RESTYPE GlyphSetType;
#define GetPictureScreen(s) ((PictureScreenPtr)dixLookupPrivate(&(s)->devPrivates, PictureScreenPrivateKey))
-#define GetPictureScreenIfSet(s) GetPictureScreen(s)
+#define GetPictureScreenIfSet(s) (dixPrivateKeyRegistered(PictureScreenPrivateKey) ? GetPictureScreen(s) : NULL)
#define SetPictureScreen(s,p) dixSetPrivate(&(s)->devPrivates, PictureScreenPrivateKey, p)
#define GetPictureWindow(w) ((PicturePtr)dixLookupPrivate(&(w)->devPrivates, PictureWindowPrivateKey))
#define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, PictureWindowPrivateKey, p)
diff --git a/xorg-server/render/render.c b/xorg-server/render/render.c index 600ffc645..cbd70cc7e 100644 --- a/xorg-server/render/render.c +++ b/xorg-server/render/render.c @@ -210,8 +210,8 @@ int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = { };
int RenderErrBase;
-static int RenderClientPrivateKeyIndex;
-DevPrivateKey RenderClientPrivateKey = &RenderClientPrivateKeyIndex;
+static DevPrivateKeyRec RenderClientPrivateKeyRec;
+#define RenderClientPrivateKey (&RenderClientPrivateKeyRec )
typedef struct _RenderClient {
int major_version;
@@ -246,7 +246,7 @@ RenderExtensionInit (void) return;
if (!PictureFinishInit ())
return;
- if (!dixRequestPrivate(RenderClientPrivateKey, sizeof(RenderClientRec)))
+ if (!dixRegisterPrivateKey(&RenderClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(RenderClientRec)))
return;
if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0))
return;
@@ -852,7 +852,7 @@ ProcRenderTriStrip (ClientPtr client) pFormat = 0;
npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq));
if (npoints & 4)
- return(BadLength);
+ return BadLength;
npoints >>= 3;
if (npoints >= 3)
CompositeTriStrip (stuff->op, pSrc, pDst, pFormat,
@@ -892,7 +892,7 @@ ProcRenderTriFan (ClientPtr client) pFormat = 0;
npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq));
if (npoints & 4)
- return(BadLength);
+ return BadLength;
npoints >>= 3;
if (npoints >= 3)
CompositeTriFan (stuff->op, pSrc, pDst, pFormat,
@@ -1461,7 +1461,7 @@ ProcRenderFillRectangles (ClientPtr client) things = (client->req_len << 2) - sizeof(xRenderFillRectanglesReq);
if (things & 4)
- return(BadLength);
+ return BadLength;
things >>= 3;
CompositeRects (stuff->op,
@@ -1530,10 +1530,10 @@ ProcRenderCreateCursor (ClientPtr client) return BadAlloc;
if ( stuff->x > width
|| stuff->y > height )
- return (BadMatch);
+ return BadMatch;
argbbits = malloc(width * height * sizeof (CARD32));
if (!argbbits)
- return (BadAlloc);
+ return BadAlloc;
stride = BitmapBytePad(width);
nbytes_mono = stride*height;
@@ -1541,14 +1541,14 @@ ProcRenderCreateCursor (ClientPtr client) if (!srcbits)
{
free(argbbits);
- return (BadAlloc);
+ return BadAlloc;
}
mskbits = calloc(1, nbytes_mono);
if (!mskbits)
{
free(argbbits);
free(srcbits);
- return (BadAlloc);
+ return BadAlloc;
}
if (pSrc->format == PICT_a8r8g8b8)
@@ -1570,7 +1570,7 @@ ProcRenderCreateCursor (ClientPtr client) free(argbbits);
free(srcbits);
free(mskbits);
- return (BadImplementation);
+ return BadImplementation;
}
pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 32,
CREATE_PIXMAP_USAGE_SCRATCH);
@@ -1579,7 +1579,7 @@ ProcRenderCreateCursor (ClientPtr client) free(argbbits);
free(srcbits);
free(mskbits);
- return (BadAlloc);
+ return BadAlloc;
}
pPicture = CreatePicture (0, &pPixmap->drawable, pFormat, 0, 0,
client, &error);
@@ -2681,7 +2681,7 @@ PanoramiXRenderCreatePicture (ClientPtr client) newPict->info[0].id = stuff->pid;
if (refDraw->type == XRT_WINDOW &&
- stuff->drawable == WindowTable[0]->drawable.id)
+ stuff->drawable == screenInfo.screens[0]->root->drawable.id)
{
newPict->u.pict.root = TRUE;
}
@@ -2703,7 +2703,7 @@ PanoramiXRenderCreatePicture (ClientPtr client) else
free(newPict);
- return (result);
+ return result;
}
static int
@@ -2723,7 +2723,7 @@ PanoramiXRenderChangePicture (ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
static int
@@ -2743,7 +2743,7 @@ PanoramiXRenderSetPictureClipRectangles (ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
static int
@@ -2763,7 +2763,7 @@ PanoramiXRenderSetPictureTransform (ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
static int
@@ -2783,7 +2783,7 @@ PanoramiXRenderSetPictureFilter (ClientPtr client) if(result != Success) break;
}
- return (result);
+ return result;
}
static int
@@ -2809,7 +2809,7 @@ PanoramiXRenderFreePicture (ClientPtr client) /* Since ProcRenderFreePicture is using FreeResource, it will free
our resource for us on the last pass through the loop above */
- return (result);
+ return result;
}
static int
@@ -2832,22 +2832,22 @@ PanoramiXRenderComposite (ClientPtr client) stuff->src = src->info[j].id;
if (src->u.pict.root)
{
- stuff->xSrc = orig.xSrc - panoramiXdataPtr[j].x;
- stuff->ySrc = orig.ySrc - panoramiXdataPtr[j].y;
+ stuff->xSrc = orig.xSrc - screenInfo.screens[j]->x;
+ stuff->ySrc = orig.ySrc - screenInfo.screens[j]->y;
}
stuff->dst = dst->info[j].id;
if (dst->u.pict.root)
{
- stuff->xDst = orig.xDst - panoramiXdataPtr[j].x;
- stuff->yDst = orig.yDst - panoramiXdataPtr[j].y;
+ stuff->xDst = orig.xDst - screenInfo.screens[j]->x;
+ stuff->yDst = orig.yDst - screenInfo.screens[j]->y;
}
if (msk)
{
stuff->mask = msk->info[j].id;
if (msk->u.pict.root)
{
- stuff->xMask = orig.xMask - panoramiXdataPtr[j].x;
- stuff->yMask = orig.yMask - panoramiXdataPtr[j].y;
+ stuff->xMask = orig.xMask - screenInfo.screens[j]->x;
+ stuff->yMask = orig.yMask - screenInfo.screens[j]->y;
}
}
result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client);
@@ -2881,14 +2881,14 @@ PanoramiXRenderCompositeGlyphs (ClientPtr client) stuff->src = src->info[j].id;
if (src->u.pict.root)
{
- stuff->xSrc = xSrc - panoramiXdataPtr[j].x;
- stuff->ySrc = ySrc - panoramiXdataPtr[j].y;
+ stuff->xSrc = xSrc - screenInfo.screens[j]->x;
+ stuff->ySrc = ySrc - screenInfo.screens[j]->y;
}
stuff->dst = dst->info[j].id;
if (dst->u.pict.root)
{
- elt->deltax = origElt.deltax - panoramiXdataPtr[j].x;
- elt->deltay = origElt.deltay - panoramiXdataPtr[j].y;
+ elt->deltax = origElt.deltax - screenInfo.screens[j]->x;
+ elt->deltay = origElt.deltay - screenInfo.screens[j]->y;
}
result = (*PanoramiXSaveRenderVector[stuff->renderReqType]) (client);
if(result != Success) break;
@@ -2918,8 +2918,8 @@ PanoramiXRenderFillRectangles (ClientPtr client) if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root)
{
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
xRectangle *rects = (xRectangle *) (stuff + 1);
@@ -2966,8 +2966,8 @@ PanoramiXRenderTrapezoids(ClientPtr client) FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
xTrapezoid *trap = (xTrapezoid *) (stuff + 1);
@@ -3026,8 +3026,8 @@ PanoramiXRenderTriangles(ClientPtr client) FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
xTriangle *tri = (xTriangle *) (stuff + 1);
@@ -3082,8 +3082,8 @@ PanoramiXRenderTriStrip(ClientPtr client) FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
xPointFixed *fixed = (xPointFixed *) (stuff + 1);
@@ -3134,8 +3134,8 @@ PanoramiXRenderTriFan(ClientPtr client) FOR_NSCREENS_FORWARD(j) {
if (j) memcpy (stuff + 1, extra, extra_len);
if (dst->u.pict.root) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
+ int x_off = screenInfo.screens[j]->x;
+ int y_off = screenInfo.screens[j]->y;
if(x_off || y_off) {
xPointFixed *fixed = (xPointFixed *) (stuff + 1);
@@ -3188,8 +3188,8 @@ PanoramiXRenderAddTraps (ClientPtr client) if (picture->u.pict.root)
{
- stuff->xOff = x_off + panoramiXdataPtr[j].x;
- stuff->yOff = y_off + panoramiXdataPtr[j].y;
+ stuff->xOff = x_off + screenInfo.screens[j]->x;
+ stuff->yOff = y_off + screenInfo.screens[j]->y;
}
result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client);
if(result != Success) break;
diff --git a/xorg-server/test/input.c b/xorg-server/test/input.c index 1271ee683..42435a9db 100644 --- a/xorg-server/test/input.c +++ b/xorg-server/test/input.c @@ -801,14 +801,34 @@ static void cmp_attr_fields(InputAttributes *attr1, } else
g_assert(attr2->device == NULL);
+ if (attr1->pnp_id != NULL)
+ {
+ g_assert(attr1->pnp_id != attr2->pnp_id);
+ g_assert(strcmp(attr1->pnp_id, attr2->pnp_id) == 0);
+ } else
+ g_assert(attr2->pnp_id == NULL);
+
+ if (attr1->usb_id != NULL)
+ {
+ g_assert(attr1->usb_id != attr2->usb_id);
+ g_assert(strcmp(attr1->usb_id, attr2->usb_id) == 0);
+ } else
+ g_assert(attr2->usb_id == NULL);
+
tags1 = attr1->tags;
tags2 = attr2->tags;
+
+ /* if we don't have any tags, skip the tag checking bits */
if (!tags1)
{
g_assert(!tags2);
return;
}
+ /* Don't lug around empty arrays */
+ g_assert(*tags1);
+ g_assert(*tags2);
+
/* check for identical content, but duplicated */
while (*tags1)
{
@@ -818,6 +838,7 @@ static void cmp_attr_fields(InputAttributes *attr1, tags2++;
}
+ /* ensure tags1 and tags2 have the same no of elements */
g_assert(!*tags2);
/* check for not sharing memory */
@@ -842,7 +863,7 @@ static void dix_input_attributes(void) g_assert(!new);
new = DuplicateInputAttributes(&orig);
- g_assert(memcpy(&orig, new, sizeof(InputAttributes)));
+ g_assert(memcmp(&orig, new, sizeof(InputAttributes)) == 0);
orig.product = "product name";
new = DuplicateInputAttributes(&orig);
@@ -859,6 +880,16 @@ static void dix_input_attributes(void) cmp_attr_fields(&orig, new);
FreeInputAttributes(new);
+ orig.pnp_id = "PnPID";
+ new = DuplicateInputAttributes(&orig);
+ cmp_attr_fields(&orig, new);
+ FreeInputAttributes(new);
+
+ orig.usb_id = "USBID";
+ new = DuplicateInputAttributes(&orig);
+ cmp_attr_fields(&orig, new);
+ FreeInputAttributes(new);
+
orig.flags = 0xF0;
new = DuplicateInputAttributes(&orig);
cmp_attr_fields(&orig, new);
diff --git a/xorg-server/test/xi2/protocol-common.c b/xorg-server/test/xi2/protocol-common.c index a06c5a913..d396a233d 100644 --- a/xorg-server/test/xi2/protocol-common.c +++ b/xorg-server/test/xi2/protocol-common.c @@ -27,6 +27,7 @@ #include <stdint.h>
#include "extinit.h" /* for XInputExtensionInit */
+#include "exglobals.h"
#include <glib.h>
#include "protocol-common.h"
@@ -107,7 +108,6 @@ ClientRec init_client(int len, void *data) /* we store the privates now and reassign it after the memset. this way
* we can share them across multiple test runs and don't have to worry
* about freeing them after each test run. */
- PrivateRec *privates = client.devPrivates;
client.index = CLIENT_INDEX;
client.clientAsMask = CLIENT_MASK;
@@ -115,7 +115,7 @@ ClientRec init_client(int len, void *data) client.req_len = len;
client.requestBuffer = data;
- client.devPrivates = privates;
+ dixAllocatePrivates(&client.devPrivates, PRIVATE_CLIENT);
return client;
}
@@ -136,6 +136,9 @@ void init_window(WindowPtr window, WindowPtr parent, int id) g_assert(window->optional);
}
+extern DevPrivateKeyRec miPointerScreenKeyRec;
+extern DevPrivateKeyRec miPointerPrivKeyRec;
+
/* Needed for the screen setup, otherwise we crash during sprite initialization */
static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE; }
static Bool set_cursor_pos(DeviceIntPtr dev, ScreenPtr screen, int x, int y, Bool event) { return TRUE; }
@@ -153,7 +156,12 @@ void init_simple(void) dixResetPrivates();
InitAtoms();
+ XkbInitPrivates();
+ dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec));
+ dixRegisterPrivateKey(&miPointerScreenKeyRec, PRIVATE_SCREEN, 0);
+ dixRegisterPrivateKey(&miPointerPrivKeyRec, PRIVATE_DEVICE, 0);
XInputExtensionInit();
+
init_window(&root, NULL, ROOT_WINDOW_ID);
init_window(&window, &root, CLIENT_WINDOW_ID);
diff --git a/xorg-server/test/xtest.c b/xorg-server/test/xtest.c index cc1188d7d..cd8f23bff 100644 --- a/xorg-server/test/xtest.c +++ b/xorg-server/test/xtest.c @@ -1,115 +1,118 @@ -/** - * Copyright © 2009 Red Hat, Inc. - * - * 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 (including the next - * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif -#include <stdint.h> -#include <X11/Xatom.h> -#include "input.h" -#include "inputstr.h" -#include "scrnintstr.h" -#include "exevents.h" -#include "xserver-properties.h" - -#include <glib.h> - -/** - */ - -/* from Xext/xtest.c */ -extern DeviceIntPtr xtestpointer, xtestkeyboard; - -/* Needed for the screen setup, otherwise we crash during sprite initialization */ -static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE; } - -static void xtest_init_devices(void) -{ - ScreenRec screen; - - /* random stuff that needs initialization */ - memset(&screen, 0, sizeof(screen)); - screenInfo.numScreens = 1; - screenInfo.screens[0] = &screen; - screen.myNum = 0; - screen.id = 100; - screen.width = 640; - screen.height = 480; - screen.DeviceCursorInitialize = device_cursor_init; - dixResetPrivates(); - InitAtoms(); - - /* this also inits the xtest devices */ - InitCoreDevices(); - - g_assert(xtestpointer); - g_assert(xtestkeyboard); - g_assert(IsXTestDevice(xtestpointer, NULL)); - g_assert(IsXTestDevice(xtestkeyboard, NULL)); - g_assert(IsXTestDevice(xtestpointer, inputInfo.pointer)); - g_assert(IsXTestDevice(xtestkeyboard, inputInfo.keyboard)); - g_assert(GetXTestDevice(inputInfo.pointer) == xtestpointer); - g_assert(GetXTestDevice(inputInfo.keyboard) == xtestkeyboard); -} - -/** - * Each xtest devices has a property attached marking it. This property - * cannot be changed. - */ -static void xtest_properties(void) -{ - int rc; - char value = 1; - XIPropertyValuePtr prop; - Atom xtest_prop = XIGetKnownProperty(XI_PROP_XTEST_DEVICE); - - rc = XIGetDeviceProperty(xtestpointer, xtest_prop, &prop); - g_assert(rc == Success); - g_assert(prop); - - rc = XIGetDeviceProperty(xtestkeyboard, xtest_prop, &prop); - g_assert(rc == Success); - g_assert(prop != NULL); - - rc = XIChangeDeviceProperty(xtestpointer, xtest_prop, - XA_INTEGER, 8, PropModeReplace, 1, &value, FALSE); - g_assert(rc == BadAccess); - rc = XIChangeDeviceProperty(xtestkeyboard, xtest_prop, - XA_INTEGER, 8, PropModeReplace, 1, &value, FALSE); - g_assert(rc == BadAccess); -} - - - -int main(int argc, char** argv) -{ - g_test_init(&argc, &argv,NULL); - g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id="); - - g_test_add_func("/dix/xtest/init", xtest_init_devices); - g_test_add_func("/dix/xtest/properties", xtest_properties); - - return g_test_run(); -} - - +/**
+ * Copyright © 2009 Red Hat, Inc.
+ *
+ * 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 (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+#include <stdint.h>
+#include <X11/Xatom.h>
+#include "input.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "exevents.h"
+#include "xkbsrv.h"
+#include "xserver-properties.h"
+
+#include <glib.h>
+
+/**
+ */
+
+/* from Xext/xtest.c */
+extern DeviceIntPtr xtestpointer, xtestkeyboard;
+
+/* Needed for the screen setup, otherwise we crash during sprite initialization */
+static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE; }
+
+static void xtest_init_devices(void)
+{
+ ScreenRec screen;
+
+ /* random stuff that needs initialization */
+ memset(&screen, 0, sizeof(screen));
+ screenInfo.numScreens = 1;
+ screenInfo.screens[0] = &screen;
+ screen.myNum = 0;
+ screen.id = 100;
+ screen.width = 640;
+ screen.height = 480;
+ screen.DeviceCursorInitialize = device_cursor_init;
+ dixResetPrivates();
+ InitAtoms();
+
+ XkbInitPrivates();
+
+ /* this also inits the xtest devices */
+ InitCoreDevices();
+
+ g_assert(xtestpointer);
+ g_assert(xtestkeyboard);
+ g_assert(IsXTestDevice(xtestpointer, NULL));
+ g_assert(IsXTestDevice(xtestkeyboard, NULL));
+ g_assert(IsXTestDevice(xtestpointer, inputInfo.pointer));
+ g_assert(IsXTestDevice(xtestkeyboard, inputInfo.keyboard));
+ g_assert(GetXTestDevice(inputInfo.pointer) == xtestpointer);
+ g_assert(GetXTestDevice(inputInfo.keyboard) == xtestkeyboard);
+}
+
+/**
+ * Each xtest devices has a property attached marking it. This property
+ * cannot be changed.
+ */
+static void xtest_properties(void)
+{
+ int rc;
+ char value = 1;
+ XIPropertyValuePtr prop;
+ Atom xtest_prop = XIGetKnownProperty(XI_PROP_XTEST_DEVICE);
+
+ rc = XIGetDeviceProperty(xtestpointer, xtest_prop, &prop);
+ g_assert(rc == Success);
+ g_assert(prop);
+
+ rc = XIGetDeviceProperty(xtestkeyboard, xtest_prop, &prop);
+ g_assert(rc == Success);
+ g_assert(prop != NULL);
+
+ rc = XIChangeDeviceProperty(xtestpointer, xtest_prop,
+ XA_INTEGER, 8, PropModeReplace, 1, &value, FALSE);
+ g_assert(rc == BadAccess);
+ rc = XIChangeDeviceProperty(xtestkeyboard, xtest_prop,
+ XA_INTEGER, 8, PropModeReplace, 1, &value, FALSE);
+ g_assert(rc == BadAccess);
+}
+
+
+
+int main(int argc, char** argv)
+{
+ g_test_init(&argc, &argv,NULL);
+ g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id=");
+
+ g_test_add_func("/dix/xtest/init", xtest_init_devices);
+ g_test_add_func("/dix/xtest/properties", xtest_properties);
+
+ return g_test_run();
+}
+
+
diff --git a/xorg-server/xfixes/cursor.c b/xorg-server/xfixes/cursor.c index c2c489e3f..bc3b321e0 100644 --- a/xorg-server/xfixes/cursor.c +++ b/xorg-server/xfixes/cursor.c @@ -61,8 +61,8 @@ static RESTYPE CursorHideCountType; static RESTYPE CursorWindowType;
static CursorPtr CursorCurrent[MAXDEVICES];
-static int CursorScreenPrivateKeyIndex;
-static DevPrivateKey CursorScreenPrivateKey = &CursorScreenPrivateKeyIndex;
+static DevPrivateKeyRec CursorScreenPrivateKeyRec;
+#define CursorScreenPrivateKey (&CursorScreenPrivateKeyRec)
static void deleteCursorHideCountsForScreen (ScreenPtr pScreen);
@@ -271,7 +271,7 @@ ProcXFixesSelectCursorInput (ClientPtr client) if (stuff->eventMask & ~CursorAllEvents)
{
client->errorValue = stuff->eventMask;
- return( BadValue );
+ return BadValue;
}
return XFixesSelectCursorInput (client, pWin, stuff->eventMask);
}
@@ -692,7 +692,7 @@ ReplaceCursor (CursorPtr pCursor, }
}
/* this "knows" that WindowHasNewCursor doesn't depend on it's argument */
- WindowHasNewCursor (WindowTable[0]);
+ WindowHasNewCursor (screenInfo.screens[0]->root);
}
static Bool
@@ -734,7 +734,7 @@ static Bool TestForCursorName (CursorPtr pCursor, pointer closure)
{
Atom *pName = closure;
- return (pCursor->name == *pName);
+ return pCursor->name == *pName;
}
int
@@ -1039,6 +1039,9 @@ XFixesCursorInit (void) if (party_like_its_1989)
CursorVisible = EnableCursor;
+ if (!dixRegisterPrivateKey(&CursorScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
for (i = 0; i < screenInfo.numScreens; i++)
{
ScreenPtr pScreen = screenInfo.screens[i];
diff --git a/xorg-server/xfixes/region.c b/xorg-server/xfixes/region.c index 7b1c40b15..0461ded11 100644 --- a/xorg-server/xfixes/region.c +++ b/xorg-server/xfixes/region.c @@ -39,20 +39,20 @@ RegionResFree (pointer data, XID id) {
RegionPtr pRegion = (RegionPtr) data;
- REGION_DESTROY (0, pRegion);
+ RegionDestroy(pRegion);
return Success;
}
RegionPtr
XFixesRegionCopy (RegionPtr pRegion)
{
- RegionPtr pNew = REGION_CREATE (0, REGION_EXTENTS(0, pRegion),
- REGION_NUM_RECTS(pRegion));
+ RegionPtr pNew = RegionCreate(RegionExtents(pRegion),
+ RegionNumRects(pRegion));
if (!pNew)
return 0;
- if (!REGION_COPY (0, pNew, pRegion))
+ if (!RegionCopy(pNew, pRegion))
{
- REGION_DESTROY (0, pNew);
+ RegionDestroy(pNew);
return 0;
}
return pNew;
@@ -63,7 +63,7 @@ XFixesRegionInit (void) {
RegionResType = CreateNewResourceType(RegionResFree, "XFixesRegion");
- return (RegionResType != 0);
+ return RegionResType != 0;
}
int
@@ -81,7 +81,7 @@ ProcXFixesCreateRegion (ClientPtr client) return BadLength;
things >>= 3;
- pRegion = RECTS_TO_REGION(0, things, (xRectangle *) (stuff + 1), CT_UNSORTED);
+ pRegion = RegionFromRects(things, (xRectangle *) (stuff + 1), CT_UNSORTED);
if (!pRegion)
return BadAlloc;
if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
@@ -124,7 +124,7 @@ ProcXFixesCreateRegionFromBitmap (ClientPtr client) if (pPixmap->drawable.depth != 1)
return BadMatch;
- pRegion = BITMAP_TO_REGION(pPixmap->drawable.pScreen, pPixmap);
+ pRegion = BitmapToRegion(pPixmap->drawable.pScreen, pPixmap);
if (!pRegion)
return BadAlloc;
@@ -227,7 +227,7 @@ ProcXFixesCreateRegionFromGC (ClientPtr client) switch (pGC->clientClipType) {
case CT_PIXMAP:
- pRegion = BITMAP_TO_REGION(pGC->pScreen, (PixmapPtr) pGC->clientClip);
+ pRegion = BitmapToRegion(pGC->pScreen, (PixmapPtr) pGC->clientClip);
if (!pRegion)
return BadAlloc;
break;
@@ -274,7 +274,7 @@ ProcXFixesCreateRegionFromPicture (ClientPtr client) switch (pPicture->clientClipType) {
case CT_PIXMAP:
- pRegion = BITMAP_TO_REGION(pPicture->pDrawable->pScreen,
+ pRegion = BitmapToRegion(pPicture->pDrawable->pScreen,
(PixmapPtr) pPicture->clientClip);
if (!pRegion)
return BadAlloc;
@@ -346,15 +346,15 @@ ProcXFixesSetRegion (ClientPtr client) return BadLength;
things >>= 3;
- pNew = RECTS_TO_REGION(0, things, (xRectangle *) (stuff + 1), CT_UNSORTED);
+ pNew = RegionFromRects(things, (xRectangle *) (stuff + 1), CT_UNSORTED);
if (!pNew)
return BadAlloc;
- if (!REGION_COPY (0, pRegion, pNew))
+ if (!RegionCopy(pRegion, pNew))
{
- REGION_DESTROY (0, pNew);
+ RegionDestroy(pNew);
return BadAlloc;
}
- REGION_DESTROY (0, pNew);
+ RegionDestroy(pNew);
return Success;
}
@@ -380,7 +380,7 @@ ProcXFixesCopyRegion (ClientPtr client) VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
- if (!REGION_COPY(pScreen, pDestination, pSource))
+ if (!RegionCopy(pDestination, pSource))
return BadAlloc;
return Success;
@@ -412,15 +412,15 @@ ProcXFixesCombineRegion (ClientPtr client) switch (stuff->xfixesReqType) {
case X_XFixesUnionRegion:
- if (!REGION_UNION (0, pDestination, pSource1, pSource2))
+ if (!RegionUnion(pDestination, pSource1, pSource2))
return BadAlloc;
break;
case X_XFixesIntersectRegion:
- if (!REGION_INTERSECT (0, pDestination, pSource1, pSource2))
+ if (!RegionIntersect(pDestination, pSource1, pSource2))
return BadAlloc;
break;
case X_XFixesSubtractRegion:
- if (!REGION_SUBTRACT (0, pDestination, pSource1, pSource2))
+ if (!RegionSubtract(pDestination, pSource1, pSource2))
return BadAlloc;
break;
}
@@ -466,7 +466,7 @@ ProcXFixesInvertRegion (ClientPtr client) else
bounds.y2 = stuff->y + stuff->height;
- if (!REGION_INVERSE(0, pDestination, pSource, &bounds))
+ if (!RegionInverse(pDestination, pSource, &bounds))
return BadAlloc;
return Success;
@@ -498,7 +498,7 @@ ProcXFixesTranslateRegion (ClientPtr client) REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
- REGION_TRANSLATE(pScreen, pRegion, stuff->dx, stuff->dy);
+ RegionTranslate(pRegion, stuff->dx, stuff->dy);
return Success;
}
@@ -526,7 +526,7 @@ ProcXFixesRegionExtents (ClientPtr client) VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
- REGION_RESET (0, pDestination, REGION_EXTENTS (0, pSource));
+ RegionReset(pDestination, RegionExtents(pSource));
return Success;
}
@@ -558,9 +558,9 @@ ProcXFixesFetchRegion (ClientPtr client) REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
VERIFY_REGION(pRegion, stuff->region, client, DixReadAccess);
- pExtent = REGION_EXTENTS (0, pRegion);
- pBox = REGION_RECTS (pRegion);
- nBox = REGION_NUM_RECTS (pRegion);
+ pExtent = RegionExtents(pRegion);
+ pBox = RegionRects (pRegion);
+ nBox = RegionNumRects (pRegion);
reply = malloc(sizeof (xXFixesFetchRegionReply) +
nBox * sizeof (xRectangle));
@@ -663,7 +663,6 @@ int ProcXFixesSetWindowShapeRegion (ClientPtr client)
{
WindowPtr pWin;
- ScreenPtr pScreen;
RegionPtr pRegion;
RegionPtr *pDestRegion;
int rc;
@@ -678,7 +677,6 @@ ProcXFixesSetWindowShapeRegion (ClientPtr client) return rc;
}
VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixWriteAccess);
- pScreen = pWin->drawable.pScreen;
switch (stuff->destKind) {
case ShapeBounding:
case ShapeClip:
@@ -708,7 +706,7 @@ ProcXFixesSetWindowShapeRegion (ClientPtr client) break;
}
if (stuff->xOff || stuff->yOff)
- REGION_TRANSLATE (0, pRegion, stuff->xOff, stuff->yOff);
+ RegionTranslate(pRegion, stuff->xOff, stuff->yOff);
}
else
{
@@ -731,9 +729,9 @@ ProcXFixesSetWindowShapeRegion (ClientPtr client) pDestRegion = &pRegion; /* a NULL region pointer */
}
if (*pDestRegion)
- REGION_DESTROY(pScreen, *pDestRegion);
+ RegionDestroy(*pDestRegion);
*pDestRegion = pRegion;
- (*pScreen->SetShape) (pWin);
+ (*pWin->drawable.pScreen->SetShape) (pWin, stuff->destKind);
SendShapeNotify (pWin, stuff->destKind);
return Success;
}
@@ -801,8 +799,8 @@ ProcXFixesExpandRegion (ClientPtr client) VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
- nBoxes = REGION_NUM_RECTS(pSource);
- pSrc = REGION_RECTS(pSource);
+ nBoxes = RegionNumRects(pSource);
+ pSrc = RegionRects(pSource);
if (nBoxes)
{
pTmp = malloc(nBoxes * sizeof (BoxRec));
@@ -815,12 +813,12 @@ ProcXFixesExpandRegion (ClientPtr client) pTmp[i].y1 = pSrc[i].y1 - stuff->top;
pTmp[i].y2 = pSrc[i].y2 + stuff->bottom;
}
- REGION_EMPTY (pScreen, pDestination);
+ RegionEmpty(pDestination);
for (i = 0; i < nBoxes; i++)
{
RegionRec r;
- REGION_INIT (pScreen, &r, &pTmp[i], 0);
- REGION_UNION (pScreen, pDestination, pDestination, &r);
+ RegionInit(&r, &pTmp[i], 0);
+ RegionUnion(pDestination, pDestination, &r);
}
free(pTmp);
}
diff --git a/xorg-server/xfixes/saveset.c b/xorg-server/xfixes/saveset.c index 72bbb4952..dcd66792a 100644 --- a/xorg-server/xfixes/saveset.c +++ b/xorg-server/xfixes/saveset.c @@ -43,17 +43,17 @@ ProcXFixesChangeSaveSet(ClientPtr client) if ((stuff->mode != SetModeInsert) && (stuff->mode != SetModeDelete))
{
client->errorValue = stuff->mode;
- return( BadValue );
+ return BadValue;
}
if ((stuff->target != SaveSetNearest) && (stuff->target != SaveSetRoot))
{
client->errorValue = stuff->target;
- return( BadValue );
+ return BadValue;
}
if ((stuff->map != SaveSetMap) && (stuff->map != SaveSetUnmap))
{
client->errorValue = stuff->map;
- return( BadValue );
+ return BadValue;
}
toRoot = (stuff->target == SaveSetRoot);
map = (stuff->map == SaveSetMap);
diff --git a/xorg-server/xfixes/select.c b/xorg-server/xfixes/select.c index 00b693f9d..1343ea737 100644 --- a/xorg-server/xfixes/select.c +++ b/xorg-server/xfixes/select.c @@ -211,7 +211,7 @@ ProcXFixesSelectSelectionInput (ClientPtr client) if (stuff->eventMask & ~SelectionAllEvents)
{
client->errorValue = stuff->eventMask;
- return( BadValue );
+ return BadValue;
}
return XFixesSelectSelectionInput (client, stuff->selection,
pWin, stuff->eventMask);
diff --git a/xorg-server/xfixes/xfixes.c b/xorg-server/xfixes/xfixes.c index 36eda56a5..67e616417 100644 --- a/xorg-server/xfixes/xfixes.c +++ b/xorg-server/xfixes/xfixes.c @@ -56,8 +56,8 @@ static unsigned char XFixesReqCode; int XFixesEventBase;
int XFixesErrorBase;
-static int XFixesClientPrivateKeyIndex;
-static DevPrivateKey XFixesClientPrivateKey = &XFixesClientPrivateKeyIndex;
+static DevPrivateKeyRec XFixesClientPrivateKeyRec;
+#define XFixesClientPrivateKey (&XFixesClientPrivateKeyRec)
static int
ProcXFixesQueryVersion(ClientPtr client)
@@ -241,7 +241,7 @@ XFixesExtensionInit(void) {
ExtensionEntry *extEntry;
- if (!dixRequestPrivate(XFixesClientPrivateKey, sizeof (XFixesClientRec)))
+ if (!dixRegisterPrivateKey(&XFixesClientPrivateKeyRec, PRIVATE_CLIENT, sizeof (XFixesClientRec)))
return;
if (!AddCallback (&ClientStateCallback, XFixesClientCallback, 0))
return;
diff --git a/xorg-server/xkb/XKBAlloc.c b/xorg-server/xkb/XKBAlloc.c index 4d342a0fa..9dab41c5e 100644 --- a/xorg-server/xkb/XKBAlloc.c +++ b/xorg-server/xkb/XKBAlloc.c @@ -82,7 +82,7 @@ XkbSymInterpretRec *prev_interpret; }
compat->size_si= nSI;
compat->num_si= 0;
- bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
+ memset((char *)&compat->groups[0], 0, XkbNumKbdGroups*sizeof(XkbModsRec));
xkb->compat= compat;
return Success;
}
@@ -99,7 +99,7 @@ register XkbCompatMapPtr compat; if (freeMap)
which= XkbAllCompatMask;
if (which&XkbGroupCompatMask)
- bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
+ memset((char *)&compat->groups[0], 0, XkbNumKbdGroups*sizeof(XkbModsRec));
if (which&XkbSymInterpMask) {
if ((compat->sym_interpret)&&(compat->size_si>0))
free(compat->sym_interpret);
diff --git a/xorg-server/xkb/XKBGAlloc.c b/xorg-server/xkb/XKBGAlloc.c index 4dc3e7017..b5c9b8446 100644 --- a/xorg-server/xkb/XKBGAlloc.c +++ b/xorg-server/xkb/XKBGAlloc.c @@ -183,8 +183,7 @@ _XkbClearColor(char *color_in) {
XkbColorPtr color= (XkbColorPtr)color_in;
- if (color->spec)
- free(color->spec);
+ free(color->spec);
return;
}
@@ -478,7 +477,7 @@ _XkbGeomAlloc( void ** old, if (*num>0) {
char *tmp= (char *)(*old);
- bzero(&tmp[sz_elem*(*num)],(num_new*sz_elem));
+ memset(&tmp[sz_elem*(*num)], 0, (num_new*sz_elem));
}
return Success;
}
@@ -663,8 +662,7 @@ register XkbPropertyPtr prop; return NULL;
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
- if (prop->value)
- free(prop->value);
+ free(prop->value);
prop->value= malloc(strlen(value)+1);
if (prop->value)
strcpy(prop->value,value);
@@ -701,7 +699,7 @@ register XkbKeyAliasPtr alias; return NULL;
for (i=0,alias=geom->key_aliases;i<geom->num_key_aliases;i++,alias++) {
if (strncmp(alias->alias,aliasStr,XkbKeyNameLength)==0) {
- bzero(alias->real,XkbKeyNameLength);
+ memset(alias->real, 0, XkbKeyNameLength);
strncpy(alias->real,realStr,XkbKeyNameLength);
return alias;
}
@@ -711,7 +709,7 @@ register XkbKeyAliasPtr alias; return NULL;
}
alias= &geom->key_aliases[geom->num_key_aliases];
- bzero(alias,sizeof(XkbKeyAliasRec));
+ memset(alias, 0, sizeof(XkbKeyAliasRec));
strncpy(alias->alias,aliasStr,XkbKeyNameLength);
strncpy(alias->real,realStr,XkbKeyNameLength);
geom->num_key_aliases++;
@@ -758,7 +756,7 @@ XkbOutlinePtr outline; return NULL;
}
outline= &shape->outlines[shape->num_outlines];
- bzero(outline,sizeof(XkbOutlineRec));
+ memset(outline, 0, sizeof(XkbOutlineRec));
if ((sz_points>0)&&(_XkbAllocPoints(outline,sz_points)!=Success))
return NULL;
shape->num_outlines++;
@@ -783,7 +781,7 @@ register int i; (_XkbAllocShapes(geom,1)!=Success))
return NULL;
shape= &geom->shapes[geom->num_shapes];
- bzero(shape,sizeof(XkbShapeRec));
+ memset(shape, 0, sizeof(XkbShapeRec));
if ((sz_outlines>0)&&(_XkbAllocOutlines(shape,sz_outlines)!=Success))
return NULL;
shape->name= name;
@@ -801,7 +799,7 @@ XkbKeyPtr key; if ((row->num_keys>=row->sz_keys)&&(_XkbAllocKeys(row,1)!=Success))
return NULL;
key= &row->keys[row->num_keys++];
- bzero(key,sizeof(XkbKeyRec));
+ memset(key, 0, sizeof(XkbKeyRec));
return key;
}
@@ -816,7 +814,7 @@ XkbRowPtr row; (_XkbAllocRows(section,1)!=Success))
return NULL;
row= §ion->rows[section->num_rows];
- bzero(row,sizeof(XkbRowRec));
+ memset(row, 0, sizeof(XkbRowRec));
if ((sz_keys>0)&&(_XkbAllocKeys(row,sz_keys)!=Success))
return NULL;
section->num_rows++;
@@ -896,7 +894,7 @@ register int i,nDoodads; return NULL;
doodad= &geom->doodads[geom->num_doodads++];
}
- bzero(doodad,sizeof(XkbDoodadRec));
+ memset(doodad, 0, sizeof(XkbDoodadRec));
doodad->any.name= name;
return doodad;
}
@@ -960,7 +958,7 @@ XkbOverlayRowPtr row; (_XkbAllocOverlayRows(overlay,1)!=Success))
return NULL;
row= &overlay->rows[overlay->num_rows];
- bzero(row,sizeof(XkbOverlayRowRec));
+ memset(row, 0, sizeof(XkbOverlayRowRec));
if ((sz_keys>0)&&(_XkbAllocOverlayKeys(row,sz_keys)!=Success))
return NULL;
row->row_under= row_under;
diff --git a/xorg-server/xkb/XKBMAlloc.c b/xorg-server/xkb/XKBMAlloc.c index 34e52835d..0bd7b5e01 100644 --- a/xorg-server/xkb/XKBMAlloc.c +++ b/xorg-server/xkb/XKBMAlloc.c @@ -84,7 +84,7 @@ XkbClientMapPtr map; return BadAlloc;
}
map->size_types= nTotalTypes;
- bzero(&map->types[map->num_types],
+ memset(&map->types[map->num_types], 0,
((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec)));
}
}
@@ -177,7 +177,7 @@ XkbServerMapPtr map; return BadAlloc;
}
map->size_acts= need;
- bzero(&map->acts[map->num_acts],
+ memset(&map->acts[map->num_acts], 0,
((map->size_acts-map->num_acts)*sizeof(XkbAction)));
}
if (map->key_acts==NULL) {
@@ -312,8 +312,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; if ((map_count>type->map_count)||(type->map==NULL))
type->map = realloc(type->map,map_count * sizeof(XkbKTMapEntryRec));
if (!type->map) {
- if (prev_map)
- free(prev_map);
+ free(prev_map);
return BadAlloc;
}
if (want_preserve) {
@@ -324,8 +323,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; map_count * sizeof(XkbModsRec));
}
if (!type->preserve) {
- if (prev_preserve)
- free(prev_preserve);
+ free(prev_preserve);
return BadAlloc;
}
}
@@ -342,8 +340,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; type->level_names = realloc(type->level_names,
new_num_lvls * sizeof(Atom));
if (!type->level_names) {
- if (prev_level_names)
- free(prev_level_names);
+ free(prev_level_names);
return BadAlloc;
}
}
@@ -368,7 +365,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; * The possibilities marked with '+' require us to examine the key types
* associated with each group for the key.
*/
- bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode));
+ memset(matchingKeys, 0, XkbMaxKeyCount*sizeof(KeyCode));
nMatchingKeys= 0;
if (new_num_lvls>type->num_levels) {
int nTotal;
@@ -461,7 +458,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) {
if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) {
if (nClear>0)
- bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym));
+ memset(&pSyms[g*width+firstClear], 0, nClear*sizeof(KeySym));
}
}
}
@@ -491,8 +488,8 @@ KeySym *newSyms; nOldSyms*sizeof(KeySym));
}
if ((needed-nOldSyms)>0) {
- bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)],
- (needed-nOldSyms)*sizeof(KeySym));
+ memset(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb, key)],
+ 0, (needed-nOldSyms)*sizeof(KeySym));
}
xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
xkb->map->num_syms+= needed;
@@ -515,7 +512,7 @@ KeySym *newSyms; if (nCopy!=0)
memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym));
if (nKeySyms>nCopy)
- bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym));
+ memset(&newSyms[nSyms+nCopy], 0, (nKeySyms-nCopy)*sizeof(KeySym));
xkb->map->key_sym_map[i].offset = nSyms;
nSyms+= nKeySyms;
}
@@ -568,7 +565,7 @@ int tmp; tmp= xkb->min_key_code-minKC;
if (xkb->map) {
if (xkb->map->key_sym_map) {
- bzero((char *)&xkb->map->key_sym_map[minKC],
+ memset((char *)&xkb->map->key_sym_map[minKC], 0,
tmp*sizeof(XkbSymMapRec));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -578,7 +575,7 @@ int tmp; }
}
if (xkb->map->modmap) {
- bzero((char *)&xkb->map->modmap[minKC],tmp);
+ memset((char *)&xkb->map->modmap[minKC], 0, tmp);
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
XkbModifierMapMask,minKC,
@@ -589,7 +586,7 @@ int tmp; }
if (xkb->server) {
if (xkb->server->behaviors) {
- bzero((char *)&xkb->server->behaviors[minKC],
+ memset((char *)&xkb->server->behaviors[minKC], 0,
tmp*sizeof(XkbBehavior));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -599,7 +596,7 @@ int tmp; }
}
if (xkb->server->key_acts) {
- bzero((char *)&xkb->server->key_acts[minKC],
+ memset((char *)&xkb->server->key_acts[minKC], 0,
tmp*sizeof(unsigned short));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -609,7 +606,7 @@ int tmp; }
}
if (xkb->server->vmodmap) {
- bzero((char *)&xkb->server->vmodmap[minKC],
+ memset((char *)&xkb->server->vmodmap[minKC], 0,
tmp*sizeof(unsigned short));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -620,7 +617,7 @@ int tmp; }
}
if ((xkb->names)&&(xkb->names->keys)) {
- bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec));
+ memset((char *)&xkb->names->keys[minKC], 0, tmp*sizeof(XkbKeyNameRec));
if (changes) {
changes->names.changed= _ExtendRange(changes->names.changed,
XkbKeyNamesMask,minKC,
@@ -644,7 +641,7 @@ int tmp; free(prev_key_sym_map);
return BadAlloc;
}
- bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code],
+ memset((char *)&xkb->map->key_sym_map[xkb->max_key_code], 0,
tmp*sizeof(XkbSymMapRec));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -662,7 +659,7 @@ int tmp; free(prev_modmap);
return BadAlloc;
}
- bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp);
+ memset((char *)&xkb->map->modmap[xkb->max_key_code], 0, tmp);
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
XkbModifierMapMask,maxKC,
@@ -681,7 +678,7 @@ int tmp; free(prev_behaviors);
return BadAlloc;
}
- bzero((char *)&xkb->server->behaviors[xkb->max_key_code],
+ memset((char *)&xkb->server->behaviors[xkb->max_key_code], 0,
tmp*sizeof(XkbBehavior));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -699,7 +696,7 @@ int tmp; free(prev_key_acts);
return BadAlloc;
}
- bzero((char *)&xkb->server->key_acts[xkb->max_key_code],
+ memset((char *)&xkb->server->key_acts[xkb->max_key_code], 0,
tmp*sizeof(unsigned short));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -717,7 +714,7 @@ int tmp; free(prev_vmodmap);
return BadAlloc;
}
- bzero((char *)&xkb->server->vmodmap[xkb->max_key_code],
+ memset((char *)&xkb->server->vmodmap[xkb->max_key_code], 0,
tmp*sizeof(unsigned short));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -736,7 +733,7 @@ int tmp; free(prev_keys);
return BadAlloc;
}
- bzero((char *)&xkb->names->keys[xkb->max_key_code],
+ memset((char *)&xkb->names->keys[xkb->max_key_code], 0,
tmp*sizeof(XkbKeyNameRec));
if (changes) {
changes->names.changed= _ExtendRange(changes->names.changed,
@@ -790,7 +787,7 @@ XkbAction *newActs; memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i),
nCopy*sizeof(XkbAction));
if (nCopy<nKeyActs)
- bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction));
+ memset(&newActs[nActs+nCopy], 0, (nKeyActs-nCopy)*sizeof(XkbAction));
xkb->server->key_acts[i]= nActs;
nActs+= nKeyActs;
}
diff --git a/xorg-server/xkb/XKBMisc.c b/xorg-server/xkb/XKBMisc.c index 758638f4b..f983466ea 100644 --- a/xorg-server/xkb/XKBMisc.c +++ b/xorg-server/xkb/XKBMisc.c @@ -580,7 +580,7 @@ int width,nOldGroups,oldWidth,newTypes[XkbNumKbdGroups]; pSyms= XkbResizeKeySyms(xkb,key,width*nGroups);
if (pSyms==NULL)
return BadAlloc;
- bzero(pSyms,width*nGroups*sizeof(KeySym));
+ memset(pSyms, 0, width*nGroups*sizeof(KeySym));
for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
pOldType= XkbKeyKeyType(xkb,key,i);
pNewType= &xkb->map->types[newTypes[i]];
@@ -596,7 +596,7 @@ int width,nOldGroups,oldWidth,newTypes[XkbNumKbdGroups]; pActs= XkbResizeKeyActions(xkb,key,width*nGroups);
if (pActs==NULL)
return BadAlloc;
- bzero(pActs,width*nGroups*sizeof(XkbAction));
+ memset(pActs, 0, width*nGroups*sizeof(XkbAction));
for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
pOldType= XkbKeyKeyType(xkb,key,i);
pNewType= &xkb->map->types[newTypes[i]];
diff --git a/xorg-server/xkb/maprules.c b/xorg-server/xkb/maprules.c index a717aa456..2a118ae6a 100644 --- a/xorg-server/xkb/maprules.c +++ b/xorg-server/xkb/maprules.c @@ -270,7 +270,7 @@ Bool found; l_ndx_present = v_ndx_present = present= 0;
str= &line->line[1];
len = remap->number;
- bzero((char *)remap,sizeof(RemapSpec));
+ memset((char *)remap, 0, sizeof(RemapSpec));
remap->number = len;
while ((tok=_XStrtok(str," ",strtok_buf))!=NULL) {
found= FALSE;
@@ -412,7 +412,7 @@ Bool append = FALSE; DebugF("Illegal line of data ignored\n");
return FALSE;
}
- bzero((char *)&tmp,sizeof(FileSpec));
+ memset((char *)&tmp, 0, sizeof(FileSpec));
str= line->line;
for (nread= 0;(tok=_XStrtok(str," ",strtok_buf))!=NULL;nread++) {
str= NULL;
@@ -495,7 +495,7 @@ static Bool MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
{
- bzero((char *)mdefs,sizeof(XkbRF_MultiDefsRec));
+ memset((char *)mdefs, 0, sizeof(XkbRF_MultiDefsRec));
mdefs->model = defs->model;
mdefs->options = _XkbDupString(defs->options);
if (mdefs->options) squeeze_spaces(mdefs->options);
@@ -553,9 +553,9 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs) static void
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
{
- if (defs->options) free(defs->options);
- if (defs->layout[1]) free(defs->layout[1]);
- if (defs->variant[1]) free(defs->variant[1]);
+ free(defs->options);
+ free(defs->layout[1]);
+ free(defs->variant[1]);
}
static void
@@ -834,7 +834,7 @@ XkbRF_GetComponents( XkbRF_RulesPtr rules, MakeMultiDefs(&mdefs, defs);
- bzero((char *)names,sizeof(XkbComponentNamesRec));
+ memset((char *)names, 0, sizeof(XkbComponentNamesRec));
XkbRF_ClearPartialMatches(rules);
XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Normal);
XkbRF_ApplyPartialMatches(rules, names);
@@ -876,7 +876,7 @@ XkbRF_AddRule(XkbRF_RulesPtr rules) DebugF("Allocation failure in XkbRF_AddRule\n");
return NULL;
}
- bzero((char *)&rules->rules[rules->num_rules],sizeof(XkbRF_RuleRec));
+ memset((char *)&rules->rules[rules->num_rules], 0, sizeof(XkbRF_RuleRec));
return &rules->rules[rules->num_rules++];
}
@@ -898,7 +898,7 @@ XkbRF_AddGroup(XkbRF_RulesPtr rules) return NULL;
}
- bzero((char *)&rules->groups[rules->num_groups],sizeof(XkbRF_GroupRec));
+ memset((char *)&rules->groups[rules->num_groups], 0, sizeof(XkbRF_GroupRec));
return &rules->groups[rules->num_groups++];
}
@@ -912,20 +912,20 @@ XkbRF_GroupRec tgroup,*group; if (!(rules && file))
return FALSE;
- bzero((char *)&remap,sizeof(RemapSpec));
- bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
+ memset((char *)&remap, 0, sizeof(RemapSpec));
+ memset((char *)&tgroup, 0, sizeof(XkbRF_GroupRec));
InitInputLine(&line);
while (GetInputLine(file,&line,TRUE)) {
if (CheckLine(&line,&remap,&trule,&tgroup)) {
if (tgroup.number) {
if ((group= XkbRF_AddGroup(rules))!=NULL) {
*group= tgroup;
- bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
+ memset((char *)&tgroup, 0, sizeof(XkbRF_GroupRec));
}
} else {
if ((rule= XkbRF_AddRule(rules))!=NULL) {
*rule= trule;
- bzero((char *)&trule,sizeof(XkbRF_RuleRec));
+ memset((char *)&trule, 0, sizeof(XkbRF_RuleRec));
}
}
}
@@ -988,16 +988,16 @@ XkbRF_GroupPtr group; return;
if (rules->rules) {
for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
- if (rule->model) free(rule->model);
- if (rule->layout) free(rule->layout);
- if (rule->variant) free(rule->variant);
- if (rule->option) free(rule->option);
- if (rule->keycodes) free(rule->keycodes);
- if (rule->symbols) free(rule->symbols);
- if (rule->types) free(rule->types);
- if (rule->compat) free(rule->compat);
- if (rule->geometry) free(rule->geometry);
- bzero((char *)rule,sizeof(XkbRF_RuleRec));
+ free(rule->model);
+ free(rule->layout);
+ free(rule->variant);
+ free(rule->option);
+ free(rule->keycodes);
+ free(rule->symbols);
+ free(rule->types);
+ free(rule->compat);
+ free(rule->geometry);
+ memset((char *)rule, 0, sizeof(XkbRF_RuleRec));
}
free(rules->rules);
rules->num_rules= rules->sz_rules= 0;
@@ -1006,8 +1006,8 @@ XkbRF_GroupPtr group; if (rules->groups) {
for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) {
- if (group->name) free(group->name);
- if (group->words) free(group->words);
+ free(group->name);
+ free(group->words);
}
free(rules->groups);
rules->num_groups= 0;
diff --git a/xorg-server/xkb/xkb.c b/xorg-server/xkb/xkb.c index 3c337b63e..cd48515d7 100644 --- a/xorg-server/xkb/xkb.c +++ b/xorg-server/xkb/xkb.c @@ -557,7 +557,7 @@ ProcXkbGetState(ClientPtr client) CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
xkb= &dev->key->xkbInfo->state;
- bzero(&rep,sizeof(xkbGetStateReply));
+ memset(&rep, 0, sizeof(xkbGetStateReply));
rep.type= X_Reply;
rep.sequenceNumber= client->sequence;
rep.length = 0;
@@ -1429,7 +1429,7 @@ ProcXkbGetMap(ClientPtr client) CHK_MASK_LEGAL(0x03,stuff->partial,XkbAllMapComponentsMask);
xkb= dev->key->xkbInfo->desc;
- bzero(&rep,sizeof(xkbGetMapReply));
+ memset(&rep, 0, sizeof(xkbGetMapReply));
rep.type= X_Reply;
rep.sequenceNumber= client->sequence;
rep.length = (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply))>>2;
@@ -2172,7 +2172,7 @@ unsigned first,last; first= req->firstKeyBehavior;
last= req->firstKeyBehavior+req->nKeyBehaviors-1;
- bzero(&server->behaviors[first],req->nKeyBehaviors*sizeof(XkbBehavior));
+ memset(&server->behaviors[first], 0, req->nKeyBehaviors*sizeof(XkbBehavior));
for (i=0;i<req->totalKeyBehaviors;i++) {
if ((server->behaviors[wire->key].type&XkbKB_Permanent)==0) {
server->behaviors[wire->key].type= wire->type;
@@ -2190,7 +2190,7 @@ unsigned first,last; else xkbi->radioGroups= calloc(1, sz);
if (xkbi->radioGroups) {
if (xkbi->nRadioGroups)
- bzero(&xkbi->radioGroups[xkbi->nRadioGroups],
+ memset(&xkbi->radioGroups[xkbi->nRadioGroups], 0,
(maxRG-xkbi->nRadioGroups)*sizeof(XkbRadioGroupRec));
xkbi->nRadioGroups= maxRG;
}
@@ -2245,7 +2245,7 @@ CARD8 * start; start= wire;
first= req->firstKeyExplicit;
last= req->firstKeyExplicit+req->nKeyExplicit-1;
- bzero(&xkb->explicit[first],req->nKeyExplicit);
+ memset(&xkb->explicit[first], 0, req->nKeyExplicit);
for (i=0;i<req->totalKeyExplicit;i++,wire+= 2) {
xkb->explicit[wire[0]]= wire[1];
}
@@ -2279,7 +2279,7 @@ CARD8 * start; start= wire;
first= req->firstModMapKey;
last= req->firstModMapKey+req->nModMapKeys-1;
- bzero(&xkb->modmap[first],req->nModMapKeys);
+ memset(&xkb->modmap[first], 0, req->nModMapKeys);
for (i=0;i<req->totalModMapKeys;i++,wire+= 2) {
xkb->modmap[wire[0]]= wire[1];
}
@@ -2311,7 +2311,7 @@ XkbServerMapPtr srv = xkbi->desc->server; first= req->firstVModMapKey;
last= req->firstVModMapKey+req->nVModMapKeys-1;
- bzero(&srv->vmodmap[first],req->nVModMapKeys*sizeof(unsigned short));
+ memset(&srv->vmodmap[first], 0, req->nVModMapKeys*sizeof(unsigned short));
for (i=0;i<req->totalVModMapKeys;i++,wire++) {
srv->vmodmap[wire->key]= wire->vmods;
}
@@ -2438,7 +2438,7 @@ _XkbSetMap(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq *req, char *values) xkb = xkbi->desc;
XkbSetCauseXkbReq(&cause,X_kbSetMap,client);
- bzero(&change, sizeof(change));
+ memset(&change, 0, sizeof(change));
sentNKN = FALSE;
if ((xkb->min_key_code!=req->minKeyCode)||
(xkb->max_key_code!=req->maxKeyCode)) {
@@ -2851,7 +2851,7 @@ _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev, XkbEventCauseRec cause;
XkbSetCauseXkbReq(&cause,X_kbSetCompatMap,client);
- bzero(&change,sizeof(XkbChangesRec));
+ memset(&change, 0, sizeof(XkbChangesRec));
XkbUpdateActions(dev,xkb->min_key_code,XkbNumKeys(xkb),&change,&check,
&cause);
if (check)
@@ -3384,8 +3384,8 @@ _XkbSetNamedIndicator(ClientPtr client, DeviceIntPtr dev, statec |= ((sli->effectiveState ^ sli->explicitState) & (1 << led));
}
- bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
- bzero((char *)&changes,sizeof(XkbChangesRec));
+ memset((char *)&ed, 0, sizeof(xkbExtensionDeviceNotify));
+ memset((char *)&changes, 0, sizeof(XkbChangesRec));
XkbSetCauseXkbReq(&cause,X_kbSetNamedIndicator,client);
if (namec)
XkbApplyLedNameChanges(dev,sli,namec,&ed,&changes,&cause);
@@ -4038,7 +4038,7 @@ _XkbSetNames(ClientPtr client, DeviceIntPtr dev, xkbSetNamesReq *stuff) return BadAlloc;
}
- bzero(&nn,sizeof(xkbNamesNotify));
+ memset(&nn, 0, sizeof(xkbNamesNotify));
nn.changed= stuff->which;
tmp = (CARD32 *)&stuff[1];
if (stuff->which&XkbKeycodesNameMask)
@@ -4160,7 +4160,7 @@ _XkbSetNames(ClientPtr client, DeviceIntPtr dev, xkbSetNamesReq *stuff) if (names->indicators[i]!=None)
sli->namesPresent|= bit;
}
- bzero(&edev,sizeof(xkbExtensionDeviceNotify));
+ memset(&edev, 0, sizeof(xkbExtensionDeviceNotify));
edev.reason= XkbXI_IndicatorNamesMask;
edev.ledClass= KbdFeedbackClass;
edev.ledID= dev->kbdfeed->ctrl.id;
@@ -4478,7 +4478,7 @@ xkbDoodadWireDesc * doodadWire; for (i=0;i<num_doodads;i++,doodad++) {
doodadWire= (xkbDoodadWireDesc *)wire;
wire= (char *)&doodadWire[1];
- bzero(doodadWire,SIZEOF(xkbDoodadWireDesc));
+ memset(doodadWire, 0, SIZEOF(xkbDoodadWireDesc));
doodadWire->any.name= doodad->any.name;
doodadWire->any.type= doodad->any.type;
doodadWire->any.priority= doodad->any.priority;
@@ -5290,7 +5290,7 @@ _XkbSetGeometry(ClientPtr client, DeviceIntPtr dev, xkbSetGeometryReq *stuff) XkbFreeGeometry(old,XkbGeomAllMask,TRUE);
if (new_name) {
xkbNamesNotify nn;
- bzero(&nn,sizeof(xkbNamesNotify));
+ memset(&nn, 0, sizeof(xkbNamesNotify));
nn.changed= XkbGeometryNameMask;
XkbSendNamesNotify(dev,&nn);
}
@@ -5497,7 +5497,7 @@ ProcXkbListComponents(ClientPtr client) status= Success;
str= (unsigned char *)&stuff[1];
- bzero(&list,sizeof(XkbSrvListInfoRec));
+ memset(&list, 0, sizeof(XkbSrvListInfoRec));
list.maxRtrn= stuff->maxNames;
list.pattern[_XkbListKeycodes]= GetComponentSpec(&str,FALSE,&status);
list.pattern[_XkbListTypes]= GetComponentSpec(&str,FALSE,&status);
@@ -5516,7 +5516,7 @@ ProcXkbListComponents(ClientPtr client) }
return status;
}
- bzero(&rep,sizeof(xkbListComponentsReply));
+ memset(&rep, 0, sizeof(xkbListComponentsReply));
rep.type= X_Reply;
rep.deviceID = dev->id;
rep.sequenceNumber = client->sequence;
@@ -5624,7 +5624,7 @@ ProcXkbGetKbdByName(ClientPtr client) geom_changed= FALSE;
}
- bzero(mapFile,PATH_MAX);
+ memset(mapFile, 0, PATH_MAX);
rep.type= X_Reply;
rep.deviceID = dev->id;
rep.sequenceNumber = client->sequence;
@@ -5659,7 +5659,7 @@ ProcXkbGetKbdByName(ClientPtr client) if (stuff->load ||
((rep.reported&XkbGBN_SymbolsMask) && (new->compat))) {
XkbChangesRec changes;
- bzero(&changes,sizeof(changes));
+ memset(&changes, 0, sizeof(changes));
XkbUpdateDescActions(new,
new->min_key_code,XkbNumKeys(new),
&changes);
@@ -6123,7 +6123,7 @@ char * str; wanted&= ~XkbXI_IndicatorsMask;
nameLen= XkbSizeCountedString(dev->name);
- bzero((char *)&rep,SIZEOF(xkbGetDeviceInfoReply));
+ memset((char *)&rep, 0, SIZEOF(xkbGetDeviceInfoReply));
rep.type = X_Reply;
rep.deviceID= dev->id;
rep.sequenceNumber = client->sequence;
@@ -6331,8 +6331,8 @@ xkbExtensionDeviceNotify ed; XkbChangesRec changes;
DeviceIntPtr kbd;
- bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
- bzero((char *)&changes,sizeof(XkbChangesRec));
+ memset((char *)&ed, 0, sizeof(xkbExtensionDeviceNotify));
+ memset((char *)&changes, 0, sizeof(XkbChangesRec));
XkbSetCauseXkbReq(&cause,X_kbSetDeviceInfo,client);
ledWire= (xkbDeviceLedsWireDesc *)wire;
for (i=0;i<num;i++) {
@@ -6353,11 +6353,11 @@ DeviceIntPtr kbd; atomWire= (CARD32 *)&ledWire[1];
if (changed&XkbXI_IndicatorNamesMask) {
namec= sli->namesPresent|ledWire->namesPresent;
- bzero((char *)sli->names,XkbNumIndicators*sizeof(Atom));
+ memset((char *)sli->names, 0, XkbNumIndicators*sizeof(Atom));
}
if (ledWire->namesPresent) {
sli->namesPresent= ledWire->namesPresent;
- bzero((char *)sli->names,XkbNumIndicators*sizeof(Atom));
+ memset((char *)sli->names, 0, XkbNumIndicators*sizeof(Atom));
for (n=0,bit=1;n<XkbNumIndicators;n++,bit<<=1) {
if (ledWire->namesPresent&bit) {
sli->names[n]= (Atom)*atomWire;
@@ -6371,7 +6371,7 @@ DeviceIntPtr kbd; if (changed&XkbXI_IndicatorMapsMask) {
mapc= sli->mapsPresent|ledWire->mapsPresent;
sli->mapsPresent= ledWire->mapsPresent;
- bzero((char*)sli->maps,XkbNumIndicators*sizeof(XkbIndicatorMapRec));
+ memset((char*)sli->maps, 0, XkbNumIndicators*sizeof(XkbIndicatorMapRec));
}
if (ledWire->mapsPresent) {
for (n=0,bit=1;n<XkbNumIndicators;n++,bit<<=1) {
@@ -6450,7 +6450,7 @@ _XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev, char *wire;
xkbExtensionDeviceNotify ed;
- bzero((char *)&ed,SIZEOF(xkbExtensionDeviceNotify));
+ memset((char *)&ed, 0, SIZEOF(xkbExtensionDeviceNotify));
ed.deviceID= dev->id;
wire= (char *)&stuff[1];
if (stuff->change&XkbXI_ButtonActionsMask) {
@@ -6709,6 +6709,9 @@ XkbExtensionInit(void) if (!RT_XKBCLIENT)
return;
+ if (!XkbInitPrivates())
+ return;
+
if ((extEntry = AddExtension(XkbName, XkbNumberEvents, XkbNumberErrors,
ProcXkbDispatch, SProcXkbDispatch,
NULL, StandardMinorOpcode))) {
diff --git a/xorg-server/xkb/xkbAccessX.c b/xorg-server/xkb/xkbAccessX.c index be1dceea3..be12e5d83 100644 --- a/xorg-server/xkb/xkbAccessX.c +++ b/xorg-server/xkb/xkbAccessX.c @@ -1,776 +1,776 @@ -/************************************************************ -Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. - -Permission to use, copy, modify, and distribute this -software and its documentation for any purpose and without -fee is hereby granted, provided that the above copyright -notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting -documentation, and that the name of Silicon Graphics not be -used in advertising or publicity pertaining to distribution -of the software without specific prior written permission. -Silicon Graphics makes no representation about the suitability -of this software for any purpose. It is provided "as is" -without any express or implied warranty. - -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH -THE USE OR PERFORMANCE OF THIS SOFTWARE. - -********************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdio.h> -#include <math.h> -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/keysym.h> -#include "exglobals.h" -#include <X11/extensions/XIproto.h> -#include "inputstr.h" -#include "eventstr.h" -#include <xkbsrv.h> -#if !defined(WIN32) -#include <sys/time.h> -#endif - -int XkbDfltRepeatDelay= 660; -int XkbDfltRepeatInterval= 40; - -#define DFLT_TIMEOUT_CTRLS (XkbAX_KRGMask|XkbStickyKeysMask|XkbMouseKeysMask) -#define DFLT_TIMEOUT_OPTS (XkbAX_IndicatorFBMask) - -unsigned short XkbDfltAccessXTimeout= 120; -unsigned int XkbDfltAccessXTimeoutMask= DFLT_TIMEOUT_CTRLS; -static unsigned int XkbDfltAccessXTimeoutValues= 0; -static unsigned int XkbDfltAccessXTimeoutOptionsMask= DFLT_TIMEOUT_OPTS; -static unsigned int XkbDfltAccessXTimeoutOptionsValues= 0; -unsigned int XkbDfltAccessXFeedback= XkbAccessXFeedbackMask; -unsigned short XkbDfltAccessXOptions= XkbAX_AllOptionsMask & ~(XkbAX_IndicatorFBMask|XkbAX_SKReleaseFBMask|XkbAX_SKRejectFBMask); - -void -AccessXComputeCurveFactor(XkbSrvInfoPtr xkbi,XkbControlsPtr ctrls) -{ - xkbi->mouseKeysCurve= 1.0+(((double)ctrls->mk_curve)*0.001); - xkbi->mouseKeysCurveFactor= ( ((double)ctrls->mk_max_speed)/ - pow((double)ctrls->mk_time_to_max,xkbi->mouseKeysCurve)); - return; -} - -void -AccessXInit(DeviceIntPtr keybd) -{ -XkbSrvInfoPtr xkbi = keybd->key->xkbInfo; -XkbControlsPtr ctrls = xkbi->desc->ctrls; - - xkbi->shiftKeyCount= 0; - xkbi->mouseKeysCounter= 0; - xkbi->inactiveKey= 0; - xkbi->slowKey= 0; - xkbi->repeatKey= 0; - xkbi->krgTimerActive= _OFF_TIMER; - xkbi->beepType= _BEEP_NONE; - xkbi->beepCount= 0; - xkbi->mouseKeyTimer= NULL; - xkbi->slowKeysTimer= NULL; - xkbi->bounceKeysTimer= NULL; - xkbi->repeatKeyTimer= NULL; - xkbi->krgTimer= NULL; - xkbi->beepTimer= NULL; - ctrls->repeat_delay = XkbDfltRepeatDelay; - ctrls->repeat_interval = XkbDfltRepeatInterval; - ctrls->debounce_delay = 300; - ctrls->slow_keys_delay = 300; - ctrls->mk_delay = 160; - ctrls->mk_interval = 40; - ctrls->mk_time_to_max = 30; - ctrls->mk_max_speed = 30; - ctrls->mk_curve = 500; - ctrls->mk_dflt_btn = 1; - ctrls->ax_timeout = XkbDfltAccessXTimeout; - ctrls->axt_ctrls_mask = XkbDfltAccessXTimeoutMask; - ctrls->axt_ctrls_values = XkbDfltAccessXTimeoutValues; - ctrls->axt_opts_mask = XkbDfltAccessXTimeoutOptionsMask; - ctrls->axt_opts_values = XkbDfltAccessXTimeoutOptionsValues; - if (XkbDfltAccessXTimeout) - ctrls->enabled_ctrls |= XkbAccessXTimeoutMask; - else - ctrls->enabled_ctrls &= ~XkbAccessXTimeoutMask; - ctrls->enabled_ctrls |= XkbDfltAccessXFeedback; - ctrls->ax_options = XkbDfltAccessXOptions; - AccessXComputeCurveFactor(xkbi,ctrls); - return; -} - -/************************************************************************/ -/* */ -/* AccessXKeyboardEvent */ -/* */ -/* Generate a synthetic keyboard event. */ -/* */ -/************************************************************************/ -static void -AccessXKeyboardEvent(DeviceIntPtr keybd, - int type, - BYTE keyCode, - Bool isRepeat) -{ - DeviceEvent event; - memset(&event, 0, sizeof(DeviceEvent)); - event.header = ET_Internal; - event.type = type; - event.detail.key = keyCode; - event.time = GetTimeInMillis(); - event.length = sizeof(DeviceEvent); - event.key_repeat = isRepeat; - event.sourceid = keybd->id; - event.deviceid = keybd->id; - - if (xkbDebugFlags&0x8) { - DebugF("[xkb] AXKE: Key %d %s\n", keyCode, - (event.type == ET_KeyPress ? "down" : "up")); - } - - XkbProcessKeyboardEvent(&event, keybd); - return; -} /* AccessXKeyboardEvent */ - -/************************************************************************/ -/* */ -/* AccessXKRGTurnOn */ -/* */ -/* Turn the keyboard response group on. */ -/* */ -/************************************************************************/ -static void -AccessXKRGTurnOn(DeviceIntPtr dev,CARD16 KRGControl,xkbControlsNotify *pCN) -{ -XkbSrvInfoPtr xkbi = dev->key->xkbInfo; -XkbControlsPtr ctrls = xkbi->desc->ctrls; -XkbControlsRec old; -XkbEventCauseRec cause; -XkbSrvLedInfoPtr sli; - - old= *ctrls; - ctrls->enabled_ctrls |= (KRGControl&XkbAX_KRGMask); - if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE)) - XkbSendControlsNotify(dev,pCN); - cause.kc= pCN->keycode; - cause.event= pCN->eventType; - cause.mjr= pCN->requestMajor; - cause.mnr= pCN->requestMinor; - sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0); - XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause); - if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) - XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,KRGControl); - return; - -} /* AccessXKRGTurnOn */ - -/************************************************************************/ -/* */ -/* AccessXKRGTurnOff */ -/* */ -/* Turn the keyboard response group off. */ -/* */ -/************************************************************************/ -static void -AccessXKRGTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN) -{ -XkbSrvInfoPtr xkbi = dev->key->xkbInfo; -XkbControlsPtr ctrls = xkbi->desc->ctrls; -XkbControlsRec old; -XkbEventCauseRec cause; -XkbSrvLedInfoPtr sli; - - old = *ctrls; - ctrls->enabled_ctrls &= ~XkbAX_KRGMask; - if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE)) - XkbSendControlsNotify(dev,pCN); - cause.kc= pCN->keycode; - cause.event= pCN->eventType; - cause.mjr= pCN->requestMajor; - cause.mnr= pCN->requestMinor; - sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0); - XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause); - if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) { - unsigned changes= old.enabled_ctrls^ctrls->enabled_ctrls; - XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,changes); - } - return; - -} /* AccessXKRGTurnOff */ - -/************************************************************************/ -/* */ -/* AccessXStickyKeysTurnOn */ -/* */ -/* Turn StickyKeys on. */ -/* */ -/************************************************************************/ -static void -AccessXStickyKeysTurnOn(DeviceIntPtr dev,xkbControlsNotify *pCN) -{ -XkbSrvInfoPtr xkbi = dev->key->xkbInfo; -XkbControlsPtr ctrls = xkbi->desc->ctrls; -XkbControlsRec old; -XkbEventCauseRec cause; -XkbSrvLedInfoPtr sli; - - old = *ctrls; - ctrls->enabled_ctrls |= XkbStickyKeysMask; - xkbi->shiftKeyCount = 0; - if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE)) - XkbSendControlsNotify(dev,pCN); - cause.kc= pCN->keycode; - cause.event= pCN->eventType; - cause.mjr= pCN->requestMajor; - cause.mnr= pCN->requestMinor; - sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0); - XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause); - if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) { - XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,XkbStickyKeysMask); - } - return; - -} /* AccessXStickyKeysTurnOn */ - -/************************************************************************/ -/* */ -/* AccessXStickyKeysTurnOff */ -/* */ -/* Turn StickyKeys off. */ -/* */ -/************************************************************************/ -static void -AccessXStickyKeysTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN) -{ -XkbSrvInfoPtr xkbi = dev->key->xkbInfo; -XkbControlsPtr ctrls = xkbi->desc->ctrls; -XkbControlsRec old; -XkbEventCauseRec cause; -XkbSrvLedInfoPtr sli; - - old = *ctrls; - ctrls->enabled_ctrls &= ~XkbStickyKeysMask; - xkbi->shiftKeyCount = 0; - if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE)) - XkbSendControlsNotify(dev,pCN); - - cause.kc= pCN->keycode; - cause.event= pCN->eventType; - cause.mjr= pCN->requestMajor; - cause.mnr= pCN->requestMinor; - sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0); - XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause); - if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) { - XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,XkbStickyKeysMask); - } -#ifndef NO_CLEAR_LATCHES_FOR_STICKY_KEYS_OFF - XkbClearAllLatchesAndLocks(dev,xkbi,FALSE,&cause); -#endif - return; -} /* AccessXStickyKeysTurnOff */ - -static CARD32 -AccessXKRGExpire(OsTimerPtr timer,CARD32 now,pointer arg) -{ -XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo; -xkbControlsNotify cn; - - if (xkbi->krgTimerActive==_KRG_WARN_TIMER) { - XkbDDXAccessXBeep((DeviceIntPtr)arg,_BEEP_SLOW_WARN,XkbStickyKeysMask); - xkbi->krgTimerActive= _KRG_TIMER; - return 4000; - } - xkbi->krgTimerActive= _OFF_TIMER; - cn.keycode = 0; - cn.eventType = 0; - cn.requestMajor = 0; - cn.requestMinor = 0; - if (xkbi->desc->ctrls->enabled_ctrls&XkbSlowKeysMask) - AccessXKRGTurnOff((DeviceIntPtr)arg,&cn); - else AccessXKRGTurnOn((DeviceIntPtr)arg,XkbSlowKeysMask,&cn); - return 0; -} - -static CARD32 -AccessXRepeatKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg) -{ -DeviceIntPtr dev = (DeviceIntPtr) arg; -XkbSrvInfoPtr xkbi = dev->key->xkbInfo; - - if (xkbi->repeatKey == 0) - return 0; - - AccessXKeyboardEvent(dev, ET_KeyPress, xkbi->repeatKey, TRUE); - - return xkbi->desc->ctrls->repeat_interval; -} - -void -AccessXCancelRepeatKey(XkbSrvInfoPtr xkbi,KeyCode key) -{ - if (xkbi->repeatKey==key) - xkbi->repeatKey= 0; - return; -} - -static CARD32 -AccessXSlowKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg) -{ -DeviceIntPtr keybd; -XkbSrvInfoPtr xkbi; -XkbDescPtr xkb; -XkbControlsPtr ctrls; - - keybd= (DeviceIntPtr)arg; - xkbi= keybd->key->xkbInfo; - xkb= xkbi->desc; - ctrls= xkb->ctrls; - if (xkbi->slowKey!=0) { - xkbAccessXNotify ev; - KeySym *sym= XkbKeySymsPtr(xkb,xkbi->slowKey); - ev.detail= XkbAXN_SKAccept; - ev.keycode= xkbi->slowKey; - ev.slowKeysDelay= ctrls->slow_keys_delay; - ev.debounceDelay= ctrls->debounce_delay; - XkbSendAccessXNotify(keybd,&ev); - if (XkbAX_NeedFeedback(ctrls,XkbAX_SKAcceptFBMask)) - XkbDDXAccessXBeep(keybd,_BEEP_SLOW_ACCEPT,XkbSlowKeysMask); - AccessXKeyboardEvent(keybd, ET_KeyPress,xkbi->slowKey,FALSE); - /* check for magic sequences */ - if ((ctrls->enabled_ctrls&XkbAccessXKeysMask) && - ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L))) - xkbi->shiftKeyCount++; - - /* Start repeating if necessary. Stop autorepeating if the user - * presses a non-modifier key that doesn't autorepeat. - */ - if (keybd->kbdfeed->ctrl.autoRepeat && - ((xkbi->slowKey != xkbi->mouseKey) || (!xkbi->mouseKeysAccel)) && - (ctrls->enabled_ctrls&XkbRepeatKeysMask)) { - if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,xkbi->slowKey)) { - xkbi->repeatKey = xkbi->slowKey; - xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer, - 0, ctrls->repeat_delay, - AccessXRepeatKeyExpire, (pointer)keybd); - } - } - } - return 0; -} - -static CARD32 -AccessXBounceKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg) -{ -XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo; - - xkbi->inactiveKey= 0; - return 0; -} - -static CARD32 -AccessXTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg) -{ -DeviceIntPtr dev = (DeviceIntPtr)arg; -XkbSrvInfoPtr xkbi= dev->key->xkbInfo; -XkbControlsPtr ctrls= xkbi->desc->ctrls; -XkbControlsRec old; -xkbControlsNotify cn; -XkbEventCauseRec cause; -XkbSrvLedInfoPtr sli; - - if (xkbi->lastPtrEventTime) { - unsigned timeToWait = (ctrls->ax_timeout*1000); - unsigned timeElapsed = (now-xkbi->lastPtrEventTime); - - if (timeToWait > timeElapsed) - return (timeToWait - timeElapsed); - } - old= *ctrls; - xkbi->shiftKeyCount= 0; - ctrls->enabled_ctrls&= ~ctrls->axt_ctrls_mask; - ctrls->enabled_ctrls|= - (ctrls->axt_ctrls_values&ctrls->axt_ctrls_mask); - if (ctrls->axt_opts_mask) { - ctrls->ax_options&= ~ctrls->axt_opts_mask; - ctrls->ax_options|= (ctrls->axt_opts_values&ctrls->axt_opts_mask); - } - if (XkbComputeControlsNotify(dev,&old,ctrls,&cn,FALSE)) { - cn.keycode = 0; - cn.eventType = 0; - cn.requestMajor = 0; - cn.requestMinor = 0; - XkbSendControlsNotify(dev,&cn); - } - XkbSetCauseUnknown(&cause); - sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0); - XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause); - if (ctrls->ax_options!=old.ax_options) { - unsigned set,cleared,bell; - set= ctrls->ax_options&(~old.ax_options); - cleared= (~ctrls->ax_options)&old.ax_options; - if (set && cleared) bell= _BEEP_FEATURE_CHANGE; - else if (set) bell= _BEEP_FEATURE_ON; - else bell= _BEEP_FEATURE_OFF; - XkbDDXAccessXBeep(dev,bell,XkbAccessXTimeoutMask); - } - xkbi->krgTimerActive= _OFF_TIMER; - return 0; -} - - -/************************************************************************/ -/* */ -/* AccessXFilterPressEvent */ -/* */ -/* Filter events before they get any further if SlowKeys is turned on. */ -/* In addition, this routine handles the ever so popular magic key */ -/* acts for turning various accessibility features on/off. */ -/* */ -/* Returns TRUE if this routine has discarded the event. */ -/* Returns FALSE if the event needs further processing. */ -/* */ -/************************************************************************/ -Bool -AccessXFilterPressEvent( DeviceEvent* event, - DeviceIntPtr keybd) -{ -XkbSrvInfoPtr xkbi = keybd->key->xkbInfo; -XkbControlsPtr ctrls = xkbi->desc->ctrls; -Bool ignoreKeyEvent = FALSE; -KeyCode key = event->detail.key; -KeySym * sym = XkbKeySymsPtr(xkbi->desc,key); - - if (ctrls->enabled_ctrls&XkbAccessXKeysMask) { - /* check for magic sequences */ - if ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L)) { - if (XkbAX_NeedFeedback(ctrls,XkbAX_SlowWarnFBMask)) { - xkbi->krgTimerActive = _KRG_WARN_TIMER; - xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 4000, - AccessXKRGExpire, (pointer)keybd); - } - else { - xkbi->krgTimerActive = _KRG_TIMER; - xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 8000, - AccessXKRGExpire, (pointer)keybd); - } - if (!(ctrls->enabled_ctrls & XkbSlowKeysMask)) { - CARD32 now= GetTimeInMillis(); - if ((now-xkbi->lastShiftEventTime)>15000) - xkbi->shiftKeyCount= 1; - else xkbi->shiftKeyCount++; - xkbi->lastShiftEventTime= now; - } - } - else { - if (xkbi->krgTimerActive) { - xkbi->krgTimer= TimerSet(xkbi->krgTimer,0, 0, NULL, NULL); - xkbi->krgTimerActive= _OFF_TIMER; - } - } - } - - /* Don't transmit the KeyPress if SlowKeys is turned on; - * The wakeup handler will synthesize one for us if the user - * has held the key long enough. - */ - if (ctrls->enabled_ctrls & XkbSlowKeysMask) { - xkbAccessXNotify ev; - /* If key was already pressed, ignore subsequent press events - * from the server's autorepeat - */ - if(xkbi->slowKey == key) - return TRUE; - ev.detail= XkbAXN_SKPress; - ev.keycode= key; - ev.slowKeysDelay= ctrls->slow_keys_delay; - ev.debounceDelay= ctrls->debounce_delay; - XkbSendAccessXNotify(keybd,&ev); - if (XkbAX_NeedFeedback(ctrls,XkbAX_SKPressFBMask)) - XkbDDXAccessXBeep(keybd,_BEEP_SLOW_PRESS,XkbSlowKeysMask); - xkbi->slowKey= key; - xkbi->slowKeysTimer = TimerSet(xkbi->slowKeysTimer, - 0, ctrls->slow_keys_delay, - AccessXSlowKeyExpire, (pointer)keybd); - ignoreKeyEvent = TRUE; - } - - /* Don't transmit the KeyPress if BounceKeys is turned on - * and the user pressed the same key within a given time period - * from the last release. - */ - else if ((ctrls->enabled_ctrls & XkbBounceKeysMask) && - (key == xkbi->inactiveKey)) { - if (XkbAX_NeedFeedback(ctrls,XkbAX_BKRejectFBMask)) - XkbDDXAccessXBeep(keybd,_BEEP_BOUNCE_REJECT,XkbBounceKeysMask); - ignoreKeyEvent = TRUE; - } - - /* Start repeating if necessary. Stop autorepeating if the user - * presses a non-modifier key that doesn't autorepeat. - */ - if (XkbDDXUsesSoftRepeat(keybd)) { - if ((keybd->kbdfeed->ctrl.autoRepeat) && - ((ctrls->enabled_ctrls&(XkbSlowKeysMask|XkbRepeatKeysMask))== - XkbRepeatKeysMask)) { - if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,key)) { - if (xkbDebugFlags&0x10) - DebugF("Starting software autorepeat...\n"); - if (xkbi->repeatKey == key) - ignoreKeyEvent = TRUE; - else { - xkbi->repeatKey = key; - xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer, - 0, ctrls->repeat_delay, - AccessXRepeatKeyExpire, (pointer)keybd); - } - } - } - } - - /* Check for two keys being pressed at the same time. This section - * essentially says the following: - * - * If StickyKeys is on, and a modifier is currently being held down, - * and one of the following is true: the current key is not a modifier - * or the currentKey is a modifier, but not the only modifier being - * held down, turn StickyKeys off if the TwoKeys off ctrl is set. - */ - if ((ctrls->enabled_ctrls & XkbStickyKeysMask) && - (xkbi->state.base_mods!=0) && - (XkbAX_NeedOption(ctrls,XkbAX_TwoKeysMask))) { - xkbControlsNotify cn; - cn.keycode = key; - cn.eventType = KeyPress; - cn.requestMajor = 0; - cn.requestMinor = 0; - AccessXStickyKeysTurnOff(keybd,&cn); - } - - if (!ignoreKeyEvent) - XkbProcessKeyboardEvent(event, keybd); - return ignoreKeyEvent; -} /* AccessXFilterPressEvent */ - -/************************************************************************/ -/* */ -/* AccessXFilterReleaseEvent */ -/* */ -/* Filter events before they get any further if SlowKeys is turned on. */ -/* In addition, this routine handles the ever so popular magic key */ -/* acts for turning various accessibility features on/off. */ -/* */ -/* Returns TRUE if this routine has discarded the event. */ -/* Returns FALSE if the event needs further processing. */ -/* */ -/************************************************************************/ -Bool -AccessXFilterReleaseEvent( DeviceEvent* event, - DeviceIntPtr keybd) -{ -XkbSrvInfoPtr xkbi = keybd->key->xkbInfo; -XkbControlsPtr ctrls = xkbi->desc->ctrls; -KeyCode key = event->detail.key; -Bool ignoreKeyEvent = FALSE; - - /* Don't transmit the KeyRelease if BounceKeys is on and - * this is the release of a key that was ignored due to - * BounceKeys. - */ - if (ctrls->enabled_ctrls & XkbBounceKeysMask) { - if ((key!=xkbi->mouseKey)&&(!BitIsOn(keybd->key->down,key))) - ignoreKeyEvent = TRUE; - xkbi->inactiveKey= key; - xkbi->bounceKeysTimer= TimerSet(xkbi->bounceKeysTimer, 0, - ctrls->debounce_delay, - AccessXBounceKeyExpire, (pointer)keybd); - } - - /* Don't transmit the KeyRelease if SlowKeys is turned on and - * the user didn't hold the key long enough. We know we passed - * the key if the down bit was set by CoreProcessKeyboadEvent. - */ - if (ctrls->enabled_ctrls & XkbSlowKeysMask) { - xkbAccessXNotify ev; - unsigned beep_type; - ev.keycode= key; - ev.slowKeysDelay= ctrls->slow_keys_delay; - ev.debounceDelay= ctrls->debounce_delay; - if (BitIsOn(keybd->key->down,key) || (xkbi->mouseKey == key)) { - ev.detail= XkbAXN_SKRelease; - beep_type= _BEEP_SLOW_RELEASE; - } - else { - ev.detail= XkbAXN_SKReject; - beep_type= _BEEP_SLOW_REJECT; - ignoreKeyEvent = TRUE; - } - XkbSendAccessXNotify(keybd,&ev); - if (XkbAX_NeedFeedback(ctrls,XkbAX_SKRejectFBMask)) { - XkbDDXAccessXBeep(keybd,beep_type,XkbSlowKeysMask); - } - if (xkbi->slowKey==key) - xkbi->slowKey= 0; - } - - /* Stop Repeating if the user releases the key that is currently - * repeating. - */ - if (xkbi->repeatKey==key) { - xkbi->repeatKey= 0; - } - - if ((ctrls->enabled_ctrls&XkbAccessXTimeoutMask)&&(ctrls->ax_timeout>0)) { - xkbi->lastPtrEventTime= 0; - xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, - ctrls->ax_timeout*1000, - AccessXTimeoutExpire, (pointer)keybd); - xkbi->krgTimerActive= _ALL_TIMEOUT_TIMER; - } - else if (xkbi->krgTimerActive!=_OFF_TIMER) { - xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 0, NULL, NULL); - xkbi->krgTimerActive= _OFF_TIMER; - } - - /* Keep track of how many times the Shift key has been pressed. - * If it has been pressed and released 5 times in a row, toggle - * the state of StickyKeys. - */ - if ((!ignoreKeyEvent)&&(xkbi->shiftKeyCount)) { - KeySym *pSym= XkbKeySymsPtr(xkbi->desc,key); - if ((pSym[0]!=XK_Shift_L)&&(pSym[0]!=XK_Shift_R)) { - xkbi->shiftKeyCount= 0; - } - else if (xkbi->shiftKeyCount>=5) { - xkbControlsNotify cn; - cn.keycode = key; - cn.eventType = KeyPress; - cn.requestMajor = 0; - cn.requestMinor = 0; - if (ctrls->enabled_ctrls & XkbStickyKeysMask) - AccessXStickyKeysTurnOff(keybd,&cn); - else - AccessXStickyKeysTurnOn(keybd,&cn); - xkbi->shiftKeyCount= 0; - } - } - - if (!ignoreKeyEvent) - XkbProcessKeyboardEvent(event, keybd); - return ignoreKeyEvent; - -} /* AccessXFilterReleaseEvent */ - -/************************************************************************/ -/* */ -/* ProcessPointerEvent */ -/* */ -/* This routine merely sets the shiftKeyCount and clears the keyboard */ -/* response group timer (if necessary) on a mouse event. This is so */ -/* multiple shifts with just the mouse and shift-drags with the mouse */ -/* don't accidentally turn on StickyKeys or the Keyboard Response Group.*/ -/* */ -/************************************************************************/ -extern int xkbDevicePrivateIndex; -extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer); -void -ProcessPointerEvent( InternalEvent *ev, - DeviceIntPtr mouse) -{ -DeviceIntPtr dev; -XkbSrvInfoPtr xkbi = NULL; -unsigned changed = 0; -ProcessInputProc backupproc; -xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse); -DeviceEvent *event = &ev->device_event; - - dev = (IsMaster(mouse) || mouse->u.master) ? GetMaster(mouse, MASTER_KEYBOARD) : mouse; - - if (dev && dev->key) - { - xkbi = dev->key->xkbInfo; - xkbi->shiftKeyCount = 0; - xkbi->lastPtrEventTime= event->time; - } - - if (event->type == ET_ButtonPress) { - changed |= XkbPointerButtonMask; - } - else if (event->type == ET_ButtonRelease) { - if (xkbi) - xkbi->lockedPtrButtons&= ~(1 << (event->detail.key & 0x7)); - changed |= XkbPointerButtonMask; - } - - /* Guesswork. mostly. - * xkb actuall goes through some effort to transparently wrap the - * processInputProcs (see XkbSetExtension). But we all love fun, so the - * previous XKB implementation just hardcoded the CPPE call here instead - * of unwrapping like anybody with any sense of decency would do. - * I got no clue what the correct thing to do is, but my guess is that - * it's not hardcoding. I may be wrong. whatever it is, don't come whining - * to me. I just work here. - * - * Anyway. here's the old call, if you don't like the wrapping, revert it. - * - * CoreProcessPointerEvent(xE,mouse,count); - * - * see. it's still steaming. told you. (whot) - */ - - UNWRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, backupproc); - mouse->public.processInputProc(ev, mouse); - COND_WRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, - backupproc, xkbUnwrapProc); - - if (!xkbi) - return; - - xkbi->state.ptr_buttons = (mouse->button) ? mouse->button->state : 0; - - /* clear any latched modifiers */ - if ( xkbi->state.latched_mods && (event->type == ET_ButtonRelease) ) { - unsigned changed_leds; - XkbStateRec oldState; - XkbSrvLedInfoPtr sli; - - sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0); - oldState= xkbi->state; - XkbLatchModifiers(dev,0xFF,0x00); - - XkbComputeDerivedState(xkbi); - changed |= XkbStateChangedFlags(&oldState,&xkbi->state); - if (changed&sli->usedComponents) { - changed_leds= XkbIndicatorsToUpdate(dev,changed,FALSE); - if (changed_leds) { - XkbEventCauseRec cause; - XkbSetCauseKey(&cause,(event->detail.key & 0x7), event->type); - XkbUpdateIndicators(dev,changed_leds,TRUE,NULL,&cause); - } - } - } - - if (((xkbi->flags&_XkbStateNotifyInProgress)==0)&&(changed!=0)) { - xkbStateNotify sn; - sn.keycode= event->detail.key; - sn.eventType= event->type; - sn.requestMajor = sn.requestMinor = 0; - sn.changed= changed; - XkbSendStateNotify(dev,&sn); - } - -} /* ProcessPointerEvent */ - - - - +/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <math.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "exglobals.h"
+#include <X11/extensions/XIproto.h>
+#include "inputstr.h"
+#include "eventstr.h"
+#include <xkbsrv.h>
+#if !defined(WIN32)
+#include <sys/time.h>
+#endif
+
+int XkbDfltRepeatDelay= 660;
+int XkbDfltRepeatInterval= 40;
+
+#define DFLT_TIMEOUT_CTRLS (XkbAX_KRGMask|XkbStickyKeysMask|XkbMouseKeysMask)
+#define DFLT_TIMEOUT_OPTS (XkbAX_IndicatorFBMask)
+
+unsigned short XkbDfltAccessXTimeout= 120;
+unsigned int XkbDfltAccessXTimeoutMask= DFLT_TIMEOUT_CTRLS;
+static unsigned int XkbDfltAccessXTimeoutValues= 0;
+static unsigned int XkbDfltAccessXTimeoutOptionsMask= DFLT_TIMEOUT_OPTS;
+static unsigned int XkbDfltAccessXTimeoutOptionsValues= 0;
+unsigned int XkbDfltAccessXFeedback= XkbAccessXFeedbackMask;
+unsigned short XkbDfltAccessXOptions= XkbAX_AllOptionsMask & ~(XkbAX_IndicatorFBMask|XkbAX_SKReleaseFBMask|XkbAX_SKRejectFBMask);
+
+void
+AccessXComputeCurveFactor(XkbSrvInfoPtr xkbi,XkbControlsPtr ctrls)
+{
+ xkbi->mouseKeysCurve= 1.0+(((double)ctrls->mk_curve)*0.001);
+ xkbi->mouseKeysCurveFactor= ( ((double)ctrls->mk_max_speed)/
+ pow((double)ctrls->mk_time_to_max,xkbi->mouseKeysCurve));
+ return;
+}
+
+void
+AccessXInit(DeviceIntPtr keybd)
+{
+XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+
+ xkbi->shiftKeyCount= 0;
+ xkbi->mouseKeysCounter= 0;
+ xkbi->inactiveKey= 0;
+ xkbi->slowKey= 0;
+ xkbi->repeatKey= 0;
+ xkbi->krgTimerActive= _OFF_TIMER;
+ xkbi->beepType= _BEEP_NONE;
+ xkbi->beepCount= 0;
+ xkbi->mouseKeyTimer= NULL;
+ xkbi->slowKeysTimer= NULL;
+ xkbi->bounceKeysTimer= NULL;
+ xkbi->repeatKeyTimer= NULL;
+ xkbi->krgTimer= NULL;
+ xkbi->beepTimer= NULL;
+ ctrls->repeat_delay = XkbDfltRepeatDelay;
+ ctrls->repeat_interval = XkbDfltRepeatInterval;
+ ctrls->debounce_delay = 300;
+ ctrls->slow_keys_delay = 300;
+ ctrls->mk_delay = 160;
+ ctrls->mk_interval = 40;
+ ctrls->mk_time_to_max = 30;
+ ctrls->mk_max_speed = 30;
+ ctrls->mk_curve = 500;
+ ctrls->mk_dflt_btn = 1;
+ ctrls->ax_timeout = XkbDfltAccessXTimeout;
+ ctrls->axt_ctrls_mask = XkbDfltAccessXTimeoutMask;
+ ctrls->axt_ctrls_values = XkbDfltAccessXTimeoutValues;
+ ctrls->axt_opts_mask = XkbDfltAccessXTimeoutOptionsMask;
+ ctrls->axt_opts_values = XkbDfltAccessXTimeoutOptionsValues;
+ if (XkbDfltAccessXTimeout)
+ ctrls->enabled_ctrls |= XkbAccessXTimeoutMask;
+ else
+ ctrls->enabled_ctrls &= ~XkbAccessXTimeoutMask;
+ ctrls->enabled_ctrls |= XkbDfltAccessXFeedback;
+ ctrls->ax_options = XkbDfltAccessXOptions;
+ AccessXComputeCurveFactor(xkbi,ctrls);
+ return;
+}
+
+/************************************************************************/
+/* */
+/* AccessXKeyboardEvent */
+/* */
+/* Generate a synthetic keyboard event. */
+/* */
+/************************************************************************/
+static void
+AccessXKeyboardEvent(DeviceIntPtr keybd,
+ int type,
+ BYTE keyCode,
+ Bool isRepeat)
+{
+ DeviceEvent event;
+ memset(&event, 0, sizeof(DeviceEvent));
+ event.header = ET_Internal;
+ event.type = type;
+ event.detail.key = keyCode;
+ event.time = GetTimeInMillis();
+ event.length = sizeof(DeviceEvent);
+ event.key_repeat = isRepeat;
+ event.sourceid = keybd->id;
+ event.deviceid = keybd->id;
+
+ if (xkbDebugFlags&0x8) {
+ DebugF("[xkb] AXKE: Key %d %s\n", keyCode,
+ (event.type == ET_KeyPress ? "down" : "up"));
+ }
+
+ XkbProcessKeyboardEvent(&event, keybd);
+ return;
+} /* AccessXKeyboardEvent */
+
+/************************************************************************/
+/* */
+/* AccessXKRGTurnOn */
+/* */
+/* Turn the keyboard response group on. */
+/* */
+/************************************************************************/
+static void
+AccessXKRGTurnOn(DeviceIntPtr dev,CARD16 KRGControl,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old= *ctrls;
+ ctrls->enabled_ctrls |= (KRGControl&XkbAX_KRGMask);
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
+ XkbSendControlsNotify(dev,pCN);
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask))
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,KRGControl);
+ return;
+
+} /* AccessXKRGTurnOn */
+
+/************************************************************************/
+/* */
+/* AccessXKRGTurnOff */
+/* */
+/* Turn the keyboard response group off. */
+/* */
+/************************************************************************/
+static void
+AccessXKRGTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old = *ctrls;
+ ctrls->enabled_ctrls &= ~XkbAX_KRGMask;
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
+ XkbSendControlsNotify(dev,pCN);
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
+ unsigned changes= old.enabled_ctrls^ctrls->enabled_ctrls;
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,changes);
+ }
+ return;
+
+} /* AccessXKRGTurnOff */
+
+/************************************************************************/
+/* */
+/* AccessXStickyKeysTurnOn */
+/* */
+/* Turn StickyKeys on. */
+/* */
+/************************************************************************/
+static void
+AccessXStickyKeysTurnOn(DeviceIntPtr dev,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old = *ctrls;
+ ctrls->enabled_ctrls |= XkbStickyKeysMask;
+ xkbi->shiftKeyCount = 0;
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
+ XkbSendControlsNotify(dev,pCN);
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,XkbStickyKeysMask);
+ }
+ return;
+
+} /* AccessXStickyKeysTurnOn */
+
+/************************************************************************/
+/* */
+/* AccessXStickyKeysTurnOff */
+/* */
+/* Turn StickyKeys off. */
+/* */
+/************************************************************************/
+static void
+AccessXStickyKeysTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old = *ctrls;
+ ctrls->enabled_ctrls &= ~XkbStickyKeysMask;
+ xkbi->shiftKeyCount = 0;
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
+ XkbSendControlsNotify(dev,pCN);
+
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,XkbStickyKeysMask);
+ }
+#ifndef NO_CLEAR_LATCHES_FOR_STICKY_KEYS_OFF
+ XkbClearAllLatchesAndLocks(dev,xkbi,FALSE,&cause);
+#endif
+ return;
+} /* AccessXStickyKeysTurnOff */
+
+static CARD32
+AccessXKRGExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
+xkbControlsNotify cn;
+
+ if (xkbi->krgTimerActive==_KRG_WARN_TIMER) {
+ XkbDDXAccessXBeep((DeviceIntPtr)arg,_BEEP_SLOW_WARN,XkbStickyKeysMask);
+ xkbi->krgTimerActive= _KRG_TIMER;
+ return 4000;
+ }
+ xkbi->krgTimerActive= _OFF_TIMER;
+ cn.keycode = 0;
+ cn.eventType = 0;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ if (xkbi->desc->ctrls->enabled_ctrls&XkbSlowKeysMask)
+ AccessXKRGTurnOff((DeviceIntPtr)arg,&cn);
+ else AccessXKRGTurnOn((DeviceIntPtr)arg,XkbSlowKeysMask,&cn);
+ return 0;
+}
+
+static CARD32
+AccessXRepeatKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+DeviceIntPtr dev = (DeviceIntPtr) arg;
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+
+ if (xkbi->repeatKey == 0)
+ return 0;
+
+ AccessXKeyboardEvent(dev, ET_KeyPress, xkbi->repeatKey, TRUE);
+
+ return xkbi->desc->ctrls->repeat_interval;
+}
+
+void
+AccessXCancelRepeatKey(XkbSrvInfoPtr xkbi,KeyCode key)
+{
+ if (xkbi->repeatKey==key)
+ xkbi->repeatKey= 0;
+ return;
+}
+
+static CARD32
+AccessXSlowKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+DeviceIntPtr keybd;
+XkbSrvInfoPtr xkbi;
+XkbDescPtr xkb;
+XkbControlsPtr ctrls;
+
+ keybd= (DeviceIntPtr)arg;
+ xkbi= keybd->key->xkbInfo;
+ xkb= xkbi->desc;
+ ctrls= xkb->ctrls;
+ if (xkbi->slowKey!=0) {
+ xkbAccessXNotify ev;
+ KeySym *sym= XkbKeySymsPtr(xkb,xkbi->slowKey);
+ ev.detail= XkbAXN_SKAccept;
+ ev.keycode= xkbi->slowKey;
+ ev.slowKeysDelay= ctrls->slow_keys_delay;
+ ev.debounceDelay= ctrls->debounce_delay;
+ XkbSendAccessXNotify(keybd,&ev);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SKAcceptFBMask))
+ XkbDDXAccessXBeep(keybd,_BEEP_SLOW_ACCEPT,XkbSlowKeysMask);
+ AccessXKeyboardEvent(keybd, ET_KeyPress,xkbi->slowKey,FALSE);
+ /* check for magic sequences */
+ if ((ctrls->enabled_ctrls&XkbAccessXKeysMask) &&
+ ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L)))
+ xkbi->shiftKeyCount++;
+
+ /* Start repeating if necessary. Stop autorepeating if the user
+ * presses a non-modifier key that doesn't autorepeat.
+ */
+ if (keybd->kbdfeed->ctrl.autoRepeat &&
+ ((xkbi->slowKey != xkbi->mouseKey) || (!xkbi->mouseKeysAccel)) &&
+ (ctrls->enabled_ctrls&XkbRepeatKeysMask)) {
+ if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,xkbi->slowKey)) {
+ xkbi->repeatKey = xkbi->slowKey;
+ xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
+ 0, ctrls->repeat_delay,
+ AccessXRepeatKeyExpire, (pointer)keybd);
+ }
+ }
+ }
+ return 0;
+}
+
+static CARD32
+AccessXBounceKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
+
+ xkbi->inactiveKey= 0;
+ return 0;
+}
+
+static CARD32
+AccessXTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+DeviceIntPtr dev = (DeviceIntPtr)arg;
+XkbSrvInfoPtr xkbi= dev->key->xkbInfo;
+XkbControlsPtr ctrls= xkbi->desc->ctrls;
+XkbControlsRec old;
+xkbControlsNotify cn;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ if (xkbi->lastPtrEventTime) {
+ unsigned timeToWait = (ctrls->ax_timeout*1000);
+ unsigned timeElapsed = (now-xkbi->lastPtrEventTime);
+
+ if (timeToWait > timeElapsed)
+ return timeToWait - timeElapsed;
+ }
+ old= *ctrls;
+ xkbi->shiftKeyCount= 0;
+ ctrls->enabled_ctrls&= ~ctrls->axt_ctrls_mask;
+ ctrls->enabled_ctrls|=
+ (ctrls->axt_ctrls_values&ctrls->axt_ctrls_mask);
+ if (ctrls->axt_opts_mask) {
+ ctrls->ax_options&= ~ctrls->axt_opts_mask;
+ ctrls->ax_options|= (ctrls->axt_opts_values&ctrls->axt_opts_mask);
+ }
+ if (XkbComputeControlsNotify(dev,&old,ctrls,&cn,FALSE)) {
+ cn.keycode = 0;
+ cn.eventType = 0;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ XkbSendControlsNotify(dev,&cn);
+ }
+ XkbSetCauseUnknown(&cause);
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
+ if (ctrls->ax_options!=old.ax_options) {
+ unsigned set,cleared,bell;
+ set= ctrls->ax_options&(~old.ax_options);
+ cleared= (~ctrls->ax_options)&old.ax_options;
+ if (set && cleared) bell= _BEEP_FEATURE_CHANGE;
+ else if (set) bell= _BEEP_FEATURE_ON;
+ else bell= _BEEP_FEATURE_OFF;
+ XkbDDXAccessXBeep(dev,bell,XkbAccessXTimeoutMask);
+ }
+ xkbi->krgTimerActive= _OFF_TIMER;
+ return 0;
+}
+
+
+/************************************************************************/
+/* */
+/* AccessXFilterPressEvent */
+/* */
+/* Filter events before they get any further if SlowKeys is turned on. */
+/* In addition, this routine handles the ever so popular magic key */
+/* acts for turning various accessibility features on/off. */
+/* */
+/* Returns TRUE if this routine has discarded the event. */
+/* Returns FALSE if the event needs further processing. */
+/* */
+/************************************************************************/
+Bool
+AccessXFilterPressEvent( DeviceEvent* event,
+ DeviceIntPtr keybd)
+{
+XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+Bool ignoreKeyEvent = FALSE;
+KeyCode key = event->detail.key;
+KeySym * sym = XkbKeySymsPtr(xkbi->desc,key);
+
+ if (ctrls->enabled_ctrls&XkbAccessXKeysMask) {
+ /* check for magic sequences */
+ if ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L)) {
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SlowWarnFBMask)) {
+ xkbi->krgTimerActive = _KRG_WARN_TIMER;
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 4000,
+ AccessXKRGExpire, (pointer)keybd);
+ }
+ else {
+ xkbi->krgTimerActive = _KRG_TIMER;
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 8000,
+ AccessXKRGExpire, (pointer)keybd);
+ }
+ if (!(ctrls->enabled_ctrls & XkbSlowKeysMask)) {
+ CARD32 now= GetTimeInMillis();
+ if ((now-xkbi->lastShiftEventTime)>15000)
+ xkbi->shiftKeyCount= 1;
+ else xkbi->shiftKeyCount++;
+ xkbi->lastShiftEventTime= now;
+ }
+ }
+ else {
+ if (xkbi->krgTimerActive) {
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer,0, 0, NULL, NULL);
+ xkbi->krgTimerActive= _OFF_TIMER;
+ }
+ }
+ }
+
+ /* Don't transmit the KeyPress if SlowKeys is turned on;
+ * The wakeup handler will synthesize one for us if the user
+ * has held the key long enough.
+ */
+ if (ctrls->enabled_ctrls & XkbSlowKeysMask) {
+ xkbAccessXNotify ev;
+ /* If key was already pressed, ignore subsequent press events
+ * from the server's autorepeat
+ */
+ if(xkbi->slowKey == key)
+ return TRUE;
+ ev.detail= XkbAXN_SKPress;
+ ev.keycode= key;
+ ev.slowKeysDelay= ctrls->slow_keys_delay;
+ ev.debounceDelay= ctrls->debounce_delay;
+ XkbSendAccessXNotify(keybd,&ev);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SKPressFBMask))
+ XkbDDXAccessXBeep(keybd,_BEEP_SLOW_PRESS,XkbSlowKeysMask);
+ xkbi->slowKey= key;
+ xkbi->slowKeysTimer = TimerSet(xkbi->slowKeysTimer,
+ 0, ctrls->slow_keys_delay,
+ AccessXSlowKeyExpire, (pointer)keybd);
+ ignoreKeyEvent = TRUE;
+ }
+
+ /* Don't transmit the KeyPress if BounceKeys is turned on
+ * and the user pressed the same key within a given time period
+ * from the last release.
+ */
+ else if ((ctrls->enabled_ctrls & XkbBounceKeysMask) &&
+ (key == xkbi->inactiveKey)) {
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_BKRejectFBMask))
+ XkbDDXAccessXBeep(keybd,_BEEP_BOUNCE_REJECT,XkbBounceKeysMask);
+ ignoreKeyEvent = TRUE;
+ }
+
+ /* Start repeating if necessary. Stop autorepeating if the user
+ * presses a non-modifier key that doesn't autorepeat.
+ */
+ if (XkbDDXUsesSoftRepeat(keybd)) {
+ if ((keybd->kbdfeed->ctrl.autoRepeat) &&
+ ((ctrls->enabled_ctrls&(XkbSlowKeysMask|XkbRepeatKeysMask))==
+ XkbRepeatKeysMask)) {
+ if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,key)) {
+ if (xkbDebugFlags&0x10)
+ DebugF("Starting software autorepeat...\n");
+ if (xkbi->repeatKey == key)
+ ignoreKeyEvent = TRUE;
+ else {
+ xkbi->repeatKey = key;
+ xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
+ 0, ctrls->repeat_delay,
+ AccessXRepeatKeyExpire, (pointer)keybd);
+ }
+ }
+ }
+ }
+
+ /* Check for two keys being pressed at the same time. This section
+ * essentially says the following:
+ *
+ * If StickyKeys is on, and a modifier is currently being held down,
+ * and one of the following is true: the current key is not a modifier
+ * or the currentKey is a modifier, but not the only modifier being
+ * held down, turn StickyKeys off if the TwoKeys off ctrl is set.
+ */
+ if ((ctrls->enabled_ctrls & XkbStickyKeysMask) &&
+ (xkbi->state.base_mods!=0) &&
+ (XkbAX_NeedOption(ctrls,XkbAX_TwoKeysMask))) {
+ xkbControlsNotify cn;
+ cn.keycode = key;
+ cn.eventType = KeyPress;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ AccessXStickyKeysTurnOff(keybd,&cn);
+ }
+
+ if (!ignoreKeyEvent)
+ XkbProcessKeyboardEvent(event, keybd);
+ return ignoreKeyEvent;
+} /* AccessXFilterPressEvent */
+
+/************************************************************************/
+/* */
+/* AccessXFilterReleaseEvent */
+/* */
+/* Filter events before they get any further if SlowKeys is turned on. */
+/* In addition, this routine handles the ever so popular magic key */
+/* acts for turning various accessibility features on/off. */
+/* */
+/* Returns TRUE if this routine has discarded the event. */
+/* Returns FALSE if the event needs further processing. */
+/* */
+/************************************************************************/
+Bool
+AccessXFilterReleaseEvent( DeviceEvent* event,
+ DeviceIntPtr keybd)
+{
+XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+KeyCode key = event->detail.key;
+Bool ignoreKeyEvent = FALSE;
+
+ /* Don't transmit the KeyRelease if BounceKeys is on and
+ * this is the release of a key that was ignored due to
+ * BounceKeys.
+ */
+ if (ctrls->enabled_ctrls & XkbBounceKeysMask) {
+ if ((key!=xkbi->mouseKey)&&(!BitIsOn(keybd->key->down,key)))
+ ignoreKeyEvent = TRUE;
+ xkbi->inactiveKey= key;
+ xkbi->bounceKeysTimer= TimerSet(xkbi->bounceKeysTimer, 0,
+ ctrls->debounce_delay,
+ AccessXBounceKeyExpire, (pointer)keybd);
+ }
+
+ /* Don't transmit the KeyRelease if SlowKeys is turned on and
+ * the user didn't hold the key long enough. We know we passed
+ * the key if the down bit was set by CoreProcessKeyboadEvent.
+ */
+ if (ctrls->enabled_ctrls & XkbSlowKeysMask) {
+ xkbAccessXNotify ev;
+ unsigned beep_type;
+ ev.keycode= key;
+ ev.slowKeysDelay= ctrls->slow_keys_delay;
+ ev.debounceDelay= ctrls->debounce_delay;
+ if (BitIsOn(keybd->key->down,key) || (xkbi->mouseKey == key)) {
+ ev.detail= XkbAXN_SKRelease;
+ beep_type= _BEEP_SLOW_RELEASE;
+ }
+ else {
+ ev.detail= XkbAXN_SKReject;
+ beep_type= _BEEP_SLOW_REJECT;
+ ignoreKeyEvent = TRUE;
+ }
+ XkbSendAccessXNotify(keybd,&ev);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SKRejectFBMask)) {
+ XkbDDXAccessXBeep(keybd,beep_type,XkbSlowKeysMask);
+ }
+ if (xkbi->slowKey==key)
+ xkbi->slowKey= 0;
+ }
+
+ /* Stop Repeating if the user releases the key that is currently
+ * repeating.
+ */
+ if (xkbi->repeatKey==key) {
+ xkbi->repeatKey= 0;
+ }
+
+ if ((ctrls->enabled_ctrls&XkbAccessXTimeoutMask)&&(ctrls->ax_timeout>0)) {
+ xkbi->lastPtrEventTime= 0;
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0,
+ ctrls->ax_timeout*1000,
+ AccessXTimeoutExpire, (pointer)keybd);
+ xkbi->krgTimerActive= _ALL_TIMEOUT_TIMER;
+ }
+ else if (xkbi->krgTimerActive!=_OFF_TIMER) {
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 0, NULL, NULL);
+ xkbi->krgTimerActive= _OFF_TIMER;
+ }
+
+ /* Keep track of how many times the Shift key has been pressed.
+ * If it has been pressed and released 5 times in a row, toggle
+ * the state of StickyKeys.
+ */
+ if ((!ignoreKeyEvent)&&(xkbi->shiftKeyCount)) {
+ KeySym *pSym= XkbKeySymsPtr(xkbi->desc,key);
+ if ((pSym[0]!=XK_Shift_L)&&(pSym[0]!=XK_Shift_R)) {
+ xkbi->shiftKeyCount= 0;
+ }
+ else if (xkbi->shiftKeyCount>=5) {
+ xkbControlsNotify cn;
+ cn.keycode = key;
+ cn.eventType = KeyPress;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ if (ctrls->enabled_ctrls & XkbStickyKeysMask)
+ AccessXStickyKeysTurnOff(keybd,&cn);
+ else
+ AccessXStickyKeysTurnOn(keybd,&cn);
+ xkbi->shiftKeyCount= 0;
+ }
+ }
+
+ if (!ignoreKeyEvent)
+ XkbProcessKeyboardEvent(event, keybd);
+ return ignoreKeyEvent;
+
+} /* AccessXFilterReleaseEvent */
+
+/************************************************************************/
+/* */
+/* ProcessPointerEvent */
+/* */
+/* This routine merely sets the shiftKeyCount and clears the keyboard */
+/* response group timer (if necessary) on a mouse event. This is so */
+/* multiple shifts with just the mouse and shift-drags with the mouse */
+/* don't accidentally turn on StickyKeys or the Keyboard Response Group.*/
+/* */
+/************************************************************************/
+extern int xkbDevicePrivateIndex;
+extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer);
+void
+ProcessPointerEvent( InternalEvent *ev,
+ DeviceIntPtr mouse)
+{
+DeviceIntPtr dev;
+XkbSrvInfoPtr xkbi = NULL;
+unsigned changed = 0;
+ProcessInputProc backupproc;
+xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
+DeviceEvent *event = &ev->device_event;
+
+ dev = (IsMaster(mouse) || mouse->u.master) ? GetMaster(mouse, MASTER_KEYBOARD) : mouse;
+
+ if (dev && dev->key)
+ {
+ xkbi = dev->key->xkbInfo;
+ xkbi->shiftKeyCount = 0;
+ xkbi->lastPtrEventTime= event->time;
+ }
+
+ if (event->type == ET_ButtonPress) {
+ changed |= XkbPointerButtonMask;
+ }
+ else if (event->type == ET_ButtonRelease) {
+ if (xkbi)
+ xkbi->lockedPtrButtons&= ~(1 << (event->detail.key & 0x7));
+ changed |= XkbPointerButtonMask;
+ }
+
+ /* Guesswork. mostly.
+ * xkb actuall goes through some effort to transparently wrap the
+ * processInputProcs (see XkbSetExtension). But we all love fun, so the
+ * previous XKB implementation just hardcoded the CPPE call here instead
+ * of unwrapping like anybody with any sense of decency would do.
+ * I got no clue what the correct thing to do is, but my guess is that
+ * it's not hardcoding. I may be wrong. whatever it is, don't come whining
+ * to me. I just work here.
+ *
+ * Anyway. here's the old call, if you don't like the wrapping, revert it.
+ *
+ * CoreProcessPointerEvent(xE,mouse,count);
+ *
+ * see. it's still steaming. told you. (whot)
+ */
+
+ UNWRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, backupproc);
+ mouse->public.processInputProc(ev, mouse);
+ COND_WRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr,
+ backupproc, xkbUnwrapProc);
+
+ if (!xkbi)
+ return;
+
+ xkbi->state.ptr_buttons = (mouse->button) ? mouse->button->state : 0;
+
+ /* clear any latched modifiers */
+ if ( xkbi->state.latched_mods && (event->type == ET_ButtonRelease) ) {
+ unsigned changed_leds;
+ XkbStateRec oldState;
+ XkbSrvLedInfoPtr sli;
+
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ oldState= xkbi->state;
+ XkbLatchModifiers(dev,0xFF,0x00);
+
+ XkbComputeDerivedState(xkbi);
+ changed |= XkbStateChangedFlags(&oldState,&xkbi->state);
+ if (changed&sli->usedComponents) {
+ changed_leds= XkbIndicatorsToUpdate(dev,changed,FALSE);
+ if (changed_leds) {
+ XkbEventCauseRec cause;
+ XkbSetCauseKey(&cause,(event->detail.key & 0x7), event->type);
+ XkbUpdateIndicators(dev,changed_leds,TRUE,NULL,&cause);
+ }
+ }
+ }
+
+ if (((xkbi->flags&_XkbStateNotifyInProgress)==0)&&(changed!=0)) {
+ xkbStateNotify sn;
+ sn.keycode= event->detail.key;
+ sn.eventType= event->type;
+ sn.requestMajor = sn.requestMinor = 0;
+ sn.changed= changed;
+ XkbSendStateNotify(dev,&sn);
+ }
+
+} /* ProcessPointerEvent */
+
+
+
+
diff --git a/xorg-server/xkb/xkbActions.c b/xorg-server/xkb/xkbActions.c index 03f23a777..44675c9fe 100644 --- a/xorg-server/xkb/xkbActions.c +++ b/xorg-server/xkb/xkbActions.c @@ -43,8 +43,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "mi.h"
#define EXTENSION_EVENT_BASE 64
-static int xkbDevicePrivateKeyIndex;
-DevPrivateKey xkbDevicePrivateKey = &xkbDevicePrivateKeyIndex;
+DevPrivateKeyRec xkbDevicePrivateKeyRec;
static void XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button);
static void XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y);
@@ -64,6 +63,11 @@ xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, backupproc,xkbUnwrapProc);
}
+Bool
+XkbInitPrivates(void)
+{
+ return dixRegisterPrivateKey(&xkbDevicePrivateKeyRec, PRIVATE_DEVICE, 0);
+}
void
XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
@@ -1033,7 +1037,7 @@ register int i; xkbi->filters= realloc(xkbi->filters,
xkbi->szFilters * sizeof(XkbFilterRec));
/* 6/21/93 (ef) -- XXX! deal with allocation failure */
- bzero(&xkbi->filters[xkbi->szFilters/2],
+ memset(&xkbi->filters[xkbi->szFilters/2], 0,
(xkbi->szFilters/2)*sizeof(XkbFilterRec));
return &xkbi->filters[xkbi->szFilters/2];
}
diff --git a/xorg-server/xkb/xkbInit.c b/xorg-server/xkb/xkbInit.c index 3da625a5b..eb3e04d64 100644 --- a/xorg-server/xkb/xkbInit.c +++ b/xorg-server/xkb/xkbInit.c @@ -43,6 +43,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "inputstr.h"
#include "opaque.h"
#include "property.h"
+#include "scrnintstr.h"
#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
#include "xkbgeom.h"
@@ -210,7 +211,7 @@ char * pval; ErrorF("[xkb] Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
out,len);
}
- dixChangeWindowProperty(serverClient, WindowTable[0], name, XA_STRING, 8,
+ dixChangeWindowProperty(serverClient, screenInfo.screens[0]->root, name, XA_STRING, 8,
PropModeReplace, len, pval, TRUE);
free(pval);
return TRUE;
@@ -219,20 +220,15 @@ char * pval; static void
XkbSetRulesUsed(XkbRMLVOSet *rmlvo)
{
- if (XkbRulesUsed)
- free(XkbRulesUsed);
+ free(XkbRulesUsed);
XkbRulesUsed= (rmlvo->rules?_XkbDupString(rmlvo->rules):NULL);
- if (XkbModelUsed)
- free(XkbModelUsed);
+ free(XkbModelUsed);
XkbModelUsed= (rmlvo->model?_XkbDupString(rmlvo->model):NULL);
- if (XkbLayoutUsed)
- free(XkbLayoutUsed);
+ free(XkbLayoutUsed);
XkbLayoutUsed= (rmlvo->layout?_XkbDupString(rmlvo->layout):NULL);
- if (XkbVariantUsed)
- free(XkbVariantUsed);
+ free(XkbVariantUsed);
XkbVariantUsed= (rmlvo->variant?_XkbDupString(rmlvo->variant):NULL);
- if (XkbOptionsUsed)
- free(XkbOptionsUsed);
+ free(XkbOptionsUsed);
XkbOptionsUsed= (rmlvo->options?_XkbDupString(rmlvo->options):NULL);
if (XkbWantRulesProp)
QueueWorkProc(XkbWriteRulesProp,NULL,NULL);
@@ -243,28 +239,23 @@ void XkbSetRulesDflts(XkbRMLVOSet *rmlvo)
{
if (rmlvo->rules) {
- if (XkbRulesDflt)
- free(XkbRulesDflt);
+ free(XkbRulesDflt);
XkbRulesDflt= _XkbDupString(rmlvo->rules);
}
if (rmlvo->model) {
- if (XkbModelDflt)
- free(XkbModelDflt);
+ free(XkbModelDflt);
XkbModelDflt= _XkbDupString(rmlvo->model);
}
if (rmlvo->layout) {
- if (XkbLayoutDflt)
- free(XkbLayoutDflt);
+ free(XkbLayoutDflt);
XkbLayoutDflt= _XkbDupString(rmlvo->layout);
}
if (rmlvo->variant) {
- if (XkbVariantDflt)
- free(XkbVariantDflt);
+ free(XkbVariantDflt);
XkbVariantDflt= _XkbDupString(rmlvo->variant);
}
if (rmlvo->options) {
- if (XkbOptionsDflt)
- free(XkbOptionsDflt);
+ free(XkbOptionsDflt);
XkbOptionsDflt= _XkbDupString(rmlvo->options);
}
return;
diff --git a/xorg-server/xkb/xkbLEDs.c b/xorg-server/xkb/xkbLEDs.c index a0a037fd7..65d8739be 100644 --- a/xorg-server/xkb/xkbLEDs.c +++ b/xorg-server/xkb/xkbLEDs.c @@ -166,7 +166,7 @@ XkbStatePtr state; }
}
}
- return (stateChange || ctrlChange);
+ return stateChange || ctrlChange;
}
/*
@@ -263,7 +263,7 @@ unsigned oldState; if (ed==NULL) {
ed= &my_ed;
- bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ memset((char *)ed, 0, sizeof(xkbExtensionDeviceNotify));
}
else if ((ed->reason&XkbXI_IndicatorsMask)&&
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
@@ -273,7 +273,7 @@ unsigned oldState; if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
if (changes==NULL) {
changes= &my_changes;
- bzero((char *)changes,sizeof(XkbChangesRec));
+ memset((char *)changes, 0, sizeof(XkbChangesRec));
}
changes->indicators.state_changes|= affected;
}
@@ -362,8 +362,8 @@ XkbChangesRec changes; xkbExtensionDeviceNotify ed;
unsigned side_affected;
- bzero((char *)&changes,sizeof(XkbChangesRec));
- bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
+ memset((char *)&changes, 0, sizeof(XkbChangesRec));
+ memset((char *)&ed, 0, sizeof(xkbExtensionDeviceNotify));
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
sli->explicitState&= ~affect;
sli->explicitState|= (affect&values);
@@ -605,8 +605,8 @@ void XkbFreeSrvLedInfo(XkbSrvLedInfoPtr sli)
{
if ((sli->flags&XkbSLI_IsDefault)==0) {
- if (sli->maps) free(sli->maps);
- if (sli->names) free(sli->names);
+ free(sli->maps);
+ free(sli->names);
}
sli->maps= NULL;
sli->names= NULL;
@@ -735,7 +735,7 @@ XkbFlushLedEvents( DeviceIntPtr dev, if (changes->indicators.state_changes)
XkbDDXUpdateDeviceIndicators(dev,sli,sli->effectiveState);
XkbSendNotification(kbd,changes,cause);
- bzero((char *)changes,sizeof(XkbChangesRec));
+ memset((char *)changes, 0, sizeof(XkbChangesRec));
if (XkbAX_NeedFeedback(kbd->key->xkbInfo->desc->ctrls, XkbAX_IndicatorFBMask)) {
if (sli->effectiveState)
@@ -751,7 +751,7 @@ XkbFlushLedEvents( DeviceIntPtr dev, XkbDDXUpdateDeviceIndicators(dev,sli,sli->effectiveState);
XkbSendExtensionDeviceNotify(dev,cause->client,ed);
}
- bzero((char *)ed,sizeof(XkbExtensionDeviceNotify));
+ memset((char *)ed, 0, sizeof(XkbExtensionDeviceNotify));
}
return;
}
@@ -778,7 +778,7 @@ xkbExtensionDeviceNotify my_ed; if (ed==NULL) {
ed= &my_ed;
- bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ memset((char *)ed, 0, sizeof(xkbExtensionDeviceNotify));
}
else if ((ed->reason&XkbXI_IndicatorsMask)&&
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
@@ -788,7 +788,7 @@ xkbExtensionDeviceNotify my_ed; if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
if (changes==NULL) {
changes= &my_changes;
- bzero((char *)changes,sizeof(XkbChangesRec));
+ memset((char *)changes, 0, sizeof(XkbChangesRec));
}
changes->names.changed|= XkbIndicatorNamesMask;
changes->names.changed_indicators|= changed_names;
@@ -855,7 +855,7 @@ xkbExtensionDeviceNotify my_ed; if (ed==NULL) {
ed= &my_ed;
- bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ memset((char *)ed, 0, sizeof(xkbExtensionDeviceNotify));
}
else if ((ed->reason&XkbXI_IndicatorsMask)&&
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
@@ -865,7 +865,7 @@ xkbExtensionDeviceNotify my_ed; if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
if (changes==NULL) {
changes= &my_changes;
- bzero((char *)changes,sizeof(XkbChangesRec));
+ memset((char *)changes, 0, sizeof(XkbChangesRec));
}
changes->indicators.map_changes|= changed_maps;
}
@@ -917,7 +917,7 @@ Bool kb_changed; if (changes==NULL) {
changes= &my_changes;
- bzero((char *)changes,sizeof(XkbChangesRec));
+ memset((char *)changes, 0, sizeof(XkbChangesRec));
}
kb_changed= FALSE;
@@ -943,7 +943,7 @@ Bool kb_changed; if (ed==NULL) {
ed= &my_ed;
- bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ memset((char *)ed, 0, sizeof(xkbExtensionDeviceNotify));
}
else if (affected&&(ed->reason&XkbXI_IndicatorsMask)&&
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
diff --git a/xorg-server/xkb/xkbUtils.c b/xorg-server/xkb/xkbUtils.c index ab433a800..6b6e6d379 100644 --- a/xorg-server/xkb/xkbUtils.c +++ b/xorg-server/xkb/xkbUtils.c @@ -282,7 +282,7 @@ register unsigned key; register unsigned bit,i;
unsigned present;
- bzero(newVMods,XkbNumVirtualMods);
+ memset(newVMods, 0, XkbNumVirtualMods);
present= 0;
for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) {
if (xkb->server->vmodmap[key]==0)
@@ -588,7 +588,7 @@ XkbSrvInfoPtr xkbi = dev->key->xkbInfo; xkbMapNotify mn;
xkbi->desc->server->explicit[key]|= XkbExplicitAutoRepeatMask;
- bzero(&mn,sizeof(mn));
+ memset(&mn, 0, sizeof(mn));
mn.changed= XkbExplicitComponentsMask;
mn.firstKeyExplicit= key;
mn.nKeyExplicit= 1;
@@ -919,11 +919,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) if (src->map->syms) {
if (src->map->size_syms != dst->map->size_syms) {
- if (dst->map->syms)
- tmp = realloc(dst->map->syms,
- src->map->size_syms * sizeof(KeySym));
- else
- tmp = malloc(src->map->size_syms * sizeof(KeySym));
+ tmp = realloc(dst->map->syms,
+ src->map->size_syms * sizeof(KeySym));
if (!tmp)
return FALSE;
dst->map->syms = tmp;
@@ -933,23 +930,16 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) src->map->size_syms * sizeof(KeySym));
}
else {
- if (dst->map->syms) {
- free(dst->map->syms);
- dst->map->syms = NULL;
- }
+ free(dst->map->syms);
+ dst->map->syms = NULL;
}
dst->map->num_syms = src->map->num_syms;
dst->map->size_syms = src->map->size_syms;
if (src->map->key_sym_map) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->map->key_sym_map)
- tmp = realloc(dst->map->key_sym_map,
- (src->max_key_code + 1) *
- sizeof(XkbSymMapRec));
- else
- tmp = malloc((src->max_key_code + 1) *
- sizeof(XkbSymMapRec));
+ tmp = realloc(dst->map->key_sym_map,
+ (src->max_key_code + 1) * sizeof(XkbSymMapRec));
if (!tmp)
return FALSE;
dst->map->key_sym_map = tmp;
@@ -958,10 +948,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) (src->max_key_code + 1) * sizeof(XkbSymMapRec));
}
else {
- if (dst->map->key_sym_map) {
- free(dst->map->key_sym_map);
- dst->map->key_sym_map = NULL;
- }
+ free(dst->map->key_sym_map);
+ dst->map->key_sym_map = NULL;
}
if (src->map->types && src->map->num_types) {
@@ -973,7 +961,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) if (!tmp)
return FALSE;
dst->map->types = tmp;
- bzero(dst->map->types + dst->map->num_types,
+ memset(dst->map->types + dst->map->num_types, 0,
(src->map->num_types - dst->map->num_types) *
sizeof(XkbKeyTypeRec));
}
@@ -988,15 +976,12 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) dst->map->types) {
for (i = src->map->num_types, dtype = (dst->map->types + i);
i < dst->map->num_types; i++, dtype++) {
- if (dtype->level_names)
- free(dtype->level_names);
+ free(dtype->level_names);
dtype->level_names = NULL;
dtype->num_levels = 0;
if (dtype->map_count) {
- if (dtype->map)
- free(dtype->map);
- if (dtype->preserve)
- free(dtype->preserve);
+ free(dtype->map);
+ free(dtype->preserve);
}
}
}
@@ -1099,10 +1084,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) }
else {
if (dtype->map_count && i < dst->map->num_types) {
- if (dtype->map)
- free(dtype->map);
- if (dtype->preserve)
- free(dtype->preserve);
+ free(dtype->map);
+ free(dtype->preserve);
}
dtype->map_count = 0;
dtype->map = NULL;
@@ -1117,26 +1100,22 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) if (dst->map->types) {
for (i = 0, dtype = dst->map->types; i < dst->map->num_types;
i++, dtype++) {
- if (dtype->level_names)
- free(dtype->level_names);
+ free(dtype->level_names);
if (dtype->map && dtype->map_count)
free(dtype->map);
if (dtype->preserve && dtype->map_count)
free(dtype->preserve);
}
- free(dst->map->types);
- dst->map->types = NULL;
}
+ free(dst->map->types);
+ dst->map->types = NULL;
dst->map->num_types = 0;
dst->map->size_types = 0;
}
if (src->map->modmap) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->map->modmap)
- tmp = realloc(dst->map->modmap, src->max_key_code + 1);
- else
- tmp = malloc(src->max_key_code + 1);
+ tmp = realloc(dst->map->modmap, src->max_key_code + 1);
if (!tmp)
return FALSE;
dst->map->modmap = tmp;
@@ -1144,10 +1123,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) memcpy(dst->map->modmap, src->map->modmap, src->max_key_code + 1);
}
else {
- if (dst->map->modmap) {
- free(dst->map->modmap);
- dst->map->modmap = NULL;
- }
+ free(dst->map->modmap);
+ dst->map->modmap = NULL;
}
}
else {
@@ -1174,10 +1151,7 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) if (src->server->explicit) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->server->explicit)
- tmp = realloc(dst->server->explicit, src->max_key_code + 1);
- else
- tmp = malloc(src->max_key_code + 1);
+ tmp = realloc(dst->server->explicit, src->max_key_code + 1);
if (!tmp)
return FALSE;
dst->server->explicit = tmp;
@@ -1186,19 +1160,14 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) src->max_key_code + 1);
}
else {
- if (dst->server->explicit) {
- free(dst->server->explicit);
- dst->server->explicit = NULL;
- }
+ free(dst->server->explicit);
+ dst->server->explicit = NULL;
}
if (src->server->acts) {
if (src->server->size_acts != dst->server->size_acts) {
- if (dst->server->acts)
- tmp = realloc(dst->server->acts,
- src->server->size_acts * sizeof(XkbAction));
- else
- tmp = malloc(src->server->size_acts * sizeof(XkbAction));
+ tmp = realloc(dst->server->acts,
+ src->server->size_acts * sizeof(XkbAction));
if (!tmp)
return FALSE;
dst->server->acts = tmp;
@@ -1207,23 +1176,16 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) src->server->size_acts * sizeof(XkbAction));
}
else {
- if (dst->server->acts) {
- free(dst->server->acts);
- dst->server->acts = NULL;
- }
+ free(dst->server->acts);
+ dst->server->acts = NULL;
}
dst->server->size_acts = src->server->size_acts;
dst->server->num_acts = src->server->num_acts;
if (src->server->key_acts) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->server->key_acts)
- tmp = realloc(dst->server->key_acts,
- (src->max_key_code + 1) *
- sizeof(unsigned short));
- else
- tmp = malloc((src->max_key_code + 1) *
- sizeof(unsigned short));
+ tmp = realloc(dst->server->key_acts,
+ (src->max_key_code + 1) * sizeof(unsigned short));
if (!tmp)
return FALSE;
dst->server->key_acts = tmp;
@@ -1232,21 +1194,14 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) (src->max_key_code + 1) * sizeof(unsigned short));
}
else {
- if (dst->server->key_acts) {
- free(dst->server->key_acts);
- dst->server->key_acts = NULL;
- }
+ free(dst->server->key_acts);
+ dst->server->key_acts = NULL;
}
if (src->server->behaviors) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->server->behaviors)
- tmp = realloc(dst->server->behaviors,
- (src->max_key_code + 1) *
- sizeof(XkbBehavior));
- else
- tmp = malloc((src->max_key_code + 1) *
- sizeof(XkbBehavior));
+ tmp = realloc(dst->server->behaviors,
+ (src->max_key_code + 1) * sizeof(XkbBehavior));
if (!tmp)
return FALSE;
dst->server->behaviors = tmp;
@@ -1255,23 +1210,16 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) (src->max_key_code + 1) * sizeof(XkbBehavior));
}
else {
- if (dst->server->behaviors) {
- free(dst->server->behaviors);
- dst->server->behaviors = NULL;
- }
+ free(dst->server->behaviors);
+ dst->server->behaviors = NULL;
}
memcpy(dst->server->vmods, src->server->vmods, XkbNumVirtualMods);
if (src->server->vmodmap) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->server->vmodmap)
- tmp = realloc(dst->server->vmodmap,
- (src->max_key_code + 1) *
- sizeof(unsigned short));
- else
- tmp = malloc((src->max_key_code + 1) *
- sizeof(unsigned short));
+ tmp = realloc(dst->server->vmodmap,
+ (src->max_key_code + 1) * sizeof(unsigned short));
if (!tmp)
return FALSE;
dst->server->vmodmap = tmp;
@@ -1280,10 +1228,8 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) (src->max_key_code + 1) * sizeof(unsigned short));
}
else {
- if (dst->server->vmodmap) {
- free(dst->server->vmodmap);
- dst->server->vmodmap = NULL;
- }
+ free(dst->server->vmodmap);
+ dst->server->vmodmap = NULL;
}
}
else {
@@ -1309,12 +1255,8 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst) if (src->names->keys) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->names->keys)
- tmp = realloc(dst->names->keys, (src->max_key_code + 1) *
- sizeof(XkbKeyNameRec));
- else
- tmp = malloc((src->max_key_code + 1) *
- sizeof(XkbKeyNameRec));
+ tmp = realloc(dst->names->keys,
+ (src->max_key_code + 1) * sizeof(XkbKeyNameRec));
if (!tmp)
return FALSE;
dst->names->keys = tmp;
@@ -1323,21 +1265,15 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst) (src->max_key_code + 1) * sizeof(XkbKeyNameRec));
}
else {
- if (dst->names->keys) {
- free(dst->names->keys);
- dst->names->keys = NULL;
- }
+ free(dst->names->keys);
+ dst->names->keys = NULL;
}
if (src->names->num_key_aliases) {
if (src->names->num_key_aliases != dst->names->num_key_aliases) {
- if (dst->names->key_aliases)
- tmp = realloc(dst->names->key_aliases,
- src->names->num_key_aliases *
- sizeof(XkbKeyAliasRec));
- else
- tmp = malloc(src->names->num_key_aliases *
- sizeof(XkbKeyAliasRec));
+ tmp = realloc(dst->names->key_aliases,
+ src->names->num_key_aliases *
+ sizeof(XkbKeyAliasRec));
if (!tmp)
return FALSE;
dst->names->key_aliases = tmp;
@@ -1346,20 +1282,15 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst) src->names->num_key_aliases * sizeof(XkbKeyAliasRec));
}
else {
- if (dst->names->key_aliases) {
- free(dst->names->key_aliases);
- dst->names->key_aliases = NULL;
- }
+ free(dst->names->key_aliases);
+ dst->names->key_aliases = NULL;
}
dst->names->num_key_aliases = src->names->num_key_aliases;
if (src->names->num_rg) {
if (src->names->num_rg != dst->names->num_rg) {
- if (dst->names->radio_groups)
- tmp = realloc(dst->names->radio_groups,
- src->names->num_rg * sizeof(Atom));
- else
- tmp = malloc(src->names->num_rg * sizeof(Atom));
+ tmp = realloc(dst->names->radio_groups,
+ src->names->num_rg * sizeof(Atom));
if (!tmp)
return FALSE;
dst->names->radio_groups = tmp;
@@ -1368,8 +1299,7 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst) src->names->num_rg * sizeof(Atom));
}
else {
- if (dst->names->radio_groups)
- free(dst->names->radio_groups);
+ free(dst->names->radio_groups);
}
dst->names->num_rg = src->names->num_rg;
@@ -1410,13 +1340,8 @@ _XkbCopyCompat(XkbDescPtr src, XkbDescPtr dst) if (src->compat->sym_interpret && src->compat->num_si) {
if (src->compat->num_si != dst->compat->size_si) {
- if (dst->compat->sym_interpret)
- tmp = realloc(dst->compat->sym_interpret,
- src->compat->num_si *
- sizeof(XkbSymInterpretRec));
- else
- tmp = malloc(src->compat->num_si *
- sizeof(XkbSymInterpretRec));
+ tmp = realloc(dst->compat->sym_interpret,
+ src->compat->num_si * sizeof(XkbSymInterpretRec));
if (!tmp)
return FALSE;
dst->compat->sym_interpret = tmp;
@@ -1501,7 +1426,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) dst->geom->sz_properties = src->geom->num_properties;
if (dst->geom->sz_properties > dst->geom->num_properties) {
- bzero(dst->geom->properties + dst->geom->num_properties,
+ memset(dst->geom->properties + dst->geom->num_properties, 0,
(dst->geom->sz_properties - dst->geom->num_properties) *
sizeof(XkbPropertyRec));
}
@@ -1579,7 +1504,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) dst->geom->sz_colors = src->geom->num_colors;
if (dst->geom->sz_colors > dst->geom->num_colors) {
- bzero(dst->geom->colors + dst->geom->num_colors,
+ memset(dst->geom->colors + dst->geom->num_colors, 0,
(dst->geom->sz_colors - dst->geom->num_colors) *
sizeof(XkbColorRec));
}
@@ -1750,25 +1675,18 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) j < dsection->num_doodads;
j++, ddoodad++) {
if (ddoodad->any.type == XkbTextDoodad) {
- if (ddoodad->text.text) {
- free(ddoodad->text.text);
- ddoodad->text.text = NULL;
- }
- if (ddoodad->text.font) {
- free(ddoodad->text.font);
- ddoodad->text.font = NULL;
- }
+ free(ddoodad->text.text);
+ ddoodad->text.text = NULL;
+ free(ddoodad->text.font);
+ ddoodad->text.font = NULL;
}
else if (ddoodad->any.type == XkbLogoDoodad) {
- if (ddoodad->logo.logo_name) {
- free(ddoodad->logo.logo_name);
- ddoodad->logo.logo_name = NULL;
- }
+ free(ddoodad->logo.logo_name);
+ ddoodad->logo.logo_name = NULL;
}
}
- if (dsection->num_doodads)
- free(dsection->doodads);
+ free(dsection->doodads);
}
dst->geom->num_sections = 0;
@@ -1877,20 +1795,14 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) i < dst->geom->num_doodads;
i++, ddoodad++) {
if (ddoodad->any.type == XkbTextDoodad) {
- if (ddoodad->text.text) {
- free(ddoodad->text.text);
- ddoodad->text.text = NULL;
- }
- if (ddoodad->text.font) {
- free(ddoodad->text.font);
- ddoodad->text.font = NULL;
- }
+ free(ddoodad->text.text);
+ ddoodad->text.text = NULL;
+ free(ddoodad->text.font);
+ ddoodad->text.font = NULL;
}
else if (ddoodad->any.type == XkbLogoDoodad) {
- if (ddoodad->logo.logo_name) {
- free(ddoodad->logo.logo_name);
- ddoodad->logo.logo_name = NULL;
- }
+ free(ddoodad->logo.logo_name);
+ ddoodad->logo.logo_name = NULL;
}
}
dst->geom->num_doodads = 0;
@@ -1966,9 +1878,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) dst->geom->num_key_aliases = dst->geom->sz_key_aliases;
}
else {
- if (dst->geom->key_aliases) {
- free(dst->geom->key_aliases);
- }
+ free(dst->geom->key_aliases);
dst->geom->key_aliases = NULL;
dst->geom->num_key_aliases = 0;
dst->geom->sz_key_aliases = 0;
@@ -1998,9 +1908,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) dst->geom->base_color = &(dst->geom->colors[i]);
}
else {
- if (dst->geom->label_font) {
- free(dst->geom->label_font);
- }
+ free(dst->geom->label_font);
dst->geom->label_font = NULL;
dst->geom->label_color = NULL;
dst->geom->base_color = NULL;
@@ -2035,10 +1943,8 @@ _XkbCopyIndicators(XkbDescPtr src, XkbDescPtr dst) memcpy(dst->indicators, src->indicators, sizeof(XkbIndicatorRec));
}
else {
- if (dst->indicators) {
- free(dst->indicators);
- dst->indicators = NULL;
- }
+ free(dst->indicators);
+ dst->indicators = NULL;
}
return TRUE;
}
@@ -2056,10 +1962,8 @@ _XkbCopyControls(XkbDescPtr src, XkbDescPtr dst) memcpy(dst->ctrls, src->ctrls, sizeof(XkbControlsRec));
}
else {
- if (dst->ctrls) {
- free(dst->ctrls);
- dst->ctrls = NULL;
- }
+ free(dst->ctrls);
+ dst->ctrls = NULL;
}
return TRUE;
}
diff --git a/xorg-server/xkb/xkbfmisc.c b/xorg-server/xkb/xkbfmisc.c index 103e609a9..382b6ebba 100644 --- a/xorg-server/xkb/xkbfmisc.c +++ b/xorg-server/xkb/xkbfmisc.c @@ -1,441 +1,441 @@ -/************************************************************ - Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc. - - Permission to use, copy, modify, and distribute this - software and its documentation for any purpose and without - fee is hereby granted, provided that the above copyright - notice appear in all copies and that both that copyright - notice and this permission notice appear in supporting - documentation, and that the name of Silicon Graphics not be - used in advertising or publicity pertaining to distribution - of the software without specific prior written permission. - Silicon Graphics makes no representation about the suitability - of this software for any purpose. It is provided "as is" - without any express or implied warranty. - - SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH - THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ********************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdio.h> -#include <ctype.h> -#include <stdlib.h> - -#include <X11/Xos.h> -#include <X11/Xfuncs.h> -#include <X11/extensions/XKMformat.h> - -#include <X11/X.h> -#include <X11/keysym.h> -#include <X11/Xproto.h> -#include "misc.h" -#include "inputstr.h" -#include "dix.h" -#include "xkbstr.h" -#define XKBSRV_NEED_FILE_FUNCS 1 -#include <xkbsrv.h> -#include "xkbgeom.h" -#include "xkb.h" - -unsigned -_XkbKSCheckCase(KeySym ks) -{ -unsigned set,rtrn; - - set= (ks & (~0xff)) >> 8; - rtrn= 0; - switch (set) { - case 0: /* latin 1 */ - if (((ks>=XK_A)&&(ks<=XK_Z))|| - ((ks>=XK_Agrave)&&(ks<=XK_THORN)&&(ks!=XK_multiply))) { - rtrn|= _XkbKSUpper; - } - if (((ks>=XK_a)&&(ks<=XK_z))|| - ((ks>=XK_agrave)&&(ks<=XK_ydiaeresis))) { - rtrn|= _XkbKSLower; - } - break; - case 1: /* latin 2 */ - if (((ks>=XK_Aogonek)&&(ks<=XK_Zabovedot)&&(ks!=XK_breve))|| - ((ks>=XK_Racute)&&(ks<=XK_Tcedilla))) { - rtrn|= _XkbKSUpper; - } - if (((ks>=XK_aogonek)&&(ks<=XK_zabovedot)&&(ks!=XK_caron))|| - ((ks>=XK_racute)&&(ks<=XK_tcedilla))) { - rtrn|= _XkbKSLower; - } - break; - case 2: /* latin 3 */ - if (((ks>=XK_Hstroke)&&(ks<=XK_Jcircumflex))|| - ((ks>=XK_Cabovedot)&&(ks<=XK_Scircumflex))) { - rtrn|= _XkbKSUpper; - } - if (((ks>=XK_hstroke)&&(ks<=XK_jcircumflex))|| - ((ks>=XK_cabovedot)&&(ks<=XK_scircumflex))) { - rtrn|= _XkbKSLower; - } - break; - case 3: /* latin 4 */ - if (((ks>=XK_Rcedilla)&&(ks<=XK_Tslash))|| - (ks==XK_ENG)|| - ((ks>=XK_Amacron)&&(ks<=XK_Umacron))) { - rtrn|= _XkbKSUpper; - } - if (((ks>=XK_rcedilla)&&(ks<=XK_tslash))|| - (ks==XK_eng)|| - ((ks>=XK_amacron)&&(ks<=XK_umacron))) { - rtrn|= _XkbKSLower; - } - break; - case 18: /* latin 8 */ - if ((ks==XK_Babovedot)|| - ((ks>=XK_Dabovedot)&&(ks<=XK_Wacute))|| - ((ks>=XK_Ygrave)&&(ks<=XK_Fabovedot))|| - (ks==XK_Mabovedot)|| - (ks==XK_Pabovedot)|| - (ks==XK_Sabovedot)|| - (ks==XK_Wdiaeresis)|| - ((ks>=XK_Wcircumflex)&&(ks<=XK_Ycircumflex))) { - rtrn|= _XkbKSUpper; - } - if ((ks==XK_babovedot)|| - (ks==XK_dabovedot)|| - (ks==XK_fabovedot)|| - (ks==XK_mabovedot)|| - ((ks>=XK_wgrave)&&(ks<=XK_wacute))|| - (ks==XK_ygrave)|| - ((ks>=XK_wdiaeresis)&&(ks<=XK_ycircumflex))) { - rtrn|= _XkbKSLower; - } - break; - case 19: /* latin 9 */ - if ((ks==XK_OE)||(ks==XK_Ydiaeresis)) { - rtrn|= _XkbKSUpper; - } - if (ks==XK_oe) { - rtrn|= _XkbKSLower; - } - break; - } - return rtrn; -} - -/***===================================================================***/ - -static Bool -XkbWriteSectionFromName(FILE *file,char *sectionName,char *name) -{ - fprintf(file," xkb_%-20s { include \"%s\" };\n",sectionName,name); - return TRUE; -} - -#define NEED_DESC(n) ((!n)||((n)[0]=='+')||((n)[0]=='|')||(strchr((n),'%'))) -#define COMPLETE(n) ((n)&&(!NEED_DESC(n))) - -/* ARGSUSED */ -static void -_AddIncl( FILE * file, - XkbDescPtr xkb, - Bool topLevel, - Bool showImplicit, - int index, - void * priv) -{ - if ((priv)&&(strcmp((char *)priv,"%")!=0)) - fprintf(file," include \"%s\"\n",(char *)priv); - return; -} - -Bool -XkbWriteXKBKeymapForNames( FILE * file, - XkbComponentNamesPtr names, - XkbDescPtr xkb, - unsigned want, - unsigned need) -{ -const char * tmp; -unsigned complete; -XkbNamesPtr old_names; -int multi_section; -unsigned wantNames,wantConfig,wantDflts; - - complete= 0; - if (COMPLETE(names->keycodes)) complete|= XkmKeyNamesMask; - if (COMPLETE(names->types)) complete|= XkmTypesMask; - if (COMPLETE(names->compat)) complete|= XkmCompatMapMask; - if (COMPLETE(names->symbols)) complete|= XkmSymbolsMask; - if (COMPLETE(names->geometry)) complete|= XkmGeometryMask; - want|= (complete|need); - if (want&XkmSymbolsMask) - want|= XkmKeyNamesMask|XkmTypesMask; - - if (want==0) - return FALSE; - - if (xkb) { - old_names = xkb->names; - - xkb->defined = 0; - /* Wow would it ever be neat if we didn't need this noise. */ - if (xkb->names && xkb->names->keys) - xkb->defined |= XkmKeyNamesMask; - if (xkb->map && xkb->map->types) - xkb->defined |= XkmTypesMask; - if (xkb->compat) - xkb->defined |= XkmCompatMapMask; - if (xkb->map && xkb->map->num_syms) - xkb->defined |= XkmSymbolsMask; - if (xkb->indicators) - xkb->defined |= XkmIndicatorsMask; - if (xkb->geom) - xkb->defined |= XkmGeometryMask; - } - else { - old_names= NULL; - } - - wantConfig= want&(~complete); - if (xkb!=NULL) { - if (wantConfig&XkmTypesMask) { - if ((!xkb->map) || (xkb->map->num_types<XkbNumRequiredTypes)) - wantConfig&= ~XkmTypesMask; - } - if (wantConfig&XkmCompatMapMask) { - if ((!xkb->compat) || (xkb->compat->num_si<1)) - wantConfig&= ~XkmCompatMapMask; - } - if (wantConfig&XkmSymbolsMask) { - if ((!xkb->map) || (!xkb->map->key_sym_map)) - wantConfig&= ~XkmSymbolsMask; - } - if (wantConfig&XkmIndicatorsMask) { - if (!xkb->indicators) - wantConfig&= ~XkmIndicatorsMask; - } - if (wantConfig&XkmKeyNamesMask) { - if ((!xkb->names)||(!xkb->names->keys)) - wantConfig&= ~XkmKeyNamesMask; - } - if ((wantConfig&XkmGeometryMask)&&(!xkb->geom)) - wantConfig&= ~XkmGeometryMask; - } - else { - wantConfig= 0; - } - complete|= wantConfig; - - wantDflts= 0; - wantNames= want&(~complete); - if ((xkb!=NULL) && (old_names!=NULL)) { - if (wantNames&XkmTypesMask) { - if (old_names->types!=None) { - tmp= NameForAtom(old_names->types); - names->types= _XkbDupString(tmp); - } - else { - wantDflts|= XkmTypesMask; - } - complete|= XkmTypesMask; - } - if (wantNames&XkmCompatMapMask) { - if (old_names->compat!=None) { - tmp= NameForAtom(old_names->compat); - names->compat= _XkbDupString(tmp); - } - else wantDflts|= XkmCompatMapMask; - complete|= XkmCompatMapMask; - } - if (wantNames&XkmSymbolsMask) { - if (old_names->symbols==None) - return FALSE; - tmp= NameForAtom(old_names->symbols); - names->symbols= _XkbDupString(tmp); - complete|= XkmSymbolsMask; - } - if (wantNames&XkmKeyNamesMask) { - if (old_names->keycodes!=None) { - tmp= NameForAtom(old_names->keycodes); - names->keycodes= _XkbDupString(tmp); - } - else wantDflts|= XkmKeyNamesMask; - complete|= XkmKeyNamesMask; - } - if (wantNames&XkmGeometryMask) { - if (old_names->geometry==None) - return FALSE; - tmp= NameForAtom(old_names->geometry); - names->geometry= _XkbDupString(tmp); - complete|= XkmGeometryMask; - wantNames&= ~XkmGeometryMask; - } - } - if (complete&XkmCompatMapMask) - complete|= XkmIndicatorsMask|XkmVirtualModsMask; - else if (complete&(XkmSymbolsMask|XkmTypesMask)) - complete|= XkmVirtualModsMask; - if (need & (~complete)) - return FALSE; - if ((complete&XkmSymbolsMask)&&((XkmKeyNamesMask|XkmTypesMask)&(~complete))) - return FALSE; - - multi_section= 1; - if (((complete&XkmKeymapRequired)==XkmKeymapRequired)&& - ((complete&(~XkmKeymapLegal))==0)) { - fprintf(file,"xkb_keymap \"default\" {\n"); - } - else if (((complete&XkmSemanticsRequired)==XkmSemanticsRequired)&& - ((complete&(~XkmSemanticsLegal))==0)) { - fprintf(file,"xkb_semantics \"default\" {\n"); - } - else if (((complete&XkmLayoutRequired)==XkmLayoutRequired)&& - ((complete&(~XkmLayoutLegal))==0)) { - fprintf(file,"xkb_layout \"default\" {\n"); - } - else if (XkmSingleSection(complete&(~XkmVirtualModsMask))) { - multi_section= 0; - } - else { - return FALSE; - } - - wantNames= complete&(~(wantConfig|wantDflts)); - if (wantConfig&XkmKeyNamesMask) - XkbWriteXKBKeycodes(file,xkb,FALSE,FALSE,_AddIncl,names->keycodes); - else if (wantDflts&XkmKeyNamesMask) - fprintf(stderr,"Default symbols not implemented yet!\n"); - else if (wantNames&XkmKeyNamesMask) - XkbWriteSectionFromName(file,"keycodes",names->keycodes); - - if (wantConfig&XkmTypesMask) - XkbWriteXKBKeyTypes(file,xkb,FALSE,FALSE,_AddIncl,names->types); - else if (wantDflts&XkmTypesMask) - fprintf(stderr,"Default types not implemented yet!\n"); - else if (wantNames&XkmTypesMask) - XkbWriteSectionFromName(file,"types",names->types); - - if (wantConfig&XkmCompatMapMask) - XkbWriteXKBCompatMap(file,xkb,FALSE,FALSE,_AddIncl,names->compat); - else if (wantDflts&XkmCompatMapMask) - fprintf(stderr,"Default interps not implemented yet!\n"); - else if (wantNames&XkmCompatMapMask) - XkbWriteSectionFromName(file,"compatibility",names->compat); - - if (wantConfig&XkmSymbolsMask) - XkbWriteXKBSymbols(file,xkb,FALSE,FALSE,_AddIncl,names->symbols); - else if (wantNames&XkmSymbolsMask) - XkbWriteSectionFromName(file,"symbols",names->symbols); - - if (wantConfig&XkmGeometryMask) - XkbWriteXKBGeometry(file,xkb,FALSE,FALSE,_AddIncl,names->geometry); - else if (wantNames&XkmGeometryMask) - XkbWriteSectionFromName(file,"geometry",names->geometry); - - if (multi_section) - fprintf(file,"};\n"); - return TRUE; -} - -/***====================================================================***/ - -int -XkbFindKeycodeByName(XkbDescPtr xkb,char *name,Bool use_aliases) -{ -register int i; - - if ((!xkb)||(!xkb->names)||(!xkb->names->keys)) - return 0; - for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - if (strncmp(xkb->names->keys[i].name,name,XkbKeyNameLength)==0) - return i; - } - if (!use_aliases) - return 0; - if (xkb->geom && xkb->geom->key_aliases) { - XkbKeyAliasPtr a; - a= xkb->geom->key_aliases; - for (i=0;i<xkb->geom->num_key_aliases;i++,a++) { - if (strncmp(name,a->alias,XkbKeyNameLength)==0) - return XkbFindKeycodeByName(xkb,a->real,FALSE); - } - } - if (xkb->names && xkb->names->key_aliases) { - XkbKeyAliasPtr a; - a= xkb->names->key_aliases; - for (i=0;i<xkb->names->num_key_aliases;i++,a++) { - if (strncmp(name,a->alias,XkbKeyNameLength)==0) - return XkbFindKeycodeByName(xkb,a->real,FALSE); - } - } - return 0; -} - - -unsigned -XkbConvertGetByNameComponents(Bool toXkm,unsigned orig) -{ -unsigned rtrn; - - rtrn= 0; - if (toXkm) { - if (orig&XkbGBN_TypesMask) rtrn|= XkmTypesMask; - if (orig&XkbGBN_CompatMapMask) rtrn|= XkmCompatMapMask; - if (orig&XkbGBN_SymbolsMask) rtrn|= XkmSymbolsMask; - if (orig&XkbGBN_IndicatorMapMask) rtrn|= XkmIndicatorsMask; - if (orig&XkbGBN_KeyNamesMask) rtrn|= XkmKeyNamesMask; - if (orig&XkbGBN_GeometryMask) rtrn|= XkmGeometryMask; - } - else { - if (orig&XkmTypesMask) rtrn|= XkbGBN_TypesMask; - if (orig&XkmCompatMapMask) rtrn|= XkbGBN_CompatMapMask; - if (orig&XkmSymbolsMask) rtrn|= XkbGBN_SymbolsMask; - if (orig&XkmIndicatorsMask) rtrn|= XkbGBN_IndicatorMapMask; - if (orig&XkmKeyNamesMask) rtrn|= XkbGBN_KeyNamesMask; - if (orig&XkmGeometryMask) rtrn|= XkbGBN_GeometryMask; - if (orig!=0) rtrn|= XkbGBN_OtherNamesMask; - } - return rtrn; -} - -/***====================================================================***/ - -#define UNMATCHABLE(c) (((c)=='(')||((c)==')')||((c)=='/')) - -Bool -XkbNameMatchesPattern(char *name,char *ptrn) -{ - while (ptrn[0]!='\0') { - if (name[0]=='\0') { - if (ptrn[0]=='*') { - ptrn++; - continue; - } - return FALSE; - } - if (ptrn[0]=='?') { - if (UNMATCHABLE(name[0])) - return FALSE; - } - else if (ptrn[0]=='*') { - if ((!UNMATCHABLE(name[0]))&&XkbNameMatchesPattern(name+1,ptrn)) - return TRUE; - return XkbNameMatchesPattern(name,ptrn+1); - } - else if (ptrn[0]!=name[0]) - return FALSE; - name++; - ptrn++; - } - /* if we get here, the pattern is exhausted (-:just like me:-) */ - return (name[0]=='\0'); -} +/************************************************************
+ Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+ Permission to use, copy, modify, and distribute this
+ software and its documentation for any purpose and without
+ fee is hereby granted, provided that the above copyright
+ notice appear in all copies and that both that copyright
+ notice and this permission notice appear in supporting
+ documentation, and that the name of Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+ ********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <X11/extensions/XKMformat.h>
+
+#include <X11/X.h>
+#include <X11/keysym.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "dix.h"
+#include "xkbstr.h"
+#define XKBSRV_NEED_FILE_FUNCS 1
+#include <xkbsrv.h>
+#include "xkbgeom.h"
+#include "xkb.h"
+
+unsigned
+_XkbKSCheckCase(KeySym ks)
+{
+unsigned set,rtrn;
+
+ set= (ks & (~0xff)) >> 8;
+ rtrn= 0;
+ switch (set) {
+ case 0: /* latin 1 */
+ if (((ks>=XK_A)&&(ks<=XK_Z))||
+ ((ks>=XK_Agrave)&&(ks<=XK_THORN)&&(ks!=XK_multiply))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_a)&&(ks<=XK_z))||
+ ((ks>=XK_agrave)&&(ks<=XK_ydiaeresis))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 1: /* latin 2 */
+ if (((ks>=XK_Aogonek)&&(ks<=XK_Zabovedot)&&(ks!=XK_breve))||
+ ((ks>=XK_Racute)&&(ks<=XK_Tcedilla))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_aogonek)&&(ks<=XK_zabovedot)&&(ks!=XK_caron))||
+ ((ks>=XK_racute)&&(ks<=XK_tcedilla))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 2: /* latin 3 */
+ if (((ks>=XK_Hstroke)&&(ks<=XK_Jcircumflex))||
+ ((ks>=XK_Cabovedot)&&(ks<=XK_Scircumflex))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_hstroke)&&(ks<=XK_jcircumflex))||
+ ((ks>=XK_cabovedot)&&(ks<=XK_scircumflex))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 3: /* latin 4 */
+ if (((ks>=XK_Rcedilla)&&(ks<=XK_Tslash))||
+ (ks==XK_ENG)||
+ ((ks>=XK_Amacron)&&(ks<=XK_Umacron))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_rcedilla)&&(ks<=XK_tslash))||
+ (ks==XK_eng)||
+ ((ks>=XK_amacron)&&(ks<=XK_umacron))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 18: /* latin 8 */
+ if ((ks==XK_Babovedot)||
+ ((ks>=XK_Dabovedot)&&(ks<=XK_Wacute))||
+ ((ks>=XK_Ygrave)&&(ks<=XK_Fabovedot))||
+ (ks==XK_Mabovedot)||
+ (ks==XK_Pabovedot)||
+ (ks==XK_Sabovedot)||
+ (ks==XK_Wdiaeresis)||
+ ((ks>=XK_Wcircumflex)&&(ks<=XK_Ycircumflex))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if ((ks==XK_babovedot)||
+ (ks==XK_dabovedot)||
+ (ks==XK_fabovedot)||
+ (ks==XK_mabovedot)||
+ ((ks>=XK_wgrave)&&(ks<=XK_wacute))||
+ (ks==XK_ygrave)||
+ ((ks>=XK_wdiaeresis)&&(ks<=XK_ycircumflex))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 19: /* latin 9 */
+ if ((ks==XK_OE)||(ks==XK_Ydiaeresis)) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (ks==XK_oe) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ }
+ return rtrn;
+}
+
+/***===================================================================***/
+
+static Bool
+XkbWriteSectionFromName(FILE *file,char *sectionName,char *name)
+{
+ fprintf(file," xkb_%-20s { include \"%s\" };\n",sectionName,name);
+ return TRUE;
+}
+
+#define NEED_DESC(n) ((!n)||((n)[0]=='+')||((n)[0]=='|')||(strchr((n),'%')))
+#define COMPLETE(n) ((n)&&(!NEED_DESC(n)))
+
+/* ARGSUSED */
+static void
+_AddIncl( FILE * file,
+ XkbDescPtr xkb,
+ Bool topLevel,
+ Bool showImplicit,
+ int index,
+ void * priv)
+{
+ if ((priv)&&(strcmp((char *)priv,"%")!=0))
+ fprintf(file," include \"%s\"\n",(char *)priv);
+ return;
+}
+
+Bool
+XkbWriteXKBKeymapForNames( FILE * file,
+ XkbComponentNamesPtr names,
+ XkbDescPtr xkb,
+ unsigned want,
+ unsigned need)
+{
+const char * tmp;
+unsigned complete;
+XkbNamesPtr old_names;
+int multi_section;
+unsigned wantNames,wantConfig,wantDflts;
+
+ complete= 0;
+ if (COMPLETE(names->keycodes)) complete|= XkmKeyNamesMask;
+ if (COMPLETE(names->types)) complete|= XkmTypesMask;
+ if (COMPLETE(names->compat)) complete|= XkmCompatMapMask;
+ if (COMPLETE(names->symbols)) complete|= XkmSymbolsMask;
+ if (COMPLETE(names->geometry)) complete|= XkmGeometryMask;
+ want|= (complete|need);
+ if (want&XkmSymbolsMask)
+ want|= XkmKeyNamesMask|XkmTypesMask;
+
+ if (want==0)
+ return FALSE;
+
+ if (xkb) {
+ old_names = xkb->names;
+
+ xkb->defined = 0;
+ /* Wow would it ever be neat if we didn't need this noise. */
+ if (xkb->names && xkb->names->keys)
+ xkb->defined |= XkmKeyNamesMask;
+ if (xkb->map && xkb->map->types)
+ xkb->defined |= XkmTypesMask;
+ if (xkb->compat)
+ xkb->defined |= XkmCompatMapMask;
+ if (xkb->map && xkb->map->num_syms)
+ xkb->defined |= XkmSymbolsMask;
+ if (xkb->indicators)
+ xkb->defined |= XkmIndicatorsMask;
+ if (xkb->geom)
+ xkb->defined |= XkmGeometryMask;
+ }
+ else {
+ old_names= NULL;
+ }
+
+ wantConfig= want&(~complete);
+ if (xkb!=NULL) {
+ if (wantConfig&XkmTypesMask) {
+ if ((!xkb->map) || (xkb->map->num_types<XkbNumRequiredTypes))
+ wantConfig&= ~XkmTypesMask;
+ }
+ if (wantConfig&XkmCompatMapMask) {
+ if ((!xkb->compat) || (xkb->compat->num_si<1))
+ wantConfig&= ~XkmCompatMapMask;
+ }
+ if (wantConfig&XkmSymbolsMask) {
+ if ((!xkb->map) || (!xkb->map->key_sym_map))
+ wantConfig&= ~XkmSymbolsMask;
+ }
+ if (wantConfig&XkmIndicatorsMask) {
+ if (!xkb->indicators)
+ wantConfig&= ~XkmIndicatorsMask;
+ }
+ if (wantConfig&XkmKeyNamesMask) {
+ if ((!xkb->names)||(!xkb->names->keys))
+ wantConfig&= ~XkmKeyNamesMask;
+ }
+ if ((wantConfig&XkmGeometryMask)&&(!xkb->geom))
+ wantConfig&= ~XkmGeometryMask;
+ }
+ else {
+ wantConfig= 0;
+ }
+ complete|= wantConfig;
+
+ wantDflts= 0;
+ wantNames= want&(~complete);
+ if ((xkb!=NULL) && (old_names!=NULL)) {
+ if (wantNames&XkmTypesMask) {
+ if (old_names->types!=None) {
+ tmp= NameForAtom(old_names->types);
+ names->types= _XkbDupString(tmp);
+ }
+ else {
+ wantDflts|= XkmTypesMask;
+ }
+ complete|= XkmTypesMask;
+ }
+ if (wantNames&XkmCompatMapMask) {
+ if (old_names->compat!=None) {
+ tmp= NameForAtom(old_names->compat);
+ names->compat= _XkbDupString(tmp);
+ }
+ else wantDflts|= XkmCompatMapMask;
+ complete|= XkmCompatMapMask;
+ }
+ if (wantNames&XkmSymbolsMask) {
+ if (old_names->symbols==None)
+ return FALSE;
+ tmp= NameForAtom(old_names->symbols);
+ names->symbols= _XkbDupString(tmp);
+ complete|= XkmSymbolsMask;
+ }
+ if (wantNames&XkmKeyNamesMask) {
+ if (old_names->keycodes!=None) {
+ tmp= NameForAtom(old_names->keycodes);
+ names->keycodes= _XkbDupString(tmp);
+ }
+ else wantDflts|= XkmKeyNamesMask;
+ complete|= XkmKeyNamesMask;
+ }
+ if (wantNames&XkmGeometryMask) {
+ if (old_names->geometry==None)
+ return FALSE;
+ tmp= NameForAtom(old_names->geometry);
+ names->geometry= _XkbDupString(tmp);
+ complete|= XkmGeometryMask;
+ wantNames&= ~XkmGeometryMask;
+ }
+ }
+ if (complete&XkmCompatMapMask)
+ complete|= XkmIndicatorsMask|XkmVirtualModsMask;
+ else if (complete&(XkmSymbolsMask|XkmTypesMask))
+ complete|= XkmVirtualModsMask;
+ if (need & (~complete))
+ return FALSE;
+ if ((complete&XkmSymbolsMask)&&((XkmKeyNamesMask|XkmTypesMask)&(~complete)))
+ return FALSE;
+
+ multi_section= 1;
+ if (((complete&XkmKeymapRequired)==XkmKeymapRequired)&&
+ ((complete&(~XkmKeymapLegal))==0)) {
+ fprintf(file,"xkb_keymap \"default\" {\n");
+ }
+ else if (((complete&XkmSemanticsRequired)==XkmSemanticsRequired)&&
+ ((complete&(~XkmSemanticsLegal))==0)) {
+ fprintf(file,"xkb_semantics \"default\" {\n");
+ }
+ else if (((complete&XkmLayoutRequired)==XkmLayoutRequired)&&
+ ((complete&(~XkmLayoutLegal))==0)) {
+ fprintf(file,"xkb_layout \"default\" {\n");
+ }
+ else if (XkmSingleSection(complete&(~XkmVirtualModsMask))) {
+ multi_section= 0;
+ }
+ else {
+ return FALSE;
+ }
+
+ wantNames= complete&(~(wantConfig|wantDflts));
+ if (wantConfig&XkmKeyNamesMask)
+ XkbWriteXKBKeycodes(file,xkb,FALSE,FALSE,_AddIncl,names->keycodes);
+ else if (wantDflts&XkmKeyNamesMask)
+ fprintf(stderr,"Default symbols not implemented yet!\n");
+ else if (wantNames&XkmKeyNamesMask)
+ XkbWriteSectionFromName(file,"keycodes",names->keycodes);
+
+ if (wantConfig&XkmTypesMask)
+ XkbWriteXKBKeyTypes(file,xkb,FALSE,FALSE,_AddIncl,names->types);
+ else if (wantDflts&XkmTypesMask)
+ fprintf(stderr,"Default types not implemented yet!\n");
+ else if (wantNames&XkmTypesMask)
+ XkbWriteSectionFromName(file,"types",names->types);
+
+ if (wantConfig&XkmCompatMapMask)
+ XkbWriteXKBCompatMap(file,xkb,FALSE,FALSE,_AddIncl,names->compat);
+ else if (wantDflts&XkmCompatMapMask)
+ fprintf(stderr,"Default interps not implemented yet!\n");
+ else if (wantNames&XkmCompatMapMask)
+ XkbWriteSectionFromName(file,"compatibility",names->compat);
+
+ if (wantConfig&XkmSymbolsMask)
+ XkbWriteXKBSymbols(file,xkb,FALSE,FALSE,_AddIncl,names->symbols);
+ else if (wantNames&XkmSymbolsMask)
+ XkbWriteSectionFromName(file,"symbols",names->symbols);
+
+ if (wantConfig&XkmGeometryMask)
+ XkbWriteXKBGeometry(file,xkb,FALSE,FALSE,_AddIncl,names->geometry);
+ else if (wantNames&XkmGeometryMask)
+ XkbWriteSectionFromName(file,"geometry",names->geometry);
+
+ if (multi_section)
+ fprintf(file,"};\n");
+ return TRUE;
+}
+
+/***====================================================================***/
+
+int
+XkbFindKeycodeByName(XkbDescPtr xkb,char *name,Bool use_aliases)
+{
+register int i;
+
+ if ((!xkb)||(!xkb->names)||(!xkb->names->keys))
+ return 0;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (strncmp(xkb->names->keys[i].name,name,XkbKeyNameLength)==0)
+ return i;
+ }
+ if (!use_aliases)
+ return 0;
+ if (xkb->geom && xkb->geom->key_aliases) {
+ XkbKeyAliasPtr a;
+ a= xkb->geom->key_aliases;
+ for (i=0;i<xkb->geom->num_key_aliases;i++,a++) {
+ if (strncmp(name,a->alias,XkbKeyNameLength)==0)
+ return XkbFindKeycodeByName(xkb,a->real,FALSE);
+ }
+ }
+ if (xkb->names && xkb->names->key_aliases) {
+ XkbKeyAliasPtr a;
+ a= xkb->names->key_aliases;
+ for (i=0;i<xkb->names->num_key_aliases;i++,a++) {
+ if (strncmp(name,a->alias,XkbKeyNameLength)==0)
+ return XkbFindKeycodeByName(xkb,a->real,FALSE);
+ }
+ }
+ return 0;
+}
+
+
+unsigned
+XkbConvertGetByNameComponents(Bool toXkm,unsigned orig)
+{
+unsigned rtrn;
+
+ rtrn= 0;
+ if (toXkm) {
+ if (orig&XkbGBN_TypesMask) rtrn|= XkmTypesMask;
+ if (orig&XkbGBN_CompatMapMask) rtrn|= XkmCompatMapMask;
+ if (orig&XkbGBN_SymbolsMask) rtrn|= XkmSymbolsMask;
+ if (orig&XkbGBN_IndicatorMapMask) rtrn|= XkmIndicatorsMask;
+ if (orig&XkbGBN_KeyNamesMask) rtrn|= XkmKeyNamesMask;
+ if (orig&XkbGBN_GeometryMask) rtrn|= XkmGeometryMask;
+ }
+ else {
+ if (orig&XkmTypesMask) rtrn|= XkbGBN_TypesMask;
+ if (orig&XkmCompatMapMask) rtrn|= XkbGBN_CompatMapMask;
+ if (orig&XkmSymbolsMask) rtrn|= XkbGBN_SymbolsMask;
+ if (orig&XkmIndicatorsMask) rtrn|= XkbGBN_IndicatorMapMask;
+ if (orig&XkmKeyNamesMask) rtrn|= XkbGBN_KeyNamesMask;
+ if (orig&XkmGeometryMask) rtrn|= XkbGBN_GeometryMask;
+ if (orig!=0) rtrn|= XkbGBN_OtherNamesMask;
+ }
+ return rtrn;
+}
+
+/***====================================================================***/
+
+#define UNMATCHABLE(c) (((c)=='(')||((c)==')')||((c)=='/'))
+
+Bool
+XkbNameMatchesPattern(char *name,char *ptrn)
+{
+ while (ptrn[0]!='\0') {
+ if (name[0]=='\0') {
+ if (ptrn[0]=='*') {
+ ptrn++;
+ continue;
+ }
+ return FALSE;
+ }
+ if (ptrn[0]=='?') {
+ if (UNMATCHABLE(name[0]))
+ return FALSE;
+ }
+ else if (ptrn[0]=='*') {
+ if ((!UNMATCHABLE(name[0]))&&XkbNameMatchesPattern(name+1,ptrn))
+ return TRUE;
+ return XkbNameMatchesPattern(name,ptrn+1);
+ }
+ else if (ptrn[0]!=name[0])
+ return FALSE;
+ name++;
+ ptrn++;
+ }
+ /* if we get here, the pattern is exhausted (-:just like me:-) */
+ return name[0]=='\0';
+}
diff --git a/xorg-server/xkb/xkmread.c b/xorg-server/xkb/xkmread.c index 660884a7f..4b2043667 100644 --- a/xorg-server/xkb/xkmread.c +++ b/xorg-server/xkb/xkmread.c @@ -80,7 +80,7 @@ int newCount= *newCountRtrn; oldPtr= realloc(oldPtr,newCount*elemSize);
if (oldPtr!=NULL) {
char *tmp= (char *)oldPtr;
- bzero(&tmp[oldCount*elemSize],(newCount-oldCount)*elemSize);
+ memset(&tmp[oldCount*elemSize], 0, (newCount-oldCount)*elemSize);
}
}
else if (newCount<oldCount) {
@@ -725,8 +725,8 @@ int nRead=0; return -1;
}
nRead+= tmp*SIZEOF(xkmKeySymMapDesc);
- bzero((char *)typeName,XkbNumKbdGroups*sizeof(Atom));
- bzero((char *)type,XkbNumKbdGroups*sizeof(XkbKeyTypePtr));
+ memset((char *)typeName, 0, XkbNumKbdGroups*sizeof(Atom));
+ memset((char *)type, 0, XkbNumKbdGroups*sizeof(XkbKeyTypePtr));
if (wireMap.flags&XkmKeyHasTypes) {
register int g;
for (g=0;g<XkbNumKbdGroups;g++) {
diff --git a/xorg-server/xkbdata.src/symbols/is b/xorg-server/xkbdata.src/symbols/is index 7debc94d5..53dddc43e 100644 --- a/xorg-server/xkbdata.src/symbols/is +++ b/xorg-server/xkbdata.src/symbols/is @@ -173,14 +173,15 @@ xkb_symbols "mac" { // Rather it's a simple modification of 5 keys of the US Dvorak layout,
// it adds Germanic/Icelandic style quotation marks („“), eth (ðÐ), ae
-// (æÆ), endash and emdash (–—) and thorn (þÞ). These keys aren't used in
-// the US version making this IS version a superset of it.
+// (æÆ), endash and emdash (–—), thorn (þÞ), EuroSign (€) and the German
+// Sharp S (ßẞ). These keys aren't used in the US version, making the
+// Icelandic version a superset of it.
// Maybe someone else will make a "full" attempt at an Icelandic layout
// but I was mostly interested in continuing to type English comfortably
// as a primary function while being able to type the full Icelandic
// alphabet as a secondary function.
-// -- Ævar Arnfjörð Bjarmason <avar@cpan.org>
+// -- Ævar Arnfjörð Bjarmason <avarab@gmail.com>
// Icelandic Dvorak
partial alphanumeric_keys
@@ -188,12 +189,14 @@ xkb_symbols "dvorak" { name[Group1]= "Iceland - Dvorak";
include "us(dvorak)"
+ include "eurosign(4)"
key <AD11> { [ slash, question, U201e, U201c ] };
key <AC06> { [ d, D, eth, ETH ] };
key <AC10> { [ s, S, ae, AE ] };
key <AC11> { [ minus, underscore, endash, emdash ] };
key <AB10> { [ z, Z, thorn, Thorn ] };
+ key <AB06> { [ b, B, ssharp, U1E9E ] };
include "level3(ralt_switch)"
};
|