diff options
| author | Po Lu | 2024-05-13 14:40:15 +0800 |
|---|---|---|
| committer | Po Lu | 2024-05-13 14:42:35 +0800 |
| commit | 9443f8145e1db86664a4af318b3bd1448094040e (patch) | |
| tree | a7d2517b88a63dd40863233a8c88ff3dafec32ae /java | |
| parent | f560e759338e4cd43113fef39bb6e35c9e8a5893 (diff) | |
| download | emacs-9443f8145e1db86664a4af318b3bd1448094040e.tar.gz emacs-9443f8145e1db86664a4af318b3bd1448094040e.zip | |
Communicate frame titles to the window manager on Android
* java/org/gnu/emacs/EmacsActivity.java (detachWindow)
(attachWindow): Call updateWmName.
(updateWmName): New function; transfer wm name from the window
attached to the task's description.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow)
<wmName>: New field.
(setWmName): New function.
* src/android.c (android_init_emacs_window): Link to new
function.
(android_set_wm_name): New function.
* src/android.h (struct android_emacs_service): Delete unused
entries.
* src/androidfns.c (android_set_name_internal, android_set_name)
(android_implicitly_set_name, android_explicitly_set_name)
(android_set_title): Port from X.
* src/androidterm.c (android_term_init): Compute default frame
title.
* src/androidterm.h (struct android_display_info) <x_id_name>:
New field.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsActivity.java | 33 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsWindow.java | 37 |
2 files changed, 69 insertions, 1 deletions
diff --git a/java/org/gnu/emacs/EmacsActivity.java b/java/org/gnu/emacs/EmacsActivity.java index 118c3375ad5..7d02e4f4834 100644 --- a/java/org/gnu/emacs/EmacsActivity.java +++ b/java/org/gnu/emacs/EmacsActivity.java | |||
| @@ -27,6 +27,7 @@ import java.util.ArrayList; | |||
| 27 | import java.util.concurrent.TimeUnit; | 27 | import java.util.concurrent.TimeUnit; |
| 28 | 28 | ||
| 29 | import android.app.Activity; | 29 | import android.app.Activity; |
| 30 | import android.app.ActivityManager.TaskDescription; | ||
| 30 | 31 | ||
| 31 | import android.content.ContentResolver; | 32 | import android.content.ContentResolver; |
| 32 | import android.content.Context; | 33 | import android.content.Context; |
| @@ -166,6 +167,10 @@ public class EmacsActivity extends Activity | |||
| 166 | layout.removeView (window.view); | 167 | layout.removeView (window.view); |
| 167 | window = null; | 168 | window = null; |
| 168 | 169 | ||
| 170 | /* Reset the WM name. */ | ||
| 171 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) | ||
| 172 | updateWmName (); | ||
| 173 | |||
| 169 | invalidateFocus (0); | 174 | invalidateFocus (0); |
| 170 | } | 175 | } |
| 171 | } | 176 | } |
| @@ -205,6 +210,11 @@ public class EmacsActivity extends Activity | |||
| 205 | invalidateFocus (1); | 210 | invalidateFocus (1); |
| 206 | } | 211 | } |
| 207 | }); | 212 | }); |
| 213 | |||
| 214 | /* Synchronize the window's window manager name with this activity's | ||
| 215 | task in the recents list. */ | ||
| 216 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) | ||
| 217 | updateWmName (); | ||
| 208 | } | 218 | } |
| 209 | 219 | ||
| 210 | @Override | 220 | @Override |
| @@ -522,6 +532,29 @@ public class EmacsActivity extends Activity | |||
| 522 | } | 532 | } |
| 523 | } | 533 | } |
| 524 | 534 | ||
| 535 | /* Update the name of this activity's task description from the | ||
| 536 | current window, or reset the same if no window is attached. */ | ||
| 537 | |||
| 538 | @SuppressWarnings ("deprecation") | ||
| 539 | public final void | ||
| 540 | updateWmName () | ||
| 541 | { | ||
| 542 | String wmName; | ||
| 543 | TaskDescription description; | ||
| 544 | |||
| 545 | if (window == null || window.wmName == null) | ||
| 546 | wmName = "Emacs"; | ||
| 547 | else | ||
| 548 | wmName = window.wmName; | ||
| 549 | |||
| 550 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) | ||
| 551 | description = new TaskDescription (wmName); | ||
| 552 | else | ||
| 553 | description = (new TaskDescription.Builder () | ||
| 554 | .setLabel (wmName).build ()); | ||
| 555 | setTaskDescription (description); | ||
| 556 | } | ||
| 557 | |||
| 525 | @Override | 558 | @Override |
| 526 | public final void | 559 | public final void |
| 527 | onAttachedToWindow () | 560 | onAttachedToWindow () |
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index f8dd8518af0..483ba0dbced 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java | |||
| @@ -169,6 +169,11 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 169 | and whether this window has previously been attached to a task. */ | 169 | and whether this window has previously been attached to a task. */ |
| 170 | public boolean preserve, previouslyAttached; | 170 | public boolean preserve, previouslyAttached; |
| 171 | 171 | ||
| 172 | /* The window manager name of this window, which supplies the name of | ||
| 173 | activities in which it is displayed as a toplevel window, or | ||
| 174 | NULL. */ | ||
| 175 | public String wmName; | ||
| 176 | |||
| 172 | public | 177 | public |
| 173 | EmacsWindow (final EmacsWindow parent, int x, int y, | 178 | EmacsWindow (final EmacsWindow parent, int x, int y, |
| 174 | int width, int height, boolean overrideRedirect) | 179 | int width, int height, boolean overrideRedirect) |
| @@ -1562,6 +1567,36 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 1562 | return dontFocusOnMap; | 1567 | return dontFocusOnMap; |
| 1563 | } | 1568 | } |
| 1564 | 1569 | ||
| 1570 | public void | ||
| 1571 | setWmName (final String wmName) | ||
| 1572 | { | ||
| 1573 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) | ||
| 1574 | return; | ||
| 1575 | |||
| 1576 | EmacsService.SERVICE.runOnUiThread (new Runnable () { | ||
| 1577 | @Override | ||
| 1578 | public void | ||
| 1579 | run () | ||
| 1580 | { | ||
| 1581 | EmacsActivity activity; | ||
| 1582 | Object tem; | ||
| 1583 | |||
| 1584 | EmacsWindow.this.wmName = wmName; | ||
| 1585 | |||
| 1586 | /* If an activity is already attached, replace its task | ||
| 1587 | description. */ | ||
| 1588 | |||
| 1589 | tem = getAttachedConsumer (); | ||
| 1590 | |||
| 1591 | if (tem != null && tem instanceof EmacsActivity) | ||
| 1592 | { | ||
| 1593 | activity = (EmacsActivity) tem; | ||
| 1594 | activity.updateWmName (); | ||
| 1595 | } | ||
| 1596 | } | ||
| 1597 | }); | ||
| 1598 | } | ||
| 1599 | |||
| 1565 | public int[] | 1600 | public int[] |
| 1566 | translateCoordinates (int x, int y) | 1601 | translateCoordinates (int x, int y) |
| 1567 | { | 1602 | { |
| @@ -1631,7 +1666,7 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 1631 | fullscreen = isFullscreen; | 1666 | fullscreen = isFullscreen; |
| 1632 | tem = getAttachedConsumer (); | 1667 | tem = getAttachedConsumer (); |
| 1633 | 1668 | ||
| 1634 | if (tem != null) | 1669 | if (tem != null && tem instanceof EmacsActivity) |
| 1635 | { | 1670 | { |
| 1636 | activity = (EmacsActivity) tem; | 1671 | activity = (EmacsActivity) tem; |
| 1637 | activity.syncFullscreenWith (EmacsWindow.this); | 1672 | activity.syncFullscreenWith (EmacsWindow.this); |