x11

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHANNEL_SIZE       = 256
	ERROR_CHANNEL_SIZE = 8
)
View Source
const (
	ModShift Keymod = 1 << 0
	ModLock         = 1 << 1
	ModCtrl         = 1 << 2
	Mod1            = 1 << 3
	Mod2            = 1 << 4
	Mod3            = 1 << 5
	Mod4            = 1 << 6
	Mod5            = 1 << 7
	ModNone         = 0
)
View Source
const (
	KeyBackspace xproto.Keycode = 22
	KeyEnter     xproto.Keycode = 104
	KeyEscape    xproto.Keycode = 9
	KeyLeft      xproto.Keycode = 113
	KeyMinus     xproto.Keycode = 20
	KeyRight     xproto.Keycode = 114
	KeyTab       xproto.Keycode = 23
	KeyAlt       xproto.Keycode = 64
	KeyCtrl      xproto.Keycode = 37
	KeyShift     xproto.Keycode = 50
	KeyA         xproto.Keycode = 38
	KeyB         xproto.Keycode = 56
	KeyC         xproto.Keycode = 54
	KeyD         xproto.Keycode = 40
	KeyE         xproto.Keycode = 26
	KeyF         xproto.Keycode = 41
	KeyG         xproto.Keycode = 42
	KeyH         xproto.Keycode = 43
	KeyI         xproto.Keycode = 31
	KeyJ         xproto.Keycode = 44
	KeyK         xproto.Keycode = 45
	KeyL         xproto.Keycode = 46
	KeyM         xproto.Keycode = 58
	KeyN         xproto.Keycode = 57
	KeyO         xproto.Keycode = 32
	KeyP         xproto.Keycode = 33
	KeyQ         xproto.Keycode = 24
	KeyR         xproto.Keycode = 27
	KeyS         xproto.Keycode = 39
	KeyT         xproto.Keycode = 28
	KeyU         xproto.Keycode = 30
	KeyV         xproto.Keycode = 55
	KeyW         xproto.Keycode = 25
	KeyX         xproto.Keycode = 53
	KeyY         xproto.Keycode = 29
	KeyZ         xproto.Keycode = 52
	Key1         xproto.Keycode = 10
	Key2         xproto.Keycode = 11
	Key3         xproto.Keycode = 12
	Key4         xproto.Keycode = 13
	Key5         xproto.Keycode = 14
	Key6         xproto.Keycode = 15
	Key7         xproto.Keycode = 16
	Key8         xproto.Keycode = 17
	Key9         xproto.Keycode = 18
	Key0         xproto.Keycode = 19
	KeyF1        xproto.Keycode = 67
	KeyF2        xproto.Keycode = 68
	KeyF3        xproto.Keycode = 69
	KeyF4        xproto.Keycode = 70
	KeyF5        xproto.Keycode = 71
	KeyF6        xproto.Keycode = 72
	KeyF7        xproto.Keycode = 73
	KeyF8        xproto.Keycode = 74
	KeyF9        xproto.Keycode = 75
	KeyF10       xproto.Keycode = 76
	KeyF11       xproto.Keycode = 95
	KeyF12       xproto.Keycode = 96
)

Variables

View Source
var ErrDied = errors.New("connection closed")

Functions

This section is empty.

Types

type ButtonEvent

type ButtonEvent struct {
	X     int16
	Y     int16
	Win   xproto.Window
	State uint16
	Time  xproto.Timestamp
}

func (ButtonEvent) Timestamp

func (e ButtonEvent) Timestamp() xproto.Timestamp

type Client added in v0.4.0

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

func NewClient added in v0.4.0

func NewClient() (*Client, error)

NewClient attempts to create a new X client.

func (*Client) Click added in v0.4.0

func (c *Client) Click(win xproto.Window) error

Click fakes a mouse click on the given window.

func (*Client) FocusWindow added in v0.4.0

func (c *Client) FocusWindow(win xproto.Window) error

FocusWindow switches input focus to the given window. It does so by sending a message to the root window indicating that it should update the _NET_ACTIVE_WINDOW property. See: https://specifications.freedesktop.org/wm-spec/1.3/ar01s03.html

func (*Client) GetActiveWindow added in v0.4.0

func (c *Client) GetActiveWindow() (xproto.Window, error)

GetActiveWindow returns the currently focused window.

func (*Client) GetAllWindows added in v0.4.0

func (c *Client) GetAllWindows() ([]xproto.Window, error)

GetAllWindows returns a list of all windows.

func (*Client) GetChildWindows added in v0.4.0

func (c *Client) GetChildWindows(win xproto.Window) ([]xproto.Window, error)

GetChildWindows returns a list of all children of the given window (and their children, and so on.)

func (*Client) GetWindowClass added in v0.4.0

func (c *Client) GetWindowClass(win xproto.Window) (string, error)

GetWindowClass returns the WM_CLASS property of the given window.

func (*Client) GetWindowPid added in v0.4.0

func (c *Client) GetWindowPid(win xproto.Window) (uint32, error)

GetWindowPid returns the process ID of the given window.

func (*Client) GetWindowSize added in v0.4.0

func (c *Client) GetWindowSize(win xproto.Window) (uint16, uint16, error)

GetWindowSize returns the size of the given window.

func (*Client) GetWindowTitle added in v0.4.0

func (c *Client) GetWindowTitle(win xproto.Window) (string, error)

GetWindowTitle returns the title of the given window.

func (*Client) GetWmName added in v0.4.0

func (c *Client) GetWmName() string

GetWmName returns the name of the window manager, if available.

func (*Client) GetWmSupported added in v0.4.0

func (c *Client) GetWmSupported() ([]string, error)

GetWmSupported returns a list of the window manager's supported properties as defined by _NET_SUPPORTED.

func (*Client) GrabKey added in v0.4.0

func (c *Client) GrabKey(key Key, win xproto.Window) error

GrabKey grabs a keyboard key from a window, diverting keypress events to resetti.

func (*Client) GrabPointer added in v0.4.0

func (c *Client) GrabPointer(win xproto.Window) error

GrabPointer grabs the mouse pointer from the given window.

func (*Client) MoveWindow added in v0.4.0

func (c *Client) MoveWindow(win xproto.Window, x, y, w, h uint32) error

MoveWindow moves and resizes the given window.

func (*Client) Poll added in v0.4.0

func (c *Client) Poll(ctx context.Context, substructures bool) (<-chan XEvent, <-chan error, error)

Poll starts a separate goroutine which will listen for and forward various input events (keypresses, mouse movements, button presses).

func (*Client) RootWindow added in v0.4.0

func (c *Client) RootWindow() xproto.Window

RootWindow returns the ID of the root window.

func (*Client) SendKeyDown added in v0.4.0

func (c *Client) SendKeyDown(code xproto.Keycode, win xproto.Window, timestamp *xproto.Timestamp)

SendKeyDown sends a key-down event with the given parameters. It increments the timestamp parameter by one to deal with a quirk of how GLFW handles key events.

See: https://github.com/glfw/glfw/blob/c18851f52ec9704eb06464058a600845ec1eada1/src/x11_window.c#L1250

func (*Client) SendKeyPress added in v0.4.0

func (c *Client) SendKeyPress(code xproto.Keycode, win xproto.Window, timestamp *xproto.Timestamp)

SendKeyPress sends a key-down and key-up event with the given parameters. It increments the timestamp parameter by one to deal with a quirk of how GLFW handles key events (as described in SendKeyDown.)

In addition to the timestamp difference check, repeated presses of the same key must circumvent another check - the timestamp must have at least a 20ms difference. In cases where this is necessary, send an alternating sequence of the key you want to press and a dummy key (such as Control) that will trick GLFW.

See: https://github.com/glfw/glfw/blob/c18851f52ec9704eb06464058a600845ec1eada1/src/x11_window.c#L1321

func (*Client) SendKeyUp added in v0.4.0

func (c *Client) SendKeyUp(code xproto.Keycode, win xproto.Window, timestamp *xproto.Timestamp)

SendKeyUp sends a key-up event with the given parameters.

Unlike SendKeyDown, it does *not* increment the timestamp parameter as GLFW's input handling does not require the timestamp to increase on key release events.

func (*Client) UngrabKey added in v0.4.0

func (c *Client) UngrabKey(key Key, win xproto.Window) error

UngrabKey releases a grabbed key and returns it back to the X server.

func (*Client) UngrabPointer added in v0.4.0

func (c *Client) UngrabPointer() error

UngrabPointer returns the mouse pointer to the X server.

type FocusEvent added in v0.4.0

type FocusEvent struct {
	Win  xproto.Window
	Time xproto.Timestamp
}

func (FocusEvent) Timestamp added in v0.4.0

func (e FocusEvent) Timestamp() xproto.Timestamp

type Key

type Key struct {
	Code xproto.Keycode
	Mod  Keymod
}

func (*Key) UnmarshalTOML

func (k *Key) UnmarshalTOML(value interface{}) error

type KeyEvent

type KeyEvent struct {
	Key   Key
	State KeyState
	Time  xproto.Timestamp
}

func (KeyEvent) Timestamp

func (e KeyEvent) Timestamp() xproto.Timestamp

type KeyState

type KeyState int
const (
	KeyUp KeyState = iota
	KeyDown
	KeyPress
)

type Keymod

type Keymod uint16

func (*Keymod) UnmarshalTOML

func (m *Keymod) UnmarshalTOML(value interface{}) error

type MoveEvent

type MoveEvent struct {
	X     int16
	Y     int16
	Win   xproto.Window
	State uint16
	Time  xproto.Timestamp
}

func (MoveEvent) Timestamp

func (e MoveEvent) Timestamp() xproto.Timestamp

type XEvent added in v0.4.0

type XEvent interface {
	Timestamp() xproto.Timestamp
}

Jump to

Keyboard shortcuts

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