From 4ff7e4150f623bd54f1f11ee53ebcca0f1d04a5c Mon Sep 17 00:00:00 2001 From: Seraphima Zykova Date: Wed, 23 Feb 2022 10:20:21 +0300 Subject: [PATCH] [AlwaysOnTop] Added error description to logs (#16514) --- .../alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp b/src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp index ded13bb920..0be570797e 100644 --- a/src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp +++ b/src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp @@ -310,15 +310,28 @@ bool AlwaysOnTop::PinTopmostWindow(HWND window) const noexcept { if (!SetProp(window, NonLocalizable::WINDOW_IS_PINNED_PROP, (HANDLE)1)) { - Logger::error(L"SetProp failed"); + Logger::error(L"SetProp failed, {}", get_last_error_or_default(GetLastError())); } - return SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + + auto res = SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + if (!res) + { + Logger::error(L"Failed to pin window, {}", get_last_error_or_default(GetLastError())); + } + + return res; } bool AlwaysOnTop::UnpinTopmostWindow(HWND window) const noexcept { RemoveProp(window, NonLocalizable::WINDOW_IS_PINNED_PROP); - return SetWindowPos(window, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + auto res = SetWindowPos(window, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + if (!res) + { + Logger::error(L"Failed to unpin window, {}", get_last_error_or_default(GetLastError())); + } + + return res; } bool AlwaysOnTop::IsTracked(HWND window) const noexcept