Skip to content

Conversation

ckerr
Copy link
Member

@ckerr ckerr commented May 16, 2025

Description of Change

This is part of a series to update the lifecycle of NativeWindow::widget_ to use non-deprecated views API, e.g. using views::Widget::MakeCloseSynchronous().

There's a lot of work to do first though. For example, we have a lot of code that calls window->widget()->foo() and it's nontrivial to figure out which code paths will be reachable when widget() is nullptr after we make its destruction synchronous. So I'm going to remove some of the footguns by reducing public use of NativeWindow::widget().


This PR moves the implementation of api::BaseWindow::SetTitleBarOverlay() into a new method NativeWindowViews::SetTitleBarOverlay(). The main motivation to reduce public use of NativeWindow::widget(); but since code being moved fits better in NativeWindowViews, it improves data hiding in several ways:

  • api::BaseWindow no longer needs to call NativeWindow::widget()
  • NativeWindowViews::set_overlay_button_color() can be made private
  • NativeWindowVeiws::set_overlay_symbol_color() can be made private
  • NativeWindow::set_titlebar_overlay_height() can be made protected
  • Improved demeter. BaseWindow no longer needs to know about Widget internals, e.g. it no longer calls NativeWindow::widget()->non_client_view()->frame_view() and no longer needs to know what derived type it should use when downcasting that NonClientFrameView*.

Checklist

Release Notes

Notes: none.

ckerr added 3 commits May 16, 2025 00:43
refactor: make NativeWindowViews::set_overlay_symbol_color() private

refactor: make NativeWindow::set_titlebar_overlay_height() protected
@ckerr ckerr added semver/patch backwards-compatible bug fixes no-backport labels May 16, 2025
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label May 16, 2025
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label May 17, 2025
@codebytere codebytere self-requested a review May 17, 2025 09:01
@ckerr ckerr merged commit 687e50b into main May 19, 2025
63 checks passed
@ckerr ckerr deleted the refactor/add-NativeWindowViews.SetTitleBarOverlay() branch May 19, 2025 13:19
@release-clerk
Copy link

release-clerk bot commented May 19, 2025

No Release Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants