mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Hyprland: fix keyboard focus for launcher and other panels with direct text input
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.Commons
|
||||
|
||||
@@ -14,6 +15,9 @@ Singleton {
|
||||
property var openedPanel: null
|
||||
property var closingPanel: null
|
||||
property bool closedImmediately: false
|
||||
// Brief window after panel opens where Exclusive keyboard is allowed on Hyprland
|
||||
// This allows text inputs to receive focus, then switches to OnDemand for click-to-close
|
||||
property bool isInitializingKeyboard: false
|
||||
signal willOpen
|
||||
signal didClose
|
||||
|
||||
@@ -87,6 +91,16 @@ Singleton {
|
||||
return name in registeredPanels;
|
||||
}
|
||||
|
||||
// Timer to switch from Exclusive to OnDemand keyboard focus on Hyprland
|
||||
Timer {
|
||||
id: keyboardInitTimer
|
||||
interval: 100
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
root.isInitializingKeyboard = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to keep only one panel open at any time
|
||||
function willOpenPanel(panel) {
|
||||
if (openedPanel && openedPanel !== panel) {
|
||||
@@ -100,6 +114,12 @@ Singleton {
|
||||
openedPanel = panel;
|
||||
assignToSlot(0, panel);
|
||||
|
||||
// Start keyboard initialization period (for Hyprland workaround)
|
||||
if (panel.exclusiveKeyboard) {
|
||||
isInitializingKeyboard = true;
|
||||
keyboardInitTimer.restart();
|
||||
}
|
||||
|
||||
// emit signal
|
||||
willOpen();
|
||||
}
|
||||
@@ -115,6 +135,10 @@ Singleton {
|
||||
assignToSlot(1, null);
|
||||
}
|
||||
|
||||
// Reset keyboard init state
|
||||
isInitializingKeyboard = false;
|
||||
keyboardInitTimer.stop();
|
||||
|
||||
// emit signal
|
||||
didClose();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user