feat: input mgr
This commit is contained in:
58
Shell/ShellInputManager.qml
Normal file
58
Shell/ShellInputManager.qml
Normal file
@@ -0,0 +1,58 @@
|
||||
pragma Singleton
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
|
||||
QtObject {
|
||||
id: inputManager
|
||||
|
||||
property var handlers: ({})
|
||||
|
||||
function openShell() {
|
||||
ShellStateManager.openShell();
|
||||
}
|
||||
|
||||
function closeShell() {
|
||||
ShellStateManager.closeShell();
|
||||
}
|
||||
|
||||
function registerHandler(context, handler) {
|
||||
handlers[context] = handler;
|
||||
}
|
||||
|
||||
function unregisterHandler(context) {
|
||||
handlers[context] = undefined;
|
||||
if (handlers.hasOwnProperty(context))
|
||||
delete handlers[context];
|
||||
}
|
||||
|
||||
function handleKeyInternal(key) {
|
||||
if (!ShellStateManager.shellOpen)
|
||||
return false;
|
||||
|
||||
var context = ShellStateManager.quickSettingsOpen ? "quickSettings" : "topbar";
|
||||
var handler = handlers[context];
|
||||
if (handler) {
|
||||
var handled = handler(key);
|
||||
if (handled)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key === Qt.Key_Escape || key === Qt.Key_Shift || key === Qt.Key_X) {
|
||||
if (context === "quickSettings") {
|
||||
ShellStateManager.closeQuickSettings();
|
||||
} else if (context === "topbar") {
|
||||
ShellStateManager.closeShell();
|
||||
Hyprland.dispatch("submap reset");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleKey(event) {
|
||||
handleKeyInternal(event.key);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user