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 view alpha #2221

Merged
merged 25 commits into from
Mar 18, 2024
Merged
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions plugins/single_plugins/alpha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class wayfire_alpha : public wf::plugin_interface_t
min_value.set_callback(min_value_changed);
wf::get_core().bindings->add_axis(modifier, &axis_cb);
ipc_repo->register_method("wf/alpha/set-view-alpha", ipc_set_view_alpha);
ipc_repo->register_method("wf/alpha/get-view-alpha", ipc_get_view_alpha);
killown marked this conversation as resolved.
Show resolved Hide resolved
}

wf::ipc::method_callback ipc_set_view_alpha = [=] (nlohmann::json data) -> nlohmann::json
Expand All @@ -73,6 +74,22 @@ class wayfire_alpha : public wf::plugin_interface_t
return wf::ipc::json_ok();
};

wf::ipc::method_callback ipc_get_view_alpha = [=] (nlohmann::json data) -> nlohmann::json
{
WFJSON_EXPECT_FIELD(data, "view-id", number_unsigned);

auto view = wf::ipc::find_view_by_id(data["view-id"]);
if (view && view->is_mapped())
{
auto response = wf::ipc::json_ok();
response["alpha"] = ensure_transformer(view)->alpha;
killown marked this conversation as resolved.
Show resolved Hide resolved
return response;
} else
{
return wf::ipc::json_error("Failed to find view with given id. Maybe it was closed?");
}
};

std::shared_ptr<wf::scene::view_2d_transformer_t> ensure_transformer(wayfire_view view)
{
auto tmgr = view->get_transformed_node();
Expand Down
Loading