From patchwork Tue Dec 30 04:17:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 424540 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 020651400A0 for ; Tue, 30 Dec 2014 15:18:11 +1100 (AEDT) Received: from localhost ([::1]:35586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y5oFz-0004rU-Pc for incoming@patchwork.ozlabs.org; Mon, 29 Dec 2014 23:18:07 -0500 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; bh=pEBHsnVRLB8AuzM0WwBycj+rR9IJPyKbBGmhku79Wu4=; b=sfK07FmSbLU3QwgwLhXM15dGJd3czeZ/b+DBndzQ+oZhGoFkxm3pNm1716Q3MPtJan 2ibfdoJMcLFPWZ6ZmMJfnzxoUpNeNkQcCVcl1C8f1n1OpxNOyCP7SyC/RI2oejy/ix+l DGO99pmBUuMJyKlfz/SdmSKqsEzCASZ9NrlIE/BinVpotYPqutA+wGJ2Ga2yPrX7/plo e8x5Avgvh4JPgbY5sUJbPtuWGwSx/LZu3ZEflCuti/ULyLS40qtTIQc0l3OFyxhzf9iE 1DGwuRxCAVX/l/7GLeUlho/xuSi5qSfnjXubTzAyXtEOjjCBc+EJFnr75BS+/VaAXtHy FcFQ== X-Received: by 10.140.28.200 with SMTP id 66mr76354385qgz.16.1419913063212; Mon, 29 Dec 2014 20:17:43 -0800 (PST) Received: from [192.168.0.2] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by mx.google.com with ESMTPSA id r12sm35205459qax.38.2014.12.29.20.17.41 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Dec 2014 20:17:42 -0800 (PST) From: Programmingkid Date: Mon, 29 Dec 2014 23:17:40 -0500 Message-Id: To: Peter Maydell Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c01::234 Cc: qemu-devel qemu-devel Subject: [Qemu-devel] [PATCH] Fixes fullscreen aspect ratio and leaving fullscreen mode problem on Mac OS X X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 From 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="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 #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;