aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/handlers/layer_shell.rs4
-rw-r--r--src/handlers/mod.rs1
-rw-r--r--src/handlers/xdg_shell.rs45
3 files changed, 30 insertions, 20 deletions
diff --git a/src/handlers/layer_shell.rs b/src/handlers/layer_shell.rs
index bf1832fb..bd3fbbcd 100644
--- a/src/handlers/layer_shell.rs
+++ b/src/handlers/layer_shell.rs
@@ -1,5 +1,5 @@
use smithay::delegate_layer_shell;
-use smithay::desktop::{layer_map_for_output, LayerSurface, WindowSurfaceType};
+use smithay::desktop::{layer_map_for_output, LayerSurface, PopupKind, WindowSurfaceType};
use smithay::output::Output;
use smithay::reexports::wayland_server::protocol::wl_output::WlOutput;
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
@@ -55,7 +55,7 @@ impl WlrLayerShellHandler for State {
}
fn new_popup(&mut self, _parent: WlrLayerSurface, popup: PopupSurface) {
- self.unconstrain_popup(&popup);
+ self.unconstrain_popup(&PopupKind::Xdg(popup));
}
}
delegate_layer_shell!(State);
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs
index ae2b4499..28b21b9f 100644
--- a/src/handlers/mod.rs
+++ b/src/handlers/mod.rs
@@ -142,6 +142,7 @@ impl InputMethodHandler for State {
send_surface_state(wl_surface, data, scale, transform);
});
}
+
if let Err(err) = self.niri.popups.track_popup(popup) {
warn!("error tracking ime popup {err:?}");
}
diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs
index 7ebf360a..1fde1eee 100644
--- a/src/handlers/xdg_shell.rs
+++ b/src/handlers/xdg_shell.rs
@@ -47,9 +47,10 @@ impl XdgShellHandler for State {
}
fn new_popup(&mut self, surface: PopupSurface, _positioner: PositionerState) {
- self.unconstrain_popup(&surface);
+ let popup = PopupKind::Xdg(surface);
+ self.unconstrain_popup(&popup);
- if let Err(err) = self.niri.popups.track_popup(PopupKind::Xdg(surface)) {
+ if let Err(err) = self.niri.popups.track_popup(popup) {
warn!("error tracking popup: {err:?}");
}
}
@@ -79,7 +80,7 @@ impl XdgShellHandler for State {
state.geometry = geometry;
state.positioner = positioner;
});
- self.unconstrain_popup(&surface);
+ self.unconstrain_popup(&PopupKind::Xdg(surface.clone()));
surface.send_repositioned(token);
}
@@ -659,12 +660,12 @@ impl State {
self.niri.output_for_root(&root)
}
- pub fn unconstrain_popup(&self, popup: &PopupSurface) {
+ pub fn unconstrain_popup(&self, popup: &PopupKind) {
let _span = tracy_client::span!("Niri::unconstrain_popup");
// Popups with a NULL parent will get repositioned in their respective protocol handlers
// (i.e. layer-shell).
- let Ok(root) = find_popup_root_surface(&PopupKind::Xdg(popup.clone())) else {
+ let Ok(root) = find_popup_root_surface(popup) else {
return;
};
@@ -680,7 +681,7 @@ impl State {
}
}
- fn unconstrain_window_popup(&self, popup: &PopupSurface, window: &Window, output: &Output) {
+ fn unconstrain_window_popup(&self, popup: &PopupKind, window: &Window, output: &Output) {
let window_geo = window.geometry();
let output_geo = self.niri.global_space.output_geometry(output).unwrap();
@@ -693,16 +694,21 @@ impl State {
let mut target =
Rectangle::from_loc_and_size((0, 0), (window_geo.size.w, output_geo.size.h));
target.loc.y -= self.niri.layout.window_y(window).unwrap();
- target.loc -= get_popup_toplevel_coords(&PopupKind::Xdg(popup.clone()));
+ target.loc -= get_popup_toplevel_coords(popup);
- popup.with_pending_state(|state| {
- state.geometry = unconstrain_with_padding(state.positioner, target);
- });
+ match popup {
+ PopupKind::Xdg(popup) => {
+ popup.with_pending_state(|state| {
+ state.geometry = unconstrain_with_padding(state.positioner, target);
+ });
+ }
+ PopupKind::InputMethod(_) => todo!(),
+ }
}
pub fn unconstrain_layer_shell_popup(
&self,
- popup: &PopupSurface,
+ popup: &PopupKind,
layer_surface: &LayerSurface,
output: &Output,
) {
@@ -716,11 +722,14 @@ impl State {
// we will compute that here.
let mut target = Rectangle::from_loc_and_size((0, 0), output_geo.size);
target.loc -= layer_geo.loc;
- target.loc -= get_popup_toplevel_coords(&PopupKind::Xdg(popup.clone()));
+ target.loc -= get_popup_toplevel_coords(popup);
- popup.with_pending_state(|state| {
- state.geometry = unconstrain_with_padding(state.positioner, target);
- });
+ match popup {
+ PopupKind::Xdg(popup) => popup.with_pending_state(|state| {
+ state.geometry = unconstrain_with_padding(state.positioner, target);
+ }),
+ PopupKind::InputMethod(_) => todo!(),
+ }
}
pub fn update_reactive_popups(&self, window: &Window, output: &Output) {
@@ -729,10 +738,10 @@ impl State {
for (popup, _) in PopupManager::popups_for_surface(
window.toplevel().expect("no x11 support").wl_surface(),
) {
- match popup {
- PopupKind::Xdg(ref popup) => {
+ match &popup {
+ xdg_popup @ PopupKind::Xdg(popup) => {
if popup.with_pending_state(|state| state.positioner.reactive) {
- self.unconstrain_window_popup(popup, window, output);
+ self.unconstrain_window_popup(xdg_popup, window, output);
if let Err(err) = popup.send_pending_configure() {
warn!("error re-configuring reactive popup: {err:?}");
}