Skip to content

Commit

Permalink
feat: show output/display names for wlgrab
Browse files Browse the repository at this point in the history
  • Loading branch information
vmsh0 committed Jul 17, 2024
1 parent b93756a commit eafb472
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/platform/linux/wlgrab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,32 @@ namespace wl {
return -1;
}

// load output names, to allow matching by name
for (auto &monitor : interface.monitors) {
monitor->listen(interface.output_manager);
}

display.roundtrip();

auto monitor = interface.monitors[0].get();

if (!display_name.empty()) {
auto streamedMonitor = util::from_view(display_name);

if (streamedMonitor >= 0 && streamedMonitor < interface.monitors.size()) {
monitor = interface.monitors[streamedMonitor].get();
// if display_name is numeric, match a display number
if (display_name.find_first_not_of("0123456789") == std::string::npos) {
auto streamedMonitor = util::from_view(display_name);
if (streamedMonitor >= 0 && streamedMonitor < interface.monitors.size()) {
monitor = interface.monitors[streamedMonitor].get();
}
}
// otherwise, match a display name
else {
for (auto &candidate : interface.monitors) {
auto candidateMonitor = candidate.get();
if (candidateMonitor->name == display_name) {
monitor = candidateMonitor;
break;
}
}
}
}

Expand Down

0 comments on commit eafb472

Please sign in to comment.