1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-26 01:23:17 +00:00

cocoa-cb: add pinch to resize window gesture

the event returns a delta ratio so we can just add it to the current
window-scale.

Adds support for #3214
This commit is contained in:
der richter 2020-01-22 17:04:33 +01:00
parent 2aa4186a25
commit 1dea80d3fd
2 changed files with 11 additions and 0 deletions

View File

@ -179,6 +179,11 @@ class EventsView: NSView {
}
}
override func magnify(with event: NSEvent) {
cocoaCB.layer?.inLiveResize = event.phase == .ended ? false : true
cocoaCB.window?.addWindowScale(Double(event.magnification))
}
func signalMouseDown(_ event: NSEvent) {
signalMouseEvent(event, MP_KEY_STATE_DOWN)
if event.clickCount > 1 {

View File

@ -461,6 +461,12 @@ class Window: NSWindow, NSWindowDelegate {
mpv?.command("set window-scale \(scale)")
}
func addWindowScale(_ scale: Double) {
if !isInFullscreen {
mpv?.command("add window-scale \(scale)")
}
}
func windowDidChangeScreen(_ notification: Notification) {
if screen == nil {
return