### Install the Cube example with Vulkan support Source: https://github.com/neurlang/wayland/blob/master/_autodocs/configuration.md Use the wayland build tag to install the cube example package. ```bash go install -tags wayland github.com/neurlang/wayland/go-wayland-cube@latest ``` -------------------------------- ### Setup and Generate Shaders Source: https://github.com/neurlang/wayland/blob/master/go-wayland-cube/SHADERS.md Install the required glslang tools and execute the generation process to compile shaders. ```bash # Install glslangValidator (one-time setup) sudo apt install glslang-tools # Ubuntu/Debian # or sudo dnf install glslang # Fedora/RHEL # Generate shaders cd go-wayland-cube go generate ``` -------------------------------- ### Install Wayland Demos Source: https://github.com/neurlang/wayland/blob/master/README.md Commands to fetch and install the sample Wayland applications. ```bash go get github.com/neurlang/wayland/... ``` ```bash go install github.com/neurlang/wayland/go-wayland-simple-shm@latest go install github.com/neurlang/wayland/go-wayland-smoke@latest go install github.com/neurlang/wayland/go-wayland-imageviewer@latest go install -tags wayland github.com/neurlang/wayland/go-wayland-cube@latest go install github.com/neurlang/wayland/go-wayland-texteditor@latest go install github.com/neurlang/wayland/go-wayland-web-browser/browser@latest ``` -------------------------------- ### Build and Run macOS Examples Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_RENDERING_FIX.md Commands to compile and execute the example applications to verify rendering and event handling fixes. ```bash # Build one of the example applications go build -tags darwin,cgo ./go-wayland-simple-shm # Or build the smoke demo go build -tags darwin,cgo ./go-wayland-smoke # Run it ./go-wayland-simple-shm ``` -------------------------------- ### Initialize Rectangle Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Example of creating a new Rectangle instance. ```go bounds := window.Rectangle{X: 0, Y: 0, Width: 800, Height: 600} ``` -------------------------------- ### Install Demos for Older Go Versions Source: https://github.com/neurlang/wayland/blob/master/README.md Commands to fetch sample applications for Go versions 1.18 and above. ```bash go get github.com/neurlang/wayland/go-wayland-simple-shm@latest go get github.com/neurlang/wayland/go-wayland-smoke@latest go get github.com/neurlang/wayland/go-wayland-imageviewer@latest go get github.com/neurlang/wayland/go-wayland-texteditor@latest ``` -------------------------------- ### Set decoration theme Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Example of applying a theme to a window. ```go w.SetDecorationTheme(window.ThemeDark) ``` -------------------------------- ### Implement and register keyboard handler Source: https://github.com/neurlang/wayland/blob/master/_autodocs/03-window-package.md Example implementation of the KeyboardHandler interface and registration with a window. ```go type MyKeyboardHandler struct{} func (h *MyKeyboardHandler) HandleKeyboardKey(ev window.KeyboardEvent) { // Process key press/release } func (h *MyKeyboardHandler) HandleKeyboardModifiers(ev window.ModifiersEvent) { // Process modifier changes } w.SetKeyboardHandler(&MyKeyboardHandler{}) ``` -------------------------------- ### Install Linux Runtime Dependencies Source: https://github.com/neurlang/wayland/blob/master/_autodocs/configuration.md System-level installation commands for required keyboard support libraries on Debian/Ubuntu and Fedora/RHEL distributions. ```bash # Debian/Ubuntu sudo apt-get install libxkbcommon-dev # Fedora/RHEL sudo dnf install libxkbcommon-devel ``` -------------------------------- ### Install Golang on Linux Source: https://github.com/neurlang/wayland/blob/master/README.md Commands to install the Go programming language on Debian-based or Fedora-based Linux distributions. ```bash sudo apt-get install golang ``` ```bash sudo dnf install golang ``` -------------------------------- ### Initialize and Run Window Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_WINDOW_FEATURES.md Basic usage pattern for creating a display, initializing a window, and starting the blocking event loop. ```go // Create display display, _ := DisplayCreate(os.Args) // Create window (200x200) window := Create(display) window.SetTitle("My App") // Add widget with handler widget := window.AddWidget(myHandler) // Run event loop (blocks) DisplayRun(display) ``` -------------------------------- ### Install Xcode Command Line Tools and Build Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_IMPLEMENTATION.md Commands to prepare the environment and build the project for macOS. ```bash # Requires macOS with Xcode Command Line Tools xcode-select --install # Build tags automatically select darwin implementation GOOS=darwin go build ./window ``` -------------------------------- ### Implement Toplevel Handler Source: https://github.com/neurlang/wayland/blob/master/_autodocs/07-xdg-shell.md Example implementation of a Toplevel handler. ```go type MyToplevelHandler struct { toplevel *xdg.Toplevel surface *xdg.Surface } func (h *MyToplevelHandler) HandleToplevelConfigure(ev xdg.ToplevelConfigureEvent) { fmt.Printf("Size: %dx%d\n", ev.Width, ev.Height) // Resize window as needed } func (h *MyToplevelHandler) HandleToplevelClose(ev xdg.ToplevelCloseEvent) { // User requested close os.Exit(0) } handler := &MyToplevelHandler{} xdg.ToplevelAddListener(toplevel, handler) ``` -------------------------------- ### Install Linux Dependencies Source: https://github.com/neurlang/wayland/blob/master/README.md Commands to install required system packages for Wayland, keyboard support, and Vulkan on Linux. ```bash sudo apt-get install weston ``` ```bash sudo apt-get install libxkbcommon-dev ``` ```bash sudo dnf install libxkbcommon-devel ``` ```bash sudo apt-get install libwayland-dev libvulkan-dev ``` ```bash sudo apt-get install libnvidia-egl-wayland1 ``` -------------------------------- ### Install glslang on Arch Linux Source: https://github.com/neurlang/wayland/blob/master/go-wayland-cube/shaders/README.md Install the required GLSL compiler tools on Arch Linux. ```bash sudo pacman -S glslang ``` -------------------------------- ### Initialize and Run a macOS Window Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_IMPLEMENTATION.md Basic usage pattern for creating a display, a window, and starting the event loop. ```go import "github.com/neurlang/wayland/window" // Create display display, err := window.DisplayCreate(os.Args) if err != nil { log.Fatal(err) } defer display.Destroy() // Create window win := window.Create(display) win.SetTitle("My macOS App") // Add widget widget := win.AddWidget(myHandler) // Run event loop window.DisplayRun(display) ``` -------------------------------- ### Install glslang-tools on Ubuntu/Debian Source: https://github.com/neurlang/wayland/blob/master/go-wayland-cube/shaders/README.md Install the required GLSL compiler tools on Debian-based distributions. ```bash sudo apt install glslang-tools ``` -------------------------------- ### Handle Key Events in Go Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_KEYSYMS.md Example of switching on key codes using the xkbcommon package. ```go import "github.com/neurlang/wayland/xkbcommon" func handleKey(keyCode uint32) { switch keyCode { case xkbcommon.KeyQ, xkbcommon.KEYq: fmt.Println("Q key pressed") case xkbcommon.KeyEscape: fmt.Println("Escape pressed") case xkbcommon.KeyReturn: fmt.Println("Return pressed") } } ``` -------------------------------- ### Implement XDG Window Setup Pattern Source: https://github.com/neurlang/wayland/blob/master/_autodocs/07-xdg-shell.md Standard boilerplate for creating an XDG surface and toplevel window, including necessary event listeners. ```go package main import ( "github.com/neurlang/wayland/wl" "github.com/neurlang/wayland/wlclient" "github.com/neurlang/wayland/xdg" ) type MyWindow struct { surface *xdg.Surface toplevel *xdg.Toplevel } func (w *MyWindow) HandleSurfaceConfigure(ev xdg.SurfaceConfigureEvent) { w.surface.AckConfigure(ev.Serial) } func (w *MyWindow) HandleToplevelConfigure(ev xdg.ToplevelConfigureEvent) { // Resize buffers if needed } func (w *MyWindow) HandleToplevelClose(ev xdg.ToplevelCloseEvent) { // Clean exit } func createWindow(shell *xdg.WmBase, compositor *wl.Compositor, width, height int32) *MyWindow { // Create Wayland surface surface, err := compositor.CreateSurface() if err != nil { panic(err) } // Create XDG surface xdgSurface, err := shell.GetXdgSurface(surface) if err != nil { panic(err) } // Create toplevel toplevel, err := xdgSurface.GetToplevel() if err != nil { panic(err) } // Set properties toplevel.SetTitle("My App") toplevel.SetAppId("com.example.myapp") // Register handlers window := &MyWindow{surface: xdgSurface, toplevel: toplevel} xdgSurface.AddListener(window) xdg.ToplevelAddListener(toplevel, window) // Commit to make visible surface.Commit() return window } ``` -------------------------------- ### Install glslang on Fedora/RHEL Source: https://github.com/neurlang/wayland/blob/master/go-wayland-cube/shaders/README.md Install the required GLSL compiler tools on Fedora or RHEL-based distributions. ```bash sudo dnf install glslang ``` -------------------------------- ### Configure Darwin Build Prerequisites Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_BUILD_NOTES.md Install Xcode Command Line Tools and verify that CGO is enabled for the build environment. ```bash # Ensure Xcode Command Line Tools are installed xcode-select --install # Verify CGO is enabled go env CGO_ENABLED # should be "1" ``` -------------------------------- ### Test and Build Applications on macOS Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_BUILD_NOTES.md Commands to build the window package, run tests, and compile example applications on a macOS system. ```bash # Build the window package go build ./window # Run tests (if any) go test ./window # Build example applications go build ./go-wayland-simple-shm go build ./go-wayland-smoke ``` -------------------------------- ### Use PointerDestroy in Client Code Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md Example of managing a pointer proxy lifecycle using defer. ```go pointer, err := seat.GetPointer() if err != nil { panic(err) } defer wlclient.PointerDestroy(pointer) // Use pointer... ``` -------------------------------- ### func DisplayGetRegistry(d *wl.Display) (*wl.Registry, error) Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md Gets the global registry from the display. ```APIDOC ## func DisplayGetRegistry(d *wl.Display) ### Description Gets the global registry. ### Parameters - **d** (*wl.Display) - Required - Display ### Return Value - ***wl.Registry** - Registry proxy - **error** - Request error ``` -------------------------------- ### Implement and register close handler Source: https://github.com/neurlang/wayland/blob/master/_autodocs/03-window-package.md Example implementation of the CloseHandler interface to manage application exit. ```go type MyCloseHandler struct{} func (h *MyCloseHandler) HandleClose(w *window.Window) { // Clean up and exit os.Exit(0) } w.SetCloseHandler(&MyCloseHandler{}) ``` -------------------------------- ### Integrate error handling in wl package Source: https://github.com/neurlang/wayland/blob/master/_autodocs/08-external-package.md Example of wrapping errors within the wl context to provide additional diagnostic information. ```go // wl/context.go func (ctx *Context) run(cb *Callback) error { ev, err := ctx.readEvent() if err != nil { if err == io.EOF { return ErrContextRunConnectionClosed } // Extract underlying error if wrapped return combinedError{ErrContextRunEventReadingError, err} } // ... } ``` -------------------------------- ### Initialize and manage window decorations Source: https://github.com/neurlang/wayland/blob/master/doc/DECORATION_IMPLEMENTATION.md Demonstrates the lifecycle of a window decoration, including creation, state updates, and cleanup. ```go // Create decoration for a window decoration := window.NewWindowDecoration(myWindow) // Show decorations err := decoration.Show() // Update active state decoration.SetActive(true) // Update hover state decoration.SetHoverButton(window.ComponentButtonClose) // Redraw when needed decoration.Redraw() // Clean up decoration.Destroy() ``` -------------------------------- ### Create and Configure a Window Source: https://github.com/neurlang/wayland/blob/master/_autodocs/README.md Initializes a surface and toplevel window, sets application metadata, and registers event listeners for configuration and closure. ```go // Create surfaces wlSurface, err := compositor.CreateSurface() xdgSurface, err := shell.GetXdgSurface(wlSurface) toplevel, err := xdgSurface.GetToplevel() // Set properties toplevel.SetTitle("My App") toplevel.SetAppId("com.example.myapp") // Register handlers for configuration type Handler struct{ toplevel *xdg.Toplevel } func (h *Handler) HandleToplevelConfigure(ev xdg.ToplevelConfigureEvent) { h.toplevel.SetWindowGeometry(0, 0, ev.Width, ev.Height) } func (h *Handler) HandleToplevelClose(ev xdg.ToplevelCloseEvent) { os.Exit(0) } h := &Handler{toplevel: toplevel} xdg.ToplevelAddListener(toplevel, h) // Make visible wlSurface.Commit() ``` -------------------------------- ### Get the Wayland registry Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md Retrieves the global registry proxy from the display. ```go registry, err := wlclient.DisplayGetRegistry(display) if err != nil { panic(err) } ``` -------------------------------- ### Implement a Basic Wayland Client Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md A standard pattern for connecting to a display, registering for globals, and running the event loop. ```go package main import ( "github.com/neurlang/wayland/wl" "github.com/neurlang/wayland/wlclient" ) type MyApp struct{} func (app *MyApp) HandleSeatCapabilities(ev wl.SeatCapabilitiesEvent) { // Seat capabilities changed } func (app *MyApp) HandleSeatName(ev wl.SeatNameEvent) { // Seat name } func main() { // Connect display, err := wlclient.DisplayConnect([]byte("")) if err != nil { panic(err) } defer wlclient.DisplayDisconnect(display) // Get registry registry, err := wlclient.DisplayGetRegistry(display) if err != nil { panic(err) } // Listen for globals app := &MyApp{} wlclient.RegistryAddListener(registry, app) // Process events for { err := wlclient.DisplayRun(display) if err != nil { break } } } ``` -------------------------------- ### Initialize and run Go WebAssembly module Source: https://github.com/neurlang/wayland/blob/master/go-wayland-smoke/index.html Instantiates the WebAssembly module from the specified path and executes the Go runtime. ```javascript const go = new Go(); WebAssembly.instantiateStreaming(fetch("smoke_wasm.wasm"), go.importObject) .then(result => go.run(result.instance)); ``` -------------------------------- ### Retrieve single keysym Source: https://github.com/neurlang/wayland/blob/master/_autodocs/05-xkbcommon.md Convenience method to get a single keysym for a keycode. ```go func (s *State) KeyGetOneSym(code uint32) uint32 ``` -------------------------------- ### Compile the project for Linux Source: https://github.com/neurlang/wayland/blob/master/_autodocs/configuration.md Build the project using pure Go without requiring cgo. ```bash go build . # Pure Go; no cgo required ``` -------------------------------- ### Get Popup Cairo surface Source: https://github.com/neurlang/wayland/blob/master/_autodocs/03-window-package.md Retrieves the surface used for rendering content to the popup. ```go func (p *Popup) PopupGetSurface() cairo.Surface ``` ```go surf := popup.PopupGetSurface() // Render menu items to surf ``` -------------------------------- ### Initialize Window Decoration Source: https://github.com/neurlang/wayland/blob/master/doc/DECORATION_SUMMARY.md Create a new decoration instance associated with a specific window. ```go decoration := window.NewWindowDecoration(myWindow) ``` -------------------------------- ### Create New Shell Instance Source: https://github.com/neurlang/wayland/blob/master/_autodocs/07-xdg-shell.md Constructor for initializing a new window manager base instance. ```go func NewShell(ctx *Context) *WmBase ``` ```go shell := xdg.NewShell(ctx) // Bind to registry global ``` -------------------------------- ### Process Keyboard Events with xkbcommon Source: https://github.com/neurlang/wayland/blob/master/_autodocs/05-xkbcommon.md Demonstrates the lifecycle of creating a context, keymap, and state to process keyboard input and character conversion. ```go package main import ( "fmt" "github.com/neurlang/wayland/xkbcommon" ) func processKeyboardEvent(keymapData []byte, depressed, latched, locked, layout uint32, keycode uint32) { // Create context and keymap ctx := xkbcommon.ContextNew(0) defer xkbcommon.ContextUnref(ctx) km := ctx.KeymapNewFromString(keymapData, 1, 0) defer xkbcommon.KeymapUnref(km) // Create keyboard state state := km.StateNew() defer xkbcommon.StateUnref(state) // Update modifier state state.UpdateMask(depressed, latched, locked, layout, 0, 0) // Get keysym and convert to character sym, ok := state.KeyGetSyms(keycode) if ok { utf32 := state.KeyGetUtf32(sym) if utf32 != 0 { fmt.Printf("Key: %c\n", rune(utf32)) } } // Handle key repeat if km.KeyRepeats(keycode) { fmt.Println("Key repeats when held") } } ``` -------------------------------- ### Check modifier key state Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Example of checking if the Control key is pressed using bitwise operations. ```go if mods&window.ModControlMask != 0 { // Control key is pressed } ``` -------------------------------- ### Convert Fixed point coordinate Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Example of converting a Fixed type coordinate from a pointer event to a float64. ```go // From Wayland pointer event with Fixed coordinates fixedX := ev.SurfaceX // Fixed type floatX := wl.FixedToFloat(fixedX) // Convert to float64 ``` -------------------------------- ### Create a Darwin Window Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_WINDOW_FEATURES.md Initializes a new window with a default size of 200x200 pixels. ```go w := Create(display) // Creates a 200x200 window ``` -------------------------------- ### Implement Cursor Changes in Cocoa Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_CONSTANTS.md Example of mapping integer cursor types to native NSCursor objects in Objective-C. ```objective-c // In Cocoa/Objective-C switch (cursorType) { case 1: // CursorHand1 [[NSCursor pointingHandCursor] set]; break; case 2: // CursorLeftPtr [[NSCursor arrowCursor] set]; break; case 3: // CursorIbeam [[NSCursor IBeamCursor] set]; break; // ... etc } ``` -------------------------------- ### Handle ErrFileIsNil OS Error Source: https://github.com/neurlang/wayland/blob/master/_autodocs/errors.md Demonstrates checking for a nil file descriptor when file creation fails. ```go fd, err := os.CreateAnonymousFile(1024) if err == os.ErrFileIsNil { fmt.Println("Failed to create temporary file") } ``` -------------------------------- ### Manage XKB Context Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Defines the keyboard layout context manager and its initialization. ```go type Context struct { // Opaque pointer to xkb_context } ``` ```go ctx := xkbcommon.ContextNew(0) defer xkbcommon.ContextUnref(ctx) ``` -------------------------------- ### Build and Run Browser Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_MOUSE_CLICK.md Commands to build and execute the browser application with the necessary build tags. ```bash go build -tags darwin,cgo ./go-wayland-web-browser/browser ./go-wayland-web-browser/browser/browser ``` -------------------------------- ### Show Decorations Source: https://github.com/neurlang/wayland/blob/master/doc/DECORATION_SUMMARY.md Display the decoration, which initializes shadow and titlebar subsurfaces and performs the initial draw. ```go err := decoration.Show() // Creates shadow and titlebar subsurfaces // Draws initial decoration content ``` -------------------------------- ### Run Smoke Demo Source: https://github.com/neurlang/wayland/blob/master/doc/DECORATION_INTEGRATION.md Commands to build and execute the smoke test application to verify decoration rendering. ```bash # Build and run smoke demo go build -o go-wayland-smoke/smoke ./go-wayland-smoke ./go-wayland-smoke/smoke # Or use the run script ./run-smoke.sh ``` -------------------------------- ### Connect to Wayland Compositor Source: https://github.com/neurlang/wayland/blob/master/_autodocs/README.md Establishes a connection to the Wayland display and retrieves the registry to bind global interfaces. ```go package main import ( "github.com/neurlang/wayland/wl" "github.com/neurlang/wayland/wlclient" ) func main() { // Connect to compositor display, err := wlclient.DisplayConnect([]byte("")) if err != nil { panic(err) } defer wlclient.DisplayDisconnect(display) // Get registry registry, err := wlclient.DisplayGetRegistry(display) if err != nil { panic(err) } // Bind interfaces compositor := wlclient.RegistryBindCompositorInterface(registry, globalName, version) seat := wlclient.RegistryBindSeatInterface(registry, seatGlobalName, seatVersion) shell := wlclient.RegistryBindWmBaseInterface(registry, shellGlobalName, shellVersion) } ``` -------------------------------- ### NewShell Source: https://github.com/neurlang/wayland/blob/master/_autodocs/07-xdg-shell.md Creates a new instance of the XDG Window Manager Base. ```APIDOC ## func NewShell(ctx *Context) *WmBase ### Description Creates a new window manager base instance to interact with the XDG shell protocol. ### Parameters - **ctx** (*Context) - Required - Wayland context ### Return Value - ***WmBase** - New shell instance ``` -------------------------------- ### Configure Keyboard Locale Source: https://github.com/neurlang/wayland/blob/master/_autodocs/configuration.md Sets up keyboard compose sequences by initializing an xkbcommon context and a locale-specific compose table. ```go ctx := xkbcommon.ContextNew(0) table := ctx.ComposeTableNewFromLocale("en_US.UTF-8", 0) composeState := xkbcommon.ComposeStateNew(table, 0) ``` -------------------------------- ### ContextNew Source: https://github.com/neurlang/wayland/blob/master/_autodocs/05-xkbcommon.md Creates a new keyboard context. ```APIDOC ## func ContextNew(flags uint32) *Context ### Description Creates a new keyboard context. ### Parameters - **flags** (uint32) - Required - Context creation flags (typically 0) ### Return Value - ***Context** - New keyboard context ``` -------------------------------- ### Manage XKB Keymap Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Defines the keyboard layout mapping structure and its creation from a string. ```go type Keymap struct { // Opaque pointer to xkb_keymap } ``` ```go keymap := ctx.KeymapNewFromString(keymapBytes, 1, 0) ``` -------------------------------- ### Set Toplevel Title Source: https://github.com/neurlang/wayland/blob/master/_autodocs/07-xdg-shell.md Sets the window title string. ```go toplevel.SetTitle("My Application") ``` -------------------------------- ### Use XKB State Components Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Defines flags for keyboard state components and demonstrates serializing modifiers. ```go type StateComponent uint32 ``` ```go component := xkbcommon.StateComponent(...) state.SerializeMods(component) ``` -------------------------------- ### Context.KeymapNewFromString Source: https://github.com/neurlang/wayland/blob/master/_autodocs/05-xkbcommon.md Creates a keymap from an XKB keymap string. ```APIDOC ## func (ctx *Context) KeymapNewFromString(str []byte, a, b uint32) *Keymap ### Description Creates a keymap from an XKB keymap string (typically from WAYLAND_KEYMAP_FORMAT_XKB_V1). ### Parameters - **str** ([]byte) - Required - XKB keymap in text format - **a** (uint32) - Required - Keymap format (typically 1 for XKB_KEYMAP_FORMAT_TEXT_V1) - **b** (uint32) - Required - Keymap compilation flags (typically 0) ### Return Value - ***Keymap** - New keymap ``` -------------------------------- ### Connect to Wayland display in Go Source: https://github.com/neurlang/wayland/blob/master/_autodocs/configuration.md Demonstrates connecting to the display; fails if XDG_RUNTIME_DIR is not set. ```go display, err := wl.Connect("") // Fails if XDG_RUNTIME_DIR not set ``` -------------------------------- ### Integrate xkbcommon in Wayland Window Input Source: https://github.com/neurlang/wayland/blob/master/_autodocs/05-xkbcommon.md Shows how to integrate xkbcommon within a Wayland input handler to process keymap events and translate key codes. ```go // In window package (window/window_linux.go) type Input struct { xkbKeymap *xkb.Keymap xkbState *xkb.State // ... } func (i *Input) HandleKeyboardKeymap(ev wl.KeyboardKeymapEvent) { // Parse keymap from Wayland keymapData := ev.Keymap // Create XKB keymap i.xkbKeymap = ctx.KeymapNewFromString(keymapData, 1, 0) i.xkbState = i.xkbKeymap.StateNew() } func (i *Input) HandleKeyboardKey(ev wl.KeyboardKeyEvent) { // Translate key using XKB keysym, ok := i.xkbState.KeyGetSyms(ev.Key) if ok { utf32 := i.xkbState.KeyGetUtf32(keysym) // Use character } } ``` -------------------------------- ### Create Keymap from String Source: https://github.com/neurlang/wayland/blob/master/_autodocs/05-xkbcommon.md Initialize a keymap from raw byte data, typically received from a Wayland keymap event. ```go // From Wayland keyboard keymap event keymap := ctx.KeymapNewFromString(keymapData, 1, 0) defer xkbcommon.KeymapUnref(keymap) ``` -------------------------------- ### Initialize and Release Context Source: https://github.com/neurlang/wayland/blob/master/_autodocs/05-xkbcommon.md Create a new keyboard context and ensure it is released to prevent memory leaks. ```go ctx := xkbcommon.ContextNew(0) defer xkbcommon.ContextUnref(ctx) ``` ```go defer xkbcommon.ContextUnref(ctx) ``` -------------------------------- ### Create Rendering Surface Source: https://github.com/neurlang/wayland/blob/master/_autodocs/configuration.md Initializes an image surface using cairoshim by calculating the required stride and buffer size based on dimensions and color format. ```go width, height := 1920, 1080 stride := cairoshim.FormatStrideForWidth(cairoshim.FormatArgb32, width) bufferSize := stride * height data := make([]byte, bufferSize) surf := cairoshim.ImageSurfaceCreateForData( data, cairoshim.FormatArgb32, width, height, stride, ) ``` -------------------------------- ### Manage XKB State Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Defines the keyboard state tracker and its initialization from a keymap. ```go type State struct { // Opaque pointer to xkb_state } ``` ```go state := keymap.StateNew() ``` -------------------------------- ### Create and Manipulate Image Surface Source: https://github.com/neurlang/wayland/blob/master/_autodocs/04-cairoshim.md Demonstrates creating an ARGB32 surface from a byte slice and performing manual pixel manipulation. ```go package main import "github.com/neurlang/wayland/cairoshim" func main() { // Create a 1024x768 ARGB32 surface width, height := 1024, 768 stride := cairoshim.FormatStrideForWidth(cairoshim.FormatArgb32, width) data := make([]byte, stride*height) surf := cairoshim.ImageSurfaceCreateForData( data, cairoshim.FormatArgb32, width, height, stride, ) // Draw to the surface drawPixels(surf) // Cleanup defer surf.Destroy() } func drawPixels(surf cairoshim.Surface) { data := surf.ImageSurfaceGetData() width := surf.ImageSurfaceGetWidth() stride := surf.ImageSurfaceGetStride() // Draw red rectangle at (10,10) with size 100x100 for y := 10; y < 110; y++ { for x := 10; x < 110; x++ { offset := y*stride + x*4 // ARGB32: A, R, G, B bytes data[offset+0] = 255 // B data[offset+1] = 0 // G data[offset+2] = 0 // R data[offset+3] = 255 // A } } } ``` -------------------------------- ### Check Subcompositor Support Source: https://github.com/neurlang/wayland/blob/master/doc/DECORATION_INTEGRATION.md Verify if the display supports the subcompositor protocol required for decorations. ```go if display.subcompositor == nil { println("No subcompositor support") } ``` -------------------------------- ### Implement Window Event Handlers Source: https://github.com/neurlang/wayland/blob/master/_autodocs/03-window-package.md Define a struct to handle window events and register it with the window instance to manage keyboard input and lifecycle events. ```go package main import ( "github.com/neurlang/wayland/window" "github.com/neurlang/wayland/wl" ) type MyApp struct{} func (app *MyApp) HandleKeyboardKey(ev window.KeyboardEvent) { // Handle key press } func (app *MyApp) HandleClose(w *window.Window) { // Clean up os.Exit(0) } func main() { // Platform-specific window creation // w := window.NewWindow(...) handler := &MyApp{} w.SetKeyboardHandler(handler) w.SetCloseHandler(handler) // Run event loop // w.Run() } ``` -------------------------------- ### Update Decoration Strategy Source: https://github.com/neurlang/wayland/blob/master/doc/SOLUTION_SUMMARY.md Transition from destroying and recreating decoration surfaces to updating existing ones during window resize operations. ```go // Before: Window.decoration.Destroy() + recreate // After: Window.decoration.UpdateSize() ``` -------------------------------- ### Manage Toplevel Window States Source: https://github.com/neurlang/wayland/blob/master/_autodocs/07-xdg-shell.md Methods for setting and unsetting window states like maximized and fullscreen. ```go // Maximize window toplevel.SetMaximized() // Enter fullscreen on specific output output := ... // Get from output events toplevel.SetFullscreen(output) // Exit fullscreen toplevel.UnsetFullscreen() ``` -------------------------------- ### Bind Output Interface Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md Binds the output interface for display or monitor management. ```go func RegistryBindOutputInterface(r *wl.Registry, name, version uint32) *wl.Output ``` -------------------------------- ### Verify Windows Build Source: https://github.com/neurlang/wayland/blob/master/doc/WINDOWS_RENDERING_OPTIMIZATION.md Command to verify that the modified window rendering code compiles correctly. ```bash go build -v ./window ``` -------------------------------- ### Including Separate C Files Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_CGO_FIX.md Use CGO flags to include separate C implementation files. ```go /* #cgo CFLAGS: -I./include #include "window_impl.c" */ import "C" ``` -------------------------------- ### Generate Go Shader Files Source: https://github.com/neurlang/wayland/blob/master/go-wayland-cube/shaders/README.md Execute the generation process to compile GLSL shaders and create the corresponding Go files. ```bash go generate ``` -------------------------------- ### Run Keyboard Test Application Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_KEYBOARD_SUPPORT.md Executes the provided test script to verify keyboard event handling functionality. ```bash ./run-keyboard-test.sh ``` -------------------------------- ### Define Buffer and Surface constants Source: https://github.com/neurlang/wayland/blob/master/_autodocs/03-window-package.md Constants for configuring surface buffer types, opacity, and resize hints. ```go const BufferTypeEglWindow = 0 // EGL surface const BufferTypeShm = 1 // Shared memory surface ``` ```go const SurfaceOpaque = 0x01 // Surface is fully opaque const SurfaceShm = 0x02 // Use shared memory const SurfaceHintResize = 0x10 // Resizable window const SurfaceHintRgb565 = 0x100 // 16-bit color format ``` ```go const PreferredFormatNone = 0 // No preference const PreferredFormatRgb565 = 1 // 16-bit RGB preferred ``` -------------------------------- ### Represent Pixel Data Source: https://github.com/neurlang/wayland/blob/master/_autodocs/04-cairoshim.md Demonstrates how to represent ARGB32 and RGB565 pixel data as byte arrays. ```go // ARGB32 pixel: Red (255,0,0) with full opacity pixelData := [4]byte{0, 0, 255, 255} // B, G, R, A // RGB565 pixel: Red pixelData16 := [2]byte{0, 248} // Red in 16-bit format ``` -------------------------------- ### Connect to Wayland compositor Source: https://github.com/neurlang/wayland/blob/master/_autodocs/01-wl-core.md Establishes a connection to the compositor using the specified socket address or environment defaults. ```go package main import ( "github.com/neurlang/wayland/wl" ) func main() { display, err := wl.Connect("") if err != nil { panic(err) } defer display.Context().Close() // Use display to get registry and bind interfaces } ``` -------------------------------- ### Create Cairo Image Surface Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Initializes an image surface using a byte slice and specified format parameters. ```go data := make([]byte, stride*height) surf := cairoshim.ImageSurfaceCreateForData( data, cairoshim.FormatArgb32, width, height, stride, ) ``` -------------------------------- ### Toplevel Window State Methods Source: https://github.com/neurlang/wayland/blob/master/_autodocs/07-xdg-shell.md Methods to manage window states like maximized, minimized, and fullscreen. ```APIDOC ## Window State Methods ### Methods - **SetMaximized() error** - **UnsetMaximized() error** - **SetMinimized() error** - **SetFullscreen(output *wl.Output) error** - **UnsetFullscreen() error** ### Parameters - **output** (*wl.Output) - Optional - The preferred output for fullscreen mode. ``` -------------------------------- ### Build and Test Wayland Text Editor Source: https://github.com/neurlang/wayland/blob/master/doc/FLICKER_FIXES.md Commands to compile the text editor and execute the test script to verify flicker-free performance. ```bash go build -o go-wayland-texteditor/texteditor ./go-wayland-texteditor ./run-texteditor.sh ``` -------------------------------- ### func Connect(addr string) (*Display, error) Source: https://github.com/neurlang/wayland/blob/master/_autodocs/01-wl-core.md Establishes a connection to a Wayland compositor using a Unix socket address. ```APIDOC ## func Connect(addr string) (*Display, error) ### Description Establishes a connection to a Wayland compositor. If the address is empty, it defaults to the WAYLAND_DISPLAY environment variable or "wayland-0", prefixed with XDG_RUNTIME_DIR. ### Parameters - **addr** (string) - Required - Unix socket address. ### Return Value - **Display** (*Display) - Connected display proxy. - **error** (error) - Returns ErrXdgRuntimeDirNotSet if XDG_RUNTIME_DIR is missing, or net.Error on socket failure. ``` -------------------------------- ### Process Keyboard Input Source: https://github.com/neurlang/wayland/blob/master/_autodocs/README.md Translate raw keycodes into symbols and UTF-32 characters using XKB state. ```go keymap := ctx.KeymapNewFromString(keymapData, 1, 0) state := keymap.StateNew() state.UpdateMask(depressed, latched, locked, layout, 0, 0) sym, _ := state.KeyGetSyms(keycode) utf32 := state.KeyGetUtf32(sym) ``` -------------------------------- ### Implement KeyboardHandler Interface Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_KEYBOARD_SUPPORT.md Applications must implement this interface to receive keyboard events and focus notifications. ```go type KeyboardHandler interface { Key(Window *Window, Input *Input, time uint32, vKey uint32, code uint32, state wl.KeyboardKeyState, data WidgetHandler) Focus(Window *Window, Input *Input) } ``` -------------------------------- ### Handle error wrapping patterns Source: https://github.com/neurlang/wayland/blob/master/_autodocs/08-external-package.md Demonstrates manual unwrapping and standard Go library approaches for error inspection. ```go // Example from wl/event.go return combinedError{ErrReadHeader, err} // To get underlying syscall error: if perr, ok := err.(interface { Unwrap() error }); ok { underlying := perr.Unwrap() } ``` ```go import "errors" if errors.Is(err, ErrReadHeader) { // Is this error or one it wraps? } if errors.As(err, &netErr) { // Extract specific type } underlying := errors.Unwrap(err) ``` -------------------------------- ### Create popup window Source: https://github.com/neurlang/wayland/blob/master/_autodocs/03-window-package.md Initializes a new popup window anchored to specific coordinates relative to the parent. ```go popup := window.CreatePopup(seat, serial, 200, 300, 100, 150) // Render menu items to popup.GetSurface() ``` -------------------------------- ### Register Keyboard Listeners Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md Registers all keyboard handlers at once. ```go func KeyboardAddListener(kb *wl.Keyboard, l KeyboardListener) ``` -------------------------------- ### Surface.AckConfigure Source: https://github.com/neurlang/wayland/blob/master/_autodocs/07-xdg-shell.md Acknowledges a surface configuration event. ```APIDOC ## func (s *Surface) AckConfigure(serial uint32) error ### Description Acknowledges a configure event. This must be called after every configure event to ensure proper compositor synchronization. ### Parameters - **serial** (uint32) - Required - Serial from the configure event ### Return Value - **error** - Returns a protocol error if the acknowledgement fails ``` -------------------------------- ### Create Keyboard State Source: https://github.com/neurlang/wayland/blob/master/_autodocs/05-xkbcommon.md Initialize a new keyboard state from an existing keymap to track modifiers and key presses. ```go keymap := ctx.KeymapNewFromString(keymapData, 1, 0) state := keymap.StateNew() defer xkbcommon.StateUnref(state) ``` -------------------------------- ### Register Output Listeners Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md Registers all output handlers at once. ```go func OutputAddListener(o *wl.Output, h OutputListener) ``` -------------------------------- ### Perform a display roundtrip Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md Synchronously waits for the compositor to process all pending requests by sending a sync request. ```go // Ensure all config changes are applied err := wlclient.DisplayRoundtrip(display) if err != nil { panic(err) } ``` -------------------------------- ### Verification Command Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_CGO_FIX.md Verify the fix by building the package on macOS. ```bash go build ./window # Should complete without duplicate symbol errors ``` -------------------------------- ### Use ProxyId for lookup Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Demonstrates looking up a proxy object using a specific ProxyId. ```go ctx := wl.Connect("") proxy := ctx.LookupProxy(wl.ProxyId(1)) ``` -------------------------------- ### Forward Mouse Movement to Go Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_WINDOW_FEATURES.md Converts window coordinates and forwards mouse motion events to the Go runtime. ```objc - (void)mouseMoved:(NSEvent *)event { if (goWindowPtr) { NSPoint location = [self convertPoint:[event locationInWindow] fromView:nil]; goMouseMotion(goWindowPtr, location.x, location.y); } } ``` -------------------------------- ### Build Darwin Window Package Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_BUILD_NOTES.md Standard build command for the window package on macOS, which automatically includes platform-specific files. ```bash # On macOS, build normally go build ./window # The build system will automatically include: # - window_darwin.go # - widget_darwin.go # - widget_handler_darwin.go ``` -------------------------------- ### Connect to Wayland display with socket options Source: https://github.com/neurlang/wayland/blob/master/_autodocs/configuration.md Shows implicit usage of environment variables versus explicit socket name specification. ```go // Empty string uses WAYLAND_DISPLAY env var, falls back to "wayland-0" display, err := wl.Connect("") // Explicit socket name display, err := wl.Connect("wayland-1") ``` -------------------------------- ### Configure CGO for Objective-C Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_IMPLEMENTATION.md Required CGO flags to enable Objective-C compilation and link against necessary macOS frameworks. ```go #cgo CFLAGS: -x objective-c #cgo LDFLAGS: -framework Cocoa -framework QuartzCore ``` -------------------------------- ### Create shared memory buffer Source: https://github.com/neurlang/wayland/blob/master/_autodocs/02-os-package.md Demonstrates creating an anonymous file for Wayland surfaces, handling the ErrUnlink case. ```go package main import ( "github.com/neurlang/wayland/os" ) func createShmBuffer(sizeBytes int64) (*os.File, error) { fd, err := os.CreateAnonymousFile(sizeBytes) if err != nil && err != os.ErrUnlink { return nil, err } return fd, nil } ``` -------------------------------- ### Compare Slice-based and Map-based Handler Storage Source: https://github.com/neurlang/wayland/blob/master/doc/PROTOCOL_REGENERATION_COMPLETE.md Comparison of the legacy slice-based implementation and the new map-based implementation for Wayland protocol handlers. ```go type ZwpShellV1 struct { BaseProxy mu sync.RWMutex capabilityHandlers []ZwpShellV1CapabilityHandler } func (p *ZwpShellV1) Dispatch(event *Event) { p.mu.RLock() for _, h := range p.capabilityHandlers { p.mu.RUnlock() h.HandleCapability(ev) p.mu.RLock() } p.mu.RUnlock() } ``` ```go type ZwpShellV1 struct { BaseProxy mu sync.RWMutex privateZwpShellV1Capabilitys map[ZwpShellV1CapabilityHandler]struct{} } func NewZwpShellV1(ctx *Context) *ZwpShellV1 { ret := new(ZwpShellV1) ret.privateZwpShellV1Capabilitys = make(map[ZwpShellV1CapabilityHandler]struct{}) ctx.Register(ret) return ret } func (p *ZwpShellV1) Dispatch(event *Event) { p.mu.RLock() for h := range p.privateZwpShellV1Capabilitys { h.HandleCapability(ev) } p.mu.RUnlock() } func (p *ZwpShellV1) AddCapabilityHandler(h ZwpShellV1CapabilityHandler) { if h != nil { p.mu.Lock() p.privateZwpShellV1Capabilitys[h] = struct{}{} p.mu.Unlock() } } func (p *ZwpShellV1) RemoveCapabilityHandler(h ZwpShellV1CapabilityHandler) { p.mu.Lock() defer p.mu.Unlock() delete(p.privateZwpShellV1Capabilitys, h) } ``` -------------------------------- ### Update Decoration State Source: https://github.com/neurlang/wayland/blob/master/doc/DECORATION_SUMMARY.md Manage decoration appearance by setting focus, hover states, and triggering manual redraws. ```go decoration.SetActive(true) // Window focused decoration.SetHoverButton(btn) // Mouse hover decoration.Redraw() // Force redraw ``` -------------------------------- ### Create a new ComposeState Source: https://github.com/neurlang/wayland/blob/master/_autodocs/05-xkbcommon.md Initializes a new compose state from a locale-specific table. Ensure the state is released using ComposeStateUnref when finished. ```go table := ctx.ComposeTableNewFromLocale("en_US.UTF-8", 0) composeState := xkbcommon.ComposeStateNew(table, 0) defer xkbcommon.ComposeStateUnref(composeState) ``` -------------------------------- ### RegistryBindOutputInterface Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md Binds the output interface. ```APIDOC ## func RegistryBindOutputInterface(r *wl.Registry, name, version uint32) *wl.Output ### Description Binds the output (display/monitor) interface from the registry. ``` -------------------------------- ### Register and Dispatch Events Source: https://github.com/neurlang/wayland/blob/master/_autodocs/README.md Register event handlers and execute the event loop to process incoming events. ```go // Register handler pointer.AddMotionHandler(myHandler) // In event loop: for { ctx.Run() // Reads event, dispatches to handler } ``` -------------------------------- ### Register Registry Listeners Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md Registers all registry handlers at once. ```go func RegistryAddListener(r *wl.Registry, data RegistryListener) ``` -------------------------------- ### Header File Definition Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_CGO_FIX.md Use header guards when sharing C functions across multiple Go files. ```c // window_darwin.h #ifndef WINDOW_DARWIN_H #define WINDOW_DARWIN_H void sharedFunction(); #endif ``` -------------------------------- ### Handle Input Events Source: https://github.com/neurlang/wayland/blob/master/_autodocs/README.md Registers handlers for pointer motion and keyboard input, utilizing xkbcommon for key symbol translation. ```go type InputHandler struct{} func (h *InputHandler) HandlePointerMotion(ev wl.PointerMotionEvent) { x := wl.FixedToFloat(ev.SurfaceX) y := wl.FixedToFloat(ev.SurfaceY) fmt.Printf("Pointer: %.1f, %.1f\n", x, y) } func (h *InputHandler) HandleKeyboardKey(ev wl.KeyboardKeyEvent) { // Translate via xkbcommon sym, ok := xkbState.KeyGetSyms(ev.Key) if ok { utf32 := xkbState.KeyGetUtf32(sym) fmt.Printf("Key: %c\n", rune(utf32)) } } // Register with seat pointer, _ := seat.GetPointer() keyboard, _ := seat.GetKeyboard() handler := &InputHandler{} pointer.AddMotionHandler(handler) keyboard.AddKeyHandler(handler) ``` -------------------------------- ### Handle ErrXdgRuntimeDirNotSet Source: https://github.com/neurlang/wayland/blob/master/_autodocs/errors.md Check for missing XDG_RUNTIME_DIR environment variable during connection. ```go display, err := wl.Connect("") if err == wl.ErrXdgRuntimeDirNotSet { fmt.Println("Wayland not available") os.Exit(1) } ``` -------------------------------- ### Register proxy Source: https://github.com/neurlang/wayland/blob/master/_autodocs/01-wl-core.md Adds a proxy object to the context registry to enable event reception. ```go newRegistry := wl.NewRegistry(ctx) ctx.Register(newRegistry) // newRegistry now has a unique ID and can receive events ``` -------------------------------- ### Create a temporary file with FD_CLOEXEC Source: https://github.com/neurlang/wayland/blob/master/_autodocs/02-os-package.md Creates a temporary file with the FD_CLOEXEC flag and unlinks it. The tmpdir should typically be retrieved from the XDG_RUNTIME_DIR environment variable. ```go fd, err := os.CreateTmpfileCloexec(os.Getenv("XDG_RUNTIME_DIR"), "myapp-XXXXXX") if err != nil && err != os.ErrUnlink { panic(err) } defer fd.Close() ``` -------------------------------- ### Register Surface Configure Handler Source: https://github.com/neurlang/wayland/blob/master/_autodocs/07-xdg-shell.md Methods and interfaces for handling surface configuration events. ```go func (s *Surface) AddListener(h SurfaceConfigureHandler) { s.AddConfigureHandler(h) } func (s *Surface) AddConfigureHandler(h SurfaceConfigureHandler) ``` ```go type SurfaceConfigureHandler interface { HandleSurfaceConfigure(ev SurfaceConfigureEvent) } ``` ```go type SurfaceConfigureEvent struct { Serial uint32 // Configuration serial, must be acked } ``` ```go type MySurfaceHandler struct { surf *xdg.Surface } func (h *MySurfaceHandler) HandleSurfaceConfigure(ev xdg.SurfaceConfigureEvent) { h.surf.AckConfigure(ev.Serial) } ``` -------------------------------- ### Create Shared Memory Buffers Source: https://github.com/neurlang/wayland/blob/master/_autodocs/README.md Allocate anonymous memory, map it, and attach it as a buffer to a surface. ```go fd, _ := os.CreateAnonymousFile(size) // mmap fd or wrap in byte slice buffer := shm.CreateBuffer(fd, width, height, stride, format) surface.Attach(buffer, 0, 0) ``` -------------------------------- ### Prevent Decoration Creation Source: https://github.com/neurlang/wayland/blob/master/doc/DECORATION_INTEGRATION.md Comment out the decoration initialization logic within the window creation process. ```go // In window.Create(), comment out: // if Display.subcompositor != nil { // Window.decoration = NewWindowDecoration(Window) // } ``` -------------------------------- ### Bind Subcompositor Interface Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md Binds the subcompositor interface from the registry. ```go func RegistryBindSubcompositorInterface(r *wl.Registry, name, version uint32) *wl.Subcompositor ``` -------------------------------- ### Integrate Cairo Surface with Window Source: https://github.com/neurlang/wayland/blob/master/_autodocs/03-window-package.md Access the underlying surface of a window and cast it to the cairoshim.Surface interface to perform direct pixel manipulation. ```go import "github.com/neurlang/wayland/cairoshim" // Get surface for a window or popup surf := window.GetSurface() // Platform-specific method // Cast to cairoshim.Surface interface if cairoSurf, ok := surf.(cairoshim.Surface); ok { data := cairoSurf.ImageSurfaceGetData() width := cairoSurf.ImageSurfaceGetWidth() height := cairoSurf.ImageSurfaceGetHeight() // Render pixels directly to data buffer } ``` -------------------------------- ### Define ToplevelConfigureEvent and Handler Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Structure for XDG toplevel configuration events and the interface for handling them. ```go type ToplevelConfigureEvent struct { Width int32 // Requested width (0 = client chooses) Height int32 // Requested height (0 = client chooses) States []uint32 // Window states array } ``` ```go type ToplevelConfigureHandler interface { HandleToplevelConfigure(ev xdg.ToplevelConfigureEvent) } ``` -------------------------------- ### Handle XKB Compose Feed Results Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Defines result types for feeding keysyms to compose state and demonstrates checking for a match. ```go type ComposeFeedResult uint8 const ( ComposeResultNothing ComposeFeedResult = 0 ComposeResultCancelled ComposeFeedResult = 1 ComposeResultMatched ComposeFeedResult = 2 ) ``` ```go result := composeState.Feed(keysym) if result == xkbcommon.ComposeResultMatched { utf8 := composeState.GetUtf8() } ``` -------------------------------- ### Define KeyboardKeyEvent and Handler Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Structure for keyboard key events and the interface for handling them. ```go type KeyboardKeyEvent struct { Serial uint32 // Request serial Time uint32 // Millisecond timestamp Key uint32 // Keycode (evdev code) State uint32 // 0 = released, 1 = pressed } ``` ```go type KeyboardKeyHandler interface { HandleKeyboardKey(ev wl.KeyboardKeyEvent) } ``` -------------------------------- ### Define macOS Key Constants Source: https://github.com/neurlang/wayland/blob/master/doc/DARWIN_KEYSYMS.md Demonstrates that uppercase and lowercase letters share the same virtual key code on macOS. ```go const KeyQ = 0x0C // Same code const KEYq = 0x0C // Same code ``` -------------------------------- ### Define SurfaceConfigureEvent and Handler Source: https://github.com/neurlang/wayland/blob/master/_autodocs/types.md Structure for XDG surface configuration events and the interface for handling them. ```go type SurfaceConfigureEvent struct { Serial uint32 // Configuration serial (must be acked) } ``` ```go type SurfaceConfigureHandler interface { HandleSurfaceConfigure(ev xdg.SurfaceConfigureEvent) } ``` -------------------------------- ### Register Touch Listeners Source: https://github.com/neurlang/wayland/blob/master/_autodocs/06-wlclient.md Registers all touch handlers at once. ```go func TouchAddListener(to *wl.Touch, tl TouchListener) ```