diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsSurfaceView.java | 54 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsView.java | 58 |
2 files changed, 27 insertions, 85 deletions
diff --git a/java/org/gnu/emacs/EmacsSurfaceView.java b/java/org/gnu/emacs/EmacsSurfaceView.java index 2fe9e103b2b..f6cb77bb2b8 100644 --- a/java/org/gnu/emacs/EmacsSurfaceView.java +++ b/java/org/gnu/emacs/EmacsSurfaceView.java | |||
| @@ -45,14 +45,11 @@ public class EmacsSurfaceView extends SurfaceView | |||
| 45 | surfaceChanged (SurfaceHolder holder, int format, | 45 | surfaceChanged (SurfaceHolder holder, int format, |
| 46 | int width, int height) | 46 | int width, int height) |
| 47 | { | 47 | { |
| 48 | Log.d (TAG, "surfaceChanged: " + view + ", " + view.pendingConfigure); | 48 | Canvas canvas; |
| 49 | 49 | ||
| 50 | /* Make sure not to swap buffers if there is pending | 50 | Log.d (TAG, "surfaceChanged: " + view + ", "); |
| 51 | configuration, because otherwise the redraw callback will not | ||
| 52 | run correctly. */ | ||
| 53 | 51 | ||
| 54 | if (view.pendingConfigure == 0) | 52 | view.swapBuffers (true); |
| 55 | view.swapBuffers (); | ||
| 56 | } | 53 | } |
| 57 | 54 | ||
| 58 | @Override | 55 | @Override |
| @@ -67,7 +64,7 @@ public class EmacsSurfaceView extends SurfaceView | |||
| 67 | 64 | ||
| 68 | /* Drop the lock when doing this, or a deadlock can | 65 | /* Drop the lock when doing this, or a deadlock can |
| 69 | result. */ | 66 | result. */ |
| 70 | view.swapBuffers (); | 67 | view.swapBuffers (true); |
| 71 | } | 68 | } |
| 72 | 69 | ||
| 73 | @Override | 70 | @Override |
| @@ -82,44 +79,6 @@ public class EmacsSurfaceView extends SurfaceView | |||
| 82 | } | 79 | } |
| 83 | } | 80 | } |
| 84 | 81 | ||
| 85 | /* And this is the callback used on Android 26 and later. It is | ||
| 86 | used because it can tell the system when drawing completes. */ | ||
| 87 | |||
| 88 | private class Callback2 extends Callback implements SurfaceHolder.Callback2 | ||
| 89 | { | ||
| 90 | @Override | ||
| 91 | public void | ||
| 92 | surfaceRedrawNeeded (SurfaceHolder holder) | ||
| 93 | { | ||
| 94 | /* This version is not supported. */ | ||
| 95 | return; | ||
| 96 | } | ||
| 97 | |||
| 98 | @Override | ||
| 99 | public void | ||
| 100 | surfaceRedrawNeededAsync (SurfaceHolder holder, | ||
| 101 | Runnable drawingFinished) | ||
| 102 | { | ||
| 103 | Runnable old; | ||
| 104 | |||
| 105 | Log.d (TAG, "surfaceRedrawNeededAsync: " + view.pendingConfigure); | ||
| 106 | |||
| 107 | /* The system calls this function when it wants to know whether | ||
| 108 | or not Emacs is still configuring itself in response to a | ||
| 109 | resize. | ||
| 110 | |||
| 111 | If the view did not send an outstanding ConfigureNotify | ||
| 112 | event, then call drawingFinish immediately. Else, give it to | ||
| 113 | the view to execute after drawing completes. */ | ||
| 114 | |||
| 115 | if (view.pendingConfigure == 0) | ||
| 116 | drawingFinished.run (); | ||
| 117 | else | ||
| 118 | /* And set this runnable to run once drawing completes. */ | ||
| 119 | view.drawingFinished = drawingFinished; | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | public | 82 | public |
| 124 | EmacsSurfaceView (final EmacsView view) | 83 | EmacsSurfaceView (final EmacsView view) |
| 125 | { | 84 | { |
| @@ -128,10 +87,7 @@ public class EmacsSurfaceView extends SurfaceView | |||
| 128 | this.surfaceChangeLock = new Object (); | 87 | this.surfaceChangeLock = new Object (); |
| 129 | this.view = view; | 88 | this.view = view; |
| 130 | 89 | ||
| 131 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) | 90 | getHolder ().addCallback (new Callback ()); |
| 132 | getHolder ().addCallback (new Callback ()); | ||
| 133 | else | ||
| 134 | getHolder ().addCallback (new Callback2 ()); | ||
| 135 | } | 91 | } |
| 136 | 92 | ||
| 137 | public boolean | 93 | public boolean |
diff --git a/java/org/gnu/emacs/EmacsView.java b/java/org/gnu/emacs/EmacsView.java index 873124c86d1..fac11870ebf 100644 --- a/java/org/gnu/emacs/EmacsView.java +++ b/java/org/gnu/emacs/EmacsView.java | |||
| @@ -96,13 +96,6 @@ public class EmacsView extends ViewGroup | |||
| 96 | /* The InputMethodManager for this view's context. */ | 96 | /* The InputMethodManager for this view's context. */ |
| 97 | private InputMethodManager imManager; | 97 | private InputMethodManager imManager; |
| 98 | 98 | ||
| 99 | /* Runnable that will run once drawing completes. */ | ||
| 100 | public Runnable drawingFinished; | ||
| 101 | |||
| 102 | /* Serial of the last ConfigureNotify event sent that Emacs has not | ||
| 103 | yet responded to. 0 if there is no such outstanding event. */ | ||
| 104 | public long pendingConfigure; | ||
| 105 | |||
| 106 | /* Whether or not this view is attached to a window. */ | 99 | /* Whether or not this view is attached to a window. */ |
| 107 | public boolean isAttachedToWindow; | 100 | public boolean isAttachedToWindow; |
| 108 | 101 | ||
| @@ -110,6 +103,14 @@ public class EmacsView extends ViewGroup | |||
| 110 | displayed whenever possible. */ | 103 | displayed whenever possible. */ |
| 111 | public boolean isCurrentlyTextEditor; | 104 | public boolean isCurrentlyTextEditor; |
| 112 | 105 | ||
| 106 | /* An empty rectangle. */ | ||
| 107 | public static final Rect emptyRect; | ||
| 108 | |||
| 109 | static | ||
| 110 | { | ||
| 111 | emptyRect = new Rect (); | ||
| 112 | }; | ||
| 113 | |||
| 113 | public | 114 | public |
| 114 | EmacsView (EmacsWindow window) | 115 | EmacsView (EmacsWindow window) |
| 115 | { | 116 | { |
| @@ -286,16 +287,10 @@ public class EmacsView extends ViewGroup | |||
| 286 | int count, i; | 287 | int count, i; |
| 287 | View child; | 288 | View child; |
| 288 | Rect windowRect; | 289 | Rect windowRect; |
| 290 | int wantedWidth, wantedHeight; | ||
| 289 | 291 | ||
| 290 | count = getChildCount (); | 292 | count = getChildCount (); |
| 291 | 293 | ||
| 292 | if (changed || mustReportLayout) | ||
| 293 | { | ||
| 294 | mustReportLayout = false; | ||
| 295 | pendingConfigure | ||
| 296 | = window.viewLayout (left, top, right, bottom); | ||
| 297 | } | ||
| 298 | |||
| 299 | measuredWidth = right - left; | 294 | measuredWidth = right - left; |
| 300 | measuredHeight = bottom - top; | 295 | measuredHeight = bottom - top; |
| 301 | 296 | ||
| @@ -311,8 +306,6 @@ public class EmacsView extends ViewGroup | |||
| 311 | Log.d (TAG, "onLayout: " + child); | 306 | Log.d (TAG, "onLayout: " + child); |
| 312 | 307 | ||
| 313 | if (child == surfaceView) | 308 | if (child == surfaceView) |
| 314 | /* The child is the surface view, so give it the entire | ||
| 315 | view. */ | ||
| 316 | child.layout (0, 0, right - left, bottom - top); | 309 | child.layout (0, 0, right - left, bottom - top); |
| 317 | else if (child.getVisibility () != GONE) | 310 | else if (child.getVisibility () != GONE) |
| 318 | { | 311 | { |
| @@ -326,6 +319,14 @@ public class EmacsView extends ViewGroup | |||
| 326 | windowRect.right, windowRect.bottom); | 319 | windowRect.right, windowRect.bottom); |
| 327 | } | 320 | } |
| 328 | } | 321 | } |
| 322 | |||
| 323 | /* Now report the layout change to the window. */ | ||
| 324 | |||
| 325 | if (changed || mustReportLayout) | ||
| 326 | { | ||
| 327 | mustReportLayout = false; | ||
| 328 | window.viewLayout (left, top, right, bottom); | ||
| 329 | } | ||
| 329 | } | 330 | } |
| 330 | 331 | ||
| 331 | public void | 332 | public void |
| @@ -352,7 +353,7 @@ public class EmacsView extends ViewGroup | |||
| 352 | 353 | ||
| 353 | synchronized (damageRegion) | 354 | synchronized (damageRegion) |
| 354 | { | 355 | { |
| 355 | if (damageRegion.isEmpty ()) | 356 | if (!force && damageRegion.isEmpty ()) |
| 356 | return; | 357 | return; |
| 357 | 358 | ||
| 358 | bitmap = getBitmap (); | 359 | bitmap = getBitmap (); |
| @@ -363,7 +364,10 @@ public class EmacsView extends ViewGroup | |||
| 363 | 364 | ||
| 364 | synchronized (surfaceView.surfaceChangeLock) | 365 | synchronized (surfaceView.surfaceChangeLock) |
| 365 | { | 366 | { |
| 366 | damageRect = damageRegion.getBounds (); | 367 | if (!force) |
| 368 | damageRect = damageRegion.getBounds (); | ||
| 369 | else | ||
| 370 | damageRect = emptyRect; | ||
| 367 | 371 | ||
| 368 | if (!surfaceView.isCreated ()) | 372 | if (!surfaceView.isCreated ()) |
| 369 | return; | 373 | return; |
| @@ -612,24 +616,6 @@ public class EmacsView extends ViewGroup | |||
| 612 | isCurrentlyTextEditor = false; | 616 | isCurrentlyTextEditor = false; |
| 613 | } | 617 | } |
| 614 | 618 | ||
| 615 | public void | ||
| 616 | windowUpdated (long serial) | ||
| 617 | { | ||
| 618 | Log.d (TAG, "windowUpdated: serial is " + serial); | ||
| 619 | |||
| 620 | if (pendingConfigure <= serial | ||
| 621 | /* Detect wraparound. */ | ||
| 622 | || pendingConfigure - serial >= 0x7fffffff) | ||
| 623 | { | ||
| 624 | pendingConfigure = 0; | ||
| 625 | |||
| 626 | if (drawingFinished != null) | ||
| 627 | drawingFinished.run (); | ||
| 628 | |||
| 629 | drawingFinished = null; | ||
| 630 | } | ||
| 631 | } | ||
| 632 | |||
| 633 | @Override | 619 | @Override |
| 634 | public InputConnection | 620 | public InputConnection |
| 635 | onCreateInputConnection (EditorInfo info) | 621 | onCreateInputConnection (EditorInfo info) |