mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-10-28 17:34:23 +00:00
fix: popup witdth with full output size as temp workaround
This commit is contained in:
parent
0615995e40
commit
e6579e1a35
2 changed files with 17 additions and 3 deletions
|
|
@ -58,6 +58,7 @@ pub struct PopupManager {
|
|||
context: PopupContext,
|
||||
popups: RefCell<Vec<ActivePopup>>,
|
||||
current_scale_factor: RefCell<f32>,
|
||||
current_output_size: RefCell<PhysicalSize>,
|
||||
}
|
||||
|
||||
impl PopupManager {
|
||||
|
|
@ -66,6 +67,7 @@ impl PopupManager {
|
|||
context,
|
||||
popups: RefCell::new(Vec::new()),
|
||||
current_scale_factor: RefCell::new(initial_scale_factor),
|
||||
current_output_size: RefCell::new(PhysicalSize::new(0, 0)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -73,6 +75,10 @@ impl PopupManager {
|
|||
*self.current_scale_factor.borrow_mut() = scale_factor;
|
||||
}
|
||||
|
||||
pub fn update_output_size(&self, output_size: PhysicalSize) {
|
||||
*self.current_output_size.borrow_mut() = output_size;
|
||||
}
|
||||
|
||||
pub fn create_popup(
|
||||
&self,
|
||||
queue_handle: &QueueHandle<WindowState>,
|
||||
|
|
@ -84,9 +90,14 @@ impl PopupManager {
|
|||
})?;
|
||||
|
||||
let scale_factor = *self.current_scale_factor.borrow();
|
||||
info!("Creating popup window with scale factor {scale_factor}");
|
||||
let output_size = *self.current_output_size.borrow();
|
||||
info!("Creating popup window with scale factor {scale_factor} and output size {output_size:?}");
|
||||
|
||||
let logical_size = slint::LogicalSize::new(360.0, 524.0);
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
let logical_size = slint::LogicalSize::new(
|
||||
output_size.width as f32 / scale_factor,
|
||||
output_size.height as f32 / scale_factor,
|
||||
);
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
#[allow(clippy::cast_sign_loss)]
|
||||
let popup_size = PhysicalSize::new(
|
||||
|
|
|
|||
|
|
@ -249,8 +249,11 @@ impl WindowState {
|
|||
self.height
|
||||
}
|
||||
|
||||
pub const fn set_output_size(&mut self, output_size: PhysicalSize) {
|
||||
pub fn set_output_size(&mut self, output_size: PhysicalSize) {
|
||||
self.output_size = output_size;
|
||||
if let Some(popup_manager) = &self.popup_manager {
|
||||
popup_manager.update_output_size(output_size);
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn output_size(&self) -> &PhysicalSize {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue