-
Notifications
You must be signed in to change notification settings - Fork 903
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
api: convert Window
to dyn Window
#3857
Conversation
I was briefly considering if we should wrap
AFAIK you can't implement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the PR isn't ready but I went ahead and implemented Web anyway just to see how everything would work out.
Its a shame about the loss of generics, but again could be resolved by adding a Window
type wrapper in the future?
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really in the loop, is the plan to keep the maybe_queue_on_main
/maybe_wait_on_main
and Send + Sync
, or are we getting rid of that?
Because if we're getting rid of it, I'd prefer to do that first, to keep the platform-specific diff smaller (otherwise we'll end up with one commit moving them to web
/appkit
/uikit
, and one commit removing them again, which is a lot of indentation changes).
The plan was to expose |
I think you can keep the diff small, but I can not make the window |
d568280
to
5103e3b
Compare
I have no idea whether what I did to |
The PR should be ready and every backend is implemented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still a little unsure about the API changes, but let's discuss it synchronously
let parent_window = self.windows.get(&self.parent_window_id.unwrap()).unwrap(); | ||
let child_window = spawn_child_window(parent_window, event_loop); | ||
let child_window = spawn_child_window(parent_window.as_ref(), event_loop); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Use &parent_window
to auto-deref the value instead (I think that works, at least)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about &*parent_window
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, I guess you have to do exactly the same as we do with the ApplicationHandler
and all the generic impls over there, I don't mind them, but I'll leave it to follow-up, since there's a chance that none of these as_ref
will be needed once we figure out how we actually store the window for the end user.
src/window.rs
Outdated
/// Create a new [`WindowAttributes`] which allows modifying the window's attributes before | ||
/// creation. | ||
#[inline] | ||
pub fn default_attributes() -> WindowAttributes { | ||
fn default_attributes() -> WindowAttributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be:
impl dyn Window {
pub fn default_attributes() -> ...
}
// Usage: <dyn Window>::default_attributes()
Or just removed entirely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated.
|
||
self.window.maybe_queue_on_main(move |w| w.set_outer_position(position)) | ||
} | ||
fn set_outer_position(&self, position: Position); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really quite unfortunate that we loose the ability to have impl Into<...>
parameters.
I feel like there's ways that we could probably make it work, my initial attempt is here, I'll also link the explanation for erased-serde
, there might be some useful information in there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll leave it if it really become a problem, but nice to remember.
97f4c74
to
1644c06
Compare
1644c06
to
6f3d1f8
Compare
This should allow us to make future split of backends much easier. The `Box<dyn Window>` is a _temporary_ solution, which will be removed with the future updates when we decide on how the Window should be stored.
6f3d1f8
to
c11e088
Compare
--
The only issue right now is how to deal with
maybe_queue_on_main
andmaybe_block_on_main
. From what I can say the backends should do that themselves for the time being, since it's a temporary peace unless we remove theSend
andSync
from the window.I've only did the Wayland backend and
examples/window.rs
to show how it may look.I'd assume @daxpedda will do for
MonitorHandle
(trait is not really needed since data is used) and after that it should be pretty much ready to split backends.The only issue I see is that we can not use generics, since they prevent object safety.
The
Drop
impl we had should also be done for backends, since it's a backend specific behavior and clearly not needed on most of the backends. Though, I've kept it to simple not forget about it.