bump product version to 7.2.5.1
[LibreOffice.git] / vcl / inc / salusereventlist.hxx
blobcc5aa88c930c7a3c1ad7f10895bcf8687549e82f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_SALUSEREVENTLIST_HXX
21 #define INCLUDED_VCL_INC_SALUSEREVENTLIST_HXX
23 #include <sal/config.h>
24 #include <vcl/dllapi.h>
25 #include <osl/mutex.hxx>
26 #include <osl/thread.hxx>
28 #include <list>
29 #include <o3tl/sorted_vector.hxx>
31 class SalFrame;
32 enum class SalEvent;
34 typedef o3tl::sorted_vector< SalFrame* > SalFrameSet;
36 class VCL_PLUGIN_PUBLIC SalUserEventList
38 public:
39 struct SalUserEvent
41 SalFrame* m_pFrame;
42 void* m_pData;
43 SalEvent m_nEvent;
45 SalUserEvent( SalFrame* pFrame, void* pData, SalEvent nEvent )
46 : m_pFrame( pFrame ),
47 m_pData( pData ),
48 m_nEvent( nEvent )
51 bool operator==(const SalUserEvent &aEvent) const
53 return m_pFrame == aEvent.m_pFrame
54 && m_pData == aEvent.m_pData
55 && m_nEvent== aEvent.m_nEvent;
59 protected:
60 mutable osl::Mutex m_aUserEventsMutex;
61 std::list< SalUserEvent > m_aUserEvents;
62 std::list< SalUserEvent > m_aProcessingUserEvents;
63 bool m_bAllUserEventProcessedSignaled;
64 SalFrameSet m_aFrames;
65 oslThreadIdentifier m_aProcessingThread;
67 virtual void ProcessEvent( SalUserEvent aEvent ) = 0;
68 virtual void TriggerUserEventProcessing() = 0;
69 virtual void TriggerAllUserEventsProcessed() {}
71 public:
72 SalUserEventList();
73 virtual ~SalUserEventList() COVERITY_NOEXCEPT_FALSE;
75 inline const SalFrameSet& getFrames() const;
76 inline SalFrame* anyFrame() const;
77 void insertFrame( SalFrame* pFrame );
78 void eraseFrame( SalFrame* pFrame );
79 inline bool isFrameAlive( const SalFrame* pFrame ) const;
81 void PostEvent( SalFrame* pFrame, void* pData, SalEvent nEvent );
82 void RemoveEvent( SalFrame* pFrame, void* pData, SalEvent nEvent );
83 inline bool HasUserEvents() const;
85 bool DispatchUserEvents( bool bHandleAllCurrentEvents );
88 inline SalFrame* SalUserEventList::anyFrame() const
90 if ( m_aFrames.empty() )
91 return nullptr;
92 return *m_aFrames.begin();
95 inline bool SalUserEventList::isFrameAlive( const SalFrame* pFrame ) const
97 auto it = m_aFrames.find( const_cast<SalFrame*>( pFrame ) );
98 return it != m_aFrames.end();
101 inline bool SalUserEventList::HasUserEvents() const
103 osl::MutexGuard aGuard( m_aUserEventsMutex );
104 return !(m_aUserEvents.empty() && m_aProcessingUserEvents.empty());
107 inline void SalUserEventList::PostEvent( SalFrame* pFrame, void* pData, SalEvent nEvent )
109 osl::MutexGuard aGuard( m_aUserEventsMutex );
110 m_aUserEvents.push_back( SalUserEvent( pFrame, pData, nEvent ) );
111 m_bAllUserEventProcessedSignaled = false;
112 TriggerUserEventProcessing();
115 inline const SalFrameSet& SalUserEventList::getFrames() const
117 return m_aFrames;
120 #endif // INCLUDED_VCL_INC_SALUSEREVENTLIST_HXX
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */