[vlc-commits] common/win32_fullscreen: hook operations moved to function

Sergey Radionov git at videolan.org
Wed Dec 21 12:54:16 CET 2011


npapi-vlc | branch: master | Sergey Radionov <RSATom at gmail.com> | Fri Dec  2 22:58:47 2011 +0700| [bb6eb59d60a5d14c71e02b4c97589d1d8f38c9ad] | committer: Jean-Baptiste Kempf

common/win32_fullscreen: hook operations moved to function

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 common/win32_fullscreen.cpp |   32 +++++++++++++++++++++-----------
 common/win32_fullscreen.h   |    2 ++
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/common/win32_fullscreen.cpp b/common/win32_fullscreen.cpp
index 06222fa..612fc37 100644
--- a/common/win32_fullscreen.cpp
+++ b/common/win32_fullscreen.cpp
@@ -124,13 +124,7 @@ LRESULT CALLBACK VLCHolderWnd::VLCHolderClassWndProc(HWND hWnd, UINT uMsg, WPARA
             SetWindowLongPtr(hWnd, GWLP_USERDATA, 0);
             break;
         case WM_TRY_SET_MOUSE_HOOK:{
-            HWND hChildWnd = GetWindow(h_data->getHWND(), GW_CHILD);
-            if(!h_data->_hMouseHook && hChildWnd){
-                //Set mouse hook to catch mouse double clicking
-                h_data->_hMouseHook =
-                    SetWindowsHookEx(WH_MOUSE, VLCHolderWnd::MouseHookProc,
-                                     NULL, GetWindowThreadProcessId(hChildWnd, NULL));
-            }
+            h_data->MouseHook(true);
             break;
         }
         case WM_MOUSEMOVE:
@@ -184,6 +178,24 @@ LRESULT CALLBACK VLCHolderWnd::MouseHookProc(int nCode, WPARAM wParam, LPARAM lP
         return 1;
 }
 
+void VLCHolderWnd::MouseHook(bool SetHook)
+{
+    if(SetHook){
+        HWND hChildWnd = GetWindow(getHWND(), GW_CHILD);
+        if(!_hMouseHook && hChildWnd){
+            _hMouseHook =
+                SetWindowsHookEx(WH_MOUSE, VLCHolderWnd::MouseHookProc,
+                                 NULL, GetWindowThreadProcessId(hChildWnd, NULL));
+        }
+    }
+    else{
+        if(_hMouseHook){
+            UnhookWindowsHookEx(_hMouseHook);
+            _hMouseHook = 0;
+        }
+    }
+}
+
 //libvlc events arrives from separate thread
 void VLCHolderWnd::OnLibVlcEvent(const libvlc_event_t* event)
 {
@@ -200,6 +212,7 @@ void VLCHolderWnd::OnLibVlcEvent(const libvlc_event_t* event)
     }
 }
 
+
 void VLCHolderWnd::LibVlcAttach()
 {
     libvlc_media_player_set_hwnd(getMD(), getHWND());
@@ -211,10 +224,7 @@ void VLCHolderWnd::LibVlcDetach()
     if(p_md)
         libvlc_media_player_set_hwnd(p_md, 0);
 
-    if(_hMouseHook){
-        UnhookWindowsHookEx(_hMouseHook);
-        _hMouseHook = 0;
-    }
+    MouseHook(false);
 }
 
 /////////////////////////////////
diff --git a/common/win32_fullscreen.h b/common/win32_fullscreen.h
index f9a91c0..8f1de8d 100644
--- a/common/win32_fullscreen.h
+++ b/common/win32_fullscreen.h
@@ -48,7 +48,9 @@ private:
     static LPCTSTR getClassName(void)  { return TEXT("VLC ActiveX Window Holder Class"); };
     static LRESULT CALLBACK VLCHolderClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
     static LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam);
+
     HHOOK _hMouseHook;
+    void MouseHook(bool SetHook);
 
     libvlc_media_player_t* getMD() const;
 



More information about the vlc-commits mailing list