mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Activate app on OS X when Aseprite is launched from Steam
It looks like a Steam clien bug on OS X, it activates Aseprite window, and then Steam is activated again, so the Aseprite window lost the focus and is left below the Steam window.
This commit is contained in:
parent
aa6040e2e4
commit
5456b5950d
@ -665,6 +665,8 @@ void App::run()
|
||||
// Initialize Steam API
|
||||
#ifdef ENABLE_STEAM
|
||||
steam::SteamAPI steam;
|
||||
if (steam.initialized())
|
||||
she::instance()->activateApp();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UPDATER
|
||||
|
@ -144,6 +144,10 @@ public:
|
||||
delete this;
|
||||
}
|
||||
|
||||
void activateApp() override {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void finishLaunching() override {
|
||||
// Do nothing
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ namespace she {
|
||||
~OSXApp();
|
||||
|
||||
bool init();
|
||||
void activateApp();
|
||||
void finishLaunching();
|
||||
|
||||
private:
|
||||
|
@ -38,6 +38,14 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// We might need to call this function when the app is launched from
|
||||
// Steam. It appears that there is a bug on OS X Steam client where
|
||||
// the app is launched, activated, and then the Steam client is
|
||||
// activated again.
|
||||
void activateApp() {
|
||||
[m_app activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
void finishLaunching() {
|
||||
[m_app finishLaunching];
|
||||
}
|
||||
@ -73,6 +81,11 @@ bool OSXApp::init()
|
||||
return m_impl->init();
|
||||
}
|
||||
|
||||
void OSXApp::activateApp()
|
||||
{
|
||||
m_impl->activateApp();
|
||||
}
|
||||
|
||||
void OSXApp::finishLaunching()
|
||||
{
|
||||
m_impl->finishLaunching();
|
||||
|
@ -57,6 +57,12 @@ public:
|
||||
delete this;
|
||||
}
|
||||
|
||||
void activateApp() override {
|
||||
#if __APPLE__
|
||||
OSXApp::instance()->activateApp();
|
||||
#endif
|
||||
}
|
||||
|
||||
void finishLaunching() override {
|
||||
#if __APPLE__
|
||||
// Start processing NSApplicationDelegate events. (E.g. after
|
||||
|
@ -32,6 +32,7 @@ namespace she {
|
||||
public:
|
||||
virtual ~System() { }
|
||||
virtual void dispose() = 0;
|
||||
virtual void activateApp() = 0;
|
||||
virtual void finishLaunching() = 0;
|
||||
virtual Capabilities capabilities() const = 0;
|
||||
virtual Logger* logger() = 0;
|
||||
|
@ -35,16 +35,20 @@ typedef void (*SteamAPI_Shutdown_Func)();
|
||||
|
||||
class SteamAPI::Impl {
|
||||
public:
|
||||
Impl() {
|
||||
Impl() : m_initialized(false) {
|
||||
m_steamLib = base::load_dll(
|
||||
base::join_path(base::get_file_path(base::get_app_path()),
|
||||
STEAM_API_DLL_FILENAME));
|
||||
if (!m_steamLib)
|
||||
if (!m_steamLib) {
|
||||
LOG("Steam library not found...\n");
|
||||
return;
|
||||
}
|
||||
|
||||
auto SteamAPI_Init = base::get_dll_proc<SteamAPI_Init_Func>(m_steamLib, "SteamAPI_Init");
|
||||
if (!SteamAPI_Init)
|
||||
if (!SteamAPI_Init) {
|
||||
LOG("SteamAPI_Init not found...\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SteamAPI_Init()) {
|
||||
LOG("Steam is not initialized...\n");
|
||||
@ -52,6 +56,7 @@ public:
|
||||
}
|
||||
|
||||
LOG("Steam initialized...\n");
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
~Impl() {
|
||||
@ -67,8 +72,13 @@ public:
|
||||
base::unload_dll(m_steamLib);
|
||||
}
|
||||
|
||||
bool initialized() const {
|
||||
return m_initialized;
|
||||
}
|
||||
|
||||
private:
|
||||
base::dll m_steamLib;
|
||||
bool m_initialized;
|
||||
};
|
||||
|
||||
SteamAPI::SteamAPI()
|
||||
@ -81,4 +91,9 @@ SteamAPI::~SteamAPI()
|
||||
delete m_impl;
|
||||
}
|
||||
|
||||
bool SteamAPI::initialized() const
|
||||
{
|
||||
return m_impl->initialized();
|
||||
}
|
||||
|
||||
} // namespace steam
|
||||
|
@ -15,6 +15,8 @@ public:
|
||||
SteamAPI();
|
||||
~SteamAPI();
|
||||
|
||||
bool initialized() const;
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
Impl* m_impl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user