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

ipc: add get active output #2230

Merged
merged 18 commits into from
Mar 21, 2024
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
Loading