internal/glfwwin: refactoring: reduce risky unsafe.Pointer usages

This commit is contained in:
Hajime Hoshi 2022-05-25 02:21:30 +09:00
parent 0d7062335e
commit 604f14d2d4

View File

@ -30,9 +30,8 @@ import (
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
func monitorCallback(handle _HMONITOR, dc _HDC, rect *_RECT, data _LPARAM) uintptr /* _BOOL */ { func monitorCallback(handle _HMONITOR, dc _HDC, rect *_RECT, monitor *Monitor /* _LPARAM */) uintptr /* _BOOL */ {
if mi, ok := _GetMonitorInfoW_Ex(handle); ok { if mi, ok := _GetMonitorInfoW_Ex(handle); ok {
monitor := (*Monitor)(unsafe.Pointer(data))
if windows.UTF16ToString(mi.szDevice[:]) == monitor.win32.adapterName { if windows.UTF16ToString(mi.szDevice[:]) == monitor.win32.adapterName {
monitor.win32.handle = handle monitor.win32.handle = handle
} }