Skip to content

Commit 64c58c2

Browse files
committed
Merge pull request #107473 from m4gr3d/address_transparency_feedback
Address remaining feedback on Android background transparency
2 parents fc1e61a + 3ade4b4 commit 64c58c2

File tree

6 files changed

+14
-9
lines changed

6 files changed

+14
-9
lines changed

doc/classes/DisplayServer.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3074,7 +3074,8 @@
30743074
<constant name="WINDOW_FLAG_TRANSPARENT" value="3" enum="WindowFlags">
30753075
The window background can be transparent.
30763076
[b]Note:[/b] This flag has no effect if [method is_window_transparency_available] returns [code]false[/code].
3077-
[b]Note:[/b] Transparency support is implemented on Android, Linux (X11/Wayland), macOS, and Windows, but availability might vary depending on GPU driver, display manager, and compositor capabilities.
3077+
[b]Note:[/b] Transparency support is implemented on Linux (X11/Wayland), macOS, and Windows, but availability might vary depending on GPU driver, display manager, and compositor capabilities.
3078+
[b]Note:[/b] Transparency support is implemented on Android, but can only be enabled via [member ProjectSettings.display/window/per_pixel_transparency/allowed]. This flag has no effect on Android.
30783079
</constant>
30793080
<constant name="WINDOW_FLAG_NO_FOCUS" value="4" enum="WindowFlags">
30803081
The window can't be focused. No-focus window will ignore all input, except mouse clicks.

doc/classes/ProjectSettings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,7 @@
10161016
If [code]true[/code], enables a window manager hint that the main window background [i]can[/i] be transparent. This does not make the background actually transparent. For the background to be transparent, the root viewport must also be made transparent by enabling [member rendering/viewport/transparent_background].
10171017
[b]Note:[/b] To use a transparent splash screen, set [member application/boot_splash/bg_color] to [code]Color(0, 0, 0, 0)[/code].
10181018
[b]Note:[/b] This setting has no effect if [member display/window/per_pixel_transparency/allowed] is set to [code]false[/code].
1019+
[b]Note:[/b] This setting has no effect on Android as transparency is controlled only via [member display/window/per_pixel_transparency/allowed].
10191020
</member>
10201021
<member name="display/window/size/viewport_height" type="int" setter="" getter="" default="648">
10211022
Sets the game's main viewport height. On desktop platforms, this is also the initial window height, represented by an indigo-colored rectangle in the 2D editor. Stretch mode settings also use this as a reference when using the [code]canvas_items[/code] or [code]viewport[/code] stretch modes. See also [member display/window/size/viewport_width], [member display/window/size/window_width_override] and [member display/window/size/window_height_override].

platform/android/display_server_android.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ void DisplayServerAndroid::window_set_flag(DisplayServer::WindowFlags p_flag, bo
596596
}
597597

598598
bool DisplayServerAndroid::window_get_flag(DisplayServer::WindowFlags p_flag, DisplayServer::WindowID p_window) const {
599+
ERR_FAIL_COND_V(p_window != MAIN_WINDOW_ID, false);
599600
switch (p_flag) {
600601
case WindowFlags::WINDOW_FLAG_TRANSPARENT:
601602
return is_window_transparency_available();

platform/android/export/export_plugin.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ void EditorExportPlatformAndroid::_write_tmp_manifest(const Ref<EditorExportPres
10501050
store_string_at_path(manifest_path, manifest_text);
10511051
}
10521052

1053-
bool EditorExportPlatformAndroid::_should_be_transparent(const Ref<EditorExportPreset> &p_preset) const {
1053+
bool EditorExportPlatformAndroid::_is_transparency_allowed(const Ref<EditorExportPreset> &p_preset) const {
10541054
return (bool)get_project_setting(p_preset, "display/window/per_pixel_transparency/allowed");
10551055
}
10561056

@@ -1062,21 +1062,21 @@ void EditorExportPlatformAndroid::_fix_themes_xml(const Ref<EditorExportPreset>
10621062
return;
10631063
}
10641064

1065-
bool should_be_transparent = _should_be_transparent(p_preset);
1065+
bool transparency_allowed = _is_transparency_allowed(p_preset);
10661066

10671067
// Default/Reserved theme attributes.
10681068
Dictionary main_theme_attributes;
10691069
main_theme_attributes["android:windowSwipeToDismiss"] = bool_to_string(p_preset->get("gesture/swipe_to_dismiss"));
1070-
main_theme_attributes["android:windowIsTranslucent"] = bool_to_string(should_be_transparent);
1071-
if (should_be_transparent) {
1070+
main_theme_attributes["android:windowIsTranslucent"] = bool_to_string(transparency_allowed);
1071+
if (transparency_allowed) {
10721072
main_theme_attributes["android:windowBackground"] = "@android:color/transparent";
10731073
}
10741074

10751075
Dictionary splash_theme_attributes;
10761076
splash_theme_attributes["android:windowSplashScreenBackground"] = "@mipmap/icon_background";
10771077
splash_theme_attributes["windowSplashScreenAnimatedIcon"] = "@mipmap/icon_foreground";
10781078
splash_theme_attributes["postSplashScreenTheme"] = "@style/GodotAppMainTheme";
1079-
splash_theme_attributes["android:windowIsTranslucent"] = bool_to_string(should_be_transparent);
1079+
splash_theme_attributes["android:windowIsTranslucent"] = bool_to_string(transparency_allowed);
10801080

10811081
PackedStringArray reserved_splash_keys;
10821082
reserved_splash_keys.append("postSplashScreenTheme");
@@ -2992,7 +2992,7 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
29922992
}
29932993
}
29942994
} else {
2995-
if (_should_be_transparent(p_preset)) {
2995+
if (_is_transparency_allowed(p_preset)) {
29962996
// Warning only, so don't override `valid`.
29972997
err += vformat(TTR("\"Use Gradle Build\" is required for transparent background on Android"));
29982998
err += "\n";

platform/android/export/export_plugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
164164

165165
void _write_tmp_manifest(const Ref<EditorExportPreset> &p_preset, bool p_give_internet, bool p_debug);
166166

167-
bool _should_be_transparent(const Ref<EditorExportPreset> &p_preset) const;
167+
bool _is_transparency_allowed(const Ref<EditorExportPreset> &p_preset) const;
168168

169169
void _fix_themes_xml(const Ref<EditorExportPreset> &p_preset);
170170

platform/android/java/lib/src/org/godotengine/godot/Godot.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,9 @@ class Godot private constructor(val context: Context) {
487487

488488
// Check whether the render view should be made transparent
489489
val shouldBeTransparent =
490-
!isProjectManagerHint() && !isEditorHint() && java.lang.Boolean.parseBoolean(GodotLib.getGlobal("display/window/per_pixel_transparency/allowed"))
490+
!isProjectManagerHint() &&
491+
!isEditorHint() &&
492+
java.lang.Boolean.parseBoolean(GodotLib.getGlobal("display/window/per_pixel_transparency/allowed"))
491493
Log.d(TAG, "Render view should be transparent: $shouldBeTransparent")
492494
renderView = if (usesVulkan()) {
493495
if (meetsVulkanRequirements(context.packageManager)) {

0 commit comments

Comments
 (0)