From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y5oFg-0004ZD-Nk for qemu-devel@nongnu.org; Mon, 29 Dec 2014 23:17:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y5oFc-0006pm-Mz for qemu-devel@nongnu.org; Mon, 29 Dec 2014 23:17:48 -0500 Received: from mail-qc0-x234.google.com ([2607:f8b0:400d:c01::234]:40604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y5oFc-0006pa-HC for qemu-devel@nongnu.org; Mon, 29 Dec 2014 23:17:44 -0500 Received: by mail-qc0-f180.google.com with SMTP id i8so10335727qcq.11 for ; Mon, 29 Dec 2014 20:17:43 -0800 (PST) From: Programmingkid Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Mon, 29 Dec 2014 23:17:40 -0500 Message-Id: Mime-Version: 1.0 (Apple Message framework v1084) Subject: [Qemu-devel] [PATCH] Fixes fullscreen aspect ratio and leaving fullscreen mode problem on Mac OS X List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel qemu-devel 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 =46rom 5baa57950e03ed18afbb63b4b500bbde95baad5c Mon Sep 17 00:00:00 2001 From: John Arbuckle 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 --- 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=3D"yes" audio_drv_list=3D"coreaudio" audio_possible_drivers=3D"coreaudio sdl fmod" - LDFLAGS=3D"-framework CoreFoundation -framework IOKit $LDFLAGS" + LDFLAGS=3D"-framework CoreFoundation -framework IOKit -framework = ApplicationServices $LDFLAGS" libs_softmmu=3D"-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 =20 #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 =3D CGDisplayCurrentMode(kCGDirectMainDisplay); + } if (isFullscreen) { // switch from fullscreen to desktop + if (original_mode !=3D nil) { + CGDisplaySwitchToMode(kCGDirectMainDisplay, original_mode); + } isFullscreen =3D FALSE; [self ungrabMouse]; [self setContentDimensions]; @@ -501,6 +510,12 @@ QemuCocoaView *cocoaView; } #endif } else { // switch from desktop to fullscreen + size_t desired_bit_depth =3D 32; + boolean_t exact_match; + CFDictionaryRef mode =3D = CGDisplayBestModeForParameters(kCGDirectMainDisplay, desired_bit_depth, = cw, ch, &exact_match); + if (mode !=3D nil) { + CGDisplaySwitchToMode(kCGDirectMainDisplay, mode); + } isFullscreen =3D TRUE; [self grabMouse]; [self setContentDimensions]; @@ -561,7 +576,7 @@ QemuCocoaView *cocoaView; } =20 // 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; --=20 1.7.5.4