Bug 467983 - Mouse cursor rendering issue under Linux and GTK3
Summary: Mouse cursor rendering issue under Linux and GTK3
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.5   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
: 471461 507938 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-05-22 05:38 EDT by Pierre-Charles David CLA
Modified: 2018-08-16 15:03 EDT (History)
8 users (show)

See Also:


Attachments
Broken cursor rendering with GTK3 (71.52 KB, image/png)
2015-05-22 05:38 EDT, Pierre-Charles David CLA
no flags Details
Correct cursor rendering with SWT_GTK3=0 (75.77 KB, image/png)
2015-05-22 05:39 EDT, Pierre-Charles David CLA
no flags Details
New screenshot using Oxygen.1a and Ecore Tools 3.3 (93.57 KB, image/png)
2017-12-18 07:43 EST, Pierre-Charles David CLA
no flags Details
Sample SWT program to try to reproduce the issue (4.15 KB, application/zip)
2018-01-19 03:14 EST, Pierre-Charles David CLA
no flags Details
Result of the sample program when run with SWT_GTK3=0 (2.68 KB, image/png)
2018-01-19 03:14 EST, Pierre-Charles David CLA
no flags Details
Result of the sample program when run with SWT_GTK3=1 (2.53 KB, image/png)
2018-01-19 03:15 EST, Pierre-Charles David CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre-Charles David CLA 2015-05-22 05:38:42 EDT
Created attachment 253667 [details]
Broken cursor rendering with GTK3

Using GEF from a Marc RC1 package, GEF version: 3.10.0.201505170205 (Build id: 3.9.100.201404071359), under Ubuntu 15.04 (64 bits), Java 1.8 and org.eclipse.swt.internal.gtk.version=3.14.12.

Steps to reproduce:
1. Install the GEF Logic example.
2. Create a new Logic diagram and a "Flow Container" in it.
3. Select the "Connection" tool in the palette.
4. Move the mouse cursor over the green area on the left of the container.

When using GTK3 under Linux (the default now), the transparency of the decorated cursor is broken (see attached screenshot).

When running the same scenario on the same Eclipse with SWT_GTK3=0, the cursor rendering is fine (I'll attach the screenshot for reference).

I'm not sure this is GEF/Draw2D-specific or directly a problem in SWT; feel free to move where appropriate.
Comment 1 Pierre-Charles David CLA 2015-05-22 05:39:30 EDT
Created attachment 253669 [details]
Correct cursor rendering with SWT_GTK3=0
Comment 2 Alexander Nyßen CLA 2015-05-22 05:46:32 EDT
This is an SWT problem (as its platform specific).
Comment 3 Alexander Kurtakov CLA 2017-12-14 18:53:18 EST
Can you still reproduce this with Oxygen?
Comment 4 Pierre-Charles David CLA 2017-12-18 07:43:21 EST
Created attachment 271939 [details]
New screenshot using Oxygen.1a and Ecore Tools 3.3

Yes, still reproducible using: Oxygen.1a (Build id: 20171005-1200) with:
* java.runtime.version=1.8.0_151-8u151-b12-1~deb9u1-b12
* org.eclipse.swt.internal.gtk.version=3.22.11

See the new attached screenshot.

This is under Debian 9.2 "stretch" (stable), using plain X11 (no Wayland) and GNOME Shell.

I had to use Ecore Tools (which is based on Sirius, itself based on GEF Legacy), as the GEF examples I used in the original steps to reproduce seem broken (by bug #522575).
Comment 5 Florian Barbin CLA 2017-12-22 09:05:07 EST
This issue is still reproducible using Photon M4 (with Ecore Tools), under Debian 9 with GNOME.
Comment 6 Alexander Kurtakov CLA 2018-01-15 15:37:10 EST
Can you come up wiht pure SWT snippet showing the issue?
Comment 7 Pierre-Charles David CLA 2018-01-16 09:01:21 EST
(In reply to Alexander Kurtakov from comment #6)
> Can you come up wiht pure SWT snippet showing the issue?

I'll try, but not sure I'll have the time to look at this. From what I've seen it seems related to the use of custom cursors built using org.eclipse.swt.graphics.Cursor.Cursor(Device, ImageData, ImageData, int, int) with BMP file as the image and a GIF for the mask as in https://github.com/eclipse/gef-legacy/blob/master/org.eclipse.gef/src/org/eclipse/gef/SharedCursors.java.
Comment 8 Pierre-Charles David CLA 2018-01-19 03:14:28 EST
Created attachment 272336 [details]
Sample SWT program to try to reproduce the issue

I tried to reproduce the issue with a plain SWT program (attached), but got a very strange result that I don't understand: with this sample, the cursor is *correct* when using Gtk3 (v3.22.11 to be precise) but the bug can be seen when switching to Gtk2 (v2.24.31). This is the complete opposite of what I see, on the same machine (I checked again), when in the contexte of GMF diagram/canvas.
Comment 9 Pierre-Charles David CLA 2018-01-19 03:14:59 EST
Created attachment 272337 [details]
Result of the sample program when run with SWT_GTK3=0
Comment 10 Pierre-Charles David CLA 2018-01-19 03:15:14 EST
Created attachment 272338 [details]
Result of the sample program when run with SWT_GTK3=1
Comment 11 Rudolf Hornig CLA 2018-07-06 12:14:56 EDT
I've just fixed this in my own codebase and indeed, if you take a look at the code of the SharedCursors class: https://github.com/eclipse/gef-legacy/blob/master/org.eclipse.gef/src/org/eclipse/gef/SharedCursors.java#L46

You will notice that the code passes the image data and mask data in reverse order when it creates the static cursors with the createCursor(surceName, maskName) call:

CURSOR_PLUG = createCursor("icons/plugmask.gif", "icons/plug.bmp"); 

while:
private static Cursor createCursor(String sourceName, String maskName)

This was probably a GTK2 specific error that was mistakenly fixed this way. That's why you are seeing correct behavior with GTK3, while incorrect on GTK2 if you test it with a proper call.

Long story short, this may need to be fixed in SWT's GTK2 code path (however I doubt they will do that now. And also it must be fixed in GEF so it would work properly on GTK3. I doubt that GEF3 will be released/fixed for this also as it's a legacy code now...

What I did, was that copied out the cursor files and fixed the issue with the creation in my own code and then set my own default icons for the tools i needed. (on connection tool, the editpart's drag tracker components and on some tools in the palette).
Comment 12 Eric Williams CLA 2018-07-06 13:28:22 EDT
Sounds like this is a bug in GEF, running the attached SWT snippet on GTK3 worked perfectly for me. GTK2 won't be fixed as SWT-GTK2 isn't in active development any more.
Comment 13 Pierre-Charles David CLA 2018-07-11 04:43:56 EDT
*** Bug 507938 has been marked as a duplicate of this bug. ***
Comment 14 Eric Williams CLA 2018-07-12 10:05:05 EDT
(In reply to Eric Williams from comment #12)
> Sounds like this is a bug in GEF, running the attached SWT snippet on GTK3
> worked perfectly for me. GTK2 won't be fixed as SWT-GTK2 isn't in active
> development any more.

Update: 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 15 Eric Williams CLA 2018-08-14 17:04:42 EDT
(In reply to Eric Williams from comment #14)
> (In reply to Eric Williams from comment #12)
> > Sounds like this is a bug in GEF, running the attached SWT snippet on GTK3
> > worked perfectly for me. GTK2 won't be fixed as SWT-GTK2 isn't in active
> > development any more.
> 
> Update: 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

Marking this as WONTFIX as per this comment.
Comment 16 Eric Williams CLA 2018-08-16 15:03:28 EDT
*** Bug 471461 has been marked as a duplicate of this bug. ***