Skip to content

Commit 0d8d379

Browse files
authored
Merge pull request #3340 from pygame-community/ankith26-scrap-sdl3
Port scap.c to SDL3
2 parents e84b4be + d466ee8 commit 0d8d379

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src_c/meson.build

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,6 @@ _camera = py.extension_module(
375375
endif
376376

377377
# pygame.scrap
378-
379-
# TODO: support SDL3
380-
if sdl_api != 3
381378
pg_scrap_link = [] # TODO: should this link logic be improved/made meson-ey?
382379
if plat == 'win'
383380
pg_scrap_link += ['-luser32', '-lgdi32']
@@ -392,7 +389,6 @@ scrap = py.extension_module(
392389
install: true,
393390
subdir: pg,
394391
)
395-
endif
396392

397393
# optional modules
398394

src_c/scrap.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@
2727
#include <SDL3/SDL.h>
2828
#else
2929
#include <SDL.h>
30-
#endif
31-
3230
#include "SDL_syswm.h"
31+
#endif
3332

3433
#include "pygame.h"
3534

src_c/scrap_win.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ _create_dib_buffer(char *data, size_t *count)
158158
int
159159
pygame_scrap_init(void)
160160
{
161+
#if SDL_VERSION_ATLEAST(3, 0, 0)
162+
int retval = 0;
163+
window_handle = (HWND)SDL_GetPointerProperty(
164+
SDL_GetWindowProperties(pg_GetDefaultWindow()),
165+
SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
166+
if (window_handle) {
167+
retval = 1;
168+
}
169+
#else
161170
SDL_SysWMinfo info;
162171
int retval = 0;
163172

@@ -170,6 +179,7 @@ pygame_scrap_init(void)
170179
window_handle = info.info.win.window;
171180
retval = 1;
172181
}
182+
#endif
173183

174184
if (retval)
175185
_scrapinitialized = 1;

0 commit comments

Comments
 (0)