fix(ags overview): properly get rid of timeouts
This commit is contained in:
parent
c4fee015d6
commit
dc73f5f384
3 changed files with 26 additions and 12 deletions
|
@ -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 { App, Utils } from './imports.js';
|
||||||
|
|
||||||
import closeAll from './js/misc/closer.js';
|
import closeAll from './js/misc/closer.js';
|
||||||
|
|
|
@ -5,9 +5,6 @@ const { execAsync } = Utils;
|
||||||
import { WindowButton } from './dragndrop.js';
|
import { WindowButton } from './dragndrop.js';
|
||||||
import * as VARS from './variables.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 scale = size => size * VARS.SCALE - VARS.MARGIN;
|
||||||
const getFontSize = client => Math.min(scale(client.size[0]),
|
const getFontSize = client => Math.min(scale(client.size[0]),
|
||||||
scale(client.size[1])) * VARS.ICON_SCALE;
|
scale(client.size[1])) * VARS.ICON_SCALE;
|
||||||
|
|
|
@ -74,7 +74,10 @@ const Workspace = (id, name, extra = false) => {
|
||||||
['wasActive', false],
|
['wasActive', false],
|
||||||
],
|
],
|
||||||
connections: [[Hyprland, box => {
|
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 activeId = Hyprland.active.workspace.id;
|
||||||
const active = activeId === box._id;
|
const active = activeId === box._id;
|
||||||
|
@ -84,15 +87,21 @@ const Workspace = (id, name, extra = false) => {
|
||||||
|
|
||||||
if (Hyprland.getWorkspace(box._id)?.windows > 0 || active) {
|
if (Hyprland.getWorkspace(box._id)?.windows > 0 || active) {
|
||||||
rev.setStyle(DEFAULT_STYLE);
|
rev.setStyle(DEFAULT_STYLE);
|
||||||
box._timeouts.push(Utils.timeout(100, () => {
|
|
||||||
|
const timer = Utils.timeout(100, () => {
|
||||||
box.revealChild = true;
|
box.revealChild = true;
|
||||||
}));
|
box._timeouts.remove(timer);
|
||||||
|
});
|
||||||
|
box._timeouts.push(timer);
|
||||||
}
|
}
|
||||||
else if (!Hyprland.getWorkspace(box._id)?.windows > 0) {
|
else if (!Hyprland.getWorkspace(box._id)?.windows > 0) {
|
||||||
rev.setStyle(DEFAULT_STYLE);
|
rev.setStyle(DEFAULT_STYLE);
|
||||||
box._timeouts.push(Utils.timeout(100, () => {
|
|
||||||
|
const timer = Utils.timeout(100, () => {
|
||||||
box.revealChild = false;
|
box.revealChild = false;
|
||||||
}));
|
box._timeouts.remove(timer);
|
||||||
|
});
|
||||||
|
box._timeouts.push(timer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,18 +112,23 @@ const Workspace = (id, name, extra = false) => {
|
||||||
box._wasActive = true;
|
box._wasActive = true;
|
||||||
}
|
}
|
||||||
else if (box._wasActive) {
|
else if (box._wasActive) {
|
||||||
box._timeouts.push(Utils.timeout(120, () => {
|
const timer1 = Utils.timeout(120, () => {
|
||||||
rev.setStyle(`${DEFAULT_STYLE}
|
rev.setStyle(`${DEFAULT_STYLE}
|
||||||
transition: margin 0.5s ease-in-out;
|
transition: margin 0.5s ease-in-out;
|
||||||
opacity: 1; margin-left: ${n ? '' : '-'}300px;
|
opacity: 1; margin-left: ${n ? '' : '-'}300px;
|
||||||
margin-right: ${n ? '-' : ''}300px;`);
|
margin-right: ${n ? '-' : ''}300px;`);
|
||||||
box._wasActive = false;
|
box._wasActive = false;
|
||||||
}));
|
box._timeouts.remove(timer1);
|
||||||
box._timeouts.push(Utils.timeout(500, () => {
|
});
|
||||||
|
box._timeouts.push(timer1);
|
||||||
|
|
||||||
|
const timer2 = Utils.timeout(500, () => {
|
||||||
rev.setStyle(`${DEFAULT_STYLE} opacity: 0;
|
rev.setStyle(`${DEFAULT_STYLE} opacity: 0;
|
||||||
margin-left: ${n ? '' : '-'}300px;
|
margin-left: ${n ? '' : '-'}300px;
|
||||||
margin-right: ${n ? '-' : ''}300px;`);
|
margin-right: ${n ? '-' : ''}300px;`);
|
||||||
}));
|
box._timeouts.remove(timer2);
|
||||||
|
});
|
||||||
|
box._timeouts.push(timer2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rev.setStyle(`${DEFAULT_STYLE} opacity: 0;
|
rev.setStyle(`${DEFAULT_STYLE} opacity: 0;
|
||||||
|
|
Loading…
Reference in a new issue