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.
This commit is contained in:
Po Lu
2024-05-13 14:40:15 +08:00
parent f560e75933
commit 9443f8145e
7 changed files with 192 additions and 5 deletions

View File

@@ -169,6 +169,11 @@ public final class EmacsWindow extends EmacsHandleObject
and whether this window has previously been attached to a task. */
public boolean preserve, previouslyAttached;
/* The window manager name of this window, which supplies the name of
activities in which it is displayed as a toplevel window, or
NULL. */
public String wmName;
public
EmacsWindow (final EmacsWindow parent, int x, int y,
int width, int height, boolean overrideRedirect)
@@ -1562,6 +1567,36 @@ public final class EmacsWindow extends EmacsHandleObject
return dontFocusOnMap;
}
public void
setWmName (final String wmName)
{
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
return;
EmacsService.SERVICE.runOnUiThread (new Runnable () {
@Override
public void
run ()
{
EmacsActivity activity;
Object tem;
EmacsWindow.this.wmName = wmName;
/* If an activity is already attached, replace its task
description. */
tem = getAttachedConsumer ();
if (tem != null && tem instanceof EmacsActivity)
{
activity = (EmacsActivity) tem;
activity.updateWmName ();
}
}
});
}
public int[]
translateCoordinates (int x, int y)
{
@@ -1631,7 +1666,7 @@ public final class EmacsWindow extends EmacsHandleObject
fullscreen = isFullscreen;
tem = getAttachedConsumer ();
if (tem != null)
if (tem != null && tem instanceof EmacsActivity)
{
activity = (EmacsActivity) tem;
activity.syncFullscreenWith (EmacsWindow.this);