vmwarexinerama.c revision 6df26cac
16df26cacSmrg/*
26df26cacSmrg * Copyright 2006 by VMware, Inc.
36df26cacSmrg *
46df26cacSmrg * Permission is hereby granted, free of charge, to any person obtaining a
56df26cacSmrg * copy of this software and associated documentation files (the "Software"),
66df26cacSmrg * to deal in the Software without restriction, including without limitation
76df26cacSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
86df26cacSmrg * and/or sell copies of the Software, and to permit persons to whom the
96df26cacSmrg * Software is furnished to do so, subject to the following conditions:
106df26cacSmrg *
116df26cacSmrg * The above copyright notice and this permission notice shall be included in
126df26cacSmrg * all copies or substantial portions of the Software.
136df26cacSmrg *
146df26cacSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
156df26cacSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
166df26cacSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
176df26cacSmrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
186df26cacSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
196df26cacSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
206df26cacSmrg * OTHER DEALINGS IN THE SOFTWARE.
216df26cacSmrg *
226df26cacSmrg * Except as contained in this notice, the name of the copyright holder(s)
236df26cacSmrg * and author(s) shall not be used in advertising or otherwise to promote
246df26cacSmrg * the sale, use or other dealings in this Software without prior written
256df26cacSmrg * authorization from the copyright holder(s) and author(s).
266df26cacSmrg */
276df26cacSmrg
286df26cacSmrg/*
296df26cacSmrg * vmwarexinerama.c --
306df26cacSmrg *
316df26cacSmrg *      The implementation of the Xinerama protocol extension.
326df26cacSmrg */
336df26cacSmrg
346df26cacSmrg
356df26cacSmrg#ifdef HAVE_CONFIG_H
366df26cacSmrg#include "config.h"
376df26cacSmrg#endif
386df26cacSmrg
396df26cacSmrg#define NEED_REPLIES
406df26cacSmrg#define NEED_EVENTS
416df26cacSmrg#include "dixstruct.h"
426df26cacSmrg#include "extnsionst.h"
436df26cacSmrg#include <X11/X.h>
446df26cacSmrg#include <X11/extensions/panoramiXproto.h>
456df26cacSmrg
466df26cacSmrg#include "vmware.h"
476df26cacSmrg
486df26cacSmrg
496df26cacSmrg/*
506df26cacSmrg *----------------------------------------------------------------------------
516df26cacSmrg *
526df26cacSmrg * VMwareXineramaQueryVersion --
536df26cacSmrg *
546df26cacSmrg *      Implementation of QueryVersion command handler. Initialises and
556df26cacSmrg *      sends a reply.
566df26cacSmrg *
576df26cacSmrg * Results:
586df26cacSmrg *      Standard response codes.
596df26cacSmrg *
606df26cacSmrg * Side effects:
616df26cacSmrg *      Writes reply to client.
626df26cacSmrg *
636df26cacSmrg *----------------------------------------------------------------------------
646df26cacSmrg */
656df26cacSmrg
666df26cacSmrgstatic int
676df26cacSmrgVMwareXineramaQueryVersion(ClientPtr client)
686df26cacSmrg{
696df26cacSmrg    xPanoramiXQueryVersionReply	  rep;
706df26cacSmrg    register int		  n;
716df26cacSmrg
726df26cacSmrg    REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq);
736df26cacSmrg    rep.type = X_Reply;
746df26cacSmrg    rep.length = 0;
756df26cacSmrg    rep.sequenceNumber = client->sequence;
766df26cacSmrg    rep.majorVersion = 1;
776df26cacSmrg    rep.minorVersion = 0;
786df26cacSmrg    if(client->swapped) {
796df26cacSmrg        swaps(&rep.sequenceNumber, n);
806df26cacSmrg        swapl(&rep.length, n);
816df26cacSmrg        swaps(&rep.majorVersion, n);
826df26cacSmrg        swaps(&rep.minorVersion, n);
836df26cacSmrg    }
846df26cacSmrg    WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *)&rep);
856df26cacSmrg    return (client->noClientException);
866df26cacSmrg}
876df26cacSmrg
886df26cacSmrg
896df26cacSmrg/*
906df26cacSmrg *----------------------------------------------------------------------------
916df26cacSmrg *
926df26cacSmrg * VMwareXineramaGetState --
936df26cacSmrg *
946df26cacSmrg *      Implementation of GetState command handler. Initialises and
956df26cacSmrg *      sends a reply.
966df26cacSmrg *
976df26cacSmrg * Results:
986df26cacSmrg *      Standard response codes.
996df26cacSmrg *
1006df26cacSmrg * Side effects:
1016df26cacSmrg *      Writes reply to client.
1026df26cacSmrg *
1036df26cacSmrg *----------------------------------------------------------------------------
1046df26cacSmrg */
1056df26cacSmrg
1066df26cacSmrgstatic int
1076df26cacSmrgVMwareXineramaGetState(ClientPtr client)
1086df26cacSmrg{
1096df26cacSmrg    REQUEST(xPanoramiXGetStateReq);
1106df26cacSmrg    WindowPtr			pWin;
1116df26cacSmrg    xPanoramiXGetStateReply	rep;
1126df26cacSmrg    register int		n;
1136df26cacSmrg    ExtensionEntry *ext;
1146df26cacSmrg    ScrnInfoPtr pScrn;
1156df26cacSmrg    VMWAREPtr pVMWARE;
1166df26cacSmrg
1176df26cacSmrg    REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
1186df26cacSmrg    pWin = LookupWindow(stuff->window, client);
1196df26cacSmrg    if(!pWin) return BadWindow;
1206df26cacSmrg
1216df26cacSmrg    if (!(ext = CheckExtension(PANORAMIX_PROTOCOL_NAME))) {
1226df26cacSmrg       return BadMatch;
1236df26cacSmrg    }
1246df26cacSmrg    pScrn = ext->extPrivate;
1256df26cacSmrg    pVMWARE = VMWAREPTR(pScrn);
1266df26cacSmrg
1276df26cacSmrg    rep.type = X_Reply;
1286df26cacSmrg    rep.length = 0;
1296df26cacSmrg    rep.sequenceNumber = client->sequence;
1306df26cacSmrg    rep.state = pVMWARE->xinerama;
1316df26cacSmrg    if(client->swapped) {
1326df26cacSmrg       swaps (&rep.sequenceNumber, n);
1336df26cacSmrg       swapl (&rep.length, n);
1346df26cacSmrg       swaps (&rep.state, n);
1356df26cacSmrg    }
1366df26cacSmrg    WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *)&rep);
1376df26cacSmrg    return client->noClientException;
1386df26cacSmrg}
1396df26cacSmrg
1406df26cacSmrg
1416df26cacSmrg/*
1426df26cacSmrg *----------------------------------------------------------------------------
1436df26cacSmrg *
1446df26cacSmrg * VMwareXineramaGetScreenCount --
1456df26cacSmrg *
1466df26cacSmrg *      Implementation of GetScreenCount command handler. Initialises and
1476df26cacSmrg *      sends a reply.
1486df26cacSmrg *
1496df26cacSmrg * Results:
1506df26cacSmrg *      Standard response codes.
1516df26cacSmrg *
1526df26cacSmrg * Side effects:
1536df26cacSmrg *      Writes reply to client.
1546df26cacSmrg *
1556df26cacSmrg *----------------------------------------------------------------------------
1566df26cacSmrg */
1576df26cacSmrg
1586df26cacSmrgstatic int
1596df26cacSmrgVMwareXineramaGetScreenCount(ClientPtr client)
1606df26cacSmrg{
1616df26cacSmrg    REQUEST(xPanoramiXGetScreenCountReq);
1626df26cacSmrg    WindowPtr				pWin;
1636df26cacSmrg    xPanoramiXGetScreenCountReply	rep;
1646df26cacSmrg    register int			n;
1656df26cacSmrg    ExtensionEntry *ext;
1666df26cacSmrg    ScrnInfoPtr pScrn;
1676df26cacSmrg    VMWAREPtr pVMWARE;
1686df26cacSmrg
1696df26cacSmrg    REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
1706df26cacSmrg    pWin = LookupWindow(stuff->window, client);
1716df26cacSmrg    if(!pWin) return BadWindow;
1726df26cacSmrg
1736df26cacSmrg    if (!(ext = CheckExtension(PANORAMIX_PROTOCOL_NAME))) {
1746df26cacSmrg       return BadMatch;
1756df26cacSmrg    }
1766df26cacSmrg    pScrn = ext->extPrivate;
1776df26cacSmrg    pVMWARE = VMWAREPTR(pScrn);
1786df26cacSmrg
1796df26cacSmrg    rep.type = X_Reply;
1806df26cacSmrg    rep.length = 0;
1816df26cacSmrg    rep.sequenceNumber = client->sequence;
1826df26cacSmrg    rep.ScreenCount = pVMWARE->xineramaNumOutputs;
1836df26cacSmrg    if(client->swapped) {
1846df26cacSmrg       swaps(&rep.sequenceNumber, n);
1856df26cacSmrg       swapl(&rep.length, n);
1866df26cacSmrg       swaps(&rep.ScreenCount, n);
1876df26cacSmrg    }
1886df26cacSmrg    WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep);
1896df26cacSmrg    return client->noClientException;
1906df26cacSmrg}
1916df26cacSmrg
1926df26cacSmrg
1936df26cacSmrg/*
1946df26cacSmrg *----------------------------------------------------------------------------
1956df26cacSmrg *
1966df26cacSmrg * VMwareXineramaGetScreenSize --
1976df26cacSmrg *
1986df26cacSmrg *      Implementation of GetScreenSize command handler. Initialises and
1996df26cacSmrg *      sends a reply.
2006df26cacSmrg *
2016df26cacSmrg * Results:
2026df26cacSmrg *      Standard response codes.
2036df26cacSmrg *
2046df26cacSmrg * Side effects:
2056df26cacSmrg *      Writes reply to client.
2066df26cacSmrg *
2076df26cacSmrg *----------------------------------------------------------------------------
2086df26cacSmrg */
2096df26cacSmrg
2106df26cacSmrgstatic int
2116df26cacSmrgVMwareXineramaGetScreenSize(ClientPtr client)
2126df26cacSmrg{
2136df26cacSmrg    REQUEST(xPanoramiXGetScreenSizeReq);
2146df26cacSmrg    WindowPtr				pWin;
2156df26cacSmrg    xPanoramiXGetScreenSizeReply	rep;
2166df26cacSmrg    register int			n;
2176df26cacSmrg    ExtensionEntry *ext;
2186df26cacSmrg    ScrnInfoPtr pScrn;
2196df26cacSmrg    VMWAREPtr pVMWARE;
2206df26cacSmrg
2216df26cacSmrg    REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
2226df26cacSmrg    pWin = LookupWindow (stuff->window, client);
2236df26cacSmrg    if(!pWin)  return BadWindow;
2246df26cacSmrg
2256df26cacSmrg    if (!(ext = CheckExtension(PANORAMIX_PROTOCOL_NAME))) {
2266df26cacSmrg       return BadMatch;
2276df26cacSmrg    }
2286df26cacSmrg    pScrn = ext->extPrivate;
2296df26cacSmrg    pVMWARE = VMWAREPTR(pScrn);
2306df26cacSmrg
2316df26cacSmrg    rep.type = X_Reply;
2326df26cacSmrg    rep.length = 0;
2336df26cacSmrg    rep.sequenceNumber = client->sequence;
2346df26cacSmrg    rep.width  = pVMWARE->xineramaState[stuff->screen].width;
2356df26cacSmrg    rep.height  = pVMWARE->xineramaState[stuff->screen].height;
2366df26cacSmrg    if(client->swapped) {
2376df26cacSmrg       swaps(&rep.sequenceNumber, n);
2386df26cacSmrg       swapl(&rep.length, n);
2396df26cacSmrg       swaps(&rep.width, n);
2406df26cacSmrg       swaps(&rep.height, n);
2416df26cacSmrg    }
2426df26cacSmrg    WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
2436df26cacSmrg    return client->noClientException;
2446df26cacSmrg}
2456df26cacSmrg
2466df26cacSmrg
2476df26cacSmrg/*
2486df26cacSmrg *----------------------------------------------------------------------------
2496df26cacSmrg *
2506df26cacSmrg * VMwareXineramaIsActive --
2516df26cacSmrg *
2526df26cacSmrg *      Implementation of IsActive command handler. Initialises and
2536df26cacSmrg *      sends a reply.
2546df26cacSmrg *
2556df26cacSmrg * Results:
2566df26cacSmrg *      Standard response codes.
2576df26cacSmrg *
2586df26cacSmrg * Side effects:
2596df26cacSmrg *      Writes reply to client.
2606df26cacSmrg *
2616df26cacSmrg *----------------------------------------------------------------------------
2626df26cacSmrg */
2636df26cacSmrg
2646df26cacSmrgstatic int
2656df26cacSmrgVMwareXineramaIsActive(ClientPtr client)
2666df26cacSmrg{
2676df26cacSmrg    xXineramaIsActiveReply	rep;
2686df26cacSmrg    ExtensionEntry *ext;
2696df26cacSmrg    ScrnInfoPtr pScrn;
2706df26cacSmrg    VMWAREPtr pVMWARE;
2716df26cacSmrg
2726df26cacSmrg    REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
2736df26cacSmrg
2746df26cacSmrg    if (!(ext = CheckExtension(PANORAMIX_PROTOCOL_NAME))) {
2756df26cacSmrg       return BadMatch;
2766df26cacSmrg    }
2776df26cacSmrg    pScrn = ext->extPrivate;
2786df26cacSmrg    pVMWARE = VMWAREPTR(pScrn);
2796df26cacSmrg
2806df26cacSmrg    rep.type = X_Reply;
2816df26cacSmrg    rep.length = 0;
2826df26cacSmrg    rep.sequenceNumber = client->sequence;
2836df26cacSmrg    rep.state = pVMWARE->xinerama;
2846df26cacSmrg    if(client->swapped) {
2856df26cacSmrg	register int n;
2866df26cacSmrg	swaps(&rep.sequenceNumber, n);
2876df26cacSmrg	swapl(&rep.length, n);
2886df26cacSmrg	swapl(&rep.state, n);
2896df26cacSmrg    }
2906df26cacSmrg    WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *) &rep);
2916df26cacSmrg    return client->noClientException;
2926df26cacSmrg}
2936df26cacSmrg
2946df26cacSmrg
2956df26cacSmrg/*
2966df26cacSmrg *----------------------------------------------------------------------------
2976df26cacSmrg *
2986df26cacSmrg * VMwareXineramaQueryScreens --
2996df26cacSmrg *
3006df26cacSmrg *      Implementation of QueryScreens command handler. Initialises and
3016df26cacSmrg *      sends a reply.
3026df26cacSmrg *
3036df26cacSmrg * Results:
3046df26cacSmrg *      Standard response codes.
3056df26cacSmrg *
3066df26cacSmrg * Side effects:
3076df26cacSmrg *      Writes reply to client.
3086df26cacSmrg *
3096df26cacSmrg *----------------------------------------------------------------------------
3106df26cacSmrg */
3116df26cacSmrg
3126df26cacSmrgstatic int
3136df26cacSmrgVMwareXineramaQueryScreens(ClientPtr client)
3146df26cacSmrg{
3156df26cacSmrg    xXineramaQueryScreensReply	rep;
3166df26cacSmrg    ExtensionEntry *ext;
3176df26cacSmrg    ScrnInfoPtr pScrn;
3186df26cacSmrg    VMWAREPtr pVMWARE;
3196df26cacSmrg
3206df26cacSmrg    REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
3216df26cacSmrg
3226df26cacSmrg    if (!(ext = CheckExtension(PANORAMIX_PROTOCOL_NAME))) {
3236df26cacSmrg       return BadMatch;
3246df26cacSmrg    }
3256df26cacSmrg    pScrn = ext->extPrivate;
3266df26cacSmrg    pVMWARE = VMWAREPTR(pScrn);
3276df26cacSmrg
3286df26cacSmrg    rep.type = X_Reply;
3296df26cacSmrg    rep.sequenceNumber = client->sequence;
3306df26cacSmrg    rep.number = pVMWARE->xinerama ? pVMWARE->xineramaNumOutputs : 0;
3316df26cacSmrg    rep.length = rep.number * sz_XineramaScreenInfo >> 2;
3326df26cacSmrg    if(client->swapped) {
3336df26cacSmrg       register int n;
3346df26cacSmrg       swaps(&rep.sequenceNumber, n);
3356df26cacSmrg       swapl(&rep.length, n);
3366df26cacSmrg       swapl(&rep.number, n);
3376df26cacSmrg    }
3386df26cacSmrg    WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *)&rep);
3396df26cacSmrg
3406df26cacSmrg    if(pVMWARE->xinerama) {
3416df26cacSmrg       xXineramaScreenInfo scratch;
3426df26cacSmrg       int i;
3436df26cacSmrg
3446df26cacSmrg       for(i = 0; i < pVMWARE->xineramaNumOutputs; i++) {
3456df26cacSmrg	  scratch.x_org  = pVMWARE->xineramaState[i].x_org;
3466df26cacSmrg	  scratch.y_org  = pVMWARE->xineramaState[i].y_org;
3476df26cacSmrg	  scratch.width  = pVMWARE->xineramaState[i].width;
3486df26cacSmrg	  scratch.height = pVMWARE->xineramaState[i].height;
3496df26cacSmrg	  if(client->swapped) {
3506df26cacSmrg	     register int n;
3516df26cacSmrg	     swaps(&scratch.x_org, n);
3526df26cacSmrg	     swaps(&scratch.y_org, n);
3536df26cacSmrg	     swaps(&scratch.width, n);
3546df26cacSmrg	     swaps(&scratch.height, n);
3556df26cacSmrg	  }
3566df26cacSmrg	  WriteToClient(client, sz_XineramaScreenInfo, (char *)&scratch);
3576df26cacSmrg       }
3586df26cacSmrg    }
3596df26cacSmrg
3606df26cacSmrg    return client->noClientException;
3616df26cacSmrg}
3626df26cacSmrg
3636df26cacSmrg
3646df26cacSmrg/*
3656df26cacSmrg *----------------------------------------------------------------------------
3666df26cacSmrg *
3676df26cacSmrg * VMwareXineramaDispatch --
3686df26cacSmrg *
3696df26cacSmrg *      Dispatcher for Xinerama commands. Calls the correct handler for
3706df26cacSmrg *      each command type.
3716df26cacSmrg *
3726df26cacSmrg * Results:
3736df26cacSmrg *      Standard response codes.
3746df26cacSmrg *
3756df26cacSmrg * Side effects:
3766df26cacSmrg *      Side effects of individual command handlers.
3776df26cacSmrg *
3786df26cacSmrg *----------------------------------------------------------------------------
3796df26cacSmrg */
3806df26cacSmrg
3816df26cacSmrgstatic int
3826df26cacSmrgVMwareXineramaDispatch(ClientPtr client)
3836df26cacSmrg{
3846df26cacSmrg    REQUEST(xReq);
3856df26cacSmrg    switch (stuff->data) {
3866df26cacSmrg	case X_PanoramiXQueryVersion:
3876df26cacSmrg	     return VMwareXineramaQueryVersion(client);
3886df26cacSmrg	case X_PanoramiXGetState:
3896df26cacSmrg	     return VMwareXineramaGetState(client);
3906df26cacSmrg	case X_PanoramiXGetScreenCount:
3916df26cacSmrg	     return VMwareXineramaGetScreenCount(client);
3926df26cacSmrg	case X_PanoramiXGetScreenSize:
3936df26cacSmrg	     return VMwareXineramaGetScreenSize(client);
3946df26cacSmrg	case X_XineramaIsActive:
3956df26cacSmrg	     return VMwareXineramaIsActive(client);
3966df26cacSmrg	case X_XineramaQueryScreens:
3976df26cacSmrg	     return VMwareXineramaQueryScreens(client);
3986df26cacSmrg    }
3996df26cacSmrg    return BadRequest;
4006df26cacSmrg}
4016df26cacSmrg
4026df26cacSmrg
4036df26cacSmrg/*
4046df26cacSmrg *----------------------------------------------------------------------------
4056df26cacSmrg *
4066df26cacSmrg * SVMwareXineramaQueryVersion --
4076df26cacSmrg *
4086df26cacSmrg *      Wrapper for QueryVersion handler that handles input from other-endian
4096df26cacSmrg *      clients.
4106df26cacSmrg *
4116df26cacSmrg * Results:
4126df26cacSmrg *      Standard response codes.
4136df26cacSmrg *
4146df26cacSmrg * Side effects:
4156df26cacSmrg *      Side effects of unswapped implementation.
4166df26cacSmrg *
4176df26cacSmrg *----------------------------------------------------------------------------
4186df26cacSmrg */
4196df26cacSmrg
4206df26cacSmrgstatic int
4216df26cacSmrgSVMwareXineramaQueryVersion (ClientPtr client)
4226df26cacSmrg{
4236df26cacSmrg    REQUEST(xPanoramiXQueryVersionReq);
4246df26cacSmrg    register int n;
4256df26cacSmrg    swaps(&stuff->length,n);
4266df26cacSmrg    REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
4276df26cacSmrg    return VMwareXineramaQueryVersion(client);
4286df26cacSmrg}
4296df26cacSmrg
4306df26cacSmrg
4316df26cacSmrg/*
4326df26cacSmrg *----------------------------------------------------------------------------
4336df26cacSmrg *
4346df26cacSmrg * SVMwareXineramaGetState --
4356df26cacSmrg *
4366df26cacSmrg *      Wrapper for GetState handler that handles input from other-endian
4376df26cacSmrg *      clients.
4386df26cacSmrg *
4396df26cacSmrg * Results:
4406df26cacSmrg *      Standard response codes.
4416df26cacSmrg *
4426df26cacSmrg * Side effects:
4436df26cacSmrg *      Side effects of unswapped implementation.
4446df26cacSmrg *
4456df26cacSmrg *----------------------------------------------------------------------------
4466df26cacSmrg */
4476df26cacSmrg
4486df26cacSmrgstatic int
4496df26cacSmrgSVMwareXineramaGetState(ClientPtr client)
4506df26cacSmrg{
4516df26cacSmrg    REQUEST(xPanoramiXGetStateReq);
4526df26cacSmrg    register int n;
4536df26cacSmrg    swaps (&stuff->length, n);
4546df26cacSmrg    REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
4556df26cacSmrg    return VMwareXineramaGetState(client);
4566df26cacSmrg}
4576df26cacSmrg
4586df26cacSmrg
4596df26cacSmrg/*
4606df26cacSmrg *----------------------------------------------------------------------------
4616df26cacSmrg *
4626df26cacSmrg * SVMwareXineramaGetScreenCount --
4636df26cacSmrg *
4646df26cacSmrg *      Wrapper for GetScreenCount handler that handles input from other-endian
4656df26cacSmrg *      clients.
4666df26cacSmrg *
4676df26cacSmrg * Results:
4686df26cacSmrg *      Standard response codes.
4696df26cacSmrg *
4706df26cacSmrg * Side effects:
4716df26cacSmrg *      Side effects of unswapped implementation.
4726df26cacSmrg *
4736df26cacSmrg *----------------------------------------------------------------------------
4746df26cacSmrg */
4756df26cacSmrg
4766df26cacSmrgstatic int
4776df26cacSmrgSVMwareXineramaGetScreenCount(ClientPtr client)
4786df26cacSmrg{
4796df26cacSmrg    REQUEST(xPanoramiXGetScreenCountReq);
4806df26cacSmrg    register int n;
4816df26cacSmrg    swaps (&stuff->length, n);
4826df26cacSmrg    REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
4836df26cacSmrg    return VMwareXineramaGetScreenCount(client);
4846df26cacSmrg}
4856df26cacSmrg
4866df26cacSmrg
4876df26cacSmrg/*
4886df26cacSmrg *----------------------------------------------------------------------------
4896df26cacSmrg *
4906df26cacSmrg * SVMwareXineramaGetScreenSize --
4916df26cacSmrg *
4926df26cacSmrg *      Wrapper for GetScreenSize handler that handles input from other-endian
4936df26cacSmrg *      clients.
4946df26cacSmrg *
4956df26cacSmrg * Results:
4966df26cacSmrg *      Standard response codes.
4976df26cacSmrg *
4986df26cacSmrg * Side effects:
4996df26cacSmrg *      Side effects of unswapped implementation.
5006df26cacSmrg *
5016df26cacSmrg *----------------------------------------------------------------------------
5026df26cacSmrg */
5036df26cacSmrg
5046df26cacSmrgstatic int
5056df26cacSmrgSVMwareXineramaGetScreenSize(ClientPtr client)
5066df26cacSmrg{
5076df26cacSmrg    REQUEST(xPanoramiXGetScreenSizeReq);
5086df26cacSmrg    register int n;
5096df26cacSmrg    swaps (&stuff->length, n);
5106df26cacSmrg    REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
5116df26cacSmrg    return VMwareXineramaGetScreenSize(client);
5126df26cacSmrg}
5136df26cacSmrg
5146df26cacSmrg
5156df26cacSmrg/*
5166df26cacSmrg *----------------------------------------------------------------------------
5176df26cacSmrg *
5186df26cacSmrg * SVMwareXineramaIsActive --
5196df26cacSmrg *
5206df26cacSmrg *      Wrapper for IsActive handler that handles input from other-endian
5216df26cacSmrg *      clients.
5226df26cacSmrg *
5236df26cacSmrg * Results:
5246df26cacSmrg *      Standard response codes.
5256df26cacSmrg *
5266df26cacSmrg * Side effects:
5276df26cacSmrg *      Side effects of unswapped implementation.
5286df26cacSmrg *
5296df26cacSmrg *----------------------------------------------------------------------------
5306df26cacSmrg */
5316df26cacSmrg
5326df26cacSmrgstatic int
5336df26cacSmrgSVMwareXineramaIsActive(ClientPtr client)
5346df26cacSmrg{
5356df26cacSmrg    REQUEST(xXineramaIsActiveReq);
5366df26cacSmrg    register int n;
5376df26cacSmrg    swaps (&stuff->length, n);
5386df26cacSmrg    REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
5396df26cacSmrg    return VMwareXineramaIsActive(client);
5406df26cacSmrg}
5416df26cacSmrg
5426df26cacSmrg
5436df26cacSmrg/*
5446df26cacSmrg *----------------------------------------------------------------------------
5456df26cacSmrg *
5466df26cacSmrg * SVMwareXineramaQueryScreens --
5476df26cacSmrg *
5486df26cacSmrg *      Wrapper for QueryScreens handler that handles input from other-endian
5496df26cacSmrg *      clients.
5506df26cacSmrg *
5516df26cacSmrg * Results:
5526df26cacSmrg *      Standard response codes.
5536df26cacSmrg *
5546df26cacSmrg * Side effects:
5556df26cacSmrg *      Side effects of unswapped implementation.
5566df26cacSmrg *
5576df26cacSmrg *----------------------------------------------------------------------------
5586df26cacSmrg */
5596df26cacSmrg
5606df26cacSmrgstatic int
5616df26cacSmrgSVMwareXineramaQueryScreens(ClientPtr client)
5626df26cacSmrg{
5636df26cacSmrg    REQUEST(xXineramaQueryScreensReq);
5646df26cacSmrg    register int n;
5656df26cacSmrg    swaps (&stuff->length, n);
5666df26cacSmrg    REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
5676df26cacSmrg    return VMwareXineramaQueryScreens(client);
5686df26cacSmrg}
5696df26cacSmrg
5706df26cacSmrg
5716df26cacSmrg/*
5726df26cacSmrg *----------------------------------------------------------------------------
5736df26cacSmrg *
5746df26cacSmrg * SVMwareXineramaDispatch --
5756df26cacSmrg *
5766df26cacSmrg *      Wrapper for dispatcher that handles input from other-endian clients.
5776df26cacSmrg *
5786df26cacSmrg * Results:
5796df26cacSmrg *      Standard response codes.
5806df26cacSmrg *
5816df26cacSmrg * Side effects:
5826df26cacSmrg *      Side effects of individual command handlers.
5836df26cacSmrg *
5846df26cacSmrg *----------------------------------------------------------------------------
5856df26cacSmrg */
5866df26cacSmrg
5876df26cacSmrgstatic int
5886df26cacSmrgSVMwareXineramaDispatch(ClientPtr client)
5896df26cacSmrg{
5906df26cacSmrg    REQUEST(xReq);
5916df26cacSmrg    switch (stuff->data) {
5926df26cacSmrg	case X_PanoramiXQueryVersion:
5936df26cacSmrg	     return SVMwareXineramaQueryVersion(client);
5946df26cacSmrg	case X_PanoramiXGetState:
5956df26cacSmrg	     return SVMwareXineramaGetState(client);
5966df26cacSmrg	case X_PanoramiXGetScreenCount:
5976df26cacSmrg	     return SVMwareXineramaGetScreenCount(client);
5986df26cacSmrg	case X_PanoramiXGetScreenSize:
5996df26cacSmrg	     return SVMwareXineramaGetScreenSize(client);
6006df26cacSmrg	case X_XineramaIsActive:
6016df26cacSmrg	     return SVMwareXineramaIsActive(client);
6026df26cacSmrg	case X_XineramaQueryScreens:
6036df26cacSmrg	     return SVMwareXineramaQueryScreens(client);
6046df26cacSmrg    }
6056df26cacSmrg    return BadRequest;
6066df26cacSmrg}
6076df26cacSmrg
6086df26cacSmrg
6096df26cacSmrg/*
6106df26cacSmrg *----------------------------------------------------------------------------
6116df26cacSmrg *
6126df26cacSmrg * VMwareXineramaResetProc --
6136df26cacSmrg *
6146df26cacSmrg *      Cleanup handler called when the extension is removed.
6156df26cacSmrg *
6166df26cacSmrg * Results:
6176df26cacSmrg *      None
6186df26cacSmrg *
6196df26cacSmrg * Side effects:
6206df26cacSmrg *      None
6216df26cacSmrg *
6226df26cacSmrg *----------------------------------------------------------------------------
6236df26cacSmrg */
6246df26cacSmrg
6256df26cacSmrgstatic void
6266df26cacSmrgVMwareXineramaResetProc(ExtensionEntry* extEntry)
6276df26cacSmrg{
6286df26cacSmrg    /* Called by CloseDownExtensions() */
6296df26cacSmrg
6306df26cacSmrg   ScrnInfoPtr pScrn = extEntry->extPrivate;
6316df26cacSmrg   VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
6326df26cacSmrg
6336df26cacSmrg   if (pVMWARE->xineramaState) {
6346df26cacSmrg      xfree(pVMWARE->xineramaState);
6356df26cacSmrg      pVMWARE->xineramaState = NULL;
6366df26cacSmrg      pVMWARE->xineramaNumOutputs = 0;
6376df26cacSmrg      pVMWARE->xinerama = FALSE;
6386df26cacSmrg   }
6396df26cacSmrg}
6406df26cacSmrg
6416df26cacSmrg
6426df26cacSmrg/*
6436df26cacSmrg *----------------------------------------------------------------------------
6446df26cacSmrg *
6456df26cacSmrg * VMwareCtrl_ExitInit --
6466df26cacSmrg *
6476df26cacSmrg *      Initialiser for the Xinerama protocol extension.
6486df26cacSmrg *
6496df26cacSmrg * Results:
6506df26cacSmrg *      None.
6516df26cacSmrg *
6526df26cacSmrg * Side effects:
6536df26cacSmrg *      Protocol extension will be registered if successful.
6546df26cacSmrg *
6556df26cacSmrg *----------------------------------------------------------------------------
6566df26cacSmrg */
6576df26cacSmrg
6586df26cacSmrgvoid
6596df26cacSmrgVMwareXinerama_ExtInit(ScrnInfoPtr pScrn)
6606df26cacSmrg{
6616df26cacSmrg   ExtensionEntry *myext;
6626df26cacSmrg   VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
6636df26cacSmrg
6646df26cacSmrg#ifdef PANORAMIX
6656df26cacSmrg   if(!noPanoramiXExtension) {
6666df26cacSmrg      xf86DrvMsg(pScrn->scrnIndex, X_INFO,
6676df26cacSmrg                 "Built-in Xinerama active, not initializing VMware Xinerama\n");
6686df26cacSmrg      pVMWARE->xinerama = FALSE;
6696df26cacSmrg      return;
6706df26cacSmrg   }
6716df26cacSmrg#endif
6726df26cacSmrg
6736df26cacSmrg   if (!(myext = CheckExtension(PANORAMIX_PROTOCOL_NAME))) {
6746df26cacSmrg      if (!(myext = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
6756df26cacSmrg                                 VMwareXineramaDispatch,
6766df26cacSmrg                                 SVMwareXineramaDispatch,
6776df26cacSmrg                                 VMwareXineramaResetProc,
6786df26cacSmrg                                 StandardMinorOpcode))) {
6796df26cacSmrg         xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
6806df26cacSmrg                    "Failed to add VMware Xinerama extension.\n");
6816df26cacSmrg         return;
6826df26cacSmrg      }
6836df26cacSmrg
6846df26cacSmrg      pVMWARE->xinerama = TRUE;
6856df26cacSmrg
6866df26cacSmrg      myext->extPrivate = pScrn;
6876df26cacSmrg
6886df26cacSmrg      xf86DrvMsg(pScrn->scrnIndex, X_INFO,
6896df26cacSmrg                 "Initialized VMware Xinerama extension.\n");
6906df26cacSmrg   }
6916df26cacSmrg}
692