Commit graph

614 commits

Author SHA1 Message Date
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
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
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
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
Amr Bashir 08f9e374e0
Add Window::title getter on Windows and macOS 2022-11-03 20:11:37 +03: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
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 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 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
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 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 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
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
Weng Xuetian 92ddb3483e
Clear preedit if there is no pending preedit on Wayland
Fixes #2478.
2022-09-09 10:53:58 +03: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 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
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
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
Kirill Chibisov b3b80166ce
Mark new events as breaking change
Adding a new enum variant is a breaking change in winit.
2022-08-24 16:33:58 +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
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 2e4338bb8d
Release 0.27.2 version 2022-08-12 14:39:44 +04: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