[Libreoffice-commits] core.git: vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Sep 18 10:51:16 UTC 2018


 vcl/unx/generic/desktopdetect/desktopdetector.cxx |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

New commits:
commit 79093cce6c3a65f84bbafd172b1e9e6702d3ce75
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Sep 17 17:41:41 2018 +0200
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Tue Sep 18 12:50:53 2018 +0200

    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 at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/vcl/unx/generic/desktopdetect/desktopdetector.cxx b/vcl/unx/generic/desktopdetect/desktopdetector.cxx
index e39348c460e6..56f6fe1d2d6c 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 )
 {
@@ -246,14 +247,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;


More information about the Libreoffice-commits mailing list