LCOV - code coverage report
Current view: top level - vcl/generic/app - gendisp.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 66 1.5 %
Date: 2014-11-03 Functions: 2 12 16.7 %
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           0 : SalGenericDisplay::SalGenericDisplay()
      25             : {
      26           0 :     m_pCapture = NULL;
      27           0 :     m_aEventGuard = osl_createMutex();
      28           0 : }
      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           0 : void SalGenericDisplay::registerFrame( SalFrame* pFrame )
      38             : {
      39           0 :     m_aFrames.push_front( pFrame );
      40           0 : }
      41             : 
      42           0 : void SalGenericDisplay::deregisterFrame( SalFrame* pFrame )
      43             : {
      44           0 :     if( osl_acquireMutex( m_aEventGuard ) )
      45             :     {
      46           0 :         std::list< SalUserEvent >::iterator it = m_aUserEvents.begin();
      47           0 :         while ( it != m_aUserEvents.end() )
      48             :         {
      49           0 :             if( it->m_pFrame == pFrame )
      50           0 :                 it = m_aUserEvents.erase( it );
      51             :             else
      52           0 :                 ++it;
      53             :         }
      54           0 :         osl_releaseMutex( m_aEventGuard );
      55             :     }
      56             :     else
      57             :         OSL_FAIL( "SalGenericDisplay::deregisterFrame !acquireMutex\n" );
      58             : 
      59           0 :     m_aFrames.remove( pFrame );
      60           0 : }
      61             : 
      62           0 : void SalGenericDisplay::emitDisplayChanged()
      63             : {
      64           0 :     if( !m_aFrames.empty() )
      65           0 :         m_aFrames.front()->CallCallback( SALEVENT_DISPLAYCHANGED, 0 );
      66           0 : }
      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           0 : void SalGenericDisplay::SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
      96             : {
      97           0 :     if( osl_acquireMutex( m_aEventGuard ) )
      98             :     {
      99           0 :         m_aUserEvents.push_back( SalUserEvent( pFrame, pData, nEvent ) );
     100             : 
     101           0 :         PostUserEvent(); // wakeup the concrete mainloop
     102             : 
     103           0 :         osl_releaseMutex( m_aEventGuard );
     104             :     }
     105             :     else
     106             :         OSL_FAIL( "SalGenericDisplay::SendInternalEvent !acquireMutex\n" );
     107           0 : }
     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        1233 : }
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10