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-11-10 14:50:16 +01:00
|
|
|
class CConfigManager;
|
2023-02-27 13:32:38 +01:00
|
|
|
class CPluginSystem;
|
2022-07-31 15:46:42 +02:00
|
|
|
|
2022-03-19 17:48:18 +01:00
|
|
|
struct SKeybind {
|
2022-12-16 18:17:31 +01:00
|
|
|
std::string key = "";
|
|
|
|
int keycode = -1;
|
|
|
|
uint32_t modmask = 0;
|
|
|
|
std::string handler = "";
|
|
|
|
std::string arg = "";
|
|
|
|
bool locked = false;
|
|
|
|
std::string submap = "";
|
|
|
|
bool release = false;
|
|
|
|
bool repeat = false;
|
|
|
|
bool mouse = false;
|
2022-07-20 23:17:26 +02:00
|
|
|
|
|
|
|
// DO NOT INITIALIZE
|
2022-12-16 18:17:31 +01:00
|
|
|
bool shadowed = false;
|
2022-03-19 17:48:18 +01:00
|
|
|
};
|
|
|
|
|
2023-04-10 21:07:49 +02:00
|
|
|
enum eFocusWindowMode {
|
2022-07-26 17:30:30 +02:00
|
|
|
MODE_CLASS_REGEX = 0,
|
|
|
|
MODE_TITLE_REGEX,
|
|
|
|
MODE_ADDRESS,
|
|
|
|
MODE_PID
|
|
|
|
};
|
|
|
|
|
2022-03-19 17:48:18 +01:00
|
|
|
class CKeybindManager {
|
2022-12-16 18:17:31 +01:00
|
|
|
public:
|
2022-04-21 15:50:52 +02:00
|
|
|
CKeybindManager();
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*);
|
|
|
|
bool onAxisEvent(wlr_pointer_axis_event*);
|
|
|
|
bool onMouseEvent(wlr_pointer_button_event*);
|
2023-02-18 23:35:31 +01:00
|
|
|
void resizeWithBorder(wlr_pointer_button_event*);
|
2022-12-16 18:17:31 +01:00
|
|
|
void onSwitchEvent(const std::string&);
|
2023-01-08 16:35:24 +01:00
|
|
|
void onSwitchOnEvent(const std::string&);
|
|
|
|
void onSwitchOffEvent(const std::string&);
|
2022-09-25 20:07:48 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
void addKeybind(SKeybind);
|
|
|
|
void removeKeybind(uint32_t, const std::string&);
|
|
|
|
uint32_t stringToModMask(std::string);
|
|
|
|
void clearKeybinds();
|
|
|
|
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-12-16 18:17:31 +01:00
|
|
|
wl_event_source* m_pActiveKeybindEventSource = nullptr;
|
2022-07-25 14:42:49 +02:00
|
|
|
|
2023-02-21 13:13:35 +01:00
|
|
|
bool m_bGroupsLocked = false;
|
|
|
|
|
2023-01-06 14:32:25 +01:00
|
|
|
std::list<SKeybind> m_lKeybinds;
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
private:
|
|
|
|
std::deque<xkb_keysym_t> m_dPressedKeysyms;
|
|
|
|
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-12-16 18:17:31 +01:00
|
|
|
xkb_keysym_t m_kHeldBack = 0;
|
2022-07-20 23:17:26 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
SKeybind* m_pActiveKeybind = nullptr;
|
2022-07-25 14:42:49 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
uint32_t m_uTimeLastMs = 0;
|
|
|
|
uint32_t m_uLastCode = 0;
|
|
|
|
uint32_t m_uLastMouseCode = 0;
|
2022-07-26 17:30:30 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
bool m_bIsMouseBindActive = false;
|
2022-09-20 11:02:20 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
int m_iPassPressed = -1; // used for pass
|
2022-08-27 19:29:28 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
CTimer m_tScrollTimer;
|
2022-07-26 23:34:03 +02:00
|
|
|
|
2022-12-16 18:17:31 +01: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-12-16 18:17:31 +01:00
|
|
|
bool handleInternalKeybinds(xkb_keysym_t);
|
|
|
|
bool handleVT(xkb_keysym_t);
|
2022-03-19 17:48:18 +01:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
xkb_state* m_pXKBTranslationState = nullptr;
|
2022-08-21 16:43:18 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
void updateXKBTranslationState();
|
|
|
|
bool ensureMouseBindState();
|
2022-08-21 16:43:18 +02:00
|
|
|
|
2023-04-10 21:07:49 +02:00
|
|
|
static bool tryMoveFocusToMonitor(CMonitor* monitor);
|
2023-04-10 15:40:03 +02:00
|
|
|
|
2022-03-19 17:48:18 +01:00
|
|
|
// -------------- Dispatchers -------------- //
|
2023-02-19 14:59:39 +01:00
|
|
|
static void killActive(std::string);
|
|
|
|
static void kill(std::string);
|
|
|
|
static void spawn(std::string);
|
|
|
|
static uint64_t spawnRaw(std::string);
|
|
|
|
static void toggleActiveFloating(std::string);
|
|
|
|
static void toggleActivePseudo(std::string);
|
|
|
|
static void changeworkspace(std::string);
|
|
|
|
static void fullscreenActive(std::string);
|
|
|
|
static void fakeFullscreenActive(std::string);
|
|
|
|
static void moveActiveToWorkspace(std::string);
|
|
|
|
static void moveActiveToWorkspaceSilent(std::string);
|
|
|
|
static void moveFocusTo(std::string);
|
|
|
|
static void focusUrgentOrLast(std::string);
|
|
|
|
static void focusCurrentOrLast(std::string);
|
|
|
|
static void centerWindow(std::string);
|
|
|
|
static void moveActiveTo(std::string);
|
2023-04-10 21:07:49 +02:00
|
|
|
static void swapActive(std::string);
|
2023-02-19 14:59:39 +01:00
|
|
|
static void toggleGroup(std::string);
|
|
|
|
static void changeGroupActive(std::string);
|
|
|
|
static void alterSplitRatio(std::string);
|
|
|
|
static void focusMonitor(std::string);
|
|
|
|
static void toggleSplit(std::string);
|
|
|
|
static void moveCursorToCorner(std::string);
|
2023-04-23 20:50:53 +02:00
|
|
|
static void moveCursor(std::string);
|
2023-02-19 14:59:39 +01:00
|
|
|
static void workspaceOpt(std::string);
|
|
|
|
static void renameWorkspace(std::string);
|
|
|
|
static void exitHyprland(std::string);
|
|
|
|
static void moveCurrentWorkspaceToMonitor(std::string);
|
|
|
|
static void moveWorkspaceToMonitor(std::string);
|
|
|
|
static void toggleSpecialWorkspace(std::string);
|
|
|
|
static void forceRendererReload(std::string);
|
|
|
|
static void resizeActive(std::string);
|
|
|
|
static void moveActive(std::string);
|
|
|
|
static void moveWindow(std::string);
|
|
|
|
static void resizeWindow(std::string);
|
|
|
|
static void circleNext(std::string);
|
|
|
|
static void focusWindow(std::string);
|
|
|
|
static void setSubmap(std::string);
|
|
|
|
static void pass(std::string);
|
|
|
|
static void layoutmsg(std::string);
|
|
|
|
static void toggleOpaque(std::string);
|
|
|
|
static void dpms(std::string);
|
|
|
|
static void swapnext(std::string);
|
|
|
|
static void swapActiveWorkspaces(std::string);
|
|
|
|
static void pinActive(std::string);
|
|
|
|
static void mouse(std::string);
|
|
|
|
static void bringActiveToTop(std::string);
|
2023-02-21 13:13:35 +01:00
|
|
|
static void lockGroups(std::string);
|
2023-02-26 14:52:11 +01:00
|
|
|
static void moveIntoGroup(std::string);
|
2023-02-26 14:55:35 +01:00
|
|
|
static void moveOutOfGroup(std::string);
|
2023-04-09 14:48:20 +02:00
|
|
|
static void global(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-11-10 14:50:16 +01:00
|
|
|
friend class CConfigManager;
|
2022-03-19 17:48:18 +01:00
|
|
|
};
|
|
|
|
|
2022-07-18 01:00:12 +02:00
|
|
|
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
|