Don't bother with a separate NSApplication thread.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6853 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
e429d75489
commit
85db30554e
|
@ -5,7 +5,6 @@ add_subdirectory(Core)
|
|||
if(wxWidgets_FOUND)
|
||||
add_subdirectory(DebuggerUICommon)
|
||||
add_subdirectory(DebuggerWX)
|
||||
add_subdirectory(InputUICommon)
|
||||
add_subdirectory(VideoUICommon)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include <queue>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "IniFile.h"
|
||||
|
@ -371,7 +372,6 @@ unsigned int Initialize()
|
|||
|
||||
// Initialized
|
||||
g_real_wiimotes_initialized = true;
|
||||
atexit(WiimoteReal::Shutdown);
|
||||
|
||||
g_wiimotes_found = FindWiimotes(g_wiimotes, wanted_wiimotes);
|
||||
|
||||
|
@ -379,6 +379,7 @@ unsigned int Initialize()
|
|||
g_wiimotes_found, wanted_wiimotes);
|
||||
|
||||
#ifndef _WIN32
|
||||
atexit(WiimoteReal::Shutdown);
|
||||
g_wiimotes_found = ConnectWiimotes(g_wiimotes);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -43,18 +43,17 @@ if(wxWidgets_FOUND)
|
|||
Src/UDPConfigDiag.cpp
|
||||
Src/WiimoteConfigDiag.cpp
|
||||
Src/MemoryCards/WiiSaveCrypted.cpp
|
||||
Src/WXInputBase.cpp
|
||||
Src/WxUtils.cpp)
|
||||
|
||||
set(WXLIBS debwx
|
||||
debugger_ui_util
|
||||
inputuicommon
|
||||
${wxWidgets_LIBRARIES}
|
||||
${GTK2_LIBRARIES})
|
||||
|
||||
else(wxWidgets_FOUND)
|
||||
set(SRCS ${SRCS}
|
||||
Src/MainNoGUI.cpp
|
||||
Src/cmdline.c)
|
||||
Src/MainNoGUI.cpp)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
Optimization="3"
|
||||
InlineFunctionExpansion="0"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
|
||||
StringPooling="false"
|
||||
RuntimeLibrary="0"
|
||||
|
@ -175,7 +175,7 @@
|
|||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="false"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
|
@ -287,7 +287,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;__WXMSW__;__WXDEBUG__;_WINDOWS;NOPCH;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
@ -398,7 +398,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;__WXMSW__;__WXDEBUG__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
@ -511,7 +511,7 @@
|
|||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
PreprocessorDefinitions="DEBUGFAST;WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
|
@ -627,7 +627,7 @@
|
|||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DebuggerWX\src;..\DebuggerUICommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\SFML\include;..\..\..\Externals\CLRun\include"
|
||||
PreprocessorDefinitions="DEBUGFAST;WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
|
@ -1231,6 +1231,14 @@
|
|||
RelativePath=".\src\stdafx.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\WXInputBase.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\WXInputBase.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\WxUtils.cpp"
|
||||
>
|
||||
|
|
|
@ -257,87 +257,13 @@ void X11_MainLoop()
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
int cocoaArgc;
|
||||
char **cocoaArgv;
|
||||
int appleMain(int argc, char *argv[]);
|
||||
|
||||
@interface CocoaThread : NSObject
|
||||
{
|
||||
NSThread *Thread;
|
||||
}
|
||||
- (void)cocoaThreadStart;
|
||||
- (void)cocoaThreadRun: (id) sender;
|
||||
@end
|
||||
|
||||
@implementation CocoaThread
|
||||
#define CocoaThreadHaveFinish @"CocoaThreadHaveFinish"
|
||||
- (void)cocoaThreadStart
|
||||
{
|
||||
[NSThread detachNewThreadSelector: @selector(cocoaThreadRun:)
|
||||
toTarget: self withObject: nil];
|
||||
}
|
||||
|
||||
- (void)cocoaThreadRun: (id) sender
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
Thread = [NSThread currentThread];
|
||||
|
||||
appleMain(cocoaArgc, cocoaArgv);
|
||||
|
||||
[pool release];
|
||||
}
|
||||
@end
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSEvent *event = [[NSEvent alloc] init];
|
||||
CocoaThread *thread = [[CocoaThread alloc] init];
|
||||
ProcessSerialNumber psn;
|
||||
|
||||
cocoaArgc = argc;
|
||||
cocoaArgv = argv;
|
||||
|
||||
GetCurrentProcess(&psn);
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
SetFrontProcess(&psn);
|
||||
|
||||
if (NSApp == nil) {
|
||||
[NSApplication sharedApplication];
|
||||
//TODO : Create menu
|
||||
[NSApp finishLaunching];
|
||||
}
|
||||
|
||||
[thread cocoaThreadStart];
|
||||
|
||||
while (1)
|
||||
{
|
||||
event = [NSApp nextEventMatchingMask: NSKeyDownMask
|
||||
untilDate: [NSDate distantFuture]
|
||||
inMode: NSDefaultRunLoopMode dequeue: YES];
|
||||
|
||||
if (([event modifierFlags] & NSCommandKeyMask) == 0)
|
||||
continue;
|
||||
|
||||
if ([[event characters] UTF8String][0] == 'q') {
|
||||
Core::Stop();
|
||||
break;
|
||||
} else
|
||||
[NSApp sendEvent: event];
|
||||
}
|
||||
|
||||
[event release];
|
||||
[thread release];
|
||||
[pool release];
|
||||
}
|
||||
|
||||
int appleMain(int argc, char *argv[])
|
||||
#else
|
||||
int main(int argc, char* argv[])
|
||||
#endif
|
||||
{
|
||||
int ch, help = 0;
|
||||
struct option longopts[] = {
|
||||
{ "exec", no_argument, NULL, 'e' },
|
||||
|
@ -380,7 +306,38 @@ int main(int argc, char* argv[])
|
|||
// No use running the loop when booting fails
|
||||
if (BootManager::BootCore(argv[optind]))
|
||||
{
|
||||
#if defined HAVE_X11 && HAVE_X11
|
||||
#ifdef __APPLE__
|
||||
GetCurrentProcess(&psn);
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
SetFrontProcess(&psn);
|
||||
|
||||
if (NSApp == nil) {
|
||||
[NSApplication sharedApplication];
|
||||
//TODO : Create menu
|
||||
[NSApp finishLaunching];
|
||||
}
|
||||
|
||||
while (running)
|
||||
{
|
||||
event = [NSApp nextEventMatchingMask: NSAnyEventMask
|
||||
untilDate: [NSDate distantFuture]
|
||||
inMode: NSDefaultRunLoopMode dequeue: YES];
|
||||
|
||||
if ([event type] == NSKeyDown &&
|
||||
[event modifierFlags] & NSCommandKeyMask &&
|
||||
[[event characters] UTF8String][0] == 'q')
|
||||
{
|
||||
Core::Stop();
|
||||
break;
|
||||
}
|
||||
|
||||
if ([event type] != NSKeyDown)
|
||||
[NSApp sendEvent: event];
|
||||
}
|
||||
|
||||
[event release];
|
||||
[pool release];
|
||||
#elif defined HAVE_X11 && HAVE_X11
|
||||
XInitThreads();
|
||||
X11_MainLoop();
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue