LCOV - code coverage report
Current view: top level - vcl/unx/generic/gdi - x11windowprovider.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 28 7.1 %
Date: 2015-06-13 12:38:46 Functions: 1 4 25.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <vcl/svapp.hxx>
      11             : 
      12             : #include "unx/x11windowprovider.hxx"
      13             : #include "unx/x11/x11display.hxx"
      14             : 
      15          13 : X11WindowProvider::~X11WindowProvider()
      16             : {
      17          13 : }
      18             : 
      19           0 : Display *OpenX11Display(OString& rDisplay)
      20             : {
      21             :     /*
      22             :      * open connection to X11 Display
      23             :      * try in this order:
      24             :      *  o  -display command line parameter,
      25             :      *  o  $DISPLAY environment variable
      26             :      *  o  default display
      27             :      */
      28             : 
      29           0 :     Display *pDisp = NULL;
      30             : 
      31             :     // is there a -display command line parameter?
      32             : 
      33           0 :     sal_uInt32 nParams = osl_getCommandArgCount();
      34           0 :     OUString aParam;
      35           0 :     for (sal_uInt32 i=0; i<nParams; i++)
      36             :     {
      37           0 :         osl_getCommandArg(i, &aParam.pData);
      38           0 :         if ( aParam == "-display" )
      39             :         {
      40           0 :             osl_getCommandArg(i+1, &aParam.pData);
      41           0 :             rDisplay = OUStringToOString(
      42           0 :                    aParam, osl_getThreadTextEncoding());
      43             : 
      44           0 :             if ((pDisp = XOpenDisplay(rDisplay.getStr()))!=NULL)
      45             :             {
      46             :                 /*
      47             :                  * if a -display switch was used, we need
      48             :                  * to set the environment accoringly since
      49             :                  * the clipboard build another connection
      50             :                  * to the xserver using $DISPLAY
      51             :                  */
      52           0 :                 OUString envVar("DISPLAY");
      53           0 :                 osl_setEnvironment(envVar.pData, aParam.pData);
      54             :             }
      55           0 :             break;
      56             :         }
      57             :     }
      58             : 
      59           0 :     if (!pDisp && rDisplay.isEmpty())
      60             :     {
      61             :         // Open $DISPLAY or default...
      62           0 :         char *pDisplay = getenv("DISPLAY");
      63           0 :         if (pDisplay != NULL)
      64           0 :             rDisplay = OString(pDisplay);
      65           0 :         pDisp  = XOpenDisplay(pDisplay);
      66             :     }
      67             : 
      68           0 :     return pDisp;
      69             : }
      70             : 
      71             : namespace vcl
      72             : {
      73             : 
      74           0 : bool IsWindowSystemAvailable()
      75             : {
      76             :     Display *pDisp;
      77           0 :     OString aDisplay;
      78             : 
      79           0 :     pDisp = OpenX11Display(aDisplay);
      80           0 :     if (pDisp)
      81           0 :         XCloseDisplay(pDisp);
      82             : 
      83           0 :     return (pDisp != nullptr);
      84             : }
      85             : 
      86             : } // namespace vcl
      87             : 
      88             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11