Commit graph

1483 commits

Author SHA1 Message Date
Simon Hausmann
199c761583 LinuxKMS: Fix animations using the wrong start time when invoked from invoke_from_event_loop
The event loop roughly loops like this:

loop {
    update_timers_and_animations();
    render();
    sleep_or_dispatch_events();
}

sleep_or_dispatch_events() will wake up when we receive a queued callback from invoke_from_event_loop, and we would
run the callback right away. If that callback sets animated properties, the start time for animations would be incorrect, as we haven't called update_timers_and_animations() yet.

So instead, let's keep track of any received callbacks per sleep cycle, update the animation tick, and then invoke the callbacks.
2024-01-15 18:30:49 +01:00
Simon Hausmann
8caa5acd30 winit: Avoid warnings about exiting fullscreen mode when compiled for the web
We call set_fullscreen(None) on startup for windows that aren't fullscreen (normally), and winit compiled for the web unconditionally calls canvas.exitFullscreen(), which
may produces warnings about exitFullscreen()
being called when not in fullscreen mode.
2024-01-15 15:22:15 +01:00
Simon Hausmann
9c247553e1 LinuxKMS: Tweak the output shown after SLINT_{DRM,VULKAN}_{MODE,OUTPUT,DISPLAY}=list to mention the environment variable in question
As suggested by Olivier, this makes it much clearer what the next steps
are.
2024-01-12 17:32:56 +01:00
Simon Hausmann
4d23bcdd97 LinuxKMS: Replace the use of panic with eprintln/std::process::exit
As suggested by Olivier, That's a little cleaner than panicing. There's
no reason to panic, this is normal :-)
2024-01-12 17:32:56 +01:00
Simon Hausmann
2b699c2189 LinuxKMS: Add support for selecting display modes with DRM output 2024-01-12 17:32:56 +01:00
Simon Hausmann
bf7a4095ad LinuxKMS: Not only print the name of the renderer, also print the resolution 2024-01-12 16:07:29 +01:00
Simon Hausmann
4d58c9877d LinuxKMS: Remove set_event_loop_quit_on_last_window_closed implementation
This is now handled in i-slint-core.

Amends 9ff13faee8
2024-01-12 10:05:02 +01:00
Olivier Goffart
a7934438ad Janitor: update some dependencies 2024-01-11 14:01:19 +01:00
Simon Hausmann
e1c5f4ff03 linuxkms: Fix support for "refresh_full_speed" in SLINT_DEBUG_PERFORMANCE
We trigger update_timers_and_animations() every time the event loop wakes up.
If there's a real animation in the UI going on, that'll also trigger a
request_redraw() call and all will be well.

But when the only source of animation is set_has_active_animations() from
RenderingMetricsCollector, then we might end up in a situation where the event
loop is woken up before the rendered frame is on the screen, which means we
invoke update_timers_and_animations(), but we won't render because the
previous frame isn't shown yet. When it is shown and our presentation callback
is invoked, has_active_animations() is false again.

So instead, remember if we need to re-render once after rendering()
and use that to decide if we need to re-render in the presentation callback.
2024-01-11 11:23:18 +01:00
Daniel
807a233849
feat: Add Key.Space to Key namespace. (#4311) 2024-01-10 16:25:31 +01:00
Olivier Goffart
926c313493
Android docs: Fix warning in the documentation 2024-01-10 10:45:28 +01:00
Olivier Goffart
afb8a66603 Qt backend: Check if platform supports the selection clipboard
Suppress console warning on Windows:
`Data set on unsupported clipboard mode. QMimeData object will be
deleted.`

Fixes #3206
2024-01-10 10:11:05 +01:00
Olivier Goffart
0725bb1b61
Android docs: mention the todo example 2024-01-10 10:06:15 +01:00
Simon Hausmann
438b9afeaa
Reduce WindowAdapter API slightly (#4304)
Move the set_fullscreen function added to the WindowAdapter trait in 779aff0b39
to be a function in WindowProperties instead.
That way it'll be easier in the future to extend this with other window states without
having to modify or break the WindowAdapter trait API.
2024-01-09 18:55:06 +01:00
Harold
779aff0b39
Added set_fullscreen API to WindowAdapter. (#4286)
See #3283
2024-01-09 15:23:23 +01:00
Olivier Goffart
9ff13faee8 Implement the quitting on windows close in i-slint-core and not in the platform
Step towards #1499
2024-01-08 21:17:52 +01:00
Olivier Goffart
b5032ca53f winit: add a hook to adjust the winit::WindowBuilder
This is still internal API but can help for the case of
https://github.com/slint-ui/slint/discussions/4284 where this could be
used to call winit::WindowBuilder::with_titlebar_transparent or others
https://docs.rs/winit/latest/x86_64-apple-darwin/winit/platform/macos/trait.WindowBuilderExtMacOS.html#tymethod.with_title_hidden
2024-01-08 15:17:34 +01:00
Simon Hausmann
a7d1ab89d7 Minor cleanup
Merge two functions that had only one call site.
2024-01-08 09:56:14 +01:00
Simon Hausmann
982b4c806f LinuxKMS: Add initial support for software rendering with Skia
This is the initial implementation based on DRM dumb buffers,
which cleans up various things at the same time:

 - DRM output is separate from GBM and DRM dumb buffer displays.
   The latter two re-use the former.
 - The timer refresh for the Vulkan KHR Display rendering lives
   now with the KHR display code, in hope to be replaced with a
   better mechanism in the future.

What's missing still is support for partial updates as well as
rendering with our own software renderer.
2024-01-07 11:54:29 +01:00
Simon Hausmann
c5aebcfde3 Fix close behaviour of PopupWindow
- Close on release when the mouse pointer is inside the popup
- Close on press when click is outside
2024-01-06 10:45:34 +01:00
Olivier Goffart
b90047599e Android: Fix delete and backspace being inverted 2024-01-05 17:35:49 +01:00
Olivier Goffart
950ffb0041 Android: make the show/hide keyboard work with native-activity 2024-01-05 16:11:28 +01:00
Olivier Goffart
f495235b74 Android todo example: cleanup console output and remove warning 2024-01-05 16:11:28 +01:00
Simon Hausmann
8193d4d064 LinuxKMS: Clean up internal page flip callback API
Remove the hack of calling present() from our swap_buffers() forwarder (and let it really only forward),
and instead call it explicitly through the shared egl_display member.
The way we can pass along the callback instead of storing it separately.
2024-01-04 10:35:40 +01:00
Simon Hausmann
f5bf6e5dc0 Skia: Clean up pre present notify callback API
Move this back out of render() again and make it stateful in the renderer. Reduces the amount of book-keeping required and it's always the same callback anyway.
2024-01-04 10:35:09 +01:00
Simon Hausmann
41bfe66447 Bump AccessKit dependencies
This brings lazy initialization of the accesskit adapter on Linux/dbus.

cc #3867
2024-01-04 10:00:55 +01:00
Simon Hausmann
3069e8e503 Add support for frame throttling on Wayland
Use winit's pre_present_notify() API to allow for the compositor to throttle rendering.

Fixes #4200
cc #1695
2024-01-04 09:21:53 +01:00
Olivier Goffart
c4a91982db Janitor: fix docs links 2024-01-03 16:29:03 +01:00
Simon Hausmann
d0616f31fb winit: Remove hack that makes request_redraw() during draw() work
Calling request_request() during RedrawRequested would not work on
Windows and wasm. Commit 372e6b0ffc worked
around this, but that can be reverted now, as this is fixed in winit.
For windows that was https://github.com/rust-windowing/winit/pull/3165
and for wasm I couldn't find the change, but could verify that it still
works.

I checked that #1574 does not regress.

Besides the cleanup, this is also needed for #1695.
2024-01-03 10:23:34 +01:00
Simon Hausmann
25579ab068 winit: Fix FocusScope's key-released not being invoked when releasing the space bar key
Upon pressing, event.text is set and all is well. But when the space bar is released, event.text is always
empty and we would not dispatch an event.
2024-01-02 15:29:24 +01:00
Simon Hausmann
6b6fd91035 linuxkms: Move the fallback timer based animation driver code into a separate helper type 2023-12-19 16:59:35 +01:00
Simon Hausmann
0b21d8bfce linuxkms: Don't use a 16ms timer for the animation frame callback after the first buffer was posted
We don't need to wait 16ms, we could render right away. In theory this could also use invoke_from_event_loop, but then
the callback needs to be sync, which is an unnecessary
complication.
2023-12-19 16:59:35 +01:00
Simon Hausmann
2d0f2a52e6 linuxkms: Simplify drm event handling code a little bit
Less code nesting :)
2023-12-19 16:59:35 +01:00
Simon Hausmann
0ccc334de7 linuxkms: remove home-grown fd event source with calloop's generic even source
That's less boiler plate for us and better error handling (note how the receive_events()
call on the DRM device now propagates the error). And this also unregisters automatically
on drop.
2023-12-19 16:59:35 +01:00
Simon Hausmann
208a1e24ac linuxkms: replace 16m timer for animations with page flip driven rendering (if possible) 2023-12-19 16:59:35 +01:00
Simon Hausmann
4f0ad4c15b linuxkms: remove page flip specific bits from the calloop event loop
This belongs encapsulated inside the egldisplay code.
2023-12-19 16:59:35 +01:00
Simon Hausmann
b998f94ad6 linuxkms: Avoid keeping the EGL display around for too long
Don't keep a strong reference to the EGL display, we don't need that. If the display is removed but there are pending events, just ignore them.
2023-12-19 16:59:35 +01:00
Simon Hausmann
388661cc53 linuxkms: Fix firing of timers while animations are running
Merge the 16 redraw timer with other timers, which might fire sooner.
2023-12-19 16:59:35 +01:00
Simon Hausmann
b40b629e11 linuxkms: don't blockingly read on the drm fd after issuing a page flip request
... instead pass the fd into the calloop event loop and change state when we receive activity on it.

This improves performance slightly, and is a necessary to be able to implement refresh rate throttled rendering (in the next commits).
2023-12-19 16:59:35 +01:00
Simon Hausmann
11df315c54 linuxkms: Clean up file descriptor handling (part 2)
File can be converted into OwnedFd, so we can replace the
use of a dyn with the concrete Rc<OwnedFd>.
2023-12-19 16:59:35 +01:00
Simon Hausmann
e98a029293 linuxkms: Clean up file descriptor handling (part 1)
We don't need Arc for the file descriptors that remain in the same thread.
2023-12-19 16:59:35 +01:00
Simon Hausmann
3b51c8e30a
LinuxKMS: Add support for synthetic display rotations (#4166)
This patch adds support for the `SLINT_KMS_ROTATION` environment
variable, that instructs the Skia/FemtoVG renderers to rotate
the scene before rendering.
2023-12-18 17:49:05 +01:00
Simon Hausmann
007de3dd8d Use raw-window-handle 0.6 for accesskit
The new release defaults to using rwh 0.6, which implicitly also
enables rhw_06 on winit.
2023-12-18 17:07:30 +01:00
Noah Sweilem
4ca5afc710
Implement colorize-icon for NativeButton (#4167)
Fixes #4159.

Co-authored-by: Florian Blasius <florian.blasius@slint.dev>
2023-12-18 09:19:09 +01:00
Noah Sweilem
1ddddf1081
Qt backend: use QObject::deleteLater() when destroying popup QWidget (#4168) 2023-12-18 09:03:39 +01:00
Florian Blasius
e587c09d9c
Added colorize-icon to Button (#4152)
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2023-12-14 12:07:55 +01:00
Simon Hausmann
8d19426723
linuxkms: decouple event loop from window adapter (#4144)
- Allow for the event loop to run before creating the window adapter
- Keep the loop running if requested
2023-12-12 13:06:36 +01:00
Simon Hausmann
c1841fdfbe Add support for compiling the linuxkms backend without libseat support 2023-12-11 17:36:17 +01:00
Florian Blasius
6da8120dfa
added palette global (#3984)
* Update docs/reference/src/language/builtins/globals.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update docs/reference/src/language/builtins/globals.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update docs/reference/src/language/builtins/globals.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update docs/reference/src/language/builtins/globals.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update docs/reference/src/language/builtins/globals.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>


---------

Co-authored-by: Florian Blasius <florian.blasius@slint-ui.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
Co-authored-by: Florian Blasius <flovansl@fedora.fritz.box>
2023-12-11 14:44:05 +00:00
Tobias Hunger
2bdcbc8e9f
core: Add a double-click callback to the TouchArea (#4060)
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2023-12-08 12:12:41 +01:00