]> git.eshelyaron.com Git - emacs.git/commitdiff
Implement hourglass cursor on Android
authorPo Lu <luangruo@yahoo.com>
Sat, 11 Mar 2023 00:34:57 +0000 (08:34 +0800)
committerPo Lu <luangruo@yahoo.com>
Sat, 11 Mar 2023 00:34:57 +0000 (08:34 +0800)
* lisp/term/android-win.el (x-pointer-arrow, x-pointer-left-ptr)
(x-pointer-left-side, x-pointer-sb-h-double-arrow)
(x-pointer-sb-v-double-arrow, x-pointer-watch, x-pointer-xterm)
(x-pointer-invisible): New constants.
* src/androidterm.c (android_show_hourglass)
(android_hide_hourglass): New functions.
(android_toggle_visible_pointer, android_define_frame_cursor):
Define or don't define hourglass cursor if x->hourglass.
(android_redisplay_interface): Add new functions.
* src/androidterm.h (struct android_output): New field
`hourglass'.

lisp/term/android-win.el
src/androidterm.c
src/androidterm.h

index 0984b4d5840370150dfe0cfbf2687273e3a65f73..94fe4d6489bcbf267f9f6513260bc30dbc384f73 100644 (file)
@@ -203,5 +203,19 @@ EVENT is a preedit-text event."
 
 (define-key special-event-map [preedit-text] 'android-preedit-text)
 
+\f
+;; Android cursor shapes, named according to the X scheme.
+;; Many X cursors are missing.
+
+(defconst x-pointer-arrow 1000)
+(defconst x-pointer-left-ptr 1000)
+(defconst x-pointer-left-side 1020)
+(defconst x-pointer-sb-h-double-arrow 1014)
+(defconst x-pointer-sb-v-double-arrow 1015)
+(defconst x-pointer-watch 1004)
+(defconst x-pointer-xterm 1008)
+(defconst x-pointer-invisible 0)
+
+\f
 (provide 'android-win)
 ;; android-win.el ends here.
index 3a0f1ccc463f994c9163bbfd39e6cfea508058c1..bd7e60dcb3f574ab19e47d885b967fced65f597c 100644 (file)
@@ -104,6 +104,45 @@ android_clear_frame (struct frame *f)
   android_clear_window (FRAME_ANDROID_DRAWABLE (f));
 }
 
+static void
+android_show_hourglass (struct frame *f)
+{
+  struct android_output *x;
+
+  /* This isn't implemented like X because a window brings alongside
+     too many unneeded resources.  */
+
+  x = FRAME_ANDROID_OUTPUT (f);
+
+  /* If the hourglass window is mapped inside a popup menu, input
+     could be lost if the menu is popped down and the grab is
+     relinquished, but the hourglass window is still up.  Just
+     avoid displaying the hourglass at all while popups are
+     active.  */
+
+  if (popup_activated ())
+    return;
+
+  x->hourglass = true;
+
+  if (!f->pointer_invisible)
+    android_define_cursor (FRAME_ANDROID_WINDOW (f),
+                          x->hourglass_cursor);
+}
+
+static void
+android_hide_hourglass (struct frame *f)
+{
+  struct android_output *x;
+
+  x = FRAME_ANDROID_OUTPUT (f);
+  x->hourglass = false;
+
+  if (!f->pointer_invisible)
+    android_define_cursor (FRAME_ANDROID_WINDOW (f),
+                          x->current_cursor);
+}
+
 static void
 android_flash (struct frame *f)
 {
@@ -245,7 +284,9 @@ android_toggle_visible_pointer (struct frame *f, bool invisible)
                           dpyinfo->invisible_cursor);
   else
     android_define_cursor (FRAME_ANDROID_WINDOW (f),
-                          f->output_data.android->current_cursor);
+                          (FRAME_ANDROID_OUTPUT (f)->hourglass
+                           ? f->output_data.android->hourglass_cursor
+                           : f->output_data.android->current_cursor));
 
   f->pointer_invisible = invisible;
 }
@@ -4032,6 +4073,7 @@ static void
 android_define_frame_cursor (struct frame *f, Emacs_Cursor cursor)
 {
   if (!f->pointer_invisible
+      && !FRAME_ANDROID_OUTPUT (f)->hourglass
       && f->output_data.android->current_cursor != cursor)
     android_define_cursor (FRAME_ANDROID_WINDOW (f), cursor);
 
@@ -5540,8 +5582,8 @@ static struct redisplay_interface android_redisplay_interface =
     android_draw_vertical_window_border,
     android_draw_window_divider,
     NULL,
-    NULL,
-    NULL,
+    android_show_hourglass,
+    android_hide_hourglass,
     android_default_font_parameter,
 #endif
   };
index 2e59365b56dde31eceb6a6fab32843aa5b0be205..9396d5fe315d003d24e4faca80f836f92aa073ca 100644 (file)
@@ -209,6 +209,9 @@ struct android_output
   Emacs_Cursor bottom_edge_cursor;
   Emacs_Cursor bottom_left_corner_cursor;
 
+  /* Whether or not the hourglass cursor is being displayed.  */
+  bool hourglass;
+
   /* This is the Emacs structure for the display this frame is on.  */
   struct android_display_info *display_info;