diff options
| author | Po Lu | 2023-03-10 15:16:05 +0800 |
|---|---|---|
| committer | Po Lu | 2023-03-10 15:16:05 +0800 |
| commit | ae5513ede52536df2cd823699d6168985915ce0f (patch) | |
| tree | 61e38d5c1f5544b03778055af964e4e0289928ac /src/androidterm.c | |
| parent | a7c8ae7d675c402923e2ff8359b9cc286792bbb0 (diff) | |
| download | emacs-ae5513ede52536df2cd823699d6168985915ce0f.tar.gz emacs-ae5513ede52536df2cd823699d6168985915ce0f.zip | |
Implement mouse cursors on Android 7.0 and later
* java/org/gnu/emacs/EmacsWindow.java (defineCursor): New
function.
* src/android.c (struct android_emacs_cursor): New struct.
(android_init_emacs_cursor): New function.
(JNICALL): Call it.
(android_create_font_cursor, android_define_cursor)
(android_free_cursor): New functions.
* src/android.h (enum android_handle_type): Add cursor handle
type.
* src/androidfns.c (Fx_create_frame, android_create_tip_frame)
(enum mouse_cursor, struct mouse_cursor_types, mouse_cursor_types)
(struct mouse_cursor_data, android_set_mouse_color)
(syms_of_androidfns):
* src/androidgui.h (enum android_cursor_shape):
* src/androidterm.c (make_invisible_cursor)
(android_toggle_invisible_pointer, android_free_frame_resources)
(android_define_frame_cursor):
* src/androidterm.h (struct android_display_info)
(struct android_output): Port mouse cursor code over from X.
Diffstat (limited to 'src/androidterm.c')
| -rw-r--r-- | src/androidterm.c | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/src/androidterm.c b/src/androidterm.c index 2e2bf86706c..3a0f1ccc463 100644 --- a/src/androidterm.c +++ b/src/androidterm.c | |||
| @@ -224,10 +224,38 @@ android_ring_bell (struct frame *f) | |||
| 224 | } | 224 | } |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | static android_cursor | ||
| 228 | make_invisible_cursor (struct android_display_info *dpyinfo) | ||
| 229 | { | ||
| 230 | return android_create_font_cursor (ANDROID_XC_NULL); | ||
| 231 | } | ||
| 232 | |||
| 227 | static void | 233 | static void |
| 228 | android_toggle_invisible_pointer (struct frame *f, bool invisible) | 234 | android_toggle_visible_pointer (struct frame *f, bool invisible) |
| 229 | { | 235 | { |
| 236 | struct android_display_info *dpyinfo; | ||
| 237 | |||
| 238 | dpyinfo = FRAME_DISPLAY_INFO (f); | ||
| 239 | |||
| 240 | if (!dpyinfo->invisible_cursor) | ||
| 241 | dpyinfo->invisible_cursor = make_invisible_cursor (dpyinfo); | ||
| 242 | |||
| 243 | if (invisible) | ||
| 244 | android_define_cursor (FRAME_ANDROID_WINDOW (f), | ||
| 245 | dpyinfo->invisible_cursor); | ||
| 246 | else | ||
| 247 | android_define_cursor (FRAME_ANDROID_WINDOW (f), | ||
| 248 | f->output_data.android->current_cursor); | ||
| 230 | 249 | ||
| 250 | f->pointer_invisible = invisible; | ||
| 251 | } | ||
| 252 | |||
| 253 | static void | ||
| 254 | android_toggle_invisible_pointer (struct frame *f, bool invisible) | ||
| 255 | { | ||
| 256 | block_input (); | ||
| 257 | android_toggle_visible_pointer (f, invisible); | ||
| 258 | unblock_input (); | ||
| 231 | } | 259 | } |
| 232 | 260 | ||
| 233 | /* Start an update of frame F. This function is installed as a hook | 261 | /* Start an update of frame F. This function is installed as a hook |
| @@ -2040,6 +2068,38 @@ android_free_frame_resources (struct frame *f) | |||
| 2040 | 2068 | ||
| 2041 | android_free_gcs (f); | 2069 | android_free_gcs (f); |
| 2042 | 2070 | ||
| 2071 | /* Free cursors. */ | ||
| 2072 | if (f->output_data.android->text_cursor) | ||
| 2073 | android_free_cursor (f->output_data.android->text_cursor); | ||
| 2074 | if (f->output_data.android->nontext_cursor) | ||
| 2075 | android_free_cursor (f->output_data.android->nontext_cursor); | ||
| 2076 | if (f->output_data.android->modeline_cursor) | ||
| 2077 | android_free_cursor (f->output_data.android->modeline_cursor); | ||
| 2078 | if (f->output_data.android->hand_cursor) | ||
| 2079 | android_free_cursor (f->output_data.android->hand_cursor); | ||
| 2080 | if (f->output_data.android->hourglass_cursor) | ||
| 2081 | android_free_cursor (f->output_data.android->hourglass_cursor); | ||
| 2082 | if (f->output_data.android->horizontal_drag_cursor) | ||
| 2083 | android_free_cursor (f->output_data.android->horizontal_drag_cursor); | ||
| 2084 | if (f->output_data.android->vertical_drag_cursor) | ||
| 2085 | android_free_cursor (f->output_data.android->vertical_drag_cursor); | ||
| 2086 | if (f->output_data.android->left_edge_cursor) | ||
| 2087 | android_free_cursor (f->output_data.android->left_edge_cursor); | ||
| 2088 | if (f->output_data.android->top_left_corner_cursor) | ||
| 2089 | android_free_cursor (f->output_data.android->top_left_corner_cursor); | ||
| 2090 | if (f->output_data.android->top_edge_cursor) | ||
| 2091 | android_free_cursor (f->output_data.android->top_edge_cursor); | ||
| 2092 | if (f->output_data.android->top_right_corner_cursor) | ||
| 2093 | android_free_cursor (f->output_data.android->top_right_corner_cursor); | ||
| 2094 | if (f->output_data.android->right_edge_cursor) | ||
| 2095 | android_free_cursor (f->output_data.android->right_edge_cursor); | ||
| 2096 | if (f->output_data.android->bottom_right_corner_cursor) | ||
| 2097 | android_free_cursor (f->output_data.android->bottom_right_corner_cursor); | ||
| 2098 | if (f->output_data.android->bottom_edge_cursor) | ||
| 2099 | android_free_cursor (f->output_data.android->bottom_edge_cursor); | ||
| 2100 | if (f->output_data.android->bottom_left_corner_cursor) | ||
| 2101 | android_free_cursor (f->output_data.android->bottom_left_corner_cursor); | ||
| 2102 | |||
| 2043 | /* Free extra GCs allocated by android_setup_relief_colors. */ | 2103 | /* Free extra GCs allocated by android_setup_relief_colors. */ |
| 2044 | if (f->output_data.android->white_relief.gc) | 2104 | if (f->output_data.android->white_relief.gc) |
| 2045 | { | 2105 | { |
| @@ -3971,7 +4031,11 @@ android_draw_glyph_string (struct glyph_string *s) | |||
| 3971 | static void | 4031 | static void |
| 3972 | android_define_frame_cursor (struct frame *f, Emacs_Cursor cursor) | 4032 | android_define_frame_cursor (struct frame *f, Emacs_Cursor cursor) |
| 3973 | { | 4033 | { |
| 3974 | /* Not supported, because cursors are not supported on Android. */ | 4034 | if (!f->pointer_invisible |
| 4035 | && f->output_data.android->current_cursor != cursor) | ||
| 4036 | android_define_cursor (FRAME_ANDROID_WINDOW (f), cursor); | ||
| 4037 | |||
| 4038 | f->output_data.android->current_cursor = cursor; | ||
| 3975 | } | 4039 | } |
| 3976 | 4040 | ||
| 3977 | static void | 4041 | static void |