2022-08-03 08:51:52 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: msizanoen1 <msizanoen@qtmlabs.xyz>
|
|
|
|
Date: Tue, 19 Jul 2022 05:11:06 +0200
|
|
|
|
Subject: Add maximized parameter to LinuxUI::GetWindowFrameProvider
|
|
|
|
|
|
|
|
This allows ClientFrameViewLinux to instruct the toolkit to draw the window
|
|
|
|
decorations in maximized mode where needed, preventing empty space caused
|
|
|
|
by decoration shadows and rounded titlebars around the window while maximized.
|
|
|
|
|
|
|
|
diff --git a/ui/gtk/gtk_ui.cc b/ui/gtk/gtk_ui.cc
|
2023-08-15 15:49:41 +00:00
|
|
|
index 45958eda0794f21a55bf80806d9e17002d246a24..4980bf9d0e25f4fcd718216ca195b7e8d51d721b 100644
|
2022-08-03 08:51:52 +00:00
|
|
|
--- a/ui/gtk/gtk_ui.cc
|
|
|
|
+++ b/ui/gtk/gtk_ui.cc
|
2023-08-15 15:49:41 +00:00
|
|
|
@@ -509,12 +509,13 @@ std::unique_ptr<ui::NavButtonProvider> GtkUi::CreateNavButtonProvider() {
|
2023-03-10 16:07:42 +00:00
|
|
|
return std::make_unique<gtk::NavButtonProviderGtk>();
|
2022-08-03 08:51:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-ui::WindowFrameProvider* GtkUi::GetWindowFrameProvider(bool solid_frame) {
|
|
|
|
+ui::WindowFrameProvider* GtkUi::GetWindowFrameProvider(bool solid_frame, bool maximized) {
|
|
|
|
auto& provider =
|
|
|
|
- solid_frame ? solid_frame_provider_ : transparent_frame_provider_;
|
2023-03-10 16:07:42 +00:00
|
|
|
- if (!provider) {
|
|
|
|
- provider = std::make_unique<gtk::WindowFrameProviderGtk>(solid_frame);
|
|
|
|
- }
|
2022-08-03 08:51:52 +00:00
|
|
|
+ maximized
|
|
|
|
+ ? (solid_frame ? solid_maximized_frame_provider_ : transparent_maximized_frame_provider_)
|
|
|
|
+ : (solid_frame ? solid_frame_provider_ : transparent_frame_provider_);
|
2023-03-10 16:07:42 +00:00
|
|
|
+ if (!provider)
|
2022-08-03 08:51:52 +00:00
|
|
|
+ provider = std::make_unique<gtk::WindowFrameProviderGtk>(solid_frame, maximized);
|
|
|
|
return provider.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/ui/gtk/gtk_ui.h b/ui/gtk/gtk_ui.h
|
2023-07-31 17:47:32 +00:00
|
|
|
index 53c02c50dac536af3f235a9d8192a92449acb9a6..5df5c3fdb62b6aa5c20715fa1d07033d0f36a23e 100644
|
2022-08-03 08:51:52 +00:00
|
|
|
--- a/ui/gtk/gtk_ui.h
|
|
|
|
+++ b/ui/gtk/gtk_ui.h
|
2023-07-31 17:47:32 +00:00
|
|
|
@@ -108,7 +108,7 @@ class GtkUi : public ui::LinuxUiAndTheme {
|
2022-08-03 08:51:52 +00:00
|
|
|
bool PreferDarkTheme() const override;
|
2023-07-31 17:47:32 +00:00
|
|
|
void SetDarkTheme(bool dark) override;
|
2022-08-03 08:51:52 +00:00
|
|
|
std::unique_ptr<ui::NavButtonProvider> CreateNavButtonProvider() override;
|
|
|
|
- ui::WindowFrameProvider* GetWindowFrameProvider(bool solid_frame) override;
|
|
|
|
+ ui::WindowFrameProvider* GetWindowFrameProvider(bool solid_frame, bool maximized) override;
|
2022-10-03 20:21:00 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
using TintMap = std::map<int, color_utils::HSL>;
|
2023-07-31 17:47:32 +00:00
|
|
|
@@ -200,6 +200,8 @@ class GtkUi : public ui::LinuxUiAndTheme {
|
2022-08-03 08:51:52 +00:00
|
|
|
// while Chrome is running.
|
|
|
|
std::unique_ptr<ui::WindowFrameProvider> solid_frame_provider_;
|
|
|
|
std::unique_ptr<ui::WindowFrameProvider> transparent_frame_provider_;
|
|
|
|
+ std::unique_ptr<ui::WindowFrameProvider> solid_maximized_frame_provider_;
|
|
|
|
+ std::unique_ptr<ui::WindowFrameProvider> transparent_maximized_frame_provider_;
|
2022-11-17 19:59:23 +00:00
|
|
|
|
|
|
|
// Objects to notify when the window frame button order changes.
|
|
|
|
base::ObserverList<ui::WindowButtonOrderObserver>::Unchecked
|
2022-08-03 08:51:52 +00:00
|
|
|
diff --git a/ui/gtk/window_frame_provider_gtk.cc b/ui/gtk/window_frame_provider_gtk.cc
|
2023-03-10 16:07:42 +00:00
|
|
|
index 1925c1a2763b8dd720f5d0a630bc98ec5d16b9a0..a4986477b46aef555d526851cf191650d2972238 100644
|
2022-08-03 08:51:52 +00:00
|
|
|
--- a/ui/gtk/window_frame_provider_gtk.cc
|
|
|
|
+++ b/ui/gtk/window_frame_provider_gtk.cc
|
2023-01-06 02:35:34 +00:00
|
|
|
@@ -39,16 +39,18 @@ std::string GetThemeName() {
|
2022-08-03 08:51:52 +00:00
|
|
|
return theme_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
-GtkCssContext WindowContext(bool solid_frame, bool focused) {
|
|
|
|
+GtkCssContext WindowContext(bool solid_frame, bool maximized, bool focused) {
|
2023-03-10 16:07:42 +00:00
|
|
|
std::string selector = "window.background.";
|
2022-08-03 08:51:52 +00:00
|
|
|
selector += solid_frame ? "solid-csd" : "csd";
|
|
|
|
+ if (maximized)
|
|
|
|
+ selector += ".maximized";
|
|
|
|
if (!focused)
|
|
|
|
selector += ":inactive";
|
|
|
|
return AppendCssNodeToStyleContext({}, selector);
|
|
|
|
}
|
|
|
|
|
|
|
|
-GtkCssContext DecorationContext(bool solid_frame, bool focused) {
|
|
|
|
- auto context = WindowContext(solid_frame, focused);
|
|
|
|
+GtkCssContext DecorationContext(bool solid_frame, bool maximized, bool focused) {
|
|
|
|
+ auto context = WindowContext(solid_frame, maximized, focused);
|
|
|
|
// GTK4 renders the decoration directly on the window.
|
|
|
|
if (!GtkCheckVersion(4))
|
2023-03-10 16:07:42 +00:00
|
|
|
context = AppendCssNodeToStyleContext(context, "decoration");
|
2023-01-06 02:35:34 +00:00
|
|
|
@@ -65,8 +67,8 @@ GtkCssContext DecorationContext(bool solid_frame, bool focused) {
|
2022-08-03 08:51:52 +00:00
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
-GtkCssContext HeaderContext(bool solid_frame, bool focused) {
|
|
|
|
- auto context = WindowContext(solid_frame, focused);
|
|
|
|
+GtkCssContext HeaderContext(bool solid_frame, bool maximized, bool focused) {
|
|
|
|
+ auto context = WindowContext(solid_frame, maximized, focused);
|
|
|
|
context =
|
2023-03-10 16:07:42 +00:00
|
|
|
AppendCssNodeToStyleContext(context, "headerbar.header-bar.titlebar");
|
2022-08-03 08:51:52 +00:00
|
|
|
if (!focused)
|
2023-03-10 16:07:42 +00:00
|
|
|
@@ -121,8 +123,8 @@ int ComputeTopCornerRadius() {
|
2022-08-03 08:51:52 +00:00
|
|
|
// need to experimentally determine the corner radius by rendering a sample.
|
|
|
|
// Additionally, in GTK4, the headerbar corners get clipped by the window
|
|
|
|
// rather than the headerbar having its own rounded corners.
|
|
|
|
- auto context = GtkCheckVersion(4) ? DecorationContext(false, false)
|
|
|
|
- : HeaderContext(false, false);
|
|
|
|
+ auto context = GtkCheckVersion(4) ? DecorationContext(false, false, false)
|
|
|
|
+ : HeaderContext(false, false, false);
|
|
|
|
ApplyCssToContext(context, R"(window, headerbar {
|
|
|
|
background-image: none;
|
|
|
|
background-color: black;
|
2023-03-10 16:07:42 +00:00
|
|
|
@@ -155,7 +157,7 @@ int ComputeTopCornerRadius() {
|
2023-02-03 11:43:42 +00:00
|
|
|
bool HeaderIsTranslucent() {
|
|
|
|
// The arbitrary square size to render a sample header.
|
|
|
|
constexpr int kHeaderSize = 32;
|
|
|
|
- auto context = HeaderContext(false, false);
|
|
|
|
+ auto context = HeaderContext(false, false, false);
|
2023-03-10 16:07:42 +00:00
|
|
|
double opacity = 1.0f;
|
|
|
|
GtkStyleContextGet(context, "opacity", &opacity, nullptr);
|
|
|
|
if (opacity < 1.0f)
|
|
|
|
@@ -211,8 +213,8 @@ void WindowFrameProviderGtk::Asset::CloneFrom(
|
2022-08-03 08:51:52 +00:00
|
|
|
unfocused_bitmap = src.unfocused_bitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
-WindowFrameProviderGtk::WindowFrameProviderGtk(bool solid_frame)
|
|
|
|
- : solid_frame_(solid_frame) {}
|
|
|
|
+WindowFrameProviderGtk::WindowFrameProviderGtk(bool solid_frame, bool maximized)
|
|
|
|
+ : solid_frame_(solid_frame), maximized_(maximized) {}
|
|
|
|
|
|
|
|
WindowFrameProviderGtk::~WindowFrameProviderGtk() = default;
|
|
|
|
|
2023-03-10 16:07:42 +00:00
|
|
|
@@ -319,7 +321,7 @@ void WindowFrameProviderGtk::PaintWindowFrame(
|
2022-10-27 16:37:04 +00:00
|
|
|
top_area_height_dip * scale - effective_frame_thickness_px.top();
|
2022-08-03 08:51:52 +00:00
|
|
|
|
|
|
|
auto header = PaintHeaderbar({client_bounds_px.width(), top_area_height_px},
|
|
|
|
- HeaderContext(solid_frame_, focused), scale);
|
|
|
|
+ HeaderContext(solid_frame_, maximized_, focused), scale);
|
|
|
|
image = gfx::ImageSkia::CreateFrom1xBitmap(header);
|
|
|
|
// In GTK4, the headerbar gets clipped by the window.
|
|
|
|
if (GtkCheckVersion(4)) {
|
2023-03-10 16:07:42 +00:00
|
|
|
@@ -351,7 +353,7 @@ void WindowFrameProviderGtk::MaybeUpdateBitmaps(float scale) {
|
2022-08-03 08:51:52 +00:00
|
|
|
|
|
|
|
gfx::Rect frame_bounds_dip(kMaxFrameSizeDip, kMaxFrameSizeDip,
|
|
|
|
2 * kMaxFrameSizeDip, 2 * kMaxFrameSizeDip);
|
|
|
|
- auto focused_context = DecorationContext(solid_frame_, true);
|
|
|
|
+ auto focused_context = DecorationContext(solid_frame_, maximized_, true);
|
|
|
|
frame_bounds_dip.Inset(-GtkStyleContextGetPadding(focused_context));
|
|
|
|
frame_bounds_dip.Inset(-GtkStyleContextGetBorder(focused_context));
|
|
|
|
gfx::Size bitmap_size(BitmapSizePx(asset), BitmapSizePx(asset));
|
2023-03-10 16:07:42 +00:00
|
|
|
@@ -359,7 +361,7 @@ void WindowFrameProviderGtk::MaybeUpdateBitmaps(float scale) {
|
2022-08-03 08:51:52 +00:00
|
|
|
PaintBitmap(bitmap_size, frame_bounds_dip, focused_context, scale);
|
|
|
|
asset.unfocused_bitmap =
|
|
|
|
PaintBitmap(bitmap_size, frame_bounds_dip,
|
|
|
|
- DecorationContext(solid_frame_, false), scale);
|
|
|
|
+ DecorationContext(solid_frame_, maximized_, false), scale);
|
|
|
|
|
|
|
|
// In GTK4, there's no way to obtain the frame thickness from CSS values
|
|
|
|
// directly, so we must determine it experimentally based on the drawn
|
|
|
|
diff --git a/ui/gtk/window_frame_provider_gtk.h b/ui/gtk/window_frame_provider_gtk.h
|
2023-02-03 11:43:42 +00:00
|
|
|
index 32c3d63ae4598339965c58443a8c2d12b99fb89a..91496d957b8291cd37948e237a1cc4bf605848b0 100644
|
2022-08-03 08:51:52 +00:00
|
|
|
--- a/ui/gtk/window_frame_provider_gtk.h
|
|
|
|
+++ b/ui/gtk/window_frame_provider_gtk.h
|
|
|
|
@@ -14,7 +14,7 @@ namespace gtk {
|
|
|
|
|
|
|
|
class WindowFrameProviderGtk : public ui::WindowFrameProvider {
|
|
|
|
public:
|
|
|
|
- explicit WindowFrameProviderGtk(bool solid_frame);
|
|
|
|
+ explicit WindowFrameProviderGtk(bool solid_frame, bool maximized);
|
|
|
|
|
|
|
|
WindowFrameProviderGtk(const WindowFrameProviderGtk&) = delete;
|
|
|
|
WindowFrameProviderGtk& operator=(const WindowFrameProviderGtk&) = delete;
|
2023-02-03 11:43:42 +00:00
|
|
|
@@ -72,6 +72,9 @@ class WindowFrameProviderGtk : public ui::WindowFrameProvider {
|
2022-08-03 08:51:52 +00:00
|
|
|
|
|
|
|
// Cached bitmaps and metrics. The scale is rounded to percent.
|
|
|
|
base::flat_map<int, Asset> assets_;
|
|
|
|
+
|
|
|
|
+ // Whether to draw the window decorations as maximized.
|
|
|
|
+ bool maximized_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gtk
|
2023-03-10 16:07:42 +00:00
|
|
|
diff --git a/ui/linux/fallback_linux_ui.cc b/ui/linux/fallback_linux_ui.cc
|
2023-07-31 17:47:32 +00:00
|
|
|
index 6d77be047e202d1b1a75c62ab829dd1131ce7f68..ee1f503a679b3e939e3f2d2417aec2182063dbd8 100644
|
2023-03-10 16:07:42 +00:00
|
|
|
--- a/ui/linux/fallback_linux_ui.cc
|
|
|
|
+++ b/ui/linux/fallback_linux_ui.cc
|
2023-07-31 17:47:32 +00:00
|
|
|
@@ -135,7 +135,7 @@ FallbackLinuxUi::CreateNavButtonProvider() {
|
2023-03-10 16:07:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ui::WindowFrameProvider* FallbackLinuxUi::GetWindowFrameProvider(
|
|
|
|
- bool solid_frame) {
|
|
|
|
+ bool solid_frame, bool maximized) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/ui/linux/fallback_linux_ui.h b/ui/linux/fallback_linux_ui.h
|
2023-07-31 17:47:32 +00:00
|
|
|
index 9901d4939400da87610b1a960ca989eb9da6dc9b..035ab6679f9f6a9083382580bbbe7fa2420ab28d 100644
|
2023-03-10 16:07:42 +00:00
|
|
|
--- a/ui/linux/fallback_linux_ui.h
|
|
|
|
+++ b/ui/linux/fallback_linux_ui.h
|
|
|
|
@@ -67,7 +67,7 @@ class FallbackLinuxUi : public LinuxUiAndTheme {
|
|
|
|
bool PreferDarkTheme() const override;
|
2023-07-31 17:47:32 +00:00
|
|
|
void SetDarkTheme(bool dark) override;
|
2023-03-10 16:07:42 +00:00
|
|
|
std::unique_ptr<ui::NavButtonProvider> CreateNavButtonProvider() override;
|
|
|
|
- ui::WindowFrameProvider* GetWindowFrameProvider(bool solid_frame) override;
|
|
|
|
+ ui::WindowFrameProvider* GetWindowFrameProvider(bool solid_frame, bool maximized) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string default_font_family_;
|
2022-08-03 08:51:52 +00:00
|
|
|
diff --git a/ui/linux/linux_ui.h b/ui/linux/linux_ui.h
|
2023-07-31 17:47:32 +00:00
|
|
|
index a47134d7fa67213e8928ce98071f85fa1bc66508..2fe17292aee5021864615abc5b60ee38d7fa0e4b 100644
|
2022-08-03 08:51:52 +00:00
|
|
|
--- a/ui/linux/linux_ui.h
|
|
|
|
+++ b/ui/linux/linux_ui.h
|
2023-07-31 17:47:32 +00:00
|
|
|
@@ -313,7 +313,7 @@ class COMPONENT_EXPORT(LINUX_UI) LinuxUiTheme {
|
2022-08-03 08:51:52 +00:00
|
|
|
// if transparency is unsupported and the frame should be rendered opaque.
|
|
|
|
// The returned object is not owned by the caller and will remain alive until
|
|
|
|
// the process ends.
|
|
|
|
- virtual WindowFrameProvider* GetWindowFrameProvider(bool solid_frame) = 0;
|
|
|
|
+ virtual WindowFrameProvider* GetWindowFrameProvider(bool solid_frame, bool maximized) = 0;
|
|
|
|
|
2022-11-17 19:59:23 +00:00
|
|
|
protected:
|
|
|
|
LinuxUiTheme();
|