Commit Graph
3496 Commits
Author SHA1 Message Date
aiongg e592e35d80 W27: Wayland set_ime_surrounding_text sends nothing when unchanged
Each commit makes the compositor send done, and input-method-v2 compositors ignore input-method commits against an older serial, so an app calling it every frame could lose typed text.
2026-10-23 05:29:11 +00:00
aiongg 063cfe9e54 W22: macOS insertText leaves the IME document alone when it drops the text
The replacement range is applied only in the arms that deliver the text, so text dropped while IME isn't allowed doesn't remove text from ImeDocument that the app still shows.
2026-10-23 05:29:11 +00:00
aiongg 953f5e9b97 W24: Windows reset_ime drops the preedit without committing
The window procedure leaves Preedit before CPS_CANCEL, so WM_IME_ENDCOMPOSITION doesn't read GCS_RESULTSTR and commit it, and sends the empty preedit itself, as X11, Wayland and macOS do.
2026-10-23 05:29:03 +00:00
aiongg 8b35388bd7 PATCHES.md: W17–W27, the language-support patches 2026-10-21 18:08:18 +00:00
aionggandDorotaC f40c76a238 W27: Wayland: IME surrounding text and delete-surrounding
Input methods that correct the text around the cursor, such as
Vietnamese engines and predictive keyboards, need the field's text
(text-input-v3 `set_surrounding_text`) and a way to delete part of it
(`delete_surrounding_text`). winit master added both with new core types
and an `Ime::DeleteSurrounding` event; winit 0.30's `Ime` enum is
exhaustive, so they come here as a Wayland extension instead:

- `WindowExtWayland::set_ime_surrounding_text(text, cursor, anchor)`
  clamps the byte offsets to character boundaries and cuts text over the
  protocol's 4000 bytes around the cursor and selection. Enabling a text
  input sends it again with the purpose and cursor area, which enabling
  resets; disallowing IME forgets it.
- A deletion goes out with the `Ime::Commit` of the same input method
  update, an empty one if the update has no commit.
  `WindowExtWayland::take_ime_delete_surrounding` returns it while that
  commit is handled, so the application deletes after removing the
  preedit and before inserting the text, in text-input-v3's order.

Co-authored-by: DorotaC <43449960+dcz-self@users.noreply.github.com>
2026-10-21 18:07:40 +00:00
aiongg 2b9cd1cf47 W26: macOS: delete replaced text by byte count with the commit
Replacement ranges were honoured by sending one Backspace per replaced
character. Toolkits delete a whole grapheme cluster per Backspace, so
replacing text after a combining accent, a flag or a ZWJ emoji deleted
text before the replaced range.

The deletion now goes with an Ime::Commit, as on Wayland:
WindowExtMacOS::take_ime_delete_surrounding returns it, in UTF-8 bytes,
while the app handles that commit. A replacement before a preedit, such
as press-and-hold marking the letter it accents, gets an empty commit.
2026-10-21 18:07:40 +00:00
aiongg eb4007da9e W25: X11/Wayland: report the Latin-layout key of keys on non-Latin layouts
Shortcuts such as Ctrl+C are defined by Latin letters, so on a Russian,
Greek, Arabic, Hebrew or Thai layout a toolkit can't match them from the
characters the keys type. GTK and Qt fall back to the first Latin layout
group for this.

The `KeyEventExtLatinLayout` extension reports, for a key event, what the
key types on the keymap's first Latin layout when the active layout isn't
Latin, letter or not, and whether the active layout is Latin. A toolkit
can then tell a key without a Latin letter (Dvorak's ' on the key that
types й on Russian) from a user without a Latin layout. A layout is Latin
when most of its 26 letter keys type Latin letters, so Dvorak and AZERTY
count as Latin and keep their own letters.
2026-10-21 18:07:40 +00:00
aiongg 4b5bc5a03a W24: Add Window::reset_ime (X11, Wayland, Windows, macOS)
Toolkits need to drop the composition when the text cursor moves to
another field or the user clicks elsewhere in the text, without turning
IME off and on: otherwise the input method continues the composition in
the next field. `reset_ime` discards the composition without committing
it and sends an empty preedit if one was shown.

- X11: resets the window's input context with `XmbResetIC`. IME requests
  are also handled before each X event, so a reset or allow request made
  when focus moved reaches the input method before the next key does.
- Wayland: disables and enables text input in two commits, so the
  compositor deactivates and reactivates the input method, then sends
  the purpose and cursor area again.
- Windows: while a composition is in progress, cancels it with
  `ImmNotifyIME(NI_COMPOSITIONSTR, CPS_CANCEL)`. The IME ends the
  composition with its usual messages; the result string stays empty.
- macOS: the input context discards its marked text, and an empty
  preedit is sent if the input method didn't send one.
- iOS, Android, Web and Orbital ignore it.
2026-10-21 18:07:40 +00:00
aiongg c8cd8aa149 W23: macOS: name keys pressed with ⌘ by the layout's ⌘ table
A key pressed with ⌘ was named by charactersIgnoringModifiers, which
ignores the layout's table for ⌘. On "Dvorak – QWERTY ⌘" the layout
types Dvorak letters but QWERTY ones with ⌘, so ⌘V was reported as ⌘K
and opened PdfCraft's command palette (storytold/pdfcraft#3655). With ⌘
held, the logical key is now UCKeyTranslate's character with cmdKey
(and shiftKey when Shift is held), falling back to the old rule when
the table has no character.

KeyEventExtMacOS::key_with_command reports the ⌘ table's character for
every key event, as key_without_modifiers does for the base table, so
shortcut matching and labels can use it without ⌘ held.
2026-10-21 18:07:40 +00:00
aionggandJeremiah S 0816871e62 W22: macOS: replacement ranges, text typed without a composition, teardown
The view reports a caret to input methods: after the text inserted
since the caret last moved for another reason (a command key, a click,
a shortcut, IME toggled), with marked text after it (ImeDocument).
Dictation, which inserted nothing while selectedRange was NSNotFound
(rust-windowing/winit#4666), now has a place to insert. Replacement
ranges that reach the caret are honoured (#3617): the replaced text is
deleted with Backspace presses before the new preedit or commit, which
toolkits already handle. Press-and-hold then replaces the letter with
the accent picked instead of typing it after the letter. Reporting a
caret also makes held letters in text input open the accent menu
instead of repeating, as in other Mac apps; the repeats the input
method takes for the menu aren't typed.

Text an input method types without a composition during a key press is
committed when it isn't the key's own text, and the key's text isn't
sent: Chinese punctuation (,for ,) and the ideographic space arrived
as the key's ASCII character.

An input method calling the view while its window is torn down no
longer panics inside an Objective-C callback, which aborted: the
firstRectForCharacterRange guard is master's d6f7a28 (#4333), and
queued events and the input context are checked the same way.

Co-authored-by: Jeremiah S <46010924+HXavS@users.noreply.github.com>
2026-10-21 18:07:40 +00:00
aiongg 23bb19a7a9 W21: X11: send the IME spot once the input method is quiet
Setting the IME spot is a synchronous XIM request, and it went out after
the next X event, often one carrying an input method's reply to a key.
Xlib handles the keys an input method forwards back while it waits for
the request's reply: it puts them back on the event queue in reverse
order and marks only the last one as forwarded, so the others are
filtered again. The input method gets its own keys back as new key
presses, and the app gets them after the text committed with them.
Vietnamese engines in fcitx5 that fix a word by forwarding BackSpaces and
committing the new tail garble the text this way
(rust-windowing/winit#4777, storytold/wordcraft#2932).

Input methods only send keys back in answer to keys the client gave
them. The latest spot for each window is now queued and sent once no X
event is queued and no event has gone to the input method for 100 ms;
the event loop wakes up to send it.
2026-10-21 18:07:40 +00:00
aiongg 019c95f115 W20: X11: keep one input context per window
Disallowing IME destroyed the window's input context and allowing it
created a new one. Input methods keep their per-context state only while
the context lives, so each focus change between text fields reset it:
Vietnamese Telex turned off, and the new context stayed unfocused until
the window lost and regained the focus.

The window now keeps the context it was created with, in the preedit
style. Allowing IME focuses it; disallowing it resets the composition and
unfocuses it, and keys are no longer filtered through it.
2026-10-21 18:07:40 +00:00
aiongg fa2e1b3d76 W19: Windows: don't send keys the IME takes as key presses
While an IME uses a key, WM_KEYDOWN carries VK_PROCESSKEY. winit sent
it as a Process key press with the key's physical code, and apps that
fall back to the physical key (egui-winit does) took it as a press of
that key: Backspace, Enter or an arrow typed into a composition acted
both in the composition and in the app. Such a key-down is no longer
sent, unless the IME passes text on with it as WM_CHAR. The key-up still
arrives with the real virtual key.

Guarded in tests/ime_patches.rs. Part of storytold/craft-libs#198
(item I6).
2026-10-21 18:07:40 +00:00
aiongg 894bf2d733 W18: Windows: keep a hidden system caret at the IME cursor area
Some IMEs place their composition and candidate windows at the system
caret (GetCaretPos, GetGUIThreadInfo) and ignore ImmSetCandidateWindow:
Sogou, and some Japanese IMEs. winit created no caret, so those windows
didn't follow the text. A window that has the keyboard focus and allows
IME now keeps a hidden caret the size of the last IME cursor area,
created on focus or when IME is allowed, moved with
set_ime_cursor_area, and destroyed before the window loses the focus
(Windows has one caret per thread).

The policy is plain Rust (ime_caret.rs), so its tests run on every
platform through tests/ime_patches.rs, with a guard on its callers.
Part of storytold/craft-libs#198 (item I6).
2026-10-21 18:07:40 +00:00
aiongg 2be273826c W17: regression tests for W2, W3, W5–W10, W12 and W13
Most of these patches can only be exercised with a real input method or
compositor, so `tests/ime_patches.rs` and `tests/pointer_patches.rs`
check that each fix is still in the source and fail if a rebase drops
it. The Wayland scroll-phase policy (W13) is plain Rust, so its unit
tests run in `tests/pointer_patches.rs` too.
2026-10-21 18:02:42 +00:00
skylartaylor ffae519877 PATCHES.md: the suite's patch list 2026-10-21 18:16:47 +02:00
tomasmark79andBrandon Thomas 5506b1a95e W13: Wayland: pixel-only wheel, wheel-tilt and continuous scrolls report Moved
Use the reported axis source so wheel, wheel-tilt and continuous-source scroll events report
`TouchPhase::Moved` instead of starting a finger gesture that never ends; egui then follows modifier
release instead of keeping Ctrl zoom latched. Finger momentum is unchanged. The phase policy lives
in `seat/pointer/scroll.rs`. Taken from storytold/pdfcraft vendor/winit patch (13)
(storytold/pdfcraft#1569). No upstream winit PR yet.

Co-authored-by: Brandon Thomas <echelon@gmail.com>
2026-10-21 18:16:39 +02:00
tisca26 7facf0011a W12: macOS: the view answers mouseDownCanMoveWindow from movable_by_window_background
With a transparent title bar over a full-size content view, AppKit asks the view under the pointer
whether a press can move the window, and NSView answers YES for a non-opaque view. winit's view did
not override it, so any drag starting in the title-bar band moved the window before the app saw it
(PdfCraft's tab reordering never got the drag). The view now answers with the window's
`movable_by_window_background` attribute (NO unless asked); apps still move the window through
`ViewportCommand::StartDrag`. Taken from storytold/pdfcraft vendor/winit patch (12)
(storytold/pdfcraft#2347). No upstream winit PR yet.
2026-10-21 18:16:39 +02:00
Carmine Paolino b05ce12933 On Wayland, offer the clipboard through winit's data device
Hyprland (0.56.2) sends the selection and drags only to the first
wl_data_device a client binds for a seat (dataDeviceForClient in
src/protocols/core/DataDevice.cpp). Winit binds one for file drops, so a
toolkit clipboard such as smithay-clipboard, which binds a second device on the
same connection, never receives the selection and paste fails everywhere. A
client should keep one data device per seat, so winit now offers the clipboard
on its own device instead.

platform::wayland::Clipboard reads and writes text on the seat that last gave
the application input. It is found from the event loop with
ActiveEventLoopExtWayland::clipboard, or from a wl_display pointer with
Clipboard::for_display, for toolkits that only receive the display handle.
Keyboard enter, key and button events record the serial that setting the
selection needs. Reading another client's selection receives it through a pipe
without dispatching the event loop and gives up after two seconds of silence.
Our own selection carries a private marker type and is returned directly, so
pasting it never waits on the thread that would have to send it. The compositor
asks for our text through the data source, and a short-lived thread writes it.
2026-10-21 18:16:39 +02:00
Carmine Paolino cf73a29ce8 On Wayland, report dropped files through the data device
Winit binds a wl_data_device for each seat and accepts drags that offer
text/uri-list with the copy action. The list is read without blocking as
soon as the drag enters a window, so the window receives HoveredFile for each
local file while the drag is over it, HoveredFileCancelled when it leaves, and
DroppedFile for each file once it is dropped.

The actions are set only on enter: setting them again on motion restarts the
negotiation and can turn a quick drop into a leave. Only file URIs naming this
machine become paths.
2026-10-21 18:16:39 +02:00
skylartaylor c488d2e9a7 W14: fix(macos): route opted-in application termination to close requests
Add an opt-in macOS builder flag that cancels native termination and queues close requests on the ordinary event loop. Preserve default behavior and handle repeated requests, stale windows and completed exits.

Required by storytold/designcraft#544.

(cherry picked from commit 3d51077fd1)
2026-10-21 18:16:39 +02:00
gyuriX 4df8554b7d W11: X11: scale factor from the server DPI before the panel's physical DPI
Without Xft.dpi, use the X screen's configured DPI (its size in pixels and millimetres) before the RandR panel-physical fallback; WINIT_X11_SCALE_FACTOR still overrides. Taken from storytold/pdfcraft vendor/winit (storytold/pdfcraft#1150, replacing the launcher pin in #908); the same change is open as storytold/photocraft#3724, gridcraft#389, deckcraft#170 and wordcraft#721. No upstream winit PR yet.
2026-10-21 18:16:39 +02:00
cyfung1031 4a7dd791ee W10: macOS: retry the first Apple Korean key
Port of rust-windowing/winit#4744.

Originally "M15.1: retry first Apple Korean key" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
2026-10-21 18:16:39 +02:00
cyfung1031 9500f25d84 W9: macOS: don't emit keyboard text again for a Korean IME space
Related to rust-windowing/winit#4478; PdfCraft patch, to be proposed upstream.

Originally "M15.1: suppress duplicate macOS Korean spaces" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
2026-10-21 18:16:39 +02:00
cyfung1031 6a87addd78 W8: macOS: forward emoji-picker text as Ime::Commit
Port of the emoji-picker part of rust-windowing/winit#4749 (0.30 backport of #4748).

Originally "M15.1: forward macOS emoji picker text" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
2026-10-21 18:16:38 +02:00
cyfung1031 9b90d5bd96 W7: macOS: discard marked text when IME is disabled
Port of rust-windowing/winit#4745.

Originally "M15.1: discard stale macOS IME composition" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
2026-10-21 18:16:38 +02:00
cyfung1031 a82b90fb83 W6: macOS: NSTextInputClient IME commit flow
Port of rust-windowing/winit#4650 (0.30 backport of #4651, merged on master).

Originally "M15.1: preserve macOS IME commits" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
2026-10-21 18:16:38 +02:00
cyfung1031 283370ce59 W5: X11: focus the replacement IME context
Port of rust-windowing/winit#4727.

Originally "M15.1: focus replacement X11 IME contexts" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
2026-10-21 18:16:38 +02:00
cyfung1031 3fffb7ce87 W4: Windows: keep hidden maximized windows hidden until shown
Port of rust-windowing/winit#4587 (focus-safe form of #4575).

Originally "M15.1: keep hidden maximized windows hidden" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
2026-10-21 18:16:38 +02:00
cyfung1031 fd104a4c78 W3: Windows: IME caret from GCS_CURSORPOS only when it is reported
Port of rust-windowing/winit#4746.

Originally "M15.1: fix Windows Korean IME caret" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
2026-10-21 18:16:38 +02:00
cyfung1031 13ca693b1e W2: Wayland: destroy the seat text input only when the seat is removed
Port of rust-windowing/winit#4747 (merged on master).

Originally "M15.1: preserve Wayland winit text input" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
2026-10-21 18:16:38 +02:00
cyfung1031 b357a33287 W1: Windows 11: apply the suggested WM_DPICHANGED rect
Backport of rust-windowing/winit#4341 (merged on master).

Originally "M15.1: fix Windows 11 winit DPI transitions" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
2026-10-21 18:16:38 +02:00
Kirill Chibisov e9809ef54b Winit version 0.30.13 v0.30.13 2026-03-02 22:49:04 +09:00
Kirill Chibisov efb5b37fff chore: fix ci 2026-03-02 22:49:04 +09:00
Kirill Chibisov a9baf5ecda fix(android): Populate KeyEvent.text via Key::to_text()
The `text` field on `KeyEvent` was hardcoded to `None` on Android,
making it impossible for custom `NativeActivity` subclasses that
show the IME to receive functional text input using *for example* the
existing `winit-egui` crate which relies on this field being set.

Use `Key::to_text()` on press events to derive `text` from
`logical_key`, matching the convention used by the Windows and macOS
backends.

Supposedly that doesn't include all kinds of special virtual unicode
keys, but at least the basics work this way.
2026-03-02 22:49:04 +09:00
Pedro Macedo 6bb43fd130 wayland: implement resize increments 2026-03-02 22:49:04 +09:00
Kotomine Shiki 17a73f4dd4 win32: fix ime setcontext lparam
Fixes #3893.
2026-03-02 22:49:04 +09:00
Takaranoao bccc568345 fix(macOS): clamp IME selected_range to prevent substringToIndex crash
macOS native Pinyin IME can send a selected_range that exceeds the
marked text string length (e.g. index 8 for a 6-character string).
This caused an NSRangeException in substringToIndex:, crashing the
application with SIGABRT.

Clamp both location and end to the string's UTF-16 length before
calling substringToIndex.
2026-03-02 22:49:04 +09:00
SuchAFuriousDeath 69b8a07ae0 winit-x11: fix debug mode overflow panic in set_timestamp
Fixes #4484
2026-03-02 22:49:04 +09:00
Silico_Biomancer 3eb731f8b5 winit-x11: replace xfixes with x11rb in set_hittest
The xfixes implementation is not that reliable and rather simple to
replace, so use x11rb to implement the same functionality.

Fixes #4120.
Co-authored-by: avitran0 <holyhades64@gmail.com>
2026-03-02 22:49:04 +09:00
itsamine27 7035dd554f winit-win32: Fix ABI mismatch in INIT_MAIN_THREAD_ID
Fixes #4435.
2026-03-02 22:49:04 +09:00
Dan Harris ab4c6bfc82 macOS: fix a crash when dragging non-file content onto window
Winit only supports text, thus we should ignore the rest
instead of crashing.
2026-03-02 22:49:04 +09:00
Kirill Chibisov f6893a4390 Winit version 0.30.12 v0.30.12 2025-07-27 21:59:42 +09:00
Kirill Chibisov c0a8bedee2 chore: fix typos from updated typos tool 2025-07-27 21:59:42 +09:00
Kirill Chibisov b248ecba31 winit: silence wasm on nightly
The lint is needed for stable, but is no longer present on nightly, so
silence it for the time being.
2025-07-27 21:59:42 +09:00
Kirill Chibisov b49d34ebf0 ci/deny: add rustix
Will take a while to move to 1.0 for everyone.
2025-07-27 21:59:42 +09:00
Robert Wallis cc43ea13d9 macOS: fix runtime crash on macos26 "type code 'q', but found 'Q'"
Fixes #4299.
2025-07-27 21:59:42 +09:00
Kirill Chibisov 911fad0af0 Winit version 0.30.11 v0.30.11 2025-05-21 17:50:00 +09:00
Kirill Chibisov 2191eacfc8 chore: appease clippy 2025-05-21 17:50:00 +09:00
Kirill Chibisov f7ac8127e3 wayland: fix pump events's loop drop deadlock 2025-05-21 17:50:00 +09:00