[PATCH] winemac.drv: Fix warnings for constants deprecated by macOS 10.12.

Ken Thomases ken at codeweavers.com
Thu Jul 23 08:05:54 CDT 2020


Hi Brendan,

Thanks for doing this.

The multiple blocks of defines is bothersome.  It looks to me like all of these files already import cocoa_event.h.  We could do all of the defines in there.  (Or in cocoa_app.h, which would just have to be added to cocoa_opengl.m.)

Thanks,
Ken

> On Jul 22, 2020, at 5:50 PM, Brendan Shanks <bshanks at codeweavers.com> wrote:
> 
> Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
> ---
> dlls/winemac.drv/cocoa_app.m         | 74 +++++++++++++++-------
> dlls/winemac.drv/cocoa_event.m       | 15 ++++-
> dlls/winemac.drv/cocoa_opengl.m      |  6 +-
> dlls/winemac.drv/cocoa_status_item.m | 13 +++-
> dlls/winemac.drv/cocoa_window.m      | 91 ++++++++++++++++------------
> 5 files changed, 133 insertions(+), 66 deletions(-)
> 
> diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
> index 8e66721da11..f2059132a82 100644
> --- a/dlls/winemac.drv/cocoa_app.m
> +++ b/dlls/winemac.drv/cocoa_app.m
> @@ -25,6 +25,30 @@
> #import "cocoa_event.h"
> #import "cocoa_window.h"
> 
> +#if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
> +/* For older SDKs, #define the new names of constants deprecated/renamed in macOS 10.12. */
> +#define NSEventMaskAny                      NSAnyEventMask
> +#define NSEventModifierFlagCommand          NSCommandKeyMask
> +#define NSEventModifierFlagControl          NSControlKeyMask
> +#define NSEventModifierFlagOption           NSAlternateKeyMask
> +#define NSEventTypeAppKitDefined            NSAppKitDefined
> +#define NSEventTypeFlagsChanged             NSFlagsChanged
> +#define NSEventTypeKeyDown                  NSKeyDown
> +#define NSEventTypeKeyUp                    NSKeyUp
> +#define NSEventTypeLeftMouseDown            NSLeftMouseDown
> +#define NSEventTypeLeftMouseDragged         NSLeftMouseDragged
> +#define NSEventTypeLeftMouseUp              NSLeftMouseUp
> +#define NSEventTypeMouseMoved               NSMouseMoved
> +#define NSEventTypeOtherMouseDown           NSOtherMouseDown
> +#define NSEventTypeOtherMouseDragged        NSOtherMouseDragged
> +#define NSEventTypeOtherMouseUp             NSOtherMouseUp
> +#define NSEventTypeRightMouseDown           NSRightMouseDown
> +#define NSEventTypeRightMouseUp             NSRightMouseUp
> +#define NSEventTypeRightMouseDragged        NSRightMouseDragged
> +#define NSEventTypeScrollWheel              NSScrollWheel
> +#define NSWindowStyleMaskResizable          NSResizableWindowMask
> +#define NSWindowStyleMaskUtilityWindow      NSUtilityWindowMask
> +#endif
> 
> static NSString* const WineAppWaitQueryResponseMode = @"WineAppWaitQueryResponseMode";
> 
> @@ -258,7 +282,7 @@ - (void) transformProcessToForeground
>             item = [submenu addItemWithTitle:WineLocalizedString(STRING_MENU_ITEM_HIDE_OTHERS)
>                                       action:@selector(hideOtherApplications:)
>                                keyEquivalent:@"h"];
> -            [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask];
> +            [item setKeyEquivalentModifierMask:NSEventModifierFlagCommand | NSEventModifierFlagOption];
> 
>             item = [submenu addItemWithTitle:WineLocalizedString(STRING_MENU_ITEM_SHOW_ALL)
>                                       action:@selector(unhideAllApplications:)
> @@ -271,7 +295,7 @@ - (void) transformProcessToForeground
>             else
>                 title = WineLocalizedString(STRING_MENU_ITEM_QUIT);
>             item = [submenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
> -            [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask];
> +            [item setKeyEquivalentModifierMask:NSEventModifierFlagCommand | NSEventModifierFlagOption];
>             item = [[[NSMenuItem alloc] init] autorelease];
>             [item setTitle:WineLocalizedString(STRING_MENU_WINE)];
>             [item setSubmenu:submenu];
> @@ -290,7 +314,9 @@ - (void) transformProcessToForeground
>                 item = [submenu addItemWithTitle:WineLocalizedString(STRING_MENU_ITEM_ENTER_FULL_SCREEN)
>                                           action:@selector(toggleFullScreen:)
>                                    keyEquivalent:@"f"];
> -                [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask | NSControlKeyMask];
> +                [item setKeyEquivalentModifierMask:NSEventModifierFlagCommand |
> +                                                   NSEventModifierFlagOption |
> +                                                   NSEventModifierFlagControl];
>             }
>             [submenu addItem:[NSMenuItem separatorItem]];
>             [submenu addItemWithTitle:WineLocalizedString(STRING_MENU_ITEM_BRING_ALL_TO_FRONT)
> @@ -317,7 +343,7 @@ - (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout processEvents:(B
>             if (processEvents)
>             {
>                 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
> -                NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
> +                NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
>                                                     untilDate:timeout
>                                                        inMode:NSDefaultRunLoopMode
>                                                       dequeue:YES];
> @@ -1607,7 +1633,7 @@ - (void) handleWindowDrag:(NSEvent*)anEvent begin:(BOOL)begin
>     - (void) handleMouseMove:(NSEvent*)anEvent
>     {
>         WineWindow* targetWindow;
> -        BOOL drag = [anEvent type] != NSMouseMoved;
> +        BOOL drag = [anEvent type] != NSEventTypeMouseMoved;
> 
>         if ([windowsBeingDragged count])
>             targetWindow = nil;
> @@ -1758,11 +1784,11 @@ - (void) handleMouseButton:(NSEvent*)theEvent
>         WineWindow* windowBroughtForward = nil;
>         BOOL process = FALSE;
> 
> -        if (type == NSLeftMouseUp && [windowsBeingDragged count])
> +        if (type == NSEventTypeLeftMouseUp && [windowsBeingDragged count])
>             [self handleWindowDrag:theEvent begin:NO];
> 
>         if ([window isKindOfClass:[WineWindow class]] &&
> -            type == NSLeftMouseDown &&
> +            type == NSEventTypeLeftMouseDown &&
>             ![theEvent wine_commandKeyDown])
>         {
>             NSWindowButton windowButton;
> @@ -1795,7 +1821,9 @@ - (void) handleMouseButton:(NSEvent*)theEvent
> 
>         if ([window isKindOfClass:[WineWindow class]])
>         {
> -            BOOL pressed = (type == NSLeftMouseDown || type == NSRightMouseDown || type == NSOtherMouseDown);
> +            BOOL pressed = (type == NSEventTypeLeftMouseDown ||
> +                            type == NSEventTypeRightMouseDown ||
> +                            type == NSEventTypeOtherMouseDown);
>             CGPoint pt = CGEventGetLocation([theEvent CGEvent]);
> 
>             if (clippingCursor)
> @@ -1811,7 +1839,7 @@ - (void) handleMouseButton:(NSEvent*)theEvent
>                     NSPoint nspoint = [self flippedMouseLocation:NSPointFromCGPoint(pt)];
>                     NSRect contentRect = [window contentRectForFrameRect:[window frame]];
>                     process = NSMouseInRect(nspoint, contentRect, NO);
> -                    if (process && [window styleMask] & NSResizableWindowMask)
> +                    if (process && [window styleMask] & NSWindowStyleMaskResizable)
>                     {
>                         // Ignore clicks in the grow box (resize widget).
>                         HIPoint origin = { 0, 0 };
> @@ -1821,7 +1849,7 @@ - (void) handleMouseButton:(NSEvent*)theEvent
> 
>                         info.kind = kHIThemeGrowBoxKindNormal;
>                         info.direction = kThemeGrowRight | kThemeGrowDown;
> -                        if ([window styleMask] & NSUtilityWindowMask)
> +                        if ([window styleMask] & NSWindowStyleMaskUtilityWindow)
>                             info.size = kHIThemeGrowBoxSizeSmall;
>                         else
>                             info.size = kHIThemeGrowBoxSizeNormal;
> @@ -2063,27 +2091,27 @@ - (BOOL) handleEvent:(NSEvent*)anEvent
>         BOOL ret = FALSE;
>         NSEventType type = [anEvent type];
> 
> -        if (type == NSFlagsChanged)
> +        if (type == NSEventTypeFlagsChanged)
>             self.lastFlagsChanged = anEvent;
> -        else if (type == NSMouseMoved || type == NSLeftMouseDragged ||
> -                 type == NSRightMouseDragged || type == NSOtherMouseDragged)
> +        else if (type == NSEventTypeMouseMoved || type == NSEventTypeLeftMouseDragged ||
> +                 type == NSEventTypeRightMouseDragged || type == NSEventTypeOtherMouseDragged)
>         {
>             [self handleMouseMove:anEvent];
>             ret = mouseCaptureWindow && ![windowsBeingDragged count];
>         }
> -        else if (type == NSLeftMouseDown || type == NSLeftMouseUp ||
> -                 type == NSRightMouseDown || type == NSRightMouseUp ||
> -                 type == NSOtherMouseDown || type == NSOtherMouseUp)
> +        else if (type == NSEventTypeLeftMouseDown || type == NSEventTypeLeftMouseUp ||
> +                 type == NSEventTypeRightMouseDown || type == NSEventTypeRightMouseUp ||
> +                 type == NSEventTypeOtherMouseDown || type == NSEventTypeOtherMouseUp)
>         {
>             [self handleMouseButton:anEvent];
>             ret = mouseCaptureWindow && ![windowsBeingDragged count];
>         }
> -        else if (type == NSScrollWheel)
> +        else if (type == NSEventTypeScrollWheel)
>         {
>             [self handleScrollWheel:anEvent];
>             ret = mouseCaptureWindow != nil;
>         }
> -        else if (type == NSKeyDown)
> +        else if (type == NSEventTypeKeyDown)
>         {
>             // -[NSApplication sendEvent:] seems to consume presses of the Help
>             // key (Insert key on PC keyboards), so we have to bypass it and
> @@ -2094,7 +2122,7 @@ - (BOOL) handleEvent:(NSEvent*)anEvent
>                 ret = TRUE;
>             }
>         }
> -        else if (type == NSKeyUp)
> +        else if (type == NSEventTypeKeyUp)
>         {
>             uint16_t keyCode = [anEvent keyCode];
>             if ([self isKeyPressed:keyCode])
> @@ -2105,7 +2133,7 @@ - (BOOL) handleEvent:(NSEvent*)anEvent
>                     [window postKeyEvent:anEvent];
>             }
>         }
> -        else if (type == NSAppKitDefined)
> +        else if (type == NSEventTypeAppKitDefined)
>         {
>             short subtype = [anEvent subtype];
> 
> @@ -2123,11 +2151,11 @@ - (void) didSendEvent:(NSEvent*)anEvent
>     {
>         NSEventType type = [anEvent type];
> 
> -        if (type == NSKeyDown && ![anEvent isARepeat] && [anEvent keyCode] == kVK_Tab)
> +        if (type == NSEventTypeKeyDown && ![anEvent isARepeat] && [anEvent keyCode] == kVK_Tab)
>         {
>             NSUInteger modifiers = [anEvent modifierFlags];
> -            if ((modifiers & NSCommandKeyMask) &&
> -                !(modifiers & (NSControlKeyMask | NSAlternateKeyMask)))
> +            if ((modifiers & NSEventModifierFlagCommand) &&
> +                !(modifiers & (NSEventModifierFlagControl | NSEventModifierFlagOption)))
>             {
>                 // Command-Tab and Command-Shift-Tab would normally be intercepted
>                 // by the system to switch applications.  If we're seeing it, it's
> diff --git a/dlls/winemac.drv/cocoa_event.m b/dlls/winemac.drv/cocoa_event.m
> index 40066ffda5e..163261e1d16 100644
> --- a/dlls/winemac.drv/cocoa_event.m
> +++ b/dlls/winemac.drv/cocoa_event.m
> @@ -29,6 +29,14 @@
> #import "cocoa_app.h"
> #import "cocoa_window.h"
> 
> +#if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
> +/* For older SDKs, #define the new names of constants deprecated/renamed in macOS 10.12. */
> +#define NSEventModifierFlagCommand          NSCommandKeyMask
> +#define NSEventModifierFlagControl          NSControlKeyMask
> +#define NSEventModifierFlagOption           NSAlternateKeyMask
> +#define NSEventModifierFlagShift            NSShiftKeyMask
> +#define NSEventTypeApplicationDefined       NSApplicationDefined
> +#endif
> 
> static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThreadDictionaryKey";
> 
> @@ -44,7 +52,10 @@ @implementation NSEvent (WineExtensions)
> 
>     static BOOL wine_commandKeyDown(NSUInteger flags)
>     {
> -        return ((flags & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)) == NSCommandKeyMask);
> +        return ((flags & (NSEventModifierFlagShift |
> +                          NSEventModifierFlagControl |
> +                          NSEventModifierFlagOption |
> +                          NSEventModifierFlagCommand)) == NSEventModifierFlagCommand);
>     }
> 
>     + (BOOL) wine_commandKeyDown
> @@ -754,7 +765,7 @@ void macdrv_set_query_done(macdrv_query *query)
>         query->done = TRUE;
>         macdrv_release_query(query);
> 
> -        event = [NSEvent otherEventWithType:NSApplicationDefined
> +        event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
>                                    location:NSZeroPoint
>                               modifierFlags:0
>                                   timestamp:[[NSProcessInfo processInfo] systemUptime]
> diff --git a/dlls/winemac.drv/cocoa_opengl.m b/dlls/winemac.drv/cocoa_opengl.m
> index 96e27b76e5d..eef4d16fcc8 100644
> --- a/dlls/winemac.drv/cocoa_opengl.m
> +++ b/dlls/winemac.drv/cocoa_opengl.m
> @@ -25,6 +25,10 @@
> #include "macdrv_cocoa.h"
> #include "cocoa_event.h"
> 
> +#if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
> +/* For older SDKs, #define the new names of constants deprecated/renamed in macOS 10.12. */
> +#define NSWindowStyleMaskBorderless     NSBorderlessWindowMask
> +#endif
> 
> @interface WineOpenGLContext ()
> @property (retain, nonatomic) NSView* latentView;
> @@ -53,7 +57,7 @@ + (NSView*) dummyView
>         dispatch_once(&once, ^{
>             OnMainThread(^{
>                 dummyWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
> -                                                          styleMask:NSBorderlessWindowMask
> +                                                          styleMask:NSWindowStyleMaskBorderless
>                                                             backing:NSBackingStoreBuffered
>                                                               defer:NO];
>             });
> diff --git a/dlls/winemac.drv/cocoa_status_item.m b/dlls/winemac.drv/cocoa_status_item.m
> index 23d78059585..5b36a25038b 100644
> --- a/dlls/winemac.drv/cocoa_status_item.m
> +++ b/dlls/winemac.drv/cocoa_status_item.m
> @@ -23,6 +23,13 @@
> #import "cocoa_app.h"
> #import "cocoa_event.h"
> 
> +#if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
> +/* For older SDKs, #define the new names of constants deprecated/renamed in macOS 10.12. */
> +#define NSCompositingOperationSourceOver    NSCompositeSourceOver
> +#define NSEventMaskLeftMouseDown            NSLeftMouseDownMask
> +#define NSEventMaskOtherMouseDown           NSOtherMouseDownMask
> +#define NSEventMaskRightMouseDown           NSRightMouseDownMask
> +#endif
> 
> @interface WineStatusItem : NSView
> {
> @@ -117,7 +124,9 @@ - (void) postMouseButtonEvent:(NSEvent*)nsevent;
>         event = macdrv_create_event(STATUS_ITEM_MOUSE_BUTTON, nil);
>         event->status_item_mouse_button.item = (macdrv_status_item)self;
>         event->status_item_mouse_button.button = [nsevent buttonNumber];
> -        event->status_item_mouse_button.down = (typeMask & (NSLeftMouseDownMask | NSRightMouseDownMask | NSOtherMouseDownMask)) != 0;
> +        event->status_item_mouse_button.down = (typeMask & (NSEventMaskLeftMouseDown |
> +                                                            NSEventMaskRightMouseDown |
> +                                                            NSEventMaskOtherMouseDown)) != 0;
>         event->status_item_mouse_button.count = [nsevent clickCount];
>         event->status_item_mouse_button.x = floor(point.x);
>         event->status_item_mouse_button.y = floor(point.y);
> @@ -147,7 +156,7 @@ - (void) drawRect:(NSRect)rect
> 
>             [image drawAtPoint:imageOrigin
>                       fromRect:NSZeroRect
> -                     operation:NSCompositeSourceOver
> +                     operation:NSCompositingOperationSourceOver
>                       fraction:1];
>         }
>     }
> diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
> index 9c2ffb1623d..4fc1bd9bbe3 100644
> --- a/dlls/winemac.drv/cocoa_window.m
> +++ b/dlls/winemac.drv/cocoa_window.m
> @@ -35,13 +35,28 @@
> #import "cocoa_event.h"
> #import "cocoa_opengl.h"
> 
> +#if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
> +/* For older SDKs, #define the new names of constants deprecated/renamed in macOS 10.12. */
> +#define NSCompositingOperationSourceOver    NSCompositeSourceOver
> +#define NSEventTypeKeyDown                  NSKeyDown
> +#define NSEventTypeLeftMouseDown            NSLeftMouseDown
> +#define NSEventTypeLeftMouseDragged         NSLeftMouseDragged
> +#define NSEventTypeLeftMouseUp              NSLeftMouseUp
> +#define NSWindowStyleMaskBorderless         NSBorderlessWindowMask
> +#define NSWindowStyleMaskClosable           NSClosableWindowMask
> +#define NSWindowStyleMaskFullScreen         NSFullScreenWindowMask
> +#define NSWindowStyleMaskMiniaturizable     NSMiniaturizableWindowMask
> +#define NSWindowStyleMaskResizable          NSResizableWindowMask
> +#define NSWindowStyleMaskTitled             NSTitledWindowMask
> +#define NSWindowStyleMaskUtilityWindow      NSUtilityWindowMask
> +#endif
> 
> #if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
> enum {
>     NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
>     NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8,
>     NSWindowFullScreenButton = 7,
> -    NSFullScreenWindowMask = 1 << 14,
> +    NSWindowStyleMaskFullScreen = 1 << 14,
> };
> 
> @interface NSWindow (WineFullScreenExtensions)
> @@ -64,13 +79,13 @@ static NSUInteger style_mask_for_features(const struct macdrv_window_features* w
> 
>     if (wf->title_bar)
>     {
> -        style_mask = NSTitledWindowMask;
> -        if (wf->close_button) style_mask |= NSClosableWindowMask;
> -        if (wf->minimize_button) style_mask |= NSMiniaturizableWindowMask;
> -        if (wf->resizable || wf->maximize_button) style_mask |= NSResizableWindowMask;
> -        if (wf->utility) style_mask |= NSUtilityWindowMask;
> +        style_mask = NSWindowStyleMaskTitled;
> +        if (wf->close_button) style_mask |= NSWindowStyleMaskClosable;
> +        if (wf->minimize_button) style_mask |= NSWindowStyleMaskMiniaturizable;
> +        if (wf->resizable || wf->maximize_button) style_mask |= NSWindowStyleMaskResizable;
> +        if (wf->utility) style_mask |= NSWindowStyleMaskUtilityWindow;
>     }
> -    else style_mask = NSBorderlessWindowMask;
> +    else style_mask = NSWindowStyleMaskBorderless;
> 
>     return style_mask;
> }
> @@ -1058,7 +1073,7 @@ - (void) dealloc
>     - (BOOL) preventResizing
>     {
>         BOOL preventForClipping = cursor_clipping_locks_windows && [[WineApplicationController sharedController] clippingCursor];
> -        return ([self styleMask] & NSResizableWindowMask) && (disabled || !resizable || preventForClipping);
> +        return ([self styleMask] & NSWindowStyleMaskResizable) && (disabled || !resizable || preventForClipping);
>     }
> 
>     - (BOOL) allowsMovingWithMaximized:(BOOL)inMaximized
> @@ -1075,11 +1090,11 @@ - (void) adjustFeaturesForState
>     {
>         NSUInteger style = [self styleMask];
> 
> -        if (style & NSClosableWindowMask)
> +        if (style & NSWindowStyleMaskClosable)
>             [[self standardWindowButton:NSWindowCloseButton] setEnabled:!self.disabled];
> -        if (style & NSMiniaturizableWindowMask)
> +        if (style & NSWindowStyleMaskMiniaturizable)
>             [[self standardWindowButton:NSWindowMiniaturizeButton] setEnabled:!self.disabled];
> -        if (style & NSResizableWindowMask)
> +        if (style & NSWindowStyleMaskResizable)
>             [[self standardWindowButton:NSWindowZoomButton] setEnabled:!self.disabled];
>         if ([self respondsToSelector:@selector(toggleFullScreen:)])
>         {
> @@ -1110,7 +1125,7 @@ - (void) adjustFullScreenBehavior:(NSWindowCollectionBehavior)behavior
>             NSUInteger style = [self styleMask];
> 
>             if (behavior & NSWindowCollectionBehaviorParticipatesInCycle &&
> -                style & NSResizableWindowMask && !(style & NSUtilityWindowMask) && !maximized &&
> +                style & NSWindowStyleMaskResizable && !(style & NSWindowStyleMaskUtilityWindow) && !maximized &&
>                 !(self.parentWindow || self.latentParentWindow))
>             {
>                 behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
> @@ -1120,7 +1135,7 @@ - (void) adjustFullScreenBehavior:(NSWindowCollectionBehavior)behavior
>             {
>                 behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
>                 behavior |= NSWindowCollectionBehaviorFullScreenAuxiliary;
> -                if (style & NSFullScreenWindowMask)
> +                if (style & NSWindowStyleMaskFullScreen)
>                     [super toggleFullScreen:nil];
>             }
>         }
> @@ -1134,24 +1149,24 @@ - (void) adjustFullScreenBehavior:(NSWindowCollectionBehavior)behavior
> 
>     - (void) setWindowFeatures:(const struct macdrv_window_features*)wf
>     {
> -        static const NSUInteger usedStyles = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask |
> -                                             NSResizableWindowMask | NSUtilityWindowMask | NSBorderlessWindowMask;
> +        static const NSUInteger usedStyles = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable |
> +                                             NSWindowStyleMaskResizable | NSWindowStyleMaskUtilityWindow | NSWindowStyleMaskBorderless;
>         NSUInteger currentStyle = [self styleMask];
>         NSUInteger newStyle = style_mask_for_features(wf) | (currentStyle & ~usedStyles);
> 
>         if (newStyle != currentStyle)
>         {
>             NSString* title = [[[self title] copy] autorelease];
> -            BOOL showingButtons = (currentStyle & (NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)) != 0;
> -            BOOL shouldShowButtons = (newStyle & (NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)) != 0;
> -            if (shouldShowButtons != showingButtons && !((newStyle ^ currentStyle) & NSClosableWindowMask))
> +            BOOL showingButtons = (currentStyle & (NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable)) != 0;
> +            BOOL shouldShowButtons = (newStyle & (NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable)) != 0;
> +            if (shouldShowButtons != showingButtons && !((newStyle ^ currentStyle) & NSWindowStyleMaskClosable))
>             {
> -                // -setStyleMask: is buggy on 10.7+ with respect to NSResizableWindowMask.
> -                // If transitioning from NSTitledWindowMask | NSResizableWindowMask to
> -                // just NSTitledWindowMask, the window buttons should disappear rather
> +                // -setStyleMask: is buggy on 10.7+ with respect to NSWindowStyleMaskResizable.
> +                // If transitioning from NSWindowStyleMaskTitled | NSWindowStyleMaskResizable to
> +                // just NSWindowStyleMaskTitled, the window buttons should disappear rather
>                 // than just being disabled.  But they don't.  Similarly in reverse.
> -                // The workaround is to also toggle NSClosableWindowMask at the same time.
> -                [self setStyleMask:newStyle ^ NSClosableWindowMask];
> +                // The workaround is to also toggle NSWindowStyleMaskClosable at the same time.
> +                [self setStyleMask:newStyle ^ NSWindowStyleMaskClosable];
>             }
>             [self setStyleMask:newStyle];
> 
> @@ -1283,14 +1298,14 @@ - (void) setMacDrvState:(const struct macdrv_window_state*)state
>             {
>                 if ([self wouldBeVisible])
>                 {
> -                    if ([self styleMask] & NSFullScreenWindowMask)
> +                    if ([self styleMask] & NSWindowStyleMaskFullScreen)
>                     {
>                         [self postDidUnminimizeEvent];
>                         discard &= ~event_mask_for_type(WINDOW_DID_UNMINIMIZE);
>                     }
>                     else
>                     {
> -                        [self setStyleMask:([self styleMask] | NSMiniaturizableWindowMask)];
> +                        [self setStyleMask:([self styleMask] | NSWindowStyleMaskMiniaturizable)];
>                         [super miniaturize:nil];
>                         discard |= event_mask_for_type(WINDOW_BROUGHT_FORWARD) |
>                                    event_mask_for_type(WINDOW_GOT_FOCUS) |
> @@ -1765,7 +1780,7 @@ - (void) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next activate:(BOOL)a
> 
>             if (pendingMinimize)
>             {
> -                [self setStyleMask:([self styleMask] | NSMiniaturizableWindowMask)];
> +                [self setStyleMask:([self styleMask] | NSWindowStyleMaskMiniaturizable)];
>                 [super miniaturize:nil];
>                 pendingMinimize = FALSE;
>             }
> @@ -1814,7 +1829,7 @@ - (void) doOrderOut
>             [parent grabDockIconSnapshotFromWindow:self force:NO];
> 
>         [self becameIneligibleParentOrChild];
> -        if ([self isMiniaturized] || [self styleMask] & NSFullScreenWindowMask)
> +        if ([self isMiniaturized] || [self styleMask] & NSWindowStyleMaskFullScreen)
>         {
>             fakingClose = TRUE;
>             [self close];
> @@ -1844,7 +1859,7 @@ - (void) doOrderOut
>     - (void) updateFullscreen
>     {
>         NSRect contentRect = [self contentRectForFrameRect:self.wine_fractionalFrame];
> -        BOOL nowFullscreen = !([self styleMask] & NSFullScreenWindowMask) && screen_covered_by_rect(contentRect, [NSScreen screens]);
> +        BOOL nowFullscreen = !([self styleMask] & NSWindowStyleMaskFullScreen) && screen_covered_by_rect(contentRect, [NSScreen screens]);
> 
>         if (nowFullscreen != fullscreen)
>         {
> @@ -2077,7 +2092,7 @@ - (void) postKeyEvent:(NSEvent *)theEvent
>     {
>         [self flagsChanged:theEvent];
>         [self postKey:[theEvent keyCode]
> -              pressed:[theEvent type] == NSKeyDown
> +              pressed:[theEvent type] == NSEventTypeKeyDown
>             modifiers:adjusted_modifiers_for_settings([theEvent modifierFlags])
>                 event:theEvent];
>     }
> @@ -2120,9 +2135,9 @@ - (void) postWindowFrameChanged:(NSRect)frame fullscreen:(BOOL)isFullscreen resi
>         NSUInteger style = self.styleMask;
> 
>         if (isFullscreen)
> -            style |= NSFullScreenWindowMask;
> +            style |= NSWindowStyleMaskFullScreen;
>         else
> -            style &= ~NSFullScreenWindowMask;
> +            style &= ~NSWindowStyleMaskFullScreen;
>         frame = [[self class] contentRectForFrameRect:frame styleMask:style];
>         [[WineApplicationController sharedController] flipRect:&frame];
> 
> @@ -2302,7 +2317,7 @@ - (void) grabDockIconSnapshotFromWindow:(WineWindow*)window force:(BOOL)force
>         CGContextDrawImage(cgcontext, rect, windowImage);
>         [appImage drawInRect:NSMakeRect(156, 4, 96, 96)
>                     fromRect:NSZeroRect
> -                   operation:NSCompositeSourceOver
> +                   operation:NSCompositingOperationSourceOver
>                     fraction:1
>               respectFlipped:YES
>                        hints:nil];
> @@ -2431,13 +2446,13 @@ - (void) sendEvent:(NSEvent*)event
>            interface control.  For example, Control-Tab switches focus among
>            views.  We want to bypass that feature, so directly route key-down
>            events to -keyDown:. */
> -        if (type == NSKeyDown)
> +        if (type == NSEventTypeKeyDown)
>             [[self firstResponder] keyDown:event];
>         else
>         {
>             if (!draggingPhase && maximized && ![self isMovable] &&
>                 ![self allowsMovingWithMaximized:YES] && [self allowsMovingWithMaximized:NO] &&
> -                type == NSLeftMouseDown && (self.styleMask & NSTitledWindowMask))
> +                type == NSEventTypeLeftMouseDown && (self.styleMask & NSWindowStyleMaskTitled))
>             {
>                 NSRect titleBar = self.frame;
>                 NSRect contentRect = [self contentRectForFrameRect:titleBar];
> @@ -2480,7 +2495,7 @@ - (void) sendEvent:(NSEvent*)event
>                     }
>                 }
>             }
> -            else if (draggingPhase && (type == NSLeftMouseDragged || type == NSLeftMouseUp))
> +            else if (draggingPhase && (type == NSEventTypeLeftMouseDragged || type == NSEventTypeLeftMouseUp))
>             {
>                 if ([self isMovable])
>                 {
> @@ -2502,7 +2517,7 @@ - (void) sendEvent:(NSEvent*)event
> 
>                     [self setFrameTopLeftPoint:newTopLeft];
>                 }
> -                else if (draggingPhase == 1 && type == NSLeftMouseDragged)
> +                else if (draggingPhase == 1 && type == NSEventTypeLeftMouseDragged)
>                 {
>                     macdrv_event* event;
>                     NSRect frame = [self contentRectForFrameRect:self.frame];
> @@ -2518,7 +2533,7 @@ - (void) sendEvent:(NSEvent*)event
>                     draggingPhase = 2;
>                 }
> 
> -                if (type == NSLeftMouseUp)
> +                if (type == NSEventTypeLeftMouseUp)
>                     [self endWindowDragging];
>             }
> 
> @@ -2919,7 +2934,7 @@ - (void)windowDidResize:(NSNotification *)notification
>         }
> 
>         [self postWindowFrameChanged:frame
> -                          fullscreen:([self styleMask] & NSFullScreenWindowMask) != 0
> +                          fullscreen:([self styleMask] & NSWindowStyleMaskFullScreen) != 0
>                             resizing:[self inLiveResize]];
> 
>         [[[self contentView] inputContext] invalidateCharacterCoordinates];
> -- 
> 2.26.2
> 
> 




More information about the wine-devel mailing list