1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SD_IDLE_DETECTION_HXX
25 #define SD_IDLE_DETECTION_HXX
26 
27 #include <sal/types.h>
28 
29 class Window;
30 
31 namespace sd { namespace tools {
32 
33 /** Detect whether the system is idle and some time consuming operation may
34     be carried out.  This class ditinguishes between different states of
35     idle-ness.
36 */
37 class IdleDetection
38 {
39 public:
40     /** When GetIdleState() returns this value, then the system is idle.
41     */
42     static const sal_Int32 IDET_IDLE = 0x0000;
43 
44     /** There are system event pending.
45     */
46     static const sal_Int32 IDET_SYSTEM_EVENT_PENDING = 0x0001;
47 
48     /** A full screen slide show is running and is active.  In contrast
49         there may be a full screen show be running in an inactive window,
50         i.e. in the background.
51     */
52     static const sal_Int32 IDET_FULL_SCREEN_SHOW_ACTIVE = 0x0002;
53 
54     /** A slide show is running in a window.
55     */
56     static const sal_Int32 IDET_WINDOW_SHOW_ACTIVE = 0x0004;
57 
58     /** A window is being painted.
59     */
60     static const sal_Int32 IDET_WINDOW_PAINTING = 0x0008;
61 
62     /** Determine whether the system is idle.
63         @param pWindow
64             When a valid Window pointer is given then it is checked
65             whether the window is currently being painting.
66         @return
67             This method either returns IDET_IDLE or a combination of
68             IdleStates values or-ed together that describe what the system
69             is currently doing so that the caller can decide what to do.
70     */
71     static sal_Int32 GetIdleState (const ::Window* pWindow = NULL);
72 
73 private:
74     /** Check whether there are input events pending.
75     */
76     static sal_Int32 CheckInputPending (void);
77 
78     /** Check whether a slide show is running full screen or in a window.
79     */
80     static sal_Int32 CheckSlideShowRunning (void);
81 
82     static sal_Int32 CheckWindowPainting (const ::Window& rWindow);
83 };
84 
85 } } // end of namespace ::sd::tools
86 
87 #endif
88