[aseprite] 02/51: Activate app on OS X when Aseprite is launched from Steam
Tobias Hansen
thansen at moszumanska.debian.org
Mon Jul 11 21:35:14 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 5456b5950de6b3b57ad86600b502700c553534da
Author: David Capello <davidcapello at gmail.com>
Date: Tue Jun 7 14:47:59 2016 -0300
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.
---
src/app/app.cpp | 2 ++
src/she/alleg4/she.cpp | 4 ++++
src/she/osx/app.h | 1 +
src/she/osx/app.mm | 13 +++++++++++++
src/she/skia/skia_system.h | 6 ++++++
src/she/system.h | 1 +
src/steam/steam.cpp | 21 ++++++++++++++++++---
src/steam/steam.h | 2 ++
8 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 53fa3e2..4df0d7c 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -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
diff --git a/src/she/alleg4/she.cpp b/src/she/alleg4/she.cpp
index 3fdea81..f0e828c 100644
--- a/src/she/alleg4/she.cpp
+++ b/src/she/alleg4/she.cpp
@@ -144,6 +144,10 @@ public:
delete this;
}
+ void activateApp() override {
+ // Do nothing
+ }
+
void finishLaunching() override {
// Do nothing
}
diff --git a/src/she/osx/app.h b/src/she/osx/app.h
index f0352b8..91842f6 100644
--- a/src/she/osx/app.h
+++ b/src/she/osx/app.h
@@ -22,6 +22,7 @@ namespace she {
~OSXApp();
bool init();
+ void activateApp();
void finishLaunching();
private:
diff --git a/src/she/osx/app.mm b/src/she/osx/app.mm
index 87304ed..900ce80 100644
--- a/src/she/osx/app.mm
+++ b/src/she/osx/app.mm
@@ -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();
diff --git a/src/she/skia/skia_system.h b/src/she/skia/skia_system.h
index 2f96549..ebb4ee3 100644
--- a/src/she/skia/skia_system.h
+++ b/src/she/skia/skia_system.h
@@ -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
diff --git a/src/she/system.h b/src/she/system.h
index 9cf224b..cce34ad 100644
--- a/src/she/system.h
+++ b/src/she/system.h
@@ -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;
diff --git a/src/steam/steam.cpp b/src/steam/steam.cpp
index 9a8ed11..29d8cd8 100644
--- a/src/steam/steam.cpp
+++ b/src/steam/steam.cpp
@@ -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
diff --git a/src/steam/steam.h b/src/steam/steam.h
index 907eee5..236682c 100644
--- a/src/steam/steam.h
+++ b/src/steam/steam.h
@@ -15,6 +15,8 @@ public:
SteamAPI();
~SteamAPI();
+ bool initialized() const;
+
private:
class Impl;
Impl* m_impl;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list