feat: enable Windows Control Overlay on Linux (#42682)

* feat: enable Windows Control Overlay on Linux

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* docs: update documentation for Linux WCO

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: initial symbol painting

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* test: enable WCO tests for Linux

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: add missing Layer include

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: fix gn-check failure

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: enable BrowserWindow.setTitleBarOverlay on Linux

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* test: fix test for maximize event on Linux

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: geometry updating on BrowserWindow.setTitleBarOverlay

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: crash when invalid titleBarStyle set

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: clean up ordering and comments

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* Update docs/api/structures/base-window-options.md

Co-authored-by: Erick Zhao <erick@hotmail.ca>

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* feat: enable customizing symbolColor

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* docs: correct symbolColor reference

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: update patches

Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>

* chore: remove Chrome-specific padding

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
This commit is contained in:
trop[bot] 2024-07-03 16:09:12 -04:00 committed by GitHub
parent 89d09922f7
commit 342ef8e7e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 1026 additions and 107 deletions

View file

@ -40,6 +40,8 @@
#include "shell/browser/ui/views/win_frame_view.h"
#include "shell/browser/ui/win/taskbar_host.h"
#include "ui/base/win/shell.h"
#elif BUILDFLAG(IS_LINUX)
#include "shell/browser/ui/views/opaque_frame_view.h"
#endif
#if BUILDFLAG(IS_WIN)
@ -1041,11 +1043,13 @@ void BaseWindow::SetAppDetails(const gin_helper::Dictionary& options) {
relaunch_command, relaunch_display_name,
window_->GetAcceleratedWidget());
}
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
void BaseWindow::SetTitleBarOverlay(const gin_helper::Dictionary& options,
gin_helper::Arguments* args) {
// Ensure WCO is already enabled on this window
if (!window_->titlebar_overlay_enabled()) {
if (!window_->IsWindowControlsOverlayEnabled()) {
args->ThrowError("Titlebar overlay is not enabled");
return;
}
@ -1090,13 +1094,18 @@ void BaseWindow::SetTitleBarOverlay(const gin_helper::Dictionary& options,
updated = true;
}
// If anything was updated, invalidate the layout and schedule a paint of the
// window's frame view
if (updated) {
auto* frame_view = static_cast<WinFrameView*>(
window->widget()->non_client_view()->frame_view());
frame_view->InvalidateCaptionButtons();
}
if (!updated)
return;
// If anything was updated, ensure the overlay is repainted.
#if BUILDFLAG(IS_WIN)
auto* frame_view = static_cast<WinFrameView*>(
window->widget()->non_client_view()->frame_view());
#else
auto* frame_view = static_cast<OpaqueFrameView*>(
window->widget()->non_client_view()->frame_view());
#endif
frame_view->InvalidateCaptionButtons();
}
#endif
@ -1286,6 +1295,8 @@ void BaseWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setThumbnailClip", &BaseWindow::SetThumbnailClip)
.SetMethod("setThumbnailToolTip", &BaseWindow::SetThumbnailToolTip)
.SetMethod("setAppDetails", &BaseWindow::SetAppDetails)
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
.SetMethod("setTitleBarOverlay", &BaseWindow::SetTitleBarOverlay)
#endif
.SetProperty("id", &BaseWindow::GetID);

View file

@ -241,6 +241,9 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
bool SetThumbnailClip(const gfx::Rect& region);
bool SetThumbnailToolTip(const std::string& tooltip);
void SetAppDetails(const gin_helper::Dictionary& options);
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
void SetTitleBarOverlay(const gin_helper::Dictionary& options,
gin_helper::Arguments* args);
#endif