From bdd7730a244dbff6b892e1d59359b8e9ad25ae0a Mon Sep 17 00:00:00 2001 From: Alex Schwartz Date: Fri, 16 Jan 2026 03:55:52 -0500 Subject: [PATCH] fix: make toplevel icon Wayland protocol work (#49290) --- ...electron_desktop_window_tree_host_linux.cc | 19 +++++++++++++++++++ .../electron_desktop_window_tree_host_linux.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc index 5e27038f7c..ad58894392 100644 --- a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc +++ b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc @@ -25,6 +25,7 @@ #include "ui/gfx/geometry/skia_conversions.h" #include "ui/linux/linux_ui.h" #include "ui/ozone/public/ozone_platform.h" +#include "ui/platform_window/extensions/wayland_extension.h" #include "ui/platform_window/platform_window.h" #include "ui/platform_window/platform_window_init_properties.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" @@ -58,6 +59,24 @@ bool ElectronDesktopWindowTreeHostLinux::IsShowingFrame() const { !native_window_view_->IsMinimized(); } +void ElectronDesktopWindowTreeHostLinux::SetWindowIcons( + const gfx::ImageSkia& window_icon, + const gfx::ImageSkia& app_icon) { + DesktopWindowTreeHostLinux::SetWindowIcons(window_icon, app_icon); + + if (ui::GetWaylandToplevelExtension(*platform_window())) + saved_window_icon_ = window_icon; +} + +void ElectronDesktopWindowTreeHostLinux::Show( + ui::mojom::WindowShowState show_state, + const gfx::Rect& restore_bounds) { + DesktopWindowTreeHostLinux::Show(show_state, restore_bounds); + + if (!saved_window_icon_.isNull()) + DesktopWindowTreeHostLinux::SetWindowIcons(saved_window_icon_, {}); +} + gfx::Insets ElectronDesktopWindowTreeHostLinux::CalculateInsetsInDIP( ui::PlatformWindowState window_state) const { // If we are not showing frame, the insets should be zero. diff --git a/shell/browser/ui/electron_desktop_window_tree_host_linux.h b/shell/browser/ui/electron_desktop_window_tree_host_linux.h index 560a76b22f..208cd5e42c 100644 --- a/shell/browser/ui/electron_desktop_window_tree_host_linux.h +++ b/shell/browser/ui/electron_desktop_window_tree_host_linux.h @@ -11,6 +11,7 @@ #include "base/memory/raw_ptr.h" #include "base/scoped_observation.h" +#include "ui/gfx/image/image_skia.h" #include "ui/linux/device_scale_factor_observer.h" #include "ui/linux/linux_ui.h" #include "ui/native_theme/native_theme_observer.h" @@ -44,6 +45,10 @@ class ElectronDesktopWindowTreeHostLinux protected: // views::DesktopWindowTreeHostLinuxImpl: void OnWidgetInitDone() override; + void SetWindowIcons(const gfx::ImageSkia& window_icon, + const gfx::ImageSkia& app_icon) override; + void Show(ui::mojom::WindowShowState show_state, + const gfx::Rect& restore_bounds) override; // ui::PlatformWindowDelegate gfx::Insets CalculateInsetsInDIP( @@ -71,6 +76,8 @@ class ElectronDesktopWindowTreeHostLinux bool IsShowingFrame() const; + gfx::ImageSkia saved_window_icon_; + raw_ptr native_window_view_; // weak ref base::ScopedObservation