From e6149e89a8ecf89405e1c61d6753edf8d388b366 Mon Sep 17 00:00:00 2001 From: Ankith Date: Sat, 2 Nov 2024 16:27:59 +0530 Subject: [PATCH] Port scap.c to SDL3 --- src_c/meson.build | 4 ---- src_c/scrap.c | 3 +-- src_c/scrap_win.c | 10 ++++++++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src_c/meson.build b/src_c/meson.build index dd63495509..8cae8145a6 100644 --- a/src_c/meson.build +++ b/src_c/meson.build @@ -394,9 +394,6 @@ _camera = py.extension_module( endif # pygame.scrap - -# TODO: support SDL3 -if sdl_api != 3 pg_scrap_link = [] # TODO: should this link logic be improved/made meson-ey? if plat == 'win' pg_scrap_link += ['-luser32', '-lgdi32'] @@ -411,7 +408,6 @@ scrap = py.extension_module( install: true, subdir: pg, ) -endif # optional modules diff --git a/src_c/scrap.c b/src_c/scrap.c index ef580e7a99..eb1a95f4b5 100644 --- a/src_c/scrap.c +++ b/src_c/scrap.c @@ -27,9 +27,8 @@ #include #else #include -#endif - #include "SDL_syswm.h" +#endif #include "pygame.h" diff --git a/src_c/scrap_win.c b/src_c/scrap_win.c index 21be080ff9..188a1363c5 100644 --- a/src_c/scrap_win.c +++ b/src_c/scrap_win.c @@ -158,6 +158,15 @@ _create_dib_buffer(char *data, size_t *count) int pygame_scrap_init(void) { +#if SDL_VERSION_ATLEAST(3, 0, 0) + int retval = 0; + window_handle = (HWND)SDL_GetPointerProperty( + SDL_GetWindowProperties(pg_GetDefaultWindow()), + SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); + if (window_handle) { + retval = 1; + } +#else SDL_SysWMinfo info; int retval = 0; @@ -170,6 +179,7 @@ pygame_scrap_init(void) window_handle = info.info.win.window; retval = 1; } +#endif if (retval) _scrapinitialized = 1;