MCPcopy Create free account
hub / github.com/cogentcore/core / pref

Method pref

core/windowgeometry.go:312–343  ·  view source on GitHub ↗

pref returns an existing preference for given window name, for given screen. if the window name has a colon, only the part prior to the colon is used. if no saved pref is available for that screen, nil is returned.

(winName string, scrn *system.Screen)

Source from the content-addressed store, hash-verified

310// if the window name has a colon, only the part prior to the colon is used.
311// if no saved pref is available for that screen, nil is returned.
312func (ws *windowGeometrySaver) pref(winName string, scrn *system.Screen) *windowGeometry {
313 ws.mu.RLock()
314 defer ws.mu.RUnlock()
315
316 if ws.geometries == nil {
317 return nil
318 }
319 winName = ws.windowName(winName)
320 wps, ok := ws.cache[winName]
321 if !ok {
322 wps, ok = ws.geometries[winName]
323 if !ok {
324 return nil
325 }
326 }
327
328 if scrn == nil {
329 scrn = system.TheApp.Screen(0)
330 if DebugSettings.WinGeomTrace {
331 log.Printf("WindowGeometry: Pref: scrn is nil, using scrn 0: %v\n", scrn.Name)
332 }
333 }
334 wp, ok := wps[scrn.Name]
335 if ok {
336 wp.constrainGeom(scrn)
337 if DebugSettings.WinGeomTrace {
338 log.Printf("WindowGeometry: Pref: Setting geom for window: %v pos: %v size: %v screen: %v dpi: %v device pixel ratio: %v\n", winName, wp.pos(), wp.size(), scrn.Name, scrn.LogicalDPI, scrn.DevicePixelRatio)
339 }
340 return &wp
341 }
342 return nil
343}
344
345// deleteAll deletes the file that saves the position and size of each window,
346// by screen, and clear current in-memory cache. You shouldn't need to use

Callers 3

restoreAllMethod · 0.95
newRenderWindowMethod · 0.80
setNameMethod · 0.80

Calls 6

windowNameMethod · 0.95
constrainGeomMethod · 0.80
posMethod · 0.80
ScreenMethod · 0.65
sizeMethod · 0.65
PrintfMethod · 0.45

Tested by

no test coverage detected