mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
subclass windows in macos so they can be made resizable even with no decorations (#408)
* make windows without decorations resizable and movable in macos
fixes #368
The subclassing logic was copied from servo's fork of glutin:
63026a0f4c/src/api/cocoa/mod.rs (L418)
* remove `isMovableByWindowBackground` and `mouseDownCanMoveWindow`
* revert example changes
* remove resizable mask from decoration: false
* avoid duplicate class declarations
* update changelog
* fix changelog
* changelog whitespace
This commit is contained in:
parent
0b922ad9c0
commit
be6d2ed3b9
|
@ -1,5 +1,7 @@
|
|||
# Unreleased
|
||||
|
||||
- Added subclass to macos windows so they can be made resizable even with no decorations.
|
||||
|
||||
# Version 0.11.3 (2018-03-28)
|
||||
|
||||
- Added `set_min_dimensions` and `set_max_dimensions` methods to `Window`, and implemented on Windows, X11, Wayland, and OSX.
|
||||
|
|
|
@ -414,10 +414,7 @@ impl Window2 {
|
|||
NSWindowStyleMask::NSTitledWindowMask
|
||||
} else if !attrs.decorations {
|
||||
// Window2 without a titlebar
|
||||
NSWindowStyleMask::NSClosableWindowMask |
|
||||
NSWindowStyleMask::NSMiniaturizableWindowMask |
|
||||
NSWindowStyleMask::NSResizableWindowMask |
|
||||
NSWindowStyleMask::NSFullSizeContentViewWindowMask
|
||||
NSWindowStyleMask::NSBorderlessWindowMask
|
||||
} else if pl_attrs.titlebar_hidden {
|
||||
NSWindowStyleMask::NSBorderlessWindowMask |
|
||||
NSWindowStyleMask::NSResizableWindowMask
|
||||
|
@ -442,7 +439,18 @@ impl Window2 {
|
|||
NSWindowStyleMask::NSTitledWindowMask
|
||||
};
|
||||
|
||||
let window = IdRef::new(NSWindow::alloc(nil).initWithContentRect_styleMask_backing_defer_(
|
||||
let winit_window = Class::get("WinitWindow").unwrap_or_else(|| {
|
||||
let window_superclass = Class::get("NSWindow").unwrap();
|
||||
let mut decl = ClassDecl::new("WinitWindow", window_superclass).unwrap();
|
||||
decl.add_method(sel!(canBecomeMainWindow), yes as extern fn(&Object, Sel) -> BOOL);
|
||||
decl.add_method(sel!(canBecomeKeyWindow), yes as extern fn(&Object, Sel) -> BOOL);
|
||||
decl.register();
|
||||
Class::get("WinitWindow").unwrap()
|
||||
});
|
||||
|
||||
let window: id = msg_send![winit_window, alloc];
|
||||
|
||||
let window = IdRef::new(window.initWithContentRect_styleMask_backing_defer_(
|
||||
frame,
|
||||
masks,
|
||||
appkit::NSBackingStoreBuffered,
|
||||
|
@ -796,3 +804,7 @@ impl Clone for IdRef {
|
|||
IdRef(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
extern fn yes(_: &Object, _: Sel) -> BOOL {
|
||||
YES
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue