feat(ags overview): add buttons on windows to focus

This commit is contained in:
matt1432 2023-09-22 22:39:43 -04:00
parent b81bb90dcd
commit 461a77d9f0
2 changed files with 23 additions and 9 deletions

View file

@ -1,6 +1,6 @@
const { GLib } = imports.gi; const { GLib } = imports.gi;
const { Notifications, Applications } = ags.Service; const { Notifications, Applications } = ags.Service;
const { lookUpIcon, timeout, exec } = ags.Utils; const { lookUpIcon, exec } = ags.Utils;
const { Box, Icon, Label, Button } = ags.Widget; const { Box, Icon, Label, Button } = ags.Widget;
import { Draggable } from '../misc/drag.js'; import { Draggable } from '../misc/drag.js';

View file

@ -1,8 +1,10 @@
const { Window, Box, CenterBox, Icon, Revealer } = ags.Widget; const { Window, Box, CenterBox, Icon, Revealer, EventBox } = ags.Widget;
const { closeWindow } = ags.App;
const { execAsync } = ags.Utils;
const { Hyprland, Applications } = ags.Service; const { Hyprland, Applications } = ags.Service;
const { Gtk } = imports.gi; const { Gtk } = imports.gi;
import { EventBox } from '../misc/cursorbox.js'; import { Button } from '../misc/cursorbox.js';
import { PopUp } from '../misc/popup.js'; import { PopUp } from '../misc/popup.js';
const WORKSPACE_PER_ROW = 6; const WORKSPACE_PER_ROW = 6;
@ -167,8 +169,8 @@ const OverviewWidget = Box({
app.at[0] * SCALE, app.at[0] * SCALE,
app.at[1] * SCALE, app.at[1] * SCALE,
); );
existingApp.child.className = `window ${active}`; existingApp.child.child.className = `window ${active}`;
existingApp.child.style = IconStyle(app); existingApp.child.child.style = IconStyle(app);
} }
else { else {
fixed.put( fixed.put(
@ -181,12 +183,24 @@ const OverviewWidget = Box({
['address', app.address], ['address', app.address],
['toDestroy', false] ['toDestroy', false]
], ],
child: Button({
onPrimaryClickRelease: () => {
if (app.class === 'thunderbird' || app.class === 'Spotify')
execAsync(['bash', '-c', `$AGS_PATH/launch-app.sh ${app.class}`])
.then(() => closeWindow('overview'))
.catch(print);
else
execAsync(`hyprctl dispatch focuswindow address:${app.address}`)
.then(() => closeWindow('overview'))
.catch(print);
},
child: Icon({ child: Icon({
className: `window ${active}`, className: `window ${active}`,
style: IconStyle(app), style: IconStyle(app),
icon: app.class, icon: app.class,
}), }),
}), }),
}),
app.at[0] * SCALE, app.at[0] * SCALE,
app.at[1] * SCALE, app.at[1] * SCALE,
); );