LibreOffice Module sd (master) 1
IdleDetection.cxx
Go to the documentation of this file.
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
21
22#include <slideshow.hxx>
23#include <ViewShellBase.hxx>
24
25#include <vcl/window.hxx>
26#include <sfx2/viewfrm.hxx>
27
28#include <com/sun/star/frame/XFrame.hpp>
29#include <vcl/svapp.hxx>
30
31using namespace ::com::sun::star;
32
33namespace sd::tools {
34
36{
38 if (pWindow != nullptr)
39 nResult |= CheckWindowPainting(*pWindow);
40 return nResult;
41}
42
44{
45 if (Application::AnyInput(VclInputFlags::MOUSE | VclInputFlags::KEYBOARD | VclInputFlags::PAINT))
47 else
48 return IdleState::Idle;
49}
50
52{
53 IdleState eResult (IdleState::Idle);
54
55 // Iterate over all view frames.
56 for (SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst();
57 pViewFrame!=nullptr;
58 pViewFrame = SfxViewFrame::GetNext(*pViewFrame))
59 {
60 // Ignore the current frame when it does not exist, is not valid, or
61 // is not active.
62 bool bIgnoreFrame (true);
63 uno::Reference<frame::XFrame> xFrame (pViewFrame->GetFrame().GetFrameInterface());
64 try
65 {
66 if (xFrame.is() && xFrame->isActive())
67 bIgnoreFrame = false;
68 }
69 catch (const uno::RuntimeException&)
70 {
71 }
72 if (bIgnoreFrame)
73 continue;
74
75 // Get sd::ViewShell from active frame.
77 if (pBase != nullptr)
78 {
80 if( xSlideShow.is() && xSlideShow->isRunning() )
81 {
82 if (xSlideShow->isFullScreen())
84 else
86 }
87 }
88 }
89
90 return eResult;
91}
92
94{
95 if (rWindow.IsInPaint())
97 else
98 return IdleState::Idle;
99}
100
101} // end of namespace ::sd::tools
102
103/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool AnyInput(VclInputFlags nType=VCL_INPUT_ANY)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static rtl::Reference< SlideShow > GetSlideShow(SdDrawDocument const *pDocument)
Definition: slideshow.cxx:157
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
static ViewShellBase * GetViewShellBase(SfxViewFrame const *pFrame)
When given a view frame this static method returns the corresponding sd::ViewShellBase object.
static IdleState CheckWindowPainting(const vcl::Window &rWindow)
static IdleState CheckSlideShowRunning()
Check whether a slide show is running full screen or in a window.
static IdleState CheckInputPending()
Check whether there are input events pending.
static IdleState GetIdleState(const vcl::Window *pWindow)
Determine whether the system is idle.
bool IsInPaint() const
@ FullScreenShowActive
A full screen slide show is running and is active.
@ WindowShowActive
A slide show is running in a window.
@ SystemEventPending
There are system event pending.
@ WindowPainting
A window is being painted.
@ Idle
When GetIdleState() returns this value, then the system is idle.
Reference< XFrame > xFrame