From a7ad68da31aa15a8b7fae51ad408c6ca17a3239a Mon Sep 17 00:00:00 2001
From: Patrick Ziegler
Date: Thu, 24 Jan 2019 21:17:35 +0100
Subject: [PATCH] fix(randr): Check if there is a primary monitor (#1621)
* fix(randr): Check if there is a primary monitor
primary_info.name() throws an error if get_output_info is called with
XCB_NONE
Fixes #1620
---
src/x11/extensions/randr.cpp | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/x11/extensions/randr.cpp b/src/x11/extensions/randr.cpp
index 5dfbd1cd..36baedb5 100644
--- a/src/x11/extensions/randr.cpp
+++ b/src/x11/extensions/randr.cpp
@@ -102,9 +102,13 @@ namespace randr_util {
}
#endif
auto primary_output = conn.get_output_primary(root).output();
- auto primary_info = conn.get_output_info(primary_output);
- auto name_iter = primary_info.name();
- string primary_name = {name_iter.begin(), name_iter.end()};
+ string primary_name{};
+
+ if (primary_output != XCB_NONE) {
+ auto primary_info = conn.get_output_info(primary_output);
+ auto name_iter = primary_info.name();
+ primary_name = {name_iter.begin(), name_iter.end()};
+ }
for (auto&& output : conn.get_screen_resources(root).outputs()) {
try {