From cc36350849342e061ddb1d8ffab1b42a4634af24 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Mon, 24 Jun 2019 17:57:54 +0200
Subject: [PATCH] xrandr: Allow not to purge cloned monitors
---
include/x11/extensions/randr.hpp | 2 +-
src/x11/extensions/randr.cpp | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/x11/extensions/randr.hpp b/include/x11/extensions/randr.hpp
index 1c8d1185..5a42b703 100644
--- a/include/x11/extensions/randr.hpp
+++ b/include/x11/extensions/randr.hpp
@@ -51,7 +51,7 @@ namespace randr_util {
monitor_t make_monitor(xcb_randr_output_t randr, string name, unsigned short int w, unsigned short int h, short int x, short int y,
bool primary);
- vector get_monitors(connection& conn, xcb_window_t root, bool connected_only = false);
+ vector get_monitors(connection& conn, xcb_window_t root, bool connected_only = false, bool purge_clones = true);
monitor_t match_monitor(vector monitors, const string& name, bool exact_match);
void get_backlight_range(connection& conn, const monitor_t& mon, backlight_values& dst);
diff --git a/src/x11/extensions/randr.cpp b/src/x11/extensions/randr.cpp
index cd195c27..64bde0b9 100644
--- a/src/x11/extensions/randr.cpp
+++ b/src/x11/extensions/randr.cpp
@@ -80,7 +80,7 @@ namespace randr_util {
/**
* Create a list of all available randr outputs
*/
- vector get_monitors(connection& conn, xcb_window_t root, bool connected_only) {
+ vector get_monitors(connection& conn, xcb_window_t root, bool connected_only, bool purge_clones) {
vector monitors;
#if WITH_XRANDR_MONITORS
@@ -148,6 +148,11 @@ namespace randr_util {
}
// Test if there are any clones in the set
+
+ if (!purge_clones) {
+ continue;
+ }
+
for (auto& monitor : monitors) {
if ((*m) == monitor || monitor->w == 0) {
continue;