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

Caolán McNamara caolanm at redhat.com
Fri Jul 17 03:58:30 PDT 2015


 vcl/unx/generic/desktopdetect/desktopdetector.cxx |  120 +++++++++++-----------
 1 file changed, 63 insertions(+), 57 deletions(-)

New commits:
commit 6353dc86585df7796200eabe1e2be8511211adee
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jul 17 11:32:00 2015 +0100

    move all the X foo of desktop detection in the fallback path
    
    Change-Id: I53e2634984c8e08b707dc3a21b2a6e68b48ec701

diff --git a/vcl/unx/generic/desktopdetect/desktopdetector.cxx b/vcl/unx/generic/desktopdetect/desktopdetector.cxx
index 0cc1f35..58ecf2d 100644
--- a/vcl/unx/generic/desktopdetect/desktopdetector.cxx
+++ b/vcl/unx/generic/desktopdetect/desktopdetector.cxx
@@ -321,54 +321,14 @@ DESKTOP_DETECTOR_PUBLIC DesktopType get_desktop_environment()
             return DESKTOP_UNKNOWN;
     }
 
-    // get display to connect to
-    const char* pDisplayStr = getenv( "DISPLAY" );
-
     OUString plugin;
     rtl::Bootstrap::get("SAL_USE_VCLPLUGIN", plugin);
 
     if (plugin == "svp")
-        pDisplayStr = NULL;
-    else
-    {
-        int nParams = rtl_getAppCommandArgCount();
-        OUString aParam;
-        OString aBParm;
-        for( int i = 0; i < nParams; i++ )
-        {
-            rtl_getAppCommandArg( i, &aParam.pData );
-            if( i < nParams-1 && (aParam == "-display" || aParam == "--display" ) )
-            {
-                rtl_getAppCommandArg( i+1, &aParam.pData );
-                aBParm = OUStringToOString( aParam, osl_getThreadTextEncoding() );
-                pDisplayStr = aBParm.getStr();
-                break;
-            }
-        }
-    }
-
-    // no server at all
-    if( ! pDisplayStr || !*pDisplayStr )
-        return DESKTOP_NONE;
-
-    /* #i92121# workaround deadlocks in the X11 implementation
-    */
-    static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" );
-    /* #i90094#
-       from now on we know that an X connection will be
-       established, so protect X against itself
-    */
-    if( ! ( pNoXInitThreads && *pNoXInitThreads ) )
-        XInitThreads();
-
-    Display* pDisplay = XOpenDisplay( pDisplayStr );
-    if( pDisplay == NULL )
         return DESKTOP_NONE;
 
     DesktopType ret;
 
-    XErrorHandler pOldHdl = XSetErrorHandler( autodect_error_handler );
-
     const char *pSession;
     OString aDesktopSession;
     if ( ( pSession = getenv( "DESKTOP_SESSION" ) ) )
@@ -390,26 +350,68 @@ DESKTOP_DETECTOR_PUBLIC DesktopType get_desktop_environment()
         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_kde5_desktop( pDisplay ) )
-        ret = DESKTOP_KDE5;
-    else if ( is_kde4_desktop( pDisplay ) )
-        ret = DESKTOP_KDE4;
-    else if ( is_gnome_desktop( pDisplay ) )
-        ret = DESKTOP_GNOME;
-    else if ( is_kde_desktop( pDisplay ) )
-        ret = DESKTOP_KDE;
-    else if ( is_tde_desktop( pDisplay ) )
-        ret = DESKTOP_TDE;
     else
-        ret = DESKTOP_UNKNOWN;
+    {
+        // these guys can be slower, with X property fetches,
+        // round-trips etc. and so are done later.
+
+        // get display to connect to
+        const char* pDisplayStr = getenv( "DISPLAY" );
 
-    // set the default handler again
-    XSetErrorHandler( pOldHdl );
+        int nParams = rtl_getAppCommandArgCount();
+        OUString aParam;
+        OString aBParm;
+        for( int i = 0; i < nParams; i++ )
+        {
+            rtl_getAppCommandArg( i, &aParam.pData );
+            if( i < nParams-1 && (aParam == "-display" || aParam == "--display" ) )
+            {
+                rtl_getAppCommandArg( i+1, &aParam.pData );
+                aBParm = OUStringToOString( aParam, osl_getThreadTextEncoding() );
+                pDisplayStr = aBParm.getStr();
+                break;
+            }
+        }
 
-    XCloseDisplay( pDisplay );
+        // no server at all
+        if( ! pDisplayStr || !*pDisplayStr )
+            return DESKTOP_NONE;
+
+
+        /* #i92121# workaround deadlocks in the X11 implementation
+        */
+        static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" );
+        /* #i90094#
+           from now on we know that an X connection will be
+           established, so protect X against itself
+        */
+        if( ! ( pNoXInitThreads && *pNoXInitThreads ) )
+            XInitThreads();
+
+        Display* pDisplay = XOpenDisplay( pDisplayStr );
+        if( pDisplay == NULL )
+            return DESKTOP_NONE;
+
+        XErrorHandler pOldHdl = XSetErrorHandler( autodect_error_handler );
+
+        if ( is_kde5_desktop( pDisplay ) )
+            ret = DESKTOP_KDE5;
+        else if ( is_kde4_desktop( pDisplay ) )
+            ret = DESKTOP_KDE4;
+        else if ( is_gnome_desktop( pDisplay ) )
+            ret = DESKTOP_GNOME;
+        else if ( is_kde_desktop( pDisplay ) )
+            ret = DESKTOP_KDE;
+        else if ( is_tde_desktop( pDisplay ) )
+            ret = DESKTOP_TDE;
+        else
+            ret = DESKTOP_UNKNOWN;
+
+        // set the default handler again
+        XSetErrorHandler( pOldHdl );
+
+        XCloseDisplay( pDisplay );
+    }
 
     return ret;
 }
commit edaacb62d057a3d68b473a36fcf9b1c6059fbfcc
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jul 17 11:28:37 2015 +0100

    add gnome-wayland alongside gnome
    
    Change-Id: I5d57f715edbadc7fef5c508cae7e98bcde0e4e5c

diff --git a/vcl/unx/generic/desktopdetect/desktopdetector.cxx b/vcl/unx/generic/desktopdetect/desktopdetector.cxx
index 4a0838b..0cc1f35 100644
--- a/vcl/unx/generic/desktopdetect/desktopdetector.cxx
+++ b/vcl/unx/generic/desktopdetect/desktopdetector.cxx
@@ -307,6 +307,8 @@ DESKTOP_DETECTOR_PUBLIC DesktopType get_desktop_environment()
             return DESKTOP_KDE4;
         if ( aOver.equalsIgnoreAsciiCase( "gnome" ) )
             return DESKTOP_GNOME;
+        if ( aOver.equalsIgnoreAsciiCase( "gnome-wayland" ) )
+            return DESKTOP_GNOME;
         if ( aOver.equalsIgnoreAsciiCase( "unity" ) )
             return DESKTOP_UNITY;
         if ( aOver.equalsIgnoreAsciiCase( "xfce" ) )
@@ -382,6 +384,8 @@ DESKTOP_DETECTOR_PUBLIC DesktopType get_desktop_environment()
         ret = DESKTOP_UNITY;
     else if ( aDesktopSession.equalsIgnoreAsciiCase( "gnome" ) )
         ret = DESKTOP_GNOME;
+    else if ( aDesktopSession.equalsIgnoreAsciiCase( "gnome-wayland" ) )
+        ret = DESKTOP_GNOME;
     else if ( aDesktopSession.equalsIgnoreAsciiCase( "mate" ) )
         ret = DESKTOP_MATE;
     else if ( aDesktopSession.equalsIgnoreAsciiCase( "xfce" ) )


More information about the Libreoffice-commits mailing list