-
-
Notifications
You must be signed in to change notification settings - Fork 898
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
bind: new long press option #8302
base: main
Are you sure you want to change the base?
Conversation
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.
also needs a clang-format
|
||
const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock(); | ||
|
||
wl_event_source_timer_update(m_pActiveKeybindEventSource, PACTIVEKEEB->repeatDelay); |
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.
please don't use event sources. See managers/eventLoop/EventLoopTimer.
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.
do you want me to include "eventLoop/EventLoopTimer.hpp"?
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.
ye
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 tried:
m_pActiveKeybind = &k;
const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock();
m_pLongPressTimer = makeShared<CEventLoopTimer>(
std::chrono::milliseconds(PACTIVEKEEB->repeatDelay),
longPressHandler,
&m_pActiveKeybind
);
g_pEventLoopManager->addTimer(m_pLongPressTimer);
continue;
not sure why now it doesn't work anymore.
(m_pLongPressTimer is in the .hpp file)
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.
the timer should be created and added in the constructor, then here you'd call setTimeout instead (or whatever the name was)
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.
in the constructure too then(since it'd be out of scope otherwise)
you can throw it into a lambda, sure.
And what is m_pLastKeybind
you used it yourself, a member of CKeybindManager. m_pLastLongPressKeybind
is a new one I added for the sake of this functionality
and should i pass in this instead of nullptr since i'd need to access the m_pactivekeybind
Nope! Throw it into a lambda and use an explicit this
catch with [this]
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.
And what is m_pLastKeybind
you used it yourself, a member of CKeybindManager. m_pLastLongPressKeybind is a new one I added for the sake of this functionality
wait, you meant m_pActiveKeybind?
Wait so in a lambda function with [this] u can directly reference its members?
I'll try this when I get back so I can test it
No wonder why When I was doing that but passing in "this" or m_pActiceKeybind it'd crash
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.
Ok, after trying to directly reference the class members in a [this] lambda func.
this is what happens,
if (!m_pActiveKeybind)
return 0;
result in
(EE) failed to read Wayland events: Broken pipe
[1] 1217210 illegal hardware instruction (core dumped) ./build/Hyprland
stuff using it:
SKeybind** ppActiveKeybind = (SKeybind**)m_pActiveKeybind;
if (!*ppActiveKeybind)
return 0
raises SEGEV
i was thinking m_pActiveKeybind might be null? so i gave it &k before calling the update, but doesnt help
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 need to see the entire code
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.
here:
m_pLongPressTimer = makeShared<CEventLoopTimer>(
std::nullopt,
[this](SP<CEventLoopTimer> self, void* data) {
SKeybind** ppActiveKeybind = (SKeybind**)m_pActiveKeybind;
if (!m_pActiveKeybind) // wayland broken pipe then crash
return 0;
if (!*ppActiveKeybind || g_pSeatManager->keyboard.expired()) // SEGEV
return 0;
// const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find((*ppActiveKeybind)->handler);
// Debug::log(LOG, "Keybind long press triggered, calling dispatcher.");
// DISPATCHER->second((*ppActiveKeybind)->arg);
},
nullptr
);
this code is in the constructor
and this in the k.longPress:
m_pActiveKeybind = &k;
const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock();
m_pLongPressTimer->updateTimeout(std::chrono::milliseconds(PACTIVEKEEB->repeatDelay));
// m_pLastLongPressKeybind = &k;
// continue;
this is soo weird huh? yesterday i tested it it works. now i re-clone my repo and checkout that commit and it doesnt work anymore... seem like a issue with longPress var not being registered... |
Describe your PR, what does it fix/add?
impl #8245, described there too
Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)
Is it ready for merging, or does it need work?
ready