refactor: pass only surface instead of whole state
parent
f310825194
commit
5649ba1056
|
@ -54,25 +54,23 @@ impl WindowingSystem {
|
||||||
);
|
);
|
||||||
|
|
||||||
let pointer = Rc::new(seat.get_pointer(&event_queue.handle(), ()));
|
let pointer = Rc::new(seat.get_pointer(&event_queue.handle(), ()));
|
||||||
|
let window = Self::initialize_renderer(&surface, &connection.display(), config)?;
|
||||||
|
let component_definition = config
|
||||||
|
.component_definition
|
||||||
|
.take()
|
||||||
|
.context("Component definition is required")?;
|
||||||
|
|
||||||
let mut state_builder = WindowStateBuilder::new()
|
let state = WindowStateBuilder::new()
|
||||||
.component_definition(
|
.component_definition(component_definition)
|
||||||
config
|
|
||||||
.component_definition
|
|
||||||
.take()
|
|
||||||
.context("Component definition is required")?,
|
|
||||||
)
|
|
||||||
.surface(Rc::clone(&surface))
|
.surface(Rc::clone(&surface))
|
||||||
.layer_surface(Rc::clone(&layer_surface))
|
.layer_surface(Rc::clone(&layer_surface))
|
||||||
.pointer(Rc::clone(&pointer))
|
.pointer(Rc::clone(&pointer))
|
||||||
.scale_factor(config.scale_factor)
|
.scale_factor(config.scale_factor)
|
||||||
.height(config.height)
|
.height(config.height)
|
||||||
.exclusive_zone(config.exclusive_zone);
|
.exclusive_zone(config.exclusive_zone)
|
||||||
|
.window(window)
|
||||||
|
.build()?;
|
||||||
|
|
||||||
let window = Self::initialize_renderer(&state_builder, &connection.display(), config)?;
|
|
||||||
state_builder = state_builder.window(window);
|
|
||||||
|
|
||||||
let state = state_builder.build()?;
|
|
||||||
let event_loop = EventLoop::try_new().context("Failed to create event loop")?;
|
let event_loop = EventLoop::try_new().context("Failed to create event loop")?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
@ -145,26 +143,22 @@ impl WindowingSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize_renderer(
|
fn initialize_renderer(
|
||||||
state_builder: &WindowStateBuilder,
|
surface: &Rc<WlSurface>,
|
||||||
display: &WlDisplay,
|
display: &WlDisplay,
|
||||||
config: &config::WindowConfig,
|
config: &config::WindowConfig,
|
||||||
) -> Result<Rc<FemtoVGWindow>> {
|
) -> Result<Rc<FemtoVGWindow>> {
|
||||||
let size = state_builder.size.unwrap_or(PhysicalSize::new(1, 1));
|
let init_size = PhysicalSize::new(1, 1);
|
||||||
let surface = state_builder
|
|
||||||
.surface
|
|
||||||
.as_ref()
|
|
||||||
.ok_or_else(|| anyhow::anyhow!("Failed to get surface"))?;
|
|
||||||
|
|
||||||
let context = EGLContext::builder()
|
let context = EGLContext::builder()
|
||||||
.with_display_id(display.id())
|
.with_display_id(display.id())
|
||||||
.with_surface_id(surface.id())
|
.with_surface_id(surface.id())
|
||||||
.with_size(size)
|
.with_size(init_size)
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let renderer = FemtoVGRenderer::new(context).context("Failed to create FemtoVGRenderer")?;
|
let renderer = FemtoVGRenderer::new(context).context("Failed to create FemtoVGRenderer")?;
|
||||||
|
|
||||||
let femtovg_window = FemtoVGWindow::new(renderer);
|
let femtovg_window = FemtoVGWindow::new(renderer);
|
||||||
femtovg_window.set_size(slint::WindowSize::Physical(size));
|
femtovg_window.set_size(slint::WindowSize::Physical(init_size));
|
||||||
femtovg_window.set_scale_factor(config.scale_factor);
|
femtovg_window.set_scale_factor(config.scale_factor);
|
||||||
femtovg_window.set_position(LogicalPosition::new(0., 0.));
|
femtovg_window.set_position(LogicalPosition::new(0., 0.));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue