From fca6a6c5f53b0dd3c00a068b6219c025802d9617 Mon Sep 17 00:00:00 2001 From: Ottatop Date: Mon, 12 Aug 2024 12:13:50 -0500 Subject: [PATCH] Update scanout output for cursor surfaces Also schedule render when they commit --- src/handlers.rs | 9 +++++ src/layout/transaction.rs | 8 +--- src/render.rs | 2 +- src/state.rs | 79 +++++++++++++++++++++++++++++++++++++-- 4 files changed, 87 insertions(+), 11 deletions(-) diff --git a/src/handlers.rs b/src/handlers.rs index 408f94e..c8c72fc 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -423,6 +423,15 @@ impl CompositorHandler for State { .cloned() { vec![output] // surface is a layer surface + } else if matches!(self.pinnacle.cursor_state.cursor_image(), CursorImageStatus::Surface(s) if s == surface) + { + // This is a cursor surface + // TODO: granular + self.pinnacle.space.outputs().cloned().collect() + } else if self.pinnacle.dnd_icon.as_ref() == Some(surface) { + // This is a dnd icon + // TODO: granular + self.pinnacle.space.outputs().cloned().collect() } else if let Some(output) = self .pinnacle .space diff --git a/src/layout/transaction.rs b/src/layout/transaction.rs index 082f84d..215a334 100644 --- a/src/layout/transaction.rs +++ b/src/layout/transaction.rs @@ -7,18 +7,14 @@ use std::{ use smithay::{ backend::renderer::element::{ - self, - surface::WaylandSurfaceRenderElement, - texture::{TextureBuffer, TextureRenderElement}, - utils::RescaleRenderElement, - Element, + surface::WaylandSurfaceRenderElement, utils::RescaleRenderElement, Element, }, desktop::Space, reexports::calloop::{ timer::{TimeoutAction, Timer}, LoopHandle, }, - utils::{Logical, Point, Scale, Serial, Transform}, + utils::{Logical, Point, Scale, Serial}, }; use crate::{ diff --git a/src/render.rs b/src/render.rs index a5dbcc1..bed3972 100644 --- a/src/render.rs +++ b/src/render.rs @@ -29,7 +29,7 @@ use smithay::{ use crate::{ backend::{udev::UdevRenderer, Backend}, - layout::transaction::{LayoutTransaction, SnapshotRenderElement, SnapshotTarget}, + layout::transaction::SnapshotRenderElement, pinnacle_render_elements, state::{State, WithState}, window::WindowElement, diff --git a/src/state.rs b/src/state.rs index d9b9412..d0e6c89 100644 --- a/src/state.rs +++ b/src/state.rs @@ -53,7 +53,9 @@ use smithay::{ }, utils::{Clock, Monotonic}, wayland::{ - compositor::{self, CompositorClientState, CompositorState, SurfaceData}, + compositor::{ + self, with_surface_tree_downward, CompositorClientState, CompositorState, SurfaceData, + }, cursor_shape::CursorShapeManagerState, fractional_scale::{with_fractional_scale, FractionalScaleManagerState}, idle_notify::IdleNotifierState, @@ -490,9 +492,22 @@ impl Pinnacle { // the frame callbacks across potentially multiple outputs, and for regular windows and // layer-shell surfaces it avoids sending frame callbacks to invisible surfaces. let current_primary_output = surface_primary_scanout_output(surface, states); + + if matches!(self.cursor_state.cursor_image(), CursorImageStatus::Surface(s) if s == surface) + { + tracing::info!( + "cursor primary scanout output: {:?}", + current_primary_output.as_ref().map(|o| o.name()) + ); + } + // tracing::info!( - // "current primary output is {:?}", - // current_primary_output.as_ref().map(|o| o.name()) + // op_count = self.outputs.len(), + // "current primary output is {:?}, wl_output {:?}", + // current_primary_output.as_ref().map(|o| o.name()), + // current_primary_output + // .as_ref() + // .and_then(|o| { self.outputs.get(o) }), // ); if current_primary_output.as_ref() != Some(output) { // return self @@ -586,7 +601,9 @@ impl Pinnacle { offscreen_id.clone().unwrap_or_else(|| Id::from(surface)), output, render_element_states, - default_primary_scanout_output_compare, + // TODO: + // default_primary_scanout_output_compare, + |_, _, op, _| op, ); if let Some(output) = primary_scanout_output { @@ -617,6 +634,60 @@ impl Pinnacle { } }); } + + if let Some(lock_surface) = output.with_state(|state| state.lock_surface.clone()) { + with_surface_tree_downward( + lock_surface.wl_surface(), + (), + |_, _, _| compositor::TraversalAction::DoChildren(()), + |surface, states, _| { + update_surface_primary_scanout_output( + surface, + output, + states, + render_element_states, + default_primary_scanout_output_compare, + ); + }, + |_, _, _| true, + ); + } + + if let Some(dnd) = self.dnd_icon.as_ref() { + with_surface_tree_downward( + dnd, + (), + |_, _, _| compositor::TraversalAction::DoChildren(()), + |surface, states, _| { + update_surface_primary_scanout_output( + surface, + output, + states, + render_element_states, + default_primary_scanout_output_compare, + ); + }, + |_, _, _| true, + ); + } + + if let CursorImageStatus::Surface(surface) = self.cursor_state.cursor_image() { + with_surface_tree_downward( + surface, + (), + |_, _, _| compositor::TraversalAction::DoChildren(()), + |surface, states, _| { + update_surface_primary_scanout_output( + surface, + output, + states, + render_element_states, + default_primary_scanout_output_compare, + ); + }, + |_, _, _| true, + ); + } } pub fn send_dmabuf_feedback(