More Menu
Reading ListGanti TemaSearch
Reading List

Queue · 0 items

Your reading list is empty. Save articles to read them later.

Start Reading

How Windows 11 CCD SetDisplayConfig Handles Multi-Monitor Coordinates

Iwan Efendi2 min

Technical developer guide to Win32 CCD SetDisplayConfig coordinate rules, primary display (0,0) constraints, and contiguous topology math on Windows 11.

When developing multi-monitor window management utilities or display switchers for Windows 10 and 11, the native Connecting and Configuring Displays (CCD) API—specifically QueryDisplayConfig and SetDisplayConfig—is the modern Win32 replacement for legacy ChangeDisplaySettingsEx. However, calling SetDisplayConfig with custom monitor coordinates frequently results in ERROR_BAD_CONFIGURATION (error code 1610 / 0x64A) or ERROR_INVALID_PARAMETER (error code 87). Here is a concise breakdown of the three strict geometric rules Windows CCD enforces on desktop topologies.

1. Rule 1: The Primary Display Must Always Anchor at (0, 0)

In the Windows desktop coordinate space, the top-left corner of the primary display is the origin:
// POINTL coordinates for the primary screen path
pathModeInfo.modeInfo.sourceMode.position.x = 0;
pathModeInfo.modeInfo.sourceMode.position.y = 0;
If you designate a new monitor as primary, you cannot simply set its SDC_SET_PRIMARY flag without shifting all other display coordinates. Every other active screen's position must be offset by (-newPrimary.X, -newPrimary.Y). For example, if Display 2 is positioned at (1920, 0) and you make Display 2 primary:
  • Display 2: moves to (0, 0)
  • Display 1: shifts to (-1920, 0)

2. Rule 2: Active Screens Must Be Contiguous (No Floating Gaps)

Windows CCD rejects arrangements where any active screen does not physically touch at least one other active screen along an edge:
[ Display 1 (0,0) ] <--- 50px gap ---> [ Display 2 (1970, 0) ]
=> SetDisplayConfig fails with ERROR_BAD_CONFIGURATION (1610)
To prevent this error, the desktop topology normalizer must project every screen against placed screens and clamp coordinates:
public static bool Overlaps(Rect a, Rect b) =>
    a.Left < b.Right && a.Right > b.Left && a.Top < b.Bottom && a.Bottom > b.Top;

public static bool IsContiguous(Rect candidate, Rect anchor, int minOverlapPx = 60)
{
    if (Overlaps(candidate, anchor)) return false;

    bool touchesHorizontally = (candidate.Right == anchor.Left || candidate.Left == anchor.Right)
        && (Math.Min(candidate.Bottom, anchor.Bottom) - Math.Max(candidate.Top, anchor.Top) >= minOverlapPx);

    bool touchesVertically = (candidate.Bottom == anchor.Top || candidate.Top == anchor.Bottom)
        && (Math.Min(candidate.Right, anchor.Right) - Math.Max(candidate.Left, anchor.Left) >= minOverlapPx);

    return touchesHorizontally || touchesVertically;
}

3. Rule 3: Smart Auto-Wake From Solo Topology

When a user switches to PC Screen Only or a secondary monitor enters deep sleep, Windows disables that display's CCD path. Attempting to call SetDisplayConfig with SDC_USE_SUPPLIED_DISPLAY_CONFIG directly on a disabled path returns ERROR_GEN_FAILURE (error code 31). To safely restore coordinates, you must execute a two-phase apply:
  1. Phase 1 (Topology Wake): Call SetDisplayConfig(0, null, 0, null, SDC_APPLY | SDC_TOPOLOGY_EXTEND).
  2. Phase 2 (Enumeration Delay): Poll QueryDisplayConfig until the newly awakened path transitions to DISPLAYCONFIG_PATH_ACTIVE (typically 100–300 ms).
  3. Phase 3 (Coordinate Restore): Call SetDisplayConfig with your saved coordinates and SDC_APPLY | SDC_USE_SUPPLIED_DISPLAY_CONFIG | SDC_SAVE_TO_DATABASE | SDC_ALLOW_CHANGES.
This is the exact auto-wake pattern implemented in DisplayFlip.
Topics

Topics in this note

Explore related ideas through the topics connected to this note.

Share this article

Discussion

Preparing the comments area...

You Might Also Like