qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Programmingkid <programmingkidx@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] Fixes fullscreen aspect ratio and leaving fullscreen mode problem on Mac OS X
Date: Mon, 29 Dec 2014 23:17:40 -0500	[thread overview]
Message-ID: <B85DFDA4-86C4-41AE-9389-91E6050D1962@gmail.com> (raw)

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 <programmingkidx@gmail.com>

From 5baa57950e03ed18afbb63b4b500bbde95baad5c Mon Sep 17 00:00:00 2001
From: John Arbuckle <programmingkidx@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 <programmingkidx@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

             reply	other threads:[~2014-12-30  4:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-30  4:17 Programmingkid [this message]
2014-12-31 23:19 ` [Qemu-devel] [PATCH] Fixes fullscreen aspect ratio and leaving fullscreen mode problem on Mac OS X Peter Maydell
2015-01-01 14:55 ` Peter Maydell
2015-01-01 16:05   ` Programmingkid
2015-01-01 16:48     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B85DFDA4-86C4-41AE-9389-91E6050D1962@gmail.com \
    --to=programmingkidx@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).