API referencestd/window

std/window/raw

Public declarations, types, methods, and source contracts for std/window/raw.

On this page

Library guide · API index and notation

This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.

import "std/window/raw"

Names used in signatures

Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.

This package has no source imports.

Error

Enum · Source

Why a window could not be opened or used.

pub enum Error {
    // No window system is reachable: no WAYLAND or X11 display on Linux, no
    // GUI session on macOS, no interactive desktop on Windows.
    NoDisplay,
    // An App already exists; a process has at most one at a time.
    AlreadyOpen,
    // The window or App was closed, or the connection to the window system
    // ended.
    Closed,
    // A zero or too large size, or a title that is too long.
    InvalidInput,
    // Memory for the pixel buffer could not be allocated.
    OutOfMemory,
    // The window system sent something unexpected or rejected a request,
    // for example an X server refusing the connection's authorization.
    Protocol,
    // The window system works in a way this library does not support, such
    // as an X server without a 24-bit true-color visual, or starting a Cocoa
    // App off the main thread.
    Unsupported,
    // Another operating-system call failed.
    System
}

from_code

Function · Source

Error codes returned by the C runtimes; 0 means success.

pub fn from_code(code: i32) -> Error

NONE

Constant · Source

Event kinds.

pub const NONE: u32 = 0

CLOSE

Constant · Source

pub const CLOSE: u32 = 1

RESIZE

Constant · Source

x and y hold the new width and height.

pub const RESIZE: u32 = 2

FOCUS

Constant · Source

flags bit 0: focused.

pub const FOCUS: u32 = 3

KEY

Constant · Source

code: Key ordinal; flags bit 0: pressed, bit 1: repeat.

pub const KEY: u32 = 4

TEXT

Constant · Source

code: a Unicode scalar value.

pub const TEXT: u32 = 5

MOUSE_MOVE

Constant · Source

pub const MOUSE_MOVE: u32 = 6

MOUSE_BUTTON

Constant · Source

code: 0 left, 1 middle, 2 right, 3 back, 4 forward; flags bit 0: pressed.

pub const MOUSE_BUTTON: u32 = 7

MOUSE_LEAVE

Constant · Source

pub const MOUSE_LEAVE: u32 = 8

SCROLL

Constant · Source

x and y hold the horizontal and vertical amounts, 120 per wheel notch.

pub const SCROLL: u32 = 9

FRAME

Constant · Source

The display refreshed after a request_frame(); std/window turns it into a Frame event when the window asked for one.

pub const FRAME: u32 = 10

QUIT

Constant · Source

The user asked the application to quit, such as with Command-Q on macOS; window is 0.

pub const QUIT: u32 = 11

CURSOR_ARROW

Constant · Source

Pointer shapes, in the order of window.Cursor.

pub const CURSOR_ARROW: u32 = 0

CURSOR_TEXT

Constant · Source

pub const CURSOR_TEXT: u32 = 1

CURSOR_HAND

Constant · Source

pub const CURSOR_HAND: u32 = 2

CURSOR_CROSSHAIR

Constant · Source

pub const CURSOR_CROSSHAIR: u32 = 3

CURSOR_MOVE

Constant · Source

pub const CURSOR_MOVE: u32 = 4

CURSOR_RESIZE_EW

Constant · Source

pub const CURSOR_RESIZE_EW: u32 = 5

CURSOR_RESIZE_NS

Constant · Source

pub const CURSOR_RESIZE_NS: u32 = 6

CURSOR_RESIZE_NWSE

Constant · Source

pub const CURSOR_RESIZE_NWSE: u32 = 7

CURSOR_RESIZE_NESW

Constant · Source

pub const CURSOR_RESIZE_NESW: u32 = 8

CURSOR_NOT_ALLOWED

Constant · Source

pub const CURSOR_NOT_ALLOWED: u32 = 9

CURSOR_WAIT

Constant · Source

pub const CURSOR_WAIT: u32 = 10

CURSORS

Constant · Source

pub const CURSORS: u32 = 11

PRESSED

Constant · Source

pub const PRESSED: u32 = 1

REPEAT

Constant · Source

pub const REPEAT: u32 = 2

SHIFT

Constant · Source

Modifier bits.

pub const SHIFT: u32 = 1

CONTROL

Constant · Source

pub const CONTROL: u32 = 2

ALT

Constant · Source

pub const ALT: u32 = 4

META

Constant · Source

pub const META: u32 = 8

CAPS_LOCK

Constant · Source

pub const CAPS_LOCK: u32 = 16

FOREVER

Constant · Source

Waiting without a time limit.

pub const FOREVER: u32 = 0xffffffff

Event

Struct · Source

One event of the window window. Window ids start at 1 and are never reused within a process; 0 stands for no window.

@repr(C)
pub struct Event {
    pub kind: u32
    pub code: u32
    pub modifiers: u32
    pub flags: u32
    pub x: i32
    pub y: i32
    pub window: u32
}

Event.empty

Function · Source

pub fn empty() -> Event

Search every guide, reference page, and API declaration.