diff src/xfns.c @ 103704:6a4e411bd83b

* xterm.h (struct x_display_info): Add invisible_cursor. (struct x_output): Add current_cursor. * xterm.c (XTtoggle_invisible_pointer): New function. (x_define_frame_cursor): Don't define cursor if invisible or the same as before. Set current_cursor. (x_create_terminal): Set toggle_invisible_pointer_hook. * xfns.c (make_invisible_cursor): New function. (x_set_mouse_color): Call make_invisible_cursor. Set current_cursor. (x_window): Set current_cursor. * termhooks.h (struct terminal): Add toggle_invisible_pointer_hook. * keyboard.c (command_loop_1): Call frame_make_pointer_invisible after inserting a character. (read_avail_input): Call frame_make_pointer_visible. * frame.c (Vmake_pointer_invisible): New variable. (frame_make_pointer_invisible, frame_make_pointer_visible): New functions. (syms_of_frame): DEFVAR make-pointer-invisible, initialize to Qt. * frame.h: Declare frame_make_pointer_invisible and frame_make_pointer_visible. (struct frame): Add pointer_invisible. * cus-start.el (all): Added make-pointer-invisible.
author Jan Djärv <jan.h.d@swipnet.se>
date Fri, 03 Jul 2009 11:07:02 +0000
parents 1867be80e595
children bc2b1f7e7bc0
line wrap: on
line diff
--- a/src/xfns.c	Fri Jul 03 01:43:33 2009 +0000
+++ b/src/xfns.c	Fri Jul 03 11:07:02 2009 +0000
@@ -941,6 +941,35 @@
     }
 }
 
+static Cursor
+make_invisible_cursor (f)
+     struct frame *f;
+{
+  Display *dpy = FRAME_X_DISPLAY (f);
+  static char const no_data[] = { 0 };
+  Pixmap pix;
+  XColor col;
+  Cursor c;
+
+  x_catch_errors (dpy);
+  pix = XCreateBitmapFromData (dpy, FRAME_X_DISPLAY_INFO (f)->root_window,
+                               no_data, 1, 1);
+  if (! x_had_errors_p (dpy) && pix != None)
+    {
+      col.pixel = 0;
+      col.red = col.green = col.blue = 0;
+      col.flags = DoRed | DoGreen | DoBlue;
+      c = XCreatePixmapCursor (dpy, pix, pix, &col, &col, 0, 0);
+      if (x_had_errors_p (dpy) || c == None)
+        c = 0;
+      XFreePixmap (dpy, pix);
+    }
+
+  x_uncatch_errors ();
+
+  return c;
+}
+
 void
 x_set_mouse_color (f, arg, oldval)
      struct frame *f;
@@ -1046,8 +1075,12 @@
   }
 
   if (FRAME_X_WINDOW (f) != 0)
-    XDefineCursor (dpy, FRAME_X_WINDOW (f), cursor);
-
+    XDefineCursor (dpy, FRAME_X_WINDOW (f),
+                   f->output_data.x->current_cursor = cursor);
+
+  if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor == 0)
+    FRAME_X_DISPLAY_INFO (f)->invisible_cursor = make_invisible_cursor (f);
+  
   if (cursor != x->text_cursor
       && x->text_cursor != 0)
     XFreeCursor (dpy, x->text_cursor);
@@ -2671,7 +2704,7 @@
   }
 
   XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-		 f->output_data.x->text_cursor);
+		 f->output.x->current_cursor = f->output_data.x->text_cursor);
 
   UNBLOCK_INPUT;
 
@@ -2816,7 +2849,7 @@
   }
 
   XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-		 f->output_data.x->text_cursor);
+		 f->output.x->current_cursor = f->output_data.x->text_cursor);
 
   UNBLOCK_INPUT;