Commit 824efac5 authored by Damien Fouilleul's avatar Damien Fouilleul

- cleaned up in place and UI activation: VLC Plugin should behave better with...

- cleaned up in place and UI activation: VLC Plugin should behave better with other controls (ie. don't eat TABSTOP keystrokes, etc...)
- minor code cleanup and fixes

parent 54330110
...@@ -40,18 +40,18 @@ STDMETHODIMP VLCOleControl::GetControlInfo(CONTROLINFO *pCI) ...@@ -40,18 +40,18 @@ STDMETHODIMP VLCOleControl::GetControlInfo(CONTROLINFO *pCI)
STDMETHODIMP VLCOleControl::OnMnemonic(LPMSG pMsg) STDMETHODIMP VLCOleControl::OnMnemonic(LPMSG pMsg)
{ {
return E_NOTIMPL; return S_OK;
}; };
STDMETHODIMP VLCOleControl::OnAmbientPropertyChange(DISPID dispID) STDMETHODIMP VLCOleControl::OnAmbientPropertyChange(DISPID dispID)
{ {
HRESULT hr; HRESULT hr;
IOleObject *oleObj; LPOLEOBJECT oleObj;
hr = QueryInterface(IID_IOleObject, (LPVOID *)&oleObj); hr = QueryInterface(IID_IOleObject, (LPVOID *)&oleObj);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
IOleClientSite *clientSite; LPOLECLIENTSITE clientSite;
hr = oleObj->GetClientSite(&clientSite); hr = oleObj->GetClientSite(&clientSite);
if( SUCCEEDED(hr) && (NULL != clientSite) ) if( SUCCEEDED(hr) && (NULL != clientSite) )
......
...@@ -41,7 +41,7 @@ STDMETHODIMP VLCOleInPlaceActiveObject::GetWindow(HWND *pHwnd) ...@@ -41,7 +41,7 @@ STDMETHODIMP VLCOleInPlaceActiveObject::GetWindow(HWND *pHwnd)
STDMETHODIMP VLCOleInPlaceActiveObject::EnableModeless(BOOL fEnable) STDMETHODIMP VLCOleInPlaceActiveObject::EnableModeless(BOOL fEnable)
{ {
return E_NOTIMPL; return S_OK;
}; };
STDMETHODIMP VLCOleInPlaceActiveObject::ContextSensitiveHelp(BOOL fEnterMode) STDMETHODIMP VLCOleInPlaceActiveObject::ContextSensitiveHelp(BOOL fEnterMode)
...@@ -51,21 +51,41 @@ STDMETHODIMP VLCOleInPlaceActiveObject::ContextSensitiveHelp(BOOL fEnterMode) ...@@ -51,21 +51,41 @@ STDMETHODIMP VLCOleInPlaceActiveObject::ContextSensitiveHelp(BOOL fEnterMode)
STDMETHODIMP VLCOleInPlaceActiveObject::TranslateAccelerator(LPMSG lpmsg) STDMETHODIMP VLCOleInPlaceActiveObject::TranslateAccelerator(LPMSG lpmsg)
{ {
return E_NOTIMPL; HRESULT hr = S_FALSE;
LPOLEOBJECT oleObj;
if( SUCCEEDED(QueryInterface(IID_IOleObject, (LPVOID *)&oleObj)) )
{
LPOLECLIENTSITE clientSite;
if( SUCCEEDED(oleObj->GetClientSite(&clientSite)) && (NULL != clientSite) )
{
IOleControlSite *controlSite;
if( SUCCEEDED(clientSite->QueryInterface(IID_IOleControlSite, (LPVOID *)&controlSite)) )
{
hr = controlSite->TranslateAccelerator(lpmsg,
((GetKeyState(VK_SHIFT) >> 15) & 1) |
((GetKeyState(VK_CONTROL) >> 14) & 2) |
((GetKeyState(VK_MENU) >> 13) & 4) );
controlSite->Release();
}
clientSite->Release();
}
oleObj->Release();
}
return hr;
}; };
STDMETHODIMP VLCOleInPlaceActiveObject::OnFrameWindowActivate(BOOL fActivate) STDMETHODIMP VLCOleInPlaceActiveObject::OnFrameWindowActivate(BOOL fActivate)
{ {
return E_NOTIMPL; return S_OK;
}; };
STDMETHODIMP VLCOleInPlaceActiveObject::OnDocWindowActivate(BOOL fActivate) STDMETHODIMP VLCOleInPlaceActiveObject::OnDocWindowActivate(BOOL fActivate)
{ {
return E_NOTIMPL; return S_OK;
}; };
STDMETHODIMP VLCOleInPlaceActiveObject::ResizeBorder(LPCRECT prcBorder, LPOLEINPLACEUIWINDOW pUIWindow, BOOL fFrameWindow) STDMETHODIMP VLCOleInPlaceActiveObject::ResizeBorder(LPCRECT prcBorder, LPOLEINPLACEUIWINDOW pUIWindow, BOOL fFrameWindow)
{ {
return E_NOTIMPL; return S_OK;
}; };
...@@ -81,9 +81,7 @@ STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void) ...@@ -81,9 +81,7 @@ STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void)
if( _p_instance->isInPlaceActive() ) if( _p_instance->isInPlaceActive() )
{ {
if( _p_instance->hasFocus() ) if( _p_instance->hasFocus() )
{
_p_instance->setFocus(FALSE); _p_instance->setFocus(FALSE);
}
LPOLEOBJECT p_oleObject; LPOLEOBJECT p_oleObject;
if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) ) if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
...@@ -95,6 +93,25 @@ STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void) ...@@ -95,6 +93,25 @@ STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void)
if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{ {
LPOLEINPLACEFRAME p_inPlaceFrame;
LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
OLEINPLACEFRAMEINFO oleFrameInfo;
RECT posRect, clipRect;
oleFrameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);
if( SUCCEEDED(p_inPlaceSite->GetWindowContext(&p_inPlaceFrame, &p_inPlaceUIWindow, &posRect, &clipRect, &oleFrameInfo)) )
{
if( p_inPlaceFrame )
{
p_inPlaceFrame->SetActiveObject(NULL, NULL);
p_inPlaceFrame->Release();
}
if( p_inPlaceUIWindow )
{
p_inPlaceUIWindow->SetActiveObject(NULL, NULL);
p_inPlaceUIWindow->Release();
}
}
p_inPlaceSite->OnUIDeactivate(FALSE); p_inPlaceSite->OnUIDeactivate(FALSE);
p_inPlaceSite->Release(); p_inPlaceSite->Release();
} }
......
...@@ -67,15 +67,20 @@ STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActi ...@@ -67,15 +67,20 @@ STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActi
case OLEIVERB_OPEN: case OLEIVERB_OPEN:
// force control to be visible when activating in place // force control to be visible when activating in place
_p_instance->setVisible(TRUE); _p_instance->setVisible(TRUE);
return doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect, TRUE);
case OLEIVERB_INPLACEACTIVATE: case OLEIVERB_INPLACEACTIVATE:
return doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect); return doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect, FALSE);
case OLEIVERB_HIDE: case OLEIVERB_HIDE:
_p_instance->setVisible(FALSE); _p_instance->setVisible(FALSE);
return S_OK; return S_OK;
case OLEIVERB_UIACTIVATE: case OLEIVERB_UIACTIVATE:
return doUIActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect); // UI activate only if visible
if( _p_instance->isVisible() )
return doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect, TRUE);
return OLEOBJ_S_CANNOT_DOVERB_NOW;
case OLEIVERB_DISCARDUNDOSTATE: case OLEIVERB_DISCARDUNDOSTATE:
return S_OK; return S_OK;
...@@ -83,41 +88,38 @@ STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActi ...@@ -83,41 +88,38 @@ STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActi
default: default:
if( iVerb > 0 ) { if( iVerb > 0 ) {
_p_instance->setVisible(TRUE); _p_instance->setVisible(TRUE);
doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect); doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect, TRUE);
return OLEOBJ_S_INVALIDVERB; return OLEOBJ_S_INVALIDVERB;
} }
return E_NOTIMPL; return E_NOTIMPL;
} }
}; };
HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect) HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect, BOOL uiActivate)
{ {
RECT posRect; RECT posRect;
RECT clipRect; RECT clipRect;
LPCRECT lprcClipRect = lprcPosRect; LPCRECT lprcClipRect = lprcPosRect;
if( NULL != pActiveSite ) if( pActiveSite )
{ {
// check if already activated
if( _p_instance->isInPlaceActive() )
{
// just attempt to show object then
if( _p_instance->getVisible() )
pActiveSite->ShowObject();
return S_OK;
}
LPOLEINPLACESITE p_inPlaceSite; LPOLEINPLACESITE p_inPlaceSite;
IOleInPlaceSiteEx *p_inPlaceSiteEx;
LPOLEINPLACEFRAME p_inPlaceFrame;
LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSiteEx, reinterpret_cast<void**>(&p_inPlaceSiteEx))) )
{ {
if( S_OK != p_inPlaceSite->CanInPlaceActivate() ) p_inPlaceSite = p_inPlaceSiteEx;
{ p_inPlaceSite->AddRef();
return OLEOBJ_S_CANNOT_DOVERB_NOW; }
} else if FAILED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, reinterpret_cast<void**>(&p_inPlaceSite)) )
{
p_inPlaceSite = p_inPlaceSiteEx = NULL;
}
LPOLEINPLACEFRAME p_inPlaceFrame; if( p_inPlaceSite )
LPOLEINPLACEUIWINDOW p_inPlaceUIWindow; {
OLEINPLACEFRAMEINFO oleFrameInfo; OLEINPLACEFRAMEINFO oleFrameInfo;
oleFrameInfo.cb = sizeof(OLEINPLACEFRAMEINFO); oleFrameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);
...@@ -125,16 +127,18 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite ...@@ -125,16 +127,18 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
{ {
lprcPosRect = &posRect; lprcPosRect = &posRect;
lprcClipRect = &clipRect; lprcClipRect = &clipRect;
if( NULL != p_inPlaceFrame )
p_inPlaceFrame->Release();
if( NULL != p_inPlaceUIWindow )
p_inPlaceUIWindow->Release();
} }
if( (NULL == hwndParent) && FAILED(p_inPlaceSite->GetWindow(&hwndParent)) ) if( (NULL == hwndParent) && FAILED(p_inPlaceSite->GetWindow(&hwndParent)) )
{ {
p_inPlaceSite->Release(); p_inPlaceSite->Release();
if( p_inPlaceSiteEx )
p_inPlaceSiteEx->Release();
if( p_inPlaceFrame )
p_inPlaceFrame->Release();
if( p_inPlaceUIWindow )
p_inPlaceUIWindow->Release();
return OLEOBJ_S_INVALIDHWND; return OLEOBJ_S_INVALIDHWND;
} }
} }
...@@ -149,68 +153,78 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite ...@@ -149,68 +153,78 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
lprcClipRect = &posRect; lprcClipRect = &posRect;
} }
if( FAILED(_p_instance->onActivateInPlace(lpMsg, hwndParent, lprcPosRect, lprcClipRect)) ) // check if not already activated
if( ! _p_instance->isInPlaceActive() )
{ {
if( NULL != p_inPlaceSite ) if( ((NULL == p_inPlaceSite) || (S_OK == p_inPlaceSite->CanInPlaceActivate()))
p_inPlaceSite->Release(); && SUCCEEDED(_p_instance->onActivateInPlace(lpMsg, hwndParent, lprcPosRect, lprcClipRect)) )
return OLEOBJ_S_CANNOT_DOVERB_NOW; {
if( p_inPlaceSiteEx )
{
BOOL needsRedraw;
p_inPlaceSiteEx->OnInPlaceActivateEx(&needsRedraw, 0);
}
else if( p_inPlaceSite )
p_inPlaceSite->OnInPlaceActivate();
}
else
{
if( p_inPlaceSite )
{
p_inPlaceSite->Release();
if( p_inPlaceSiteEx )
p_inPlaceSiteEx->Release();
if( p_inPlaceFrame )
p_inPlaceFrame->Release();
if( p_inPlaceUIWindow )
p_inPlaceUIWindow->Release();
}
return OLEOBJ_S_CANNOT_DOVERB_NOW;
}
} }
if( NULL != p_inPlaceSite ) if( p_inPlaceSite )
{
p_inPlaceSite->OnInPlaceActivate();
p_inPlaceSite->OnPosRectChange(lprcPosRect); p_inPlaceSite->OnPosRectChange(lprcPosRect);
p_inPlaceSite->Release();
}
if( _p_instance->getVisible() ) if( uiActivate )
pActiveSite->ShowObject();
if( NULL != lpMsg )
{ {
switch( lpMsg->message ) if( (NULL == p_inPlaceSiteEx) || (S_OK == p_inPlaceSiteEx->RequestUIActivate()) )
{ {
case WM_LBUTTONDOWN: if( p_inPlaceSite)
case WM_LBUTTONDBLCLK: {
doUIActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect); p_inPlaceSite->OnUIActivate();
break;
default: LPOLEINPLACEACTIVEOBJECT p_inPlaceActiveObject;
break; if( SUCCEEDED(QueryInterface(IID_IOleInPlaceActiveObject, reinterpret_cast<void**>(&p_inPlaceActiveObject))) )
{
if( p_inPlaceFrame )
p_inPlaceFrame->SetActiveObject(p_inPlaceActiveObject, NULL);
if( p_inPlaceUIWindow )
p_inPlaceUIWindow->SetActiveObject(p_inPlaceActiveObject, NULL);
p_inPlaceActiveObject->Release();
}
if( p_inPlaceFrame )
p_inPlaceFrame->RequestBorderSpace(NULL);
pActiveSite->ShowObject();
}
_p_instance->setFocus(TRUE);
} }
} }
return S_OK;
}
return OLEOBJ_S_CANNOT_DOVERB_NOW;
};
HRESULT VLCOleObject::doUIActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect) if( p_inPlaceSite )
{
if( NULL != pActiveSite )
{
// check if already activated
if( ! _p_instance->isInPlaceActive() )
return OLE_E_NOT_INPLACEACTIVE;
LPOLEINPLACESITE p_inPlaceSite;
if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{ {
p_inPlaceSite->OnUIActivate();
if( NULL != lprcPosRect )
{
p_inPlaceSite->OnPosRectChange(lprcPosRect);
}
p_inPlaceSite->Release(); p_inPlaceSite->Release();
if( p_inPlaceSiteEx )
p_inPlaceSiteEx->Release();
if( p_inPlaceFrame )
p_inPlaceFrame->Release();
if( p_inPlaceUIWindow )
p_inPlaceUIWindow->Release();
} }
pActiveSite->ShowObject();
_p_instance->setVisible(TRUE);
_p_instance->setFocus(TRUE);
return S_OK; return S_OK;
} }
return E_FAIL; return OLEOBJ_S_CANNOT_DOVERB_NOW;
}; };
STDMETHODIMP VLCOleObject::EnumAdvise(IEnumSTATDATA **ppEnumAdvise) STDMETHODIMP VLCOleObject::EnumAdvise(IEnumSTATDATA **ppEnumAdvise)
...@@ -335,7 +349,6 @@ STDMETHODIMP VLCOleObject::SetExtent(DWORD dwDrawAspect, SIZEL *pSizel) ...@@ -335,7 +349,6 @@ STDMETHODIMP VLCOleObject::SetExtent(DWORD dwDrawAspect, SIZEL *pSizel)
if( NULL == pSizel ) if( NULL == pSizel )
return E_POINTER; return E_POINTER;
if( dwDrawAspect & DVASPECT_CONTENT ) if( dwDrawAspect & DVASPECT_CONTENT )
{ {
_p_instance->setExtent(*pSizel); _p_instance->setExtent(*pSizel);
......
...@@ -73,8 +73,7 @@ public: ...@@ -73,8 +73,7 @@ public:
private: private:
HRESULT doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect); HRESULT doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect, BOOL uiActivate);
HRESULT doUIActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect);
IOleAdviseHolder *_p_advise_holder; IOleAdviseHolder *_p_advise_holder;
IOleClientSite *_p_clientsite; IOleClientSite *_p_clientsite;
......
...@@ -802,9 +802,6 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc ...@@ -802,9 +802,6 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
SetWindowLongPtr(_videownd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); SetWindowLongPtr(_videownd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
if( getVisible() )
ShowWindow(_inplacewnd, SW_SHOW);
if( _b_usermode ) if( _b_usermode )
{ {
/* will run vlc if not done already */ /* will run vlc if not done already */
...@@ -831,6 +828,10 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc ...@@ -831,6 +828,10 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
fireOnPlayEvent(); fireOnPlayEvent();
} }
} }
if( isVisible() )
ShowWindow(_inplacewnd, SW_SHOW);
return S_OK; return S_OK;
}; };
...@@ -914,7 +915,7 @@ BOOL VLCPlugin::hasFocus(void) ...@@ -914,7 +915,7 @@ BOOL VLCPlugin::hasFocus(void)
void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev, void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds) HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds)
{ {
if( getVisible() ) if( isVisible() )
{ {
long width = lprcBounds->right-lprcBounds->left; long width = lprcBounds->right-lprcBounds->left;
long height = lprcBounds->bottom-lprcBounds->top; long height = lprcBounds->bottom-lprcBounds->top;
...@@ -976,7 +977,7 @@ void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev, ...@@ -976,7 +977,7 @@ void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect) void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect)
{ {
if( getVisible() ) if( isVisible() )
{ {
/** if VLC is playing, it may not display any VIDEO content /** if VLC is playing, it may not display any VIDEO content
** hence, draw control logo*/ ** hence, draw control logo*/
......
...@@ -110,10 +110,11 @@ public: ...@@ -110,10 +110,11 @@ public:
inline BOOL getAutoLoop(void) { return _b_autoloop;}; inline BOOL getAutoLoop(void) { return _b_autoloop;};
void setVolume(int volume); void setVolume(int volume);
BOOL getVolume(void) { return _i_volume; }; int getVolume(void) { return _i_volume; };
void setVisible(BOOL fVisible); void setVisible(BOOL fVisible);
BOOL getVisible(void) { return _b_visible; }; BOOL getVisible(void) { return _b_visible; };
BOOL isVisible(void) { return _b_visible || (! _b_usermode); };
void setTime(int time); void setTime(int time);
int getTime(void) { return _i_time; }; int getTime(void) { return _i_time; };
......
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