fix(xrandr): Merge outputs and 1-output monitors

Refs #280
This commit is contained in:
Michael Carlberg 2017-01-13 04:31:20 +01:00
parent 081578b168
commit 761b224f7c
2 changed files with 16 additions and 3 deletions

View File

@ -111,9 +111,9 @@ int main(int argc, char** argv) {
if (cli->has("list-monitors")) { if (cli->has("list-monitors")) {
for (auto&& mon : randr_util::get_monitors(conn, conn.root(), true)) { for (auto&& mon : randr_util::get_monitors(conn, conn.root(), true)) {
if (ENABLE_XRANDR_MONITORS && mon->output == XCB_NONE) { if (ENABLE_XRANDR_MONITORS && mon->output == XCB_NONE) {
printf("%s: %ix%i+%i+%i\n", mon->name.c_str(), mon->w, mon->h, mon->x, mon->y);
} else {
printf("%s: %ix%i+%i+%i (XRandR monitor)\n", mon->name.c_str(), mon->w, mon->h, mon->x, mon->y); printf("%s: %ix%i+%i+%i (XRandR monitor)\n", mon->name.c_str(), mon->w, mon->h, mon->x, mon->y);
} else {
printf("%s: %ix%i+%i+%i\n", mon->name.c_str(), mon->w, mon->h, mon->x, mon->y);
} }
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -105,9 +105,22 @@ namespace randr_util {
} else if (connected_only && info->connection != XCB_RANDR_CONNECTION_CONNECTED) { } else if (connected_only && info->connection != XCB_RANDR_CONNECTION_CONNECTED) {
continue; continue;
} }
auto crtc = conn.get_crtc_info(info->crtc);
auto name_iter = info.name(); auto name_iter = info.name();
string name{name_iter.begin(), name_iter.end()}; string name{name_iter.begin(), name_iter.end()};
#if ENABLE_XRANDR_MONITORS
if (check_monitor_support()) {
auto mon = std::find_if(
monitors.begin(), monitors.end(), [&name](const monitor_t& mon) { return mon->name == name; });
if (mon != monitors.end()) {
(*mon)->output = output;
continue;
}
}
#endif
auto crtc = conn.get_crtc_info(info->crtc);
monitors.emplace_back(make_monitor(output, move(name), crtc->width, crtc->height, crtc->x, crtc->y)); monitors.emplace_back(make_monitor(output, move(name), crtc->width, crtc->height, crtc->x, crtc->y));
} catch (const exception&) { } catch (const exception&) {
// silently ignore output // silently ignore output