Support Wayland monitor selection by connector name
Some checks failed
Some checks failed
This commit is contained in:
parent
c4315144b3
commit
916eb1a213
1 changed files with 31 additions and 2 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
* @brief Definitions for wlgrab capture.
|
* @brief Definitions for wlgrab capture.
|
||||||
*/
|
*/
|
||||||
// standard includes
|
// standard includes
|
||||||
|
#include <algorithm>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
|
|
@ -57,6 +58,30 @@ namespace wl {
|
||||||
|
|
||||||
if (streamedMonitor >= 0 && streamedMonitor < interface.monitors.size()) {
|
if (streamedMonitor >= 0 && streamedMonitor < interface.monitors.size()) {
|
||||||
monitor = interface.monitors[streamedMonitor].get();
|
monitor = interface.monitors[streamedMonitor].get();
|
||||||
|
} else {
|
||||||
|
auto by_name = std::find_if(
|
||||||
|
std::begin(interface.monitors),
|
||||||
|
std::end(interface.monitors),
|
||||||
|
[&display_name](const auto &candidate) {
|
||||||
|
return candidate->name == display_name;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (by_name != std::end(interface.monitors)) {
|
||||||
|
monitor = by_name->get();
|
||||||
|
} else {
|
||||||
|
auto by_description = std::find_if(
|
||||||
|
std::begin(interface.monitors),
|
||||||
|
std::end(interface.monitors),
|
||||||
|
[&display_name](const auto &candidate) {
|
||||||
|
return candidate->description == display_name;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (by_description != std::end(interface.monitors)) {
|
||||||
|
monitor = by_description->get();
|
||||||
|
} else {
|
||||||
|
BOOST_LOG(warning) << "No Wayland monitor matched output_name='"sv << display_name << "'; falling back to monitor 0"sv;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -431,8 +456,12 @@ namespace platf {
|
||||||
|
|
||||||
BOOST_LOG(info) << "Monitor " << x << " is "sv << monitor->name << ": "sv << monitor->description;
|
BOOST_LOG(info) << "Monitor " << x << " is "sv << monitor->name << ": "sv << monitor->description;
|
||||||
|
|
||||||
display_names.emplace_back(std::to_string(x));
|
if (!monitor->name.empty()) {
|
||||||
}
|
display_names.emplace_back(monitor->name);
|
||||||
|
} else {
|
||||||
|
display_names.emplace_back(std::to_string(x));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_LOG(info) << "--------- End of Wayland monitor list ---------"sv;
|
BOOST_LOG(info) << "--------- End of Wayland monitor list ---------"sv;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue