mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Don't call app_main() from OSXApp
This commit is contained in:
parent
4acf12a478
commit
c900e4aa3c
@ -1,5 +1,5 @@
|
||||
// SHE library
|
||||
// Copyright (C) 2012-2015 David Capello
|
||||
// Copyright (C) 2012-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -16,15 +16,14 @@ namespace she {
|
||||
|
||||
class OSXApp {
|
||||
public:
|
||||
static OSXApp* instance() { return g_instance; }
|
||||
|
||||
OSXApp();
|
||||
~OSXApp();
|
||||
|
||||
int run(int argc, char* argv[]);
|
||||
bool init();
|
||||
|
||||
private:
|
||||
static OSXApp* g_instance;
|
||||
class Impl;
|
||||
Impl* m_impl;
|
||||
};
|
||||
|
||||
} // namespace she
|
||||
|
@ -19,29 +19,36 @@ extern int app_main(int argc, char* argv[]);
|
||||
|
||||
namespace she {
|
||||
|
||||
OSXApp* OSXApp::g_instance = nullptr;
|
||||
class OSXApp::Impl {
|
||||
public:
|
||||
bool init() {
|
||||
m_app = [NSApplication sharedApplication];
|
||||
m_appDelegate = [OSXAppDelegate new];
|
||||
|
||||
[m_app setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
[m_app setDelegate:m_appDelegate];
|
||||
[m_app activateIgnoringOtherApps:YES];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
NSApplication* m_app;
|
||||
id m_appDelegate;
|
||||
};
|
||||
|
||||
OSXApp::OSXApp()
|
||||
: m_impl(new Impl)
|
||||
{
|
||||
g_instance = this;
|
||||
}
|
||||
|
||||
OSXApp::~OSXApp()
|
||||
{
|
||||
g_instance = nullptr;
|
||||
}
|
||||
|
||||
int OSXApp::run(int argc, char* argv[])
|
||||
bool OSXApp::init()
|
||||
{
|
||||
NSApplication* app = [NSApplication sharedApplication];
|
||||
id appDelegate = [OSXAppDelegate new];
|
||||
|
||||
[app setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
[app setDelegate:appDelegate];
|
||||
[app activateIgnoringOtherApps:YES];
|
||||
|
||||
app_main(argc, argv);
|
||||
return 0;
|
||||
return m_impl->init();
|
||||
}
|
||||
|
||||
} // namespace she
|
||||
|
@ -54,8 +54,7 @@ extern int app_main(int argc, char* argv[]);
|
||||
|
||||
#if _WIN32
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
LPSTR lpCmdLine, int nCmdShow) {
|
||||
int argc = 0;
|
||||
LPWSTR* argvW = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
char** argv;
|
||||
@ -70,19 +69,16 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
argv[0] = base_strdup("");
|
||||
}
|
||||
#else
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int main(int argc, char* argv[]) {
|
||||
#endif
|
||||
|
||||
#if __APPLE__
|
||||
she::OSXApp app;
|
||||
return app.run(argc, argv);
|
||||
#else
|
||||
|
||||
#ifndef _WIN32
|
||||
if (!app.init())
|
||||
return 1;
|
||||
#elif !defined(_WIN32)
|
||||
she::X11 x11;
|
||||
#endif
|
||||
|
||||
return app_main(argc, argv);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user