internal/glfwwin: skip functions for Xbox

Updates #2084
This commit is contained in:
Hajime Hoshi 2022-05-25 02:00:55 +09:00
parent 847357c3ea
commit ec2df98c70
3 changed files with 22 additions and 6 deletions

View File

@ -1457,6 +1457,10 @@ func _LoadImageW(hInst _HINSTANCE, name uintptr, typ uint32, cx int32, cy int32,
return windows.Handle(r), nil return windows.Handle(r), nil
} }
func _LoadImageW_Available() bool {
return procLoadImageW.Find() == nil
}
func _MapVirtualKeyW(uCode uint32, uMapType uint32) uint32 { func _MapVirtualKeyW(uCode uint32, uMapType uint32) uint32 {
r, _, _ := procMapVirtualKeyW.Call(uintptr(uCode), uintptr(uMapType)) r, _, _ := procMapVirtualKeyW.Call(uintptr(uCode), uintptr(uMapType))
return uint32(r) return uint32(r)
@ -1683,6 +1687,10 @@ func _SetProcessDpiAwarenessContext(value _DPI_AWARENESS_CONTEXT) error {
return nil return nil
} }
func _SetProcessDpiAwarenessContext_Available() bool {
return procSetProcessDpiAwarenessContext.Find() == nil
}
func _SetPropW(hWnd windows.HWND, str string, hData windows.Handle) error { func _SetPropW(hWnd windows.HWND, str string, hData windows.Handle) error {
var lpString *uint16 var lpString *uint16
if str != "" { if str != "" {

View File

@ -254,8 +254,10 @@ func platformInit() error {
createKeyTables() createKeyTables()
if isWindows10CreatorsUpdateOrGreaterWin32() { if isWindows10CreatorsUpdateOrGreaterWin32() {
if err := _SetProcessDpiAwarenessContext(_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) { if _SetProcessDpiAwarenessContext_Available() {
return err if err := _SetProcessDpiAwarenessContext(_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) {
return err
}
} }
} else if _IsWindows8Point1OrGreater() { } else if _IsWindows8Point1OrGreater() {
if err := _SetProcessDpiAwareness(_PROCESS_PER_MONITOR_DPI_AWARE); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) { if err := _SetProcessDpiAwareness(_PROCESS_PER_MONITOR_DPI_AWARE); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) {

View File

@ -1355,11 +1355,13 @@ func registerWindowClassWin32() error {
// In the original GLFW implementation, an embedded resource GLFW_ICON is used if possible. // In the original GLFW implementation, an embedded resource GLFW_ICON is used if possible.
// See https://www.glfw.org/docs/3.3/group__window.html // See https://www.glfw.org/docs/3.3/group__window.html
icon, err := _LoadImageW(0, _IDI_APPLICATION, _IMAGE_ICON, 0, 0, _LR_DEFAULTSIZE|_LR_SHARED) if _LoadImageW_Available() {
if err != nil { icon, err := _LoadImageW(0, _IDI_APPLICATION, _IMAGE_ICON, 0, 0, _LR_DEFAULTSIZE|_LR_SHARED)
return err if err != nil {
return err
}
wc.hIcon = _HICON(icon)
} }
wc.hIcon = _HICON(icon)
if _, err := _RegisterClassExW(&wc); err != nil { if _, err := _RegisterClassExW(&wc); err != nil {
return err return err
@ -2138,6 +2140,10 @@ func (c *Cursor) platformCreateCursor(image *Image, xhot, yhot int) error {
} }
func (c *Cursor) platformCreateStandardCursor(shape StandardCursor) error { func (c *Cursor) platformCreateStandardCursor(shape StandardCursor) error {
if !_LoadImageW_Available() {
return nil
}
var id int var id int
switch shape { switch shape {
case ArrowCursor: case ArrowCursor: