mirror of
https://github.com/CloudNebulaProject/wayray.git
synced 2026-04-10 13:10:41 +00:00
Fix client surface rendering: add window.on_commit() and space.refresh()
Root cause: Window::bbox() stayed at 0x0 because Window::on_commit() was never called after surface commits. The Space then never associated the window with the output (no overlap), so render_elements_for_output returned empty. Two fixes: - Call window.on_commit() in CompositorHandler::commit() to update the window's bounding box from the committed surface tree - Call space.refresh() each frame to update output-element mappings Also: send xdg_toplevel configure with suggested 800x600 size.
This commit is contained in:
parent
8d248a8f52
commit
c4e3920c79
3 changed files with 21 additions and 32 deletions
|
|
@ -232,19 +232,9 @@ fn render_headless_frame(data: &mut CalloopData) {
|
|||
}
|
||||
};
|
||||
|
||||
let element_count = data.state.space.elements().count();
|
||||
tracing::debug!(element_count, "render tick");
|
||||
|
||||
// Check if window toplevel has been configured.
|
||||
if element_count > 0 {
|
||||
for window in data.state.space.elements() {
|
||||
if let Some(toplevel) = window.toplevel() {
|
||||
let configured = toplevel.is_initial_configure_sent();
|
||||
let bbox = window.bbox();
|
||||
tracing::info!(configured, ?bbox, "window state");
|
||||
}
|
||||
}
|
||||
}
|
||||
// Refresh the space — updates output-to-element mappings.
|
||||
// Must be called each frame before rendering.
|
||||
data.state.space.refresh();
|
||||
|
||||
let custom_elements: &[TextureRenderElement<PixmanTexture>] = &[];
|
||||
|
||||
|
|
@ -279,14 +269,6 @@ fn render_headless_frame(data: &mut CalloopData) {
|
|||
std::slice::from_raw_parts(ptr, frame_bytes)
|
||||
};
|
||||
|
||||
// One-shot content check for debugging.
|
||||
if element_count > 0 {
|
||||
let non_bg = pixels.chunks_exact(4).any(|p| p != [25, 25, 25, 255]);
|
||||
if non_bg {
|
||||
tracing::info!("client surface rendered successfully");
|
||||
}
|
||||
}
|
||||
|
||||
// Send frame over network if a client is connected.
|
||||
if data.client_connected {
|
||||
send_frame_to_network(data, pixels, &damage, output_size.w, output_size.h, stride);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use smithay::{
|
|||
shm::{ShmHandler, ShmState},
|
||||
},
|
||||
};
|
||||
use tracing::trace;
|
||||
|
||||
use crate::state::WayRay;
|
||||
|
||||
|
|
@ -40,23 +39,26 @@ impl CompositorHandler for WayRay {
|
|||
}
|
||||
|
||||
fn commit(&mut self, surface: &WlSurface) {
|
||||
trace!(?surface, "surface commit");
|
||||
smithay::backend::renderer::utils::on_commit_buffer_handler::<Self>(surface);
|
||||
|
||||
// If this surface belongs to an xdg toplevel that hasn't received
|
||||
// its initial configure yet, send it now so the client can start
|
||||
// drawing.
|
||||
// Find the window this surface belongs to and update its state.
|
||||
if let Some(window) = self
|
||||
.space
|
||||
.elements()
|
||||
.find(|w| w.wl_surface().map(|s| s.into_owned()) == Some(surface.clone()))
|
||||
.cloned()
|
||||
&& let Some(toplevel) = window.toplevel()
|
||||
{
|
||||
// Update the window's bounding box from the committed surface tree.
|
||||
// Without this, the window stays at 0x0 and never gets rendered.
|
||||
window.on_commit();
|
||||
|
||||
if let Some(toplevel) = window.toplevel()
|
||||
&& !toplevel.is_initial_configure_sent()
|
||||
{
|
||||
toplevel.send_configure();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BufferHandler for WayRay {
|
||||
|
|
|
|||
|
|
@ -21,11 +21,16 @@ impl XdgShellHandler for WayRay {
|
|||
}
|
||||
|
||||
fn new_toplevel(&mut self, surface: ToplevelSurface) {
|
||||
// Send the initial configure so the client can start drawing.
|
||||
// Set a suggested size and send the initial configure so the
|
||||
// client can start drawing.
|
||||
surface.with_pending_state(|state| {
|
||||
state.size = Some((800, 600).into());
|
||||
});
|
||||
surface.send_configure();
|
||||
|
||||
let window = Window::new_wayland_window(surface);
|
||||
self.space.map_element(window, (0, 0), false);
|
||||
info!("new toplevel mapped");
|
||||
self.space.map_element(window, (0, 0), true);
|
||||
info!("new toplevel mapped with suggested size 800x600");
|
||||
}
|
||||
|
||||
fn new_popup(&mut self, surface: PopupSurface, _positioner: PositionerState) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue