config: add automatic closing to submaps (#11760)
* Allow submaps to auto reset to parent.
* Really should be a stack instead.
If hyprlang would allow for { } i would be so happy.
* Fixed: Somewhat better way to do it..
Lets you define what submap you want to go to instead.
* squash! Fixed: Somewhat better way to do it..
* God i hate cf..
* Force clang-format on the whole thing..
* Removed {}.
* Added tests
Tests and reset fix.
This commit is contained in:
parent
6a01c399a9
commit
d599513d4a
8 changed files with 102 additions and 26 deletions
|
|
@ -17,6 +17,14 @@ class IKeyboard;
|
|||
|
||||
enum eMouseBindMode : int8_t;
|
||||
|
||||
struct SSubmap {
|
||||
std::string name = "";
|
||||
std::string reset = "";
|
||||
bool operator==(const SSubmap& other) const {
|
||||
return name == other.name;
|
||||
}
|
||||
};
|
||||
|
||||
struct SKeybind {
|
||||
std::string key = "";
|
||||
std::set<xkb_keysym_t> sMkKeys = {};
|
||||
|
|
@ -27,7 +35,7 @@ struct SKeybind {
|
|||
std::string handler = "";
|
||||
std::string arg = "";
|
||||
bool locked = false;
|
||||
std::string submap = "";
|
||||
SSubmap submap = {};
|
||||
std::string description = "";
|
||||
bool release = false;
|
||||
bool repeat = false;
|
||||
|
|
@ -63,7 +71,7 @@ struct SPressedKeyWithMods {
|
|||
uint32_t keycode = 0;
|
||||
uint32_t modmaskAtPressTime = 0;
|
||||
bool sent = false;
|
||||
std::string submapAtPress = "";
|
||||
SSubmap submapAtPress = {};
|
||||
Vector2D mousePosAtPress = {};
|
||||
};
|
||||
|
||||
|
|
@ -98,7 +106,7 @@ class CKeybindManager {
|
|||
uint32_t keycodeToModifier(xkb_keycode_t);
|
||||
void clearKeybinds();
|
||||
void shadowKeybinds(const xkb_keysym_t& doesntHave = 0, const uint32_t doesntHaveCode = 0);
|
||||
std::string getCurrentSubmap();
|
||||
SSubmap getCurrentSubmap();
|
||||
|
||||
std::unordered_map<std::string, std::function<SDispatchResult(std::string)>> m_dispatchers;
|
||||
|
||||
|
|
@ -117,7 +125,7 @@ class CKeybindManager {
|
|||
private:
|
||||
std::vector<SPressedKeyWithMods> m_pressedKeys;
|
||||
|
||||
inline static std::string m_currentSelectedSubmap = "";
|
||||
inline static SSubmap m_currentSelectedSubmap = {};
|
||||
|
||||
std::vector<WP<SKeybind>> m_activeKeybinds;
|
||||
WP<SKeybind> m_lastLongPressKeybind;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue