Skip to content
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

[Multi-Monitor] SWT applications to support and work with different zoom values per Shell. #131

Open
niraj-modi opened this issue May 11, 2022 · 1 comment
Labels
help wanted Extra attention is needed Windows Happens on Windows OS

Comments

@niraj-modi
Copy link
Member

Copying @SyntevoAlex comment from #62 (comment)

To my understanding, the biggest blocker in current design is that in Windows, DPI is assigned per top-level window (Shell in terms of SWT) , whereas methods in DPIUtil do not use Shell as argument, so it uses a single DPI value for all monitors. With such design, we can only resort to supporting some scenarios at cost of other scenarios.

A proper fix would be to teach DpiUtil to consider Shell in question. Unfortunately, that will require massive (but probably not too complex) changes.

If someone volunteers to do that, I could assist to a reasonable extent.

@niraj-modi niraj-modi changed the title SWT/Eclipse to support different zoom values per shell [Multi-Monitor] SWT applications to support and work with different zoom values per Shell. May 11, 2022
@niraj-modi niraj-modi added the Windows Happens on Windows OS label May 11, 2022
@akoch-yatta
Copy link
Contributor

Hello,

I am currently working on the HiDPI issues on Windows and got most of it to a decent state. The issue I am currently struggling with is how to adjust Fonts properly, when there are different zoom levels. I think for the system fonts (font == null) I found a proper way to handle it, but when an explicit font is set, I do not see a good solution. The main problem is how the make sure, that the font is applied correctly to each control depending on the monitor zoom. Having it refreshed when the zoom change is happening is fine, but when it is set in between, e.g. as by the CSS SWT Engine, that does not work properly.

  1. The obvious idea was to adapt the place, where FontData is used to create a font. In Font.init(...) device.computePixels is called, which uses LOGPIXELSY to calculate the scale factor.
    int pixels = -(int)(0.5f + (height * OS.GetDeviceCaps(hDC, OS.LOGPIXELSY) / 72f));
    As this uses the primary monitor, this won't work in a monitor setup with different zoom levels. As there is only one instance of Display even with multiple monitors I don't see a way to handle it there.

  2. Second idea was to adapt Control::setFont to resize fonts if necessary. That does not sound great as well. When called, there is already a font created and should be set for this control and this could lead to the creation of a new one that needs to be managed. Additionally one would need to recalculate the font size taking the zoom of the primary monitor and the one of the controls monitor into consideration, which sounds rather complicated.

Anyone has another idea for an approach about that topic or am I missing a basic concept here?

@HeikoKlare HeikoKlare added the help wanted Extra attention is needed label Sep 28, 2023
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Apr 24, 2024
…as parameter

This contribution adds additional methods to scale different datatypes up or down by passing the target zoom level as parameter. All existing methods will delegate to the added methods and pass DPIUtil::deviceZoom as zoom.

Contributes to eclipse-platform#62
and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Apr 24, 2024
…as parameter

This contribution adds additional methods to scale different datatypes up or down by passing the target zoom level as parameter. All existing methods will delegate to the added methods and pass DPIUtil::deviceZoom as zoom.

Contributes to eclipse-platform#62
and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Apr 24, 2024
…as parameter

This contribution adds additional methods to scale different datatypes up or down by passing the target zoom level as parameter. All existing methods will delegate to the added methods and pass DPIUtil::deviceZoom as zoom.

Contributes to eclipse-platform#62
and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Apr 24, 2024
…as parameter

This contribution adds additional methods to scale different datatypes up or down by passing the target zoom level as parameter. All existing methods will delegate to the added methods and pass DPIUtil::deviceZoom as zoom.

Contributes to eclipse-platform#62
and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Apr 24, 2024
…as parameter

This contribution adds additional methods to scale different datatypes up or down by passing the target zoom level as parameter. All existing methods will delegate to the added methods and pass DPIUtil::deviceZoom as zoom.

Contributes to eclipse-platform#62
and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Apr 24, 2024
…as parameter

This contribution adds additional methods to scale different datatypes up or down by passing the target zoom level as parameter. All existing methods will delegate to the added methods and pass DPIUtil::deviceZoom as zoom.

Contributes to eclipse-platform#62
and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Apr 30, 2024
…as parameter

This contribution adds additional methods to scale different datatypes up or down by passing the target zoom level as parameter. All existing methods will delegate to the added methods and pass DPIUtil::deviceZoom as zoom.

Contributes to eclipse-platform#62
and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Apr 30, 2024
…as parameter

This contribution adds additional methods to scale different datatypes up or down by passing the target zoom level as parameter. All existing methods will delegate to the added methods and pass DPIUtil::deviceZoom as zoom.

Contributes to eclipse-platform#62
and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue May 3, 2024
…as parameter

This contribution adds additional methods to scale different datatypes up or down by passing the target zoom level as parameter. All existing methods will delegate to the added methods and pass DPIUtil::deviceZoom as zoom.

Contributes to eclipse-platform#62
and eclipse-platform#131
HeikoKlare pushed a commit to akoch-yatta/eclipse.platform.swt that referenced this issue May 3, 2024
…as parameter

This contribution adds additional methods to scale different datatypes up or down by passing the target zoom level as parameter. All existing methods will delegate to the added methods and pass DPIUtil::deviceZoom as zoom.

Contributes to eclipse-platform#62
and eclipse-platform#131
HeikoKlare pushed a commit that referenced this issue May 3, 2024
…as parameter

This contribution adds additional methods to scale different datatypes up or down by passing the target zoom level as parameter. All existing methods will delegate to the added methods and pass DPIUtil::deviceZoom as zoom.

Contributes to #62
and #131
amartya4256 added a commit to amartya4256/eclipse.platform.swt that referenced this issue May 6, 2024
…ch can be

extended by other resources and widgets.

Contributes to
eclipse-platform#62 and eclipse-platform#131
amartya4256 added a commit to amartya4256/eclipse.platform.swt that referenced this issue May 6, 2024
…ch can be

extended by other resources and widgets.

Contributes to
eclipse-platform#62 and eclipse-platform#131
amartya4256 added a commit to amartya4256/eclipse.platform.swt that referenced this issue May 8, 2024
…ch can be

extended by other resources and widgets.

Contributes to
eclipse-platform#62 and eclipse-platform#131
amartya4256 added a commit to amartya4256/eclipse.platform.swt that referenced this issue May 13, 2024
…ch can be

extended by other resources and widgets.

Contributes to
eclipse-platform#62 and eclipse-platform#131
amartya4256 added a commit to amartya4256/eclipse.platform.swt that referenced this issue May 13, 2024
…ch can be

extended by other resources and widgets.

Contributes to
eclipse-platform#62 and eclipse-platform#131
amartya4256 added a commit to amartya4256/eclipse.platform.swt that referenced this issue May 14, 2024
…ch can be

extended by other resources and widgets.

Contributes to
eclipse-platform#62 and eclipse-platform#131
amartya4256 added a commit to amartya4256/eclipse.platform.swt that referenced this issue May 15, 2024
…ch can be

extended by other resources and widgets.

Contributes to
eclipse-platform#62 and eclipse-platform#131
amartya4256 added a commit to amartya4256/eclipse.platform.swt that referenced this issue May 15, 2024
…ch can be

extended by other resources and widgets.

Contributes to
eclipse-platform#62 and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Nov 1, 2024
This commit adds a workaround for ImageDataProvider implementations that instantiate new Images inside the getImageData(zoom) implementation. This image can be instantiated with the wrong zoom in a multi zoom setting as Images still relay on the static zoom value in DPIUtil. This workaround should be replaced by a proper solution.

Contributes to eclipse-platform#62 and eclipse-platform#131
HeikoKlare pushed a commit to eclipse-platform/eclipse.platform.ui that referenced this issue Nov 1, 2024
This commit adds a listener for the ZoomChanged event to the canvas of a LineNumberRulerColumn. If the listener is notified of this event this means, that state, that differs over different zoom values, must be recalculated. Therefore the indentation are reset, when the event occurs.

Contributes to eclipse-platform/eclipse.platform.swt#62 and eclipse-platform/eclipse.platform.swt#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Nov 1, 2024
This commit adds a workaround for ImageDataProvider implementations that instantiate new Images inside the getImageData(zoom) implementation. This image can be instantiated with the wrong zoom in a multi zoom setting as Images still relay on the static zoom value in DPIUtil. This workaround should be replaced by a proper solution.

Contributes to eclipse-platform#62 and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Nov 4, 2024
This commit adds a workaround for ImageDataProvider implementations that instantiate new Images inside the getImageData(zoom) implementation. This image can be instantiated with the wrong zoom in a multi zoom setting as Images still relay on the static zoom value in DPIUtil. This workaround should be replaced by a proper solution.

Contributes to eclipse-platform#62 and eclipse-platform#131
HeikoKlare pushed a commit that referenced this issue Nov 5, 2024
This commit adds a workaround for ImageDataProvider implementations that instantiate new Images inside the getImageData(zoom) implementation. This image can be instantiated with the wrong zoom in a multi zoom setting as Images still relay on the static zoom value in DPIUtil. This workaround should be replaced by a proper solution.

Contributes to #62 and #131
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This commit adds two win32 API calls to get DPI dependent theming data and identify a monitor by a given rect. Both API calls are required to target HiDPI issues in the win32 implementation.

Contributes to eclipse-platform#62 and eclipse-platform#131
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This adds the win32 API methods GetThreadDpiAwarenessContext and
SetThreadDpiAwarenessContext to be able to manually set and retrieve the
DPI awareness mode for a thread, including the PerMonitorV2 mode.

Contributes to
eclipse-platform#62
Contributes to
eclipse-platform#131
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
The runtime auto-scaling for multi-monitor HiDPI support on Windows
requires the system's DPI awareness to be set to PerMonitorV2. This
change makes the Display class initialize its UI thread with the
according DPI awareness.

Contributes to
eclipse-platform#62
Contributes to
eclipse-platform#131
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This commit adapts how to fetch fonts in GC in the win32 implementation. Now it always uses the internal SWTFontProvider to fetch system and non-system fonts in the correct scaling.

Contributes to eclipse-platform#62 and eclipse-platform#131
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This commit changes the createButtonImage method in CTabFolder. Until now the requested image data were created once and are scaled to other zoom settings with an AutoScaleImageDataProvider, which is a destructive operation when scaling it to a smaller zoom. With this change the whole logic is moved into an ImageDataProvider, so each time ImageData for a specific zoom value is requested, it will be created from scratch for this zoom value.

Contributes to eclipse-platform#62 and eclipse-platform#131
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This commit adds a method to receive handles for scaled variants of an ImageList for the specified zoom. All calls to the handle of an ImageList is replaced by the added method.

Contributes to eclipse-platform#62 and eclipse-platform#131.
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This commit refactors the callback use for ToolBar and ToolItem after a DPI change in the win32 implementation. It makes use of the scalable ImageList to reuse the existing items in the toolbar and only resets the ImageList with a correctly scaled one. Due to the limitations of the win32 implementation all items must be removed and re-added via the win32-API to make shrinking of toolbars possible. Additionally, the commit removes the now unused callback in ToolItem

Contributes to eclipse-platform#62 and eclipse-platform#131.
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This commit adapt how the DPI change is propagated into the DPI update mechanism. In comes down to the following:
Automatic rescaling is not active: It is exactly as in the beginning -> A ZoomChanged event is send for the affected control, wenn the zoom is change
Automatic rescaling is active: The update is no longer propagation via a ZoomChanged event that was used by a listener in a Shell to propagate this change into the DPIZoomChangeRegistry, but it is directly propagated into DPIZoomChangeRegistry in the WM_DPICHANGED callback.
Additionally, for each widget, that is handled in DPIZoomChangeRegistry for a dpi change a ZoomChanged event is created and sent to the widget. That enables creators of custom widget to hook into the update and refresh the state of the affected widget, e.g. refresh a widget, when it is rendering its content without a layout manager.

Contributes to eclipse-platform#62 and eclipse-platform#131
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This commit prevents an ArrayIndexOutOfBounds exception, when the commandIds of toolbar buttons are not in line with button count, e.g. there is an id higher than the button count.

Contributes to eclipse-platform#62 and eclipse-platform#131
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This commit properly creates scaled variants of an ImageList if there a null images contained in the source ImageList

Contributes to eclipse-platform#62 and eclipse-platform#131
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This commit moves the initialization of the thread DPI awareness into the creation method. It was done too late before which resulted in all calls do Display::messageProc being executed with the wrong DPI awarness of the thread dpi awareness differs from the process DPI awareness.

Contributes to eclipse-platform#62 and eclipse-platform#131
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This commit replaces the OS calls for OpenThemeData with calls to the dpi dependent equivalent OpenThemeDataForDpi. Therefor the handling of loading/unloading of theme in Display is refactored to be able to manage multiple DPI dependent variants of a theme in multi zoom environments

Contributes to eclipse-platform#62 nd eclipse-platform#131
lathapatil pushed a commit to swt-initiative31/prototype-gtk that referenced this issue Nov 14, 2024
This commit adds a workaround for ImageDataProvider implementations that instantiate new Images inside the getImageData(zoom) implementation. This image can be instantiated with the wrong zoom in a multi zoom setting as Images still relay on the static zoom value in DPIUtil. This workaround should be replaced by a proper solution.

Contributes to eclipse-platform#62 and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Dec 2, 2024
This contributes extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display

Contributes to eclipse-platform#62 and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Dec 2, 2024
This contributes extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display

Contributes to eclipse-platform#62 and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Dec 2, 2024
This contributes extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display

Contributes to eclipse-platform#62 and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Dec 5, 2024
This contributes extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display

Contributes to eclipse-platform#62 and eclipse-platform#131
mai-tran-03 pushed a commit to mai-tran-03/eclipse.platform.ui that referenced this issue Dec 10, 2024
This commit adds a listener for the ZoomChanged event to the canvas of a LineNumberRulerColumn. If the listener is notified of this event this means, that state, that differs over different zoom values, must be recalculated. Therefore the indentation are reset, when the event occurs.

Contributes to eclipse-platform/eclipse.platform.swt#62 and eclipse-platform/eclipse.platform.swt#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Dec 10, 2024
This contributes extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display

Contributes to eclipse-platform#62 and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Dec 10, 2024
This contributes extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display

Contributes to eclipse-platform#62 and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Dec 10, 2024
This contributes extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display

Contributes to eclipse-platform#62 and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Dec 10, 2024
This contributes extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display

Contributes to eclipse-platform#62 and eclipse-platform#131
akoch-yatta added a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Dec 10, 2024
This contribution extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display.

Contributes to eclipse-platform#62 and eclipse-platform#131
Fixes eclipse-platform/eclipse.platform.ui#2595
HeikoKlare pushed a commit to akoch-yatta/eclipse.platform.swt that referenced this issue Dec 10, 2024
This contribution extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display.

Contributes to eclipse-platform#62 and eclipse-platform#131
Fixes eclipse-platform/eclipse.platform.ui#2595
HeikoKlare pushed a commit that referenced this issue Dec 10, 2024
This contribution extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display.

Contributes to #62 and #131
Fixes eclipse-platform/eclipse.platform.ui#2595
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed Windows Happens on Windows OS
Projects
None yet
Development

No branches or pull requests

3 participants