mirror of
https://github.com/clsid2/mpc-hc
synced 2026-11-26 09:58:00 +08:00
IMPCVRSubclassReplacement
This commit is contained in:
1 parent
d7a1c284f3
commit
a7c6e5976a
6 files changed
+103
-5
No files matched your search
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* (C) 2026 see Authors.txt
|
||||
*
|
||||
* This file is part of MPC-HC.
|
||||
*
|
||||
* MPC-HC is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* MPC-HC is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Normally MPCVR subclasses the top-level ancestor of its parent window to
|
||||
// receive the messages it needs (hotkeys, exclusive mode handling, ...).
|
||||
// The player can disable that subclassing by calling "DisableSubclassing"
|
||||
// right after creating the filter and before the input pin is connected.
|
||||
// It must then forward the messages from its own WindowProc by calling
|
||||
// "WindowProcFromParent", from the same window MPCVR would otherwise have
|
||||
// subclassed. If "WindowProcFromParent" returns "TRUE", consider the message
|
||||
// handled by MPCVR: do not process it further, just return the value written
|
||||
// to "result". If it returns "FALSE", process the message as usual.
|
||||
|
||||
interface __declspec(uuid("79C92864-E293-445B-90C7-2816E0508790"))
|
||||
IMPCVRSubclassReplacement :
|
||||
public IUnknown
|
||||
{
|
||||
STDMETHOD_(void, DisableSubclassing)() PURE; // must be called before the input pin is connected
|
||||
STDMETHOD_(bool, WindowProcFromParent)(HWND hwnd, UINT uMsg, WPARAM* wParam, LPARAM* lParam, LRESULT* result) PURE;
|
||||
};
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "uuids.h"
|
||||
#include "moreuuids.h"
|
||||
#include <mvrInterfaces.h>
|
||||
#include <IMPCVRSubclassReplacement.h>
|
||||
|
||||
#include <initguid.h>
|
||||
#include "AllocatorCommon.h"
|
||||
@@ -605,6 +606,9 @@ HRESULT CFGFilterVideoRenderer::Create(IBaseFilter** ppBF, CInterfaceList<IUnkno
|
||||
*ppBF = CComQIPtr<IBaseFilter>(pRenderer).Detach();
|
||||
|
||||
if (m_clsid == CLSID_MPCVRAllocatorPresenter) {
|
||||
if (CComQIPtr<IMPCVRSubclassReplacement> pSR = pCAP) {
|
||||
pSR->DisableSubclassing();
|
||||
}
|
||||
auto pMainFrame = (CMainFrame*)(AfxGetApp()->m_pMainWnd);
|
||||
if (pMainFrame && pMainFrame->HasDedicatedFSVideoWindow()) {
|
||||
if (CComQIPtr<ID3DFullscreenControl> pD3DFSC = *ppBF) {
|
||||
|
||||
@@ -65,6 +65,24 @@ LRESULT CFullscreenWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_pMainFrame->m_pVideoWnd == this) {
|
||||
// the renderer is parented to this top-level window, so it gets the messages it would otherwise have hooked from here
|
||||
LRESULT ret = 0;
|
||||
switch (message) {
|
||||
case WM_CLOSE:
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_LBUTTONUP:
|
||||
// CMouseWnd will call madVR window proc
|
||||
break;
|
||||
default:
|
||||
if (m_pMainFrame->ForwardMessageToRenderer(m_hWnd, message, wParam, lParam, ret)) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return __super::WindowProc(message, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
+25
-4
@@ -95,6 +95,7 @@
|
||||
#include <IPinHook.h>
|
||||
|
||||
#include <mvrInterfaces.h>
|
||||
#include <IMPCVRSubclassReplacement.h>
|
||||
|
||||
#include <Il21dec.h>
|
||||
#include <dvdevcod.h>
|
||||
@@ -16667,6 +16668,7 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
|
||||
m_pMVRI = nullptr;
|
||||
m_pMVRS = nullptr;
|
||||
m_pMVRSR = nullptr;
|
||||
m_pMPCVRSR = nullptr;
|
||||
m_pMVRFG = nullptr;
|
||||
m_pMVTO = nullptr;
|
||||
m_pD3DFSC = nullptr;
|
||||
@@ -16740,6 +16742,7 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
|
||||
m_pMVRI = m_pCAP;
|
||||
m_pMVRS = m_pCAP;
|
||||
m_pMVRSR = m_pCAP;
|
||||
m_pMPCVRSR = m_pCAP;
|
||||
m_pMVRFG = m_pCAP;
|
||||
m_pMVTO = m_pCAP;
|
||||
m_pD3DFSC = m_pCAP;
|
||||
@@ -17096,6 +17099,7 @@ void CMainFrame::CloseMediaPrivate()
|
||||
m_pMVRC.Release();
|
||||
m_pMVRI.Release();
|
||||
m_pMVTO.Release();
|
||||
m_pMPCVRSR.Release();
|
||||
m_pD3DFSC.Release();
|
||||
m_pCAP3.Release();
|
||||
m_pCAP2.Release();
|
||||
@@ -20117,7 +20121,7 @@ bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPrevi
|
||||
m_pMVRFG.Release();
|
||||
m_pMVRSR.Release();
|
||||
m_pMVTO.Release();
|
||||
|
||||
m_pMPCVRSR.Release();
|
||||
m_pCAP3.Release();
|
||||
m_pCAP2.Release();
|
||||
m_pCAP.Release();
|
||||
@@ -20196,6 +20200,7 @@ bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPrevi
|
||||
m_pMVRSR = m_pCAP;
|
||||
m_pMVRS = m_pCAP;
|
||||
m_pMVRFG = m_pCAP;
|
||||
m_pMPCVRSR = m_pCAP;
|
||||
|
||||
const CAppSettings& s = AfxGetAppSettings();
|
||||
m_pVideoWnd = &m_wndView;
|
||||
@@ -23422,8 +23427,8 @@ LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
LRESULT ret = 0;
|
||||
bool bCallOurProc = true;
|
||||
if (m_pMVRSR) {
|
||||
// call madVR window proc directly when the interface is available
|
||||
if (m_pMVRSR || m_pMPCVRSR) {
|
||||
// call the video renderer window proc directly when the interface is available
|
||||
switch (message) {
|
||||
case WM_CLOSE:
|
||||
case WM_SYSCOMMAND:
|
||||
@@ -23434,7 +23439,11 @@ LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
// CMouseWnd will call madVR window proc
|
||||
break;
|
||||
default:
|
||||
bCallOurProc = !m_pMVRSR->ParentWindowProc(m_hWnd, message, &wParam, &lParam, &ret);
|
||||
// when the dedicated fullscreen window hosts the video, CFullscreenWnd forwards its own messages
|
||||
// keyboard messages are re-posted from there to this window, so those still go through here
|
||||
if (m_pVideoWnd != m_pDedicatedFSVideoWnd || (message >= WM_KEYFIRST && message <= WM_KEYLAST) && m_pMVRSR) {
|
||||
bCallOurProc = !ForwardMessageToRenderer(m_hWnd, message, wParam, lParam, ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bCallOurProc && m_hWnd) {
|
||||
@@ -23444,6 +23453,18 @@ LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Forwards a message to the renderer that would otherwise have subclassed hWnd; returns true when it handled the message
|
||||
inline bool CMainFrame::ForwardMessageToRenderer(HWND hWnd, UINT message, WPARAM& wParam, LPARAM& lParam, LRESULT& ret)
|
||||
{
|
||||
if (m_pMVRSR) {
|
||||
return !!m_pMVRSR->ParentWindowProc(hWnd, message, &wParam, &lParam, &ret);
|
||||
}
|
||||
if (m_pMPCVRSR && (message == WM_MOVE || message == WM_DISPLAYCHANGE)) {
|
||||
return !!m_pMPCVRSR->WindowProcFromParent(hWnd, message, &wParam, &lParam, &ret);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMainFrame::IsAeroSnapped()
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
@@ -72,6 +72,7 @@ interface IMadVRInfo;
|
||||
interface IMadVRFrameGrabber;
|
||||
interface IMadVRSettings;
|
||||
interface IMadVRSubclassReplacement;
|
||||
interface IMPCVRSubclassReplacement;
|
||||
interface ISubClock;
|
||||
interface ISubPicAllocatorPresenter2;
|
||||
interface ISubPicAllocatorPresenter;
|
||||
@@ -302,6 +303,7 @@ private:
|
||||
|
||||
CComPtr<IMadVRSettings> m_pMVRS;
|
||||
CComPtr<IMadVRSubclassReplacement> m_pMVRSR;
|
||||
CComPtr<IMPCVRSubclassReplacement> m_pMPCVRSR;
|
||||
CComPtr<IMadVRCommand> m_pMVRC;
|
||||
CComPtr<IMadVRInfo> m_pMVRI;
|
||||
CComPtr<IMadVRFrameGrabber> m_pMVRFG;
|
||||
@@ -1395,6 +1397,7 @@ protected:
|
||||
afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
|
||||
// GDI+
|
||||
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
bool ForwardMessageToRenderer(HWND hWnd, UINT message, WPARAM& wParam, LPARAM& lParam, LRESULT& ret);
|
||||
void WTSRegisterSessionNotification();
|
||||
void WTSUnRegisterSessionNotification();
|
||||
|
||||
|
||||
@@ -483,7 +483,9 @@ void CMouse::InternalOnRButtonUp(UINT nFlags, const CPoint& point)
|
||||
{
|
||||
if (m_bWaitingRButtonUp) {
|
||||
m_bWaitingRButtonUp = false;
|
||||
OnButton(wmcmd::RUP, point);
|
||||
if (!m_pMainFrame->m_bIsMPCVRExclusiveMode) {
|
||||
OnButton(wmcmd::RUP, point);
|
||||
}
|
||||
SetCursor(nFlags, point);
|
||||
}
|
||||
}
|
||||
@@ -663,6 +665,17 @@ void CMouse::InternalOnMouseMove(UINT nFlags, const CPoint& point)
|
||||
|
||||
void CMouse::InternalOnMouseLeave()
|
||||
{
|
||||
// A renderer child window created on our thread (MPCVR in exclusive mode)
|
||||
// makes TrackMouseEvent report a leave while the cursor is still on the video.
|
||||
// Ignore it; the next mouse move re-arms the tracker.
|
||||
CPoint screenPoint;
|
||||
if (GetCursorPos(&screenPoint)) {
|
||||
HWND hUnder = ::WindowFromPoint(screenPoint);
|
||||
if (hUnder && (hUnder == GetWnd().m_hWnd || ::IsChild(GetWnd().m_hWnd, hUnder))) {
|
||||
m_bTrackingMouseLeave = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
StopMouseHider();
|
||||
m_bTrackingMouseLeave = false;
|
||||
m_cursor = Cursor::ARROW;
|
||||
|
||||
Reference in new issue
Block a user