From 761b224f7c603e006afdd2476afb5f92628f50d5 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Fri, 13 Jan 2017 04:31:20 +0100 Subject: [PATCH] fix(xrandr): Merge outputs and 1-output monitors Refs #280 --- src/main.cpp | 4 ++-- src/x11/extensions/randr.cpp | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 23b67586..c2d7b56c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -111,9 +111,9 @@ int main(int argc, char** argv) { if (cli->has("list-monitors")) { for (auto&& mon : randr_util::get_monitors(conn, conn.root(), true)) { 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); + } else { + printf("%s: %ix%i+%i+%i\n", mon->name.c_str(), mon->w, mon->h, mon->x, mon->y); } } return EXIT_SUCCESS; diff --git a/src/x11/extensions/randr.cpp b/src/x11/extensions/randr.cpp index 4be1f3dd..2597dbcc 100644 --- a/src/x11/extensions/randr.cpp +++ b/src/x11/extensions/randr.cpp @@ -105,9 +105,22 @@ namespace randr_util { } else if (connected_only && info->connection != XCB_RANDR_CONNECTION_CONNECTED) { continue; } - auto crtc = conn.get_crtc_info(info->crtc); + auto name_iter = info.name(); 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)); } catch (const exception&) { // silently ignore output