[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/android e9a879260d7 2/2: Implement hourglass cursor on Android
From: |
Po Lu |
Subject: |
feature/android e9a879260d7 2/2: Implement hourglass cursor on Android |
Date: |
Fri, 10 Mar 2023 19:36:01 -0500 (EST) |
branch: feature/android
commit e9a879260d791ccd509f031ea4e2f3fd645a9672
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
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'.
---
lisp/term/android-win.el | 14 ++++++++++++++
src/androidterm.c | 48 +++++++++++++++++++++++++++++++++++++++++++++---
src/androidterm.h | 3 +++
3 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/lisp/term/android-win.el b/lisp/term/android-win.el
index 0984b4d5840..94fe4d6489b 100644
--- a/lisp/term/android-win.el
+++ b/lisp/term/android-win.el
@@ -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.
diff --git a/src/androidterm.c b/src/androidterm.c
index 3a0f1ccc463..bd7e60dcb3f 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -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
};
diff --git a/src/androidterm.h b/src/androidterm.h
index 2e59365b56d..9396d5fe315 100644
--- a/src/androidterm.h
+++ b/src/androidterm.h
@@ -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;