Repository: electron/electron
File: shell/browser/ui/electron_desktop_window_tree_host_linux.cc (C++)

Code before:
  return platform_window()->CanSetDecorationInsets() &&
         views::Widget::IsWindowCompositingSupported();
}

void ElectronDesktopWindowTreeHostLinux::OnWidgetInitDone() {
  views::DesktopWindowTreeHostLinux::OnWidgetInitDone();
  UpdateFrameHints();
}

bool ElectronDesktopWindowTreeHostLinux::IsShowingFrame() const {
  return !native_window_view_->IsFullscreen() &&
         !native_window_view_->IsMaximized() &&
         !native_window_view_->IsMinimized();
}

void ElectronDesktopWindowTreeHostLinux::SetWindowIcons(
    const gfx::ImageSkia& window_icon,
    const gfx::ImageSkia& app_icon) {
  DesktopWindowTreeHostLinux::SetWindowIcons(window_icon, app_icon);

  auto* wayland_extension = ui::GetWaylandToplevelExtension(*platform_window());
  if (!wayland_extension) {
    return;
  }

  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()) {
    return;
  }

  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.
  if (!IsShowingFrame()) {
    return gfx::Insets();
  }

  auto* const view = native_window_view_->GetClientFrameViewLinux();
  if (!view)
    return {};


Review comment (suggestion):
```suggestion
  if (auto* wayland_extension = ui::GetWaylandToplevelExtension(*platform_window()))
    saved_window_icon_ = window_icon;
```

Code after:
  return platform_window()->CanSetDecorationInsets() &&
         views::Widget::IsWindowCompositingSupported();
}

void ElectronDesktopWindowTreeHostLinux::OnWidgetInitDone() {
  views::DesktopWindowTreeHostLinux::OnWidgetInitDone();
  UpdateFrameHints();
}

bool ElectronDesktopWindowTreeHostLinux::IsShowingFrame() const {
  return !native_window_view_->IsFullscreen() &&
         !native_window_view_->IsMaximized() &&
         !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.
  if (!IsShowingFrame()) {
    return gfx::Insets();
  }

  auto* const view = native_window_view_->GetClientFrameViewLinux();
  if (!view)
    return {};

  gfx::Insets insets = view->RestoredMirroredFrameBorderInsets();
  if (base::i18n::IsRTL())
    insets.set_left_right(insets.right(), insets.left());
  return insets;
}

void ElectronDesktopWindowTreeHostLinux::OnBoundsChanged(