[PATCH] Make the cursor completely optional

Simon Farnsworth simon.farnsworth at onelan.com
Thu Apr 23 08:15:01 PDT 2009


From: Simon Farnsworth <simon.farnsworth at onelan.co.uk>

For embedded use, it's convenient to be able to disable the cursor
completely, without having to audit and fix up all your third-party
code (e.g. Mozilla Firefox).

Add -nocursor and -cursor server options to enable and disable the
cursor. The default is still -cursor, but embedded users can run the
server with -nocursor to hide the cursor regardless of what
application developers do.
---
 include/input.h |    4 ++++
 os/utils.c      |   12 +++++++++++-
 xfixes/cursor.c |    6 ++++--
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/include/input.h b/include/input.h
index b3bb5d1..94089b2 100644
--- a/include/input.h
+++ b/include/input.h
@@ -494,4 +494,8 @@ extern _X_EXPORT void DDXRingBell(
     int pitch,
     int duration);
 
+/* Set to TRUE by default - os/utils.c sets it to FALSE on user request,
+   xfixes/cursor.c uses it to determine if the cursor is enabled */
+extern Bool EnableCursor;
+
 #endif /* INPUT_H */
diff --git a/os/utils.c b/os/utils.c
index 78a50b2..00abd63 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -482,6 +482,8 @@ void UseMsg(void)
     ErrorF("-c                     turns off key-click\n");
     ErrorF("c #                    key-click volume (0-100)\n");
     ErrorF("-cc int                default color visual class\n");
+    ErrorF("-cursor                enable the cursor (default)\n");
+    ErrorF("-nocursor              disable the cursor\n");
     ErrorF("-core                  generate core dump on fatal error\n");
     ErrorF("-dpi int               screen resolution in dots per inch\n");
 #ifdef DPMSExtension
@@ -660,7 +662,15 @@ ProcessCommandLine(int argc, char *argv[])
 #endif
 	    CoreDump = TRUE;
 	}
-	else if ( strcmp( argv[i], "-dpi") == 0)
+        else if ( strcmp( argv[i], "-nocursor") == 0)
+        {
+            EnableCursor = FALSE;
+        }
+        else if ( strcmp( argv[i], "-cursor") == 0)
+        {
+            EnableCursor = TRUE;
+        }
+        else if ( strcmp( argv[i], "-dpi") == 0)
 	{
 	    if(++i < argc)
 	        monitorResolution = atoi(argv[i]);
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 33ab426..eb83cfe 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -129,6 +129,8 @@ typedef struct _CursorScreen {
 /* The cursor doesn't show up until the first XDefineCursor() */
 static Bool CursorVisible = FALSE;
 
+Bool EnableCursor = TRUE;
+
 static Bool
 CursorDisplayCursor (DeviceIntPtr pDev,
                      ScreenPtr pScreen,
@@ -144,7 +146,7 @@ CursorDisplayCursor (DeviceIntPtr pDev,
      * initial root window setup.  Not a great way to do it, I admit.
      */
     if (ConnectionInfo)
-	CursorVisible = TRUE;
+	CursorVisible = EnableCursor;
 
     if (cs->pCursorHideCounts != NULL || !CursorVisible) {
         ret = ((*pScreen->RealizeCursor)(pDev, pScreen, pInvisibleCursor) &&
@@ -1052,7 +1054,7 @@ XFixesCursorInit (void)
     int	i;
 
     if (party_like_its_1989)
-	CursorVisible = TRUE;
+	CursorVisible = EnableCursor;
     
     for (i = 0; i < screenInfo.numScreens; i++)
     {
-- 
1.5.4.1



More information about the xorg-devel mailing list