summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2013-07-02 21:58:12 +0100
committerMichael Meeks <michael.meeks@suse.com>2013-07-02 21:59:31 +0100
commitd2a71b952850cdf1a7efc5c0f86df9864201a950 (patch)
treecd2ceed4b0b012c5a7883bcdf137ec2d18806d92
parentf31fad32005c6709eaae71b49af31264e585478a (diff)
fdo#46990 - re-work new desktop checks, guard against NULL DESKTOP_SESSION.
Change-Id: Ia3e408b372989b757f7dde080849e38d315d53cd
-rw-r--r--vcl/unx/generic/desktopdetect/desktopdetector.cxx47
-rw-r--r--vcl/unx/generic/plugadapt/salplug.cxx10
2 files changed, 27 insertions, 30 deletions
diff --git a/vcl/unx/generic/desktopdetect/desktopdetector.cxx b/vcl/unx/generic/desktopdetect/desktopdetector.cxx
index a133449d21fc..d2d91dee76b2 100644
--- a/vcl/unx/generic/desktopdetect/desktopdetector.cxx
+++ b/vcl/unx/generic/desktopdetect/desktopdetector.cxx
@@ -42,11 +42,8 @@ static bool is_gnome_desktop( Display* pDisplay )
// warning: these checks are coincidental, GNOME does not
// explicitly advertise itself
-
- if ( "gnome" == getenv( "DESKTOP_SESSION" ) || NULL != getenv( "GNOME_DESKTOP_SESSION_ID" ) )
- {
+ if ( NULL != getenv( "GNOME_DESKTOP_SESSION_ID" ) )
ret = true;
- }
if( ! ret )
{
@@ -121,24 +118,6 @@ static bool is_gnome_desktop( Display* pDisplay )
return ret;
}
-static bool is_xfce_desktop( Display* pDisplay )
-{
- if ( "xfce" == getenv( "DESKTOP_SESSION" ) )
- {
- return true;
- }
- return false;
-}
-
-static bool is_mate_desktop( Display* pDisplay )
-{
- if ( "mate" == getenv( "DESKTOP_SESSION" ) )
- {
- return true;
- }
- return false;
-}
-
static bool bWasXError = false;
static inline bool WasXError()
@@ -369,18 +348,30 @@ DESKTOP_DETECTOR_PUBLIC DesktopType get_desktop_environment()
XErrorHandler pOldHdl = XSetErrorHandler( autodect_error_handler );
- if ( is_tde_desktop( pDisplay ) )
- ret = DESKTOP_TDE;
+ const char *pSession;
+ OString aDesktopSession;
+
+ if ( ( pSession = getenv( "DESKTOP_SESSION" ) ) )
+ aDesktopSession = OString( pSession, strlen( pSession ) );
+
+ // fast environment variable checks
+ if ( aDesktopSession.equalsIgnoreAsciiCase( "gnome" ) )
+ ret = DESKTOP_GNOME;
+ else if ( aDesktopSession.equalsIgnoreAsciiCase( "mate" ) )
+ ret = DESKTOP_MATE;
+ else if ( aDesktopSession.equalsIgnoreAsciiCase( "xfce" ) )
+ ret = DESKTOP_XFCE;
+
+ // these guys can be slower, with X property fetches,
+ // round-trips etc. and so are done later.
else if ( is_kde4_desktop( pDisplay ) )
ret = DESKTOP_KDE4;
else if ( is_gnome_desktop( pDisplay ) )
ret = DESKTOP_GNOME;
- else if ( is_xfce_desktop( pDisplay ) )
- ret = DESKTOP_XFCE;
- else if ( is_mate_desktop( pDisplay ) )
- ret = DESKTOP_MATE;
else if ( is_kde_desktop( pDisplay ) )
ret = DESKTOP_KDE;
+ else if ( is_tde_desktop( pDisplay ) )
+ ret = DESKTOP_TDE;
else
ret = DESKTOP_UNKNOWN;
diff --git a/vcl/unx/generic/plugadapt/salplug.cxx b/vcl/unx/generic/plugadapt/salplug.cxx
index fba45f1c4a80..4cb49f9bccb1 100644
--- a/vcl/unx/generic/plugadapt/salplug.cxx
+++ b/vcl/unx/generic/plugadapt/salplug.cxx
@@ -188,7 +188,9 @@ static SalInstance* autodetect_plugin()
// no server at all: dummy plugin
if ( desktop == DESKTOP_NONE )
pList = pHeadlessFallbackList;
- else if ( desktop == DESKTOP_GNOME || desktop == DESKTOP_XFCE || desktop == DESKTOP_MATE )
+ else if ( desktop == DESKTOP_GNOME ||
+ desktop == DESKTOP_XFCE ||
+ desktop == DESKTOP_MATE )
pList = pStandardFallbackList;
else if( desktop == DESKTOP_TDE )
pList = pTDEFallbackList;
@@ -287,7 +289,11 @@ void SalAbort( const OUString& rErrorText, bool bDumpCore )
_exit(1);
}
-static const char * desktop_strings[] = { "none", "unknown", "GNOME", "XFCE", "MATE", "TDE", "KDE", "KDE4" };
+// Order to match desktops.hxx' DesktopType
+static const char * desktop_strings[] = {
+ "none", "unknown", "GNOME",
+ "XFCE", "MATE", "TDE",
+ "KDE", "KDE4" };
const OUString& SalGetDesktopEnvironment()
{