From da3b5b2131d2b4ff5cb127e92090fca568376835 Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Wed, 24 May 2023 10:28:49 +1200 Subject: in-progress: Config refactor started, changed all existing keybind command args and added in the new files, still many errors --- keybinds.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 keybinds.h (limited to 'keybinds.h') diff --git a/keybinds.h b/keybinds.h new file mode 100644 index 0000000..d26b7a1 --- /dev/null +++ b/keybinds.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +#include "commands.h" + +class KeybindsModule { + public: + KeybindsModule(CommandsModule& commandsModule); + ~KeybindsModule() = default; + const void bind(const CommandArg* argv); + const void readBinds(const CommandArg* argv); + const void exit(const CommandArg* argv); + private: + std::unordered_map binds; + bool exitNow; + CommandsModule& commandsModule; +}; -- cgit v1.2.3 From 27137ec9d29c36df8117869773203b243849896c Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Fri, 26 May 2023 21:46:19 +1200 Subject: feat: Made keybinds work (I hope) Note: the config file reloading keybinds isn't quite working, though, need to ungrab the keys --- keybinds.h | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'keybinds.h') diff --git a/keybinds.h b/keybinds.h index d26b7a1..c0cc955 100644 --- a/keybinds.h +++ b/keybinds.h @@ -1,19 +1,31 @@ #pragma once -#include +#include +#include +#include #include +#include +#include #include "commands.h" +struct Keybind { + KeyCode key; + unsigned int modifiers; + std::string command; +}; + class KeybindsModule { - public: - KeybindsModule(CommandsModule& commandsModule); - ~KeybindsModule() = default; - const void bind(const CommandArg* argv); - const void readBinds(const CommandArg* argv); - const void exit(const CommandArg* argv); - private: - std::unordered_map binds; - bool exitNow; - CommandsModule& commandsModule; +public: + KeybindsModule(CommandsModule& commandsModule, Display* dpy, Window root); + ~KeybindsModule() = default; + const void bind(const CommandArg* argv); + const void exit(const CommandArg* argv); + const void handleKeypress(XKeyEvent e); +private: + std::vector binds; + bool exitNow; + CommandsModule& commandsModule; + Display* dpy; + Window root; }; -- cgit v1.2.3 From 01bc6a33eb235cd10851e2c31b99e6840603ca7d Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Thu, 1 Jun 2023 12:53:13 +1200 Subject: IT WORKS!!!!!! The new config commands system works, finally able to run this as a test and it works!!!!!. Still more to be done but at least it works. --- keybinds.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'keybinds.h') diff --git a/keybinds.h b/keybinds.h index c0cc955..43f6ef3 100644 --- a/keybinds.h +++ b/keybinds.h @@ -8,24 +8,22 @@ #include #include "commands.h" +#include "util.h" struct Keybind { - KeyCode key; + KeySym key; unsigned int modifiers; std::string command; }; class KeybindsModule { public: - KeybindsModule(CommandsModule& commandsModule, Display* dpy, Window root); + KeybindsModule(CommandsModule& commandsModule, Globals& globals); ~KeybindsModule() = default; const void bind(const CommandArg* argv); - const void exit(const CommandArg* argv); const void handleKeypress(XKeyEvent e); private: std::vector binds; - bool exitNow; CommandsModule& commandsModule; - Display* dpy; - Window root; + Globals& globals; }; -- cgit v1.2.3 From e9cc5756dbb0a2d079a7b5e3438d79945f819df5 Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Sat, 3 Jun 2023 21:30:05 +1200 Subject: feat: Keybind updates Re added the ability to swap super and mod as a config parameter (the ~swapmods~) command). Finally fixed keybinds sometimes not working because of numlock, bitwise & with the modifiers I actually care about. --- keybinds.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'keybinds.h') diff --git a/keybinds.h b/keybinds.h index 43f6ef3..07d9aea 100644 --- a/keybinds.h +++ b/keybinds.h @@ -8,6 +8,7 @@ #include #include "commands.h" +#include "config.h" #include "util.h" struct Keybind { @@ -18,12 +19,14 @@ struct Keybind { class KeybindsModule { public: - KeybindsModule(CommandsModule& commandsModule, Globals& globals); + KeybindsModule(CommandsModule& commandsModule, Config& cfg, Globals& globals); ~KeybindsModule() = default; const void bind(const CommandArg* argv); const void handleKeypress(XKeyEvent e); + const void clearKeybinds(); private: std::vector binds; CommandsModule& commandsModule; + Config& cfg; Globals& globals; }; -- cgit v1.2.3 From 0b539b0b0278f2d7c2b7629e6d28d8463cba2688 Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Mon, 5 Jun 2023 20:35:32 +1200 Subject: Added a very basic config, and fixed some stuff NOTE: for some reason toggling doesn't work anymore --- keybinds.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'keybinds.h') diff --git a/keybinds.h b/keybinds.h index 07d9aea..686eaf8 100644 --- a/keybinds.h +++ b/keybinds.h @@ -19,7 +19,7 @@ struct Keybind { class KeybindsModule { public: - KeybindsModule(CommandsModule& commandsModule, Config& cfg, Globals& globals); + KeybindsModule(CommandsModule& commandsModule, Config& cfg, Globals& globals, void (*updateMousePos)()); ~KeybindsModule() = default; const void bind(const CommandArg* argv); const void handleKeypress(XKeyEvent e); @@ -29,4 +29,5 @@ private: CommandsModule& commandsModule; Config& cfg; Globals& globals; + void (*updateMousePos)(); }; -- cgit v1.2.3