[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/android 97ca0a85511 1/2: Update Android port
From: |
Po Lu |
Subject: |
feature/android 97ca0a85511 1/2: Update Android port |
Date: |
Sun, 5 Mar 2023 22:46:39 -0500 (EST) |
branch: feature/android
commit 97ca0a855116797779450bfb758ea6c706348df3
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Update Android port
* java/org/gnu/emacs/EmacsService.java (sync): Delete function.
* java/org/gnu/emacs/EmacsView.java (handleDirtyBitmap): Erase
with window background.
(onDetachedFromWindow): Only recycle bitmap if non-NULL.
* java/org/gnu/emacs/EmacsWindow.java (background): New field.
(changeWindowBackground): Set it.
* src/android.c (struct android_emacs_service): Remove `sync'.
(android_init_emacs_service): Likewise.
(android_sync): Delete function.
* src/androidfns.c (android_create_tip_frame): Set frame
background color correctly.
(Fx_show_tip): Make the tip frame visible.
* src/androidgui.h: Update prototypes.
* src/androidterm.c (handle_one_android_event): Handle tooltip
movement correctly.
---
java/org/gnu/emacs/EmacsService.java | 19 -------------------
java/org/gnu/emacs/EmacsView.java | 7 +++++--
java/org/gnu/emacs/EmacsWindow.java | 7 +++++++
src/android.c | 11 -----------
src/androidfns.c | 12 +++++++-----
src/androidgui.h | 2 --
src/androidterm.c | 10 ++++++++++
7 files changed, 29 insertions(+), 39 deletions(-)
diff --git a/java/org/gnu/emacs/EmacsService.java
b/java/org/gnu/emacs/EmacsService.java
index d05ebce75dc..f99d7a40067 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -481,25 +481,6 @@ public final class EmacsService extends Service
return String.valueOf (keysym);
}
- public void
- sync ()
- {
- Runnable runnable;
-
- runnable = new Runnable () {
- public void
- run ()
- {
- synchronized (this)
- {
- notify ();
- }
- }
- };
-
- syncRunnable (runnable);
- }
-
/* Start the Emacs service if necessary. On Android 26 and up,
diff --git a/java/org/gnu/emacs/EmacsView.java
b/java/org/gnu/emacs/EmacsView.java
index aefc79c4fb7..f751eaaa3e4 100644
--- a/java/org/gnu/emacs/EmacsView.java
+++ b/java/org/gnu/emacs/EmacsView.java
@@ -168,7 +168,7 @@ public final class EmacsView extends ViewGroup
= Bitmap.createBitmap (measuredWidth,
measuredHeight,
Bitmap.Config.ARGB_8888);
- bitmap.eraseColor (0xffffffff);
+ bitmap.eraseColor (window.background | 0xff000000);
/* And canvases. */
canvas = new Canvas (bitmap);
@@ -507,7 +507,10 @@ public final class EmacsView extends ViewGroup
synchronized (this)
{
/* Recycle the bitmap and call GC. */
- bitmap.recycle ();
+
+ if (bitmap != null)
+ bitmap.recycle ();
+
bitmap = null;
canvas = null;
surfaceView.setBitmap (null, null);
diff --git a/java/org/gnu/emacs/EmacsWindow.java
b/java/org/gnu/emacs/EmacsWindow.java
index ffc7476f010..9d907d2b481 100644
--- a/java/org/gnu/emacs/EmacsWindow.java
+++ b/java/org/gnu/emacs/EmacsWindow.java
@@ -129,6 +129,10 @@ public final class EmacsWindow extends EmacsHandleObject
/* Whether or not this window is fullscreen. */
public boolean fullscreen;
+ /* The window background pixel. This is used by EmacsView when
+ creating new bitmaps. */
+ public volatile int background;
+
public
EmacsWindow (short handle, final EmacsWindow parent, int x, int y,
int width, int height, boolean overrideRedirect)
@@ -183,6 +187,9 @@ public final class EmacsWindow extends EmacsHandleObject
/* scratchGC is used as the argument to a FillRectangles req. */
scratchGC.foreground = pixel;
scratchGC.markDirty (false);
+
+ /* Make the background known to the view as well. */
+ background = pixel;
}
public Rect
diff --git a/src/android.c b/src/android.c
index 656971e154f..9fc4143602c 100644
--- a/src/android.c
+++ b/src/android.c
@@ -104,7 +104,6 @@ struct android_emacs_service
jmethodID get_screen_height;
jmethodID detect_mouse;
jmethodID name_keysym;
- jmethodID sync;
jmethodID browse_url;
jmethodID restart_emacs;
jmethodID update_ic;
@@ -2122,7 +2121,6 @@ android_init_emacs_service (void)
FIND_METHOD (get_screen_height, "getScreenHeight", "(Z)I");
FIND_METHOD (detect_mouse, "detectMouse", "()Z");
FIND_METHOD (name_keysym, "nameKeysym", "(I)Ljava/lang/String;");
- FIND_METHOD (sync, "sync", "()V");
FIND_METHOD (browse_url, "browseUrl", "(Ljava/lang/String;)"
"Ljava/lang/String;");
FIND_METHOD (restart_emacs, "restartEmacs", "()V");
@@ -4514,15 +4512,6 @@ android_translate_coordinates (android_window src, int x,
ANDROID_DELETE_LOCAL_REF (coordinates);
}
-void
-android_sync (void)
-{
- (*android_java_env)->CallVoidMethod (android_java_env,
- emacs_service,
- service_class.sync);
- android_exception_check ();
-}
-
int
android_wc_lookup_string (android_key_pressed_event *event,
wchar_t *buffer_return, int wchars_buffer,
diff --git a/src/androidfns.c b/src/androidfns.c
index 4837b00a21e..5a23e8bd196 100644
--- a/src/androidfns.c
+++ b/src/androidfns.c
@@ -1883,9 +1883,10 @@ android_create_tip_frame (struct android_display_info
*dpyinfo,
unsigned long mask;
block_input ();
- mask = ANDROID_CW_OVERRIDE_REDIRECT;
+ mask = ANDROID_CW_OVERRIDE_REDIRECT | ANDROID_CW_BACK_PIXEL;
attrs.override_redirect = true;
+ attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f);
tip_window
= FRAME_ANDROID_WINDOW (f)
= android_create_window (FRAME_DISPLAY_INFO (f)->root_window,
@@ -2314,10 +2315,6 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
android_map_raised (FRAME_ANDROID_WINDOW (tip_f));
unblock_input ();
- /* Synchronize with the UI thread. This is required to prevent ugly
- black splotches. */
- android_sync ();
-
/* Garbage the tip frame too. */
SET_FRAME_GARBAGED (tip_f);
@@ -2328,6 +2325,11 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
unbind_to (count_1, Qnil);
windows_or_buffers_changed = old_windows_or_buffers_changed;
+ /* MapNotify events are not sent on Android, so make the frame
+ visible. */
+
+ SET_FRAME_VISIBLE (tip_f, true);
+
start_timer:
/* Let the tip disappear after timeout seconds. */
tip_timer = call3 (Qrun_at_time, timeout, Qnil,
diff --git a/src/androidgui.h b/src/androidgui.h
index 84419457a8a..6514c78d289 100644
--- a/src/androidgui.h
+++ b/src/androidgui.h
@@ -606,8 +606,6 @@ extern void android_move_resize_window (android_window,
int, int,
extern void android_map_raised (android_window);
extern void android_translate_coordinates (android_window, int,
int, int *, int *);
-extern void android_sync (void);
-
extern int android_wc_lookup_string (android_key_pressed_event *,
wchar_t *, int, int *,
enum android_lookup_status *);
diff --git a/src/androidterm.c b/src/androidterm.c
index 814af87819b..a6709ac8169 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -676,6 +676,16 @@ handle_one_android_event (struct android_display_info
*dpyinfo,
if (!f)
goto OTHER;
+ if (FRAME_TOOLTIP_P (f))
+ {
+ if (FRAME_PIXEL_HEIGHT (f) != configureEvent.xconfigure.height
+ || FRAME_PIXEL_WIDTH (f) != configureEvent.xconfigure.width)
+ SET_FRAME_GARBAGED (f);
+
+ FRAME_PIXEL_HEIGHT (f) = configureEvent.xconfigure.height;
+ FRAME_PIXEL_WIDTH (f) = configureEvent.xconfigure.width;
+ }
+
int width = configureEvent.xconfigure.width;
int height = configureEvent.xconfigure.height;