Commit Graph

3756 Commits

Author SHA1 Message Date
bjorn3
4e6525b4b7 orbital: Fix EventLoop::run_app_on_demand
Previously event_loop.exit() would persist and cause all future
run_app_on_demand() calls to immediately exit.
2026-08-07 14:48:23 -06:00
Kirill Chibisov
42366231b0 chore: implement EventLoopProvider in each winit-* crate 2026-08-04 01:30:40 +09:00
Kirill Chibisov
d74e5c51d1 winit-core: add EventLoopProvider for common methods
Thus implementing winit main event loop API is standardized.
2026-08-04 01:30:40 +09:00
Olivier Goffart
93045a5b51 Fix formatting 2026-07-29 12:23:49 +02:00
Olivier Goffart
d786b10230 Add changelog entry for the non_exhaustive enums 2026-07-29 12:23:49 +02:00
Olivier Goffart
ea5d7b68c0 Warn on exhaustive exported enums
Enable clippy::exhaustive_enums in every crate so new exported enums
are either #[non_exhaustive] or explicitly allowed as a closed set.
2026-07-29 12:23:49 +02:00
Olivier Goffart
9c7e191407 Mark platform extension enums as #[non_exhaustive]
OS-defined sets and error enums in the platform crates can now gain
variants without a breaking change.
2026-07-29 12:23:49 +02:00
Olivier Goffart
37d8a503e4 Mark extensible enums in winit-core as #[non_exhaustive]
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).
2026-07-29 12:23:49 +02:00
Till Adam
6a8a334426 macOS: add WindowEvent::PointerButton::is_macos_activation_click
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.
2026-07-28 15:16:14 +02:00
Steffen Moeller
92b643c3f1 On macOS, add fullscreen auxiliary window support
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>
2026-07-28 11:49:36 +02:00
Martin Marmsoler
9674d8ceef Wayland, Windows, MacOS: Popup Implementation (#4543)
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
2026-07-27 15:43:51 +02:00
Invades
1fe178b2a6 fix: win32 taskbar_created deadlock 2026-07-27 21:07:17 +09:00
Tony
4a0fd4d4d5 win32: fix window hwnd_dpi leaks HDC handles 2026-07-27 20:42:31 +09:00
Ian Douglas Scott
a9e7bef8ff wayland: Update sctk to 0.21
This uses `Dispatch2`, which will be how `Dispatch` is defined in the
upcoming wayland-rs release.
2026-07-27 20:39:32 +09:00
Ian Douglas Scott
0e7ed677f1 Bump MSRV to 1.86 2026-07-27 20:39:32 +09:00
Mads Marquart
0ea5f3c875 macOS: Feature-gate CGSSetWindowBackgroundBlurRadius
Behind the Cargo feature `private-apple-apis`.
2026-07-23 20:16:35 +02:00
Simon Hausmann
6b113977d8 ci/deny: skip syn 2 and allow libc's packaged script
syn 3 is out and parts of the ecosystem (serde_derive, foreign-types-macros)
have moved to it while others (displaydoc) still use syn 2, so skip the old
version until the migration completes.

libc 0.2.189 ships etc/libc-util.py with the executable bit set, tripping
the interpreted-script check; bypass it until upstream fixes packaging.
2026-07-23 17:20:34 +02:00
Wildan M
d84ec647d8 winit-orbital: Implement pump_app_events 2026-07-19 06:27:29 -06:00
Jeremy Soller
47dada25e4 winit-orbital: provide last mouse position with button events 2026-07-18 16:09:29 -06:00
Wildan M
6616906647 winit-orbital: Fix i586 build 2026-07-18 15:55:06 -06:00
bjorn3
5a0a4ec2a3 winit-orbital: Respect ORBITAL_DISPLAY 2026-07-18 15:19:03 -06:00
Olivier Goffart
48890a95d1 Update cfg_aliases to 0.2.2
Remove the workaround introduced in commit 156433eb, since cfg_aliases
0.2.2 fixes the semicolon_in_expressions_from_macros lint.
2026-07-17 07:07:56 +02:00
Eira Fransham
156433eb91 New drag and drop API (#4571)
This commit implements a new API for drag and drop, with a `DataTransfer` type which abstracts over the various clipboard/drag and drop APIs across different platforms. I built this on top of #2429 although admittedly I ended up removing pretty much all of their work while I was reworking the design.

This is being built in order to help support [drag-and-drop work](https://github.com/slint-ui/slint/issues/1967) in Slint's winit backend. As part of that work, I did extensive research on how drag-and-drop and clipboard APIs are implemented across different platforms, and wrote a (still WIP) research document that can be found [here](https://gist.github.com/eira-fransham/06750cf8d25ade08d362a0ca8dfafe06).

The new API is inspired by the browser's [`DataTransfer`](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer) API.
2026-07-16 14:48:12 +02:00
Martin Marmsoler
066c091b56 fix clippy 2026-07-13 10:26:40 +02:00
Olivier Goffart
ca573df559 wayland: don't send set_buffer_scale on wl_surface below version 3
wl_surface::set_buffer_scale is available since version 3. Sending it
on an older surface is a protocol error that terminates the connection.
This could happen when setting a custom cursor on a compositor without
wp_viewporter. The neighboring damage call already checks the version.
2026-07-09 15:21:47 +02:00
Olivier Goffart
11dd459136 Use the MSRV-aware resolver instead of pinning versions in CI
Resolver 3 skips dependency versions whose rust-version is above
ours, so the CI lockfile step no longer needs --precise pins that
must be maintained by hand.
This is also more reliable as more crate are release with higher MSRV
2026-07-09 15:21:23 +02:00
Olivier Goffart
a4cae17bd9 Ignore quick-xml and ttf-parser advisories in cargo-deny
quick-xml is a build-time dependency of wayland-scanner, which
requires quick-xml 0.39 and only parses trusted protocol XML.
The ttf-parser advisory is an unmaintained notice.
2026-07-09 15:20:19 +02:00
Vitaly Kravchenko
27e17e3f29 Fix AppKit live resize redraw timing 2026-06-24 17:03:24 +02:00
Simon Hausmann
56fde0791b Fix CI
Pin wayland-protocols to the previous version that still compiles with
our MSRV.
2026-06-24 16:58:57 +02:00
William-Selna
4ef144b519 macOS: make Ime::Preedit cursor range surrogate-safe in setMarkedText
`setMarkedText:selectedRange:replacementRange:` converted the IME's UTF-16
`selectedRange` into UTF-8 byte offsets by taking `substringToIndex:` prefixes
and measuring them with `NSString::len()`
(`lengthOfBytesUsingEncoding:NSUTF8StringEncoding`). When an index falls inside
a surrogate pair, the prefix ends in a lone high surrogate, which UTF-8 cannot
represent, so `lengthOfBytesUsingEncoding:` returns 0 for the entire prefix and
the offset silently collapses to 0.
2026-06-20 01:34:43 +09:00
Mads Marquart
7fe8c206ae chore: avoid unsafe in examples
By using `OwnedDisplayHandle`, which uses reference-counting, instead of
`DisplayHandle<'static>` (where the user has to guarantee that the
Application doesn't outlive the event loop).
2026-06-15 03:36:22 +09:00
Sergey Kikevich
fb78ecbb03 windows: fix freeze on keyboard layout switch
Any winit app on Windows freezes when the keyboard layout is switched by
tools such as Punto Switcher. A minidump of the frozen process shows the
main thread blocked in MsgWaitForMultipleObjectsEx (winit's event-loop
wait), re-entered during message dispatch through the switcher's injected
global hook (pshook64.dll, via CallNextHookEx) — a re-entrant Win32
message-loop wait, not a mutex deadlock (no LAYOUT_CACHE frames present).

Handle WM_INPUTLANGCHANGE to refresh the cached keyboard layout, then
defer to DefWindowProc so the message still propagates to first-level
child windows as the Win32 docs require. The cache refresh is the minimal
change that stops the freeze (verified on Windows 11 by isolation
variants); update_modifiers and swallowing the message are not needed.
2026-06-15 03:29:35 +09:00
Martin Marmsoler
850d5f59a7 winit-wayland: add pointer gesture hold 2026-06-13 02:36:23 +09:00
Martin Marmsoler
81b2729765 winit-x11: fix clippy lint 2026-06-05 02:25:58 +09:00
Kirill Chibisov
c4afadbfab winit-wayland: use ext-background-effect if available
A more modern protocol compared to the KDE one.
2026-04-04 23:59:33 +09:00
dependabot[bot]
b5252f1366 chore: bump actions/configure-pages (#4550) 2026-03-28 07:44:01 +01:00
Mads Marquart
f93a223da9 Clean up cargo-deny
Remove the matrix in the CI action; EmbarkStudios/cargo-deny#324 hasn't been resolved yet, but since we've split Winit out into multiple crates, there's still value in minimizing dependency conflicts even if they won't be hit by users, since e.g. Rust-Analyzer will by default check the entire workspace (and thus download and compile duplicate dependencies).
2026-03-28 10:28:31 +09:00
dependabot[bot]
d75a0dada0 chore: bump actions/deploy-pages from 4 to 5 (#4545) 2026-03-26 06:32:41 +01:00
Mads Marquart
9bf46af6f7 AppKit: Use fn_addr_eq now that it's in MSRV (#4532) 2026-03-26 05:50:16 +01:00
Mads Marquart
464c37a94e Remove leftover apple/appkit/mod.rs (#4533) 2026-03-26 05:49:49 +01:00
Mads Marquart
557d285170 Remove symlinking between winit-appkit and winit-uikit (#4530) 2026-03-26 05:49:12 +01:00
Mads Marquart
ba856e127a Fix CI (#4546)
* Fix cargo-deny erroring on new jni-sys version
* Fix unicode-segmentation bumping MSRV
* Fix cargo-deny finding new script in android-activity
2026-03-26 05:26:54 +01:00
Charlie Tonneslan
0ffd303db6 fix(typo): dependant -> dependent (#4540) 2026-03-24 15:54:31 +01:00
Mads Marquart
5a74bf0aab Android: Add further scancode conversions (#4023)
Firefox' source at:
https://searchfox.org/mozilla-central/rev/c597e9c789ad36af84a0370d395be066b7dc94f4/widget/NativeKeyToDOMCodeName.h

Seems to use some other form of scan code? So instead we try to map as
many of the codes available on `Keycode` that they do as possible.
2026-03-19 02:27:23 +01:00
Mads Marquart
117ec364f9 examples: Always use tracing helper module 2026-03-18 22:55:47 +01:00
Mads Marquart
9f789e56ee examples: Use tracing macros instead of println!
This allows the examples to work a bit better in WASM and on iOS.
2026-03-18 22:55:47 +01:00
Mads Marquart
91558169d2 example: Fix tracing registration in pump_events
Tracing subscribers must be set up before `EventLoop::new()`.
2026-03-18 22:55:47 +01:00
Mads Marquart
4998cb990f AppKit: Trace sendEvent: calls
Most events in AppKit go through `sendEvent:`, and they contain a lot of
information, so it's nice to surface this when debugging.

We could override `sendEvent:` in UIKit and track this in there too, but
that's much less important, since there the relevant events are fairly
narrowly scoped, see the link below, other events go through CFRunLoop.
https://developer.apple.com/documentation/uikit/uievent/eventtype
2026-03-18 22:55:47 +01:00
Mads Marquart
98692641c4 UIKit: Add tracing spans 2026-03-18 22:55:47 +01:00
Mads Marquart
a630b5333c Apple: Track spans across queued closures 2026-03-18 22:55:47 +01:00