From 9e8a6f48059298dea4d0dd21db132077babfb5f0 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sun, 5 Jul 2020 18:33:08 +0200 Subject: [PATCH] Add logging to monitor enumeration --- AdaptiveBrightness/monitor.hpp | 1 + AdaptiveBrightness/monitor_control_win.cpp | 2 ++ AdaptiveBrightness/monitor_win.cpp | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/AdaptiveBrightness/monitor.hpp b/AdaptiveBrightness/monitor.hpp index 57cf27f..54af96d 100644 --- a/AdaptiveBrightness/monitor.hpp +++ b/AdaptiveBrightness/monitor.hpp @@ -17,6 +17,7 @@ extern BOOL enumMonitorsCallback(HMONITOR, HDC, LPRECT, LPARAM); class Monitor { public: Monitor() = delete; + ~Monitor(); private: struct PhysicalMonitor { diff --git a/AdaptiveBrightness/monitor_control_win.cpp b/AdaptiveBrightness/monitor_control_win.cpp index 4df4469..4e8b012 100644 --- a/AdaptiveBrightness/monitor_control_win.cpp +++ b/AdaptiveBrightness/monitor_control_win.cpp @@ -81,6 +81,8 @@ static BOOL enumMonitorsCallback(HMONITOR hMonitor, [[maybe_unused]] HDC hDC, [[ std::vector enumerateMonitors() { + qDebug(ltr("Enumerating monitors")); + std::vector monitors; if(!EnumDisplayMonitors(nullptr, nullptr, detail::enumMonitorsCallback, reinterpret_cast(&monitors))) { diff --git a/AdaptiveBrightness/monitor_win.cpp b/AdaptiveBrightness/monitor_win.cpp index 91a9d2c..7532ffc 100644 --- a/AdaptiveBrightness/monitor_win.cpp +++ b/AdaptiveBrightness/monitor_win.cpp @@ -2,10 +2,27 @@ #ifdef _MSC_VER + #include + #include + + #include "log_tr.hpp" + Monitor::Monitor(HMONITOR hMonitor, PHYSICAL_MONITOR physicalMonitor) : m_hMonitor(hMonitor) , m_physicalMonitor(physicalMonitor.hPhysicalMonitor, physicalMonitor.szPhysicalMonitorDescription) { + qInfo(ltr("Creating monitor '%1' with handle '0x%2' and physical handle '0x%3'") + .arg(m_physicalMonitor.name) + .arg(reinterpret_cast(m_hMonitor), 0, 16) + .arg(reinterpret_cast(m_physicalMonitor.handle), 0, 16)); +} + +Monitor::~Monitor() +{ + qDebug(ltr("Destroying monitor '%1' with handle '0x%2' and physical handle '0x%3'") + .arg(m_physicalMonitor.name) + .arg(reinterpret_cast(m_hMonitor), 0, 16) + .arg(reinterpret_cast(m_physicalMonitor.handle), 0, 16)); } #endif