Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set SDL_HINT_APP_NAME in SDL3GameHost constructor #6260

Merged
merged 2 commits into from
Apr 25, 2024

Conversation

FreezyLemon
Copy link
Contributor

Supersedes #5650. Closes ppy/osu#25783.

The docs say that

This hint should be set before SDL is initialized.

Since SDL_Init is called in the SDL3Window constructor, this means that the application name must be known at that point in time. So it's not possible to rely on the window title.

This appName value is then used to tell SDL the application name to show in OS windows, prompts, etc.:

image

The appName could arguably be used as the initial window title.

@FreezyLemon FreezyLemon changed the title Add appName parameter to window constructors & CreateWindow Set SDL_HINT_APP_NAME in SDL3GameHost constructor Apr 21, 2024
@bdach
Copy link
Collaborator

bdach commented Apr 24, 2024

I suppose this works, but my main question here is - what is the intent with respect to the game-side override of the window title (see here and then here)?

Like as far as I can tell, you can't actually move that title logic out to use FriendlyGameName instead, because the logic is circular - the host needs to know the friendly game name first, but that name is not actually determined until the actual game instance to run on the host is constructed? Feels a bit circular imo.

Like it's either going to be this:

diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs
index 29b05a402f..1dafe0d9ff 100644
--- a/osu.Desktop/Program.cs
+++ b/osu.Desktop/Program.cs
@@ -107,7 +107,11 @@ public static void Main(string[] args)
                 }
             }
 
-            using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions { IPCPort = !tournamentClient ? OsuGame.IPC_PORT : null }))
+            using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions
+                   {
+                       IPCPort = !tournamentClient ? OsuGame.IPC_PORT : null,
+                       FriendlyGameName = "osu!"
+                   }))
             {
                 if (!host.IsPrimaryInstance)
                 {

as a best-effort, or something like

diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs
index 29b05a402f..d8364fc6e6 100644
--- a/osu.Desktop/Program.cs
+++ b/osu.Desktop/Program.cs
@@ -107,7 +107,11 @@ public static void Main(string[] args)
                 }
             }
 
-            using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions { IPCPort = !tournamentClient ? OsuGame.IPC_PORT : null }))
+            using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions
+                   {
+                       IPCPort = !tournamentClient ? OsuGame.IPC_PORT : null,
+                       FriendlyGameName = OsuGameBase.GAME_NAME,
+                   }))
             {
                 if (!host.IsPrimaryInstance)
                 {
diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs
index fb7a238c46..6654b39137 100644
--- a/osu.Game/OsuGameBase.cs
+++ b/osu.Game/OsuGameBase.cs
@@ -75,6 +75,12 @@ public partial class OsuGameBase : Framework.Game, ICanAcceptFiles, IBeatSyncPro
     {
         public static readonly string[] VIDEO_EXTENSIONS = { ".mp4", ".mov", ".avi", ".flv", ".mpg", ".wmv", ".m4v" };
 
+#if DEBUG
+        public const string GAME_NAME = "osu! (development)";
+#else
+        public const string GAME_NAME = "osu!";
+#endif
+
         public const string OSU_PROTOCOL = "osu://";
 
         public const string CLIENT_STREAM_NAME = @"lazer";
@@ -241,11 +247,7 @@ public virtual string Version
 
         public OsuGameBase()
         {
-            Name = @"osu!";
-
-#if DEBUG
-            Name += " (development)";
-#endif
+            Name = GAME_NAME;
 
             allowableExceptions = UnhandledExceptionsBeforeCrash;
         }

I guess?

Food for thought as to whether things can be done better API-design-wise I guess. I'm probably fine with either resolution myself.

@smoogipoo
Copy link
Contributor

Both of those diffs look reasonable to me. As far I've convinced myself, its purpose is not the same as the window title so I wouldn't see us doing anything around that:

  • Window.Title: Some dynamic text that contains contextual information.
  • FriendlyGameName: Static text that identifies the app in system controls.
  • GetSuitableHost(gameName): Static text that identifies the app's runtime folder (~/.local/share/{gameName}).

@smoogipoo smoogipoo merged commit 169bd07 into ppy:master Apr 25, 2024
21 checks passed
@FreezyLemon FreezyLemon deleted the add-sdl-hint-app-name branch April 25, 2024 17:23
peppy added a commit to peppy/osu-framework that referenced this pull request May 21, 2024
…-name"

This reverts commit 169bd07, reversing
changes made to 2e6cced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Osu sometimes reports itself as "My SDL application" on Linux
4 participants