LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/vcl/generic/app - gendisp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 68 1.5 %
Date: 2013-07-09 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             : 
      25           0 : SalGenericDisplay::SalGenericDisplay()
      26             : {
      27           0 :     m_pCapture = NULL;
      28           0 :     m_aEventGuard = osl_createMutex();
      29           0 : }
      30             : 
      31           0 : SalGenericDisplay::~SalGenericDisplay()
      32             : {
      33           0 :     if (m_aEventGuard)
      34           0 :         osl_destroyMutex( m_aEventGuard );
      35           0 :     m_aEventGuard = NULL;
      36           0 : }
      37             : 
      38           0 : void SalGenericDisplay::registerFrame( SalFrame* pFrame )
      39             : {
      40           0 :     m_aFrames.push_front( pFrame );
      41           0 : }
      42             : 
      43           0 : void SalGenericDisplay::deregisterFrame( SalFrame* pFrame )
      44             : {
      45           0 :     if( osl_acquireMutex( m_aEventGuard ) )
      46             :     {
      47           0 :         std::list< SalUserEvent >::iterator it = m_aUserEvents.begin();
      48           0 :         while ( it != m_aUserEvents.end() )
      49             :         {
      50           0 :             if( it->m_pFrame == pFrame )
      51           0 :                 it = m_aUserEvents.erase( it );
      52             :             else
      53           0 :                 ++it;
      54             :         }
      55           0 :         osl_releaseMutex( m_aEventGuard );
      56             :     }
      57             :     else
      58             :         OSL_FAIL( "SalGenericDisplay::deregisterFrame !acquireMutex\n" );
      59             : 
      60           0 :     m_aFrames.remove( pFrame );
      61           0 : }
      62             : 
      63           0 : void SalGenericDisplay::emitDisplayChanged()
      64             : {
      65           0 :     if( !m_aFrames.empty() )
      66           0 :         m_aFrames.front()->CallCallback( SALEVENT_DISPLAYCHANGED, 0 );
      67           0 : }
      68             : 
      69           0 : bool SalGenericDisplay::DispatchInternalEvent()
      70             : {
      71           0 :     void* pData = NULL;
      72           0 :     SalFrame* pFrame = NULL;
      73           0 :     sal_uInt16 nEvent = 0;
      74             : 
      75           0 :     if( osl_acquireMutex( m_aEventGuard ) )
      76             :     {
      77           0 :         if( m_aUserEvents.begin() != m_aUserEvents.end() )
      78             :         {
      79           0 :             pFrame      = m_aUserEvents.front().m_pFrame;
      80           0 :             pData       = m_aUserEvents.front().m_pData;
      81           0 :             nEvent      = m_aUserEvents.front().m_nEvent;
      82             : 
      83           0 :             m_aUserEvents.pop_front();
      84             :         }
      85           0 :         osl_releaseMutex( m_aEventGuard );
      86             :     }
      87             :     else
      88             :         OSL_FAIL( "SalGenericDisplay::Yield !acquireMutex\n" );
      89             : 
      90           0 :     if( pFrame )
      91           0 :         pFrame->CallCallback( nEvent, pData );
      92             : 
      93           0 :     return pFrame != NULL;
      94             : }
      95             : 
      96           0 : void SalGenericDisplay::SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
      97             : {
      98           0 :     if( osl_acquireMutex( m_aEventGuard ) )
      99             :     {
     100           0 :         m_aUserEvents.push_back( SalUserEvent( pFrame, pData, nEvent ) );
     101             : 
     102           0 :         PostUserEvent(); // wakeup the concrete mainloop
     103             : 
     104           0 :         osl_releaseMutex( m_aEventGuard );
     105             :     }
     106             :     else
     107             :         OSL_FAIL( "SalGenericDisplay::SendInternalEvent !acquireMutex\n" );
     108           0 : }
     109             : 
     110           0 : void SalGenericDisplay::CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
     111             : {
     112           0 :     if( osl_acquireMutex( m_aEventGuard ) )
     113             :     {
     114           0 :         if( ! m_aUserEvents.empty() )
     115             :         {
     116           0 :             std::list< SalUserEvent >::iterator it, next;
     117           0 :             next = m_aUserEvents.begin();
     118           0 :             do
     119             :             {
     120           0 :                 it = next++;
     121           0 :                 if( it->m_pFrame    == pFrame   &&
     122           0 :                     it->m_pData     == pData    &&
     123           0 :                     it->m_nEvent    == nEvent )
     124             :                 {
     125           0 :                     m_aUserEvents.erase( it );
     126             :                 }
     127           0 :             } while( next != m_aUserEvents.end() );
     128             :         }
     129             : 
     130           0 :         osl_releaseMutex( m_aEventGuard );
     131             :     }
     132             :     else
     133             :         OSL_FAIL( "SalGenericDisplay::CancelInternalEvent !acquireMutex\n" );
     134           0 : }
     135             : 
     136           0 : bool SalGenericDisplay::HasUserEvents() const
     137             : {
     138           0 :     bool bRet = false;
     139           0 :     if( osl_acquireMutex( m_aEventGuard ) )
     140             :     {
     141           0 :         if( m_aUserEvents.begin() != m_aUserEvents.end() )
     142           0 :             bRet = true;
     143           0 :         osl_releaseMutex( m_aEventGuard );
     144             :     }
     145           0 :     return bRet;
     146         465 : }
     147             : 
     148             : 
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10