summaryrefslogtreecommitdiff
path: root/java/org/gnu/emacs/EmacsSurfaceView.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/org/gnu/emacs/EmacsSurfaceView.java')
-rw-r--r--java/org/gnu/emacs/EmacsSurfaceView.java83
1 files changed, 83 insertions, 0 deletions
diff --git a/java/org/gnu/emacs/EmacsSurfaceView.java b/java/org/gnu/emacs/EmacsSurfaceView.java
new file mode 100644
index 00000000000..194f6ad37a3
--- /dev/null
+++ b/java/org/gnu/emacs/EmacsSurfaceView.java
@@ -0,0 +1,83 @@
+/* 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.graphics.Canvas;
+import android.graphics.Rect;
+
+public class EmacsSurfaceView extends SurfaceView
+{
+ private boolean created;
+
+ public
+ EmacsSurfaceView (final EmacsView view)
+ {
+ super (view.getContext ());
+
+ getHolder ().addCallback (new SurfaceHolder.Callback () {
+ @Override
+ public void
+ surfaceChanged (SurfaceHolder holder, int format,
+ int width, int height)
+ {
+
+ }
+
+ @Override
+ public void
+ surfaceCreated (SurfaceHolder holder)
+ {
+ created = true;
+
+ /* Force a buffer swap now to get the contents of the Emacs
+ view on screen. */
+ view.swapBuffers ();
+ }
+
+ @Override
+ public void
+ surfaceDestroyed (SurfaceHolder holder)
+ {
+ created = false;
+ }
+ });
+ }
+
+ public boolean
+ isCreated ()
+ {
+ return created;
+ }
+
+ public Canvas
+ lockCanvas (Rect damage)
+ {
+ return getHolder ().lockCanvas (damage);
+ }
+
+ public void
+ unlockCanvasAndPost (Canvas canvas)
+ {
+ getHolder ().unlockCanvasAndPost (canvas);
+ }
+};