Commit e02f864f authored by Adam Jackson's avatar Adam Jackson 💣

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.
parent 64ef7ed0
...@@ -70,7 +70,7 @@ static void deleteCursorHideCountsForScreen (ScreenPtr pScreen); ...@@ -70,7 +70,7 @@ static void deleteCursorHideCountsForScreen (ScreenPtr pScreen);
return BadCursor; \ return BadCursor; \
} \ } \
} }
/* /*
* There is a global list of windows selecting for cursor events * There is a global list of windows selecting for cursor events
*/ */
...@@ -109,6 +109,7 @@ typedef struct _CursorHideCountRec { ...@@ -109,6 +109,7 @@ typedef struct _CursorHideCountRec {
typedef struct _CursorScreen { typedef struct _CursorScreen {
DisplayCursorProcPtr DisplayCursor; DisplayCursorProcPtr DisplayCursor;
ChangeWindowAttributesProcPtr ChangeWindowAttributes;
CloseScreenProcPtr CloseScreen; CloseScreenProcPtr CloseScreen;
CursorHideCountPtr pCursorHideCounts; CursorHideCountPtr pCursorHideCounts;
} CursorScreenRec, *CursorScreenPtr; } CursorScreenRec, *CursorScreenPtr;
...@@ -119,6 +120,9 @@ typedef struct _CursorScreen { ...@@ -119,6 +120,9 @@ typedef struct _CursorScreen {
#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) ((s)->elt = (as)->elt) #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 static Bool
CursorDisplayCursor (DeviceIntPtr pDev, CursorDisplayCursor (DeviceIntPtr pDev,
ScreenPtr pScreen, ScreenPtr pScreen,
...@@ -129,7 +133,7 @@ CursorDisplayCursor (DeviceIntPtr pDev, ...@@ -129,7 +133,7 @@ CursorDisplayCursor (DeviceIntPtr pDev,
Unwrap (cs, pScreen, DisplayCursor); Unwrap (cs, pScreen, DisplayCursor);
if (cs->pCursorHideCounts != NULL) { if (cs->pCursorHideCounts != NULL || !CursorVisible) {
ret = (*pScreen->DisplayCursor) (pDev, pScreen, pInvisibleCursor); ret = (*pScreen->DisplayCursor) (pDev, pScreen, pInvisibleCursor);
} else { } else {
ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor); ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
...@@ -161,6 +165,27 @@ CursorDisplayCursor (DeviceIntPtr pDev, ...@@ -161,6 +165,27 @@ CursorDisplayCursor (DeviceIntPtr pDev,
return ret; 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 static Bool
CursorCloseScreen (int index, ScreenPtr pScreen) CursorCloseScreen (int index, ScreenPtr pScreen)
{ {
...@@ -169,6 +194,7 @@ CursorCloseScreen (int index, ScreenPtr pScreen) ...@@ -169,6 +194,7 @@ CursorCloseScreen (int index, ScreenPtr pScreen)
Unwrap (cs, pScreen, CloseScreen); Unwrap (cs, pScreen, CloseScreen);
Unwrap (cs, pScreen, DisplayCursor); Unwrap (cs, pScreen, DisplayCursor);
Unwrap (cs, pScreen, ChangeWindowAttributes);
deleteCursorHideCountsForScreen(pScreen); deleteCursorHideCountsForScreen(pScreen);
ret = (*pScreen->CloseScreen) (index, pScreen); ret = (*pScreen->CloseScreen) (index, pScreen);
xfree (cs); xfree (cs);
...@@ -1043,6 +1069,8 @@ XFixesCursorInit (void) ...@@ -1043,6 +1069,8 @@ XFixesCursorInit (void)
return FALSE; return FALSE;
Wrap (cs, pScreen, CloseScreen, CursorCloseScreen); Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor); Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
Wrap (cs, pScreen, ChangeWindowAttributes,
CursorChangeWindowAttributes);
cs->pCursorHideCounts = NULL; cs->pCursorHideCounts = NULL;
SetCursorScreen (pScreen, cs); SetCursorScreen (pScreen, cs);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment