mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-10 07:25:37 -05:00
dankbar/mask: extra polish for Hyprland maybe
This commit is contained in:
@@ -6,49 +6,27 @@ import QtQuick
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property var activeOverflowMenus: ({})
|
||||
property var activeTrayMenus: ({})
|
||||
property var activeTrayBars: ({})
|
||||
|
||||
function registerOverflowMenu(screenName, menuOpenBinding) {
|
||||
function register(screenName, trayBar) {
|
||||
if (!screenName || !trayBar) return
|
||||
activeTrayBars[screenName] = trayBar
|
||||
}
|
||||
|
||||
function unregister(screenName) {
|
||||
if (!screenName) return
|
||||
activeOverflowMenus[screenName] = menuOpenBinding
|
||||
}
|
||||
|
||||
function unregisterOverflowMenu(screenName) {
|
||||
if (!screenName) return
|
||||
delete activeOverflowMenus[screenName]
|
||||
}
|
||||
|
||||
function registerTrayMenu(screenName, closeCallback) {
|
||||
if (!screenName) return
|
||||
activeTrayMenus[screenName] = closeCallback
|
||||
}
|
||||
|
||||
function unregisterTrayMenu(screenName) {
|
||||
if (!screenName) return
|
||||
delete activeTrayMenus[screenName]
|
||||
}
|
||||
|
||||
function closeOverflowMenus() {
|
||||
for (const screenName in activeOverflowMenus) {
|
||||
const menuBinding = activeOverflowMenus[screenName]
|
||||
if (menuBinding && menuBinding.close) {
|
||||
menuBinding.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function closeTrayMenus() {
|
||||
for (const screenName in activeTrayMenus) {
|
||||
const closeCallback = activeTrayMenus[screenName]
|
||||
if (closeCallback) {
|
||||
closeCallback()
|
||||
}
|
||||
}
|
||||
delete activeTrayBars[screenName]
|
||||
}
|
||||
|
||||
function closeAllMenus() {
|
||||
closeOverflowMenus()
|
||||
closeTrayMenus()
|
||||
for (const screenName in activeTrayBars) {
|
||||
const trayBar = activeTrayBars[screenName]
|
||||
if (!trayBar) continue
|
||||
|
||||
trayBar.menuOpen = false
|
||||
if (trayBar.currentTrayMenu) {
|
||||
trayBar.currentTrayMenu.showMenu = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,10 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: shouldHaveFocus ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||
WlrLayershell.keyboardFocus: {
|
||||
if (!shouldHaveFocus) return WlrKeyboardFocus.None
|
||||
return CompositorService.isHyprland ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.Exclusive
|
||||
}
|
||||
onVisibleChanged: {
|
||||
if (root.visible) {
|
||||
opened()
|
||||
|
||||
@@ -17,9 +17,6 @@ DankPopout {
|
||||
|
||||
property var triggerScreen: null
|
||||
|
||||
// Setting to Exclusive, so virtual keyboards can send input to app drawer
|
||||
WlrLayershell.keyboardFocus: shouldBeVisible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||
|
||||
function show() {
|
||||
open()
|
||||
}
|
||||
|
||||
@@ -49,21 +49,16 @@ Item {
|
||||
visible: allTrayItems.length > 0
|
||||
|
||||
property bool menuOpen: false
|
||||
property bool overflowWasOpenBeforeTrayMenu: false
|
||||
property var currentTrayMenu: null
|
||||
|
||||
Component.onCompleted: {
|
||||
if (parentScreen) {
|
||||
TrayMenuManager.registerOverflowMenu(parentScreen.name, {
|
||||
close: () => { root.menuOpen = false }
|
||||
})
|
||||
}
|
||||
if (!parentScreen) return
|
||||
TrayMenuManager.register(parentScreen.name, root)
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
if (parentScreen) {
|
||||
TrayMenuManager.unregisterOverflowMenu(parentScreen.name)
|
||||
TrayMenuManager.unregisterTrayMenu(parentScreen.name)
|
||||
}
|
||||
if (!parentScreen) return
|
||||
TrayMenuManager.unregister(parentScreen.name)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -186,7 +181,7 @@ Item {
|
||||
|
||||
if (!delegateRoot.trayItem.hasMenu) return
|
||||
|
||||
root.overflowWasOpenBeforeTrayMenu = root.menuOpen
|
||||
root.menuOpen = false
|
||||
root.showForTrayItem(delegateRoot.trayItem, visualContent, parentScreen, root.isAtBottom, root.isVertical, root.axis)
|
||||
}
|
||||
}
|
||||
@@ -319,7 +314,7 @@ Item {
|
||||
|
||||
if (!delegateRoot.trayItem.hasMenu) return
|
||||
|
||||
root.overflowWasOpenBeforeTrayMenu = root.menuOpen
|
||||
root.menuOpen = false
|
||||
root.showForTrayItem(delegateRoot.trayItem, visualContent, parentScreen, root.isAtBottom, root.isVertical, root.axis)
|
||||
}
|
||||
}
|
||||
@@ -722,7 +717,6 @@ Item {
|
||||
|
||||
if (!trayItem.hasMenu) return
|
||||
|
||||
root.overflowWasOpenBeforeTrayMenu = true
|
||||
root.menuOpen = false
|
||||
root.showForTrayItem(trayItem, parent, parentScreen, root.isAtBottom, root.isVertical, root.axis)
|
||||
}
|
||||
@@ -784,7 +778,6 @@ Item {
|
||||
}
|
||||
|
||||
function closeWithAction() {
|
||||
root.overflowWasOpenBeforeTrayMenu = false
|
||||
close()
|
||||
}
|
||||
|
||||
@@ -1329,39 +1322,19 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
property var currentTrayMenu: null
|
||||
|
||||
Connections {
|
||||
target: currentTrayMenu
|
||||
enabled: currentTrayMenu !== null
|
||||
function onShowMenuChanged() {
|
||||
if (parentWindow && typeof parentWindow.systemTrayMenuOpen !== "undefined") {
|
||||
parentWindow.systemTrayMenuOpen = currentTrayMenu.showMenu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showForTrayItem(item, anchor, screen, atBottom, vertical, axisObj) {
|
||||
if (parentWindow && typeof parentWindow.systemTrayMenuOpen !== "undefined") {
|
||||
parentWindow.systemTrayMenuOpen = true
|
||||
}
|
||||
if (!screen) return
|
||||
|
||||
if (currentTrayMenu) {
|
||||
root.overflowWasOpenBeforeTrayMenu = false
|
||||
currentTrayMenu.showMenu = false
|
||||
currentTrayMenu.destroy()
|
||||
currentTrayMenu = null
|
||||
}
|
||||
|
||||
currentTrayMenu = trayMenuComponent.createObject(null)
|
||||
if (currentTrayMenu && screen) {
|
||||
if (!currentTrayMenu) return
|
||||
|
||||
currentTrayMenu.showForTrayItem(item, anchor, screen, atBottom, vertical ?? false, axisObj)
|
||||
TrayMenuManager.registerTrayMenu(screen.name, () => {
|
||||
if (currentTrayMenu) {
|
||||
currentTrayMenu.close()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ DankPopout {
|
||||
property var triggerScreen: null
|
||||
property int currentTabIndex: 0
|
||||
|
||||
keyboardFocusMode: WlrKeyboardFocus.Exclusive
|
||||
|
||||
function setTriggerPosition(x, y, width, section, screen) {
|
||||
triggerSection = section
|
||||
|
||||
@@ -35,7 +35,7 @@ Scope {
|
||||
WlrLayershell.namespace: "dms:workspace-overview"
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
||||
WlrLayershell.keyboardFocus: overviewScope.overviewOpen ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
|
||||
@@ -8,8 +8,6 @@ DankPopout {
|
||||
|
||||
layerNamespace: "dms-plugin:" + layerNamespacePlugin
|
||||
|
||||
WlrLayershell.keyboardFocus: shouldBeVisible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||
|
||||
property var triggerScreen: null
|
||||
property Component pluginContent: null
|
||||
property real contentWidth: 400
|
||||
|
||||
@@ -28,7 +28,6 @@ PanelWindow {
|
||||
property list<real> animationEnterCurve: Theme.expressiveCurves.expressiveDefaultSpatial
|
||||
property list<real> animationExitCurve: Theme.expressiveCurves.emphasized
|
||||
property bool shouldBeVisible: false
|
||||
property int keyboardFocusMode: WlrKeyboardFocus.Exclusive
|
||||
|
||||
visible: false
|
||||
|
||||
@@ -97,7 +96,10 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: shouldBeVisible ? keyboardFocusMode : WlrKeyboardFocus.None
|
||||
WlrLayershell.keyboardFocus: {
|
||||
if (!shouldBeVisible) return WlrKeyboardFocus.None
|
||||
return CompositorService.isHyprland ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.Exclusive
|
||||
}
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
|
||||
Reference in New Issue
Block a user