Commit bb2e02ab authored by Brendan Shanks's avatar Brendan Shanks Committed by Alexandre Julliard

winemac.drv: Use ObjC literals.

parent 8943fcbc
...@@ -78,8 +78,7 @@ int macdrv_err_on; ...@@ -78,8 +78,7 @@ int macdrv_err_on;
*/ */
static NSString* WineLocalizedString(unsigned int stringID) static NSString* WineLocalizedString(unsigned int stringID)
{ {
NSNumber* key = [NSNumber numberWithUnsignedInt:stringID]; return ((NSDictionary*)localized_strings)[@(stringID)];
return [(NSDictionary*)localized_strings objectForKey:key];
} }
...@@ -135,11 +134,13 @@ static NSString* WineLocalizedString(unsigned int stringID) ...@@ -135,11 +134,13 @@ static NSString* WineLocalizedString(unsigned int stringID)
{ {
if (self == [WineApplicationController class]) if (self == [WineApplicationController class])
{ {
NSDictionary* defaults = [NSDictionary dictionaryWithObjectsAndKeys: NSDictionary<NSString *, id> *defaults =
@"", @"NSQuotedKeystrokeBinding", @{
@"", @"NSRepeatCountBinding", @"NSQuotedKeystrokeBinding" : @"",
[NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled", @"NSRepeatCountBinding" : @"",
nil]; @"ApplePressAndHoldEnabled" : @NO
};
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
if ([NSWindow respondsToSelector:@selector(setAllowsAutomaticWindowTabbing:)]) if ([NSWindow respondsToSelector:@selector(setAllowsAutomaticWindowTabbing:)])
...@@ -539,7 +540,7 @@ static NSString* WineLocalizedString(unsigned int stringID) ...@@ -539,7 +540,7 @@ static NSString* WineLocalizedString(unsigned int stringID)
CGRect* rect; CGRect* rect;
NSScreen* screen; NSScreen* screen;
primaryScreenHeight = NSHeight([[screens objectAtIndex:0] frame]); primaryScreenHeight = NSHeight([screens[0] frame]);
primaryScreenHeightValid = TRUE; primaryScreenHeightValid = TRUE;
size = count * sizeof(CGRect); size = count * sizeof(CGRect);
...@@ -577,7 +578,7 @@ static NSString* WineLocalizedString(unsigned int stringID) ...@@ -577,7 +578,7 @@ static NSString* WineLocalizedString(unsigned int stringID)
// We don't use -primaryScreenHeight here so there's no chance of having // We don't use -primaryScreenHeight here so there's no chance of having
// out-of-date cached info. This method is called infrequently enough // out-of-date cached info. This method is called infrequently enough
// that getting the screen height each time is not prohibitively expensive. // that getting the screen height each time is not prohibitively expensive.
rect->origin.y = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - NSMaxY(*rect); rect->origin.y = NSMaxY([[NSScreen screens][0] frame]) - NSMaxY(*rect);
} }
- (WineWindow*) frontWineWindow - (WineWindow*) frontWineWindow
...@@ -835,7 +836,7 @@ static NSString* WineLocalizedString(unsigned int stringID) ...@@ -835,7 +836,7 @@ static NSString* WineLocalizedString(unsigned int stringID)
NSNumber* displayIDKey = [NSNumber numberWithUnsignedInt:displayID]; NSNumber* displayIDKey = [NSNumber numberWithUnsignedInt:displayID];
CGDisplayModeRef originalMode; CGDisplayModeRef originalMode;
originalMode = (CGDisplayModeRef)[originalDisplayModes objectForKey:displayIDKey]; originalMode = (CGDisplayModeRef)originalDisplayModes[displayIDKey];
if (originalMode && [self mode:mode matchesMode:originalMode]) if (originalMode && [self mode:mode matchesMode:originalMode])
{ {
...@@ -866,7 +867,7 @@ static NSString* WineLocalizedString(unsigned int stringID) ...@@ -866,7 +867,7 @@ static NSString* WineLocalizedString(unsigned int stringID)
CGDisplayModeRef currentMode; CGDisplayModeRef currentMode;
NSArray* modes; NSArray* modes;
currentMode = CGDisplayModeRetain((CGDisplayModeRef)[latentDisplayModes objectForKey:displayIDKey]); currentMode = CGDisplayModeRetain((CGDisplayModeRef)latentDisplayModes[displayIDKey]);
if (!currentMode) if (!currentMode)
currentMode = CGDisplayCopyDisplayMode(displayID); currentMode = CGDisplayCopyDisplayMode(displayID);
if (!currentMode) // Invalid display ID if (!currentMode) // Invalid display ID
...@@ -1013,11 +1014,11 @@ static NSString* WineLocalizedString(unsigned int stringID) ...@@ -1013,11 +1014,11 @@ static NSString* WineLocalizedString(unsigned int stringID)
- (void) setCursor - (void) setCursor
{ {
NSDictionary* frame = [cursorFrames objectAtIndex:cursorFrame]; NSDictionary* frame = cursorFrames[cursorFrame];
CGImageRef cgimage = (CGImageRef)[frame objectForKey:@"image"]; CGImageRef cgimage = (CGImageRef)frame[@"image"];
CGSize size = CGSizeMake(CGImageGetWidth(cgimage), CGImageGetHeight(cgimage)); CGSize size = CGSizeMake(CGImageGetWidth(cgimage), CGImageGetHeight(cgimage));
NSImage* image = [[NSImage alloc] initWithCGImage:cgimage size:NSSizeFromCGSize(cgsize_mac_from_win(size))]; NSImage* image = [[NSImage alloc] initWithCGImage:cgimage size:NSSizeFromCGSize(cgsize_mac_from_win(size))];
CFDictionaryRef hotSpotDict = (CFDictionaryRef)[frame objectForKey:@"hotSpot"]; CFDictionaryRef hotSpotDict = (CFDictionaryRef)frame[@"hotSpot"];
CGPoint hotSpot; CGPoint hotSpot;
if (!CGPointMakeWithDictionaryRepresentation(hotSpotDict, &hotSpot)) if (!CGPointMakeWithDictionaryRepresentation(hotSpotDict, &hotSpot))
...@@ -1039,8 +1040,8 @@ static NSString* WineLocalizedString(unsigned int stringID) ...@@ -1039,8 +1040,8 @@ static NSString* WineLocalizedString(unsigned int stringID)
cursorFrame = 0; cursorFrame = 0;
[self setCursor]; [self setCursor];
frame = [cursorFrames objectAtIndex:cursorFrame]; frame = cursorFrames[cursorFrame];
duration = [[frame objectForKey:@"duration"] doubleValue]; duration = [frame[@"duration"] doubleValue];
date = [[theTimer fireDate] dateByAddingTimeInterval:duration]; date = [[theTimer fireDate] dateByAddingTimeInterval:duration];
[cursorTimer setFireDate:date]; [cursorTimer setFireDate:date];
} }
...@@ -1059,8 +1060,8 @@ static NSString* WineLocalizedString(unsigned int stringID) ...@@ -1059,8 +1060,8 @@ static NSString* WineLocalizedString(unsigned int stringID)
{ {
if ([frames count] > 1) if ([frames count] > 1)
{ {
NSDictionary* frame = [frames objectAtIndex:0]; NSDictionary* frame = frames[0];
NSTimeInterval duration = [[frame objectForKey:@"duration"] doubleValue]; NSTimeInterval duration = [frame[@"duration"] doubleValue];
NSDate* date = [NSDate dateWithTimeIntervalSinceNow:duration]; NSDate* date = [NSDate dateWithTimeIntervalSinceNow:duration];
self.cursorTimer = [[[NSTimer alloc] initWithFireDate:date self.cursorTimer = [[[NSTimer alloc] initWithFireDate:date
interval:1000000 interval:1000000
...@@ -2140,7 +2141,7 @@ static NSString* WineLocalizedString(unsigned int stringID) ...@@ -2140,7 +2141,7 @@ static NSString* WineLocalizedString(unsigned int stringID)
latentDisplayModes = [[NSMutableDictionary alloc] init]; latentDisplayModes = [[NSMutableDictionary alloc] init];
for (displayID in modesToRealize) for (displayID in modesToRealize)
{ {
CGDisplayModeRef mode = (CGDisplayModeRef)[modesToRealize objectForKey:displayID]; CGDisplayModeRef mode = (CGDisplayModeRef)modesToRealize[displayID];
[self setMode:mode forDisplay:[displayID unsignedIntValue]]; [self setMode:mode forDisplay:[displayID unsignedIntValue]];
} }
...@@ -2295,7 +2296,7 @@ static void PerformRequest(void *info) ...@@ -2295,7 +2296,7 @@ static void PerformRequest(void *info)
dispatch_sync(controller->requestsManipQueue, ^{ dispatch_sync(controller->requestsManipQueue, ^{
if ([controller->requests count]) if ([controller->requests count])
{ {
block = (dispatch_block_t)[[controller->requests objectAtIndex:0] retain]; block = (dispatch_block_t)[controller->requests[0] retain];
[controller->requests removeObjectAtIndex:0]; [controller->requests removeObjectAtIndex:0];
} }
else else
......
...@@ -35,8 +35,7 @@ ...@@ -35,8 +35,7 @@
static int owned_change_count = -1; static int owned_change_count = -1;
static int change_count = -1; static int change_count = -1;
static NSArray* BitmapOutputTypes; static NSDictionary<NSString *, NSNumber *> *BitmapOutputTypeMap;
static NSDictionary* BitmapOutputTypeMap;
static dispatch_once_t BitmapOutputTypesInitOnce; static dispatch_once_t BitmapOutputTypesInitOnce;
static NSString* const OwnershipSentinel = @"org.winehq.wine.winemac.pasteboard-ownership-sentinel"; static NSString* const OwnershipSentinel = @"org.winehq.wine.winemac.pasteboard-ownership-sentinel";
...@@ -94,19 +93,14 @@ CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard) ...@@ -94,19 +93,14 @@ CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard)
__block CFArrayRef ret = NULL; __block CFArrayRef ret = NULL;
dispatch_once(&BitmapOutputTypesInitOnce, ^{ dispatch_once(&BitmapOutputTypesInitOnce, ^{
NSArray* bitmapFileTypes = [NSArray arrayWithObjects: BitmapOutputTypeMap =
[NSNumber numberWithUnsignedInteger:NSBitmapImageFileTypeTIFF], @{
[NSNumber numberWithUnsignedInteger:NSBitmapImageFileTypePNG], @"public.tiff" : @(NSBitmapImageFileTypeTIFF),
[NSNumber numberWithUnsignedInteger:NSBitmapImageFileTypeBMP], @"public.png" : @(NSBitmapImageFileTypePNG),
[NSNumber numberWithUnsignedInteger:NSBitmapImageFileTypeGIF], @"com.microsoft.bmp" : @(NSBitmapImageFileTypeBMP),
[NSNumber numberWithUnsignedInteger:NSBitmapImageFileTypeJPEG], @"com.compuserve.gif" : @(NSBitmapImageFileTypeGIF),
nil]; @"public.jpeg" : @(NSBitmapImageFileTypeJPEG),
};
BitmapOutputTypes = [[NSArray alloc] initWithObjects:@"public.tiff", @"public.png",
@"com.microsoft.bmp", @"com.compuserve.gif", @"public.jpeg", nil];
BitmapOutputTypeMap = [[NSDictionary alloc] initWithObjects:bitmapFileTypes
forKeys:BitmapOutputTypes];
}); });
OnMainThread(^{ OnMainThread(^{
...@@ -125,7 +119,7 @@ CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard) ...@@ -125,7 +119,7 @@ CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard)
if ([types firstObjectCommonWithArray:[NSBitmapImageRep imageTypes]] || if ([types firstObjectCommonWithArray:[NSBitmapImageRep imageTypes]] ||
[types firstObjectCommonWithArray:[NSBitmapImageRep imagePasteboardTypes]]) [types firstObjectCommonWithArray:[NSBitmapImageRep imagePasteboardTypes]])
{ {
NSMutableArray* newTypes = [BitmapOutputTypes mutableCopy]; NSMutableArray<NSString *> *newTypes = [[BitmapOutputTypeMap allKeys] mutableCopy];
[newTypes removeObjectsInArray:types]; [newTypes removeObjectsInArray:types];
types = [types arrayByAddingObjectsFromArray:newTypes]; types = [types arrayByAddingObjectsFromArray:newTypes];
[newTypes release]; [newTypes release];
...@@ -161,11 +155,11 @@ CFDataRef macdrv_copy_pasteboard_data(CFTypeRef pasteboard, CFStringRef type) ...@@ -161,11 +155,11 @@ CFDataRef macdrv_copy_pasteboard_data(CFTypeRef pasteboard, CFStringRef type)
{ {
NSPasteboard* local_pb = pb; NSPasteboard* local_pb = pb;
if (!local_pb) local_pb = [NSPasteboard generalPasteboard]; if (!local_pb) local_pb = [NSPasteboard generalPasteboard];
if ([local_pb availableTypeFromArray:[NSArray arrayWithObject:(NSString*)type]]) if ([local_pb availableTypeFromArray:@[(NSString*)type]])
ret = [[local_pb dataForType:(NSString*)type] copy]; ret = [[local_pb dataForType:(NSString*)type] copy];
else else
{ {
NSNumber* bitmapType = [BitmapOutputTypeMap objectForKey:(NSString*)type]; NSNumber* bitmapType = BitmapOutputTypeMap[(NSString*)type];
if (bitmapType) if (bitmapType)
{ {
NSArray* reps = [NSBitmapImageRep imageRepsWithPasteboard:local_pb]; NSArray* reps = [NSBitmapImageRep imageRepsWithPasteboard:local_pb];
...@@ -199,7 +193,7 @@ void macdrv_clear_pasteboard(macdrv_window w) ...@@ -199,7 +193,7 @@ void macdrv_clear_pasteboard(macdrv_window w)
@try @try
{ {
NSPasteboard* pb = [NSPasteboard generalPasteboard]; NSPasteboard* pb = [NSPasteboard generalPasteboard];
owned_change_count = [pb declareTypes:[NSArray arrayWithObject:OwnershipSentinel] owned_change_count = [pb declareTypes:@[OwnershipSentinel]
owner:window]; owner:window];
[window.queue discardEventsMatchingMask:event_mask_for_type(LOST_PASTEBOARD_OWNERSHIP) [window.queue discardEventsMatchingMask:event_mask_for_type(LOST_PASTEBOARD_OWNERSHIP)
forWindow:window]; forWindow:window];
...@@ -230,7 +224,7 @@ int macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w ...@@ -230,7 +224,7 @@ int macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w
@try @try
{ {
NSPasteboard* pb = [NSPasteboard generalPasteboard]; NSPasteboard* pb = [NSPasteboard generalPasteboard];
NSInteger change_count = [pb addTypes:[NSArray arrayWithObject:(NSString*)type] NSInteger change_count = [pb addTypes:@[(NSString*)type]
owner:window]; owner:window];
if (change_count) if (change_count)
{ {
......
...@@ -230,7 +230,7 @@ static void scale_rect_for_retina_mode(int mode, CGRect *cursorClipRect) ...@@ -230,7 +230,7 @@ static void scale_rect_for_retina_mode(int mode, CGRect *cursorClipRect)
for (i = 0; i < warpsFinished; i++) for (i = 0; i < warpsFinished; i++)
{ {
WarpRecord* warpRecord = [warpRecords objectAtIndex:0]; WarpRecord* warpRecord = warpRecords[0];
deltaX -= warpRecord.to.x - warpRecord.from.x; deltaX -= warpRecord.to.x - warpRecord.from.x;
deltaY -= warpRecord.to.y - warpRecord.from.y; deltaY -= warpRecord.to.y - warpRecord.from.y;
[warpRecords removeObjectAtIndex:0]; [warpRecords removeObjectAtIndex:0];
......
...@@ -73,14 +73,14 @@ int macdrv_get_displays(struct macdrv_display** displays, int* count) ...@@ -73,14 +73,14 @@ int macdrv_get_displays(struct macdrv_display** displays, int* count)
NSUInteger i; NSUInteger i;
for (i = 0; i < num_screens; i++) for (i = 0; i < num_screens; i++)
{ {
NSScreen* screen = [screens objectAtIndex:i]; NSScreen* screen = screens[i];
NSRect frame = [screen frame]; NSRect frame = [screen frame];
NSRect visible_frame = [screen visibleFrame]; NSRect visible_frame = [screen visibleFrame];
if (i == 0) if (i == 0)
primary_frame = frame; primary_frame = frame;
disps[i].displayID = [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; disps[i].displayID = [[screen deviceDescription][@"NSScreenNumber"] unsignedIntValue];
convert_display_rect(&disps[i].frame, frame, primary_frame); convert_display_rect(&disps[i].frame, frame, primary_frame);
convert_display_rect(&disps[i].work_frame, visible_frame, convert_display_rect(&disps[i].work_frame, visible_frame,
primary_frame); primary_frame);
......
...@@ -162,8 +162,8 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -162,8 +162,8 @@ static const OSType WineHotKeySignature = 'Wine';
for (hotKeyMacID in hotKeysByMacID) for (hotKeyMacID in hotKeysByMacID)
{ {
NSDictionary* hotKeyDict = [hotKeysByMacID objectForKey:hotKeyMacID]; NSDictionary<NSString *, id> *hotKeyDict = hotKeysByMacID[hotKeyMacID];
EventHotKeyRef hotKeyRef = [[hotKeyDict objectForKey:WineHotKeyCarbonRefKey] pointerValue]; EventHotKeyRef hotKeyRef = [hotKeyDict[WineHotKeyCarbonRefKey] pointerValue];
UnregisterEventHotKey(hotKeyRef); UnregisterEventHotKey(hotKeyRef);
} }
[hotKeysByMacID release]; [hotKeysByMacID release];
...@@ -269,7 +269,7 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -269,7 +269,7 @@ static const OSType WineHotKeySignature = 'Wine';
index = 0; index = 0;
while (index < [events count]) while (index < [events count])
{ {
MacDrvEvent* event = [events objectAtIndex:index]; MacDrvEvent* event = events[index];
if (event_mask_for_type(event->event->type) & mask) if (event_mask_for_type(event->event->type) & mask)
{ {
[[event retain] autorelease]; [[event retain] autorelease];
...@@ -369,15 +369,15 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -369,15 +369,15 @@ static const OSType WineHotKeySignature = 'Wine';
- (BOOL) postHotKeyEvent:(UInt32)hotKeyNumber time:(double)time - (BOOL) postHotKeyEvent:(UInt32)hotKeyNumber time:(double)time
{ {
NSDictionary* hotKeyDict = [hotKeysByMacID objectForKey:[NSNumber numberWithUnsignedInt:hotKeyNumber]]; NSDictionary<NSString *, id> *hotKeyDict = hotKeysByMacID[@(hotKeyNumber)];
if (hotKeyDict) if (hotKeyDict)
{ {
macdrv_event* event; macdrv_event* event;
event = macdrv_create_event(HOTKEY_PRESS, nil); event = macdrv_create_event(HOTKEY_PRESS, nil);
event->hotkey_press.vkey = [[hotKeyDict objectForKey:WineHotKeyVkeyKey] unsignedIntValue]; event->hotkey_press.vkey = [hotKeyDict[WineHotKeyVkeyKey] unsignedIntValue];
event->hotkey_press.mod_flags = [[hotKeyDict objectForKey:WineHotKeyModFlagsKey] unsignedIntValue]; event->hotkey_press.mod_flags = [hotKeyDict[WineHotKeyModFlagsKey] unsignedIntValue];
event->hotkey_press.keycode = [[hotKeyDict objectForKey:WineHotKeyKeyCodeKey] unsignedIntValue]; event->hotkey_press.keycode = [hotKeyDict[WineHotKeyKeyCodeKey] unsignedIntValue];
event->hotkey_press.time_ms = [[WineApplicationController sharedController] ticksForEventTime:time]; event->hotkey_press.time_ms = [[WineApplicationController sharedController] ticksForEventTime:time];
[self postEvent:event]; [self postEvent:event];
...@@ -408,14 +408,12 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -408,14 +408,12 @@ static const OSType WineHotKeySignature = 'Wine';
- (void) unregisterHotKey:(unsigned int)vkey modFlags:(unsigned int)modFlags - (void) unregisterHotKey:(unsigned int)vkey modFlags:(unsigned int)modFlags
{ {
NSNumber* vkeyNumber = [NSNumber numberWithUnsignedInt:vkey]; NSArray<NSNumber *> *winIDPair = @[@(vkey), @(modFlags)];
NSNumber* modFlagsNumber = [NSNumber numberWithUnsignedInt:modFlags]; NSDictionary<NSString *, id> *hotKeyDict = hotKeysByWinID[winIDPair];
NSArray* winIDPair = [NSArray arrayWithObjects:vkeyNumber, modFlagsNumber, nil];
NSDictionary* hotKeyDict = [hotKeysByWinID objectForKey:winIDPair];
if (hotKeyDict) if (hotKeyDict)
{ {
EventHotKeyRef hotKeyRef = [[hotKeyDict objectForKey:WineHotKeyCarbonRefKey] pointerValue]; EventHotKeyRef hotKeyRef = [hotKeyDict[WineHotKeyCarbonRefKey] pointerValue];
NSNumber* macID = [hotKeyDict objectForKey:WineHotKeyMacIDKey]; NSNumber* macID = hotKeyDict[WineHotKeyMacIDKey];
UnregisterEventHotKey(hotKeyRef); UnregisterEventHotKey(hotKeyRef);
[hotKeysByMacID removeObjectForKey:macID]; [hotKeysByMacID removeObjectForKey:macID];
...@@ -428,13 +426,10 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -428,13 +426,10 @@ static const OSType WineHotKeySignature = 'Wine';
static EventHandlerRef handler; static EventHandlerRef handler;
static UInt32 hotKeyNumber; static UInt32 hotKeyNumber;
OSStatus status; OSStatus status;
NSNumber* vkeyNumber; NSArray<NSNumber *> *winIDPair;
NSNumber* modFlagsNumber;
NSArray* winIDPair;
EventHotKeyID hotKeyID; EventHotKeyID hotKeyID;
EventHotKeyRef hotKeyRef; EventHotKeyRef hotKeyRef;
NSNumber* macIDNumber; NSDictionary<NSString *, id> *hotKeyDict;
NSDictionary* hotKeyDict;
if (!handler) if (!handler)
{ {
...@@ -453,10 +448,8 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -453,10 +448,8 @@ static const OSType WineHotKeySignature = 'Wine';
if (!hotKeysByWinID && !(hotKeysByWinID = [[NSMutableDictionary alloc] init])) if (!hotKeysByWinID && !(hotKeysByWinID = [[NSMutableDictionary alloc] init]))
return MACDRV_HOTKEY_FAILURE; return MACDRV_HOTKEY_FAILURE;
vkeyNumber = [NSNumber numberWithUnsignedInt:vkey]; winIDPair = @[@(vkey), @(modFlags)];
modFlagsNumber = [NSNumber numberWithUnsignedInt:modFlags]; if (hotKeysByWinID[winIDPair])
winIDPair = [NSArray arrayWithObjects:vkeyNumber, modFlagsNumber, nil];
if ([hotKeysByWinID objectForKey:winIDPair])
return MACDRV_HOTKEY_ALREADY_REGISTERED; return MACDRV_HOTKEY_ALREADY_REGISTERED;
hotKeyID.signature = WineHotKeySignature; hotKeyID.signature = WineHotKeySignature;
...@@ -472,16 +465,16 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -472,16 +465,16 @@ static const OSType WineHotKeySignature = 'Wine';
return MACDRV_HOTKEY_FAILURE; return MACDRV_HOTKEY_FAILURE;
} }
macIDNumber = [NSNumber numberWithUnsignedInt:hotKeyID.id]; hotKeyDict =
hotKeyDict = [NSDictionary dictionaryWithObjectsAndKeys: @{
macIDNumber, WineHotKeyMacIDKey, WineHotKeyMacIDKey : @(hotKeyID.id),
vkeyNumber, WineHotKeyVkeyKey, WineHotKeyVkeyKey : @(vkey),
modFlagsNumber, WineHotKeyModFlagsKey, WineHotKeyModFlagsKey : @(modFlags),
[NSNumber numberWithUnsignedInt:keyCode], WineHotKeyKeyCodeKey, WineHotKeyKeyCodeKey : @(keyCode),
[NSValue valueWithPointer:hotKeyRef], WineHotKeyCarbonRefKey, WineHotKeyCarbonRefKey : [NSValue valueWithPointer:hotKeyRef]
nil]; };
[hotKeysByMacID setObject:hotKeyDict forKey:macIDNumber]; hotKeysByMacID[@(hotKeyID.id)] = hotKeyDict;
[hotKeysByWinID setObject:hotKeyDict forKey:winIDPair]; hotKeysByWinID[winIDPair] = hotKeyDict;
return MACDRV_HOTKEY_SUCCESS; return MACDRV_HOTKEY_SUCCESS;
} }
...@@ -497,7 +490,7 @@ void OnMainThread(dispatch_block_t block) ...@@ -497,7 +490,7 @@ void OnMainThread(dispatch_block_t block)
@autoreleasepool @autoreleasepool
{ {
NSMutableDictionary* threadDict = [[NSThread currentThread] threadDictionary]; NSMutableDictionary* threadDict = [[NSThread currentThread] threadDictionary];
WineEventQueue* queue = [threadDict objectForKey:WineEventQueueThreadDictionaryKey]; WineEventQueue* queue = threadDict[WineEventQueueThreadDictionaryKey];
dispatch_semaphore_t semaphore = NULL; dispatch_semaphore_t semaphore = NULL;
__block BOOL finished; __block BOOL finished;
...@@ -561,7 +554,7 @@ macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler) ...@@ -561,7 +554,7 @@ macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler)
{ {
NSMutableDictionary* threadDict = [[NSThread currentThread] threadDictionary]; NSMutableDictionary* threadDict = [[NSThread currentThread] threadDictionary];
WineEventQueue* queue = [threadDict objectForKey:WineEventQueueThreadDictionaryKey]; WineEventQueue* queue = threadDict[WineEventQueueThreadDictionaryKey];
if (!queue) if (!queue)
{ {
queue = [[[WineEventQueue alloc] initWithEventHandler:handler] autorelease]; queue = [[[WineEventQueue alloc] initWithEventHandler:handler] autorelease];
......
...@@ -1032,9 +1032,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -1032,9 +1032,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
window->resizable = wf->resizable; window->resizable = wf->resizable;
window->_lastDisplayTime = [[NSDate distantPast] timeIntervalSinceReferenceDate]; window->_lastDisplayTime = [[NSDate distantPast] timeIntervalSinceReferenceDate];
[window registerForDraggedTypes:[NSArray arrayWithObjects:(NSString*)kUTTypeData, [window registerForDraggedTypes:@[(NSString*)kUTTypeData, (NSString*)kUTTypeContent]];
(NSString*)kUTTypeContent,
nil]];
contentView = [[[WineContentView alloc] initWithFrame:NSZeroRect] autorelease]; contentView = [[[WineContentView alloc] initWithFrame:NSZeroRect] autorelease];
if (!contentView) if (!contentView)
...@@ -1437,7 +1435,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -1437,7 +1435,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
limit = MIN(origChildren.count, count); limit = MIN(origChildren.count, count);
for (start = 0; start < limit; start++) for (start = 0; start < limit; start++)
{ {
if ([origChildren objectAtIndex:start] != [childWindows objectAtIndex:start]) if (origChildren[start] != childWindows[start])
break; break;
} }
...@@ -1445,12 +1443,12 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -1445,12 +1443,12 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
// are in the desired order. // are in the desired order.
for (i = start; i < count; i++) for (i = start; i < count; i++)
{ {
WineWindow* child = [childWindows objectAtIndex:i]; WineWindow* child = childWindows[i];
[self removeChildWindow:child]; [self removeChildWindow:child];
} }
for (i = start; i < count; i++) for (i = start; i < count; i++)
{ {
WineWindow* child = [childWindows objectAtIndex:i]; WineWindow* child = childWindows[i];
[self addChildWindow:child ordered:NSWindowAbove]; [self addChildWindow:child ordered:NSWindowAbove];
} }
} }
...@@ -1507,7 +1505,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -1507,7 +1505,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
WineWindow* child = [latentChildWindows objectAtIndex:i]; WineWindow* child = latentChildWindows[i];
if ([child isVisible] && (self.floating || !child.floating)) if ([child isVisible] && (self.floating || !child.floating))
{ {
if (child.latentParentWindow == self) if (child.latentParentWindow == self)
...@@ -1612,7 +1610,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -1612,7 +1610,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
for (i = lowIndex + 1; i < highIndex; i++) for (i = lowIndex + 1; i < highIndex; i++)
{ {
NSInteger interveningWindowNumber = [[windowNumbers objectAtIndex:i] integerValue]; NSInteger interveningWindowNumber = [windowNumbers[i] integerValue];
NSWindow* interveningWindow = [NSApp windowWithWindowNumber:interveningWindowNumber]; NSWindow* interveningWindow = [NSApp windowWithWindowNumber:interveningWindowNumber];
if ([interveningWindow isKindOfClass:[WineWindow class]]) if ([interveningWindow isKindOfClass:[WineWindow class]])
return FALSE; return FALSE;
...@@ -1693,7 +1691,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -1693,7 +1691,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
if (index == 0) if (index == 0)
*ancestorOfOther = nil; *ancestorOfOther = nil;
else else
*ancestorOfOther = [otherAncestors objectAtIndex:index - 1]; *ancestorOfOther = otherAncestors[index - 1];
return; return;
} }
} }
...@@ -2234,8 +2232,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -2234,8 +2232,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
if (!_lastDisplayID) if (!_lastDisplayID)
return nil; return nil;
NSMutableDictionary* displayIDToDisplayLinkMap = [self displayIDToDisplayLinkMap]; return [self displayIDToDisplayLinkMap][@(_lastDisplayID)];
return [displayIDToDisplayLinkMap objectForKey:[NSNumber numberWithUnsignedInt:_lastDisplayID]];
} }
- (void) checkWineDisplayLink - (void) checkWineDisplayLink
...@@ -2248,7 +2245,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -2248,7 +2245,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
screen = nil; screen = nil;
#endif #endif
NSNumber* displayIDNumber = [screen.deviceDescription objectForKey:@"NSScreenNumber"]; NSNumber* displayIDNumber = screen.deviceDescription[@"NSScreenNumber"];
CGDirectDisplayID displayID = [displayIDNumber unsignedIntValue]; CGDirectDisplayID displayID = [displayIDNumber unsignedIntValue];
if (displayID == _lastDisplayID) if (displayID == _lastDisplayID)
return; return;
...@@ -2257,12 +2254,12 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -2257,12 +2254,12 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
if (_lastDisplayID) if (_lastDisplayID)
{ {
WineDisplayLink* link = [displayIDToDisplayLinkMap objectForKey:[NSNumber numberWithUnsignedInt:_lastDisplayID]]; WineDisplayLink* link = displayIDToDisplayLinkMap[@(_lastDisplayID)];
[link removeWindow:self]; [link removeWindow:self];
} }
if (displayID) if (displayID)
{ {
WineDisplayLink* link = [displayIDToDisplayLinkMap objectForKey:displayIDNumber]; WineDisplayLink* link = displayIDToDisplayLinkMap[displayIDNumber];
if (!link) if (!link)
{ {
link = [[[WineDisplayLink alloc] initWithDisplayID:displayID] autorelease]; link = [[[WineDisplayLink alloc] initWithDisplayID:displayID] autorelease];
...@@ -3740,9 +3737,9 @@ void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, ma ...@@ -3740,9 +3737,9 @@ void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, ma
NSUInteger index = [subviews indexOfObjectIdenticalTo:view]; NSUInteger index = [subviews indexOfObjectIdenticalTo:view];
if (!prev && !next && index == [subviews count] - 1) if (!prev && !next && index == [subviews count] - 1)
return; return;
if (prev && index + 1 < [subviews count] && [subviews objectAtIndex:index + 1] == prev) if (prev && index + 1 < [subviews count] && subviews[index + 1] == prev)
return; return;
if (!prev && next && index > 0 && [subviews objectAtIndex:index - 1] == next) if (!prev && next && index > 0 && subviews[index - 1] == next)
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment