mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-26 17:16:59 +08:00
wayland: Add the ability to import and wrap external surfaces
Add the ability to import and wrap external surfaces from external toolkits such as Qt and GTK. Wayland surfaces and windows are more intrinsically tied to the client library than other windowing systems, so it is necessary to provide a way to initialize SDL with an existing wl_display object, which needs to be set prior to video system initialization, or export the internal SDL wl_display object for use by external applications or toolkits. For this, the global property SDL_PROPERTY_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER is used. A Wayland example was added to testnative, and a basic example of Qt 6 interoperation is provided in the Wayland readme to demonstrate the use of external windows with both SDL owning the wl_display, and an external toolkit owning it.
This commit is contained in:
@@ -30,6 +30,9 @@ static NativeWindowFactory *factories[] = {
|
||||
#ifdef TEST_NATIVE_WINDOWS
|
||||
&WindowsWindowFactory,
|
||||
#endif
|
||||
#ifdef TEST_NATIVE_WAYLAND
|
||||
&WaylandWindowFactory,
|
||||
#endif
|
||||
#ifdef TEST_NATIVE_X11
|
||||
&X11WindowFactory,
|
||||
#endif
|
||||
@@ -47,10 +50,10 @@ static SDLTest_CommonState *state;
|
||||
static void
|
||||
quit(int rc)
|
||||
{
|
||||
SDL_Quit();
|
||||
if (native_window && factory) {
|
||||
factory->DestroyNativeWindow(native_window);
|
||||
}
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
/* Let 'main()' return normally */
|
||||
if (rc != 0) {
|
||||
@@ -149,6 +152,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
props = SDL_CreateProperties();
|
||||
SDL_SetProperty(props, "sdl2-compat.external_window", native_window);
|
||||
SDL_SetBooleanProperty(props, SDL_PROPERTY_WINDOW_CREATE_OPENGL_BOOLEAN, SDL_TRUE);
|
||||
SDL_SetNumberProperty(props, SDL_PROPERTY_WINDOW_CREATE_WIDTH_NUMBER, WINDOW_W);
|
||||
SDL_SetNumberProperty(props, SDL_PROPERTY_WINDOW_CREATE_HEIGHT_NUMBER, WINDOW_H);
|
||||
window = SDL_CreateWindowWithProperties(props);
|
||||
SDL_DestroyProperties(props);
|
||||
if (!window) {
|
||||
|
||||
Reference in New Issue
Block a user