[vlc-commits] skins2: handle cursor internally (refs #18661)

Rémi Denis-Courmont git at videolan.org
Sun May 20 19:51:28 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri May 18 17:52:48 2018 +0300| [a21fc0979529dc5522e200d5c9664a47fde22a7c] | committer: Rémi Denis-Courmont

skins2: handle cursor internally (refs #18661)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a21fc0979529dc5522e200d5c9664a47fde22a7c
---

 modules/gui/skins2/commands/cmd_resize.cpp | 11 ----------
 modules/gui/skins2/commands/cmd_resize.hpp | 16 ---------------
 modules/gui/skins2/src/skin_main.cpp       | 10 ----------
 modules/gui/skins2/src/vout_window.cpp     | 32 +++++++++++++++++++++++++++++-
 modules/gui/skins2/src/vout_window.hpp     | 11 ++++++++++
 5 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/modules/gui/skins2/commands/cmd_resize.cpp b/modules/gui/skins2/commands/cmd_resize.cpp
index 6b8b378f06..c3c2afbaa0 100644
--- a/modules/gui/skins2/commands/cmd_resize.cpp
+++ b/modules/gui/skins2/commands/cmd_resize.cpp
@@ -64,14 +64,3 @@ void CmdSetFullscreen::execute()
 {
     getIntf()->p_sys->p_voutManager->setFullscreenWnd( m_pWnd, m_bFullscreen );
 }
-
-
-CmdHideMouse::CmdHideMouse( intf_thread_t *pIntf,
-			    vout_window_t * pWnd, bool hide )
-    : CmdGeneric( pIntf ), m_pWnd( pWnd ), m_bHide( hide ) { }
-
-
-void CmdHideMouse::execute()
-{
-    getIntf()->p_sys->p_voutManager->hideMouseWnd( m_pWnd, m_bHide );
-}
diff --git a/modules/gui/skins2/commands/cmd_resize.hpp b/modules/gui/skins2/commands/cmd_resize.hpp
index 9a9d76b731..a1d342b592 100644
--- a/modules/gui/skins2/commands/cmd_resize.hpp
+++ b/modules/gui/skins2/commands/cmd_resize.hpp
@@ -83,20 +83,4 @@ private:
     vout_window_t* m_pWnd;
     bool m_bFullscreen;
 };
-
-
-/// Command to hide mouse
-class CmdHideMouse: public CmdGeneric
-{
-public:
-    /// hide the mouse
-    CmdHideMouse( intf_thread_t *pIntf, vout_window_t* pWnd, bool hide );
-    virtual ~CmdHideMouse() { }
-    virtual void execute();
-    virtual std::string getType() const { return "hide mouse"; }
-
-private:
-    vout_window_t* m_pWnd;
-    bool m_bHide;
-};
 #endif
diff --git a/modules/gui/skins2/src/skin_main.cpp b/modules/gui/skins2/src/skin_main.cpp
index 93f9f21e1a..80c1183174 100644
--- a/modules/gui/skins2/src/skin_main.cpp
+++ b/modules/gui/skins2/src/skin_main.cpp
@@ -475,16 +475,6 @@ static int WindowControl( vout_window_t *pWnd, int query, va_list args )
             return VLC_SUCCESS;
         }
 
-        case VOUT_WINDOW_HIDE_MOUSE:
-        {
-            bool hide = va_arg( args, int );
-            // Post a HideMouse command
-            CmdHideMouse* pCmd =
-                new CmdHideMouse( pIntf, pWnd, hide );
-            pQueue->push( CmdGenericPtr( pCmd ) );
-            return VLC_SUCCESS;
-        }
-
         default:
             msg_Dbg( pIntf, "control query not supported" );
             return VLC_EGENERIC;
diff --git a/modules/gui/skins2/src/vout_window.cpp b/modules/gui/skins2/src/vout_window.cpp
index 105468bdea..77d0822be0 100644
--- a/modules/gui/skins2/src/vout_window.cpp
+++ b/modules/gui/skins2/src/vout_window.cpp
@@ -27,6 +27,7 @@
 #include "theme.hpp"
 #include "os_factory.hpp"
 #include "os_graphics.hpp"
+#include "os_timer.hpp"
 #include "os_window.hpp"
 #include "../events/evt_key.hpp"
 #include "../events/evt_motion.hpp"
@@ -40,8 +41,12 @@ VoutWindow::VoutWindow( intf_thread_t *pIntf, vout_window_t* pWnd,
       GenericWindow( pIntf, 0, 0, false, false, pParent,
                      GenericWindow::VoutWindow ),
       m_pWnd( pWnd ), original_width( width ), original_height( height ),
-      m_pCtrlVideo( NULL ), m_pParentWindow( pParent )
+      m_pCtrlVideo( NULL ), m_pParentWindow( pParent ),
+      mouse_hide_timeout( var_InheritInteger( pWnd, "mouse-hide-timeout" ) ),
+      m_cmdHideMouse( this )
 {
+    OSFactory *pOsFactory = OSFactory::instance( pIntf );
+
     if( m_pWnd )
     {
         vlc_object_hold( m_pWnd );
@@ -52,6 +57,8 @@ VoutWindow::VoutWindow( intf_thread_t *pIntf, vout_window_t* pWnd,
 #else
         m_pWnd->handle.hwnd = getOSHandle();
 #endif
+
+        m_pTimer = pOsFactory->createOSTimer( m_cmdHideMouse );
     }
 }
 
@@ -60,6 +67,7 @@ VoutWindow::~VoutWindow()
 {
     if( m_pWnd )
     {
+        delete m_pTimer;
         vlc_object_release( m_pWnd );
     }
 }
@@ -125,7 +133,9 @@ void VoutWindow::processEvent( EvtMotion &rEvtMotion )
 {
     int x = rEvtMotion.getXPos() - m_pParentWindow->getLeft() - getLeft();
     int y = rEvtMotion.getYPos() - m_pParentWindow->getTop() - getTop();
+
     vout_window_ReportMouseMoved( m_pWnd, x, y );
+    showMouse();
 }
 
 
@@ -145,4 +155,24 @@ void VoutWindow::processEvent( EvtMouse &rEvtMouse )
         vout_window_ReportMouseReleased( m_pWnd, button );
     else if( rEvtMouse.getAction() == EvtMouse::kDblClick )
         vout_window_ReportMouseDoubleClick( m_pWnd, button );
+    showMouse();
+}
+
+
+void VoutWindow::showMouse()
+{
+    m_pTimer->start( mouse_hide_timeout, true );
+    hideMouse( false );
+}
+
+
+void VoutWindow::hideMouse( bool hide )
+{
+    VoutManager::instance( getIntf() )->hideMouseWnd( m_pWnd, hide );
+}
+
+
+void VoutWindow::CmdHideMouse::execute()
+{
+    m_pParent->hideMouse( true );
 }
diff --git a/modules/gui/skins2/src/vout_window.hpp b/modules/gui/skins2/src/vout_window.hpp
index 0a927c80cd..804c50915d 100644
--- a/modules/gui/skins2/src/vout_window.hpp
+++ b/modules/gui/skins2/src/vout_window.hpp
@@ -26,9 +26,11 @@
 
 #include "generic_window.hpp"
 #include "dialogs.hpp"
+#include "../commands/cmd_generic.hpp"
 #include <vlc_vout_window.h>
 
 class OSGraphics;
+class OSTimer;
 class CtrlVideo;
 
 
@@ -75,6 +77,10 @@ public:
     /// Resize the window
     virtual void resize( int width, int height );
 
+    // Hide/show cursor
+    void showMouse( );
+    void hideMouse( bool );
+
     virtual std::string getType() const { return "Vout"; }
 
 private:
@@ -91,6 +97,11 @@ private:
 
     /// Parent Window
     GenericWindow* m_pParentWindow;
+
+    // Cursor timer
+    OSTimer *m_pTimer;
+    int mouse_hide_timeout;
+    DEFINE_CALLBACK( VoutWindow, HideMouse );
 };
 
 typedef CountedPtr<VoutWindow> VoutWindowPtr;



More information about the vlc-commits mailing list