mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-24 18:31:22 +01:00
feat(wm): immediate stackbar mode updates via ipc
This commit ensures that when the stackbar mode is updated via a SocketMessage or static config update, any visible stackbars will have their mode updated immediately without having to wait for user interaction.
This commit is contained in:
@@ -156,4 +156,18 @@ impl Container {
|
||||
tracing::info!("focusing window");
|
||||
self.windows.focus(idx);
|
||||
}
|
||||
|
||||
pub fn set_stackbar_mode(&mut self, mode: StackbarMode) {
|
||||
self.stackbar = match mode {
|
||||
StackbarMode::Always => Stackbar::create().ok(),
|
||||
StackbarMode::Never => None,
|
||||
StackbarMode::OnStack => {
|
||||
if self.windows().len() > 1 && self.stackbar().is_none() {
|
||||
Stackbar::create().ok()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1280,6 +1280,14 @@ impl WindowManager {
|
||||
SocketMessage::StackbarMode(mode) => {
|
||||
let mut stackbar_mode = STACKBAR_MODE.lock();
|
||||
*stackbar_mode = mode;
|
||||
|
||||
for m in self.monitors_mut() {
|
||||
for w in m.workspaces_mut() {
|
||||
for c in w.containers_mut() {
|
||||
c.set_stackbar_mode(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SocketMessage::StackbarFocusedTextColour(r, g, b) => {
|
||||
let rgb = Rgb::new(r, g, b);
|
||||
|
||||
@@ -188,12 +188,14 @@ impl WindowManager {
|
||||
self.has_pending_raise_op = false;
|
||||
}
|
||||
WindowManagerEvent::Destroy(_, window) | WindowManagerEvent::Unmanage(window) => {
|
||||
self.focused_workspace_mut()?.remove_window(window.hwnd)?;
|
||||
self.update_focused_workspace(false, false)?;
|
||||
if self.focused_workspace()?.contains_window(window.hwnd) {
|
||||
self.focused_workspace_mut()?.remove_window(window.hwnd)?;
|
||||
self.update_focused_workspace(false, false)?;
|
||||
|
||||
let mut already_moved_window_handles = self.already_moved_window_handles.lock();
|
||||
let mut already_moved_window_handles = self.already_moved_window_handles.lock();
|
||||
|
||||
already_moved_window_handles.remove(&window.hwnd);
|
||||
already_moved_window_handles.remove(&window.hwnd);
|
||||
}
|
||||
}
|
||||
WindowManagerEvent::Minimize(_, window) => {
|
||||
let mut hide = false;
|
||||
|
||||
@@ -518,10 +518,12 @@ impl StaticConfig {
|
||||
if let Some(height) = &stackbar.height {
|
||||
STACKBAR_TAB_HEIGHT.store(*height, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
if let Some(mode) = &stackbar.mode {
|
||||
let mut stackbar_mode = STACKBAR_MODE.lock();
|
||||
*stackbar_mode = *mode;
|
||||
}
|
||||
|
||||
if let Some(tabs) = &stackbar.tabs {
|
||||
if let Some(background) = &tabs.background {
|
||||
STACKBAR_TAB_BACKGROUND_COLOUR.store((*background).into(), Ordering::SeqCst);
|
||||
@@ -725,6 +727,16 @@ impl StaticConfig {
|
||||
|
||||
value.apply_globals()?;
|
||||
|
||||
let stackbar_mode = STACKBAR_MODE.lock().clone();
|
||||
|
||||
for m in wm.monitors_mut() {
|
||||
for w in m.workspaces_mut() {
|
||||
for c in w.containers_mut() {
|
||||
c.set_stackbar_mode(stackbar_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(monitors) = value.monitors {
|
||||
for (i, monitor) in monitors.iter().enumerate() {
|
||||
if let Some(m) = wm.monitors_mut().get_mut(i) {
|
||||
|
||||
@@ -359,7 +359,7 @@ impl WindowsApi {
|
||||
flags |= SetWindowPosition::NO_Z_ORDER;
|
||||
}
|
||||
|
||||
let shadow_rect = Self::shadow_rect(hwnd)?;
|
||||
let shadow_rect = Self::shadow_rect(hwnd).unwrap_or_default();
|
||||
let rect = Rect {
|
||||
left: layout.left + shadow_rect.left,
|
||||
top: layout.top + shadow_rect.top,
|
||||
|
||||
@@ -327,17 +327,17 @@ impl Workspace {
|
||||
}
|
||||
|
||||
if let Some(stackbar) = container_topbar {
|
||||
stackbar.set_position(
|
||||
if let Ok(_) = stackbar.set_position(
|
||||
&stackbar.get_position_from_container_layout(layout),
|
||||
false,
|
||||
)?;
|
||||
) {
|
||||
stackbar.update(&container_windows, focused_hwnd)?;
|
||||
let tab_height = STACKBAR_TAB_HEIGHT.load(Ordering::SeqCst);
|
||||
let total_height = tab_height + container_padding;
|
||||
|
||||
stackbar.update(&container_windows, focused_hwnd)?;
|
||||
let tab_height = STACKBAR_TAB_HEIGHT.load(Ordering::SeqCst);
|
||||
let total_height = tab_height + container_padding;
|
||||
|
||||
rect.top += total_height;
|
||||
rect.bottom -= total_height;
|
||||
rect.top += total_height;
|
||||
rect.bottom -= total_height;
|
||||
}
|
||||
}
|
||||
|
||||
window.set_position(&rect, false)?;
|
||||
|
||||
Reference in New Issue
Block a user