Bug 530693 - [GTK2] Editor redrawn incorrectly on horizontal scrolling
Summary: [GTK2] Editor redrawn incorrectly on horizontal scrolling
Status: CLOSED DUPLICATE of bug 530841
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P5 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
: 542516 (view as bug list)
Depends on:
Blocks: 530841
  Show dependency tree
 
Reported: 2018-02-03 18:24 EST by Ivan CLA
Modified: 2018-12-07 08:22 EST (History)
6 users (show)

See Also:


Attachments
Screenshot 1 (61.16 KB, image/png)
2018-02-03 18:24 EST, Ivan CLA
no flags Details
Screenshot 2 (82.95 KB, image/png)
2018-02-03 18:24 EST, Ivan CLA
no flags Details
Screenshot 3 (58.86 KB, image/png)
2018-02-03 18:25 EST, Ivan CLA
no flags Details
Screenshot 4 (88.28 KB, image/png)
2018-02-04 10:45 EST, Ivan CLA
no flags Details
GTK2 (114.39 KB, image/png)
2018-02-09 19:21 EST, Ivan CLA
no flags Details
GTK2 Dark (100.50 KB, image/png)
2018-02-09 19:22 EST, Ivan CLA
no flags Details
GTK3 (112.59 KB, image/png)
2018-02-09 19:22 EST, Ivan CLA
no flags Details
GTK3 Stripped (109.66 KB, image/png)
2018-02-09 19:23 EST, Ivan CLA
no flags Details
GTK3 Stripped Dark (108.71 KB, image/png)
2018-02-09 19:25 EST, Ivan CLA
no flags Details
gtk3-widget-factory (96.94 KB, image/png)
2018-02-09 19:25 EST, Ivan CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan CLA 2018-02-03 18:24:11 EST
Created attachment 272529 [details]
Screenshot 1

When horizontal scroll-bar in editor is scrolled the content is redrawn incorrectly. Subjectively looks like eclipse tries to draw editor window multiple times with different indentation from left.

The smaller width of window to the left from "Editor" (usually "Project Explorer") - more times it is redrawn. The pixel shift of all draws is approximately equal to left window width.

This happens only in Photon + GTK2. Photon + GTK3, Oxygen + GTK2/3, Neon + GTK2/3 work normally. Usage of GTK3 is not an option for me of course, because it has huge buttons and useless on small screens. So meanwhile using Oxygen + GTK2.

This happens in all editors I tried (Java, text, gradle), so looks irrelevant to certain editor specifics.

Eclipse Java EE IDE for Web Developers.
Version: Photon Milestone 4 (4.8.0M4)
Build id: 20171214-1849
OS: Linux, v.4.4.0-111-generic, x86_64 / gtk 2.24.24
Comment 1 Ivan CLA 2018-02-03 18:24:48 EST
Created attachment 272530 [details]
Screenshot 2
Comment 2 Ivan CLA 2018-02-03 18:25:09 EST
Created attachment 272531 [details]
Screenshot 3
Comment 3 Andrey Loskutov CLA 2018-02-04 02:15:51 EST
Can you please attach your GTK2 version, and your DE/distribution names? Just to be sure, is this still reproducible on 4.8 M5 build? Are you using wayland? Does this also appear in the Console view on scrolling? 

Movimg to SWT because it is probably styled test related.
Comment 4 Ivan CLA 2018-02-04 10:45:28 EST
Not sure what is DE/destribution names.
GTK2: ii  libgtk2.0-0:amd64                       2.24.24-0ubuntu1~trusty1 amd64                    GTK+ graphical user interface library
Linux: xubuntu 14.04.5 LTS (Xfce 4.10).

Have no Wayland, X11 only.

As for console - yes, it also has this bug, didn't notice earlier.

After installing Photon M5 (Build id: 20180202-1214), the bug still exists. New screenshot-4 (console view) is from M5.


Btw vertical scrolling works Ok, it even fixes the view after corruption by horizontal scrolling (probably because view is just redrawn).
Comment 5 Ivan CLA 2018-02-04 10:45:48 EST
Created attachment 272538 [details]
Screenshot 4
Comment 6 Leo Ufimtsev CLA 2018-02-05 09:46:29 EST
Thank you for bug submission. 

We currently don't fix gtk2 bugs anymore, all our efforts are in fixing any outstanding gtk3 bugs.
So while we would perhaps accept a patch, we don't have man-power to investigate the issue ourselves. 

Maybe we should focus on looking into what's stopping you from moving to gtk3.
(We've been using gtk3 for over 2 years ourselves now).

If something is stopping you from moving to gtk3, then we should add the issue to:
527444 – (Gtk3ShowStoppers) [GTK3] Umbrella bug for GTK3 showstoppers
https://bugs.eclipse.org/bugs/show_bug.cgi?id=527444

Afaik, the big button issue was fixed a while ago.
Have you tried with gtk3.22 and recent eclipse?

Is it specific to your theme?
Comment 7 Leo Ufimtsev CLA 2018-02-07 10:36:54 EST
Triaging Gtk2-only bugs. Please see Bug 530841 for details.
If this bug is not gtk2-specific, please indicate.
Thank you for your bug submission.
Comment 8 Ivan CLA 2018-02-09 19:21:30 EST
The main concern as for GTK3 is a toolbar and maybe some related components.
To show the difference between gtk2 and gtk3 I created more screenshots.
a) Screenshot_gtk2.png - just GTK2.
b) Screenshot_gtk2_dark.png - GTK2 with dark theme.
c) Screenshot_gtk3.png - just GTK3.
d) Screenshot_gtk3_stripped.png - GTK3 with less toolbar buttons (to fit screen width).
e) Screenshot_gtk3_stripped_dark.png - GTK3 with less toolbar buttons and dark theme.
f) gtk3-widget-factory.png - output of gtk3-widget-factory tool.

Explanation:
1) Comparing a) and c) it is obvious even without measuring the toolbar elements are wider in GTK3. The toolbar even don't fit the screen width and shifted to new toolbar line.
2) Comparing a) and d) we see obvious thing - toolbar uses different bg color and looks like imported from other theme. Less obvious - all headers of all views ("Markers", "Project Explorer", "Outline" etc) and also the main toolbar are a couple of pixels higher in GTK3. 2px here, 2px there and in total on small screen you see much less.
3) Comparing b) and e) we see that for GTK2 toolbar is of somewhat its own color, but this color is equal to some bg colors on the screen. For GTK3  toolbar looks completely corrupted, it doesn't follow any theme rules.

In general looks like toolbars are rendered with some "engine" completely different from other controls on the screen. While in GTK2 it is almost not noticeable even on exotic themes, in GTK3 it always attracts attention and irritates.

The last GTK3 I can test is 3.18.9. But I don't think the version is relevant, because this problem exists for ages.
Additionally checked photon-M5 on Windows-8.1, it looks almost the same as on GTK2 in both classic and dark themes.

So what should I do next? Create a separate issue for GTK3 or this one is good?
Comment 9 Ivan CLA 2018-02-09 19:21:57 EST
Created attachment 272624 [details]
GTK2
Comment 10 Ivan CLA 2018-02-09 19:22:18 EST
Created attachment 272625 [details]
GTK2 Dark
Comment 11 Ivan CLA 2018-02-09 19:22:38 EST
Created attachment 272626 [details]
GTK3
Comment 12 Ivan CLA 2018-02-09 19:23:04 EST
Created attachment 272627 [details]
GTK3 Stripped
Comment 13 Ivan CLA 2018-02-09 19:25:19 EST
Created attachment 272628 [details]
GTK3 Stripped Dark
Comment 14 Ivan CLA 2018-02-09 19:25:46 EST
Created attachment 272629 [details]
gtk3-widget-factory
Comment 15 Leo Ufimtsev CLA 2018-02-12 16:26:45 EST
(In reply to Ivan Bondarenko from comment #8)

Thank you for your feedback.

> The main concern as for GTK3 is a toolbar and maybe some related components.
> To show the difference between gtk2 and gtk3 I created more screenshots.
> a) Screenshot_gtk2.png - just GTK2.
> b) Screenshot_gtk2_dark.png - GTK2 with dark theme.
> c) Screenshot_gtk3.png - just GTK3.
> d) Screenshot_gtk3_stripped.png - GTK3 with less toolbar buttons (to fit
> screen width).
> e) Screenshot_gtk3_stripped_dark.png - GTK3 with less toolbar buttons and
> dark theme.
> f) gtk3-widget-factory.png - output of gtk3-widget-factory tool.
> 
> Explanation:
> 1) Comparing a) and c) it is obvious even without measuring the toolbar
> elements are wider in GTK3. The toolbar even don't fit the screen width and
> shifted to new toolbar line.

Note, the wide toolbar business has been fixed a while ago:
456345 – [GTK3] Toolbars, Editor tabs, status line way too large
https://bugs.eclipse.org/bugs/show_bug.cgi?id=456345

Try latest nightly:
http://download.eclipse.org/eclipse/downloads/

> 2) Comparing a) and d) we see obvious thing - toolbar uses different bg
> color and looks like imported from other theme. Less obvious - all headers
> of all views ("Markers", "Project Explorer", "Outline" etc) and also the
> main toolbar are a couple of pixels higher in GTK3. 2px here, 2px there and
> in total on small screen you see much less.
> 3) Comparing b) and e) we see that for GTK2 toolbar is of somewhat its own
> color, but this color is equal to some bg colors on the screen. For GTK3 
> toolbar looks completely corrupted, it doesn't follow any theme rules.
> 
> In general looks like toolbars are rendered with some "engine" completely
> different from other controls on the screen. While in GTK2 it is almost not
> noticeable even on exotic themes, in GTK3 it always attracts attention and
> irritates.

Eclipse with Darktheme works well with the reference Gnome3/Adwaita-dark implementation.
Other gtk3 themes tend to be buggy and there are problems. 

> 
> The last GTK3 I can test is 3.18.9. But I don't think the version is
> relevant, because this problem exists for ages.

Gtk3 version does actually make quite a big difference. There was a big change in theming support
starting with gtk3.20 and above. (A separate .css support file for pre3.20 and post.320 is used.).
So I would try gtk3.20+, gtk3.22 works best.

> Additionally checked photon-M5 on Windows-8.1, it looks almost the same as
> on GTK2 in both classic and dark themes.
> 
> So what should I do next? Create a separate issue for GTK3 or this one is
> good?

Given your situation, my recommendation is as following:
*) If you're using gtk3.0 - gtk3.19, consider using white theme if current dark theme is not adequate.
*) If you're using gtk3.20 or 3.22, dark theme (with Adwaita) works well. If there are issues, please submit bugs.

*) If you're using gtk3.20 - 3.22 with a custom theme & dark theme and it doesn't look well, then it might be a limitation of that particular gtk3 theme as SWT on gtk3 currently uses OS theme colors.


In general, anything not related to original bug report is best put into a separate bug/ticket and maybe leave a reference to the old ticket in the new one. Keeping problems in separate bugs makes it easier to keep track of them.
Comment 16 Leo Ufimtsev CLA 2018-02-12 16:27:02 EST
Let me know if you have questions or I can help further.
Comment 17 Ivan CLA 2018-02-14 05:33:48 EST
As for dark theme, I used it only for demonstration.
However if I understood you correctly it may be related to Linux's GTK3 theme (either because of GTK3 version or because of CSS configuration). I use one of standard xubuntu themes (Greybird as I remember) with my modifications and looks like toolbars looks different in other themes (Equinox, Bluebird etc). Need some time to experiment here.
Comment 18 Leo Ufimtsev CLA 2018-02-14 10:34:27 EST
(In reply to Ivan Bondarenko from comment #17)
> As for dark theme, I used it only for demonstration.
> However if I understood you correctly it may be related to Linux's GTK3
> theme (either because of GTK3 version or because of CSS configuration). I
> use one of standard xubuntu themes (Greybird as I remember) with my
> modifications and looks like toolbars looks different in other themes
> (Equinox, Bluebird etc). Need some time to experiment here.

Interesting to hear.

In my experience, Gtk3.0 - 3.20 is a bit of a roller coaster. However, Gtk3.22 is stable.
I expect themes based off of Gtk 3.22's reference theme (Adwaita) will probably function well. But in my experience all the stuff between Gtk3.0-3.20 is a bit of a hit-and miss. Atm I'm using Gnome3/Adwaita, works well.

Let me know if I can help further.
Comment 19 Eric Williams CLA 2018-07-10 13:57:31 EDT
Please note: GTK2 support for SWT is being dropped in Eclipse 4.10 / SimRel 2018-12 release. 

See the following mail for more info: http://dev.eclipse.org/mhonarc/lists/cross-project-issues-dev/msg15783.html
Comment 20 Bing-Yi Wong CLA 2018-07-12 03:14:24 EDT
I believe I have found a fix for the original problem that editor redrawn incorrectly on horizontal scrolling.

In Canvas.java, scrollInPixels(), there is some code like this:

if (Cairo.cairo_version() < Cairo.CAIRO_VERSION_ENCODE(1, 12, 0)) {
	GDK.gdk_cairo_set_source_window(cairo, window, 0, 0);
} else {
	Cairo.cairo_push_group(cairo);
	GDK.gdk_cairo_set_source_window(cairo, window, 0, 0);
	Cairo.cairo_paint(cairo);
	Cairo.cairo_pop_group_to_source(cairo);
}

This code was GTK3-only in 4.7.3, and there was some other code for GTK2.  However, the GTK2 code is removed in 4.8.0 for some reason I don't know, so eclipse goes through this code even with GTK2 now.

Now, we have two code branches to go, depending on cairo version.  I believe someone has found the push_group/pop_group approach does not work with cairo<1.12, so we have the version check.  But, I found it does not work with GTK2, too, with any version of cairo.  Instead, looks like the upper branch - simple gdk_cairo_set_source_window - works just well.

So my fix is to choose the upper branch if GTK2:

change the code from this
if (Cairo.cairo_version() < Cairo.CAIRO_VERSION_ENCODE(1, 12, 0)) {
to this
if (!GTK.GTK3 || Cairo.cairo_version() < Cairo.CAIRO_VERSION_ENCODE(1, 12, 0)) {
Comment 21 Alexander Kurtakov CLA 2018-07-12 10:10:11 EDT
Marking the bug as duplicate of the GTK2 tracker as no work for GTK2 issues will happen. Please reopen if you still face the issue using GTK 3.x.

*** This bug has been marked as a duplicate of bug 530841 ***
Comment 22 Bing-Yi Wong CLA 2018-07-12 12:55:26 EDT
Ok then.  Just want to add that this issue can also be worked around by using cairo 1.11.4.
Comment 23 Anton Krug CLA 2018-11-05 11:17:36 EST
Could be:

if (GTK.GTK_VERSION < OS.VERSION(3, 0, 0) || Cairo.cairo_version() < Cairo.CAIRO_VERSION_ENCODE(1, 12, 0)) {

solution to the GTK2 issue as well?
Comment 24 Andrey ''Bass'' Shcheglov CLA 2018-12-07 08:22:41 EST
*** Bug 542516 has been marked as a duplicate of this bug. ***