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