Skip to content

Commit fa7e9f9

Browse files
Scaling of Color/Font Dialog not working properly after DPI change
Creating a separate UI thread to set the DPI Awareness context to use UNAWARE GDI scale before opening the either dialogs since windows has issues with dialog scaling in AWARE context
1 parent 0e7f799 commit fa7e9f9

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ public class OS extends C {
370370
public static final short DMDUP_VERTICAL = 2;
371371
public static final short DMDUP_HORIZONTAL = 3;
372372
public static final int DPI_AWARENESS_CONTEXT_UNAWARE = 24592;
373+
public static final int DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = 1073766416;
373374
public static final int DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = 24593;
374375
public static final int DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = 18;
375376
public static final int DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = 34;

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ public RGB open () {
184184

185185
/* Allocate the Custom Colors and initialize to white */
186186
Display display = parent.display;
187+
if(display.isRescalingAtRuntime()) {
188+
OS.SetThreadDpiAwarenessContext(OS.DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED);
189+
}
187190
if (display.lpCustColors == 0) {
188191
long hHeap = OS.GetProcessHeap ();
189192
display.lpCustColors = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, CUSTOM_COLOR_COUNT * 4);

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ public FontData open () {
219219
/* Make the parent shell be temporary modal */
220220
Dialog oldModal = null;
221221
Display display = parent.getDisplay ();
222+
if(display.isRescalingAtRuntime()) {
223+
OS.SetThreadDpiAwarenessContext(OS.DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED);
224+
}
222225
if ((style & (SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) != 0) {
223226
oldModal = display.getModalDialog ();
224227
display.setModalDialog (this);

0 commit comments

Comments
 (0)