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