[vlc-commits] [Git][videolan/vlc][master] macosx: Replace arbitrary delay with bounds change detection
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Jul 21 05:11:19 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
8fa23df2 by Bob Moriasi at 2025-07-21T04:52:59+00:00
macosx: Replace arbitrary delay with bounds change detection
- - - - -
1 changed file:
- modules/gui/macosx/windows/video/VLCMainVideoViewController.m
Changes:
=====================================
modules/gui/macosx/windows/video/VLCMainVideoViewController.m
=====================================
@@ -53,12 +53,15 @@
#import "private/PIPSPI.h"
@interface PIPVoutViewController : NSViewController
+ at property (nonatomic) NSRect previousBounds;
+ at property (nonatomic, copy) void (^boundsChangeHandler)(void);
@end
@implementation PIPVoutViewController
- (void)setView:(NSView *)view {
[super setView:view];
+ self.previousBounds = NSZeroRect;
}
- (void)viewDidLoad {
@@ -76,6 +79,23 @@
- (void)viewDidAppear {
[super viewDidAppear];
}
+
+- (void)viewDidLayout
+{
+ [super viewDidLayout];
+
+ NSRect currentBounds = self.view.bounds;
+ if (!NSIsEmptyRect(currentBounds) && !NSEqualRects(currentBounds, _previousBounds)) {
+ _previousBounds = currentBounds;
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ if (self.boundsChangeHandler) {
+ self.boundsChangeHandler();
+ self.boundsChangeHandler = nil;
+ }
+ });
+ }
+}
@end
@interface VLCMainVideoViewController() <PIPViewControllerDelegate>
@@ -540,7 +560,14 @@
}
vlc_mutex_unlock(&p_input->lock);
_pipViewController.title = window.title;
- [_pipViewController presentViewControllerAsPictureInPicture:_voutViewController];
+
+ __weak typeof(self) weakSelf = self;
+ _voutViewController.boundsChangeHandler = ^{
+ typeof(self) strongSelf = weakSelf;
+ if (strongSelf && strongSelf->_voutViewController.presentingViewController == nil) {
+ [strongSelf->_pipViewController presentViewControllerAsPictureInPicture:strongSelf->_voutViewController];
+ }
+ };
if ([window isKindOfClass:VLCLibraryWindow.class]) {
[self returnToLibrary:self];
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8fa23df284bf9a8eefb2095f794cc78de3a1a4e8
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8fa23df284bf9a8eefb2095f794cc78de3a1a4e8
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list