refactor: use views NonClientHitTest for draggable regions on mac (#35603)

* refactor: use views NonClientHitTest for draggable regions on mac

* iwyu

* add backport of 9bb5f0316

* chore: update patches

* remove some unneeded functions

* remove test for triggering when BW is focused

* chore: update patches

* simplify views/mac split now that the draggable logic is the same

* Apply suggestions from code review

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* Update shell/browser/native_window.h

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* fix build

Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
Jeremy Rose 2022-10-12 09:05:45 -07:00 committed by GitHub
parent 7ce94eb0b4
commit 8a926ffde4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 70 additions and 392 deletions

View file

@ -13,6 +13,7 @@
#include "base/mac/scoped_nsobject.h"
#include "shell/browser/native_window.h"
#include "shell/common/api/api.mojom.h"
#include "ui/display/display_observer.h"
#include "ui/native_theme/native_theme_observer.h"
#include "ui/views/controls/native/native_view_host.h"
@ -160,9 +161,6 @@ class NativeWindowMac : public NativeWindow,
// cleanup in destructor.
void Cleanup();
// Use a custom content view instead of Chromium's BridgedContentView.
void OverrideNSWindowContentView();
void UpdateVibrancyRadii(bool fullscreen);
void UpdateWindowOriginalFrame();
@ -206,6 +204,8 @@ class NativeWindowMac : public NativeWindow,
// views::WidgetDelegate:
views::View* GetContentsView() override;
bool CanMaximize() const override;
std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
views::Widget* widget) override;
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
@ -228,11 +228,6 @@ class NativeWindowMac : public NativeWindow,
base::scoped_nsobject<ElectronPreviewItem> preview_item_;
base::scoped_nsobject<ElectronTouchBar> touch_bar_;
// The NSView that used as contentView of window.
//
// For frameless window it would fill the whole window.
base::scoped_nsobject<NSView> container_view_;
// The views::View that fills the client area.
std::unique_ptr<RootViewMac> root_view_;
@ -261,6 +256,8 @@ class NativeWindowMac : public NativeWindow,
// Controls the position and visibility of window buttons.
base::scoped_nsobject<WindowButtonsProxy> buttons_proxy_;
std::unique_ptr<SkRegion> draggable_region_;
// Maximizable window state; necessary for persistence through redraws.
bool maximizable_ = true;