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. Signed-off-by: Andreas Färber <andreas.faerber@web.de> Cc: John Arbuckle <programmingkidx@gmail.com> Cc: Ryan Schmidt <qemu-2009@ryandesign.com> Cc: Mike Kronenberg <mike.kronenberg@kronenberg.org> Signed-off-by: malc <av1474@comtv.ru>
This commit is contained in:
parent
fd10a04ef1
commit
38ec7b5357
17
cocoa.m
17
cocoa.m
@ -28,6 +28,9 @@
|
|||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "sysemu.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
|
#ifndef MAC_OS_X_VERSION_10_5
|
||||||
#define MAC_OS_X_VERSION_10_5 1050
|
#define MAC_OS_X_VERSION_10_5 1050
|
||||||
#endif
|
#endif
|
||||||
@ -331,7 +334,7 @@ static int cocoa_keycode_to_qemu(int keycode)
|
|||||||
0, //interpolate
|
0, //interpolate
|
||||||
kCGRenderingIntentDefault //intent
|
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 (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
|
||||||
if (CGImageCreateWithImageInRect == NULL) { // test if "CGImageCreateWithImageInRect" is supported on host at runtime
|
if (CGImageCreateWithImageInRect == NULL) { // test if "CGImageCreateWithImageInRect" is supported on host at runtime
|
||||||
#endif
|
#endif
|
||||||
@ -428,8 +431,8 @@ static int cocoa_keycode_to_qemu(int keycode)
|
|||||||
isFullscreen = FALSE;
|
isFullscreen = FALSE;
|
||||||
[self ungrabMouse];
|
[self ungrabMouse];
|
||||||
[self setContentDimensions];
|
[self setContentDimensions];
|
||||||
// test if host support "enterFullScreenMode:withOptions" at compiletime
|
// test if host supports "exitFullScreenModeWithOptions" at compile time
|
||||||
#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)
|
||||||
if ([NSView respondsToSelector:@selector(exitFullScreenModeWithOptions:)]) { // test if "exitFullScreenModeWithOptions" is supported on host at runtime
|
if ([NSView respondsToSelector:@selector(exitFullScreenModeWithOptions:)]) { // test if "exitFullScreenModeWithOptions" is supported on host at runtime
|
||||||
[self exitFullScreenModeWithOptions:nil];
|
[self exitFullScreenModeWithOptions:nil];
|
||||||
} else {
|
} else {
|
||||||
@ -438,15 +441,15 @@ static int cocoa_keycode_to_qemu(int keycode)
|
|||||||
[normalWindow setContentView: self];
|
[normalWindow setContentView: self];
|
||||||
[normalWindow makeKeyAndOrderFront: self];
|
[normalWindow makeKeyAndOrderFront: self];
|
||||||
[NSMenu setMenuBarVisible:YES];
|
[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
|
#endif
|
||||||
} else { // switch from desktop to fullscreen
|
} else { // switch from desktop to fullscreen
|
||||||
isFullscreen = TRUE;
|
isFullscreen = TRUE;
|
||||||
[self grabMouse];
|
[self grabMouse];
|
||||||
[self setContentDimensions];
|
[self setContentDimensions];
|
||||||
// test if host support "enterFullScreenMode:withOptions" at compiletime
|
// test if host supports "enterFullScreenMode:withOptions" at compile time
|
||||||
#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)
|
||||||
if ([NSView respondsToSelector:@selector(enterFullScreenMode:withOptions:)]) { // test if "enterFullScreenMode:withOptions" is supported on host at runtime
|
if ([NSView respondsToSelector:@selector(enterFullScreenMode:withOptions:)]) { // test if "enterFullScreenMode:withOptions" is supported on host at runtime
|
||||||
[self enterFullScreenMode:[NSScreen mainScreen] withOptions:[NSDictionary dictionaryWithObjectsAndKeys:
|
[self enterFullScreenMode:[NSScreen mainScreen] withOptions:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
[NSNumber numberWithBool:NO], NSFullScreenModeAllScreens,
|
[NSNumber numberWithBool:NO], NSFullScreenModeAllScreens,
|
||||||
@ -462,7 +465,7 @@ static int cocoa_keycode_to_qemu(int keycode)
|
|||||||
[fullScreenWindow setHasShadow:NO];
|
[fullScreenWindow setHasShadow:NO];
|
||||||
[fullScreenWindow setContentView:self];
|
[fullScreenWindow setContentView:self];
|
||||||
[fullScreenWindow makeKeyAndOrderFront: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
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user