# SDL: win32: Only declare the context as DPI-unaware if the set function succeeds

**URL:** <https://discourse.libsdl.org/t/sdl-win32-only-declare-the-context-as-dpi-unaware-if-the-set-function-succeeds/69685>\
**Category:** SDL Commits\
**Created:** [October 30, 2026, 4:19pm UTC](https://discourse.libsdl.org/t/sdl-win32-only-declare-the-context-as-dpi-unaware-if-the-set-function-succeeds/69685 "2026-10-30T16:19:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [October 30, 2026, 4:19pm UTC](https://discourse.libsdl.org/t/sdl-win32-only-declare-the-context-as-dpi-unaware-if-the-set-function-succeeds/69685/1 "2026-10-30T16:19:02Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/284ba3de65b06111149065053e2af8bf80ba73f8>
>
> Otherwise, the flag can be true, even if setting the process to DPI unaware mode… failed.
> 
> Fixes #16616

```diff
From 284ba3de65b06111149065053e2af8bf80ba73f8 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Fri, 30 Oct 2026 12:15:36 -0400
Subject: [PATCH] win32: Only declare the context as DPI-unaware if the set
 function succeeds

Otherwise, the flag can be true, even if setting the process to DPI unaware mode failed.

Fixes #16616
---
 src/video/windows/SDL_windowsvideo.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c
index 30e4e5339553a..4f4b2c29bbf51 100644
--- a/src/video/windows/SDL_windowsvideo.c
+++ b/src/video/windows/SDL_windowsvideo.c
@@ -473,8 +473,10 @@ static BOOL WIN_DeclareDPIAwareUnaware(SDL_VideoDevice *_this)
     SDL_VideoData *data = _this->internal;
 
     if (data->SetProcessDpiAwarenessContext) {
- data->dpi_unaware_context_declared = true;
- return data->SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
+ if (data->SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE)) {
+ data->dpi_unaware_context_declared = true;
+ return TRUE;
+ }
     } else if (data->SetProcessDpiAwareness) {
         // Windows 8.1
         return SUCCEEDED(data->SetProcessDpiAwareness(PROCESS_DPI_UNAWARE));

```
