-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only consider rescaling at runtime enabled when DPI awareness mode fits
Activating rescaling at runtime requires a proper DPI awareness mode to be set. Currently, if setting the DPI awareness mode fails, rescaling may still be activated if the user requested to. With this change, setting the rescaling mode of a Display ensures that the correct DPI awareness for the UI thread is set and, in case an error occurs, the rescaling mode is not changed. It also adapts some faulty constants and provides according test cases for setting the rescaling behavior.
- Loading branch information
1 parent
fc0098c
commit c073cf7
Showing
5 changed files
with
84 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...les/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/DisplayWin32Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.eclipse.swt.widgets; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.eclipse.swt.internal.*; | ||
import org.eclipse.swt.internal.win32.*; | ||
import org.junit.jupiter.api.*; | ||
|
||
public class DisplayWin32Test { | ||
|
||
private Display display; | ||
|
||
@BeforeAll | ||
public static void assumeIsFittingPlatform() { | ||
PlatformSpecificExecution.assumeIsFittingPlatform(); | ||
} | ||
|
||
@BeforeEach | ||
public void createDisplay() { | ||
display = new Display(); | ||
} | ||
|
||
@AfterEach | ||
public void destroyDisplay() { | ||
display.dispose(); | ||
} | ||
|
||
@Test | ||
public void setRescaleAtRuntime_activate() { | ||
display.setRescalingAtRuntime(true); | ||
assertTrue(display.isRescalingAtRuntime()); | ||
assertEquals(OS.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, OS.GetThreadDpiAwarenessContext()); | ||
} | ||
|
||
@Test | ||
public void setRescaleAtRuntime_deactivate() { | ||
display.setRescalingAtRuntime(false); | ||
assertFalse(display.isRescalingAtRuntime()); | ||
assertEquals(OS.DPI_AWARENESS_CONTEXT_SYSTEM_AWARE, OS.GetThreadDpiAwarenessContext()); | ||
} | ||
|
||
@Test | ||
public void setRescaleAtRuntime_toggling() { | ||
display.setRescalingAtRuntime(false); | ||
assertFalse(display.isRescalingAtRuntime()); | ||
assertEquals(OS.DPI_AWARENESS_CONTEXT_SYSTEM_AWARE, OS.GetThreadDpiAwarenessContext()); | ||
display.setRescalingAtRuntime(true); | ||
assertTrue(display.isRescalingAtRuntime()); | ||
assertEquals(OS.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, OS.GetThreadDpiAwarenessContext()); | ||
display.setRescalingAtRuntime(false); | ||
assertFalse(display.isRescalingAtRuntime()); | ||
assertEquals(OS.DPI_AWARENESS_CONTEXT_SYSTEM_AWARE, OS.GetThreadDpiAwarenessContext()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters