Skip to content

Add support for sending mouse events from a kitten #2538

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

Merged
merged 1 commit into from
Apr 12, 2020

Conversation

trygveaa
Copy link
Contributor

This allows you to a control a program running in kitty from a kitten
using mouse events. If the program is not receiving mouse events of that
type, it is not sent.

if (!PyArg_ParseTuple(args, "O!IIiii", &Screen_Type, &screen, &x, &y, &button, &action, &mods)) return NULL;

MouseTrackingMode mode = screen->modes.mouse_tracking_mode;
if (mode == ANY_MODE || (mode == MOTION_MODE && action != MOVE) || (mode == BUTTON_MODE && (action == PRESS || action == RELEASE))) {
Copy link
Owner

Choose a reason for hiding this comment

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

Shouldnt this be action == move??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, when the mode is MOTION_MODE, the terminal should send PRESS, RELEASE and DRAG actions, but not MOVE actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could write mode == MOTION_MODE && (action == PRESS || action == RELEASE || action == DRAG) if that's clearer?

It would be nice with some tests for this function, but not sure how to test the whole function? I guess the easiest would be to pull out this if to a separate function and test that?

This allows you to a control a program running in kitty from a kitten
using mouse events. If the program is not receiving mouse events of that
type, it is not sent.
@trygveaa trygveaa force-pushed the kitten-send-mouse-events branch from 84303c2 to 43af6e3 Compare April 12, 2020 14:20
@trygveaa
Copy link
Contributor Author

That force push was just fixing some indentation I had messed up.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Apr 12, 2020 via email

@kovidgoyal kovidgoyal merged commit 3c970e0 into kovidgoyal:master Apr 12, 2020
@trygveaa trygveaa deleted the kitten-send-mouse-events branch April 13, 2020 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants