summaryrefslogtreecommitdiff
path: root/src/managers/input
diff options
context:
space:
mode:
Diffstat (limited to 'src/managers/input')
-rw-r--r--src/managers/input/IdleInhibitor.cpp54
-rw-r--r--src/managers/input/InputManager.cpp98
-rw-r--r--src/managers/input/InputManager.hpp16
-rw-r--r--src/managers/input/Swipe.cpp152
-rw-r--r--src/managers/input/Tablets.cpp18
5 files changed, 306 insertions, 32 deletions
diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp
new file mode 100644
index 00000000..3efb40c6
--- /dev/null
+++ b/src/managers/input/IdleInhibitor.cpp
@@ -0,0 +1,54 @@
+#include "InputManager.hpp"
+#include "../../Compositor.hpp"
+
+void Events::listener_newIdleInhibitor(wl_listener* listener, void* data) {
+ const auto WLRIDLEINHIBITOR = (wlr_idle_inhibitor_v1*)data;
+
+ if (!WLRIDLEINHIBITOR)
+ return;
+
+ g_pInputManager->newIdleInhibitor(WLRIDLEINHIBITOR);
+}
+
+void CInputManager::newIdleInhibitor(wlr_idle_inhibitor_v1* pInhibitor) {
+ const auto PINHIBIT = &m_lIdleInhibitors.emplace_back();
+
+ Debug::log(LOG, "New idle inhibitor registered");
+
+ PINHIBIT->pWlrInhibitor = pInhibitor;
+
+ PINHIBIT->hyprListener_Destroy.initCallback(&pInhibitor->events.destroy, [](void* owner, void* data){
+
+ const auto PINH = (SIdleInhibitor*)owner;
+
+ g_pInputManager->m_lIdleInhibitors.remove(*PINH);
+
+ Debug::log(LOG, "Destroyed an idleinhibitor");
+
+ g_pInputManager->recheckIdleInhibitorStatus();
+
+ }, PINHIBIT, "IdleInhibitor");
+
+ PINHIBIT->pWindow = g_pCompositor->getWindowFromSurface(pInhibitor->surface);
+
+ if (PINHIBIT->pWindow)
+ Debug::log(LOG, "IdleInhibitor got window %x (%s)", PINHIBIT->pWindow, PINHIBIT->pWindow->m_szTitle.c_str());
+
+ recheckIdleInhibitorStatus();
+}
+
+void CInputManager::recheckIdleInhibitorStatus() {
+
+ for (auto& ii : m_lIdleInhibitors) {
+ if (!ii.pWindow) {
+ wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false);
+ return;
+ } else if (g_pHyprRenderer->shouldRenderWindow(ii.pWindow)) {
+ wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false);
+ return;
+ }
+ }
+
+ wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, true);
+ return;
+} \ No newline at end of file
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 92a06a4c..5f1b1a3a 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -28,6 +28,8 @@ void CInputManager::onMouseWarp(wlr_pointer_motion_absolute_event* e) {
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
+ static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
+
if (!g_pCompositor->m_bReadyToProcess)
return;
@@ -36,10 +38,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
return;
}
+ if (g_pCompositor->m_sSeat.mouse->virt)
+ return; // don't refocus on virt
+
Vector2D mouseCoords = getMouseCoordsInternal();
const auto MOUSECOORDSFLOORED = mouseCoords.floor();
- if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored)
+ if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored && !refocus)
return;
m_vLastCursorPosFloored = MOUSECOORDSFLOORED;
@@ -86,6 +91,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
} else {
if ((!CONSTRAINTWINDOW->m_bIsX11 && PMONITOR && CONSTRAINTWINDOW->m_iWorkspaceID == PMONITOR->activeWorkspace) || (CONSTRAINTWINDOW->m_bIsX11)) {
g_pCompositor->m_sSeat.mouse->constraintActive = true;
+ didConstraintOnCursor = true;
}
}
}
@@ -138,6 +144,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (!pFoundWindow->m_bIsX11) {
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
+ surfacePos = Vector2D(-1337, -1337);
} else {
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
surfacePos = pFoundWindow->m_vRealPosition.vec();
@@ -153,9 +160,21 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
// then windows
if (!foundSurface) {
- if (PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED)
- pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
- else
+ if (PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) {
+
+ if (PMONITOR->specialWorkspaceOpen) {
+ pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
+
+ if (pFoundWindow && pFoundWindow->m_iWorkspaceID != SPECIAL_WORKSPACE_ID) {
+ pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
+ }
+ } else {
+ pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
+
+ if (!(pFoundWindow && pFoundWindow->m_bIsFloating && pFoundWindow->m_bCreatedOverFullscreen))
+ pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
+ }
+ } else
pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
if (pFoundWindow) {
@@ -183,6 +202,12 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat);
+ if (refocus) { // if we are forcing a refocus, and we don't find a surface, clear the kb focus too!
+ g_pCompositor->focusSurface(nullptr);
+
+ g_pCompositor->m_pLastWindow = nullptr;
+ }
+
return;
}
@@ -200,7 +225,6 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
}
if (pFoundWindow) {
- static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
if (*PFOLLOWMOUSE != 1 && !refocus) {
if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating)) {
// enter if change floating style
@@ -384,8 +408,8 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
Debug::log(ERR, "Keyboard had no name???"); // logic error
}
- PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&keyboard->keyboard->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard");
- PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&keyboard->keyboard->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
+ PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard");
+ PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
if (m_pActiveKeyboard)
@@ -394,7 +418,7 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
applyConfigToKeyboard(PNEWKEYBOARD);
- wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, keyboard->keyboard);
+ wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(keyboard));
Debug::log(LOG, "New keyboard created, pointers Hypr: %x and WLR: %x", PNEWKEYBOARD, keyboard);
}
@@ -409,6 +433,9 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
ASSERT(pKeyboard);
+ if (!wlr_keyboard_from_input_device(pKeyboard->keyboard))
+ return;
+
const auto REPEATRATE = HASCONFIG ? g_pConfigManager->getDeviceInt(pKeyboard->name, "repeat_rate") : g_pConfigManager->getInt("input:repeat_rate");
const auto REPEATDELAY = HASCONFIG ? g_pConfigManager->getDeviceInt(pKeyboard->name, "repeat_delay") : g_pConfigManager->getInt("input:repeat_delay");
@@ -421,7 +448,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_options") : g_pConfigManager->getString("input:kb_options");
try {
- if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == std::string(pKeyboard->currentRules.rules) && MODEL == std::string(pKeyboard->currentRules.model) && LAYOUT == std::string(pKeyboard->currentRules.layout) && VARIANT == std::string(pKeyboard->currentRules.variant) && OPTIONS == std::string(pKeyboard->currentRules.options)) {
+ if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options) {
Debug::log(LOG, "Not applying config to keyboard, it did not change.");
return;
}
@@ -430,7 +457,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
// we can ignore those and just apply
}
- wlr_keyboard_set_repeat_info(pKeyboard->keyboard->keyboard, std::max(0, REPEATRATE), std::max(0, REPEATDELAY));
+ wlr_keyboard_set_repeat_info(wlr_keyboard_from_input_device(pKeyboard->keyboard), std::max(0, REPEATRATE), std::max(0, REPEATDELAY));
pKeyboard->repeatDelay = REPEATDELAY;
pKeyboard->repeatRate = REPEATRATE;
@@ -443,7 +470,11 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
.variant = VARIANT.c_str(),
.options = OPTIONS.c_str()};
- pKeyboard->currentRules = rules;
+ pKeyboard->currentRules.rules = RULES;
+ pKeyboard->currentRules.model = MODEL;
+ pKeyboard->currentRules.variant = VARIANT;
+ pKeyboard->currentRules.options = OPTIONS;
+ pKeyboard->currentRules.layout = LAYOUT;
const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
@@ -460,12 +491,16 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
Debug::log(ERR, "Keyboard layout %s with variant %s (rules: %s, model: %s, options: %s) couldn't have been loaded.", rules.layout, rules.variant, rules.rules, rules.model, rules.options);
memset(&rules, 0, sizeof(rules));
- pKeyboard->currentRules = rules;
+ pKeyboard->currentRules.rules = "";
+ pKeyboard->currentRules.model = "";
+ pKeyboard->currentRules.variant = "";
+ pKeyboard->currentRules.options = "";
+ pKeyboard->currentRules.layout = "";
KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
}
- wlr_keyboard_set_keymap(pKeyboard->keyboard->keyboard, KEYMAP);
+ wlr_keyboard_set_keymap(wlr_keyboard_from_input_device(pKeyboard->keyboard), KEYMAP);
wlr_keyboard_modifiers wlrMods = {0};
@@ -478,7 +513,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
}
if (wlrMods.locked != 0) {
- wlr_keyboard_notify_modifiers(pKeyboard->keyboard->keyboard, 0, 0, wlrMods.locked, 0);
+ wlr_keyboard_notify_modifiers(wlr_keyboard_from_input_device(pKeyboard->keyboard), 0, 0, wlrMods.locked, 0);
}
xkb_keymap_unref(KEYMAP);
@@ -487,11 +522,12 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
Debug::log(LOG, "Set the keyboard layout to %s and variant to %s for keyboard \"%s\"", rules.layout, rules.variant, pKeyboard->keyboard->name);
}
-void CInputManager::newMouse(wlr_input_device* mouse) {
+void CInputManager::newMouse(wlr_input_device* mouse, bool virt) {
m_lMice.emplace_back();
const auto PMOUSE = &m_lMice.back();
PMOUSE->mouse = mouse;
+ PMOUSE->virt = virt;
try {
PMOUSE->name = std::string(mouse->name);
} catch(std::exception& e) {
@@ -515,6 +551,11 @@ void CInputManager::newMouse(wlr_input_device* mouse) {
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
}
+ if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "drag_lock") : g_pConfigManager->getInt("input:touchpad:drag_lock")) == 0)
+ libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
+ else
+ libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
+
if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop)
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "tap-to-click") : g_pConfigManager->getInt("input:touchpad:tap-to-click")) == 1)
libinput_device_config_tap_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_ENABLED);
@@ -582,29 +623,31 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar
const auto KEYCODE = e->keycode + 8; // Because to xkbcommon it's +8 from libinput
const xkb_keysym_t* keysyms;
- int syms = xkb_state_key_get_syms(pKeyboard->keyboard->keyboard->xkb_state, KEYCODE, &keysyms);
+ int syms = xkb_state_key_get_syms(wlr_keyboard_from_input_device(pKeyboard->keyboard)->xkb_state, KEYCODE, &keysyms);
- const auto MODS = wlr_keyboard_get_modifiers(pKeyboard->keyboard->keyboard);
+ const auto MODS = accumulateModsFromAllKBs();
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
bool found = false;
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
for (int i = 0; i < syms; ++i)
- found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i]) || found;
+ found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i], 0) || found;
+
+ found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE) || found;
} else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
// hee hee
}
if (!found) {
- wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, pKeyboard->keyboard->keyboard);
+ wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard));
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, e->time_msec, e->keycode, e->state);
}
}
void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
- wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, pKeyboard->keyboard->keyboard);
- wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &pKeyboard->keyboard->keyboard->modifiers);
+ wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard));
+ wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers);
}
void CInputManager::refocus() {
@@ -722,4 +765,15 @@ void CInputManager::updateCapabilities(wlr_input_device* pDev) {
}
wlr_seat_set_capabilities(g_pCompositor->m_sSeat.seat, m_uiCapabilities);
-} \ No newline at end of file
+}
+
+uint32_t CInputManager::accumulateModsFromAllKBs() {
+
+ uint32_t finalMask = 0;
+
+ for (auto& kb : m_lKeyboards) {
+ finalMask |= wlr_keyboard_get_modifiers(wlr_keyboard_from_input_device(kb.keyboard));
+ }
+
+ return finalMask;
+}
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 1a50c585..5e0c86b1 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -22,7 +22,7 @@ public:
void onKeyboardMod(void*, SKeyboard*);
void newKeyboard(wlr_input_device*);
- void newMouse(wlr_input_device*);
+ void newMouse(wlr_input_device*, bool virt = false);
void destroyKeyboard(SKeyboard*);
void destroyMouse(wlr_input_device*);
@@ -57,9 +57,20 @@ public:
std::list<STabletTool> m_lTabletTools;
std::list<STabletPad> m_lTabletPads;
+ // idle inhibitors
+ std::list<SIdleInhibitor> m_lIdleInhibitors;
+
void newTabletTool(wlr_input_device*);
void newTabletPad(wlr_input_device*);
void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
+ void newIdleInhibitor(wlr_idle_inhibitor_v1*);
+ void recheckIdleInhibitorStatus();
+
+ void onSwipeBegin(wlr_pointer_swipe_begin_event*);
+ void onSwipeEnd(wlr_pointer_swipe_end_event*);
+ void onSwipeUpdate(wlr_pointer_swipe_update_event*);
+
+ SSwipeGesture m_sActiveSwipe;
SKeyboard* m_pActiveKeyboard = nullptr;
@@ -81,6 +92,9 @@ private:
STabletTool* ensureTabletToolPresent(wlr_tablet_tool*);
void applyConfigToKeyboard(SKeyboard*);
+
+ // for shared mods
+ uint32_t accumulateModsFromAllKBs();
};
inline std::unique_ptr<CInputManager> g_pInputManager; \ No newline at end of file
diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp
new file mode 100644
index 00000000..98f31945
--- /dev/null
+++ b/src/managers/input/Swipe.cpp
@@ -0,0 +1,152 @@
+#include "InputManager.hpp"
+#include "../../Compositor.hpp"
+
+void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) {
+
+ static auto *const PSWIPE = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe")->intValue;
+
+ if (e->fingers < 3 || *PSWIPE == 0)
+ return;
+
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
+
+ Debug::log(LOG, "Starting a swipe from %s", PWORKSPACE->m_szName.c_str());
+
+ m_sActiveSwipe.pWorkspaceBegin = PWORKSPACE;
+ m_sActiveSwipe.delta = 0;
+ m_sActiveSwipe.pMonitor = g_pCompositor->m_pLastMonitor;
+ m_sActiveSwipe.avgSpeed = 0;
+ m_sActiveSwipe.speedPoints = 0;
+}
+
+void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
+
+ if (!m_sActiveSwipe.pWorkspaceBegin)
+ return; // no valid swipe
+
+ static auto *const PSWIPEPERC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_cancel_ratio")->floatValue;
+ static auto *const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue;
+ static auto *const PSWIPEFORC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_min_speed_to_force")->intValue;
+
+ // commit
+ std::string wsname = "";
+ auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
+ auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
+
+ const auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight);
+ const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
+
+ const auto RENDEROFFSETMIDDLE = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.vec();
+
+ if ((abs(m_sActiveSwipe.delta) < *PSWIPEDIST * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) || abs(m_sActiveSwipe.delta) < 2) {
+ // revert
+ if (m_sActiveSwipe.delta < 0) {
+ // to left
+ PWORKSPACEL->m_vRenderOffset = Vector2D({-m_sActiveSwipe.pMonitor->vecSize.x, 0});
+ } else {
+ // to right
+ PWORKSPACER->m_vRenderOffset = Vector2D({m_sActiveSwipe.pMonitor->vecSize.x, 0});
+ }
+
+ m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D();
+ } else if (m_sActiveSwipe.delta < 0) {
+ // switch to left
+ const auto RENDEROFFSET = PWORKSPACEL->m_vRenderOffset.vec();
+
+ g_pKeybindManager->m_mDispatchers["workspace"]("[internal]" + std::to_string(workspaceIDLeft));
+
+ PWORKSPACEL->m_vRenderOffset.setValue(RENDEROFFSET);
+ PWORKSPACEL->m_fAlpha.setValueAndWarp(255.f);
+
+ Debug::log(LOG, "Ended swipe to the left");
+ } else {
+ // switch to right
+ const auto RENDEROFFSET = PWORKSPACER->m_vRenderOffset.vec();
+
+ g_pKeybindManager->m_mDispatchers["workspace"]("[internal]" + std::to_string(workspaceIDRight));
+
+ PWORKSPACER->m_vRenderOffset.setValue(RENDEROFFSET);
+ PWORKSPACER->m_fAlpha.setValueAndWarp(255.f);
+
+ Debug::log(LOG, "Ended swipe to the right");
+ }
+
+ m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE);
+ m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f);
+
+ PWORKSPACEL->m_bForceRendering = false;
+ PWORKSPACER->m_bForceRendering = false;
+ m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = false;
+
+ m_sActiveSwipe.pWorkspaceBegin = nullptr;
+
+ g_pInputManager->refocus();
+}
+
+void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
+ if (!m_sActiveSwipe.pWorkspaceBegin)
+ return;
+
+ static auto *const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue;
+ static auto *const PSWIPEINVR = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_invert")->intValue;
+
+ m_sActiveSwipe.delta += *PSWIPEINVR ? -e->dx : e->dx;
+
+ m_sActiveSwipe.avgSpeed = (m_sActiveSwipe.avgSpeed * m_sActiveSwipe.speedPoints + abs(e->dx)) / (m_sActiveSwipe.speedPoints + 1);
+ m_sActiveSwipe.speedPoints++;
+
+ std::string wsname = "";
+ auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
+ auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
+
+ if (workspaceIDLeft == INT_MAX || workspaceIDRight == INT_MAX || workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID)
+ return;
+
+ m_sActiveSwipe.delta = std::clamp(m_sActiveSwipe.delta, (double)-*PSWIPEDIST, (double)*PSWIPEDIST);
+
+ if (m_sActiveSwipe.delta < 0) {
+ if (workspaceIDLeft > m_sActiveSwipe.pWorkspaceBegin->m_iID){
+ m_sActiveSwipe.delta = 0;
+ return;
+ }
+
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
+
+ PWORKSPACE->m_bForceRendering = true;
+
+ if (workspaceIDLeft != workspaceIDRight) {
+ const auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight);
+
+ PWORKSPACER->m_bForceRendering = false;
+ }
+
+ PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x - m_sActiveSwipe.pMonitor->vecSize.x, 0));
+ m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0));
+
+ g_pCompositor->updateWorkspaceWindowDecos(workspaceIDLeft);
+ } else {
+ if (workspaceIDRight < m_sActiveSwipe.pWorkspaceBegin->m_iID){
+ m_sActiveSwipe.delta = 0;
+ return;
+ }
+
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDRight);
+
+ PWORKSPACE->m_bForceRendering = true;
+
+ if (workspaceIDLeft != workspaceIDRight) {
+ const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
+
+ PWORKSPACEL->m_bForceRendering = false;
+ }
+
+ PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x + m_sActiveSwipe.pMonitor->vecSize.x, 0));
+ m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0));
+
+ g_pCompositor->updateWorkspaceWindowDecos(workspaceIDRight);
+ }
+
+ g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor);
+
+ g_pCompositor->updateWorkspaceWindowDecos(m_sActiveSwipe.pWorkspaceBegin->m_iID);
+} \ No newline at end of file
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp
index 6a62e58e..ba79c458 100644
--- a/src/managers/input/Tablets.cpp
+++ b/src/managers/input/Tablets.cpp
@@ -10,7 +10,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
Debug::log(ERR, "Tablet had no name???"); // logic error
}
- PNEWTABLET->wlrTablet = pDevice->tablet;
+ PNEWTABLET->wlrTablet = wlr_tablet_from_input_device(pDevice);
PNEWTABLET->wlrDevice = pDevice;
PNEWTABLET->wlrTabletV2 = wlr_tablet_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice);
PNEWTABLET->wlrTablet->data = PNEWTABLET;
@@ -27,7 +27,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
Debug::log(LOG, "Removed a tablet");
}, PNEWTABLET, "Tablet");
- PNEWTABLET->hyprListener_Axis.initCallback(&pDevice->tablet->events.axis, [](void* owner, void* data) {
+ PNEWTABLET->hyprListener_Axis.initCallback(&wlr_tablet_from_input_device(pDevice)->events.axis, [](void* owner, void* data) {
const auto EVENT = (wlr_tablet_tool_axis_event*)data;
const auto PTAB = (STablet*)owner;
@@ -80,7 +80,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
}, PNEWTABLET, "Tablet");
- PNEWTABLET->hyprListener_Tip.initCallback(&pDevice->tablet->events.tip, [](void* owner, void* data) {
+ PNEWTABLET->hyprListener_Tip.initCallback(&wlr_tablet_from_input_device(pDevice)->events.tip, [](void* owner, void* data) {
const auto EVENT = (wlr_tablet_tool_tip_event*)data;
const auto PTAB = (STablet*)owner;
@@ -98,7 +98,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
}, PNEWTABLET, "Tablet");
- PNEWTABLET->hyprListener_Button.initCallback(&pDevice->tablet->events.button, [](void* owner, void* data) {
+ PNEWTABLET->hyprListener_Button.initCallback(&wlr_tablet_from_input_device(pDevice)->events.button, [](void* owner, void* data) {
const auto EVENT = (wlr_tablet_tool_button_event*)data;
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
@@ -107,7 +107,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
}, PNEWTABLET, "Tablet");
- PNEWTABLET->hyprListener_Proximity.initCallback(&pDevice->tablet->events.proximity, [](void* owner, void* data) {
+ PNEWTABLET->hyprListener_Proximity.initCallback(&wlr_tablet_from_input_device(pDevice)->events.proximity, [](void* owner, void* data) {
const auto EVENT = (wlr_tablet_tool_proximity_event*)data;
const auto PTAB = (STablet*)owner;
@@ -165,7 +165,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) {
PNEWPAD->wlrTabletPadV2 = wlr_tablet_pad_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice);
- PNEWPAD->hyprListener_Button.initCallback(&pDevice->tablet_pad->events.button, [](void* owner, void* data) {
+ PNEWPAD->hyprListener_Button.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.button, [](void* owner, void* data) {
const auto EVENT = (wlr_tablet_pad_button_event*)data;
const auto PPAD = (STabletPad*)owner;
@@ -175,7 +175,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) {
}, PNEWPAD, "Tablet Pad");
- PNEWPAD->hyprListener_Strip.initCallback(&pDevice->tablet_pad->events.strip, [](void* owner, void* data) {
+ PNEWPAD->hyprListener_Strip.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.strip, [](void* owner, void* data) {
const auto EVENT = (wlr_tablet_pad_strip_event*)data;
const auto PPAD = (STabletPad*)owner;
@@ -184,7 +184,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) {
}, PNEWPAD, "Tablet Pad");
- PNEWPAD->hyprListener_Ring.initCallback(&pDevice->tablet_pad->events.strip, [](void* owner, void* data) {
+ PNEWPAD->hyprListener_Ring.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.strip, [](void* owner, void* data) {
const auto EVENT = (wlr_tablet_pad_ring_event*)data;
const auto PPAD = (STabletPad*)owner;
@@ -193,7 +193,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) {
}, PNEWPAD, "Tablet Pad");
- PNEWPAD->hyprListener_Attach.initCallback(&pDevice->tablet_pad->events.strip, [](void* owner, void* data) {
+ PNEWPAD->hyprListener_Attach.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.strip, [](void* owner, void* data) {
const auto TABLET = (wlr_tablet_tool*)data;
const auto PPAD = (STabletPad*)owner;