aboutsummaryrefslogtreecommitdiffhomepage
path: root/video
diff options
context:
space:
mode:
authorGravatar Akemi <der.richter@gmx.de>2018-10-20 21:19:16 +0200
committerGravatar sfan5 <sfan5@live.de>2018-10-21 23:33:25 +0200
commit9a52b90f04597fb7ee3cbc806404ac0984ebd50d (patch)
tree6d83a1904cec6f8f03dc34fd4def23bf7b91a72c /video
parentf3098cd61b663d3368baf23299e7d1a530e6cec5 (diff)
cocoa-cb: fix double clicking the title bar
since we draw our own title bar we lose the standard functionality of the system provided title bar. because of that we have to reimplement the functionality of double clicking the title bar. depending on the system preferences we want to minimize, zoom or do nothing. Fixes #6223
Diffstat (limited to 'video')
-rw-r--r--video/out/cocoa-cb/window.swift30
1 files changed, 29 insertions, 1 deletions
diff --git a/video/out/cocoa-cb/window.swift b/video/out/cocoa-cb/window.swift
index b3e691b3a2..34a73f88d1 100644
--- a/video/out/cocoa-cb/window.swift
+++ b/video/out/cocoa-cb/window.swift
@@ -17,6 +17,31 @@
import Cocoa
+class CustomTtitleBar: NSVisualEffectView {
+
+ // catch these events so they are not propagated to the underlying view
+ override func mouseDown(with event: NSEvent) { }
+
+ override func mouseUp(with event: NSEvent) {
+ if event.clickCount > 1 {
+ let def = UserDefaults.standard
+ var action = def.string(forKey: "AppleActionOnDoubleClick")
+
+ // macOS 10.10 and earlier
+ if action == nil {
+ action = def.bool(forKey: "AppleMiniaturizeOnDoubleClick") == true ?
+ "Minimize" : "Maximize"
+ }
+
+ if action == "Minimize" {
+ window!.miniaturize(self)
+ } else if action == "Maximize" {
+ window!.zoom(self)
+ }
+ }
+ }
+}
+
class Window: NSWindow, NSWindowDelegate {
weak var cocoaCB: CocoaCB! = nil
@@ -113,7 +138,7 @@ class Window: NSWindow, NSWindowDelegate {
styleMask.insert(.fullSizeContentView)
titleBar.alphaValue = 0
titlebarAppearsTransparent = true
- titleBarEffect = NSVisualEffectView(frame: f)
+ titleBarEffect = CustomTtitleBar(frame: f)
titleBarEffect!.alphaValue = 0
titleBarEffect!.blendingMode = .withinWindow
titleBarEffect!.autoresizingMask = [.viewWidthSizable, .viewMinYMargin]
@@ -179,6 +204,7 @@ class Window: NSWindow, NSWindowDelegate {
titleBar.animator().alphaValue = 1
if !isInFullscreen && !isAnimating {
titleBarEffect!.animator().alphaValue = 1
+ titleBarEffect!.isHidden = false
}
}, completionHandler: nil )
@@ -193,6 +219,7 @@ class Window: NSWindow, NSWindowDelegate {
if titleBarEffect == nil { return }
if isInFullscreen && !isAnimating {
titleBarEffect!.alphaValue = 0
+ titleBarEffect!.isHidden = true
return
}
NSAnimationContext.runAnimationGroup({ (context) -> Void in
@@ -201,6 +228,7 @@ class Window: NSWindow, NSWindowDelegate {
titleBarEffect!.animator().alphaValue = 0
}, completionHandler: {
self.titleButtons.forEach { $0.isHidden = true }
+ self.titleBarEffect!.isHidden = true
})
}