aboutsummaryrefslogtreecommitdiffstats
path: root/src/androidterm.c
diff options
context:
space:
mode:
authorPo Lu2023-01-17 22:10:43 +0800
committerPo Lu2023-01-17 22:10:43 +0800
commit1b8258a1f2b6a080a4f0e819aa4a86c1ec2da89f (patch)
treed6c709e513882f5d430a98508e631cc503469fab /src/androidterm.c
parent356249d9faf2b454879ff30f06d97beb97fb9a36 (diff)
downloademacs-1b8258a1f2b6a080a4f0e819aa4a86c1ec2da89f.tar.gz
emacs-1b8258a1f2b6a080a4f0e819aa4a86c1ec2da89f.zip
Update Android port
* doc/emacs/android.texi (Android Fonts): Document that TTC format fonts are now supported. * doc/emacs/emacs.texi (Top): Fix menus. * doc/lispref/commands.texi (Touchscreen Events) (Key Sequence Input): Document changes to touchscreen events. * etc/DEBUG: Describe how to debug 64 bit binaries on Android. * java/org/gnu/emacs/EmacsCopyArea.java (perform): Explicitly recycle copy bitmap. * java/org/gnu/emacs/EmacsDialog.java (EmacsDialog): New class. * java/org/gnu/emacs/EmacsDrawRectangle.java (perform): Use 5 point PolyLine like X, because Android behaves like Postscript on some devices and X elsewhere. * java/org/gnu/emacs/EmacsFillRectangle.java (perform): Explicitly recycle copy bitmap. * java/org/gnu/emacs/EmacsPixmap.java (destroyHandle): Explicitly recycle bitmap and GC if it is big. * java/org/gnu/emacs/EmacsView.java (EmacsView): Make `bitmapDirty' a boolean. (handleDirtyBitmap): Reimplement in terms of that boolean. Explicitly recycle old bitmap and GC. (onLayout): Fix lock up. (onDetachedFromWindow): Recycle bitmap and GC. * java/org/gnu/emacs/EmacsWindow.java (requestViewLayout): Update call to explicitlyDirtyBitmap. * src/android.c (android_run_select_thread, android_select): Really fix android_select. (android_build_jstring): New function. * src/android.h: Update prototypes. * src/androidmenu.c (android_process_events_for_menu): Totally unblock input before process_pending_signals. (android_menu_show): Remove redundant unblock_input and debugging code. (struct android_emacs_dialog, android_init_emacs_dialog) (android_dialog_show, android_popup_dialog, init_androidmenu): Implement popup dialogs on Android. * src/androidterm.c (android_update_tools) (handle_one_android_event, android_frame_up_to_date): Allow tapping tool bar items. (android_create_terminal): Add dialog hook. (android_wait_for_event): Adjust call to android_select. * src/androidterm.h (struct android_touch_point): New field `tool_bar_p'. * src/keyboard.c (read_key_sequence, head_table) (syms_of_keyboard): Prefix touchscreen events with posn. * src/keyboard.h (EVENT_HEAD): Handle touchscreen events. * src/process.c (wait_reading_process_output): Adjust call to android_select. * src/sfnt.c (sfnt_read_table_directory): If the first long turns out to be ttcf, return -1. (sfnt_read_ttc_header): New function. (main): Test TTC support. * src/sfnt.h (struct sfnt_ttc_header): New structure. (enum sfnt_ttc_tag): New enum. * src/sfntfont-android.c (struct sfntfont_android_scanline_buffer): New structure. (GET_SCANLINE_BUFFER): New macro. Try to avoid so much malloc upon accessing the scanline buffer. (sfntfont_android_put_glyphs): Do not use SAFE_ALLOCA to allocate the scaline buffer. (Fandroid_enumerate_fonts): Enumerate ttc fonts too. * src/sfntfont.c (struct sfnt_font_desc): New field `offset'. (sfnt_enum_font_1): Split out enumeration code from sfnt_enum_font. (sfnt_enum_font): Read TTC tables and enumerate each font therein. (sfntfont_open): Seek to the offset specified. * xcompile/Makefile.in (maintainer-clean): Fix depends here.
Diffstat (limited to 'src/androidterm.c')
-rw-r--r--src/androidterm.c100
1 files changed, 92 insertions, 8 deletions
diff --git a/src/androidterm.c b/src/androidterm.c
index cc2da279bb3..f19cee5b11b 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -496,10 +496,17 @@ android_update_tools (struct frame *f, struct input_event *ie)
496 /* Build the list of active touches. */ 496 /* Build the list of active touches. */
497 for (touchpoint = FRAME_OUTPUT_DATA (f)->touch_points; 497 for (touchpoint = FRAME_OUTPUT_DATA (f)->touch_points;
498 touchpoint; touchpoint = touchpoint->next) 498 touchpoint; touchpoint = touchpoint->next)
499 ie->arg = Fcons (list3i (touchpoint->x, 499 {
500 touchpoint->y, 500 /* Skip touch points which originated on the tool bar. */
501 touchpoint->tool_id), 501
502 ie->arg); 502 if (touchpoint->tool_bar_p)
503 continue;
504
505 ie->arg = Fcons (list3i (touchpoint->x,
506 touchpoint->y,
507 touchpoint->tool_id),
508 ie->arg);
509 }
503} 510}
504 511
505/* Find and return an existing tool pressed against FRAME, identified 512/* Find and return an existing tool pressed against FRAME, identified
@@ -951,6 +958,59 @@ handle_one_android_event (struct android_display_info *dpyinfo,
951 touchpoint->next = FRAME_OUTPUT_DATA (any)->touch_points; 958 touchpoint->next = FRAME_OUTPUT_DATA (any)->touch_points;
952 FRAME_OUTPUT_DATA (any)->touch_points = touchpoint; 959 FRAME_OUTPUT_DATA (any)->touch_points = touchpoint;
953 960
961 /* Figure out whether or not the tool was pressed on the tool
962 bar. Note that the code which runs when it was is more or
963 less an abuse of the mouse highlight machinery, but it works
964 well enough in practice. */
965
966 if (WINDOWP (any->tool_bar_window)
967 && WINDOW_TOTAL_LINES (XWINDOW (any->tool_bar_window)))
968 {
969 Lisp_Object window;
970 int x = event->touch.x;
971 int y = event->touch.y;
972
973 window = window_from_coordinates (any, x, y, 0, true,
974 true);
975
976 /* If this touch has started in the tool bar, do not
977 send it to Lisp. Instead, simulate a tool bar
978 click, releasing it once it goes away. */
979
980 if (EQ (window, any->tool_bar_window))
981 {
982 /* Call note_mouse_highlight on the tool bar
983 item. Otherwise, get_tool_bar_item will
984 return 1.
985
986 This is not necessary when mouse-highlight is
987 nil. */
988
989 if (!NILP (Vmouse_highlight))
990 {
991 note_mouse_highlight (any, x, y);
992
993 /* Always allow future mouse motion to
994 update the mouse highlight, no matter
995 where it is. */
996 memset (&dpyinfo->last_mouse_glyph, 0,
997 sizeof dpyinfo->last_mouse_glyph);
998 dpyinfo->last_mouse_glyph_frame = any;
999 }
1000
1001 handle_tool_bar_click (any, x, y, true, 0);
1002
1003 /* Flush any changes made by that to the front
1004 buffer. */
1005 android_flush_dirty_back_buffer_on (any);
1006
1007 /* Mark the touch point as being grabbed by the tool
1008 bar. */
1009 touchpoint->tool_bar_p = true;
1010 goto OTHER;
1011 }
1012 }
1013
954 /* Now generate the Emacs event. */ 1014 /* Now generate the Emacs event. */
955 inev.ie.kind = TOUCHSCREEN_BEGIN_EVENT; 1015 inev.ie.kind = TOUCHSCREEN_BEGIN_EVENT;
956 inev.ie.timestamp = event->touch.time; 1016 inev.ie.timestamp = event->touch.time;
@@ -970,9 +1030,10 @@ handle_one_android_event (struct android_display_info *dpyinfo,
970 1030
971 touchpoint = android_find_tool (any, event->touch.pointer_id); 1031 touchpoint = android_find_tool (any, event->touch.pointer_id);
972 1032
973 /* If it doesn't exist, skip processing this event. */ 1033 /* If it doesn't exist or has been grabbed by the tool bar, skip
1034 processing this event. */
974 1035
975 if (!touchpoint) 1036 if (!touchpoint || touchpoint->tool_bar_p)
976 goto OTHER; 1037 goto OTHER;
977 1038
978 /* Otherwise, update the position and send the update event. */ 1039 /* Otherwise, update the position and send the update event. */
@@ -999,8 +1060,27 @@ handle_one_android_event (struct android_display_info *dpyinfo,
999 *last = touchpoint->next; 1060 *last = touchpoint->next;
1000 1061
1001 /* The tool was unlinked. Free it and generate the 1062 /* The tool was unlinked. Free it and generate the
1002 appropriate Emacs event. */ 1063 appropriate Emacs event (assuming that it was not
1064 grabbed by the tool bar). */
1003 xfree (touchpoint); 1065 xfree (touchpoint);
1066
1067 if (touchpoint->tool_bar_p)
1068 {
1069 /* Do what is necessary to release the tool bar and
1070 possibly trigger a click. */
1071
1072 if (any->last_tool_bar_item != -1)
1073 handle_tool_bar_click (any, event->touch.x,
1074 event->touch.y, false,
1075 0);
1076
1077 /* Cancel any outstanding mouse highlight. */
1078 note_mouse_highlight (any, -1, -1);
1079 android_flush_dirty_back_buffer_on (any);
1080
1081 goto OTHER;
1082 }
1083
1004 inev.ie.kind = TOUCHSCREEN_END_EVENT; 1084 inev.ie.kind = TOUCHSCREEN_END_EVENT;
1005 inev.ie.timestamp = event->touch.time; 1085 inev.ie.timestamp = event->touch.time;
1006 1086
@@ -1227,6 +1307,9 @@ android_frame_up_to_date (struct frame *f)
1227 1307
1228 /* The frame is now complete, as its contents have been drawn. */ 1308 /* The frame is now complete, as its contents have been drawn. */
1229 FRAME_ANDROID_COMPLETE_P (f) = true; 1309 FRAME_ANDROID_COMPLETE_P (f) = true;
1310
1311 /* Shrink the scanline buffer used by the font backend. */
1312 sfntfont_android_shrink_scanline_buffer ();
1230 unblock_input (); 1313 unblock_input ();
1231} 1314}
1232 1315
@@ -1513,7 +1596,7 @@ android_wait_for_event (struct frame *f, int eventtype)
1513 break; 1596 break;
1514 1597
1515 tmo = timespec_sub (tmo_at, time_now); 1598 tmo = timespec_sub (tmo_at, time_now);
1516 if (android_select (0, NULL, NULL, NULL, &tmo, NULL) == 0) 1599 if (android_select (0, NULL, NULL, NULL, &tmo) == 0)
1517 break; /* Timeout */ 1600 break; /* Timeout */
1518 } 1601 }
1519 1602
@@ -4061,6 +4144,7 @@ android_create_terminal (struct android_display_info *dpyinfo)
4061 terminal->set_bitmap_icon_hook = android_bitmap_icon; 4144 terminal->set_bitmap_icon_hook = android_bitmap_icon;
4062 terminal->implicit_set_name_hook = android_implicitly_set_name; 4145 terminal->implicit_set_name_hook = android_implicitly_set_name;
4063 terminal->menu_show_hook = android_menu_show; 4146 terminal->menu_show_hook = android_menu_show;
4147 terminal->popup_dialog_hook = android_popup_dialog;
4064 terminal->change_tab_bar_height_hook = android_change_tab_bar_height; 4148 terminal->change_tab_bar_height_hook = android_change_tab_bar_height;
4065 terminal->change_tool_bar_height_hook = android_change_tool_bar_height; 4149 terminal->change_tool_bar_height_hook = android_change_tool_bar_height;
4066 terminal->set_scroll_bar_default_width_hook 4150 terminal->set_scroll_bar_default_width_hook