mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
Extract SizeChange::from(PresetSize)
This commit is contained in:
@@ -768,6 +768,15 @@ pub enum PresetSize {
|
||||
Fixed(#[knuffel(argument)] i32),
|
||||
}
|
||||
|
||||
impl From<PresetSize> for SizeChange {
|
||||
fn from(value: PresetSize) -> Self {
|
||||
match value {
|
||||
PresetSize::Proportion(prop) => SizeChange::SetProportion(prop * 100.),
|
||||
PresetSize::Fixed(fixed) => SizeChange::SetFixed(fixed),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct DefaultPresetSize(pub Option<PresetSize>);
|
||||
|
||||
|
||||
@@ -677,12 +677,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
|
||||
};
|
||||
|
||||
let preset = self.options.preset_window_heights[preset_idx];
|
||||
let change = match preset {
|
||||
PresetSize::Proportion(prop) => SizeChange::SetProportion(prop * 100.),
|
||||
PresetSize::Fixed(fixed) => SizeChange::SetFixed(fixed),
|
||||
};
|
||||
|
||||
self.set_window_height(Some(&id), change, true);
|
||||
self.set_window_height(Some(&id), SizeChange::from(preset), true);
|
||||
|
||||
let tile = &mut self.tiles[idx];
|
||||
tile.floating_preset_height_idx = Some(preset_idx);
|
||||
|
||||
+1
-4
@@ -862,10 +862,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
activate: ActivateWindow,
|
||||
) -> Option<&Output> {
|
||||
let resolved_width = self.resolve_default_width(&window, width, is_floating);
|
||||
let resolved_height = height.map(|h| match h {
|
||||
PresetSize::Proportion(prop) => SizeChange::SetProportion(prop * 100.),
|
||||
PresetSize::Fixed(fixed) => SizeChange::SetFixed(fixed),
|
||||
});
|
||||
let resolved_height = height.map(SizeChange::from);
|
||||
let id = window.id().clone();
|
||||
|
||||
match &mut self.monitor_set {
|
||||
|
||||
Reference in New Issue
Block a user