Expand description
Abstract platform traits shared by gpui and its platform backends.
This crate is the contract between the GPUI facade and the concrete
platform implementations (gpui_macos, gpui_linux, gpui_windows,
gpui_web). It depends only on gpui_types and other low-level leaf
crates, never on gpui, so a backend can implement these traits without
depending on the entire framework.
The gpui crate re-exports everything here, so consumers keep using
gpui::PlatformKeyboardMapper and friends.
Re-exports§
pub use profiler::ForegroundRunnableCounter;pub use profiler::foreground_runnable_counter;pub use profiler::foreground_runnable_finished;pub use queue::*;
Modules§
- popup
- Parent-anchored popup window options shared by
gpuiand its platform backends. - profiler
- Profiler hooks used by the executor runtime.
- queue
Structs§
- A11y
Callbacks - Callbacks for the accessibility adapter.
- Activity
Guard - Keeps an operating system activity, such as an idle sleep inhibitor, alive until dropped.
- Background
- A background color, which can be either a solid color or a linear gradient.
- Background
Executor - A pointer to the executor that is currently running, for spawning background tasks.
- Bounds
- Represents a rectangular area in a 2D space with an origin point and a size.
- Bounds
Refinement - A refinable version of [
#ident], see that documentation for details. - Capslock
- The state of the capslock key at some point in time
- Clipboard
Item - A clipboard item that should be copied to the clipboard
- Clipboard
String - A clipboard item that should be copied to the clipboard
- Content
Mask - Indicates which region of the window is visible. Content falling outside of this mask will not be rendered. Currently, only rectangular content masks are supported, but we give the mask its own type to leave room to support more complex shapes in the future.
- Corners
- Represents the corners of a box in a 2D space, such as border radius.
- Corners
Refinement - A refinable version of [
#ident], see that documentation for details. - Dedicated
Executor - A long-lived handle to one dedicated session: every future spawned on it runs on that session’s single thread, never on the background pool.
- Device
Pixels - Represents physical pixels on the display.
- Dispatch
Event Result - Display
Changes - The properties of a display that a
DisplayEvent::Changedreports. - Display
Id - An opaque identifier for a hardware display
- Dummy
Keyboard Mapper - A dummy implementation of the platform keyboard mapper
- DynRenderer
Factory - A shared
RendererFactory, which is alsoDebugbecause the window options it lives in are. - Edges
- Represents the edges of a box in a 2D space, such as padding or margin.
- Edges
Refinement - A refinable version of [
#ident], see that documentation for details. - External
Paths - A collection of paths from the platform, such as from a file drop.
- Fallible
Task - A task that returns
Option<T>instead of panicking when cancelled. - File
Drag Paths - Paths handed to the platform for a native file drag. Directory metadata is provided by the caller to avoid querying it when the platform drag starts.
- FnRenderer
Factory - The spelling for the common case: a closure is a factory.
- Foreground
Executor - A pointer to the executor that is currently running, for spawning tasks on the main thread.
- Gesture
Kinds - The gesture kinds a platform recognizes natively, rather than leaving to gpui core’s portable recognizers.
- Gesture
Tuning - Feel constants consumed by gesture recognizers. Provided on a best-effort basis, depending on each platform’s support, defaulting to GPUI’s own (iOS flavored) values
- GpuAdapter
Info - One adapter an application can choose between.
- GpuId
- The identity of an adapter, for
GpuPreference::Device. - GpuRank
- The sort key for one adapter under a
GpuPreference. - GpuSpecs
- Information about the GPU GPUI is running on.
- Graphical
Environment - The graphical session to connect to: the variables that locate its display server, as some process sees them.
- Grid
Location - A location in a grid layout.
- Hsla
- An HSLA color
- Image
- An image, with a format and certain bytes
- Image
Format Iter - An iterator over the variants of ImageFormat
- Invalid
Keystroke Error - Error type for
Keystroke::parse. This is used instead ofanyhow::Errorso that Zed can use markdown to display it. - KeyDown
Event - The key down event equivalent for the platform.
- KeyUp
Event - The key up event equivalent for the platform.
- Keybinding
Keystroke - Represents a keystroke that can be used in keybindings and displayed to the user.
- Keystroke
- A keystroke and associated metadata generated by the platform
- Linear
Color Stop - A color stop in a linear gradient.
- Long
Press Event - A phased long-press gesture recognized from a touch.
- Modifiers
- The state of the modifier keys at some point in time
- Modifiers
Changed Event - The modifiers changed event equivalent for the platform.
- Mouse
Down Event - A mouse down event from the platform
- Mouse
Exit Event - A mouse exit event from the platform, generated when the mouse leaves the window.
- Mouse
Move Event - A mouse move event from the platform.
- Mouse
Pressure Event - A mouse pressure event from the platform. Generated when a force-sensitive trackpad is pressed hard. Currently only implemented for macOS trackpads.
- Mouse
UpEvent - A mouse up event from the platform
- Null
Platform Gestures - A no-op
PlatformGesturesimplementation: no native recognizers and default tuning. Suitable for desktop platforms and tests. - Path
Prompt Options - The options that can be configured for a file dialog prompt
- Percentage
- A type representing a percentage value.
- Pinch
Event - A pinch gesture event from the platform, generated when the user performs a pinch-to-zoom gesture (typically on a trackpad).
- Pixels
- Represents a length in pixels, the base unit of measurement in the UI framework.
- Platform
Frame Signal - Preserves the first platform frame request time across coalesced notifications.
- Platform
Input Handler - Handles text input from the platform’s IME system on behalf of a window.
- Platform
Menu - A menu of the application, either a main menu or a submenu.
- Platform
OsMenu - A menu managed by the operating system.
- Platform
Scheduler - A production implementation of
Schedulerthat wraps a [PlatformDispatcher]. - Point
- Describes a location in a 2D cartesian space.
- Point
Refinement - A refinable version of [
#ident], see that documentation for details. - Radians
- Represents an angle in Radians
- Rems
- Represents a length in rems, a unit based on the font-size of the window, which can be assigned with
Window::set_rem_size. - Renderer
Target - What a renderer is built against: the window’s handles, its geometry, and whatever the backend needs to add.
- Request
Frame Options - Rgba
- An RGBA color
- Runnable
Meta - Metadata attached to runnables for debugging and profiling.
- Scaled
Pixels - Represents scaled pixels that take into account the device’s scale factor.
- Scheduler
Local Executor - A
!Sendexecutor pinned to a single session. Tasks spawned on it run in order on whichever thread drains the dispatch destination supplied at construction time — typically the main thread for the default session, or a dedicated OS thread for sessions created byspawn_dedicated_thread. - Scope
- Scope manages a set of tasks that are enqueued and waited on together. See
BackgroundExecutor::scoped. - Screen
Capture Frame - A frame of video captured from a screen.
- Scroll
Wheel Event - A mouse wheel event from the platform.
- Shadow
- Shared
String - A shared string is an immutable string that can be cheaply cloned in GPUI
tasks. Essentially an abstraction over an
Arc<str>and&'static str, currently backed by aSmolStr. - Size
- A structure representing a two-dimensional size with width and height in a given unit.
- Size
Refinement - A refinable version of [
#ident], see that documentation for details. - Source
Metadata - Metadata for a given screen capture source
- Strikethrough
Style - The properties that can be applied to a strikethrough.
- Strikethrough
Style Refinement - A refinable version of [
#ident], see that documentation for details. - System
Notification - A notification posted to the operating system’s notification center, rather than rendered as in-app UI.
- System
Notification Action - A button offered on a
SystemNotification. - System
Notification Response - The user’s activation of a
SystemNotification. - Task
- Task is a primitive that allows work to happen in the background.
- Text
Input Configuration - The configuration of a focused text region’s input session.
- Tiling
- A type to describe which sides of the window are currently tiled in some way
- Titlebar
Options - The options that can be configured for a window’s titlebar
- Touch
Drag Event - A direct touch drag claimed by an element before touch input becomes a tap, long press, or scrolling gesture.
- Touch
Event - A raw touch event from the platform.
- TouchId
- Identifies one touch (finger or stylus contact) for its lifetime, from
TouchPhase::StartedthroughTouchPhase::EndedorTouchPhase::Cancelled. - UTF16
Selection - A struct representing a selection in a text buffer, in UTF16 characters. This is different from a range because the head may be before the tail.
- Underline
Style - The properties that can be applied to an underline.
- Underline
Style Refinement - A refinable version of [
#ident], see that documentation for details. - Window
Button Layout - Describes which
WindowButtons appear on each side of the titlebar. - Window
Controls - What window controls this platform supports
- Window
Id - A unique identifier for a window.
- Window
Insets - Regions of a window that are obscured or reserved by the system.
- Window
Metrics - The state a window is presenting, sampled once from its platform window.
- Window
Options - The variables that can be configured when creating a new window
- Window
Params - The variables that can be configured when creating a new window
- Windowing
Modes - The windowing modes a platform may start in or switch to.
Enums§
- Absolute
Length - Represents an absolute length in pixels or rems.
- Activation
Policy - Controls whether the application participates in the system’s foreground UI.
- Anchor
- Identifies a reference point on a 2D box, used to anchor positioned elements.
- AppLifecycle
Phase - The application’s lifecycle phase, as owned and reported by a mobile OS.
- Autocapitalize
- Automatic capitalization applied by software keyboards.
- Available
Space - The space available for an element to be laid out in
- Axis
- Axis in a 2D cartesian space.
- Background
Tag - Identifies which kind of
Backgroundis being described. - Clipboard
Entry - Either a ClipboardString or a ClipboardImage
- Clipboard
Read Error - An error produced by
Platform::read_from_clipboard_async. - Color
Space - A color space for color interpolation.
- Cursor
Style - The style of the cursor (pointer)
- Decorations
- A type to describe how this window is currently configured
- Definite
Length - A non-auto length that can be defined in pixels, rems, or percent of parent.
- Display
Event - A change to the connected displays, reported through
App::observe_displays. - External
Drag Payload - Data offered to the platform when an internal drag leaves the window and is promoted to a native drag session.
- File
Drop Event - A file drop event from the platform, generated when files are dragged and dropped onto the window.
- Frame
Request Source - The source of a platform frame request’s timestamp.
- GpuBackend
- The graphics API a
GpuAdapterInforuns on, without namingwgpu. - GpuDevice
Type - The class of adapter a
GpuAdapterInfodescribes, without namingwgpu. - GpuPreference
- Which GPU an application prefers the renderer to run on.
- Grid
Placement - The placement of an item within a grid layout’s column or row.
- Image
Format - One of the editor’s supported image formats (e.g. PNG, JPEG) - used when dealing with images in the clipboard
- Length
- A length that can be defined in pixels, rems, percent of parent, or auto.
- Mouse
Button - An enum representing the mouse button that was pressed.
- Navigation
Direction - A navigation direction, such as back or forward.
- OsAction
- An action that the operating system recognizes and can give specialized behavior to.
- Permanent
GpuId - The stable part of a
GpuId. Every adapterenumerate_gpusreports carries one. - Platform
Input - An enum corresponding to all kinds of platform input events.
- Platform
Menu Item - The different kinds of items that can be in a menu.
- Pressure
Stage - The stage of a pressure click event.
- Priority
- Task priority for background tasks.
- Prompt
Button - Prompt Button
- Prompt
Level - The options that can be configured for a file dialog prompt What kind of prompt styling to show
- Resize
Edge - Which part of the window to resize
- Scroll
Delta - The scroll delta for a scroll wheel event.
- Scroll
Physics - How free scrolling decelerates after a fling.
- Session
GpuId - The backend’s handle for an adapter in this session.
- System
Menu Type - The type of a system-managed menu.
- Text
Input Action - The action a software keyboard advertises on its confirm (“enter”) key.
- Text
Input State Change - A change in the state of the focused text input.
- Thermal
State - Thermal state of the system
- Touch
Phase - The phase of a touch motion event. Based on the winit enum of the same name.
- Window
Appearance - The appearance of the window, as defined by the operating system.
- Window
Background Appearance - The appearance of the background of the window itself, when there is no content or the content is transparent.
- Window
Bounds - Represents the status of how a window should be opened.
- Window
Button - A window control button type used in
WindowButtonLayout. - Window
Control Area - A type of window control area that corresponds to the platform window.
- Window
Decorations - A type to describe the appearance of a window
- Window
Kind - The kind of window to create
- Window
Visibility - Whether the platform is presenting a window’s frames.
- Windowing
Request - A display mode for [
App::request_windowing] to switch to.
Constants§
- DEFAULT_
WINDOW_ SIZE - Default window size used when no explicit size is provided.
- KEYSTROKE_
PARSE_ EXPECTED_ MESSAGE - Sentence explaining what keystroke parser expects, starting with “Expected …”
- MAX_
BUTTONS_ PER_ SIDE - Maximum number of
WindowButtons per side in the titlebar.
Traits§
- Along
- A trait for accessing the given unit along a certain axis.
- AsKeystroke
- This is a helper trait so that we can simplify the implementation of some functions
- Half
- Provides a trait for types that can calculate half of their value.
- HasRem
Size - A source of the current rem size, used to convert
PixelstoRems. - IsZero
- A trait for checking if a value is zero.
- Native
Scene Hooks - The platform’s native hooks, as a supertrait every
PlatformRendererhas. - Platform
- Platform
Display - A handle to a platform’s display, e.g. a monitor or laptop screen.
- Platform
Gestures - Platform gesture recognition services.
- Platform
Input Handler Delegate - The gpui-side implementation backing a
PlatformInputHandler. - Platform
Keyboard Layout - A trait for platform-specific keyboard layouts
- Platform
Keyboard Mapper - A trait for platform-specific keyboard mappings
- Platform
Renderer - What a window asks of whatever renders into it.
- Platform
Window - Renderer
Factory - Builds a window’s renderer from the surface the window has already made.
- Screen
Capture Source - A source of on-screen video content that can be captured.
- Screen
Capture Stream - A video stream captured from a screen.
Functions§
- auto
- Returns a
Lengthrepresenting an automatic length. - black
- Pure black in
Hsla - blue
- The color blue in
Hsla - bounds
- Create a bounds with the given origin and size
- ceil_
to_ device_ pixel - Rounds a logical coordinate up to a device pixel boundary.
- checkerboard
- Creates a checkerboard pattern background
- custom_
choice - Resolve a
GpuPreference::Customselector against the adapters that were enumerated. - floor_
to_ device_ pixel - Rounds a logical coordinate down to a device pixel boundary.
- green
- The color green in
Hsla - guess_
compositor - Return which compositor we’re guessing we’ll use. Does not attempt to connect to the given compositor.
- hash
- Use a quick, non-cryptographically secure hash function to get an identifier from data
- hsla
- Construct an
Hslaobject from plain values - linear_
color_ stop - Creates a new linear color stop.
- linear_
gradient - Creates a LinearGradient background color.
- opaque_
grey - Opaque grey in
Hsla, values will be clamped to the range [0, 1] - pattern_
slash - Creates a hash pattern background
- percentage
- Generate a
Radianfrom a percentage of a full circle. - phi
- Returns the Golden Ratio, i.e.
~(1.0 + sqrt(5.0)) / 2.0. - point
- Constructs a new
Point<T>with the given x and y coordinates. - px
- Constructs a
Pixelsvalue representing a length in pixels. - radians
- Create a
Radianfrom a raw value - rank
- Rank one adapter under
preference. - red
- The color red in
Hsla - refresh_
interval_ from_ hz - Converts a refresh rate in hertz to the time between refreshes, rejecting the zero, negative, and non-finite rates platforms use to mean “unknown”.
- relative
- Constructs a
DefiniteLengthrepresenting a relative fraction of a parent size. - rems
- Constructs a
Remsvalue representing a length in rems. - rgb
- Convert an RGB hex color code number to a color type
- rgba
- Convert an RGBA hex color code number to
Rgba - round_
half_ toward_ zero - Rounds to the nearest integer with 0.5 ties toward zero.
- round_
half_ toward_ zero_ f64 - Rounds to the nearest integer with 0.5 ties toward zero.
- round_
stroke_ to_ device_ pixel - Snaps a stroke width to at least one device pixel.
- round_
to_ device_ pixel - Rounds a logical coordinate to the nearest device pixel.
- size
- Constructs a new
Size<T>with the provided width and height. - solid_
background - Creates a solid background color.
- swap_
rgba_ pa_ to_ bgra - Swap from RGBA with premultiplied alpha to BGRA
- transparent_
black - Transparent black in
Hsla - transparent_
white - Transparent white in
Hsla - white
- Pure white in
Hsla - yellow
- The color yellow in
Hsla
Type Aliases§
- Draw
Order - The order in which a primitive is painted within a frame.
- Menu
Command Id - Identifies a menu command whose action
gpuiwill dispatch. - Platform
Screen Capture Frame - The platform-specific representation of a captured frame.
- Runnable
Variant - Type alias for runnables with metadata. Previously an enum with a single variant, now simplified to a direct type alias.
- Timer
Resolution Guard