Skip to content

Commit

Permalink
refactor: move checking for WaylandWindowDecorations inside class
Browse files Browse the repository at this point in the history
  • Loading branch information
p2004a committed Mar 22, 2022
1 parent 46f3b94 commit 8c94ba6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
7 changes: 2 additions & 5 deletions shell/browser/native_window_views.cc
Expand Up @@ -19,7 +19,6 @@
#include "content/public/browser/desktop_media_id.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/native_browser_view_views.h"
#include "shell/browser/native_window_features.h"
#include "shell/browser/ui/drag_util.h"
#include "shell/browser/ui/inspectable_web_contents.h"
#include "shell/browser/ui/inspectable_web_contents_view.h"
Expand Down Expand Up @@ -59,7 +58,6 @@
#include "shell/browser/ui/views/global_menu_bar_x11.h"
#include "shell/browser/ui/x/event_disabler.h"
#include "shell/browser/ui/x/x_window_utils.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/shape.h"
#include "ui/gfx/x/x11_atom_cache.h"
Expand Down Expand Up @@ -270,9 +268,8 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,

auto* native_widget = new views::DesktopNativeWidgetAura(widget());
params.native_widget = native_widget;
params.desktop_window_tree_host = new ElectronDesktopWindowTreeHostLinux(
this, native_widget,
base::FeatureList::IsEnabled(features::kWaylandWindowDecorations));
params.desktop_window_tree_host =
new ElectronDesktopWindowTreeHostLinux(this, native_widget);
#endif

widget()->Init(std::move(params));
Expand Down
10 changes: 5 additions & 5 deletions shell/browser/ui/electron_desktop_window_tree_host_linux.cc
Expand Up @@ -10,7 +10,9 @@

#include <vector>

#include "base/feature_list.h"
#include "base/i18n/rtl.h"
#include "shell/browser/native_window_features.h"
#include "shell/browser/ui/views/client_frame_view_linux.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/skia_conversions.h"
Expand All @@ -24,12 +26,10 @@ namespace electron {

ElectronDesktopWindowTreeHostLinux::ElectronDesktopWindowTreeHostLinux(
NativeWindowViews* native_window_view,
views::DesktopNativeWidgetAura* desktop_native_widget_aura,
bool wayland_window_decorations)
views::DesktopNativeWidgetAura* desktop_native_widget_aura)
: views::DesktopWindowTreeHostLinux(native_window_view->widget(),
desktop_native_widget_aura),
native_window_view_(native_window_view),
wayland_window_decorations_(wayland_window_decorations) {}
native_window_view_(native_window_view) {}

ElectronDesktopWindowTreeHostLinux::~ElectronDesktopWindowTreeHostLinux() =
default;
Expand Down Expand Up @@ -107,7 +107,7 @@ void ElectronDesktopWindowTreeHostLinux::OnDeviceScaleFactorChanged() {
}

void ElectronDesktopWindowTreeHostLinux::UpdateFrameHints() {
if (wayland_window_decorations_) {
if (base::FeatureList::IsEnabled(features::kWaylandWindowDecorations)) {
if (SupportsClientFrameShadow() && native_window_view_->has_frame() &&
native_window_view_->has_client_frame()) {
UpdateClientDecorationHints(static_cast<ClientFrameViewLinux*>(
Expand Down
4 changes: 1 addition & 3 deletions shell/browser/ui/electron_desktop_window_tree_host_linux.h
Expand Up @@ -26,8 +26,7 @@ class ElectronDesktopWindowTreeHostLinux
public:
ElectronDesktopWindowTreeHostLinux(
NativeWindowViews* native_window_view,
views::DesktopNativeWidgetAura* desktop_native_widget_aura,
bool wayland_window_decorations);
views::DesktopNativeWidgetAura* desktop_native_widget_aura);
~ElectronDesktopWindowTreeHostLinux() override;

// disable copy
Expand Down Expand Up @@ -67,7 +66,6 @@ class ElectronDesktopWindowTreeHostLinux
&views::LinuxUI::AddDeviceScaleFactorObserver,
&views::LinuxUI::RemoveDeviceScaleFactorObserver>
scale_observation_{this};
bool wayland_window_decorations_;
ui::PlatformWindowState window_state_ = ui::PlatformWindowState::kUnknown;
};

Expand Down

0 comments on commit 8c94ba6

Please sign in to comment.