Skip to content

Commit

Permalink
Port scap.c to SDL3
Browse files Browse the repository at this point in the history
  • Loading branch information
ankith26 committed Nov 2, 2024
1 parent 0830fa7 commit e6149e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src_c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -411,7 +408,6 @@ scrap = py.extension_module(
install: true,
subdir: pg,
)
endif

# optional modules

Expand Down
3 changes: 1 addition & 2 deletions src_c/scrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
#include <SDL3/SDL.h>
#else
#include <SDL.h>
#endif

#include "SDL_syswm.h"
#endif

#include "pygame.h"

Expand Down
10 changes: 10 additions & 0 deletions src_c/scrap_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -170,6 +179,7 @@ pygame_scrap_init(void)
window_handle = info.info.win.window;
retval = 1;
}
#endif

if (retval)
_scrapinitialized = 1;
Expand Down

0 comments on commit e6149e8

Please sign in to comment.