Skip to content

Commit 3017967

Browse files
ids1024Drakulix
authored andcommitted
anvil: Call leave_all before removing output global
This prevents clients from getting a `leave` for a `wl_output` they've already destroyed after the global was removed, which seems to match other compositors and may fix some issues. `foot` for instance no longer prints a warning.
1 parent 8ed76f1 commit 3017967

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

anvil/src/udev.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ struct SurfaceData {
624624
dh: DisplayHandle,
625625
device_id: DrmNode,
626626
render_node: Option<DrmNode>,
627+
output: Output,
627628
global: Option<GlobalId>,
628629
drm_output: DrmOutput<
629630
GbmAllocator<DrmDeviceFd>,
@@ -643,6 +644,7 @@ struct SurfaceData {
643644

644645
impl Drop for SurfaceData {
645646
fn drop(&mut self) {
647+
self.output.leave_all();
646648
if let Some(global) = self.global.take() {
647649
self.dh.remove_global::<AnvilState<UdevData>>(global);
648650
}
@@ -1030,6 +1032,7 @@ impl AnvilState<UdevData> {
10301032
dh: self.display_handle.clone(),
10311033
device_id: node,
10321034
render_node: device.render_node,
1035+
output,
10331036
global: Some(global),
10341037
drm_output,
10351038
disable_direct_scanout,
@@ -1067,23 +1070,9 @@ impl AnvilState<UdevData> {
10671070
if let Some(leasing_state) = device.leasing_global.as_mut() {
10681071
leasing_state.withdraw_connector(connector.handle());
10691072
}
1070-
} else {
1071-
device.surfaces.remove(&crtc);
1072-
1073-
let output = self
1074-
.space
1075-
.outputs()
1076-
.find(|o| {
1077-
o.user_data()
1078-
.get::<UdevOutputId>()
1079-
.map(|id| id.device_id == node && id.crtc == crtc)
1080-
.unwrap_or(false)
1081-
})
1082-
.cloned();
1083-
1084-
if let Some(output) = output {
1085-
self.space.unmap_output(&output);
1086-
}
1073+
} else if let Some(surface) = device.surfaces.remove(&crtc) {
1074+
self.space.unmap_output(&surface.output);
1075+
self.space.refresh();
10871076
}
10881077

10891078
let render_node = device.render_node.unwrap_or(self.backend_data.primary_gpu);

0 commit comments

Comments
 (0)