Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a window list to IPC workspace messages #506

Closed
wants to merge 1 commit into from

Conversation

TheZoq2
Copy link
Contributor

@TheZoq2 TheZoq2 commented Jul 2, 2024

I want workspaces to list the windows they contain so I can have icons for the programs active on each workspace. This should make that work for my usecase, but I'm not sure if this is the "correct" way to implement this.

@@ -237,3 +226,20 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply {

Ok(response)
}

pub fn smithay_window_to_ipc(window: &smithay::desktop::Window) -> niri_ipc::Window {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally I'd have wanted this function to be a method on either niri_ipc::Window or on smithay::desktop::Window

However, doing that would either require adding smithay and some other stuff as deps of niri-ipc, or adding an extension trait which would be impl'd on smithay windows. That was extra annoying since methods are being called on the window which requires more work.

For now, this is the cleanest solution I came up with


impl Layout<Mapped> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dragging ipc_workspaces out of the impl<W: LayoutElement> block isn't super pretty, but without this, I can't access any window information here as far as I can tell

@@ -523,6 +523,8 @@ pub struct Workspace {
pub output: Option<String>,
/// Whether the workspace is currently active on its output.
pub is_active: bool,
/// The windows currently on this workspace
pub windows: Vec<Window>,
Copy link
Owner

Choose a reason for hiding this comment

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

This is one of the things that I'm not sure what the best design is. We have a MappedId now which we can add to niri_ipc::Window (maybe not right away, need to think some more if it should be u32 or u64). So we can have this as essentially pub windows: Vec<MappedId>, thereby avoiding sending a lot of extra data (niri_ipc::Window will surely grow in size in the future) along with every workspace. Then there can be another IPC call to get window info. This will be similar to how output is Option<String> and not Option<Output>.

Copy link
Owner

Choose a reason for hiding this comment

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

It does mean there's a race between niri msg workspaces and niri msg windows (or something), but then there will be the event stream IPC to solve that cleanly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, that sounds like a pretty good solution, I'm not sure what the overhead of IPC is but having too large things sent over doesn't seem ideal

@YaLTeR
Copy link
Owner

YaLTeR commented Aug 30, 2024

I think the event stream IPC should cover this case, could you test #453 to see if you can get what you wanted to work?

  1. Wait for WorkspacesChanged
  2. Wait for WindowsChanged
  3. Group windows by their workspace_id

@YaLTeR
Copy link
Owner

YaLTeR commented Sep 2, 2024

I added niri msg windows, so now you can get workspace IDs from niri msg --json workspaces, then get windows for a workspace ID using something like niri msg --json windows | jq '.[] | select(.workspace_id == 6)'

@TheZoq2
Copy link
Contributor Author

TheZoq2 commented Sep 6, 2024

Excellent, that should satisfy my use case so I'll close this

@TheZoq2 TheZoq2 closed this Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants