From 1d5a04017ef98eaf9c5c68cc8a4a25431544bd46 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 13:50:42 +0200 Subject: [PATCH 01/22] add option in xml --- metadata/hide-cursor.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/metadata/hide-cursor.xml b/metadata/hide-cursor.xml index 8c61fcb..7a31af7 100644 --- a/metadata/hide-cursor.xml +++ b/metadata/hide-cursor.xml @@ -15,5 +15,9 @@ 2000 250 + From 7cb1227ac9a7fac0c4abb99635a28750c514df09 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 13:55:15 +0200 Subject: [PATCH 02/22] add disabled_for option --- src/hide-cursor.cpp | 195 ++++++++++++++++++++++++-------------------- 1 file changed, 107 insertions(+), 88 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index c7ffd94..4f0529c 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -3,115 +3,134 @@ * * Copyright (c) 2023 Scott Moreau * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in the - * Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ -#include +#include +#include #include #include -#include +#include #include #include -namespace wf_hide_cursor -{ +namespace wf_hide_cursor { + bool hidden; -class wayfire_hide_cursor -{ - wf::option_wrapper_t hide_delay{"hide-cursor/hide_delay"}; - wf::wl_timer hide_timer; - - public: - wayfire_hide_cursor() - { - hidden = false; - setup_hide_timer(); - wf::get_core().connect(&pointer_motion); +class wayfire_hide_cursor { + wf::option_wrapper_t hide_delay{"hide-cursor/hide_delay"}; + wf::view_matcher_t disabled_for{"hide-cursor/disabled_for"}; + wf::wl_timer hide_timer; + + void hide() { + if (!hidden) { + wf::get_core().hide_cursor(); + hidden = true; } + } - wf::signal::connection_t> pointer_motion = - [=] (wf::input_event_signal *ev) - { - setup_hide_timer(); - if (hidden) - { - wf::get_core().unhide_cursor(); - hidden = false; - } - }; - - void setup_hide_timer() - { - hide_timer.disconnect(); - hide_timer.set_timeout(hide_delay, [=] () - { - if (!hidden) - { - wf::get_core().hide_cursor(); - hidden = true; - } - }); + void unhide() { + if (hidden) { + wf::get_core().unhide_cursor(); + hidden = false; } + } - ~wayfire_hide_cursor() - { - pointer_motion.disconnect(); - hide_timer.disconnect(); - if (hidden) - { - wf::get_core().unhide_cursor(); - } + void setup_hide_timer() { + hide_timer.disconnect(); + + hide_timer.set_timeout(hide_delay, [=]() { reevaluate(); }); + } + +public: + wayfire_hide_cursor() { + hidden = false; + setup_hide_timer(); + + wf::get_core().connect(&pointer_motion); + wf::get_core().connect(&workspace_changed); + } + + void reevaluate() { + auto view = wf::get_core().get_cursor_focus_view(); + + if (view && disabled_for.matches(view)) { + unhide(); + hide_timer.disconnect(); + return; } + + hide(); + } + + wf::signal::connection_t> + pointer_motion = + [=](wf::input_event_signal *ev) { + auto view = wf::get_core().get_cursor_focus_view(); + + if (view && disabled_for.matches(view)) { + unhide(); + hide_timer.disconnect(); + return; + } + + unhide(); + setup_hide_timer(); + }; + + wf::signal::connection_t workspace_changed = + [=](wf::workspace_changed_signal *ev) { reevaluate(); }; + + ~wayfire_hide_cursor() { + pointer_motion.disconnect(); + workspace_changed.disconnect(); + hide_timer.disconnect(); + unhide(); + } }; -class wayfire_hide_cursor_plugin : public wf::per_output_plugin_instance_t -{ - wf::shared_data::ref_ptr_t global_idle; - - wf::activator_callback toggle_cb = [=] (auto) - { - hidden = !hidden; - - if (hidden) - { - wf::get_core().hide_cursor(); - } else - { - wf::get_core().unhide_cursor(); - } - - return true; - }; - - public: - void init() override - { - output->add_activator( - wf::option_wrapper_t{"hide-cursor/toggle"}, - &toggle_cb); - } +class wayfire_hide_cursor_plugin : public wf::per_output_plugin_instance_t { + wf::shared_data::ref_ptr_t global_idle; + + wf::activator_callback toggle_cb = [=](auto) { + hidden = !hidden; - void fini() override - { - output->rem_binding(&toggle_cb); + if (hidden) { + wf::get_core().hide_cursor(); + } else { + wf::get_core().unhide_cursor(); } + + return true; + }; + +public: + void init() override { + output->add_activator( + wf::option_wrapper_t{"hide-cursor/toggle"}, + &toggle_cb); + } + + void fini() override { output->rem_binding(&toggle_cb); } }; DECLARE_WAYFIRE_PLUGIN(wf::per_output_plugin_t); -} + +} // namespace wf_hide_cursor From 8525fdefa851f279d90e0333499d66e2f7b2780d Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 14:41:44 +0200 Subject: [PATCH 03/22] preserve original formatting --- src/hide-cursor.cpp | 228 ++++++++++++++++++++++++-------------------- 1 file changed, 127 insertions(+), 101 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index 4f0529c..5669128 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -3,134 +3,160 @@ * * Copyright (c) 2023 Scott Moreau * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the + * Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include -#include +#include #include #include -#include +#include #include #include -namespace wf_hide_cursor { - +namespace wf_hide_cursor +{ bool hidden; -class wayfire_hide_cursor { - wf::option_wrapper_t hide_delay{"hide-cursor/hide_delay"}; - wf::view_matcher_t disabled_for{"hide-cursor/disabled_for"}; - wf::wl_timer hide_timer; - - void hide() { - if (!hidden) { - wf::get_core().hide_cursor(); - hidden = true; +class wayfire_hide_cursor +{ + wf::option_wrapper_t hide_delay{"hide-cursor/hide_delay"}; + wf::view_matcher_t disabled_for{"hide-cursor/disabled_for"}; + wf::wl_timer hide_timer; + + public: + wayfire_hide_cursor() + { + hidden = false; + setup_hide_timer(); + wf::get_core().connect(&pointer_motion); + wf::get_core().connect(&workspace_changed); } - } - void unhide() { - if (hidden) { - wf::get_core().unhide_cursor(); - hidden = false; - } - } - - void setup_hide_timer() { - hide_timer.disconnect(); - - hide_timer.set_timeout(hide_delay, [=]() { reevaluate(); }); - } + void reevaluate() + { + auto view = wf::get_core().get_cursor_focus_view(); -public: - wayfire_hide_cursor() { - hidden = false; - setup_hide_timer(); - - wf::get_core().connect(&pointer_motion); - wf::get_core().connect(&workspace_changed); - } + if (view && disabled_for.matches(view)) + { + if (hidden) + { + wf::get_core().unhide_cursor(); + hidden = false; + } - void reevaluate() { - auto view = wf::get_core().get_cursor_focus_view(); + hide_timer.disconnect(); + return; + } - if (view && disabled_for.matches(view)) { - unhide(); - hide_timer.disconnect(); - return; + if (!hidden) + { + wf::get_core().hide_cursor(); + hidden = true; + } } - hide(); - } - - wf::signal::connection_t> - pointer_motion = - [=](wf::input_event_signal *ev) { - auto view = wf::get_core().get_cursor_focus_view(); - - if (view && disabled_for.matches(view)) { - unhide(); - hide_timer.disconnect(); - return; + wf::signal::connection_t> pointer_motion = + [=] (wf::input_event_signal *ev) + { + auto view = wf::get_core().get_cursor_focus_view(); + + if (view && disabled_for.matches(view)) + { + if (hidden) + { + wf::get_core().unhide_cursor(); + hidden = false; } - unhide(); - setup_hide_timer(); - }; - - wf::signal::connection_t workspace_changed = - [=](wf::workspace_changed_signal *ev) { reevaluate(); }; + hide_timer.disconnect(); + return; + } + + if (hidden) + { + wf::get_core().unhide_cursor(); + hidden = false; + } + + setup_hide_timer(); + }; + + wf::signal::connection_t workspace_changed = + [=] (wf::workspace_changed_signal *ev) + { + reevaluate(); + }; + + void setup_hide_timer() + { + hide_timer.disconnect(); + hide_timer.set_timeout(hide_delay, [=] () + { + reevaluate(); + }); + } - ~wayfire_hide_cursor() { - pointer_motion.disconnect(); - workspace_changed.disconnect(); - hide_timer.disconnect(); - unhide(); - } + ~wayfire_hide_cursor() + { + pointer_motion.disconnect(); + workspace_changed.disconnect(); + hide_timer.disconnect(); + if (hidden) + { + wf::get_core().unhide_cursor(); + hidden = false; + } + } }; -class wayfire_hide_cursor_plugin : public wf::per_output_plugin_instance_t { - wf::shared_data::ref_ptr_t global_idle; - - wf::activator_callback toggle_cb = [=](auto) { - hidden = !hidden; - - if (hidden) { - wf::get_core().hide_cursor(); - } else { - wf::get_core().unhide_cursor(); +class wayfire_hide_cursor_plugin : public wf::per_output_plugin_instance_t +{ + wf::shared_data::ref_ptr_t global_idle; + + wf::activator_callback toggle_cb = [=] (auto) + { + hidden = !hidden; + + if (hidden) + { + wf::get_core().hide_cursor(); + } else + { + wf::get_core().unhide_cursor(); + } + + return true; + }; + + public: + void init() override + { + output->add_activator( + wf::option_wrapper_t{"hide-cursor/toggle"}, + &toggle_cb); } - return true; - }; - -public: - void init() override { - output->add_activator( - wf::option_wrapper_t{"hide-cursor/toggle"}, - &toggle_cb); - } - - void fini() override { output->rem_binding(&toggle_cb); } + void fini() override + { + output->rem_binding(&toggle_cb); + } }; DECLARE_WAYFIRE_PLUGIN(wf::per_output_plugin_t); - -} // namespace wf_hide_cursor +} From ca677b310dd47cad244c4764835477ea62703f30 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 15:18:30 +0200 Subject: [PATCH 04/22] unify duplicate code --- src/hide-cursor.cpp | 52 +++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index 5669128..2f88264 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -39,11 +39,20 @@ class wayfire_hide_cursor wf::view_matcher_t disabled_for{"hide-cursor/disabled_for"}; wf::wl_timer hide_timer; + void debounce_reevaluate() + { + hide_timer.disconnect(); + hide_timer.set_timeout(hide_delay, [=] () + { + reevaluate(); + }); + } + public: wayfire_hide_cursor() { hidden = false; - setup_hide_timer(); + debounce_reevaluate(); wf::get_core().connect(&pointer_motion); wf::get_core().connect(&workspace_changed); } @@ -54,37 +63,14 @@ class wayfire_hide_cursor if (view && disabled_for.matches(view)) { - if (hidden) - { - wf::get_core().unhide_cursor(); - hidden = false; - } - hide_timer.disconnect(); - return; - } - - if (!hidden) - { - wf::get_core().hide_cursor(); - hidden = true; - } - } - - wf::signal::connection_t> pointer_motion = - [=] (wf::input_event_signal *ev) - { - auto view = wf::get_core().get_cursor_focus_view(); - if (view && disabled_for.matches(view)) - { if (hidden) { wf::get_core().unhide_cursor(); hidden = false; } - hide_timer.disconnect(); return; } @@ -94,7 +80,13 @@ class wayfire_hide_cursor hidden = false; } - setup_hide_timer(); + debounce_reevaluate(); + } + + wf::signal::connection_t> pointer_motion = + [=] (wf::input_event_signal *ev) + { + reevaluate(); }; wf::signal::connection_t workspace_changed = @@ -103,15 +95,6 @@ class wayfire_hide_cursor reevaluate(); }; - void setup_hide_timer() - { - hide_timer.disconnect(); - hide_timer.set_timeout(hide_delay, [=] () - { - reevaluate(); - }); - } - ~wayfire_hide_cursor() { pointer_motion.disconnect(); @@ -120,7 +103,6 @@ class wayfire_hide_cursor if (hidden) { wf::get_core().unhide_cursor(); - hidden = false; } } }; From 050017afba0ccf33f8d092d9918aa631ef2bbae3 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 15:21:26 +0200 Subject: [PATCH 05/22] accept "none" value --- src/hide-cursor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index 2f88264..635d9e9 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -36,7 +36,8 @@ bool hidden; class wayfire_hide_cursor { wf::option_wrapper_t hide_delay{"hide-cursor/hide_delay"}; - wf::view_matcher_t disabled_for{"hide-cursor/disabled_for"}; + wf::option_wrapper_t disabled_for{"hide-cursor/disabled_for"}; + wf::view_matcher_t matcher{"hide-cursor/disabled_for"}; wf::wl_timer hide_timer; void debounce_reevaluate() @@ -61,7 +62,7 @@ class wayfire_hide_cursor { auto view = wf::get_core().get_cursor_focus_view(); - if (view && disabled_for.matches(view)) + if (disabled_for.get_value() != "none" && view && matcher.matches(view)) { hide_timer.disconnect(); From b18c52d9881ac9dfce1deba86e809f901cc4daff Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 15:21:33 +0200 Subject: [PATCH 06/22] none is the default --- metadata/hide-cursor.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata/hide-cursor.xml b/metadata/hide-cursor.xml index 7a31af7..f416508 100644 --- a/metadata/hide-cursor.xml +++ b/metadata/hide-cursor.xml @@ -16,7 +16,7 @@ 250 From b3144ecafb47616648a3f7d2ed3176b816bb241b Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 15:24:14 +0200 Subject: [PATCH 07/22] none is supported by default --- src/hide-cursor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index 635d9e9..e259a0f 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -36,8 +36,7 @@ bool hidden; class wayfire_hide_cursor { wf::option_wrapper_t hide_delay{"hide-cursor/hide_delay"}; - wf::option_wrapper_t disabled_for{"hide-cursor/disabled_for"}; - wf::view_matcher_t matcher{"hide-cursor/disabled_for"}; + wf::view_matcher_t disabled_for{"hide-cursor/disabled_for"}; wf::wl_timer hide_timer; void debounce_reevaluate() @@ -62,7 +61,7 @@ class wayfire_hide_cursor { auto view = wf::get_core().get_cursor_focus_view(); - if (disabled_for.get_value() != "none" && view && matcher.matches(view)) + if (view && disabled_for.matches(view)) { hide_timer.disconnect(); @@ -101,6 +100,7 @@ class wayfire_hide_cursor pointer_motion.disconnect(); workspace_changed.disconnect(); hide_timer.disconnect(); + if (hidden) { wf::get_core().unhide_cursor(); From d17ca3b447b5e692ab5e3488f97528665075e34a Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 16:01:27 +0200 Subject: [PATCH 08/22] complies to xml --- metadata/hide-cursor.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metadata/hide-cursor.xml b/metadata/hide-cursor.xml index f416508..3a182ff 100644 --- a/metadata/hide-cursor.xml +++ b/metadata/hide-cursor.xml @@ -15,9 +15,9 @@ 2000 250 - - From 98ea1c499bb263628a87a383309eb8085650a4d2 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 16:31:59 +0200 Subject: [PATCH 09/22] fix xml --- metadata/hide-cursor.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/metadata/hide-cursor.xml b/metadata/hide-cursor.xml index 3a182ff..b27f7de 100644 --- a/metadata/hide-cursor.xml +++ b/metadata/hide-cursor.xml @@ -21,3 +21,4 @@ none + From cfec9ee32fc211625fcd37264617025b662efdd7 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 16:32:16 +0200 Subject: [PATCH 10/22] fix debouncer --- src/hide-cursor.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index e259a0f..5c9aa40 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -39,12 +39,23 @@ class wayfire_hide_cursor wf::view_matcher_t disabled_for{"hide-cursor/disabled_for"}; wf::wl_timer hide_timer; - void debounce_reevaluate() + void restart_hide_timer() { hide_timer.disconnect(); hide_timer.set_timeout(hide_delay, [=] () { - reevaluate(); + auto view = wf::get_core().get_cursor_focus_view(); + + if (view && disabled_for.matches(view)) + { + return; + } + + if (!hidden) + { + wf::get_core().hide_cursor(); + hidden = true; + } }); } @@ -52,7 +63,8 @@ class wayfire_hide_cursor wayfire_hide_cursor() { hidden = false; - debounce_reevaluate(); + restart_hide_timer(); + wf::get_core().connect(&pointer_motion); wf::get_core().connect(&workspace_changed); } @@ -80,13 +92,19 @@ class wayfire_hide_cursor hidden = false; } - debounce_reevaluate(); + restart_hide_timer(); } wf::signal::connection_t> pointer_motion = [=] (wf::input_event_signal *ev) { - reevaluate(); + if (hidden) + { + wf::get_core().unhide_cursor(); + hidden = false; + } + + restart_hide_timer(); }; wf::signal::connection_t workspace_changed = From 16730d988e1cf11df11433fb970da730872d9035 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 17:30:13 +0200 Subject: [PATCH 11/22] simplify code + remove workspace switch event --- src/hide-cursor.cpp | 72 ++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 53 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index 5c9aa40..35aac8b 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -31,6 +31,7 @@ namespace wf_hide_cursor { + bool hidden; class wayfire_hide_cursor @@ -44,85 +45,49 @@ class wayfire_hide_cursor hide_timer.disconnect(); hide_timer.set_timeout(hide_delay, [=] () { - auto view = wf::get_core().get_cursor_focus_view(); - - if (view && disabled_for.matches(view)) - { - return; - } - - if (!hidden) - { - wf::get_core().hide_cursor(); - hidden = true; - } + hide_or_show_cursor(); }); } - public: - wayfire_hide_cursor() - { - hidden = false; - restart_hide_timer(); - - wf::get_core().connect(&pointer_motion); - wf::get_core().connect(&workspace_changed); - } - - void reevaluate() + void hide_or_show_cursor() { auto view = wf::get_core().get_cursor_focus_view(); if (view && disabled_for.matches(view)) - { - hide_timer.disconnect(); - - if (hidden) - { - wf::get_core().unhide_cursor(); - hidden = false; - } - - return; - } - - if (hidden) { wf::get_core().unhide_cursor(); hidden = false; + } else + { + wf::get_core().hide_cursor(); + hidden = true; } + } + public: + wayfire_hide_cursor() + { + hidden = false; restart_hide_timer(); + + wf::get_core().connect(&pointer_motion); } wf::signal::connection_t> pointer_motion = [=] (wf::input_event_signal *ev) { - if (hidden) - { - wf::get_core().unhide_cursor(); - hidden = false; - } - + wf::get_core().unhide_cursor(); + hidden = false; restart_hide_timer(); }; - wf::signal::connection_t workspace_changed = - [=] (wf::workspace_changed_signal *ev) - { - reevaluate(); - }; - ~wayfire_hide_cursor() { pointer_motion.disconnect(); - workspace_changed.disconnect(); hide_timer.disconnect(); - if (hidden) - { - wf::get_core().unhide_cursor(); - } + wf::get_core().unhide_cursor(); + hidden = false; } }; @@ -160,4 +125,5 @@ class wayfire_hide_cursor_plugin : public wf::per_output_plugin_instance_t }; DECLARE_WAYFIRE_PLUGIN(wf::per_output_plugin_t); + } From 1284c394b14bb4e9b5cdfa349d4b26c7d01cfabe Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 17:54:57 +0200 Subject: [PATCH 12/22] mouse functions --- src/hide-cursor.cpp | 46 +++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index 35aac8b..644f2a6 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -34,6 +34,29 @@ namespace wf_hide_cursor bool hidden; +void hide_cursor() +{ + wf::get_core().hide_cursor(); + hidden = true; +} + +void show_cursor() +{ + wf::get_core().unhide_cursor(); + hidden = false; +} + +void toggle_cursor() +{ + if (hidden) + { + show_cursor(); + } else + { + hide_cursor(); + } +} + class wayfire_hide_cursor { wf::option_wrapper_t hide_delay{"hide-cursor/hide_delay"}; @@ -55,12 +78,10 @@ class wayfire_hide_cursor if (view && disabled_for.matches(view)) { - wf::get_core().unhide_cursor(); - hidden = false; + show_cursor(); } else { - wf::get_core().hide_cursor(); - hidden = true; + hide_cursor(); } } @@ -76,8 +97,7 @@ class wayfire_hide_cursor wf::signal::connection_t> pointer_motion = [=] (wf::input_event_signal *ev) { - wf::get_core().unhide_cursor(); - hidden = false; + show_cursor(); restart_hide_timer(); }; @@ -86,8 +106,7 @@ class wayfire_hide_cursor pointer_motion.disconnect(); hide_timer.disconnect(); - wf::get_core().unhide_cursor(); - hidden = false; + show_cursor(); } }; @@ -97,16 +116,7 @@ class wayfire_hide_cursor_plugin : public wf::per_output_plugin_instance_t wf::activator_callback toggle_cb = [=] (auto) { - hidden = !hidden; - - if (hidden) - { - wf::get_core().hide_cursor(); - } else - { - wf::get_core().unhide_cursor(); - } - + toggle_cursor(); return true; }; From cf55cf3554103bf3e20046b27c69f346f1420b38 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 18:05:13 +0200 Subject: [PATCH 13/22] guard show_cursor on mouse motion --- src/hide-cursor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index 644f2a6..8ea7e10 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -97,7 +97,9 @@ class wayfire_hide_cursor wf::signal::connection_t> pointer_motion = [=] (wf::input_event_signal *ev) { - show_cursor(); + if (hidden) { + show_cursor(); + } restart_hide_timer(); }; From 37064f2f609d1d88326d2d52b1a8f9aaf40aed5a Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 18:07:03 +0200 Subject: [PATCH 14/22] bracket return --- src/hide-cursor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index 8ea7e10..6a43708 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -97,9 +97,11 @@ class wayfire_hide_cursor wf::signal::connection_t> pointer_motion = [=] (wf::input_event_signal *ev) { - if (hidden) { + if (hidden) + { show_cursor(); } + restart_hide_timer(); }; From 9546d7999d24d51f3de88c3d96a0e118548336eb Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 18:30:19 +0200 Subject: [PATCH 15/22] move mouse functions in wayfire_hide_cursor class --- src/hide-cursor.cpp | 53 +++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index 6a43708..4b3826f 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -34,29 +34,6 @@ namespace wf_hide_cursor bool hidden; -void hide_cursor() -{ - wf::get_core().hide_cursor(); - hidden = true; -} - -void show_cursor() -{ - wf::get_core().unhide_cursor(); - hidden = false; -} - -void toggle_cursor() -{ - if (hidden) - { - show_cursor(); - } else - { - hide_cursor(); - } -} - class wayfire_hide_cursor { wf::option_wrapper_t hide_delay{"hide-cursor/hide_delay"}; @@ -86,6 +63,30 @@ class wayfire_hide_cursor } public: + void hide_cursor() + { + wf::get_core().hide_cursor(); + hidden = true; + } + + void show_cursor() + { + hide_timer.disconnect(); + wf::get_core().unhide_cursor(); + hidden = false; + } + + void toggle_cursor() + { + if (hidden) + { + show_cursor(); + } else + { + hide_cursor(); + } + } + wayfire_hide_cursor() { hidden = false; @@ -98,9 +99,9 @@ class wayfire_hide_cursor [=] (wf::input_event_signal *ev) { if (hidden) - { + { show_cursor(); - } + } restart_hide_timer(); }; @@ -120,7 +121,7 @@ class wayfire_hide_cursor_plugin : public wf::per_output_plugin_instance_t wf::activator_callback toggle_cb = [=] (auto) { - toggle_cursor(); + global_idle->toggle_cursor(); return true; }; From 6892f67c71c7347954781bacea77f537fe233297 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 20:43:10 +0200 Subject: [PATCH 16/22] disconnect timer when hiding cursor --- src/hide-cursor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index 4b3826f..ffe3847 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -65,6 +65,7 @@ class wayfire_hide_cursor public: void hide_cursor() { + hide_timer.disconnect(); wf::get_core().hide_cursor(); hidden = true; } From 2739a6250992fdb166af93975420471bdd46f1ce Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 22:02:38 +0200 Subject: [PATCH 17/22] add hidden guards --- src/hide-cursor.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index ffe3847..e47968a 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -66,13 +66,21 @@ class wayfire_hide_cursor void hide_cursor() { hide_timer.disconnect(); + + if (hidden) + return; + wf::get_core().hide_cursor(); hidden = true; } - + void show_cursor() { hide_timer.disconnect(); + + if (!hidden) + return; + wf::get_core().unhide_cursor(); hidden = false; } From b3cbada8bd9e5126088f41cb5a30a3415c5626a5 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 22:13:00 +0200 Subject: [PATCH 18/22] added workspace_changed event --- src/hide-cursor.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index e47968a..fa38863 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -66,21 +66,21 @@ class wayfire_hide_cursor void hide_cursor() { hide_timer.disconnect(); - + if (hidden) return; - + wf::get_core().hide_cursor(); hidden = true; } - + void show_cursor() { hide_timer.disconnect(); - + if (!hidden) return; - + wf::get_core().unhide_cursor(); hidden = false; } @@ -102,6 +102,7 @@ class wayfire_hide_cursor restart_hide_timer(); wf::get_core().connect(&pointer_motion); + wf::get_core().connect(&workspace_changed); } wf::signal::connection_t> pointer_motion = @@ -115,9 +116,21 @@ class wayfire_hide_cursor restart_hide_timer(); }; + wf::signal::connection_t workspace_changed = + [=] (wf::workspace_changed_signal *ev) + { + if (hidden) + { + show_cursor(); + } + + restart_hide_timer(); + }; + ~wayfire_hide_cursor() { pointer_motion.disconnect(); + workspace_changed.disconnect(); hide_timer.disconnect(); show_cursor(); From dd6d4e2257af9d86ececb8ab36dcb499a5f2aab0 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 22:37:46 +0200 Subject: [PATCH 19/22] move workspace change event in plugin class --- src/hide-cursor.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index fa38863..56f9b1b 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace wf_hide_cursor { @@ -102,11 +103,10 @@ class wayfire_hide_cursor restart_hide_timer(); wf::get_core().connect(&pointer_motion); - wf::get_core().connect(&workspace_changed); + // wf::get_core().connect(&workspace_changed); } - wf::signal::connection_t> pointer_motion = - [=] (wf::input_event_signal *ev) + void on_event() { if (hidden) { @@ -114,23 +114,18 @@ class wayfire_hide_cursor } restart_hide_timer(); - }; + } - wf::signal::connection_t workspace_changed = - [=] (wf::workspace_changed_signal *ev) + wf::signal::connection_t> pointer_motion = + [=] (wf::input_event_signal *ev) { - if (hidden) - { - show_cursor(); - } - - restart_hide_timer(); + on_event(); }; ~wayfire_hide_cursor() { pointer_motion.disconnect(); - workspace_changed.disconnect(); + // workspace_changed.disconnect(); hide_timer.disconnect(); show_cursor(); @@ -147,17 +142,26 @@ class wayfire_hide_cursor_plugin : public wf::per_output_plugin_instance_t return true; }; + wf::signal::connection_t workspace_changed = + [=] (wf::workspace_changed_signal *ev) + { + global_idle->on_event(); + }; + public: void init() override { output->add_activator( wf::option_wrapper_t{"hide-cursor/toggle"}, &toggle_cb); + + output->connect(&workspace_changed); } void fini() override { output->rem_binding(&toggle_cb); + workspace_changed.disconnect(); } }; From cbd89c48a1d3cc619426436f4bc7d11c72fa8ff5 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Mon, 31 Aug 2026 22:48:57 +0200 Subject: [PATCH 20/22] remove unwanted comments --- src/hide-cursor.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index 56f9b1b..d9b0604 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -103,7 +103,6 @@ class wayfire_hide_cursor restart_hide_timer(); wf::get_core().connect(&pointer_motion); - // wf::get_core().connect(&workspace_changed); } void on_event() @@ -125,7 +124,6 @@ class wayfire_hide_cursor ~wayfire_hide_cursor() { pointer_motion.disconnect(); - // workspace_changed.disconnect(); hide_timer.disconnect(); show_cursor(); From c41c6850f6df6206c0d756ceadd1da6141306835 Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Wed, 2 Sep 2026 15:12:19 +0200 Subject: [PATCH 21/22] remove unecessary fstream --- src/hide-cursor.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hide-cursor.cpp b/src/hide-cursor.cpp index d9b0604..daf8526 100644 --- a/src/hide-cursor.cpp +++ b/src/hide-cursor.cpp @@ -28,7 +28,6 @@ #include #include #include -#include namespace wf_hide_cursor { From b1643c0de5000482665944b77bc5da554a180f4c Mon Sep 17 00:00:00 2001 From: Valentin Degenne Date: Sun, 6 Sep 2026 12:37:03 +0200 Subject: [PATCH 22/22] [keycolor] enabled_for option --- metadata/keycolor.xml | 33 ++++++++++++++++------------ src/keycolor.cpp | 51 ++++++++++++++++++++++++++++++------------- 2 files changed, 55 insertions(+), 29 deletions(-) diff --git a/metadata/keycolor.xml b/metadata/keycolor.xml index d667cc2..0577c94 100644 --- a/metadata/keycolor.xml +++ b/metadata/keycolor.xml @@ -1,19 +1,24 @@ - <_short>Keycolor - Effects - - - + <_short>Keycolor + Effects + + + + diff --git a/src/keycolor.cpp b/src/keycolor.cpp index 277c4a0..c15bcf5 100644 --- a/src/keycolor.cpp +++ b/src/keycolor.cpp @@ -30,6 +30,7 @@ #include #include #include +#include static const char *vertex_shader = @@ -243,6 +244,14 @@ class wayfire_keycolor : public wf::plugin_interface_t const std::string transformer_name = "keycolor"; std::map> transformers; + wf::view_matcher_t enabled_for{"keycolor/enabled_for"}; + wf::option_wrapper_t enabled_for_option{"keycolor/enabled_for"}; + + bool should_enable_for(wayfire_view view) + { + return enabled_for.matches(view); + } + void add_transformer(wayfire_view view) { if (view->get_transformed_node()->get_transformer(transformer_name)) @@ -263,6 +272,23 @@ class wayfire_keycolor : public wf::plugin_interface_t } } + void update_view(wayfire_view view) + { + if (view->role == wf::VIEW_ROLE_DESKTOP_ENVIRONMENT) + { + pop_transformer(view); + return; + } + + if (should_enable_for(view)) + { + add_transformer(view); + } else + { + pop_transformer(view); + } + } + void remove_transformers() { for (auto& view : wf::get_core().get_all_views()) @@ -295,16 +321,19 @@ class wayfire_keycolor : public wf::plugin_interface_t program_ref_count++; - wf::get_core().connect(&on_view_map); - - for (auto& view : wf::get_core().get_all_views()) + enabled_for_option.set_callback([=] () { - if (view->role == wf::VIEW_ROLE_DESKTOP_ENVIRONMENT) + for (auto& view : wf::get_core().get_all_views()) { - continue; + update_view(view); } + }); - add_transformer(view); + wf::get_core().connect(&on_view_map); + + for (auto& view : wf::get_core().get_all_views()) + { + update_view(view); } } @@ -316,17 +345,9 @@ class wayfire_keycolor : public wf::plugin_interface_t return; } - if (view->role == wf::VIEW_ROLE_DESKTOP_ENVIRONMENT) - { - return; - } - idle_attach.run_once([=] () { - if (!view->get_transformed_node()->get_transformer(transformer_name)) - { - add_transformer(view); - } + update_view(view); }); };