Skip to content

Commit

Permalink
janitor: Rename GLWindow to WinitWindowAdapter
Browse files Browse the repository at this point in the history
It's no more an "OpenGL Window", it's the type that adapts winit to our windowing
system abstraction.
  • Loading branch information
tronical committed Apr 5, 2023
1 parent 09fc401 commit ab05168
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/backends/winit/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub enum CustomEvent {
WakeEventLoopWorkaround,
UpdateWindowProperties(winit::window::WindowId),
UserEvent(Box<dyn FnOnce() + Send>),
/// Called from `GLWindow::hide` so that we can check if we should quit the event loop
/// Sent from `WinitWindowAdapter::hide` so that we can check if we should quit the event loop
WindowHidden,
Exit,
}
Expand Down
8 changes: 4 additions & 4 deletions internal/backends/winit/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use i_slint_core::window::WindowAdapter;
use renderer::WinitCompatibleRenderer;
use std::rc::Rc;

mod glwindow;
use glwindow::*;
mod winitwindowadapter;
use i_slint_core::platform::PlatformError;
use winitwindowadapter::*;
pub(crate) mod event_loop;

mod renderer {
Expand Down Expand Up @@ -61,11 +61,11 @@ pub(crate) mod wasm_input_helper;

#[cfg(target_arch = "wasm32")]
pub fn create_gl_window_with_canvas_id(canvas_id: String) -> Rc<dyn WindowAdapter> {
GLWindow::<crate::renderer::femtovg::GlutinFemtoVGRenderer>::new(canvas_id)
WinitWindowAdapter::<crate::renderer::femtovg::GlutinFemtoVGRenderer>::new(canvas_id)
}

fn window_factory_fn<R: WinitCompatibleRenderer + 'static>() -> Rc<dyn WindowAdapter> {
GLWindow::<R>::new(
WinitWindowAdapter::<R>::new(
#[cfg(target_arch = "wasm32")]
"canvas".into(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn window_is_resizable(min_size: Option<LogicalSize>, max_size: Option<LogicalSi

/// GraphicsWindow is an implementation of the [WindowAdapter][`crate::eventloop::WindowAdapter`] trait. This is
/// typically instantiated by entry factory functions of the different graphics back ends.
pub(crate) struct GLWindow<Renderer: WinitCompatibleRenderer + 'static> {
pub(crate) struct WinitWindowAdapter<Renderer: WinitCompatibleRenderer + 'static> {
window: corelib::api::Window,
self_weak: Weak<Self>,
map_state: RefCell<GraphicsWindowBackendState>,
Expand All @@ -115,7 +115,7 @@ pub(crate) struct GLWindow<Renderer: WinitCompatibleRenderer + 'static> {
virtual_keyboard_helper: RefCell<Option<super::wasm_input_helper::WasmInputHelper>>,
}

impl<Renderer: WinitCompatibleRenderer + 'static> GLWindow<Renderer> {
impl<Renderer: WinitCompatibleRenderer + 'static> WinitWindowAdapter<Renderer> {
/// Creates a new reference-counted instance.
///
/// Arguments:
Expand Down Expand Up @@ -213,7 +213,7 @@ impl<Renderer: WinitCompatibleRenderer + 'static> GLWindow<Renderer> {
}
}

impl<Renderer: WinitCompatibleRenderer + 'static> WinitWindow for GLWindow<Renderer> {
impl<Renderer: WinitCompatibleRenderer + 'static> WinitWindow for WinitWindowAdapter<Renderer> {
fn take_pending_redraw(&self) -> bool {
self.pending_redraw.take()
}
Expand Down Expand Up @@ -287,13 +287,15 @@ impl<Renderer: WinitCompatibleRenderer + 'static> WinitWindow for GLWindow<Rende
}
}

impl<Renderer: WinitCompatibleRenderer + 'static> WindowAdapter for GLWindow<Renderer> {
impl<Renderer: WinitCompatibleRenderer + 'static> WindowAdapter for WinitWindowAdapter<Renderer> {
fn window(&self) -> &corelib::api::Window {
&self.window
}
}

impl<Renderer: WinitCompatibleRenderer + 'static> WindowAdapterSealed for GLWindow<Renderer> {
impl<Renderer: WinitCompatibleRenderer + 'static> WindowAdapterSealed
for WinitWindowAdapter<Renderer>
{
fn request_redraw(&self) {
self.pending_redraw.set(true);
self.with_window_handle(&mut |window| window.request_redraw())
Expand Down Expand Up @@ -785,7 +787,7 @@ impl<Renderer: WinitCompatibleRenderer + 'static> WindowAdapterSealed for GLWind
}
}

impl<Renderer: WinitCompatibleRenderer + 'static> Drop for GLWindow<Renderer> {
impl<Renderer: WinitCompatibleRenderer + 'static> Drop for WinitWindowAdapter<Renderer> {
fn drop(&mut self) {
self.unmap().expect("winit backend: error unmapping window");
}
Expand Down

0 comments on commit ab05168

Please sign in to comment.