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