Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HMCL/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ val makeDeb by tasks.registering(CreateDeb::class) {

version.set(project.version.toString())
releaseType.set(debChannel)
launcherClassName.set("org.jackhuang.hmcl.Launcher")
appShFile.set(layout.file(provider { artifactFile("sh") }))
iconFile.set(layout.projectDirectory.file("image/hmcl.png"))
outputFile.set(debFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public abstract class CreateDeb extends DefaultTask {
@Input
public abstract Property<ReleaseType> getReleaseType();

/// Launcher class name for Linux StartupWMClass property in the .desktop file.
@Input
public abstract Property<String> getLauncherClassName();

/// Executable `.sh` artifact produced by `makeExecutables`.
@InputFile
public abstract RegularFileProperty getAppShFile();
Expand Down Expand Up @@ -295,6 +299,7 @@ private String getDesktopInfo() {
StartupNotify=false
Categories=Game;
Keywords=mc;minecraft;
""".formatted(getCurrentType().getDisplayName(), getLauncherPath(), getIconTargetPath());
StartupWMClass=%s
""".formatted(getCurrentType().getDisplayName(), getLauncherPath(), getIconTargetPath(), getLauncherClassName().get());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In Java AWT/Swing/JavaFX on Linux, the default WM_CLASS of the window is generated by taking the fully qualified name of the main class and replacing dots ('.') with hyphens ('-'). Therefore, for org.jackhuang.hmcl.Launcher, the actual window's WM_CLASS will be org-jackhuang-hmcl-Launcher. If the .desktop file specifies StartupWMClass=org.jackhuang.hmcl.Launcher (with dots), the desktop environment will fail to match the running window with the .desktop file, and the application icon will still not display correctly on the dock/dash (or a duplicate generic icon will appear). To fix this, we should replace dots with hyphens in the StartupWMClass value.

Suggested change
""".formatted(getCurrentType().getDisplayName(), getLauncherPath(), getIconTargetPath(), getLauncherClassName().get());
""".formatted(getCurrentType().getDisplayName(), getLauncherPath(), getIconTargetPath(), getLauncherClassName().get().replace('.', '-'));

}
}