summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2018-09-17 17:41:41 +0200
committerAndras Timar <andras.timar@collabora.com>2018-09-21 09:41:53 +0200
commit32166cb1a88bba9a5ab6a6b4737d4d2117aec473 (patch)
tree19cffcc3da8f194dcc63a6f17f143527ae771f78
parentc1d717425027ee5770b69e1826ebb75d1d9a3013 (diff)
tdf#119881: Check if Unity/Gnome is separated by colon in XDG_CURRENT_DESKTOP
Change-Id: Ie29c2213d8efccd7750396325ce05b4909c09d02 Reviewed-on: https://gerrit.libreoffice.org/60592 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com> (cherry picked from commit 79093cce6c3a65f84bbafd172b1e9e6702d3ce75) Reviewed-on: https://gerrit.libreoffice.org/60678 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> Tested-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> (cherry picked from commit 0ed572e46a14078c3e96eae063226fcb8823f758)
-rw-r--r--vcl/unx/generic/desktopdetect/desktopdetector.cxx21
1 files changed, 16 insertions, 5 deletions
diff --git a/vcl/unx/generic/desktopdetect/desktopdetector.cxx b/vcl/unx/generic/desktopdetect/desktopdetector.cxx
index 02ac9be09c3d..765aa80dcebb 100644
--- a/vcl/unx/generic/desktopdetect/desktopdetector.cxx
+++ b/vcl/unx/generic/desktopdetect/desktopdetector.cxx
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <string.h>
+#include <comphelper/string.hxx>
static bool is_gnome_desktop( Display* pDisplay )
{
@@ -324,14 +325,24 @@ DESKTOP_DETECTOR_PUBLIC DesktopType get_desktop_environment()
aDesktopSession = OString( pSession, strlen( pSession ) );
const char *pDesktop;
- OString aCurrentDesktop;
if ( ( pDesktop = getenv( "XDG_CURRENT_DESKTOP" ) ) )
- aCurrentDesktop = OString( pDesktop, strlen( pDesktop ) );
+ {
+ OString aCurrentDesktop = OString( pDesktop, strlen( pDesktop ) );
+
+ //it may be separated by colon ( e.g. unity:unity7:ubuntu )
+ std::vector<OUString> aSplitCurrentDesktop = comphelper::string::split(
+ OStringToOUString( aCurrentDesktop, RTL_TEXTENCODING_UTF8), ':');
+ for (auto& rCurrentDesktopStr : aSplitCurrentDesktop)
+ {
+ if ( rCurrentDesktopStr.equalsIgnoreAsciiCase( "unity" ) )
+ return DESKTOP_UNITY;
+ else if ( rCurrentDesktopStr.equalsIgnoreAsciiCase( "gnome") )
+ return DESKTOP_GNOME;
+ }
+ }
// fast environment variable checks
- if ( aCurrentDesktop.equalsIgnoreAsciiCase( "unity" ) )
- ret = DESKTOP_UNITY;
- else if ( aDesktopSession.equalsIgnoreAsciiCase( "gnome" ) )
+ if ( aDesktopSession.equalsIgnoreAsciiCase( "gnome" ) )
ret = DESKTOP_GNOME;
else if ( aDesktopSession.equalsIgnoreAsciiCase( "gnome-wayland" ) )
ret = DESKTOP_GNOME;