mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Merge branch 'master' into 12.0-development
This commit is contained in:
+27
-26
@@ -76,38 +76,39 @@ static void get_app_arguments(int argc, char **argv, int &new_argc, char **&new_
|
|||||||
temp_argv.push_back(std::string(argv[i]));
|
temp_argv.push_back(std::string(argv[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOVE_MACOS
|
// If it exists, add the love file in love.app/Contents/Resources/ to argv.
|
||||||
// Check for a drop file string, if the app wasn't launched in a terminal.
|
std::string loveResourcesPath;
|
||||||
// Checking for the terminal is a pretty big hack, but works around an issue
|
bool fused = true;
|
||||||
// where OS X will switch Spaces if the terminal launching love is in its
|
|
||||||
// own full-screen Space.
|
|
||||||
std::string dropfilestr;
|
|
||||||
if (!isatty(STDIN_FILENO))
|
|
||||||
dropfilestr = love::macos::checkDropEvents();
|
|
||||||
|
|
||||||
if (!dropfilestr.empty())
|
|
||||||
temp_argv.insert(temp_argv.begin() + 1, dropfilestr);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
// If it exists, add the love file in love.app/Contents/Resources/ to argv.
|
|
||||||
std::string loveResourcesPath;
|
|
||||||
bool fused = true;
|
|
||||||
#if defined(LOVE_MACOS)
|
#if defined(LOVE_MACOS)
|
||||||
loveResourcesPath = love::macos::getLoveInResources();
|
loveResourcesPath = love::macos::getLoveInResources();
|
||||||
#elif defined(LOVE_IOS)
|
#elif defined(LOVE_IOS)
|
||||||
loveResourcesPath = love::ios::getLoveInResources(fused);
|
loveResourcesPath = love::ios::getLoveInResources(fused);
|
||||||
#endif
|
#endif
|
||||||
if (!loveResourcesPath.empty())
|
if (!loveResourcesPath.empty())
|
||||||
{
|
{
|
||||||
std::vector<std::string>::iterator it = temp_argv.begin();
|
std::vector<std::string>::iterator it = temp_argv.begin();
|
||||||
it = temp_argv.insert(it + 1, loveResourcesPath);
|
it = temp_argv.insert(it + 1, loveResourcesPath);
|
||||||
|
|
||||||
// Run in pseudo-fused mode.
|
// Run in pseudo-fused mode.
|
||||||
if (fused)
|
if (fused)
|
||||||
temp_argv.insert(it + 1, std::string("--fused"));
|
temp_argv.insert(it + 1, std::string("--fused"));
|
||||||
|
}
|
||||||
|
#ifdef LOVE_MACOS
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check for a drop file string, if the app wasn't launched in a
|
||||||
|
// terminal. Checking for the terminal is a pretty big hack, but works
|
||||||
|
// around an issue where OS X will switch Spaces if the terminal
|
||||||
|
// launching love is in its own full-screen Space.
|
||||||
|
if (!isatty(STDIN_FILENO))
|
||||||
|
{
|
||||||
|
// Static to keep the same value after love.event.equit("restart").
|
||||||
|
static std::string dropfilestr = love::macos::checkDropEvents();
|
||||||
|
if (!dropfilestr.empty())
|
||||||
|
temp_argv.insert(temp_argv.begin() + 1, dropfilestr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Copy temp argv vector to new argv array.
|
// Copy temp argv vector to new argv array.
|
||||||
new_argc = (int) temp_argv.size();
|
new_argc = (int) temp_argv.size();
|
||||||
|
|||||||
@@ -39,7 +39,18 @@
|
|||||||
#if defined(LOVE_ANDROID)
|
#if defined(LOVE_ANDROID)
|
||||||
#include "common/android.h"
|
#include "common/android.h"
|
||||||
#elif defined(LOVE_LINUX)
|
#elif defined(LOVE_LINUX)
|
||||||
|
|
||||||
|
#ifdef __has_include
|
||||||
|
#if __has_include(<spawn.h>)
|
||||||
|
#define LOVE_HAS_POSIX_SPAWN
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOVE_HAS_POSIX_SPAWN
|
||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
@@ -70,10 +81,12 @@ std::string System::getOS() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LOVE_HAS_POSIX_SPAWN
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
extern char **environ; // The environment, always available
|
extern char **environ; // The environment, always available
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool System::openURL(const std::string &url) const
|
bool System::openURL(const std::string &url) const
|
||||||
{
|
{
|
||||||
@@ -104,10 +117,19 @@ bool System::openURL(const std::string &url) const
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
const char *argv[] = {"xdg-open", url.c_str(), nullptr};
|
const char *argv[] = {"xdg-open", url.c_str(), nullptr};
|
||||||
|
|
||||||
|
#ifdef LOVE_HAS_POSIX_SPAWN
|
||||||
// Note: at the moment this process inherits our file descriptors.
|
// Note: at the moment this process inherits our file descriptors.
|
||||||
// Note: the below const_cast is really ugly as well.
|
// Note: the below const_cast is really ugly as well.
|
||||||
if (posix_spawnp(&pid, "xdg-open", nullptr, nullptr, const_cast<char **>(argv), environ) != 0)
|
if (posix_spawnp(&pid, "xdg-open", nullptr, nullptr, const_cast<char **>(argv), environ) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
#else
|
||||||
|
pid = fork();
|
||||||
|
if (pid == 0)
|
||||||
|
{
|
||||||
|
execvp("xdg-open", const_cast<char **>(argv));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check if xdg-open already completed (or failed.)
|
// Check if xdg-open already completed (or failed.)
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user