mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
SDL: Add implementation of OSystem::openUrl for SDL 2.0.14
This commit is contained in:
committed by
Filippos Karapetis
parent
76bf73ff46
commit
dfe79052d2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user