fix: ensure custom traffic lights float to top (#29663)

* fix: ensure custom traffic lights float to top

* chore: split into separate function
This commit is contained in:
Shelley Vohr
2021-06-14 02:36:15 +02:00
committed by GitHub
parent 72733bae8a
commit 46e7511af9
2 changed files with 16 additions and 5 deletions

View File

@@ -152,6 +152,9 @@ class NativeWindowMac : public NativeWindow,
void NotifyWindowWillEnterFullScreen();
void NotifyWindowWillLeaveFullScreen();
// Ensure the buttons view are always floated on the top.
void ReorderButtonsView();
// Cleanup observers when window is getting closed. Note that the destructor
// can be called much later after window gets closed, so we should not do
// cleanup in destructor.

View File

@@ -458,11 +458,8 @@ void NativeWindowMac::SetContentView(views::View* view) {
set_content_view(view);
root_view->AddChildView(content_view());
if (buttons_view_) {
// Ensure the buttons view are always floated on the top.
[buttons_view_ removeFromSuperview];
[[window_ contentView] addSubview:buttons_view_];
}
if (buttons_view_)
ReorderButtonsView();
root_view->Layout();
}
@@ -1143,6 +1140,8 @@ void NativeWindowMac::AddBrowserView(NativeBrowserView* view) {
}
[CATransaction commit];
ReorderButtonsView();
}
void NativeWindowMac::RemoveBrowserView(NativeBrowserView* view) {
@@ -1184,6 +1183,8 @@ void NativeWindowMac::SetTopBrowserView(NativeBrowserView* view) {
}
[CATransaction commit];
ReorderButtonsView();
}
void NativeWindowMac::SetParentWindow(NativeWindow* parent) {
@@ -1636,6 +1637,13 @@ void NativeWindowMac::NotifyWindowWillLeaveFullScreen() {
UpdateVibrancyRadii(false);
}
void NativeWindowMac::ReorderButtonsView() {
if (buttons_view_) {
[buttons_view_ removeFromSuperview];
[[window_ contentView] addSubview:buttons_view_];
}
}
void NativeWindowMac::Cleanup() {
DCHECK(!IsClosed());
ui::NativeTheme::GetInstanceForNativeUi()->RemoveObserver(this);