forked from Shinonome/dots-hyprland
use shared focusgrab for most stuff (makes osk usable w/ other panels)
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
|
||||
/**
|
||||
* Manages a HyprlandFocusGrab that's to be shared by all windows.
|
||||
* "Persistent" is for windows that should always be included but not closed on dismiss, like bar and onscreen keyboard.
|
||||
* "Dismissable" is for stuff like sidebars
|
||||
*/
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
signal dismissed()
|
||||
|
||||
property list<var> persistent: []
|
||||
property list<var> dismissable: []
|
||||
|
||||
function dismiss() {
|
||||
root.dismissable = [];
|
||||
root.dismissed();
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("[GlobalFocusGrab] Initialized");
|
||||
}
|
||||
|
||||
function addPersistent(window) {
|
||||
if (root.persistent.indexOf(window) === -1) {
|
||||
root.persistent.push(window);
|
||||
}
|
||||
}
|
||||
|
||||
function removePersistent(window) {
|
||||
var index = root.persistent.indexOf(window);
|
||||
if (index !== -1) {
|
||||
root.persistent.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function addDismissable(window) {
|
||||
if (root.dismissable.indexOf(window) === -1) {
|
||||
root.dismissable.push(window);
|
||||
}
|
||||
}
|
||||
|
||||
function removeDismissable(window) {
|
||||
var index = root.dismissable.indexOf(window);
|
||||
if (index !== -1) {
|
||||
root.dismissable.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
HyprlandFocusGrab {
|
||||
id: grab
|
||||
windows: [...root.persistent, ...root.dismissable]
|
||||
active: root.dismissable.length > 0
|
||||
onCleared: () => {
|
||||
root.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user