Commit graph

692 commits

Author SHA1 Message Date
Simon Hausmann
f60b2ebde9 Add slint::platform::OpenGLInterface
This allows for the use of the FemtoVG renderer but delegate the GL implementation to the user.
2023-07-27 16:48:57 +02:00
Simon Hausmann
3b29bfe2f6 Change OpenGLContextWrapper to return a generic Error
This is in preparation for making the trait public.
2023-07-27 16:48:57 +02:00
Simon Hausmann
4e7ebdceba Improve zero-size OpenGL surface handling
- Use NonZeroU32 in the OpenGLContextWrapper interface (correct API for the future)
- Don't render zero sized windows with the software renderer and FemtoVG
2023-07-27 16:48:57 +02:00
Olivier Goffart
49485dbf7d SoftwareRenderer: add API to construct and change the buffer type 2023-07-27 14:44:28 +02:00
Simon Hausmann
af97435463 Replace show()/hide() in the WindowAdapter with set_visible(bool)
This makes for a smaller interface.
2023-07-26 13:53:45 +02:00
Simon Hausmann
f15bc6147e Simplify FemtoVG and Skia renderer APIs: remove resize()
We can convey the new physical window size from the run-time
through the private renderer API
when a window resize event is dispatched.
2023-07-25 19:33:26 +02:00
Simon Hausmann
7649153b3e janitor: silence rust warning 2023-07-25 17:58:46 +02:00
Simon Hausmann
7d136b6568 Remove the window parameter from the render() function of all the renderers
This makes for a slimmer API and instead we can create the renderer <-> window association
behind the scenes ourselves,
in set_component.
2023-07-25 17:28:08 +02:00
Simon Hausmann
507428b03e
Simplify FemtoVG and Skia renderer API (#3153)
Fold show() into the first time render() is invoked,
and hide() into the Drop implementation.
2023-07-25 17:17:40 +02:00
ogoffart
aebaa7d6c9 Bump version number to 1.2.0 2023-07-25 10:44:53 +00:00
Simon Hausmann
3e420b32ad Fix accessibility tree on Linux when UI has no repeaters
We need to make sure to replace the dummy tree from #3046 with a real tree.
2023-07-10 12:16:19 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Olivier Goffart
4531210952 Fix the accesskit fix
We also need to add the node in the list of node
2023-07-10 08:50:31 +02:00
Olivier Goffart
8009f12646 Attempt to fix a panic in accesskit
On unix, the panic happens since the upgrade from zbus 3.10 to zbus 3.14

```
thread 'test_window_accessor' panicked at 'called `Option::unwrap()` on a `None` value', /home/olivier/.cargo/registry/src/index.crates.io-6f17d22bba15001f/accesskit_consumer-0.15.0/src/tree.rs:274:45
stack backtrace: [...]
   3: core::option::Option<T>::unwrap
   4: accesskit_consumer::tree::Tree::new
             at /home/olivier/.cargo/registry/src/index.crates.io-6f17d22bba15001f/accesskit_consumer-0.15.0/src/tree.rs:274:19
   5: accesskit_unix::adapter::Adapter::new
             at /home/olivier/.cargo/registry/src/index.crates.io-6f17d22bba15001f/accesskit_unix-0.5.0/src/adapter.rs:53:20
   6: accesskit_winit::platform_impl::platform::Adapter::new
             at /home/olivier/.cargo/registry/src/index.crates.io-6f17d22bba15001f/accesskit_winit-0.14.1/src/platform_impl/unix.rs:21:23
   7: accesskit_winit::Adapter::with_action_handler
             at /home/olivier/.cargo/registry/src/index.crates.io-6f17d22bba15001f/accesskit_winit-0.14.1/src/lib.rs:170:23
   8: i_slint_backend_winit::accesskit::AccessKitAdapter::new
             at ./accesskit.rs:62:20
   9: i_slint_backend_winit::winitwindowadapter::WinitWindowAdapter:🆕:{{closure}}
             at ./winitwindowadapter.rs:163:32
  10: alloc::rc::Rc<T>::new_cyclic
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/rc.rs:461:20
  11: i_slint_backend_winit::winitwindowadapter::WinitWindowAdapter::new
             at ./winitwindowadapter.rs:148:23
  12: i_slint_backend_winit::window_factory_fn
             at ./lib.rs:71:5
  13: <i_slint_backend_winit::Backend as i_slint_core::platform::Platform>::create_window_adapter
             at ./lib.rs:220:9
```

The problem is that we get called to create the tree directly from
WinitWindowAdapter::new before the WinitWindowAdaptor is initialized,
So of course, the upgrade from weak is still the pseudo-weak from
Rc::new_cyclic, so the upgrade fails, resulting in a default constructed
`TreeUpdate` which is invalid for the first call as it doesn't have a
tree.

Just give it a tree with a dummy id
2023-07-07 12:51:44 +02:00
Olivier Goffart
9afadf50be Get rid of the "use_modules" workaround
This doesn't seem to be needed anymore with newer rust version.
As long as one symbol from the crate is used, all exported function
from the crate are available.

The reason why some symbols in some module were gone was a bug in rust
that has been fixed, it seems
2023-07-05 13:41:06 +02:00
Guilhem Vallat
6845fc2e4e remove clippy::new_ret_no_self warning 2023-06-30 12:28:13 +02:00
Guilhem Vallat
555e191ab4 remove clippy::needless_borrow warnings 2023-06-30 12:28:13 +02:00
Guilhem Vallat
67493a4f3c remove clippy::new-without-default warnings 2023-06-30 12:28:13 +02:00
Guilhem Vallat
d27e0a4852 micro-optim ItemRc::component() returns a ref instead of cloning 2023-06-29 12:38:54 +02:00
Olivier Goffart
734a5b888c Improve winit's backend documentation 2023-06-28 17:08:12 +02:00
Olivier Goffart
7464c0897e Winit don't need a rtti feature 2023-06-28 17:08:12 +02:00
Tobias Hunger
e81a3d40f0 Get rid of more clippy warnings
* Configure clippy to not report about type complexity until *much*
  later
* Configure clippy to only complain about more than 10 function
  arguments
* Properly format safety sections
* Allow unnecessary main functions in doctests in the slint API crate
* AccessKit: Move big block of code before if condition
2023-06-28 14:22:30 +02:00
Tobias Hunger
e02c360000 Clippy polish 2023-06-28 14:22:30 +02:00
Tobias Hunger
8345c6cd79 Do automatic clippy fixes 2023-06-28 14:22:30 +02:00
ogoffart
c8c9496722 Bump version number to 1.1.1 2023-06-26 12:50:02 +00:00
Olivier Goffart
9b59036816 Add licenses symlinks 2023-06-26 13:12:29 +02:00
Olivier Goffart
5fde19d111 winit: cache the size returned by inner_size
So that subsequent call to Window::size() return the same value

Should fix flickering of window size at startup
2023-06-26 12:37:30 +02:00
Simon Hausmann
4820d29bcb Fix macOS lsp bundle
Avoid duplicating the core-graphics crate, as that leads to linking
errors about duplicate emissions of the cg_event_tap_callback_internal
helper function from the core-graphics crate.

This partially reverts commit d91622d64f

In order to re-apply d91622d64f, winit
needs to release a new version first.
2023-06-23 07:40:43 +02:00
Simon Hausmann
d91622d64f Bump cocoa and core-text dependencies 2023-06-22 08:11:16 +02:00
Simon Hausmann
a181fe0196 Port to softbuffer 0.3.0 2023-06-22 08:11:16 +02:00
Olivier Goffart
613992d0dc LSP: fix errors or panic when exiting
Two problem:
 1. we were calling quit_event_loop from another thread, which didn't
    work with winit
 2. we need to ignore error from the lsp-server when shutdown as it may
    result in https://github.com/slint-ui/slint-cpp-template/issues/15

Closes https://github.com/slint-ui/slint-cpp-template/issues/15
2023-06-21 16:34:16 +02:00
Olivier Goffart
38879ce1b9 Wasm: initialize properly the WinitWindowAdapter::self_weak
This fixes keyboard input on mobile
2023-06-19 18:27:23 +02:00
Simon Hausmann
74ae79bca7 winit: Fall back to any renderer if the default fails
Fixes #2903
2023-06-16 12:52:15 +02:00
Simon Hausmann
7c36121082 Sanity check that the OpenGL context we have provides what we need
On Windows without OpenGL, wgl might succeed all the way, but get_proc_address will fail.
2023-06-16 12:52:15 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Tobias Hunger
34fd360576 Fix license information in accesskit 2023-06-16 09:14:20 +02:00
Tobias Hunger
04d1229685 Fix licnese information using xtask 2023-06-16 09:14:20 +02:00
ogoffart
641cab0e75 Bump version number to 1.1.0 2023-06-15 16:01:28 +00:00
Simon Hausmann
5efbbeff1a Fix panic with Narrator on Windows when transferring narrator focus
The action requests on Windows typically come in from a non-main thread,
so we'd try to clone the send wrapper in `do_action`
in a non-main thread. That panics unfortunately - send-wrapper
requires the clone to be done in the original thread.

To work around this, wrap the send-wrapper in an Arc, which we can
safely clone. Then inside the closure invoked from within the main thread,
we can clone the send wrapper safely and then take out the Weak
from it (safely as well).
2023-06-15 13:20:14 +02:00
Matt Campbell
6db6711e12 New scheme for stable node IDs 2023-06-15 13:20:14 +02:00
Simon Hausmann
2e7cc49567 Initial AccessKit support
This change adds initial accessibility support for the winit backend
through use of AccessKit.
2023-06-15 13:20:14 +02:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Olivier Goffart
4dd10f4a78 Make WindowAdaptor::request_redraw public 2023-06-13 20:29:52 +02:00
Olivier Goffart
0e31f097a4 Un-seal the WindowAdapter trait 2023-06-13 17:44:04 +02:00
Olivier Goffart
23b910725f Rename WindowAdapterSealed to WindowAdapterInternal 2023-06-13 17:44:04 +02:00
Olivier Goffart
6341769cbd WindowAdaptor: move a few function to the public trait
Note: the addition of MinimalSoftwareWindow::set_size is there because
it would be a breaking change for user who called set_size on the
MinimalSoftwareWindow while also using the WindowAdapter trait.
This was the case of a test.
The same problem theorically exist with set_position and position, but
is unlikely to be a problem because i don't think people would use the
position with a MinimalSoftwareWindow

The renderer() is now public as well. That's because I want to make sure
that the scealed trait don't have non-provided method
2023-06-13 17:44:04 +02:00
Olivier Goffart
5f84cd5a90 Change the return type of WindowAdapterSealed::position to be an Option 2023-06-12 19:25:33 +02:00
Simon Hausmann
fb1d37286f Clean up the Skia renderer API
Accept display and window handles with life time, instead of &dyn
HasRaw*Handle.
2023-06-07 12:20:57 +02:00
Simon Hausmann
af6b49a47d Simplify FemtoVG renderer API
For wasm builds, just require the canvas element.
2023-06-07 11:30:43 +02:00
Simon Hausmann
2b891b6097 winit: Remove the html canvas element from the GL context
It's not needed anymore. We can pass the canvas
element to the renderer once
and then we don't need it anymore.
2023-06-07 11:30:43 +02:00