Index: [thread] [date] [subject] [author]
  From: Osku Salerma <osku@iki.fi>
  To  : ggi-develop@eskimo.com
  Date: Sun, 18 Jul 1999 22:11:43 +0300 (EET DST)

Patch for disabling ggi messing with X's cursor

I have an app that uses a small 256x256 window in addition to a normal 
xterm for displaying some data graphically, and also for getting mouse 
clicks. However, the normal ggi behavior of setting the cursor for the 
window to some ridiculously small dot that's almost impossible to see
is rather bizarre. What's wrong with keeping the normal X cursor as it 
is?

Anyway, it's your library, you can set the cursor to whatever you
want. But I did make a little patch to allow disabling the behavior.
With the patch you can do ggiOpen("x:-defcursor", NULL) and ggi
doesn't do any cursor setting at all. It handles both x and xlib
targets.

Works for me in 2.0b2, patched cleanly against beta 2.1 so shold
probably work fine in it.

diff -r -u libggi-2.0b2/display/X/mode.inc libggi-2.0b2-osku/display/X/mode.inc
--- libggi-2.0b2/display/X/mode.inc	Thu Apr  1 05:01:02 1999
+++ libggi-2.0b2-osku/display/X/mode.inc	Sun Jul 18 21:37:00 1999
@@ -463,8 +463,10 @@
 				0, 0, tm->visible.x, tm->visible.y, 0,
 				priv->visual.depth, priv->visual.class,
 				priv->visual.visual, 0, NULL);
-			XDefineCursor(priv->display, priv->window,
-				      priv->cursor);
+
+			if (priv->cursor != None)
+				XDefineCursor(priv->display, priv->window,
+					priv->cursor);
 		}
 	}
 	GGIDPRINT_MODE("X: has window 0x%x\n", priv->window);
diff -r -u libggi-2.0b2/display/X/visual.c libggi-2.0b2-osku/display/X/visual.c
--- libggi-2.0b2/display/X/visual.c	Mon Feb 15 15:38:00 1999
+++ libggi-2.0b2-osku/display/X/visual.c	Sun Jul 18 21:48:03 1999
@@ -31,14 +31,18 @@
 #include <ggi/internal/ggi-dl.h>
 #include <ggi/display/x.h>
 
-#define NUM_OPTS  2
-
-static gg_option x_options[NUM_OPTS] =
+static gg_option x_options[] =
 {
 	{ "inroot", "no" },
-	{ "inwin",  "no" }
+	{ "inwin",  "no" },
+	{ "defcursor", "no" }
 };
 
+#define OPT_INROOT    0
+#define OPT_INWIN     1
+#define OPT_DEFCURSOR 2
+
+#define NUM_OPTIONS	(sizeof(x_options)/sizeof(gg_option))
 
 void _GGI_X_freedbs(ggi_visual *vis, struct Xhooks *priv) {
 	int i;
@@ -104,7 +108,7 @@
 
 	if (args) {
 		args = ggParseOptions((char *)args, x_options,
-				      NUM_OPTS);
+				      NUM_OPTIONS);
 		if (args == NULL) {
 			fprintf(stderr, "display-x: error in "
 				"arguments.\n");
@@ -149,10 +153,10 @@
 		priv->defsize.y = h;
 	}
 
-	if (x_options[0].result[0] != 'n') {
+	if (x_options[OPT_INROOT].result[0] != 'n') {
 		priv->wintype = GGIX_ROOT;
 		GGIDPRINT_MISC("X: using root window\n");
-	} else if (x_options[1].result[0] != 'n') {
+	} else if (x_options[OPT_INWIN].result[0] != 'n') {
 		priv->wintype = GGIX_WIN;
 		priv->window = strtol(x_options[1].result, NULL, 0);
 		GGIDPRINT_MISC("X: using window id 0x%x\n", priv->window);
@@ -170,7 +174,10 @@
 		return GGI_DL_ERROR;
 	}
 
-	priv->cursor = make_cursor(disp);
+	if (x_options[OPT_DEFCURSOR].result[0] != 'n')
+		priv->cursor = None;
+	else
+		priv->cursor = make_cursor(disp);
 
 	for(i = 0; i<8; i++) {
 		priv->ximage_list[i] = NULL;
diff -r -u libggi-2.0b2/display/Xlib/visual.c libggi-2.0b2-osku/display/Xlib/visual.c
--- libggi-2.0b2/display/Xlib/visual.c	Mon Feb 15 15:38:00 1999
+++ libggi-2.0b2-osku/display/Xlib/visual.c	Sun Jul 18 21:48:13 1999
@@ -31,14 +31,18 @@
 #include <ggi/internal/ggi-dl.h>
 #include <ggi/display/xlib.h>
 
-#define NUM_OPTS 2
-
-static gg_option x_options[NUM_OPTS] =
+static gg_option x_options[] =
 {
 	{ "inroot", "no" },
-	{ "inwin",  "no" }
+	{ "inwin",  "no" },
+	{ "defcursor", "no" }
 };
 
+#define OPT_INROOT    0
+#define OPT_INWIN     1
+#define OPT_DEFCURSOR 2
+
+#define NUM_OPTIONS	(sizeof(x_options)/sizeof(gg_option))
 
 static inline Cursor make_cursor(Display *disp)
 {
@@ -70,7 +74,7 @@
 
 	if (args) {
 		args = ggParseOptions((char *)args, x_options,
-				      NUM_OPTS);
+				      NUM_OPTIONS);
 		if (args == NULL) {
 			fprintf(stderr, "display-xlib: error in arguments.\n");
 			return GGI_DL_ERROR;
@@ -115,18 +119,21 @@
 		priv->defsize.y = h;
 	}
 
-	if (x_options[0].result[0] != 'n') {
+	if (x_options[OPT_INROOT].result[0] != 'n') {
 		priv->wintype = GGIX_ROOT;
 		GGIDPRINT_MISC("Xlib: using root window\n");
-	} else if (x_options[1].result[0] != 'n') {
+	} else if (x_options[OPT_INWIN].result[0] != 'n') {
 		priv->wintype = GGIX_WIN;
 		priv->window = strtol(x_options[1].result, NULL, 0);
 		GGIDPRINT_MISC("Xlib: using window id 0x%x\n", priv->window);
 	} else {
 		priv->wintype = GGIX_NORMAL;
 	}
-
-	priv->cursor = make_cursor(disp);
+    
+    if (x_options[OPT_DEFCURSOR].result[0] != 'n')
+        priv->cursor = None;
+    else
+        priv->cursor = make_cursor(disp);
 
 	/* This doesn't work yet... */
 #if 0


--
Osku Salerma - osku@iki.fi - http://www.iki.fi/osku/
Save the whales. Feed the hungry. Free the mallocs.

Index: [thread] [date] [subject] [author]