-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
win32 and winrt (uwp) window handles
- Loading branch information
1 parent
cea3b33
commit 2730376
Showing
1 changed file
with
15 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1120,7 +1120,7 @@ const SDL_SysWMInfo = new Struct({ | |
}); | ||
|
||
/* bug in [email protected] where SDL_SysWMInfo.size is NaN */ | ||
const sizeOfSDL_SysWMInfo = 3 + 4 + 64; | ||
const sizeOfSDL_SysWMInfo = 3 + 4 + 8 * 64; | ||
const wmInfoBuf = new Uint8Array(sizeOfSDL_SysWMInfo); | ||
|
||
type Reader<T> = (reader: Deno.UnsafePointerView) => T; | ||
|
@@ -1182,25 +1182,28 @@ export class Window { | |
} | ||
|
||
const view = new Deno.UnsafePointerView(wm_info!); | ||
const info = SDL_SysWMInfo.read(view); | ||
const win = Deno.UnsafePointer.create(info.window); | ||
|
||
const subsystem = view.getUint32(4); | ||
const window = view.getPointer(4 + 4); | ||
|
||
if (isMacos()) { | ||
const SDL_SYSWM_COCOA = 4; | ||
if (info.subsystem != SDL_SYSWM_COCOA) { | ||
if (subsystem != SDL_SYSWM_COCOA) { | ||
throw new Error("Expected SDL_SYSWM_COCOA on macOS"); | ||
} | ||
|
||
return ["cocoa", win, this.metalView]; | ||
return ["cocoa", window, this.metalView]; | ||
} | ||
|
||
if (isWindows()) { | ||
// const SDL_SYSWM_WINRT = 8; | ||
// if (info.subsystem != SDL_SYSWM_WINRT) { | ||
// console.log(info.subsystem); | ||
// throw new Error("Expected SDL_SYSWM_WINRT on Windows"); | ||
// } | ||
return ["winrt", win, null]; | ||
const SDL_SYSWM_WINDOWS = 1; | ||
const SDL_SYSWM_WINRT = 8; | ||
if (subsystem == SDL_SYSWM_WINDOWS) { | ||
const hinstance = view.getPointer(4 + 4 + 8 + 8); | ||
return ["win32", window, hinstance]; | ||
} else if (subsystem == SDL_SYSWM_WINRT) { | ||
return ["winrt", window, null]; | ||
} | ||
throw new Error("Expected SDL_SYSWM_WINRT or SDL_SYSWM_WINDOWS on Windows"); | ||
} | ||
|
||
throw new Error("Unsupported platform"); | ||
|