diff options
| author | Po Lu | 2023-01-02 21:38:19 +0800 |
|---|---|---|
| committer | Po Lu | 2023-01-02 21:38:19 +0800 |
| commit | a32963e11f9f8e5d22b0d754d34a867f3b178ed2 (patch) | |
| tree | 898f12248beb2feb63ed4295f9de40c89053ae19 /src/androidgui.h | |
| parent | fd074f3133a348dd1d3b7ee569f0fc046223efb9 (diff) | |
| download | emacs-a32963e11f9f8e5d22b0d754d34a867f3b178ed2.tar.gz emacs-a32963e11f9f8e5d22b0d754d34a867f3b178ed2.zip | |
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.
Diffstat (limited to 'src/androidgui.h')
| -rw-r--r-- | src/androidgui.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/androidgui.h b/src/androidgui.h index 43ccc86e5c7..b0ea820cfdf 100644 --- a/src/androidgui.h +++ b/src/androidgui.h | |||
| @@ -201,6 +201,9 @@ enum android_event_type | |||
| 201 | ANDROID_KEY_PRESS, | 201 | ANDROID_KEY_PRESS, |
| 202 | ANDROID_KEY_RELEASE, | 202 | ANDROID_KEY_RELEASE, |
| 203 | ANDROID_CONFIGURE_NOTIFY, | 203 | ANDROID_CONFIGURE_NOTIFY, |
| 204 | ANDROID_FOCUS_IN, | ||
| 205 | ANDROID_FOCUS_OUT, | ||
| 206 | ANDROID_WINDOW_ACTION, | ||
| 204 | }; | 207 | }; |
| 205 | 208 | ||
| 206 | struct android_any_event | 209 | struct android_any_event |
| @@ -209,6 +212,13 @@ struct android_any_event | |||
| 209 | android_window window; | 212 | android_window window; |
| 210 | }; | 213 | }; |
| 211 | 214 | ||
| 215 | enum android_modifier_mask | ||
| 216 | { | ||
| 217 | ANDROID_SHIFT_MASK = 193, | ||
| 218 | ANDROID_CONTROL_MASK = 4096, | ||
| 219 | ANDROID_ALT_MASK = 2, | ||
| 220 | }; | ||
| 221 | |||
| 212 | struct android_key_event | 222 | struct android_key_event |
| 213 | { | 223 | { |
| 214 | enum android_event_type type; | 224 | enum android_event_type type; |
| @@ -216,8 +226,18 @@ struct android_key_event | |||
| 216 | android_time time; | 226 | android_time time; |
| 217 | unsigned int state; | 227 | unsigned int state; |
| 218 | unsigned int keycode; | 228 | unsigned int keycode; |
| 229 | unsigned int unicode_char; | ||
| 219 | }; | 230 | }; |
| 220 | 231 | ||
| 232 | /* These hard coded values are Android modifier keycodes derived | ||
| 233 | through experimentation. */ | ||
| 234 | |||
| 235 | #define ANDROID_IS_MODIFIER_KEY(key) \ | ||
| 236 | ((key) == 57 || (key) == 58 || (key) == 113 || (key) == 114 \ | ||
| 237 | || (key) == 119 || (key) == 117 || (key) == 118 || (key) == 78 \ | ||
| 238 | || (key) == 94 || (key) == 59 || (key) == 60 || (key) == 95 \ | ||
| 239 | || (key) == 63) | ||
| 240 | |||
| 221 | struct android_configure_event | 241 | struct android_configure_event |
| 222 | { | 242 | { |
| 223 | enum android_event_type type; | 243 | enum android_event_type type; |
| @@ -227,12 +247,35 @@ struct android_configure_event | |||
| 227 | int width, height; | 247 | int width, height; |
| 228 | }; | 248 | }; |
| 229 | 249 | ||
| 250 | struct android_focus_event | ||
| 251 | { | ||
| 252 | enum android_event_type type; | ||
| 253 | android_window window; | ||
| 254 | android_time time; | ||
| 255 | }; | ||
| 256 | |||
| 257 | struct android_window_action_event | ||
| 258 | { | ||
| 259 | enum android_event_type type; | ||
| 260 | |||
| 261 | /* The window handle. This can be ANDROID_NONE. */ | ||
| 262 | android_window window; | ||
| 263 | |||
| 264 | /* Numerical identifier for this action. If 0 and WINDOW is set, | ||
| 265 | then it means the frame associated with that window has been | ||
| 266 | destroyed. Otherwise, it means Emacs should create a new | ||
| 267 | frame. */ | ||
| 268 | unsigned int action; | ||
| 269 | }; | ||
| 270 | |||
| 230 | union android_event | 271 | union android_event |
| 231 | { | 272 | { |
| 232 | enum android_event_type type; | 273 | enum android_event_type type; |
| 233 | struct android_any_event xany; | 274 | struct android_any_event xany; |
| 234 | struct android_key_event xkey; | 275 | struct android_key_event xkey; |
| 235 | struct android_configure_event xconfigure; | 276 | struct android_configure_event xconfigure; |
| 277 | struct android_focus_event xfocus; | ||
| 278 | struct android_window_action_event xaction; | ||
| 236 | }; | 279 | }; |
| 237 | 280 | ||
| 238 | extern int android_pending (void); | 281 | extern int android_pending (void); |
| @@ -303,9 +346,47 @@ extern android_pixmap android_create_pixmap (unsigned int, unsigned int, | |||
| 303 | extern void android_set_ts_origin (struct android_gc *, int, int); | 346 | extern void android_set_ts_origin (struct android_gc *, int, int); |
| 304 | extern void android_clear_area (android_window, int, int, unsigned int, | 347 | extern void android_clear_area (android_window, int, int, unsigned int, |
| 305 | unsigned int); | 348 | unsigned int); |
| 349 | extern android_pixmap android_create_bitmap_from_data (char *, unsigned int, | ||
| 350 | unsigned int); | ||
| 306 | 351 | ||
| 307 | #endif | 352 | #endif |
| 308 | 353 | ||
| 354 | |||
| 355 | |||
| 356 | /* Image support. Keep the API as similar to XImage as possible. To | ||
| 357 | avoid leaving a huge mess of "#ifndef ANDROID_STUBIFY" in image.c, | ||
| 358 | stubs should be defined for all functions. */ | ||
| 359 | |||
| 360 | enum android_image_format | ||
| 361 | { | ||
| 362 | ANDROID_Z_PIXMAP, | ||
| 363 | }; | ||
| 364 | |||
| 365 | struct android_image | ||
| 366 | { | ||
| 367 | int width, height; | ||
| 368 | enum android_image_format format; | ||
| 369 | char *data; | ||
| 370 | int depth; | ||
| 371 | int bytes_per_line; | ||
| 372 | int bits_per_pixel; | ||
| 373 | }; | ||
| 374 | |||
| 375 | extern struct android_image *android_create_image (unsigned int, | ||
| 376 | enum android_image_format, | ||
| 377 | char *, unsigned int, | ||
| 378 | unsigned int); | ||
| 379 | extern void android_destroy_image (struct android_image *); | ||
| 380 | |||
| 381 | extern void android_put_pixel (struct android_image *, int, int, | ||
| 382 | unsigned long); | ||
| 383 | extern unsigned long android_get_pixel (struct android_image *, int, int); | ||
| 384 | extern struct android_image *android_get_image (android_drawable, | ||
| 385 | enum android_image_format); | ||
| 386 | extern void android_put_image (android_pixmap, struct android_image *); | ||
| 387 | |||
| 388 | |||
| 389 | |||
| 309 | /* X emulation stuff also needed while building stubs. */ | 390 | /* X emulation stuff also needed while building stubs. */ |
| 310 | 391 | ||
| 311 | extern struct android_gc *android_create_gc (enum android_gc_value_mask, | 392 | extern struct android_gc *android_create_gc (enum android_gc_value_mask, |