Skip to content

Commit

Permalink
wm-actions: add method for home button in plamo
Browse files Browse the repository at this point in the history
its just original toggle_showdesktop but its not a toggle, only hides clients

Signed-off-by: Deepak Kumar <[email protected]>
  • Loading branch information
WHO53 committed Jan 21, 2025
1 parent aba4382 commit 9b1440d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions metadata/wm-actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<_long>Show the desktop.</_long>
<default>disabled</default>
</option>
<option name="plamo_showdesktop" type="activator">
<_short>Plasmo Show Desktop</_short>
<_long>Show the desktop.</_long>
<default>disabled</default>
</option>
<option name="send_to_back" type="activator">
<_short>Send to back</_short>
<_long>Send the active view to behind all other views.</_long>
Expand Down
32 changes: 32 additions & 0 deletions plugins/wm-actions/wm-actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,31 @@ class wayfire_wm_actions_output_t : public wf::per_output_plugin_instance_t
return true;
}

bool on_plamo_showdesktop()
{
showdesktop_active = !showdesktop_active;

if (showdesktop_active)
{
for (auto& view : output->wset()->get_views())
{
if (!view->minimized)
{
wf::get_core().default_wm->minimize_request(view, true);
view->store_data(std::make_unique<wf::custom_data_t>(), "wm-actions-showdesktop");
}
}

output->connect(&view_set_output);
output->connect(&workspace_changed);
output->connect(&view_minimized);
output->connect(&on_view_mapped);
return true;
}

return true;
}

void do_send_to_back(wayfire_view view)
{
auto view_root = view->get_root_node();
Expand Down Expand Up @@ -397,6 +422,7 @@ class wayfire_wm_actions_t : public wf::plugin_interface_t,
{
wf::shared_data::ref_ptr_t<wf::ipc::method_repository_t> ipc_repo;
wf::ipc_activator_t toggle_showdesktop{"wm-actions/toggle_showdesktop"};
wf::ipc_activator_t plamo_showdesktop{"wm-actions/plamo_showdesktop"};

public:
void init() override
Expand All @@ -408,6 +434,7 @@ class wayfire_wm_actions_t : public wf::plugin_interface_t,
ipc_repo->register_method("wm-actions/set-sticky", ipc_set_sticky);
ipc_repo->register_method("wm-actions/send-to-back", ipc_send_to_back);
toggle_showdesktop.set_handler(on_toggle_showdesktop);
plamo_showdesktop.set_handler(on_plamo_showdesktop);
}

void fini() override
Expand Down Expand Up @@ -500,6 +527,11 @@ class wayfire_wm_actions_t : public wf::plugin_interface_t,
{
return this->output_instance[output]->on_toggle_showdesktop();
};

wf::ipc_activator_t::handler_t on_plamo_showdesktop = [=] (wf::output_t *output, wayfire_view)
{
return this->output_instance[output]->on_plamo_showdesktop();
};
};

DECLARE_WAYFIRE_PLUGIN(wayfire_wm_actions_t);

0 comments on commit 9b1440d

Please sign in to comment.