Skip to content

Refactor NativeWindow (Part 9): Use views::Widget on macOS - #12696

Merged
zcbenz merged 4 commits into
masterfrom
mac-use-widget
Apr 26, 2018
Merged

zcbenz merged 4 commits into
masterfrom
mac-use-widget

Conversation

@zcbenz

@zcbenz zcbenz commented Apr 24, 2018

Copy link
Copy Markdown
Contributor

This PR uses views::Widget to replace current manual creation of NSWindow, it would allow us to put arbitrary views::View inside TopLevelWindow on macOS.

To make the migration graceful, I'm still using our own logics for managing window's styles and states, so this change should have minimal affects on window's behaviors. But it can still cause quirks and regressions since Chromium is adding a lot of custom logics to NSWindow in views::Widget, please let me know if you noticed any quirk after this change.

@zcbenz
zcbenz requested a review from a team April 24, 2018 11:30

options.Get(options::kSimpleFullScreen, &always_simple_fullscreen_);
if (!has_frame() || use_content_size)
SetContentSize(gfx::Size(width, height));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change the semantic meaning of width and height to refer to the contents rather than the whole window (including the border)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The views::Widget forces setting window size with window borders, which is opposite to when we manually created NSWindow. So I need to replace SetSize with SetContentSize here, for frameless window both calls are the same.

base::scoped_nsobject<CALayer> background_layer([[CALayer alloc] init]);
[background_layer
setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
[[window_ contentView] setLayer:background_layer];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm curious, what happened without the CALayer set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without setting a layer we would have a black flash when showing window. Cocoa seems to behave differently when we have more than one views with layers.

Comment thread atom/browser/native_window_mac.mm Outdated
}

void NativeWindowMac::DeleteDelegate() {
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is this called (and do we need to do anything here)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not really needed, I'll remove it.

// on the fly.
// TODO(zcbenz): Add interface in NativeWidgetMac to allow overriding creating
// window delegate.
views::BridgedNativeWidget* bridget_view =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bridged_view?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants