Commit graph

30 commits

Author SHA1 Message Date
Lukas Jung
e4559f0ea6
Fix Bugs Introduced by GL Jitter on Resize Fix (#1397) 2022-07-15 10:03:03 +02:00
Simon Hausmann
3ce9977f0a Add slint::Window::(set_)position
Fixes #323
2022-07-08 18:37:01 +02:00
Lukas Jung
d63407066d Add documentation to WinitWindow::size() and set_size(). 2022-06-30 10:59:33 +02:00
Lukas Jung
e1b4727c9c Fix resize jitter bug on macOS with GL Backend 2022-06-30 10:59:33 +02:00
Jocelyn Turcotte
041238708f wasm: Prevent wasted redraws with multiple post_events
The previous approach of calling send_event on a timer has the disadvantage
or re-entering the event loop for every queued event. Any requested redraw
after one of those events will end up actually drawing, even if that frame could be
replaced by the next event's redraw without being shown to the user.

winit also doesn't expose publicly its web Runner send_events method that would
allow us to queue the events outside and pass them all together.

We can however queue the events inside winit by putting the event loop in
ControlFlow::Poll mode so that winit batches them itself.
This has the side effect of processing and painting those events using
requestAnimationFrame.

To achieve this we take advantage of winit processing send_event calls
synchronously, possibly while on a native event handler, by entering the
event loop just to send WakeEventLoopWorkaround, set the event loop in
Poll mode, exit, and call send_events again with our event which then
ends up being queue in the web event loop's Runner until the next animation
frame where all queued events are processed and redrawn together.
2022-05-16 11:02:28 +02:00
Olivier Goffart
877934f1f1 GL backend: process timing event before processing input events
Otherwise the timing code might think at the time of an event (eg key press)
that the starting point of an animation that starts in this event is
earlier in time than it really is. Causing the animation to appear as it
had started earlier or literaly be finished before it starts.

Fixes #1255
2022-05-12 11:43:07 +02:00
Lukas Jung
d648862589 Make window.hide() respect the set EventLoopQuitBehavior 2022-05-04 09:16:13 +02:00
Olivier Goffart
723f89d342 Fix changing the size of contrained window on x11
Changing the constraint doesn't work on non-rezsizable window.
So first set the window as resizeable, then change the constraints, then
maybe remove the resizable flag
2022-04-29 11:54:31 +02:00
Olivier Goffart
9ec6ed0406 wasm: fix tab and back tab
The situation differs depending if the widget show the virtual keyboard or not:
For widget that don't show the virtual keyboard, we rely on the winit events,
but for some reason we don't recieve WindowEvent::ModifiersChanged events with
wasm. Since the event handling in winit is about to be rewriten, I did not
bother reporting the bug upstream, but just work around by using the deprecated
API. So that way shift + tab will no longer be understood as just tab.

For widget using the virtual keyboard, then the event handling is in
wasm_input_helper.rs.  There is a couple of issues:

 - We must map shift+tab to backtab.
 - We need to prevent the default events to trigger, so that tab and other
   shortcuts don't take effect on the browser. Winit already inhibit these
   events so we must do the same otherwise tab and shift+tab would change the
   html focus.
 - By luck, tab used to give the focus back to the canvas before (see previous
   point) and that's why it worked. But now that we don't do that anymore,
   hiding the virtual keyboard should actually re-focus the canvas
 - That will cause the focus event to be intercepted by winit, and will cause
   recursions and borrow error, so we make sure that we do not recurse when
   getting the focus event
2022-04-22 13:58:37 +02:00
Simon Hausmann
a881922dd2 Replace touch point workaround with winit patch
Commit c85e1b6d25 added a workaround for a
winit issue, which has been fixed upstream. Until a new release is
available, let's patch in winit from a branch that has the fix
cherry-picked.

This way we don't have to remember to remove the workaround with the
next update and this has been verified on the device.
2022-04-13 11:43:24 +02:00
Olivier Goffart
1b91158b46 corelib: allow to use i32 for coordinate instead of f32 2022-04-11 17:46:50 +02:00
Simon Hausmann
c85e1b6d25 Fix touch position reported on touch release with wayland
Work around https://github.com/rust-windowing/winit/issues/1996 by tracking
touch positions ourselves
2022-04-11 15:56:34 +02:00
Olivier Goffart
1891e4489a GL backend: update the resizable flag
I only tested on X11 plasma, and there this doesn't have any effect,
But this might be needed because i removed it a few commit ago in another
function.

I think the reason it is there is that it allow changing from a fixed size
to a custom size
2022-04-01 16:18:59 +02:00
Olivier Goffart
16a0f28449 Keep the existing size re-using a window
Eg, in the viewer or in the preview.

The preferred size is still set as the size when the window is first open
2022-04-01 16:18:59 +02:00
Olivier Goffart
575665994a GL backend: don't force every window to be redrawn in case of animation
When the animation tick occurs, the tracker will tell winit to repaint
the relevant window already.
2022-03-23 17:43:48 +01:00
Olivier Goffart
bd44afdbf4 Wasm: When getting native callback, make sure to call the winit event loop
Otherwise it won't be woken up if the window needs a redraw
2022-03-23 17:43:48 +01:00
Simon Hausmann
e9350403bc Fix animations not running in secondary windows with wasm
When a second canvas is visible, only animations in the first canvas
resulted in updates and visible animation.  An animation in the second
canvas wouldn't result in repaints.

When we start an animation, we request a redraw on all windows and
return with `ControlFlow::Poll` to winit.

Winit then schedules an animation frame request, and in the callback the
redraw request events are delivered. For the first window we call
`update_animations()`, a new tick is detected (different than the
previous one) and animated properties are dirty and yield new windows.

Then right away we get called again with a redraw request for the second
window. update_animations() determines that the instant::now() is the
same, and has_animations() returns false. So at the end of the event
handler we return fail to return `Poll` and therefore no animation frame
request is created, which means the animations just stop.

Fix this by calling update_animations() only once, when all input events
have been processed and the redraw events are up for delivery next.

This is visible in the preview canvases in the documentation, if a
canvas other than the first has animations.
2022-03-22 14:22:27 +01:00
Olivier Goffart
e017d5118b Wasm GL backend: use a <input> element so it show the keyboard on mobile
cc #215

Handle Input event from the input directly instead of going through winit
for the TextInput.

Note that this doesn't handle the composition event well, so the text is
only considered written when it is accepted
2022-03-22 13:33:31 +01:00
Simon Hausmann
fb20113f17 Fix manual application of the window constraints with the HTML canvas
The size returned by inner_size is a physical size, so we must convert it to
a logical one before comparing it with the logical constraint sizes.
2022-03-21 16:53:30 +01:00
Lukas Jung
8617e92d65 add close request handling the gl backend 2022-03-17 08:51:00 +01:00
Olivier Goffart
f7a0fda86c
Send a MouseExit event when the mouse leaves the window
Fixes #989
2022-03-01 11:23:39 +01:00
Tobias Hunger
a8756119eb Update internal/backends/gl/event_loop.rs
Co-authored-by: Olivier Goffart <olivier@woboq.com>
2022-02-16 12:09:03 +01:00
Tobias Hunger
d443481dee Send less key events from the GL backend
When "combining" information from winit's ReceiveCharacter and
KeyboardInput events, then do not create a second KeyPress event
when the KeyboardInput contained a control character.

This makes us not send duplicate events for `Tab`, but leaves the
handling for e.g. `Ctrl-C` unchanged.
2022-02-16 12:09:03 +01:00
Tobias Hunger
4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00
Tobias Hunger
de4e195280
Rename internal crates and add a README.md to them
The README.md contains the warning that used to be in lib.rs.

Add README.md files to all internal crates

... pointing to the official public crate to use instead.

Rename internal crates

fixup: README files

fixup rename
2022-02-07 13:12:48 +01:00
Tobias Hunger
2b55c488ca
Rename sixtyfps to slint in internal 2022-02-02 16:16:55 +01:00
Tobias Hunger
1a0a495bc5
Rename environment variables 2022-02-02 13:35:07 +01:00
Simon Hausmann
ad0c020aa4 Rename the sixtyfps-corelib crate 2022-02-01 18:04:30 +01:00
Simon Hausmann
0bd627cad6 Rename the common crate 2022-02-01 18:00:25 +01:00
Tobias Hunger
a3b86690ff [reorg]: Move the rendering backends into internal 2022-01-31 16:00:50 +01:00
Renamed from sixtyfps_runtime/rendering_backends/gl/event_loop.rs (Browse further)