fix(ags overview): properly get rid of timeouts

This commit is contained in:
matt1432 2023-10-28 21:41:20 -04:00
parent c4fee015d6
commit dc73f5f384
3 changed files with 26 additions and 12 deletions

View file

@ -1,3 +1,6 @@
// Has to be a traditional function for 'this' scope
Array.prototype.remove = function (el) { this.splice(this.indexOf(el), 1); };
import { App, Utils } from './imports.js';
import closeAll from './js/misc/closer.js';

View file

@ -5,9 +5,6 @@ const { execAsync } = Utils;
import { WindowButton } from './dragndrop.js';
import * as VARS from './variables.js';
// Has to be a traditional function for 'this' scope
Array.prototype.remove = function (el) { this.splice(this.indexOf(el), 1); };
const scale = size => size * VARS.SCALE - VARS.MARGIN;
const getFontSize = client => Math.min(scale(client.size[0]),
scale(client.size[1])) * VARS.ICON_SCALE;

View file

@ -74,7 +74,10 @@ const Workspace = (id, name, extra = false) => {
['wasActive', false],
],
connections: [[Hyprland, box => {
box._timeouts.forEach(timer => GLib.source_remove(timer));
box._timeouts.forEach(timer => {
GLib.source_remove(timer);
box._timeouts.remove(timer);
});
const activeId = Hyprland.active.workspace.id;
const active = activeId === box._id;
@ -84,15 +87,21 @@ const Workspace = (id, name, extra = false) => {
if (Hyprland.getWorkspace(box._id)?.windows > 0 || active) {
rev.setStyle(DEFAULT_STYLE);
box._timeouts.push(Utils.timeout(100, () => {
const timer = Utils.timeout(100, () => {
box.revealChild = true;
}));
box._timeouts.remove(timer);
});
box._timeouts.push(timer);
}
else if (!Hyprland.getWorkspace(box._id)?.windows > 0) {
rev.setStyle(DEFAULT_STYLE);
box._timeouts.push(Utils.timeout(100, () => {
const timer = Utils.timeout(100, () => {
box.revealChild = false;
}));
box._timeouts.remove(timer);
});
box._timeouts.push(timer);
return;
}
@ -103,18 +112,23 @@ const Workspace = (id, name, extra = false) => {
box._wasActive = true;
}
else if (box._wasActive) {
box._timeouts.push(Utils.timeout(120, () => {
const timer1 = Utils.timeout(120, () => {
rev.setStyle(`${DEFAULT_STYLE}
transition: margin 0.5s ease-in-out;
opacity: 1; margin-left: ${n ? '' : '-'}300px;
margin-right: ${n ? '-' : ''}300px;`);
box._wasActive = false;
}));
box._timeouts.push(Utils.timeout(500, () => {
box._timeouts.remove(timer1);
});
box._timeouts.push(timer1);
const timer2 = Utils.timeout(500, () => {
rev.setStyle(`${DEFAULT_STYLE} opacity: 0;
margin-left: ${n ? '' : '-'}300px;
margin-right: ${n ? '-' : ''}300px;`);
}));
box._timeouts.remove(timer2);
});
box._timeouts.push(timer2);
}
else {
rev.setStyle(`${DEFAULT_STYLE} opacity: 0;