API
WindowAbstractions.BUTTON_PRESSEDWindowAbstractions.BUTTON_RELEASEDWindowAbstractions.KEY_PRESSEDWindowAbstractions.KEY_RELEASEDWindowAbstractions.NO_EVENTWindowAbstractions.POINTER_ENTEREDWindowAbstractions.POINTER_EXITEDWindowAbstractions.POINTER_MOVEDWindowAbstractions.WINDOW_CLOSEDWindowAbstractions.WINDOW_EXPOSEDWindowAbstractions.WINDOW_GAINED_FOCUSWindowAbstractions.WINDOW_INVALIDWindowAbstractions.WINDOW_LOST_FOCUSWindowAbstractions.WINDOW_MOVEDWindowAbstractions.WINDOW_RESIZEDCore.TypeWindowAbstractions.AbstractWindowWindowAbstractions.AbstractWindowManagerWindowAbstractions.EventWindowAbstractions.EventQueueWindowAbstractions.EventTypeWindowAbstractions.KeyCombinationWindowAbstractions.KeyEventWindowAbstractions.KeySymbolWindowAbstractions.MouseEventWindowAbstractions.PointerStateBase.closeWindowAbstractions.collect_events!WindowAbstractions.dpiWindowAbstractions.get_windowWindowAbstractions.key_symbolWindowAbstractions.map_windowWindowAbstractions.move_window_byWindowAbstractions.move_window_toWindowAbstractions.poll_for_events!WindowAbstractions.replay_historyWindowAbstractions.resize_windowWindowAbstractions.save_historyWindowAbstractions.set_iconWindowAbstractions.set_icon_titleWindowAbstractions.set_titleWindowAbstractions.unmap_windowWindowAbstractions.windowsWindowAbstractions.@key_str
WindowAbstractions.BUTTON_PRESSED — ConstantA mouse button was released.
WindowAbstractions.BUTTON_RELEASED — ConstantThe pointer entered the window area.
WindowAbstractions.KEY_PRESSED — ConstantA key was pressed. Note that some key combinations can be reserved by the OS, so they don't trigger the corresponding event. On Ubuntu 20.04, this is for example the case with some combinations of the form alt+fkey such as alt+f4.
WindowAbstractions.KEY_RELEASED — ConstantA key was released.
WindowAbstractions.NO_EVENT — ConstantSignals an absence of event.
WindowAbstractions.POINTER_ENTERED — ConstantA mouse button was pressed.
WindowAbstractions.POINTER_EXITED — ConstantThe pointer left the window area.
WindowAbstractions.POINTER_MOVED — ConstantThe pointer moves in the window.
WindowAbstractions.WINDOW_CLOSED — ConstantThe window was closed, e.g. manually by the user or by a programmatic action.
WindowAbstractions.WINDOW_EXPOSED — ConstantA window was exposed to the screen; either right after creation, or when it was previously hidden and then visible again.
WindowAbstractions.WINDOW_GAINED_FOCUS — ConstantThe window gained focus.
WindowAbstractions.WINDOW_INVALID — ConstantThe window is detected as invalid (for example, when closed externally).
The conditions for tagging a window as invalid depend on the windowing API used. It is typically used to signal that a window crashed or does not exist, but for which an event was reported. It may however not possible to know exactly why or when a window becomes invalid. For example, the X11 protocol does not offer a way to check for window validity, since the window may get invalidated by the time the X server answer comes back. Windows that are tagged invalid should be terminated.
WindowAbstractions.WINDOW_LOST_FOCUS — ConstantThe window lost focus.
WindowAbstractions.WINDOW_MOVED — ConstantThe window moved.
WindowAbstractions.WINDOW_RESIZED — ConstantThe window was resized (and may have had its origin moved).
Core.Type — Method(::Type{<:AbstractWindow})(wm::AbstractWindowManager; kwargs...)Create a window.
WindowAbstractions.AbstractWindow — TypeAbstract window type.
Must hold the following properties:
.position::Tuple{Int,Int}: window position within its parent (x, y)..extent::Tuple{Int,Int}: window dimensions (width, height).
abstract type AbstractWindowWindowAbstractions.AbstractWindowManager — TypeEntity that manages windows.
abstract type AbstractWindowManagerWindowAbstractions.Event — TypeGeneric event structure identified by its type (see EventType) and which may hold data depending on the type of event.
The event may have the following properties, depending on its type:
.key_event::KeyEvent|KEY_PRESSEDorKEY_RELEASED.mouse_event::KeyEvent|BUTTON_PRESSEDorBUTTON_RELEASED.pointer_state::PointerState|POINTER_MOVED.resize::Tuple{Int64,Int64}|WINDOW_RESIZED: indicates the difference in size with respect to the previous dimensions..movement::Tuple{Int64,Int64}|WINDOW_RESIZEDorWINDOW_MOVED: indicates how much the window moved along thexandydirections..area::Tuple{Float64,Float64}|WINDOW_EXPOSED
struct Event{W<:AbstractWindow}type::EventTypedata::Anylocation::Tuple{Float64, Float64}time::Float64window::AbstractWindow
WindowAbstractions.EventQueue — TypeEvent queue meant to hold events to be processed by an application.
The event queue is bound to a window manager, and will be filled upon notification of low-level events sent by that window manager. Only high-level events will be recorded in the event queue, which are typically suited for use in applications.
The event queue is infinitely iterable, returning Events as they are received. When no events are available, the queue will either enter a sleeping state of approximately 1 ms (if sleep = true) or spin while yielding at every iteration.
Any task iterating over the event queue is therefore a good candidate to be scheduled using an interactive thread from Julia 1.9 onwards.
Alternatively, the event queue may be manually filled with collect_events! and processed using Base.isempty and Base.popfirst!.
The parameter record_history may be set to true to save all events that have been processed (either by iteration or manual Base.popfirst!). Implementations of window managers may extend save_history and replay_history to allow for the saving and replay of events that have been stored. Note that record_history will have to be set to true for save_history to work.
struct EventQueue{WM<:AbstractWindowManager, W<:AbstractWindow}wm::AbstractWindowManagerevents::Array{Event{W}, 1} where W<:AbstractWindowhistory::Array{Event{W}, 1} where W<:AbstractWindowsleep::Boolrecord_history::Bool
WindowAbstractions.EventType — TypeType of input or window event which may occur on a particular window.
This type is defined as a bitmask, to make it easier to work with sets of events.
struct EventType <: BitMasks.BitMask{UInt32}val::UInt32
WindowAbstractions.KeyCombination — TypeKey binding associated to a character and a key modifier state.
struct KeyCombinationkey::KeySymbolexact_modifiers::ModifierStatesignificant_modifiers::ModifierState
WindowAbstractions.KeyEvent — TypeDetails surrounding an event produced by a keystroke.
struct KeyEventkey_name::Symbol: The name of the physical key.
key::KeySymbol: The symbol associated with the keystroke.
input::Char: Printable input (can be the empty string).
modifiers::ModifierState: Modifier state.
consumed_modifiers::ModifierState: Modifiers that were used when translating the physical key into a key symbol.
WindowAbstractions.KeySymbol — TypeRepresentation of a symbol that may be bound to a key, depending on a keyboard layout. It differs from the physical representation of a key, denoted by names such as AD01 which represent physical keys (in this case, q on a US keyboard). A key symbol is sent when a physical key is pressed, even if no input character is bound to the key. This structure provides a friendly symbol field, and a prettier description field (mostly used for printing). For example, the right arrow, with symbol :right_arrow (resp. :kp_right_arrow for keypad input), is represented by "→" (resp. "→ (keypad)").
There is no consistent representation, so the one provided here may differ from windowing API implementations.
struct KeySymbolname::Symboldescription::Union{Char, String}
WindowAbstractions.MouseEvent — TypeA mouse press/release associated to a certain state.
struct MouseEventbutton::MouseButtonstate::MouseButton
WindowAbstractions.PointerState — TypeContext in which a pointer motion was performed, including active mouse buttons and keyboard modifiers.
struct PointerStatestate::MouseButtonmodifiers::ModifierState
Base.close — Methodclose(wm::AbstractWindowManager, window::AbstractWindow)Close a window.
close(wm::AbstractWindowManager, _::AbstractWindow)
WindowAbstractions.collect_events! — MethodGather all pending events.
collect_events!(queue::EventQueue)
WindowAbstractions.dpi — MethodGet window DPI.
dpi(window::AbstractWindow)
WindowAbstractions.get_window — MethodRetrieve a window given an identifier id, would typically be an integer identifier, a handle or a name.
get_window(wm::AbstractWindowManager, id)
WindowAbstractions.key_symbol — MethodDefine an internal representation and a readable description for some key inputs.
The keys that are listed here are not exhaustive and only cover a very small subset of all possible keys.
key_symbol(name::Symbol) -> Any
WindowAbstractions.map_window — MethodMap a window to the screen.
map_window(window::AbstractWindow)
WindowAbstractions.move_window_by — MethodMove the window, relative to the current window position.
move_window_by(window::AbstractWindow, offset)
WindowAbstractions.move_window_to — MethodMove the window to new_position.
move_window_to(window::AbstractWindow, position)
WindowAbstractions.poll_for_events! — MethodNon-blocking poll for events. Must return whether a client event was consumed, even if no Event is added to the queue.
poll_for_events!(queue::EventQueue)
WindowAbstractions.replay_history — Functionreplay_history(wm, events)Replay events generated by save_history on the provided window manager.
Delays between events should be respected. The window manager is free to assume that no other event will be generated during the replay: user interactinos with the window while the replay is ongoing may affect the integrity of the replication.
Note that any global state such as RNG is not saved; the application is responsible for managing state appropriately for effects outside of the event system.
WindowAbstractions.resize_window — MethodResize the window with extent reflecting the new (width, height).
resize_window(window::AbstractWindow, extent; corner)
WindowAbstractions.save_history — Functionsave_history(wm::WM, queue::EventQueue{WM}) -> Vector{<:Event}Save actions stored inside the event queue for later replay with replay_history.
The event queue must have been created with record_history = true.
WindowAbstractions.set_icon — MethodSet window icon.
set_icon(window::AbstractWindow, icon)
WindowAbstractions.set_icon_title — MethodSet window icon title.
set_icon_title(window::AbstractWindow, icon_title)
WindowAbstractions.set_title — MethodSet window title.
set_title(window::AbstractWindow, title)
WindowAbstractions.unmap_window — MethodUnmap a window from the screen.
unmap_window(window::AbstractWindow)
WindowAbstractions.windows — MethodRetrieve all the AbstractWindows in use by wm.
windows(wm::AbstractWindowManager)
WindowAbstractions.@key_str — MacroConstruct a KeyCombination instance from a string as "[<state_1>+[...<state_n>+]]<key>". The string must be a list of elements separated by '+' characters, with only one key symbol at the end. For example, "k", "alt+k" and "ctrl+alt+shift+f11" are valid strings, but "k+a" is not. Casing is significant, as z and Z are different key symbols. For modifier strings, the casing should be lowercase, or will be forcefully converted into a lowercase string (reducing performance).