Fix MacVim compiler warnings (for Vim-process files)

Fix NSStringPboardType and NSFindPboard deprecation warnings.

Also, fix up an awkward use of colors in that we are loading the ARGB
values of system colors using device calibrated space but CoreText
renderer uses sRGB instead. Just load it as sRGB.

This should fix up all Vim-side compiler warnings except for the usage
of NSConnection, which is a much larger task to tackle as we need to
move to XPC. Note that the set of warnings differ depending on whether
we have `MACOSX_DEPLOYMENT_TARGET=10.9` set or not as Xcode will
recommend different changes. With that set we currently do not throw any
warnings on the Vim process side (since NSConnection was not deprecated
at 10.9 yet).
This commit is contained in:
Yee Cheng Chin
2022-10-04 23:34:31 -07:00
parent 2499e5333a
commit e9e129017c
4 changed files with 39 additions and 10 deletions
+5 -3
View File
@@ -1138,7 +1138,7 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
NSColor *col = [NSColor performSelector:NSSelectorFromString(obj)];
if (col) {
CGFloat r, g, b, a;
col = [col colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
col = [col colorUsingColorSpace:NSColorSpace.sRGBColorSpace];
[col getRed:&r green:&g blue:&b alpha:&a];
return (((int)(r*255+.5f) & 0xff) << 16)
+ (((int)(g*255+.5f) & 0xff) << 8)
@@ -1473,9 +1473,9 @@ static char_u *extractSelectedText()
NSString *string = [[NSString alloc] initWithUTF8String:(char*)str];
NSArray *types = [NSArray arrayWithObject:NSStringPboardType];
NSArray *types = [NSArray arrayWithObject:NSPasteboardTypeString];
[pboard declareTypes:types owner:nil];
BOOL ok = [pboard setString:string forType:NSStringPboardType];
BOOL ok = [pboard setString:string forType:NSPasteboardTypeString];
[string release];
vim_free(str);
@@ -2502,12 +2502,14 @@ static char_u *extractSelectedText()
case NSScrollerIncrementPage:
value += (size > 2 ? size - 2 : 1);
break;
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
case NSScrollerDecrementLine:
--value;
break;
case NSScrollerIncrementLine:
++value;
break;
#endif
case NSScrollerKnob:
isStillDragging = YES;
// fall through ...
+28 -1
View File
@@ -1,4 +1,4 @@
/* vi:set ts=8 sts=4 sw=4 ft=objc:
/* vi:set ts=8 sts=4 sw=4 ft=objc fdm=syntax:
*
* VIM - Vi IMproved by Bram Moolenaar
* MacVim GUI port by Bjorn Winckler
@@ -8,8 +8,13 @@
* See README.txt for an overview of the Vim source code.
*/
// This file contains root-level commonly used definitions that both Vim and
// MacVim processes need access to.
#import <Cocoa/Cocoa.h>
#pragma region Backward compatibility defines
// Taken from /usr/include/AvailabilityMacros.h
#ifndef MAC_OS_X_VERSION_10_7
# define MAC_OS_X_VERSION_10_7 1070
@@ -58,6 +63,10 @@
# define NSAppKitVersionNumber10_14 1671
#endif
// Deprecated constants. Since these are constants, we just need the compiler,
// not the runtime to know about them. As such, we can use MAX_ALLOWED to
// determine if we need to map or not.
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
// Deprecated constants in 10.12 SDK
# define NSAlertStyleCritical NSCriticalAlertStyle
@@ -91,6 +100,16 @@
# define NSWindowStyleMaskUnifiedTitleAndToolbar NSUnifiedTitleAndToolbarWindowMask
#endif
// Deprecated runtime values. Since these are runtime values, we need to use the
// minimum required OS as determining factor. Otherwise it would crash.
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13
// Deprecated runtime values in 10.13 SDK.
# define NSPasteboardNameFind NSFindPboard
#endif
#pragma endregion
#import <asl.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
# define MM_USE_ASL
@@ -98,6 +117,7 @@
# import <os/log.h>
#endif
#pragma region Shared protocols
//
// This is the protocol MMBackend implements.
@@ -171,7 +191,9 @@
client:(in byref id <MMVimClientProtocol>)client;
@end
#pragma endregion
#pragma region IPC messages
//
// The following enum lists all messages that are passed between MacVim and
@@ -330,6 +352,8 @@ enum {
MMGestureForceClick,
};
#pragma endregion
// Create a string holding the labels of all messages in message queue for
// debugging purposes (condense some messages since there may typically be LOTS
@@ -405,6 +429,7 @@ extern NSString *VimFindPboardType;
// MacVim Apple Event Constants
#define keyMMUntitledWindow 'MMuw'
#pragma region Logging
// Logging related functions and macros.
//
@@ -496,3 +521,5 @@ void ASLInit();
# define ASLogTmp(fmt, ...) ASLog(OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__)
#endif
#pragma endregion
+3 -3
View File
@@ -159,7 +159,7 @@ debugStringForMessageQueue(NSArray *queue)
- (unsigned)argbInt {
CGFloat rf, gf, bf, af;
[[self colorUsingColorSpace:NSColorSpace.deviceRGBColorSpace]
[[self colorUsingColorSpace:NSColorSpace.sRGBColorSpace]
getRed:&rf green:&gf blue:&bf alpha:&af];
unsigned r = rf * 255, g = gf * 255, b = bf * 255, a = af*255;
return a<<24 | r<<16 | g<<8 | b;
@@ -171,7 +171,7 @@ debugStringForMessageQueue(NSArray *queue)
float g = ((rgb>>8) & 0xff)/255.0f;
float b = (rgb & 0xff)/255.0f;
return [NSColor colorWithDeviceRed:r green:g blue:b alpha:1.0f];
return [NSColor colorWithSRGBRed:r green:g blue:b alpha:1.0f];
}
+ (NSColor *)colorWithArgbInt:(unsigned)argb
@@ -181,7 +181,7 @@ debugStringForMessageQueue(NSArray *queue)
float g = ((argb>>8) & 0xff)/255.0f;
float b = (argb & 0xff)/255.0f;
return [NSColor colorWithDeviceRed:r green:g blue:b alpha:a];
return [NSColor colorWithSRGBRed:r green:g blue:b alpha:a];
}
@end // NSColor (MMExtras)
+3 -3
View File
@@ -1916,9 +1916,9 @@ gui_macvim_add_to_find_pboard(char_u *pat)
if (!s) return;
NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSFindPboard];
NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSPasteboardNameFind];
NSArray *supportedTypes = [NSArray arrayWithObjects:VimFindPboardType,
NSStringPboardType, nil];
NSPasteboardTypeString, nil];
[pb declareTypes:supportedTypes owner:nil];
// Put two entries on the Find pasteboard:
@@ -1927,7 +1927,7 @@ gui_macvim_add_to_find_pboard(char_u *pat)
// The second entry will be used by other applications when taking entries
// off the Find pasteboard, whereas MacVim will use the first if present.
[pb setString:s forType:VimFindPboardType];
[pb setString:[s stringByRemovingFindPatterns] forType:NSStringPboardType];
[pb setString:[s stringByRemovingFindPatterns] forType:NSPasteboardTypeString];
}
void