-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expose window as RawWindowHandle #877
Comments
…st for sixtyfps::Window RWH is the de-facto standard crate in Rust to express window handles (and associated windowing system connections). This should be safe to use in the public API. This patch implements RWH for the GL backend. cc #877
I pushed a WIP - see linked commit/branch. The Qt implementation is missing, which is a bit of work, but quite doable I think. In C++ we can get the window handle for a |
…st for sixtyfps::Window RWH is the de-facto standard crate in Rust to express window handles (and associated windowing system connections). This should be safe to use in the public API. This patch implements RWH for the GL backend. cc #877
…st for sixtyfps::Window RWH is the de-facto standard crate in Rust to express window handles (and associated windowing system connections). This should be safe to use in the public API. This patch implements RWH for the GL backend. cc #877
@tronical I couldn't find this code in the current Slint UI release. I'm guessing it was never finished? |
Right, this was not yet merged to the master branch. |
I had another look at this and this is not so easy as it looked originally:
|
consumer APIFrom the consumer point of view, we have two option:
platform APIThen from the platform point of view, we need to extend the WindowAdapter trait in some way.
I wonder if this should be just one function, or two functions for the window and display handle. The example bellow use one function with a tuple, but it would be changed. trait WindowAdapter {
fn raw_handle(&self) -> (Option<&dyn HasRawWindowHandle>, Option<&dyn HasRawDisplayHandle>)
{ ... }
} With such API, one would typically implement Has*Handle for the struct that implements WindowAdapter and just return self. But that means that the platform need to be unsafe. trait WindowAdapter {
fn raw_handle(&self) -> (Option<Rc<dyn HasRawWindowHandle>>, Option<Rc<dyn HasRawDisplayHandle>>)
{ ... }
} That would work fine for the winit platform when we keep a Rcwinit::Window. But otherwise we have the risk that we'd need to make an allocation just to put the return value in the Rc. Also the returned struct must have a 'static lifetime. trait WindowAdapter {
type RawHandle<'a> : HasRawWindowHandle + HasRawDisplayHandle;
fn raw_handle<'a>(&'a self) -> Self::RawHandle<'a>;
} But since there is no default for associated types, we can't make it optional. (Looking forward for the return impl in trait)
trait WindowAdapter {
fn raw_handle(callback: &mut dyn FnMut(&dyn HasRawWindowHandle, &dyn HasRawDisplayHandle)) {}
} I think i'd go with 2 at first |
any progress? |
We're trying to sort out how to model the RWH api with the interior mutability of the winit window owner. Meanwhile #2617 adds API to the i-slint-backend-winit crate to provide you with access to the winit window and consequently the RWH. Can you give it a try? |
Add a `rwh_06` feature to the Rust API crates, which adds support for version 0.6 of rwh to slint::Window, by delegation to the backend. HasDisplayHandle could also be provided on the backend, but that can be done separately if needed. Fixes #877
Add a `rwh_06` feature to the Rust API crates, which adds support for version 0.6 of rwh to slint::Window, by delegation to the backend. HasDisplayHandle could also be provided on the backend, but that can be done separately if needed. This is only implemented for the winit backend right now. Fixes #877
Add a `rwh_06` feature to the Rust API crates, which adds support for version 0.6 of rwh to slint::Window, by delegation to the backend. HasDisplayHandle could also be provided on the backend, but that can be done separately if needed. This is only implemented for the winit backend right now. Fixes #877
Add a `raw-window-handle-06` feature to the Rust API crates, which adds support for version 0.6 of rwh to slint::Window, by delegation adding a `window_handle()` function that returns a struct that implements the corresponding traits from rwh. HasDisplayHandle could also be provided on the backend, but that can be done separately if needed. This is only implemented for the winit backend right now. cc #877
For Qt, commit db9b6a5 in the Slint repo attempts to implement RHW support for the Qt backend. This works on macOS and Windows, but requires the use of private API. For Linux, the same could be done, but that kind of sucks because it means it can't be easily compiled against Linux distro package, which typically don't install private Qt headers. One workaround would be to use QWindow::winId() and cast accordingly. By looking at the public So for now, I'll leave the Qt backend. If you need RWH support, the use of the winit backend is required. |
RawWindowHandle is a cross platform API for window handles. Some libraries like rfd can make use of a RawWindowHandle (in rfd's case, to parent a popup dialog to the appropriate window).
The text was updated successfully, but these errors were encountered: