mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-06 05:28:29 -04:00
9981fcf529
DankSlideout always held WlrKeyboardFocus.OnDemand regardless of modals, causing Notepad to steal focus back when Launcher was opened. ModalManager: clone currentModalsByScreen on mutation so QML bindings re-evaluate when modals open/close. DankSlideout: set keyboardFocus to None while a modal is active on the same screen, letting the modal (launcher) claim focus exclusively.
51 lines
1.5 KiB
QML
51 lines
1.5 KiB
QML
pragma Singleton
|
|
pragma ComponentBehavior: Bound
|
|
|
|
import Quickshell
|
|
import QtQuick
|
|
|
|
Singleton {
|
|
id: modalManager
|
|
|
|
signal closeAllModalsExcept(var excludedModal)
|
|
signal modalChanged
|
|
|
|
property var currentModalsByScreen: ({})
|
|
|
|
function openModal(modal) {
|
|
PopoutManager.screenshotActive = false;
|
|
const screenName = modal.effectiveScreen?.name ?? "unknown";
|
|
var next = {};
|
|
for (var k in currentModalsByScreen)
|
|
next[k] = currentModalsByScreen[k];
|
|
next[screenName] = modal;
|
|
currentModalsByScreen = next;
|
|
modalChanged();
|
|
Qt.callLater(() => {
|
|
if (!modal.allowStacking)
|
|
closeAllModalsExcept(modal);
|
|
if (!modal.keepPopoutsOpen)
|
|
PopoutManager.closeAllPopouts();
|
|
TrayMenuManager.closeAllMenus();
|
|
});
|
|
}
|
|
|
|
function isCurrentModal(modal, screenName) {
|
|
const name = screenName || modal?.effectiveScreen?.name || "unknown";
|
|
return currentModalsByScreen[name] === modal;
|
|
}
|
|
|
|
function closeModal(modal) {
|
|
const screenName = modal.effectiveScreen?.name ?? "unknown";
|
|
if (currentModalsByScreen[screenName] === modal) {
|
|
var next = {};
|
|
for (var k in currentModalsByScreen) {
|
|
if (k !== screenName)
|
|
next[k] = currentModalsByScreen[k];
|
|
}
|
|
currentModalsByScreen = next;
|
|
modalChanged();
|
|
}
|
|
}
|
|
}
|