Skip to content

Commit

Permalink
24.3.9 WebView2.1.0.2365.46
Browse files Browse the repository at this point in the history
  • Loading branch information
tablacus committed Mar 9, 2024
1 parent b0fd20f commit 41e109e
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 25 deletions.
2 changes: 1 addition & 1 deletion tewv/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#define STRING(str) STRING2(str)
#define STRING2(str) #str
#define VER_Y 24
#define VER_M 1
#define VER_M 3
#define VER_D 9
#define VER_Z 0
2 changes: 1 addition & 1 deletion tewv/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.WebView2" version="1.0.1722.45" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.2365.46" targetFramework="native" />
</packages>
96 changes: 75 additions & 21 deletions tewv/tewv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ CteBase::CteBase()
m_pDocument = NULL;
m_webviewController = NULL;
m_webviewWindow = NULL;
#ifdef USE_DRAGDROP
m_webviewEnvironment3 = NULL;
m_webviewCompositionController3 = NULL;
#endif
}

CteBase::~CteBase()
Expand All @@ -451,7 +455,20 @@ CteBase::~CteBase()
SafeRelease(&m_pDocument);
SafeRelease(&m_webviewController);
SafeRelease(&m_webviewWindow);
#ifdef USE_DRAGDROP
SafeRelease(&m_webviewCompositionController3);
SafeRelease(&m_webviewEnvironment3);
#endif
}

#ifdef USE_DRAGDROP
VOID CteBase::OffsetPointToWebView(LPPOINT ppt)
{
HWND hwnd;
GetWindow(&hwnd);
::ScreenToClient(hwnd, ppt);
}
#endif

STDMETHODIMP CteBase::QueryInterface(REFIID riid, void **ppvObject)
{
Expand All @@ -473,6 +490,9 @@ STDMETHODIMP CteBase::QueryInterface(REFIID riid, void **ppvObject)
QITABENT(CteBase, IServiceProvider),
QITABENT(CteBase, ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler),
QITABENT(CteBase, ICoreWebView2CreateCoreWebView2ControllerCompletedHandler),
#ifdef USE_DRAGDROP
QITABENT(CteBase, ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler),
#endif
QITABENT(CteBase, ICoreWebView2DocumentTitleChangedEventHandler),
QITABENT(CteBase, ICoreWebView2NavigationCompletedEventHandler),
{ 0 }
Expand Down Expand Up @@ -797,7 +817,7 @@ STDMETHODIMP CteBase::get_HWND(SHANDLE_PTR *pHWND)
HWND hwnd;
HRESULT hr = GetWindow(&hwnd);
*pHWND = (HANDLE_PTR)hwnd;
return S_OK;
return hr;
}

STDMETHODIMP CteBase::get_FullName(BSTR *FullName)
Expand Down Expand Up @@ -964,6 +984,11 @@ STDMETHODIMP CteBase::put_RegisterAsDropTarget(VARIANT_BOOL bRegister)
pDocHostUIHandler->GetDropTarget(this, &pDropTarget);
RegisterDragDrop(hwnd, pDropTarget);
pDropTarget->Release();
#ifdef USE_DRAGDROP
if (m_webviewEnvironment3) {
m_webviewEnvironment3->CreateCoreWebView2CompositionController(m_hwndParent, this);
}
#endif
}
}
return S_OK;
Expand Down Expand Up @@ -1067,8 +1092,9 @@ STDMETHODIMP CteBase::DoVerb(LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSit
}
auto options = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>();
if (pszProxyServer[0]) {
lstrcat(pszSetting, L" --proxy-server=");
lstrcat(pszSetting, L" --proxy-server=\"");
lstrcat(pszSetting, pszProxyServer);
lstrcat(pszSetting, L"\"");
}
options->put_AdditionalBrowserArguments(pszSetting);
#ifdef _DEBUG
Expand Down Expand Up @@ -1144,28 +1170,17 @@ STDMETHODIMP CteBase::SetColorScheme(LOGPALETTE *pLogpal)
//IOleWindow
STDMETHODIMP CteBase::GetWindow(HWND *phwnd)
{
HRESULT hr = E_FAIL;
if (m_webviewController) {
HWND hwnd1, hwnd = NULL;
hr = m_webviewController->get_ParentWindow(&hwnd1);
if (hr == S_OK) {
hwnd = hwnd1;
hwnd1 = FindWindowEx(hwnd1, NULL, L"Chrome_WidgetWin_0", NULL);
if (hwnd1) {
hwnd = hwnd1;
hwnd1 = FindWindowEx(hwnd1, NULL, L"Chrome_WidgetWin_1", NULL);
if (hwnd1) {
hwnd = hwnd1;
hwnd1 = FindWindowEx(hwnd1, NULL, L"Chrome_RenderWidgetHostHWND", NULL);
if (hwnd1) {
hwnd = hwnd1;
}
}
if (m_hwndParent) {
*phwnd = FindWindowEx(m_hwndParent, NULL, L"Chrome_WidgetWin_0", NULL);
if (*phwnd) {
*phwnd = FindWindowEx(*phwnd, NULL, L"Chrome_WidgetWin_1", NULL);
if (*phwnd) {
*phwnd = FindWindowEx(*phwnd, NULL, L"Chrome_RenderWidgetHostHWND", NULL);
return S_OK;
}
}
*phwnd = hwnd;
}
return hr;
return E_FAIL;
}

STDMETHODIMP CteBase::ContextSensitiveHelp(BOOL fEnterMode)
Expand Down Expand Up @@ -1195,6 +1210,7 @@ STDMETHODIMP CteBase::SetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
int deviceYDPI = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(m_hwndParent, hdc);
m_webviewController->SetBoundsAndZoomFactor(*lprcClipRect, 96.0 / deviceYDPI);
CopyRect(&m_webviewBounds, lprcClipRect);
return S_OK;
}

Expand All @@ -1209,21 +1225,47 @@ STDMETHODIMP CteBase::ReactivateAndUndo(void)
//IDropTarget
STDMETHODIMP CteBase::DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
{
#ifdef USE_DRAGDROP
if (m_webviewCompositionController3) {
POINT ptc = { pt.x, pt.y };
OffsetPointToWebView(&ptc);
return m_webviewCompositionController3->DragEnter(pDataObj, grfKeyState, ptc, pdwEffect);
}
#endif
return E_NOTIMPL;
}

STDMETHODIMP CteBase::DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
{
#ifdef USE_DRAGDROP
if (m_webviewCompositionController3) {
POINT ptc = { pt.x, pt.y };
OffsetPointToWebView(&ptc);
return m_webviewCompositionController3->DragOver(grfKeyState, ptc, pdwEffect);
}
#endif
return E_NOTIMPL;
}

STDMETHODIMP CteBase::DragLeave()
{
#ifdef USE_DRAGDROP
if (m_webviewCompositionController3) {
return m_webviewCompositionController3->DragLeave();
}
#endif
return E_NOTIMPL;
}

STDMETHODIMP CteBase::Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
{
#ifdef USE_DRAGDROP
if (m_webviewCompositionController3) {
POINT ptc = { pt.x, pt.y };
OffsetPointToWebView(&ptc);
return m_webviewCompositionController3->Drop(pDataObj, grfKeyState, ptc, pdwEffect);
}
#endif
return E_NOTIMPL;
}

Expand Down Expand Up @@ -1325,6 +1367,9 @@ STDMETHODIMP CteBase::QueryService(REFGUID guidService, REFIID riid, void **ppv)
STDMETHODIMP CteBase::Invoke(HRESULT result, ICoreWebView2Environment *created_environment)
{
created_environment->CreateCoreWebView2Controller(m_hwndParent, this);
#ifdef USE_DRAGDROP
created_environment->QueryInterface(IID_PPV_ARGS(&m_webviewEnvironment3));
#endif
return S_OK;
}

Expand Down Expand Up @@ -1362,6 +1407,15 @@ STDMETHODIMP CteBase::Invoke(HRESULT result, ICoreWebView2Controller *createdCon
return S_OK;
}

#ifdef USE_DRAGDROP
//ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler
STDMETHODIMP CteBase::Invoke(HRESULT result, ICoreWebView2CompositionController *createdController)
{
SafeRelease(&m_webviewCompositionController3);
return createdController->QueryInterface(IID_PPV_ARGS(&m_webviewCompositionController3));
}
#endif

//ICoreWebView2ExecuteScriptCompletedHandler
STDMETHODIMP CteBase::Invoke(HRESULT result, LPCWSTR resultObjectAsJson)
{
Expand Down
19 changes: 19 additions & 0 deletions tewv/tewv.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#define DISPID_TE_MAX TE_VI
#define MAX_PATHEX 32768

//#define USE_DRAGDROP 1

//Tablacus Explorer (Edge)
const CLSID CLSID_WebBrowserExt = {0x55bbf1b8, 0x0d30, 0x4908, { 0xbe, 0x0c, 0xd5, 0x76, 0x61, 0x2a, 0x0f, 0x48}};
// {BD34E79B-963F-4AFB-B03E-C5BD289B5080}
Expand All @@ -53,6 +55,9 @@ class CteBase : public IWebBrowser2, public IOleObject, public IOleInPlaceObject
public IDropTarget, public IShellBrowser,
public ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler,
public ICoreWebView2CreateCoreWebView2ControllerCompletedHandler,
#ifdef USE_DRAGDROP
public ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler,
#endif
public ICoreWebView2ExecuteScriptCompletedHandler,
public ICoreWebView2DocumentTitleChangedEventHandler,
public ICoreWebView2NavigationStartingEventHandler,
Expand Down Expand Up @@ -189,6 +194,10 @@ class CteBase : public IWebBrowser2, public IOleObject, public IOleInPlaceObject
STDMETHODIMP Invoke(HRESULT result, ICoreWebView2Environment *created_environment);
//ICoreWebView2CreateCoreWebView2ControllerCompletedHandler
STDMETHODIMP Invoke(HRESULT result, ICoreWebView2Controller *createdController);
#ifdef USE_DRAGDROP
//ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler
STDMETHODIMP Invoke(HRESULT result, ICoreWebView2CompositionController *createdController);
#endif
//ICoreWebView2ExecuteScriptCompletedHandler
STDMETHODIMP Invoke(HRESULT result, LPCWSTR resultObjectAsJson);
//ICoreWebView2DocumentTitleChangedEventHandler
Expand All @@ -200,18 +209,28 @@ class CteBase : public IWebBrowser2, public IOleObject, public IOleInPlaceObject

CteBase();
~CteBase();

#ifdef USE_DRAGDROP
VOID OffsetPointToWebView(LPPOINT point);
#endif
private:
IOleClientSite *m_pOleClientSite;
IDispatch *m_pdisp;
HWND m_hwndParent;
ICoreWebView2Controller *m_webviewController;
ICoreWebView2 *m_webviewWindow;
#ifdef USE_DRAGDROP
ICoreWebView2Environment3 *m_webviewEnvironment3;
ICoreWebView2CompositionController3 *m_webviewCompositionController3;
#endif
EventRegistrationToken m_documentTitleChangedToken;
EventRegistrationToken m_navigationStartingToken;
EventRegistrationToken m_navigationCompletedToken;
BSTR m_bstrPath;
// HANDLE m_hOleDropTargetInterface;

IDispatch *m_pDocument;
RECT m_webviewBounds;
LONG m_cRef;
};

Expand Down
4 changes: 2 additions & 2 deletions tewv/tewv.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.1722.45\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.1722.45\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.2365.46\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.2365.46\build\native\Microsoft.Web.WebView2.targets')" />
</ImportGroup>
<PropertyGroup>
<WebView2LoaderPreference>Static</WebView2LoaderPreference>
Expand All @@ -166,6 +166,6 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1722.45\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1722.45\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.2365.46\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.2365.46\build\native\Microsoft.Web.WebView2.targets'))" />
</Target>
</Project>

0 comments on commit 41e109e

Please sign in to comment.