1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove 25*b1cdbd2cSJim Jagielski #include "precompiled_sd.hxx" 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include "tools/IdleDetection.hxx" 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski #include "ViewShell.hxx" 30*b1cdbd2cSJim Jagielski #include "slideshow.hxx" 31*b1cdbd2cSJim Jagielski #include "ViewShellBase.hxx" 32*b1cdbd2cSJim Jagielski 33*b1cdbd2cSJim Jagielski #include <vcl/window.hxx> 34*b1cdbd2cSJim Jagielski #include <sfx2/viewfrm.hxx> 35*b1cdbd2cSJim Jagielski 36*b1cdbd2cSJim Jagielski #include <com/sun/star/frame/XFrame.hdl> 37*b1cdbd2cSJim Jagielski #include <vcl/svapp.hxx> 38*b1cdbd2cSJim Jagielski 39*b1cdbd2cSJim Jagielski using namespace ::com::sun::star; 40*b1cdbd2cSJim Jagielski 41*b1cdbd2cSJim Jagielski namespace sd { namespace tools { 42*b1cdbd2cSJim Jagielski 43*b1cdbd2cSJim Jagielski GetIdleState(const::Window * pWindow)44*b1cdbd2cSJim Jagielskisal_Int32 IdleDetection::GetIdleState (const ::Window* pWindow) 45*b1cdbd2cSJim Jagielski { 46*b1cdbd2cSJim Jagielski sal_Int32 nResult (CheckInputPending() | CheckSlideShowRunning()); 47*b1cdbd2cSJim Jagielski if (pWindow != NULL) 48*b1cdbd2cSJim Jagielski nResult |= CheckWindowPainting(*pWindow); 49*b1cdbd2cSJim Jagielski return nResult; 50*b1cdbd2cSJim Jagielski } 51*b1cdbd2cSJim Jagielski 52*b1cdbd2cSJim Jagielski 53*b1cdbd2cSJim Jagielski 54*b1cdbd2cSJim Jagielski CheckInputPending(void)55*b1cdbd2cSJim Jagielskisal_Int32 IdleDetection::CheckInputPending (void) 56*b1cdbd2cSJim Jagielski { 57*b1cdbd2cSJim Jagielski if (GetpApp()->AnyInput(INPUT_MOUSE | INPUT_KEYBOARD | INPUT_PAINT)) 58*b1cdbd2cSJim Jagielski return IDET_SYSTEM_EVENT_PENDING; 59*b1cdbd2cSJim Jagielski else 60*b1cdbd2cSJim Jagielski return IDET_IDLE; 61*b1cdbd2cSJim Jagielski } 62*b1cdbd2cSJim Jagielski 63*b1cdbd2cSJim Jagielski 64*b1cdbd2cSJim Jagielski 65*b1cdbd2cSJim Jagielski CheckSlideShowRunning(void)66*b1cdbd2cSJim Jagielskisal_Int32 IdleDetection::CheckSlideShowRunning (void) 67*b1cdbd2cSJim Jagielski { 68*b1cdbd2cSJim Jagielski sal_Int32 eResult (IDET_IDLE); 69*b1cdbd2cSJim Jagielski 70*b1cdbd2cSJim Jagielski bool bIsSlideShowShowing = false; 71*b1cdbd2cSJim Jagielski 72*b1cdbd2cSJim Jagielski // Iterate over all view frames. 73*b1cdbd2cSJim Jagielski SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(); 74*b1cdbd2cSJim Jagielski for (pViewFrame = SfxViewFrame::GetFirst(); 75*b1cdbd2cSJim Jagielski pViewFrame!=NULL && !bIsSlideShowShowing; 76*b1cdbd2cSJim Jagielski pViewFrame = SfxViewFrame::GetNext(*pViewFrame)) 77*b1cdbd2cSJim Jagielski { 78*b1cdbd2cSJim Jagielski // Ignore the current frame when it does not exist, is not valid, or 79*b1cdbd2cSJim Jagielski // is not active. 80*b1cdbd2cSJim Jagielski bool bIgnoreFrame (true); 81*b1cdbd2cSJim Jagielski uno::Reference<frame::XFrame> xFrame (pViewFrame->GetFrame().GetFrameInterface()); 82*b1cdbd2cSJim Jagielski try 83*b1cdbd2cSJim Jagielski { 84*b1cdbd2cSJim Jagielski if (xFrame.is() && xFrame->isActive()) 85*b1cdbd2cSJim Jagielski bIgnoreFrame = false; 86*b1cdbd2cSJim Jagielski } 87*b1cdbd2cSJim Jagielski catch (uno::RuntimeException e) 88*b1cdbd2cSJim Jagielski { 89*b1cdbd2cSJim Jagielski (void) e; 90*b1cdbd2cSJim Jagielski } 91*b1cdbd2cSJim Jagielski if (bIgnoreFrame) 92*b1cdbd2cSJim Jagielski continue; 93*b1cdbd2cSJim Jagielski 94*b1cdbd2cSJim Jagielski // Get sd::ViewShell from active frame. 95*b1cdbd2cSJim Jagielski ViewShellBase* pBase = ViewShellBase::GetViewShellBase(pViewFrame); 96*b1cdbd2cSJim Jagielski if (pBase != NULL) 97*b1cdbd2cSJim Jagielski { 98*b1cdbd2cSJim Jagielski rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pBase ) ); 99*b1cdbd2cSJim Jagielski if( xSlideShow.is() && xSlideShow->isRunning() ) 100*b1cdbd2cSJim Jagielski { 101*b1cdbd2cSJim Jagielski if (xSlideShow->isFullScreen()) 102*b1cdbd2cSJim Jagielski eResult |= IDET_FULL_SCREEN_SHOW_ACTIVE; 103*b1cdbd2cSJim Jagielski else 104*b1cdbd2cSJim Jagielski eResult |= IDET_WINDOW_SHOW_ACTIVE; 105*b1cdbd2cSJim Jagielski } 106*b1cdbd2cSJim Jagielski } 107*b1cdbd2cSJim Jagielski } 108*b1cdbd2cSJim Jagielski 109*b1cdbd2cSJim Jagielski return eResult; 110*b1cdbd2cSJim Jagielski } 111*b1cdbd2cSJim Jagielski 112*b1cdbd2cSJim Jagielski 113*b1cdbd2cSJim Jagielski 114*b1cdbd2cSJim Jagielski CheckWindowPainting(const::Window & rWindow)115*b1cdbd2cSJim Jagielskisal_Int32 IdleDetection::CheckWindowPainting (const ::Window& rWindow) 116*b1cdbd2cSJim Jagielski { 117*b1cdbd2cSJim Jagielski if (rWindow.IsInPaint()) 118*b1cdbd2cSJim Jagielski return IDET_WINDOW_PAINTING; 119*b1cdbd2cSJim Jagielski else 120*b1cdbd2cSJim Jagielski return IDET_IDLE; 121*b1cdbd2cSJim Jagielski } 122*b1cdbd2cSJim Jagielski 123*b1cdbd2cSJim Jagielski } } // end of namespace ::sd::tools 124