1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_WIN_SALTIMER_H
21 #define INCLUDED_VCL_INC_WIN_SALTIMER_H
23 #include <saltimer.hxx>
25 class WinSalTimer final
: public SalTimer
, protected VersionedEvent
27 // for access to Impl* functions
28 friend LRESULT CALLBACK
SalComWndProc( HWND
, UINT nMsg
, WPARAM wParam
, LPARAM lParam
, bool& rDef
);
29 // for access to GetNextVersionedEvent
30 friend void CALLBACK
SalTimerProc( PVOID data
, BOOLEAN
);
31 // for access to ImplHandleElapsedTimer
32 friend bool ImplSalYield( bool bWait
, bool bHandleAllCurrentEvents
);
35 * Identifier for our SetTimer based timer
37 static constexpr UINT_PTR m_aWmTimerId
= 0xdeadbeef;
39 HANDLE m_nTimerId
; ///< Windows timer id
40 bool m_bDirectTimeout
; ///< timeout can be processed directly
41 bool m_bForceRealTimer
; ///< enforce using a real timer for 0ms
42 bool m_bSetTimerRunning
; ///< true, if a SetTimer is running
44 void ImplStart( sal_uInt64 nMS
);
46 void ImplHandleTimerEvent( WPARAM aWPARAM
);
47 void ImplHandleElapsedTimer();
48 void ImplHandle_WM_TIMER( WPARAM aWPARAM
);
52 virtual ~WinSalTimer() override
;
54 virtual void Start(sal_uInt64 nMS
) override
;
55 virtual void Stop() override
;
57 inline bool IsDirectTimeout() const;
58 inline bool HasTimerElapsed() const;
61 * Enforces the usage of a real timer instead of the message queue
63 * Needed for Window resize processing, as this starts a modal event loop.
65 void SetForceRealTimer( bool bVal
);
66 inline bool GetForceRealTimer() const;
69 inline bool WinSalTimer::IsDirectTimeout() const
71 return m_bDirectTimeout
;
74 inline bool WinSalTimer::HasTimerElapsed() const
76 return m_bDirectTimeout
|| ExistsValidEvent();
79 inline bool WinSalTimer::GetForceRealTimer() const
81 return m_bForceRealTimer
;
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */