diff --git a/config/ags/js/overview/clients.js b/config/ags/js/overview/clients.js index cc74bc2..7190dbc 100644 --- a/config/ags/js/overview/clients.js +++ b/config/ags/js/overview/clients.js @@ -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, app.size[1] * VARS.SCALE - VARS.MARGIN) * VARS.ICON_SCALE}px;`; -const Client = (client, active) => Revealer({ +const Client = (client, active, clients) => Revealer({ transition: 'crossfade', setup: rev => { rev.revealChild = true; @@ -28,14 +28,31 @@ const Client = (client, active) => Revealer({ .catch(print) }, onPrimaryClickRelease: () => { - if (client.class === 'thunderbird' || client.class === 'Spotify') - execAsync(['bash', '-c', `$AGS_PATH/launch-app.sh ${client.class}`]) - .then(() => closeWindow('overview')) - .catch(print); - else + if (client.workspace.id < 0) { + if (client.workspace.name === 'special') { + execAsync(`hyprctl dispatch movetoworkspacesilent special:${client.workspace.id},address:${client.address}`) + .then(execAsync(`hyprctl dispatch togglespecialworkspace ${client.workspace.id}`) + .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}`) .then(() => closeWindow('overview')) .catch(print); + } }, child: Icon({ className: `window ${active}`, @@ -84,7 +101,7 @@ export function updateClients(box) { } else { fixed.put( - Client(client, active), + Client(client, active, clients), client.at[0] * VARS.SCALE, client.at[1] * VARS.SCALE, ); diff --git a/config/ags/js/overview/dragndrop.js b/config/ags/js/overview/dragndrop.js index 15b8843..0060535 100644 --- a/config/ags/js/overview/dragndrop.js +++ b/config/ags/js/overview/dragndrop.js @@ -25,10 +25,15 @@ function createSurfaceFromWidget(widget) { return surface; }; -export const WorkspaceDrop = ({id, ...params} = {}) => EventBox({ +export const WorkspaceDrop = ({id, name, ...params} = {}) => EventBox({ ...params, - tooltipText: `Workspace: ${id}`, + //tooltipText: `Workspace: ${id}`, 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.connect('drag-data-received', (_w, _c, _x, _y, data) => { execAsync(`hyprctl dispatch movetoworkspacesilent ${id},address:${data.get_text()}`) diff --git a/config/ags/js/overview/workspaces.js b/config/ags/js/overview/workspaces.js index 67cbd4d..55d8d8f 100644 --- a/config/ags/js/overview/workspaces.js +++ b/config/ags/js/overview/workspaces.js @@ -1,4 +1,4 @@ -const { Revealer, CenterBox, Box } = ags.Widget; +const { Revealer, CenterBox, Box, EventBox, Label } = ags.Widget; const { Hyprland } = ags.Service; const { Gtk } = imports.gi; @@ -9,7 +9,7 @@ export function getWorkspaces(box) { let children = []; box.children.forEach(type => { type.children.forEach(row => { - row.child.centerWidget.children.forEach(ch => { + row.child.centerWidget.child.children.forEach(ch => { children.push(ch); }); }); @@ -25,16 +25,49 @@ export const WorkspaceRow = (className, i) => Revealer({ ws.id === Hyprland.active.workspace.id)); }]], child: CenterBox({ - children: [null, Box({ - className: className, + children: [null, EventBox({ + 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], }), }); -const Workspace = id => Revealer({ +const Workspace = (id, name) => Revealer({ transition: 'slide_right', properties: [ ['id', id], + ['name', name], ], connections: [[Hyprland, box => { let active = Hyprland.active.workspace.id === box._id; @@ -43,6 +76,7 @@ const Workspace = id => Revealer({ }]], child: WorkspaceDrop({ id: id, + name: name, child: Box({ className: 'workspace', 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); if (rowNo >= box.children[type].children.length) { 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; - row.add(Workspace(ws.id)); + var row = box.children[type].children[rowNo].child.centerWidget.child; + row.add(Workspace(ws.id, type ? ws.name : '')); } }); box.show_all();