Skip to content

Commit

Permalink
Actually allow windows to be upcasted
Browse files Browse the repository at this point in the history
  • Loading branch information
jgcodes2020 committed Oct 24, 2024
1 parent 3a3dc58 commit dcc96a7
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,10 @@ impl CoreWindow for Window {
}

fn reset_dead_keys(&self) {}

fn as_surface(&self) -> &dyn CoreSurface {
self
}
}

#[derive(Default, Clone, Debug)]
Expand Down
4 changes: 4 additions & 0 deletions src/platform_impl/apple/appkit/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ impl CoreWindow for Window {
fn show_window_menu(&self, position: Position) {
self.maybe_wait_on_main(|delegate| delegate.show_window_menu(position))
}

fn as_surface(&self) -> &dyn CoreSurface {
self
}
}

declare_class!(
Expand Down
4 changes: 4 additions & 0 deletions src/platform_impl/apple/uikit/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,10 @@ impl CoreWindow for Window {
fn show_window_menu(&self, position: Position) {
self.maybe_wait_on_main(|delegate| delegate.show_window_menu(position))
}

fn as_surface(&self) -> &dyn CoreSurface {
self
}
}

// WindowExtIOS
Expand Down
4 changes: 4 additions & 0 deletions src/platform_impl/linux/wayland/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,10 @@ impl CoreWindow for Window {
let position = position.to_logical(scale_factor);
self.window_state.lock().unwrap().show_window_menu(position);
}

fn as_surface(&self) -> &dyn CoreSurface {
self
}
}

/// The request from the window to the event loop.
Expand Down
4 changes: 4 additions & 0 deletions src/platform_impl/linux/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ impl CoreWindow for Window {
fn show_window_menu(&self, position: Position) {
self.0.show_window_menu(position);
}

fn as_surface(&self) -> &dyn CoreSurface {
self
}
}

#[cfg(feature = "rwh_06")]
Expand Down
4 changes: 4 additions & 0 deletions src/platform_impl/orbital/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ impl CoreWindow for Window {
fn set_theme(&self, _theme: Option<window::Theme>) {}

fn set_content_protected(&self, _protected: bool) {}

fn as_surface(&self) -> &dyn CoreSurface {
self
}
}

#[cfg(feature = "rwh_06")]
Expand Down
4 changes: 4 additions & 0 deletions src/platform_impl/web/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ impl RootWindow for Window {
}

fn show_window_menu(&self, _: Position) {}

fn as_surface(&self) -> &dyn CoreSurface {
self
}
}

#[cfg(feature = "rwh_06")]
Expand Down
4 changes: 4 additions & 0 deletions src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,10 @@ impl CoreWindow for Window {
);
}
}

fn as_surface(&self) -> &dyn CoreSurface {
self
}
}

pub(super) struct InitData<'a> {
Expand Down
4 changes: 1 addition & 3 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,9 +1310,7 @@ pub trait Window: Surface {
fn show_window_menu(&self, position: Position);

/// Upcasts this `Window` to a [`Surface`].
fn as_surface(&self) -> &dyn Surface where Self: Sized {
self
}
fn as_surface(&self) -> &dyn Surface;
}

impl dyn Window {
Expand Down

0 comments on commit dcc96a7

Please sign in to comment.