Mutter can reposition window on resize, if it is behind mutter's "bounding box".
So, when you start winit window in maximized mode with CSD, mutter places its CSD
behind the GNOME's status bar initially, and then sends configure with the
exact same size as your current window. If winit decides to optimize calling
frame.resize(..) in this case, we won't call set_geometry(we're calling
it through resize) and GNOME won't reposition your window to be inside the
"bounding box", which is not a desired behavior for the end user.
* Add ModifiersChanged event for macOS
This implements the macOS portion of #1124.
* Fix ModifiersChanged event import
* Fix event passing window instead of device id
* X11: Report `CursorMoved` when touch event occurs
* Only trigger CursorMoved events for the first touch ID
* Fix testing for current touch events
* Fix first touch logic
* X11: Sync key press/release with window focus
* When a window loses focus, key release events are issued for all pressed keys
* When a window gains focus, key press events are issued for all pressed keys
* Adds `is_synthetic` field to `WindowEvent` variant `KeyboardInput`
to indicate that these events are synthetic.
* Adds `is_synthetic: false` to `WindowEvent::KeyboardInput` events issued
on all other platforms
* Clarify code with comments
* X11: Fix incorrect modifiers when events are missed
* Syncs modifier state with state data in X key/button/motion events.
* Fixes modifier state in XWayland, as xinput2 raw input events will
not be received when a window does not have focus.
* Removes `impl From<_> for ModifiersState` on X11/Wayland API types,
replacing them with `pub(crate)` methods.
* Cleanup modifier state update using a macro
* Remove keys from modifier state when updating
* X11: Fix window creation hangs when another application is fullscreen
Previously, the X11 backend would block until a `VisibilityNotify` event
is received when creating a Window that is visible or when calling
`set_visible(true)` on a Window that is not currently visible. This
could cause winit to hang in situations where the WM does not quickly
send this event to the application, such as another window being
fullscreen at the time.
This behavior existed to prevent an X protocol error caused by setting
fullscreen state on an invisible window. This fix instead stores desired
fullscreen state when `set_fullscreen` is called (iff the window is not
visible or not yet visible) and issues X commands to set fullscreen
state when a `VisibilityNotify` event is received through the normal
processing of events in the event loop.
* Add window_debug example to facilitate testing
* Add a CHANGELOG entry
* Call `XUnmapWindow` if `VisibilityNotify` is received on an invisible window
* Prevent EventLoop from getting initialized outside the main thread
This only applies to the cross-platform functions. We expose functions
to do this in a platform-specific manner, when available.
* Add CHANGELOG entry
* Formatting has changed since the latest stable update...
* Fix error spacing
* Unix: Prevent initializing EventLoop outside main thread
* Updates libc dependency to 0.2.64, as required by BSD platforms
* Update CHANGELOG.md for Linux implementation
* Finish sentence
* Consolidate documentation
* Fix so the compiler can infer msg_send! return type
Currently, due to a quirk in Rust's type inference interacting with the
structure of the msg_send! macro, a () return type will be inferred when
the compiler cannot otherwise determine the return type. This behavior
is expected to change, and in the future could resolve to a ! return
type, which results in undefined behavior.
Linting has previously been added for this in rust-lang/rust#39216, but
it did not catch these cases due to SSheldon/rust-objc#62. An upcoming
version of objc will be fixed to stop hiding these errors, at which
point they will become compile errors.
This change fixes these errors and allows winit to compile with the
fixed version of objc.
* Bump cocoa to 0.19.1
Adds fullscreen using native web APIs to the stdweb and web-sys backends.
Due to limitations of browser APIs, requests for fullscreen can only be fulfilled during a short-lived user-triggered event. This commit does automatically handle that under the hood, but it does introduce unavoidable latency in full-screening the canvas.
* Expose HINSTANCE now using a getter function
* Missing changes
* remove unused import
* Required changes for the PR
* Rust fmt
* Use GetWindowLong
* Use GetWindowLong
* Fixed relative_pointer not being set up when the "zwp_relative_pointer_manager_v1" callback comes after the "wl_seat" callback
* Ran cargo fmt
* Updated changelog
* Added wayland support for set_grab_cursor and set_cursor_visible
* Updated changelog
* Ran cargo fmt
* Fixed set_cursor_visible and set_cursor_grab so they can be called from any thread.
* Ran cargo_fmt
* Improved CHANGELOG
* Added workaround so that when cursor is hidden it takes effect before the cursor enters the surface. Making the cursor visible again still only happens once the cursor re-enters the surface
* Switched to using Rc<RefCell> instead of Arc<Mutex> since all accesses to the relative_pointer_manager_proxy will happen on the same thread.
* Forgot to run cargo fmt
* Switched to using Rc and RefCell instead of Arc and Mutex where applicable.
* Improved comments and documentation relating to changing a hidden cursor back to visible on wayland.
* Wayland: Fixed cursor not appearing immendiately when setting the cursor to visible.
* Forgot to run cargo fmt
* Switched to only storing the pointers in CursorManager as AutoPointer.
* Fixed typo and removed println
* Update CHANGELOG.md
Co-Authored-By: Kirill Chibisov <wchibisovkirill@gmail.com>
* Fixed relative_pointer not being set up when the "zwp_relative_pointer_manager_v1" callback comes after the "wl_seat" callback
* Ran cargo fmt
* Updated changelog
* Improved CHANGELOG
* Switched to using Rc<RefCell> instead of Arc<Mutex> since all accesses to the relative_pointer_manager_proxy will happen on the same thread.
* Forgot to run cargo fmt
* X11: Fix panic when no monitors are available
* Set dummy monitor's dimensions to `(1, 1)`
* X11: Avoid panicking when there are no monitors in Window::new
* Allow using multiple `XWindowType`s on X11 (#1140)
* Update documentation to make combining window types clearer
* Update build flags because X11 runs on more than just Linux
* Revert "Update build flags because X11 runs on more than just Linux"
This reverts commit 882b9100462a5ee0cf89dcd42891ebd0f709964f.
* Revert "Update documentation to make combining window types clearer"
This reverts commit da00ad391a8ce42cea08b577b216316b013f9e36.
* Revert "Allow using multiple `XWindowType`s on X11 (#1140)"
This reverts commit a23033345697463400286c4d297f5c1552369fc2.
* Allow using multiple `XWindowType`s on X11 (slice variant) (#1140)
* Multiple `XWindowType`s, with non-static lifetime.
* Multiple `XWindowType`s (#1140) (`Vec` variant)
* Append change to changelog.
* Fix formatting.
* Keep track of what windows have requested redraw
Instead of using request_animation_frame and sending redraw request
events, just keep track of all windows that have asked for a redraw.
This doesn't handle dispatching the events
* Issue redraw events to windows that request it
* Cargo fmt
* Use actual numeric IDs to differentiate Windows
This is generally important to identifying which window should
recieve which event, but is also specifically crucial for fixing
RedrawRequested on web.
* Cargo fmt
* Flush high surrogate if not followed by low surrogate
* Remove transmute from WM_CHAR handler
* Fix window_state being locked while dispatching ReceivedCharacter for surrogate codepoints.
* Format
Just before starting to poll/wait on calloop(mio), check if there
are already events pending in the internal buffer of our wayland
event queue. If so, dispatch them and force an instant wakeup from
the polling, in order to behave as if we were instantly woken up by
incoming wayland events.
When using OpenGL, mesa shares our wayland socket, and also reads
from it, especially if vsync is enabled as it'll do blocking reads.
When doing so, it may enqueue events in the internal buffer of our
event queue.
As the socket has been read, mio will thus not notify it to calloop
as read, and thus calloop will not know it needs to dispatch. In some
cases this can lead to some events being delivered much later than
they should. Combined with key repetition this can actually cause some
flooding of the event queue making this effect event worse.
Fixes#1148
* Add touch pressure information for touch events on Windows
* Modified CHANGELOG.md and FEATURES.md to reflect changes
* Updated documentation of struct Touch to reflect changes
* Replaced mem::uninitalized() with mem::MaybeUninit
Fixed warnings in platform_impl/windows/dpi.rs
* fix#1087. the CFRunLoopTimer was never started if the user never changed the controlflow.
* RedrawRequested ordering matches the new redraw api
consistent asserts
lots of appstate refactoring to rely less on unsafe, and hopefully make it easier to maintain
* ios: dpi bugfix. inputs to setContentScaleFactor are not to be trusted as iOS uses 0.0 as a sentinel value for "default device dpi".
the fix is to always go through the getter.
* move touch handling onto uiview
* update changelog
* rustfmt weirdness
* fix use option around nullable function pointers in ffi
* Document why gl and metal views don't use setNeedsDisplay
* change main events cleared observer priority to 0 instead of magic number
log when processing non-redraw events when we expect to only be processing redraw events
* X11: Fix performance issue with rapidly resetting cursor icon
* When setting cursor icon, if the new icon value is the same as the
current value, no messages are sent the X server.
* X11: Cache cursor objects in XConnection
* Add changelog entry
* iOS os version checking
* iOS, fix some incorrect msg_send return types
* address nits, and fix OS version check for unsupported os versions
* source for 60fps guarantee
* macOS/iOS: Fix auto trait impls of `EventLoopProxy`
`EventLoopProxy<T>` allows sending `T` from an arbitrary thread that
owns the proxy object. Thus, if `T` is `!Send`, `EventLoopProxy<T>` must
not be allowed to leave the main thread.
`EventLoopProxy<T>` uses `std::sync::mpsc::Sender` under the hood,
meaning the `!Sync` restriction of it also applies to
`EventLoopProxy<T>`. That is, even if `T` is thread-safe, a single
`EventLoopProxy` object cannot be shared between threads.
* Update `CHANGELOG.md`
* Stop appending canvas to document in web platform
* Remove `tabindex` TODO in web backend
* Return `OsError` instead of panicking on web canvas creation
* Add exclusive fullscreen mode
* Add `WindowExtMacOS::set_fullscreen_presentation_options`
* Capture display for exclusive fullscreen on macOS
* Fix applying video mode on macOS after a fullscreen cycle
* Fix compilation on iOS
* Set monitor appropriately for fullscreen on macOS
* Fix exclusive to borderless fullscreen transitions on macOS
* Fix borderless to exclusive fullscreen transition on macOS
* Sort video modes on Windows
* Fix fullscreen issues on Windows
* Fix video mode changes during exclusive fullscreen on Windows
* Add video mode sorting for macOS and iOS
* Fix monitor `ns_screen` returning `None` after video mode change
* Fix "multithreaded" example on macOS
* Restore video mode upon closing an exclusive fullscreen window
* Fix "multithreaded" example closing multiple windows at once
* Fix compilation on Linux
* Update FEATURES.md
* Don't care about logical monitor groups on X11
* Add exclusive fullscreen for X11
* Update FEATURES.md
* Fix transitions between exclusive and borderless fullscreen on X11
* Update CHANGELOG.md
* Document that Wayland doesn't support exclusive fullscreen
* Replace core-graphics display mode bindings on macOS
* Use `panic!()` instead of `unreachable!()` in "fullscreen" example
* Fix fullscreen "always on top" flag on Windows
* Track current monitor for fullscreen in "multithreaded" example
* Fix exclusive fullscreen sometimes not positioning window properly
* Format
* More formatting and fix CI issues
* Fix formatting
* Fix changelog formatting
* Process WM_SYSCOMMAND to forbid screen savers in fullscreen mode
Fixes#1047
* Update CHANGELOG.md and documentation to reflect changes from issue #1065
* Updated documentation of window.Window.set_fullscreen to match the documentation of window.WindowBuilder.with_fullscreen.
* Touch events emit screen coordinates instead of client coordinates on Windows
Fixes#1002
* Don't lose precision of WM_TOUCH events when converting from screen space to client space
* Updated CHANGELOG.md to reflect changes from issue: #1042
* Replace `std::mem::uninitialized` with `MaybeUninit`
* Avoid undefined behavior when using `MaybeUninit`
* Restore unused `PointerState` fields as internally public
* Zero-initialize some struct values in Xlib FFI calls
* Reform usage of `MaybeUninit` in Xlib FFI
* Prefer safe zero-initialization using `Default`, when possible
* Zero-initialize integers and floats using `0` or `0.0`
* Use `MaybeUninit::uninit` for large byte buffers and union types
* Use `MaybeUninit::uninit` when the resulting value is ignored
* Fix old `use` declarations
* Fix hidden lifetime parameter
* Fix missing methods in `web::Monitor`.
Originally fixed by @ryanisaacg in 94387c4bf5bca35f4e24562ce89a4f4badd53aa8.
* Disable some tests and examples on `wasm32`
* Fix issues with redraw_requested when called during EventsCleared
* Format
* Fix event dispatch after RedrawRequested but before EventsCleared
This could happen if the event queue was cleared, we processed WM_PAINT,
but the event queue got re-filled before we checked to see it was empty.
* Fix paint ordering issues when resizing window
* Format
* Make FileDropHandler::iterate_filenames more robust
by replacing the call to mem::uninitialized with mem::zeroed and change
file name retrieval to use buffers of exact length as reported
by DragQueryFileW instead of relying on MAX_PATH.
* Change remaining calls of uninitialized to zeroed
* Run rustfmt
* Add CHANGELOG entry and comment
Internally, `XFlush` calls `_XSend` to write data. It then calls
`XEventsQueued(display, QueuedAfterReading)`, which reads data from the
X server connection. This prevents the event loop source callback from
being run, as there is no longer data waiting on the socket.
Ideally, we would want to call `_XSend` directly to ensure that no
output is buffered by Xlib. However, this function is not exported as
part of Xlib's public API.
Testing with the `XFlush` call removed does not appear to adversely
affect the performance of an application. If any bugs should eventually
arise from this change, perhaps another function may be used in place of
`XFlush`, such as `XPending`, which writes buffered output but does not
so aggressively read from the X server connection.
Closes#865
* Add relative pointer movement for Wayland
* Format changed code with rustfmt
* Wayland: merge window and device event queues into one
* Replace map_or_else call for simplification
* Format everything and add rustfmt to travis
* Remove extern crate winit from examples and add force_multiline_blocks
* Format the code properly
* Fix inconsistent period in PULL_REQUEST_TEMPLATE.md
* Only run rustfmt on nightly
* Travis fixings
This decorelates the window management from the actual user content,
meaning:
- the created window no longer needs the user to draw something to
start existing
- it reduces our need to do roundtrips during initialization to
avoid protocol errors
* Support listing available video modes for a monitor
* Use derivative for Windows `MonitorHandle`
* Update FEATURES.md
* Fix multiline if statement
* Add documentation for `VideoMode` type
* Fix request_redraw with Poll and WaitUntil(time_in_the_past) on Windows
`Window::request_redraw` now fires a `RedrawRequested` event when
called from an `Event::EventsCleared` callback while the control
flow is set to `Poll`. A control flow of `WaitUntil(resume_time)`,
will now also fire the `RedrawRequested` event when `resume_time`
is in the past.
* Prevent panic on x11 when WaitUntil(resume_time) is in the past
* Prevent panic on wayland when WaitUntil(resume_time) is in the past
* First name consistency pass. More to come!
* Remove multitouch variable (hopefully this compiles!)
* Remove CreationError::NotSupported
* Add new error handling types
* Remove `get_` prefix from getters.
This is as per the Rust naming conventions recommended in
https://rust-lang-nursery.github.io/api-guidelines/naming.html#getter-names-follow-rust-convention-c-getter
* Make changes to Window position and size function signatures
* Remove CreationError in favor of OsError
* Begin updating iOS backend
* Change MonitorHandle::outer_position to just position
* Fix build on Windows and Linux
* Add Display and Error implementations to Error types
* Attempt to fix iOS build.
I can't actually check that this works since I can't cross-compile to
iOS on a Windows machine (thanks apple :/) but this should be one of
several commits to get it working.
* Attempt to fix iOS errors, and muck up Travis to make debugging easier
* More iOS fixins
* Add Debug and Display impls to OsError
* Fix Display impl
* Fix unused code warnings and travis
* Rename set_ime_spot to set_ime_position
* Add CHANGELOG entry
* Rename set_cursor to set_cursor_icon and MouseCursor to CursorIcon
* Organize Window functions into multiple, categorized impls
* Improve clarity of function ordering and docs in EventLoop
* port ios winit el2.0 implementation to the new rust-windowing repo
* unimplemented! => unreachable
trailing comma in CFRunLoopTimerCallback
* implement get_fullscreen
* add iOS specific platform documentation. Add a TODO about how to possibly extend the iOS backend to work have methods callable from more than just the main thread
* assert that window is only dropped from the main thread
* assert_main_thread called from fewer places
* Prevent the event loop from pausing after entering modal loop
After clicking the window title bar or border (for a drag or resize),
the event loop pauses until the mouse is moved. This change relays
the WM_NCLBUTTONDOWN message to the dummy window where it queues
a redraw and consumes the message. This effectively jumpstarts
the modal loop and it continues to fire draw requests.
* Handle WM_NCLBUTTONDOWN in public_window_callback instead of relaying.
Relaying the WM_NCLBUTTONDOWN message to the modal window turned out
to be unnecessary.
* Add additional numpad key mappings
Since some platforms have already used the existing `Add`, `Subtract`
and `Divide` codes to map numpad keys, the X11 and Wayland platform has
been updated to achieve parity between platforms. On macOS only the
`Subtract` numpad key had to be added.
Since the numpad key is different from the normal keys, an alternative
option would be to add new `NumpadAdd`, `NumpadSubtract` and
`NumpadDivide` actions, however I think in this case it should be fine
to map them to the same virtual key code.
* Add Numpad PageUp/Down, Home and End on Wayland
* Use `XRRGetScreenResourcesCurrent` when avail.
Signed-off-by: Hal Gentz <zegentzy@protonmail.com>
* Changelog
Signed-off-by: Hal Gentz <zegentzy@protonmail.com>
XNextEvent will block for input while holding the global Xlib mutex.
This will cause a deadlock in even the most trivial multi-threaded
application because OpenGL functions will need to hold the Xlib mutex
too.
Add EventsLoop::poll_one_event and EventsLoop::wait_for_input to provide
thread-safe functions to poll and wait events from the X11 event queue
using unix select(2) and XCheckIfEvent.
This is a somewhat ugly workaround to an ugly problem.
Fixes#779
* Fix incorrect keycodes when using a non-US keyboard layout.
This commit fixes the issue described in #752, and uses the advised
method to fix it.
* Style fixes
Co-Authored-By: Toqozz <toqoz@hotmail.com>
* Refactoring of macOS `virtualkeycode` fix (#752)
* Applies requested changes as per pull request discussion (#755).
* match unix common API to evl 2.0
* wayland: eventloop2.0
* make EventLoopProxy require T: 'static
* Fix linux build and tests
* wayland: update sctk & small fixes
* Rename EventsLoop and associated types to EventLoop
* Rename WindowEvent::Refresh to WindowEvent::Redraw
* Remove second thread from win32 backend
* Update run_forever to hijack thread
* Replace windows Mutex with parking_lot Mutex
* Implement new ControlFlow and associated events
* Add StartCause::Init support, timer example
* Add ability to send custom user events
* Fully invert windows control flow so win32 calls into winit's callback
* Add request_redraw
* Rename platform to platform_impl
* Rename os to platform, add Ext trait postfixes
* Add platform::desktop module with EventLoopExt::run_return
* Re-organize into module structure
* Improve documentation
* Small changes to examples
* Improve docs for run and run_return
* Change instances of "events_loop" to "event_loop"
* Rename MonitorId to MonitorHandle
* Add CHANGELOG entry
* Improve WaitUntil timer precision
* When SendEvent is called during event closure, buffer events
* Fix resize lag when waiting in some situations
* Update send test and errors that broke some examples/APIs
* Improve clarity/fix typos in docs
* Fix unreachable panic after setting ControlFlow to Poll during some RedrawRequested events.
* Fix crash when running in release mode
* Remove crossbeam dependency and make drop events work again
* Remove serde implementations from ControlFlow
* Fix 1.24.1 build
* Fix freeze when setting decorations
* Replace &EventLoop in callback with &EventLoopWindowTarget
* Document and implement Debug for EventLoopWindowTarget
* Fix some deadlocks that could occur when changing window state
* Fix thread executor not executing closure when called from non-loop thread
* Fix buffered events not getting dispatched
* Fix crash with runner refcell not getting dropped
* Address review feedback
* Fix CHANGELOG typo
* Catch panics in user callback