Hyprexpo: support touchscreen taps for workspace selection (#136)

* feat(hyprexpo): also monitor touches for selecting workspace

* refactor(hyprexpo): use same callbacks for hooks
This commit is contained in:
Mathis H 2024-04-11 11:47:36 +00:00 committed by GitHub
parent 5ec0140d4a
commit e9457e08ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View file

@ -17,6 +17,8 @@ static void removeOverview(void*) {
COverview::~COverview() { COverview::~COverview() {
g_pHyprRenderer->makeEGLCurrent(); g_pHyprRenderer->makeEGLCurrent();
images.clear(); // otherwise we get a vram leak images.clear(); // otherwise we get a vram leak
g_pHookSystem->unhook(touchUpHook);
g_pHookSystem->unhook(touchMoveHook);
g_pHookSystem->unhook(mouseButtonHook); g_pHookSystem->unhook(mouseButtonHook);
g_pHookSystem->unhook(mouseMoveHook); g_pHookSystem->unhook(mouseMoveHook);
g_pInputManager->unsetCursorImage(); g_pInputManager->unsetCursorImage();
@ -184,15 +186,15 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn
lastMousePosLocal = g_pInputManager->getMouseCoordsInternal() - pMonitor->vecPosition; lastMousePosLocal = g_pInputManager->getMouseCoordsInternal() - pMonitor->vecPosition;
mouseMoveHook = g_pHookSystem->hookDynamic("mouseMove", [this](void* self, SCallbackInfo& info, std::any param) { auto onCursorMove = [this](void* self, SCallbackInfo& info, std::any param) {
if (closing) if (closing)
return; return;
info.cancelled = true; info.cancelled = true;
lastMousePosLocal = g_pInputManager->getMouseCoordsInternal() - pMonitor->vecPosition; lastMousePosLocal = g_pInputManager->getMouseCoordsInternal() - pMonitor->vecPosition;
}); };
mouseButtonHook = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any param) { auto onCursorSelect = [this](void* self, SCallbackInfo& info, std::any param) {
if (closing) if (closing)
return; return;
@ -205,7 +207,13 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn
closeOnID = x + y * SIDE_LENGTH; closeOnID = x + y * SIDE_LENGTH;
close(); close();
}); };
mouseMoveHook = g_pHookSystem->hookDynamic("mouseMove", onCursorMove);
touchMoveHook = g_pHookSystem->hookDynamic("touchMove", onCursorMove);
mouseButtonHook = g_pHookSystem->hookDynamic("mouseButton", onCursorSelect);
touchUpHook = g_pHookSystem->hookDynamic("touchUp", onCursorSelect);
} }
void COverview::redrawID(int id, bool forcelowres) { void COverview::redrawID(int id, bool forcelowres) {

View file

@ -70,6 +70,8 @@ class COverview {
HOOK_CALLBACK_FN* mouseMoveHook = nullptr; HOOK_CALLBACK_FN* mouseMoveHook = nullptr;
HOOK_CALLBACK_FN* mouseButtonHook = nullptr; HOOK_CALLBACK_FN* mouseButtonHook = nullptr;
HOOK_CALLBACK_FN* touchMoveHook = nullptr;
HOOK_CALLBACK_FN* touchUpHook = nullptr;
bool swipe = false; bool swipe = false;
bool swipeWasCommenced = false; bool swipeWasCommenced = false;