internal/glfwwin: remove unused members (a monitor size)

This commit is contained in:
Hajime Hoshi 2022-05-27 20:12:43 +09:00
parent d577cc5e7d
commit 3a6b707b29
4 changed files with 2 additions and 76 deletions

View File

@ -727,10 +727,8 @@ var (
procChoosePixelFormat = gdi32.NewProc("ChoosePixelFormat") procChoosePixelFormat = gdi32.NewProc("ChoosePixelFormat")
procCreateBitmap = gdi32.NewProc("CreateBitmap") procCreateBitmap = gdi32.NewProc("CreateBitmap")
procCreateDCW = gdi32.NewProc("CreateDCW")
procCreateDIBSection = gdi32.NewProc("CreateDIBSection") procCreateDIBSection = gdi32.NewProc("CreateDIBSection")
procCreateRectRgn = gdi32.NewProc("CreateRectRgn") procCreateRectRgn = gdi32.NewProc("CreateRectRgn")
procDeleteDC = gdi32.NewProc("DeleteDC")
procDeleteObject = gdi32.NewProc("DeleteObject") procDeleteObject = gdi32.NewProc("DeleteObject")
procDescribePixelFormat = gdi32.NewProc("DescribePixelFormat") procDescribePixelFormat = gdi32.NewProc("DescribePixelFormat")
procGetDeviceCaps = gdi32.NewProc("GetDeviceCaps") procGetDeviceCaps = gdi32.NewProc("GetDeviceCaps")
@ -945,44 +943,6 @@ func _CreateBitmap(nWidth int32, nHeight int32, nPlanes uint32, nBitCount uint32
return _HBITMAP(r), nil return _HBITMAP(r), nil
} }
func _CreateDCW(driver string, device string, port string, pdm *_DEVMODEW) (_HDC, error) {
var lpszDriver *uint16
if driver != "" {
var err error
lpszDriver, err = windows.UTF16PtrFromString(driver)
if err != nil {
panic("glfwwin: driver must not include a NUL character")
}
}
var lpszDevice *uint16
if device != "" {
var err error
lpszDevice, err = windows.UTF16PtrFromString(device)
if err != nil {
panic("glfwwin: device must not include a NUL character")
}
}
var lpszPort *uint16
if port != "" {
var err error
lpszPort, err = windows.UTF16PtrFromString(port)
if err != nil {
panic("glfwwin: port must not include a NUL character")
}
}
r, _, e := procCreateDCW.Call(uintptr(unsafe.Pointer(lpszDriver)), uintptr(unsafe.Pointer(lpszDevice)), uintptr(unsafe.Pointer(lpszPort)), uintptr(unsafe.Pointer(pdm)))
runtime.KeepAlive(lpszDriver)
runtime.KeepAlive(lpszDevice)
runtime.KeepAlive(lpszPort)
if _HDC(r) == 0 {
return 0, fmt.Errorf("glfwwin: CreateDCW failed: %w", e)
}
return _HDC(r), nil
}
func _CreateDIBSection(hdc _HDC, pbmi *_BITMAPV5HEADER, usage uint32, hSection windows.Handle, offset uint32) (_HBITMAP, *byte, error) { func _CreateDIBSection(hdc _HDC, pbmi *_BITMAPV5HEADER, usage uint32, hSection windows.Handle, offset uint32) (_HBITMAP, *byte, error) {
// pbmi is originally *BITMAPINFO. // pbmi is originally *BITMAPINFO.
var bits *byte var bits *byte
@ -1062,14 +1022,6 @@ func _DestroyWindow(hWnd windows.HWND) error {
return nil return nil
} }
func _DeleteDC(hdc _HDC) error {
r, _, e := procDeleteDC.Call(uintptr(hdc))
if int32(r) == 0 {
return fmt.Errorf("glfwwin: DeleteDC failed: %w", e)
}
return nil
}
func _DeleteObject(ho _HGDIOBJ) error { func _DeleteObject(ho _HGDIOBJ) error {
r, _, e := procDeleteObject.Call(uintptr(ho)) r, _, e := procDeleteObject.Call(uintptr(ho))
if int32(r) == 0 { if int32(r) == 0 {

View File

@ -220,9 +220,6 @@ type Window struct {
type Monitor struct { type Monitor struct {
name string name string
widthMM int
heightMM int
window *Window window *Window
modes []*VidMode modes []*VidMode

View File

@ -240,12 +240,7 @@ func (m *Monitor) GetWorkarea() (xpos, ypos, width, height int, err error) {
return return
} }
func (m *Monitor) GetPhysicalSize() (widthMM, heightMM int, err error) { // GetPhysicalSize is not implemented.
if !_glfw.initialized {
return 0, 0, NotInitialized
}
return m.widthMM, m.heightMM, nil
}
func (m *Monitor) GetContentScale() (xscale, yscale float32, err error) { func (m *Monitor) GetContentScale() (xscale, yscale float32, err error) {
if !_glfw.initialized { if !_glfw.initialized {

View File

@ -58,26 +58,8 @@ func createMonitor(adapter *_DISPLAY_DEVICEW, display *_DISPLAY_DEVICEW) (*Monit
return nil, nil return nil, nil
} }
var widthMM, heightMM int
dc, err := _CreateDCW("DISPLAY", adapterDeviceName, "", nil)
if err != nil {
return nil, err
}
if _IsWindows8Point1OrGreater() {
widthMM = int(_GetDeviceCaps(dc, _HORZSIZE))
heightMM = int(_GetDeviceCaps(dc, _VERTSIZE))
} else {
widthMM = int(float64(dm.dmPelsWidth) * 25.4 / float64(_GetDeviceCaps(dc, _LOGPIXELSX)))
heightMM = int(float64(dm.dmPelsHeight) * 25.4 / float64(_GetDeviceCaps(dc, _LOGPIXELSY)))
}
if err := _DeleteDC(dc); err != nil {
return nil, err
}
monitor := &Monitor{ monitor := &Monitor{
name: name, name: name,
widthMM: widthMM,
heightMM: heightMM,
} }
if adapter.StateFlags&_DISPLAY_DEVICE_MODESPRUNED != 0 { if adapter.StateFlags&_DISPLAY_DEVICE_MODESPRUNED != 0 {