mirror of https://github.com/OpenTTD/OpenTTD.git
Fix: [OSX] Remove some OSX compiler warnings on newer SDKs/compilers.
This commit is contained in:
parent
fa587ad3cc
commit
74b7f0a9aa
|
@ -27,6 +27,8 @@
|
||||||
#define MARGIN_NORMAL_THRESHOLD (zoom == ZOOM_LVL_OUT_32X ? 8 : 4) ///< Minimum width to use margins with BM_NORMAL.
|
#define MARGIN_NORMAL_THRESHOLD (zoom == ZOOM_LVL_OUT_32X ? 8 : 4) ///< Minimum width to use margins with BM_NORMAL.
|
||||||
#define MARGIN_REMAP_THRESHOLD 4 ///< Minimum width to use margins with BM_COLOUR_REMAP.
|
#define MARGIN_REMAP_THRESHOLD 4 ///< Minimum width to use margins with BM_COLOUR_REMAP.
|
||||||
|
|
||||||
|
#undef ALIGN
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define ALIGN(n) __declspec(align(n))
|
#define ALIGN(n) __declspec(align(n))
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
#undef Rect
|
#undef Rect
|
||||||
#undef Point
|
#undef Point
|
||||||
|
|
||||||
|
#ifndef __clang__
|
||||||
|
#define __bridge
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file contains objective C
|
* This file contains objective C
|
||||||
* Apple uses objective C instead of plain C to interact with OS specific/native functions
|
* Apple uses objective C instead of plain C to interact with OS specific/native functions
|
||||||
|
@ -182,7 +186,7 @@ uint GetCPUCoreCount()
|
||||||
uint count = 1;
|
uint count = 1;
|
||||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||||
if (MacOSVersionIsAtLeast(10, 5, 0)) {
|
if (MacOSVersionIsAtLeast(10, 5, 0)) {
|
||||||
count = [ [ NSProcessInfo processInfo ] activeProcessorCount ];
|
count = (uint)[ [ NSProcessInfo processInfo ] activeProcessorCount ];
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -201,7 +205,7 @@ uint GetCPUCoreCount()
|
||||||
*/
|
*/
|
||||||
bool IsMonospaceFont(CFStringRef name)
|
bool IsMonospaceFont(CFStringRef name)
|
||||||
{
|
{
|
||||||
NSFont *font = [ NSFont fontWithName:(NSString *)name size:0.0f ];
|
NSFont *font = [ NSFont fontWithName:(__bridge NSString *)name size:0.0f ];
|
||||||
|
|
||||||
return font != NULL ? [ font isFixedPitch ] : false;
|
return font != NULL ? [ font isFixedPitch ] : false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,7 +259,11 @@ uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_i
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/** Delegate for our NSWindow to send ask for quit on close */
|
/** Delegate for our NSWindow to send ask for quit on close */
|
||||||
@interface OTTD_CocoaWindowDelegate : NSObject {
|
@interface OTTD_CocoaWindowDelegate : NSObject
|
||||||
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||||
|
<NSWindowDelegate>
|
||||||
|
#endif
|
||||||
|
{
|
||||||
CocoaSubdriver *driver;
|
CocoaSubdriver *driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,9 @@
|
||||||
|
|
||||||
|
|
||||||
@interface OTTDMain : NSObject
|
@interface OTTDMain : NSObject
|
||||||
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||||
|
<NSApplicationDelegate>
|
||||||
|
#endif
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,8 +215,7 @@ static void setupApplication()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Become the front process, important when start from the command line. */
|
/* Become the front process, important when start from the command line. */
|
||||||
OSErr err = SetFrontProcess(&psn);
|
[ [ NSApplication sharedApplication ] activateIgnoringOtherApps:YES ];
|
||||||
if (err != 0) DEBUG(driver, 0, "Could not bring the application to front. Error %d", (int)err);
|
|
||||||
|
|
||||||
/* Set up the menubar */
|
/* Set up the menubar */
|
||||||
[ NSApp setMainMenu:[ [ NSMenu alloc ] init ] ];
|
[ NSApp setMainMenu:[ [ NSMenu alloc ] init ] ];
|
||||||
|
@ -575,9 +577,12 @@ void VideoDriver_Cocoa::EditBoxLostFocus()
|
||||||
if (_cocoa_subdriver != NULL) {
|
if (_cocoa_subdriver != NULL) {
|
||||||
if ([ _cocoa_subdriver->cocoaview respondsToSelector:@selector(inputContext) ] && [ [ _cocoa_subdriver->cocoaview performSelector:@selector(inputContext) ] respondsToSelector:@selector(discardMarkedText) ]) {
|
if ([ _cocoa_subdriver->cocoaview respondsToSelector:@selector(inputContext) ] && [ [ _cocoa_subdriver->cocoaview performSelector:@selector(inputContext) ] respondsToSelector:@selector(discardMarkedText) ]) {
|
||||||
[ [ _cocoa_subdriver->cocoaview performSelector:@selector(inputContext) ] performSelector:@selector(discardMarkedText) ];
|
[ [ _cocoa_subdriver->cocoaview performSelector:@selector(inputContext) ] performSelector:@selector(discardMarkedText) ];
|
||||||
} else {
|
}
|
||||||
|
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6)
|
||||||
|
else {
|
||||||
[ [ NSInputManager currentInputManager ] markedTextAbandoned:_cocoa_subdriver->cocoaview ];
|
[ [ NSInputManager currentInputManager ] markedTextAbandoned:_cocoa_subdriver->cocoaview ];
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
/* Clear any marked string from the current edit box. */
|
/* Clear any marked string from the current edit box. */
|
||||||
HandleTextInput(NULL, true);
|
HandleTextInput(NULL, true);
|
||||||
|
@ -1032,7 +1037,17 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count)
|
||||||
{
|
{
|
||||||
if (!EditBoxInGlobalFocus()) return NSNotFound;
|
if (!EditBoxInGlobalFocus()) return NSNotFound;
|
||||||
|
|
||||||
NSPoint view_pt = [ self convertPoint:[ [ self window ] convertScreenToBase:thePoint ] fromView:nil ];
|
NSPoint view_pt = NSZeroPoint;
|
||||||
|
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
|
||||||
|
if ([ [ self window ] respondsToSelector:@selector(convertRectFromScreen:) ]) {
|
||||||
|
view_pt = [ self convertRect:[ [ self window ] convertRectFromScreen:NSMakeRect(thePoint.x, thePoint.y, 0, 0) ] fromView:nil ].origin;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7)
|
||||||
|
view_pt = [ self convertPoint:[ [ self window ] convertScreenToBase:thePoint ] fromView:nil ];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
Point pt = { (int)view_pt.x, (int)[ self frame ].size.height - (int)view_pt.y };
|
Point pt = { (int)view_pt.x, (int)[ self frame ].size.height - (int)view_pt.y };
|
||||||
|
|
||||||
|
@ -1061,9 +1076,13 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
|
||||||
NSRect window_rect = [ self convertRect:view_rect toView:nil ];
|
NSRect window_rect = [ self convertRect:view_rect toView:nil ];
|
||||||
NSPoint origin = [ [ self window ] convertBaseToScreen:window_rect.origin ];
|
NSPoint origin = [ [ self window ] convertBaseToScreen:window_rect.origin ];
|
||||||
return NSMakeRect(origin.x, origin.y, window_rect.size.width, window_rect.size.height);
|
return NSMakeRect(origin.x, origin.y, window_rect.size.width, window_rect.size.height);
|
||||||
|
#else
|
||||||
|
return NSMakeRect(0, 0, 0, 0);;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the bounding rect for the given range. */
|
/** Get the bounding rect for the given range. */
|
||||||
|
|
|
@ -100,10 +100,10 @@ static void QZ_WarpCursor(int x, int y)
|
||||||
NSPoint p = NSMakePoint(x, y);
|
NSPoint p = NSMakePoint(x, y);
|
||||||
CGPoint cgp = _cocoa_subdriver->PrivateLocalToCG(&p);
|
CGPoint cgp = _cocoa_subdriver->PrivateLocalToCG(&p);
|
||||||
|
|
||||||
/* this is the magic call that fixes cursor "freezing" after warp */
|
|
||||||
CGSetLocalEventsSuppressionInterval(0.0);
|
|
||||||
/* Do the actual warp */
|
/* Do the actual warp */
|
||||||
CGWarpMouseCursorPosition(cgp);
|
CGWarpMouseCursorPosition(cgp);
|
||||||
|
/* this is the magic call that fixes cursor "freezing" after warp */
|
||||||
|
CGAssociateMouseAndMouseCursorPosition(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -333,7 +333,9 @@ bool WindowQuartzSubdriver::SetVideoMode(int width, int height, int bpp)
|
||||||
[ this->window setAcceptsMouseMovedEvents:YES ];
|
[ this->window setAcceptsMouseMovedEvents:YES ];
|
||||||
[ this->window setViewsNeedDisplay:NO ];
|
[ this->window setViewsNeedDisplay:NO ];
|
||||||
|
|
||||||
[ this->window useOptimizedDrawing:YES ];
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
|
||||||
|
if ([ this->window respondsToSelector:@selector(useOptimizedDrawing:) ]) [ this->window useOptimizedDrawing:YES ];
|
||||||
|
#endif
|
||||||
|
|
||||||
delegate = [ [ OTTD_CocoaWindowDelegate alloc ] init ];
|
delegate = [ [ OTTD_CocoaWindowDelegate alloc ] init ];
|
||||||
[ delegate setDriver:this ];
|
[ delegate setDriver:this ];
|
||||||
|
@ -517,7 +519,16 @@ CGPoint WindowQuartzSubdriver::PrivateLocalToCG(NSPoint *p)
|
||||||
p->y = this->window_height - p->y;
|
p->y = this->window_height - p->y;
|
||||||
*p = [ this->cocoaview convertPoint:*p toView:nil ];
|
*p = [ this->cocoaview convertPoint:*p toView:nil ];
|
||||||
|
|
||||||
*p = [ this->window convertBaseToScreen:*p ];
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||||
|
if ([ this->window respondsToSelector:@selector(convertRectToScreen:) ]) {
|
||||||
|
*p = [ this->window convertRectToScreen:NSMakeRect(p->x, p->y, 0, 0) ].origin;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
|
||||||
|
*p = [ this->window convertBaseToScreen:*p ];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
p->y = this->device_height - p->y;
|
p->y = this->device_height - p->y;
|
||||||
|
|
||||||
CGPoint cgp;
|
CGPoint cgp;
|
||||||
|
@ -539,7 +550,9 @@ NSPoint WindowQuartzSubdriver::GetMouseLocation(NSEvent *event)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
|
||||||
pt = [ this->cocoaview convertPoint:[ [ this->cocoaview window ] convertScreenToBase:[ event locationInWindow ] ] fromView:nil ];
|
pt = [ this->cocoaview convertPoint:[ [ this->cocoaview window ] convertScreenToBase:[ event locationInWindow ] ] fromView:nil ];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pt = [ event locationInWindow ];
|
pt = [ event locationInWindow ];
|
||||||
|
|
Loading…
Reference in New Issue