mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-15 07:35:20 -04:00
refactor: implement keyboard focus management
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import QtQuick
|
||||
import Quickshell.Hyprland
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
|
||||
@@ -52,6 +53,22 @@ Item {
|
||||
focus: true
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
// One focus grab for every modal; on Hyprland this is what delivers
|
||||
// keyboard focus to the OnDemand surface, identically in both modes.
|
||||
// The clickCatcher is whitelisted so an outside click is delivered to
|
||||
// it (closing the modal) instead of being consumed clearing the grab.
|
||||
HyprlandFocusGrab {
|
||||
windows: {
|
||||
const list = [];
|
||||
if (root.contentWindow)
|
||||
list.push(root.contentWindow);
|
||||
if (root.clickCatcher)
|
||||
list.push(root.clickCatcher);
|
||||
return list;
|
||||
}
|
||||
active: KeyboardFocus.wantsGrab(root.shouldHaveFocus, root.customKeyboardFocus)
|
||||
}
|
||||
readonly property var contentWindow: impl.item ? impl.item.contentWindow : null
|
||||
readonly property var clickCatcher: impl.item ? impl.item.clickCatcher : null
|
||||
readonly property var effectiveScreen: impl.item ? impl.item.effectiveScreen : null
|
||||
|
||||
@@ -509,15 +509,7 @@ Item {
|
||||
"error": true
|
||||
})
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: {
|
||||
if (customKeyboardFocus !== null)
|
||||
return customKeyboardFocus;
|
||||
if (!shouldHaveFocus)
|
||||
return WlrKeyboardFocus.None;
|
||||
if (root.useHyprlandFocusGrab)
|
||||
return WlrKeyboardFocus.OnDemand;
|
||||
return WlrKeyboardFocus.Exclusive;
|
||||
}
|
||||
WlrLayershell.keyboardFocus: KeyboardFocus.keyboardFocus(shouldHaveFocus, customKeyboardFocus)
|
||||
|
||||
anchors {
|
||||
left: true
|
||||
|
||||
@@ -259,15 +259,7 @@ Item {
|
||||
"error": true
|
||||
})
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: {
|
||||
if (customKeyboardFocus !== null)
|
||||
return customKeyboardFocus;
|
||||
if (!shouldHaveFocus)
|
||||
return WlrKeyboardFocus.None;
|
||||
if (root.useHyprlandFocusGrab)
|
||||
return WlrKeyboardFocus.OnDemand;
|
||||
return WlrKeyboardFocus.Exclusive;
|
||||
}
|
||||
WlrLayershell.keyboardFocus: KeyboardFocus.keyboardFocus(shouldHaveFocus, customKeyboardFocus)
|
||||
|
||||
anchors {
|
||||
left: true
|
||||
|
||||
Reference in New Issue
Block a user