Bug 123425 - Selection in StyledText looks weird
Summary: Selection in StyledText looks weird
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords: polish
: 112858 123935 125220 127786 128028 132447 137910 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-01-11 09:44 EST by Douglas Pollock CLA
Modified: 2009-08-19 13:55 EDT (History)
16 users (show)

See Also:


Attachments
StyledText with weird selection (57.59 KB, image/png)
2006-01-11 09:46 EST, Douglas Pollock CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Douglas Pollock CLA 2006-01-11 09:44:31 EST
I20060110-1026, GTK+ 2.8.8, KDE 3.4.3, X.org 6.8.2, Linux 2.6.14

I'll attach a screenshot.  There seems to be "gaps" in the selection in StyledText widgets.
Comment 1 Douglas Pollock CLA 2006-01-11 09:46:06 EST
Created attachment 32838 [details]
StyledText with weird selection
Comment 2 Steve Northover CLA 2006-01-11 10:08:00 EST
A festival for carets perhaps?
Comment 3 Ismael Juma CLA 2006-01-11 10:22:12 EST
Just a FYI, I can also see this with eclipe 3.2 M4, GTK+ 2.8.9, X.org 7.0 and Linux 2.6.15.
Comment 4 Douglas Pollock CLA 2006-01-11 10:23:07 EST
After mentioning this on IRC, I suspect this is GTK+ version specific.  It is likely not a recent change in our code base.  Talk to tashiro or ijuma on irc.freenode.net#eclipse-dev for more information (or me, for that matter).
Comment 5 Douglas Pollock CLA 2006-01-11 10:23:49 EST
pango 1.10.2
Comment 6 Billy Biggs CLA 2006-01-11 11:03:53 EST
The pango version may be the most critical (and whether pango-cairo is used).
There have been some bugs found recently with zero-width characters under
pango-cairo.  Just a guess though really.
Comment 7 Ismael Juma CLA 2006-01-11 11:06:41 EST
From the discussions on IRC, this happens with two versions of pango, 1.10.2 and 1.11.1.
Comment 8 Tom Hofmann CLA 2006-01-16 11:20:57 EST
*** Bug 123935 has been marked as a duplicate of this bug. ***
Comment 9 Felipe Heidrich CLA 2006-02-14 15:09:26 EST
*** Bug 127786 has been marked as a duplicate of this bug. ***
Comment 10 Francesco Gigli CLA 2006-02-15 17:16:03 EST
*** Bug 128028 has been marked as a duplicate of this bug. ***
Comment 11 Francesco Gigli CLA 2006-02-15 17:20:50 EST
same problem here
gtk+ 2.8.8
pango 1.10.3
cairo 1.0.2
Comment 12 Felipe Heidrich CLA 2006-02-16 12:26:43 EST
*** Bug 125220 has been marked as a duplicate of this bug. ***
Comment 13 Felipe Heidrich CLA 2006-02-16 17:25:48 EST
Billy:

I wrote a test code for this problem in C and it worked just fine, I got the same c code and I pasted it in a JNI method and compiled it as library, from java I only load the library and call the jni method and the problem happens.

SSQ told me that the some c library load by the java vm has a bug with float point math that causes this problem to happen. Billy, do you know anything about this ?
Comment 14 Billy Biggs CLA 2006-02-16 17:32:59 EST
If you see this it is likely a floating point precision problem in cairo.  Let
me find the magic code.
Comment 15 Billy Biggs CLA 2006-02-16 17:36:21 EST
Use this template at the start of your test application:

#include <gtk/gtk.h>
#include <fpu_control.h>

int main (int argc, char **argv)
{
    fpu_control_t fpu_control;

    _FPU_GETCW (fpu_control);
    fpu_control &= ~_FPU_EXTENDED;
    fpu_control |= _FPU_DOUBLE;
    _FPU_SETCW (fpu_control);

And see this cairo bug:

  https://bugs.freedesktop.org/show_bug.cgi?id=5200
Comment 16 Felipe Heidrich CLA 2006-02-16 18:37:28 EST
Thanks billy, you the man!

I verified that in extended fpu it works fine.
The problem here is in gdk_pango_layout_get_clip_region(), this func  returns a region that is one pixel to short when the planets are not aligned properly (so far they are: font, text, pango version, and last but not least: FPU mode).

The trivial fix is to flip the FPU to extended before calling gdk_pango_layout_get_clip_region() and restore it after. But that doesn't work, the metrics are computed by the pango layout and cached, I don't know when it gets computed, sometime during pango_draw or pango_size_get, etc.
Set extended right when the app start fixes the problem, but the VM probably has a reason to FPU to double mode.

Not sure I can fix this.
Comment 17 Douglas Pollock CLA 2006-02-17 10:43:45 EST
I've posted to https://bugs.freedesktop.org/show_bug.cgi?id=5200 -- mentioning that their current suggested patch does not work, and asking for a workaround.
Comment 18 Silenio Quarti CLA 2006-03-28 14:16:24 EST
*** Bug 132447 has been marked as a duplicate of this bug. ***
Comment 19 Michael Van Meekeren CLA 2006-04-05 17:01:33 EDT
this item is on the polish list for 3.2, will it be fixed for 3.2?
Comment 20 Felipe Heidrich CLA 2006-04-12 16:09:53 EDT
I can't get this to work with Eclipse, I change the code to flip the mpu mode to extended but (I think) the VM keeps flipping it back to double precision.
The fix worked for the simple testcase but with eclipse.

Comment 21 Billy Biggs CLA 2006-04-12 16:23:00 EDT
Note that the upstream bug is now fixed in pango CVS.
Comment 22 Steve Northover CLA 2006-04-20 12:08:47 EDT
Billy, we need to put in a work around for this but guard it with a version check and only run the code when we have to.  Can you help us determine which versions have the bug and which do not?
Comment 23 Dani Megert CLA 2006-04-21 05:44:42 EDT
*** Bug 137910 has been marked as a duplicate of this bug. ***
Comment 24 Felipe Heidrich CLA 2006-05-02 11:46:33 EDT
I just had my machine updated to Fedora Core 5 and I have the bug now:
-sh-3.1$ rpm -q gtk2 glib2 pango cairo
gtk2-2.8.17-1.fc5.1
glib2-2.10.2-1.fc5.1
pango-1.12.1-1.fc5.1
cairo-1.0.4-1

Past week I was running gtk-2.8.17, glib-2.10.2, cairo-1.0.4, and pango-1.13.0 in my old Fedora Core 3 and it was all working fine.
I think this bug got fixed between pango 1.12.1 and pango 1.13.0. I verify it and report back.
Comment 25 Ben Konrath CLA 2006-05-02 13:23:41 EDT
(In reply to comment #24)
> I think this bug got fixed between pango 1.12.1 and pango 1.13.0. I verify it
> and report back.

I think you're right - at least that's what the changelog says :)

http://cvs.gnome.org/viewcvs/pango/ChangeLog?view=markup
 

Comment 26 Felipe Heidrich CLA 2006-05-02 17:08:01 EDT
I verified it works on pango 1.13.0
Comment 27 Felipe Heidrich CLA 2007-04-30 11:11:49 EDT
closing
Comment 28 Felipe Heidrich CLA 2009-08-19 13:55:45 EDT
*** Bug 112858 has been marked as a duplicate of this bug. ***