refactor: minor refactor

WIP/draft
drendog 2024-08-14 23:24:41 +02:00
parent 0910670518
commit 3554b1684d
Signed by: dwenya
GPG Key ID: 8DD77074645332D0
8 changed files with 96 additions and 94 deletions

View File

@ -6,13 +6,13 @@ pub struct LayerSize {
} }
impl LayerSize { impl LayerSize {
pub fn new(width: u32, height: u32) -> Self { pub const fn new(width: u32, height: u32) -> Self {
Self { Self {
size: PhysicalSize::new(width, height), size: PhysicalSize::new(width, height),
} }
} }
pub fn physical_size(&self) -> PhysicalSize { pub const fn physical_size(self) -> PhysicalSize {
self.size self.size
} }
} }

View File

@ -2,4 +2,4 @@ mod common;
mod rendering; mod rendering;
mod windowing; mod windowing;
pub use windowing::WindowingSystemBuilder; pub use windowing::WindowingSystemBuilder as LayerShika;

View File

@ -36,7 +36,7 @@ pub struct EGLContextBuilder {
#[allow(dead_code)] #[allow(dead_code)]
impl EGLContextBuilder { impl EGLContextBuilder {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Self::default()
} }
pub fn with_display_id(mut self, display_id: ObjectId) -> Self { pub fn with_display_id(mut self, display_id: ObjectId) -> Self {
@ -49,17 +49,20 @@ impl EGLContextBuilder {
self self
} }
pub fn with_size(mut self, size: LayerSize) -> Self { pub const fn with_size(mut self, size: LayerSize) -> Self {
self.size = Some(size); self.size = Some(size);
self self
} }
pub fn with_config_template(mut self, config_template: ConfigTemplateBuilder) -> Self { pub const fn with_config_template(mut self, config_template: ConfigTemplateBuilder) -> Self {
self.config_template = Some(config_template); self.config_template = Some(config_template);
self self
} }
pub fn with_context_attributes(mut self, context_attributes: ContextAttributesBuilder) -> Self { pub const fn with_context_attributes(
mut self,
context_attributes: ContextAttributesBuilder,
) -> Self {
self.context_attributes = Some(context_attributes); self.context_attributes = Some(context_attributes);
self self
} }
@ -73,7 +76,7 @@ impl EGLContextBuilder {
.ok_or_else(|| anyhow!("Surface ID is required"))?; .ok_or_else(|| anyhow!("Surface ID is required"))?;
let size = self.size.ok_or_else(|| anyhow!("Size is required"))?; let size = self.size.ok_or_else(|| anyhow!("Size is required"))?;
let display_handle = create_wayland_display_handle(display_id); let display_handle = create_wayland_display_handle(&display_id);
let glutin_display = unsafe { Display::new(display_handle) }?; let glutin_display = unsafe { Display::new(display_handle) }?;
let config_template = self.config_template.unwrap_or_default(); let config_template = self.config_template.unwrap_or_default();
@ -84,7 +87,7 @@ impl EGLContextBuilder {
let context = create_context(&glutin_display, &config, context_attributes)?; let context = create_context(&glutin_display, &config, context_attributes)?;
let surface_handle = create_surface_handle(surface_id); let surface_handle = create_surface_handle(&surface_id);
let surface = create_surface(&glutin_display, &config, surface_handle, size)?; let surface = create_surface(&glutin_display, &config, surface_handle, size)?;
let context = context let context = context
@ -108,9 +111,9 @@ impl EGLContext {
} }
} }
fn create_wayland_display_handle(display_id: ObjectId) -> RawDisplayHandle { fn create_wayland_display_handle(display_id: &ObjectId) -> RawDisplayHandle {
let display = let display = NonNull::new(display_id.as_ptr().cast::<c_void>())
NonNull::new(display_id.as_ptr() as *mut c_void).expect("NonNull pointer creation failed"); .expect("NonNull pointer creation failed");
let handle = WaylandDisplayHandle::new(display); let handle = WaylandDisplayHandle::new(display);
RawDisplayHandle::Wayland(handle) RawDisplayHandle::Wayland(handle)
} }
@ -133,9 +136,9 @@ fn create_context(
.map_err(|e| anyhow!("Failed to create context: {}", e)) .map_err(|e| anyhow!("Failed to create context: {}", e))
} }
fn create_surface_handle(surface_id: ObjectId) -> RawWindowHandle { fn create_surface_handle(surface_id: &ObjectId) -> RawWindowHandle {
let surface = let surface = NonNull::new(surface_id.as_ptr().cast::<c_void>())
NonNull::new(surface_id.as_ptr() as *mut c_void).expect("NonNull pointer creation failed"); .expect("NonNull pointer creation failed");
let handle = WaylandWindowHandle::new(surface); let handle = WaylandWindowHandle::new(surface);
RawWindowHandle::Wayland(handle) RawWindowHandle::Wayland(handle)
} }

View File

@ -21,7 +21,7 @@ impl FemtoVGWindow {
Self { Self {
window, window,
renderer, renderer,
is_dirty: Default::default(), is_dirty: Cell::default(),
size: Cell::new(PhysicalSize::default()), size: Cell::new(PhysicalSize::default()),
scale_factor: Cell::new(1.), scale_factor: Cell::new(1.),
} }
@ -31,7 +31,7 @@ impl FemtoVGWindow {
pub fn render_frame_if_dirty(&self) { pub fn render_frame_if_dirty(&self) {
if self.is_dirty.get() { if self.is_dirty.get() {
match self.renderer.render() { match self.renderer.render() {
Ok(_) => {} //log::debug!("Frame rendered successfully"), Ok(()) => {} //log::debug!("Frame rendered successfully"),
Err(e) => log::error!("Error rendering frame: {}", e), Err(e) => log::error!("Error rendering frame: {}", e),
} }
self.is_dirty.set(false); self.is_dirty.set(false);

View File

@ -1,3 +1,4 @@
use super::state::WindowState;
use crate::impl_empty_dispatch; use crate::impl_empty_dispatch;
use log::info; use log::info;
use slint::platform::{PointerEventButton, WindowEvent}; use slint::platform::{PointerEventButton, WindowEvent};
@ -7,6 +8,7 @@ use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::{
}; };
use std::rc::Rc; use std::rc::Rc;
use std::{cell::RefCell, rc::Weak}; use std::{cell::RefCell, rc::Weak};
use wayland_client::WEnum;
use wayland_client::{ use wayland_client::{
globals::GlobalListContents, globals::GlobalListContents,
protocol::{ protocol::{
@ -17,12 +19,9 @@ use wayland_client::{
wl_seat::WlSeat, wl_seat::WlSeat,
wl_surface::WlSurface, wl_surface::WlSurface,
}, },
Connection, Dispatch, QueueHandle, Connection, Dispatch, Proxy, QueueHandle,
}; };
use super::state::WindowState;
#[derive(Clone)]
pub struct WindowEventHandler { pub struct WindowEventHandler {
state: Weak<RefCell<WindowState>>, state: Weak<RefCell<WindowState>>,
} }
@ -36,7 +35,7 @@ impl WindowEventHandler {
self.state.upgrade().unwrap() self.state.upgrade().unwrap()
} }
fn handle_pointer_enter(&mut self, surface_x: f64, surface_y: f64) { fn handle_pointer_enter(&self, surface_x: f64, surface_y: f64) {
if let Some(state) = self.state.upgrade() { if let Some(state) = self.state.upgrade() {
state state
.borrow() .borrow()
@ -50,7 +49,7 @@ impl WindowEventHandler {
} }
} }
fn handle_pointer_leave(&mut self) { fn handle_pointer_leave(&self) {
if let Some(state) = self.state.upgrade() { if let Some(state) = self.state.upgrade() {
if let Some(window) = state.borrow().window() { if let Some(window) = state.borrow().window() {
window.dispatch_event(WindowEvent::PointerExited); window.dispatch_event(WindowEvent::PointerExited);
@ -58,7 +57,7 @@ impl WindowEventHandler {
} }
} }
fn handle_pointer_motion(&mut self, surface_x: f64, surface_y: f64) { fn handle_pointer_motion(&self, surface_x: f64, surface_y: f64) {
if let Some(state) = self.state.upgrade() { if let Some(state) = self.state.upgrade() {
state state
.borrow() .borrow()
@ -72,15 +71,9 @@ impl WindowEventHandler {
} }
} }
fn handle_pointer_button( fn handle_pointer_button(&self, button_state: wayland_client::WEnum<wl_pointer::ButtonState>) {
&mut self,
button_state: wayland_client::WEnum<wl_pointer::ButtonState>,
) {
if let Some(state) = self.state.upgrade() { if let Some(state) = self.state.upgrade() {
let is_press = matches!( let is_press = matches!(button_state, WEnum::Value(wl_pointer::ButtonState::Pressed));
button_state,
wayland_client::WEnum::Value(wl_pointer::ButtonState::Pressed)
);
let current_position = state.borrow().current_pointer_position(); let current_position = state.borrow().current_pointer_position();
if let Some(window) = state.borrow().window() { if let Some(window) = state.borrow().window() {
let event = if is_press { let event = if is_press {
@ -140,7 +133,7 @@ impl Dispatch<WlOutput, ()> for WindowEventHandler {
fn event( fn event(
state: &mut Self, state: &mut Self,
_proxy: &WlOutput, _proxy: &WlOutput,
event: <WlOutput as wayland_client::Proxy>::Event, event: <WlOutput as Proxy>::Event,
_data: &(), _data: &(),
_conn: &Connection, _conn: &Connection,
_qhandle: &QueueHandle<Self>, _qhandle: &QueueHandle<Self>,
@ -150,7 +143,9 @@ impl Dispatch<WlOutput, ()> for WindowEventHandler {
info!("WlOutput size changed to {}x{}", width, height); info!("WlOutput size changed to {}x{}", width, height);
if let Some(state) = state.state.upgrade() { if let Some(state) = state.state.upgrade() {
let state_borrow = state.borrow(); let state_borrow = state.borrow();
state_borrow.set_output_size(width as u32, height as u32); let width = width.try_into().unwrap_or_default();
let height = height.try_into().unwrap_or_default();
state_borrow.set_output_size(width, height);
} }
} }
wl_output::Event::Description { ref description } => { wl_output::Event::Description { ref description } => {
@ -186,7 +181,7 @@ impl Dispatch<WlPointer, ()> for WindowEventHandler {
fn event( fn event(
state: &mut Self, state: &mut Self,
_proxy: &WlPointer, _proxy: &WlPointer,
event: <WlPointer as wayland_client::Proxy>::Event, event: <WlPointer as Proxy>::Event,
_data: &(), _data: &(),
_conn: &Connection, _conn: &Connection,
_qhandle: &QueueHandle<Self>, _qhandle: &QueueHandle<Self>,

View File

@ -1,6 +1,6 @@
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use log::{debug, error, info}; use log::{debug, error};
use smithay_client_toolkit::reexports::calloop::{self, EventLoop, Interest, Mode, PostAction}; use smithay_client_toolkit::reexports::calloop::{self, Interest, Mode, PostAction};
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
use wayland_client::{Connection, EventQueue}; use wayland_client::{Connection, EventQueue};
@ -44,7 +44,7 @@ impl EventLoopHandler {
loop_handle loop_handle
.insert_source( .insert_source(
calloop::generic::Generic::new(connection, Interest::READ, Mode::Level), calloop::generic::Generic::new(connection, Interest::READ, Mode::Level),
move |_, connection, _| { move |_, connection, ()| {
let result: Result<PostAction, anyhow::Error> = (|| { let result: Result<PostAction, anyhow::Error> = (|| {
let wayland_queue = wayland_queue let wayland_queue = wayland_queue
.upgrade() .upgrade()
@ -75,13 +75,6 @@ impl EventLoopHandler {
Ok(()) Ok(())
} }
pub fn run(&self, event_loop: &mut EventLoop<()>) -> Result<()> {
info!("Starting event loop");
event_loop
.run(None, &mut (), |_| {})
.map_err(|e| anyhow!("Failed to run event loop: {}", e))
}
fn handle_wayland_events( fn handle_wayland_events(
connection: &Connection, connection: &Connection,
wayland_queue: &Rc<RefCell<EventQueue<WindowEventHandler>>>, wayland_queue: &Rc<RefCell<EventQueue<WindowEventHandler>>>,

View File

@ -1,3 +1,11 @@
use self::{event_handler::WindowEventHandler, event_loop::EventLoopHandler, state::WindowState};
use crate::{
bind_globals,
common::LayerSize,
rendering::{
egl_context::EGLContext, femtovg_window::FemtoVGWindow, slint_platform::CustomSlintPlatform,
},
};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use log::{debug, info}; use log::{debug, info};
use slint::{platform::femtovg_renderer::FemtoVGRenderer, ComponentHandle, LogicalPosition}; use slint::{platform::femtovg_renderer::FemtoVGRenderer, ComponentHandle, LogicalPosition};
@ -19,21 +27,11 @@ use wayland_client::{
Connection, EventQueue, Proxy, QueueHandle, Connection, EventQueue, Proxy, QueueHandle,
}; };
use crate::{
bind_globals,
common::LayerSize,
rendering::{
egl_context::EGLContext, femtovg_window::FemtoVGWindow, slint_platform::CustomSlintPlatform,
},
};
mod event_handler; mod event_handler;
mod event_loop; mod event_loop;
mod macros; mod macros;
mod state; mod state;
use self::{event_handler::WindowEventHandler, event_loop::EventLoopHandler, state::WindowState};
pub struct WindowConfig { pub struct WindowConfig {
height: u32, height: u32,
layer: zwlr_layer_shell_v1::Layer, layer: zwlr_layer_shell_v1::Layer,
@ -43,7 +41,7 @@ pub struct WindowConfig {
exclusive_zone: i32, exclusive_zone: i32,
scale_factor: f32, scale_factor: f32,
namespace: String, namespace: String,
component_definition: Option<Rc<ComponentDefinition>>, component_definition: Option<ComponentDefinition>,
} }
impl Default for WindowConfig { impl Default for WindowConfig {
@ -55,7 +53,7 @@ impl Default for WindowConfig {
anchor: Anchor::Top | Anchor::Left | Anchor::Right, anchor: Anchor::Top | Anchor::Left | Anchor::Right,
keyboard_interactivity: KeyboardInteractivity::OnDemand, keyboard_interactivity: KeyboardInteractivity::OnDemand,
exclusive_zone: -1, exclusive_zone: -1,
namespace: "layer-sheeka".to_string(), namespace: "layer-shika".to_owned(),
scale_factor: 1.0, scale_factor: 1.0,
component_definition: None, component_definition: None,
} }
@ -73,53 +71,69 @@ impl Default for WindowingSystemBuilder {
} }
impl WindowingSystemBuilder { impl WindowingSystemBuilder {
#[must_use]
#[inline]
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
config: WindowConfig::default(), config: WindowConfig::default(),
} }
} }
pub fn with_height(mut self, height: u32) -> Self { #[must_use]
pub const fn with_height(mut self, height: u32) -> Self {
self.config.height = height; self.config.height = height;
self self
} }
pub fn with_layer(mut self, layer: zwlr_layer_shell_v1::Layer) -> Self { #[must_use]
#[inline]
pub const fn with_layer(mut self, layer: zwlr_layer_shell_v1::Layer) -> Self {
self.config.layer = layer; self.config.layer = layer;
self self
} }
pub fn with_margin(mut self, top: i32, right: i32, bottom: i32, left: i32) -> Self { #[must_use]
#[inline]
pub const fn with_margin(mut self, top: i32, right: i32, bottom: i32, left: i32) -> Self {
self.config.margin = (top, right, bottom, left); self.config.margin = (top, right, bottom, left);
self self
} }
#[must_use]
pub fn with_anchor(mut self, anchor: Anchor) -> Self { #[inline]
pub const fn with_anchor(mut self, anchor: Anchor) -> Self {
self.config.anchor = anchor; self.config.anchor = anchor;
self self
} }
#[must_use]
pub fn with_keyboard_interactivity(mut self, interactivity: KeyboardInteractivity) -> Self { #[inline]
pub const fn with_keyboard_interactivity(
mut self,
interactivity: KeyboardInteractivity,
) -> Self {
self.config.keyboard_interactivity = interactivity; self.config.keyboard_interactivity = interactivity;
self self
} }
#[must_use]
pub fn with_exclusive_zone(mut self, zone: i32) -> Self { #[inline]
pub const fn with_exclusive_zone(mut self, zone: i32) -> Self {
self.config.exclusive_zone = zone; self.config.exclusive_zone = zone;
self self
} }
#[must_use]
#[inline]
pub fn with_namespace(mut self, namespace: String) -> Self { pub fn with_namespace(mut self, namespace: String) -> Self {
self.config.namespace = namespace; self.config.namespace = namespace;
self self
} }
#[must_use]
pub fn with_scale_factor(mut self, scale_factor: f32) -> Self { #[inline]
pub const fn with_scale_factor(mut self, scale_factor: f32) -> Self {
self.config.scale_factor = scale_factor; self.config.scale_factor = scale_factor;
self self
} }
#[must_use]
pub fn with_component_definition(mut self, component: Rc<ComponentDefinition>) -> Self { #[inline]
pub fn with_component_definition(mut self, component: ComponentDefinition) -> Self {
self.config.component_definition = Some(component); self.config.component_definition = Some(component);
self self
} }
@ -185,7 +199,8 @@ impl<'a> WindowingSystem<'a> {
system.wait_for_configure()?; system.wait_for_configure()?;
system.initialize_renderer_and_ui()?; system.initialize_renderer_and_ui()?;
system.initialize_event_loop_handler()?; system.initialize_event_loop_handler();
system.setup_event_sources()?;
Ok(system) Ok(system)
} }
@ -253,14 +268,14 @@ impl<'a> WindowingSystem<'a> {
config.margin.2, config.margin.2,
config.margin.3, config.margin.3,
); );
println!("Setting exclusive zone: {}", config.exclusive_zone);
layer_surface.set_exclusive_zone(config.exclusive_zone); layer_surface.set_exclusive_zone(config.exclusive_zone);
layer_surface.set_keyboard_interactivity(config.keyboard_interactivity); layer_surface.set_keyboard_interactivity(config.keyboard_interactivity);
layer_surface.set_size(1, config.height); layer_surface.set_size(1, config.height);
surface.commit(); surface.commit();
} }
fn wait_for_configure(&mut self) -> Result<()> { fn wait_for_configure(&self) -> Result<()> {
info!("Waiting for surface to be configured..."); info!("Waiting for surface to be configured...");
loop { loop {
self.connection.flush()?; self.connection.flush()?;
@ -288,10 +303,10 @@ impl<'a> WindowingSystem<'a> {
.clone() .clone()
.ok_or_else(|| anyhow::anyhow!("Component definition not set"))?; .ok_or_else(|| anyhow::anyhow!("Component definition not set"))?;
let (window, component_instance) = let (window, component_instance) =
self.initialize_slint_ui(renderer, component_definition)?; self.initialize_slint_ui(renderer, &component_definition)?;
self.window = Some(window.clone()); self.window = Some(window.clone());
self.state.borrow_mut().set_window(Rc::downgrade(&window)); self.state.borrow_mut().set_window(window);
self.component_instance = Some(component_instance); self.component_instance = Some(component_instance);
Ok(()) Ok(())
@ -310,7 +325,7 @@ impl<'a> WindowingSystem<'a> {
.with_surface_id(surface.id()) .with_surface_id(surface.id())
.with_size(LayerSize::new(size.width, size.height)) .with_size(LayerSize::new(size.width, size.height))
.build() .build()
.context("Failed to build EGL context")?; .map_err(|e| anyhow::anyhow!("Failed to create EGL context: {:?}", e))?;
debug!("Creating FemtoVGRenderer"); debug!("Creating FemtoVGRenderer");
FemtoVGRenderer::new(context).context("Failed to create FemtoVGRenderer") FemtoVGRenderer::new(context).context("Failed to create FemtoVGRenderer")
@ -319,7 +334,7 @@ impl<'a> WindowingSystem<'a> {
fn initialize_slint_ui( fn initialize_slint_ui(
&self, &self,
renderer: FemtoVGRenderer, renderer: FemtoVGRenderer,
component_definition: Rc<ComponentDefinition>, component_definition: &ComponentDefinition,
) -> Result<(Rc<FemtoVGWindow>, Rc<ComponentInstance>)> { ) -> Result<(Rc<FemtoVGWindow>, Rc<ComponentInstance>)> {
let femtovg_window = FemtoVGWindow::new(renderer); let femtovg_window = FemtoVGWindow::new(renderer);
let size = self.state.borrow().size(); let size = self.state.borrow().size();
@ -343,7 +358,7 @@ impl<'a> WindowingSystem<'a> {
Ok((femtovg_window, slint_component)) Ok((femtovg_window, slint_component))
} }
pub fn initialize_event_loop_handler(&mut self) -> Result<()> { pub fn initialize_event_loop_handler(&mut self) {
let event_loop_handler = EventLoopHandler::new( let event_loop_handler = EventLoopHandler::new(
Rc::downgrade(self.window.as_ref().unwrap()), Rc::downgrade(self.window.as_ref().unwrap()),
Rc::downgrade(&self.event_queue), Rc::downgrade(&self.event_queue),
@ -352,7 +367,6 @@ impl<'a> WindowingSystem<'a> {
); );
self.event_loop_handler = Some(event_loop_handler); self.event_loop_handler = Some(event_loop_handler);
Ok(())
} }
pub fn setup_event_sources(&self) -> Result<()> { pub fn setup_event_sources(&self) -> Result<()> {
@ -377,12 +391,9 @@ impl<'a> WindowingSystem<'a> {
window.render_frame_if_dirty(); window.render_frame_if_dirty();
} }
let event_loop_handler = self self.event_loop
.event_loop_handler .run(None, &mut (), |()| {})
.as_ref() .map_err(|e| anyhow::anyhow!("Failed to run event loop: {}", e))
.ok_or_else(|| anyhow::anyhow!("EventLoopHandler not initialized"))?;
event_loop_handler.run(&mut self.event_loop)
} }
pub fn component_instance(&self) -> Option<Rc<ComponentInstance>> { pub fn component_instance(&self) -> Option<Rc<ComponentInstance>> {
@ -397,7 +408,7 @@ impl<'a> WindowingSystem<'a> {
self.state.clone() self.state.clone()
} }
pub fn display(&self) -> &WlDisplay { pub const fn display(&self) -> &WlDisplay {
&self.display &self.display
} }
} }

View File

@ -1,4 +1,4 @@
use std::{cell::Cell, rc::Weak}; use std::cell::Cell;
use std::rc::Rc; use std::rc::Rc;
use log::info; use log::info;
use slint::{LogicalPosition, PhysicalSize}; use slint::{LogicalPosition, PhysicalSize};
@ -14,7 +14,7 @@ pub struct WindowState {
size: Cell<PhysicalSize>, size: Cell<PhysicalSize>,
output_size: Cell<PhysicalSize>, output_size: Cell<PhysicalSize>,
pointer: Option<WlPointer>, pointer: Option<WlPointer>,
window: Option<Weak<FemtoVGWindow>>, window: Option<Rc<FemtoVGWindow>>,
current_pointer_position: Cell<LogicalPosition>, current_pointer_position: Cell<LogicalPosition>,
scale_factor: f32, scale_factor: f32,
height: u32, height: u32,
@ -54,7 +54,7 @@ impl WindowState {
} }
if let Some(s) = self.surface.as_ref() { if let Some(s) = self.surface.as_ref() {
s.commit() s.commit();
} }
} }
@ -77,24 +77,24 @@ impl WindowState {
self.current_pointer_position.get() self.current_pointer_position.get()
} }
pub fn window(&self) -> Option<Rc<FemtoVGWindow>> { pub fn window(&self) -> Option<Rc<FemtoVGWindow>> {
self.window.as_ref().and_then(|w| w.upgrade()) self.window.clone()
} }
pub fn layer_surface(&self) -> Option<Rc<ZwlrLayerSurfaceV1>> { pub fn layer_surface(&self) -> Option<Rc<ZwlrLayerSurfaceV1>> {
self.layer_surface.clone() self.layer_surface.clone()
} }
pub fn surface(&self) -> Option<&WlSurface> { pub const fn surface(&self) -> Option<&WlSurface> {
self.surface.as_ref() self.surface.as_ref()
} }
pub fn height(&self) -> u32 { pub const fn height(&self) -> u32 {
self.height self.height
} }
pub fn set_output_size(&self, width: u32, height: u32) { pub fn set_output_size(&self, width: u32, height: u32) {
self.output_size.set(PhysicalSize::new(width, height)); self.output_size.set(PhysicalSize::new(width, height));
} }
pub fn set_window(&mut self, window: Weak<FemtoVGWindow>) { pub fn set_window(&mut self, window: Rc<FemtoVGWindow>) {
self.window = Some(window); self.window = Some(window);
} }