Skip to content

Commit

Permalink
ipc: add get active output (#2230)
Browse files Browse the repository at this point in the history
  • Loading branch information
killown authored Mar 21, 2024
1 parent 3d2ddca commit 101dad0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plugins/single_plugins/ipc-rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class ipc_rules_t : public wf::plugin_interface_t, public wf::per_output_tracker
method_repository->register_method("window-rules/configure-view", configure_view);
method_repository->register_method("window-rules/focus-view", focus_view);
method_repository->register_method("window-rules/get-focused-view", get_focused_view);
method_repository->register_method("window-rules/get-focused-output", get_focused_output);
method_repository->register_method("window-rules/close-view", close_view);
method_repository->connect(&on_client_disconnected);
wf::get_core().connect(&on_view_mapped);
Expand All @@ -168,6 +169,7 @@ class ipc_rules_t : public wf::plugin_interface_t, public wf::per_output_tracker
method_repository->unregister_method("window-rules/configure-view");
method_repository->unregister_method("window-rules/focus-view");
method_repository->unregister_method("window-rules/get-focused-view");
method_repository->unregister_method("window-rules/get-focused-output");
method_repository->unregister_method("window-rules/close-view");
fini_output_tracking();
}
Expand Down Expand Up @@ -249,6 +251,22 @@ class ipc_rules_t : public wf::plugin_interface_t, public wf::per_output_tracker
}
};

wf::ipc::method_callback get_focused_output = [=] (nlohmann::json data)
{
auto active_output = wf::get_core().seat->get_active_output();
auto response = wf::ipc::json_ok();

if (active_output)
{
response["info"] = output_to_json(active_output);
} else
{
response["info"] = nullptr;
}

return response;
};

wf::ipc::method_callback focus_view = [=] (nlohmann::json data)
{
WFJSON_EXPECT_FIELD(data, "id", number_integer);
Expand Down

0 comments on commit 101dad0

Please sign in to comment.