From 18b1ca6bbed4162b65def00ab29d1d3009e88577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 18 May 2009 21:13:23 +0000 Subject: [PATCH] * Auto hide the mouse after 5 seconds. * Disable the screen saver when playing in full screen mode. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30797 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/Jamfile | 4 +-- src/apps/mediaplayer/MainWin.cpp | 2 ++ src/apps/mediaplayer/VideoView.cpp | 49 ++++++++++++++++++++++++++++-- src/apps/mediaplayer/VideoView.h | 8 ++++- 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/apps/mediaplayer/Jamfile b/src/apps/mediaplayer/Jamfile index ea96e4ce8a..371bd0faa3 100644 --- a/src/apps/mediaplayer/Jamfile +++ b/src/apps/mediaplayer/Jamfile @@ -46,7 +46,7 @@ Application MediaPlayer : AudioResampler.cpp AudioSupplier.cpp AudioVolumeConverter.cpp - + # media_node_framework/video VideoConsumer.cpp VideoProducer.cpp @@ -104,7 +104,7 @@ Application MediaPlayer : TransportControlGroup.cpp VideoView.cpp - : be media tracker translation textencoding $(TARGET_LIBSTDC++) + : be game media tracker translation textencoding $(TARGET_LIBSTDC++) : MediaPlayer.rdef ; diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp index 204ad85a97..6aac2cedda 100644 --- a/src/apps/mediaplayer/MainWin.cpp +++ b/src/apps/mediaplayer/MainWin.cpp @@ -1466,6 +1466,8 @@ MainWin::_ToggleFullscreen() Show(); } + fVideoView->SetFullscreen(fIsFullscreen); + _MarkSettingsItem(M_TOGGLE_FULLSCREEN, fIsFullscreen); printf("_ToggleFullscreen leave\n"); diff --git a/src/apps/mediaplayer/VideoView.cpp b/src/apps/mediaplayer/VideoView.cpp index 448c84b31d..d8e4a8e1f2 100644 --- a/src/apps/mediaplayer/VideoView.cpp +++ b/src/apps/mediaplayer/VideoView.cpp @@ -1,5 +1,5 @@ /* - * Copyright © 2006-2008 Stephan Aßmus + * Copyright © 2006-2009 Stephan Aßmus * All rights reserved. Distributed under the terms of the MIT license. */ #include "VideoView.h" @@ -18,13 +18,19 @@ #undef private #endif +#include +#include + #include "Settings.h" VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask) - : BView(frame, name, resizeMask, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), + : BView(frame, name, resizeMask, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE + | B_PULSE_NEEDED), fOverlayMode(false), fIsPlaying(false), + fIsFullscreen(false), + fLastMouseMove(system_time()), fGlobalSettingsListener(this) { SetViewColor(B_TRANSPARENT_COLOR); @@ -84,6 +90,37 @@ VideoView::MessageReceived(BMessage* message) } +void +VideoView::Pulse() +{ + if (!fIsFullscreen || !fIsPlaying) + return; + + bigtime_t now = system_time(); + if (now - fLastMouseMove > 5LL * 1000000) { + fLastMouseMove = now; + // take care of disabling the screen saver + BPoint where; + uint32 buttons; + GetMouse(&where, &buttons, false); + set_mouse_position((int32)where.x, (int32)where.y); + // hide the mouse cursor until the user moves it + be_app->ObscureCursor(); + } +} + + +void +VideoView::MouseMoved(BPoint where, uint32 transit, + const BMessage* dragMessage) +{ + fLastMouseMove = system_time(); +} + + +// #pragma mark - + + void VideoView::SetBitmap(const BBitmap* bitmap) { @@ -214,11 +251,17 @@ VideoView::DisableOverlay() void VideoView::SetPlaying(bool playing) { - printf("VideoView::SetPlaying(%d)\n", playing); fIsPlaying = playing; } +void +VideoView::SetFullscreen(bool fullScreen) +{ + fIsFullscreen = fullScreen; +} + + // #pragma mark - diff --git a/src/apps/mediaplayer/VideoView.h b/src/apps/mediaplayer/VideoView.h index de03e912d7..4ee5d35ff4 100644 --- a/src/apps/mediaplayer/VideoView.h +++ b/src/apps/mediaplayer/VideoView.h @@ -1,5 +1,5 @@ /* - * Copyright © 2006-2008 Stephan Aßmus + * Copyright © 2006-2009 Stephan Aßmus * All rights reserved. Distributed under the terms of the MIT license. */ #ifndef VIDEO_VIEW_H @@ -21,6 +21,9 @@ public: // BView interface virtual void Draw(BRect updateRect); virtual void MessageReceived(BMessage* message); + virtual void Pulse(); + virtual void MouseMoved(BPoint where, uint32 transit, + const BMessage* dragMessage = NULL); // VideoTarget interface virtual void SetBitmap(const BBitmap* bitmap); @@ -37,6 +40,7 @@ public: void DisableOverlay(); void SetPlaying(bool playing); + void SetFullscreen(bool fullScreen); private: void _DrawBitmap(const BBitmap* bitmap); @@ -46,6 +50,8 @@ private: overlay_restrictions fOverlayRestrictions; rgb_color fOverlayKeyColor; bool fIsPlaying; + bool fIsFullscreen; + bigtime_t fLastMouseMove; ListenerAdapter fGlobalSettingsListener; bool fUseOverlays;