diff options
| author | Po Lu | 2024-02-18 12:48:41 +0800 |
|---|---|---|
| committer | Po Lu | 2024-02-18 12:48:41 +0800 |
| commit | c2d714886ef139f601d89463675b0d5b49d18ff9 (patch) | |
| tree | 7a4bc116a2816c61cdea438c692c178923071aa4 /java | |
| parent | bd0e281a6a27c048b12847811bc0385acbaa1eec (diff) | |
| download | emacs-c2d714886ef139f601d89463675b0d5b49d18ff9.tar.gz emacs-c2d714886ef139f601d89463675b0d5b49d18ff9.zip | |
Implement tooltip_reuse_hidden_frame for Android
* java/org/gnu/emacs/EmacsWindow.java
(findSuitableActivityContext): Return Activity rather than
Context.
(mapWindow): Provide window token manually.
* src/androidfns.c (Fx_show_tip, Fx_hide_tip): Respect
tooltip_reuse_hidden_frame.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsWindow.java | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index 978891ba619..427a1a92332 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java | |||
| @@ -27,6 +27,8 @@ import java.util.HashMap; | |||
| 27 | import java.util.LinkedHashMap; | 27 | import java.util.LinkedHashMap; |
| 28 | import java.util.Map; | 28 | import java.util.Map; |
| 29 | 29 | ||
| 30 | import android.app.Activity; | ||
| 31 | |||
| 30 | import android.content.ClipData; | 32 | import android.content.ClipData; |
| 31 | import android.content.ClipDescription; | 33 | import android.content.ClipDescription; |
| 32 | import android.content.Context; | 34 | import android.content.Context; |
| @@ -362,6 +364,9 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 362 | requestViewLayout (); | 364 | requestViewLayout (); |
| 363 | } | 365 | } |
| 364 | 366 | ||
| 367 | /* Return WM layout parameters for an override redirect window with | ||
| 368 | the geometry provided here. */ | ||
| 369 | |||
| 365 | private WindowManager.LayoutParams | 370 | private WindowManager.LayoutParams |
| 366 | getWindowLayoutParams () | 371 | getWindowLayoutParams () |
| 367 | { | 372 | { |
| @@ -384,15 +389,15 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 384 | return params; | 389 | return params; |
| 385 | } | 390 | } |
| 386 | 391 | ||
| 387 | private Context | 392 | private Activity |
| 388 | findSuitableActivityContext () | 393 | findSuitableActivityContext () |
| 389 | { | 394 | { |
| 390 | /* Find a recently focused activity. */ | 395 | /* Find a recently focused activity. */ |
| 391 | if (!EmacsActivity.focusedActivities.isEmpty ()) | 396 | if (!EmacsActivity.focusedActivities.isEmpty ()) |
| 392 | return EmacsActivity.focusedActivities.get (0); | 397 | return EmacsActivity.focusedActivities.get (0); |
| 393 | 398 | ||
| 394 | /* Return the service context, which probably won't work. */ | 399 | /* Resort to the last activity to be focused. */ |
| 395 | return EmacsService.SERVICE; | 400 | return EmacsActivity.lastFocusedActivity; |
| 396 | } | 401 | } |
| 397 | 402 | ||
| 398 | public synchronized void | 403 | public synchronized void |
| @@ -416,7 +421,7 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 416 | { | 421 | { |
| 417 | EmacsWindowAttachmentManager manager; | 422 | EmacsWindowAttachmentManager manager; |
| 418 | WindowManager windowManager; | 423 | WindowManager windowManager; |
| 419 | Context ctx; | 424 | Activity ctx; |
| 420 | Object tem; | 425 | Object tem; |
| 421 | WindowManager.LayoutParams params; | 426 | WindowManager.LayoutParams params; |
| 422 | 427 | ||
| @@ -447,11 +452,23 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 447 | activity using the system window manager. */ | 452 | activity using the system window manager. */ |
| 448 | 453 | ||
| 449 | ctx = findSuitableActivityContext (); | 454 | ctx = findSuitableActivityContext (); |
| 455 | |||
| 456 | if (ctx == null) | ||
| 457 | { | ||
| 458 | Log.w (TAG, "failed to attach override-redirect window" | ||
| 459 | + " for want of activity"); | ||
| 460 | return; | ||
| 461 | } | ||
| 462 | |||
| 450 | tem = ctx.getSystemService (Context.WINDOW_SERVICE); | 463 | tem = ctx.getSystemService (Context.WINDOW_SERVICE); |
| 451 | windowManager = (WindowManager) tem; | 464 | windowManager = (WindowManager) tem; |
| 452 | 465 | ||
| 453 | /* Calculate layout parameters. */ | 466 | /* Calculate layout parameters and propagate the |
| 467 | activity's token into it. */ | ||
| 468 | |||
| 454 | params = getWindowLayoutParams (); | 469 | params = getWindowLayoutParams (); |
| 470 | params.token = (ctx.findViewById (android.R.id.content) | ||
| 471 | .getWindowToken ()); | ||
| 455 | view.setLayoutParams (params); | 472 | view.setLayoutParams (params); |
| 456 | 473 | ||
| 457 | /* Attach the view. */ | 474 | /* Attach the view. */ |