feat(ags pointers): make list of widgets that don't close others when clicked on
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
0b3861a867
commit
2f4781e60e
2 changed files with 55 additions and 31 deletions
|
@ -117,8 +117,8 @@ class Pointers extends Service {
|
||||||
(Array.from(App.windows) as Array<[string, AgsWindow]>)
|
(Array.from(App.windows) as Array<[string, AgsWindow]>)
|
||||||
.some((w) => {
|
.some((w) => {
|
||||||
const closable = w[1].attribute?.close_on_unfocus &&
|
const closable = w[1].attribute?.close_on_unfocus &&
|
||||||
!(w[1].attribute?.close_on_unfocus === 'none' ||
|
!(w[1].attribute.close_on_unfocus === 'none' ||
|
||||||
w[1].attribute?.close_on_unfocus === 'stay');
|
w[1].attribute.close_on_unfocus === 'stay');
|
||||||
|
|
||||||
return w[1].visible && closable;
|
return w[1].visible && closable;
|
||||||
});
|
});
|
||||||
|
@ -137,7 +137,7 @@ class Pointers extends Service {
|
||||||
const toClose = (Array.from(App.windows) as Array<[string, AgsWindow]>)
|
const toClose = (Array.from(App.windows) as Array<[string, AgsWindow]>)
|
||||||
.some((w) => {
|
.some((w) => {
|
||||||
const closable = (w[1].attribute?.close_on_unfocus &&
|
const closable = (w[1].attribute?.close_on_unfocus &&
|
||||||
w[1].attribute?.close_on_unfocus === clickStage);
|
w[1].attribute.close_on_unfocus === clickStage);
|
||||||
|
|
||||||
return w[1].visible && closable;
|
return w[1].visible && closable;
|
||||||
});
|
});
|
||||||
|
@ -153,28 +153,50 @@ class Pointers extends Service {
|
||||||
const pos = JSON.parse(res) as CursorPos;
|
const pos = JSON.parse(res) as CursorPos;
|
||||||
|
|
||||||
Object.values(layers).forEach((key) => {
|
Object.values(layers).forEach((key) => {
|
||||||
const bar = key.levels['3']?.find(
|
const overlayLayer = key.levels['3'];
|
||||||
(n) => n.namespace === 'bar',
|
|
||||||
) ||
|
|
||||||
// Return an empty Layer if bar doesn't exist
|
|
||||||
{ address: '', x: 0, y: 0, w: 0, h: 0, namespace: '' };
|
|
||||||
|
|
||||||
const widgets = key.levels['3']?.filter(
|
if (overlayLayer) {
|
||||||
(n) => {
|
const noCloseWidgetsNames = ['bar', 'osk'];
|
||||||
|
|
||||||
|
const getNoCloseWidgets = (names: Array<string>) => {
|
||||||
|
const arr = [] as Array<Layer>;
|
||||||
|
|
||||||
|
names.forEach((name) => {
|
||||||
|
arr.push(
|
||||||
|
overlayLayer.find(
|
||||||
|
(n) => n.namespace === name,
|
||||||
|
) ||
|
||||||
|
// Return an empty Layer if widget doesn't exist
|
||||||
|
{
|
||||||
|
address: '',
|
||||||
|
x: 0, y: 0, w: 0, h: 0,
|
||||||
|
namespace: '',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return arr;
|
||||||
|
};
|
||||||
|
const clickIsOnWidget = (w: Layer) => {
|
||||||
|
return pos.x > w.x && pos.x < w.x + w.w &&
|
||||||
|
pos.y > w.y && pos.y < w.y + w.h;
|
||||||
|
};
|
||||||
|
|
||||||
|
const noCloseWidgets =
|
||||||
|
getNoCloseWidgets(noCloseWidgetsNames);
|
||||||
|
|
||||||
|
const widgets = overlayLayer.filter((n) => {
|
||||||
const window =
|
const window =
|
||||||
(App.getWindow(n.namespace) as AgsWindow);
|
(App.getWindow(n.namespace) as AgsWindow);
|
||||||
|
|
||||||
return window?.attribute?.close_on_unfocus &&
|
return window &&
|
||||||
window?.attribute
|
window.attribute?.close_on_unfocus &&
|
||||||
?.close_on_unfocus === clickStage;
|
window.attribute?.close_on_unfocus ===
|
||||||
},
|
clickStage;
|
||||||
);
|
});
|
||||||
|
|
||||||
if (pos.x > bar?.x && pos.x < bar?.x + bar?.w &&
|
if (noCloseWidgets.some(clickIsOnWidget)) {
|
||||||
pos.y > bar?.y && pos.y < bar?.y + bar?.h) {
|
// Don't handle clicks when on certain widgets
|
||||||
|
|
||||||
// Don't handle clicks when on bar
|
|
||||||
// TODO: make this configurable
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
widgets?.forEach(
|
widgets?.forEach(
|
||||||
|
@ -186,6 +208,7 @@ class Pointers extends Service {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}).catch(print);
|
}).catch(print);
|
||||||
}).catch(print);
|
}).catch(print);
|
||||||
|
|
|
@ -14,6 +14,7 @@ export default () => {
|
||||||
const window = Window({
|
const window = Window({
|
||||||
name: 'osk',
|
name: 'osk',
|
||||||
visible: false,
|
visible: false,
|
||||||
|
layer: 'overlay',
|
||||||
anchor: ['left', 'bottom', 'right'],
|
anchor: ['left', 'bottom', 'right'],
|
||||||
|
|
||||||
setup: (self) => {
|
setup: (self) => {
|
||||||
|
|
Loading…
Reference in a new issue