Skip to content

Commit b984846

Browse files
authored
windows: Add property mapping displayID to HMONITOR. (#14494)
1 parent 67728a5 commit b984846

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/SDL3/SDL_video.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,11 @@ extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
665665
* - `SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER`: the wl_output associated
666666
* with the display
667667
*
668+
* On Windows:
669+
*
670+
* - `SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER`: the monitor handle (HMONITOR)
671+
* associated with the display
672+
*
668673
* \param displayID the instance ID of the display to query.
669674
* \returns a valid property ID on success or 0 on failure; call
670675
* SDL_GetError() for more information.
@@ -678,6 +683,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_Displa
678683
#define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled"
679684
#define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation"
680685
#define SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER "SDL.display.wayland.wl_output"
686+
#define SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER "SDL.display.windows.hmonitor"
681687

682688
/**
683689
* Get the name of a display in UTF-8 encoding.

src/video/windows/SDL_windowsmodes.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,9 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI
605605
internal->MonitorHandle = hMonitor;
606606
internal->state = DisplayUnchanged;
607607

608+
SDL_PropertiesID props = SDL_GetDisplayProperties(_this->displays[i]->id);
609+
SDL_SetPointerProperty(props, SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER, hMonitor);
610+
608611
if (!_this->setting_display_mode) {
609612
SDL_VideoDisplay *existing_display = _this->displays[i];
610613
SDL_Rect bounds;
@@ -665,6 +668,9 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI
665668
if (SDL_AddVideoDisplay(&display, false)) {
666669
// The mode is owned by the video subsystem
667670
mode.internal = NULL;
671+
672+
SDL_PropertiesID props = SDL_GetDisplayProperties(display.id);
673+
SDL_SetPointerProperty(props, SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER, hMonitor);
668674
} else {
669675
SDL_free(displaydata);
670676
}

0 commit comments

Comments
 (0)