Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure custom traffic lights float to top #29628

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions shell/browser/native_window_mac.h
Expand Up @@ -155,6 +155,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.
Expand Down
18 changes: 13 additions & 5 deletions shell/browser/native_window_mac.mm
Expand Up @@ -460,11 +460,8 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
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();
}
Expand Down Expand Up @@ -1150,6 +1147,8 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
}

[CATransaction commit];

ReorderButtonsView();
}

void NativeWindowMac::RemoveBrowserView(NativeBrowserView* view) {
Expand Down Expand Up @@ -1191,6 +1190,8 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
}

[CATransaction commit];

ReorderButtonsView();
}

void NativeWindowMac::SetParentWindow(NativeWindow* parent) {
Expand Down Expand Up @@ -1653,6 +1654,13 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
return is_active_;
}

void NativeWindowMac::ReorderButtonsView() {
if (buttons_view_) {
[buttons_view_ removeFromSuperview];
[[window_ contentView] addSubview:buttons_view_];
}
}

void NativeWindowMac::Cleanup() {
DCHECK(!IsClosed());
ui::NativeTheme::GetInstanceForNativeUi()->RemoveObserver(this);
Expand Down