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 759725 - Setting Container:border-width on TextView breaks gesture positions
Setting Container:border-width on TextView breaks gesture positions
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
3.22.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 781987 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-12-21 10:17 UTC by Frédéric Parrenin
Modified: 2017-08-29 17:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case showing Container:border-width breaking text selection (823 bytes, text/plain)
2017-08-28 14:47 UTC, Daniel Boles
  Details
TextView: Fix gesture coords with :border-width >0 (1.06 KB, patch)
2017-08-28 21:02 UTC, Daniel Boles
none Details | Review
TextView: Fix gesture coords with :border-width >0 (1.44 KB, patch)
2017-08-28 21:28 UTC, Daniel Boles
committed Details | Review

Description Frédéric Parrenin 2015-12-21 10:17:26 UTC
Steps to reproduce:
- open a new workbook
- insert a rectangle object
- double-click on it
- go to "content" and insert some text
- try to select the whole text with the mouse, from the left to the right
=> it is impossible to select the first character
Comment 1 Jean Bréfort 2015-12-22 06:47:45 UTC
It is not impossible, just not that easy. Not sure why, we just use a GtkTextView there, nothing specific to gnumeric.
Comment 2 Andreas J. Guelzow 2015-12-23 01:50:42 UTC
Hmm, I have no problem at all with selecting it. It is also not difficult at all...
Comment 3 Jean Bréfort 2015-12-23 07:21:28 UTC
For me, clicking on a character always puts the cursor after the character even if the click occurs on the first pixel. Might be a new Gtk+ feature.
Comment 4 Daniel Boles 2017-08-28 00:22:42 UTC
(In reply to Jean Bréfort from comment #3)
> For me, clicking on a character always puts the cursor after the character
> even if the click occurs on the first pixel. Might be a new Gtk+ feature.

I can confirm this on the gnumeric distributed with Debian Jessie; I've not tried unstable yet.

However, this is not an innate problem with GtkTextView; I can't reproduce it with basic test cases in GTK+ alone. So we'd need more info about what gnumeric does here.
Comment 5 Daniel Boles 2017-08-28 00:23:12 UTC
*** Bug 781987 has been marked as a duplicate of this bug. ***
Comment 6 Morten Welinder 2017-08-28 14:10:19 UTC
I'm sure we're not doing anything special.

I can select the first character with a right-to-left motion of the mouse (ie., from the back), but not with a left-to-right motion.
Comment 7 Morten Welinder 2017-08-28 14:23:40 UTC
Actually, we are doing something mildly special in that we are setting a border
width for the view:

    gtk_container_set_border_width (GTK_CONTAINER (gtv->view), 5);

That's a dead kitten, btw.
Comment 8 Daniel Boles 2017-08-28 14:47:50 UTC
Created attachment 358601 [details]
test case showing Container:border-width breaking text selection

It sure is! And it's the culprit here.

Attached is a test case with 16 px of Container:border-width, showing that the issue affects all sides. It seems like the border-width causes the dragged coordinate to be shifted both rightwards and downwards before the text is selected (or not, as the case may be).
Comment 9 Jean Bréfort 2017-08-28 14:52:17 UTC
We can just fix it with:
    g_object_set (G_OBJECT (gtv->view), "margin", 5, NULL);
Comment 10 Daniel Boles 2017-08-28 21:02:34 UTC
Created attachment 358634 [details] [review]
TextView: Fix gesture coords with :border-width >0

Container:border-width caused the x/y coords converted to iters to be
offset inwards by that width, breaking positioning/selecting by gesture.

Fix by subtracting the :border-width in _widget_to_text_window_coords().

--

As noted here, this broke all kinds of gesture positions, not just selecting.
Comment 11 Daniel Boles 2017-08-28 21:28:08 UTC
Created attachment 358636 [details] [review]
TextView: Fix gesture coords with :border-width >0

Container:border-width caused the x/y coords converted to iters to be
offset inwards by that width, breaking positioning/selecting by gesture.

So, subtract :border-width in widget_to_text_window_coords(). This fixes
gesture positions, & plays fine with :margin & CSS margin/border/padding

N.B.: This is not to endorse :border-width. It’s gone in GTK+ 4 & weird
on a TextView: it’d be more intuitive to – if you must! – set it on the
TV parent. Really, please just use CSS instead. Still, it’s easy to fix.
Comment 12 Daniel Boles 2017-08-28 21:30:31 UTC
Attachment 358636 [details] pushed as bd7c87c - TextView: Fix gesture coords with :border-width >0
Comment 13 Daniel Boles 2017-08-29 09:19:10 UTC
There might be a follow-up commit required for conversion of coordinates in the opposite direction, window to widget coords, but I need to test that separately.