fix(linux/pipewire): calculate env_width/env_height from all displays for pipewire_display_t (#5050)

This commit is contained in:
Kishi
2026-04-26 17:03:37 +02:00
committed by GitHub
parent 5cf5e8c1ce
commit 7a4c940e0f
+23 -16
View File
@@ -608,31 +608,38 @@ namespace pipewire {
* @brief Verify and update display parameters for logical dimensions, desktop dimensions and logical desktop dimensions (default is adapted from wlgrab)
*/
virtual void verify_and_update_display_parameters() {
// Set environment dimensions to stream dimensions (unless we find something better to report here)
if (env_height <= 0 || env_width <= 0) {
this->env_width = width;
this->env_height = height;
BOOST_LOG(debug) << "[pipewire] Desktop Resolution: "sv << env_width << 'x' << env_height;
}
// Query logical sizes directly using wayland wl::monitors() and match current screen based on offset/dimensions
if (logical_height <= 0 || logical_width <= 0 || env_logical_height <= 0 || env_logical_width <= 0) {
// Query outputs directly using wayland wl::monitors()
if (logical_height <= 0 || logical_width <= 0 || env_logical_height <= 0 || env_logical_width <= 0 || env_height <= 0 || env_width <= 0) {
int desktop_width = 0;
int desktop_height = 0;
int desktop_logical_width = 0;
int desktop_logical_height = 0;
for (const auto &monitor : wl::monitors()) {
// If logical_width and logical_height are not valid try to update them to correct values by matching to monitor position/dimension or position/logical dimensions
// since we're iterating for maximum environment size anyway
BOOST_LOG(debug) << "[pipewire] Found output: '"sv << monitor->name << "' offset: "sv << monitor->viewport.offset_x << 'x' << monitor->viewport.offset_y << " resolution: "sv << monitor->viewport.width << 'x' << monitor->viewport.height << " logical resolution: "sv << monitor->viewport.logical_width << 'x' << monitor->viewport.logical_height;
// If logical_width and logical_height are not valid try to update them to correct values by matching to monitor
// position/dimension or position/logical dimensions here since we're iterating for maximum environment size anyway
if ((logical_width <= 0 || logical_height <= 0) && monitor->viewport.offset_x == offset_x && monitor->viewport.offset_y == offset_y && ((monitor->viewport.width == width && monitor->viewport.height == height) || (monitor->viewport.logical_width == width && monitor->viewport.logical_height == height))) {
this->logical_width = monitor->viewport.logical_width;
this->logical_height = monitor->viewport.logical_height;
BOOST_LOG(debug) << "[pipewire] Logical Resolution: "sv << logical_width << 'x' << logical_height;
BOOST_LOG(debug) << "[pipewire] Set logical resolution: "sv << logical_width << 'x' << logical_height;
}
// Update logical dimensions to setup maximum environment size over all screens
// Update desktop dimensions to setup maximum environment size over all screens
desktop_width = std::max(desktop_width, monitor->viewport.offset_x + monitor->viewport.width);
desktop_height = std::max(desktop_height, monitor->viewport.offset_y + monitor->viewport.height);
// Update desktop logical dimensions to setup maximum logical environment size over all screens
desktop_logical_width = std::max(desktop_logical_width, monitor->viewport.offset_x + monitor->viewport.logical_width);
desktop_logical_height = std::max(desktop_logical_height, monitor->viewport.offset_y + monitor->viewport.logical_height);
}
this->env_logical_width = std::max(env_logical_width, desktop_logical_width);
this->env_logical_height = std::max(env_logical_height, desktop_logical_height);
BOOST_LOG(debug) << "[pipewire] Logical Desktop Resolution: "sv << env_logical_width << 'x' << env_logical_height;
if (env_height <= 0 || env_width <= 0) {
this->env_width = desktop_width;
this->env_height = desktop_height;
BOOST_LOG(debug) << "[pipewire] Set desktop resolution: "sv << env_width << 'x' << env_height;
}
if (env_logical_height <= 0 || env_logical_width <= 0) {
this->env_logical_width = desktop_logical_width;
this->env_logical_height = desktop_logical_height;
BOOST_LOG(debug) << "[pipewire] Set desktop logical resolution: "sv << env_logical_width << 'x' << env_logical_height;
}
}
}
@@ -662,7 +669,7 @@ namespace pipewire {
BOOST_LOG(error) << "[pipewire] Could not find display with name: '"sv << display_name << "'";
return -1;
}
BOOST_LOG(info) << "[pipewire] Streaming display '"sv << display_name << "' from position: "sv << offset_x << "x"sv << offset_y << " resolution: "sv << width << "x"sv << height;
BOOST_LOG(info) << "[pipewire] Streaming display '"sv << display_name << "' offset: "sv << offset_x << "x"sv << offset_y << " resolution: "sv << width << "x"sv << height;
// Verify or update display parameters for streaming to ensure absolute touch inputs work as expected
verify_and_update_display_parameters();