From f4d11d2d43aed8b62eb4c4cb62f9e1d7b91c327c Mon Sep 17 00:00:00 2001 From: vaxerski Date: Wed, 17 Aug 2022 22:59:40 +0200 Subject: fix lastFocus on activateWindow --- src/managers/XWaylandManager.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 962fea03..fd0194bf 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -54,7 +54,6 @@ void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) { else wlr_xdg_toplevel_set_activated(pWindow->m_uSurface.xdg->toplevel, activate); - g_pCompositor->m_pLastFocus = getWindowSurface(pWindow); g_pCompositor->m_pLastWindow = pWindow; } -- cgit v1.2.3 From c5a4c83f78308ae3cef5d60626086611e033d4ed Mon Sep 17 00:00:00 2001 From: vaxerski Date: Wed, 17 Aug 2022 23:23:36 +0200 Subject: better integrate touch with subsurfaces --- src/managers/input/InputManager.hpp | 1 + src/managers/input/Touch.cpp | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 6f472521..2db6c5a9 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -14,6 +14,7 @@ enum eClickBehaviorMode { struct STouchData { CWindow* touchFocusWindow = nullptr; + Vector2D touchSurfaceOrigin; }; class CInputManager { diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp index 0b3c8961..daf34200 100644 --- a/src/managers/input/Touch.cpp +++ b/src/managers/input/Touch.cpp @@ -10,9 +10,16 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) { m_sTouchData.touchFocusWindow = nullptr; if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) { - wlr_seat_touch_notify_down(g_pCompositor->m_sSeat.seat, g_pCompositor->m_pLastFocus, e->time_msec, e->touch_id, - e->x * g_pCompositor->m_pLastMonitor->vecSize.x + g_pCompositor->m_pLastMonitor->vecPosition.x - g_pCompositor->m_pLastWindow->m_vRealPosition.vec().x, - e->y * g_pCompositor->m_pLastMonitor->vecSize.y + g_pCompositor->m_pLastMonitor->vecPosition.y - g_pCompositor->m_pLastWindow->m_vRealPosition.vec().y); + Vector2D local; + if (g_pCompositor->m_pLastWindow->m_bIsX11) { + local = g_pInputManager->getMouseCoordsInternal() - g_pCompositor->m_pLastWindow->m_vRealPosition.goalv(); + } else { + g_pCompositor->vectorWindowToSurface(g_pInputManager->getMouseCoordsInternal(), g_pCompositor->m_pLastWindow, local); + } + + m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local; + + wlr_seat_touch_notify_down(g_pCompositor->m_sSeat.seat, g_pCompositor->m_pLastFocus, e->time_msec, e->touch_id, local.x, local.y); m_sTouchData.touchFocusWindow = g_pCompositor->m_pLastWindow; } @@ -29,10 +36,10 @@ void CInputManager::onTouchMove(wlr_touch_motion_event* e){ if (g_pCompositor->windowValidMapped(m_sTouchData.touchFocusWindow)) { const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusWindow->m_iMonitorID); - wlr_seat_touch_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id, - e->x * PMONITOR->vecSize.x + PMONITOR->vecPosition.x - m_sTouchData.touchFocusWindow->m_vRealPosition.vec().x, - e->y * PMONITOR->vecSize.y + PMONITOR->vecPosition.y - m_sTouchData.touchFocusWindow->m_vRealPosition.vec().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; + + wlr_seat_touch_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id, local.x, local.y); } } \ No newline at end of file -- cgit v1.2.3 From f3c597bfb7f288ff1cfd43b307ab6c209ccdc255 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Thu, 18 Aug 2022 07:28:07 +0200 Subject: fix crash --- src/managers/XWaylandManager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/managers') diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index fd0194bf..962fea03 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -54,6 +54,7 @@ void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) { else wlr_xdg_toplevel_set_activated(pWindow->m_uSurface.xdg->toplevel, activate); + g_pCompositor->m_pLastFocus = getWindowSurface(pWindow); g_pCompositor->m_pLastWindow = pWindow; } -- cgit v1.2.3 From b078a12eed18c848bfb876b9af482982504a5f73 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Thu, 18 Aug 2022 17:17:33 +0200 Subject: Added an activelayout event --- src/managers/input/InputManager.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 95b30587..b002864d 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -441,10 +441,20 @@ void CInputManager::newKeyboard(wlr_input_device* 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; + + if (PKEYBOARD == m_pActiveKeyboard) + g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent + + }, PNEWKEYBOARD, "Keyboard"); + if (m_pActiveKeyboard) m_pActiveKeyboard->active = false; m_pActiveKeyboard = PNEWKEYBOARD; + PNEWKEYBOARD->active = true; + applyConfigToKeyboard(PNEWKEYBOARD); wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(keyboard)); @@ -472,6 +482,8 @@ void CInputManager::newVirtualKeyboard(wlr_input_device* keyboard) { m_pActiveKeyboard->active = false; m_pActiveKeyboard = PNEWKEYBOARD; + PNEWKEYBOARD->active = true; + applyConfigToKeyboard(PNEWKEYBOARD); wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(keyboard)); @@ -582,6 +594,9 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { xkb_keymap_unref(KEYMAP); xkb_context_unref(CONTEXT); + if (pKeyboard == m_pActiveKeyboard) + g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", 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); } @@ -735,6 +750,15 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) { wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard)); wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers); } + + const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard); + + if (PWLRKB->modifiers.group != pKeyboard->activeLayout) { + pKeyboard->activeLayout = PWLRKB->modifiers.group; + + if (pKeyboard == m_pActiveKeyboard) + g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent + } } void CInputManager::refocus() { -- cgit v1.2.3 From 9b62328b22fbd1ca20ac96cca0fcf21906d42aa6 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Thu, 18 Aug 2022 17:50:32 +0200 Subject: minor changes to the activelayout event --- src/managers/input/InputManager.cpp | 33 +++++++++++++++++++++++---------- src/managers/input/InputManager.hpp | 2 ++ 2 files changed, 25 insertions(+), 10 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index b002864d..f8899f62 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -444,13 +444,12 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) { PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) { const auto PKEYBOARD = (SKeyboard*)owner; - if (PKEYBOARD == m_pActiveKeyboard) - g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", 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 }, PNEWKEYBOARD, "Keyboard"); - if (m_pActiveKeyboard) - m_pActiveKeyboard->active = false; + disableAllKeyboards(false); + m_pActiveKeyboard = PNEWKEYBOARD; PNEWKEYBOARD->active = true; @@ -477,9 +476,15 @@ void CInputManager::newVirtualKeyboard(wlr_input_device* keyboard) { PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard"); PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard"); PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard"); + 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, "Keyboard"); + + disableAllKeyboards(true); - if (m_pActiveKeyboard) - m_pActiveKeyboard->active = false; m_pActiveKeyboard = PNEWKEYBOARD; PNEWKEYBOARD->active = true; @@ -594,8 +599,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { xkb_keymap_unref(KEYMAP); xkb_context_unref(CONTEXT); - if (pKeyboard == m_pActiveKeyboard) - g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", 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); } @@ -756,8 +760,7 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) { if (PWLRKB->modifiers.group != pKeyboard->activeLayout) { pKeyboard->activeLayout = PWLRKB->modifiers.group; - if (pKeyboard == m_pActiveKeyboard) - g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", 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 } } @@ -930,3 +933,13 @@ std::string CInputManager::getActiveLayoutForKeyboard(SKeyboard* pKeyboard) { return "none"; } + +void CInputManager::disableAllKeyboards(bool virt) { + + for (auto& k : m_lKeyboards) { + if (k.isVirtual != virt) + continue; + + k.active = false; + } +} \ No newline at end of file diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 2db6c5a9..9ced0e8d 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -107,6 +107,8 @@ private: void processMouseDownNormal(wlr_pointer_button_event* e); void processMouseDownKill(wlr_pointer_button_event* e); + void disableAllKeyboards(bool virt = false); + uint32_t m_uiCapabilities = 0; void mouseMoveUnified(uint32_t, bool refocus = false); -- cgit v1.2.3