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