diff mbox

Makes -full-screen option work on Mac OS X

Message ID 60B7B5DB-1DEE-4FA3-B97A-6695746EA427@gmail.com
State New
Headers show

Commit Message

Programmingkid Jan. 12, 2015, 12:31 a.m. UTC
This patch makes the -full-screen option work under Mac OS X. 

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>

---
 ui/cocoa.m |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

Comments

Peter Maydell Jan. 12, 2015, 4:10 p.m. UTC | #1
On 12 January 2015 at 00:31, Programmingkid <programmingkidx@gmail.com> wrote:
> This patch makes the -full-screen option work under Mac OS X.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>

> +// Looks for the -full-screen option being sent to QEMU
> +static void scanForFullScreenOption(int argc, char * argv[])
> +{
> + set_to_full_screen = false;
> +
> + // search for the -full-screen option
> + for(int i = 0; i < argc; i++) {
> +     if(strcmp(argv[i], "-full-screen") == 0) {
> +         set_to_full_screen = true;
> +            break;
> +     }
> + }
> +}

Why do we need to do this rather than just honouring the
full_screen parameter passed into cocoa_display_init() ?

thanks
-- PMM
Programmingkid Jan. 12, 2015, 4:16 p.m. UTC | #2
On Jan 12, 2015, at 11:10 AM, Peter Maydell wrote:

> On 12 January 2015 at 00:31, Programmingkid <programmingkidx@gmail.com> wrote:
>> This patch makes the -full-screen option work under Mac OS X.
>> 
>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> 
>> +// Looks for the -full-screen option being sent to QEMU
>> +static void scanForFullScreenOption(int argc, char * argv[])
>> +{
>> + set_to_full_screen = false;
>> +
>> + // search for the -full-screen option
>> + for(int i = 0; i < argc; i++) {
>> +     if(strcmp(argv[i], "-full-screen") == 0) {
>> +         set_to_full_screen = true;
>> +            break;
>> +     }
>> + }
>> +}
> 
> Why do we need to do this rather than just honouring the
> full_screen parameter passed into cocoa_display_init() ?

Didn't know about this variable. Will make a new patch that eliminates unneeded code. Thanks.
diff mbox

Patch

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 685081e..3a70cfc 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -67,6 +67,7 @@  char **gArgv;
 /* bitmap_info is used in drawRect:. Starts with little endian format. */
 static int bitmap_info = kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst;
 SInt32 current_mac_os_version;
+bool set_to_full_screen;

 // keymap conversion
 int keymap[] =
@@ -252,6 +253,20 @@  static void determineMacOSVersion()
     }
 }
 
+// Looks for the -full-screen option being sent to QEMU
+static void scanForFullScreenOption(int argc, char * argv[])
+{
+	set_to_full_screen = false;
+
+	// search for the -full-screen option
+	for(int i = 0; i < argc; i++) {
+	    if(strcmp(argv[i], "-full-screen") == 0) {
+	        set_to_full_screen = true;
+            break;
+	    }
+	}
+}
+
 /*
  ------------------------------------------------------
     QemuCocoaView
@@ -911,6 +926,12 @@  QemuCocoaView *cocoaView;
               didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL];
 #endif
     } else {
+        /* for activating full screen at launch */
+        if (set_to_full_screen == true) {
+            [NSApp activateIgnoringOtherApps: YES];
+            [self toggleFullScreen: nil];
+        }
+
         // or launch QEMU, with the global args
         [self startEmulationWithArgc:gArgc argv:(char **)gArgv];
     }
@@ -1002,6 +1023,8 @@  int main (int argc, const char * argv[]) {
     gArgv = (char **)argv;
     int i;
 
+    scanForFullScreenOption(argc, argv);
+
     /* In case we don't need to display a window, let's not do that */
     for (i = 1; i < argc; i++) {
         const char *opt = argv[i];