Skip to content

Commit

Permalink
[win32] Add internal strict mode flag for GC
Browse files Browse the repository at this point in the history
This contribution adds a strict mode flag configurable via system
property to GC the print our errors, if the GC is not configured
correctly for the monitor-specific-scaling
  • Loading branch information
akoch-yatta committed Jan 22, 2025
1 parent 60ef7e9 commit 0f86d60
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ public final class GC extends Resource {
static final float[] LINE_DASHDOT_ZERO = new float[]{9, 6, 3, 6};
static final float[] LINE_DASHDOTDOT_ZERO = new float[]{9, 3, 3, 3, 3, 3};

/**
* System property to activate a strict mode for GC, which outputs errors for misconfigured GCs.
* <ul>
* <li><b>true</b>: Enables additional checks and prints errors if an invalid configuration is detected.
* This mode should only be used during development.</li>
* <li><b>false</b>: No additional checks are executed.</li>
* </ul>
* <b>Important:</b> This flag is currently only used on Win32. Setting it to
* true on GTK or cocoa wont have any effect.
* <p>
* The current default is "false".
*/
private static final String GC_STRICT_MODE = "gc.strict";

/**
* Prevents uninitialized instances from being created outside the package.
*/
Expand Down Expand Up @@ -3950,6 +3964,10 @@ void init(Drawable drawable, GCData data, long hDC) {
}

private static int extractZoom(long hDC) {
if (Boolean.getBoolean (GC_STRICT_MODE)) {
System.err.println("***WARNING: GC is initialized with a missing zoom. This indicates an "
+ "incompatible custom Drawable implementation.");
}
long hwnd = OS.WindowFromDC(hDC);
long parentWindow = OS.GetAncestor(hwnd, OS.GA_ROOT);
long monitorParent = OS.MonitorFromWindow(parentWindow, OS.MONITOR_DEFAULTTONEAREST);
Expand Down

0 comments on commit 0f86d60

Please sign in to comment.