Commit bb6eb59d authored by Sergey Radionov's avatar Sergey Radionov Committed by Jean-Baptiste Kempf

common/win32_fullscreen: hook operations moved to function

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 04022490
......@@ -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);
}
/////////////////////////////////
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment