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