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 .
21 #include "tools/IdleDetection.hxx"
23 #include "ViewShell.hxx"
24 #include "slideshow.hxx"
25 #include "ViewShellBase.hxx"
27 #include <vcl/window.hxx>
28 #include <sfx2/viewfrm.hxx>
30 #include <com/sun/star/frame/XFrame.hpp>
31 #include <vcl/svapp.hxx>
33 using namespace ::com::sun::star
;
35 namespace sd
{ namespace tools
{
38 sal_Int32
IdleDetection::GetIdleState (const ::Window
* pWindow
)
40 sal_Int32
nResult (CheckInputPending() | CheckSlideShowRunning());
42 nResult
|= CheckWindowPainting(*pWindow
);
49 sal_Int32
IdleDetection::CheckInputPending (void)
51 if (GetpApp()->AnyInput(VCL_INPUT_MOUSE
| VCL_INPUT_KEYBOARD
| VCL_INPUT_PAINT
))
52 return IDET_SYSTEM_EVENT_PENDING
;
60 sal_Int32
IdleDetection::CheckSlideShowRunning (void)
62 sal_Int32
eResult (IDET_IDLE
);
64 bool bIsSlideShowShowing
= false;
66 // Iterate over all view frames.
67 SfxViewFrame
* pViewFrame
= SfxViewFrame::GetFirst();
68 for (pViewFrame
= SfxViewFrame::GetFirst();
69 pViewFrame
!=NULL
&& !bIsSlideShowShowing
;
70 pViewFrame
= SfxViewFrame::GetNext(*pViewFrame
))
72 // Ignore the current frame when it does not exist, is not valid, or
74 bool bIgnoreFrame (true);
75 uno::Reference
<frame::XFrame
> xFrame (pViewFrame
->GetFrame().GetFrameInterface());
78 if (xFrame
.is() && xFrame
->isActive())
81 catch (const uno::RuntimeException
&)
87 // Get sd::ViewShell from active frame.
88 ViewShellBase
* pBase
= ViewShellBase::GetViewShellBase(pViewFrame
);
91 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( *pBase
) );
92 if( xSlideShow
.is() && xSlideShow
->isRunning() )
94 if (xSlideShow
->isFullScreen())
95 eResult
|= IDET_FULL_SCREEN_SHOW_ACTIVE
;
97 eResult
|= IDET_WINDOW_SHOW_ACTIVE
;
108 sal_Int32
IdleDetection::CheckWindowPainting (const ::Window
& rWindow
)
110 if (rWindow
.IsInPaint())
111 return IDET_WINDOW_PAINTING
;
116 } } // end of namespace ::sd::tools
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */