[Scummvm-git-logs] scummvm master -> dfe79052d2adaafc4ac3297f36953a2bb1d288cf
bluegr
bluegr at gmail.com
Wed Mar 3 01:27:12 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
dfe79052d2 SDL: Add implementation of OSystem::openUrl for SDL 2.0.14
Commit: dfe79052d2adaafc4ac3297f36953a2bb1d288cf
https://github.com/scummvm/scummvm/commit/dfe79052d2adaafc4ac3297f36953a2bb1d288cf
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-03-03T03:27:09+02:00
Commit Message:
SDL: Add implementation of OSystem::openUrl for SDL 2.0.14
Changed paths:
backends/platform/sdl/posix/posix.cpp
backends/platform/sdl/posix/posix.h
backends/platform/sdl/sdl.cpp
backends/platform/sdl/sdl.h
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp
index 1af55bcd6b..8577e926eb 100644
--- a/backends/platform/sdl/posix/posix.cpp
+++ b/backends/platform/sdl/posix/posix.cpp
@@ -357,8 +357,8 @@ bool OSystem_POSIX::displayLogFile() {
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
}
-bool OSystem_POSIX::openUrl(const Common::String &url) {
#ifdef HAS_POSIX_SPAWN
+bool OSystem_POSIX::openUrl(const Common::String &url) {
// inspired by Qt's "qdesktopservices_x11.cpp"
// try "standards"
@@ -393,13 +393,9 @@ bool OSystem_POSIX::openUrl(const Common::String &url) {
warning("openUrl() (POSIX) failed to open URL");
return false;
-#else
- return false;
-#endif
}
bool OSystem_POSIX::launchBrowser(const Common::String &client, const Common::String &url) {
-#ifdef HAS_POSIX_SPAWN
pid_t pid;
const char *argv[] = {
client.c_str(),
@@ -415,10 +411,8 @@ bool OSystem_POSIX::launchBrowser(const Common::String &client, const Common::St
return false;
}
return (waitpid(pid, NULL, WNOHANG) != -1);
-#else
- return false;
-#endif
}
+#endif
AudioCDManager *OSystem_POSIX::createAudioCDManager() {
#ifdef USE_LINUXCD
diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h
index af4763e4d7..f2a00b2922 100644
--- a/backends/platform/sdl/posix/posix.h
+++ b/backends/platform/sdl/posix/posix.h
@@ -31,8 +31,6 @@ public:
virtual bool displayLogFile() override;
- virtual bool openUrl(const Common::String &url) override;
-
virtual void init() override;
virtual void initBackend() override;
@@ -48,7 +46,13 @@ protected:
virtual AudioCDManager *createAudioCDManager() override;
+#ifdef HAS_POSIX_SPAWN
+public:
+ virtual bool openUrl(const Common::String &url) override;
+
+protected:
bool launchBrowser(const Common::String& client, const Common::String &url);
+#endif
};
#endif
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index df64d8cf02..ff3795941c 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -182,6 +182,9 @@ void OSystem_SDL::init() {
bool OSystem_SDL::hasFeature(Feature f) {
#if SDL_VERSION_ATLEAST(2, 0, 0)
if (f == kFeatureClipboardSupport) return true;
+#endif
+#if SDL_VERSION_ATLEAST(2, 0, 14)
+ if (f == kFeatureOpenUrl) return true;
#endif
if (f == kFeatureJoystickDeadzone || f == kFeatureKbdMouseSpeed) {
return _eventSource->isJoystickConnected();
@@ -614,6 +617,17 @@ bool OSystem_SDL::setTextInClipboard(const Common::U32String &text) {
}
#endif
+#if SDL_VERSION_ATLEAST(2, 0, 14)
+bool OSystem_SDL::openUrl(const Common::String &url) {
+ if (SDL_OpenURL(url.c_str()) != 0) {
+ warning("Failed to open URL: %s", SDL_GetError());
+ return false;
+ }
+
+ return true;
+}
+#endif
+
uint32 OSystem_SDL::getMillis(bool skipRecord) {
uint32 millis = SDL_GetTicks();
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 125d26f89d..7eb7d8ba73 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -75,6 +75,10 @@ public:
virtual bool setTextInClipboard(const Common::U32String &text) override;
#endif
+#if SDL_VERSION_ATLEAST(2, 0, 14)
+ virtual bool openUrl(const Common::String &url) override;
+#endif
+
virtual void setWindowCaption(const Common::U32String &caption) override;
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
virtual uint32 getMillis(bool skipRecord = false) override;
More information about the Scummvm-git-logs
mailing list