From b39f063f74bf0163eaf34db03134f226d18142ec Mon Sep 17 00:00:00 2001 From: marha Date: Thu, 24 Mar 2011 07:37:29 +0000 Subject: xserver xkeyboard-config libX11 pixman mesa git update 24 Mar 2011 --- xorg-server/Xext/panoramiX.c | 16 +- xorg-server/Xext/panoramiX.h | 158 +- xorg-server/Xext/panoramiXprocs.c | 4846 ++++---- xorg-server/Xext/panoramiXsrv.h | 11 + xorg-server/Xext/shm.c | 2652 ++-- xorg-server/Xext/xvdisp.c | 3922 +++--- xorg-server/composite/compext.c | 1861 ++- xorg-server/dix/events.c | 10 +- xorg-server/dix/window.c | 7372 +++++------ xorg-server/hw/dmx/dmxcb.c | 7 +- xorg-server/hw/dmx/dmxextension.c | 4 +- xorg-server/hw/dmx/dmxgcops.c | 1210 +- xorg-server/render/render.c | 25 +- .../xkeyboard-config/rules/base.extras.xml.in | 34 +- xorg-server/xkeyboard-config/rules/base.xml.in | 12418 +++++++++---------- xorg-server/xkeyboard-config/symbols/in | 2 +- xorg-server/xkeyboard-config/symbols/lk | 181 +- xorg-server/xkeyboard-config/symbols/lt | 614 +- xorg-server/xkeyboard-config/symbols/nbsp | 398 +- 19 files changed, 17887 insertions(+), 17854 deletions(-) (limited to 'xorg-server') diff --git a/xorg-server/Xext/panoramiX.c b/xorg-server/Xext/panoramiX.c index 391346a6b..00afe94f1 100644 --- a/xorg-server/Xext/panoramiX.c +++ b/xorg-server/Xext/panoramiX.c @@ -393,7 +393,7 @@ static void XineramaInitData(ScreenPtr pScreen) int i, w, h; RegionNull(&PanoramiXScreenRegion); - for (i = 0; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS(i) { BoxRec TheBox; RegionRec ScreenRegion; @@ -413,7 +413,7 @@ static void XineramaInitData(ScreenPtr pScreen) PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width; PanoramiXPixHeight = screenInfo.screens[0]->y + screenInfo.screens[0]->height; - for (i = 1; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS_FORWARD_SKIP(i) { pScreen = screenInfo.screens[i]; w = pScreen->x + pScreen->width; h = pScreen->y + pScreen->height; @@ -478,7 +478,7 @@ void PanoramiXExtensionInit(int argc, char *argv[]) * run in non-PanoramiXeen mode. */ - for (i = 0; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS(i) { pScreen = screenInfo.screens[i]; pScreenPriv = malloc(sizeof(PanoramiXScreenRec)); dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey, @@ -740,7 +740,7 @@ PanoramiXMaybeAddDepth(DepthPtr pDepth) int j, k; Bool found = FALSE; - for (j = 1; j < PanoramiXNumScreens; j++) { + FOR_NSCREENS_FORWARD_SKIP(j) { pScreen = screenInfo.screens[j]; for (k = 0; k < pScreen->numDepths; k++) { if (pScreen->allowedDepths[k].depth == pDepth->depth) { @@ -773,7 +773,7 @@ PanoramiXMaybeAddVisual(VisualPtr pVisual) int j, k; Bool found = FALSE; - for (j = 1; j < PanoramiXNumScreens; j++) { + FOR_NSCREENS_FORWARD_SKIP(j) { pScreen = screenInfo.screens[j]; found = FALSE; @@ -836,7 +836,7 @@ PanoramiXConsolidate(void) saver = malloc(sizeof(PanoramiXRes)); saver->type = XRT_WINDOW; - for (i = 0; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS(i) { ScreenPtr pScreen = screenInfo.screens[i]; root->info[i].id = pScreen->root->drawable.id; root->u.win.class = InputOutput; @@ -1074,7 +1074,7 @@ ProcXineramaQueryScreens(ClientPtr client) xXineramaScreenInfo scratch; int i; - for(i = 0; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS(i) { scratch.x_org = screenInfo.screens[i]->x; scratch.y_org = screenInfo.screens[i]->y; scratch.width = screenInfo.screens[i]->width; @@ -1179,7 +1179,7 @@ XineramaGetImageData( depth = (format == XYPixmap) ? 1 : pDraw->depth; - for(i = 0; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS(i) { BoxRec TheBox; ScreenPtr pScreen; pDraw = pDrawables[i]; diff --git a/xorg-server/Xext/panoramiX.h b/xorg-server/Xext/panoramiX.h index 1bf6194c6..71651e558 100644 --- a/xorg-server/Xext/panoramiX.h +++ b/xorg-server/Xext/panoramiX.h @@ -1,78 +1,80 @@ -/***************************************************************** - -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. - -******************************************************************/ - - -/* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */ - -/* - * PanoramiX definitions - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef _PANORAMIX_H_ -#define _PANORAMIX_H_ - -#define _PANORAMIX_SERVER -#include -#undef _PANORAMIX_SERVER -#include "gcstruct.h" - - -typedef struct _PanoramiXInfo { - XID id ; -} PanoramiXInfo; - -typedef struct { - PanoramiXInfo info[MAXSCREENS]; - RESTYPE type; - union { - struct { - char visibility; - char class; - char root; - } win; - struct { - Bool shared; - } pix; - struct { - Bool root; - } pict; - char raw_data[4]; - } u; -} PanoramiXRes; - -#define FOR_NSCREENS_FORWARD(j) for(j = 0; j < PanoramiXNumScreens; j++) -#define FOR_NSCREENS_BACKWARD(j) for(j = PanoramiXNumScreens - 1; j >= 0; j--) -#define FOR_NSCREENS(j) FOR_NSCREENS_FORWARD(j) - -#define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared) - -#endif /* _PANORAMIX_H_ */ +/***************************************************************** + +Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, +BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of Digital Equipment Corporation +shall not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from Digital +Equipment Corporation. + +******************************************************************/ + + +/* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */ + +/* + * PanoramiX definitions + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef _PANORAMIX_H_ +#define _PANORAMIX_H_ + +#define _PANORAMIX_SERVER +#include +#undef _PANORAMIX_SERVER +#include "gcstruct.h" +#include "dixstruct.h" + +typedef struct _PanoramiXInfo { + XID id ; +} PanoramiXInfo; + +typedef struct { + PanoramiXInfo info[MAXSCREENS]; + RESTYPE type; + union { + struct { + char visibility; + char class; + char root; + } win; + struct { + Bool shared; + } pix; + struct { + Bool root; + } pict; + char raw_data[4]; + } u; +} PanoramiXRes; + +#define FOR_NSCREENS_FORWARD(j) for(j = 0; j < PanoramiXNumScreens; j++) +#define FOR_NSCREENS_FORWARD_SKIP(j) for(j = 1; j < PanoramiXNumScreens; j++) +#define FOR_NSCREENS_BACKWARD(j) for(j = PanoramiXNumScreens - 1; j >= 0; j--) +#define FOR_NSCREENS(j) FOR_NSCREENS_FORWARD(j) + +#define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared) + +#define IS_ROOT_DRAWABLE(d) (((d)->type == XRT_WINDOW) && (d)->u.win.root) +#endif /* _PANORAMIX_H_ */ diff --git a/xorg-server/Xext/panoramiXprocs.c b/xorg-server/Xext/panoramiXprocs.c index 615246bab..9ea461173 100644 --- a/xorg-server/Xext/panoramiXprocs.c +++ b/xorg-server/Xext/panoramiXprocs.c @@ -1,2428 +1,2418 @@ -/***************************************************************** -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. -******************************************************************/ - -/* Massively rewritten by Mark Vojkovich */ - - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include -#include -#include -#include "windowstr.h" -#include "dixfontstr.h" -#include "gcstruct.h" -#include "colormapst.h" -#include "scrnintstr.h" -#include "opaque.h" -#include "inputstr.h" -#include "migc.h" -#include "misc.h" -#include "dixstruct.h" -#include "panoramiX.h" -#include "panoramiXsrv.h" -#include "resource.h" -#include "panoramiXh.h" - -#define XINERAMA_IMAGE_BUFSIZE (256*1024) -#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \ - CWDontPropagate | CWOverrideRedirect | CWCursor ) - -int PanoramiXCreateWindow(ClientPtr client) -{ - PanoramiXRes *parent, *newWin; - PanoramiXRes *backPix = NULL; - PanoramiXRes *bordPix = NULL; - PanoramiXRes *cmap = NULL; - REQUEST(xCreateWindowReq); - int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; - int result, len, j; - int orig_x, orig_y; - XID orig_visual, tmp; - Bool parentIsRoot; - - REQUEST_AT_LEAST_SIZE(xCreateWindowReq); - - len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq)); - if (Ones(stuff->mask) != len) - return BadLength; - - result = dixLookupResourceByType((pointer *)&parent, stuff->parent, - XRT_WINDOW, client, DixWriteAccess); - if (result != Success) - return result; - - if(stuff->class == CopyFromParent) - stuff->class = parent->u.win.class; - - if((stuff->class == InputOnly) && (stuff->mask & (~INPUTONLY_LEGAL_MASK))) - return BadMatch; - - if ((Mask)stuff->mask & CWBackPixmap) { - pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1)); - tmp = *((CARD32 *) &stuff[1] + pback_offset); - if ((tmp != None) && (tmp != ParentRelative)) { - result = dixLookupResourceByType((pointer *)&backPix, tmp, - XRT_PIXMAP, client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->mask & CWBorderPixmap) { - pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1)); - tmp = *((CARD32 *) &stuff[1] + pbord_offset); - if (tmp != CopyFromParent) { - result = dixLookupResourceByType((pointer *)&bordPix, tmp, - XRT_PIXMAP, client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->mask & CWColormap) { - cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1)); - tmp = *((CARD32 *) &stuff[1] + cmap_offset); - if ((tmp != CopyFromParent) && (tmp != None)) { - result = dixLookupResourceByType((pointer *)&cmap, tmp, - XRT_COLORMAP, client, DixReadAccess); - if (result != Success) - return result; - } - } - - if(!(newWin = malloc(sizeof(PanoramiXRes)))) - return BadAlloc; - - newWin->type = XRT_WINDOW; - newWin->u.win.visibility = VisibilityNotViewable; - newWin->u.win.class = stuff->class; - newWin->u.win.root = FALSE; - newWin->info[0].id = stuff->wid; - for(j = 1; j < PanoramiXNumScreens; j++) - newWin->info[j].id = FakeClientID(client->index); - - if (stuff->class == InputOnly) - stuff->visual = CopyFromParent; - orig_visual = stuff->visual; - orig_x = stuff->x; - orig_y = stuff->y; - parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) || - (stuff->parent == screenInfo.screens[0]->screensaver.wid); - FOR_NSCREENS_BACKWARD(j) { - stuff->wid = newWin->info[j].id; - stuff->parent = parent->info[j].id; - if (parentIsRoot) { - stuff->x = orig_x - screenInfo.screens[j]->x; - stuff->y = orig_y - screenInfo.screens[j]->y; - } - if (backPix) - *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; - if (bordPix) - *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; - if (cmap) - *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; - if ( orig_visual != CopyFromParent ) - stuff->visual = PanoramiXTranslateVisualID(j, orig_visual); - result = (*SavedProcVector[X_CreateWindow])(client); - if(result != Success) break; - } - - if (result == Success) - AddResource(newWin->info[0].id, XRT_WINDOW, newWin); - else - free(newWin); - - return result; -} - - -int PanoramiXChangeWindowAttributes(ClientPtr client) -{ - PanoramiXRes *win; - PanoramiXRes *backPix = NULL; - PanoramiXRes *bordPix = NULL; - PanoramiXRes *cmap = NULL; - REQUEST(xChangeWindowAttributesReq); - int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; - int result, len, j; - XID tmp; - - REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); - - len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq)); - if (Ones(stuff->valueMask) != len) - return BadLength; - - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixWriteAccess); - if (result != Success) - return result; - - if((win->u.win.class == InputOnly) && - (stuff->valueMask & (~INPUTONLY_LEGAL_MASK))) - return BadMatch; - - if ((Mask)stuff->valueMask & CWBackPixmap) { - pback_offset = Ones((Mask)stuff->valueMask & (CWBackPixmap - 1)); - tmp = *((CARD32 *) &stuff[1] + pback_offset); - if ((tmp != None) && (tmp != ParentRelative)) { - result = dixLookupResourceByType((pointer *)&backPix, tmp, - XRT_PIXMAP, client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->valueMask & CWBorderPixmap) { - pbord_offset = Ones((Mask)stuff->valueMask & (CWBorderPixmap - 1)); - tmp = *((CARD32 *) &stuff[1] + pbord_offset); - if (tmp != CopyFromParent) { - result = dixLookupResourceByType((pointer *)&bordPix, tmp, - XRT_PIXMAP, client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->valueMask & CWColormap) { - cmap_offset = Ones((Mask)stuff->valueMask & (CWColormap - 1)); - tmp = *((CARD32 *) &stuff[1] + cmap_offset); - if ((tmp != CopyFromParent) && (tmp != None)) { - result = dixLookupResourceByType((pointer *)&cmap, tmp, - XRT_COLORMAP, client, DixReadAccess); - if (result != Success) - return result; - } - } - - FOR_NSCREENS_BACKWARD(j) { - stuff->window = win->info[j].id; - if (backPix) - *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; - if (bordPix) - *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; - if (cmap) - *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; - result = (*SavedProcVector[X_ChangeWindowAttributes])(client); - } - - return result; -} - - -int PanoramiXDestroyWindow(ClientPtr client) -{ - PanoramiXRes *win; - int result, j; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - - result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW, - client, DixDestroyAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_DestroyWindow])(client); - if(result != Success) break; - } - - /* Since ProcDestroyWindow is using FreeResource, it will free - our resource for us on the last pass through the loop above */ - - return result; -} - - -int PanoramiXDestroySubwindows(ClientPtr client) -{ - PanoramiXRes *win; - int result, j; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - - result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW, - client, DixDestroyAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_DestroySubwindows])(client); - if(result != Success) break; - } - - /* DestroySubwindows is using FreeResource which will free - our resources for us on the last pass through the loop above */ - - return result; -} - - -int PanoramiXChangeSaveSet(ClientPtr client) -{ - PanoramiXRes *win; - int result, j; - REQUEST(xChangeSaveSetReq); - - REQUEST_SIZE_MATCH(xChangeSaveSetReq); - - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixReadAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j) { - stuff->window = win->info[j].id; - result = (*SavedProcVector[X_ChangeSaveSet])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXReparentWindow(ClientPtr client) -{ - PanoramiXRes *win, *parent; - int result, j; - int x, y; - Bool parentIsRoot; - REQUEST(xReparentWindowReq); - - REQUEST_SIZE_MATCH(xReparentWindowReq); - - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixWriteAccess); - if (result != Success) - return result; - - result = dixLookupResourceByType((pointer *)&parent, stuff->parent, - XRT_WINDOW, client, DixWriteAccess); - if (result != Success) - return result; - - x = stuff->x; - y = stuff->y; - parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) || - (stuff->parent == screenInfo.screens[0]->screensaver.wid); - FOR_NSCREENS_BACKWARD(j) { - stuff->window = win->info[j].id; - stuff->parent = parent->info[j].id; - if(parentIsRoot) { - stuff->x = x - screenInfo.screens[j]->x; - stuff->y = y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_ReparentWindow])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXMapWindow(ClientPtr client) -{ - PanoramiXRes *win; - int result, j; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - - result = dixLookupResourceByType((pointer *)&win, stuff->id, - XRT_WINDOW, client, DixReadAccess); - if (result != Success) - return result; - - FOR_NSCREENS_FORWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_MapWindow])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXMapSubwindows(ClientPtr client) -{ - PanoramiXRes *win; - int result, j; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - - result = dixLookupResourceByType((pointer *)&win, stuff->id, - XRT_WINDOW, client, DixReadAccess); - if (result != Success) - return result; - - FOR_NSCREENS_FORWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_MapSubwindows])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXUnmapWindow(ClientPtr client) -{ - PanoramiXRes *win; - int result, j; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - - result = dixLookupResourceByType((pointer *)&win, stuff->id, - XRT_WINDOW, client, DixReadAccess); - if (result != Success) - return result; - - FOR_NSCREENS_FORWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_UnmapWindow])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXUnmapSubwindows(ClientPtr client) -{ - PanoramiXRes *win; - int result, j; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - - result = dixLookupResourceByType((pointer *)&win, stuff->id, - XRT_WINDOW, client, DixReadAccess); - if (result != Success) - return result; - - FOR_NSCREENS_FORWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_UnmapSubwindows])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXConfigureWindow(ClientPtr client) -{ - PanoramiXRes *win; - PanoramiXRes *sib = NULL; - WindowPtr pWin; - int result, j, len, sib_offset = 0, x = 0, y = 0; - int x_offset = -1; - int y_offset = -1; - REQUEST(xConfigureWindowReq); - - REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); - - len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq)); - if (Ones(stuff->mask) != len) - return BadLength; - - /* because we need the parent */ - result = dixLookupResourceByType((pointer *)&pWin, stuff->window, - RT_WINDOW, client, DixWriteAccess); - if (result != Success) - return result; - - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixWriteAccess); - if (result != Success) - return result; - - if ((Mask)stuff->mask & CWSibling) { - XID tmp; - sib_offset = Ones((Mask)stuff->mask & (CWSibling - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + sib_offset))) { - result = dixLookupResourceByType((pointer *)&sib, tmp, XRT_WINDOW, - client, DixReadAccess); - if (result != Success) - return result; - } - } - - if(pWin->parent && ((pWin->parent == screenInfo.screens[0]->root) || - (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid))) - { - if ((Mask)stuff->mask & CWX) { - x_offset = 0; - x = *((CARD32 *)&stuff[1]); - } - if ((Mask)stuff->mask & CWY) { - y_offset = (x_offset == -1) ? 0 : 1; - y = *((CARD32 *) &stuff[1] + y_offset); - } - } - - /* have to go forward or you get expose events before - ConfigureNotify events */ - FOR_NSCREENS_FORWARD(j) { - stuff->window = win->info[j].id; - if(sib) - *((CARD32 *) &stuff[1] + sib_offset) = sib->info[j].id; - if(x_offset >= 0) - *((CARD32 *) &stuff[1] + x_offset) = x - screenInfo.screens[j]->x; - if(y_offset >= 0) - *((CARD32 *) &stuff[1] + y_offset) = y - screenInfo.screens[j]->y; - result = (*SavedProcVector[X_ConfigureWindow])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXCirculateWindow(ClientPtr client) -{ - PanoramiXRes *win; - int result, j; - REQUEST(xCirculateWindowReq); - - REQUEST_SIZE_MATCH(xCirculateWindowReq); - - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixWriteAccess); - if (result != Success) - return result; - - FOR_NSCREENS_FORWARD(j) { - stuff->window = win->info[j].id; - result = (*SavedProcVector[X_CirculateWindow])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXGetGeometry(ClientPtr client) -{ - xGetGeometryReply rep; - DrawablePtr pDraw; - int rc; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixGetAttrAccess); - if (rc != Success) - return rc; - - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.root = screenInfo.screens[0]->root->drawable.id; - rep.depth = pDraw->depth; - rep.width = pDraw->width; - rep.height = pDraw->height; - rep.x = rep.y = rep.borderWidth = 0; - - if (stuff->id == rep.root) { - xWindowRoot *root = (xWindowRoot *) - (ConnectionInfo + connBlockScreenStart); - - rep.width = root->pixWidth; - rep.height = root->pixHeight; - } else - if (WindowDrawable(pDraw->type)) - { - WindowPtr pWin = (WindowPtr)pDraw; - rep.x = pWin->origin.x - wBorderWidth (pWin); - rep.y = pWin->origin.y - wBorderWidth (pWin); - if((pWin->parent == screenInfo.screens[0]->root) || - (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid)) - { - rep.x += screenInfo.screens[0]->x; - rep.y += screenInfo.screens[0]->y; - } - rep.borderWidth = pWin->borderWidth; - } - - WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep); - return Success; -} - -int PanoramiXTranslateCoords(ClientPtr client) -{ - INT16 x, y; - REQUEST(xTranslateCoordsReq); - int rc; - WindowPtr pWin, pDst; - xTranslateCoordsReply rep; - - REQUEST_SIZE_MATCH(xTranslateCoordsReq); - rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess); - if (rc != Success) - return rc; - rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess); - if (rc != Success) - return rc; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.sameScreen = xTrue; - rep.child = None; - - if((pWin == screenInfo.screens[0]->root) || - (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid)) - { - x = stuff->srcX - screenInfo.screens[0]->x; - y = stuff->srcY - screenInfo.screens[0]->y; - } else { - x = pWin->drawable.x + stuff->srcX; - y = pWin->drawable.y + stuff->srcY; - } - pWin = pDst->firstChild; - while (pWin) { - BoxRec box; - if ((pWin->mapped) && - (x >= pWin->drawable.x - wBorderWidth (pWin)) && - (x < pWin->drawable.x + (int)pWin->drawable.width + - wBorderWidth (pWin)) && - (y >= pWin->drawable.y - wBorderWidth (pWin)) && - (y < pWin->drawable.y + (int)pWin->drawable.height + - wBorderWidth (pWin)) - /* When a window is shaped, a further check - * is made to see if the point is inside - * borderSize - */ - && (!wBoundingShape(pWin) || - RegionContainsPoint(wBoundingShape(pWin), - x - pWin->drawable.x, - y - pWin->drawable.y, &box)) - ) - { - rep.child = pWin->drawable.id; - pWin = (WindowPtr) NULL; - } - else - pWin = pWin->nextSib; - } - rep.dstX = x - pDst->drawable.x; - rep.dstY = y - pDst->drawable.y; - if((pDst == screenInfo.screens[0]->root) || - (pDst->drawable.id == screenInfo.screens[0]->screensaver.wid)) - { - rep.dstX += screenInfo.screens[0]->x; - rep.dstY += screenInfo.screens[0]->y; - } - - WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); - return Success; -} - -int PanoramiXCreatePixmap(ClientPtr client) -{ - PanoramiXRes *refDraw, *newPix; - int result, j; - REQUEST(xCreatePixmapReq); - - REQUEST_SIZE_MATCH(xCreatePixmapReq); - client->errorValue = stuff->pid; - - result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable, - XRC_DRAWABLE, client, DixReadAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(!(newPix = malloc(sizeof(PanoramiXRes)))) - return BadAlloc; - - newPix->type = XRT_PIXMAP; - newPix->u.pix.shared = FALSE; - newPix->info[0].id = stuff->pid; - for(j = 1; j < PanoramiXNumScreens; j++) - newPix->info[j].id = FakeClientID(client->index); - - FOR_NSCREENS_BACKWARD(j) { - stuff->pid = newPix->info[j].id; - stuff->drawable = refDraw->info[j].id; - result = (*SavedProcVector[X_CreatePixmap])(client); - if(result != Success) break; - } - - if (result == Success) - AddResource(newPix->info[0].id, XRT_PIXMAP, newPix); - else - free(newPix); - - return result; -} - - -int PanoramiXFreePixmap(ClientPtr client) -{ - PanoramiXRes *pix; - int result, j; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - - client->errorValue = stuff->id; - - result = dixLookupResourceByType((pointer *)&pix, stuff->id, XRT_PIXMAP, - client, DixDestroyAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j) { - stuff->id = pix->info[j].id; - result = (*SavedProcVector[X_FreePixmap])(client); - if(result != Success) break; - } - - /* Since ProcFreePixmap is using FreeResource, it will free - our resource for us on the last pass through the loop above */ - - return result; -} - - -int PanoramiXCreateGC(ClientPtr client) -{ - PanoramiXRes *refDraw; - PanoramiXRes *newGC; - PanoramiXRes *stip = NULL; - PanoramiXRes *tile = NULL; - PanoramiXRes *clip = NULL; - REQUEST(xCreateGCReq); - int tile_offset = 0, stip_offset = 0, clip_offset = 0; - int result, len, j; - XID tmp; - - REQUEST_AT_LEAST_SIZE(xCreateGCReq); - - client->errorValue = stuff->gc; - len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq)); - if (Ones(stuff->mask) != len) - return BadLength; - - result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable, - XRC_DRAWABLE, client, DixReadAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if ((Mask)stuff->mask & GCTile) { - tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { - result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->mask & GCStipple) { - stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { - result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->mask & GCClipMask) { - clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { - result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } - } - - if(!(newGC = malloc(sizeof(PanoramiXRes)))) - return BadAlloc; - - newGC->type = XRT_GC; - newGC->info[0].id = stuff->gc; - for(j = 1; j < PanoramiXNumScreens; j++) - newGC->info[j].id = FakeClientID(client->index); - - FOR_NSCREENS_BACKWARD(j) { - stuff->gc = newGC->info[j].id; - stuff->drawable = refDraw->info[j].id; - if (tile) - *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; - if (stip) - *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; - if (clip) - *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; - result = (*SavedProcVector[X_CreateGC])(client); - if(result != Success) break; - } - - if (result == Success) - AddResource(newGC->info[0].id, XRT_GC, newGC); - else - free(newGC); - - return result; -} - -int PanoramiXChangeGC(ClientPtr client) -{ - PanoramiXRes *gc; - PanoramiXRes *stip = NULL; - PanoramiXRes *tile = NULL; - PanoramiXRes *clip = NULL; - REQUEST(xChangeGCReq); - int tile_offset = 0, stip_offset = 0, clip_offset = 0; - int result, len, j; - XID tmp; - - REQUEST_AT_LEAST_SIZE(xChangeGCReq); - - len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq)); - if (Ones(stuff->mask) != len) - return BadLength; - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - if ((Mask)stuff->mask & GCTile) { - tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { - result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->mask & GCStipple) { - stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { - result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->mask & GCClipMask) { - clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { - result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } - } - - - FOR_NSCREENS_BACKWARD(j) { - stuff->gc = gc->info[j].id; - if (tile) - *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; - if (stip) - *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; - if (clip) - *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; - result = (*SavedProcVector[X_ChangeGC])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXCopyGC(ClientPtr client) -{ - PanoramiXRes *srcGC, *dstGC; - int result, j; - REQUEST(xCopyGCReq); - - REQUEST_SIZE_MATCH(xCopyGCReq); - - result = dixLookupResourceByType((pointer *)&srcGC, stuff->srcGC, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - result = dixLookupResourceByType((pointer *)&dstGC, stuff->dstGC, XRT_GC, - client, DixWriteAccess); - if (result != Success) - return result; - - FOR_NSCREENS(j) { - stuff->srcGC = srcGC->info[j].id; - stuff->dstGC = dstGC->info[j].id; - result = (*SavedProcVector[X_CopyGC])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXSetDashes(ClientPtr client) -{ - PanoramiXRes *gc; - int result, j; - REQUEST(xSetDashesReq); - - REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixWriteAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j) { - stuff->gc = gc->info[j].id; - result = (*SavedProcVector[X_SetDashes])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXSetClipRectangles(ClientPtr client) -{ - PanoramiXRes *gc; - int result, j; - REQUEST(xSetClipRectanglesReq); - - REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixWriteAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j) { - stuff->gc = gc->info[j].id; - result = (*SavedProcVector[X_SetClipRectangles])(client); - if(result != Success) break; - } - - return result; -} - - -int PanoramiXFreeGC(ClientPtr client) -{ - PanoramiXRes *gc; - int result, j; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - - result = dixLookupResourceByType((pointer *)&gc, stuff->id, XRT_GC, - client, DixDestroyAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j) { - stuff->id = gc->info[j].id; - result = (*SavedProcVector[X_FreeGC])(client); - if(result != Success) break; - } - - /* Since ProcFreeGC is using FreeResource, it will free - our resource for us on the last pass through the loop above */ - - return result; -} - - -int PanoramiXClearToBackground(ClientPtr client) -{ - PanoramiXRes *win; - int result, j, x, y; - Bool isRoot; - REQUEST(xClearAreaReq); - - REQUEST_SIZE_MATCH(xClearAreaReq); - - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixWriteAccess); - if (result != Success) - return result; - - x = stuff->x; - y = stuff->y; - isRoot = win->u.win.root; - FOR_NSCREENS_BACKWARD(j) { - stuff->window = win->info[j].id; - if(isRoot) { - stuff->x = x - screenInfo.screens[j]->x; - stuff->y = y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_ClearArea])(client); - if(result != Success) break; - } - - return result; -} - - -/* - For Window to Pixmap copies you're screwed since each screen's - pixmap will look like what it sees on its screen. Unless the - screens overlap and the window lies on each, the two copies - will be out of sync. To remedy this we do a GetImage and PutImage - in place of the copy. Doing this as a single Image isn't quite - correct since it will include the obscured areas but we will - have to fix this later. (MArk). -*/ - -int PanoramiXCopyArea(ClientPtr client) -{ - int j, result, srcx, srcy, dstx, dsty; - PanoramiXRes *gc, *src, *dst; - Bool srcIsRoot = FALSE; - Bool dstIsRoot = FALSE; - Bool srcShared, dstShared; - REQUEST(xCopyAreaReq); - - REQUEST_SIZE_MATCH(xCopyAreaReq); - - result = dixLookupResourceByClass((pointer *)&src, stuff->srcDrawable, - XRC_DRAWABLE, client, DixReadAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - srcShared = IS_SHARED_PIXMAP(src); - - result = dixLookupResourceByClass((pointer *)&dst, stuff->dstDrawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - dstShared = IS_SHARED_PIXMAP(dst); - - if(dstShared && srcShared) - return (* SavedProcVector[X_CopyArea])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - if((dst->type == XRT_WINDOW) && dst->u.win.root) - dstIsRoot = TRUE; - if((src->type == XRT_WINDOW) && src->u.win.root) - srcIsRoot = TRUE; - - srcx = stuff->srcX; srcy = stuff->srcY; - dstx = stuff->dstX; dsty = stuff->dstY; - if((dst->type == XRT_PIXMAP) && (src->type == XRT_WINDOW)) { - DrawablePtr drawables[MAXSCREENS]; - DrawablePtr pDst; - GCPtr pGC; - char *data; - int pitch, rc; - - FOR_NSCREENS(j) { - rc = dixLookupDrawable(drawables+j, src->info[j].id, client, 0, - DixGetAttrAccess); - if (rc != Success) - return rc; - } - - pitch = PixmapBytePad(stuff->width, drawables[0]->depth); - if(!(data = calloc(1, stuff->height * pitch))) - return BadAlloc; - - XineramaGetImageData(drawables, srcx, srcy, - stuff->width, stuff->height, ZPixmap, ~0, data, pitch, - srcIsRoot); - - FOR_NSCREENS_BACKWARD(j) { - stuff->gc = gc->info[j].id; - VALIDATE_DRAWABLE_AND_GC(dst->info[j].id, pDst, DixWriteAccess); - if(drawables[0]->depth != pDst->depth) { - client->errorValue = stuff->dstDrawable; - free(data); - return BadMatch; - } - - (*pGC->ops->PutImage) (pDst, pGC, pDst->depth, dstx, dsty, - stuff->width, stuff->height, - 0, ZPixmap, data); - - if(dstShared) break; - } - - free(data); - } else { - DrawablePtr pDst = NULL, pSrc = NULL; - GCPtr pGC = NULL; - RegionRec totalReg; - int rc; - - RegionNull(&totalReg); - FOR_NSCREENS_BACKWARD(j) { - RegionPtr pRgn; - stuff->dstDrawable = dst->info[j].id; - stuff->srcDrawable = src->info[j].id; - stuff->gc = gc->info[j].id; - if (srcIsRoot) { - stuff->srcX = srcx - screenInfo.screens[j]->x; - stuff->srcY = srcy - screenInfo.screens[j]->y; - } - if (dstIsRoot) { - stuff->dstX = dstx - screenInfo.screens[j]->x; - stuff->dstY = dsty - screenInfo.screens[j]->y; - } - - VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess); - - if (stuff->dstDrawable != stuff->srcDrawable) { - rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0, - DixReadAccess); - if (rc != Success) - return rc; - - if ((pDst->pScreen != pSrc->pScreen) || - (pDst->depth != pSrc->depth)) { - client->errorValue = stuff->dstDrawable; - return BadMatch; - } - } else - pSrc = pDst; - - pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, - stuff->srcX, stuff->srcY, - stuff->width, stuff->height, - stuff->dstX, stuff->dstY); - if(pGC->graphicsExposures && pRgn) { - if(srcIsRoot) { - RegionTranslate(pRgn, - screenInfo.screens[j]->x, screenInfo.screens[j]->y); - } - RegionAppend(&totalReg, pRgn); - RegionDestroy(pRgn); - } - - if(dstShared) - break; - } - - if(pGC->graphicsExposures) { - Bool overlap; - RegionValidate(&totalReg, &overlap); - (*pDst->pScreen->SendGraphicsExpose)( - client, &totalReg, stuff->dstDrawable, X_CopyArea, 0); - RegionUninit(&totalReg); - } - } - - return Success; -} - - -int PanoramiXCopyPlane(ClientPtr client) -{ - int j, srcx, srcy, dstx, dsty, rc; - PanoramiXRes *gc, *src, *dst; - Bool srcIsRoot = FALSE; - Bool dstIsRoot = FALSE; - Bool srcShared, dstShared; - DrawablePtr psrcDraw, pdstDraw = NULL; - GCPtr pGC = NULL; - RegionRec totalReg; - REQUEST(xCopyPlaneReq); - - REQUEST_SIZE_MATCH(xCopyPlaneReq); - - rc = dixLookupResourceByClass((pointer *)&src, stuff->srcDrawable, - XRC_DRAWABLE, client, DixReadAccess); - if (rc != Success) - return (rc == BadValue) ? BadDrawable : rc; - - srcShared = IS_SHARED_PIXMAP(src); - - rc = dixLookupResourceByClass((pointer *)&dst, stuff->dstDrawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (rc != Success) - return (rc == BadValue) ? BadDrawable : rc; - - dstShared = IS_SHARED_PIXMAP(dst); - - if(dstShared && srcShared) - return (* SavedProcVector[X_CopyPlane])(client); - - rc = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (rc != Success) - return rc; - - if((dst->type == XRT_WINDOW) && dst->u.win.root) - dstIsRoot = TRUE; - if((src->type == XRT_WINDOW) && src->u.win.root) - srcIsRoot = TRUE; - - srcx = stuff->srcX; srcy = stuff->srcY; - dstx = stuff->dstX; dsty = stuff->dstY; - - RegionNull(&totalReg); - FOR_NSCREENS_BACKWARD(j) { - RegionPtr pRgn; - stuff->dstDrawable = dst->info[j].id; - stuff->srcDrawable = src->info[j].id; - stuff->gc = gc->info[j].id; - if (srcIsRoot) { - stuff->srcX = srcx - screenInfo.screens[j]->x; - stuff->srcY = srcy - screenInfo.screens[j]->y; - } - if (dstIsRoot) { - stuff->dstX = dstx - screenInfo.screens[j]->x; - stuff->dstY = dsty - screenInfo.screens[j]->y; - } - - VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess); - if (stuff->dstDrawable != stuff->srcDrawable) { - rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0, - DixReadAccess); - if (rc != Success) - return rc; - - if (pdstDraw->pScreen != psrcDraw->pScreen) { - client->errorValue = stuff->dstDrawable; - return BadMatch; - } - } else - psrcDraw = pdstDraw; - - if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) || - (stuff->bitPlane > (1L << (psrcDraw->depth - 1)))) { - client->errorValue = stuff->bitPlane; - return BadValue; - } - - pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, - stuff->srcX, stuff->srcY, - stuff->width, stuff->height, - stuff->dstX, stuff->dstY, stuff->bitPlane); - if(pGC->graphicsExposures && pRgn) { - RegionAppend(&totalReg, pRgn); - RegionDestroy(pRgn); - } - - if(dstShared) - break; - } - - if(pGC->graphicsExposures) { - Bool overlap; - RegionValidate(&totalReg, &overlap); - (*pdstDraw->pScreen->SendGraphicsExpose)( - client, &totalReg, stuff->dstDrawable, X_CopyPlane, 0); - RegionUninit(&totalReg); - } - - return Success; -} - - -int PanoramiXPolyPoint(ClientPtr client) -{ - PanoramiXRes *gc, *draw; - int result, npoint, j; - xPoint *origPts; - Bool isRoot; - REQUEST(xPolyPointReq); - - REQUEST_AT_LEAST_SIZE(xPolyPointReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyPoint])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq)); - if (npoint > 0) { - origPts = malloc(npoint * sizeof(xPoint)); - memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - if(x_off || y_off) { - xPoint *pnts = (xPoint*)&stuff[1]; - int i = (stuff->coordMode==CoordModePrevious) ? 1 : npoint; - - while(i--) { - pnts->x -= x_off; - pnts->y -= y_off; - pnts++; - } - } - } - - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyPoint])(client); - if(result != Success) break; - } - free(origPts); - return result; - } else - return Success; -} - - -int PanoramiXPolyLine(ClientPtr client) -{ - PanoramiXRes *gc, *draw; - int result, npoint, j; - xPoint *origPts; - Bool isRoot; - REQUEST(xPolyLineReq); - - REQUEST_AT_LEAST_SIZE(xPolyLineReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyLine])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq)); - if (npoint > 0){ - origPts = malloc(npoint * sizeof(xPoint)); - memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - if(x_off || y_off) { - xPoint *pnts = (xPoint*)&stuff[1]; - int i = (stuff->coordMode==CoordModePrevious) ? 1 : npoint; - - while(i--) { - pnts->x -= x_off; - pnts->y -= y_off; - pnts++; - } - } - } - - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyLine])(client); - if(result != Success) break; - } - free(origPts); - return result; - } else - return Success; -} - - -int PanoramiXPolySegment(ClientPtr client) -{ - int result, nsegs, i, j; - PanoramiXRes *gc, *draw; - xSegment *origSegs; - Bool isRoot; - REQUEST(xPolySegmentReq); - - REQUEST_AT_LEAST_SIZE(xPolySegmentReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolySegment])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq); - if(nsegs & 4) return BadLength; - nsegs >>= 3; - if (nsegs > 0) { - origSegs = malloc(nsegs * sizeof(xSegment)); - memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], origSegs, nsegs * sizeof(xSegment)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - if(x_off || y_off) { - xSegment *segs = (xSegment*)&stuff[1]; - - for (i = nsegs; i--; segs++) { - segs->x1 -= x_off; - segs->x2 -= x_off; - segs->y1 -= y_off; - segs->y2 -= y_off; - } - } - } - - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolySegment])(client); - if(result != Success) break; - } - free(origSegs); - return result; - } else - return Success; -} - - -int PanoramiXPolyRectangle(ClientPtr client) -{ - int result, nrects, i, j; - PanoramiXRes *gc, *draw; - Bool isRoot; - xRectangle *origRecs; - REQUEST(xPolyRectangleReq); - - REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyRectangle])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq); - if(nrects & 4) return BadLength; - nrects >>= 3; - if (nrects > 0){ - origRecs = malloc(nrects * sizeof(xRectangle)); - memcpy((char *)origRecs,(char *)&stuff[1],nrects * sizeof(xRectangle)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], origRecs, nrects * sizeof(xRectangle)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - - if(x_off || y_off) { - xRectangle *rects = (xRectangle *) &stuff[1]; - - for (i = nrects; i--; rects++) { - rects->x -= x_off; - rects->y -= y_off; - } - } - } - - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyRectangle])(client); - if(result != Success) break; - } - free(origRecs); - return result; - } else - return Success; -} - - -int PanoramiXPolyArc(ClientPtr client) -{ - int result, narcs, i, j; - PanoramiXRes *gc, *draw; - Bool isRoot; - xArc *origArcs; - REQUEST(xPolyArcReq); - - REQUEST_AT_LEAST_SIZE(xPolyArcReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyArc])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - narcs = (client->req_len << 2) - sizeof(xPolyArcReq); - if(narcs % sizeof(xArc)) return BadLength; - narcs /= sizeof(xArc); - if (narcs > 0){ - origArcs = malloc(narcs * sizeof(xArc)); - memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - if(x_off || y_off) { - xArc *arcs = (xArc *) &stuff[1]; - - for (i = narcs; i--; arcs++) { - arcs->x -= x_off; - arcs->y -= y_off; - } - } - } - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyArc])(client); - if(result != Success) break; - } - free(origArcs); - return result; - } else - return Success; -} - - -int PanoramiXFillPoly(ClientPtr client) -{ - int result, count, j; - PanoramiXRes *gc, *draw; - Bool isRoot; - DDXPointPtr locPts; - REQUEST(xFillPolyReq); - - REQUEST_AT_LEAST_SIZE(xFillPolyReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_FillPoly])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq)); - if (count > 0){ - locPts = malloc(count * sizeof(DDXPointRec)); - memcpy((char *)locPts, (char *)&stuff[1], count * sizeof(DDXPointRec)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], locPts, count * sizeof(DDXPointRec)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - if(x_off || y_off) { - DDXPointPtr pnts = (DDXPointPtr)&stuff[1]; - int i = (stuff->coordMode==CoordModePrevious) ? 1 : count; - - while(i--) { - pnts->x -= x_off; - pnts->y -= y_off; - pnts++; - } - } - } - - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_FillPoly])(client); - if(result != Success) break; - } - free(locPts); - return result; - } else - return Success; -} - - -int PanoramiXPolyFillRectangle(ClientPtr client) -{ - int result, things, i, j; - PanoramiXRes *gc, *draw; - Bool isRoot; - xRectangle *origRects; - REQUEST(xPolyFillRectangleReq); - - REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyFillRectangle])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq); - if(things & 4) return BadLength; - things >>= 3; - if (things > 0){ - origRects = malloc(things * sizeof(xRectangle)); - memcpy((char*)origRects,(char*)&stuff[1], things * sizeof(xRectangle)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], origRects, things * sizeof(xRectangle)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - if(x_off || y_off) { - xRectangle *rects = (xRectangle *) &stuff[1]; - - for (i = things; i--; rects++) { - rects->x -= x_off; - rects->y -= y_off; - } - } - } - - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyFillRectangle])(client); - if(result != Success) break; - } - free(origRects); - return result; - } else - return Success; -} - - -int PanoramiXPolyFillArc(ClientPtr client) -{ - PanoramiXRes *gc, *draw; - Bool isRoot; - int result, narcs, i, j; - xArc *origArcs; - REQUEST(xPolyFillArcReq); - - REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyFillArc])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq); - if (narcs % sizeof(xArc)) return BadLength; - narcs /= sizeof(xArc); - if (narcs > 0) { - origArcs = malloc(narcs * sizeof(xArc)); - memcpy((char *) origArcs, (char *)&stuff[1], narcs * sizeof(xArc)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - if(x_off || y_off) { - xArc *arcs = (xArc *) &stuff[1]; - - for (i = narcs; i--; arcs++) { - arcs->x -= x_off; - arcs->y -= y_off; - } - } - } - - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyFillArc])(client); - if(result != Success) break; - } - free(origArcs); - return result; - } else - return Success; -} - - -int PanoramiXPutImage(ClientPtr client) -{ - PanoramiXRes *gc, *draw; - Bool isRoot; - int j, result, orig_x, orig_y; - REQUEST(xPutImageReq); - - REQUEST_AT_LEAST_SIZE(xPutImageReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PutImage])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - orig_x = stuff->dstX; - orig_y = stuff->dstY; - FOR_NSCREENS_BACKWARD(j){ - if (isRoot) { - stuff->dstX = orig_x - screenInfo.screens[j]->x; - stuff->dstY = orig_y - screenInfo.screens[j]->y; - } - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PutImage])(client); - if(result != Success) break; - } - return result; -} - - -int PanoramiXGetImage(ClientPtr client) -{ - DrawablePtr drawables[MAXSCREENS]; - DrawablePtr pDraw; - PanoramiXRes *draw; - xGetImageReply xgi; - Bool isRoot; - char *pBuf; - int i, x, y, w, h, format, rc; - Mask plane = 0, planemask; - int linesDone, nlines, linesPerBuf; - long widthBytesLine, length; - - REQUEST(xGetImageReq); - - REQUEST_SIZE_MATCH(xGetImageReq); - - if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) { - client->errorValue = stuff->format; - return BadValue; - } - - rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (rc != Success) - return (rc == BadValue) ? BadDrawable : rc; - - if(draw->type == XRT_PIXMAP) - return (*SavedProcVector[X_GetImage])(client); - - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, - DixReadAccess); - if (rc != Success) - return rc; - - if(!((WindowPtr)pDraw)->realized) - return BadMatch; - - x = stuff->x; - y = stuff->y; - w = stuff->width; - h = stuff->height; - format = stuff->format; - planemask = stuff->planeMask; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - if(isRoot) { - if( /* check for being onscreen */ - x < 0 || x + w > PanoramiXPixWidth || - y < 0 || y + h > PanoramiXPixHeight ) - return BadMatch; - } else { - if( /* check for being onscreen */ - screenInfo.screens[0]->x + pDraw->x + x < 0 || - screenInfo.screens[0]->x + pDraw->x + x + w > PanoramiXPixWidth || - screenInfo.screens[0]->y + pDraw->y + y < 0 || - screenInfo.screens[0]->y + pDraw->y + y + h > PanoramiXPixHeight || - /* check for being inside of border */ - x < - wBorderWidth((WindowPtr)pDraw) || - x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width || - y < -wBorderWidth((WindowPtr)pDraw) || - y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height) - return BadMatch; - } - - drawables[0] = pDraw; - for(i = 1; i < PanoramiXNumScreens; i++) { - rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0, - DixGetAttrAccess); - if (rc != Success) - return rc; - } - - xgi.visual = wVisual (((WindowPtr) pDraw)); - xgi.type = X_Reply; - xgi.sequenceNumber = client->sequence; - xgi.depth = pDraw->depth; - if(format == ZPixmap) { - widthBytesLine = PixmapBytePad(w, pDraw->depth); - length = widthBytesLine * h; - - - } else { - widthBytesLine = BitmapBytePad(w); - plane = ((Mask)1) << (pDraw->depth - 1); - /* only planes asked for */ - length = widthBytesLine * h * - Ones(planemask & (plane | (plane - 1))); - - } - - xgi.length = bytes_to_int32(length); - - if (widthBytesLine == 0 || h == 0) - linesPerBuf = 0; - else if (widthBytesLine >= XINERAMA_IMAGE_BUFSIZE) - linesPerBuf = 1; - else { - linesPerBuf = XINERAMA_IMAGE_BUFSIZE / widthBytesLine; - if (linesPerBuf > h) - linesPerBuf = h; - } - length = linesPerBuf * widthBytesLine; - if(!(pBuf = malloc(length))) - return BadAlloc; - - WriteReplyToClient(client, sizeof (xGetImageReply), &xgi); - - if (linesPerBuf == 0) { - /* nothing to do */ - } - else if (format == ZPixmap) { - linesDone = 0; - while (h - linesDone > 0) { - nlines = min(linesPerBuf, h - linesDone); - - if(pDraw->depth == 1) - memset(pBuf, 0, nlines * widthBytesLine); - - XineramaGetImageData(drawables, x, y + linesDone, w, nlines, - format, planemask, pBuf, widthBytesLine, isRoot); - - (void)WriteToClient(client, - (int)(nlines * widthBytesLine), - pBuf); - linesDone += nlines; - } - } else { /* XYPixmap */ - for (; plane; plane >>= 1) { - if (planemask & plane) { - linesDone = 0; - while (h - linesDone > 0) { - nlines = min(linesPerBuf, h - linesDone); - - memset(pBuf, 0, nlines * widthBytesLine); - - XineramaGetImageData(drawables, x, y + linesDone, w, - nlines, format, plane, pBuf, - widthBytesLine, isRoot); - - (void)WriteToClient(client, - (int)(nlines * widthBytesLine), - pBuf); - - linesDone += nlines; - } - } - } - } - free(pBuf); - return Success; -} - - -/* The text stuff should be rewritten so that duplication happens - at the GlyphBlt level. That is, loading the font and getting - the glyphs should only happen once */ - -int -PanoramiXPolyText8(ClientPtr client) -{ - PanoramiXRes *gc, *draw; - Bool isRoot; - int result, j; - int orig_x, orig_y; - REQUEST(xPolyTextReq); - - REQUEST_AT_LEAST_SIZE(xPolyTextReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyText8])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - orig_x = stuff->x; - orig_y = stuff->y; - FOR_NSCREENS_BACKWARD(j){ - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - if (isRoot) { - stuff->x = orig_x - screenInfo.screens[j]->x; - stuff->y = orig_y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_PolyText8])(client); - if(result != Success) break; - } - return result; -} - -int -PanoramiXPolyText16(ClientPtr client) -{ - PanoramiXRes *gc, *draw; - Bool isRoot; - int result, j; - int orig_x, orig_y; - REQUEST(xPolyTextReq); - - REQUEST_AT_LEAST_SIZE(xPolyTextReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyText16])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - orig_x = stuff->x; - orig_y = stuff->y; - FOR_NSCREENS_BACKWARD(j){ - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - if (isRoot) { - stuff->x = orig_x - screenInfo.screens[j]->x; - stuff->y = orig_y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_PolyText16])(client); - if(result != Success) break; - } - return result; -} - - -int PanoramiXImageText8(ClientPtr client) -{ - int result, j; - PanoramiXRes *gc, *draw; - Bool isRoot; - int orig_x, orig_y; - REQUEST(xImageTextReq); - - REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_ImageText8])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - orig_x = stuff->x; - orig_y = stuff->y; - FOR_NSCREENS_BACKWARD(j){ - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - if (isRoot) { - stuff->x = orig_x - screenInfo.screens[j]->x; - stuff->y = orig_y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_ImageText8])(client); - if(result != Success) break; - } - return result; -} - - -int PanoramiXImageText16(ClientPtr client) -{ - int result, j; - PanoramiXRes *gc, *draw; - Bool isRoot; - int orig_x, orig_y; - REQUEST(xImageTextReq); - - REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_ImageText16])(client); - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - orig_x = stuff->x; - orig_y = stuff->y; - FOR_NSCREENS_BACKWARD(j){ - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - if (isRoot) { - stuff->x = orig_x - screenInfo.screens[j]->x; - stuff->y = orig_y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_ImageText16])(client); - if(result != Success) break; - } - return result; -} - - - -int PanoramiXCreateColormap(ClientPtr client) -{ - PanoramiXRes *win, *newCmap; - int result, j, orig_visual; - REQUEST(xCreateColormapReq); - - REQUEST_SIZE_MATCH(xCreateColormapReq); - - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixReadAccess); - if (result != Success) - return result; - - if(!(newCmap = malloc(sizeof(PanoramiXRes)))) - return BadAlloc; - - newCmap->type = XRT_COLORMAP; - newCmap->info[0].id = stuff->mid; - for(j = 1; j < PanoramiXNumScreens; j++) - newCmap->info[j].id = FakeClientID(client->index); - - orig_visual = stuff->visual; - FOR_NSCREENS_BACKWARD(j){ - stuff->mid = newCmap->info[j].id; - stuff->window = win->info[j].id; - stuff->visual = PanoramiXTranslateVisualID(j, orig_visual); - result = (* SavedProcVector[X_CreateColormap])(client); - if(result != Success) break; - } - - if (result == Success) - AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap); - else - free(newCmap); - - return result; -} - - -int PanoramiXFreeColormap(ClientPtr client) -{ - PanoramiXRes *cmap; - int result, j; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - - client->errorValue = stuff->id; - - result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, - client, DixDestroyAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j) { - stuff->id = cmap->info[j].id; - result = (* SavedProcVector[X_FreeColormap])(client); - if(result != Success) break; - } - - /* Since ProcFreeColormap is using FreeResource, it will free - our resource for us on the last pass through the loop above */ - - return result; -} - - -int -PanoramiXCopyColormapAndFree(ClientPtr client) -{ - PanoramiXRes *cmap, *newCmap; - int result, j; - REQUEST(xCopyColormapAndFreeReq); - - REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); - - client->errorValue = stuff->srcCmap; - - result = dixLookupResourceByType((pointer *)&cmap, stuff->srcCmap, - XRT_COLORMAP, client, - DixReadAccess | DixWriteAccess); - if (result != Success) - return result; - - if(!(newCmap = malloc(sizeof(PanoramiXRes)))) - return BadAlloc; - - newCmap->type = XRT_COLORMAP; - newCmap->info[0].id = stuff->mid; - for(j = 1; j < PanoramiXNumScreens; j++) - newCmap->info[j].id = FakeClientID(client->index); - - FOR_NSCREENS_BACKWARD(j){ - stuff->srcCmap = cmap->info[j].id; - stuff->mid = newCmap->info[j].id; - result = (* SavedProcVector[X_CopyColormapAndFree])(client); - if(result != Success) break; - } - - if (result == Success) - AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap); - else - free(newCmap); - - return result; -} - - -int PanoramiXInstallColormap(ClientPtr client) -{ - REQUEST(xResourceReq); - int result, j; - PanoramiXRes *cmap; - - REQUEST_SIZE_MATCH(xResourceReq); - - client->errorValue = stuff->id; - - result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, - client, DixReadAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j){ - stuff->id = cmap->info[j].id; - result = (* SavedProcVector[X_InstallColormap])(client); - if(result != Success) break; - } - return result; -} - - -int PanoramiXUninstallColormap(ClientPtr client) -{ - REQUEST(xResourceReq); - int result, j; - PanoramiXRes *cmap; - - REQUEST_SIZE_MATCH(xResourceReq); - - client->errorValue = stuff->id; - - result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, - client, DixReadAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j) { - stuff->id = cmap->info[j].id; - result = (* SavedProcVector[X_UninstallColormap])(client); - if(result != Success) break; - } - return result; -} - - -int PanoramiXAllocColor(ClientPtr client) -{ - int result, j; - PanoramiXRes *cmap; - REQUEST(xAllocColorReq); - - REQUEST_SIZE_MATCH(xAllocColorReq); - - client->errorValue = stuff->cmap; - - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j){ - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_AllocColor])(client); - if(result != Success) break; - } - return result; -} - - -int PanoramiXAllocNamedColor(ClientPtr client) -{ - int result, j; - PanoramiXRes *cmap; - REQUEST(xAllocNamedColorReq); - - REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes); - - client->errorValue = stuff->cmap; - - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j){ - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_AllocNamedColor])(client); - if(result != Success) break; - } - return result; -} - - -int PanoramiXAllocColorCells(ClientPtr client) -{ - int result, j; - PanoramiXRes *cmap; - REQUEST(xAllocColorCellsReq); - - REQUEST_SIZE_MATCH(xAllocColorCellsReq); - - client->errorValue = stuff->cmap; - - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j){ - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_AllocColorCells])(client); - if(result != Success) break; - } - return result; -} - - -int PanoramiXAllocColorPlanes(ClientPtr client) -{ - int result, j; - PanoramiXRes *cmap; - REQUEST(xAllocColorPlanesReq); - - REQUEST_SIZE_MATCH(xAllocColorPlanesReq); - - client->errorValue = stuff->cmap; - - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j){ - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_AllocColorPlanes])(client); - if(result != Success) break; - } - return result; -} - - - -int PanoramiXFreeColors(ClientPtr client) -{ - int result, j; - PanoramiXRes *cmap; - REQUEST(xFreeColorsReq); - - REQUEST_AT_LEAST_SIZE(xFreeColorsReq); - - client->errorValue = stuff->cmap; - - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j) { - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_FreeColors])(client); - } - return result; -} - - -int PanoramiXStoreColors(ClientPtr client) -{ - int result, j; - PanoramiXRes *cmap; - REQUEST(xStoreColorsReq); - - REQUEST_AT_LEAST_SIZE(xStoreColorsReq); - - client->errorValue = stuff->cmap; - - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j){ - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_StoreColors])(client); - if(result != Success) break; - } - return result; -} - - -int PanoramiXStoreNamedColor(ClientPtr client) -{ - int result, j; - PanoramiXRes *cmap; - REQUEST(xStoreNamedColorReq); - - REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes); - - client->errorValue = stuff->cmap; - - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(j){ - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_StoreNamedColor])(client); - if(result != Success) break; - } - return result; -} +/***************************************************************** +Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, +BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of Digital Equipment Corporation +shall not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from Digital +Equipment Corporation. +******************************************************************/ + +/* Massively rewritten by Mark Vojkovich */ + + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include +#include +#include "windowstr.h" +#include "dixfontstr.h" +#include "gcstruct.h" +#include "colormapst.h" +#include "scrnintstr.h" +#include "opaque.h" +#include "inputstr.h" +#include "migc.h" +#include "misc.h" +#include "dixstruct.h" +#include "panoramiX.h" +#include "panoramiXsrv.h" +#include "resource.h" +#include "panoramiXh.h" + +#define XINERAMA_IMAGE_BUFSIZE (256*1024) +#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \ + CWDontPropagate | CWOverrideRedirect | CWCursor ) + +int PanoramiXCreateWindow(ClientPtr client) +{ + PanoramiXRes *parent, *newWin; + PanoramiXRes *backPix = NULL; + PanoramiXRes *bordPix = NULL; + PanoramiXRes *cmap = NULL; + REQUEST(xCreateWindowReq); + int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; + int result, len, j; + int orig_x, orig_y; + XID orig_visual, tmp; + Bool parentIsRoot; + + REQUEST_AT_LEAST_SIZE(xCreateWindowReq); + + len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq)); + if (Ones(stuff->mask) != len) + return BadLength; + + result = dixLookupResourceByType((pointer *)&parent, stuff->parent, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return result; + + if(stuff->class == CopyFromParent) + stuff->class = parent->u.win.class; + + if((stuff->class == InputOnly) && (stuff->mask & (~INPUTONLY_LEGAL_MASK))) + return BadMatch; + + if ((Mask)stuff->mask & CWBackPixmap) { + pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1)); + tmp = *((CARD32 *) &stuff[1] + pback_offset); + if ((tmp != None) && (tmp != ParentRelative)) { + result = dixLookupResourceByType((pointer *)&backPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask)stuff->mask & CWBorderPixmap) { + pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1)); + tmp = *((CARD32 *) &stuff[1] + pbord_offset); + if (tmp != CopyFromParent) { + result = dixLookupResourceByType((pointer *)&bordPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask)stuff->mask & CWColormap) { + cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1)); + tmp = *((CARD32 *) &stuff[1] + cmap_offset); + if ((tmp != CopyFromParent) && (tmp != None)) { + result = dixLookupResourceByType((pointer *)&cmap, tmp, + XRT_COLORMAP, client, DixReadAccess); + if (result != Success) + return result; + } + } + + if(!(newWin = malloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newWin->type = XRT_WINDOW; + newWin->u.win.visibility = VisibilityNotViewable; + newWin->u.win.class = stuff->class; + newWin->u.win.root = FALSE; + panoramix_setup_ids(newWin, client, stuff->wid); + + if (stuff->class == InputOnly) + stuff->visual = CopyFromParent; + orig_visual = stuff->visual; + orig_x = stuff->x; + orig_y = stuff->y; + parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) || + (stuff->parent == screenInfo.screens[0]->screensaver.wid); + FOR_NSCREENS_BACKWARD(j) { + stuff->wid = newWin->info[j].id; + stuff->parent = parent->info[j].id; + if (parentIsRoot) { + stuff->x = orig_x - screenInfo.screens[j]->x; + stuff->y = orig_y - screenInfo.screens[j]->y; + } + if (backPix) + *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; + if (bordPix) + *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; + if (cmap) + *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; + if ( orig_visual != CopyFromParent ) + stuff->visual = PanoramiXTranslateVisualID(j, orig_visual); + result = (*SavedProcVector[X_CreateWindow])(client); + if(result != Success) break; + } + + if (result == Success) + AddResource(newWin->info[0].id, XRT_WINDOW, newWin); + else + free(newWin); + + return result; +} + + +int PanoramiXChangeWindowAttributes(ClientPtr client) +{ + PanoramiXRes *win; + PanoramiXRes *backPix = NULL; + PanoramiXRes *bordPix = NULL; + PanoramiXRes *cmap = NULL; + REQUEST(xChangeWindowAttributesReq); + int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; + int result, len, j; + XID tmp; + + REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); + + len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq)); + if (Ones(stuff->valueMask) != len) + return BadLength; + + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return result; + + if((win->u.win.class == InputOnly) && + (stuff->valueMask & (~INPUTONLY_LEGAL_MASK))) + return BadMatch; + + if ((Mask)stuff->valueMask & CWBackPixmap) { + pback_offset = Ones((Mask)stuff->valueMask & (CWBackPixmap - 1)); + tmp = *((CARD32 *) &stuff[1] + pback_offset); + if ((tmp != None) && (tmp != ParentRelative)) { + result = dixLookupResourceByType((pointer *)&backPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask)stuff->valueMask & CWBorderPixmap) { + pbord_offset = Ones((Mask)stuff->valueMask & (CWBorderPixmap - 1)); + tmp = *((CARD32 *) &stuff[1] + pbord_offset); + if (tmp != CopyFromParent) { + result = dixLookupResourceByType((pointer *)&bordPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask)stuff->valueMask & CWColormap) { + cmap_offset = Ones((Mask)stuff->valueMask & (CWColormap - 1)); + tmp = *((CARD32 *) &stuff[1] + cmap_offset); + if ((tmp != CopyFromParent) && (tmp != None)) { + result = dixLookupResourceByType((pointer *)&cmap, tmp, + XRT_COLORMAP, client, DixReadAccess); + if (result != Success) + return result; + } + } + + FOR_NSCREENS_BACKWARD(j) { + stuff->window = win->info[j].id; + if (backPix) + *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; + if (bordPix) + *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; + if (cmap) + *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; + result = (*SavedProcVector[X_ChangeWindowAttributes])(client); + } + + return result; +} + + +int PanoramiXDestroyWindow(ClientPtr client) +{ + PanoramiXRes *win; + int result, j; + REQUEST(xResourceReq); + + REQUEST_SIZE_MATCH(xResourceReq); + + result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW, + client, DixDestroyAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_DestroyWindow])(client); + if(result != Success) break; + } + + /* Since ProcDestroyWindow is using FreeResource, it will free + our resource for us on the last pass through the loop above */ + + return result; +} + + +int PanoramiXDestroySubwindows(ClientPtr client) +{ + PanoramiXRes *win; + int result, j; + REQUEST(xResourceReq); + + REQUEST_SIZE_MATCH(xResourceReq); + + result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW, + client, DixDestroyAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_DestroySubwindows])(client); + if(result != Success) break; + } + + /* DestroySubwindows is using FreeResource which will free + our resources for us on the last pass through the loop above */ + + return result; +} + + +int PanoramiXChangeSaveSet(ClientPtr client) +{ + PanoramiXRes *win; + int result, j; + REQUEST(xChangeSaveSetReq); + + REQUEST_SIZE_MATCH(xChangeSaveSetReq); + + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j) { + stuff->window = win->info[j].id; + result = (*SavedProcVector[X_ChangeSaveSet])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXReparentWindow(ClientPtr client) +{ + PanoramiXRes *win, *parent; + int result, j; + int x, y; + Bool parentIsRoot; + REQUEST(xReparentWindowReq); + + REQUEST_SIZE_MATCH(xReparentWindowReq); + + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return result; + + result = dixLookupResourceByType((pointer *)&parent, stuff->parent, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return result; + + x = stuff->x; + y = stuff->y; + parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) || + (stuff->parent == screenInfo.screens[0]->screensaver.wid); + FOR_NSCREENS_BACKWARD(j) { + stuff->window = win->info[j].id; + stuff->parent = parent->info[j].id; + if(parentIsRoot) { + stuff->x = x - screenInfo.screens[j]->x; + stuff->y = y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_ReparentWindow])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXMapWindow(ClientPtr client) +{ + PanoramiXRes *win; + int result, j; + REQUEST(xResourceReq); + + REQUEST_SIZE_MATCH(xResourceReq); + + result = dixLookupResourceByType((pointer *)&win, stuff->id, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return result; + + FOR_NSCREENS_FORWARD(j) { + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_MapWindow])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXMapSubwindows(ClientPtr client) +{ + PanoramiXRes *win; + int result, j; + REQUEST(xResourceReq); + + REQUEST_SIZE_MATCH(xResourceReq); + + result = dixLookupResourceByType((pointer *)&win, stuff->id, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return result; + + FOR_NSCREENS_FORWARD(j) { + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_MapSubwindows])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXUnmapWindow(ClientPtr client) +{ + PanoramiXRes *win; + int result, j; + REQUEST(xResourceReq); + + REQUEST_SIZE_MATCH(xResourceReq); + + result = dixLookupResourceByType((pointer *)&win, stuff->id, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return result; + + FOR_NSCREENS_FORWARD(j) { + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_UnmapWindow])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXUnmapSubwindows(ClientPtr client) +{ + PanoramiXRes *win; + int result, j; + REQUEST(xResourceReq); + + REQUEST_SIZE_MATCH(xResourceReq); + + result = dixLookupResourceByType((pointer *)&win, stuff->id, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return result; + + FOR_NSCREENS_FORWARD(j) { + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_UnmapSubwindows])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXConfigureWindow(ClientPtr client) +{ + PanoramiXRes *win; + PanoramiXRes *sib = NULL; + WindowPtr pWin; + int result, j, len, sib_offset = 0, x = 0, y = 0; + int x_offset = -1; + int y_offset = -1; + REQUEST(xConfigureWindowReq); + + REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); + + len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq)); + if (Ones(stuff->mask) != len) + return BadLength; + + /* because we need the parent */ + result = dixLookupResourceByType((pointer *)&pWin, stuff->window, + RT_WINDOW, client, DixWriteAccess); + if (result != Success) + return result; + + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return result; + + if ((Mask)stuff->mask & CWSibling) { + XID tmp; + sib_offset = Ones((Mask)stuff->mask & (CWSibling - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + sib_offset))) { + result = dixLookupResourceByType((pointer *)&sib, tmp, XRT_WINDOW, + client, DixReadAccess); + if (result != Success) + return result; + } + } + + if(pWin->parent && ((pWin->parent == screenInfo.screens[0]->root) || + (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid))) + { + if ((Mask)stuff->mask & CWX) { + x_offset = 0; + x = *((CARD32 *)&stuff[1]); + } + if ((Mask)stuff->mask & CWY) { + y_offset = (x_offset == -1) ? 0 : 1; + y = *((CARD32 *) &stuff[1] + y_offset); + } + } + + /* have to go forward or you get expose events before + ConfigureNotify events */ + FOR_NSCREENS_FORWARD(j) { + stuff->window = win->info[j].id; + if(sib) + *((CARD32 *) &stuff[1] + sib_offset) = sib->info[j].id; + if(x_offset >= 0) + *((CARD32 *) &stuff[1] + x_offset) = x - screenInfo.screens[j]->x; + if(y_offset >= 0) + *((CARD32 *) &stuff[1] + y_offset) = y - screenInfo.screens[j]->y; + result = (*SavedProcVector[X_ConfigureWindow])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXCirculateWindow(ClientPtr client) +{ + PanoramiXRes *win; + int result, j; + REQUEST(xCirculateWindowReq); + + REQUEST_SIZE_MATCH(xCirculateWindowReq); + + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return result; + + FOR_NSCREENS_FORWARD(j) { + stuff->window = win->info[j].id; + result = (*SavedProcVector[X_CirculateWindow])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXGetGeometry(ClientPtr client) +{ + xGetGeometryReply rep; + DrawablePtr pDraw; + int rc; + REQUEST(xResourceReq); + + REQUEST_SIZE_MATCH(xResourceReq); + rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixGetAttrAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.root = screenInfo.screens[0]->root->drawable.id; + rep.depth = pDraw->depth; + rep.width = pDraw->width; + rep.height = pDraw->height; + rep.x = rep.y = rep.borderWidth = 0; + + if (stuff->id == rep.root) { + xWindowRoot *root = (xWindowRoot *) + (ConnectionInfo + connBlockScreenStart); + + rep.width = root->pixWidth; + rep.height = root->pixHeight; + } else + if (WindowDrawable(pDraw->type)) + { + WindowPtr pWin = (WindowPtr)pDraw; + rep.x = pWin->origin.x - wBorderWidth (pWin); + rep.y = pWin->origin.y - wBorderWidth (pWin); + if((pWin->parent == screenInfo.screens[0]->root) || + (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid)) + { + rep.x += screenInfo.screens[0]->x; + rep.y += screenInfo.screens[0]->y; + } + rep.borderWidth = pWin->borderWidth; + } + + WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep); + return Success; +} + +int PanoramiXTranslateCoords(ClientPtr client) +{ + INT16 x, y; + REQUEST(xTranslateCoordsReq); + int rc; + WindowPtr pWin, pDst; + xTranslateCoordsReply rep; + + REQUEST_SIZE_MATCH(xTranslateCoordsReq); + rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess); + if (rc != Success) + return rc; + rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess); + if (rc != Success) + return rc; + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.sameScreen = xTrue; + rep.child = None; + + if((pWin == screenInfo.screens[0]->root) || + (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid)) + { + x = stuff->srcX - screenInfo.screens[0]->x; + y = stuff->srcY - screenInfo.screens[0]->y; + } else { + x = pWin->drawable.x + stuff->srcX; + y = pWin->drawable.y + stuff->srcY; + } + pWin = pDst->firstChild; + while (pWin) { + BoxRec box; + if ((pWin->mapped) && + (x >= pWin->drawable.x - wBorderWidth (pWin)) && + (x < pWin->drawable.x + (int)pWin->drawable.width + + wBorderWidth (pWin)) && + (y >= pWin->drawable.y - wBorderWidth (pWin)) && + (y < pWin->drawable.y + (int)pWin->drawable.height + + wBorderWidth (pWin)) + /* When a window is shaped, a further check + * is made to see if the point is inside + * borderSize + */ + && (!wBoundingShape(pWin) || + RegionContainsPoint(wBoundingShape(pWin), + x - pWin->drawable.x, + y - pWin->drawable.y, &box)) + ) + { + rep.child = pWin->drawable.id; + pWin = (WindowPtr) NULL; + } + else + pWin = pWin->nextSib; + } + rep.dstX = x - pDst->drawable.x; + rep.dstY = y - pDst->drawable.y; + if((pDst == screenInfo.screens[0]->root) || + (pDst->drawable.id == screenInfo.screens[0]->screensaver.wid)) + { + rep.dstX += screenInfo.screens[0]->x; + rep.dstY += screenInfo.screens[0]->y; + } + + WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); + return Success; +} + +int PanoramiXCreatePixmap(ClientPtr client) +{ + PanoramiXRes *refDraw, *newPix; + int result, j; + REQUEST(xCreatePixmapReq); + + REQUEST_SIZE_MATCH(xCreatePixmapReq); + client->errorValue = stuff->pid; + + result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable, + XRC_DRAWABLE, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(!(newPix = malloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newPix->type = XRT_PIXMAP; + newPix->u.pix.shared = FALSE; + panoramix_setup_ids(newPix, client, stuff->pid); + + FOR_NSCREENS_BACKWARD(j) { + stuff->pid = newPix->info[j].id; + stuff->drawable = refDraw->info[j].id; + result = (*SavedProcVector[X_CreatePixmap])(client); + if(result != Success) break; + } + + if (result == Success) + AddResource(newPix->info[0].id, XRT_PIXMAP, newPix); + else + free(newPix); + + return result; +} + + +int PanoramiXFreePixmap(ClientPtr client) +{ + PanoramiXRes *pix; + int result, j; + REQUEST(xResourceReq); + + REQUEST_SIZE_MATCH(xResourceReq); + + client->errorValue = stuff->id; + + result = dixLookupResourceByType((pointer *)&pix, stuff->id, XRT_PIXMAP, + client, DixDestroyAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = pix->info[j].id; + result = (*SavedProcVector[X_FreePixmap])(client); + if(result != Success) break; + } + + /* Since ProcFreePixmap is using FreeResource, it will free + our resource for us on the last pass through the loop above */ + + return result; +} + + +int PanoramiXCreateGC(ClientPtr client) +{ + PanoramiXRes *refDraw; + PanoramiXRes *newGC; + PanoramiXRes *stip = NULL; + PanoramiXRes *tile = NULL; + PanoramiXRes *clip = NULL; + REQUEST(xCreateGCReq); + int tile_offset = 0, stip_offset = 0, clip_offset = 0; + int result, len, j; + XID tmp; + + REQUEST_AT_LEAST_SIZE(xCreateGCReq); + + client->errorValue = stuff->gc; + len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq)); + if (Ones(stuff->mask) != len) + return BadLength; + + result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable, + XRC_DRAWABLE, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if ((Mask)stuff->mask & GCTile) { + tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { + result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask)stuff->mask & GCStipple) { + stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { + result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask)stuff->mask & GCClipMask) { + clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { + result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } + } + + if(!(newGC = malloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newGC->type = XRT_GC; + panoramix_setup_ids(newGC, client, stuff->gc); + + FOR_NSCREENS_BACKWARD(j) { + stuff->gc = newGC->info[j].id; + stuff->drawable = refDraw->info[j].id; + if (tile) + *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; + if (stip) + *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; + if (clip) + *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; + result = (*SavedProcVector[X_CreateGC])(client); + if(result != Success) break; + } + + if (result == Success) + AddResource(newGC->info[0].id, XRT_GC, newGC); + else + free(newGC); + + return result; +} + +int PanoramiXChangeGC(ClientPtr client) +{ + PanoramiXRes *gc; + PanoramiXRes *stip = NULL; + PanoramiXRes *tile = NULL; + PanoramiXRes *clip = NULL; + REQUEST(xChangeGCReq); + int tile_offset = 0, stip_offset = 0, clip_offset = 0; + int result, len, j; + XID tmp; + + REQUEST_AT_LEAST_SIZE(xChangeGCReq); + + len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq)); + if (Ones(stuff->mask) != len) + return BadLength; + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + if ((Mask)stuff->mask & GCTile) { + tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { + result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask)stuff->mask & GCStipple) { + stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { + result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask)stuff->mask & GCClipMask) { + clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { + result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } + } + + + FOR_NSCREENS_BACKWARD(j) { + stuff->gc = gc->info[j].id; + if (tile) + *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; + if (stip) + *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; + if (clip) + *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; + result = (*SavedProcVector[X_ChangeGC])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXCopyGC(ClientPtr client) +{ + PanoramiXRes *srcGC, *dstGC; + int result, j; + REQUEST(xCopyGCReq); + + REQUEST_SIZE_MATCH(xCopyGCReq); + + result = dixLookupResourceByType((pointer *)&srcGC, stuff->srcGC, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + result = dixLookupResourceByType((pointer *)&dstGC, stuff->dstGC, XRT_GC, + client, DixWriteAccess); + if (result != Success) + return result; + + FOR_NSCREENS(j) { + stuff->srcGC = srcGC->info[j].id; + stuff->dstGC = dstGC->info[j].id; + result = (*SavedProcVector[X_CopyGC])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXSetDashes(ClientPtr client) +{ + PanoramiXRes *gc; + int result, j; + REQUEST(xSetDashesReq); + + REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixWriteAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j) { + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_SetDashes])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXSetClipRectangles(ClientPtr client) +{ + PanoramiXRes *gc; + int result, j; + REQUEST(xSetClipRectanglesReq); + + REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixWriteAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j) { + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_SetClipRectangles])(client); + if(result != Success) break; + } + + return result; +} + + +int PanoramiXFreeGC(ClientPtr client) +{ + PanoramiXRes *gc; + int result, j; + REQUEST(xResourceReq); + + REQUEST_SIZE_MATCH(xResourceReq); + + result = dixLookupResourceByType((pointer *)&gc, stuff->id, XRT_GC, + client, DixDestroyAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = gc->info[j].id; + result = (*SavedProcVector[X_FreeGC])(client); + if(result != Success) break; + } + + /* Since ProcFreeGC is using FreeResource, it will free + our resource for us on the last pass through the loop above */ + + return result; +} + + +int PanoramiXClearToBackground(ClientPtr client) +{ + PanoramiXRes *win; + int result, j, x, y; + Bool isRoot; + REQUEST(xClearAreaReq); + + REQUEST_SIZE_MATCH(xClearAreaReq); + + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return result; + + x = stuff->x; + y = stuff->y; + isRoot = win->u.win.root; + FOR_NSCREENS_BACKWARD(j) { + stuff->window = win->info[j].id; + if(isRoot) { + stuff->x = x - screenInfo.screens[j]->x; + stuff->y = y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_ClearArea])(client); + if(result != Success) break; + } + + return result; +} + + +/* + For Window to Pixmap copies you're screwed since each screen's + pixmap will look like what it sees on its screen. Unless the + screens overlap and the window lies on each, the two copies + will be out of sync. To remedy this we do a GetImage and PutImage + in place of the copy. Doing this as a single Image isn't quite + correct since it will include the obscured areas but we will + have to fix this later. (MArk). +*/ + +int PanoramiXCopyArea(ClientPtr client) +{ + int j, result, srcx, srcy, dstx, dsty; + PanoramiXRes *gc, *src, *dst; + Bool srcIsRoot = FALSE; + Bool dstIsRoot = FALSE; + Bool srcShared, dstShared; + REQUEST(xCopyAreaReq); + + REQUEST_SIZE_MATCH(xCopyAreaReq); + + result = dixLookupResourceByClass((pointer *)&src, stuff->srcDrawable, + XRC_DRAWABLE, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + srcShared = IS_SHARED_PIXMAP(src); + + result = dixLookupResourceByClass((pointer *)&dst, stuff->dstDrawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + dstShared = IS_SHARED_PIXMAP(dst); + + if(dstShared && srcShared) + return (* SavedProcVector[X_CopyArea])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + if((dst->type == XRT_WINDOW) && dst->u.win.root) + dstIsRoot = TRUE; + if((src->type == XRT_WINDOW) && src->u.win.root) + srcIsRoot = TRUE; + + srcx = stuff->srcX; srcy = stuff->srcY; + dstx = stuff->dstX; dsty = stuff->dstY; + if((dst->type == XRT_PIXMAP) && (src->type == XRT_WINDOW)) { + DrawablePtr drawables[MAXSCREENS]; + DrawablePtr pDst; + GCPtr pGC; + char *data; + int pitch, rc; + + FOR_NSCREENS(j) { + rc = dixLookupDrawable(drawables+j, src->info[j].id, client, 0, + DixGetAttrAccess); + if (rc != Success) + return rc; + } + + pitch = PixmapBytePad(stuff->width, drawables[0]->depth); + if(!(data = calloc(1, stuff->height * pitch))) + return BadAlloc; + + XineramaGetImageData(drawables, srcx, srcy, + stuff->width, stuff->height, ZPixmap, ~0, data, pitch, + srcIsRoot); + + FOR_NSCREENS_BACKWARD(j) { + stuff->gc = gc->info[j].id; + VALIDATE_DRAWABLE_AND_GC(dst->info[j].id, pDst, DixWriteAccess); + if(drawables[0]->depth != pDst->depth) { + client->errorValue = stuff->dstDrawable; + free(data); + return BadMatch; + } + + (*pGC->ops->PutImage) (pDst, pGC, pDst->depth, dstx, dsty, + stuff->width, stuff->height, + 0, ZPixmap, data); + + if(dstShared) break; + } + + free(data); + } else { + DrawablePtr pDst = NULL, pSrc = NULL; + GCPtr pGC = NULL; + RegionRec totalReg; + int rc; + + RegionNull(&totalReg); + FOR_NSCREENS_BACKWARD(j) { + RegionPtr pRgn; + stuff->dstDrawable = dst->info[j].id; + stuff->srcDrawable = src->info[j].id; + stuff->gc = gc->info[j].id; + if (srcIsRoot) { + stuff->srcX = srcx - screenInfo.screens[j]->x; + stuff->srcY = srcy - screenInfo.screens[j]->y; + } + if (dstIsRoot) { + stuff->dstX = dstx - screenInfo.screens[j]->x; + stuff->dstY = dsty - screenInfo.screens[j]->y; + } + + VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess); + + if (stuff->dstDrawable != stuff->srcDrawable) { + rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + + if ((pDst->pScreen != pSrc->pScreen) || + (pDst->depth != pSrc->depth)) { + client->errorValue = stuff->dstDrawable; + return BadMatch; + } + } else + pSrc = pDst; + + pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, + stuff->srcX, stuff->srcY, + stuff->width, stuff->height, + stuff->dstX, stuff->dstY); + if(pGC->graphicsExposures && pRgn) { + if(srcIsRoot) { + RegionTranslate(pRgn, + screenInfo.screens[j]->x, screenInfo.screens[j]->y); + } + RegionAppend(&totalReg, pRgn); + RegionDestroy(pRgn); + } + + if(dstShared) + break; + } + + if(pGC->graphicsExposures) { + Bool overlap; + RegionValidate(&totalReg, &overlap); + (*pDst->pScreen->SendGraphicsExpose)( + client, &totalReg, stuff->dstDrawable, X_CopyArea, 0); + RegionUninit(&totalReg); + } + } + + return Success; +} + + +int PanoramiXCopyPlane(ClientPtr client) +{ + int j, srcx, srcy, dstx, dsty, rc; + PanoramiXRes *gc, *src, *dst; + Bool srcIsRoot = FALSE; + Bool dstIsRoot = FALSE; + Bool srcShared, dstShared; + DrawablePtr psrcDraw, pdstDraw = NULL; + GCPtr pGC = NULL; + RegionRec totalReg; + REQUEST(xCopyPlaneReq); + + REQUEST_SIZE_MATCH(xCopyPlaneReq); + + rc = dixLookupResourceByClass((pointer *)&src, stuff->srcDrawable, + XRC_DRAWABLE, client, DixReadAccess); + if (rc != Success) + return (rc == BadValue) ? BadDrawable : rc; + + srcShared = IS_SHARED_PIXMAP(src); + + rc = dixLookupResourceByClass((pointer *)&dst, stuff->dstDrawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (rc != Success) + return (rc == BadValue) ? BadDrawable : rc; + + dstShared = IS_SHARED_PIXMAP(dst); + + if(dstShared && srcShared) + return (* SavedProcVector[X_CopyPlane])(client); + + rc = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (rc != Success) + return rc; + + if((dst->type == XRT_WINDOW) && dst->u.win.root) + dstIsRoot = TRUE; + if((src->type == XRT_WINDOW) && src->u.win.root) + srcIsRoot = TRUE; + + srcx = stuff->srcX; srcy = stuff->srcY; + dstx = stuff->dstX; dsty = stuff->dstY; + + RegionNull(&totalReg); + FOR_NSCREENS_BACKWARD(j) { + RegionPtr pRgn; + stuff->dstDrawable = dst->info[j].id; + stuff->srcDrawable = src->info[j].id; + stuff->gc = gc->info[j].id; + if (srcIsRoot) { + stuff->srcX = srcx - screenInfo.screens[j]->x; + stuff->srcY = srcy - screenInfo.screens[j]->y; + } + if (dstIsRoot) { + stuff->dstX = dstx - screenInfo.screens[j]->x; + stuff->dstY = dsty - screenInfo.screens[j]->y; + } + + VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess); + if (stuff->dstDrawable != stuff->srcDrawable) { + rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + + if (pdstDraw->pScreen != psrcDraw->pScreen) { + client->errorValue = stuff->dstDrawable; + return BadMatch; + } + } else + psrcDraw = pdstDraw; + + if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) || + (stuff->bitPlane > (1L << (psrcDraw->depth - 1)))) { + client->errorValue = stuff->bitPlane; + return BadValue; + } + + pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, + stuff->srcX, stuff->srcY, + stuff->width, stuff->height, + stuff->dstX, stuff->dstY, stuff->bitPlane); + if(pGC->graphicsExposures && pRgn) { + RegionAppend(&totalReg, pRgn); + RegionDestroy(pRgn); + } + + if(dstShared) + break; + } + + if(pGC->graphicsExposures) { + Bool overlap; + RegionValidate(&totalReg, &overlap); + (*pdstDraw->pScreen->SendGraphicsExpose)( + client, &totalReg, stuff->dstDrawable, X_CopyPlane, 0); + RegionUninit(&totalReg); + } + + return Success; +} + + +int PanoramiXPolyPoint(ClientPtr client) +{ + PanoramiXRes *gc, *draw; + int result, npoint, j; + xPoint *origPts; + Bool isRoot; + REQUEST(xPolyPointReq); + + REQUEST_AT_LEAST_SIZE(xPolyPointReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyPoint])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; + npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq)); + if (npoint > 0) { + origPts = malloc(npoint * sizeof(xPoint)); + memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + + if(x_off || y_off) { + xPoint *pnts = (xPoint*)&stuff[1]; + int i = (stuff->coordMode==CoordModePrevious) ? 1 : npoint; + + while(i--) { + pnts->x -= x_off; + pnts->y -= y_off; + pnts++; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyPoint])(client); + if(result != Success) break; + } + free(origPts); + return result; + } else + return Success; +} + + +int PanoramiXPolyLine(ClientPtr client) +{ + PanoramiXRes *gc, *draw; + int result, npoint, j; + xPoint *origPts; + Bool isRoot; + REQUEST(xPolyLineReq); + + REQUEST_AT_LEAST_SIZE(xPolyLineReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyLine])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq)); + if (npoint > 0){ + origPts = malloc(npoint * sizeof(xPoint)); + memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + + if(x_off || y_off) { + xPoint *pnts = (xPoint*)&stuff[1]; + int i = (stuff->coordMode==CoordModePrevious) ? 1 : npoint; + + while(i--) { + pnts->x -= x_off; + pnts->y -= y_off; + pnts++; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyLine])(client); + if(result != Success) break; + } + free(origPts); + return result; + } else + return Success; +} + + +int PanoramiXPolySegment(ClientPtr client) +{ + int result, nsegs, i, j; + PanoramiXRes *gc, *draw; + xSegment *origSegs; + Bool isRoot; + REQUEST(xPolySegmentReq); + + REQUEST_AT_LEAST_SIZE(xPolySegmentReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolySegment])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + + nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq); + if(nsegs & 4) return BadLength; + nsegs >>= 3; + if (nsegs > 0) { + origSegs = malloc(nsegs * sizeof(xSegment)); + memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origSegs, nsegs * sizeof(xSegment)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + + if(x_off || y_off) { + xSegment *segs = (xSegment*)&stuff[1]; + + for (i = nsegs; i--; segs++) { + segs->x1 -= x_off; + segs->x2 -= x_off; + segs->y1 -= y_off; + segs->y2 -= y_off; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolySegment])(client); + if(result != Success) break; + } + free(origSegs); + return result; + } else + return Success; +} + + +int PanoramiXPolyRectangle(ClientPtr client) +{ + int result, nrects, i, j; + PanoramiXRes *gc, *draw; + Bool isRoot; + xRectangle *origRecs; + REQUEST(xPolyRectangleReq); + + REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyRectangle])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + + nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq); + if(nrects & 4) return BadLength; + nrects >>= 3; + if (nrects > 0){ + origRecs = malloc(nrects * sizeof(xRectangle)); + memcpy((char *)origRecs,(char *)&stuff[1],nrects * sizeof(xRectangle)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origRecs, nrects * sizeof(xRectangle)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + + + if(x_off || y_off) { + xRectangle *rects = (xRectangle *) &stuff[1]; + + for (i = nrects; i--; rects++) { + rects->x -= x_off; + rects->y -= y_off; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyRectangle])(client); + if(result != Success) break; + } + free(origRecs); + return result; + } else + return Success; +} + + +int PanoramiXPolyArc(ClientPtr client) +{ + int result, narcs, i, j; + PanoramiXRes *gc, *draw; + Bool isRoot; + xArc *origArcs; + REQUEST(xPolyArcReq); + + REQUEST_AT_LEAST_SIZE(xPolyArcReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyArc])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + + narcs = (client->req_len << 2) - sizeof(xPolyArcReq); + if(narcs % sizeof(xArc)) return BadLength; + narcs /= sizeof(xArc); + if (narcs > 0){ + origArcs = malloc(narcs * sizeof(xArc)); + memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + + if(x_off || y_off) { + xArc *arcs = (xArc *) &stuff[1]; + + for (i = narcs; i--; arcs++) { + arcs->x -= x_off; + arcs->y -= y_off; + } + } + } + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyArc])(client); + if(result != Success) break; + } + free(origArcs); + return result; + } else + return Success; +} + + +int PanoramiXFillPoly(ClientPtr client) +{ + int result, count, j; + PanoramiXRes *gc, *draw; + Bool isRoot; + DDXPointPtr locPts; + REQUEST(xFillPolyReq); + + REQUEST_AT_LEAST_SIZE(xFillPolyReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_FillPoly])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + + count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq)); + if (count > 0){ + locPts = malloc(count * sizeof(DDXPointRec)); + memcpy((char *)locPts, (char *)&stuff[1], count * sizeof(DDXPointRec)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], locPts, count * sizeof(DDXPointRec)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + + if(x_off || y_off) { + DDXPointPtr pnts = (DDXPointPtr)&stuff[1]; + int i = (stuff->coordMode==CoordModePrevious) ? 1 : count; + + while(i--) { + pnts->x -= x_off; + pnts->y -= y_off; + pnts++; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_FillPoly])(client); + if(result != Success) break; + } + free(locPts); + return result; + } else + return Success; +} + + +int PanoramiXPolyFillRectangle(ClientPtr client) +{ + int result, things, i, j; + PanoramiXRes *gc, *draw; + Bool isRoot; + xRectangle *origRects; + REQUEST(xPolyFillRectangleReq); + + REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyFillRectangle])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + + things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq); + if(things & 4) return BadLength; + things >>= 3; + if (things > 0){ + origRects = malloc(things * sizeof(xRectangle)); + memcpy((char*)origRects,(char*)&stuff[1], things * sizeof(xRectangle)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origRects, things * sizeof(xRectangle)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + + if(x_off || y_off) { + xRectangle *rects = (xRectangle *) &stuff[1]; + + for (i = things; i--; rects++) { + rects->x -= x_off; + rects->y -= y_off; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyFillRectangle])(client); + if(result != Success) break; + } + free(origRects); + return result; + } else + return Success; +} + + +int PanoramiXPolyFillArc(ClientPtr client) +{ + PanoramiXRes *gc, *draw; + Bool isRoot; + int result, narcs, i, j; + xArc *origArcs; + REQUEST(xPolyFillArcReq); + + REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyFillArc])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + + narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq); + if (narcs % sizeof(xArc)) return BadLength; + narcs /= sizeof(xArc); + if (narcs > 0) { + origArcs = malloc(narcs * sizeof(xArc)); + memcpy((char *) origArcs, (char *)&stuff[1], narcs * sizeof(xArc)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + + if(x_off || y_off) { + xArc *arcs = (xArc *) &stuff[1]; + + for (i = narcs; i--; arcs++) { + arcs->x -= x_off; + arcs->y -= y_off; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyFillArc])(client); + if(result != Success) break; + } + free(origArcs); + return result; + } else + return Success; +} + + +int PanoramiXPutImage(ClientPtr client) +{ + PanoramiXRes *gc, *draw; + Bool isRoot; + int j, result, orig_x, orig_y; + REQUEST(xPutImageReq); + + REQUEST_AT_LEAST_SIZE(xPutImageReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PutImage])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + + orig_x = stuff->dstX; + orig_y = stuff->dstY; + FOR_NSCREENS_BACKWARD(j){ + if (isRoot) { + stuff->dstX = orig_x - screenInfo.screens[j]->x; + stuff->dstY = orig_y - screenInfo.screens[j]->y; + } + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PutImage])(client); + if(result != Success) break; + } + return result; +} + + +int PanoramiXGetImage(ClientPtr client) +{ + DrawablePtr drawables[MAXSCREENS]; + DrawablePtr pDraw; + PanoramiXRes *draw; + xGetImageReply xgi; + Bool isRoot; + char *pBuf; + int i, x, y, w, h, format, rc; + Mask plane = 0, planemask; + int linesDone, nlines, linesPerBuf; + long widthBytesLine, length; + + REQUEST(xGetImageReq); + + REQUEST_SIZE_MATCH(xGetImageReq); + + if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) { + client->errorValue = stuff->format; + return BadValue; + } + + rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (rc != Success) + return (rc == BadValue) ? BadDrawable : rc; + + if(draw->type == XRT_PIXMAP) + return (*SavedProcVector[X_GetImage])(client); + + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + + if(!((WindowPtr)pDraw)->realized) + return BadMatch; + + x = stuff->x; + y = stuff->y; + w = stuff->width; + h = stuff->height; + format = stuff->format; + planemask = stuff->planeMask; + + isRoot = IS_ROOT_DRAWABLE(draw); + + if(isRoot) { + if( /* check for being onscreen */ + x < 0 || x + w > PanoramiXPixWidth || + y < 0 || y + h > PanoramiXPixHeight ) + return BadMatch; + } else { + if( /* check for being onscreen */ + screenInfo.screens[0]->x + pDraw->x + x < 0 || + screenInfo.screens[0]->x + pDraw->x + x + w > PanoramiXPixWidth || + screenInfo.screens[0]->y + pDraw->y + y < 0 || + screenInfo.screens[0]->y + pDraw->y + y + h > PanoramiXPixHeight || + /* check for being inside of border */ + x < - wBorderWidth((WindowPtr)pDraw) || + x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width || + y < -wBorderWidth((WindowPtr)pDraw) || + y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height) + return BadMatch; + } + + drawables[0] = pDraw; + FOR_NSCREENS_FORWARD_SKIP(i) { + rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0, + DixGetAttrAccess); + if (rc != Success) + return rc; + } + + xgi.visual = wVisual (((WindowPtr) pDraw)); + xgi.type = X_Reply; + xgi.sequenceNumber = client->sequence; + xgi.depth = pDraw->depth; + if(format == ZPixmap) { + widthBytesLine = PixmapBytePad(w, pDraw->depth); + length = widthBytesLine * h; + + + } else { + widthBytesLine = BitmapBytePad(w); + plane = ((Mask)1) << (pDraw->depth - 1); + /* only planes asked for */ + length = widthBytesLine * h * + Ones(planemask & (plane | (plane - 1))); + + } + + xgi.length = bytes_to_int32(length); + + if (widthBytesLine == 0 || h == 0) + linesPerBuf = 0; + else if (widthBytesLine >= XINERAMA_IMAGE_BUFSIZE) + linesPerBuf = 1; + else { + linesPerBuf = XINERAMA_IMAGE_BUFSIZE / widthBytesLine; + if (linesPerBuf > h) + linesPerBuf = h; + } + length = linesPerBuf * widthBytesLine; + if(!(pBuf = malloc(length))) + return BadAlloc; + + WriteReplyToClient(client, sizeof (xGetImageReply), &xgi); + + if (linesPerBuf == 0) { + /* nothing to do */ + } + else if (format == ZPixmap) { + linesDone = 0; + while (h - linesDone > 0) { + nlines = min(linesPerBuf, h - linesDone); + + if(pDraw->depth == 1) + memset(pBuf, 0, nlines * widthBytesLine); + + XineramaGetImageData(drawables, x, y + linesDone, w, nlines, + format, planemask, pBuf, widthBytesLine, isRoot); + + (void)WriteToClient(client, + (int)(nlines * widthBytesLine), + pBuf); + linesDone += nlines; + } + } else { /* XYPixmap */ + for (; plane; plane >>= 1) { + if (planemask & plane) { + linesDone = 0; + while (h - linesDone > 0) { + nlines = min(linesPerBuf, h - linesDone); + + memset(pBuf, 0, nlines * widthBytesLine); + + XineramaGetImageData(drawables, x, y + linesDone, w, + nlines, format, plane, pBuf, + widthBytesLine, isRoot); + + (void)WriteToClient(client, + (int)(nlines * widthBytesLine), + pBuf); + + linesDone += nlines; + } + } + } + } + free(pBuf); + return Success; +} + + +/* The text stuff should be rewritten so that duplication happens + at the GlyphBlt level. That is, loading the font and getting + the glyphs should only happen once */ + +int +PanoramiXPolyText8(ClientPtr client) +{ + PanoramiXRes *gc, *draw; + Bool isRoot; + int result, j; + int orig_x, orig_y; + REQUEST(xPolyTextReq); + + REQUEST_AT_LEAST_SIZE(xPolyTextReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyText8])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + + orig_x = stuff->x; + orig_y = stuff->y; + FOR_NSCREENS_BACKWARD(j){ + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { + stuff->x = orig_x - screenInfo.screens[j]->x; + stuff->y = orig_y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_PolyText8])(client); + if(result != Success) break; + } + return result; +} + +int +PanoramiXPolyText16(ClientPtr client) +{ + PanoramiXRes *gc, *draw; + Bool isRoot; + int result, j; + int orig_x, orig_y; + REQUEST(xPolyTextReq); + + REQUEST_AT_LEAST_SIZE(xPolyTextReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyText16])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + + orig_x = stuff->x; + orig_y = stuff->y; + FOR_NSCREENS_BACKWARD(j){ + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { + stuff->x = orig_x - screenInfo.screens[j]->x; + stuff->y = orig_y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_PolyText16])(client); + if(result != Success) break; + } + return result; +} + + +int PanoramiXImageText8(ClientPtr client) +{ + int result, j; + PanoramiXRes *gc, *draw; + Bool isRoot; + int orig_x, orig_y; + REQUEST(xImageTextReq); + + REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_ImageText8])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + + orig_x = stuff->x; + orig_y = stuff->y; + FOR_NSCREENS_BACKWARD(j){ + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { + stuff->x = orig_x - screenInfo.screens[j]->x; + stuff->y = orig_y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_ImageText8])(client); + if(result != Success) break; + } + return result; +} + + +int PanoramiXImageText16(ClientPtr client) +{ + int result, j; + PanoramiXRes *gc, *draw; + Bool isRoot; + int orig_x, orig_y; + REQUEST(xImageTextReq); + + REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_ImageText16])(client); + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return result; + + isRoot = IS_ROOT_DRAWABLE(draw); + + orig_x = stuff->x; + orig_y = stuff->y; + FOR_NSCREENS_BACKWARD(j){ + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { + stuff->x = orig_x - screenInfo.screens[j]->x; + stuff->y = orig_y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_ImageText16])(client); + if(result != Success) break; + } + return result; +} + + + +int PanoramiXCreateColormap(ClientPtr client) +{ + PanoramiXRes *win, *newCmap; + int result, j, orig_visual; + REQUEST(xCreateColormapReq); + + REQUEST_SIZE_MATCH(xCreateColormapReq); + + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return result; + + if(!(newCmap = malloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newCmap->type = XRT_COLORMAP; + panoramix_setup_ids(newCmap, client, stuff->mid); + + orig_visual = stuff->visual; + FOR_NSCREENS_BACKWARD(j){ + stuff->mid = newCmap->info[j].id; + stuff->window = win->info[j].id; + stuff->visual = PanoramiXTranslateVisualID(j, orig_visual); + result = (* SavedProcVector[X_CreateColormap])(client); + if(result != Success) break; + } + + if (result == Success) + AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap); + else + free(newCmap); + + return result; +} + + +int PanoramiXFreeColormap(ClientPtr client) +{ + PanoramiXRes *cmap; + int result, j; + REQUEST(xResourceReq); + + REQUEST_SIZE_MATCH(xResourceReq); + + client->errorValue = stuff->id; + + result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, + client, DixDestroyAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = cmap->info[j].id; + result = (* SavedProcVector[X_FreeColormap])(client); + if(result != Success) break; + } + + /* Since ProcFreeColormap is using FreeResource, it will free + our resource for us on the last pass through the loop above */ + + return result; +} + + +int +PanoramiXCopyColormapAndFree(ClientPtr client) +{ + PanoramiXRes *cmap, *newCmap; + int result, j; + REQUEST(xCopyColormapAndFreeReq); + + REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); + + client->errorValue = stuff->srcCmap; + + result = dixLookupResourceByType((pointer *)&cmap, stuff->srcCmap, + XRT_COLORMAP, client, + DixReadAccess | DixWriteAccess); + if (result != Success) + return result; + + if(!(newCmap = malloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newCmap->type = XRT_COLORMAP; + panoramix_setup_ids(newCmap, client, stuff->mid); + + FOR_NSCREENS_BACKWARD(j) { + stuff->srcCmap = cmap->info[j].id; + stuff->mid = newCmap->info[j].id; + result = (* SavedProcVector[X_CopyColormapAndFree])(client); + if(result != Success) break; + } + + if (result == Success) + AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap); + else + free(newCmap); + + return result; +} + + +int PanoramiXInstallColormap(ClientPtr client) +{ + REQUEST(xResourceReq); + int result, j; + PanoramiXRes *cmap; + + REQUEST_SIZE_MATCH(xResourceReq); + + client->errorValue = stuff->id; + + result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, + client, DixReadAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j){ + stuff->id = cmap->info[j].id; + result = (* SavedProcVector[X_InstallColormap])(client); + if(result != Success) break; + } + return result; +} + + +int PanoramiXUninstallColormap(ClientPtr client) +{ + REQUEST(xResourceReq); + int result, j; + PanoramiXRes *cmap; + + REQUEST_SIZE_MATCH(xResourceReq); + + client->errorValue = stuff->id; + + result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, + client, DixReadAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = cmap->info[j].id; + result = (* SavedProcVector[X_UninstallColormap])(client); + if(result != Success) break; + } + return result; +} + + +int PanoramiXAllocColor(ClientPtr client) +{ + int result, j; + PanoramiXRes *cmap; + REQUEST(xAllocColorReq); + + REQUEST_SIZE_MATCH(xAllocColorReq); + + client->errorValue = stuff->cmap; + + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; + result = (* SavedProcVector[X_AllocColor])(client); + if(result != Success) break; + } + return result; +} + + +int PanoramiXAllocNamedColor(ClientPtr client) +{ + int result, j; + PanoramiXRes *cmap; + REQUEST(xAllocNamedColorReq); + + REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes); + + client->errorValue = stuff->cmap; + + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; + result = (* SavedProcVector[X_AllocNamedColor])(client); + if(result != Success) break; + } + return result; +} + + +int PanoramiXAllocColorCells(ClientPtr client) +{ + int result, j; + PanoramiXRes *cmap; + REQUEST(xAllocColorCellsReq); + + REQUEST_SIZE_MATCH(xAllocColorCellsReq); + + client->errorValue = stuff->cmap; + + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; + result = (* SavedProcVector[X_AllocColorCells])(client); + if(result != Success) break; + } + return result; +} + + +int PanoramiXAllocColorPlanes(ClientPtr client) +{ + int result, j; + PanoramiXRes *cmap; + REQUEST(xAllocColorPlanesReq); + + REQUEST_SIZE_MATCH(xAllocColorPlanesReq); + + client->errorValue = stuff->cmap; + + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; + result = (* SavedProcVector[X_AllocColorPlanes])(client); + if(result != Success) break; + } + return result; +} + + + +int PanoramiXFreeColors(ClientPtr client) +{ + int result, j; + PanoramiXRes *cmap; + REQUEST(xFreeColorsReq); + + REQUEST_AT_LEAST_SIZE(xFreeColorsReq); + + client->errorValue = stuff->cmap; + + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j) { + stuff->cmap = cmap->info[j].id; + result = (* SavedProcVector[X_FreeColors])(client); + } + return result; +} + + +int PanoramiXStoreColors(ClientPtr client) +{ + int result, j; + PanoramiXRes *cmap; + REQUEST(xStoreColorsReq); + + REQUEST_AT_LEAST_SIZE(xStoreColorsReq); + + client->errorValue = stuff->cmap; + + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; + result = (* SavedProcVector[X_StoreColors])(client); + if(result != Success) break; + } + return result; +} + + +int PanoramiXStoreNamedColor(ClientPtr client) +{ + int result, j; + PanoramiXRes *cmap; + REQUEST(xStoreNamedColorReq); + + REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes); + + client->errorValue = stuff->cmap; + + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; + result = (* SavedProcVector[X_StoreNamedColor])(client); + if(result != Success) break; + } + return result; +} diff --git a/xorg-server/Xext/panoramiXsrv.h b/xorg-server/Xext/panoramiXsrv.h index 9751feb54..6fc903b88 100644 --- a/xorg-server/Xext/panoramiXsrv.h +++ b/xorg-server/Xext/panoramiXsrv.h @@ -51,4 +51,15 @@ extern _X_EXPORT void XineramaGetImageData( Bool isRoot ); +static inline void panoramix_setup_ids(PanoramiXRes *resource, + ClientPtr client, XID base_id) +{ + int j; + + resource->info[0].id = base_id; + FOR_NSCREENS_FORWARD_SKIP(j) { + resource->info[j].id = FakeClientID(client->index); + } +} + #endif /* _PANORAMIXSRV_H_ */ diff --git a/xorg-server/Xext/shm.c b/xorg-server/Xext/shm.c index 8a048deb0..b08af821b 100644 --- a/xorg-server/Xext/shm.c +++ b/xorg-server/Xext/shm.c @@ -1,1327 +1,1325 @@ -/************************************************************ - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -********************************************************/ - -/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */ - - -#define SHM - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include "misc.h" -#include "os.h" -#include "dixstruct.h" -#include "resource.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "gcstruct.h" -#include "extnsionst.h" -#include "servermd.h" -#include "shmint.h" -#include "xace.h" -#include -#include -#include "protocol-versions.h" - -/* Needed for Solaris cross-zone shared memory extension */ -#ifdef HAVE_SHMCTL64 -#include -#define SHMSTAT(id, buf) shmctl64(id, IPC_STAT64, buf) -#define SHMSTAT_TYPE struct shmid_ds64 -#define SHMPERM_TYPE struct ipc_perm64 -#define SHM_PERM(buf) buf.shmx_perm -#define SHM_SEGSZ(buf) buf.shmx_segsz -#define SHMPERM_UID(p) p->ipcx_uid -#define SHMPERM_CUID(p) p->ipcx_cuid -#define SHMPERM_GID(p) p->ipcx_gid -#define SHMPERM_CGID(p) p->ipcx_cgid -#define SHMPERM_MODE(p) p->ipcx_mode -#define SHMPERM_ZONEID(p) p->ipcx_zoneid -#else -#define SHMSTAT(id, buf) shmctl(id, IPC_STAT, buf) -#define SHMSTAT_TYPE struct shmid_ds -#define SHMPERM_TYPE struct ipc_perm -#define SHM_PERM(buf) buf.shm_perm -#define SHM_SEGSZ(buf) buf.shm_segsz -#define SHMPERM_UID(p) p->uid -#define SHMPERM_CUID(p) p->cuid -#define SHMPERM_GID(p) p->gid -#define SHMPERM_CGID(p) p->cgid -#define SHMPERM_MODE(p) p->mode -#endif - -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" -#endif - -#include "modinit.h" - -typedef struct _ShmDesc { - struct _ShmDesc *next; - int shmid; - int refcnt; - char *addr; - Bool writable; - unsigned long size; -} ShmDescRec, *ShmDescPtr; - -typedef struct _ShmScrPrivateRec { - CloseScreenProcPtr CloseScreen; - ShmFuncsPtr shmFuncs; - DestroyPixmapProcPtr destroyPixmap; -} ShmScrPrivateRec; - -static PixmapPtr fbShmCreatePixmap(XSHM_CREATE_PIXMAP_ARGS); -static int ShmDetachSegment( - pointer /* value */, - XID /* shmseg */ - ); -static void ShmResetProc( - ExtensionEntry * /* extEntry */ - ); -static void SShmCompletionEvent( - xShmCompletionEvent * /* from */, - xShmCompletionEvent * /* to */ - ); - -static Bool ShmDestroyPixmap (PixmapPtr pPixmap); - - -static unsigned char ShmReqCode; -int ShmCompletionCode; -int BadShmSegCode; -RESTYPE ShmSegType; -static ShmDescPtr Shmsegs; -static Bool sharedPixmaps; -static DevPrivateKeyRec shmScrPrivateKeyRec; -#define shmScrPrivateKey (&shmScrPrivateKeyRec) -static DevPrivateKeyRec shmPixmapPrivateKeyRec; -#define shmPixmapPrivateKey (&shmPixmapPrivateKeyRec) -static ShmFuncs miFuncs = {NULL, NULL}; -static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL}; - -#define ShmGetScreenPriv(s) ((ShmScrPrivateRec *)dixLookupPrivate(&(s)->devPrivates, shmScrPrivateKey)) - -#define VERIFY_SHMSEG(shmseg,shmdesc,client) \ -{ \ - int rc; \ - rc = dixLookupResourceByType((pointer *)&(shmdesc), shmseg, ShmSegType, \ - client, DixReadAccess); \ - if (rc != Success) \ - return rc; \ -} - -#define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \ -{ \ - VERIFY_SHMSEG(shmseg, shmdesc, client); \ - if ((offset & 3) || (offset > shmdesc->size)) \ - { \ - client->errorValue = offset; \ - return BadValue; \ - } \ - if (needwrite && !shmdesc->writable) \ - return BadAccess; \ -} - -#define VERIFY_SHMSIZE(shmdesc,offset,len,client) \ -{ \ - if ((offset + len) > shmdesc->size) \ - { \ - return BadAccess; \ - } \ -} - - -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__) -#include - -static Bool badSysCall = FALSE; - -static void -SigSysHandler(int signo) -{ - badSysCall = TRUE; -} - -static Bool CheckForShmSyscall(void) -{ - void (*oldHandler)(); - int shmid = -1; - - /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */ - oldHandler = signal(SIGSYS, SigSysHandler); - - badSysCall = FALSE; - shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT); - - if (shmid != -1) - { - /* Successful allocation - clean up */ - shmctl(shmid, IPC_RMID, NULL); - } - else - { - /* Allocation failed */ - badSysCall = TRUE; - } - signal(SIGSYS, oldHandler); - return !badSysCall; -} - -#define MUST_CHECK_FOR_SHM_SYSCALL - -#endif - -static Bool -ShmCloseScreen(int i, ScreenPtr pScreen) -{ - ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen); - pScreen->CloseScreen = screen_priv->CloseScreen; - dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, NULL); - free(screen_priv); - return (*pScreen->CloseScreen) (i, pScreen); -} - -static ShmScrPrivateRec * -ShmInitScreenPriv(ScreenPtr pScreen) -{ - ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen); - if (!screen_priv) - { - screen_priv = calloc(1, sizeof (ShmScrPrivateRec)); - screen_priv->CloseScreen = pScreen->CloseScreen; - dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, screen_priv); - pScreen->CloseScreen = ShmCloseScreen; - } - return screen_priv; -} - -static Bool -ShmRegisterPrivates(void) -{ - if (!dixRegisterPrivateKey(&shmScrPrivateKeyRec, PRIVATE_SCREEN, 0)) - return FALSE; - if (!dixRegisterPrivateKey(&shmPixmapPrivateKeyRec, PRIVATE_PIXMAP, 0)) - return FALSE; - return TRUE; -} - -/*ARGSUSED*/ -static void -ShmResetProc(ExtensionEntry *extEntry) -{ - int i; - for (i = 0; i < screenInfo.numScreens; i++) - ShmRegisterFuncs(screenInfo.screens[i], NULL); -} - -void -ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs) -{ - if (!ShmRegisterPrivates()) - return; - ShmInitScreenPriv(pScreen)->shmFuncs = funcs; -} - -static Bool -ShmDestroyPixmap (PixmapPtr pPixmap) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen); - Bool ret; - if (pPixmap->refcnt == 1) - { - ShmDescPtr shmdesc; - shmdesc = (ShmDescPtr)dixLookupPrivate(&pPixmap->devPrivates, - shmPixmapPrivateKey); - if (shmdesc) - ShmDetachSegment ((pointer) shmdesc, pPixmap->drawable.id); - } - - pScreen->DestroyPixmap = screen_priv->destroyPixmap; - ret = (*pScreen->DestroyPixmap) (pPixmap); - screen_priv->destroyPixmap = pScreen->DestroyPixmap; - pScreen->DestroyPixmap = ShmDestroyPixmap; - return ret; -} - -void -ShmRegisterFbFuncs(ScreenPtr pScreen) -{ - ShmRegisterFuncs(pScreen, &fbFuncs); -} - -static int -ProcShmQueryVersion(ClientPtr client) -{ - xShmQueryVersionReply rep; - int n; - - REQUEST_SIZE_MATCH(xShmQueryVersionReq); - memset(&rep, 0, sizeof(xShmQueryVersionReply)); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.sharedPixmaps = sharedPixmaps; - rep.pixmapFormat = sharedPixmaps ? ZPixmap : 0; - rep.majorVersion = SERVER_SHM_MAJOR_VERSION; - rep.minorVersion = SERVER_SHM_MINOR_VERSION; - rep.uid = geteuid(); - rep.gid = getegid(); - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.majorVersion, n); - swaps(&rep.minorVersion, n); - swaps(&rep.uid, n); - swaps(&rep.gid, n); - } - WriteToClient(client, sizeof(xShmQueryVersionReply), (char *)&rep); - return Success; -} - -/* - * Simulate the access() system call for a shared memory segement, - * using the credentials from the client if available - */ -static int -shm_access(ClientPtr client, SHMPERM_TYPE *perm, int readonly) -{ - int uid, gid; - mode_t mask; - int uidset = 0, gidset = 0; - LocalClientCredRec *lcc; - - if (GetLocalClientCreds(client, &lcc) != -1) { - - if (lcc->fieldsSet & LCC_UID_SET) { - uid = lcc->euid; - uidset = 1; - } - if (lcc->fieldsSet & LCC_GID_SET) { - gid = lcc->egid; - gidset = 1; - } - -#if defined(HAVE_GETZONEID) && defined(SHMPERM_ZONEID) - if ( ((lcc->fieldsSet & LCC_ZID_SET) == 0) || (lcc->zoneid == -1) - || (lcc->zoneid != SHMPERM_ZONEID(perm))) { - uidset = 0; - gidset = 0; - } -#endif - FreeLocalClientCreds(lcc); - - if (uidset) { - /* User id 0 always gets access */ - if (uid == 0) { - return 0; - } - /* Check the owner */ - if (SHMPERM_UID(perm) == uid || SHMPERM_CUID(perm) == uid) { - mask = S_IRUSR; - if (!readonly) { - mask |= S_IWUSR; - } - return (SHMPERM_MODE(perm) & mask) == mask ? 0 : -1; - } - } - - if (gidset) { - /* Check the group */ - if (SHMPERM_GID(perm) == gid || SHMPERM_CGID(perm) == gid) { - mask = S_IRGRP; - if (!readonly) { - mask |= S_IWGRP; - } - return (SHMPERM_MODE(perm) & mask) == mask ? 0 : -1; - } - } - } - /* Otherwise, check everyone else */ - mask = S_IROTH; - if (!readonly) { - mask |= S_IWOTH; - } - return (SHMPERM_MODE(perm) & mask) == mask ? 0 : -1; -} - -static int -ProcShmAttach(ClientPtr client) -{ - SHMSTAT_TYPE buf; - ShmDescPtr shmdesc; - REQUEST(xShmAttachReq); - - REQUEST_SIZE_MATCH(xShmAttachReq); - LEGAL_NEW_RESOURCE(stuff->shmseg, client); - if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) - { - client->errorValue = stuff->readOnly; - return BadValue; - } - for (shmdesc = Shmsegs; - shmdesc && (shmdesc->shmid != stuff->shmid); - shmdesc = shmdesc->next) - ; - if (shmdesc) - { - if (!stuff->readOnly && !shmdesc->writable) - return BadAccess; - shmdesc->refcnt++; - } - else - { - shmdesc = malloc(sizeof(ShmDescRec)); - if (!shmdesc) - return BadAlloc; - shmdesc->addr = shmat(stuff->shmid, 0, - stuff->readOnly ? SHM_RDONLY : 0); - if ((shmdesc->addr == ((char *)-1)) || - SHMSTAT(stuff->shmid, &buf)) - { - free(shmdesc); - return BadAccess; - } - - /* The attach was performed with root privs. We must - * do manual checking of access rights for the credentials - * of the client */ - - if (shm_access(client, &(SHM_PERM(buf)), stuff->readOnly) == -1) { - shmdt(shmdesc->addr); - free(shmdesc); - return BadAccess; - } - - shmdesc->shmid = stuff->shmid; - shmdesc->refcnt = 1; - shmdesc->writable = !stuff->readOnly; - shmdesc->size = SHM_SEGSZ(buf); - shmdesc->next = Shmsegs; - Shmsegs = shmdesc; - } - if (!AddResource(stuff->shmseg, ShmSegType, (pointer)shmdesc)) - return BadAlloc; - return Success; -} - -/*ARGSUSED*/ -static int -ShmDetachSegment(pointer value, /* must conform to DeleteType */ - XID shmseg) -{ - ShmDescPtr shmdesc = (ShmDescPtr)value; - ShmDescPtr *prev; - - if (--shmdesc->refcnt) - return TRUE; - shmdt(shmdesc->addr); - for (prev = &Shmsegs; *prev != shmdesc; prev = &(*prev)->next) - ; - *prev = shmdesc->next; - free(shmdesc); - return Success; -} - -static int -ProcShmDetach(ClientPtr client) -{ - ShmDescPtr shmdesc; - REQUEST(xShmDetachReq); - - REQUEST_SIZE_MATCH(xShmDetachReq); - VERIFY_SHMSEG(stuff->shmseg, shmdesc, client); - FreeResource(stuff->shmseg, RT_NONE); - return Success; -} - -/* - * If the given request doesn't exactly match PutImage's constraints, - * wrap the image in a scratch pixmap header and let CopyArea sort it out. - */ -static void -doShmPutImage(DrawablePtr dst, GCPtr pGC, - int depth, unsigned int format, - int w, int h, int sx, int sy, int sw, int sh, int dx, int dy, - char *data) -{ - PixmapPtr pPixmap; - - if (format == ZPixmap || depth == 1) { - pPixmap = GetScratchPixmapHeader(dst->pScreen, w, h, depth, - BitsPerPixel(depth), - PixmapBytePad(w, depth), - data); - if (!pPixmap) - return; - pGC->ops->CopyArea((DrawablePtr)pPixmap, dst, pGC, sx, sy, sw, sh, dx, dy); - FreeScratchPixmapHeader(pPixmap); - } else { - GCPtr putGC = GetScratchGC(depth, dst->pScreen); - - if (!putGC) - return; - - pPixmap = (*dst->pScreen->CreatePixmap)(dst->pScreen, sw, sh, depth, - CREATE_PIXMAP_USAGE_SCRATCH); - if (!pPixmap) { - FreeScratchGC(putGC); - return; - } - ValidateGC(&pPixmap->drawable, putGC); - (*putGC->ops->PutImage)(&pPixmap->drawable, putGC, depth, -sx, -sy, w, h, 0, - (format == XYPixmap) ? XYPixmap : ZPixmap, data); - FreeScratchGC(putGC); - if (format == XYBitmap) - (void)(*pGC->ops->CopyPlane)(&pPixmap->drawable, dst, pGC, 0, 0, sw, sh, - dx, dy, 1L); - else - (void)(*pGC->ops->CopyArea)(&pPixmap->drawable, dst, pGC, 0, 0, sw, sh, - dx, dy); - (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap); - } -} - -static int -ProcShmPutImage(ClientPtr client) -{ - GCPtr pGC; - DrawablePtr pDraw; - long length; - ShmDescPtr shmdesc; - REQUEST(xShmPutImageReq); - - REQUEST_SIZE_MATCH(xShmPutImageReq); - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client); - if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse)) - return BadValue; - if (stuff->format == XYBitmap) - { - if (stuff->depth != 1) - return BadMatch; - length = PixmapBytePad(stuff->totalWidth, 1); - } - else if (stuff->format == XYPixmap) - { - if (pDraw->depth != stuff->depth) - return BadMatch; - length = PixmapBytePad(stuff->totalWidth, 1); - length *= stuff->depth; - } - else if (stuff->format == ZPixmap) - { - if (pDraw->depth != stuff->depth) - return BadMatch; - length = PixmapBytePad(stuff->totalWidth, stuff->depth); - } - else - { - client->errorValue = stuff->format; - return BadValue; - } - - /* - * There's a potential integer overflow in this check: - * VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight, - * client); - * the version below ought to avoid it - */ - if (stuff->totalHeight != 0 && - length > (shmdesc->size - stuff->offset)/stuff->totalHeight) { - client->errorValue = stuff->totalWidth; - return BadValue; - } - if (stuff->srcX > stuff->totalWidth) - { - client->errorValue = stuff->srcX; - return BadValue; - } - if (stuff->srcY > stuff->totalHeight) - { - client->errorValue = stuff->srcY; - return BadValue; - } - if ((stuff->srcX + stuff->srcWidth) > stuff->totalWidth) - { - client->errorValue = stuff->srcWidth; - return BadValue; - } - if ((stuff->srcY + stuff->srcHeight) > stuff->totalHeight) - { - client->errorValue = stuff->srcHeight; - return BadValue; - } - - if ((((stuff->format == ZPixmap) && (stuff->srcX == 0)) || - ((stuff->format != ZPixmap) && - (stuff->srcX < screenInfo.bitmapScanlinePad) && - ((stuff->format == XYBitmap) || - ((stuff->srcY == 0) && - (stuff->srcHeight == stuff->totalHeight))))) && - ((stuff->srcX + stuff->srcWidth) == stuff->totalWidth)) - (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, - stuff->dstX, stuff->dstY, - stuff->totalWidth, stuff->srcHeight, - stuff->srcX, stuff->format, - shmdesc->addr + stuff->offset + - (stuff->srcY * length)); - else - doShmPutImage(pDraw, pGC, stuff->depth, stuff->format, - stuff->totalWidth, stuff->totalHeight, - stuff->srcX, stuff->srcY, - stuff->srcWidth, stuff->srcHeight, - stuff->dstX, stuff->dstY, - shmdesc->addr + stuff->offset); - - if (stuff->sendEvent) - { - xShmCompletionEvent ev; - - ev.type = ShmCompletionCode; - ev.drawable = stuff->drawable; - ev.minorEvent = X_ShmPutImage; - ev.majorEvent = ShmReqCode; - ev.shmseg = stuff->shmseg; - ev.offset = stuff->offset; - WriteEventsToClient(client, 1, (xEvent *) &ev); - } - - return Success; -} - -static int -ProcShmGetImage(ClientPtr client) -{ - DrawablePtr pDraw; - long lenPer = 0, length; - Mask plane = 0; - xShmGetImageReply xgi; - ShmDescPtr shmdesc; - int n, rc; - - REQUEST(xShmGetImageReq); - - REQUEST_SIZE_MATCH(xShmGetImageReq); - if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) - { - client->errorValue = stuff->format; - return BadValue; - } - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, - DixReadAccess); - if (rc != Success) - return rc; - VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); - if (pDraw->type == DRAWABLE_WINDOW) - { - if( /* check for being viewable */ - !((WindowPtr) pDraw)->realized || - /* check for being on screen */ - pDraw->x + stuff->x < 0 || - pDraw->x + stuff->x + (int)stuff->width > pDraw->pScreen->width || - pDraw->y + stuff->y < 0 || - pDraw->y + stuff->y + (int)stuff->height > pDraw->pScreen->height || - /* check for being inside of border */ - stuff->x < - wBorderWidth((WindowPtr)pDraw) || - stuff->x + (int)stuff->width > - wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width || - stuff->y < -wBorderWidth((WindowPtr)pDraw) || - stuff->y + (int)stuff->height > - wBorderWidth((WindowPtr)pDraw) + (int)pDraw->height - ) - return BadMatch; - xgi.visual = wVisual(((WindowPtr)pDraw)); - } - else - { - if (stuff->x < 0 || - stuff->x+(int)stuff->width > pDraw->width || - stuff->y < 0 || - stuff->y+(int)stuff->height > pDraw->height - ) - return BadMatch; - xgi.visual = None; - } - xgi.type = X_Reply; - xgi.length = 0; - xgi.sequenceNumber = client->sequence; - xgi.depth = pDraw->depth; - if(stuff->format == ZPixmap) - { - length = PixmapBytePad(stuff->width, pDraw->depth) * stuff->height; - } - else - { - lenPer = PixmapBytePad(stuff->width, 1) * stuff->height; - plane = ((Mask)1) << (pDraw->depth - 1); - /* only planes asked for */ - length = lenPer * Ones(stuff->planeMask & (plane | (plane - 1))); - } - - VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client); - xgi.size = length; - - if (length == 0) - { - /* nothing to do */ - } - else if (stuff->format == ZPixmap) - { - (*pDraw->pScreen->GetImage)(pDraw, stuff->x, stuff->y, - stuff->width, stuff->height, - stuff->format, stuff->planeMask, - shmdesc->addr + stuff->offset); - } - else - { - - length = stuff->offset; - for (; plane; plane >>= 1) - { - if (stuff->planeMask & plane) - { - (*pDraw->pScreen->GetImage)(pDraw, - stuff->x, stuff->y, - stuff->width, stuff->height, - stuff->format, plane, - shmdesc->addr + length); - length += lenPer; - } - } - } - - if (client->swapped) { - swaps(&xgi.sequenceNumber, n); - swapl(&xgi.length, n); - swapl(&xgi.visual, n); - swapl(&xgi.size, n); - } - WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi); - - return Success; -} - -#ifdef PANORAMIX -static int -ProcPanoramiXShmPutImage(ClientPtr client) -{ - int j, result, orig_x, orig_y; - PanoramiXRes *draw, *gc; - Bool sendEvent, isRoot; - - REQUEST(xShmPutImageReq); - REQUEST_SIZE_MATCH(xShmPutImageReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, - XRT_GC, client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - orig_x = stuff->dstX; - orig_y = stuff->dstY; - sendEvent = stuff->sendEvent; - stuff->sendEvent = 0; - FOR_NSCREENS(j) { - if(!j) stuff->sendEvent = sendEvent; - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - if (isRoot) { - stuff->dstX = orig_x - screenInfo.screens[j]->x; - stuff->dstY = orig_y - screenInfo.screens[j]->y; - } - result = ProcShmPutImage(client); - if(result != Success) break; - } - return result; -} - -static int -ProcPanoramiXShmGetImage(ClientPtr client) -{ - PanoramiXRes *draw; - DrawablePtr *drawables; - DrawablePtr pDraw; - xShmGetImageReply xgi; - ShmDescPtr shmdesc; - int i, x, y, w, h, format, rc; - Mask plane = 0, planemask; - long lenPer = 0, length, widthBytesLine; - Bool isRoot; - - REQUEST(xShmGetImageReq); - - REQUEST_SIZE_MATCH(xShmGetImageReq); - - if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) { - client->errorValue = stuff->format; - return BadValue; - } - - rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (rc != Success) - return (rc == BadValue) ? BadDrawable : rc; - - if (draw->type == XRT_PIXMAP) - return ProcShmGetImage(client); - - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, - DixReadAccess); - if (rc != Success) - return rc; - - VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); - - x = stuff->x; - y = stuff->y; - w = stuff->width; - h = stuff->height; - format = stuff->format; - planemask = stuff->planeMask; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - if(isRoot) { - if( /* check for being onscreen */ - x < 0 || x + w > PanoramiXPixWidth || - y < 0 || y + h > PanoramiXPixHeight ) - return BadMatch; - } else { - if( /* check for being onscreen */ - screenInfo.screens[0]->x + pDraw->x + x < 0 || - screenInfo.screens[0]->x + pDraw->x + x + w > PanoramiXPixWidth || - screenInfo.screens[0]->y + pDraw->y + y < 0 || - screenInfo.screens[0]->y + pDraw->y + y + h > PanoramiXPixHeight || - /* check for being inside of border */ - x < - wBorderWidth((WindowPtr)pDraw) || - x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width || - y < -wBorderWidth((WindowPtr)pDraw) || - y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height) - return BadMatch; - } - - drawables = calloc(PanoramiXNumScreens, sizeof(DrawablePtr)); - if(!drawables) - return BadAlloc; - - drawables[0] = pDraw; - for(i = 1; i < PanoramiXNumScreens; i++) { - rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0, - DixReadAccess); - if (rc != Success) - { - free(drawables); - return rc; - } - } - - xgi.visual = wVisual(((WindowPtr)pDraw)); - xgi.type = X_Reply; - xgi.length = 0; - xgi.sequenceNumber = client->sequence; - xgi.depth = pDraw->depth; - - if(format == ZPixmap) { - widthBytesLine = PixmapBytePad(w, pDraw->depth); - length = widthBytesLine * h; - } else { - widthBytesLine = PixmapBytePad(w, 1); - lenPer = widthBytesLine * h; - plane = ((Mask)1) << (pDraw->depth - 1); - length = lenPer * Ones(planemask & (plane | (plane - 1))); - } - - VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client); - xgi.size = length; - - if (length == 0) {/* nothing to do */ } - else if (format == ZPixmap) { - XineramaGetImageData(drawables, x, y, w, h, format, planemask, - shmdesc->addr + stuff->offset, - widthBytesLine, isRoot); - } else { - - length = stuff->offset; - for (; plane; plane >>= 1) { - if (planemask & plane) { - XineramaGetImageData(drawables, x, y, w, h, - format, plane, shmdesc->addr + length, - widthBytesLine, isRoot); - length += lenPer; - } - } - } - free(drawables); - - if (client->swapped) { - int n; - swaps(&xgi.sequenceNumber, n); - swapl(&xgi.length, n); - swapl(&xgi.visual, n); - swapl(&xgi.size, n); - } - WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi); - - return Success; -} - -static int -ProcPanoramiXShmCreatePixmap(ClientPtr client) -{ - ScreenPtr pScreen = NULL; - PixmapPtr pMap = NULL; - DrawablePtr pDraw; - DepthPtr pDepth; - int i, j, result, rc; - ShmDescPtr shmdesc; - REQUEST(xShmCreatePixmapReq); - unsigned int width, height, depth; - unsigned long size; - PanoramiXRes *newPix; - - REQUEST_SIZE_MATCH(xShmCreatePixmapReq); - client->errorValue = stuff->pid; - if (!sharedPixmaps) - return BadImplementation; - LEGAL_NEW_RESOURCE(stuff->pid, client); - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, - DixGetAttrAccess); - if (rc != Success) - return rc; - - VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); - - width = stuff->width; - height = stuff->height; - depth = stuff->depth; - if (!width || !height || !depth) - { - client->errorValue = 0; - return BadValue; - } - if (width > 32767 || height > 32767) - return BadAlloc; - - if (stuff->depth != 1) - { - pDepth = pDraw->pScreen->allowedDepths; - for (i=0; ipScreen->numDepths; i++, pDepth++) - if (pDepth->depth == stuff->depth) - goto CreatePmap; - client->errorValue = stuff->depth; - return BadValue; - } - -CreatePmap: - size = PixmapBytePad(width, depth) * height; - if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) { - if (size < width * height) - return BadAlloc; - } - /* thankfully, offset is unsigned */ - if (stuff->offset + size < size) - return BadAlloc; - - VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); - - if(!(newPix = malloc(sizeof(PanoramiXRes)))) - return BadAlloc; - - newPix->type = XRT_PIXMAP; - newPix->u.pix.shared = TRUE; - newPix->info[0].id = stuff->pid; - for(j = 1; j < PanoramiXNumScreens; j++) - newPix->info[j].id = FakeClientID(client->index); - - result = Success; - - FOR_NSCREENS(j) { - ShmScrPrivateRec *screen_priv; - pScreen = screenInfo.screens[j]; - - screen_priv = ShmGetScreenPriv(pScreen); - pMap = (*screen_priv->shmFuncs->CreatePixmap)(pScreen, - stuff->width, stuff->height, stuff->depth, - shmdesc->addr + stuff->offset); - - if (pMap) { - dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc); - shmdesc->refcnt++; - pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - pMap->drawable.id = newPix->info[j].id; - if (!AddResource(newPix->info[j].id, RT_PIXMAP, (pointer)pMap)) { - (*pScreen->DestroyPixmap)(pMap); - result = BadAlloc; - break; - } - } else { - result = BadAlloc; - break; - } - } - - if(result == BadAlloc) { - while(j--) { - (*pScreen->DestroyPixmap)(pMap); - FreeResource(newPix->info[j].id, RT_NONE); - } - free(newPix); - } else - AddResource(stuff->pid, XRT_PIXMAP, newPix); - - return result; -} -#endif - -static PixmapPtr -fbShmCreatePixmap (ScreenPtr pScreen, - int width, int height, int depth, char *addr) -{ - PixmapPtr pPixmap; - - pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth, 0); - if (!pPixmap) - return NullPixmap; - - if (!(*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth, - BitsPerPixel(depth), PixmapBytePad(width, depth), (pointer)addr)) { - (*pScreen->DestroyPixmap)(pPixmap); - return NullPixmap; - } - return pPixmap; -} - -static int -ProcShmCreatePixmap(ClientPtr client) -{ - PixmapPtr pMap; - DrawablePtr pDraw; - DepthPtr pDepth; - int i, rc; - ShmDescPtr shmdesc; - ShmScrPrivateRec *screen_priv; - REQUEST(xShmCreatePixmapReq); - unsigned int width, height, depth; - unsigned long size; - - REQUEST_SIZE_MATCH(xShmCreatePixmapReq); - client->errorValue = stuff->pid; - if (!sharedPixmaps) - return BadImplementation; - LEGAL_NEW_RESOURCE(stuff->pid, client); - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, - DixGetAttrAccess); - if (rc != Success) - return rc; - - VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); - - width = stuff->width; - height = stuff->height; - depth = stuff->depth; - if (!width || !height || !depth) - { - client->errorValue = 0; - return BadValue; - } - if (width > 32767 || height > 32767) - return BadAlloc; - - if (stuff->depth != 1) - { - pDepth = pDraw->pScreen->allowedDepths; - for (i=0; ipScreen->numDepths; i++, pDepth++) - if (pDepth->depth == stuff->depth) - goto CreatePmap; - client->errorValue = stuff->depth; - return BadValue; - } - -CreatePmap: - size = PixmapBytePad(width, depth) * height; - if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) { - if (size < width * height) - return BadAlloc; - } - /* thankfully, offset is unsigned */ - if (stuff->offset + size < size) - return BadAlloc; - - VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); - screen_priv = ShmGetScreenPriv(pDraw->pScreen); - pMap = (*screen_priv->shmFuncs->CreatePixmap)( - pDraw->pScreen, stuff->width, - stuff->height, stuff->depth, - shmdesc->addr + stuff->offset); - if (pMap) - { - rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP, - pMap, RT_NONE, NULL, DixCreateAccess); - if (rc != Success) { - pDraw->pScreen->DestroyPixmap(pMap); - return rc; - } - dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc); - shmdesc->refcnt++; - pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - pMap->drawable.id = stuff->pid; - if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap)) - { - return Success; - } - pDraw->pScreen->DestroyPixmap(pMap); - } - return BadAlloc; -} - -static int -ProcShmDispatch (ClientPtr client) -{ - REQUEST(xReq); - switch (stuff->data) - { - case X_ShmQueryVersion: - return ProcShmQueryVersion(client); - case X_ShmAttach: - return ProcShmAttach(client); - case X_ShmDetach: - return ProcShmDetach(client); - case X_ShmPutImage: -#ifdef PANORAMIX - if ( !noPanoramiXExtension ) - return ProcPanoramiXShmPutImage(client); -#endif - return ProcShmPutImage(client); - case X_ShmGetImage: -#ifdef PANORAMIX - if ( !noPanoramiXExtension ) - return ProcPanoramiXShmGetImage(client); -#endif - return ProcShmGetImage(client); - case X_ShmCreatePixmap: -#ifdef PANORAMIX - if ( !noPanoramiXExtension ) - return ProcPanoramiXShmCreatePixmap(client); -#endif - return ProcShmCreatePixmap(client); - default: - return BadRequest; - } -} - -static void -SShmCompletionEvent(xShmCompletionEvent *from, xShmCompletionEvent *to) -{ - to->type = from->type; - cpswaps(from->sequenceNumber, to->sequenceNumber); - cpswapl(from->drawable, to->drawable); - cpswaps(from->minorEvent, to->minorEvent); - to->majorEvent = from->majorEvent; - cpswapl(from->shmseg, to->shmseg); - cpswapl(from->offset, to->offset); -} - -static int -SProcShmQueryVersion(ClientPtr client) -{ - int n; - REQUEST(xShmQueryVersionReq); - - swaps(&stuff->length, n); - return ProcShmQueryVersion(client); -} - -static int -SProcShmAttach(ClientPtr client) -{ - int n; - REQUEST(xShmAttachReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xShmAttachReq); - swapl(&stuff->shmseg, n); - swapl(&stuff->shmid, n); - return ProcShmAttach(client); -} - -static int -SProcShmDetach(ClientPtr client) -{ - int n; - REQUEST(xShmDetachReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xShmDetachReq); - swapl(&stuff->shmseg, n); - return ProcShmDetach(client); -} - -static int -SProcShmPutImage(ClientPtr client) -{ - int n; - REQUEST(xShmPutImageReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xShmPutImageReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->totalWidth, n); - swaps(&stuff->totalHeight, n); - swaps(&stuff->srcX, n); - swaps(&stuff->srcY, n); - swaps(&stuff->srcWidth, n); - swaps(&stuff->srcHeight, n); - swaps(&stuff->dstX, n); - swaps(&stuff->dstY, n); - swapl(&stuff->shmseg, n); - swapl(&stuff->offset, n); - return ProcShmPutImage(client); -} - -static int -SProcShmGetImage(ClientPtr client) -{ - int n; - REQUEST(xShmGetImageReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xShmGetImageReq); - swapl(&stuff->drawable, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swapl(&stuff->planeMask, n); - swapl(&stuff->shmseg, n); - swapl(&stuff->offset, n); - return ProcShmGetImage(client); -} - -static int -SProcShmCreatePixmap(ClientPtr client) -{ - int n; - REQUEST(xShmCreatePixmapReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xShmCreatePixmapReq); - swapl(&stuff->pid, n); - swapl(&stuff->drawable, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swapl(&stuff->shmseg, n); - swapl(&stuff->offset, n); - return ProcShmCreatePixmap(client); -} - -static int -SProcShmDispatch (ClientPtr client) -{ - REQUEST(xReq); - switch (stuff->data) - { - case X_ShmQueryVersion: - return SProcShmQueryVersion(client); - case X_ShmAttach: - return SProcShmAttach(client); - case X_ShmDetach: - return SProcShmDetach(client); - case X_ShmPutImage: - return SProcShmPutImage(client); - case X_ShmGetImage: - return SProcShmGetImage(client); - case X_ShmCreatePixmap: - return SProcShmCreatePixmap(client); - default: - return BadRequest; - } -} - -void -ShmExtensionInit(INITARGS) -{ - ExtensionEntry *extEntry; - int i; - -#ifdef MUST_CHECK_FOR_SHM_SYSCALL - if (!CheckForShmSyscall()) - { - ErrorF("MIT-SHM extension disabled due to lack of kernel support\n"); - return; - } -#endif - - if (!ShmRegisterPrivates()) - return; - - sharedPixmaps = xFalse; - { - sharedPixmaps = xTrue; - for (i = 0; i < screenInfo.numScreens; i++) - { - ShmScrPrivateRec *screen_priv = ShmInitScreenPriv(screenInfo.screens[i]); - if (!screen_priv->shmFuncs) - screen_priv->shmFuncs = &miFuncs; - if (!screen_priv->shmFuncs->CreatePixmap) - sharedPixmaps = xFalse; - } - if (sharedPixmaps) - for (i = 0; i < screenInfo.numScreens; i++) - { - ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(screenInfo.screens[i]); - screen_priv->destroyPixmap = screenInfo.screens[i]->DestroyPixmap; - screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap; - } - } - ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg"); - if (ShmSegType && - (extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors, - ProcShmDispatch, SProcShmDispatch, - ShmResetProc, StandardMinorOpcode))) - { - ShmReqCode = (unsigned char)extEntry->base; - ShmCompletionCode = extEntry->eventBase; - BadShmSegCode = extEntry->errorBase; - SetResourceTypeErrorValue(ShmSegType, BadShmSegCode); - EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent; - } -} +/************************************************************ + +Copyright 1989, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +********************************************************/ + +/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */ + + +#define SHM + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "resource.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "gcstruct.h" +#include "extnsionst.h" +#include "servermd.h" +#include "shmint.h" +#include "xace.h" +#include +#include +#include "protocol-versions.h" + +/* Needed for Solaris cross-zone shared memory extension */ +#ifdef HAVE_SHMCTL64 +#include +#define SHMSTAT(id, buf) shmctl64(id, IPC_STAT64, buf) +#define SHMSTAT_TYPE struct shmid_ds64 +#define SHMPERM_TYPE struct ipc_perm64 +#define SHM_PERM(buf) buf.shmx_perm +#define SHM_SEGSZ(buf) buf.shmx_segsz +#define SHMPERM_UID(p) p->ipcx_uid +#define SHMPERM_CUID(p) p->ipcx_cuid +#define SHMPERM_GID(p) p->ipcx_gid +#define SHMPERM_CGID(p) p->ipcx_cgid +#define SHMPERM_MODE(p) p->ipcx_mode +#define SHMPERM_ZONEID(p) p->ipcx_zoneid +#else +#define SHMSTAT(id, buf) shmctl(id, IPC_STAT, buf) +#define SHMSTAT_TYPE struct shmid_ds +#define SHMPERM_TYPE struct ipc_perm +#define SHM_PERM(buf) buf.shm_perm +#define SHM_SEGSZ(buf) buf.shm_segsz +#define SHMPERM_UID(p) p->uid +#define SHMPERM_CUID(p) p->cuid +#define SHMPERM_GID(p) p->gid +#define SHMPERM_CGID(p) p->cgid +#define SHMPERM_MODE(p) p->mode +#endif + +#ifdef PANORAMIX +#include "panoramiX.h" +#include "panoramiXsrv.h" +#endif + +#include "modinit.h" + +typedef struct _ShmDesc { + struct _ShmDesc *next; + int shmid; + int refcnt; + char *addr; + Bool writable; + unsigned long size; +} ShmDescRec, *ShmDescPtr; + +typedef struct _ShmScrPrivateRec { + CloseScreenProcPtr CloseScreen; + ShmFuncsPtr shmFuncs; + DestroyPixmapProcPtr destroyPixmap; +} ShmScrPrivateRec; + +static PixmapPtr fbShmCreatePixmap(XSHM_CREATE_PIXMAP_ARGS); +static int ShmDetachSegment( + pointer /* value */, + XID /* shmseg */ + ); +static void ShmResetProc( + ExtensionEntry * /* extEntry */ + ); +static void SShmCompletionEvent( + xShmCompletionEvent * /* from */, + xShmCompletionEvent * /* to */ + ); + +static Bool ShmDestroyPixmap (PixmapPtr pPixmap); + + +static unsigned char ShmReqCode; +int ShmCompletionCode; +int BadShmSegCode; +RESTYPE ShmSegType; +static ShmDescPtr Shmsegs; +static Bool sharedPixmaps; +static DevPrivateKeyRec shmScrPrivateKeyRec; +#define shmScrPrivateKey (&shmScrPrivateKeyRec) +static DevPrivateKeyRec shmPixmapPrivateKeyRec; +#define shmPixmapPrivateKey (&shmPixmapPrivateKeyRec) +static ShmFuncs miFuncs = {NULL, NULL}; +static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL}; + +#define ShmGetScreenPriv(s) ((ShmScrPrivateRec *)dixLookupPrivate(&(s)->devPrivates, shmScrPrivateKey)) + +#define VERIFY_SHMSEG(shmseg,shmdesc,client) \ +{ \ + int rc; \ + rc = dixLookupResourceByType((pointer *)&(shmdesc), shmseg, ShmSegType, \ + client, DixReadAccess); \ + if (rc != Success) \ + return rc; \ +} + +#define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \ +{ \ + VERIFY_SHMSEG(shmseg, shmdesc, client); \ + if ((offset & 3) || (offset > shmdesc->size)) \ + { \ + client->errorValue = offset; \ + return BadValue; \ + } \ + if (needwrite && !shmdesc->writable) \ + return BadAccess; \ +} + +#define VERIFY_SHMSIZE(shmdesc,offset,len,client) \ +{ \ + if ((offset + len) > shmdesc->size) \ + { \ + return BadAccess; \ + } \ +} + + +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__) +#include + +static Bool badSysCall = FALSE; + +static void +SigSysHandler(int signo) +{ + badSysCall = TRUE; +} + +static Bool CheckForShmSyscall(void) +{ + void (*oldHandler)(); + int shmid = -1; + + /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */ + oldHandler = signal(SIGSYS, SigSysHandler); + + badSysCall = FALSE; + shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT); + + if (shmid != -1) + { + /* Successful allocation - clean up */ + shmctl(shmid, IPC_RMID, NULL); + } + else + { + /* Allocation failed */ + badSysCall = TRUE; + } + signal(SIGSYS, oldHandler); + return !badSysCall; +} + +#define MUST_CHECK_FOR_SHM_SYSCALL + +#endif + +static Bool +ShmCloseScreen(int i, ScreenPtr pScreen) +{ + ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen); + pScreen->CloseScreen = screen_priv->CloseScreen; + dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, NULL); + free(screen_priv); + return (*pScreen->CloseScreen) (i, pScreen); +} + +static ShmScrPrivateRec * +ShmInitScreenPriv(ScreenPtr pScreen) +{ + ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen); + if (!screen_priv) + { + screen_priv = calloc(1, sizeof (ShmScrPrivateRec)); + screen_priv->CloseScreen = pScreen->CloseScreen; + dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, screen_priv); + pScreen->CloseScreen = ShmCloseScreen; + } + return screen_priv; +} + +static Bool +ShmRegisterPrivates(void) +{ + if (!dixRegisterPrivateKey(&shmScrPrivateKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + if (!dixRegisterPrivateKey(&shmPixmapPrivateKeyRec, PRIVATE_PIXMAP, 0)) + return FALSE; + return TRUE; +} + +/*ARGSUSED*/ +static void +ShmResetProc(ExtensionEntry *extEntry) +{ + int i; + for (i = 0; i < screenInfo.numScreens; i++) + ShmRegisterFuncs(screenInfo.screens[i], NULL); +} + +void +ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs) +{ + if (!ShmRegisterPrivates()) + return; + ShmInitScreenPriv(pScreen)->shmFuncs = funcs; +} + +static Bool +ShmDestroyPixmap (PixmapPtr pPixmap) +{ + ScreenPtr pScreen = pPixmap->drawable.pScreen; + ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen); + Bool ret; + if (pPixmap->refcnt == 1) + { + ShmDescPtr shmdesc; + shmdesc = (ShmDescPtr)dixLookupPrivate(&pPixmap->devPrivates, + shmPixmapPrivateKey); + if (shmdesc) + ShmDetachSegment ((pointer) shmdesc, pPixmap->drawable.id); + } + + pScreen->DestroyPixmap = screen_priv->destroyPixmap; + ret = (*pScreen->DestroyPixmap) (pPixmap); + screen_priv->destroyPixmap = pScreen->DestroyPixmap; + pScreen->DestroyPixmap = ShmDestroyPixmap; + return ret; +} + +void +ShmRegisterFbFuncs(ScreenPtr pScreen) +{ + ShmRegisterFuncs(pScreen, &fbFuncs); +} + +static int +ProcShmQueryVersion(ClientPtr client) +{ + xShmQueryVersionReply rep; + int n; + + REQUEST_SIZE_MATCH(xShmQueryVersionReq); + memset(&rep, 0, sizeof(xShmQueryVersionReply)); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.sharedPixmaps = sharedPixmaps; + rep.pixmapFormat = sharedPixmaps ? ZPixmap : 0; + rep.majorVersion = SERVER_SHM_MAJOR_VERSION; + rep.minorVersion = SERVER_SHM_MINOR_VERSION; + rep.uid = geteuid(); + rep.gid = getegid(); + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + swaps(&rep.uid, n); + swaps(&rep.gid, n); + } + WriteToClient(client, sizeof(xShmQueryVersionReply), (char *)&rep); + return Success; +} + +/* + * Simulate the access() system call for a shared memory segement, + * using the credentials from the client if available + */ +static int +shm_access(ClientPtr client, SHMPERM_TYPE *perm, int readonly) +{ + int uid, gid; + mode_t mask; + int uidset = 0, gidset = 0; + LocalClientCredRec *lcc; + + if (GetLocalClientCreds(client, &lcc) != -1) { + + if (lcc->fieldsSet & LCC_UID_SET) { + uid = lcc->euid; + uidset = 1; + } + if (lcc->fieldsSet & LCC_GID_SET) { + gid = lcc->egid; + gidset = 1; + } + +#if defined(HAVE_GETZONEID) && defined(SHMPERM_ZONEID) + if ( ((lcc->fieldsSet & LCC_ZID_SET) == 0) || (lcc->zoneid == -1) + || (lcc->zoneid != SHMPERM_ZONEID(perm))) { + uidset = 0; + gidset = 0; + } +#endif + FreeLocalClientCreds(lcc); + + if (uidset) { + /* User id 0 always gets access */ + if (uid == 0) { + return 0; + } + /* Check the owner */ + if (SHMPERM_UID(perm) == uid || SHMPERM_CUID(perm) == uid) { + mask = S_IRUSR; + if (!readonly) { + mask |= S_IWUSR; + } + return (SHMPERM_MODE(perm) & mask) == mask ? 0 : -1; + } + } + + if (gidset) { + /* Check the group */ + if (SHMPERM_GID(perm) == gid || SHMPERM_CGID(perm) == gid) { + mask = S_IRGRP; + if (!readonly) { + mask |= S_IWGRP; + } + return (SHMPERM_MODE(perm) & mask) == mask ? 0 : -1; + } + } + } + /* Otherwise, check everyone else */ + mask = S_IROTH; + if (!readonly) { + mask |= S_IWOTH; + } + return (SHMPERM_MODE(perm) & mask) == mask ? 0 : -1; +} + +static int +ProcShmAttach(ClientPtr client) +{ + SHMSTAT_TYPE buf; + ShmDescPtr shmdesc; + REQUEST(xShmAttachReq); + + REQUEST_SIZE_MATCH(xShmAttachReq); + LEGAL_NEW_RESOURCE(stuff->shmseg, client); + if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) + { + client->errorValue = stuff->readOnly; + return BadValue; + } + for (shmdesc = Shmsegs; + shmdesc && (shmdesc->shmid != stuff->shmid); + shmdesc = shmdesc->next) + ; + if (shmdesc) + { + if (!stuff->readOnly && !shmdesc->writable) + return BadAccess; + shmdesc->refcnt++; + } + else + { + shmdesc = malloc(sizeof(ShmDescRec)); + if (!shmdesc) + return BadAlloc; + shmdesc->addr = shmat(stuff->shmid, 0, + stuff->readOnly ? SHM_RDONLY : 0); + if ((shmdesc->addr == ((char *)-1)) || + SHMSTAT(stuff->shmid, &buf)) + { + free(shmdesc); + return BadAccess; + } + + /* The attach was performed with root privs. We must + * do manual checking of access rights for the credentials + * of the client */ + + if (shm_access(client, &(SHM_PERM(buf)), stuff->readOnly) == -1) { + shmdt(shmdesc->addr); + free(shmdesc); + return BadAccess; + } + + shmdesc->shmid = stuff->shmid; + shmdesc->refcnt = 1; + shmdesc->writable = !stuff->readOnly; + shmdesc->size = SHM_SEGSZ(buf); + shmdesc->next = Shmsegs; + Shmsegs = shmdesc; + } + if (!AddResource(stuff->shmseg, ShmSegType, (pointer)shmdesc)) + return BadAlloc; + return Success; +} + +/*ARGSUSED*/ +static int +ShmDetachSegment(pointer value, /* must conform to DeleteType */ + XID shmseg) +{ + ShmDescPtr shmdesc = (ShmDescPtr)value; + ShmDescPtr *prev; + + if (--shmdesc->refcnt) + return TRUE; + shmdt(shmdesc->addr); + for (prev = &Shmsegs; *prev != shmdesc; prev = &(*prev)->next) + ; + *prev = shmdesc->next; + free(shmdesc); + return Success; +} + +static int +ProcShmDetach(ClientPtr client) +{ + ShmDescPtr shmdesc; + REQUEST(xShmDetachReq); + + REQUEST_SIZE_MATCH(xShmDetachReq); + VERIFY_SHMSEG(stuff->shmseg, shmdesc, client); + FreeResource(stuff->shmseg, RT_NONE); + return Success; +} + +/* + * If the given request doesn't exactly match PutImage's constraints, + * wrap the image in a scratch pixmap header and let CopyArea sort it out. + */ +static void +doShmPutImage(DrawablePtr dst, GCPtr pGC, + int depth, unsigned int format, + int w, int h, int sx, int sy, int sw, int sh, int dx, int dy, + char *data) +{ + PixmapPtr pPixmap; + + if (format == ZPixmap || depth == 1) { + pPixmap = GetScratchPixmapHeader(dst->pScreen, w, h, depth, + BitsPerPixel(depth), + PixmapBytePad(w, depth), + data); + if (!pPixmap) + return; + pGC->ops->CopyArea((DrawablePtr)pPixmap, dst, pGC, sx, sy, sw, sh, dx, dy); + FreeScratchPixmapHeader(pPixmap); + } else { + GCPtr putGC = GetScratchGC(depth, dst->pScreen); + + if (!putGC) + return; + + pPixmap = (*dst->pScreen->CreatePixmap)(dst->pScreen, sw, sh, depth, + CREATE_PIXMAP_USAGE_SCRATCH); + if (!pPixmap) { + FreeScratchGC(putGC); + return; + } + ValidateGC(&pPixmap->drawable, putGC); + (*putGC->ops->PutImage)(&pPixmap->drawable, putGC, depth, -sx, -sy, w, h, 0, + (format == XYPixmap) ? XYPixmap : ZPixmap, data); + FreeScratchGC(putGC); + if (format == XYBitmap) + (void)(*pGC->ops->CopyPlane)(&pPixmap->drawable, dst, pGC, 0, 0, sw, sh, + dx, dy, 1L); + else + (void)(*pGC->ops->CopyArea)(&pPixmap->drawable, dst, pGC, 0, 0, sw, sh, + dx, dy); + (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap); + } +} + +static int +ProcShmPutImage(ClientPtr client) +{ + GCPtr pGC; + DrawablePtr pDraw; + long length; + ShmDescPtr shmdesc; + REQUEST(xShmPutImageReq); + + REQUEST_SIZE_MATCH(xShmPutImageReq); + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); + VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client); + if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse)) + return BadValue; + if (stuff->format == XYBitmap) + { + if (stuff->depth != 1) + return BadMatch; + length = PixmapBytePad(stuff->totalWidth, 1); + } + else if (stuff->format == XYPixmap) + { + if (pDraw->depth != stuff->depth) + return BadMatch; + length = PixmapBytePad(stuff->totalWidth, 1); + length *= stuff->depth; + } + else if (stuff->format == ZPixmap) + { + if (pDraw->depth != stuff->depth) + return BadMatch; + length = PixmapBytePad(stuff->totalWidth, stuff->depth); + } + else + { + client->errorValue = stuff->format; + return BadValue; + } + + /* + * There's a potential integer overflow in this check: + * VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight, + * client); + * the version below ought to avoid it + */ + if (stuff->totalHeight != 0 && + length > (shmdesc->size - stuff->offset)/stuff->totalHeight) { + client->errorValue = stuff->totalWidth; + return BadValue; + } + if (stuff->srcX > stuff->totalWidth) + { + client->errorValue = stuff->srcX; + return BadValue; + } + if (stuff->srcY > stuff->totalHeight) + { + client->errorValue = stuff->srcY; + return BadValue; + } + if ((stuff->srcX + stuff->srcWidth) > stuff->totalWidth) + { + client->errorValue = stuff->srcWidth; + return BadValue; + } + if ((stuff->srcY + stuff->srcHeight) > stuff->totalHeight) + { + client->errorValue = stuff->srcHeight; + return BadValue; + } + + if ((((stuff->format == ZPixmap) && (stuff->srcX == 0)) || + ((stuff->format != ZPixmap) && + (stuff->srcX < screenInfo.bitmapScanlinePad) && + ((stuff->format == XYBitmap) || + ((stuff->srcY == 0) && + (stuff->srcHeight == stuff->totalHeight))))) && + ((stuff->srcX + stuff->srcWidth) == stuff->totalWidth)) + (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, + stuff->dstX, stuff->dstY, + stuff->totalWidth, stuff->srcHeight, + stuff->srcX, stuff->format, + shmdesc->addr + stuff->offset + + (stuff->srcY * length)); + else + doShmPutImage(pDraw, pGC, stuff->depth, stuff->format, + stuff->totalWidth, stuff->totalHeight, + stuff->srcX, stuff->srcY, + stuff->srcWidth, stuff->srcHeight, + stuff->dstX, stuff->dstY, + shmdesc->addr + stuff->offset); + + if (stuff->sendEvent) + { + xShmCompletionEvent ev; + + ev.type = ShmCompletionCode; + ev.drawable = stuff->drawable; + ev.minorEvent = X_ShmPutImage; + ev.majorEvent = ShmReqCode; + ev.shmseg = stuff->shmseg; + ev.offset = stuff->offset; + WriteEventsToClient(client, 1, (xEvent *) &ev); + } + + return Success; +} + +static int +ProcShmGetImage(ClientPtr client) +{ + DrawablePtr pDraw; + long lenPer = 0, length; + Mask plane = 0; + xShmGetImageReply xgi; + ShmDescPtr shmdesc; + int n, rc; + + REQUEST(xShmGetImageReq); + + REQUEST_SIZE_MATCH(xShmGetImageReq); + if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) + { + client->errorValue = stuff->format; + return BadValue; + } + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); + if (pDraw->type == DRAWABLE_WINDOW) + { + if( /* check for being viewable */ + !((WindowPtr) pDraw)->realized || + /* check for being on screen */ + pDraw->x + stuff->x < 0 || + pDraw->x + stuff->x + (int)stuff->width > pDraw->pScreen->width || + pDraw->y + stuff->y < 0 || + pDraw->y + stuff->y + (int)stuff->height > pDraw->pScreen->height || + /* check for being inside of border */ + stuff->x < - wBorderWidth((WindowPtr)pDraw) || + stuff->x + (int)stuff->width > + wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width || + stuff->y < -wBorderWidth((WindowPtr)pDraw) || + stuff->y + (int)stuff->height > + wBorderWidth((WindowPtr)pDraw) + (int)pDraw->height + ) + return BadMatch; + xgi.visual = wVisual(((WindowPtr)pDraw)); + } + else + { + if (stuff->x < 0 || + stuff->x+(int)stuff->width > pDraw->width || + stuff->y < 0 || + stuff->y+(int)stuff->height > pDraw->height + ) + return BadMatch; + xgi.visual = None; + } + xgi.type = X_Reply; + xgi.length = 0; + xgi.sequenceNumber = client->sequence; + xgi.depth = pDraw->depth; + if(stuff->format == ZPixmap) + { + length = PixmapBytePad(stuff->width, pDraw->depth) * stuff->height; + } + else + { + lenPer = PixmapBytePad(stuff->width, 1) * stuff->height; + plane = ((Mask)1) << (pDraw->depth - 1); + /* only planes asked for */ + length = lenPer * Ones(stuff->planeMask & (plane | (plane - 1))); + } + + VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client); + xgi.size = length; + + if (length == 0) + { + /* nothing to do */ + } + else if (stuff->format == ZPixmap) + { + (*pDraw->pScreen->GetImage)(pDraw, stuff->x, stuff->y, + stuff->width, stuff->height, + stuff->format, stuff->planeMask, + shmdesc->addr + stuff->offset); + } + else + { + + length = stuff->offset; + for (; plane; plane >>= 1) + { + if (stuff->planeMask & plane) + { + (*pDraw->pScreen->GetImage)(pDraw, + stuff->x, stuff->y, + stuff->width, stuff->height, + stuff->format, plane, + shmdesc->addr + length); + length += lenPer; + } + } + } + + if (client->swapped) { + swaps(&xgi.sequenceNumber, n); + swapl(&xgi.length, n); + swapl(&xgi.visual, n); + swapl(&xgi.size, n); + } + WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi); + + return Success; +} + +#ifdef PANORAMIX +static int +ProcPanoramiXShmPutImage(ClientPtr client) +{ + int j, result, orig_x, orig_y; + PanoramiXRes *draw, *gc; + Bool sendEvent, isRoot; + + REQUEST(xShmPutImageReq); + REQUEST_SIZE_MATCH(xShmPutImageReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, + XRT_GC, client, DixReadAccess); + if (result != Success) + return result; + + isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; + + orig_x = stuff->dstX; + orig_y = stuff->dstY; + sendEvent = stuff->sendEvent; + stuff->sendEvent = 0; + FOR_NSCREENS(j) { + if(!j) stuff->sendEvent = sendEvent; + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { + stuff->dstX = orig_x - screenInfo.screens[j]->x; + stuff->dstY = orig_y - screenInfo.screens[j]->y; + } + result = ProcShmPutImage(client); + if(result != Success) break; + } + return result; +} + +static int +ProcPanoramiXShmGetImage(ClientPtr client) +{ + PanoramiXRes *draw; + DrawablePtr *drawables; + DrawablePtr pDraw; + xShmGetImageReply xgi; + ShmDescPtr shmdesc; + int i, x, y, w, h, format, rc; + Mask plane = 0, planemask; + long lenPer = 0, length, widthBytesLine; + Bool isRoot; + + REQUEST(xShmGetImageReq); + + REQUEST_SIZE_MATCH(xShmGetImageReq); + + if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) { + client->errorValue = stuff->format; + return BadValue; + } + + rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (rc != Success) + return (rc == BadValue) ? BadDrawable : rc; + + if (draw->type == XRT_PIXMAP) + return ProcShmGetImage(client); + + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + + VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); + + x = stuff->x; + y = stuff->y; + w = stuff->width; + h = stuff->height; + format = stuff->format; + planemask = stuff->planeMask; + + isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; + + if(isRoot) { + if( /* check for being onscreen */ + x < 0 || x + w > PanoramiXPixWidth || + y < 0 || y + h > PanoramiXPixHeight ) + return BadMatch; + } else { + if( /* check for being onscreen */ + screenInfo.screens[0]->x + pDraw->x + x < 0 || + screenInfo.screens[0]->x + pDraw->x + x + w > PanoramiXPixWidth || + screenInfo.screens[0]->y + pDraw->y + y < 0 || + screenInfo.screens[0]->y + pDraw->y + y + h > PanoramiXPixHeight || + /* check for being inside of border */ + x < - wBorderWidth((WindowPtr)pDraw) || + x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width || + y < -wBorderWidth((WindowPtr)pDraw) || + y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height) + return BadMatch; + } + + drawables = calloc(PanoramiXNumScreens, sizeof(DrawablePtr)); + if(!drawables) + return BadAlloc; + + drawables[0] = pDraw; + FOR_NSCREENS_FORWARD_SKIP(i) { + rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0, + DixReadAccess); + if (rc != Success) + { + free(drawables); + return rc; + } + } + + xgi.visual = wVisual(((WindowPtr)pDraw)); + xgi.type = X_Reply; + xgi.length = 0; + xgi.sequenceNumber = client->sequence; + xgi.depth = pDraw->depth; + + if(format == ZPixmap) { + widthBytesLine = PixmapBytePad(w, pDraw->depth); + length = widthBytesLine * h; + } else { + widthBytesLine = PixmapBytePad(w, 1); + lenPer = widthBytesLine * h; + plane = ((Mask)1) << (pDraw->depth - 1); + length = lenPer * Ones(planemask & (plane | (plane - 1))); + } + + VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client); + xgi.size = length; + + if (length == 0) {/* nothing to do */ } + else if (format == ZPixmap) { + XineramaGetImageData(drawables, x, y, w, h, format, planemask, + shmdesc->addr + stuff->offset, + widthBytesLine, isRoot); + } else { + + length = stuff->offset; + for (; plane; plane >>= 1) { + if (planemask & plane) { + XineramaGetImageData(drawables, x, y, w, h, + format, plane, shmdesc->addr + length, + widthBytesLine, isRoot); + length += lenPer; + } + } + } + free(drawables); + + if (client->swapped) { + int n; + swaps(&xgi.sequenceNumber, n); + swapl(&xgi.length, n); + swapl(&xgi.visual, n); + swapl(&xgi.size, n); + } + WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi); + + return Success; +} + +static int +ProcPanoramiXShmCreatePixmap(ClientPtr client) +{ + ScreenPtr pScreen = NULL; + PixmapPtr pMap = NULL; + DrawablePtr pDraw; + DepthPtr pDepth; + int i, j, result, rc; + ShmDescPtr shmdesc; + REQUEST(xShmCreatePixmapReq); + unsigned int width, height, depth; + unsigned long size; + PanoramiXRes *newPix; + + REQUEST_SIZE_MATCH(xShmCreatePixmapReq); + client->errorValue = stuff->pid; + if (!sharedPixmaps) + return BadImplementation; + LEGAL_NEW_RESOURCE(stuff->pid, client); + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, + DixGetAttrAccess); + if (rc != Success) + return rc; + + VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); + + width = stuff->width; + height = stuff->height; + depth = stuff->depth; + if (!width || !height || !depth) + { + client->errorValue = 0; + return BadValue; + } + if (width > 32767 || height > 32767) + return BadAlloc; + + if (stuff->depth != 1) + { + pDepth = pDraw->pScreen->allowedDepths; + for (i=0; ipScreen->numDepths; i++, pDepth++) + if (pDepth->depth == stuff->depth) + goto CreatePmap; + client->errorValue = stuff->depth; + return BadValue; + } + +CreatePmap: + size = PixmapBytePad(width, depth) * height; + if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) { + if (size < width * height) + return BadAlloc; + } + /* thankfully, offset is unsigned */ + if (stuff->offset + size < size) + return BadAlloc; + + VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); + + if(!(newPix = malloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newPix->type = XRT_PIXMAP; + newPix->u.pix.shared = TRUE; + panoramix_setup_ids(newPix, client, stuff->pid); + + result = Success; + + FOR_NSCREENS(j) { + ShmScrPrivateRec *screen_priv; + pScreen = screenInfo.screens[j]; + + screen_priv = ShmGetScreenPriv(pScreen); + pMap = (*screen_priv->shmFuncs->CreatePixmap)(pScreen, + stuff->width, stuff->height, stuff->depth, + shmdesc->addr + stuff->offset); + + if (pMap) { + dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc); + shmdesc->refcnt++; + pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; + pMap->drawable.id = newPix->info[j].id; + if (!AddResource(newPix->info[j].id, RT_PIXMAP, (pointer)pMap)) { + (*pScreen->DestroyPixmap)(pMap); + result = BadAlloc; + break; + } + } else { + result = BadAlloc; + break; + } + } + + if(result == BadAlloc) { + while(j--) { + (*pScreen->DestroyPixmap)(pMap); + FreeResource(newPix->info[j].id, RT_NONE); + } + free(newPix); + } else + AddResource(stuff->pid, XRT_PIXMAP, newPix); + + return result; +} +#endif + +static PixmapPtr +fbShmCreatePixmap (ScreenPtr pScreen, + int width, int height, int depth, char *addr) +{ + PixmapPtr pPixmap; + + pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth, 0); + if (!pPixmap) + return NullPixmap; + + if (!(*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth, + BitsPerPixel(depth), PixmapBytePad(width, depth), (pointer)addr)) { + (*pScreen->DestroyPixmap)(pPixmap); + return NullPixmap; + } + return pPixmap; +} + +static int +ProcShmCreatePixmap(ClientPtr client) +{ + PixmapPtr pMap; + DrawablePtr pDraw; + DepthPtr pDepth; + int i, rc; + ShmDescPtr shmdesc; + ShmScrPrivateRec *screen_priv; + REQUEST(xShmCreatePixmapReq); + unsigned int width, height, depth; + unsigned long size; + + REQUEST_SIZE_MATCH(xShmCreatePixmapReq); + client->errorValue = stuff->pid; + if (!sharedPixmaps) + return BadImplementation; + LEGAL_NEW_RESOURCE(stuff->pid, client); + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, + DixGetAttrAccess); + if (rc != Success) + return rc; + + VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); + + width = stuff->width; + height = stuff->height; + depth = stuff->depth; + if (!width || !height || !depth) + { + client->errorValue = 0; + return BadValue; + } + if (width > 32767 || height > 32767) + return BadAlloc; + + if (stuff->depth != 1) + { + pDepth = pDraw->pScreen->allowedDepths; + for (i=0; ipScreen->numDepths; i++, pDepth++) + if (pDepth->depth == stuff->depth) + goto CreatePmap; + client->errorValue = stuff->depth; + return BadValue; + } + +CreatePmap: + size = PixmapBytePad(width, depth) * height; + if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) { + if (size < width * height) + return BadAlloc; + } + /* thankfully, offset is unsigned */ + if (stuff->offset + size < size) + return BadAlloc; + + VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); + screen_priv = ShmGetScreenPriv(pDraw->pScreen); + pMap = (*screen_priv->shmFuncs->CreatePixmap)( + pDraw->pScreen, stuff->width, + stuff->height, stuff->depth, + shmdesc->addr + stuff->offset); + if (pMap) + { + rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP, + pMap, RT_NONE, NULL, DixCreateAccess); + if (rc != Success) { + pDraw->pScreen->DestroyPixmap(pMap); + return rc; + } + dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc); + shmdesc->refcnt++; + pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; + pMap->drawable.id = stuff->pid; + if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap)) + { + return Success; + } + pDraw->pScreen->DestroyPixmap(pMap); + } + return BadAlloc; +} + +static int +ProcShmDispatch (ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_ShmQueryVersion: + return ProcShmQueryVersion(client); + case X_ShmAttach: + return ProcShmAttach(client); + case X_ShmDetach: + return ProcShmDetach(client); + case X_ShmPutImage: +#ifdef PANORAMIX + if ( !noPanoramiXExtension ) + return ProcPanoramiXShmPutImage(client); +#endif + return ProcShmPutImage(client); + case X_ShmGetImage: +#ifdef PANORAMIX + if ( !noPanoramiXExtension ) + return ProcPanoramiXShmGetImage(client); +#endif + return ProcShmGetImage(client); + case X_ShmCreatePixmap: +#ifdef PANORAMIX + if ( !noPanoramiXExtension ) + return ProcPanoramiXShmCreatePixmap(client); +#endif + return ProcShmCreatePixmap(client); + default: + return BadRequest; + } +} + +static void +SShmCompletionEvent(xShmCompletionEvent *from, xShmCompletionEvent *to) +{ + to->type = from->type; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->drawable, to->drawable); + cpswaps(from->minorEvent, to->minorEvent); + to->majorEvent = from->majorEvent; + cpswapl(from->shmseg, to->shmseg); + cpswapl(from->offset, to->offset); +} + +static int +SProcShmQueryVersion(ClientPtr client) +{ + int n; + REQUEST(xShmQueryVersionReq); + + swaps(&stuff->length, n); + return ProcShmQueryVersion(client); +} + +static int +SProcShmAttach(ClientPtr client) +{ + int n; + REQUEST(xShmAttachReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xShmAttachReq); + swapl(&stuff->shmseg, n); + swapl(&stuff->shmid, n); + return ProcShmAttach(client); +} + +static int +SProcShmDetach(ClientPtr client) +{ + int n; + REQUEST(xShmDetachReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xShmDetachReq); + swapl(&stuff->shmseg, n); + return ProcShmDetach(client); +} + +static int +SProcShmPutImage(ClientPtr client) +{ + int n; + REQUEST(xShmPutImageReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xShmPutImageReq); + swapl(&stuff->drawable, n); + swapl(&stuff->gc, n); + swaps(&stuff->totalWidth, n); + swaps(&stuff->totalHeight, n); + swaps(&stuff->srcX, n); + swaps(&stuff->srcY, n); + swaps(&stuff->srcWidth, n); + swaps(&stuff->srcHeight, n); + swaps(&stuff->dstX, n); + swaps(&stuff->dstY, n); + swapl(&stuff->shmseg, n); + swapl(&stuff->offset, n); + return ProcShmPutImage(client); +} + +static int +SProcShmGetImage(ClientPtr client) +{ + int n; + REQUEST(xShmGetImageReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xShmGetImageReq); + swapl(&stuff->drawable, n); + swaps(&stuff->x, n); + swaps(&stuff->y, n); + swaps(&stuff->width, n); + swaps(&stuff->height, n); + swapl(&stuff->planeMask, n); + swapl(&stuff->shmseg, n); + swapl(&stuff->offset, n); + return ProcShmGetImage(client); +} + +static int +SProcShmCreatePixmap(ClientPtr client) +{ + int n; + REQUEST(xShmCreatePixmapReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xShmCreatePixmapReq); + swapl(&stuff->pid, n); + swapl(&stuff->drawable, n); + swaps(&stuff->width, n); + swaps(&stuff->height, n); + swapl(&stuff->shmseg, n); + swapl(&stuff->offset, n); + return ProcShmCreatePixmap(client); +} + +static int +SProcShmDispatch (ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_ShmQueryVersion: + return SProcShmQueryVersion(client); + case X_ShmAttach: + return SProcShmAttach(client); + case X_ShmDetach: + return SProcShmDetach(client); + case X_ShmPutImage: + return SProcShmPutImage(client); + case X_ShmGetImage: + return SProcShmGetImage(client); + case X_ShmCreatePixmap: + return SProcShmCreatePixmap(client); + default: + return BadRequest; + } +} + +void +ShmExtensionInit(INITARGS) +{ + ExtensionEntry *extEntry; + int i; + +#ifdef MUST_CHECK_FOR_SHM_SYSCALL + if (!CheckForShmSyscall()) + { + ErrorF("MIT-SHM extension disabled due to lack of kernel support\n"); + return; + } +#endif + + if (!ShmRegisterPrivates()) + return; + + sharedPixmaps = xFalse; + { + sharedPixmaps = xTrue; + for (i = 0; i < screenInfo.numScreens; i++) + { + ShmScrPrivateRec *screen_priv = ShmInitScreenPriv(screenInfo.screens[i]); + if (!screen_priv->shmFuncs) + screen_priv->shmFuncs = &miFuncs; + if (!screen_priv->shmFuncs->CreatePixmap) + sharedPixmaps = xFalse; + } + if (sharedPixmaps) + for (i = 0; i < screenInfo.numScreens; i++) + { + ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(screenInfo.screens[i]); + screen_priv->destroyPixmap = screenInfo.screens[i]->DestroyPixmap; + screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap; + } + } + ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg"); + if (ShmSegType && + (extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors, + ProcShmDispatch, SProcShmDispatch, + ShmResetProc, StandardMinorOpcode))) + { + ShmReqCode = (unsigned char)extEntry->base; + ShmCompletionCode = extEntry->eventBase; + BadShmSegCode = extEntry->errorBase; + SetResourceTypeErrorValue(ShmSegType, BadShmSegCode); + EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent; + } +} diff --git a/xorg-server/Xext/xvdisp.c b/xorg-server/Xext/xvdisp.c index e723fd84b..b96843159 100644 --- a/xorg-server/Xext/xvdisp.c +++ b/xorg-server/Xext/xvdisp.c @@ -1,1961 +1,1961 @@ -/*********************************************************** -Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts, -and the Massachusetts Institute of Technology, Cambridge, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Digital or MIT not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. -******************************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include - -#include -#include -#include "misc.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "gcstruct.h" -#include "dixstruct.h" -#include "resource.h" -#include "opaque.h" - -#include -#include -#include "xvdix.h" -#ifdef MITSHM -#include -#endif - -#include "xvdisp.h" - -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" - -unsigned long XvXRTPort; -#endif - -static int -SWriteQueryExtensionReply( - ClientPtr client, - xvQueryExtensionReply *rep -){ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->version, n); - swaps(&rep->revision, n); - - (void)WriteToClient(client, sz_xvQueryExtensionReply, (char *)rep); - - return Success; -} - -static int -SWriteQueryAdaptorsReply( - ClientPtr client, - xvQueryAdaptorsReply *rep -){ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->num_adaptors, n); - - (void)WriteToClient(client, sz_xvQueryAdaptorsReply, (char *)rep); - - return Success; -} - -static int -SWriteQueryEncodingsReply( - ClientPtr client, - xvQueryEncodingsReply *rep -){ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->num_encodings, n); - - (void)WriteToClient(client, sz_xvQueryEncodingsReply, (char *)rep); - - return Success; -} - -static int -SWriteAdaptorInfo( - ClientPtr client, - xvAdaptorInfo *pAdaptor -){ - char n; - - swapl(&pAdaptor->base_id, n); - swaps(&pAdaptor->name_size, n); - swaps(&pAdaptor->num_ports, n); - swaps(&pAdaptor->num_formats, n); - - (void)WriteToClient(client, sz_xvAdaptorInfo, (char *)pAdaptor); - - return Success; -} - -static int -SWriteEncodingInfo( - ClientPtr client, - xvEncodingInfo *pEncoding -){ - char n; - - swapl(&pEncoding->encoding, n); - swaps(&pEncoding->name_size, n); - swaps(&pEncoding->width, n); - swaps(&pEncoding->height, n); - swapl(&pEncoding->rate.numerator, n); - swapl(&pEncoding->rate.denominator, n); - (void)WriteToClient(client, sz_xvEncodingInfo, (char *)pEncoding); - - return Success; -} - -static int -SWriteFormat( - ClientPtr client, - xvFormat *pFormat -){ - char n; - - swapl(&pFormat->visual, n); - (void)WriteToClient(client, sz_xvFormat, (char *)pFormat); - - return Success; -} - -static int -SWriteAttributeInfo( - ClientPtr client, - xvAttributeInfo *pAtt -){ - char n; - - swapl(&pAtt->flags, n); - swapl(&pAtt->size, n); - swapl(&pAtt->min, n); - swapl(&pAtt->max, n); - (void)WriteToClient(client, sz_xvAttributeInfo, (char *)pAtt); - - return Success; -} - -static int -SWriteImageFormatInfo( - ClientPtr client, - xvImageFormatInfo *pImage -){ - char n; - - swapl(&pImage->id, n); - swapl(&pImage->red_mask, n); - swapl(&pImage->green_mask, n); - swapl(&pImage->blue_mask, n); - swapl(&pImage->y_sample_bits, n); - swapl(&pImage->u_sample_bits, n); - swapl(&pImage->v_sample_bits, n); - swapl(&pImage->horz_y_period, n); - swapl(&pImage->horz_u_period, n); - swapl(&pImage->horz_v_period, n); - swapl(&pImage->vert_y_period, n); - swapl(&pImage->vert_u_period, n); - swapl(&pImage->vert_v_period, n); - - (void)WriteToClient(client, sz_xvImageFormatInfo, (char *)pImage); - - return Success; -} - -static int -SWriteGrabPortReply( - ClientPtr client, - xvGrabPortReply *rep -){ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - - (void)WriteToClient(client, sz_xvGrabPortReply, (char *)rep); - - return Success; -} - -static int -SWriteGetPortAttributeReply( - ClientPtr client, - xvGetPortAttributeReply *rep -){ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->value, n); - - (void)WriteToClient(client, sz_xvGetPortAttributeReply, (char *)rep); - - return Success; -} - -static int -SWriteQueryBestSizeReply( - ClientPtr client, - xvQueryBestSizeReply *rep -){ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->actual_width, n); - swaps(&rep->actual_height, n); - - (void)WriteToClient(client, sz_xvQueryBestSizeReply, (char *)rep); - - return Success; -} - -static int -SWriteQueryPortAttributesReply( - ClientPtr client, - xvQueryPortAttributesReply *rep -){ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->num_attributes, n); - swapl(&rep->text_size, n); - - (void)WriteToClient(client, sz_xvQueryPortAttributesReply, (char *)rep); - - return Success; -} - -static int -SWriteQueryImageAttributesReply( - ClientPtr client, - xvQueryImageAttributesReply *rep -){ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->num_planes, n); - swapl(&rep->data_size, n); - swaps(&rep->width, n); - swaps(&rep->height, n); - - (void)WriteToClient(client, sz_xvQueryImageAttributesReply, (char *)rep); - - return Success; -} - -static int -SWriteListImageFormatsReply( - ClientPtr client, - xvListImageFormatsReply *rep -){ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->num_formats, n); - - (void)WriteToClient(client, sz_xvListImageFormatsReply, (char *)rep); - - return Success; -} - -#define _WriteQueryAdaptorsReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryAdaptorsReply, (char*)_d) - -#define _WriteQueryExtensionReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryExtensionReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryExtensionReply, (char*)_d) - -#define _WriteQueryEncodingsReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryEncodingsReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryEncodingsReply, (char*)_d) - -#define _WriteAdaptorInfo(_c,_d) \ - if ((_c)->swapped) SWriteAdaptorInfo(_c, _d); \ - else WriteToClient(_c, sz_xvAdaptorInfo, (char*)_d) - -#define _WriteAttributeInfo(_c,_d) \ - if ((_c)->swapped) SWriteAttributeInfo(_c, _d); \ - else WriteToClient(_c, sz_xvAttributeInfo, (char*)_d) - -#define _WriteEncodingInfo(_c,_d) \ - if ((_c)->swapped) SWriteEncodingInfo(_c, _d); \ - else WriteToClient(_c, sz_xvEncodingInfo, (char*)_d) - -#define _WriteFormat(_c,_d) \ - if ((_c)->swapped) SWriteFormat(_c, _d); \ - else WriteToClient(_c, sz_xvFormat, (char*)_d) - -#define _WriteGrabPortReply(_c,_d) \ - if ((_c)->swapped) SWriteGrabPortReply(_c, _d); \ - else WriteToClient(_c, sz_xvGrabPortReply, (char*)_d) - -#define _WriteGetPortAttributeReply(_c,_d) \ - if ((_c)->swapped) SWriteGetPortAttributeReply(_c, _d); \ - else WriteToClient(_c, sz_xvGetPortAttributeReply, (char*)_d) - -#define _WriteQueryBestSizeReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryBestSizeReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryBestSizeReply,(char*) _d) - -#define _WriteQueryPortAttributesReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryPortAttributesReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryPortAttributesReply,(char*) _d) - -#define _WriteQueryImageAttributesReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryImageAttributesReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryImageAttributesReply,(char*) _d) - -#define _WriteListImageFormatsReply(_c,_d) \ - if ((_c)->swapped) SWriteListImageFormatsReply(_c, _d); \ - else WriteToClient(_c, sz_xvListImageFormatsReply,(char*) _d) - -#define _WriteImageFormatInfo(_c,_d) \ - if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \ - else WriteToClient(_c, sz_xvImageFormatInfo, (char*)_d) - -#define _AllocatePort(_i,_p) \ - ((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success - -static int -ProcXvQueryExtension(ClientPtr client) -{ - xvQueryExtensionReply rep; - /* REQUEST(xvQueryExtensionReq); */ - REQUEST_SIZE_MATCH(xvQueryExtensionReq); - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.version = XvVersion; - rep.revision = XvRevision; - - _WriteQueryExtensionReply(client, &rep); - - return Success; -} - -static int -ProcXvQueryAdaptors(ClientPtr client) -{ - xvFormat format; - xvAdaptorInfo ainfo; - xvQueryAdaptorsReply rep; - int totalSize, na, nf, rc; - int nameSize; - XvAdaptorPtr pa; - XvFormatPtr pf; - WindowPtr pWin; - ScreenPtr pScreen; - XvScreenPtr pxvs; - - REQUEST(xvQueryAdaptorsReq); - REQUEST_SIZE_MATCH(xvQueryAdaptorsReq); - - rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); - if (rc != Success) - return rc; - - pScreen = pWin->drawable.pScreen; - pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, - XvGetScreenKey()); - if (!pxvs) - { - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_adaptors = 0; - rep.length = 0; - - _WriteQueryAdaptorsReply(client, &rep); - - return Success; - } - - (* pxvs->ddQueryAdaptors)(pScreen, &pxvs->pAdaptors, &pxvs->nAdaptors); - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_adaptors = pxvs->nAdaptors; - - /* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */ - - totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo; - - /* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */ - - na = pxvs->nAdaptors; - pa = pxvs->pAdaptors; - while (na--) - { - totalSize += pad_to_int32(strlen(pa->name)); - totalSize += pa->nFormats * sz_xvFormat; - pa++; - } - - rep.length = bytes_to_int32(totalSize); - - _WriteQueryAdaptorsReply(client, &rep); - - na = pxvs->nAdaptors; - pa = pxvs->pAdaptors; - while (na--) - { - - ainfo.base_id = pa->base_id; - ainfo.num_ports = pa->nPorts; - ainfo.type = pa->type; - ainfo.name_size = nameSize = strlen(pa->name); - ainfo.num_formats = pa->nFormats; - - _WriteAdaptorInfo(client, &ainfo); - - WriteToClient(client, nameSize, pa->name); - - nf = pa->nFormats; - pf = pa->pFormats; - while (nf--) - { - format.depth = pf->depth; - format.visual = pf->visual; - _WriteFormat(client, &format); - pf++; - } - - pa++; - - } - - return Success; -} - -static int -ProcXvQueryEncodings(ClientPtr client) -{ - xvEncodingInfo einfo; - xvQueryEncodingsReply rep; - int totalSize; - int nameSize; - XvPortPtr pPort; - int ne; - XvEncodingPtr pe; - int status; - - REQUEST(xvQueryEncodingsReq); - REQUEST_SIZE_MATCH(xvQueryEncodingsReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_encodings = pPort->pAdaptor->nEncodings; - - /* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */ - - ne = pPort->pAdaptor->nEncodings; - pe = pPort->pAdaptor->pEncodings; - totalSize = ne * sz_xvEncodingInfo; - while (ne--) - { - totalSize += pad_to_int32(strlen(pe->name)); - pe++; - } - - rep.length = bytes_to_int32(totalSize); - - _WriteQueryEncodingsReply(client, &rep); - - ne = pPort->pAdaptor->nEncodings; - pe = pPort->pAdaptor->pEncodings; - while (ne--) - { - einfo.encoding = pe->id; - einfo.name_size = nameSize = strlen(pe->name); - einfo.width = pe->width; - einfo.height = pe->height; - einfo.rate.numerator = pe->rate.numerator; - einfo.rate.denominator = pe->rate.denominator; - _WriteEncodingInfo(client, &einfo); - WriteToClient(client, nameSize, pe->name); - pe++; - } - - return Success; -} - -static int -ProcXvPutVideo(ClientPtr client) -{ - DrawablePtr pDraw; - XvPortPtr pPort; - GCPtr pGC; - int status; - - REQUEST(xvPutVideoReq); - REQUEST_SIZE_MATCH(xvPutVideoReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - if (!(pPort->pAdaptor->type & XvInputMask) || - !(pPort->pAdaptor->type & XvVideoMask)) - { - client->errorValue = stuff->port; - return BadMatch; - } - - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; - } - - return XvdiPutVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); -} - -static int -ProcXvPutStill(ClientPtr client) -{ - DrawablePtr pDraw; - XvPortPtr pPort; - GCPtr pGC; - int status; - - REQUEST(xvPutStillReq); - REQUEST_SIZE_MATCH(xvPutStillReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - if (!(pPort->pAdaptor->type & XvInputMask) || - !(pPort->pAdaptor->type & XvStillMask)) - { - client->errorValue = stuff->port; - return BadMatch; - } - - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; - } - - return XvdiPutStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); -} - -static int -ProcXvGetVideo(ClientPtr client) -{ - DrawablePtr pDraw; - XvPortPtr pPort; - GCPtr pGC; - int status; - - REQUEST(xvGetVideoReq); - REQUEST_SIZE_MATCH(xvGetVideoReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - if (!(pPort->pAdaptor->type & XvOutputMask) || - !(pPort->pAdaptor->type & XvVideoMask)) - { - client->errorValue = stuff->port; - return BadMatch; - } - - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; - } - - return XvdiGetVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); -} - -static int -ProcXvGetStill(ClientPtr client) -{ - DrawablePtr pDraw; - XvPortPtr pPort; - GCPtr pGC; - int status; - - REQUEST(xvGetStillReq); - REQUEST_SIZE_MATCH(xvGetStillReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - if (!(pPort->pAdaptor->type & XvOutputMask) || - !(pPort->pAdaptor->type & XvStillMask)) - { - client->errorValue = stuff->port; - return BadMatch; - } - - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; - } - - return XvdiGetStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); -} - -static int -ProcXvSelectVideoNotify(ClientPtr client) -{ - DrawablePtr pDraw; - int rc; - REQUEST(xvSelectVideoNotifyReq); - REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq); - - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReceiveAccess); - if (rc != Success) - return rc; - - return XvdiSelectVideoNotify(client, pDraw, stuff->onoff); -} - -static int -ProcXvSelectPortNotify(ClientPtr client) -{ - int status; - XvPortPtr pPort; - REQUEST(xvSelectPortNotifyReq); - REQUEST_SIZE_MATCH(xvSelectPortNotifyReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - return XvdiSelectPortNotify(client, pPort, stuff->onoff); -} - -static int -ProcXvGrabPort(ClientPtr client) -{ - int result, status; - XvPortPtr pPort; - xvGrabPortReply rep; - REQUEST(xvGrabPortReq); - REQUEST_SIZE_MATCH(xvGrabPortReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - status = XvdiGrabPort(client, pPort, stuff->time, &result); - - if (status != Success) - { - return status; - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.result = result; - - _WriteGrabPortReply(client, &rep); - - return Success; -} - -static int -ProcXvUngrabPort(ClientPtr client) -{ - int status; - XvPortPtr pPort; - REQUEST(xvGrabPortReq); - REQUEST_SIZE_MATCH(xvGrabPortReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - return XvdiUngrabPort(client, pPort, stuff->time); -} - -static int -ProcXvStopVideo(ClientPtr client) -{ - int status, rc; - DrawablePtr pDraw; - XvPortPtr pPort; - REQUEST(xvStopVideoReq); - REQUEST_SIZE_MATCH(xvStopVideoReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess); - if (rc != Success) - return rc; - - return XvdiStopVideo(client, pPort, pDraw); -} - -static int -ProcXvSetPortAttribute(ClientPtr client) -{ - int status; - XvPortPtr pPort; - REQUEST(xvSetPortAttributeReq); - REQUEST_SIZE_MATCH(xvSetPortAttributeReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixSetAttrAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - if (!ValidAtom(stuff->attribute)) - { - client->errorValue = stuff->attribute; - return BadAtom; - } - - status = XvdiSetPortAttribute(client, pPort, stuff->attribute, stuff->value); - - if (status == BadMatch) - client->errorValue = stuff->attribute; - else - client->errorValue = stuff->value; - - return status; -} - -static int -ProcXvGetPortAttribute(ClientPtr client) -{ - INT32 value; - int status; - XvPortPtr pPort; - xvGetPortAttributeReply rep; - REQUEST(xvGetPortAttributeReq); - REQUEST_SIZE_MATCH(xvGetPortAttributeReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - if (!ValidAtom(stuff->attribute)) - { - client->errorValue = stuff->attribute; - return BadAtom; - } - - status = XvdiGetPortAttribute(client, pPort, stuff->attribute, &value); - if (status != Success) - { - client->errorValue = stuff->attribute; - return status; - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.value = value; - - _WriteGetPortAttributeReply(client, &rep); - - return Success; -} - -static int -ProcXvQueryBestSize(ClientPtr client) -{ - int status; - unsigned int actual_width, actual_height; - XvPortPtr pPort; - xvQueryBestSizeReply rep; - REQUEST(xvQueryBestSizeReq); - REQUEST_SIZE_MATCH(xvQueryBestSizeReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - - (* pPort->pAdaptor->ddQueryBestSize)(client, pPort, stuff->motion, - stuff->vid_w, stuff->vid_h, - stuff->drw_w, stuff->drw_h, - &actual_width, &actual_height); - - rep.actual_width = actual_width; - rep.actual_height = actual_height; - - _WriteQueryBestSizeReply(client, &rep); - - return Success; -} - - -static int -ProcXvQueryPortAttributes(ClientPtr client) -{ - int status, size, i; - XvPortPtr pPort; - XvAttributePtr pAtt; - xvQueryPortAttributesReply rep; - xvAttributeInfo Info; - REQUEST(xvQueryPortAttributesReq); - REQUEST_SIZE_MATCH(xvQueryPortAttributesReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_attributes = pPort->pAdaptor->nAttributes; - rep.text_size = 0; - - for(i = 0, pAtt = pPort->pAdaptor->pAttributes; - i < pPort->pAdaptor->nAttributes; i++, pAtt++) - { - rep.text_size += pad_to_int32(strlen(pAtt->name) + 1); - } - - rep.length = (pPort->pAdaptor->nAttributes * sz_xvAttributeInfo) - + rep.text_size; - rep.length >>= 2; - - _WriteQueryPortAttributesReply(client, &rep); - - for(i = 0, pAtt = pPort->pAdaptor->pAttributes; - i < pPort->pAdaptor->nAttributes; i++, pAtt++) - { - size = strlen(pAtt->name) + 1; /* pass the NULL */ - Info.flags = pAtt->flags; - Info.min = pAtt->min_value; - Info.max = pAtt->max_value; - Info.size = pad_to_int32(size); - - _WriteAttributeInfo(client, &Info); - - WriteToClient(client, size, pAtt->name); - } - - return Success; -} - -static int -ProcXvPutImage(ClientPtr client) -{ - DrawablePtr pDraw; - XvPortPtr pPort; - XvImagePtr pImage = NULL; - GCPtr pGC; - int status, i, size; - CARD16 width, height; - - REQUEST(xvPutImageReq); - REQUEST_AT_LEAST_SIZE(xvPutImageReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - if (!(pPort->pAdaptor->type & XvImageMask) || - !(pPort->pAdaptor->type & XvInputMask)) - { - client->errorValue = stuff->port; - return BadMatch; - } - - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; - } - - for(i = 0; i < pPort->pAdaptor->nImages; i++) { - if(pPort->pAdaptor->pImages[i].id == stuff->id) { - pImage = &(pPort->pAdaptor->pImages[i]); - break; - } - } - - if(!pImage) - return BadMatch; - - width = stuff->width; - height = stuff->height; - size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, - pPort, pImage, &width, &height, NULL, NULL); - size += sizeof(xvPutImageReq); - size = bytes_to_int32(size); - - if((width < stuff->width) || (height < stuff->height)) - return BadValue; - - if(client->req_len < size) - return BadLength; - - return XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y, - stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h, pImage, - (unsigned char*)(&stuff[1]), FALSE, - stuff->width, stuff->height); -} - -#ifdef MITSHM -/* redefined here since it's not in any header file */ -typedef struct _ShmDesc { - struct _ShmDesc *next; - int shmid; - int refcnt; - char *addr; - Bool writable; - unsigned long size; -} ShmDescRec, *ShmDescPtr; - -extern RESTYPE ShmSegType; -extern int ShmCompletionCode; - -static int -ProcXvShmPutImage(ClientPtr client) -{ - ShmDescPtr shmdesc; - DrawablePtr pDraw; - XvPortPtr pPort; - XvImagePtr pImage = NULL; - GCPtr pGC; - int status, size_needed, i; - CARD16 width, height; - - REQUEST(xvShmPutImageReq); - REQUEST_SIZE_MATCH(xvShmPutImageReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; - } - - if (!(pPort->pAdaptor->type & XvImageMask) || - !(pPort->pAdaptor->type & XvInputMask)) - { - client->errorValue = stuff->port; - return BadMatch; - } - - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; - } - - for(i = 0; i < pPort->pAdaptor->nImages; i++) { - if(pPort->pAdaptor->pImages[i].id == stuff->id) { - pImage = &(pPort->pAdaptor->pImages[i]); - break; - } - } - - if(!pImage) - return BadMatch; - - status = dixLookupResourceByType((pointer *)&shmdesc, stuff->shmseg, - ShmSegType, serverClient, DixReadAccess); - if (status != Success) - return status; - - width = stuff->width; - height = stuff->height; - size_needed = (*pPort->pAdaptor->ddQueryImageAttributes)(client, - pPort, pImage, &width, &height, NULL, NULL); - if((size_needed + stuff->offset) > shmdesc->size) - return BadAccess; - - if((width < stuff->width) || (height < stuff->height)) - return BadValue; - - status = XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y, - stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h, pImage, - (unsigned char *)shmdesc->addr + stuff->offset, - stuff->send_event, stuff->width, stuff->height); - - if((status == Success) && stuff->send_event) { - xShmCompletionEvent ev; - - ev.type = ShmCompletionCode; - ev.drawable = stuff->drawable; - ev.minorEvent = xv_ShmPutImage; - ev.majorEvent = XvReqCode; - ev.shmseg = stuff->shmseg; - ev.offset = stuff->offset; - WriteEventsToClient(client, 1, (xEvent *) &ev); - } - - return status; -} -#else /* !MITSHM */ -static int -ProcXvShmPutImage(ClientPtr client) -{ - SendErrorToClient(client, XvReqCode, xv_ShmPutImage, 0, BadImplementation); - return BadImplementation; -} -#endif - -#ifdef XvMCExtension -#include "xvmcext.h" -#endif - -static int -ProcXvQueryImageAttributes(ClientPtr client) -{ - xvQueryImageAttributesReply rep; - int size, num_planes, i; - CARD16 width, height; - XvImagePtr pImage = NULL; - XvPortPtr pPort; - int *offsets; - int *pitches; - int planeLength; - REQUEST(xvQueryImageAttributesReq); - - REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - for(i = 0; i < pPort->pAdaptor->nImages; i++) { - if(pPort->pAdaptor->pImages[i].id == stuff->id) { - pImage = &(pPort->pAdaptor->pImages[i]); - break; - } - } - -#ifdef XvMCExtension - if(!pImage) - pImage = XvMCFindXvImage(pPort, stuff->id); -#endif - - if(!pImage) - return BadMatch; - - num_planes = pImage->num_planes; - - if(!(offsets = malloc(num_planes << 3))) - return BadAlloc; - pitches = offsets + num_planes; - - width = stuff->width; - height = stuff->height; - - size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, pPort, pImage, - &width, &height, offsets, pitches); - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = planeLength = num_planes << 1; - rep.num_planes = num_planes; - rep.width = width; - rep.height = height; - rep.data_size = size; - - _WriteQueryImageAttributesReply(client, &rep); - if(client->swapped) - SwapLongs((CARD32*)offsets, planeLength); - WriteToClient(client, planeLength << 2, (char*)offsets); - - free(offsets); - - return Success; -} - -static int -ProcXvListImageFormats(ClientPtr client) -{ - XvPortPtr pPort; - XvImagePtr pImage; - int i; - xvListImageFormatsReply rep; - xvImageFormatInfo info; - REQUEST(xvListImageFormatsReq); - - REQUEST_SIZE_MATCH(xvListImageFormatsReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_formats = pPort->pAdaptor->nImages; - rep.length = bytes_to_int32(pPort->pAdaptor->nImages * sz_xvImageFormatInfo); - - _WriteListImageFormatsReply(client, &rep); - - pImage = pPort->pAdaptor->pImages; - - for(i = 0; i < pPort->pAdaptor->nImages; i++, pImage++) { - info.id = pImage->id; - info.type = pImage->type; - info.byte_order = pImage->byte_order; - memcpy(&info.guid, pImage->guid, 16); - info.bpp = pImage->bits_per_pixel; - info.num_planes = pImage->num_planes; - info.depth = pImage->depth; - info.red_mask = pImage->red_mask; - info.green_mask = pImage->green_mask; - info.blue_mask = pImage->blue_mask; - info.format = pImage->format; - info.y_sample_bits = pImage->y_sample_bits; - info.u_sample_bits = pImage->u_sample_bits; - info.v_sample_bits = pImage->v_sample_bits; - info.horz_y_period = pImage->horz_y_period; - info.horz_u_period = pImage->horz_u_period; - info.horz_v_period = pImage->horz_v_period; - info.vert_y_period = pImage->vert_y_period; - info.vert_u_period = pImage->vert_u_period; - info.vert_v_period = pImage->vert_v_period; - memcpy(&info.comp_order, pImage->component_order, 32); - info.scanline_order = pImage->scanline_order; - _WriteImageFormatInfo(client, &info); - } - - return Success; -} - -static int (*XvProcVector[xvNumRequests])(ClientPtr) = { - ProcXvQueryExtension, - ProcXvQueryAdaptors, - ProcXvQueryEncodings, - ProcXvGrabPort, - ProcXvUngrabPort, - ProcXvPutVideo, - ProcXvPutStill, - ProcXvGetVideo, - ProcXvGetStill, - ProcXvStopVideo, - ProcXvSelectVideoNotify, - ProcXvSelectPortNotify, - ProcXvQueryBestSize, - ProcXvSetPortAttribute, - ProcXvGetPortAttribute, - ProcXvQueryPortAttributes, - ProcXvListImageFormats, - ProcXvQueryImageAttributes, - ProcXvPutImage, - ProcXvShmPutImage, -}; - -int -ProcXvDispatch(ClientPtr client) -{ - REQUEST(xReq); - - UpdateCurrentTime(); - - if (stuff->data > xvNumRequests) { - SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); - return BadRequest; - } - - return XvProcVector[stuff->data](client); -} - -/* Swapped Procs */ - -static int -SProcXvQueryExtension(ClientPtr client) -{ - char n; - REQUEST(xvQueryExtensionReq); - swaps(&stuff->length, n); - return XvProcVector[xv_QueryExtension](client); -} - -static int -SProcXvQueryAdaptors(ClientPtr client) -{ - char n; - REQUEST(xvQueryAdaptorsReq); - swaps(&stuff->length, n); - swapl(&stuff->window, n); - return XvProcVector[xv_QueryAdaptors](client); -} - -static int -SProcXvQueryEncodings(ClientPtr client) -{ - char n; - REQUEST(xvQueryEncodingsReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - return XvProcVector[xv_QueryEncodings](client); -} - -static int -SProcXvGrabPort(ClientPtr client) -{ - char n; - REQUEST(xvGrabPortReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->time, n); - return XvProcVector[xv_GrabPort](client); -} - -static int -SProcXvUngrabPort(ClientPtr client) -{ - char n; - REQUEST(xvUngrabPortReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->time, n); - return XvProcVector[xv_UngrabPort](client); -} - -static int -SProcXvPutVideo(ClientPtr client) -{ - char n; - REQUEST(xvPutVideoReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->vid_x, n); - swaps(&stuff->vid_y, n); - swaps(&stuff->vid_w, n); - swaps(&stuff->vid_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - return XvProcVector[xv_PutVideo](client); -} - -static int -SProcXvPutStill(ClientPtr client) -{ - char n; - REQUEST(xvPutStillReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->vid_x, n); - swaps(&stuff->vid_y, n); - swaps(&stuff->vid_w, n); - swaps(&stuff->vid_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - return XvProcVector[xv_PutStill](client); -} - -static int -SProcXvGetVideo(ClientPtr client) -{ - char n; - REQUEST(xvGetVideoReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->vid_x, n); - swaps(&stuff->vid_y, n); - swaps(&stuff->vid_w, n); - swaps(&stuff->vid_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - return XvProcVector[xv_GetVideo](client); -} - -static int -SProcXvGetStill(ClientPtr client) -{ - char n; - REQUEST(xvGetStillReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->vid_x, n); - swaps(&stuff->vid_y, n); - swaps(&stuff->vid_w, n); - swaps(&stuff->vid_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - return XvProcVector[xv_GetStill](client); -} - -static int -SProcXvPutImage(ClientPtr client) -{ - char n; - REQUEST(xvPutImageReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swapl(&stuff->id, n); - swaps(&stuff->src_x, n); - swaps(&stuff->src_y, n); - swaps(&stuff->src_w, n); - swaps(&stuff->src_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return XvProcVector[xv_PutImage](client); -} - -#ifdef MITSHM -static int -SProcXvShmPutImage(ClientPtr client) -{ - char n; - REQUEST(xvShmPutImageReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swapl(&stuff->shmseg, n); - swapl(&stuff->id, n); - swapl(&stuff->offset, n); - swaps(&stuff->src_x, n); - swaps(&stuff->src_y, n); - swaps(&stuff->src_w, n); - swaps(&stuff->src_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return XvProcVector[xv_ShmPutImage](client); -} -#else /* MITSHM */ -#define SProcXvShmPutImage ProcXvShmPutImage -#endif - -static int -SProcXvSelectVideoNotify(ClientPtr client) -{ - char n; - REQUEST(xvSelectVideoNotifyReq); - swaps(&stuff->length, n); - swapl(&stuff->drawable, n); - return XvProcVector[xv_SelectVideoNotify](client); -} - -static int -SProcXvSelectPortNotify(ClientPtr client) -{ - char n; - REQUEST(xvSelectPortNotifyReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - return XvProcVector[xv_SelectPortNotify](client); -} - -static int -SProcXvStopVideo(ClientPtr client) -{ - char n; - REQUEST(xvStopVideoReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - return XvProcVector[xv_StopVideo](client); -} - -static int -SProcXvSetPortAttribute(ClientPtr client) -{ - char n; - REQUEST(xvSetPortAttributeReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->attribute, n); - swapl(&stuff->value, n); - return XvProcVector[xv_SetPortAttribute](client); -} - -static int -SProcXvGetPortAttribute(ClientPtr client) -{ - char n; - REQUEST(xvGetPortAttributeReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->attribute, n); - return XvProcVector[xv_GetPortAttribute](client); -} - -static int -SProcXvQueryBestSize(ClientPtr client) -{ - char n; - REQUEST(xvQueryBestSizeReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swaps(&stuff->vid_w, n); - swaps(&stuff->vid_h, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - return XvProcVector[xv_QueryBestSize](client); -} - -static int -SProcXvQueryPortAttributes(ClientPtr client) -{ - char n; - REQUEST(xvQueryPortAttributesReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - return XvProcVector[xv_QueryPortAttributes](client); -} - -static int -SProcXvQueryImageAttributes(ClientPtr client) -{ - char n; - REQUEST(xvQueryImageAttributesReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->id, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return XvProcVector[xv_QueryImageAttributes](client); -} - -static int -SProcXvListImageFormats(ClientPtr client) -{ - char n; - REQUEST(xvListImageFormatsReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - return XvProcVector[xv_ListImageFormats](client); -} - -static int (*SXvProcVector[xvNumRequests])(ClientPtr) = { - SProcXvQueryExtension, - SProcXvQueryAdaptors, - SProcXvQueryEncodings, - SProcXvGrabPort, - SProcXvUngrabPort, - SProcXvPutVideo, - SProcXvPutStill, - SProcXvGetVideo, - SProcXvGetStill, - SProcXvStopVideo, - SProcXvSelectVideoNotify, - SProcXvSelectPortNotify, - SProcXvQueryBestSize, - SProcXvSetPortAttribute, - SProcXvGetPortAttribute, - SProcXvQueryPortAttributes, - SProcXvListImageFormats, - SProcXvQueryImageAttributes, - SProcXvPutImage, - SProcXvShmPutImage, -}; - -int -SProcXvDispatch(ClientPtr client) -{ - REQUEST(xReq); - - UpdateCurrentTime(); - - if (stuff->data > xvNumRequests) { - SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); - return BadRequest; - } - - return SXvProcVector[stuff->data](client); -} - -#ifdef PANORAMIX -static int -XineramaXvStopVideo(ClientPtr client) -{ - int result, i; - PanoramiXRes *draw, *port; - REQUEST(xvStopVideoReq); - REQUEST_SIZE_MATCH(xvStopVideoReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - result = ProcXvStopVideo(client); - } - } - - return result; -} - -static int -XineramaXvSetPortAttribute(ClientPtr client) -{ - REQUEST(xvSetPortAttributeReq); - PanoramiXRes *port; - int result, i; - - REQUEST_SIZE_MATCH(xvSetPortAttributeReq); - - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); - if (result != Success) - return result; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->port = port->info[i].id; - result = ProcXvSetPortAttribute(client); - } - } - return result; -} - -#ifdef MITSHM -static int -XineramaXvShmPutImage(ClientPtr client) -{ - REQUEST(xvShmPutImageReq); - PanoramiXRes *draw, *gc, *port; - Bool send_event = stuff->send_event; - Bool isRoot; - int result, i, x, y; - - REQUEST_SIZE_MATCH(xvShmPutImageReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, - XRT_GC, client, DixReadAccess); - if (result != Success) - return result; - - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - x = stuff->drw_x; - y = stuff->drw_y; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { - stuff->drw_x -= screenInfo.screens[i]->x; - stuff->drw_y -= screenInfo.screens[i]->y; - } - stuff->send_event = (send_event && !i) ? 1 : 0; - - result = ProcXvShmPutImage(client); - } - } - return result; -} -#else -#define XineramaXvShmPutImage ProcXvShmPutImage -#endif - -static int -XineramaXvPutImage(ClientPtr client) -{ - REQUEST(xvPutImageReq); - PanoramiXRes *draw, *gc, *port; - Bool isRoot; - int result, i, x, y; - - REQUEST_AT_LEAST_SIZE(xvPutImageReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, - XRT_GC, client, DixReadAccess); - if (result != Success) - return result; - - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - x = stuff->drw_x; - y = stuff->drw_y; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { - stuff->drw_x -= screenInfo.screens[i]->x; - stuff->drw_y -= screenInfo.screens[i]->y; - } - - result = ProcXvPutImage(client); - } - } - return result; -} - -static int -XineramaXvPutVideo(ClientPtr client) -{ - REQUEST(xvPutImageReq); - PanoramiXRes *draw, *gc, *port; - Bool isRoot; - int result, i, x, y; - - REQUEST_AT_LEAST_SIZE(xvPutVideoReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, - XRT_GC, client, DixReadAccess); - if (result != Success) - return result; - - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - x = stuff->drw_x; - y = stuff->drw_y; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { - stuff->drw_x -= screenInfo.screens[i]->x; - stuff->drw_y -= screenInfo.screens[i]->y; - } - - result = ProcXvPutVideo(client); - } - } - return result; -} - -static int -XineramaXvPutStill(ClientPtr client) -{ - REQUEST(xvPutImageReq); - PanoramiXRes *draw, *gc, *port; - Bool isRoot; - int result, i, x, y; - - REQUEST_AT_LEAST_SIZE(xvPutImageReq); - - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, - XRT_GC, client, DixReadAccess); - if (result != Success) - return result; - - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); - if (result != Success) - return result; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - x = stuff->drw_x; - y = stuff->drw_y; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { - stuff->drw_x -= screenInfo.screens[i]->x; - stuff->drw_y -= screenInfo.screens[i]->y; - } - - result = ProcXvPutStill(client); - } - } - return result; -} - -static Bool -isImageAdaptor(XvAdaptorPtr pAdapt) -{ - return (pAdapt->type & XvImageMask) && (pAdapt->nImages > 0); -} - -static Bool -hasOverlay(XvAdaptorPtr pAdapt) -{ - int i; - for(i = 0; i < pAdapt->nAttributes; i++) - if(!strcmp(pAdapt->pAttributes[i].name, "XV_COLORKEY")) - return TRUE; - return FALSE; -} - -static XvAdaptorPtr -matchAdaptor(ScreenPtr pScreen, XvAdaptorPtr refAdapt, Bool isOverlay) -{ - int i; - XvScreenPtr xvsp = dixLookupPrivate(&pScreen->devPrivates, XvGetScreenKey()); - /* Do not try to go on if xv is not supported on this screen */ - if(xvsp == NULL) - return NULL; - - /* if the adaptor has the same name it's a perfect match */ - for(i = 0; i < xvsp->nAdaptors; i++) { - XvAdaptorPtr pAdapt = xvsp->pAdaptors + i; - if(!strcmp(refAdapt->name, pAdapt->name)) - return pAdapt; - } - - /* otherwise we only look for XvImage adaptors */ - if(!isImageAdaptor(refAdapt)) - return NULL; - - /* prefer overlay/overlay non-overlay/non-overlay pairing */ - for(i = 0; i < xvsp->nAdaptors; i++) { - XvAdaptorPtr pAdapt = xvsp->pAdaptors + i; - if(isImageAdaptor(pAdapt) && isOverlay == hasOverlay(pAdapt)) - return pAdapt; - } - - /* but we'll take any XvImage pairing if we can get it */ - for(i = 0; i < xvsp->nAdaptors; i++) { - XvAdaptorPtr pAdapt = xvsp->pAdaptors + i; - if(isImageAdaptor(pAdapt)) - return pAdapt; - } - return NULL; -} - -void XineramifyXv(void) -{ - XvScreenPtr xvsp0 = dixLookupPrivate(&screenInfo.screens[0]->devPrivates, XvGetScreenKey()); - XvAdaptorPtr MatchingAdaptors[MAXSCREENS]; - int i, j, k; - - XvXRTPort = CreateNewResourceType(XineramaDeleteResource, "XvXRTPort"); - - if (!xvsp0 || !XvXRTPort) return; - SetResourceTypeErrorValue(XvXRTPort, _XvBadPort); - - for(i = 0; i < xvsp0->nAdaptors; i++) { - Bool isOverlay; - XvAdaptorPtr refAdapt = xvsp0->pAdaptors + i; - if(!(refAdapt->type & XvInputMask)) continue; - - MatchingAdaptors[0] = refAdapt; - isOverlay = hasOverlay(refAdapt); - for(j = 1; j < PanoramiXNumScreens; j++) - MatchingAdaptors[j] = matchAdaptor(screenInfo.screens[j], refAdapt, isOverlay); - - /* now create a resource for each port */ - for(j = 0; j < refAdapt->nPorts; j++) { - PanoramiXRes *port = malloc(sizeof(PanoramiXRes)); - if(!port) - break; - - for(k = 0; k < PanoramiXNumScreens; k++) { - if(MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j)) - port->info[k].id = MatchingAdaptors[k]->base_id + j; - else - port->info[k].id = 0; - } - AddResource(port->info[0].id, XvXRTPort, port); - } - } - - /* munge the dispatch vector */ - XvProcVector[xv_PutVideo] = XineramaXvPutVideo; - XvProcVector[xv_PutStill] = XineramaXvPutStill; - XvProcVector[xv_StopVideo] = XineramaXvStopVideo; - XvProcVector[xv_SetPortAttribute] = XineramaXvSetPortAttribute; - XvProcVector[xv_PutImage] = XineramaXvPutImage; - XvProcVector[xv_ShmPutImage] = XineramaXvShmPutImage; -} -#endif /* PANORAMIX */ - -void -XvResetProcVector(void) -{ -#ifdef PANORAMIX - XvProcVector[xv_PutVideo] = ProcXvPutVideo; - XvProcVector[xv_PutStill] = ProcXvPutStill; - XvProcVector[xv_StopVideo] = ProcXvStopVideo; - XvProcVector[xv_SetPortAttribute] = ProcXvSetPortAttribute; - XvProcVector[xv_PutImage] = ProcXvPutImage; - XvProcVector[xv_ShmPutImage] = ProcXvShmPutImage; -#endif -} +/*********************************************************** +Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts, +and the Massachusetts Institute of Technology, Cambridge, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Digital or MIT not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. +******************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include + +#include +#include +#include "misc.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "gcstruct.h" +#include "dixstruct.h" +#include "resource.h" +#include "opaque.h" + +#include +#include +#include "xvdix.h" +#ifdef MITSHM +#include +#endif + +#include "xvdisp.h" + +#ifdef PANORAMIX +#include "panoramiX.h" +#include "panoramiXsrv.h" + +unsigned long XvXRTPort; +#endif + +static int +SWriteQueryExtensionReply( + ClientPtr client, + xvQueryExtensionReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->version, n); + swaps(&rep->revision, n); + + (void)WriteToClient(client, sz_xvQueryExtensionReply, (char *)rep); + + return Success; +} + +static int +SWriteQueryAdaptorsReply( + ClientPtr client, + xvQueryAdaptorsReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->num_adaptors, n); + + (void)WriteToClient(client, sz_xvQueryAdaptorsReply, (char *)rep); + + return Success; +} + +static int +SWriteQueryEncodingsReply( + ClientPtr client, + xvQueryEncodingsReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->num_encodings, n); + + (void)WriteToClient(client, sz_xvQueryEncodingsReply, (char *)rep); + + return Success; +} + +static int +SWriteAdaptorInfo( + ClientPtr client, + xvAdaptorInfo *pAdaptor +){ + char n; + + swapl(&pAdaptor->base_id, n); + swaps(&pAdaptor->name_size, n); + swaps(&pAdaptor->num_ports, n); + swaps(&pAdaptor->num_formats, n); + + (void)WriteToClient(client, sz_xvAdaptorInfo, (char *)pAdaptor); + + return Success; +} + +static int +SWriteEncodingInfo( + ClientPtr client, + xvEncodingInfo *pEncoding +){ + char n; + + swapl(&pEncoding->encoding, n); + swaps(&pEncoding->name_size, n); + swaps(&pEncoding->width, n); + swaps(&pEncoding->height, n); + swapl(&pEncoding->rate.numerator, n); + swapl(&pEncoding->rate.denominator, n); + (void)WriteToClient(client, sz_xvEncodingInfo, (char *)pEncoding); + + return Success; +} + +static int +SWriteFormat( + ClientPtr client, + xvFormat *pFormat +){ + char n; + + swapl(&pFormat->visual, n); + (void)WriteToClient(client, sz_xvFormat, (char *)pFormat); + + return Success; +} + +static int +SWriteAttributeInfo( + ClientPtr client, + xvAttributeInfo *pAtt +){ + char n; + + swapl(&pAtt->flags, n); + swapl(&pAtt->size, n); + swapl(&pAtt->min, n); + swapl(&pAtt->max, n); + (void)WriteToClient(client, sz_xvAttributeInfo, (char *)pAtt); + + return Success; +} + +static int +SWriteImageFormatInfo( + ClientPtr client, + xvImageFormatInfo *pImage +){ + char n; + + swapl(&pImage->id, n); + swapl(&pImage->red_mask, n); + swapl(&pImage->green_mask, n); + swapl(&pImage->blue_mask, n); + swapl(&pImage->y_sample_bits, n); + swapl(&pImage->u_sample_bits, n); + swapl(&pImage->v_sample_bits, n); + swapl(&pImage->horz_y_period, n); + swapl(&pImage->horz_u_period, n); + swapl(&pImage->horz_v_period, n); + swapl(&pImage->vert_y_period, n); + swapl(&pImage->vert_u_period, n); + swapl(&pImage->vert_v_period, n); + + (void)WriteToClient(client, sz_xvImageFormatInfo, (char *)pImage); + + return Success; +} + +static int +SWriteGrabPortReply( + ClientPtr client, + xvGrabPortReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + + (void)WriteToClient(client, sz_xvGrabPortReply, (char *)rep); + + return Success; +} + +static int +SWriteGetPortAttributeReply( + ClientPtr client, + xvGetPortAttributeReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swapl(&rep->value, n); + + (void)WriteToClient(client, sz_xvGetPortAttributeReply, (char *)rep); + + return Success; +} + +static int +SWriteQueryBestSizeReply( + ClientPtr client, + xvQueryBestSizeReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swaps(&rep->actual_width, n); + swaps(&rep->actual_height, n); + + (void)WriteToClient(client, sz_xvQueryBestSizeReply, (char *)rep); + + return Success; +} + +static int +SWriteQueryPortAttributesReply( + ClientPtr client, + xvQueryPortAttributesReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swapl(&rep->num_attributes, n); + swapl(&rep->text_size, n); + + (void)WriteToClient(client, sz_xvQueryPortAttributesReply, (char *)rep); + + return Success; +} + +static int +SWriteQueryImageAttributesReply( + ClientPtr client, + xvQueryImageAttributesReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swapl(&rep->num_planes, n); + swapl(&rep->data_size, n); + swaps(&rep->width, n); + swaps(&rep->height, n); + + (void)WriteToClient(client, sz_xvQueryImageAttributesReply, (char *)rep); + + return Success; +} + +static int +SWriteListImageFormatsReply( + ClientPtr client, + xvListImageFormatsReply *rep +){ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + swapl(&rep->num_formats, n); + + (void)WriteToClient(client, sz_xvListImageFormatsReply, (char *)rep); + + return Success; +} + +#define _WriteQueryAdaptorsReply(_c,_d) \ + if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \ + else WriteToClient(_c, sz_xvQueryAdaptorsReply, (char*)_d) + +#define _WriteQueryExtensionReply(_c,_d) \ + if ((_c)->swapped) SWriteQueryExtensionReply(_c, _d); \ + else WriteToClient(_c, sz_xvQueryExtensionReply, (char*)_d) + +#define _WriteQueryEncodingsReply(_c,_d) \ + if ((_c)->swapped) SWriteQueryEncodingsReply(_c, _d); \ + else WriteToClient(_c, sz_xvQueryEncodingsReply, (char*)_d) + +#define _WriteAdaptorInfo(_c,_d) \ + if ((_c)->swapped) SWriteAdaptorInfo(_c, _d); \ + else WriteToClient(_c, sz_xvAdaptorInfo, (char*)_d) + +#define _WriteAttributeInfo(_c,_d) \ + if ((_c)->swapped) SWriteAttributeInfo(_c, _d); \ + else WriteToClient(_c, sz_xvAttributeInfo, (char*)_d) + +#define _WriteEncodingInfo(_c,_d) \ + if ((_c)->swapped) SWriteEncodingInfo(_c, _d); \ + else WriteToClient(_c, sz_xvEncodingInfo, (char*)_d) + +#define _WriteFormat(_c,_d) \ + if ((_c)->swapped) SWriteFormat(_c, _d); \ + else WriteToClient(_c, sz_xvFormat, (char*)_d) + +#define _WriteGrabPortReply(_c,_d) \ + if ((_c)->swapped) SWriteGrabPortReply(_c, _d); \ + else WriteToClient(_c, sz_xvGrabPortReply, (char*)_d) + +#define _WriteGetPortAttributeReply(_c,_d) \ + if ((_c)->swapped) SWriteGetPortAttributeReply(_c, _d); \ + else WriteToClient(_c, sz_xvGetPortAttributeReply, (char*)_d) + +#define _WriteQueryBestSizeReply(_c,_d) \ + if ((_c)->swapped) SWriteQueryBestSizeReply(_c, _d); \ + else WriteToClient(_c, sz_xvQueryBestSizeReply,(char*) _d) + +#define _WriteQueryPortAttributesReply(_c,_d) \ + if ((_c)->swapped) SWriteQueryPortAttributesReply(_c, _d); \ + else WriteToClient(_c, sz_xvQueryPortAttributesReply,(char*) _d) + +#define _WriteQueryImageAttributesReply(_c,_d) \ + if ((_c)->swapped) SWriteQueryImageAttributesReply(_c, _d); \ + else WriteToClient(_c, sz_xvQueryImageAttributesReply,(char*) _d) + +#define _WriteListImageFormatsReply(_c,_d) \ + if ((_c)->swapped) SWriteListImageFormatsReply(_c, _d); \ + else WriteToClient(_c, sz_xvListImageFormatsReply,(char*) _d) + +#define _WriteImageFormatInfo(_c,_d) \ + if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \ + else WriteToClient(_c, sz_xvImageFormatInfo, (char*)_d) + +#define _AllocatePort(_i,_p) \ + ((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success + +static int +ProcXvQueryExtension(ClientPtr client) +{ + xvQueryExtensionReply rep; + /* REQUEST(xvQueryExtensionReq); */ + REQUEST_SIZE_MATCH(xvQueryExtensionReq); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.version = XvVersion; + rep.revision = XvRevision; + + _WriteQueryExtensionReply(client, &rep); + + return Success; +} + +static int +ProcXvQueryAdaptors(ClientPtr client) +{ + xvFormat format; + xvAdaptorInfo ainfo; + xvQueryAdaptorsReply rep; + int totalSize, na, nf, rc; + int nameSize; + XvAdaptorPtr pa; + XvFormatPtr pf; + WindowPtr pWin; + ScreenPtr pScreen; + XvScreenPtr pxvs; + + REQUEST(xvQueryAdaptorsReq); + REQUEST_SIZE_MATCH(xvQueryAdaptorsReq); + + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + pScreen = pWin->drawable.pScreen; + pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + XvGetScreenKey()); + if (!pxvs) + { + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.num_adaptors = 0; + rep.length = 0; + + _WriteQueryAdaptorsReply(client, &rep); + + return Success; + } + + (* pxvs->ddQueryAdaptors)(pScreen, &pxvs->pAdaptors, &pxvs->nAdaptors); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.num_adaptors = pxvs->nAdaptors; + + /* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */ + + totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo; + + /* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */ + + na = pxvs->nAdaptors; + pa = pxvs->pAdaptors; + while (na--) + { + totalSize += pad_to_int32(strlen(pa->name)); + totalSize += pa->nFormats * sz_xvFormat; + pa++; + } + + rep.length = bytes_to_int32(totalSize); + + _WriteQueryAdaptorsReply(client, &rep); + + na = pxvs->nAdaptors; + pa = pxvs->pAdaptors; + while (na--) + { + + ainfo.base_id = pa->base_id; + ainfo.num_ports = pa->nPorts; + ainfo.type = pa->type; + ainfo.name_size = nameSize = strlen(pa->name); + ainfo.num_formats = pa->nFormats; + + _WriteAdaptorInfo(client, &ainfo); + + WriteToClient(client, nameSize, pa->name); + + nf = pa->nFormats; + pf = pa->pFormats; + while (nf--) + { + format.depth = pf->depth; + format.visual = pf->visual; + _WriteFormat(client, &format); + pf++; + } + + pa++; + + } + + return Success; +} + +static int +ProcXvQueryEncodings(ClientPtr client) +{ + xvEncodingInfo einfo; + xvQueryEncodingsReply rep; + int totalSize; + int nameSize; + XvPortPtr pPort; + int ne; + XvEncodingPtr pe; + int status; + + REQUEST(xvQueryEncodingsReq); + REQUEST_SIZE_MATCH(xvQueryEncodingsReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.num_encodings = pPort->pAdaptor->nEncodings; + + /* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */ + + ne = pPort->pAdaptor->nEncodings; + pe = pPort->pAdaptor->pEncodings; + totalSize = ne * sz_xvEncodingInfo; + while (ne--) + { + totalSize += pad_to_int32(strlen(pe->name)); + pe++; + } + + rep.length = bytes_to_int32(totalSize); + + _WriteQueryEncodingsReply(client, &rep); + + ne = pPort->pAdaptor->nEncodings; + pe = pPort->pAdaptor->pEncodings; + while (ne--) + { + einfo.encoding = pe->id; + einfo.name_size = nameSize = strlen(pe->name); + einfo.width = pe->width; + einfo.height = pe->height; + einfo.rate.numerator = pe->rate.numerator; + einfo.rate.denominator = pe->rate.denominator; + _WriteEncodingInfo(client, &einfo); + WriteToClient(client, nameSize, pe->name); + pe++; + } + + return Success; +} + +static int +ProcXvPutVideo(ClientPtr client) +{ + DrawablePtr pDraw; + XvPortPtr pPort; + GCPtr pGC; + int status; + + REQUEST(xvPutVideoReq); + REQUEST_SIZE_MATCH(xvPutVideoReq); + + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + if (!(pPort->pAdaptor->type & XvInputMask) || + !(pPort->pAdaptor->type & XvVideoMask)) + { + client->errorValue = stuff->port; + return BadMatch; + } + + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) + { + return status; + } + + return XvdiPutVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); +} + +static int +ProcXvPutStill(ClientPtr client) +{ + DrawablePtr pDraw; + XvPortPtr pPort; + GCPtr pGC; + int status; + + REQUEST(xvPutStillReq); + REQUEST_SIZE_MATCH(xvPutStillReq); + + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + if (!(pPort->pAdaptor->type & XvInputMask) || + !(pPort->pAdaptor->type & XvStillMask)) + { + client->errorValue = stuff->port; + return BadMatch; + } + + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) + { + return status; + } + + return XvdiPutStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); +} + +static int +ProcXvGetVideo(ClientPtr client) +{ + DrawablePtr pDraw; + XvPortPtr pPort; + GCPtr pGC; + int status; + + REQUEST(xvGetVideoReq); + REQUEST_SIZE_MATCH(xvGetVideoReq); + + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + if (!(pPort->pAdaptor->type & XvOutputMask) || + !(pPort->pAdaptor->type & XvVideoMask)) + { + client->errorValue = stuff->port; + return BadMatch; + } + + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) + { + return status; + } + + return XvdiGetVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); +} + +static int +ProcXvGetStill(ClientPtr client) +{ + DrawablePtr pDraw; + XvPortPtr pPort; + GCPtr pGC; + int status; + + REQUEST(xvGetStillReq); + REQUEST_SIZE_MATCH(xvGetStillReq); + + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + if (!(pPort->pAdaptor->type & XvOutputMask) || + !(pPort->pAdaptor->type & XvStillMask)) + { + client->errorValue = stuff->port; + return BadMatch; + } + + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) + { + return status; + } + + return XvdiGetStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); +} + +static int +ProcXvSelectVideoNotify(ClientPtr client) +{ + DrawablePtr pDraw; + int rc; + REQUEST(xvSelectVideoNotifyReq); + REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq); + + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReceiveAccess); + if (rc != Success) + return rc; + + return XvdiSelectVideoNotify(client, pDraw, stuff->onoff); +} + +static int +ProcXvSelectPortNotify(ClientPtr client) +{ + int status; + XvPortPtr pPort; + REQUEST(xvSelectPortNotifyReq); + REQUEST_SIZE_MATCH(xvSelectPortNotifyReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + return XvdiSelectPortNotify(client, pPort, stuff->onoff); +} + +static int +ProcXvGrabPort(ClientPtr client) +{ + int result, status; + XvPortPtr pPort; + xvGrabPortReply rep; + REQUEST(xvGrabPortReq); + REQUEST_SIZE_MATCH(xvGrabPortReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + status = XvdiGrabPort(client, pPort, stuff->time, &result); + + if (status != Success) + { + return status; + } + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.result = result; + + _WriteGrabPortReply(client, &rep); + + return Success; +} + +static int +ProcXvUngrabPort(ClientPtr client) +{ + int status; + XvPortPtr pPort; + REQUEST(xvGrabPortReq); + REQUEST_SIZE_MATCH(xvGrabPortReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + return XvdiUngrabPort(client, pPort, stuff->time); +} + +static int +ProcXvStopVideo(ClientPtr client) +{ + int status, rc; + DrawablePtr pDraw; + XvPortPtr pPort; + REQUEST(xvStopVideoReq); + REQUEST_SIZE_MATCH(xvStopVideoReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess); + if (rc != Success) + return rc; + + return XvdiStopVideo(client, pPort, pDraw); +} + +static int +ProcXvSetPortAttribute(ClientPtr client) +{ + int status; + XvPortPtr pPort; + REQUEST(xvSetPortAttributeReq); + REQUEST_SIZE_MATCH(xvSetPortAttributeReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixSetAttrAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + if (!ValidAtom(stuff->attribute)) + { + client->errorValue = stuff->attribute; + return BadAtom; + } + + status = XvdiSetPortAttribute(client, pPort, stuff->attribute, stuff->value); + + if (status == BadMatch) + client->errorValue = stuff->attribute; + else + client->errorValue = stuff->value; + + return status; +} + +static int +ProcXvGetPortAttribute(ClientPtr client) +{ + INT32 value; + int status; + XvPortPtr pPort; + xvGetPortAttributeReply rep; + REQUEST(xvGetPortAttributeReq); + REQUEST_SIZE_MATCH(xvGetPortAttributeReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + if (!ValidAtom(stuff->attribute)) + { + client->errorValue = stuff->attribute; + return BadAtom; + } + + status = XvdiGetPortAttribute(client, pPort, stuff->attribute, &value); + if (status != Success) + { + client->errorValue = stuff->attribute; + return status; + } + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.value = value; + + _WriteGetPortAttributeReply(client, &rep); + + return Success; +} + +static int +ProcXvQueryBestSize(ClientPtr client) +{ + int status; + unsigned int actual_width, actual_height; + XvPortPtr pPort; + xvQueryBestSizeReply rep; + REQUEST(xvQueryBestSizeReq); + REQUEST_SIZE_MATCH(xvQueryBestSizeReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + + (* pPort->pAdaptor->ddQueryBestSize)(client, pPort, stuff->motion, + stuff->vid_w, stuff->vid_h, + stuff->drw_w, stuff->drw_h, + &actual_width, &actual_height); + + rep.actual_width = actual_width; + rep.actual_height = actual_height; + + _WriteQueryBestSizeReply(client, &rep); + + return Success; +} + + +static int +ProcXvQueryPortAttributes(ClientPtr client) +{ + int status, size, i; + XvPortPtr pPort; + XvAttributePtr pAtt; + xvQueryPortAttributesReply rep; + xvAttributeInfo Info; + REQUEST(xvQueryPortAttributesReq); + REQUEST_SIZE_MATCH(xvQueryPortAttributesReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.num_attributes = pPort->pAdaptor->nAttributes; + rep.text_size = 0; + + for(i = 0, pAtt = pPort->pAdaptor->pAttributes; + i < pPort->pAdaptor->nAttributes; i++, pAtt++) + { + rep.text_size += pad_to_int32(strlen(pAtt->name) + 1); + } + + rep.length = (pPort->pAdaptor->nAttributes * sz_xvAttributeInfo) + + rep.text_size; + rep.length >>= 2; + + _WriteQueryPortAttributesReply(client, &rep); + + for(i = 0, pAtt = pPort->pAdaptor->pAttributes; + i < pPort->pAdaptor->nAttributes; i++, pAtt++) + { + size = strlen(pAtt->name) + 1; /* pass the NULL */ + Info.flags = pAtt->flags; + Info.min = pAtt->min_value; + Info.max = pAtt->max_value; + Info.size = pad_to_int32(size); + + _WriteAttributeInfo(client, &Info); + + WriteToClient(client, size, pAtt->name); + } + + return Success; +} + +static int +ProcXvPutImage(ClientPtr client) +{ + DrawablePtr pDraw; + XvPortPtr pPort; + XvImagePtr pImage = NULL; + GCPtr pGC; + int status, i, size; + CARD16 width, height; + + REQUEST(xvPutImageReq); + REQUEST_AT_LEAST_SIZE(xvPutImageReq); + + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + if (!(pPort->pAdaptor->type & XvImageMask) || + !(pPort->pAdaptor->type & XvInputMask)) + { + client->errorValue = stuff->port; + return BadMatch; + } + + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) + { + return status; + } + + for(i = 0; i < pPort->pAdaptor->nImages; i++) { + if(pPort->pAdaptor->pImages[i].id == stuff->id) { + pImage = &(pPort->pAdaptor->pImages[i]); + break; + } + } + + if(!pImage) + return BadMatch; + + width = stuff->width; + height = stuff->height; + size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, + pPort, pImage, &width, &height, NULL, NULL); + size += sizeof(xvPutImageReq); + size = bytes_to_int32(size); + + if((width < stuff->width) || (height < stuff->height)) + return BadValue; + + if(client->req_len < size) + return BadLength; + + return XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y, + stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h, pImage, + (unsigned char*)(&stuff[1]), FALSE, + stuff->width, stuff->height); +} + +#ifdef MITSHM +/* redefined here since it's not in any header file */ +typedef struct _ShmDesc { + struct _ShmDesc *next; + int shmid; + int refcnt; + char *addr; + Bool writable; + unsigned long size; +} ShmDescRec, *ShmDescPtr; + +extern RESTYPE ShmSegType; +extern int ShmCompletionCode; + +static int +ProcXvShmPutImage(ClientPtr client) +{ + ShmDescPtr shmdesc; + DrawablePtr pDraw; + XvPortPtr pPort; + XvImagePtr pImage = NULL; + GCPtr pGC; + int status, size_needed, i; + CARD16 width, height; + + REQUEST(xvShmPutImageReq); + REQUEST_SIZE_MATCH(xvShmPutImageReq); + + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) + { + client->errorValue = stuff->port; + return status; + } + + if (!(pPort->pAdaptor->type & XvImageMask) || + !(pPort->pAdaptor->type & XvInputMask)) + { + client->errorValue = stuff->port; + return BadMatch; + } + + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) + { + return status; + } + + for(i = 0; i < pPort->pAdaptor->nImages; i++) { + if(pPort->pAdaptor->pImages[i].id == stuff->id) { + pImage = &(pPort->pAdaptor->pImages[i]); + break; + } + } + + if(!pImage) + return BadMatch; + + status = dixLookupResourceByType((pointer *)&shmdesc, stuff->shmseg, + ShmSegType, serverClient, DixReadAccess); + if (status != Success) + return status; + + width = stuff->width; + height = stuff->height; + size_needed = (*pPort->pAdaptor->ddQueryImageAttributes)(client, + pPort, pImage, &width, &height, NULL, NULL); + if((size_needed + stuff->offset) > shmdesc->size) + return BadAccess; + + if((width < stuff->width) || (height < stuff->height)) + return BadValue; + + status = XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y, + stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h, pImage, + (unsigned char *)shmdesc->addr + stuff->offset, + stuff->send_event, stuff->width, stuff->height); + + if((status == Success) && stuff->send_event) { + xShmCompletionEvent ev; + + ev.type = ShmCompletionCode; + ev.drawable = stuff->drawable; + ev.minorEvent = xv_ShmPutImage; + ev.majorEvent = XvReqCode; + ev.shmseg = stuff->shmseg; + ev.offset = stuff->offset; + WriteEventsToClient(client, 1, (xEvent *) &ev); + } + + return status; +} +#else /* !MITSHM */ +static int +ProcXvShmPutImage(ClientPtr client) +{ + SendErrorToClient(client, XvReqCode, xv_ShmPutImage, 0, BadImplementation); + return BadImplementation; +} +#endif + +#ifdef XvMCExtension +#include "xvmcext.h" +#endif + +static int +ProcXvQueryImageAttributes(ClientPtr client) +{ + xvQueryImageAttributesReply rep; + int size, num_planes, i; + CARD16 width, height; + XvImagePtr pImage = NULL; + XvPortPtr pPort; + int *offsets; + int *pitches; + int planeLength; + REQUEST(xvQueryImageAttributesReq); + + REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + for(i = 0; i < pPort->pAdaptor->nImages; i++) { + if(pPort->pAdaptor->pImages[i].id == stuff->id) { + pImage = &(pPort->pAdaptor->pImages[i]); + break; + } + } + +#ifdef XvMCExtension + if(!pImage) + pImage = XvMCFindXvImage(pPort, stuff->id); +#endif + + if(!pImage) + return BadMatch; + + num_planes = pImage->num_planes; + + if(!(offsets = malloc(num_planes << 3))) + return BadAlloc; + pitches = offsets + num_planes; + + width = stuff->width; + height = stuff->height; + + size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, pPort, pImage, + &width, &height, offsets, pitches); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = planeLength = num_planes << 1; + rep.num_planes = num_planes; + rep.width = width; + rep.height = height; + rep.data_size = size; + + _WriteQueryImageAttributesReply(client, &rep); + if(client->swapped) + SwapLongs((CARD32*)offsets, planeLength); + WriteToClient(client, planeLength << 2, (char*)offsets); + + free(offsets); + + return Success; +} + +static int +ProcXvListImageFormats(ClientPtr client) +{ + XvPortPtr pPort; + XvImagePtr pImage; + int i; + xvListImageFormatsReply rep; + xvImageFormatInfo info; + REQUEST(xvListImageFormatsReq); + + REQUEST_SIZE_MATCH(xvListImageFormatsReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.num_formats = pPort->pAdaptor->nImages; + rep.length = bytes_to_int32(pPort->pAdaptor->nImages * sz_xvImageFormatInfo); + + _WriteListImageFormatsReply(client, &rep); + + pImage = pPort->pAdaptor->pImages; + + for(i = 0; i < pPort->pAdaptor->nImages; i++, pImage++) { + info.id = pImage->id; + info.type = pImage->type; + info.byte_order = pImage->byte_order; + memcpy(&info.guid, pImage->guid, 16); + info.bpp = pImage->bits_per_pixel; + info.num_planes = pImage->num_planes; + info.depth = pImage->depth; + info.red_mask = pImage->red_mask; + info.green_mask = pImage->green_mask; + info.blue_mask = pImage->blue_mask; + info.format = pImage->format; + info.y_sample_bits = pImage->y_sample_bits; + info.u_sample_bits = pImage->u_sample_bits; + info.v_sample_bits = pImage->v_sample_bits; + info.horz_y_period = pImage->horz_y_period; + info.horz_u_period = pImage->horz_u_period; + info.horz_v_period = pImage->horz_v_period; + info.vert_y_period = pImage->vert_y_period; + info.vert_u_period = pImage->vert_u_period; + info.vert_v_period = pImage->vert_v_period; + memcpy(&info.comp_order, pImage->component_order, 32); + info.scanline_order = pImage->scanline_order; + _WriteImageFormatInfo(client, &info); + } + + return Success; +} + +static int (*XvProcVector[xvNumRequests])(ClientPtr) = { + ProcXvQueryExtension, + ProcXvQueryAdaptors, + ProcXvQueryEncodings, + ProcXvGrabPort, + ProcXvUngrabPort, + ProcXvPutVideo, + ProcXvPutStill, + ProcXvGetVideo, + ProcXvGetStill, + ProcXvStopVideo, + ProcXvSelectVideoNotify, + ProcXvSelectPortNotify, + ProcXvQueryBestSize, + ProcXvSetPortAttribute, + ProcXvGetPortAttribute, + ProcXvQueryPortAttributes, + ProcXvListImageFormats, + ProcXvQueryImageAttributes, + ProcXvPutImage, + ProcXvShmPutImage, +}; + +int +ProcXvDispatch(ClientPtr client) +{ + REQUEST(xReq); + + UpdateCurrentTime(); + + if (stuff->data > xvNumRequests) { + SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); + return BadRequest; + } + + return XvProcVector[stuff->data](client); +} + +/* Swapped Procs */ + +static int +SProcXvQueryExtension(ClientPtr client) +{ + char n; + REQUEST(xvQueryExtensionReq); + swaps(&stuff->length, n); + return XvProcVector[xv_QueryExtension](client); +} + +static int +SProcXvQueryAdaptors(ClientPtr client) +{ + char n; + REQUEST(xvQueryAdaptorsReq); + swaps(&stuff->length, n); + swapl(&stuff->window, n); + return XvProcVector[xv_QueryAdaptors](client); +} + +static int +SProcXvQueryEncodings(ClientPtr client) +{ + char n; + REQUEST(xvQueryEncodingsReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + return XvProcVector[xv_QueryEncodings](client); +} + +static int +SProcXvGrabPort(ClientPtr client) +{ + char n; + REQUEST(xvGrabPortReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->time, n); + return XvProcVector[xv_GrabPort](client); +} + +static int +SProcXvUngrabPort(ClientPtr client) +{ + char n; + REQUEST(xvUngrabPortReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->time, n); + return XvProcVector[xv_UngrabPort](client); +} + +static int +SProcXvPutVideo(ClientPtr client) +{ + char n; + REQUEST(xvPutVideoReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->drawable, n); + swapl(&stuff->gc, n); + swaps(&stuff->vid_x, n); + swaps(&stuff->vid_y, n); + swaps(&stuff->vid_w, n); + swaps(&stuff->vid_h, n); + swaps(&stuff->drw_x, n); + swaps(&stuff->drw_y, n); + swaps(&stuff->drw_w, n); + swaps(&stuff->drw_h, n); + return XvProcVector[xv_PutVideo](client); +} + +static int +SProcXvPutStill(ClientPtr client) +{ + char n; + REQUEST(xvPutStillReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->drawable, n); + swapl(&stuff->gc, n); + swaps(&stuff->vid_x, n); + swaps(&stuff->vid_y, n); + swaps(&stuff->vid_w, n); + swaps(&stuff->vid_h, n); + swaps(&stuff->drw_x, n); + swaps(&stuff->drw_y, n); + swaps(&stuff->drw_w, n); + swaps(&stuff->drw_h, n); + return XvProcVector[xv_PutStill](client); +} + +static int +SProcXvGetVideo(ClientPtr client) +{ + char n; + REQUEST(xvGetVideoReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->drawable, n); + swapl(&stuff->gc, n); + swaps(&stuff->vid_x, n); + swaps(&stuff->vid_y, n); + swaps(&stuff->vid_w, n); + swaps(&stuff->vid_h, n); + swaps(&stuff->drw_x, n); + swaps(&stuff->drw_y, n); + swaps(&stuff->drw_w, n); + swaps(&stuff->drw_h, n); + return XvProcVector[xv_GetVideo](client); +} + +static int +SProcXvGetStill(ClientPtr client) +{ + char n; + REQUEST(xvGetStillReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->drawable, n); + swapl(&stuff->gc, n); + swaps(&stuff->vid_x, n); + swaps(&stuff->vid_y, n); + swaps(&stuff->vid_w, n); + swaps(&stuff->vid_h, n); + swaps(&stuff->drw_x, n); + swaps(&stuff->drw_y, n); + swaps(&stuff->drw_w, n); + swaps(&stuff->drw_h, n); + return XvProcVector[xv_GetStill](client); +} + +static int +SProcXvPutImage(ClientPtr client) +{ + char n; + REQUEST(xvPutImageReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->drawable, n); + swapl(&stuff->gc, n); + swapl(&stuff->id, n); + swaps(&stuff->src_x, n); + swaps(&stuff->src_y, n); + swaps(&stuff->src_w, n); + swaps(&stuff->src_h, n); + swaps(&stuff->drw_x, n); + swaps(&stuff->drw_y, n); + swaps(&stuff->drw_w, n); + swaps(&stuff->drw_h, n); + swaps(&stuff->width, n); + swaps(&stuff->height, n); + return XvProcVector[xv_PutImage](client); +} + +#ifdef MITSHM +static int +SProcXvShmPutImage(ClientPtr client) +{ + char n; + REQUEST(xvShmPutImageReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->drawable, n); + swapl(&stuff->gc, n); + swapl(&stuff->shmseg, n); + swapl(&stuff->id, n); + swapl(&stuff->offset, n); + swaps(&stuff->src_x, n); + swaps(&stuff->src_y, n); + swaps(&stuff->src_w, n); + swaps(&stuff->src_h, n); + swaps(&stuff->drw_x, n); + swaps(&stuff->drw_y, n); + swaps(&stuff->drw_w, n); + swaps(&stuff->drw_h, n); + swaps(&stuff->width, n); + swaps(&stuff->height, n); + return XvProcVector[xv_ShmPutImage](client); +} +#else /* MITSHM */ +#define SProcXvShmPutImage ProcXvShmPutImage +#endif + +static int +SProcXvSelectVideoNotify(ClientPtr client) +{ + char n; + REQUEST(xvSelectVideoNotifyReq); + swaps(&stuff->length, n); + swapl(&stuff->drawable, n); + return XvProcVector[xv_SelectVideoNotify](client); +} + +static int +SProcXvSelectPortNotify(ClientPtr client) +{ + char n; + REQUEST(xvSelectPortNotifyReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + return XvProcVector[xv_SelectPortNotify](client); +} + +static int +SProcXvStopVideo(ClientPtr client) +{ + char n; + REQUEST(xvStopVideoReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->drawable, n); + return XvProcVector[xv_StopVideo](client); +} + +static int +SProcXvSetPortAttribute(ClientPtr client) +{ + char n; + REQUEST(xvSetPortAttributeReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->attribute, n); + swapl(&stuff->value, n); + return XvProcVector[xv_SetPortAttribute](client); +} + +static int +SProcXvGetPortAttribute(ClientPtr client) +{ + char n; + REQUEST(xvGetPortAttributeReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->attribute, n); + return XvProcVector[xv_GetPortAttribute](client); +} + +static int +SProcXvQueryBestSize(ClientPtr client) +{ + char n; + REQUEST(xvQueryBestSizeReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swaps(&stuff->vid_w, n); + swaps(&stuff->vid_h, n); + swaps(&stuff->drw_w, n); + swaps(&stuff->drw_h, n); + return XvProcVector[xv_QueryBestSize](client); +} + +static int +SProcXvQueryPortAttributes(ClientPtr client) +{ + char n; + REQUEST(xvQueryPortAttributesReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + return XvProcVector[xv_QueryPortAttributes](client); +} + +static int +SProcXvQueryImageAttributes(ClientPtr client) +{ + char n; + REQUEST(xvQueryImageAttributesReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + swapl(&stuff->id, n); + swaps(&stuff->width, n); + swaps(&stuff->height, n); + return XvProcVector[xv_QueryImageAttributes](client); +} + +static int +SProcXvListImageFormats(ClientPtr client) +{ + char n; + REQUEST(xvListImageFormatsReq); + swaps(&stuff->length, n); + swapl(&stuff->port, n); + return XvProcVector[xv_ListImageFormats](client); +} + +static int (*SXvProcVector[xvNumRequests])(ClientPtr) = { + SProcXvQueryExtension, + SProcXvQueryAdaptors, + SProcXvQueryEncodings, + SProcXvGrabPort, + SProcXvUngrabPort, + SProcXvPutVideo, + SProcXvPutStill, + SProcXvGetVideo, + SProcXvGetStill, + SProcXvStopVideo, + SProcXvSelectVideoNotify, + SProcXvSelectPortNotify, + SProcXvQueryBestSize, + SProcXvSetPortAttribute, + SProcXvGetPortAttribute, + SProcXvQueryPortAttributes, + SProcXvListImageFormats, + SProcXvQueryImageAttributes, + SProcXvPutImage, + SProcXvShmPutImage, +}; + +int +SProcXvDispatch(ClientPtr client) +{ + REQUEST(xReq); + + UpdateCurrentTime(); + + if (stuff->data > xvNumRequests) { + SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); + return BadRequest; + } + + return SXvProcVector[stuff->data](client); +} + +#ifdef PANORAMIX +static int +XineramaXvStopVideo(ClientPtr client) +{ + int result, i; + PanoramiXRes *draw, *port; + REQUEST(xvStopVideoReq); + REQUEST_SIZE_MATCH(xvStopVideoReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(i) { + if(port->info[i].id) { + stuff->drawable = draw->info[i].id; + stuff->port = port->info[i].id; + result = ProcXvStopVideo(client); + } + } + + return result; +} + +static int +XineramaXvSetPortAttribute(ClientPtr client) +{ + REQUEST(xvSetPortAttributeReq); + PanoramiXRes *port; + int result, i; + + REQUEST_SIZE_MATCH(xvSetPortAttributeReq); + + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return result; + + FOR_NSCREENS_BACKWARD(i) { + if(port->info[i].id) { + stuff->port = port->info[i].id; + result = ProcXvSetPortAttribute(client); + } + } + return result; +} + +#ifdef MITSHM +static int +XineramaXvShmPutImage(ClientPtr client) +{ + REQUEST(xvShmPutImageReq); + PanoramiXRes *draw, *gc, *port; + Bool send_event = stuff->send_event; + Bool isRoot; + int result, i, x, y; + + REQUEST_SIZE_MATCH(xvShmPutImageReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, + XRT_GC, client, DixReadAccess); + if (result != Success) + return result; + + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return result; + + isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; + + x = stuff->drw_x; + y = stuff->drw_y; + + FOR_NSCREENS_BACKWARD(i) { + if(port->info[i].id) { + stuff->drawable = draw->info[i].id; + stuff->port = port->info[i].id; + stuff->gc = gc->info[i].id; + stuff->drw_x = x; + stuff->drw_y = y; + if(isRoot) { + stuff->drw_x -= screenInfo.screens[i]->x; + stuff->drw_y -= screenInfo.screens[i]->y; + } + stuff->send_event = (send_event && !i) ? 1 : 0; + + result = ProcXvShmPutImage(client); + } + } + return result; +} +#else +#define XineramaXvShmPutImage ProcXvShmPutImage +#endif + +static int +XineramaXvPutImage(ClientPtr client) +{ + REQUEST(xvPutImageReq); + PanoramiXRes *draw, *gc, *port; + Bool isRoot; + int result, i, x, y; + + REQUEST_AT_LEAST_SIZE(xvPutImageReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, + XRT_GC, client, DixReadAccess); + if (result != Success) + return result; + + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return result; + + isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; + + x = stuff->drw_x; + y = stuff->drw_y; + + FOR_NSCREENS_BACKWARD(i) { + if(port->info[i].id) { + stuff->drawable = draw->info[i].id; + stuff->port = port->info[i].id; + stuff->gc = gc->info[i].id; + stuff->drw_x = x; + stuff->drw_y = y; + if(isRoot) { + stuff->drw_x -= screenInfo.screens[i]->x; + stuff->drw_y -= screenInfo.screens[i]->y; + } + + result = ProcXvPutImage(client); + } + } + return result; +} + +static int +XineramaXvPutVideo(ClientPtr client) +{ + REQUEST(xvPutImageReq); + PanoramiXRes *draw, *gc, *port; + Bool isRoot; + int result, i, x, y; + + REQUEST_AT_LEAST_SIZE(xvPutVideoReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, + XRT_GC, client, DixReadAccess); + if (result != Success) + return result; + + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return result; + + isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; + + x = stuff->drw_x; + y = stuff->drw_y; + + FOR_NSCREENS_BACKWARD(i) { + if(port->info[i].id) { + stuff->drawable = draw->info[i].id; + stuff->port = port->info[i].id; + stuff->gc = gc->info[i].id; + stuff->drw_x = x; + stuff->drw_y = y; + if(isRoot) { + stuff->drw_x -= screenInfo.screens[i]->x; + stuff->drw_y -= screenInfo.screens[i]->y; + } + + result = ProcXvPutVideo(client); + } + } + return result; +} + +static int +XineramaXvPutStill(ClientPtr client) +{ + REQUEST(xvPutImageReq); + PanoramiXRes *draw, *gc, *port; + Bool isRoot; + int result, i, x, y; + + REQUEST_AT_LEAST_SIZE(xvPutImageReq); + + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, + XRT_GC, client, DixReadAccess); + if (result != Success) + return result; + + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return result; + + isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; + + x = stuff->drw_x; + y = stuff->drw_y; + + FOR_NSCREENS_BACKWARD(i) { + if(port->info[i].id) { + stuff->drawable = draw->info[i].id; + stuff->port = port->info[i].id; + stuff->gc = gc->info[i].id; + stuff->drw_x = x; + stuff->drw_y = y; + if(isRoot) { + stuff->drw_x -= screenInfo.screens[i]->x; + stuff->drw_y -= screenInfo.screens[i]->y; + } + + result = ProcXvPutStill(client); + } + } + return result; +} + +static Bool +isImageAdaptor(XvAdaptorPtr pAdapt) +{ + return (pAdapt->type & XvImageMask) && (pAdapt->nImages > 0); +} + +static Bool +hasOverlay(XvAdaptorPtr pAdapt) +{ + int i; + for(i = 0; i < pAdapt->nAttributes; i++) + if(!strcmp(pAdapt->pAttributes[i].name, "XV_COLORKEY")) + return TRUE; + return FALSE; +} + +static XvAdaptorPtr +matchAdaptor(ScreenPtr pScreen, XvAdaptorPtr refAdapt, Bool isOverlay) +{ + int i; + XvScreenPtr xvsp = dixLookupPrivate(&pScreen->devPrivates, XvGetScreenKey()); + /* Do not try to go on if xv is not supported on this screen */ + if(xvsp == NULL) + return NULL; + + /* if the adaptor has the same name it's a perfect match */ + for(i = 0; i < xvsp->nAdaptors; i++) { + XvAdaptorPtr pAdapt = xvsp->pAdaptors + i; + if(!strcmp(refAdapt->name, pAdapt->name)) + return pAdapt; + } + + /* otherwise we only look for XvImage adaptors */ + if(!isImageAdaptor(refAdapt)) + return NULL; + + /* prefer overlay/overlay non-overlay/non-overlay pairing */ + for(i = 0; i < xvsp->nAdaptors; i++) { + XvAdaptorPtr pAdapt = xvsp->pAdaptors + i; + if(isImageAdaptor(pAdapt) && isOverlay == hasOverlay(pAdapt)) + return pAdapt; + } + + /* but we'll take any XvImage pairing if we can get it */ + for(i = 0; i < xvsp->nAdaptors; i++) { + XvAdaptorPtr pAdapt = xvsp->pAdaptors + i; + if(isImageAdaptor(pAdapt)) + return pAdapt; + } + return NULL; +} + +void XineramifyXv(void) +{ + XvScreenPtr xvsp0 = dixLookupPrivate(&screenInfo.screens[0]->devPrivates, XvGetScreenKey()); + XvAdaptorPtr MatchingAdaptors[MAXSCREENS]; + int i, j, k; + + XvXRTPort = CreateNewResourceType(XineramaDeleteResource, "XvXRTPort"); + + if (!xvsp0 || !XvXRTPort) return; + SetResourceTypeErrorValue(XvXRTPort, _XvBadPort); + + for(i = 0; i < xvsp0->nAdaptors; i++) { + Bool isOverlay; + XvAdaptorPtr refAdapt = xvsp0->pAdaptors + i; + if(!(refAdapt->type & XvInputMask)) continue; + + MatchingAdaptors[0] = refAdapt; + isOverlay = hasOverlay(refAdapt); + FOR_NSCREENS_FORWARD_SKIP(j) + MatchingAdaptors[j] = matchAdaptor(screenInfo.screens[j], refAdapt, isOverlay); + + /* now create a resource for each port */ + for(j = 0; j < refAdapt->nPorts; j++) { + PanoramiXRes *port = malloc(sizeof(PanoramiXRes)); + if(!port) + break; + + FOR_NSCREENS(k) { + if(MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j)) + port->info[k].id = MatchingAdaptors[k]->base_id + j; + else + port->info[k].id = 0; + } + AddResource(port->info[0].id, XvXRTPort, port); + } + } + + /* munge the dispatch vector */ + XvProcVector[xv_PutVideo] = XineramaXvPutVideo; + XvProcVector[xv_PutStill] = XineramaXvPutStill; + XvProcVector[xv_StopVideo] = XineramaXvStopVideo; + XvProcVector[xv_SetPortAttribute] = XineramaXvSetPortAttribute; + XvProcVector[xv_PutImage] = XineramaXvPutImage; + XvProcVector[xv_ShmPutImage] = XineramaXvShmPutImage; +} +#endif /* PANORAMIX */ + +void +XvResetProcVector(void) +{ +#ifdef PANORAMIX + XvProcVector[xv_PutVideo] = ProcXvPutVideo; + XvProcVector[xv_PutStill] = ProcXvPutStill; + XvProcVector[xv_StopVideo] = ProcXvStopVideo; + XvProcVector[xv_SetPortAttribute] = ProcXvSetPortAttribute; + XvProcVector[xv_PutImage] = ProcXvPutImage; + XvProcVector[xv_ShmPutImage] = ProcXvShmPutImage; +#endif +} diff --git a/xorg-server/composite/compext.c b/xorg-server/composite/compext.c index d6f26d688..e0d8e75e4 100644 --- a/xorg-server/composite/compext.c +++ b/xorg-server/composite/compext.c @@ -1,932 +1,929 @@ -/* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright © 2003 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "compint.h" -#include "xace.h" -#include "protocol-versions.h" - -static CARD8 CompositeReqCode; -static DevPrivateKeyRec CompositeClientPrivateKeyRec; -#define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec) -RESTYPE CompositeClientWindowType; -RESTYPE CompositeClientSubwindowsType; -RESTYPE CompositeClientOverlayType; - -typedef struct _CompositeClient { - int major_version; - int minor_version; -} CompositeClientRec, *CompositeClientPtr; - -#define GetCompositeClient(pClient) ((CompositeClientPtr) \ - dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey)) - -static void -CompositeClientCallback (CallbackListPtr *list, - pointer closure, - pointer data) -{ - NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; - ClientPtr pClient = clientinfo->client; - CompositeClientPtr pCompositeClient = GetCompositeClient (pClient); - - pCompositeClient->major_version = 0; - pCompositeClient->minor_version = 0; -} - -static int -FreeCompositeClientWindow (pointer value, XID ccwid) -{ - WindowPtr pWin = value; - - compFreeClientWindow (pWin, ccwid); - return Success; -} - -static int -FreeCompositeClientSubwindows (pointer value, XID ccwid) -{ - WindowPtr pWin = value; - - compFreeClientSubwindows (pWin, ccwid); - return Success; -} - -static int -FreeCompositeClientOverlay (pointer value, XID ccwid) -{ - CompOverlayClientPtr pOc = (CompOverlayClientPtr) value; - - compFreeOverlayClient (pOc); - return Success; -} - -static int -ProcCompositeQueryVersion (ClientPtr client) -{ - CompositeClientPtr pCompositeClient = GetCompositeClient (client); - xCompositeQueryVersionReply rep; - register int n; - REQUEST(xCompositeQueryVersionReq); - - REQUEST_SIZE_MATCH(xCompositeQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - if (stuff->majorVersion < SERVER_COMPOSITE_MAJOR_VERSION) { - rep.majorVersion = stuff->majorVersion; - rep.minorVersion = stuff->minorVersion; - } else { - rep.majorVersion = SERVER_COMPOSITE_MAJOR_VERSION; - rep.minorVersion = SERVER_COMPOSITE_MINOR_VERSION; - } - pCompositeClient->major_version = rep.majorVersion; - pCompositeClient->minor_version = rep.minorVersion; - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.majorVersion, n); - swapl(&rep.minorVersion, n); - } - WriteToClient(client, sizeof(xCompositeQueryVersionReply), (char *)&rep); - return Success; -} - -#define VERIFY_WINDOW(pWindow, wid, client, mode) \ - do { \ - int err; \ - err = dixLookupResourceByType((pointer *) &pWindow, wid, \ - RT_WINDOW, client, mode); \ - if (err != Success) { \ - client->errorValue = wid; \ - return err; \ - } \ - } while (0) - -static int -ProcCompositeRedirectWindow (ClientPtr client) -{ - WindowPtr pWin; - REQUEST(xCompositeRedirectWindowReq); - - REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq); - VERIFY_WINDOW(pWin, stuff->window, client, - DixSetAttrAccess|DixManageAccess|DixBlendAccess); - - return compRedirectWindow (client, pWin, stuff->update); -} - -static int -ProcCompositeRedirectSubwindows (ClientPtr client) -{ - WindowPtr pWin; - REQUEST(xCompositeRedirectSubwindowsReq); - - REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq); - VERIFY_WINDOW(pWin, stuff->window, client, - DixSetAttrAccess|DixManageAccess|DixBlendAccess); - - return compRedirectSubwindows (client, pWin, stuff->update); -} - -static int -ProcCompositeUnredirectWindow (ClientPtr client) -{ - WindowPtr pWin; - REQUEST(xCompositeUnredirectWindowReq); - - REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq); - VERIFY_WINDOW(pWin, stuff->window, client, - DixSetAttrAccess|DixManageAccess|DixBlendAccess); - - return compUnredirectWindow (client, pWin, stuff->update); -} - -static int -ProcCompositeUnredirectSubwindows (ClientPtr client) -{ - WindowPtr pWin; - REQUEST(xCompositeUnredirectSubwindowsReq); - - REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq); - VERIFY_WINDOW(pWin, stuff->window, client, - DixSetAttrAccess|DixManageAccess|DixBlendAccess); - - return compUnredirectSubwindows (client, pWin, stuff->update); -} - -static int -ProcCompositeCreateRegionFromBorderClip (ClientPtr client) -{ - WindowPtr pWin; - CompWindowPtr cw; - RegionPtr pBorderClip, pRegion; - REQUEST(xCompositeCreateRegionFromBorderClipReq); - - REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq); - VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); - LEGAL_NEW_RESOURCE (stuff->region, client); - - cw = GetCompWindow (pWin); - if (cw) - pBorderClip = &cw->borderClip; - else - pBorderClip = &pWin->borderClip; - pRegion = XFixesRegionCopy (pBorderClip); - if (!pRegion) - return BadAlloc; - RegionTranslate(pRegion, -pWin->drawable.x, -pWin->drawable.y); - - if (!AddResource (stuff->region, RegionResType, (pointer) pRegion)) - return BadAlloc; - - return Success; -} - -static int -ProcCompositeNameWindowPixmap (ClientPtr client) -{ - WindowPtr pWin; - CompWindowPtr cw; - PixmapPtr pPixmap; - int rc; - REQUEST(xCompositeNameWindowPixmapReq); - - REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq); - VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); - - if (!pWin->viewable) - return BadMatch; - - LEGAL_NEW_RESOURCE (stuff->pixmap, client); - - cw = GetCompWindow (pWin); - if (!cw) - return BadMatch; - - pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin); - if (!pPixmap) - return BadMatch; - - /* security creation/labeling check */ - rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, RT_PIXMAP, - pPixmap, RT_WINDOW, pWin, DixCreateAccess); - if (rc != Success) - return rc; - - ++pPixmap->refcnt; - - if (!AddResource (stuff->pixmap, RT_PIXMAP, (pointer) pPixmap)) - return BadAlloc; - - return Success; -} - - -static int -ProcCompositeGetOverlayWindow (ClientPtr client) -{ - REQUEST(xCompositeGetOverlayWindowReq); - xCompositeGetOverlayWindowReply rep; - WindowPtr pWin; - ScreenPtr pScreen; - CompScreenPtr cs; - CompOverlayClientPtr pOc; - int rc; - - REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); - VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); - pScreen = pWin->drawable.pScreen; - - /* - * Create an OverlayClient structure to mark this client's - * interest in the overlay window - */ - pOc = compCreateOverlayClient(pScreen, client); - if (pOc == NULL) - return BadAlloc; - - /* - * Make sure the overlay window exists - */ - cs = GetCompScreen(pScreen); - if (cs->pOverlayWin == NULL) - if (!compCreateOverlayWindow(pScreen)) - { - FreeResource (pOc->resource, RT_NONE); - return BadAlloc; - } - - rc = XaceHook(XACE_RESOURCE_ACCESS, client, cs->pOverlayWin->drawable.id, - RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, DixGetAttrAccess); - if (rc != Success) - { - FreeResource (pOc->resource, RT_NONE); - return rc; - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.overlayWin = cs->pOverlayWin->drawable.id; - - if (client->swapped) - { - int n; - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.overlayWin, n); - } - (void) WriteToClient(client, sz_xCompositeGetOverlayWindowReply, (char *)&rep); - - return Success; -} - -static int -ProcCompositeReleaseOverlayWindow (ClientPtr client) -{ - REQUEST(xCompositeReleaseOverlayWindowReq); - WindowPtr pWin; - ScreenPtr pScreen; - CompOverlayClientPtr pOc; - - REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq); - VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); - pScreen = pWin->drawable.pScreen; - - /* - * Has client queried a reference to the overlay window - * on this screen? If not, generate an error. - */ - pOc = compFindOverlayClient (pWin->drawable.pScreen, client); - if (pOc == NULL) - return BadMatch; - - /* The delete function will free the client structure */ - FreeResource (pOc->resource, RT_NONE); - - return Success; -} - -static int (*ProcCompositeVector[CompositeNumberRequests])(ClientPtr) = { - ProcCompositeQueryVersion, - ProcCompositeRedirectWindow, - ProcCompositeRedirectSubwindows, - ProcCompositeUnredirectWindow, - ProcCompositeUnredirectSubwindows, - ProcCompositeCreateRegionFromBorderClip, - ProcCompositeNameWindowPixmap, - ProcCompositeGetOverlayWindow, - ProcCompositeReleaseOverlayWindow, -}; - -static int -ProcCompositeDispatch (ClientPtr client) -{ - REQUEST(xReq); - - if (stuff->data < CompositeNumberRequests) - return (*ProcCompositeVector[stuff->data]) (client); - else - return BadRequest; -} - -static int -SProcCompositeQueryVersion (ClientPtr client) -{ - int n; - REQUEST(xCompositeQueryVersionReq); - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCompositeQueryVersionReq); - swapl(&stuff->majorVersion, n); - swapl(&stuff->minorVersion, n); - return (*ProcCompositeVector[stuff->compositeReqType]) (client); -} - -static int -SProcCompositeRedirectWindow (ClientPtr client) -{ - int n; - REQUEST(xCompositeRedirectWindowReq); - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq); - swapl (&stuff->window, n); - return (*ProcCompositeVector[stuff->compositeReqType]) (client); -} - -static int -SProcCompositeRedirectSubwindows (ClientPtr client) -{ - int n; - REQUEST(xCompositeRedirectSubwindowsReq); - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq); - swapl (&stuff->window, n); - return (*ProcCompositeVector[stuff->compositeReqType]) (client); -} - -static int -SProcCompositeUnredirectWindow (ClientPtr client) -{ - int n; - REQUEST(xCompositeUnredirectWindowReq); - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq); - swapl (&stuff->window, n); - return (*ProcCompositeVector[stuff->compositeReqType]) (client); -} - -static int -SProcCompositeUnredirectSubwindows (ClientPtr client) -{ - int n; - REQUEST(xCompositeUnredirectSubwindowsReq); - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq); - swapl (&stuff->window, n); - return (*ProcCompositeVector[stuff->compositeReqType]) (client); -} - -static int -SProcCompositeCreateRegionFromBorderClip (ClientPtr client) -{ - int n; - REQUEST(xCompositeCreateRegionFromBorderClipReq); - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq); - swapl (&stuff->region, n); - swapl (&stuff->window, n); - return (*ProcCompositeVector[stuff->compositeReqType]) (client); -} - -static int -SProcCompositeNameWindowPixmap (ClientPtr client) -{ - int n; - REQUEST(xCompositeNameWindowPixmapReq); - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq); - swapl (&stuff->window, n); - swapl (&stuff->pixmap, n); - return (*ProcCompositeVector[stuff->compositeReqType]) (client); -} - -static int -SProcCompositeGetOverlayWindow (ClientPtr client) -{ - int n; - REQUEST(xCompositeGetOverlayWindowReq); - - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); - swapl(&stuff->window, n); - return (*ProcCompositeVector[stuff->compositeReqType]) (client); -} - -static int -SProcCompositeReleaseOverlayWindow (ClientPtr client) -{ - int n; - REQUEST(xCompositeReleaseOverlayWindowReq); - - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq); - swapl(&stuff->window, n); - return (*ProcCompositeVector[stuff->compositeReqType]) (client); -} - -static int (*SProcCompositeVector[CompositeNumberRequests])(ClientPtr) = { - SProcCompositeQueryVersion, - SProcCompositeRedirectWindow, - SProcCompositeRedirectSubwindows, - SProcCompositeUnredirectWindow, - SProcCompositeUnredirectSubwindows, - SProcCompositeCreateRegionFromBorderClip, - SProcCompositeNameWindowPixmap, - SProcCompositeGetOverlayWindow, - SProcCompositeReleaseOverlayWindow, -}; - -static int -SProcCompositeDispatch (ClientPtr client) -{ - REQUEST(xReq); - - if (stuff->data < CompositeNumberRequests) - return (*SProcCompositeVector[stuff->data]) (client); - else - return BadRequest; -} - -void -CompositeExtensionInit (void) -{ - ExtensionEntry *extEntry; - int s; - - /* Assume initialization is going to fail */ - noCompositeExtension = TRUE; - - for (s = 0; s < screenInfo.numScreens; s++) { - ScreenPtr pScreen = screenInfo.screens[s]; - VisualPtr vis; - - /* Composite on 8bpp pseudocolor root windows appears to fail, so - * just disable it on anything pseudocolor for safety. - */ - for (vis = pScreen->visuals; vis->vid != pScreen->rootVisual; vis++) - ; - if ((vis->class | DynamicClass) == PseudoColor) - return; - - /* Ensure that Render is initialized, which is required for automatic - * compositing. - */ - if (GetPictureScreenIfSet(pScreen) == NULL) - return; - } - - CompositeClientWindowType = CreateNewResourceType - (FreeCompositeClientWindow, "CompositeClientWindow"); - if (!CompositeClientWindowType) - return; - - CompositeClientSubwindowsType = CreateNewResourceType - (FreeCompositeClientSubwindows, "CompositeClientSubwindows"); - if (!CompositeClientSubwindowsType) - return; - - CompositeClientOverlayType = CreateNewResourceType - (FreeCompositeClientOverlay, "CompositeClientOverlay"); - if (!CompositeClientOverlayType) - return; - - if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec, PRIVATE_CLIENT, - sizeof(CompositeClientRec))) - return; - - if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0)) - return; - - for (s = 0; s < screenInfo.numScreens; s++) - if (!compScreenInit (screenInfo.screens[s])) - return; - - extEntry = AddExtension (COMPOSITE_NAME, 0, 0, - ProcCompositeDispatch, SProcCompositeDispatch, - NULL, StandardMinorOpcode); - if (!extEntry) - return; - CompositeReqCode = (CARD8) extEntry->base; - - miRegisterRedirectBorderClipProc (compSetRedirectBorderClip, - compGetRedirectBorderClip); - - /* Initialization succeeded */ - noCompositeExtension = FALSE; -} - -#ifdef PANORAMIX -#include "panoramiXsrv.h" - -int (*PanoramiXSaveCompositeVector[CompositeNumberRequests]) (ClientPtr); - -static int -PanoramiXCompositeRedirectWindow (ClientPtr client) -{ - PanoramiXRes *win; - int rc = 0, j; - REQUEST(xCompositeRedirectWindowReq); - - REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq); - - if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, - client, DixUnknownAccess))) { - client->errorValue = stuff->window; - return rc; - } - - FOR_NSCREENS_FORWARD(j) { - stuff->window = win->info[j].id; - rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); - if (rc != Success) break; - } - - return rc; -} - -static int -PanoramiXCompositeRedirectSubwindows (ClientPtr client) -{ - PanoramiXRes *win; - int rc = 0, j; - REQUEST(xCompositeRedirectSubwindowsReq); - - REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq); - - if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, - client, DixUnknownAccess))) { - client->errorValue = stuff->window; - return rc; - } - - FOR_NSCREENS_FORWARD(j) { - stuff->window = win->info[j].id; - rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); - if (rc != Success) break; - } - - return rc; -} - -static int -PanoramiXCompositeUnredirectWindow (ClientPtr client) -{ - PanoramiXRes *win; - int rc = 0, j; - REQUEST(xCompositeUnredirectWindowReq); - - REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq); - - if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, - client, DixUnknownAccess))) { - client->errorValue = stuff->window; - return rc; - } - - FOR_NSCREENS_FORWARD(j) { - stuff->window = win->info[j].id; - rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); - if (rc != Success) break; - } - - return rc; -} - -static int -PanoramiXCompositeUnredirectSubwindows (ClientPtr client) -{ - PanoramiXRes *win; - int rc = 0, j; - REQUEST(xCompositeUnredirectSubwindowsReq); - - REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq); - - if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, - client, DixUnknownAccess))) { - client->errorValue = stuff->window; - return rc; - } - - FOR_NSCREENS_FORWARD(j) { - stuff->window = win->info[j].id; - rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); - if (rc != Success) break; - } - - return rc; -} - -static int -PanoramiXCompositeNameWindowPixmap (ClientPtr client) -{ - WindowPtr pWin; - CompWindowPtr cw; - PixmapPtr pPixmap; - int rc; - PanoramiXRes *win, *newPix; - int i; - REQUEST(xCompositeNameWindowPixmapReq); - - REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq); - - if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, - client, DixUnknownAccess))) { - client->errorValue = stuff->window; - return rc; - } - - LEGAL_NEW_RESOURCE (stuff->pixmap, client); - - if(!(newPix = malloc(sizeof(PanoramiXRes)))) - return BadAlloc; - - newPix->type = XRT_PIXMAP; - newPix->u.pix.shared = FALSE; - newPix->info[0].id = stuff->pixmap; - - for (i = 1; i < PanoramiXNumScreens; i++) - newPix->info[i].id = FakeClientID (client->index); - - FOR_NSCREENS(i) { - rc = dixLookupResourceByType ((void **) &pWin, win->info[i].id, - RT_WINDOW, client, DixGetAttrAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - free (newPix); - return rc; - } - - if (!pWin->viewable) - { - free (newPix); - return BadMatch; - } - - cw = GetCompWindow (pWin); - if (!cw) - { - free (newPix); - return BadMatch; - } - - pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin); - if (!pPixmap) - { - free (newPix); - return BadMatch; - } - - if (!AddResource (newPix->info[i].id, RT_PIXMAP, - (pointer) pPixmap)) - return BadAlloc; - - ++pPixmap->refcnt; - } - - if (!AddResource (stuff->pixmap, XRT_PIXMAP, (pointer) newPix)) - return BadAlloc; - - return Success; -} - - -static int -PanoramiXCompositeGetOverlayWindow (ClientPtr client) -{ - REQUEST(xCompositeGetOverlayWindowReq); - xCompositeGetOverlayWindowReply rep; - WindowPtr pWin; - ScreenPtr pScreen; - CompScreenPtr cs; - CompOverlayClientPtr pOc; - int rc; - PanoramiXRes *win, *overlayWin = NULL; - int i; - - REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); - - if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, - client, DixUnknownAccess))) { - client->errorValue = stuff->window; - return rc; - } - - cs = GetCompScreen(screenInfo.screens[0]); - if (!cs->pOverlayWin) - { - if(!(overlayWin = malloc(sizeof(PanoramiXRes)))) - return BadAlloc; - - overlayWin->type = XRT_WINDOW; - overlayWin->u.win.root = FALSE; - } - - FOR_NSCREENS_BACKWARD(i) { - rc = dixLookupResourceByType((pointer *)&pWin, win->info[i].id, - RT_WINDOW, client, DixGetAttrAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - return rc; - } - pScreen = pWin->drawable.pScreen; - - /* - * Create an OverlayClient structure to mark this client's - * interest in the overlay window - */ - pOc = compCreateOverlayClient(pScreen, client); - if (pOc == NULL) - return BadAlloc; - - /* - * Make sure the overlay window exists - */ - cs = GetCompScreen(pScreen); - if (cs->pOverlayWin == NULL) - if (!compCreateOverlayWindow(pScreen)) - { - FreeResource (pOc->resource, RT_NONE); - return BadAlloc; - } - - rc = XaceHook(XACE_RESOURCE_ACCESS, client, - cs->pOverlayWin->drawable.id, - RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, - DixGetAttrAccess); - if (rc != Success) - { - FreeResource (pOc->resource, RT_NONE); - return rc; - } - } - - if (overlayWin) - { - FOR_NSCREENS(i) { - cs = GetCompScreen(screenInfo.screens[i]); - overlayWin->info[i].id = cs->pOverlayWin->drawable.id; - } - - AddResource(overlayWin->info[0].id, XRT_WINDOW, overlayWin); - } - - cs = GetCompScreen(screenInfo.screens[0]); - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.overlayWin = cs->pOverlayWin->drawable.id; - - if (client->swapped) - { - int n; - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.overlayWin, n); - } - (void) WriteToClient(client, sz_xCompositeGetOverlayWindowReply, (char *)&rep); - - return Success; -} - -static int -PanoramiXCompositeReleaseOverlayWindow (ClientPtr client) -{ - REQUEST(xCompositeReleaseOverlayWindowReq); - WindowPtr pWin; - ScreenPtr pScreen; - CompOverlayClientPtr pOc; - PanoramiXRes *win; - int i, rc; - - REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq); - - if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, - client, DixUnknownAccess))) { - client->errorValue = stuff->window; - return rc; - } - - FOR_NSCREENS_BACKWARD(i) { - if ((rc = dixLookupResourceByType((void **)&pWin, win->info[i].id, - XRT_WINDOW, client, - DixUnknownAccess))) { - client->errorValue = stuff->window; - return rc; - } - pScreen = pWin->drawable.pScreen; - - /* - * Has client queried a reference to the overlay window - * on this screen? If not, generate an error. - */ - pOc = compFindOverlayClient (pWin->drawable.pScreen, client); - if (pOc == NULL) - return BadMatch; - - /* The delete function will free the client structure */ - FreeResource (pOc->resource, RT_NONE); - } - - return Success; -} - -void -PanoramiXCompositeInit (void) -{ - int i; - - for (i = 0; i < CompositeNumberRequests; i++) - PanoramiXSaveCompositeVector[i] = ProcCompositeVector[i]; - /* - * Stuff in Xinerama aware request processing hooks - */ - ProcCompositeVector[X_CompositeRedirectWindow] = - PanoramiXCompositeRedirectWindow; - ProcCompositeVector[X_CompositeRedirectSubwindows] = - PanoramiXCompositeRedirectSubwindows; - ProcCompositeVector[X_CompositeUnredirectWindow] = - PanoramiXCompositeUnredirectWindow; - ProcCompositeVector[X_CompositeUnredirectSubwindows] = - PanoramiXCompositeUnredirectSubwindows; - ProcCompositeVector[X_CompositeNameWindowPixmap] = - PanoramiXCompositeNameWindowPixmap; - ProcCompositeVector[X_CompositeGetOverlayWindow] = - PanoramiXCompositeGetOverlayWindow; - ProcCompositeVector[X_CompositeReleaseOverlayWindow] = - PanoramiXCompositeReleaseOverlayWindow; -} - -void -PanoramiXCompositeReset (void) -{ - int i; - - for (i = 0; i < CompositeNumberRequests; i++) - ProcCompositeVector[i] = PanoramiXSaveCompositeVector[i]; -} - -#endif +/* + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright © 2003 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "compint.h" +#include "xace.h" +#include "protocol-versions.h" + +static CARD8 CompositeReqCode; +static DevPrivateKeyRec CompositeClientPrivateKeyRec; +#define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec) +RESTYPE CompositeClientWindowType; +RESTYPE CompositeClientSubwindowsType; +RESTYPE CompositeClientOverlayType; + +typedef struct _CompositeClient { + int major_version; + int minor_version; +} CompositeClientRec, *CompositeClientPtr; + +#define GetCompositeClient(pClient) ((CompositeClientPtr) \ + dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey)) + +static void +CompositeClientCallback (CallbackListPtr *list, + pointer closure, + pointer data) +{ + NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; + ClientPtr pClient = clientinfo->client; + CompositeClientPtr pCompositeClient = GetCompositeClient (pClient); + + pCompositeClient->major_version = 0; + pCompositeClient->minor_version = 0; +} + +static int +FreeCompositeClientWindow (pointer value, XID ccwid) +{ + WindowPtr pWin = value; + + compFreeClientWindow (pWin, ccwid); + return Success; +} + +static int +FreeCompositeClientSubwindows (pointer value, XID ccwid) +{ + WindowPtr pWin = value; + + compFreeClientSubwindows (pWin, ccwid); + return Success; +} + +static int +FreeCompositeClientOverlay (pointer value, XID ccwid) +{ + CompOverlayClientPtr pOc = (CompOverlayClientPtr) value; + + compFreeOverlayClient (pOc); + return Success; +} + +static int +ProcCompositeQueryVersion (ClientPtr client) +{ + CompositeClientPtr pCompositeClient = GetCompositeClient (client); + xCompositeQueryVersionReply rep; + register int n; + REQUEST(xCompositeQueryVersionReq); + + REQUEST_SIZE_MATCH(xCompositeQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + if (stuff->majorVersion < SERVER_COMPOSITE_MAJOR_VERSION) { + rep.majorVersion = stuff->majorVersion; + rep.minorVersion = stuff->minorVersion; + } else { + rep.majorVersion = SERVER_COMPOSITE_MAJOR_VERSION; + rep.minorVersion = SERVER_COMPOSITE_MINOR_VERSION; + } + pCompositeClient->major_version = rep.majorVersion; + pCompositeClient->minor_version = rep.minorVersion; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.majorVersion, n); + swapl(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xCompositeQueryVersionReply), (char *)&rep); + return Success; +} + +#define VERIFY_WINDOW(pWindow, wid, client, mode) \ + do { \ + int err; \ + err = dixLookupResourceByType((pointer *) &pWindow, wid, \ + RT_WINDOW, client, mode); \ + if (err != Success) { \ + client->errorValue = wid; \ + return err; \ + } \ + } while (0) + +static int +ProcCompositeRedirectWindow (ClientPtr client) +{ + WindowPtr pWin; + REQUEST(xCompositeRedirectWindowReq); + + REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq); + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + + return compRedirectWindow (client, pWin, stuff->update); +} + +static int +ProcCompositeRedirectSubwindows (ClientPtr client) +{ + WindowPtr pWin; + REQUEST(xCompositeRedirectSubwindowsReq); + + REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq); + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + + return compRedirectSubwindows (client, pWin, stuff->update); +} + +static int +ProcCompositeUnredirectWindow (ClientPtr client) +{ + WindowPtr pWin; + REQUEST(xCompositeUnredirectWindowReq); + + REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq); + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + + return compUnredirectWindow (client, pWin, stuff->update); +} + +static int +ProcCompositeUnredirectSubwindows (ClientPtr client) +{ + WindowPtr pWin; + REQUEST(xCompositeUnredirectSubwindowsReq); + + REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq); + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + + return compUnredirectSubwindows (client, pWin, stuff->update); +} + +static int +ProcCompositeCreateRegionFromBorderClip (ClientPtr client) +{ + WindowPtr pWin; + CompWindowPtr cw; + RegionPtr pBorderClip, pRegion; + REQUEST(xCompositeCreateRegionFromBorderClipReq); + + REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq); + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); + LEGAL_NEW_RESOURCE (stuff->region, client); + + cw = GetCompWindow (pWin); + if (cw) + pBorderClip = &cw->borderClip; + else + pBorderClip = &pWin->borderClip; + pRegion = XFixesRegionCopy (pBorderClip); + if (!pRegion) + return BadAlloc; + RegionTranslate(pRegion, -pWin->drawable.x, -pWin->drawable.y); + + if (!AddResource (stuff->region, RegionResType, (pointer) pRegion)) + return BadAlloc; + + return Success; +} + +static int +ProcCompositeNameWindowPixmap (ClientPtr client) +{ + WindowPtr pWin; + CompWindowPtr cw; + PixmapPtr pPixmap; + int rc; + REQUEST(xCompositeNameWindowPixmapReq); + + REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq); + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); + + if (!pWin->viewable) + return BadMatch; + + LEGAL_NEW_RESOURCE (stuff->pixmap, client); + + cw = GetCompWindow (pWin); + if (!cw) + return BadMatch; + + pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin); + if (!pPixmap) + return BadMatch; + + /* security creation/labeling check */ + rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, RT_PIXMAP, + pPixmap, RT_WINDOW, pWin, DixCreateAccess); + if (rc != Success) + return rc; + + ++pPixmap->refcnt; + + if (!AddResource (stuff->pixmap, RT_PIXMAP, (pointer) pPixmap)) + return BadAlloc; + + return Success; +} + + +static int +ProcCompositeGetOverlayWindow (ClientPtr client) +{ + REQUEST(xCompositeGetOverlayWindowReq); + xCompositeGetOverlayWindowReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + CompScreenPtr cs; + CompOverlayClientPtr pOc; + int rc; + + REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); + pScreen = pWin->drawable.pScreen; + + /* + * Create an OverlayClient structure to mark this client's + * interest in the overlay window + */ + pOc = compCreateOverlayClient(pScreen, client); + if (pOc == NULL) + return BadAlloc; + + /* + * Make sure the overlay window exists + */ + cs = GetCompScreen(pScreen); + if (cs->pOverlayWin == NULL) + if (!compCreateOverlayWindow(pScreen)) + { + FreeResource (pOc->resource, RT_NONE); + return BadAlloc; + } + + rc = XaceHook(XACE_RESOURCE_ACCESS, client, cs->pOverlayWin->drawable.id, + RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, DixGetAttrAccess); + if (rc != Success) + { + FreeResource (pOc->resource, RT_NONE); + return rc; + } + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.overlayWin = cs->pOverlayWin->drawable.id; + + if (client->swapped) + { + int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.overlayWin, n); + } + (void) WriteToClient(client, sz_xCompositeGetOverlayWindowReply, (char *)&rep); + + return Success; +} + +static int +ProcCompositeReleaseOverlayWindow (ClientPtr client) +{ + REQUEST(xCompositeReleaseOverlayWindowReq); + WindowPtr pWin; + ScreenPtr pScreen; + CompOverlayClientPtr pOc; + + REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq); + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); + pScreen = pWin->drawable.pScreen; + + /* + * Has client queried a reference to the overlay window + * on this screen? If not, generate an error. + */ + pOc = compFindOverlayClient (pWin->drawable.pScreen, client); + if (pOc == NULL) + return BadMatch; + + /* The delete function will free the client structure */ + FreeResource (pOc->resource, RT_NONE); + + return Success; +} + +static int (*ProcCompositeVector[CompositeNumberRequests])(ClientPtr) = { + ProcCompositeQueryVersion, + ProcCompositeRedirectWindow, + ProcCompositeRedirectSubwindows, + ProcCompositeUnredirectWindow, + ProcCompositeUnredirectSubwindows, + ProcCompositeCreateRegionFromBorderClip, + ProcCompositeNameWindowPixmap, + ProcCompositeGetOverlayWindow, + ProcCompositeReleaseOverlayWindow, +}; + +static int +ProcCompositeDispatch (ClientPtr client) +{ + REQUEST(xReq); + + if (stuff->data < CompositeNumberRequests) + return (*ProcCompositeVector[stuff->data]) (client); + else + return BadRequest; +} + +static int +SProcCompositeQueryVersion (ClientPtr client) +{ + int n; + REQUEST(xCompositeQueryVersionReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xCompositeQueryVersionReq); + swapl(&stuff->majorVersion, n); + swapl(&stuff->minorVersion, n); + return (*ProcCompositeVector[stuff->compositeReqType]) (client); +} + +static int +SProcCompositeRedirectWindow (ClientPtr client) +{ + int n; + REQUEST(xCompositeRedirectWindowReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq); + swapl (&stuff->window, n); + return (*ProcCompositeVector[stuff->compositeReqType]) (client); +} + +static int +SProcCompositeRedirectSubwindows (ClientPtr client) +{ + int n; + REQUEST(xCompositeRedirectSubwindowsReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq); + swapl (&stuff->window, n); + return (*ProcCompositeVector[stuff->compositeReqType]) (client); +} + +static int +SProcCompositeUnredirectWindow (ClientPtr client) +{ + int n; + REQUEST(xCompositeUnredirectWindowReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq); + swapl (&stuff->window, n); + return (*ProcCompositeVector[stuff->compositeReqType]) (client); +} + +static int +SProcCompositeUnredirectSubwindows (ClientPtr client) +{ + int n; + REQUEST(xCompositeUnredirectSubwindowsReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq); + swapl (&stuff->window, n); + return (*ProcCompositeVector[stuff->compositeReqType]) (client); +} + +static int +SProcCompositeCreateRegionFromBorderClip (ClientPtr client) +{ + int n; + REQUEST(xCompositeCreateRegionFromBorderClipReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq); + swapl (&stuff->region, n); + swapl (&stuff->window, n); + return (*ProcCompositeVector[stuff->compositeReqType]) (client); +} + +static int +SProcCompositeNameWindowPixmap (ClientPtr client) +{ + int n; + REQUEST(xCompositeNameWindowPixmapReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq); + swapl (&stuff->window, n); + swapl (&stuff->pixmap, n); + return (*ProcCompositeVector[stuff->compositeReqType]) (client); +} + +static int +SProcCompositeGetOverlayWindow (ClientPtr client) +{ + int n; + REQUEST(xCompositeGetOverlayWindowReq); + + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); + swapl(&stuff->window, n); + return (*ProcCompositeVector[stuff->compositeReqType]) (client); +} + +static int +SProcCompositeReleaseOverlayWindow (ClientPtr client) +{ + int n; + REQUEST(xCompositeReleaseOverlayWindowReq); + + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq); + swapl(&stuff->window, n); + return (*ProcCompositeVector[stuff->compositeReqType]) (client); +} + +static int (*SProcCompositeVector[CompositeNumberRequests])(ClientPtr) = { + SProcCompositeQueryVersion, + SProcCompositeRedirectWindow, + SProcCompositeRedirectSubwindows, + SProcCompositeUnredirectWindow, + SProcCompositeUnredirectSubwindows, + SProcCompositeCreateRegionFromBorderClip, + SProcCompositeNameWindowPixmap, + SProcCompositeGetOverlayWindow, + SProcCompositeReleaseOverlayWindow, +}; + +static int +SProcCompositeDispatch (ClientPtr client) +{ + REQUEST(xReq); + + if (stuff->data < CompositeNumberRequests) + return (*SProcCompositeVector[stuff->data]) (client); + else + return BadRequest; +} + +void +CompositeExtensionInit (void) +{ + ExtensionEntry *extEntry; + int s; + + /* Assume initialization is going to fail */ + noCompositeExtension = TRUE; + + for (s = 0; s < screenInfo.numScreens; s++) { + ScreenPtr pScreen = screenInfo.screens[s]; + VisualPtr vis; + + /* Composite on 8bpp pseudocolor root windows appears to fail, so + * just disable it on anything pseudocolor for safety. + */ + for (vis = pScreen->visuals; vis->vid != pScreen->rootVisual; vis++) + ; + if ((vis->class | DynamicClass) == PseudoColor) + return; + + /* Ensure that Render is initialized, which is required for automatic + * compositing. + */ + if (GetPictureScreenIfSet(pScreen) == NULL) + return; + } + + CompositeClientWindowType = CreateNewResourceType + (FreeCompositeClientWindow, "CompositeClientWindow"); + if (!CompositeClientWindowType) + return; + + CompositeClientSubwindowsType = CreateNewResourceType + (FreeCompositeClientSubwindows, "CompositeClientSubwindows"); + if (!CompositeClientSubwindowsType) + return; + + CompositeClientOverlayType = CreateNewResourceType + (FreeCompositeClientOverlay, "CompositeClientOverlay"); + if (!CompositeClientOverlayType) + return; + + if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec, PRIVATE_CLIENT, + sizeof(CompositeClientRec))) + return; + + if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0)) + return; + + for (s = 0; s < screenInfo.numScreens; s++) + if (!compScreenInit (screenInfo.screens[s])) + return; + + extEntry = AddExtension (COMPOSITE_NAME, 0, 0, + ProcCompositeDispatch, SProcCompositeDispatch, + NULL, StandardMinorOpcode); + if (!extEntry) + return; + CompositeReqCode = (CARD8) extEntry->base; + + miRegisterRedirectBorderClipProc (compSetRedirectBorderClip, + compGetRedirectBorderClip); + + /* Initialization succeeded */ + noCompositeExtension = FALSE; +} + +#ifdef PANORAMIX +#include "panoramiXsrv.h" + +int (*PanoramiXSaveCompositeVector[CompositeNumberRequests]) (ClientPtr); + +static int +PanoramiXCompositeRedirectWindow (ClientPtr client) +{ + PanoramiXRes *win; + int rc = 0, j; + REQUEST(xCompositeRedirectWindowReq); + + REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq); + + if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, + client, DixUnknownAccess))) { + client->errorValue = stuff->window; + return rc; + } + + FOR_NSCREENS_FORWARD(j) { + stuff->window = win->info[j].id; + rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); + if (rc != Success) break; + } + + return rc; +} + +static int +PanoramiXCompositeRedirectSubwindows (ClientPtr client) +{ + PanoramiXRes *win; + int rc = 0, j; + REQUEST(xCompositeRedirectSubwindowsReq); + + REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq); + + if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, + client, DixUnknownAccess))) { + client->errorValue = stuff->window; + return rc; + } + + FOR_NSCREENS_FORWARD(j) { + stuff->window = win->info[j].id; + rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); + if (rc != Success) break; + } + + return rc; +} + +static int +PanoramiXCompositeUnredirectWindow (ClientPtr client) +{ + PanoramiXRes *win; + int rc = 0, j; + REQUEST(xCompositeUnredirectWindowReq); + + REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq); + + if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, + client, DixUnknownAccess))) { + client->errorValue = stuff->window; + return rc; + } + + FOR_NSCREENS_FORWARD(j) { + stuff->window = win->info[j].id; + rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); + if (rc != Success) break; + } + + return rc; +} + +static int +PanoramiXCompositeUnredirectSubwindows (ClientPtr client) +{ + PanoramiXRes *win; + int rc = 0, j; + REQUEST(xCompositeUnredirectSubwindowsReq); + + REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq); + + if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, + client, DixUnknownAccess))) { + client->errorValue = stuff->window; + return rc; + } + + FOR_NSCREENS_FORWARD(j) { + stuff->window = win->info[j].id; + rc = (*PanoramiXSaveCompositeVector[stuff->compositeReqType]) (client); + if (rc != Success) break; + } + + return rc; +} + +static int +PanoramiXCompositeNameWindowPixmap (ClientPtr client) +{ + WindowPtr pWin; + CompWindowPtr cw; + PixmapPtr pPixmap; + int rc; + PanoramiXRes *win, *newPix; + int i; + REQUEST(xCompositeNameWindowPixmapReq); + + REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq); + + if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, + client, DixUnknownAccess))) { + client->errorValue = stuff->window; + return rc; + } + + LEGAL_NEW_RESOURCE (stuff->pixmap, client); + + if(!(newPix = malloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newPix->type = XRT_PIXMAP; + newPix->u.pix.shared = FALSE; + panoramix_setup_ids(newPix, client, stuff->pixmap); + + FOR_NSCREENS(i) { + rc = dixLookupResourceByType ((void **) &pWin, win->info[i].id, + RT_WINDOW, client, DixGetAttrAccess); + if (rc != Success) + { + client->errorValue = stuff->window; + free (newPix); + return rc; + } + + if (!pWin->viewable) + { + free (newPix); + return BadMatch; + } + + cw = GetCompWindow (pWin); + if (!cw) + { + free (newPix); + return BadMatch; + } + + pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin); + if (!pPixmap) + { + free (newPix); + return BadMatch; + } + + if (!AddResource (newPix->info[i].id, RT_PIXMAP, + (pointer) pPixmap)) + return BadAlloc; + + ++pPixmap->refcnt; + } + + if (!AddResource (stuff->pixmap, XRT_PIXMAP, (pointer) newPix)) + return BadAlloc; + + return Success; +} + + +static int +PanoramiXCompositeGetOverlayWindow (ClientPtr client) +{ + REQUEST(xCompositeGetOverlayWindowReq); + xCompositeGetOverlayWindowReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + CompScreenPtr cs; + CompOverlayClientPtr pOc; + int rc; + PanoramiXRes *win, *overlayWin = NULL; + int i; + + REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); + + if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, + client, DixUnknownAccess))) { + client->errorValue = stuff->window; + return rc; + } + + cs = GetCompScreen(screenInfo.screens[0]); + if (!cs->pOverlayWin) + { + if(!(overlayWin = malloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + overlayWin->type = XRT_WINDOW; + overlayWin->u.win.root = FALSE; + } + + FOR_NSCREENS_BACKWARD(i) { + rc = dixLookupResourceByType((pointer *)&pWin, win->info[i].id, + RT_WINDOW, client, DixGetAttrAccess); + if (rc != Success) + { + client->errorValue = stuff->window; + return rc; + } + pScreen = pWin->drawable.pScreen; + + /* + * Create an OverlayClient structure to mark this client's + * interest in the overlay window + */ + pOc = compCreateOverlayClient(pScreen, client); + if (pOc == NULL) + return BadAlloc; + + /* + * Make sure the overlay window exists + */ + cs = GetCompScreen(pScreen); + if (cs->pOverlayWin == NULL) + if (!compCreateOverlayWindow(pScreen)) + { + FreeResource (pOc->resource, RT_NONE); + return BadAlloc; + } + + rc = XaceHook(XACE_RESOURCE_ACCESS, client, + cs->pOverlayWin->drawable.id, + RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, + DixGetAttrAccess); + if (rc != Success) + { + FreeResource (pOc->resource, RT_NONE); + return rc; + } + } + + if (overlayWin) + { + FOR_NSCREENS(i) { + cs = GetCompScreen(screenInfo.screens[i]); + overlayWin->info[i].id = cs->pOverlayWin->drawable.id; + } + + AddResource(overlayWin->info[0].id, XRT_WINDOW, overlayWin); + } + + cs = GetCompScreen(screenInfo.screens[0]); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.overlayWin = cs->pOverlayWin->drawable.id; + + if (client->swapped) + { + int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.overlayWin, n); + } + (void) WriteToClient(client, sz_xCompositeGetOverlayWindowReply, (char *)&rep); + + return Success; +} + +static int +PanoramiXCompositeReleaseOverlayWindow (ClientPtr client) +{ + REQUEST(xCompositeReleaseOverlayWindowReq); + WindowPtr pWin; + ScreenPtr pScreen; + CompOverlayClientPtr pOc; + PanoramiXRes *win; + int i, rc; + + REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq); + + if ((rc = dixLookupResourceByType((void **)&win, stuff->window, XRT_WINDOW, + client, DixUnknownAccess))) { + client->errorValue = stuff->window; + return rc; + } + + FOR_NSCREENS_BACKWARD(i) { + if ((rc = dixLookupResourceByType((void **)&pWin, win->info[i].id, + XRT_WINDOW, client, + DixUnknownAccess))) { + client->errorValue = stuff->window; + return rc; + } + pScreen = pWin->drawable.pScreen; + + /* + * Has client queried a reference to the overlay window + * on this screen? If not, generate an error. + */ + pOc = compFindOverlayClient (pWin->drawable.pScreen, client); + if (pOc == NULL) + return BadMatch; + + /* The delete function will free the client structure */ + FreeResource (pOc->resource, RT_NONE); + } + + return Success; +} + +void +PanoramiXCompositeInit (void) +{ + int i; + + for (i = 0; i < CompositeNumberRequests; i++) + PanoramiXSaveCompositeVector[i] = ProcCompositeVector[i]; + /* + * Stuff in Xinerama aware request processing hooks + */ + ProcCompositeVector[X_CompositeRedirectWindow] = + PanoramiXCompositeRedirectWindow; + ProcCompositeVector[X_CompositeRedirectSubwindows] = + PanoramiXCompositeRedirectSubwindows; + ProcCompositeVector[X_CompositeUnredirectWindow] = + PanoramiXCompositeUnredirectWindow; + ProcCompositeVector[X_CompositeUnredirectSubwindows] = + PanoramiXCompositeUnredirectSubwindows; + ProcCompositeVector[X_CompositeNameWindowPixmap] = + PanoramiXCompositeNameWindowPixmap; + ProcCompositeVector[X_CompositeGetOverlayWindow] = + PanoramiXCompositeGetOverlayWindow; + ProcCompositeVector[X_CompositeReleaseOverlayWindow] = + PanoramiXCompositeReleaseOverlayWindow; +} + +void +PanoramiXCompositeReset (void) +{ + int i; + + for (i = 0; i < CompositeNumberRequests; i++) + ProcCompositeVector[i] = PanoramiXSaveCompositeVector[i]; +} + +#endif diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c index df62e839b..8835c5e61 100644 --- a/xorg-server/dix/events.c +++ b/xorg-server/dix/events.c @@ -558,7 +558,7 @@ XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin) if(pWin == screenInfo.screens[0]->root) { int i; - for (i = 0; i < PanoramiXNumScreens; i++) + FOR_NSCREENS(i) pSprite->windows[i] = screenInfo.screens[i]->root; } else { PanoramiXRes *win; @@ -569,7 +569,7 @@ XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin) if (rc != Success) return FALSE; - for(i = 0; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS(i) { rc = dixLookupWindow(pSprite->windows + i, win->info[i].id, serverClient, DixReadAccess); if (rc != Success) /* window is being unmapped */ @@ -2554,7 +2554,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y) SpritePtr pSprite = inputInfo.pointer->spriteInfo->sprite; int i; - for(i = 1; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS_FORWARD_SKIP(i) { if(RegionContainsPoint(&pSprite->windows[i]->borderSize, x + screenInfo.screens[0]->x - screenInfo.screens[i]->x, y + screenInfo.screens[0]->y - screenInfo.screens[i]->y, @@ -3153,7 +3153,7 @@ XineramaPointInWindowIsVisible( xoff = x + screenInfo.screens[0]->x; yoff = y + screenInfo.screens[0]->y; - for(i = 1; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS_FORWARD_SKIP(i) { pWin = inputInfo.pointer->spriteInfo->sprite->windows[i]; x = xoff - screenInfo.screens[i]->x; y = yoff - screenInfo.screens[i]->y; @@ -3360,7 +3360,7 @@ BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin) if(!noPanoramiXExtension && XineramaSetWindowPntrs(pDev, pWin)) { int i; - for(i = 1; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS_FORWARD_SKIP(i) { if(RegionNotEmpty(&pDev->spriteInfo->sprite->windows[i]->borderSize)) return TRUE; } diff --git a/xorg-server/dix/window.c b/xorg-server/dix/window.c index c2cee9198..3668370b3 100644 --- a/xorg-server/dix/window.c +++ b/xorg-server/dix/window.c @@ -1,3686 +1,3686 @@ -/* - -Copyright (c) 2006, Red Hat, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -*/ - -/* The panoramix components contained the following notice */ -/***************************************************************** - -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. - -******************************************************************/ - - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "misc.h" -#include "scrnintstr.h" -#include "os.h" -#include "regionstr.h" -#include "validate.h" -#include "windowstr.h" -#include "input.h" -#include "inputstr.h" -#include "resource.h" -#include "colormapst.h" -#include "cursorstr.h" -#include "dixstruct.h" -#include "gcstruct.h" -#include "servermd.h" -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" -#endif -#include "dixevents.h" -#include "globals.h" -#include "mi.h" /* miPaintWindow */ - -#include "privates.h" -#include "xace.h" - -/****** - * Window stuff for server - * - * CreateRootWindow, CreateWindow, ChangeWindowAttributes, - * GetWindowAttributes, DeleteWindow, DestroySubWindows, - * HandleSaveSet, ReparentWindow, MapWindow, MapSubWindows, - * UnmapWindow, UnmapSubWindows, ConfigureWindow, CirculateWindow, - * ChangeWindowDeviceCursor - ******/ - -Bool bgNoneRoot = FALSE; - -static unsigned char _back_lsb[4] = {0x88, 0x22, 0x44, 0x11}; -static unsigned char _back_msb[4] = {0x11, 0x44, 0x22, 0x88}; - -static Bool WindowParentHasDeviceCursor(WindowPtr pWin, - DeviceIntPtr pDev, - CursorPtr pCurs); -static Bool -WindowSeekDeviceCursor(WindowPtr pWin, - DeviceIntPtr pDev, - DevCursNodePtr* pNode, - DevCursNodePtr* pPrev); - -int screenIsSaved = SCREEN_SAVER_OFF; - -static Bool TileScreenSaver(ScreenPtr pScreen, int kind); - -#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \ - CWDontPropagate | CWOverrideRedirect | CWCursor ) - -#define BOXES_OVERLAP(b1, b2) \ - (!( ((b1)->x2 <= (b2)->x1) || \ - ( ((b1)->x1 >= (b2)->x2)) || \ - ( ((b1)->y2 <= (b2)->y1)) || \ - ( ((b1)->y1 >= (b2)->y2)) ) ) - -#define RedirectSend(pWin) \ - ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureRedirectMask) - -#define SubSend(pWin) \ - ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureNotifyMask) - -#define StrSend(pWin) \ - ((pWin->eventMask|wOtherEventMasks(pWin)) & StructureNotifyMask) - -#define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent)) - -#ifdef DEBUG -/****** - * PrintWindowTree - * For debugging only - ******/ - -static void -PrintChildren(WindowPtr p1, int indent) -{ - WindowPtr p2; - int i; - - while (p1) - { - p2 = p1->firstChild; - ErrorF("[dix] "); - for (i=0; idrawable.id); - RegionPrint(&p1->clipList); - PrintChildren(p2, indent+4); - p1 = p1->nextSib; - } -} - -static void -PrintWindowTree(void) -{ - int i; - WindowPtr pWin, p1; - - for (i=0; iroot; - RegionPrint(&pWin->clipList); - p1 = pWin->firstChild; - PrintChildren(p1, 4); - } -} -#endif - -int -TraverseTree(WindowPtr pWin, VisitWindowProcPtr func, pointer data) -{ - int result; - WindowPtr pChild; - - if (!(pChild = pWin)) - return WT_NOMATCH; - while (1) - { - result = (* func)(pChild, data); - if (result == WT_STOPWALKING) - return WT_STOPWALKING; - if ((result == WT_WALKCHILDREN) && pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - while (!pChild->nextSib && (pChild != pWin)) - pChild = pChild->parent; - if (pChild == pWin) - break; - pChild = pChild->nextSib; - } - return WT_NOMATCH; -} - -/***** - * WalkTree - * Walk the window tree, for SCREEN, preforming FUNC(pWin, data) on - * each window. If FUNC returns WT_WALKCHILDREN, traverse the children, - * if it returns WT_DONTWALKCHILDREN, dont. If it returns WT_STOPWALKING - * exit WalkTree. Does depth-first traverse. - *****/ - -int -WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, pointer data) -{ - return(TraverseTree(pScreen->root, func, data)); -} - -/* hack for forcing backing store on all windows */ -int defaultBackingStore = NotUseful; -/* hack to force no backing store */ -Bool disableBackingStore = FALSE; -Bool enableBackingStore = FALSE; - -static void -SetWindowToDefaults(WindowPtr pWin) -{ - pWin->prevSib = NullWindow; - pWin->firstChild = NullWindow; - pWin->lastChild = NullWindow; - - pWin->valdata = (ValidatePtr)NULL; - pWin->optional = (WindowOptPtr)NULL; - pWin->cursorIsNone = TRUE; - - pWin->backingStore = NotUseful; - pWin->DIXsaveUnder = FALSE; - pWin->backStorage = (pointer) NULL; - - pWin->mapped = FALSE; /* off */ - pWin->realized = FALSE; /* off */ - pWin->viewable = FALSE; - pWin->visibility = VisibilityNotViewable; - pWin->overrideRedirect = FALSE; - pWin->saveUnder = FALSE; - - pWin->bitGravity = ForgetGravity; - pWin->winGravity = NorthWestGravity; - - pWin->eventMask = 0; - pWin->deliverableEvents = 0; - pWin->dontPropagate = 0; - pWin->forcedBS = FALSE; - pWin->redirectDraw = RedirectDrawNone; - pWin->forcedBG = FALSE; - -#ifdef ROOTLESS - pWin->rootlessUnhittable = FALSE; -#endif - -#ifdef COMPOSITE - pWin->damagedDescendants = FALSE; -#endif -} - -static void -MakeRootTile(WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - GCPtr pGC; - unsigned char back[128]; - int len = BitmapBytePad(sizeof(long)); - unsigned char *from, *to; - int i, j; - - pWin->background.pixmap = (*pScreen->CreatePixmap)(pScreen, 4, 4, - pScreen->rootDepth, 0); - - pWin->backgroundState = BackgroundPixmap; - pGC = GetScratchGC(pScreen->rootDepth, pScreen); - if (!pWin->background.pixmap || !pGC) - FatalError("could not create root tile"); - - { - ChangeGCVal attributes[2]; - - attributes[0].val = pScreen->whitePixel; - attributes[1].val = pScreen->blackPixel; - - (void)ChangeGC(NullClient, pGC, GCForeground | GCBackground, attributes); - } - - ValidateGC((DrawablePtr)pWin->background.pixmap, pGC); - - from = (screenInfo.bitmapBitOrder == LSBFirst) ? _back_lsb : _back_msb; - to = back; - - for (i = 4; i > 0; i--, from++) - for (j = len; j > 0; j--) - *to++ = *from; - - (*pGC->ops->PutImage)((DrawablePtr)pWin->background.pixmap, pGC, 1, - 0, 0, len, 4, 0, XYBitmap, (char *)back); - - FreeScratchGC(pGC); - -} - -/***** - * CreateRootWindow - * Makes a window at initialization time for specified screen - *****/ - -Bool -CreateRootWindow(ScreenPtr pScreen) -{ - WindowPtr pWin; - BoxRec box; - PixmapFormatRec *format; - - pWin = dixAllocateObjectWithPrivates(WindowRec, PRIVATE_WINDOW); - if (!pWin) - return FALSE; - - pScreen->screensaver.pWindow = NULL; - pScreen->screensaver.wid = FakeClientID(0); - pScreen->screensaver.ExternalScreenSaver = NULL; - screenIsSaved = SCREEN_SAVER_OFF; - - pScreen->root = pWin; - - pWin->drawable.pScreen = pScreen; - pWin->drawable.type = DRAWABLE_WINDOW; - - pWin->drawable.depth = pScreen->rootDepth; - for (format = screenInfo.formats; - format->depth != pScreen->rootDepth; - format++) - ; - pWin->drawable.bitsPerPixel = format->bitsPerPixel; - - pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER; - - pWin->parent = NullWindow; - SetWindowToDefaults(pWin); - - pWin->optional = malloc(sizeof (WindowOptRec)); - if (!pWin->optional) - return FALSE; - - pWin->optional->dontPropagateMask = 0; - pWin->optional->otherEventMasks = 0; - pWin->optional->otherClients = NULL; - pWin->optional->passiveGrabs = NULL; - pWin->optional->userProps = NULL; - pWin->optional->backingBitPlanes = ~0L; - pWin->optional->backingPixel = 0; - pWin->optional->boundingShape = NULL; - pWin->optional->clipShape = NULL; - pWin->optional->inputShape = NULL; - pWin->optional->inputMasks = NULL; - pWin->optional->deviceCursors = NULL; - pWin->optional->colormap = pScreen->defColormap; - pWin->optional->visual = pScreen->rootVisual; - - pWin->nextSib = NullWindow; - - pWin->drawable.id = FakeClientID(0); - - pWin->origin.x = pWin->origin.y = 0; - pWin->drawable.height = pScreen->height; - pWin->drawable.width = pScreen->width; - pWin->drawable.x = pWin->drawable.y = 0; - - box.x1 = 0; - box.y1 = 0; - box.x2 = pScreen->width; - box.y2 = pScreen->height; - RegionInit(&pWin->clipList, &box, 1); - RegionInit(&pWin->winSize, &box, 1); - RegionInit(&pWin->borderSize, &box, 1); - RegionInit(&pWin->borderClip, &box, 1); - - pWin->drawable.class = InputOutput; - pWin->optional->visual = pScreen->rootVisual; - - pWin->backgroundState = BackgroundPixel; - pWin->background.pixel = pScreen->whitePixel; - - pWin->borderIsPixel = TRUE; - pWin->border.pixel = pScreen->blackPixel; - pWin->borderWidth = 0; - - /* security creation/labeling check - */ - if (XaceHook(XACE_RESOURCE_ACCESS, serverClient, pWin->drawable.id, - RT_WINDOW, pWin, RT_NONE, NULL, DixCreateAccess)) - return FALSE; - - if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer)pWin)) - return FALSE; - - if (disableBackingStore) - pScreen->backingStoreSupport = NotUseful; - if (enableBackingStore) - pScreen->backingStoreSupport = Always; - - pScreen->saveUnderSupport = NotUseful; - - return TRUE; -} - -void -InitRootWindow(WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - int backFlag = CWBorderPixel | CWCursor | CWBackingStore; - - if (!(*pScreen->CreateWindow)(pWin)) - return; /* XXX */ - (*pScreen->PositionWindow)(pWin, 0, 0); - - pWin->cursorIsNone = FALSE; - pWin->optional->cursor = rootCursor; - rootCursor->refcnt++; - - - if (party_like_its_1989) { - MakeRootTile(pWin); - backFlag |= CWBackPixmap; - } else if (pScreen->canDoBGNoneRoot && bgNoneRoot) { - pWin->backgroundState = XaceBackgroundNoneState(pWin); - pWin->background.pixel = pScreen->whitePixel; - backFlag |= CWBackPixmap; - } else { - if (whiteRoot) - pWin->background.pixel = pScreen->whitePixel; - else - pWin->background.pixel = pScreen->blackPixel; - backFlag |= CWBackPixel; - } - - pWin->backingStore = defaultBackingStore; - pWin->forcedBS = (defaultBackingStore != NotUseful); - /* We SHOULD check for an error value here XXX */ - (*pScreen->ChangeWindowAttributes)(pWin, backFlag); - - MapWindow(pWin, serverClient); -} - -/* Set the region to the intersection of the rectangle and the - * window's winSize. The window is typically the parent of the - * window from which the region came. - */ - -static void -ClippedRegionFromBox(WindowPtr pWin, RegionPtr Rgn, - int x, int y, - int w, int h) -{ - BoxRec box = *RegionExtents(&pWin->winSize); - - /* we do these calculations to avoid overflows */ - if (x > box.x1) - box.x1 = x; - if (y > box.y1) - box.y1 = y; - x += w; - if (x < box.x2) - box.x2 = x; - y += h; - if (y < box.y2) - box.y2 = y; - if (box.x1 > box.x2) - box.x2 = box.x1; - if (box.y1 > box.y2) - box.y2 = box.y1; - RegionReset(Rgn, &box); - RegionIntersect(Rgn, Rgn, &pWin->winSize); -} - -static RealChildHeadProc realChildHeadProc = NULL; - -void -RegisterRealChildHeadProc (RealChildHeadProc proc) -{ - realChildHeadProc = proc; -} - - -WindowPtr -RealChildHead(WindowPtr pWin) -{ - if (realChildHeadProc) { - return realChildHeadProc (pWin); - } - - if (!pWin->parent && - (screenIsSaved == SCREEN_SAVER_ON) && - (HasSaverWindow (pWin->drawable.pScreen))) - return pWin->firstChild; - else - return NullWindow; -} - -/***** - * CreateWindow - * Makes a window in response to client request - *****/ - -WindowPtr -CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w, - unsigned h, unsigned bw, unsigned class, Mask vmask, XID *vlist, - int depth, ClientPtr client, VisualID visual, int *error) -{ - WindowPtr pWin; - WindowPtr pHead; - ScreenPtr pScreen; - xEvent event; - int idepth, ivisual; - Bool fOK; - DepthPtr pDepth; - PixmapFormatRec *format; - WindowOptPtr ancwopt; - - if (class == CopyFromParent) - class = pParent->drawable.class; - - if ((class != InputOutput) && (class != InputOnly)) - { - *error = BadValue; - client->errorValue = class; - return NullWindow; - } - - if ((class != InputOnly) && (pParent->drawable.class == InputOnly)) - { - *error = BadMatch; - return NullWindow; - } - - if ((class == InputOnly) && ((bw != 0) || (depth != 0))) - { - *error = BadMatch; - return NullWindow; - } - - pScreen = pParent->drawable.pScreen; - if ((class == InputOutput) && (depth == 0)) - depth = pParent->drawable.depth; - ancwopt = pParent->optional; - if (!ancwopt) - ancwopt = FindWindowWithOptional(pParent)->optional; - if (visual == CopyFromParent) { - visual = ancwopt->visual; - } - - /* Find out if the depth and visual are acceptable for this Screen */ - if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth)) - { - fOK = FALSE; - for(idepth = 0; idepth < pScreen->numDepths; idepth++) - { - pDepth = (DepthPtr) &pScreen->allowedDepths[idepth]; - if ((depth == pDepth->depth) || (depth == 0)) - { - for (ivisual = 0; ivisual < pDepth->numVids; ivisual++) - { - if (visual == pDepth->vids[ivisual]) - { - fOK = TRUE; - break; - } - } - } - } - if (fOK == FALSE) - { - *error = BadMatch; - return NullWindow; - } - } - - if (((vmask & (CWBorderPixmap | CWBorderPixel)) == 0) && - (class != InputOnly) && - (depth != pParent->drawable.depth)) - { - *error = BadMatch; - return NullWindow; - } - - if (((vmask & CWColormap) == 0) && - (class != InputOnly) && - ((visual != ancwopt->visual) || (ancwopt->colormap == None))) - { - *error = BadMatch; - return NullWindow; - } - - pWin = dixAllocateObjectWithPrivates(WindowRec, PRIVATE_WINDOW); - if (!pWin) - { - *error = BadAlloc; - return NullWindow; - } - pWin->drawable = pParent->drawable; - pWin->drawable.depth = depth; - if (depth == pParent->drawable.depth) - pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel; - else - { - for (format = screenInfo.formats; format->depth != depth; format++) - ; - pWin->drawable.bitsPerPixel = format->bitsPerPixel; - } - if (class == InputOnly) - pWin->drawable.type = (short) UNDRAWABLE_WINDOW; - pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER; - - pWin->drawable.id = wid; - pWin->drawable.class = class; - - pWin->parent = pParent; - SetWindowToDefaults(pWin); - - if (visual != ancwopt->visual) - { - if (!MakeWindowOptional (pWin)) - { - dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW); - *error = BadAlloc; - return NullWindow; - } - pWin->optional->visual = visual; - pWin->optional->colormap = None; - } - - pWin->borderWidth = bw; - - /* security creation/labeling check - */ - *error = XaceHook(XACE_RESOURCE_ACCESS, client, wid, RT_WINDOW, pWin, - RT_WINDOW, pWin->parent, DixCreateAccess|DixSetAttrAccess); - if (*error != Success) { - dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW); - return NullWindow; - } - - pWin->backgroundState = XaceBackgroundNoneState(pWin); - pWin->background.pixel = pScreen->whitePixel; - - pWin->borderIsPixel = pParent->borderIsPixel; - pWin->border = pParent->border; - if (pWin->borderIsPixel == FALSE) - pWin->border.pixmap->refcnt++; - - pWin->origin.x = x + (int)bw; - pWin->origin.y = y + (int)bw; - pWin->drawable.width = w; - pWin->drawable.height = h; - pWin->drawable.x = pParent->drawable.x + x + (int)bw; - pWin->drawable.y = pParent->drawable.y + y + (int)bw; - - /* set up clip list correctly for unobscured WindowPtr */ - RegionNull(&pWin->clipList); - RegionNull(&pWin->borderClip); - RegionNull(&pWin->winSize); - RegionNull(&pWin->borderSize); - - pHead = RealChildHead(pParent); - if (pHead) - { - pWin->nextSib = pHead->nextSib; - if (pHead->nextSib) - pHead->nextSib->prevSib = pWin; - else - pParent->lastChild = pWin; - pHead->nextSib = pWin; - pWin->prevSib = pHead; - } - else - { - pWin->nextSib = pParent->firstChild; - if (pParent->firstChild) - pParent->firstChild->prevSib = pWin; - else - pParent->lastChild = pWin; - pParent->firstChild = pWin; - } - - SetWinSize (pWin); - SetBorderSize (pWin); - - /* We SHOULD check for an error value here XXX */ - if (!(*pScreen->CreateWindow)(pWin)) - { - *error = BadAlloc; - DeleteWindow(pWin, None); - return NullWindow; - } - /* We SHOULD check for an error value here XXX */ - (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y); - - if (!(vmask & CWEventMask)) - RecalculateDeliverableEvents(pWin); - - if (vmask) - *error = ChangeWindowAttributes(pWin, vmask, vlist, wClient (pWin)); - else - *error = Success; - - if (*error != Success) - { - DeleteWindow(pWin, None); - return NullWindow; - } - if (!(vmask & CWBackingStore) && (defaultBackingStore != NotUseful)) - { - XID value = defaultBackingStore; - (void)ChangeWindowAttributes(pWin, CWBackingStore, &value, wClient (pWin)); - pWin->forcedBS = TRUE; - } - - if (SubSend(pParent)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = CreateNotify; - event.u.createNotify.window = wid; - event.u.createNotify.parent = pParent->drawable.id; - event.u.createNotify.x = x; - event.u.createNotify.y = y; - event.u.createNotify.width = w; - event.u.createNotify.height = h; - event.u.createNotify.borderWidth = bw; - event.u.createNotify.override = pWin->overrideRedirect; - DeliverEvents(pParent, &event, 1, NullWindow); - } - return pWin; -} - -static void -DisposeWindowOptional (WindowPtr pWin) -{ - if (!pWin->optional) - return; - /* - * everything is peachy. Delete the optional record - * and clean up - */ - if (pWin->optional->cursor) - { - FreeCursor (pWin->optional->cursor, (Cursor)0); - pWin->cursorIsNone = FALSE; - } - else - pWin->cursorIsNone = TRUE; - - if (pWin->optional->deviceCursors) - { - DevCursorList pList; - DevCursorList pPrev; - pList = pWin->optional->deviceCursors; - while(pList) - { - if (pList->cursor) - FreeCursor(pList->cursor, (XID)0); - pPrev = pList; - pList = pList->next; - free(pPrev); - } - pWin->optional->deviceCursors = NULL; - } - - free(pWin->optional); - pWin->optional = NULL; -} - -static void -FreeWindowResources(WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - - DeleteWindowFromAnySaveSet(pWin); - DeleteWindowFromAnySelections(pWin); - DeleteWindowFromAnyEvents(pWin, TRUE); - RegionUninit(&pWin->clipList); - RegionUninit(&pWin->winSize); - RegionUninit(&pWin->borderClip); - RegionUninit(&pWin->borderSize); - if (wBoundingShape (pWin)) - RegionDestroy(wBoundingShape (pWin)); - if (wClipShape (pWin)) - RegionDestroy(wClipShape (pWin)); - if (wInputShape (pWin)) - RegionDestroy(wInputShape (pWin)); - if (pWin->borderIsPixel == FALSE) - (*pScreen->DestroyPixmap)(pWin->border.pixmap); - if (pWin->backgroundState == BackgroundPixmap) - (*pScreen->DestroyPixmap)(pWin->background.pixmap); - - DeleteAllWindowProperties(pWin); - /* We SHOULD check for an error value here XXX */ - (*pScreen->DestroyWindow)(pWin); - DisposeWindowOptional (pWin); -} - -static void -CrushTree(WindowPtr pWin) -{ - WindowPtr pChild, pSib, pParent; - UnrealizeWindowProcPtr UnrealizeWindow; - xEvent event; - - if (!(pChild = pWin->firstChild)) - return; - UnrealizeWindow = pWin->drawable.pScreen->UnrealizeWindow; - while (1) - { - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - while (1) - { - pParent = pChild->parent; - if (SubStrSend(pChild, pParent)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = DestroyNotify; - event.u.destroyNotify.window = pChild->drawable.id; - DeliverEvents(pChild, &event, 1, NullWindow); - } - FreeResource(pChild->drawable.id, RT_WINDOW); - pSib = pChild->nextSib; - pChild->viewable = FALSE; - if (pChild->realized) - { - pChild->realized = FALSE; - (*UnrealizeWindow)(pChild); - } - FreeWindowResources(pChild); - dixFreeObjectWithPrivates(pChild, PRIVATE_WINDOW); - if ( (pChild = pSib) ) - break; - pChild = pParent; - pChild->firstChild = NullWindow; - pChild->lastChild = NullWindow; - if (pChild == pWin) - return; - } - } -} - -/***** - * DeleteWindow - * Deletes child of window then window itself - * If wid is None, don't send any events - *****/ - -int -DeleteWindow(pointer value, XID wid) - { - WindowPtr pParent; - WindowPtr pWin = (WindowPtr)value; - xEvent event; - - UnmapWindow(pWin, FALSE); - - CrushTree(pWin); - - pParent = pWin->parent; - if (wid && pParent && SubStrSend(pWin, pParent)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = DestroyNotify; - event.u.destroyNotify.window = pWin->drawable.id; - DeliverEvents(pWin, &event, 1, NullWindow); - } - - FreeWindowResources(pWin); - if (pParent) - { - if (pParent->firstChild == pWin) - pParent->firstChild = pWin->nextSib; - if (pParent->lastChild == pWin) - pParent->lastChild = pWin->prevSib; - if (pWin->nextSib) - pWin->nextSib->prevSib = pWin->prevSib; - if (pWin->prevSib) - pWin->prevSib->nextSib = pWin->nextSib; - } - else - pWin->drawable.pScreen->root = NULL; - dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW); - return Success; -} - -int -DestroySubwindows(WindowPtr pWin, ClientPtr client) -{ - /* XXX - * The protocol is quite clear that each window should be - * destroyed in turn, however, unmapping all of the first - * eliminates most of the calls to ValidateTree. So, - * this implementation is incorrect in that all of the - * UnmapNotifies occur before all of the DestroyNotifies. - * If you care, simply delete the call to UnmapSubwindows. - */ - UnmapSubwindows(pWin); - while (pWin->lastChild) { - int rc = XaceHook(XACE_RESOURCE_ACCESS, client, - pWin->lastChild->drawable.id, RT_WINDOW, - pWin->lastChild, RT_NONE, NULL, DixDestroyAccess); - if (rc != Success) - return rc; - FreeResource(pWin->lastChild->drawable.id, RT_NONE); - } - return Success; -} - -static void -SetRootWindowBackground(WindowPtr pWin, ScreenPtr pScreen, Mask *index2) -{ - /* following the protocol: "Changing the background of a root window to - * None or ParentRelative restores the default background pixmap" */ - if (bgNoneRoot) { - pWin->backgroundState = XaceBackgroundNoneState(pWin); - pWin->background.pixel = pScreen->whitePixel; - } - else if (party_like_its_1989) - MakeRootTile(pWin); - else { - if (whiteRoot) - pWin->background.pixel = pScreen->whitePixel; - else - pWin->background.pixel = pScreen->blackPixel; - *index2 = CWBackPixel; - } -} - -/***** - * ChangeWindowAttributes - * - * The value-mask specifies which attributes are to be changed; the - * value-list contains one value for each one bit in the mask, from least - * to most significant bit in the mask. - *****/ - -int -ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) -{ - XID *pVlist; - PixmapPtr pPixmap; - Pixmap pixID; - CursorPtr pCursor, pOldCursor; - Cursor cursorID; - WindowPtr pChild; - Colormap cmap; - ColormapPtr pCmap; - xEvent xE; - int error, rc; - ScreenPtr pScreen; - Mask index2, tmask, vmaskCopy = 0; - unsigned int val; - Bool checkOptional = FALSE, borderRelative = FALSE; - - if ((pWin->drawable.class == InputOnly) && (vmask & (~INPUTONLY_LEGAL_MASK))) - return BadMatch; - - error = Success; - pScreen = pWin->drawable.pScreen; - pVlist = vlist; - tmask = vmask; - while (tmask) - { - index2 = (Mask) lowbit (tmask); - tmask &= ~index2; - switch (index2) - { - case CWBackPixmap: - pixID = (Pixmap )*pVlist; - pVlist++; - if (pWin->backgroundState == ParentRelative) - borderRelative = TRUE; - if (pixID == None) - { - if (pWin->backgroundState == BackgroundPixmap) - (*pScreen->DestroyPixmap)(pWin->background.pixmap); - if (!pWin->parent) - SetRootWindowBackground(pWin, pScreen, &index2); - else { - pWin->backgroundState = XaceBackgroundNoneState(pWin); - pWin->background.pixel = pScreen->whitePixel; - } - } - else if (pixID == ParentRelative) - { - if (pWin->parent && - pWin->drawable.depth != pWin->parent->drawable.depth) - { - error = BadMatch; - goto PatchUp; - } - if (pWin->backgroundState == BackgroundPixmap) - (*pScreen->DestroyPixmap)(pWin->background.pixmap); - if (!pWin->parent) - SetRootWindowBackground(pWin, pScreen, &index2); - else - pWin->backgroundState = ParentRelative; - borderRelative = TRUE; - /* Note that the parent's backgroundTile's refcnt is NOT - * incremented. */ - } - else - { - rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP, - client, DixReadAccess); - if (rc == Success) - { - if ((pPixmap->drawable.depth != pWin->drawable.depth) || - (pPixmap->drawable.pScreen != pScreen)) - { - error = BadMatch; - goto PatchUp; - } - if (pWin->backgroundState == BackgroundPixmap) - (*pScreen->DestroyPixmap)(pWin->background.pixmap); - pWin->backgroundState = BackgroundPixmap; - pWin->background.pixmap = pPixmap; - pPixmap->refcnt++; - } - else - { - error = rc; - client->errorValue = pixID; - goto PatchUp; - } - } - break; - case CWBackPixel: - if (pWin->backgroundState == ParentRelative) - borderRelative = TRUE; - if (pWin->backgroundState == BackgroundPixmap) - (*pScreen->DestroyPixmap)(pWin->background.pixmap); - pWin->backgroundState = BackgroundPixel; - pWin->background.pixel = (CARD32 ) *pVlist; - /* background pixel overrides background pixmap, - so don't let the ddx layer see both bits */ - vmaskCopy &= ~CWBackPixmap; - pVlist++; - break; - case CWBorderPixmap: - pixID = (Pixmap ) *pVlist; - pVlist++; - if (pixID == CopyFromParent) - { - if (!pWin->parent || - (pWin->drawable.depth != pWin->parent->drawable.depth)) - { - error = BadMatch; - goto PatchUp; - } - if (pWin->parent->borderIsPixel == TRUE) { - if (pWin->borderIsPixel == FALSE) - (*pScreen->DestroyPixmap)(pWin->border.pixmap); - pWin->border = pWin->parent->border; - pWin->borderIsPixel = TRUE; - index2 = CWBorderPixel; - break; - } - else - { - pixID = pWin->parent->border.pixmap->drawable.id; - } - } - rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP, - client, DixReadAccess); - if (rc == Success) - { - if ((pPixmap->drawable.depth != pWin->drawable.depth) || - (pPixmap->drawable.pScreen != pScreen)) - { - error = BadMatch; - goto PatchUp; - } - if (pWin->borderIsPixel == FALSE) - (*pScreen->DestroyPixmap)(pWin->border.pixmap); - pWin->borderIsPixel = FALSE; - pWin->border.pixmap = pPixmap; - pPixmap->refcnt++; - } - else - { - error = rc; - client->errorValue = pixID; - goto PatchUp; - } - break; - case CWBorderPixel: - if (pWin->borderIsPixel == FALSE) - (*pScreen->DestroyPixmap)(pWin->border.pixmap); - pWin->borderIsPixel = TRUE; - pWin->border.pixel = (CARD32) *pVlist; - /* border pixel overrides border pixmap, - so don't let the ddx layer see both bits */ - vmaskCopy &= ~CWBorderPixmap; - pVlist++; - break; - case CWBitGravity: - val = (CARD8 )*pVlist; - pVlist++; - if (val > StaticGravity) - { - error = BadValue; - client->errorValue = val; - goto PatchUp; - } - pWin->bitGravity = val; - break; - case CWWinGravity: - val = (CARD8 )*pVlist; - pVlist++; - if (val > StaticGravity) - { - error = BadValue; - client->errorValue = val; - goto PatchUp; - } - pWin->winGravity = val; - break; - case CWBackingStore: - val = (CARD8 )*pVlist; - pVlist++; - if ((val != NotUseful) && (val != WhenMapped) && (val != Always)) - { - error = BadValue; - client->errorValue = val; - goto PatchUp; - } - pWin->backingStore = val; - pWin->forcedBS = FALSE; - break; - case CWBackingPlanes: - if (pWin->optional || ((CARD32)*pVlist != (CARD32)~0L)) { - if (!pWin->optional && !MakeWindowOptional (pWin)) - { - error = BadAlloc; - goto PatchUp; - } - pWin->optional->backingBitPlanes = (CARD32) *pVlist; - if ((CARD32)*pVlist == (CARD32)~0L) - checkOptional = TRUE; - } - pVlist++; - break; - case CWBackingPixel: - if (pWin->optional || (CARD32) *pVlist) { - if (!pWin->optional && !MakeWindowOptional (pWin)) - { - error = BadAlloc; - goto PatchUp; - } - pWin->optional->backingPixel = (CARD32) *pVlist; - if (!*pVlist) - checkOptional = TRUE; - } - pVlist++; - break; - case CWSaveUnder: - val = (BOOL) *pVlist; - pVlist++; - if ((val != xTrue) && (val != xFalse)) - { - error = BadValue; - client->errorValue = val; - goto PatchUp; - } - pWin->saveUnder = val; - break; - case CWEventMask: - rc = EventSelectForWindow(pWin, client, (Mask )*pVlist); - if (rc) - { - error = rc; - goto PatchUp; - } - pVlist++; - break; - case CWDontPropagate: - rc = EventSuppressForWindow(pWin, client, (Mask )*pVlist, - &checkOptional); - if (rc) - { - error = rc; - goto PatchUp; - } - pVlist++; - break; - case CWOverrideRedirect: - val = (BOOL ) *pVlist; - pVlist++; - if ((val != xTrue) && (val != xFalse)) - { - error = BadValue; - client->errorValue = val; - goto PatchUp; - } - if (val == xTrue) { - rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, - RT_WINDOW, pWin, RT_NONE, NULL, DixGrabAccess); - if (rc != Success) { - error = rc; - client->errorValue = pWin->drawable.id; - goto PatchUp; - } - } - pWin->overrideRedirect = val; - break; - case CWColormap: - cmap = (Colormap) *pVlist; - pVlist++; - if (cmap == CopyFromParent) - { - if (pWin->parent && - (!pWin->optional || - pWin->optional->visual == wVisual (pWin->parent))) - { - cmap = wColormap (pWin->parent); - } - else - cmap = None; - } - if (cmap == None) - { - error = BadMatch; - goto PatchUp; - } - rc = dixLookupResourceByType((pointer *)&pCmap, cmap, RT_COLORMAP, - client, DixUseAccess); - if (rc != Success) - { - error = rc; - client->errorValue = cmap; - goto PatchUp; - } - if (pCmap->pVisual->vid != wVisual (pWin) || - pCmap->pScreen != pScreen) - { - error = BadMatch; - goto PatchUp; - } - if (cmap != wColormap (pWin)) - { - if (!pWin->optional) - { - if (!MakeWindowOptional (pWin)) - { - error = BadAlloc; - goto PatchUp; - } - } - else if (pWin->parent && cmap == wColormap (pWin->parent)) - checkOptional = TRUE; - - /* - * propagate the original colormap to any children - * inheriting it - */ - - for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib) - { - if (!pChild->optional && !MakeWindowOptional (pChild)) - { - error = BadAlloc; - goto PatchUp; - } - } - - pWin->optional->colormap = cmap; - - /* - * check on any children now matching the new colormap - */ - - for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib) - { - if (pChild->optional->colormap == cmap) - CheckWindowOptionalNeed (pChild); - } - - xE.u.u.type = ColormapNotify; - xE.u.colormap.window = pWin->drawable.id; - xE.u.colormap.colormap = cmap; - xE.u.colormap.new = xTrue; - xE.u.colormap.state = IsMapInstalled(cmap, pWin); - DeliverEvents(pWin, &xE, 1, NullWindow); - } - break; - case CWCursor: - cursorID = (Cursor ) *pVlist; - pVlist++; - /* - * install the new - */ - if ( cursorID == None) - { - if (pWin == pWin->drawable.pScreen->root) - pCursor = rootCursor; - else - pCursor = (CursorPtr) None; - } - else - { - rc = dixLookupResourceByType((pointer *)&pCursor, cursorID, - RT_CURSOR, client, DixUseAccess); - if (rc != Success) - { - error = rc; - client->errorValue = cursorID; - goto PatchUp; - } - } - - if (pCursor != wCursor (pWin)) - { - /* - * patch up child windows so they don't lose cursors. - */ - - for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib) - { - if (!pChild->optional && !pChild->cursorIsNone && - !MakeWindowOptional (pChild)) - { - error = BadAlloc; - goto PatchUp; - } - } - - pOldCursor = 0; - if (pCursor == (CursorPtr) None) - { - pWin->cursorIsNone = TRUE; - if (pWin->optional) - { - pOldCursor = pWin->optional->cursor; - pWin->optional->cursor = (CursorPtr) None; - checkOptional = TRUE; - } - } else { - if (!pWin->optional) - { - if (!MakeWindowOptional (pWin)) - { - error = BadAlloc; - goto PatchUp; - } - } - else if (pWin->parent && pCursor == wCursor (pWin->parent)) - checkOptional = TRUE; - pOldCursor = pWin->optional->cursor; - pWin->optional->cursor = pCursor; - pCursor->refcnt++; - pWin->cursorIsNone = FALSE; - /* - * check on any children now matching the new cursor - */ - - for (pChild=pWin->firstChild; pChild; pChild=pChild->nextSib) - { - if (pChild->optional && - (pChild->optional->cursor == pCursor)) - CheckWindowOptionalNeed (pChild); - } - } - - if (pWin->realized) - WindowHasNewCursor( pWin); - - /* Can't free cursor until here - old cursor - * is needed in WindowHasNewCursor - */ - if (pOldCursor) - FreeCursor (pOldCursor, (Cursor)0); - } - break; - default: - error = BadValue; - client->errorValue = vmask; - goto PatchUp; - } - vmaskCopy |= index2; - } -PatchUp: - if (checkOptional) - CheckWindowOptionalNeed (pWin); - - /* We SHOULD check for an error value here XXX */ - (*pScreen->ChangeWindowAttributes)(pWin, vmaskCopy); - - /* - If the border contents have changed, redraw the border. - Note that this has to be done AFTER pScreen->ChangeWindowAttributes - for the tile to be rotated, and the correct function selected. - */ - if (((vmaskCopy & (CWBorderPixel | CWBorderPixmap)) || borderRelative) - && pWin->viewable && HasBorder (pWin)) - { - RegionRec exposed; - - RegionNull(&exposed); - RegionSubtract(&exposed, &pWin->borderClip, &pWin->winSize); - miPaintWindow(pWin, &exposed, PW_BORDER); - RegionUninit(&exposed); - } - return error; -} - - -/***** - * GetWindowAttributes - * Notice that this is different than ChangeWindowAttributes - *****/ - -void -GetWindowAttributes(WindowPtr pWin, ClientPtr client, xGetWindowAttributesReply *wa) -{ - wa->type = X_Reply; - wa->bitGravity = pWin->bitGravity; - wa->winGravity = pWin->winGravity; - if (pWin->forcedBS && pWin->backingStore != Always) - wa->backingStore = NotUseful; - else - wa->backingStore = pWin->backingStore; - wa->length = bytes_to_int32(sizeof(xGetWindowAttributesReply) - - sizeof(xGenericReply)); - wa->sequenceNumber = client->sequence; - wa->backingBitPlanes = wBackingBitPlanes (pWin); - wa->backingPixel = wBackingPixel (pWin); - wa->saveUnder = (BOOL)pWin->saveUnder; - wa->override = pWin->overrideRedirect; - if (!pWin->mapped) - wa->mapState = IsUnmapped; - else if (pWin->realized) - wa->mapState = IsViewable; - else - wa->mapState = IsUnviewable; - - wa->colormap = wColormap (pWin); - wa->mapInstalled = (wa->colormap == None) ? xFalse - : IsMapInstalled(wa->colormap, pWin); - - wa->yourEventMask = EventMaskForClient(pWin, client); - wa->allEventMasks = pWin->eventMask | wOtherEventMasks (pWin); - wa->doNotPropagateMask = wDontPropagateMask (pWin); - wa->class = pWin->drawable.class; - wa->visualID = wVisual (pWin); -} - - -WindowPtr -MoveWindowInStack(WindowPtr pWin, WindowPtr pNextSib) -{ - WindowPtr pParent = pWin->parent; - WindowPtr pFirstChange = pWin; /* highest window where list changes */ - - if (pWin->nextSib != pNextSib) - { - WindowPtr pOldNextSib = pWin->nextSib; - - if (!pNextSib) /* move to bottom */ - { - if (pParent->firstChild == pWin) - pParent->firstChild = pWin->nextSib; - /* if (pWin->nextSib) */ /* is always True: pNextSib == NULL - * and pWin->nextSib != pNextSib - * therefore pWin->nextSib != NULL */ - pFirstChange = pWin->nextSib; - pWin->nextSib->prevSib = pWin->prevSib; - if (pWin->prevSib) - pWin->prevSib->nextSib = pWin->nextSib; - pParent->lastChild->nextSib = pWin; - pWin->prevSib = pParent->lastChild; - pWin->nextSib = NullWindow; - pParent->lastChild = pWin; - } - else if (pParent->firstChild == pNextSib) /* move to top */ - { - pFirstChange = pWin; - if (pParent->lastChild == pWin) - pParent->lastChild = pWin->prevSib; - if (pWin->nextSib) - pWin->nextSib->prevSib = pWin->prevSib; - if (pWin->prevSib) - pWin->prevSib->nextSib = pWin->nextSib; - pWin->nextSib = pParent->firstChild; - pWin->prevSib = (WindowPtr ) NULL; - pNextSib->prevSib = pWin; - pParent->firstChild = pWin; - } - else /* move in middle of list */ - { - WindowPtr pOldNext = pWin->nextSib; - - pFirstChange = NullWindow; - if (pParent->firstChild == pWin) - pFirstChange = pParent->firstChild = pWin->nextSib; - if (pParent->lastChild == pWin) { - pFirstChange = pWin; - pParent->lastChild = pWin->prevSib; - } - if (pWin->nextSib) - pWin->nextSib->prevSib = pWin->prevSib; - if (pWin->prevSib) - pWin->prevSib->nextSib = pWin->nextSib; - pWin->nextSib = pNextSib; - pWin->prevSib = pNextSib->prevSib; - if (pNextSib->prevSib) - pNextSib->prevSib->nextSib = pWin; - pNextSib->prevSib = pWin; - if (!pFirstChange) { /* do we know it yet? */ - pFirstChange = pParent->firstChild; /* no, search from top */ - while ((pFirstChange != pWin) && (pFirstChange != pOldNext)) - pFirstChange = pFirstChange->nextSib; - } - } - if(pWin->drawable.pScreen->RestackWindow) - (*pWin->drawable.pScreen->RestackWindow)(pWin, pOldNextSib); - } - -#ifdef ROOTLESS - /* - * In rootless mode we can't optimize away window restacks. - * There may be non-X windows around, so even if the window - * is in the correct position from X's point of view, - * the underlying window system may want to reorder it. - */ - else if (pWin->drawable.pScreen->RestackWindow) - (*pWin->drawable.pScreen->RestackWindow)(pWin, pWin->nextSib); -#endif - - return pFirstChange; -} - -void -SetWinSize (WindowPtr pWin) -{ -#ifdef COMPOSITE - if (pWin->redirectDraw != RedirectDrawNone) - { - BoxRec box; - - /* - * Redirected clients get clip list equal to their - * own geometry, not clipped to their parent - */ - box.x1 = pWin->drawable.x; - box.y1 = pWin->drawable.y; - box.x2 = pWin->drawable.x + pWin->drawable.width; - box.y2 = pWin->drawable.y + pWin->drawable.height; - RegionReset(&pWin->winSize, &box); - } - else -#endif - ClippedRegionFromBox(pWin->parent, &pWin->winSize, - pWin->drawable.x, pWin->drawable.y, - (int)pWin->drawable.width, - (int)pWin->drawable.height); - if (wBoundingShape (pWin) || wClipShape (pWin)) { - RegionTranslate(&pWin->winSize, - pWin->drawable.x, - - pWin->drawable.y); - if (wBoundingShape (pWin)) - RegionIntersect(&pWin->winSize, &pWin->winSize, - wBoundingShape (pWin)); - if (wClipShape (pWin)) - RegionIntersect(&pWin->winSize, &pWin->winSize, - wClipShape (pWin)); - RegionTranslate(&pWin->winSize, pWin->drawable.x, - pWin->drawable.y); - } -} - -void -SetBorderSize (WindowPtr pWin) -{ - int bw; - - if (HasBorder (pWin)) { - bw = wBorderWidth (pWin); -#ifdef COMPOSITE - if (pWin->redirectDraw != RedirectDrawNone) - { - BoxRec box; - - /* - * Redirected clients get clip list equal to their - * own geometry, not clipped to their parent - */ - box.x1 = pWin->drawable.x - bw; - box.y1 = pWin->drawable.y - bw; - box.x2 = pWin->drawable.x + pWin->drawable.width + bw; - box.y2 = pWin->drawable.y + pWin->drawable.height + bw; - RegionReset(&pWin->borderSize, &box); - } - else -#endif - ClippedRegionFromBox(pWin->parent, &pWin->borderSize, - pWin->drawable.x - bw, pWin->drawable.y - bw, - (int)(pWin->drawable.width + (bw<<1)), - (int)(pWin->drawable.height + (bw<<1))); - if (wBoundingShape (pWin)) { - RegionTranslate(&pWin->borderSize, - pWin->drawable.x, - - pWin->drawable.y); - RegionIntersect(&pWin->borderSize, &pWin->borderSize, - wBoundingShape (pWin)); - RegionTranslate(&pWin->borderSize, pWin->drawable.x, - pWin->drawable.y); - RegionUnion(&pWin->borderSize, &pWin->borderSize, - &pWin->winSize); - } - } else { - RegionCopy(&pWin->borderSize, &pWin->winSize); - } -} - -/** - * - * \param x,y new window position - * \param oldx,oldy old window position - * \param destx,desty position relative to gravity - */ - -void -GravityTranslate (int x, int y, int oldx, int oldy, - int dw, int dh, unsigned gravity, - int *destx, int *desty) -{ - switch (gravity) { - case NorthGravity: - *destx = x + dw / 2; - *desty = y; - break; - case NorthEastGravity: - *destx = x + dw; - *desty = y; - break; - case WestGravity: - *destx = x; - *desty = y + dh / 2; - break; - case CenterGravity: - *destx = x + dw / 2; - *desty = y + dh / 2; - break; - case EastGravity: - *destx = x + dw; - *desty = y + dh / 2; - break; - case SouthWestGravity: - *destx = x; - *desty = y + dh; - break; - case SouthGravity: - *destx = x + dw / 2; - *desty = y + dh; - break; - case SouthEastGravity: - *destx = x + dw; - *desty = y + dh; - break; - case StaticGravity: - *destx = oldx; - *desty = oldy; - break; - default: - *destx = x; - *desty = y; - break; - } -} - -/* XXX need to retile border on each window with ParentRelative origin */ -void -ResizeChildrenWinSize(WindowPtr pWin, int dx, int dy, int dw, int dh) -{ - ScreenPtr pScreen; - WindowPtr pSib, pChild; - Bool resized = (dw || dh); - - pScreen = pWin->drawable.pScreen; - - for (pSib = pWin->firstChild; pSib; pSib = pSib->nextSib) - { - if (resized && (pSib->winGravity > NorthWestGravity)) - { - int cwsx, cwsy; - - cwsx = pSib->origin.x; - cwsy = pSib->origin.y; - GravityTranslate (cwsx, cwsy, cwsx - dx, cwsy - dy, dw, dh, - pSib->winGravity, &cwsx, &cwsy); - if (cwsx != pSib->origin.x || cwsy != pSib->origin.y) - { - xEvent event; - - event.u.u.type = GravityNotify; - event.u.gravity.window = pSib->drawable.id; - event.u.gravity.x = cwsx - wBorderWidth (pSib); - event.u.gravity.y = cwsy - wBorderWidth (pSib); - DeliverEvents (pSib, &event, 1, NullWindow); - pSib->origin.x = cwsx; - pSib->origin.y = cwsy; - } - } - pSib->drawable.x = pWin->drawable.x + pSib->origin.x; - pSib->drawable.y = pWin->drawable.y + pSib->origin.y; - SetWinSize (pSib); - SetBorderSize (pSib); - (*pScreen->PositionWindow)(pSib, pSib->drawable.x, pSib->drawable.y); - - if ( (pChild = pSib->firstChild) ) - { - while (1) - { - pChild->drawable.x = pChild->parent->drawable.x + - pChild->origin.x; - pChild->drawable.y = pChild->parent->drawable.y + - pChild->origin.y; - SetWinSize (pChild); - SetBorderSize (pChild); - (*pScreen->PositionWindow)(pChild, - pChild->drawable.x, pChild->drawable.y); - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - while (!pChild->nextSib && (pChild != pSib)) - pChild = pChild->parent; - if (pChild == pSib) - break; - pChild = pChild->nextSib; - } - } - } -} - -#define GET_INT16(m, f) \ - if (m & mask) \ - { \ - f = (INT16) *pVlist;\ - pVlist++; \ - } -#define GET_CARD16(m, f) \ - if (m & mask) \ - { \ - f = (CARD16) *pVlist;\ - pVlist++;\ - } - -#define GET_CARD8(m, f) \ - if (m & mask) \ - { \ - f = (CARD8) *pVlist;\ - pVlist++;\ - } - -#define ChangeMask ((Mask)(CWX | CWY | CWWidth | CWHeight)) - -#define IllegalInputOnlyConfigureMask (CWBorderWidth) - -/* - * IsSiblingAboveMe - * returns Above if pSib above pMe in stack or Below otherwise - */ - -static int -IsSiblingAboveMe( - WindowPtr pMe, - WindowPtr pSib) -{ - WindowPtr pWin; - - pWin = pMe->parent->firstChild; - while (pWin) - { - if (pWin == pSib) - return Above; - else if (pWin == pMe) - return Below; - pWin = pWin->nextSib; - } - return Below; -} - -static BoxPtr -WindowExtents( - WindowPtr pWin, - BoxPtr pBox) -{ - pBox->x1 = pWin->drawable.x - wBorderWidth (pWin); - pBox->y1 = pWin->drawable.y - wBorderWidth (pWin); - pBox->x2 = pWin->drawable.x + (int)pWin->drawable.width - + wBorderWidth (pWin); - pBox->y2 = pWin->drawable.y + (int)pWin->drawable.height - + wBorderWidth (pWin); - return pBox; -} - -#define IS_SHAPED(pWin) (wBoundingShape (pWin) != (RegionPtr) NULL) - -static RegionPtr -MakeBoundingRegion ( - WindowPtr pWin, - BoxPtr pBox) -{ - RegionPtr pRgn = RegionCreate(pBox, 1); - if (wBoundingShape (pWin)) { - RegionTranslate(pRgn, -pWin->origin.x, -pWin->origin.y); - RegionIntersect(pRgn, pRgn, wBoundingShape (pWin)); - RegionTranslate(pRgn, pWin->origin.x, pWin->origin.y); - } - return pRgn; -} - -static Bool -ShapeOverlap ( - WindowPtr pWin, - BoxPtr pWinBox, - WindowPtr pSib, - BoxPtr pSibBox) -{ - RegionPtr pWinRgn, pSibRgn; - Bool ret; - - if (!IS_SHAPED(pWin) && !IS_SHAPED(pSib)) - return TRUE; - pWinRgn = MakeBoundingRegion (pWin, pWinBox); - pSibRgn = MakeBoundingRegion (pSib, pSibBox); - RegionIntersect(pWinRgn, pWinRgn, pSibRgn); - ret = RegionNotEmpty(pWinRgn); - RegionDestroy(pWinRgn); - RegionDestroy(pSibRgn); - return ret; -} - -static Bool -AnyWindowOverlapsMe( - WindowPtr pWin, - WindowPtr pHead, - BoxPtr box) -{ - WindowPtr pSib; - BoxRec sboxrec; - BoxPtr sbox; - - for (pSib = pWin->prevSib; pSib != pHead; pSib = pSib->prevSib) - { - if (pSib->mapped) - { - sbox = WindowExtents(pSib, &sboxrec); - if (BOXES_OVERLAP(sbox, box) - && ShapeOverlap (pWin, box, pSib, sbox) - ) - return TRUE; - } - } - return FALSE; -} - -static Bool -IOverlapAnyWindow( - WindowPtr pWin, - BoxPtr box) -{ - WindowPtr pSib; - BoxRec sboxrec; - BoxPtr sbox; - - for (pSib = pWin->nextSib; pSib; pSib = pSib->nextSib) - { - if (pSib->mapped) - { - sbox = WindowExtents(pSib, &sboxrec); - if (BOXES_OVERLAP(sbox, box) - && ShapeOverlap (pWin, box, pSib, sbox) - ) - return TRUE; - } - } - return FALSE; -} - -/* - * WhereDoIGoInTheStack() - * Given pWin and pSib and the relationshipe smode, return - * the window that pWin should go ABOVE. - * If a pSib is specified: - * Above: pWin is placed just above pSib - * Below: pWin is placed just below pSib - * TopIf: if pSib occludes pWin, then pWin is placed - * at the top of the stack - * BottomIf: if pWin occludes pSib, then pWin is - * placed at the bottom of the stack - * Opposite: if pSib occludes pWin, then pWin is placed at the - * top of the stack, else if pWin occludes pSib, then - * pWin is placed at the bottom of the stack - * - * If pSib is NULL: - * Above: pWin is placed at the top of the stack - * Below: pWin is placed at the bottom of the stack - * TopIf: if any sibling occludes pWin, then pWin is placed at - * the top of the stack - * BottomIf: if pWin occludes any sibline, then pWin is placed at - * the bottom of the stack - * Opposite: if any sibling occludes pWin, then pWin is placed at - * the top of the stack, else if pWin occludes any - * sibling, then pWin is placed at the bottom of the stack - * - */ - -static WindowPtr -WhereDoIGoInTheStack( - WindowPtr pWin, - WindowPtr pSib, - short x, - short y, - unsigned short w, - unsigned short h, - int smode) -{ - BoxRec box; - WindowPtr pHead, pFirst; - - if ((pWin == pWin->parent->firstChild) && - (pWin == pWin->parent->lastChild)) - return((WindowPtr ) NULL); - pHead = RealChildHead(pWin->parent); - pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild; - box.x1 = x; - box.y1 = y; - box.x2 = x + (int)w; - box.y2 = y + (int)h; - switch (smode) - { - case Above: - if (pSib) - return pSib; - else if (pWin == pFirst) - return pWin->nextSib; - else - return pFirst; - case Below: - if (pSib) - if (pSib->nextSib != pWin) - return pSib->nextSib; - else - return pWin->nextSib; - else - return NullWindow; - case TopIf: - if ((!pWin->mapped || (pSib && !pSib->mapped))) - return pWin->nextSib; - else if (pSib) - { - if ((IsSiblingAboveMe(pWin, pSib) == Above) && - (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT)) - return pFirst; - else - return pWin->nextSib; - } - else if (AnyWindowOverlapsMe(pWin, pHead, &box)) - return pFirst; - else - return pWin->nextSib; - case BottomIf: - if ((!pWin->mapped || (pSib && !pSib->mapped))) - return pWin->nextSib; - else if (pSib) - { - if ((IsSiblingAboveMe(pWin, pSib) == Below) && - (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT)) - return NullWindow; - else - return pWin->nextSib; - } - else if (IOverlapAnyWindow(pWin, &box)) - return NullWindow; - else - return pWin->nextSib; - case Opposite: - if ((!pWin->mapped || (pSib && !pSib->mapped))) - return pWin->nextSib; - else if (pSib) - { - if (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT) - { - if (IsSiblingAboveMe(pWin, pSib) == Above) - return pFirst; - else - return NullWindow; - } - else - return pWin->nextSib; - } - else if (AnyWindowOverlapsMe(pWin, pHead, &box)) - { - /* If I'm occluded, I can't possibly be the first child - * if (pWin == pWin->parent->firstChild) - * return pWin->nextSib; - */ - return pFirst; - } - else if (IOverlapAnyWindow(pWin, &box)) - return NullWindow; - else - return pWin->nextSib; - default: - { - /* should never happen; make something up. */ - return pWin->nextSib; - } - } -} - -static void -ReflectStackChange( - WindowPtr pWin, - WindowPtr pSib, - VTKind kind) -{ -/* Note that pSib might be NULL */ - - Bool WasViewable = (Bool)pWin->viewable; - Bool anyMarked; - WindowPtr pFirstChange; - WindowPtr pLayerWin; - ScreenPtr pScreen = pWin->drawable.pScreen; - - /* if this is a root window, can't be restacked */ - if (!pWin->parent) - return; - - pFirstChange = MoveWindowInStack(pWin, pSib); - - if (WasViewable) - { - anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, - &pLayerWin); - if (pLayerWin != pWin) pFirstChange = pLayerWin; - if (anyMarked) - { - (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, kind); - (*pScreen->HandleExposures)(pLayerWin->parent); - } - if (anyMarked && pWin->drawable.pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, kind); - } - if (pWin->realized) - WindowsRestructured (); -} - -/***** - * ConfigureWindow - *****/ - -int -ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client) -{ -#define RESTACK_WIN 0 -#define MOVE_WIN 1 -#define RESIZE_WIN 2 -#define REBORDER_WIN 3 - WindowPtr pSib = NullWindow; - WindowPtr pParent = pWin->parent; - Window sibwid = 0; - Mask index2, tmask; - XID *pVlist; - short x, y, beforeX, beforeY; - unsigned short w = pWin->drawable.width, - h = pWin->drawable.height, - bw = pWin->borderWidth; - int rc, action, smode = Above; - xEvent event; - - if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask)) - return BadMatch; - - if ((mask & CWSibling) && !(mask & CWStackMode)) - return BadMatch; - - pVlist = vlist; - - if (pParent) - { - x = pWin->drawable.x - pParent->drawable.x - (int)bw; - y = pWin->drawable.y - pParent->drawable.y - (int)bw; - } - else - { - x = pWin->drawable.x; - y = pWin->drawable.y; - } - beforeX = x; - beforeY = y; - action = RESTACK_WIN; - if ((mask & (CWX | CWY)) && (!(mask & (CWHeight | CWWidth)))) - { - GET_INT16(CWX, x); - GET_INT16(CWY, y); - action = MOVE_WIN; - } - /* or should be resized */ - else if (mask & (CWX | CWY | CWWidth | CWHeight)) - { - GET_INT16(CWX, x); - GET_INT16(CWY, y); - GET_CARD16(CWWidth, w); - GET_CARD16 (CWHeight, h); - if (!w || !h) - { - client->errorValue = 0; - return BadValue; - } - action = RESIZE_WIN; - } - tmask = mask & ~ChangeMask; - while (tmask) - { - index2 = (Mask)lowbit (tmask); - tmask &= ~index2; - switch (index2) - { - case CWBorderWidth: - GET_CARD16(CWBorderWidth, bw); - break; - case CWSibling: - sibwid = (Window ) *pVlist; - pVlist++; - rc = dixLookupWindow(&pSib, sibwid, client, DixGetAttrAccess); - if (rc != Success) - { - client->errorValue = sibwid; - return rc; - } - if (pSib->parent != pParent) - return BadMatch; - if (pSib == pWin) - return BadMatch; - break; - case CWStackMode: - GET_CARD8(CWStackMode, smode); - if ((smode != TopIf) && (smode != BottomIf) && - (smode != Opposite) && (smode != Above) && (smode != Below)) - { - client->errorValue = smode; - return BadValue; - } - break; - default: - client->errorValue = mask; - return BadValue; - } - } - /* root really can't be reconfigured, so just return */ - if (!pParent) - return Success; - - /* Figure out if the window should be moved. Doesnt - make the changes to the window if event sent */ - - if (mask & CWStackMode) - pSib = WhereDoIGoInTheStack(pWin, pSib, pParent->drawable.x + x, - pParent->drawable.y + y, - w + (bw << 1), h + (bw << 1), smode); - else - pSib = pWin->nextSib; - - - if ((!pWin->overrideRedirect) && - (RedirectSend(pParent) - )) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = ConfigureRequest; - event.u.configureRequest.window = pWin->drawable.id; - if (mask & CWSibling) - event.u.configureRequest.sibling = sibwid; - else - event.u.configureRequest.sibling = None; - if (mask & CWStackMode) - event.u.u.detail = smode; - else - event.u.u.detail = Above; - event.u.configureRequest.x = x; - event.u.configureRequest.y = y; -#ifdef PANORAMIX - if(!noPanoramiXExtension && (!pParent || !pParent->parent)) { - event.u.configureRequest.x += screenInfo.screens[0]->x; - event.u.configureRequest.y += screenInfo.screens[0]->y; - } -#endif - event.u.configureRequest.width = w; - event.u.configureRequest.height = h; - event.u.configureRequest.borderWidth = bw; - event.u.configureRequest.valueMask = mask; - event.u.configureRequest.parent = pParent->drawable.id; - if (MaybeDeliverEventsToClient(pParent, &event, 1, - SubstructureRedirectMask, client) == 1) - return Success; - } - if (action == RESIZE_WIN) - { - Bool size_change = (w != pWin->drawable.width) - || (h != pWin->drawable.height); - if (size_change && ((pWin->eventMask|wOtherEventMasks(pWin)) & ResizeRedirectMask)) - { - xEvent eventT; - memset(&eventT, 0, sizeof(xEvent)); - eventT.u.u.type = ResizeRequest; - eventT.u.resizeRequest.window = pWin->drawable.id; - eventT.u.resizeRequest.width = w; - eventT.u.resizeRequest.height = h; - if (MaybeDeliverEventsToClient(pWin, &eventT, 1, - ResizeRedirectMask, client) == 1) - { - /* if event is delivered, leave the actual size alone. */ - w = pWin->drawable.width; - h = pWin->drawable.height; - size_change = FALSE; - } - } - if (!size_change) - { - if (mask & (CWX | CWY)) - action = MOVE_WIN; - else if (mask & (CWStackMode | CWBorderWidth)) - action = RESTACK_WIN; - else /* really nothing to do */ - return(Success) ; - } - } - - if (action == RESIZE_WIN) - /* we've already checked whether there's really a size change */ - goto ActuallyDoSomething; - if ((mask & CWX) && (x != beforeX)) - goto ActuallyDoSomething; - if ((mask & CWY) && (y != beforeY)) - goto ActuallyDoSomething; - if ((mask & CWBorderWidth) && (bw != wBorderWidth (pWin))) - goto ActuallyDoSomething; - if (mask & CWStackMode) - { -#ifndef ROOTLESS - /* See above for why we always reorder in rootless mode. */ - if (pWin->nextSib != pSib) -#endif - goto ActuallyDoSomething; - } - return Success; - -ActuallyDoSomething: - if (pWin->drawable.pScreen->ConfigNotify) - { - int ret; - ret = (*pWin->drawable.pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib); - if (ret) { - client->errorValue = 0; - return ret; - } - } - - if (SubStrSend(pWin, pParent)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = ConfigureNotify; - event.u.configureNotify.window = pWin->drawable.id; - if (pSib) - event.u.configureNotify.aboveSibling = pSib->drawable.id; - else - event.u.configureNotify.aboveSibling = None; - event.u.configureNotify.x = x; - event.u.configureNotify.y = y; -#ifdef PANORAMIX - if(!noPanoramiXExtension && (!pParent || !pParent->parent)) { - event.u.configureNotify.x += screenInfo.screens[0]->x; - event.u.configureNotify.y += screenInfo.screens[0]->y; - } -#endif - event.u.configureNotify.width = w; - event.u.configureNotify.height = h; - event.u.configureNotify.borderWidth = bw; - event.u.configureNotify.override = pWin->overrideRedirect; - DeliverEvents(pWin, &event, 1, NullWindow); - } - if (mask & CWBorderWidth) - { - if (action == RESTACK_WIN) - { - action = MOVE_WIN; - pWin->borderWidth = bw; - } - else if ((action == MOVE_WIN) && - (beforeX + wBorderWidth (pWin) == x + (int)bw) && - (beforeY + wBorderWidth (pWin) == y + (int)bw)) - { - action = REBORDER_WIN; - (*pWin->drawable.pScreen->ChangeBorderWidth)(pWin, bw); - } - else - pWin->borderWidth = bw; - } - if (action == MOVE_WIN) - (*pWin->drawable.pScreen->MoveWindow)(pWin, x, y, pSib, - (mask & CWBorderWidth) ? VTOther : VTMove); - else if (action == RESIZE_WIN) - (*pWin->drawable.pScreen->ResizeWindow)(pWin, x, y, w, h, pSib); - else if (mask & CWStackMode) - ReflectStackChange(pWin, pSib, VTOther); - - if (action != RESTACK_WIN) - CheckCursorConfinement(pWin); - return Success; -#undef RESTACK_WIN -#undef MOVE_WIN -#undef RESIZE_WIN -#undef REBORDER_WIN -} - - -/****** - * - * CirculateWindow - * For RaiseLowest, raises the lowest mapped child (if any) that is - * obscured by another child to the top of the stack. For LowerHighest, - * lowers the highest mapped child (if any) that is obscuring another - * child to the bottom of the stack. Exposure processing is performed - * - ******/ - -int -CirculateWindow(WindowPtr pParent, int direction, ClientPtr client) -{ - WindowPtr pWin, pHead, pFirst; - xEvent event; - BoxRec box; - - pHead = RealChildHead(pParent); - pFirst = pHead ? pHead->nextSib : pParent->firstChild; - if (direction == RaiseLowest) - { - for (pWin = pParent->lastChild; - (pWin != pHead) && - !(pWin->mapped && - AnyWindowOverlapsMe(pWin, pHead, WindowExtents(pWin, &box))); - pWin = pWin->prevSib) ; - if (pWin == pHead) - return Success; - } - else - { - for (pWin = pFirst; - pWin && - !(pWin->mapped && - IOverlapAnyWindow(pWin, WindowExtents(pWin, &box))); - pWin = pWin->nextSib) ; - if (!pWin) - return Success; - } - - event.u.circulate.window = pWin->drawable.id; - event.u.circulate.parent = pParent->drawable.id; - event.u.circulate.event = pParent->drawable.id; - if (direction == RaiseLowest) - event.u.circulate.place = PlaceOnTop; - else - event.u.circulate.place = PlaceOnBottom; - - if (RedirectSend(pParent)) - { - event.u.u.type = CirculateRequest; - if (MaybeDeliverEventsToClient(pParent, &event, 1, - SubstructureRedirectMask, client) == 1) - return Success; - } - - event.u.u.type = CirculateNotify; - DeliverEvents(pWin, &event, 1, NullWindow); - ReflectStackChange(pWin, - (direction == RaiseLowest) ? pFirst : NullWindow, - VTStack); - - return Success; -} - -static int -CompareWIDs( - WindowPtr pWin, - pointer value) /* must conform to VisitWindowProcPtr */ -{ - Window *wid = (Window *)value; - - if (pWin->drawable.id == *wid) - return WT_STOPWALKING; - else - return WT_WALKCHILDREN; -} - -/***** - * ReparentWindow - *****/ - -int -ReparentWindow(WindowPtr pWin, WindowPtr pParent, - int x, int y, ClientPtr client) -{ - WindowPtr pPrev, pPriorParent; - Bool WasMapped = (Bool)(pWin->mapped); - xEvent event; - int bw = wBorderWidth (pWin); - ScreenPtr pScreen; - - pScreen = pWin->drawable.pScreen; - if (TraverseTree(pWin, CompareWIDs, (pointer)&pParent->drawable.id) == WT_STOPWALKING) - return BadMatch; - if (!MakeWindowOptional(pWin)) - return BadAlloc; - - if (WasMapped) - UnmapWindow(pWin, FALSE); - - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = ReparentNotify; - event.u.reparent.window = pWin->drawable.id; - event.u.reparent.parent = pParent->drawable.id; - event.u.reparent.x = x; - event.u.reparent.y = y; -#ifdef PANORAMIX - if(!noPanoramiXExtension && !pParent->parent) { - event.u.reparent.x += screenInfo.screens[0]->x; - event.u.reparent.y += screenInfo.screens[0]->y; - } -#endif - event.u.reparent.override = pWin->overrideRedirect; - DeliverEvents(pWin, &event, 1, pParent); - - /* take out of sibling chain */ - - pPriorParent = pPrev = pWin->parent; - if (pPrev->firstChild == pWin) - pPrev->firstChild = pWin->nextSib; - if (pPrev->lastChild == pWin) - pPrev->lastChild = pWin->prevSib; - - if (pWin->nextSib) - pWin->nextSib->prevSib = pWin->prevSib; - if (pWin->prevSib) - pWin->prevSib->nextSib = pWin->nextSib; - - /* insert at begining of pParent */ - pWin->parent = pParent; - pPrev = RealChildHead(pParent); - if (pPrev) - { - pWin->nextSib = pPrev->nextSib; - if (pPrev->nextSib) - pPrev->nextSib->prevSib = pWin; - else - pParent->lastChild = pWin; - pPrev->nextSib = pWin; - pWin->prevSib = pPrev; - } - else - { - pWin->nextSib = pParent->firstChild; - pWin->prevSib = NullWindow; - if (pParent->firstChild) - pParent->firstChild->prevSib = pWin; - else - pParent->lastChild = pWin; - pParent->firstChild = pWin; - } - - pWin->origin.x = x + bw; - pWin->origin.y = y + bw; - pWin->drawable.x = x + bw + pParent->drawable.x; - pWin->drawable.y = y + bw + pParent->drawable.y; - - /* clip to parent */ - SetWinSize (pWin); - SetBorderSize (pWin); - - if (pScreen->ReparentWindow) - (*pScreen->ReparentWindow)(pWin, pPriorParent); - (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y); - ResizeChildrenWinSize(pWin, 0, 0, 0, 0); - - CheckWindowOptionalNeed(pWin); - - if (WasMapped) - MapWindow(pWin, client); - RecalculateDeliverableEvents(pWin); - return Success; -} - -static void -RealizeTree(WindowPtr pWin) -{ - WindowPtr pChild; - RealizeWindowProcPtr Realize; - - Realize = pWin->drawable.pScreen->RealizeWindow; - pChild = pWin; - while (1) - { - if (pChild->mapped) - { - pChild->realized = TRUE; - pChild->viewable = (pChild->drawable.class == InputOutput); - (* Realize)(pChild); - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - } - while (!pChild->nextSib && (pChild != pWin)) - pChild = pChild->parent; - if (pChild == pWin) - return; - pChild = pChild->nextSib; - } -} - -static WindowPtr windowDisableMapUnmapEvents; - -void -DisableMapUnmapEvents(WindowPtr pWin) -{ - assert (windowDisableMapUnmapEvents == NULL); - - windowDisableMapUnmapEvents = pWin; -} - -void -EnableMapUnmapEvents(WindowPtr pWin) -{ - assert (windowDisableMapUnmapEvents != NULL); - - windowDisableMapUnmapEvents = NULL; -} - -static Bool -MapUnmapEventsEnabled(WindowPtr pWin) -{ - return pWin != windowDisableMapUnmapEvents; -} - -/***** - * MapWindow - * If some other client has selected SubStructureReDirect on the parent - * and override-redirect is xFalse, then a MapRequest event is generated, - * but the window remains unmapped. Otherwise, the window is mapped and a - * MapNotify event is generated. - *****/ - -int -MapWindow(WindowPtr pWin, ClientPtr client) -{ - ScreenPtr pScreen; - - WindowPtr pParent; - WindowPtr pLayerWin; - - if (pWin->mapped) - return Success; - - /* general check for permission to map window */ - if (XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, RT_WINDOW, - pWin, RT_NONE, NULL, DixShowAccess) != Success) - return Success; - - pScreen = pWin->drawable.pScreen; - if ( (pParent = pWin->parent) ) - { - xEvent event; - Bool anyMarked; - - if ((!pWin->overrideRedirect) && - (RedirectSend(pParent) - )) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = MapRequest; - event.u.mapRequest.window = pWin->drawable.id; - event.u.mapRequest.parent = pParent->drawable.id; - - if (MaybeDeliverEventsToClient(pParent, &event, 1, - SubstructureRedirectMask, client) == 1) - return Success; - } - - pWin->mapped = TRUE; - if (SubStrSend(pWin, pParent) && MapUnmapEventsEnabled(pWin)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = MapNotify; - event.u.mapNotify.window = pWin->drawable.id; - event.u.mapNotify.override = pWin->overrideRedirect; - DeliverEvents(pWin, &event, 1, NullWindow); - } - - if (!pParent->realized) - return Success; - RealizeTree(pWin); - if (pWin->viewable) - { - anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, - &pLayerWin); - if (anyMarked) - { - (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTMap); - (*pScreen->HandleExposures)(pLayerWin->parent); - } - if (anyMarked && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTMap); - } - WindowsRestructured (); - } - else - { - RegionRec temp; - - pWin->mapped = TRUE; - pWin->realized = TRUE; /* for roots */ - pWin->viewable = pWin->drawable.class == InputOutput; - /* We SHOULD check for an error value here XXX */ - (*pScreen->RealizeWindow)(pWin); - if (pScreen->ClipNotify) - (*pScreen->ClipNotify) (pWin, 0, 0); - if (pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(NullWindow, pWin, VTMap); - RegionNull(&temp); - RegionCopy(&temp, &pWin->clipList); - (*pScreen->WindowExposures) (pWin, &temp, NullRegion); - RegionUninit(&temp); - } - - return Success; -} - - -/***** - * MapSubwindows - * Performs a MapWindow all unmapped children of the window, in top - * to bottom stacking order. - *****/ - -void -MapSubwindows(WindowPtr pParent, ClientPtr client) -{ - WindowPtr pWin; - WindowPtr pFirstMapped = NullWindow; - ScreenPtr pScreen; - Mask parentRedirect; - Mask parentNotify; - xEvent event; - Bool anyMarked; - WindowPtr pLayerWin; - - pScreen = pParent->drawable.pScreen; - parentRedirect = RedirectSend(pParent); - parentNotify = SubSend(pParent); - anyMarked = FALSE; - for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib) - { - if (!pWin->mapped) - { - if (parentRedirect && !pWin->overrideRedirect) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = MapRequest; - event.u.mapRequest.window = pWin->drawable.id; - event.u.mapRequest.parent = pParent->drawable.id; - - if (MaybeDeliverEventsToClient(pParent, &event, 1, - SubstructureRedirectMask, client) == 1) - continue; - } - - pWin->mapped = TRUE; - if (parentNotify || StrSend(pWin)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = MapNotify; - event.u.mapNotify.window = pWin->drawable.id; - event.u.mapNotify.override = pWin->overrideRedirect; - DeliverEvents(pWin, &event, 1, NullWindow); - } - - if (!pFirstMapped) - pFirstMapped = pWin; - if (pParent->realized) - { - RealizeTree(pWin); - if (pWin->viewable) - { - anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, - (WindowPtr *)NULL); - } - } - } - } - - if (pFirstMapped) - { - pLayerWin = (*pScreen->GetLayerWindow)(pParent); - if (pLayerWin->parent != pParent) { - anyMarked |= (*pScreen->MarkOverlappedWindows)(pLayerWin, - pLayerWin, - (WindowPtr *)NULL); - pFirstMapped = pLayerWin; - } - if (anyMarked) - { - (*pScreen->ValidateTree)(pLayerWin->parent, pFirstMapped, VTMap); - (*pScreen->HandleExposures)(pLayerWin->parent); - } - if (anyMarked && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstMapped, - VTMap); - WindowsRestructured (); - } -} - -static void -UnrealizeTree( - WindowPtr pWin, - Bool fromConfigure) -{ - WindowPtr pChild; - UnrealizeWindowProcPtr Unrealize; - MarkUnrealizedWindowProcPtr MarkUnrealizedWindow; - - Unrealize = pWin->drawable.pScreen->UnrealizeWindow; - MarkUnrealizedWindow = pWin->drawable.pScreen->MarkUnrealizedWindow; - pChild = pWin; - while (1) - { - if (pChild->realized) - { - pChild->realized = FALSE; - pChild->visibility = VisibilityNotViewable; -#ifdef PANORAMIX - if(!noPanoramiXExtension && !pChild->drawable.pScreen->myNum) { - PanoramiXRes *win; - int rc = dixLookupResourceByType((pointer *)&win, - pChild->drawable.id, XRT_WINDOW, - serverClient, DixWriteAccess); - if (rc == Success) - win->u.win.visibility = VisibilityNotViewable; - } -#endif - (* Unrealize)(pChild); - if (MapUnmapEventsEnabled(pWin)) - DeleteWindowFromAnyEvents(pChild, FALSE); - if (pChild->viewable) - { - pChild->viewable = FALSE; - (* MarkUnrealizedWindow)(pChild, pWin, fromConfigure); - pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER; - } - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - } - while (!pChild->nextSib && (pChild != pWin)) - pChild = pChild->parent; - if (pChild == pWin) - return; - pChild = pChild->nextSib; - } -} - -/***** - * UnmapWindow - * If the window is already unmapped, this request has no effect. - * Otherwise, the window is unmapped and an UnMapNotify event is - * generated. Cannot unmap a root window. - *****/ - -int -UnmapWindow(WindowPtr pWin, Bool fromConfigure) -{ - WindowPtr pParent; - xEvent event; - Bool wasRealized = (Bool)pWin->realized; - Bool wasViewable = (Bool)pWin->viewable; - ScreenPtr pScreen = pWin->drawable.pScreen; - WindowPtr pLayerWin = pWin; - - if ((!pWin->mapped) || (!(pParent = pWin->parent))) - return Success; - if (SubStrSend(pWin, pParent) && MapUnmapEventsEnabled(pWin)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = UnmapNotify; - event.u.unmapNotify.window = pWin->drawable.id; - event.u.unmapNotify.fromConfigure = fromConfigure; - DeliverEvents(pWin, &event, 1, NullWindow); - } - if (wasViewable && !fromConfigure) - { - pWin->valdata = UnmapValData; - (*pScreen->MarkOverlappedWindows)(pWin, pWin->nextSib, &pLayerWin); - (*pScreen->MarkWindow)(pLayerWin->parent); - } - pWin->mapped = FALSE; - if (wasRealized) - UnrealizeTree(pWin, fromConfigure); - if (wasViewable) - { - if (!fromConfigure) - { - (*pScreen->ValidateTree)(pLayerWin->parent, pWin, VTUnmap); - (*pScreen->HandleExposures)(pLayerWin->parent); - } - if (!fromConfigure && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, pWin, VTUnmap); - } - if (wasRealized && !fromConfigure) - WindowsRestructured (); - return Success; -} - -/***** - * UnmapSubwindows - * Performs an UnmapWindow request with the specified mode on all mapped - * children of the window, in bottom to top stacking order. - *****/ - -void -UnmapSubwindows(WindowPtr pWin) -{ - WindowPtr pChild, pHead; - xEvent event; - Bool wasRealized = (Bool)pWin->realized; - Bool wasViewable = (Bool)pWin->viewable; - Bool anyMarked = FALSE; - Mask parentNotify; - WindowPtr pLayerWin = NULL; - ScreenPtr pScreen = pWin->drawable.pScreen; - - if (!pWin->firstChild) - return; - parentNotify = SubSend(pWin); - pHead = RealChildHead(pWin); - - if (wasViewable) - pLayerWin = (*pScreen->GetLayerWindow)(pWin); - - for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) - { - if (pChild->mapped) - { - if (parentNotify || StrSend(pChild)) - { - event.u.u.type = UnmapNotify; - event.u.unmapNotify.window = pChild->drawable.id; - event.u.unmapNotify.fromConfigure = xFalse; - DeliverEvents(pChild, &event, 1, NullWindow); - } - if (pChild->viewable) - { - pChild->valdata = UnmapValData; - anyMarked = TRUE; - } - pChild->mapped = FALSE; - if (pChild->realized) - UnrealizeTree(pChild, FALSE); - if (wasViewable) - { - } - } - } - if (wasViewable) - { - if (anyMarked) - { - if (pLayerWin->parent == pWin) - (*pScreen->MarkWindow)(pWin); - else - { - WindowPtr ptmp; - (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin, - (WindowPtr *)NULL); - (*pScreen->MarkWindow)(pLayerWin->parent); - - /* Windows between pWin and pLayerWin may not have been marked */ - ptmp = pWin; - - while (ptmp != pLayerWin->parent) - { - (*pScreen->MarkWindow)(ptmp); - ptmp = ptmp->parent; - } - pHead = pWin->firstChild; - } - (*pScreen->ValidateTree)(pLayerWin->parent, pHead, VTUnmap); - (*pScreen->HandleExposures)(pLayerWin->parent); - } - if (anyMarked && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, pHead, VTUnmap); - } - if (wasRealized) - WindowsRestructured (); -} - - -void -HandleSaveSet(ClientPtr client) -{ - WindowPtr pParent, pWin; - int j; - - for (j=0; jnumSaved; j++) - { - pWin = SaveSetWindow(client->saveSet[j]); -#ifdef XFIXES - if (SaveSetToRoot(client->saveSet[j])) - pParent = pWin->drawable.pScreen->root; - else -#endif - { - pParent = pWin->parent; - while (pParent && (wClient (pParent) == client)) - pParent = pParent->parent; - } - if (pParent) - { - if (pParent != pWin->parent) - { -#ifdef XFIXES - /* unmap first so that ReparentWindow doesn't remap */ - if (!SaveSetShouldMap (client->saveSet[j])) - UnmapWindow(pWin, FALSE); -#endif - ReparentWindow(pWin, pParent, - pWin->drawable.x - wBorderWidth (pWin) - pParent->drawable.x, - pWin->drawable.y - wBorderWidth (pWin) - pParent->drawable.y, - client); - if(!pWin->realized && pWin->mapped) - pWin->mapped = FALSE; - } -#ifdef XFIXES - if (SaveSetShouldMap (client->saveSet[j])) -#endif - MapWindow(pWin, client); - } - } - free(client->saveSet); - client->numSaved = 0; - client->saveSet = (SaveSetElt *)NULL; -} - -/** - * - * \param x,y in root - */ -Bool -PointInWindowIsVisible(WindowPtr pWin, int x, int y) -{ - BoxRec box; - - if (!pWin->realized) - return FALSE; - if (RegionContainsPoint(&pWin->borderClip, - x, y, &box) - && (!wInputShape(pWin) || - RegionContainsPoint(wInputShape(pWin), - x - pWin->drawable.x, - y - pWin->drawable.y, &box))) - return TRUE; - return FALSE; -} - - -RegionPtr -NotClippedByChildren(WindowPtr pWin) -{ - RegionPtr pReg = RegionCreate(NullBox, 1); - if (pWin->parent || - screenIsSaved != SCREEN_SAVER_ON || - !HasSaverWindow (pWin->drawable.pScreen)) - { - RegionIntersect(pReg, &pWin->borderClip, &pWin->winSize); - } - return pReg; -} - -void -SendVisibilityNotify(WindowPtr pWin) -{ - xEvent event; - unsigned int visibility = pWin->visibility; - - if (!MapUnmapEventsEnabled(pWin)) - return; -#ifdef PANORAMIX - /* This is not quite correct yet, but it's close */ - if(!noPanoramiXExtension) { - PanoramiXRes *win; - WindowPtr pWin2; - int rc, i, Scrnum; - - Scrnum = pWin->drawable.pScreen->myNum; - - win = PanoramiXFindIDByScrnum(XRT_WINDOW, pWin->drawable.id, Scrnum); - - if(!win || (win->u.win.visibility == visibility)) - return; - - switch(visibility) { - case VisibilityUnobscured: - for(i = 0; i < PanoramiXNumScreens; i++) { - if(i == Scrnum) continue; - - rc = dixLookupWindow(&pWin2, win->info[i].id, serverClient, - DixWriteAccess); - - if (rc == Success) { - if(pWin2->visibility == VisibilityPartiallyObscured) - return; - - if(!i) pWin = pWin2; - } - } - break; - case VisibilityPartiallyObscured: - if(Scrnum) { - rc = dixLookupWindow(&pWin2, win->info[0].id, serverClient, - DixWriteAccess); - if (rc == Success) pWin = pWin2; - } - break; - case VisibilityFullyObscured: - for(i = 0; i < PanoramiXNumScreens; i++) { - if(i == Scrnum) continue; - - rc = dixLookupWindow(&pWin2, win->info[i].id, serverClient, - DixWriteAccess); - - if (rc == Success) { - if(pWin2->visibility != VisibilityFullyObscured) - return; - - if(!i) pWin = pWin2; - } - } - break; - } - - win->u.win.visibility = visibility; - } -#endif - - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = VisibilityNotify; - event.u.visibility.window = pWin->drawable.id; - event.u.visibility.state = visibility; - DeliverEvents(pWin, &event, 1, NullWindow); -} - -#define RANDOM_WIDTH 32 -int -dixSaveScreens(ClientPtr client, int on, int mode) -{ - int rc, i, what, type; - - if (on == SCREEN_SAVER_FORCER) - { - if (mode == ScreenSaverReset) - what = SCREEN_SAVER_OFF; - else - what = SCREEN_SAVER_ON; - type = what; - } - else - { - what = on; - type = what; - if (what == screenIsSaved) - type = SCREEN_SAVER_CYCLE; - } - - for (i = 0; i < screenInfo.numScreens; i++) { - rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i], - DixShowAccess | DixHideAccess); - if (rc != Success) - return rc; - } - for (i = 0; i < screenInfo.numScreens; i++) - { - ScreenPtr pScreen = screenInfo.screens[i]; - if (on == SCREEN_SAVER_FORCER) - (* pScreen->SaveScreen) (pScreen, on); - if (pScreen->screensaver.ExternalScreenSaver) - { - if ((*pScreen->screensaver.ExternalScreenSaver) - (pScreen, type, on == SCREEN_SAVER_FORCER)) - continue; - } - if (type == screenIsSaved) - continue; - switch (type) { - case SCREEN_SAVER_OFF: - if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED) - { - (* pScreen->SaveScreen) (pScreen, what); - } - else if (HasSaverWindow (pScreen)) - { - pScreen->screensaver.pWindow = NullWindow; - FreeResource(pScreen->screensaver.wid, RT_NONE); - } - break; - case SCREEN_SAVER_CYCLE: - if (pScreen->screensaver.blanked == SCREEN_IS_TILED) - { - WindowPtr pWin = pScreen->screensaver.pWindow; - /* make it look like screen saver is off, so that - * NotClippedByChildren will compute a clip list - * for the root window, so miPaintWindow works - */ - screenIsSaved = SCREEN_SAVER_OFF; - (*pWin->drawable.pScreen->MoveWindow)(pWin, - (short)(-(rand() % RANDOM_WIDTH)), - (short)(-(rand() % RANDOM_WIDTH)), - pWin->nextSib, VTMove); - screenIsSaved = SCREEN_SAVER_ON; - } - /* - * Call the DDX saver in case it wants to do something - * at cycle time - */ - else if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED) - { - (* pScreen->SaveScreen) (pScreen, type); - } - break; - case SCREEN_SAVER_ON: - if (ScreenSaverBlanking != DontPreferBlanking) - { - if ((* pScreen->SaveScreen) (pScreen, what)) - { - pScreen->screensaver.blanked = SCREEN_IS_BLANKED; - continue; - } - if ((ScreenSaverAllowExposures != DontAllowExposures) && - TileScreenSaver(pScreen, SCREEN_IS_BLACK)) - { - pScreen->screensaver.blanked = SCREEN_IS_BLACK; - continue; - } - } - if ((ScreenSaverAllowExposures != DontAllowExposures) && - TileScreenSaver(pScreen, SCREEN_IS_TILED)) - { - pScreen->screensaver.blanked = SCREEN_IS_TILED; - } - else - pScreen->screensaver.blanked = SCREEN_ISNT_SAVED; - break; - } - } - screenIsSaved = what; - if (mode == ScreenSaverReset) { - if (on == SCREEN_SAVER_FORCER) { - UpdateCurrentTimeIf(); - lastDeviceEventTime = currentTime; - } - SetScreenSaverTimer(); - } - return Success; -} - -int -SaveScreens(int on, int mode) -{ - return dixSaveScreens(serverClient, on, mode); -} - -static Bool -TileScreenSaver(ScreenPtr pScreen, int kind) -{ - int j; - int result; - XID attributes[3]; - Mask mask; - WindowPtr pWin; - CursorMetricRec cm; - unsigned char *srcbits, *mskbits; - CursorPtr cursor; - XID cursorID = 0; - int attri; - - mask = 0; - attri = 0; - switch (kind) { - case SCREEN_IS_TILED: - switch (pScreen->root->backgroundState) { - case BackgroundPixel: - attributes[attri++] = pScreen->root->background.pixel; - mask |= CWBackPixel; - break; - case BackgroundPixmap: - attributes[attri++] = None; - mask |= CWBackPixmap; - break; - default: - break; - } - break; - case SCREEN_IS_BLACK: - attributes[attri++] = pScreen->root->drawable.pScreen->blackPixel; - mask |= CWBackPixel; - break; - } - mask |= CWOverrideRedirect; - attributes[attri++] = xTrue; - - /* - * create a blank cursor - */ - - cm.width=16; - cm.height=16; - cm.xhot=8; - cm.yhot=8; - srcbits = malloc( BitmapBytePad(32)*16); - mskbits = malloc( BitmapBytePad(32)*16); - if (!srcbits || !mskbits) - { - free(srcbits); - free(mskbits); - cursor = 0; - } - else - { - for (j=0; jscreensaver.pWindow = - CreateWindow(pScreen->screensaver.wid, - pScreen->root, - -RANDOM_WIDTH, -RANDOM_WIDTH, - (unsigned short)pScreen->width + RANDOM_WIDTH, - (unsigned short)pScreen->height + RANDOM_WIDTH, - 0, InputOutput, mask, attributes, 0, serverClient, - wVisual (pScreen->root), &result); - - if (cursor) - FreeResource (cursorID, RT_NONE); - - if (!pWin) - return FALSE; - - if (!AddResource(pWin->drawable.id, RT_WINDOW, - (pointer)pScreen->screensaver.pWindow)) - return FALSE; - - if (mask & CWBackPixmap) - { - MakeRootTile (pWin); - (*pWin->drawable.pScreen->ChangeWindowAttributes)(pWin, CWBackPixmap); - } - MapWindow(pWin, serverClient); - return TRUE; -} - -/* - * FindWindowWithOptional - * - * search ancestors of the given window for an entry containing - * a WindowOpt structure. Assumptions: some parent will - * contain the structure. - */ - -WindowPtr -FindWindowWithOptional (WindowPtr w) -{ - do - w = w->parent; - while (!w->optional); - return w; -} - -/* - * CheckWindowOptionalNeed - * - * check each optional entry in the given window to see if - * the value is satisfied by the default rules. If so, - * release the optional record - */ - -void -CheckWindowOptionalNeed (WindowPtr w) -{ - WindowOptPtr optional; - WindowOptPtr parentOptional; - - if (!w->parent || !w->optional) - return; - optional = w->optional; - if (optional->dontPropagateMask != DontPropagateMasks[w->dontPropagate]) - return; - if (optional->otherEventMasks != 0) - return; - if (optional->otherClients != NULL) - return; - if (optional->passiveGrabs != NULL) - return; - if (optional->userProps != NULL) - return; - if (optional->backingBitPlanes != ~0L) - return; - if (optional->backingPixel != 0) - return; - if (optional->boundingShape != NULL) - return; - if (optional->clipShape != NULL) - return; - if (optional->inputShape != NULL) - return; - if (optional->inputMasks != NULL) - return; - if (optional->deviceCursors != NULL) - { - DevCursNodePtr pNode = optional->deviceCursors; - while(pNode) - { - if (pNode->cursor != None) - return; - pNode = pNode->next; - } - } - - parentOptional = FindWindowWithOptional(w)->optional; - if (optional->visual != parentOptional->visual) - return; - if (optional->cursor != None && - (optional->cursor != parentOptional->cursor || - w->parent->cursorIsNone)) - return; - if (optional->colormap != parentOptional->colormap) - return; - DisposeWindowOptional (w); -} - -/* - * MakeWindowOptional - * - * create an optional record and initialize it with the default - * values. - */ - -Bool -MakeWindowOptional (WindowPtr pWin) -{ - WindowOptPtr optional; - WindowOptPtr parentOptional; - - if (pWin->optional) - return TRUE; - optional = malloc(sizeof (WindowOptRec)); - if (!optional) - return FALSE; - optional->dontPropagateMask = DontPropagateMasks[pWin->dontPropagate]; - optional->otherEventMasks = 0; - optional->otherClients = NULL; - optional->passiveGrabs = NULL; - optional->userProps = NULL; - optional->backingBitPlanes = ~0L; - optional->backingPixel = 0; - optional->boundingShape = NULL; - optional->clipShape = NULL; - optional->inputShape = NULL; - optional->inputMasks = NULL; - optional->deviceCursors = NULL; - - parentOptional = FindWindowWithOptional(pWin)->optional; - optional->visual = parentOptional->visual; - if (!pWin->cursorIsNone) - { - optional->cursor = parentOptional->cursor; - optional->cursor->refcnt++; - } - else - { - optional->cursor = None; - } - optional->colormap = parentOptional->colormap; - pWin->optional = optional; - return TRUE; -} - -/* - * Changes the cursor struct for the given device and the given window. - * A cursor that does not have a device cursor set will use whatever the - * standard cursor is for the window. If all devices have a cursor set, - * changing the window cursor (e.g. using XDefineCursor()) will not have any - * visible effect. Only when one of the device cursors is set to None again, - * this device's cursor will display the changed standard cursor. - * - * CursorIsNone of the window struct is NOT modified if you set a device - * cursor. - * - * Assumption: If there is a node for a device in the list, the device has a - * cursor. If the cursor is set to None, it is inherited by the parent. - */ -int -ChangeWindowDeviceCursor(WindowPtr pWin, - DeviceIntPtr pDev, - CursorPtr pCursor) -{ - DevCursNodePtr pNode, pPrev; - CursorPtr pOldCursor = NULL; - ScreenPtr pScreen; - WindowPtr pChild; - - if (!pWin->optional && !MakeWindowOptional(pWin)) - return BadAlloc; - - /* 1) Check if window has device cursor set - * Yes: 1.1) swap cursor with given cursor if parent does not have same - * cursor, free old cursor - * 1.2) free old cursor, use parent cursor - * No: 1.1) add node to beginning of list. - * 1.2) add cursor to node if parent does not have same cursor - * 1.3) use parent cursor if parent does not have same cursor - * 2) Patch up children if child has a devcursor - * 2.1) if child has cursor None, it inherited from parent, set to old - * cursor - * 2.2) if child has same cursor as new cursor, remove and set to None - */ - - pScreen = pWin->drawable.pScreen; - - if (WindowSeekDeviceCursor(pWin, pDev, &pNode, &pPrev)) - { - /* has device cursor */ - - if (pNode->cursor == pCursor) - return Success; - - pOldCursor = pNode->cursor; - - if (!pCursor) /* remove from list */ - { - if(pPrev) - pPrev->next = pNode->next; - else - /* first item in list */ - pWin->optional->deviceCursors = pNode->next; - - free(pNode); - goto out; - } - - } else - { - /* no device cursor yet */ - DevCursNodePtr pNewNode; - - if (!pCursor) - return Success; - - pNewNode = malloc(sizeof(DevCursNodeRec)); - pNewNode->dev = pDev; - pNewNode->next = pWin->optional->deviceCursors; - pWin->optional->deviceCursors = pNewNode; - pNode = pNewNode; - - } - - if (pCursor && WindowParentHasDeviceCursor(pWin, pDev, pCursor)) - pNode->cursor = None; - else - { - pNode->cursor = pCursor; - pCursor->refcnt++; - } - - pNode = pPrev = NULL; - /* fix up children */ - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) - { - if (WindowSeekDeviceCursor(pChild, pDev, &pNode, &pPrev)) - { - if (pNode->cursor == None) /* inherited from parent */ - { - pNode->cursor = pOldCursor; - pOldCursor->refcnt++; - } else if (pNode->cursor == pCursor) - { - pNode->cursor = None; - FreeCursor(pCursor, (Cursor)0); /* fix up refcnt */ - } - } - } - -out: - if (pWin->realized) - WindowHasNewCursor(pWin); - - if (pOldCursor) - FreeCursor(pOldCursor, (Cursor)0); - - /* FIXME: We SHOULD check for an error value here XXX - (comment taken from ChangeWindowAttributes) */ - (*pScreen->ChangeWindowAttributes)(pWin, CWCursor); - - return Success; -} - -/* Get device cursor for given device or None if none is set */ -CursorPtr -WindowGetDeviceCursor(WindowPtr pWin, DeviceIntPtr pDev) -{ - DevCursorList pList; - - if (!pWin->optional || !pWin->optional->deviceCursors) - return NULL; - - pList = pWin->optional->deviceCursors; - - while(pList) - { - if (pList->dev == pDev) - { - if (pList->cursor == None) /* inherited from parent */ - return WindowGetDeviceCursor(pWin->parent, pDev); - else - return pList->cursor; - } - pList = pList->next; - } - return NULL; -} - -/* Searches for a DevCursorNode for the given window and device. If one is - * found, return True and set pNode and pPrev to the node and to the node - * before the node respectively. Otherwise return False. - * If the device is the first in list, pPrev is set to NULL. - */ -static Bool -WindowSeekDeviceCursor(WindowPtr pWin, - DeviceIntPtr pDev, - DevCursNodePtr* pNode, - DevCursNodePtr* pPrev) -{ - DevCursorList pList; - - if (!pWin->optional) - return FALSE; - - pList = pWin->optional->deviceCursors; - - if (pList && pList->dev == pDev) - { - *pNode = pList; - *pPrev = NULL; - return TRUE; - } - - while(pList) - { - if (pList->next) - { - if (pList->next->dev == pDev) - { - *pNode = pList->next; - *pPrev = pList; - return TRUE; - } - } - pList = pList->next; - } - return FALSE; -} - -/* Return True if a parent has the same device cursor set or False if - * otherwise - */ -static Bool -WindowParentHasDeviceCursor(WindowPtr pWin, - DeviceIntPtr pDev, - CursorPtr pCursor) -{ - WindowPtr pParent; - DevCursNodePtr pParentNode, pParentPrev; - - pParent = pWin->parent; - while(pParent) - { - if (WindowSeekDeviceCursor(pParent, pDev, - &pParentNode, &pParentPrev)) - { - /* if there is a node in the list, the win has a dev cursor */ - if (!pParentNode->cursor) /* inherited. */ - pParent = pParent->parent; - else if (pParentNode->cursor == pCursor) /* inherit */ - return TRUE; - else /* different cursor */ - return FALSE; - } - else - /* parent does not have a device cursor for our device */ - return FALSE; - } - return FALSE; -} +/* + +Copyright (c) 2006, Red Hat, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +*/ + +/* The panoramix components contained the following notice */ +/***************************************************************** + +Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, +BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of Digital Equipment Corporation +shall not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from Digital +Equipment Corporation. + +******************************************************************/ + + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "misc.h" +#include "scrnintstr.h" +#include "os.h" +#include "regionstr.h" +#include "validate.h" +#include "windowstr.h" +#include "input.h" +#include "inputstr.h" +#include "resource.h" +#include "colormapst.h" +#include "cursorstr.h" +#include "dixstruct.h" +#include "gcstruct.h" +#include "servermd.h" +#ifdef PANORAMIX +#include "panoramiX.h" +#include "panoramiXsrv.h" +#endif +#include "dixevents.h" +#include "globals.h" +#include "mi.h" /* miPaintWindow */ + +#include "privates.h" +#include "xace.h" + +/****** + * Window stuff for server + * + * CreateRootWindow, CreateWindow, ChangeWindowAttributes, + * GetWindowAttributes, DeleteWindow, DestroySubWindows, + * HandleSaveSet, ReparentWindow, MapWindow, MapSubWindows, + * UnmapWindow, UnmapSubWindows, ConfigureWindow, CirculateWindow, + * ChangeWindowDeviceCursor + ******/ + +Bool bgNoneRoot = FALSE; + +static unsigned char _back_lsb[4] = {0x88, 0x22, 0x44, 0x11}; +static unsigned char _back_msb[4] = {0x11, 0x44, 0x22, 0x88}; + +static Bool WindowParentHasDeviceCursor(WindowPtr pWin, + DeviceIntPtr pDev, + CursorPtr pCurs); +static Bool +WindowSeekDeviceCursor(WindowPtr pWin, + DeviceIntPtr pDev, + DevCursNodePtr* pNode, + DevCursNodePtr* pPrev); + +int screenIsSaved = SCREEN_SAVER_OFF; + +static Bool TileScreenSaver(ScreenPtr pScreen, int kind); + +#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \ + CWDontPropagate | CWOverrideRedirect | CWCursor ) + +#define BOXES_OVERLAP(b1, b2) \ + (!( ((b1)->x2 <= (b2)->x1) || \ + ( ((b1)->x1 >= (b2)->x2)) || \ + ( ((b1)->y2 <= (b2)->y1)) || \ + ( ((b1)->y1 >= (b2)->y2)) ) ) + +#define RedirectSend(pWin) \ + ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureRedirectMask) + +#define SubSend(pWin) \ + ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureNotifyMask) + +#define StrSend(pWin) \ + ((pWin->eventMask|wOtherEventMasks(pWin)) & StructureNotifyMask) + +#define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent)) + +#ifdef DEBUG +/****** + * PrintWindowTree + * For debugging only + ******/ + +static void +PrintChildren(WindowPtr p1, int indent) +{ + WindowPtr p2; + int i; + + while (p1) + { + p2 = p1->firstChild; + ErrorF("[dix] "); + for (i=0; idrawable.id); + RegionPrint(&p1->clipList); + PrintChildren(p2, indent+4); + p1 = p1->nextSib; + } +} + +static void +PrintWindowTree(void) +{ + int i; + WindowPtr pWin, p1; + + for (i=0; iroot; + RegionPrint(&pWin->clipList); + p1 = pWin->firstChild; + PrintChildren(p1, 4); + } +} +#endif + +int +TraverseTree(WindowPtr pWin, VisitWindowProcPtr func, pointer data) +{ + int result; + WindowPtr pChild; + + if (!(pChild = pWin)) + return WT_NOMATCH; + while (1) + { + result = (* func)(pChild, data); + if (result == WT_STOPWALKING) + return WT_STOPWALKING; + if ((result == WT_WALKCHILDREN) && pChild->firstChild) + { + pChild = pChild->firstChild; + continue; + } + while (!pChild->nextSib && (pChild != pWin)) + pChild = pChild->parent; + if (pChild == pWin) + break; + pChild = pChild->nextSib; + } + return WT_NOMATCH; +} + +/***** + * WalkTree + * Walk the window tree, for SCREEN, preforming FUNC(pWin, data) on + * each window. If FUNC returns WT_WALKCHILDREN, traverse the children, + * if it returns WT_DONTWALKCHILDREN, dont. If it returns WT_STOPWALKING + * exit WalkTree. Does depth-first traverse. + *****/ + +int +WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, pointer data) +{ + return(TraverseTree(pScreen->root, func, data)); +} + +/* hack for forcing backing store on all windows */ +int defaultBackingStore = NotUseful; +/* hack to force no backing store */ +Bool disableBackingStore = FALSE; +Bool enableBackingStore = FALSE; + +static void +SetWindowToDefaults(WindowPtr pWin) +{ + pWin->prevSib = NullWindow; + pWin->firstChild = NullWindow; + pWin->lastChild = NullWindow; + + pWin->valdata = (ValidatePtr)NULL; + pWin->optional = (WindowOptPtr)NULL; + pWin->cursorIsNone = TRUE; + + pWin->backingStore = NotUseful; + pWin->DIXsaveUnder = FALSE; + pWin->backStorage = (pointer) NULL; + + pWin->mapped = FALSE; /* off */ + pWin->realized = FALSE; /* off */ + pWin->viewable = FALSE; + pWin->visibility = VisibilityNotViewable; + pWin->overrideRedirect = FALSE; + pWin->saveUnder = FALSE; + + pWin->bitGravity = ForgetGravity; + pWin->winGravity = NorthWestGravity; + + pWin->eventMask = 0; + pWin->deliverableEvents = 0; + pWin->dontPropagate = 0; + pWin->forcedBS = FALSE; + pWin->redirectDraw = RedirectDrawNone; + pWin->forcedBG = FALSE; + +#ifdef ROOTLESS + pWin->rootlessUnhittable = FALSE; +#endif + +#ifdef COMPOSITE + pWin->damagedDescendants = FALSE; +#endif +} + +static void +MakeRootTile(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + GCPtr pGC; + unsigned char back[128]; + int len = BitmapBytePad(sizeof(long)); + unsigned char *from, *to; + int i, j; + + pWin->background.pixmap = (*pScreen->CreatePixmap)(pScreen, 4, 4, + pScreen->rootDepth, 0); + + pWin->backgroundState = BackgroundPixmap; + pGC = GetScratchGC(pScreen->rootDepth, pScreen); + if (!pWin->background.pixmap || !pGC) + FatalError("could not create root tile"); + + { + ChangeGCVal attributes[2]; + + attributes[0].val = pScreen->whitePixel; + attributes[1].val = pScreen->blackPixel; + + (void)ChangeGC(NullClient, pGC, GCForeground | GCBackground, attributes); + } + + ValidateGC((DrawablePtr)pWin->background.pixmap, pGC); + + from = (screenInfo.bitmapBitOrder == LSBFirst) ? _back_lsb : _back_msb; + to = back; + + for (i = 4; i > 0; i--, from++) + for (j = len; j > 0; j--) + *to++ = *from; + + (*pGC->ops->PutImage)((DrawablePtr)pWin->background.pixmap, pGC, 1, + 0, 0, len, 4, 0, XYBitmap, (char *)back); + + FreeScratchGC(pGC); + +} + +/***** + * CreateRootWindow + * Makes a window at initialization time for specified screen + *****/ + +Bool +CreateRootWindow(ScreenPtr pScreen) +{ + WindowPtr pWin; + BoxRec box; + PixmapFormatRec *format; + + pWin = dixAllocateObjectWithPrivates(WindowRec, PRIVATE_WINDOW); + if (!pWin) + return FALSE; + + pScreen->screensaver.pWindow = NULL; + pScreen->screensaver.wid = FakeClientID(0); + pScreen->screensaver.ExternalScreenSaver = NULL; + screenIsSaved = SCREEN_SAVER_OFF; + + pScreen->root = pWin; + + pWin->drawable.pScreen = pScreen; + pWin->drawable.type = DRAWABLE_WINDOW; + + pWin->drawable.depth = pScreen->rootDepth; + for (format = screenInfo.formats; + format->depth != pScreen->rootDepth; + format++) + ; + pWin->drawable.bitsPerPixel = format->bitsPerPixel; + + pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER; + + pWin->parent = NullWindow; + SetWindowToDefaults(pWin); + + pWin->optional = malloc(sizeof (WindowOptRec)); + if (!pWin->optional) + return FALSE; + + pWin->optional->dontPropagateMask = 0; + pWin->optional->otherEventMasks = 0; + pWin->optional->otherClients = NULL; + pWin->optional->passiveGrabs = NULL; + pWin->optional->userProps = NULL; + pWin->optional->backingBitPlanes = ~0L; + pWin->optional->backingPixel = 0; + pWin->optional->boundingShape = NULL; + pWin->optional->clipShape = NULL; + pWin->optional->inputShape = NULL; + pWin->optional->inputMasks = NULL; + pWin->optional->deviceCursors = NULL; + pWin->optional->colormap = pScreen->defColormap; + pWin->optional->visual = pScreen->rootVisual; + + pWin->nextSib = NullWindow; + + pWin->drawable.id = FakeClientID(0); + + pWin->origin.x = pWin->origin.y = 0; + pWin->drawable.height = pScreen->height; + pWin->drawable.width = pScreen->width; + pWin->drawable.x = pWin->drawable.y = 0; + + box.x1 = 0; + box.y1 = 0; + box.x2 = pScreen->width; + box.y2 = pScreen->height; + RegionInit(&pWin->clipList, &box, 1); + RegionInit(&pWin->winSize, &box, 1); + RegionInit(&pWin->borderSize, &box, 1); + RegionInit(&pWin->borderClip, &box, 1); + + pWin->drawable.class = InputOutput; + pWin->optional->visual = pScreen->rootVisual; + + pWin->backgroundState = BackgroundPixel; + pWin->background.pixel = pScreen->whitePixel; + + pWin->borderIsPixel = TRUE; + pWin->border.pixel = pScreen->blackPixel; + pWin->borderWidth = 0; + + /* security creation/labeling check + */ + if (XaceHook(XACE_RESOURCE_ACCESS, serverClient, pWin->drawable.id, + RT_WINDOW, pWin, RT_NONE, NULL, DixCreateAccess)) + return FALSE; + + if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer)pWin)) + return FALSE; + + if (disableBackingStore) + pScreen->backingStoreSupport = NotUseful; + if (enableBackingStore) + pScreen->backingStoreSupport = Always; + + pScreen->saveUnderSupport = NotUseful; + + return TRUE; +} + +void +InitRootWindow(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + int backFlag = CWBorderPixel | CWCursor | CWBackingStore; + + if (!(*pScreen->CreateWindow)(pWin)) + return; /* XXX */ + (*pScreen->PositionWindow)(pWin, 0, 0); + + pWin->cursorIsNone = FALSE; + pWin->optional->cursor = rootCursor; + rootCursor->refcnt++; + + + if (party_like_its_1989) { + MakeRootTile(pWin); + backFlag |= CWBackPixmap; + } else if (pScreen->canDoBGNoneRoot && bgNoneRoot) { + pWin->backgroundState = XaceBackgroundNoneState(pWin); + pWin->background.pixel = pScreen->whitePixel; + backFlag |= CWBackPixmap; + } else { + if (whiteRoot) + pWin->background.pixel = pScreen->whitePixel; + else + pWin->background.pixel = pScreen->blackPixel; + backFlag |= CWBackPixel; + } + + pWin->backingStore = defaultBackingStore; + pWin->forcedBS = (defaultBackingStore != NotUseful); + /* We SHOULD check for an error value here XXX */ + (*pScreen->ChangeWindowAttributes)(pWin, backFlag); + + MapWindow(pWin, serverClient); +} + +/* Set the region to the intersection of the rectangle and the + * window's winSize. The window is typically the parent of the + * window from which the region came. + */ + +static void +ClippedRegionFromBox(WindowPtr pWin, RegionPtr Rgn, + int x, int y, + int w, int h) +{ + BoxRec box = *RegionExtents(&pWin->winSize); + + /* we do these calculations to avoid overflows */ + if (x > box.x1) + box.x1 = x; + if (y > box.y1) + box.y1 = y; + x += w; + if (x < box.x2) + box.x2 = x; + y += h; + if (y < box.y2) + box.y2 = y; + if (box.x1 > box.x2) + box.x2 = box.x1; + if (box.y1 > box.y2) + box.y2 = box.y1; + RegionReset(Rgn, &box); + RegionIntersect(Rgn, Rgn, &pWin->winSize); +} + +static RealChildHeadProc realChildHeadProc = NULL; + +void +RegisterRealChildHeadProc (RealChildHeadProc proc) +{ + realChildHeadProc = proc; +} + + +WindowPtr +RealChildHead(WindowPtr pWin) +{ + if (realChildHeadProc) { + return realChildHeadProc (pWin); + } + + if (!pWin->parent && + (screenIsSaved == SCREEN_SAVER_ON) && + (HasSaverWindow (pWin->drawable.pScreen))) + return pWin->firstChild; + else + return NullWindow; +} + +/***** + * CreateWindow + * Makes a window in response to client request + *****/ + +WindowPtr +CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w, + unsigned h, unsigned bw, unsigned class, Mask vmask, XID *vlist, + int depth, ClientPtr client, VisualID visual, int *error) +{ + WindowPtr pWin; + WindowPtr pHead; + ScreenPtr pScreen; + xEvent event; + int idepth, ivisual; + Bool fOK; + DepthPtr pDepth; + PixmapFormatRec *format; + WindowOptPtr ancwopt; + + if (class == CopyFromParent) + class = pParent->drawable.class; + + if ((class != InputOutput) && (class != InputOnly)) + { + *error = BadValue; + client->errorValue = class; + return NullWindow; + } + + if ((class != InputOnly) && (pParent->drawable.class == InputOnly)) + { + *error = BadMatch; + return NullWindow; + } + + if ((class == InputOnly) && ((bw != 0) || (depth != 0))) + { + *error = BadMatch; + return NullWindow; + } + + pScreen = pParent->drawable.pScreen; + if ((class == InputOutput) && (depth == 0)) + depth = pParent->drawable.depth; + ancwopt = pParent->optional; + if (!ancwopt) + ancwopt = FindWindowWithOptional(pParent)->optional; + if (visual == CopyFromParent) { + visual = ancwopt->visual; + } + + /* Find out if the depth and visual are acceptable for this Screen */ + if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth)) + { + fOK = FALSE; + for(idepth = 0; idepth < pScreen->numDepths; idepth++) + { + pDepth = (DepthPtr) &pScreen->allowedDepths[idepth]; + if ((depth == pDepth->depth) || (depth == 0)) + { + for (ivisual = 0; ivisual < pDepth->numVids; ivisual++) + { + if (visual == pDepth->vids[ivisual]) + { + fOK = TRUE; + break; + } + } + } + } + if (fOK == FALSE) + { + *error = BadMatch; + return NullWindow; + } + } + + if (((vmask & (CWBorderPixmap | CWBorderPixel)) == 0) && + (class != InputOnly) && + (depth != pParent->drawable.depth)) + { + *error = BadMatch; + return NullWindow; + } + + if (((vmask & CWColormap) == 0) && + (class != InputOnly) && + ((visual != ancwopt->visual) || (ancwopt->colormap == None))) + { + *error = BadMatch; + return NullWindow; + } + + pWin = dixAllocateObjectWithPrivates(WindowRec, PRIVATE_WINDOW); + if (!pWin) + { + *error = BadAlloc; + return NullWindow; + } + pWin->drawable = pParent->drawable; + pWin->drawable.depth = depth; + if (depth == pParent->drawable.depth) + pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel; + else + { + for (format = screenInfo.formats; format->depth != depth; format++) + ; + pWin->drawable.bitsPerPixel = format->bitsPerPixel; + } + if (class == InputOnly) + pWin->drawable.type = (short) UNDRAWABLE_WINDOW; + pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER; + + pWin->drawable.id = wid; + pWin->drawable.class = class; + + pWin->parent = pParent; + SetWindowToDefaults(pWin); + + if (visual != ancwopt->visual) + { + if (!MakeWindowOptional (pWin)) + { + dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW); + *error = BadAlloc; + return NullWindow; + } + pWin->optional->visual = visual; + pWin->optional->colormap = None; + } + + pWin->borderWidth = bw; + + /* security creation/labeling check + */ + *error = XaceHook(XACE_RESOURCE_ACCESS, client, wid, RT_WINDOW, pWin, + RT_WINDOW, pWin->parent, DixCreateAccess|DixSetAttrAccess); + if (*error != Success) { + dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW); + return NullWindow; + } + + pWin->backgroundState = XaceBackgroundNoneState(pWin); + pWin->background.pixel = pScreen->whitePixel; + + pWin->borderIsPixel = pParent->borderIsPixel; + pWin->border = pParent->border; + if (pWin->borderIsPixel == FALSE) + pWin->border.pixmap->refcnt++; + + pWin->origin.x = x + (int)bw; + pWin->origin.y = y + (int)bw; + pWin->drawable.width = w; + pWin->drawable.height = h; + pWin->drawable.x = pParent->drawable.x + x + (int)bw; + pWin->drawable.y = pParent->drawable.y + y + (int)bw; + + /* set up clip list correctly for unobscured WindowPtr */ + RegionNull(&pWin->clipList); + RegionNull(&pWin->borderClip); + RegionNull(&pWin->winSize); + RegionNull(&pWin->borderSize); + + pHead = RealChildHead(pParent); + if (pHead) + { + pWin->nextSib = pHead->nextSib; + if (pHead->nextSib) + pHead->nextSib->prevSib = pWin; + else + pParent->lastChild = pWin; + pHead->nextSib = pWin; + pWin->prevSib = pHead; + } + else + { + pWin->nextSib = pParent->firstChild; + if (pParent->firstChild) + pParent->firstChild->prevSib = pWin; + else + pParent->lastChild = pWin; + pParent->firstChild = pWin; + } + + SetWinSize (pWin); + SetBorderSize (pWin); + + /* We SHOULD check for an error value here XXX */ + if (!(*pScreen->CreateWindow)(pWin)) + { + *error = BadAlloc; + DeleteWindow(pWin, None); + return NullWindow; + } + /* We SHOULD check for an error value here XXX */ + (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y); + + if (!(vmask & CWEventMask)) + RecalculateDeliverableEvents(pWin); + + if (vmask) + *error = ChangeWindowAttributes(pWin, vmask, vlist, wClient (pWin)); + else + *error = Success; + + if (*error != Success) + { + DeleteWindow(pWin, None); + return NullWindow; + } + if (!(vmask & CWBackingStore) && (defaultBackingStore != NotUseful)) + { + XID value = defaultBackingStore; + (void)ChangeWindowAttributes(pWin, CWBackingStore, &value, wClient (pWin)); + pWin->forcedBS = TRUE; + } + + if (SubSend(pParent)) + { + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = CreateNotify; + event.u.createNotify.window = wid; + event.u.createNotify.parent = pParent->drawable.id; + event.u.createNotify.x = x; + event.u.createNotify.y = y; + event.u.createNotify.width = w; + event.u.createNotify.height = h; + event.u.createNotify.borderWidth = bw; + event.u.createNotify.override = pWin->overrideRedirect; + DeliverEvents(pParent, &event, 1, NullWindow); + } + return pWin; +} + +static void +DisposeWindowOptional (WindowPtr pWin) +{ + if (!pWin->optional) + return; + /* + * everything is peachy. Delete the optional record + * and clean up + */ + if (pWin->optional->cursor) + { + FreeCursor (pWin->optional->cursor, (Cursor)0); + pWin->cursorIsNone = FALSE; + } + else + pWin->cursorIsNone = TRUE; + + if (pWin->optional->deviceCursors) + { + DevCursorList pList; + DevCursorList pPrev; + pList = pWin->optional->deviceCursors; + while(pList) + { + if (pList->cursor) + FreeCursor(pList->cursor, (XID)0); + pPrev = pList; + pList = pList->next; + free(pPrev); + } + pWin->optional->deviceCursors = NULL; + } + + free(pWin->optional); + pWin->optional = NULL; +} + +static void +FreeWindowResources(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + + DeleteWindowFromAnySaveSet(pWin); + DeleteWindowFromAnySelections(pWin); + DeleteWindowFromAnyEvents(pWin, TRUE); + RegionUninit(&pWin->clipList); + RegionUninit(&pWin->winSize); + RegionUninit(&pWin->borderClip); + RegionUninit(&pWin->borderSize); + if (wBoundingShape (pWin)) + RegionDestroy(wBoundingShape (pWin)); + if (wClipShape (pWin)) + RegionDestroy(wClipShape (pWin)); + if (wInputShape (pWin)) + RegionDestroy(wInputShape (pWin)); + if (pWin->borderIsPixel == FALSE) + (*pScreen->DestroyPixmap)(pWin->border.pixmap); + if (pWin->backgroundState == BackgroundPixmap) + (*pScreen->DestroyPixmap)(pWin->background.pixmap); + + DeleteAllWindowProperties(pWin); + /* We SHOULD check for an error value here XXX */ + (*pScreen->DestroyWindow)(pWin); + DisposeWindowOptional (pWin); +} + +static void +CrushTree(WindowPtr pWin) +{ + WindowPtr pChild, pSib, pParent; + UnrealizeWindowProcPtr UnrealizeWindow; + xEvent event; + + if (!(pChild = pWin->firstChild)) + return; + UnrealizeWindow = pWin->drawable.pScreen->UnrealizeWindow; + while (1) + { + if (pChild->firstChild) + { + pChild = pChild->firstChild; + continue; + } + while (1) + { + pParent = pChild->parent; + if (SubStrSend(pChild, pParent)) + { + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = DestroyNotify; + event.u.destroyNotify.window = pChild->drawable.id; + DeliverEvents(pChild, &event, 1, NullWindow); + } + FreeResource(pChild->drawable.id, RT_WINDOW); + pSib = pChild->nextSib; + pChild->viewable = FALSE; + if (pChild->realized) + { + pChild->realized = FALSE; + (*UnrealizeWindow)(pChild); + } + FreeWindowResources(pChild); + dixFreeObjectWithPrivates(pChild, PRIVATE_WINDOW); + if ( (pChild = pSib) ) + break; + pChild = pParent; + pChild->firstChild = NullWindow; + pChild->lastChild = NullWindow; + if (pChild == pWin) + return; + } + } +} + +/***** + * DeleteWindow + * Deletes child of window then window itself + * If wid is None, don't send any events + *****/ + +int +DeleteWindow(pointer value, XID wid) + { + WindowPtr pParent; + WindowPtr pWin = (WindowPtr)value; + xEvent event; + + UnmapWindow(pWin, FALSE); + + CrushTree(pWin); + + pParent = pWin->parent; + if (wid && pParent && SubStrSend(pWin, pParent)) + { + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = DestroyNotify; + event.u.destroyNotify.window = pWin->drawable.id; + DeliverEvents(pWin, &event, 1, NullWindow); + } + + FreeWindowResources(pWin); + if (pParent) + { + if (pParent->firstChild == pWin) + pParent->firstChild = pWin->nextSib; + if (pParent->lastChild == pWin) + pParent->lastChild = pWin->prevSib; + if (pWin->nextSib) + pWin->nextSib->prevSib = pWin->prevSib; + if (pWin->prevSib) + pWin->prevSib->nextSib = pWin->nextSib; + } + else + pWin->drawable.pScreen->root = NULL; + dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW); + return Success; +} + +int +DestroySubwindows(WindowPtr pWin, ClientPtr client) +{ + /* XXX + * The protocol is quite clear that each window should be + * destroyed in turn, however, unmapping all of the first + * eliminates most of the calls to ValidateTree. So, + * this implementation is incorrect in that all of the + * UnmapNotifies occur before all of the DestroyNotifies. + * If you care, simply delete the call to UnmapSubwindows. + */ + UnmapSubwindows(pWin); + while (pWin->lastChild) { + int rc = XaceHook(XACE_RESOURCE_ACCESS, client, + pWin->lastChild->drawable.id, RT_WINDOW, + pWin->lastChild, RT_NONE, NULL, DixDestroyAccess); + if (rc != Success) + return rc; + FreeResource(pWin->lastChild->drawable.id, RT_NONE); + } + return Success; +} + +static void +SetRootWindowBackground(WindowPtr pWin, ScreenPtr pScreen, Mask *index2) +{ + /* following the protocol: "Changing the background of a root window to + * None or ParentRelative restores the default background pixmap" */ + if (bgNoneRoot) { + pWin->backgroundState = XaceBackgroundNoneState(pWin); + pWin->background.pixel = pScreen->whitePixel; + } + else if (party_like_its_1989) + MakeRootTile(pWin); + else { + if (whiteRoot) + pWin->background.pixel = pScreen->whitePixel; + else + pWin->background.pixel = pScreen->blackPixel; + *index2 = CWBackPixel; + } +} + +/***** + * ChangeWindowAttributes + * + * The value-mask specifies which attributes are to be changed; the + * value-list contains one value for each one bit in the mask, from least + * to most significant bit in the mask. + *****/ + +int +ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) +{ + XID *pVlist; + PixmapPtr pPixmap; + Pixmap pixID; + CursorPtr pCursor, pOldCursor; + Cursor cursorID; + WindowPtr pChild; + Colormap cmap; + ColormapPtr pCmap; + xEvent xE; + int error, rc; + ScreenPtr pScreen; + Mask index2, tmask, vmaskCopy = 0; + unsigned int val; + Bool checkOptional = FALSE, borderRelative = FALSE; + + if ((pWin->drawable.class == InputOnly) && (vmask & (~INPUTONLY_LEGAL_MASK))) + return BadMatch; + + error = Success; + pScreen = pWin->drawable.pScreen; + pVlist = vlist; + tmask = vmask; + while (tmask) + { + index2 = (Mask) lowbit (tmask); + tmask &= ~index2; + switch (index2) + { + case CWBackPixmap: + pixID = (Pixmap )*pVlist; + pVlist++; + if (pWin->backgroundState == ParentRelative) + borderRelative = TRUE; + if (pixID == None) + { + if (pWin->backgroundState == BackgroundPixmap) + (*pScreen->DestroyPixmap)(pWin->background.pixmap); + if (!pWin->parent) + SetRootWindowBackground(pWin, pScreen, &index2); + else { + pWin->backgroundState = XaceBackgroundNoneState(pWin); + pWin->background.pixel = pScreen->whitePixel; + } + } + else if (pixID == ParentRelative) + { + if (pWin->parent && + pWin->drawable.depth != pWin->parent->drawable.depth) + { + error = BadMatch; + goto PatchUp; + } + if (pWin->backgroundState == BackgroundPixmap) + (*pScreen->DestroyPixmap)(pWin->background.pixmap); + if (!pWin->parent) + SetRootWindowBackground(pWin, pScreen, &index2); + else + pWin->backgroundState = ParentRelative; + borderRelative = TRUE; + /* Note that the parent's backgroundTile's refcnt is NOT + * incremented. */ + } + else + { + rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP, + client, DixReadAccess); + if (rc == Success) + { + if ((pPixmap->drawable.depth != pWin->drawable.depth) || + (pPixmap->drawable.pScreen != pScreen)) + { + error = BadMatch; + goto PatchUp; + } + if (pWin->backgroundState == BackgroundPixmap) + (*pScreen->DestroyPixmap)(pWin->background.pixmap); + pWin->backgroundState = BackgroundPixmap; + pWin->background.pixmap = pPixmap; + pPixmap->refcnt++; + } + else + { + error = rc; + client->errorValue = pixID; + goto PatchUp; + } + } + break; + case CWBackPixel: + if (pWin->backgroundState == ParentRelative) + borderRelative = TRUE; + if (pWin->backgroundState == BackgroundPixmap) + (*pScreen->DestroyPixmap)(pWin->background.pixmap); + pWin->backgroundState = BackgroundPixel; + pWin->background.pixel = (CARD32 ) *pVlist; + /* background pixel overrides background pixmap, + so don't let the ddx layer see both bits */ + vmaskCopy &= ~CWBackPixmap; + pVlist++; + break; + case CWBorderPixmap: + pixID = (Pixmap ) *pVlist; + pVlist++; + if (pixID == CopyFromParent) + { + if (!pWin->parent || + (pWin->drawable.depth != pWin->parent->drawable.depth)) + { + error = BadMatch; + goto PatchUp; + } + if (pWin->parent->borderIsPixel == TRUE) { + if (pWin->borderIsPixel == FALSE) + (*pScreen->DestroyPixmap)(pWin->border.pixmap); + pWin->border = pWin->parent->border; + pWin->borderIsPixel = TRUE; + index2 = CWBorderPixel; + break; + } + else + { + pixID = pWin->parent->border.pixmap->drawable.id; + } + } + rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP, + client, DixReadAccess); + if (rc == Success) + { + if ((pPixmap->drawable.depth != pWin->drawable.depth) || + (pPixmap->drawable.pScreen != pScreen)) + { + error = BadMatch; + goto PatchUp; + } + if (pWin->borderIsPixel == FALSE) + (*pScreen->DestroyPixmap)(pWin->border.pixmap); + pWin->borderIsPixel = FALSE; + pWin->border.pixmap = pPixmap; + pPixmap->refcnt++; + } + else + { + error = rc; + client->errorValue = pixID; + goto PatchUp; + } + break; + case CWBorderPixel: + if (pWin->borderIsPixel == FALSE) + (*pScreen->DestroyPixmap)(pWin->border.pixmap); + pWin->borderIsPixel = TRUE; + pWin->border.pixel = (CARD32) *pVlist; + /* border pixel overrides border pixmap, + so don't let the ddx layer see both bits */ + vmaskCopy &= ~CWBorderPixmap; + pVlist++; + break; + case CWBitGravity: + val = (CARD8 )*pVlist; + pVlist++; + if (val > StaticGravity) + { + error = BadValue; + client->errorValue = val; + goto PatchUp; + } + pWin->bitGravity = val; + break; + case CWWinGravity: + val = (CARD8 )*pVlist; + pVlist++; + if (val > StaticGravity) + { + error = BadValue; + client->errorValue = val; + goto PatchUp; + } + pWin->winGravity = val; + break; + case CWBackingStore: + val = (CARD8 )*pVlist; + pVlist++; + if ((val != NotUseful) && (val != WhenMapped) && (val != Always)) + { + error = BadValue; + client->errorValue = val; + goto PatchUp; + } + pWin->backingStore = val; + pWin->forcedBS = FALSE; + break; + case CWBackingPlanes: + if (pWin->optional || ((CARD32)*pVlist != (CARD32)~0L)) { + if (!pWin->optional && !MakeWindowOptional (pWin)) + { + error = BadAlloc; + goto PatchUp; + } + pWin->optional->backingBitPlanes = (CARD32) *pVlist; + if ((CARD32)*pVlist == (CARD32)~0L) + checkOptional = TRUE; + } + pVlist++; + break; + case CWBackingPixel: + if (pWin->optional || (CARD32) *pVlist) { + if (!pWin->optional && !MakeWindowOptional (pWin)) + { + error = BadAlloc; + goto PatchUp; + } + pWin->optional->backingPixel = (CARD32) *pVlist; + if (!*pVlist) + checkOptional = TRUE; + } + pVlist++; + break; + case CWSaveUnder: + val = (BOOL) *pVlist; + pVlist++; + if ((val != xTrue) && (val != xFalse)) + { + error = BadValue; + client->errorValue = val; + goto PatchUp; + } + pWin->saveUnder = val; + break; + case CWEventMask: + rc = EventSelectForWindow(pWin, client, (Mask )*pVlist); + if (rc) + { + error = rc; + goto PatchUp; + } + pVlist++; + break; + case CWDontPropagate: + rc = EventSuppressForWindow(pWin, client, (Mask )*pVlist, + &checkOptional); + if (rc) + { + error = rc; + goto PatchUp; + } + pVlist++; + break; + case CWOverrideRedirect: + val = (BOOL ) *pVlist; + pVlist++; + if ((val != xTrue) && (val != xFalse)) + { + error = BadValue; + client->errorValue = val; + goto PatchUp; + } + if (val == xTrue) { + rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, + RT_WINDOW, pWin, RT_NONE, NULL, DixGrabAccess); + if (rc != Success) { + error = rc; + client->errorValue = pWin->drawable.id; + goto PatchUp; + } + } + pWin->overrideRedirect = val; + break; + case CWColormap: + cmap = (Colormap) *pVlist; + pVlist++; + if (cmap == CopyFromParent) + { + if (pWin->parent && + (!pWin->optional || + pWin->optional->visual == wVisual (pWin->parent))) + { + cmap = wColormap (pWin->parent); + } + else + cmap = None; + } + if (cmap == None) + { + error = BadMatch; + goto PatchUp; + } + rc = dixLookupResourceByType((pointer *)&pCmap, cmap, RT_COLORMAP, + client, DixUseAccess); + if (rc != Success) + { + error = rc; + client->errorValue = cmap; + goto PatchUp; + } + if (pCmap->pVisual->vid != wVisual (pWin) || + pCmap->pScreen != pScreen) + { + error = BadMatch; + goto PatchUp; + } + if (cmap != wColormap (pWin)) + { + if (!pWin->optional) + { + if (!MakeWindowOptional (pWin)) + { + error = BadAlloc; + goto PatchUp; + } + } + else if (pWin->parent && cmap == wColormap (pWin->parent)) + checkOptional = TRUE; + + /* + * propagate the original colormap to any children + * inheriting it + */ + + for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib) + { + if (!pChild->optional && !MakeWindowOptional (pChild)) + { + error = BadAlloc; + goto PatchUp; + } + } + + pWin->optional->colormap = cmap; + + /* + * check on any children now matching the new colormap + */ + + for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib) + { + if (pChild->optional->colormap == cmap) + CheckWindowOptionalNeed (pChild); + } + + xE.u.u.type = ColormapNotify; + xE.u.colormap.window = pWin->drawable.id; + xE.u.colormap.colormap = cmap; + xE.u.colormap.new = xTrue; + xE.u.colormap.state = IsMapInstalled(cmap, pWin); + DeliverEvents(pWin, &xE, 1, NullWindow); + } + break; + case CWCursor: + cursorID = (Cursor ) *pVlist; + pVlist++; + /* + * install the new + */ + if ( cursorID == None) + { + if (pWin == pWin->drawable.pScreen->root) + pCursor = rootCursor; + else + pCursor = (CursorPtr) None; + } + else + { + rc = dixLookupResourceByType((pointer *)&pCursor, cursorID, + RT_CURSOR, client, DixUseAccess); + if (rc != Success) + { + error = rc; + client->errorValue = cursorID; + goto PatchUp; + } + } + + if (pCursor != wCursor (pWin)) + { + /* + * patch up child windows so they don't lose cursors. + */ + + for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib) + { + if (!pChild->optional && !pChild->cursorIsNone && + !MakeWindowOptional (pChild)) + { + error = BadAlloc; + goto PatchUp; + } + } + + pOldCursor = 0; + if (pCursor == (CursorPtr) None) + { + pWin->cursorIsNone = TRUE; + if (pWin->optional) + { + pOldCursor = pWin->optional->cursor; + pWin->optional->cursor = (CursorPtr) None; + checkOptional = TRUE; + } + } else { + if (!pWin->optional) + { + if (!MakeWindowOptional (pWin)) + { + error = BadAlloc; + goto PatchUp; + } + } + else if (pWin->parent && pCursor == wCursor (pWin->parent)) + checkOptional = TRUE; + pOldCursor = pWin->optional->cursor; + pWin->optional->cursor = pCursor; + pCursor->refcnt++; + pWin->cursorIsNone = FALSE; + /* + * check on any children now matching the new cursor + */ + + for (pChild=pWin->firstChild; pChild; pChild=pChild->nextSib) + { + if (pChild->optional && + (pChild->optional->cursor == pCursor)) + CheckWindowOptionalNeed (pChild); + } + } + + if (pWin->realized) + WindowHasNewCursor( pWin); + + /* Can't free cursor until here - old cursor + * is needed in WindowHasNewCursor + */ + if (pOldCursor) + FreeCursor (pOldCursor, (Cursor)0); + } + break; + default: + error = BadValue; + client->errorValue = vmask; + goto PatchUp; + } + vmaskCopy |= index2; + } +PatchUp: + if (checkOptional) + CheckWindowOptionalNeed (pWin); + + /* We SHOULD check for an error value here XXX */ + (*pScreen->ChangeWindowAttributes)(pWin, vmaskCopy); + + /* + If the border contents have changed, redraw the border. + Note that this has to be done AFTER pScreen->ChangeWindowAttributes + for the tile to be rotated, and the correct function selected. + */ + if (((vmaskCopy & (CWBorderPixel | CWBorderPixmap)) || borderRelative) + && pWin->viewable && HasBorder (pWin)) + { + RegionRec exposed; + + RegionNull(&exposed); + RegionSubtract(&exposed, &pWin->borderClip, &pWin->winSize); + miPaintWindow(pWin, &exposed, PW_BORDER); + RegionUninit(&exposed); + } + return error; +} + + +/***** + * GetWindowAttributes + * Notice that this is different than ChangeWindowAttributes + *****/ + +void +GetWindowAttributes(WindowPtr pWin, ClientPtr client, xGetWindowAttributesReply *wa) +{ + wa->type = X_Reply; + wa->bitGravity = pWin->bitGravity; + wa->winGravity = pWin->winGravity; + if (pWin->forcedBS && pWin->backingStore != Always) + wa->backingStore = NotUseful; + else + wa->backingStore = pWin->backingStore; + wa->length = bytes_to_int32(sizeof(xGetWindowAttributesReply) - + sizeof(xGenericReply)); + wa->sequenceNumber = client->sequence; + wa->backingBitPlanes = wBackingBitPlanes (pWin); + wa->backingPixel = wBackingPixel (pWin); + wa->saveUnder = (BOOL)pWin->saveUnder; + wa->override = pWin->overrideRedirect; + if (!pWin->mapped) + wa->mapState = IsUnmapped; + else if (pWin->realized) + wa->mapState = IsViewable; + else + wa->mapState = IsUnviewable; + + wa->colormap = wColormap (pWin); + wa->mapInstalled = (wa->colormap == None) ? xFalse + : IsMapInstalled(wa->colormap, pWin); + + wa->yourEventMask = EventMaskForClient(pWin, client); + wa->allEventMasks = pWin->eventMask | wOtherEventMasks (pWin); + wa->doNotPropagateMask = wDontPropagateMask (pWin); + wa->class = pWin->drawable.class; + wa->visualID = wVisual (pWin); +} + + +WindowPtr +MoveWindowInStack(WindowPtr pWin, WindowPtr pNextSib) +{ + WindowPtr pParent = pWin->parent; + WindowPtr pFirstChange = pWin; /* highest window where list changes */ + + if (pWin->nextSib != pNextSib) + { + WindowPtr pOldNextSib = pWin->nextSib; + + if (!pNextSib) /* move to bottom */ + { + if (pParent->firstChild == pWin) + pParent->firstChild = pWin->nextSib; + /* if (pWin->nextSib) */ /* is always True: pNextSib == NULL + * and pWin->nextSib != pNextSib + * therefore pWin->nextSib != NULL */ + pFirstChange = pWin->nextSib; + pWin->nextSib->prevSib = pWin->prevSib; + if (pWin->prevSib) + pWin->prevSib->nextSib = pWin->nextSib; + pParent->lastChild->nextSib = pWin; + pWin->prevSib = pParent->lastChild; + pWin->nextSib = NullWindow; + pParent->lastChild = pWin; + } + else if (pParent->firstChild == pNextSib) /* move to top */ + { + pFirstChange = pWin; + if (pParent->lastChild == pWin) + pParent->lastChild = pWin->prevSib; + if (pWin->nextSib) + pWin->nextSib->prevSib = pWin->prevSib; + if (pWin->prevSib) + pWin->prevSib->nextSib = pWin->nextSib; + pWin->nextSib = pParent->firstChild; + pWin->prevSib = (WindowPtr ) NULL; + pNextSib->prevSib = pWin; + pParent->firstChild = pWin; + } + else /* move in middle of list */ + { + WindowPtr pOldNext = pWin->nextSib; + + pFirstChange = NullWindow; + if (pParent->firstChild == pWin) + pFirstChange = pParent->firstChild = pWin->nextSib; + if (pParent->lastChild == pWin) { + pFirstChange = pWin; + pParent->lastChild = pWin->prevSib; + } + if (pWin->nextSib) + pWin->nextSib->prevSib = pWin->prevSib; + if (pWin->prevSib) + pWin->prevSib->nextSib = pWin->nextSib; + pWin->nextSib = pNextSib; + pWin->prevSib = pNextSib->prevSib; + if (pNextSib->prevSib) + pNextSib->prevSib->nextSib = pWin; + pNextSib->prevSib = pWin; + if (!pFirstChange) { /* do we know it yet? */ + pFirstChange = pParent->firstChild; /* no, search from top */ + while ((pFirstChange != pWin) && (pFirstChange != pOldNext)) + pFirstChange = pFirstChange->nextSib; + } + } + if(pWin->drawable.pScreen->RestackWindow) + (*pWin->drawable.pScreen->RestackWindow)(pWin, pOldNextSib); + } + +#ifdef ROOTLESS + /* + * In rootless mode we can't optimize away window restacks. + * There may be non-X windows around, so even if the window + * is in the correct position from X's point of view, + * the underlying window system may want to reorder it. + */ + else if (pWin->drawable.pScreen->RestackWindow) + (*pWin->drawable.pScreen->RestackWindow)(pWin, pWin->nextSib); +#endif + + return pFirstChange; +} + +void +SetWinSize (WindowPtr pWin) +{ +#ifdef COMPOSITE + if (pWin->redirectDraw != RedirectDrawNone) + { + BoxRec box; + + /* + * Redirected clients get clip list equal to their + * own geometry, not clipped to their parent + */ + box.x1 = pWin->drawable.x; + box.y1 = pWin->drawable.y; + box.x2 = pWin->drawable.x + pWin->drawable.width; + box.y2 = pWin->drawable.y + pWin->drawable.height; + RegionReset(&pWin->winSize, &box); + } + else +#endif + ClippedRegionFromBox(pWin->parent, &pWin->winSize, + pWin->drawable.x, pWin->drawable.y, + (int)pWin->drawable.width, + (int)pWin->drawable.height); + if (wBoundingShape (pWin) || wClipShape (pWin)) { + RegionTranslate(&pWin->winSize, - pWin->drawable.x, + - pWin->drawable.y); + if (wBoundingShape (pWin)) + RegionIntersect(&pWin->winSize, &pWin->winSize, + wBoundingShape (pWin)); + if (wClipShape (pWin)) + RegionIntersect(&pWin->winSize, &pWin->winSize, + wClipShape (pWin)); + RegionTranslate(&pWin->winSize, pWin->drawable.x, + pWin->drawable.y); + } +} + +void +SetBorderSize (WindowPtr pWin) +{ + int bw; + + if (HasBorder (pWin)) { + bw = wBorderWidth (pWin); +#ifdef COMPOSITE + if (pWin->redirectDraw != RedirectDrawNone) + { + BoxRec box; + + /* + * Redirected clients get clip list equal to their + * own geometry, not clipped to their parent + */ + box.x1 = pWin->drawable.x - bw; + box.y1 = pWin->drawable.y - bw; + box.x2 = pWin->drawable.x + pWin->drawable.width + bw; + box.y2 = pWin->drawable.y + pWin->drawable.height + bw; + RegionReset(&pWin->borderSize, &box); + } + else +#endif + ClippedRegionFromBox(pWin->parent, &pWin->borderSize, + pWin->drawable.x - bw, pWin->drawable.y - bw, + (int)(pWin->drawable.width + (bw<<1)), + (int)(pWin->drawable.height + (bw<<1))); + if (wBoundingShape (pWin)) { + RegionTranslate(&pWin->borderSize, - pWin->drawable.x, + - pWin->drawable.y); + RegionIntersect(&pWin->borderSize, &pWin->borderSize, + wBoundingShape (pWin)); + RegionTranslate(&pWin->borderSize, pWin->drawable.x, + pWin->drawable.y); + RegionUnion(&pWin->borderSize, &pWin->borderSize, + &pWin->winSize); + } + } else { + RegionCopy(&pWin->borderSize, &pWin->winSize); + } +} + +/** + * + * \param x,y new window position + * \param oldx,oldy old window position + * \param destx,desty position relative to gravity + */ + +void +GravityTranslate (int x, int y, int oldx, int oldy, + int dw, int dh, unsigned gravity, + int *destx, int *desty) +{ + switch (gravity) { + case NorthGravity: + *destx = x + dw / 2; + *desty = y; + break; + case NorthEastGravity: + *destx = x + dw; + *desty = y; + break; + case WestGravity: + *destx = x; + *desty = y + dh / 2; + break; + case CenterGravity: + *destx = x + dw / 2; + *desty = y + dh / 2; + break; + case EastGravity: + *destx = x + dw; + *desty = y + dh / 2; + break; + case SouthWestGravity: + *destx = x; + *desty = y + dh; + break; + case SouthGravity: + *destx = x + dw / 2; + *desty = y + dh; + break; + case SouthEastGravity: + *destx = x + dw; + *desty = y + dh; + break; + case StaticGravity: + *destx = oldx; + *desty = oldy; + break; + default: + *destx = x; + *desty = y; + break; + } +} + +/* XXX need to retile border on each window with ParentRelative origin */ +void +ResizeChildrenWinSize(WindowPtr pWin, int dx, int dy, int dw, int dh) +{ + ScreenPtr pScreen; + WindowPtr pSib, pChild; + Bool resized = (dw || dh); + + pScreen = pWin->drawable.pScreen; + + for (pSib = pWin->firstChild; pSib; pSib = pSib->nextSib) + { + if (resized && (pSib->winGravity > NorthWestGravity)) + { + int cwsx, cwsy; + + cwsx = pSib->origin.x; + cwsy = pSib->origin.y; + GravityTranslate (cwsx, cwsy, cwsx - dx, cwsy - dy, dw, dh, + pSib->winGravity, &cwsx, &cwsy); + if (cwsx != pSib->origin.x || cwsy != pSib->origin.y) + { + xEvent event; + + event.u.u.type = GravityNotify; + event.u.gravity.window = pSib->drawable.id; + event.u.gravity.x = cwsx - wBorderWidth (pSib); + event.u.gravity.y = cwsy - wBorderWidth (pSib); + DeliverEvents (pSib, &event, 1, NullWindow); + pSib->origin.x = cwsx; + pSib->origin.y = cwsy; + } + } + pSib->drawable.x = pWin->drawable.x + pSib->origin.x; + pSib->drawable.y = pWin->drawable.y + pSib->origin.y; + SetWinSize (pSib); + SetBorderSize (pSib); + (*pScreen->PositionWindow)(pSib, pSib->drawable.x, pSib->drawable.y); + + if ( (pChild = pSib->firstChild) ) + { + while (1) + { + pChild->drawable.x = pChild->parent->drawable.x + + pChild->origin.x; + pChild->drawable.y = pChild->parent->drawable.y + + pChild->origin.y; + SetWinSize (pChild); + SetBorderSize (pChild); + (*pScreen->PositionWindow)(pChild, + pChild->drawable.x, pChild->drawable.y); + if (pChild->firstChild) + { + pChild = pChild->firstChild; + continue; + } + while (!pChild->nextSib && (pChild != pSib)) + pChild = pChild->parent; + if (pChild == pSib) + break; + pChild = pChild->nextSib; + } + } + } +} + +#define GET_INT16(m, f) \ + if (m & mask) \ + { \ + f = (INT16) *pVlist;\ + pVlist++; \ + } +#define GET_CARD16(m, f) \ + if (m & mask) \ + { \ + f = (CARD16) *pVlist;\ + pVlist++;\ + } + +#define GET_CARD8(m, f) \ + if (m & mask) \ + { \ + f = (CARD8) *pVlist;\ + pVlist++;\ + } + +#define ChangeMask ((Mask)(CWX | CWY | CWWidth | CWHeight)) + +#define IllegalInputOnlyConfigureMask (CWBorderWidth) + +/* + * IsSiblingAboveMe + * returns Above if pSib above pMe in stack or Below otherwise + */ + +static int +IsSiblingAboveMe( + WindowPtr pMe, + WindowPtr pSib) +{ + WindowPtr pWin; + + pWin = pMe->parent->firstChild; + while (pWin) + { + if (pWin == pSib) + return Above; + else if (pWin == pMe) + return Below; + pWin = pWin->nextSib; + } + return Below; +} + +static BoxPtr +WindowExtents( + WindowPtr pWin, + BoxPtr pBox) +{ + pBox->x1 = pWin->drawable.x - wBorderWidth (pWin); + pBox->y1 = pWin->drawable.y - wBorderWidth (pWin); + pBox->x2 = pWin->drawable.x + (int)pWin->drawable.width + + wBorderWidth (pWin); + pBox->y2 = pWin->drawable.y + (int)pWin->drawable.height + + wBorderWidth (pWin); + return pBox; +} + +#define IS_SHAPED(pWin) (wBoundingShape (pWin) != (RegionPtr) NULL) + +static RegionPtr +MakeBoundingRegion ( + WindowPtr pWin, + BoxPtr pBox) +{ + RegionPtr pRgn = RegionCreate(pBox, 1); + if (wBoundingShape (pWin)) { + RegionTranslate(pRgn, -pWin->origin.x, -pWin->origin.y); + RegionIntersect(pRgn, pRgn, wBoundingShape (pWin)); + RegionTranslate(pRgn, pWin->origin.x, pWin->origin.y); + } + return pRgn; +} + +static Bool +ShapeOverlap ( + WindowPtr pWin, + BoxPtr pWinBox, + WindowPtr pSib, + BoxPtr pSibBox) +{ + RegionPtr pWinRgn, pSibRgn; + Bool ret; + + if (!IS_SHAPED(pWin) && !IS_SHAPED(pSib)) + return TRUE; + pWinRgn = MakeBoundingRegion (pWin, pWinBox); + pSibRgn = MakeBoundingRegion (pSib, pSibBox); + RegionIntersect(pWinRgn, pWinRgn, pSibRgn); + ret = RegionNotEmpty(pWinRgn); + RegionDestroy(pWinRgn); + RegionDestroy(pSibRgn); + return ret; +} + +static Bool +AnyWindowOverlapsMe( + WindowPtr pWin, + WindowPtr pHead, + BoxPtr box) +{ + WindowPtr pSib; + BoxRec sboxrec; + BoxPtr sbox; + + for (pSib = pWin->prevSib; pSib != pHead; pSib = pSib->prevSib) + { + if (pSib->mapped) + { + sbox = WindowExtents(pSib, &sboxrec); + if (BOXES_OVERLAP(sbox, box) + && ShapeOverlap (pWin, box, pSib, sbox) + ) + return TRUE; + } + } + return FALSE; +} + +static Bool +IOverlapAnyWindow( + WindowPtr pWin, + BoxPtr box) +{ + WindowPtr pSib; + BoxRec sboxrec; + BoxPtr sbox; + + for (pSib = pWin->nextSib; pSib; pSib = pSib->nextSib) + { + if (pSib->mapped) + { + sbox = WindowExtents(pSib, &sboxrec); + if (BOXES_OVERLAP(sbox, box) + && ShapeOverlap (pWin, box, pSib, sbox) + ) + return TRUE; + } + } + return FALSE; +} + +/* + * WhereDoIGoInTheStack() + * Given pWin and pSib and the relationshipe smode, return + * the window that pWin should go ABOVE. + * If a pSib is specified: + * Above: pWin is placed just above pSib + * Below: pWin is placed just below pSib + * TopIf: if pSib occludes pWin, then pWin is placed + * at the top of the stack + * BottomIf: if pWin occludes pSib, then pWin is + * placed at the bottom of the stack + * Opposite: if pSib occludes pWin, then pWin is placed at the + * top of the stack, else if pWin occludes pSib, then + * pWin is placed at the bottom of the stack + * + * If pSib is NULL: + * Above: pWin is placed at the top of the stack + * Below: pWin is placed at the bottom of the stack + * TopIf: if any sibling occludes pWin, then pWin is placed at + * the top of the stack + * BottomIf: if pWin occludes any sibline, then pWin is placed at + * the bottom of the stack + * Opposite: if any sibling occludes pWin, then pWin is placed at + * the top of the stack, else if pWin occludes any + * sibling, then pWin is placed at the bottom of the stack + * + */ + +static WindowPtr +WhereDoIGoInTheStack( + WindowPtr pWin, + WindowPtr pSib, + short x, + short y, + unsigned short w, + unsigned short h, + int smode) +{ + BoxRec box; + WindowPtr pHead, pFirst; + + if ((pWin == pWin->parent->firstChild) && + (pWin == pWin->parent->lastChild)) + return((WindowPtr ) NULL); + pHead = RealChildHead(pWin->parent); + pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild; + box.x1 = x; + box.y1 = y; + box.x2 = x + (int)w; + box.y2 = y + (int)h; + switch (smode) + { + case Above: + if (pSib) + return pSib; + else if (pWin == pFirst) + return pWin->nextSib; + else + return pFirst; + case Below: + if (pSib) + if (pSib->nextSib != pWin) + return pSib->nextSib; + else + return pWin->nextSib; + else + return NullWindow; + case TopIf: + if ((!pWin->mapped || (pSib && !pSib->mapped))) + return pWin->nextSib; + else if (pSib) + { + if ((IsSiblingAboveMe(pWin, pSib) == Above) && + (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT)) + return pFirst; + else + return pWin->nextSib; + } + else if (AnyWindowOverlapsMe(pWin, pHead, &box)) + return pFirst; + else + return pWin->nextSib; + case BottomIf: + if ((!pWin->mapped || (pSib && !pSib->mapped))) + return pWin->nextSib; + else if (pSib) + { + if ((IsSiblingAboveMe(pWin, pSib) == Below) && + (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT)) + return NullWindow; + else + return pWin->nextSib; + } + else if (IOverlapAnyWindow(pWin, &box)) + return NullWindow; + else + return pWin->nextSib; + case Opposite: + if ((!pWin->mapped || (pSib && !pSib->mapped))) + return pWin->nextSib; + else if (pSib) + { + if (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT) + { + if (IsSiblingAboveMe(pWin, pSib) == Above) + return pFirst; + else + return NullWindow; + } + else + return pWin->nextSib; + } + else if (AnyWindowOverlapsMe(pWin, pHead, &box)) + { + /* If I'm occluded, I can't possibly be the first child + * if (pWin == pWin->parent->firstChild) + * return pWin->nextSib; + */ + return pFirst; + } + else if (IOverlapAnyWindow(pWin, &box)) + return NullWindow; + else + return pWin->nextSib; + default: + { + /* should never happen; make something up. */ + return pWin->nextSib; + } + } +} + +static void +ReflectStackChange( + WindowPtr pWin, + WindowPtr pSib, + VTKind kind) +{ +/* Note that pSib might be NULL */ + + Bool WasViewable = (Bool)pWin->viewable; + Bool anyMarked; + WindowPtr pFirstChange; + WindowPtr pLayerWin; + ScreenPtr pScreen = pWin->drawable.pScreen; + + /* if this is a root window, can't be restacked */ + if (!pWin->parent) + return; + + pFirstChange = MoveWindowInStack(pWin, pSib); + + if (WasViewable) + { + anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, + &pLayerWin); + if (pLayerWin != pWin) pFirstChange = pLayerWin; + if (anyMarked) + { + (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, kind); + (*pScreen->HandleExposures)(pLayerWin->parent); + } + if (anyMarked && pWin->drawable.pScreen->PostValidateTree) + (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, kind); + } + if (pWin->realized) + WindowsRestructured (); +} + +/***** + * ConfigureWindow + *****/ + +int +ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client) +{ +#define RESTACK_WIN 0 +#define MOVE_WIN 1 +#define RESIZE_WIN 2 +#define REBORDER_WIN 3 + WindowPtr pSib = NullWindow; + WindowPtr pParent = pWin->parent; + Window sibwid = 0; + Mask index2, tmask; + XID *pVlist; + short x, y, beforeX, beforeY; + unsigned short w = pWin->drawable.width, + h = pWin->drawable.height, + bw = pWin->borderWidth; + int rc, action, smode = Above; + xEvent event; + + if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask)) + return BadMatch; + + if ((mask & CWSibling) && !(mask & CWStackMode)) + return BadMatch; + + pVlist = vlist; + + if (pParent) + { + x = pWin->drawable.x - pParent->drawable.x - (int)bw; + y = pWin->drawable.y - pParent->drawable.y - (int)bw; + } + else + { + x = pWin->drawable.x; + y = pWin->drawable.y; + } + beforeX = x; + beforeY = y; + action = RESTACK_WIN; + if ((mask & (CWX | CWY)) && (!(mask & (CWHeight | CWWidth)))) + { + GET_INT16(CWX, x); + GET_INT16(CWY, y); + action = MOVE_WIN; + } + /* or should be resized */ + else if (mask & (CWX | CWY | CWWidth | CWHeight)) + { + GET_INT16(CWX, x); + GET_INT16(CWY, y); + GET_CARD16(CWWidth, w); + GET_CARD16 (CWHeight, h); + if (!w || !h) + { + client->errorValue = 0; + return BadValue; + } + action = RESIZE_WIN; + } + tmask = mask & ~ChangeMask; + while (tmask) + { + index2 = (Mask)lowbit (tmask); + tmask &= ~index2; + switch (index2) + { + case CWBorderWidth: + GET_CARD16(CWBorderWidth, bw); + break; + case CWSibling: + sibwid = (Window ) *pVlist; + pVlist++; + rc = dixLookupWindow(&pSib, sibwid, client, DixGetAttrAccess); + if (rc != Success) + { + client->errorValue = sibwid; + return rc; + } + if (pSib->parent != pParent) + return BadMatch; + if (pSib == pWin) + return BadMatch; + break; + case CWStackMode: + GET_CARD8(CWStackMode, smode); + if ((smode != TopIf) && (smode != BottomIf) && + (smode != Opposite) && (smode != Above) && (smode != Below)) + { + client->errorValue = smode; + return BadValue; + } + break; + default: + client->errorValue = mask; + return BadValue; + } + } + /* root really can't be reconfigured, so just return */ + if (!pParent) + return Success; + + /* Figure out if the window should be moved. Doesnt + make the changes to the window if event sent */ + + if (mask & CWStackMode) + pSib = WhereDoIGoInTheStack(pWin, pSib, pParent->drawable.x + x, + pParent->drawable.y + y, + w + (bw << 1), h + (bw << 1), smode); + else + pSib = pWin->nextSib; + + + if ((!pWin->overrideRedirect) && + (RedirectSend(pParent) + )) + { + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = ConfigureRequest; + event.u.configureRequest.window = pWin->drawable.id; + if (mask & CWSibling) + event.u.configureRequest.sibling = sibwid; + else + event.u.configureRequest.sibling = None; + if (mask & CWStackMode) + event.u.u.detail = smode; + else + event.u.u.detail = Above; + event.u.configureRequest.x = x; + event.u.configureRequest.y = y; +#ifdef PANORAMIX + if(!noPanoramiXExtension && (!pParent || !pParent->parent)) { + event.u.configureRequest.x += screenInfo.screens[0]->x; + event.u.configureRequest.y += screenInfo.screens[0]->y; + } +#endif + event.u.configureRequest.width = w; + event.u.configureRequest.height = h; + event.u.configureRequest.borderWidth = bw; + event.u.configureRequest.valueMask = mask; + event.u.configureRequest.parent = pParent->drawable.id; + if (MaybeDeliverEventsToClient(pParent, &event, 1, + SubstructureRedirectMask, client) == 1) + return Success; + } + if (action == RESIZE_WIN) + { + Bool size_change = (w != pWin->drawable.width) + || (h != pWin->drawable.height); + if (size_change && ((pWin->eventMask|wOtherEventMasks(pWin)) & ResizeRedirectMask)) + { + xEvent eventT; + memset(&eventT, 0, sizeof(xEvent)); + eventT.u.u.type = ResizeRequest; + eventT.u.resizeRequest.window = pWin->drawable.id; + eventT.u.resizeRequest.width = w; + eventT.u.resizeRequest.height = h; + if (MaybeDeliverEventsToClient(pWin, &eventT, 1, + ResizeRedirectMask, client) == 1) + { + /* if event is delivered, leave the actual size alone. */ + w = pWin->drawable.width; + h = pWin->drawable.height; + size_change = FALSE; + } + } + if (!size_change) + { + if (mask & (CWX | CWY)) + action = MOVE_WIN; + else if (mask & (CWStackMode | CWBorderWidth)) + action = RESTACK_WIN; + else /* really nothing to do */ + return(Success) ; + } + } + + if (action == RESIZE_WIN) + /* we've already checked whether there's really a size change */ + goto ActuallyDoSomething; + if ((mask & CWX) && (x != beforeX)) + goto ActuallyDoSomething; + if ((mask & CWY) && (y != beforeY)) + goto ActuallyDoSomething; + if ((mask & CWBorderWidth) && (bw != wBorderWidth (pWin))) + goto ActuallyDoSomething; + if (mask & CWStackMode) + { +#ifndef ROOTLESS + /* See above for why we always reorder in rootless mode. */ + if (pWin->nextSib != pSib) +#endif + goto ActuallyDoSomething; + } + return Success; + +ActuallyDoSomething: + if (pWin->drawable.pScreen->ConfigNotify) + { + int ret; + ret = (*pWin->drawable.pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib); + if (ret) { + client->errorValue = 0; + return ret; + } + } + + if (SubStrSend(pWin, pParent)) + { + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = ConfigureNotify; + event.u.configureNotify.window = pWin->drawable.id; + if (pSib) + event.u.configureNotify.aboveSibling = pSib->drawable.id; + else + event.u.configureNotify.aboveSibling = None; + event.u.configureNotify.x = x; + event.u.configureNotify.y = y; +#ifdef PANORAMIX + if(!noPanoramiXExtension && (!pParent || !pParent->parent)) { + event.u.configureNotify.x += screenInfo.screens[0]->x; + event.u.configureNotify.y += screenInfo.screens[0]->y; + } +#endif + event.u.configureNotify.width = w; + event.u.configureNotify.height = h; + event.u.configureNotify.borderWidth = bw; + event.u.configureNotify.override = pWin->overrideRedirect; + DeliverEvents(pWin, &event, 1, NullWindow); + } + if (mask & CWBorderWidth) + { + if (action == RESTACK_WIN) + { + action = MOVE_WIN; + pWin->borderWidth = bw; + } + else if ((action == MOVE_WIN) && + (beforeX + wBorderWidth (pWin) == x + (int)bw) && + (beforeY + wBorderWidth (pWin) == y + (int)bw)) + { + action = REBORDER_WIN; + (*pWin->drawable.pScreen->ChangeBorderWidth)(pWin, bw); + } + else + pWin->borderWidth = bw; + } + if (action == MOVE_WIN) + (*pWin->drawable.pScreen->MoveWindow)(pWin, x, y, pSib, + (mask & CWBorderWidth) ? VTOther : VTMove); + else if (action == RESIZE_WIN) + (*pWin->drawable.pScreen->ResizeWindow)(pWin, x, y, w, h, pSib); + else if (mask & CWStackMode) + ReflectStackChange(pWin, pSib, VTOther); + + if (action != RESTACK_WIN) + CheckCursorConfinement(pWin); + return Success; +#undef RESTACK_WIN +#undef MOVE_WIN +#undef RESIZE_WIN +#undef REBORDER_WIN +} + + +/****** + * + * CirculateWindow + * For RaiseLowest, raises the lowest mapped child (if any) that is + * obscured by another child to the top of the stack. For LowerHighest, + * lowers the highest mapped child (if any) that is obscuring another + * child to the bottom of the stack. Exposure processing is performed + * + ******/ + +int +CirculateWindow(WindowPtr pParent, int direction, ClientPtr client) +{ + WindowPtr pWin, pHead, pFirst; + xEvent event; + BoxRec box; + + pHead = RealChildHead(pParent); + pFirst = pHead ? pHead->nextSib : pParent->firstChild; + if (direction == RaiseLowest) + { + for (pWin = pParent->lastChild; + (pWin != pHead) && + !(pWin->mapped && + AnyWindowOverlapsMe(pWin, pHead, WindowExtents(pWin, &box))); + pWin = pWin->prevSib) ; + if (pWin == pHead) + return Success; + } + else + { + for (pWin = pFirst; + pWin && + !(pWin->mapped && + IOverlapAnyWindow(pWin, WindowExtents(pWin, &box))); + pWin = pWin->nextSib) ; + if (!pWin) + return Success; + } + + event.u.circulate.window = pWin->drawable.id; + event.u.circulate.parent = pParent->drawable.id; + event.u.circulate.event = pParent->drawable.id; + if (direction == RaiseLowest) + event.u.circulate.place = PlaceOnTop; + else + event.u.circulate.place = PlaceOnBottom; + + if (RedirectSend(pParent)) + { + event.u.u.type = CirculateRequest; + if (MaybeDeliverEventsToClient(pParent, &event, 1, + SubstructureRedirectMask, client) == 1) + return Success; + } + + event.u.u.type = CirculateNotify; + DeliverEvents(pWin, &event, 1, NullWindow); + ReflectStackChange(pWin, + (direction == RaiseLowest) ? pFirst : NullWindow, + VTStack); + + return Success; +} + +static int +CompareWIDs( + WindowPtr pWin, + pointer value) /* must conform to VisitWindowProcPtr */ +{ + Window *wid = (Window *)value; + + if (pWin->drawable.id == *wid) + return WT_STOPWALKING; + else + return WT_WALKCHILDREN; +} + +/***** + * ReparentWindow + *****/ + +int +ReparentWindow(WindowPtr pWin, WindowPtr pParent, + int x, int y, ClientPtr client) +{ + WindowPtr pPrev, pPriorParent; + Bool WasMapped = (Bool)(pWin->mapped); + xEvent event; + int bw = wBorderWidth (pWin); + ScreenPtr pScreen; + + pScreen = pWin->drawable.pScreen; + if (TraverseTree(pWin, CompareWIDs, (pointer)&pParent->drawable.id) == WT_STOPWALKING) + return BadMatch; + if (!MakeWindowOptional(pWin)) + return BadAlloc; + + if (WasMapped) + UnmapWindow(pWin, FALSE); + + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = ReparentNotify; + event.u.reparent.window = pWin->drawable.id; + event.u.reparent.parent = pParent->drawable.id; + event.u.reparent.x = x; + event.u.reparent.y = y; +#ifdef PANORAMIX + if(!noPanoramiXExtension && !pParent->parent) { + event.u.reparent.x += screenInfo.screens[0]->x; + event.u.reparent.y += screenInfo.screens[0]->y; + } +#endif + event.u.reparent.override = pWin->overrideRedirect; + DeliverEvents(pWin, &event, 1, pParent); + + /* take out of sibling chain */ + + pPriorParent = pPrev = pWin->parent; + if (pPrev->firstChild == pWin) + pPrev->firstChild = pWin->nextSib; + if (pPrev->lastChild == pWin) + pPrev->lastChild = pWin->prevSib; + + if (pWin->nextSib) + pWin->nextSib->prevSib = pWin->prevSib; + if (pWin->prevSib) + pWin->prevSib->nextSib = pWin->nextSib; + + /* insert at begining of pParent */ + pWin->parent = pParent; + pPrev = RealChildHead(pParent); + if (pPrev) + { + pWin->nextSib = pPrev->nextSib; + if (pPrev->nextSib) + pPrev->nextSib->prevSib = pWin; + else + pParent->lastChild = pWin; + pPrev->nextSib = pWin; + pWin->prevSib = pPrev; + } + else + { + pWin->nextSib = pParent->firstChild; + pWin->prevSib = NullWindow; + if (pParent->firstChild) + pParent->firstChild->prevSib = pWin; + else + pParent->lastChild = pWin; + pParent->firstChild = pWin; + } + + pWin->origin.x = x + bw; + pWin->origin.y = y + bw; + pWin->drawable.x = x + bw + pParent->drawable.x; + pWin->drawable.y = y + bw + pParent->drawable.y; + + /* clip to parent */ + SetWinSize (pWin); + SetBorderSize (pWin); + + if (pScreen->ReparentWindow) + (*pScreen->ReparentWindow)(pWin, pPriorParent); + (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y); + ResizeChildrenWinSize(pWin, 0, 0, 0, 0); + + CheckWindowOptionalNeed(pWin); + + if (WasMapped) + MapWindow(pWin, client); + RecalculateDeliverableEvents(pWin); + return Success; +} + +static void +RealizeTree(WindowPtr pWin) +{ + WindowPtr pChild; + RealizeWindowProcPtr Realize; + + Realize = pWin->drawable.pScreen->RealizeWindow; + pChild = pWin; + while (1) + { + if (pChild->mapped) + { + pChild->realized = TRUE; + pChild->viewable = (pChild->drawable.class == InputOutput); + (* Realize)(pChild); + if (pChild->firstChild) + { + pChild = pChild->firstChild; + continue; + } + } + while (!pChild->nextSib && (pChild != pWin)) + pChild = pChild->parent; + if (pChild == pWin) + return; + pChild = pChild->nextSib; + } +} + +static WindowPtr windowDisableMapUnmapEvents; + +void +DisableMapUnmapEvents(WindowPtr pWin) +{ + assert (windowDisableMapUnmapEvents == NULL); + + windowDisableMapUnmapEvents = pWin; +} + +void +EnableMapUnmapEvents(WindowPtr pWin) +{ + assert (windowDisableMapUnmapEvents != NULL); + + windowDisableMapUnmapEvents = NULL; +} + +static Bool +MapUnmapEventsEnabled(WindowPtr pWin) +{ + return pWin != windowDisableMapUnmapEvents; +} + +/***** + * MapWindow + * If some other client has selected SubStructureReDirect on the parent + * and override-redirect is xFalse, then a MapRequest event is generated, + * but the window remains unmapped. Otherwise, the window is mapped and a + * MapNotify event is generated. + *****/ + +int +MapWindow(WindowPtr pWin, ClientPtr client) +{ + ScreenPtr pScreen; + + WindowPtr pParent; + WindowPtr pLayerWin; + + if (pWin->mapped) + return Success; + + /* general check for permission to map window */ + if (XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, RT_WINDOW, + pWin, RT_NONE, NULL, DixShowAccess) != Success) + return Success; + + pScreen = pWin->drawable.pScreen; + if ( (pParent = pWin->parent) ) + { + xEvent event; + Bool anyMarked; + + if ((!pWin->overrideRedirect) && + (RedirectSend(pParent) + )) + { + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = MapRequest; + event.u.mapRequest.window = pWin->drawable.id; + event.u.mapRequest.parent = pParent->drawable.id; + + if (MaybeDeliverEventsToClient(pParent, &event, 1, + SubstructureRedirectMask, client) == 1) + return Success; + } + + pWin->mapped = TRUE; + if (SubStrSend(pWin, pParent) && MapUnmapEventsEnabled(pWin)) + { + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = MapNotify; + event.u.mapNotify.window = pWin->drawable.id; + event.u.mapNotify.override = pWin->overrideRedirect; + DeliverEvents(pWin, &event, 1, NullWindow); + } + + if (!pParent->realized) + return Success; + RealizeTree(pWin); + if (pWin->viewable) + { + anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, + &pLayerWin); + if (anyMarked) + { + (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTMap); + (*pScreen->HandleExposures)(pLayerWin->parent); + } + if (anyMarked && pScreen->PostValidateTree) + (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTMap); + } + WindowsRestructured (); + } + else + { + RegionRec temp; + + pWin->mapped = TRUE; + pWin->realized = TRUE; /* for roots */ + pWin->viewable = pWin->drawable.class == InputOutput; + /* We SHOULD check for an error value here XXX */ + (*pScreen->RealizeWindow)(pWin); + if (pScreen->ClipNotify) + (*pScreen->ClipNotify) (pWin, 0, 0); + if (pScreen->PostValidateTree) + (*pScreen->PostValidateTree)(NullWindow, pWin, VTMap); + RegionNull(&temp); + RegionCopy(&temp, &pWin->clipList); + (*pScreen->WindowExposures) (pWin, &temp, NullRegion); + RegionUninit(&temp); + } + + return Success; +} + + +/***** + * MapSubwindows + * Performs a MapWindow all unmapped children of the window, in top + * to bottom stacking order. + *****/ + +void +MapSubwindows(WindowPtr pParent, ClientPtr client) +{ + WindowPtr pWin; + WindowPtr pFirstMapped = NullWindow; + ScreenPtr pScreen; + Mask parentRedirect; + Mask parentNotify; + xEvent event; + Bool anyMarked; + WindowPtr pLayerWin; + + pScreen = pParent->drawable.pScreen; + parentRedirect = RedirectSend(pParent); + parentNotify = SubSend(pParent); + anyMarked = FALSE; + for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib) + { + if (!pWin->mapped) + { + if (parentRedirect && !pWin->overrideRedirect) + { + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = MapRequest; + event.u.mapRequest.window = pWin->drawable.id; + event.u.mapRequest.parent = pParent->drawable.id; + + if (MaybeDeliverEventsToClient(pParent, &event, 1, + SubstructureRedirectMask, client) == 1) + continue; + } + + pWin->mapped = TRUE; + if (parentNotify || StrSend(pWin)) + { + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = MapNotify; + event.u.mapNotify.window = pWin->drawable.id; + event.u.mapNotify.override = pWin->overrideRedirect; + DeliverEvents(pWin, &event, 1, NullWindow); + } + + if (!pFirstMapped) + pFirstMapped = pWin; + if (pParent->realized) + { + RealizeTree(pWin); + if (pWin->viewable) + { + anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, + (WindowPtr *)NULL); + } + } + } + } + + if (pFirstMapped) + { + pLayerWin = (*pScreen->GetLayerWindow)(pParent); + if (pLayerWin->parent != pParent) { + anyMarked |= (*pScreen->MarkOverlappedWindows)(pLayerWin, + pLayerWin, + (WindowPtr *)NULL); + pFirstMapped = pLayerWin; + } + if (anyMarked) + { + (*pScreen->ValidateTree)(pLayerWin->parent, pFirstMapped, VTMap); + (*pScreen->HandleExposures)(pLayerWin->parent); + } + if (anyMarked && pScreen->PostValidateTree) + (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstMapped, + VTMap); + WindowsRestructured (); + } +} + +static void +UnrealizeTree( + WindowPtr pWin, + Bool fromConfigure) +{ + WindowPtr pChild; + UnrealizeWindowProcPtr Unrealize; + MarkUnrealizedWindowProcPtr MarkUnrealizedWindow; + + Unrealize = pWin->drawable.pScreen->UnrealizeWindow; + MarkUnrealizedWindow = pWin->drawable.pScreen->MarkUnrealizedWindow; + pChild = pWin; + while (1) + { + if (pChild->realized) + { + pChild->realized = FALSE; + pChild->visibility = VisibilityNotViewable; +#ifdef PANORAMIX + if(!noPanoramiXExtension && !pChild->drawable.pScreen->myNum) { + PanoramiXRes *win; + int rc = dixLookupResourceByType((pointer *)&win, + pChild->drawable.id, XRT_WINDOW, + serverClient, DixWriteAccess); + if (rc == Success) + win->u.win.visibility = VisibilityNotViewable; + } +#endif + (* Unrealize)(pChild); + if (MapUnmapEventsEnabled(pWin)) + DeleteWindowFromAnyEvents(pChild, FALSE); + if (pChild->viewable) + { + pChild->viewable = FALSE; + (* MarkUnrealizedWindow)(pChild, pWin, fromConfigure); + pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER; + } + if (pChild->firstChild) + { + pChild = pChild->firstChild; + continue; + } + } + while (!pChild->nextSib && (pChild != pWin)) + pChild = pChild->parent; + if (pChild == pWin) + return; + pChild = pChild->nextSib; + } +} + +/***** + * UnmapWindow + * If the window is already unmapped, this request has no effect. + * Otherwise, the window is unmapped and an UnMapNotify event is + * generated. Cannot unmap a root window. + *****/ + +int +UnmapWindow(WindowPtr pWin, Bool fromConfigure) +{ + WindowPtr pParent; + xEvent event; + Bool wasRealized = (Bool)pWin->realized; + Bool wasViewable = (Bool)pWin->viewable; + ScreenPtr pScreen = pWin->drawable.pScreen; + WindowPtr pLayerWin = pWin; + + if ((!pWin->mapped) || (!(pParent = pWin->parent))) + return Success; + if (SubStrSend(pWin, pParent) && MapUnmapEventsEnabled(pWin)) + { + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = UnmapNotify; + event.u.unmapNotify.window = pWin->drawable.id; + event.u.unmapNotify.fromConfigure = fromConfigure; + DeliverEvents(pWin, &event, 1, NullWindow); + } + if (wasViewable && !fromConfigure) + { + pWin->valdata = UnmapValData; + (*pScreen->MarkOverlappedWindows)(pWin, pWin->nextSib, &pLayerWin); + (*pScreen->MarkWindow)(pLayerWin->parent); + } + pWin->mapped = FALSE; + if (wasRealized) + UnrealizeTree(pWin, fromConfigure); + if (wasViewable) + { + if (!fromConfigure) + { + (*pScreen->ValidateTree)(pLayerWin->parent, pWin, VTUnmap); + (*pScreen->HandleExposures)(pLayerWin->parent); + } + if (!fromConfigure && pScreen->PostValidateTree) + (*pScreen->PostValidateTree)(pLayerWin->parent, pWin, VTUnmap); + } + if (wasRealized && !fromConfigure) + WindowsRestructured (); + return Success; +} + +/***** + * UnmapSubwindows + * Performs an UnmapWindow request with the specified mode on all mapped + * children of the window, in bottom to top stacking order. + *****/ + +void +UnmapSubwindows(WindowPtr pWin) +{ + WindowPtr pChild, pHead; + xEvent event; + Bool wasRealized = (Bool)pWin->realized; + Bool wasViewable = (Bool)pWin->viewable; + Bool anyMarked = FALSE; + Mask parentNotify; + WindowPtr pLayerWin = NULL; + ScreenPtr pScreen = pWin->drawable.pScreen; + + if (!pWin->firstChild) + return; + parentNotify = SubSend(pWin); + pHead = RealChildHead(pWin); + + if (wasViewable) + pLayerWin = (*pScreen->GetLayerWindow)(pWin); + + for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) + { + if (pChild->mapped) + { + if (parentNotify || StrSend(pChild)) + { + event.u.u.type = UnmapNotify; + event.u.unmapNotify.window = pChild->drawable.id; + event.u.unmapNotify.fromConfigure = xFalse; + DeliverEvents(pChild, &event, 1, NullWindow); + } + if (pChild->viewable) + { + pChild->valdata = UnmapValData; + anyMarked = TRUE; + } + pChild->mapped = FALSE; + if (pChild->realized) + UnrealizeTree(pChild, FALSE); + if (wasViewable) + { + } + } + } + if (wasViewable) + { + if (anyMarked) + { + if (pLayerWin->parent == pWin) + (*pScreen->MarkWindow)(pWin); + else + { + WindowPtr ptmp; + (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin, + (WindowPtr *)NULL); + (*pScreen->MarkWindow)(pLayerWin->parent); + + /* Windows between pWin and pLayerWin may not have been marked */ + ptmp = pWin; + + while (ptmp != pLayerWin->parent) + { + (*pScreen->MarkWindow)(ptmp); + ptmp = ptmp->parent; + } + pHead = pWin->firstChild; + } + (*pScreen->ValidateTree)(pLayerWin->parent, pHead, VTUnmap); + (*pScreen->HandleExposures)(pLayerWin->parent); + } + if (anyMarked && pScreen->PostValidateTree) + (*pScreen->PostValidateTree)(pLayerWin->parent, pHead, VTUnmap); + } + if (wasRealized) + WindowsRestructured (); +} + + +void +HandleSaveSet(ClientPtr client) +{ + WindowPtr pParent, pWin; + int j; + + for (j=0; jnumSaved; j++) + { + pWin = SaveSetWindow(client->saveSet[j]); +#ifdef XFIXES + if (SaveSetToRoot(client->saveSet[j])) + pParent = pWin->drawable.pScreen->root; + else +#endif + { + pParent = pWin->parent; + while (pParent && (wClient (pParent) == client)) + pParent = pParent->parent; + } + if (pParent) + { + if (pParent != pWin->parent) + { +#ifdef XFIXES + /* unmap first so that ReparentWindow doesn't remap */ + if (!SaveSetShouldMap (client->saveSet[j])) + UnmapWindow(pWin, FALSE); +#endif + ReparentWindow(pWin, pParent, + pWin->drawable.x - wBorderWidth (pWin) - pParent->drawable.x, + pWin->drawable.y - wBorderWidth (pWin) - pParent->drawable.y, + client); + if(!pWin->realized && pWin->mapped) + pWin->mapped = FALSE; + } +#ifdef XFIXES + if (SaveSetShouldMap (client->saveSet[j])) +#endif + MapWindow(pWin, client); + } + } + free(client->saveSet); + client->numSaved = 0; + client->saveSet = (SaveSetElt *)NULL; +} + +/** + * + * \param x,y in root + */ +Bool +PointInWindowIsVisible(WindowPtr pWin, int x, int y) +{ + BoxRec box; + + if (!pWin->realized) + return FALSE; + if (RegionContainsPoint(&pWin->borderClip, + x, y, &box) + && (!wInputShape(pWin) || + RegionContainsPoint(wInputShape(pWin), + x - pWin->drawable.x, + y - pWin->drawable.y, &box))) + return TRUE; + return FALSE; +} + + +RegionPtr +NotClippedByChildren(WindowPtr pWin) +{ + RegionPtr pReg = RegionCreate(NullBox, 1); + if (pWin->parent || + screenIsSaved != SCREEN_SAVER_ON || + !HasSaverWindow (pWin->drawable.pScreen)) + { + RegionIntersect(pReg, &pWin->borderClip, &pWin->winSize); + } + return pReg; +} + +void +SendVisibilityNotify(WindowPtr pWin) +{ + xEvent event; + unsigned int visibility = pWin->visibility; + + if (!MapUnmapEventsEnabled(pWin)) + return; +#ifdef PANORAMIX + /* This is not quite correct yet, but it's close */ + if(!noPanoramiXExtension) { + PanoramiXRes *win; + WindowPtr pWin2; + int rc, i, Scrnum; + + Scrnum = pWin->drawable.pScreen->myNum; + + win = PanoramiXFindIDByScrnum(XRT_WINDOW, pWin->drawable.id, Scrnum); + + if(!win || (win->u.win.visibility == visibility)) + return; + + switch(visibility) { + case VisibilityUnobscured: + FOR_NSCREENS(i) { + if(i == Scrnum) continue; + + rc = dixLookupWindow(&pWin2, win->info[i].id, serverClient, + DixWriteAccess); + + if (rc == Success) { + if(pWin2->visibility == VisibilityPartiallyObscured) + return; + + if(!i) pWin = pWin2; + } + } + break; + case VisibilityPartiallyObscured: + if(Scrnum) { + rc = dixLookupWindow(&pWin2, win->info[0].id, serverClient, + DixWriteAccess); + if (rc == Success) pWin = pWin2; + } + break; + case VisibilityFullyObscured: + FOR_NSCREENS(i) { + if(i == Scrnum) continue; + + rc = dixLookupWindow(&pWin2, win->info[i].id, serverClient, + DixWriteAccess); + + if (rc == Success) { + if(pWin2->visibility != VisibilityFullyObscured) + return; + + if(!i) pWin = pWin2; + } + } + break; + } + + win->u.win.visibility = visibility; + } +#endif + + memset(&event, 0, sizeof(xEvent)); + event.u.u.type = VisibilityNotify; + event.u.visibility.window = pWin->drawable.id; + event.u.visibility.state = visibility; + DeliverEvents(pWin, &event, 1, NullWindow); +} + +#define RANDOM_WIDTH 32 +int +dixSaveScreens(ClientPtr client, int on, int mode) +{ + int rc, i, what, type; + + if (on == SCREEN_SAVER_FORCER) + { + if (mode == ScreenSaverReset) + what = SCREEN_SAVER_OFF; + else + what = SCREEN_SAVER_ON; + type = what; + } + else + { + what = on; + type = what; + if (what == screenIsSaved) + type = SCREEN_SAVER_CYCLE; + } + + for (i = 0; i < screenInfo.numScreens; i++) { + rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i], + DixShowAccess | DixHideAccess); + if (rc != Success) + return rc; + } + for (i = 0; i < screenInfo.numScreens; i++) + { + ScreenPtr pScreen = screenInfo.screens[i]; + if (on == SCREEN_SAVER_FORCER) + (* pScreen->SaveScreen) (pScreen, on); + if (pScreen->screensaver.ExternalScreenSaver) + { + if ((*pScreen->screensaver.ExternalScreenSaver) + (pScreen, type, on == SCREEN_SAVER_FORCER)) + continue; + } + if (type == screenIsSaved) + continue; + switch (type) { + case SCREEN_SAVER_OFF: + if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED) + { + (* pScreen->SaveScreen) (pScreen, what); + } + else if (HasSaverWindow (pScreen)) + { + pScreen->screensaver.pWindow = NullWindow; + FreeResource(pScreen->screensaver.wid, RT_NONE); + } + break; + case SCREEN_SAVER_CYCLE: + if (pScreen->screensaver.blanked == SCREEN_IS_TILED) + { + WindowPtr pWin = pScreen->screensaver.pWindow; + /* make it look like screen saver is off, so that + * NotClippedByChildren will compute a clip list + * for the root window, so miPaintWindow works + */ + screenIsSaved = SCREEN_SAVER_OFF; + (*pWin->drawable.pScreen->MoveWindow)(pWin, + (short)(-(rand() % RANDOM_WIDTH)), + (short)(-(rand() % RANDOM_WIDTH)), + pWin->nextSib, VTMove); + screenIsSaved = SCREEN_SAVER_ON; + } + /* + * Call the DDX saver in case it wants to do something + * at cycle time + */ + else if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED) + { + (* pScreen->SaveScreen) (pScreen, type); + } + break; + case SCREEN_SAVER_ON: + if (ScreenSaverBlanking != DontPreferBlanking) + { + if ((* pScreen->SaveScreen) (pScreen, what)) + { + pScreen->screensaver.blanked = SCREEN_IS_BLANKED; + continue; + } + if ((ScreenSaverAllowExposures != DontAllowExposures) && + TileScreenSaver(pScreen, SCREEN_IS_BLACK)) + { + pScreen->screensaver.blanked = SCREEN_IS_BLACK; + continue; + } + } + if ((ScreenSaverAllowExposures != DontAllowExposures) && + TileScreenSaver(pScreen, SCREEN_IS_TILED)) + { + pScreen->screensaver.blanked = SCREEN_IS_TILED; + } + else + pScreen->screensaver.blanked = SCREEN_ISNT_SAVED; + break; + } + } + screenIsSaved = what; + if (mode == ScreenSaverReset) { + if (on == SCREEN_SAVER_FORCER) { + UpdateCurrentTimeIf(); + lastDeviceEventTime = currentTime; + } + SetScreenSaverTimer(); + } + return Success; +} + +int +SaveScreens(int on, int mode) +{ + return dixSaveScreens(serverClient, on, mode); +} + +static Bool +TileScreenSaver(ScreenPtr pScreen, int kind) +{ + int j; + int result; + XID attributes[3]; + Mask mask; + WindowPtr pWin; + CursorMetricRec cm; + unsigned char *srcbits, *mskbits; + CursorPtr cursor; + XID cursorID = 0; + int attri; + + mask = 0; + attri = 0; + switch (kind) { + case SCREEN_IS_TILED: + switch (pScreen->root->backgroundState) { + case BackgroundPixel: + attributes[attri++] = pScreen->root->background.pixel; + mask |= CWBackPixel; + break; + case BackgroundPixmap: + attributes[attri++] = None; + mask |= CWBackPixmap; + break; + default: + break; + } + break; + case SCREEN_IS_BLACK: + attributes[attri++] = pScreen->root->drawable.pScreen->blackPixel; + mask |= CWBackPixel; + break; + } + mask |= CWOverrideRedirect; + attributes[attri++] = xTrue; + + /* + * create a blank cursor + */ + + cm.width=16; + cm.height=16; + cm.xhot=8; + cm.yhot=8; + srcbits = malloc( BitmapBytePad(32)*16); + mskbits = malloc( BitmapBytePad(32)*16); + if (!srcbits || !mskbits) + { + free(srcbits); + free(mskbits); + cursor = 0; + } + else + { + for (j=0; jscreensaver.pWindow = + CreateWindow(pScreen->screensaver.wid, + pScreen->root, + -RANDOM_WIDTH, -RANDOM_WIDTH, + (unsigned short)pScreen->width + RANDOM_WIDTH, + (unsigned short)pScreen->height + RANDOM_WIDTH, + 0, InputOutput, mask, attributes, 0, serverClient, + wVisual (pScreen->root), &result); + + if (cursor) + FreeResource (cursorID, RT_NONE); + + if (!pWin) + return FALSE; + + if (!AddResource(pWin->drawable.id, RT_WINDOW, + (pointer)pScreen->screensaver.pWindow)) + return FALSE; + + if (mask & CWBackPixmap) + { + MakeRootTile (pWin); + (*pWin->drawable.pScreen->ChangeWindowAttributes)(pWin, CWBackPixmap); + } + MapWindow(pWin, serverClient); + return TRUE; +} + +/* + * FindWindowWithOptional + * + * search ancestors of the given window for an entry containing + * a WindowOpt structure. Assumptions: some parent will + * contain the structure. + */ + +WindowPtr +FindWindowWithOptional (WindowPtr w) +{ + do + w = w->parent; + while (!w->optional); + return w; +} + +/* + * CheckWindowOptionalNeed + * + * check each optional entry in the given window to see if + * the value is satisfied by the default rules. If so, + * release the optional record + */ + +void +CheckWindowOptionalNeed (WindowPtr w) +{ + WindowOptPtr optional; + WindowOptPtr parentOptional; + + if (!w->parent || !w->optional) + return; + optional = w->optional; + if (optional->dontPropagateMask != DontPropagateMasks[w->dontPropagate]) + return; + if (optional->otherEventMasks != 0) + return; + if (optional->otherClients != NULL) + return; + if (optional->passiveGrabs != NULL) + return; + if (optional->userProps != NULL) + return; + if (optional->backingBitPlanes != ~0L) + return; + if (optional->backingPixel != 0) + return; + if (optional->boundingShape != NULL) + return; + if (optional->clipShape != NULL) + return; + if (optional->inputShape != NULL) + return; + if (optional->inputMasks != NULL) + return; + if (optional->deviceCursors != NULL) + { + DevCursNodePtr pNode = optional->deviceCursors; + while(pNode) + { + if (pNode->cursor != None) + return; + pNode = pNode->next; + } + } + + parentOptional = FindWindowWithOptional(w)->optional; + if (optional->visual != parentOptional->visual) + return; + if (optional->cursor != None && + (optional->cursor != parentOptional->cursor || + w->parent->cursorIsNone)) + return; + if (optional->colormap != parentOptional->colormap) + return; + DisposeWindowOptional (w); +} + +/* + * MakeWindowOptional + * + * create an optional record and initialize it with the default + * values. + */ + +Bool +MakeWindowOptional (WindowPtr pWin) +{ + WindowOptPtr optional; + WindowOptPtr parentOptional; + + if (pWin->optional) + return TRUE; + optional = malloc(sizeof (WindowOptRec)); + if (!optional) + return FALSE; + optional->dontPropagateMask = DontPropagateMasks[pWin->dontPropagate]; + optional->otherEventMasks = 0; + optional->otherClients = NULL; + optional->passiveGrabs = NULL; + optional->userProps = NULL; + optional->backingBitPlanes = ~0L; + optional->backingPixel = 0; + optional->boundingShape = NULL; + optional->clipShape = NULL; + optional->inputShape = NULL; + optional->inputMasks = NULL; + optional->deviceCursors = NULL; + + parentOptional = FindWindowWithOptional(pWin)->optional; + optional->visual = parentOptional->visual; + if (!pWin->cursorIsNone) + { + optional->cursor = parentOptional->cursor; + optional->cursor->refcnt++; + } + else + { + optional->cursor = None; + } + optional->colormap = parentOptional->colormap; + pWin->optional = optional; + return TRUE; +} + +/* + * Changes the cursor struct for the given device and the given window. + * A cursor that does not have a device cursor set will use whatever the + * standard cursor is for the window. If all devices have a cursor set, + * changing the window cursor (e.g. using XDefineCursor()) will not have any + * visible effect. Only when one of the device cursors is set to None again, + * this device's cursor will display the changed standard cursor. + * + * CursorIsNone of the window struct is NOT modified if you set a device + * cursor. + * + * Assumption: If there is a node for a device in the list, the device has a + * cursor. If the cursor is set to None, it is inherited by the parent. + */ +int +ChangeWindowDeviceCursor(WindowPtr pWin, + DeviceIntPtr pDev, + CursorPtr pCursor) +{ + DevCursNodePtr pNode, pPrev; + CursorPtr pOldCursor = NULL; + ScreenPtr pScreen; + WindowPtr pChild; + + if (!pWin->optional && !MakeWindowOptional(pWin)) + return BadAlloc; + + /* 1) Check if window has device cursor set + * Yes: 1.1) swap cursor with given cursor if parent does not have same + * cursor, free old cursor + * 1.2) free old cursor, use parent cursor + * No: 1.1) add node to beginning of list. + * 1.2) add cursor to node if parent does not have same cursor + * 1.3) use parent cursor if parent does not have same cursor + * 2) Patch up children if child has a devcursor + * 2.1) if child has cursor None, it inherited from parent, set to old + * cursor + * 2.2) if child has same cursor as new cursor, remove and set to None + */ + + pScreen = pWin->drawable.pScreen; + + if (WindowSeekDeviceCursor(pWin, pDev, &pNode, &pPrev)) + { + /* has device cursor */ + + if (pNode->cursor == pCursor) + return Success; + + pOldCursor = pNode->cursor; + + if (!pCursor) /* remove from list */ + { + if(pPrev) + pPrev->next = pNode->next; + else + /* first item in list */ + pWin->optional->deviceCursors = pNode->next; + + free(pNode); + goto out; + } + + } else + { + /* no device cursor yet */ + DevCursNodePtr pNewNode; + + if (!pCursor) + return Success; + + pNewNode = malloc(sizeof(DevCursNodeRec)); + pNewNode->dev = pDev; + pNewNode->next = pWin->optional->deviceCursors; + pWin->optional->deviceCursors = pNewNode; + pNode = pNewNode; + + } + + if (pCursor && WindowParentHasDeviceCursor(pWin, pDev, pCursor)) + pNode->cursor = None; + else + { + pNode->cursor = pCursor; + pCursor->refcnt++; + } + + pNode = pPrev = NULL; + /* fix up children */ + for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) + { + if (WindowSeekDeviceCursor(pChild, pDev, &pNode, &pPrev)) + { + if (pNode->cursor == None) /* inherited from parent */ + { + pNode->cursor = pOldCursor; + pOldCursor->refcnt++; + } else if (pNode->cursor == pCursor) + { + pNode->cursor = None; + FreeCursor(pCursor, (Cursor)0); /* fix up refcnt */ + } + } + } + +out: + if (pWin->realized) + WindowHasNewCursor(pWin); + + if (pOldCursor) + FreeCursor(pOldCursor, (Cursor)0); + + /* FIXME: We SHOULD check for an error value here XXX + (comment taken from ChangeWindowAttributes) */ + (*pScreen->ChangeWindowAttributes)(pWin, CWCursor); + + return Success; +} + +/* Get device cursor for given device or None if none is set */ +CursorPtr +WindowGetDeviceCursor(WindowPtr pWin, DeviceIntPtr pDev) +{ + DevCursorList pList; + + if (!pWin->optional || !pWin->optional->deviceCursors) + return NULL; + + pList = pWin->optional->deviceCursors; + + while(pList) + { + if (pList->dev == pDev) + { + if (pList->cursor == None) /* inherited from parent */ + return WindowGetDeviceCursor(pWin->parent, pDev); + else + return pList->cursor; + } + pList = pList->next; + } + return NULL; +} + +/* Searches for a DevCursorNode for the given window and device. If one is + * found, return True and set pNode and pPrev to the node and to the node + * before the node respectively. Otherwise return False. + * If the device is the first in list, pPrev is set to NULL. + */ +static Bool +WindowSeekDeviceCursor(WindowPtr pWin, + DeviceIntPtr pDev, + DevCursNodePtr* pNode, + DevCursNodePtr* pPrev) +{ + DevCursorList pList; + + if (!pWin->optional) + return FALSE; + + pList = pWin->optional->deviceCursors; + + if (pList && pList->dev == pDev) + { + *pNode = pList; + *pPrev = NULL; + return TRUE; + } + + while(pList) + { + if (pList->next) + { + if (pList->next->dev == pDev) + { + *pNode = pList->next; + *pPrev = pList; + return TRUE; + } + } + pList = pList->next; + } + return FALSE; +} + +/* Return True if a parent has the same device cursor set or False if + * otherwise + */ +static Bool +WindowParentHasDeviceCursor(WindowPtr pWin, + DeviceIntPtr pDev, + CursorPtr pCursor) +{ + WindowPtr pParent; + DevCursNodePtr pParentNode, pParentPrev; + + pParent = pWin->parent; + while(pParent) + { + if (WindowSeekDeviceCursor(pParent, pDev, + &pParentNode, &pParentPrev)) + { + /* if there is a node in the list, the win has a dev cursor */ + if (!pParentNode->cursor) /* inherited. */ + pParent = pParent->parent; + else if (pParentNode->cursor == pCursor) /* inherit */ + return TRUE; + else /* different cursor */ + return FALSE; + } + else + /* parent does not have a device cursor for our device */ + return FALSE; + } + return FALSE; +} diff --git a/xorg-server/hw/dmx/dmxcb.c b/xorg-server/hw/dmx/dmxcb.c index 4e7279a51..d0eb35117 100644 --- a/xorg-server/hw/dmx/dmxcb.c +++ b/xorg-server/hw/dmx/dmxcb.c @@ -46,6 +46,7 @@ extern int connBlockScreenStart; #ifdef PANORAMIX +#include "panoramiXsrv.h" extern int PanoramiXPixWidth; extern int PanoramiXPixHeight; extern int PanoramiXNumScreens; @@ -137,7 +138,7 @@ void dmxConnectionBlockCallback(void) } dmxLog(dmxInfo, "%d screens configured with Xinerama (%d %d)\n", PanoramiXNumScreens, PanoramiXPixWidth, PanoramiXPixHeight); - for (i = 0; i < PanoramiXNumScreens; i++) found[i] = FALSE; + FOR_NSCREENS(i) found[i] = FALSE; } else { #endif /* This never happens because we're @@ -177,7 +178,7 @@ void dmxConnectionBlockCallback(void) #ifdef PANORAMIX if (!noPanoramiXExtension) { int k; - for (k = 0; k < PanoramiXNumScreens; k++) { + FOR_NSCREENS(k) { DMXScreenInfo *dmxScreen = &dmxScreens[k]; if (dmxScreen->beDisplay) { @@ -203,7 +204,7 @@ void dmxConnectionBlockCallback(void) #ifdef PANORAMIX if (!noPanoramiXExtension) { Bool fatal = FALSE; - for (i = 0; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS(i) { fatal |= !found[i]; if (!found[i]) { dmxLog(dmxError, diff --git a/xorg-server/hw/dmx/dmxextension.c b/xorg-server/hw/dmx/dmxextension.c index bd326ce2a..db5709ee6 100644 --- a/xorg-server/hw/dmx/dmxextension.c +++ b/xorg-server/hw/dmx/dmxextension.c @@ -703,7 +703,7 @@ static void dmxBERestorePixmapImage(pointer value, XID id, RESTYPE type, RT_PIXMAP, NullClient, DixUnknownAccess); if (pPix != pDst) return; /* Not a match.... Next! */ - for (i = 0; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS(i) { PixmapPtr pSrc; dmxPixPrivPtr pSrcPriv = NULL; @@ -1372,7 +1372,7 @@ static void dmxBEFindPixmapImage(pointer value, XID id, RESTYPE type, RT_PIXMAP, NullClient, DixUnknownAccess); if (pPix != pDst) return; /* Not a match.... Next! */ - for (i = 0; i < PanoramiXNumScreens; i++) { + FOR_NSCREENS(i) { PixmapPtr pSrc; dmxPixPrivPtr pSrcPriv = NULL; diff --git a/xorg-server/hw/dmx/dmxgcops.c b/xorg-server/hw/dmx/dmxgcops.c index 8f4f5c774..500e2cdf1 100644 --- a/xorg-server/hw/dmx/dmxgcops.c +++ b/xorg-server/hw/dmx/dmxgcops.c @@ -1,605 +1,605 @@ -/* - * 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 - * - */ - -/** \file - * This file provides support for GC operations. */ - -#ifdef HAVE_DMX_CONFIG_H -#include -#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 (Success != dixLookupResourceByType((pointer*) &pXinPix, - pDrawable->id, XRT_PIXMAP, - NullClient, DixUnknownAccess)) - return NULL; - - for (i = 1; i < PanoramiXNumScreens; i++) { - dmxScreen = &dmxScreens[i]; - if (dmxScreen->beDisplay) { - PixmapPtr pSrc; - dmxPixPrivPtr pSrcPriv; - - dixLookupResourceByType((pointer*) &pSrc, pXinPix->info[i].id, - RT_PIXMAP, NullClient, DixUnknownAccess); - 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 + * + */ + +/** \file + * This file provides support for GC operations. */ + +#ifdef HAVE_DMX_CONFIG_H +#include +#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 (Success != dixLookupResourceByType((pointer*) &pXinPix, + pDrawable->id, XRT_PIXMAP, + NullClient, DixUnknownAccess)) + return NULL; + + FOR_NSCREENS_FORWARD_SKIP(i) { + dmxScreen = &dmxScreens[i]; + if (dmxScreen->beDisplay) { + PixmapPtr pSrc; + dmxPixPrivPtr pSrcPriv; + + dixLookupResourceByType((pointer*) &pSrc, pXinPix->info[i].id, + RT_PIXMAP, NullClient, DixUnknownAccess); + 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/render/render.c b/xorg-server/render/render.c index fbb296809..8ff8ee6f6 100644 --- a/xorg-server/render/render.c +++ b/xorg-server/render/render.c @@ -2690,7 +2690,7 @@ PanoramiXRenderCreatePicture (ClientPtr client) if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) return BadAlloc; newPict->type = XRT_PICTURE; - newPict->info[0].id = stuff->pid; + panoramix_setup_ids(newPict, client, stuff->pid); if (refDraw->type == XRT_WINDOW && stuff->drawable == screenInfo.screens[0]->root->drawable.id) @@ -2699,9 +2699,6 @@ PanoramiXRenderCreatePicture (ClientPtr client) } else newPict->u.pict.root = FALSE; - - for(j = 1; j < PanoramiXNumScreens; j++) - newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; @@ -3225,11 +3222,8 @@ PanoramiXRenderCreateSolidFill (ClientPtr client) return BadAlloc; newPict->type = XRT_PICTURE; - newPict->info[0].id = stuff->pid; + panoramix_setup_ids(newPict, client, stuff->pid); newPict->u.pict.root = FALSE; - - for(j = 1; j < PanoramiXNumScreens; j++) - newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; @@ -3258,12 +3252,9 @@ PanoramiXRenderCreateLinearGradient (ClientPtr client) return BadAlloc; newPict->type = XRT_PICTURE; - newPict->info[0].id = stuff->pid; + panoramix_setup_ids(newPict, client, stuff->pid); newPict->u.pict.root = FALSE; - for(j = 1; j < PanoramiXNumScreens; j++) - newPict->info[j].id = FakeClientID(client->index); - FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreateLinearGradient]) (client); @@ -3291,12 +3282,9 @@ PanoramiXRenderCreateRadialGradient (ClientPtr client) return BadAlloc; newPict->type = XRT_PICTURE; - newPict->info[0].id = stuff->pid; + panoramix_setup_ids(newPict, client, stuff->pid); newPict->u.pict.root = FALSE; - for(j = 1; j < PanoramiXNumScreens; j++) - newPict->info[j].id = FakeClientID(client->index); - FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreateRadialGradient]) (client); @@ -3324,12 +3312,9 @@ PanoramiXRenderCreateConicalGradient (ClientPtr client) return BadAlloc; newPict->type = XRT_PICTURE; - newPict->info[0].id = stuff->pid; + panoramix_setup_ids(newPict, client, stuff->pid); newPict->u.pict.root = FALSE; - for(j = 1; j < PanoramiXNumScreens; j++) - newPict->info[j].id = FakeClientID(client->index); - FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreateConicalGradient]) (client); diff --git a/xorg-server/xkeyboard-config/rules/base.extras.xml.in b/xorg-server/xkeyboard-config/rules/base.extras.xml.in index b068589fd..1118bec4d 100644 --- a/xorg-server/xkeyboard-config/rules/base.extras.xml.in +++ b/xorg-server/xkeyboard-config/rules/base.extras.xml.in @@ -23,12 +23,28 @@ ave - <_description>Iran Avestan + <_description>Iran - Avestan ave + + + lt + <_shortDescription>Ltu + <_description>Lithuania + lit + + + + + dvorak + <_description>Lithuania - Dvorak + + + + us @@ -40,26 +56,26 @@ intl-unicode - <_description>USA International (AltGr Unicode combining) + <_description>USA - International (AltGr Unicode combining) alt-intl-unicode - <_description>USA International (AltGr Unicode combining, alternative) + <_description>USA - International (AltGr Unicode combining, alternative) ats - <_description>USA Atsina + <_description>USA - Atsina crd - <_description>USA Couer D'alene Salish + <_description>USA - Couer D'alene Salish crd @@ -76,7 +92,7 @@ ergonomic - <_description>Ergonomic Touchtype + <_description>Romania - Ergonomic Touchtype @@ -84,7 +100,7 @@ rs - <_shortDescription>SRB + <_shortDescription>Srb <_description>Serbia srp @@ -92,7 +108,7 @@ combiningkeys - <_description>Serbia Combining accents instead of dead keys + <_description>Serbia - Combining accents instead of dead keys @@ -107,7 +123,7 @@ chu - Russia Church Slavonic + Russia - Church Slavonic chu diff --git a/xorg-server/xkeyboard-config/rules/base.xml.in b/xorg-server/xkeyboard-config/rules/base.xml.in index 1a3d528d1..2d3df0126 100644 --- a/xorg-server/xkeyboard-config/rules/base.xml.in +++ b/xorg-server/xkeyboard-config/rules/base.xml.in @@ -1,6209 +1,6209 @@ - - - - - - - pc101 - <_description>Generic 101-key PC - Generic - - - - - pc102 - <_description>Generic 102-key (Intl) PC - Generic - - - - - pc104 - <_description>Generic 104-key PC - Generic - - - - - pc105 - <_description>Generic 105-key (Intl) PC - Generic - - - - - dell101 - <_description>Dell 101-key PC - Dell - - - - - latitude - <_description>Dell Latitude series laptop - Dell - - - - - dellm65 - <_description>Dell Precision M65 - Dell - - - - - everex - <_description>Everex STEPnote - Everex - - - - - flexpro - <_description>Keytronic FlexPro - Keytronic - - - - - microsoft - <_description>Microsoft Natural - Microsoft Inc. - - - - - omnikey101 - <_description>Northgate OmniKey 101 - Northgate - - - - - winbook - <_description>Winbook Model XP5 - Generic - - - - - pc98 - <_description>PC-98xx Series - Generic - - - - - a4techKB21 - <_description>A4Tech KB-21 - A4Tech - - - - - a4techKBS8 - <_description>A4Tech KBS-8 - A4Tech - - - - - a4_rfkb23 - <_description>A4Tech Wireless Desktop RFKB-23 - A4Tech - - - - - airkey - <_description>Acer AirKey V - Acer - - - - - azonaRF2300 - <_description>Azona RF2300 wireless Internet Keyboard - Azona - - - - - scorpius - <_description>Advance Scorpius KI - Scorpius - - - - - brother - <_description>Brother Internet Keyboard - Brother - - - - - btc5113rf - <_description>BTC 5113RF Multimedia - BTC - - - - - btc5126t - <_description>BTC 5126T - BTC - - - - - btc6301urf - <_description>BTC 6301URF - BTC - - - - - btc9000 - <_description>BTC 9000 - BTC - - - - - btc9000a - <_description>BTC 9000A - BTC - - - - - btc9001ah - <_description>BTC 9001AH - BTC - - - - - btc5090 - <_description>BTC 5090 - BTC - - - - - btc9019u - <_description>BTC 9019U - BTC - - - - - btc9116u - <_description>BTC 9116U Mini Wireless Internet and Gaming - - - - - cherryblue - <_description>Cherry Blue Line CyBo@rd - - - - - cherryblueb - <_description>Cherry CyMotion Master XPress - Cherry - - - - - cherrybluea - <_description>Cherry Blue Line CyBo@rd (alternate option) - Cherry - - - - - cherrycyboard - <_description>Cherry CyBo@rd USB-Hub - Cherry - - - - - cherrycmexpert - <_description>Cherry CyMotion Expert - Cherry - - - - - cherrybunlim - <_description>Cherry B.UNLIMITED - Cherry - - - - - chicony - <_description>Chicony Internet Keyboard - Chicony - - - - - chicony0108 - <_description>Chicony KU-0108 - Chicony - - - - - chicony0420 - <_description>Chicony KU-0420 - Chicony - - - - - chicony9885 - <_description>Chicony KB-9885 - Chicony - - - - - compaqeak8 - <_description>Compaq Easy Access Keyboard - Compaq - - - - - compaqik7 - <_description>Compaq Internet Keyboard (7 keys) - Compaq - - - - - compaqik13 - <_description>Compaq Internet Keyboard (13 keys) - Compaq - - - - - compaqik18 - <_description>Compaq Internet Keyboard (18 keys) - Compaq - - - - - cymotionlinux - <_description>Cherry CyMotion Master Linux - Cherry - - - - - armada - <_description>Laptop/notebook Compaq (eg. Armada) Laptop Keyboard - Compaq - - - - - presario - <_description>Laptop/notebook Compaq (eg. Presario) Internet Keyboard - Compaq - - - - - ipaq - <_description>Compaq iPaq Keyboard - Compaq - - - - - dell - <_description>Dell - Dell - - - - - dellsk8125 - <_description>Dell SK-8125 - Dell - - - - - dellsk8135 - <_description>Dell SK-8135 - Dell - - - - - dellusbmm - <_description>Dell USB Multimedia Keyboard - Dell - - - - - inspiron - <_description>Dell Laptop/notebook Inspiron 6xxx/8xxx - Dell - - - - - precision_m - <_description>Dell Laptop/notebook Precision M series - Dell - - - - - dexxa - <_description>Dexxa Wireless Desktop Keyboard - Dexxa - - - - - diamond - <_description>Diamond 9801 / 9802 series - Diamond - - - - - dtk2000 - <_description>DTK2000 - - - - - ennyah_dkb1008 - <_description>Ennyah DKB-1008 - Ennyah - - - - - fscaa1667g - <_description>Fujitsu-Siemens Computers AMILO laptop - Fujitsu-Siemens - - - - - genius - <_description>Genius Comfy KB-16M / Genius MM Keyboard KWD-910 - Genius - - - - - geniuscomfy - <_description>Genius Comfy KB-12e - Genius - - - - - geniuscomfy2 - <_description>Genius Comfy KB-21e-Scroll - Genius - - - - - geniuskb19e - <_description>Genius KB-19e NB - Genius - - - - - geniuskkb2050hs - <_description>Genius KKB-2050HS - Genius - - - - - gyration - <_description>Gyration - Gyration - - - - - htcdream - <_description>HTC Dream - HTC - - - - - kinesis - <_description>Kinesis - Kinesis - - - - - logitech_base - <_description>Logitech Generic Keyboard - Logitech - - - - - logitech_g15 - <_description>Logitech G15 extra keys via G15daemon - Logitech - - - - - hpi6 - <_description>Hewlett-Packard Internet Keyboard - Hewlett-Packard - - - - - hp250x - <_description>Hewlett-Packard SK-250x Multimedia Keyboard - Hewlett-Packard - - - - - hpxe3gc - <_description>Hewlett-Packard Omnibook XE3 GC - Hewlett-Packard - - - - - hpxe3gf - <_description>Hewlett-Packard Omnibook XE3 GF - Hewlett-Packard - - - - - hpxt1000 - <_description>Hewlett-Packard Omnibook XT1000 - Hewlett-Packard - - - - - hpdv5 - <_description>Hewlett-Packard Pavilion dv5 - Hewlett-Packard - - - - - hpzt11xx - <_description>Hewlett-Packard Pavilion ZT11xx - Hewlett-Packard - - - - - hp500fa - <_description>Hewlett-Packard Omnibook 500 FA - Hewlett-Packard - - - - - hp5xx - <_description>Hewlett-Packard Omnibook 5xx - Hewlett-Packard - - - - - hpnx9020 - <_description>Hewlett-Packard nx9020 - Hewlett-Packard - - - - - hp6000 - <_description>Hewlett-Packard Omnibook 6000/6100 - Hewlett-Packard - - - - - honeywell_euroboard - <_description>Honeywell Euroboard - Hewlett-Packard - - - - - hpmini110 - <_description>Hewlett-Packard Mini 110 Notebook - Hewlett-Packard - - - - - rapidaccess - <_description>IBM Rapid Access - Lenovo (previously IBM) - - - - - rapidaccess2 - <_description>IBM Rapid Access II - Lenovo (previously IBM) - - - - - thinkpad - <_description>IBM ThinkPad 560Z/600/600E/A22E - Lenovo (previously IBM) - - - - - thinkpad60 - <_description>IBM ThinkPad R60/T60/R61/T61 - Lenovo (previously IBM) - - - - - thinkpadz60 - <_description>IBM ThinkPad Z60m/Z60t/Z61m/Z61t - Lenovo (previously IBM) - - - - - ibm_spacesaver - <_description>IBM Space Saver - Lenovo (previously IBM) - - - - - logiaccess - <_description>Logitech Access Keyboard - Logitech - - - - - logiclx300 - <_description>Logitech Cordless Desktop LX-300 - Logitech - - - - - logii350 - <_description>Logitech Internet 350 Keyboard - Logitech - - - - - logimel - <_description>Logitech Media Elite Keyboard - Logitech - - - - - logicd - <_description>Logitech Cordless Desktop - Logitech - - - - - logicd_it - <_description>Logitech Cordless Desktop iTouch - Logitech - - - - - logicd_nav - <_description>Logitech Cordless Desktop Navigator - Logitech - - - - - logicd_opt - <_description>Logitech Cordless Desktop Optical - Logitech - - - - - logicda - <_description>Logitech Cordless Desktop (alternate option) - Logitech - - - - - logicdpa2 - <_description>Logitech Cordless Desktop Pro (alternate option 2) - Logitech - - - - - logicfn - <_description>Logitech Cordless Freedom/Desktop Navigator - Logitech - - - - - logicdn - <_description>Logitech Cordless Desktop Navigator - Logitech - - - - - logiitc - <_description>Logitech iTouch Cordless Keyboard (model Y-RB6) - Logitech - - - - - logiik - <_description>Logitech Internet Keyboard - Logitech - - - - - itouch - <_description>Logitech iTouch - Logitech - - - - - logicink - <_description>Logitech Internet Navigator Keyboard - Logitech - - - - - logiex110 - <_description>Logitech Cordless Desktop EX110 - Logitech - - - - - logiinkse - <_description>Logitech iTouch Internet Navigator Keyboard SE - Logitech - - - - - logiinkseusb - <_description>Logitech iTouch Internet Navigator Keyboard SE (USB) - Logitech - - - - - logiultrax - <_description>Logitech Ultra-X Keyboard - Logitech - - - - - logiultraxc - <_description>Logitech Ultra-X Cordless Media Desktop Keyboard - Logitech - - - - - logidinovo - <_description>Logitech diNovo Keyboard - Logitech - - - - - logidinovoedge - <_description>Logitech diNovo Edge Keyboard - Logitech - - - - - mx1998 - <_description>Memorex MX1998 - Memorex - - - - - mx2500 - <_description>Memorex MX2500 EZ-Access Keyboard - Memorex - - - - - mx2750 - <_description>Memorex MX2750 - Memorex - - - - - microsoft4000 - <_description>Microsoft Natural Wireless Ergonomic Keyboard 4000 - Microsoft Inc. - - - - - microsoft7000 - <_description>Microsoft Natural Wireless Ergonomic Keyboard 7000 - Microsoft Inc. - - - - - microsoftinet - <_description>Microsoft Internet Keyboard - Microsoft Inc. - - - - - microsoftpro - <_description>Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro - Microsoft Inc. - - - - - microsoftprousb - <_description>Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro - Microsoft Inc. - - - - - microsoftprooem - <_description>Microsoft Natural Keyboard Pro OEM - Microsoft Inc. - - - - - vsonku306 - <_description>ViewSonic KU-306 Internet Keyboard - ViewSonic - - - - - microsoftprose - <_description>Microsoft Internet Keyboard Pro, Swedish - Microsoft Inc. - - - - - microsoftoffice - <_description>Microsoft Office Keyboard - Microsoft Inc. - - - - - microsoftmult - <_description>Microsoft Wireless Multimedia Keyboard 1.0A - Microsoft Inc. - - - - - microsoftelite - <_description>Microsoft Natural Keyboard Elite - Microsoft Inc. - - - - - microsoftccurve2k - <_description>Microsoft Comfort Curve Keyboard 2000 - Microsoft Inc. - - - - - oretec - <_description>Ortek MCK-800 MM/Internet keyboard - Ortek - - - - - propeller - <_description>Propeller Voyager (KTEZ-1000) - KeyTronic - - - - - qtronix - <_description>QTronix Scorpius 98N+ - QTronix - - - - - samsung4500 - <_description>Samsung SDM 4500P - Samsung - - - - - samsung4510 - <_description>Samsung SDM 4510P - Samsung - - - - - sanwaskbkg3 - <_description>Sanwa Supply SKB-KG3 - Sanwa Supply Inc. - - - - - sk1300 - <_description>SK-1300 - NEC - - - - - sk2500 - <_description>SK-2500 - NEC - - - - - sk6200 - <_description>SK-6200 - NEC - - - - - sk7100 - <_description>SK-7100 - NEC - - - - - sp_inet - <_description>Super Power Multimedia Keyboard - Generic - - - - - sven - <_description>SVEN Ergonomic 2500 - SVEN - - - - - sven303 - <_description>SVEN Slim 303 - SVEN - - - - - symplon - <_description>Symplon PaceBook (tablet PC) - Symplon - - - - - toshiba_s3000 - <_description>Toshiba Satellite S3000 - Toshiba - - - - - trust - <_description>Trust Wireless Keyboard Classic - Trust - - - - - trustda - <_description>Trust Direct Access Keyboard - Trust - - - - - trust_slimline - <_description>Trust Slimline - Trust - - - - - tm2020 - <_description>TypeMatrix EZ-Reach 2020 - TypeMatrix - - - - - tm2030PS2 - <_description>TypeMatrix EZ-Reach 2030 PS2 - TypeMatrix - - - - - tm2030USB - <_description>TypeMatrix EZ-Reach 2030 USB - TypeMatrix - - - - - tm2030USB-102 - <_description>TypeMatrix EZ-Reach 2030 USB (102/105:EU mode) - TypeMatrix - - - - - tm2030USB-106 - <_description>TypeMatrix EZ-Reach 2030 USB (106:JP mode) - TypeMatrix - - - - - yahoo - <_description>Yahoo! Internet Keyboard - Yahoo! - - - - - macbook78 - <_description>MacBook/MacBook Pro - Apple - - - - - macbook79 - <_description>MacBook/MacBook Pro (Intl) - Apple - - - - - macintosh - <_description>Macintosh - Apple - - - - - macintosh_old - <_description>Macintosh Old - Apple - - - - - macintosh_hhk - <_description>Happy Hacking Keyboard for Mac - Fujitsu - - - - - acer_c300 - <_description>Acer C300 - Acer - - - - - acer_ferrari4k - <_description>Acer Ferrari 4000 - Acer - - - - - acer_laptop - <_description>Acer Laptop - Acer - - - - - asus_laptop - <_description>Asus Laptop - Asus - - - - - apple - <_description>Apple - Apple - - - - - apple_laptop - <_description>Apple Laptop - Apple - - - - - applealu_ansi - <_description>Apple Aluminium Keyboard (ANSI) - Apple - - - - - applealu_iso - <_description>Apple Aluminium Keyboard (ISO) - Apple - - - - - applealu_jis - <_description>Apple Aluminium Keyboard (JIS) - Apple - - - - - silvercrest - <_description>SILVERCREST Multimedia Wireless Keyboard - Silvercrest - - - - - emachines - <_description>Laptop/notebook eMachines m68xx - eMachines - - - - - benqx - <_description>BenQ X-Touch - BenQ - - - - - benqx730 - <_description>BenQ X-Touch 730 - BenQ - - - - - benqx800 - <_description>BenQ X-Touch 800 - BenQ - - - - - hhk - <_description>Happy Hacking Keyboard - Fujitsu - - - - - classmate - <_description>Classmate PC - Intel - - - - - olpc - <_description>OLPC - OLPC - - - - - sun6 - <_description>Sun Type 5/6 - Sun Microsystems - - - - - targa_v811 - <_description>Targa Visionary 811 - Targa - - - - - unitekkb1925 - <_description>Unitek KB-1925 - Unitek Group - - - - - compalfl90 - <_description>FL90 - Compal Electronics Inc. - - - - - creativedw7000 - <_description>Creative Desktop Wireless 7000 - Creative - - - - - htcdream - <_description>Htc Dream phone - htc - - - - - - - us - <_shortDescription>USA - <_description>USA - - eng - - - - - - chr - <_description>USA - Cherokee - - chr - - - - - - euro - <_description>USA - With EuroSign on 5 - - - - - intl - <_description>USA - International (with dead keys) - - - - - alt-intl - <_description>USA - Alternative international - - - - - colemak - <_description>USA - Colemak - - - - - dvorak - <_description>USA - Dvorak - - - - - dvorak-intl - <_description>USA - Dvorak international (with dead keys) - - - - - dvorak-alt-intl - <_description>USA - Dvorak alternative international (no dead keys) - - - - - dvorak-l - <_description>USA - Left handed Dvorak - - - - - dvorak-r - <_description>USA - Right handed Dvorak - - - - - dvorak-classic - <_description>USA - Classic Dvorak - - - - - dvp - <_description>USA - Programmer Dvorak - - - - - rus - <_description>USA - Russian phonetic - - rus - - - - - - mac - <_description>USA - Macintosh - - - - - altgr-intl - <_description>USA - International (AltGr dead keys) - eng - fra - ger - - - - - olpc2 - <_description>USA - Layout toggle on multiply/divide key - - - - - hbs - <_description>USA - Serbo-Croatian - eng - bos - hbs - hrv - srp - - - - - - - ad - <_shortDescription>And - <_description>Andorra - - cat - - - - - - - af - <_shortDescription>Afg - <_description>Afghanistan - - - - - ps - <_description>Afghanistan - Pashto - - pus - - - - - - uz - <_description>Afghanistan - Southern Uzbek - - uzb - - - - - - olpc-ps - <_description>Afghanistan - OLPC Pashto - - pus - - - - - - fa-olpc - <_description>Afghanistan - OLPC Dari - - - - - uz-olpc - <_description>Afghanistan - OLPC Southern Uzbek - - uzb - - - - - - - - ara - <_shortDescription>Ara - <_description>Arabic - - AE - BH - DZ - EG - EH - JO - KW - LB - LY - MA - MR - OM - PS - QA - SA - SD - SY - TN - YE - - - ara - - - - - - azerty - <_description>Arabic - azerty - - - - - azerty_digits - <_description>Arabic - azerty/digits - - - - - digits - <_description>Arabic - digits - - - - - qwerty - <_description>Arabic - qwerty - - - - - qwerty_digits - <_description>Arabic - qwerty/digits - - - - - buckwalter - <_description>Arabic - Buckwalter - - - - - - - al - <_shortDescription>Alb - <_description>Albania - - alb - - - - - - - am - <_shortDescription>Arm - <_description>Armenia - - hye - - - - - - phonetic - <_description>Armenia - Phonetic - - - - - phonetic-alt - <_description>Armenia - Alternative Phonetic - - - - - eastern - <_description>Armenia - Eastern - - - - - western - <_description>Armenia - Western - - - - - eastern-alt - <_description>Armenia - Alternative Eastern - - - - - - - at - <_shortDescription>Aut - <_description>Austria - - ger - - - - - - nodeadkeys - <_description>Austria - Eliminate dead keys - - - - - sundeadkeys - <_description>Austria - Sun dead keys - - - - - mac - <_description>Austria - Macintosh - - - - - - - az - <_shortDescription>Aze - <_description>Azerbaijan - - aze - - - - - - cyrillic - <_description>Azerbaijan - Cyrillic - - - - - - - by - <_shortDescription>Blr - <_description>Belarus - - bel - - - - - - legacy - <_description>Belarus - Legacy - - - - - latin - <_description>Belarus - Latin - - - - - - - be - <_shortDescription>Bel - <_description>Belgium - ger - nld - fra - - - - - oss - <_description>Belgium - Alternative - - - - - oss_latin9 - <_description>Belgium - Alternative, latin-9 only - - - - - oss_sundeadkeys - <_description>Belgium - Alternative, Sun dead keys - - - - - iso-alternate - <_description>Belgium - ISO Alternate - - - - - nodeadkeys - <_description>Belgium - Eliminate dead keys - - - - - sundeadkeys - <_description>Belgium - Sun dead keys - - - - - wang - <_description>Belgium - Wang model 724 azerty - - - - - - - bd - <_shortDescription>Bgd - <_description>Bangladesh - - ben - - - - - - probhat - <_description>Bangladesh - Probhat - - - - - - - in - <_shortDescription>Ind - <_description>India - - - - - ben - <_description>India - Bengali - - ben - - - - - - ben_probhat - <_description>India - Bengali Probhat - - ben - - - - - - guj - <_description>India - Gujarati - - guj - - - - - - guru - <_description>India - Gurmukhi - - pan - - - - - - jhelum - <_description>India - Gurmukhi Jhelum - - pan - - - - - - kan - <_description>India - Kannada - - kan - - - - - - mal - <_description>India - Malayalam - - mal - - - - - - mal_lalitha - <_description>India - Malayalam Lalitha - - mal - - - - - - mal_enhanced - <_description>India - Malayalam enhanced INSCRIPT with Rupee Sign - mal - - - - - ori - <_description>India - Oriya - - ori - - - - - - tam_unicode - <_description>India - Tamil Unicode - - tam - - - - - - tam_keyboard_with_numerals - <_description>India - Tamil Keyboard with Numerals - - tam - - - - - - tam_TAB - <_description>India - Tamil TAB Typewriter - - tam - - - - - - tam_TSCII - <_description>India - Tamil TSCII Typewriter - - tam - - - - - - tam - <_description>India - Tamil - - tam - - - - - - tel - <_description>India - Telugu - - tel - - - - - - urd-phonetic - <_description>India - Urdu, Phonetic - - urd - - - - - - urd-phonetic3 - <_description>India - Urdu, Alternative phonetic - - urd - - - - - - urd-winkeys - <_description>India - Urdu, Winkeys - - urd - - - - - - bolnagri - <_description>India - Hindi Bolnagri - - hin - - - - - - hin-wx - <_description>India - Hindi Wx - - hin - - - - - - eng - <_description>India - English with RupeeSign - - eng - - - - - - - - ba - <_shortDescription>Bih - <_description>Bosnia and Herzegovina - - bos - - - - - - alternatequotes - <_description>Bosnia and Herzegovina - Use guillemets for quotes - - - - - unicode - <_description>Bosnia and Herzegovina - Use Bosnian digraphs - - - - - unicodeus - <_description>Bosnia and Herzegovina - US keyboard with Bosnian digraphs - - - - - us - <_description>Bosnia and Herzegovina - US keyboard with Bosnian letters - - - - - - - br - <_shortDescription>Bra - <_description>Brazil - - por - - - - - - nodeadkeys - <_description>Brazil - Eliminate dead keys - - - - - dvorak - <_description>Brazil - Dvorak - - - - - nativo - <_description>Brazil - Nativo - - - - - nativo-us - <_description>Brazil - Nativo for USA keyboards - - - - - nativo-epo - <_description>Brazil - Nativo for Esperanto - - epo - - - - - - - - bg - <_shortDescription>Bgr - <_description>Bulgaria - - bul - - - - - - phonetic - <_description>Bulgaria - Traditional phonetic - - - - - bas_phonetic - <_description>Bulgaria - New phonetic - - - - - - - ma - <_description>Morocco - - - - - french - <_description>Morocco - French - - fra - - - - - - tifinagh - <_description>Morocco - Tifinagh - - ber - - - - - - tifinagh-alt - <_description>Morocco - Tifinagh alternative - - ber - - - - - - tifinagh-alt-phonetic - <_description>Morocco - Tifinagh alternative phonetic - - ber - - - - - - tifinagh-extended - <_description>Morocco - Tifinagh extended - - ber - - - - - - tifinagh-phonetic - <_description>Morocco - Tifinagh phonetic - - ber - - - - - - tifinagh-extended-phonetic - <_description>Morocco - Tifinagh extended phonetic - - ber - - - - - - - - mm - <_shortDescription>Mmr - <_description>Myanmar - - mya - - - - - - - ca - <_shortDescription>Can - <_description>Canada - - fra - - - - - - fr-dvorak - <_description>Canada - French Dvorak - - - - - fr-legacy - <_description>Canada - French (legacy) - - - - - multix - <_description>Canada - Multilingual - - - - - multi - <_description>Canada - Multilingual, first part - - - - - multi-2gr - <_description>Canada - Multilingual, second part - - - - - ike - <_description>Canada - Inuktitut - - iku - - - - - - shs - <_description>Canada - Secwepemctsin - - - - - kut - <_description>Canada - Ktunaxa - - - - - eng - <_description>Canada - English - - eng - - - - - - - - cd - <_shortDescription>COD - <_description>Congo, Democratic Republic of the - - fra - - - - - - - cn - <_shortDescription>Chn - <_description>China - - chi - - - - - - tib - <_description>China - Tibetan - - tib - - - - - - tib_asciinum - <_description>China - Tibetan (with ASCII numerals) - - tib - - - - - - uig - <_description>China - Uyghur - - uig - - - - - - - - hr - <_shortDescription>Hrv - <_description>Croatia - - scr - - - - - - alternatequotes - <_description>Croatia - Use guillemets for quotes - - - - - unicode - <_description>Croatia - Use Croatian digraphs - - - - - unicodeus - <_description>Croatia - US keyboard with Croatian digraphs - - - - - us - <_description>Croatia - US keyboard with Croatian letters - - - - - - - cz - <_shortDescription>Cze - <_description>Czechia - - cze - - - - - - bksl - <_description>Czechia - With <\|> key - - - - - qwerty - <_description>Czechia - qwerty - - - - - qwerty_bksl - <_description>Czechia - qwerty, extended Backslash - - - - - ucw - <_description>Czechia - UCW layout (accented letters only) - - - - - dvorak-ucw - <_description>Czechia - US Dvorak with CZ UCW support - - - - - - - dk - <_shortDescription>Dnk - <_description>Denmark - - dan - - - - - - nodeadkeys - <_description>Denmark - Eliminate dead keys - - - - - mac - <_description>Denmark - Macintosh - - - - - mac_nodeadkeys - <_description>Denmark - Macintosh, eliminate dead keys - - - - - dvorak - <_description>Denmark - Dvorak - - - - - - - nl - <_shortDescription>Nld - <_description>Netherlands - - nld - - - - - - sundeadkeys - <_description>Netherlands - Sun dead keys - - - - - mac - <_description>Netherlands - Macintosh - - - - - std - <_description>Netherlands - Standard - - - - - - - bt - <_shortDescription>Btn - <_description>Bhutan - - dzo - - - - - - ee - <_shortDescription>Est - <_description>Estonia - - est - - - - - - nodeadkeys - <_description>Estonia - Eliminate dead keys - - - - - dvorak - <_description>Estonia - Dvorak - - - - - us - <_description>Estonia - US keyboard with Estonian letters - - - - - - - ir - <_shortDescription>Irn - <_description>Iran - - per - - - - - - pes_keypad - <_description>Iran - Persian, with Persian Keypad - - - - - ku - <_description>Iran - Kurdish, Latin Q - - kur - - - - - - ku_f - <_description>Iran - Kurdish, (F) - - kur - - - - - - ku_alt - <_description>Iran - Kurdish, Latin Alt-Q - - kur - - - - - - ku_ara - <_description>Iran - Kurdish, Arabic-Latin - - kur - - - - - - - - iq - <_shortDescription>Irq - <_description>Iraq - ara - kur - - - - - ku - <_description>Iraq - Kurdish, Latin Q - - kur - - - - - - ku_f - <_description>Iraq - Kurdish, (F) - - kur - - - - - - ku_alt - <_description>Iraq - Kurdish, Latin Alt-Q - - kur - - - - - - ku_ara - <_description>Iraq - Kurdish, Arabic-Latin - - kur - - - - - - - - fo - <_shortDescription>Fro - <_description>Faroe Islands - - fao - - - - - - nodeadkeys - <_description>Faroe Islands - Eliminate dead keys - - - - - - - fi - <_shortDescription>Fin - <_description>Finland - - fin - - - - - - classic - <_description>Finland - Classic - - - - - nodeadkeys - <_description>Finland - Classic, eliminate dead keys - - - - - smi - <_description>Finland - Northern Saami - smi - sme - - - - - mac - <_description>Finland - Macintosh - - - - - - - fr - <_shortDescription>Fra - <_description>France - - fra - - - - - - nodeadkeys - <_description>France - Eliminate dead keys - - - - - sundeadkeys - <_description>France - Sun dead keys - - - - - oss - <_description>France - Alternative - - - - - oss_latin9 - <_description>France - Alternative, latin-9 only - - - - - oss_nodeadkeys - <_description>France - Alternative, eliminate dead keys - - - - - oss_sundeadkeys - <_description>France - Alternative, Sun dead keys - - - - - latin9 - <_description>France - (Legacy) Alternative - - - - - latin9_nodeadkeys - <_description>France - (Legacy) Alternative, eliminate dead keys - - - - - latin9_sundeadkeys - <_description>France - (Legacy) Alternative, Sun dead keys - - - - - bepo - <_description>France - Bepo, ergonomic, Dvorak way - - - - - bepo_latin9 - <_description>France - Bepo, ergonomic, Dvorak way, latin-9 only - - - - - dvorak - <_description>France - Dvorak - - - - - mac - <_description>France - Macintosh - - - - - bre - <_description>France - Breton - - - - - oci - <_description>France - Occitan - - oci - - - - - - geo - <_description>France - Georgian AZERTY Tskapo - - geo - - - - - - - - gh - <_shortDescription>Gha - <_description>Ghana - - eng - - - - - - generic - <_description>Ghana - Multilingual - - - - - akan - <_description>Ghana - Akan - - aka - - - - - - ewe - <_description>Ghana - Ewe - - ewe - - - - - - fula - <_description>Ghana - Fula - - ful - - - - - - ga - <_description>Ghana - Ga - - gaa - - - - - - hausa - <_description>Ghana - Hausa - - hau - - - - - - avn - <_description>Ghana - Avatime - - avn - - - - - - gillbt - <_description>Ghana - GILLBT - - - - - - - gn - <_shortDescription>Gin - <_description>Guinea - - fra - - - - - - - ge - <_shortDescription>Geo - <_description>Georgia - - geo - - - - - - ergonomic - <_description>Georgia - Ergonomic - - - - - mess - <_description>Georgia - MESS - - - - - ru - <_description>Georgia - Russian - - rus - - - - - - os - <_description>Georgia - Ossetian - - oss - - - - - - - - de - <_shortDescription>Deu - <_description>Germany - - ger - - - - - - deadacute - <_description>Germany - Dead acute - - - - - deadgraveacute - <_description>Germany - Dead grave acute - - - - - nodeadkeys - <_description>Germany - Eliminate dead keys - - - - - ro - <_description>Germany - Romanian keyboard with German letters - - - - - ro_nodeadkeys - <_description>Germany - Romanian keyboard with German letters, eliminate dead keys - - - - - dvorak - <_description>Germany - Dvorak - - - - - sundeadkeys - <_description>Germany - Sun dead keys - - - - - neo - <_description>Germany - Neo 2 - - - - - mac - <_description>Germany - Macintosh - - - - - mac_nodeadkeys - <_description>Germany - Macintosh, eliminate dead keys - - - - - dsb - <_description>Germany - Lower Sorbian - - dsb - - - - - - dsb_qwertz - <_description>Germany - Lower Sorbian (qwertz) - - dsb - - - - - - qwerty - <_description>Germany - qwerty - - - - - ru - <_description>Germany - Russian phonetic - - rus - - - - - - - - gr - <_shortDescription>Grc - <_description>Greece - - gre - - - - - - simple - <_description>Greece - Simple - - - - - extended - <_description>Greece - Extended - - - - - nodeadkeys - <_description>Greece - Eliminate dead keys - - - - - polytonic - <_description>Greece - Polytonic - - - - - - - hu - <_shortDescription>Hun - <_description>Hungary - - hun - - - - - - standard - <_description>Hungary - Standard - - - - - nodeadkeys - <_description>Hungary - Eliminate dead keys - - - - - qwerty - <_description>Hungary - qwerty - - - - - 101_qwertz_comma_dead - <_description>Hungary - 101/qwertz/comma/Dead keys - - - - - 101_qwertz_comma_nodead - <_description>Hungary - 101/qwertz/comma/Eliminate dead keys - - - - - 101_qwertz_dot_dead - <_description>Hungary - 101/qwertz/dot/Dead keys - - - - - 101_qwertz_dot_nodead - <_description>Hungary - 101/qwertz/dot/Eliminate dead keys - - - - - 101_qwerty_comma_dead - <_description>Hungary - 101/qwerty/comma/Dead keys - - - - - 101_qwerty_comma_nodead - <_description>Hungary - 101/qwerty/comma/Eliminate dead keys - - - - - 101_qwerty_dot_dead - <_description>Hungary - 101/qwerty/dot/Dead keys - - - - - 101_qwerty_dot_nodead - <_description>Hungary - 101/qwerty/dot/Eliminate dead keys - - - - - 102_qwertz_comma_dead - <_description>Hungary - 102/qwertz/comma/Dead keys - - - - - 102_qwertz_comma_nodead - <_description>Hungary - 102/qwertz/comma/Eliminate dead keys - - - - - 102_qwertz_dot_dead - <_description>Hungary - 102/qwertz/dot/Dead keys - - - - - 102_qwertz_dot_nodead - <_description>Hungary - 102/qwertz/dot/Eliminate dead keys - - - - - 102_qwerty_comma_dead - <_description>Hungary - 102/qwerty/comma/Dead keys - - - - - 102_qwerty_comma_nodead - <_description>Hungary - 102/qwerty/comma/Eliminate dead keys - - - - - 102_qwerty_dot_dead - <_description>Hungary - 102/qwerty/dot/Dead keys - - - - - 102_qwerty_dot_nodead - <_description>Hungary - 102/qwerty/dot/Eliminate dead keys - - - - - - - is - <_shortDescription>Isl - <_description>Iceland - - ice - - - - - - Sundeadkeys - <_description>Iceland - Sun dead keys - - - - - nodeadkeys - <_description>Iceland - Eliminate dead keys - - - - - mac - <_description>Iceland - Macintosh - - - - - dvorak - <_description>Iceland - Dvorak - - - - - - - il - <_shortDescription>Isr - <_description>Israel - - heb - - - - - - lyx - <_description>Israel - lyx - - - - - phonetic - <_description>Israel - Phonetic - - - - - biblical - <_description>Israel - Biblical Hebrew (Tiro) - - - - - - - it - <_shortDescription>Ita - <_description>Italy - - ita - - - - - - nodeadkeys - <_description>Italy - Eliminate dead keys - - - - - mac - <_description>Italy - Macintosh - - - - - us - <_description>Italy - US keyboard with Italian letters - - - - - geo - <_description>Italy - Georgian - - geo - - - - - - - - jp - <_shortDescription>Jpn - <_description>Japan - - jpn - - - - - - kana - <_description>Japan - Kana - - - - - kana86 - <_description>Japan - Kana 86 - - - - - OADG109A - <_description>Japan - OADG 109A - - - - - mac - <_description>Japan - Macintosh - - - - - - - kg - <_shortDescription>Kgz - <_description>Kyrgyzstan - - kir - - - - - - phonetic - <_description>Kyrgyzstan - Phonetic - - - - - - - kh - <_shortDescription>Khm - <_description>Cambodia - - khm - - - - - - - kz - <_shortDescription>Kaz - <_description>Kazakhstan - - kaz - - - - - - ruskaz - <_description>Kazakhstan - Russian with Kazakh - kaz - rus - - - - - kazrus - <_description>Kazakhstan - Kazakh with Russian - kaz - rus - - - - - - - la - <_shortDescription>Lao - <_description>Laos - - lao - - - - - - stea - <_description>Laos - STEA (proposed standard layout) - lao - - - - - - - - latam - <_shortDescription>Esp - <_description>Latin American - - AR - BO - CL - CO - CR - CU - DO - EC - GT - HN - HT - MX - NI - PA - PE - PR - PY - SV - US - UY - VE - - - spa - - - - - - nodeadkeys - <_description>Latin American - Eliminate dead keys - - - - - deadtilde - <_description>Latin American - Include dead tilde - - - - - sundeadkeys - <_description>Latin American - Sun dead keys - - - - - - - lt - <_shortDescription>Ltu - <_description>Lithuania - - lit - - - - - - std - <_description>Lithuania - Standard - - - - - us - <_description>Lithuania - US keyboard with Lithuanian letters - - - - - ibm - <_description>Lithuania - IBM (LST 1205-92) - - - - - lekp - <_description>Lithuania - LEKP - - - - - lekpa - <_description>Lithuania - LEKPa - - - - - - - lv - <_shortDescription>Lva - <_description>Latvia - - lav - - - - - - apostrophe - <_description>Latvia - Apostrophe (') variant - - - - - tilde - <_description>Latvia - Tilde (~) variant - - - - - fkey - <_description>Latvia - F-letter (F) variant - - - - - - - mao - <_shortDescription>Mao - <_description>Maori - - mao - - - - - - - me - <_shortDescription>MNE - <_description>Montenegro - - srp - - - - - - cyrillic - <_description>Montenegro - Cyrillic - - - - - cyrillicyz - <_description>Montenegro - Cyrillic, Z and ZHE swapped - - - - - latinunicode - <_description>Montenegro - Latin unicode - - - - - latinyz - <_description>Montenegro - Latin qwerty - - - - - latinunicodeyz - <_description>Montenegro - Latin unicode qwerty - - - - - cyrillicalternatequotes - <_description>Montenegro - Cyrillic with guillemets - - - - - latinalternatequotes - <_description>Montenegro - Latin with guillemets - - - - - - - mk - <_shortDescription>Mkd - <_description>Macedonia - - mkd - - - - - - nodeadkeys - <_description>Macedonia - Eliminate dead keys - - - - - - - mt - <_shortDescription>Mlt - <_description>Malta - - mlt - - - - - - us - <_description>Malta - Maltese keyboard with US layout - - - - - - - mn - <_shortDescription>Mng - <_description>Mongolia - - mng - - - - - - - no - <_shortDescription>Nor - <_description>Norway - - nor - - - - - - nodeadkeys - <_description>Norway - Eliminate dead keys - - - - - dvorak - <_description>Norway - Dvorak - - - - - smi - <_description>Norway - Northern Saami - - sme - - - - - - smi_nodeadkeys - <_description>Norway - Northern Saami, eliminate dead keys - - sme - - - - - - mac - <_description>Norway - Macintosh - - - - - mac_nodeadkeys - <_description>Norway - Macintosh, eliminate dead keys - - - - - - - pl - <_shortDescription>Pol - <_description>Poland - - pol - - - - - - qwertz - <_description>Poland - qwertz - - - - - dvorak - <_description>Poland - Dvorak - - - - - dvorak_quotes - <_description>Poland - Dvorak, Polish quotes on quotemark key - - - - - dvorak_altquotes - <_description>Poland - Dvorak, Polish quotes on key 1 - - - - - csb - <_description>Poland - Kashubian - - csb - - - - - - ru_phonetic_dvorak - <_description>Poland - Russian phonetic Dvorak - - rus - - - - - - dvp - <_description>Poland - Programmer Dvorak - - - - - - - pt - <_shortDescription>Prt - <_description>Portugal - - por - - - - - - nodeadkeys - <_description>Portugal - Eliminate dead keys - - - - - sundeadkeys - <_description>Portugal - Sun dead keys - - - - - mac - <_description>Portugal - Macintosh - - - - - mac_nodeadkeys - <_description>Portugal - Macintosh, eliminate dead keys - - - - - mac_sundeadkeys - <_description>Portugal - Macintosh, Sun dead keys - - - - - nativo - <_description>Portugal - Nativo - - - - - nativo-us - <_description>Portugal - Nativo for USA keyboards - - - - - nativo-epo - <_description>Portugal - Nativo for Esperanto - - epo - - - - - - - - ro - <_shortDescription>Rou - <_description>Romania - - rum - - - - - - cedilla - <_description>Romania - Cedilla - - - - - std - <_description>Romania - Standard - - - - - std_cedilla - <_description>Romania - Standard (Cedilla) - - - - - winkeys - <_description>Romania - Winkeys - - - - - crh_f - <_description>Romania - Crimean Tatar (Turkish F) - - crh - - - - - - crh_alt - <_description>Romania - Crimean Tatar (Turkish Alt-Q) - - crh - - - - - - crh_dobruca1 - <_description>Romania - Crimean Tatar (Dobruca-1 Q) - - crh - - - - - - crh_dobruca2 - <_description>Romania - Crimean Tatar (Dobruca-2 Q) - - crh - - - - - - - - ru - <_shortDescription>Rus - <_description>Russia - - rus - - - - - - phonetic - <_description>Russia - Phonetic - - - - - phonetic_winkeys - <_description>Russia - Phonetic Winkeys - - - - - typewriter - <_description>Russia - Typewriter - - - - - legacy - <_description>Russia - Legacy - - - - - typewriter-legacy - <_description>Russia - Typewriter, legacy - - - - - tt - <_description>Russia - Tatar - - tat - - - - - - os_legacy - <_description>Russia - Ossetian, legacy - - oss - - - - - - os_winkeys - <_description>Russia - Ossetian, Winkeys - - oss - - - - - - cv - <_description>Russia - Chuvash - - chv - - - - - - cv_latin - <_description>Russia - Chuvash Latin - - chv - - - - - - udm - <_description>Russia - Udmurt - - udm - - - - - - kom - <_description>Russia - Komi - - kom - - - - - - sah - <_description>Russia - Yakut - - sah - - - - - - xal - <_description>Russia - Kalmyk - - xal - - - - - - dos - <_description>Russia - DOS - - - - - srp - <_description>Russia - Serbian - rus - srp - - - - - bak - <_description>Russia - Bashkirian - - bak - - - - - - chm - <_description>Russia - Mari - - chm - - - - - - - - rs - <_shortDescription>SRB - <_description>Serbia - - srp - - - - - - yz - <_description>Serbia - Z and ZHE swapped - - - - - latin - <_description>Serbia - Latin - - - - - latinunicode - <_description>Serbia - Latin Unicode - - - - - latinyz - <_description>Serbia - Latin qwerty - - - - - latinunicodeyz - <_description>Serbia - Latin Unicode qwerty - - - - - alternatequotes - <_description>Serbia - With guillemets - - - - - latinalternatequotes - <_description>Serbia - Latin with guillemets - - - - - rue - <_description>Serbia - Pannonian Rusyn Homophonic - - rue - - - - - - - - si - <_shortDescription>Svn - <_description>Slovenia - - slv - - - - - - alternatequotes - <_description>Slovenia - Use guillemets for quotes - - - - - us - <_description>Slovenia - US keyboard with Slovenian letters - - - - - - - sk - <_shortDescription>Svk - <_description>Slovakia - - slo - - - - - - bksl - <_description>Slovakia - Extended Backslash - - - - - qwerty - <_description>Slovakia - qwerty - - - - - qwerty_bksl - <_description>Slovakia - qwerty, extended Backslash - - - - - - - es - <_shortDescription>Esp - <_description>Spain - - spa - - - - - - nodeadkeys - <_description>Spain - Eliminate dead keys - - - - - deadtilde - <_description>Spain - Include dead tilde - - - - - sundeadkeys - <_description>Spain - Sun dead keys - - - - - dvorak - <_description>Spain - Dvorak - - - - - ast - <_description>Spain - Asturian variant with bottom-dot H and bottom-dot L - - ast - - - - - - cat - <_description>Spain - Catalan variant with middle-dot L - - cat - - - - - - mac - <_description>Spain - Macintosh - - - - - - - se - <_shortDescription>Swe - <_description>Sweden - - swe - - - - - - nodeadkeys - <_description>Sweden - Eliminate dead keys - - - - - dvorak - <_description>Sweden - Dvorak - - - - - rus - <_description>Sweden - Russian phonetic - - rus - - - - - - rus_nodeadkeys - <_description>Sweden - Russian phonetic, eliminate dead keys - - rus - - - - - - smi - <_description>Sweden - Northern Saami - - sme - - - - - - mac - <_description>Sweden - Macintosh - - - - - svdvorak - <_description>Sweden - Svdvorak - - - - - - - ch - <_shortDescription>Che - <_description>Switzerland - ger - gsw - - - - - legacy - <_description>Switzerland - Legacy - - - - - de_nodeadkeys - <_description>Switzerland - German, eliminate dead keys - - - - - de_sundeadkeys - <_description>Switzerland - German, Sun dead keys - - - - - fr - <_description>Switzerland - French - - fra - - - - - - fr_nodeadkeys - <_description>Switzerland - French, eliminate dead keys - - fra - - - - - - fr_sundeadkeys - <_description>Switzerland - French, Sun dead keys - - fra - - - - - - fr_mac - <_description>Switzerland - French (Macintosh) - - fra - - - - - - de_mac - <_description>Switzerland - German (Macintosh) - - - - - - - sy - <_shortDescription>Syr - <_description>Syria - - syr - - - - - - syc - <_description>Syria - Syriac - - - - - syc_phonetic - <_description>Syria - Syriac phonetic - - - - - ku - <_description>Syria - Kurdish, Latin Q - - kur - - - - - - ku_f - <_description>Syria - Kurdish, (F) - - kur - - - - - - ku_alt - <_description>Syria - Kurdish, Latin Alt-Q - - kur - - - - - - - - tj - <_shortDescription>Tjk - <_description>Tajikistan - - tgk - - - - - - legacy - <_description>Tajikistan - Legacy - - - - - - - lk - <_shortDescription>Lka - <_description>Sri Lanka - - sin - - - - - - tam_unicode - <_description>Sri Lanka - Tamil Unicode - - tam - - - - - - tam_TAB - <_description>Sri Lanka - Tamil TAB Typewriter - - tam - - - - - - - - th - <_shortDescription>Tha - <_description>Thailand - - tha - - - - - - tis - <_description>Thailand - TIS-820.2538 - - - - - pat - <_description>Thailand - Pattachote - - - - - - - tr - <_shortDescription>Tur - <_description>Turkey - - tur - - - - - - f - <_description>Turkey - (F) - - - - - alt - <_description>Turkey - Alt-Q - - - - - sundeadkeys - <_description>Turkey - Sun dead keys - - - - - ku - <_description>Turkey - Kurdish, Latin Q - - kur - - - - - - ku_f - <_description>Turkey - Kurdish, (F) - - kur - - - - - - ku_alt - <_description>Turkey - Kurdish, Latin Alt-Q - - kur - - - - - - intl - <_description>Turkey - International (with dead keys) - - - - - crh - <_description>Turkey - Crimean Tatar (Turkish Q) - - crh - - - - - - crh_f - <_description>Turkey - Crimean Tatar (Turkish F) - - crh - - - - - - crh_alt - <_description>Turkey - Crimean Tatar (Turkish Alt-Q) - - crh - - - - - - - - tw - <_shortDescription>Twn - <_description>Taiwan - - trv - - - - - - indigenous - <_description>Taiwan - Indigenous - - ami - tay - bnn - ckv - pwn - pyu - dru - ais - ssf - tao - tsu - - - - - - saisiyat - <_description>Taiwan - Saisiyat - - xsf - - - - - - - - ua - <_shortDescription>Ukr - <_description>Ukraine - - ukr - - - - - - phonetic - <_description>Ukraine - Phonetic - - - - - typewriter - <_description>Ukraine - Typewriter - - - - - winkeys - <_description>Ukraine - Winkeys - - - - - legacy - <_description>Ukraine - Legacy - - - - - rstu - <_description>Ukraine - Standard RSTU - - - - - rstu_ru - <_description>Ukraine - Standard RSTU on Russian layout - - - - - homophonic - <_description>Ukraine - Homophonic - - - - - crh - <_description>Ukraine - Crimean Tatar (Turkish Q) - - crh - - - - - - crh_f - <_description>Ukraine - Crimean Tatar (Turkish F) - - crh - - - - - - crh_alt - <_description>Ukraine - Crimean Tatar (Turkish Alt-Q) - - crh - - - - - - - - gb - <_shortDescription>GBr - <_description>United Kingdom - - eng - - - - - - extd - <_description>United Kingdom - Extended - Winkeys - - - - - intl - <_description>United Kingdom - International (with dead keys) - - - - - dvorak - <_description>United Kingdom - Dvorak - - - - - dvorakukp - <_description>United Kingdom - Dvorak (UK Punctuation) - - - - - mac - <_description>United Kingdom - Macintosh - - - - - mac_intl - <_description>United Kingdom - Macintosh (International) - - - - - colemak - <_description>United Kingdom - Colemak - - - - - - - uz - <_shortDescription>Uzb - <_description>Uzbekistan - - uzb - - - - - - latin - <_description>Uzbekistan - Latin - - - - - crh - <_description>Uzbekistan - Crimean Tatar (Turkish Q) - - crh - - - - - - crh_f - <_description>Uzbekistan - Crimean Tatar (Turkish F) - - crh - - - - - - crh_alt - <_description>Uzbekistan - Crimean Tatar (Turkish Alt-Q) - - crh - - - - - - - - vn - <_shortDescription>Vnm - <_description>Vietnam - - vie - - - - - - - kr - <_shortDescription>Kor - <_description>Korea, Republic of - - kor - - - - - - kr104 - <_description>Korea, Republic of - 101/104 key Compatible - - - - - - - nec_vndr/jp - <_shortDescription>Jpn - <_description>Japan (PC-98xx Series) - - JP - - - jpn - - - - - - - ie - <_shortDescription>Irl - <_description>Ireland - - eng - - - - - - CloGaelach - <_description>Ireland - CloGaelach - - gla - - - - - - UnicodeExpert - <_description>Ireland - UnicodeExpert - - - - - ogam - <_description>Ireland - Ogham - - - - - ogam_is434 - <_description>Ireland - Ogham IS434 - - - - - - - pk - <_shortDescription>Pak - <_description>Pakistan - - urd - - - - - - urd-crulp - <_description>Pakistan - CRULP - - urd - - - - - - urd-nla - <_description>Pakistan - NLA - - urd - - - - - - ara - <_description>Pakistan - Arabic - - ara - - - - - - snd - <_description>Pakistan - Sindhi - - sd - - - - - - - - mv - <_shortDescription>Mdv - <_description>Maldives - - div - - - - - - - za - <_shortDescription>Zaf - <_description>South Africa - - eng - - - - - - epo - <_shortDescription>Epo - <_description>Esperanto - - epo - - - - - - legacy - <_description>Esperanto - displaced semicolon and quote (obsolete) - - - - - - - np - <_shortDescription>Npl - <_description>Nepal - - nep - - - - - - ng - <_shortDescription>Nga - <_description>Nigeria - - eng - - - - - - igbo - <_description>Nigeria - Igbo - - ibo - - - - - - yoruba - <_description>Nigeria - Yoruba - - yor - - - - - - hausa - <_description>Nigeria - Hausa - - hau - - - - - - - - et - <_shortDescription>Eth - <_description>Ethiopia - - amh - - - - - - - sn - <_shortDescription>Sen - <_description>Senegal - - wol - - - - - - - brai - <_shortDescription>Brl - <_description>Braille - - - - - left_hand - <_description>Braille - Left hand - - - - - right_hand - <_description>Braille - Right hand - - - - - - - tm - <_shortDescription>Tkm - <_description>Turkmenistan - - tuk - - - - - - alt - <_description>Turkmenistan - Alt-Q - - - - - - - ml - <_shortDescription>Mli - <_description>Mali - - bam - - - - - - fr-oss - <_description>Mali - Français (France Alternative) - - - - - us-mac - <_description>Mali - English (USA Macintosh) - - - - - us-intl - <_description>Mali - English (USA International) - - - - - - - tz - <_shortDescription>Tza - <_description>Tanzania - - swa - - - - - - ke - <_shortDescription>Ken - <_description>Kenya - - swa - - - - - - kik - <_description>Kenya - Kikuyu - - kik - - - - - - - - bw - <_shortDescription>Bwa - <_description>Botswana - - tsn - - - - - - ph - <_shortDescription>Phi - <_description>Philippines - eng - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - qwerty-bay - <_description>Philippines - QWERTY (Baybayin) - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - capewell-dvorak - <_description>Philippines - Capewell-Dvorak (Latin) - - - - - capewell-dvorak-bay - <_description>Philippines - Capewell-Dvorak (Baybayin) - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - capewell-qwerf2k6 - <_description>Philippines - Capewell-QWERF 2006 (Latin) - - - - - capewell-qwerf2k6-bay - <_description>Philippines - Capewell-QWERF 2006 (Baybayin) - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - colemak - <_description>Philippines - Colemak (Latin) - - - - - colemak-bay - <_description>Philippines - Colemak (Baybayin) - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - dvorak - <_description>Philippines - Dvorak (Latin) - - - - - dvorak-bay - <_description>Philippines - Dvorak (Baybayin) - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - - - - - - grp - <_description>Key(s) to change layout - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - lv3 - <_description>Key to choose 3rd level - - - - - - - - - - - - - - - - - - - - - - - ctrl - <_description>Ctrl key position - - - - - - - - - - - - - grp_led - <_description>Use keyboard LED to show alternative layout - - - - - - - - - keypad - <_description>Numeric keypad layout selection - - - - - - - - - - - - - - - kpdl - <_description>Numeric keypad delete key behaviour - - - - - - - - - - - - - - caps - <_description>Caps Lock key behavior - - - - - - - - - - - - - - - - - - - - altwin - <_description>Alt/Win key behavior - - - - - - - - - - - - - - - Compose key - <_description>Compose key position - - - - - - - - - - - - - - - - compat - <_description>Miscellaneous compatibility options - - - - - - - - - - - - - - - - - - eurosign - <_description>Adding currency signs to certain keys - - - - - - - - - - lv5 - <_description>Key to choose 5th level - - - - - - - - - - - - - - - - nbsp - <_description>Using space key to input non-breakable space character - - - - - - - - - - - - - - - - - - - - - japan - <_description>Japanese keyboard options - - - - - - - esperanto - <_description>Adding Esperanto circumflexes (supersigno) - - - - - - - terminate - <_description>Key sequence to kill the X server - - - - - + + + + + + + pc101 + <_description>Generic 101-key PC + Generic + + + + + pc102 + <_description>Generic 102-key (Intl) PC + Generic + + + + + pc104 + <_description>Generic 104-key PC + Generic + + + + + pc105 + <_description>Generic 105-key (Intl) PC + Generic + + + + + dell101 + <_description>Dell 101-key PC + Dell + + + + + latitude + <_description>Dell Latitude series laptop + Dell + + + + + dellm65 + <_description>Dell Precision M65 + Dell + + + + + everex + <_description>Everex STEPnote + Everex + + + + + flexpro + <_description>Keytronic FlexPro + Keytronic + + + + + microsoft + <_description>Microsoft Natural + Microsoft Inc. + + + + + omnikey101 + <_description>Northgate OmniKey 101 + Northgate + + + + + winbook + <_description>Winbook Model XP5 + Generic + + + + + pc98 + <_description>PC-98xx Series + Generic + + + + + a4techKB21 + <_description>A4Tech KB-21 + A4Tech + + + + + a4techKBS8 + <_description>A4Tech KBS-8 + A4Tech + + + + + a4_rfkb23 + <_description>A4Tech Wireless Desktop RFKB-23 + A4Tech + + + + + airkey + <_description>Acer AirKey V + Acer + + + + + azonaRF2300 + <_description>Azona RF2300 wireless Internet Keyboard + Azona + + + + + scorpius + <_description>Advance Scorpius KI + Scorpius + + + + + brother + <_description>Brother Internet Keyboard + Brother + + + + + btc5113rf + <_description>BTC 5113RF Multimedia + BTC + + + + + btc5126t + <_description>BTC 5126T + BTC + + + + + btc6301urf + <_description>BTC 6301URF + BTC + + + + + btc9000 + <_description>BTC 9000 + BTC + + + + + btc9000a + <_description>BTC 9000A + BTC + + + + + btc9001ah + <_description>BTC 9001AH + BTC + + + + + btc5090 + <_description>BTC 5090 + BTC + + + + + btc9019u + <_description>BTC 9019U + BTC + + + + + btc9116u + <_description>BTC 9116U Mini Wireless Internet and Gaming + + + + + cherryblue + <_description>Cherry Blue Line CyBo@rd + + + + + cherryblueb + <_description>Cherry CyMotion Master XPress + Cherry + + + + + cherrybluea + <_description>Cherry Blue Line CyBo@rd (alternate option) + Cherry + + + + + cherrycyboard + <_description>Cherry CyBo@rd USB-Hub + Cherry + + + + + cherrycmexpert + <_description>Cherry CyMotion Expert + Cherry + + + + + cherrybunlim + <_description>Cherry B.UNLIMITED + Cherry + + + + + chicony + <_description>Chicony Internet Keyboard + Chicony + + + + + chicony0108 + <_description>Chicony KU-0108 + Chicony + + + + + chicony0420 + <_description>Chicony KU-0420 + Chicony + + + + + chicony9885 + <_description>Chicony KB-9885 + Chicony + + + + + compaqeak8 + <_description>Compaq Easy Access Keyboard + Compaq + + + + + compaqik7 + <_description>Compaq Internet Keyboard (7 keys) + Compaq + + + + + compaqik13 + <_description>Compaq Internet Keyboard (13 keys) + Compaq + + + + + compaqik18 + <_description>Compaq Internet Keyboard (18 keys) + Compaq + + + + + cymotionlinux + <_description>Cherry CyMotion Master Linux + Cherry + + + + + armada + <_description>Laptop/notebook Compaq (eg. Armada) Laptop Keyboard + Compaq + + + + + presario + <_description>Laptop/notebook Compaq (eg. Presario) Internet Keyboard + Compaq + + + + + ipaq + <_description>Compaq iPaq Keyboard + Compaq + + + + + dell + <_description>Dell + Dell + + + + + dellsk8125 + <_description>Dell SK-8125 + Dell + + + + + dellsk8135 + <_description>Dell SK-8135 + Dell + + + + + dellusbmm + <_description>Dell USB Multimedia Keyboard + Dell + + + + + inspiron + <_description>Dell Laptop/notebook Inspiron 6xxx/8xxx + Dell + + + + + precision_m + <_description>Dell Laptop/notebook Precision M series + Dell + + + + + dexxa + <_description>Dexxa Wireless Desktop Keyboard + Dexxa + + + + + diamond + <_description>Diamond 9801 / 9802 series + Diamond + + + + + dtk2000 + <_description>DTK2000 + + + + + ennyah_dkb1008 + <_description>Ennyah DKB-1008 + Ennyah + + + + + fscaa1667g + <_description>Fujitsu-Siemens Computers AMILO laptop + Fujitsu-Siemens + + + + + genius + <_description>Genius Comfy KB-16M / Genius MM Keyboard KWD-910 + Genius + + + + + geniuscomfy + <_description>Genius Comfy KB-12e + Genius + + + + + geniuscomfy2 + <_description>Genius Comfy KB-21e-Scroll + Genius + + + + + geniuskb19e + <_description>Genius KB-19e NB + Genius + + + + + geniuskkb2050hs + <_description>Genius KKB-2050HS + Genius + + + + + gyration + <_description>Gyration + Gyration + + + + + htcdream + <_description>HTC Dream + HTC + + + + + kinesis + <_description>Kinesis + Kinesis + + + + + logitech_base + <_description>Logitech Generic Keyboard + Logitech + + + + + logitech_g15 + <_description>Logitech G15 extra keys via G15daemon + Logitech + + + + + hpi6 + <_description>Hewlett-Packard Internet Keyboard + Hewlett-Packard + + + + + hp250x + <_description>Hewlett-Packard SK-250x Multimedia Keyboard + Hewlett-Packard + + + + + hpxe3gc + <_description>Hewlett-Packard Omnibook XE3 GC + Hewlett-Packard + + + + + hpxe3gf + <_description>Hewlett-Packard Omnibook XE3 GF + Hewlett-Packard + + + + + hpxt1000 + <_description>Hewlett-Packard Omnibook XT1000 + Hewlett-Packard + + + + + hpdv5 + <_description>Hewlett-Packard Pavilion dv5 + Hewlett-Packard + + + + + hpzt11xx + <_description>Hewlett-Packard Pavilion ZT11xx + Hewlett-Packard + + + + + hp500fa + <_description>Hewlett-Packard Omnibook 500 FA + Hewlett-Packard + + + + + hp5xx + <_description>Hewlett-Packard Omnibook 5xx + Hewlett-Packard + + + + + hpnx9020 + <_description>Hewlett-Packard nx9020 + Hewlett-Packard + + + + + hp6000 + <_description>Hewlett-Packard Omnibook 6000/6100 + Hewlett-Packard + + + + + honeywell_euroboard + <_description>Honeywell Euroboard + Hewlett-Packard + + + + + hpmini110 + <_description>Hewlett-Packard Mini 110 Notebook + Hewlett-Packard + + + + + rapidaccess + <_description>IBM Rapid Access + Lenovo (previously IBM) + + + + + rapidaccess2 + <_description>IBM Rapid Access II + Lenovo (previously IBM) + + + + + thinkpad + <_description>IBM ThinkPad 560Z/600/600E/A22E + Lenovo (previously IBM) + + + + + thinkpad60 + <_description>IBM ThinkPad R60/T60/R61/T61 + Lenovo (previously IBM) + + + + + thinkpadz60 + <_description>IBM ThinkPad Z60m/Z60t/Z61m/Z61t + Lenovo (previously IBM) + + + + + ibm_spacesaver + <_description>IBM Space Saver + Lenovo (previously IBM) + + + + + logiaccess + <_description>Logitech Access Keyboard + Logitech + + + + + logiclx300 + <_description>Logitech Cordless Desktop LX-300 + Logitech + + + + + logii350 + <_description>Logitech Internet 350 Keyboard + Logitech + + + + + logimel + <_description>Logitech Media Elite Keyboard + Logitech + + + + + logicd + <_description>Logitech Cordless Desktop + Logitech + + + + + logicd_it + <_description>Logitech Cordless Desktop iTouch + Logitech + + + + + logicd_nav + <_description>Logitech Cordless Desktop Navigator + Logitech + + + + + logicd_opt + <_description>Logitech Cordless Desktop Optical + Logitech + + + + + logicda + <_description>Logitech Cordless Desktop (alternate option) + Logitech + + + + + logicdpa2 + <_description>Logitech Cordless Desktop Pro (alternate option 2) + Logitech + + + + + logicfn + <_description>Logitech Cordless Freedom/Desktop Navigator + Logitech + + + + + logicdn + <_description>Logitech Cordless Desktop Navigator + Logitech + + + + + logiitc + <_description>Logitech iTouch Cordless Keyboard (model Y-RB6) + Logitech + + + + + logiik + <_description>Logitech Internet Keyboard + Logitech + + + + + itouch + <_description>Logitech iTouch + Logitech + + + + + logicink + <_description>Logitech Internet Navigator Keyboard + Logitech + + + + + logiex110 + <_description>Logitech Cordless Desktop EX110 + Logitech + + + + + logiinkse + <_description>Logitech iTouch Internet Navigator Keyboard SE + Logitech + + + + + logiinkseusb + <_description>Logitech iTouch Internet Navigator Keyboard SE (USB) + Logitech + + + + + logiultrax + <_description>Logitech Ultra-X Keyboard + Logitech + + + + + logiultraxc + <_description>Logitech Ultra-X Cordless Media Desktop Keyboard + Logitech + + + + + logidinovo + <_description>Logitech diNovo Keyboard + Logitech + + + + + logidinovoedge + <_description>Logitech diNovo Edge Keyboard + Logitech + + + + + mx1998 + <_description>Memorex MX1998 + Memorex + + + + + mx2500 + <_description>Memorex MX2500 EZ-Access Keyboard + Memorex + + + + + mx2750 + <_description>Memorex MX2750 + Memorex + + + + + microsoft4000 + <_description>Microsoft Natural Wireless Ergonomic Keyboard 4000 + Microsoft Inc. + + + + + microsoft7000 + <_description>Microsoft Natural Wireless Ergonomic Keyboard 7000 + Microsoft Inc. + + + + + microsoftinet + <_description>Microsoft Internet Keyboard + Microsoft Inc. + + + + + microsoftpro + <_description>Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro + Microsoft Inc. + + + + + microsoftprousb + <_description>Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro + Microsoft Inc. + + + + + microsoftprooem + <_description>Microsoft Natural Keyboard Pro OEM + Microsoft Inc. + + + + + vsonku306 + <_description>ViewSonic KU-306 Internet Keyboard + ViewSonic + + + + + microsoftprose + <_description>Microsoft Internet Keyboard Pro, Swedish + Microsoft Inc. + + + + + microsoftoffice + <_description>Microsoft Office Keyboard + Microsoft Inc. + + + + + microsoftmult + <_description>Microsoft Wireless Multimedia Keyboard 1.0A + Microsoft Inc. + + + + + microsoftelite + <_description>Microsoft Natural Keyboard Elite + Microsoft Inc. + + + + + microsoftccurve2k + <_description>Microsoft Comfort Curve Keyboard 2000 + Microsoft Inc. + + + + + oretec + <_description>Ortek MCK-800 MM/Internet keyboard + Ortek + + + + + propeller + <_description>Propeller Voyager (KTEZ-1000) + KeyTronic + + + + + qtronix + <_description>QTronix Scorpius 98N+ + QTronix + + + + + samsung4500 + <_description>Samsung SDM 4500P + Samsung + + + + + samsung4510 + <_description>Samsung SDM 4510P + Samsung + + + + + sanwaskbkg3 + <_description>Sanwa Supply SKB-KG3 + Sanwa Supply Inc. + + + + + sk1300 + <_description>SK-1300 + NEC + + + + + sk2500 + <_description>SK-2500 + NEC + + + + + sk6200 + <_description>SK-6200 + NEC + + + + + sk7100 + <_description>SK-7100 + NEC + + + + + sp_inet + <_description>Super Power Multimedia Keyboard + Generic + + + + + sven + <_description>SVEN Ergonomic 2500 + SVEN + + + + + sven303 + <_description>SVEN Slim 303 + SVEN + + + + + symplon + <_description>Symplon PaceBook (tablet PC) + Symplon + + + + + toshiba_s3000 + <_description>Toshiba Satellite S3000 + Toshiba + + + + + trust + <_description>Trust Wireless Keyboard Classic + Trust + + + + + trustda + <_description>Trust Direct Access Keyboard + Trust + + + + + trust_slimline + <_description>Trust Slimline + Trust + + + + + tm2020 + <_description>TypeMatrix EZ-Reach 2020 + TypeMatrix + + + + + tm2030PS2 + <_description>TypeMatrix EZ-Reach 2030 PS2 + TypeMatrix + + + + + tm2030USB + <_description>TypeMatrix EZ-Reach 2030 USB + TypeMatrix + + + + + tm2030USB-102 + <_description>TypeMatrix EZ-Reach 2030 USB (102/105:EU mode) + TypeMatrix + + + + + tm2030USB-106 + <_description>TypeMatrix EZ-Reach 2030 USB (106:JP mode) + TypeMatrix + + + + + yahoo + <_description>Yahoo! Internet Keyboard + Yahoo! + + + + + macbook78 + <_description>MacBook/MacBook Pro + Apple + + + + + macbook79 + <_description>MacBook/MacBook Pro (Intl) + Apple + + + + + macintosh + <_description>Macintosh + Apple + + + + + macintosh_old + <_description>Macintosh Old + Apple + + + + + macintosh_hhk + <_description>Happy Hacking Keyboard for Mac + Fujitsu + + + + + acer_c300 + <_description>Acer C300 + Acer + + + + + acer_ferrari4k + <_description>Acer Ferrari 4000 + Acer + + + + + acer_laptop + <_description>Acer Laptop + Acer + + + + + asus_laptop + <_description>Asus Laptop + Asus + + + + + apple + <_description>Apple + Apple + + + + + apple_laptop + <_description>Apple Laptop + Apple + + + + + applealu_ansi + <_description>Apple Aluminium Keyboard (ANSI) + Apple + + + + + applealu_iso + <_description>Apple Aluminium Keyboard (ISO) + Apple + + + + + applealu_jis + <_description>Apple Aluminium Keyboard (JIS) + Apple + + + + + silvercrest + <_description>SILVERCREST Multimedia Wireless Keyboard + Silvercrest + + + + + emachines + <_description>Laptop/notebook eMachines m68xx + eMachines + + + + + benqx + <_description>BenQ X-Touch + BenQ + + + + + benqx730 + <_description>BenQ X-Touch 730 + BenQ + + + + + benqx800 + <_description>BenQ X-Touch 800 + BenQ + + + + + hhk + <_description>Happy Hacking Keyboard + Fujitsu + + + + + classmate + <_description>Classmate PC + Intel + + + + + olpc + <_description>OLPC + OLPC + + + + + sun6 + <_description>Sun Type 5/6 + Sun Microsystems + + + + + targa_v811 + <_description>Targa Visionary 811 + Targa + + + + + unitekkb1925 + <_description>Unitek KB-1925 + Unitek Group + + + + + compalfl90 + <_description>FL90 + Compal Electronics Inc. + + + + + creativedw7000 + <_description>Creative Desktop Wireless 7000 + Creative + + + + + htcdream + <_description>Htc Dream phone + htc + + + + + + + us + <_shortDescription>USA + <_description>USA + + eng + + + + + + chr + <_description>USA - Cherokee + + chr + + + + + + euro + <_description>USA - With EuroSign on 5 + + + + + intl + <_description>USA - International (with dead keys) + + + + + alt-intl + <_description>USA - Alternative international + + + + + colemak + <_description>USA - Colemak + + + + + dvorak + <_description>USA - Dvorak + + + + + dvorak-intl + <_description>USA - Dvorak international (with dead keys) + + + + + dvorak-alt-intl + <_description>USA - Dvorak alternative international (no dead keys) + + + + + dvorak-l + <_description>USA - Left handed Dvorak + + + + + dvorak-r + <_description>USA - Right handed Dvorak + + + + + dvorak-classic + <_description>USA - Classic Dvorak + + + + + dvp + <_description>USA - Programmer Dvorak + + + + + rus + <_description>USA - Russian phonetic + + rus + + + + + + mac + <_description>USA - Macintosh + + + + + altgr-intl + <_description>USA - International (AltGr dead keys) + eng + fra + ger + + + + + olpc2 + <_description>USA - Layout toggle on multiply/divide key + + + + + hbs + <_description>USA - Serbo-Croatian + eng + bos + hbs + hrv + srp + + + + + + + ad + <_shortDescription>And + <_description>Andorra + + cat + + + + + + + af + <_shortDescription>Afg + <_description>Afghanistan + + + + + ps + <_description>Afghanistan - Pashto + + pus + + + + + + uz + <_description>Afghanistan - Southern Uzbek + + uzb + + + + + + olpc-ps + <_description>Afghanistan - OLPC Pashto + + pus + + + + + + fa-olpc + <_description>Afghanistan - OLPC Dari + + + + + uz-olpc + <_description>Afghanistan - OLPC Southern Uzbek + + uzb + + + + + + + + ara + <_shortDescription>Ara + <_description>Arabic + + AE + BH + DZ + EG + EH + JO + KW + LB + LY + MA + MR + OM + PS + QA + SA + SD + SY + TN + YE + + + ara + + + + + + azerty + <_description>Arabic - azerty + + + + + azerty_digits + <_description>Arabic - azerty/digits + + + + + digits + <_description>Arabic - digits + + + + + qwerty + <_description>Arabic - qwerty + + + + + qwerty_digits + <_description>Arabic - qwerty/digits + + + + + buckwalter + <_description>Arabic - Buckwalter + + + + + + + al + <_shortDescription>Alb + <_description>Albania + + alb + + + + + + + am + <_shortDescription>Arm + <_description>Armenia + + hye + + + + + + phonetic + <_description>Armenia - Phonetic + + + + + phonetic-alt + <_description>Armenia - Alternative Phonetic + + + + + eastern + <_description>Armenia - Eastern + + + + + western + <_description>Armenia - Western + + + + + eastern-alt + <_description>Armenia - Alternative Eastern + + + + + + + at + <_shortDescription>Aut + <_description>Austria + + ger + + + + + + nodeadkeys + <_description>Austria - Eliminate dead keys + + + + + sundeadkeys + <_description>Austria - Sun dead keys + + + + + mac + <_description>Austria - Macintosh + + + + + + + az + <_shortDescription>Aze + <_description>Azerbaijan + + aze + + + + + + cyrillic + <_description>Azerbaijan - Cyrillic + + + + + + + by + <_shortDescription>Blr + <_description>Belarus + + bel + + + + + + legacy + <_description>Belarus - Legacy + + + + + latin + <_description>Belarus - Latin + + + + + + + be + <_shortDescription>Bel + <_description>Belgium + ger + nld + fra + + + + + oss + <_description>Belgium - Alternative + + + + + oss_latin9 + <_description>Belgium - Alternative, latin-9 only + + + + + oss_sundeadkeys + <_description>Belgium - Alternative, Sun dead keys + + + + + iso-alternate + <_description>Belgium - ISO Alternate + + + + + nodeadkeys + <_description>Belgium - Eliminate dead keys + + + + + sundeadkeys + <_description>Belgium - Sun dead keys + + + + + wang + <_description>Belgium - Wang model 724 azerty + + + + + + + bd + <_shortDescription>Bgd + <_description>Bangladesh + + ben + + + + + + probhat + <_description>Bangladesh - Probhat + + + + + + + in + <_shortDescription>Ind + <_description>India + + + + + ben + <_description>India - Bengali + + ben + + + + + + ben_probhat + <_description>India - Bengali Probhat + + ben + + + + + + guj + <_description>India - Gujarati + + guj + + + + + + guru + <_description>India - Gurmukhi + + pan + + + + + + jhelum + <_description>India - Gurmukhi Jhelum + + pan + + + + + + kan + <_description>India - Kannada + + kan + + + + + + mal + <_description>India - Malayalam + + mal + + + + + + mal_lalitha + <_description>India - Malayalam Lalitha + + mal + + + + + + mal_enhanced + <_description>India - Malayalam enhanced Inscript with Rupee Sign + mal + + + + + ori + <_description>India - Oriya + + ori + + + + + + tam_unicode + <_description>India - Tamil Unicode + + tam + + + + + + tam_keyboard_with_numerals + <_description>India - Tamil Keyboard with Numerals + + tam + + + + + + tam_TAB + <_description>India - Tamil TAB Typewriter + + tam + + + + + + tam_TSCII + <_description>India - Tamil TSCII Typewriter + + tam + + + + + + tam + <_description>India - Tamil + + tam + + + + + + tel + <_description>India - Telugu + + tel + + + + + + urd-phonetic + <_description>India - Urdu, Phonetic + + urd + + + + + + urd-phonetic3 + <_description>India - Urdu, Alternative phonetic + + urd + + + + + + urd-winkeys + <_description>India - Urdu, Winkeys + + urd + + + + + + bolnagri + <_description>India - Hindi Bolnagri + + hin + + + + + + hin-wx + <_description>India - Hindi Wx + + hin + + + + + + eng + <_description>India - English with RupeeSign + + eng + + + + + + + + ba + <_shortDescription>Bih + <_description>Bosnia and Herzegovina + + bos + + + + + + alternatequotes + <_description>Bosnia and Herzegovina - Use guillemets for quotes + + + + + unicode + <_description>Bosnia and Herzegovina - Use Bosnian digraphs + + + + + unicodeus + <_description>Bosnia and Herzegovina - US keyboard with Bosnian digraphs + + + + + us + <_description>Bosnia and Herzegovina - US keyboard with Bosnian letters + + + + + + + br + <_shortDescription>Bra + <_description>Brazil + + por + + + + + + nodeadkeys + <_description>Brazil - Eliminate dead keys + + + + + dvorak + <_description>Brazil - Dvorak + + + + + nativo + <_description>Brazil - Nativo + + + + + nativo-us + <_description>Brazil - Nativo for USA keyboards + + + + + nativo-epo + <_description>Brazil - Nativo for Esperanto + + epo + + + + + + + + bg + <_shortDescription>Bgr + <_description>Bulgaria + + bul + + + + + + phonetic + <_description>Bulgaria - Traditional phonetic + + + + + bas_phonetic + <_description>Bulgaria - New phonetic + + + + + + + ma + <_description>Morocco + + + + + french + <_description>Morocco - French + + fra + + + + + + tifinagh + <_description>Morocco - Tifinagh + + ber + + + + + + tifinagh-alt + <_description>Morocco - Tifinagh alternative + + ber + + + + + + tifinagh-alt-phonetic + <_description>Morocco - Tifinagh alternative phonetic + + ber + + + + + + tifinagh-extended + <_description>Morocco - Tifinagh extended + + ber + + + + + + tifinagh-phonetic + <_description>Morocco - Tifinagh phonetic + + ber + + + + + + tifinagh-extended-phonetic + <_description>Morocco - Tifinagh extended phonetic + + ber + + + + + + + + mm + <_shortDescription>Mmr + <_description>Myanmar + + mya + + + + + + + ca + <_shortDescription>Can + <_description>Canada + + fra + + + + + + fr-dvorak + <_description>Canada - French Dvorak + + + + + fr-legacy + <_description>Canada - French (legacy) + + + + + multix + <_description>Canada - Multilingual + + + + + multi + <_description>Canada - Multilingual, first part + + + + + multi-2gr + <_description>Canada - Multilingual, second part + + + + + ike + <_description>Canada - Inuktitut + + iku + + + + + + shs + <_description>Canada - Secwepemctsin + + + + + kut + <_description>Canada - Ktunaxa + + + + + eng + <_description>Canada - English + + eng + + + + + + + + cd + <_shortDescription>COD + <_description>Congo, Democratic Republic of the + + fra + + + + + + + cn + <_shortDescription>Chn + <_description>China + + chi + + + + + + tib + <_description>China - Tibetan + + tib + + + + + + tib_asciinum + <_description>China - Tibetan (with ASCII numerals) + + tib + + + + + + uig + <_description>China - Uyghur + + uig + + + + + + + + hr + <_shortDescription>Hrv + <_description>Croatia + + scr + + + + + + alternatequotes + <_description>Croatia - Use guillemets for quotes + + + + + unicode + <_description>Croatia - Use Croatian digraphs + + + + + unicodeus + <_description>Croatia - US keyboard with Croatian digraphs + + + + + us + <_description>Croatia - US keyboard with Croatian letters + + + + + + + cz + <_shortDescription>Cze + <_description>Czechia + + cze + + + + + + bksl + <_description>Czechia - With <\|> key + + + + + qwerty + <_description>Czechia - qwerty + + + + + qwerty_bksl + <_description>Czechia - qwerty, extended Backslash + + + + + ucw + <_description>Czechia - UCW layout (accented letters only) + + + + + dvorak-ucw + <_description>Czechia - US Dvorak with CZ UCW support + + + + + + + dk + <_shortDescription>Dnk + <_description>Denmark + + dan + + + + + + nodeadkeys + <_description>Denmark - Eliminate dead keys + + + + + mac + <_description>Denmark - Macintosh + + + + + mac_nodeadkeys + <_description>Denmark - Macintosh, eliminate dead keys + + + + + dvorak + <_description>Denmark - Dvorak + + + + + + + nl + <_shortDescription>Nld + <_description>Netherlands + + nld + + + + + + sundeadkeys + <_description>Netherlands - Sun dead keys + + + + + mac + <_description>Netherlands - Macintosh + + + + + std + <_description>Netherlands - Standard + + + + + + + bt + <_shortDescription>Btn + <_description>Bhutan + + dzo + + + + + + ee + <_shortDescription>Est + <_description>Estonia + + est + + + + + + nodeadkeys + <_description>Estonia - Eliminate dead keys + + + + + dvorak + <_description>Estonia - Dvorak + + + + + us + <_description>Estonia - US keyboard with Estonian letters + + + + + + + ir + <_shortDescription>Irn + <_description>Iran + + per + + + + + + pes_keypad + <_description>Iran - Persian, with Persian Keypad + + + + + ku + <_description>Iran - Kurdish, Latin Q + + kur + + + + + + ku_f + <_description>Iran - Kurdish, (F) + + kur + + + + + + ku_alt + <_description>Iran - Kurdish, Latin Alt-Q + + kur + + + + + + ku_ara + <_description>Iran - Kurdish, Arabic-Latin + + kur + + + + + + + + iq + <_shortDescription>Irq + <_description>Iraq + ara + kur + + + + + ku + <_description>Iraq - Kurdish, Latin Q + + kur + + + + + + ku_f + <_description>Iraq - Kurdish, (F) + + kur + + + + + + ku_alt + <_description>Iraq - Kurdish, Latin Alt-Q + + kur + + + + + + ku_ara + <_description>Iraq - Kurdish, Arabic-Latin + + kur + + + + + + + + fo + <_shortDescription>Fro + <_description>Faroe Islands + + fao + + + + + + nodeadkeys + <_description>Faroe Islands - Eliminate dead keys + + + + + + + fi + <_shortDescription>Fin + <_description>Finland + + fin + + + + + + classic + <_description>Finland - Classic + + + + + nodeadkeys + <_description>Finland - Classic, eliminate dead keys + + + + + smi + <_description>Finland - Northern Saami + smi + sme + + + + + mac + <_description>Finland - Macintosh + + + + + + + fr + <_shortDescription>Fra + <_description>France + + fra + + + + + + nodeadkeys + <_description>France - Eliminate dead keys + + + + + sundeadkeys + <_description>France - Sun dead keys + + + + + oss + <_description>France - Alternative + + + + + oss_latin9 + <_description>France - Alternative, latin-9 only + + + + + oss_nodeadkeys + <_description>France - Alternative, eliminate dead keys + + + + + oss_sundeadkeys + <_description>France - Alternative, Sun dead keys + + + + + latin9 + <_description>France - (Legacy) Alternative + + + + + latin9_nodeadkeys + <_description>France - (Legacy) Alternative, eliminate dead keys + + + + + latin9_sundeadkeys + <_description>France - (Legacy) Alternative, Sun dead keys + + + + + bepo + <_description>France - Bepo, ergonomic, Dvorak way + + + + + bepo_latin9 + <_description>France - Bepo, ergonomic, Dvorak way, latin-9 only + + + + + dvorak + <_description>France - Dvorak + + + + + mac + <_description>France - Macintosh + + + + + bre + <_description>France - Breton + + + + + oci + <_description>France - Occitan + + oci + + + + + + geo + <_description>France - Georgian AZERTY Tskapo + + geo + + + + + + + + gh + <_shortDescription>Gha + <_description>Ghana + + eng + + + + + + generic + <_description>Ghana - Multilingual + + + + + akan + <_description>Ghana - Akan + + aka + + + + + + ewe + <_description>Ghana - Ewe + + ewe + + + + + + fula + <_description>Ghana - Fula + + ful + + + + + + ga + <_description>Ghana - Ga + + gaa + + + + + + hausa + <_description>Ghana - Hausa + + hau + + + + + + avn + <_description>Ghana - Avatime + + avn + + + + + + gillbt + <_description>Ghana - GILLBT + + + + + + + gn + <_shortDescription>Gin + <_description>Guinea + + fra + + + + + + + ge + <_shortDescription>Geo + <_description>Georgia + + geo + + + + + + ergonomic + <_description>Georgia - Ergonomic + + + + + mess + <_description>Georgia - MESS + + + + + ru + <_description>Georgia - Russian + + rus + + + + + + os + <_description>Georgia - Ossetian + + oss + + + + + + + + de + <_shortDescription>Deu + <_description>Germany + + ger + + + + + + deadacute + <_description>Germany - Dead acute + + + + + deadgraveacute + <_description>Germany - Dead grave acute + + + + + nodeadkeys + <_description>Germany - Eliminate dead keys + + + + + ro + <_description>Germany - Romanian keyboard with German letters + + + + + ro_nodeadkeys + <_description>Germany - Romanian keyboard with German letters, eliminate dead keys + + + + + dvorak + <_description>Germany - Dvorak + + + + + sundeadkeys + <_description>Germany - Sun dead keys + + + + + neo + <_description>Germany - Neo 2 + + + + + mac + <_description>Germany - Macintosh + + + + + mac_nodeadkeys + <_description>Germany - Macintosh, eliminate dead keys + + + + + dsb + <_description>Germany - Lower Sorbian + + dsb + + + + + + dsb_qwertz + <_description>Germany - Lower Sorbian (qwertz) + + dsb + + + + + + qwerty + <_description>Germany - qwerty + + + + + ru + <_description>Germany - Russian phonetic + + rus + + + + + + + + gr + <_shortDescription>Grc + <_description>Greece + + gre + + + + + + simple + <_description>Greece - Simple + + + + + extended + <_description>Greece - Extended + + + + + nodeadkeys + <_description>Greece - Eliminate dead keys + + + + + polytonic + <_description>Greece - Polytonic + + + + + + + hu + <_shortDescription>Hun + <_description>Hungary + + hun + + + + + + standard + <_description>Hungary - Standard + + + + + nodeadkeys + <_description>Hungary - Eliminate dead keys + + + + + qwerty + <_description>Hungary - qwerty + + + + + 101_qwertz_comma_dead + <_description>Hungary - 101/qwertz/comma/Dead keys + + + + + 101_qwertz_comma_nodead + <_description>Hungary - 101/qwertz/comma/Eliminate dead keys + + + + + 101_qwertz_dot_dead + <_description>Hungary - 101/qwertz/dot/Dead keys + + + + + 101_qwertz_dot_nodead + <_description>Hungary - 101/qwertz/dot/Eliminate dead keys + + + + + 101_qwerty_comma_dead + <_description>Hungary - 101/qwerty/comma/Dead keys + + + + + 101_qwerty_comma_nodead + <_description>Hungary - 101/qwerty/comma/Eliminate dead keys + + + + + 101_qwerty_dot_dead + <_description>Hungary - 101/qwerty/dot/Dead keys + + + + + 101_qwerty_dot_nodead + <_description>Hungary - 101/qwerty/dot/Eliminate dead keys + + + + + 102_qwertz_comma_dead + <_description>Hungary - 102/qwertz/comma/Dead keys + + + + + 102_qwertz_comma_nodead + <_description>Hungary - 102/qwertz/comma/Eliminate dead keys + + + + + 102_qwertz_dot_dead + <_description>Hungary - 102/qwertz/dot/Dead keys + + + + + 102_qwertz_dot_nodead + <_description>Hungary - 102/qwertz/dot/Eliminate dead keys + + + + + 102_qwerty_comma_dead + <_description>Hungary - 102/qwerty/comma/Dead keys + + + + + 102_qwerty_comma_nodead + <_description>Hungary - 102/qwerty/comma/Eliminate dead keys + + + + + 102_qwerty_dot_dead + <_description>Hungary - 102/qwerty/dot/Dead keys + + + + + 102_qwerty_dot_nodead + <_description>Hungary - 102/qwerty/dot/Eliminate dead keys + + + + + + + is + <_shortDescription>Isl + <_description>Iceland + + ice + + + + + + Sundeadkeys + <_description>Iceland - Sun dead keys + + + + + nodeadkeys + <_description>Iceland - Eliminate dead keys + + + + + mac + <_description>Iceland - Macintosh + + + + + dvorak + <_description>Iceland - Dvorak + + + + + + + il + <_shortDescription>Isr + <_description>Israel + + heb + + + + + + lyx + <_description>Israel - lyx + + + + + phonetic + <_description>Israel - Phonetic + + + + + biblical + <_description>Israel - Biblical Hebrew (Tiro) + + + + + + + it + <_shortDescription>Ita + <_description>Italy + + ita + + + + + + nodeadkeys + <_description>Italy - Eliminate dead keys + + + + + mac + <_description>Italy - Macintosh + + + + + us + <_description>Italy - US keyboard with Italian letters + + + + + geo + <_description>Italy - Georgian + + geo + + + + + + + + jp + <_shortDescription>Jpn + <_description>Japan + + jpn + + + + + + kana + <_description>Japan - Kana + + + + + kana86 + <_description>Japan - Kana 86 + + + + + OADG109A + <_description>Japan - OADG 109A + + + + + mac + <_description>Japan - Macintosh + + + + + + + kg + <_shortDescription>Kgz + <_description>Kyrgyzstan + + kir + + + + + + phonetic + <_description>Kyrgyzstan - Phonetic + + + + + + + kh + <_shortDescription>Khm + <_description>Cambodia + + khm + + + + + + + kz + <_shortDescription>Kaz + <_description>Kazakhstan + + kaz + + + + + + ruskaz + <_description>Kazakhstan - Russian with Kazakh + kaz + rus + + + + + kazrus + <_description>Kazakhstan - Kazakh with Russian + kaz + rus + + + + + + + la + <_shortDescription>Lao + <_description>Laos + + lao + + + + + + stea + <_description>Laos - STEA (proposed standard layout) + lao + + + + + + + + latam + <_shortDescription>Esp + <_description>Latin American + + AR + BO + CL + CO + CR + CU + DO + EC + GT + HN + HT + MX + NI + PA + PE + PR + PY + SV + US + UY + VE + + + spa + + + + + + nodeadkeys + <_description>Latin American - Eliminate dead keys + + + + + deadtilde + <_description>Latin American - Include dead tilde + + + + + sundeadkeys + <_description>Latin American - Sun dead keys + + + + + + + lt + <_shortDescription>Ltu + <_description>Lithuania + + lit + + + + + + std + <_description>Lithuania - Standard + + + + + us + <_description>Lithuania - US keyboard with Lithuanian letters + + + + + ibm + <_description>Lithuania - IBM (LST 1205-92) + + + + + lekp + <_description>Lithuania - LEKP + + + + + lekpa + <_description>Lithuania - LEKPa + + + + + + + lv + <_shortDescription>Lva + <_description>Latvia + + lav + + + + + + apostrophe + <_description>Latvia - Apostrophe (') variant + + + + + tilde + <_description>Latvia - Tilde (~) variant + + + + + fkey + <_description>Latvia - F-letter (F) variant + + + + + + + mao + <_shortDescription>Mao + <_description>Maori + + mao + + + + + + + me + <_shortDescription>MNE + <_description>Montenegro + + srp + + + + + + cyrillic + <_description>Montenegro - Cyrillic + + + + + cyrillicyz + <_description>Montenegro - Cyrillic, Z and ZHE swapped + + + + + latinunicode + <_description>Montenegro - Latin unicode + + + + + latinyz + <_description>Montenegro - Latin qwerty + + + + + latinunicodeyz + <_description>Montenegro - Latin unicode qwerty + + + + + cyrillicalternatequotes + <_description>Montenegro - Cyrillic with guillemets + + + + + latinalternatequotes + <_description>Montenegro - Latin with guillemets + + + + + + + mk + <_shortDescription>Mkd + <_description>Macedonia + + mkd + + + + + + nodeadkeys + <_description>Macedonia - Eliminate dead keys + + + + + + + mt + <_shortDescription>Mlt + <_description>Malta + + mlt + + + + + + us + <_description>Malta - Maltese keyboard with US layout + + + + + + + mn + <_shortDescription>Mng + <_description>Mongolia + + mng + + + + + + + no + <_shortDescription>Nor + <_description>Norway + + nor + + + + + + nodeadkeys + <_description>Norway - Eliminate dead keys + + + + + dvorak + <_description>Norway - Dvorak + + + + + smi + <_description>Norway - Northern Saami + + sme + + + + + + smi_nodeadkeys + <_description>Norway - Northern Saami, eliminate dead keys + + sme + + + + + + mac + <_description>Norway - Macintosh + + + + + mac_nodeadkeys + <_description>Norway - Macintosh, eliminate dead keys + + + + + + + pl + <_shortDescription>Pol + <_description>Poland + + pol + + + + + + qwertz + <_description>Poland - qwertz + + + + + dvorak + <_description>Poland - Dvorak + + + + + dvorak_quotes + <_description>Poland - Dvorak, Polish quotes on quotemark key + + + + + dvorak_altquotes + <_description>Poland - Dvorak, Polish quotes on key 1 + + + + + csb + <_description>Poland - Kashubian + + csb + + + + + + ru_phonetic_dvorak + <_description>Poland - Russian phonetic Dvorak + + rus + + + + + + dvp + <_description>Poland - Programmer Dvorak + + + + + + + pt + <_shortDescription>Prt + <_description>Portugal + + por + + + + + + nodeadkeys + <_description>Portugal - Eliminate dead keys + + + + + sundeadkeys + <_description>Portugal - Sun dead keys + + + + + mac + <_description>Portugal - Macintosh + + + + + mac_nodeadkeys + <_description>Portugal - Macintosh, eliminate dead keys + + + + + mac_sundeadkeys + <_description>Portugal - Macintosh, Sun dead keys + + + + + nativo + <_description>Portugal - Nativo + + + + + nativo-us + <_description>Portugal - Nativo for USA keyboards + + + + + nativo-epo + <_description>Portugal - Nativo for Esperanto + + epo + + + + + + + + ro + <_shortDescription>Rou + <_description>Romania + + rum + + + + + + cedilla + <_description>Romania - Cedilla + + + + + std + <_description>Romania - Standard + + + + + std_cedilla + <_description>Romania - Standard (Cedilla) + + + + + winkeys + <_description>Romania - Winkeys + + + + + crh_f + <_description>Romania - Crimean Tatar (Turkish F) + + crh + + + + + + crh_alt + <_description>Romania - Crimean Tatar (Turkish Alt-Q) + + crh + + + + + + crh_dobruca1 + <_description>Romania - Crimean Tatar (Dobruca-1 Q) + + crh + + + + + + crh_dobruca2 + <_description>Romania - Crimean Tatar (Dobruca-2 Q) + + crh + + + + + + + + ru + <_shortDescription>Rus + <_description>Russia + + rus + + + + + + phonetic + <_description>Russia - Phonetic + + + + + phonetic_winkeys + <_description>Russia - Phonetic Winkeys + + + + + typewriter + <_description>Russia - Typewriter + + + + + legacy + <_description>Russia - Legacy + + + + + typewriter-legacy + <_description>Russia - Typewriter, legacy + + + + + tt + <_description>Russia - Tatar + + tat + + + + + + os_legacy + <_description>Russia - Ossetian, legacy + + oss + + + + + + os_winkeys + <_description>Russia - Ossetian, Winkeys + + oss + + + + + + cv + <_description>Russia - Chuvash + + chv + + + + + + cv_latin + <_description>Russia - Chuvash Latin + + chv + + + + + + udm + <_description>Russia - Udmurt + + udm + + + + + + kom + <_description>Russia - Komi + + kom + + + + + + sah + <_description>Russia - Yakut + + sah + + + + + + xal + <_description>Russia - Kalmyk + + xal + + + + + + dos + <_description>Russia - DOS + + + + + srp + <_description>Russia - Serbian + rus + srp + + + + + bak + <_description>Russia - Bashkirian + + bak + + + + + + chm + <_description>Russia - Mari + + chm + + + + + + + + rs + <_shortDescription>Srb + <_description>Serbia + + srp + + + + + + yz + <_description>Serbia - Z and ZHE swapped + + + + + latin + <_description>Serbia - Latin + + + + + latinunicode + <_description>Serbia - Latin Unicode + + + + + latinyz + <_description>Serbia - Latin qwerty + + + + + latinunicodeyz + <_description>Serbia - Latin Unicode qwerty + + + + + alternatequotes + <_description>Serbia - With guillemets + + + + + latinalternatequotes + <_description>Serbia - Latin with guillemets + + + + + rue + <_description>Serbia - Pannonian Rusyn Homophonic + + rue + + + + + + + + si + <_shortDescription>Svn + <_description>Slovenia + + slv + + + + + + alternatequotes + <_description>Slovenia - Use guillemets for quotes + + + + + us + <_description>Slovenia - US keyboard with Slovenian letters + + + + + + + sk + <_shortDescription>Svk + <_description>Slovakia + + slo + + + + + + bksl + <_description>Slovakia - Extended Backslash + + + + + qwerty + <_description>Slovakia - qwerty + + + + + qwerty_bksl + <_description>Slovakia - qwerty, extended Backslash + + + + + + + es + <_shortDescription>Esp + <_description>Spain + + spa + + + + + + nodeadkeys + <_description>Spain - Eliminate dead keys + + + + + deadtilde + <_description>Spain - Include dead tilde + + + + + sundeadkeys + <_description>Spain - Sun dead keys + + + + + dvorak + <_description>Spain - Dvorak + + + + + ast + <_description>Spain - Asturian variant with bottom-dot H and bottom-dot L + + ast + + + + + + cat + <_description>Spain - Catalan variant with middle-dot L + + cat + + + + + + mac + <_description>Spain - Macintosh + + + + + + + se + <_shortDescription>Swe + <_description>Sweden + + swe + + + + + + nodeadkeys + <_description>Sweden - Eliminate dead keys + + + + + dvorak + <_description>Sweden - Dvorak + + + + + rus + <_description>Sweden - Russian phonetic + + rus + + + + + + rus_nodeadkeys + <_description>Sweden - Russian phonetic, eliminate dead keys + + rus + + + + + + smi + <_description>Sweden - Northern Saami + + sme + + + + + + mac + <_description>Sweden - Macintosh + + + + + svdvorak + <_description>Sweden - Svdvorak + + + + + + + ch + <_shortDescription>Che + <_description>Switzerland + ger + gsw + + + + + legacy + <_description>Switzerland - Legacy + + + + + de_nodeadkeys + <_description>Switzerland - German, eliminate dead keys + + + + + de_sundeadkeys + <_description>Switzerland - German, Sun dead keys + + + + + fr + <_description>Switzerland - French + + fra + + + + + + fr_nodeadkeys + <_description>Switzerland - French, eliminate dead keys + + fra + + + + + + fr_sundeadkeys + <_description>Switzerland - French, Sun dead keys + + fra + + + + + + fr_mac + <_description>Switzerland - French (Macintosh) + + fra + + + + + + de_mac + <_description>Switzerland - German (Macintosh) + + + + + + + sy + <_shortDescription>Syr + <_description>Syria + + syr + + + + + + syc + <_description>Syria - Syriac + + + + + syc_phonetic + <_description>Syria - Syriac phonetic + + + + + ku + <_description>Syria - Kurdish, Latin Q + + kur + + + + + + ku_f + <_description>Syria - Kurdish, (F) + + kur + + + + + + ku_alt + <_description>Syria - Kurdish, Latin Alt-Q + + kur + + + + + + + + tj + <_shortDescription>Tjk + <_description>Tajikistan + + tgk + + + + + + legacy + <_description>Tajikistan - Legacy + + + + + + + lk + <_shortDescription>Lka + <_description>Sri Lanka + + sin + + + + + + tam_unicode + <_description>Sri Lanka - Tamil Unicode + + tam + + + + + + tam_TAB + <_description>Sri Lanka - Tamil TAB Typewriter + + tam + + + + + + + + th + <_shortDescription>Tha + <_description>Thailand + + tha + + + + + + tis + <_description>Thailand - TIS-820.2538 + + + + + pat + <_description>Thailand - Pattachote + + + + + + + tr + <_shortDescription>Tur + <_description>Turkey + + tur + + + + + + f + <_description>Turkey - (F) + + + + + alt + <_description>Turkey - Alt-Q + + + + + sundeadkeys + <_description>Turkey - Sun dead keys + + + + + ku + <_description>Turkey - Kurdish, Latin Q + + kur + + + + + + ku_f + <_description>Turkey - Kurdish, (F) + + kur + + + + + + ku_alt + <_description>Turkey - Kurdish, Latin Alt-Q + + kur + + + + + + intl + <_description>Turkey - International (with dead keys) + + + + + crh + <_description>Turkey - Crimean Tatar (Turkish Q) + + crh + + + + + + crh_f + <_description>Turkey - Crimean Tatar (Turkish F) + + crh + + + + + + crh_alt + <_description>Turkey - Crimean Tatar (Turkish Alt-Q) + + crh + + + + + + + + tw + <_shortDescription>Twn + <_description>Taiwan + + trv + + + + + + indigenous + <_description>Taiwan - Indigenous + + ami + tay + bnn + ckv + pwn + pyu + dru + ais + ssf + tao + tsu + + + + + + saisiyat + <_description>Taiwan - Saisiyat + + xsf + + + + + + + + ua + <_shortDescription>Ukr + <_description>Ukraine + + ukr + + + + + + phonetic + <_description>Ukraine - Phonetic + + + + + typewriter + <_description>Ukraine - Typewriter + + + + + winkeys + <_description>Ukraine - Winkeys + + + + + legacy + <_description>Ukraine - Legacy + + + + + rstu + <_description>Ukraine - Standard RSTU + + + + + rstu_ru + <_description>Ukraine - Standard RSTU on Russian layout + + + + + homophonic + <_description>Ukraine - Homophonic + + + + + crh + <_description>Ukraine - Crimean Tatar (Turkish Q) + + crh + + + + + + crh_f + <_description>Ukraine - Crimean Tatar (Turkish F) + + crh + + + + + + crh_alt + <_description>Ukraine - Crimean Tatar (Turkish Alt-Q) + + crh + + + + + + + + gb + <_shortDescription>GBr + <_description>United Kingdom + + eng + + + + + + extd + <_description>United Kingdom - Extended - Winkeys + + + + + intl + <_description>United Kingdom - International (with dead keys) + + + + + dvorak + <_description>United Kingdom - Dvorak + + + + + dvorakukp + <_description>United Kingdom - Dvorak (UK Punctuation) + + + + + mac + <_description>United Kingdom - Macintosh + + + + + mac_intl + <_description>United Kingdom - Macintosh (International) + + + + + colemak + <_description>United Kingdom - Colemak + + + + + + + uz + <_shortDescription>Uzb + <_description>Uzbekistan + + uzb + + + + + + latin + <_description>Uzbekistan - Latin + + + + + crh + <_description>Uzbekistan - Crimean Tatar (Turkish Q) + + crh + + + + + + crh_f + <_description>Uzbekistan - Crimean Tatar (Turkish F) + + crh + + + + + + crh_alt + <_description>Uzbekistan - Crimean Tatar (Turkish Alt-Q) + + crh + + + + + + + + vn + <_shortDescription>Vnm + <_description>Vietnam + + vie + + + + + + + kr + <_shortDescription>Kor + <_description>Korea, Republic of + + kor + + + + + + kr104 + <_description>Korea, Republic of - 101/104 key Compatible + + + + + + + nec_vndr/jp + <_shortDescription>Jpn + <_description>Japan (PC-98xx Series) + + JP + + + jpn + + + + + + + ie + <_shortDescription>Irl + <_description>Ireland + + eng + + + + + + CloGaelach + <_description>Ireland - CloGaelach + + gla + + + + + + UnicodeExpert + <_description>Ireland - UnicodeExpert + + + + + ogam + <_description>Ireland - Ogham + + + + + ogam_is434 + <_description>Ireland - Ogham IS434 + + + + + + + pk + <_shortDescription>Pak + <_description>Pakistan + + urd + + + + + + urd-crulp + <_description>Pakistan - CRULP + + urd + + + + + + urd-nla + <_description>Pakistan - NLA + + urd + + + + + + ara + <_description>Pakistan - Arabic + + ara + + + + + + snd + <_description>Pakistan - Sindhi + + sd + + + + + + + + mv + <_shortDescription>Mdv + <_description>Maldives + + div + + + + + + + za + <_shortDescription>Zaf + <_description>South Africa + + eng + + + + + + epo + <_shortDescription>Epo + <_description>Esperanto + + epo + + + + + + legacy + <_description>Esperanto - displaced semicolon and quote (obsolete) + + + + + + + np + <_shortDescription>Npl + <_description>Nepal + + nep + + + + + + ng + <_shortDescription>Nga + <_description>Nigeria + + eng + + + + + + igbo + <_description>Nigeria - Igbo + + ibo + + + + + + yoruba + <_description>Nigeria - Yoruba + + yor + + + + + + hausa + <_description>Nigeria - Hausa + + hau + + + + + + + + et + <_shortDescription>Eth + <_description>Ethiopia + + amh + + + + + + + sn + <_shortDescription>Sen + <_description>Senegal + + wol + + + + + + + brai + <_shortDescription>Brl + <_description>Braille + + + + + left_hand + <_description>Braille - Left hand + + + + + right_hand + <_description>Braille - Right hand + + + + + + + tm + <_shortDescription>Tkm + <_description>Turkmenistan + + tuk + + + + + + alt + <_description>Turkmenistan - Alt-Q + + + + + + + ml + <_shortDescription>Mli + <_description>Mali + + bam + + + + + + fr-oss + <_description>Mali - Français (France Alternative) + + + + + us-mac + <_description>Mali - English (USA Macintosh) + + + + + us-intl + <_description>Mali - English (USA International) + + + + + + + tz + <_shortDescription>Tza + <_description>Tanzania + + swa + + + + + + ke + <_shortDescription>Ken + <_description>Kenya + + swa + + + + + + kik + <_description>Kenya - Kikuyu + + kik + + + + + + + + bw + <_shortDescription>Bwa + <_description>Botswana + + tsn + + + + + + ph + <_shortDescription>Phi + <_description>Philippines + eng + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + qwerty-bay + <_description>Philippines - QWERTY (Baybayin) + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + capewell-dvorak + <_description>Philippines - Capewell-Dvorak (Latin) + + + + + capewell-dvorak-bay + <_description>Philippines - Capewell-Dvorak (Baybayin) + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + capewell-qwerf2k6 + <_description>Philippines - Capewell-QWERF 2006 (Latin) + + + + + capewell-qwerf2k6-bay + <_description>Philippines - Capewell-QWERF 2006 (Baybayin) + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + colemak + <_description>Philippines - Colemak (Latin) + + + + + colemak-bay + <_description>Philippines - Colemak (Baybayin) + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + dvorak + <_description>Philippines - Dvorak (Latin) + + + + + dvorak-bay + <_description>Philippines - Dvorak (Baybayin) + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + + + + + + grp + <_description>Key(s) to change layout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + lv3 + <_description>Key to choose 3rd level + + + + + + + + + + + + + + + + + + + + + + + ctrl + <_description>Ctrl key position + + + + + + + + + + + + + grp_led + <_description>Use keyboard LED to show alternative layout + + + + + + + + + keypad + <_description>Numeric keypad layout selection + + + + + + + + + + + + + + + kpdl + <_description>Numeric keypad delete key behaviour + + + + + + + + + + + + + + caps + <_description>Caps Lock key behavior + + + + + + + + + + + + + + + + + + + + altwin + <_description>Alt/Win key behavior + + + + + + + + + + + + + + + Compose key + <_description>Compose key position + + + + + + + + + + + + + + + + compat + <_description>Miscellaneous compatibility options + + + + + + + + + + + + + + + + + + eurosign + <_description>Adding currency signs to certain keys + + + + + + + + + + lv5 + <_description>Key to choose 5th level + + + + + + + + + + + + + + + + nbsp + <_description>Using space key to input non-breakable space character + + + + + + + + + + + + + + + + + + + + + japan + <_description>Japanese keyboard options + + + + + + + esperanto + <_description>Adding Esperanto circumflexes (supersigno) + + + + + + + terminate + <_description>Key sequence to kill the X server + + + + + diff --git a/xorg-server/xkeyboard-config/symbols/in b/xorg-server/xkeyboard-config/symbols/in index cb38a84c0..75447148e 100644 --- a/xorg-server/xkeyboard-config/symbols/in +++ b/xorg-server/xkeyboard-config/symbols/in @@ -1351,7 +1351,7 @@ xkb_symbols "eng" { partial alphanumeric_keys xkb_symbols "mal_enhanced" { - name[Group1] = "India - Malayalam Modified Inscript with Rupee Sign"; + name[Group1] = "India - Malayalam enhanced Inscript with Rupee Sign"; //From grave to backslash (\) diff --git a/xorg-server/xkeyboard-config/symbols/lk b/xorg-server/xkeyboard-config/symbols/lk index 8480607de..928781d05 100644 --- a/xorg-server/xkeyboard-config/symbols/lk +++ b/xorg-server/xkeyboard-config/symbols/lk @@ -1,90 +1,91 @@ -// X Keyboard Extension file for Sinhala (Sri Lanka) (2004-04-22) -// Maintainer : Harshula Jayasuriya -// Last Updated: 2007-06-29 -// This is a static phonetic mapping for a standard US-English keyboard -// (qwerty) -// http://www.nongnu.org/sinhala/doc/keymaps/sinhala-keyboard_3.html - -// Repaya, Rakaransaya and Yansaya aren't inserted with A-r, R and Y, -// respectively. The problem lies with the XKB infrastructure which -// only allows a one-to-one mapping of keycodes to Unicode codepoints. -// Unfortunately, the 3 mentioned glyphs actually consists of 3 -// Unicode codepoints each. The result is that the user must -// manually construct the glyph by typing each of the 3 codepoints. -// ALT-, represents the 'JOIN' key, it requires -// two codepoints, hence it also has to be manually constructed. -// Similarly, ALT-/ representing the 'TOUCH' key requires -// two codepoints. - -// Repaya = rayanna,AL,ZWJ -// Rakaransaya = AL,ZWJ,rayanna -// Yansaya = AL,ZWJ,yayanna -// JOIN = AL,ZWJ -// TOUCH = ZWJ,AL - -// Where, -// AL = Al Lakuna = ALT-a -// ZWJ = Zero Width Joiner = ALT-/ -// rayanna = r -// yayanna = y - -partial default alphanumeric_keys -xkb_symbols "sin_phonetic" { - - include "us" -// it is default - no details in the name - name[Group1] = "Sri Lanka"; - key.type[Group1] = "FOUR_LEVEL"; - - // q - p - key { [ 0x01000d8d, 0x01000d8e, 0x01000dd8, 0x01000df2 ] }; - key { [ 0x01000d87, 0x01000d88, 0x01000dd0, 0x01000dd1 ] }; - key { [ 0x01000d91, 0x01000d92, 0x01000dd9, 0x01000dda ] }; - key { [ 0x01000dbb, 0x01000dca, 0x01000dbb, NoSymbol ] }; - key { [ 0x01000dad, 0x01000dae, 0x01000da7, 0x01000da8 ] }; - key { [ 0x01000dba, 0x01000dca, NoSymbol, NoSymbol ] }; - key { [ 0x01000d8b, 0x01000d8c, 0x01000dd4, 0x01000dd6 ] }; - key { [ 0x01000d89, 0x01000d8a, 0x01000dd2, 0x01000dd3 ] }; - key { [ 0x01000d94, 0x01000d95, 0x01000ddc, 0x01000ddd ] }; - key { [ 0x01000db4, 0x01000db5, NoSymbol, NoSymbol ] }; - - // a - l - key { [ 0x01000d85, 0x01000d86, 0x01000dca, 0x01000dcf ] }; - key { [ 0x01000dc3, 0x01000dc1, 0x01000dc2, NoSymbol ] }; - key { [ 0x01000daf, 0x01000db0, 0x01000da9, 0x01000daa ] }; - key { [ 0x01000dc6, NoSymbol, 0x01000ddb, 0x01000d93 ] }; - key { [ 0x01000d9c, 0x01000d9d, 0x01000d9f, NoSymbol ] }; - key { [ 0x01000dc4, 0x01000d83, 0x01000dde, 0x01000d96 ] }; - key { [ 0x01000da2, 0x01000da3, 0x01000da6, NoSymbol ] }; - key { [ 0x01000d9a, 0x01000d9b, 0x01000d8f, 0x01000d90 ] }; - key { [ 0x01000dbd, 0x01000dc5, 0x01000ddf, 0x01000df3 ] }; - - // z - ? - key { [ 0x01000da4, 0x01000da5, NoSymbol, NoSymbol ] }; - key { [ 0x01000db3, 0x01000dac, NoSymbol, NoSymbol ] }; - key { [ 0x01000da0, 0x01000da1, NoSymbol, NoSymbol ] }; - key { [ 0x01000dc0, NoSymbol, NoSymbol, NoSymbol ] }; - key { [ 0x01000db6, 0x01000db7, NoSymbol, NoSymbol ] }; - key { [ 0x01000db1, 0x01000dab, 0x01000d82, 0x01000d9e ] }; - key { [ 0x01000db8, 0x01000db9, NoSymbol, NoSymbol ] }; - key { [ any, any, 0x01000dca, NoSymbol ] }; - key { [ any, any, 0x01000df4, NoSymbol ] }; - key { [ any, any, 0x0100200d, NoSymbol ] }; - - // Space - include "nbsp(zwnj2nb3s)" - - include "level3(ralt_switch)" -}; - -partial alphanumeric_keys -xkb_symbols "tam_unicode" { - include "in(tam_unicode)" - name[Group1]= "Sri Lanka - Tamil Unicode"; -}; - -partial alphanumeric_keys -xkb_symbols "tam_TAB" { - include "in(tam_TAB)" - name[Group1]= "Sri Lanka - Tamil TAB Typewriter"; -}; +// X Keyboard Extension file for Sinhala (Sri Lanka) (2004-04-22) +// Maintainer : Harshula Jayasuriya +// Last Updated: 2011-03-20 +// This is a phonetic static mapping for a standard US-English keyboard +// (qwerty) +// http://www.nongnu.org/sinhala/doc/keymaps/sinhala-keyboard_3.html + +// Repaya, Rakaransaya and Yansaya aren't inserted with A-r, R and Y, +// respectively. The problem lies with the XKB infrastructure which +// only allows a one-to-one mapping of keycodes to Unicode codepoints. +// Unfortunately, the 3 mentioned glyphs actually consists of 3 +// Unicode codepoints each. The result is that the user must +// manually construct the glyph by typing each of the 3 codepoints. +// ALT-, represents the 'JOIN' key, it requires +// two codepoints, hence it also has to be manually constructed. +// Similarly, ALT-/ representing the 'TOUCH' key requires +// two codepoints. + +// Repaya = rayanna,AL,ZWJ +// Rakaransaya = AL,ZWJ,rayanna +// Yansaya = AL,ZWJ,yayanna +// JOIN = AL,ZWJ +// TOUCH = ZWJ,AL + +// Where, +// AL = Al Lakuna = ALT-a +// ZWJ = Zero Width Joiner = ALT-/ +// rayanna = r +// yayanna = y + +partial default alphanumeric_keys +xkb_symbols "sin_phonetic" { + + include "us" +// it is default - no details in the name + name[Group1] = "Sri Lanka"; + key.type[Group1] = "FOUR_LEVEL"; + + // q - p + key { [ Sinh_ri, Sinh_rii, Sinh_ru2, Sinh_ruu2 ] }; + key { [ Sinh_ae, Sinh_aee, Sinh_ae2, Sinh_aee2 ] }; + key { [ Sinh_e, Sinh_ee, Sinh_e2, Sinh_ee2 ] }; + key { [ Sinh_ra, Sinh_al, Sinh_ra, NoSymbol ] }; + key { [ Sinh_tha, Sinh_thha, Sinh_tta, Sinh_ttha ] }; + key { [ Sinh_ya, Sinh_al, NoSymbol, NoSymbol ] }; + key { [ Sinh_u, Sinh_uu, Sinh_u2, Sinh_uu2 ] }; + key { [ Sinh_i, Sinh_ii, Sinh_i2, Sinh_ii2 ] }; + key { [ Sinh_o, Sinh_oo, Sinh_o2, Sinh_oo2 ] }; + key { [ Sinh_pa, Sinh_pha, NoSymbol, NoSymbol ] }; + + // a - l + key { [ Sinh_a, Sinh_aa, Sinh_al, Sinh_aa2 ] }; + key { [ Sinh_sa, Sinh_sha, Sinh_ssha, NoSymbol ] }; + key { [ Sinh_dha, Sinh_dhha, Sinh_dda, Sinh_ddha ] }; + key { [ Sinh_fa, NoSymbol, Sinh_ai2, Sinh_ai ] }; + key { [ Sinh_ga, Sinh_gha, Sinh_nga, NoSymbol ] }; + key { [ Sinh_ha, Sinh_h2, Sinh_au2, Sinh_au ] }; + key { [ Sinh_ja, Sinh_jha, Sinh_nja, NoSymbol ] }; + key { [ Sinh_ka, Sinh_kha, Sinh_lu, Sinh_luu ] }; + key { [ Sinh_la, Sinh_lla, Sinh_lu2, Sinh_luu2 ] }; + + // z - ? + key { [ Sinh_nya, Sinh_jnya, NoSymbol, NoSymbol ] }; + key { [ Sinh_ndha, Sinh_ndda, NoSymbol, NoSymbol ] }; + key { [ Sinh_ca, Sinh_cha, NoSymbol, NoSymbol ] }; + key { [ Sinh_va, NoSymbol, NoSymbol, NoSymbol ] }; + key { [ Sinh_ba, Sinh_bha, NoSymbol, NoSymbol ] }; + key { [ Sinh_na, Sinh_nna, Sinh_ng, Sinh_ng2 ] }; + key { [ Sinh_ma, Sinh_mba, NoSymbol, NoSymbol ] }; + key { [ any, any, Sinh_al, NoSymbol ] }; + key { [ any, any, Sinh_kunddaliya, NoSymbol ] }; + key { [ any, any, 0x100200d, NoSymbol ] }; + + // Space + include "nbsp(nb2zwnj3s)" + + include "level3(ralt_switch)" +}; + +partial alphanumeric_keys +xkb_symbols "tam_unicode" { + include "in(tam_unicode)" + name[Group1]= "Sri Lanka - Tamil Unicode"; +}; + +partial alphanumeric_keys +xkb_symbols "tam_TAB" { + include "in(tam_TAB)" + name[Group1]= "Sri Lanka - Tamil TAB Typewriter"; +}; + diff --git a/xorg-server/xkeyboard-config/symbols/lt b/xorg-server/xkeyboard-config/symbols/lt index 5a19dc265..c19629f9d 100644 --- a/xorg-server/xkeyboard-config/symbols/lt +++ b/xorg-server/xkeyboard-config/symbols/lt @@ -1,296 +1,318 @@ -// Separate keymaps merged into one file by Nerijus Baliūnas, 2002 - -// Lithuanian Numeric layout - Lithuanian letters on the numeric row -// based on Lithuanian keyboard map by Ričardas Čepas -// 3rd and 4th levels added by Mantas Kriaučiūnas , 2004 -// Minor modifications and cleanup by Rimas Kudelis , 2010 -// -// If you want two layouts, use: -// Option "XkbLayout" "lt,lt(us)" -partial default alphanumeric_keys modifier_keys -xkb_symbols "basic" { - - include "latin" - include "eurosign(e)" - include "level3(ralt_switch)" - - name[Group1]="Lithuania"; - - key {[ grave, asciitilde, acute ]}; - key {[ aogonek, Aogonek, 1, exclam ]}; - key {[ ccaron, Ccaron, 2, at ]}; - key {[ eogonek, Eogonek, 3, numbersign ]}; - key {[ eabovedot, Eabovedot, 4, dollar ]}; - key {[ iogonek, Iogonek, 5, percent ]}; - key {[ scaron, Scaron, 6, asciicircum ]}; - key {[ uogonek, Uogonek, 7, ampersand ]}; - key {[ umacron, Umacron, 8, asterisk ]}; - key {[ doublelowquotemark, parenleft, 9, parenleft ]}; - key {[ leftdoublequotemark, parenright, 0, parenright ]}; - key {[ minus, underscore, endash ]}; - key {[ zcaron, Zcaron, equal, plus ]}; - - key {[ endash, EuroSign ]}; -}; - -// Similar to the above, but uses 3rd and 4th levels in the numeric row -// for Lithuanian letters -partial alphanumeric_keys modifier_keys -xkb_symbols "us" { - - include "latin" - include "eurosign(e)" - include "level3(ralt_switch)" - - name[Group1]="Lithuania - US keyboard with Lithuanian letters"; - - key {[ grave, asciitilde, acute ]}; - key {[ 1, exclam, aogonek, Aogonek ]}; - key {[ 2, at, ccaron, Ccaron ]}; - key {[ 3, numbersign, eogonek, Eogonek ]}; - key {[ 4, dollar, eabovedot, Eabovedot ]}; - key {[ 5, percent, iogonek, Iogonek ]}; - key {[ 6, asciicircum, scaron, Scaron ]}; - key {[ 7, ampersand, uogonek, Uogonek ]}; - key {[ 8, asterisk, umacron, Umacron ]}; - key {[ 9, parenleft, doublelowquotemark, parenleft ]}; - key {[ 0, parenright, leftdoublequotemark, parenright ]}; - key {[ minus, underscore, endash ]}; - key {[ equal, plus, zcaron, Zcaron ]}; - - key {[ endash, EuroSign ]}; -}; - -// Lithuanian keymap LST 1582:2000 -// The standard is described at http://ims.mii.lt/klav/ -// Extensions: B01 L3 is "<" , B02 L3 is ">" and B03 L3 is endash to make this -// layout usable with pc101 and pc104 keyboards. -// -// Made by Gediminas Paulauskas -// Minor modifications by Ričardas Čepas and Rimas Kudelis - -partial alphanumeric_keys modifier_keys -xkb_symbols "std" { - - include "latin" - include "eurosign(e)" - include "nbsp(level3)" - include "kpdl(comma)" - include "level3(ralt_switch)" - - name[Group1]="Lithuania - Standard"; - - key {[ grave, asciitilde, acute ]}; - key {[ exclam, 1, at ]}; - key {[ minus, 2, underscore ]}; - key {[ slash, 3, numbersign ]}; - key {[ semicolon, 4, dollar ]}; - key {[ colon, 5, section ]}; - key {[ comma, 6, asciicircum ]}; - key {[ period, 7, ampersand ]}; - key {[ equal, 8, asterisk ]}; - key {[ parenleft, 9, bracketleft ]}; - key {[ parenright, 0, bracketright ]}; - key {[ question, plus, apostrophe ]}; - key {[ x, X, percent ]}; - - key {[ aogonek, Aogonek ]}; - key {[ zcaron, Zcaron ]}; - key {[ iogonek, Iogonek, braceleft ]}; - key {[ w, W, braceright ]}; - - key {[ scaron, Scaron ]}; - key {[ uogonek, Uogonek ]}; - key {[ eabovedot, Eabovedot, quotedbl ]}; - key {[ q, Q, bar ]}; - - key {[ less, greater, endash ]}; - key {[ z, Z, less ]}; - key {[ umacron, Umacron, greater ]}; - key {[ c, C, endash ]}; - key {[ ccaron, Ccaron, doublelowquotemark ]}; - key {[ f, F, leftdoublequotemark ]}; - key {[ eogonek, Eogonek, backslash ]}; -}; - -// Lithuanian keymap LST 1205-92 -// This standard was made deprecated by LST 1582:2000 above. -// This keyboard is also know as IBM layout. -// We follow the map shown at: http://www.registrucentras.lt/litwin/kbdlta.gif -// and info from Edis Tamošauskas -// -// Made by Piter PUNK -// Minor modifications and cleanup by Rimas Kudelis, 2010 - -partial alphanumeric_keys modifier_keys -xkb_symbols "ibm" { - - include "latin" - include "eurosign(e)" - include "nbsp(level3)" - include "level3(ralt_switch)" - - name[Group1]="Lithuania - IBM (LST 1205-92)"; - - key {[ grave, asciitilde, acute ]}; - key {[ exclam, 1 ]}; - key {[ quotedbl, 2, at ]}; - key {[ slash, 3, numbersign ]}; - key {[ semicolon, 4, dollar ]}; - key {[ colon, 5, percent ]}; - key {[ comma, 6, asciicircum ]}; - key {[ period, 7, ampersand ]}; - key {[ question, 8, asterisk ]}; - key {[ parenleft, 9 ]}; - key {[ parenright, 0 ]}; - key {[ underscore, minus, endash ]}; - key {[ plus, equal ]}; - - key {[ aogonek, Aogonek, q, Q ]}; - key {[ zcaron, Zcaron, w, W ]}; - key {[ iogonek, Iogonek, bracketleft, braceleft ]}; - key {[ doublelowquotemark, leftdoublequotemark, bracketright, braceright ]}; - - key {[ uogonek, Uogonek, semicolon, colon ]}; - key {[ eabovedot, Eabovedot, apostrophe, quotedbl ]}; - - key {[ less, greater, endash ]}; - key {[ umacron, Umacron, x, X ]}; - key {[ ccaron, Ccaron, comma, less ]}; - key {[ scaron, Scaron, period, greater ]}; - key {[ eogonek, Eogonek, slash, question ]}; -}; - -// LEKP and LEKPa layouts 1.0 -// Copyright (c) 2007 Tautrimas Pajarskas -// For more info visit http://lekp.info -// -// LEKP and LEKPa layouts are licensed under the Creative Commons -// Attribution-Noncommercial-Share Alike 3.0 License. -// To view a copy of this license, visit -// http://creativecommons.org/licenses/by-nc-sa/3.0/ or send -// a letter to Creative Commons, 171 Second Street, Suite 300, -// San Francisco, California, 94105, USA. -// -// Minor cleanup by Rimas Kudelis, 2010 - -partial alphanumeric_keys modifier_keys -xkb_symbols "lekp" { - - include "capslock(backspace)" - include "level3(ralt_switch)" - - name[Group1]="Lithuania - LEKP"; - - key {[ grave, asciitilde, acute ]}; - key {[ slash, numbersign, bar ]}; - key {[ backslash, at, section ]}; - key {[ period, braceleft ]}; - key {[ comma, braceright ]}; - key {[ f, F ]}; - key {[ exclam, endash ]}; - key {[ w, W ]}; - key {[ uogonek, Uogonek ]}; - key {[ iogonek, Iogonek ]}; - key {[ parenleft, doublelowquotemark, registered ]}; - key {[ parenright, leftdoublequotemark, copyright ]}; - key {[ colon, ampersand, trademark ]}; - - key {[ q, Q, EuroSign ]}; - key {[ g, G, 7 ]}; - key {[ r, R, 8 ]}; - key {[ l, L, 9 ]}; - key {[ d, D, percent ]}; - key {[ ccaron, Ccaron ]}; - key {[ j, J ]}; - key {[ u, U, period ]}; - key {[ eabovedot, Eabovedot, minus ]}; - key {[ eogonek, Eogonek, slash ]}; - key {[ question, bracketleft, division ]}; - key {[ equal, bracketright ]}; - - key {[ a, A, 0 ]}; - key {[ k, K, 4 ]}; - key {[ s, S, 5 ]}; - key {[ t, T, 6 ]}; - key {[ m, M, dollar ]}; - key {[ p, P ]}; - key {[ n, N ]}; - key {[ e, E, comma ]}; - key {[ i, I, plus ]}; - key {[ o, O, asterisk ]}; - key {[ y, Y, multiply ]}; - key {[ apostrophe, underscore ]}; - - key {[ semicolon, quotedbl, sterling ]}; - key {[ z, Z, asciicircum ]}; - key {[ x, X, 1 ]}; - key {[ c, C, 2 ]}; - key {[ v, V, 3 ]}; - key {[ zcaron, Zcaron ]}; - key {[ scaron, Scaron ]}; - key {[ b, B, degree ]}; - key {[ umacron, Umacron, less ]}; - key {[ aogonek, Aogonek, greater ]}; - key {[ h, H ]}; -}; - -partial alphanumeric_keys modifier_keys -xkb_symbols "lekpa" { - - include "capslock(backspace)" - include "level3(ralt_switch)" - - name[Group1]="Lithuania - LEKPa"; - - key {[ grave, asciitilde, acute ]}; - key {[ slash, quotedbl, bar ]}; - key {[ backslash, at, section ]}; - key {[ period, braceleft, numbersign ]}; - key {[ comma, braceright, sterling ]}; - key {[ f, F, ampersand ]}; - key {[ exclam, endash ]}; - key {[ w, W ]}; - key {[ uogonek, Uogonek ]}; - key {[ iogonek, Iogonek ]}; - key {[ parenleft, doublelowquotemark, registered ]}; - key {[ parenright, leftdoublequotemark, copyright ]}; - key {[ colon, semicolon, trademark ]}; - - key {[ q, Q, EuroSign ]}; - key {[ g, G, 7 ]}; - key {[ r, R, 8 ]}; - key {[ l, L, 9 ]}; - key {[ d, D, percent ]}; - key {[ ccaron, Ccaron ]}; - key {[ j, J ]}; - key {[ u, U, period ]}; - key {[ eabovedot, Eabovedot, minus ]}; - key {[ eogonek, Eogonek, slash ]}; - key {[ question, bracketleft, division ]}; - key {[ equal, bracketright ]}; - - key {[ a, A, 0 ]}; - key {[ k, K, 4 ]}; - key {[ s, S, 5 ]}; - key {[ t, T, 6 ]}; - key {[ m, M, dollar ]}; - key {[ p, P ]}; - key {[ n, N ]}; - key {[ e, E, comma ]}; - key {[ i, I, plus ]}; - key {[ o, O, asterisk ]}; - key {[ y, Y, multiply ]}; - key {[ apostrophe, underscore ]}; - - key {[ z, Z, asciicircum ]}; - key {[ x, X, 1 ]}; - key {[ c, C, 2 ]}; - key {[ v, V, 3 ]}; - key {[ zcaron, Zcaron ]}; - key {[ scaron, Scaron ]}; - key {[ b, B, degree ]}; - key {[ umacron, Umacron, less ]}; - key {[ aogonek, Aogonek, greater ]}; - key {[ h, H ]}; -}; +// Separate keymaps merged into one file by Nerijus Baliūnas, 2002 + +// Lithuanian Numeric layout - Lithuanian letters on the numeric row +// based on Lithuanian keyboard map by Ričardas Čepas +// 3rd and 4th levels added by Mantas Kriaučiūnas , 2004 +// Minor modifications and cleanup by Rimas Kudelis , 2010 +// +// If you want two layouts, use: +// Option "XkbLayout" "lt,lt(us)" +partial default alphanumeric_keys modifier_keys +xkb_symbols "basic" { + + include "latin" + include "eurosign(e)" + include "level3(ralt_switch)" + + name[Group1]="Lithuania"; + + key {[ grave, asciitilde, acute ]}; + key {[ aogonek, Aogonek, 1, exclam ]}; + key {[ ccaron, Ccaron, 2, at ]}; + key {[ eogonek, Eogonek, 3, numbersign ]}; + key {[ eabovedot, Eabovedot, 4, dollar ]}; + key {[ iogonek, Iogonek, 5, percent ]}; + key {[ scaron, Scaron, 6, asciicircum ]}; + key {[ uogonek, Uogonek, 7, ampersand ]}; + key {[ umacron, Umacron, 8, asterisk ]}; + key {[ doublelowquotemark, parenleft, 9, parenleft ]}; + key {[ leftdoublequotemark, parenright, 0, parenright ]}; + key {[ minus, underscore, endash ]}; + key {[ zcaron, Zcaron, equal, plus ]}; + + key {[ endash, EuroSign ]}; +}; + +// Similar to the above, but uses 3rd and 4th levels in the numeric row +// for Lithuanian letters +partial alphanumeric_keys modifier_keys +xkb_symbols "us" { + + include "latin" + include "eurosign(e)" + include "level3(ralt_switch)" + + name[Group1]="Lithuania - US keyboard with Lithuanian letters"; + + key {[ grave, asciitilde, acute ]}; + key {[ 1, exclam, aogonek, Aogonek ]}; + key {[ 2, at, ccaron, Ccaron ]}; + key {[ 3, numbersign, eogonek, Eogonek ]}; + key {[ 4, dollar, eabovedot, Eabovedot ]}; + key {[ 5, percent, iogonek, Iogonek ]}; + key {[ 6, asciicircum, scaron, Scaron ]}; + key {[ 7, ampersand, uogonek, Uogonek ]}; + key {[ 8, asterisk, umacron, Umacron ]}; + key {[ 9, parenleft, doublelowquotemark, parenleft ]}; + key {[ 0, parenright, leftdoublequotemark, parenright ]}; + key {[ minus, underscore, endash ]}; + key {[ equal, plus, zcaron, Zcaron ]}; + + key {[ endash, EuroSign ]}; +}; + +// Lithuanian keymap LST 1582:2000 +// The standard is described at http://ims.mii.lt/klav/ +// Extensions: B01 L3 is "<" , B02 L3 is ">" and B03 L3 is endash to make this +// layout usable with pc101 and pc104 keyboards. +// +// Made by Gediminas Paulauskas +// Minor modifications by Ričardas Čepas and Rimas Kudelis + +partial alphanumeric_keys modifier_keys +xkb_symbols "std" { + + include "latin" + include "eurosign(e)" + include "nbsp(level3)" + include "kpdl(comma)" + include "level3(ralt_switch)" + + name[Group1]="Lithuania - Standard"; + + key {[ grave, asciitilde, acute ]}; + key {[ exclam, 1, at ]}; + key {[ minus, 2, underscore ]}; + key {[ slash, 3, numbersign ]}; + key {[ semicolon, 4, dollar ]}; + key {[ colon, 5, section ]}; + key {[ comma, 6, asciicircum ]}; + key {[ period, 7, ampersand ]}; + key {[ equal, 8, asterisk ]}; + key {[ parenleft, 9, bracketleft ]}; + key {[ parenright, 0, bracketright ]}; + key {[ question, plus, apostrophe ]}; + key {[ x, X, percent ]}; + + key {[ aogonek, Aogonek ]}; + key {[ zcaron, Zcaron ]}; + key {[ iogonek, Iogonek, braceleft ]}; + key {[ w, W, braceright ]}; + + key {[ scaron, Scaron ]}; + key {[ uogonek, Uogonek ]}; + key {[ eabovedot, Eabovedot, quotedbl ]}; + key {[ q, Q, bar ]}; + + key {[ less, greater, endash ]}; + key {[ z, Z, less ]}; + key {[ umacron, Umacron, greater ]}; + key {[ c, C, endash ]}; + key {[ ccaron, Ccaron, doublelowquotemark ]}; + key {[ f, F, leftdoublequotemark ]}; + key {[ eogonek, Eogonek, backslash ]}; +}; + +// Lithuanian keymap LST 1205-92 +// This standard was made deprecated by LST 1582:2000 above. +// This keyboard is also know as IBM layout. +// We follow the map shown at: http://www.registrucentras.lt/litwin/kbdlta.gif +// and info from Edis Tamošauskas +// +// Made by Piter PUNK +// Minor modifications and cleanup by Rimas Kudelis, 2010 + +partial alphanumeric_keys modifier_keys +xkb_symbols "ibm" { + + include "latin" + include "eurosign(e)" + include "nbsp(level3)" + include "level3(ralt_switch)" + + name[Group1]="Lithuania - IBM (LST 1205-92)"; + + key {[ grave, asciitilde, acute ]}; + key {[ exclam, 1 ]}; + key {[ quotedbl, 2, at ]}; + key {[ slash, 3, numbersign ]}; + key {[ semicolon, 4, dollar ]}; + key {[ colon, 5, percent ]}; + key {[ comma, 6, asciicircum ]}; + key {[ period, 7, ampersand ]}; + key {[ question, 8, asterisk ]}; + key {[ parenleft, 9 ]}; + key {[ parenright, 0 ]}; + key {[ underscore, minus, endash ]}; + key {[ plus, equal ]}; + + key {[ aogonek, Aogonek, q, Q ]}; + key {[ zcaron, Zcaron, w, W ]}; + key {[ iogonek, Iogonek, bracketleft, braceleft ]}; + key {[ doublelowquotemark, leftdoublequotemark, bracketright, braceright ]}; + + key {[ uogonek, Uogonek, semicolon, colon ]}; + key {[ eabovedot, Eabovedot, apostrophe, quotedbl ]}; + + key {[ less, greater, endash ]}; + key {[ umacron, Umacron, x, X ]}; + key {[ ccaron, Ccaron, comma, less ]}; + key {[ scaron, Scaron, period, greater ]}; + key {[ eogonek, Eogonek, slash, question ]}; +}; + +// LEKP and LEKPa layouts 1.0 +// Copyright (c) 2007 Tautrimas Pajarskas +// For more info visit http://lekp.info +// +// LEKP and LEKPa layouts are licensed under the Creative Commons +// Attribution-Noncommercial-Share Alike 3.0 License. +// To view a copy of this license, visit +// http://creativecommons.org/licenses/by-nc-sa/3.0/ or send +// a letter to Creative Commons, 171 Second Street, Suite 300, +// San Francisco, California, 94105, USA. +// +// Minor cleanup by Rimas Kudelis, 2010 + +partial alphanumeric_keys modifier_keys +xkb_symbols "lekp" { + + include "capslock(backspace)" + include "level3(ralt_switch)" + + name[Group1]="Lithuania - LEKP"; + + key {[ grave, asciitilde, acute ]}; + key {[ slash, numbersign, bar ]}; + key {[ backslash, at, section ]}; + key {[ period, braceleft ]}; + key {[ comma, braceright ]}; + key {[ f, F ]}; + key {[ exclam, endash ]}; + key {[ w, W ]}; + key {[ uogonek, Uogonek ]}; + key {[ iogonek, Iogonek ]}; + key {[ parenleft, doublelowquotemark, registered ]}; + key {[ parenright, leftdoublequotemark, copyright ]}; + key {[ colon, ampersand, trademark ]}; + + key {[ q, Q, EuroSign ]}; + key {[ g, G, 7 ]}; + key {[ r, R, 8 ]}; + key {[ l, L, 9 ]}; + key {[ d, D, percent ]}; + key {[ ccaron, Ccaron ]}; + key {[ j, J ]}; + key {[ u, U, period ]}; + key {[ eabovedot, Eabovedot, minus ]}; + key {[ eogonek, Eogonek, slash ]}; + key {[ question, bracketleft, division ]}; + key {[ equal, bracketright ]}; + + key {[ a, A, 0 ]}; + key {[ k, K, 4 ]}; + key {[ s, S, 5 ]}; + key {[ t, T, 6 ]}; + key {[ m, M, dollar ]}; + key {[ p, P ]}; + key {[ n, N ]}; + key {[ e, E, comma ]}; + key {[ i, I, plus ]}; + key {[ o, O, asterisk ]}; + key {[ y, Y, multiply ]}; + key {[ apostrophe, underscore ]}; + + key {[ semicolon, quotedbl, sterling ]}; + key {[ z, Z, asciicircum ]}; + key {[ x, X, 1 ]}; + key {[ c, C, 2 ]}; + key {[ v, V, 3 ]}; + key {[ zcaron, Zcaron ]}; + key {[ scaron, Scaron ]}; + key {[ b, B, degree ]}; + key {[ umacron, Umacron, less ]}; + key {[ aogonek, Aogonek, greater ]}; + key {[ h, H ]}; +}; + +partial alphanumeric_keys modifier_keys +xkb_symbols "lekpa" { + + include "capslock(backspace)" + include "level3(ralt_switch)" + + name[Group1]="Lithuania - LEKPa"; + + key {[ grave, asciitilde, acute ]}; + key {[ slash, quotedbl, bar ]}; + key {[ backslash, at, section ]}; + key {[ period, braceleft, numbersign ]}; + key {[ comma, braceright, sterling ]}; + key {[ f, F, ampersand ]}; + key {[ exclam, endash ]}; + key {[ w, W ]}; + key {[ uogonek, Uogonek ]}; + key {[ iogonek, Iogonek ]}; + key {[ parenleft, doublelowquotemark, registered ]}; + key {[ parenright, leftdoublequotemark, copyright ]}; + key {[ colon, semicolon, trademark ]}; + + key {[ q, Q, EuroSign ]}; + key {[ g, G, 7 ]}; + key {[ r, R, 8 ]}; + key {[ l, L, 9 ]}; + key {[ d, D, percent ]}; + key {[ ccaron, Ccaron ]}; + key {[ j, J ]}; + key {[ u, U, period ]}; + key {[ eabovedot, Eabovedot, minus ]}; + key {[ eogonek, Eogonek, slash ]}; + key {[ question, bracketleft, division ]}; + key {[ equal, bracketright ]}; + + key {[ a, A, 0 ]}; + key {[ k, K, 4 ]}; + key {[ s, S, 5 ]}; + key {[ t, T, 6 ]}; + key {[ m, M, dollar ]}; + key {[ p, P ]}; + key {[ n, N ]}; + key {[ e, E, comma ]}; + key {[ i, I, plus ]}; + key {[ o, O, asterisk ]}; + key {[ y, Y, multiply ]}; + key {[ apostrophe, underscore ]}; + + key {[ z, Z, asciicircum ]}; + key {[ x, X, 1 ]}; + key {[ c, C, 2 ]}; + key {[ v, V, 3 ]}; + key {[ zcaron, Zcaron ]}; + key {[ scaron, Scaron ]}; + key {[ b, B, degree ]}; + key {[ umacron, Umacron, less ]}; + key {[ aogonek, Aogonek, greater ]}; + key {[ h, H ]}; +}; + +partial alphanumeric_keys modifier_keys +xkb_symbols "dvorak" { + + include "us(dvorak)" + + name[Group1]="Lithuania - Dvorak"; + + key { [ aogonek, Aogonek, 1, exclam ] }; + key { [ ccaron, Ccaron, 2, at ] }; + key { [ eogonek, Eogonek, 3, numbersign ] }; + key { [ eabovedot, Eabovedot, 4, dollar ] }; + key { [ iogonek, Iogonek, 5, percent ] }; + key { [ scaron, Scaron, 6, asciicircum ] }; + key { [ uogonek, Uogonek, 7, ampersand ] }; + key { [ umacron, Umacron, 8, asterisk ] }; + key { [doublelowquotemark, parenleft, 9, parenleft ] }; + key { [leftdoublequotemark,parenright, 0, parenright ] }; + key { [ zcaron, Zcaron, equal, plus ] }; + + include "level3(ralt_switch)" +}; diff --git a/xorg-server/xkeyboard-config/symbols/nbsp b/xorg-server/xkeyboard-config/symbols/nbsp index 220dae460..77b40df07 100644 --- a/xorg-server/xkeyboard-config/symbols/nbsp +++ b/xorg-server/xkeyboard-config/symbols/nbsp @@ -1,194 +1,204 @@ -// Let Space key provide No-Break Space (NBSP), Narrow No-Break Space (NNBSP), -// Zero-Width Non-Joiner (ZWNJ), and Zero-Width Joiner (ZWJ) for the desired -// levels. - - -//////////////////////////////////////// -// Only Space - -partial -xkb_symbols "none" { - key { - type[Group1]="ONE_LEVEL", - symbols[Group1]= [ space ] - }; -}; - - -//////////////////////////////////////// -// No-Break Space - -partial -xkb_symbols "level2" { - key { - type[Group1]="TWO_LEVEL", - symbols[Group1]= [ space, nobreakspace ] - }; -}; - - -// level3 & level3ns provide no-breaking spaces starting from level3 -// This is good for typographers but experience shows many users accidently -// type no-breaking spaces on the CLI (resulting in errors) -// Used by fr(latin9) and lt(std) -partial -xkb_symbols "level3" { - key { - type[Group1]="FOUR_LEVEL", - symbols[Group1]= [ space, space, nobreakspace ] - }; -}; - -// level3s kills fourth level -// Used by ca(multix) -partial -xkb_symbols "level3s" { - key { - type[Group1]="FOUR_LEVEL", - symbols[Group1]= [ space, space, nobreakspace, NoSymbol ] - }; -}; - -// for this reason pushing no-breaking spaces to level4 is the safe default nowadays -partial -xkb_symbols "level4" { - key { - type[Group1]="FOUR_LEVEL", - symbols[Group1]= [ space, space, space, nobreakspace ] - }; -}; - - -//////////////////////////////////////// -// Narrow No-Break Space - -// level3n provides narrow no-breaking space in addition to the normal one -partial -xkb_symbols "level3n" { - key { - type[Group1]="FOUR_LEVEL", - symbols[Group1]= [ space, space, nobreakspace, 0x100202F ] - }; -}; - -// level4n provides narrow no-breaking space in addition to the normal one -partial -xkb_symbols "level4n" { - key { - type[Group1]="EIGHT_LEVEL", - symbols[Group1]= [ space, space, space, nobreakspace, space, 0x100202F, NoSymbol, NoSymbol ] - }; -}; - -// level4nl provides narrow no-breaking space in addition to the normal one -// without forcing the use of level5 for mostly four-level layouts -// Used by fr(oss), be(oss)… -partial -xkb_symbols "level4nl" { - key { - type[Group1]="LOCAL_EIGHT_LEVEL", - symbols[Group1]= [ space, space, space, nobreakspace, space, 0x100202F, NoSymbol, NoSymbol ] - }; -}; - - -//////////////////////////////////////// -// Zero-Width Non-Joiner & Zero-Width Joiner -// Author: Behnam Esfahbod - -// ZWNJ and ZWJ are widely used in Persian, Kurdinsh, Pashto, Uzbek and other -// languages that use PersoArabic script. - - -// ZWNJ on level 2 -partial -xkb_symbols "zwnj2" { - key { - type[Group1]="TWO_LEVEL", - symbols[Group1]= [ space, 0x100200c ] - }; -}; - - -// ZWNJ on level 2 -// ZWJ on level 3 -partial -xkb_symbols "zwnj2zwj3" { - key { - type[Group1]="FOUR_LEVEL", - symbols[Group1]= [ space, 0x100200c, 0x100200d ] - }; -}; - - -// ZWNJ on level 2 -// ZWJ on level 3 -// NBSP on level 4 -partial -xkb_symbols "zwnj2zwj3nb4" { - key { - type[Group1]="FOUR_LEVEL", - symbols[Group1]= [ space, 0x100200c, 0x100200d, nobreakspace ] - }; -}; - -// ZWNJ on level 2 -// NBSP on level 3 -// Used by ir(ku_ara), af(basic), af(ps), af(uz), af(olpc-fa), af(olpc-ps), af(olpc-uz) -partial -xkb_symbols "zwnj2nb3" { - key { - type[Group1]="FOUR_LEVEL", - symbols[Group1]= [ space, 0x100200c, nobreakspace ] - }; -}; - - -// ZWNJ on level 2 -// ZWJ on level 3 -// NBSP on level 4 -// Used by lk(sin_phonetic) -partial -xkb_symbols "zwnj2nb3s" { - key { - type[Group1]="FOUR_LEVEL", - symbols[Group1]= [ space, 0x100200c, nobreakspace, NoSymbol ] - }; -}; - - -// ZWNJ on level 2 -// NBSP on level 3 -// ZWJ on level 4 -partial -xkb_symbols "zwnj2nb3zwj4" { - key { - type[Group1]="FOUR_LEVEL", - symbols[Group1]= [ space, 0x100200c, nobreakspace, 0x100200d ] - }; -}; - - -// ZWNJ on level 2 -// NBSP on level 3 -// NNBSP on level 4 -// Used by ir(pes) -partial -xkb_symbols "zwnj2nb3nnb4" { - key { - type[Group1]="FOUR_LEVEL", - symbols[Group1]= [ space, 0x100200c, nobreakspace, 0x100202F ] - }; -}; - - -// ZWNJ on level 3 -// ZWJ on level 4 -// Used by in(deva), in(olpc) -partial -xkb_symbols "zwnj3zwj4" { - key { - type[Group1]="FOUR_LEVEL", - symbols[Group1]= [ space, space, 0x100200c, 0x100200d ] - }; -}; +// Let Space key provide No-Break Space (NBSP), Narrow No-Break Space (NNBSP), +// Zero-Width Non-Joiner (ZWNJ), and Zero-Width Joiner (ZWJ) for the desired +// levels. + + +//////////////////////////////////////// +// Only Space + +partial +xkb_symbols "none" { + key { + type[Group1]="ONE_LEVEL", + symbols[Group1]= [ space ] + }; +}; + + +//////////////////////////////////////// +// No-Break Space + +partial +xkb_symbols "level2" { + key { + type[Group1]="TWO_LEVEL", + symbols[Group1]= [ space, nobreakspace ] + }; +}; + + +// level3 & level3ns provide no-breaking spaces starting from level3 +// This is good for typographers but experience shows many users accidently +// type no-breaking spaces on the CLI (resulting in errors) +// Used by fr(latin9) and lt(std) +partial +xkb_symbols "level3" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, space, nobreakspace ] + }; +}; + +// level3s kills fourth level +// Used by ca(multix) +partial +xkb_symbols "level3s" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, space, nobreakspace, NoSymbol ] + }; +}; + +// for this reason pushing no-breaking spaces to level4 is the safe default nowadays +partial +xkb_symbols "level4" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, space, space, nobreakspace ] + }; +}; + + +//////////////////////////////////////// +// Narrow No-Break Space + +// level3n provides narrow no-breaking space in addition to the normal one +partial +xkb_symbols "level3n" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, space, nobreakspace, 0x100202F ] + }; +}; + +// level4n provides narrow no-breaking space in addition to the normal one +partial +xkb_symbols "level4n" { + key { + type[Group1]="EIGHT_LEVEL", + symbols[Group1]= [ space, space, space, nobreakspace, space, 0x100202F, NoSymbol, NoSymbol ] + }; +}; + +// level4nl provides narrow no-breaking space in addition to the normal one +// without forcing the use of level5 for mostly four-level layouts +// Used by fr(oss), be(oss)… +partial +xkb_symbols "level4nl" { + key { + type[Group1]="LOCAL_EIGHT_LEVEL", + symbols[Group1]= [ space, space, space, nobreakspace, space, 0x100202F, NoSymbol, NoSymbol ] + }; +}; + + +//////////////////////////////////////// +// Zero-Width Non-Joiner & Zero-Width Joiner +// Author: Behnam Esfahbod + +// ZWNJ and ZWJ are widely used in Persian, Kurdinsh, Pashto, Uzbek and other +// languages that use PersoArabic script. + + +// ZWNJ on level 2 +partial +xkb_symbols "zwnj2" { + key { + type[Group1]="TWO_LEVEL", + symbols[Group1]= [ space, 0x100200c ] + }; +}; + + +// ZWNJ on level 2 +// ZWJ on level 3 +partial +xkb_symbols "zwnj2zwj3" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, 0x100200c, 0x100200d ] + }; +}; + + +// ZWNJ on level 2 +// ZWJ on level 3 +// NBSP on level 4 +partial +xkb_symbols "zwnj2zwj3nb4" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, 0x100200c, 0x100200d, nobreakspace ] + }; +}; + +// ZWNJ on level 2 +// NBSP on level 3 +// Used by ir(ku_ara), af(basic), af(ps), af(uz), af(olpc-fa), af(olpc-ps), af(olpc-uz) +partial +xkb_symbols "zwnj2nb3" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, 0x100200c, nobreakspace ] + }; +}; + + +// ZWNJ on level 2 +// NBSP on level 3 +partial +xkb_symbols "zwnj2nb3s" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, 0x100200c, nobreakspace, NoSymbol ] + }; +}; + + +// ZWNJ on level 2 +// NBSP on level 3 +// ZWJ on level 4 +partial +xkb_symbols "zwnj2nb3zwj4" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, 0x100200c, nobreakspace, 0x100200d ] + }; +}; + + +// ZWNJ on level 2 +// NBSP on level 3 +// NNBSP on level 4 +// Used by ir(pes) +partial +xkb_symbols "zwnj2nb3nnb4" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, 0x100200c, nobreakspace, 0x100202F ] + }; +}; + + +// ZWNJ on level 3 +// ZWJ on level 4 +// Used by in(deva), in(olpc) +partial +xkb_symbols "zwnj3zwj4" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, space, 0x100200c, 0x100200d ] + }; +}; + + +// NBSP on level 2 +// ZWNJ on level 3 +// Used by lk(sin_phonetic) +partial +xkb_symbols "nb2zwnj3s" { + key { + type[Group1]="FOUR_LEVEL", + symbols[Group1]= [ space, nobreakspace, 0x100200c, NoSymbol ] + }; +}; -- cgit v1.2.3