desktop

package
v0.3.27 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ScreenDebug turns on various debugging statements about monitor changes
	// and updates from glfw.
	ScreenDebug = false

	// ScreenPollInterval is the time between checking if screens have changed.
	// This is primarily for detecting changes after sleep, in which case
	// the interval has likely been much longer than a few seconds.
	ScreenPollInterval = time.Second

	// Note: MacOS monitor situation is significantly buggy.  we try to work around this.
	// https://github.com/glfw/glfw/issues/2160
	MacOsBuiltinMonitor = "Built-in Retina Display"
)
View Source
var TheApp = &App{AppMulti: base.NewAppMulti[*Window]()}

TheApp is the single system.App for the desktop platform

View Source
var TheClipboard = &Clipboard{}

TheClipboard is the single system.Clipboard for Linux

View Source
var TheCursor = &Cursor{CursorBase: system.CursorBase{Vis: true, Size: units.Dp(32)}, cursors: map[enums.Enum]map[int]*glfw.Cursor{}}

TheCursor is the single system.Cursor for the desktop platform

Functions

func GlfwKeyCode

func GlfwKeyCode(kcode glfw.Key) key.Codes

TODO: should this be a map?

func GlfwMods

func GlfwMods(mod glfw.ModifierKey) key.Modifiers

func Init

func Init()

Types

type App

type App struct {
	base.AppMulti[*Window]

	// GPU is the system GPU used for the app
	GPU *gpu.GPU

	// Monitors are pointers to the glfw monitors corresponding to Screens.
	Monitors []*glfw.Monitor
}

App is the system.App implementation for the desktop platform

func (*App) Clipboard

func (a *App) Clipboard(win system.Window) system.Clipboard

func (*App) Cursor

func (a *App) Cursor(win system.Window) system.Cursor

func (*App) DataDir

func (a *App) DataDir() string

func (*App) FindScreenInfo

func (a *App) FindScreenInfo(name string) (*system.Screen, bool)

FindScreenInfo finds saved screen info based on name

func (*App) GetScreens

func (a *App) GetScreens()

func (*App) InitGPU added in v0.3.2

func (a *App) InitGPU()

InitGPU initializes glfw, gpu, and the screens.

func (*App) MainLoop

func (a *App) MainLoop()

MainLoop starts running event loop on main thread (must be called from the main thread).

func (*App) MonitorChange

func (a *App) MonitorChange(monitor *glfw.Monitor, event glfw.PeripheralEvent)

MonitorChange is called when a monitor is connected to or disconnected from the system.

func (*App) NewWindow

func (a *App) NewWindow(opts *system.NewWindowOptions) (system.Window, error)

func (*App) OpenURL

func (a *App) OpenURL(url string)

func (*App) Platform

func (a *App) Platform() system.Platforms

func (*App) PollScreenChanges added in v0.3.6

func (a *App) PollScreenChanges()

func (*App) SaveScreenInfo

func (a *App) SaveScreenInfo(sc *system.Screen) bool

SaveScreenInfo saves a copy of given screen info to screensAll list if unique based on name. Returns true if added a new screen.

func (*App) SendEmptyEvent

func (a *App) SendEmptyEvent()

SendEmptyEvent sends an empty, blank event to global event processing system, which has the effect of pushing the system along during cases when the event loop needs to be "pinged" to get things moving along..

type Clipboard

type Clipboard struct{}

Clipboard is the system.Clipboard implementation for Linux

func (*Clipboard) Clear

func (cl *Clipboard) Clear()

func (*Clipboard) IsEmpty

func (cl *Clipboard) IsEmpty() bool

func (*Clipboard) Read

func (cl *Clipboard) Read(types []string) mimedata.Mimes

func (*Clipboard) Write

func (cl *Clipboard) Write(data mimedata.Mimes) error

type Cursor

type Cursor struct {
	system.CursorBase
	// contains filtered or unexported fields
}

Cursor is the [cursor.Cursor] implementation for the desktop platform

func (*Cursor) Set

func (cu *Cursor) Set(cursor enums.Enum) error

type Window

type Window struct {
	base.WindowMulti[*App, *composer.ComposerDrawer]

	// Glw is the glfw window associated with this window
	Glw *glfw.Window

	// Draw is the [gpudraw.Drawer] used for the Composer.
	Draw *gpudraw.Drawer // TODO: really need this separately?

	// ScreenName is the name of the last known screen this window was on
	ScreenWindow string
}

Window is the implementation of system.Window for the desktop platform.

func (*Window) Activate

func (w *Window) Activate() bool

Activate() sets this window as the current render target for gpu rendering functions, and the current context for gpu state (equivalent to MakeCurrentContext on OpenGL). If it returns false, then window is not visible / valid and nothing further should happen. Must call this on app main thread using system.TheApp.RunOnMain

system.TheApp.RunOnMain(func() {
   if !win.Activate() {
       return
   }
   // do GPU calls here
})

func (*Window) CharEvent

func (w *Window) CharEvent(gw *glfw.Window, char rune, mod glfw.ModifierKey)

char input

func (*Window) Close

func (w *Window) Close()

func (*Window) ConstrainFrame added in v0.3.6

func (w *Window) ConstrainFrame(topOnly bool) sides.Sides[int]

func (*Window) CurMousePosPoint

func (w *Window) CurMousePosPoint(gw *glfw.Window) image.Point

func (*Window) CursorEnterEvent

func (w *Window) CursorEnterEvent(gw *glfw.Window, entered bool)

func (*Window) CursorPosEvent

func (w *Window) CursorPosEvent(gw *glfw.Window, x, y float64)

func (*Window) DeActivate

func (w *Window) DeActivate()

DeActivate() clears the current render target and gpu rendering context. Generally more efficient to NOT call this and just be sure to call Activate where relevant, so that if the window is already current context no switching is required. Must call this on app main thread using system.TheApp.RunOnMain

func (*Window) DropEvent

func (w *Window) DropEvent(gw *glfw.Window, names []string)

func (*Window) FbResized

func (w *Window) FbResized(gw *glfw.Window, width, height int)

func (*Window) FocusWindow

func (w *