1111#include < wayfire/geometry.hpp>
1212#include < wlr/types/wlr_output.h>
1313#include < wayfire/signal-provider.hpp>
14+ #include " view/view-impl.hpp"
1415#include " wayfire/debug.hpp"
1516#include " xdg-output-unstable-v1-protocol.h"
1617
@@ -62,6 +63,11 @@ class xdg_output_v1_resource
6263 }
6364 }
6465
66+ bool is_xwayland () const
67+ {
68+ return wl_resource_get_client (xdg_output) == wf::xwayland_get_client ();
69+ }
70+
6571 bool resend_details (wf::geometry_t geometry)
6672 {
6773 if (last_sent_geometry == geometry)
@@ -117,12 +123,14 @@ void xdg_output_manager_v1::update_outputs()
117123 return config.count (output) && (config[output].source & OUTPUT_IMAGE_SOURCE_SELF);
118124 };
119125
120- const auto & update_output = [&] (wlr_output *output, wf::geometry_t geometry)
126+ const auto & update_output = [&] (wlr_output *output, wf::geometry_t geometry,
127+ wf::geometry_t xwayland_geometry)
121128 {
122129 bool changed = false ;
123130 for (auto & resource : output_resources[output])
124131 {
125- changed |= resource->resend_details (geometry);
132+ wf::geometry_t to_send = resource->is_xwayland () ? xwayland_geometry : geometry;
133+ changed |= resource->resend_details (to_send);
126134 }
127135
128136 if (changed)
@@ -131,6 +139,9 @@ void xdg_output_manager_v1::update_outputs()
131139 }
132140 };
133141
142+ static wf::option_wrapper_t <bool > force_xwayland_scaling{" workarounds/force_xwayland_scaling" };
143+
144+ int xwayland_location_x = 0 ;
134145 auto it = output_resources.begin ();
135146 while (it != output_resources.end ())
136147 {
@@ -139,8 +150,22 @@ void xdg_output_manager_v1::update_outputs()
139150 it = output_resources.erase (it);
140151 } else
141152 {
142- auto geometry = ol->find_output (it->first )->get_layout_geometry ();
143- update_output (it->first , geometry);
153+ auto wo = ol->find_output (it->first );
154+ auto geometry = wo->get_layout_geometry ();
155+ if (force_xwayland_scaling)
156+ {
157+ int width, height;
158+ wlr_output_transformed_resolution (it->first , &width, &height);
159+ wf::geometry_t xwayland_geometry = {xwayland_location_x, 0 , width, height};
160+ update_output (it->first , geometry, xwayland_geometry);
161+ xwayland_location_x += width;
162+ wo->get_data_safe <wf::xdg_output_xwayland_geometry>()->geometry = xwayland_geometry;
163+ } else
164+ {
165+ update_output (it->first , geometry, geometry);
166+ wo->get_data_safe <wf::xdg_output_xwayland_geometry>()->geometry = geometry;
167+ }
168+
144169 ++it;
145170 }
146171 }
0 commit comments