aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2023-03-06 11:25:51 +0800
committerPo Lu2023-03-06 11:25:51 +0800
commit97ca0a855116797779450bfb758ea6c706348df3 (patch)
treeac323afb4eb8a92f55f76d31ea89589de65fda9b
parent0dbbdd20f44c7757835a85a30763af18491f6eb1 (diff)
downloademacs-97ca0a855116797779450bfb758ea6c706348df3.tar.gz
emacs-97ca0a855116797779450bfb758ea6c706348df3.zip
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.
-rw-r--r--java/org/gnu/emacs/EmacsService.java19
-rw-r--r--java/org/gnu/emacs/EmacsView.java7
-rw-r--r--java/org/gnu/emacs/EmacsWindow.java7
-rw-r--r--src/android.c11
-rw-r--r--src/androidfns.c12
-rw-r--r--src/androidgui.h2
-rw-r--r--src/androidterm.c10
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
481 return String.valueOf (keysym); 481 return String.valueOf (keysym);
482 } 482 }
483 483
484 public void
485 sync ()
486 {
487 Runnable runnable;
488
489 runnable = new Runnable () {
490 public void
491 run ()
492 {
493 synchronized (this)
494 {
495 notify ();
496 }
497 }
498 };
499
500 syncRunnable (runnable);
501 }
502
503 484
504 485
505 /* Start the Emacs service if necessary. On Android 26 and up, 486 /* 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
168 = Bitmap.createBitmap (measuredWidth, 168 = Bitmap.createBitmap (measuredWidth,
169 measuredHeight, 169 measuredHeight,
170 Bitmap.Config.ARGB_8888); 170 Bitmap.Config.ARGB_8888);
171 bitmap.eraseColor (0xffffffff); 171 bitmap.eraseColor (window.background | 0xff000000);
172 172
173 /* And canvases. */ 173 /* And canvases. */
174 canvas = new Canvas (bitmap); 174 canvas = new Canvas (bitmap);
@@ -507,7 +507,10 @@ public final class EmacsView extends ViewGroup
507 synchronized (this) 507 synchronized (this)
508 { 508 {
509 /* Recycle the bitmap and call GC. */ 509 /* Recycle the bitmap and call GC. */
510 bitmap.recycle (); 510
511 if (bitmap != null)
512 bitmap.recycle ();
513
511 bitmap = null; 514 bitmap = null;
512 canvas = null; 515 canvas = null;
513 surfaceView.setBitmap (null, null); 516 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
129 /* Whether or not this window is fullscreen. */ 129 /* Whether or not this window is fullscreen. */
130 public boolean fullscreen; 130 public boolean fullscreen;
131 131
132 /* The window background pixel. This is used by EmacsView when
133 creating new bitmaps. */
134 public volatile int background;
135
132 public 136 public
133 EmacsWindow (short handle, final EmacsWindow parent, int x, int y, 137 EmacsWindow (short handle, final EmacsWindow parent, int x, int y,
134 int width, int height, boolean overrideRedirect) 138 int width, int height, boolean overrideRedirect)
@@ -183,6 +187,9 @@ public final class EmacsWindow extends EmacsHandleObject
183 /* scratchGC is used as the argument to a FillRectangles req. */ 187 /* scratchGC is used as the argument to a FillRectangles req. */
184 scratchGC.foreground = pixel; 188 scratchGC.foreground = pixel;
185 scratchGC.markDirty (false); 189 scratchGC.markDirty (false);
190
191 /* Make the background known to the view as well. */
192 background = pixel;
186 } 193 }
187 194
188 public Rect 195 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
104 jmethodID get_screen_height; 104 jmethodID get_screen_height;
105 jmethodID detect_mouse; 105 jmethodID detect_mouse;
106 jmethodID name_keysym; 106 jmethodID name_keysym;
107 jmethodID sync;
108 jmethodID browse_url; 107 jmethodID browse_url;
109 jmethodID restart_emacs; 108 jmethodID restart_emacs;
110 jmethodID update_ic; 109 jmethodID update_ic;
@@ -2122,7 +2121,6 @@ android_init_emacs_service (void)
2122 FIND_METHOD (get_screen_height, "getScreenHeight", "(Z)I"); 2121 FIND_METHOD (get_screen_height, "getScreenHeight", "(Z)I");
2123 FIND_METHOD (detect_mouse, "detectMouse", "()Z"); 2122 FIND_METHOD (detect_mouse, "detectMouse", "()Z");
2124 FIND_METHOD (name_keysym, "nameKeysym", "(I)Ljava/lang/String;"); 2123 FIND_METHOD (name_keysym, "nameKeysym", "(I)Ljava/lang/String;");
2125 FIND_METHOD (sync, "sync", "()V");
2126 FIND_METHOD (browse_url, "browseUrl", "(Ljava/lang/String;)" 2124 FIND_METHOD (browse_url, "browseUrl", "(Ljava/lang/String;)"
2127 "Ljava/lang/String;"); 2125 "Ljava/lang/String;");
2128 FIND_METHOD (restart_emacs, "restartEmacs", "()V"); 2126 FIND_METHOD (restart_emacs, "restartEmacs", "()V");
@@ -4514,15 +4512,6 @@ android_translate_coordinates (android_window src, int x,
4514 ANDROID_DELETE_LOCAL_REF (coordinates); 4512 ANDROID_DELETE_LOCAL_REF (coordinates);
4515} 4513}
4516 4514
4517void
4518android_sync (void)
4519{
4520 (*android_java_env)->CallVoidMethod (android_java_env,
4521 emacs_service,
4522 service_class.sync);
4523 android_exception_check ();
4524}
4525
4526int 4515int
4527android_wc_lookup_string (android_key_pressed_event *event, 4516android_wc_lookup_string (android_key_pressed_event *event,
4528 wchar_t *buffer_return, int wchars_buffer, 4517 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,
1883 unsigned long mask; 1883 unsigned long mask;
1884 1884
1885 block_input (); 1885 block_input ();
1886 mask = ANDROID_CW_OVERRIDE_REDIRECT; 1886 mask = ANDROID_CW_OVERRIDE_REDIRECT | ANDROID_CW_BACK_PIXEL;
1887 1887
1888 attrs.override_redirect = true; 1888 attrs.override_redirect = true;
1889 attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f);
1889 tip_window 1890 tip_window
1890 = FRAME_ANDROID_WINDOW (f) 1891 = FRAME_ANDROID_WINDOW (f)
1891 = android_create_window (FRAME_DISPLAY_INFO (f)->root_window, 1892 = 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,
2314 android_map_raised (FRAME_ANDROID_WINDOW (tip_f)); 2315 android_map_raised (FRAME_ANDROID_WINDOW (tip_f));
2315 unblock_input (); 2316 unblock_input ();
2316 2317
2317 /* Synchronize with the UI thread. This is required to prevent ugly
2318 black splotches. */
2319 android_sync ();
2320
2321 /* Garbage the tip frame too. */ 2318 /* Garbage the tip frame too. */
2322 SET_FRAME_GARBAGED (tip_f); 2319 SET_FRAME_GARBAGED (tip_f);
2323 2320
@@ -2328,6 +2325,11 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
2328 unbind_to (count_1, Qnil); 2325 unbind_to (count_1, Qnil);
2329 windows_or_buffers_changed = old_windows_or_buffers_changed; 2326 windows_or_buffers_changed = old_windows_or_buffers_changed;
2330 2327
2328 /* MapNotify events are not sent on Android, so make the frame
2329 visible. */
2330
2331 SET_FRAME_VISIBLE (tip_f, true);
2332
2331 start_timer: 2333 start_timer:
2332 /* Let the tip disappear after timeout seconds. */ 2334 /* Let the tip disappear after timeout seconds. */
2333 tip_timer = call3 (Qrun_at_time, timeout, Qnil, 2335 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,
606extern void android_map_raised (android_window); 606extern void android_map_raised (android_window);
607extern void android_translate_coordinates (android_window, int, 607extern void android_translate_coordinates (android_window, int,
608 int, int *, int *); 608 int, int *, int *);
609extern void android_sync (void);
610
611extern int android_wc_lookup_string (android_key_pressed_event *, 609extern int android_wc_lookup_string (android_key_pressed_event *,
612 wchar_t *, int, int *, 610 wchar_t *, int, int *,
613 enum android_lookup_status *); 611 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,
676 if (!f) 676 if (!f)
677 goto OTHER; 677 goto OTHER;
678 678
679 if (FRAME_TOOLTIP_P (f))
680 {
681 if (FRAME_PIXEL_HEIGHT (f) != configureEvent.xconfigure.height
682 || FRAME_PIXEL_WIDTH (f) != configureEvent.xconfigure.width)
683 SET_FRAME_GARBAGED (f);
684
685 FRAME_PIXEL_HEIGHT (f) = configureEvent.xconfigure.height;
686 FRAME_PIXEL_WIDTH (f) = configureEvent.xconfigure.width;
687 }
688
679 int width = configureEvent.xconfigure.width; 689 int width = configureEvent.xconfigure.width;
680 int height = configureEvent.xconfigure.height; 690 int height = configureEvent.xconfigure.height;
681 691