Commit graph

752 commits

Author SHA1 Message Date
StarStarJ 81fd39485f
Implement PartialOrd/Ord for KeyCode/NativeKeyCode 2023-07-01 19:07:35 +04: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
Josh Groves bc216b8f67
Allow recreating wasm event loop with spawn (#2897) 2023-06-23 19:31:42 +02:00
Josh Groves 864a1d5924
Fix some typos (#2901) 2023-06-23 10:10:36 +03:00
Kirill Chibisov 05444628e6
Provide a way to set cursor area for IME cursor
Rename `Window::set_ime_position` to `Window::set_ime_cursor_area`
adding a way to create cursor exclusive zone.

Fixes #2886.
2023-06-22 19:12:14 +00:00
Kirill Chibisov 7094a223af
Bring OptionAsAlt back for macOS
The correct handling of this setting requires to change the events
we're getting from the macOS on the fly and call `interpretKeyEvents`,
which could affect handling of the next events, meaning that we can't
provide them on `KeyEvent`.
2023-06-20 19:07:49 +00:00
bbb651 4748890935
Add MouseButton::{Back, Forward} to MouseInput
Add named variants for physical back and forward keys which could
be found on some mice. The macOS bits may not work on all the
hardware given that apple doesn't directly support such a thing.

Co-authored-by: daxpedda <daxpedda@gmail.com>
2023-06-16 08:51:09 +00:00
daxpedda 6300cf915e
On Web, implement DeviceEvents (#2871) 2023-06-14 10:26:26 +02: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 7ce86c3d2a Use Window.requestIdleCallback() 2023-06-14 00:03:23 +02:00
dAxpeDDa a7a8ff0bbb Drop pointerrawupdate support 2023-06-13 10:23:48 +02:00
Xiaopeng Li 07d39abddd
Fix panic when destroying window (#2773)
* Fix crash when destroying window

* Add a comment to draw_rect

---------

Co-authored-by: Xiaopeng Li <lixiaopeng.jetspark@bytedance.com>
2023-06-09 16:20:27 +03:00
dAxpeDDa b5785ba785 Revert "Fix Window::set_inner_size()"
This reverts commit e220a75556.
2023-06-08 09:09:46 +02:00
dAxpeDDa 9797ed86f0 Fix unable to ignore scale factor resize suggestion 2023-06-07 22:46:14 +02:00
dAxpeDDa e220a75556 Fix Window::set_inner_size() 2023-06-07 14:53:59 +02:00
Robin Thunström 4a36741f9c
On Android, change default implementation to ignore volume keys and let operating system handle them (#2748) 2023-06-06 23:04:51 +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 c88a4ab221 Use correct canvas size for scale factor change 2023-06-05 15:39:17 +02:00
daxpedda 8f7f3efc0d
On Web, implement Send and Sync where appropriate (#2834) 2023-06-05 02:44:54 +02:00
dAxpeDDa 3f4f580181 Add pointerrawupdate support 2023-06-05 02:04:37 +02:00
dAxpeDDa 964e342f69 Prevent text selection 2023-06-05 02:04:37 +02:00
dAxpeDDa a134a59917 Remove MouseEvent fallback support 2023-06-05 02:04:37 +02:00
dAxpeDDa fbba203c4a Focus window on touch press 2023-06-05 02:04:37 +02:00
dAxpeDDa 61bd8b8254 Send position on button release 2023-06-05 02:04:37 +02:00
dAxpeDDa 7500a88230 Fix up changelog 2023-06-04 13:45:43 +02:00
dAxpeDDa 82d0380ea6 Ignore pen input on Web 2023-06-04 00:23:47 +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
dAxpeDDa 4f3eacf01e On Web, handle coalesced events 2023-06-02 18:48:34 +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 d273518ce9 Process pointer button events 2023-06-02 12:41:35 +02:00
dAxpeDDa ba5ad3be13 On Web, fix no-op for Window::set_fullscreen 2023-05-31 15:25:15 +02:00
dAxpeDDa 8092fa2440 Fix changelog 2023-05-31 13:47:34 +02:00
Toniman575 8bb004a1d9
Rename DeviceEventFilter to DeviceEvents
The use of `Filter` was confusing so it was removed inverting the 
behavior of the enum and methods using it.

Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
2023-05-30 22:32:31 +03:00
Simon Hausmann de5327477a web: Fix position of touch events to be relative to the canvas
Use the same logic as for mouse events when not captured.
2023-05-30 21:21:41 +02:00
dAxpeDDa 1805124c54 On Web, wake event loop on request_redraw() 2023-05-28 23:22:08 +02:00
dAxpeDDa 0f64589dba Don't change the internal canvas size 2023-05-28 23:10:33 +02: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
John Nunley 3c3be71a77
Implement PartialOrd/Ord for dpi module types 2023-05-16 05:11:43 +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 a9e168e10d
On macOS, fix backspace emission on preedit clear
Fixes: d15feb5cfa (On macOS, fix empty marked text)
2023-05-13 03:02:05 +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
Xiaopeng Li 92592ec605
Fix device description leak (#2758)
* Fix device description leak

* Update CHANGELOG.md

---------

Co-authored-by: Xiaopeng Li <lixiaopeng.jetspark@bytedance.com>
2023-05-08 17:58:34 +03:00
Kirill Chibisov 25c4e2e451
On macOS, fix key_up being ignored without IME
Fixes: d15feb5cfa (On macOS, fix empty marked text)
2023-05-06 14:05:28 +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 d15feb5cfa On macOS, fix empty marked text blocking input
Fixes #2775.
2023-05-04 00:24:02 +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
Amandus Søve Thorsrud 60e91b187a
Run Window::set_ime_position on main thread on macOS
Fixes #2756.
2023-04-15 02:58:36 +03:00
Xiaopeng Li 2486f0f1a1
Fix potential panic (#2755)
* Fix potential panic

* Update CHANGELOG.md

* Use checked_div

---------

Co-authored-by: Xiaopeng Li <lixiaopeng.jetspark@bytedance.com>
2023-04-03 21:46:09 +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
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
Dylan Scott 79ac236721
On macOS, resize simple fullscreen on window move
Fixes #1118.
2023-03-02 01:47:45 +03:00
Nicolas Mazzon b870a11a99
On Windows, check whether CoCreateInstance succeeds 2023-03-02 01:24:04 +03:00
Kirill Chibisov 2af1550bbb
On macOS, fix initial focused state
The synthetic focused event was queued after the real event was send
leading to focused issues on startup.

Fixes #2695.
2023-02-27 20:46:00 +03:00
Kirill Chibisov a006cd7dc8
On Wayland, fix rounding issue in resizes 2023-02-21 11:44:22 +03:00
Simon Hausmann a31f71ee07
Add support for Window::theme on the web (#2687) 2023-02-20 08:51:21 +01:00
Kirill Chibisov 0f89aac9f6
On Wayland, fix rare crash on DPI change
While I don't understand the root cause for this issue, we can
dirty fix like that for now.
2023-02-19 17:39:39 +03:00
Kirill Chibisov 82df9531f4
On macOS, set resize increments only for live resize
Closes #2684 for macOS.
2023-02-15 03:32:55 +03:00
Sludge 265152355e
Implement HasRawDisplayHandle for EventLoop (#2677)
* Implement `HasRawDisplayHandle` for `EventLoop`

* Add changelog entry
2023-02-10 16:25:22 +01: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 7029ce6ecd
Fix window drop on Wayland
In some scenarious of window dropping the callback for keyboard
may run after the window was dropped.
2023-02-02 14:42:34 +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
Kirill Chibisov 3fd73848dd
On macOS, fix Ime::Commit persisting
This commit clears the currently marked text on `Ime::Commit`, so
normal `ReceivedCharacter` input can continue.
2023-02-01 18:08:25 +03:00
Jack Wright 180a4c7a16
Add WindowExtMacOS::{set_,}option_as_alt
This adds an ability to control left and right `Option` keys to be
treated as `Alt`, thus not producing diacritical marks.

Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
2023-01-31 12:35:49 +03:00
Lukas Lihotzki 1b4045dcb2
Add Window::set_ime_purpose
This adds a way to set the purpose for the IME input, implemented
only on Wayland for now.
2023-01-29 18:46:46 +03:00
Markus Siglreithmaier 23b821285c
On Windows, fix window size for maximized, undecorated windows (#2584)
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
2023-01-28 14:04:47 +01:00
Shane Pearman 422c6b1987
Allow introspection of WindowBuilder attributes
Makes WindowAttributes public and adds window_attributes() getter to
WindowBuilder.

In version 0.27, the WindowAttributes struct was made private, but this
removed the ability to introspect the default WindowBuilder values.
2023-01-27 08:38:56 +03:00
Amr Bashir b457329003
Add WindowBuilder::with_active
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
2023-01-27 08:08:29 +03:00
Jim Eckerlein d448d3e14f
Add smart magnify gesture support for macOS (#2554)
* Add smart magnification gesture

* Deliver position of smart magnification event

* Document smart magnification event

* Revert "Deliver position of smart magnification event"

This reverts commit ac0e61a9a4e67bf54fc80230660051d366846bd4.

* Remove mention of touchpad from smart magnification event

* Update change log

* Mention minimum macOS version supporting smart magnification

* Improve doc
2023-01-21 17:35:07 +01:00
Andreas Reich a867032e1e
[MacOS] Fix deadlock on maximizing window from event callback (#2636) 2023-01-21 17:29:29 +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
Amr Bashir 809162fbd0
Add Window::is_minimized
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>
2023-01-20 00:39:04 +03: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
Roman Akberov 1886949efe
On macOS, fix middle/other mouse buttons reporting
All buttons except for the left/right/middle was always reported
as middle.
2023-01-18 06:32:34 +03:00
Kirill Chibisov b1a5fae1f5
On X11, fix errors bleeding from hooks handling them
This commit fixes it, by not updating the `latest_error` when
any of the hooks handled the error, otherwise it'd interfere
with the winit's error checking.
2023-01-18 05:58:09 +03:00
Amr Bashir a88d2e079d
On Windows and MacOS, add Window::has_focus 2023-01-17 04:30:14 +03:00
Amr Bashir 067535eb38
Fix Window::set_minimized(false) on Windows
When other application minimized the winit window the
minimize state was going out of sync. This commit fixes
it by polling the state in `set_minimized`.
2023-01-17 03:22:52 +03:00
John Nunley 7d626d9dfd
Add a function for waiting on a Duration 2023-01-16 04:14:09 +03:00
Kirill Chibisov 62ce14a013
Add Window::set_transparent
Provide a hint to system compositor whether the window is transparent or
not. Only implemented on macOS and Wayland for now.
2023-01-15 23:39:36 +03:00
Michael Murphy 9225b2812e
feat(x11): Add Window::drag_resize_window (#2515) 2023-01-11 10:07:09 -07:00
John Nunley 490abcad14
Remove xlib_xconnection from public interface 2023-01-10 11:46:48 +03: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
Kirill Chibisov 2f52c23fa9
Fix RedrawRequested not emitted on Wayland in resize
Fixes #2609.
2022-12-29 21:06:46 +03:00
Alphyr 58ec458877
Remove compatibility shim for raw-window-handle 0.4 2022-12-24 15:53:46 +03:00
Ryo Hirayama f43ce2a131
Web touch event (#2188)
* feat: add pointer events to web

* feat: remove PointerType for touch events

* Remove duplicate

* Changelog and features

* Remove PointerType

* feat: renamed events, added touch type guard

* Rename

* Flip the y axis

* Fix physical position and add force

* Update comment

* Update features

* Use normalized force

* Remove unnecessary todos

* Update comment

* Refactor add touch_handler

* Rephrase by Liamolucko

* Update CHANGELOG.md

* Fix duplicate mouse and touch events

* Removed workaround for scale factor

* Flip the y axis

* Fix

* Fmt

* Replace `match` with a single pattern with `if let`

* Update documentation

* Have one callback per event

* Remove a comment

* Fix

* Remove y-axis flip

* Update src/event.rs

Co-authored-by: Mads Marquart <mads@marquart.dk>

* Fix platform specific comment

* Fix extra argument to `touch_position` function

Co-authored-by: Dany Sluijk <me@dany.dev>
Co-authored-by: Johan Klokkhammer Helsing <johanhelsing@gmail.com>
Co-authored-by: oscrim <oscar@widefind.se>
Co-authored-by: Mads Marquart <mads@marquart.dk>
2022-12-23 06:55:22 +01:00
Ngo Iok Ui (Wu Yu Wei) da7422c6e1
Add WindowBuilder::with_parent_window (#2548)
* On macOS, add `WindowBuilderExtMacOS::with_parent_window`

* Replace Parent with Option<Id<NSWindow, Shared>>

* Add addChildWindow method on NSWindow instead

* Update with_parent_window to be unsafe fn

* Add unified `with_parent_window`

* Remove `WindowBuilderExtUnix::with_parent`

* Remove `WindowBuilderExtWindows::with_parent_window`

* Clean up CI warnings

* Update CHANGELOG.md

It's `WindowBuilderExtX11` rather than `WindowBuilderExtUnix`

* Rename parent to owner

* Make with_parent_window unsafe and update its doc

* Add another way to get window on mac

* Add more documentations

* Add match arm and panic on invalid varients

* Add Xcb arm

* Update child_window example to make it safer and work in i686

* Remove duplicate entry in CHANGELOG.md

* Propogate error instead of expect

* Replace unreachable to panic

* Add platform note to X11

Co-authored-by: Wu Yu Wei <wusyong9104@gmail.com>
2022-12-22 01:07:13 +01:00
Amr Bashir 89eea64a4a
Retain WS_MAXIMZE when unminmizing a maximized window (#2581)
Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>
2022-12-09 19:33:11 +01:00
feelingnothing 9f781bc422
On Windows, fix left mouse button release event not being sent after Window::drag_window (#2564) 2022-12-06 23:18:50 +01:00
Mads Marquart bf92f3e97b
macOS: Run tasks synchronously on main thread instead of asynchronously (#2574)
* Close windows synchronously on main thread

* Set style mask synchronously on main thread

* Set title synchronously on main thread

* Set visibility and focus synchronously on main thread

* Set window level synchronously on main thread

* Set position and size synchronously on main thread

* Set cursor hittest synchronously on main thread

* Add changelog entry
2022-11-30 14:30:32 +01:00
Xiaopeng Li 32784af3c4
Don't panic when getting refresh rate failed (#2533)
This fixes a crash on macOS when trying to get the monitor
refresh rate from the disabled monitor.

Co-authored-by: Jet Spark <lixiaopeng.jetspark@bytedance.com>
Co-authored-by: Mads Marquart <mads@marquart.dk>
2022-11-29 11:28:46 +01:00
Amr Bashir 94688a62f0
On Windows and macOS, add API to enable/disable window controls (#2537)
* On Windows and macOS, add API to enable/disable window controls

* fix build

* missing import

* use `WindowButtons` flags

* rename to `[set_]enabled_buttons`

* add example, fix windows impl for minimize

* macOS: Fix button enabling close/minimize while disabling maximized

* Update src/platform_impl/windows/window.rs

Co-authored-by: Kirill Chibisov <contact@kchibisov.com>

* compose the flags on a sep line, use `bool::then`

Co-authored-by: Mads Marquart <mads@marquart.dk>
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
2022-11-29 11:03:51 +01:00
Amr Bashir 28e34c2e1b
Add Window::set_theme (#2553)
* Add `Window::set_theme`

* typo

* fix linux build

* fix wayland

* review changes

* update docs

* update changelog

* pin `image` dep

* suppport falling back to system default

* fix linux

* default to dark on macOS and x11

* fix `setAppearance` definition

* add macOS notes

* update docs

* Update CHANGELOG.md

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

* update doc

* Revert "pin `image` dep"

This reverts commit 7517f7c5065b4089ca146ce8799dab445ec32068.

* Update theme example with Window::set_theme

* Fix Window::theme getter on macOS

Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>
Co-authored-by: Mads Marquart <mads@marquart.dk>
2022-11-29 10:05:51 +01:00
Fotis Gimian 9ae7498a8a
On Windows, revert window background to an empty brush to avoid white flashes when changing scaling (#2571) 2022-11-27 22:28:14 +01:00
Amr Bashir 101ac8908c
Add Window::set_window_level API
This adds `Window::set_window_level` to control the preferred
z level of the window.

Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
Co-authored-by: Mads Marquart <mads@marquart.dk>
2022-11-26 04:50:58 +03:00
Mads Marquart a63b066ed5
Fix MouseButton::Other value on Windows (#2565)
This was a mistake in the transition to windows-sys: https://github.com/rust-windowing/winit/pull/2057

We used winapi's GET_XBUTTON_WPARAM before which is using HIWORD instead of LOWORD: https://docs.rs/winapi/0.3.9/src/winapi/um/winuser.rs.html#1297-1299
2022-11-23 16:43:56 +01:00