a16651f
From e99347a3e82e6db47dd482169b6799968afc3893 Mon Sep 17 00:00:00 2001
a16651f
From: Adam Jackson <ajax@redhat.com>
a16651f
Date: Wed, 20 Aug 2008 10:11:07 -0400
a16651f
Subject: [PATCH] Hide the cursor until the first XDefineCursor() call.
a16651f
a16651f
---
a16651f
 xfixes/cursor.c |   28 ++++++++++++++++++++++++++--
a16651f
 1 files changed, 26 insertions(+), 2 deletions(-)
a16651f
a16651f
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
a16651f
index d51251f..c8c4c9f 100755
a16651f
--- a/xfixes/cursor.c
a16651f
+++ b/xfixes/cursor.c
a16651f
@@ -70,7 +70,7 @@
a16651f
 	return BadCursor; \
a16651f
     } \
a16651f
 }
a16651f
-	
a16651f
+
a16651f
 /*
a16651f
  * There is a global list of windows selecting for cursor events
a16651f
  */
a16651f
@@ -109,6 +109,7 @@
a16651f
 
a16651f
 typedef struct _CursorScreen {
a16651f
     DisplayCursorProcPtr	DisplayCursor;
a16651f
+    ChangeWindowAttributesProcPtr ChangeWindowAttributes;
a16651f
     CloseScreenProcPtr		CloseScreen;
a16651f
     CursorHideCountPtr          pCursorHideCounts;
a16651f
 } CursorScreenRec, *CursorScreenPtr;
a16651f
@@ -119,6 +120,9 @@
a16651f
 #define Wrap(as,s,elt,func)	(((as)->elt = (s)->elt), (s)->elt = func)
a16651f
 #define Unwrap(as,s,elt)	((s)->elt = (as)->elt)
a16651f
 
a16651f
+/* The cursor doesn't show up until the first XDefineCursor() */
a16651f
+static Bool CursorVisible = FALSE;
a16651f
+
a16651f
 static Bool
a16651f
 CursorDisplayCursor (ScreenPtr pScreen,
a16651f
 		     CursorPtr pCursor)
a16651f
@@ -128,7 +132,7 @@
a16651f
 
a16651f
     Unwrap (cs, pScreen, DisplayCursor);
a16651f
 
a16651f
-    if (cs->pCursorHideCounts != NULL) {
a16651f
+    if (cs->pCursorHideCounts != NULL || !CursorVisible) {
a16651f
 	ret = (*pScreen->DisplayCursor) (pScreen, pInvisibleCursor);
a16651f
     } else {
a16651f
 	ret = (*pScreen->DisplayCursor) (pScreen, pCursor);
a16651f
@@ -161,6 +165,24 @@
a16651f
 }
a16651f
 
a16651f
 static Bool
a16651f
+CursorChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
a16651f
+{
a16651f
+    ScreenPtr           pScreen = pWin->drawable.pScreen;
a16651f
+    CursorScreenPtr	cs = GetCursorScreen(pScreen);
a16651f
+    Bool		ret;
a16651f
+    extern char *ConnectionInfo;
a16651f
+
a16651f
+    if ((mask & CWCursor) && ConnectionInfo)
a16651f
+	CursorVisible = TRUE;
a16651f
+
a16651f
+    Unwrap(cs, pScreen, ChangeWindowAttributes);
a16651f
+    ret = pScreen->ChangeWindowAttributes(pWin, mask);
a16651f
+    Wrap(cs, pScreen, ChangeWindowAttributes, CursorChangeWindowAttributes);
a16651f
+
a16651f
+    return ret;
a16651f
+}
a16651f
+
a16651f
+static Bool
a16651f
 CursorCloseScreen (int index, ScreenPtr pScreen)
a16651f
 {
a16651f
     CursorScreenPtr	cs = GetCursorScreen (pScreen);
a16651f
@@ -168,6 +190,7 @@
a16651f
 
a16651f
     Unwrap (cs, pScreen, CloseScreen);
a16651f
     Unwrap (cs, pScreen, DisplayCursor);
a16651f
+    Unwrap (cs, pScreen, ChangeWindowAttributes);
a16651f
     deleteCursorHideCountsForScreen(pScreen);
a16651f
     ret = (*pScreen->CloseScreen) (index, pScreen);
a16651f
     xfree (cs);
a16651f
@@ -1042,6 +1065,8 @@
a16651f
 	    return FALSE;
a16651f
 	Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
a16651f
 	Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
a16651f
+	Wrap (cs, pScreen, ChangeWindowAttributes,
a16651f
+	      CursorChangeWindowAttributes);
a16651f
 	cs->pCursorHideCounts = NULL;
a16651f
 	SetCursorScreen (pScreen, cs);
a16651f
     }
a16651f
-- 
a16651f
1.5.6.4
a16651f