Add logging to monitor enumeration

This commit is contained in:
BlackMark 2020-07-05 18:33:08 +02:00
parent 1e7e0b4e6d
commit 9e8a6f4805
3 changed files with 20 additions and 0 deletions

View File

@ -17,6 +17,7 @@ extern BOOL enumMonitorsCallback(HMONITOR, HDC, LPRECT, LPARAM);
class Monitor {
public:
Monitor() = delete;
~Monitor();
private:
struct PhysicalMonitor {

View File

@ -81,6 +81,8 @@ static BOOL enumMonitorsCallback(HMONITOR hMonitor, [[maybe_unused]] HDC hDC, [[
std::vector<Monitor> enumerateMonitors()
{
qDebug(ltr("Enumerating monitors"));
std::vector<Monitor> monitors;
if(!EnumDisplayMonitors(nullptr, nullptr, detail::enumMonitorsCallback, reinterpret_cast<LPARAM>(&monitors))) {

View File

@ -2,10 +2,27 @@
#ifdef _MSC_VER
#include <QtDebug>
#include <QtGlobal>
#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<qulonglong>(m_hMonitor), 0, 16)
.arg(reinterpret_cast<qulonglong>(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<qulonglong>(m_hMonitor), 0, 16)
.arg(reinterpret_cast<qulonglong>(m_physicalMonitor.handle), 0, 16));
}
#endif