From cbcbf2acd9ba83f3c3353e343ea0282085529c33 Mon Sep 17 00:00:00 2001 From: drendog Date: Tue, 20 Aug 2024 23:43:33 +0200 Subject: [PATCH] refactor: default on state builder --- src/windowing/mod.rs | 2 +- src/windowing/state/builder.rs | 33 +++++++++++++++++++-------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/windowing/mod.rs b/src/windowing/mod.rs index 6ca566d..5938ebf 100644 --- a/src/windowing/mod.rs +++ b/src/windowing/mod.rs @@ -16,7 +16,7 @@ use smithay_client_toolkit::reexports::{ use state::builder::WindowStateBuilder; use std::rc::Rc; use wayland_client::{ - globals::{registry_queue_init, GlobalList}, + globals::registry_queue_init, protocol::{ wl_compositor::WlCompositor, wl_display::WlDisplay, wl_output::WlOutput, wl_seat::WlSeat, wl_surface::WlSurface, diff --git a/src/windowing/state/builder.rs b/src/windowing/state/builder.rs index c2000da..943725f 100644 --- a/src/windowing/state/builder.rs +++ b/src/windowing/state/builder.rs @@ -8,7 +8,6 @@ use anyhow::Result; use super::WindowState; -#[derive(Clone)] pub struct WindowStateBuilder { pub component_definition: Option, pub surface: Option>, @@ -23,19 +22,8 @@ pub struct WindowStateBuilder { } impl WindowStateBuilder { - pub const fn new() -> Self { - Self { - component_definition: None, - surface: None, - layer_surface: None, - size: None, - output_size: None, - pointer: None, - window: None, - scale_factor: 1.0, - height: 30, - exclusive_zone: -1, - } + pub fn new() -> Self { + Default::default() } pub fn surface(mut self, surface: Rc) -> Self { @@ -96,3 +84,20 @@ impl WindowStateBuilder { WindowState::new(self) } } + +impl Default for WindowStateBuilder { + fn default() -> Self { + Self { + component_definition: None, + surface: None, + layer_surface: None, + size: None, + output_size: None, + pointer: None, + window: None, + scale_factor: 1.0, + height: 30, + exclusive_zone: -1, + } + } +}