bsnes/hiro/windows/monitor.cpp
Tim Allen f0c17ffc0d Update to v094r24 release.
byuu says:

Finally!! Compilation works once again on Windows.

However, it's pretty buggy. Modality isn't really working right, you can
still poke at other windows, but when you select ListView items, they
redraw as empty boxes (need to process WM_DRAWITEM before checking
modality.)

The program crashes when you close it (probably a ruby driver's term()
function, that's what it usually is.)

The Layout::setEnabled(false) call isn't working right, so you get that
annoying chiming sound and cursor movement when mapping keyboard keys to
game inputs.

The column sizing seems off a bit on first display for the Hotkeys tab.

And probably lots more.
2015-06-16 20:30:04 +10:00

48 lines
1.3 KiB
C++

#if defined(Hiro_Monitor)
namespace hiro {
struct MonitorInfo {
unsigned monitor = 0;
unsigned primary = 0;
unsigned index = 0;
Geometry geometry;
};
static auto CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -> BOOL {
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;
}
auto pMonitor::count() -> unsigned {
return GetSystemMetrics(SM_CMONITORS);
}
auto pMonitor::geometry(unsigned monitor) -> Geometry {
MonitorInfo info;
info.monitor = monitor;
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&info);
return info.geometry;
}
auto pMonitor::primary() -> unsigned {
MonitorInfo info;
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&info);
return info.primary;
}
}
#endif