Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/niri.rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this function it doesn't matter where the code is because it's a synchronous function. We don't send or receive anything from clients within this function. So I'd rather leave the code where it was

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both, disable global and layersurface send_close will send events to clients. This commit does change the order. I am not convinced this is necessary, but it seems to prevent some qs ghost Windows. I have to check, but my theory is like stated in the commit message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right, they aren't sent but they are buffered to be sent in the ordered Wayland message buffer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, technically they are buffered and not directly sent here.

My theory is based on the fact that without sending the output destroy before the close the client can not tell the difference.

layer shell close defines:

The closed event is sent by the compositor when the surface will no longer be shown. The output may have been destroyed or the user may have asked for it to be removed. Further changes to the surface will be ignored. The client should destroy the resource after receiving this event, and create a new surface if they so choose.

I can't tell if it intentionally uses the past tense for output destroy, but it would make sense.

Original file line number Diff line number Diff line change
Expand Up @@ -2825,6 +2825,25 @@ impl Niri {
}

pub fn remove_output(&mut self, output: &Output) {
let state = self.output_state.remove(output).unwrap();

// Disable the output global and remove some time later to give the clients some time to
// process it.
let global = state.global;
self.display_handle.disable_global::<State>(global.clone());
self.event_loop
.insert_source(
Timer::from_duration(Duration::from_secs(10)),
move |_, _, state| {
state
.niri
.display_handle
.remove_global::<State>(global.clone());
TimeoutAction::Drop
},
)
.unwrap();

for layer in layer_map_for_output(output).layers() {
layer.layer_surface().send_close();
}
Expand All @@ -2834,8 +2853,6 @@ impl Niri {
self.reposition_outputs(None);
self.gamma_control_manager_state.output_removed(output);

let state = self.output_state.remove(output).unwrap();

match state.redraw_state {
RedrawState::Idle => (),
RedrawState::Queued => (),
Expand All @@ -2847,23 +2864,6 @@ impl Niri {
self.stop_casts_for_target(CastTarget::output(output));
self.screencopy_state.remove_output(output);

// Disable the output global and remove some time later to give the clients some time to
// process it.
let global = state.global;
self.display_handle.disable_global::<State>(global.clone());
self.event_loop
.insert_source(
Timer::from_duration(Duration::from_secs(10)),
move |_, _, state| {
state
.niri
.display_handle
.remove_global::<State>(global.clone());
TimeoutAction::Drop
},
)
.unwrap();

match mem::take(&mut self.lock_state) {
LockState::Locking(confirmation) => {
// We're locking and an output was removed, check if the requirements are now met.
Expand Down