Cocoa: ppc64 host support and various improvements
v2 cover Cocoa: ppc64 host support and various improvements
Hello,
This is a resend of my full Cocoa series posted Dec 13, last updated on Dec 14 following a suggestion by Juha. Original intro follows.
Recently, OSX/ppc64 TCG support was merged. This series replaces the remainder of my ppc64 series, splitting it up for review and bisectability.
It starts with fixing an essential 64-bit incompatibility, followed by elimination of all cocoa.m warnings on a v10.5 ppc64 system.
Also included are respins of patches fixing errors/warnings on older hosts and optimizing drawing. Support for -nographic is added.
New is my modification of window close behavior plus another drawing optimization for non-overlapping Views.
Most of these patches do not depend on each other, so could be cherry-picked if necessary.
Also available at git://repo.or.cz/qemu/afaerber.git, branch cocoa.
Regards,
Andreas
Andreas Färber (11):
Cocoa: ppc64 host support
Cocoa: Silence warning for cocoa_keycode_to_qemu
Cocoa: Silence warning on Big Endian host
Cocoa: Silence type warning
Cocoa: Fix compilation on Mac OS X v10.4 and earlier
Cocoa: Mark the View as opaque
Cocoa: Redraw the View asynchronously
Cocoa: Don't unconditionally show the window
Cocoa: Shutdown when window is closed
Cocoa: Suppress window resize animation
Cocoa: Use optimized drawing for the window
cocoa.m | 56 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 44 insertions(+), 12 deletions(-)
PATCH RESEND v2 1/11 Cocoa: ppc64 host support
Fix integer usage in the Cocoa backend: NSInteger is long on LP64.
This makes the graphical display show up on a ppc64 host.
v3:
- Confine NSInteger to Mac OS X v10.5 and later
--- cocoa.m | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
cocoa.m +8 -0
@@ -28,6 +28,10 @@ #include "console.h" #include "sysemu.h" +#ifndef MAC_OS_X_VERSION_10_5 +#define MAC_OS_X_VERSION_10_5 1050 +#endif + //#define DEBUG
@@ -337,7 +341,11 @@ int cocoa_keycode_to_qemu(int keycode) } else { // selective drawing code (draws only dirty rectangles) (OS X >= 10.4) const NSRect *rectList; +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) + NSInteger rectCount; +#else int rectCount; +#endif int i; CGImageRef clipImageRef; CGRect clipRect;
Signature · 1 line
1.6.5.3
PATCH RESEND v2 2/11 Cocoa: Silence warning for cocoa_keycode_to_qemu
Make cocoa_keycode_to_qemu static, to avoid:
warning: no previous prototype for ‘cocoa_keycode_to_qemu’
--- cocoa.m | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
cocoa.m +1 -1
@@ -233,7 +233,7 @@ int keymap[] = */ }; -int cocoa_keycode_to_qemu(int keycode) +static int cocoa_keycode_to_qemu(int keycode) { if((sizeof(keymap)/sizeof(int)) <= keycode) {
Signature · 1 line
1.6.5.3
PATCH RESEND v2 3/11 Cocoa: Silence warning on Big Endian host
__LITTLE_ENDIAN__ is undefined on Big Endian host.
--- cocoa.m | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
cocoa.m +1 -1
@@ -319,7 +319,7 @@ static int cocoa_keycode_to_qemu(int keycode) screen.bitsPerComponent, //bitsPerComponent screen.bitsPerPixel, //bitsPerPixel (screen.width * (screen.bitsPerComponent/2)), //bytesPerRow -#if __LITTLE_ENDIAN__ +#ifdef __LITTLE_ENDIAN__ CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB), //colorspace for OS X >= 10.4 kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst, #else
Signature · 1 line
1.6.5.3
PATCH RESEND v2 4/11 Cocoa: Silence type warning
Add const for "qemu" character literal, to avoid:
warning: initialization discards qualifiers from pointer target type
An earlier patch by John proposed to use char[5]. Since we do not modify the text and later copy it into malloc'ed memory, marking it as const seems sufficient.
--- cocoa.m | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
cocoa.m +1 -1
@@ -791,7 +791,7 @@ static int cocoa_keycode_to_qemu(int keycode) if(returnCode == NSCancelButton) { exit(0); } else if(returnCode == NSOKButton) { - char *bin = "qemu"; + const char *bin = "qemu"; char *img = (char*)[ [ sheet filename ] cStringUsingEncoding:NSASCIIStringEncoding]; char **argv = (char**)malloc( sizeof(char*)*3 );
Signature · 1 line
1.6.5.3
PATCH RESEND v2 5/11 Cocoa: Fix compilation on Mac OS X v10.4 and earlier
NSView's enterFullScreenMode:withOptions: and exitFullScreenModeWithOptions: are available on v10.5 and later only. Undefined methods raise warnings and undefined constants result in errors.
Reported by Ryan Schmidt.
While at it, avoid a warning on v10.3.9, where MAC_OS_X_VERSION_10_4 is not defined.
Spotted by John Arbuckle.
Fix associated comments.
--- cocoa.m | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
cocoa.m +10 -7
@@ -28,6 +28,9 @@ #include "console.h" #include "sysemu.h" +#ifndef MAC_OS_X_VERSION_10_4 +#define MAC_OS_X_VERSION_10_4 1040 +#endif #ifndef MAC_OS_X_VERSION_10_5 #define MAC_OS_X_VERSION_10_5 1050 #endif
@@ -331,7 +334,7 @@ static int cocoa_keycode_to_qemu(int keycode) 0, //interpolate kCGRenderingIntentDefault //intent ); -// test if host support "CGImageCreateWithImageInRect" at compiletime +// test if host supports "CGImageCreateWithImageInRect" at compile time #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) if (CGImageCreateWithImageInRect == NULL) { // test if "CGImageCreateWithImageInRect" is supported on host at runtime #endif
@@ -428,8 +431,8 @@ static int cocoa_keycode_to_qemu(int keycode) isFullscreen = FALSE; [self ungrabMouse]; [self setContentDimensions]; -// test if host support "enterFullScreenMode:withOptions" at compiletime -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) +// test if host supports "exitFullScreenModeWithOptions" at compile time +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if ([NSView respondsToSelector:@selector(exitFullScreenModeWithOptions:)]) { // test if "exitFullScreenModeWithOptions" is supported on host at runtime [self exitFullScreenModeWithOptions:nil]; } else {
@@ -438,15 +441,15 @@ static int cocoa_keycode_to_qemu(int keycode) [normalWindow setContentView: self]; [normalWindow makeKeyAndOrderFront: self]; [NSMenu setMenuBarVisible:YES]; -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) } #endif } else { // switch from desktop to fullscreen isFullscreen = TRUE; [self grabMouse]; [self setContentDimensions]; -// test if host support "enterFullScreenMode:withOptions" at compiletime -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) +// test if host supports "enterFullScreenMode:withOptions" at compile time +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if ([NSView respondsToSelector:@selector(enterFullScreenMode:withOptions:)]) { // test if "enterFullScreenMode:withOptions" is supported on host at runtime [self enterFullScreenMode:[NSScreen mainScreen] withOptions:[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:NO], NSFullScreenModeAllScreens,
@@ -462,7 +465,7 @@ static int cocoa_keycode_to_qemu(int keycode) [fullScreenWindow setHasShadow:NO]; [fullScreenWindow setContentView:self]; [fullScreenWindow makeKeyAndOrderFront:self]; -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) } #endif }
Signature · 1 line
1.6.5.3
PATCH RESEND v2 6/11 Cocoa: Mark the View as opaque
Default is NO.
Based on patch by Juha Riihimäki.
--- cocoa.m | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
cocoa.m +5 -0
@@ -305,6 +305,11 @@ static int cocoa_keycode_to_qemu(int keycode) [super dealloc]; } +- (BOOL) isOpaque +{ + return YES; +} + - (void) drawRect:(NSRect) rect { COCOA_DEBUG("QemuCocoaView: drawRect\n");
Signature · 1 line
1.6.5.3
PATCH RESEND v2 7/11 Cocoa: Redraw the View asynchronously
Based on patch by Juha Riihimäki.
--- cocoa.m | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
cocoa.m +1 -1
@@ -938,7 +938,7 @@ static void cocoa_update(DisplayState *ds, int x, int y, int w, int h) w * [cocoaView cdx], h * [cocoaView cdy]); } - [cocoaView displayRect:rect]; + [cocoaView setNeedsDisplayInRect:rect]; } static void cocoa_resize(DisplayState *ds)
Signature · 1 line
1.6.5.3
PATCH RESEND v2 8/11 Cocoa: Don't unconditionally show the window
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
--- cocoa.m | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
cocoa.m +10 -0
@@ -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];
Signature · 1 line
1.6.5.3
PATCH RESEND v2 9/11 Cocoa: Shutdown when window is closed
The application is not very useful once the guest window is closed. QEMU is not a document-based application; terminating it automatically saves the user another action and resembles SDL behavior.
v2:
- Use delegate method, suggested by Juha Riihimäki.
--- cocoa.m | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
cocoa.m +5 -0
@@ -783,6 +783,11 @@ static int cocoa_keycode_to_qemu(int keycode) exit(0); } +- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication +{ + return YES; +} + - (void)startEmulationWithArgc:(int)argc argv:(char**)argv { COCOA_DEBUG("QemuCocoaAppController: startEmulationWithArgc\n");
Signature · 1 line
1.6.5.3
PATCH RESEND v2 10/11 Cocoa: Suppress window resize animation
Disable the nice resize animation, to avoid drawing glitches following a guest's screen size change.
Based on patch by Juha Riihimäki.
--- cocoa.m | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
cocoa.m +1 -1
@@ -419,7 +419,7 @@ static int cocoa_keycode_to_qemu(int keycode) } else { if (qemu_name) [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; - [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:YES]; + [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:NO]; } screen.width = w; screen.height = h;
Signature · 1 line
1.6.5.3
PATCH RESEND v2 11/11 Cocoa: Use optimized drawing for the window
Default is NO.
--- cocoa.m | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
cocoa.m +1 -0
@@ -740,6 +740,7 @@ static int cocoa_keycode_to_qemu(int keycode) [normalWindow setAcceptsMouseMovedEvents:YES]; [normalWindow setTitle:[NSString stringWithFormat:@"QEMU"]]; [normalWindow setContentView:cocoaView]; + [normalWindow useOptimizedDrawing:YES]; [normalWindow makeKeyAndOrderFront:self]; [normalWindow center];
Signature · 1 line
1.6.5.3
[Qemu-devel] Re: [PATCH v2 RESEND 08/11] Cocoa: Don't unconditionally show the window
In reply to Andreas FärberQuoted 25 lines · Andreas Färber
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 changesSigned-off-by Andreas Färber <[email protected]>Cc Alexander Graf <[email protected]>Cc Mike Kronenberg <[email protected]>---
cocoa.m | 10 ++++++++++1 files changed, 10 insertions(+), 0 deletions(-)cocoa.m +0
-0@@ -855,6 +855,16 @@ int main (int argc, const char * argv[]) { gArgc = argc; gArgv = (char **)argv; CPSProcessSerNum PSN;
cocoa.m int main (int argc, const char * argv[]) { · line 867
Quoted 10 lines
cocoa.m +10
-0+ 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
[Qemu-devel] Re: [PATCH v2 RESEND 08/11] Cocoa: Don't unconditionally show the window
Am 06.01.2010 um 23:49 schrieb Alexander Graf:
Quoted 33 lines · Andreas Färber
Quoted 31 lines
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 changesSigned-off-by Andreas Färber <[email protected]>Cc Alexander Graf <[email protected]>Cc Mike Kronenberg <[email protected]>---
cocoa.m | 10 ++++++++++1 files changed, 10 insertions(+), 0 deletions(-)cocoa.m +3
-0@@ -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 dothat */
+ for (i = 1; i < argc; i++) {
Quoted 8 lines
cocoa.m int main (int argc, const char * argv[]) { · line 867
Quoted 6 lines
cocoa.m +6
-0+ 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
[Qemu-devel] Re: [PATCH v2 RESEND 08/11] Cocoa: Don't unconditionally show the window
Quoted 44 lines · Andreas Färber
Am 06.01.2010 um 23:49 schrieb Alexander Graf:
Quoted 32 lines · Andreas Färber
Quoted 30 lines
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 changesSigned-off-by Andreas Färber <[email protected]>Cc Alexander Graf <[email protected]>Cc Mike Kronenberg <[email protected]>---
cocoa.m | 10 ++++++++++1 files changed, 10 insertions(+), 0 deletions(-)cocoa.m +4
-0@@ -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++) {Quoted 8 lines
cocoa.m int main (int argc, const char * argv[]) { · line 867
Quoted 6 lines
cocoa.m +6
-0+ 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?
Quoted 1 line
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