summaryrefslogtreecommitdiff
path: root/src/managers/input
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2022-12-16 17:17:31 +0000
committerGitHub <noreply@github.com>2022-12-16 17:17:31 +0000
commit98a4fa2b0d79298fa29b048a3ba15c3bf5aed8cd (patch)
tree64e78342cf08e5f9ad87bd5f6ea36233133be7bb /src/managers/input
parent7c33c7fc64203c17b4f3625a16ae6b4774992c0e (diff)
Added clang format (#1239)
* clang-format stuff and format files
Diffstat (limited to 'src/managers/input')
-rw-r--r--src/managers/input/IdleInhibitor.cpp17
-rw-r--r--src/managers/input/InputManager.cpp429
-rw-r--r--src/managers/input/InputManager.hpp194
-rw-r--r--src/managers/input/InputMethodRelay.cpp291
-rw-r--r--src/managers/input/InputMethodRelay.hpp37
-rw-r--r--src/managers/input/Swipe.cpp81
-rw-r--r--src/managers/input/Tablets.cpp307
-rw-r--r--src/managers/input/Touch.cpp19
8 files changed, 705 insertions, 670 deletions
diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp
index 8c0a3267..3e3411fb 100644
--- a/src/managers/input/IdleInhibitor.cpp
+++ b/src/managers/input/IdleInhibitor.cpp
@@ -17,17 +17,18 @@ void CInputManager::newIdleInhibitor(wlr_idle_inhibitor_v1* pInhibitor) {
PINHIBIT->pWlrInhibitor = pInhibitor;
- PINHIBIT->hyprListener_Destroy.initCallback(&pInhibitor->events.destroy, [](void* owner, void* data){
+ PINHIBIT->hyprListener_Destroy.initCallback(
+ &pInhibitor->events.destroy,
+ [](void* owner, void* data) {
+ const auto PINH = (SIdleInhibitor*)owner;
- const auto PINH = (SIdleInhibitor*)owner;
+ g_pInputManager->m_lIdleInhibitors.remove(*PINH);
- g_pInputManager->m_lIdleInhibitors.remove(*PINH);
+ Debug::log(LOG, "Destroyed an idleinhibitor");
- Debug::log(LOG, "Destroyed an idleinhibitor");
-
- g_pInputManager->recheckIdleInhibitorStatus();
-
- }, PINHIBIT, "IdleInhibitor");
+ g_pInputManager->recheckIdleInhibitorStatus();
+ },
+ PINHIBIT, "IdleInhibitor");
PINHIBIT->pWindow = g_pCompositor->getWindowFromSurface(pInhibitor->surface);
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 41233f92..d3cd9079 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -2,16 +2,18 @@
#include "../../Compositor.hpp"
void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
- static auto *const PSENS = &g_pConfigManager->getConfigValuePtr("general:sensitivity")->floatValue;
- static auto *const PNOACCEL = &g_pConfigManager->getConfigValuePtr("input:force_no_accel")->intValue;
+ static auto* const PSENS = &g_pConfigManager->getConfigValuePtr("general:sensitivity")->floatValue;
+ static auto* const PNOACCEL = &g_pConfigManager->getConfigValuePtr("input:force_no_accel")->intValue;
static auto* const PSENSTORAW = &g_pConfigManager->getConfigValuePtr("general:apply_sens_to_raw")->intValue;
- const auto DELTA = *PNOACCEL == 1 ? Vector2D(e->unaccel_dx, e->unaccel_dy) : Vector2D(e->delta_x, e->delta_y);
+ const auto DELTA = *PNOACCEL == 1 ? Vector2D(e->unaccel_dx, e->unaccel_dy) : Vector2D(e->delta_x, e->delta_y);
if (*PSENSTORAW == 1)
- wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x * *PSENS, DELTA.y * *PSENS, e->unaccel_dx * *PSENS, e->unaccel_dy * *PSENS);
+ wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x * *PSENS,
+ DELTA.y * *PSENS, e->unaccel_dx * *PSENS, e->unaccel_dy * *PSENS);
else
- wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x, DELTA.y, e->unaccel_dx, e->unaccel_dy);
+ wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x, DELTA.y,
+ e->unaccel_dx, e->unaccel_dy);
wlr_cursor_move(g_pCompositor->m_sWLRCursor, &e->pointer->base, DELTA.x * *PSENS, DELTA.y * *PSENS);
@@ -29,19 +31,19 @@ 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;
- static auto *const PMOUSEDPMS = &g_pConfigManager->getConfigValuePtr("misc:mouse_move_enables_dpms")->intValue;
- static auto *const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
- static auto *const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue;
- static auto *const PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->intValue;
-
- m_pFoundSurfaceToFocus = nullptr;
- m_pFoundLSToFocus = nullptr;
- m_pFoundWindowToFocus = nullptr;
- wlr_surface* foundSurface = nullptr;
- Vector2D surfaceCoords;
- Vector2D surfacePos = Vector2D(-1337, -1337);
- CWindow* pFoundWindow = nullptr;
+ static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
+ static auto* const PMOUSEDPMS = &g_pConfigManager->getConfigValuePtr("misc:mouse_move_enables_dpms")->intValue;
+ static auto* const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
+ static auto* const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue;
+ static auto* const PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->intValue;
+
+ m_pFoundSurfaceToFocus = nullptr;
+ m_pFoundLSToFocus = nullptr;
+ m_pFoundWindowToFocus = nullptr;
+ wlr_surface* foundSurface = nullptr;
+ Vector2D surfaceCoords;
+ Vector2D surfacePos = Vector2D(-1337, -1337);
+ CWindow* pFoundWindow = nullptr;
SLayerSurface* pFoundLayerSurface = nullptr;
if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown)
@@ -57,7 +59,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
g_pKeybindManager->dpms("on");
}
- Vector2D mouseCoords = getMouseCoordsInternal();
+ Vector2D mouseCoords = getMouseCoordsInternal();
const auto MOUSECOORDSFLOORED = mouseCoords.floor();
if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored && !refocus)
@@ -73,20 +75,22 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
// XWayland windows sometimes issue constraints weirdly.
// TODO: We probably should search their parent. wlr_xwayland_surface->parent
const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
- const auto PCONSTRAINT = constraintFromWlr(g_pCompositor->m_sSeat.mouse->currentConstraint);
+ const auto PCONSTRAINT = constraintFromWlr(g_pCompositor->m_sSeat.mouse->currentConstraint);
if (!CONSTRAINTWINDOW || !PCONSTRAINT) {
unconstrainMouse();
} else {
// Native Wayland apps know how 2 constrain themselves.
// XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya.
- const auto CONSTRAINTPOS = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec();
- const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec();
+ const auto CONSTRAINTPOS =
+ CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec();
+ const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) :
+ CONSTRAINTWINDOW->m_vRealSize.vec();
if (g_pCompositor->m_sSeat.mouse->currentConstraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED) {
// we just snap the cursor to where it should be.
- Vector2D hint = { PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y };
+ Vector2D hint = {PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y};
wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, CONSTRAINTPOS.x + hint.x, CONSTRAINTPOS.y + hint.y);
@@ -108,7 +112,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (CONSTRAINTWINDOW->m_bIsX11) {
foundSurface = g_pXWaylandManager->getWindowSurface(CONSTRAINTWINDOW);
- surfacePos = CONSTRAINTWINDOW->m_vRealPosition.vec();
+ surfacePos = CONSTRAINTWINDOW->m_vRealPosition.vec();
} else {
g_pCompositor->vectorWindowToSurface(mouseCoords, CONSTRAINTWINDOW, surfaceCoords);
}
@@ -152,7 +156,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
// only check floating because tiled cant be over fullscreen
for (auto w = g_pCompositor->m_vWindows.rbegin(); w != g_pCompositor->m_vWindows.rend(); w++) {
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
- if ((((*w)->m_bIsFloating && (*w)->m_bIsMapped && ((*w)->m_bCreatedOverFullscreen || (*w)->m_bPinned)) || (g_pCompositor->isWorkspaceSpecial((*w)->m_iWorkspaceID) && PMONITOR->specialWorkspaceID)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->isHidden()) {
+ if ((((*w)->m_bIsFloating && (*w)->m_bIsMapped && ((*w)->m_bCreatedOverFullscreen || (*w)->m_bPinned)) ||
+ (g_pCompositor->isWorkspaceSpecial((*w)->m_iWorkspaceID) && PMONITOR->specialWorkspaceID)) &&
+ wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->isHidden()) {
pFoundWindow = (*w).get();
break;
}
@@ -160,10 +166,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (!pFoundWindow->m_bIsX11) {
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
- surfacePos = Vector2D(-1337, -1337);
+ surfacePos = Vector2D(-1337, -1337);
} else {
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
- surfacePos = pFoundWindow->m_vRealPosition.vec();
+ surfacePos = pFoundWindow->m_vRealPosition.vec();
}
}
@@ -187,9 +193,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
// TODO: this causes crashes, sometimes. ???
- // if (refocus && !pFoundWindow) {
- // pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace);
- // }
+ // if (refocus && !pFoundWindow) {
+ // pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace);
+ // }
}
if (pFoundWindow) {
@@ -197,7 +203,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
} else {
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
- surfacePos = pFoundWindow->m_vRealPosition.vec();
+ surfacePos = pFoundWindow->m_vRealPosition.vec();
}
}
}
@@ -218,7 +224,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor);
else
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor);
-
+
m_bEmptyFocusCursorSet = true;
}
@@ -258,14 +264,15 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
// set the values for use
if (refocus) {
- m_pFoundLSToFocus = pFoundLayerSurface;
- m_pFoundWindowToFocus = pFoundWindow;
+ m_pFoundLSToFocus = pFoundLayerSurface;
+ m_pFoundWindowToFocus = pFoundWindow;
m_pFoundSurfaceToFocus = foundSurface;
}
if (pFoundWindow) {
if (*PFOLLOWMOUSE != 1 && !refocus) {
- if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow && ((pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR == 2) || (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR != 0))) {
+ if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow &&
+ ((pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR == 2) || (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR != 0))) {
// enter if change floating style
if (*PFOLLOWMOUSE != 3 && allowKeyboardRefocus)
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
@@ -289,7 +296,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
m_bLastFocusOnLS = false;
- return; // don't enter any new surfaces
+ return; // don't enter any new surfaces
} else {
if ((*PFOLLOWMOUSE != 3 && allowKeyboardRefocus) || refocus)
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
@@ -315,14 +322,9 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
m_tmrLastCursorMovement.reset();
switch (m_ecbClickBehavior) {
- case CLICKMODE_DEFAULT:
- processMouseDownNormal(e);
- break;
- case CLICKMODE_KILL:
- processMouseDownKill(e);
- break;
- default:
- break;
+ case CLICKMODE_DEFAULT: processMouseDownNormal(e); break;
+ case CLICKMODE_KILL: processMouseDownKill(e); break;
+ default: break;
}
}
@@ -372,17 +374,16 @@ void CInputManager::setClickMode(eClickBehaviorMode mode) {
// set cursor
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor);
break;
- default:
- break;
+ default: break;
}
}
void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
-
+
// notify the keybind manager
- static auto *const PPASSMOUSE = &g_pConfigManager->getConfigValuePtr("binds:pass_mouse_when_bound")->intValue;
- const auto PASS = g_pKeybindManager->onMouseEvent(e);
- static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
+ static auto* const PPASSMOUSE = &g_pConfigManager->getConfigValuePtr("binds:pass_mouse_when_bound")->intValue;
+ const auto PASS = g_pKeybindManager->onMouseEvent(e);
+ static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
if (!PASS && !*PPASSMOUSE)
return;
@@ -400,8 +401,7 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
g_pCompositor->moveWindowToTop(g_pCompositor->m_pLastWindow);
break;
- case WLR_BUTTON_RELEASED:
- break;
+ case WLR_BUTTON_RELEASED: break;
}
// notify app if we didnt handle it
@@ -424,10 +424,8 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
kill(PWINDOW->getPID(), SIGKILL);
break;
}
- case WLR_BUTTON_RELEASED:
- break;
- default:
- break;
+ case WLR_BUTTON_RELEASED: break;
+ default: break;
}
// reset click behavior mode
@@ -435,17 +433,16 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
}
void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
- static auto *const PSCROLLFACTOR = &g_pConfigManager->getConfigValuePtr("input:touchpad:scroll_factor")->floatValue;
+ static auto* const PSCROLLFACTOR = &g_pConfigManager->getConfigValuePtr("input:touchpad:scroll_factor")->floatValue;
- auto factor = (*PSCROLLFACTOR <= 0.f || e->source != WLR_AXIS_SOURCE_FINGER ? 1.f : *PSCROLLFACTOR);
+ auto factor = (*PSCROLLFACTOR <= 0.f || e->source != WLR_AXIS_SOURCE_FINGER ? 1.f : *PSCROLLFACTOR);
- bool passEvent = g_pKeybindManager->onAxisEvent(e);
+ bool passEvent = g_pKeybindManager->onAxisEvent(e);
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
if (passEvent) {
- wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, factor * e->delta,
- std::round(factor * e->delta_discrete), e->source);
+ wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, factor * e->delta, std::round(factor * e->delta_discrete), e->source);
}
}
@@ -461,19 +458,21 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
try {
PNEWKEYBOARD->name = getNameForNewDevice(keyboard->name);
} catch (std::exception& e) {
- Debug::log(ERR, "Keyboard had no name???"); // logic error
+ Debug::log(ERR, "Keyboard had no name???"); // logic error
}
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");
- PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
- const auto PKEYBOARD = (SKeyboard*)owner;
-
- g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
+ PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(
+ &wlr_keyboard_from_input_device(keyboard)->events.keymap,
+ [&](void* owner, void* data) {
+ const auto PKEYBOARD = (SKeyboard*)owner;
- }, PNEWKEYBOARD, "Keyboard");
+ g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," + getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
+ },
+ PNEWKEYBOARD, "Keyboard");
disableAllKeyboards(false);
@@ -491,24 +490,26 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
void CInputManager::newVirtualKeyboard(wlr_input_device* keyboard) {
const auto PNEWKEYBOARD = &m_lKeyboards.emplace_back();
- PNEWKEYBOARD->keyboard = keyboard;
+ PNEWKEYBOARD->keyboard = keyboard;
PNEWKEYBOARD->isVirtual = true;
try {
PNEWKEYBOARD->name = getNameForNewDevice(keyboard->name);
} catch (std::exception& e) {
- Debug::log(ERR, "Keyboard had no name???"); // logic error
+ Debug::log(ERR, "Keyboard had no name???"); // logic error
}
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");
- PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
- const auto PKEYBOARD = (SKeyboard*)owner;
-
- g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
+ PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(
+ &wlr_keyboard_from_input_device(keyboard)->events.keymap,
+ [&](void* owner, void* data) {
+ const auto PKEYBOARD = (SKeyboard*)owner;
- }, PNEWKEYBOARD, "Keyboard");
+ g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," + getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
+ },
+ PNEWKEYBOARD, "Keyboard");
disableAllKeyboards(true);
@@ -531,7 +532,7 @@ void CInputManager::setKeyboardLayout() {
}
void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
- auto devname = pKeyboard->name;
+ auto devname = pKeyboard->name;
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
@@ -542,20 +543,22 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
if (!wlr_keyboard_from_input_device(pKeyboard->keyboard))
return;
- const auto REPEATRATE = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "repeat_rate") : g_pConfigManager->getInt("input:repeat_rate");
+ const auto REPEATRATE = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "repeat_rate") : g_pConfigManager->getInt("input:repeat_rate");
const auto REPEATDELAY = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "repeat_delay") : g_pConfigManager->getInt("input:repeat_delay");
const auto NUMLOCKON = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "numlock_by_default") : g_pConfigManager->getInt("input:numlock_by_default");
const auto FILEPATH = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_file") : g_pConfigManager->getString("input:kb_file");
- const auto RULES = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_rules") : g_pConfigManager->getString("input:kb_rules");
- const auto MODEL = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_model") : g_pConfigManager->getString("input:kb_model");
- const auto LAYOUT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_layout") : g_pConfigManager->getString("input:kb_layout");
- const auto VARIANT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_variant") : g_pConfigManager->getString("input:kb_variant");
- const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_options") : g_pConfigManager->getString("input:kb_options");
+ const auto RULES = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_rules") : g_pConfigManager->getString("input:kb_rules");
+ const auto MODEL = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_model") : g_pConfigManager->getString("input:kb_model");
+ const auto LAYOUT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_layout") : g_pConfigManager->getString("input:kb_layout");
+ const auto VARIANT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_variant") : g_pConfigManager->getString("input:kb_variant");
+ const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_options") : g_pConfigManager->getString("input:kb_options");
try {
- 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 && FILEPATH == pKeyboard->xkbFilePath) {
+ 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 && FILEPATH == pKeyboard->xkbFilePath) {
Debug::log(LOG, "Not applying config to keyboard, it did not change.");
return;
}
@@ -567,22 +570,17 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
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;
- pKeyboard->numlockOn = NUMLOCKON;
+ pKeyboard->repeatRate = REPEATRATE;
+ pKeyboard->numlockOn = NUMLOCKON;
pKeyboard->xkbFilePath = FILEPATH.c_str();
- xkb_rule_names rules = {
- .rules = RULES.c_str(),
- .model = MODEL.c_str(),
- .layout = LAYOUT.c_str(),
- .variant = VARIANT.c_str(),
- .options = OPTIONS.c_str()};
+ xkb_rule_names rules = {.rules = RULES.c_str(), .model = MODEL.c_str(), .layout = LAYOUT.c_str(), .variant = VARIANT.c_str(), .options = OPTIONS.c_str()};
- pKeyboard->currentRules.rules = RULES;
- pKeyboard->currentRules.model = MODEL;
+ pKeyboard->currentRules.rules = RULES;
+ pKeyboard->currentRules.model = MODEL;
pKeyboard->currentRules.variant = VARIANT;
pKeyboard->currentRules.options = OPTIONS;
- pKeyboard->currentRules.layout = LAYOUT;
+ pKeyboard->currentRules.layout = LAYOUT;
const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
@@ -591,35 +589,38 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
return;
}
- Debug::log(LOG, "Attempting to create a keymap for layout %s with variant %s (rules: %s, model: %s, options: %s)", rules.layout, rules.variant, rules.rules, rules.model, rules.options);
+ Debug::log(LOG, "Attempting to create a keymap for layout %s with variant %s (rules: %s, model: %s, options: %s)", rules.layout, rules.variant, rules.rules, rules.model,
+ rules.options);
- xkb_keymap * KEYMAP = NULL;
+ xkb_keymap* KEYMAP = NULL;
if (!FILEPATH.empty()) {
- auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath);
+ auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath);
- if (!std::filesystem::exists(path)) {
- Debug::log(ERR, "input:kb_file= file doesnt exist");
- } else {
- KEYMAP = xkb_keymap_new_from_file(CONTEXT, fopen(path.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
- }
+ if (!std::filesystem::exists(path)) {
+ Debug::log(ERR, "input:kb_file= file doesnt exist");
+ } else {
+ KEYMAP = xkb_keymap_new_from_file(CONTEXT, fopen(path.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
+ }
}
if (!KEYMAP) {
- KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
+ KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
}
if (!KEYMAP) {
- g_pConfigManager->addParseError("Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS + ", layout: " + LAYOUT + " )");
+ g_pConfigManager->addParseError("Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS +
+ ", layout: " + LAYOUT + " )");
- 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);
+ 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.model = "";
+ pKeyboard->currentRules.rules = "";
+ pKeyboard->currentRules.model = "";
pKeyboard->currentRules.variant = "";
pKeyboard->currentRules.options = "";
- pKeyboard->currentRules.layout = "";
+ pKeyboard->currentRules.layout = "";
KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
}
@@ -643,7 +644,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
xkb_keymap_unref(KEYMAP);
xkb_context_unref(CONTEXT);
- g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," +getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
+ g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," + getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
Debug::log(LOG, "Set the keyboard layout to %s and variant to %s for keyboard \"%s\"", rules.layout, rules.variant, pKeyboard->keyboard->name);
}
@@ -653,17 +654,19 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) {
const auto PMOUSE = &m_lMice.back();
PMOUSE->mouse = mouse;
- PMOUSE->virt = virt;
+ PMOUSE->virt = virt;
try {
PMOUSE->name = getNameForNewDevice(mouse->name);
- } catch(std::exception& e) {
+ } catch (std::exception& e) {
Debug::log(ERR, "Mouse had no name???"); // logic error
}
if (wlr_input_device_is_libinput(mouse)) {
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(mouse);
- Debug::log(LOG, "New mouse has libinput sens %.2f (%.2f) with accel profile %i (%i)", libinput_device_config_accel_get_speed(LIBINPUTDEV), libinput_device_config_accel_get_default_speed(LIBINPUTDEV), libinput_device_config_accel_get_profile(LIBINPUTDEV), libinput_device_config_accel_get_default_profile(LIBINPUTDEV));
+ Debug::log(LOG, "New mouse has libinput sens %.2f (%.2f) with accel profile %i (%i)", libinput_device_config_accel_get_speed(LIBINPUTDEV),
+ libinput_device_config_accel_get_default_speed(LIBINPUTDEV), libinput_device_config_accel_get_profile(LIBINPUTDEV),
+ libinput_device_config_accel_get_default_profile(LIBINPUTDEV));
}
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse);
@@ -685,7 +688,7 @@ void CInputManager::setPointerConfigs() {
for (auto& m : m_lMice) {
const auto PPOINTER = &m;
- auto devname = PPOINTER->name;
+ auto devname = PPOINTER->name;
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
@@ -703,7 +706,8 @@ void CInputManager::setPointerConfigs() {
if (wlr_input_device_is_libinput(m.mouse)) {
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.mouse);
- if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "clickfinger_behavior") : g_pConfigManager->getInt("input:touchpad:clickfinger_behavior")) == 0) // toggle software buttons or clickfinger
+ if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "clickfinger_behavior") : g_pConfigManager->getInt("input:touchpad:clickfinger_behavior")) ==
+ 0) // toggle software buttons or clickfinger
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
else
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
@@ -713,7 +717,7 @@ void CInputManager::setPointerConfigs() {
else
libinput_device_config_left_handed_set(LIBINPUTDEV, 1);
- if (libinput_device_config_middle_emulation_is_available(LIBINPUTDEV)) { // middleclick on r+l mouse button pressed
+ if (libinput_device_config_middle_emulation_is_available(LIBINPUTDEV)) { // middleclick on r+l mouse button pressed
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "middle_button_emulation") : g_pConfigManager->getInt("input:touchpad:middle_button_emulation")) == 1)
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
else
@@ -740,25 +744,30 @@ void CInputManager::setPointerConfigs() {
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 (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop)
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "tap-to-click") : g_pConfigManager->getInt("input:touchpad:tap-to-click")) == 1)
libinput_device_config_tap_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_ENABLED);
if (libinput_device_config_scroll_has_natural_scroll(LIBINPUTDEV)) {
double w = 0, h = 0;
- if (libinput_device_has_capability(LIBINPUTDEV, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(LIBINPUTDEV, &w, &h) == 0) // pointer with size is a touchpad
- libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "natural_scroll") : g_pConfigManager->getInt("input:touchpad:natural_scroll")));
+ if (libinput_device_has_capability(LIBINPUTDEV, LIBINPUT_DEVICE_CAP_POINTER) &&
+ libinput_device_get_size(LIBINPUTDEV, &w, &h) == 0) // pointer with size is a touchpad
+ libinput_device_config_scroll_set_natural_scroll_enabled(
+ LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "natural_scroll") : g_pConfigManager->getInt("input:touchpad:natural_scroll")));
else
- libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "natural_scroll") : g_pConfigManager->getInt("input:natural_scroll")));
+ libinput_device_config_scroll_set_natural_scroll_enabled(
+ LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "natural_scroll") : g_pConfigManager->getInt("input:natural_scroll")));
}
if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) {
- const auto DWT = static_cast<enum libinput_config_dwt_state>((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "disable_while_typing") : g_pConfigManager->getInt("input:touchpad:disable_while_typing")) != 0);
+ const auto DWT = static_cast<enum libinput_config_dwt_state>(
+ (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "disable_while_typing") : g_pConfigManager->getInt("input:touchpad:disable_while_typing")) != 0);
libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT);
}
- const auto LIBINPUTSENS = std::clamp((HASCONFIG ? g_pConfigManager->getDeviceFloat(devname, "sensitivity") : g_pConfigManager->getFloat("input:sensitivity")), -1.f, 1.f);
+ const auto LIBINPUTSENS =
+ std::clamp((HASCONFIG ? g_pConfigManager->getDeviceFloat(devname, "sensitivity") : g_pConfigManager->getFloat("input:sensitivity")), -1.f, 1.f);
libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS);
const auto ACCELPROFILE = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "accel_profile") : g_pConfigManager->getString("input:accel_profile");
@@ -791,7 +800,7 @@ void CInputManager::destroyKeyboard(SKeyboard* pKeyboard) {
m_lKeyboards.remove(*pKeyboard);
if (m_lKeyboards.size() > 0) {
- m_pActiveKeyboard = &m_lKeyboards.back();
+ m_pActiveKeyboard = &m_lKeyboards.back();
m_pActiveKeyboard->active = true;
} else {
m_pActiveKeyboard = nullptr;
@@ -815,22 +824,20 @@ void CInputManager::destroyMouse(wlr_input_device* mouse) {
unconstrainMouse();
}
-
-void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) {
+void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) {
auto keyboard = wlr_keyboard_from_input_device(pKeyboard);
-
+
if (keyboard->xkb_state == NULL) {
- return;
- }
-
- uint32_t leds = 0;
- for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) {
- if (xkb_state_led_index_is_active(keyboard->xkb_state,
- keyboard->led_indexes[i])) {
- leds |= (1 << i);
- }
- }
-
+ return;
+ }
+
+ uint32_t leds = 0;
+ for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) {
+ if (xkb_state_led_index_is_active(keyboard->xkb_state, keyboard->led_indexes[i])) {
+ leds |= (1 << i);
+ }
+ }
+
for (auto& kb : m_lKeyboards) {
if ((kb.isVirtual && shouldIgnoreVirtualKeyboard(&kb)) || kb.keyboard == pKeyboard)
continue;
@@ -839,7 +846,6 @@ void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) {
}
}
-
void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {
bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard);
@@ -866,8 +872,8 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
const auto ALLMODS = accumulateModsFromAllKBs();
- auto MODS = wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers;
- MODS.depressed = ALLMODS;
+ auto MODS = wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers;
+ MODS.depressed = ALLMODS;
if (PIMEGRAB && PIMEGRAB->pWlrKbGrab && PIMEGRAB->pWlrKbGrab->input_method) {
wlr_input_method_keyboard_grab_v2_set_keyboard(PIMEGRAB->pWlrKbGrab, wlr_keyboard_from_input_device(pKeyboard->keyboard));
@@ -882,14 +888,16 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
if (PWLRKB->modifiers.group != pKeyboard->activeLayout) {
- pKeyboard->activeLayout = PWLRKB->modifiers.group;
+ pKeyboard->activeLayout = PWLRKB->modifiers.group;
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," + getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
- }
+ }
}
bool CInputManager::shouldIgnoreVirtualKeyboard(SKeyboard* pKeyboard) {
- return !pKeyboard || (m_sIMERelay.m_pKeyboardGrab && wl_resource_get_client(m_sIMERelay.m_pKeyboardGrab->pWlrKbGrab->resource) == wl_resource_get_client(wlr_input_device_get_virtual_keyboard(pKeyboard->keyboard)->resource));
+ return !pKeyboard ||
+ (m_sIMERelay.m_pKeyboardGrab &&
+ wl_resource_get_client(m_sIMERelay.m_pKeyboardGrab->pWlrKbGrab->resource) == wl_resource_get_client(wlr_input_device_get_virtual_keyboard(pKeyboard->keyboard)->resource));
}
void CInputManager::refocus() {
@@ -901,16 +909,14 @@ void CInputManager::updateDragIcon() {
return;
switch (m_sDrag.dragIcon->drag->grab_type) {
- case WLR_DRAG_GRAB_KEYBOARD:
- break;
+ case WLR_DRAG_GRAB_KEYBOARD: break;
case WLR_DRAG_GRAB_KEYBOARD_POINTER: {
wlr_box box = {m_sDrag.pos.x - 2, m_sDrag.pos.y - 2, m_sDrag.dragIcon->surface->current.width + 4, m_sDrag.dragIcon->surface->current.height + 4};
g_pHyprRenderer->damageBox(&box);
m_sDrag.pos = getMouseCoordsInternal();
break;
}
- default:
- break;
+ default: break;
}
}
@@ -926,10 +932,11 @@ void CInputManager::recheckConstraint(SMouse* pMouse) {
pixman_region32_clear(&pMouse->confinedTo);
}
- const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
+ const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
const auto PWINDOWNAME = PWINDOW ? PWINDOW->m_szTitle : "";
- Debug::log(LOG, "Constraint rechecked: %i, %i to %i, %i for %x (window name: %s)", PREGION->extents.x1, PREGION->extents.y1, PREGION->extents.x2, PREGION->extents.y2, pMouse->currentConstraint->surface, PWINDOWNAME.c_str());
+ Debug::log(LOG, "Constraint rechecked: %i, %i to %i, %i for %x (window name: %s)", PREGION->extents.x1, PREGION->extents.y1, PREGION->extents.x2, PREGION->extents.y2,
+ pMouse->currentConstraint->surface, PWINDOWNAME.c_str());
}
void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* constraint) {
@@ -937,7 +944,7 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
if (pMouse->currentConstraint == constraint)
return;
- const auto PWINDOW = g_pCompositor->getWindowFromSurface(constraint->surface);
+ const auto PWINDOW = g_pCompositor->getWindowFromSurface(constraint->surface);
const auto MOUSECOORDS = getMouseCoordsInternal();
pMouse->hyprListener_commitConstraint.removeCallback();
@@ -949,13 +956,13 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
if (constraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) {
if (PWINDOW) {
if (PWINDOW->m_bIsX11) {
- wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
- constraint->current.cursor_hint.x + PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y + PWINDOW->m_vRealPosition.vec().y);
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, constraint->current.cursor_hint.x + PWINDOW->m_uSurface.xwayland->x,
+ PWINDOW->m_uSurface.xwayland->y + PWINDOW->m_vRealPosition.vec().y);
wlr_seat_pointer_warp(constraint->seat, constraint->current.cursor_hint.x, constraint->current.cursor_hint.y);
} else {
- wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
- constraint->current.cursor_hint.x + PWINDOW->m_vRealPosition.vec().x, constraint->current.cursor_hint.y + PWINDOW->m_vRealPosition.vec().y);
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, constraint->current.cursor_hint.x + PWINDOW->m_vRealPosition.vec().x,
+ constraint->current.cursor_hint.y + PWINDOW->m_vRealPosition.vec().y);
wlr_seat_pointer_warp(constraint->seat, constraint->current.cursor_hint.x, constraint->current.cursor_hint.y);
}
@@ -964,7 +971,7 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
const auto PCONSTRAINT = constraintFromWlr(constraint);
if (PCONSTRAINT) { // should never be null but who knows
PCONSTRAINT->positionHint = Vector2D(constraint->current.cursor_hint.x, constraint->current.cursor_hint.y);
- PCONSTRAINT->hintSet = true;
+ PCONSTRAINT->hintSet = true;
}
}
}
@@ -973,7 +980,7 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
}
pMouse->currentConstraint = constraint;
- pMouse->constraintActive = true;
+ pMouse->constraintActive = true;
if (pixman_region32_not_empty(&constraint->current.region)) {
pixman_region32_intersect(&constraint->region, &constraint->surface->input_region, &constraint->current.region);
@@ -1015,9 +1022,9 @@ void Events::listener_commitConstraint(void* owner, void* data) {
if (PMOUSE->currentConstraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) {
const auto PCONSTRAINT = g_pInputManager->constraintFromWlr(PMOUSE->currentConstraint);
- if (PCONSTRAINT) { // should never be null but who knows
+ if (PCONSTRAINT) { // should never be null but who knows
PCONSTRAINT->positionHint = Vector2D(PMOUSE->currentConstraint->current.cursor_hint.x, PMOUSE->currentConstraint->current.cursor_hint.y);
- PCONSTRAINT->hintSet = true;
+ PCONSTRAINT->hintSet = true;
}
}
}
@@ -1053,9 +1060,9 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
}
std::string CInputManager::getActiveLayoutForKeyboard(SKeyboard* pKeyboard) {
- const auto WLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
- const auto KEYMAP = WLRKB->keymap;
- const auto STATE = WLRKB->xkb_state;
+ const auto WLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
+ const auto KEYMAP = WLRKB->keymap;
+ const auto STATE = WLRKB->xkb_state;
const auto LAYOUTSNUM = xkb_keymap_num_layouts(KEYMAP);
for (uint32_t i = 0; i < LAYOUTSNUM; ++i) {
@@ -1082,12 +1089,12 @@ void CInputManager::disableAllKeyboards(bool virt) {
}
void CInputManager::newTouchDevice(wlr_input_device* pDevice) {
- const auto PNEWDEV = &m_lTouchDevices.emplace_back();
+ const auto PNEWDEV = &m_lTouchDevices.emplace_back();
PNEWDEV->pWlrDevice = pDevice;
try {
PNEWDEV->name = getNameForNewDevice(pDevice->name);
- } catch(std::exception& e) {
+ } catch (std::exception& e) {
Debug::log(ERR, "Touch Device had no name???"); // logic error
}
@@ -1096,47 +1103,28 @@ void CInputManager::newTouchDevice(wlr_input_device* pDevice) {
Debug::log(LOG, "New touch device added at %x", PNEWDEV);
- PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) {
- destroyTouchDevice((STouchDevice*)data);
- }, PNEWDEV, "TouchDevice");
+ PNEWDEV->hyprListener_destroy.initCallback(
+ &pDevice->events.destroy, [&](void* owner, void* data) { destroyTouchDevice((STouchDevice*)data); }, PNEWDEV, "TouchDevice");
}
void CInputManager::setTouchDeviceConfigs() {
// The third row is always 0 0 1 and is not expected by `libinput_device_config_calibration_set_matrix`
- static const float MATRICES[8][6] = {
- { // normal
- 1, 0, 0,
- 0, 1, 0
- },
- { // rotation 90°
- 0, -1, 1,
- 1, 0, 0
- },
- { // rotation 180°
- -1, 0, 1,
- 0, -1, 1
- },
- { // rotation 270°
- 0, 1, 0,
- -1, 0, 1
- },
- { // flipped
- -1, 0, 1,
- 0, 1, 0
- },
- { // flipped + rotation 90°
- 0, 1, 0,
- 1, 0, 0
- },
- { // flipped + rotation 180°
- 1, 0, 0,
- 0, -1, 1
- },
- { // flipped + rotation 270°
- 0, -1, 1,
- -1, 0, 1
- }
- };
+ static const float MATRICES[8][6] = {{// normal
+ 1, 0, 0, 0, 1, 0},
+ {// rotation 90°
+ 0, -1, 1, 1, 0, 0},
+ {// rotation 180°
+ -1, 0, 1, 0, -1, 1},
+ {// rotation 270°
+ 0, 1, 0, -1, 0, 1},
+ {// flipped
+ -1, 0, 1, 0, 1, 0},
+ {// flipped + rotation 90°
+ 0, 1, 0, 1, 0, 0},
+ {// flipped + rotation 180°
+ 1, 0, 0, 0, -1, 1},
+ {// flipped + rotation 270°
+ 0, -1, 1, -1, 0, 1}};
for (auto& m : m_lTouchDevices) {
const auto PTOUCHDEV = &m;
@@ -1145,7 +1133,8 @@ void CInputManager::setTouchDeviceConfigs() {
if (wlr_input_device_is_libinput(m.pWlrDevice)) {
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.pWlrDevice);
- const int ROTATION = std::clamp(HASCONFIG ? g_pConfigManager->getDeviceInt(PTOUCHDEV->name, "touch_transform") : g_pConfigManager->getInt("input:touchdevice:transform"), 0, 7);
+ const int ROTATION =
+ std::clamp(HASCONFIG ? g_pConfigManager->getDeviceInt(PTOUCHDEV->name, "touch_transform") : g_pConfigManager->getInt("input:touchdevice:transform"), 0, 7);
libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]);
const auto OUTPUT = HASCONFIG ? g_pConfigManager->getDeviceString(PTOUCHDEV->name, "touch_output") : g_pConfigManager->getString("input:touchdevice:output");
@@ -1164,25 +1153,27 @@ void CInputManager::destroyTouchDevice(STouchDevice* pDevice) {
}
void CInputManager::newSwitch(wlr_input_device* pDevice) {
- const auto PNEWDEV = &m_lSwitches.emplace_back();
+ const auto PNEWDEV = &m_lSwitches.emplace_back();
PNEWDEV->pWlrDevice = pDevice;
Debug::log(LOG, "New switch with name \"%s\" added", pDevice->name);
- PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) {
- destroySwitch((SSwitchDevice*)owner);
- }, PNEWDEV, "SwitchDevice");
+ PNEWDEV->hyprListener_destroy.initCallback(
+ &pDevice->events.destroy, [&](void* owner, void* data) { destroySwitch((SSwitchDevice*)owner); }, PNEWDEV, "SwitchDevice");
const auto PSWITCH = wlr_switch_from_input_device(pDevice);
- PNEWDEV->hyprListener_toggle.initCallback(&PSWITCH->events.toggle, [&](void* owner, void* data) {
- const auto PDEVICE = (SSwitchDevice*)owner;
- const auto NAME = std::string(PDEVICE->pWlrDevice->name);
+ PNEWDEV->hyprListener_toggle.initCallback(
+ &PSWITCH->events.toggle,
+ [&](void* owner, void* data) {
+ const auto PDEVICE = (SSwitchDevice*)owner;
+ const auto NAME = std::string(PDEVICE->pWlrDevice->name);
- Debug::log(LOG, "Switch %s fired, triggering binds.", NAME.c_str());
+ Debug::log(LOG, "Switch %s fired, triggering binds.", NAME.c_str());
- g_pKeybindManager->onSwitchEvent(NAME);
- }, PNEWDEV, "SwitchDevice");
+ g_pKeybindManager->onSwitchEvent(NAME);
+ },
+ PNEWDEV, "SwitchDevice");
}
void CInputManager::destroySwitch(SSwitchDevice* pDevice) {
@@ -1212,24 +1203,30 @@ std::string CInputManager::deviceNameToInternalString(std::string in) {
std::string CInputManager::getNameForNewDevice(std::string internalName) {
auto proposedNewName = deviceNameToInternalString(internalName);
- int dupeno = 0;
+ int dupeno = 0;
- while (std::find_if(m_lKeyboards.begin(), m_lKeyboards.end(), [&] (const SKeyboard& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lKeyboards.end())
+ while (std::find_if(m_lKeyboards.begin(), m_lKeyboards.end(),
+ [&](const SKeyboard& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lKeyboards.end())
dupeno++;
- while (std::find_if(m_lMice.begin(), m_lMice.end(), [&] (const SMouse& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lMice.end())
+ while (std::find_if(m_lMice.begin(), m_lMice.end(), [&](const SMouse& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) !=
+ m_lMice.end())
dupeno++;
- while (std::find_if(m_lTouchDevices.begin(), m_lTouchDevices.end(), [&] (const STouchDevice& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTouchDevices.end())
+ while (std::find_if(m_lTouchDevices.begin(), m_lTouchDevices.end(),
+ [&](const STouchDevice& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTouchDevices.end())
dupeno++;
- while (std::find_if(m_lTabletPads.begin(), m_lTabletPads.end(), [&] (const STabletPad& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTabletPads.end())
+ while (std::find_if(m_lTabletPads.begin(), m_lTabletPads.end(),
+ [&](const STabletPad& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTabletPads.end())
dupeno++;
- while (std::find_if(m_lTablets.begin(), m_lTablets.end(), [&] (const STablet& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTablets.end())
+ while (std::find_if(m_lTablets.begin(), m_lTablets.end(),
+ [&](const STablet& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTablets.end())
dupeno++;
- while (std::find_if(m_lTabletTools.begin(), m_lTabletTools.end(), [&] (const STabletTool& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTabletTools.end())
+ while (std::find_if(m_lTabletTools.begin(), m_lTabletTools.end(),
+ [&](const STabletTool& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTabletTools.end())
dupeno++;
return proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno)));
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 5645f163..460b5ac2 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -7,89 +7,90 @@
#include "../../helpers/Timer.hpp"
#include "InputMethodRelay.hpp"
-enum eClickBehaviorMode {
+enum eClickBehaviorMode
+{
CLICKMODE_DEFAULT = 0,
CLICKMODE_KILL
};
-enum eMouseBindMode {
+enum eMouseBindMode
+{
MBIND_INVALID = -1,
- MBIND_MOVE = 0,
+ MBIND_MOVE = 0,
MBIND_RESIZE
};
struct STouchData {
- CWindow* touchFocusWindow = nullptr;
- SLayerSurface* touchFocusLS = nullptr;
- wlr_surface* touchFocusSurface = nullptr;
- Vector2D touchSurfaceOrigin;
+ CWindow* touchFocusWindow = nullptr;
+ SLayerSurface* touchFocusLS = nullptr;
+ wlr_surface* touchFocusSurface = nullptr;
+ Vector2D touchSurfaceOrigin;
};
class CKeybindManager;
class CInputManager {
-public:
-
- void onMouseMoved(wlr_pointer_motion_event*);
- void onMouseWarp(wlr_pointer_motion_absolute_event*);
- void onMouseButton(wlr_pointer_button_event*);
- void onMouseWheel(wlr_pointer_axis_event*);
- void onKeyboardKey(wlr_keyboard_key_event*, SKeyboard*);
- void onKeyboardMod(void*, SKeyboard*);
-
- void newKeyboard(wlr_input_device*);
- void newVirtualKeyboard(wlr_input_device*);
- void newMouse(wlr_input_device*, bool virt = false);
- void newTouchDevice(wlr_input_device*);
- void newSwitch(wlr_input_device*);
- void destroyTouchDevice(STouchDevice*);
- void destroyKeyboard(SKeyboard*);
- void destroyMouse(wlr_input_device*);
- void destroySwitch(SSwitchDevice*);
-
- void constrainMouse(SMouse*, wlr_pointer_constraint_v1*);
- void recheckConstraint(SMouse*);
- void unconstrainMouse();
- SConstraint* constraintFromWlr(wlr_pointer_constraint_v1*);
- std::string getActiveLayoutForKeyboard(SKeyboard*);
-
- Vector2D getMouseCoordsInternal();
- void refocus();
-
- void setKeyboardLayout();
- void setPointerConfigs();
- void setTouchDeviceConfigs();
-
- void updateDragIcon();
- void updateCapabilities();
-
- void setClickMode(eClickBehaviorMode);
+ public:
+ void onMouseMoved(wlr_pointer_motion_event*);
+ void onMouseWarp(wlr_pointer_motion_absolute_event*);
+ void onMouseButton(wlr_pointer_button_event*);
+ void onMouseWheel(wlr_pointer_axis_event*);
+ void onKeyboardKey(wlr_keyboard_key_event*, SKeyboard*);
+ void onKeyboardMod(void*, SKeyboard*);
+
+ void newKeyboard(wlr_input_device*);
+ void newVirtualKeyboard(wlr_input_device*);
+ void newMouse(wlr_input_device*, bool virt = false);
+ void newTouchDevice(wlr_input_device*);
+ void newSwitch(wlr_input_device*);
+ void destroyTouchDevice(STouchDevice*);
+ void destroyKeyboard(SKeyboard*);
+ void destroyMouse(wlr_input_device*);
+ void destroySwitch(SSwitchDevice*);
+
+ void constrainMouse(SMouse*, wlr_pointer_constraint_v1*);
+ void recheckConstraint(SMouse*);
+ void unconstrainMouse();
+ SConstraint* constraintFromWlr(wlr_pointer_constraint_v1*);
+ std::string getActiveLayoutForKeyboard(SKeyboard*);
+
+ Vector2D getMouseCoordsInternal();
+ void refocus();
+
+ void setKeyboardLayout();
+ void setPointerConfigs();
+ void setTouchDeviceConfigs();
+
+ void updateDragIcon();
+ void updateCapabilities();
+
+ void setClickMode(eClickBehaviorMode);
eClickBehaviorMode getClickMode();
- void processMouseRequest(wlr_seat_pointer_request_set_cursor_event*);
+ void processMouseRequest(wlr_seat_pointer_request_set_cursor_event*);
- void onTouchDown(wlr_touch_down_event*);
- void onTouchUp(wlr_touch_up_event*);
- void onTouchMove(wlr_touch_motion_event*);
+ void onTouchDown(wlr_touch_down_event*);
+ void onTouchUp(wlr_touch_up_event*);
+ void onTouchMove(wlr_touch_motion_event*);
- void onPointerHoldBegin(wlr_pointer_hold_begin_event*);
- void onPointerHoldEnd(wlr_pointer_hold_end_event*);
+ void onPointerHoldBegin(wlr_pointer_hold_begin_event*);
+ void onPointerHoldEnd(wlr_pointer_hold_end_event*);
- STouchData m_sTouchData;
+ STouchData m_sTouchData;
// for dragging floating windows
- CWindow* currentlyDraggedWindow = nullptr;
- eMouseBindMode dragMode = MBIND_INVALID;
+ CWindow* currentlyDraggedWindow = nullptr;
+ eMouseBindMode dragMode = MBIND_INVALID;
- SDrag m_sDrag;
+ SDrag m_sDrag;
- std::list<SConstraint> m_lConstraints;
- std::list<SKeyboard> m_lKeyboards;
- std::list<SMouse> m_lMice;
+ std::list<SConstraint> m_lConstraints;
+ std::list<SKeyboard> m_lKeyboards;
+ std::list<SMouse> m_lMice;
// tablets
- std::list<STablet> m_lTablets;
- std::list<STabletTool> m_lTabletTools;
- std::list<STabletPad> m_lTabletPads;
+ std::list<STablet> m_lTablets;
+ std::list<STabletTool> m_lTabletTools;
+ std::list<STabletPad> m_lTabletPads;
// idle inhibitors
std::list<SIdleInhibitor> m_lIdleInhibitors;
@@ -100,73 +101,72 @@ public:
// Switches
std::list<SSwitchDevice> m_lSwitches;
- 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 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*);
+ void onSwipeBegin(wlr_pointer_swipe_begin_event*);
+ void onSwipeEnd(wlr_pointer_swipe_end_event*);
+ void onSwipeUpdate(wlr_pointer_swipe_update_event*);
- SSwipeGesture m_sActiveSwipe;
+ SSwipeGesture m_sActiveSwipe;
- SKeyboard* m_pActiveKeyboard = nullptr;
+ SKeyboard* m_pActiveKeyboard = nullptr;
- CTimer m_tmrLastCursorMovement;
+ CTimer m_tmrLastCursorMovement;
- CInputMethodRelay m_sIMERelay;
+ CInputMethodRelay m_sIMERelay;
- void updateKeyboardsLeds(wlr_input_device* pKeyboard);
+ void updateKeyboardsLeds(wlr_input_device* pKeyboard);
// for shared mods
- uint32_t accumulateModsFromAllKBs();
+ uint32_t accumulateModsFromAllKBs();
- CWindow* m_pFollowOnDnDBegin = nullptr;
+ CWindow* m_pFollowOnDnDBegin = nullptr;
// for virtual keyboards: whether we should respect them as normal ones
- bool shouldIgnoreVirtualKeyboard(SKeyboard*);
+ bool shouldIgnoreVirtualKeyboard(SKeyboard*);
// for special cursors that we choose
- void setCursorImageUntilUnset(std::string);
- void unsetCursorImage();
+ void setCursorImageUntilUnset(std::string);
+ void unsetCursorImage();
- std::string deviceNameToInternalString(std::string);
- std::string getNameForNewDevice(std::string);
+ std::string deviceNameToInternalString(std::string);
+ std::string getNameForNewDevice(std::string);
-private:
-
- bool m_bCursorImageOverriden = false;
+ private:
+ bool m_bCursorImageOverriden = false;
// for click behavior override
- eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT;
- bool m_bEmptyFocusCursorSet = false;
- Vector2D m_vLastCursorPosFloored = Vector2D();
+ eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT;
+ bool m_bEmptyFocusCursorSet = false;
+ Vector2D m_vLastCursorPosFloored = Vector2D();
// for some bugs in follow mouse 0
- bool m_bLastFocusOnLS = false;
+ bool m_bLastFocusOnLS = false;
- void processMouseDownNormal(wlr_pointer_button_event* e);
- void processMouseDownKill(wlr_pointer_button_event* e);
+ void processMouseDownNormal(wlr_pointer_button_event* e);
+ void processMouseDownKill(wlr_pointer_button_event* e);
- void disableAllKeyboards(bool virt = false);
+ void disableAllKeyboards(bool virt = false);
- uint32_t m_uiCapabilities = 0;
+ uint32_t m_uiCapabilities = 0;
- void mouseMoveUnified(uint32_t, bool refocus = false);
+ void mouseMoveUnified(uint32_t, bool refocus = false);
- STabletTool* ensureTabletToolPresent(wlr_tablet_tool*);
+ STabletTool* ensureTabletToolPresent(wlr_tablet_tool*);
- void applyConfigToKeyboard(SKeyboard*);
+ void applyConfigToKeyboard(SKeyboard*);
// this will be set after a refocus()
- wlr_surface* m_pFoundSurfaceToFocus = nullptr;
- SLayerSurface* m_pFoundLSToFocus = nullptr;
- CWindow* m_pFoundWindowToFocus = nullptr;
+ wlr_surface* m_pFoundSurfaceToFocus = nullptr;
+ SLayerSurface* m_pFoundLSToFocus = nullptr;
+ CWindow* m_pFoundWindowToFocus = nullptr;
// swipe
- void beginWorkspaceSwipe();
+ void beginWorkspaceSwipe();
friend class CKeybindManager;
};
diff --git a/src/managers/input/InputMethodRelay.cpp b/src/managers/input/InputMethodRelay.cpp
index d49623db..93c7040b 100644
--- a/src/managers/input/InputMethodRelay.cpp
+++ b/src/managers/input/InputMethodRelay.cpp
@@ -2,7 +2,7 @@
#include "InputManager.hpp"
#include "../../Compositor.hpp"
-CInputMethodRelay::CInputMethodRelay() { }
+CInputMethodRelay::CInputMethodRelay() {}
void CInputMethodRelay::onNewIME(wlr_input_method_v2* pIME) {
if (m_pWLRIME) {
@@ -15,101 +15,107 @@ void CInputMethodRelay::onNewIME(wlr_input_method_v2* pIME) {
m_pWLRIME = pIME;
- hyprListener_IMECommit.initCallback(&m_pWLRIME->events.commit, [&](void* owner, void* data) {
+ hyprListener_IMECommit.initCallback(
+ &m_pWLRIME->events.commit,
+ [&](void* owner, void* data) {
+ const auto PTI = getFocusedTextInput();
+ const auto PIMR = (CInputMethodRelay*)owner;
- const auto PTI = getFocusedTextInput();
- const auto PIMR = (CInputMethodRelay*)owner;
-
- if (!PTI) {
- Debug::log(LOG, "No focused TextInput on IME Commit");
- return;
- }
-
- if (PIMR->m_pWLRIME->current.preedit.text) {
- wlr_text_input_v3_send_preedit_string(PTI->pWlrInput, PIMR->m_pWLRIME->current.preedit.text, PIMR->m_pWLRIME->current.preedit.cursor_begin, PIMR->m_pWLRIME->current.preedit.cursor_end);
- }
-
- if (PIMR->m_pWLRIME->current.commit_text) {
- wlr_text_input_v3_send_commit_string(PTI->pWlrInput, PIMR->m_pWLRIME->current.commit_text);
- }
-
- if (PIMR->m_pWLRIME->current.delete_.before_length || PIMR->m_pWLRIME->current.delete_.after_length) {
- wlr_text_input_v3_send_delete_surrounding_text(PTI->pWlrInput, PIMR->m_pWLRIME->current.delete_.before_length, PIMR->m_pWLRIME->current.delete_.after_length);
- }
-
- wlr_text_input_v3_send_done(PTI->pWlrInput);
-
- }, this, "IMERelay");
-
- hyprListener_IMEDestroy.initCallback(&m_pWLRIME->events.destroy, [&](void* owner, void* data) {
-
- m_pWLRIME = nullptr;
-
- hyprListener_IMEDestroy.removeCallback();
- hyprListener_IMECommit.removeCallback();
- hyprListener_IMEGrab.removeCallback();
- hyprListener_IMENewPopup.removeCallback();
-
- m_pKeyboardGrab.reset(nullptr);
+ if (!PTI) {
+ Debug::log(LOG, "No focused TextInput on IME Commit");
+ return;
+ }
- const auto PTI = getFocusedTextInput();
+ if (PIMR->m_pWLRIME->current.preedit.text) {
+ wlr_text_input_v3_send_preedit_string(PTI->pWlrInput, PIMR->m_pWLRIME->current.preedit.text, PIMR->m_pWLRIME->current.preedit.cursor_begin,
+ PIMR->m_pWLRIME->current.preedit.cursor_end);
+ }
- Debug::log(LOG, "IME Destroy");
+ if (PIMR->m_pWLRIME->current.commit_text) {
+ wlr_text_input_v3_send_commit_string(PTI->pWlrInput, PIMR->m_pWLRIME->current.commit_text);
+ }
- if (PTI) {
- setPendingSurface(PTI, PTI->pWlrInput->focused_surface);
+ if (PIMR->m_pWLRIME->current.delete_.before_length || PIMR->m_pWLRIME->current.delete_.after_length) {
+ wlr_text_input_v3_send_delete_surrounding_text(PTI->pWlrInput, PIMR->m_pWLRIME->current.delete_.before_length, PIMR->m_pWLRIME->current.delete_.after_length);
+ }
- wlr_text_input_v3_send_leave(PTI->pWlrInput);
- }
+ wlr_text_input_v3_send_done(PTI->pWlrInput);
+ },
+ this, "IMERelay");
- }, this, "IMERelay");
+ hyprListener_IMEDestroy.initCallback(
+ &m_pWLRIME->events.destroy,
+ [&](void* owner, void* data) {
+ m_pWLRIME = nullptr;
- hyprListener_IMEGrab.initCallback(&m_pWLRIME->events.grab_keyboard, [&](void* owner, void* data) {
+ hyprListener_IMEDestroy.removeCallback();
+ hyprListener_IMECommit.removeCallback();
+ hyprListener_IMEGrab.removeCallback();
+ hyprListener_IMENewPopup.removeCallback();
- Debug::log(LOG, "IME TextInput Keyboard Grab new");
+ m_pKeyboardGrab.reset(nullptr);
- m_pKeyboardGrab.reset(nullptr);
+ const auto PTI = getFocusedTextInput();
- m_pKeyboardGrab = std::make_unique<SIMEKbGrab>();
+ Debug::log(LOG, "IME Destroy");
- m_pKeyboardGrab->pKeyboard = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
+ if (PTI) {
+ setPendingSurface(PTI, PTI->pWlrInput->focused_surface);
- const auto PKBGRAB = (wlr_input_method_keyboard_grab_v2*)data;
+ wlr_text_input_v3_send_leave(PTI->pWlrInput);
+ }
+ },
+ this, "IMERelay");
- m_pKeyboardGrab->pWlrKbGrab = PKBGRAB;
+ hyprListener_IMEGrab.initCallback(
+ &m_pWLRIME->events.grab_keyboard,
+ [&](void* owner, void* data) {
+ Debug::log(LOG, "IME TextInput Keyboard Grab new");
- wlr_input_method_keyboard_grab_v2_set_keyboard(m_pKeyboardGrab->pWlrKbGrab, m_pKeyboardGrab->pKeyboard);
+ m_pKeyboardGrab.reset(nullptr);
- m_pKeyboardGrab->hyprListener_grabDestroy.initCallback(&PKBGRAB->events.destroy, [&](void* owner, void* data) {
+ m_pKeyboardGrab = std::make_unique<SIMEKbGrab>();
- m_pKeyboardGrab->hyprListener_grabDestroy.removeCallback();
+ m_pKeyboardGrab->pKeyboard = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
- Debug::log(LOG, "IME TextInput Keyboard Grab destroy");
+ const auto PKBGRAB = (wlr_input_method_keyboard_grab_v2*)data;
- if (m_pKeyboardGrab->pKeyboard) {
- wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &m_pKeyboardGrab->pKeyboard->modifiers);
- }
+ m_pKeyboardGrab->pWlrKbGrab = PKBGRAB;
- m_pKeyboardGrab.reset(nullptr);
+ wlr_input_method_keyboard_grab_v2_set_keyboard(m_pKeyboardGrab->pWlrKbGrab, m_pKeyboardGrab->pKeyboard);
- }, m_pKeyboardGrab.get(), "IME Keyboard Grab");
+ m_pKeyboardGrab->hyprListener_grabDestroy.initCallback(
+ &PKBGRAB->events.destroy,
+ [&](void* owner, void* data) {
+ m_pKeyboardGrab->hyprListener_grabDestroy.removeCallback();
- }, this, "IMERelay");
+ Debug::log(LOG, "IME TextInput Keyboard Grab destroy");
- hyprListener_IMENewPopup.initCallback(&m_pWLRIME->events.new_popup_surface, [&](void* owner, void* data) {
+ if (m_pKeyboardGrab->pKeyboard) {
+ wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &m_pKeyboardGrab->pKeyboard->modifiers);
+ }
- const auto PNEWPOPUP = &m_lIMEPopups.emplace_back();
+ m_pKeyboardGrab.reset(nullptr);
+ },
+ m_pKeyboardGrab.get(), "IME Keyboard Grab");
+ },
+ this, "IMERelay");
- PNEWPOPUP->pSurface = (wlr_input_popup_surface_v2*)data;
+ hyprListener_IMENewPopup.initCallback(
+ &m_pWLRIME->events.new_popup_surface,
+ [&](void* owner, void* data) {
+ const auto PNEWPOPUP = &m_lIMEPopups.emplace_back();
- PNEWPOPUP->hyprListener_commitPopup.initCallback(&PNEWPOPUP->pSurface->surface->events.commit, &Events::listener_commitInputPopup, PNEWPOPUP, "IME Popup");
- PNEWPOPUP->hyprListener_mapPopup.initCallback(&PNEWPOPUP->pSurface->events.map, &Events::listener_mapInputPopup, PNEWPOPUP, "IME Popup");
- PNEWPOPUP->hyprListener_unmapPopup.initCallback(&PNEWPOPUP->pSurface->events.unmap, &Events::listener_unmapInputPopup, PNEWPOPUP, "IME Popup");
- PNEWPOPUP->hyprListener_destroyPopup.initCallback(&PNEWPOPUP->pSurface->events.destroy, &Events::listener_destroyInputPopup, PNEWPOPUP, "IME Popup");
+ PNEWPOPUP->pSurface = (wlr_input_popup_surface_v2*)data;
- Debug::log(LOG, "New input popup");
+ PNEWPOPUP->hyprListener_commitPopup.initCallback(&PNEWPOPUP->pSurface->surface->events.commit, &Events::listener_commitInputPopup, PNEWPOPUP, "IME Popup");
+ PNEWPOPUP->hyprListener_mapPopup.initCallback(&PNEWPOPUP->pSurface->events.map, &Events::listener_mapInputPopup, PNEWPOPUP, "IME Popup");
+ PNEWPOPUP->hyprListener_unmapPopup.initCallback(&PNEWPOPUP->pSurface->events.unmap, &Events::listener_unmapInputPopup, PNEWPOPUP, "IME Popup");
+ PNEWPOPUP->hyprListener_destroyPopup.initCallback(&PNEWPOPUP->pSurface->events.destroy, &Events::listener_destroyInputPopup, PNEWPOPUP, "IME Popup");
- }, this, "IMERelay");
+ Debug::log(LOG, "New input popup");
+ },
+ this, "IMERelay");
const auto PTI = getFocusableTextInput();
@@ -131,25 +137,25 @@ void CInputMethodRelay::updateInputPopup(SIMEPopup* pPopup) {
if (!PFOCUSEDTI || !PFOCUSEDTI->pWlrInput->focused_surface)
return;
- bool cursorRect = PFOCUSEDTI->pWlrInput->current.features & WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE;
+ bool cursorRect = PFOCUSEDTI->pWlrInput->current.features & WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE;
const auto PFOCUSEDSURFACE = PFOCUSEDTI->pWlrInput->focused_surface;
- auto cursorBox = PFOCUSEDTI->pWlrInput->current.cursor_rectangle;
+ auto cursorBox = PFOCUSEDTI->pWlrInput->current.cursor_rectangle;
- Vector2D parentPos;
- Vector2D parentSize;
+ Vector2D parentPos;
+ Vector2D parentSize;
if (wlr_surface_is_layer_surface(PFOCUSEDSURFACE)) {
const auto PLS = g_pCompositor->getLayerSurfaceFromWlr(wlr_layer_surface_v1_from_wlr_surface(PFOCUSEDSURFACE));
if (PLS) {
- parentPos = Vector2D(PLS->geometry.x, PLS->geometry.y) + g_pCompositor->getMonitorFromID(PLS->monitorID)->vecPosition;
+ parentPos = Vector2D(PLS->geometry.x, PLS->geometry.y) + g_pCompositor->getMonitorFromID(PLS->monitorID)->vecPosition;
parentSize = Vector2D(PLS->geometry.width, PLS->geometry.height);
}
} else {
const auto PWINDOW = g_pCompositor->getWindowFromSurface(PFOCUSEDSURFACE);
if (PWINDOW) {
- parentPos = PWINDOW->m_vRealPosition.goalv();
+ parentPos = PWINDOW->m_vRealPosition.goalv();
parentSize = PWINDOW->m_vRealSize.goalv();
}
}
@@ -230,7 +236,7 @@ void CInputMethodRelay::damagePopup(SIMEPopup* pPopup) {
if (!PFOCUSEDTI || !PFOCUSEDTI->pWlrInput->focused_surface)
return;
- Vector2D parentPos;
+ Vector2D parentPos;
const auto PFOCUSEDSURFACE = PFOCUSEDTI->pWlrInput->focused_surface;
@@ -296,82 +302,86 @@ void CInputMethodRelay::createNewTextInput(wlr_text_input_v3* pInput) {
PTEXTINPUT->pWlrInput = pInput;
- PTEXTINPUT->hyprListener_textInputEnable.initCallback(&pInput->events.enable, [](void* owner, void* data) {
-
- const auto PINPUT = (STextInput*)owner;
-
- if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
- // Debug::log(WARN, "Enabling TextInput on no IME!");
- return;
- }
-
- Debug::log(LOG, "Enable TextInput");
-
- wlr_input_method_v2_send_activate(g_pInputManager->m_sIMERelay.m_pWLRIME);
- g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
-
- }, PTEXTINPUT, "textInput");
-
- PTEXTINPUT->hyprListener_textInputCommit.initCallback(&pInput->events.commit, [](void* owner, void* data) {
-
- const auto PINPUT = (STextInput*)owner;
-
- if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
- // Debug::log(WARN, "Committing TextInput on no IME!");
- return;
- }
+ PTEXTINPUT->hyprListener_textInputEnable.initCallback(
+ &pInput->events.enable,
+ [](void* owner, void* data) {
+ const auto PINPUT = (STextInput*)owner;
- if (!PINPUT->pWlrInput->current_enabled) {
- Debug::log(WARN, "Disabled TextInput commit?");
- return;
- }
+ if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
+ // Debug::log(WARN, "Enabling TextInput on no IME!");
+ return;
+ }
- g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ Debug::log(LOG, "Enable TextInput");
- }, PTEXTINPUT, "textInput");
+ wlr_input_method_v2_send_activate(g_pInputManager->m_sIMERelay.m_pWLRIME);
+ g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ },
+ PTEXTINPUT, "textInput");
- PTEXTINPUT->hyprListener_textInputDisable.initCallback(&pInput->events.disable, [](void* owner, void* data) {
+ PTEXTINPUT->hyprListener_textInputCommit.initCallback(
+ &pInput->events.commit,
+ [](void* owner, void* data) {
+ const auto PINPUT = (STextInput*)owner;
- const auto PINPUT = (STextInput*)owner;
+ if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
+ // Debug::log(WARN, "Committing TextInput on no IME!");
+ return;
+ }
- if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
- // Debug::log(WARN, "Disabling TextInput on no IME!");
- return;
- }
+ if (!PINPUT->pWlrInput->current_enabled) {
+ Debug::log(WARN, "Disabled TextInput commit?");
+ return;
+ }
- Debug::log(LOG, "Disable TextInput");
+ g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ },
+ PTEXTINPUT, "textInput");
- wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
+ PTEXTINPUT->hyprListener_textInputDisable.initCallback(
+ &pInput->events.disable,
+ [](void* owner, void* data) {
+ const auto PINPUT = (STextInput*)owner;
- g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
+ // Debug::log(WARN, "Disabling TextInput on no IME!");
+ return;
+ }
- }, PTEXTINPUT, "textInput");
+ Debug::log(LOG, "Disable TextInput");
- PTEXTINPUT->hyprListener_textInputDestroy.initCallback(&pInput->events.destroy, [](void* owner, void* data) {
+ wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
- const auto PINPUT = (STextInput*)owner;
+ g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ },
+ PTEXTINPUT, "textInput");
- if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
- // Debug::log(WARN, "Disabling TextInput on no IME!");
- return;
- }
+ PTEXTINPUT->hyprListener_textInputDestroy.initCallback(
+ &pInput->events.destroy,
+ [](void* owner, void* data) {
+ const auto PINPUT = (STextInput*)owner;
- if (PINPUT->pWlrInput->current_enabled) {
- wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
+ if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
+ // Debug::log(WARN, "Disabling TextInput on no IME!");
+ return;
+ }
- g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
- }
+ if (PINPUT->pWlrInput->current_enabled) {
+ wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
- g_pInputManager->m_sIMERelay.setPendingSurface(PINPUT, nullptr);
+ g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ }
- PINPUT->hyprListener_textInputCommit.removeCallback();
- PINPUT->hyprListener_textInputDestroy.removeCallback();
- PINPUT->hyprListener_textInputDisable.removeCallback();
- PINPUT->hyprListener_textInputEnable.removeCallback();
+ g_pInputManager->m_sIMERelay.setPendingSurface(PINPUT, nullptr);
- g_pInputManager->m_sIMERelay.removeTextInput(PINPUT->pWlrInput);
+ PINPUT->hyprListener_textInputCommit.removeCallback();
+ PINPUT->hyprListener_textInputDestroy.removeCallback();
+ PINPUT->hyprListener_textInputDisable.removeCallback();
+ PINPUT->hyprListener_textInputEnable.removeCallback();
- }, PTEXTINPUT, "textInput");
+ g_pInputManager->m_sIMERelay.removeTextInput(PINPUT->pWlrInput);
+ },
+ PTEXTINPUT, "textInput");
}
void CInputMethodRelay::removeTextInput(wlr_text_input_v3* pInput) {
@@ -417,7 +427,6 @@ void CInputMethodRelay::onKeyboardFocus(wlr_surface* pSurface) {
} else {
continue;
}
-
}
if (pSurface && wl_resource_get_client(ti.pWlrInput->resource) == wl_resource_get_client(pSurface->resource)) {
@@ -427,7 +436,6 @@ void CInputMethodRelay::onKeyboardFocus(wlr_surface* pSurface) {
} else {
setPendingSurface(&ti, pSurface);
}
-
}
}
}
@@ -436,13 +444,16 @@ void CInputMethodRelay::setPendingSurface(STextInput* pInput, wlr_surface* pSurf
pInput->pPendingSurface = pSurface;
if (pSurface) {
- pInput->hyprListener_pendingSurfaceDestroy.initCallback(&pSurface->events.destroy, [](void* owner, void* data) {
- const auto PINPUT = (STextInput*)owner;
+ pInput->hyprListener_pendingSurfaceDestroy.initCallback(
+ &pSurface->events.destroy,
+ [](void* owner, void* data) {
+ const auto PINPUT = (STextInput*)owner;
- PINPUT->pPendingSurface = nullptr;
+ PINPUT->pPendingSurface = nullptr;
- PINPUT->hyprListener_pendingSurfaceDestroy.removeCallback();
- }, pInput, "TextInput");
+ PINPUT->hyprListener_pendingSurfaceDestroy.removeCallback();
+ },
+ pInput, "TextInput");
} else {
pInput->hyprListener_pendingSurfaceDestroy.removeCallback();
}
diff --git a/src/managers/input/InputMethodRelay.hpp b/src/managers/input/InputMethodRelay.hpp
index 5f4e9752..76746487 100644
--- a/src/managers/input/InputMethodRelay.hpp
+++ b/src/managers/input/InputMethodRelay.hpp
@@ -6,37 +6,36 @@
class CInputManager;
class CInputMethodRelay {
-public:
+ public:
CInputMethodRelay();
- void onNewIME(wlr_input_method_v2*);
- void onNewTextInput(wlr_text_input_v3*);
+ void onNewIME(wlr_input_method_v2*);
+ void onNewTextInput(wlr_text_input_v3*);
wlr_input_method_v2* m_pWLRIME = nullptr;
- void commitIMEState(wlr_text_input_v3*);
- void removeTextInput(wlr_text_input_v3*);
+ void commitIMEState(wlr_text_input_v3*);
+ void removeTextInput(wlr_text_input_v3*);
- void onKeyboardFocus(wlr_surface*);
+ void onKeyboardFocus(wlr_surface*);
- STextInput* getFocusedTextInput();
- STextInput* getFocusableTextInput();
+ STextInput* getFocusedTextInput();
+ STextInput* getFocusableTextInput();
- void setPendingSurface(STextInput*, wlr_surface*);
+ void setPendingSurface(STextInput*, wlr_surface*);
- SIMEKbGrab* getIMEKeyboardGrab(SKeyboard*);
+ SIMEKbGrab* getIMEKeyboardGrab(SKeyboard*);
- void setIMEPopupFocus(SIMEPopup*, wlr_surface*);
- void updateInputPopup(SIMEPopup*);
- void damagePopup(SIMEPopup*);
- void removePopup(SIMEPopup*);
-
-private:
+ void setIMEPopupFocus(SIMEPopup*, wlr_surface*);
+ void updateInputPopup(SIMEPopup*);
+ void damagePopup(SIMEPopup*);
+ void removePopup(SIMEPopup*);
+ private:
std::unique_ptr<SIMEKbGrab> m_pKeyboardGrab;
- std::list<STextInput> m_lTextInputs;
- std::list<SIMEPopup> m_lIMEPopups;
+ std::list<STextInput> m_lTextInputs;
+ std::list<SIMEPopup> m_lIMEPopups;
DYNLISTENER(textInputNew);
DYNLISTENER(IMECommit);
@@ -44,7 +43,7 @@ private:
DYNLISTENER(IMEGrab);
DYNLISTENER(IMENewPopup);
- void createNewTextInput(wlr_text_input_v3*);
+ void createNewTextInput(wlr_text_input_v3*);
friend class CHyprRenderer;
friend class CInputManager;
diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp
index ab85a988..f2a31172 100644
--- a/src/managers/input/Swipe.cpp
+++ b/src/managers/input/Swipe.cpp
@@ -2,9 +2,9 @@
#include "../../Compositor.hpp"
void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) {
- static auto *const PSWIPE = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe")->intValue;
- static auto *const PSWIPEFINGERS = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_fingers")->intValue;
- static auto *const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
+ static auto* const PSWIPE = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe")->intValue;
+ static auto* const PSWIPEFINGERS = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_fingers")->intValue;
+ static auto* const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
if (e->fingers != *PSWIPEFINGERS || *PSWIPE == 0)
return;
@@ -28,10 +28,10 @@ void CInputManager::beginWorkspaceSwipe() {
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;
+ m_sActiveSwipe.delta = 0;
+ m_sActiveSwipe.pMonitor = g_pCompositor->m_pLastMonitor;
+ m_sActiveSwipe.avgSpeed = 0;
+ m_sActiveSwipe.speedPoints = 0;
if (PWORKSPACE->m_bHasFullscreenWindow) {
for (auto& ls : g_pCompositor->m_pLastMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
@@ -44,35 +44,37 @@ 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;
- static auto *const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
- const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
+ 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;
+ static auto* const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
+ const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
// commit
- std::string wsname = "";
- auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
- auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
+ std::string wsname = "";
+ auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
+ auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
- if ((workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_iID || (workspaceIDRight == workspaceIDLeft && workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID)) && *PSWIPENEW) {
+ if ((workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_iID || (workspaceIDRight == workspaceIDLeft && workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID)) &&
+ *PSWIPENEW) {
workspaceIDRight = m_sActiveSwipe.pWorkspaceBegin->m_iID > 0 ? m_sActiveSwipe.pWorkspaceBegin->m_iID + 1 : 1;
}
- auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); // not guaranteed if PSWIPENEW
- const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
+ auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); // not guaranteed if PSWIPENEW
+ const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
- const auto RENDEROFFSETMIDDLE = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.vec();
+ const auto RENDEROFFSETMIDDLE = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.vec();
CWorkspace* pSwitchedTo = nullptr;
- if ((abs(m_sActiveSwipe.delta) < *PSWIPEDIST * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) || abs(m_sActiveSwipe.delta) < 2) {
+ if ((abs(m_sActiveSwipe.delta) < *PSWIPEDIST * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) ||
+ abs(m_sActiveSwipe.delta) < 2) {
// revert
if (abs(m_sActiveSwipe.delta) < 2) {
- PWORKSPACEL->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
+ PWORKSPACEL->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
if (PWORKSPACER)
- PWORKSPACER->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
- m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
+ PWORKSPACER->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
+ m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
} else {
if (m_sActiveSwipe.delta < 0) {
// to left
@@ -163,21 +165,21 @@ 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;
- static auto *const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
- static auto *const PSWIPEFOREVER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_forever")->intValue;
+ static auto* const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue;
+ static auto* const PSWIPEINVR = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_invert")->intValue;
+ static auto* const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
+ static auto* const PSWIPEFOREVER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_forever")->intValue;
- const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
+ const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
m_sActiveSwipe.delta += VERTANIMS ? (*PSWIPEINVR ? -e->dy : e->dy) : (*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);
+ 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) && !*PSWIPENEW) {
m_sActiveSwipe.pWorkspaceBegin = nullptr; // invalidate the swipe
@@ -189,7 +191,8 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
m_sActiveSwipe.delta = std::clamp(m_sActiveSwipe.delta, (double)-*PSWIPEDIST, (double)*PSWIPEDIST);
if ((m_sActiveSwipe.pWorkspaceBegin->m_iID == workspaceIDLeft && *PSWIPENEW && (m_sActiveSwipe.delta < 0)) ||
- (m_sActiveSwipe.delta > 0 && g_pCompositor->getWindowsOnWorkspace(m_sActiveSwipe.pWorkspaceBegin->m_iID) == 0 && workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_iID) ||
+ (m_sActiveSwipe.delta > 0 && g_pCompositor->getWindowsOnWorkspace(m_sActiveSwipe.pWorkspaceBegin->m_iID) == 0 &&
+ workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_iID) ||
(m_sActiveSwipe.delta < 0 && m_sActiveSwipe.pWorkspaceBegin->m_iID <= workspaceIDLeft)) {
m_sActiveSwipe.delta = 0;
@@ -197,7 +200,7 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
}
if (m_sActiveSwipe.delta < 0) {
- if (workspaceIDLeft > m_sActiveSwipe.pWorkspaceBegin->m_iID && !*PSWIPENEW){
+ if (workspaceIDLeft > m_sActiveSwipe.pWorkspaceBegin->m_iID && !*PSWIPENEW) {
m_sActiveSwipe.delta = 0;
return;
}
@@ -215,10 +218,12 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
}
if (VERTANIMS) {
- PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y - m_sActiveSwipe.pMonitor->vecSize.y));
+ PWORKSPACE->m_vRenderOffset.setValueAndWarp(
+ Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y - m_sActiveSwipe.pMonitor->vecSize.y));
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y));
} else {
- PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x - m_sActiveSwipe.pMonitor->vecSize.x, 0));
+ 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));
}
@@ -253,10 +258,12 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
}
if (VERTANIMS) {
- PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y + m_sActiveSwipe.pMonitor->vecSize.y));
+ PWORKSPACE->m_vRenderOffset.setValueAndWarp(
+ Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y + m_sActiveSwipe.pMonitor->vecSize.y));
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y));
} else {
- PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x + m_sActiveSwipe.pMonitor->vecSize.x, 0));
+ 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));
}
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp
index eef466ec..00cedb09 100644
--- a/src/managers/input/Tablets.cpp
+++ b/src/managers/input/Tablets.cpp
@@ -7,127 +7,136 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
try {
PNEWTABLET->name = deviceNameToInternalString(pDevice->name);
} catch (std::exception& e) {
- Debug::log(ERR, "Tablet had no name???"); // logic error
+ Debug::log(ERR, "Tablet had no name???"); // logic error
}
- 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 = 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;
Debug::log(LOG, "Attaching tablet to cursor!");
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, pDevice);
- PNEWTABLET->hyprListener_Destroy.initCallback(&pDevice->events.destroy, [](void* owner, void* data) {
- const auto PTAB = (STablet*)owner;
-
- g_pInputManager->m_lTablets.remove(*PTAB);
-
- Debug::log(LOG, "Removed a tablet");
- }, PNEWTABLET, "Tablet");
-
- PNEWTABLET->hyprListener_Axis.initCallback(&wlr_tablet_from_input_device(pDevice)->events.axis, [](void* owner, void* data) {
+ PNEWTABLET->hyprListener_Destroy.initCallback(
+ &pDevice->events.destroy,
+ [](void* owner, void* data) {
+ const auto PTAB = (STablet*)owner;
+
+ g_pInputManager->m_lTablets.remove(*PTAB);
+
+ Debug::log(LOG, "Removed a tablet");
+ },
+ PNEWTABLET, "Tablet");
+
+ 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;
+
+ switch (EVENT->tool->type) {
+ case WLR_TABLET_TOOL_TYPE_MOUSE:
+ wlr_cursor_move(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, EVENT->dx, EVENT->dy);
+ g_pInputManager->refocus();
+ break;
+ default:
+ double x = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_X) ? EVENT->x : NAN;
+ double y = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_Y) ? EVENT->y : NAN;
+ wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, x, y);
+ g_pInputManager->refocus();
+ break;
+ }
- const auto EVENT = (wlr_tablet_tool_axis_event*)data;
- const auto PTAB = (STablet*)owner;
+ const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
- switch (EVENT->tool->type) {
- case WLR_TABLET_TOOL_TYPE_MOUSE:
- wlr_cursor_move(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, EVENT->dx, EVENT->dy);
- g_pInputManager->refocus();
- break;
- default:
- double x = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_X) ? EVENT->x : NAN;
- double y = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_Y) ? EVENT->y : NAN;
- wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, x, y);
+ // TODO: this might be wrong
+ if (PTOOL->active) {
g_pInputManager->refocus();
- break;
- }
-
- const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
-
- // TODO: this might be wrong
- if (PTOOL->active) {
- g_pInputManager->refocus();
-
- g_pInputManager->focusTablet(PTAB, EVENT->tool, true);
- }
-
- if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_PRESSURE)
- wlr_tablet_v2_tablet_tool_notify_pressure(PTOOL->wlrTabletToolV2, EVENT->pressure);
- if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_DISTANCE)
- wlr_tablet_v2_tablet_tool_notify_distance(PTOOL->wlrTabletToolV2, EVENT->distance);
+ g_pInputManager->focusTablet(PTAB, EVENT->tool, true);
+ }
- if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_ROTATION)
- wlr_tablet_v2_tablet_tool_notify_rotation(PTOOL->wlrTabletToolV2, EVENT->rotation);
+ if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_PRESSURE)
+ wlr_tablet_v2_tablet_tool_notify_pressure(PTOOL->wlrTabletToolV2, EVENT->pressure);
- if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_SLIDER)
- wlr_tablet_v2_tablet_tool_notify_slider(PTOOL->wlrTabletToolV2, EVENT->slider);
+ if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_DISTANCE)
+ wlr_tablet_v2_tablet_tool_notify_distance(PTOOL->wlrTabletToolV2, EVENT->distance);
- if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_WHEEL)
- wlr_tablet_v2_tablet_tool_notify_wheel(PTOOL->wlrTabletToolV2, EVENT->wheel_delta, 0);
+ if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_ROTATION)
+ wlr_tablet_v2_tablet_tool_notify_rotation(PTOOL->wlrTabletToolV2, EVENT->rotation);
- if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_X)
- PTOOL->tiltX = EVENT->tilt_x;
+ if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_SLIDER)
+ wlr_tablet_v2_tablet_tool_notify_slider(PTOOL->wlrTabletToolV2, EVENT->slider);
- if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_Y)
- PTOOL->tiltY = EVENT->tilt_y;
+ if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_WHEEL)
+ wlr_tablet_v2_tablet_tool_notify_wheel(PTOOL->wlrTabletToolV2, EVENT->wheel_delta, 0);
- if (EVENT->updated_axes & (WLR_TABLET_TOOL_AXIS_TILT_X | WLR_TABLET_TOOL_AXIS_TILT_Y))
- wlr_tablet_v2_tablet_tool_notify_tilt(PTOOL->wlrTabletToolV2, PTOOL->tiltX, PTOOL->tiltY);
+ if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_X)
+ PTOOL->tiltX = EVENT->tilt_x;
- }, PNEWTABLET, "Tablet");
+ if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_Y)
+ PTOOL->tiltY = EVENT->tilt_y;
- 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;
+ if (EVENT->updated_axes & (WLR_TABLET_TOOL_AXIS_TILT_X | WLR_TABLET_TOOL_AXIS_TILT_Y))
+ wlr_tablet_v2_tablet_tool_notify_tilt(PTOOL->wlrTabletToolV2, PTOOL->tiltX, PTOOL->tiltY);
+ },
+ PNEWTABLET, "Tablet");
- const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
+ 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;
- // TODO: this might be wrong
- if (EVENT->state == WLR_TABLET_TOOL_TIP_DOWN) {
- g_pInputManager->refocus();
- g_pInputManager->focusTablet(PTAB, EVENT->tool);
- wlr_send_tablet_v2_tablet_tool_down(PTOOL->wlrTabletToolV2);
- }
- else {
- wlr_send_tablet_v2_tablet_tool_up(PTOOL->wlrTabletToolV2);
- }
+ const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
- }, PNEWTABLET, "Tablet");
+ // TODO: this might be wrong
+ if (EVENT->state == WLR_TABLET_TOOL_TIP_DOWN) {
+ g_pInputManager->refocus();
+ g_pInputManager->focusTablet(PTAB, EVENT->tool);
+ wlr_send_tablet_v2_tablet_tool_down(PTOOL->wlrTabletToolV2);
+ } else {
+ wlr_send_tablet_v2_tablet_tool_up(PTOOL->wlrTabletToolV2);
+ }
+ },
+ PNEWTABLET, "Tablet");
- 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;
+ 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);
+ const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
- wlr_tablet_v2_tablet_tool_notify_button(PTOOL->wlrTabletToolV2, (zwp_tablet_pad_v2_button_state)EVENT->button, (zwp_tablet_pad_v2_button_state)EVENT->state);
+ wlr_tablet_v2_tablet_tool_notify_button(PTOOL->wlrTabletToolV2, (zwp_tablet_pad_v2_button_state)EVENT->button, (zwp_tablet_pad_v2_button_state)EVENT->state);
+ },
+ PNEWTABLET, "Tablet");
- }, PNEWTABLET, "Tablet");
+ 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;
- 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;
+ const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
- const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
+ if (EVENT->state == WLR_TABLET_TOOL_PROXIMITY_OUT) {
+ PTOOL->active = false;
- if (EVENT->state == WLR_TABLET_TOOL_PROXIMITY_OUT) {
- PTOOL->active = false;
+ if (PTOOL->pSurface) {
+ wlr_tablet_v2_tablet_tool_notify_proximity_out(PTOOL->wlrTabletToolV2);
+ PTOOL->pSurface = nullptr;
+ }
- if (PTOOL->pSurface) {
- wlr_tablet_v2_tablet_tool_notify_proximity_out(PTOOL->wlrTabletToolV2);
- PTOOL->pSurface = nullptr;
+ } else {
+ PTOOL->active = true;
+ g_pInputManager->refocus();
+ g_pInputManager->focusTablet(PTAB, EVENT->tool);
}
-
- } else {
- PTOOL->active = true;
- g_pInputManager->refocus();
- g_pInputManager->focusTablet(PTAB, EVENT->tool);
- }
-
- }, PNEWTABLET, "Tablet");
+ },
+ PNEWTABLET, "Tablet");
}
STabletTool* CInputManager::ensureTabletToolPresent(wlr_tablet_tool* pTool) {
@@ -137,16 +146,19 @@ STabletTool* CInputManager::ensureTabletToolPresent(wlr_tablet_tool* pTool) {
Debug::log(LOG, "Creating tablet tool v2 for %x", pTool);
PTOOL->wlrTabletTool = pTool;
- pTool->data = PTOOL;
+ pTool->data = PTOOL;
PTOOL->wlrTabletToolV2 = wlr_tablet_tool_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pTool);
- PTOOL->hyprListener_TabletToolDestroy.initCallback(&pTool->events.destroy, [](void* owner, void* data) {
- const auto PTOOL = (STabletTool*)owner;
+ PTOOL->hyprListener_TabletToolDestroy.initCallback(
+ &pTool->events.destroy,
+ [](void* owner, void* data) {
+ const auto PTOOL = (STabletTool*)owner;
- PTOOL->wlrTabletTool->data = nullptr;
- g_pInputManager->m_lTabletTools.remove(*PTOOL);
- }, PTOOL, "Tablet Tool V1");
+ PTOOL->wlrTabletTool->data = nullptr;
+ g_pInputManager->m_lTabletTools.remove(*PTOOL);
+ },
+ PTOOL, "Tablet Tool V1");
//TODO: set cursor request
}
@@ -160,60 +172,65 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) {
try {
PNEWPAD->name = deviceNameToInternalString(pDevice->name);
} catch (std::exception& e) {
- Debug::log(ERR, "Pad had no name???"); // logic error
+ Debug::log(ERR, "Pad had no name???"); // logic error
}
PNEWPAD->wlrTabletPadV2 = wlr_tablet_pad_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice);
- 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;
-
- wlr_tablet_v2_tablet_pad_notify_mode(PPAD->wlrTabletPadV2, EVENT->group, EVENT->mode, EVENT->time_msec);
- wlr_tablet_v2_tablet_pad_notify_button(PPAD->wlrTabletPadV2, EVENT->button, EVENT->time_msec, (zwp_tablet_pad_v2_button_state)EVENT->state);
-
- }, PNEWPAD, "Tablet Pad");
-
- 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;
-
- wlr_tablet_v2_tablet_pad_notify_strip(PPAD->wlrTabletPadV2, EVENT->strip, EVENT->position, EVENT->source == WLR_TABLET_PAD_STRIP_SOURCE_FINGER, EVENT->time_msec);
-
- }, PNEWPAD, "Tablet Pad");
-
- 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;
-
- wlr_tablet_v2_tablet_pad_notify_ring(PPAD->wlrTabletPadV2, EVENT->ring, EVENT->position, EVENT->source == WLR_TABLET_PAD_RING_SOURCE_FINGER, EVENT->time_msec);
-
- }, PNEWPAD, "Tablet Pad");
-
- 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;
-
- PPAD->pTabletParent = (STablet*)TABLET->data;
-
- if (!PPAD->pTabletParent)
- Debug::log(ERR, "tabletpad got attached to a nullptr tablet!! this might be bad.");
-
- }, PNEWPAD, "Tablet Pad");
-
- PNEWPAD->hyprListener_Destroy.initCallback(&pDevice->events.destroy, [](void* owner, void* data) {
-
- const auto PPAD = (STabletPad*)owner;
-
- g_pInputManager->m_lTabletPads.remove(*PPAD);
-
- Debug::log(LOG, "Removed a tablet pad");
-
- }, PNEWPAD, "Tablet Pad");
+ 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;
+
+ wlr_tablet_v2_tablet_pad_notify_mode(PPAD->wlrTabletPadV2, EVENT->group, EVENT->mode, EVENT->time_msec);
+ wlr_tablet_v2_tablet_pad_notify_button(PPAD->wlrTabletPadV2, EVENT->button, EVENT->time_msec, (zwp_tablet_pad_v2_button_state)EVENT->state);
+ },
+ PNEWPAD, "Tablet Pad");
+
+ 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;
+
+ wlr_tablet_v2_tablet_pad_notify_strip(PPAD->wlrTabletPadV2, EVENT->strip, EVENT->position, EVENT->source == WLR_TABLET_PAD_STRIP_SOURCE_FINGER, EVENT->time_msec);
+ },
+ PNEWPAD, "Tablet Pad");
+
+ 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;
+
+ wlr_tablet_v2_tablet_pad_notify_ring(PPAD->wlrTabletPadV2, EVENT->ring, EVENT->position, EVENT->source == WLR_TABLET_PAD_RING_SOURCE_FINGER, EVENT->time_msec);
+ },
+ PNEWPAD, "Tablet Pad");
+
+ 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;
+
+ PPAD->pTabletParent = (STablet*)TABLET->data;
+
+ if (!PPAD->pTabletParent)
+ Debug::log(ERR, "tabletpad got attached to a nullptr tablet!! this might be bad.");
+ },
+ PNEWPAD, "Tablet Pad");
+
+ PNEWPAD->hyprListener_Destroy.initCallback(
+ &pDevice->events.destroy,
+ [](void* owner, void* data) {
+ const auto PPAD = (STabletPad*)owner;
+
+ g_pInputManager->m_lTabletPads.remove(*PPAD);
+
+ Debug::log(LOG, "Removed a tablet pad");
+ },
+ PNEWPAD, "Tablet Pad");
}
void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool motion) {
diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp
index b07bb915..9c0c2a8d 100644
--- a/src/managers/input/Touch.cpp
+++ b/src/managers/input/Touch.cpp
@@ -2,7 +2,7 @@
#include "../../Compositor.hpp"
void CInputManager::onTouchDown(wlr_touch_down_event* e) {
- auto PMONITOR = g_pCompositor->getMonitorFromName(e->touch->output_name ? e->touch->output_name : "");
+ auto PMONITOR = g_pCompositor->getMonitorFromName(e->touch->output_name ? e->touch->output_name : "");
const auto PDEVIT = std::find_if(m_lTouchDevices.begin(), m_lTouchDevices.end(), [&](const STouchDevice& other) { return other.pWlrDevice == &e->touch->base; });
@@ -15,9 +15,9 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
refocus();
- m_sTouchData.touchFocusWindow = m_pFoundWindowToFocus;
+ m_sTouchData.touchFocusWindow = m_pFoundWindowToFocus;
m_sTouchData.touchFocusSurface = m_pFoundSurfaceToFocus;
- m_sTouchData.touchFocusLS = m_pFoundLSToFocus;
+ m_sTouchData.touchFocusLS = m_pFoundLSToFocus;
Vector2D local;
@@ -30,7 +30,8 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
} else if (m_sTouchData.touchFocusLS) {
- local = g_pInputManager->getMouseCoordsInternal() - Vector2D(m_sTouchData.touchFocusLS->geometry.x, m_sTouchData.touchFocusLS->geometry.y) - g_pCompositor->m_pLastMonitor->vecPosition;
+ local = g_pInputManager->getMouseCoordsInternal() - Vector2D(m_sTouchData.touchFocusLS->geometry.x, m_sTouchData.touchFocusLS->geometry.y) -
+ g_pCompositor->m_pLastMonitor->vecPosition;
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
} else {
@@ -42,17 +43,18 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
}
-void CInputManager::onTouchUp(wlr_touch_up_event* e){
+void CInputManager::onTouchUp(wlr_touch_up_event* e) {
if (m_sTouchData.touchFocusSurface) {
wlr_seat_touch_notify_up(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id);
}
}
-void CInputManager::onTouchMove(wlr_touch_motion_event* e){
+void CInputManager::onTouchMove(wlr_touch_motion_event* e) {
if (m_sTouchData.touchFocusWindow && g_pCompositor->windowValidMapped(m_sTouchData.touchFocusWindow)) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusWindow->m_iMonitorID);
- wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x,
+ PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
const auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin;
@@ -60,7 +62,8 @@ void CInputManager::onTouchMove(wlr_touch_motion_event* e){
} else if (m_sTouchData.touchFocusLS) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusLS->monitorID);
- wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x,
+ PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
const auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin;