Skip to content

Commit dcc96a7

Browse files
committed
Actually allow windows to be upcasted
1 parent 3a3dc58 commit dcc96a7

File tree

9 files changed

+33
-3
lines changed

9 files changed

+33
-3
lines changed

src/platform_impl/android/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,10 @@ impl CoreWindow for Window {
985985
}
986986

987987
fn reset_dead_keys(&self) {}
988+
989+
fn as_surface(&self) -> &dyn CoreSurface {
990+
self
991+
}
988992
}
989993

990994
#[derive(Default, Clone, Debug)]

src/platform_impl/apple/appkit/window.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ impl CoreWindow for Window {
338338
fn show_window_menu(&self, position: Position) {
339339
self.maybe_wait_on_main(|delegate| delegate.show_window_menu(position))
340340
}
341+
342+
fn as_surface(&self) -> &dyn CoreSurface {
343+
self
344+
}
341345
}
342346

343347
declare_class!(

src/platform_impl/apple/uikit/window.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,10 @@ impl CoreWindow for Window {
830830
fn show_window_menu(&self, position: Position) {
831831
self.maybe_wait_on_main(|delegate| delegate.show_window_menu(position))
832832
}
833+
834+
fn as_surface(&self) -> &dyn CoreSurface {
835+
self
836+
}
833837
}
834838

835839
// WindowExtIOS

src/platform_impl/linux/wayland/window/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,10 @@ impl CoreWindow for Window {
664664
let position = position.to_logical(scale_factor);
665665
self.window_state.lock().unwrap().show_window_menu(position);
666666
}
667+
668+
fn as_surface(&self) -> &dyn CoreSurface {
669+
self
670+
}
667671
}
668672

669673
/// The request from the window to the event loop.

src/platform_impl/linux/x11/window.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ impl CoreWindow for Window {
309309
fn show_window_menu(&self, position: Position) {
310310
self.0.show_window_menu(position);
311311
}
312+
313+
fn as_surface(&self) -> &dyn CoreSurface {
314+
self
315+
}
312316
}
313317

314318
#[cfg(feature = "rwh_06")]

src/platform_impl/orbital/window.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ impl CoreWindow for Window {
464464
fn set_theme(&self, _theme: Option<window::Theme>) {}
465465

466466
fn set_content_protected(&self, _protected: bool) {}
467+
468+
fn as_surface(&self) -> &dyn CoreSurface {
469+
self
470+
}
467471
}
468472

469473
#[cfg(feature = "rwh_06")]

src/platform_impl/web/window.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ impl RootWindow for Window {
390390
}
391391

392392
fn show_window_menu(&self, _: Position) {}
393+
394+
fn as_surface(&self) -> &dyn CoreSurface {
395+
self
396+
}
393397
}
394398

395399
#[cfg(feature = "rwh_06")]

src/platform_impl/windows/window.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,10 @@ impl CoreWindow for Window {
10681068
);
10691069
}
10701070
}
1071+
1072+
fn as_surface(&self) -> &dyn CoreSurface {
1073+
self
1074+
}
10711075
}
10721076

10731077
pub(super) struct InitData<'a> {

src/window.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,9 +1310,7 @@ pub trait Window: Surface {
13101310
fn show_window_menu(&self, position: Position);
13111311

13121312
/// Upcasts this `Window` to a [`Surface`].
1313-
fn as_surface(&self) -> &dyn Surface where Self: Sized {
1314-
self
1315-
}
1313+
fn as_surface(&self) -> &dyn Surface;
13161314
}
13171315

13181316
impl dyn Window {

0 commit comments

Comments
 (0)