diff --git a/src/MacVim/DBPrefsWindowController.m b/src/MacVim/DBPrefsWindowController.m index 27486e58b3..814900a69b 100644 --- a/src/MacVim/DBPrefsWindowController.m +++ b/src/MacVim/DBPrefsWindowController.m @@ -349,7 +349,7 @@ static DBPrefsWindowController *_sharedPrefsWindowController = nil; { [viewAnimation stopAnimation]; - if ([self shiftSlowsAnimation] && [[[self window] currentEvent] modifierFlags] & NSShiftKeyMask) + if ([self shiftSlowsAnimation] && [[[self window] currentEvent] modifierFlags] & NSEventModifierFlagShift) [viewAnimation setDuration:1.25]; else [viewAnimation setDuration:0.25]; diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index cea068f81b..f61f3902bb 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -1869,7 +1869,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef, // background, the runloop won't bother flushing the autorelease pool. // Triggering an NSEvent works around this. // http://www.mikeash.com/pyblog/more-fun-with-autorelease.html - NSEvent* event = [NSEvent otherEventWithType:NSApplicationDefined + NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined location:NSZeroPoint modifierFlags:0 timestamp:0 diff --git a/src/MacVim/MMApplication.m b/src/MacVim/MMApplication.m index b68870b986..7f48bfd708 100644 --- a/src/MacVim/MMApplication.m +++ b/src/MacVim/MMApplication.m @@ -27,14 +27,15 @@ // help mode' (the keyDown: event itself never reaches the text view). By // clearing the 'help key flag' this event will be treated like a normal // key event. - if ((NSKeyDown == type || NSKeyUp == type) && (flags & NSHelpKeyMask)) { - flags &= ~NSHelpKeyMask; + if ((NSEventTypeKeyDown == type || NSEventTypeKeyUp == type) && + (flags & NSEventModifierFlagHelp)) { + flags &= ~NSEventModifierFlagHelp; event = [NSEvent keyEventWithType:[event type] location:[event locationInWindow] modifierFlags:flags timestamp:[event timestamp] windowNumber:[event windowNumber] - context:[event context] + context:nil // [event context] is always nil characters:[event characters] charactersIgnoringModifiers:[event charactersIgnoringModifiers] isARepeat:[event isARepeat] diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 91fef64ffe..9f924be715 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -3173,11 +3173,11 @@ static int eventModifierFlagsToVimModMask(int modifierFlags) { int modMask = 0; - if (modifierFlags & NSShiftKeyMask) + if (modifierFlags & NSEventModifierFlagShift) modMask |= MOD_MASK_SHIFT; - if (modifierFlags & NSControlKeyMask) + if (modifierFlags & NSEventModifierFlagControl) modMask |= MOD_MASK_CTRL; - if (modifierFlags & NSAlternateKeyMask) + if (modifierFlags & NSEventModifierFlagOption) modMask |= MOD_MASK_ALT; if (modifierFlags & NSEventModifierFlagCommand) modMask |= MOD_MASK_CMD; @@ -3189,11 +3189,11 @@ static int eventModifierFlagsToVimMouseModMask(int modifierFlags) { int modMask = 0; - if (modifierFlags & NSShiftKeyMask) + if (modifierFlags & NSEventModifierFlagShift) modMask |= MOUSE_SHIFT; - if (modifierFlags & NSControlKeyMask) + if (modifierFlags & NSEventModifierFlagControl) modMask |= MOUSE_CTRL; - if (modifierFlags & NSAlternateKeyMask) + if (modifierFlags & NSEventModifierFlagOption) modMask |= MOUSE_ALT; return modMask; diff --git a/src/MacVim/MMCoreTextView+ToolTip.m b/src/MacVim/MMCoreTextView+ToolTip.m index 83fd12abb1..e0989cc1c2 100644 --- a/src/MacVim/MMCoreTextView+ToolTip.m +++ b/src/MacVim/MMCoreTextView+ToolTip.m @@ -150,12 +150,12 @@ static const NSTrackingRectTag kTrackingRectTag = 0xBADFACE; } } -// Sends a fake NSMouseExited event to the view for its current tracking rect. +// Sends a fake NSEventTypeMouseExited event to the view for its current tracking rect. - (void)_sendToolTipMouseExited { // Nothing matters except window, trackingNumber, and userData. int windowNumber = [[self window] windowNumber]; - NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseExited + NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSEventTypeMouseExited location:NSMakePoint(0, 0) modifierFlags:0 timestamp:0 @@ -167,12 +167,12 @@ static const NSTrackingRectTag kTrackingRectTag = 0xBADFACE; [trackingRectOwner_ mouseExited:fakeEvent]; } -// Sends a fake NSMouseEntered event to the view for its current tracking rect. +// Sends a fake NSEventTypeMouseEntered event to the view for its current tracking rect. - (void)_sendToolTipMouseEntered { // Nothing matters except window, trackingNumber, and userData. int windowNumber = [[self window] windowNumber]; - NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseEntered + NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSEventTypeMouseEntered location:NSMakePoint(0, 0) modifierFlags:0 timestamp:0 diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index 0dccb987ed..46f92c1052 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -910,7 +910,7 @@ defaultAdvanceForFont(NSFont *font) numColumns:width]; [signImg drawInRect:r fromRect:NSZeroRect - operation:NSCompositeSourceOver + operation:NSCompositingOperationSourceOver fraction:1.0]; } else if (DrawStringDrawType == type) { int bg = *((int*)bytes); bytes += sizeof(int); diff --git a/src/MacVim/MMFullScreenWindow.m b/src/MacVim/MMFullScreenWindow.m index 521016599b..ee6205de23 100644 --- a/src/MacVim/MMFullScreenWindow.m +++ b/src/MacVim/MMFullScreenWindow.m @@ -67,7 +67,7 @@ enum { // (another way would be to make the existing window large enough that the // title bar is off screen. but that doesn't work with multiple screens). self = [super initWithContentRect:[screen frame] - styleMask:NSBorderlessWindowMask + styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES // since we're passing [screen frame] above, diff --git a/src/MacVim/MMTextViewHelper.m b/src/MacVim/MMTextViewHelper.m index fc5adf3108..46f7601d67 100644 --- a/src/MacVim/MMTextViewHelper.m +++ b/src/MacVim/MMTextViewHelper.m @@ -158,12 +158,13 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) // ASCII chars in the range after space (0x20) and before backspace (0x7f). // Note that this implies that 'mmta' (if enabled) breaks input methods // when the Alt key is held. - if ((flags & NSAlternateKeyMask) && [mmta boolValue] && [unmod length] == 1 + if ((flags & NSEventModifierFlagOption) + && [mmta boolValue] && [unmod length] == 1 && [unmod characterAtIndex:0] > 0x20) { ASLogDebug(@"MACMETA key, don't interpret it"); string = unmod; - } else if (imState && (flags & NSControlKeyMask) - && !(flags & (NSAlternateKeyMask|NSEventModifierFlagCommand)) + } else if (imState && (flags & NSEventModifierFlagControl) + && !(flags & (NSEventModifierFlagOption|NSEventModifierFlagCommand)) && [unmod length] == 1 && ([unmod characterAtIndex:0] == '6' || [unmod characterAtIndex:0] == '^')) { @@ -186,8 +187,9 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) // following heuristic seems to work but it may have to change. // Note that the Shift and Alt flags may also need to be cleared // (see doKeyDown:keyCode:modifiers: in MMBackend). - if ((flags & NSShiftKeyMask && !(flags & NSAlternateKeyMask)) - || flags & NSControlKeyMask) + if ((flags & NSEventModifierFlagShift + && !(flags & NSEventModifierFlagOption)) + || flags & NSEventModifierFlagControl) string = unmod; } } @@ -339,12 +341,12 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) // If desired, intepret Ctrl-Click as a right mouse click. BOOL translateCtrlClick = [[NSUserDefaults standardUserDefaults] boolForKey:MMTranslateCtrlClickKey]; - flags = flags & NSDeviceIndependentModifierFlagsMask; + flags = flags & NSEventModifierFlagDeviceIndependentFlagsMask; if (translateCtrlClick && button == 0 && - (flags == NSControlKeyMask || - flags == (NSControlKeyMask|NSAlphaShiftKeyMask))) { + (flags == NSEventModifierFlagControl || flags == + (NSEventModifierFlagControl|NSEventModifierFlagCapsLock))) { button = 1; - flags &= ~NSControlKeyMask; + flags &= ~NSEventModifierFlagControl; } [data appendBytes:&row length:sizeof(int)]; @@ -853,7 +855,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) // The low 16 bits are not used for modifier flags by NSEvent. Use // these bits for custom flags. - flags &= NSDeviceIndependentModifierFlagsMask; + flags &= NSEventModifierFlagDeviceIndependentFlagsMask; if ([currentEvent isARepeat]) flags |= 1; @@ -886,8 +888,8 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) // HACK! Keys on the numeric key pad are treated as special keys by Vim // so we need to pass on key code and modifier flags in this situation. unsigned mods = [currentEvent modifierFlags]; - if (mods & NSNumericPadKeyMask) { - flags = mods & NSDeviceIndependentModifierFlagsMask; + if (mods & NSEventModifierFlagNumericPad) { + flags = mods & NSEventModifierFlagDeviceIndependentFlagsMask; keyCode = [currentEvent keyCode]; } diff --git a/src/MacVim/MacVim.h b/src/MacVim/MacVim.h index a487e89c7d..adf788309e 100644 --- a/src/MacVim/MacVim.h +++ b/src/MacVim/MacVim.h @@ -41,10 +41,24 @@ #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 // Deprecated constants in 10.12 SDK # define NSAlertStyleWarning NSWarningAlertStyle +# define NSCompositingOperationSourceOver NSCompositeSourceOver # define NSControlSizeRegular NSRegularControlSize +# define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask # define NSEventModifierFlagCommand NSCommandKeyMask +# define NSEventModifierFlagControl NSControlKeyMask +# define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask +# define NSEventModifierFlagHelp NSHelpKeyMask +# define NSEventModifierFlagNumericPad NSNumericPadKeyMask +# define NSEventModifierFlagOption NSAlternateKeyMask +# define NSEventModifierFlagShift NSShiftKeyMask +# define NSEventTypeApplicationDefined NSApplicationDefined +# define NSEventTypeKeyDown NSKeyDown +# define NSEventTypeKeyUp NSKeyUp # define NSEventTypeLeftMouseUp NSLeftMouseUp +# define NSEventTypeMouseEntered NSMouseEntered +# define NSEventTypeMouseExited NSMouseExited # define NSEventTypeRightMouseDown NSRightMouseDown +# define NSWindowStyleMaskBorderless NSBorderlessWindowMask # define NSWindowStyleMaskClosable NSClosableWindowMask # define NSWindowStyleMaskFullScreen NSFullScreenWindowMask # define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index fffe01c1f3..23695632b4 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -2247,11 +2247,11 @@ static int vimModMaskToEventModifierFlags(int mods) int flags = 0; if (mods & MOD_MASK_SHIFT) - flags |= NSShiftKeyMask; + flags |= NSEventModifierFlagShift; if (mods & MOD_MASK_CTRL) - flags |= NSControlKeyMask; + flags |= NSEventModifierFlagControl; if (mods & MOD_MASK_ALT) - flags |= NSAlternateKeyMask; + flags |= NSEventModifierFlagOption; if (mods & MOD_MASK_CMD) flags |= NSEventModifierFlagCommand;