]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix mouse pointer avoidance in some configurations
authorPo Lu <luangruo@yahoo.com>
Wed, 11 May 2022 08:01:32 +0000 (16:01 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 11 May 2022 08:01:52 +0000 (16:01 +0800)
* lisp/avoid.el (mouse-avoidance-random-shape): Ignore invisible
pointer.
(mouse-avoidance-ignore-p): Adjust for interprogram DND.
* lisp/term/x-win.el (x-pointer-invisible): Make value larger
than the maximum possible glyph.

* src/xfns.c (x_set_mouse_color): Use function that handles
`x-pointer-invisible' too.
* src/xterm.c (x_create_font_cursor): New function.  Handle
invisible cursors.
* src/xterm.h: Update prototypes.

lisp/avoid.el
lisp/term/x-win.el
src/xfns.c
src/xterm.c
src/xterm.h

index b53d84d2e8d478189cd2559e92a6cf33c91a72e5..c97e51a6f7dcfebca255d6261b2d1f0dac684172 100644 (file)
@@ -300,12 +300,14 @@ has an integer value is a valid cursor shape.  You might want to
 redefine this function to suit your own tastes."
   (if (null mouse-avoidance-pointer-shapes)
       (progn
-       (setq mouse-avoidance-pointer-shapes
-             (mapcar (lambda (x) (symbol-value (intern x)))
-                     (all-completions "x-pointer-" obarray
-                                      (lambda (x)
-                                         (and (boundp x)
-                                               (integerp (symbol-value x)))))))))
+       (dolist (i (all-completions "x-pointer-" obarray
+                                   (lambda (x)
+                                     (and (boundp x)
+                                           (integerp (symbol-value x))))))
+          (ignore-errors
+            (let ((value (symbol-value (intern i))))
+              (when (< value x-pointer-invisible)
+                (push value mouse-avoidance-pointer-shapes)))))))
   (seq-random-elt mouse-avoidance-pointer-shapes))
 
 (defun mouse-avoidance-ignore-p ()
@@ -317,7 +319,8 @@ redefine this function to suit your own tastes."
        (not (eq (car mp) (selected-frame)))
         ;; Don't interfere with ongoing `mouse-drag-and-drop-region'
         ;; (Bug#36269).
-        (eq track-mouse 'dropping)
+        (or (eq track-mouse 'dropping)
+            (eq track-mouse 'drag-source))
        ;; Don't do anything if last event was a mouse event.
        ;; FIXME: this code fails in the case where the mouse was moved
        ;; since the last key-press but without generating any event.
index ca38a0a8c924416d4d646e1fdf0bc906f53cf19c..08a8bf88e5df829322e59127a7d6feb9e8b23ee4 100644 (file)
@@ -241,7 +241,9 @@ exists."
 (defconst x-pointer-ur-angle 148)
 (defconst x-pointer-watch 150)
 (defconst x-pointer-xterm 152)
-(defconst x-pointer-invisible 255)
+(defconst x-pointer-invisible 65536) ;; This value is larger than a
+                                     ;; CARD16, so it cannot be a
+                                     ;; valid cursor.
 
 \f
 ;;;; Keysyms
index 5522684170f6f0730a9bd190adf84a7159a741b4..6eddf3a494975fb4d963bd1d8673dd9234351334 100644 (file)
@@ -1261,25 +1261,27 @@ struct mouse_cursor_types {
 };
 
 /* This array must stay in sync with enum mouse_cursor above!  */
-static const struct mouse_cursor_types mouse_cursor_types[] = {
-  { "text",      &Vx_pointer_shape,                    XC_xterm               },
-  { "nontext",   &Vx_nontext_pointer_shape,            XC_left_ptr            },
-  { "hourglass", &Vx_hourglass_pointer_shape,          XC_watch               },
-  { "modeline",  &Vx_mode_pointer_shape,               XC_xterm               },
-  { NULL,        &Vx_sensitive_text_pointer_shape,     XC_hand2               },
-  { NULL,        &Vx_window_horizontal_drag_shape,     XC_sb_h_double_arrow   },
-  { NULL,        &Vx_window_vertical_drag_shape,       XC_sb_v_double_arrow   },
-  { NULL,        &Vx_window_left_edge_shape,           XC_left_side           },
-  { NULL,        &Vx_window_top_left_corner_shape,     XC_top_left_corner     },
-  { NULL,        &Vx_window_top_edge_shape,            XC_top_side            },
-  { NULL,        &Vx_window_top_right_corner_shape,    XC_top_right_corner    },
-  { NULL,        &Vx_window_right_edge_shape,          XC_right_side          },
-  { NULL,        &Vx_window_bottom_right_corner_shape, XC_bottom_right_corner },
-  { NULL,        &Vx_window_bottom_edge_shape,         XC_bottom_side         },
-  { NULL,        &Vx_window_bottom_left_corner_shape,  XC_bottom_left_corner  },
-};
+static const struct mouse_cursor_types mouse_cursor_types[] =
+  {
+    { "text",      &Vx_pointer_shape,                    XC_xterm               },
+    { "nontext",   &Vx_nontext_pointer_shape,            XC_left_ptr            },
+    { "hourglass", &Vx_hourglass_pointer_shape,          XC_watch               },
+    { "modeline",  &Vx_mode_pointer_shape,               XC_xterm               },
+    { NULL,        &Vx_sensitive_text_pointer_shape,     XC_hand2               },
+    { NULL,        &Vx_window_horizontal_drag_shape,     XC_sb_h_double_arrow   },
+    { NULL,        &Vx_window_vertical_drag_shape,       XC_sb_v_double_arrow   },
+    { NULL,        &Vx_window_left_edge_shape,           XC_left_side           },
+    { NULL,        &Vx_window_top_left_corner_shape,     XC_top_left_corner     },
+    { NULL,        &Vx_window_top_edge_shape,            XC_top_side            },
+    { NULL,        &Vx_window_top_right_corner_shape,    XC_top_right_corner    },
+    { NULL,        &Vx_window_right_edge_shape,          XC_right_side          },
+    { NULL,        &Vx_window_bottom_right_corner_shape, XC_bottom_right_corner },
+    { NULL,        &Vx_window_bottom_edge_shape,         XC_bottom_side         },
+    { NULL,        &Vx_window_bottom_left_corner_shape,  XC_bottom_left_corner  },
+  };
 
-struct mouse_cursor_data {
+struct mouse_cursor_data
+{
   /* Last index for which XCreateFontCursor has been called, and thus
      the last index for which x_request_serial[] is valid.  */
   int last_cursor_create_request;
@@ -1360,8 +1362,10 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
     {
       cursor_data.x_request_serial[i] = XNextRequest (dpy);
       cursor_data.last_cursor_create_request = i;
-      cursor_data.cursor[i] = XCreateFontCursor (dpy,
-                                                cursor_data.cursor_num[i]);
+
+      cursor_data.cursor[i]
+       = x_create_font_cursor (FRAME_DISPLAY_INFO (f),
+                               cursor_data.cursor_num[i]);
     }
 
   /* Now sync up and process all received errors from cursor
index 4c1720ca94f79b0c3f724cdd9653a9ef54549c14..a250fce9b092bed78121af316d9ea89d53c2982f 100644 (file)
@@ -22639,6 +22639,18 @@ x_make_frame_visible_invisible (struct frame *f, bool visible)
     x_make_frame_invisible (f);
 }
 
+Cursor
+x_create_font_cursor (struct x_display_info *dpyinfo, int glyph)
+{
+  if (glyph <= 65535)
+    return XCreateFontCursor (dpyinfo->display, glyph);
+
+  /* x-pointer-invisible cannot fit in CARD16, and thus cannot be any
+     existing cursor.  */
+  return make_invisible_cursor (dpyinfo);
+}
+
+
 /* Change window state from mapped to iconified.  */
 
 void
index 98c4c5f01c6f16054e4d9b02554ca66a7d87aeb8..3437037e674274def8425d5779b478fa40aa83c9 100644 (file)
@@ -1383,7 +1383,8 @@ extern void x_iconify_frame (struct frame *f);
 extern void x_free_frame_resources (struct frame *);
 extern void x_wm_set_size_hint (struct frame *, long, bool);
 
-extern void x_delete_terminal (struct terminal *terminal);
+extern void x_delete_terminal (struct terminal *);
+extern Cursor x_create_font_cursor (struct x_display_info *, int);
 extern unsigned long x_copy_color (struct frame *, unsigned long);
 #ifdef USE_X_TOOLKIT
 extern XtAppContext Xt_app_con;