x11

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package x11 provides a simple client for interacting with the X server to do things like sending input events.

Index

Constants

This section is empty.

Variables

View Source
var (
	KeyEsc   = xproto.Keycode(9)
	KeyF1    = xproto.Keycode(67)
	KeyF3    = xproto.Keycode(69)
	KeyF6    = xproto.Keycode(72)
	KeyH     = xproto.Keycode(43)
	KeyShift = xproto.Keycode(50)
)

Important keys

View Source
var Buttons = map[string]xproto.Button{
	"lmb":         xproto.ButtonIndex1,
	"leftclick":   xproto.ButtonIndex1,
	"leftmouse":   xproto.ButtonIndex1,
	"mouse1":      xproto.ButtonIndex1,
	"m1":          xproto.ButtonIndex1,
	"mmb":         xproto.ButtonIndex2,
	"middleclick": xproto.ButtonIndex2,
	"middlemouse": xproto.ButtonIndex2,
	"mouse2":      xproto.ButtonIndex2,
	"m2":          xproto.ButtonIndex2,
	"rmb":         xproto.ButtonIndex3,
	"rightclick":  xproto.ButtonIndex3,
	"rightmouse":  xproto.ButtonIndex3,
	"mouse3":      xproto.ButtonIndex3,
	"m3":          xproto.ButtonIndex3,
	"mouse4":      xproto.ButtonIndex4,
	"m4":          xproto.ButtonIndex4,
	"mouse5":      xproto.ButtonIndex5,
	"m5":          xproto.ButtonIndex5,
}

Buttons is a list of buttons used for config parsing.

View Source
var (
	ErrConnectionDied = errors.New("connection with X server closed")
)

Error types

View Source
var Keycodes = map[string]xproto.Keycode{

	"0":            19,
	"1":            10,
	"2":            11,
	"3":            12,
	"4":            13,
	"5":            14,
	"6":            15,
	"7":            16,
	"8":            17,
	"9":            18,
	"a":            38,
	"b":            56,
	"c":            54,
	"d":            40,
	"e":            26,
	"f":            41,
	"g":            42,
	"h":            43,
	"i":            31,
	"j":            44,
	"k":            45,
	"l":            46,
	"m":            58,
	"n":            57,
	"o":            32,
	"p":            33,
	"q":            24,
	"r":            27,
	"s":            39,
	"t":            28,
	"u":            30,
	"v":            55,
	"w":            25,
	"x":            53,
	"y":            29,
	"z":            52,
	"f1":           67,
	"f2":           68,
	"f3":           69,
	"f4":           70,
	"f5":           71,
	"f6":           72,
	"f7":           73,
	"f8":           74,
	"f9":           75,
	"f10":          76,
	"f11":          95,
	"f12":          96,
	"down":         116,
	"left":         113,
	"right":        114,
	"up":           111,
	"apostrophe":   48,
	"grave":        49,
	"backslash":    51,
	"comma":        59,
	"equal":        21,
	"minus":        20,
	"period":       60,
	"semicolon":    47,
	"slash":        61,
	"space":        65,
	"tab":          23,
	"enter":        36,
	"return":       36,
	"escape":       9,
	"esc":          9,
	"backspace":    22,
	"delete":       119,
	"del":          119,
	"end":          115,
	"home":         110,
	"insert":       118,
	"ins":          118,
	"pause":        127,
	"menu":         135,
	"print.screen": 107,
	"printscreen":  107,
}

Keycodes is a list of keycodes used for config parsing.

View Source
var KeycodesMc = map[string]xproto.Keycode{
	"0":               19,
	"1":               10,
	"2":               11,
	"3":               12,
	"4":               13,
	"5":               14,
	"6":               15,
	"7":               16,
	"8":               17,
	"9":               18,
	"a":               38,
	"b":               56,
	"c":               54,
	"d":               40,
	"e":               26,
	"f":               41,
	"g":               42,
	"h":               43,
	"i":               31,
	"j":               44,
	"k":               45,
	"l":               46,
	"m":               58,
	"n":               57,
	"o":               32,
	"p":               33,
	"q":               24,
	"r":               27,
	"s":               39,
	"t":               28,
	"u":               30,
	"v":               55,
	"w":               25,
	"x":               53,
	"y":               29,
	"z":               52,
	"f1":              67,
	"f2":              68,
	"f3":              69,
	"f4":              70,
	"f5":              71,
	"f6":              72,
	"f7":              73,
	"f8":              74,
	"f9":              75,
	"f10":             76,
	"f11":             95,
	"f12":             96,
	"keypad.0":        90,
	"keypad.1":        87,
	"keypad.2":        88,
	"keypad.3":        89,
	"keypad.4":        83,
	"keypad.5":        84,
	"keypad.6":        85,
	"keypad.7":        79,
	"keypad.8":        80,
	"keypad.9":        81,
	"keypad.add":      86,
	"keypad.decimal":  91,
	"keypad.enter":    104,
	"keypad.equal":    125,
	"keypad.multiply": 63,
	"keypad.divide":   106,
	"keypad.subtract": 82,
	"down":            116,
	"left":            113,
	"right":           114,
	"up":              111,
	"apostrophe":      48,
	"grave.accent":    49,
	"backslash":       51,
	"comma":           59,
	"equal":           21,
	"left.bracket":    34,
	"minus":           20,
	"period":          60,
	"right.bracket":   35,
	"semicolon":       47,
	"slash":           61,
	"space":           65,
	"tab":             23,
	"enter":           36,
	"escape":          9,
	"backspace":       22,
	"delete":          119,
	"end":             115,
	"home":            110,
	"insert":          118,
	"pause":           127,
	"menu":            135,
	"print.screen":    107,
}

KeycodesMc is a list of keycodes used for parsing Minecraft options.

View Source
var Modifiers = map[string]xproto.Keycode{
	"ctrl":     37,
	"control":  37,
	"lctrl":    37,
	"lcontrol": 37,
	"shift":    50,
	"lshift":   50,
	"rshift":   62,
	"alt":      64,
	"lalt":     64,
	"rctrl":    105,
	"rcontrol": 105,
}

Keycodes is a list of modifier keycodes used for config parsing.

Functions

This section is empty.

Types

type Client

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

Client maintains a connection with the X server and performs tasks like sending fake inputs and receiving user input.

func NewClient

func NewClient() (Client, error)

NewClient attempts to create a new Client.

func (*Client) Click

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

Click clicks the top left corner (0, 0) of the given window.

func (*Client) FocusWindow

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

FocusWindow activates the given window.

func (*Client) GetActiveWindow

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

GetActiveWindow returns the active window.

func (*Client) GetCurrentTime

func (c *Client) GetCurrentTime() uint32

GetCurrentTime returns the approximate current X server time.

func (*Client) GetRootWindow

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

GetRootWindow returns the ID of the root window.

func (*Client) GetWindowChildren

func (c *Client) GetWindowChildren(win xproto.Window) []xproto.Window

GetWindowChildren returns a list of all child windows (and their children, and so on) for the given window.

func (*Client) GetWindowClass

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

GetWindowClass returns the class of the given window.

func (*Client) GetWindowList

func (c *Client) GetWindowList() []xproto.Window

GetWindowList returns a list of all open windows.

func (*Client) GetWindowPid

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

GetWindowPid returns the PID of the process that owns the given window.

func (*Client) GetWindowSize

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

GetWindowSize returns the size of the given window.

func (*Client) GetWindowTitle

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

GetWindowTitle returns the title of the given window.

func (*Client) GrabPointer

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

GrabPointer grabs the mouse pointer, diverting all mouse events to resetti.

func (*Client) MoveWindow

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

MoveWindow moves and resizes the given window.

func (*Client) Poll

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

Poll starts listening for window focus changes in the background.

func (*Client) QueryKeymap

func (c *Client) QueryKeymap() (Keymap, error)

QueryKeymap queries the state of the keyboard.

func (*Client) QueryPointer

func (c *Client) QueryPointer(win xproto.Window) (Pointer, error)

QueryPointer queries the state of the pointer.

func (*Client) SendKeyDown

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

SendKeyDown sends a key down event to the given window with the given key.

func (*Client) SendKeyPress

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

SendKeyPress sends a key press (key down and key up event) to the given window with the given key.

func (*Client) SendKeyUp

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

SendKeyUp sends a key up event to the given window with the given key.

func (*Client) UngrabPointer

func (c *Client) UngrabPointer() error

UngrabPointer ungrabs the mouse pointer.

func (*Client) WarpPointer

func (c *Client) WarpPointer(x, y int, dest xproto.Window)

WarpPointer warps the mouse pointer.

type Event

type Event any

Event represents an event from the X server to be processed by resetti.

type FocusEvent

type FocusEvent xproto.Window

FocusEvent represents a window focus change.

type InputState

type InputState int

InputState represents the state of a button or key (up or down.)

const (
	StateDown InputState = iota
	StateUp
)

Key/button states

type Keymap

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

Keymap contains information about the state of the user's keyboard.

func (*Keymap) HasPressed

func (k *Keymap) HasPressed(mask [32]byte) bool

HasPressed determines whether all of the given keys are pressed in the keymap.

type Pointer

type Pointer struct {
	RootX, RootY, EventX, EventY int
	Window                       xproto.Window
	// contains filtered or unexported fields
}

Pointer contains information about the state of the mouse pointer.

func (*Pointer) HasPressed

func (p *Pointer) HasPressed(button xproto.Button) bool

HasPressed determines whether all of the given buttons are pressed in the keymap.

Jump to

Keyboard shortcuts

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