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

programmable activators #873

Merged
merged 3 commits into from
Nov 20, 2020
Merged

programmable activators #873

merged 3 commits into from
Nov 20, 2020

Conversation

ammen99
Copy link
Member

@ammen99 ammen99 commented Nov 15, 2020

Still WIP, but should eventually:

fix #655
fix #833

This PR adds the long-awaited support for calling arbitrary plugins via their activator bindings. Example patch to make Expo activate on all workspaces at the same time (although I recommend actually doing an external plugin which activates all Expos on all outputs):

diff --git a/plugins/single_plugins/expo.cpp b/plugins/single_plugins/expo.cpp
index 2d4e11b6..8092898b 100644
--- a/plugins/single_plugins/expo.cpp
+++ b/plugins/single_plugins/expo.cpp
@@ -35,8 +35,23 @@ class wayfire_expo : public wf::plugin_interface_t
         return wf::point_t{x, y};
     }
 
-    wf::activator_callback toggle_cb = [=] (auto)
+    wf::activator_callback toggle_cb = [=] (auto ev)
     {
+        // Avoid self-loop
+        if (ev.source != wf::activator_source_t::PLUGIN)
+        {
+            wf::activator_data_t data;
+            data.source = wf::activator_source_t::PLUGIN;
+
+            for (auto& wo : wf::get_core().output_layout->get_outputs())
+            {
+                if (wo != output) {
+                    wo->call_plugin("expo/toggle", data);
+                }
+            }
+        }
+
         if (!state.active)
         {
             return activate();

@ammen99 ammen99 marked this pull request as ready for review November 15, 2020 20:21
@ammen99
Copy link
Member Author

ammen99 commented Nov 17, 2020

@myfreeweb I took your changes from #828 and put them in the appropriate place. Now you can use an activator binding in caps2esc I think.

The reason to use activator bindings is that there you actually can differentiate what triggered the binding - and modifier and keybinding are separate triggers.

@damianatorrpm
Copy link
Contributor

Also testing this now inse hotspot is merged

ammen99 and others added 3 commits November 20, 2020 07:30
Currently this is the only way for plugins to e.g. distinguish whether
the '<shift>' binding was pressed by the left or right Shift key.
@ammen99 ammen99 merged commit fdae6ef into master Nov 20, 2020
@ammen99 ammen99 deleted the programmable-activators branch November 20, 2020 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make activator bindings receive a struct instead of uint32_t Programatically callable activators
3 participants