feat: add window management (list, minimize-all, focus, maximize)
This commit is contained in:
parent
c9643c8543
commit
9f06d84f28
7 changed files with 277 additions and 1 deletions
|
|
@ -233,6 +233,80 @@ pub async fn request_type(
|
|||
}
|
||||
}
|
||||
|
||||
/// GET /sessions/:id/windows
|
||||
pub async fn list_windows(
|
||||
Path(session_id): Path<String>,
|
||||
State(state): State<AppState>,
|
||||
) -> impl IntoResponse {
|
||||
match dispatch(&state, &session_id, "list_windows", |rid| {
|
||||
ServerMessage::ListWindowsRequest { request_id: rid }
|
||||
})
|
||||
.await
|
||||
{
|
||||
Ok(ClientMessage::ListWindowsResponse { windows, .. }) => (
|
||||
StatusCode::OK,
|
||||
Json(serde_json::json!({ "windows": windows })),
|
||||
)
|
||||
.into_response(),
|
||||
Ok(ClientMessage::Error { message, .. }) => (
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(serde_json::json!({ "error": message })),
|
||||
)
|
||||
.into_response(),
|
||||
Ok(_) => (
|
||||
StatusCode::BAD_GATEWAY,
|
||||
Json(serde_json::json!({ "error": "Unexpected response from client" })),
|
||||
)
|
||||
.into_response(),
|
||||
Err(e) => e.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
/// POST /sessions/:id/windows/minimize-all
|
||||
pub async fn minimize_all(
|
||||
Path(session_id): Path<String>,
|
||||
State(state): State<AppState>,
|
||||
) -> impl IntoResponse {
|
||||
match dispatch(&state, &session_id, "minimize_all", |rid| {
|
||||
ServerMessage::MinimizeAllRequest { request_id: rid }
|
||||
})
|
||||
.await
|
||||
{
|
||||
Ok(_) => (StatusCode::OK, Json(serde_json::json!({ "ok": true }))).into_response(),
|
||||
Err(e) => e.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
/// POST /sessions/:id/windows/:window_id/focus
|
||||
pub async fn focus_window(
|
||||
Path((session_id, window_id)): Path<(String, u64)>,
|
||||
State(state): State<AppState>,
|
||||
) -> impl IntoResponse {
|
||||
match dispatch(&state, &session_id, "focus_window", |rid| {
|
||||
ServerMessage::FocusWindowRequest { request_id: rid, window_id }
|
||||
})
|
||||
.await
|
||||
{
|
||||
Ok(_) => (StatusCode::OK, Json(serde_json::json!({ "ok": true }))).into_response(),
|
||||
Err(e) => e.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
/// POST /sessions/:id/windows/:window_id/maximize
|
||||
pub async fn maximize_and_focus(
|
||||
Path((session_id, window_id)): Path<(String, u64)>,
|
||||
State(state): State<AppState>,
|
||||
) -> impl IntoResponse {
|
||||
match dispatch(&state, &session_id, "maximize_and_focus", |rid| {
|
||||
ServerMessage::MaximizeAndFocusRequest { request_id: rid, window_id }
|
||||
})
|
||||
.await
|
||||
{
|
||||
Ok(_) => (StatusCode::OK, Json(serde_json::json!({ "ok": true }))).into_response(),
|
||||
Err(e) => e.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
/// POST /sessions/:id/label
|
||||
#[derive(Deserialize)]
|
||||
pub struct LabelBody {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue