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

Function computeDeclaredDesktopSize

codersdk/workspacesdk/display.go:108–127  ·  view source on GitHub ↗
(nativeWidth, nativeHeight int)

Source from the content-addressed store, hash-verified

106}
107
108func computeDeclaredDesktopSize(nativeWidth, nativeHeight int) (declaredWidth, declaredHeight int) {
109 if desktopSizeFitsDeclaredLimits(nativeWidth, nativeHeight) {
110 return nativeWidth, nativeHeight
111 }
112
113 if nativeWidth >= nativeHeight {
114 for _, declaredWidth := range preferredDeclaredDesktopWidths {
115 if declaredWidth > nativeWidth {
116 continue
117 }
118
119 declaredHeight := max(1, declaredWidth*nativeHeight/nativeWidth)
120 if desktopSizeFitsDeclaredLimits(declaredWidth, declaredHeight) {
121 return declaredWidth, declaredHeight
122 }
123 }
124 }
125
126 return computeGenericDeclaredDesktopSize(nativeWidth, nativeHeight)
127}
128
129func desktopSizeFitsDeclaredLimits(width, height int) bool {
130 return max(width, height) <= desktopDeclaredMaxLongEdge &&

Callers 1

NewDesktopGeometryFunction · 0.85

Tested by

no test coverage detected