Commit graph

2949 commits

Author SHA1 Message Date
Kirill Chibisov b166e1ff13
On Wayland, make the CSD frame double click reliable
It was discovered that on GNOME the click sometimes being swallowed
by the mutter's `wl_pointer::enter/leave` sequences. This was happening
due to `xdg_toplevel::move` making the pointer to leave the surface.

To make handling of that more robust, we could start the
`xdg_toplevel::move` when the actual pointer motion is being performed.

Links: https://github.com/alacritty/alacritty/issues/7011
Links: https://gitlab.gnome.org/GNOME/mutter/-/issues/2669#note_1790825
2023-07-15 08:09:28 +00:00
Kirill Chibisov 97434d8d80
On macOS, add a way to query amount of tabbed windows
This should provide a way to iterate all the tabs and select the last
tab. The tab indicies are now zero based as any other sane index.

Follow-up-to: c5941d105f (add tabbing API)
2023-07-14 08:01:40 +00:00
Sam 06fb089633
On macOS, set that we prefer tabbing
Winit now supports tabbing identifiers, thus set that we prefer tabbing,
in particular it'll make windows tab when using the same tabbing identifiers,
which is desirable for the end users.
2023-07-14 04:14:04 +00:00
Kirill Chibisov 4d6dbea74c
On macOS, move automatic tabbing setting to ELWT
Those are global for the application, so it's better to keep them
on EventLoopWindowTarget.
2023-07-13 15:55:51 +00:00
Kirill Chibisov c5941d105f
On macOS, add tabbing APIs
This should let the users control macOS tabbing and allow to create
windows in tab.

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
2023-07-13 06:52:34 +00:00
daxpedda b63164645b
On Web, add WindowBuilderExtWebSys::with_append() (#2953) 2023-07-12 17:11:52 +02:00
daxpedda 5b5ebc25d8
Improve documentation of WindowBuilderExtWebSys methods (#2952) 2023-07-12 17:11:17 +02:00
John Nunley d7ec899d69
Replace parts of the Xlib backend with x11-rb 2023-07-12 07:59:12 +00:00
daxpedda 5379d60e4d
On Web, remove Window::is_dark_mode() (#2951) 2023-07-11 18:26:32 +02:00
daxpedda 44e2f95331
Fix mentions of Wasm (#2950) 2023-07-11 18:26:00 +02:00
daxpedda 3b2d1a7643
On Web, implement and fix missing methods on Window(Builder) (#2949) 2023-07-11 13:14:40 +02:00
daxpedda 50b17a3907
Add Fullscreen API compatibility for Safari (#2948) 2023-07-11 00:34:02 +02:00
daxpedda af26f01b95
On Web, cache commonly used values (#2947) 2023-07-11 00:11:06 +02:00
daxpedda c4d70d75c1
Increase accuracy of various Web APIs (#2946) 2023-07-10 23:55:43 +02:00
daxpedda db8de03142
Improve Web specific documentation for various APIs (#2941)
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
2023-07-10 12:50:28 +02:00
Kirill Chibisov ff0ce9d065
Rename Window::set_inner_size to Window::request_inner_size
Some systems could resize the window immediately and we'd rather
inform the users right away if that was the case, so they could
create e.g. EGLSurface without waiting for resize, which is really
important for Wayland.

Fixes #2868.
2023-07-10 04:02:26 +00:00
daxpedda 42e492cde8
Fix touch location accuracy (#2944) 2023-07-10 02:17:36 +02:00
daxpedda 5e0e1e96bc
On Web, implement WindowEvent::Occluded (#2940) 2023-07-10 02:02:38 +02:00
Imbris bd890e69aa
On X11, avoid false positive key repeats
Instead of a single `bool` indicating that a key press has occured and
no key has been released since then, we store the scancode of the last
pressed key (if it is a key that repeats when held). This fixes a bug
where pressing a new key while one is already held down will be flagged
as a repeat even though it is obviously not a repeat.
2023-07-09 17:05:49 +00:00
Mads Marquart bca57ed0b4
Stop using &mut in Objective-C delegate methods (#2925)
* Make iOS declared classes not use &mut

* Prepare `init` methods for not having access to &mut self

* Prepare WinitWindow methods for not having access to &mut self

* Convert a bit of WinitView's to use interior mutability

* Convert a bit more of WinitView's to use interior mutability

* Convert the rest of WinitView to use interior mutability

* Use interior mutability instead of a Mutex for the CursorState

* Use interior mutability in WinitWindowDelegate
2023-07-08 22:36:42 +03:00
daxpedda 4652d48105
Don't unnecessarily clone canvas on Web (#2934) 2023-07-08 17:05:05 +02:00
daxpedda 96c0b267e2
Fix typos on Web (#2933) 2023-07-08 16:47:31 +02:00
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
Kirill Chibisov a320702a71
On X11, fix IME not working
The change to xinput2 completely disabled IME support, thus we've got
a dead keys reporting, because nothing was eating the key events
anymore, however that's not what we really need, given that not
working IME makes it impossible for some users to type.

The proper solution is to not use Xlib at all for that and rely on
xcb and its tooling around the XIM and text compose stuff, so
we'll have full control over what is getting sent to the XIM/IC or not.

Fixes #2888.
2023-06-30 19:59:24 +04:00
dAxpeDDa b0106898f7 Don't allow event loops to run in parallel 2023-06-29 15:53:58 +02:00
Fredrik Fornwall 924f3323b5 On Web, map bfcache load/unload to suspend/resume 2023-06-28 15:38:49 +02:00
Kirill Chibisov b97df599c5 On Linux, fix wrong layout for key_without_modifiers
The layout was hardcoded to zero, so the keys were sent for whatever
user configured first.
2023-06-28 14:48:35 +04: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
Kirill Chibisov e23186db8e
Disallow cleanup for TLS in examples
Fixes issue on Wayland due to drop order, since TLS is being dropped
after the event loop, while it shouldn't. In particular it fixes the
crash in the window_run_return example.
2023-06-26 01:04:38 +04:00
Kirill Chibisov 059abb06fc
On Wayland, handle none decorations
During the migration some logic wrt `none` decorations was lost along
the way, however we also now try to ask for client side decorations if
the user wants to disable server side decorations.

Fixes #2902.
2023-06-25 14:12:12 +04: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 66ff52b012
On Wayland, fix transparency hint not set in new
Fixes #2894.
2023-06-22 00:21:43 +00:00
Robert Bragg 7929999c1c
Android: rework keycode handling (#2890)
The recent overhaul of the keyboard API broke keyboard input on Android.

The recent keyboard changes also broke building against the
game-activity backend of android-activity because it was assumed that
the backend is based on the NDK input API which isn't the case with
with game-activity since it doesn't use the InputQueue API from the NDK.

Any alphanumeric keycodes were being mapped to `Unidentified` Keys
which meant even crude keyboard input support was broken.

We do need to expose `getUnicodeChar` (or the ability to look
up characters based on the current character map and modifiers) but
for now we should at least map alphanumeric keycodes to `Key::Character`
for basic interim support of virtual keyboards.

This moves all the keycode mapping into a separate `keycodes.rs` file
to reduce clutter.

This adds back the mapping from Android key codes to Winit key codes
that we had before the keyboard API overhaul.

Android activity does expose scan codes but key codes currently seem
like the more appropriate mapping to Winit physical key codes.

This removes the gnarly, unsafe cfg() guarded digging into
'native-activity' and 'game-activity' specific implementation details. I
never intended to expose these details in the public API and really
hope to avoid there being a release of Winit that would depend on this.

I'm also hoping/considering if I can get away with sealing this without
necessarily requiring a semver breaking release of android_activity
since this absolutely should never have been possible, and can probably
safely assume this was the only code in the wild that has briefly done
this.

I'm also a bit unclear as to what led to doing this. There is a
`.key_code()` and `.scan_code()` getter and we even already accessed the
keycode in the Android backend so I'm not sure how those APIs were missed.
2023-06-21 19:49:44 +02: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
John Nunley b2a46d0439
Fill the windows in the examples with a solid color
Fixes #776.
2023-06-19 18:46:38 +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 a444637b18 Revert "Send modifiers first"
This reverts commit e17977d7c7.
2023-06-14 00:01:37 +02:00
daxpedda f0d88c52a3
Fix pointer deltas on Firefox and send coalesced events together (#2878) 2023-06-13 15:49:27 +02:00
dAxpeDDa e17977d7c7 Send modifiers first 2023-06-13 14:33:08 +02:00
dAxpeDDa a7a8ff0bbb Drop pointerrawupdate support 2023-06-13 10:23:48 +02:00
dAxpeDDa fc046add78 Resume propagation of events 2023-06-12 00:48:14 +02:00
dAxpeDDa ab4a4a89e6 Remove unused EventListenerOptions 2023-06-11 19:44:52 +02:00
dAxpeDDa f7a400ddf6 Improve media queries take 2 2023-06-09 20:38:54 +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