New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GTK] Disabled toolbar icons and button images are double size on hi-res screen #315
Comments
Snippet to reproduce: import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class DisabledButtonImageTest {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
shell.setText("Button Image");
Image image = display.getSystemImage(SWT.ICON_WARNING);
Button button = new Button(shell, SWT.FLAT);
button.setImage(image);
button.setEnabled(false);
shell.open();
while(!shell.isDisposed()) {
if(!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
} To test this at 200% scaling either use a Hi-DPI monitor or set an Environment Variable |
Reproduced the bug in XWayland (Wayland using GDK_BACKEND=x11). EDIT: This bug does affect Wayland. The issue is that GDK_SCALE=2 does not change the device zoom in Wayland, but it does in X11. To test this bug in Wayland I had to change my display scale directly from Fedora 36's settings. |
Affects Ubuntu with Eclipse 2022-03 (4.23) (see https://github.com/gama-platform/gama/issues/3460). Disabled icons for buttons in the Coolbar (contributed by |
Looking at this some more, to create the disabled image we copy from the image we get using getSystemImage. In this case, the icon is already scaled when it is first created. When creating the copy in the Image constructor, it copies the currentDeviceZoom and performs another scale up using cairo_surface_set_device_scale. This is why the image scaled 4x. The fix is to check if DPIUtil.getDeviceZoom() is equal to the copied currentDeviceZoom, and if it is, skip the scaling. I have a patch ready which I will upload in the morning eastern time. EDIT: ToolItem has this issue too. Testing on the same patch causes the ToolItem image to be correctly "sized" i.e not cut off. However it is much too large compared to the regular image. I suspect this is due to the image setting working differently but I'm not sure at the moment. Will try to find out before pushing the patch. |
Might be a clue in this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=568407 Maybe the fix for that bug wasn't applied to disabled images? |
I was able to find the issue on the toolbar icon size; it was due to a bug in ImageList. Pushed the fix. EDIT: Please test and let me know if there are any regressions that are caused by this patch. |
Describe the bug
I'm bringing this over from https://bugs.eclipse.org/bugs/show_bug.cgi?id=575492 as the problem still exists.
Disabled images in buttons and toolbar items are the wrong size when DPI scaling is at 200%
To Reproduce
Run Snippet at 200% scaling to see that the disabled button image is scaled incorrectly and is too big and off-centred.
Expected behavior
The disabled button image should be scaled correctly when DPI is at 200% scale.
Screenshots
Disabled button at 100% scale:
Disabled button at 200% scale:
Environment:
Additional OS info (e.g. OS version, Linux Desktop, etc)
Linux Mint Cinnamon X11. Didn't test on Wayland.
JRE/JDK version
AdoptOpeJDK 11.0.15
Version since
Worked OK in Eclipse 4.15, but not since
The text was updated successfully, but these errors were encountered: