mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-12 22:40:46 -08:00
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.
This commit is contained in:
parent
fd074f3133
commit
a32963e11f
36 changed files with 2435 additions and 693 deletions
|
|
@ -32,6 +32,8 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
/* This defines a window, which is a handle. Windows represent a
|
||||
rectangular subset of the screen with their own contents.
|
||||
|
||||
|
|
@ -57,10 +59,10 @@ public class EmacsWindow extends EmacsHandleObject
|
|||
|
||||
/* List of all children in stacking order. This must be kept
|
||||
consistent! */
|
||||
private ArrayList<EmacsWindow> children;
|
||||
public ArrayList<EmacsWindow> children;
|
||||
|
||||
/* The EmacsActivity currently attached, if it exists. */
|
||||
private EmacsActivity attached;
|
||||
/* The window consumer currently attached, if it exists. */
|
||||
private EmacsWindowAttachmentManager.WindowConsumer attached;
|
||||
|
||||
/* The window background scratch GC. foreground is always the
|
||||
window background. */
|
||||
|
|
@ -74,35 +76,44 @@ public class EmacsWindow extends EmacsHandleObject
|
|||
|
||||
rect = new Rect (x, y, x + width, y + height);
|
||||
|
||||
/* Create the view from the context's UI thread. */
|
||||
view = EmacsService.SERVICE.getEmacsView (this);
|
||||
/* Create the view from the context's UI thread. The window is
|
||||
unmapped, so the view is GONE. */
|
||||
view = EmacsService.SERVICE.getEmacsView (this, View.GONE,
|
||||
parent == null);
|
||||
this.parent = parent;
|
||||
|
||||
/* Create the list of children. */
|
||||
children = new ArrayList<EmacsWindow> ();
|
||||
|
||||
/* The window is unmapped by default. */
|
||||
view.setVisibility (View.GONE);
|
||||
|
||||
/* If parent is the root window, notice that there are new
|
||||
children available for interested activites to pick up. */
|
||||
if (parent == null)
|
||||
EmacsService.SERVICE.noticeAvailableChild (this);
|
||||
else
|
||||
if (parent != null)
|
||||
{
|
||||
/* Otherwise, directly add this window as a child of that
|
||||
window's view. */
|
||||
synchronized (parent)
|
||||
{
|
||||
parent.children.add (this);
|
||||
parent.view.post (new Runnable () {
|
||||
@Override
|
||||
public void
|
||||
run ()
|
||||
{
|
||||
parent.view.addView (view);
|
||||
}
|
||||
});
|
||||
}
|
||||
parent.children.add (this);
|
||||
parent.view.post (new Runnable () {
|
||||
@Override
|
||||
public void
|
||||
run ()
|
||||
{
|
||||
parent.view.addView (view);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
EmacsService.SERVICE.runOnUiThread (new Runnable () {
|
||||
@Override
|
||||
public void
|
||||
run ()
|
||||
{
|
||||
EmacsWindowAttachmentManager manager;
|
||||
|
||||
manager = EmacsWindowAttachmentManager.MANAGER;
|
||||
|
||||
/* If parent is the root window, notice that there are new
|
||||
children available for interested activites to pick
|
||||
up. */
|
||||
|
||||
manager.registerWindow (EmacsWindow.this);
|
||||
}
|
||||
});
|
||||
|
||||
scratchGC = new EmacsGC ((short) 0);
|
||||
}
|
||||
|
|
@ -129,28 +140,35 @@ public class EmacsWindow extends EmacsHandleObject
|
|||
public void
|
||||
destroyHandle () throws IllegalStateException
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (!children.isEmpty ())
|
||||
throw new IllegalStateException ("Trying to destroy window with "
|
||||
+ "children!");
|
||||
}
|
||||
if (parent != null)
|
||||
parent.children.remove (this);
|
||||
|
||||
/* Notice that the child has been destroyed. */
|
||||
EmacsService.SERVICE.noticeChildDestroyed (this);
|
||||
EmacsActivity.invalidateFocus ();
|
||||
|
||||
if (!children.isEmpty ())
|
||||
throw new IllegalStateException ("Trying to destroy window with "
|
||||
+ "children!");
|
||||
|
||||
/* Remove the view from its parent and make it invisible. */
|
||||
view.post (new Runnable () {
|
||||
public void
|
||||
run ()
|
||||
{
|
||||
View parent;
|
||||
EmacsWindowAttachmentManager manager;
|
||||
|
||||
if (EmacsActivity.focusedWindow == EmacsWindow.this)
|
||||
EmacsActivity.focusedWindow = null;
|
||||
|
||||
manager = EmacsWindowAttachmentManager.MANAGER;
|
||||
view.setVisibility (View.GONE);
|
||||
|
||||
if (view.getParent () != null)
|
||||
((ViewGroup) view.getParent ()).removeView (view);
|
||||
parent = (View) view.getParent ();
|
||||
|
||||
if (attached != null)
|
||||
attached.makeAvailable ();
|
||||
if (parent != null && attached == null)
|
||||
((ViewGroup) parent).removeView (view);
|
||||
|
||||
manager.detachWindow (EmacsWindow.this);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -158,12 +176,15 @@ public class EmacsWindow extends EmacsHandleObject
|
|||
}
|
||||
|
||||
public void
|
||||
setActivity (EmacsActivity activity)
|
||||
setConsumer (EmacsWindowAttachmentManager.WindowConsumer consumer)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
activity = activity;
|
||||
}
|
||||
attached = consumer;
|
||||
}
|
||||
|
||||
public EmacsWindowAttachmentManager.WindowConsumer
|
||||
getAttachedConsumer ()
|
||||
{
|
||||
return attached;
|
||||
}
|
||||
|
||||
public void
|
||||
|
|
@ -233,7 +254,10 @@ public class EmacsWindow extends EmacsHandleObject
|
|||
public void
|
||||
run ()
|
||||
{
|
||||
|
||||
view.setVisibility (View.VISIBLE);
|
||||
/* Eventually this should check no-focus-on-map. */
|
||||
view.requestFocus ();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -319,18 +343,47 @@ public class EmacsWindow extends EmacsHandleObject
|
|||
public void
|
||||
onKeyDown (int keyCode, KeyEvent event)
|
||||
{
|
||||
int state;
|
||||
|
||||
state = event.getModifiers ();
|
||||
state &= ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK);
|
||||
|
||||
EmacsNative.sendKeyPress (this.handle,
|
||||
event.getEventTime (),
|
||||
event.getModifiers (),
|
||||
keyCode);
|
||||
keyCode,
|
||||
/* Ignore meta-state understood by Emacs
|
||||
for now, or Ctrl+C will not be
|
||||
recognized as an ASCII key press
|
||||
event. */
|
||||
event.getUnicodeChar (state));
|
||||
}
|
||||
|
||||
public void
|
||||
onKeyUp (int keyCode, KeyEvent event)
|
||||
{
|
||||
int state;
|
||||
|
||||
state = event.getModifiers ();
|
||||
state &= ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK);
|
||||
|
||||
EmacsNative.sendKeyRelease (this.handle,
|
||||
event.getEventTime (),
|
||||
event.getModifiers (),
|
||||
keyCode);
|
||||
keyCode,
|
||||
event.getUnicodeChar (state));
|
||||
}
|
||||
|
||||
public void
|
||||
onFocusChanged (boolean gainFocus)
|
||||
{
|
||||
EmacsActivity.invalidateFocus ();
|
||||
}
|
||||
|
||||
public void
|
||||
onActivityDetached ()
|
||||
{
|
||||
/* Destroy the associated frame when the activity is detached. */
|
||||
EmacsNative.sendWindowAction (this.handle, 0);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue