Skip to content

Commit

Permalink
state: send_frames/primary_output/dmabuf_feedback for dnd surfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Dec 18, 2024
1 parent 7ac204e commit 29ea548
Showing 1 changed file with 87 additions and 12 deletions.
99 changes: 87 additions & 12 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ use crate::{
input::{gestures::GestureState, PointerFocusState},
shell::{grabs::SeatMoveGrabState, CosmicSurface, SeatExt, Shell},
utils::prelude::OutputExt,
wayland::handlers::screencopy::SessionHolder,
wayland::protocols::{
atspi::AtspiState,
drm::WlDrmState,
image_source::ImageSourceState,
output_configuration::OutputConfigurationState,
output_power::OutputPowerState,
overlap_notify::OverlapNotifyState,
screencopy::ScreencopyState,
toplevel_info::ToplevelInfoState,
toplevel_management::{ManagementCapabilities, ToplevelManagementState},
workspace::{WorkspaceClientState, WorkspaceState, WorkspaceUpdateGuard},
wayland::{
handlers::{data_device::get_dnd_icon, screencopy::SessionHolder},
protocols::{
atspi::AtspiState,
drm::WlDrmState,
image_source::ImageSourceState,
output_configuration::OutputConfigurationState,
output_power::OutputPowerState,
overlap_notify::OverlapNotifyState,
screencopy::ScreencopyState,
toplevel_info::ToplevelInfoState,
toplevel_management::{ManagementCapabilities, ToplevelManagementState},
workspace::{WorkspaceClientState, WorkspaceState, WorkspaceUpdateGuard},
},
},
xwayland::XWaylandState,
};
Expand Down Expand Up @@ -722,6 +724,11 @@ impl Common {
with_surfaces_surface_tree(&wl_surface, processor);
}

//dnd
if let Some(dnd_icon) = get_dnd_icon(seat) {
with_surfaces_surface_tree(&dnd_icon.surface, processor);
}

// grabs
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() {
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() {
Expand Down Expand Up @@ -807,6 +814,64 @@ impl Common {
.iter()
.filter(|seat| &seat.active_output() == output)
{
let cursor_status = seat
.user_data()
.get::<Mutex<CursorImageStatus>>()
.map(|lock| {
let mut cursor_status = lock.lock().unwrap();
if let CursorImageStatus::Surface(ref surface) = *cursor_status {
if !surface.alive() {
*cursor_status = CursorImageStatus::default_named();
}
}
cursor_status.clone()
})
.unwrap_or(CursorImageStatus::default_named());

// cursor ...
if let CursorImageStatus::Surface(wl_surface) = cursor_status {
if let Some(feedback) =
advertised_node_for_surface(&wl_surface, &self.display_handle)
.and_then(|source| dmabuf_feedback(source))
{
send_dmabuf_feedback_surface_tree(
&wl_surface,
output,
surface_primary_scanout_output,
|surface, _| {
select_dmabuf_feedback(
surface,
render_element_states,
&feedback.render_feedback,
&feedback.scanout_feedback,
)
},
);
}
}

//dnd
if let Some(dnd_icon) = get_dnd_icon(seat) {
if let Some(feedback) =
advertised_node_for_surface(&dnd_icon.surface, &self.display_handle)
.and_then(|source| dmabuf_feedback(source))
{
send_dmabuf_feedback_surface_tree(
&dnd_icon.surface,
output,
surface_primary_scanout_output,
|surface, _| {
select_dmabuf_feedback(
surface,
render_element_states,
&feedback.render_feedback,
&feedback.scanout_feedback,
)
},
)
}
}

if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() {
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() {
for (window, _) in grab_state.element().windows() {
Expand Down Expand Up @@ -1012,6 +1077,16 @@ impl Common {
)
}

if let Some(dnd_icon) = get_dnd_icon(seat) {
send_frames_surface_tree(
&dnd_icon.surface,
output,
time,
Some(Duration::ZERO),
should_send,
)
}

if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() {
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() {
for (window, _) in grab_state.element().windows() {
Expand Down

0 comments on commit 29ea548

Please sign in to comment.