mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-24 01:28:39 +02:00
refactor(rust): upgrade to edition 2024 part 2 (clippy --fix)
This commit is contained in:
@@ -322,16 +322,15 @@ pub fn apply_theme(
|
|||||||
// apply rounding to the widgets
|
// apply rounding to the widgets
|
||||||
if let Some(Grouping::Bar(config) | Grouping::Alignment(config) | Grouping::Widget(config)) =
|
if let Some(Grouping::Bar(config) | Grouping::Alignment(config) | Grouping::Widget(config)) =
|
||||||
&grouping
|
&grouping
|
||||||
|
&& let Some(rounding) = config.rounding
|
||||||
{
|
{
|
||||||
if let Some(rounding) = config.rounding {
|
ctx.style_mut(|style| {
|
||||||
ctx.style_mut(|style| {
|
style.visuals.widgets.noninteractive.corner_radius = rounding.into();
|
||||||
style.visuals.widgets.noninteractive.corner_radius = rounding.into();
|
style.visuals.widgets.inactive.corner_radius = rounding.into();
|
||||||
style.visuals.widgets.inactive.corner_radius = rounding.into();
|
style.visuals.widgets.hovered.corner_radius = rounding.into();
|
||||||
style.visuals.widgets.hovered.corner_radius = rounding.into();
|
style.visuals.widgets.active.corner_radius = rounding.into();
|
||||||
style.visuals.widgets.active.corner_radius = rounding.into();
|
style.visuals.widgets.open.corner_radius = rounding.into();
|
||||||
style.visuals.widgets.open.corner_radius = rounding.into();
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update RenderConfig's background_color so that widgets will have the new color
|
// Update RenderConfig's background_color so that widgets will have the new color
|
||||||
@@ -672,17 +671,16 @@ impl Komobar {
|
|||||||
| Grouping::Alignment(config)
|
| Grouping::Alignment(config)
|
||||||
| Grouping::Widget(config),
|
| Grouping::Widget(config),
|
||||||
) = &bar_grouping
|
) = &bar_grouping
|
||||||
|
&& let Some(rounding) = config.rounding
|
||||||
{
|
{
|
||||||
if let Some(rounding) = config.rounding {
|
ctx.style_mut(|style| {
|
||||||
ctx.style_mut(|style| {
|
style.visuals.widgets.noninteractive.corner_radius =
|
||||||
style.visuals.widgets.noninteractive.corner_radius =
|
rounding.into();
|
||||||
rounding.into();
|
style.visuals.widgets.inactive.corner_radius = rounding.into();
|
||||||
style.visuals.widgets.inactive.corner_radius = rounding.into();
|
style.visuals.widgets.hovered.corner_radius = rounding.into();
|
||||||
style.visuals.widgets.hovered.corner_radius = rounding.into();
|
style.visuals.widgets.active.corner_radius = rounding.into();
|
||||||
style.visuals.widgets.active.corner_radius = rounding.into();
|
style.visuals.widgets.open.corner_radius = rounding.into();
|
||||||
style.visuals.widgets.open.corner_radius = rounding.into();
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,41 +87,41 @@ impl Battery {
|
|||||||
if now.duration_since(self.last_updated) > Duration::from_secs(self.data_refresh_interval) {
|
if now.duration_since(self.last_updated) > Duration::from_secs(self.data_refresh_interval) {
|
||||||
output = None;
|
output = None;
|
||||||
|
|
||||||
if let Ok(mut batteries) = self.manager.batteries() {
|
if let Ok(mut batteries) = self.manager.batteries()
|
||||||
if let Some(Ok(first)) = batteries.nth(0) {
|
&& let Some(Ok(first)) = batteries.nth(0)
|
||||||
let percentage = first.state_of_charge().get::<percent>().round() as u8;
|
{
|
||||||
|
let percentage = first.state_of_charge().get::<percent>().round() as u8;
|
||||||
|
|
||||||
if percentage == 100 && self.hide_on_full_charge {
|
if percentage == 100 && self.hide_on_full_charge {
|
||||||
output = None
|
output = None
|
||||||
} else {
|
} else {
|
||||||
match first.state() {
|
match first.state() {
|
||||||
State::Charging => self.state = BatteryState::Charging,
|
State::Charging => self.state = BatteryState::Charging,
|
||||||
State::Discharging => {
|
State::Discharging => {
|
||||||
self.state = match percentage {
|
self.state = match percentage {
|
||||||
p if p > 75 => BatteryState::Discharging,
|
p if p > 75 => BatteryState::Discharging,
|
||||||
p if p > 50 => BatteryState::High,
|
p if p > 50 => BatteryState::High,
|
||||||
p if p > 25 => BatteryState::Medium,
|
p if p > 25 => BatteryState::Medium,
|
||||||
p if p > 10 => BatteryState::Low,
|
p if p > 10 => BatteryState::Low,
|
||||||
_ => BatteryState::Warning,
|
_ => BatteryState::Warning,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
let selected = self.auto_select_under.is_some_and(|u| percentage <= u);
|
|
||||||
|
|
||||||
output = Some(BatteryOutput {
|
|
||||||
label: match self.label_prefix {
|
|
||||||
LabelPrefix::Text | LabelPrefix::IconAndText => {
|
|
||||||
format!("BAT: {percentage}%")
|
|
||||||
}
|
|
||||||
LabelPrefix::None | LabelPrefix::Icon => {
|
|
||||||
format!("{percentage}%")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
selected,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let selected = self.auto_select_under.is_some_and(|u| percentage <= u);
|
||||||
|
|
||||||
|
output = Some(BatteryOutput {
|
||||||
|
label: match self.label_prefix {
|
||||||
|
LabelPrefix::Text | LabelPrefix::IconAndText => {
|
||||||
|
format!("BAT: {percentage}%")
|
||||||
|
}
|
||||||
|
LabelPrefix::None | LabelPrefix::Icon => {
|
||||||
|
format!("{percentage}%")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selected,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,13 +176,11 @@ impl BarWidget for Battery {
|
|||||||
if SelectableFrame::new_auto(output.selected, auto_focus_fill)
|
if SelectableFrame::new_auto(output.selected, auto_focus_fill)
|
||||||
.show(ui, |ui| ui.add(Label::new(layout_job).selectable(false)))
|
.show(ui, |ui| ui.add(Label::new(layout_job).selectable(false)))
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
&& let Err(error) = Command::new("cmd.exe")
|
||||||
if let Err(error) = Command::new("cmd.exe")
|
|
||||||
.args(["/C", "start", "ms-settings:batterysaver"])
|
.args(["/C", "start", "ms-settings:batterysaver"])
|
||||||
.spawn()
|
.spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{error}")
|
eprintln!("{error}")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,12 +120,10 @@ impl BarWidget for Cpu {
|
|||||||
if SelectableFrame::new_auto(output.selected, auto_focus_fill)
|
if SelectableFrame::new_auto(output.selected, auto_focus_fill)
|
||||||
.show(ui, |ui| ui.add(Label::new(layout_job).selectable(false)))
|
.show(ui, |ui| ui.add(Label::new(layout_job).selectable(false)))
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
&& let Err(error) =
|
||||||
if let Err(error) =
|
|
||||||
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{error}")
|
eprintln!("{error}")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -271,14 +271,14 @@ impl Komorebi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn render_layout(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) {
|
fn render_layout(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) {
|
||||||
if let Some(layout_config) = &self.layout {
|
if let Some(layout_config) = &self.layout
|
||||||
if layout_config.enable {
|
&& layout_config.enable
|
||||||
let monitor_info = &mut *self.monitor_info.borrow_mut();
|
{
|
||||||
let workspace_idx = monitor_info.focused_workspace_idx;
|
let monitor_info = &mut *self.monitor_info.borrow_mut();
|
||||||
monitor_info
|
let workspace_idx = monitor_info.focused_workspace_idx;
|
||||||
.layout
|
monitor_info
|
||||||
.show(ctx, ui, config, layout_config, workspace_idx);
|
.layout
|
||||||
}
|
.show(ctx, ui, config, layout_config, workspace_idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,10 +558,8 @@ impl FocusedContainerBar {
|
|||||||
ui.add(img.fit_to_exact_size(self.icon_size));
|
ui.add(img.fit_to_exact_size(self.icon_size));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if HOVEL {
|
if HOVEL && let Some(title) = &info.title {
|
||||||
if let Some(title) = &info.title {
|
inner_response.response.on_hover_text(title);
|
||||||
inner_response.response.on_hover_text(title);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,16 +91,15 @@ impl KomorebiLayout {
|
|||||||
fn on_click_option(&mut self, monitor_idx: usize, workspace_idx: Option<usize>) {
|
fn on_click_option(&mut self, monitor_idx: usize, workspace_idx: Option<usize>) {
|
||||||
match self {
|
match self {
|
||||||
KomorebiLayout::Default(option) => {
|
KomorebiLayout::Default(option) => {
|
||||||
if let Some(ws_idx) = workspace_idx {
|
if let Some(ws_idx) = workspace_idx
|
||||||
if komorebi_client::send_message(&SocketMessage::WorkspaceLayout(
|
&& komorebi_client::send_message(&SocketMessage::WorkspaceLayout(
|
||||||
monitor_idx,
|
monitor_idx,
|
||||||
ws_idx,
|
ws_idx,
|
||||||
*option,
|
*option,
|
||||||
))
|
))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
tracing::error!("could not send message to komorebi: WorkspaceLayout");
|
tracing::error!("could not send message to komorebi: WorkspaceLayout");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KomorebiLayout::Monocle => {
|
KomorebiLayout::Monocle => {
|
||||||
@@ -269,57 +268,53 @@ impl KomorebiLayout {
|
|||||||
show_options = self.on_click(&show_options, monitor_idx, workspace_idx);
|
show_options = self.on_click(&show_options, monitor_idx, workspace_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if show_options {
|
if show_options && let Some(workspace_idx) = workspace_idx {
|
||||||
if let Some(workspace_idx) = workspace_idx {
|
Frame::NONE.show(ui, |ui| {
|
||||||
Frame::NONE.show(ui, |ui| {
|
ui.add(
|
||||||
ui.add(
|
Label::new(egui_phosphor::regular::ARROW_FAT_LINES_RIGHT.to_string())
|
||||||
Label::new(egui_phosphor::regular::ARROW_FAT_LINES_RIGHT.to_string())
|
.selectable(false),
|
||||||
.selectable(false),
|
);
|
||||||
);
|
|
||||||
|
|
||||||
let mut layout_options = layout_config.options.clone().unwrap_or(vec![
|
let mut layout_options = layout_config.options.clone().unwrap_or(vec![
|
||||||
KomorebiLayout::Default(komorebi_client::DefaultLayout::BSP),
|
KomorebiLayout::Default(komorebi_client::DefaultLayout::BSP),
|
||||||
KomorebiLayout::Default(komorebi_client::DefaultLayout::Columns),
|
KomorebiLayout::Default(komorebi_client::DefaultLayout::Columns),
|
||||||
KomorebiLayout::Default(komorebi_client::DefaultLayout::Rows),
|
KomorebiLayout::Default(komorebi_client::DefaultLayout::Rows),
|
||||||
KomorebiLayout::Default(komorebi_client::DefaultLayout::VerticalStack),
|
KomorebiLayout::Default(komorebi_client::DefaultLayout::VerticalStack),
|
||||||
KomorebiLayout::Default(
|
KomorebiLayout::Default(
|
||||||
komorebi_client::DefaultLayout::RightMainVerticalStack,
|
komorebi_client::DefaultLayout::RightMainVerticalStack,
|
||||||
),
|
),
|
||||||
KomorebiLayout::Default(
|
KomorebiLayout::Default(komorebi_client::DefaultLayout::HorizontalStack),
|
||||||
komorebi_client::DefaultLayout::HorizontalStack,
|
KomorebiLayout::Default(
|
||||||
),
|
komorebi_client::DefaultLayout::UltrawideVerticalStack,
|
||||||
KomorebiLayout::Default(
|
),
|
||||||
komorebi_client::DefaultLayout::UltrawideVerticalStack,
|
KomorebiLayout::Default(komorebi_client::DefaultLayout::Grid),
|
||||||
),
|
//KomorebiLayout::Custom,
|
||||||
KomorebiLayout::Default(komorebi_client::DefaultLayout::Grid),
|
KomorebiLayout::Monocle,
|
||||||
//KomorebiLayout::Custom,
|
KomorebiLayout::Floating,
|
||||||
KomorebiLayout::Monocle,
|
KomorebiLayout::Paused,
|
||||||
KomorebiLayout::Floating,
|
]);
|
||||||
KomorebiLayout::Paused,
|
|
||||||
]);
|
|
||||||
|
|
||||||
for layout_option in &mut layout_options {
|
for layout_option in &mut layout_options {
|
||||||
let is_selected = self == layout_option;
|
let is_selected = self == layout_option;
|
||||||
|
|
||||||
if SelectableFrame::new(is_selected)
|
if SelectableFrame::new(is_selected)
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
layout_option.show_icon(is_selected, font_id.clone(), ctx, ui)
|
layout_option.show_icon(is_selected, font_id.clone(), ctx, ui)
|
||||||
})
|
})
|
||||||
.on_hover_text(match layout_option {
|
.on_hover_text(match layout_option {
|
||||||
KomorebiLayout::Default(layout) => layout.to_string(),
|
KomorebiLayout::Default(layout) => layout.to_string(),
|
||||||
KomorebiLayout::Monocle => "Toggle monocle".to_string(),
|
KomorebiLayout::Monocle => "Toggle monocle".to_string(),
|
||||||
KomorebiLayout::Floating => "Toggle tiling".to_string(),
|
KomorebiLayout::Floating => "Toggle tiling".to_string(),
|
||||||
KomorebiLayout::Paused => "Toggle pause".to_string(),
|
KomorebiLayout::Paused => "Toggle pause".to_string(),
|
||||||
KomorebiLayout::Custom => "Custom".to_string(),
|
KomorebiLayout::Custom => "Custom".to_string(),
|
||||||
})
|
})
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
layout_option.on_click_option(monitor_idx, Some(workspace_idx));
|
layout_option.on_click_option(monitor_idx, Some(workspace_idx));
|
||||||
show_options = false;
|
show_options = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -46,30 +46,28 @@ impl Media {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle(&self) {
|
pub fn toggle(&self) {
|
||||||
if let Ok(session) = self.session_manager.GetCurrentSession() {
|
if let Ok(session) = self.session_manager.GetCurrentSession()
|
||||||
if let Ok(op) = session.TryTogglePlayPauseAsync() {
|
&& let Ok(op) = session.TryTogglePlayPauseAsync()
|
||||||
op.get().unwrap_or_default();
|
{
|
||||||
}
|
op.get().unwrap_or_default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn output(&mut self) -> String {
|
fn output(&mut self) -> String {
|
||||||
if let Ok(session) = self.session_manager.GetCurrentSession() {
|
if let Ok(session) = self.session_manager.GetCurrentSession()
|
||||||
if let Ok(operation) = session.TryGetMediaPropertiesAsync() {
|
&& let Ok(operation) = session.TryGetMediaPropertiesAsync()
|
||||||
if let Ok(properties) = operation.get() {
|
&& let Ok(properties) = operation.get()
|
||||||
if let (Ok(artist), Ok(title)) = (properties.Artist(), properties.Title()) {
|
&& let (Ok(artist), Ok(title)) = (properties.Artist(), properties.Title())
|
||||||
if artist.is_empty() {
|
{
|
||||||
return format!("{title}");
|
if artist.is_empty() {
|
||||||
}
|
return format!("{title}");
|
||||||
|
|
||||||
if title.is_empty() {
|
|
||||||
return format!("{artist}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return format!("{artist} - {title}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if title.is_empty() {
|
||||||
|
return format!("{artist}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return format!("{artist} - {title}");
|
||||||
}
|
}
|
||||||
|
|
||||||
String::new()
|
String::new()
|
||||||
|
|||||||
@@ -124,12 +124,10 @@ impl BarWidget for Memory {
|
|||||||
if SelectableFrame::new_auto(output.selected, auto_focus_fill)
|
if SelectableFrame::new_auto(output.selected, auto_focus_fill)
|
||||||
.show(ui, |ui| ui.add(Label::new(layout_job).selectable(false)))
|
.show(ui, |ui| ui.add(Label::new(layout_job).selectable(false)))
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
&& let Err(error) =
|
||||||
if let Err(error) =
|
|
||||||
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{error}")
|
eprintln!("{error}")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,10 +110,10 @@ impl Network {
|
|||||||
if now.duration_since(self.last_updated_default_interface)
|
if now.duration_since(self.last_updated_default_interface)
|
||||||
> Duration::from_secs(self.default_refresh_interval)
|
> Duration::from_secs(self.default_refresh_interval)
|
||||||
{
|
{
|
||||||
if let Ok(interface) = netdev::get_default_interface() {
|
if let Ok(interface) = netdev::get_default_interface()
|
||||||
if let Some(friendly_name) = &interface.friendly_name {
|
&& let Some(friendly_name) = &interface.friendly_name
|
||||||
self.default_interface.clone_from(friendly_name);
|
{
|
||||||
}
|
self.default_interface.clone_from(friendly_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.last_updated_default_interface = now;
|
self.last_updated_default_interface = now;
|
||||||
@@ -131,43 +131,40 @@ impl Network {
|
|||||||
activity.clear();
|
activity.clear();
|
||||||
total_activity.clear();
|
total_activity.clear();
|
||||||
|
|
||||||
if let Ok(interface) = netdev::get_default_interface() {
|
if let Ok(interface) = netdev::get_default_interface()
|
||||||
if let Some(friendly_name) = &interface.friendly_name {
|
&& let Some(friendly_name) = &interface.friendly_name
|
||||||
self.default_interface.clone_from(friendly_name);
|
{
|
||||||
|
self.default_interface.clone_from(friendly_name);
|
||||||
|
|
||||||
self.networks_network_activity.refresh(true);
|
self.networks_network_activity.refresh(true);
|
||||||
|
|
||||||
for (interface_name, data) in &self.networks_network_activity {
|
for (interface_name, data) in &self.networks_network_activity {
|
||||||
if friendly_name.eq(interface_name) {
|
if friendly_name.eq(interface_name) {
|
||||||
if self.show_activity {
|
if self.show_activity {
|
||||||
let received = Self::to_pretty_bytes(
|
let received =
|
||||||
data.received(),
|
Self::to_pretty_bytes(data.received(), self.data_refresh_interval);
|
||||||
self.data_refresh_interval,
|
let transmitted = Self::to_pretty_bytes(
|
||||||
);
|
data.transmitted(),
|
||||||
let transmitted = Self::to_pretty_bytes(
|
self.data_refresh_interval,
|
||||||
data.transmitted(),
|
);
|
||||||
self.data_refresh_interval,
|
|
||||||
);
|
|
||||||
|
|
||||||
activity.push(NetworkReading::new(
|
activity.push(NetworkReading::new(
|
||||||
NetworkReadingFormat::Speed,
|
NetworkReadingFormat::Speed,
|
||||||
ReadingValue::from(received),
|
ReadingValue::from(received),
|
||||||
ReadingValue::from(transmitted),
|
ReadingValue::from(transmitted),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.show_total_activity {
|
if self.show_total_activity {
|
||||||
let total_received =
|
let total_received = Self::to_pretty_bytes(data.total_received(), 1);
|
||||||
Self::to_pretty_bytes(data.total_received(), 1);
|
let total_transmitted =
|
||||||
let total_transmitted =
|
Self::to_pretty_bytes(data.total_transmitted(), 1);
|
||||||
Self::to_pretty_bytes(data.total_transmitted(), 1);
|
|
||||||
|
|
||||||
total_activity.push(NetworkReading::new(
|
total_activity.push(NetworkReading::new(
|
||||||
NetworkReadingFormat::Total,
|
NetworkReadingFormat::Total,
|
||||||
ReadingValue::from(total_received),
|
ReadingValue::from(total_received),
|
||||||
ReadingValue::from(total_transmitted),
|
ReadingValue::from(total_transmitted),
|
||||||
))
|
))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -327,10 +324,9 @@ impl Network {
|
|||||||
if SelectableFrame::new_auto(selected, auto_focus_fill)
|
if SelectableFrame::new_auto(selected, auto_focus_fill)
|
||||||
.show(ui, add_contents)
|
.show(ui, add_contents)
|
||||||
.clicked()
|
.clicked()
|
||||||
|
&& let Err(error) = Command::new("cmd.exe").args(["/C", "ncpa"]).spawn()
|
||||||
{
|
{
|
||||||
if let Err(error) = Command::new("cmd.exe").args(["/C", "ncpa"]).spawn() {
|
eprintln!("{error}");
|
||||||
eprintln!("{error}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,17 +156,15 @@ impl BarWidget for Storage {
|
|||||||
if SelectableFrame::new_auto(output.selected, auto_focus_fill)
|
if SelectableFrame::new_auto(output.selected, auto_focus_fill)
|
||||||
.show(ui, |ui| ui.add(Label::new(layout_job).selectable(false)))
|
.show(ui, |ui| ui.add(Label::new(layout_job).selectable(false)))
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
&& let Err(error) = Command::new("cmd.exe")
|
||||||
if let Err(error) = Command::new("cmd.exe")
|
|
||||||
.args([
|
.args([
|
||||||
"/C",
|
"/C",
|
||||||
"explorer.exe",
|
"explorer.exe",
|
||||||
output.label.split(' ').collect::<Vec<&str>>()[0],
|
output.label.split(' ').collect::<Vec<&str>>()[0],
|
||||||
])
|
])
|
||||||
.spawn()
|
.spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{error}")
|
eprintln!("{error}")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,16 +140,14 @@ impl BarWidget for Update {
|
|||||||
if SelectableFrame::new(false)
|
if SelectableFrame::new(false)
|
||||||
.show(ui, |ui| ui.add(Label::new(layout_job).selectable(false)))
|
.show(ui, |ui| ui.add(Label::new(layout_job).selectable(false)))
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
&& let Err(error) = Command::new("explorer.exe")
|
||||||
if let Err(error) = Command::new("explorer.exe")
|
|
||||||
.args([format!(
|
.args([format!(
|
||||||
"https://github.com/LGUG2Z/komorebi/releases/v{}",
|
"https://github.com/LGUG2Z/komorebi/releases/v{}",
|
||||||
self.latest_version
|
self.latest_version
|
||||||
)])
|
)])
|
||||||
.spawn()
|
.spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{error}")
|
eprintln!("{error}")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,10 +102,10 @@ pub extern "system" fn border_hwnds(hwnd: HWND, lparam: LPARAM) -> BOOL {
|
|||||||
let hwnds = unsafe { &mut *(lparam.0 as *mut Vec<isize>) };
|
let hwnds = unsafe { &mut *(lparam.0 as *mut Vec<isize>) };
|
||||||
let hwnd = hwnd.0 as isize;
|
let hwnd = hwnd.0 as isize;
|
||||||
|
|
||||||
if let Ok(class) = WindowsApi::real_window_class_w(hwnd) {
|
if let Ok(class) = WindowsApi::real_window_class_w(hwnd)
|
||||||
if class.starts_with("komoborder") {
|
&& class.starts_with("komoborder")
|
||||||
hwnds.push(hwnd);
|
{
|
||||||
}
|
hwnds.push(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
true.into()
|
true.into()
|
||||||
@@ -392,63 +392,63 @@ impl Border {
|
|||||||
tracing::error!("failed to update border position {error}");
|
tracing::error!("failed to update border position {error}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if !rect.is_same_size_as(&old_rect) || !rect.has_same_position_as(&old_rect) {
|
if (!rect.is_same_size_as(&old_rect) || !rect.has_same_position_as(&old_rect))
|
||||||
if let Some(render_target) = (*border_pointer).render_target.as_ref() {
|
&& let Some(render_target) = (*border_pointer).render_target.as_ref()
|
||||||
let border_width = (*border_pointer).width;
|
{
|
||||||
let border_offset = (*border_pointer).offset;
|
let border_width = (*border_pointer).width;
|
||||||
|
let border_offset = (*border_pointer).offset;
|
||||||
|
|
||||||
(*border_pointer).rounded_rect.rect = D2D_RECT_F {
|
(*border_pointer).rounded_rect.rect = D2D_RECT_F {
|
||||||
left: (border_width / 2 - border_offset) as f32,
|
left: (border_width / 2 - border_offset) as f32,
|
||||||
top: (border_width / 2 - border_offset) as f32,
|
top: (border_width / 2 - border_offset) as f32,
|
||||||
right: (rect.right - border_width / 2 + border_offset) as f32,
|
right: (rect.right - border_width / 2 + border_offset) as f32,
|
||||||
bottom: (rect.bottom - border_width / 2 + border_offset) as f32,
|
bottom: (rect.bottom - border_width / 2 + border_offset) as f32,
|
||||||
|
};
|
||||||
|
|
||||||
|
let _ = render_target.Resize(&D2D_SIZE_U {
|
||||||
|
width: rect.right as u32,
|
||||||
|
height: rect.bottom as u32,
|
||||||
|
});
|
||||||
|
|
||||||
|
let window_kind = (*border_pointer).window_kind;
|
||||||
|
if let Some(brush) = (*border_pointer).brushes.get(&window_kind) {
|
||||||
|
render_target.BeginDraw();
|
||||||
|
render_target.Clear(None);
|
||||||
|
|
||||||
|
// Calculate border radius based on style
|
||||||
|
let style = match (*border_pointer).style {
|
||||||
|
BorderStyle::System => {
|
||||||
|
if *WINDOWS_11 {
|
||||||
|
BorderStyle::Rounded
|
||||||
|
} else {
|
||||||
|
BorderStyle::Square
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BorderStyle::Rounded => BorderStyle::Rounded,
|
||||||
|
BorderStyle::Square => BorderStyle::Square,
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = render_target.Resize(&D2D_SIZE_U {
|
match style {
|
||||||
width: rect.right as u32,
|
BorderStyle::Rounded => {
|
||||||
height: rect.bottom as u32,
|
render_target.DrawRoundedRectangle(
|
||||||
});
|
&(*border_pointer).rounded_rect,
|
||||||
|
brush,
|
||||||
let window_kind = (*border_pointer).window_kind;
|
border_width as f32,
|
||||||
if let Some(brush) = (*border_pointer).brushes.get(&window_kind) {
|
None,
|
||||||
render_target.BeginDraw();
|
);
|
||||||
render_target.Clear(None);
|
|
||||||
|
|
||||||
// Calculate border radius based on style
|
|
||||||
let style = match (*border_pointer).style {
|
|
||||||
BorderStyle::System => {
|
|
||||||
if *WINDOWS_11 {
|
|
||||||
BorderStyle::Rounded
|
|
||||||
} else {
|
|
||||||
BorderStyle::Square
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BorderStyle::Rounded => BorderStyle::Rounded,
|
|
||||||
BorderStyle::Square => BorderStyle::Square,
|
|
||||||
};
|
|
||||||
|
|
||||||
match style {
|
|
||||||
BorderStyle::Rounded => {
|
|
||||||
render_target.DrawRoundedRectangle(
|
|
||||||
&(*border_pointer).rounded_rect,
|
|
||||||
brush,
|
|
||||||
border_width as f32,
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
BorderStyle::Square => {
|
|
||||||
render_target.DrawRectangle(
|
|
||||||
&(*border_pointer).rounded_rect.rect,
|
|
||||||
brush,
|
|
||||||
border_width as f32,
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
BorderStyle::Square => {
|
||||||
let _ = render_target.EndDraw(None, None);
|
render_target.DrawRectangle(
|
||||||
|
&(*border_pointer).rounded_rect.rect,
|
||||||
|
brush,
|
||||||
|
border_width as f32,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _ = render_target.EndDraw(None, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -341,15 +341,11 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
|
|||||||
should_process_notification = true;
|
should_process_notification = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !should_process_notification {
|
if !should_process_notification
|
||||||
if let Some(Notification::Update(ref previous)) = previous_notification
|
&& let Some(Notification::Update(ref previous)) = previous_notification
|
||||||
{
|
&& previous.unwrap_or_default() != notification_hwnd.unwrap_or_default()
|
||||||
if previous.unwrap_or_default()
|
{
|
||||||
!= notification_hwnd.unwrap_or_default()
|
should_process_notification = true;
|
||||||
{
|
|
||||||
should_process_notification = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
should_process_notification
|
should_process_notification
|
||||||
|
|||||||
@@ -45,12 +45,11 @@ impl Container {
|
|||||||
for window in self.windows().iter().rev() {
|
for window in self.windows().iter().rev() {
|
||||||
let mut should_hide = omit.is_none();
|
let mut should_hide = omit.is_none();
|
||||||
|
|
||||||
if !should_hide {
|
if !should_hide
|
||||||
if let Some(omit) = omit {
|
&& let Some(omit) = omit
|
||||||
if omit != window.hwnd {
|
&& omit != window.hwnd
|
||||||
should_hide = true
|
{
|
||||||
}
|
should_hide = true
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if should_hide {
|
if should_hide {
|
||||||
@@ -82,10 +81,10 @@ impl Container {
|
|||||||
|
|
||||||
pub fn hwnd_from_exe(&self, exe: &str) -> Option<isize> {
|
pub fn hwnd_from_exe(&self, exe: &str) -> Option<isize> {
|
||||||
for window in self.windows() {
|
for window in self.windows() {
|
||||||
if let Ok(window_exe) = window.exe() {
|
if let Ok(window_exe) = window.exe()
|
||||||
if exe == window_exe {
|
&& exe == window_exe
|
||||||
return Option::from(window.hwnd);
|
{
|
||||||
}
|
return Option::from(window.hwnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,10 +93,10 @@ impl Container {
|
|||||||
|
|
||||||
pub fn idx_from_exe(&self, exe: &str) -> Option<usize> {
|
pub fn idx_from_exe(&self, exe: &str) -> Option<usize> {
|
||||||
for (idx, window) in self.windows().iter().enumerate() {
|
for (idx, window) in self.windows().iter().enumerate() {
|
||||||
if let Ok(window_exe) = window.exe() {
|
if let Ok(window_exe) = window.exe()
|
||||||
if exe == window_exe {
|
&& exe == window_exe
|
||||||
return Option::from(idx);
|
{
|
||||||
}
|
return Option::from(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,10 +70,9 @@ impl Arrangement for DefaultLayout {
|
|||||||
if matches!(
|
if matches!(
|
||||||
layout_flip,
|
layout_flip,
|
||||||
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
||||||
) {
|
) && let 2.. = len
|
||||||
if let 2.. = len {
|
{
|
||||||
columns_reverse(&mut layouts);
|
columns_reverse(&mut layouts);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// treat >= column_count as scrolling
|
// treat >= column_count as scrolling
|
||||||
@@ -166,10 +165,9 @@ impl Arrangement for DefaultLayout {
|
|||||||
if matches!(
|
if matches!(
|
||||||
layout_flip,
|
layout_flip,
|
||||||
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
||||||
) {
|
) && let 2.. = len
|
||||||
if let 2.. = len {
|
{
|
||||||
columns_reverse(&mut layouts);
|
columns_reverse(&mut layouts);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
@@ -191,10 +189,9 @@ impl Arrangement for DefaultLayout {
|
|||||||
if matches!(
|
if matches!(
|
||||||
layout_flip,
|
layout_flip,
|
||||||
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
||||||
) {
|
) && let 2.. = len
|
||||||
if let 2.. = len {
|
{
|
||||||
rows_reverse(&mut layouts);
|
rows_reverse(&mut layouts);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
@@ -245,25 +242,23 @@ impl Arrangement for DefaultLayout {
|
|||||||
if matches!(
|
if matches!(
|
||||||
layout_flip,
|
layout_flip,
|
||||||
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
||||||
) {
|
) && let 2.. = len
|
||||||
if let 2.. = len {
|
{
|
||||||
let (primary, rest) = layouts.split_at_mut(1);
|
let (primary, rest) = layouts.split_at_mut(1);
|
||||||
let primary = &mut primary[0];
|
let primary = &mut primary[0];
|
||||||
|
|
||||||
for rect in rest.iter_mut() {
|
for rect in rest.iter_mut() {
|
||||||
rect.left = primary.left;
|
rect.left = primary.left;
|
||||||
}
|
|
||||||
primary.left = rest[0].left + rest[0].right;
|
|
||||||
}
|
}
|
||||||
|
primary.left = rest[0].left + rest[0].right;
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches!(
|
if matches!(
|
||||||
layout_flip,
|
layout_flip,
|
||||||
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
||||||
) {
|
) && let 3.. = len
|
||||||
if let 3.. = len {
|
{
|
||||||
rows_reverse(&mut layouts[1..]);
|
rows_reverse(&mut layouts[1..]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
@@ -317,25 +312,23 @@ impl Arrangement for DefaultLayout {
|
|||||||
if matches!(
|
if matches!(
|
||||||
layout_flip,
|
layout_flip,
|
||||||
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
||||||
) {
|
) && let 2.. = len
|
||||||
if let 2.. = len {
|
{
|
||||||
let (primary, rest) = layouts.split_at_mut(1);
|
let (primary, rest) = layouts.split_at_mut(1);
|
||||||
let primary = &mut primary[0];
|
let primary = &mut primary[0];
|
||||||
|
|
||||||
primary.left = rest[0].left;
|
primary.left = rest[0].left;
|
||||||
for rect in rest.iter_mut() {
|
for rect in rest.iter_mut() {
|
||||||
rect.left = primary.left + primary.right;
|
rect.left = primary.left + primary.right;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches!(
|
if matches!(
|
||||||
layout_flip,
|
layout_flip,
|
||||||
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
||||||
) {
|
) && let 3.. = len
|
||||||
if let 3.. = len {
|
{
|
||||||
rows_reverse(&mut layouts[1..]);
|
rows_reverse(&mut layouts[1..]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
@@ -386,25 +379,23 @@ impl Arrangement for DefaultLayout {
|
|||||||
if matches!(
|
if matches!(
|
||||||
layout_flip,
|
layout_flip,
|
||||||
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
||||||
) {
|
) && let 2.. = len
|
||||||
if let 2.. = len {
|
{
|
||||||
let (primary, rest) = layouts.split_at_mut(1);
|
let (primary, rest) = layouts.split_at_mut(1);
|
||||||
let primary = &mut primary[0];
|
let primary = &mut primary[0];
|
||||||
|
|
||||||
for rect in rest.iter_mut() {
|
for rect in rest.iter_mut() {
|
||||||
rect.top = primary.top;
|
rect.top = primary.top;
|
||||||
}
|
|
||||||
primary.top = rest[0].top + rest[0].bottom;
|
|
||||||
}
|
}
|
||||||
|
primary.top = rest[0].top + rest[0].bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches!(
|
if matches!(
|
||||||
layout_flip,
|
layout_flip,
|
||||||
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
||||||
) {
|
) && let 3.. = len
|
||||||
if let 3.. = len {
|
{
|
||||||
columns_reverse(&mut layouts[1..]);
|
columns_reverse(&mut layouts[1..]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
@@ -513,10 +504,9 @@ impl Arrangement for DefaultLayout {
|
|||||||
if matches!(
|
if matches!(
|
||||||
layout_flip,
|
layout_flip,
|
||||||
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
||||||
) {
|
) && let 4.. = len
|
||||||
if let 4.. = len {
|
{
|
||||||
rows_reverse(&mut layouts[2..]);
|
rows_reverse(&mut layouts[2..]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
@@ -782,67 +772,67 @@ fn calculate_resize_adjustments(resize_dimensions: &[Option<Rect>]) -> Vec<Optio
|
|||||||
|
|
||||||
// This needs to be aware of layout flips
|
// This needs to be aware of layout flips
|
||||||
for (i, opt) in resize_dimensions.iter().enumerate() {
|
for (i, opt) in resize_dimensions.iter().enumerate() {
|
||||||
if let Some(resize_ref) = opt {
|
if let Some(resize_ref) = opt
|
||||||
if i > 0 {
|
&& i > 0
|
||||||
if resize_ref.left != 0 {
|
{
|
||||||
#[allow(clippy::if_not_else)]
|
if resize_ref.left != 0 {
|
||||||
let range = if i == 1 {
|
#[allow(clippy::if_not_else)]
|
||||||
0..1
|
let range = if i == 1 {
|
||||||
} else if i & 1 != 0 {
|
0..1
|
||||||
i - 1..i
|
} else if i & 1 != 0 {
|
||||||
} else {
|
i - 1..i
|
||||||
i - 2..i
|
} else {
|
||||||
};
|
i - 2..i
|
||||||
|
};
|
||||||
|
|
||||||
for n in range {
|
for n in range {
|
||||||
let should_adjust = n % 2 == 0;
|
let should_adjust = n % 2 == 0;
|
||||||
if should_adjust {
|
if should_adjust {
|
||||||
if let Some(Some(adjacent_resize)) = resize_adjustments.get_mut(n) {
|
if let Some(Some(adjacent_resize)) = resize_adjustments.get_mut(n) {
|
||||||
adjacent_resize.right += resize_ref.left;
|
adjacent_resize.right += resize_ref.left;
|
||||||
} else {
|
} else {
|
||||||
resize_adjustments[n] = Option::from(Rect {
|
resize_adjustments[n] = Option::from(Rect {
|
||||||
left: 0,
|
left: 0,
|
||||||
top: 0,
|
top: 0,
|
||||||
right: resize_ref.left,
|
right: resize_ref.left,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(rr) = resize_adjustments[i].as_mut() {
|
|
||||||
rr.left = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if resize_ref.top != 0 {
|
if let Some(rr) = resize_adjustments[i].as_mut() {
|
||||||
let range = if i == 1 {
|
rr.left = 0;
|
||||||
0..1
|
}
|
||||||
} else if i & 1 == 0 {
|
}
|
||||||
i - 1..i
|
|
||||||
} else {
|
|
||||||
i - 2..i
|
|
||||||
};
|
|
||||||
|
|
||||||
for n in range {
|
if resize_ref.top != 0 {
|
||||||
let should_adjust = n % 2 != 0;
|
let range = if i == 1 {
|
||||||
if should_adjust {
|
0..1
|
||||||
if let Some(Some(adjacent_resize)) = resize_adjustments.get_mut(n) {
|
} else if i & 1 == 0 {
|
||||||
adjacent_resize.bottom += resize_ref.top;
|
i - 1..i
|
||||||
} else {
|
} else {
|
||||||
resize_adjustments[n] = Option::from(Rect {
|
i - 2..i
|
||||||
left: 0,
|
};
|
||||||
top: 0,
|
|
||||||
right: 0,
|
for n in range {
|
||||||
bottom: resize_ref.top,
|
let should_adjust = n % 2 != 0;
|
||||||
});
|
if should_adjust {
|
||||||
}
|
if let Some(Some(adjacent_resize)) = resize_adjustments.get_mut(n) {
|
||||||
|
adjacent_resize.bottom += resize_ref.top;
|
||||||
|
} else {
|
||||||
|
resize_adjustments[n] = Option::from(Rect {
|
||||||
|
left: 0,
|
||||||
|
top: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: resize_ref.top,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(Some(resize)) = resize_adjustments.get_mut(i) {
|
if let Some(Some(resize)) = resize_adjustments.get_mut(i) {
|
||||||
resize.top = 0;
|
resize.top = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,11 +211,10 @@ lazy_static! {
|
|||||||
pub static ref AHK_EXE: String = {
|
pub static ref AHK_EXE: String = {
|
||||||
let mut ahk: String = String::from("autohotkey.exe");
|
let mut ahk: String = String::from("autohotkey.exe");
|
||||||
|
|
||||||
if let Ok(komorebi_ahk_exe) = std::env::var("KOMOREBI_AHK_EXE") {
|
if let Ok(komorebi_ahk_exe) = std::env::var("KOMOREBI_AHK_EXE")
|
||||||
if which(&komorebi_ahk_exe).is_ok() {
|
&& which(&komorebi_ahk_exe).is_ok() {
|
||||||
ahk = komorebi_ahk_exe;
|
ahk = komorebi_ahk_exe;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ahk
|
ahk
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -233,10 +233,10 @@ fn main() -> Result<()> {
|
|||||||
if matched_procs.len() > 1 {
|
if matched_procs.len() > 1 {
|
||||||
let mut len = matched_procs.len();
|
let mut len = matched_procs.len();
|
||||||
for proc in matched_procs {
|
for proc in matched_procs {
|
||||||
if let Some(executable_path) = proc.exe() {
|
if let Some(executable_path) = proc.exe()
|
||||||
if executable_path.to_string_lossy().contains("shims") {
|
&& executable_path.to_string_lossy().contains("shims")
|
||||||
len -= 1;
|
{
|
||||||
}
|
len -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,12 +100,12 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
for d in &all_displays {
|
for d in &all_displays {
|
||||||
if let Some(id) = &d.serial_number_id {
|
if let Some(id) = &d.serial_number_id
|
||||||
if serial_id_map.get(id).copied().unwrap_or_default() > 1 {
|
&& serial_id_map.get(id).copied().unwrap_or_default() > 1
|
||||||
let mut dupes = DUPLICATE_MONITOR_SERIAL_IDS.write();
|
{
|
||||||
if !dupes.contains(id) {
|
let mut dupes = DUPLICATE_MONITOR_SERIAL_IDS.write();
|
||||||
(*dupes).push(id.clone());
|
if !dupes.contains(id) {
|
||||||
}
|
(*dupes).push(id.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,17 +221,17 @@ where
|
|||||||
let mut should_update = false;
|
let mut should_update = false;
|
||||||
|
|
||||||
// Update work areas as necessary
|
// Update work areas as necessary
|
||||||
if let Ok(reference) = WindowsApi::monitor(monitor.id) {
|
if let Ok(reference) = WindowsApi::monitor(monitor.id)
|
||||||
if reference.work_area_size != monitor.work_area_size {
|
&& reference.work_area_size != monitor.work_area_size
|
||||||
monitor.work_area_size = Rect {
|
{
|
||||||
left: reference.work_area_size.left,
|
monitor.work_area_size = Rect {
|
||||||
top: reference.work_area_size.top,
|
left: reference.work_area_size.left,
|
||||||
right: reference.work_area_size.right,
|
top: reference.work_area_size.top,
|
||||||
bottom: reference.work_area_size.bottom,
|
right: reference.work_area_size.right,
|
||||||
};
|
bottom: reference.work_area_size.bottom,
|
||||||
|
};
|
||||||
|
|
||||||
should_update = true;
|
should_update = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if should_update {
|
if should_update {
|
||||||
|
|||||||
@@ -195,16 +195,15 @@ impl WindowManager {
|
|||||||
message: SocketMessage,
|
message: SocketMessage,
|
||||||
mut reply: impl std::io::Write,
|
mut reply: impl std::io::Write,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if let Some(virtual_desktop_id) = &self.virtual_desktop_id {
|
if let Some(virtual_desktop_id) = &self.virtual_desktop_id
|
||||||
if let Some(id) = current_virtual_desktop() {
|
&& let Some(id) = current_virtual_desktop()
|
||||||
if id != *virtual_desktop_id {
|
&& id != *virtual_desktop_id
|
||||||
tracing::info!(
|
{
|
||||||
"ignoring events and commands while not on virtual desktop {:?}",
|
tracing::info!(
|
||||||
virtual_desktop_id
|
"ignoring events and commands while not on virtual desktop {:?}",
|
||||||
);
|
virtual_desktop_id
|
||||||
return Ok(());
|
);
|
||||||
}
|
return Ok(());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::useless_asref)]
|
#[allow(clippy::useless_asref)]
|
||||||
@@ -532,10 +531,10 @@ impl WindowManager {
|
|||||||
|
|
||||||
let mut should_push = true;
|
let mut should_push = true;
|
||||||
for m in &*manage_identifiers {
|
for m in &*manage_identifiers {
|
||||||
if let MatchingRule::Simple(m) = m {
|
if let MatchingRule::Simple(m) = m
|
||||||
if m.id.eq(id) {
|
&& m.id.eq(id)
|
||||||
should_push = false;
|
{
|
||||||
}
|
should_push = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,10 +598,10 @@ impl WindowManager {
|
|||||||
|
|
||||||
let mut should_push = true;
|
let mut should_push = true;
|
||||||
for i in &*ignore_identifiers {
|
for i in &*ignore_identifiers {
|
||||||
if let MatchingRule::Simple(i) = i {
|
if let MatchingRule::Simple(i) = i
|
||||||
if i.id.eq(id) {
|
&& i.id.eq(id)
|
||||||
should_push = false;
|
{
|
||||||
}
|
should_push = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -692,16 +691,13 @@ impl WindowManager {
|
|||||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||||
// secondary monitor where the cursor is focused will be used as the target for
|
// secondary monitor where the cursor is focused will be used as the target for
|
||||||
// the workspace switch op
|
// the workspace switch op
|
||||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||||
if monitor_idx != self.focused_monitor_idx() {
|
&& monitor_idx != self.focused_monitor_idx()
|
||||||
if let Some(monitor) = self.monitors().get(monitor_idx) {
|
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||||
if let Some(workspace) = monitor.focused_workspace() {
|
&& let Some(workspace) = monitor.focused_workspace()
|
||||||
if workspace.is_empty() {
|
&& workspace.is_empty()
|
||||||
self.focus_monitor(monitor_idx)?;
|
{
|
||||||
}
|
self.focus_monitor(monitor_idx)?;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let idx = self
|
let idx = self
|
||||||
@@ -709,10 +705,10 @@ impl WindowManager {
|
|||||||
.ok_or_eyre("there is no monitor")?
|
.ok_or_eyre("there is no monitor")?
|
||||||
.focused_workspace_idx();
|
.focused_workspace_idx();
|
||||||
|
|
||||||
if let Some(monitor) = self.focused_monitor_mut() {
|
if let Some(monitor) = self.focused_monitor_mut()
|
||||||
if let Some(last_focused_workspace) = monitor.last_focused_workspace {
|
&& let Some(last_focused_workspace) = monitor.last_focused_workspace
|
||||||
self.move_container_to_workspace(last_focused_workspace, true, None)?;
|
{
|
||||||
}
|
self.move_container_to_workspace(last_focused_workspace, true, None)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.focused_monitor_mut()
|
self.focused_monitor_mut()
|
||||||
@@ -723,16 +719,13 @@ impl WindowManager {
|
|||||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||||
// secondary monitor where the cursor is focused will be used as the target for
|
// secondary monitor where the cursor is focused will be used as the target for
|
||||||
// the workspace switch op
|
// the workspace switch op
|
||||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||||
if monitor_idx != self.focused_monitor_idx() {
|
&& monitor_idx != self.focused_monitor_idx()
|
||||||
if let Some(monitor) = self.monitors().get(monitor_idx) {
|
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||||
if let Some(workspace) = monitor.focused_workspace() {
|
&& let Some(workspace) = monitor.focused_workspace()
|
||||||
if workspace.is_empty() {
|
&& workspace.is_empty()
|
||||||
self.focus_monitor(monitor_idx)?;
|
{
|
||||||
}
|
self.focus_monitor(monitor_idx)?;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let idx = self
|
let idx = self
|
||||||
@@ -740,10 +733,10 @@ impl WindowManager {
|
|||||||
.ok_or_eyre("there is no monitor")?
|
.ok_or_eyre("there is no monitor")?
|
||||||
.focused_workspace_idx();
|
.focused_workspace_idx();
|
||||||
|
|
||||||
if let Some(monitor) = self.focused_monitor_mut() {
|
if let Some(monitor) = self.focused_monitor_mut()
|
||||||
if let Some(last_focused_workspace) = monitor.last_focused_workspace {
|
&& let Some(last_focused_workspace) = monitor.last_focused_workspace
|
||||||
self.move_container_to_workspace(last_focused_workspace, false, None)?;
|
{
|
||||||
}
|
self.move_container_to_workspace(last_focused_workspace, false, None)?;
|
||||||
}
|
}
|
||||||
self.focused_monitor_mut()
|
self.focused_monitor_mut()
|
||||||
.ok_or_eyre("there is no monitor")?
|
.ok_or_eyre("there is no monitor")?
|
||||||
@@ -1038,16 +1031,13 @@ impl WindowManager {
|
|||||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||||
// secondary monitor where the cursor is focused will be used as the target for
|
// secondary monitor where the cursor is focused will be used as the target for
|
||||||
// the workspace switch op
|
// the workspace switch op
|
||||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||||
if monitor_idx != self.focused_monitor_idx() {
|
&& monitor_idx != self.focused_monitor_idx()
|
||||||
if let Some(monitor) = self.monitors().get(monitor_idx) {
|
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||||
if let Some(workspace) = monitor.focused_workspace() {
|
&& let Some(workspace) = monitor.focused_workspace()
|
||||||
if workspace.is_empty() {
|
&& workspace.is_empty()
|
||||||
self.focus_monitor(monitor_idx)?;
|
{
|
||||||
}
|
self.focus_monitor(monitor_idx)?;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
||||||
@@ -1067,16 +1057,13 @@ impl WindowManager {
|
|||||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||||
// secondary monitor where the cursor is focused will be used as the target for
|
// secondary monitor where the cursor is focused will be used as the target for
|
||||||
// the workspace switch op
|
// the workspace switch op
|
||||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||||
if monitor_idx != self.focused_monitor_idx() {
|
&& monitor_idx != self.focused_monitor_idx()
|
||||||
if let Some(monitor) = self.monitors().get(monitor_idx) {
|
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||||
if let Some(workspace) = monitor.focused_workspace() {
|
&& let Some(workspace) = monitor.focused_workspace()
|
||||||
if workspace.is_empty() {
|
&& workspace.is_empty()
|
||||||
self.focus_monitor(monitor_idx)?;
|
{
|
||||||
}
|
self.focus_monitor(monitor_idx)?;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
let focused_monitor = self.focused_monitor().ok_or_eyre("there is no monitor")?;
|
||||||
@@ -1114,16 +1101,13 @@ impl WindowManager {
|
|||||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||||
// secondary monitor where the cursor is focused will be used as the target for
|
// secondary monitor where the cursor is focused will be used as the target for
|
||||||
// the workspace switch op
|
// the workspace switch op
|
||||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||||
if monitor_idx != self.focused_monitor_idx() {
|
&& monitor_idx != self.focused_monitor_idx()
|
||||||
if let Some(monitor) = self.monitors().get(monitor_idx) {
|
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||||
if let Some(workspace) = monitor.focused_workspace() {
|
&& let Some(workspace) = monitor.focused_workspace()
|
||||||
if workspace.is_empty() {
|
&& workspace.is_empty()
|
||||||
self.focus_monitor(monitor_idx)?;
|
{
|
||||||
}
|
self.focus_monitor(monitor_idx)?;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut can_close = false;
|
let mut can_close = false;
|
||||||
@@ -1132,16 +1116,15 @@ impl WindowManager {
|
|||||||
let focused_workspace_idx = monitor.focused_workspace_idx();
|
let focused_workspace_idx = monitor.focused_workspace_idx();
|
||||||
let next_focused_workspace_idx = focused_workspace_idx.saturating_sub(1);
|
let next_focused_workspace_idx = focused_workspace_idx.saturating_sub(1);
|
||||||
|
|
||||||
if let Some(workspace) = monitor.focused_workspace() {
|
if let Some(workspace) = monitor.focused_workspace()
|
||||||
if monitor.workspaces().len() > 1
|
&& monitor.workspaces().len() > 1
|
||||||
&& workspace.containers().is_empty()
|
&& workspace.containers().is_empty()
|
||||||
&& workspace.floating_windows().is_empty()
|
&& workspace.floating_windows().is_empty()
|
||||||
&& workspace.monocle_container.is_none()
|
&& workspace.monocle_container.is_none()
|
||||||
&& workspace.maximized_window.is_none()
|
&& workspace.maximized_window.is_none()
|
||||||
&& workspace.name.is_none()
|
&& workspace.name.is_none()
|
||||||
{
|
{
|
||||||
can_close = true;
|
can_close = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if can_close
|
if can_close
|
||||||
@@ -1158,16 +1141,13 @@ impl WindowManager {
|
|||||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||||
// secondary monitor where the cursor is focused will be used as the target for
|
// secondary monitor where the cursor is focused will be used as the target for
|
||||||
// the workspace switch op
|
// the workspace switch op
|
||||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||||
if monitor_idx != self.focused_monitor_idx() {
|
&& monitor_idx != self.focused_monitor_idx()
|
||||||
if let Some(monitor) = self.monitors().get(monitor_idx) {
|
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||||
if let Some(workspace) = monitor.focused_workspace() {
|
&& let Some(workspace) = monitor.focused_workspace()
|
||||||
if workspace.is_empty() {
|
&& workspace.is_empty()
|
||||||
self.focus_monitor(monitor_idx)?;
|
{
|
||||||
}
|
self.focus_monitor(monitor_idx)?;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let idx = self
|
let idx = self
|
||||||
@@ -1175,10 +1155,10 @@ impl WindowManager {
|
|||||||
.ok_or_eyre("there is no monitor")?
|
.ok_or_eyre("there is no monitor")?
|
||||||
.focused_workspace_idx();
|
.focused_workspace_idx();
|
||||||
|
|
||||||
if let Some(monitor) = self.focused_monitor_mut() {
|
if let Some(monitor) = self.focused_monitor_mut()
|
||||||
if let Some(last_focused_workspace) = monitor.last_focused_workspace {
|
&& let Some(last_focused_workspace) = monitor.last_focused_workspace
|
||||||
self.focus_workspace(last_focused_workspace)?;
|
{
|
||||||
}
|
self.focus_workspace(last_focused_workspace)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.focused_monitor_mut()
|
self.focused_monitor_mut()
|
||||||
@@ -1189,16 +1169,13 @@ impl WindowManager {
|
|||||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||||
// secondary monitor where the cursor is focused will be used as the target for
|
// secondary monitor where the cursor is focused will be used as the target for
|
||||||
// the workspace switch op
|
// the workspace switch op
|
||||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||||
if monitor_idx != self.focused_monitor_idx() {
|
&& monitor_idx != self.focused_monitor_idx()
|
||||||
if let Some(monitor) = self.monitors().get(monitor_idx) {
|
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||||
if let Some(workspace) = monitor.focused_workspace() {
|
&& let Some(workspace) = monitor.focused_workspace()
|
||||||
if workspace.is_empty() {
|
&& workspace.is_empty()
|
||||||
self.focus_monitor(monitor_idx)?;
|
{
|
||||||
}
|
self.focus_monitor(monitor_idx)?;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.focused_workspace_idx().unwrap_or_default() != workspace_idx {
|
if self.focused_workspace_idx().unwrap_or_default() != workspace_idx {
|
||||||
@@ -1209,16 +1186,13 @@ impl WindowManager {
|
|||||||
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
// This is to ensure that even on an empty workspace on a secondary monitor, the
|
||||||
// secondary monitor where the cursor is focused will be used as the target for
|
// secondary monitor where the cursor is focused will be used as the target for
|
||||||
// the workspace switch op
|
// the workspace switch op
|
||||||
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
|
if let Some(monitor_idx) = self.monitor_idx_from_current_pos()
|
||||||
if monitor_idx != self.focused_monitor_idx() {
|
&& monitor_idx != self.focused_monitor_idx()
|
||||||
if let Some(monitor) = self.monitors().get(monitor_idx) {
|
&& let Some(monitor) = self.monitors().get(monitor_idx)
|
||||||
if let Some(workspace) = monitor.focused_workspace() {
|
&& let Some(workspace) = monitor.focused_workspace()
|
||||||
if workspace.is_empty() {
|
&& workspace.is_empty()
|
||||||
self.focus_monitor(monitor_idx)?;
|
{
|
||||||
}
|
self.focus_monitor(monitor_idx)?;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let focused_monitor_idx = self.focused_monitor_idx();
|
let focused_monitor_idx = self.focused_monitor_idx();
|
||||||
@@ -1297,10 +1271,10 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(monocle) = &workspace.monocle_container {
|
if let Some(monocle) = &workspace.monocle_container
|
||||||
if let Some(window) = monocle.focused_window() {
|
&& let Some(window) = monocle.focused_window()
|
||||||
window.lower()?;
|
{
|
||||||
}
|
window.lower()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WorkspaceLayer::Floating => {
|
WorkspaceLayer::Floating => {
|
||||||
@@ -1515,17 +1489,15 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for rule in &mut workspace.layout_rules {
|
for rule in &mut workspace.layout_rules {
|
||||||
if container_len >= rule.0 {
|
if container_len >= rule.0
|
||||||
if let Layout::Custom(ref mut custom) = rule.1 {
|
&& let Layout::Custom(ref mut custom) = rule.1
|
||||||
match sizing {
|
{
|
||||||
Sizing::Increase => {
|
match sizing {
|
||||||
custom
|
Sizing::Increase => {
|
||||||
.set_primary_width_percentage(percentage + 5.0);
|
custom.set_primary_width_percentage(percentage + 5.0);
|
||||||
}
|
}
|
||||||
Sizing::Decrease => {
|
Sizing::Decrease => {
|
||||||
custom
|
custom.set_primary_width_percentage(percentage - 5.0);
|
||||||
.set_primary_width_percentage(percentage - 5.0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1807,10 +1779,10 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
|||||||
|
|
||||||
let mut should_push = true;
|
let mut should_push = true;
|
||||||
for i in &*identifiers {
|
for i in &*identifiers {
|
||||||
if let MatchingRule::Simple(i) = i {
|
if let MatchingRule::Simple(i) = i
|
||||||
if i.id.eq(id) {
|
&& i.id.eq(id)
|
||||||
should_push = false;
|
{
|
||||||
}
|
should_push = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1826,10 +1798,10 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
|||||||
let mut identifiers = TRAY_AND_MULTI_WINDOW_IDENTIFIERS.lock();
|
let mut identifiers = TRAY_AND_MULTI_WINDOW_IDENTIFIERS.lock();
|
||||||
let mut should_push = true;
|
let mut should_push = true;
|
||||||
for i in &*identifiers {
|
for i in &*identifiers {
|
||||||
if let MatchingRule::Simple(i) = i {
|
if let MatchingRule::Simple(i) = i
|
||||||
if i.id.eq(id) {
|
&& i.id.eq(id)
|
||||||
should_push = false;
|
{
|
||||||
}
|
should_push = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1846,10 +1818,10 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
|||||||
|
|
||||||
let mut should_push = true;
|
let mut should_push = true;
|
||||||
for i in &*identifiers {
|
for i in &*identifiers {
|
||||||
if let MatchingRule::Simple(i) = i {
|
if let MatchingRule::Simple(i) = i
|
||||||
if i.id.eq(id) {
|
&& i.id.eq(id)
|
||||||
should_push = false;
|
{
|
||||||
}
|
should_push = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1879,11 +1851,11 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SocketMessage::WorkspaceWorkAreaOffset(monitor_idx, workspace_idx, rect) => {
|
SocketMessage::WorkspaceWorkAreaOffset(monitor_idx, workspace_idx, rect) => {
|
||||||
if let Some(monitor) = self.monitors_mut().get_mut(monitor_idx) {
|
if let Some(monitor) = self.monitors_mut().get_mut(monitor_idx)
|
||||||
if let Some(workspace) = monitor.workspaces_mut().get_mut(workspace_idx) {
|
&& let Some(workspace) = monitor.workspaces_mut().get_mut(workspace_idx)
|
||||||
workspace.work_area_offset = Option::from(rect);
|
{
|
||||||
self.retile_all(false)?
|
workspace.work_area_offset = Option::from(rect);
|
||||||
}
|
self.retile_all(false)?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SocketMessage::ToggleWindowBasedWorkAreaOffset => {
|
SocketMessage::ToggleWindowBasedWorkAreaOffset => {
|
||||||
@@ -2251,10 +2223,10 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
|||||||
|
|
||||||
let mut should_push = true;
|
let mut should_push = true;
|
||||||
for i in &*identifiers {
|
for i in &*identifiers {
|
||||||
if let MatchingRule::Simple(i) = i {
|
if let MatchingRule::Simple(i) = i
|
||||||
if i.id.eq(id) {
|
&& i.id.eq(id)
|
||||||
should_push = false;
|
{
|
||||||
}
|
should_push = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,12 +207,11 @@ impl WindowManager {
|
|||||||
//
|
//
|
||||||
// This check ensures that we only update the focused monitor when the window
|
// This check ensures that we only update the focused monitor when the window
|
||||||
// triggering monitor reconciliation is known to not be tied to a specific monitor.
|
// triggering monitor reconciliation is known to not be tied to a specific monitor.
|
||||||
if let Ok(class) = window.class() {
|
if let Ok(class) = window.class()
|
||||||
if class != "OleMainThreadWndClass"
|
&& class != "OleMainThreadWndClass"
|
||||||
&& self.focused_monitor_idx() != monitor_idx
|
&& self.focused_monitor_idx() != monitor_idx
|
||||||
{
|
{
|
||||||
self.focus_monitor(monitor_idx)?;
|
self.focus_monitor(monitor_idx)?;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -323,10 +322,10 @@ impl WindowManager {
|
|||||||
|
|
||||||
match floating_window_idx {
|
match floating_window_idx {
|
||||||
None => {
|
None => {
|
||||||
if let Some(w) = &workspace.maximized_window {
|
if let Some(w) = &workspace.maximized_window
|
||||||
if w.hwnd == window.hwnd {
|
&& w.hwnd == window.hwnd
|
||||||
return Ok(());
|
{
|
||||||
}
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(monocle) = &workspace.monocle_container {
|
if let Some(monocle) = &workspace.monocle_container {
|
||||||
@@ -393,23 +392,20 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((m_idx, w_idx)) = self.known_hwnds.get(&window.hwnd) {
|
if let Some((m_idx, w_idx)) = self.known_hwnds.get(&window.hwnd)
|
||||||
if let Some(focused_workspace_idx) = self
|
&& let Some(focused_workspace_idx) = self
|
||||||
.monitors()
|
.monitors()
|
||||||
.get(*m_idx)
|
.get(*m_idx)
|
||||||
.map(|m| m.focused_workspace_idx())
|
.map(|m| m.focused_workspace_idx())
|
||||||
{
|
&& *m_idx != self.focused_monitor_idx()
|
||||||
if *m_idx != self.focused_monitor_idx()
|
&& *w_idx != focused_workspace_idx
|
||||||
&& *w_idx != focused_workspace_idx
|
{
|
||||||
{
|
tracing::debug!(
|
||||||
tracing::debug!(
|
"ignoring show event for window already associated with another workspace"
|
||||||
"ignoring show event for window already associated with another workspace"
|
);
|
||||||
);
|
|
||||||
|
|
||||||
window.hide();
|
window.hide();
|
||||||
proceed = false;
|
proceed = false;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if proceed {
|
if proceed {
|
||||||
@@ -508,12 +504,11 @@ impl WindowManager {
|
|||||||
|
|
||||||
if workspace_contains_window {
|
if workspace_contains_window {
|
||||||
let mut monocle_window_event = false;
|
let mut monocle_window_event = false;
|
||||||
if let Some(ref monocle) = monocle_container {
|
if let Some(ref monocle) = monocle_container
|
||||||
if let Some(monocle_window) = monocle.focused_window() {
|
&& let Some(monocle_window) = monocle.focused_window()
|
||||||
if monocle_window.hwnd == window.hwnd {
|
&& monocle_window.hwnd == window.hwnd
|
||||||
monocle_window_event = true;
|
{
|
||||||
}
|
monocle_window_event = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let workspace = self.focused_workspace()?;
|
let workspace = self.focused_workspace()?;
|
||||||
@@ -548,14 +543,14 @@ impl WindowManager {
|
|||||||
|
|
||||||
// If the window handles don't match then something went wrong and the pending move
|
// If the window handles don't match then something went wrong and the pending move
|
||||||
// is not related to this current move, if so abort this operation.
|
// is not related to this current move, if so abort this operation.
|
||||||
if let Some((_, _, w_hwnd)) = pending {
|
if let Some((_, _, w_hwnd)) = pending
|
||||||
if w_hwnd != window.hwnd {
|
&& w_hwnd != window.hwnd
|
||||||
color_eyre::eyre::bail!(
|
{
|
||||||
"window handles for move operation don't match: {} != {}",
|
color_eyre::eyre::bail!(
|
||||||
w_hwnd,
|
"window handles for move operation don't match: {} != {}",
|
||||||
window.hwnd
|
w_hwnd,
|
||||||
);
|
window.hwnd
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let target_monitor_idx = self
|
let target_monitor_idx = self
|
||||||
@@ -583,10 +578,10 @@ impl WindowManager {
|
|||||||
// This will be true if we have moved to another monitor
|
// This will be true if we have moved to another monitor
|
||||||
let mut moved_across_monitors = false;
|
let mut moved_across_monitors = false;
|
||||||
|
|
||||||
if let Some((m_idx, _)) = self.known_hwnds.get(&window.hwnd) {
|
if let Some((m_idx, _)) = self.known_hwnds.get(&window.hwnd)
|
||||||
if *m_idx != target_monitor_idx {
|
&& *m_idx != target_monitor_idx
|
||||||
moved_across_monitors = true;
|
{
|
||||||
}
|
moved_across_monitors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((origin_monitor_idx, origin_workspace_idx, _)) = pending {
|
if let Some((origin_monitor_idx, origin_workspace_idx, _)) = pending {
|
||||||
@@ -848,13 +843,12 @@ impl WindowManager {
|
|||||||
|
|
||||||
if let Some(target_container) =
|
if let Some(target_container) =
|
||||||
c_idx.and_then(|c_idx| target_workspace.containers().get(c_idx))
|
c_idx.and_then(|c_idx| target_workspace.containers().get(c_idx))
|
||||||
|
&& target_container.focused_window() != Some(&window)
|
||||||
{
|
{
|
||||||
if target_container.focused_window() != Some(&window) {
|
tracing::debug!(
|
||||||
tracing::debug!(
|
"Needs reconciliation within a stack on the focused workspace"
|
||||||
"Needs reconciliation within a stack on the focused workspace"
|
);
|
||||||
);
|
needs_reconciliation = Some((*m_idx, *ws_idx));
|
||||||
needs_reconciliation = Some((*m_idx, *ws_idx));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -353,16 +353,15 @@ impl Stackbar {
|
|||||||
// stackbar, make sure we update its location so that it doesn't render
|
// stackbar, make sure we update its location so that it doesn't render
|
||||||
// on top of other tiles before eventually ending up in the correct
|
// on top of other tiles before eventually ending up in the correct
|
||||||
// tile
|
// tile
|
||||||
if index != focused_window_idx {
|
if index != focused_window_idx
|
||||||
if let Err(err) =
|
&& let Err(err) =
|
||||||
window.set_position(&focused_window_rect, false)
|
window.set_position(&focused_window_rect, false)
|
||||||
{
|
{
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
"stackbar WM_LBUTTONDOWN repositioning error: hwnd {} ({})",
|
"stackbar WM_LBUTTONDOWN repositioning error: hwnd {} ({})",
|
||||||
*window,
|
*window,
|
||||||
err
|
err
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the window corresponding to the tab we have clicked
|
// Restore the window corresponding to the tab we have clicked
|
||||||
|
|||||||
@@ -1367,12 +1367,12 @@ impl StaticConfig {
|
|||||||
for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() {
|
for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() {
|
||||||
let preferred_config_idx = {
|
let preferred_config_idx = {
|
||||||
let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read();
|
let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read();
|
||||||
let c_idx = display_index_preferences.iter().find_map(|(c_idx, id)| {
|
|
||||||
|
display_index_preferences.iter().find_map(|(c_idx, id)| {
|
||||||
(monitor.serial_number_id.as_ref().is_some_and(|sn| sn == id)
|
(monitor.serial_number_id.as_ref().is_some_and(|sn| sn == id)
|
||||||
|| monitor.device_id.eq(id))
|
|| monitor.device_id.eq(id))
|
||||||
.then_some(*c_idx)
|
.then_some(*c_idx)
|
||||||
});
|
})
|
||||||
c_idx
|
|
||||||
};
|
};
|
||||||
let idx = preferred_config_idx.or({
|
let idx = preferred_config_idx.or({
|
||||||
// Monitor without preferred config idx.
|
// Monitor without preferred config idx.
|
||||||
@@ -1538,12 +1538,12 @@ impl StaticConfig {
|
|||||||
for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() {
|
for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() {
|
||||||
let preferred_config_idx = {
|
let preferred_config_idx = {
|
||||||
let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read();
|
let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read();
|
||||||
let c_idx = display_index_preferences.iter().find_map(|(c_idx, id)| {
|
|
||||||
|
display_index_preferences.iter().find_map(|(c_idx, id)| {
|
||||||
(monitor.serial_number_id.as_ref().is_some_and(|sn| sn == id)
|
(monitor.serial_number_id.as_ref().is_some_and(|sn| sn == id)
|
||||||
|| monitor.device_id.eq(id))
|
|| monitor.device_id.eq(id))
|
||||||
.then_some(*c_idx)
|
.then_some(*c_idx)
|
||||||
});
|
})
|
||||||
c_idx
|
|
||||||
};
|
};
|
||||||
let idx = preferred_config_idx.or({
|
let idx = preferred_config_idx.or({
|
||||||
// Monitor without preferred config idx.
|
// Monitor without preferred config idx.
|
||||||
|
|||||||
@@ -152,25 +152,25 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
|
|||||||
for (window_idx, window) in c.windows().iter().enumerate() {
|
for (window_idx, window) in c.windows().iter().enumerate() {
|
||||||
if window_idx == focused_window_idx {
|
if window_idx == focused_window_idx {
|
||||||
let mut should_make_transparent = true;
|
let mut should_make_transparent = true;
|
||||||
if !transparency_blacklist.is_empty() {
|
if !transparency_blacklist.is_empty()
|
||||||
if let (Ok(title), Ok(exe_name), Ok(class), Ok(path)) = (
|
&& let (Ok(title), Ok(exe_name), Ok(class), Ok(path)) = (
|
||||||
window.title(),
|
window.title(),
|
||||||
window.exe(),
|
window.exe(),
|
||||||
window.class(),
|
window.class(),
|
||||||
window.path(),
|
window.path(),
|
||||||
) {
|
)
|
||||||
let is_blacklisted = should_act(
|
{
|
||||||
&title,
|
let is_blacklisted = should_act(
|
||||||
&exe_name,
|
&title,
|
||||||
&class,
|
&exe_name,
|
||||||
&path,
|
&class,
|
||||||
&transparency_blacklist,
|
&path,
|
||||||
®ex_identifiers,
|
&transparency_blacklist,
|
||||||
)
|
®ex_identifiers,
|
||||||
.is_some();
|
)
|
||||||
|
.is_some();
|
||||||
|
|
||||||
should_make_transparent = !is_blacklisted;
|
should_make_transparent = !is_blacklisted;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if should_make_transparent {
|
if should_make_transparent {
|
||||||
|
|||||||
@@ -568,15 +568,15 @@ impl Window {
|
|||||||
|
|
||||||
pub fn focus(self, mouse_follows_focus: bool) -> Result<()> {
|
pub fn focus(self, mouse_follows_focus: bool) -> Result<()> {
|
||||||
// If the target window is already focused, do nothing.
|
// If the target window is already focused, do nothing.
|
||||||
if let Ok(ihwnd) = WindowsApi::foreground_window() {
|
if let Ok(ihwnd) = WindowsApi::foreground_window()
|
||||||
if ihwnd == self.hwnd {
|
&& ihwnd == self.hwnd
|
||||||
// Center cursor in Window
|
{
|
||||||
if mouse_follows_focus {
|
// Center cursor in Window
|
||||||
WindowsApi::center_cursor_in_rect(&WindowsApi::window_rect(self.hwnd)?)?;
|
if mouse_follows_focus {
|
||||||
}
|
WindowsApi::center_cursor_in_rect(&WindowsApi::window_rect(self.hwnd)?)?;
|
||||||
|
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowsApi::raise_and_focus_window(self.hwnd)?;
|
WindowsApi::raise_and_focus_window(self.hwnd)?;
|
||||||
@@ -817,13 +817,13 @@ impl Window {
|
|||||||
|
|
||||||
let mut allow_cloaked = false;
|
let mut allow_cloaked = false;
|
||||||
|
|
||||||
if let Some(event) = event {
|
if let Some(event) = event
|
||||||
if matches!(
|
&& matches!(
|
||||||
event,
|
event,
|
||||||
WindowManagerEvent::Hide(_, _) | WindowManagerEvent::Cloak(_, _)
|
WindowManagerEvent::Hide(_, _) | WindowManagerEvent::Cloak(_, _)
|
||||||
) {
|
)
|
||||||
allow_cloaked = true;
|
{
|
||||||
}
|
allow_cloaked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug.allow_cloaked = allow_cloaked;
|
debug.allow_cloaked = allow_cloaked;
|
||||||
@@ -1302,31 +1302,31 @@ pub fn should_act_individual(
|
|||||||
},
|
},
|
||||||
Some(MatchingStrategy::Regex) => match identifier.kind {
|
Some(MatchingStrategy::Regex) => match identifier.kind {
|
||||||
ApplicationIdentifier::Title => {
|
ApplicationIdentifier::Title => {
|
||||||
if let Some(re) = regex_identifiers.get(&identifier.id) {
|
if let Some(re) = regex_identifiers.get(&identifier.id)
|
||||||
if re.is_match(title) {
|
&& re.is_match(title)
|
||||||
should_act = true;
|
{
|
||||||
}
|
should_act = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ApplicationIdentifier::Class => {
|
ApplicationIdentifier::Class => {
|
||||||
if let Some(re) = regex_identifiers.get(&identifier.id) {
|
if let Some(re) = regex_identifiers.get(&identifier.id)
|
||||||
if re.is_match(class) {
|
&& re.is_match(class)
|
||||||
should_act = true;
|
{
|
||||||
}
|
should_act = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ApplicationIdentifier::Exe => {
|
ApplicationIdentifier::Exe => {
|
||||||
if let Some(re) = regex_identifiers.get(&identifier.id) {
|
if let Some(re) = regex_identifiers.get(&identifier.id)
|
||||||
if re.is_match(exe_name) {
|
&& re.is_match(exe_name)
|
||||||
should_act = true;
|
{
|
||||||
}
|
should_act = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ApplicationIdentifier::Path => {
|
ApplicationIdentifier::Path => {
|
||||||
if let Some(re) = regex_identifiers.get(&identifier.id) {
|
if let Some(re) = regex_identifiers.get(&identifier.id)
|
||||||
if re.is_match(path) {
|
&& re.is_match(path)
|
||||||
should_act = true;
|
{
|
||||||
}
|
should_act = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -486,11 +486,11 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(window) = workspace.maximized_window {
|
if let Some(window) = workspace.maximized_window
|
||||||
if window.exe().is_err() {
|
&& window.exe().is_err()
|
||||||
can_apply = false;
|
{
|
||||||
break;
|
can_apply = false;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(container) = &workspace.monocle_container {
|
if let Some(container) = &workspace.monocle_container {
|
||||||
@@ -522,21 +522,20 @@ impl WindowManager {
|
|||||||
for (monitor_idx, monitor) in self.monitors_mut().iter_mut().enumerate() {
|
for (monitor_idx, monitor) in self.monitors_mut().iter_mut().enumerate() {
|
||||||
let mut focused_workspace = 0;
|
let mut focused_workspace = 0;
|
||||||
for (workspace_idx, workspace) in monitor.workspaces_mut().iter_mut().enumerate() {
|
for (workspace_idx, workspace) in monitor.workspaces_mut().iter_mut().enumerate() {
|
||||||
if let Some(state_monitor) = state.monitors.elements().get(monitor_idx) {
|
if let Some(state_monitor) = state.monitors.elements().get(monitor_idx)
|
||||||
if let Some(state_workspace) = state_monitor.workspaces().get(workspace_idx)
|
&& let Some(state_workspace) = state_monitor.workspaces().get(workspace_idx)
|
||||||
{
|
{
|
||||||
// to make sure padding changes get applied for users after a quick restart
|
// to make sure padding changes get applied for users after a quick restart
|
||||||
let container_padding = workspace.container_padding;
|
let container_padding = workspace.container_padding;
|
||||||
let workspace_padding = workspace.workspace_padding;
|
let workspace_padding = workspace.workspace_padding;
|
||||||
|
|
||||||
*workspace = state_workspace.clone();
|
*workspace = state_workspace.clone();
|
||||||
|
|
||||||
workspace.container_padding = container_padding;
|
workspace.container_padding = container_padding;
|
||||||
workspace.workspace_padding = workspace_padding;
|
workspace.workspace_padding = workspace_padding;
|
||||||
|
|
||||||
if state_monitor.focused_workspace_idx() == workspace_idx {
|
if state_monitor.focused_workspace_idx() == workspace_idx {
|
||||||
focused_workspace = workspace_idx;
|
focused_workspace = workspace_idx;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -622,66 +621,61 @@ impl WindowManager {
|
|||||||
monitor_idx: usize,
|
monitor_idx: usize,
|
||||||
workspace_idx: usize,
|
workspace_idx: usize,
|
||||||
) -> WindowManagementBehaviour {
|
) -> WindowManagementBehaviour {
|
||||||
if let Some(monitor) = self.monitors().get(monitor_idx) {
|
if let Some(monitor) = self.monitors().get(monitor_idx)
|
||||||
if let Some(workspace) = monitor.workspaces().get(workspace_idx) {
|
&& let Some(workspace) = monitor.workspaces().get(workspace_idx)
|
||||||
let current_behaviour =
|
{
|
||||||
if let Some(behaviour) = workspace.window_container_behaviour {
|
let current_behaviour = if let Some(behaviour) = workspace.window_container_behaviour {
|
||||||
if workspace.containers().is_empty()
|
if workspace.containers().is_empty()
|
||||||
&& matches!(behaviour, WindowContainerBehaviour::Append)
|
&& matches!(behaviour, WindowContainerBehaviour::Append)
|
||||||
{
|
{
|
||||||
// You can't append to an empty workspace
|
// You can't append to an empty workspace
|
||||||
WindowContainerBehaviour::Create
|
WindowContainerBehaviour::Create
|
||||||
} else {
|
|
||||||
behaviour
|
|
||||||
}
|
|
||||||
} else if workspace.containers().is_empty()
|
|
||||||
&& matches!(
|
|
||||||
self.window_management_behaviour.current_behaviour,
|
|
||||||
WindowContainerBehaviour::Append
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// You can't append to an empty workspace
|
|
||||||
WindowContainerBehaviour::Create
|
|
||||||
} else {
|
|
||||||
self.window_management_behaviour.current_behaviour
|
|
||||||
};
|
|
||||||
|
|
||||||
let float_override = if let Some(float_override) = workspace.float_override {
|
|
||||||
float_override
|
|
||||||
} else {
|
} else {
|
||||||
self.window_management_behaviour.float_override
|
behaviour
|
||||||
|
}
|
||||||
|
} else if workspace.containers().is_empty()
|
||||||
|
&& matches!(
|
||||||
|
self.window_management_behaviour.current_behaviour,
|
||||||
|
WindowContainerBehaviour::Append
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// You can't append to an empty workspace
|
||||||
|
WindowContainerBehaviour::Create
|
||||||
|
} else {
|
||||||
|
self.window_management_behaviour.current_behaviour
|
||||||
|
};
|
||||||
|
|
||||||
|
let float_override = if let Some(float_override) = workspace.float_override {
|
||||||
|
float_override
|
||||||
|
} else {
|
||||||
|
self.window_management_behaviour.float_override
|
||||||
|
};
|
||||||
|
|
||||||
|
let floating_layer_behaviour =
|
||||||
|
if let Some(behaviour) = workspace.floating_layer_behaviour {
|
||||||
|
behaviour
|
||||||
|
} else {
|
||||||
|
monitor
|
||||||
|
.floating_layer_behaviour
|
||||||
|
.unwrap_or(self.window_management_behaviour.floating_layer_behaviour)
|
||||||
};
|
};
|
||||||
|
|
||||||
let floating_layer_behaviour =
|
// If the workspace layer is `Floating` and the floating layer behaviour should
|
||||||
if let Some(behaviour) = workspace.floating_layer_behaviour {
|
// float then change floating_layer_override to true so that new windows spawn
|
||||||
behaviour
|
// as floating
|
||||||
} else {
|
let floating_layer_override = matches!(workspace.layer, WorkspaceLayer::Floating)
|
||||||
monitor
|
&& floating_layer_behaviour.should_float();
|
||||||
.floating_layer_behaviour
|
|
||||||
.unwrap_or(self.window_management_behaviour.floating_layer_behaviour)
|
|
||||||
};
|
|
||||||
|
|
||||||
// If the workspace layer is `Floating` and the floating layer behaviour should
|
return WindowManagementBehaviour {
|
||||||
// float then change floating_layer_override to true so that new windows spawn
|
current_behaviour,
|
||||||
// as floating
|
float_override,
|
||||||
let floating_layer_override = matches!(workspace.layer, WorkspaceLayer::Floating)
|
floating_layer_override,
|
||||||
&& floating_layer_behaviour.should_float();
|
floating_layer_behaviour,
|
||||||
|
toggle_float_placement: self.window_management_behaviour.toggle_float_placement,
|
||||||
return WindowManagementBehaviour {
|
floating_layer_placement: self.window_management_behaviour.floating_layer_placement,
|
||||||
current_behaviour,
|
float_override_placement: self.window_management_behaviour.float_override_placement,
|
||||||
float_override,
|
float_rule_placement: self.window_management_behaviour.float_rule_placement,
|
||||||
floating_layer_override,
|
};
|
||||||
floating_layer_behaviour,
|
|
||||||
toggle_float_placement: self.window_management_behaviour.toggle_float_placement,
|
|
||||||
floating_layer_placement: self
|
|
||||||
.window_management_behaviour
|
|
||||||
.floating_layer_placement,
|
|
||||||
float_override_placement: self
|
|
||||||
.window_management_behaviour
|
|
||||||
.float_override_placement,
|
|
||||||
float_rule_placement: self.window_management_behaviour.float_rule_placement,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowManagementBehaviour {
|
WindowManagementBehaviour {
|
||||||
@@ -1049,10 +1043,10 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if workspace.wallpaper.is_some() || monitor_wp.is_some() {
|
if (workspace.wallpaper.is_some() || monitor_wp.is_some())
|
||||||
if let Err(error) = workspace.apply_wallpaper(hmonitor, &monitor_wp) {
|
&& let Err(error) = workspace.apply_wallpaper(hmonitor, &monitor_wp)
|
||||||
tracing::error!("failed to apply wallpaper: {}", error);
|
{
|
||||||
}
|
tracing::error!("failed to apply wallpaper: {}", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
workspace.update()?;
|
workspace.update()?;
|
||||||
@@ -1081,24 +1075,22 @@ impl WindowManager {
|
|||||||
|
|
||||||
let workspace = self.focused_workspace()?;
|
let workspace = self.focused_workspace()?;
|
||||||
// first check the focused workspace
|
// first check the focused workspace
|
||||||
if let Some(container_idx) = workspace.container_idx_from_current_point() {
|
if let Some(container_idx) = workspace.container_idx_from_current_point()
|
||||||
if let Some(container) = workspace.containers().get(container_idx) {
|
&& let Some(container) = workspace.containers().get(container_idx)
|
||||||
if let Some(window) = container.focused_window() {
|
&& let Some(window) = container.focused_window()
|
||||||
hwnd = Some(window.hwnd);
|
{
|
||||||
}
|
hwnd = Some(window.hwnd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// then check all workspaces
|
// then check all workspaces
|
||||||
if hwnd.is_none() {
|
if hwnd.is_none() {
|
||||||
for monitor in self.monitors() {
|
for monitor in self.monitors() {
|
||||||
for ws in monitor.workspaces() {
|
for ws in monitor.workspaces() {
|
||||||
if let Some(container_idx) = ws.container_idx_from_current_point() {
|
if let Some(container_idx) = ws.container_idx_from_current_point()
|
||||||
if let Some(container) = ws.containers().get(container_idx) {
|
&& let Some(container) = ws.containers().get(container_idx)
|
||||||
if let Some(window) = container.focused_window() {
|
&& let Some(window) = container.focused_window()
|
||||||
hwnd = Some(window.hwnd);
|
{
|
||||||
}
|
hwnd = Some(window.hwnd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1399,10 +1391,10 @@ impl WindowManager {
|
|||||||
window.focus(self.mouse_follows_focus)?;
|
window.focus(self.mouse_follows_focus)?;
|
||||||
}
|
}
|
||||||
} else if let Some(container) = &self.focused_workspace()?.monocle_container {
|
} else if let Some(container) = &self.focused_workspace()?.monocle_container {
|
||||||
if let Some(window) = container.focused_window() {
|
if let Some(window) = container.focused_window()
|
||||||
if trigger_focus {
|
&& trigger_focus
|
||||||
window.focus(self.mouse_follows_focus)?;
|
{
|
||||||
}
|
window.focus(self.mouse_follows_focus)?;
|
||||||
}
|
}
|
||||||
} else if let Ok(window) = self.focused_window_mut() {
|
} else if let Ok(window) = self.focused_window_mut() {
|
||||||
if trigger_focus {
|
if trigger_focus {
|
||||||
@@ -1443,12 +1435,10 @@ impl WindowManager {
|
|||||||
&& self.focused_workspace()?.monocle_container.is_none()
|
&& self.focused_workspace()?.monocle_container.is_none()
|
||||||
// and we don't have any floating windows that should show on top
|
// and we don't have any floating windows that should show on top
|
||||||
&& self.focused_workspace()?.floating_windows().is_empty()
|
&& self.focused_workspace()?.floating_windows().is_empty()
|
||||||
|
&& let Ok(window) = self.focused_window_mut()
|
||||||
|
&& trigger_focus
|
||||||
{
|
{
|
||||||
if let Ok(window) = self.focused_window_mut() {
|
window.focus(self.mouse_follows_focus)?;
|
||||||
if trigger_focus {
|
|
||||||
window.focus(self.mouse_follows_focus)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1889,10 +1879,10 @@ impl WindowManager {
|
|||||||
|
|
||||||
let focused_monitor_idx = self.focused_monitor_idx();
|
let focused_monitor_idx = self.focused_monitor_idx();
|
||||||
|
|
||||||
if focused_monitor_idx == monitor_idx {
|
if focused_monitor_idx == monitor_idx
|
||||||
if let Some(workspace_idx) = workspace_idx {
|
&& let Some(workspace_idx) = workspace_idx
|
||||||
return self.move_container_to_workspace(workspace_idx, follow, None);
|
{
|
||||||
}
|
return self.move_container_to_workspace(workspace_idx, follow, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
@@ -1937,11 +1927,11 @@ impl WindowManager {
|
|||||||
.ok_or_eyre("there is no monitor")?;
|
.ok_or_eyre("there is no monitor")?;
|
||||||
|
|
||||||
let mut should_load_workspace = false;
|
let mut should_load_workspace = false;
|
||||||
if let Some(workspace_idx) = workspace_idx {
|
if let Some(workspace_idx) = workspace_idx
|
||||||
if workspace_idx != target_monitor.focused_workspace_idx() {
|
&& workspace_idx != target_monitor.focused_workspace_idx()
|
||||||
target_monitor.focus_workspace(workspace_idx)?;
|
{
|
||||||
should_load_workspace = true;
|
target_monitor.focus_workspace(workspace_idx)?;
|
||||||
}
|
should_load_workspace = true;
|
||||||
}
|
}
|
||||||
let target_workspace = target_monitor
|
let target_workspace = target_monitor
|
||||||
.focused_workspace_mut()
|
.focused_workspace_mut()
|
||||||
@@ -1979,12 +1969,12 @@ impl WindowManager {
|
|||||||
target_monitor.add_container(container, workspace_idx)?;
|
target_monitor.add_container(container, workspace_idx)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(workspace) = target_monitor.focused_workspace() {
|
if let Some(workspace) = target_monitor.focused_workspace()
|
||||||
if !workspace.tile {
|
&& !workspace.tile
|
||||||
for hwnd in container_hwnds {
|
{
|
||||||
Window::from(hwnd)
|
for hwnd in container_hwnds {
|
||||||
.move_to_area(¤t_area, &target_monitor.work_area_size)?;
|
Window::from(hwnd)
|
||||||
}
|
.move_to_area(¤t_area, &target_monitor.work_area_size)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2223,34 +2213,34 @@ impl WindowManager {
|
|||||||
|
|
||||||
self.focus_workspace(next_idx)?;
|
self.focus_workspace(next_idx)?;
|
||||||
|
|
||||||
if let Ok(focused_workspace) = self.focused_workspace_mut() {
|
if let Ok(focused_workspace) = self.focused_workspace_mut()
|
||||||
if focused_workspace.monocle_container.is_none() {
|
&& focused_workspace.monocle_container.is_none()
|
||||||
match direction {
|
{
|
||||||
OperationDirection::Left => match focused_workspace.layout {
|
match direction {
|
||||||
Layout::Default(layout) => {
|
OperationDirection::Left => match focused_workspace.layout {
|
||||||
let target_index =
|
Layout::Default(layout) => {
|
||||||
layout.rightmost_index(focused_workspace.containers().len());
|
let target_index =
|
||||||
focused_workspace.focus_container(target_index);
|
layout.rightmost_index(focused_workspace.containers().len());
|
||||||
}
|
focused_workspace.focus_container(target_index);
|
||||||
Layout::Custom(_) => {
|
}
|
||||||
focused_workspace.focus_container(
|
Layout::Custom(_) => {
|
||||||
focused_workspace.containers().len().saturating_sub(1),
|
focused_workspace.focus_container(
|
||||||
);
|
focused_workspace.containers().len().saturating_sub(1),
|
||||||
}
|
);
|
||||||
},
|
}
|
||||||
OperationDirection::Right => match focused_workspace.layout {
|
},
|
||||||
Layout::Default(layout) => {
|
OperationDirection::Right => match focused_workspace.layout {
|
||||||
let target_index =
|
Layout::Default(layout) => {
|
||||||
layout.leftmost_index(focused_workspace.containers().len());
|
let target_index =
|
||||||
focused_workspace.focus_container(target_index);
|
layout.leftmost_index(focused_workspace.containers().len());
|
||||||
}
|
focused_workspace.focus_container(target_index);
|
||||||
Layout::Custom(_) => {
|
}
|
||||||
focused_workspace.focus_container(0);
|
Layout::Custom(_) => {
|
||||||
}
|
focused_workspace.focus_container(0);
|
||||||
},
|
}
|
||||||
_ => {}
|
},
|
||||||
};
|
_ => {}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -2378,34 +2368,34 @@ impl WindowManager {
|
|||||||
|
|
||||||
self.focus_workspace(next_idx)?;
|
self.focus_workspace(next_idx)?;
|
||||||
|
|
||||||
if let Ok(focused_workspace) = self.focused_workspace_mut() {
|
if let Ok(focused_workspace) = self.focused_workspace_mut()
|
||||||
if focused_workspace.monocle_container.is_none() {
|
&& focused_workspace.monocle_container.is_none()
|
||||||
match direction {
|
{
|
||||||
OperationDirection::Left => match focused_workspace.layout {
|
match direction {
|
||||||
Layout::Default(layout) => {
|
OperationDirection::Left => match focused_workspace.layout {
|
||||||
let target_index =
|
Layout::Default(layout) => {
|
||||||
layout.rightmost_index(focused_workspace.containers().len());
|
let target_index =
|
||||||
focused_workspace.focus_container(target_index);
|
layout.rightmost_index(focused_workspace.containers().len());
|
||||||
}
|
focused_workspace.focus_container(target_index);
|
||||||
Layout::Custom(_) => {
|
}
|
||||||
focused_workspace.focus_container(
|
Layout::Custom(_) => {
|
||||||
focused_workspace.containers().len().saturating_sub(1),
|
focused_workspace.focus_container(
|
||||||
);
|
focused_workspace.containers().len().saturating_sub(1),
|
||||||
}
|
);
|
||||||
},
|
}
|
||||||
OperationDirection::Right => match focused_workspace.layout {
|
},
|
||||||
Layout::Default(layout) => {
|
OperationDirection::Right => match focused_workspace.layout {
|
||||||
let target_index =
|
Layout::Default(layout) => {
|
||||||
layout.leftmost_index(focused_workspace.containers().len());
|
let target_index =
|
||||||
focused_workspace.focus_container(target_index);
|
layout.leftmost_index(focused_workspace.containers().len());
|
||||||
}
|
focused_workspace.focus_container(target_index);
|
||||||
Layout::Custom(_) => {
|
}
|
||||||
focused_workspace.focus_container(0);
|
Layout::Custom(_) => {
|
||||||
}
|
focused_workspace.focus_container(0);
|
||||||
},
|
}
|
||||||
_ => {}
|
},
|
||||||
};
|
_ => {}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -2652,10 +2642,10 @@ impl WindowManager {
|
|||||||
|
|
||||||
// unset monocle container on target workspace if there is one
|
// unset monocle container on target workspace if there is one
|
||||||
let mut target_workspace_has_monocle = false;
|
let mut target_workspace_has_monocle = false;
|
||||||
if let Ok(target_workspace) = self.focused_workspace() {
|
if let Ok(target_workspace) = self.focused_workspace()
|
||||||
if target_workspace.monocle_container.is_some() {
|
&& target_workspace.monocle_container.is_some()
|
||||||
target_workspace_has_monocle = true;
|
{
|
||||||
}
|
target_workspace_has_monocle = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if target_workspace_has_monocle {
|
if target_workspace_has_monocle {
|
||||||
@@ -2782,10 +2772,10 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(idx) = target_idx {
|
if let Some(idx) = target_idx
|
||||||
if let Some(window) = focused_workspace.floating_windows().get(idx) {
|
&& let Some(window) = focused_workspace.floating_windows().get(idx)
|
||||||
window.focus(mouse_follows_focus)?;
|
{
|
||||||
}
|
window.focus(mouse_follows_focus)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -2962,10 +2952,10 @@ impl WindowManager {
|
|||||||
let workspace = self.focused_workspace_mut()?;
|
let workspace = self.focused_workspace_mut()?;
|
||||||
|
|
||||||
let mut focused_hwnd = None;
|
let mut focused_hwnd = None;
|
||||||
if let Some(container) = workspace.focused_container() {
|
if let Some(container) = workspace.focused_container()
|
||||||
if let Some(window) = container.focused_window() {
|
&& let Some(window) = container.focused_window()
|
||||||
focused_hwnd = Some(window.hwnd);
|
{
|
||||||
}
|
focused_hwnd = Some(window.hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
workspace.focus_container(workspace.containers().len().saturating_sub(1));
|
workspace.focus_container(workspace.containers().len().saturating_sub(1));
|
||||||
@@ -2989,10 +2979,10 @@ impl WindowManager {
|
|||||||
let workspace = self.focused_workspace_mut()?;
|
let workspace = self.focused_workspace_mut()?;
|
||||||
|
|
||||||
let mut focused_hwnd = None;
|
let mut focused_hwnd = None;
|
||||||
if let Some(container) = workspace.focused_container() {
|
if let Some(container) = workspace.focused_container()
|
||||||
if let Some(window) = container.focused_window() {
|
&& let Some(window) = container.focused_window()
|
||||||
focused_hwnd = Some(window.hwnd);
|
{
|
||||||
}
|
focused_hwnd = Some(window.hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
let initial_focused_container_index = workspace.focused_container_idx();
|
let initial_focused_container_index = workspace.focused_container_idx();
|
||||||
@@ -3061,10 +3051,10 @@ impl WindowManager {
|
|||||||
|
|
||||||
let mut target_container_is_stack = false;
|
let mut target_container_is_stack = false;
|
||||||
|
|
||||||
if let Some(container) = workspace.containers().get(adjusted_new_index) {
|
if let Some(container) = workspace.containers().get(adjusted_new_index)
|
||||||
if container.windows().len() > 1 {
|
&& container.windows().len() > 1
|
||||||
target_container_is_stack = true;
|
{
|
||||||
}
|
target_container_is_stack = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(current) = workspace.focused_container() {
|
if let Some(current) = workspace.focused_container() {
|
||||||
@@ -3077,12 +3067,10 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if changed_focus {
|
if changed_focus && let Some(container) = workspace.focused_container_mut() {
|
||||||
if let Some(container) = workspace.focused_container_mut() {
|
container.load_focused_window();
|
||||||
container.load_focused_window();
|
if let Some(window) = container.focused_window() {
|
||||||
if let Some(window) = container.focused_window() {
|
window.focus(self.mouse_follows_focus)?;
|
||||||
window.focus(self.mouse_follows_focus)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3929,10 +3917,10 @@ impl WindowManager {
|
|||||||
|
|
||||||
for (monitor_idx, monitor) in self.monitors().iter().enumerate() {
|
for (monitor_idx, monitor) in self.monitors().iter().enumerate() {
|
||||||
for (workspace_idx, workspace) in monitor.workspaces().iter().enumerate() {
|
for (workspace_idx, workspace) in monitor.workspaces().iter().enumerate() {
|
||||||
if let Some(workspace_name) = &workspace.name {
|
if let Some(workspace_name) = &workspace.name
|
||||||
if workspace_name == name {
|
&& workspace_name == name
|
||||||
return Option::from((monitor_idx, workspace_idx));
|
{
|
||||||
}
|
return Option::from((monitor_idx, workspace_idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,12 +282,12 @@ impl WindowsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for d in &all_displays {
|
for d in &all_displays {
|
||||||
if let Some(id) = &d.serial_number_id {
|
if let Some(id) = &d.serial_number_id
|
||||||
if serial_id_map.get(id).copied().unwrap_or_default() > 1 {
|
&& serial_id_map.get(id).copied().unwrap_or_default() > 1
|
||||||
let mut dupes = DUPLICATE_MONITOR_SERIAL_IDS.write();
|
{
|
||||||
if !dupes.contains(id) {
|
let mut dupes = DUPLICATE_MONITOR_SERIAL_IDS.write();
|
||||||
(*dupes).push(id.clone());
|
if !dupes.contains(id) {
|
||||||
}
|
(*dupes).push(id.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,16 +33,16 @@ pub extern "system" fn enum_window(hwnd: HWND, lparam: LPARAM) -> BOOL {
|
|||||||
if is_visible && is_window && !is_minimized {
|
if is_visible && is_window && !is_minimized {
|
||||||
let window = Window::from(hwnd);
|
let window = Window::from(hwnd);
|
||||||
|
|
||||||
if let Ok(should_manage) = window.should_manage(None, &mut RuleDebug::default()) {
|
if let Ok(should_manage) = window.should_manage(None, &mut RuleDebug::default())
|
||||||
if should_manage {
|
&& should_manage
|
||||||
if is_maximized {
|
{
|
||||||
WindowsApi::restore_window(window.hwnd);
|
if is_maximized {
|
||||||
}
|
WindowsApi::restore_window(window.hwnd);
|
||||||
|
|
||||||
let mut container = Container::default();
|
|
||||||
container.windows_mut().push_back(window);
|
|
||||||
containers.push_back(container);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut container = Container::default();
|
||||||
|
container.windows_mut().push_back(window);
|
||||||
|
containers.push_back(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,10 +59,10 @@ pub extern "system" fn alt_tab_windows(hwnd: HWND, lparam: LPARAM) -> BOOL {
|
|||||||
if is_visible && is_window && !is_minimized {
|
if is_visible && is_window && !is_minimized {
|
||||||
let window = Window::from(hwnd);
|
let window = Window::from(hwnd);
|
||||||
|
|
||||||
if let Ok(should_manage) = window.should_manage(None, &mut RuleDebug::default()) {
|
if let Ok(should_manage) = window.should_manage(None, &mut RuleDebug::default())
|
||||||
if should_manage {
|
&& should_manage
|
||||||
windows.push(window);
|
{
|
||||||
}
|
windows.push(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -238,12 +238,11 @@ impl Workspace {
|
|||||||
for window in self.floating_windows_mut().iter_mut().rev() {
|
for window in self.floating_windows_mut().iter_mut().rev() {
|
||||||
let mut should_hide = omit.is_none();
|
let mut should_hide = omit.is_none();
|
||||||
|
|
||||||
if !should_hide {
|
if !should_hide
|
||||||
if let Some(omit) = omit {
|
&& let Some(omit) = omit
|
||||||
if omit != window.hwnd {
|
&& omit != window.hwnd
|
||||||
should_hide = true
|
{
|
||||||
}
|
should_hide = true
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if should_hide {
|
if should_hide {
|
||||||
@@ -386,22 +385,22 @@ impl Workspace {
|
|||||||
hmonitor: isize,
|
hmonitor: isize,
|
||||||
monitor_wp: &Option<Wallpaper>,
|
monitor_wp: &Option<Wallpaper>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if let Some(container) = &self.monocle_container {
|
if let Some(container) = &self.monocle_container
|
||||||
if let Some(window) = container.focused_window() {
|
&& let Some(window) = container.focused_window()
|
||||||
container.restore();
|
{
|
||||||
window.focus(mouse_follows_focus)?;
|
container.restore();
|
||||||
return self.apply_wallpaper(hmonitor, monitor_wp);
|
window.focus(mouse_follows_focus)?;
|
||||||
}
|
return self.apply_wallpaper(hmonitor, monitor_wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
let idx = self.focused_container_idx();
|
let idx = self.focused_container_idx();
|
||||||
let mut to_focus = None;
|
let mut to_focus = None;
|
||||||
|
|
||||||
for (i, container) in self.containers_mut().iter_mut().enumerate() {
|
for (i, container) in self.containers_mut().iter_mut().enumerate() {
|
||||||
if let Some(window) = container.focused_window_mut() {
|
if let Some(window) = container.focused_window_mut()
|
||||||
if idx == i {
|
&& idx == i
|
||||||
to_focus = Option::from(*window);
|
{
|
||||||
}
|
to_focus = Option::from(*window);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.restore();
|
container.restore();
|
||||||
@@ -665,10 +664,10 @@ impl Workspace {
|
|||||||
let point = WindowsApi::cursor_pos().ok()?;
|
let point = WindowsApi::cursor_pos().ok()?;
|
||||||
|
|
||||||
for (i, _container) in self.containers().iter().enumerate() {
|
for (i, _container) in self.containers().iter().enumerate() {
|
||||||
if let Some(rect) = self.latest_layout.get(i) {
|
if let Some(rect) = self.latest_layout.get(i)
|
||||||
if rect.contains_point((point.x, point.y)) {
|
&& rect.contains_point((point.x, point.y))
|
||||||
idx = Option::from(i);
|
{
|
||||||
}
|
idx = Option::from(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -682,25 +681,24 @@ impl Workspace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(window) = self.maximized_window {
|
if let Some(window) = self.maximized_window
|
||||||
if let Ok(window_exe) = window.exe() {
|
&& let Ok(window_exe) = window.exe()
|
||||||
if exe == window_exe {
|
&& exe == window_exe
|
||||||
return Option::from(window.hwnd);
|
{
|
||||||
}
|
return Option::from(window.hwnd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(container) = &self.monocle_container {
|
if let Some(container) = &self.monocle_container
|
||||||
if let Some(hwnd) = container.hwnd_from_exe(exe) {
|
&& let Some(hwnd) = container.hwnd_from_exe(exe)
|
||||||
return Option::from(hwnd);
|
{
|
||||||
}
|
return Option::from(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
for window in self.floating_windows() {
|
for window in self.floating_windows() {
|
||||||
if let Ok(window_exe) = window.exe() {
|
if let Ok(window_exe) = window.exe()
|
||||||
if exe == window_exe {
|
&& exe == window_exe
|
||||||
return Option::from(window.hwnd);
|
{
|
||||||
}
|
return Option::from(window.hwnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,25 +715,24 @@ impl Workspace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(window) = self.maximized_window {
|
if let Some(window) = self.maximized_window
|
||||||
if let Ok(window_exe) = window.exe() {
|
&& let Ok(window_exe) = window.exe()
|
||||||
if exe == window_exe {
|
&& exe == window_exe
|
||||||
return Some(WorkspaceWindowLocation::Maximized);
|
{
|
||||||
}
|
return Some(WorkspaceWindowLocation::Maximized);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(container) = &self.monocle_container {
|
if let Some(container) = &self.monocle_container
|
||||||
if let Some(window_idx) = container.idx_from_exe(exe) {
|
&& let Some(window_idx) = container.idx_from_exe(exe)
|
||||||
return Some(WorkspaceWindowLocation::Monocle(window_idx));
|
{
|
||||||
}
|
return Some(WorkspaceWindowLocation::Monocle(window_idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (window_idx, window) in self.floating_windows().iter().enumerate() {
|
for (window_idx, window) in self.floating_windows().iter().enumerate() {
|
||||||
if let Ok(window_exe) = window.exe() {
|
if let Ok(window_exe) = window.exe()
|
||||||
if exe == window_exe {
|
&& exe == window_exe
|
||||||
return Some(WorkspaceWindowLocation::Floating(window_idx));
|
{
|
||||||
}
|
return Some(WorkspaceWindowLocation::Floating(window_idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -749,16 +746,16 @@ impl Workspace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(window) = self.maximized_window {
|
if let Some(window) = self.maximized_window
|
||||||
if hwnd == window.hwnd {
|
&& hwnd == window.hwnd
|
||||||
return true;
|
{
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(container) = &self.monocle_container {
|
if let Some(container) = &self.monocle_container
|
||||||
if container.contains_window(hwnd) {
|
&& container.contains_window(hwnd)
|
||||||
return true;
|
{
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
false
|
false
|
||||||
@@ -766,16 +763,16 @@ impl Workspace {
|
|||||||
|
|
||||||
pub fn is_focused_window_monocle_or_maximized(&self) -> Result<bool> {
|
pub fn is_focused_window_monocle_or_maximized(&self) -> Result<bool> {
|
||||||
let hwnd = WindowsApi::foreground_window()?;
|
let hwnd = WindowsApi::foreground_window()?;
|
||||||
if let Some(window) = self.maximized_window {
|
if let Some(window) = self.maximized_window
|
||||||
if hwnd == window.hwnd {
|
&& hwnd == window.hwnd
|
||||||
return Ok(true);
|
{
|
||||||
}
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(container) = &self.monocle_container {
|
if let Some(container) = &self.monocle_container
|
||||||
if container.contains_window(hwnd) {
|
&& container.contains_window(hwnd)
|
||||||
return Ok(true);
|
{
|
||||||
}
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(false)
|
Ok(false)
|
||||||
@@ -795,16 +792,16 @@ impl Workspace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(window) = self.maximized_window {
|
if let Some(window) = self.maximized_window
|
||||||
if hwnd == window.hwnd {
|
&& hwnd == window.hwnd
|
||||||
return true;
|
{
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(container) = &self.monocle_container {
|
if let Some(container) = &self.monocle_container
|
||||||
if container.contains_window(hwnd) {
|
&& container.contains_window(hwnd)
|
||||||
return true;
|
{
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for window in self.floating_windows() {
|
for window in self.floating_windows() {
|
||||||
@@ -897,36 +894,35 @@ impl Workspace {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(container) = &mut self.monocle_container {
|
if let Some(container) = &mut self.monocle_container
|
||||||
if let Some(window_idx) = container
|
&& let Some(window_idx) = container
|
||||||
.windows()
|
.windows()
|
||||||
.iter()
|
.iter()
|
||||||
.position(|window| window.hwnd == hwnd)
|
.position(|window| window.hwnd == hwnd)
|
||||||
{
|
{
|
||||||
container
|
container
|
||||||
.remove_window_by_idx(window_idx)
|
.remove_window_by_idx(window_idx)
|
||||||
.ok_or_eyre("there is no window")?;
|
.ok_or_eyre("there is no window")?;
|
||||||
|
|
||||||
if container.windows().is_empty() {
|
if container.windows().is_empty() {
|
||||||
self.monocle_container = None;
|
self.monocle_container = None;
|
||||||
self.monocle_container_restore_idx = None;
|
self.monocle_container_restore_idx = None;
|
||||||
}
|
|
||||||
|
|
||||||
for c in self.containers() {
|
|
||||||
c.restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for c in self.containers() {
|
||||||
|
c.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(window) = self.maximized_window {
|
if let Some(window) = self.maximized_window
|
||||||
if window.hwnd == hwnd {
|
&& window.hwnd == hwnd
|
||||||
window.unmaximize();
|
{
|
||||||
self.maximized_window = None;
|
window.unmaximize();
|
||||||
self.maximized_window_restore_idx = None;
|
self.maximized_window = None;
|
||||||
return Ok(());
|
self.maximized_window_restore_idx = None;
|
||||||
}
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let container_idx = self
|
let container_idx = self
|
||||||
@@ -1632,25 +1628,24 @@ impl Workspace {
|
|||||||
pub fn visible_window_details(&self) -> Vec<WindowDetails> {
|
pub fn visible_window_details(&self) -> Vec<WindowDetails> {
|
||||||
let mut vec: Vec<WindowDetails> = vec![];
|
let mut vec: Vec<WindowDetails> = vec![];
|
||||||
|
|
||||||
if let Some(maximized) = self.maximized_window {
|
if let Some(maximized) = self.maximized_window
|
||||||
if let Ok(details) = (maximized).try_into() {
|
&& let Ok(details) = (maximized).try_into()
|
||||||
vec.push(details);
|
{
|
||||||
}
|
vec.push(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(monocle) = &self.monocle_container {
|
if let Some(monocle) = &self.monocle_container
|
||||||
if let Some(focused) = monocle.focused_window() {
|
&& let Some(focused) = monocle.focused_window()
|
||||||
if let Ok(details) = (*focused).try_into() {
|
&& let Ok(details) = (*focused).try_into()
|
||||||
vec.push(details);
|
{
|
||||||
}
|
vec.push(details);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for container in self.containers() {
|
for container in self.containers() {
|
||||||
if let Some(focused) = container.focused_window() {
|
if let Some(focused) = container.focused_window()
|
||||||
if let Ok(details) = (*focused).try_into() {
|
&& let Ok(details) = (*focused).try_into()
|
||||||
vec.push(details);
|
{
|
||||||
}
|
vec.push(details);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2182,10 +2182,10 @@ fn main() -> Result<()> {
|
|||||||
SubCommand::Start(arg) => {
|
SubCommand::Start(arg) => {
|
||||||
let mut ahk: String = String::from("autohotkey.exe");
|
let mut ahk: String = String::from("autohotkey.exe");
|
||||||
|
|
||||||
if let Ok(komorebi_ahk_exe) = std::env::var("KOMOREBI_AHK_EXE") {
|
if let Ok(komorebi_ahk_exe) = std::env::var("KOMOREBI_AHK_EXE")
|
||||||
if which(&komorebi_ahk_exe).is_ok() {
|
&& which(&komorebi_ahk_exe).is_ok()
|
||||||
ahk = komorebi_ahk_exe;
|
{
|
||||||
}
|
ahk = komorebi_ahk_exe;
|
||||||
}
|
}
|
||||||
|
|
||||||
if arg.whkd && which("whkd").is_err() {
|
if arg.whkd && which("whkd").is_err() {
|
||||||
@@ -2360,33 +2360,18 @@ if (!(Get-Process whkd -ErrorAction SilentlyContinue))
|
|||||||
komorebi_json.is_file().then_some(komorebi_json)
|
komorebi_json.is_file().then_some(komorebi_json)
|
||||||
});
|
});
|
||||||
|
|
||||||
if arg.bar {
|
if arg.bar
|
||||||
if let Some(config) = &static_config {
|
&& let Some(config) = &static_config
|
||||||
let mut config = StaticConfig::read(config)?;
|
{
|
||||||
if let Some(display_bar_configurations) = &mut config.bar_configurations {
|
let mut config = StaticConfig::read(config)?;
|
||||||
for config_file_path in &mut *display_bar_configurations {
|
if let Some(display_bar_configurations) = &mut config.bar_configurations {
|
||||||
let script = format!(
|
for config_file_path in &mut *display_bar_configurations {
|
||||||
r#"Start-Process "komorebi-bar" '"--config" "{}"' -WindowStyle hidden"#,
|
let script = format!(
|
||||||
config_file_path.to_string_lossy()
|
r#"Start-Process "komorebi-bar" '"--config" "{}"' -WindowStyle hidden"#,
|
||||||
);
|
config_file_path.to_string_lossy()
|
||||||
|
);
|
||||||
|
|
||||||
match powershell_script::run(&script) {
|
match powershell_script::run(&script) {
|
||||||
Ok(_) => {
|
|
||||||
println!("{script}");
|
|
||||||
}
|
|
||||||
Err(error) => {
|
|
||||||
println!("Error: {error}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let script = r"
|
|
||||||
if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
|
||||||
{
|
|
||||||
Start-Process komorebi-bar -WindowStyle hidden
|
|
||||||
}
|
|
||||||
";
|
|
||||||
match powershell_script::run(script) {
|
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!("{script}");
|
println!("{script}");
|
||||||
}
|
}
|
||||||
@@ -2395,6 +2380,21 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
let script = r"
|
||||||
|
if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
||||||
|
{
|
||||||
|
Start-Process komorebi-bar -WindowStyle hidden
|
||||||
|
}
|
||||||
|
";
|
||||||
|
match powershell_script::run(script) {
|
||||||
|
Ok(_) => {
|
||||||
|
println!("{script}");
|
||||||
|
}
|
||||||
|
Err(error) => {
|
||||||
|
println!("Error: {error}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user