[vlc-commits] macosx: Limit fullscreen panel to video content area

David Fuhrmann git at videolan.org
Thu Jan 5 19:40:25 CET 2017


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Thu Jan  5 19:34:47 2017 +0100| [76f12cba4c4114e9e75faf6a5669938e86ce0994] | committer: David Fuhrmann

macosx: Limit fullscreen panel to video content area

Limit dragging / moving of fullscreen panel to video content area.
This forbids dragging the fspanel outside of fullscreen. Also make
sure that the fs panel stays inside the video view if dragged, in
case the video view is smaller then the complete screen (this can
happen with macOS split screen feature).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=76f12cba4c4114e9e75faf6a5669938e86ce0994
---

 .../Resources/English.lproj/VLCFullScreenPanel.xib |  8 +--
 .../package/macosx/vlc.xcodeproj/project.pbxproj   |  6 ++
 modules/gui/macosx/Makefile.am                     |  1 +
 modules/gui/macosx/VLCFSPanelController.h          |  6 +-
 modules/gui/macosx/VLCFSPanelController.m          |  2 +-
 modules/gui/macosx/VLCFSPanelDraggableView.h       | 31 ++++++++
 modules/gui/macosx/VLCFSPanelDraggableView.m       | 82 ++++++++++++++++++++++
 modules/gui/macosx/VLCVoutView.m                   |  2 +-
 modules/gui/macosx/misc.m                          |  2 +
 9 files changed, 130 insertions(+), 10 deletions(-)

diff --git a/extras/package/macosx/Resources/English.lproj/VLCFullScreenPanel.xib b/extras/package/macosx/Resources/English.lproj/VLCFullScreenPanel.xib
index a917607..d8dba5c 100644
--- a/extras/package/macosx/Resources/English.lproj/VLCFullScreenPanel.xib
+++ b/extras/package/macosx/Resources/English.lproj/VLCFullScreenPanel.xib
@@ -1,9 +1,9 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11761" systemVersion="16B2657" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11542" systemVersion="15G1212" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
         <development version="7000" identifier="xcode"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11761"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11542"/>
         <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
         <capability name="system font weights other than Regular or Bold" minToolsVersion="7.0"/>
     </dependencies>
@@ -35,7 +35,7 @@
             <rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
             <value key="minSize" type="size" width="480" height="60"/>
             <value key="maxSize" type="size" width="4068" height="90"/>
-            <view key="contentView" id="Npt-C5-K77">
+            <view key="contentView" id="Npt-C5-K77" customClass="VLCFSPanelDraggableView">
                 <rect key="frame" x="0.0" y="0.0" width="480" height="80"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
diff --git a/extras/package/macosx/vlc.xcodeproj/project.pbxproj b/extras/package/macosx/vlc.xcodeproj/project.pbxproj
index 962c48e..daddc6b 100644
--- a/extras/package/macosx/vlc.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/vlc.xcodeproj/project.pbxproj
@@ -317,6 +317,7 @@
 		1C88BC5619DC7C8100645190 /* ys-volume-slider-track_dark at 2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C88BBE419DC7C8100645190 /* ys-volume-slider-track_dark at 2x.png */; };
 		1C94659B1B77B9FC007C965A /* PopupPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1C9465971B77B9FC007C965A /* PopupPanel.xib */; };
 		1C94659C1B77B9FC007C965A /* TextfieldPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1C9465991B77B9FC007C965A /* TextfieldPanel.xib */; };
+		1CAEBC011E1EC0A400A99E49 /* VLCFSPanelDraggableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CAEBC001E1EC0A400A99E49 /* VLCFSPanelDraggableView.m */; };
 		1CBB2CC81B06A6DE00110ADA /* Help.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1CBB2CC61B06A6DE00110ADA /* Help.xib */; };
 		1CC25CA81B2C585D0003F994 /* darwinvlc.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CC25CA71B2C585D0003F994 /* darwinvlc.m */; };
 		1CC30CE81DC8D561001400E2 /* VLCFSPanelController.h in Sources */ = {isa = PBXBuildFile; fileRef = 6BCB59091DA247CD009BCA66 /* VLCFSPanelController.h */; };
@@ -1098,6 +1099,8 @@
 		1C88BBE419DC7C8100645190 /* ys-volume-slider-track_dark at 2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ys-volume-slider-track_dark at 2x.png"; sourceTree = "<group>"; };
 		1C9465981B77B9FC007C965A /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/PopupPanel.xib; sourceTree = "<group>"; };
 		1C94659A1B77B9FC007C965A /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/TextfieldPanel.xib; sourceTree = "<group>"; };
+		1CAEBBFF1E1EC0A400A99E49 /* VLCFSPanelDraggableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCFSPanelDraggableView.h; path = ../../../modules/gui/macosx/VLCFSPanelDraggableView.h; sourceTree = "<group>"; };
+		1CAEBC001E1EC0A400A99E49 /* VLCFSPanelDraggableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCFSPanelDraggableView.m; path = ../../../modules/gui/macosx/VLCFSPanelDraggableView.m; sourceTree = "<group>"; };
 		1CBB2CC71B06A6DE00110ADA /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/Help.xib; sourceTree = "<group>"; };
 		1CC25CA71B2C585D0003F994 /* darwinvlc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = darwinvlc.m; path = ../../../bin/darwinvlc.m; sourceTree = "<group>"; };
 		1CCB5F2F1A62A6A5004C3E90 /* pseudo-vlc.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "pseudo-vlc.app"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1705,6 +1708,8 @@
 				5CCED71314C0D4A90057F8D1 /* VLCExtensionsManager.m */,
 				6BCB59091DA247CD009BCA66 /* VLCFSPanelController.h */,
 				6BCB590A1DA247CD009BCA66 /* VLCFSPanelController.m */,
+				1CAEBBFF1E1EC0A400A99E49 /* VLCFSPanelDraggableView.h */,
+				1CAEBC001E1EC0A400A99E49 /* VLCFSPanelDraggableView.m */,
 				7D871D391B5E684D000B56C0 /* helpers.h */,
 				7DF812ED1B555A340052293C /* VLCInputManager.h */,
 				7DF812EE1B555A340052293C /* VLCInputManager.m */,
@@ -3641,6 +3646,7 @@
 				1CCB5FAB1A62A724004C3E90 /* SPMediaKeyTap.h in Sources */,
 				1C67C8A51D58C0980079E1C1 /* VLCHelpWindowController.m in Sources */,
 				1CCB5FAC1A62A724004C3E90 /* SPMediaKeyTap.m in Sources */,
+				1CAEBC011E1EC0A400A99E49 /* VLCFSPanelDraggableView.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index 9f5cc4f..7f581b7 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -89,5 +89,6 @@ libmacosx_plugin_la_SOURCES = \
 	VLCTrackSynchronizationWindowController.h VLCTrackSynchronizationWindowController.m \
 	VLCVideoEffectsWindowController.h VLCVideoEffectsWindowController.m \
 	VLCFSPanelController.h VLCFSPanelController.m \
+	VLCFSPanelDraggableView.h VLCFSPanelDraggableView.m \
 	VLCDefaultValueSlider.h VLCDefaultValueSlider.m \
 	VLCDefaultValueSliderCell.h VLCDefaultValueSliderCell.m
diff --git a/modules/gui/macosx/VLCFSPanelController.h b/modules/gui/macosx/VLCFSPanelController.h
index 070b42b..ee8ec95 100644
--- a/modules/gui/macosx/VLCFSPanelController.h
+++ b/modules/gui/macosx/VLCFSPanelController.h
@@ -29,13 +29,13 @@
 #import "misc.h"
 #import "Windows.h"
 #import "VLCDefaultValueSlider.h"
+#import "VLCFSPanelDraggableView.h"
 
 @interface VLCFSPanelController : NSWindowController
 
- at property (readwrite)       NSWindow  *voutWindow;
 @property (readwrite, weak) NSTimer   *hideTimer;
 
- at property IBOutlet NSView       *controlsView;
+ at property IBOutlet VLCFSPanelDraggableView *controlsView;
 @property IBOutlet NSButton     *playPauseButton;
 @property IBOutlet NSButton     *forwardButton;
 @property IBOutlet NSButton     *backwardButton;
@@ -73,7 +73,6 @@
 - (void)setPlay;
 - (void)setPause;
 
-
 /**
  Center the window on the specified screen in the lower third
 
@@ -83,5 +82,4 @@
  */
 - (void)centerWindowOnScreen:(CGDirectDisplayID)screenID;
 
-
 @end
diff --git a/modules/gui/macosx/VLCFSPanelController.m b/modules/gui/macosx/VLCFSPanelController.m
index e93347d..06b8181 100644
--- a/modules/gui/macosx/VLCFSPanelController.m
+++ b/modules/gui/macosx/VLCFSPanelController.m
@@ -328,7 +328,7 @@
 
 - (void)setVoutWasUpdated:(VLCWindow *)voutWindow
 {
-    _voutWindow = voutWindow;
+    [_controlsView setLimitWindow:voutWindow];
     int newDisplayID = [[self.window screen] displayID];
 
     if (_displayID != newDisplayID) {
diff --git a/modules/gui/macosx/VLCFSPanelDraggableView.h b/modules/gui/macosx/VLCFSPanelDraggableView.h
new file mode 100644
index 0000000..ceec719
--- /dev/null
+++ b/modules/gui/macosx/VLCFSPanelDraggableView.h
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * VLCFSPanelDraggableView.h
+ *****************************************************************************
+ * Copyright (C) 2017 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: David Fuhrmann <dfuhrmann at videolan dot org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+ at interface VLCFSPanelDraggableView : NSView
+
+ at property NSWindow     *limitWindow;
+
+ at end
+
diff --git a/modules/gui/macosx/VLCFSPanelDraggableView.m b/modules/gui/macosx/VLCFSPanelDraggableView.m
new file mode 100644
index 0000000..f257894
--- /dev/null
+++ b/modules/gui/macosx/VLCFSPanelDraggableView.m
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * VLCFSPanelDraggableView.m
+ *****************************************************************************
+ * Copyright (C) 2017 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: David Fuhrmann <dfuhrmann at videolan dot org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCFSPanelDraggableView.h"
+
+ at implementation VLCFSPanelDraggableView
+
+- (BOOL)mouseDownCanMoveWindow
+{
+    return NO;
+}
+
+- (void)mouseDown:(NSEvent *)event
+{
+    NSWindow *window = [self window];
+    NSRect mouseLocationInWindow = {[event locationInWindow], {0,0}};
+    NSPoint originalMouseLocation = [window convertRectToScreen:mouseLocationInWindow].origin;
+    NSRect originalFrame = [window frame];
+
+    while (YES)
+    {
+        // Get all dragged and mouse up events during dragging
+        NSEvent *newEvent = [window nextEventMatchingMask:(NSLeftMouseDraggedMask | NSLeftMouseUpMask)];
+
+        if ([newEvent type] == NSLeftMouseUp) {
+            break;
+        }
+
+        // Calculate delta of dragging
+        NSRect newMouseLocationInWindow = {[newEvent locationInWindow], {0,0}};
+        NSPoint newMouseLocation = [window convertRectToScreen:newMouseLocationInWindow].origin;
+        NSPoint delta = NSMakePoint(newMouseLocation.x - originalMouseLocation.x,
+                                    newMouseLocation.y - originalMouseLocation.y);
+
+        NSRect limitFrame = _limitWindow.frame;
+        NSRect newFrame = originalFrame;
+        newFrame.origin.x += delta.x;
+        newFrame.origin.y += delta.y;
+
+        // Limit rect to limitation view
+        if (newFrame.origin.x < limitFrame.origin.x)
+            newFrame.origin.x = limitFrame.origin.x;
+        if (newFrame.origin.y < limitFrame.origin.y)
+            newFrame.origin.y = limitFrame.origin.x;
+
+        // Limit size (could be needed after resolution changes)
+        if (newFrame.size.height > limitFrame.size.height)
+            newFrame.size.height = limitFrame.size.height;
+        if (newFrame.size.width > limitFrame.size.width)
+            newFrame.size.width = limitFrame.size.width;
+
+        if (newFrame.origin.x + newFrame.size.width > limitFrame.origin.x + limitFrame.size.width)
+            newFrame.origin.x = limitFrame.origin.x + limitFrame.size.width - newFrame.size.width;
+        if (newFrame.origin.y + newFrame.size.height > limitFrame.origin.y + limitFrame.size.height)
+            newFrame.origin.y = limitFrame.origin.y + limitFrame.size.height - newFrame.size.height;
+
+        [window setFrame:newFrame display:YES animate:NO];
+    }
+
+}
+
+ at end
diff --git a/modules/gui/macosx/VLCVoutView.m b/modules/gui/macosx/VLCVoutView.m
index c36b411..843bc91 100644
--- a/modules/gui/macosx/VLCVoutView.m
+++ b/modules/gui/macosx/VLCVoutView.m
@@ -334,7 +334,7 @@
 
 - (BOOL)mouseDownCanMoveWindow
 {
-    return YES;
+    return NO;
 }
 
 - (BOOL)acceptsFirstResponder
diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m
index e984113..f6084c8 100644
--- a/modules/gui/macosx/misc.m
+++ b/modules/gui/macosx/misc.m
@@ -802,6 +802,8 @@ void _drawFrameInRect(NSRect frameRect)
             b_time_remaining = !b_time_remaining;
         }
     }
+
+    [[self nextResponder] mouseDown:ourEvent];
 }
 
 - (BOOL)timeRemaining



More information about the vlc-commits mailing list