1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-30 08:09:04 +00:00
Commit Graph

378 Commits

Author SHA1 Message Date
Po Lu
47f97b5ae4 Update Android port
* java/org/gnu/emacs/EmacsSafThread.java (EmacsSafThread, getCache)
(pruneCache1, pruneCache, cacheChild, cacheDirectoryFromCursor)
(documentIdFromName1, openDocumentDirectory1): Implement the
cache referred to by the commentary.
* java/org/gnu/emacs/EmacsService.java (deleteDocument):
Invalidate the cache upon document removal.
* src/androidvfs.c (android_saf_exception_check)
(android_document_id_from_name): Correctly preserve or set errno
in error cases.
2023-07-29 11:24:07 +08:00
Po Lu
25ef0c3a89 Fix SAF query
* java/org/gnu/emacs/EmacsSafThread.java (documentIdFromName1):
Fix query argument placeholder string.
2023-07-28 16:43:40 +08:00
Po Lu
0709e03f88 Allow quitting from Android content provider operations
* doc/emacs/android.texi (Android Document Providers): Say that
quitting is now possible.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
functions `safSyncAndReadInput', `safync' and `safPostRequest'.
* java/org/gnu/emacs/EmacsSafThread.java: New file.  Move
cancel-able SAF operations here.
* java/org/gnu/emacs/EmacsService.java (EmacsService): Allow
quitting from most SAF operations.
* src/androidvfs.c (android_saf_exception_check): Return EINTR
if OperationCanceledException is received.
(android_saf_stat, android_saf_access)
(android_document_id_from_name, android_saf_tree_opendir_1)
(android_saf_file_open): Don't allow reentrant calls from async
input handlers.
(NATIVE_NAME): Implement new synchronization primitives for JNI.
(android_vfs_init): Initialize new class.

* src/dired.c (open_directory): Handle EINTR from opendir.
* src/sysdep.c: Describe which operations may return EINTR on
Android.
2023-07-28 15:19:37 +08:00
Po Lu
03cf3bbb5c Update Android port
* java/org/gnu/emacs/EmacsDirectoryEntry.java
(EmacsDirectoryEntry): Make class final.
* java/org/gnu/emacs/EmacsService.java (accessDocument)
(openDocumentDirectory, openDocument, createDocument): Throw
access and IO error exceptions instead of catching them.
(createDirectory, deleteDocument): New functions.
* src/android.c (android_init_emacs_service): Add new functions.
* src/android.h (struct android_emacs_service): Likewise.
* src/androidvfs.c (android_saf_exception_check): New function.
Translate between Java exceptions and errno values.
(android_saf_stat, android_saf_access, android_saf_delete_document)
(struct android_saf_tree_vnode, android_document_id_from_name)
(android_saf_tree_name, android_saf_tree_rmdir)
(android_saf_tree_opendir_1, android_saf_tree_opendir)
(android_saf_file_open, android_saf_file_unlink)
(android_saf_new_open, android_saf_new_mkdir): Implement missing
VFS operations and derive errno values from the type of any
exceptions thrown.
(android_vfs_init): Initialize exception classes.
(android_mkdir, android_fstat): Remove trailing whitespace.
2023-07-28 12:21:47 +08:00
Po Lu
de0e0939f0 Update Android port
* doc/emacs/android.texi (Android Document Providers): Improve
wording of paragraph clarifying limits on subprocesses.
* java/org/gnu/emacs/EmacsService.java (getDocumentTrees): Use
Java standard US-ASCII coding standard instead of the
undocumented ``ASCII'' alias.
(decodeFileName): Remove unused function.
(documentIdFromName):
* src/android.c (android_init_emacs_service): Take a String for
NAME instead of a byte array.
* src/androidvfs.c (android_verify_jni_string): New function.
(android_document_id_from_name): Verify that STRING is a valid
Modified UTF-8 string.
2023-07-27 21:59:58 +08:00
Po Lu
24af8af62c Avoid crashes in some edge cases
* java/org/gnu/emacs/EmacsActivity.java (onActivityResult):
Avoid crashes in some edge cases.
2023-07-27 20:32:16 +08:00
Po Lu
65b58251b1 Update Android port
* configure.ac (ANDROID_STUBIFY): Add androidvfs.o when building
libemacs.so.
* doc/emacs/android.texi (Android): Add `Android Document Providers'.
(Android Startup): Update the location of the content identifier
directory.
(Android File System): Describe access to document provider
directories.
(Android Document Providers): New node.
* doc/emacs/emacs.texi (Top): Update the menu for the Android
appendix.
* java/Makefile.in (filename, install_temp/assets/build_info): Make
directory-tree depend on build_info.
* java/org/gnu/emacs/EmacsActivity.java (onActivityResult): New
function.  When a document tree is accepted, persist access to it.
* java/org/gnu/emacs/EmacsDirectoryEntry.java (EmacsDirectoryEntry):
New struct.
* java/org/gnu/emacs/EmacsOpenActivity.java (checkReadableOrCopy): Use
EmacsService.buildContentName.
* java/org/gnu/emacs/EmacsService.java (getEmacsView, openContentUri)
(checkContentUri): Remove excessive debug logging.
(buildContentName, getDocumentAuthorities, requestDirectoryAccess)
(getDocumentTrees, decodeFileName, documentIdFromName, getTreeUri)
(statDocument, accessDocument, openDocumentDirectory, readDirectoryEntry)
(openDocument, createDocument): New functions.

* lib-src/asset-directory-tool.c: Improve commentary by illustrating
the difference between directory and ordinary files.

* src/android.c (ANDROID_THROW, enum android_fd_table_entry_flags)
(struct android_emacs_service, android_extract_long)
(android_scan_directory_tree, android_is_directory)
(android_get_asset_name, android_url_encode, android_content_name_p)
(android_get_content_name, android_check_content_access, android_fstat)
(android_fstatat, android_file_access_p, android_hack_asset_fd_fallback)
(android_detect_ashmem, android_hack_asset_fd, android_close_on_exec)
(android_open, android_close, android_fclose, android_create_lib_link)
(android_faccessat, struct android_dir, android_opendir, android_dirfd)
(android_readdir, android_closedir, android_lookup_asset_directory_fd)
(android_exception_check_3, android_get_current_api_level)
(android_open_asset, android_close_asset, android_asset_read_quit)
(android_asset_read, android_asset_lseek, android_asset_fstat): Move
content and asset related functions to androidvfs.c.
(android_init_emacs_service): Obtain handles for new JNI functions.
(initEmacsParams): Initialize the VFS layer.
(android_request_directory_access): New function.
(android_display_toast): Remove unused function.

* src/android.h (android_get_current_api_level): Assume that
this function never returns less than __ANDROID_API__.
(struct android_emacs_service): Move `struct
android_emacs_service' here.

* src/androidfns.c (Fandroid_request_directory_access): New
interactive function.
(syms_of_androidfns): Register new subr.

* src/androidvfs.c (struct android_vdir, struct android_vops)
(struct android_vnode, struct android_special_vnode)
(enum android_vnode_type, struct android_cursor_class)
(struct emacs_directory_entry_class)
(struct android_parcel_file_descriptor_class)
(android_init_cursor_class, android_init_entry_class)
(android_init_fd_class, android_vfs_canonicalize_name)
(struct android_unix_vnode, struct android_unix_vdir, unix_vfs_ops)
(android_unix_name, android_unix_vnode, android_unix_open)
(android_unix_close, android_unix_unlink, android_unix_symlink)
(android_unix_rmdir, android_unix_rename, android_unix_stat)
(android_unix_access, android_unix_mkdir, android_unix_readdir)
(android_unix_closedir, android_unix_dirfd, android_unix_opendir)
(android_extract_long, android_scan_directory_tree)
(android_is_directory, android_init_assets)
(android_hack_asset_fd_fallback, android_detect_ashmem)
(android_hack_asset_fd, struct android_afs_vnode)
(struct android_afs_vdir, struct android_afs_open_fd, afs_vfs_ops)
(android_afs_name, android_afs_initial, android_close_on_exec)
(android_afs_open, android_afs_close, android_afs_unlink)
(android_afs_symlink, android_afs_rmdir, android_afs_rename)
(android_afs_stat, android_afs_access, android_afs_mkdir)
(android_afs_readdir, android_afs_closedir, android_afs_dirfd)
(android_afs_opendir, android_afs_get_directory_name)
(struct android_content_vdir, content_vfs_ops)
(content_directory_contents, android_content_name)
(android_content_open, android_content_close)
(android_content_unlink, android_content_symlink)
(android_content_rmdir, android_content_rename)
(android_content_stat, android_content_access)
(android_content_mkdir, android_content_readdir)
(android_content_closedir, android_content_dirfd)
(android_content_opendir, android_content_get_directory_name)
(android_content_initial, android_get_content_name)
(android_check_content_access, struct android_authority_vnode)
(authority_vfs_ops, android_authority_name, android_authority_open)
(android_authority_close, android_authority_unlink)
(android_authority_symlink, android_authority_rmdir)
(android_authority_rename, android_authority_stat)
(android_authority_access, android_authority_mkdir)
(android_authority_opendir, android_authority_initial)
(struct android_saf_root_vnode, struct android_saf_root_vdir)
(saf_root_vfs_ops, android_saf_root_name, android_saf_root_open)
(android_saf_root_close, android_saf_root_unlink)
(android_saf_root_symlink, android_saf_root_rmdir)
(android_saf_root_rename, android_saf_root_stat)
(android_saf_root_access, android_saf_root_mkdir)
(android_saf_root_readdir, android_saf_root_closedir)
(android_saf_root_dirfd, android_saf_root_opendir)
(android_saf_root_initial, android_saf_root_get_directory)
(android_saf_stat, android_saf_access)
(struct android_saf_tree_vnode, struct android_saf_tree_vdir)
(saf_tree_vfs_ops, android_document_id_from_name)
(android_saf_tree_name, android_saf_tree_open)
(android_saf_tree_close, android_saf_tree_unlink)
(android_saf_tree_symlink, android_saf_tree_rmdir)
(android_saf_tree_rename, android_saf_tree_stat)
(android_saf_tree_access, android_saf_tree_mkdir)
(android_saf_tree_opendir_1, android_saf_tree_readdir)
(android_saf_tree_closedir, android_saf_tree_dirfd)
(android_saf_tree_opendir, android_saf_tree_from_name)
(android_saf_tree_get_directory, android_saf_file_vnode)
(saf_file_vfs_ops, android_saf_file_name, android_saf_file_open)
(android_saf_file_unlink, android_saf_file_rmdir)
(android_saf_file_opendir, android_close_parcel_fd)
(android_saf_new_vnode, android_saf_new_name, android_saf_new_open)
(android_saf_new_unlink, android_saf_new_symlink)
(android_saf_new_rmdir, android_saf_new_rename)
(android_saf_new_stat, android_saf_new_access)
(android_saf_new_mkdir, android_saf_new_opendir, root_vfs_ops)
(special_vnodes, android_root_name, android_name_file)
(android_vfs_init, android_open, android_unlink, android_symlink)
(android_rmdir, android_mkdir, android_renameat_noreplace)
(android_rename, android_fstat, android_fstatat_1, android_fstatat)
(android_faccessat, android_fdopen, android_close, android_fclose)
(android_open_asset, android_close_asset, android_asset_read_quit)
(android_asset_read, android_asset_lseek, android_asset_fstat)
(android_opendir, android_dirfd, android_readdir)
(android_closedir): Move file system emulation routines here.
Introduce a new ``VFS'' layer for translating between
Emacs-specific file names and the various disparate interfaces
for accessing files on Android.

* src/callproc.c (delete_temp_file):
* src/charset.c (load_charset_map_from_file):
* src/dired.c:
* src/emacs.c (Fkill_emacs):
* src/fileio.c (check_mutable_filename, Fcopy_file)
(Fmake_directory_internal, Fdelete_directory_internal)
(Fdelete_file, Frename_file, Fadd_name_to_file)
(Fmake_symbolic_link, file_accessible_directory_p, Fset_file_modes)
(Fset_file_times, write_region):
* src/filelock.c (get_boot_time, rename_lock_file)
(create_lock_file, current_lock_owner, unlock_file):
* src/image.c (slurp_file, png_load_body, jpeg_load_body):
* src/keyboard.c (Fopen_dribble_file):
* src/lisp.h:
* src/lread.c (Fload):
* src/process.c (handle_child_signal):
* src/sysdep.c (init_standard_fds, emacs_fopen, emacs_fdopen)
(emacs_unlink, emacs_symlink, emacs_rmdir, emacs_mkdir)
(emacs_renameat_noreplace, emacs_rename):
* src/term.c (Fresume_tty, init_tty): Use and add new wrappers
for fopen, fdopen, unlink, symlink, rmdir, mkdir,
renameat_norepalce and rename.
2023-07-27 17:13:39 +08:00
Po Lu
7e8904e796 Use context menu header titles on Android
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu):
New field `title'.
(addSubmenu): New arg TITLE.  Set that field.
(expandTo): Set MENU's header title if it's a context menu.
* src/androidmenu.c (android_init_emacs_context_menu): Adjust
signature of `createContextMenu'.
(android_menu_show): Use TITLE instead of pane titles if there's
only one pane.
2023-07-20 11:21:25 +08:00
Po Lu
5ff31bf36c Update Android port
* doc/lispref/commands.texi (Touchscreen Events): Describe
treatment of canceled touch sequences during touch event
translation.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): Update JNI
prototypes.
* java/org/gnu/emacs/EmacsWindow.java (motionEvent): Set
cancelation flag in events sent where appropriate.
* lisp/touch-screen.el (touch-screen-handle-point-update):
Improve treatment of horizontal scrolling near window edges.
(touch-screen-handle-touch): Don't handle point up if the touch
sequence has been canceled.
* src/android.c (sendTouchDown, sendTouchUp, sendTouchMove): New
argument `flags'.
* src/androidgui.h (enum android_touch_event_flags): New enum.
(struct android_touch_event): New field `flags'.
* src/androidterm.c (handle_one_android_event): Report
cancelation in TOUCHSCREEN_END_EVENTs.
* src/keyboard.c (make_lispy_event): Fix botched merge.
2023-07-18 10:12:40 +08:00
Po Lu
8335c76e88 Update Android port
* java/org/gnu/emacs/EmacsService.java (displayToast):
* src/android.c (android_init_emacs_service): Remove unused
function.
* lisp/touch-screen.el (touch-screen-handle-point-up): Correctly
compute posn point.
(touch-screen-translate-touch): Update doc string.
(function-key-map): Define touch screen translation functions
within the internal border.
2023-07-16 20:10:18 +08:00
Po Lu
e9a39fd898 Update Android port
* doc/emacs/android.texi (Android): Add new node to menu.
(Android Environment): Add footnote pointing to new node.
(Android Software): New node.
* doc/emacs/emacs.texi (Top): Add new node to menu.
* java/AndroidManifest.xml.in (manifest): Fix location of
sharedUserId property.
* java/INSTALL: Improve documentation of shared user ID
support.
2023-07-15 09:53:22 +08:00
Po Lu
11c8a2fa87 Make --with-shared-user-id work
* configure.ac (ANDROID_SHARED_USER_NAME): New variable.
Substitute it.
* java/AndroidManifest.xml.in: Set `sharedUserLabel' if a shared
user ID is enabled.
* java/res/values/strings.xml (shared_user_name): New string
resource.
2023-07-14 20:30:30 +08:00
Po Lu
4c390f14f4 Clean up Android debug code
* java/org/gnu/emacs/EmacsInputConnection.java
(getSurroundingText): Don't print debug information if DEBUG_IC
is off.
2023-07-14 08:51:07 +08:00
Po Lu
ae9f1a075c Improve workaround for partial texture updates on Android
* java/AndroidManifest.xml.in:
* java/org/gnu/emacs/EmacsDialog.java (toAlertDialog): Don't
change hardware acceleration state.
* java/org/gnu/emacs/EmacsNative.java (notifyPixelsChanged): New
function.
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
New field `bitmapChanged'.
(copyToFrontBuffer): Signal that the bitmap has changed.
(onDraw): If the bitmap has changed, increment the generation
ID.
* src/android.c (JNICALL): Implement new function.
2023-07-13 18:17:59 +08:00
Po Lu
140755f2cf Disable hardware acceleration on Android
It serves no purpose and causes tearing.  Uploading the bitmap
to the GPU takes about as long as it does to incrementally
update the surface in software.

* java/AndroidManifest.xml.in: Disable hardware acceleration.
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity): Make
lastClosedMenu static.
* java/org/gnu/emacs/EmacsDialog.java (toAlertDialog): Enable
hardware acceleration within alert dialogs.
* java/org/gnu/emacs/EmacsSurfaceView.java (onDraw): Describe
why hardware acceleration is disabled.
* java/org/gnu/emacs/EmacsWindow.java (run): Remove redundant
call.
2023-07-13 12:05:50 +08:00
Po Lu
c8c2bec5f8 Update Android port
* java/org/gnu/emacs/EmacsWindow.java (whatButtonWasIt): Handle
back and forward buttons along with styluses.
* src/doc.c (close_file_unwind_android_fd): New function.
(get_doc_string, Fsnarf_documentation): Don't create a temporary
fd if it can be avoided.
2023-07-12 09:45:58 +08:00
Po Lu
fcf53bf9f5 Fix doc file generation on Android
* .gitignore: Ignore cross/etc/DOC.
* configure.ac: Make the directory `cross/etc'.
* cross/Makefile.in (CLEAN_SUBDIRS): Clean files inside `etc' as
well.
* java/Makefile.in (install_temp): Copy cross/etc/DOC to the
package if it is available.
* src/Makefile.in (SOME_MACHINE_OBJECTS): Add androidselect.c,
sfntfont-android.c and sfntfont.c.
(libemacs.so): Depend on $(etc)/DOC.
2023-07-11 16:47:13 +08:00
Po Lu
24ae08c113 Update Android port
* java/org/gnu/emacs/EmacsView.java (onGenericMotionEvent): Call
onGenericMotionEvent.
* java/org/gnu/emacs/EmacsWindow.java (Coordinate): New fields
`button' and `id'.
(<init>): Add new arguments to the construtor.
(whatButtonWasIt): Return 0 if the button state has not changed.
(buttonForEvent): New function.
(figureChange): Return the Coordinate object associated to
EVENT.  Determine whether or not EVENT was accompanied by a
change to the button state, and ascertain which button that was.
(motionEvent): New function.
(onGenericMotionEvent, onTouchEvent): Factor out touch and mouse
event delivery to motionEvent.
2023-07-11 10:22:03 +08:00
Po Lu
cf2dde4261 Update Android port
* java/org/gnu/emacs/EmacsService.java (browseUrl): New argument
SEND.  Choose from a list of applications that want to share the
URL if true.
* lisp/net/browse-url.el (browse-url-android-share): New user
option.
(browse-url-default-android-browser): Respect said user option.
* src/android.c (android_init_emacs_service)
(android_browse_url): Expose new option.
* src/android.h: Update prototypes.
* src/androidselect.c (Fandroid_browse_url): Likewise.
2023-07-10 13:31:57 +08:00
Po Lu
ed5ade097e Update Android port
* java/org/gnu/emacs/EmacsWindow.java (eventModifiers)
(motionEventModifiers): New functions.
(onKeyDown, onKeyUp, onFocusChanged, onSomeKindOfMotionEvent):
Don't record the previous modifier mask; instead, always use the
modifier state specified in the event.
* src/androidterm.c (handle_one_android_event): Don't dispatch
button release events when a popup is active.
2023-07-09 13:13:53 +08:00
Po Lu
97f926b82d Update Android port
* java/org/gnu/emacs/EmacsService.java (onStartCommand): Fix
typo in notification message.
* java/org/gnu/emacs/EmacsWindow.java (onFocusChanged): Reset
the recorded modifier state upon a change to the window focus.
2023-07-09 12:50:15 +08:00
Po Lu
8afb5644fd ; * java/org/gnu/emacs/EmacsService.java (onCreate): Fix typo. 2023-07-09 10:06:18 +08:00
Po Lu
105c876a60 Update Android port
* java/org/gnu/emacs/EmacsDrawPoint.java (perform): Don't fill
an extra pixel.
* java/org/gnu/emacs/EmacsService.java (onCreate): Make sure
scaledDensity is always at least 160 dpi.
2023-07-09 10:05:08 +08:00
Po Lu
a36207574a Fix EmacsDrawLine again
* java/org/gnu/emacs/EmacsDrawLine.java (perform): Symmetrically
adjust coordinates to cover the last pixel.  Then, fill the left
most pixel of the line.
2023-07-08 21:49:21 +08:00
Po Lu
c843f3e23b Update Android port
* java/org/gnu/emacs/EmacsService.java (DEBUG_IC)
(DEBUG_THREADS): Improve commentary.
* src/androidterm.c (handle_one_android_event): Signal
completion of IME events that have lost their frames.
(requestCursorUpdates): Don't set an edit counter as this event
won't be passed to the text conversion machinery.
2023-07-08 10:15:38 +08:00
Po Lu
e40dca8361 Update Android port
* java/org/gnu/emacs/EmacsSurfaceView.java (copyToFrontBuffer):
Use fallback bit blit function on Android 7.0 as well, as
crashes have been observed in drawBitmap.
2023-07-07 14:22:38 +08:00
Po Lu
75db451170 Update Android port
* java/org/gnu/emacs/EmacsNative.java (scaledDensity): Announce
new argument `scaledDensity'.
* java/org/gnu/emacs/EmacsNoninteractive.java (main): Specify
new argument.
* java/org/gnu/emacs/EmacsService.java (onCreate): Compute an
adjusted DPI for the font size based on the ratio between
density and scaledDensity.
(run): Specify that adjusted density.
* src/android.c (setEmacsParams): Set
`android_scaled_pixel_density'.
* src/android.h: (android_scaled_pixel_density: New variable.
* src/androidterm.c (android_term_init): Set `font_resolution'.
* src/androidterm.h (struct android_display_info): New field.
* src/font.c (font_pixel_size, font_find_for_lface)
(font_open_for_lface, Ffont_face_attributes, Fopen_font): Use
FRAME_RES instead of FRAME_RES_Y.
* src/frame.h (FRAME_RES): New macro.  Use this to convert
between font point and pixel sizes as opposed to FRAME_RES_Y.
* src/w32font.c (fill_in_logfont):
* src/xfaces.c (Fx_family_fonts, set_lface_from_font): Use
FRAME_RES instead of FRAME_RES_Y.  (bug#64444)
2023-07-06 09:35:27 +08:00
Po Lu
08f90dc005 Fix bug#64445
* doc/emacs/android.texi (Android Environment): Document that
Emacs also receives READ_EXTERNAL_STORAGE by default on old
versions of Android.
* java/AndroidManifest.xml.in: Request READ_EXTERNAL_STORAGE.
(bug#64445)
2023-07-05 20:16:14 +08:00
Po Lu
257e49ff0d Fix crash between Android 4.0 and Android 5.1
* java/org/gnu/emacs/EmacsService.java (detectMouse): Don't use
function that is not present on Android 4.0.
2023-07-05 14:57:15 +08:00
Po Lu
a5ee9a69ae Update Android port
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java (Sdk7FontEntity):
(hasChar): Clean up dead stores.
2023-06-23 11:54:56 +08:00
Po Lu
405d14402f Update Android port
* java/org/gnu/emacs/EmacsView.java (EmacsView, dimensionsLock):
New field.
(<init>): Create new lock object.
(handleDirtyBitmap, onLayout, onAttachedToWindow): Make sure
measuredWidth and measuredHeight are extracted and set
atomically.  Send Expose upon layout changes if the view has
grown.
2023-06-19 15:26:07 +08:00
Po Lu
797c30b7ab Initialize signal mask earlier
* java/org/gnu/emacs/EmacsService.java (onCreate, run): Don't
initialize signal mask here.
* java/org/gnu/emacs/EmacsApplication.java (onCreate): Do it
here instead.
* src/android.c (JNICALL): Restore previous signal masks.
2023-06-17 12:07:40 +08:00
Po Lu
fa821ed186 ; * java/README: More documentation. 2023-06-17 11:24:54 +08:00
Po Lu
377a3ebbb5 Update Android port
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity):
* java/org/gnu/emacs/EmacsApplication.java (findDumpFile):
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu)
(addSubmenu, display):
* java/org/gnu/emacs/EmacsDocumentsProvider.java
(getNotificationUri, queryChildDocuments, deleteDocument):
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform):
* java/org/gnu/emacs/EmacsFillRectangle.java (perform):
* java/org/gnu/emacs/EmacsOpenActivity.java (readEmacsClientLog)
(checkReadableOrCopy):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java
(EmacsSdk7FontDriver):
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
* java/org/gnu/emacs/EmacsView.java (EmacsView):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow, onKeyUp):
* java/org/gnu/emacs/EmacsWindowAttachmentManager.java
(EmacsWindowAttachmentManager): Remove various unused arguments
and variables, dead stores, and make minor cleanups and
performance improvements.
* src/androidmenu.c (FIND_METHOD_STATIC, android_menu_show):
Adjust accordingly.
2023-06-16 12:59:44 +08:00
Po Lu
363e293cc9 Update Android port
* java/org/gnu/emacs/EmacsInputConnection.java
(EmacsInputConnection, beginBatchEdit, reset, endBatchEdit):
Keep track of the number of batch edits and return an
appropriate value.
(takeSnapshot): Implement function.
* java/org/gnu/emacs/EmacsNative.java (takeSnapshot): New
function.
* java/org/gnu/emacs/EmacsService.java (resetIC): Improve
debugging output.
* java/org/gnu/emacs/EmacsView.java (onCreateInputConnection):
Call `reset' to clear the UI side batch edit count.
* src/androidterm.c (struct
android_get_surrounding_text_context): New fields
`conversion_start' and `conversion_end'.
(android_get_surrounding_text): Return the conversion region.
(android_get_surrounding_text_internal, NATIVE_NAME): Factor out
`getSurroundingText'.
(takeSnapshot): New function.
2023-06-15 12:36:50 +08:00
Po Lu
90ae3cc387 Improve IM synchronization on Android
* java/org/gnu/emacs/EmacsInputConnection.java
(EmacsInputConnection): Reimplement as an InputConnection, not
BaseInputConnection.
* src/androidterm.c (performEditorAction): Sync prior to sending
keyboard events.
2023-06-14 15:37:47 +08:00
Po Lu
1cd514c297 Improve appearance of custom dialog buttons on Android
* java/org/gnu/emacs/EmacsDialog.java (toAlertDialog): Resolve
dialog button style and use it instead.
2023-06-12 20:09:09 +08:00
Po Lu
3b08bb1318 Fix deadlocks
* java/org/gnu/emacs/EmacsView.java (EmacsView)
(showOnScreenKeyboard, hideOnScreenKeyboard): Don't synchronize.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow)
(toggleOnScreenKeyboard): Revert to calling IMM functions from
the main thread.
* src/android.c (struct android_event_container)
(android_pselect_nfds, android_pselect_readfds)
(android_pselect_writefds, android_pselect_exceptfds)
(android_pselect_timeout): Don't make volatile.
(android_wait_event): Run queries if necessary.
2023-06-12 14:19:01 +08:00
Po Lu
24f25fc2f8 Update Android port
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
Document member variables.
(onDraw): Use separate Paint object on the UI thread.
* src/textconv.c (really_commit_text, really_set_composing_text)
(really_delete_surrounding_text): Run modification hooks when
deleting text.
2023-06-11 14:35:13 +08:00
Po Lu
5abc977bbb Avoid extraneous calls to the UI thread
* java/org/gnu/emacs/EmacsView.java (EmacsView)
(showOnScreenKeyboard, hideOnScreenKeyboard)
(onCheckIsTextEditor): Make synchronized.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow)
(toggleOnScreenKeyboard): Don't post to the main thread.
2023-06-11 08:52:10 +08:00
Po Lu
c321eea5af Block profiling signals in the Android UI thread
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
function `setupSystemThread'.
* java/org/gnu/emacs/EmacsService.java (onCreate): Block all
signals except for SIGBUS and SIGSEGV in the UI thread.
* src/android.c (setupSystemThread): New function.
2023-06-09 14:03:50 +08:00
Po Lu
7f073df533 Fix crash starting Emacs to open file
* java/org/gnu/emacs/EmacsThread.java (run): Correct check
against extraStartupArgument when an initial file is specified.
2023-06-09 09:27:04 +08:00
Po Lu
1661762784 Correctly display popup dialogs from Emacsclient
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu):
Make subclasses final.
* java/org/gnu/emacs/EmacsDialog.java (display1): Check if an
instance of EmacsOpenActivity is open; if it is, try using it to
display the pop up dialog.
* java/org/gnu/emacs/EmacsDialogButtonLayout.java
(EmacsDialogButtonLayout): Make final.
* java/org/gnu/emacs/EmacsHolder.java (EmacsHolder<T>):
Likewise.
* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity):
New field `currentActivity'.
(onCreate, onDestroy, onWindowFocusChanged, onPause): Set that
field as appropriate.
2023-06-08 20:50:02 +08:00
Po Lu
63339a9577 Update Android port
* java/org/gnu/emacs/EmacsInputConnection.java (beginBatchEdit)
(endBatchEdit, commitCompletion, commitText, deleteSurroundingText)
(finishComposingText, getSelectedText, getTextAfterCursor)
(getTextBeforeCursor, setComposingText, setComposingRegion)
(performEditorAction, performContextMenuAction, getExtractedText)
(setSelection, sendKeyEvent, deleteSurroundingTextInCodePoints)
(requestCursorUpdates): Ensure that the input connection is up
to date.
(getSurroundingText): New function.
* java/org/gnu/emacs/EmacsNative.java (getSurroundingText):
Export new C function.
* java/org/gnu/emacs/EmacsService.java (resetIC): Invalidate
previously created input connections.
* java/org/gnu/emacs/EmacsView.java (EmacsView)
(onCreateInputConnection): Signify that input connections are
now up to date.
* src/androidterm.c (struct
android_get_surrounding_text_context): New structure.
(android_get_surrounding_text, NATIVE_NAME):
* src/textconv.c (get_surrounding_text):
* src/textconv.h: New functions.
2023-06-07 11:03:56 +08:00
Po Lu
5b4dea0fc7 Update Android port
* java/org/gnu/emacs/EmacsContextMenu.java (display): Use
`EmacsHolder' instead of `Holder'.
* java/org/gnu/emacs/EmacsDialog.java (toAlertDialog): Use
`EmacsDialogButtonLayout' to ensure that buttons are wrapped
properly.
(display): Adjust for new holder class.
* java/org/gnu/emacs/EmacsDialogButtonLayout.java
(EmacsDialogButtonLayout, onMeasure, onLayout): New functions.

* java/org/gnu/emacs/EmacsDrawLine.java:
* java/org/gnu/emacs/EmacsFillPolygon.java: Remove redundant
imports.
* java/org/gnu/emacs/EmacsHolder.java (EmacsHolder<T>):
* java/org/gnu/emacs/EmacsService.java (class Holder<T>)
(getEmacsView, EmacsService): Rename `Holder' to `EmacsHolder'
and make it public.
2023-06-06 14:35:19 +08:00
Po Lu
66783af554 Update Android port
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
function clearInputFlags.
* java/org/gnu/emacs/EmacsView.java (onCreateInputConnection):
Stop reporting changes after a new input method connection is
established.
* src/androidterm.c (android_handle_ime_event): Implement that
change.
(JNICALL): New function.
2023-06-05 10:38:25 +08:00
Po Lu
740af4668c Fix input method synchronization problems
* java/debug.sh (gdbserver_cmd, is_root): Prefer TCP again.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
function `queryAndSpin'.
* java/org/gnu/emacs/EmacsService.java (EmacsService)
(icBeginSynchronous, icEndSynchronous, viewGetSelection): New
synchronization functions.
(resetIC, updateCursorAnchorInfo): Call those instead.
* java/org/gnu/emacs/EmacsView.java (onCreateInputConnection):
Call viewGetSelection.
* src/android.c (JNICALL, android_answer_query_spin): New
functions.
2023-06-04 12:04:15 +08:00
Po Lu
189a91bfb6 Update Android port
* java/org/gnu/emacs/EmacsInputConnection.java
(EmacsInputConnection): Apply workarounds on Vivo devices as
well.
* src/android.c (sendKeyPress, sendKeyRelease): Clear counter.
* src/androidgui.h (struct android_key_event): New field
`counter'.
* src/androidterm.c (handle_one_android_event): Generate
barriers as appropriate.
(JNICALL): Set `counter'.
* src/frame.h (enum text_conversion_operation):
* src/textconv.c (detect_conversion_events)
(really_set_composing_text, handle_pending_conversion_events_1)
(handle_pending_conversion_events, textconv_barrier):
* src/textconv.h: Implement text conversion barriers and fix
various typos.
2023-06-02 13:31:40 +08:00
Po Lu
0014a10b24 Correctly export file:// URIs on Android
* java/org/gnu/emacs/EmacsService.java (browseUrl): If uri's
scheme is `file', rewrite it into a content URI.
2023-06-01 16:31:50 +08:00
Po Lu
aed0a11147 Update Android port
* java/org/gnu/emacs/EmacsInputConnection.java
(EmacsInputConnection, performContextMenuAction): New function.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative)
(performContextMenuAction): New function.
* src/android.c (android_get_gc_values): Implement more
efficiently.
* src/androidterm.c (android_handle_ime_event): Pass through
`update' argument to `finish_composing_text'.  Fix thinko.
* src/textconv.c (really_finish_composing_text)
(really_set_composing_text, really_set_composing_region)
(handle_pending_conversion_events_1, finish_composing_text): New
argument `update'.  Notify IME of conversion region changes if
set.
* src/textconv.h: Update structs and prototypes.
2023-06-01 15:16:02 +08:00
Po Lu
9a958c59a2 Update Android port
* java/org/gnu/emacs/EmacsInputConnection.java
(EmacsInputConnection): Add compatibility adjustments for
Samsung devices.
2023-06-01 10:05:42 +08:00
Po Lu
57903519eb Update Android port
* java/debug.sh (is_root): Go back to using unix sockets; allow
adb to forward them correctly.
* java/org/gnu/emacs/EmacsInputConnection.java
(getExtractedText): Don't print text if NULL.
* java/org/gnu/emacs/EmacsService.java (EmacsService): New field
`imSyncInProgress'.
(updateIC): If an IM sync might be in progress, avoid deadlocks.
* java/org/gnu/emacs/EmacsView.java (onCreateInputConnection):
Set `imSyncInProgress' across synchronization point.
* src/android.c (android_check_query): Use __atomic_store_n.
(android_answer_query): New function.
(android_begin_query): Set `android_servicing_query' to 2.
Check once, and don't spin waiting for query to complete.
(android_end_query): Use __atomic_store_n.
(android_run_in_emacs_thread): Compare-and-exchange flag.  If
originally 1, fail.
* src/textconv.c (really_set_composing_text): Clear conversion
region if text is empty.
2023-05-31 10:13:04 +08:00
Po Lu
7fdde02f32 Work around more problems with Bitmaps
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
function `blitRect'.
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
Use it on Android 8.x.
* src/android.c (blitRect): Implement new function.
2023-05-29 17:46:19 +08:00
Po Lu
00671b1843 Implement android_copy_area in C
* java/org/gnu/emacs/EmacsCopyArea.java: Remove file.
* java/org/gnu/emacs/EmacsService.java (EmacsService, copyArea):
Delete function.
* src/android.c (struct android_emacs_service)
(android_init_emacs_service): Remove `copy_area'.
(android_create_gc, android_change_gc, android_get_gc_values):
Record new GC values.
(android_neon_mask_line): New function.
(android_blit_copy, android_blit_xor): New functions.
(android_copy_area): Implement in C.
(android_lock_bitmap): Accept drawables instead of windows.
* src/android.h: Adjust prototype for `android_lock_bitmap'.
* src/androidgui.h (struct android_gc): Record last known GC
values.
2023-05-29 15:44:14 +08:00
Po Lu
327d2d0131 Add extra thread-related checking
* java/org/gnu/emacs/EmacsService.java (EmacsService)
(checkEmacsThread): New function.
(fillPolygon, drawRectangle, drawLine, drawPoint, copyArea)
(clearArea):
* java/org/gnu/emacs/EmacsThread.java (EmacsThread):
* java/org/gnu/emacs/EmacsView.java (EmacsView, swapBuffers):
Call where appropriate.
2023-05-27 16:30:12 +08:00
Po Lu
d33bf0a0af Remove synchronization around `damageRegion'
* java/org/gnu/emacs/EmacsView.java (EmacsView, swapBuffers):
Remove unnecessary documentation.  `damageRegion' is only
changed from the Emacs thread.
2023-05-27 15:19:02 +08:00
Po Lu
0eb1f4e571 Allow starting Emacs --debug-init on Android
* doc/emacs/android.texi (Android Troubleshooting): Document
`debug-init' option.
* java/AndroidManifest.xml.in
(EmacsLauncherPreferencesActivity): New activity.  Export on
systems older than Android 7.0.
* java/org/gnu/emacs/EmacsActivity.java (onCreate): Adjust for
string startup argument.
* java/org/gnu/emacs/EmacsLauncherPreferencesActivity.java: New
file.
* java/org/gnu/emacs/EmacsPreferencesActivity.java
(EmacsPreferencesActivity): Don't make final.
(startEmacsQ): Give start-up argument as an argument, not as a
boolean.
(startEmacsDebugInit): New function.
(onCreate): Register new listener; make final.
* java/org/gnu/emacs/EmacsService.java (onCreate): Pass
extraStartupArgument.
* java/org/gnu/emacs/EmacsThread.java (EmacsThread): Rename
startDashQ to extraStartupArgument.
(run): Adjust accordingly.
* java/res/values-v24/bool.xml:
* java/res/values/bool.xml:
* java/res/values/strings.xml: New files.
* java/res/xml/preferences.xml: Add new option.  Move string
resources around.
2023-05-26 15:20:39 +08:00
Po Lu
181453285c Update Android port
* java/org/gnu/emacs/EmacsView.java (swapBuffers): Restore
missing damage rect code.
(onDetachedFromWindow): Remove redundant synchronization.
2023-05-20 10:26:28 +08:00
Po Lu
841b0e2201 Implement document moving on Android
* java/org/gnu/emacs/EmacsDocumentsProvider.java
(notifyChangeByName): New function.
(queryDocument1): Set FLAG_SUPPORTS_MOVE where necessary.
(moveDocument): Implement new function.
2023-05-14 11:12:54 +08:00
Po Lu
428c59180d Update Android port
* java/Makefile.in (install_temp/assets/version): Fix generation
in out of tree builds.
2023-05-08 08:34:27 +08:00
Po Lu
889b61b999 Update Android port
* java/org/gnu/emacs/EmacsInputConnection.java
(requestCursorUpdates):
* java/org/gnu/emacs/EmacsNative.java (requestCursorUpdates):
* java/org/gnu/emacs/EmacsService.java (updateCursorAnchorInfo):
New functions.
* src/android.c (struct android_emacs_service)
(android_init_emacs_service): Add new method.
(android_update_cursor_anchor_info): New function.
* src/androidfns.c (android_set_preeditarea): New function.
* src/androidgui.h (enum android_ime_operation): New operation
`REQUEST_CURSOR_UPDATES'.
(struct android_ime_event): Document new meaning of `length'.
* src/androidterm.c (android_request_cursor_updates): New
function.
(android_handle_ime_event): Handle new operations.
(handle_one_android_event, android_draw_window_cursor): Update
the preedit area if needed, like on X.
(requestCursorUpdates): New function.
* src/androidterm.h (struct android_output): New field
`need_cursor_updates'.
2023-05-07 11:09:56 +08:00
Po Lu
3198b7dc56 Update Android port
* cross/verbose.mk.android: Get rid of badly aligned ANDROID_CC
messages.
* java/org/gnu/emacs/EmacsInputConnection.java (syncAfterCommit)
(extractAbsoluteOffsets): Add workarounds for several kinds of
machines.
(commitText, getExtractedText): Likewise.
* src/textconv.c (really_commit_text): Improve definition of
POSITION.
(get_extracted_text): Default to providing at least 4
characters.
2023-05-06 11:32:56 +08:00
Po Lu
258c98240d Update Android port
* java/Makefile.in (FIND_DELETE): New substitution.
(clean): Use FIND_DELETE.
2023-05-03 07:50:29 +08:00
Po Lu
ddc16de869 Update Android port
* Makefile.in (extraclean): Clean in exec as well.
* configure.ac: Fix detection of absolute srcdir.  Also, pass
CFLAGS.
* exec/Makefile.in: (.c.o): Add -I. so config.h can be
found.:(.s.o): Don't create m4 temporary in srcdir.
* exec/config-mips.m4.in (DADDI2, DADDI3): New macros.  Define
to substitute if as cannot assemble daddi.
* exec/configure.ac (user_h): Look for user.h in asm/ as well.
Use new user.h.  Also look in ptrace.h on arm systems.  Check if
as supports daddi on mips64.
* exec/exec.c (check_interpreter): Fix char signedness bug.
* exec/loader-mips64el.s (__start): Use DADDI2 and DADDI3 for
two- and 3-operand daddi.
* exec/mipsel-user.h: Don't include sgidefs.h.
* java/INSTALL: Document that m4 is now required.
* src/android.c (android_rewrite_spawn_argv): Add missing NULL.
2023-05-01 11:28:22 +08:00
Po Lu
368f6f3942 Add helper binary `exec1'
* .gitignore: New files.
* Makefile.in (mostlyclean_dirs): Add libexec, if its Makefile
exists.
* autogen.sh (do_git): Autoreconf in exec as well.
* configure.ac: Configure libexec on Android.
* exec/Makefile.in:
* exec/README:
* exec/config-mips.m4.in:
* exec/config.guess:
* exec/config.h.in:
* exec/config.sub:
* exec/configure:
* exec/configure.ac:
* exec/deps.mk:
* exec/exec.c (MIN, struct exec_open_command)
(struct exec_map_command, struct exec_jump_command)
(write_open_command, write_load_command, process_interpreter_1)
(process_interpreter, process_program_header, insert_args)
(exec_0):
* exec/exec.h (_EXEC_H_, struct elf_header_32)
(struct program_header_32, struct dt_entry_32)
(struct elf_header_64, struct program_header_64)
(struct dt_entry_64, struct exec_tracee):
* exec/exec1.c (main):
* exec/install-sh (scriptversion):
* exec/loader-aarch64.s (_start):
* exec/loader-armeabi.s (_start):
* exec/loader-mips64el.s (__start):
* exec/loader-mipsel.s (__start):
* exec/loader-x86.s (_start):
* exec/loader-x86_64.s (_start):
* exec/mipsel-user.h (_MIPSEL_USER_H_):
* exec/mipsfpu.c (MIPS_ABI_FP_ANY, fpu_reqs, valid_abi_p)
(fp_mode_for_abi, cpu_supports_fr0_p, determine_fpu_mode):
* exec/mipsfpu.h (_MIPSFPU_H_, FP_FR0):
* exec/test.c (print_usage, main):
* exec/trace.c (MAX_TRACEES, aarch64_set_regs, read_memory)
(user_alloca, user_copy, remove_tracee, handle_clone)
(syscall_trap_p, handle_exec, process_system_call, tracing_execve)
(after_fork, find_tracee, exec_waitpid, exec_init): New files.
* java/Makefile.in (CROSS_EXEC_BINS): Add exec1 and
loader.
($(CROSS_EXEC_BINS) &): New target.
2023-04-30 21:37:19 +08:00
Po Lu
3d7c06869d Update Android port
* build-aux/ndk-build-helper.mk (TARGET_ARCH): Define variable.
* configure.ac (ENABLE_CHECKING, CHECK_STRUCTS)
(GC_CHECK_STRING_OVERRUN, GC_CHECK_STRING_FREE_LIST, GLYPH_DEBUG)
(GC_CHECK_STRING_BYTES): Enable checking correctly on Android.
* java/README: Fix typos.
* m4/ndk-build.m4 (ndk_run_test): Pass target arch.
* src/android.c (android_get_content_name, android_close)
(android_fclose, android_check_string): Fix various typos caught
by checking.
* src/charset.c (load_charset_map_from_file): Call emacs_fclose,
not fclose.
* src/image.c (image_set_transform): Fix thinko.
(png_load_body, jpeg_load_body, gif_load): Call emacs_fclose,
not fclose.  Use open instead of fdopen.
* src/xfaces.c (Fx_load_color_file): Likewise.
2023-04-29 08:27:44 +08:00
Po Lu
3b07a4b315 Implement `yank-media' on Android
* doc/emacs/android.texi (Android Windowing): Update selection
restrictions.
* java/org/gnu/emacs/EmacsClipboard.java (EmacsClipboard): New
functions `getClipboardTargets' and `getClipboardData'.
* java/org/gnu/emacs/EmacsSdk11Clipboard.java
(EmacsSdk11Clipboard, getClipboardTargets, getClipboardData):
Implement.
* java/org/gnu/emacs/EmacsSdk8Clipboard.java: Stub out new
functions.

* lisp/term/android-win.el (android-get-clipboard-1): Implement
MIME type targets.
* src/android.c (android_exception_check)
(android_exception_check_1, android_exception_check_2): Fix
punctuation in warning message.
(android_exception_check_nonnull_1): New function.
* src/android.h: Update prototypes.
* src/androidselect.c (struct android_emacs_clipboard): New
methods.
(android_init_emacs_clipboard): Initialize new methods.
(Fandroid_get_clipboard_targets, android_xfree_inside)
(Fandroid_get_clipboard_data): New functions.
(syms_of_androidselect): Define new subrs.
2023-04-06 09:56:23 +08:00
Po Lu
b26b4c537b ; * java/INSTALL: Fix typo. 2023-03-20 15:37:11 +08:00
Po Lu
6bd1cfa24f Update Android port
* configure.ac: Add support for HarfBuzz on Android.
* java/INSTALL: Document where to get Emacs with HarfBuzz.
* lisp/subr.el (overriding-text-conversion-style, y-or-n-p):
Correctly set text conversion style if y-or-n-p is called inside
the minibuffer.
* src/sfnt.c (sfnt_read_cmap_format_8)
(sfnt_read_cmap_format_12): Fix typos.
(sfnt_read_24, sfnt_read_cmap_format_14): New function.
(sfnt_read_cmap_table_1, sfnt_read_cmap_table): Handle format 14
cmap tables.
(sfnt_read_default_uvs_table, sfnt_read_nondefault_uvs_table)
(sfnt_compare_table_offsets, sfnt_create_uvs_context)
(sfnt_free_uvs_context, sfnt_compare_uvs_mapping)
(sfnt_variation_glyph_for_char, sfnt_map_table, sfnt_unmap_table)
(sfnt_read_table, sfnt_test_uvs): New functions.
(main): Add UVS tests.
* src/sfnt.h (struct sfnt_cmap_format_14)
(struct sfnt_variation_selector_record)
(struct sfnt_default_uvs_table, struct sfnt_unicode_value_range)
(struct sfnt_nondefault_uvs_table, struct sfnt_uvs_mapping)
(struct sfnt_mapped_variation_selector_record)
(struct sfnt_table_offset_rec, struct sfnt_uvs_context)
(struct sfnt_mapped_table): New structures.  Update prototypes.
* src/sfntfont-android.c (android_sfntfont_driver): Register
HarfBuzz callbacks where required.
* src/sfntfont.c (sfntfont_select_cmap): Look for a format 14
table.  Save it in new arg FORMAT14.
(sfntfont_read_cmap): Adjust accordingly.
(struct sfnt_font_info): New field `uvs'.  New fields `hb_font',
`fd' and `directory'.
(sfntfont_open): Open uvs context.  Under HarfBuzz, don't close
the fd or subtable, but save them in the font info instead.
(sfntfont_close): Free UVS context.  Close font fd and table
directory and HarfBuzz font.
(sfntfont_draw): Handle case where s->padding_p.
(sfntfont_get_variation_glyphs): New function.
(sfntfont_unmap_blob, sfntfont_get_font_table)
(sfntfont_begin_hb_font): New functions.
* src/sfntfont.h: Update prototypes.
* src/textconv.c (Fset_text_conversion_style): Fix doc string.
2023-03-20 14:47:39 +08:00
Po Lu
f3dd887d18 Update Android port
* java/org/gnu/emacs/EmacsView.java (onAttachedToWindow): Send
measured width and height in exposures again.
2023-03-18 20:05:38 +08:00
Po Lu
634e3fcc20 Update Android port
* java/org/gnu/emacs/EmacsView.java (EmacsView)
(prepareForLayout): New function.  Call this prior to mapping
the view.
(onGlobalLayout): New function.  Register as global layout
listener.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow)
(notifyContentRectPosition): New function.  Use specified
xPosition and yPosition when reporting the offsets of children
of the root window.
* java/org/gnu/emacs/EmacsWindowAttachmentManager.java
(registerWindow): Specify activity launch bounds if necessary.
* src/androidterm.c (handle_one_android_event): Send
MOVE_FRAME_EVENT where necessary.
2023-03-18 10:54:26 +08:00
Po Lu
45b5c9b8b7 Improve radio button appearance in Android menus
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu):
New field `lastGroupId'.
(Item): New field `isRadio'.
(addItem): New arg `isRadio'.
(inflateMenuItems): Apply an empty radio button group if
required.
* src/androidmenu.c (android_init_emacs_context_menu): Adjust
accordingly.
(android_menu_show): Likewise.
2023-03-17 13:10:23 +08:00
Po Lu
da660a1ffa Update Android port
* java/org/gnu/emacs/EmacsView.java (cancelPopupMenu): Dismiss
context menu correctly.
(isOpaque): New function.
* java/org/gnu/emacs/EmacsWindowAttachmentManager.java: Make
consumer list public.
2023-03-17 10:38:09 +08:00
Po Lu
ce66228ac5 Update Android port
* java/org/gnu/emacs/EmacsDocumentsProvider.java (queryRoots): Add
icon to document root.
2023-03-16 14:13:21 +08:00
Po Lu
c74bab6067 Update Android port
* doc/lispref/commands.texi (Misc Events): Document variable
`disable-inhibit-text-conversion'.
* java/org/gnu/emacs/EmacsDialog.java (display1): Try an
activity that is certain to be focused first.
* lisp/touch-screen.el (touch-screen-track-tap)
(touch-screen-track-drag): Bind
`disable-inhibit-text-conversion'.
* src/keyboard.c (read_key_sequence): Only disable text
conversion if an actual function or numeric key is found in the
key sequence.
(syms_of_keyboard): New variable
`disable-inhibit-text-conversion'.
* src/lread.c (read_filtered_event): Check new variable.
* src/textconv.c (textconv_query): Remove unused label.
2023-03-15 09:46:01 +08:00
Po Lu
d6bddca26c Update Android port
* java/org/gnu/emacs/EmacsWindow.java (figureChange): Detect
mice on up events as well.
(onSomeKindOfMotionEvent): Work past framework bug.
* src/androidterm.c (android_perform_conversion_query):
* src/textconv.c (textconv_query):
* src/textconv.h (TEXTCONV_SKIP_ACTIVE_REGION): Remove unused
code.
2023-03-14 13:19:01 +08:00
Po Lu
5964051fce Update Android port
* doc/emacs/android.texi (Android Windowing): Document how to
display dialogs when Emacs is in the background.
* java/org/gnu/emacs/EmacsDialog.java (display1): Use system
dialogs if possible.
2023-03-14 09:48:02 +08:00
Po Lu
b776feb7f2 Update Android port
* doc/emacs/android.texi (Android Startup): Document changes to
emacsclient wrapper.
* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity)
(startEmacsClient): Open EmacsActivity if the service is not
running.
* java/org/gnu/emacs/EmacsService.java (onCreate):
* java/org/gnu/emacs/EmacsThread.java (EmacsThread, run): Pass
any file to open to Emacs.
* lisp/term/android-win.el (handle-args-function): Implement.
2023-03-13 13:25:02 +08:00
Po Lu
a17380e80d Update Android port
* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity)
(onCancel): New function.
(displayFailureDialog): Handle dialog cancellation.
* src/sfntfont.c (sfnt_parse_languages): Look for SLNG tag if
DLNG is not present.
2023-03-12 15:43:14 +08:00
Po Lu
b83324d1bd Update Android port
* configure.ac: Take option `--with-shared-user-id' and give it
to AndroidManifest.xml.in.
* java/AndroidManifest.xml.in: Substitute that into the
application info.
* java/INSTALL (BUILDING WITH A SHARED USER ID): New section.
2023-03-12 09:53:41 +08:00
Po Lu
c4b77b82de Update Android port
* configure.ac (HAVE_MAILUTILS, with_mailutils)
(ANDROID_SDK_8_OR_EARLIER, XCONFIGURE): Fix POP and mailutils
configuration on Android.
* java/Makefile.in:
* src/callproc.c (syms_of_callproc): Avoid using built-in
movemail when --with-mailutils.
2023-03-11 17:42:24 +08:00
Po Lu
4a328b8578 Fix problems with the menu bar on large screen Android devices
* java/org/gnu/emacs/EmacsActivity.java (onContextMenuClosed):
Process submenu closing normally if it happens more than 300 ms
after a submenu item was selected.
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu)
(onMenuItemClick, display1): Give `wasSubmenuSelected' different
values depending on how the submenu was selected.
2023-03-11 11:35:59 +08:00
Po Lu
1eb546309b Update Android port
* doc/emacs/android.texi (Android Windowing): Document how to
pass multimedia keys to the system.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
function.
* java/org/gnu/emacs/EmacsView.java (onKeyDown, onKeyMultiple)
(onKeyUp): Check that function.
* java/org/gnu/emacs/EmacsWindow.java (defineCursor): Handle
cases where cursor is NULL.
* src/android.c (NATIVE_NAME): New function.
* src/androidfns.c (syms_of_androidfns): New variable.
* src/keyboard.c (lispy_function_keys): Add volume keys.
2023-03-10 19:13:22 +08:00
Po Lu
98d43dbef5 * java/org/gnu/emacs/EmacsCursor.java: New file. 2023-03-10 15:16:13 +08:00
Po Lu
ae5513ede5 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.
2023-03-10 15:16:05 +08:00
Po Lu
a7c8ae7d67 ; * java/org/gnu/emacs/EmacsNative.java: Add missing dependency. 2023-03-10 11:39:30 +08:00
Po Lu
488a75f2e2 Port Android battery status to Android 4.4 and earlier
* java/org/gnu/emacs/EmacsService.java (EmacsService)
(queryBattery19): New function.
(queryBattery): Call it on old systems.  Also, return AC line
status and temperature.
* lisp/battery.el (battery-android): Implement more format
directives.
* src/android.c (android_query_battery): Handle new status
fields.
* src/android.h (struct android_battery_state): Add `plugged'
and `temperature'.
* src/androidfns.c (Fandroid_query_battery): Return new fields.
2023-03-10 09:40:41 +08:00
Po Lu
e859a14bee Fix menu and popup race conditions on Android
* java/org/gnu/emacs/EmacsActivity.java (onContextMenuClosed):
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu)
(onMenuItemClick, run):
* java/org/gnu/emacs/EmacsDialog.java (EmacsDialog, onClick)
(createDialog, onDismiss): Take menu event serial, and pass it
along in context menu events.
* java/org/gnu/emacs/EmacsNative.java (sendContextMenu): New
argument.
* src/android.c (sendContextMenu): Pass serial number in event.

* src/androidgui.h (struct android_menu_event): New field
`menu_event_serial'.
* src/androidmenu.c (FIND_METHOD_STATIC)
(android_init_emacs_context_menu): Adjust method declarations.
(android_menu_show, android_dialog_show):
* src/androidterm.c (handle_one_android_event): Expect serial in
context menu events.
* src/androidterm.h: Update prototypes.
2023-03-09 16:30:02 +08:00
Po Lu
682a6542cd Update Android port
* java/debug.sh (is_root): Port to android versions which don't
support `chmod +x'.
* src/android.c (android_content_name_p): Disable before API
level 19.
2023-03-09 14:50:32 +08:00
Po Lu
dcc3c63c6e Update Android port
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu)
(addItem): New argument `tooltip'.
2023-03-09 11:27:00 +08:00
Po Lu
bb55528c7b Update Android port
* doc/emacs/android.texi (Android File System): Document what
`temp~unlinked' means in the temporary files directory.
* java/org/gnu/emacs/EmacsService.java (updateExtractedText):
New function.
* java/org/gnu/emacs/EmacsView.java (onCreateInputConnection):
Ask the input method nicely to not display the extracted text
UI.
* src/android.c (struct android_emacs_service): New method
`updateExtractedText'.
(android_hack_asset_fd_fallback): Improve naming convention.
Fix typo.
(android_init_emacs_service): Add new method.
(android_update_extracted_text): New function.
(android_open_asset): Fix typo.
* src/androidgui.h: Update prototypes.
* src/androidterm.c (struct android_get_extracted_text_context):
New field `flags'.
(android_get_extracted_text): Set flags on the frame's output
data.
(android_build_extracted_text): New function.
(getExtractedText): Move out class structures.
(android_update_selection): Send updates to extracted text if
the input method asked for them.
(android_reset_conversion): Clear extracted text flags.
* src/androidterm.h (struct android_output): New fields for
storing extracted text data.
2023-03-08 15:04:49 +08:00
Po Lu
84d27fe53b Save build timestamps in Android builds
* java/Makefile.in (install_temp/assets/build_info): New
rule.:(emacs.apk-in): Depend on that file.
* lisp/version.el (android-read-build-system)
(android-read-build-time): New functions.
(emacs-build-system, emacs-build-time): Use those functions on
Android, as dumping is done after installation on Android.
* src/fileio.c (Finsert_file_contents):
* src/window.c (replace_buffer_in_windows): Don't call functions
if they are not defined, which can happen during loadup.
2023-03-07 20:18:02 +08:00
Po Lu
83c29bd40e Update Android port
* java/org/gnu/emacs/EmacsWindow.java (onSomeKindOfMotionEvent):
Dismiss splurious LeaveNotify events from button presses.
* src/android.c (android_change_window_attributes)
(android_change_gc, android_set_clip_rectangles)
(android_reparent_window, android_clear_window, android_map_window)
(android_unmap_window, android_resize_window, android_move_window)
(android_swap_buffers, android_fill_rectangle, android_copy_area)
(android_fill_polygon, android_draw_rectangle, android_draw_point)
(android_draw_line, android_clear_area, android_bell)
(android_set_input_focus, android_raise_window)
(android_lower_window, android_set_dont_focus_on_map)
(android_set_dont_accept_focus, android_get_keysym_name)
(android_toggle_on_screen_keyboard, android_restart_emacs)
(android_display_toast, android_update_ic, android_reset_ic)
(android_set_fullscreen): Optimize by specifying the class
explicitly when calling a method.
2023-03-07 16:49:45 +08:00
Po Lu
c0a6f14f4a Update Android port
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
function requestSelectionUpdate.
* java/org/gnu/emacs/EmacsView.java (onCreateInputConnection):
Call it instead of losing if getting the current selection
fails.
* src/android-asset.h (AAsset_seek): Define stub.
* src/android.c (android_open): Take mode_t.
(android_open_asset, android_close_asset, android_asset_read_quit)
(android_asset_read, android_asset_lseek, android_asset_fstat):
New functions.
* src/android.h (struct android_fd_or_asset): Update prototypes.
* src/androidgui.h (enum android_ime_operation): Add new
operation to update the selection position.
* src/androidterm.c (android_handle_ime_event): Handle new
operation.
(requestSelectionUpdate): New function.
* src/fileio.c (close_file_unwind_emacs_fd): New function.
(Fcopy_file, union read_non_regular, read_non_regular)
(Finsert_file_contents): Use optimized codepath to insert
Android asset files.
* src/frame.h (enum text_conversion_operation): New operation.
* src/textconv.c (really_request_point_update)
(handle_pending_conversion_events_1, request_point_update): New
functions.
* src/textconv.h: Update prototypes.
2023-03-06 15:30:29 +08:00
Po Lu
97ca0a8551 Update Android port
* java/org/gnu/emacs/EmacsService.java (sync): Delete function.
* java/org/gnu/emacs/EmacsView.java (handleDirtyBitmap): Erase
with window background.
(onDetachedFromWindow): Only recycle bitmap if non-NULL.
* java/org/gnu/emacs/EmacsWindow.java (background): New field.
(changeWindowBackground): Set it.
* src/android.c (struct android_emacs_service): Remove `sync'.
(android_init_emacs_service): Likewise.
(android_sync): Delete function.
* src/androidfns.c (android_create_tip_frame): Set frame
background color correctly.
(Fx_show_tip): Make the tip frame visible.
* src/androidgui.h: Update prototypes.
* src/androidterm.c (handle_one_android_event): Handle tooltip
movement correctly.
2023-03-06 11:25:51 +08:00
Po Lu
1cae464859 Update Android port
* java/org/gnu/emacs/EmacsActivity.java (onCreate):
* java/org/gnu/emacs/EmacsContextMenu.java:
* java/org/gnu/emacs/EmacsDocumentsProvider.java (getMimeType):
* java/org/gnu/emacs/EmacsDrawLine.java (perform):
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform):
* java/org/gnu/emacs/EmacsFillPolygon.java:
* java/org/gnu/emacs/EmacsFontDriver.java:
* java/org/gnu/emacs/EmacsHandleObject.java:
* java/org/gnu/emacs/EmacsInputConnection.java:
* java/org/gnu/emacs/EmacsMultitaskActivity.java
(EmacsMultitaskActivity):
* java/org/gnu/emacs/EmacsNative.java:
* java/org/gnu/emacs/EmacsNoninteractive.java
(EmacsNoninteractive, main):
* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity)
(startEmacsClient):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java:
* java/org/gnu/emacs/EmacsSdk8Clipboard.java:
* java/org/gnu/emacs/EmacsService.java (EmacsService, onCreate):
* java/org/gnu/emacs/EmacsView.java (EmacsView, onLayout):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow):
* java/org/gnu/emacs/EmacsWindowAttachmentManager.java
(EmacsWindowAttachmentManager): Remove redundant includes.
Reorganize some functions around, remove duplicate `getLibDir'
functions, and remove unused local variables.
2023-03-05 19:58:28 +08:00
Po Lu
26b3b8433d Update Android port
* java/org/gnu/emacs/EmacsOpenActivity.java (onCreate): Don't
set the style here.
* java/res/values-v11/style.xml:
* java/res/values-v14/style.xml:
* java/res/values-v29/style.xml:
* java/res/values/style.xml: Define styles for the emacsclient
wrapper.
* src/keyboard.c (read_key_sequence): Don't disable text
conversion if use_mouse_menu or if a menu bar prefix key is
being displayed.
2023-03-05 15:55:24 +08:00
Po Lu
2634765bc3 Improve context menus on old versions of Android
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity): New
field `lastClosedMenu'.
(onContextMenuClosed): Don't send event if a menu is closed
twice in a row.  Also, clear wasSubmenuSelected immediately.
* java/org/gnu/emacs/EmacsContextMenu.java: Display submenus
manually in Android 6.0 and earlier.
* java/org/gnu/emacs/EmacsView.java (onCreateContextMenu)
(popupMenu): Adjust accordingly.
2023-03-04 15:55:09 +08:00
Po Lu
39a7e6b79f Port to broken Android NDK version
* configure.ac: Check for __ctype_get_mb_cur_max.
Then see if MB_CUR_MAX is defined to it, and define
REPLACEMENT_MB_CUR_MAX if so and it does not link.
* java/INSTALL: Update documentation.
* src/conf_post.h (MB_CUR_MAX): Define replacement if
necessary.
2023-03-04 13:38:00 +08:00
Po Lu
0e995d06a8 Improve support for building Android C++ dependencies
* configure.ac: Call ndk_LATE after gl_EARLY.
* cross/ndk-build/Makefile.in (NDK_BUILD_CXX): New variable.
* cross/ndk-build/ndk-build-shared-library.mk:
* cross/ndk-build/ndk-build-static-library.mk: Use it.
* java/INSTALL: Describe how to build C++ dependencies.
* m4/ndk-build.m4 (ndk_LATE): New macro.
(ndk_INIT): Try to find a suitable C++ compiler.
(ndk_CHECK_MODULES): Make sure the C++ compiler works before
allowing C++ dependencies.
2023-03-04 11:19:25 +08:00
Po Lu
48b5a770f2 Fix visiting and saving writable content provider files
* java/org/gnu/emacs/EmacsService.java (checkContentUri):
Improve debug output.
* lisp/files.el (basic-save-buffer): Check whether or not file
itself exists before checking for the existence of the directory
containing it.
* src/android.c (android_open): Don't forget to set errno after
open_content_uri fails.
2023-03-03 16:00:27 +08:00
Po Lu
bc9239eb51 Update Android port
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity)
(onCreate): Add view tree observer.
(onGlobalLayout): Sync fullscreen state.
(syncFullscreenWith): Improve visibility flag setting.

* src/textconv.c (select_window): New function.
(textconv_query):
(restore_selected_window):
(really_commit_text):
(really_set_composing_text):
(really_set_composing_region):
(really_delete_surrounding_text):
(really_set_point_and_mark):
(get_extracted_text): Call it instead of Fselect_window
to avoid selecting the mini window if it is no longer active.
2023-03-03 15:23:21 +08:00
Po Lu
960230d88d Summary: Update Android port
* INSTALL: Document where to find Android installation
instructions.
* configure.ac (CHECK_LISP_OBJECT_TYPE): Pacify
-Wsuggest-attribute=noreturn only on Android.
* cross/ndk-build/README: New file.
* doc/emacs/android.texi (Android):
* doc/emacs/emacs.texi (Top):
* doc/emacs/input.texi (Other Input Devices): Untabify menus.
* etc/NEWS: Move INSTALL.android to java/INSTALL.
* java/INSTALL: New file.
* java/README:
* src/coding.c (from_unicode_buffer): Make Android specific code
only build on Android.
2023-03-02 18:31:35 +08:00
Po Lu
09aa948ab4 Improve criteria for restoring fullscreen state on Android
* java/Makefile.in ($(CLASS_FILES) &): Touch all class files,
even those javac chose not to rebuild.

* java/org/gnu/emacs/EmacsActivity.java (onWindowFocusChanged):
Restore fullscreen state here.
(onResume): And not here.
2023-03-02 12:30:36 +08:00
Po Lu
7fb3c0d039 Update Android port
* doc/emacs/android.texi (Android Windowing): Reword
documentation.
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity):
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu):
* java/org/gnu/emacs/EmacsFontDriver.java (EmacsFontDriver):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java
(EmacsSdk7FontDriver):
* java/org/gnu/emacs/EmacsService.java (queryBattery):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): Make
functions final and classes static where necessary.
* src/android.c (struct android_emacs_service): New method
`display_toast'.
(android_init_emacs_service): Load new method.
(android_display_toast): New function.
* src/android.h: Export.
* src/androidfns.c (Fandroid_detect_mouse):
* src/androidselect.c (Fandroid_clipboard_owner_p)
(Fandroid_set_clipboard, Fandroid_get_clipboard)
(Fandroid_browse_url): Prevent crashes when called from
libandroid-emacs.so.
* src/androidterm.c (handle_one_android_event): Fix out of date
commentary.
2023-03-02 09:27:37 +08:00
Po Lu
daf9c62871 Fix out-of-tree Android builds
* configure.ac (JAVA_PUSH_LINT): Push to WARN_JAVAFLAGS instead
of JAVAFLAGS.
(cross/lib): Always AS_MKDIR_P.
* cross/Makefile.in (srcdir): New variable.
(LIB_SRCDIR): Take realpath relative to srcdir, not
.:(src/verbose.mk): Depend on verbose.mk.android in srcdir.
(lib/Makefile): Edit srcdir and VPATH to LIB_SRCDIR.
(src/Makefile): Edit -I$$(top_srcdir) to -I../$(srcdir)/lib,
instead of ommitting it.
(clean): Allow ndk-build clean to fail.

* java/Makefile.in (builddir): New variable.
(WARN_JAVAFLAGS): Likewise.
(JAVAFLAGS): Define in terms of WARN_JAVAFLAGS.
(SIGN_EMACS, SIGN_EMACS_V2): Use emacs.keystore relative to
srcdir.  Allow inclusion of ndk-build.mk to fail.
(install_temp, emacs.apk-in)
(../config.status): Depend relative to top_srcdir.
(AndroidManifest.xml, $(APK_NAME)): Likewise.
(RESOURCE_FILE, CLASS_FILES, classes.dex): Output class files
to $(srcdir); these are arch independents, so this is okay.
2023-03-01 19:35:19 +08:00
Po Lu
ad8e12b9f9 Update Android port
* doc/emacs/android.texi (Android File System): Document new
behavior of starting a subprocess from /assets.
* java/org/gnu/emacs/EmacsWindow.java (onSomeKindOfMotionEvent):
Don't use isFromSource where not present.
* src/androidterm.c (android_scroll_run): Avoid undefined
behavior writing to bitfields.
* src/callproc.c (get_current_directory): When trying to run a
subprocess inside /assets, run it from the home directory
instead.
2023-03-01 15:49:02 +08:00
Po Lu
194b3f948c Update Android port
* java/AndroidManifest.xml.in: Specify @style/EmacsStyle.
* java/org/gnu/emacs/EmacsActivity.java (onCreate): Stop setting
the theme here.
* java/res/values-v11/style.xml:
* java/res/values-v14/style.xml:
* java/res/values-v29/style.xml:
* java/res/values/style.xml: Extract style resources into
res/values.
2023-03-01 14:31:57 +08:00
Po Lu
15bcb446be Update Android port
* java/Makefile.in (ETAGS, clean): New rules to generate tags.
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity):
* java/org/gnu/emacs/EmacsApplication.java (EmacsApplication):
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu):
* java/org/gnu/emacs/EmacsCopyArea.java (EmacsCopyArea):
* java/org/gnu/emacs/EmacsDialog.java (EmacsDialog)::(dialog.
Then):
* java/org/gnu/emacs/EmacsDocumentsProvider.java
(EmacsDocumentsProvider):
* java/org/gnu/emacs/EmacsDrawLine.java (EmacsDrawLine):
* java/org/gnu/emacs/EmacsDrawPoint.java (EmacsDrawPoint):
* java/org/gnu/emacs/EmacsDrawRectangle.java
(EmacsDrawRectangle):
* java/org/gnu/emacs/EmacsFillPolygon.java (EmacsFillPolygon):
* java/org/gnu/emacs/EmacsFillRectangle.java
(EmacsFillRectangle):
* java/org/gnu/emacs/EmacsGC.java (EmacsGC):
* java/org/gnu/emacs/EmacsInputConnection.java
(EmacsInputConnection):
* java/org/gnu/emacs/EmacsNative.java (EmacsNative):
* java/org/gnu/emacs/EmacsNoninteractive.java
(EmacsNoninteractive):
* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity):
* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap):
* java/org/gnu/emacs/EmacsPreferencesActivity.java
(EmacsPreferencesActivity):
* java/org/gnu/emacs/EmacsSdk11Clipboard.java
(EmacsSdk11Clipboard):
* java/org/gnu/emacs/EmacsSdk23FontDriver.java
(EmacsSdk23FontDriver):
* java/org/gnu/emacs/EmacsSdk8Clipboard.java
(EmacsSdk8Clipboard):
* java/org/gnu/emacs/EmacsService.java (EmacsService):
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView)
(buffers):
* java/org/gnu/emacs/EmacsView.java (EmacsView, ViewGroup):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow, drawables):
* java/org/gnu/emacs/EmacsWindowAttachmentManager.java
(EmacsWindowAttachmentManager): Make classes final where
appropriate.
2023-03-01 12:00:46 +08:00
Po Lu
39ddf1855b Update Android port
* doc/lispref/commands.texi (Misc Events): Update documentation.
* java/org/gnu/emacs/EmacsService.java (EmacsService)
(onStartCommand): Improve notification message.
* src/android.c (android_hack_asset_fd): Detect if ashmem is
available dynamically.
(android_detect_ashmem): New function.
* src/textconv.c (record_buffer_change): Use markers to
represent BEG and END instead.
(syms_of_textconv): Update doc string.
2023-02-26 10:33:41 +08:00
Po Lu
8fa86cc7cd Update Android port
* java/debug.sh (is_root): Fix tee detection again for old
systems which don't return exit codes from adb shell.
* src/android.c (android_run_select_thread, NATIVE_NAME,
JNICALL):
* src/android.h (NATIVE_NAME):
* src/androidterm.c (JNICALL, NATIVE_NAME): Apply stack
alignment to all JNICALL functions.
2023-02-25 21:52:11 +08:00
Po Lu
df29bb71fc Update Android port
* java/org/gnu/emacs/EmacsNoninteractive.java (main): Port to
Android 2.2.
* src/android-asset.h (AAsset_openFileDescriptor): Delete stub
function.
* src/android.c (android_check_compressed_file): Delete
function.
(android_open): Stop trying to find compressed files or to use
the system provided file descriptor.  Explain why.
2023-02-25 20:11:48 +08:00
Po Lu
8e4c5db193 Update Android port
* doc/emacs/android.texi (Android Startup, Android File System)
(Android Environment, Android Windowing, Android
Troubleshooting): Improve documentation; fix typos.
* doc/lispref/commands.texi (Misc Events): Likewise.
* java/org/gnu/emacs/EmacsService.java (queryBattery): New
function.
* lisp/battery.el (battery-status-function): Set appropriately
for Android.
(battery-android): New function.
* src/android.c (struct android_emacs_service): New method
`query_battery'.
(android_check_content_access): Improve exception checking.
(android_init_emacs_service): Look up new method.
(android_destroy_handle, android_create_window)
(android_init_android_rect_class, android_init_emacs_gc_class)
(android_set_clip_rectangles)
(android_create_pixmap_from_bitmap_data, android_fill_polygon)
(android_get_image, android_put_image, android_bell)
(android_set_input_focus, android_raise_window)
(android_lower_window, android_query_tree, android_get_geometry)
(android_translate_coordinates, android_wc_lookup_string)
(android_damage_window, android_build_string)
(android_build_jstring, android_exception_check_1)
(android_exception_check_2): New functions.
(android_browse_url): Improve exception handling.  Always use
android_exception_check and don't leak local refs.
(android_query_battery): New function.
* src/android.h (struct android_battery_state): New struct.
* src/androidfns.c (Fandroid_query_battery, syms_of_androidfns):
New function.
* src/androidfont.c (androidfont_from_lisp, DO_SYMBOL_FIELD)
(DO_CARDINAL_FIELD, androidfont_list, androidfont_match)
(androidfont_draw, androidfont_open_font)
(androidfont_close_font):
* src/androidselect.c (Fandroid_set_clipboard)
(Fandroid_get_clipboard):
* src/sfnt.c (sfnt_map_glyf_table):
* src/sfntfont.c (sfntfont_free_outline_cache)
(sfntfont_free_raster_cache, sfntfont_close): Allow font close
functions to be called twice.
2023-02-25 19:11:07 +08:00
Po Lu
ea74f3c067 Improve Android configury
* configure.ac (JAVA_PUSH_LINT): New macro.
(JAVAFLAGS): New variable.  Check for various lint flags and
macros and enable them.
* java/Makefile.in (ANDROID_ABI):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java: Remove compiler
warning.
2023-02-24 22:25:48 +08:00
Po Lu
1e6f957c0d Update Android port
* doc/emacs/input.texi (On-Screen Keyboards): Document changes
to text conversion.
* java/org/gnu/emacs/EmacsInputConnection.java (getExtractedText)
(EmacsInputConnection):
* src/keyboard.c (read_key_sequence): Disable text conversion
after reading prefix key.
* src/textconv.c (get_extracted_text): Fix returned value when
request length is zero.
2023-02-22 14:59:27 +08:00
Po Lu
77feba7456 Update Android port
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu)
(addSubmenu, inflateMenuItems): Handle tooltips correctly.
* src/android.c (android_scan_directory_tree): Fix limit
generation for root directory.
* src/androidmenu.c (android_init_emacs_context_menu)
(android_menu_show): Implement menu item help text on Android
8.0 and later.
2023-02-21 21:07:57 +08:00
Po Lu
7aa4ffddd8 Update Android port
* doc/emacs/android.texi (Android Startup): Document `content'
special directory.
* java/debug.sh (is_root): Improve /bin/tee detection.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
function `dup'.
* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity)
(checkReadableOrCopy, onCreate): Create content directory names
when the file is not readable.
* java/org/gnu/emacs/EmacsService.java (EmacsService)
(openContentUri, checkContentUri): New functions.
* src/android.c (struct android_emacs_service): New methods.
(android_content_name_p, android_get_content_name)
(android_check_content_access): New function.
(android_fstatat, android_open): Implement opening content URIs.
(dup): Export to Java.
(android_init_emacs_service): Initialize new methods.
(android_faccessat): Implement content file names.
2023-02-21 15:28:06 +08:00
Po Lu
57c19f477f Update Android port
* INSTALL.android: Explain where to get tree-sitter.

* configure.ac: Add support for dynamic modules and tree-sitter.

* doc/emacs/android.texi (Android Windowing):
* java/org/gnu/emacs/EmacsSdk11Clipboard.java
(EmacsSdk11Clipboard, ownsClipboard): Improve clipboard handling
and documentation.
2023-02-20 22:14:29 +08:00
Po Lu
b91396bace Improve reliability of Java code rebuilds
* java/Makefile.in ($(CLASS_FILES)): Depend on the Java
compiler's internal dependency tracking.
2023-02-20 10:50:04 +08:00
Po Lu
585ee91b21 More fixes to parallel Make
* cross/ndk-build/ndk-build.mk.in (NDK_BUILD_MODULES)
(NDK_BUILD_SHARED, NDK_BUILD_STATIC): Define group rule to build
all files so that they are built within one make process.
* java/Makefile.in: Reorganize cross compilation and make sure
there is only one make subprocess for each subdirectory of
cross.
2023-02-19 21:52:21 +08:00
Po Lu
f319605207 More parallel build fixes
* cross/Makefile.in: (.PHONY):
* java/Makefile.in: (.PHONY):
* src/Makefile.in: (libemacs.so): Avoid calling ndk-build from
two places at once.  Build android-emacs separately from
libemacs.so.
2023-02-19 21:25:37 +08:00
Po Lu
18f723faa8 Fix parallel compilation of Android port
* cross/Makefile.in ($(top_builddir)/lib/libgnu.a):
* java/Makefile.in (CROSS_LIBS): Explicitly depend on gnulib
to prevent it from being built at the same time from different
jobs.
2023-02-19 20:45:32 +08:00
Po Lu
0998ab3ade Report both sides of the region to the input method upon setup
* java/org/gnu/emacs/EmacsNative.java (getSelection): Return
array of ints.
* java/org/gnu/emacs/EmacsView.java (onCreateInputConnection):
Adjust accordingly.
* src/androidterm.c (struct android_get_selection_context): New
field `mark'.
(android_get_selection): Set the mark field as appropriate.
(getSelection): Adjust accordingly.
2023-02-19 19:56:51 +08:00
Po Lu
efc46330aa Allow opening more files in emacsclient on Android
* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity)
(checkReadableOrCopy): New function.
(onCreate): If the file specified is not readable from C, read
it into a temporary file and ask Emacs to open that.
2023-02-19 15:29:46 +08:00
Po Lu
c8f49c9276 Implement `fullscreen' on Android 4.0 and later
* doc/emacs/android.texi (Android Windowing): Document what new
frame parameters are now supported.
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity): New
field `isFullscreen'.
(detachWindow, attachWindow): Sync fullscreen state.
(onWindowFocusChanged): Add more logging.
(onResume): Restore previous fullscreen state.
(syncFullscreen): New function.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow)
(setFullscreen): New function.
* src/android.c (struct android_emacs_window): Add new method.
(android_init_emacs_window): Look up new method.
(android_set_fullscreen): New function.
* src/androidgui.h:
* src/androidterm.c (android_fullscreen_hook): Implement
accordingly.
2023-02-19 13:17:43 +08:00
Po Lu
a61f9cb77c Update Android port
* doc/emacs/input.texi (On-Screen Keyboards): Document
`touch-screen-always-display'.
* doc/lispref/commands.texi (Misc Events): Improve documentation
of text conversion events.
* java/org/gnu/emacs/EmacsDialog.java (toAlertDialog, display1):
Reorder buttons to make more sense.
* lisp/elec-pair.el (electric-pair-analyze-conversion): New
function.
* lisp/simple.el (analyze-text-conversion): Improve integration
with electric pair modes.
* lisp/term.el (term-mode): Always display the onscreen
keyboard.
* lisp/touch-screen.el (touch-screen-display-keyboard)
(touch-screen-handle-point-up): Respect new options.
* src/textconv.c (really_set_composing_text): Stop widenining
unnecessarily.
(really_delete_surrounding_text): Really delete surrounding
text.  Give text conversion analyzers the buffer text.
(syms_of_textconv): Update doc string.
2023-02-18 23:09:30 +08:00
Po Lu
d70bb47aeb Update emacsbug and version.el for the Android port
* java/Makefile.in (install_temp/assets/version): New generated
file.
* lisp/loadup.el: Set emacs versions appropriately prior to
dumping on Android.
* lisp/mail/emacsbug.el (emacs-build-description): Insert
Android build fingerprint.
* lisp/version.el (emacs-repository-version-android)
(emacs-repository-get-version, emacs-repository-get-branch):
Implement for Android.
* src/androidterm.c (android_set_build_fingerprint): New
function.
(syms_of_androidterm): New variable `android-build-fingerprint'.
2023-02-17 21:09:00 +08:00
Po Lu
60ed861b10 Fix crash on old versions of Android
* java/org/gnu/emacs/EmacsService.java (nameKeysym): Implement
stub on Android 3.0 and earlier.
2023-02-17 19:02:23 +08:00
Po Lu
88afd96e36 Fix build and running on Android 2.2
* INSTALL.android: Document that Android 2.2 is now supported,
with caveats.
* configure.ac (ANDROID_MIN_SDK, ANDROID_SDK_18_OR_EARLIER)
(SYSTEM_TYPE, ANDROID_STUBIFY, SIZEOF_LONG): Correctly detect
things missing on Android 2.2.
* java/Makefile.in (ANDROID_JAR, JARSIGNER_FLAGS):
* java/debug.sh (jdb, gdbserver, line):
* java/org/gnu/emacs/EmacsApplication.java (findDumpFile):
* java/org/gnu/emacs/EmacsService.java (onCreate):
* java/org/gnu/emacs/EmacsThread.java (EmacsThread, run): Run
parameter initialization on main thread.
* src/android-asset.h (struct android_asset_manager)
(struct android_asset, AAssetManager_fromJava, AAssetManager_open)
(AAsset_close, android_asset_create_stream)
(android_asset_read_internal, AAsset_openFileDescriptor)
(AAsset_getLength, AAsset_getBuffer, AAsset_read): New file.
* src/android.c (android_user_full_name, android_hack_asset_fd)
(android_check_compressed_file): Implement for Android 2.2.
* src/process.c (Fprocess_send_eof): Don't call tcdrain if
unavailable.
* src/sfntfont-android.c (system_font_directories): Fix compiler
warning.
* src/sfntfont.c (sfntfont_read_cmap): Correctly test rc of
emacs_open.
* src/textconv.c (handle_pending_conversion_events_1): Mark
buffer UNINIT.
2023-02-17 16:27:00 +08:00
Po Lu
2dcce30290 Update Android port
* doc/emacs/android.texi (Android Fonts):
* doc/emacs/input.texi (On-Screen Keyboards):
* doc/lispref/commands.texi (Misc Events): Update documentation.
* java/org/gnu/emacs/EmacsInputConnection.java (setSelection):
New function.
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView)
(reconfigureFrontBuffer): Make bitmap references weak
references.
* java/org/gnu/emacs/EmacsView.java (handleDirtyBitmap): Don't
clear surfaceView bitmap.
* lisp/comint.el (comint-mode):
* lisp/international/fontset.el (script-representative-chars)
(setup-default-fontset): Improve detection of CJK fonts.
* lisp/isearch.el (set-text-conversion-style): New variable.
(isearch-mode, isearch-done): Save and restore the text
conversion style.
* lisp/minibuffer.el (minibuffer-mode): Set an appropriate text
conversion style.
* lisp/simple.el (analyze-text-conversion): Run
post-self-insert-hook properly.
* lisp/subr.el (read-char-from-minibuffer): Disable text
conversion when reading character.
* src/androidterm.c (show_back_buffer): Don't check that F is
not garbaged.
(android_update_selection, android_reset_conversion): Use the
ephemeral last point and handle text conversion being disabled.
* src/buffer.c (syms_of_buffer): Convert old style DEFVAR.
* src/keyboard.c (kbd_buffer_get_event): Handle text conversion
first.
* src/lisp.h: Update prototypes.
* src/lread.c (read_filtered_event): Temporarily disable text
conversion.
* src/sfnt.c (sfnt_decompose_glyph_1, sfnt_decompose_glyph_2):
New functions.
(sfnt_decompose_glyph, sfnt_decompose_instructed_outline):
Refactor contour decomposition to those two functions.
(main): Update tests.
* src/sfntfont-android.c (system_font_directories): Add empty
field.
(Fandroid_enumerate_fonts, init_sfntfont_android): Enumerate
fonts in a user fonts directory.
* src/sfntfont.c (struct sfnt_font_desc): New field
`num_glyphs'.
(sfnt_enum_font_1): Set num_glyphs and avoid duplicate fonts.
(sfntfont_glyph_valid): New function.
(sfntfont_lookup_char, sfntfont_list_1): Make sure glyphs found
are valid.

* src/textconv.c (sync_overlay, really_commit_text)
(really_set_composing_text, really_set_composing_region)
(really_delete_surrounding_text, really_set_point_and_mark)
(handle_pending_conversion_events_1)
(handle_pending_conversion_events, conversion_disabled_p)
(disable_text_conversion, resume_text_conversion)
(Fset_text_conversion_style, syms_of_textconv): Update to
respect new options.
* src/textconv.h:
* src/window.h (GCALIGNED_STRUCT): New field
`ephemeral_last_point'.
* src/xdisp.c (mark_window_display_accurate_1): Set it.
2023-02-16 23:57:01 +08:00
Po Lu
cf24b61985 Update Android port
* doc/emacs/input.texi (On-Screen Keyboards):
* doc/lispref/commands.texi (Misc Events): Improve documentation
of text conversion stuff.
* java/org/gnu/emacs/EmacsInputConnection.java (beginBatchEdit)
(endBatchEdit, commitCompletion, commitText, deleteSurroundingText)
(finishComposingText, getSelectedText, getTextAfterCursor)
(EmacsInputConnection, setComposingRegion, performEditorAction)
(getExtractedText): Condition debug code on DEBUG_IC.
* java/org/gnu/emacs/EmacsService.java (EmacsService, updateIC):
Likewise.
* lisp/bindings.el (global-map):
* lisp/electric.el (global-map): Make `text-conversion'
`analyze-text-conversion'.
* lisp/progmodes/prog-mode.el (prog-mode): Enable text
conversion in input methods.
* lisp/simple.el (analyze-text-conversion): New function.
* lisp/textmodes/text-mode.el (text-conversion-style)
(text-mode): Likewise.
* src/androidterm.c (android_handle_ime_event): Handle
set_point_and_mark.
(android_sync_edit): Give Emacs 100 ms instead.
(android_perform_conversion_query): Skip the active region, not
the conversion region.
(getSelectedText): Implement properly.
(android_update_selection): Expose mark to input methods.
(android_reset_conversion): Handle `text-conversion-style'.
* src/buffer.c (init_buffer_once, syms_of_buffer): Add buffer
local variable `text-conversion-style'.
* src/buffer.h (struct buffer, bset_text_conversion_style): New
fields.
* src/emacs.c (android_emacs_init): Call syms_of_textconv.
* src/frame.h (enum text_conversion_operation): Rename
TEXTCONV_SET_POINT.
* src/lisp.h: Export syms_of_textconv.

* src/marker.c (set_marker_internal): Force redisplay when the
mark is set and the buffer is visible on builds that use text
conversion.  Explain why.

* src/textconv.c (copy_buffer): Fix copying past gap.
(get_mark): New function.
(textconv_query): Implement new flag.
(sync_overlay): New function.  Display conversion text in an
overlay.
(record_buffer_change, really_commit_text)
(really_set_composing_text, really_set_composing_region)
(really_delete_surrounding_text, really_set_point)
(handle_pending_conversion_events_1, decrement_inside)
(handle_pending_conversion_events, textconv_set_point)
(get_extracted_text, register_textconv_interface): Various fixes
and improvements.

* src/textconv.h (struct textconv_interface): Update
documentation.
* src/window.h (GCALIGNED_STRUCT): New field `prev_mark'.
* src/xdisp.c (mark_window_display_accurate_1): Handle
prev_mark.
2023-02-15 22:51:44 +08:00
Po Lu
dd7066901f Make debug.sh detect adb running as root
* java/debug.sh: Run gdbserver directly if possible.
2023-02-15 13:39:47 +08:00
Po Lu
a158c1d5b9 Update Android port
* configure.ac (HAVE_TEXT_CONVERSION): Define on Android.
* doc/emacs/input.texi (On-Screen Keyboards): Document ``text
conversion'' slightly.
* doc/lispref/commands.texi (Misc Events): Document new
`text-conversion' event.
* java/org/gnu/emacs/EmacsContextMenu.java (display): Use
`syncRunnable'.
* java/org/gnu/emacs/EmacsDialog.java (display): Likewise.
* java/org/gnu/emacs/EmacsEditable.java: Delete file.
* java/org/gnu/emacs/EmacsInputConnection.java
(EmacsInputConnection): Reimplement from scratch.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): Add new
functions.
* java/org/gnu/emacs/EmacsService.java (EmacsService, getEmacsView)
(getLocationOnScreen, sync, getClipboardManager, restartEmacs):
Use syncRunnable.
(syncRunnable): New function.
(updateIC, resetIC): New functions.

* java/org/gnu/emacs/EmacsView.java (EmacsView): New field
`inputConnection' and `icMode'.
(onCreateInputConnection): Update accordingly.
(setICMode, getICMode): New functions.

* lisp/bindings.el (global-map): Ignore text conversion events.
* src/alloc.c (mark_frame): Mark text conversion data.
* src/android.c (struct android_emacs_service): New fields
`update_ic' and `reset_ic'.
(event_serial): Export.
(android_query_sem): New function.
(android_init_events): Initialize new semaphore.
(android_write_event): Export.
(android_select): Check for UI thread code.
(setEmacsParams, android_init_emacs_service): Initialize new
methods.
(android_check_query, android_begin_query, android_end_query)
(android_run_in_emacs_thread):
(android_update_ic, android_reset_ic): New functions for
managing synchronous queries from one thread to another.

* src/android.h: Export new functions.
* src/androidgui.h (enum android_event_type): Add input method
events.
(enum android_ime_operation, struct android_ime_event)
(union android_event, enum android_ic_mode): New structs and
enums.

* src/androidterm.c (android_window_to_frame): Allow DPYINFO to
be NULL.
(android_decode_utf16, android_handle_ime_event)
(handle_one_android_event, android_sync_edit)
(android_copy_java_string, beginBatchEdit, endBatchEdit)
(commitCompletion, deleteSurroundingText, finishComposingText)
(getSelectedtext, getTextAfterCursor, getTextBeforeCursor)
(setComposingText, setComposingRegion, setSelection, getSelection)
(performEditorAction, getExtractedText): New functions.
(struct android_conversion_query_context):
(android_perform_conversion_query):
(android_text_to_string):
(struct android_get_selection_context):
(android_get_selection):
(struct android_get_extracted_text_context):
(android_get_extracted_text):
(struct android_extracted_text_request_class):
(struct android_extracted_text_class):
(android_update_selection):
(android_reset_conversion):
(android_set_point):
(android_compose_region_changed):
(android_notify_conversion):
(text_conversion_interface): New functions and structures.
(android_term_init): Initialize text conversion.

* src/coding.c (syms_of_coding): Define Qutf_16le on Android.
* src/frame.c (make_frame): Clear conversion data.
(delete_frame): Reset conversion state.

* src/frame.h (enum text_conversion_operation)
(struct text_conversion_action, struct text_conversion_state)
(GCALIGNED_STRUCT): Update structures.
* src/keyboard.c (read_char, readable_events, kbd_buffer_get_event)
(syms_of_keyboard): Handle text conversion events.
* src/lisp.h:
* src/process.c: Fix includes.

* src/textconv.c (enum textconv_batch_edit_flags, textconv_query)
(reset_frame_state, detect_conversion_events)
(restore_selected_window, really_commit_text)
(really_finish_composing_text, really_set_composing_text)
(really_set_composing_region, really_delete_surrounding_text)
(really_set_point, complete_edit)
(handle_pending_conversion_events_1)
(handle_pending_conversion_events, start_batch_edit)
(end_batch_edit, commit_text, finish_composing_text)
(set_composing_text, set_composing_region, textconv_set_point)
(delete_surrounding_text, get_extracted_text)
(report_selected_window_change, report_point_change)
(register_texconv_interface): New functions.

* src/textconv.h (struct textconv_interface)
(TEXTCONV_SKIP_CONVERSION_REGION): Update prototype.
* src/xdisp.c (mark_window_display_accurate_1):
* src/xfns.c (xic_string_conversion_callback):
* src/xterm.c (init_xterm): Adjust accordingly.
2023-02-15 12:23:03 +08:00
Po Lu
0198b8cffd Update Android port
* doc/emacs/android.texi (Android Environment): Document
notifications permission.
* java/org/gnu/emacs/EmacsEditable.java (EmacsEditable):
* java/org/gnu/emacs/EmacsInputConnection.java
(EmacsInputConnection): New files.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): Load
library dependencies in a less verbose fashion.
* java/org/gnu/emacs/EmacsView.java (EmacsView): Make imManager
public.
(onCreateInputConnection): Set InputType to TYPE_NULL for now.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow, onKeyDown)
(onKeyUp, getEventUnicodeChar): Correctly handle key events with
strings.
* lisp/term/android-win.el (android-clear-preedit-text)
(android-preedit-text): New special event handlers.
* src/android.c (struct android_emacs_window): Add function
lookup_string.
(android_init_emacs_window): Adjust accordingly.
(android_wc_lookup_string): New function.
* src/androidgui.h (struct android_key_event): Improve
commentary.
(enum android_lookup_status): New enum.
* src/androidterm.c (handle_one_android_event): Synchronize IM
lookup code with X.
* src/coding.c (from_unicode_buffer): Implement on Android.
* src/coding.h:
* src/sfnt.c: Fix commentary.
2023-02-12 20:32:25 +08:00
Po Lu
ab48881a2f Fix displaying popup menus from a menu entry on Android
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity, onDestroy)
(onWindowFocusChanged): Keep track of the last focused activity.
* java/org/gnu/emacs/EmacsDialog.java (display1): Use it if
there is no current focus.
2023-02-11 10:26:34 +08:00
Po Lu
dc120c7ad6 Improve appearance of the Android preferences screen
* .gitignore: Add org/gnu/emacs/R.java.
* cross/Makefile.in (top_builddir): Include verbose.mk.  Rewrite
rules to print nice looking statements.
* doc/emacs/android.texi (Android, Android Startup)
(Android Environment, Android Windowing, Android Fonts):
* doc/emacs/emacs.texi (Top): Add an extra ``Android
Troubleshooting'' node and move troubleshooting details there.
* java/Makefile.in: Generate R.java; improve appearance by using
verbose.mk.

* java/org/gnu/emacs/EmacsPreferencesActivity.java: Reimplement
in terms of PreferencesActivity.
* java/org/gnu/emacs/EmacsView.java (handleDirtyBitmap): Avoid
flicker.
* java/res/xml/preferences.xml: New file.
* src/verbose.mk.in (AM_V_AAPT, AM_V_SILENT): New variables.
2023-02-10 23:03:43 +08:00
Po Lu
2489126e68 Implement more features for the Emacs ``documents provider''
* java/org/gnu/emacs/EmacsDocumentsProvider.java (queryRoots):
Implement isChild.
(getNotificationUri, notifyChange): New functions.
(queryDocument1): Set rename and remove flags.
(queryDocument, queryChildDocuments): Allow the requester to
detect changes in the directory hierarchy.
(createDocument, deleteDocument, removeDocument): Signal changes
to the directory hierarchy.
2023-02-10 21:07:14 +08:00
Po Lu
9b50500b22 ; * java/org/gnu/emacs/EmacsCopyArea.java (perform): Fix typo. 2023-02-10 19:25:10 +08:00
Po Lu
664140fc26 Fix buffer swapping on Android 7.1 and earlier
* java/org/gnu/emacs/EmacsSurfaceView.java
(reconfigureFrontBuffer): Don't use function only present on
Android 8.0 and later.
2023-02-10 19:06:38 +08:00
Po Lu
a1941cd7a7 Update Android port
* doc/emacs/android.texi (Android Windowing): Remove yet another
limitation.
* java/debug.sh: Make this work on systems which prohibit
attaching to app processes from adbd.
* java/org/gnu/emacs/EmacsCopyArea.java (perform): Avoid
creating copies whenever possible.
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
Remove SurfaceView based implementation and use manual double
buffering with invalidate instead.
* java/org/gnu/emacs/EmacsView.java (EmacsView, handleDirtyBitmap)
(raise, lower, onDetachedFromWindow): Adjust accordingly.
* java/org/gnu/emacs/EmacsWindow.java (windowUpdated): Remove
function.
* src/sfntfont.c (sfntfont_open): Set font->max_width correctly.
2023-02-10 18:57:51 +08:00
Po Lu
209ae003b7 Allow other text editors to edit files in Emacs' home directory
* java/AndroidManifest.xml.in: Declare the new documents
provider.
* java/README: Describe the meaning of files in res/values.
* java/org/gnu/emacs/EmacsDocumentsProvider.java
(EmacsDocumentsProvider): New file.
* java/res/values-v19/bool.xml:
* java/res/values/bool.xml: New files.
2023-02-09 22:56:41 +08:00
Po Lu
0bd4b7fdab Update Android port
* doc/lispref/frames.texi (On-Screen Keyboards): Describe return
value of `frame-toggle-on-screen-keyboard'.
* java/org/gnu/emacs/EmacsSurfaceView.java (surfaceChanged)
(surfaceCreated, EmacsSurfaceView): Remove unuseful
synchronization code.  The framework doesn't seem to look at
this at all.

* java/org/gnu/emacs/EmacsView.java (EmacsView):
(onLayout): Lay out the window after children.
(swapBuffers): Properly implement `force'.
(windowUpdated): Delete function.

* lisp/frame.el (frame-toggle-on-screen-keyboard): Return
whether or not the on screen keyboard might've been displayed.

* lisp/minibuffer.el (minibuffer-on-screen-keyboard-timer):
(minibuffer-on-screen-keyboard-displayed):
(minibuffer-setup-on-screen-keyboard):
(minibuffer-exit-on-screen-keyboard): Improve OSK dismissal when
there are consecutive minibuffers.

* lisp/touch-screen.el (touch-screen-window-selection-changed):
New function.
(touch-screen-handle-point-up): Register it as a window
selection changed function.

* src/android.c (struct android_emacs_window)
(android_init_emacs_window): Remove references to
`windowUpdated'.
(android_window_updated): Delete function.
* src/android.h (struct android_output): Remove
`last_configure_serial'.
* src/androidterm.c (handle_one_android_event)
(android_frame_up_to_date):
* src/androidterm.h (struct android_output): Remove frame
synchronization, as that does not work on Android.
2023-02-08 22:40:10 +08:00
Po Lu
9b79f429ed Port emacsclient wrapper to Android 7.1 and earlier
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): Load every
native library on which Emacs depends prior to loading libemacs
itself.

* java/org/gnu/emacs/EmacsOpenActivity.java (readEmacsClientLog)
(EmacsOpenActivity, startEmacsClient): Don't use redirectError
on Android 7.1 and earlier.
2023-02-06 22:55:42 +08:00
Po Lu
fc82efc1fe Update Android port
* java/AndroidManifest.xml.in: Prevent the Emacs activity from
being overlayed by the emacsclient wrapper.
* java/org/gnu/emacs/EmacsOpenActivity.java (run): Likewise.
(onCreate): Set an appropriate theme on ICS and up.

* java/org/gnu/emacs/EmacsWindow.java (onTouchEvent): Handle
ACTION_CANCEL correctly.
2023-02-06 22:00:08 +08:00
Po Lu
98c90135fe Update Android port
* INSTALL.android: Explain how to build selinux.
* configure.ac: Enable selinux on Android.
* cross/ndk-build/ndk-build-shared-library.mk: ($(call
objname,$(LOCAL_MODULE),$(basename $(1))))::($$(error
Unsupported suffix)::(NDK_CFLAGS_$(LOCAL_MODULE)):
* cross/ndk-build/ndk-build-static-library.mk: ($(call
objname,$(LOCAL_MODULE),$(basename $(1))))::($$(error
Unsupported suffix)::(NDK_CFLAGS_$(LOCAL_MODULE)): Correctly
handle files with a .cc suffix, and clang-specific asflags.
* cross/ndk-build/ndk-clear-vars.mk: Handle AOSP extensions
LOCAL_ADDITIONAL_DEPENDENCIES,
LOCAL_CLANG_ASFLAGS_$(NDK_BUILD_ARCH) and LOCAL_IS_HOST_MODULE.

* doc/emacs/android.texi (Android Startup): Explain emacsclient
wrapper.

* java/org/gnu/emacs/EmacsView.java (EmacsView): New flag
`isCurrentlyTextEditor'.
(showOnScreenKeyboard, hideOnScreenKeyboard): Set as
appropriate.
(onCheckIsTextEditor): Return its value.

* lisp/touch-screen.el (touch-screen-handle-scroll): Don't ding
at buffer limits.
* m4/ndk-build.m4: Improve doc.

* src/Makefile.in (LIBSELINUX_CFLAGS): New variable.
(EMACS_CFLAGS): Add it.
2023-02-05 23:02:14 +08:00
Po Lu
420533a8f9 Add emacsclient desktop file equivalent on Android
* doc/emacs/android.texi (Android File System):
* java/AndroidManifest.xml.in: Update with new activity.  Remove
Android 10 restrictions through a special flag.

* java/org/gnu/emacs/EmacsNative.java (getProcName): New
function.
* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity):
New file.
* java/org/gnu/emacs/EmacsService.java (getLibraryDirection):
Remove unused annotation.
* lib-src/emacsclient.c (decode_options): Set alt_display on
Android.
* src/android.c (android_proc_name): New function.
(NATIVE_NAME): Export via JNI.
2023-02-04 23:32:07 +08:00
Po Lu
9ffb5c0cf3 Add additional permissions to Android port
* doc/emacs/android.texi (Android Environment):
* java/AndroidManifest.xml.in: Add network state permissions.
2023-02-04 19:49:51 +08:00
Po Lu
aa32c9b78b Add Emacs icon for Android package
* java/AndroidManifest.xml.in: Add new icon.
* java/Makefile.in (srcdir): New variable.
(JAVA_FILES, RESOURCE_FILES): Update variables.
(emacs.apk-in): Apply resources.
* java/README: Describe directory tree.
2023-02-02 10:31:10 +08:00
Po Lu
718b1d73d7 Add Emacs icon for Android
* java/res/drawable/emacs.png: New file.
2023-02-02 10:30:15 +08:00
Po Lu
492aa74b13 Update Android port
* INSTALL.android (module_target): Clarify documentation.
* cross/ndk-build/ndk-build-shared-library.mk:
* cross/ndk-build/ndk-build-static-library.mk: Fix building Neon objects.
* java/AndroidManifest.xml.in: Add a version code.
2023-01-29 11:21:07 +08:00
Po Lu
f9e32ce157 Implement `restart-emacs' on Android
* java/org/gnu/emacs/EmacsService.java (restartEmacs): New
function.
* src/android.c (struct android_emacs_service)
(android_init_emacs_service): Add new method.
(android_restart_emacs): New function.
* src/android.h: Update prototypes.
* src/emacs.c (Fkill_emacs): Call android_restart_emacs whenever
appropriate.
2023-01-28 21:21:45 +08:00
Po Lu
198b8160cf Update Android port
* doc/emacs/android.texi (Android File System): Describe an
easier way to disable scoped storage.
* java/AndroidManifest.xml.in: Add new permission to allow that.
* java/README: Add more text describing Java.
* java/org/gnu/emacs/EmacsContextMenu.java (Item): New fields
`isCheckable' and `isChecked'.
(EmacsContextMenu, addItem): New arguments.
(inflateMenuItems): Set checked status as appropriate.

* java/org/gnu/emacs/EmacsCopyArea.java (perform): Disallow
operations where width and height are less than or equal to
zero.
* lisp/menu-bar.el (menu-bar-edit-menu): Make
execute-extended-command available as a menu item.
* src/androidmenu.c (android_init_emacs_context_menu)
(android_menu_show):
* src/menu.c (have_boxes): Implement menu check boxes.
2023-01-28 16:29:22 +08:00
Po Lu
e3b50ec8ec Update Android port
* INSTALL.android: Document support for gnutls and libgmp.
* build-aux/ndk-build-helper-1.mk (NDK_SO_NAMES, NDK_INCLUDES)
(SYSTEM_LIBRARIES):
* build-aux/ndk-build-helper-2.mk: Recursively resolve and add
shared library dependencies; even those of static libraries.
* build-aux/ndk-module-extract.awk: Fix makefile_imports code.
* configure.ac (ANDROID_SDK_18_OR_EARLIER, XCONFIGURE)
(LIBGMP_CFLAGS): Enable GMP and gnutls on Android.

* cross/ndk-build/Makefile.in (LOCAL_EXPORT_C_INCLUDES):
* cross/ndk-build/ndk-build-shared-library.mk: ($(call
objname,$(LOCAL_MODULE),$(basename $(1))))::($$(error
Unsupported suffix)::($(LOCAL_MODULE_FILENAME)):
* cross/ndk-build/ndk-build-static-library.mk: ($(call
objname,$(LOCAL_MODULE),$(basename $(1))))::($$(error
Unsupported suffix):
* cross/ndk-build/ndk-clear-vars.mk:
* cross/ndk-build/ndk-resolve.mk (NDK_SYSTEM_LIBRARIES):
(NDK_LOCAL_EXPORT_C_INCLUDES_$(LOCAL_MODULE)):
(NDK_SO_EXTRA_FLAGS_$(LOCAL_MODULE)):
Implement ``LOCAL_ASM_RULE'' and ``LOCAL_C_ADDITIONAL_FLAGS''
extensions for libgmp.

* doc/emacs/input.texi (Touchscreens): Document how to
horizontally scroll.
* java/org/gnu/emacs/EmacsActivity.java (attachWindow): Give the
view focus again if necessary.
(onPause): Call right super function.
* java/org/gnu/emacs/EmacsPreferencesActivity.java (onClick):
Clear dumpFileName lest Emacs try to load a nonexistent dump
file.
* java/org/gnu/emacs/EmacsView.java (onDetachedFromWindow)
(onAttachedToWindow): Call super functions.
(onCreateInputConnection): Make sure the IME never obscures
Emacs.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow, onKeyDown)
(onKeyUp): Improve tracking of quit keys.

* lisp/isearch.el (isearch-mode): Bring up the onscreen
keyboard.
* lisp/touch-screen.el (touch-screen-current-tool): Add three
fields.
(touch-screen-handle-scroll): Allow hscrolling as well.
(touch-screen-handle-touch): Add additional fields to
`touch-screen-current-tool'.
* src/Makefile.in (LIBGMP_CFLAGS, EMACS_CFLAGS): Add new
variable.
* src/android.c (android_run_select_thread):
(android_write_event): Use pthread_cond_broadcast because
pthread_cond_signal does nothing on some Android
versions/devices?
2023-01-28 14:29:51 +08:00
Po Lu
b0e7ae6d5b Update Android port
* INSTALL.android: Describe that apksigner is also required.
* configure.ac: Correctly add cross/Makefile to
SUBDIR_MAKEFILES.
* cross/Makefile.in: (config.status): Depend on
$(top_srcdir)/config.status.
* doc/emacs/input.texi (On-Screen Keyboards): Document how to
quit without a physical keyboard.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
function `quit'.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): New field
`lastVolumeButtonPress'.
(onKeyDown): Quit if necessary.
* m4/ndk-build.m4 (ndk_where_cc): Fix search if CC is not a
single word.
* src/android.c (android_open): Remove unused variable.
(quit): New function.
* src/androidmenu.c (android_process_events_for_menu): Allow
quitting the menu.
* src/xterm.c (handle_one_xevent, x_term_init, syms_of_xterm):
Implement features described above, so they work on free
operating systems.
* src/xterm.h (struct x_display_info): New fields `quit_keysym',
`quit_keysym_time'.
2023-01-26 22:11:04 +08:00
Po Lu
22f7ad1057 Update Android port
* INSTALL.android: Document how to install sqlite3.
* build-aux/ndk-build-helper-1.mk (SYSTEM_LIBRARIES):
* build-aux/ndk-build-helper-2.mk (SYSTEM_LIBRARIES): Add liblog
and libandroid.
* configure.ac (SQLITE3_LIBS, HAVE_SQLITE3)
(HAVE_SQLITE3_LOAD_EXTENSION): Support on Android.
(APKSIGNER): Look for this new required binary.

* cross/ndk-build/ndk-build-shared-library.mk (objname):
* cross/ndk-build/ndk-build-static-library.mk (objname): Avoid
duplicate rules by prefixing objects with module type.

* cross/ndk-build/ndk-build.mk.in (NDK_BUILD_SHARED): Fix
definition.
* cross/ndk-build/ndk-resolve.mk:
(NDK_SO_EXTRA_FLAGS_$(LOCAL_MODULE)): Handle new system
libraries.

* doc/emacs/android.texi (Android File System): Document Android
10 system restriction.

* java/AndroidManifest.xml.in: Target Android 33, not 28.
* java/Makefile.in (SIGN_EMACS_V2, APKSIGNER): New variables.
($(APK_NAME)): Make sure to apply a ``version 2 signature'' to
the package as well.

* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
argument apiLevel.
* java/org/gnu/emacs/EmacsNoninteractive.java (main):
* java/org/gnu/emacs/EmacsThread.java (run): Pass API level.
* m4/ndk-build.m4 (ndk_package_mape): Add package mapping for
sqlite3.
* src/Makefile.in (SQLITE3_CFLAGS): New substition.
(EMACS_CFLAGS): Add that variable.

* src/android.c (android_api_level): New variable.
(initEmacs): Set it.
(android_file_access_p): Make static.
(android_hack_asset_fd): Adjust for restrictions in Android 29
and later.
(android_close_on_exec): New function.
(android_open): Adjust to not duplicate file descriptor even if
CLOEXEC.
(android_faccessat): Use fstatat at-func emulation.

* src/android.h: Update prototypes.
* src/dired.c (file_name_completion_dirp):
* src/fileio.c (file_access_p, Faccess_file): Now that
sys_faccessat takes care of everything, stop calling
android_file_access_p.
2023-01-26 19:54:38 +08:00
Po Lu
4255d7f051 Update Android port
* .gitignore: Ignore lib/math.h.
* INSTALL.android: Update accordingly.
* build-aux/ndk-build-helper-1.mk:
* build-aux/ndk-build-helper-2.mk:
* build-aux/ndk-build-helper.mk:
* build-aux/ndk-module-extract.awk: Handle C++ modules.
* configure.ac: Enable libxml2 on Android.

* cross/ndk-build/Makefile.in:
* cross/ndk-build/ndk-build-shared-library.mk:
* cross/ndk-build/ndk-build-static-library.mk:
* cross/ndk-build/ndk-build.mk.in:
* cross/ndk-build/ndk-resolve.mk: Fix dependency resolution of
includes.

* java/org/gnu/emacs/EmacsView.java (popupMenu): Fix minimum SDK
version for actual popup menus.
* lib/math.h: Delete file.

* m4/ndk-build.m4 (ndk_SEARCH_MODULE, ndk_CHECK_MODULES): Look
for nasm and C++ libraries.

* src/android.c (faccessat): Rename to `android_faccessat'.
* src/android.h: Update prototypes.
* src/dired.c (file_name_completion_dirp):
* src/fileio.c (file_access_p, Faccess_file, file_directory_p):
* src/lisp.h:
* src/lread.c (openp):
* src/process.c (allocate_pty): Use sys_faccessat.
* src/sysdep.c (sys_faccessat): New function.
2023-01-26 15:37:04 +08:00
Po Lu
0b1ef9ea31 Update Android port
* java/org/gnu/emacs/EmacsDrawLine.java: Fix this again.  Gosh,
how does Android do this.
* java/org/gnu/emacs/EmacsNoninteractive.java (main): Port to
Android 2.3.3.

* java/org/gnu/emacs/EmacsSdk11Clipboard.java
(EmacsSdk11Clipboard): Port to Android 4.0.3.
* java/org/gnu/emacs/EmacsService.java (getClipboardManager):
New function.

* src/alloc.c (find_string_data_in_pure): Fix Android alignment
issue.

* src/android-emacs.c (main): Port to Android 4.4.
* src/android.c (initEmacs): Align stack to 32 bytes, so it ends
up aligned to 16 even though gcc thinks the stack is already
aligned to 16 bytes.

* src/callproc.c (init_callproc): Use /system/bin/sh instead of
/bin/sh by default.
2023-01-25 22:07:51 +08:00
Po Lu
888d351496 Minor fixes to Android port
* java/Makefile.in: (emacs.apk-in): Don't call cp with empty
args.
* java/org/gnu/emacs/EmacsDrawLine.java (perform): Fix for
PostScript filling semantics.
* src/Makefile.in (android-emacs): Build android-emacs directly.
2023-01-25 19:15:30 +08:00
Po Lu
0900bfbcc5 Update Android port
* doc/emacs/android.texi (Android Startup, Android Environment):
Document that restrictions on starting Emacs have been lifted.

* java/README: Document Java for Emacs developers and how the
Android port works.

* java/org/gnu/emacs/EmacsApplication.java (EmacsApplication)
(findDumpFile): New function.
(onCreate): Factor out dump file finding functions to there.

* java/org/gnu/emacs/EmacsNative.java (EmacsNative): Update
function declarations.
* java/org/gnu/emacs/EmacsNoninteractive.java
(EmacsNoninteractive): New class.

* java/org/gnu/emacs/EmacsService.java (EmacsService, getApkFile)
(onCreate): Pass classpath to setEmacsParams.
* java/org/gnu/emacs/EmacsThread.java (EmacsThread): Make run an
override.
* lisp/loadup.el: Don't dump on Android when noninteractive.
* lisp/shell.el (shell--command-completion-data): Handle
inaccessible directories.
* src/Makefile.in (android-emacs): Link with gnulib.
* src/android-emacs.c (main): Implement to launch app-process
and then EmacsNoninteractive.
* src/android.c (setEmacsParams): New argument `class_path'.
Don't set stuff up when running noninteractive.
* src/android.h (initEmacs): Likewise.
* src/androidfont.c (init_androidfont):
* src/androidselect.c (init_androidselect): Don't initialize
when running noninteractive.
* src/emacs.c (load_pdump): New argument `dump_file'.
(android_emacs_init): Give new argument `dump_file' to
`load_pdump'.
* src/sfntfont-android.c (init_sfntfont_android): Don't
initialize when running noninteractive.
2023-01-25 18:44:47 +08:00
Po Lu
9082b4e6ee Make binaries distributed with Emacs work on Android
* doc/lispref/processes.texi (Subprocess Creation): Document
variables containing program names.
* etc/NEWS: Document new variables.
* java/Makefile.in (CROSS_BINS): Add missing etags binary.
* lisp/cedet/semantic/db-ebrowse.el
(semanticdb-create-ebrowse-database):
* lisp/gnus/mail-source.el (mail-source-movemail-program):
* lisp/hexl.el (hexl-program):
* lisp/htmlfontify.el (hfy-etags-bin):
* lisp/ielm.el (inferior-emacs-lisp-mode):
* lisp/mail/rmail.el (rmail-autodetect):
(rmail-insert-inbox-text):
* lisp/org/org-ctags.el (org-ctags-path-to-ctags):
* lisp/progmodes/cperl-mode.el (cperl-etags):
* lisp/speedbar.el (speedbar-fetch-etags-command):
* lisp/textmodes/reftex-global.el (reftex-create-tags-file): Use
new variables.
* src/callproc.c (syms_of_callproc): New variables naming
binaries redistributed with Emacs.
2023-01-24 21:37:22 +08:00
Po Lu
56e55a8008 Update Android port
* INSTALL.android: Update.
* build-aux/ndk-build-helper-1.mk: Fix typo.
* configure.ac: Enable --with-json on Android.
* cross/ndk-build/ndk-build-shared-library.mk:
(NDK_CFLAGS_$(LOCAL_MODULE)):
(LOCAL_MODULE_FILENAME):
* cross/ndk-build/ndk-build-static-library.mk:
(ALL_OBJECT_FILES$(LOCAL_MODULE)):
(LOCAL_MODULE_FILENAME): Recursively resolve dependencies.
* cross/ndk-build/ndk-resolve.mk: New function.

* doc/emacs/android.texi (Android Startup): Document how Emacs
is dumped during initial startup.

* java/Makefile.in (filename): Fix build with multiple shared
libraries.
* java/README: Improve commentary.
* java/org/gnu/emacs/EmacsApplication.java (onCreate): Look and
set dump file.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
function getFingerprint.
* java/org/gnu/emacs/EmacsPreferencesActivity.java (onCreate):
Add option to erase the dump file.
* java/org/gnu/emacs/EmacsService.java (browseUrl): New
function.
* java/org/gnu/emacs/EmacsThread.java (run): Specify dump file
if found.
* lisp/loadup.el: Always dump during loadup on Android.

* lisp/net/browse-url.el (browse-url--browser-defcustom-type):
(browse-url-default-browser):
(browse-url-default-android-browser): New browse url type.

* m4/ndk-build.m4 (ndk_package_map): Map jansson to libjansson.
* src/android.c (struct android_emacs_service): New method
`browse_url'.
(getFingerprint): New function.
(android_init_emacs_service): Initialize new method.
(android_browse_url): New function.

* src/android.h: Update prototypes.

* src/androidselect.c (Fandroid_browse_url): New function.
(syms_of_androidselect): Define it.

* src/emacs.c (load_pdump): Don't look in fancy places on
Android.
* src/pdumper.c (Fdump_emacs_portable): Allow dumping while
interactive on Android.
(syms_of_pdumper): New variable `pdumper-fingerprint'.

* src/sfntfont-android.c (sfntfont_android_composite_bitmap):
Fix unused variables.
2023-01-24 17:31:16 +08:00
Po Lu
4de6b18793 Update Android port
* .gitignore: Update with new files.  Do not ignore std*.in.h.
* INSTALL.android: Explain how to build Emacs with external
dependencies.

* Makefile.in (xcompile, cross): Rename to `cross'.
(clean_dirs): Clean cross, not xcompile.

* README: Document new directories.

* build-aux/ndk-build-helper-1.mk (build_kind, NDK_SO_NAMES):
* build-aux/ndk-build-helper-2.mk (build_kind, NDK_SO_NAMES):
* build-aux/ndk-build-helper-3.mk (build_kind):
* build-aux/ndk-build-helper-4.mk:
* build-aux/ndk-build-helper.mk (NDK_BUILD_DIR, my-dir):
* build-aux/ndk-module-extract.awk: New files.
* configure.ac: Set up libgif, libwebp, and libpng for
ndk-build.
* cross/ndk-build/Makefile.in (srcdir, NDK_BUILD_ANDROID_MK):
* cross/ndk-build/ndk-build-executable.mk:
* cross/ndk-build/ndk-build-shared-library.mk (eq, objname):
* cross/ndk-build/ndk-build-static-library.mk (eq, objname):
* cross/ndk-build/ndk-build.in (NDK_BUILD_MODULES):
* cross/ndk-build/ndk-build.mk.in (NDK_BUILD_MODULES)
(NDK_BUILD_SHARED):
* cross/ndk-build/ndk-clear-vars.mk:
* cross/ndk-build/ndk-prebuilt-shared-library.mk:
* cross/ndk-build/ndk-prebuilt-static-library.mk: New files.
* doc/emacs/android.texi (Android, Android Environment):
Document clipboard support on Android.
* doc/emacs/emacs.texi (Top): Update menus.
* etc/MACHINES: Document Android.
* java/AndroidManifest.xml.in: Respect new
`--with-android-debug' option.
* java/Makefile.in (CROSS_BINS, CROSS_LIBS): Adjust for rename.
Include ndk-build.mk.:(emacs.apk-in): Depend on shared
libraries.  Then, package shared libraries.
* java/org/gnu/emacs/EmacsClipboard.java (EmacsClipboard): New
class.
* java/org/gnu/emacs/EmacsFontDriver.java: Update comment to say
this is unused.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
function `sendExpose'.
* java/org/gnu/emacs/EmacsSdk11Clipboard.java
(EmacsSdk11Clipboard):
* java/org/gnu/emacs/EmacsSdk8Clipboard.java
(EmacsSdk8Clipboard): New classes.
* java/org/gnu/emacs/EmacsView.java (EmacsView, handleDirtyBitmap)
(onDetachedFromWindow): When window is reattached, expose the
frame.

* lib/Makefile.in (VPATH):
(ALL_CFLAGS): Adjust for rename.

* lisp/term/android-win.el (android-clipboard-exists-p)
(android-get-clipboard, android-set-clipboard)
(android-clipboard-owner-p, android-primary-selection)
(android-get-clipboard-1, android-get-primary)
(android-selection-bounds, android-encode-select-string)
(gui-backend-get-selection, gui-backend-selection-exists-p)
(gui-backend-selection-owner-p, gui-backend-set-selection): New
functions.

* m4/ndk-build.m4: New file.
* src/Makefile.in (GIF_CFLAGS, ANDROID_LDFLAGS): New variables.
(EMACS_CFLAGS): Add GIF_CFLAGS.  Include
ndk-build.mk.
(libemacs.so): Depend on and link with required
libraries.

* src/android.c (android_check_compressed_file): New function.
(android_open): Work around Android platform bug.
(sendExpose): New function.
(android_readdir): Set d_type if this is a directory.

* src/androidgui.h (enum android_event_type)
(struct android_expose_event, union android_event): Add expose
events.

* src/androidselect.c (struct android_emacs_clipboard)
(android_init_emacs_clipboard, Fandroid_clipboard_owner_p)
(Fandroid_set_clipboard, Fandroid_get_clipboard)
(Fandroid_clipboard_exists_p, init_androidselect)
(syms_of_androidselect): New file.

* src/androidterm.c (handle_one_android_event): Handle
exposures.
* src/androidterm.h: Update prototypes.
* src/emacs.c (android_emacs_init): Initialize androidselect.
2023-01-24 10:34:40 +08:00
Po Lu
aaacf24ca2 Update Android port
* doc/emacs/android.texi (Android File System): Document that
ls-lisp is now used by default.
* java/org/gnu/emacs/EmacsThread.java (EmacsThread): Name the
thread something meaningful.
* lisp/loadup.el (featurep): Load ls-lisp on Android.
* lisp/ls-lisp.el (ls-lisp-use-insert-directory-program):
Default to off on Android.
* src/android.c (android_is_directory): New fucntion.
(android_fstatat): Handle directories created by
`android_opendir'.
(android_open): Return meaningful file mode.
(struct android_dir): New fields `next', `asset_file' and `fd'.
(android_opendir): Populate those fields.
(android_dirfd): New function.
(android_closedir): Close file descriptor if set.
(android_lookup_asset_directory_fd): New function.

* src/android.h: Update prototypes.
* src/androidfont.c (androidfont_check_init): New function.
(androidfont_list, androidfont_match, androidfont_draw)
(androidfont_open_font, androidfont_close_font)
(androidfont_has_char, androidfont_encode_char)
(androidfont_text_extents, androidfont_list_family): Initialize
font driver if necessary.
(init_androidfont): Don't initialize Java font if necessary.

* src/dired.c (open_directory): Return android_dirfd if
appropriate.
(directory_files_internal, file_name_completion_dirp): Implement
correctly for Android.

* src/fileio.c (check_mutable_filename): New function.
(Fcopy_file, Fdelete_directory_internal, Fdelete_file)
(Frename_file, Fadd_name_to_file, Fmake_symbolic_link)
(Fset_file_modes, Fset_file_times, Ffile_newer_than_file_p)
(Fverify_visited_file_modtime, Fset_visited_file_modtime): Check
that files being written to do not lie in /assets.

* src/sfntfont-android.c (GET_SCANLINE_BUFFER)
(sfntfont_android_u255to256, sfntfont_android_over_8888_1)
(sfntfont_android_over_8888, sfntfont_android_composite_bitmap):
Optimize on 64-bit ARM devices.
(sfntfont_android_put_glyphs): Optimize away memset if
background need not be filled.
2023-01-21 20:03:37 +08:00
Po Lu
d44b60c2f0 Update Android port
* .gitignore: Don't ignore verbose.mk.android.
* doc/emacs/Makefile.in (EMACSSOURCES): Add android.texi and
input.texi.
* doc/emacs/android.texi (Android): Document support for the
on-screen keyboard.
(Android Startup): Document how to start Emacs with -Q on
Android.
(Android Environment): Document how Emacs works around the
system ``task killer''.  Document changes to frame deletion
behavior.
* doc/emacs/emacs.texi (Top):
* doc/emacs/input.texi (Other Input Devices, On-Screen
Keyboards): Document how to use Emacs with virtual keyboards.
* doc/lispref/commands.texi (Touchscreen Events): Document
changes to `touch-screen-track-drag'.
* doc/lispref/frames.texi (Frames, On-Screen Keyboards): New
node.
* java/AndroidManifest.xml.in: Add settings activity and
appropriate OSK adjustment mode.
* java/org/gnu/emacs/EmacsActivity.java (onCreate): Allow
creating Emacs with -Q.
(onDestroy): Don't remove if killed by the system.
* java/org/gnu/emacs/EmacsContextMenu.java (inflateMenuItems):
Fix context menus again.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): Make all
event sending functions return long.
* java/org/gnu/emacs/EmacsPreferencesActivity.java
(EmacsPreferencesActivity): New class.
* java/org/gnu/emacs/EmacsService.java (EmacsService)
(onStartCommand, onCreate, startEmacsService): Start as a
foreground service if necessary to bypass system restrictions.
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
* java/org/gnu/emacs/EmacsThread.java (EmacsThread, run):
* java/org/gnu/emacs/EmacsView.java (EmacsView, onLayout)
(onDetachedFromWindow):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow, viewLayout):
Implement frame resize synchronization..
* java/org/gnu/emacs/EmacsWindowAttachmentManager.java
(EmacsWindowAttachmentManager, removeWindowConsumer): Adjust
accordingly for changes to frame deletion behavior.
* lisp/frame.el (android-toggle-on-screen-keyboard)
(frame-toggle-on-screen-keyboard): New function.
* lisp/minibuffer.el (minibuffer-setup-on-screen-keyboard)
(minibuffer-exit-on-screen-keyboard): New functions.
(minibuffer-setup-hook, minibuffer-exit-hook): Add new functions
to hooks.

* lisp/touch-screen.el (touch-screen-relative-xy): Accept new
value of window `frame'.  Return frame coordinates in that case.
(touch-screen-set-point-commands): New variable.
(touch-screen-handle-point-up): Respect that variable.
(touch-screen-track-drag): Return `no-drag' where appropriate.
(touch-screen-drag-mode-line-1, touch-screen-drag-mode-line):
Refactor to use `no-drag'.

* src/android.c (struct android_emacs_window): New methods.
Make all event sending functions return the event serial.
(android_toggle_on_screen_keyboard, android_window_updated): New
functions.
* src/android.h: Update prototypes.
* src/androidfns.c (Fandroid_toggle_on_screen_keyboard)
(syms_of_androidfns): New function.
* src/androidgui.h (struct android_any_event)
(struct android_key_event, struct android_configure_event)
(struct android_focus_event, struct android_window_action_event)
(struct android_crossing_event, struct android_motion_event)
(struct android_button_event, struct android_touch_event)
(struct android_wheel_event, struct android_iconify_event)
(struct android_menu_event): Add `serial' fields.

* src/androidterm.c (handle_one_android_event)
(android_frame_up_to_date):
* src/androidterm.h (struct android_output): Implement frame
resize synchronization.
2023-01-20 19:06:32 +08:00
Po Lu
a496509ced Update Android port
* .gitignore: Add new files.
* INSTALL.android: Explain how to build Emacs for ancient
versions of Android.
* admin/merge-gnulib (GNULIB_MODULES): Add getdelim.
* build-aux/config.guess (timestamp, version):
* build-aux/config.sub (timestamp, version): Autoupdate.
* configure.ac (BUILD_DETAILS, ANDROID_MIN_SDK):
(ANDROID_STUBIFY): Allow specifying CFLAGS via ANDROID_CFLAGS.
Add new configure tests for Android API version when not
explicitly specified.

* doc/emacs/android.texi (Android): Add reference to ``Other
Input Devices''.
(Android File System): Remove restrictions on directory-files on
the assets directory.
* doc/emacs/emacs.texi (Top): Add Other Input Devices to menu.
* doc/emacs/input.texi (Other Input Devices): New node.
* doc/lispref/commands.texi (Touchscreen Events): Document
changes to touchscreen input events.
* doc/lispref/frames.texi (Pop-Up Menus): Likewise.
* etc/NEWS: Announce changes.
* java/Makefile.in: Use lib-src/asset-directory-tool to generate
an `directory-tree' file placed in /assets.
* java/debug.sh: Large adjustments to support Android 2.2 and
later.

* java/org/gnu/emacs/EmacsContextMenu.java (inflateMenuItems):
* java/org/gnu/emacs/EmacsCopyArea.java (perform):
* java/org/gnu/emacs/EmacsDialog.java (toAlertDialog):
* java/org/gnu/emacs/EmacsDrawLine.java (perform):
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform):
* java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable):
* java/org/gnu/emacs/EmacsFillPolygon.java (perform):
* java/org/gnu/emacs/EmacsFillRectangle.java (perform):
* java/org/gnu/emacs/EmacsGC.java (EmacsGC):
* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap):
(destroyHandle):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java (draw): Avoid
redundant canvas saves and restores.
* java/org/gnu/emacs/EmacsService.java (run):
* java/org/gnu/emacs/EmacsView.java (EmacsView):
(handleDirtyBitmap):
* java/org/gnu/emacs/EmacsWindow.java (changeWindowBackground)
(EmacsWindow): Make compatible with Android 2.2 and later.

* lib-src/Makefile.in (DONT_INSTALL): Add asset-directory-tool
on Android.:(asset-directory-tool{EXEEXT}): New target.
* lib-src/asset-directory-tool.c (struct directory_tree, xmalloc)
(main_1, main_2, main): New file.

* lib, m4: Merge from gnulib.  This will be reverted before
merging to master.

* lisp/button.el (button-map):
(push-button):
* lisp/frame.el (display-popup-menus-p): Improve touchscreen
support.
* lisp/subr.el (event-start):
(event-end): Handle touchscreen events.
* lisp/touch-screen.el (touch-screen-handle-timeout):
(touch-screen-handle-point-update):
(touch-screen-handle-point-up):
(touch-screen-track-tap):
(touch-screen-track-drag):
(touch-screen-drag-mode-line-1):
(touch-screen-drag-mode-line): New functions.
([mode-line touchscreen-begin]):
([bottom-divider touchscreen-begin]): Bind new events.

* lisp/wid-edit.el (widget-event-point):
(widget-keymap):
(widget-event-start):
(widget-button--check-and-call-button):
(widget-button-click): Improve touchscreen support.

* src/alloc.c (make_lisp_symbol): Avoid ICE on Android NDK GCC.
(mark_pinned_symbols): Likewise.

* src/android.c (struct android_emacs_window): New struct.
(window_class): New variable.
(android_run_select_thread): Add workaround for Android platform
bug.
(android_extract_long, android_scan_directory_tree): New
functions.
(android_file_access_p): Use those functions instead.
(android_init_emacs_window): New function.
(android_init_emacs_gc_class): Update signature of `markDirty'.
(android_change_gc, android_set_clip_rectangles): Tell the GC
whether or not clip rects were dirtied.
(android_swap_buffers): Do not look up method every time.
(struct android_dir): Adjust for new directory tree lookup.
(android_opendir, android_readdir, android_closedir): Likewise.
(android_four_corners_bilinear): Fix coding style.
(android_ftruncate): New function.
* src/android.h: Update prototypes.  Replace ftruncate with
android_ftruncate when necessary.

* src/androidterm.c (handle_one_android_event): Pacify GCC.  Fix
touch screen tool bar bug.
* src/emacs.c (using_utf8): Fix compilation error.
* src/fileio.c (Ffile_system_info): Return Qnil when fsusage.o
is not built.
* src/filelock.c (BOOT_TIME_FILE): Fix definition for Android.
* src/frame.c (Fx_parse_geometry): Fix uninitialized variable
uses.
* src/keyboard.c (lispy_function_keys): Fix `back'.
* src/menu.c (x_popup_menu_1): Handle touch screen events.
(Fx_popup_menu): Document changes.

* src/sfnt.c (main): Improve tests.

* src/sfntfont-android.c (sfntfont_android_put_glyphs): Fix
minor problem.
(init_sfntfont_android): Check for
HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL.
* src/sfntfont.c (struct sfnt_font_desc): New fields `adstyle'
and `languages'.
(sfnt_parse_style): Append tokens to adstyle.
(sfnt_parse_languages): New function.
(sfnt_enum_font_1): Parse supported languages and adstyle.
(sfntfont_list_1): Handle new fields.
(sfntfont_text_extents): Fix uninitialized variable use.
(syms_of_sfntfont, mark_sfntfont): Adjust accordingly.
2023-01-19 22:19:06 +08:00
Po Lu
1b8258a1f2 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.
2023-01-17 22:10:43 +08:00
Po Lu
ad59d8986a Update Android port
* doc/emacs/android.texi (Android, Android Environment): Improve
documentation.
* doc/lispref/commands.texi (Touchscreen Events): Document
changes to touchscreen support.
* doc/lispref/display.texi (Defining Faces, Window Systems):
* doc/lispref/frames.texi (Frame Layout, Font and Color
Parameters):
* doc/lispref/os.texi (System Environment): Document Android in
various places.

* java/org/gnu/emacs/EmacsWindow.java (figureChange): Fix crash.
* lisp/loadup.el: ("touch-screen"): Load touch-screen.el.
* lisp/pixel-scroll.el: Autoload two functions.
* lisp/term/android-win.el: Add require 'touch-screen.
* lisp/touch-screen.el (touch-screen-current-tool)
(touch-screen-current-timer, touch-screen-delay)
(touch-screen-relative-xy, touch-screen-handle-scroll)
(touch-screen-handle-timeout, touch-screen-handle-point-update)
(touch-screen-handle-point-up, touch-screen-handle-touch)
(global-map, touch-screen): New file.
* src/android.c (android_run_debug_thread): Fix build on 64 bit
systems.
(JNICALL, android_put_pixel): Likewise.
(android_transform_coordinates, android_four_corners_bilinear)
(android_fetch_pixel_bilinear, android_project_image_bilinear)
(android_fetch_pixel_nearest_24, android_fetch_pixel_nearest_1)
(android_project_image_nearest): New functions.
* src/androidgui.h (struct android_transform): New structure.
* src/androidterm.c (android_note_mouse_movement): Remove
obsolete TODO.
(android_get_scale_factor): New function.
(android_draw_underwave): Scale underwave correctly.
* src/dispextern.h: Support native image transforms on Android.
* src/image.c (matrix_identity, matrix_rotate)
(matrix_mirror_horizontal, matrix_translate): New functions.
(image_set_transform): Implement native image transforms on
Android.
(Fimage_transforms_p): Implement on Android.

* src/keyboard.c (make_lispy_event, syms_of_keyboard): Handle
touch screen- menu bar events.
* src/sfnt.c: Fix typo in comment.
* src/sfntfont-android.c (sfntfont_android_blend, U255TO256)
(sfntfont_android_put_glyphs): Avoid redundant swizzling.
* src/sfntfont.c (sfntfont_lookup_char): Fix build on 64 bit
systems.
2023-01-16 19:50:02 +08:00
Po Lu
da9ae10636 Implement submenus on Android
* java/org/gnu/emacs/EmacsActivity.java (onCreate): Set the
default theme to Theme.DeviceDefault.NoActionBar if possible.
(onContextMenuClosed): Add hack for Android bug.
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu)
(onMenuItemClick): Set flag upon submenu selection.
(inflateMenuItems): Set onClickListener for submenus as well.
(display1): Clear new flag.
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform): Fix
rectangle bounds.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative):
* java/org/gnu/emacs/EmacsService.java (onCreate): Pass cache
directory.
(sync): New function.
* src/android.c (struct android_emacs_service): New method
`sync'.
(setEmacsParams, initEmacs): Handle cache directory.
(android_init_emacs_service): Initialize new method `sync'.
(android_sync): New function.
* src/androidfns.c (Fx_show_tip): Call both functions.
* src/androidgui.h: Update prototypes.
* src/androidmenu.c (struct android_menu_subprefix)
(android_free_subprefixes, android_menu_show): Handle submenu
prefixes correctly.
* src/androidterm.c (handle_one_android_event): Clear help echo
on MotionNotify like on X.
* src/menu.c (single_menu_item): Enable submenus on Android.
2023-01-15 15:45:29 +08:00
Po Lu
6e2bc91d92 Implement toolkit menus on Android
* java/org/gnu/emacs/EmacsActivity.java (onContextMenuClosed):
New function.
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu):
New field `itemAlreadySelected'.
(onMenuItemClick): New function.
(inflateMenuItems): Attach onClickListener as appropriate.
(display1): Clear itemAlreadySelected.
(display): Fix runnable synchronization.
* java/org/gnu/emacs/EmacsNative.java (sendContextMenu): New
function.
* java/org/gnu/emacs/EmacsView.java (popupMenu):
(cancelPopupMenu): Set popupactive correctly.

* src/android.c (android_run_select_thread): Fix android_select
again.
(android_wait_event): New function.
* src/android.h: Update prototypes.
* src/androidgui.h (enum android_event_type): New
`ANDROID_CONTEXT_MENU' event.
(struct android_menu_event, union android_event): Add new event.

* src/androidmenu.c (struct android_emacs_context_menu): New
structure.
(android_init_emacs_context_menu): Add `dismiss' method.
(struct android_dismiss_menu_data): New structure.
(android_dismiss_menu, android_process_events_for_menu): New
functions.
(android_menu_show): Set an actual item ID.
(popup_activated): Define when stubify as well.
(Fmenu_or_popup_active_p): New function.
(syms_of_androidmenu): New function.

* src/androidterm.c (handle_one_android_event): Handle context
menu events.
* src/androidterm.h (struct android_display_info): New field for
menu item ID.
* src/emacs.c (android_emacs_init): Call syms_of_androidmenu.
* src/xdisp.c (note_mouse_highlight): Return if popup_activated
on Android as well.
2023-01-15 11:57:10 +08:00
Po Lu
2b87ab7b27 Update Android port
* java/Makefile.in (clean): Fix distclean and bootstrap-clean rules.
* java/debug.sh (jdb_port):
(attach_existing):
(num_pids):
(line): Add new options to upload a gdbserver binary to the device.

* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity): Make
focusedActivities public.
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu):
New class.
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform): Fix
bounds computation.
* java/org/gnu/emacs/EmacsGC.java (markDirty): Set stroke width
explicitly.
* java/org/gnu/emacs/EmacsService.java (EmacsService)
(getLocationOnScreen, nameKeysym): New functions.
* java/org/gnu/emacs/EmacsView.java (EmacsView): Disable focus
highlight.
(onCreateContextMenu, popupMenu, cancelPopupMenu): New
functions.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): Implement a
kind of ``override redirect'' window for tooltips.
* src/android.c (struct android_emacs_service): New method
`name_keysym'.
(android_run_select_thread, android_init_events):
(android_select): Release select thread on semaphores instead of
signals to avoid one nasty race on SIGUSR2 delivery.
(android_init_emacs_service): Initialize new method.
(android_create_window): Handle CW_OVERRIDE_REDIRECT.
(android_move_resize_window, android_map_raised)
(android_translate_coordinates, android_get_keysym_name)
(android_build_string, android_exception_check): New functions.
* src/android.h: Update prototypes.

* src/androidfns.c (android_set_parent_frame, Fx_create_frame)
(unwind_create_tip_frame, android_create_tip_frame)
(android_hide_tip, compute_tip_xy, Fx_show_tip, Fx_hide_tip)
(syms_of_androidfns): Implement tooltips and iconification
reporting.

* src/androidgui.h (enum android_window_value_mask): Add
CWOverrideRedirect.
(struct android_set_window_attributes): Add `override_redirect'.
(ANDROID_IS_MODIFIER_KEY): Recognize Caps Lock.

* src/androidmenu.c (struct android_emacs_context_menu): New
struct.
(android_init_emacs_context_menu, android_unwind_local_frame)
(android_push_local_frame, android_menu_show, init_androidmenu):
New functions.

* src/androidterm.c (handle_one_android_event): Fix NULL pointer
dereference.
(android_fullscreen_hook): Handle fullscreen correctly.
(android_draw_box_rect): Fix top line.
(get_keysym_name): Implement function.
(android_create_terminal): Remove scroll bar stubs and add menu
hook.

* src/androidterm.h: Update prototypes.
* src/emacs.c (android_emacs_init): Initialize androidmenu.c.
* xcompile/Makefile.in: Fix clean rules.
2023-01-14 22:12:16 +08:00
Po Lu
28a9baccd4 Improve reliability of Android build system
* .gitignore: Add new files.
* INSTALL.android: New file.
* Makefile.in (clean_dirs): Clean xcompile as well.
* admin/merge-gnulib (avoided_flags): Import gnulib into Android
directory as well.
* doc/emacs/android.texi (Android):
* doc/emacs/emacs.texi (Top): New node `Android'.
* java/org/gnu/emacs/EmacsThread.java (run): Use right
executable name.
* lib/Makefile.in (ANDROID_CFLAGS): Use better way to refer to
/src.
(vpath): Delete ugly block of vpath statements.
(mostlyclean): Remove Makefile.android.
* lib/fpending.c (__fpending):
* lib/open.c:
* lib/unistd.c (_GL_UNISTD_INLINE): Revert changes to gnulib in
lib/.
* src/android.h:
* src/androidterm.c: Fix build.
* xcompile/Makefile.in (LIB_SRCDIR):
(LIBSRC_BINARIES, src/verbose.mk):
(PRE_BUILD_DEPS, PHONY): Use gnulib in xcompile/lib/ as opposed
to lib/.
* xcompile/README: Adjust README.
2023-01-14 09:34:53 +08:00
Po Lu
24910d3f37 Fix crashes in Android port
* java/org/gnu/emacs/EmacsService.java (queryTree): Fix NULL
pointer dereference.
* src/android.c (android_query_tree): Set *nchildren_return.
2023-01-13 16:08:11 +08:00
Po Lu
0b61fd7700 * java/AndroidManifest.xml: Remove file that is now generated. 2023-01-13 16:05:08 +08:00
Po Lu
f9732131cf Update Android port
* configure.ac (ANDROID_MIN_SDK): New variable.
(DX): Remove and replace with D8.
(XCONFIGURE): Check for the minimum version of Android the cross
compiler compiles for.  Generate java/AndroidManifest.xml from
java/AndroidManifest.xml.in.  Allow using Zlib on Android.

* java/AndroidManifest.xml.in: New file.  Use the minimum SDK
detected by configure.

* java/Makefile.in (top_srcdir, version): New variables.
(DX, D8): Replace with D8.
(ANDROID_MIN_SDK, APK_NAME): New variables.
(.PHONY):
(.PRECIOUS):
(classes.dex):
(emacs.apk): Generate $(APK_NAME) instead of `emacs.apk'.

* java/debug.sh: New option --attach-existing.  Attach to an
existing Emacs instance when specified.

* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity): New
field `isPaused'.
(invalidateFocus1): Fix infinite recursion.
(detachWindow): Deiconify window.
(attachWindow): Iconify the window if the activity is paused.
(onCreate): Use the ``no title bar'' theme.
(onPause, onResume): New functions.
* java/org/gnu/emacs/EmacsNative.java (sendTouchUp, sendTouchDown)
(sendTouchMove, sendWheel, sendIconified, sendDeiconified): New
functions.
* java/org/gnu/emacs/EmacsSdk7FontDriver.java (Sdk7Typeface):
(list): Remove logging for code that is mostly going to be unused.
* java/org/gnu/emacs/EmacsService.java (ringBell, queryTree)
(getScreenWidth, getScreenHeight, detectMouse): New functions.
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView)
(surfaceChanged, surfaceCreated, surfaceDestroyed): Add extra
debug logging.  Avoid deadlock in surfaceCreated.

* java/org/gnu/emacs/EmacsView.java (EmacsView): Try very hard
to make the SurfaceView respect Z order.  It didn't work.
(handleDirtyBitmap): Copy over the contents from the old bitmap.
(explicitlyDirtyBitmap): New function.
(onLayout): Don't dirty bitmap if unnecessary.
(damageRect, swapBuffers): Don't synchronize so hard.
(onTouchEvent): Call window.onTouchEvent instead.
(moveChildToBack, raise, lower): New functions.

* java/org/gnu/emacs/EmacsWindow.java (Coordinate): New
subclass.
(pointerMap, isMapped, isIconified, dontFocusOnMap)
(dontAcceptFocus): New fields.
(EmacsWindow): Don't immediately register unmapped window.
(viewLayout): Send configure event outside the lock.
(requestViewLayout): Explicitly dirty the bitmap.
(mapWindow): Register the window now.  Respect dontFocusOnMap.
(unmapWindow): Unregister the window now.
(figureChange, onTouchEvent): New functions.
(onSomeKindOfMotionEvent): Handle scroll wheel events.
(reparentTo, makeInputFocus, raise, lower, getWindowGeometry)
(noticeIconified, noticeDeiconified, setDontAcceptFocus)
(setDontFocusOnMap, getDontFocusOnMap): New functions.
* java/org/gnu/emacs/EmacsWindowAttachmentManager.java
(registerWindow, detachWindow): Synchronize.
(noticeIconified, noticeDeiconified): New functions.
(copyWindows): New function.

* lisp/frame.el (frame-geometry, frame-edges)
(mouse-absolute-pixel-position, set-mouse-absolute-pixel-position)
(frame-list-z-order, frame-restack, display-mouse-p)
(display-monitor-attributes-list): Implement on Android.

* lisp/mwheel.el (mouse-wheel-down-event):
(mouse-wheel-up-event):
(mouse-wheel-left-event):
(mouse-wheel-right-event): Define on Android.

* src/android.c (struct android_emacs_service): New methods
`ringBell', `queryTree', `getScreenWidth', `getScreenHeight',
and `detectMouse'.
(struct android_event_queue, android_init_events)
(android_next_event, android_write_event): Remove write limit.
(android_file_access_p): Handle directories correcty.
(android_close): Fix coding style.
(android_fclose): New function.
(android_init_emacs_service): Initialize new methods.
(android_reparent_window): Implement function.
(android_bell, android_set_input_focus, android_raise_window)
(android_lower_window, android_query_tree, android_get_geometry)
(android_get_screen_width, android_get_screen_height)
(android_get_mm_width, android_get_mm_height, android_detect_mouse)
(android_set_dont_focus_on_map, android_set_dont_accept_focus):
New functions.
(struct android_dir): New structure.
(android_opendir, android_readdir, android_closedir): New
functions.
(emacs_abort): Implement here on Android and poke debuggerd into
generating a tombstone.

* src/android.h: Update prototypes.

* src/androidfns.c (android_set_parent_frame): New function.
(android_default_font_parameter): Use sane font size by default.
(Fx_display_pixel_width, Fx_display_pixel_height)
(Fx_display_mm_width, Fx_display_mm_height)
(Fx_display_monitor_attributes_list): Rename to start with
`android-'.  Implement.  Fiddle with documentation to introduce
Android specific nuances.
(Fandroid_display_monitor_attributes_list): New function.
(Fx_frame_geometry, frame_geometry): New function.
(Fandroid_frame_geometry): Implement correctly.
(Fx_frame_list_z_order): Rename to start with `android-'.
(android_frame_list_z_order, Fandroid_frame_list_z_order):
Implement.
(Fx_frame_restack): Rename to start with `android-'.
(Fandroid_frame_restack): ``Implement''.
(Fx_mouse_absolute_pixel_position): Rename to start with
`android-'.
(Fandroid_mouse_absolute_pixel_position): ``Implement''.
(Fx_set_mouse_absolute_pixel_position): Rename to start with
`android-'.
(Fandroid_set_mouse_absolute_pixel_position): ``Implement''.
(Fandroid_detect_mouse): New function.
(android_set_menu_bar_lines): Use FRAME_ANDROID_DRAWABLE when
clearing area.
(android_set_no_focus_on_map, android_set_no_accept_focus): New
functions.
(android_frame_parm_handlers): Register new frame parameter
handlers.
(syms_of_androidfns): Update appropriately.

* src/androidfont.c (androidfont_draw): Use
FRAME_ANDROID_DRAWABLE instead of FRAME_ANDROID_WINDOW.

* src/androidgui.h (enum android_event_type): New events.
(struct android_touch_event, struct android_wheel_event)
(struct android_iconify_event): New structures.
(union android_event): Add new events.

* src/androidterm.c (android_clear_frame): Use
FRAME_ANDROID_DRAWABLE instead of FRAME_ANDROID_WINDOW.
(android_flash, android_ring_bell): Implement bell ringing.
(android_toggle_invisible_pointer): Don't TODO function that
can't be implemented.
(show_back_buffer, android_flush_dirty_back_buffer_on): Check if
a buffer flip is required before doing the flip.
(android_lower_frame, android_raise_frame): Implement functions.
(android_update_tools, android_find_tool): New functions.
(handle_one_android_event): Handle new iconification, wheel and
touch events.
(android_read_socket): Implement pending-autoraise-frames.
(android_frame_up_to_date): Implement bell ringing.
(android_buffer_flipping_unblocked_hook): Check if a buffer flip
is required before doing the flip.
(android_focus_frame, android_frame_highlight)
(android_frame_unhighlight): New function.
(android_frame_rehighlight): Implement functions.
(android_iconify_frame): Always display error.
(android_set_alpha): Update commentary.
(android_free_frame_resources): Free frame touch points.
(android_scroll_run, android_flip_and_flush)
(android_clear_rectangle, android_draw_fringe_bitmap)
(android_draw_glyph_string_background, android_fill_triangle)
(android_clear_point, android_draw_relief_rect)
(android_draw_box_rect, android_draw_glyph_string_bg_rect)
(android_draw_image_foreground, android_draw_stretch_glyph_string)
(android_draw_underwave, android_draw_glyph_string_foreground)
(android_draw_composite_glyph_string_foreground)
(android_draw_glyphless_glyph_string_foreground)
(android_draw_glyph_string, android_clear_frame_area)
(android_clear_under_internal_border, android_draw_hollow_cursor)
(android_draw_bar_cursor, android_draw_vertical_window_border)
(android_draw_window_divider): Use FRAME_ANDROID_DRAWABLE
instead of FRAME_ANDROID_WINDOW for drawing operations.

* src/androidterm.h (struct android_touch_point): New structure.
(struct android_output): New fields.
(FRAME_ANDROID_NEED_BUFFER_FLIP): New macro.

* src/dired.c (emacs_readdir, open_directory)
(directory_files_internal_unwind, read_dirent)
(directory_files_internal, file_name_completion): Add
indirection over readdir and opendir.  Use android variants on
Android.

* src/dispnew.c (Fopen_termscript):
* src/fileio.c (fclose_unwind): Use emacs_fclose.
(Faccess_file): Call android_file_access_p.
(file_accessible_directory_p): Append right suffix to Android
assets directory.
(do_auto_save_unwind): Use emacs_fclose.
* src/keyboard.c (lispy_function_keys): Use right function key
for page up and page down.
(Fopen_dribble_file): Use emacs_fclose.

* src/lisp.h: New prototype emacs_fclose.

* src/lread.c (close_infile_unwind): Use emacs_fclose.

* src/sfnt.c (sfnt_curve_is_flat): Fix area-squared computation.
(sfnt_prepare_raster): Compute raster width and height
consistently with outline building.
(sfnt_build_outline_edges): Use the same offsets used to set
offy and offx.
(main): Adjust debug code.

* src/sfntfont-android.c (sfntfont_android_saturate32): Delete
function.
(sfntfont_android_blend, sfntfont_android_blendrgb): Remove
unnecessary debug code.
(sfntfont_android_composite_bitmap): Prevent out of bounds
write.
(sfntfont_android_put_glyphs): Use FRAME_ANDROID_DRAWABLE.
(init_sfntfont_android): Initialize Monospace Serif font to
something sensible.
* src/sfntfont.c (sfntfont_text_extents): Clear glyph metrics
before summing up pcm.
(sfntfont_draw): Use s->font instead of s->face->font.

* src/sysdep.c (emacs_fclose): Wrap around android_fclose on
android.

* src/term.c (Fsuspend_tty):
(delete_tty): Use emacs_fclose.
* src/verbose.mk.in (AM_V_DX): Replace with D8 version.
2023-01-13 15:53:08 +08:00
Po Lu
86fe893128 Delete unused files
* java/org/gnu/emacs/EmacsPaintQueue.java
* java/org/gnu/emacs/EmacsPaintReq.java: Remove files.
2023-01-08 15:39:28 +08:00
Po Lu
695e26079e Update Java part of Android port
* java/org/gnu/emacs/EmacsCopyArea.java (EmacsCopyArea, perform)
(paintTo):
* java/org/gnu/emacs/EmacsDrawLine.java (EmacsDrawLine):
* java/org/gnu/emacs/EmacsDrawPoint.java (EmacsDrawPoint):
* java/org/gnu/emacs/EmacsDrawRectangle.java (EmacsDrawRectangle)
(paintTo):
* java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable):
* java/org/gnu/emacs/EmacsFillPolygon.java (EmacsFillPolygon):
* java/org/gnu/emacs/EmacsFillRectangle.java
(EmacsFillRectangle):
* java/org/gnu/emacs/EmacsFontDriver.java (EmacsFontDriver):
* java/org/gnu/emacs/EmacsGC.java (EmacsGC):
* java/org/gnu/emacs/EmacsNative.java (EmacsNative):
* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap):
* java/org/gnu/emacs/EmacsSdk23FontDriver.java
(EmacsSdk23FontDriver):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java
(EmacsSdk7FontDriver, textExtents1, textExtents, draw):
* java/org/gnu/emacs/EmacsService.java (EmacsService, copyArea):
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
* java/org/gnu/emacs/EmacsView.java (EmacsView, onLayout)
(onFocusChanged):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow, run)
(resizeWindow, lockCanvas, getBitmap, onKeyDown, onKeyUp)
(onActivityDetached): Move rendering to main thread.  Make
drawing operations completely static.
2023-01-08 15:39:02 +08:00
Po Lu
a32963e11f Update Android port
* Makefile.in (java): Depend on info.
(MAKEFILE_NAME):
(config.status): Remove unneeded changes.
* configure.ac (BUILD_DETAILS, ANDROID_STUBIFY): Don't require a
C++ compiler on Android.
* java/AndroidManifest.xml: <EmacsActivity>: Set launchMode
appropriately.  <EmacsMultitaskActivity>: New activity.
* java/Makefile.in (CROSS_BINS): Add EmacsClient.
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity)
(onCreate): Use the window attachment manager.
* java/org/gnu/emacs/EmacsCopyArea.java (EmacsCopyArea)
(paintTo): Implement clip masks correctly.
* java/org/gnu/emacs/EmacsDrawRectangle.java (getRect, paintTo):
Fix damage tracking rectangles.
* java/org/gnu/emacs/EmacsFontDriver.java (FontSpec, toString):
New function.
(FontMetrics, EmacsFontDriver): Fix signature of textExtents.
* java/org/gnu/emacs/EmacsMultitaskActivity.java
(EmacsMultitaskActivity): New file.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
functions sendFocusIn, sendFocusOut, sendWindowAction.
* java/org/gnu/emacs/EmacsPaintQueue.java (run): Fix clipping
handling.
* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap): Add
constructor for mutable pixmaps.
* java/org/gnu/emacs/EmacsSdk23FontDriver.java
(EmacsSdk23FontDriver): New file.
* java/org/gnu/emacs/EmacsSdk7FontDriver.java
(EmacsSdk7FontDriver, Sdk7Typeface, Sdk7FontEntity, Sdk7FontObject)
(checkMatch, hasChar, encodeChar): Implement text display and
fix font metrics semantics.

* java/org/gnu/emacs/EmacsService.java (EmacsService): Remove
availableChildren.
(getLibraryDirectory, onCreate): Pass pixel density to Emacs.
(clearArea): Fix arguments.  Switch to using the window
attachment manager.
* java/org/gnu/emacs/EmacsSurfaceView.java (surfaceChanged)
(surfaceCreated): Flip buffers on surface attachment.
* java/org/gnu/emacs/EmacsView.java (EmacsView, swapBuffers):
New argument FORCE.  Always swap if it is true.
(onKeyMultiple, onFocusChanged): New functions.

* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow, destroyHandle)
(run): Switch to using the window attachment manager.
* java/org/gnu/emacs/EmacsWindowAttachmentManager.java
(EmacsWindowAttachmentManager): New file.

* lisp/cus-edit.el (custom-button, custom-button-mouse)
(custom-button-pressed):
* lisp/faces.el (tool-bar): Define faces correctly on Android.
* src/android.c (struct android_emacs_pixmap): Add mutable
constructor.
(struct android_emacs_drawable): New structure.
(android_write_event): Check if event queue hasn't yet been
initialized.
(android_select): Set errno to EINTR if pselect fails.
(android_close): Remove unused debugging code.
(android_get_home_directory): New function.
(Java_org_gnu_emacs_EmacsNative_setEmacsParams): Set pixel
density and compute game path.
(android_init_emacs_drawable): New function.
(Java_org_gnu_emacs_EmacsNative_sendKeyPress): New argument
`unicode_char'.  Pass it in events.
(Java_org_gnu_emacs_EmacsNative_sendKeyRelease): Likewise.
(Java_org_gnu_emacs_EmacsNative_sendFocusIn)
(Java_org_gnu_emacs_EmacsNative_sendFocusOut)
(Java_org_gnu_emacs_EmacsNative_sendWindowAction): New
functions.
(android_resolve_handle): Export function.
(android_change_gc): Clear clip rects under the right
circumstances.  Set right clip mask field.
(android_create_pixmap_from_bitmap_data): Use correct alpha
channels.
(android_create_pixmap): Create mutable pixmap and avoid
redundant color array allocation.
(android_create_bitmap_from_data, android_create_image)
(android_destroy_image, android_put_pixel, android_get_pixel)
(android_get_image, android_put_image, faccessat): New
functions.

* src/android.h: Update prototypes.

* src/androidfns.c (android_default_font_parameter): Prefer
monospace to Droid Sans Mono.
* src/androidfont.c (struct android_emacs_font_driver): New
method `draw'.
(struct android_emacs_font_spec): New field `dpi'.
(struct androidfont_info): Add font metrics cache.
(android_init_font_driver, android_init_font_spec): Adjust
accordingly.
(androidfont_from_lisp, androidfont_from_java): Handle new
fields.
(androidfont_draw): Implement function.
(androidfont_open_font): Set pixel size correctly.
(androidfont_close_font): Free metrics cache.
(androidfont_cache_text_extents)
(androidfont_check_cached_extents): New functions.
(androidfont_text_extents): Cache glyph metrics somewhere for
future use.
(androidfont_list_family): Implement function.

* src/androidgui.h (enum android_event_type): New focus and
window action events.
(enum android_modifier_mask): New masks.
(struct android_key_event): New field `unicode_char'.
(ANDROID_IS_MODIFIER_KEY): Newmacro.
(struct android_focus_event, struct
android_window_action_event): New structs.
(union android_event): Add new fields.
(enum android_image_format, struct android_image): New enums and
structs.

* src/androidterm.c (android_android_to_emacs_modifiers)
(android_emacs_to_android_modifiers, android_lower_frame)
(android_raise_frame, android_new_focus_frame)
(android_focus_changed, android_detect_focus_change): New
functions.
(handle_one_android_event): Implement focus and key event
handling.
(android_frame_rehighlight): New function.
(android_frame_raise_lower): Implement accordingly.
(android_make_frame_invisible): Clear highlight_frame if
required.
(android_free_frame_resources): Clear x_focus_event_frame if
required.
(android_draw_fringe_bitmap, android_draw_image_foreground)
(android_draw_image_foreground_1)
(android_draw_image_glyph_string): Remove unnecessary code.
(android_create_terminal, android_term_init): Set the baud rate
to something sensible.
* src/androidterm.h (struct android_bitmap_record): Make
structure the same as on X.
(struct android_display_info): New focus tracking fields.
(struct android_output): Likewise.
* src/dispextern.h (struct image): Add ximg and mask_img on
Android.

* src/emacs.c (android_emacs_init): Fix argc sorting iteration.

* src/fileio.c (user_homedir):
(get_homedir): Implement correctly on Android.

* src/font.h (PT_PER_INCH): Define correctly on Android.

* src/fringe.c (X, swap_nibble, init_fringe_bitmap): Swap fringe
bitmaps correctly on Android.

* src/image.c (GET_PIXEL, image_create_bitmap_from_data)
(image_create_bitmap_from_file, free_bitmap_record)
(image_unget_x_image_or_dc, struct image_type)
(prepare_image_for_display, image_clear_image_1)
(image_size_in_bytes, x_check_image_size)
(x_create_x_image_and_pixmap, x_destroy_x_image)
(image_check_image_size, image_create_x_image_and_pixmap_1)
(image_destroy_x_image, gui_put_x_image, image_put_x_image)
(image_get_x_image, image_unget_x_image)
(Create_Pixmap_From_Bitmap_Data, image_pixmap_draw_cross)
(MaskForeground, image_types, syms_of_image): Implement all of
the above on Android in terms of an API very similar to X.

* src/keyboard.c (FUNCTION_KEY_OFFSET, lispy_function_keys):
Define on Android to something sensible.

* src/lread.c (build_load_history): Fix problem.
2023-01-02 21:38:19 +08:00
Po Lu
cfbc8a5dbc Bring up the Android operating system and its window system
* .dir-locals.el (c-mode): Add ANDROID_EXPORT noise macro.
* .gitignore: Add new files to ignore.
* Makefile.in: Adjust for Android.
* admin/merge-gnulib: Add new warning.
* configure.ac: Detect Android.  Run cross-configuration for
Android when appropriate.

* etc/DEBUG: Document how to debug Emacs on Android.

* java/AndroidManifest.xml:
* java/Makefile.in:
* java/README:
* java/debug.sh:
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity):
* java/org/gnu/emacs/EmacsApplication.java (EmacsApplication):
* java/org/gnu/emacs/EmacsCopyArea.java (EmacsCopyArea):
* java/org/gnu/emacs/EmacsDrawLine.java (EmacsDrawLine):
* java/org/gnu/emacs/EmacsDrawPoint.java (EmacsDrawPoint):
* java/org/gnu/emacs/EmacsDrawRectangle.java
(EmacsDrawRectangle):
* java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable):
* java/org/gnu/emacs/EmacsFillPolygon.java (EmacsFillPolygon):
* java/org/gnu/emacs/EmacsFillRectangle.java
(EmacsFillRectangle):
* java/org/gnu/emacs/EmacsFontDriver.java (EmacsFontDriver):
* java/org/gnu/emacs/EmacsGC.java (EmacsGC):
* java/org/gnu/emacs/EmacsHandleObject.java (EmacsHandleObject):
* java/org/gnu/emacs/EmacsNative.java (EmacsNative):
* java/org/gnu/emacs/EmacsPaintQueue.java (EmacsPaintQueue):
* java/org/gnu/emacs/EmacsPaintReq.java (EmacsPaintReq):
* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java
(EmacsSdk7FontDriver):
* java/org/gnu/emacs/EmacsService.java (class Holder<T>)
(EmacsService):
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
* java/org/gnu/emacs/EmacsThread.java (EmacsThread):
* java/org/gnu/emacs/EmacsView.java (EmacsView):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): New files
and classes.

* lib-src/Makefile.in (srcdir):
* lib/Makefile.in (VPATH):
(HAVE_NATIVE_COMP):
(libgnu_a_SOURCES):
(DEPFLAGS): Configure correctly for cross-compiling.

* lib/faccessat.c:
* lib/fpending.c (__fpending):
* lib/open.c:
* lib/unistd.c (_GL_UNISTD_INLINE): Temporary adjustments to
gnulib.

* lisp/frame.el (display-graphic-p):
(display-screens):
(display-pixel-height):
(display-pixel-width):
(display-mm-height):
(display-mm-width):
(display-backing-store):
(display-save-under):
(display-planes):
(display-color-cells):
(display-visual-class): Adjust for new window system `android'.

* lisp/image/wallpaper.el (x-open-connection): Add declaration.
* lisp/loadup.el (featurep): Load up files for Android.
* lisp/net/eww.el (eww-form-submit, eww-form-file)
(eww-form-checkbox, eww-form-select): Adjust faces for android.
* lisp/term/android-win.el: New file.
* src/Makefile.in: Add new targets emacs.so and android-emacs,
then adjust for cross compilation.
* src/alloc.c (cleanup_vector): Clean up Android font entities
as well.
(garbage_collect): Mark androidterm.
* src/android-emacs.c (main):
* src/android.c (ANDROID_THROW, enum android_fd_table_entry_flags)
(struct android_emacs_service, struct android_emacs_pixmap)
(struct android_graphics_point, struct android_event_container)
(struct android_event_queue, android_run_select_thread)
(android_handle_sigusr1, android_init_events, android_pending)
(android_next_event, android_write_event, android_select)
(android_run_debug_thread, android_user_full_name)
(android_get_asset_name, android_fstat, android_fstatat)
(android_file_access_p, android_hack_asset_fd, android_open)
(android_close, JNICALL, android_init_emacs_service)
(android_init_emacs_pixmap, android_init_graphics_point)
(MAX_HANDLE, struct android_handle_entry, android_alloc_id)
(android_destroy_handle, android_resolve_handle)
(android_resolve_handle2, android_change_window_attributes)
(android_create_window, android_set_window_background)
(android_destroy_window, android_init_android_rect_class)
(android_init_emacs_gc_class, android_create_gc, android_free_gc)
(android_change_gc, android_set_clip_rectangles)
(android_reparent_window, android_lookup_method)
(android_clear_window, android_map_window, android_unmap_window)
(android_resize_window, android_move_window, android_swap_buffers)
(android_get_gc_values, android_set_foreground)
(android_fill_rectangle, android_create_pixmap_from_bitmap_data)
(android_set_clip_mask, android_set_fill_style, android_copy_area)
(android_free_pixmap, android_set_background, android_fill_polygon)
(android_draw_rectangle, android_draw_point, android_draw_line)
(android_create_pixmap, android_set_ts_origin, android_clear_area):
* src/android.h (ANDROID_EXPORT):
* src/androidfns.c (android_display_info_for_name)
(check_android_display_info, check_x_display_info, gamma_correct)
(android_defined_color, android_decode_color)
(android_implicitly_set_name, android_explicitly_set_name)
(android_set_tool_bar_lines, android_change_tool_bar_height)
(android_set_tab_bar_lines, android_change_tab_bar_height)
(android_set_scroll_bar_default_height)
(android_set_scroll_bar_default_width, android_icon_verify)
(android_icon, android_make_gc, android_free_gcs)
(unwind_create_frame, do_unwind_create_frame)
(android_default_font_parameter, android_create_frame_window)
(Fx_create_frame, Fxw_color_defined_p, Fxw_color_values)
(Fxw_display_color_p, Fx_display_grayscale_p)
(Fx_display_pixel_width, Fx_display_pixel_height)
(Fx_display_planes, Fx_display_color_cells, Fx_display_screens)
(Fx_display_mm_width, Fx_display_mm_height)
(Fx_display_backing_store, Fx_display_visual_class)
(Fx_display_monitor_attributes_list, Fx_frame_geometry)
(Fx_frame_list_z_order, Fx_frame_restack)
(Fx_mouse_absolute_pixel_position)
(Fx_set_mouse_absolute_pixel_position, Fandroid_get_connection)
(Fx_display_list, Fx_show_tip, Fx_hide_tip)
(android_set_background_color, android_set_border_color)
(android_set_cursor_color, android_set_cursor_type)
(android_set_foreground_color)
(android_set_child_frame_border_width)
(android_set_internal_border_width, android_set_menu_bar_lines)
(android_set_mouse_color, android_set_title, android_set_alpha)
(android_frame_parm_handlers, syms_of_androidfns):
* src/androidfont.c (struct android_emacs_font_driver)
(struct android_emacs_font_spec, struct android_emacs_font_metrics)
(struct android_emacs_font_object, struct android_integer)
(struct androidfont_info, struct androidfont_entity)
(android_init_font_driver, android_init_font_spec)
(android_init_font_metrics, android_init_integer)
(android_init_font_object, androidfont_get_cache)
(androidfont_from_lisp, androidfont_from_java, androidfont_list)
(androidfont_match, androidfont_draw, androidfont_open_font)
(androidfont_close_font, androidfont_has_char)
(androidfont_encode_char, androidfont_text_extents)
(androidfont_list_family, androidfont_driver)
(syms_of_androidfont_for_pdumper, syms_of_androidfont)
(init_androidfont, android_finalize_font_entity):
* src/androidgui.h (_ANDROID_GUI_H_, struct android_rectangle)
(struct android_point, enum android_gc_function)
(enum android_gc_value_mask, enum android_fill_style)
(enum android_window_value_mask)
(struct android_set_window_attributes, struct android_gc_values)
(struct android_gc, enum android_swap_action, enum android_shape)
(enum android_coord_mode, struct android_swap_info)
(NativeRectangle, struct android_any_event)
(struct android_key_event, struct android_configure_event)
(union android_event):
* src/androidterm.c (android_window_to_frame, android_clear_frame)
(android_ring_bell, android_toggle_invisible_pointer)
(android_update_begin, android_update_end, show_back_buffer)
(android_flush_dirty_back_buffer_on, handle_one_android_event)
(android_read_socket, android_frame_up_to_date)
(android_buffer_flipping_unblocked_hook)
(android_query_frame_background_color, android_parse_color)
(android_alloc_nearest_color, android_query_colors)
(android_mouse_position, android_get_focus_frame)
(android_focus_frame, android_frame_rehighlight)
(android_frame_raise_lower, android_make_frame_visible)
(android_make_frame_invisible)
(android_make_frame_visible_invisible, android_fullscreen_hook)
(android_iconify_frame, android_set_window_size_1)
(android_set_window_size, android_set_offset, android_set_alpha)
(android_new_font, android_bitmap_icon, android_free_pixmap_hook)
(android_free_frame_resources, android_delete_frame)
(android_delete_terminal, android_scroll_run)
(android_after_update_window_line, android_flip_and_flush)
(android_clear_rectangle, android_reset_clip_rectangles)
(android_clip_to_row, android_draw_fringe_bitmap)
(android_set_cursor_gc, android_set_mouse_face_gc)
(android_set_mode_line_face_gc, android_set_glyph_string_gc)
(android_set_glyph_string_clipping)
(android_set_glyph_string_clipping_exactly)
(android_compute_glyph_string_overhangs)
(android_clear_glyph_string_rect)
(android_draw_glyph_string_background, android_fill_triangle)
(android_make_point, android_inside_rect_p, android_clear_point)
(android_draw_relief_rect, android_draw_box_rect)
(HIGHLIGHT_COLOR_DARK_BOOST_LIMIT, android_setup_relief_color)
(android_setup_relief_colors, android_draw_glyph_string_box)
(android_draw_glyph_string_bg_rect, android_draw_image_relief)
(android_draw_image_foreground, android_draw_image_foreground_1)
(android_draw_image_glyph_string)
(android_draw_stretch_glyph_string, android_draw_underwave)
(android_draw_glyph_string_foreground)
(android_draw_composite_glyph_string_foreground)
(android_draw_glyphless_glyph_string_foreground)
(android_draw_glyph_string, android_define_frame_cursor)
(android_clear_frame_area, android_clear_under_internal_border)
(android_draw_hollow_cursor, android_draw_bar_cursor)
(android_draw_window_cursor, android_draw_vertical_window_border)
(android_draw_window_divider, android_redisplay_interface)
(frame_set_mouse_pixel_position, get_keysym_name)
(android_create_terminal, android_term_init, syms_of_androidterm)
(mark_androidterm):
* src/androidterm.h (_ANDROID_TERM_H_, struct android_display_info)
(struct android_output, FRAME_ANDROID_OUTPUT, XSCROLL_BAR): New
files.
* src/dired.c (file_attributes): Do not use openat on Android.
* src/dispextern.h (No_Cursor): Define appropriately on Android.
(struct glyph_string, struct face): Make gc field of type struct
android_gc on Android.
* src/dispnew.c (clear_current_matrices, clear_desired_matrices)
(adjust_frame_glyphs_for_window_redisplay, free_glyphs)
(update_frame, scrolling, char_ins_del_cost, update_frame_line)
(init_display_interactive): Disable text terminal support
completely on Android.  Fix non-toolkit menus for non-X systems.
* src/editfns.c (Fuser_full_name): Call android_user_full_name.
* src/emacs.c (android_emacs_init): Make main this on Android.
Prohibit argv sorting from exceeding end of argv.
* src/epaths.in: Add path definitions for Android.

* src/fileio.c (file_access_p): Call android_file_access_p.
(file_name_directory): Avoid using openat on Android.
(Fcopy_file): Adjust to call sys_fstat instead.
(file_directory_p):
(Finsert_file_contents):
(write_region): Likewise.
* src/filelock.c:
* src/fns.c (Flocale_info): Pacify warning on Android.
* src/font.c (font_make_entity_android): New function.
* src/font.h:
* src/frame.c (Fframep):
(Fwindow_system): Handle new window system `android'.  Update doc strings.
(Fmake_terminal_frame): Disable on Android.
(gui_display_get_resource): Disable get_string_resource_hook on Android.
(syms_of_frame): New defsym `android'.

* src/frame.h (GCALIGNED_STRUCT): Add new output data for
Android.
(ENUM_BF): Expand enumerator size.
(FRAME_ANDROID_P, FRAME_WINDOW_P, MOUSE_HL_INFO): Add
definitions for Android.

* src/image.c (GET_PIXEL):
(image_create_bitmap_from_file):
(image_create_x_image_and_pixmap_1):
(image_get_x_image):
(slurp_file):
(lookup_rgb_color):
(image_to_emacs_colors):
(image_from_emacs_colors):
(image_pixmap_draw_cross):
(image_disable_image):
(MaskForeground):
(gif_load): Add stubs for Android.

* src/lisp.h:
* src/lread.c (safe_to_load_version, maybe_swap_for_eln1, openp):
* src/pdumper.c (pdumper_load): Call sys_fstat instead of fstat.
* src/process.c (wait_reading_process_output): Use
android_select instead of pselect.
* src/scroll.c: Disable on Android.
* src/sysdep.c (widen_foreground_group, reset_sys_modes)
(init_signals, emacs_fstatat, sys_fstat): New function.
(emacs_open, emacs_open_noquit, emacs_close): Implement
differently on Android.
(close_output_streams): Disable what is not required on Android.

* src/term.c (OUTPUT1_IF, encode_terminal_code, string_cost)
(string_cost_one_line, per_line_cost, calculate_costs)
(struct fkey_table, tty_append_glyph, produce_glyphs)
(tty_capable_p, Fsuspend_tty, Fresume_tty, device, init_tty)
(maybe_fatal, syms_of_term): Disable text terminal support on
Android.

* src/termhooks.h (enum output_method): Add android output
method.
(GCALIGNED_STRUCT, TERMINAL_FONT_CACHE): Define for Android.

* src/terminal.c (Fterminal_live_p): Implement for Android.

* src/verbose.mk.in (AM_V_GLOBALS): Add JAVAC and DX.
* src/xdisp.c (redisplay_internal): Disable text terminals on Android.
(display_menu_bar):
(display_tty_menu_item):
(draw_row_with_mouse_face):
(expose_frame): Make the non toolkit menu bar work on Android.

* src/xfaces.c (GCGraphicsExposures):
(x_create_gc):
(x_free_gc):
(Fx_load_color_file): Define for Android.

* xcompile/Makefile.in (top_srcdir):
(top_builddir):
* xcompile/README:
* xcompile/langinfo.h (nl_langinfo): New files.
2022-12-31 18:04:18 +08:00