LCOV - code coverage report
Current view: top level - vcl/generic/app - gendisp.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 27 66 40.9 %
Date: 2015-06-13 12:38:46 Functions: 7 12 58.3 %
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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <salframe.hxx>
      21             : #include <generic/gendisp.hxx>
      22             : #include <generic/geninst.h>
      23             : 
      24           3 : SalGenericDisplay::SalGenericDisplay()
      25             : {
      26           3 :     m_pCapture = NULL;
      27           3 :     m_aEventGuard = osl_createMutex();
      28           3 : }
      29             : 
      30           0 : SalGenericDisplay::~SalGenericDisplay()
      31             : {
      32           0 :     if (m_aEventGuard)
      33           0 :         osl_destroyMutex( m_aEventGuard );
      34           0 :     m_aEventGuard = NULL;
      35           0 : }
      36             : 
      37          16 : void SalGenericDisplay::registerFrame( SalFrame* pFrame )
      38             : {
      39          16 :     m_aFrames.push_front( pFrame );
      40          16 : }
      41             : 
      42          13 : void SalGenericDisplay::deregisterFrame( SalFrame* pFrame )
      43             : {
      44          13 :     if( osl_acquireMutex( m_aEventGuard ) )
      45             :     {
      46          13 :         std::list< SalUserEvent >::iterator it = m_aUserEvents.begin();
      47         220 :         while ( it != m_aUserEvents.end() )
      48             :         {
      49         194 :             if( it->m_pFrame == pFrame )
      50          33 :                 it = m_aUserEvents.erase( it );
      51             :             else
      52         161 :                 ++it;
      53             :         }
      54          13 :         osl_releaseMutex( m_aEventGuard );
      55             :     }
      56             :     else
      57             :         OSL_FAIL( "SalGenericDisplay::deregisterFrame !acquireMutex\n" );
      58             : 
      59          13 :     m_aFrames.remove( pFrame );
      60          13 : }
      61             : 
      62           6 : void SalGenericDisplay::emitDisplayChanged()
      63             : {
      64           6 :     if( !m_aFrames.empty() )
      65           0 :         m_aFrames.front()->CallCallback( SALEVENT_DISPLAYCHANGED, 0 );
      66           6 : }
      67             : 
      68           0 : bool SalGenericDisplay::DispatchInternalEvent()
      69             : {
      70           0 :     void* pData = NULL;
      71           0 :     SalFrame* pFrame = NULL;
      72           0 :     sal_uInt16 nEvent = 0;
      73             : 
      74           0 :     if( osl_acquireMutex( m_aEventGuard ) )
      75             :     {
      76           0 :         if( m_aUserEvents.begin() != m_aUserEvents.end() )
      77             :         {
      78           0 :             pFrame      = m_aUserEvents.front().m_pFrame;
      79           0 :             pData       = m_aUserEvents.front().m_pData;
      80           0 :             nEvent      = m_aUserEvents.front().m_nEvent;
      81             : 
      82           0 :             m_aUserEvents.pop_front();
      83             :         }
      84           0 :         osl_releaseMutex( m_aEventGuard );
      85             :     }
      86             :     else
      87             :         OSL_FAIL( "SalGenericDisplay::Yield !acquireMutex\n" );
      88             : 
      89           0 :     if( pFrame )
      90           0 :         pFrame->CallCallback( nEvent, pData );
      91             : 
      92           0 :     return pFrame != NULL;
      93             : }
      94             : 
      95          58 : void SalGenericDisplay::SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
      96             : {
      97          58 :     if( osl_acquireMutex( m_aEventGuard ) )
      98             :     {
      99          58 :         m_aUserEvents.push_back( SalUserEvent( pFrame, pData, nEvent ) );
     100             : 
     101          58 :         PostUserEvent(); // wakeup the concrete mainloop
     102             : 
     103          58 :         osl_releaseMutex( m_aEventGuard );
     104             :     }
     105             :     else
     106             :         OSL_FAIL( "SalGenericDisplay::SendInternalEvent !acquireMutex\n" );
     107          58 : }
     108             : 
     109           0 : void SalGenericDisplay::CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
     110             : {
     111           0 :     if( osl_acquireMutex( m_aEventGuard ) )
     112             :     {
     113           0 :         if( ! m_aUserEvents.empty() )
     114             :         {
     115           0 :             std::list< SalUserEvent >::iterator it = m_aUserEvents.begin();
     116           0 :             while (it != m_aUserEvents.end())
     117             :             {
     118           0 :                 if( it->m_pFrame    == pFrame   &&
     119           0 :                     it->m_pData     == pData    &&
     120           0 :                     it->m_nEvent    == nEvent )
     121             :                 {
     122           0 :                     it = m_aUserEvents.erase( it );
     123             :                 }
     124             :                 else
     125           0 :                     ++it;
     126             :             }
     127             :         }
     128             : 
     129           0 :         osl_releaseMutex( m_aEventGuard );
     130             :     }
     131             :     else
     132             :         OSL_FAIL( "SalGenericDisplay::CancelInternalEvent !acquireMutex\n" );
     133           0 : }
     134             : 
     135           0 : bool SalGenericDisplay::HasUserEvents() const
     136             : {
     137           0 :     bool bRet = false;
     138           0 :     if( osl_acquireMutex( m_aEventGuard ) )
     139             :     {
     140           0 :         if( m_aUserEvents.begin() != m_aUserEvents.end() )
     141           0 :             bRet = true;
     142           0 :         osl_releaseMutex( m_aEventGuard );
     143             :     }
     144           0 :     return bRet;
     145         801 : }
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11