From eba888207e7cb6a6557ca98cc1c49efddf818c71 Mon Sep 17 00:00:00 2001 From: Joe Moon Date: Sun, 29 Apr 2018 15:51:57 -0700 Subject: [PATCH] macos platform attributes regression (#488) * macOS: fix regression in 03c3e794097676888234b3cc82c01228dcbe48c8 fixed !decorations case and refactored logic to be a little easier to read * fix default case to inlude closable mask * add comment to default case of macos platform attrs --- CHANGELOG.md | 1 + src/platform/macos/window.rs | 29 +++++++++++------------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc907c40..7bc0117e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased +- Fix `.with_decorations(false)` in macOS - On Mac, `NSWindow` and supporting objects might be alive long after they were `closed` which resulted in apps consuming more heap then needed. Mainly it was affecting multi window applications. Not expecting any user visible change of behaviour after the fix. - Fix regression of Window platform extensions for macOS where `NSFullSizeContentViewWindowMask` was not being correctly applied to `.fullsize_content_view`. - Corrected `get_position` on Windows to be relative to the screen rather than to the taskbar. diff --git a/src/platform/macos/window.rs b/src/platform/macos/window.rs index 6f2d00de..c9ff4917 100644 --- a/src/platform/macos/window.rs +++ b/src/platform/macos/window.rs @@ -719,33 +719,26 @@ impl Window2 { } }; - let masks = if pl_attrs.titlebar_hidden { + let mut masks = if !attrs.decorations && !screen.is_some() { + // unresizable Window2 without a titlebar or borders + // if decorations is set to false, ignore pl_attrs + NSWindowStyleMask::NSBorderlessWindowMask + } else if pl_attrs.titlebar_hidden { + // if the titlebar is hidden, ignore other pl_attrs NSWindowStyleMask::NSBorderlessWindowMask | NSWindowStyleMask::NSResizableWindowMask - } else if !pl_attrs.titlebar_transparent { - // Window2 with a titlebar - NSWindowStyleMask::NSClosableWindowMask | - NSWindowStyleMask::NSMiniaturizableWindowMask | - NSWindowStyleMask::NSResizableWindowMask | - NSWindowStyleMask::NSTitledWindowMask - } else if pl_attrs.fullsize_content_view { - // Window2 with a transparent titlebar and fullsize content view - NSWindowStyleMask::NSClosableWindowMask | - NSWindowStyleMask::NSMiniaturizableWindowMask | - NSWindowStyleMask::NSResizableWindowMask | - NSWindowStyleMask::NSTitledWindowMask | - NSWindowStyleMask::NSFullSizeContentViewWindowMask - } else if !attrs.decorations && !screen.is_some() { - // Window2 without a titlebar - NSWindowStyleMask::NSBorderlessWindowMask } else { - // Window2 with a transparent titlebar and regular content view + // default case, resizable window with titlebar and titlebar buttons NSWindowStyleMask::NSClosableWindowMask | NSWindowStyleMask::NSMiniaturizableWindowMask | NSWindowStyleMask::NSResizableWindowMask | NSWindowStyleMask::NSTitledWindowMask }; + if pl_attrs.fullsize_content_view { + masks = masks | NSWindowStyleMask::NSFullSizeContentViewWindowMask; + } + let winit_window = Window2::class(); let window: id = msg_send![winit_window, alloc];