Commit Graph

550 Commits

Author SHA1 Message Date
Kirill Chibisov 2d96480a89
Use beta versions of android crates 2023-08-16 12:31:23 +04:00
Kirill Chibisov 6caff77abb
Bump MSRV to 1.65 2023-08-16 12:10:38 +04:00
Mads Marquart af6c343d0e
Improve macOS/iOS/Web thread safety
Co-authored-by: daxpedda <daxpedda@gmail.com>
2023-08-14 23:19:57 +04:00
Kirill Chibisov 119462795a
Pin android-activity git dependency 2023-08-14 23:10:32 +04:00
Robert Bragg bd2f1e8312
Android: Support unicode character mapping + dead keys
Up until now the Android backend has been directly mapping key codes
which essentially just represent the "physical" cap of the key (quoted
since this also related to virtual keyboards).

Since we didn't account for any meta keys either it meant the backend
only supported a 1:1 mapping from key codes, which only covers a tiny
subset of characters. For example you couldn't type a colon since
there's no keycode for that and we didn't try and map Shift+Semicolon
into a colon character.

This has been tricky to support because the `NativeActivity` class doesn't
have direct access to the Java `KeyEvent` object which exposes a more
convenient `getUnicodeChar` API.

It is now possible to query a `KeyCharcterMap` for the device associated
with a `KeyEvent` via the `AndroidApp::device_key_character_map` API
which provides a binding to the SDK `KeyCharacterMap` API in Java:

 https://developer.android.com/reference/android/view/KeyCharacterMap

This is effectively what `getUnicodeChar` is implemented based on and is
a bit more general purpose.

`KeyCharacterMap` lets us map a key_code + meta_state from a `KeyEvent`
into either a unicode character or dead key accent that can be combined
with the following key. This mapping is done based on the user's chosen
layout for the keyboard.

To enable support for key character maps the
`AndroidApp::input_events()` API was replaced by
`AndroidApp::input_events_iter()` which returns a (lending) iterator for
events. This was changed because the previous design made it difficult
to allow other AndroidApp APIs to be used while iterating events (mainly
because AndroidApp held a lock over the backend during iteration)
2023-08-08 02:56:42 +04:00
Mads Marquart b5aa96bea4
Update icrate to v0.0.4 (#2992) 2023-08-02 16:30:41 +02:00
Mads Marquart e33d2bee6c
Update `objc2` version (#2936)
* Upgrade to objc2 v0.4.0 and icrate v0.0.3

* Fix `touchBar` method

* Use ClassType::alloc

* Use #[method_id(...)] functionality in declare_class!
2023-07-29 00:33:03 +02:00
John Nunley 43acf7f42f
Replace libc with rustix in some modules
Unfortunately this isn't a total removal, for two reasons:

- We still need "libc" for the Xlib XIM implementation, for locales.
- BSD requires libc to check for main-threadedness.

First one we can likely resolve in the near future, not so sure about
the second one without using some weird pthreads trick.
2023-07-22 09:32:27 +00:00
Kirill Chibisov f7a84a5b50
Add `platform::startup_notify` for Wayland/X11
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes #2279.

Co-authored-by: John Nunley <jtnunley01@gmail.com>
2023-07-20 13:16:51 +00:00
John Nunley d7ec899d69
Replace parts of the Xlib backend with x11-rb 2023-07-12 07:59:12 +00:00
daxpedda 5e0e1e96bc
On Web, implement `WindowEvent::Occluded` (#2940) 2023-07-10 02:02:38 +02:00
Kirill Chibisov 6178acede8
Bump version on master
This commit does not represent a release and only synchronizes CHANGELOG
from the latest release.
2023-07-01 00:10:02 +04:00
Fredrik Fornwall 924f3323b5 On Web, map bfcache load/unload to suspend/resume 2023-06-28 15:38:49 +02:00
Kirill Chibisov 0defd747c8 Update xkbcommon-dl to 0.4.0
Most things were simply renamed due to migration to xkeysym.
2023-06-28 14:48:35 +04:00
John Nunley b2a46d0439
Fill the windows in the examples with a solid color
Fixes #776.
2023-06-19 18:46:38 +00:00
daxpedda 9a9c9b15ba
Implement `ResizeObserver` (#2859)
Co-authored-by: Liam Murphy <43807659+Liamolucko@users.noreply.github.com>
2023-06-14 09:43:53 +02:00
daxpedda f0d88c52a3
Fix pointer deltas on Firefox and send coalesced events together (#2878) 2023-06-13 15:49:27 +02:00
dAxpeDDa ab4a4a89e6 Remove unused `EventListenerOptions` 2023-06-11 19:44:52 +02:00
dAxpeDDa ab46aa5b79 Replace `beforeunload` with `pagehide` 2023-06-05 16:40:53 +02:00
dAxpeDDa 12fb37d827 Make media queries more robust 2023-06-05 16:11:22 +02:00
daxpedda 8f7f3efc0d
On Web, implement `Send` and `Sync` where appropriate (#2834) 2023-06-05 02:44:54 +02:00
dAxpeDDa a134a59917 Remove `MouseEvent` fallback support 2023-06-05 02:04:37 +02:00
John Nunley 642ce2bfa7
Port to windows-sys v0.48.0 (#2842) 2023-06-04 00:02:37 +02:00
dAxpeDDa 5bbe87960e Replace `instant` with `web-time` 2023-06-03 16:05:44 +02:00
George Burton 31ebc5caf4
Update `bitflags` to `2.0`
Co-authored-by: dAxpeDDa <daxpedda@gmail.com>
2023-06-02 17:44:36 +03:00
dAxpeDDa 2ade772ab0 Bump `console_log` to v1 2023-06-01 17:19:30 +02:00
John Nunley 4ac2006cbc
Replace mio with calloop in the X11 backend 2023-05-31 19:44:42 +03:00
dAxpeDDa ba5ad3be13 On Web, fix no-op for `Window::set_fullscreen` 2023-05-31 15:25:15 +02:00
Kirill Chibisov b5af6bb266
Use xkbcommon-dl 0.3.0 2023-05-29 00:55:54 +03:00
Markus Røyset 918430979f
Overhaul the Keyboard API
Overhaul the keyboard API in winit to mimic the W3C specification
to achieve better crossplatform parity. The `KeyboardInput` event
is now uses `KeyEvent` which consists of:

  - `physical_key` - a cross platform way to refer to scancodes;
  - `logical_key`  - keysym value, which shows your key respecting the
                     layout;
  - `text`         - the text produced by this keypress;
  - `location`     - the location of the key on the keyboard;
  - `repeat`       - whether the key was produced by the repeat.

And also a `platform_specific` field which encapsulates extra
information on desktop platforms, like key without modifiers
and text with all modifiers.

The `Modifiers` were also slightly reworked as in, the information
whether the left or right modifier is pressed is now also exposed
on platforms where it could be queried reliably. The support was
also added for the web and orbital platforms finishing the API
change.

This change made the `OptionAsAlt` API on macOS redundant thus it
was removed all together.

Co-authored-by: Artúr Kovács <kovacs.artur.barnabas@gmail.com>
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
Co-authored-by: daxpedda <daxpedda@gmail.com>
Fixes: #2631.
Fixes: #2055.
Fixes: #2032.
Fixes: #1904.
Fixes: #1810.
Fixes: #1700.
Fixes: #1443.
Fixes: #1343.
Fixes: #1208.
Fixes: #1151.
Fixes: #812.
Fixes: #600.
Fixes: #361.
Fixes: #343.
2023-05-28 21:02:59 +03:00
Kirill Chibisov a7986b077f
Bump version on master
This commit does not represent a release and only synchronizes CHANGELOG
from the latest release.
2023-05-14 20:36:23 +03:00
Kirill Chibisov bd9cc2a9da
Use `cursor-icon` crate for `CursorIcon`
This crate is aimed to simplify handling of cursor icon across
various crates and be used in the public API.
2023-05-09 20:19:35 +03:00
Kirill Chibisov 596c0edf0f
Bump version on master
This commit does not represent a release and only synchronizes CHANGELOG
from the latest release.
2023-05-09 18:28:20 +03:00
Kirill Chibisov ad52c72e41
Bump version on master
This commit does not represent a release and only synchronizes CHANGELOG
from the latest release.
2023-05-05 13:27:22 +03:00
Kirill Chibisov 2496098890
Update wayland-rs to 0.30.0
This update rewrites the winit's Wayland backend using new wayland-rs
0.30 API. This fixes long standing issue with the forward compatibility
of the wayland backend, meaning that future updates to the wayland
protocol won't break rust code anymore. like it was before when adding
new shm/enum variants into the protocol.

Fixes #2560.
Fixes #2164.
Fixes #2128.
Fixes #1760.
Fixes #725.
2023-04-19 00:56:29 +03:00
Kirill Chibisov d4c9535af9
Bump version on master
This commit does not represent a release and only synchronizes CHANGELOG
from the latest release.
2023-03-16 23:05:17 +03:00
daxpedda f0fcb346b0
On Web, use `target_family = "wasm"` 2023-03-16 22:49:59 +03:00
Mads Marquart 77f8e511e9
Fix macos memory leaks (#2739)
* Use a weak reference from WinitView to WinitWindow

* Allow patched objc2 version

* Add changelog entry
2023-03-14 13:27:41 +03:00
Kirill Chibisov b18295a1ce
Bump MSRV to 1.64 2023-03-08 19:34:10 +03:00
Kirill Chibisov 08bdca19b1
Bump version on master
This commit does not represent a release and only
synchronizes CHANGELOG from the latest release.
2023-03-02 17:15:48 +03:00
Kirill Chibisov 69d6076310
Bump version on master
This commit does not represent a release and only
synchronizes CHANGELOG from the latest release.
2023-02-04 14:47:31 +03:00
Kirill Chibisov 1eb1a13a77
Bump version on master
This commit does not represent a release and only
synchronizes CHANGELOG from the latest release.
2023-02-02 10:55:59 +03:00
Markus Siglreithmaier e1b7fda409
Bump windows-sys version to 0.45 (#2639)
Bump windows-sys version to fix regression
2023-01-23 22:10:28 +01:00
Douglas Dwyer b711a11549
Properly remove window mouse event listeners (#2632)
* Properly remove window mouse event listeners

* Update CHANGELOG.md

* Fix formatting

Co-authored-by: Mads Marquart <mads@marquart.dk>
2023-01-21 16:58:05 +01:00
Kirill Chibisov de782504ab
On Wayland, add support for fractional scaling
This adds support for the fractional scaling on Wayland via the
wp-fractional-scale protocol.

Co-authored-by: Julian Orth <ju.orth@gmail.com>
2023-01-20 00:02:16 +03:00
John Nunley 08ce3af3e1
Ensure all free unixes can build
This fixes the `cfg` guards inside the `Cargo.toml`.
2023-01-10 12:00:28 +03:00
John Nunley 4b22ca8daf
chore: Alphabetize dependencies (#2619) 2023-01-06 11:26:57 +01:00
Jeremy Soller 66ca445caa
Redox OS support (#2588)
* Add Redox OS support

* Simplify control flow usage

* Apply more recommendations

* Update naming to indicate that Orbital is a platform

* Adjust import order
2023-01-05 06:58:08 -07:00
Amr Bashir 5e77d70245
Use cfg aliases throught the code base
Co-authored-by: Mads Marquart <mads@marquart.dk>
2022-12-25 10:57:27 +03:00
Alphyr 58ec458877
Remove compatibility shim for `raw-window-handle` 0.4 2022-12-24 15:53:46 +03:00
Robert Bragg 1786c877ec
android: depend on android-activity 0.4.0 (#2557) 2022-11-26 11:54:08 +01:00
Robert Bragg 05484c5888
Android: rework backend to use android-activity crate (#2444)
This updates the Android backend to use the android-activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves #2299)

To make it possible for application crates to avoid explicitly
depending on the `android-activity` crate (and avoid version conflicts)
this re-exports the android-activity crate under:

  `winit::platform::android::activity::*`

This also adds `android-native-activity` and `android-game-activity`
features that set the corresponding android-activity features.

Addresses: PR https://github.com/rust-windowing/winit/pull/1892
Addresses: PR https://github.com/rust-windowing/winit/pull/2307
Addresses: PR https://github.com/rust-windowing/winit/pull/2343

Addresses: #2293
Resolves: #2299

Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>

Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>
2022-11-10 17:55:19 +01:00
Ihor Ranchynskyi a7a7cc64cd
Bump `windows-sys` to 0.42 (#2540) 2022-10-31 23:19:45 +01:00
Kirill Chibisov 04d9e081b8
Bump version on master
This commit does not represent a release and only
synchronizes CHANGELOG from the latest release.
2022-10-26 18:20:58 +03:00
i509VCB 8fc24c959a
Generate docs.rs documentation with doc_auto_cfg (#2358) 2022-10-25 00:02:52 +02:00
Kirill Chibisov 462bb4d324
Bump version on master
This commit does not represent a release and only
synchronizes CHANGELOG from the latest release.
2022-10-15 09:30:25 +03:00
Kirill Chibisov 58f2455aa9
Bump version on master
This commit does not represent a release and only
synchronizes CHANGELOG from the latest release.
2022-09-12 18:15:30 +03:00
Kirill Chibisov a4695c5397
Specify minimum supported version for RWH 0.4
Winit uses raw-window-handle of version 0.4.3,
but only 0.4.0 was specified.
2022-09-09 12:11:55 +03:00
Mads Marquart d8c0ee733b
Remove custom definition of Core Foundation runloop functionality (#2479)
Use the definitions that `core_foundation` exposes (almost the same, except `CFRunLoopSourceContext::perform` is not nullable, so we account for that as well).
2022-09-08 21:03:25 +02:00
Mads Marquart fb248eaadc
Clean up iOS class declaration (#2462)
* Begin abstraction over UIKit

* Clean up UIWindow override declaration

* Clean up UIApplication delegate declaration

* Clean up UIViewController override declaration

* Finalize objc -> objc2 rename
2022-09-08 20:30:34 +02:00
Mads Marquart 340f951d10
Refactor macOS to use new `objc2` features (#2465)
* Remove UnownedWindow::inner_rect

* Refactor custom view to use much less `unsafe`

The compiler fence is safe to get rid of now since `interpretKeyEvents` takes `&mut self`

* Refactor Window to use much less unsafe

* Refactor NSApplication usage to have much less unsafe

* Remove cocoa dependency

* Enable `deny(unsafe_op_in_unsafe_fn)` on macOS

Also re-enable clippy `let_unit_value` lint

* Remove #[macro_use] on macOS

* Refactor window delegate to use much less unsafe
2022-09-08 16:45:29 +02:00
Lucas Kent 97d2aaa953
Add web_aspect_ratio example (#2209)
* Add web_aspect_ratio example

* Review feedback
2022-09-03 18:26:24 +02:00
Mads Marquart 112965b4ff
Initial transition to `objc2` (#2452)
* Use objc2

* Use objc2's NSInteger/NSUInteger/NSRange
2022-09-02 15:48:02 +02:00
Mads Marquart e0018d0710
Bump MSRV to 1.60 (#2453) 2022-09-02 10:59:05 +02:00
Mads Marquart 8729119536
Remove parking_lot dependency (#2423) 2022-08-31 18:32:19 +02:00
ajtribick fd72000a9a
Disable default features in simple_logger
This fix CI building due to implicit rust version
bump in examples.
2022-08-29 00:26:51 +03:00
daxpedda f9b41fd819
Update `sctk-adwaita` to use `ab_glyph`
The crossfont will still be available under the option.
2022-08-24 15:24:29 +03:00
Kirill Chibisov 2e4338bb8d
Release 0.27.2 version 2022-08-12 14:39:44 +04:00
Robert Bragg 11d4a301e4
Implement version 0.4 of the HasRawWindowHandle trait
This makes Winit 0.27 compatible with crates like Wgpu 0.13 that are
using the raw_window_handle v0.4 crate and aren't able to upgrade to 0.5
until they do a new release (since it requires a semver change).

The change is intended to be self-contained (instead of pushing
the details into all the platform_impl backends) since this is only
intended to be a temporary trait implementation for backwards
compatibility that will likely be removed before the next Winit release.

Fixes #2415.
2022-08-11 18:33:02 +04:00
Kirill Chibisov c53a574bff
Release 0.27.1 version 2022-07-30 19:33:23 +03:00
Kirill Chibisov bf537009d9
Explicitly specify minimum supported rust version
This should help with distributing apps using winit.

Fixes #1075.
2022-07-29 14:39:41 +03:00
Kirill Chibisov 50035643f7
Release 0.27.0 version 2022-07-26 23:54:12 +03:00
Marijn Suijten 5a0bad130d
Bump `ndk` and `ndk-glue` dependencies to stable `0.7.0` release (#2392) 2022-07-25 15:20:31 +02:00
Kirill Chibisov 653bc59813
Update raw-window-handle to v0.5.0
This updates raw-window-handle to v0.5.0.
2022-07-21 22:22:36 +03:00
Kirill Chibisov f09259f6de
Bump sctk-adwaita to 0.4.1
This should force the use of system libraries for Fontconfig
and freetype instead of building them with cmake if missing.

This also fixes compilation failures on nightly.

Fixes #2373.
2022-07-20 11:50:49 +03:00
Marijn Suijten 472d7b9376
android: Hold `NativeWindow` lock until after notifying the user with `Event::Suspended` (#2307)
This applies https://github.com/rust-windowing/android-ndk-rs/issues/117
on the `winit` side: Android destroys its window/surface as soon as the
user returns from [`onNativeWindowDestroyed`], and we "fixed" this on
the `ndk-glue` side by sending the `WindowDestroyed` event before
locking the window and removing it: this lock has to wait for any user
of `ndk-glue` - ie. `winit` - to give up its readlock on the window,
which is what we utilize here to give users of `winit` "time" to destroy
any resource created on top of a `RawWindowHandle`.

since we can't pass the user a `RawWindowHandle` through the
`HasRawWindowHandle` trait we have to document this case explicitly and
keep the lock alive on the `winit` side instead.

[`onNativeWindowDestroyed`]: https://developer.android.com/ndk/reference/struct/a-native-activity-callbacks#onnativewindowdestroyed
2022-07-14 12:35:49 +02:00
Kirill Chibisov c93ef47b9b
Bump smithay-client-toolkit to v0.16.0 2022-06-20 10:19:49 +03:00
Mads Marquart 40abb526cc
Remove core-video-sys dependency (#2326)
Hasn't been updated in over 2 years - many open PRs, seems abandoned. Is the cause of several duplicate dependencies in our dependency tree!
2022-06-11 02:37:46 +02:00
Mads Marquart c532d910c0
Build docs on `docs.rs` for iOS and Android as well (#2324) 2022-06-11 00:45:24 +02:00
Marijn Suijten 57981b533d
On Android, use `HasRawWindowHandle` directly from the `ndk` crate (#2318)
The `ndk` crate now implements [`HasRawWindowHandle` directly on
`NativeWindow`], relieving the burden to reimplement it on `winit`.

[`HasRawWindowHandle` directly on `NativeWindow`]: https://github.com/rust-windowing/android-ndk-rs/pull/274
2022-06-10 11:37:06 +02:00
James Liu 2c01e9e747
Migrate from lazy_static to once_cell 2022-06-08 21:50:26 +03:00
Bartłomiej Maryńczak 829a140d9b
On Wayland, provide option for better CSD
While most compositors provide server side decorations, the GNOME
does not, and won't provide them. Also Wayland clients must render
client side decorations.

Winit was already drawing some decorations, however they were bad
looking and provided no text rendering, so the title was missing.
However this commit makes use of the SCTK external frame similar to
GTK's Adwaita theme supporting text rendering and looking similar to
other GTK applications.

Fixes #1967.
2022-05-20 03:09:23 +03:00
Kirill Chibisov f04fa5d54f
Add new `Ime` event for desktop platforms
This commit brings new Ime event to account for preedit state of input
method, also adding `Window::set_ime_allowed` to toggle IME input on
the particular window.

This commit implements API as designed in #1497 for desktop platforms.

Co-authored-by: Artur Kovacs <kovacs.artur.barnabas@gmail.com>
Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>
Co-authored-by: Murarth <murarth@gmail.com>
Co-authored-by: Yusuke Kominami <yukke.konan@gmail.com>
Co-authored-by: moko256 <koutaro.mo@gmail.com>
2022-05-07 05:29:25 +03:00
Markus Siglreithmaier b4175c1454
Bump windows-sys version to 0.36 (#2277) 2022-05-03 12:39:29 +02:00
Kirill Chibisov aac28d24ac
Force SCTK version to prevent pointer leaking
SCTK versions before 15.4 were leaking pointers when window got closed.
So the more windows you've got the pointers you'll keep around.

Fixes #2248.
2022-04-10 13:42:05 +03:00
Clemens Wasser b222dde835
Adopt windows-sys (#2057) 2022-03-07 22:58:12 +01:00
Lucas Kent b7e7755edd
Improve web example (#2115)
* Improve web example

* Implement basic logger into the example webpage

* Repace bash script with xtask

* replace wasm-bindgen-cli with wasm-bindgen-cli-support

* refactor

* Move logic into external crate.

* Remove CI changes

* Review feedback
2022-02-25 12:57:46 +01:00
Mads Marquart cd9ec0afc7
Bump `dev-dependencies` (#2181)
* Update image 0.23 -> 0.24 and simple_logger 1.9 -> 2.1

* Reduce feature set in `image` dev-dependency
2022-02-17 14:13:32 +01:00
David Ackerman f93f2c158b
Bump versions of ndk to 0.6, ndk-sys to 0.3, ndk-glue to 0.6 (#2163) 2022-02-01 00:14:36 +01:00
Lucas Kent cf4660841a
Update to Rust 2021 Edition (#2114) 2022-01-13 06:59:57 +01:00
Artúr Kovács d3e6949007
Release 0.26.1 (#2125) 2022-01-05 15:38:59 +01:00
Artúr Kovács 6b250a74f8
Revert "Add composition event on macOS (#1979)" (#2119)
This reverts commit 8afeb910bd.

Reverting because this change made Pinyin input unusable
(only latin characters showed even after selecting the
desired Chinese character)
2022-01-02 22:01:51 +01:00
Kirill Chibisov ea1c031b54
Release 0.26.0 version 2021-12-01 14:43:38 +03:00
Mads Marquart 5eb9c9504b
Update `raw-window-handle` to `0.4.1` (#1957)
* Update raw-window-handle to `0.4.2`

See:
- https://github.com/rust-windowing/raw-window-handle/issues/72
- https://github.com/rust-windowing/raw-window-handle/pull/73
- https://github.com/rust-windowing/raw-window-handle/pull/74

* Clean up raw_window_handle functions a bit
2021-11-30 17:50:23 +01:00
Adrien Bennadji 29a078f65c
bump ndk dependencies to 0.5 (#2071) 2021-11-24 16:56:57 +01:00
Alphyr be61ca13fe
On X11, update 'mio' to 0.8 2021-11-20 03:42:23 +03:00
Markus Siglreithmaier cfbe8462cc
Windows: Increase wait timer resolution (#2007)
Windows: Increase wait timer resolution for more accurate timing when using `WaitUntil`.
2021-11-02 21:51:39 +01:00
Markus Siglreithmaier 5f4df54895
Android: Bump ndk/ndk-glue version (#2047) 2021-11-02 18:54:59 +01:00
Kirill Chibisov ed698f2462
On Wayland, add wayland-dlopen feature to use dlopen
While winit was always using dlopen for opening system libs, it
provides a way now to disable dlopen feature helping with linking
on some targets.

Fixes #2037.
2021-10-31 17:06:00 +03:00
Alexis Hildebrandt 9768f73bb7
Update smithay-client-toolkit
Fixes libxcbcommon linking on OpenBSD by using pkg-config when
building without dlopen feature. For details see [1].

[1] - https://github.com/Smithay/client-toolkit/pull/198
2021-10-30 22:35:36 +03:00