cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / tools / IdleDetection.hxx
blobdecf5ff2626bad8fc1e5cbb312efb961b14847dc
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 #pragma once
22 #include <o3tl/typed_flags_set.hxx>
24 namespace vcl { class Window; }
26 namespace sd::tools {
27 enum class IdleState {
28 /** When GetIdleState() returns this value, then the system is idle.
30 Idle = 0x0000,
32 /** There are system event pending.
34 SystemEventPending = 0x0001,
36 /** A full screen slide show is running and is active. In contrast
37 there may be a full screen show be running in an inactive window,
38 i.e. in the background.
40 FullScreenShowActive = 0x0002,
42 /** A slide show is running in a window.
44 WindowShowActive = 0x0004,
46 /** A window is being painted.
48 WindowPainting = 0x0008,
50 } // end of namespace ::sd::tools
51 namespace o3tl {
52 template<> struct typed_flags<::sd::tools::IdleState> : is_typed_flags<::sd::tools::IdleState, 0x0f> {};
55 namespace sd::tools {
57 /** Detect whether the system is idle and some time consuming operation may
58 be carried out. This class distinguishes between different states of
59 idle-ness.
61 class IdleDetection
63 public:
64 /** Determine whether the system is idle.
65 @param pWindow
66 When a valid Window pointer is given then it is checked
67 whether the window is currently being painting.
68 @return
69 This method either returns IdleState::Idle or a combination of
70 IdleStates values or-ed together that describe what the system
71 is currently doing so that the caller can decide what to do.
73 static IdleState GetIdleState (const vcl::Window* pWindow);
75 private:
76 /** Check whether there are input events pending.
78 static IdleState CheckInputPending();
80 /** Check whether a slide show is running full screen or in a window.
82 static IdleState CheckSlideShowRunning();
84 static IdleState CheckWindowPainting (const vcl::Window& rWindow);
87 } // end of namespace ::sd::tools
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */