Crafter.Graphics/interfaces
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jorijn van der Graaf a9ce1a02e8
feat(wayland): SetTextInput takes text-input-v3's purposes and its version 1 hints, and enables anew for a field of another kind
Window::SetTextInput knew two purposes, Normal and Phone, and
Device::ApplyTextInput chose the content hints from them: none for
Phone, and completion, spellcheck and auto_capitalization for Normal.
Nothing could send another purpose, or hidden_text or sensitive_data:
a password field was Normal, with those three hints, or Phone.

Types: TextInputPurpose has the fourteen content purposes of the
bundled text-input-v3 protocol, in its order, so that the enumerators
have the protocol's values; Phone was 1 and is 4. kTextInputHintNone
and the ten kTextInputHint* bits are the content hints of version 1
of the protocol, the version Device binds the text input's manager
at, with the protocol's values, and kTextInputHintMask is the ten
together. TextInputDefaultHints(purpose) is what a field gets when
the caller names no hints: the three Normal had, hidden_text and
sensitive_data for Password and Pin, none for the other eleven. For
Normal and Phone without hints that is the content type they had
before.

Window: SetTextInput takes the hints as a last, defaulted
std::optional<std::uint32_t>, which tells kTextInputHintNone (no
hints) from no argument (the purpose's defaults). It keeps only the
bits of kTextInputHintMask: version 2's hints are not in version 1's
enum. On Win32 and in the browser the call still does nothing.

Device, ApplyTextInput: it sends the window's purpose and hints as
they are. For a window whose field is enabled it compares them with
the ones the enable in force went out with, which the window now
keeps, and when either differs it sends an enable before the content
type, where it sent the content type without one. The protocol, as
bundled in lib/text-input-unstable-v3-client-protocol.h, says of
set_content_type's values that "Subsequent attempts to update them
may have no effect" and that they "remain valid until the next
committed enable or disable request", and of enable that it "must be
issued every time the focused text input changes to a new one,
including within the current surface". The same text has an enable
reset "the state associated with preedit_string, commit_string, and
delete_surrounding_text events", so such an enable clears the pending
flags and the record of the composing text the window was last told,
as the disable path does (6f471ca), and fires no onPreedit. A call
with the purpose and hints of the enable in force sends no enable, as
before, also when it is for another field: the window does not know
one field from another of the same purpose and hints, and a caller
marks that move with SetTextInput(false) first.

Device, text_input_done: a listener of onTextInputDelete, onTextInput
or onPreedit may call SetTextInput, and the disable path's clearing
then ran in the middle of a done that was still reading the pending
flags and strings it clears: a disable from a listener of onPreedit
cleared the string the listeners' string_view points into, and one
from a listener of onTextInputDelete reset the flag the commit of the
same done waited on, so that commit never reached onTextInput. The
enable for a field of another kind clears the same values. A listener
may also dispatch the display, as Clipboard::GetText and Window's
constructor do, and the next done then ran inside the first, on
pending values the first had not yet reset. The handler now moves a
done out of the pending values as it arrives, onto a queue, and
delivers from there: the deletion, then the commit, then the
composing text. A done that arrives while another is being delivered
waits on the queue for it, so the window hears the dones in the order
they came. Only the dones wait: a key, pointer or touch event that
the same dispatch brings still fires where it arrives, ahead of a
done that waits, which the consumer notes now say. The commit goes
out whatever a listener of the deletion called SetTextInput with. The
composing text is reported only when nothing has overtaken it since
its done arrived: textInputEpoch, a counter in Device.cpp, moves at a
disable, at an enable for a field of another kind, at a leave and at
every done, and the handler compares the value a done arrived with
against the one after its commit's listeners. A listener may also
destroy the window: ~Window calls Device::ForgetTextInputDones, which
takes the window out of the queue's entries, the one being delivered
among them, and the handler fires nothing more of those. A look-up of
the address in Device::windows would take a window opened at that
address in the meantime for the one destroyed.

Tests: TextInputContent (new) makes the text input a proxy on a
wl_display over a socketpair, as TitleWayland makes its proxies,
reads the requests off the other end and calls the text input's
listener callbacks itself. It checks the purposes and the hint
constants against the bundled protocol header's values, the mask,
and the default hints of the fourteen purposes; then, on the wire:
nothing from a window the text input has not entered; an enable, the
content type, the caret and a commit at the enter; no enable for a
caret that moves; an enable with its own content type for the other
thirteen purposes in turn, after which a composing text equal to the
one before them reaches onPreedit again; named hints in place of the
defaults; an enable for other hints under the same purpose; a
version 2 hint (no_emoji) neither sent nor taken for a change;
kTextInputHintNone sent as 0; the caret in surface coordinates at a
scale of 2; one disable for a field losing the focus; no enable for
a call for another field of the same purpose and hints, and one when
a disable comes before it; and after a leave, nothing until the
enter, which enables the field the window has by then. For the done,
with two listeners on onTextInput and on onPreedit: a first listener
of onPreedit that changes the purpose, or disables the field, and the
listener after it are given the composing text as the input method
sent it; after a listener of onTextInputDelete that changes the
hints, or disables the field, the commit of the same done reaches
both listeners of onTextInput and that done fires no onPreedit; a
done fed from inside a listener of
onTextInputDelete is delivered after the one that listener was called
for, whose commit reaches the listeners of onTextInput before the fed
one's; a done fed from inside a listener of onTextInput is delivered
after that listener's done, whose own composing text is not reported;
a leave fed from inside a listener of onTextInput is followed by no
onPreedit for that done's composing text; and when a listener of
onTextInputDelete feeds a done, destroys the window and puts another
at its address, listed in Device::windows, neither onTextInput nor
onPreedit fires on the new one.

Docs: the consumer notes list the purposes and the hints, the default
hints, what a call that changes either does to a composition under
way, the SetTextInput(false) that marks a move to another field of
the same purpose and hints, and the order the input method's dones
are delivered in. AGENTS.template.md names TextInputContent among
the tests that need no GPU.
2026-11-20 10:08:36 +01:00
..
Crafter.Graphics-Animation.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Clipboard.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-ComputeShader.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-Decompress.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-DescriptorHeapVulkan.cppm fix(window): size the swapchain for its present mode, and key frames in flight by frame instead of image 2026-10-31 18:14:18 +01:00
Crafter.Graphics-DescriptorHeapWebGPU.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Device.cppm feat(wayland): SetTextInput takes text-input-v3's purposes and its version 1 hints, and enables anew for a field of another kind 2026-11-20 10:08:36 +01:00
Crafter.Graphics-Dom.cppm wasm improvements 2026-08-05 04:08:13 +02:00
Crafter.Graphics-DomEvents.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Font.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-FontAtlas.cppm fix(ui): decode the font atlas's SDF in atlas pixels, so text edges ramp over one screen pixel 2026-10-31 20:23:40 +01:00
Crafter.Graphics-ForwardDeclarations.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Gamepad.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-GraphicsTypes.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Image2D.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-ImageVulkan.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-Input.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-InputField.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Keys.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Mesh.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-PipelineRTVulkan.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-PipelineRTWebGPU.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-PlainComputeShader.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-RenderingElement3D.cppm fix(window): size the swapchain for its present mode, and key frames in flight by frame instead of image 2026-10-31 18:14:18 +01:00
Crafter.Graphics-RenderPass.cppm fix(window): size the swapchain for its present mode, and key frames in flight by frame instead of image 2026-10-31 18:14:18 +01:00
Crafter.Graphics-Router.cppm wasm improvements 2026-08-05 04:08:13 +02:00
Crafter.Graphics-RT.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-RTPass.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-SamplerVulkan.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-ShaderBindingTableVulkan.cppm feat(vulkan): run the compute/UI path without VK_EXT_descriptor_heap 2026-10-06 17:28:46 +02:00
Crafter.Graphics-ShaderBindingTableWebGPU.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-ShaderVulkan.cppm feat(device): applications ask for the device features their shaders use 2026-10-31 06:40:02 +01:00
Crafter.Graphics-Types.cppm feat(wayland): SetTextInput takes text-input-v3's purposes and its version 1 hints, and enables anew for a field of another kind 2026-11-20 10:08:36 +01:00
Crafter.Graphics-UI.cppm fix(font-atlas): give glyphs that find no room a cell when the next frame begins, evicting the least recently drawn 2026-10-31 19:43:58 +01:00
Crafter.Graphics-UIComponents.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-VulkanBuffer.cppm feat: windows on their own clock, deferred deletion for every handle owner, staged re-uploads, and RTPass push data 2026-10-20 20:20:29 +02:00
Crafter.Graphics-VulkanTransition.cppm feat(vulkan): run the compute/UI path without VK_EXT_descriptor_heap 2026-10-06 17:28:46 +02:00
Crafter.Graphics-WebGPU.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-WebGPUBuffer.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-WebGPUComputeShader.cppm SPDX license update 2026-07-22 18:09:06 +02:00
Crafter.Graphics-Window.cppm feat(wayland): SetTextInput takes text-input-v3's purposes and its version 1 hints, and enables anew for a field of another kind 2026-11-20 10:08:36 +01:00
Crafter.Graphics.cppm SPDX license update 2026-07-22 18:09:06 +02:00