1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-23 23:21:08 +01:00

Weather: Fixed display issues in RTL layouts (#954)

This commit is contained in:
Valentin Radu 2022-03-01 15:01:30 +02:00
parent f9680fca0d
commit 38650ccab8
3 changed files with 94 additions and 85 deletions

View File

@ -265,7 +265,7 @@ HRESULT STDMETHODCALLTYPE _ep_weather_ReboundBrowser(EPWeather* _this, LONG64 dw
DWORD dwTextScaleFactor = epw_Weather_GetTextScaleFactor(_this);
bounds.left = 0 - MulDiv(MulDiv(167, dpi, 96), dwTextScaleFactor, 100);
bounds.top = 0 - MulDiv(MulDiv(178, dpi, 96), dwTextScaleFactor, 100);
bounds.right = MulDiv(MulDiv(1333, dpi, 96), dwTextScaleFactor, 100);// 5560;
bounds.right = MulDiv(MulDiv((!InterlockedAdd64(&_this->dwTextDir, 0) ? 1333 : 705), dpi, 96), dwTextScaleFactor, 100);// 5560;
bounds.bottom = MulDiv(MulDiv(600, dpi, 96), dwTextScaleFactor, 100);// 15600;
}
if (_this->pCoreWebView2Controller)
@ -427,9 +427,15 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2Exec
epw_Weather_LockData(_this);
WCHAR* wszHeight = pResultObjectAsJson + 1;
WCHAR* wszTextDir = pResultObjectAsJson + 1;
if (wszTextDir)
{
WCHAR* wszHeight = wcschr(wszTextDir, L'#');
if (wszHeight)
{
wszHeight[0] = 0;
wszHeight++;
InterlockedExchange64(&_this->dwTextDir, wcsstr(wszTextDir, L"rtl"));
WCHAR* wszTemperature = wcschr(wszHeight, L'#');
if (wszTemperature)
{
@ -531,6 +537,7 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2Exec
}
}
}
}
epw_Weather_UnlockData(_this);
}

View File

@ -52,6 +52,7 @@ typedef interface EPWeather
LONG64 dwGeolocationMode;
LONG64 dwWindowCornerPreference;
LONG64 dwDevMode;
LONG64 dwTextDir;
HANDLE hMutexData; // protects the following:
DWORD cbTemperature;

View File

@ -63,6 +63,7 @@ function ep_weather_getData(imageBitmap, ch) {\n\
}\n\
}\n\
let res = (\n\
document.documentElement.getAttribute(\"dir\") + \"#\" + \n\
document.getElementsByClassName(\"ULSxyf\")[0].offsetHeight + \"#\" + \n\
document.getElementById(ch.includes('x') ? \"wob_ttm\" : \"wob_tm\").innerText + \"#\" + \n\
Array.from(document.getElementsByClassName('wob-unit')[0].getElementsByTagName('span')).filter(e => e.className == 'wob_t').filter(e => !e.style.display.toString().includes(\"none\"))[0].innerText + \"#\" + \n\