fix: synchronize floating window geometry
This commit is contained in:
1 parent
e1f1c1b9b6
commit
677e0ba5d1
5 files changed
+165
-5
No files matched your search
+29
-1
@@ -21,7 +21,7 @@ use smithay::{
|
||||
protocol::wl_surface::WlSurface,
|
||||
},
|
||||
},
|
||||
utils::{Logical, Point},
|
||||
utils::{Logical, Point, Size},
|
||||
wayland::{
|
||||
compositor::{CompositorClientState, CompositorState},
|
||||
fractional_scale::FractionalScaleManagerState,
|
||||
@@ -440,6 +440,34 @@ impl Ferese {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_floating_window(&self, window: &Window) -> bool {
|
||||
self.window_ids
|
||||
.get(window)
|
||||
.and_then(|id| self.workspaces.placement(*id))
|
||||
.is_some_and(|placement| matches!(placement, WindowPlacement::Floating { .. }))
|
||||
}
|
||||
|
||||
pub fn set_floating_window_geometry(
|
||||
&mut self,
|
||||
window: &Window,
|
||||
location: Point<i32, Logical>,
|
||||
size: Size<i32, Logical>,
|
||||
) {
|
||||
let Some(id) = self.window_ids.get(window).copied() else {
|
||||
return;
|
||||
};
|
||||
let rect = Rect::new(
|
||||
location.x as f64,
|
||||
location.y as f64,
|
||||
size.w.max(1) as f64,
|
||||
size.h.max(1) as f64,
|
||||
);
|
||||
|
||||
if let Err(error) = self.workspaces.set_floating_rect(id, rect) {
|
||||
tracing::error!(%error, ?id, "failed to update floating window geometry");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn switch_workspace(&mut self, index: u32) {
|
||||
let focus = match self.workspaces.switch_to_numeric(index) {
|
||||
Ok(focus) => focus,
|
||||
|
||||
Reference in new issue
Block a user