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
This commit is contained in:
Patrick Ziegler 2019-01-24 21:17:35 +01:00 committed by GitHub
parent 1145681cf5
commit a7ad68da31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,9 +102,13 @@ namespace randr_util {
} }
#endif #endif
auto primary_output = conn.get_output_primary(root).output(); auto primary_output = conn.get_output_primary(root).output();
auto primary_info = conn.get_output_info(primary_output); string primary_name{};
auto name_iter = primary_info.name();
string primary_name = {name_iter.begin(), name_iter.end()}; 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()) { for (auto&& output : conn.get_screen_resources(root).outputs()) {
try { try {