LCOV - code coverage report
Current view: top level - eq/x11 - window.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 1 58 1.7 %
Date: 2016-07-30 05:04:55 Functions: 2 9 22.2 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-2015, Stefan.Eilemann@epfl.ch
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #include "window.h"
      19             : #include <eq/system.h>
      20             : #include <eq/fabric/drawableConfig.h>
      21             : #include <co/objectOCommand.h>
      22             : 
      23             : namespace eq
      24             : {
      25             : namespace x11
      26             : {
      27             : 
      28           0 : Window::Window( NotifierInterface& parent, const WindowSettings& settings,
      29             :                 Display* xDisplay )
      30             :     : SystemWindow( parent, settings )
      31             :     , _xDisplay( xDisplay )
      32           0 :     , _xDrawable( 0 )
      33             : {
      34           0 : }
      35             : 
      36           0 : Display* Window::getXDisplay()
      37             : {
      38           0 :     return _xDisplay;
      39             : }
      40             : 
      41           0 : bool Window::configInit()
      42             : {
      43           0 :     if( !_xDisplay )
      44             :     {
      45           0 :         sendError( ERROR_GLXWINDOW_NO_DISPLAY );
      46           0 :         return false;
      47             :     }
      48             : 
      49           0 :     if( getIAttribute( WindowSettings::IATTR_HINT_FULLSCREEN ) == ON )
      50             :     {
      51           0 :         const int screen = DefaultScreen( _xDisplay );
      52             :         setPixelViewport(
      53           0 :             PixelViewport( 0, 0, DisplayWidth( _xDisplay, screen ),
      54           0 :                            DisplayHeight( _xDisplay, screen )));
      55             :     }
      56             : 
      57           0 :     XID drawable = _createWindow();
      58           0 :     if( !drawable )
      59           0 :         return false;
      60             : 
      61             :     // Grab keyboard focus in fullscreen mode
      62           0 :     if( getIAttribute( WindowSettings::IATTR_HINT_FULLSCREEN ) == ON )
      63             :         XGrabKeyboard( _xDisplay, drawable, True, GrabModeAsync, GrabModeAsync,
      64           0 :                        CurrentTime );
      65             : 
      66           0 :     setXDrawable( drawable );
      67           0 :     return true;
      68             : }
      69             : 
      70           0 : XID Window::_createWindow()
      71             : {
      72           0 :     if( !_xDisplay )
      73             :     {
      74           0 :         sendError( ERROR_GLXWINDOW_NO_DISPLAY );
      75           0 :         return false;
      76             :     }
      77             : 
      78           0 :     const int screen = DefaultScreen( _xDisplay );
      79           0 :     XID parent = RootWindow( _xDisplay, screen );
      80           0 :     const PixelViewport& pvp = getPixelViewport();
      81             :     XID drawable = XCreateSimpleWindow( _xDisplay,
      82             :                                         parent,
      83             :                                         pvp.x, pvp.y, pvp.w, pvp.h, 1,
      84           0 :                                         BlackPixel( _xDisplay, screen ),
      85           0 :                                         WhitePixel( _xDisplay, screen ));
      86           0 :     if ( !drawable )
      87             :     {
      88           0 :         sendError( ERROR_GLXWINDOW_CREATECONTEXT_FAILED );
      89           0 :         return 0;
      90             :     }
      91             : 
      92           0 :     XSelectInput( _xDisplay, drawable, ExposureMask | KeyPressMask );
      93           0 :     XMapWindow( _xDisplay, drawable );
      94             : 
      95           0 :     std::stringstream windowTitle;
      96           0 :     windowTitle << "eqCpu Example";
      97           0 :     XStoreName( _xDisplay, drawable, windowTitle.str().c_str( ));
      98             : 
      99             :     // Register for close window request from the window manager
     100           0 :     Atom deleteAtom = XInternAtom( _xDisplay, "WM_DELETE_WINDOW", False );
     101           0 :     XSetWMProtocols( _xDisplay, drawable, &deleteAtom, 1 );
     102             : 
     103           0 :     XMoveResizeWindow( _xDisplay, drawable, pvp.x, pvp.y, pvp.w, pvp.h );
     104           0 :     XFlush( _xDisplay );
     105             : 
     106           0 :     return drawable;
     107             : }
     108             : 
     109           0 : void Window::configExit()
     110             : {
     111           0 :     if( _xDrawable )
     112           0 :         XDestroyWindow( _xDisplay, _xDrawable );
     113           0 :     setXDrawable( 0 );
     114           0 : }
     115             : 
     116           0 : void Window::queryDrawableConfig( DrawableConfig& drawableConfig )
     117             : {
     118           0 :     drawableConfig.stencilBits = 0;
     119           0 :     drawableConfig.alphaBits = 0;
     120           0 :     drawableConfig.glVersion = 0.f;
     121           0 :     drawableConfig.stereo = false;
     122           0 :     drawableConfig.doublebuffered = false;
     123           0 : }
     124             : 
     125           0 : void Window::flush()
     126             : {
     127           0 :     XFlush( _xDisplay );
     128           0 : }
     129             : 
     130             : }
     131          42 : }

Generated by: LCOV version 1.11