Skip to content

Commit

Permalink
Send wayfire-shell toggle menu event on activator
Browse files Browse the repository at this point in the history
Update wayfire-shell protocol to include a toggle menu event on the output.
Clients using wayfire-shell protocol can listen for this event and open a
menu in response.
  • Loading branch information
soreau committed Jan 14, 2024
1 parent 2676a3c commit f0d4d09
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion metadata/expo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<option name="toggle" type="activator">
<_short>Toggle</_short>
<_long>Shows an overview of all workspaces with the specified activator. Pressing again exits.</_long>
<default>&lt;super&gt;</default>
<default>&lt;super&gt; KEY_E</default>
</option>
<option name="background" type="color">
<_short>Background color</_short>
Expand Down
5 changes: 5 additions & 0 deletions metadata/wayfire-shell.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
<_short>Wayfire Shell Protocol</_short>
<_long>An implementation of the wayfire-shell protocol.</_long>
<category>Utility</category>
<option name="toggle_menu" type="activator">
<_short>Toggle Menu</_short>
<_long>Toggles menu with the specified activator.</_long>
<default>&lt;super&gt;</default>
</option>
</plugin>
</wayfire>
14 changes: 14 additions & 0 deletions plugins/protocols/wayfire-shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "wayfire/render-manager.hpp"
#include "wayfire-shell-unstable-v2-protocol.h"
#include "wayfire/signal-definitions.hpp"
#include "plugins/ipc/ipc-activator.hpp"

/* ----------------------------- wfs_hotspot -------------------------------- */
static void handle_hotspot_destroy(wl_resource *resource);
Expand Down Expand Up @@ -196,6 +197,7 @@ static struct zwf_output_v2_interface zwf_output_impl = {
*/
class wfs_output
{
wf::ipc_activator_t toggle_menu{"wayfire-shell/toggle_menu"};
uint32_t num_inhibits = 0;
wl_resource *resource;
wf::output_t *output;
Expand Down Expand Up @@ -228,6 +230,17 @@ class wfs_output
}
};

wf::ipc_activator_t::handler_t toggle_menu_cb = [=] (wf::output_t *toggle_menu_output, wayfire_view)
{
if (output != toggle_menu_output)
{
return false;
}

zwf_output_v2_send_toggle_menu(resource);
return true;
};

public:
wfs_output(wf::output_t *output, wl_client *client, int id)
{
Expand All @@ -237,6 +250,7 @@ class wfs_output
wl_resource_set_implementation(resource, &zwf_output_impl, this, handle_output_destroy);
output->connect(&on_fullscreen_layer_focused);
wf::get_core().output_layout->connect(&on_output_removed);
toggle_menu.set_handler(toggle_menu_cb);
}

~wfs_output()
Expand Down
8 changes: 8 additions & 0 deletions proto/wayfire-shell-unstable-v2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
<arg name="timeout" type="uint" summary="minimum time for the mouse to be in the hotspot"/>
<arg name="id" type="new_id" interface="zwf_hotspot_v2"/>
</request>

<event name="toggle_menu">
<description summary="Toggle menu event">
Tells the menu to open.

Emitted using an activator binding.
</description>
</event>
</interface>

<interface name="zwf_hotspot_v2" version="1">
Expand Down
6 changes: 5 additions & 1 deletion wayfire.ini
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ activate = <ctrl> <alt> BTN_LEFT

# Show an overview of all workspaces.
[expo]
toggle = <super>
toggle = <super> KEY_E
# Select a workspace.
# Workspaces are arranged into a grid of 3 × 3.
# The numbering is left to right, line by line.
Expand Down Expand Up @@ -309,6 +309,10 @@ next_output_with_win = <super> <shift> KEY_O
[invert]
toggle = <super> KEY_I

# Send toggle menu event.
[wayfire-shell]
toggle_menu = <super>

# Rules ────────────────────────────────────────────────────────────────────────

# Example configuration:
Expand Down

0 comments on commit f0d4d09

Please sign in to comment.