From ea3c3e719e367a300d08cd4c254f9b5fd75c2e1e Mon Sep 17 00:00:00 2001 From: Kristen McWilliam <9575627+Merrit@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:52:50 -0400 Subject: [PATCH] fix(Linux): specify application id (#154522) This change sets the program name to the application ID, which helps various systems like GTK and desktop environments map this running application to its corresponding .desktop file. This ensures better integration by allowing the application to be recognized beyond its binary name. Notably, this is necessary on Wayland to map the running application window to the desktop file, and therefore apply the correct icon. I've tested that this works in both GNOME & KDE Wayland sessions. Partially addresses https://github.com/flutter/flutter/issues/53229 Resolves https://github.com/flutter/flutter/issues/154521 ## Icon Association ### Task switcher The task switcher shows the application's icon in the bottom-middle. Before it only showed a generic Wayland icon. | Before | After | |-------- |------- | | ![before1](https://github.com/user-attachments/assets/6f9392f3-c6ff-4ea4-b71b-7186949e2afd) |![after1](https://github.com/user-attachments/assets/e70d394a-a880-42c9-8409-6b975fb59ce1) | ### Window Decorations KDE shows the application's icon on the window decorations, at the top-left. Before it only showed a generic Wayland icon. | Before | After | |-------- |------- | | ![before2](https://github.com/user-attachments/assets/8076ccf8-79c7-4a60-b12b-2fe1ccf9c393) | ![after2](https://github.com/user-attachments/assets/7a96def2-030c-45c4-9c3f-403256b5da07) | --- .../templates/app_shared/linux.tmpl/my_application.cc.tmpl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/flutter_tools/templates/app_shared/linux.tmpl/my_application.cc.tmpl b/packages/flutter_tools/templates/app_shared/linux.tmpl/my_application.cc.tmpl index f6312e53641..e497462c461 100644 --- a/packages/flutter_tools/templates/app_shared/linux.tmpl/my_application.cc.tmpl +++ b/packages/flutter_tools/templates/app_shared/linux.tmpl/my_application.cc.tmpl @@ -117,6 +117,12 @@ static void my_application_class_init(MyApplicationClass* klass) { static void my_application_init(MyApplication* self) {} MyApplication* my_application_new() { + // Set the program name to the application ID, which helps various systems + // like GTK and desktop environments map this running application to its + // corresponding .desktop file. This ensures better integration by allowing + // the application to be recognized beyond its binary name. + g_set_prgname(APPLICATION_ID); + return MY_APPLICATION(g_object_new(my_application_get_type(), "application-id", APPLICATION_ID, "flags", G_APPLICATION_NON_UNIQUE,