electron/shell/browser/ui/views/client_frame_view_linux.h
electron-roller[bot] ea6f873f97
chore: bump chromium to 109.0.5382.0 (main) (#36057)
* chore: bump chromium in DEPS to 109.0.5364.0

* chore: update patches

* chore: bump chromium in DEPS to 109.0.5366.0

* chore: update patches

* i3940364: Change PermissionType::WINDOW_PLACEMENT to WINDOW_MANAGEMENT

https://chromium-review.googlesource.com/c/chromium/src/+/3940364

* 3866812: Change content::PluginList to only run on the UI thread.

https://chromium-review.googlesource.com/c/chromium/src/+/3866812

* chore: bump chromium in DEPS to 109.0.5368.0

* [cleanup] Replace enable_basic_printing with enable_printing

https://chromium-review.googlesource.com/c/chromium/src/+/3957357

* chore: update patches

* 3956318: Desktop PWAs: Retire kWebAppWindowControlsOverlay flag

https://chromium-review.googlesource.com/c/chromium/src/+/3956318

* fixup! Change content::PluginList to only run on the UI thread.

(cherry picked from commit 7b5ec87d4ff5d34e7493b4fb46c40c0afeef2005)
Co-Authored-By: Robo <hop2deep@gmail.com>

* chore: bump chromium in DEPS to 109.0.5370.0

* 3956299: Quota: Cleanup QuotaPermissionContext

https://chromium-review.googlesource.com/c/chromium/src/+/3956299

* chore: update patches

* 3803867: Add Mojo interface to parse XML for OOP printer capabilities

https://chromium-review.googlesource.com/c/chromium/src/+/3803867

* fixup: Add Mojo interface to parse XML for OOP printer capabilities

* chore: bump chromium in DEPS to 109.0.5372.0

* chore: update patches

* chore: bump chromium in DEPS to 109.0.5374.0

* chore: bump chromium in DEPS to 109.0.5376.0

* chore: bump chromium in DEPS to 109.0.5378.0

* chore: update patches

* Quota: Cleanup kPersistent in BrowsingDataRemover

https://chromium-review.googlesource.com/c/chromium/src/+/3964859

* 3955976: serial: Create DOMException with V8ThrowDOMException

https://chromium-review.googlesource.com/c/chromium/src/+/3955976

* 3758405: Append trailer data to serialized messages.

https://chromium-review.googlesource.com/c/chromium/src/+/3758405

* chore: revert clang roll

This patch reverts https://chromium-review.googlesource.com/c/chromium/src/+/3967491
because that roll breaks the WOA build: https://crbug.com/1377819

* chore: update patches

* chore: bump chromium in DEPS to 109.0.5380.0

* chore: update patches

* 3859750: [linux/wayland] Added plumbing for the state of tiled edges.

https://chromium-review.googlesource.com/c/chromium/src/+/3859750

Also 3970920: [linux/wayland] Fixed the tiled edges for the GTK frame.

https://chromium-review.googlesource.com/c/chromium/src/+/3970920

* chore: bump chromium in DEPS to 109.0.5382.0

* chore: update patches

* chore: revert Use accessibility.pkey when setting page access.

https://chromium-review.googlesource.com/c/chromium/src/+/3949281
breaks our Linux builds run under Docker.

This patch should be removed once
https://chromium-review.googlesource.com/c/chromium/src/+/3949284
is merged.

* 3976312: Roll clang llvmorg-16-init-8189-g97196a2d-2 : llvmorg-16-init-8697-g60809cd2-1

https://chromium-review.googlesource.com/c/chromium/src/+/3976312

* 3967841: [heap] Remove AllocationSpace::MAP_SPACE enum constant

https://chromium-review.googlesource.com/c/v8/v8/+/3967841

* 3956131: [cleanup] Remove flag for Wasm threads & atomics

https://chromium-review.googlesource.com/c/v8/v8/+/3956131

* chore: update docs for Quota: Cleanup kPersistent in BrowsingDataRemover

https://chromium-review.googlesource.com/c/chromium/src/+/3964859

* test: fixup HID test for ARM CI

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com>
2022-10-27 12:37:04 -04:00

152 lines
4.9 KiB
C++

// Copyright (c) 2021 Ryan Gonzalez.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_CLIENT_FRAME_VIEW_LINUX_H_
#define ELECTRON_SHELL_BROWSER_UI_VIEWS_CLIENT_FRAME_VIEW_LINUX_H_
#include <array>
#include <memory>
#include <vector>
#include "base/scoped_observation.h"
#include "shell/browser/ui/views/frameless_view.h"
#include "ui/base/ui_base_types.h"
#include "ui/linux/linux_ui.h"
#include "ui/linux/nav_button_provider.h"
#include "ui/linux/window_button_order_observer.h"
#include "ui/linux/window_frame_provider.h"
#include "ui/native_theme/native_theme.h"
#include "ui/native_theme/native_theme_observer.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/frame_buttons.h"
namespace electron {
class ClientFrameViewLinux : public FramelessView,
public ui::NativeThemeObserver,
public ui::WindowButtonOrderObserver {
public:
static const char kViewClassName[];
ClientFrameViewLinux();
~ClientFrameViewLinux() override;
void Init(NativeWindowViews* window, views::Widget* frame) override;
// These are here for ElectronDesktopWindowTreeHostLinux to use.
gfx::Insets GetBorderDecorationInsets() const;
gfx::Insets GetInputInsets() const;
gfx::Rect GetWindowContentBounds() const;
SkRRect GetRoundedWindowContentBounds() const;
// Returns which edges of the frame are tiled.
const ui::WindowTiledEdges& tiled_edges() const { return tiled_edges_; }
void set_tiled_edges(ui::WindowTiledEdges tiled_edges) {
tiled_edges_ = tiled_edges;
}
protected:
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
// views::WindowButtonOrderObserver:
void OnWindowButtonOrderingChange() override;
// Overridden from FramelessView:
int ResizingBorderHitTest(const gfx::Point& point) override;
// Overridden from views::NonClientFrameView:
gfx::Rect GetBoundsForClientView() const override;
gfx::Rect GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const override;
int NonClientHitTest(const gfx::Point& point) override;
void GetWindowMask(const gfx::Size& size, SkPath* window_mask) override;
void UpdateWindowTitle() override;
void SizeConstraintsChanged() override;
// Overridden from View:
gfx::Size CalculatePreferredSize() const override;
gfx::Size GetMinimumSize() const override;
gfx::Size GetMaximumSize() const override;
void Layout() override;
void OnPaint(gfx::Canvas* canvas) override;
const char* GetClassName() const override;
// Overriden from views::ViewTargeterDelegate
views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override;
private:
static constexpr int kNavButtonCount = 4;
struct NavButton {
ui::NavButtonProvider::FrameButtonDisplayType type;
views::FrameButton frame_button;
void (views::Widget::*callback)();
int accessibility_id;
int hit_test_id;
views::ImageButton* button{nullptr};
};
struct ThemeValues {
float window_border_radius;
int titlebar_min_height;
gfx::Insets titlebar_padding;
SkColor title_color;
gfx::Insets title_padding;
int button_min_size;
gfx::Insets button_padding;
};
void PaintAsActiveChanged();
void UpdateThemeValues();
enum class ButtonSide { kLeading, kTrailing };
ui::NavButtonProvider::FrameButtonDisplayType GetButtonTypeToSkip() const;
void UpdateButtonImages();
void LayoutButtons();
void LayoutButtonsOnSide(ButtonSide side,
gfx::Rect* remaining_content_bounds);
gfx::Rect GetTitlebarBounds() const;
gfx::Insets GetTitlebarContentInsets() const;
gfx::Rect GetTitlebarContentBounds() const;
gfx::Size SizeWithDecorations(gfx::Size size) const;
ui::NativeTheme* theme_;
ThemeValues theme_values_;
views::Label* title_;
std::unique_ptr<ui::NavButtonProvider> nav_button_provider_;
std::array<NavButton, kNavButtonCount> nav_buttons_;
std::vector<views::FrameButton> leading_frame_buttons_;
std::vector<views::FrameButton> trailing_frame_buttons_;
bool host_supports_client_frame_shadow_ = false;
ui::WindowFrameProvider* frame_provider_;
base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
native_theme_observer_{this};
base::ScopedObservation<ui::LinuxUiTheme,
ui::WindowButtonOrderObserver,
&ui::LinuxUiTheme::AddWindowButtonOrderObserver,
&ui::LinuxUiTheme::RemoveWindowButtonOrderObserver>
window_button_order_observer_{this};
base::CallbackListSubscription paint_as_active_changed_subscription_;
ui::WindowTiledEdges tiled_edges_;
};
} // namespace electron
#endif // ELECTRON_SHELL_BROWSER_UI_VIEWS_CLIENT_FRAME_VIEW_LINUX_H_