mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-20 20:07:36 +00:00
* .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.
189 lines
4.5 KiB
Java
189 lines
4.5 KiB
Java
/* Communication module for Android terminals. -*- c-file-style: "GNU" -*-
|
|
|
|
Copyright (C) 2023 Free Software Foundation, Inc.
|
|
|
|
This file is part of GNU Emacs.
|
|
|
|
GNU Emacs is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or (at
|
|
your option) any later version.
|
|
|
|
GNU Emacs is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|
|
|
package org.gnu.emacs;
|
|
|
|
import android.view.SurfaceView;
|
|
import android.view.SurfaceHolder;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Rect;
|
|
|
|
import android.util.Log;
|
|
|
|
public class EmacsSurfaceView extends SurfaceView
|
|
{
|
|
private static final String TAG = "EmacsSurfaceView";
|
|
public Object surfaceChangeLock;
|
|
private boolean created;
|
|
private EmacsView view;
|
|
|
|
/* This is the callback used on Android 8 to 25. */
|
|
|
|
private class Callback implements SurfaceHolder.Callback
|
|
{
|
|
@Override
|
|
public void
|
|
surfaceChanged (SurfaceHolder holder, int format,
|
|
int width, int height)
|
|
{
|
|
Log.d (TAG, "surfaceChanged: " + view + ", " + view.pendingConfigure);
|
|
|
|
/* Make sure not to swap buffers if there is pending
|
|
configuration, because otherwise the redraw callback will not
|
|
run correctly. */
|
|
|
|
if (view.pendingConfigure == 0)
|
|
view.swapBuffers ();
|
|
}
|
|
|
|
@Override
|
|
public void
|
|
surfaceCreated (SurfaceHolder holder)
|
|
{
|
|
synchronized (surfaceChangeLock)
|
|
{
|
|
Log.d (TAG, "surfaceCreated: " + view);
|
|
created = true;
|
|
}
|
|
|
|
/* Drop the lock when doing this, or a deadlock can
|
|
result. */
|
|
view.swapBuffers ();
|
|
}
|
|
|
|
@Override
|
|
public void
|
|
surfaceDestroyed (SurfaceHolder holder)
|
|
{
|
|
synchronized (surfaceChangeLock)
|
|
{
|
|
Log.d (TAG, "surfaceDestroyed: " + view);
|
|
created = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* And this is the callback used on Android 26 and later. It is
|
|
used because it can tell the system when drawing completes. */
|
|
|
|
private class Callback2 extends Callback implements SurfaceHolder.Callback2
|
|
{
|
|
@Override
|
|
public void
|
|
surfaceRedrawNeeded (SurfaceHolder holder)
|
|
{
|
|
/* This version is not supported. */
|
|
return;
|
|
}
|
|
|
|
@Override
|
|
public void
|
|
surfaceRedrawNeededAsync (SurfaceHolder holder,
|
|
Runnable drawingFinished)
|
|
{
|
|
Runnable old;
|
|
|
|
Log.d (TAG, "surfaceRedrawNeededAsync: " + view.pendingConfigure);
|
|
|
|
/* The system calls this function when it wants to know whether
|
|
or not Emacs is still configuring itself in response to a
|
|
resize.
|
|
|
|
If the view did not send an outstanding ConfigureNotify
|
|
event, then call drawingFinish immediately. Else, give it to
|
|
the view to execute after drawing completes. */
|
|
|
|
if (view.pendingConfigure == 0)
|
|
drawingFinished.run ();
|
|
else
|
|
/* And set this runnable to run once drawing completes. */
|
|
view.drawingFinished = drawingFinished;
|
|
}
|
|
}
|
|
|
|
public
|
|
EmacsSurfaceView (final EmacsView view)
|
|
{
|
|
super (view.getContext ());
|
|
|
|
this.surfaceChangeLock = new Object ();
|
|
this.view = view;
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
|
|
getHolder ().addCallback (new Callback ());
|
|
else
|
|
getHolder ().addCallback (new Callback2 ());
|
|
}
|
|
|
|
public boolean
|
|
isCreated ()
|
|
{
|
|
return created;
|
|
}
|
|
|
|
public Canvas
|
|
lockCanvas (Rect damage)
|
|
{
|
|
SurfaceHolder holder;
|
|
|
|
holder = getHolder ();
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
|
{
|
|
damage.setEmpty ();
|
|
return holder.lockHardwareCanvas ();
|
|
}
|
|
|
|
return holder.lockCanvas (damage);
|
|
}
|
|
|
|
@Override
|
|
protected void
|
|
onLayout (boolean changed, int left, int top, int right,
|
|
int bottom)
|
|
{
|
|
Log.d (TAG, ("onLayout: " + left + " " + top + " " + right
|
|
+ " " + bottom + " -- " + changed + " visibility "
|
|
+ getVisibility ()));
|
|
}
|
|
|
|
/* This method is only used during debugging when it seems damage
|
|
isn't working correctly. */
|
|
|
|
public Canvas
|
|
lockCanvas ()
|
|
{
|
|
SurfaceHolder holder;
|
|
|
|
holder = getHolder ();
|
|
return holder.lockCanvas ();
|
|
}
|
|
|
|
public void
|
|
unlockCanvasAndPost (Canvas canvas)
|
|
{
|
|
SurfaceHolder holder;
|
|
|
|
holder = getHolder ();
|
|
holder.unlockCanvasAndPost (canvas);
|
|
}
|
|
};
|