Commit 3b1cf3f4 authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Use native SDL_OpenURL function for better wayland compatability

parent cb6d930a
......@@ -41,6 +41,7 @@
#include "lldir.h"
#include "llfindlocale.h"
#include <SDL_misc.h>
#if LL_GTK
extern "C" {
......@@ -2507,39 +2508,6 @@ BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b)
}
#endif // LL_GTK
#if LL_LINUX
// extracted from spawnWebBrowser for clarity and to eliminate
// compiler confusion regarding close(int fd) vs. LLWindow::close()
void exec_cmd(const std::string& cmd, const std::string& arg)
{
char* const argv[] = {(char*)cmd.c_str(), (char*)arg.c_str(), NULL};
fflush(NULL);
pid_t pid = fork();
if (pid == 0)
{ // child
// disconnect from stdin/stdout/stderr, or child will
// keep our output pipe undesirably alive if it outlives us.
close(0);
close(1);
close(2);
// end ourself by running the command
execv(cmd.c_str(), argv); /* Flawfinder: ignore */
// if execv returns at all, there was a problem.
LL_WARNS() << "execv failure when trying to start " << cmd << LL_ENDL;
_exit(1); // _exit because we don't want atexit() clean-up!
} else {
if (pid > 0)
{
// parent - wait for child to die
int childExitStatus;
waitpid(pid, &childExitStatus, 0);
} else {
LL_WARNS() << "fork failure." << LL_ENDL;
}
}
}
#endif
// Open a URL with the user's default web browser.
// Must begin with protocol identifier.
void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async)
......@@ -2563,24 +2531,10 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async)
LL_INFOS() << "spawn_web_browser: " << escaped_url << LL_ENDL;
#if LL_LINUX
# if LL_X11
if (mSDL_Display)
if (SDL_OpenURL(escaped_url.c_str()) != 0)
{
// Just in case - before forking.
XSync(mSDL_Display, False);
LL_WARNS() << "spawn_web_browser failed with error: " << SDL_GetError() << LL_ENDL;
}
# endif // LL_X11
std::string cmd, arg;
cmd = gDirUtilp->getAppRODataDir();
cmd += gDirUtilp->getDirDelimiter();
cmd += "etc";
cmd += gDirUtilp->getDirDelimiter();
cmd += "launch_url.sh";
arg = escaped_url;
exec_cmd(cmd, arg);
#endif // LL_LINUX
LL_INFOS() << "spawn_web_browser returning." << LL_ENDL;
}
......
Second Life - Linux Beta README
Alchemy - Linux Beta README
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This document contains information about the Alchemy Viewer Linux
......
#!/bin/bash
# This script loads a web page in the 'default' graphical web browser.
# It MUST return immediately (or soon), so the browser should be
# launched in the background (thus no text-only browsers).
# This script does not trust the URL to be well-escaped or shell-safe.
#
# On Unixoids we try, in order of decreasing priority:
# - $BROWSER if set (preferred)
# - Default GNOME browser
# - Default KDE browser
# - x-www-browser
# - The first browser in $BROWSER_COMMANDS that is found.
URL="$1"
if [ -z "$URL" ]; then
echo "Usage: $(basename "$0") URL"
exit
fi
# restore LD_LIBRARY_PATH from SAVED_LD_LIBRARY_PATH if it exists
if [ "${SAVED_LD_LIBRARY_PATH+isset}" = "isset" ]; then
export LD_LIBRARY_PATH="${SAVED_LD_LIBRARY_PATH}"
echo "$0: Restored library path to '${SAVED_LD_LIBRARY_PATH}'"
fi
# if $BROWSER is defined, use it.
XBROWSER=`echo "$BROWSER" |cut -f1 -d:`
if [ ! -z "$XBROWSER" ]; then
XBROWSER_CMD=`echo "$XBROWSER" |cut -f1 -d' '`
# look for $XBROWSER_CMD either literally or in PATH
if [ -x "$XBROWSER_CMD" ] || which $XBROWSER_CMD >/dev/null; then
# check for %s string, avoiding bash2-ism of [[ ]]
if echo "$XBROWSER" | grep %s >/dev/null; then
# $XBROWSER has %s which needs substituting
echo "$URL" | xargs -r -i%s $XBROWSER &
exit
fi
# $XBROWSER has no %s, tack URL on the end instead
$XBROWSER "$URL" &
exit
fi
echo "$0: Couldn't find the browser specified by \$BROWSER ($BROWSER)"
echo "$0: Trying some others..."
fi
# Launcher the default GNOME browser.
if [ ! -z "$GNOME_DESKTOP_SESSION_ID" ] && which gnome-open >/dev/null; then
gnome-open "$URL" &
exit
fi
# Launch the default KDE browser.
if [ ! -z "$KDE_FULL_SESSION" ] && which kfmclient >/dev/null; then
kfmclient openURL "$URL" &
exit
fi
# List of browser commands that will be tried in the order listed. x-www-browser
# will be tried first, which is a debian alternative.
BROWSER_COMMANDS=" \
x-www-browser \
google-chrome-stable \
google-chrome \
chromium \
firefox \
mozilla-firefox \
iceweasel \
iceape \
opera \
epiphany-browser \
epiphany-gecko \
epiphany-webkit \
epiphany \
mozilla \
seamonkey \
galeon \
dillo \
netscape"
for browser_cmd in $BROWSER_COMMANDS; do
if which $browser_cmd >/dev/null; then
$browser_cmd "$URL" &
exit
fi
done
echo '$0: Failed to find a known browser. Please consider setting the $BROWSER environment variable.'
exit 1
......@@ -1093,7 +1093,6 @@ def construct(self):
self.path("handle_secondlifeprotocol.sh")
self.path("register_secondlifeprotocol.sh")
self.path("refresh_desktop_app_entry.sh")
self.path("launch_url.sh")
self.path("chrome_sandboxing_permissions_setup.sh")
self.path("install.sh")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment