diff options
Diffstat (limited to 'src/win/native')
-rw-r--r-- | src/win/native/Cursor.cpp | 4 | ||||
-rw-r--r-- | src/win/native/GodWindow.cpp | 6 | ||||
-rw-r--r-- | src/win/native/InputMethod.cpp | 34 | ||||
-rw-r--r-- | src/win/native/Window.cpp | 26 |
4 files changed, 34 insertions, 36 deletions
diff --git a/src/win/native/Cursor.cpp b/src/win/native/Cursor.cpp index ca8bb1cd..a6ab5bfc 100644 --- a/src/win/native/Cursor.cpp +++ b/src/win/native/Cursor.cpp @@ -16,8 +16,8 @@ WinCursor::~WinCursor() { if (!::DestroyCursor(handle_)) { // This is not a fetal error but might still need notice because it may // cause leak. - log::Warn("Failed to destroy a cursor. Last error code: {}", - ::GetLastError()); + log::TagWarn(log_tag, "Failed to destroy a cursor. Last error code: {}", + ::GetLastError()); } } } diff --git a/src/win/native/GodWindow.cpp b/src/win/native/GodWindow.cpp index 076954d4..8ef2788e 100644 --- a/src/win/native/GodWindow.cpp +++ b/src/win/native/GodWindow.cpp @@ -1,11 +1,11 @@ #include "cru/win/native/GodWindow.hpp" +#include "GodWindowMessage.hpp" +#include "Timer.hpp" #include "cru/common/Logger.hpp" #include "cru/win/native/Exception.hpp" #include "cru/win/native/UiApplication.hpp" #include "cru/win/native/WindowClass.hpp" -#include "GodWindowMessage.hpp" -#include "Timer.hpp" namespace cru::platform::native::win { constexpr auto god_window_class_name = L"GodWindowClass"; @@ -45,7 +45,7 @@ GodWindow::GodWindow(WinUiApplication* application) { GodWindow::~GodWindow() { if (!::DestroyWindow(hwnd_)) { // Although this could be "safely" ignore. - log::Warn("Failed to destroy god window."); + log::TagWarn(log_tag, "Failed to destroy god window."); } } diff --git a/src/win/native/InputMethod.cpp b/src/win/native/InputMethod.cpp index 2e31108e..d3d989f3 100644 --- a/src/win/native/InputMethod.cpp +++ b/src/win/native/InputMethod.cpp @@ -1,11 +1,11 @@ #include "cru/win/native/InputMethod.hpp" +#include "DpiUtil.hpp" #include "cru/common/Logger.hpp" #include "cru/platform/Check.hpp" #include "cru/win/Exception.hpp" -#include "cru/win/native/Window.hpp" #include "cru/win/String.hpp" -#include "DpiUtil.hpp" +#include "cru/win/native/Window.hpp" #include <vector> @@ -35,7 +35,7 @@ AutoHIMC& AutoHIMC::operator=(AutoHIMC&& other) { AutoHIMC::~AutoHIMC() { if (handle_) { if (!::ImmReleaseContext(hwnd_, handle_)) - log::Warn("AutoHIMC: Failed to release HIMC."); + log::TagWarn(log_tag, "Failed to release HIMC."); } } @@ -169,7 +169,7 @@ void WinInputMethodContext::EnableIME() { const auto hwnd = native_window->GetWindowHandle(); if (::ImmAssociateContextEx(hwnd, nullptr, IACE_DEFAULT) == FALSE) { - log::Warn("WinInputMethodContext: Failed to enable ime."); + log::TagWarn(log_tag, "Failed to enable ime."); } } @@ -181,13 +181,11 @@ void WinInputMethodContext::DisableIME() { AutoHIMC himc{hwnd}; if (!::ImmNotifyIME(himc.Get(), NI_COMPOSITIONSTR, CPS_COMPLETE, 0)) { - log::Warn( - "WinInputMethodContext: Failed to complete composition before disable " - "ime."); + log::TagWarn(log_tag, "Failed to complete composition before disable ime."); } if (::ImmAssociateContextEx(hwnd, nullptr, 0) == FALSE) { - log::Warn("WinInputMethodContext: Failed to disable ime."); + log::TagWarn(log_tag, "Failed to disable ime."); } } @@ -197,7 +195,7 @@ void WinInputMethodContext::CompleteComposition() { auto himc = *std::move(optional_himc); if (!::ImmNotifyIME(himc.Get(), NI_COMPOSITIONSTR, CPS_COMPLETE, 0)) { - log::Warn("WinInputMethodContext: Failed to complete composition."); + log::TagWarn(log_tag, "Failed to complete composition."); } } @@ -207,7 +205,7 @@ void WinInputMethodContext::CancelComposition() { auto himc = *std::move(optional_himc); if (!::ImmNotifyIME(himc.Get(), NI_COMPOSITIONSTR, CPS_CANCEL, 0)) { - log::Warn("WinInputMethodContext: Failed to complete composition."); + log::TagWarn(log_tag, "Failed to complete composition."); } } @@ -230,9 +228,8 @@ void WinInputMethodContext::SetCandidateWindowPosition(const Point& point) { form.ptCurrentPos = DipToPi(point); if (!::ImmSetCandidateWindow(himc.Get(), &form)) - log::Debug( - "WinInputMethodContext: Failed to set input method candidate window " - "position."); + log::TagDebug(log_tag, + "Failed to set input method candidate window position."); } IEvent<std::nullptr_t>* WinInputMethodContext::CompositionStartEvent() { @@ -261,9 +258,9 @@ void WinInputMethodContext::OnWindowNativeMessage( // I don't think this will happen because normal key strike without ime // should only trigger ascci character. If it is a charater from // supplementary planes, it should be handled with ime messages. - log::Warn( - "WinInputMethodContext: A WM_CHAR message for character from " - "supplementary planes is ignored."); + log::TagWarn(log_tag, + "A WM_CHAR message for character from supplementary " + "planes is ignored."); } else { wchar_t s[1] = {c}; auto str = platform::win::ToUtf8String({s, 1}); @@ -275,9 +272,8 @@ void WinInputMethodContext::OnWindowNativeMessage( case WM_IME_COMPOSITION: { composition_event_.Raise(nullptr); auto composition_text = GetCompositionText(); - log::Debug( - "WinInputMethodContext: WM_IME_COMPOSITION composition text:\n{}", - composition_text); + log::TagDebug(log_tag, "WM_IME_COMPOSITION composition text:\n{}", + composition_text); if (message.l_param & GCS_RESULTSTR) { auto result_string = GetResultString(); text_event_.Raise(result_string); diff --git a/src/win/native/Window.cpp b/src/win/native/Window.cpp index 9dde1af3..22505bd6 100644 --- a/src/win/native/Window.cpp +++ b/src/win/native/Window.cpp @@ -1,17 +1,17 @@ #include "cru/win/native/Window.hpp" +#include "DpiUtil.hpp" +#include "WindowD2DPainter.hpp" +#include "WindowManager.hpp" #include "cru/common/Logger.hpp" #include "cru/platform/Check.hpp" +#include "cru/win/String.hpp" #include "cru/win/native/Cursor.hpp" #include "cru/win/native/Exception.hpp" #include "cru/win/native/Keyboard.hpp" #include "cru/win/native/UiApplication.hpp" #include "cru/win/native/WindowClass.hpp" #include "cru/win/native/WindowRenderTarget.hpp" -#include "cru/win/String.hpp" -#include "DpiUtil.hpp" -#include "WindowD2DPainter.hpp" -#include "WindowManager.hpp" #include <imm.h> #include <windowsx.h> @@ -124,7 +124,7 @@ bool WinNativeWindow::ReleaseMouse() { } void WinNativeWindow::RequestRepaint() { - log::Debug("A repaint is requested."); + log::TagDebug(log_tag, "A repaint is requested."); if (!::InvalidateRect(hwnd_, nullptr, FALSE)) throw Win32Error(::GetLastError(), "Failed to invalidate window."); if (!::UpdateWindow(hwnd_)) @@ -144,19 +144,20 @@ void WinNativeWindow::SetCursor(std::shared_ptr<ICursor> cursor) { if (!::SetClassLongPtrW(hwnd_, GCLP_HCURSOR, reinterpret_cast<LONG_PTR>(cursor_->GetHandle()))) { - log::Warn( - "Failed to set cursor because failed to set class long. Last error " - "code: {}.", - ::GetLastError()); + log::TagWarn(log_tag, + "Failed to set cursor because failed to set class long. Last " + "error code: {}.", + ::GetLastError()); return; } if (!IsVisible()) return; auto lg = [](const std::string_view& reason) { - log::Warn( - "Failed to set cursor because {} when window is visible. (We need " - "to update cursor if it is inside the window.) Last error code: {}.", + log::TagWarn( + log_tag, + "Failed to set cursor because {} when window is visible. (We need to " + "update cursor if it is inside the window.) Last error code: {}.", reason, ::GetLastError()); }; @@ -353,6 +354,7 @@ void WinNativeWindow::OnDestroyInternal() { void WinNativeWindow::OnPaintInternal() { paint_event_.Raise(nullptr); ValidateRect(hwnd_, nullptr); + log::TagDebug(log_tag, "A repaint is finished."); } void WinNativeWindow::OnResizeInternal(const int new_width, |