Skip to content

Commit

Permalink
Tweaks to mitigate #1 / Eliminate the whiteness from the toolbox bitm…
Browse files Browse the repository at this point in the history
…ap to make it less ugly on non-white backgrounds
  • Loading branch information
datadiode committed Oct 1, 2023
1 parent 11ffca3 commit 48291fe
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
Binary file modified BrowserProxy/BrowserProxy.bmp
Binary file not shown.
34 changes: 29 additions & 5 deletions BrowserProxy/BrowserProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "SettingsRequestHandler.h"
#include "BrowserProxy_i.h"
#include "BrowserProxy.h"
#include <WebView2EnvironmentOptions.h>

BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_ThereEdgeWebBrowser, BrowserProxyModule)
Expand Down Expand Up @@ -177,7 +178,10 @@ BrowserProxyModule::~BrowserProxyModule()
}

if (m_controller != nullptr)
{
m_controller->remove_MoveFocusRequested(m_moveFocusRequested);
m_controller->Close();
}

#ifdef THERE
if (m_voiceTrainerProxy != nullptr)
Expand Down Expand Up @@ -268,6 +272,7 @@ LRESULT BrowserProxyModule::OnCreate(UINT, WPARAM, LPARAM, BOOL&)

WCHAR userDataFolder[MAX_PATH] = { 0 };
WCHAR browserExecutableFolder[MAX_PATH] = { 0 };
WCHAR additionalBrowserArguments[4096] = { 0 };

if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, userDataFolder)) && userDataFolder[0] != 0)
{
Expand All @@ -283,13 +288,20 @@ LRESULT BrowserProxyModule::OnCreate(UINT, WPARAM, LPARAM, BOOL&)
}

PathRenameExtension(executingHost, L".ini");
if (GetPrivateProfileString(executingFileName, L"BrowserExecutableFolder", nullptr, browserExecutableFolder, _countof(browserExecutableFolder), executingHost) == 0)
{
PathRenameExtension(executingFile, L".ini");
GetPrivateProfileString(executingFileName, L"BrowserExecutableFolder", nullptr, browserExecutableFolder, _countof(browserExecutableFolder), executingHost);
GetPrivateProfileString(executingFileName, L"AdditionalBrowserArguments", nullptr, additionalBrowserArguments, _countof(additionalBrowserArguments), executingHost);

PathRenameExtension(executingFile, L".ini");
if (*browserExecutableFolder == L'\0')
GetPrivateProfileString(executingFileName, L"BrowserExecutableFolder", nullptr, browserExecutableFolder, _countof(browserExecutableFolder), executingFile);
}
if (*additionalBrowserArguments == L'\0')
GetPrivateProfileString(executingFileName, L"AdditionalBrowserArguments", nullptr, additionalBrowserArguments, _countof(additionalBrowserArguments), executingFile);

// https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions
auto environmentOptions = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>();
environmentOptions->put_AdditionalBrowserArguments(additionalBrowserArguments);

HRESULT rc = CreateCoreWebView2EnvironmentWithOptions(browserExecutableFolder, m_userDataFolder, nullptr, this);
HRESULT rc = CreateCoreWebView2EnvironmentWithOptions(browserExecutableFolder, m_userDataFolder, environmentOptions.Get(), this);
if (FAILED(rc))
{
switch (rc)
Expand Down Expand Up @@ -574,6 +586,18 @@ HRESULT STDMETHODCALLTYPE BrowserProxyModule::Invoke(HRESULT errorCode, ICoreWeb
m_controller->put_ShouldDetectMonitorScaleChanges(false);
m_controller->put_RasterizationScale(1.0);
m_controller->put_IsVisible(m_visible);
m_controller->add_MoveFocusRequested(Callback<ICoreWebView2MoveFocusRequestedEventHandler>(
[this](ICoreWebView2Controller *sender, ICoreWebView2MoveFocusRequestedEventArgs *args) -> HRESULT
{
COREWEBVIEW2_MOVE_FOCUS_REASON reason = COREWEBVIEW2_MOVE_FOCUS_REASON_PROGRAMMATIC;
args->get_Reason(&reason);
if (reason != COREWEBVIEW2_MOVE_FOCUS_REASON_PROGRAMMATIC)
{
args->put_Handled(TRUE);
}
return S_OK;
}
).Get(), &m_moveFocusRequested);

#ifdef THERE
m_view->AddWebResourceRequestedFilter(L"https://webapps.prod.there.com/*", COREWEBVIEW2_WEB_RESOURCE_CONTEXT_DOCUMENT);
Expand Down
1 change: 1 addition & 0 deletions BrowserProxy/BrowserProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ class BrowserProxyModule: public CComObjectRootEx<CComSingleThreadModel>,
EventRegistrationToken m_windowCloseRequestedToken;
EventRegistrationToken m_domContentLoadedToken;
EventRegistrationToken m_downloadStartingToken;
EventRegistrationToken m_moveFocusRequested;
BOOL m_ready;
BOOL m_visible;
};
8 changes: 4 additions & 4 deletions BrowserProxy/BrowserProxy.rc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,2,3
PRODUCTVERSION 1,1,2,3
FILEVERSION 1,1,2,4
PRODUCTVERSION 1,1,2,4
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -76,12 +76,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "datadiode"
VALUE "FileDescription", "ActiveX proxy to Edge WebView2"
VALUE "FileVersion", "1.1.2.3"
VALUE "FileVersion", "1.1.2.4"
VALUE "InternalName", "OpennessWebView2.dll"
VALUE "LegalCopyright", "(c) Hmph! et al."
VALUE "OriginalFilename", "OpennessWebView2.dll"
VALUE "ProductName", "OpennessWebView2 Control"
VALUE "ProductVersion", "1.1.2.3"
VALUE "ProductVersion", "1.1.2.4"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 48291fe

Please sign in to comment.