Commit 76f12cba authored by David Fuhrmann's avatar 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).
parent bda86a1b
<?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>
......
......@@ -317,6 +317,7 @@
1C88BC5619DC7C8100645190 /* ys-volume-slider-track_dark@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C88BBE419DC7C8100645190 /* ys-volume-slider-track_dark@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@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ys-volume-slider-track_dark@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;
};
......
......@@ -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
......@@ -29,13 +29,13 @@
#import "misc.h"
#import "Windows.h"
#import "VLCDefaultValueSlider.h"
#import "VLCFSPanelDraggableView.h"
@interface VLCFSPanelController : NSWindowController
@property (readwrite) NSWindow *voutWindow;
@property (readwrite, weak) NSTimer *hideTimer;
@property IBOutlet NSView *controlsView;
@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
......@@ -328,7 +328,7 @@
- (void)setVoutWasUpdated:(VLCWindow *)voutWindow
{
_voutWindow = voutWindow;
[_controlsView setLimitWindow:voutWindow];
int newDisplayID = [[self.window screen] displayID];
if (_displayID != newDisplayID) {
......
/*****************************************************************************
* 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>
@interface VLCFSPanelDraggableView : NSView
@property NSWindow *limitWindow;
@end
/*****************************************************************************
* 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"
@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];
}
}
@end
......@@ -334,7 +334,7 @@
- (BOOL)mouseDownCanMoveWindow
{
return YES;
return NO;
}
- (BOOL)acceptsFirstResponder
......
......@@ -802,6 +802,8 @@ void _drawFrameInRect(NSRect frameRect)
b_time_remaining = !b_time_remaining;
}
}
[[self nextResponder] mouseDown:ourEvent];
}
- (BOOL)timeRemaining
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment