1717import java .nio .file .*;
1818import java .nio .file .Path ;
1919import java .util .*;
20+ import java .util .List ;
2021
2122import org .eclipse .swt .*;
2223import org .eclipse .swt .graphics .*;
2324import org .eclipse .swt .internal .*;
2425import org .eclipse .swt .internal .gtk .*;
2526import org .eclipse .swt .internal .gtk3 .*;
2627import org .eclipse .swt .internal .gtk4 .*;
28+ import org .eclipse .swt .widgets .*;
2729
2830/**
2931 * Instances of this class represent programs and
@@ -146,6 +148,7 @@ public ImageData getImageData() {
146148public ImageData getImageData (int zoom ) {
147149 if (iconPath == null ) return null ;
148150 ImageData data = null ;
151+ int scale = 1 ;
149152
150153 long gicon = OS .g_icon_new_for_string (Converter .javaStringToCString (iconPath ), null );
151154 if (gicon != 0 ) {
@@ -168,7 +171,15 @@ public ImageData getImageData(int zoom) {
168171 OS .g_object_unref (paintable );
169172 } else {
170173 long icon_theme = GTK3 .gtk_icon_theme_get_default ();
171- long gicon_info = GTK3 .gtk_icon_theme_lookup_by_gicon (icon_theme , gicon , 16 /*size*/ , 0 );
174+ Shell shell = Display .getCurrent ().getActiveShell ();
175+ if (shell != null ) {
176+ long shellHandle = shell .handle ;
177+ long window = GTK3 .gtk_widget_get_window (shellHandle );
178+ if (window != 0 ) {
179+ scale = GDK .gdk_window_get_scale_factor (window );
180+ }
181+ }
182+ long gicon_info = GTK3 .gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme , gicon , 16 /*size*/ , scale , 0 );
172183 if (gicon_info != 0 ) {
173184 pixbuf = GTK3 .gtk_icon_info_load_icon (gicon_info , null );
174185 OS .g_object_unref (gicon_info );
@@ -204,6 +215,10 @@ public ImageData getImageData(int zoom) {
204215 }
205216 }
206217 data .alphaData = alphaData ;
218+ if (scale == 1 && height > 16 && width > 16 ) {
219+ ImageData scaled = data .scaledTo (16 , 16 );
220+ data = scaled ;
221+ }
207222 } else {
208223 PaletteData palette = new PaletteData (0xFF0000 , 0xFF00 , 0xFF );
209224 data = new ImageData (width , height , 24 , palette , 4 , srcData );
0 commit comments