Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/SDL3/SDL_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,11 @@ extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
* - `SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER`: the wl_output associated
* with the display
*
* On Windows:
*
* - `SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER`: the monitor handle (HMONITOR)
* associated with the display
*
* \param displayID the instance ID of the display to query.
* \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information.
Expand All @@ -678,6 +683,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_Displa
#define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled"
#define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation"
#define SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER "SDL.display.wayland.wl_output"
#define SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER "SDL.display.windows.hmonitor"

/**
* Get the name of a display in UTF-8 encoding.
Expand Down
6 changes: 6 additions & 0 deletions src/video/windows/SDL_windowsmodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,9 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI
internal->MonitorHandle = hMonitor;
internal->state = DisplayUnchanged;

SDL_PropertiesID props = SDL_GetDisplayProperties(_this->displays[i]->id);
SDL_SetPointerProperty(props, SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER, hMonitor);

if (!_this->setting_display_mode) {
SDL_VideoDisplay *existing_display = _this->displays[i];
SDL_Rect bounds;
Expand Down Expand Up @@ -665,6 +668,9 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI
if (SDL_AddVideoDisplay(&display, false)) {
// The mode is owned by the video subsystem
mode.internal = NULL;

SDL_PropertiesID props = SDL_GetDisplayProperties(display.id);
SDL_SetPointerProperty(props, SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER, hMonitor);
} else {
SDL_free(displaydata);
}
Expand Down
Loading