Suppress cursor display until the first XDefineCursor() request.

Yes, this means the server will start without showing a cursor.  Pretty
much any application that wants to interact with the mouse will define
cursors, so this essentially just delays showing it until gdm (or
whatever) loads.
This commit is contained in:
Adam Jackson 2008-08-20 13:24:03 -04:00
parent 64ef7ed072
commit e02f864fdf

View File

@ -70,7 +70,7 @@ static void deleteCursorHideCountsForScreen (ScreenPtr pScreen);
return BadCursor; \
} \
}
/*
* There is a global list of windows selecting for cursor events
*/
@ -109,6 +109,7 @@ typedef struct _CursorHideCountRec {
typedef struct _CursorScreen {
DisplayCursorProcPtr DisplayCursor;
ChangeWindowAttributesProcPtr ChangeWindowAttributes;
CloseScreenProcPtr CloseScreen;
CursorHideCountPtr pCursorHideCounts;
} CursorScreenRec, *CursorScreenPtr;
@ -119,6 +120,9 @@ typedef struct _CursorScreen {
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
/* The cursor doesn't show up until the first XDefineCursor() */
static Bool CursorVisible = FALSE;
static Bool
CursorDisplayCursor (DeviceIntPtr pDev,
ScreenPtr pScreen,
@ -129,7 +133,7 @@ CursorDisplayCursor (DeviceIntPtr pDev,
Unwrap (cs, pScreen, DisplayCursor);
if (cs->pCursorHideCounts != NULL) {
if (cs->pCursorHideCounts != NULL || !CursorVisible) {
ret = (*pScreen->DisplayCursor) (pDev, pScreen, pInvisibleCursor);
} else {
ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
@ -161,6 +165,27 @@ CursorDisplayCursor (DeviceIntPtr pDev,
return ret;
}
static Bool
CursorChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
CursorScreenPtr cs = GetCursorScreen(pScreen);
Bool ret;
/*
* Have to check ConnectionInfo to distinguish client requests from
* initial root window setup. Not a great way to do it, I admit.
*/
if ((mask & CWCursor) && ConnectionInfo)
CursorVisible = TRUE;
Unwrap(cs, pScreen, ChangeWindowAttributes);
ret = pScreen->ChangeWindowAttributes(pWin, mask);
Wrap(cs, pScreen, ChangeWindowAttributes, CursorChangeWindowAttributes);
return ret;
}
static Bool
CursorCloseScreen (int index, ScreenPtr pScreen)
{
@ -169,6 +194,7 @@ CursorCloseScreen (int index, ScreenPtr pScreen)
Unwrap (cs, pScreen, CloseScreen);
Unwrap (cs, pScreen, DisplayCursor);
Unwrap (cs, pScreen, ChangeWindowAttributes);
deleteCursorHideCountsForScreen(pScreen);
ret = (*pScreen->CloseScreen) (index, pScreen);
xfree (cs);
@ -1043,6 +1069,8 @@ XFixesCursorInit (void)
return FALSE;
Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
Wrap (cs, pScreen, ChangeWindowAttributes,
CursorChangeWindowAttributes);
cs->pCursorHideCounts = NULL;
SetCursorScreen (pScreen, cs);
}