This patch fixes these problems for QEMU on Mac OS X: - fullscreen mode not having the correct aspect ratio - the inability to leave fullscreen mode
signed-off-by: John Arbuckle <programmingk...@gmail.com> From 5baa57950e03ed18afbb63b4b500bbde95baad5c Mon Sep 17 00:00:00 2001 From: John Arbuckle <programmingk...@gmail.com> Date: Mon, 29 Dec 2014 22:47:56 -0500 Subject: [PATCH] Fixes fullscreen aspect ratio and leaving fullscreen mode problem. signed-off-by: John Arbuckle <programmingk...@gmail.com> --- configure | 2 +- ui/cocoa.m | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/configure b/configure index cae588c..32d3d3f 100755 --- a/configure +++ b/configure @@ -611,7 +611,7 @@ Darwin) cocoa="yes" audio_drv_list="coreaudio" audio_possible_drivers="coreaudio sdl fmod" - LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS" + LDFLAGS="-framework CoreFoundation -framework IOKit -framework ApplicationServices $LDFLAGS" libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu" # Disable attempts to use ObjectiveC features in os/object.h since they # won't work when we're compiling with gcc as a C compiler. diff --git a/ui/cocoa.m b/ui/cocoa.m index d37c29b..d1bebb9 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -29,6 +29,7 @@ #include "ui/console.h" #include "ui/input.h" #include "sysemu/sysemu.h" +#import <ApplicationServices/ApplicationServices.h> #ifndef MAC_OS_X_VERSION_10_4 #define MAC_OS_X_VERSION_10_4 1040 @@ -482,8 +483,16 @@ QemuCocoaView *cocoaView; - (void) toggleFullScreen:(id)sender { COCOA_DEBUG("QemuCocoaView: toggleFullScreen\n"); - + static CFDictionaryRef original_mode; + + // initialize original_mode only once - before the resolution has been changed + if (!original_mode) { + original_mode = CGDisplayCurrentMode(kCGDirectMainDisplay); + } if (isFullscreen) { // switch from fullscreen to desktop + if (original_mode != nil) { + CGDisplaySwitchToMode(kCGDirectMainDisplay, original_mode); + } isFullscreen = FALSE; [self ungrabMouse]; [self setContentDimensions]; @@ -501,6 +510,12 @@ QemuCocoaView *cocoaView; } #endif } else { // switch from desktop to fullscreen + size_t desired_bit_depth = 32; + boolean_t exact_match; + CFDictionaryRef mode = CGDisplayBestModeForParameters(kCGDirectMainDisplay, desired_bit_depth, cw, ch, &exact_match); + if (mode != nil) { + CGDisplaySwitchToMode(kCGDirectMainDisplay, mode); + } isFullscreen = TRUE; [self grabMouse]; [self setContentDimensions]; @@ -561,7 +576,7 @@ QemuCocoaView *cocoaView; } // release Mouse grab when pressing ctrl+alt - if (!isFullscreen && ([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { + if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { [self ungrabMouse]; } break; -- 1.7.5.4