MCPcopy Index your code
hub / github.com/coder/coder / NewDesktopGeometryWithDeclared

Function NewDesktopGeometryWithDeclared

codersdk/workspacesdk/display.go:71–92  ·  view source on GitHub ↗

NewDesktopGeometryWithDeclared returns a geometry that preserves the native desktop size while using the provided declared model-facing dimensions.

(
	nativeWidth,
	nativeHeight,
	declaredWidth,
	declaredHeight int,
)

Source from the content-addressed store, hash-verified

69// NewDesktopGeometryWithDeclared returns a geometry that preserves the native
70// desktop size while using the provided declared model-facing dimensions.
71func NewDesktopGeometryWithDeclared(
72 nativeWidth,
73 nativeHeight,
74 declaredWidth,
75 declaredHeight int,
76) DesktopGeometry {
77 nativeWidth = sanitizeDesktopDimension(nativeWidth)
78 nativeHeight = sanitizeDesktopDimension(nativeHeight)
79 if declaredWidth <= 0 {
80 declaredWidth = nativeWidth
81 }
82 if declaredHeight <= 0 {
83 declaredHeight = nativeHeight
84 }
85
86 return DesktopGeometry{
87 NativeWidth: nativeWidth,
88 NativeHeight: nativeHeight,
89 DeclaredWidth: sanitizeDesktopDimension(declaredWidth),
90 DeclaredHeight: sanitizeDesktopDimension(declaredHeight),
91 }
92}
93
94// DeclaredPointToNative maps a point from declared model-facing coordinates to
95// native desktop coordinates using the existing pixel-center truncation rule.

Calls 1

sanitizeDesktopDimensionFunction · 0.85