After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 385695 - want API to convert screen coordinates to logical (row/col) coordinates
want API to convert screen coordinates to logical (row/col) coordinates
Status: RESOLVED OBSOLETE
Product: vte
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: VTE Maintainers
VTE Maintainers
: 481037 (view as bug list)
Depends on:
Blocks: vte1.0
 
 
Reported: 2006-12-14 02:18 UTC by Allison Karlitskaya (desrt)
Modified: 2015-12-26 12:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Perform the event translate on behalf of g-t (1.70 KB, patch)
2007-02-01 00:24 UTC, Chris Wilson
none Details | Review

Description Allison Karlitskaya (desrt) 2006-12-14 02:18:39 UTC
sometimes when you right click on a link in the terminal the "show link" item isn't on the context menu.  of course, as soon as you go to try again it works fine.

this has annoyed me for ages (since it causes me to click "new terminal" instead).  i finally figured out where the problem is.

approach a url from the bottom.  until it just barely becomes underlined.  click the right mouse button and notice the lack of "open link".  it seems that the bottom couple of pixels that result in the link being underlined do not result in the "open link" item being added to the context menu.
Comment 1 Allison Karlitskaya (desrt) 2006-12-14 02:19:40 UTC
it's actually exactly 1 pixel.  sure enough, if you position the mouse above the underlining zone by one pixel the menu item *is* there (when it should not be).
Comment 2 Allison Karlitskaya (desrt) 2006-12-14 02:59:10 UTC
the problem is caused by gnome-terminal naively assuming that it can figure out column/row by taking x/y and dividing by the font width/height.

this calculuation doesn't take VTE_PAD_WIDTH into account.

of course, gnome-terminal has no way of knowing about VTE_PAD_WIDTH since it's in vte-private.h.

this is more or less a vte API bug...
Comment 3 Chris Wilson 2007-02-01 00:24:54 UTC
Created attachment 81639 [details] [review]
Perform the event translate on behalf of g-t

Would this be appropriate?
Comment 4 Allison Karlitskaya (desrt) 2007-02-01 00:35:20 UTC
i was thinking about an API to let g-t give vte the x/y coordinate of the click directly instead of converting it and then making another call into vte.

this API is quite fine, though, and will allow g-t to do other things with the information (should it have the need).
Comment 5 Behdad Esfahbod 2007-02-01 21:06:19 UTC
Chris,

Notes about the API:

1) Why does it have to take doubles?  Doesn't make sense to me.
2) If taking int, you possibly can use a single pair as input/output args.  But I agree that row+col instead of x+y is more readable (those confusing also because row is y, not x.)
3) I prefer, and I think is more useful, to clamp the mapped position to within the terminal.  Similar to pango_layout_xy_to_index().
Comment 6 Behdad Esfahbod 2007-02-01 21:07:56 UTC
And I think it can use a better name.  transform_position instead of translate_position to start with.  xy_to_rowcol maybe!

Do we need the other direction too?  To get bounding box of a cell?
Comment 7 Chris Wilson 2007-02-01 21:40:08 UTC
I chose a pair of doubles because that maps closely with GdkEventButton which passes around the mouse coordinate as a pair of doubles.

vte_terminal_xy_to_rowcol(), vte_terminal_rowcol_to_rectangle()?

Couldn't immediately see a use for the cell bbox so I didn't include it the first time. Silly example might be if the host application wished to overlay GtkWidgets over a set of cells.
Comment 8 Behdad Esfahbod 2007-02-03 18:04:56 UTC
(In reply to comment #7)
> I chose a pair of doubles because that maps closely with GdkEventButton which
> passes around the mouse coordinate as a pair of doubles.
> 
> vte_terminal_xy_to_rowcol(), vte_terminal_rowcol_to_rectangle()?
> 
> Couldn't immediately see a use for the cell bbox so I didn't include it the
> first time. Silly example might be if the host application wished to overlay
> GtkWidgets over a set of cells.

Well, if we don't want apps to guess the conversion, we need to provide both ways.  Should the rowcol_to_rectangle() take double-width chars into account?  Not sure.  And what type should it return?  GdkRectangle()?
Comment 9 Mariano Suárez-Alvarez 2007-02-05 01:06:45 UTC
Regarding the original issue: the API Ryan was missing is just vte_terminal_get_padding plus a division by 2 ;-)
Comment 10 Allison Karlitskaya (desrt) 2007-02-05 01:08:08 UTC
hah.  go figure.

for the record: i still think the new API would be nice.
Comment 11 Mariano Suárez-Alvarez 2007-02-05 01:15:47 UTC
/me too. _xy_to_rowcol is the way to do this cleanly.
Comment 12 Chris Wilson 2007-09-27 17:59:44 UTC
*** Bug 481037 has been marked as a duplicate of this bug. ***
Comment 13 Christian Persch 2008-06-26 20:45:15 UTC
The original bug is fixed in g-t svn trunk; retitling.
Comment 14 Behdad Esfahbod 2008-11-29 08:33:20 UTC
Is this still interesting?
Comment 15 Allison Karlitskaya (desrt) 2008-11-29 21:42:00 UTC
not worth it i think.

you can just take the x/y, subtract the padding and divide by the font size.  the fact that this trivial addition has been left for so long with nobody really caring about it is a good indication. :)
Comment 16 Christian Persch 2011-06-02 17:19:39 UTC
Reopening; I'm going to add this on vte-next.
Comment 17 Allison Karlitskaya (desrt) 2012-01-19 02:53:48 UTC
ping?
Comment 18 Behdad Esfahbod 2012-01-19 03:21:40 UTC
I think ChPe is kinda away.  Feel free to give it a try, Ryan.
Comment 19 Christian Persch 2012-01-19 11:25:32 UTC
This is done on vte-next. Do you need something like it right now on vte-0-32 ?
Comment 20 Allison Karlitskaya (desrt) 2012-01-19 15:11:58 UTC
Nope.  Feel free to close as FIXED (or do so when you land the branch).
Comment 21 Christian Persch 2015-12-26 12:44:29 UTC
This is obsolete. We now do the check by passing the GdkEvent to vte, which then translates the coordinates internally taking into account the padding. 

If another use case for view/grid coord transforms emerge, we can reconsider this, but for now, it's WONTFIX/OBSOLETE.