[vlc-commits] [Git][videolan/vlc][master] macosx: Stop performing custom actions on window zoom/minimize/close, handle normally
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed May 24 07:38:09 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
27f07461 by Claudio Cambra at 2023-05-24T07:21:29+00:00
macosx: Stop performing custom actions on window zoom/minimize/close, handle normally
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1 changed file:
- modules/gui/macosx/windows/video/VLCVideoWindowCommon.m
Changes:
=====================================
modules/gui/macosx/windows/video/VLCVideoWindowCommon.m
=====================================
@@ -70,9 +70,9 @@ NSString *VLCWindowShouldShowController = @"VLCWindowShouldShowController";
BOOL _preFullScreenVideoViewLibraryControlsDisplayed;
}
-- (void)customZoom:(id)sender;
- (void)hasBecomeFullscreen;
- (void)hasEndedFullscreen;
+
@end
@implementation VLCVideoWindowCommon
@@ -171,149 +171,6 @@ NSString *VLCWindowShouldShowController = @"VLCWindowShouldShowController";
[super setTitle: title];
}
-#pragma mark -
-#pragma mark zoom / minimize / close
-
-- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
-{
- SEL s_menuAction = [menuItem action];
-
- if ((s_menuAction == @selector(performClose:)) || (s_menuAction == @selector(performMiniaturize:)) || (s_menuAction == @selector(performZoom:)))
- return YES;
-
- return [super validateMenuItem:menuItem];
-}
-
-- (BOOL)windowShouldClose:(id)sender
-{
- return YES;
-}
-
-- (void)performClose:(id)sender
-{
- if (!([self styleMask] & NSTitledWindowMask)) {
- [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowWillCloseNotification object:self];
-
- [self close];
- } else
- [super performClose: sender];
-}
-
-- (void)performMiniaturize:(id)sender
-{
- if (!([self styleMask] & NSTitledWindowMask))
- [self miniaturize: sender];
- else
- [super performMiniaturize: sender];
-}
-
-- (void)performZoom:(id)sender
-{
- if (!([self styleMask] & NSTitledWindowMask))
- [self customZoom: sender];
- else
- [super performZoom: sender];
-}
-
-- (void)zoom:(id)sender
-{
- if (!([self styleMask] & NSTitledWindowMask))
- [self customZoom: sender];
- else
- [super zoom: sender];
-}
-
-/**
- * Given a proposed frame rectangle, return a modified version
- * which will fit inside the screen.
- *
- * This method is based upon NSWindow.m, part of the GNUstep GUI Library, licensed under LGPLv2+.
- * Authors: Scott Christley <scottc at net-community.com>, Venkat Ajjanagadde <venkat at ocbi.com>,
- * Felipe A. Rodriguez <far at ix.netcom.com>, Richard Frith-Macdonald <richard at brainstorm.co.uk>
- * Copyright (C) 1996 Free Software Foundation, Inc.
- */
-- (NSRect) customConstrainFrameRect: (NSRect)frameRect toScreen: (NSScreen*)screen
-{
- NSRect screenRect = [screen visibleFrame];
- CGFloat difference;
-
- /* Move top edge of the window inside the screen */
- difference = NSMaxY (frameRect) - NSMaxY (screenRect);
- if (difference > 0) {
- frameRect.origin.y -= difference;
- }
-
- /* If the window is resizable, resize it (if needed) so that the
- bottom edge is on the screen or can be on the screen when the user moves
- the window */
- difference = NSMaxY (screenRect) - NSMaxY (frameRect);
- if (self.styleMask & NSResizableWindowMask) {
- CGFloat difference2;
-
- difference2 = screenRect.origin.y - frameRect.origin.y;
- difference2 -= difference;
- // Take in account the space between the top of window and the top of the
- // screen which can be used to move the bottom of the window on the screen
- if (difference2 > 0) {
- frameRect.size.height -= difference2;
- frameRect.origin.y += difference2;
- }
-
- /* Ensure that resizing doesn't makewindow smaller than minimum */
- difference2 = [self minSize].height - frameRect.size.height;
- if (difference2 > 0) {
- frameRect.size.height += difference2;
- frameRect.origin.y -= difference2;
- }
- }
-
- return frameRect;
-}
-
-#define DIST 3
-
-/**
- Zooms the receiver. This method calls the delegate method
- windowShouldZoom:toFrame: to determine if the window should
- be allowed to zoom to full screen.
- *
- * This method is based upon NSWindow.m, part of the GNUstep GUI Library, licensed under LGPLv2+.
- * Authors: Scott Christley <scottc at net-community.com>, Venkat Ajjanagadde <venkat at ocbi.com>,
- * Felipe A. Rodriguez <far at ix.netcom.com>, Richard Frith-Macdonald <richard at brainstorm.co.uk>
- * Copyright (C) 1996 Free Software Foundation, Inc.
- */
-- (void) customZoom: (id)sender
-{
- NSRect maxRect = [[self screen] visibleFrame];
- NSRect currentFrame = [self frame];
-
- if ([[self delegate] respondsToSelector: @selector(windowWillUseStandardFrame:defaultFrame:)]) {
- maxRect = [[self delegate] windowWillUseStandardFrame: self defaultFrame: maxRect];
- }
-
- maxRect = [self customConstrainFrameRect: maxRect toScreen: [self screen]];
-
- // Compare the new frame with the current one
- if ((fabs(NSMaxX(maxRect) - NSMaxX(currentFrame)) < DIST)
- && (fabs(NSMaxY(maxRect) - NSMaxY(currentFrame)) < DIST)
- && (fabs(NSMinX(maxRect) - NSMinX(currentFrame)) < DIST)
- && (fabs(NSMinY(maxRect) - NSMinY(currentFrame)) < DIST)) {
- // Already in zoomed mode, reset user frame, if stored
- if ([self frameAutosaveName] != nil) {
- [self setFrame: self.previousSavedFrame display: YES animate: YES];
- [self saveFrameUsingName: [self frameAutosaveName]];
- }
- return;
- }
-
- if ([self frameAutosaveName] != nil) {
- [self saveFrameUsingName: [self frameAutosaveName]];
- self.previousSavedFrame = [self frame];
- }
-
- [self setFrame: maxRect display: YES animate: YES];
-}
-
# pragma mark -
# pragma mark Window level handling
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/27f07461be1511f0a64632f80dba6d644851861e
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/27f07461be1511f0a64632f80dba6d644851861e
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