mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
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:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user