Implement hourglass cursor on Android

* 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'.
This commit is contained in:
Po Lu 2023-03-11 08:34:57 +08:00
parent 769a4e7ff5
commit e9a879260d
3 changed files with 62 additions and 3 deletions

View file

@ -203,5 +203,19 @@ EVENT is a preedit-text event."
(define-key special-event-map [preedit-text] 'android-preedit-text)
;; 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)
(provide 'android-win)
;; android-win.el ends here.

View 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
};

View 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;