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

Stop using NSFullSizeContentViewWindowMask to get borderless windows, because that disables the swap interval. #729

Closed

Conversation

pcwalton
Copy link
Contributor

This hack is very simple but a little evil. We get the superview of the
content view, which is the NSThemeFrame, and install an OpenGL context
into it. NSThemeFrame is a private class, but we never speak its
name, we get to it with public APIs, and we only call public NSView
APIs on it, so this seems OK in terms of being supported by Apple going
forward.

Additionally, we remove the standard window buttons so that they
disappear and the user can't click them. This can also be done using
public APIs.

The reason for using this hack as opposed to
NSFullSizeContentViewWindowMask is that the latter forces the window
to be Core Animation-backed, which results in us rendering to an off
screen surface. Not only does this inject another compositor into the
system, but it also results in us rendering to an off-screen surface,
disabling the swap interval.

This depends on a cocoa-rs upgrade to add a binding to the -[NSView superview] method.

Note that the top edge of the window is not rounded, although the shadow
is. Applications that wish to use this mode will need to round the top
edge themselves if they wish. (This is how Cocoa internally works:
rounding is done by the app, not the window manager.)

This should fix servo/servo#9431.

because that disables the swap interval.

This hack is very simple but a little evil. We get the superview of the
content view, which is the `NSThemeFrame`, and install an OpenGL context
into it.  `NSThemeFrame` is a private class, but we never speak its
name, we get to it with public APIs, and we only call public `NSView`
APIs on it, so this seems OK in terms of being supported by Apple going
forward.

Additionally, we remove the standard window buttons so that they
disappear and the user can't click them. This can also be done using
public APIs.

The reason for using this hack as opposed to
`NSFullSizeContentViewWindowMask` is that the latter forces the window
to be Core Animation-backed, which results in us rendering to an off
screen surface. Not only does this inject another compositor into the
system, but it also results in us rendering to an off-screen surface,
disabling the swap interval.

This depends on a `cocoa-rs` upgrade to add a binding to the `-[NSView
superview]` method.

Note that the top edge of the window is not rounded, although the shadow
is. Applications that wish to use this mode will need to round the top
edge themselves if they wish. (This is how Cocoa internally works:
rounding is done by the app, not the window manager.)

This should fix servo/servo#9431.
@@ -416,8 +416,7 @@ impl Window {
NSClosableWindowMask as NSUInteger |
NSMiniaturizableWindowMask as NSUInteger |
NSResizableWindowMask as NSUInteger |
NSTitledWindowMask as NSUInteger |
NSFullSizeContentViewWindowMask as NSUInteger
NSTitledWindowMask as NSUInteger,
Copy link
Contributor

Choose a reason for hiding this comment

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

Travis complains that this comma shouldn't be there.

@tomaka
Copy link
Contributor

tomaka commented Feb 29, 2016

I'm not qualified to review this! If someone who knows cocoa wants to have a look at it, that would be nice.
Otherwise I'm just going to be merge in a few days.

@paulrouget
Copy link
Contributor

This has been reviewed by someone who knows cocoa here: servo#68 (comment)

@goddessfreya
Copy link
Contributor

No longer relevant.

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

Successfully merging this pull request may close these issues.

With --no-native-titlebar, requestAnimationFrame runs at 500 FPS
4 participants