-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gesture Hooks API #174
base: main
Are you sure you want to change the base?
Gesture Hooks API #174
Conversation
that's genius! I had the idea of using dispatchers to do somewhat the same thing but it was too clunky to use and so I dropped it. I think rather than hooking on to the "opposite of workspace gesture" it's easier to provide hooks for a generic "swipe" event (and same for "edge" and others). for that you can emit the events in not so important to the problem at hand, if handleDragGesture did not do anything (returns false), I'd like to see some way for hook users to tell us if they did anything: if they handled the gesture, we need to block touch events from going to the app window (among other things). for this, EMIT_CANCELLABLE_EVENT might be useful |
So I try having I try to swipe vertically instead to not trigger the workspace swipe but that does not emit anything during that gesture. |
can you push what you have now? |
It's not much but here you go |
Crashes Hyprland as soon as I do a gesture :( No crash report in |
added some checks, so that workspace swipe doesn't crash notification now works, but idk what the API should look like yet. i think at the very least we'll need 3 separate hook events for start/update/end and possibly more for each gesture type edit: also the events should be namespaced under |
Yes I was thinking that too.
Yes I agree |
I tried your latest commit and it did work to emit changes for swipes, but the workspace swiping wasn't working, is that normal? |
yea right now the hook just "consumes" the drag event unconditionally |
src/GestureManager.cpp
Outdated
|
||
IPointer::SSwipeUpdateEvent ev = { | ||
.fingers = (uint32_t)gev.finger_count, | ||
.delta = Vector2D(delta_percent.x * 5, delta_percent.y * 5), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it easier to hook onto, I convert the touch gesture event to a touchpad gesture event. However, I don't really know how to properly convert the delta.
Do you have any ideas @horriblename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure what unit touchpad swipes are in (and I have no clue where to even dig up this info). you can either:
try whatever wizardry I did in updateWorkspaceSwipe()ask vaxryconvert to touch events instead, in this case you can useGestureManager::pixelPositionToPercentagePosition()
to get the position
try the 1 and 2 first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed my mind, I think it's more helpful to give the exact position of gesture, instead of delta like in SSwipeUpdateEvent,
please use ITouch::SMotionEvent instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use GestureManager::pixelPositionToPercentagePosition() to get the position
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I was doing it this way to make it as easy as possible to implement in hyprexpo. Is ITouch::SMotionEvent
a Hyprland thing? Edit: it is, I just found it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@horriblename ITouch::SMotionEvent
doesn't have a fingers
prop
0e5a19b
to
61bd94c
Compare
@horriblename I finally figured out how to make the hooks compatible with hyprexpo's gesture, which was my original goal. I had to stick with What do you think? |
Also, should I be using |
EMIT_HOOK_EVENT is fine. Only the start event needs to check that an event is handled |
uuh I'll mull it over, but I think if we're exposing a hook API I'd like it to be extensible as possible |
g_pHookSystem->emit(PEVENTVEC, info, | ||
IPointer::SSwipeBeginEvent{.fingers = (uint32_t)gev.finger_count}); | ||
|
||
if (!info.cancelled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@horriblename I figured out how to add it back, but to make it work with hyprexpo I had to check if info.cancelled
was false instead of true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@horriblename Is this expected? I thought it would've been the opposite no?
edc142c
to
63bf88a
Compare
@horriblename Have you given this PR any more thoughts? I added a small check list in my original message to clarify what I'm hung up on |
Sorry it took this long, I've decided to go ahead with #189 as a stopgap and leave the event hooks for another time. #189 should cover your use cases (hyprexpo integration), I tested on Hyprspace but please help me test on hyprexpo as well. I will be generalizing ideas from this PR for a more extensible event hook API. |
If you have no problems with #189 I will close this PR and merge that one |
No worries! #189 works perfectly for my use case. Just gave it a shot and I'm happy. Go for it We can leave this PR open and leave it as a draft imo. It's up to you if you wanna continue it or open another one but it's still a good reference for what's possible and whatnot. |
I am trying to make it possible for another plugin to hook onto the opposite gesture of the workspace gesture.
I had the idea of copying hyprexpo's touchpad gesture on a touchscreen by having hyprgrass emit a hook when dragging the opposite way and then have hyprexpo hook onto it.
I have the hook and listen thing figured out, but the gesture part is very unclear to me.
I can't really tell how to listen to a gesture or even if one is recognized at all. Would love to get some info on that.
Thanks!
Edits:
Check List:
info.cancelled
is the opposite in hyprexpo