eclipse-platform / eclipse.platform.swt

Eclipse SWT
https://www.eclipse.org/swt/
Eclipse Public License 2.0
101 stars 123 forks source link

shell.setImage - icon is not set on ubuntu 22 #266

Open elaskavaia opened 1 year ago

elaskavaia commented 1 year ago

Describe the bug Setting application icon no longer works on Ubuntu 22 (and RHEL 8) You can also see that eclipse installer and any eclipse apps installed from zip do not have proper icon It works on Ubuntu 20 and below

To Reproduce import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell;

public class MainClass { public static void main(String[] a) { Display d = new Display(); Shell s = new Shell(d); s.setSize(500, 500); s.setImage(new Image(d, "icon.png")); // should be a real .png file in current dir from where it is launched, I used 32 px s.setText("An application icon example"); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); } }

Expected behavior Expected to see icon change in launch bar (usually bar on the left but depends on window manager)

Screenshots Default icon is shown (looks like gears)

Environment:

  1. Select the platform(s) on which the behavior is seen:

      • [] All OS
      • [ ] Windows
      • [x ] Linux
      • [ ] macOS
  2. Additional OS info (e.g. OS version, Linux Desktop, etc) Ubuntu 22 - default image ubuntu-22.04-desktop-amd64.iso gtk 3.24.33 gtk 2.24.33 gtk 4.6.2

  3. JRE/JDK version - openjdk 11

Version since I did not check other version, it may not work in any I tried 3.120 (gtk)

elaskavaia commented 1 year ago

Screenshot from 2022-07-20 13-47-53

this is screenshot of eclipse launcher, but they all look the same

joel-majano commented 1 year ago

Are you using Wayland? You can check in your system settings.

elaskavaia commented 1 year ago

This is out of the box installation of ubuntu-22.04-desktop-amd64.iso - minimal install on virtual box (but I don't think it matter about virual box)? The windowing system is Wayland indeed

Is there is workaround I will be happy to hear about it

joel-majano commented 1 year ago

Looked into this more. It's a result of Wayland not supporting setting icons programatically. See: https://gitlab.gnome.org/GNOME/gtk/-/issues/1602.

Now from some research this by including a *.desktop file with Eclipse. This might need to be accompanied by calling GLib.set_prgname() but not sure about this part. I won't be able to fix this myself but hopefully this helps.