config: move window operations
This commit is contained in:
parent
274e7c0602
commit
05c40cb46d
2 changed files with 143 additions and 113 deletions
|
|
@ -197,4 +197,147 @@ impl ConfigProxyHandler {
|
|||
self.respond(Response::GetWindowChildren { windows });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_window_close(&self, window: Window) -> Result<(), CphError> {
|
||||
let window = self.get_window(window)?;
|
||||
window.tl_close();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_window_move(
|
||||
&self,
|
||||
window: Window,
|
||||
direction: Direction,
|
||||
) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let window = self.get_window(window)?;
|
||||
if let Some(float) = window.tl_data().float.get() {
|
||||
float.move_by_direction(direction.into());
|
||||
} else if let Some(c) = toplevel_parent_container(&*window) {
|
||||
c.move_child(window, direction.into());
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_window_fullscreen(
|
||||
&self,
|
||||
window: Window,
|
||||
) -> Result<(), CphError> {
|
||||
let tl = self.get_window(window)?;
|
||||
self.respond(Response::GetWindowFullscreen {
|
||||
fullscreen: tl.tl_data().is_fullscreen.get(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_window_fullscreen(
|
||||
&self,
|
||||
window: Window,
|
||||
fullscreen: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let tl = self.get_window(window)?;
|
||||
tl.tl_set_fullscreen(fullscreen, None);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_window_float_pinned(
|
||||
&self,
|
||||
window: Window,
|
||||
) -> Result<(), CphError> {
|
||||
let window = self.get_window(window)?;
|
||||
self.respond(Response::GetWindowFloatPinned {
|
||||
pinned: window.tl_pinned(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_window_float_pinned(
|
||||
&self,
|
||||
window: Window,
|
||||
pinned: bool,
|
||||
) -> Result<(), CphError> {
|
||||
let window = self.get_window(window)?;
|
||||
window.tl_set_pinned(true, pinned);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_window_mono(&self, window: Window) -> Result<(), CphError> {
|
||||
let window = self.get_window(window)?;
|
||||
self.respond(Response::GetWindowMono {
|
||||
mono: toplevel_parent_container(&*window)
|
||||
.map(|c| c.mono_child.is_some())
|
||||
.unwrap_or(false),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_window_mono(
|
||||
&self,
|
||||
window: Window,
|
||||
mono: bool,
|
||||
) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let window = self.get_window(window)?;
|
||||
if let Some(c) = toplevel_parent_container(&*window) {
|
||||
c.set_mono(mono.then_some(window.as_ref()));
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_window_split(&self, window: Window) -> Result<(), CphError> {
|
||||
let window = self.get_window(window)?;
|
||||
self.respond(Response::GetWindowSplit {
|
||||
axis: toplevel_parent_container(&*window)
|
||||
.map(|c| c.split.get())
|
||||
.unwrap_or(ContainerSplit::Horizontal)
|
||||
.into(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_window_split(
|
||||
&self,
|
||||
window: Window,
|
||||
axis: Axis,
|
||||
) -> Result<(), CphError> {
|
||||
self.state.with_layout_animations(|| {
|
||||
let window = self.get_window(window)?;
|
||||
if let Some(c) = toplevel_parent_container(&*window) {
|
||||
c.set_split(axis.into());
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn handle_create_window_split(
|
||||
&self,
|
||||
window: Window,
|
||||
axis: Axis,
|
||||
) -> Result<(), CphError> {
|
||||
let window = self.get_window(window)?;
|
||||
toplevel_create_split(&self.state, window, axis.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_get_window_floating(&self, window: Window) -> Result<(), CphError> {
|
||||
let window = self.get_window(window)?;
|
||||
self.respond(Response::GetWindowFloating {
|
||||
floating: window.tl_data().parent_is_float.get(),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_window_floating(
|
||||
&self,
|
||||
window: Window,
|
||||
floating: bool,
|
||||
) -> Result<(), CphError> {
|
||||
self.state.with_linear_layout_animations(|| {
|
||||
let window = self.get_window(window)?;
|
||||
toplevel_set_floating(&self.state, window, floating);
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue