[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 1/8] ui/cocoa: Remove the uses of full screen APIs
From: |
Gerd Hoffmann |
Subject: |
[PULL 1/8] ui/cocoa: Remove the uses of full screen APIs |
Date: |
Thu, 4 Mar 2021 09:36:58 +0100 |
From: Akihiko Odaki <akihiko.odaki@gmail.com>
The detections of [NSView -enterFullScreen:] and
[NSView -exitFullScreen:] were wrong. A detection is coded as:
[NSView respondsToSelector:@selector(exitFullScreenModeWithOptions:)]
but it should be:
[NSView instancesRespondToSelector:@selector(exitFullScreenModeWithOptions:)]
Because of those APIs were not detected, ui/cocoa always falled
back to a borderless window whose frame matches the screen to
implement fullscreen behavior.
The code using [NSView -enterFullScreen:] and
[NSView -exitFullScreen:] will be used if you fix the detections,
but its behavior is undesirable; the full screen view stretches
the video, changing the aspect ratio, even if zooming is disabled.
This change removes the code as it does nothing good.
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Message-Id: <20210220013138.51437-1-akihiko.odaki@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/cocoa.m | 41 +++++++++++++++--------------------------
1 file changed, 15 insertions(+), 26 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 0ef5fdf3b7a3..5ad44b84aaaf 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -585,37 +585,26 @@ QemuCocoaView *cocoaView;
isFullscreen = FALSE;
[self ungrabMouse];
[self setContentDimensions];
- if ([NSView
respondsToSelector:@selector(exitFullScreenModeWithOptions:)]) { // test if
"exitFullScreenModeWithOptions" is supported on host at runtime
- [self exitFullScreenModeWithOptions:nil];
- } else {
- [fullScreenWindow close];
- [normalWindow setContentView: self];
- [normalWindow makeKeyAndOrderFront: self];
- [NSMenu setMenuBarVisible:YES];
- }
+ [fullScreenWindow close];
+ [normalWindow setContentView: self];
+ [normalWindow makeKeyAndOrderFront: self];
+ [NSMenu setMenuBarVisible:YES];
} else { // switch from desktop to fullscreen
isFullscreen = TRUE;
[normalWindow orderOut: nil]; /* Hide the window */
[self grabMouse];
[self setContentDimensions];
- if ([NSView
respondsToSelector:@selector(enterFullScreenMode:withOptions:)]) { // test if
"enterFullScreenMode:withOptions" is supported on host at runtime
- [self enterFullScreenMode:[NSScreen mainScreen]
withOptions:[NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:NO], NSFullScreenModeAllScreens,
- [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber
numberWithBool:NO], kCGDisplayModeIsStretched, nil], NSFullScreenModeSetting,
- nil]];
- } else {
- [NSMenu setMenuBarVisible:NO];
- fullScreenWindow = [[NSWindow alloc]
initWithContentRect:[[NSScreen mainScreen] frame]
- styleMask:NSWindowStyleMaskBorderless
- backing:NSBackingStoreBuffered
- defer:NO];
- [fullScreenWindow setAcceptsMouseMovedEvents: YES];
- [fullScreenWindow setHasShadow:NO];
- [fullScreenWindow setBackgroundColor: [NSColor blackColor]];
- [self setFrame:NSMakeRect(cx, cy, cw, ch)];
- [[fullScreenWindow contentView] addSubview: self];
- [fullScreenWindow makeKeyAndOrderFront:self];
- }
+ [NSMenu setMenuBarVisible:NO];
+ fullScreenWindow = [[NSWindow alloc] initWithContentRect:[[NSScreen
mainScreen] frame]
+ styleMask:NSWindowStyleMaskBorderless
+ backing:NSBackingStoreBuffered
+ defer:NO];
+ [fullScreenWindow setAcceptsMouseMovedEvents: YES];
+ [fullScreenWindow setHasShadow:NO];
+ [fullScreenWindow setBackgroundColor: [NSColor blackColor]];
+ [self setFrame:NSMakeRect(cx, cy, cw, ch)];
+ [[fullScreenWindow contentView] addSubview: self];
+ [fullScreenWindow makeKeyAndOrderFront:self];
}
}
--
2.29.2
- [PULL 0/8] Ui 20210304 patches, Gerd Hoffmann, 2021/03/04
- [PULL 1/8] ui/cocoa: Remove the uses of full screen APIs,
Gerd Hoffmann <=
- [PULL 2/8] ui/gtk: vte: fix sending multiple characeters, Gerd Hoffmann, 2021/03/04
- [PULL 6/8] ui/console: Add placeholder flag to message surface, Gerd Hoffmann, 2021/03/04
- [PULL 3/8] ui/cocoa: Fix stride resolution of pixman image, Gerd Hoffmann, 2021/03/04
- [PULL 4/8] configure: Improve OpenGL dependency detections, Gerd Hoffmann, 2021/03/04
- [PULL 5/8] ui/cocoa: Replace fprintf with error_report, Gerd Hoffmann, 2021/03/04
- [PULL 7/8] ui/console: Pass placeholder surface to displays, Gerd Hoffmann, 2021/03/04
- [PULL 8/8] virtio-gpu: Do not distinguish the primary console, Gerd Hoffmann, 2021/03/04
- Re: [PULL 0/8] Ui 20210304 patches, Peter Maydell, 2021/03/05