LCOV - code coverage report
Current view: top level - eq/qt - windowSystem.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 13 29 44.8 %
Date: 2016-09-29 05:02:09 Functions: 5 10 50.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2014-2015, Daniel Nachbaur <danielnachbaur@gmail.com>
       3             :  *                          Juan Hernando <jhernando@fi.upm.es>
       4             :  *                          Stefan.Eilemann@epfl.ch
       5             :  *
       6             :  * This library is free software; you can redistribute it and/or modify it under
       7             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       8             :  * by the Free Software Foundation.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      12             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #define NOMINMAX // no min/max from windows.h
      21             : #pragma warning( disable: 4407 ) // see lunchbox/commandFunc.h
      22             : #include <eq/window.h> // be first to avoid max/min name clashes on Win32
      23             : 
      24             : #include "windowSystem.h"
      25             : 
      26             : #include "messagePump.h"
      27             : #include "pipe.h"
      28             : #include "shareContextWindow.h"
      29             : #include "window.h"
      30             : #include "windowImpl.h"
      31             : #include "windowFactory.h"
      32             : 
      33             : #include <eq/client.h>
      34             : #include <QApplication>
      35             : #include <QThread>
      36             : 
      37             : namespace eq
      38             : {
      39             : namespace qt
      40             : {
      41             : 
      42          14 : WindowSystem::WindowSystem()
      43          14 :     : _factory( new WindowFactory )
      44             : {
      45          14 :     qRegisterMetaType< WindowSettings >( "WindowSettings" );
      46          14 :     QCoreApplication* app = QApplication::instance();
      47          14 :     if( !app )
      48          28 :         return;
      49             : 
      50           0 :     _factory->moveToThread( app->thread( ));
      51             :     app->connect( this, SIGNAL( createImpl( const eq::Pipe*,
      52             :                                             const WindowSettings&, QThread* )),
      53             :                   _factory, SLOT( onCreateImpl( const eq::Pipe*,
      54             :                                                 const WindowSettings&,
      55             :                                                 QThread* )),
      56           0 :                   Qt::BlockingQueuedConnection );
      57             : }
      58             : 
      59          28 : WindowSystem::~WindowSystem()
      60             : {
      61          14 :     delete _factory;
      62          14 : }
      63             : 
      64          92 : std::string WindowSystem::getName() const
      65          92 :     { return QApplication::instance() ? "Qt" : ""; }
      66             : 
      67           0 : eq::SystemWindow* WindowSystem::createWindow( eq::Window* window,
      68             :                                               const WindowSettings& settings )
      69             : {
      70           0 :     LBDEBUG << "Using qt::Window" << std::endl;
      71             : 
      72             :     // QWindow creation/destruction must happen in the app thread; unblock main
      73             :     // thread to give QApplication the chance to process the createImpl signal.
      74             :     // Note that even a QOffscreenSurface is backed by a QWindow on some
      75             :     // platforms.
      76           0 :     window->getClient()->interruptMainThread();
      77           0 :     qt::detail::Window* impl = createImpl( window->getPipe(), settings,
      78           0 :                                            QThread::currentThread( ));
      79           0 :     Window* qtWindow = new Window( *window, settings, impl );
      80             :     qtWindow->connect( qtWindow, SIGNAL( destroyImpl( detail::Window* )),
      81           0 :                       _factory, SLOT( onDestroyImpl( detail::Window* )));
      82           0 :     return qtWindow;
      83             : }
      84             : 
      85           0 : eq::SystemPipe* WindowSystem::createPipe( eq::Pipe* pipe )
      86             : {
      87           0 :     return new Pipe( pipe );
      88             : }
      89             : 
      90           0 : eq::MessagePump* WindowSystem::createMessagePump()
      91             : {
      92           0 :     return new MessagePump;
      93             : }
      94             : 
      95           0 : bool WindowSystem::setupFont( util::ObjectManager& gl LB_UNUSED,
      96             :                               const void* key LB_UNUSED,
      97             :                               const std::string& name LB_UNUSED,
      98             :                               const uint32_t size LB_UNUSED ) const
      99             : {
     100           0 :     return false;
     101             : }
     102             : 
     103          14 : static WindowSystem _instance;
     104             : 
     105             : }
     106          42 : }

Generated by: LCOV version 1.11