mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-10-28 14:14:23 +00:00
refactor: minor refactor on windowing builder
This commit is contained in:
parent
e9f02a8533
commit
35f5b1321f
2 changed files with 18 additions and 12 deletions
|
|
@ -6,7 +6,10 @@ use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::{
|
|||
|
||||
use crate::errors::{LayerShikaError, Result};
|
||||
|
||||
use super::{config::{Margins, WindowConfig}, WindowingSystem};
|
||||
use super::{
|
||||
config::{Margins, WindowConfig},
|
||||
WindowingSystem,
|
||||
};
|
||||
|
||||
pub struct WindowingSystemBuilder {
|
||||
config: Option<WindowConfig>,
|
||||
|
|
@ -22,9 +25,7 @@ impl WindowingSystemBuilder {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
config: None,
|
||||
}
|
||||
Self { config: None }
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
|
@ -46,7 +47,12 @@ impl WindowingSystemBuilder {
|
|||
#[must_use]
|
||||
pub const fn with_margin(mut self, top: i32, right: i32, bottom: i32, left: i32) -> Self {
|
||||
if let Some(ref mut config) = self.config {
|
||||
config.margin = Margins { top, right, bottom, left };
|
||||
config.margin = Margins {
|
||||
top,
|
||||
right,
|
||||
bottom,
|
||||
left,
|
||||
};
|
||||
}
|
||||
self
|
||||
}
|
||||
|
|
@ -102,9 +108,9 @@ impl WindowingSystemBuilder {
|
|||
|
||||
#[allow(clippy::missing_errors_doc)]
|
||||
pub fn build(self) -> Result<WindowingSystem> {
|
||||
let config = self.config.as_ref().ok_or_else(|| {
|
||||
LayerShikaError::InvalidInput("Slint component not set".into())
|
||||
})?;
|
||||
let config = self
|
||||
.config
|
||||
.ok_or_else(|| LayerShikaError::InvalidInput("Slint component not set".into()))?;
|
||||
WindowingSystem::new(config)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ pub struct WindowingSystem {
|
|||
}
|
||||
|
||||
impl WindowingSystem {
|
||||
fn new(config: &WindowConfig) -> Result<Self> {
|
||||
fn new(config: WindowConfig) -> Result<Self> {
|
||||
info!("Initializing WindowingSystem");
|
||||
let connection =
|
||||
Rc::new(Connection::connect_to_env().map_err(LayerShikaError::WaylandConnection)?);
|
||||
|
|
@ -81,15 +81,15 @@ impl WindowingSystem {
|
|||
fractional_scale_manager.as_ref(),
|
||||
viewporter.as_ref(),
|
||||
&event_queue.handle(),
|
||||
config,
|
||||
&config,
|
||||
);
|
||||
|
||||
let pointer = Rc::new(seat.get_pointer(&event_queue.handle(), ()));
|
||||
let window = Self::initialize_renderer(&surface, &connection.display(), config)
|
||||
let window = Self::initialize_renderer(&surface, &connection.display(), &config)
|
||||
.map_err(|e| LayerShikaError::EGLContextCreation(e.to_string()))?;
|
||||
|
||||
let mut builder = WindowStateBuilder::new()
|
||||
.with_component_definition(config.component_definition.clone())
|
||||
.with_component_definition(config.component_definition)
|
||||
.with_surface(Rc::clone(&surface))
|
||||
.with_layer_surface(Rc::clone(&layer_surface))
|
||||
.with_pointer(Rc::clone(&pointer))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue