Commit graph

3666 commits

Author SHA1 Message Date
Kirill Chibisov
90cf9a3398 docs: remove dead doc link 2025-02-20 22:03:03 +03:00
Kirill Chibisov
05d8fa0b91 chore: fix clippy lints 2025-02-20 22:03:03 +03:00
Kirill Chibisov
d7d20507ed ci: disable 32-bit windows gnu on nightly 2025-02-20 22:03:03 +03:00
Bruce Mitchener
f6e66a71f8
doc: remove spurious derive directive
This was unintentionally added in eccd9e415.
2025-02-18 14:53:16 +03:00
Kirill Chibisov
c09160d1a8
Bump version on master
This commit does not represent a release and only synchronizes CHANGELOG
from the latest release.

This also includes 0.30.8 sync, since it was forgotten.
2025-02-06 13:26:30 +03:00
Mads Marquart
2230e71093
ios: fix timers
Fixes #4074.
Fixes #3816.
2025-02-06 12:56:10 +03:00
Kirill Chibisov
5e6350d142
x11: fix modifiers replay
The serial was not unique, thus leading to issues and replay being
triggered for normal input. Track modifiers based on they keycodes
instead, since it's more unique.

Links: https://github.com/alacritty/alacritty/issues/8461
2025-02-05 09:04:09 +03:00
Kirill Chibisov
a6998af997
x11: fix crash with uim
Let's just not forward events to the IME once the user requested that
it should be disabled, though, still try to change its state explicitly.

Fixes #4082.
2025-02-03 20:43:43 +03:00
Mads Marquart
5c48ec7977
Document that we require cargo +nightly fmt (#4105) 2025-01-31 18:24:33 +01:00
Mads Marquart
953d9b4268
Update to objc2 v0.6 (#4092)
* Use available! macro
* Use objc2-core-foundation and objc2-core-graphics
* Use MainThreadBound instead of StaticMainThreadBound hack
2025-01-28 21:31:14 +01:00
valadaptive
f5dcd2aabe
Rework Drag-And-Drop API (#4079)
* Add cursor position drag and drop events.
* Reword drag events to match pointer ones.
* appkit: Use `convertPoint_fromView` for coordinate conversion.
* appkit: use ProtocolObject<dyn NSDraggingInfo>.
* x11: store dnd.position as pair of i16

  It's what translate_coords takes anyway, so the extra precision is
  misleading if we're going to cast it to i16 everywhere it's used.

  We can also simplify the "unpacking" from the XdndPosition message--we
  can and should use the value of 16 as the shift instead of
  size_of::<c_short> * 2 or something like that, because the specification
  gives us the constant 16.
* x11: store translated DnD coords.
* x11: don't emit DragLeave without DragEnter.
* windows: only emit DragEnter if valid.
* windows: in DnD, always set pdwEffect.

  It appears other apps (like Chromium) set pdwEffect on Drop too:
  61a391b86b/ui/base/dragdrop/drop_target_win.cc
* docs: make it clearer that drag events are for dragged *files*.
* examples/dnd: handle RedrawRequested event.

Co-authored-by: amrbashir <amr.bashir2015@gmail.com>
2025-01-28 21:10:40 +01:00
Tom Churchman
77f1c73f06
wayland: clear IME preedit only when necessary
When all we'll be doing is setting a new preedit, the preedit doesn't
have to be explicitly cleared first. This change is perhaps debatable.

The direct reason for this is to make it easier to work around
quirks/bugs: in Masonry we've found IBus appears to resend
the IME preedit in response to `Window::set_ime_cursor_area`
(`zwp_text_input_v3::set_cursor_rectangle`). Because currently the
preedit is first cleared, a new IME cursor area is sent, which again
causes IBus to resend the preedit. This can loop for a while.

The Wayland protocol is mechanically quite prescriptive,
it says for zwp_text_input_v3:event:done.

> 1. Replace existing preedit string with the cursor. 
> 2. Delete requested surrounding text.
> 3. Insert commit string with the cursor at its end.
> 4. Calculate surrounding text to send.
> 5. Insert new preedit text in cursor position.
> 6. Place cursor inside preedit text.

Winit currently doesn't do surrounding text, so 2. and 4. can be
ignored. In Winit's IME model, without a commit, sending just the
`Ime::Preedit` event without explicitly clearing is arguably still
equivalent to doing 1., 5., and 6.
2025-01-17 19:29:10 +03:00
Pascal Hertleif
24c226416e
Use wrapper type for CFUUID (#4032)
This no longer exposes `CGDisplayCreateUUIDFromDisplayID` and instead
uses `CFUUID` to avoid a leak.

Monitor comparisons should also be more stable now.
2025-01-17 12:38:42 +01:00
Sl-L
69382fda9a
examples/child_window: use distinct color/position for children
This should help with understanding how they work.
2025-01-10 18:07:17 +03:00
Kirill Chibisov
ee245c569d
api: make VideoModeHandle into VideoMode
The video mode is generally a static data and not a reference to some
video mode. This changes the exclusive fullscreen API to match that an
accept a monitor now.
2025-01-02 03:29:42 +03:00
Kirill Chibisov
5462f27dda
api: add ActivationToken::{from,into}_raw
This is needed when passing and getting token from the IPC to activate
the window.
2024-12-31 06:08:18 +03:00
Kirill Chibisov
927deb030f
x11: fix cursor grab mode tracking on error
Fixes #4064.
2024-12-31 05:52:12 +03:00
Kirill Chibisov
5ea81efc74 x11: add workaround for disabling IME on gnome
GNOME doesn't list that there's a _NONE_ style at all, but it still
works if you use it.
2024-12-28 14:25:56 -08:00
Matt Campbell
6896de5b73
windows: fix the event loop not waking on accessibility requests
Fixes #4055.
2024-12-24 00:23:44 +03:00
Kirill Chibisov
d736763216
Bump version on master
This commit does not represent a release and only synchronizes CHANGELOG
from the latest release.
2024-12-22 23:13:25 +03:00
Kirill Chibisov
e316a89847
x11: fix KeyboardInput delivered twice with IME
The filtered events were still processed even though they shouldn't once
we know that they're filtered.

Fixes #4048.
2024-12-22 17:51:44 +03:00
Kirill Chibisov
f0d8689039
Bump version on master
This commit does not represent a release and only synchronizes CHANGELOG
from the latest release.
2024-12-21 09:39:09 +03:00
Exidex
4d5e68c6e2
Implement ability to make non-activating window on macOS (#4035)
Fixes #3894
2024-12-13 00:56:39 +01:00
Skip R.
5835c9102e
macOS: Fix checking for undocumented cursors (#4033)
`AnyClass::responds_to` delegates to `class_respondsToSelector`, a
function provided by the Objective-C runtime. However, at some point,
this began to return `false` for selectors referring to undocumented
cursors, despite the cursors remaining accessible via said selectors.
That this check fails prevents the cursors from being used.

We can instead send `respondsToSelector:` to the `NSCursor` class
itself. As an instance method, this is nominally impossible; however,
Apple grants an exemption[1] that permits class objects to perform
instance methods defined in the root class.

Checking for the undocumented cursors in this way gets them working
again, at least on macOS Sequoia 15.1.1.

[1]: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocObjectsClasses.html#//apple_ref/doc/uid/TP30001163-CH11-TPXREF120
2024-12-08 22:01:57 +01:00
Mads Marquart
e47081e385
docs: show less of the unstable docs in the README 2024-12-06 13:16:30 +03:00
Benjamin Brienen
171d53c042
Update smol_str (#3991) 2024-12-03 23:07:19 +01:00
Mads Marquart
35379f305a
Remove feature description in FEATURES.md (#3479)
It easily becomes out of date.
2024-12-03 21:24:57 +01:00
Mads Marquart
4d2a0dd2b3
iOS: Never queue application-level events (#3905)
Events like `resumed`, `new_events`, `about_to_wait`, and so on will
never happen as a result of programmer action, so we'll never need to
queue those. This allows us to remove the need for the old `Event`
struct in the iOS backend.

Furthermore, we can now remove `InUserCallback`, since that state is
already stored inside `EventHandler`.

I've tried to otherwise keep the semantics as close to the original by
calling `handle_nonuser_events(mtm, [])`, which flushes pending events.
2024-12-03 19:53:29 +01:00
Mads Marquart
4a8b659228
Fix MonitorHandle PartialEq and Hash on iOS (#4013) 2024-12-03 19:02:53 +01:00
Mads Marquart
f314cd2b9a
macOS: Fix crash when pressing Caps Lock (#4024)
Events emitted by `flagsChanged:` cannot access
`charactersIgnoringModifiers`. We were previously doing this because we
were trying to re-use the `create_key_event` function, but that is unsuited
for this purpose, so I have separated the `flagsChanged:` logic out from it.
2024-12-03 18:48:23 +01:00
Mads Marquart
3657506f6e
macOS: Avoid redundant initial resize event (#3913)
The `NSViewFrameDidChangeNotification` that we listen to is emitted when
`-[NSWindow setContentView]` is called, since that sets the frame of the
view as well.

So now we register the notification later, so that it's not triggered at
window creation.

This behaviour is well described in the documentation:
https://developer.apple.com/documentation/appkit/nsview/postsframechangednotifications?language=objc
2024-12-03 18:35:04 +01:00
Mads Marquart
edca3ebc41
macOS: Align scancode conversions with Chromium and Firefox (#4019)
Also fix missing codes in physicalkey_to_scancode - This had become out of
sync with scancode_to_physicalkey.
2024-12-03 18:17:57 +01:00
Mads Marquart
ca46e29203
macOS: Fix surface position (#4027) 2024-12-03 17:31:32 +01:00
Mads Marquart
132fbe14d5
macOS: Fix safe area on macOS 10.14 and below (#4028) 2024-12-03 17:19:45 +01:00
Mads Marquart
164bf85b5b
Windows: Add scancode conversions from Chromium sources (#4020) 2024-12-03 11:05:22 +01:00
Mads Marquart
cfa8f027cc
AppKit/UIKit: Do not emit default state events upon window creation (#3912)
Do not emit redundant ScaleFactorChanged, SurfaceResized and Focused.
2024-12-02 23:10:33 +01:00
Mads Marquart
2e5db75101
Linux: Align scancode conversions with Firefox (#4021) 2024-12-02 13:38:37 +01:00
Mads Marquart
19e5bee3d1
chore: fix clippy lints 2024-12-02 14:51:26 +03:00
Hamir Mahal
fc6cf89ac0
style: simplify string formatting for readability (#4001) 2024-11-22 22:14:11 +01:00
Mads Marquart
dbcdb6f1b4
Add safe area and document coordinate systems (#3890)
Added `Window::safe_area`, which describes the area of the surface that
is unobstructed by notches, bezels etc. The drawing code in the examples
have been updated to draw a star inside the safe area, and the plain
background outside of it.

Also renamed `Window::inner_position` to `Window::surface_position`, and
changed it to from screen coordinates to window coordinates, to better
align how these coordinate systems work together.

Finally, added some SVG images and documentation to describe how all of
this works.

This is fully implemented on macOS and iOS, and partially on the web.

Co-authored-by: daxpedda <daxpedda@gmail.com>
2024-11-21 17:37:03 +01:00
Rodrigo Rivas Costa
d0c6c34eaa
x11: move up XInput2 event registration
It should be done before mapping the window, or we could
lose the firsst XInput2 events, such as the first FocusIn.

Fixes #2841.
2024-11-21 14:04:55 +03:00
Mads Marquart
f2688d94ea
ci: fix cargo deny 2024-11-21 10:28:32 +03:00
Nico Burns
f6b20852bf
macOS: set activation policy by default if app is not bundled (#3961) 2024-11-18 21:19:45 +01:00
Kirill Chibisov
59b1eb5410
api: make OwnedDisplayHandle wrap an opaque type
This will help in case we want to linger the event loop during drop
to prevent use after free in the consumers code.
2024-11-13 15:29:05 +03:00
Aaron Muir Hamilton
f781e13166
X11: Use bottom-right corner of IME cursor area as caret position
XIM servers currently do not support preedit area reporting from
clients and there may be no standard way to report it.

Fcitx and iBus both place the candidate window descending descending
from the caret, with the reported X font; but since winit does not
report a font, the height of the line is assumed 0, so when we report
the top left corner of the cursor area they will tend to obscure it.

Taking this into account, the best default option is to report the
bottom right corner of the cursor area, because it will tend not to
obscure the preedit area when using `Window::set_ime_cursor_area` in
the way suggested by documentation.
2024-11-13 15:13:09 +03:00
Piotr Podusowski
9f8ac8feb5
android: use show_soft_input to summon the keyboard
Route it via the `Window::set_ime_allowed` like on iOS.
2024-11-13 14:43:59 +03:00
Mads Marquart
74958ecc6f
docs: add fn main to root examples
This is not strictly required, but makes the examples a bit easier to
read understand (especially since the `EventLoop` really _should_ be
created inside `fn main`, and not in some random function potentially
running on a random thread).
2024-11-12 16:52:48 +03:00
Kirill Chibisov
3a60cbaba5
api: make EventLoopProxy wrap an opaque type
The proxy is intended to be Clone, thus use `Arc` for it internally and
don't require backends for it to be `Clone`. Use `EventLoopProxyProvider`
to hide the backend's proxy implementation details.

Co-authored-by: daxpedda <daxpedda@gmail.com>
2024-11-12 10:56:20 +03:00
Matěj Laitl
ae4c449670 x11: fix WindowAttributesExtX11::with_x11_screen()
Based on https://github.com/rust-windowing/winit/pull/3973, which should be merged first.

There's an API to programmatically specify X11 screen id (override what is determined from the `DISPLAY` env variable), but it doesn't work.

Seeting up X Server with 2 screens and calling `DISPLAY=:0 X11_SCREEN_ID=1 cargo run --example window` should be equivalent to calling `DISPLAY=:0.1 cargo run --example window`

The latter works (and places the window on the correct screen), but the former yields

`failed to create initial window: Os(OsError { line: 620, file: "src/platform_impl/linux/x11/window.rs", error: X11Error(X11Error { error_kind: Match, error_code: 8, sequence: 219, bad_value: 1319, minor_opcode: 0, major_opcode: 1, extension_name: None, request_name: Some("CreateWindow") }) })`

_Here `1319` is the root window id for screen 0, which doesn't match the screen 1 that we request._

The problem is that we need to factor in the screen id when determining the parent (root) window when not explicitly set. This patch does that.

---

Also: Extend the window example with X11_{SCREEN,VISUAL}_ID env variables
2024-11-06 08:30:25 -08:00
Kirill Chibisov
b2896d7408
chore: always pull raw-window-handle
Winit is not useful without it and we don't provide older versions
anymore.
2024-11-03 00:39:01 +03:00