fix: set Wayland application ID (#34855)
* refactor: extract XDG app ID logic into a method * fix: set application ID on Wayland
This commit is contained in:
parent
8f3fb8db09
commit
f63bba8ce2
4 changed files with 24 additions and 8 deletions
|
@ -51,6 +51,7 @@
|
||||||
#include "shell/browser/ui/views/client_frame_view_linux.h"
|
#include "shell/browser/ui/views/client_frame_view_linux.h"
|
||||||
#include "shell/browser/ui/views/frameless_view.h"
|
#include "shell/browser/ui/views/frameless_view.h"
|
||||||
#include "shell/browser/ui/views/native_frame_view.h"
|
#include "shell/browser/ui/views/native_frame_view.h"
|
||||||
|
#include "shell/common/platform_util.h"
|
||||||
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
|
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
|
||||||
#include "ui/views/window/native_frame_view.h"
|
#include "ui/views/window/native_frame_view.h"
|
||||||
|
|
||||||
|
@ -271,6 +272,8 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
|
||||||
// Set WM_CLASS.
|
// Set WM_CLASS.
|
||||||
params.wm_class_name = base::ToLowerASCII(name);
|
params.wm_class_name = base::ToLowerASCII(name);
|
||||||
params.wm_class_class = name;
|
params.wm_class_class = name;
|
||||||
|
// Set Wayland application ID.
|
||||||
|
params.wayland_app_id = platform_util::GetXdgAppId();
|
||||||
|
|
||||||
auto* native_widget = new views::DesktopNativeWidgetAura(widget());
|
auto* native_widget = new views::DesktopNativeWidgetAura(widget());
|
||||||
params.native_widget = native_widget;
|
params.native_widget = native_widget;
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include "base/files/file_enumerator.h"
|
#include "base/files/file_enumerator.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/strings/string_util.h"
|
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "shell/browser/notifications/notification_delegate.h"
|
#include "shell/browser/notifications/notification_delegate.h"
|
||||||
#include "shell/browser/ui/gtk_util.h"
|
#include "shell/browser/ui/gtk_util.h"
|
||||||
|
@ -138,13 +137,8 @@ void LibnotifyNotification::Show(const NotificationOptions& options) {
|
||||||
|
|
||||||
// Send the desktop name to identify the application
|
// Send the desktop name to identify the application
|
||||||
// The desktop-entry is the part before the .desktop
|
// The desktop-entry is the part before the .desktop
|
||||||
std::string desktop_id;
|
std::string desktop_id = platform_util::GetXdgAppId();
|
||||||
if (platform_util::GetDesktopName(&desktop_id)) {
|
if (!desktop_id.empty()) {
|
||||||
const std::string suffix{".desktop"};
|
|
||||||
if (base::EndsWith(desktop_id, suffix,
|
|
||||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
|
||||||
desktop_id.resize(desktop_id.size() - suffix.size());
|
|
||||||
}
|
|
||||||
libnotify_loader_.notify_notification_set_hint_string(
|
libnotify_loader_.notify_notification_set_hint_string(
|
||||||
notification_, "desktop-entry", desktop_id.c_str());
|
notification_, "desktop-entry", desktop_id.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,10 @@ bool SetLoginItemEnabled(bool enabled);
|
||||||
// Returns a success flag.
|
// Returns a success flag.
|
||||||
// Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback.
|
// Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback.
|
||||||
bool GetDesktopName(std::string* setme);
|
bool GetDesktopName(std::string* setme);
|
||||||
|
|
||||||
|
// The XDG application ID must match the name of the desktop entry file without
|
||||||
|
// the .desktop extension.
|
||||||
|
std::string GetXdgAppId();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace platform_util
|
} // namespace platform_util
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "base/posix/eintr_wrapper.h"
|
#include "base/posix/eintr_wrapper.h"
|
||||||
#include "base/process/kill.h"
|
#include "base/process/kill.h"
|
||||||
#include "base/process/launch.h"
|
#include "base/process/launch.h"
|
||||||
|
#include "base/strings/string_util.h"
|
||||||
#include "base/threading/thread_restrictions.h"
|
#include "base/threading/thread_restrictions.h"
|
||||||
#include "components/dbus/thread_linux/dbus_thread_linux.h"
|
#include "components/dbus/thread_linux/dbus_thread_linux.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
|
@ -403,4 +404,18 @@ bool GetDesktopName(std::string* setme) {
|
||||||
return base::Environment::Create()->GetVar("CHROME_DESKTOP", setme);
|
return base::Environment::Create()->GetVar("CHROME_DESKTOP", setme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GetXdgAppId() {
|
||||||
|
std::string desktop_file_name;
|
||||||
|
if (GetDesktopName(&desktop_file_name)) {
|
||||||
|
const std::string kDesktopExtension{".desktop"};
|
||||||
|
if (base::EndsWith(desktop_file_name, kDesktopExtension,
|
||||||
|
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||||
|
desktop_file_name.resize(desktop_file_name.size() -
|
||||||
|
kDesktopExtension.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return desktop_file_name;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace platform_util
|
} // namespace platform_util
|
||||||
|
|
Loading…
Reference in a new issue