teek-sdl2 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/teek_sdl2/extconf.rb +9 -0
- data/ext/teek_sdl2/sdl2_macos.m +47 -0
- data/ext/teek_sdl2/sdl2_macos_stub.c +9 -0
- data/ext/teek_sdl2/sdl2surface.c +13 -4
- data/ext/teek_sdl2/teek_sdl2.h +3 -0
- data/lib/teek/sdl2/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: de03bda40a94468e6956aba1a61fbfda2ae7caed7dd8d4f54632816c5c72db80
|
|
4
|
+
data.tar.gz: a53e78b3469245cfd47bc3b72dc9b9acffc0b035abad24647b4e824d5ec5e40a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4bc926660c4760d6f3fc6f54ab6f7c982e3f5164dd66b80531e54f729e0ffde515843ded5438824d6a0616529d362c1b15d033e8bbb91b09773546cd46586723
|
|
7
|
+
data.tar.gz: d3393755c68d9b4bf95fbf9fcab193cf155fd5996773bc0018a572d4e39837b4a5e333e207df14c66361c920f0e3c4d4627067af0ec080561982d27274f7b937
|
data/ext/teek_sdl2/extconf.rb
CHANGED
|
@@ -130,4 +130,13 @@ end
|
|
|
130
130
|
|
|
131
131
|
$srcs = ['teek_sdl2.c', 'sdl2surface.c', 'sdl2bridge.c', 'sdl2text.c', 'sdl2pixels.c', 'sdl2image.c', 'sdl2mixer.c', 'sdl2audio.c', 'sdl2gamepad.c']
|
|
132
132
|
|
|
133
|
+
# macOS: ObjC file to clean up SDL2 Metal subview left on foreign windows.
|
|
134
|
+
# Non-macOS: C stub with no-op implementation.
|
|
135
|
+
if RUBY_PLATFORM =~ /darwin/
|
|
136
|
+
$srcs << 'sdl2_macos.m'
|
|
137
|
+
$LDFLAGS << ' -framework Cocoa -framework QuartzCore'
|
|
138
|
+
else
|
|
139
|
+
$srcs << 'sdl2_macos_stub.c'
|
|
140
|
+
end
|
|
141
|
+
|
|
133
142
|
create_makefile('teek_sdl2')
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#include "teek_sdl2.h"
|
|
2
|
+
|
|
3
|
+
#ifdef __APPLE__
|
|
4
|
+
#import <Cocoa/Cocoa.h>
|
|
5
|
+
#include <SDL2/SDL_syswm.h>
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Remove any non-Tk subviews from the NSWindow's contentView and mark
|
|
9
|
+
* it for redisplay. Called from renderer_destroy() after
|
|
10
|
+
* SDL_DestroyRenderer — SDL2's Metal backend fails to remove its
|
|
11
|
+
* SDL_cocoametalview on foreign (Tk-owned) windows.
|
|
12
|
+
*
|
|
13
|
+
* Must be called BEFORE SDL_DestroyWindow (which NULLs the window
|
|
14
|
+
* pointer in SDL_WindowData, making SDL_GetWindowWMInfo fail).
|
|
15
|
+
*/
|
|
16
|
+
void
|
|
17
|
+
sdl2_macos_cleanup_metal_view(SDL_Window *window)
|
|
18
|
+
{
|
|
19
|
+
if (!window) return;
|
|
20
|
+
|
|
21
|
+
SDL_SysWMinfo wminfo;
|
|
22
|
+
SDL_VERSION(&wminfo.version);
|
|
23
|
+
|
|
24
|
+
if (!SDL_GetWindowWMInfo(window, &wminfo)) return;
|
|
25
|
+
if (wminfo.subsystem != SDL_SYSWM_COCOA) return;
|
|
26
|
+
|
|
27
|
+
NSWindow *nswindow = wminfo.info.cocoa.window;
|
|
28
|
+
NSView *contentView = [nswindow contentView];
|
|
29
|
+
|
|
30
|
+
/* Remove any subviews that aren't part of Tk's view hierarchy.
|
|
31
|
+
* Tk's own views are TKContentView (the contentView itself) and
|
|
32
|
+
* occasionally internal Tk_ prefixed views. The Metal subview is
|
|
33
|
+
* SDL_cocoametalview. Rather than matching class names, just
|
|
34
|
+
* remove everything — Tk draws into the contentView directly, it
|
|
35
|
+
* doesn't use subviews. */
|
|
36
|
+
NSArray *subviews = [contentView.subviews copy];
|
|
37
|
+
for (NSView *subview in subviews) {
|
|
38
|
+
[subview removeFromSuperview];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[contentView setNeedsDisplay:YES];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#else
|
|
45
|
+
/* No-op on non-macOS */
|
|
46
|
+
void sdl2_macos_cleanup_metal_view(SDL_Window *window) { (void)window; }
|
|
47
|
+
#endif
|
data/ext/teek_sdl2/sdl2surface.c
CHANGED
|
@@ -48,8 +48,11 @@ renderer_free(void *ptr)
|
|
|
48
48
|
SDL_DestroyRenderer(r->renderer);
|
|
49
49
|
r->renderer = NULL;
|
|
50
50
|
}
|
|
51
|
-
if (r->window
|
|
52
|
-
|
|
51
|
+
if (r->window) {
|
|
52
|
+
sdl2_macos_cleanup_metal_view(r->window);
|
|
53
|
+
if (r->owned_window) {
|
|
54
|
+
SDL_DestroyWindow(r->window);
|
|
55
|
+
}
|
|
53
56
|
r->window = NULL;
|
|
54
57
|
}
|
|
55
58
|
r->destroyed = 1;
|
|
@@ -388,8 +391,14 @@ renderer_destroy(VALUE self)
|
|
|
388
391
|
SDL_DestroyRenderer(r->renderer);
|
|
389
392
|
r->renderer = NULL;
|
|
390
393
|
}
|
|
391
|
-
if (r->window
|
|
392
|
-
|
|
394
|
+
if (r->window) {
|
|
395
|
+
/* On macOS, SDL2's Metal backend leaves an SDL_cocoametalview
|
|
396
|
+
* subview on foreign (Tk-owned) windows after SDL_DestroyRenderer.
|
|
397
|
+
* Remove it before destroying the SDL_Window. */
|
|
398
|
+
sdl2_macos_cleanup_metal_view(r->window);
|
|
399
|
+
if (r->owned_window) {
|
|
400
|
+
SDL_DestroyWindow(r->window);
|
|
401
|
+
}
|
|
393
402
|
r->window = NULL;
|
|
394
403
|
}
|
|
395
404
|
r->destroyed = 1;
|
data/ext/teek_sdl2/teek_sdl2.h
CHANGED
|
@@ -63,4 +63,7 @@ void Init_sdl2mixer(VALUE mTeekSDL2);
|
|
|
63
63
|
void Init_sdl2audio(VALUE mTeekSDL2);
|
|
64
64
|
void Init_sdl2gamepad(VALUE mTeekSDL2);
|
|
65
65
|
|
|
66
|
+
/* macOS Metal view cleanup (sdl2_macos.m) — no-op on other platforms */
|
|
67
|
+
void sdl2_macos_cleanup_metal_view(SDL_Window *window);
|
|
68
|
+
|
|
66
69
|
#endif /* TEEK_SDL2_H */
|
data/lib/teek/sdl2/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: teek-sdl2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Cook
|
|
@@ -74,6 +74,8 @@ extensions:
|
|
|
74
74
|
extra_rdoc_files: []
|
|
75
75
|
files:
|
|
76
76
|
- ext/teek_sdl2/extconf.rb
|
|
77
|
+
- ext/teek_sdl2/sdl2_macos.m
|
|
78
|
+
- ext/teek_sdl2/sdl2_macos_stub.c
|
|
77
79
|
- ext/teek_sdl2/sdl2audio.c
|
|
78
80
|
- ext/teek_sdl2/sdl2bridge.c
|
|
79
81
|
- ext/teek_sdl2/sdl2gamepad.c
|