2015-06-12 13:14:38 +00:00
|
|
|
#if defined(Hiro_Monitor)
|
|
|
|
|
|
|
|
namespace hiro {
|
2014-01-05 09:59:17 +00:00
|
|
|
|
|
|
|
struct MonitorInfo {
|
|
|
|
unsigned monitor = 0;
|
|
|
|
unsigned primary = 0;
|
|
|
|
unsigned index = 0;
|
|
|
|
Geometry geometry;
|
|
|
|
};
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
static auto CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -> BOOL {
|
2014-01-05 09:59:17 +00:00
|
|
|
MonitorInfo& info = *(MonitorInfo*)dwData;
|
|
|
|
MONITORINFOEX mi;
|
|
|
|
memset(&mi, 0, sizeof(MONITORINFOEX));
|
|
|
|
mi.cbSize = sizeof(MONITORINFOEX);
|
|
|
|
GetMonitorInfo(hMonitor, &mi);
|
|
|
|
string displayName = (const char*)utf8_t(mi.szDevice);
|
|
|
|
if(displayName.beginsWith(R"(\\.\DISPLAYV)")) return TRUE; //ignore pseudo-monitors
|
|
|
|
if(mi.dwFlags & MONITORINFOF_PRIMARY) info.primary = info.index;
|
|
|
|
if(info.monitor == info.index) {
|
|
|
|
info.geometry = {lprcMonitor->left, lprcMonitor->top, lprcMonitor->right - lprcMonitor->left, lprcMonitor->bottom - lprcMonitor->top};
|
|
|
|
}
|
|
|
|
info.index++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMonitor::count() -> unsigned {
|
2014-01-05 09:59:17 +00:00
|
|
|
return GetSystemMetrics(SM_CMONITORS);
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMonitor::geometry(unsigned monitor) -> Geometry {
|
2014-01-05 09:59:17 +00:00
|
|
|
MonitorInfo info;
|
|
|
|
info.monitor = monitor;
|
|
|
|
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&info);
|
|
|
|
return info.geometry;
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMonitor::primary() -> unsigned {
|
2014-01-05 09:59:17 +00:00
|
|
|
MonitorInfo info;
|
|
|
|
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&info);
|
|
|
|
return info.primary;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
|
|
|
|
#endif
|