From 6346c8941ce8b434423b0787733e084076d51d6f Mon Sep 17 00:00:00 2001 From: Ryan Leavengood Date: Wed, 20 Dec 2006 01:08:55 +0000 Subject: [PATCH] Implemented Stephan's previous TODO (in an svn commit message) to hide the cursor after a delay when in fullscreen mode. I set the delay to 5 seconds. In addition I make sure the ShowImage window is the active window before trying to hide the cursor, because otherwise there is a lot of cursor flickering if you change workspaces. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19569 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/ShowImageView.cpp | 19 ++++++++++++++++--- src/apps/showimage/ShowImageView.h | 7 +++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index a1e1707e8f..0ad2609f62 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -202,6 +202,7 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode, #if DELAYED_SCALING fScalingCountDown = SCALING_DELAY_TIME; #endif + fHideCursorCountDown = HIDE_CURSOR_DELAY_TIME; if (settings->Lock()) { fDither = settings->GetBool("Dither", fDither); @@ -310,8 +311,12 @@ ShowImageView::Pulse() } // Hide cursor in full screen mode - if (fFullScreen && !fShowingPopUpMenu) - be_app->ObscureCursor(); + if (fFullScreen && !fShowingPopUpMenu && fIsActiveWin) { + if (fHideCursorCountDown <= 0) + be_app->ObscureCursor(); + else + fHideCursorCountDown--; + } #if DELAYED_SCALING if (fBitmap && (fScaleBilinear || fDither) && fScalingCountDown > 0) { @@ -624,7 +629,6 @@ ShowImageView::SetFullScreen(bool fullScreen) fFullScreen = fullScreen; if (fFullScreen) { SetLowColor(0, 0, 0, 255); - be_app->ObscureCursor(); } else SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); } @@ -1375,6 +1379,7 @@ ShowImageView::MergeSelection() void ShowImageView::MouseDown(BPoint position) { + fHideCursorCountDown = HIDE_CURSOR_DELAY_TIME; BPoint point; uint32 buttons; MakeFocus(true); @@ -1472,6 +1477,7 @@ ShowImageView::UpdateSelectionRect(BPoint point, bool final) void ShowImageView::MouseMoved(BPoint point, uint32 state, const BMessage *message) { + fHideCursorCountDown = HIDE_CURSOR_DELAY_TIME; if (fMakesSelection) { UpdateSelectionRect(point, false); } else if (fMovesImage) { @@ -2567,3 +2573,10 @@ ShowImageView::ExitFullScreen() } +void +ShowImageView::WindowActivated(bool active) +{ + fIsActiveWin = active; + fHideCursorCountDown = HIDE_CURSOR_DELAY_TIME; +} + diff --git a/src/apps/showimage/ShowImageView.h b/src/apps/showimage/ShowImageView.h index 269833afde..470dbcde02 100644 --- a/src/apps/showimage/ShowImageView.h +++ b/src/apps/showimage/ShowImageView.h @@ -33,6 +33,9 @@ // width of the black border stroked arround the bitmap #define PEN_SIZE 1.0f +// the delay time for hiding the cursor in 1/10 seconds (the pulse rate) +#define HIDE_CURSOR_DELAY_TIME 50 + class ShowImageView : public BView { public: ShowImageView(BRect rect, const char *name, uint32 resizingMode, @@ -49,6 +52,7 @@ class ShowImageView : public BView { virtual void Pulse(); virtual void MessageReceived(BMessage *message); + virtual void WindowActivated(bool active); void SetTrackerMessenger(const BMessenger& trackerMessenger); status_t SetImage(const entry_ref *ref); @@ -237,6 +241,9 @@ class ShowImageView : public BView { bool fShowingPopUpMenu; + int fHideCursorCountDown; // Hides the cursor when it reaches zero + bool fIsActiveWin; // Is the parent window the active window? + enum image_orientation fImageOrientation; static enum image_orientation fTransformation[ ImageProcessor::kNumberOfAffineTransformations][kNumberOfOrientations];