feat(ags overview): implement special workspaces better and fix some bugs
This commit is contained in:
parent
e6848e2184
commit
7306b39e3a
3 changed files with 73 additions and 17 deletions
|
@ -12,7 +12,7 @@ const IconStyle = app => `min-width: ${app.size[0] * VARS.SCALE - VARS.MARGIN}px
|
||||||
font-size: ${Math.min(app.size[0] * VARS.SCALE - VARS.MARGIN,
|
font-size: ${Math.min(app.size[0] * VARS.SCALE - VARS.MARGIN,
|
||||||
app.size[1] * VARS.SCALE - VARS.MARGIN) * VARS.ICON_SCALE}px;`;
|
app.size[1] * VARS.SCALE - VARS.MARGIN) * VARS.ICON_SCALE}px;`;
|
||||||
|
|
||||||
const Client = (client, active) => Revealer({
|
const Client = (client, active, clients) => Revealer({
|
||||||
transition: 'crossfade',
|
transition: 'crossfade',
|
||||||
setup: rev => {
|
setup: rev => {
|
||||||
rev.revealChild = true;
|
rev.revealChild = true;
|
||||||
|
@ -28,14 +28,31 @@ const Client = (client, active) => Revealer({
|
||||||
.catch(print)
|
.catch(print)
|
||||||
},
|
},
|
||||||
onPrimaryClickRelease: () => {
|
onPrimaryClickRelease: () => {
|
||||||
if (client.class === 'thunderbird' || client.class === 'Spotify')
|
if (client.workspace.id < 0) {
|
||||||
execAsync(['bash', '-c', `$AGS_PATH/launch-app.sh ${client.class}`])
|
if (client.workspace.name === 'special') {
|
||||||
.then(() => closeWindow('overview'))
|
execAsync(`hyprctl dispatch movetoworkspacesilent special:${client.workspace.id},address:${client.address}`)
|
||||||
.catch(print);
|
.then(execAsync(`hyprctl dispatch togglespecialworkspace ${client.workspace.id}`)
|
||||||
else
|
.then(() => closeWindow('overview'))
|
||||||
|
.catch(print))
|
||||||
|
.catch(print);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
execAsync(`hyprctl dispatch togglespecialworkspace ${String(client.workspace.name)
|
||||||
|
.replace('special:', '')}`)
|
||||||
|
.then(() => closeWindow('overview'))
|
||||||
|
.catch(print);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// close special workspace if one is opened
|
||||||
|
let currentActive = clients.find(c => c.class === Hyprland.active.client.class)
|
||||||
|
if (currentActive.workspace.id < 0)
|
||||||
|
execAsync(`hyprctl dispatch togglespecialworkspace ${String(currentActive.workspace.name)
|
||||||
|
.replace('special:', '')}`).catch(print);
|
||||||
execAsync(`hyprctl dispatch focuswindow address:${client.address}`)
|
execAsync(`hyprctl dispatch focuswindow address:${client.address}`)
|
||||||
.then(() => closeWindow('overview'))
|
.then(() => closeWindow('overview'))
|
||||||
.catch(print);
|
.catch(print);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Icon({
|
child: Icon({
|
||||||
className: `window ${active}`,
|
className: `window ${active}`,
|
||||||
|
@ -84,7 +101,7 @@ export function updateClients(box) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fixed.put(
|
fixed.put(
|
||||||
Client(client, active),
|
Client(client, active, clients),
|
||||||
client.at[0] * VARS.SCALE,
|
client.at[0] * VARS.SCALE,
|
||||||
client.at[1] * VARS.SCALE,
|
client.at[1] * VARS.SCALE,
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,10 +25,15 @@ function createSurfaceFromWidget(widget) {
|
||||||
return surface;
|
return surface;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const WorkspaceDrop = ({id, ...params} = {}) => EventBox({
|
export const WorkspaceDrop = ({id, name, ...params} = {}) => EventBox({
|
||||||
...params,
|
...params,
|
||||||
tooltipText: `Workspace: ${id}`,
|
//tooltipText: `Workspace: ${id}`,
|
||||||
setup: eventbox => {
|
setup: eventbox => {
|
||||||
|
if (id < 0)
|
||||||
|
id = name;
|
||||||
|
else if (id === 1000)
|
||||||
|
id = "empty";
|
||||||
|
|
||||||
eventbox.drag_dest_set(Gtk.DestDefaults.ALL, TARGET, Gdk.DragAction.COPY);
|
eventbox.drag_dest_set(Gtk.DestDefaults.ALL, TARGET, Gdk.DragAction.COPY);
|
||||||
eventbox.connect('drag-data-received', (_w, _c, _x, _y, data) => {
|
eventbox.connect('drag-data-received', (_w, _c, _x, _y, data) => {
|
||||||
execAsync(`hyprctl dispatch movetoworkspacesilent ${id},address:${data.get_text()}`)
|
execAsync(`hyprctl dispatch movetoworkspacesilent ${id},address:${data.get_text()}`)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { Revealer, CenterBox, Box } = ags.Widget;
|
const { Revealer, CenterBox, Box, EventBox, Label } = ags.Widget;
|
||||||
const { Hyprland } = ags.Service;
|
const { Hyprland } = ags.Service;
|
||||||
const { Gtk } = imports.gi;
|
const { Gtk } = imports.gi;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ export function getWorkspaces(box) {
|
||||||
let children = [];
|
let children = [];
|
||||||
box.children.forEach(type => {
|
box.children.forEach(type => {
|
||||||
type.children.forEach(row => {
|
type.children.forEach(row => {
|
||||||
row.child.centerWidget.children.forEach(ch => {
|
row.child.centerWidget.child.children.forEach(ch => {
|
||||||
children.push(ch);
|
children.push(ch);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,16 +25,49 @@ export const WorkspaceRow = (className, i) => Revealer({
|
||||||
ws.id === Hyprland.active.workspace.id));
|
ws.id === Hyprland.active.workspace.id));
|
||||||
}]],
|
}]],
|
||||||
child: CenterBox({
|
child: CenterBox({
|
||||||
children: [null, Box({
|
children: [null, EventBox({
|
||||||
className: className,
|
properties: [['box']],
|
||||||
|
setup: eventbox => eventbox._box = eventbox.child.children[0],
|
||||||
|
onHover: eventbox => eventbox._box.revealChild = true,
|
||||||
|
child: Box({
|
||||||
|
className: className,
|
||||||
|
children: [
|
||||||
|
Revealer({
|
||||||
|
transition: 'slide_right',
|
||||||
|
properties: [
|
||||||
|
['id', className === 'special' ? -1 : 1000],
|
||||||
|
['name', className === 'special' ? 'special' : ''],
|
||||||
|
],
|
||||||
|
child: WorkspaceDrop({
|
||||||
|
id: className === 'special' ? -1 : 1000,
|
||||||
|
name: className === 'special' ? 'special' : '',
|
||||||
|
child: Box({
|
||||||
|
className: 'workspace',
|
||||||
|
style: `min-width: ${VARS.SCREEN.X * VARS.SCALE}px;
|
||||||
|
min-height: ${VARS.SCREEN.Y * VARS.SCALE}px;`,
|
||||||
|
children: [
|
||||||
|
ags.Widget({
|
||||||
|
type: Gtk.Fixed,
|
||||||
|
}),
|
||||||
|
Label({
|
||||||
|
label: ' +',
|
||||||
|
style: 'font-size: 40px;',
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
}), null],
|
}), null],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const Workspace = id => Revealer({
|
const Workspace = (id, name) => Revealer({
|
||||||
transition: 'slide_right',
|
transition: 'slide_right',
|
||||||
properties: [
|
properties: [
|
||||||
['id', id],
|
['id', id],
|
||||||
|
['name', name],
|
||||||
],
|
],
|
||||||
connections: [[Hyprland, box => {
|
connections: [[Hyprland, box => {
|
||||||
let active = Hyprland.active.workspace.id === box._id;
|
let active = Hyprland.active.workspace.id === box._id;
|
||||||
|
@ -43,6 +76,7 @@ const Workspace = id => Revealer({
|
||||||
}]],
|
}]],
|
||||||
child: WorkspaceDrop({
|
child: WorkspaceDrop({
|
||||||
id: id,
|
id: id,
|
||||||
|
name: name,
|
||||||
child: Box({
|
child: Box({
|
||||||
className: 'workspace',
|
className: 'workspace',
|
||||||
style: `min-width: ${VARS.SCREEN.X * VARS.SCALE}px;
|
style: `min-width: ${VARS.SCREEN.X * VARS.SCALE}px;
|
||||||
|
@ -69,12 +103,12 @@ export function updateWorkspaces(box) {
|
||||||
rowNo = Math.floor((ws.id - 1) / VARS.WORKSPACE_PER_ROW);
|
rowNo = Math.floor((ws.id - 1) / VARS.WORKSPACE_PER_ROW);
|
||||||
if (rowNo >= box.children[type].children.length) {
|
if (rowNo >= box.children[type].children.length) {
|
||||||
for (let i = box.children[type].children.length; i <= rowNo; ++i) {
|
for (let i = box.children[type].children.length; i <= rowNo; ++i) {
|
||||||
box.children[type].add(WorkspaceRow('normal', i));
|
box.children[type].add(WorkspaceRow(type ? 'special' : 'normal', i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var row = box.children[type].children[rowNo].child.centerWidget;
|
var row = box.children[type].children[rowNo].child.centerWidget.child;
|
||||||
row.add(Workspace(ws.id));
|
row.add(Workspace(ws.id, type ? ws.name : ''));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
box.show_all();
|
box.show_all();
|
||||||
|
|
Loading…
Reference in a new issue