Hyprland/src/managers/input/InputManager.hpp

145 lines
4.5 KiB
C++
Raw Normal View History

2022-03-17 15:53:45 +01:00
#pragma once
2022-06-09 12:46:55 +02:00
#include "../../defines.hpp"
2022-03-18 23:25:26 +01:00
#include <list>
2022-06-09 12:46:55 +02:00
#include "../../helpers/WLClasses.hpp"
#include "../../Window.hpp"
2022-06-24 23:27:02 +02:00
#include "../../helpers/Timer.hpp"
2022-08-05 13:03:37 +02:00
#include "InputMethodRelay.hpp"
2022-03-17 15:53:45 +01:00
2022-06-27 13:42:20 +02:00
enum eClickBehaviorMode {
CLICKMODE_DEFAULT = 0,
CLICKMODE_KILL
};
2022-09-19 20:04:48 +02:00
enum eMouseBindMode {
MBIND_INVALID = -1,
MBIND_MOVE = 0,
MBIND_RESIZE
};
2022-08-07 21:17:03 +02:00
struct STouchData {
CWindow* touchFocusWindow = nullptr;
Vector2D touchSurfaceOrigin;
2022-08-07 21:17:03 +02:00
};
2022-03-17 15:53:45 +01:00
class CInputManager {
public:
2022-03-24 15:57:46 +01:00
void onMouseMoved(wlr_pointer_motion_event*);
void onMouseWarp(wlr_pointer_motion_absolute_event*);
void onMouseButton(wlr_pointer_button_event*);
2022-09-25 20:07:48 +02:00
void onMouseWheel(wlr_pointer_axis_event*);
2022-03-24 15:57:46 +01:00
void onKeyboardKey(wlr_keyboard_key_event*, SKeyboard*);
2022-03-18 23:06:45 +01:00
void onKeyboardMod(void*, SKeyboard*);
2022-03-17 15:53:45 +01:00
2022-03-17 20:55:04 +01:00
void newKeyboard(wlr_input_device*);
2022-08-05 16:21:08 +02:00
void newVirtualKeyboard(wlr_input_device*);
2022-07-11 20:23:16 +02:00
void newMouse(wlr_input_device*, bool virt = false);
void newTouchDevice(wlr_input_device*);
2022-10-04 21:07:21 +02:00
void newSwitch(wlr_input_device*);
void destroyTouchDevice(STouchDevice*);
2022-03-18 23:25:26 +01:00
void destroyKeyboard(SKeyboard*);
void destroyMouse(wlr_input_device*);
2022-10-04 21:07:21 +02:00
void destroySwitch(SSwitchDevice*);
2022-03-17 19:03:15 +01:00
void constrainMouse(SMouse*, wlr_pointer_constraint_v1*);
void recheckConstraint(SMouse*);
2022-08-09 20:36:21 +02:00
void unconstrainMouse();
2022-08-16 16:10:20 +02:00
std::string getActiveLayoutForKeyboard(SKeyboard*);
2022-03-17 19:03:15 +01:00
Vector2D getMouseCoordsInternal();
2022-03-21 19:28:43 +01:00
void refocus();
2022-03-17 19:03:15 +01:00
2022-03-24 21:05:34 +01:00
void setKeyboardLayout();
void setMouseConfigs();
2022-03-24 21:05:34 +01:00
2022-03-31 17:25:23 +02:00
void updateDragIcon();
2022-06-09 12:46:55 +02:00
void updateCapabilities(wlr_input_device*);
2022-03-31 17:25:23 +02:00
2022-06-27 13:42:20 +02:00
void setClickMode(eClickBehaviorMode);
eClickBehaviorMode getClickMode();
void processMouseRequest(wlr_seat_pointer_request_set_cursor_event*);
2022-08-07 21:17:03 +02:00
void onTouchDown(wlr_touch_down_event*);
void onTouchUp(wlr_touch_up_event*);
void onTouchMove(wlr_touch_motion_event*);
2022-09-22 22:14:02 +02:00
void onPointerHoldBegin(wlr_pointer_hold_begin_event*);
void onPointerHoldEnd(wlr_pointer_hold_end_event*);
2022-08-07 21:17:03 +02:00
STouchData m_sTouchData;
2022-03-20 11:14:24 +01:00
// for dragging floating windows
CWindow* currentlyDraggedWindow = nullptr;
2022-09-19 20:04:48 +02:00
eMouseBindMode dragMode = MBIND_INVALID;
2022-03-20 11:14:24 +01:00
2022-03-31 17:25:23 +02:00
SDrag m_sDrag;
2022-06-02 13:59:33 +02:00
std::list<SConstraint> m_lConstraints;
std::list<SKeyboard> m_lKeyboards;
std::list<SMouse> m_lMice;
2022-06-09 12:46:55 +02:00
// tablets
std::list<STablet> m_lTablets;
std::list<STabletTool> m_lTabletTools;
std::list<STabletPad> m_lTabletPads;
// idle inhibitors
std::list<SIdleInhibitor> m_lIdleInhibitors;
// Touch devices
std::list<STouchDevice> m_lTouchDevices;
2022-10-04 21:07:21 +02:00
// Switches
std::list<SSwitchDevice> m_lSwitches;
2022-06-09 12:46:55 +02:00
void newTabletTool(wlr_input_device*);
void newTabletPad(wlr_input_device*);
2022-06-09 18:09:09 +02:00
void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
void newIdleInhibitor(wlr_idle_inhibitor_v1*);
void recheckIdleInhibitorStatus();
2022-06-09 12:46:55 +02:00
2022-07-07 11:52:12 +02:00
void onSwipeBegin(wlr_pointer_swipe_begin_event*);
void onSwipeEnd(wlr_pointer_swipe_end_event*);
void onSwipeUpdate(wlr_pointer_swipe_update_event*);
SSwipeGesture m_sActiveSwipe;
2022-06-09 12:46:55 +02:00
SKeyboard* m_pActiveKeyboard = nullptr;
2022-06-24 23:27:02 +02:00
CTimer m_tmrLastCursorMovement;
2022-08-05 13:03:37 +02:00
CInputMethodRelay m_sIMERelay;
2022-07-20 22:45:06 +02:00
// for shared mods
uint32_t accumulateModsFromAllKBs();
2022-08-06 22:26:32 +02:00
CWindow* m_pFollowOnDnDBegin = nullptr;
private:
2022-03-17 20:55:04 +01:00
2022-06-27 13:42:20 +02:00
// for click behavior override
eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT;
2022-08-28 22:45:05 +02:00
bool m_bEmptyFocusCursorSet = false;
2022-07-01 17:59:11 +02:00
Vector2D m_vLastCursorPosFloored = Vector2D();
2022-06-27 13:42:20 +02:00
// for some bugs in follow mouse 0
bool m_bLastFocusOnLS = false;
2022-06-27 13:42:20 +02:00
void processMouseDownNormal(wlr_pointer_button_event* e);
void processMouseDownKill(wlr_pointer_button_event* e);
void disableAllKeyboards(bool virt = false);
2022-06-09 12:46:55 +02:00
uint32_t m_uiCapabilities = 0;
2022-04-13 20:19:40 +02:00
void mouseMoveUnified(uint32_t, bool refocus = false);
2022-06-09 12:46:55 +02:00
2022-06-09 19:38:39 +02:00
STabletTool* ensureTabletToolPresent(wlr_tablet_tool*);
void applyConfigToKeyboard(SKeyboard*);
2022-03-17 15:53:45 +01:00
};
2022-09-25 20:07:48 +02:00
inline std::unique_ptr<CInputManager> g_pInputManager;