desktop

package
v1.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package desktop holds the pieces of the Windows application that do not need Win32.

Index

Constants

View Source
const (
	DensityLarge    = "large"
	DensityStandard = "standard"
	DensityCompact  = "compact"
)

Variables

This section is empty.

Functions

func DIBFromIcon

func DIBFromIcon(ico []byte) []byte

DIBFromIcon returns the image data of a single-image .ico (without the ICO header), which is what CreateIconFromResourceEx expects.

func FormatRate

func FormatRate(bytesPerSec int64, bits bool) string

FormatRate writes a speed given in bytes per second, either as bytes (КБ/с, МБ/с: binary prefixes, like sizes) or as bits (Кб/с, Мб/с: decimal prefixes, the way networks are measured).

func Icon

func Icon() []byte

Icon returns a 32x32 .ico image: equinox, drawn as a circle split into a sunlit half and a night half, tilted by Earth's axial tilt (23.4°), with a sun and a moon set into the two halves. It is drawn in code so the executable needs no resource files.

func PNG

func PNG(n int) []byte

PNG returns the same picture as a PNG of the given size (for the executable's resources).

func PosVisible added in v1.0.1

func PosVisible(x, y, vx, vy, vw, vh int) bool

PosVisible reports whether a window at (x, y) would still be reachable on a screen area (the whole desktop): a monitor that was unplugged must not leave the window out of sight.

func ValidDensity added in v1.0.1

func ValidDensity(d string) bool

ValidDensity reports whether d is one of the known densities.

Types

type Size added in v1.0.1

type Size struct {
	W int `json:"w"`
	H int `json:"h"`
}

Size is in pixels.

func DefaultSize added in v1.0.1

func DefaultSize(d string) Size

DefaultSize is the client size of a window that has no remembered size.

func MinSize added in v1.0.1

func MinSize(d string) Size

MinSize is the smallest outer size the window may be given.

type WindowPrefs added in v1.0.1

type WindowPrefs struct {
	Density string          `json:"density"`
	HasPos  bool            `json:"hasPos"`
	X       int             `json:"x"` // outer position
	Y       int             `json:"y"`
	Max     bool            `json:"maximized"`
	Sizes   map[string]Size `json:"sizes"` // outer sizes the person has left the window at
}

WindowPrefs is what is remembered about the window.

func LoadWindowPrefs added in v1.0.1

func LoadWindowPrefs(path string) WindowPrefs

LoadWindowPrefs reads the file; a missing or broken file gives the defaults.

func (*WindowPrefs) ForgetSize added in v1.0.1

func (p *WindowPrefs) ForgetSize(d string)

ForgetSize drops the remembered size of a density, so it goes back to the default.

func (WindowPrefs) Save added in v1.0.1

func (p WindowPrefs) Save(path string) error

Save writes the file (through a temporary one, so a crash cannot leave half of it).

func (WindowPrefs) Saved added in v1.0.1

func (p WindowPrefs) Saved(d string) (Size, bool)

Saved returns the remembered outer size for a density, if there is one.

func (*WindowPrefs) SetSize added in v1.0.1

func (p *WindowPrefs) SetSize(d string, s Size)

SetSize remembers the outer size for a density.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL