From af30cc8df68b29973c8b9eec290f9e6b93463929 Mon Sep 17 00:00:00 2001 From: yrkv Date: Sat, 16 Aug 2025 01:42:08 -0700 Subject: niri-ipc: Add window positions and sizes (#1265) * Add window sizes and positions to the IPC * basic fixes * report window_loc instead of window pos * clean ups * make scrolling indices 1-based * add printing to niri msg windows * don't include render offset in floating tile pos --------- Co-authored-by: Ivan Molodetskikh --- src/layout/floating.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/layout/floating.rs') diff --git a/src/layout/floating.rs b/src/layout/floating.rs index 98927c0d..bd976d7d 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -3,7 +3,7 @@ use std::iter::zip; use std::rc::Rc; use niri_config::{PresetSize, RelativeTo}; -use niri_ipc::{PositionChange, SizeChange}; +use niri_ipc::{PositionChange, SizeChange, WindowLayout}; use smithay::backend::renderer::gles::GlesRenderer; use smithay::utils::{Logical, Point, Rectangle, Scale, Serial, Size}; @@ -322,6 +322,22 @@ impl FloatingSpace { }) } + pub fn tiles_with_ipc_layouts(&self) -> impl Iterator, WindowLayout)> { + let scale = self.scale; + self.tiles_with_offsets().map(move |(tile, offset)| { + // Do not include animated render offset here to avoid IPC spam. + let pos = offset; + // Round to physical pixels. + let pos = pos.to_physical_precise_round(scale).to_logical(scale); + + let layout = WindowLayout { + tile_pos_in_workspace_view: Some(pos.into()), + ..tile.ipc_layout_template() + }; + (tile, layout) + }) + } + pub fn new_window_toplevel_bounds(&self, rules: &ResolvedWindowRules) -> Size { let border_config = rules.border.resolve_against(self.options.border); compute_toplevel_bounds(border_config, self.working_area.size) -- cgit