summaryrefslogtreecommitdiffstats
path: root/widget
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-09-17 15:28:59 +0000
committerMoonchild <moonchild@palemoon.org>2020-09-21 11:05:03 +0000
commite2e483ac47ae12c9d4151d7936d2f793fbc60620 (patch)
treeafd9024a78030eb8e4680ad453b7d7ced0c5cdd2 /widget
parent892a2d9655650616c361750a4d1a49f7d7914ad2 (diff)
downloadUXP-e2e483ac47ae12c9d4151d7936d2f793fbc60620.tar
UXP-e2e483ac47ae12c9d4151d7936d2f793fbc60620.tar.gz
UXP-e2e483ac47ae12c9d4151d7936d2f793fbc60620.tar.lz
UXP-e2e483ac47ae12c9d4151d7936d2f793fbc60620.tar.xz
UXP-e2e483ac47ae12c9d4151d7936d2f793fbc60620.zip
Issue #1653 - Part 2: Stop indirectly loading DWM functions through WinUtils.
Diffstat (limited to 'widget')
-rw-r--r--widget/windows/TaskbarPreview.cpp14
-rw-r--r--widget/windows/WinUtils.cpp31
-rw-r--r--widget/windows/WinUtils.h25
-rw-r--r--widget/windows/nsUXThemeData.cpp12
-rw-r--r--widget/windows/nsWindow.cpp10
5 files changed, 18 insertions, 74 deletions
diff --git a/widget/windows/TaskbarPreview.cpp b/widget/windows/TaskbarPreview.cpp
index 6c15df2e0..b07b8039f 100644
--- a/widget/windows/TaskbarPreview.cpp
+++ b/widget/windows/TaskbarPreview.cpp
@@ -139,7 +139,7 @@ TaskbarPreview::Invalidate() {
return NS_OK;
HWND previewWindow = PreviewWindow();
- return FAILED(WinUtils::dwmInvalidateIconicBitmapsPtr(previewWindow))
+ return FAILED(DwmInvalidateIconicBitmaps(previewWindow))
? NS_ERROR_FAILURE
: NS_OK;
}
@@ -284,13 +284,13 @@ TaskbarPreview::GetWindowHook() {
void
TaskbarPreview::EnableCustomDrawing(HWND aHWND, bool aEnable) {
BOOL enabled = aEnable;
- WinUtils::dwmSetWindowAttributePtr(
+ DwmSetWindowAttribute(
aHWND,
DWMWA_FORCE_ICONIC_REPRESENTATION,
&enabled,
sizeof(enabled));
- WinUtils::dwmSetWindowAttributePtr(
+ DwmSetWindowAttribute(
aHWND,
DWMWA_HAS_ICONIC_BITMAP,
&enabled,
@@ -385,11 +385,11 @@ TaskbarPreviewCallback::Done(nsISupports *aCanvas, bool aDrawBorder) {
POINT pptClient = { 0, 0 };
HRESULT hr;
if (!mIsThumbnail) {
- hr = WinUtils::dwmSetIconicLivePreviewBitmapPtr(mPreview->PreviewWindow(),
- hBitmap, &pptClient, flags);
+ hr = DwmSetIconicLivePreviewBitmap(mPreview->PreviewWindow(),
+ hBitmap, &pptClient, flags);
} else {
- hr = WinUtils::dwmSetIconicThumbnailPtr(mPreview->PreviewWindow(),
- hBitmap, flags);
+ hr = DwmSetIconicThumbnail(mPreview->PreviewWindow(),
+ hBitmap, flags);
}
MOZ_ASSERT(SUCCEEDED(hr));
return NS_OK;
diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp
index 6d9aab50d..28033193f 100644
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -423,20 +423,6 @@ WinUtils::SHCreateItemFromParsingNamePtr WinUtils::sCreateItemFromParsingName =
// on them during shutdown anyway.
static const wchar_t kShellLibraryName[] = L"shell32.dll";
static HMODULE sShellDll = nullptr;
-static const wchar_t kDwmLibraryName[] = L"dwmapi.dll";
-static HMODULE sDwmDll = nullptr;
-
-WinUtils::DwmExtendFrameIntoClientAreaProc WinUtils::dwmExtendFrameIntoClientAreaPtr = nullptr;
-WinUtils::DwmIsCompositionEnabledProc WinUtils::dwmIsCompositionEnabledPtr = nullptr;
-WinUtils::DwmSetIconicThumbnailProc WinUtils::dwmSetIconicThumbnailPtr = nullptr;
-WinUtils::DwmSetIconicLivePreviewBitmapProc WinUtils::dwmSetIconicLivePreviewBitmapPtr = nullptr;
-WinUtils::DwmGetWindowAttributeProc WinUtils::dwmGetWindowAttributePtr = nullptr;
-WinUtils::DwmSetWindowAttributeProc WinUtils::dwmSetWindowAttributePtr = nullptr;
-WinUtils::DwmInvalidateIconicBitmapsProc WinUtils::dwmInvalidateIconicBitmapsPtr = nullptr;
-WinUtils::DwmDefWindowProcProc WinUtils::dwmDwmDefWindowProcPtr = nullptr;
-WinUtils::DwmGetCompositionTimingInfoProc WinUtils::dwmGetCompositionTimingInfoPtr = nullptr;
-WinUtils::DwmFlushProc WinUtils::dwmFlushProcPtr = nullptr;
-
// Prefix for path used by NT calls.
const wchar_t kNTPrefix[] = L"\\??\\";
const size_t kNTPrefixLen = ArrayLength(kNTPrefix) - 1;
@@ -460,23 +446,6 @@ static NtTestAlertPtr sNtTestAlert = nullptr;
void
WinUtils::Initialize()
{
- if (!sDwmDll) {
- sDwmDll = ::LoadLibraryW(kDwmLibraryName);
-
- if (sDwmDll) {
- dwmExtendFrameIntoClientAreaPtr = (DwmExtendFrameIntoClientAreaProc)::GetProcAddress(sDwmDll, "DwmExtendFrameIntoClientArea");
- dwmIsCompositionEnabledPtr = (DwmIsCompositionEnabledProc)::GetProcAddress(sDwmDll, "DwmIsCompositionEnabled");
- dwmSetIconicThumbnailPtr = (DwmSetIconicThumbnailProc)::GetProcAddress(sDwmDll, "DwmSetIconicThumbnail");
- dwmSetIconicLivePreviewBitmapPtr = (DwmSetIconicLivePreviewBitmapProc)::GetProcAddress(sDwmDll, "DwmSetIconicLivePreviewBitmap");
- dwmGetWindowAttributePtr = (DwmGetWindowAttributeProc)::GetProcAddress(sDwmDll, "DwmGetWindowAttribute");
- dwmSetWindowAttributePtr = (DwmSetWindowAttributeProc)::GetProcAddress(sDwmDll, "DwmSetWindowAttribute");
- dwmInvalidateIconicBitmapsPtr = (DwmInvalidateIconicBitmapsProc)::GetProcAddress(sDwmDll, "DwmInvalidateIconicBitmaps");
- dwmDwmDefWindowProcPtr = (DwmDefWindowProcProc)::GetProcAddress(sDwmDll, "DwmDefWindowProc");
- dwmGetCompositionTimingInfoPtr = (DwmGetCompositionTimingInfoProc)::GetProcAddress(sDwmDll, "DwmGetCompositionTimingInfo");
- dwmFlushProcPtr = (DwmFlushProc)::GetProcAddress(sDwmDll, "DwmFlush");
- }
- }
-
if (IsWin10OrLater()) {
HMODULE user32Dll = ::GetModuleHandleW(L"user32");
if (user32Dll) {
diff --git a/widget/windows/WinUtils.h b/widget/windows/WinUtils.h
index 9aa2c1c8a..1281171be 100644
--- a/widget/windows/WinUtils.h
+++ b/widget/windows/WinUtils.h
@@ -470,31 +470,6 @@ public:
*/
static bool ResolveJunctionPointsAndSymLinks(std::wstring& aPath);
- /**
- * dwmapi.dll function typedefs and declarations
- */
- typedef HRESULT (WINAPI*DwmExtendFrameIntoClientAreaProc)(HWND hWnd, const MARGINS *pMarInset);
- typedef HRESULT (WINAPI*DwmIsCompositionEnabledProc)(BOOL *pfEnabled);
- typedef HRESULT (WINAPI*DwmSetIconicThumbnailProc)(HWND hWnd, HBITMAP hBitmap, DWORD dwSITFlags);
- typedef HRESULT (WINAPI*DwmSetIconicLivePreviewBitmapProc)(HWND hWnd, HBITMAP hBitmap, POINT *pptClient, DWORD dwSITFlags);
- typedef HRESULT (WINAPI*DwmGetWindowAttributeProc)(HWND hWnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
- typedef HRESULT (WINAPI*DwmSetWindowAttributeProc)(HWND hWnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
- typedef HRESULT (WINAPI*DwmInvalidateIconicBitmapsProc)(HWND hWnd);
- typedef HRESULT (WINAPI*DwmDefWindowProcProc)(HWND hWnd, UINT msg, LPARAM lParam, WPARAM wParam, LRESULT *aRetValue);
- typedef HRESULT (WINAPI*DwmGetCompositionTimingInfoProc)(HWND hWnd, DWM_TIMING_INFO *info);
- typedef HRESULT (WINAPI*DwmFlushProc)(void);
-
- static DwmExtendFrameIntoClientAreaProc dwmExtendFrameIntoClientAreaPtr;
- static DwmIsCompositionEnabledProc dwmIsCompositionEnabledPtr;
- static DwmSetIconicThumbnailProc dwmSetIconicThumbnailPtr;
- static DwmSetIconicLivePreviewBitmapProc dwmSetIconicLivePreviewBitmapPtr;
- static DwmGetWindowAttributeProc dwmGetWindowAttributePtr;
- static DwmSetWindowAttributeProc dwmSetWindowAttributePtr;
- static DwmInvalidateIconicBitmapsProc dwmInvalidateIconicBitmapsPtr;
- static DwmDefWindowProcProc dwmDwmDefWindowProcPtr;
- static DwmGetCompositionTimingInfoProc dwmGetCompositionTimingInfoPtr;
- static DwmFlushProc dwmFlushProcPtr;
-
static void Initialize();
static bool ShouldHideScrollbars();
diff --git a/widget/windows/nsUXThemeData.cpp b/widget/windows/nsUXThemeData.cpp
index 4d9ac9570..ce2777585 100644
--- a/widget/windows/nsUXThemeData.cpp
+++ b/widget/windows/nsUXThemeData.cpp
@@ -156,10 +156,10 @@ nsUXThemeData::UpdateTitlebarInfo(HWND aWnd)
if (!sTitlebarInfoPopulatedAero && nsUXThemeData::CheckForCompositor()) {
RECT captionButtons;
- if (SUCCEEDED(WinUtils::dwmGetWindowAttributePtr(aWnd,
- DWMWA_CAPTION_BUTTON_BOUNDS,
- &captionButtons,
- sizeof(captionButtons)))) {
+ if (SUCCEEDED(DwmGetWindowAttribute(aWnd,
+ DWMWA_CAPTION_BUTTON_BOUNDS,
+ &captionButtons,
+ sizeof(captionButtons)))) {
sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cx = captionButtons.right - captionButtons.left - 3;
sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cy = (captionButtons.bottom - captionButtons.top) - 1;
sTitlebarInfoPopulatedAero = true;
@@ -293,8 +293,8 @@ bool nsUXThemeData::IsHighContrastOn()
bool nsUXThemeData::CheckForCompositor(bool aUpdateCache)
{
static BOOL sCachedValue = FALSE;
- if (aUpdateCache && WinUtils::dwmIsCompositionEnabledPtr) {
- WinUtils::dwmIsCompositionEnabledPtr(&sCachedValue);
+ if (aUpdateCache) {
+ DwmIsCompositionEnabled(&sCachedValue);
}
return sCachedValue;
}
diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp
index 122d18686..907d8b9a5 100644
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -846,9 +846,9 @@ nsWindow::Create(nsIWidget* aParent,
return NS_ERROR_FAILURE;
}
- if (mIsRTL && WinUtils::dwmSetWindowAttributePtr) {
+ if (mIsRTL) {
DWORD dwAttribute = TRUE;
- WinUtils::dwmSetWindowAttributePtr(mWnd, DWMWA_NONCLIENT_RTL_LAYOUT, &dwAttribute, sizeof dwAttribute);
+ DwmSetWindowAttribute(mWnd, DWMWA_NONCLIENT_RTL_LAYOUT, &dwAttribute, sizeof dwAttribute);
}
if (!IsPlugin() &&
@@ -3113,8 +3113,8 @@ void nsWindow::UpdateGlass()
// Extends the window frame behind the client area
if (nsUXThemeData::CheckForCompositor()) {
- WinUtils::dwmExtendFrameIntoClientAreaPtr(mWnd, &margins);
- WinUtils::dwmSetWindowAttributePtr(mWnd, DWMWA_NCRENDERING_POLICY, &policy, sizeof policy);
+ DwmExtendFrameIntoClientArea(mWnd, &margins);
+ DwmSetWindowAttribute(mWnd, DWMWA_NCRENDERING_POLICY, &policy, sizeof policy);
}
}
#endif
@@ -4961,7 +4961,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
/* We don't do this for win10 glass with a custom titlebar,
* in order to avoid the caption buttons breaking. */
!(IsWin10OrLater() && HasGlass()) &&
- WinUtils::dwmDwmDefWindowProcPtr(mWnd, msg, wParam, lParam, &dwmHitResult)) {
+ DwmDefWindowProc(mWnd, msg, wParam, lParam, &dwmHitResult)) {
*aRetValue = dwmHitResult;
return true;
}