- fixed deprecation warnings in Cocoa backend

This commit is contained in:
alexey.lysiuk 2021-10-18 11:03:34 +03:00
parent 7741a934b8
commit 8ec6c21195
5 changed files with 55 additions and 55 deletions

View file

@ -284,11 +284,11 @@ uint8_t ModifierToDIK(const uint32_t modifier)
{
switch (modifier)
{
case NSAlphaShiftKeyMask: return DIK_CAPITAL;
case NSShiftKeyMask: return DIK_LSHIFT;
case NSControlKeyMask: return DIK_LCONTROL;
case NSAlternateKeyMask: return DIK_LMENU;
case NSCommandKeyMask: return DIK_LWIN;
case NSEventModifierFlagCapsLock: return DIK_CAPITAL;
case NSEventModifierFlagShift: return DIK_LSHIFT;
case NSEventModifierFlagControl: return DIK_LCONTROL;
case NSEventModifierFlagOption: return DIK_LMENU;
case NSEventModifierFlagCommand: return DIK_LWIN;
}
return 0;
@ -296,20 +296,20 @@ uint8_t ModifierToDIK(const uint32_t modifier)
int16_t ModifierFlagsToGUIKeyModifiers(NSEvent* theEvent)
{
const NSUInteger modifiers([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask);
return ((modifiers & NSShiftKeyMask ) ? GKM_SHIFT : 0)
| ((modifiers & NSControlKeyMask ) ? GKM_CTRL : 0)
| ((modifiers & NSAlternateKeyMask) ? GKM_ALT : 0)
| ((modifiers & NSCommandKeyMask ) ? GKM_META : 0);
const NSUInteger modifiers([theEvent modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask);
return ((modifiers & NSEventModifierFlagShift ) ? GKM_SHIFT : 0)
| ((modifiers & NSEventModifierFlagControl) ? GKM_CTRL : 0)
| ((modifiers & NSEventModifierFlagOption ) ? GKM_ALT : 0)
| ((modifiers & NSEventModifierFlagCommand) ? GKM_META : 0);
}
bool ShouldGenerateGUICharEvent(NSEvent* theEvent)
{
const NSUInteger modifiers([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask);
return !(modifiers & NSControlKeyMask)
&& !(modifiers & NSAlternateKeyMask)
&& !(modifiers & NSCommandKeyMask)
&& !(modifiers & NSFunctionKeyMask);
const NSUInteger modifiers([theEvent modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask);
return !(modifiers & NSEventModifierFlagControl)
&& !(modifiers & NSEventModifierFlagOption)
&& !(modifiers & NSEventModifierFlagCommand)
&& !(modifiers & NSEventModifierFlagFunction);
}
@ -373,7 +373,7 @@ void ProcessKeyboardEventInMenu(NSEvent* theEvent)
unichar realchar;
event.type = EV_GUI_Event;
event.subtype = NSKeyDown == [theEvent type] ? EV_GUI_KeyDown : EV_GUI_KeyUp;
event.subtype = NSEventTypeKeyDown == [theEvent type] ? EV_GUI_KeyDown : EV_GUI_KeyUp;
event.data2 = GetCharacterFromNSEvent(theEvent, &realchar);
event.data3 = ModifierFlagsToGUIKeyModifiers(theEvent);
@ -505,8 +505,8 @@ void ProcessKeyboardEvent(NSEvent* theEvent)
if (k_allowfullscreentoggle
&& (kVK_ANSI_F == keyCode)
&& (NSCommandKeyMask & [theEvent modifierFlags])
&& (NSKeyDown == [theEvent type])
&& (NSEventModifierFlagCommand & [theEvent modifierFlags])
&& (NSEventTypeKeyDown == [theEvent type])
&& !isARepeat)
{
ToggleFullscreen = !ToggleFullscreen;
@ -521,7 +521,7 @@ void ProcessKeyboardEvent(NSEvent* theEvent)
{
event_t event = {};
event.type = NSKeyDown == [theEvent type] ? EV_KeyDown : EV_KeyUp;
event.type = NSEventTypeKeyDown == [theEvent type] ? EV_KeyDown : EV_KeyUp;
event.data1 = KEYCODE_TO_DIK[ keyCode ];
if (0 != event.data1)
@ -542,7 +542,7 @@ void ProcessKeyboardFlagsEvent(NSEvent* theEvent)
}
static const uint32_t FLAGS_MASK =
NSDeviceIndependentModifierFlagsMask & ~NSNumericPadKeyMask;
NSEventModifierFlagDeviceIndependentFlagsMask & ~NSEventModifierFlagNumericPad;
const uint32_t modifiers = [theEvent modifierFlags] & FLAGS_MASK;
static uint32_t oldModifiers = 0;
@ -611,12 +611,12 @@ void ProcessMouseButtonEvent(NSEvent* theEvent)
switch (cocoaEventType)
{
case NSLeftMouseDown: event.subtype = EV_GUI_LButtonDown; break;
case NSRightMouseDown: event.subtype = EV_GUI_RButtonDown; break;
case NSOtherMouseDown: event.subtype = EV_GUI_MButtonDown; break;
case NSLeftMouseUp: event.subtype = EV_GUI_LButtonUp; break;
case NSRightMouseUp: event.subtype = EV_GUI_RButtonUp; break;
case NSOtherMouseUp: event.subtype = EV_GUI_MButtonUp; break;
case NSEventTypeLeftMouseDown: event.subtype = EV_GUI_LButtonDown; break;
case NSEventTypeRightMouseDown: event.subtype = EV_GUI_RButtonDown; break;
case NSEventTypeOtherMouseDown: event.subtype = EV_GUI_MButtonDown; break;
case NSEventTypeLeftMouseUp: event.subtype = EV_GUI_LButtonUp; break;
case NSEventTypeRightMouseUp: event.subtype = EV_GUI_RButtonUp; break;
case NSEventTypeOtherMouseUp: event.subtype = EV_GUI_MButtonUp; break;
default: break;
}
@ -628,15 +628,15 @@ void ProcessMouseButtonEvent(NSEvent* theEvent)
{
switch (cocoaEventType)
{
case NSLeftMouseDown:
case NSRightMouseDown:
case NSOtherMouseDown:
case NSEventTypeLeftMouseDown:
case NSEventTypeRightMouseDown:
case NSEventTypeOtherMouseDown:
event.type = EV_KeyDown;
break;
case NSLeftMouseUp:
case NSRightMouseUp:
case NSOtherMouseUp:
case NSEventTypeLeftMouseUp:
case NSEventTypeRightMouseUp:
case NSEventTypeOtherMouseUp:
event.type = EV_KeyUp;
break;
@ -694,36 +694,36 @@ void I_ProcessEvent(NSEvent* event)
switch (eventType)
{
case NSMouseMoved:
case NSEventTypeMouseMoved:
ProcessMouseMoveEvent(event);
break;
case NSLeftMouseDown:
case NSLeftMouseUp:
case NSRightMouseDown:
case NSRightMouseUp:
case NSOtherMouseDown:
case NSOtherMouseUp:
case NSEventTypeLeftMouseDown:
case NSEventTypeLeftMouseUp:
case NSEventTypeRightMouseDown:
case NSEventTypeRightMouseUp:
case NSEventTypeOtherMouseDown:
case NSEventTypeOtherMouseUp:
ProcessMouseButtonEvent(event);
break;
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSOtherMouseDragged:
case NSEventTypeLeftMouseDragged:
case NSEventTypeRightMouseDragged:
case NSEventTypeOtherMouseDragged:
ProcessMouseButtonEvent(event);
ProcessMouseMoveEvent(event);
break;
case NSScrollWheel:
case NSEventTypeScrollWheel:
ProcessMouseWheelEvent(event);
break;
case NSKeyDown:
case NSKeyUp:
case NSEventTypeKeyDown:
case NSEventTypeKeyUp:
ProcessKeyboardEvent(event);
break;
case NSFlagsChanged:
case NSEventTypeFlagsChanged:
ProcessKeyboardFlagsEvent(event);
break;

View file

@ -396,7 +396,7 @@ extern bool AppActive;
while (true)
{
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
untilDate:[NSDate dateWithTimeIntervalSinceNow:0]
inMode:NSDefaultRunLoopMode
dequeue:YES];
@ -449,7 +449,7 @@ NSMenuItem* CreateApplicationMenu()
[[menu addItemWithTitle:@"Hide Others"
action:@selector(hideOtherApplications:)
keyEquivalent:@"h"]
setKeyEquivalentModifierMask:NSAlternateKeyMask | NSCommandKeyMask];
setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
[menu addItemWithTitle:@"Show All"
action:@selector(unhideAllApplications:)
keyEquivalent:@""];

View file

@ -121,8 +121,8 @@ namespace
const NSInteger LEVEL_FULLSCREEN = NSMainMenuWindowLevel + 1;
const NSInteger LEVEL_WINDOWED = NSNormalWindowLevel;
const NSUInteger STYLE_MASK_FULLSCREEN = NSBorderlessWindowMask;
const NSUInteger STYLE_MASK_WINDOWED = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask;
const NSUInteger STYLE_MASK_FULLSCREEN = NSWindowStyleMaskBorderless;
const NSUInteger STYLE_MASK_WINDOWED = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
}

View file

@ -104,7 +104,7 @@ FConsoleWindow::FConsoleWindow()
NSString* const title = [NSString stringWithFormat:@"%s %s - Console", GAMENAME, GetVersionString()];
[m_window initWithContentRect:initialRect
styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable
backing:NSBackingStoreBuffered
defer:NO];
[m_window setMinSize:[m_window frame].size];
@ -348,7 +348,7 @@ void FConsoleWindow::SetTitleText()
NSTextField* titleText = [[NSTextField alloc] initWithFrame:titleTextRect];
[titleText setStringValue:[NSString stringWithCString:GameStartupInfo.Name.GetChars()
encoding:NSISOLatin1StringEncoding]];
[titleText setAlignment:NSCenterTextAlignment];
[titleText setAlignment:NSTextAlignmentCenter];
[titleText setTextColor:RGB(GameStartupInfo.FgColor)];
[titleText setBackgroundColor:RGB(GameStartupInfo.BkColor)];
[titleText setFont:[NSFont fontWithName:@"Trebuchet MS Bold" size:18.0f]];
@ -434,7 +434,7 @@ void FConsoleWindow::NetInit(const char* const message, const int playerCount)
// Text with connected/total players count
m_netCountText = [[NSTextField alloc] initWithFrame:NSMakeRect(428.0f, 64.0f, 72.0f, 16.0f)];
[m_netCountText setAutoresizingMask:NSViewMinXMargin];
[m_netCountText setAlignment:NSRightTextAlignment];
[m_netCountText setAlignment:NSTextAlignmentRight];
[m_netCountText setDrawsBackground:NO];
[m_netCountText setSelectable:NO];
[m_netCountText setBordered:NO];

View file

@ -194,7 +194,7 @@ static NSArray* GetKnownExtensions()
[openPanel setResolvesAliases:YES];
[openPanel setAllowedFileTypes:GetKnownExtensions()];
if (NSOKButton == [openPanel runModal])
if (NSModalResponseOK == [openPanel runModal])
{
NSArray* files = [openPanel URLs];
NSMutableString* parameters = [NSMutableString string];
@ -259,7 +259,7 @@ static NSArray* GetKnownExtensions()
id windowTitle = [NSString stringWithFormat:@"%s %s", GAMENAME, GetVersionString()];
NSRect frame = NSMakeRect(0, 0, 440, 450);
window = [[NSWindow alloc] initWithContentRect:frame styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO];
window = [[NSWindow alloc] initWithContentRect:frame styleMask:NSWindowStyleMaskTitled backing:NSBackingStoreBuffered defer:NO];
[window setTitle:windowTitle];
NSTextField *description = [[NSTextField alloc] initWithFrame:NSMakeRect(18, 384, 402, 50)];