The native legs use step-security/dtolnay-rust-toolchain. The two Windows
GNU legs install a toolchain for another host, which needs
--force-non-host; that fork does not pass it, so rustup installs those
directly.
* ci: use StepSecurity's maintained actions
Each third-party action that StepSecurity publishes a secure drop-in
replacement for now uses that replacement, pinned to a commit with its
version as a comment. Versions follow what we used: the newest
StepSecurity release in the same major, or the closest major they
publish. dtolnay/rust-toolchain refs that named a toolchain (stable,
nightly, 1.76) become the replacement's `toolchain` input.
* ci: keep upstream rust-toolchain where a non-native host toolchain is installed
Adds step-security/harden-runner (audit, pinned to v2.22.4 like
craft-common-actions) as the first step of each job that did not have it,
so every workflow in the org's public repos reports its egress to
StepSecurity. Audit, not block: block-mode allow lists come from each
job's observed traffic.
Fixes#4722.
Both horizontal Win32 wheel paths negate a signed i16 before converting it to f32. For i16::MIN, that overflows in debug builds and wraps in release builds. Convert to f32 before negation and share the conversion helper.
Co-authored-by: mikamikasuki <211269698+mikamikasuki@users.noreply.github.com>
This fixes a crash introduced by #4646. It has already shipped in 0.31.0-beta.3, so hopefully this fix can be merged before the next stable release. We hit it by dragging the window in our project, [Graphite](https://github.com/GraphiteEditor/Graphite), which freezes the app on the first move and followed shortly by a crash to desktop.
`reposition_owned_windows` runs on every `WM_WINDOWPOSCHANGED` that moves a window. It enumerates all windows on the thread that are owned by the moved window, reads each one's `GWL_USERDATA`, and dereferences the value as `*mut WindowData`:
```rs
let userdata_ptr = unsafe { util::get_window_long(hwnd, GWL_USERDATA) } as *mut WindowData;
if !userdata_ptr.is_null() {
let userdata = unsafe { &*userdata_ptr };
```
Nothing checks that the enumerated window was created by winit. `GWL_USERDATA` is free for any window's creator to use, so any owned window that stores something non-zero there is dereferenced as a winit struct. That covers windows the application creates itself through `raw-window-handle`, and potentially dialogs or controls created on the same thread by other libraries.
In Graphite, we are drawing a custom frame and implementing native resize borders with an invisible helper window owned by the winit window. The helper stores the main window's `HWND` in `GWLP_USERDATA`. Moving the winit window therefore crashes on the first position change, every time:
- `0xC0000005` access violation in `winit_win32::event_loop::reposition_owned_windows::enum_proc`
- followed by `0xC000041D` (`STATUS_FATAL_USER_CALLBACK_EXCEPTION`), since the fault happens inside the window procedure while Windows is dispatching the message
This PR fixes it by comparing the window's `GWL_WNDPROC` against `public_window_callback` before touching `GWL_USERDATA` and skipping the window when they differ. Winit's window procedure is what defines the meaning of that slot, so this is the narrowest test that the pointer really is a `WindowData`. Anchored popups still follow their owner with this change.
To reproduce outside of Graphite, on winit's `master`, in any of its examples: create a top-level Win32 window (e.g. `WS_POPUP`) with `CreateWindowExW`, passing the winit window's `HWND` as the owner, call `SetWindowLongPtrW(helper, GWLP_USERDATA, 1)`, then move the winit window by dragging it or calling `set_outer_position`. It dies on the first move. A debug build panics with "misaligned pointer dereference" at the `&*userdata_ptr` line, and a release build exits with `0xC000041D`. With this PR it does not.
Tested on Windows 11 25H2 (build 26200.9445).
The win32 drag-and-drop code now converts between file paths and `file:`
URIs with `percent-encoding` instead of `url`, which pulled in the large
idna and icu4x dependency tree.
The dnd example no longer drags a file out, which was the only thing that
needed the path-to-URI conversion there. It still receives file URIs and
drags out text, HTML and images.
Drop the path/URI conversion helpers (SendData::from_file_paths,
TypedData::try_as_file_paths and From<Vec<url::Url>>) and let downstream
convert file: URIs themselves via SendData::Uris / try_as_uris.
Fixes: #4685
Enum `Ime` should not be `#[non_exhaustive]` since ignoring variants could lead to a mis-match between in-application and external representation of text contents and thus bad behaviour.
Fills in the TODO left when `CGSSetWindowBackgroundBlurRadius` moved
behind `private-apple-apis`, so blur works again by default.
The window's `contentView` is now a plain container `NSView` holding
`WinitView`, and the effect view is installed as a sibling ordered
below it, so the view returned by `raw-window-handle` is never
unlinked from the window. With `private-apple-apis` enabled, the
private API is used exactly as before.
The material is tinted and follows the window's appearance, so the
fixed radius of 80 is not reproduced; that stays available through
the feature.
EventLoop::new() currently panics while handling the XIQueryVersion
reply on servers that only support XI1, such as x2goagent.
Propagate XInput initialization failures through the existing error path
and return NotSupported when the server does not support XI2.
Device::new marks any pointer whose valuator class carries Abs X/Y
labels as DeviceType::Pen, and the XI_Motion/XI_ButtonPress/scroll
handlers drop events from every non-mouse source device. Emulated
pointing devices in virtual machines (the QEMU/VMware/VirtualBox USB
tablets, and any desktop accessed through SPICE or similar VDI
viewers) expose absolute X/Y axes without pressure or tilt, so all
their motion and button input silently disappears: a winit 0.31
application inside a VM console has a dead mouse. winit 0.30, which
had no device classification, handles these devices fine.
Classify a device as pen or eraser only when it has pressure or tilt
axes, which identify actual stylus hardware; bare absolute X/Y is how
every emulated tablet reports and behaves like a mouse.
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
Three fixes for NSTextInputClient protocol implementation:
1. validAttributesForMarkedText now returns standard attributes
(NSUnderlineStyle, NSMarkedClauseSegment) instead of an empty
array. Some IMEs (e.g. LogInputMac3) require non-empty return to
enter composition mode.
2. insertText:replacementRange: no longer gates commit on
hasMarkedText(). Some IMEs call unmarkText before insertText,
which clears the marked text and caused all commits to be
silently discarded.
3. Added pending_commit flag to distinguish genuine composition
commits from regular typing during IME mode (spaces, English
chars), which should go through keyboard input.
Fixes#3925.
Implement possibility to change the anchor properties of a popup on wayland and imitate the behaviour for other platforms which do not support such anchoring system
Trait upcasting (rust-lang/rust#65991) is stable since Rust 1.86, which
is already the MSRV, so dyn trait objects coerce to dyn Any directly.
Traits that needed AsAny now list Any as their supertrait, and the
as_any module is renamed to casting as only the impl_dyn_casting macro
remains.
They were split at some point for whatever reason, yet should result in
a single application level event. The current hack of emitting an IME
event for TextInputEvent breaks with applications that don't handle IME
and it would cause applications that both handle physical key events and
IME events to get double key presses.
Co-authored-by: Jeremy Soller <jackpot51@gmail.com>
Event, input source, error, data transfer, native key, IME request,
scroll delta and fullscreen enums can now gain variants without a
breaking change. Backends and examples get wildcard arms where they
matched exhaustively; unknown IME requests are reported as
ImeRequestError::NotSupported and unknown fullscreen modes behave
like Fullscreen::Borderless(None).
Apps need per-click decisions to follow the macOS convention of accepting
first mouse for low-risk actions (selection, scrolling) but rejecting it
for buttons and destructive actions. Motivated by slint-ui/slint#10451.
Always return `true` from `acceptsFirstMouse:`, and tag the resulting
`PointerButton` events with `is_macos_activation_click: true` (on both
the activating left press and its matching release) so the app can
short-circuit the whole gesture with a single check:
WindowEvent::PointerButton { is_macos_activation_click: true, .. } => return,
Replaces an earlier callback-based design (`accepts_first_mouse` on
`ApplicationHandlerExtMacOS`) that mapped more closely to AppKit but
didn't fit winit's event-driven model and required re-entrancy handling.
Also removes `WindowAttributesMacOS::with_accepts_first_mouse`, which is
now redundant — apps that want to reject activation clicks check the
flag on the per-event instead.
Add `WindowAttributesMacOS::with_fullscreen_auxiliary` and
`WindowExtMacOS::set_fullscreen_auxiliary` / `fullscreen_auxiliary`,
exposing `NSWindowCollectionBehaviorFullScreenAuxiliary`.
An auxiliary window can be shown on the same Space as a fullscreen
window. Without this, ordering a new window on screen while another
window of the application is fullscreen on the active Space makes macOS
switch Spaces or attempt Split View tiling, which flickers and can
abort the fullscreen state. This affects any application that opens
secondary windows (palettes, inspectors, tool windows) from a
fullscreen main window; see e.g.
https://github.com/emilk/egui/issues/8259 for a downstream bug caused
by this.
The attribute is applied in `new_window` so the collection behavior is
already in place when the window is first ordered on screen, which is
required for the fullscreen Space to remain undisturbed (and is not
achievable through the runtime setter, since winit shows the window
during creation).
Since `toggleFullScreen:` is silently ignored by AppKit on windows with
the auxiliary collection behavior, `set_fullscreen` now warns and bails
out early on such windows instead of recording a fullscreen state that
never materializes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Implement proper decorationless popups by specifying the type of the child window with with_type()
With this commit, different kind of child windows can be created
- Popups: Special windows without any decoration which can be positioned relative to the parent
- Window: Normal window with a parent or not
The type can be specified during creation of the Window using the window_attributes and the with_type() function. As default a normal Window is used. If Popup is choosen a parent must be specified, otherwise the Popup creation fails with an Error returned by the new() function.
Related issues: #403 and #4256