Skip to content

Commit 8e6eaf1

Browse files
committed
wayland: Expose wl_output objects on video displays
Some protocols take a wl_output object to function, so expose them via a property on the video displays.
1 parent 1f917d5 commit 8e6eaf1

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

include/SDL3/SDL_video.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,10 @@ extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
632632
* responsible for any coordinate transformations needed to conform to the
633633
* requested display orientation.
634634
*
635+
* On Wayland:
636+
*
637+
* - `SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER`: the wl_output associated with the display
638+
*
635639
* \param displayID the instance ID of the display to query.
636640
* \returns a valid property ID on success or 0 on failure; call
637641
* SDL_GetError() for more information.
@@ -644,6 +648,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_Displa
644648

645649
#define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled"
646650
#define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation"
651+
#define SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER "SDL.display.wayland.wl_output"
647652

648653
/**
649654
* Get the name of a display in UTF-8 encoding.

src/video/SDL_video.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ SDL_DisplayID SDL_AddVideoDisplay(const SDL_VideoDisplay *display, bool send_eve
855855
SDL_copyp(new_display, display);
856856
new_display->id = id;
857857
new_display->device = _this;
858+
new_display->props = display->props;
858859
if (display->name) {
859860
new_display->name = SDL_strdup(display->name);
860861
} else {

src/video/wayland/SDL_waylandvideo.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,9 @@ static void display_handle_done(void *data,
10711071
internal->placeholder.current_orientation = internal->orientation;
10721072
internal->placeholder.internal = internal;
10731073

1074+
internal->placeholder.props = SDL_CreateProperties();
1075+
SDL_SetPointerProperty(internal->placeholder.props, SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER, internal->output);
1076+
10741077
// During initialization, the displays will be added after enumeration is complete.
10751078
if (!video->initializing) {
10761079
internal->display = SDL_AddVideoDisplay(&internal->placeholder, true);

0 commit comments

Comments
 (0)