Patchwork [v2,RESEND,08/11] Cocoa: Don't unconditionally show the window

login
register
mail settings
Submitter Andreas Färber
Date Jan. 6, 2010, 10:47 p.m.
Message ID <1262818037-926-9-git-send-email-andreas.faerber@web.de>
Download mbox | patch
Permalink /patch/42354/
State New
Headers show

Comments

Andreas Färber - Jan. 6, 2010, 10:47 p.m.
When QEMU was launched in no-graphic, Curses or VNC mode,
don't run it as a Cocoa application.

Based on patch by Alexander Graf.

v1:
- Avoid type mismatch warning for argv
- Drop noCocoa variable
- Coding Style changes

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Cc: Alexander Graf <agraf@suse.de>
Cc: Mike Kronenberg <mike.kronenberg@kronenberg.org>
---
 cocoa.m |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
Alexander Graf - Jan. 6, 2010, 10:49 p.m.
On 06.01.2010, at 23:47, Andreas Färber wrote:

> When QEMU was launched in no-graphic, Curses or VNC mode,
> don't run it as a Cocoa application.
> 
> Based on patch by Alexander Graf.
> 
> v1:
> - Avoid type mismatch warning for argv
> - Drop noCocoa variable
> - Coding Style changes
> 
> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Mike Kronenberg <mike.kronenberg@kronenberg.org>
> ---
> cocoa.m |   10 ++++++++++
> 1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/cocoa.m b/cocoa.m
> index d5f941b..70c249b 100644
> --- a/cocoa.m
> +++ b/cocoa.m
> @@ -855,6 +855,16 @@ int main (int argc, const char * argv[]) {
>     gArgc = argc;
>     gArgv = (char **)argv;
>     CPSProcessSerNum PSN;
> +    int i;
> +
> +    /* In case we don't need to display a window, let's not do that */
> +    for (i = 1; i < argc; i++) {
> +        if (!strcmp(argv[i], "-vnc") ||
> +            !strcmp(argv[i], "-nographic") ||
> +            !strcmp(argv[i], "-curses")) {
> +                return qemu_main(gArgc, gArgv);
> +        }
> +    }

Hm, does that work with qemu -hda /tmp/bla.img -nographic?

Alex
Andreas Färber - Jan. 6, 2010, 11:18 p.m.
Am 06.01.2010 um 23:49 schrieb Alexander Graf:

>
> On 06.01.2010, at 23:47, Andreas Färber wrote:
>
>> When QEMU was launched in no-graphic, Curses or VNC mode,
>> don't run it as a Cocoa application.
>>
>> Based on patch by Alexander Graf.
>>
>> v1:
>> - Avoid type mismatch warning for argv
>> - Drop noCocoa variable
>> - Coding Style changes
>>
>> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
>> Cc: Alexander Graf <agraf@suse.de>
>> Cc: Mike Kronenberg <mike.kronenberg@kronenberg.org>
>> ---
>> cocoa.m |   10 ++++++++++
>> 1 files changed, 10 insertions(+), 0 deletions(-)
>>
>> diff --git a/cocoa.m b/cocoa.m
>> index d5f941b..70c249b 100644
>> --- a/cocoa.m
>> +++ b/cocoa.m
>> @@ -855,6 +855,16 @@ int main (int argc, const char * argv[]) {
>>    gArgc = argc;
>>    gArgv = (char **)argv;
>>    CPSProcessSerNum PSN;
>> +    int i;
>> +
>> +    /* In case we don't need to display a window, let's not do  
>> that */
>> +    for (i = 1; i < argc; i++) {
>> +        if (!strcmp(argv[i], "-vnc") ||
>> +            !strcmp(argv[i], "-nographic") ||
>> +            !strcmp(argv[i], "-curses")) {
>> +                return qemu_main(gArgc, gArgv);
>> +        }
>> +    }
>
> Hm, does that work with qemu -hda /tmp/bla.img -nographic?

Yes, your code! :) I just did the minor changes decribed unter v1.

I run Milax that way:
qemu-system-sparc64 -m 256 -boot d -cdrom milax032sparc.iso -nographic

Andreas
Alexander Graf - Jan. 6, 2010, 11:23 p.m.
On 07.01.2010, at 00:18, Andreas Färber wrote:

> 
> Am 06.01.2010 um 23:49 schrieb Alexander Graf:
> 
>> 
>> On 06.01.2010, at 23:47, Andreas Färber wrote:
>> 
>>> When QEMU was launched in no-graphic, Curses or VNC mode,
>>> don't run it as a Cocoa application.
>>> 
>>> Based on patch by Alexander Graf.
>>> 
>>> v1:
>>> - Avoid type mismatch warning for argv
>>> - Drop noCocoa variable
>>> - Coding Style changes
>>> 
>>> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
>>> Cc: Alexander Graf <agraf@suse.de>
>>> Cc: Mike Kronenberg <mike.kronenberg@kronenberg.org>
>>> ---
>>> cocoa.m |   10 ++++++++++
>>> 1 files changed, 10 insertions(+), 0 deletions(-)
>>> 
>>> diff --git a/cocoa.m b/cocoa.m
>>> index d5f941b..70c249b 100644
>>> --- a/cocoa.m
>>> +++ b/cocoa.m
>>> @@ -855,6 +855,16 @@ int main (int argc, const char * argv[]) {
>>>   gArgc = argc;
>>>   gArgv = (char **)argv;
>>>   CPSProcessSerNum PSN;
>>> +    int i;
>>> +
>>> +    /* In case we don't need to display a window, let's not do that */
>>> +    for (i = 1; i < argc; i++) {
>>> +        if (!strcmp(argv[i], "-vnc") ||
>>> +            !strcmp(argv[i], "-nographic") ||
>>> +            !strcmp(argv[i], "-curses")) {
>>> +                return qemu_main(gArgc, gArgv);
>>> +        }
>>> +    }
>> 
>> Hm, does that work with qemu -hda /tmp/bla.img -nographic?
> 
> Yes, your code! :) I just did the minor changes decribed unter v1.

Oh, in case any of these arguments is passed, we just directly call the 'normal' main function. I was really being tricky back then :-).

Alex

Patch

diff --git a/cocoa.m b/cocoa.m
index d5f941b..70c249b 100644
--- a/cocoa.m
+++ b/cocoa.m
@@ -855,6 +855,16 @@  int main (int argc, const char * argv[]) {
     gArgc = argc;
     gArgv = (char **)argv;
     CPSProcessSerNum PSN;
+    int i;
+
+    /* In case we don't need to display a window, let's not do that */
+    for (i = 1; i < argc; i++) {
+        if (!strcmp(argv[i], "-vnc") ||
+            !strcmp(argv[i], "-nographic") ||
+            !strcmp(argv[i], "-curses")) {
+                return qemu_main(gArgc, gArgv);
+        }
+    }
 
     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     [NSApplication sharedApplication];