Skip to content

Replace getDeviceZoom() call in ImageTransfer class #194

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

Open
ShahzaibIbrahim opened this issue Jan 20, 2025 · 3 comments · May be fixed by eclipse-platform/eclipse.platform.swt#2158
Open
Assignees
Labels
HiDPI A HiDPI-Related Issue or Feature SWT Issue for SWT
Milestone

Comments

@ShahzaibIbrahim
Copy link

ShahzaibIbrahim commented Jan 20, 2025

I have tried finding issue with the usage of getDeviceZoom in org.eclipse.swt.dnd.ImageTransfer.nativeToJava(TransferData) using example ClipboardExample class Image transfer option. No visible issue found.

Update:

While running the ClipboardExample on a primary monitor set to 150% scaling, the following behavior was observed:

  • Selecting an image from the file system and pressing the Copy button copies the image data to the clipboard with the DeviceZoom value set to 150% (the scaling of the primary monitor).

  • Moving the application shell to a secondary monitor with 100% scaling and pressing the Paste button retrieves the image data from the clipboard and displays the image based on the original DeviceZoom (150% from the primary monitor).
    This results in the pasted image appearing larger on the secondary monitor, as it is rendered with the DeviceZoom of the primary monitor instead of adapting to the scaling of the current monitor.

Steps to reproduce:

  1. Run the ClipboardExample with following VM arguments

-Dswt.autoScale.updateOnRuntime=true
-Dswt.autoScale=quarter

  1. Open an image on primary monitor (150%) and press copy button

Image

  1. Move the shell to other monitor (200%) and press paste button

Image

Observed Behavior:

The pasted image appears larger on the secondary monitor because the image data uses the DeviceZoom from the primary monitor (150%) instead of adjusting to the scaling of the current monitor (100%).

Suggested Solution:

To address this issue, the image data copied to the clipboard should not retain the zoom level from the original monitor. Instead, the application should adapt the zoom level dynamically based on the context of the monitor where the image is pasted. This ensures consistent rendering across monitors with different scaling factors.

Hint

@ShahzaibIbrahim ShahzaibIbrahim added SWT Issue for SWT HiDPI A HiDPI-Related Issue or Feature labels Jan 20, 2025
@ShahzaibIbrahim ShahzaibIbrahim moved this to 🔖 Ready: Atomic in HiDPI Jan 20, 2025
@HeikoKlare HeikoKlare added this to the 4.36 M1 milestone Jan 20, 2025
@HeikoKlare
Copy link
Contributor

Marked this with priority "high" as we are unsure about the effects and the intended meaning of the usage in this case yet.

@ShahzaibIbrahim ShahzaibIbrahim self-assigned this Jan 21, 2025
@akoch-yatta
Copy link

After discussing the issue with Shahzaib my opinion is that the whole implementation doesn't make much sense in monitor-specific scaling setting. There is not real contract defined in the method, javadoc only states, that it should return ImageData. What we probably could or should do is pass a target zoom via TransferData, to define the zoom of the ImageData, that is returned to at least get rid of the getDeviceZoom call. Nevertheless the usage of the ImageTransfer is not existent, at least not in the platform.

@HeikoKlare
Copy link
Contributor

For the record: we have no usages of that class in our product.

@fedejeanne fedejeanne modified the milestones: 4.36 M1, 4.36 M3 Apr 16, 2025
@arunjose696 arunjose696 self-assigned this May 13, 2025
@arunjose696 arunjose696 moved this from 🔖 Ready: Atomic to 🏗 In Work: Short in HiDPI May 13, 2025
@arunjose696 arunjose696 moved this from 🏗 In Work: Short to 👀 In Review in HiDPI May 27, 2025
@akoch-yatta akoch-yatta moved this from 👀 In Review to ✅ Approved in HiDPI Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HiDPI A HiDPI-Related Issue or Feature SWT Issue for SWT
Projects
Status: ✅ Approved
Development

Successfully merging a pull request may close this issue.

5 participants