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 --- config.h | 85 +++++++++++++++++++++------------------------------------------- 1 file changed, 28 insertions(+), 57 deletions(-) (limited to 'config.h') diff --git a/config.h b/config.h index 31005e7..3956492 100644 --- a/config.h +++ b/config.h @@ -1,63 +1,30 @@ #pragma once -#include "error.h" - -#include - +#include "commands.h" #include #include #include -enum MoveDir +struct Workspace { - Up, - Right, - Down, - Left + std::string name; + int* screenPreferences; + int screenPreferencesc; }; -typedef union -{ - char* str; - int num; - MoveDir dir; -} KeyArg; - -struct KeyBind -{ - unsigned int modifiers; - KeySym keysym; - void(* func) (const KeyArg arg); - KeyArg args; -}; - -//Keybind commands -#define KEYCOM(X) \ - void X (const KeyArg arg) -KEYCOM(exit); -KEYCOM(spawn); -KEYCOM(toggle); -KEYCOM(kill); -KEYCOM(changeWS); -KEYCOM(wToWS); -KEYCOM(focChange); -KEYCOM(wMove); -KEYCOM(bashSpawn); -KEYCOM(reload); -KEYCOM(wsDump); -KEYCOM(nextMonitor); +#define COMMAND(X) \ + const void X (const CommandArg* argv) class Config -{ +{ public: - Config(); + Config(CommandsModule& commandsModule); ~Config(); void free(); - Err loadFromFile(std::string path); - Err reload(); - + void loadFromFile(std::string path); + void reloadFile(); // Startup std::string* startupBash; int startupBashc; @@ -68,6 +35,7 @@ class Config std::string logFile; // Workspaces + std::vector workspaces; int numWS; std::string* workspaceNames; int workspaceNamesc; @@ -75,19 +43,22 @@ class Config int** screenPreferences; int screenPreferencesc; - // Keybinds - KeyBind* binds; - int bindsc; + // Config Commands + COMMAND(gapsCmd); + COMMAND(outerGapsCmd); + COMMAND(logFileCmd); + COMMAND(addWorkspaceCmd); + + // Keybind Commands + COMMAND(exit); + COMMAND(spawn); + COMMAND(spawn_once); + COMMAND(changeWS); + COMMAND(wToWS); + COMMAND(focChange); + COMMAND(reload); private: - template - T getValue(std::string path, Err* err); - - void loadWorkspaceArrays(toml::table tbl, toml::table defaults, Err* err); - void loadStartupBash(toml::table tbl, toml::table defaults, Err* err); - - toml::table tbl; - toml::table defaults; - + CommandsModule& commandsModule; bool loaded = false; - std::string path; + std::string file; }; -- 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 --- config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config.h') diff --git a/config.h b/config.h index 3956492..a31c1df 100644 --- a/config.h +++ b/config.h @@ -23,8 +23,8 @@ class Config ~Config(); void free(); - void loadFromFile(std::string path); - void reloadFile(); + Err loadFromFile(std::string path); + Err reloadFile(); // Startup std::string* startupBash; int startupBashc; -- cgit v1.2.3 From ea827624d203c73af896669e161972fc8be022ed Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Sat, 27 May 2023 16:33:46 +1200 Subject: feat: Made it compile woo Note: doesn't work yet though, as commands haven't all been registered yet --- config.h | 82 ++++++++++++++++++++++++++++++---------------------------------- 1 file changed, 39 insertions(+), 43 deletions(-) (limited to 'config.h') diff --git a/config.h b/config.h index a31c1df..55e55aa 100644 --- a/config.h +++ b/config.h @@ -5,6 +5,7 @@ #include #include +#include struct Workspace { @@ -13,52 +14,47 @@ struct Workspace int screenPreferencesc; }; -#define COMMAND(X) \ +#define COMMAND(X) \ const void X (const CommandArg* argv) class Config { - public: - Config(CommandsModule& commandsModule); - ~Config(); - void free(); +public: + Config(CommandsModule& commandsModule); + ~Config(); + void free(); - Err loadFromFile(std::string path); - Err reloadFile(); - // Startup - std::string* startupBash; - int startupBashc; - - // Main - int gaps; - int outerGaps; - std::string logFile; - - // Workspaces - std::vector workspaces; - int numWS; - std::string* workspaceNames; - int workspaceNamesc; - int maxMonitors; - int** screenPreferences; - int screenPreferencesc; - - // Config Commands - COMMAND(gapsCmd); - COMMAND(outerGapsCmd); - COMMAND(logFileCmd); - COMMAND(addWorkspaceCmd); - - // Keybind Commands - COMMAND(exit); - COMMAND(spawn); - COMMAND(spawn_once); - COMMAND(changeWS); - COMMAND(wToWS); - COMMAND(focChange); - COMMAND(reload); - private: - CommandsModule& commandsModule; - bool loaded = false; - std::string file; + std::vector loadFromFile(std::string path); + std::vector reloadFile(); + // Startup + std::string* startupBash; + int startupBashc; + + // Main + int gaps; + int outerGaps; + std::string logFile; + + // Workspaces + std::vector workspaces; + int numWS; + + // Config Commands + COMMAND(gapsCmd); + COMMAND(outerGapsCmd); + COMMAND(logFileCmd); + COMMAND(addWorkspaceCmd); + + // Keybind Commands + COMMAND(exit); + COMMAND(spawn); + COMMAND(spawn_once); + COMMAND(changeWS); + COMMAND(wToWS); + COMMAND(focChange); + COMMAND(reload); +private: + CommandsModule& commandsModule; + bool loaded = false; + std::string file; }; -- cgit v1.2.3 From 6b3dff404248bcf03e0bf0463a8c53d8918f7eec Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Wed, 31 May 2023 20:55:49 +1200 Subject: Added support for commands without a module Also made it easier to add commands by making the ~addCommand~ function accept a vector for ~argTypes~ and then convert it. --- config.h | 1 - 1 file changed, 1 deletion(-) (limited to 'config.h') diff --git a/config.h b/config.h index 55e55aa..e6d6227 100644 --- a/config.h +++ b/config.h @@ -47,7 +47,6 @@ public: // Keybind Commands COMMAND(exit); - COMMAND(spawn); COMMAND(spawn_once); COMMAND(changeWS); COMMAND(wToWS); -- 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. --- config.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'config.h') diff --git a/config.h b/config.h index e6d6227..b02dc9e 100644 --- a/config.h +++ b/config.h @@ -26,9 +26,6 @@ public: std::vector loadFromFile(std::string path); std::vector reloadFile(); - // Startup - std::string* startupBash; - int startupBashc; // Main int gaps; @@ -38,6 +35,8 @@ public: // Workspaces std::vector workspaces; int numWS; + bool loaded = false; + // Config Commands COMMAND(gapsCmd); @@ -45,15 +44,7 @@ public: COMMAND(logFileCmd); COMMAND(addWorkspaceCmd); - // Keybind Commands - COMMAND(exit); - COMMAND(spawn_once); - COMMAND(changeWS); - COMMAND(wToWS); - COMMAND(focChange); - COMMAND(reload); private: CommandsModule& commandsModule; - bool loaded = false; std::string file; }; -- 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. --- config.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'config.h') diff --git a/config.h b/config.h index b02dc9e..452db9c 100644 --- a/config.h +++ b/config.h @@ -37,12 +37,15 @@ public: int numWS; bool loaded = false; + // Binds + bool swapSuperAlt; // Config Commands COMMAND(gapsCmd); COMMAND(outerGapsCmd); COMMAND(logFileCmd); COMMAND(addWorkspaceCmd); + COMMAND(swapSuperAltCmd); private: CommandsModule& commandsModule; -- cgit v1.2.3