Skip to content

Commit

Permalink
Extract popup_output()
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Dec 18, 2023
1 parent 041ca67 commit 887574c
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions src/handlers/xdg_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,31 +303,12 @@ impl State {
.initial_configure_sent
});
if !initial_configure_sent {
if let Ok(toplevel) = find_popup_root_surface(&PopupKind::Xdg(popup.clone())) {
let output = self
.niri
.layout
.find_window_and_output(&toplevel)
.map(|(_, output)| output)
.or_else(|| {
self.niri
.layout
.outputs()
.find(|o| {
let map = layer_map_for_output(o);
map.layer_for_surface(&toplevel, WindowSurfaceType::TOPLEVEL)
.is_some()
})
.cloned()
});

if let Some(output) = output {
let scale = output.current_scale().integer_scale();
let transform = output.current_transform();
with_states(surface, |data| {
send_surface_state(surface, data, scale, transform);
});
}
if let Some(output) = self.popup_output(&PopupKind::Xdg(popup.clone())) {
let scale = output.current_scale().integer_scale();
let transform = output.current_transform();
with_states(surface, |data| {
send_surface_state(surface, data, scale, transform);
});
}

if let Err(err) = popup.send_configure() {
Expand Down Expand Up @@ -377,4 +358,26 @@ impl State {

unconstrain_popup(target, popup)
}

pub fn popup_output(&self, popup: &PopupKind) -> Option<Output> {
let Ok(root) = find_popup_root_surface(popup) else {
return None;
};

self.niri
.layout
.find_window_and_output(&root)
.map(|(_, output)| output)
.or_else(|| {
self.niri
.layout
.outputs()
.find(|o| {
let map = layer_map_for_output(o);
map.layer_for_surface(&root, WindowSurfaceType::TOPLEVEL)
.is_some()
})
.cloned()
})
}
}

0 comments on commit 887574c

Please sign in to comment.