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

Allow mouse coordinate updates outside of terminal window #2741

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 6 additions & 26 deletions src/lib/in.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,19 +567,6 @@ pixelmouse_click(inputctx* ictx, ncinput* ni, long y, long x){
x /= ictx->ti->cellpxx;
x -= ictx->lmargin;
y -= ictx->tmargin;
// convert from 1- to 0-indexing, and account for margins
Copy link
Owner

Choose a reason for hiding this comment

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

ugh, i should really probably have factored these out. if you're getting rid of them, i guess it doesn't matter.

if(x < 0 || y < 0){ // click was in margins, drop it
logwarn("dropping click in margins %ld/%ld", y, x);
return;
}
if((unsigned)x >= ictx->ti->dimx - (ictx->rmargin + ictx->lmargin)){
logwarn("dropping click in margins %ld/%ld", y, x);
return;
}
if((unsigned)y >= ictx->ti->dimy - (ictx->bmargin + ictx->tmargin)){
logwarn("dropping click in margins %ld/%ld", y, x);
return;
}
ni->y = y;
ni->x = x;
load_ncinput(ictx, ni);
Expand Down Expand Up @@ -631,19 +618,6 @@ mouse_click(inputctx* ictx, unsigned release, char follow){
}
x -= (1 + ictx->lmargin);
y -= (1 + ictx->tmargin);
// convert from 1- to 0-indexing, and account for margins
if(x < 0 || y < 0){ // click was in margins, drop it
logwarn("dropping click in margins %ld/%ld", y, x);
return;
}
if((unsigned)x >= ictx->ti->dimx - (ictx->rmargin + ictx->lmargin)){
logwarn("dropping click in margins %ld/%ld", y, x);
return;
}
if((unsigned)y >= ictx->ti->dimy - (ictx->bmargin + ictx->tmargin)){
logwarn("dropping click in margins %ld/%ld", y, x);
return;
}
tni.x = x;
tni.y = y;
tni.ypx = -1;
Expand Down Expand Up @@ -1768,6 +1742,12 @@ build_cflow_automaton(inputctx* ictx){
{ "[E", simple_cb_begin, },
{ "[<\\N;\\N;\\NM", mouse_press_cb, },
{ "[<\\N;\\N;\\Nm", mouse_release_cb, },
{ "[<\\N;-\\N;\\NM", mouse_press_cb, },
Copy link
Owner

Choose a reason for hiding this comment

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

who's sending these?

Copy link
Author

Choose a reason for hiding this comment

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

From a quick test it seems kitty, ghostty, xterm and urxvt do. alacritty, wezterm, gnome-terminal don't.

{ "[<\\N;-\\N;\\Nm", mouse_release_cb, },
{ "[<\\N;\\N;-\\NM", mouse_press_cb, },
{ "[<\\N;\\N;-\\Nm", mouse_release_cb, },
{ "[<\\N;-\\N;-\\NM", mouse_press_cb, },
{ "[<\\N;-\\N;-\\Nm", mouse_release_cb, },
Copy link
Owner

Choose a reason for hiding this comment

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

erp, i need some unit tests on this badly. i know touching it sometimes has unexpected results, due to a bug or bugs of mine.

Copy link
Author

Choose a reason for hiding this comment

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

I've been using it daily for a few months without noticing any wierdness, but yeah, it didn't look like the "correct" fix to me.

// technically these must begin with "4" or "8"; enforce in callbacks
{ "[\\N;\\N;\\Nt", geom_cb, },
{ "[\\Nu", kitty_cb_simple, },
Expand Down
Loading