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

common/win32_fullscreen: fixed handling mouse events when vout window thread...

common/win32_fullscreen: fixed handling mouse events when vout window thread has changed (usially after "stop")
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent c3d77bfb
......@@ -181,16 +181,24 @@ LRESULT CALLBACK VLCHolderWnd::MouseHookProc(int nCode, WPARAM wParam, LPARAM lP
void VLCHolderWnd::MouseHook(bool SetHook)
{
if(SetHook){
HWND hChildWnd = GetWindow(getHWND(), GW_CHILD);
if(!_hMouseHook && hChildWnd){
const HWND hChildWnd = GetWindow(getHWND(), GW_CHILD);
const DWORD WndThreadID = (hChildWnd) ? GetWindowThreadProcessId(hChildWnd, NULL) : 0;
if( _hMouseHook &&( !hChildWnd || WndThreadID != _MouseHookThreadId) ){
//unhook if something changed
MouseHook(false);
}
if(!_hMouseHook && hChildWnd && WndThreadID){
_MouseHookThreadId = WndThreadID;
_hMouseHook =
SetWindowsHookEx(WH_MOUSE, VLCHolderWnd::MouseHookProc,
NULL, GetWindowThreadProcessId(hChildWnd, NULL));
NULL, WndThreadID);
}
}
else{
if(_hMouseHook){
UnhookWindowsHookEx(_hMouseHook);
_MouseHookThreadId=0;
_hMouseHook = 0;
}
}
......@@ -205,14 +213,16 @@ void VLCHolderWnd::OnLibVlcEvent(const libvlc_event_t* event)
//So we try catch events,
//(suppose wnd will be ever created),
//and then try set mouse hook.
if(!_hMouseHook){
const HWND hChildWnd = GetWindow(getHWND(), GW_CHILD);
const DWORD WndThreadID = (hChildWnd) ? GetWindowThreadProcessId(hChildWnd, NULL) : 0;
//if no hook, or window thread has changed
if(!_hMouseHook || (hChildWnd && WndThreadID != _MouseHookThreadId)){
//libvlc events arrives from separate thread,
//so we need post message to main thread, to notify it.
PostMessage(getHWND(), WM_TRY_SET_MOUSE_HOOK, 0, 0);
}
}
void VLCHolderWnd::LibVlcAttach()
{
libvlc_media_player_set_hwnd(getMD(), getHWND());
......
......@@ -50,6 +50,7 @@ private:
static LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam);
HHOOK _hMouseHook;
DWORD _MouseHookThreadId;
void MouseHook(bool SetHook);
libvlc_media_player_t* getMD() const;
......@@ -60,7 +61,7 @@ private:
private:
VLCHolderWnd(HWND hWnd, VLCWindowsManager* WM)
: _hMouseHook(NULL), _hWnd(hWnd)
: _hMouseHook(NULL), _MouseHookThreadId(0), _hWnd(hWnd)
, _WindowsManager(WM){};
public:
......
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