Ver Fonte

Address remaining feedback on https://github.com/godotengine/godot/pull/106709

Address https://github.com/godotengine/godot/pull/106709#discussion_r2114489487
Fredia Huya-Kouadio há 3 meses atrás
pai
commit
3ade4b4b63

+ 2 - 1
doc/classes/DisplayServer.xml

@@ -3074,7 +3074,8 @@
 		<constant name="WINDOW_FLAG_TRANSPARENT" value="3" enum="WindowFlags">
 			The window background can be transparent.
 			[b]Note:[/b] This flag has no effect if [method is_window_transparency_available] returns [code]false[/code].
-			[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.
+			[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.
+			[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.
 		</constant>
 		<constant name="WINDOW_FLAG_NO_FOCUS" value="4" enum="WindowFlags">
 			The window can't be focused. No-focus window will ignore all input, except mouse clicks.

+ 1 - 0
doc/classes/ProjectSettings.xml

@@ -1016,6 +1016,7 @@
 			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].
 			[b]Note:[/b] To use a transparent splash screen, set [member application/boot_splash/bg_color] to [code]Color(0, 0, 0, 0)[/code].
 			[b]Note:[/b] This setting has no effect if [member display/window/per_pixel_transparency/allowed] is set to [code]false[/code].
+			[b]Note:[/b] This setting has no effect on Android as transparency is controlled only via [member display/window/per_pixel_transparency/allowed].
 		</member>
 		<member name="display/window/size/viewport_height" type="int" setter="" getter="" default="648">
 			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].

+ 1 - 0
platform/android/display_server_android.cpp

@@ -596,6 +596,7 @@ void DisplayServerAndroid::window_set_flag(DisplayServer::WindowFlags p_flag, bo
 }
 
 bool DisplayServerAndroid::window_get_flag(DisplayServer::WindowFlags p_flag, DisplayServer::WindowID p_window) const {
+	ERR_FAIL_COND_V(p_window != MAIN_WINDOW_ID, false);
 	switch (p_flag) {
 		case WindowFlags::WINDOW_FLAG_TRANSPARENT:
 			return is_window_transparency_available();

+ 6 - 6
platform/android/export/export_plugin.cpp

@@ -1050,7 +1050,7 @@ void EditorExportPlatformAndroid::_write_tmp_manifest(const Ref<EditorExportPres
 	store_string_at_path(manifest_path, manifest_text);
 }
 
-bool EditorExportPlatformAndroid::_should_be_transparent(const Ref<EditorExportPreset> &p_preset) const {
+bool EditorExportPlatformAndroid::_is_transparency_allowed(const Ref<EditorExportPreset> &p_preset) const {
 	return (bool)get_project_setting(p_preset, "display/window/per_pixel_transparency/allowed");
 }
 
@@ -1062,13 +1062,13 @@ void EditorExportPlatformAndroid::_fix_themes_xml(const Ref<EditorExportPreset>
 		return;
 	}
 
-	bool should_be_transparent = _should_be_transparent(p_preset);
+	bool transparency_allowed = _is_transparency_allowed(p_preset);
 
 	// Default/Reserved theme attributes.
 	Dictionary main_theme_attributes;
 	main_theme_attributes["android:windowSwipeToDismiss"] = bool_to_string(p_preset->get("gesture/swipe_to_dismiss"));
-	main_theme_attributes["android:windowIsTranslucent"] = bool_to_string(should_be_transparent);
-	if (should_be_transparent) {
+	main_theme_attributes["android:windowIsTranslucent"] = bool_to_string(transparency_allowed);
+	if (transparency_allowed) {
 		main_theme_attributes["android:windowBackground"] = "@android:color/transparent";
 	}
 
@@ -1076,7 +1076,7 @@ void EditorExportPlatformAndroid::_fix_themes_xml(const Ref<EditorExportPreset>
 	splash_theme_attributes["android:windowSplashScreenBackground"] = "@mipmap/icon_background";
 	splash_theme_attributes["windowSplashScreenAnimatedIcon"] = "@mipmap/icon_foreground";
 	splash_theme_attributes["postSplashScreenTheme"] = "@style/GodotAppMainTheme";
-	splash_theme_attributes["android:windowIsTranslucent"] = bool_to_string(should_be_transparent);
+	splash_theme_attributes["android:windowIsTranslucent"] = bool_to_string(transparency_allowed);
 
 	Dictionary custom_theme_attributes = p_preset->get("gradle_build/custom_theme_attributes");
 
@@ -2988,7 +2988,7 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
 			}
 		}
 	} else {
-		if (_should_be_transparent(p_preset)) {
+		if (_is_transparency_allowed(p_preset)) {
 			// Warning only, so don't override `valid`.
 			err += vformat(TTR("\"Use Gradle Build\" is required for transparent background on Android"));
 			err += "\n";

+ 1 - 1
platform/android/export/export_plugin.h

@@ -164,7 +164,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
 
 	void _write_tmp_manifest(const Ref<EditorExportPreset> &p_preset, bool p_give_internet, bool p_debug);
 
-	bool _should_be_transparent(const Ref<EditorExportPreset> &p_preset) const;
+	bool _is_transparency_allowed(const Ref<EditorExportPreset> &p_preset) const;
 
 	void _fix_themes_xml(const Ref<EditorExportPreset> &p_preset);
 

+ 3 - 1
platform/android/java/lib/src/org/godotengine/godot/Godot.kt

@@ -487,7 +487,9 @@ class Godot private constructor(val context: Context) {
 
 			// Check whether the render view should be made transparent
 			val shouldBeTransparent =
-				!isProjectManagerHint() && !isEditorHint() && java.lang.Boolean.parseBoolean(GodotLib.getGlobal("display/window/per_pixel_transparency/allowed"))
+				!isProjectManagerHint() &&
+					!isEditorHint() &&
+					java.lang.Boolean.parseBoolean(GodotLib.getGlobal("display/window/per_pixel_transparency/allowed"))
 			Log.d(TAG, "Render view should be transparent: $shouldBeTransparent")
 			renderView = if (usesVulkan()) {
 				if (meetsVulkanRequirements(context.packageManager)) {