Fix capturing scaled output with wlgrab

This commit is contained in:
Cameron Gutman 2024-01-03 10:14:50 -06:00
parent 1bd45ca803
commit 0403ad147a
2 changed files with 32 additions and 10 deletions

View File

@ -67,7 +67,14 @@ namespace wl {
}
inline monitor_t::monitor_t(wl_output *output):
output { output }, listener {
output { output },
wl_listener {
&CLASS_CALL(monitor_t, wl_geometry),
&CLASS_CALL(monitor_t, wl_mode),
&CLASS_CALL(monitor_t, wl_done),
&CLASS_CALL(monitor_t, wl_scale),
},
xdg_listener {
&CLASS_CALL(monitor_t, xdg_position),
&CLASS_CALL(monitor_t, xdg_size),
&CLASS_CALL(monitor_t, xdg_done),
@ -99,21 +106,23 @@ namespace wl {
void
monitor_t::xdg_size(zxdg_output_v1 *, std::int32_t width, std::int32_t height) {
BOOST_LOG(info) << "Logical size: "sv << width << 'x' << height;
}
void
monitor_t::wl_mode(wl_output *wl_output, std::uint32_t flags,
std::int32_t width, std::int32_t height, std::int32_t refresh) {
viewport.width = width;
viewport.height = height;
BOOST_LOG(info) << "Resolution: "sv << width << 'x' << height;
}
void
monitor_t::xdg_done(zxdg_output_v1 *) {
BOOST_LOG(info) << "All info about monitor ["sv << name << "] has been send"sv;
}
void
monitor_t::listen(zxdg_output_manager_v1 *output_manager) {
auto xdg_output = zxdg_output_manager_v1_get_xdg_output(output_manager, output);
zxdg_output_v1_add_listener(xdg_output, &listener, this);
zxdg_output_v1_add_listener(xdg_output, &xdg_listener, this);
wl_output_add_listener(output, &wl_listener, this);
}
interface_t::interface_t() noexcept
@ -137,7 +146,7 @@ namespace wl {
BOOST_LOG(info) << "Found interface: "sv << interface << '(' << id << ") version "sv << version;
monitors.emplace_back(
std::make_unique<monitor_t>(
(wl_output *) wl_registry_bind(registry, id, &wl_output_interface, version)));
(wl_output *) wl_registry_bind(registry, id, &wl_output_interface, 2)));
}
else if (!std::strcmp(interface, zxdg_output_manager_v1_interface.name)) {
BOOST_LOG(info) << "Found interface: "sv << interface << '(' << id << ") version "sv << version;

View File

@ -118,7 +118,19 @@ namespace wl {
void
xdg_size(zxdg_output_v1 *, std::int32_t width, std::int32_t height);
void
xdg_done(zxdg_output_v1 *);
xdg_done(zxdg_output_v1 *) {}
void
wl_geometry(wl_output *wl_output, std::int32_t x, std::int32_t y,
std::int32_t physical_width, std::int32_t physical_height, std::int32_t subpixel,
const char *make, const char *model, std::int32_t transform) {}
void
wl_mode(wl_output *wl_output, std::uint32_t flags,
std::int32_t width, std::int32_t height, std::int32_t refresh);
void
wl_done(wl_output *wl_output) {}
void
wl_scale(wl_output *wl_output, std::int32_t factor) {}
void
listen(zxdg_output_manager_v1 *output_manager);
@ -130,7 +142,8 @@ namespace wl {
platf::touch_port_t viewport;
zxdg_output_v1_listener listener;
wl_output_listener wl_listener;
zxdg_output_v1_listener xdg_listener;
};
class interface_t {