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
}
func _LoadImageW_Available() bool {
return procLoadImageW.Find() == nil
}
func _MapVirtualKeyW(uCode uint32, uMapType uint32) uint32 {
r, _, _ := procMapVirtualKeyW.Call(uintptr(uCode), uintptr(uMapType))
return uint32(r)
@ -1683,6 +1687,10 @@ func _SetProcessDpiAwarenessContext(value _DPI_AWARENESS_CONTEXT) error {
return nil
}
func _SetProcessDpiAwarenessContext_Available() bool {
return procSetProcessDpiAwarenessContext.Find() == nil
}
func _SetPropW(hWnd windows.HWND, str string, hData windows.Handle) error {
var lpString *uint16
if str != "" {

View File

@ -254,8 +254,10 @@ func platformInit() error {
createKeyTables()
if isWindows10CreatorsUpdateOrGreaterWin32() {
if err := _SetProcessDpiAwarenessContext(_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) {
return err
if _SetProcessDpiAwarenessContext_Available() {
if err := _SetProcessDpiAwarenessContext(_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) {
return err
}
}
} else if _IsWindows8Point1OrGreater() {
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.
// 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 err != nil {
return err
if _LoadImageW_Available() {
icon, err := _LoadImageW(0, _IDI_APPLICATION, _IMAGE_ICON, 0, 0, _LR_DEFAULTSIZE|_LR_SHARED)
if err != nil {
return err
}
wc.hIcon = _HICON(icon)
}
wc.hIcon = _HICON(icon)
if _, err := _RegisterClassExW(&wc); err != nil {
return err
@ -2138,6 +2140,10 @@ func (c *Cursor) platformCreateCursor(image *Image, xhot, yhot int) error {
}
func (c *Cursor) platformCreateStandardCursor(shape StandardCursor) error {
if !_LoadImageW_Available() {
return nil
}
var id int
switch shape {
case ArrowCursor: