* Remove window subclassing
* Always call `DefWindowProcW` when we don't process a message
* Improve window initialization
Note that the error path in `init` is kind of cursed at the moment.
* Rename `ThreadMsgTargetCallbackData` to `ThreadMsgTargetData`
* Simplify window initialization
* Fix compilation on 32-bit targets
* Simplify the creation of the event target window
* Use `.clone()` rather than `Rc::clone()`
* Use concrete types for args to `SetWindowLongPtrW`
On 32-bit targets, `SetWindowLongPtrW` is an alias to `SetWindowLongW`,
which returns `LONG` (`i32`) rather than `LONG_PTR` (`isisze`).
* Minor comment adjustments
Fixes#1488.
`is_key_down` was only set to true when `insertText` was called.
Therefore `is_key_down` was actually meant to store whether the most
recently pressed key generated an `insertText` event, at which, winit
produces a `ReceivedCharacter`. The issue is that `insertText` is *not*
called for "key repeat", but winit wants to send `ReceivedCharacter`
events for "key repeat" too. To solve this, the `is_key_down` variable
was then checked in the `key_down` function to determine whether it was
valid to produce repeated `ReceivedCharacter` events during "key
repeat". However this check is not needed since `ReceivedCharacter` must
always be called if the key event has a non-empty `characters` property.
Furthermore `is_key_down` didn't actually store whether the previously
pressed character had an `insertText` event, because it was incorrectly
set to false on every "key up". This meant that if two keys were pressed
consecutively and then the first was released, then `is_key_down` was
set to false even if the most recent keypress did actually produce an
`insertText`.
Update changelog.
* changed description of window scale factor in Events
* Update src/dpi.rs
Co-authored-by: Markus Røyset <maroider@protonmail.com>
* Fix intra-doc link
Co-authored-by: Markus Røyset <maroider@protonmail.com>
* Drop the event callback before exiting
* Update the changelog
* Apply suggestion from review
Co-authored-by: Markus Røyset <maroider@protonmail.com>
* Apply review suggestions
Co-authored-by: Markus Røyset <maroider@protonmail.com>
* Remove support for `stdweb`
* Expunge `stdweb`; make `web-sys` the default
* Mark this change as a breaking change
* Re-insert accidental removal of space
* Use the correct cargo feature syntax
* Re-add some `cfg` attributes
* Remove `web-sys` feature from CI
* Require setting the activation policy on the event loop
* Run cargo fmt
* Update changelog
* Fixes and tweaks from review
* Correct comment in app_state.rs
Co-authored-by: Mads Marquart <mads@marquart.dk>
* MacOS: Only activate after the application has finished launching
This fixes the main menu not responding until you refocus, at least from what I can tell - though we might have to do something similar to https://github.com/linebender/druid/pull/994 to fix it fully?
* MacOS: Remove activation hack
* Stop unnecessarily calling `makeKeyWindow` on initially hidden windows
You can't make hidden windows the key window
* Add new, simpler activation hack
For activating multiple windows created before the application finished launching
* feat: added MacOS menu
* fix: ran fmt
* extracted function into variable
* idiomatic formatting
* Set the default menu only during app startup
* Don't set the activation policy in the menu init
Co-authored-by: Artur Kovacs <kovacs.artur.barnabas@gmail.com>
This is called internally by NSApplication.run, and is not something we should call - I couldn't find the reasoning behind this being there in the first place, git blame reveals c38110cac from 2014, so probably a piece of legacy code.
Removing this fixes creating new windows when you have assigned a main menu to the application.
We allow to have RunLoop running only on the main thread. Which means if
we call Window::request_redraw() from other the thread then we have to
wait until some other event arrives on the main thread. That situation
is even worse when we have ControlFlow set to the `Wait` mode then user
will not ever render anything.
* Fix for #1850
* Update changelog
* Fix for compilation warnings
* Apply suggestions from code review
Co-authored-by: Markus Røyset <maroider@protonmail.com>
* Improve code quality
* Change Arc<Mutex> to Rc<RefCell>
* Panicking in the user callback is now well defined
* Address feedback
* Fix nightly warning
* The panic info is now not a global.
* Apply suggestions from code review
Co-authored-by: Francesca Lovebloom <francesca@brainiumstudios.com>
* Address feedback
Co-authored-by: Markus Røyset <maroider@protonmail.com>
Co-authored-by: Francesca Lovebloom <francesca@brainiumstudios.com>
* Restore the ability to have fully transparent windows on Windows
Besides its original purpose, commit 6343059b "Fix Windows transparency
behavior to support fully-opaque regions (#1621)" also included some
changes considered cleanups, one of them was:
* Remove the `CreateRectRgn` call, since we want the entire window's region to
have blur behind it, and `DwnEnableBlurBehindWindow` does that by default.
But the original code actually disabled the blur effect for the whole
window by creating an empty region for it, because that allows for the
window to be truely fully transparent. With the blur effect in place,
the areas meant to be transparent either blur the things behind it
(until Windows 8) or are darkened (since Windows 8). This also means
that on Windows 8 and newer, the resulting colors are darker than
intended in translucent areas when the blur effect is enabled.
This restores the behaviour from winit <0.24 and fixes#1814.
Arguably, one might want to expose the ability to control the blur
region, but that is outside the scope of this commit.
* Remove useless WS_EX_LAYERED from transparent windows on Windows
`WS_EX_LAYERED` is not supposed to be used in combination with
`CS_OWNDC`. In winit, as it is currently used, `WS_EX_LAYERED` actually
has no effect at all. The only relevant call is to
`SetLayeredWindowAttributes`, which is required to make the window
visible at all with `WS_EX_LAYERED` set, but is called with full
opacity, i.e. there's no transparency involved at all.
The actual transparency is already achieved by using
`DwmEnableBlurBehindWindow`, so `WS_EX_LAYERED` and the call to
`SetLayeredWindowAttributes` can both be removed.
* Add DeviceEvent::MouseMove on web platform to support pointer lock
* Update changelog
* Add support for stdweb too
* Add mouse_delta to stdweb
* Remove reference to pointer lock
* Link CGDisplayCreateUUIDFromDisplayID through ColorSync instead of CoreGraphics
* Conditionally link through ColorSync only if WINIT_LINK_COLORSYNC is set
to true
* Document new macos env var in README
Following the changes in [1] this bumps ndk and ndk-glue to 0.3 and uses
the new constants. The minor version has been bumped to prevent
applications from running an older winit (without #1826) with a newer
ndk/ndk-glue that does not pass this `ident` through the `data` pointer
anymore.
[1]: https://github.com/rust-windowing/android-ndk-rs/pull/112
The issue was caused by calling SetCapture on a window which already
had the capture. The WM_CAPTURECHANGED handler assumed that it would
only run if the capture was lost, but that wasn't the case. This made
the handler to try to lock the window state mutex while it was already
locked.
The issue was introduced in #1797 (932cbe4).
ndk-glue currently sets both the `ident` field and user-data pointer to
`0` or `1` for the event pipe and input queue respectively, to tell
these sources apart. While it works to reinterpret this `data` pointer
as integer identifier it shouldn't be abused for that, in particular
when one may wish to provide extra information with an event in the
future; then the `data` field is used as pointer (or abused as abstract
value) for that.