diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-10-12 09:19:23 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-10-12 10:11:19 +0200 |
commit | 4b1b17f40aaeac23bd03e676f8c0739ad5765646 (patch) | |
tree | f3b8381a99dcddffbe5537761543d3af08c631b7 /sd | |
parent | 7adac063f88842c5f4f7c1d44ed41fa6ab5d819e (diff) |
convert IDET flags to typed_flags
Change-Id: Iaaea3b3693ab4c67a60e48e7de8865413e8e246b
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/inc/tools/IdleDetection.hxx | 62 | ||||
-rw-r--r-- | sd/source/ui/sidebar/MasterPageContainerQueue.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/tools/IdleDetection.cxx | 24 |
4 files changed, 52 insertions, 44 deletions
diff --git a/sd/source/ui/inc/tools/IdleDetection.hxx b/sd/source/ui/inc/tools/IdleDetection.hxx index b6dbb182dd40..3289db47fd11 100644 --- a/sd/source/ui/inc/tools/IdleDetection.hxx +++ b/sd/source/ui/inc/tools/IdleDetection.hxx @@ -21,10 +21,40 @@ #define INCLUDED_SD_SOURCE_UI_INC_TOOLS_IDLEDETECTION_HXX #include <sal/types.h> +#include <o3tl/typed_flags_set.hxx> 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 { /** Detect whether the system is idle and some time consuming operation may be carried out. This class distinguishes between different states of @@ -33,49 +63,27 @@ namespace sd { namespace tools { class IdleDetection { 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. @param pWindow When a valid Window pointer is given then it is checked whether the window is currently being painting. @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 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: /** 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. */ - 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 diff --git a/sd/source/ui/sidebar/MasterPageContainerQueue.cxx b/sd/source/ui/sidebar/MasterPageContainerQueue.cxx index 8b56bbd9224b..7fdafe6aa5ab 100644 --- a/sd/source/ui/sidebar/MasterPageContainerQueue.cxx +++ b/sd/source/ui/sidebar/MasterPageContainerQueue.cxx @@ -187,10 +187,10 @@ IMPL_LINK(MasterPageContainerQueue, DelayedPreviewCreation, Timer*, pTimer, void break; // First check whether the system is idle. - sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(nullptr)); - if (nIdleState != tools::IdleDetection::IDET_IDLE) + tools::IdleState nIdleState (tools::IdleDetection::GetIdleState(nullptr)); + if (nIdleState != tools::IdleState::Idle) { - if ((nIdleState&tools::IdleDetection::IDET_FULL_SCREEN_SHOW_ACTIVE) != 0) + if (nIdleState & tools::IdleState::FullScreenShowActive) bIsShowingFullScreenShow = true; break; } diff --git a/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx b/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx index 065c2491da8d..c88fab8eeecc 100644 --- a/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx +++ b/sd/source/ui/slidesorter/view/SlsViewCacheContext.cxx @@ -65,8 +65,8 @@ void ViewCacheContext::NotifyPreviewCreation ( bool ViewCacheContext::IsIdle() { - sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow())); - if (nIdleState == tools::IdleDetection::IDET_IDLE) + tools::IdleState nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow())); + if (nIdleState == tools::IdleState::Idle) return true; else return false; diff --git a/sd/source/ui/tools/IdleDetection.cxx b/sd/source/ui/tools/IdleDetection.cxx index e5e9dab48ba4..b2e31e93270c 100644 --- a/sd/source/ui/tools/IdleDetection.cxx +++ b/sd/source/ui/tools/IdleDetection.cxx @@ -33,25 +33,25 @@ using namespace ::com::sun::star; 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) nResult |= CheckWindowPainting(*pWindow); return nResult; } -sal_Int32 IdleDetection::CheckInputPending() +IdleState IdleDetection::CheckInputPending() { if (Application::AnyInput(VclInputFlags::MOUSE | VclInputFlags::KEYBOARD | VclInputFlags::PAINT)) - return IDET_SYSTEM_EVENT_PENDING; + return IdleState::SystemEventPending; 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; @@ -83,9 +83,9 @@ sal_Int32 IdleDetection::CheckSlideShowRunning() if( xSlideShow.is() && xSlideShow->isRunning() ) { if (xSlideShow->isFullScreen()) - eResult |= IDET_FULL_SCREEN_SHOW_ACTIVE; + eResult |= IdleState::FullScreenShowActive; else - eResult |= IDET_WINDOW_SHOW_ACTIVE; + eResult |= IdleState::WindowShowActive; } } } @@ -93,12 +93,12 @@ sal_Int32 IdleDetection::CheckSlideShowRunning() return eResult; } -sal_Int32 IdleDetection::CheckWindowPainting (const vcl::Window& rWindow) +IdleState IdleDetection::CheckWindowPainting (const vcl::Window& rWindow) { if (rWindow.IsInPaint()) - return IDET_WINDOW_PAINTING; + return IdleState::WindowPainting; else - return IDET_IDLE; + return IdleState::Idle; } } } // end of namespace ::sd::tools |