Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use new UnsafeWindowSurface syntax #79

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@divy/sdl2",
"version": "0.12.0",
"version": "0.12.1",
"exports": "./mod.ts",
"lint": {
"rules": {
Expand Down
29 changes: 19 additions & 10 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// deno-lint-ignore-file no-unused-vars
import {
cstring,
i32,
SizedFFIType,
type SizedFFIType,
Struct,
u16,
u32,
Expand Down Expand Up @@ -1097,7 +1098,6 @@ const SDL_WindowEvent = new Struct({
data2: i32,
});

// deno-lint-ignore no-unused-vars
const SDL_DisplayEvent = new Struct({
type: u32,
timestamp: u32,
Expand Down Expand Up @@ -1198,7 +1198,7 @@ const SDL_TextEditingEvent = new Struct({
type: u32,
timestamp: u32,
windowID: u32,
// @ts-ignore
// @ts-ignore cstring
text: cstring,
start: i32,
length: i32,
Expand All @@ -1208,7 +1208,7 @@ const SDL_TextInputEvent = new Struct({
type: u32,
timestamp: u32,
windowID: u32,
// @ts-ignore
// @ts-ignore cstring
text: cstring,
});

Expand Down Expand Up @@ -1297,11 +1297,13 @@ export class Window {

static deserialize(data: ArrayBuffer): Deno.UnsafeWindowSurface {
const [surface, p1, p2] = new BigInt64Array(data);
return new Deno.UnsafeWindowSurface(
systems[Number(surface)],
Deno.UnsafePointer.create(p1),
Deno.UnsafePointer.create(p2),
);
return new Deno.UnsafeWindowSurface({
system: systems[Number(surface)],
windowHandle: Deno.UnsafePointer.create(p1),
displayHandle: Deno.UnsafePointer.create(p2),
width: 0,
height: 0,
});
}

/**
Expand All @@ -1310,7 +1312,13 @@ export class Window {
*/
windowSurface(): Deno.UnsafeWindowSurface {
const [surface, p1, p2] = this.#windowSurface();
return new Deno.UnsafeWindowSurface(surface, p1, p2);
return new Deno.UnsafeWindowSurface({
system: surface,
windowHandle: p1,
displayHandle: p2,
width: 0,
height: 0,
});
}

#windowSurface(): [
Expand Down Expand Up @@ -1380,6 +1388,7 @@ export class Window {
/**
* Events from the window.
*/
// deno-lint-ignore no-explicit-any
async *events(wait = false): AsyncGenerator<any> {
while (true) {
const event = Deno.UnsafePointer.of(eventBuf);
Expand Down
Loading