Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

littleblack111
Copy link
Contributor

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

Copy link
Member

@vaxerski vaxerski left a 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);
Copy link
Member

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.

Copy link
Contributor Author

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"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ye

Copy link
Contributor Author

@littleblack111 littleblack111 Nov 2, 2024

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)

Copy link
Member

@vaxerski vaxerski Nov 2, 2024

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)

Copy link
Member

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]

Copy link
Contributor Author

@littleblack111 littleblack111 Nov 4, 2024

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

Copy link
Contributor Author

@littleblack111 littleblack111 Nov 4, 2024

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

Copy link
Member

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

Copy link
Contributor Author

@littleblack111 littleblack111 Nov 5, 2024

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;

src/managers/KeybindManager.cpp Show resolved Hide resolved
src/config/ConfigManager.cpp Outdated Show resolved Hide resolved
@littleblack111
Copy link
Contributor Author

littleblack111 commented Nov 3, 2024

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...

@github-actions github-actions bot added the debug label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants