xfixes: use embedded private instead of pointer
The private struct is pretty small and it needs to be allocated anyways, so save an extra allocation by directly embedding it. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
bd8b8481da
commit
1c3150f507
|
@ -123,8 +123,6 @@ typedef struct _CursorScreen {
|
||||||
} CursorScreenRec, *CursorScreenPtr;
|
} CursorScreenRec, *CursorScreenPtr;
|
||||||
|
|
||||||
#define GetCursorScreen(s) ((CursorScreenPtr)dixLookupPrivate(&(s)->devPrivates, CursorScreenPrivateKey))
|
#define GetCursorScreen(s) ((CursorScreenPtr)dixLookupPrivate(&(s)->devPrivates, CursorScreenPrivateKey))
|
||||||
#define GetCursorScreenIfSet(s) GetCursorScreen(s)
|
|
||||||
#define SetCursorScreen(s,p) dixSetPrivate(&(s)->devPrivates, CursorScreenPrivateKey, p)
|
|
||||||
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
|
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
|
||||||
#define Unwrap(as,s,elt,backup) (((backup) = (s)->elt), (s)->elt = (as)->elt)
|
#define Unwrap(as,s,elt,backup) (((backup) = (s)->elt), (s)->elt = (as)->elt)
|
||||||
|
|
||||||
|
@ -196,16 +194,14 @@ static Bool
|
||||||
CursorCloseScreen(ScreenPtr pScreen)
|
CursorCloseScreen(ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
CursorScreenPtr cs = GetCursorScreen(pScreen);
|
CursorScreenPtr cs = GetCursorScreen(pScreen);
|
||||||
Bool ret;
|
|
||||||
_X_UNUSED CloseScreenProcPtr close_proc;
|
_X_UNUSED CloseScreenProcPtr close_proc;
|
||||||
_X_UNUSED DisplayCursorProcPtr display_proc;
|
_X_UNUSED DisplayCursorProcPtr display_proc;
|
||||||
|
|
||||||
Unwrap(cs, pScreen, CloseScreen, close_proc);
|
Unwrap(cs, pScreen, CloseScreen, close_proc);
|
||||||
Unwrap(cs, pScreen, DisplayCursor, display_proc);
|
Unwrap(cs, pScreen, DisplayCursor, display_proc);
|
||||||
deleteCursorHideCountsForScreen(pScreen);
|
deleteCursorHideCountsForScreen(pScreen);
|
||||||
ret = (*pScreen->CloseScreen) (pScreen);
|
return pScreen->CloseScreen(pScreen);
|
||||||
free(cs);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CursorAllEvents (XFixesDisplayCursorNotifyMask)
|
#define CursorAllEvents (XFixesDisplayCursorNotifyMask)
|
||||||
|
@ -1058,20 +1054,15 @@ XFixesCursorInit(void)
|
||||||
else
|
else
|
||||||
CursorVisible = FALSE;
|
CursorVisible = FALSE;
|
||||||
|
|
||||||
if (!dixRegisterPrivateKey(&CursorScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
|
if (!dixRegisterPrivateKey(&CursorScreenPrivateKeyRec, PRIVATE_SCREEN, sizeof(CursorScreenRec)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
for (i = 0; i < screenInfo.numScreens; i++) {
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
||||||
ScreenPtr pScreen = screenInfo.screens[i];
|
ScreenPtr pScreen = screenInfo.screens[i];
|
||||||
CursorScreenPtr cs;
|
CursorScreenPtr cs = GetCursorScreen(pScreen);
|
||||||
|
|
||||||
cs = (CursorScreenPtr) calloc(1, sizeof(CursorScreenRec));
|
|
||||||
if (!cs)
|
|
||||||
return FALSE;
|
|
||||||
Wrap(cs, pScreen, CloseScreen, CursorCloseScreen);
|
Wrap(cs, pScreen, CloseScreen, CursorCloseScreen);
|
||||||
Wrap(cs, pScreen, DisplayCursor, CursorDisplayCursor);
|
Wrap(cs, pScreen, DisplayCursor, CursorDisplayCursor);
|
||||||
cs->pCursorHideCounts = NULL;
|
cs->pCursorHideCounts = NULL;
|
||||||
SetCursorScreen(pScreen, cs);
|
|
||||||
}
|
}
|
||||||
CursorClientType = CreateNewResourceType(CursorFreeClient,
|
CursorClientType = CreateNewResourceType(CursorFreeClient,
|
||||||
"XFixesCursorClient");
|
"XFixesCursorClient");
|
||||||
|
|
Loading…
Reference in New Issue