2022-03-19 17:48:18 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../defines.hpp"
|
|
|
|
#include <deque>
|
|
|
|
#include "../Compositor.hpp"
|
2022-04-21 15:50:52 +02:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <functional>
|
2022-03-19 17:48:18 +01:00
|
|
|
|
2022-07-31 15:46:42 +02:00
|
|
|
class CInputManager;
|
|
|
|
|
2022-03-19 17:48:18 +01:00
|
|
|
struct SKeybind {
|
2022-07-06 16:50:11 +02:00
|
|
|
std::string key = "";
|
2022-07-08 09:27:17 +02:00
|
|
|
int keycode = -1;
|
2022-03-19 17:48:18 +01:00
|
|
|
uint32_t modmask = 0;
|
|
|
|
std::string handler = "";
|
|
|
|
std::string arg = "";
|
2022-06-21 22:47:27 +02:00
|
|
|
bool locked = false;
|
2022-06-22 20:23:20 +02:00
|
|
|
std::string submap = "";
|
2022-07-20 22:45:06 +02:00
|
|
|
bool release = false;
|
2022-07-25 14:42:49 +02:00
|
|
|
bool repeat = false;
|
2022-07-20 23:17:26 +02:00
|
|
|
|
|
|
|
// DO NOT INITIALIZE
|
|
|
|
bool shadowed = false;
|
2022-03-19 17:48:18 +01:00
|
|
|
};
|
|
|
|
|
2022-07-26 17:30:30 +02:00
|
|
|
enum eFocusWindowMode {
|
|
|
|
MODE_CLASS_REGEX = 0,
|
|
|
|
MODE_TITLE_REGEX,
|
|
|
|
MODE_ADDRESS,
|
|
|
|
MODE_PID
|
|
|
|
};
|
|
|
|
|
2022-03-19 17:48:18 +01:00
|
|
|
class CKeybindManager {
|
|
|
|
public:
|
2022-04-21 15:50:52 +02:00
|
|
|
CKeybindManager();
|
|
|
|
|
2022-07-20 22:45:06 +02:00
|
|
|
bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*);
|
2022-07-21 18:18:03 +02:00
|
|
|
bool onAxisEvent(wlr_pointer_axis_event*);
|
2022-07-26 14:50:21 +02:00
|
|
|
bool onMouseEvent(wlr_pointer_button_event*);
|
2022-07-20 22:45:06 +02:00
|
|
|
|
2022-03-19 17:48:18 +01:00
|
|
|
void addKeybind(SKeybind);
|
2022-04-21 17:06:43 +02:00
|
|
|
void removeKeybind(uint32_t, const std::string&);
|
2022-03-19 17:48:18 +01:00
|
|
|
uint32_t stringToModMask(std::string);
|
2022-03-19 21:48:24 +01:00
|
|
|
void clearKeybinds();
|
2022-07-25 14:06:49 +02:00
|
|
|
void shadowKeybinds(const xkb_keysym_t& doesntHave = 0, const int& doesntHaveCode = 0);
|
2022-03-19 17:48:18 +01:00
|
|
|
|
2022-04-21 15:50:52 +02:00
|
|
|
std::unordered_map<std::string, std::function<void(std::string)>> m_mDispatchers;
|
|
|
|
|
2022-07-25 14:42:49 +02:00
|
|
|
wl_event_source* m_pActiveKeybindEventSource = nullptr;
|
|
|
|
|
2022-03-19 17:48:18 +01:00
|
|
|
private:
|
2022-04-21 17:06:43 +02:00
|
|
|
std::list<SKeybind> m_lKeybinds;
|
2022-07-20 23:17:26 +02:00
|
|
|
std::deque<xkb_keysym_t> m_dPressedKeysyms;
|
2022-07-25 14:06:49 +02:00
|
|
|
std::deque<int> m_dPressedKeycodes;
|
2022-03-19 17:48:18 +01:00
|
|
|
|
2022-06-22 20:23:20 +02:00
|
|
|
inline static std::string m_szCurrentSelectedSubmap = "";
|
|
|
|
|
2022-07-20 23:17:26 +02:00
|
|
|
xkb_keysym_t m_kHeldBack = 0;
|
|
|
|
|
2022-07-25 14:42:49 +02:00
|
|
|
SKeybind* m_pActiveKeybind = nullptr;
|
|
|
|
|
2022-07-26 17:30:30 +02:00
|
|
|
uint32_t m_uTimeLastMs = 0;
|
|
|
|
uint32_t m_uLastCode = 0;
|
|
|
|
|
2022-08-27 19:29:28 +02:00
|
|
|
int m_iPassPressed = -1; // used for pass
|
|
|
|
|
2022-07-26 23:34:03 +02:00
|
|
|
CTimer m_tScrollTimer;
|
|
|
|
|
2022-07-21 18:18:03 +02:00
|
|
|
bool handleKeybinds(const uint32_t&, const std::string&, const xkb_keysym_t&, const int&, bool, uint32_t);
|
2022-07-20 23:17:26 +02:00
|
|
|
|
2022-03-27 19:32:50 +02:00
|
|
|
bool handleInternalKeybinds(xkb_keysym_t);
|
2022-06-27 13:42:20 +02:00
|
|
|
bool handleVT(xkb_keysym_t);
|
2022-03-19 17:48:18 +01:00
|
|
|
|
2022-08-21 16:43:18 +02:00
|
|
|
xkb_state* m_pXKBTranslationState = nullptr;
|
|
|
|
|
|
|
|
void updateXKBTranslationState();
|
|
|
|
|
2022-03-19 17:48:18 +01:00
|
|
|
// -------------- Dispatchers -------------- //
|
2022-04-21 15:50:52 +02:00
|
|
|
static void killActive(std::string);
|
|
|
|
static void spawn(std::string);
|
|
|
|
static void toggleActiveFloating(std::string);
|
|
|
|
static void toggleActivePseudo(std::string);
|
|
|
|
static void changeworkspace(std::string);
|
|
|
|
static void fullscreenActive(std::string);
|
|
|
|
static void moveActiveToWorkspace(std::string);
|
2022-05-18 12:18:58 +02:00
|
|
|
static void moveActiveToWorkspaceSilent(std::string);
|
2022-04-21 15:50:52 +02:00
|
|
|
static void moveFocusTo(std::string);
|
|
|
|
static void moveActiveTo(std::string);
|
|
|
|
static void toggleGroup(std::string);
|
|
|
|
static void changeGroupActive(std::string);
|
|
|
|
static void alterSplitRatio(std::string);
|
2022-05-05 12:50:25 +02:00
|
|
|
static void focusMonitor(std::string);
|
2022-05-16 17:37:46 +02:00
|
|
|
static void toggleSplit(std::string);
|
2022-05-22 11:52:39 +02:00
|
|
|
static void moveCursorToCorner(std::string);
|
2022-05-26 19:05:32 +02:00
|
|
|
static void workspaceOpt(std::string);
|
2022-05-29 00:00:47 +02:00
|
|
|
static void exitHyprland(std::string);
|
2022-05-30 20:05:38 +02:00
|
|
|
static void moveCurrentWorkspaceToMonitor(std::string);
|
|
|
|
static void moveWorkspaceToMonitor(std::string);
|
2022-05-31 14:01:00 +02:00
|
|
|
static void toggleSpecialWorkspace(std::string);
|
2022-06-06 13:48:17 +02:00
|
|
|
static void forceRendererReload(std::string);
|
2022-06-06 19:32:14 +02:00
|
|
|
static void resizeActive(std::string);
|
2022-06-23 10:14:59 +02:00
|
|
|
static void moveActive(std::string);
|
2022-08-15 15:59:07 +02:00
|
|
|
static void moveWindow(std::string);
|
|
|
|
static void resizeWindow(std::string);
|
2022-06-10 11:39:06 +02:00
|
|
|
static void circleNext(std::string);
|
2022-07-01 16:24:37 +02:00
|
|
|
static void focusWindow(std::string);
|
2022-06-22 20:23:20 +02:00
|
|
|
static void setSubmap(std::string);
|
2022-07-26 17:30:30 +02:00
|
|
|
static void pass(std::string);
|
2022-07-28 12:00:10 +02:00
|
|
|
static void layoutmsg(std::string);
|
2022-07-28 12:07:41 +02:00
|
|
|
static void toggleOpaque(std::string);
|
2022-07-30 23:51:13 +02:00
|
|
|
static void dpms(std::string);
|
2022-08-24 21:40:36 +02:00
|
|
|
static void swapnext(std::string);
|
2022-08-25 21:25:28 +02:00
|
|
|
static void swapActiveWorkspaces(std::string);
|
2022-05-30 17:11:35 +02:00
|
|
|
|
|
|
|
friend class CCompositor;
|
2022-07-31 15:46:42 +02:00
|
|
|
friend class CInputManager;
|
2022-03-19 17:48:18 +01:00
|
|
|
};
|
|
|
|
|
2022-07-18 01:00:12 +02:00
|
|
|
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
|