diff options
| author | Po Lu | 2023-01-13 15:53:08 +0800 |
|---|---|---|
| committer | Po Lu | 2023-01-13 15:53:08 +0800 |
| commit | f9732131cf3c67e24db74a3d49f256d3c189a7e3 (patch) | |
| tree | e44e097c0c4c513390f58fa0020c8662943fbac6 /src/androidfns.c | |
| parent | 2fa5583d96fe78ff66d6fd41f18e54e4e20ea7d6 (diff) | |
| download | emacs-f9732131cf3c67e24db74a3d49f256d3c189a7e3.tar.gz emacs-f9732131cf3c67e24db74a3d49f256d3c189a7e3.zip | |
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.
Diffstat (limited to 'src/androidfns.c')
| -rw-r--r-- | src/androidfns.c | 471 |
1 files changed, 417 insertions, 54 deletions
diff --git a/src/androidfns.c b/src/androidfns.c index 96c2746a21a..459e407b901 100644 --- a/src/androidfns.c +++ b/src/androidfns.c | |||
| @@ -21,6 +21,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 21 | #include <math.h> | 21 | #include <math.h> |
| 22 | 22 | ||
| 23 | #include "lisp.h" | 23 | #include "lisp.h" |
| 24 | #include "android.h" | ||
| 24 | #include "androidterm.h" | 25 | #include "androidterm.h" |
| 25 | #include "blockinput.h" | 26 | #include "blockinput.h" |
| 26 | #include "keyboard.h" | 27 | #include "keyboard.h" |
| @@ -151,6 +152,36 @@ android_decode_color (struct frame *f, Lisp_Object color_name, int mono_color) | |||
| 151 | signal_error ("Undefined color", color_name); | 152 | signal_error ("Undefined color", color_name); |
| 152 | } | 153 | } |
| 153 | 154 | ||
| 155 | static void | ||
| 156 | android_set_parent_frame (struct frame *f, Lisp_Object new_value, | ||
| 157 | Lisp_Object old_value) | ||
| 158 | { | ||
| 159 | struct frame *p; | ||
| 160 | |||
| 161 | p = NULL; | ||
| 162 | |||
| 163 | if (!NILP (new_value) | ||
| 164 | && (!FRAMEP (new_value) | ||
| 165 | || !FRAME_LIVE_P (p = XFRAME (new_value)) | ||
| 166 | || !FRAME_ANDROID_P (p))) | ||
| 167 | { | ||
| 168 | store_frame_param (f, Qparent_frame, old_value); | ||
| 169 | error ("Invalid specification of `parent-frame'"); | ||
| 170 | } | ||
| 171 | |||
| 172 | if (p != FRAME_PARENT_FRAME (f)) | ||
| 173 | { | ||
| 174 | block_input (); | ||
| 175 | android_reparent_window (FRAME_ANDROID_WINDOW (f), | ||
| 176 | (p ? FRAME_ANDROID_WINDOW (p) | ||
| 177 | : FRAME_DISPLAY_INFO (f)->root_window), | ||
| 178 | f->left_pos, f->top_pos); | ||
| 179 | unblock_input (); | ||
| 180 | |||
| 181 | fset_parent_frame (f, new_value); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 154 | void | 185 | void |
| 155 | android_implicitly_set_name (struct frame *f, Lisp_Object arg, | 186 | android_implicitly_set_name (struct frame *f, Lisp_Object arg, |
| 156 | Lisp_Object oldval) | 187 | Lisp_Object oldval) |
| @@ -531,9 +562,9 @@ android_default_font_parameter (struct frame *f, Lisp_Object parms) | |||
| 531 | if (! FONTP (font) && ! STRINGP (font)) | 562 | if (! FONTP (font) && ! STRINGP (font)) |
| 532 | { | 563 | { |
| 533 | const char *names[] = { | 564 | const char *names[] = { |
| 534 | "Droid Sans Mono", | 565 | "Droid Sans Mono-12", |
| 535 | "monospace", | 566 | "Monospace-12", |
| 536 | "DroidSansMono", | 567 | "DroidSansMono-12", |
| 537 | NULL | 568 | NULL |
| 538 | }; | 569 | }; |
| 539 | int i; | 570 | int i; |
| @@ -1119,8 +1150,7 @@ DEFUN ("x-display-pixel-width", Fx_display_pixel_width, | |||
| 1119 | error ("Android cross-compilation stub called!"); | 1150 | error ("Android cross-compilation stub called!"); |
| 1120 | return Qnil; | 1151 | return Qnil; |
| 1121 | #else | 1152 | #else |
| 1122 | error ("Not implemented"); | 1153 | return make_fixnum (android_get_screen_width ()); |
| 1123 | return Qnil; | ||
| 1124 | #endif | 1154 | #endif |
| 1125 | } | 1155 | } |
| 1126 | 1156 | ||
| @@ -1133,8 +1163,7 @@ DEFUN ("x-display-pixel-height", Fx_display_pixel_height, | |||
| 1133 | error ("Android cross-compilation stub called!"); | 1163 | error ("Android cross-compilation stub called!"); |
| 1134 | return Qnil; | 1164 | return Qnil; |
| 1135 | #else | 1165 | #else |
| 1136 | error ("Not implemented"); | 1166 | return make_fixnum (android_get_screen_height ()); |
| 1137 | return Qnil; | ||
| 1138 | #endif | 1167 | #endif |
| 1139 | } | 1168 | } |
| 1140 | 1169 | ||
| @@ -1185,8 +1214,7 @@ DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, | |||
| 1185 | error ("Android cross-compilation stub called!"); | 1214 | error ("Android cross-compilation stub called!"); |
| 1186 | return Qnil; | 1215 | return Qnil; |
| 1187 | #else | 1216 | #else |
| 1188 | error ("Not implemented"); | 1217 | return make_fixnum (android_get_mm_width ()); |
| 1189 | return Qnil; | ||
| 1190 | #endif | 1218 | #endif |
| 1191 | } | 1219 | } |
| 1192 | 1220 | ||
| @@ -1198,8 +1226,7 @@ DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, | |||
| 1198 | error ("Android cross-compilation stub called!"); | 1226 | error ("Android cross-compilation stub called!"); |
| 1199 | return Qnil; | 1227 | return Qnil; |
| 1200 | #else | 1228 | #else |
| 1201 | error ("Not implemented"); | 1229 | return make_fixnum (android_get_mm_height ()); |
| 1202 | return Qnil; | ||
| 1203 | #endif | 1230 | #endif |
| 1204 | } | 1231 | } |
| 1205 | 1232 | ||
| @@ -1225,77 +1252,373 @@ DEFUN ("x-display-visual-class", Fx_display_visual_class, | |||
| 1225 | return Qtrue_color; | 1252 | return Qtrue_color; |
| 1226 | } | 1253 | } |
| 1227 | 1254 | ||
| 1228 | DEFUN ("x-display-monitor-attributes-list", Fx_display_monitor_attributes_list, | 1255 | DEFUN ("android-display-monitor-attributes-list", |
| 1229 | Sx_display_monitor_attributes_list, | 1256 | Fandroid_display_monitor_attributes_list, |
| 1257 | Sandroid_display_monitor_attributes_list, | ||
| 1230 | 0, 1, 0, | 1258 | 0, 1, 0, |
| 1231 | doc: /* SKIP: real doc in xfns.c. */) | 1259 | doc: /* Return a list of physical monitor attributes on the X display TERMINAL. |
| 1260 | |||
| 1261 | The optional argument TERMINAL specifies which display to ask about. | ||
| 1262 | TERMINAL should be a terminal object, a frame or a display name (a string). | ||
| 1263 | If omitted or nil, that stands for the selected frame's display. | ||
| 1264 | |||
| 1265 | Internal use only, use `display-monitor-attributes-list' instead. */) | ||
| 1232 | (Lisp_Object terminal) | 1266 | (Lisp_Object terminal) |
| 1233 | { | 1267 | { |
| 1234 | #ifdef ANDROID_STUBIFY | 1268 | #ifdef ANDROID_STUBIFY |
| 1235 | error ("Android cross-compilation stub called!"); | 1269 | error ("Android cross-compilation stub called!"); |
| 1236 | return Qnil; | 1270 | return Qnil; |
| 1237 | #else | 1271 | #else |
| 1238 | error ("Not implemented"); | 1272 | struct MonitorInfo monitor; |
| 1239 | return Qnil; | 1273 | |
| 1274 | memset (&monitor, 0, sizeof monitor); | ||
| 1275 | monitor.geom.width = android_get_screen_width (); | ||
| 1276 | monitor.geom.height = android_get_screen_height (); | ||
| 1277 | monitor.mm_width = android_get_mm_width (); | ||
| 1278 | monitor.mm_height = android_get_mm_height (); | ||
| 1279 | monitor.work = monitor.geom; | ||
| 1280 | monitor.name = (char *) "Android device monitor"; | ||
| 1281 | |||
| 1282 | /* What to do about monitor_frames? */ | ||
| 1283 | return make_monitor_attribute_list (&monitor, 1, | ||
| 1284 | 0, Qnil, NULL); | ||
| 1240 | #endif | 1285 | #endif |
| 1241 | } | 1286 | } |
| 1242 | 1287 | ||
| 1243 | DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, | 1288 | #ifndef ANDROID_STUBIFY |
| 1244 | 0, 1, 0, doc: /* SKIP: real doc in xfns.c. */) | 1289 | |
| 1245 | (Lisp_Object terminal) | 1290 | static Lisp_Object |
| 1291 | frame_geometry (Lisp_Object frame, Lisp_Object attribute) | ||
| 1292 | { | ||
| 1293 | struct frame *f = decode_live_frame (frame); | ||
| 1294 | android_window rootw; | ||
| 1295 | unsigned int native_width, native_height, x_border_width = 0; | ||
| 1296 | int x_native = 0, y_native = 0, xptr = 0, yptr = 0; | ||
| 1297 | int left_off = 0, right_off = 0, top_off = 0, bottom_off = 0; | ||
| 1298 | int outer_left, outer_top, outer_right, outer_bottom; | ||
| 1299 | int native_left, native_top, native_right, native_bottom; | ||
| 1300 | int inner_left, inner_top, inner_right, inner_bottom; | ||
| 1301 | int internal_border_width; | ||
| 1302 | bool menu_bar_external = false, tool_bar_external = false; | ||
| 1303 | int menu_bar_height = 0, menu_bar_width = 0; | ||
| 1304 | int tab_bar_height = 0, tab_bar_width = 0; | ||
| 1305 | int tool_bar_height = 0, tool_bar_width = 0; | ||
| 1306 | |||
| 1307 | if (FRAME_INITIAL_P (f) || !FRAME_ANDROID_P (f) | ||
| 1308 | || !FRAME_ANDROID_WINDOW (f)) | ||
| 1309 | return Qnil; | ||
| 1310 | |||
| 1311 | block_input (); | ||
| 1312 | android_get_geometry (FRAME_ANDROID_WINDOW (f), | ||
| 1313 | &rootw, &x_native, &y_native, | ||
| 1314 | &native_width, &native_height, &x_border_width); | ||
| 1315 | unblock_input (); | ||
| 1316 | |||
| 1317 | if (FRAME_PARENT_FRAME (f)) | ||
| 1318 | { | ||
| 1319 | Lisp_Object parent, edges; | ||
| 1320 | |||
| 1321 | XSETFRAME (parent, FRAME_PARENT_FRAME (f)); | ||
| 1322 | edges = Fandroid_frame_edges (parent, Qnative_edges); | ||
| 1323 | if (!NILP (edges)) | ||
| 1324 | { | ||
| 1325 | x_native += XFIXNUM (Fnth (make_fixnum (0), edges)); | ||
| 1326 | y_native += XFIXNUM (Fnth (make_fixnum (1), edges)); | ||
| 1327 | } | ||
| 1328 | |||
| 1329 | outer_left = x_native; | ||
| 1330 | outer_top = y_native; | ||
| 1331 | outer_right = outer_left + native_width + 2 * x_border_width; | ||
| 1332 | outer_bottom = outer_top + native_height + 2 * x_border_width; | ||
| 1333 | |||
| 1334 | native_left = x_native + x_border_width; | ||
| 1335 | native_top = y_native + x_border_width; | ||
| 1336 | native_right = native_left + native_width; | ||
| 1337 | native_bottom = native_top + native_height; | ||
| 1338 | } | ||
| 1339 | else | ||
| 1340 | { | ||
| 1341 | outer_left = xptr; | ||
| 1342 | outer_top = yptr; | ||
| 1343 | outer_right = outer_left + left_off + native_width + right_off; | ||
| 1344 | outer_bottom = outer_top + top_off + native_height + bottom_off; | ||
| 1345 | |||
| 1346 | native_left = outer_left + left_off; | ||
| 1347 | native_top = outer_top + top_off; | ||
| 1348 | native_right = native_left + native_width; | ||
| 1349 | native_bottom = native_top + native_height; | ||
| 1350 | } | ||
| 1351 | |||
| 1352 | internal_border_width = FRAME_INTERNAL_BORDER_WIDTH (f); | ||
| 1353 | inner_left = native_left + internal_border_width; | ||
| 1354 | inner_top = native_top + internal_border_width; | ||
| 1355 | inner_right = native_right - internal_border_width; | ||
| 1356 | inner_bottom = native_bottom - internal_border_width; | ||
| 1357 | |||
| 1358 | menu_bar_height = FRAME_MENU_BAR_HEIGHT (f); | ||
| 1359 | inner_top += menu_bar_height; | ||
| 1360 | menu_bar_width = menu_bar_height ? native_width : 0; | ||
| 1361 | |||
| 1362 | tab_bar_height = FRAME_TAB_BAR_HEIGHT (f); | ||
| 1363 | tab_bar_width = (tab_bar_height | ||
| 1364 | ? native_width - 2 * internal_border_width | ||
| 1365 | : 0); | ||
| 1366 | inner_top += tab_bar_height; | ||
| 1367 | |||
| 1368 | tool_bar_height = FRAME_TOOL_BAR_HEIGHT (f); | ||
| 1369 | tool_bar_width = (tool_bar_height | ||
| 1370 | ? native_width - 2 * internal_border_width | ||
| 1371 | : 0); | ||
| 1372 | inner_top += tool_bar_height; | ||
| 1373 | |||
| 1374 | /* Construct list. */ | ||
| 1375 | if (EQ (attribute, Qouter_edges)) | ||
| 1376 | return list4i (outer_left, outer_top, outer_right, outer_bottom); | ||
| 1377 | else if (EQ (attribute, Qnative_edges)) | ||
| 1378 | return list4i (native_left, native_top, native_right, native_bottom); | ||
| 1379 | else if (EQ (attribute, Qinner_edges)) | ||
| 1380 | return list4i (inner_left, inner_top, inner_right, inner_bottom); | ||
| 1381 | else | ||
| 1382 | return | ||
| 1383 | list (Fcons (Qouter_position, | ||
| 1384 | Fcons (make_fixnum (outer_left), | ||
| 1385 | make_fixnum (outer_top))), | ||
| 1386 | Fcons (Qouter_size, | ||
| 1387 | Fcons (make_fixnum (outer_right - outer_left), | ||
| 1388 | make_fixnum (outer_bottom - outer_top))), | ||
| 1389 | /* Approximate. */ | ||
| 1390 | Fcons (Qexternal_border_size, | ||
| 1391 | Fcons (make_fixnum (right_off), | ||
| 1392 | make_fixnum (bottom_off))), | ||
| 1393 | Fcons (Qouter_border_width, make_fixnum (x_border_width)), | ||
| 1394 | /* Approximate. */ | ||
| 1395 | Fcons (Qtitle_bar_size, | ||
| 1396 | Fcons (make_fixnum (0), | ||
| 1397 | make_fixnum (top_off - bottom_off))), | ||
| 1398 | Fcons (Qmenu_bar_external, menu_bar_external ? Qt : Qnil), | ||
| 1399 | Fcons (Qmenu_bar_size, | ||
| 1400 | Fcons (make_fixnum (menu_bar_width), | ||
| 1401 | make_fixnum (menu_bar_height))), | ||
| 1402 | Fcons (Qtab_bar_size, | ||
| 1403 | Fcons (make_fixnum (tab_bar_width), | ||
| 1404 | make_fixnum (tab_bar_height))), | ||
| 1405 | Fcons (Qtool_bar_external, tool_bar_external ? Qt : Qnil), | ||
| 1406 | Fcons (Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f)), | ||
| 1407 | Fcons (Qtool_bar_size, | ||
| 1408 | Fcons (make_fixnum (tool_bar_width), | ||
| 1409 | make_fixnum (tool_bar_height))), | ||
| 1410 | Fcons (Qinternal_border_width, | ||
| 1411 | make_fixnum (internal_border_width))); | ||
| 1412 | } | ||
| 1413 | |||
| 1414 | #endif | ||
| 1415 | |||
| 1416 | DEFUN ("android-frame-geometry", Fandroid_frame_geometry, | ||
| 1417 | Sandroid_frame_geometry, | ||
| 1418 | 0, 1, 0, | ||
| 1419 | doc: /* Return geometric attributes of FRAME. | ||
| 1420 | FRAME must be a live frame and defaults to the selected one. The return | ||
| 1421 | value is an association list of the attributes listed below. All height | ||
| 1422 | and width values are in pixels. | ||
| 1423 | |||
| 1424 | `outer-position' is a cons of the outer left and top edges of FRAME | ||
| 1425 | relative to the origin - the position (0, 0) - of FRAME's display. | ||
| 1426 | |||
| 1427 | `outer-size' is a cons of the outer width and height of FRAME. The | ||
| 1428 | outer size includes the title bar and the external borders as well as | ||
| 1429 | any menu and/or tool bar of frame. | ||
| 1430 | |||
| 1431 | `external-border-size' is a cons of the horizontal and vertical width of | ||
| 1432 | FRAME's external borders as supplied by the window manager. | ||
| 1433 | |||
| 1434 | `title-bar-size' is a cons of the width and height of the title bar of | ||
| 1435 | FRAME as supplied by the window manager. If both of them are zero, | ||
| 1436 | FRAME has no title bar. If only the width is zero, Emacs was not | ||
| 1437 | able to retrieve the width information. | ||
| 1438 | |||
| 1439 | `menu-bar-external', if non-nil, means the menu bar is external (never | ||
| 1440 | included in the inner edges of FRAME). | ||
| 1441 | |||
| 1442 | `menu-bar-size' is a cons of the width and height of the menu bar of | ||
| 1443 | FRAME. | ||
| 1444 | |||
| 1445 | `tool-bar-external', if non-nil, means the tool bar is external (never | ||
| 1446 | included in the inner edges of FRAME). | ||
| 1447 | |||
| 1448 | `tool-bar-position' tells on which side the tool bar on FRAME is and can | ||
| 1449 | be one of `left', `top', `right' or `bottom'. If this is nil, FRAME | ||
| 1450 | has no tool bar. | ||
| 1451 | |||
| 1452 | `tool-bar-size' is a cons of the width and height of the tool bar of | ||
| 1453 | FRAME. | ||
| 1454 | |||
| 1455 | `internal-border-width' is the width of the internal border of | ||
| 1456 | FRAME. */) | ||
| 1457 | (Lisp_Object frame) | ||
| 1246 | { | 1458 | { |
| 1247 | #ifdef ANDROID_STUBIFY | 1459 | #ifdef ANDROID_STUBIFY |
| 1248 | error ("Android cross-compilation stub called!"); | 1460 | error ("Android cross-compilation stub called!"); |
| 1249 | return Qnil; | 1461 | return Qnil; |
| 1250 | #else | 1462 | #else |
| 1251 | error ("Not implemented"); | 1463 | return frame_geometry (frame, Qnil); |
| 1464 | #endif | ||
| 1465 | } | ||
| 1466 | |||
| 1467 | DEFUN ("android-frame-edges", Fandroid_frame_edges, Sandroid_frame_edges, 0, 2, 0, | ||
| 1468 | doc: /* Return edge coordinates of FRAME. | ||
| 1469 | FRAME must be a live frame and defaults to the selected one. The return | ||
| 1470 | value is a list of the form (LEFT, TOP, RIGHT, BOTTOM). All values are | ||
| 1471 | in pixels relative to the origin - the position (0, 0) - of FRAME's | ||
| 1472 | display. | ||
| 1473 | |||
| 1474 | If optional argument TYPE is the symbol `outer-edges', return the outer | ||
| 1475 | edges of FRAME. The outer edges comprise the decorations of the window | ||
| 1476 | manager (like the title bar or external borders) as well as any external | ||
| 1477 | menu or tool bar of FRAME. If optional argument TYPE is the symbol | ||
| 1478 | `native-edges' or nil, return the native edges of FRAME. The native | ||
| 1479 | edges exclude the decorations of the window manager and any external | ||
| 1480 | menu or tool bar of FRAME. If TYPE is the symbol `inner-edges', return | ||
| 1481 | the inner edges of FRAME. These edges exclude title bar, any borders, | ||
| 1482 | menu bar or tool bar of FRAME. */) | ||
| 1483 | (Lisp_Object frame, Lisp_Object type) | ||
| 1484 | { | ||
| 1485 | #ifndef ANDROID_STUBIFY | ||
| 1486 | return frame_geometry (frame, ((EQ (type, Qouter_edges) | ||
| 1487 | || EQ (type, Qinner_edges)) | ||
| 1488 | ? type | ||
| 1489 | : Qnative_edges)); | ||
| 1490 | #else | ||
| 1252 | return Qnil; | 1491 | return Qnil; |
| 1253 | #endif | 1492 | #endif |
| 1254 | } | 1493 | } |
| 1255 | 1494 | ||
| 1256 | DEFUN ("x-frame-list-z-order", Fx_frame_list_z_order, | 1495 | #ifndef ANDROID_STUBIFY |
| 1257 | Sx_frame_list_z_order, 0, 1, 0, | 1496 | |
| 1258 | doc: /* SKIP: real doc in xfns.c. */) | 1497 | static Lisp_Object |
| 1498 | android_frame_list_z_order (struct android_display_info *dpyinfo, | ||
| 1499 | android_window window) | ||
| 1500 | { | ||
| 1501 | android_window root, parent, *children; | ||
| 1502 | unsigned int nchildren; | ||
| 1503 | unsigned long i; | ||
| 1504 | Lisp_Object frames; | ||
| 1505 | |||
| 1506 | frames = Qnil; | ||
| 1507 | |||
| 1508 | if (android_query_tree (window, &root, &parent, | ||
| 1509 | &children, &nchildren)) | ||
| 1510 | { | ||
| 1511 | for (i = 0; i < nchildren; i++) | ||
| 1512 | { | ||
| 1513 | Lisp_Object frame, tail; | ||
| 1514 | |||
| 1515 | FOR_EACH_FRAME (tail, frame) | ||
| 1516 | { | ||
| 1517 | struct frame *cf = XFRAME (frame); | ||
| 1518 | |||
| 1519 | if (FRAME_ANDROID_P (cf) | ||
| 1520 | && (FRAME_ANDROID_WINDOW (cf) == children[i])) | ||
| 1521 | frames = Fcons (frame, frames); | ||
| 1522 | } | ||
| 1523 | } | ||
| 1524 | |||
| 1525 | if (children) | ||
| 1526 | xfree (children); | ||
| 1527 | } | ||
| 1528 | |||
| 1529 | return frames; | ||
| 1530 | } | ||
| 1531 | |||
| 1532 | #endif | ||
| 1533 | |||
| 1534 | DEFUN ("android-frame-list-z-order", Fandroid_frame_list_z_order, | ||
| 1535 | Sandroid_frame_list_z_order, 0, 1, 0, | ||
| 1536 | doc: /* Return list of Emacs' frames, in Z (stacking) order. | ||
| 1537 | The optional argument TERMINAL specifies which display to ask about. | ||
| 1538 | TERMINAL should be either a frame or a display name (a string). If | ||
| 1539 | omitted or nil, that stands for the selected frame's display. Return | ||
| 1540 | nil if TERMINAL contains no Emacs frame. | ||
| 1541 | |||
| 1542 | As a special case, if TERMINAL is non-nil and specifies a live frame, | ||
| 1543 | return the child frames of that frame in Z (stacking) order. | ||
| 1544 | |||
| 1545 | Frames are listed from topmost (first) to bottommost (last). | ||
| 1546 | |||
| 1547 | On Android, the order of the frames returned is undefined unless | ||
| 1548 | TERMINAL is a frame. */) | ||
| 1259 | (Lisp_Object terminal) | 1549 | (Lisp_Object terminal) |
| 1260 | { | 1550 | { |
| 1261 | #ifdef ANDROID_STUBIFY | 1551 | #ifdef ANDROID_STUBIFY |
| 1262 | error ("Android cross-compilation stub called!"); | 1552 | error ("Android cross-compilation stub called!"); |
| 1263 | return Qnil; | 1553 | return Qnil; |
| 1264 | #else | 1554 | #else |
| 1265 | error ("Not implemented"); | 1555 | struct android_display_info *dpyinfo; |
| 1266 | return Qnil; | 1556 | android_window window; |
| 1557 | |||
| 1558 | dpyinfo = check_android_display_info (terminal); | ||
| 1559 | |||
| 1560 | if (FRAMEP (terminal) && FRAME_LIVE_P (XFRAME (terminal))) | ||
| 1561 | window = FRAME_ANDROID_WINDOW (XFRAME (terminal)); | ||
| 1562 | else | ||
| 1563 | window = dpyinfo->root_window; | ||
| 1564 | |||
| 1565 | return android_frame_list_z_order (dpyinfo, window); | ||
| 1267 | #endif | 1566 | #endif |
| 1268 | } | 1567 | } |
| 1269 | 1568 | ||
| 1270 | DEFUN ("x-frame-restack", Fx_frame_restack, Sx_frame_restack, 2, 3, 0, | 1569 | DEFUN ("android-frame-restack", Fandroid_frame_restack, |
| 1271 | doc: /* SKIP: real doc in xfns.c. */) | 1570 | Sandroid_frame_restack, 2, 3, 0, |
| 1571 | doc: /* Restack FRAME1 below FRAME2. | ||
| 1572 | This means that if both frames are visible and the display areas of | ||
| 1573 | these frames overlap, FRAME2 (partially) obscures FRAME1. If optional | ||
| 1574 | third argument ABOVE is non-nil, restack FRAME1 above FRAME2. This | ||
| 1575 | means that if both frames are visible and the display areas of these | ||
| 1576 | frames overlap, FRAME1 (partially) obscures FRAME2. | ||
| 1577 | |||
| 1578 | This may be thought of as an atomic action performed in two steps: The | ||
| 1579 | first step removes FRAME1's window-step window from the display. The | ||
| 1580 | second step reinserts FRAME1's window below (above if ABOVE is true) | ||
| 1581 | that of FRAME2. Hence the position of FRAME2 in its display's Z | ||
| 1582 | \(stacking) order relative to all other frames excluding FRAME1 remains | ||
| 1583 | unaltered. | ||
| 1584 | |||
| 1585 | The Android system refuses to restack windows, so this does not | ||
| 1586 | work. */) | ||
| 1272 | (Lisp_Object frame1, Lisp_Object frame2, Lisp_Object frame3) | 1587 | (Lisp_Object frame1, Lisp_Object frame2, Lisp_Object frame3) |
| 1273 | { | 1588 | { |
| 1274 | #ifdef ANDROID_STUBIFY | 1589 | #ifdef ANDROID_STUBIFY |
| 1275 | error ("Android cross-compilation stub called!"); | 1590 | error ("Android cross-compilation stub called!"); |
| 1276 | return Qnil; | 1591 | return Qnil; |
| 1277 | #else | 1592 | #else |
| 1278 | error ("Not implemented"); | 1593 | /* This is not supported on Android because of limitations in the |
| 1594 | platform that prevent ViewGroups from restacking | ||
| 1595 | SurfaceViews. */ | ||
| 1279 | return Qnil; | 1596 | return Qnil; |
| 1280 | #endif | 1597 | #endif |
| 1281 | } | 1598 | } |
| 1282 | 1599 | ||
| 1283 | DEFUN ("x-mouse-absolute-pixel-position", Fx_mouse_absolute_pixel_position, | 1600 | DEFUN ("android-mouse-absolute-pixel-position", |
| 1284 | Sx_mouse_absolute_pixel_position, 0, 0, 0, | 1601 | Fandroid_mouse_absolute_pixel_position, |
| 1285 | doc: /* SKIP: real doc in xfns.c. */) | 1602 | Sandroid_mouse_absolute_pixel_position, 0, 0, 0, |
| 1603 | doc: /* Return absolute position of mouse cursor in pixels. | ||
| 1604 | The position is returned as a cons cell (X . Y) of the coordinates of | ||
| 1605 | the mouse cursor position in pixels relative to a position (0, 0) of the | ||
| 1606 | selected frame's display. This does not work on Android. */) | ||
| 1286 | (void) | 1607 | (void) |
| 1287 | { | 1608 | { |
| 1288 | /* TODO: figure out how to implement this. */ | 1609 | /* This cannot be implemented on Android. */ |
| 1289 | return Qnil; | 1610 | return Qnil; |
| 1290 | } | 1611 | } |
| 1291 | 1612 | ||
| 1292 | DEFUN ("x-set-mouse-absolute-pixel-position", | 1613 | DEFUN ("android-set-mouse-absolute-pixel-position", |
| 1293 | Fx_set_mouse_absolute_pixel_position, | 1614 | Fandroid_set_mouse_absolute_pixel_position, |
| 1294 | Sx_set_mouse_absolute_pixel_position, 2, 2, 0, | 1615 | Sandroid_set_mouse_absolute_pixel_position, 2, 2, 0, |
| 1295 | doc: /* SKIP: real doc in xfns.c. */) | 1616 | doc: /* Move mouse pointer to a pixel position at (X, Y). The |
| 1617 | coordinates X and Y are interpreted to start from the top-left corner | ||
| 1618 | of the screen. This does not work on Android. */) | ||
| 1296 | (Lisp_Object x, Lisp_Object y) | 1619 | (Lisp_Object x, Lisp_Object y) |
| 1297 | { | 1620 | { |
| 1298 | /* TODO: figure out how to implement this. */ | 1621 | /* This cannot be implemented on Android. */ |
| 1299 | return Qnil; | 1622 | return Qnil; |
| 1300 | } | 1623 | } |
| 1301 | 1624 | ||
| @@ -1364,6 +1687,20 @@ DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0, | |||
| 1364 | #endif | 1687 | #endif |
| 1365 | } | 1688 | } |
| 1366 | 1689 | ||
| 1690 | DEFUN ("android-detect-mouse", Fandroid_detect_mouse, | ||
| 1691 | Sandroid_detect_mouse, 0, 0, 0, | ||
| 1692 | doc: /* Figure out whether or not there is a mouse. | ||
| 1693 | Return non-nil if a mouse is connected to this computer, and nil if | ||
| 1694 | there is no mouse. */) | ||
| 1695 | (void) | ||
| 1696 | { | ||
| 1697 | #ifndef ANDROID_STUBIFY | ||
| 1698 | return android_detect_mouse () ? Qt : Qnil; | ||
| 1699 | #else | ||
| 1700 | return Qnil; | ||
| 1701 | #endif | ||
| 1702 | } | ||
| 1703 | |||
| 1367 | 1704 | ||
| 1368 | 1705 | ||
| 1369 | #ifndef ANDROID_STUBIFY | 1706 | #ifndef ANDROID_STUBIFY |
| @@ -1579,7 +1916,7 @@ android_set_menu_bar_lines (struct frame *f, Lisp_Object value, | |||
| 1579 | y = FRAME_TOP_MARGIN_HEIGHT (f); | 1916 | y = FRAME_TOP_MARGIN_HEIGHT (f); |
| 1580 | 1917 | ||
| 1581 | block_input (); | 1918 | block_input (); |
| 1582 | android_clear_area (FRAME_ANDROID_WINDOW (f), | 1919 | android_clear_area (FRAME_ANDROID_DRAWABLE (f), |
| 1583 | 0, y, width, height); | 1920 | 0, y, width, height); |
| 1584 | unblock_input (); | 1921 | unblock_input (); |
| 1585 | } | 1922 | } |
| @@ -1590,7 +1927,7 @@ android_set_menu_bar_lines (struct frame *f, Lisp_Object value, | |||
| 1590 | height = nlines * FRAME_LINE_HEIGHT (f) - y; | 1927 | height = nlines * FRAME_LINE_HEIGHT (f) - y; |
| 1591 | 1928 | ||
| 1592 | block_input (); | 1929 | block_input (); |
| 1593 | android_clear_area (FRAME_ANDROID_WINDOW (f), 0, y, | 1930 | android_clear_area (FRAME_ANDROID_DRAWABLE (f), 0, y, |
| 1594 | width, height); | 1931 | width, height); |
| 1595 | unblock_input (); | 1932 | unblock_input (); |
| 1596 | } | 1933 | } |
| @@ -1682,6 +2019,30 @@ android_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 1682 | } | 2019 | } |
| 1683 | } | 2020 | } |
| 1684 | 2021 | ||
| 2022 | static void | ||
| 2023 | android_set_no_focus_on_map (struct frame *f, Lisp_Object new_value, | ||
| 2024 | Lisp_Object old_value) | ||
| 2025 | { | ||
| 2026 | if (!EQ (new_value, old_value)) | ||
| 2027 | { | ||
| 2028 | android_set_dont_focus_on_map (FRAME_ANDROID_WINDOW (f), | ||
| 2029 | new_value); | ||
| 2030 | FRAME_NO_FOCUS_ON_MAP (f) = !NILP (new_value); | ||
| 2031 | } | ||
| 2032 | } | ||
| 2033 | |||
| 2034 | static void | ||
| 2035 | android_set_no_accept_focus (struct frame *f, Lisp_Object new_value, | ||
| 2036 | Lisp_Object old_value) | ||
| 2037 | { | ||
| 2038 | if (!EQ (new_value, old_value)) | ||
| 2039 | { | ||
| 2040 | android_set_dont_accept_focus (FRAME_ANDROID_WINDOW (f), | ||
| 2041 | new_value); | ||
| 2042 | FRAME_NO_ACCEPT_FOCUS (f) = !NILP (new_value); | ||
| 2043 | } | ||
| 2044 | } | ||
| 2045 | |||
| 1685 | frame_parm_handler android_frame_parm_handlers[] = | 2046 | frame_parm_handler android_frame_parm_handlers[] = |
| 1686 | { | 2047 | { |
| 1687 | gui_set_autoraise, | 2048 | gui_set_autoraise, |
| @@ -1724,16 +2085,16 @@ frame_parm_handler android_frame_parm_handlers[] = | |||
| 1724 | NULL, | 2085 | NULL, |
| 1725 | NULL, | 2086 | NULL, |
| 1726 | NULL, | 2087 | NULL, |
| 1727 | NULL, /* x_set_undecorated, */ | 2088 | NULL, |
| 1728 | NULL, /* x_set_parent_frame, */ | 2089 | android_set_parent_frame, |
| 1729 | NULL, /* x_set_skip_taskbar, */ | 2090 | NULL, |
| 1730 | NULL, /* x_set_no_focus_on_map, */ | 2091 | android_set_no_focus_on_map, |
| 1731 | NULL, /* x_set_no_accept_focus, */ | 2092 | android_set_no_accept_focus, |
| 1732 | NULL, /* x_set_z_group, */ | 2093 | NULL, |
| 1733 | NULL, /* x_set_override_redirect, */ | 2094 | NULL, |
| 1734 | gui_set_no_special_glyphs, | 2095 | gui_set_no_special_glyphs, |
| 1735 | NULL, /* x_set_alpha_background, */ | 2096 | NULL, |
| 1736 | NULL, /* x_set_use_frame_synchronization, */ | 2097 | NULL, |
| 1737 | }; | 2098 | }; |
| 1738 | 2099 | ||
| 1739 | #endif | 2100 | #endif |
| @@ -1766,14 +2127,16 @@ syms_of_androidfns (void) | |||
| 1766 | defsubr (&Sx_display_mm_height); | 2127 | defsubr (&Sx_display_mm_height); |
| 1767 | defsubr (&Sx_display_backing_store); | 2128 | defsubr (&Sx_display_backing_store); |
| 1768 | defsubr (&Sx_display_visual_class); | 2129 | defsubr (&Sx_display_visual_class); |
| 1769 | defsubr (&Sx_display_monitor_attributes_list); | 2130 | defsubr (&Sandroid_display_monitor_attributes_list); |
| 1770 | defsubr (&Sx_frame_geometry); | 2131 | defsubr (&Sandroid_frame_geometry); |
| 1771 | defsubr (&Sx_frame_list_z_order); | 2132 | defsubr (&Sandroid_frame_edges); |
| 1772 | defsubr (&Sx_frame_restack); | 2133 | defsubr (&Sandroid_frame_list_z_order); |
| 1773 | defsubr (&Sx_mouse_absolute_pixel_position); | 2134 | defsubr (&Sandroid_frame_restack); |
| 1774 | defsubr (&Sx_set_mouse_absolute_pixel_position); | 2135 | defsubr (&Sandroid_mouse_absolute_pixel_position); |
| 2136 | defsubr (&Sandroid_set_mouse_absolute_pixel_position); | ||
| 1775 | defsubr (&Sandroid_get_connection); | 2137 | defsubr (&Sandroid_get_connection); |
| 1776 | defsubr (&Sx_display_list); | 2138 | defsubr (&Sx_display_list); |
| 1777 | defsubr (&Sx_show_tip); | 2139 | defsubr (&Sx_show_tip); |
| 1778 | defsubr (&Sx_hide_tip); | 2140 | defsubr (&Sx_hide_tip); |
| 2141 | defsubr (&Sandroid_detect_mouse); | ||
| 1779 | } | 2142 | } |