Skip to content

Commit

Permalink
Hyprexpo: support touchscreen taps for workspace selection (#136)
Browse files Browse the repository at this point in the history
* feat(hyprexpo): also monitor touches for selecting workspace

* refactor(hyprexpo): use same callbacks for hooks
  • Loading branch information
matt1432 authored Apr 11, 2024
1 parent 5ec0140 commit e9457e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 12 additions & 4 deletions hyprexpo/overview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ static void removeOverview(void*) {
COverview::~COverview() {
g_pHyprRenderer->makeEGLCurrent();
images.clear(); // otherwise we get a vram leak
g_pHookSystem->unhook(touchUpHook);
g_pHookSystem->unhook(touchMoveHook);
g_pHookSystem->unhook(mouseButtonHook);
g_pHookSystem->unhook(mouseMoveHook);
g_pInputManager->unsetCursorImage();
Expand Down Expand Up @@ -184,15 +186,15 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn

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)
return;

info.cancelled = true;
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)
return;

Expand All @@ -205,7 +207,13 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn
closeOnID = x + y * SIDE_LENGTH;

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) {
Expand Down
2 changes: 2 additions & 0 deletions hyprexpo/overview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class COverview {

HOOK_CALLBACK_FN* mouseMoveHook = nullptr;
HOOK_CALLBACK_FN* mouseButtonHook = nullptr;
HOOK_CALLBACK_FN* touchMoveHook = nullptr;
HOOK_CALLBACK_FN* touchUpHook = nullptr;

bool swipe = false;
bool swipeWasCommenced = false;
Expand Down

0 comments on commit e9457e0

Please sign in to comment.