Documentation
¶
Index ¶
- Variables
- func ContainsLogicalPoint(m Monitor, x, y int) bool
- func ContainsPhysicalPoint(m Monitor, x, y int) bool
- type FitMode
- type Monitor
- type Rect
- func FitToMonitor(m Monitor, mode FitMode, window Rect) (Rect, error)
- func FitToNearestMonitor(monitors []Monitor, mode FitMode, window Rect, minWidth, minHeight int) (Rect, error)
- func InitialPlacement(minWidth, minHeight, desiredWidth, desiredHeight, margin int) Rect
- func LogicalToPhysical(m Monitor, logical Rect) Rect
- func PhysicalToLogical(m Monitor, physical Rect) Rect
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidDimensions = errors.New("invalid dimensions: negative width or height")
ErrInvalidDimensions is returned when a window or monitor has negative dimensions
var ErrNoMonitors = errors.New("no monitors available")
ErrNoMonitors is returned when no monitors are available for fitting
Functions ¶
func ContainsLogicalPoint ¶
ContainsLogicalPoint checks if a logical point is within the monitor's logical bounds
func ContainsPhysicalPoint ¶
ContainsPhysicalPoint checks if a physical point is within the monitor's physical bounds
Types ¶
type Monitor ¶
Monitor represents a display monitor and its properties
func FindMonitorFromLogicalPoint ¶
FindMonitorFromLogicalPoint finds the monitor that contains the given logical point
func FindMonitorFromLogicalRect ¶
FindMonitorFromLogicalRect finds a monitor with the largest overlap with the given rect
func FindMonitorFromPhysicalPoint ¶
FindMonitorFromPhysicalPoint finds the monitor that contains the given physical point
type Rect ¶
Rect represents a rectangle with coordinates in screen space
func FitToMonitor ¶
FitToMonitor fits a window to a specific monitor. All coordinates are in logical space. Returns error if window or monitor has negative dimensions.
func FitToNearestMonitor ¶
func FitToNearestMonitor(monitors []Monitor, mode FitMode, window Rect, minWidth, minHeight int) (Rect, error)
FitToNearestMonitor finds the most appropriate monitor and fits the window to it. If minWidth and minHeight are > 0, it will try to find a monitor that can fit these minimum dimensions. Returns error if window has negative dimensions or if no valid monitors are available.
func InitialPlacement ¶ added in v0.2.0
InitialPlacement calculates the initial window placement on a default monitor. The default monitor is either: - The monitor containing point (0,0) in logical coordinates - If no monitor contains (0,0), the monitor with largest logical area
All calculations are performed in logical (scaled) coordinates, accounting for the system's DPI settings and scaling factors.
Parameters: - minWidth, minHeight: minimum required window size in logical pixels - desiredWidth, desiredHeight: preferred window size in logical pixels (will be clamped if exceeds work area) - margin: minimum distance from work area edges in logical pixels
Returns a Rect with the calculated window position and size in logical coordinates.
func LogicalToPhysical ¶
LogicalToPhysical converts logical coordinates to physical coordinates for a given monitor
func PhysicalToLogical ¶
PhysicalToLogical converts physical coordinates to logical coordinates for a given monitor