Rearrange some CLI and IPC enum values

This commit is contained in:
Ivan Molodetskikh
2024-09-02 08:53:50 +03:00
parent b7901579d5
commit 332af8b062
3 changed files with 27 additions and 27 deletions
+4 -4
View File
@@ -62,10 +62,12 @@ pub enum Msg {
Outputs,
/// List workspaces.
Workspaces,
/// Print information about the focused window.
FocusedWindow,
/// Get the configured keyboard layouts.
KeyboardLayouts,
/// Print information about the focused output.
FocusedOutput,
/// Print information about the focused window.
FocusedWindow,
/// Perform an action.
Action {
#[command(subcommand)]
@@ -86,8 +88,6 @@ pub enum Msg {
#[command(subcommand)]
action: OutputAction,
},
/// Get the configured keyboard layouts.
KeyboardLayouts,
/// Start continuously receiving events from the compositor.
EventStream,
/// Print the version of the running niri instance.
+11 -11
View File
@@ -255,6 +255,17 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply {
let outputs = ipc_outputs.values().cloned().map(|o| (o.name.clone(), o));
Response::Outputs(outputs.collect())
}
Request::Workspaces => {
let state = ctx.event_stream_state.borrow();
let workspaces = state.workspaces.workspaces.values().cloned().collect();
Response::Workspaces(workspaces)
}
Request::KeyboardLayouts => {
let state = ctx.event_stream_state.borrow();
let layout = state.keyboard_layouts.keyboard_layouts.clone();
let layout = layout.expect("keyboard layouts should be set at startup");
Response::KeyboardLayouts(layout)
}
Request::FocusedWindow => {
let state = ctx.event_stream_state.borrow();
let windows = &state.windows.windows;
@@ -294,11 +305,6 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply {
Response::OutputConfigChanged(response)
}
Request::Workspaces => {
let state = ctx.event_stream_state.borrow();
let workspaces = state.workspaces.workspaces.values().cloned().collect();
Response::Workspaces(workspaces)
}
Request::FocusedOutput => {
let (tx, rx) = async_channel::bounded(1);
ctx.event_loop.insert_idle(move |state| {
@@ -325,12 +331,6 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply {
let output = result.map_err(|_| String::from("error getting active output info"))?;
Response::FocusedOutput(output)
}
Request::KeyboardLayouts => {
let state = ctx.event_stream_state.borrow();
let layout = state.keyboard_layouts.keyboard_layouts.clone();
let layout = layout.expect("keyboard layouts should be set at startup");
Response::KeyboardLayouts(layout)
}
Request::EventStream => Response::Handled,
};