-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add support for sending mouse events from a kitten #2538
Conversation
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))) { |
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.
Shouldnt this be action == move??
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.
No, when the mode is MOTION_MODE
, the terminal should send PRESS
, RELEASE
and DRAG
actions, but not MOVE
actions.
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 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.
84303c2
to
43af6e3
Compare
That force push was just fixing some indentation I had messed up. |
On Sun, Apr 12, 2020 at 07:13:19AM -0700, Trygve Aaberge wrote:
@trygveaa commented on this pull request.
> @@ -698,6 +700,25 @@ scroll_event(double UNUSED xoffset, double yoffset, int flags) {
}
}
+static PyObject*
+send_mouse_event(PyObject *self UNUSED, PyObject *args) {
+ Screen *screen;
+ unsigned int x, y;
+ int button, action, mods;
+ 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))) {
I could write `mode == MOTION_MODE && (action == PRESS || action == RELEASE || action == DRAG)` if that's clearer?
No, it's fine.
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?
You can test the whole function by getting the output sent by
write_escape_code_to_child. Which can be done by passing test_child
to the Screen object.
|
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.