87c183df6a
* chore: bump chromium in DEPS to 109.0.5386.0 * chore: bump chromium in DEPS to 109.0.5388.0 * chore: bump chromium in DEPS to 109.0.5390.0 * chore: bump chromium in DEPS to 109.0.5392.0 * chore: bump chromium in DEPS to 109.0.5394.0 * chore: bump chromium in DEPS to 109.0.5396.0 * chore: bump chromium in DEPS to 109.0.5398.0 * chore: bump chromium in DEPS to 109.0.5400.0 * chore: update galactus * chore: bump chromium in DEPS to 109.0.5402.0 * chore: bump chromium in DEPS to 109.0.5403.0 * chore: bump chromium in DEPS to 109.0.5406.0 * chore: update patches * 4004247: Delete unused DocumentWebContentsDelegate Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4004247 * chore: bump chromium in DEPS to 109.0.5408.1 * chore: update patches * 3949284: Support pkey debug mode without pkey 0 access Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3949284 * chore: bump chromium in DEPS to 109.0.5410.0 * chore: update patches * 4000944: [Extensions] Create an API directory in //chrome/renderer/extensions Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4000944 * 3988524: Remove DocumentOverlayWindowViews | https://chromium-review.googlesource.com/c/chromium/src/+/3988524 Co-authored-by: George Xu <33054982+georgexu99@users.noreply.github.com> * chore: bump chromium in DEPS to 109.0.5412.0 * chore: update patches * 3984022: Add AddChildWindowToBrowser to DisplayClient mojo interface Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3984022 * 3957079: Delete the CryptoToken component extension and internal API Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3957079 * 4004421: Migreate ScopedAllowIO to ScopedAllowBlocking Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4004421 Co-authored-by: George Xu <georgexu99@users.noreply.github.com> * chore: bump chromium in DEPS to 109.0.5414.0 * chore: update patches * 4016180: Split PPAPI Mojo interfaces out of RenderFrameHostImpl. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4016180 * 3970838: [MPArch] Convert HostZoomMap and ZoomController off of RenderViewHost ids Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3970838 * 3997795: Don't add Chromium as a login item Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3997795 * 3993482: Remove RefCountedString::TakeString Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3993482 * 3990749: Allow forward-declared sources in base::ScopedObservation<> Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3990749 * fixup! 3957079: Delete the CryptoToken component extension and internal API * chore: bump chromium in DEPS to 110.0.5415.0 * 3883790: Move devtools_frame_token to the RenderFrameHost, to preserve RFH identity across MPArch activations. https://chromium-review.googlesource.com/c/chromium/src/+/3883790 * 4022205: Move license tooling into //tools/licenses https://chromium-review.googlesource.com/c/chromium/src/+/4022205 * chore: fixup patch indices * fixup! 3957079: Delete the CryptoToken component extension and internal API * 4008687: Finish ScopedAllowIO migration https://chromium-review.googlesource.com/c/chromium/src/+/4008687 * 3991548: Move WindowButtonOrderObserver and WindowFrameAction to LinuxUi https://chromium-review.googlesource.com/c/chromium/src/+/3991548 * fixup! 3984022: Add AddChildWindowToBrowser to DisplayClient mojo interface * 4016595: Migrate non-default ScopedObservation<> instantiations to ScopedObservationTraits<> in chrome/browser/ https://chromium-review.googlesource.com/c/chromium/src/+/4016595 * 4000481: Rename :chromedriver to :chromedriver_server Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4000481 * 4008687: Finish ScopedAllowIO migration https://chromium-review.googlesource.com/c/chromium/src/+/4008687 * 3988524: Remove DocumentOverlayWindowViews https://chromium-review.googlesource.com/c/chromium/src/+/3988524 * fixup! 3997795: Don't add Chromium as a login item * chore: fixup patches * 3996872: Plumb input event task runner to EventFactoryEvdev https://chromium-review.googlesource.com/c/chromium/src/+/3996872 * 4014994: Enable SiteIsolationForGuests by default. https://chromium-review.googlesource.com/c/chromium/src/+/4014994 * chore: adopt new thread restrictions api for //electron (#36357) chore: add thread blocking api * fixup! 4014994: Enable SiteIsolationForGuests by default. * pull parent HWND for dialogs on ui thread * chore: set parent_window in MessageBoxSettings * chore: remove redundant patch * chore: revert accidental deletion * chore: update patches Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <sattard@salesforce.com> Co-authored-by: Keeley Hammond <khammond@slack-corp.com> Co-authored-by: VerteDinde <vertedinde@electronjs.org> Co-authored-by: George Xu <33054982+georgexu99@users.noreply.github.com> Co-authored-by: George Xu <georgexu99@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Robo <hop2deep@gmail.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
149 lines
4.7 KiB
C++
149 lines
4.7 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::LinuxUi, ui::WindowButtonOrderObserver>
|
|
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_
|