feat(wm): add native window maximization toggle

Windows that have been maximized do not retain their maximized state
across workspaces as workspaces are built on top of sending SW_HIDE and
SW_SHOW events which at various points of the event loop end up
overriding SW_SHOWMAXIMIZED and SW_SHOWMAXIMIZE.

To handle this use case, I have added a new 'komorebic toggle-maximize'
command which sends SW_MAXIMIZE for a window and keeps a record of the
window in the focused workspace in the same way that monocle windows are
tracked.

In this way, komorebi can know when switching to a workspace if it has
to restore a window to a native maximized state.

Some additional edge cases are caught in this commit in showing and
hiding workspaces, to also account for floating windows and monocle
containers.

resolve #12
This commit is contained in:
LGUG2Z
2021-08-18 09:49:05 -07:00
parent 13b335cecc
commit 0725549d45
11 changed files with 256 additions and 15 deletions
+11 -2
View File
@@ -70,14 +70,23 @@ impl Monitor {
}
}
#[tracing::instrument(skip(self))]
pub fn move_container_to_workspace(
&mut self,
target_workspace_idx: usize,
follow: bool,
) -> Result<()> {
let container = self
let workspace = self
.focused_workspace_mut()
.context("there is no workspace")?
.context("there is no workspace")?;
if workspace.maximized_window().is_some() {
return Err(eyre::anyhow!(
"cannot move native maximized window to another monitor or workspace"
));
}
let container = workspace
.remove_focused_container()
.context("there is no container")?;