feat(agsV2): only let one notif popup at a time
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
4c7fd11ee3
commit
bb17277123
6 changed files with 96 additions and 60 deletions
|
@ -59,6 +59,9 @@ const NotificationList = () => (
|
||||||
);
|
);
|
||||||
|
|
||||||
const ClearButton = () => (
|
const ClearButton = () => (
|
||||||
|
<eventbox
|
||||||
|
cursor={bind(HasNotifs).as((hasNotifs) => hasNotifs ? 'pointer' : 'not-allowed')}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
className="clear"
|
className="clear"
|
||||||
sensitive={bind(HasNotifs)}
|
sensitive={bind(HasNotifs)}
|
||||||
|
@ -82,6 +85,7 @@ const ClearButton = () => (
|
||||||
/>
|
/>
|
||||||
</box>
|
</box>
|
||||||
</button>
|
</button>
|
||||||
|
</eventbox>
|
||||||
);
|
);
|
||||||
|
|
||||||
const Header = () => (
|
const Header = () => (
|
||||||
|
|
|
@ -62,6 +62,9 @@ export class NotifGestureWrapper extends Widget.EventBox {
|
||||||
@signal(Number)
|
@signal(Number)
|
||||||
declare timer_update: (popup_timer: number) => void;
|
declare timer_update: (popup_timer: number) => void;
|
||||||
|
|
||||||
|
public static sliding_in = 0;
|
||||||
|
public static on_sliding_in: (amount: number) => void;
|
||||||
|
|
||||||
public dragging: boolean;
|
public dragging: boolean;
|
||||||
|
|
||||||
private async get_hovered(): Promise<boolean> {
|
private async get_hovered(): Promise<boolean> {
|
||||||
|
@ -69,17 +72,16 @@ export class NotifGestureWrapper extends Widget.EventBox {
|
||||||
const layers = JSON.parse(await hyprMessage('j/layers')) as LayerResult;
|
const layers = JSON.parse(await hyprMessage('j/layers')) as LayerResult;
|
||||||
const cursorPos = JSON.parse(await hyprMessage('j/cursorpos')) as CursorPos;
|
const cursorPos = JSON.parse(await hyprMessage('j/cursorpos')) as CursorPos;
|
||||||
|
|
||||||
const window = this.get_window();
|
const monitor = display?.get_monitor_at_window(this.get_window()!);
|
||||||
|
const plugName = get_hyprland_monitor(monitor!)?.name;
|
||||||
|
|
||||||
if (window) {
|
|
||||||
const monitor = display?.get_monitor_at_window(window);
|
|
||||||
|
|
||||||
if (monitor) {
|
|
||||||
const plugName = get_hyprland_monitor(monitor)?.name;
|
|
||||||
const notifLayer = layers[plugName ?? '']?.levels['3']
|
const notifLayer = layers[plugName ?? '']?.levels['3']
|
||||||
?.find((n) => n.namespace === 'notifications');
|
?.find((n) => n.namespace === 'notifications');
|
||||||
|
|
||||||
if (notifLayer) {
|
if (!notifLayer) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const index = [...NotifGestureWrapper.popups.keys()]
|
const index = [...NotifGestureWrapper.popups.keys()]
|
||||||
.sort((a, b) => b - a)
|
.sort((a, b) => b - a)
|
||||||
.indexOf(this.id);
|
.indexOf(this.id);
|
||||||
|
@ -100,9 +102,6 @@ export class NotifGestureWrapper extends Widget.EventBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
@ -301,6 +300,10 @@ export class NotifGestureWrapper extends Widget.EventBox {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.is_popup) {
|
||||||
|
NotifGestureWrapper.on_sliding_in(++NotifGestureWrapper.sliding_in);
|
||||||
|
}
|
||||||
|
|
||||||
// Reverse of slideAway, so it started at squeeze, then we go to slide
|
// Reverse of slideAway, so it started at squeeze, then we go to slide
|
||||||
self.css = this.slide_in_from === 'Left' ?
|
self.css = this.slide_in_from === 'Left' ?
|
||||||
slideLeft :
|
slideLeft :
|
||||||
|
@ -312,6 +315,14 @@ export class NotifGestureWrapper extends Widget.EventBox {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// Then we go to center
|
// Then we go to center
|
||||||
self.css = defaultStyle;
|
self.css = defaultStyle;
|
||||||
|
|
||||||
|
if (this.is_popup) {
|
||||||
|
setTimeout(() => {
|
||||||
|
NotifGestureWrapper.on_sliding_in(
|
||||||
|
--NotifGestureWrapper.sliding_in,
|
||||||
|
);
|
||||||
|
}, ANIM_DURATION);
|
||||||
|
}
|
||||||
}, ANIM_DURATION);
|
}, ANIM_DURATION);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { App, Gtk, Gdk } from 'astal/gtk3';
|
import { App, Gtk, Gdk, Widget } from 'astal/gtk3';
|
||||||
import { Variable } from 'astal';
|
import { Variable } from 'astal';
|
||||||
|
|
||||||
import GLib from 'gi://GLib?version=2.0';
|
import GLib from 'gi://GLib?version=2.0';
|
||||||
|
@ -26,11 +26,11 @@ const NotifIcon = ({ notifObj }: {
|
||||||
}) => {
|
}) => {
|
||||||
let icon: string;
|
let icon: string;
|
||||||
|
|
||||||
if (notifObj.get_image() !== '') {
|
if (notifObj.get_image() && notifObj.get_image() !== '') {
|
||||||
icon = notifObj.get_image();
|
icon = notifObj.get_image();
|
||||||
App.add_icons(icon);
|
App.add_icons(icon);
|
||||||
}
|
}
|
||||||
else if (notifObj.get_app_icon() !== '') {
|
else if (notifObj.get_app_icon() !== '' && Widget.Icon.lookup_icon(notifObj.get_app_icon())) {
|
||||||
icon = notifObj.get_app_icon();
|
icon = notifObj.get_app_icon();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -13,11 +13,14 @@ export default () => (
|
||||||
vertical
|
vertical
|
||||||
|
|
||||||
setup={(self) => {
|
setup={(self) => {
|
||||||
|
const notifQueue: number[] = [];
|
||||||
|
|
||||||
const addPopup = (id: number) => {
|
const addPopup = (id: number) => {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NotifGestureWrapper.sliding_in === 0) {
|
||||||
const NewNotif = Notification({ id, popup_timer: 5 });
|
const NewNotif = Notification({ id, popup_timer: 5 });
|
||||||
|
|
||||||
if (NewNotif) {
|
if (NewNotif) {
|
||||||
|
@ -27,6 +30,20 @@ export default () => (
|
||||||
|
|
||||||
NotifGestureWrapper.popups.set(id, NewNotif);
|
NotifGestureWrapper.popups.set(id, NewNotif);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
notifQueue.push(id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NotifGestureWrapper.on_sliding_in = (n) => {
|
||||||
|
if (n === 0) {
|
||||||
|
const id = notifQueue.shift();
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
addPopup(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleResolved = (id: number) => {
|
const handleResolved = (id: number) => {
|
||||||
|
|
|
@ -70,6 +70,10 @@
|
||||||
border-radius: 30px;
|
border-radius: 30px;
|
||||||
border-top: 2px solid $accent-color;
|
border-top: 2px solid $accent-color;
|
||||||
|
|
||||||
|
.notification {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
viewport {
|
viewport {
|
||||||
all: unset;
|
all: unset;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue