use hyprland global keybind dispatch for window toggling

This commit is contained in:
end-4
2025-04-27 23:06:22 +02:00
parent 4548000077
commit 9b0d769598
13 changed files with 134 additions and 111 deletions
@@ -21,15 +21,16 @@ Scope {
property var modelData
property string searchingText: ""
screen: modelData
visible: GlobalStates.overviewOpen
// visible: GlobalStates.overviewOpen
visible: true
WlrLayershell.namespace: "quickshell:overview"
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
// WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
color: "transparent"
mask: Region {
item: columnLayout
item: GlobalStates.overviewOpen ? columnLayout : null
}
anchors {
@@ -69,6 +70,7 @@ Scope {
ColumnLayout {
id: columnLayout
visible: GlobalStates.overviewOpen
anchors.horizontalCenter: parent.horizontalCenter
Keys.onPressed: (event) => {
@@ -125,6 +127,14 @@ Scope {
GlobalStates.overviewOpen = !GlobalStates.overviewOpen
}
}
GlobalShortcut {
name: "overviewClose"
description: "Closes overview"
onPressed: {
GlobalStates.overviewOpen = false
}
}
GlobalShortcut {
name: "overviewToggleRelease"
description: "Toggles overview on release"
@@ -42,11 +42,6 @@ Item {
property Component windowComponent: OverviewWindow {}
property list<OverviewWindow> windowWidgets: []
Process {
id: closeOverview
command: ["bash", "-c", "qs ipc call overview close &"] // Somehow has to be async to work?
}
Rectangle {
id: overviewBackground
@@ -91,7 +86,7 @@ Item {
acceptedButtons: Qt.LeftButton
onClicked: {
if (root.draggingTargetWorkspace === -1) {
closeOverview.running = true
Hyprland.dispatch(`global quickshell:overviewClose`)
Hyprland.dispatch(`workspace ${workspaceValue}`)
}
}
@@ -191,7 +186,7 @@ Item {
if (!windowData) return;
if (event.button === Qt.LeftButton) {
closeOverview.running = true
Hyprland.dispatch(`global quickshell:overviewClose`)
Hyprland.dispatch(`workspace ${windowData.workspace.id}`)
event.accepted = true
} else if (event.button === Qt.MiddleButton) {
@@ -71,11 +71,6 @@ Rectangle { // Window
}
}
Process {
id: closeOverview
command: ["bash", "-c", "qs ipc call overview close &"] // Somehow has to by async to work?
}
ColumnLayout {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
@@ -8,6 +8,7 @@ import QtQuick.Layouts
import Quickshell
import Quickshell.Io
import Quickshell.Widgets
import Quickshell.Hyprland
Button {
id: root
@@ -35,7 +36,7 @@ Button {
PointingHandInteraction {}
onClicked: {
root.itemExecute()
closeOverview.running = true
Hyprland.dispatch("global quickshell:overviewClose")
}
Keys.onPressed: (event) => {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
@@ -116,9 +117,4 @@ Button {
text: root.itemClickActionName
}
}
Process {
id: closeOverview
command: ["bash", "-c", "qs ipc call overview close &"] // Somehow has to be async to work?
}
}