Cogs.Core
Monitor.Windows.cpp
1#include "Monitor.h"
2#include "Unicode.h"
3
4#include <vector>
5
6#include <Windows.h>
7
8void Cogs::Monitor::enumerate() {
9 monitors.clear();
10
11 EnumDisplayMonitors(nullptr, nullptr, &callback, 0);
12}
13
14BOOL Cogs::Monitor::callback(HMONITOR monitor, HDC, RECT* coords, LPARAM) {
15 monitors.push_back({});
16
17 Monitor& m = monitors.back();
18 MONITORINFOEXW info = {};
19
20 info.cbSize = sizeof(info);
21 GetMonitorInfoW(monitor, &info);
22
23 m.identifier = monitor;
24 m.name = narrow(info.szDevice);
25 m.position = glm::ivec2(coords->left, coords->top);
26 m.size = glm::ivec2(coords->right - coords->left, coords->bottom - coords->top);
27 m.primary = (info.dwFlags & MONITORINFOF_PRIMARY) ? true : false;
28 return true;
29}