diff options
| author | Po Lu | 2023-08-28 13:08:22 +0800 |
|---|---|---|
| committer | Po Lu | 2023-08-28 13:08:22 +0800 |
| commit | 2134fd9f2767f6c0d14d3ad45cabcb963a06a8ed (patch) | |
| tree | 2f4a45293bbc5435ac3aef7baa2df66f0055a3eb /java | |
| parent | 967fa846fc7a83bbddf920cadd569490b837873c (diff) | |
| download | emacs-2134fd9f2767f6c0d14d3ad45cabcb963a06a8ed.tar.gz emacs-2134fd9f2767f6c0d14d3ad45cabcb963a06a8ed.zip | |
Update Android port
* java/org/gnu/emacs/EmacsActivity.java (attachWindow, onDestroy)
(onWindowFocusChanged, onContextMenuClosed):
* java/org/gnu/emacs/EmacsContextMenu.java (onMenuItemClick):
* java/org/gnu/emacs/EmacsDialog.java (onClick, display1, onDismiss):
* java/org/gnu/emacs/EmacsOpenActivity.java (checkReadableOrCopy)
(onDestroy, onWindowFocusChanged, onPause):
* java/org/gnu/emacs/EmacsWindowAttachmentManager.java
(registerWindow, removeWindowConsumer, detachWindow)
(noticeIconified, noticeDeiconified): Remove superfluous
debugging code now that the Android port is stable.
* java/org/gnu/emacs/EmacsView.java (onLayout): Detect if the
IME is hidden while a toplevel window is focused, and clear
isCurrentlyTextEditor in that case.
(onApplyWindowInsets): New function.
(raise, lower, popupMenu, onCreateInputConnection): Delete
aforementioned debugging code.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsActivity.java | 8 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsContextMenu.java | 4 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsDialog.java | 12 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsOpenActivity.java | 12 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsView.java | 95 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsWindowAttachmentManager.java | 24 |
6 files changed, 79 insertions, 76 deletions
diff --git a/java/org/gnu/emacs/EmacsActivity.java b/java/org/gnu/emacs/EmacsActivity.java index 4ddf51fbb20..cecd9c21d99 100644 --- a/java/org/gnu/emacs/EmacsActivity.java +++ b/java/org/gnu/emacs/EmacsActivity.java | |||
| @@ -149,8 +149,6 @@ public class EmacsActivity extends Activity | |||
| 149 | public final void | 149 | public final void |
| 150 | attachWindow (EmacsWindow child) | 150 | attachWindow (EmacsWindow child) |
| 151 | { | 151 | { |
| 152 | Log.d (TAG, "attachWindow: " + child); | ||
| 153 | |||
| 154 | if (window != null) | 152 | if (window != null) |
| 155 | throw new IllegalStateException ("trying to attach window when one" | 153 | throw new IllegalStateException ("trying to attach window when one" |
| 156 | + " already exists"); | 154 | + " already exists"); |
| @@ -257,7 +255,6 @@ public class EmacsActivity extends Activity | |||
| 257 | 255 | ||
| 258 | /* The activity will die shortly hereafter. If there is a window | 256 | /* The activity will die shortly hereafter. If there is a window |
| 259 | attached, close it now. */ | 257 | attached, close it now. */ |
| 260 | Log.d (TAG, "onDestroy " + this); | ||
| 261 | isMultitask = this instanceof EmacsMultitaskActivity; | 258 | isMultitask = this instanceof EmacsMultitaskActivity; |
| 262 | manager.removeWindowConsumer (this, isMultitask || isFinishing ()); | 259 | manager.removeWindowConsumer (this, isMultitask || isFinishing ()); |
| 263 | focusedActivities.remove (this); | 260 | focusedActivities.remove (this); |
| @@ -274,9 +271,6 @@ public class EmacsActivity extends Activity | |||
| 274 | public final void | 271 | public final void |
| 275 | onWindowFocusChanged (boolean isFocused) | 272 | onWindowFocusChanged (boolean isFocused) |
| 276 | { | 273 | { |
| 277 | Log.d (TAG, ("onWindowFocusChanged: " | ||
| 278 | + (isFocused ? "YES" : "NO"))); | ||
| 279 | |||
| 280 | if (isFocused && !focusedActivities.contains (this)) | 274 | if (isFocused && !focusedActivities.contains (this)) |
| 281 | { | 275 | { |
| 282 | focusedActivities.add (this); | 276 | focusedActivities.add (this); |
| @@ -323,8 +317,6 @@ public class EmacsActivity extends Activity | |||
| 323 | { | 317 | { |
| 324 | int serial; | 318 | int serial; |
| 325 | 319 | ||
| 326 | Log.d (TAG, "onContextMenuClosed: " + menu); | ||
| 327 | |||
| 328 | /* See the comment inside onMenuItemClick. */ | 320 | /* See the comment inside onMenuItemClick. */ |
| 329 | 321 | ||
| 330 | if (((EmacsContextMenu.wasSubmenuSelected == -2) | 322 | if (((EmacsContextMenu.wasSubmenuSelected == -2) |
diff --git a/java/org/gnu/emacs/EmacsContextMenu.java b/java/org/gnu/emacs/EmacsContextMenu.java index 46eddeeda3d..c5b87aa804a 100644 --- a/java/org/gnu/emacs/EmacsContextMenu.java +++ b/java/org/gnu/emacs/EmacsContextMenu.java | |||
| @@ -72,8 +72,6 @@ public final class EmacsContextMenu | |||
| 72 | public boolean | 72 | public boolean |
| 73 | onMenuItemClick (MenuItem item) | 73 | onMenuItemClick (MenuItem item) |
| 74 | { | 74 | { |
| 75 | Log.d (TAG, "onMenuItemClick: " + itemName + " (" + itemID + ")"); | ||
| 76 | |||
| 77 | if (subMenu != null) | 75 | if (subMenu != null) |
| 78 | { | 76 | { |
| 79 | /* Android 6.0 and earlier don't support nested submenus | 77 | /* Android 6.0 and earlier don't support nested submenus |
| @@ -81,8 +79,6 @@ public final class EmacsContextMenu | |||
| 81 | 79 | ||
| 82 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) | 80 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) |
| 83 | { | 81 | { |
| 84 | Log.d (TAG, "onMenuItemClick: displaying submenu " + subMenu); | ||
| 85 | |||
| 86 | /* Still set wasSubmenuSelected -- if not set, the | 82 | /* Still set wasSubmenuSelected -- if not set, the |
| 87 | dismissal of this context menu will result in a | 83 | dismissal of this context menu will result in a |
| 88 | context menu event being sent. */ | 84 | context menu event being sent. */ |
diff --git a/java/org/gnu/emacs/EmacsDialog.java b/java/org/gnu/emacs/EmacsDialog.java index 2291207fbcc..af3bf538410 100644 --- a/java/org/gnu/emacs/EmacsDialog.java +++ b/java/org/gnu/emacs/EmacsDialog.java | |||
| @@ -88,8 +88,6 @@ public final class EmacsDialog implements DialogInterface.OnDismissListener | |||
| 88 | public void | 88 | public void |
| 89 | onClick (View view) | 89 | onClick (View view) |
| 90 | { | 90 | { |
| 91 | Log.d (TAG, "onClicked " + this); | ||
| 92 | |||
| 93 | wasButtonClicked = true; | 91 | wasButtonClicked = true; |
| 94 | EmacsNative.sendContextMenu ((short) 0, id, menuEventSerial); | 92 | EmacsNative.sendContextMenu ((short) 0, id, menuEventSerial); |
| 95 | dismissDialog.dismiss (); | 93 | dismissDialog.dismiss (); |
| @@ -99,8 +97,6 @@ public final class EmacsDialog implements DialogInterface.OnDismissListener | |||
| 99 | public void | 97 | public void |
| 100 | onClick (DialogInterface dialog, int which) | 98 | onClick (DialogInterface dialog, int which) |
| 101 | { | 99 | { |
| 102 | Log.d (TAG, "onClicked " + this); | ||
| 103 | |||
| 104 | wasButtonClicked = true; | 100 | wasButtonClicked = true; |
| 105 | EmacsNative.sendContextMenu ((short) 0, id, menuEventSerial); | 101 | EmacsNative.sendContextMenu ((short) 0, id, menuEventSerial); |
| 106 | } | 102 | } |
| @@ -300,10 +296,6 @@ public final class EmacsDialog implements DialogInterface.OnDismissListener | |||
| 300 | work, then any focused EmacsOpenActivity, and finally the | 296 | work, then any focused EmacsOpenActivity, and finally the |
| 301 | last EmacsActivity to be focused. */ | 297 | last EmacsActivity to be focused. */ |
| 302 | 298 | ||
| 303 | Log.d (TAG, "display1: no focused activities..."); | ||
| 304 | Log.d (TAG, ("display1: EmacsOpenActivity.currentActivity: " | ||
| 305 | + EmacsOpenActivity.currentActivity)); | ||
| 306 | |||
| 307 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M | 299 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M |
| 308 | || Settings.canDrawOverlays (EmacsService.SERVICE)) | 300 | || Settings.canDrawOverlays (EmacsService.SERVICE)) |
| 309 | context = EmacsService.SERVICE; | 301 | context = EmacsService.SERVICE; |
| @@ -321,8 +313,6 @@ public final class EmacsDialog implements DialogInterface.OnDismissListener | |||
| 321 | consistently. */ | 313 | consistently. */ |
| 322 | context = EmacsActivity.focusedActivities.get (0); | 314 | context = EmacsActivity.focusedActivities.get (0); |
| 323 | 315 | ||
| 324 | Log.d (TAG, "display1: using context " + context); | ||
| 325 | |||
| 326 | dialog = dismissDialog = toAlertDialog (context); | 316 | dialog = dismissDialog = toAlertDialog (context); |
| 327 | 317 | ||
| 328 | try | 318 | try |
| @@ -418,8 +408,6 @@ public final class EmacsDialog implements DialogInterface.OnDismissListener | |||
| 418 | public void | 408 | public void |
| 419 | onDismiss (DialogInterface dialog) | 409 | onDismiss (DialogInterface dialog) |
| 420 | { | 410 | { |
| 421 | Log.d (TAG, "onDismiss: " + this); | ||
| 422 | |||
| 423 | if (wasButtonClicked) | 411 | if (wasButtonClicked) |
| 424 | return; | 412 | return; |
| 425 | 413 | ||
diff --git a/java/org/gnu/emacs/EmacsOpenActivity.java b/java/org/gnu/emacs/EmacsOpenActivity.java index 3832cd2faab..ea503ebd120 100644 --- a/java/org/gnu/emacs/EmacsOpenActivity.java +++ b/java/org/gnu/emacs/EmacsOpenActivity.java | |||
| @@ -232,19 +232,14 @@ public final class EmacsOpenActivity extends Activity | |||
| 232 | int read; | 232 | int read; |
| 233 | String content; | 233 | String content; |
| 234 | 234 | ||
| 235 | Log.d (TAG, "checkReadableOrCopy: " + file); | ||
| 236 | |||
| 237 | inFile = new File (file); | 235 | inFile = new File (file); |
| 238 | 236 | ||
| 239 | if (inFile.canRead ()) | 237 | if (inFile.canRead ()) |
| 240 | return file; | 238 | return file; |
| 241 | 239 | ||
| 242 | Log.d (TAG, "checkReadableOrCopy: NO"); | ||
| 243 | |||
| 244 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) | 240 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) |
| 245 | { | 241 | { |
| 246 | content = EmacsService.buildContentName (uri); | 242 | content = EmacsService.buildContentName (uri); |
| 247 | Log.d (TAG, "checkReadableOrCopy: " + content); | ||
| 248 | return content; | 243 | return content; |
| 249 | } | 244 | } |
| 250 | 245 | ||
| @@ -509,8 +504,6 @@ public final class EmacsOpenActivity extends Activity | |||
| 509 | public void | 504 | public void |
| 510 | onDestroy () | 505 | onDestroy () |
| 511 | { | 506 | { |
| 512 | Log.d (TAG, "onDestroy: " + this); | ||
| 513 | |||
| 514 | /* Clear `currentActivity' if it refers to the activity being | 507 | /* Clear `currentActivity' if it refers to the activity being |
| 515 | destroyed. */ | 508 | destroyed. */ |
| 516 | 509 | ||
| @@ -524,9 +517,6 @@ public final class EmacsOpenActivity extends Activity | |||
| 524 | public void | 517 | public void |
| 525 | onWindowFocusChanged (boolean isFocused) | 518 | onWindowFocusChanged (boolean isFocused) |
| 526 | { | 519 | { |
| 527 | Log.d (TAG, "onWindowFocusChanged: " + this + ", is now focused: " | ||
| 528 | + isFocused); | ||
| 529 | |||
| 530 | if (isFocused) | 520 | if (isFocused) |
| 531 | currentActivity = this; | 521 | currentActivity = this; |
| 532 | else if (currentActivity == this) | 522 | else if (currentActivity == this) |
| @@ -539,8 +529,6 @@ public final class EmacsOpenActivity extends Activity | |||
| 539 | public void | 529 | public void |
| 540 | onPause () | 530 | onPause () |
| 541 | { | 531 | { |
| 542 | Log.d (TAG, "onPause: " + this); | ||
| 543 | |||
| 544 | /* XXX: clear currentActivity here as well; I don't know whether | 532 | /* XXX: clear currentActivity here as well; I don't know whether |
| 545 | or not onWindowFocusChanged is always called prior to this. */ | 533 | or not onWindowFocusChanged is always called prior to this. */ |
| 546 | 534 | ||
diff --git a/java/org/gnu/emacs/EmacsView.java b/java/org/gnu/emacs/EmacsView.java index f964f096d88..5a4bcbaa005 100644 --- a/java/org/gnu/emacs/EmacsView.java +++ b/java/org/gnu/emacs/EmacsView.java | |||
| @@ -29,6 +29,7 @@ import android.view.KeyEvent; | |||
| 29 | import android.view.MotionEvent; | 29 | import android.view.MotionEvent; |
| 30 | import android.view.ViewGroup; | 30 | import android.view.ViewGroup; |
| 31 | import android.view.ViewTreeObserver; | 31 | import android.view.ViewTreeObserver; |
| 32 | import android.view.WindowInsets; | ||
| 32 | 33 | ||
| 33 | import android.view.inputmethod.EditorInfo; | 34 | import android.view.inputmethod.EditorInfo; |
| 34 | import android.view.inputmethod.InputConnection; | 35 | import android.view.inputmethod.InputConnection; |
| @@ -302,6 +303,26 @@ public final class EmacsView extends ViewGroup | |||
| 302 | super.setMeasuredDimension (width, height); | 303 | super.setMeasuredDimension (width, height); |
| 303 | } | 304 | } |
| 304 | 305 | ||
| 306 | /* Return whether this view's window is focused. This is made | ||
| 307 | necessary by Android 11's unreliable dispatch of | ||
| 308 | onWindowFocusChanged prior to gesture navigation away from a | ||
| 309 | frame. */ | ||
| 310 | |||
| 311 | public boolean | ||
| 312 | checkWindowFocus () | ||
| 313 | { | ||
| 314 | EmacsActivity activity; | ||
| 315 | Object consumer; | ||
| 316 | |||
| 317 | consumer = window.getAttachedConsumer (); | ||
| 318 | |||
| 319 | if (!(consumer instanceof EmacsActivity)) | ||
| 320 | return false; | ||
| 321 | |||
| 322 | activity = (EmacsActivity) consumer; | ||
| 323 | return activity.hasWindowFocus (); | ||
| 324 | } | ||
| 325 | |||
| 305 | /* Note that the monitor lock for the window must never be held from | 326 | /* Note that the monitor lock for the window must never be held from |
| 306 | within the lock for the view, because the window also locks the | 327 | within the lock for the view, because the window also locks the |
| 307 | other way around. */ | 328 | other way around. */ |
| @@ -315,6 +336,7 @@ public final class EmacsView extends ViewGroup | |||
| 315 | View child; | 336 | View child; |
| 316 | Rect windowRect; | 337 | Rect windowRect; |
| 317 | boolean needExpose; | 338 | boolean needExpose; |
| 339 | WindowInsets rootWindowInsets; | ||
| 318 | 340 | ||
| 319 | count = getChildCount (); | 341 | count = getChildCount (); |
| 320 | needExpose = false; | 342 | needExpose = false; |
| @@ -349,14 +371,37 @@ public final class EmacsView extends ViewGroup | |||
| 349 | if (right - left > oldMeasuredWidth | 371 | if (right - left > oldMeasuredWidth |
| 350 | || bottom - top > oldMeasuredHeight) | 372 | || bottom - top > oldMeasuredHeight) |
| 351 | needExpose = true; | 373 | needExpose = true; |
| 374 | |||
| 375 | /* This might return NULL if this view is not attached. */ | ||
| 376 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) | ||
| 377 | { | ||
| 378 | /* If a toplevel view is focused and isCurrentlyTextEditor | ||
| 379 | is enabled when the IME is hidden, clear | ||
| 380 | isCurrentlyTextEditor so it isn't shown again if the | ||
| 381 | user dismisses Emacs before returning. */ | ||
| 382 | rootWindowInsets = getRootWindowInsets (); | ||
| 383 | |||
| 384 | if (isCurrentlyTextEditor | ||
| 385 | && rootWindowInsets != null | ||
| 386 | && isAttachedToWindow | ||
| 387 | && !rootWindowInsets.isVisible (WindowInsets.Type.ime ()) | ||
| 388 | /* N.B. that the keyboard is dismissed during gesture | ||
| 389 | navigation under Android 30, but the system is | ||
| 390 | quite tempermental regarding whether the window is | ||
| 391 | focused at that point. Ideally | ||
| 392 | isCurrentlyTextEditor shouldn't be reset in that | ||
| 393 | case, but detecting that situation appears to be | ||
| 394 | impossible. Sigh. */ | ||
| 395 | && (window == EmacsActivity.focusedWindow | ||
| 396 | && hasWindowFocus ())) | ||
| 397 | isCurrentlyTextEditor = false; | ||
| 398 | } | ||
| 352 | } | 399 | } |
| 353 | 400 | ||
| 354 | for (i = 0; i < count; ++i) | 401 | for (i = 0; i < count; ++i) |
| 355 | { | 402 | { |
| 356 | child = getChildAt (i); | 403 | child = getChildAt (i); |
| 357 | 404 | ||
| 358 | Log.d (TAG, "onLayout: " + child); | ||
| 359 | |||
| 360 | if (child == surfaceView) | 405 | if (child == surfaceView) |
| 361 | child.layout (0, 0, right - left, bottom - top); | 406 | child.layout (0, 0, right - left, bottom - top); |
| 362 | else if (child.getVisibility () != GONE) | 407 | else if (child.getVisibility () != GONE) |
| @@ -491,6 +536,8 @@ public final class EmacsView extends ViewGroup | |||
| 491 | return window.onTouchEvent (motion); | 536 | return window.onTouchEvent (motion); |
| 492 | } | 537 | } |
| 493 | 538 | ||
| 539 | |||
| 540 | |||
| 494 | private void | 541 | private void |
| 495 | moveChildToBack (View child) | 542 | moveChildToBack (View child) |
| 496 | { | 543 | { |
| @@ -518,8 +565,6 @@ public final class EmacsView extends ViewGroup | |||
| 518 | 565 | ||
| 519 | parent = (EmacsView) getParent (); | 566 | parent = (EmacsView) getParent (); |
| 520 | 567 | ||
| 521 | Log.d (TAG, "raise: parent " + parent); | ||
| 522 | |||
| 523 | if (parent.indexOfChild (this) | 568 | if (parent.indexOfChild (this) |
| 524 | == parent.getChildCount () - 1) | 569 | == parent.getChildCount () - 1) |
| 525 | return; | 570 | return; |
| @@ -534,8 +579,6 @@ public final class EmacsView extends ViewGroup | |||
| 534 | 579 | ||
| 535 | parent = (EmacsView) getParent (); | 580 | parent = (EmacsView) getParent (); |
| 536 | 581 | ||
| 537 | Log.d (TAG, "lower: parent " + parent); | ||
| 538 | |||
| 539 | if (parent.indexOfChild (this) == 1) | 582 | if (parent.indexOfChild (this) == 1) |
| 540 | return; | 583 | return; |
| 541 | 584 | ||
| @@ -562,9 +605,6 @@ public final class EmacsView extends ViewGroup | |||
| 562 | contextMenu = menu; | 605 | contextMenu = menu; |
| 563 | popupActive = true; | 606 | popupActive = true; |
| 564 | 607 | ||
| 565 | Log.d (TAG, "popupMenu: " + menu + " @" + xPosition | ||
| 566 | + ", " + yPosition + " " + force); | ||
| 567 | |||
| 568 | /* Use showContextMenu (float, float) on N to get actual popup | 608 | /* Use showContextMenu (float, float) on N to get actual popup |
| 569 | behavior. */ | 609 | behavior. */ |
| 570 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) | 610 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) |
| @@ -700,14 +740,8 @@ public final class EmacsView extends ViewGroup | |||
| 700 | 740 | ||
| 701 | selection = EmacsService.viewGetSelection (window.handle); | 741 | selection = EmacsService.viewGetSelection (window.handle); |
| 702 | 742 | ||
| 703 | if (selection != null) | 743 | if (selection == null) |
| 704 | Log.d (TAG, "onCreateInputConnection: current selection is: " | ||
| 705 | + selection[0] + ", by " + selection[1]); | ||
| 706 | else | ||
| 707 | { | 744 | { |
| 708 | Log.d (TAG, "onCreateInputConnection: current selection could" | ||
| 709 | + " not be retrieved."); | ||
| 710 | |||
| 711 | /* If the selection could not be obtained, return 0 by 0. | 745 | /* If the selection could not be obtained, return 0 by 0. |
| 712 | However, ask for the selection position to be updated as | 746 | However, ask for the selection position to be updated as |
| 713 | soon as possible. */ | 747 | soon as possible. */ |
| @@ -780,4 +814,33 @@ public final class EmacsView extends ViewGroup | |||
| 780 | window.notifyContentRectPosition (locations[0], | 814 | window.notifyContentRectPosition (locations[0], |
| 781 | locations[1]); | 815 | locations[1]); |
| 782 | } | 816 | } |
| 817 | |||
| 818 | @Override | ||
| 819 | public WindowInsets | ||
| 820 | onApplyWindowInsets (WindowInsets insets) | ||
| 821 | { | ||
| 822 | WindowInsets rootWindowInsets; | ||
| 823 | |||
| 824 | /* This function is called when window insets change, which | ||
| 825 | encompasses input method visibility changes under Android 30 | ||
| 826 | and later. If a toplevel view is focused and | ||
| 827 | isCurrentlyTextEditor is enabled when the IME is hidden, clear | ||
| 828 | isCurrentlyTextEditor so it isn't shown again if the user | ||
| 829 | dismisses Emacs before returning. */ | ||
| 830 | |||
| 831 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) | ||
| 832 | return super.onApplyWindowInsets (insets); | ||
| 833 | |||
| 834 | /* This might return NULL if this view is not attached. */ | ||
| 835 | rootWindowInsets = getRootWindowInsets (); | ||
| 836 | |||
| 837 | if (isCurrentlyTextEditor | ||
| 838 | && rootWindowInsets != null | ||
| 839 | && isAttachedToWindow | ||
| 840 | && !rootWindowInsets.isVisible (WindowInsets.Type.ime ()) | ||
| 841 | && window == EmacsActivity.focusedWindow) | ||
| 842 | isCurrentlyTextEditor = false; | ||
| 843 | |||
| 844 | return super.onApplyWindowInsets (insets); | ||
| 845 | } | ||
| 783 | }; | 846 | }; |
diff --git a/java/org/gnu/emacs/EmacsWindowAttachmentManager.java b/java/org/gnu/emacs/EmacsWindowAttachmentManager.java index bc96de7fe1a..4ba5b35aacf 100644 --- a/java/org/gnu/emacs/EmacsWindowAttachmentManager.java +++ b/java/org/gnu/emacs/EmacsWindowAttachmentManager.java | |||
| @@ -87,21 +87,17 @@ public final class EmacsWindowAttachmentManager | |||
| 87 | public void | 87 | public void |
| 88 | registerWindowConsumer (WindowConsumer consumer) | 88 | registerWindowConsumer (WindowConsumer consumer) |
| 89 | { | 89 | { |
| 90 | Log.d (TAG, "registerWindowConsumer " + consumer); | ||
| 91 | |||
| 92 | consumers.add (consumer); | 90 | consumers.add (consumer); |
| 93 | 91 | ||
| 94 | for (EmacsWindow window : windows) | 92 | for (EmacsWindow window : windows) |
| 95 | { | 93 | { |
| 96 | if (window.getAttachedConsumer () == null) | 94 | if (window.getAttachedConsumer () == null) |
| 97 | { | 95 | { |
| 98 | Log.d (TAG, "registerWindowConsumer: attaching " + window); | ||
| 99 | consumer.attachWindow (window); | 96 | consumer.attachWindow (window); |
| 100 | return; | 97 | return; |
| 101 | } | 98 | } |
| 102 | } | 99 | } |
| 103 | 100 | ||
| 104 | Log.d (TAG, "registerWindowConsumer: sendWindowAction 0, 0"); | ||
| 105 | EmacsNative.sendWindowAction ((short) 0, 0); | 101 | EmacsNative.sendWindowAction ((short) 0, 0); |
| 106 | } | 102 | } |
| 107 | 103 | ||
| @@ -111,21 +107,16 @@ public final class EmacsWindowAttachmentManager | |||
| 111 | Intent intent; | 107 | Intent intent; |
| 112 | ActivityOptions options; | 108 | ActivityOptions options; |
| 113 | 109 | ||
| 114 | Log.d (TAG, "registerWindow (maybe): " + window); | ||
| 115 | |||
| 116 | if (windows.contains (window)) | 110 | if (windows.contains (window)) |
| 117 | /* The window is already registered. */ | 111 | /* The window is already registered. */ |
| 118 | return; | 112 | return; |
| 119 | 113 | ||
| 120 | Log.d (TAG, "registerWindow: " + window); | ||
| 121 | |||
| 122 | windows.add (window); | 114 | windows.add (window); |
| 123 | 115 | ||
| 124 | for (WindowConsumer consumer : consumers) | 116 | for (WindowConsumer consumer : consumers) |
| 125 | { | 117 | { |
| 126 | if (consumer.getAttachedWindow () == null) | 118 | if (consumer.getAttachedWindow () == null) |
| 127 | { | 119 | { |
| 128 | Log.d (TAG, "registerWindow: attaching " + consumer); | ||
| 129 | consumer.attachWindow (window); | 120 | consumer.attachWindow (window); |
| 130 | return; | 121 | return; |
| 131 | } | 122 | } |
| @@ -147,8 +138,6 @@ public final class EmacsWindowAttachmentManager | |||
| 147 | EmacsService.SERVICE.startActivity (intent, | 138 | EmacsService.SERVICE.startActivity (intent, |
| 148 | options.toBundle ()); | 139 | options.toBundle ()); |
| 149 | } | 140 | } |
| 150 | |||
| 151 | Log.d (TAG, "registerWindow: startActivity"); | ||
| 152 | } | 141 | } |
| 153 | 142 | ||
| 154 | public void | 143 | public void |
| @@ -156,19 +145,14 @@ public final class EmacsWindowAttachmentManager | |||
| 156 | { | 145 | { |
| 157 | EmacsWindow window; | 146 | EmacsWindow window; |
| 158 | 147 | ||
| 159 | Log.d (TAG, "removeWindowConsumer " + consumer); | ||
| 160 | |||
| 161 | window = consumer.getAttachedWindow (); | 148 | window = consumer.getAttachedWindow (); |
| 162 | 149 | ||
| 163 | if (window != null) | 150 | if (window != null) |
| 164 | { | 151 | { |
| 165 | Log.d (TAG, "removeWindowConsumer: detaching " + window); | ||
| 166 | |||
| 167 | consumer.detachWindow (); | 152 | consumer.detachWindow (); |
| 168 | window.onActivityDetached (isFinishing); | 153 | window.onActivityDetached (isFinishing); |
| 169 | } | 154 | } |
| 170 | 155 | ||
| 171 | Log.d (TAG, "removeWindowConsumer: removing " + consumer); | ||
| 172 | consumers.remove (consumer); | 156 | consumers.remove (consumer); |
| 173 | } | 157 | } |
| 174 | 158 | ||
| @@ -177,14 +161,10 @@ public final class EmacsWindowAttachmentManager | |||
| 177 | { | 161 | { |
| 178 | WindowConsumer consumer; | 162 | WindowConsumer consumer; |
| 179 | 163 | ||
| 180 | Log.d (TAG, "detachWindow " + window); | ||
| 181 | |||
| 182 | if (window.getAttachedConsumer () != null) | 164 | if (window.getAttachedConsumer () != null) |
| 183 | { | 165 | { |
| 184 | consumer = window.getAttachedConsumer (); | 166 | consumer = window.getAttachedConsumer (); |
| 185 | 167 | ||
| 186 | Log.d (TAG, "detachWindow: removing" + consumer); | ||
| 187 | |||
| 188 | consumers.remove (consumer); | 168 | consumers.remove (consumer); |
| 189 | consumer.destroy (); | 169 | consumer.destroy (); |
| 190 | } | 170 | } |
| @@ -197,8 +177,6 @@ public final class EmacsWindowAttachmentManager | |||
| 197 | { | 177 | { |
| 198 | EmacsWindow window; | 178 | EmacsWindow window; |
| 199 | 179 | ||
| 200 | Log.d (TAG, "noticeIconified " + consumer); | ||
| 201 | |||
| 202 | /* If a window is attached, send the appropriate iconification | 180 | /* If a window is attached, send the appropriate iconification |
| 203 | events. */ | 181 | events. */ |
| 204 | window = consumer.getAttachedWindow (); | 182 | window = consumer.getAttachedWindow (); |
| @@ -212,8 +190,6 @@ public final class EmacsWindowAttachmentManager | |||
| 212 | { | 190 | { |
| 213 | EmacsWindow window; | 191 | EmacsWindow window; |
| 214 | 192 | ||
| 215 | Log.d (TAG, "noticeDeiconified " + consumer); | ||
| 216 | |||
| 217 | /* If a window is attached, send the appropriate iconification | 193 | /* If a window is attached, send the appropriate iconification |
| 218 | events. */ | 194 | events. */ |
| 219 | window = consumer.getAttachedWindow (); | 195 | window = consumer.getAttachedWindow (); |