mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-14 01:32:29 -04:00
dock: restore Hyprland special workspace windows on click (#1924)
* dock: restore Hyprland special workspace windows on click * settings: add dock special workspace restore key to spec
This commit is contained in:
@@ -480,6 +480,7 @@ Singleton {
|
|||||||
property bool dockAutoHide: false
|
property bool dockAutoHide: false
|
||||||
property bool dockSmartAutoHide: false
|
property bool dockSmartAutoHide: false
|
||||||
property bool dockGroupByApp: false
|
property bool dockGroupByApp: false
|
||||||
|
property bool dockRestoreSpecialWorkspaceOnClick: false
|
||||||
property bool dockOpenOnOverview: false
|
property bool dockOpenOnOverview: false
|
||||||
property int dockPosition: SettingsData.Position.Bottom
|
property int dockPosition: SettingsData.Position.Bottom
|
||||||
property real dockSpacing: 4
|
property real dockSpacing: 4
|
||||||
|
|||||||
@@ -295,6 +295,7 @@ var SPEC = {
|
|||||||
dockAutoHide: { def: false },
|
dockAutoHide: { def: false },
|
||||||
dockSmartAutoHide: { def: false },
|
dockSmartAutoHide: { def: false },
|
||||||
dockGroupByApp: { def: false },
|
dockGroupByApp: { def: false },
|
||||||
|
dockRestoreSpecialWorkspaceOnClick: { def: false },
|
||||||
dockOpenOnOverview: { def: false },
|
dockOpenOnOverview: { def: false },
|
||||||
dockPosition: { def: 1 },
|
dockPosition: { def: 1 },
|
||||||
dockSpacing: { def: 4 },
|
dockSpacing: { def: 4 },
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Effects
|
import QtQuick.Effects
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Hyprland
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
import qs.Common
|
import qs.Common
|
||||||
@@ -133,6 +134,40 @@ Item {
|
|||||||
function getGroupedToplevels() {
|
function getGroupedToplevels() {
|
||||||
return appData?.allWindows?.map(w => w.toplevel).filter(t => t !== null) || [];
|
return appData?.allWindows?.map(w => w.toplevel).filter(t => t !== null) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getHyprToplevelForWayland(waylandToplevel) {
|
||||||
|
if (!waylandToplevel || !CompositorService.isHyprland || !Hyprland.toplevels)
|
||||||
|
return null;
|
||||||
|
const hyprToplevels = Array.from(Hyprland.toplevels.values);
|
||||||
|
for (let i = 0; i < hyprToplevels.length; i++) {
|
||||||
|
if (hyprToplevels[i].wayland === waylandToplevel)
|
||||||
|
return hyprToplevels[i];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSpecialWorkspaceName(waylandToplevel) {
|
||||||
|
const hyprToplevel = getHyprToplevelForWayland(waylandToplevel);
|
||||||
|
if (!hyprToplevel)
|
||||||
|
return "";
|
||||||
|
const wsName = String(hyprToplevel.lastIpcObject?.workspace?.name || hyprToplevel.workspace?.name || "");
|
||||||
|
if (!wsName.startsWith("special:"))
|
||||||
|
return "";
|
||||||
|
return wsName.slice("special:".length);
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreSpecialWorkspaceWindow(waylandToplevel) {
|
||||||
|
if (!SettingsData.dockRestoreSpecialWorkspaceOnClick || !CompositorService.isHyprland || !waylandToplevel)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const specialName = getSpecialWorkspaceName(waylandToplevel);
|
||||||
|
if (!specialName)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Hyprland.dispatch("togglespecialworkspace " + specialName);
|
||||||
|
Qt.callLater(() => waylandToplevel.activate());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
onIsHoveredChanged: {
|
onIsHoveredChanged: {
|
||||||
if (mouseArea.pressed || dragging)
|
if (mouseArea.pressed || dragging)
|
||||||
return;
|
return;
|
||||||
@@ -276,8 +311,11 @@ Item {
|
|||||||
break;
|
break;
|
||||||
case "window":
|
case "window":
|
||||||
const windowToplevel = getToplevelObject();
|
const windowToplevel = getToplevelObject();
|
||||||
if (windowToplevel)
|
if (windowToplevel) {
|
||||||
|
if (restoreSpecialWorkspaceWindow(windowToplevel))
|
||||||
|
return;
|
||||||
windowToplevel.activate();
|
windowToplevel.activate();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "grouped":
|
case "grouped":
|
||||||
if (appData.windowCount === 0) {
|
if (appData.windowCount === 0) {
|
||||||
@@ -300,8 +338,11 @@ Item {
|
|||||||
SessionService.launchDesktopEntry(groupedEntry);
|
SessionService.launchDesktopEntry(groupedEntry);
|
||||||
} else if (appData.windowCount === 1) {
|
} else if (appData.windowCount === 1) {
|
||||||
const groupedToplevel = getToplevelObject();
|
const groupedToplevel = getToplevelObject();
|
||||||
if (groupedToplevel)
|
if (groupedToplevel) {
|
||||||
|
if (restoreSpecialWorkspaceWindow(groupedToplevel))
|
||||||
|
return;
|
||||||
groupedToplevel.activate();
|
groupedToplevel.activate();
|
||||||
|
}
|
||||||
} else if (contextMenu) {
|
} else if (contextMenu) {
|
||||||
const shouldHidePin = appData.appId === "org.quickshell";
|
const shouldHidePin = appData.appId === "org.quickshell";
|
||||||
contextMenu.showForButton(root, appData, root.height + 25, shouldHidePin, cachedDesktopEntry, parentDockScreen, dockApps);
|
contextMenu.showForButton(root, appData, root.height + 25, shouldHidePin, cachedDesktopEntry, parentDockScreen, dockApps);
|
||||||
|
|||||||
@@ -160,6 +160,16 @@ Item {
|
|||||||
onToggled: checked => SettingsData.set("dockGroupByApp", checked)
|
onToggled: checked => SettingsData.set("dockGroupByApp", checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsToggleRow {
|
||||||
|
settingKey: "dockRestoreSpecialWorkspaceOnClick"
|
||||||
|
tags: ["dock", "hyprland", "special", "workspace", "restore"]
|
||||||
|
text: I18n.tr("Restore Special Workspace Windows")
|
||||||
|
description: I18n.tr("When clicking a dock window in a Hyprland special workspace, bring that special workspace back before focusing the window")
|
||||||
|
checked: SettingsData.dockRestoreSpecialWorkspaceOnClick
|
||||||
|
visible: CompositorService.isHyprland
|
||||||
|
onToggled: checked => SettingsData.set("dockRestoreSpecialWorkspaceOnClick", checked)
|
||||||
|
}
|
||||||
|
|
||||||
SettingsButtonGroupRow {
|
SettingsButtonGroupRow {
|
||||||
settingKey: "dockIndicatorStyle"
|
settingKey: "dockIndicatorStyle"
|
||||||
tags: ["dock", "indicator", "style", "circle", "line"]
|
tags: ["dock", "indicator", "style", "circle", "line"]
|
||||||
|
|||||||
Reference in New Issue
Block a user