summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/xfree86/dixmods/extmod/xf86dga2.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c
index 100bde9cf..df0030e80 100644
--- a/hw/xfree86/dixmods/extmod/xf86dga2.c
+++ b/hw/xfree86/dixmods/extmod/xf86dga2.c
@@ -725,6 +725,10 @@ ProcXF86DGADirectVideo(ClientPtr client)
if (!DGAAvailable(stuff->screen))
return DGAErrorBase + XF86DGANoDirectVideoMode;
+ if (DGAClients[stuff->screen] &&
+ (DGAClients[stuff->screen] != client))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
if (stuff->enable & XF86DGADirectGraphics) {
if(!(num = DGAGetOldDGAMode(stuff->screen)))
return (DGAErrorBase + XF86DGANoDirectVideoMode);
@@ -738,6 +742,24 @@ ProcXF86DGADirectVideo(ClientPtr client)
(stuff->enable & XF86DGADirectKeyb) != 0,
(stuff->enable & XF86DGADirectMouse) != 0);
+ /* We need to track the client and attach the teardown callback */
+ if (stuff->enable &
+ (XF86DGADirectGraphics | XF86DGADirectKeyb | XF86DGADirectMouse)) {
+ if (!DGAClients[stuff->screen]) {
+ if (DGACallbackRefCount++ == 0)
+ AddCallback (&ClientStateCallback, DGAClientStateChange, NULL);
+ }
+
+ DGAClients[stuff->screen] = client;
+ } else {
+ if (DGAClients[stuff->screen]) {
+ if (--DGACallbackRefCount == 0)
+ DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL);
+ }
+
+ DGAClients[stuff->screen] = NULL;
+ }
+
return (client->noClientException);
}
@@ -780,22 +802,16 @@ ProcXF86DGASetViewPort(ClientPtr client)
if (stuff->screen > screenInfo.numScreens)
return BadValue;
+ if (DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq);
if (!DGAAvailable(stuff->screen))
return (DGAErrorBase + XF86DGANoDirectVideoMode);
if (!DGAActive(stuff->screen))
- {
- int num;
- PixmapPtr pix;
- XDGAModeRec mode;
-
- if(!(num = DGAGetOldDGAMode(stuff->screen)))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
- if(Success != DGASetMode(stuff->screen, num, &mode, &pix))
- return (DGAErrorBase + XF86DGAScreenNotActive);
- }
+ return DGAErrorBase + XF86DGADirectNotActivated;
if (DGASetViewport(stuff->screen, stuff->x, stuff->y, DGA_FLIP_RETRACE)
!= Success)
@@ -846,6 +862,12 @@ ProcXF86DGAInstallColormap(ClientPtr client)
ColormapPtr pcmp;
REQUEST(xXF86DGAInstallColormapReq);
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if (DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq);
if (!DGAActive(stuff->screen))
@@ -892,6 +914,9 @@ ProcXF86DGAViewPortChanged(ClientPtr client)
if (stuff->screen > screenInfo.numScreens)
return BadValue;
+ if (DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq);
if (!DGAActive(stuff->screen))