mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-17 18:41:11 +02:00
wip
This commit is contained in:
@@ -6,6 +6,7 @@ use crossbeam_channel::Receiver;
|
|||||||
use crossbeam_channel::Sender;
|
use crossbeam_channel::Sender;
|
||||||
use crossbeam_utils::atomic::AtomicConsume;
|
use crossbeam_utils::atomic::AtomicConsume;
|
||||||
use komorebi_core::BorderStyle;
|
use komorebi_core::BorderStyle;
|
||||||
|
use komorebi_core::StackbarMode;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
@@ -22,6 +23,8 @@ use std::time::Duration;
|
|||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use windows::Win32::Foundation::HWND;
|
use windows::Win32::Foundation::HWND;
|
||||||
|
|
||||||
|
use crate::stackbar_manager;
|
||||||
|
use crate::stackbar_manager::STACKBAR_MODE;
|
||||||
use crate::workspace_reconciliator::ALT_TAB_HWND;
|
use crate::workspace_reconciliator::ALT_TAB_HWND;
|
||||||
use crate::Colour;
|
use crate::Colour;
|
||||||
use crate::Rect;
|
use crate::Rect;
|
||||||
@@ -56,7 +59,10 @@ lazy_static! {
|
|||||||
static ref FOCUS_STATE: Mutex<HashMap<isize, WindowKind>> = Mutex::new(HashMap::new());
|
static ref FOCUS_STATE: Mutex<HashMap<isize, WindowKind>> = Mutex::new(HashMap::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Notification;
|
pub enum Notification {
|
||||||
|
Default,
|
||||||
|
Move,
|
||||||
|
}
|
||||||
|
|
||||||
static CHANNEL: OnceLock<(Sender<Notification>, Receiver<Notification>)> = OnceLock::new();
|
static CHANNEL: OnceLock<(Sender<Notification>, Receiver<Notification>)> = OnceLock::new();
|
||||||
|
|
||||||
@@ -124,9 +130,9 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
|
|||||||
|
|
||||||
let receiver = event_rx();
|
let receiver = event_rx();
|
||||||
let mut instant: Option<Instant> = None;
|
let mut instant: Option<Instant> = None;
|
||||||
event_tx().send(Notification)?;
|
event_tx().send(Notification::Default)?;
|
||||||
|
|
||||||
'receiver: for _ in receiver {
|
'receiver: for notification in receiver {
|
||||||
if let Some(instant) = instant {
|
if let Some(instant) = instant {
|
||||||
if instant.elapsed().lt(&Duration::from_millis(50)) {
|
if instant.elapsed().lt(&Duration::from_millis(50)) {
|
||||||
continue 'receiver;
|
continue 'receiver;
|
||||||
@@ -270,6 +276,40 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
|
|||||||
borders.remove(id);
|
borders.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let workspace_has_stack = {
|
||||||
|
let mut should = false;
|
||||||
|
for c in ws.containers() {
|
||||||
|
if stackbar_manager::should_have_stackbar(c.windows().len()) {
|
||||||
|
should = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
should
|
||||||
|
};
|
||||||
|
|
||||||
|
let stackbar_mode = STACKBAR_MODE.load();
|
||||||
|
let workspace_has_stackbar = matches!(stackbar_mode, StackbarMode::Always)
|
||||||
|
|| workspace_has_stack && matches!(stackbar_mode, StackbarMode::OnStack);
|
||||||
|
|
||||||
|
if matches!(notification, Notification::Move) && workspace_has_stackbar {
|
||||||
|
let focus_state = FOCUS_STATE.lock();
|
||||||
|
|
||||||
|
let mut to_remove = vec![];
|
||||||
|
for (id, border) in borders.iter() {
|
||||||
|
if borders_monitors.get(id).copied().unwrap_or_default() == monitor_idx
|
||||||
|
&& container_ids.contains(id)
|
||||||
|
&& matches!(focus_state.get(&border.hwnd), Some(&WindowKind::Unfocused))
|
||||||
|
{
|
||||||
|
border.destroy()?;
|
||||||
|
to_remove.push(id.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for id in &to_remove {
|
||||||
|
borders.remove(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (idx, c) in ws.containers().iter().enumerate() {
|
for (idx, c) in ws.containers().iter().enumerate() {
|
||||||
// Update border when moving or resizing with mouse
|
// Update border when moving or resizing with mouse
|
||||||
if state.pending_move_op.is_some() && idx == ws.focused_container_idx() {
|
if state.pending_move_op.is_some() && idx == ws.focused_container_idx() {
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
|
|||||||
if should_update {
|
if should_update {
|
||||||
tracing::info!("updated work area for {}", monitor.device_id());
|
tracing::info!("updated work area for {}", monitor.device_id());
|
||||||
monitor.update_focused_workspace(offset)?;
|
monitor.update_focused_workspace(offset)?;
|
||||||
border_manager::event_tx().send(border_manager::Notification)?;
|
border_manager::event_tx().send(border_manager::Notification::Default)?;
|
||||||
} else {
|
} else {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"work areas match, reconciliation not required for {}",
|
"work areas match, reconciliation not required for {}",
|
||||||
@@ -207,7 +207,7 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
|
|||||||
);
|
);
|
||||||
|
|
||||||
monitor.update_focused_workspace(offset)?;
|
monitor.update_focused_workspace(offset)?;
|
||||||
border_manager::event_tx().send(border_manager::Notification)?;
|
border_manager::event_tx().send(border_manager::Notification::Default)?;
|
||||||
} else {
|
} else {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"resolutions match, reconciliation not required for {}",
|
"resolutions match, reconciliation not required for {}",
|
||||||
@@ -394,7 +394,7 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
|
|||||||
// Second retile to fix DPI/resolution related jank
|
// Second retile to fix DPI/resolution related jank
|
||||||
wm.retile_all(true)?;
|
wm.retile_all(true)?;
|
||||||
// Border updates to fix DPI/resolution related jank
|
// Border updates to fix DPI/resolution related jank
|
||||||
border_manager::event_tx().send(border_manager::Notification)?;
|
border_manager::event_tx().send(border_manager::Notification::Default)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
SocketMessage::MoveWindow(direction) => {
|
SocketMessage::MoveWindow(direction) => {
|
||||||
self.move_container_in_direction(direction)?;
|
self.move_container_in_direction(direction)?;
|
||||||
|
border_manager::event_tx().send(border_manager::Notification::Move)?;
|
||||||
}
|
}
|
||||||
SocketMessage::CycleFocusWindow(direction) => {
|
SocketMessage::CycleFocusWindow(direction) => {
|
||||||
self.focus_container_in_cycle_direction(direction)?;
|
self.focus_container_in_cycle_direction(direction)?;
|
||||||
@@ -1334,7 +1335,7 @@ impl WindowManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
notify_subscribers(&serde_json::to_string(¬ification)?)?;
|
notify_subscribers(&serde_json::to_string(¬ification)?)?;
|
||||||
border_manager::event_tx().send(border_manager::Notification)?;
|
border_manager::event_tx().send(border_manager::Notification::Default)?;
|
||||||
stackbar_manager::event_tx().send(stackbar_manager::Notification)?;
|
stackbar_manager::event_tx().send(stackbar_manager::Notification)?;
|
||||||
|
|
||||||
tracing::info!("processed");
|
tracing::info!("processed");
|
||||||
|
|||||||
@@ -620,7 +620,7 @@ impl WindowManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
notify_subscribers(&serde_json::to_string(¬ification)?)?;
|
notify_subscribers(&serde_json::to_string(¬ification)?)?;
|
||||||
border_manager::event_tx().send(border_manager::Notification)?;
|
border_manager::event_tx().send(border_manager::Notification::Default)?;
|
||||||
stackbar_manager::event_tx().send(stackbar_manager::Notification)?;
|
stackbar_manager::event_tx().send(stackbar_manager::Notification)?;
|
||||||
|
|
||||||
tracing::info!("processed: {}", event.window().to_string());
|
tracing::info!("processed: {}", event.window().to_string());
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
|
|||||||
// Unblock the border manager
|
// Unblock the border manager
|
||||||
ALT_TAB_HWND.store(None);
|
ALT_TAB_HWND.store(None);
|
||||||
// Send a notification to the border manager to update the borders
|
// Send a notification to the border manager to update the borders
|
||||||
border_manager::event_tx().send(border_manager::Notification)?;
|
border_manager::event_tx().send(border_manager::Notification::Default)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user