Commit Graph
72 Commits
Author SHA1 Message Date
Diggory Hardy 809b3bca88 Remove variant RequestError::Ignored 2026-09-24 10:08:56 +02:00
Diggory Hardy 528fc3e552 Add enum CustomCursorError 2026-09-24 10:08:56 +02:00
Diggory Hardy c8f71cf346 Add enum TransferError 2026-09-24 10:08:56 +02:00
Diggory Hardy 5766910754 Add enum CreateWindowError 2026-09-24 10:08:56 +02:00
Diggory Hardy f377391e48 Add struct InternalError and use in SurfaceSizeWriter 2026-09-24 10:08:56 +02:00
Olivier Goffart 1a7a8f74b7 Remove the url dependency from winit-core
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
2026-09-18 21:03:25 +02:00
Hojjat 818cacd3e8 wayland: use touch serials for drag_window, resize and window_menu 2026-09-18 09:17:44 +02:00
Diggory Hardy a98b2b217c Remove #[non_exhaustive] on enum Ime (#4682)
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.
2026-09-07 12:12:40 +02:00
jess 97fb66b4f6 macOS: implement set_blur using NSVisualEffectView
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.
2026-09-04 10:15:52 +02:00
Martin Marmsoler 4ddca89067 Popup anchor system refinement (#4646)
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
2026-09-02 09:48:58 +02:00
Olivier Goffart 874a1e31f1 Remove the AsAny helper trait
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.
2026-08-21 14:08:47 +02:00
Olivier Goffart c5eee2fb52 Fix clippy warning with Rust 1.98
```
error: unneeded late initialization
    --> winit-core/src/event.rs:1332:9
     |
1332 |         let altitude;
     |         ^^^^^^^^^^^^^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#needless_late_init
     = note: `-D clippy::needless-late-init` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::needless_late_init)]`
help: move the declaration `altitude` here and remove the assignments from the branches
     |
1332 ~
1333 |
1334 ~         let altitude = if self.x.abs() == 90 || self.y.abs() == 90 {
1335 ~             0.
1336 |         } else if self.x == 0 {
1337 ~             PI_0_5 - y.abs()
1338 |         } else if self.y == 0 {
1339 ~             PI_0_5 - x.abs()
1340 |         } else {
1341 |             // Non-boundary case: neither tiltX nor tiltY is equal to 0 or +-90
1342 ~             f64::atan(1. / f64::sqrt(x.tan().powi(2) + y.tan().powi(2)))
1343 ~         };
     |

```
2026-08-21 13:20:28 +02: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 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 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
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
Mads Marquart 0ea5f3c875 macOS: Feature-gate CGSSetWindowBackgroundBlurRadius
Behind the Cargo feature `private-apple-apis`.
2026-07-23 20:16:35 +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 850d5f59a7 winit-wayland: add pointer gesture hold 2026-06-13 02:36:23 +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
RandomScientist 4d81f4aa62 internal(macOS) use NSTrackingArea instead of trackingRect (#4514) 2026-03-18 02:03:16 +01:00
junglie85 8e38112ad3 Add Send and Sync to OwnedDisplayHandle (#4509) 2026-03-17 03:54:42 +01:00
RandomScientist 6f3d763650 Document potential user expectation of ctrl+left click behavior on macOS. (#4518) 2026-03-17 03:39:12 +01:00
Marijn Suijten 5e2f421e34 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:37:30 +09:00
Pedro Macedo 41f4265957 wayland: implement resize increments 2026-03-01 22:28:35 +09:00
Diggory Hardy 7b1dd52ad1 winit-core/ime: implement Error for ImeSurroundingTextError 2025-11-20 19:18:48 +09:00
richerfu 6a46610632 feat(core): add keyboard for ohos 2025-11-17 15:56:20 +09:00
Kirill Chibisov f2ba68771f winit-core: fix set_ime_allowed always panicing 2025-11-16 16:39:15 +09:00
Mads Marquart cc23fbf3be winit/event_loop: Add register_app and run_app_never_return
To allow users to explicitly choose the run semantics that they want.
2025-11-16 16:25:44 +09:00
Mads Marquart c98d880a1c winit-web: return immediately from run_app on web
This avoids using JavaScript exceptions to support `EventLoop::run_app`
on the web, which is a huge hack, and doesn't work with the Exception
Handling Proposal for WebAssembly:
https://github.com/WebAssembly/exception-handling

This needs the application handler passed to `run_app` to be `'static`,
but that works better on iOS too anyhow (since you can't accidentally
forget to pass in state that then wouldn't be dropped when terminating).
2025-11-16 16:25:44 +09:00
Diggory Hardy 9d9d21cfdb winit-core: revise MouseButton type
Unify the values of `MouseButton` and thus remove `Other` variant in
limit possible buttons to 32, which was picked based on platform
capabilities, where 32 is the highest.

For the reference, SDL has identical limit.
2025-11-01 21:00:39 +09:00
Kirill Chibisov 779f52a21f chore: latest typos 2025-11-01 21:00:39 +09:00
DorotaC f41897cfa4 examples/ime: fix crash on wayland
When pressing Ctrl+Space, KeyEvent::text_with_all_modifiers would return
\0. That would get included in the text-input text. When an input method
gets activated, the invalid string returning \0 would get sent as
surrounding text, resulting in a Wayland protocol error and crashing the
application.
2025-10-29 13:40:30 +09:00
Kirill Chibisov c333003514 Bump MSRV to 1.85 and edition to 2024 2025-10-20 00:01:36 +09:00
Kirill Chibisovanddaxpedda f046e778aa winit-core:winit: add tablet input support
The API is integrated into the `WindowEvent::Pointer*` API and is
present in form of `TabletTool` variant on corresponding data entries.

For now implemented for Web, Windows, and with limitations for Wayland.

Fixes #99.

Co-authored-by: daxpedda <daxpedda@gmail.com>
2025-10-07 21:42:36 +09:00
sachharine ffcdf80192 chore: fix typos causing dead links 2025-10-07 19:25:41 +09:00
Kirill Chibisov d815bc089c chore: fix nightly clippy 2025-10-07 17:56:05 +09:00
3be30affe4 wayland: support for pinch, rotation, and pan gestures
Co-Authored-By: linkmauve <linkmauve@linkmauve.fr>
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
2025-09-07 11:45:35 +09:00
DorotaCandKirill Chibisov 6de5041a94 winit-core/ime: add more purposes and content hints
Also move IME example into `ime.rs` thus making IME integrations more
easily comprehendible.

Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
2025-09-06 13:27:55 +09:00
Jeremy Soller 4d9302b33c Add borderless fullscreen mode for orbital (#4343) 2025-09-04 22:14:41 +02:00
Kirill Chibisov bd98561b38 chore: fix typos from recent typos-cli (#4329) 2025-08-12 16:30:34 +09:00
DorotaC d7fdfb1bca winit-core: add Ime::DeleteSurroundingText API
This completes the basic API required for e.g. Wayland.
2025-08-02 19:17:27 +09:00
DorotaC e7a6034b55 winit-core: add surrounding_text for IME
Allow communicating surrounding text to IME to better handle user input
and account for content around for preedit.
2025-07-13 14:57:10 +09:00
DorotaC abed32eb80 winit-core/window: wrap ImeCapabilities in struct
To prevent user from using `::all()` and thus writing not forward
compatible code wrap the bitflags struct and provide simpler interface
to it.
2025-06-29 13:53:47 +09:00
DorotaCanddcz 08907148ec winit-core/window: add Window::request_ime_update
Allow updating IME state atomically to make it easier for platforms
where it's atomic by its nature, like Wayland. The old API is marked
as deprecated and is routed to the new atomic API.

Co-authored-by: dcz <gilapfco.dcz@porcupinefactory.org>
2025-06-28 13:14:20 +09:00
Enn3Developer fe1eab07ae wayland: add xdg_toplevel_icon_v1 support
Closes: #3859.
2025-06-22 19:40:05 +09:00
Kirill Chibisov 0b21c55b72 winit-core/as_any: fix Box<AsAny> casting
The casting was doing an incorrect check on the `ref` instead of
actually trying to downcast a ref as `cast_ref` does. So use `cast_ref`
to check whether we can safely `cast` to owned type.
2025-06-08 22:11:02 +09:00
Martin Fischer f1e0f6c646 icon: add PartialEq and Hash for RgbaIcon 2025-06-08 01:18:55 +09:00
Mads Marquart 2900ecab93 winit-core/keyboard: use keyboard_types
Closes #2394.
2025-06-07 16:47:47 +09:00