From e012f2312b4bcdf31bb5d622ddd34571f3c12429 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Thu, 13 Jan 2011 20:19:18 +0200 Subject: xf86/xv: Remove copy paste code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xf86XVFillKeyHelperDrawable can be used to implement xf86XVFillKeyHelper. V2: * Remove RegionTranslate that clobbered parameter region. Signed-off-by: Pauli Nieminen Reviewed-by: Ville Syrjälä --- hw/xfree86/common/xf86xv.c | 68 ++++++++-------------------------------------- 1 file changed, 11 insertions(+), 57 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 016db1f04..f1a87f120 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -1869,62 +1869,10 @@ xf86XVQueryImageAttributes( format->id, width, height, pitches, offsets); } - void xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes) { ScreenPtr pScreen = pDraw->pScreen; - WindowPtr pWin = (WindowPtr)pDraw; - XF86XVWindowPtr pPriv = GET_XF86XV_WINDOW(pWin); - GCPtr pGC = NULL; - BoxPtr pbox = RegionRects(clipboxes); - int i, nbox = RegionNumRects(clipboxes); - xRectangle *rects; - - if(!xf86Screens[pScreen->myNum]->vtSema) return; - - if(pPriv) - pGC = pPriv->pGC; - - if(!pGC) { - int status; - XID pval[2]; - pval[0] = key; - pval[1] = IncludeInferiors; - pGC = CreateGC(pDraw, GCForeground | GCSubwindowMode, pval, &status, - (XID)0, serverClient); - if(!pGC) return; - ValidateGC(pDraw, pGC); - if (pPriv) pPriv->pGC = pGC; - } else if (key != pGC->fgPixel){ - ChangeGCVal val; - val.val = key; - ChangeGC(NullClient, pGC, GCForeground, &val); - ValidateGC(pDraw, pGC); - } - - RegionTranslate(clipboxes, -pDraw->x, -pDraw->y); - - rects = malloc(nbox * sizeof(xRectangle)); - - for(i = 0; i < nbox; i++, pbox++) { - rects[i].x = pbox->x1; - rects[i].y = pbox->y1; - rects[i].width = pbox->x2 - pbox->x1; - rects[i].height = pbox->y2 - pbox->y1; - } - - (*pGC->ops->PolyFillRect)(pDraw, pGC, nbox, rects); - - if (!pPriv) FreeGC(pGC, 0); - - free(rects); -} - -void -xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes) -{ - DrawablePtr root = &pScreen->root->drawable; ChangeGCVal pval[2]; BoxPtr pbox = RegionRects(clipboxes); int i, nbox = RegionNumRects(clipboxes); @@ -1933,28 +1881,34 @@ xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes) if(!xf86Screens[pScreen->myNum]->vtSema) return; - gc = GetScratchGC(root->depth, pScreen); + gc = GetScratchGC(pDraw->depth, pScreen); pval[0].val = key; pval[1].val = IncludeInferiors; (void) ChangeGC(NullClient, gc, GCForeground|GCSubwindowMode, pval); - ValidateGC(root, gc); + ValidateGC(pDraw, gc); rects = malloc(nbox * sizeof(xRectangle)); for(i = 0; i < nbox; i++, pbox++) { - rects[i].x = pbox->x1; - rects[i].y = pbox->y1; + rects[i].x = pbox->x1 - pDraw->x; + rects[i].y = pbox->y1 - pDraw->y; rects[i].width = pbox->x2 - pbox->x1; rects[i].height = pbox->y2 - pbox->y1; } - (*gc->ops->PolyFillRect)(root, gc, nbox, rects); + (*gc->ops->PolyFillRect)(pDraw, gc, nbox, rects); free(rects); FreeScratchGC (gc); } +void +xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes) +{ + xf86XVFillKeyHelperDrawable (&pScreen->root->drawable, key, clipboxes); +} + /* xf86XVClipVideoHelper - Takes the dst box in standard X BoxRec form (top and left -- cgit v1.2.3 From 4f8f803280894a8c41691e350b7a34bfd719fe05 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Thu, 13 Jan 2011 20:21:09 +0200 Subject: xf86/xv: Remove unused GC pointers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pauli Nieminen Reviewed-by: Ville Syrjälä --- hw/xfree86/common/xf86xv.c | 10 ---------- hw/xfree86/common/xf86xvpriv.h | 2 -- 2 files changed, 12 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index f1a87f120..6dcd497a9 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -280,8 +280,6 @@ xf86XVScreenInit( pScrn = xf86Screens[pScreen->myNum]; - ScreenPriv->videoGC = NULL; /* for the helper */ - ScreenPriv->DestroyWindow = pScreen->DestroyWindow; ScreenPriv->WindowExposures = pScreen->WindowExposures; ScreenPriv->ClipNotify = pScreen->ClipNotify; @@ -1123,9 +1121,6 @@ xf86XVDestroyWindow(WindowPtr pWin) pPriv->pDraw = NULL; tmp = WinPriv; - if(WinPriv->pGC) { - FreeGC(WinPriv->pGC, 0); - } WinPriv = WinPriv->next; free(tmp); } @@ -1232,11 +1227,6 @@ xf86XVCloseScreen(int i, ScreenPtr pScreen) if(!ScreenPriv) return TRUE; - if(ScreenPriv->videoGC) { - FreeGC(ScreenPriv->videoGC, 0); - ScreenPriv->videoGC = NULL; - } - pScreen->DestroyWindow = ScreenPriv->DestroyWindow; pScreen->WindowExposures = ScreenPriv->WindowExposures; pScreen->ClipNotify = ScreenPriv->ClipNotify; diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h index 88e7a0e59..c6679260a 100644 --- a/hw/xfree86/common/xf86xvpriv.h +++ b/hw/xfree86/common/xf86xvpriv.h @@ -43,7 +43,6 @@ typedef struct { void (*AdjustFrame)(int, int, int, int); Bool (*EnterVT)(int, int); void (*LeaveVT)(int, int); - GCPtr videoGC; xf86ModeSetProc *ModeSet; } XF86XVScreenRec, *XF86XVScreenPtr; @@ -82,7 +81,6 @@ typedef struct { typedef struct _XF86XVWindowRec{ XvPortRecPrivatePtr PortRec; struct _XF86XVWindowRec *next; - GCPtr pGC; } XF86XVWindowRec, *XF86XVWindowPtr; #endif /* _XF86XVPRIV_H_ */ -- cgit v1.2.3 From 9b048ca420864e19862f63f4a491a4da0ff9b54f Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Mon, 17 Jan 2011 15:07:28 +0200 Subject: xf86/xv: Remove unused variable from XvPortRecPrivate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pauli Nieminen Reviewed-by: Ville Syrjälä --- hw/xfree86/common/xf86xvpriv.h | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h index c6679260a..4572218cb 100644 --- a/hw/xfree86/common/xf86xvpriv.h +++ b/hw/xfree86/common/xf86xvpriv.h @@ -72,7 +72,6 @@ typedef struct { Bool FreeCompositeClip; XvAdaptorRecPrivatePtr AdaptorRec; XvStatus isOn; - Bool moved; int vid_x, vid_y, vid_w, vid_h; int drw_x, drw_y, drw_w, drw_h; DevUnion DevPriv; -- cgit v1.2.3 From 5678a41f6bc0ef8965bd50a88c5ef01ba7eb8b24 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Mon, 17 Jan 2011 16:58:00 +0200 Subject: xf86/xv: Fill color key on expose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If window gets exposed but clipboxes doesn't change drivers would avoid color key fill. This makes XResizeWindo&co to lose colorkey if background is painted. To help drivers to avoid filling colorkey for each put server can provide helper function if there is exposed areas. Server can subtract exposed areas from filled region. As a side effect we can avoid useless color key fills if window only moves in screen without background fills. v3: * Change tracking to filled area to account for client initiated clip changes * Make overlaid XvPutImage behavior like textured XvPutImage or PutImage * Make region dynamically allocated only when required. v4: * Simplify new driver interface to reduce duplicate code Signed-off-by: Pauli Nieminen Reviewed-by: Ville Syrjälä --- hw/xfree86/common/xf86xv.c | 78 ++++++++++++++++++++++++++++++++++++++---- hw/xfree86/common/xf86xv.h | 3 ++ hw/xfree86/common/xf86xvpriv.h | 1 + 3 files changed, 76 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 6dcd497a9..21e00355c 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -331,6 +331,8 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor) RegionDestroy(pPriv->clientClip); if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) RegionDestroy(pPriv->pCompositeClip); + if (pPriv->ckeyFilled) + RegionDestroy(pPriv->ckeyFilled); free(pPriv); } } @@ -1016,7 +1018,6 @@ static void xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) { XF86XVWindowPtr winPriv, prevPriv = NULL; - winPriv = GET_XF86XV_WINDOW(pWin); while(winPriv) { @@ -1033,6 +1034,10 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) winPriv = winPriv->next; } portPriv->pDraw = NULL; + if (portPriv->ckeyFilled) { + RegionDestroy(portPriv->ckeyFilled); + portPriv->ckeyFilled = NULL; + } } static void @@ -1165,6 +1170,21 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) if (!pPriv->type && !pPriv->AdaptorRec->ReputImage) visible = !AreasExposed; + /* + * Subtract exposed areas from overlaid image to match textured video + * behavior. + */ + if (!pPriv->type && pPriv->clientClip) + RegionSubtract(pPriv->clientClip, pPriv->clientClip, reg1); + + if (visible && pPriv->ckeyFilled) { + RegionRec tmp; + RegionNull(&tmp); + RegionCopy(&tmp, reg1); + RegionTranslate(&tmp, pWin->drawable.x, pWin->drawable.y); + RegionSubtract(pPriv->ckeyFilled, pPriv->ckeyFilled, &tmp); + } + WinPriv = WinPriv->next; xf86XVReputOrStopPort(pPriv, pWin, visible); } @@ -1860,12 +1880,12 @@ xf86XVQueryImageAttributes( } void -xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes) +xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr fillboxes) { ScreenPtr pScreen = pDraw->pScreen; ChangeGCVal pval[2]; - BoxPtr pbox = RegionRects(clipboxes); - int i, nbox = RegionNumRects(clipboxes); + BoxPtr pbox = RegionRects(fillboxes); + int i, nbox = RegionNumRects(fillboxes); xRectangle *rects; GCPtr gc; @@ -1894,11 +1914,57 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes) } void -xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes) +xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr fillboxes) { - xf86XVFillKeyHelperDrawable (&pScreen->root->drawable, key, clipboxes); + xf86XVFillKeyHelperDrawable (&pScreen->root->drawable, key, fillboxes); } +void +xf86XVFillKeyHelperPort (DrawablePtr pDraw, pointer data, CARD32 key, RegionPtr clipboxes, Bool fillEverything) +{ + WindowPtr pWin = (WindowPtr)pDraw; + XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin); + XvPortRecPrivatePtr portPriv = NULL; + RegionRec reg; + RegionPtr fillboxes; + + while (WinPriv) { + XvPortRecPrivatePtr pPriv = WinPriv->PortRec; + + if (data == pPriv->DevPriv.ptr) { + portPriv = pPriv; + break; + } + + WinPriv = WinPriv->next; + } + + if (!portPriv) + return; + + if (!portPriv->ckeyFilled) + portPriv->ckeyFilled = RegionCreate(NULL, 0); + + if (!fillEverything) { + RegionNull(®); + fillboxes = ® + RegionSubtract(fillboxes, clipboxes, portPriv->ckeyFilled); + + if (!RegionNotEmpty(fillboxes)) + goto out; + } else + fillboxes = clipboxes; + + + RegionCopy(portPriv->ckeyFilled, clipboxes); + + xf86XVFillKeyHelperDrawable(pDraw, key, fillboxes); +out: + if (!fillEverything) + RegionUninit(®); +} + + /* xf86XVClipVideoHelper - Takes the dst box in standard X BoxRec form (top and left diff --git a/hw/xfree86/common/xf86xv.h b/hw/xfree86/common/xf86xv.h index 47061fed2..f0d8495c6 100644 --- a/hw/xfree86/common/xf86xv.h +++ b/hw/xfree86/common/xf86xv.h @@ -244,6 +244,9 @@ xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes); extern _X_EXPORT void xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes); +extern _X_EXPORT void +xf86XVFillKeyHelperPort (DrawablePtr pDraw, pointer data, CARD32 key, RegionPtr clipboxes, Bool fillEverything); + extern _X_EXPORT Bool xf86XVClipVideoHelper( BoxPtr dst, diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h index 4572218cb..3f1106de7 100644 --- a/hw/xfree86/common/xf86xvpriv.h +++ b/hw/xfree86/common/xf86xvpriv.h @@ -68,6 +68,7 @@ typedef struct { unsigned char type; unsigned int subWindowMode; RegionPtr clientClip; + RegionPtr ckeyFilled; RegionPtr pCompositeClip; Bool FreeCompositeClip; XvAdaptorRecPrivatePtr AdaptorRec; -- cgit v1.2.3 From ddf32df5cc2e73b833f6e414276d938fdc38869e Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Thu, 13 Jan 2011 20:50:16 +0200 Subject: xf86/xv: Use PostValidateTree to do reput MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ValidateTree calls first ClipNotify and later might call WindowExposures. To avoid useless double reput ClipNotify delays reput to WindowExposures or PostValidateTree. PostValidatTree checks all ports if there is clip changes. On clip changes reput is done to move or scale the overlay. Signed-off-by: Pauli Nieminen Reviewed-by: Ville Syrjälä --- hw/xfree86/common/xf86xv.c | 54 +++++++++++++++++++++++++++++++----------- hw/xfree86/common/xf86xvpriv.h | 2 ++ 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 21e00355c..ea286df79 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -97,6 +97,7 @@ static int xf86XVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr, static Bool xf86XVDestroyWindow(WindowPtr pWin); static void xf86XVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2); +static void xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind); static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy); /* ScrnInfoRec functions */ @@ -282,6 +283,7 @@ xf86XVScreenInit( ScreenPriv->DestroyWindow = pScreen->DestroyWindow; ScreenPriv->WindowExposures = pScreen->WindowExposures; + ScreenPriv->PostValidateTree = pScreen->PostValidateTree; ScreenPriv->ClipNotify = pScreen->ClipNotify; ScreenPriv->EnterVT = pScrn->EnterVT; ScreenPriv->LeaveVT = pScrn->LeaveVT; @@ -290,6 +292,7 @@ xf86XVScreenInit( pScreen->DestroyWindow = xf86XVDestroyWindow; pScreen->WindowExposures = xf86XVWindowExposures; + pScreen->PostValidateTree = xf86XVPostValidateTree; pScreen->ClipNotify = xf86XVClipNotify; pScrn->EnterVT = xf86XVEnterVT; pScrn->LeaveVT = xf86XVLeaveVT; @@ -1038,6 +1041,7 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) RegionDestroy(portPriv->ckeyFilled); portPriv->ckeyFilled = NULL; } + portPriv->clipChanged = FALSE; } static void @@ -1072,7 +1076,7 @@ xf86XVReputOrStopPort(XvPortRecPrivatePtr pPriv, } static void -xf86XVReputOrStopAllPorts(ScrnInfoPtr pScrn) +xf86XVReputOrStopAllPorts(ScrnInfoPtr pScrn, Bool onlyChanged) { ScreenPtr pScreen = pScrn->pScreen; XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); @@ -1090,6 +1094,9 @@ xf86XVReputOrStopAllPorts(ScrnInfoPtr pScrn) if (pPriv->isOn == XV_OFF || !pWin) continue; + if (onlyChanged && !pPriv->clipChanged) + continue; + visible = pWin->visibility == VisibilityUnobscured || pWin->visibility == VisibilityPartiallyObscured; @@ -1101,6 +1108,8 @@ xf86XVReputOrStopAllPorts(ScrnInfoPtr pScrn) visible = FALSE; xf86XVReputOrStopPort(pPriv, pWin, visible); + + pPriv->clipChanged = FALSE; } } } @@ -1139,6 +1148,30 @@ xf86XVDestroyWindow(WindowPtr pWin) return ret; } +static void +xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind) +{ + ScreenPtr pScreen; + XF86XVScreenPtr ScreenPriv; + ScrnInfoPtr pScrn; + + if (pWin) + pScreen = pWin->drawable.pScreen; + else + pScreen = pLayerWin->drawable.pScreen; + + ScreenPriv = GET_XF86XV_SCREEN(pScreen); + pScrn = xf86Screens[pScreen->myNum]; + + xf86XVReputOrStopAllPorts(pScrn, TRUE); + + if (ScreenPriv->PostValidateTree) { + pScreen->PostValidateTree = ScreenPriv->PostValidateTree; + (*pScreen->PostValidateTree)(pWin, pLayerWin, kind); + ScreenPriv->PostValidateTree = pScreen->PostValidateTree; + pScreen->PostValidateTree = xf86XVPostValidateTree; + } +} static void xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) @@ -1187,10 +1220,11 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) WinPriv = WinPriv->next; xf86XVReputOrStopPort(pPriv, pWin, visible); + + pPriv->clipChanged = FALSE; } } - static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy) { @@ -1200,9 +1234,6 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) XvPortRecPrivatePtr pPriv; while(WinPriv) { - Bool visible = pWin->visibility == VisibilityUnobscured || - pWin->visibility == VisibilityPartiallyObscured; - pPriv = WinPriv->PortRec; if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) @@ -1214,15 +1245,9 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) (*pPriv->AdaptorRec->ClipNotify)(pPriv->pScrn, pPriv->DevPriv.ptr, pWin, dx, dy); - /* - * Stop and remove still/images if - * ReputImage isn't supported. - */ - if (!pPriv->type && !pPriv->AdaptorRec->ReputImage) - visible = FALSE; + pPriv->clipChanged = TRUE; WinPriv = WinPriv->next; - xf86XVReputOrStopPort(pPriv, pWin, visible); } if(ScreenPriv->ClipNotify) { @@ -1249,6 +1274,7 @@ xf86XVCloseScreen(int i, ScreenPtr pScreen) pScreen->DestroyWindow = ScreenPriv->DestroyWindow; pScreen->WindowExposures = ScreenPriv->WindowExposures; + pScreen->PostValidateTree = ScreenPriv->PostValidateTree; pScreen->ClipNotify = ScreenPriv->ClipNotify; pScrn->EnterVT = ScreenPriv->EnterVT; @@ -1355,7 +1381,7 @@ xf86XVAdjustFrame(int index, int x, int y, int flags) pScrn->AdjustFrame = xf86XVAdjustFrame; } - xf86XVReputOrStopAllPorts(pScrn); + xf86XVReputOrStopAllPorts(pScrn, FALSE); } static void @@ -1376,7 +1402,7 @@ xf86XVModeSet(ScrnInfoPtr pScrn) pScrn->ModeSet = xf86XVModeSet; } - xf86XVReputOrStopAllPorts(pScrn); + xf86XVReputOrStopAllPorts(pScrn, FALSE); } /**** XvAdaptorRec fields ****/ diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h index 3f1106de7..2a459f1b4 100644 --- a/hw/xfree86/common/xf86xvpriv.h +++ b/hw/xfree86/common/xf86xvpriv.h @@ -40,6 +40,7 @@ typedef struct { DestroyWindowProcPtr DestroyWindow; ClipNotifyProcPtr ClipNotify; WindowExposuresProcPtr WindowExposures; + PostValidateTreeProcPtr PostValidateTree; void (*AdjustFrame)(int, int, int, int); Bool (*EnterVT)(int, int); void (*LeaveVT)(int, int); @@ -73,6 +74,7 @@ typedef struct { Bool FreeCompositeClip; XvAdaptorRecPrivatePtr AdaptorRec; XvStatus isOn; + Bool clipChanged; int vid_x, vid_y, vid_w, vid_h; int drw_x, drw_y, drw_w, drw_h; DevUnion DevPriv; -- cgit v1.2.3 From 5d020c31351594c104fb46615ce41f256cd8e8b9 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Fri, 14 Jan 2011 15:03:28 +0200 Subject: xf86/xv: Only register PostValidateTree hook when there is work to do MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If none of Xv ports were affected by window tree modifications we don't want scan the port list. To avoid useless scanning of port list PostValidateTree hook is only registered when ClipNotify was called for any port. Signed-off-by: Pauli Nieminen Reviewed-by: Ville Syrjälä --- hw/xfree86/common/xf86xv.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index ea286df79..53ebe8f88 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -100,6 +100,8 @@ static void xf86XVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2); static void xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind); static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy); +#define PostValidateTreeUndefined ((PostValidateTreeProcPtr)-1) + /* ScrnInfoRec functions */ static Bool xf86XVEnterVT(int, int); @@ -283,7 +285,7 @@ xf86XVScreenInit( ScreenPriv->DestroyWindow = pScreen->DestroyWindow; ScreenPriv->WindowExposures = pScreen->WindowExposures; - ScreenPriv->PostValidateTree = pScreen->PostValidateTree; + ScreenPriv->PostValidateTree = PostValidateTreeUndefined; ScreenPriv->ClipNotify = pScreen->ClipNotify; ScreenPriv->EnterVT = pScrn->EnterVT; ScreenPriv->LeaveVT = pScrn->LeaveVT; @@ -292,7 +294,6 @@ xf86XVScreenInit( pScreen->DestroyWindow = xf86XVDestroyWindow; pScreen->WindowExposures = xf86XVWindowExposures; - pScreen->PostValidateTree = xf86XVPostValidateTree; pScreen->ClipNotify = xf86XVClipNotify; pScrn->EnterVT = xf86XVEnterVT; pScrn->LeaveVT = xf86XVLeaveVT; @@ -1165,12 +1166,11 @@ xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind) xf86XVReputOrStopAllPorts(pScrn, TRUE); - if (ScreenPriv->PostValidateTree) { - pScreen->PostValidateTree = ScreenPriv->PostValidateTree; + pScreen->PostValidateTree = ScreenPriv->PostValidateTree; + if (pScreen->PostValidateTree) { (*pScreen->PostValidateTree)(pWin, pLayerWin, kind); - ScreenPriv->PostValidateTree = pScreen->PostValidateTree; - pScreen->PostValidateTree = xf86XVPostValidateTree; } + ScreenPriv->PostValidateTree = PostValidateTreeUndefined; } static void @@ -1247,6 +1247,11 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) pPriv->clipChanged = TRUE; + if (ScreenPriv->PostValidateTree == PostValidateTreeUndefined) { + ScreenPriv->PostValidateTree = pScreen->PostValidateTree; + pScreen->PostValidateTree = xf86XVPostValidateTree; + } + WinPriv = WinPriv->next; } @@ -1274,7 +1279,6 @@ xf86XVCloseScreen(int i, ScreenPtr pScreen) pScreen->DestroyWindow = ScreenPriv->DestroyWindow; pScreen->WindowExposures = ScreenPriv->WindowExposures; - pScreen->PostValidateTree = ScreenPriv->PostValidateTree; pScreen->ClipNotify = ScreenPriv->ClipNotify; pScrn->EnterVT = ScreenPriv->EnterVT; -- cgit v1.2.3 From 81892bf6b7e3730ebd19318183734f55dbaa5d4b Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Wed, 14 Apr 2010 21:34:39 +0100 Subject: Cygwin/X: Generate X keycodes for multimedia keys Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winkeybd.h | 14 +++++++------- hw/xwin/winkeynames.h | 13 +++++++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/hw/xwin/winkeybd.h b/hw/xwin/winkeybd.h index 5b2a5892f..662392be3 100644 --- a/hw/xwin/winkeybd.h +++ b/hw/xwin/winkeybd.h @@ -216,13 +216,13 @@ g_iKeyMap [] = { /* 170 */ 0, 0, 0, /* 171 */ 0, 0, 0, /* 172 */ 0, 0, 0, - /* 173 */ 0, 0, 0, - /* 174 */ 0, 0, 0, - /* 175 */ 0, 0, 0, - /* 176 */ 0, 0, 0, - /* 177 */ 0, 0, 0, - /* 178 */ 0, 0, 0, - /* 179 */ 0, 0, 0, + /* 173 */ VK_VOLUME_MUTE, 0, KEY_Mute, + /* 174 */ VK_VOLUME_DOWN, 0, KEY_AudioLower, + /* 175 */ VK_VOLUME_UP, 0, KEY_AudioRaise, + /* 176 */ VK_MEDIA_NEXT_TRACK, 0, KEY_NEXTSONG, + /* 177 */ VK_MEDIA_PREV_TRACK, 0, KEY_PREVIOUSSONG, + /* 178 */ VK_MEDIA_STOP, 0, KEY_STOPCD, + /* 179 */ VK_MEDIA_PLAY_PAUSE, 0, KEY_PLAYPAUSE, /* 180 */ 0, 0, 0, /* 181 */ 0, 0, 0, /* 182 */ 0, 0, 0, diff --git a/hw/xwin/winkeynames.h b/hw/xwin/winkeynames.h index 3d5938348..914016a76 100644 --- a/hw/xwin/winkeynames.h +++ b/hw/xwin/winkeynames.h @@ -23,10 +23,6 @@ * */ -#define XK_TECHNICAL -#define XK_KATAKANA -#include - #define GLYPHS_PER_KEY 4 #define NUM_KEYCODES 248 #define MIN_KEYCODE 8 @@ -194,6 +190,15 @@ #define KEY_HKTG /* Hirugana/Katakana tog 0xc8 */ 200 #define KEY_BSlash2 /* \ _ 0xcb */ 203 +#define KEY_Mute /* Audio Mute */ 152 +#define KEY_AudioLower /* Audio Lower */ 168 +#define KEY_AudioRaise /* Audio Raise */ 166 + +#define KEY_NEXTSONG /* Media next */ 145 +#define KEY_PLAYPAUSE /* Media play/pause toggle */ 154 +#define KEY_PREVIOUSSONG /* Media previous */ 136 +#define KEY_STOPCD /* Media stop */ 156 + /* These are for "notused" and "unknown" entries in translation maps. */ #define KEY_NOTUSED 0 #define KEY_UNKNOWN 255 -- cgit v1.2.3 From be3e5bb50178406e46368be00860331e1b6c4093 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Wed, 14 Apr 2010 21:45:29 +0100 Subject: Cygwin/X: Better keycode debugging output Replace useless #if 0/ErrorF/#endif with winDebug Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winkeybd.c | 8 ++++---- hw/xwin/winkeyhook.c | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c index 83fea21cd..9e5a9b02a 100644 --- a/hw/xwin/winkeybd.c +++ b/hw/xwin/winkeybd.c @@ -73,6 +73,8 @@ winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode) int iParam = HIWORD (lParam); int iParamScanCode = LOBYTE (iParam); + winDebug("winTranslateKey: wParam %08x lParam %08x\n", wParam, lParam); + /* WM_ key messages faked by Vista speech recognition (WSR) don't have a * scan code. * @@ -488,10 +490,8 @@ winSendKeyEvent (DWORD dwKey, Bool fDown) for (i = 0; i < nevents; i++) mieqEnqueue(g_pwinKeyboard, (InternalEvent*)events[i].event); -#if CYGDEBUG - ErrorF("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n", - dwKey, fDown, nevents); -#endif + winDebug("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n", + dwKey, fDown, nevents); } BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam) diff --git a/hw/xwin/winkeyhook.c b/hw/xwin/winkeyhook.c index fe1156dcf..cbee7cbda 100644 --- a/hw/xwin/winkeyhook.c +++ b/hw/xwin/winkeyhook.c @@ -88,9 +88,7 @@ winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam) /* Pass keystrokes on to our main message loop */ if (iCode == HC_ACTION) { -#if 0 - ErrorF ("vkCode: %08x\tscanCode: %08x\n", p->vkCode, p->scanCode); -#endif + winDebug("winKeyboardMessageHook: vkCode: %08x scanCode: %08x\n", p->vkCode, p->scanCode); switch (wParam) { -- cgit v1.2.3 From 57ca09441ee5ff2a8deb95eaa17a2625a756d912 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Thu, 1 Jul 2010 14:54:48 +0100 Subject: Cygwin/X: Update mapping for Canadian keyboard layouts 0x00000c0c "Canadian French (legacy)" => layout ca variant fr-legacy 0x00001009 "Canadian French" => layout ca variant fr 0x00011009 "Canadian Multilingual Standard" => layout ca variant multix Signed-off-by: Yaakov Selkowitz Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winlayouts.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/xwin/winlayouts.h b/hw/xwin/winlayouts.h index 9500689bc..288af193c 100644 --- a/hw/xwin/winlayouts.h +++ b/hw/xwin/winlayouts.h @@ -55,13 +55,15 @@ WinKBLayoutRec winKBLayouts[] = { 0x00010409, -1, "pc105", "dvorak", NULL, NULL, "English (USA,Dvorak)"}, { 0x00020409, -1, "pc105", "us_intl", NULL, NULL, "English (USA,International)"}, { 0x00000809, -1, "pc105", "gb", NULL, NULL, "English (United Kingdom)"}, + { 0x00001009, -1, "pc105", "ca", "fr", NULL, "French (Canada)"}, + { 0x00011009, -1, "pc105", "ca", "multix", NULL, "Canadian Multilingual Standard"}, { 0x00001809, -1, "pc105", "ie", NULL, NULL, "Irish"}, { 0x0000040a, -1, "pc105", "es", NULL, NULL, "Spanish (Spain,Traditional Sort)"}, { 0x0000080a, -1, "pc105", "latam", NULL, NULL, "Latin American"}, { 0x0000040b, -1, "pc105", "fi", NULL, NULL, "Finnish"}, { 0x0000040c, -1, "pc105", "fr", NULL, NULL, "French (Standard)"}, { 0x0000080c, -1, "pc105", "be", NULL, NULL, "French (Belgian)"}, - { 0x00000c0c, -1, "pc105", "ca", "fr", NULL, "French (Canada)"}, + { 0x00000c0c, -1, "pc105", "ca", "fr-legacy", NULL, "French (Canada, Legacy)"}, { 0x0000100c, -1, "pc105", "ch", "fr", NULL, "French (Switzerland)"}, { 0x0000040d, -1, "pc105", "il", NULL, NULL, "Hebrew"}, { 0x0000040e, -1, "pc105", "hu", NULL, NULL, "Hungarian"}, @@ -89,5 +91,3 @@ WinKBLayoutRec winKBLayouts[] = See http://technet.microsoft.com/en-us/library/cc766503%28WS.10%29.aspx for a listing of input locale (keyboard layout) codes */ - - -- cgit v1.2.3 From ae99a6f895a3a5b6f71e2dd4874cd4bb0235aff0 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sun, 18 Jul 2010 13:42:29 +0100 Subject: Cygwin/X: Make the keyboard layout detection logging a bit clearer Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winconfig.c | 77 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c index 758c54d89..76bf8e2de 100644 --- a/hw/xwin/winconfig.c +++ b/hw/xwin/winconfig.c @@ -240,6 +240,7 @@ Bool winConfigKeyboard (DeviceIntPtr pDevice) { char layoutName[KL_NAMELENGTH]; + unsigned char layoutFriendlyName[256]; static unsigned int layoutNum = 0; int keyboardType; #ifdef XWIN_XF86CONFIG @@ -299,11 +300,32 @@ winConfigKeyboard (DeviceIntPtr pDevice) if (LoadKeyboardLayout("00000409", KLF_ACTIVATE) != NULL) winMsg (X_INFO, "Loading US keyboard layout.\n"); else - winMsg (X_ERROR, "LoadKeyboardLaout failed.\n"); + winMsg (X_ERROR, "LoadKeyboardLayout failed.\n"); } } - winMsg (X_PROBED, "winConfigKeyboard - Layout: \"%s\" (%08x) \n", - layoutName, layoutNum); + + /* Discover the friendly name of the current layout */ + { + HKEY regkey = NULL; + const char regtempl[] = "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\"; + char *regpath; + DWORD namesize = sizeof(layoutFriendlyName); + + regpath = malloc(sizeof(regtempl) + KL_NAMELENGTH + 1); + strcpy(regpath, regtempl); + strcat(regpath, layoutName); + + if (!RegOpenKey(HKEY_LOCAL_MACHINE, regpath, ®key)) + RegQueryValueEx(regkey, "Layout Text", 0, NULL, layoutFriendlyName, &namesize); + + /* Close registry key */ + if (regkey) + RegCloseKey (regkey); + free(regpath); + } + + winMsg (X_PROBED, "Windows keyboard layout: \"%s\" (%08x) \"%s\", type %d\n", + layoutName, layoutNum, layoutFriendlyName, keyboardType); for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++) { @@ -311,46 +333,35 @@ winConfigKeyboard (DeviceIntPtr pDevice) continue; if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType) continue; - + bfound = TRUE; winMsg (X_PROBED, - "Using preset keyboard for \"%s\" (%x), type \"%d\"\n", - pLayout->layoutname, pLayout->winlayout, keyboardType); - + "Found matching XKB configuration \"%s\"\n", + pLayout->layoutname); + + winMsg(X_PROBED, + "Model = \"%s\" Layout = \"%s\"" + " Variant = \"%s\" Options = \"%s\"\n", + pLayout->xkbmodel ? pLayout->xkbmodel : "none", + pLayout->xkblayout ? pLayout->xkblayout : "none", + pLayout->xkbvariant ? pLayout->xkbvariant : "none", + pLayout->xkboptions ? pLayout->xkboptions : "none"); + g_winInfo.xkb.model = pLayout->xkbmodel; g_winInfo.xkb.layout = pLayout->xkblayout; g_winInfo.xkb.variant = pLayout->xkbvariant; - g_winInfo.xkb.options = pLayout->xkboptions; + g_winInfo.xkb.options = pLayout->xkboptions; + + break; } - + if (!bfound) { - HKEY regkey = NULL; - const char regtempl[] = - "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\"; - char *regpath; - unsigned char lname[256]; - DWORD namesize = sizeof(lname); - - regpath = malloc(sizeof(regtempl) + KL_NAMELENGTH + 1); - strcpy(regpath, regtempl); - strcat(regpath, layoutName); - - if (!RegOpenKey(HKEY_LOCAL_MACHINE, regpath, ®key) && - !RegQueryValueEx(regkey, "Layout Text", 0, NULL, lname, &namesize)) - { - winMsg (X_ERROR, - "Keyboardlayout \"%s\" (%s) is unknown\n", lname, layoutName); - } - - /* Close registry key */ - if (regkey) - RegCloseKey (regkey); - free(regpath); + winMsg (X_ERROR, "Keyboardlayout \"%s\" (%s) is unknown, using X server default layout\n", layoutFriendlyName, layoutName); } - } - + } + /* parse the configuration */ #ifdef XWIN_XF86CONFIG if (g_cmdline.keyboard) -- cgit v1.2.3 From e930aa7bbc7f04a128df8e6fd441aed5123a2eb6 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Tue, 14 Sep 2010 16:02:53 +0100 Subject: Cygwin/X: Add Turkish keyboard layouts to keyboard layout mapping table 0x0000041f "Turkish Q" => layout tr 0x0001041f "Turkish F" => layout tr variant f Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winlayouts.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/xwin/winlayouts.h b/hw/xwin/winlayouts.h index 288af193c..ce502a005 100644 --- a/hw/xwin/winlayouts.h +++ b/hw/xwin/winlayouts.h @@ -81,6 +81,8 @@ WinKBLayoutRec winKBLayouts[] = { 0x00000816, -1, "pc105", "pt", NULL, NULL, "Portuguese (Portugal)"}, { 0x0000041a, -1, "pc105", "hr", NULL, NULL, "Croatian"}, { 0x0000041d, -1, "pc105", "se", NULL, NULL, "Swedish (Sweden)"}, + { 0x0000041f, -1, "pc105", "tr", NULL, NULL, "Turkish (Q)"}, + { 0x0001041f, -1, "pc105", "tr", "f", NULL, "Turkish (F)"}, { 0x00000424, -1, "pc105", "si", NULL, NULL, "Slovenian"}, { 0x00000425, -1, "pc105", "ee", NULL, NULL, "Estonian"}, { 0x00000452, -1, "pc105", "gb", "intl", NULL, "United Kingdom (Extended)"}, -- cgit v1.2.3 From b421f5e5122dbe125a5629969cc657bd966b4261 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Thu, 1 Apr 2010 23:10:58 +0100 Subject: Cygwin/X: Ignore MappingNotify events sent to clipboard integration client Ignore MappingNotify events sent to clipboard integration client, xmodmap changes aren't of interest to it, but there is no mechanism to express that disinterest. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winclipboardxevents.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c index 2f042fd0b..8b502b117 100644 --- a/hw/xwin/winclipboardxevents.c +++ b/hw/xwin/winclipboardxevents.c @@ -789,6 +789,9 @@ winClipboardFlushXEvents (HWND hwnd, case PropertyNotify: break; + case MappingNotify: + break; + default: ErrorF ("winClipboardFlushXEvents - unexpected event type %d\n", event.type); break; -- cgit v1.2.3 From f6e4ace9eabea1bb2a06dd86b6ffb954917a74ce Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sun, 18 Jul 2010 13:24:48 +0100 Subject: Cygwin/X: Fix for Canadian Multilingual Standard keyboard layout handling Add a keycode mapping for VK_OEM_8 as RCtrl, which is issued by Canadian Multilingual Standard layout Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winkeybd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xwin/winkeybd.h b/hw/xwin/winkeybd.h index 662392be3..4e4c35c37 100644 --- a/hw/xwin/winkeybd.h +++ b/hw/xwin/winkeybd.h @@ -266,7 +266,7 @@ g_iKeyMap [] = { /* 220 */ 0, 0, 0, /* 221 */ 0, 0, 0, /* 222 */ 0, 0, 0, - /* 223 */ 0, 0, 0, + /* 223 */ VK_OEM_8, 0, KEY_RCtrl, /* at least on Candian Multilingual Standard layout */ /* 224 */ 0, 0, 0, /* 225 */ 0, 0, 0, /* 226 */ 0, 0, 0, -- cgit v1.2.3 From be186586e504197623c69637b8122fb814f59429 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 00:06:48 -0500 Subject: xf86vidmode: warning fix xf86VidMode.c: In function 'VidModeGetMonitorValue': xf86VidMode.c:637:19: warning: 'ret.i' may be used uninitialized in this function Reviewed-by: Matt Turner Reviewed-by: Julien Cristau Signed-off-by: Adam Jackson --- hw/xfree86/common/xf86VidMode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86VidMode.c b/hw/xfree86/common/xf86VidMode.c index 1788fa192..4dd454d8b 100644 --- a/hw/xfree86/common/xf86VidMode.c +++ b/hw/xfree86/common/xf86VidMode.c @@ -634,7 +634,7 @@ VidModeSetModeValue(pointer mode, int valtyp, int val) vidMonitorValue VidModeGetMonitorValue(pointer monitor, int valtyp, int indx) { - vidMonitorValue ret; + vidMonitorValue ret = { NULL, }; switch (valtyp) { case VIDMODE_MON_VENDOR: -- cgit v1.2.3 From f1b7c9cead94b520e6b96774d605d63d3f341b50 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 00:09:19 -0500 Subject: int10: warning fix helper_exec.c: In function 'pciCfg1in': helper_exec.c:507:4: warning: passing argument 2 of 'pci_device_cfg_read_u32' from incompatible pointer type /usr/include/pciaccess.h:153:5: note: expected 'uint32_t *' but argument is of type 'CARD32 *' Reviewed-by: Matt Turner Reviewed-by: Julien Cristau Signed-off-by: Adam Jackson --- hw/xfree86/int10/helper_exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c index b9af473b1..ec8420040 100644 --- a/hw/xfree86/int10/helper_exec.c +++ b/hw/xfree86/int10/helper_exec.c @@ -504,7 +504,7 @@ pciCfg1in(CARD16 addr, CARD32 *val) } if (addr == 0xCFC) { pci_device_cfg_read_u32(pci_device_for_cfg_address(PciCfg1Addr), - val, PCI_OFFSET(PciCfg1Addr)); + (uint32_t *)val, PCI_OFFSET(PciCfg1Addr)); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" cfg_inl(%#lx) = %8.8lx\n", PciCfg1Addr, *val); return 1; -- cgit v1.2.3 From ae16c5796fdb22fb6b2f680fe5123bfd2c89a825 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 00:14:11 -0500 Subject: fbdevhw: Remove the non-sysfs hack for mapping from PCI to fbdev It's broken for devices with BARs above 4G, and the sysfs method should work everywhere anyway. As a pleasant side effect, this fixes some warnings: fbdevhw.c: In function 'fbdev_open_pci': fbdevhw.c:333:4: warning: cast from pointer to integer of different size fbdevhw.c:334:4: warning: cast from pointer to integer of different size fbdevhw.c:336:4: warning: cast from pointer to integer of different size fbdevhw.c:337:4: warning: cast from pointer to integer of different size Reviewed-by: Matt Turner Reviewed-by: Julien Cristau Signed-off-by: Adam Jackson --- hw/xfree86/fbdevhw/fbdevhw.c | 56 ++------------------------------------------ 1 file changed, 2 insertions(+), 54 deletions(-) diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index a5b59e762..17fba36d0 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -264,14 +264,7 @@ fbdev_open_pci(struct pci_device * pPci, char **namep) { struct fb_fix_screeninfo fix; char filename[256]; - int fd,i,j; - - - /* There are two ways to that we can determine which fb device is - * associated with this PCI device. The more modern way is to look in - * the sysfs directory for the PCI device for a file named - * "graphics/fb*" - */ + int fd, i; for (i = 0; i < 8; i++) { sprintf(filename, @@ -304,55 +297,10 @@ fbdev_open_pci(struct pci_device * pPci, char **namep) } } - - /* The other way is to examine the resources associated with each fb - * device and see if there is a match with the PCI device. This technique - * has some problems on certain mixed 64-bit / 32-bit architectures. - * There is a flaw in the fb_fix_screeninfo structure in that it only - * returns the low 32-bits of the address of the resources associated with - * a device. However, on a mixed architecture the base addresses of PCI - * devices, even for 32-bit applications, may be higher than 0x0f0000000. - */ - - for (i = 0; i < 8; i++) { - sprintf(filename,"/dev/fb%d",i); - if (-1 == (fd = open(filename,O_RDWR,0))) { - xf86DrvMsg(-1, X_WARNING, - "open %s: %s\n", filename, strerror(errno)); - continue; - } - if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,(void*)&fix)) { - close(fd); - continue; - } - for (j = 0; j < 6; j++) { - const pciaddr_t res_start = pPci->regions[j].base_addr; - const pciaddr_t res_end = res_start + pPci->regions[j].size; - - if ((0 != fix.smem_len && - (pciaddr_t) fix.smem_start >= res_start && - (pciaddr_t) fix.smem_start < res_end) || - (0 != fix.mmio_len && - (pciaddr_t) fix.mmio_start >= res_start && - (pciaddr_t) fix.mmio_start < res_end)) - break; - } - if (j == 6) { - close(fd); - continue; - } - if (namep) { - *namep = xnfalloc(16); - strncpy(*namep,fix.id,16); - } - return fd; - } - if (namep) *namep = NULL; - xf86DrvMsg(-1, X_ERROR, - "Unable to find a valid framebuffer device\n"); + xf86DrvMsg(-1, X_ERROR, "Unable to find a valid framebuffer device\n"); return -1; } -- cgit v1.2.3 From 994b7b3dc97f9afa713fe636af45a78002a4366f Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 00:17:52 -0500 Subject: xfree86: warning fix Did you know that anonymous enums with function scope will not only override the enum values from global scope, but will be treated as entirely different types? C's type system just rules. xf86Crtc.c: In function 'handle_detailed_monrec': xf86Crtc.c:1555:33: warning: comparison between 'enum det_monrec_source' and 'enum ' xf86Crtc.c:1562:33: warning: comparison between 'enum det_monrec_source' and 'enum ' Reviewed-by: Matt Turner Reviewed-by: Julien Cristau Signed-off-by: Adam Jackson --- hw/xfree86/modes/xf86Crtc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 47d3ad14c..b5e9dc26f 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1542,7 +1542,6 @@ struct det_monrec_parameter { static void handle_detailed_monrec(struct detailed_monitor_section *det_mon, void *data) { - enum { sync_config, sync_edid, sync_default }; struct det_monrec_parameter *p; p = (struct det_monrec_parameter *)data; -- cgit v1.2.3 From 59d8e3cbdba032c7354c28c86cbd155e9da6447a Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 00:23:07 -0500 Subject: fb: Remove hw/xfree86/ from includes Reviewed-by: Matt Turner Reviewed-by: Julien Cristau Signed-off-by: Adam Jackson --- fb/Makefile.am | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fb/Makefile.am b/fb/Makefile.am index f9f34c44c..89f3babb1 100644 --- a/fb/Makefile.am +++ b/fb/Makefile.am @@ -1,9 +1,5 @@ noinst_LTLIBRARIES = libfb.la libwfb.la -INCLUDES = \ - -I$(top_srcdir)/hw/xfree86/os-support \ - -I$(top_srcdir)/hw/xfree86/os-support/bus \ - -I$(top_srcdir)/hw/xfree86/common AM_CFLAGS = $(DIX_CFLAGS) if XORG -- cgit v1.2.3 From 505defd270e49cfbcbe6a04d1de817d305edb3c2 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 00:24:20 -0500 Subject: damage: Remove hw/xfree86/ from includes Reviewed-by: Matt Turner Reviewed-by: Julien Cristau Signed-off-by: Adam Jackson --- miext/damage/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miext/damage/Makefile.am b/miext/damage/Makefile.am index 595835731..767a65aee 100644 --- a/miext/damage/Makefile.am +++ b/miext/damage/Makefile.am @@ -2,7 +2,7 @@ noinst_LTLIBRARIES = libdamage.la AM_CFLAGS = $(DIX_CFLAGS) -INCLUDES = -I$(srcdir)/../cw -I$(top_srcdir)/hw/xfree86/os-support +INCLUDES = -I$(srcdir)/../cw if XORG sdk_HEADERS = damage.h damagestr.h -- cgit v1.2.3 From 0c230728f3af2c4250e93a070c0851a597069447 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 00:25:57 -0500 Subject: rootless: Remove hw/xfree86/ from includes Reviewed-by: Matt Turner Reviewed-by: Julien Cristau Signed-off-by: Adam Jackson --- miext/rootless/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/miext/rootless/Makefile.am b/miext/rootless/Makefile.am index f09300d5c..c97bebebe 100644 --- a/miext/rootless/Makefile.am +++ b/miext/rootless/Makefile.am @@ -1,5 +1,4 @@ AM_CFLAGS = $(DIX_CFLAGS) $(XSERVER_CFLAGS) -AM_CPPFLAGS = -I$(top_srcdir)/hw/xfree86/os-support noinst_LTLIBRARIES = librootless.la librootless_la_SOURCES = \ -- cgit v1.2.3 From 93cd4b1034e3c8bed32c5acd391eadd7605e10f0 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 00:27:00 -0500 Subject: shadow: Remove hw/xfree86/ from includes Reviewed-by: Matt Turner Reviewed-by: Julien Cristau Signed-off-by: Adam Jackson --- miext/shadow/Makefile.am | 2 -- 1 file changed, 2 deletions(-) diff --git a/miext/shadow/Makefile.am b/miext/shadow/Makefile.am index a73d0ec78..30f7bda96 100644 --- a/miext/shadow/Makefile.am +++ b/miext/shadow/Makefile.am @@ -2,8 +2,6 @@ noinst_LTLIBRARIES = libshadow.la AM_CFLAGS = $(DIX_CFLAGS) -INCLUDES = -I$(top_srcdir)/hw/xfree86/os-support - if XORG sdk_HEADERS = shadow.h endif -- cgit v1.2.3 From 81daba8ce906bfbbe44cd71d0ff269ad34e2f6b5 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 31 Jan 2011 13:53:08 +1000 Subject: Xi: constify XIChangeDeviceProperty() We don't modify "value", make it official. Signed-off-by: Peter Hutterer Reviewed-by: Chase Douglas Signed-off-by: Ander Conselvan de Oliveira --- Xi/xiproperty.c | 2 +- include/exevents.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c index b9f53f7dc..17835e2cd 100644 --- a/Xi/xiproperty.c +++ b/Xi/xiproperty.c @@ -701,7 +701,7 @@ XIDeleteDeviceProperty (DeviceIntPtr device, Atom property, Bool fromClient) int XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type, int format, int mode, unsigned long len, - pointer value, Bool sendevent) + const pointer value, Bool sendevent) { XIPropertyPtr prop; int size_in_bytes; diff --git a/include/exevents.h b/include/exevents.h index dc594304f..2b226986b 100644 --- a/include/exevents.h +++ b/include/exevents.h @@ -69,7 +69,7 @@ extern _X_EXPORT int XIChangeDeviceProperty( int /* format*/, int /* mode*/, unsigned long /* len*/, - pointer /* value*/, + const pointer /* value*/, Bool /* sendevent*/ ); -- cgit v1.2.3 From 0ef5973860e17c5edc996c923610f7ad88b4dfbe Mon Sep 17 00:00:00 2001 From: Ander Conselvan de Oliveira Date: Tue, 8 Feb 2011 11:10:08 +0200 Subject: ProcRRQueryVersion: fix use of uninitialised bytes valgrind error. ==9999== Syscall param writev(vector[...]) points to uninitialised byte(s) ==9999== at 0x4AB5154: writev (writev.c:51) ==9999== by 0x7C7C3: _XSERVTransWritev (Xtrans.c:912) ==9999== by 0x61C8B: FlushClient (io.c:924) ==9999== by 0x62743: FlushAllOutput (io.c:668) ==9999== by 0x4AA5B: Dispatch (dispatch.c:453) ==9999== by 0x205BF: main (main.c:291) ==9999== Address 0x55711b9 is 1 bytes inside a block of size 4,096 alloc'd ==9999== at 0x48334A4: calloc (vg_replace_malloc.c:467) ==9999== by 0x62567: WriteToClient (io.c:1065) ==9999== by 0x452EB: ProcEstablishConnection (dispatch.c:3685) ==9999== by 0x4AB53: Dispatch (dispatch.c:432) ==9999== by 0x205BF: main (main.c:291) ==9999== Uninitialised value was created by a stack allocation ==9999== at 0x160E78: ProcRRQueryVersion (rrdispatch.c:37) Signed-off-by: Peter Hutterer Reviewed-by: Oliver McFadden Signed-off-by: Ander Conselvan de Oliveira --- randr/rrdispatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index aed746bac..b0b451c2a 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -35,7 +35,7 @@ RRClientKnowsRates (ClientPtr pClient) static int ProcRRQueryVersion (ClientPtr client) { - xRRQueryVersionReply rep; + xRRQueryVersionReply rep = {0}; register int n; REQUEST(xRRQueryVersionReq); rrClientPriv(client); -- cgit v1.2.3 From 87fbef9157a6f1e1318382e368d27942d7ad72ab Mon Sep 17 00:00:00 2001 From: Ander Conselvan de Oliveira Date: Tue, 8 Feb 2011 11:10:09 +0200 Subject: ProcRRCreateMode: fix use of uninitialised bytes valgrind error. ==543== Syscall param writev(vector[...]) points to uninitialised byte(s) ==543== at 0x4AB7154: writev (writev.c:51) ==543== by 0x8935B: _XSERVTransWritev (Xtrans.c:912) ==543== by 0x6C55F: FlushClient (io.c:924) ==543== by 0x6D013: FlushAllOutput (io.c:668) ==543== by 0x27A83: Dispatch (dispatch.c:453) ==543== by 0x205B7: main (main.c:291) ==543== Address 0x556dc8c is 12 bytes inside a block of size 4,096 alloc'd ==543== at 0x48334A4: calloc (vg_replace_malloc.c:467) ==543== by 0x6CE37: WriteToClient (io.c:1065) ==543== by 0x223A7: ProcEstablishConnection (dispatch.c:3685) ==543== by 0x27B7B: Dispatch (dispatch.c:432) ==543== by 0x205B7: main (main.c:291) ==543== Uninitialised value was created by a stack allocation ==543== at 0xA3350: ProcRRCreateMode (rrmode.c:289) Signed-off-by: Peter Hutterer Reviewed-by: Oliver McFadden Signed-off-by: Ander Conselvan de Oliveira --- randr/rrmode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/randr/rrmode.c b/randr/rrmode.c index 5ffa4006f..d7560dcb2 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -288,7 +288,7 @@ int ProcRRCreateMode (ClientPtr client) { REQUEST(xRRCreateModeReq); - xRRCreateModeReply rep; + xRRCreateModeReply rep = {0}; WindowPtr pWin; ScreenPtr pScreen; rrScrPrivPtr pScrPriv; -- cgit v1.2.3 From 8a34d7a8532c7ca013e67307f3baf200167abb92 Mon Sep 17 00:00:00 2001 From: Ander Conselvan de Oliveira Date: Tue, 8 Feb 2011 11:10:11 +0200 Subject: XkbSendNames: fix use of uninitialised bytes valgrind error. ==537== Syscall param writev(vector[...]) points to uninitialised byte(s) ==537== at 0x4AB7154: writev (writev.c:51) ==537== by 0x8935B: _XSERVTransWritev (Xtrans.c:912) ==537== by 0x6C55F: FlushClient (io.c:924) ==537== by 0x6CCF3: WriteToClient (io.c:846) ==537== by 0xD51D3: XkbSendNames (xkb.c:3765) ==537== by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825) ==537== by 0x27B7B: Dispatch (dispatch.c:432) ==537== by 0x205B7: main (main.c:291) ==537== Address 0x55899f2 is 154 bytes inside a block of size 1,896 alloc'd ==537== at 0x4834C48: malloc (vg_replace_malloc.c:236) ==537== by 0xD47AF: XkbSendNames (xkb.c:3642) ==537== by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825) ==537== by 0x27B7B: Dispatch (dispatch.c:432) ==537== by 0x205B7: main (main.c:291) ==537== Uninitialised value was created by a heap allocation ==537== at 0x4834C48: malloc (vg_replace_malloc.c:236) ==537== by 0xD47AF: XkbSendNames (xkb.c:3642) ==537== by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825) ==537== by 0x27B7B: Dispatch (dispatch.c:432) ==537== by 0x205B7: main (main.c:291) Signed-off-by: Peter Hutterer Reviewed-by: Oliver McFadden Signed-off-by: Ander Conselvan de Oliveira --- xkb/xkb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xkb/xkb.c b/xkb/xkb.c index 6fd66c5e5..a2cbbf315 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -3644,7 +3644,7 @@ register int n; swapl(&rep->indicators,n); } - start = desc = malloc(length); + start = desc = calloc(1, length); if ( !start ) return BadAlloc; if (xkb->names) { -- cgit v1.2.3 From 85f9017393c9bb19553e9afcf554673a44a09993 Mon Sep 17 00:00:00 2001 From: Ander Conselvan de Oliveira Date: Tue, 8 Feb 2011 11:10:10 +0200 Subject: ProcXkbGetXkbByName: fix use of uninitialised bytes valgrind error. ==9999== Syscall param writev(vector[...]) points to uninitialised byte(s) ==9999== at 0x4AB5154: writev (writev.c:51) ==9999== by 0x7C7C3: _XSERVTransWritev (Xtrans.c:912) ==9999== by 0x61C8B: FlushClient (io.c:924) ==9999== by 0x62423: WriteToClient (io.c:846) ==9999== by 0xCE39B: XkbSendMap (xkb.c:1408) ==9999== by 0xD247B: ProcXkbGetKbdByName (xkb.c:5814) ==9999== by 0x4AB53: Dispatch (dispatch.c:432) ==9999== by 0x205BF: main (main.c:291) ==9999== Address 0x557eb68 is 40 bytes inside a block of size 4,096 alloc'd ==9999== at 0x48334A4: calloc (vg_replace_malloc.c:467) ==9999== by 0x62567: WriteToClient (io.c:1065) ==9999== by 0x452EB: ProcEstablishConnection (dispatch.c:3685) ==9999== by 0x4AB53: Dispatch (dispatch.c:432) ==9999== by 0x205BF: main (main.c:291) ==9999== Uninitialised value was created by a stack allocation ==9999== at 0xD1910: ProcXkbGetKbdByName (xkb.c:5559) Signed-off-by: Peter Hutterer Reviewed-by: Oliver McFadden Signed-off-by: Ander Conselvan de Oliveira --- xkb/xkb.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xkb/xkb.c b/xkb/xkb.c index a2cbbf315..a57139f35 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -5569,13 +5569,13 @@ ProcXkbGetKbdByName(ClientPtr client) { DeviceIntPtr dev; DeviceIntPtr tmpd; - xkbGetKbdByNameReply rep; - xkbGetMapReply mrep; - xkbGetCompatMapReply crep; - xkbGetIndicatorMapReply irep; - xkbGetNamesReply nrep; - xkbGetGeometryReply grep; - XkbComponentNamesRec names; + xkbGetKbdByNameReply rep = {0}; + xkbGetMapReply mrep = {0}; + xkbGetCompatMapReply crep = {0}; + xkbGetIndicatorMapReply irep = {0}; + xkbGetNamesReply nrep = {0}; + xkbGetGeometryReply grep = {0}; + XkbComponentNamesRec names = {0}; XkbDescPtr xkb, new; unsigned char * str; char mapFile[PATH_MAX]; -- cgit v1.2.3 From 787ba25a8a3af52b38448a1a6f8c9704ea8b7905 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 7 Feb 2011 18:21:31 +0100 Subject: Xi: make XIQueryPointer return the current modifiers/group as documented. The previous XKB info was being returned instead of the current one, producing inconsistent results between the latest events and the modifiers/group returned by this call. Signed-off-by: Carlos Garnacho Reviewed-by: Daniel Stone Reviewed-by: Peter Hutterer ` Signed-off-by: Peter Hutterer --- Xi/xiquerypointer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c index b521c48ef..8df958ea2 100644 --- a/Xi/xiquerypointer.c +++ b/Xi/xiquerypointer.c @@ -129,7 +129,7 @@ ProcXIQueryPointer(ClientPtr client) if (kbd) { - state = &kbd->key->xkbInfo->prev_state; + state = &kbd->key->xkbInfo->state; rep.mods.base_mods = state->base_mods; rep.mods.latched_mods = state->latched_mods; rep.mods.locked_mods = state->locked_mods; -- cgit v1.2.3 From 47d1d2fed656c3a3b2600491078da90962c46934 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 10 Feb 2011 15:11:34 +1000 Subject: xkb: split out keymap compilation. Refactoring for simpler double-use in the next patch. No functional changes. Signed-off-by: Peter Hutterer Reviewed-by: Dan Nicholson --- xkb/ddxLoad.c | 55 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index 51b577725..b968c4360 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -425,35 +425,58 @@ XkbRF_RulesPtr rules; return complete; } -XkbDescPtr -XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet *rmlvo) +static Bool +XkbRMLVOtoKcCGST(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, XkbComponentNamesPtr kccgst) { - XkbComponentNamesRec kccgst; XkbRF_VarDefsRec mlvo; - XkbDescPtr xkb; - char name[PATH_MAX]; - - if (!dev || !rmlvo) { - LogMessage(X_ERROR, "XKB: No device or RMLVO specified\n"); - return NULL; - } mlvo.model = rmlvo->model; mlvo.layout = rmlvo->layout; mlvo.variant = rmlvo->variant; mlvo.options = rmlvo->options; - /* XDNFR already logs for us. */ - if (!XkbDDXNamesFromRules(dev, rmlvo->rules, &mlvo, &kccgst)) + return XkbDDXNamesFromRules(dev, rmlvo->rules, &mlvo, kccgst); +} + +/** + * Compile the given RMLVO keymap and return it. Returns the XkbDescPtr on + * success or NULL on failure. If the components compiled are not a superset + * or equal to need, the compiliation is treated as failure. + */ +static XkbDescPtr +XkbCompileKeymapForDevice(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, int need) +{ + XkbDescPtr xkb; + unsigned int provided; + XkbComponentNamesRec kccgst; + char name[PATH_MAX]; + + if (!XkbRMLVOtoKcCGST(dev, rmlvo, &kccgst)) return NULL; - /* XDLKBN too, but it might return 0 as well as allocating. */ - if (!XkbDDXLoadKeymapByNames(dev, &kccgst, XkmAllIndicesMask, 0, &xkb, name, - PATH_MAX)) { - if (xkb) + provided = XkbDDXLoadKeymapByNames(dev, &kccgst, XkmAllIndicesMask, need, + &xkb, name, PATH_MAX); + if ((need & provided) != need) { + if (xkb) { XkbFreeKeyboard(xkb, 0, TRUE); + xkb = NULL; + } + } + + return xkb; +} + +XkbDescPtr +XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet *rmlvo) +{ + XkbDescPtr xkb; + + if (!dev || !rmlvo) { + LogMessage(X_ERROR, "XKB: No device or RMLVO specified\n"); return NULL; } + xkb = XkbCompileKeymapForDevice(dev, rmlvo, 0); + return xkb; } -- cgit v1.2.3 From d3499556d8d83396fa2585bd00371a81e086be36 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 10 Feb 2011 15:12:14 +1000 Subject: xkb: if the keymap failed to compile, load the default keymap instead. We really need symbols, compat, keynames, vmods and types for a sensible keymap. Try this in your xorg.conf.d snippets for all keyboards: Option "XkbLayout" "us" Option "XkbVariant" "nodeadkeys" us(nodeadkeys) doesn't exist so xkbcomp provides everything but the symbols map. We say we want everything but don't _need_ anything, the server happily gives us a keymap with every key mapped to NoSymbol. This in turn isn't what we want after all. So instead, require symbols, compat, keynames, vmods and types from the keymap and if that fails, load the default keymap instead. If that fails too, all bets are off. Signed-off-by: Peter Hutterer Reviewed-by: Dan Nicholson --- xkb/ddxLoad.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index b968c4360..ac587fc9d 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -470,13 +470,34 @@ XkbDescPtr XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet *rmlvo) { XkbDescPtr xkb; + unsigned int need; if (!dev || !rmlvo) { LogMessage(X_ERROR, "XKB: No device or RMLVO specified\n"); return NULL; } - xkb = XkbCompileKeymapForDevice(dev, rmlvo, 0); + /* These are the components we really really need */ + need = XkmSymbolsMask | XkmCompatMapMask | XkmTypesMask | + XkmKeyNamesMask | XkmVirtualModsMask; + + + xkb = XkbCompileKeymapForDevice(dev, rmlvo, need); + + if (!xkb) { + XkbRMLVOSet dflts; + + /* we didn't get what we really needed. And that will likely leave + * us with a keyboard that doesn't work. Use the defaults instead */ + LogMessage(X_ERROR, "XKB: Failed to load keymap. Loading default " + "keymap instead.\n"); + + XkbGetRulesDflts(&dflts); + + xkb = XkbCompileKeymapForDevice(dev, &dflts, 0); + + XkbFreeRMLVOSet(&dflts, FALSE); + } return xkb; } -- cgit v1.2.3 From c9f7b303a36ca501c6ecf1196c266ee8e8f49d2d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Feb 2011 13:50:10 +1000 Subject: xfixes: calloc, not malloc the cursorScreenRec Debugging NULL pointers is significantly easier than random memory. Plus, if new fields (such as pointer barriers) are added they may just be properly initialised. Signed-off-by: Peter Hutterer Reviewed-by: Keith Packard --- xfixes/cursor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xfixes/cursor.c b/xfixes/cursor.c index 54e5d755e..fb608f694 100644 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -1045,7 +1045,7 @@ XFixesCursorInit (void) ScreenPtr pScreen = screenInfo.screens[i]; CursorScreenPtr cs; - cs = (CursorScreenPtr) malloc(sizeof (CursorScreenRec)); + cs = (CursorScreenPtr) calloc(1, sizeof (CursorScreenRec)); if (!cs) return FALSE; Wrap (cs, pScreen, CloseScreen, CursorCloseScreen); -- cgit v1.2.3 From a883cf1545abd89bb2cadfa659718884b56fd234 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Sun, 23 Jan 2011 17:05:26 +0100 Subject: glx: fix request length check for CreateGLXPbufferSGIX The request is followed by an attribute list. Signed-off-by: Julien Cristau Reviewed-by: Adam Jackson --- glx/glxcmds.c | 2 +- glx/glxcmdsswap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 3ef567d10..0b375c382 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1436,7 +1436,7 @@ int __glXDisp_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; - REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq); return DoCreatePbuffer(cl->client, req->screen, req->fbconfig, req->width, req->height, req->pbuffer); diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index 3bb4cade9..9d96c9de3 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -421,7 +421,7 @@ int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); -- cgit v1.2.3 From 1137c11be0f82049d28024eaf963c6f76e0d4334 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Wed, 26 Jan 2011 13:06:53 +0100 Subject: glx: fix BindTexImageEXT length check The request is followed by a list of attributes. X.Org bug#33449 Reported-and-tested-by: meng Signed-off-by: Julien Cristau Reviewed-by: Adam Jackson --- glx/glxcmds.c | 10 +++++++++- glx/glxcmdsswap.c | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 0b375c382..5d633dfc5 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1697,13 +1697,21 @@ int __glXDisp_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) GLXDrawable drawId; int buffer; int error; + CARD32 num_attribs; - REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len) + return BadLength; pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); buffer = *((INT32 *) (pc + 4)); + num_attribs = *((CARD32 *) (pc + 8)); + if (num_attribs > (UINT32_MAX >> 3)) { + client->errorValue = num_attribs; + return BadValue; + } + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 12 + (num_attribs << 3)); if (buffer != GLX_FRONT_LEFT_EXT) return __glXError(GLXBadPixmap); diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index 9d96c9de3..d58de6299 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -648,19 +648,23 @@ int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; + CARD32 *num_attribs; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len) + return BadLength; pc += __GLX_VENDPRIV_HDR_SIZE; drawId = ((GLXDrawable *) (pc)); buffer = ((int *) (pc + 4)); + num_attribs = ((CARD32 *) (pc + 8)); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); __GLX_SWAP_INT(drawId); __GLX_SWAP_INT(buffer); + __GLX_SWAP_INT(num_attribs); return __glXDisp_BindTexImageEXT(cl, (GLbyte *)pc); } -- cgit v1.2.3 From 402b329c3aa8ddbebaa1f593306a02d4cd6fed26 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Sun, 23 Jan 2011 13:35:54 +0100 Subject: glx: Work around wrong request lengths sent by mesa mesa used to send too long requests for GLXDestroyPixmap, GLXDestroyWindow, GLXChangeDrawableAttributes, GLXGetDrawableAttributes and GLXGetFBConfigsSGIX. Fixes a regression introduced in ec9c97c6bf70b523bc500bd3adf62176f1bb33a4 X.Org bug#33324 Reported-by: xunx.fang@intel.com Signed-off-by: Julien Cristau Reviewed-by: Adam Jackson --- glx/glxcmds.c | 19 +++++++++++++++---- glx/glxcmdsswap.c | 12 +++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 5d633dfc5..9b4bc9ec3 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1132,7 +1132,8 @@ int __glXDisp_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; - REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); + /* work around mesa bug, don't use REQUEST_SIZE_MATCH */ + REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq); return DoGetFBConfigs(cl, req->screen); } @@ -1356,7 +1357,9 @@ int __glXDisp_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXDestroyPixmapReq *req = (xGLXDestroyPixmapReq *) pc; - REQUEST_SIZE_MATCH(xGLXDestroyPixmapReq); + /* should be REQUEST_SIZE_MATCH, but mesa's glXDestroyPixmap used to set + * length to 3 instead of 2 */ + REQUEST_AT_LEAST_SIZE(xGLXDestroyPixmapReq); return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP); } @@ -1498,7 +1501,13 @@ int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) client->errorValue = req->numAttribs; return BadValue; } +#if 0 + /* mesa sends an additional 8 bytes */ REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); +#else + if (((sizeof(xGLXChangeDrawableAttributesReq) + (req->numAttribs << 3)) >> 2) < client->req_len) + return BadLength; +#endif return DoChangeDrawableAttributes(cl->client, req->drawable, req->numAttribs, (CARD32 *) (req + 1)); @@ -1563,7 +1572,8 @@ int __glXDisp_DestroyWindow(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; - REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + /* mesa's glXDestroyWindow used to set length to 3 instead of 2 */ + REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq); return DoDestroyDrawable(cl, req->glxwindow, GLX_DRAWABLE_WINDOW); } @@ -1872,7 +1882,8 @@ int __glXDisp_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; - REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + /* this should be REQUEST_SIZE_MATCH, but mesa sends an additional 4 bytes */ + REQUEST_AT_LEAST_SIZE(xGLXGetDrawableAttributesReq); return DoGetDrawableAttributes(cl, req->drawable); } diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index d58de6299..76e6fb629 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -279,7 +279,7 @@ int __glXDispSwap_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq); __GLX_SWAP_INT(&req->screen); return __glXDisp_GetFBConfigsSGIX(cl, pc); @@ -368,7 +368,7 @@ int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + REQUEST_AT_LEAST_SIZE(xGLXDestroyGLXPixmapReq); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->glxpixmap); @@ -476,7 +476,9 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) client->errorValue = req->numAttribs; return BadValue; } - REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); + if (((sizeof(xGLXChangeDrawableAttributesReq) + (req->numAttribs << 3)) >> 2) < client->req_len) + return BadLength; + attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -542,7 +544,7 @@ int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc) xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq); __GLX_SWAP_INT(&req->glxwindow); @@ -742,7 +744,7 @@ int __glXDispSwap_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + REQUEST_AT_LEAST_SIZE(xGLXGetDrawableAttributesReq); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); -- cgit v1.2.3 From 3bbb70a1a7b24d3d1375b20a13db7011cf961c86 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 16 Feb 2011 07:56:58 +1000 Subject: xfree86: fix up an out-of-date comment. InitInput simply initialises all input devices now. Signed-off-by: Peter Hutterer Reviewed-by: Keith Packard --- hw/xfree86/common/xf86Init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index a1fda54cd..e664ce451 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -808,7 +808,7 @@ InitInput(int argc, char **argv) GetEventList(&xf86Events); - /* Call the PreInit function for each input device instance. */ + /* Initialize all configured input devices */ for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) { /* Replace obsolete keyboard driver with kbd */ if (!xf86NameCmp((*pDev)->driver, "keyboard")) { -- cgit v1.2.3 From a73c28f0bdafb1c5cb8129179188a99c0ca052e2 Mon Sep 17 00:00:00 2001 From: Justin Dou Date: Thu, 10 Feb 2011 16:27:29 -0500 Subject: Replace malloc with calloc to initialize the buffers[] as NULL in do_get_buffers function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The calling for allocate_or_reuse_buffer may fail due to some reason, e.g. out of memory. If the buffers[] were not initialized to be NULL, the following err_out may try to access an illegal memory, which will cause X crash afterward. Reviewed-by: Kristian Høgsberg Signed-off-by: Justin Dou Signed-off-by: Keith Packard --- hw/xfree86/dri2/dri2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index 39996f946..9ca378fed 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -403,7 +403,7 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height, && (pDraw->height == pPriv->height) && (pPriv->serialNumber == DRI2DrawableSerial(pDraw)); - buffers = malloc((count + 1) * sizeof(buffers[0])); + buffers = calloc((count + 1), sizeof(buffers[0])); for (i = 0; i < count; i++) { const unsigned attachment = *(attachments++); -- cgit v1.2.3 From 443d75446bcbe7d97a23860a1e2d46c0b7e7cb26 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 18 Feb 2011 14:46:33 -0800 Subject: Version bumped to 1.9.99.902 (1.10 RC2) Signed-off-by: Keith Packard --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 9b3e2be2b..ac4bf8c74 100644 --- a/configure.ac +++ b/configure.ac @@ -26,8 +26,8 @@ dnl dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) -AC_INIT([xorg-server], 1.9.99.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) -RELEASE_DATE="2010-12-06" +AC_INIT([xorg-server], 1.9.99.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +RELEASE_DATE="2011-2-18" AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE -- cgit v1.2.3 From b4ef34d4664e0eaac7211f7a22a2025958aa1527 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Sun, 20 Feb 2011 11:59:41 +0100 Subject: Revert "exa/mixed: Exclude frontbuffer from deferred pixmap handling." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 541b25038a5de74411a094570b407c5ae018c2ba. - It turns out that the high latency was a driver problem. - catting a large amount of text turns out to look prettier when the throughput is lower, but it's not worth the loss for a minor improvement that may not even exist on someone else's computer. Reviewed-by: Michel Dänzer Signed-off-by: Maarten Maathuis Signed-off-by: Keith Packard --- exa/exa_migration_mixed.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/exa/exa_migration_mixed.c b/exa/exa_migration_mixed.c index 4f49905d3..fb4715135 100644 --- a/exa/exa_migration_mixed.c +++ b/exa/exa_migration_mixed.c @@ -138,7 +138,6 @@ void exaDamageReport_mixed(DamagePtr pDamage, RegionPtr pRegion, void *closure) { PixmapPtr pPixmap = closure; - ScreenPtr pScreen = pPixmap->drawable.pScreen; ExaPixmapPriv(pPixmap); /* Move back results of software rendering on system memory copy of mixed driver @@ -150,18 +149,10 @@ exaDamageReport_mixed(DamagePtr pDamage, RegionPtr pRegion, void *closure) if (!pExaPixmap->use_gpu_copy && exaPixmapHasGpuCopy(pPixmap)) { ExaScreenPriv(pPixmap->drawable.pScreen); - /* Front buffer: Don't wait for the block handler to copy back the data. - * This avoids annoying latency if you encounter a lot of software rendering. - */ - if (pPixmap == pScreen->GetScreenPixmap(pScreen)) - exaMoveInPixmap_mixed(pPixmap); - else { - if (pExaScr->deferred_mixed_pixmap && - pExaScr->deferred_mixed_pixmap != pPixmap) - exaMoveInPixmap_mixed(pExaScr->deferred_mixed_pixmap); - - pExaScr->deferred_mixed_pixmap = pPixmap; - } + if (pExaScr->deferred_mixed_pixmap && + pExaScr->deferred_mixed_pixmap != pPixmap) + exaMoveInPixmap_mixed(pExaScr->deferred_mixed_pixmap); + pExaScr->deferred_mixed_pixmap = pPixmap; } } -- cgit v1.2.3 From 4cdf1013771bc86fe2f6d9223bc4a46753bc918f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 21 Feb 2011 15:32:57 +1000 Subject: dix: a valuator number of 0 is valid (#34510) For all but motion and proximity events, having no valuators is ok. Regression from 1.9, keyboard events are not converted to protocol events. X.Org Bug 34510 Signed-off-by: Peter Hutterer Reviewed-by: Keith Packard Reviewed-by: Daniel Stone Tested-by: Timo Aaltonen --- dix/eventconvert.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 7b894f016..dd1ca460b 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -263,8 +263,20 @@ eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count) num_events = (countValuators(ev, &first) + 5)/6; /* valuator ev */ if (num_events <= 0) { - *count = 0; - return BadMatch; + switch (ev->type) + { + case ET_KeyPress: + case ET_KeyRelease: + case ET_ButtonPress: + case ET_ButtonRelease: + /* no axes is ok */ + break; + case ET_Motion: + case ET_ProximityIn: + case ET_ProximityOut: + *count = 0; + return BadMatch; + } } num_events++; /* the actual event event */ -- cgit v1.2.3 From 93a73993708b1345c86ec3ec06b02ed236595673 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 21 Feb 2011 15:40:40 +1000 Subject: test: write some event → XI1 conversion tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't test everything, but hey, life is short and I'm trying to have one. Signed-off-by: Peter Hutterer Reviewed-by: Keith Packard Reviewed-by: Daniel Stone --- test/input.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/test/input.c b/test/input.c index 879e14f2f..e0e9e6af7 100644 --- a/test/input.c +++ b/test/input.c @@ -36,6 +36,7 @@ #include "inputstr.h" #include "eventconvert.h" #include "exevents.h" +#include "exglobals.h" #include "dixgrabs.h" #include "eventstr.h" #include "inpututils.h" @@ -285,6 +286,143 @@ static void dix_event_to_core_conversion(void) dix_event_to_core(ET_Motion); } +static void +_dix_test_xi_convert(DeviceEvent *ev, int expected_rc, int expected_count) +{ + xEvent *xi; + int count = 0; + int rc; + + rc = EventToXI((InternalEvent*)ev, &xi, &count); + g_assert(rc == expected_rc); + g_assert(count >= expected_count); + if (count > 0){ + deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer*)xi; + g_assert(kbp->type == IEventBase + ev->type); + g_assert(kbp->detail == ev->detail.key); + g_assert(kbp->time == ev->time); + g_assert((kbp->deviceid & ~MORE_EVENTS) == ev->deviceid); + g_assert(kbp->root_x == ev->root_x); + g_assert(kbp->root_y == ev->root_y); + g_assert(kbp->state == ev->corestate); + g_assert(kbp->event_x == 0); + g_assert(kbp->event_y == 0); + g_assert(kbp->root == ev->root); + g_assert(kbp->event == 0); + g_assert(kbp->child == 0); + g_assert(kbp->same_screen == FALSE); + + while (--count > 0) { + deviceValuator *v = (deviceValuator*)&xi[count]; + g_assert(v->type == DeviceValuator); + g_assert(v->num_valuators <= 6); + } + + + free(xi); + } +} + +/** + * This tests for internal event → XI1 event conversion + * - all conversions should generate the right XI event type + * - right number of events generated + * - extra events are valuators + */ +static void dix_event_to_xi1_conversion(void) +{ + DeviceEvent ev = {0}; + int time; + int x, y; + int state; + int detail; + const int ROOT_WINDOW_ID = 0x100; + int deviceid; + + IEventBase = 80; + DeviceValuator = IEventBase - 1; + DeviceKeyPress = IEventBase + ET_KeyPress; + DeviceKeyRelease = IEventBase + ET_KeyRelease; + DeviceButtonPress = IEventBase + ET_ButtonPress; + DeviceButtonRelease = IEventBase + ET_ButtonRelease; + DeviceMotionNotify = IEventBase + ET_Motion; + DeviceFocusIn = IEventBase + ET_FocusIn; + DeviceFocusOut = IEventBase + ET_FocusOut; + ProximityIn = IEventBase + ET_ProximityIn; + ProximityOut = IEventBase + ET_ProximityOut; + + /* EventToXI callocs */ + x = 0; + y = 0; + time = 12345; + state = 0; + detail = 0; + deviceid = 4; + + ev.header = 0xFF; + + ev.header = 0xFF; + ev.length = sizeof(DeviceEvent); + ev.time = time; + ev.root_y = x; + ev.root_x = y; + SetBit(ev.valuators.mask, 0); + SetBit(ev.valuators.mask, 1); + ev.root = ROOT_WINDOW_ID; + ev.corestate = state; + ev.detail.key = detail; + ev.deviceid = deviceid; + + /* test all types for bad match */ + ev.type = ET_KeyPress; _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_KeyRelease; _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ButtonPress; _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ButtonRelease; _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_Motion; _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ProximityIn; _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ProximityOut; _dix_test_xi_convert(&ev, Success, 1); + + /* No axes */ + ClearBit(ev.valuators.mask, 0); + ClearBit(ev.valuators.mask, 1); + ev.type = ET_KeyPress; _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_KeyRelease; _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ButtonPress; _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ButtonRelease; _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_Motion; _dix_test_xi_convert(&ev, BadMatch, 0); + ev.type = ET_ProximityIn; _dix_test_xi_convert(&ev, BadMatch, 0); + ev.type = ET_ProximityOut; _dix_test_xi_convert(&ev, BadMatch, 0); + + /* more than 6 axes → 2 valuator events */ + SetBit(ev.valuators.mask, 0); + SetBit(ev.valuators.mask, 1); + SetBit(ev.valuators.mask, 2); + SetBit(ev.valuators.mask, 3); + SetBit(ev.valuators.mask, 4); + SetBit(ev.valuators.mask, 5); + SetBit(ev.valuators.mask, 6); + ev.type = ET_KeyPress; _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_KeyRelease; _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_ButtonPress; _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_ButtonRelease; _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_Motion; _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_ProximityIn; _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_ProximityOut; _dix_test_xi_convert(&ev, Success, 2); + + + /* keycode too high */ + ev.type = ET_KeyPress; + ev.detail.key = 256; + _dix_test_xi_convert(&ev, Success, 0); + + /* deviceid too high */ + ev.type = ET_KeyPress; + ev.detail.key = 18; + ev.deviceid = 128; + _dix_test_xi_convert(&ev, Success, 0); +} + + static void xi2_struct_sizes(void) { #define compare(req) \ @@ -1070,6 +1208,7 @@ int main(int argc, char** argv) g_test_add_func("/dix/input/attributes", dix_input_attributes); g_test_add_func("/dix/input/init-valuators", dix_init_valuators); g_test_add_func("/dix/input/event-core-conversion", dix_event_to_core_conversion); + g_test_add_func("/dix/input/event-xi1-conversion", dix_event_to_xi1_conversion); g_test_add_func("/dix/input/check-grab-values", dix_check_grab_values); g_test_add_func("/dix/input/xi2-struct-sizes", xi2_struct_sizes); g_test_add_func("/dix/input/grab_matching", dix_grab_matching); -- cgit v1.2.3 From 15fe86e69fc256342881112cd07565527e32435b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Feb 2011 11:01:19 +1000 Subject: mi: remove static GenerateEvent variable. Push into the respective devices. This should have no functional changes since we never warp more than one device at a time. In the glorious future with true multithreading, still the better thing to do. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- mi/mipointer.c | 9 +++++---- mi/mipointrst.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mi/mipointer.c b/mi/mipointer.c index 554397a3b..5ee456c71 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -220,15 +220,15 @@ miPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, *pTopLeftBox = *pHotBox; } -static Bool GenerateEvent; - static Bool miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, Bool generateEvent) { SetupScreen (pScreen); + miPointerPtr pPointer = MIPOINTER(pDev); + + pPointer->generateEvent = generateEvent; - GenerateEvent = generateEvent; /* device dependent - must pend signal and call miPointerWarpCursor */ (*pScreenPriv->screenFuncs->WarpCursor) (pDev, pScreen, x, y); if (!generateEvent) @@ -261,6 +261,7 @@ miPointerDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) pPointer->confined = FALSE; pPointer->x = 0; pPointer->y = 0; + pPointer->generateEvent = FALSE; if (!((*pScreenPriv->spriteFuncs->DeviceCursorInitialize)(pDev, pScreen))) { @@ -306,7 +307,7 @@ miPointerWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) changedScreen = TRUE; } - if (GenerateEvent) + if (pPointer->generateEvent) miPointerMove (pDev, pScreen, x, y); else miPointerMoveNoEvent(pDev, pScreen, x, y); diff --git a/mi/mipointrst.h b/mi/mipointrst.h index bd9c24a00..c912a17da 100644 --- a/mi/mipointrst.h +++ b/mi/mipointrst.h @@ -44,6 +44,7 @@ typedef struct { Bool confined; /* pointer can't change screens */ int x, y; /* hot spot location */ int devx, devy; /* sprite position */ + Bool generateEvent; /* generate an event during warping? */ } miPointerRec, *miPointerPtr; typedef struct { -- cgit v1.2.3 From d9987c8c45236bc9cfcaf716f4bfcac2a9d0e7e6 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Feb 2011 11:22:45 +1000 Subject: mi: Add a few comments explaining various cursor move functions. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- mi/mipointer.c | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 138 insertions(+), 15 deletions(-) diff --git a/mi/mipointer.c b/mi/mipointer.c index 5ee456c71..a3c26d030 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -23,6 +23,29 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ +/** + * @file + * This file contains functions to move the pointer on the screen and/or + * restrict its movement. These functions are divided into two sets: + * Screen-specific functions that are used as function pointers from other + * parts of the server (and end up heavily wrapped by e.g. animcur and + * xfixes): + * miPointerConstrainCursor + * miPointerCursorLimits + * miPointerDisplayCursor + * miPointerRealizeCursor + * miPointerUnrealizeCursor + * miPointerSetCursorPosition + * miRecolorCursor + * miPointerDeviceInitialize + * miPointerDeviceCleanup + * If wrapped, these are the last element in the wrapping chain. They may + * call into sprite-specific code through further function pointers though. + * + * The second type of functions are those that are directly called by the + * DIX, DDX and some drivers. + */ + #ifdef HAVE_DIX_CONFIG_H #include #endif @@ -126,6 +149,12 @@ miPointerInitialize (ScreenPtr pScreen, return TRUE; } +/** + * Destroy screen-specific information. + * + * @param index Screen index of the screen in screenInfo.screens[] + * @param pScreen The actual screen pointer + */ static Bool miPointerCloseScreen (int index, ScreenPtr pScreen) { @@ -201,6 +230,15 @@ miPointerDisplayCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) return TRUE; } +/** + * Set up the constraints for the given device. This function does not + * actually constrain the cursor but merely copies the given box to the + * internal constraint storage. + * + * @param pDev The device to constrain to the box + * @param pBox The rectangle to constrain the cursor to + * @param pScreen Used for copying screen confinement + */ static void miPointerConstrainCursor (DeviceIntPtr pDev, ScreenPtr pScreen, BoxPtr pBox) { @@ -212,7 +250,17 @@ miPointerConstrainCursor (DeviceIntPtr pDev, ScreenPtr pScreen, BoxPtr pBox) pPointer->confined = PointerConfinedToScreen(pDev); } -/*ARGSUSED*/ +/** + * Should calculate the box for the given cursor, based on screen and the + * confinement given. But we assume that whatever box is passed in is valid + * anyway. + * + * @param pDev The device to calculate the cursor limits for + * @param pScreen The screen the confinement happens on + * @param pCursor The screen the confinement happens on + * @param pHotBox The confinement box for the cursor + * @param[out] pTopLeftBox The new confinement box, always *pHotBox. + */ static void miPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, BoxPtr pHotBox, BoxPtr pTopLeftBox) @@ -220,6 +268,27 @@ miPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, *pTopLeftBox = *pHotBox; } +/** + * Set the device's cursor position to the x/y position on the given screen. + * Generates and event if required. + * + * This function is called from: + * - sprite init code to place onto initial position + * - the various WarpPointer implementations (core, XI, Xinerama, dmx,…) + * - during the cursor update path in CheckMotion + * - in the Xinerama part of NewCurrentScreen + * - when a RandR/RandR1.2 mode was applied (it may have moved the pointer, so + * it's set back to the original pos) + * + * @param pDev The device to move + * @param pScreen The screen the device is on + * @param x The x coordinate in per-screen coordinates + * @param y The y coordinate in per-screen coordinates + * @param generateEvent True if the pointer movement should generate an + * event. + * + * @return TRUE in all cases + */ static Bool miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, Bool generateEvent) @@ -236,9 +305,13 @@ miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen, return TRUE; } -/* Set up sprite information for the device. - This function will be called once for each device after it is initialized - in the DIX. +/** + * Set up sprite information for the device. + * This function will be called once for each device after it is initialized + * in the DIX. + * + * @param pDev The newly created device + * @param pScreen The initial sprite scree. */ static Bool miPointerDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) @@ -273,8 +346,12 @@ miPointerDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) return TRUE; } -/* Clean up after device. - This function will be called once before the device is freed in the DIX +/** + * Clean up after device. + * This function will be called once before the device is freed in the DIX + * + * @param pDev The device to be removed from the server + * @param pScreen Current screen of the device */ static void miPointerDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) @@ -290,7 +367,17 @@ miPointerDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) } -/* Once signals are ignored, the WarpCursor function can call this */ +/** + * Warp the pointer to the given position on the given screen. May generate + * an event, depending on whether we're coming from miPointerSetPosition. + * + * Once signals are ignored, the WarpCursor function can call this + * + * @param pDev The device to warp + * @param pScreen Screen to warp on + * @param x The x coordinate in per-screen coordinates + * @param y The y coordinate in per-screen coordinates + */ void miPointerWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) @@ -323,16 +410,11 @@ miPointerWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) UpdateSpriteForScreen (pDev, pScreen) ; } -/* - * Pointer/CursorDisplay interface routines - */ - -/* - * miPointerUpdateSprite +/** + * Syncronize the sprite with the cursor. * - * Syncronize the sprite with the cursor - called from ProcessInputEvents + * @param pDev The device to sync */ - void miPointerUpdateSprite (DeviceIntPtr pDev) { @@ -409,6 +491,14 @@ miPointerUpdateSprite (DeviceIntPtr pDev) } } +/** + * Set the device to the coordinates on the given screen. + * + * @param pDev The device to move + * @param screen_no Index of the screen to move to + * @param x The x coordinate in per-screen coordinates + * @param y The y coordinate in per-screen coordinates + */ void miPointerSetScreen(DeviceIntPtr pDev, int screen_no, int x, int y) { @@ -427,12 +517,18 @@ miPointerSetScreen(DeviceIntPtr pDev, int screen_no, int x, int y) pPointer->limits.y2 = pScreen->height; } +/** + * @return The current screen of the VCP + */ ScreenPtr miPointerCurrentScreen (void) { return miPointerGetScreen(inputInfo.pointer); } +/** + * @return The current screen of the given device or NULL. + */ ScreenPtr miPointerGetScreen(DeviceIntPtr pDev) { @@ -484,6 +580,18 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, pPointer->pScreen = pScreen; } +/** + * Set the devices' cursor position to the given x/y position. + * + * This function is called during the pointer update path in + * GetPointerEvents and friends (and the same in the xwin DDX). + * + * @param pDev The device to move + * @param[in,out] x The x coordiante in screen coordinates (in regards to total + * desktop size) + * @param[in,out] y The y coordiante in screen coordinates (in regards to total + * desktop size) + */ void miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y) { @@ -537,6 +645,12 @@ miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y) miPointerMoveNoEvent(pDev, pScreen, *x, *y); } +/** + * Get the current position of the device in desktop coordinates. + * + * @param x Return value for the current x coordinate in desktop coordiates. + * @param y Return value for the current y coordinate in desktop coordiates. + */ void miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y) { @@ -550,6 +664,15 @@ void darwinEvents_lock(void); void darwinEvents_unlock(void); #endif +/** + * Move the device's pointer to the x/y coordinates on the given screen. + * This function generates and enqueues pointer events. + * + * @param pDev The device to move + * @param pScreen The screen the device is on + * @param x The x coordinate in per-screen coordinates + * @param y The y coordinate in per-screen coordinates + */ void miPointerMove (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) { -- cgit v1.2.3 From 3a6160b408447ce620140849f962683a5d139cb9 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Feb 2011 11:40:01 +1000 Subject: mi: remove if 0 code. Note sure why this is in if 0 but it's been that way since 2007. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- mi/mipointer.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/mi/mipointer.c b/mi/mipointer.c index a3c26d030..124f9de4d 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -158,33 +158,8 @@ miPointerInitialize (ScreenPtr pScreen, static Bool miPointerCloseScreen (int index, ScreenPtr pScreen) { -#if 0 - miPointerPtr pPointer; - DeviceIntPtr pDev; -#endif - SetupScreen(pScreen); -#if 0 - for (pDev = inputInfo.devices; pDev; pDev = pDev->next) - { - if (DevHasCursor(pDev)) - { - pPointer = MIPOINTER(pDev); - - if (pScreen == pPointer->pScreen) - pPointer->pScreen = 0; - if (pScreen == pPointer->pSpriteScreen) - pPointer->pSpriteScreen = 0; - } - } - - if (MIPOINTER(inputInfo.pointer)->pScreen == pScreen) - MIPOINTER(inputInfo.pointer)->pScreen = 0; - if (MIPOINTER(inputInfo.pointer)->pSpriteScreen == pScreen) - MIPOINTER(inputInfo.pointer)->pSpriteScreen = 0; -#endif - pScreen->CloseScreen = pScreenPriv->CloseScreen; free((pointer) pScreenPriv); FreeEventList(events, GetMaximumEventsNum()); -- cgit v1.2.3 From c2a9e0a96983f22f721196513e75a53ea0b86d7e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Feb 2011 11:41:47 +1000 Subject: mi: simplify a "check for keyboard" condition Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- mi/mipointer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mi/mipointer.c b/mi/mipointer.c index 124f9de4d..aa0ca6d78 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -193,8 +193,7 @@ miPointerDisplayCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) miPointerPtr pPointer; /* return for keyboards */ - if ((IsMaster(pDev) && !DevHasCursor(pDev)) || - (!IsMaster(pDev) && pDev->u.master && !DevHasCursor(pDev->u.master))) + if (!IsPointerDevice(pDev)) return FALSE; pPointer = MIPOINTER(pDev); -- cgit v1.2.3 From d63c979c7fe0f2b114b27e73ebe0a706be8840ae Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Feb 2011 15:21:31 +1000 Subject: dix: replace direct master access with GetMaster and temp. device. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- dix/getevents.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dix/getevents.c b/dix/getevents.c index 794df420b..60282a826 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -866,10 +866,11 @@ positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac, miPointerSetPosition(dev, screenx, screeny); if (dev->u.master) { - dev->u.master->last.valuators[0] = *screenx; - dev->u.master->last.valuators[1] = *screeny; - dev->u.master->last.remainder[0] = *screenx_frac; - dev->u.master->last.remainder[1] = *screeny_frac; + DeviceIntPtr master = GetMaster(dev, MASTER_POINTER); + master->last.valuators[0] = *screenx; + master->last.valuators[1] = *screeny; + master->last.remainder[0] = *screenx_frac; + master->last.remainder[1] = *screeny_frac; } if (dev->valuator) -- cgit v1.2.3 From dc32a23890776edf575bf18b3f3c079da6214340 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Feb 2011 15:21:51 +1000 Subject: Fix two incorrect checks for master devices. These two were sideeffects of lastSlave being in the same field as the master. For devices generated by the master device directly, lastSlave was 0 and the device would (with the old checks) be interpreted as floating. Add the required checks to safeguard against master devices. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- Xi/exevents.c | 3 +++ mi/mieq.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index 327873e29..b39e202ff 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -710,6 +710,9 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce) if (rc != Success) return; /* Device has disappeared */ + if (IsMaster(slave)) + return; + if (!slave->u.master) return; /* set floating since the event */ diff --git a/mi/mieq.c b/mi/mieq.c index 01da52a6c..c0020c3c3 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -325,7 +325,7 @@ CopyGetMasterEvent(DeviceIntPtr sdev, CHECKEVENT(original); /* ET_XQuartz has sdev == NULL */ - if (!sdev || !sdev->u.master) + if (!sdev || IsMaster(sdev) || !sdev->u.master) return NULL; #if XFreeXDGA -- cgit v1.2.3 From 77af45ebc3eda32dc534968cab8d5adfb01bd9e3 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Feb 2011 12:48:30 +1000 Subject: dix: Simplify retrieving the master device. GetMaster() returns NULL for floating slaves. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- dix/events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/events.c b/dix/events.c index 07f8b05ea..4826781d7 100644 --- a/dix/events.c +++ b/dix/events.c @@ -4277,7 +4277,7 @@ DeviceEnterLeaveEvent( if (BitIsOn(mouse->button->down, i)) SetBit(&event[1], i); - kbd = (IsMaster(mouse) || mouse->u.master) ? GetPairedDevice(mouse) : NULL; + kbd = GetMaster(mouse, MASTER_KEYBOARD); if (kbd && kbd->key) { event->mods.base_mods = kbd->key->xkbInfo->state.base_mods; -- cgit v1.2.3 From 703baece7ebd128a6742d0523d5b3ebe65126fa5 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Feb 2011 12:19:26 +1000 Subject: dix: Add IsFloating(device) wrapper. Simplifies check for floating devices. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- dix/events.c | 7 +++++++ include/dix.h | 1 + 2 files changed, 8 insertions(+) diff --git a/dix/events.c b/dix/events.c index 4826781d7..f6d92cf6a 100644 --- a/dix/events.c +++ b/dix/events.c @@ -328,6 +328,13 @@ IsMaster(DeviceIntPtr dev) return dev->type == MASTER_POINTER || dev->type == MASTER_KEYBOARD; } +Bool +IsFloating(DeviceIntPtr dev) +{ + return GetMaster(dev, MASTER_KEYBOARD) == NULL; +} + + /** * Max event opcode. */ diff --git a/include/dix.h b/include/dix.h index 12e4b5977..3f99098a2 100644 --- a/include/dix.h +++ b/include/dix.h @@ -570,6 +570,7 @@ extern Bool _X_EXPORT IsPointerDevice( DeviceIntPtr dev); extern Bool _X_EXPORT IsKeyboardDevice(DeviceIntPtr dev); extern Bool IsPointerEvent(InternalEvent *event); extern _X_EXPORT Bool IsMaster(DeviceIntPtr dev); +extern _X_EXPORT Bool IsFloating(DeviceIntPtr dev); extern _X_HIDDEN void CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master); extern _X_HIDDEN int CorePointerProc(DeviceIntPtr dev, int what); -- cgit v1.2.3 From e48bf3b6403dde33586ca0e421db61e402525453 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Feb 2011 11:11:57 +1000 Subject: xfree86: replace two inputInfo.pointer uses with device loops. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- hw/xfree86/common/xf86RandR.c | 37 ++++++++++++++++++++++++++++++------- hw/xfree86/modes/xf86RandR12.c | 36 +++++++++++++++++++++++++++++------- 2 files changed, 59 insertions(+), 14 deletions(-) diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c index d7ffff4ca..4663d0366 100644 --- a/hw/xfree86/common/xf86RandR.c +++ b/hw/xfree86/common/xf86RandR.c @@ -242,11 +242,20 @@ xf86RandRSetConfig (ScreenPtr pScreen, ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); DisplayModePtr mode; - int px, py; + int pos[MAXDEVICES][2]; Bool useVirtual = FALSE; Rotation oldRotation = randrp->rotation; + DeviceIntPtr dev; + Bool view_adjusted = FALSE; + + for (dev = inputInfo.devices; dev; dev = dev->next) + { + if (!IsMaster(dev) && !IsFloating(dev)) + continue; + + miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]); + } - miPointerGetPosition(inputInfo.pointer, &px, &py); for (mode = scrp->modes; ; mode = mode->next) { if (mode->HDisplay == pSize->width && @@ -303,17 +312,31 @@ xf86RandRSetConfig (ScreenPtr pScreen, } return FALSE; } + /* * Move the cursor back where it belongs; SwitchMode repositions it + * FIXME: duplicated code, see modes/xf86RandR12.c */ - if (pScreen == miPointerCurrentScreen ()) + for (dev = inputInfo.devices; dev; dev = dev->next) { - px = (px >= pScreen->width ? (pScreen->width - 1) : px); - py = (py >= pScreen->height ? (pScreen->height - 1) : py); + if (!IsMaster(dev) && !IsFloating(dev)) + continue; - xf86SetViewport(pScreen, px, py); + if (pScreen == miPointerGetScreen(dev)) { + int px = pos[dev->id][0]; + int py = pos[dev->id][1]; - (*pScreen->SetCursorPosition) (inputInfo.pointer, pScreen, px, py, FALSE); + px = (px >= pScreen->width ? (pScreen->width - 1) : px); + py = (py >= pScreen->height ? (pScreen->height - 1) : py); + + /* Setting the viewpoint makes only sense on one device */ + if (!view_adjusted && IsMaster(dev)) { + xf86SetViewport(pScreen, px, py); + view_adjusted = TRUE; + } + + (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE); + } } return TRUE; diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 407bf3567..82d180bb0 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -584,10 +584,12 @@ xf86RandR12SetConfig (ScreenPtr pScreen, ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); DisplayModePtr mode; - int px, py; + int pos[MAXDEVICES][2]; Bool useVirtual = FALSE; int maxX = 0, maxY = 0; Rotation oldRotation = randrp->rotation; + DeviceIntPtr dev; + Bool view_adjusted = FALSE; randrp->rotation = rotation; @@ -597,7 +599,14 @@ xf86RandR12SetConfig (ScreenPtr pScreen, randrp->virtualY = scrp->virtualY; } - miPointerGetPosition (inputInfo.pointer, &px, &py); + for (dev = inputInfo.devices; dev; dev = dev->next) + { + if (!IsMaster(dev) && !IsFloating(dev)) + continue; + + miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]); + } + for (mode = scrp->modes; ; mode = mode->next) { if (randrp->maxX == 0 || randrp->maxY == 0) @@ -643,15 +652,28 @@ xf86RandR12SetConfig (ScreenPtr pScreen, /* * Move the cursor back where it belongs; SwitchMode repositions it + * FIXME: duplicated code, see modes/xf86RandR12.c */ - if (pScreen == miPointerGetScreen(inputInfo.pointer)) + for (dev = inputInfo.devices; dev; dev = dev->next) { - px = (px >= pScreen->width ? (pScreen->width - 1) : px); - py = (py >= pScreen->height ? (pScreen->height - 1) : py); + if (!IsMaster(dev) && !IsFloating(dev)) + continue; - xf86SetViewport(pScreen, px, py); + if (pScreen == miPointerGetScreen(dev)) { + int px = pos[dev->id][0]; + int py = pos[dev->id][1]; - (*pScreen->SetCursorPosition) (inputInfo.pointer, pScreen, px, py, FALSE); + px = (px >= pScreen->width ? (pScreen->width - 1) : px); + py = (py >= pScreen->height ? (pScreen->height - 1) : py); + + /* Setting the viewpoint makes only sense on one device */ + if (!view_adjusted && IsMaster(dev)) { + xf86SetViewport(pScreen, px, py); + view_adjusted = TRUE; + } + + (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE); + } } return TRUE; -- cgit v1.2.3 From dc57f89959e549403f8488eb9f23425bd7118b22 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 11 Feb 2011 12:47:37 +1000 Subject: Switch to use IsFloating() This is not a straightforward search/replacement due to a long-standing issue. dev->u.master is the same field as dev->u.lastSlave. Thus, if dev is a master device, a check for dev->u.master may give us false positives and false negatives. The switch to IsFloating() spells out these cases and modifies the conditions accordingly to cover both cases. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- Xi/exevents.c | 6 +++--- Xi/xipassivegrab.c | 10 ++-------- Xi/xiquerydevice.c | 2 +- Xi/xiquerypointer.c | 2 +- Xi/xiwarppointer.c | 2 +- dix/devices.c | 8 ++++---- dix/events.c | 6 +++--- dix/getevents.c | 6 +++--- dix/inpututils.c | 2 +- mi/mieq.c | 6 +++--- mi/mipointer.c | 4 ++-- mi/misprite.c | 16 ++++++++-------- xkb/xkb.c | 2 +- xkb/xkbAccessX.c | 2 +- xkb/xkbActions.c | 6 +++--- 15 files changed, 37 insertions(+), 43 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index b39e202ff..ea9daa905 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -713,7 +713,7 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce) if (IsMaster(slave)) return; - if (!slave->u.master) + if (IsFloating(slave)) return; /* set floating since the event */ if (slave->u.master->id != dce->masterid) @@ -1009,7 +1009,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device) b = device->button; k = device->key; - if (IsMaster(device) || !device->u.master) + if (IsMaster(device) || IsFloating(device)) CheckMotion(event, device); switch (event->type) @@ -1226,7 +1226,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, DeviceIntPtr mouse; int btlen, len, i; - mouse = (IsMaster(dev) || dev->u.master) ? GetMaster(dev, MASTER_POINTER) : dev; + mouse = IsFloating(dev) ? dev : GetMaster(dev, MASTER_POINTER); /* XI 2 event */ btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0; diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c index e99b6e554..8663d12a1 100644 --- a/Xi/xipassivegrab.c +++ b/Xi/xipassivegrab.c @@ -162,10 +162,7 @@ ProcXIPassiveGrabDevice(ClientPtr client) if (!modifiers_failed) return BadAlloc; - if (!IsMaster(dev) && dev->u.master) - mod_dev = GetMaster(dev, MASTER_KEYBOARD); - else - mod_dev = dev; + mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD); for (i = 0; i < stuff->num_modifiers; i++, modifiers++) { @@ -280,10 +277,7 @@ ProcXIPassiveUngrabDevice(ClientPtr client) if (rc != Success) return rc; - if (!IsMaster(dev) && dev->u.master) - mod_dev = GetMaster(dev, MASTER_KEYBOARD); - else - mod_dev = dev; + mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD); tempGrab.resource = client->clientAsMask; tempGrab.device = dev; diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index fdd2c051d..3cad8d7f1 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -383,7 +383,7 @@ int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment) DeviceIntPtr paired = GetPairedDevice(dev); use = IsPointerDevice(dev) ? XIMasterPointer : XIMasterKeyboard; *attachment = (paired ? paired->id : 0); - } else if (master) + } else if (!IsFloating(dev)) { use = IsPointerDevice(master) ? XISlavePointer : XISlaveKeyboard; *attachment = master->id; diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c index 8df958ea2..51317994b 100644 --- a/Xi/xiquerypointer.c +++ b/Xi/xiquerypointer.c @@ -93,7 +93,7 @@ ProcXIQueryPointer(ClientPtr client) } if (pDev->valuator == NULL || IsKeyboardDevice(pDev) || - (!IsMaster(pDev) && pDev->u.master)) /* no attached devices */ + (!IsMaster(pDev) && !IsFloating(pDev))) /* no attached devices */ { client->errorValue = stuff->deviceid; return BadDevice; diff --git a/Xi/xiwarppointer.c b/Xi/xiwarppointer.c index c01b115f3..a463ab94d 100644 --- a/Xi/xiwarppointer.c +++ b/Xi/xiwarppointer.c @@ -97,7 +97,7 @@ ProcXIWarpPointer(ClientPtr client) return rc; } - if ((!IsMaster(pDev) && pDev->u.master) || + if ((!IsMaster(pDev) && !IsFloating(pDev)) || (IsMaster(pDev) && !IsPointerDevice(pDev))) { client->errorValue = stuff->deviceid; diff --git a/dix/devices.c b/dix/devices.c index 6c0dc42a4..a3367f7b8 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -987,7 +987,7 @@ CloseDownDevices(void) */ for (dev = inputInfo.devices; dev; dev = dev->next) { - if (!IsMaster(dev) && dev->u.master) + if (!IsMaster(dev) && !IsFloating(dev)) dev->u.master = NULL; } @@ -2397,11 +2397,11 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) return BadDevice; /* set from floating to floating? */ - if (!dev->u.master && !master && dev->enabled) + if (IsFloating(dev) && !master && dev->enabled) return Success; /* free the existing sprite. */ - if (!dev->u.master && dev->spriteInfo->paired == dev) + if (IsFloating(dev) && dev->spriteInfo->paired == dev) { screen = miPointerGetScreen(dev); screen->DeviceCursorCleanup(dev, screen); @@ -2459,7 +2459,7 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) DeviceIntPtr GetPairedDevice(DeviceIntPtr dev) { - if (!IsMaster(dev) && dev->u.master) + if (!IsMaster(dev) && !IsFloating(dev)) dev = dev->u.master; return dev->spriteInfo->paired; diff --git a/dix/events.c b/dix/events.c index f6d92cf6a..b0e52f1c4 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1404,7 +1404,7 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, Bool thisMode, Bool otherMode) static void DetachFromMaster(DeviceIntPtr dev) { - if (!dev->u.master) + if (!IsFloating(dev)) return; dev->saved_master_id = dev->u.master->id; @@ -2806,7 +2806,7 @@ WindowsRestructured(void) DeviceIntPtr pDev = inputInfo.devices; while(pDev) { - if (IsMaster(pDev) || !pDev->u.master) + if (IsMaster(pDev) || IsFloating(pDev)) CheckMotion(NULL, pDev); pDev = pDev->next; } @@ -3401,7 +3401,7 @@ CheckPassiveGrabsOnWindow( * attached master keyboard. Since the slave may have been * reattached after the grab, the modifier device may not be the * same. */ - if (!IsMaster(grab->device) && device->u.master) + if (!IsMaster(grab->device) && !IsFloating(device)) gdev = GetMaster(device, MASTER_KEYBOARD); } diff --git a/dix/getevents.c b/dix/getevents.c index 60282a826..5b8e3798d 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -767,7 +767,7 @@ moveRelative(DeviceIntPtr dev, int *x, int *y, ValuatorMask *mask) /* if attached, clip both x and y to the defined limits (usually * co-ord space limit). If it is attached, we need x/y to go over the * limits to be able to change screens. */ - if(dev->u.master && dev->valuator) { + if(dev->valuator && IsMaster(dev) || !IsFloating(dev)) { if (valuator_get_mode(dev, 0) == Absolute) clipAxis(dev, 0, x); if (valuator_get_mode(dev, 1) == Absolute) @@ -865,7 +865,7 @@ positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac, * to the current screen. */ miPointerSetPosition(dev, screenx, screeny); - if (dev->u.master) { + if(!IsMaster(dev) || !IsFloating(dev)) { DeviceIntPtr master = GetMaster(dev, MASTER_POINTER); master->last.valuators[0] = *screenx; master->last.valuators[1] = *screeny; @@ -912,7 +912,7 @@ updateHistory(DeviceIntPtr dev, ValuatorMask *mask, CARD32 ms) return; updateMotionHistory(dev, ms, mask, dev->last.valuators); - if (dev->u.master) + if(!IsMaster(dev) || !IsFloating(dev)) { DeviceIntPtr master = GetMaster(dev, MASTER_POINTER); updateMotionHistory(master, ms, mask, dev->last.valuators); diff --git a/dix/inpututils.c b/dix/inpututils.c index ef3142c84..8b7b03523 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -273,7 +273,7 @@ change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *modkeymap, do_modmap_change(client, tmp, modmap); } } - else if (dev->u.master && dev->u.master->u.lastSlave == dev) { + else if (!IsFloating(dev) && dev->u.master->u.lastSlave == dev) { /* If this fails, expect the results to be weird. */ if (check_modmap_change(client, dev->u.master, modmap)) do_modmap_change(client, dev->u.master, modmap); diff --git a/mi/mieq.c b/mi/mieq.c index c0020c3c3..6853103a5 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -325,7 +325,7 @@ CopyGetMasterEvent(DeviceIntPtr sdev, CHECKEVENT(original); /* ET_XQuartz has sdev == NULL */ - if (!sdev || IsMaster(sdev) || !sdev->u.master) + if (!sdev || IsMaster(sdev) || IsFloating(sdev)) return NULL; #if XFreeXDGA @@ -410,7 +410,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, handler(screenNum, event, dev); /* Check for the SD's master in case the device got detached * during event processing */ - if (master && dev->u.master) + if (master && !IsFloating(dev)) handler(screenNum, &mevent, master); } else { @@ -419,7 +419,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, /* Check for the SD's master in case the device got detached * during event processing */ - if (master && dev->u.master) + if (master && !IsFloating(dev)) master->public.processInputProc(&mevent, master); } } diff --git a/mi/mipointer.c b/mi/mipointer.c index aa0ca6d78..5b8297880 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -73,7 +73,7 @@ DevPrivateKeyRec miPointerScreenKeyRec; DevPrivateKeyRec miPointerPrivKeyRec; #define MIPOINTER(dev) \ - ((!IsMaster(dev) && !dev->u.master) ? \ + (IsFloating(dev) ? \ (miPointerPtr)dixLookupPrivate(&(dev)->devPrivates, miPointerPrivKey): \ (miPointerPtr)dixLookupPrivate(&(GetMaster(dev, MASTER_POINTER))->devPrivates, miPointerPrivKey)) @@ -332,7 +332,7 @@ miPointerDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) { SetupScreen(pScreen); - if (!IsMaster(pDev) && pDev->u.master) + if (!IsMaster(pDev) && !IsFloating(pDev)) return; (*pScreenPriv->spriteFuncs->DeviceCursorCleanup)(pDev, pScreen); diff --git a/mi/misprite.c b/mi/misprite.c index 770951e8f..b0290af29 100644 --- a/mi/misprite.c +++ b/mi/misprite.c @@ -143,7 +143,7 @@ typedef struct { #endif #define MISPRITE(dev) \ - ((!IsMaster(dev) && !dev->u.master) ? \ + (IsFloating(dev) ? \ (miCursorInfoPtr)dixLookupPrivate(&dev->devPrivates, miSpriteDevPrivatesKey) : \ (miCursorInfoPtr)dixLookupPrivate(&(GetMaster(dev, MASTER_POINTER))->devPrivates, miSpriteDevPrivatesKey)) @@ -766,7 +766,7 @@ miSpriteRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { miCursorInfoPtr pCursorInfo; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return FALSE; pCursorInfo = MISPRITE(pDev); @@ -790,7 +790,7 @@ miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, miCursorInfoPtr pPointer; miSpriteScreenPtr pScreenPriv; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; pPointer = MISPRITE(pDev); @@ -848,7 +848,7 @@ miSpriteMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) { CursorPtr pCursor; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; pCursor = MISPRITE(pDev)->pCursor; @@ -905,7 +905,7 @@ miSpriteRemoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen) miCursorInfoPtr pCursorInfo; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; DamageDrawInternal (pScreen, TRUE); @@ -944,7 +944,7 @@ miSpriteSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen) CursorPtr pCursor; miCursorInfoPtr pCursorInfo; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; DamageDrawInternal (pScreen, TRUE); @@ -985,7 +985,7 @@ miSpriteRestoreCursor (DeviceIntPtr pDev, ScreenPtr pScreen) CursorPtr pCursor; miCursorInfoPtr pCursorInfo; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; DamageDrawInternal (pScreen, TRUE); @@ -1025,7 +1025,7 @@ miSpriteComputeSaved (DeviceIntPtr pDev, ScreenPtr pScreen) CursorPtr pCursor; miCursorInfoPtr pCursorInfo; - if (!IsMaster(pDev) && !pDev->u.master) + if (IsFloating(pDev)) return; pCursorInfo = MISPRITE(pDev); diff --git a/xkb/xkb.c b/xkb/xkb.c index a57139f35..4557350bf 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -5883,7 +5883,7 @@ ProcXkbGetKbdByName(ClientPtr client) nkn.changed|= XkbNKN_GeometryMask; XkbSendNewKeyboardNotify(dev,&nkn); - if (!IsMaster(dev) && dev->u.master) + if (!IsMaster(dev) && !IsFloating(dev)) { DeviceIntPtr master = dev->u.master; if (master->u.lastSlave == dev) diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c index 10c38ca47..12fe2a1f5 100644 --- a/xkb/xkbAccessX.c +++ b/xkb/xkbAccessX.c @@ -694,7 +694,7 @@ ProcessInputProc backupproc; xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse); DeviceEvent *event = &ev->device_event; - dev = (IsMaster(mouse) || mouse->u.master) ? GetMaster(mouse, MASTER_KEYBOARD) : mouse; + dev = IsFloating(mouse) ? mouse : GetMaster(mouse, MASTER_KEYBOARD); if (dev && dev->key) { diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 8d7c124e8..eda409c07 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -1367,7 +1367,7 @@ InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags, Valuat mpointer = GetMaster(dev, MASTER_POINTER); lastSlave = mpointer->u.lastSlave; ptr = GetXTestDevice(mpointer); - } else if (!dev->u.master) + } else if (IsFloating(dev)) ptr = dev; else return; @@ -1397,7 +1397,7 @@ XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y) int gpe_flags = 0; /* ignore attached SDs */ - if (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) != NULL) + if (!IsMaster(dev) && !IsFloating(dev)) return; if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY) @@ -1427,7 +1427,7 @@ XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button) if (IsMaster(dev)) { DeviceIntPtr mpointer = GetMaster(dev, MASTER_POINTER); ptr = GetXTestDevice(mpointer); - } else if (!dev->u.master) + } else if (IsFloating(dev)) ptr = dev; else return; -- cgit v1.2.3 From df6559237a2d641b2fc38d14975beab9bae0d971 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 18 Feb 2011 11:30:10 +1000 Subject: dix: add MASTER_ATTACHED as allowed type for GetMaster(). In some cases, we don't know/care whether we want the master pointer or keyboard for a device. Add a new type MASTER_ATTACHED to return the master this device is attached to. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- dix/devices.c | 7 +++++-- include/inputstr.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index a3367f7b8..8be1903eb 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2473,7 +2473,10 @@ GetPairedDevice(DeviceIntPtr dev) * returned master is either the device itself or the paired master device. * If dev is a floating slave device, NULL is returned. * - * @type ::MASTER_KEYBOARD or ::MASTER_POINTER + * @type ::MASTER_KEYBOARD or ::MASTER_POINTER or ::MASTER_ATTACHED + * @return The requested master device. In the case of MASTER_ATTACHED, this + * is the directly attached master to this device, regardless of the type. + * Otherwise, it is either the master keyboard or pointer for this device. */ DeviceIntPtr GetMaster(DeviceIntPtr dev, int which) @@ -2485,7 +2488,7 @@ GetMaster(DeviceIntPtr dev, int which) else master = dev->u.master; - if (master) + if (master && which != MASTER_ATTACHED) { if (which == MASTER_KEYBOARD) { diff --git a/include/inputstr.h b/include/inputstr.h index b74ee0454..58d318fd6 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -493,6 +493,7 @@ typedef struct _SpriteInfoRec { #define MASTER_POINTER 1 #define MASTER_KEYBOARD 2 #define SLAVE 3 +#define MASTER_ATTACHED 4 /* special type for GetMaster */ typedef struct _DeviceIntRec { DeviceRec public; -- cgit v1.2.3 From febce8cb814df46018f6ae1e6a9daea019b8ad0a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 18 Feb 2011 11:32:28 +1000 Subject: Xi: replace a direct master access with GetMaster() Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- Xi/exevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index ea9daa905..0df65791a 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -869,7 +869,7 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) * event being delivered through the slave first */ for (sd = inputInfo.devices; sd; sd = sd->next) { - if (IsMaster(sd) || sd->u.master != device) + if (IsMaster(sd) || GetMaster(sd, MASTER_POINTER) != device) continue; if (!sd->button) continue; -- cgit v1.2.3 From e1ac704185dee31b427a46cd41a00ef7a28b4129 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 18 Feb 2011 11:42:09 +1000 Subject: dix: fix up a master check in ChangeKeyboardMapping handling. We don't just care about the directly attached master, we care about the master keyboard. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- dix/devices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/devices.c b/dix/devices.c index 8be1903eb..f7018d0d1 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -1664,7 +1664,7 @@ ProcChangeKeyboardMapping(ClientPtr client) stuff->keyCodes, NULL, client); for (tmp = inputInfo.devices; tmp; tmp = tmp->next) { - if (IsMaster(tmp) || tmp->u.master != pDev) + if (IsMaster(tmp) || GetMaster(tmp, MASTER_KEYBOARD) != pDev) continue; if (!tmp->key) continue; -- cgit v1.2.3 From ce7f79efd588899f01c74f95c2f58d6dd6d816cd Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 18 Feb 2011 11:53:06 +1000 Subject: dix: fix a master device access in change_modmap. We need to check if our master keyboard is the given device since we may be a pointer with keys and thus need to change the modmap too. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- dix/inpututils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dix/inpututils.c b/dix/inpututils.c index 8b7b03523..abeabf229 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -268,12 +268,12 @@ change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *modkeymap, /* Change any attached masters/slaves. */ if (IsMaster(dev)) { for (tmp = inputInfo.devices; tmp; tmp = tmp->next) { - if (!IsMaster(tmp) && tmp->u.master == dev) + if (!IsMaster(tmp) && GetMaster(tmp, MASTER_KEYBOARD) == dev) if (check_modmap_change_slave(client, dev, tmp, modmap)) do_modmap_change(client, tmp, modmap); } } - else if (!IsFloating(dev) && dev->u.master->u.lastSlave == dev) { + else if (!IsFloating(dev) && GetMaster(dev, MASTER_KEYBOARD)->u.lastSlave == dev) { /* If this fails, expect the results to be weird. */ if (check_modmap_change(client, dev->u.master, modmap)) do_modmap_change(client, dev->u.master, modmap); -- cgit v1.2.3 From d270f12a3e44f4ea01f176a86783e8cd4c59ddf7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 18 Feb 2011 11:55:51 +1000 Subject: xfree86: update GetMaster check for the VCP. Same result, but now also triggers on slave keyboards that send pointer events. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- hw/xfree86/ramdac/xf86Cursor.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index ec781aad8..24c91cc37 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -317,8 +317,7 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs, /* only update for VCP, otherwise we get cursor jumps when removing a sprite. The second cursor is never HW rendered anyway. */ - if (pDev == inputInfo.pointer || - (!IsMaster(pDev) && pDev->u.master == inputInfo.pointer)) + if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer) { pCurs->refcnt++; if (ScreenPriv->CurrentCursor) @@ -386,8 +385,7 @@ xf86CursorMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) /* only update coordinate state for first sprite, otherwise we get jumps when removing a sprite. The second sprite is never HW rendered anyway */ - if (pDev == inputInfo.pointer || - (!IsMaster(pDev) && pDev->u.master == inputInfo.pointer)) + if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer) { ScreenPriv->x = x; ScreenPriv->y = y; -- cgit v1.2.3 From 52c13896ce9a1e178d4eeed15f68020947cc20ed Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 18 Feb 2011 11:57:06 +1000 Subject: mi: update macro to search for MASTER_POINTER Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- mi/midispcur.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mi/midispcur.c b/mi/midispcur.c index 48feb8823..9b3e87a57 100644 --- a/mi/midispcur.c +++ b/mi/midispcur.c @@ -76,7 +76,7 @@ typedef struct { #define miGetDCDevice(dev, screen) \ ((DevHasCursor(dev)) ? \ (miDCBufferPtr)dixLookupScreenPrivate(&dev->devPrivates, miDCDeviceKey, screen) : \ - (miDCBufferPtr)dixLookupScreenPrivate(&dev->u.master->devPrivates, miDCDeviceKey, screen)) + (miDCBufferPtr)dixLookupScreenPrivate(&GetMaster(dev, MASTER_POINTER)->devPrivates, miDCDeviceKey, screen)) /* * The core pointer buffer will point to the index of the virtual core pointer -- cgit v1.2.3 From 0ba526deeb4d54ee1a75400291ee7a3673ed4d96 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 18 Feb 2011 12:04:46 +1000 Subject: mi: check for MASTER_POINTER instead of manual checks. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- mi/mipointer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mi/mipointer.c b/mi/mipointer.c index 5b8297880..209ea06be 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -540,7 +540,7 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, * VCP, as this may cause a non-HW rendered cursor to be rendered during * SIGIO. This again leads to allocs during SIGIO which leads to SIGABRT. */ - if ((pDev == inputInfo.pointer || (!IsMaster(pDev) && pDev->u.master == inputInfo.pointer)) + if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer && !pScreenPriv->waitForUpdate && pScreen == pPointer->pSpriteScreen) { pPointer->devx = x; -- cgit v1.2.3 From 2936635698619271a790004480a14285149277cb Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 18 Feb 2011 12:06:56 +1000 Subject: xkb: Fix a check for MASTER_KEYBOARD And copy into the master keyboard, not just the directly attached device. Signed-off-by: Peter Hutterer Reviewed-by: Daniel Stone Reviewed-by: Benjamin Tissoires --- xkb/xkb.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xkb/xkb.c b/xkb/xkb.c index 4557350bf..22417533e 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -5883,12 +5883,10 @@ ProcXkbGetKbdByName(ClientPtr client) nkn.changed|= XkbNKN_GeometryMask; XkbSendNewKeyboardNotify(dev,&nkn); - if (!IsMaster(dev) && !IsFloating(dev)) - { - DeviceIntPtr master = dev->u.master; - if (master->u.lastSlave == dev) - { - XkbCopyDeviceKeymap(dev->u.master, dev); + if (!IsMaster(dev)) { + DeviceIntPtr master = GetMaster(dev, MASTER_KEYBOARD); + if (master && master->u.lastSlave == dev) { + XkbCopyDeviceKeymap(master, dev); XkbSendNewKeyboardNotify(dev,&nkn); } } -- cgit v1.2.3 From 77113dd3eef03dd65b556b672d976817b3f4542e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 18 Feb 2011 11:45:29 +1000 Subject: input: Change a bunch of direct dev->u.master accesses to use GetMaster() Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- Xi/exevents.c | 2 +- Xi/xichangehierarchy.c | 4 ++-- Xi/xiquerydevice.c | 2 +- dix/devices.c | 10 +++++----- dix/events.c | 4 ++-- mi/mieq.c | 10 ++++++---- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index 0df65791a..736896092 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -716,7 +716,7 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce) if (IsFloating(slave)) return; /* set floating since the event */ - if (slave->u.master->id != dce->masterid) + if (GetMaster(slave, MASTER_ATTACHED)->id != dce->masterid) return; /* not our slave anymore, don't care */ /* FIXME: we probably need to send a DCE for the new slave now */ diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c index b9cdedf77..6683f6a5c 100644 --- a/Xi/xichangehierarchy.c +++ b/Xi/xichangehierarchy.c @@ -282,12 +282,12 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r, for (attached = inputInfo.devices; attached; attached = attached->next) { if (!IsMaster(attached)) { - if (attached->u.master == ptr) + if (GetMaster(attached, MASTER_ATTACHED) == ptr) { AttachDevice(client, attached, newptr); flags[attached->id] |= XISlaveAttached; } - if (attached->u.master == keybd) + if (GetMaster(attached, MASTER_ATTACHED) == keybd) { AttachDevice(client, attached, newkeybd); flags[attached->id] |= XISlaveAttached; diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index 3cad8d7f1..8b5421130 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -375,7 +375,7 @@ SwapValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info) int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment) { - DeviceIntPtr master = dev->u.master; + DeviceIntPtr master = GetMaster(dev, MASTER_ATTACHED); int use; if (IsMaster(dev)) diff --git a/dix/devices.c b/dix/devices.c index f7018d0d1..058f32b05 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -446,7 +446,7 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent) { for (other = inputInfo.devices; other; other = other->next) { - if (other->u.master == dev) + if (!IsMaster(other) && GetMaster(other, MASTER_ATTACHED) == dev) { AttachDevice(NULL, other, NULL); flags[other->id] |= XISlaveDetached; @@ -2327,7 +2327,7 @@ RecalculateMasterButtons(DeviceIntPtr slave) for (dev = inputInfo.devices; dev; dev = dev->next) { if (IsMaster(dev) || - dev->u.master != master || + GetMaster(dev, MASTER_ATTACHED) != master || !dev->button) continue; @@ -2408,8 +2408,8 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) free(dev->spriteInfo->sprite); } - oldmaster = dev->u.master; - dev->u.master = master; + oldmaster = GetMaster(dev, MASTER_ATTACHED); + dev->master = master; /* If device is set to floating, we need to create a sprite for it, * otherwise things go bad. However, we don't want to render the cursor, @@ -2460,7 +2460,7 @@ DeviceIntPtr GetPairedDevice(DeviceIntPtr dev) { if (!IsMaster(dev) && !IsFloating(dev)) - dev = dev->u.master; + dev = GetMaster(dev, MASTER_ATTACHED); return dev->spriteInfo->paired; } diff --git a/dix/events.c b/dix/events.c index b0e52f1c4..8b3bfb791 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1407,7 +1407,7 @@ DetachFromMaster(DeviceIntPtr dev) if (!IsFloating(dev)) return; - dev->saved_master_id = dev->u.master->id; + dev->saved_master_id = GetMaster(dev, MASTER_ATTACHED)->id; AttachDevice(NULL, dev, NULL); } @@ -3237,7 +3237,7 @@ ProcWarpPointer(ClientPtr client) dev = PickPointer(client); for (tmp = inputInfo.devices; tmp; tmp = tmp->next) { - if ((tmp == dev) || (!IsMaster(tmp) && tmp->u.master == dev)) { + if (GetMaster(tmp, MASTER_ATTACHED) == dev) { rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixWriteAccess); if (rc != Success) return rc; diff --git a/mi/mieq.c b/mi/mieq.c index 6853103a5..a3e60855d 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -321,6 +321,7 @@ CopyGetMasterEvent(DeviceIntPtr sdev, DeviceIntPtr mdev; int len = original->any.length; int type = original->any.type; + int mtype; /* which master type? */ CHECKEVENT(original); @@ -337,20 +338,21 @@ CopyGetMasterEvent(DeviceIntPtr sdev, { case ET_KeyPress: case ET_KeyRelease: - mdev = GetMaster(sdev, MASTER_KEYBOARD); + mtype = MASTER_KEYBOARD; break; case ET_ButtonPress: case ET_ButtonRelease: case ET_Motion: case ET_ProximityIn: case ET_ProximityOut: - mdev = GetMaster(sdev, MASTER_POINTER); + mtype = MASTER_POINTER; break; default: - mdev = sdev->u.master; + mtype = MASTER_ATTACHED; break; } + mdev = GetMaster(sdev, mtype); memcpy(copy, original, len); ChangeDeviceID(mdev, copy); FixUpEventForMaster(mdev, sdev, original, copy); @@ -466,7 +468,7 @@ mieqProcessInputEvents(void) pthread_mutex_unlock(&miEventQueueMutex); #endif - master = (dev && !IsMaster(dev) && dev->u.master) ? dev->u.master : NULL; + master = (dev) ? GetMaster(dev, MASTER_ATTACHED) : NULL; if (screenIsSaved == SCREEN_SAVER_ON) dixSaveScreens (serverClient, SCREEN_SAVER_OFF, ScreenSaverReset); -- cgit v1.2.3 From 17265ccb027e3f956bf7409106174f44621d1cb8 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 18 Feb 2011 12:28:43 +1000 Subject: Move master/lastSlave out of the union into separate fields. The removal of the double-use will cause some suble bugs as some conditions to check for the dev->u.master case were broken and also evaluated as true if lastSlave was set (instead of master). Also breaks the input ABI. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- dix/devices.c | 12 ++++++------ dix/events.c | 4 ++-- dix/inpututils.c | 6 +++--- include/inputstr.h | 6 ++---- mi/mieq.c | 2 +- test/xi2/protocol-xiquerypointer.c | 2 +- test/xi2/protocol-xiwarppointer.c | 2 +- xkb/xkb.c | 2 +- xkb/xkbActions.c | 2 +- 9 files changed, 18 insertions(+), 20 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index 058f32b05..8fb06bbfa 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -457,8 +457,8 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent) { for (other = inputInfo.devices; other; other = other->next) { - if (IsMaster(other) && other->u.lastSlave == dev) - other->u.lastSlave = NULL; + if (IsMaster(other) && other->lastSlave == dev) + other->lastSlave = NULL; } } @@ -988,7 +988,7 @@ CloseDownDevices(void) for (dev = inputInfo.devices; dev; dev = dev->next) { if (!IsMaster(dev) && !IsFloating(dev)) - dev->u.master = NULL; + dev->master = NULL; } CloseDeviceList(&inputInfo.devices); @@ -2486,7 +2486,7 @@ GetMaster(DeviceIntPtr dev, int which) if (IsMaster(dev)) master = dev; else - master = dev->u.master; + master = dev->master; if (master && which != MASTER_ATTACHED) { @@ -2541,7 +2541,7 @@ AllocDevicePair (ClientPtr client, char* name, pointer->coreEvents = TRUE; pointer->spriteInfo->spriteOwner = TRUE; - pointer->u.lastSlave = NULL; + pointer->lastSlave = NULL; pointer->last.slave = NULL; pointer->type = (master) ? MASTER_POINTER : SLAVE; @@ -2567,7 +2567,7 @@ AllocDevicePair (ClientPtr client, char* name, keyboard->coreEvents = TRUE; keyboard->spriteInfo->spriteOwner = FALSE; - keyboard->u.lastSlave = NULL; + keyboard->lastSlave = NULL; keyboard->last.slave = NULL; keyboard->type = (master) ? MASTER_KEYBOARD : SLAVE; diff --git a/dix/events.c b/dix/events.c index 8b3bfb791..f39d8a90b 100644 --- a/dix/events.c +++ b/dix/events.c @@ -3244,8 +3244,8 @@ ProcWarpPointer(ClientPtr client) } } - if (dev->u.lastSlave) - dev = dev->u.lastSlave; + if (dev->lastSlave) + dev = dev->lastSlave; pSprite = dev->spriteInfo->sprite; #ifdef PANORAMIX diff --git a/dix/inpututils.c b/dix/inpututils.c index abeabf229..077ffce01 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -273,10 +273,10 @@ change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *modkeymap, do_modmap_change(client, tmp, modmap); } } - else if (!IsFloating(dev) && GetMaster(dev, MASTER_KEYBOARD)->u.lastSlave == dev) { + else if (!IsFloating(dev) && GetMaster(dev, MASTER_KEYBOARD)->lastSlave == dev) { /* If this fails, expect the results to be weird. */ - if (check_modmap_change(client, dev->u.master, modmap)) - do_modmap_change(client, dev->u.master, modmap); + if (check_modmap_change(client, dev->master, modmap)) + do_modmap_change(client, dev->master, modmap); } return Success; diff --git a/include/inputstr.h b/include/inputstr.h index 58d318fd6..4c67e3dea 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -530,10 +530,8 @@ typedef struct _DeviceIntRec { PrivateRec *devPrivates; DeviceUnwrapProc unwrapProc; SpriteInfoPtr spriteInfo; - union { - DeviceIntPtr master; /* master device */ - DeviceIntPtr lastSlave; /* last slave device used */ - } u; + DeviceIntPtr master; /* master device */ + DeviceIntPtr lastSlave; /* last slave device used */ /* last valuator values recorded, not posted to client; * for slave devices, valuators is in device coordinates diff --git a/mi/mieq.c b/mi/mieq.c index a3e60855d..08a0c8758 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -402,7 +402,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, master = CopyGetMasterEvent(dev, event, &mevent); if (master) - master->u.lastSlave = dev; + master->lastSlave = dev; /* If someone's registered a custom event handler, let them * steal it. */ diff --git a/test/xi2/protocol-xiquerypointer.c b/test/xi2/protocol-xiquerypointer.c index 810c61575..a42d59515 100644 --- a/test/xi2/protocol-xiquerypointer.c +++ b/test/xi2/protocol-xiquerypointer.c @@ -185,7 +185,7 @@ static void test_XIQueryPointer(void) request_XIQueryPointer(&client_request, &request, BadDevice); test_data.dev = devices.mouse; - devices.mouse->u.master = NULL; /* Float, kind-of */ + devices.mouse->master = NULL; /* Float, kind-of */ request.deviceid = devices.mouse->id; request_XIQueryPointer(&client_request, &request, Success); diff --git a/test/xi2/protocol-xiwarppointer.c b/test/xi2/protocol-xiwarppointer.c index 4f8860ea0..75b7617a0 100644 --- a/test/xi2/protocol-xiwarppointer.c +++ b/test/xi2/protocol-xiwarppointer.c @@ -145,7 +145,7 @@ static void test_XIWarpPointer(void) request.deviceid = devices.kbd->id; request_XIWarpPointer(&client_request, &request, BadDevice); - devices.mouse->u.master = NULL; /* Float, kind-of */ + devices.mouse->master = NULL; /* Float, kind-of */ request.deviceid = devices.mouse->id; request_XIWarpPointer(&client_request, &request, Success); diff --git a/xkb/xkb.c b/xkb/xkb.c index 22417533e..15831591d 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -5885,7 +5885,7 @@ ProcXkbGetKbdByName(ClientPtr client) if (!IsMaster(dev)) { DeviceIntPtr master = GetMaster(dev, MASTER_KEYBOARD); - if (master && master->u.lastSlave == dev) { + if (master && master->lastSlave == dev) { XkbCopyDeviceKeymap(master, dev); XkbSendNewKeyboardNotify(dev,&nkn); } diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index eda409c07..65c678af8 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -1365,7 +1365,7 @@ InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags, Valuat if (IsMaster(dev)) { mpointer = GetMaster(dev, MASTER_POINTER); - lastSlave = mpointer->u.lastSlave; + lastSlave = mpointer->lastSlave; ptr = GetXTestDevice(mpointer); } else if (IsFloating(dev)) ptr = dev; -- cgit v1.2.3