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 {
|
2023-06-14 13:08:56 +02:00
|
|
|
std::string key = "";
|
2024-01-01 18:29:51 +01:00
|
|
|
uint32_t keycode = 0;
|
2024-03-03 01:17:02 +01:00
|
|
|
bool catchAll = false;
|
2023-06-14 13:08:56 +02:00
|
|
|
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;
|
|
|
|
bool nonConsuming = false;
|
2023-08-25 12:35:24 +02:00
|
|
|
bool transparent = false;
|
2023-10-17 21:09:54 +02:00
|
|
|
bool ignoreMods = 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-12-06 23:54:56 +01:00
|
|
|
enum eFocusWindowMode {
|
2022-07-26 17:30:30 +02:00
|
|
|
MODE_CLASS_REGEX = 0,
|
|
|
|
MODE_TITLE_REGEX,
|
|
|
|
MODE_ADDRESS,
|
|
|
|
MODE_PID
|
|
|
|
};
|
|
|
|
|
2024-01-01 18:29:51 +01:00
|
|
|
struct SPressedKeyWithMods {
|
|
|
|
std::string keyName = "";
|
|
|
|
xkb_keysym_t keysym = 0;
|
|
|
|
uint32_t keycode = 0;
|
|
|
|
uint32_t modmaskAtPressTime = 0;
|
2024-01-10 18:06:38 +01:00
|
|
|
bool sent = false;
|
2024-03-09 17:08:07 +01:00
|
|
|
std::string submapAtPress = "";
|
2024-01-01 18:29:51 +01:00
|
|
|
};
|
|
|
|
|
2024-03-03 01:17:02 +01:00
|
|
|
struct SParsedKey {
|
|
|
|
std::string key = "";
|
|
|
|
uint32_t keycode = 0;
|
|
|
|
bool catchAll = false;
|
|
|
|
};
|
|
|
|
|
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);
|
2024-03-03 01:17:02 +01:00
|
|
|
void removeKeybind(uint32_t, const SParsedKey&);
|
2022-12-16 18:17:31 +01:00
|
|
|
uint32_t stringToModMask(std::string);
|
2024-01-01 18:29:51 +01:00
|
|
|
uint32_t keycodeToModifier(xkb_keycode_t);
|
2022-12-16 18:17:31 +01:00
|
|
|
void clearKeybinds();
|
2024-01-01 18:29:51 +01:00
|
|
|
void shadowKeybinds(const xkb_keysym_t& doesntHave = 0, const uint32_t 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;
|
2024-02-28 00:14:56 +01:00
|
|
|
std::list<SShortcutInhibitor> m_lShortcutInhibitors;
|
2023-01-06 14:32:25 +01:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
private:
|
2024-01-01 18:29:51 +01:00
|
|
|
std::deque<SPressedKeyWithMods> m_dPressedKeys;
|
2022-03-19 17:48:18 +01:00
|
|
|
|
2024-01-01 18:29:51 +01:00
|
|
|
inline static std::string m_szCurrentSelectedSubmap = "";
|
2022-06-22 20:23:20 +02:00
|
|
|
|
2024-01-01 18:29:51 +01:00
|
|
|
SKeybind* m_pActiveKeybind = nullptr;
|
2022-07-25 14:42:49 +02:00
|
|
|
|
2024-01-01 18:29:51 +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
|
|
|
|
2024-01-01 18:29:51 +01:00
|
|
|
bool m_bIsMouseBindActive = false;
|
|
|
|
std::vector<SKeybind*> m_vPressedSpecialBinds;
|
2022-09-20 11:02:20 +02:00
|
|
|
|
2024-01-01 18:29:51 +01:00
|
|
|
int m_iPassPressed = -1; // used for pass
|
2022-08-27 19:29:28 +02:00
|
|
|
|
2024-01-01 18:29:51 +01:00
|
|
|
CTimer m_tScrollTimer;
|
2022-07-26 23:34:03 +02:00
|
|
|
|
2024-01-01 18:29:51 +01:00
|
|
|
bool handleKeybinds(const uint32_t, const SPressedKeyWithMods&, bool);
|
2022-07-20 23:17:26 +02:00
|
|
|
|
2024-01-01 18:29:51 +01:00
|
|
|
bool handleInternalKeybinds(xkb_keysym_t);
|
|
|
|
bool handleVT(xkb_keysym_t);
|
2022-03-19 17:48:18 +01:00
|
|
|
|
2024-01-01 18:29:51 +01:00
|
|
|
xkb_state* m_pXKBTranslationState = nullptr;
|
2022-08-21 16:43:18 +02:00
|
|
|
|
2024-01-01 18:29:51 +01:00
|
|
|
void updateXKBTranslationState();
|
|
|
|
bool ensureMouseBindState();
|
2022-08-21 16:43:18 +02:00
|
|
|
|
2024-01-01 18:29:51 +01:00
|
|
|
static bool tryMoveFocusToMonitor(CMonitor* monitor);
|
|
|
|
static void moveWindowOutOfGroup(CWindow* pWindow, const std::string& dir = "");
|
|
|
|
static void moveWindowIntoGroup(CWindow* pWindow, CWindow* pWindowInDirection);
|
|
|
|
static void switchToWindow(CWindow* PWINDOWTOCHANGETO);
|
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);
|
2024-02-14 18:58:28 +01:00
|
|
|
static void swapSplit(std::string);
|
2023-02-19 14:59:39 +01:00
|
|
|
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);
|
2024-01-15 16:30:46 +01:00
|
|
|
static void focusWorkspaceOnCurrentMonitor(std::string);
|
2023-02-19 14:59:39 +01:00
|
|
|
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-09-21 23:18:26 +02:00
|
|
|
static void alterZOrder(std::string);
|
2023-02-21 13:13:35 +01:00
|
|
|
static void lockGroups(std::string);
|
2023-06-09 23:44:18 +02:00
|
|
|
static void lockActiveGroup(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-07-13 17:55:20 +02:00
|
|
|
static void moveGroupWindow(std::string);
|
2023-09-11 00:29:10 +02:00
|
|
|
static void moveWindowOrGroup(std::string);
|
|
|
|
static void setIgnoreGroupLock(std::string);
|
2023-09-22 01:42:00 +02:00
|
|
|
static void denyWindowFromGroup(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;
|