fix(ags overview): put highlight behind for dragndrop

This commit is contained in:
matt1432 2023-11-07 13:00:29 -05:00
parent 8307198659
commit e6fdb163eb
3 changed files with 28 additions and 12 deletions

View file

@ -22,7 +22,7 @@ const IconStyle = client => `
`; `;
const Client = (client, active, clients) => { const Client = (client, active, clients, box) => {
const wsName = String(client.workspace.name).replace('special:', ''); const wsName = String(client.workspace.name).replace('special:', '');
const wsId = client.workspace.id; const wsId = client.workspace.id;
const addr = `address:${client.address}`; const addr = `address:${client.address}`;
@ -35,6 +35,7 @@ const Client = (client, active, clients) => {
['toDestroy', false], ['toDestroy', false],
], ],
child: WindowButton({ child: WindowButton({
mainBox: box,
address: client.address, address: client.address,
onSecondaryClickRelease: () => { onSecondaryClickRelease: () => {
execAsync(`hyprctl dispatch closewindow ${addr}`) execAsync(`hyprctl dispatch closewindow ${addr}`)
@ -120,7 +121,7 @@ export function updateClients(box) {
]; ];
if (!newClient[0]) { if (!newClient[0]) {
newClient[0] = Client(client, active, clients); newClient[0] = Client(client, active, clients, box);
fixed.put(...newClient); fixed.put(...newClient);
} }
else { else {

View file

@ -1,4 +1,3 @@
import App from 'resource:///com/github/Aylur/ags/app.js';
import { EventBox } from 'resource:///com/github/Aylur/ags/widget.js'; import { EventBox } from 'resource:///com/github/Aylur/ags/widget.js';
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
@ -51,7 +50,7 @@ export const WorkspaceDrop = props => EventBox({
}, },
}); });
export const WindowButton = ({ address, ...props } = {}) => Button({ export const WindowButton = ({ address, mainBox, ...props } = {}) => Button({
isButton: true, isButton: true,
...props, ...props,
setup: self => { setup: self => {
@ -66,8 +65,7 @@ export const WindowButton = ({ address, ...props } = {}) => Button({
self.connect('drag-end', () => { self.connect('drag-end', () => {
self.get_parent().destroy(); self.get_parent().destroy();
const mainBox = App.getWindow('overview').getChild(); updateClients(mainBox);
updateClients(mainBox.child);
}); });
}, },
}); });

View file

@ -1,7 +1,6 @@
import App from 'resource:///com/github/Aylur/ags/app.js'; import App from 'resource:///com/github/Aylur/ags/app.js';
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js'; import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
import { Box, Overlay } from 'resource:///com/github/Aylur/ags/widget.js'; import { Box, Overlay } from 'resource:///com/github/Aylur/ags/widget.js';
import { timeout } from 'resource:///com/github/Aylur/ags/utils.js';
import PopupWindow from '../misc/popup.js'; import PopupWindow from '../misc/popup.js';
import { WorkspaceRow, getWorkspaces, updateWorkspaces } from './workspaces.js'; import { WorkspaceRow, getWorkspaces, updateWorkspaces } from './workspaces.js';
@ -16,14 +15,18 @@ function update(box, highlight) {
updateCurrentWorkspace(box, highlight); updateCurrentWorkspace(box, highlight);
} }
// FIXME: can't drag in workspaces that are before the highlight
// TODO: have a 'page' for each monitor, arrows on both sides to loop through // TODO: have a 'page' for each monitor, arrows on both sides to loop through
export default () => { export default () => {
const highlighter = Highlighter(); const highlighter = Highlighter();
const mainBox = Box({ const mainBox = Box({
// do this for scss hierarchy
className: 'overview', className: 'overview',
css: 'all: unset',
vertical: true, vertical: true,
vpack: 'center',
hpack: 'center',
children: [ children: [
Box({ Box({
vertical: true, vertical: true,
@ -55,11 +58,25 @@ export default () => {
onOpen: () => update(mainBox, highlighter), onOpen: () => update(mainBox, highlighter),
child: Overlay({ child: Overlay({
// FIXME: see if we can get rid of this timeout overlays: [highlighter, mainBox],
setup: self => timeout(1, () => self.pass_through = true),
overlays: [highlighter], child: Box({
child: mainBox, className: 'overview',
css: `
min-height: ${mainBox.get_allocated_height()}px;
min-width: ${mainBox.get_allocated_width()}px;
`,
}),
// TODO: throttle his?
connections: [['get-child-position', (self, ch) => {
if (ch === mainBox) {
self.child.setCss(`
transition: min-height 0.2s ease, min-width 0.2s ease;
min-height: ${mainBox.get_allocated_height()}px;
min-width: ${mainBox.get_allocated_width()}px;
`);
}
}]],
}), }),
}); });