no more hacky focus grab thanks to hyprland's dfb841c303263208c2f8ac7a55fbdf4668594fb7

This commit is contained in:
end-4
2025-05-19 08:45:40 +02:00
parent a0ed714199
commit 29fb9a5268
3 changed files with 8 additions and 59 deletions
@@ -22,7 +22,6 @@ Scope { // Scope
sourceComponent: PanelWindow { // Window sourceComponent: PanelWindow { // Window
id: cheatsheetRoot id: cheatsheetRoot
visible: cheatsheetLoader.active visible: cheatsheetLoader.active
focusable: true
anchors { anchors {
top: true top: true
@@ -49,28 +48,12 @@ Scope { // Scope
HyprlandFocusGrab { // Click outside to close HyprlandFocusGrab { // Click outside to close
id: grab id: grab
windows: [ cheatsheetRoot ] windows: [ cheatsheetRoot ]
active: false active: cheatsheetRoot.visible
onCleared: () => { onCleared: () => {
if (!active) cheatsheetRoot.hide() if (!active) cheatsheetRoot.hide()
} }
} }
Connections {
target: cheatsheetRoot
function onVisibleChanged() {
delayedGrabTimer.start()
}
}
Timer {
id: delayedGrabTimer
interval: ConfigOptions.hacks.arbitraryRaceConditionDelay
repeat: false
onTriggered: {
grab.active = cheatsheetRoot.visible
}
}
// Background // Background
Rectangle { Rectangle {
id: cheatsheetBackground id: cheatsheetBackground
@@ -27,7 +27,7 @@ Scope { // Scope
PanelWindow { // Window PanelWindow { // Window
id: sidebarRoot id: sidebarRoot
visible: sidebarLoader.active visible: sidebarLoader.active
focusable: true
property int selectedTab: PersistentStates.sidebar.leftSide.selectedTab property int selectedTab: PersistentStates.sidebar.leftSide.selectedTab
property bool extend: false property bool extend: false
property bool pin: false property bool pin: false
@@ -37,7 +37,10 @@ Scope { // Scope
sidebarLoader.active = false sidebarLoader.active = false
} }
exclusiveZone: pin ? sidebarWidth : 0 exclusiveZone: {
console.log(sidebarRoot.pin ? sidebarWidth : 0)
return sidebarRoot.pin ? sidebarWidth : 0
}
implicitWidth: Appearance.sizes.sidebarWidthExtended implicitWidth: Appearance.sizes.sidebarWidthExtended
WlrLayershell.namespace: "quickshell:sidebarLeft" WlrLayershell.namespace: "quickshell:sidebarLeft"
// Hyprland 0.49: OnDemand is Exclusive, Exclusive just breaks click-outside-to-close // Hyprland 0.49: OnDemand is Exclusive, Exclusive just breaks click-outside-to-close
@@ -57,32 +60,12 @@ Scope { // Scope
HyprlandFocusGrab { // Click outside to close HyprlandFocusGrab { // Click outside to close
id: grab id: grab
windows: [ sidebarRoot ] windows: [ sidebarRoot ]
active: false active: sidebarRoot.visible && !sidebarRoot.pin
onCleared: () => { onCleared: () => {
if (!active) sidebarRoot.hide() if (!active) sidebarRoot.hide()
} }
} }
Connections {
target: sidebarRoot
function onVisibleChanged() {
delayedGrabTimer.start()
swipeView.children[0].children[0].children[sidebarRoot.selectedTab].forceActiveFocus()
}
function onPinChanged() {
grab.active = !sidebarRoot.pin
}
}
Timer {
id: delayedGrabTimer
interval: ConfigOptions.hacks.arbitraryRaceConditionDelay
repeat: false
onTriggered: {
grab.active = sidebarRoot.visible && !sidebarRoot.pin
}
}
// Background // Background
Rectangle { Rectangle {
id: sidebarLeftBackground id: sidebarLeftBackground
@@ -27,7 +27,6 @@ Scope {
PanelWindow { PanelWindow {
id: sidebarRoot id: sidebarRoot
visible: sidebarLoader.active visible: sidebarLoader.active
focusable: true
function hide() { function hide() {
sidebarLoader.active = false sidebarLoader.active = false
@@ -49,28 +48,12 @@ Scope {
HyprlandFocusGrab { HyprlandFocusGrab {
id: grab id: grab
windows: [ sidebarRoot ] windows: [ sidebarRoot ]
active: false active: sidebarRoot.visible
onCleared: () => { onCleared: () => {
if (!active) sidebarRoot.hide() if (!active) sidebarRoot.hide()
} }
} }
Connections {
target: sidebarRoot
function onVisibleChanged() {
delayedGrabTimer.start()
}
}
Timer {
id: delayedGrabTimer
interval: ConfigOptions.hacks.arbitraryRaceConditionDelay
repeat: false
onTriggered: {
grab.active = sidebarRoot.visible
}
}
// Background // Background
Rectangle { Rectangle {
id: sidebarRightBackground id: sidebarRightBackground