-
Notifications
You must be signed in to change notification settings - Fork 166
Fix zoom issue during copy paste in clipboard example #2158
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
base: master
Are you sure you want to change the base?
Conversation
56fcbd4
to
a80f142
Compare
e501e52
to
c691984
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is sound. Always using the 100% version of an image via copy/paste makes sense. I was wondering about situations where an image is provided in at different resolution for different zooms (such as we do for icons with the @2x
version or as would be possible for SVGs), but that does not seem to be a reasonable use case for copy/paste / DnD and in any case you would not know which zoom to actually use.
In addition, this aligns the implementation with the (also HiDPI-aware) implementation on MacOS (and Linux).
I have tested the change on Windows and MacOS (as the ClipboardExample is OS-agnostic). On Windows, I tested different primary monitor zooms (including values that are mapped to both device zooms of 100% and 200% with default int200-autoscaling).
It seems to work as expected.
I have also tested with monitor-specific scaling enabled (i.e., running the snippet with -Dswt.autoScale.updateOnRuntime=true
) on a two-monitor setup with 200% and 100%. Behavior was completely broken before when switching between the monitors and now behaves properly fine and just as expected.
Actually, I think this is the proper solution for basically the same issue discussed 9 years ago: https://bugs.eclipse.org/bugs/show_bug.cgi?id=493047
There also a proposal for always using the image data at 100% was made, but was ignored in favor of using the adaptations to the ClipboardExample
.
So I am all for merging this for 4.37 M1. But since this affects integral copy/paste behavior, I would like to have someone else have a look at the change and its behavior as well (@fedejeanne @akoch-yatta).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave it a short test round to see if a find any issue, but behavior looks good to me. Additionally I think using the zoom of 100% aligns now with the behavior of copy&paste of images in windows overall, therefor a +1 from me
Just one minor request @arunjose696: could you please improve the commit message to have a short, comprehensive header and more information in a separated explaining body? You may just restructure the existing commit message or also take parts of your PR message for a more expressive commit body. See also the commit message commendations. |
c691984
to
33f0ba6
Compare
This pull request changes some projects for the first time in this development cycle.
An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patch
Further information are available in Common Build Issues - Missing version increments. |
33f0ba6
to
a84a61b
Compare
This pull request changes some projects for the first time in this development cycle.
An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patch
Further information are available in Common Build Issues - Missing version increments. |
Done, should I patch my branch as per the bots comment? |
Thank you, but please only link to issues in the official SWT repository, not in the one we use for our work planning. In this case, we don't have an issue in this repo to link to, so you can just leave out those links. Sorry if I confused here by linking to the commit message recommendations.
In general, yes, but please wait until the master branch is open again as the patch is currently not correct because we are in the transition to the new development stream. Once that's done, the bot should creat a proper patch proposal that you can add as a separate commit to the PR. It will contain required version bumps for the new development cycle. |
Yeah, I misunderstood I thought those were the commit message guidelines for eclipse-platform. Thanks for clarifying! 😅 Looks like I’ll need to go back and edit all the commit messages for other PRs I just updated. |
Previously, when copying an image in the clipboard example, the image at the current zoom level was stored to clipboard using getImageDataAtCurrentZoom(). However, in normal Windows behavior (e.g., Paint), images are always copied at their original size regardless of the current zoom. When pasting, the image is pasted at 100% zoom, and the application handles zoom internally when displaying the image. To match this behavior, copy and paste now always handle images at 100% scale, ignoring the current zoom and leaving zoom handling to the image class when it is fetched for display.
a84a61b
to
34111e8
Compare
Copy and paste no longer tries to autoscale the image. The image is always copied and pasted at 100% zoom.
The purpose of this change is to:
DPIUtil.get[Native]DeviceZoom()
Previously, when copying an image in the clipboard example, the image at the current zoom level was stored to clipboard using
getImageDataAtCurrentZoom()
. However, in normal Windows behavior (e.g., Paint), images are always copied at their original size regardless of the current zoom. When pasting, the image is pasted at 100% zoom, and the application handles zoom internally when displaying the image.To match this behavior, copy and paste now always handle images at 100% scale, ignoring the current zoom and leaving zoom handling to the image class when it is fetched for display.