refactor: minor changes

This commit is contained in:
drendog 2025-11-13 18:29:12 +01:00
parent 69b56d59ae
commit bc7d13be55
Signed by: dwenya
GPG key ID: 8DD77074645332D0
6 changed files with 12 additions and 24 deletions

View file

@ -72,8 +72,8 @@ impl EventContext {
.publish(&WindowStateEvent::PopupConfigurationChanged); .publish(&WindowStateEvent::PopupConfigurationChanged);
} }
pub const fn popup_manager(&self) -> &Option<Rc<PopupManager>> { pub const fn popup_manager(&self) -> Option<&Rc<PopupManager>> {
&self.popup_manager self.popup_manager.as_ref()
} }
#[must_use] #[must_use]

View file

@ -46,7 +46,7 @@ impl<W: RenderableWindow> RenderingState<W> {
self.renderer.layer_surface() self.renderer.layer_surface()
} }
pub const fn fractional_scale(&self) -> &Option<ManagedWpFractionalScaleV1> { pub fn fractional_scale(&self) -> Option<&ManagedWpFractionalScaleV1> {
self.renderer.fractional_scale() self.renderer.fractional_scale()
} }
} }

View file

@ -261,7 +261,7 @@ impl WindowState {
.update_scale_for_fractional_scale_object(fractional_scale_proxy, scale_120ths); .update_scale_for_fractional_scale_object(fractional_scale_proxy, scale_120ths);
} }
pub fn popup_manager(&self) -> &Option<Rc<PopupManager>> { pub fn popup_manager(&self) -> Option<&Rc<PopupManager>> {
self.event_context.popup_manager() self.event_context.popup_manager()
} }
} }

View file

@ -3,23 +3,13 @@ use slint::PhysicalSize;
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum WindowStateEvent { pub enum WindowStateEvent {
ScaleFactorChanged { ScaleFactorChanged { new_scale: f32, source: ScaleSource },
new_scale: f32,
source: ScaleSource,
},
OutputSizeChanged { OutputSizeChanged { output_size: PhysicalSize },
output_size: PhysicalSize,
},
PointerPositionChanged { PointerPositionChanged { physical_x: f64, physical_y: f64 },
physical_x: f64,
physical_y: f64,
},
PointerSerialUpdated { PointerSerialUpdated { serial: u32 },
serial: u32,
},
PopupConfigurationChanged, PopupConfigurationChanged,
} }

View file

@ -183,7 +183,7 @@ impl<W: RenderableWindow> WindowRenderer<W> {
self.logical_size self.logical_size
} }
pub const fn fractional_scale(&self) -> &Option<ManagedWpFractionalScaleV1> { pub const fn fractional_scale(&self) -> Option<&ManagedWpFractionalScaleV1> {
&self.fractional_scale self.fractional_scale.as_ref()
} }
} }

View file

@ -164,13 +164,12 @@ impl RuntimeState<'_> {
let popup_manager = self let popup_manager = self
.window_state .window_state
.popup_manager() .popup_manager()
.as_ref()
.ok_or_else(|| { .ok_or_else(|| {
Error::Domain(DomainError::Configuration { Error::Domain(DomainError::Configuration {
message: "No popup manager available".to_string(), message: "No popup manager available".to_string(),
}) })
}) })
.map(Rc::clone)?; .cloned()?;
let initial_dimensions = match req.size { let initial_dimensions = match req.size {
PopupSize::Fixed { w, h } => { PopupSize::Fixed { w, h } => {
@ -242,13 +241,12 @@ impl RuntimeState<'_> {
let popup_manager = self let popup_manager = self
.window_state .window_state
.popup_manager() .popup_manager()
.as_ref()
.ok_or_else(|| { .ok_or_else(|| {
Error::Domain(DomainError::Configuration { Error::Domain(DomainError::Configuration {
message: "No popup manager available".to_string(), message: "No popup manager available".to_string(),
}) })
}) })
.map(Rc::clone)?; .cloned()?;
let Some((request, _serial)) = popup_manager.get_popup_info(key) else { let Some((request, _serial)) = popup_manager.get_popup_info(key) else {
log::debug!( log::debug!(