aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/dmx
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-06-11 12:14:52 +0000
committermarha <marha@users.sourceforge.net>2010-06-11 12:14:52 +0000
commit4c61bf84b11e26e6f22648668c95ea760a379163 (patch)
tree0ac762ab2815eae283dded7447ad7cb5a54b926a /xorg-server/hw/dmx
parente1dabd2ce8be0d70c6c15353b58de256129dfd1f (diff)
downloadvcxsrv-4c61bf84b11e26e6f22648668c95ea760a379163.tar.gz
vcxsrv-4c61bf84b11e26e6f22648668c95ea760a379163.tar.bz2
vcxsrv-4c61bf84b11e26e6f22648668c95ea760a379163.zip
xserver git update 11/6/2010
Diffstat (limited to 'xorg-server/hw/dmx')
-rw-r--r--xorg-server/hw/dmx/config/dmxparse.c1214
-rw-r--r--xorg-server/hw/dmx/dmx.h757
-rw-r--r--xorg-server/hw/dmx/dmx_glxvisuals.c8
-rw-r--r--xorg-server/hw/dmx/dmxcmap.c2
-rw-r--r--xorg-server/hw/dmx/dmxcmap.h135
-rw-r--r--xorg-server/hw/dmx/dmxcursor.c62
-rw-r--r--xorg-server/hw/dmx/dmxextension.c3232
-rw-r--r--xorg-server/hw/dmx/dmxfont.c2
-rw-r--r--xorg-server/hw/dmx/dmxgc.c6
-rw-r--r--xorg-server/hw/dmx/dmxgc.h175
-rw-r--r--xorg-server/hw/dmx/dmxgcops.c1206
-rw-r--r--xorg-server/hw/dmx/dmxinit.c6
-rw-r--r--xorg-server/hw/dmx/dmxpict.c6
-rw-r--r--xorg-server/hw/dmx/dmxpict.h264
-rw-r--r--xorg-server/hw/dmx/dmxpixmap.c28
-rw-r--r--xorg-server/hw/dmx/dmxpixmap.h131
-rw-r--r--xorg-server/hw/dmx/dmxscrinit.c28
-rw-r--r--xorg-server/hw/dmx/dmxscrinit.h99
-rw-r--r--xorg-server/hw/dmx/dmxshadow.c142
-rw-r--r--xorg-server/hw/dmx/dmxstat.c442
-rw-r--r--xorg-server/hw/dmx/dmxwindow.c14
-rw-r--r--xorg-server/hw/dmx/dmxwindow.h273
-rw-r--r--xorg-server/hw/dmx/doc/dmx.xml15
-rw-r--r--xorg-server/hw/dmx/glxProxy/compsize.c1116
-rw-r--r--xorg-server/hw/dmx/glxProxy/g_renderswap.c112
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxcmds.c5
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxcmdsswap.c2109
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxfbconfig.c212
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxscreens.c14
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxsingle.c19
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxutil.c4
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxvendor.c8
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxvisuals.c25
-rw-r--r--xorg-server/hw/dmx/glxProxy/render2swap.c5
-rw-r--r--xorg-server/hw/dmx/glxProxy/unpack.h4
-rw-r--r--xorg-server/hw/dmx/input/dmxbackend.c1232
-rw-r--r--xorg-server/hw/dmx/input/dmxcommon.c1339
-rw-r--r--xorg-server/hw/dmx/input/dmxconsole.c2059
-rw-r--r--xorg-server/hw/dmx/input/dmxinputinit.c18
-rw-r--r--xorg-server/hw/dmx/input/dmxinputinit.h582
-rw-r--r--xorg-server/hw/dmx/input/lnx-keyboard.c2
-rw-r--r--xorg-server/hw/dmx/input/lnx-ms.c642
-rw-r--r--xorg-server/hw/dmx/input/lnx-ps2.c578
-rw-r--r--xorg-server/hw/dmx/input/usb-common.c762
44 files changed, 9618 insertions, 9476 deletions
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 94643ea94..0871ab5f5 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&lsqb;&rsqb;)
- 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&lsqb;i&rsqb;) is initialized for each
- physical screen, and single region (PanoramiXScreenRegion) is
- initialized to be the union of the screen regions. The
- panoramiXdataPtr&lsqb;&rsqb; 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&lsqb;&rsqb;, 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);
+}