Skip to content

Commit

Permalink
chore: with upstream fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Aug 11, 2024
1 parent 4325c90 commit 05b1052
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lala_bar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ iced = { version = "0.12", features = [
] }
#iced_native = "0.12"
iced_runtime = "0.12"
iced_layershell = { git = "https://github.com/waycrate/exwlshelleventloop", package = "iced_layershell" }
iced_layershell = { git = "https://github.com/waycrate/exwlshelleventloop", package = "iced_layershell", branch = "mutiwindowcreate" }
tokio = { version = "1.39", features = ["full"] }
iced_futures = "0.12.0"
env_logger = "0.11.5"
Expand Down
83 changes: 72 additions & 11 deletions lala_bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ mod zbus_mpirs;
type LaLaShellIdAction = LayershellCustomActionsWithIdAndInfo<LaLaInfo>;
type LalaShellAction = LayershellCustomActionsWithInfo<LaLaInfo>;

const BEGINNING_UP_MARGIN: i32 = 10;

const UNIT_MARGIN: i32 = 135;

const EXTRAINF_MARGIN: i32 = BEGINNING_UP_MARGIN + 4 * UNIT_MARGIN;

const LAUNCHER_SVG: &[u8] = include_bytes!("../../misc/launcher.svg");

const RESET_SVG: &[u8] = include_bytes!("../../misc/reset.svg");
Expand All @@ -57,6 +63,7 @@ pub fn main() -> Result<(), iced_layershell::Error> {
enum LaLaInfo {
Launcher,
Notify(NotifyUnitWidgetInfo),
HidenInfo,

Check warning on line 66 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"Hiden" should be "Hidden".

Check warning on line 66 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"Hiden" should be "Hidden".
}

#[derive(Debug, Clone)]
Expand All @@ -82,8 +89,9 @@ struct LalaMusicBar {
bar_index: SliderIndex,
launcher: Option<launcher::Launcher>,
launcherid: Option<iced::window::Id>,
hidenid: Option<iced::window::Id>,
notifications: HashMap<iced::window::Id, NotifyUnitWidgetInfo>,
hided_notifications: Vec<NotifyUnitWidgetInfo>,
hidded_notifications: Vec<NotifyUnitWidgetInfo>,

Check warning on line 94 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".

Check warning on line 94 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".
sender: Sender<NotifyCommand>,
receiver: Arc<Mutex<Receiver<NotifyCommand>>>,
}
Expand Down Expand Up @@ -367,8 +375,9 @@ impl MultiApplication for LalaMusicBar {
bar_index: SliderIndex::Balance,
launcher: None,
launcherid: None,
hidenid: None,
notifications: HashMap::new(),
hided_notifications: Vec::new(),
hidded_notifications: Vec::new(),

Check warning on line 380 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".

Check warning on line 380 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".
sender,
receiver: Arc::new(Mutex::new(receiver)),
},
Expand All @@ -383,6 +392,8 @@ impl MultiApplication for LalaMusicBar {
fn id_info(&self, id: iced::window::Id) -> Option<Self::WindowInfo> {
if self.launcherid.is_some_and(|tid| tid == id) {
Some(LaLaInfo::Launcher)
} else if self.hidenid.is_some_and(|tid| tid == id) {
Some(LaLaInfo::HidenInfo)

Check warning on line 396 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"Hiden" should be "Hidden".

Check warning on line 396 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"Hiden" should be "Hidden".
} else {
self.notifications.get(&id).cloned().map(LaLaInfo::Notify)
}
Expand All @@ -396,13 +407,19 @@ impl MultiApplication for LalaMusicBar {
LaLaInfo::Notify(notify) => {
self.notifications.entry(id).or_insert(notify);
}
LaLaInfo::HidenInfo => {

Check warning on line 410 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"Hiden" should be "Hidden".

Check warning on line 410 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"Hiden" should be "Hidden".
self.hidenid = Some(id);
}
}
}

fn remove_id(&mut self, id: iced::window::Id) {
if self.launcherid.is_some_and(|lid| lid == id) {
self.launcherid.take();
}
if self.hidenid.is_some_and(|lid| lid == id) {
self.hidenid.take();
}
self.notifications.remove(&id);
}

Expand Down Expand Up @@ -525,7 +542,7 @@ impl MultiApplication for LalaMusicBar {
}
Message::Notify(NotifyMessage::UnitAdd(notify)) => {
let mut commands = vec![];
for unit in self.hided_notifications.iter_mut() {
for unit in self.hidded_notifications.iter_mut() {

Check warning on line 545 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".

Check warning on line 545 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".
unit.upper += 135;
unit.counter += 1;
}
Expand All @@ -534,7 +551,7 @@ impl MultiApplication for LalaMusicBar {
unit.upper += 135;
unit.counter += 1;
if unit.counter > 3 {
self.hided_notifications.push(unit.clone());
self.hidded_notifications.push(unit.clone());

Check warning on line 554 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".

Check warning on line 554 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".
commands.push(Command::single(Action::Window(WindowAction::Close(*id))));
} else {
commands.push(Command::single(
Expand Down Expand Up @@ -570,6 +587,27 @@ impl MultiApplication for LalaMusicBar {
)
.into(),
));

if !self.hidded_notifications.is_empty() && self.hidenid.is_none() {

Check warning on line 591 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".

Check warning on line 591 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".
commands.push(Command::single(
LaLaShellIdAction::new(
iced::window::Id::MAIN,
LalaShellAction::NewLayerShell((
NewLayerShellSettings {
size: Some((300, 25)),
exclusive_zone: None,
anchor: Anchor::Right | Anchor::Top,
layer: Layer::Top,
margin: Some((EXTRAINF_MARGIN, 10, 10, 10)),
keyboard_interactivity: KeyboardInteractivity::OnDemand,
use_last_output: true,
},
LaLaInfo::HidenInfo,

Check warning on line 605 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"Hiden" should be "Hidden".

Check warning on line 605 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"Hiden" should be "Hidden".
)),
)
.into(),
));
}
return Command::batch(commands);
}
Message::Notify(NotifyMessage::UnitRemove(removed_id)) => {
Expand Down Expand Up @@ -615,7 +653,7 @@ impl MultiApplication for LalaMusicBar {
}

let remove_hided_notifications_count: Vec<usize> = self
.hided_notifications
.hidded_notifications

Check warning on line 656 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".

Check warning on line 656 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"hidded" should be "hidden".
.iter()
.filter(
|NotifyUnitWidgetInfo {
Expand All @@ -626,22 +664,22 @@ impl MultiApplication for LalaMusicBar {
.map(|NotifyUnitWidgetInfo { counter, .. }| *counter)
.collect();

self.hided_notifications.retain(
self.hidded_notifications.retain(
|NotifyUnitWidgetInfo {
unit: NotifyUnit { id, .. },
..
}| *id == removed_id,
);

for count in remove_hided_notifications_count {
for unit in self.hided_notifications.iter_mut() {
for unit in self.hidded_notifications.iter_mut() {
if unit.counter > count {
unit.counter -= 1;
unit.upper -= 135;
}
}
}
for notify in self.hided_notifications.iter() {
for notify in self.hidded_notifications.iter() {
if notify.counter <= 4 {
commands.push(Command::single(
LaLaShellIdAction::new(
Expand All @@ -664,9 +702,17 @@ impl MultiApplication for LalaMusicBar {
}
}

self.hided_notifications
self.hidded_notifications
.retain(|NotifyUnitWidgetInfo { counter, .. }| *counter > 4);

if self.hidded_notifications.is_empty() && self.hidenid.is_some() {
let hidenid = self.hidenid.unwrap();

commands.push(Command::single(Action::Window(WindowAction::Close(
hidenid,
))));
}

commands.push(Command::perform(async {}, |_| Message::CheckOutput));

return Command::batch(commands);
Expand Down Expand Up @@ -708,7 +754,7 @@ impl MultiApplication for LalaMusicBar {
}

let mut to_show_id = None;
for (index, notify) in self.hided_notifications.iter_mut().enumerate() {
for (index, notify) in self.hidded_notifications.iter_mut().enumerate() {
notify.counter -= 1;
notify.upper -= 135;
if notify.counter == 3 {
Expand All @@ -735,7 +781,15 @@ impl MultiApplication for LalaMusicBar {
}

if let Some(index) = to_show_id {
self.hided_notifications.remove(index);
self.hidded_notifications.remove(index);
}

if self.hidded_notifications.is_empty() && self.hidenid.is_some() {
let hidenid = self.hidenid.unwrap();

commands.push(Command::single(Action::Window(WindowAction::Close(
hidenid,
))));
}

commands.append(&mut vec![
Expand Down Expand Up @@ -875,6 +929,13 @@ impl MultiApplication for LalaMusicBar {
}
return btnwidgets;
}
LaLaInfo::HidenInfo => {
return text(format!(
"hidden notifications {}",
self.hidded_notifications.len()
))
.into();
}
}
}
self.main_view()
Expand Down

0 comments on commit 05b1052

Please sign in to comment.