Browse Source

macOS: fix issues with drag-and-drop to open a love game

- Fix love.event.quit("restart") running the no-game screen instead of the current game.
- Fix fused apps opening other games when drag-and-drop is used.
Alex Szpakowski 4 years ago
parent
commit
f519d2e2df
1 changed files with 27 additions and 26 deletions
  1. 27 26
      src/love.cpp

+ 27 - 26
src/love.cpp

@@ -75,38 +75,39 @@ static void get_app_arguments(int argc, char **argv, int &new_argc, char **&new_
 			temp_argv.push_back(std::string(argv[i]));
 	}
 
-#ifdef LOVE_MACOSX
-	// 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.
-	std::string dropfilestr;
-	if (!isatty(STDIN_FILENO))
-		dropfilestr = love::macosx::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 it exists, add the love file in love.app/Contents/Resources/ to argv.
+	std::string loveResourcesPath;
+	bool fused = true;
 #if defined(LOVE_MACOSX)
-		loveResourcesPath = love::macosx::getLoveInResources();
+	loveResourcesPath = love::macosx::getLoveInResources();
 #elif defined(LOVE_IOS)
-		loveResourcesPath = love::ios::getLoveInResources(fused);
+	loveResourcesPath = love::ios::getLoveInResources(fused);
 #endif
-		if (!loveResourcesPath.empty())
-		{
-			std::vector<std::string>::iterator it = temp_argv.begin();
-			it = temp_argv.insert(it + 1, loveResourcesPath);
+	if (!loveResourcesPath.empty())
+	{
+		std::vector<std::string>::iterator it = temp_argv.begin();
+		it = temp_argv.insert(it + 1, loveResourcesPath);
 
-			// Run in pseudo-fused mode.
-			if (fused)
-				temp_argv.insert(it + 1, std::string("--fused"));
+		// Run in pseudo-fused mode.
+		if (fused)
+			temp_argv.insert(it + 1, std::string("--fused"));
+	}
+#ifdef LOVE_MACOSX
+	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::macosx::checkDropEvents();
+			if (!dropfilestr.empty())
+				temp_argv.insert(temp_argv.begin() + 1, dropfilestr);
 		}
 	}
+#endif
 
 	// Copy temp argv vector to new argv array.
 	new_argc = (int) temp_argv.size();