Commit graph

2805 commits

Author SHA1 Message Date
Francesca Lovebloom e423802ed3
Remove francesca64 from CODEOWNERS (#2644) 2023-01-23 09:56:09 +01:00
Mads Marquart a82f66826b
Use a bit less unsafe on iOS (#2643)
* Use a bit less `unsafe` on iOS

I did test this in XCode 11.3's "Debug View Heirarchy", the NSStringRust problem is no longer applicable (likely because Rust got better at emitting correct debug info).

* Avoid using `id` on iOS
2023-01-23 00:01:45 +01:00
Mads Marquart 0f2fbe373b
Simplify event queuing on macOS (#2642) 2023-01-22 23:29:38 +01:00
Mads Marquart 7341ee80ea
Note the status quo on RedrawRequested (#2641)
And link to https://github.com/rust-windowing/winit/issues/2640
2023-01-21 18:56:58 +01: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
Mads Marquart 6f60c7a6cc
Note the macOS and Windows versions that winit supports 2023-01-15 23:18:23 +03:00
Turki Jamaan 6cf0bf76da
iOS: fix accidentally flipped assertion (#2629)
* iOS: fix accidentally flipped assertion

* No need to update the changelog
2023-01-13 23:40:24 +01:00
Michael Murphy 9225b2812e
feat(x11): Add Window::drag_resize_window (#2515) 2023-01-11 10:07:09 -07: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 490abcad14
Remove xlib_xconnection from public interface 2023-01-10 11:46:48 +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
Kirill Chibisov 2f52c23fa9
Fix RedrawRequested not emitted on Wayland in resize
Fixes #2609.
2022-12-29 21:06:46 +03:00
Mads Marquart ee88e38f13
Reduce amount of unsafe on iOS (#2579)
* Use objc2::foundation CG types

* Add safe abstraction over UIApplication

* Add safe abstraction over UIDevice

* Add safe abstraction over UIScreen

* Add safe abstraction over UIWindow

* Add safe abstraction over UIViewController

* Add safe abstraction over UIView

* Appease clippy
2022-12-28 18:36:32 +01: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
Miguel Medina Ballesteros 94e4c394e7
Swap assert by debug_assert for recovereable issue. Fixes #2597 (#2599)
* Swap assert by debug_assert for recovereable issue

* Remove debug assert completely
2022-12-23 14:19:25 +01: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
Amr Bashir 402cbd55f9
fix unnecessary cast lint (#2596)
* fix clippy lints on Windows

* fix lints on other platforms

* a couple more

* again

* don't know what's goging on anymore

* fix examples

* comon

* how about now?

* this is getting annoying

* hmmm

* explicitly set a type

* 😢

* don't cast on x64 targets

* apply code review requests

* fix attributes on expressions

* fix ios
2022-12-22 20:35:33 +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 8934d2765d
Add missing closing parentheses (#2587) 2022-12-11 03:29:19 +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 4ed4e918f3
Clean up UIView override declaration (#2578) 2022-12-01 09:32:44 +01:00
Mads Marquart 2e4d79f57a
Do fullscreen logic synchronously on main thread (#2575) 2022-11-30 14:49:18 +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
Mads Marquart 2a58b785fe
Refactor SharedState so that it is no longer behind an Arc (#2573)
* Refactor SharedState so that it is no longer behind an Arc

* Always use `Window::lock_shared_state`
2022-11-29 12:58:35 +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
Robert Bragg 1786c877ec
android: depend on android-activity 0.4.0 (#2557) 2022-11-26 11:54:08 +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
Marijn Suijten ba4bf03675
ci: Specify to build winit package when invoking cargo-apk (#2561)
* ci: Don't use `$CMD` for Android doc building

Since migrating `cargo-apk` to `clap` [it is now annoying] to pass
unknown arguments to an underlying `cargo` command (like `cargo doc`):
fortunately generating docs doesn't need to go through `cargo apk` to
set up cross-compiler/linker environment variables at all.

[it is now annoying]: https://github.com/rust-windowing/android-ndk-rs/pull/363

* ci: Simplify

* ci: Explicitly build just the `winit` package on Android

Since https://github.com/dvc94ch/cargo-subcommand/pull/23 `cargo-apk`
now strictly searches for workspaces first before committing to finding
the right package _within said workspace_, and bails when no package was
selected since we don't support selecting (building, packaging, running)
>1 target currently.

Perhaps it's a bit hash to enforce this on free-form `cargo apk --`
invocations, but it is what it is.
2022-11-24 21:49:47 +01: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
Amr Bashir f77f858e9b
On macOS, add documentEdited APIs (#2550)
* On macOS, add documentEdited APIs

Port of 33fdeab629

* Update src/platform/macos.rs

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

* typo

Co-authored-by: Mads Marquart <mads@marquart.dk>
2022-11-23 16:07:41 +01:00
Mads Marquart 6d0cf6a275
Remove WindowBuilderExtIOS::with_root_view_class (#2459) 2022-11-23 15:53:06 +01:00
Mads Marquart 12df8b6c0c
macOS: Fix ApplicationDelegate::init (#2566) 2022-11-23 15:23:06 +01:00
Amr Bashir 65baae75c4
Add Window::set_content_protected on macOS and Windows (#2525)
* Add `Window::set_content_protect` on macOS and Windows

* Update window.rs

* Add builder variant

* fix import

* fix argument type

* fix import

* fix always visible window on Windows

* update docs
2022-11-23 14:51:34 +01:00
Amr Bashir 418cc44e93
On macOS, add EventLoopBuilderExtMacOS::with_activate_ignoring_other_apps (#2551)
* On macOS,  add `EventLoopBuilderExtMacOS::with_activate_ignoring_other_apps`

* Update src/platform/macos.rs

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

* remove todo

Co-authored-by: Mads Marquart <mads@marquart.dk>
2022-11-23 13:42:46 +01:00