windowfocus

package
v2.22.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package windowfocus activates windows created by launched Windows processes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Focuser added in v2.21.0

type Focuser interface {
	Focus(ctx context.Context, pid uint32) error
}

Focuser activates the window of a launched process.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager waits for a launched process to create a top-level window and then asks Windows to activate it.

func (*Manager) Focus

func (m *Manager) Focus(ctx context.Context, pid uint32) error

Focus polls until the process owns a window that Windows accepts as foreground.

func (*Manager) HasWindow added in v2.21.0

func (m *Manager) HasWindow(pid uint32) bool

func (*Manager) HasWindowOfClass added in v2.21.0

func (m *Manager) HasWindowOfClass(pid uint32, classes []string) bool

HasWindow reports whether pid, or a process it started, owns a visible top-level window. It does not activate the window. HasWindowOfClass reports whether the process tree rooted at pid has a visible top-level window of one of the classes.

type Pending added in v2.21.0

type Pending struct {
	// contains filtered or unexported fields
}

Pending is a Focus call that is running in the background. Its outcome is the earliest sign that a launched program has a window that takes input.

func Start added in v2.21.0

func Start(ctx context.Context, f Focuser, pid uint32) *Pending

Start runs f.Focus for pid in the background.

func (*Pending) Err added in v2.21.0

func (p *Pending) Err(ctx context.Context) error

Err waits for the focus attempt to finish and returns its outcome: nil once the window took focus, the attempt's error if it gave up or was cancelled, or ctx's error if ctx ends first.

type Tracker added in v2.21.0

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker remembers the focus attempt of the process Core is tracking, so a readiness probe can wait for that process's window.

func (*Tracker) Forget added in v2.21.0

func (t *Tracker) Forget()

Forget drops the current attempt, as when its process is gone.

func (*Tracker) Track added in v2.21.0

func (t *Tracker) Track(ctx context.Context, f Focuser, pid uint32) *Pending

Track starts focusing pid's window and remembers the attempt as the current one, replacing any earlier attempt.

func (*Tracker) Wait added in v2.21.0

func (t *Tracker) Wait(ctx context.Context, clock clockwork.Clock, expectProcess bool) error

Wait returns once the tracked process's window has taken focus. A program that opens no window within the focus timeout is treated as ready: it is not waiting on anything Core can see.

With expectProcess the wait also covers a process that is not tracked yet, as with a launcher whose media is published before its game process exists; without it, no tracked process means there is nothing to wait for.

Jump to

Keyboard shortcuts

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