From f65ecf24f14dbf5c2f3db9481537dc85eff13e4e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 27 Dec 2020 16:48:36 +0100 Subject: [PATCH] Go back to ObjC file --- griffin/griffin_objc.m | 1 + ...a_application.c => ui_cocoa_application.m} | 119 ++++++++---------- 2 files changed, 56 insertions(+), 64 deletions(-) rename ui/drivers/cocoa/{ui_cocoa_application.c => ui_cocoa_application.m} (55%) mode change 100644 => 100755 diff --git a/griffin/griffin_objc.m b/griffin/griffin_objc.m index aa7cd65111..dad5e96e12 100644 --- a/griffin/griffin_objc.m +++ b/griffin/griffin_objc.m @@ -39,6 +39,7 @@ #if TARGET_OS_OSX #include "../ui/drivers/cocoa/ui_cocoa_window.m" #include "../ui/drivers/cocoa/ui_cocoa_browser_window.m" +#include "../ui/drivers/cocoa/ui_cocoa_application.m" #include "../ui/drivers/cocoa/ui_cocoa_msg_window.m" #include "../ui/drivers/ui_cocoa.m" #endif diff --git a/ui/drivers/cocoa/ui_cocoa_application.c b/ui/drivers/cocoa/ui_cocoa_application.m old mode 100644 new mode 100755 similarity index 55% rename from ui/drivers/cocoa/ui_cocoa_application.c rename to ui/drivers/cocoa/ui_cocoa_application.m index 1d7c8abb7b..a782459495 --- a/ui/drivers/cocoa/ui_cocoa_application.c +++ b/ui/drivers/cocoa/ui_cocoa_application.m @@ -1,64 +1,55 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2017 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "cocoa_defines.h" -#include "../../ui_companion_driver.h" - -extern id NSApp; -extern id const NSDefaultRunLoopMode; - -static void* ui_application_cocoa_initialize(void) -{ - return NULL; -} - -static void ui_application_cocoa_process_events(void) -{ - SEL sel_nextEventMatchingMask_untilDate_inMode_dequeue = - sel_registerName("nextEventMatchingMask:untilDate:inMode:dequeue:"); - Class class_NSDate = objc_getClass("NSDate"); - SEL sel_distantPast = sel_registerName("distantPast"); - SEL sel_sendEvent = sel_registerName("sendEvent:"); - id distant_past = ((id (*)(Class, SEL))objc_msgSend)(class_NSDate, sel_distantPast); - for (;;) - { - id event = ((id (*)(id, SEL, NSUInteger, id, id, BOOL))objc_msgSend)(NSApp, sel_nextEventMatchingMask_untilDate_inMode_dequeue, - NSUIntegerMax, - distant_past, - NSDefaultRunLoopMode, - YES); - if (event == nil) - break; - ((id (*)(id, SEL, id))objc_msgSend)(NSApp, sel_sendEvent, event); - } -} - -ui_application_t ui_application_cocoa = { - ui_application_cocoa_initialize, - ui_application_cocoa_process_events, - NULL, - false, - "cocoa" -}; +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2017 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include +#include +#include +#include + +#include +#include "cocoa_defines.h" +#include "cocoa_common.h" +#include "../../ui_companion_driver.h" + +static void* ui_application_cocoa_initialize(void) +{ + return NULL; +} + +static void ui_application_cocoa_process_events(void) +{ + for (;;) + { + NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES]; + if (!event) + break; +#ifndef HAVE_COCOA_METAL + [event retain]; +#endif + [NSApp sendEvent: event]; +#ifndef HAVE_COCOA_METAL + [event retain]; +#endif + } +} + +ui_application_t ui_application_cocoa = { + ui_application_cocoa_initialize, + ui_application_cocoa_process_events, + NULL, + false, + "cocoa" +};