aa23198ad8
* chore: in shell/renderer/renderer_client_base.h, remove include media/base/key_systems_support_registration.h
last use removed in c670e38b
(##41610)
* chore: iwyu electron/fuses.h
* chore: iwyu media/base/video_frame.h
* chore: iwyu base/functional/callback.h
* chore: iwyu base/task/cancelable_task_tracker.h
* chore: iwyu shell/browser/draggable_region_provider.h
* chore: iwyu shell/browser/ui/inspectable_web_contents_view.h
* chore: iwyu ui/aura/window.h
* chore: iwyu ui/base/win/shell.h
* chore: iwyu ui/display/win/screen_win.h
* chore: iwyu ui/gfx/geometry/insets.h
* chore: iwyu ui/display/display.h
* chore: iwyu ui/gfx/geometry/skia_conversions.h
* chore: iwyu ui/gfx/geometry/rect_conversions.h
* chore: iwyu ui/gfx/geometry/point.h
* chore: iwyu ui/gfx/scoped_canvas.h
* chore: iwyu ui/gfx/image/image.h
* chore: iwyu ui/accessibility/ax_node_data.h
* chore: iwyu ui/views/animation/ink_drop_highlight.h
* chore: iwyu ui/gfx/font_list.h
* chore: iwyu ui/linux/nav_button_provider.h
* chore: iwyu shell/browser/ui/views/frameless_view.h
* chore: iwyu services/metrics/public/cpp/ukm_source_id.h
* chore: iwyu net/http/http_util.h
* chore: iwyu net/base/mime_util.h
* chore: iwyu content/public/common/content_client.h
* chore: iwyu <list>
* chore: iwyu <optional>
* chore: iwyu <memory>
* chore: iwyu base/files/file_path.h
* chore: iwyu ui/base/cursor/cursor.h
* chore: iwyu build/build_config.h
* chore: iwyu content/public/browser/web_contents.h
* chore: iwyu shell/browser/hid/hid_chooser_context.h
* chore: iwyu shell/common/platform_util.h
* chore: iwyu base/task/single_thread_task_runner.h
* chore: iwyu content/browser/renderer_host/render_widget_host_impl.h
* chore: iwyu content/public/browser/render_widget_host.h
* chore: iwyu shell/browser/electron_browser_context.h
* chore: iwyu content/public/browser/web_contents_observer.h
* chore: iwyu content/public/browser/render_frame_host.h
* chore: iwyu content/public/browser/media_stream_request.h
* chore: iwyu chrome/common/chrome_paths.h
* chore: iwyu chrome/browser/icon_manager.h
* chore: iwyu printing/print_settings.h
* chore: iwyu renderer/pepper_helper.h
* chore: iwyu shell/browser/api/process_metric.h
* chore: iwyu shell/browser/electron_browser_client.h
* chore: iwyu shell/browser/electron_browser_context.h
* chore: iwyu shell/browser/api/electron_api_session.h
* chore: iwyu shell/browser/api/electron_api_app.h
* chore: iwyu shell/browser/ui/views/client_frame_view_linux.h
* chore: iwyu shell/browser/native_window_views.h
* chore: iwyu base/win/windows_version.h
* chore: iwyu shell/common/electron_paths.h
* chore: iwyu content/public/common/content_switches.h
* chore: iwyu third_party/skia/include/core/SkRRect.h
* chore: iwyu third_party/skia/include/core/SkBitmap.h
* chore: iwyu third_party/skia
* chore: iwyu shell/browser/osr/osr_host_display_client.h
* chore: iwyu shell/browser/login_handler.h
* chore: iwyu shell/browser/javascript_environment.h
* chore: iwyu shell/browser/event_emitter_mixin.h
* fix: mac
* fix: mac
* chore: iwyu base/nix/xdg_util.h
* fix: win
* fix: win
* fix: win
* fix: win
157 lines
5 KiB
C++
157 lines
5 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/memory/raw_ptr.h"
|
|
#include "base/memory/raw_ptr_exclusion.h"
|
|
#include "base/scoped_observation.h"
|
|
#include "shell/browser/ui/views/frameless_view.h"
|
|
#include "third_party/skia/include/core/SkRRect.h"
|
|
#include "ui/base/metadata/metadata_header_macros.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 NativeWindowViews;
|
|
|
|
class ClientFrameViewLinux : public FramelessView,
|
|
private ui::NativeThemeObserver,
|
|
private ui::WindowButtonOrderObserver {
|
|
METADATA_HEADER(ClientFrameViewLinux, FramelessView)
|
|
|
|
public:
|
|
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;
|
|
int GetTranslucentTopAreaHeight() 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 views::SizeBounds& available_size) const override;
|
|
gfx::Size GetMinimumSize() const override;
|
|
gfx::Size GetMaximumSize() const override;
|
|
void Layout(PassKey) override;
|
|
void OnPaint(gfx::Canvas* canvas) override;
|
|
|
|
// Overridden from views::ViewTargeterDelegate
|
|
views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override;
|
|
|
|
ui::WindowFrameProvider* GetFrameProvider() const;
|
|
|
|
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;
|
|
RAW_PTR_EXCLUSION 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;
|
|
|
|
raw_ptr<ui::NativeTheme> theme_;
|
|
ThemeValues theme_values_;
|
|
|
|
RAW_PTR_EXCLUSION 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;
|
|
|
|
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_
|