Commit 7fef23ea authored by captainwong's avatar captainwong

add getMainMonitor

parent 761d9d42
...@@ -9,9 +9,7 @@ namespace win32 { ...@@ -9,9 +9,7 @@ namespace win32 {
struct MonitorInfo { struct MonitorInfo {
struct Resolution { struct Resolution {
int w; int w = 0, h = 0, hz = 0;
int h;
int hz;
bool operator==(const Resolution& r) const { bool operator==(const Resolution& r) const {
return w == r.w && h == r.h && hz == r.hz; return w == r.w && h == r.h && hz == r.hz;
...@@ -23,9 +21,7 @@ struct MonitorInfo { ...@@ -23,9 +21,7 @@ struct MonitorInfo {
return res; return res;
} }
bool valid() const { bool valid() const { return !(w == 0 || h == 0 || hz == 0); }
return !(w == 0 || h == 0 || hz == 0);
}
}; };
bool isMain = false; bool isMain = false;
...@@ -185,8 +181,15 @@ static MonitorInfos getMonitors() ...@@ -185,8 +181,15 @@ static MonitorInfos getMonitors()
return mis; return mis;
} }
//! 获取主显示器信息
static MonitorInfo getMainMonitor(MonitorInfos mis = {}) {
if (mis.empty()) { mis = getMonitors(); }
for (const auto& mi : mis) { if (mi.isMain) { return mi; } }
return MonitorInfo{};
}
//////////////////////////////////////////////////////////////////////////////////////////////
//! 设置显示模式:扩展模式 //! 设置显示模式:扩展模式
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment