bsnes-libretro/hiro/cocoa/application.cpp
Tim Allen a512d14628 Update to v094r09 release.
byuu says:

This will easily be the biggest diff in the history of higan. And not in
a good way.

* target-higan and target-loki have been blown away completely
* nall and ruby massively updated
* phoenix replaced with hiro (pretty near a total rewrite)
* target-higan restarted using hiro (just a window for now)
* all emulation cores updated to compile again
* installation changed to not require root privileges (installs locally)

For the foreseeable future (maybe even permanently?), the new higan UI
will only build under Linux/BSD with GTK+ 2.20+. Probably the most
likely route for Windows/OS X will be to try and figure out how to build
hiro/GTK on those platforms, as awful as that would be. The other
alternative would be to produce new UIs for those platforms ... which
would actually be a good opportunity to make something much more user
friendly.

Being that I just started on this a few hours ago, that means that for
at least a few weeks, don't expect to be able to actually play any
games. Right now, you can pretty much just compile the binary and that's
it. It's quite possible that some nall changes didn't produce
compilation errors, but will produce runtime errors. So until the UI can
actually load games, we won't know if anything is broken. But we should
mostly be okay. It was mostly just trim<1> -> trim changes, moving to
Hash::SHA256 (much cleaner), and patching some reckless memory copy
functions enough to compile.

Progress isn't going to be like it was before: I'm now dividing my time
much thinner between studying and other hobbies.

My aim this time is not to produce a binary for everyone to play games
on. Rather, it's to keep the emulator alive. I want to be able to apply
critical patches again. And I would also like the base of the emulator
to live on, for use in other emulator frontends that utilize higan.
2015-02-28 12:52:53 +11:00

92 lines
2.8 KiB
C++

@implementation CocoaDelegate : NSObject
-(NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication*)sender {
using phoenix::Application;
if(Application::Cocoa::onQuit) Application::Cocoa::onQuit();
else Application::quit();
return NSTerminateCancel;
}
-(BOOL) applicationShouldHandleReopen:(NSApplication*)application hasVisibleWindows:(BOOL)flag {
using phoenix::Application;
if(Application::Cocoa::onActivate) Application::Cocoa::onActivate();
return NO;
}
-(void) run:(NSTimer*)timer {
using phoenix::Application;
if(Application::main) Application::main();
}
-(void) updateInDock:(NSTimer*)timer {
NSArray* windows = [NSApp windows];
for(unsigned n = 0; n < [windows count]; n++) {
NSWindow* window = [windows objectAtIndex:n];
if([window isMiniaturized]) {
[window updateInDock];
}
}
}
@end
CocoaDelegate* cocoaDelegate = nullptr;
namespace phoenix {
void pApplication::run() {
//NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval:0.1667 target:cocoaDelegate selector:@selector(updateInDock:) userInfo:nil repeats:YES];
if(Application::main) {
NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval:0.0 target:cocoaDelegate selector:@selector(run:) userInfo:nil repeats:YES];
//below line is needed to run application during window resize; however it has a large performance penalty on the resize smoothness
//[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode];
}
@autoreleasepool {
[NSApp run];
}
}
bool pApplication::pendingEvents() {
bool result = false;
@autoreleasepool {
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:NO];
if(event != nil) result = true;
}
return result;
}
void pApplication::processEvents() {
@autoreleasepool {
while(applicationState.quit == false) {
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if(event == nil) break;
[event retain];
[NSApp sendEvent:event];
[event release];
}
}
}
void pApplication::quit() {
@autoreleasepool {
[NSApp stop:nil];
NSEvent* event = [NSEvent otherEventWithType:NSApplicationDefined location:NSMakePoint(0, 0) modifierFlags:0 timestamp:0.0 windowNumber:0 context:nil subtype:0 data1:0 data2:0];
[NSApp postEvent:event atStart:true];
}
}
void pApplication::initialize() {
@autoreleasepool {
[NSApplication sharedApplication];
cocoaDelegate = [[CocoaDelegate alloc] init];
[NSApp setDelegate:cocoaDelegate];
//every window has the default application menu; call this so it is displayed at startup
[NSApp setMainMenu:[pWindow::none().p.cocoaWindow menu]];
}
}
}