File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
Eclipse SWT PI/win32/org/eclipse/swt/internal/win32
Eclipse SWT/win32/org/eclipse/swt/widgets Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff line change @@ -233,6 +233,13 @@ public RGB open () {
233233
234234 display .externalEventLoop = true ;
235235 display .sendPreExternalEventDispatchEvent ();
236+
237+ /* Temporarily setting the thread dpi awareness to gdi scaling because window dialog has weird resize handling */
238+ long currentDpiAwarenessContext = OS .GetThreadDpiAwarenessContext ();
239+ if (display .isRescalingAtRuntime ()) {
240+ currentDpiAwarenessContext = OS .SetThreadDpiAwarenessContext (OS .DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED );
241+ }
242+
236243 /* Open the dialog */
237244 boolean success = OS .ChooseColor (lpcc );
238245 display .externalEventLoop = false ;
@@ -270,6 +277,11 @@ public RGB open () {
270277 rgb = new RGB (red , green , blue );
271278 }
272279
280+ /* Reset the dpi awareness context */
281+ if (display .isRescalingAtRuntime ()) {
282+ OS .SetThreadDpiAwarenessContext (currentDpiAwarenessContext );
283+ }
284+
273285 /* Free the CCHookProc */
274286 callback .dispose ();
275287
Original file line number Diff line number Diff line change @@ -226,6 +226,13 @@ public FontData open () {
226226
227227 display .externalEventLoop = true ;
228228 display .sendPreExternalEventDispatchEvent ();
229+
230+ /* Temporarily setting the thread dpi awareness to gdi scaling because window dialog has weird resize handling */
231+ long currentDpiAwarenessContext = OS .GetThreadDpiAwarenessContext ();
232+ if (display .isRescalingAtRuntime ()) {
233+ currentDpiAwarenessContext = OS .SetThreadDpiAwarenessContext (OS .DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED );
234+ }
235+
229236 /* Open the dialog */
230237 boolean success = OS .ChooseFont (lpcf );
231238 display .externalEventLoop = false ;
@@ -279,6 +286,11 @@ public FontData open () {
279286 }
280287 }
281288
289+ /* Reset the dpi awareness context */
290+ if (display .isRescalingAtRuntime ()) {
291+ OS .SetThreadDpiAwarenessContext (currentDpiAwarenessContext );
292+ }
293+
282294 /* Free the OS memory */
283295 if (lpLogFont != 0 ) OS .HeapFree (hHeap , 0 , lpLogFont );
284296
You can’t perform that action at this time.
0 commit comments