mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-24 17:48:34 +02:00
handling grouping edge case for komorebi focus window
This commit is contained in:
@@ -129,6 +129,7 @@ impl BarWidget for Komorebi {
|
|||||||
if self.workspaces.enable {
|
if self.workspaces.enable {
|
||||||
let mut update = None;
|
let mut update = None;
|
||||||
|
|
||||||
|
// NOTE: There should always be at least one workspace.
|
||||||
config.grouping.apply_on_widget(ui, |ui| {
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
for (i, (ws, should_show)) in
|
for (i, (ws, should_show)) in
|
||||||
komorebi_notification_state.workspaces.iter().enumerate()
|
komorebi_notification_state.workspaces.iter().enumerate()
|
||||||
@@ -308,115 +309,120 @@ impl BarWidget for Komorebi {
|
|||||||
|
|
||||||
if let Some(focused_window) = self.focused_window {
|
if let Some(focused_window) = self.focused_window {
|
||||||
if focused_window.enable {
|
if focused_window.enable {
|
||||||
config.grouping.apply_on_widget(ui, |ui| {
|
let titles = &komorebi_notification_state.focused_container_information.0;
|
||||||
let titles = &komorebi_notification_state.focused_container_information.0;
|
|
||||||
let icons = &komorebi_notification_state.focused_container_information.1;
|
|
||||||
let focused_window_idx =
|
|
||||||
komorebi_notification_state.focused_container_information.2;
|
|
||||||
|
|
||||||
let iter = titles.iter().zip(icons.iter());
|
if !titles.is_empty() {
|
||||||
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
|
let icons = &komorebi_notification_state.focused_container_information.1;
|
||||||
|
let focused_window_idx =
|
||||||
|
komorebi_notification_state.focused_container_information.2;
|
||||||
|
|
||||||
for (i, (title, icon)) in iter.enumerate() {
|
let iter = titles.iter().zip(icons.iter());
|
||||||
if focused_window.show_icon {
|
|
||||||
if let Some(img) = icon {
|
for (i, (title, icon)) in iter.enumerate() {
|
||||||
ui.add(
|
if focused_window.show_icon {
|
||||||
Image::from(&img_to_texture(ctx, img))
|
if let Some(img) = icon {
|
||||||
.maintain_aspect_ratio(true)
|
ui.add(
|
||||||
.max_height(15.0),
|
Image::from(&img_to_texture(ctx, img))
|
||||||
);
|
.maintain_aspect_ratio(true)
|
||||||
|
.max_height(15.0),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if i == focused_window_idx {
|
if i == focused_window_idx {
|
||||||
let font_id = ctx
|
let font_id = ctx
|
||||||
.style()
|
.style()
|
||||||
.text_styles
|
.text_styles
|
||||||
.get(&TextStyle::Body)
|
.get(&TextStyle::Body)
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_else(FontId::default);
|
.unwrap_or_else(FontId::default);
|
||||||
|
|
||||||
let layout_job = LayoutJob::simple(
|
let layout_job = LayoutJob::simple(
|
||||||
title.to_string(),
|
title.to_string(),
|
||||||
font_id.clone(),
|
font_id.clone(),
|
||||||
komorebi_notification_state
|
komorebi_notification_state
|
||||||
.stack_accent
|
.stack_accent
|
||||||
.unwrap_or(ctx.style().visuals.selection.stroke.color),
|
.unwrap_or(ctx.style().visuals.selection.stroke.color),
|
||||||
100.0,
|
100.0,
|
||||||
);
|
|
||||||
|
|
||||||
if titles.len() > 1 {
|
|
||||||
let available_height = ui.available_height();
|
|
||||||
let mut custom_ui = CustomUi(ui);
|
|
||||||
custom_ui.add_sized_left_to_right(
|
|
||||||
Vec2::new(
|
|
||||||
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
|
||||||
available_height,
|
|
||||||
),
|
|
||||||
Label::new(layout_job).selectable(false).truncate(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if titles.len() > 1 {
|
||||||
|
let available_height = ui.available_height();
|
||||||
|
let mut custom_ui = CustomUi(ui);
|
||||||
|
custom_ui.add_sized_left_to_right(
|
||||||
|
Vec2::new(
|
||||||
|
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
||||||
|
available_height,
|
||||||
|
),
|
||||||
|
Label::new(layout_job).selectable(false).truncate(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
let available_height = ui.available_height();
|
||||||
|
let mut custom_ui = CustomUi(ui);
|
||||||
|
custom_ui.add_sized_left_to_right(
|
||||||
|
Vec2::new(
|
||||||
|
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
||||||
|
available_height,
|
||||||
|
),
|
||||||
|
Label::new(title).selectable(false).truncate(),
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let available_height = ui.available_height();
|
let available_height = ui.available_height();
|
||||||
let mut custom_ui = CustomUi(ui);
|
let mut custom_ui = CustomUi(ui);
|
||||||
custom_ui.add_sized_left_to_right(
|
|
||||||
Vec2::new(
|
|
||||||
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
|
||||||
available_height,
|
|
||||||
),
|
|
||||||
Label::new(title).selectable(false).truncate(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let available_height = ui.available_height();
|
|
||||||
let mut custom_ui = CustomUi(ui);
|
|
||||||
|
|
||||||
if custom_ui
|
if custom_ui
|
||||||
.add_sized_left_to_right(
|
.add_sized_left_to_right(
|
||||||
Vec2::new(
|
Vec2::new(
|
||||||
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
||||||
available_height,
|
available_height,
|
||||||
),
|
),
|
||||||
Label::new(title)
|
Label::new(title)
|
||||||
.selectable(false)
|
.selectable(false)
|
||||||
.sense(Sense::click())
|
.sense(Sense::click())
|
||||||
.truncate(),
|
.truncate(),
|
||||||
)
|
)
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
|
||||||
if komorebi_client::send_message(&SocketMessage::MouseFollowsFocus(
|
|
||||||
false,
|
|
||||||
))
|
|
||||||
.is_err()
|
|
||||||
{
|
{
|
||||||
tracing::error!(
|
if komorebi_client::send_message(
|
||||||
"could not send message to komorebi: MouseFollowsFocus"
|
&SocketMessage::MouseFollowsFocus(false),
|
||||||
);
|
)
|
||||||
}
|
.is_err()
|
||||||
|
{
|
||||||
|
tracing::error!(
|
||||||
|
"could not send message to komorebi: MouseFollowsFocus"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if komorebi_client::send_message(&SocketMessage::FocusStackWindow(
|
if komorebi_client::send_message(
|
||||||
i,
|
&SocketMessage::FocusStackWindow(i),
|
||||||
))
|
)
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
"could not send message to komorebi: FocusStackWindow"
|
"could not send message to komorebi: FocusStackWindow"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if komorebi_client::send_message(&SocketMessage::MouseFollowsFocus(
|
if komorebi_client::send_message(
|
||||||
komorebi_notification_state.mouse_follows_focus,
|
&SocketMessage::MouseFollowsFocus(
|
||||||
))
|
komorebi_notification_state.mouse_follows_focus,
|
||||||
.is_err()
|
),
|
||||||
{
|
)
|
||||||
tracing::error!(
|
.is_err()
|
||||||
"could not send message to komorebi: MouseFollowsFocus"
|
{
|
||||||
);
|
tracing::error!(
|
||||||
|
"could not send message to komorebi: MouseFollowsFocus"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.add_space(WIDGET_SPACING);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
ui.add_space(WIDGET_SPACING);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.add_space(WIDGET_SPACING);
|
ui.add_space(WIDGET_SPACING);
|
||||||
|
|||||||
Reference in New Issue
Block a user