Commit Graph
1078 Commits
Author SHA1 Message Date
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 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 c0a8bedee2 chore: fix typos from updated typos tool 2025-07-27 21:59:42 +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
Varphone Wong bd2b5cda8d windows: Fix crash in for Windows versions < 17763
In Windows versions < 17763, `GetProcAddress("#132")` from `uxtheme.dll`
also returns a non-null pointer. However, the function does not match
the expected `extern "system" fn() -> bool` prototype, which causes a
crash when it is called.

This fix ensures compatibility by adding proper checks to prevent such
crashes on older Windows versions.
2025-05-21 17:50:00 +09:00
Bruce Mitchener 17b5737972 Fix typos from updated typos tool (#4213) 2025-05-21 17:50:00 +09:00
Kirill Chibisov f49a2a1827 clippy: fix casing in windows backend 2025-05-21 17:50:00 +09:00
Mitoma Ryo a26899a75d windows: fix incorrect cursor_range calculation in Ime::Preedit
The `text` is retrieved as UTF-8 while `attributes` are based on UTF-16,
thus the offset was getting out of sync on some unicode payloads
like surrogate pairs.

Fixes #3967.
2025-04-30 20:46:44 +09:00
Mads MarquartandRJ 80bddda641 macOS: Fix monitors connected via certain Thunderbolt hubs
Instead of panicking, raise a warning and return `None` or similar.

Co-Authored-By: RJ <rj@metabrew.com>
2025-04-30 20:46:44 +09:00
Mads Marquart 5f1e9f6cc1 macOS: Store UUID in MonitorHandle instead of CGDirectDisplayID
The monitor UUID is what actually represents the monitor,
CGDirectDisplayID is closer in correspondence to a specific framebuffer.
2025-04-30 20:46:44 +09:00
Mads Marquart 57baf72741 Allow the user to register the application delegate on iOS
iOS parts of #3758.

This allows the user to override the application delegate themselves,
which opens several doors for customization that were previously closed.
To do this, we use notifications instead of a top-level application
delegate.

One effect of not providing an application delegate on iOS is that we no
longer act as-if the application successfully open all URLs there.

This is a breaking change, although unlikely to matter in practice,
since the return value of `application:didFinishLaunchingWithOptions:`
is seldom used by the system (and this is likely the preferred behaviour
anyhow).
2025-04-30 20:46:44 +09:00
Mads Marquart da7a09658a fix: Support fractional refresh rates in video modes on macOS (#4191)
We were rounding the refresh rate before converting it to millihertz.
2025-04-30 20:46:44 +09:00
Mads Marquart 53321dc6f5 Swizzle sendEvent: instead of subclassing NSApplication
This is done to avoid order-dependent behavior that you'd otherwise
encounter where `EventLoop::new` had to be called at the beginning of
`fn main` to ensure that Winit's application was the one being
registered as the main application by calling `sharedApplication`.

Fixes https://github.com/rust-windowing/winit/issues/3772.

This should also make it (more) possible to use multiple versions of
Winit in the same application (though that's still untested).

Finally, it should allow the user to override `NSApplication` themselves
if they need to do that for some reason.
2025-04-30 20:46:44 +09:00
Mads Marquart 6556cde246 macOS: Close windows automatically when exiting
This disallows carrying over open windows between calls of
`run_app_on_demand` (which wasn't intended to be supported anyhow).
2025-04-30 20:46:44 +09:00
jpy794 7672fd5657 wayland: support fractional scale for custom cursor 2025-04-30 20:46:44 +09:00
Putta Khunchalee 847511672a wayland: add WindowExtWayland::xdg_toplevel
Fixes #4068.
2025-04-30 20:46:44 +09:00
Kirill Chibisov 53bbe6c273 wayland: ensure external loop is notified with pump_events
Spawn a thread when pump_events is used, so the external thread will
get woken-up correctly. This only happens when timeout was given.

Fixes #4183.
2025-04-30 20:46:44 +09:00
robtfm a224b3de06 windows: add locked cursor 2025-04-30 20:46:44 +09:00
Kirill Chibisov 114599c2da wayland/fix: crash due consequent calls to set_cursor_grab
Only mark that the grab was applied when it actually got applied.
Previously there was an issue with grab being marked as applied without
a pointer over the window, when in reality it wasn't.

Fixes #4073.
2025-04-30 20:46:44 +09:00
Kirill Chibisov aaecc92b62 chore: fix clippy issues 2025-04-30 20:46:44 +09:00
Kirill Chibisov c6cfa048b0 x11:wayland: fix pump_events blocking with Wait
Using `Duration::Zero` with `Wait` polling mode was still blocking until
the event was actually delivered. Thus when `pump_events` API is used,
ensure that it's not happening.

Fixes #4130.
2025-04-30 20:46:44 +09:00
aloucks c591089ece macOS: Make set_simple_fullscreen honor set_borderless_game (#4164)
* Prevent panic when calling set_simple_fullscreen(false) on macos

Calling `set_simple_fullscreen(false)` to restore the window after
a previous call to `set_simple_fullscreen(true)` panics with
`view must be installed in a window` in the call to `set_style_mask`
with the old style.

Moving the `set_style_mask` call after the frame has been resized
fixes the issue.

* Hide the doc and menubar on macos when using set_borderless_game
with set_simple_fullscreen
2025-04-30 20:46:44 +09:00
aloucks ec7677d692 Fix a pause in the event loop when clicking the title bar on windows (#4136)
* Fix a pause in the event loop when clicking the title bar on windows

When clicking the title bar on Windows, to drag the window, there is
a noticible pause in continuous redraw requests. This was fixed
in #839 and then regressed in #1852. The cursor blinks in both
cases and is unrelated. The regression made the blink happen after
the pause instead of immediately.

* Update the event loop pause note on the WM_NCLBUTTONDOWN handler

The application example was also updated to optionally animate the fill color
in order to demonstrate continuous redraw without pauses in the event
loop.
2025-04-30 20:46:44 +09:00
rctlmk b9b2f1643e Windows: add IconExtWindows::from_resource_name (#4137) 2025-04-30 20:46:44 +09:00
Kirill Chibisov 1db15b6875 chore: fix clippy lints 2025-04-30 20:46:44 +09:00
Mads Marquart 37a4394a3e Remove apple/appkit/window.rs
Accidentally added in 485ae90aae.
2025-03-17 23:50:15 +01:00