Bug 575492

Summary: [GTK] Disabled toolbar icons are double size on hi-res screen (200% scaling)
Product: [Eclipse Project] Platform Reporter: Phil Beauvoir <p.beauvoir>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: alexis.drogoul, loskutov
Version: 4.20Keywords: regression
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Screenshot of enabled and disabled toolbar icons
none
Screenshot of enabled and disabled toolbar icons
none
Test Project
none
Snippet to show disabled button image none

Description Phil Beauvoir CLA 2021-08-18 15:19:32 EDT
Created attachment 286966 [details]
Screenshot of enabled and disabled toolbar icons

Eclipse I20210818-0600

Linux Mint at 200% scaling. This can be emulated on non hi-res screens by setting the Environment variable GDK_SCALE=2

If a toolbar action is disabled the default icon is twice as big.
Comment 1 Phil Beauvoir CLA 2021-08-18 15:21:38 EDT
Created attachment 286967 [details]
Screenshot of enabled and disabled toolbar icons

New screenshot.
Comment 2 Phil Beauvoir CLA 2021-08-18 15:22:39 EDT
Created attachment 286968 [details]
Test Project

Test RCP project demonstrating the problem.
Comment 3 Andrey Loskutov CLA 2021-08-19 10:53:21 EDT
Broken latest in 4.20, works in 4.15.

Standalone SWT snippet (shows wrong icon size with GDK_SCALE=2)

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

public class Snippet380 {

public static void main (String [] args) {
	Display display = new Display ();
	Shell shell = new Shell (display);
	shell.setText("Snippet 360");

	Image image = display.getSystemImage(SWT.ICON_WARNING);

	ToolBar bar = new ToolBar (shell, SWT.BORDER | SWT.FLAT);
	Rectangle clientArea = shell.getClientArea ();
	bar.setBounds (clientArea.x, clientArea.y, 300, 64);
	for (int i = 0; i < 2; i++) {
		ToolItem item = new ToolItem (bar, 0);
		item.setImage (image);
		if (i == 1) {
			item.setEnabled (false);
		}
	}

	shell.open ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
}
Comment 4 Phil Beauvoir CLA 2022-01-19 14:42:05 EST
This also happens for SWT Buttons with an Image when the display is at 200% scale

Button = new Button()....
button.setImage(image);
button.setEnabled(true);

The image will be the wrong size
Comment 5 Phil Beauvoir CLA 2022-01-19 14:55:01 EST
Created attachment 287857 [details]
Snippet to show disabled button image

Snippet to show disabled button image
Comment 6 Phil Beauvoir CLA 2022-01-19 14:56:16 EST
(In reply to Phil Beauvoir from comment #4)
> This also happens for SWT Buttons with an Image when the display is at 200%
> scale
> 
> Button = new Button()....
> button.setImage(image);
> button.setEnabled(true);
> 
> The image will be the wrong size

That should be:

button.setEnabled(false);
Comment 7 Alexis Drogoul CLA 2022-08-21 10:50:39 EDT
The problem is still happening in Eclipse 2022-03 in a RCP product, only with disabled icons, and only in Linux (Ubuntu in that case). It can only be fixed when using ToolItems programmatically and forcing the disabled icon. But specifying the disabled icon to use in the plugin.xml does not help.
Comment 8 Phil Beauvoir CLA 2022-08-21 11:09:21 EDT
As SWT has moved to GitHub I opened an issue there:

https://github.com/eclipse-platform/eclipse.platform.swt/issues/315