| @@ -34,7 +34,8 @@ | |||
| // The AudioHardwareService stuff was deprecated in 10.11 but there's no replacement yet, | |||
| // so we'll have to silence the warnings here and revisit it in a future OS version.. | |||
| #if defined (MAC_OS_X_VERSION_10_11) && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_11 | |||
| #if ((defined (MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_12) \ | |||
| || (defined (MAC_OS_X_VERSION_10_11) && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_11)) | |||
| #pragma clang diagnostic ignored "-Wdeprecated-declarations" | |||
| #endif | |||
| #endif | |||
| @@ -42,6 +42,46 @@ | |||
| #include <sys/fcntl.h> | |||
| #else | |||
| #import <Cocoa/Cocoa.h> | |||
| #if (! defined MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 | |||
| #define NSEventModifierFlagCommand NSCommandKeyMask | |||
| #define NSEventModifierFlagControl NSControlKeyMask | |||
| #define NSEventModifierFlagHelp NSHelpKeyMask | |||
| #define NSEventModifierFlagNumericPad NSNumericPadKeyMask | |||
| #define NSEventModifierFlagOption NSAlternateKeyMask | |||
| #define NSEventModifierFlagShift NSShiftKeyMask | |||
| #define NSCompositingOperationSourceOver NSCompositeSourceOver | |||
| #define NSEventMaskApplicationDefined NSApplicationDefinedMask | |||
| #define NSEventTypeApplicationDefined NSApplicationDefined | |||
| #define NSEventTypeCursorUpdate NSCursorUpdate | |||
| #define NSEventTypeMouseMoved NSMouseMoved | |||
| #define NSEventTypeLeftMouseDown NSLeftMouseDown | |||
| #define NSEventTypeRightMouseDown NSRightMouseDown | |||
| #define NSEventTypeOtherMouseDown NSOtherMouseDown | |||
| #define NSEventTypeLeftMouseUp NSLeftMouseUp | |||
| #define NSEventTypeRightMouseUp NSRightMouseUp | |||
| #define NSEventTypeOtherMouseUp NSOtherMouseUp | |||
| #define NSEventTypeLeftMouseDragged NSLeftMouseDragged | |||
| #define NSEventTypeRightMouseDragged NSRightMouseDragged | |||
| #define NSEventTypeOtherMouseDragged NSOtherMouseDragged | |||
| #define NSEventTypeScrollWheel NSScrollWheel | |||
| #define NSEventTypeKeyDown NSKeyDown | |||
| #define NSEventTypeKeyUp NSKeyUp | |||
| #define NSEventTypeFlagsChanged NSFlagsChanged | |||
| #define NSEventMaskAny NSAnyEventMask | |||
| #define NSWindowStyleMaskBorderless NSBorderlessWindowMask | |||
| #define NSWindowStyleMaskClosable NSClosableWindowMask | |||
| #define NSWindowStyleMaskFullScreen NSFullScreenWindowMask | |||
| #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask | |||
| #define NSWindowStyleMaskResizable NSResizableWindowMask | |||
| #define NSWindowStyleMaskTitled NSTitledWindowMask | |||
| #define NSAlertStyleCritical NSCriticalAlertStyle | |||
| #define NSControlSizeRegular NSRegularControlSize | |||
| #define NSEventTypeMouseEntered NSMouseEntered | |||
| #define NSEventTypeMouseExited NSMouseExited | |||
| #define NSAlertStyleInformational NSInformationalAlertStyle | |||
| #define NSEventTypeTabletPoint NSTabletPoint | |||
| #define NSEventTypeTabletProximity NSTabletProximity | |||
| #endif | |||
| #import <CoreAudio/HostTime.h> | |||
| #include <sys/dir.h> | |||
| #endif | |||
| @@ -297,7 +297,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) | |||
| { | |||
| CFRunLoopRunInMode (kCFRunLoopDefaultMode, 0.001, true); | |||
| NSEvent* e = [NSApp nextEventMatchingMask: NSAnyEventMask | |||
| NSEvent* e = [NSApp nextEventMatchingMask: NSEventMaskAny | |||
| untilDate: [NSDate dateWithTimeIntervalSinceNow: 0.001] | |||
| inMode: NSDefaultRunLoopMode | |||
| dequeue: YES]; | |||
| @@ -389,9 +389,9 @@ private: | |||
| if ([menu indexOfItem: item] >= 0) | |||
| { | |||
| NSEvent* f35Event = [NSEvent keyEventWithType: NSKeyDown | |||
| NSEvent* f35Event = [NSEvent keyEventWithType: NSEventTypeKeyDown | |||
| location: NSZeroPoint | |||
| modifierFlags: NSCommandKeyMask | |||
| modifierFlags: NSEventModifierFlagCommand | |||
| timestamp: 0 | |||
| windowNumber: 0 | |||
| context: [NSGraphicsContext currentContext] | |||
| @@ -412,10 +412,10 @@ private: | |||
| static unsigned int juceModsToNSMods (const ModifierKeys mods) | |||
| { | |||
| unsigned int m = 0; | |||
| if (mods.isShiftDown()) m |= NSShiftKeyMask; | |||
| if (mods.isCtrlDown()) m |= NSControlKeyMask; | |||
| if (mods.isAltDown()) m |= NSAlternateKeyMask; | |||
| if (mods.isCommandDown()) m |= NSCommandKeyMask; | |||
| if (mods.isShiftDown()) m |= NSEventModifierFlagShift; | |||
| if (mods.isCtrlDown()) m |= NSEventModifierFlagControl; | |||
| if (mods.isAltDown()) m |= NSEventModifierFlagOption; | |||
| if (mods.isCommandDown()) m |= NSEventModifierFlagCommand; | |||
| return m; | |||
| } | |||
| @@ -481,13 +481,13 @@ private: | |||
| // our own components, which may have wanted to intercept it. So, rather than dispatching directly, we'll feed it back | |||
| // into the focused component and let it trigger the menu item indirectly. | |||
| NSEvent* e = [NSApp currentEvent]; | |||
| if ([e type] == NSKeyDown || [e type] == NSKeyUp) | |||
| if ([e type] == NSEventTypeKeyDown || [e type] == NSEventTypeKeyUp) | |||
| { | |||
| if (juce::Component* focused = juce::Component::getCurrentlyFocusedComponent()) | |||
| { | |||
| if (juce::NSViewComponentPeer* peer = dynamic_cast<juce::NSViewComponentPeer*> (focused->getPeer())) | |||
| { | |||
| if ([e type] == NSKeyDown) | |||
| if ([e type] == NSEventTypeKeyDown) | |||
| peer->redirectKeyDown (e); | |||
| else | |||
| peer->redirectKeyUp (e); | |||
| @@ -624,7 +624,7 @@ namespace MainMenuHelpers | |||
| createMenuItem (menu, "Hide " + appName, @selector (hide:), nsStringLiteral ("h")); | |||
| [createMenuItem (menu, "Hide Others", @selector (hideOtherApplications:), nsStringLiteral ("h")) | |||
| setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask]; | |||
| setKeyEquivalentModifierMask: NSEventModifierFlagCommand | NSEventModifierFlagOption]; | |||
| createMenuItem (menu, "Show All", @selector (unhideAllApplications:), nsEmptyString()); | |||
| @@ -375,7 +375,7 @@ public: | |||
| bool isKioskMode() const override | |||
| { | |||
| #if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 | |||
| if (hasNativeTitleBar() && ([window styleMask] & NSFullScreenWindowMask) != 0) | |||
| if (hasNativeTitleBar() && ([window styleMask] & NSWindowStyleMaskFullScreen) != 0) | |||
| return true; | |||
| #endif | |||
| @@ -729,7 +729,7 @@ public: | |||
| break; // (these all seem to generate unwanted garbage unicode strings) | |||
| default: | |||
| if (([ev modifierFlags] & NSCommandKeyMask) != 0 | |||
| if (([ev modifierFlags] & NSEventModifierFlagCommand) != 0 | |||
| || (keyCode >= NSF1FunctionKey && keyCode <= NSF35FunctionKey)) | |||
| textCharacter = 0; | |||
| break; | |||
| @@ -758,7 +758,7 @@ public: | |||
| updateKeysDown (ev, true); | |||
| bool used = handleKeyEvent (ev, true); | |||
| if (([ev modifierFlags] & NSCommandKeyMask) != 0) | |||
| if (([ev modifierFlags] & NSEventModifierFlagCommand) != 0) | |||
| { | |||
| // for command keys, the key-up event is thrown away, so simulate one.. | |||
| updateKeysDown (ev, false); | |||
| @@ -1098,10 +1098,10 @@ public: | |||
| { | |||
| int m = 0; | |||
| if ((flags & NSShiftKeyMask) != 0) m |= ModifierKeys::shiftModifier; | |||
| if ((flags & NSControlKeyMask) != 0) m |= ModifierKeys::ctrlModifier; | |||
| if ((flags & NSAlternateKeyMask) != 0) m |= ModifierKeys::altModifier; | |||
| if ((flags & NSCommandKeyMask) != 0) m |= ModifierKeys::commandModifier; | |||
| if ((flags & NSEventModifierFlagShift) != 0) m |= ModifierKeys::shiftModifier; | |||
| if ((flags & NSEventModifierFlagControl) != 0) m |= ModifierKeys::ctrlModifier; | |||
| if ((flags & NSEventModifierFlagOption) != 0) m |= ModifierKeys::altModifier; | |||
| if ((flags & NSEventModifierFlagCommand) != 0) m |= ModifierKeys::commandModifier; | |||
| currentModifiers = currentModifiers.withOnlyMouseButtons().withFlags (m); | |||
| } | |||
| @@ -1174,7 +1174,7 @@ public: | |||
| else | |||
| keyCode = (int) CharacterFunctions::toUpperCase ((juce_wchar) keyCode); | |||
| if (([ev modifierFlags] & NSNumericPadKeyMask) != 0) | |||
| if (([ev modifierFlags] & NSEventModifierFlagNumericPad) != 0) | |||
| { | |||
| const int numPadConversions[] = { '0', KeyPress::numberPad0, '1', KeyPress::numberPad1, | |||
| '2', KeyPress::numberPad2, '3', KeyPress::numberPad3, | |||
| @@ -1205,7 +1205,7 @@ public: | |||
| { | |||
| @try | |||
| { | |||
| if (e.type != NSMouseEntered && e.type != NSMouseExited) | |||
| if (e.type != NSEventTypeMouseEntered && e.type != NSEventTypeMouseExited) | |||
| return (float) e.pressure; | |||
| } | |||
| @catch (NSException* e) {} | |||
| @@ -1229,12 +1229,12 @@ public: | |||
| static unsigned int getNSWindowStyleMask (const int flags) noexcept | |||
| { | |||
| unsigned int style = (flags & windowHasTitleBar) != 0 ? NSTitledWindowMask | |||
| : NSBorderlessWindowMask; | |||
| unsigned int style = (flags & windowHasTitleBar) != 0 ? NSWindowStyleMaskTitled | |||
| : NSWindowStyleMaskBorderless; | |||
| if ((flags & windowHasMinimiseButton) != 0) style |= NSMiniaturizableWindowMask; | |||
| if ((flags & windowHasCloseButton) != 0) style |= NSClosableWindowMask; | |||
| if ((flags & windowIsResizable) != 0) style |= NSResizableWindowMask; | |||
| if ((flags & windowHasMinimiseButton) != 0) style |= NSWindowStyleMaskMiniaturizable; | |||
| if ((flags & windowHasCloseButton) != 0) style |= NSWindowStyleMaskClosable; | |||
| if ((flags & windowIsResizable) != 0) style |= NSWindowStyleMaskResizable; | |||
| return style; | |||
| } | |||
| @@ -1433,34 +1433,34 @@ private: | |||
| switch ([e type]) | |||
| { | |||
| case NSKeyDown: | |||
| case NSKeyUp: | |||
| case NSEventTypeKeyDown: | |||
| case NSEventTypeKeyUp: | |||
| isKey = isInputAttempt = true; | |||
| break; | |||
| case NSLeftMouseDown: | |||
| case NSRightMouseDown: | |||
| case NSOtherMouseDown: | |||
| case NSEventTypeLeftMouseDown: | |||
| case NSEventTypeRightMouseDown: | |||
| case NSEventTypeOtherMouseDown: | |||
| isInputAttempt = true; | |||
| break; | |||
| case NSLeftMouseDragged: | |||
| case NSRightMouseDragged: | |||
| case NSLeftMouseUp: | |||
| case NSRightMouseUp: | |||
| case NSOtherMouseUp: | |||
| case NSOtherMouseDragged: | |||
| case NSEventTypeLeftMouseDragged: | |||
| case NSEventTypeRightMouseDragged: | |||
| case NSEventTypeLeftMouseUp: | |||
| case NSEventTypeRightMouseUp: | |||
| case NSEventTypeOtherMouseUp: | |||
| case NSEventTypeOtherMouseDragged: | |||
| if (Desktop::getInstance().getDraggingMouseSource(0) != nullptr) | |||
| return false; | |||
| break; | |||
| case NSMouseMoved: | |||
| case NSMouseEntered: | |||
| case NSMouseExited: | |||
| case NSCursorUpdate: | |||
| case NSScrollWheel: | |||
| case NSTabletPoint: | |||
| case NSTabletProximity: | |||
| case NSEventTypeMouseMoved: | |||
| case NSEventTypeMouseEntered: | |||
| case NSEventTypeMouseExited: | |||
| case NSEventTypeCursorUpdate: | |||
| case NSEventTypeScrollWheel: | |||
| case NSEventTypeTabletPoint: | |||
| case NSEventTypeTabletProximity: | |||
| break; | |||
| default: | |||
| @@ -2079,7 +2079,7 @@ void Desktop::setKioskComponent (Component* kioskComp, bool shouldBeEnabled, boo | |||
| if (shouldBeEnabled) | |||
| { | |||
| if (peer->hasNativeTitleBar()) | |||
| [peer->window setStyleMask: NSBorderlessWindowMask]; | |||
| [peer->window setStyleMask: NSWindowStyleMaskBorderless]; | |||
| [NSApp setPresentationOptions: (allowMenusAndBars ? (NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar) | |||
| : (NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar))]; | |||
| @@ -89,8 +89,8 @@ private: | |||
| [alert setMessageText: juceStringToNS (title)]; | |||
| [alert setInformativeText: juceStringToNS (message)]; | |||
| [alert setAlertStyle: iconType == AlertWindow::WarningIcon ? NSCriticalAlertStyle | |||
| : NSInformationalAlertStyle]; | |||
| [alert setAlertStyle: iconType == AlertWindow::WarningIcon ? NSAlertStyleCritical | |||
| : NSAlertStyleInformational]; | |||
| addButton (alert, button1); | |||
| addButton (alert, button2); | |||
| addButton (alert, button3); | |||
| @@ -419,7 +419,7 @@ Image juce_createIconForFile (const File& file) | |||
| selectImageForDrawing (result); | |||
| [image drawAtPoint: NSMakePoint (0, 0) | |||
| fromRect: NSMakeRect (0, 0, [image size].width, [image size].height) | |||
| operation: NSCompositeSourceOver fraction: 1.0f]; | |||
| operation: NSCompositingOperationSourceOver fraction: 1.0f]; | |||
| releaseImageAfterDrawing(); | |||
| return result; | |||
| @@ -85,8 +85,8 @@ public: | |||
| { | |||
| NSEventType type = [e type]; | |||
| const bool isLeft = (type == NSLeftMouseDown || type == NSLeftMouseUp); | |||
| const bool isRight = (type == NSRightMouseDown || type == NSRightMouseUp); | |||
| const bool isLeft = (type == NSEventTypeLeftMouseDown || type == NSEventTypeLeftMouseUp); | |||
| const bool isRight = (type == NSEventTypeRightMouseDown || type == NSEventTypeRightMouseUp); | |||
| if (owner.isCurrentlyBlockedByAnotherModalComponent()) | |||
| { | |||
| @@ -98,7 +98,7 @@ public: | |||
| { | |||
| ModifierKeys eventMods (ModifierKeys::getCurrentModifiersRealtime()); | |||
| if (([e modifierFlags] & NSCommandKeyMask) != 0) | |||
| if (([e modifierFlags] & NSEventModifierFlagCommand) != 0) | |||
| eventMods = eventMods.withFlags (ModifierKeys::commandModifier); | |||
| const Time now (Time::getCurrentTime()); | |||
| @@ -121,7 +121,7 @@ public: | |||
| pressure, &owner, &owner, now, | |||
| Point<float>(), now, 1, false)); | |||
| } | |||
| else if (type == NSMouseMoved) | |||
| else if (type == NSEventTypeMouseMoved) | |||
| { | |||
| owner.mouseMove (MouseEvent (mouseSource, Point<float>(), eventMods, | |||
| pressure, &owner, &owner, now, | |||
| @@ -214,7 +214,7 @@ private: | |||
| bounds.origin.y + ((bounds.size.height - imageSize.height) / 2.0f), | |||
| imageSize.width, imageSize.height) | |||
| fromRect: NSZeroRect | |||
| operation: NSCompositeSourceOver | |||
| operation: NSCompositingOperationSourceOver | |||
| fraction: 1.0f]; | |||
| } | |||
| } | |||