Kaydet (Commit) 4b1b17f4 authored tarafından Noel Grandin's avatar Noel Grandin

convert IDET flags to typed_flags

Change-Id: Iaaea3b3693ab4c67a60e48e7de8865413e8e246b
üst 7adac063
...@@ -21,9 +21,39 @@ ...@@ -21,9 +21,39 @@
#define INCLUDED_SD_SOURCE_UI_INC_TOOLS_IDLEDETECTION_HXX #define INCLUDED_SD_SOURCE_UI_INC_TOOLS_IDLEDETECTION_HXX
#include <sal/types.h> #include <sal/types.h>
#include <o3tl/typed_flags_set.hxx>
namespace vcl { class Window; } namespace vcl { class Window; }
namespace sd { namespace tools {
enum class IdleState {
/** When GetIdleState() returns this value, then the system is idle.
*/
Idle = 0x0000,
/** There are system event pending.
*/
SystemEventPending = 0x0001,
/** A full screen slide show is running and is active. In contrast
there may be a full screen show be running in an inactive window,
i.e. in the background.
*/
FullScreenShowActive = 0x0002,
/** A slide show is running in a window.
*/
WindowShowActive = 0x0004,
/** A window is being painted.
*/
WindowPainting = 0x0008,
};
} } // end of namespace ::sd::tools
namespace o3tl {
template<> struct typed_flags<::sd::tools::IdleState> : is_typed_flags<::sd::tools::IdleState, 0x0f> {};
}
namespace sd { namespace tools { namespace sd { namespace tools {
/** Detect whether the system is idle and some time consuming operation may /** Detect whether the system is idle and some time consuming operation may
...@@ -33,49 +63,27 @@ namespace sd { namespace tools { ...@@ -33,49 +63,27 @@ namespace sd { namespace tools {
class IdleDetection class IdleDetection
{ {
public: public:
/** When GetIdleState() returns this value, then the system is idle.
*/
static const sal_Int32 IDET_IDLE = 0x0000;
/** There are system event pending.
*/
static const sal_Int32 IDET_SYSTEM_EVENT_PENDING = 0x0001;
/** A full screen slide show is running and is active. In contrast
there may be a full screen show be running in an inactive window,
i.e. in the background.
*/
static const sal_Int32 IDET_FULL_SCREEN_SHOW_ACTIVE = 0x0002;
/** A slide show is running in a window.
*/
static const sal_Int32 IDET_WINDOW_SHOW_ACTIVE = 0x0004;
/** A window is being painted.
*/
static const sal_Int32 IDET_WINDOW_PAINTING = 0x0008;
/** Determine whether the system is idle. /** Determine whether the system is idle.
@param pWindow @param pWindow
When a valid Window pointer is given then it is checked When a valid Window pointer is given then it is checked
whether the window is currently being painting. whether the window is currently being painting.
@return @return
This method either returns IDET_IDLE or a combination of This method either returns IdleState::Idle or a combination of
IdleStates values or-ed together that describe what the system IdleStates values or-ed together that describe what the system
is currently doing so that the caller can decide what to do. is currently doing so that the caller can decide what to do.
*/ */
static sal_Int32 GetIdleState (const vcl::Window* pWindow); static IdleState GetIdleState (const vcl::Window* pWindow);
private: private:
/** Check whether there are input events pending. /** Check whether there are input events pending.
*/ */
static sal_Int32 CheckInputPending(); static IdleState CheckInputPending();
/** Check whether a slide show is running full screen or in a window. /** Check whether a slide show is running full screen or in a window.
*/ */
static sal_Int32 CheckSlideShowRunning(); static IdleState CheckSlideShowRunning();
static sal_Int32 CheckWindowPainting (const vcl::Window& rWindow); static IdleState CheckWindowPainting (const vcl::Window& rWindow);
}; };
} } // end of namespace ::sd::tools } } // end of namespace ::sd::tools
......
...@@ -187,10 +187,10 @@ IMPL_LINK(MasterPageContainerQueue, DelayedPreviewCreation, Timer*, pTimer, void ...@@ -187,10 +187,10 @@ IMPL_LINK(MasterPageContainerQueue, DelayedPreviewCreation, Timer*, pTimer, void
break; break;
// First check whether the system is idle. // First check whether the system is idle.
sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(nullptr)); tools::IdleState nIdleState (tools::IdleDetection::GetIdleState(nullptr));
if (nIdleState != tools::IdleDetection::IDET_IDLE) if (nIdleState != tools::IdleState::Idle)
{ {
if ((nIdleState&tools::IdleDetection::IDET_FULL_SCREEN_SHOW_ACTIVE) != 0) if (nIdleState & tools::IdleState::FullScreenShowActive)
bIsShowingFullScreenShow = true; bIsShowingFullScreenShow = true;
break; break;
} }
......
...@@ -65,8 +65,8 @@ void ViewCacheContext::NotifyPreviewCreation ( ...@@ -65,8 +65,8 @@ void ViewCacheContext::NotifyPreviewCreation (
bool ViewCacheContext::IsIdle() bool ViewCacheContext::IsIdle()
{ {
sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow())); tools::IdleState nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow()));
if (nIdleState == tools::IdleDetection::IDET_IDLE) if (nIdleState == tools::IdleState::Idle)
return true; return true;
else else
return false; return false;
......
...@@ -33,25 +33,25 @@ using namespace ::com::sun::star; ...@@ -33,25 +33,25 @@ using namespace ::com::sun::star;
namespace sd { namespace tools { namespace sd { namespace tools {
sal_Int32 IdleDetection::GetIdleState (const vcl::Window* pWindow) IdleState IdleDetection::GetIdleState (const vcl::Window* pWindow)
{ {
sal_Int32 nResult (CheckInputPending() | CheckSlideShowRunning()); IdleState nResult (CheckInputPending() | CheckSlideShowRunning());
if (pWindow != nullptr) if (pWindow != nullptr)
nResult |= CheckWindowPainting(*pWindow); nResult |= CheckWindowPainting(*pWindow);
return nResult; return nResult;
} }
sal_Int32 IdleDetection::CheckInputPending() IdleState IdleDetection::CheckInputPending()
{ {
if (Application::AnyInput(VclInputFlags::MOUSE | VclInputFlags::KEYBOARD | VclInputFlags::PAINT)) if (Application::AnyInput(VclInputFlags::MOUSE | VclInputFlags::KEYBOARD | VclInputFlags::PAINT))
return IDET_SYSTEM_EVENT_PENDING; return IdleState::SystemEventPending;
else else
return IDET_IDLE; return IdleState::Idle;
} }
sal_Int32 IdleDetection::CheckSlideShowRunning() IdleState IdleDetection::CheckSlideShowRunning()
{ {
sal_Int32 eResult (IDET_IDLE); IdleState eResult (IdleState::Idle);
bool bIsSlideShowShowing = false; bool bIsSlideShowShowing = false;
...@@ -83,9 +83,9 @@ sal_Int32 IdleDetection::CheckSlideShowRunning() ...@@ -83,9 +83,9 @@ sal_Int32 IdleDetection::CheckSlideShowRunning()
if( xSlideShow.is() && xSlideShow->isRunning() ) if( xSlideShow.is() && xSlideShow->isRunning() )
{ {
if (xSlideShow->isFullScreen()) if (xSlideShow->isFullScreen())
eResult |= IDET_FULL_SCREEN_SHOW_ACTIVE; eResult |= IdleState::FullScreenShowActive;
else else
eResult |= IDET_WINDOW_SHOW_ACTIVE; eResult |= IdleState::WindowShowActive;
} }
} }
} }
...@@ -93,12 +93,12 @@ sal_Int32 IdleDetection::CheckSlideShowRunning() ...@@ -93,12 +93,12 @@ sal_Int32 IdleDetection::CheckSlideShowRunning()
return eResult; return eResult;
} }
sal_Int32 IdleDetection::CheckWindowPainting (const vcl::Window& rWindow) IdleState IdleDetection::CheckWindowPainting (const vcl::Window& rWindow)
{ {
if (rWindow.IsInPaint()) if (rWindow.IsInPaint())
return IDET_WINDOW_PAINTING; return IdleState::WindowPainting;
else else
return IDET_IDLE; return IdleState::Idle;
} }
} } // end of namespace ::sd::tools } } // end of namespace ::sd::tools
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment