Commit graph

1932 commits

Author SHA1 Message Date
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
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 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
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 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
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
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
Mads Marquart ce6c6e8c95
Only build, but don't run tests in MSRV CI (#2558)
* Only build, but don't run tests in MSRV CI

Since the MSRV of development dependencies can easily be bumped without it affecting the MSRV of the published version of `winit`

* Run clippy on stable Rust instead of MSRV Rust

clippy inspects the `rust-version` field, and only suggests changes that conform to that.
2022-11-23 13:07:58 +01:00
Mads Marquart bdcbd7d1f9
macOS: Fix NSWindowLevel values (#2545)
* Fix NSWindowLevel values

* Fix formatting
2022-11-22 11:08:56 +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
Amr Bashir 50bbc85dc3
On Windows, fix icons specified on WindowBuilder not taking effect for windows created after the first one (#2530) 2022-11-06 21:30:55 +01:00
Xiaopeng Li 8669c2e8df
On macOS, fix panic in current_monitor_inner 2022-11-05 05:30:39 +03:00
Mads Marquart 97d4c7b303
macOS: Fix overridden fullscreen selectors (#2546) 2022-11-03 22:33:38 +01:00
Amr Bashir 08f9e374e0
Add Window::title getter on Windows and macOS 2022-11-03 20:11:37 +03:00
Ihor Ranchynskyi a7a7cc64cd
Bump windows-sys to 0.42 (#2540) 2022-10-31 23:19:45 +01:00
i509VCB 8fc24c959a
Generate docs.rs documentation with doc_auto_cfg (#2358) 2022-10-25 00:02:52 +02:00
Amr Bashir 2fb15dbe8a
Fix menubar focus using Alt on Windows (#2521) 2022-10-20 17:59:12 +02:00
keiya sasaki 92fdf5ba85
Rework theme API
This commit adds support for theming on macOS and
also unifies the system theme handling across platforms.
2022-10-18 21:34:36 +03:00
Kirill Chibisov 4f06cfcf5b
On Wayland, fix invalid offsets being sent in Preedit
Even when the protocol explicitly tells to send proper UTF-8
boundaries for cursor, some IMEs don't do that, so sanity check
them before sending downstream.
2022-10-18 17:13:31 +03:00
Kirill Chibisov f6ca8515ab
On X11, fix IME crashing during reload
During reload we were picking old styles, but the styles could
change during reload leading to errors during IME building.

Fixes #2510.
2022-10-10 00:13:37 +03:00
Shinichi Tanaka 71094e5703
On X11, allow building window with parent 2022-10-09 23:12:23 +03:00
Markus Siglreithmaier 4d48c76da9
Windows, emit ReceivedCharacter on system keybinds
Currently needed for downstream users relaying on `ReceivedCharacter` for implementing
keybindings.
2022-10-08 06:32:40 +03:00
Mads Marquart fafdedfb7d
Simplify internal type construction 2022-09-21 11:04:28 +03:00
killian 25b129362f
On Windows, fixed focus event emission on minimize. 2022-09-20 20:26:37 +02:00
Mads Marquart 48b843e42d Accepts first mouse (#2457)
* MacOS: set value for `accepts_first_mouse`

* Update CHANGELOG and FEATURES

* Field doesn't need to be public

* Convert `bool` to `BOOL`

* Fix formatting

* Move flag from window state to view instance

* Feedback from PR

* Fix changelog location
2022-09-13 21:11:18 +02:00
Kirill Chibisov 155f1f9720
On X11 query for XIM styles before creating IME
Fixes #2448.
2022-09-11 19:36:56 +03:00
Kirill Chibisov 5d2aca90bd
Send empty Ime::Preedit before the Ime::Commit
This should help downstream to automatically clear it.
2022-09-11 00:48:24 +03:00
Weng Xuetian 92ddb3483e
Clear preedit if there is no pending preedit on Wayland
Fixes #2478.
2022-09-09 10:53:58 +03:00
Mads Marquart fec52b028e
Fix runloop entry (#2480)
Introduced in https://github.com/rust-windowing/winit/pull/2479; turns out the definitions were not entirely equal, the `kCFRunLoopEntry` that we were using previously was defined as `0` while the correct value is `1` (which meant the `unimplemented!()` branch suddenly started triggering)
2022-09-08 21:56:53 +02: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 da7bf8e29b
macOS: Fix WindowBuilder::with_resize_increments (#2477)
Introduced in https://github.com/rust-windowing/winit/pull/2411
2022-09-08 18:54:22 +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 0fca8b088d
WindowBuilderExtWebSys::with_prevent_default disables scrolling on both mobile and desktop (previously just desktop) (#2216)
* Disable scrolling on web by default but provide method in builder to enable it

* rename enable_web_scroll -> enable_web_page_scroll

* move enable_web_page_scroll into prevent_default option

* final approach

* Mark prevent_default change as breaking

Co-authored-by: Mads Marquart <mads@marquart.dk>
2022-09-04 05:45:30 +02:00
Anton Bulakh ab56e9f57d
Allow changing resize increments after window creation 2022-09-03 21:50:22 +03:00
Mads Marquart 29419d6c38
Refactor macOS cursor code (#2463) 2022-09-02 21:02:40 +02:00
Mads Marquart e517e468f8
Fix declare_class! indentation (#2461)
* Fix NSWindow delegate indentation

* Fix NSView delegate indentation
2022-09-02 19:38:32 +02:00
Mads Marquart d67c928120
Clean up macOS class declaration (#2458)
* Begin abstraction over AppKit

* Clean up NSApplication delegate declaration

* Clean up NSApplication override declaration

* Clean up NSWindow delegate declaration

* Clean up NSWindow override declaration

* Clean up NSView delegate declaration
2022-09-02 18:46:18 +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 1ca8b65e85
Split platform::unix into platform::x11 and platform::wayland
This also removes deprecated `WindowExtUnix::is_ready`.
2022-09-01 08:05:32 +03:00
Mads Marquart a43a15b4a0
iOS: Fix a few instances of UB (#2428)
* Fix iOS 32-bit

* Fix a few invalid message sends on iOS
2022-09-01 03:10:00 +02:00
ajtribick dfecdc5762
Windows: Update handling of system keypresses (#2445)
- Pass WM_SYSKEYDOWN to DefWindowProc
- Avoid intercepting WM_SYSCHAR to allow ALT+Space to work: removes ReceivedCharacter events for alt+keypress
- Intercept WM_MENUCHAR to disable bell sound
2022-09-01 00:03:48 +02:00
Mads Marquart 8729119536
Remove parking_lot dependency (#2423) 2022-08-31 18:32:19 +02:00
daxpedda ec7e935248
Document WindowEvent::Moved OS support (#2442) 2022-08-31 06:57:37 +02:00
Alex Butler e91ee811cb
Use sctk-adwaita 0.5.1 auto theme selection
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
2022-08-24 23:43:36 +03:00
Sludge 0d9c39029c
Document WindowEvent::Moved as unsupported on Wayland 2022-08-20 00:32:40 +03:00
Joonas Satka da2cef97a3
Add touchpad magnify and rotate gestures support for macOS (#2157)
* Add touchpad magnify support for macOS

* Add touchpad rotate support for macOS

* Add macOS rotate and magnify gesture cancelled phases

* Correct docs for TouchpadRotate event

* Fix tracing macros
2022-08-16 17:20:06 +02:00
Markus Siglreithmaier 76f158d310
On Windows, improve support for undecorated windows (#2419) 2022-08-15 02:36:37 +02:00
Kirill Chibisov ec2888b8b7
On Wayland, fix Window::request_redraw being delayed
On Waylnad when asking for redraw before `MainEventsCleared`
would result for redraw being send on the next event loop tick,
which is not expectable given that it must be delivered on the same
event loop tick.
2022-08-12 11:54:02 +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
ajtribick 9b71df9f97
On Windows, add opt-in function for device events (#2409) 2022-08-11 15:17:46 +02:00
Mads Marquart b1c9e4a6fa Fix tracking of phase changes for mousewheel on trackpad (#2158) 2022-08-10 18:28:19 +02:00
Anton Bulakh cdbaf4816a
On X11, fix window hints not persisting
This commit fixes the issue with min, max, and resize increments
not persisting across the dpi changes.
2022-08-08 18:27:11 +04:00
Amr Bashir 6b7ceedc91
Windows: respect min/max sizes when creating the window (#2393) 2022-08-04 23:03:55 +02:00
Kirill Chibisov 95246d81c1
On X11, fix crash when can't disable IME
Fixes #2402.
2022-07-30 17:15:57 +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
Robert Bragg 6cdb3179c8
Consistently deliver a Resumed event on all platforms
To be more consistent with mobile platforms this updates the Windows,
macOS, Wayland, X11 and Web backends to all emit a Resumed event
immediately after the initial `NewEvents(StartCause::Init)` event.

The documentation for Suspended and Resumed has also been updated
to provide general recommendations for how to handle Suspended and
Resumed events in portable applications as well as providing
Android and iOS specific details.

This consistency makes it possible to write applications that lazily
initialize their graphics state when the application resumes without
any platform-specific knowledge. Previously, applications that wanted
to run on Android and other systems would have to maintain two,
mutually-exclusive, initialization paths.

Note: This patch does nothing to guarantee that Suspended events will
be delivered. It's still reasonable to say that most OSs without a
formal lifecycle for applications will simply never "suspend" your
application. There are currently no known portability issues caused
by not delivering `Suspended` events consistently and technically
it's not possible to guarantee the delivery of `Suspended` events if
the OS doesn't define an application lifecycle. (app can always be
terminated without any kind of clean up notification on most
non-mobile OSs)

Fixes #2185.

Co-authored-by: Marijn Suijten <marijns95@gmail.com>
Co-authored-by: Markus Røyset <maroider@protonmail.com>
2022-07-26 16:03:12 +03:00
Kirill Chibisov 4fd52af682
Fix type hint reference for xlib hook 2022-07-26 16:02:09 +03:00
Amr Bashir 08d025968e
Fix hiding a maximized window On Windows (#2336) 2022-07-23 14:23:58 +02:00
Amr Bashir 1cd0e94c26
Windows: apply skip taskbar state when taskbar is restarted (#2380) 2022-07-22 19:33:22 +02:00
Kirill Chibisov 1ec976f95e
Add method to hook xlib error handler
This should help glutin to handle errors coming from GLX
and offer multithreading support in a safe way.

Fixes #2378.
2022-07-22 20:21:28 +03:00
Kirill Chibisov f10ef5f331
On macOS, fix confirmed character inserted
When confirming input in e.g. Korean IME or using characters like
`+` winit was sending those twice, once via `Ime::Commit` and the
other one via `ReceivedCharacter`, since those events weren't generating
any `Ime::Preedit` and were forwarded due to `do_command_by_selector`.
2022-07-21 22:23:22 +03: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
Rodrigo Batista de Moraes 3e991e13dc
Android: avoid deadlocks while handling UserEvent (#2343)
Replace `Arc<Mutex<VecDeque<T>>` by `mpsc`
2022-07-20 19:52:36 +02:00
Markus Røyset 5397b53e04
Tidy up "platform-specifc" doc sections (#2356)
* Tidy up "platform-specific" doc sections

* Unrelated grammatical fix

* Subjective improvements
2022-07-20 13:45:12 +02: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
Josh Groves 430a49ebc2
Fix typos (#2375) 2022-07-15 18:32:12 +02:00
Steve Wooster 1091a8ba1a
Make winit focus take activity into account on Windows (#2159)
winit's notion of "focus" is very simple; you're either focused or not.
However, Windows has both notions of focused window and active window
and paying attention only to WM_SETFOCUS/WM_KILLFOCUS can cause a window
to believe the user is interacting with it when they're not. (this
manifests when a user switches to another application between when a
winit application starts and it creates its first window)
2022-07-15 10:27:27 +02:00
Josh Groves 9116b6c8cd
windows: Use correct value for mouse wheel delta (#2374) 2022-07-14 22:00:22 +02:00
Josh Groves 990e34a129
web: add with_prevent_default, with_focusable (#2365)
* web: add `with_prevent_default`, `with_focusable`

`with_prevent_default` controls whether `event.preventDefault` is called

`with_focusable` controls whether `tabindex` is added

Fixes #1768

* Remove extra space from CHANGELOG
2022-07-14 17:52:31 +02: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
Liam Murphy aa8f8db305
web: Add EventLoop::spawn (#2208)
* web: Add `EventLoop::spawn`

This is the same as `EventLoop::run`, but doesn't throw an exception in order to return `!`.

I decided to name it `spawn` rather than `run_web` because I think that's more descriptive, but I'm happy to change it to `run_web`.

Resolves #1714

* Update src/platform/web.rs

Co-authored-by: Markus Røyset <maroider@protonmail.com>

* Fix outdated names

Co-authored-by: Markus Røyset <maroider@protonmail.com>
2022-07-13 17:17:18 +02:00
Lucas Kent cdd9b1e1eb
web: Manually emit focused event on mouse click (#2202)
* Manually emit focused event on mouse click

* Update CHANGELOG.md

Co-authored-by: Markus Røyset <maroider@protonmail.com>

Co-authored-by: Markus Røyset <maroider@protonmail.com>
2022-07-13 00:46:15 +02:00
Kirill Chibisov 2d2ce70edc
On Wayland, drop wl_surface on window close 2022-07-09 21:41:18 +03:00