mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-25 10:08:33 +02:00
feat(wm): add promote-focus command
This commit adds a promote-focus command to complement the promote command. resolve #203
This commit is contained in:
@@ -52,6 +52,7 @@ pub enum SocketMessage {
|
|||||||
SendContainerToMonitorWorkspaceNumber(usize, usize),
|
SendContainerToMonitorWorkspaceNumber(usize, usize),
|
||||||
MoveWorkspaceToMonitorNumber(usize),
|
MoveWorkspaceToMonitorNumber(usize),
|
||||||
Promote,
|
Promote,
|
||||||
|
PromoteFocus,
|
||||||
ToggleFloat,
|
ToggleFloat,
|
||||||
ToggleMonocle,
|
ToggleMonocle,
|
||||||
ToggleMaximize,
|
ToggleMaximize,
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ impl WindowManager {
|
|||||||
|
|
||||||
match message {
|
match message {
|
||||||
SocketMessage::Promote => self.promote_container_to_front()?,
|
SocketMessage::Promote => self.promote_container_to_front()?,
|
||||||
|
SocketMessage::PromoteFocus => self.promote_focus_to_front()?,
|
||||||
SocketMessage::FocusWindow(direction) => {
|
SocketMessage::FocusWindow(direction) => {
|
||||||
self.focus_container_in_direction(direction)?;
|
self.focus_container_in_direction(direction)?;
|
||||||
}
|
}
|
||||||
@@ -805,6 +806,7 @@ impl WindowManager {
|
|||||||
| SocketMessage::ToggleMonocle
|
| SocketMessage::ToggleMonocle
|
||||||
| SocketMessage::ToggleMaximize
|
| SocketMessage::ToggleMaximize
|
||||||
| SocketMessage::Promote
|
| SocketMessage::Promote
|
||||||
|
| SocketMessage::PromoteFocus
|
||||||
| SocketMessage::Retile
|
| SocketMessage::Retile
|
||||||
| SocketMessage::InvisibleBorders(_)
|
| SocketMessage::InvisibleBorders(_)
|
||||||
| SocketMessage::WorkAreaOffset(_)
|
| SocketMessage::WorkAreaOffset(_)
|
||||||
|
|||||||
@@ -1251,6 +1251,23 @@ impl WindowManager {
|
|||||||
self.update_focused_workspace(self.mouse_follows_focus)
|
self.update_focused_workspace(self.mouse_follows_focus)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip(self))]
|
||||||
|
pub fn promote_focus_to_front(&mut self) -> Result<()> {
|
||||||
|
self.handle_unmanaged_window_behaviour()?;
|
||||||
|
|
||||||
|
tracing::info!("promoting focus");
|
||||||
|
|
||||||
|
let workspace = self.focused_workspace_mut()?;
|
||||||
|
let target_idx = match workspace.layout() {
|
||||||
|
Layout::Default(_) => 0,
|
||||||
|
Layout::Custom(custom) => custom
|
||||||
|
.first_container_idx(custom.primary_idx().map_or(0, |primary_idx| primary_idx)),
|
||||||
|
};
|
||||||
|
|
||||||
|
workspace.focus_container(target_idx);
|
||||||
|
self.update_focused_workspace(self.mouse_follows_focus)
|
||||||
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub fn remove_window_from_container(&mut self) -> Result<()> {
|
pub fn remove_window_from_container(&mut self) -> Result<()> {
|
||||||
self.handle_unmanaged_window_behaviour()?;
|
self.handle_unmanaged_window_behaviour()?;
|
||||||
|
|||||||
@@ -164,6 +164,10 @@ Promote() {
|
|||||||
Run, komorebic.exe promote, , Hide
|
Run, komorebic.exe promote, , Hide
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PromoteFocus() {
|
||||||
|
Run, komorebic.exe promote-focus, , Hide
|
||||||
|
}
|
||||||
|
|
||||||
Retile() {
|
Retile() {
|
||||||
Run, komorebic.exe retile, , Hide
|
Run, komorebic.exe retile, , Hide
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -594,6 +594,8 @@ enum SubCommand {
|
|||||||
FlipLayout(FlipLayout),
|
FlipLayout(FlipLayout),
|
||||||
/// Promote the focused window to the top of the tree
|
/// Promote the focused window to the top of the tree
|
||||||
Promote,
|
Promote,
|
||||||
|
/// Promote the user focus to the top of the tree
|
||||||
|
PromoteFocus,
|
||||||
/// Force the retiling of all managed windows
|
/// Force the retiling of all managed windows
|
||||||
Retile,
|
Retile,
|
||||||
/// Create at least this many workspaces for the specified monitor
|
/// Create at least this many workspaces for the specified monitor
|
||||||
@@ -769,6 +771,9 @@ fn main() -> Result<()> {
|
|||||||
SubCommand::Promote => {
|
SubCommand::Promote => {
|
||||||
send_message(&SocketMessage::Promote.as_bytes()?)?;
|
send_message(&SocketMessage::Promote.as_bytes()?)?;
|
||||||
}
|
}
|
||||||
|
SubCommand::PromoteFocus => {
|
||||||
|
send_message(&SocketMessage::PromoteFocus.as_bytes()?)?;
|
||||||
|
}
|
||||||
SubCommand::TogglePause => {
|
SubCommand::TogglePause => {
|
||||||
send_message(&SocketMessage::TogglePause.as_bytes()?)?;
|
send_message(&SocketMessage::TogglePause.as_bytes()?)?;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user