1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

re-work mouse handling of dannkbar

This commit is contained in:
bbedward
2025-10-13 21:34:53 -04:00
parent 07fe2ca407
commit 3be3e622bc
3 changed files with 13 additions and 57 deletions

View File

@@ -302,7 +302,7 @@ Item {
property bool reveal: { property bool reveal: {
if (CompositorService.isNiri && NiriService.inOverview) { if (CompositorService.isNiri && NiriService.inOverview) {
return SettingsData.dankBarOpenOnOverview return SettingsData.dankBarOpenOnOverview || topBarMouseArea.containsMouse || hasActivePopout || revealSticky
} }
return SettingsData.dankBarVisible && (!autoHide || topBarMouseArea.containsMouse || hasActivePopout || revealSticky) return SettingsData.dankBarVisible && (!autoHide || topBarMouseArea.containsMouse || hasActivePopout || revealSticky)
} }
@@ -385,7 +385,6 @@ Item {
top: barWindow.isVertical ? parent.top : undefined top: barWindow.isVertical ? parent.top : undefined
bottom: barWindow.isVertical ? parent.bottom : undefined bottom: barWindow.isVertical ? parent.bottom : undefined
} }
// Only enable mouse handling while hidden (for reveal-on-edge logic).
readonly property bool inOverview: CompositorService.isNiri && NiriService.inOverview && SettingsData.dankBarOpenOnOverview readonly property bool inOverview: CompositorService.isNiri && NiriService.inOverview && SettingsData.dankBarOpenOnOverview
hoverEnabled: SettingsData.dankBarAutoHide && !topBarCore.reveal && !inOverview hoverEnabled: SettingsData.dankBarAutoHide && !topBarCore.reveal && !inOverview
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton

View File

@@ -128,7 +128,6 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
if (root.popupTarget && root.popupTarget.setTriggerPosition) { if (root.popupTarget && root.popupTarget.setTriggerPosition) {
@@ -139,36 +138,6 @@ Rectangle {
} }
root.clicked() root.clicked()
} }
onEntered: {
tooltipLoader.active = true
if (tooltipLoader.item && activePlayer) {
const globalPos = parent.mapToGlobal(parent.width / 2, parent.height / 2)
const screenX = root.parentScreen ? root.parentScreen.x : 0
const screenY = root.parentScreen ? root.parentScreen.y : 0
const relativeY = globalPos.y - screenY
const tooltipX = root.axis?.edge === "left" ? (Theme.barHeight + SettingsData.dankBarSpacing + Theme.spacingXS) : (root.parentScreen.width - Theme.barHeight - SettingsData.dankBarSpacing - Theme.spacingXS)
let identity = activePlayer.identity || ""
let isWebMedia = identity.toLowerCase().includes("firefox") || identity.toLowerCase().includes("chrome") || identity.toLowerCase().includes("chromium")
let title = activePlayer.trackTitle || "Unknown Track"
let subtitle = ""
if (isWebMedia && activePlayer.trackTitle) {
subtitle = activePlayer.trackArtist || identity
} else {
subtitle = activePlayer.trackArtist || ""
}
let tooltipText = subtitle.length > 0 ? title + " • " + subtitle : title
const isLeft = root.axis?.edge === "left"
tooltipLoader.item.show(tooltipText, screenX + tooltipX, relativeY, root.parentScreen, isLeft, !isLeft)
}
}
onExited: {
if (tooltipLoader.item) {
tooltipLoader.item.hide()
}
tooltipLoader.active = false
}
} }
} }
@@ -191,8 +160,7 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
enabled: root.playerAvailable enabled: root.playerAvailable
hoverEnabled: enabled cursorShape: Qt.PointingHandCursor
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
onClicked: (mouse) => { onClicked: (mouse) => {
if (!activePlayer) return if (!activePlayer) return
@@ -208,12 +176,6 @@ Rectangle {
} }
} }
Loader {
id: tooltipLoader
active: false
sourceComponent: DankTooltip {}
}
Row { Row {
id: mediaRow id: mediaRow
@@ -314,9 +276,8 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
enabled: root.playerAvailable && root.opacity > 0 && root.width > 0 && textContainer.visible enabled: root.playerAvailable
hoverEnabled: enabled cursorShape: Qt.PointingHandCursor
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
onPressed: { onPressed: {
if (root.popupTarget && root.popupTarget.setTriggerPosition) { if (root.popupTarget && root.popupTarget.setTriggerPosition) {
const globalPos = mapToGlobal(0, 0) const globalPos = mapToGlobal(0, 0)
@@ -356,9 +317,9 @@ Rectangle {
id: prevArea id: prevArea
anchors.fill: parent anchors.fill: parent
enabled: root.playerAvailable && root.width > 0 enabled: root.playerAvailable
hoverEnabled: enabled hoverEnabled: true
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
if (activePlayer) { if (activePlayer) {
activePlayer.previous(); activePlayer.previous();
@@ -386,9 +347,8 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
enabled: root.playerAvailable && root.width > 0 enabled: root.playerAvailable
hoverEnabled: enabled cursorShape: Qt.PointingHandCursor
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: { onClicked: {
if (activePlayer) { if (activePlayer) {
activePlayer.togglePlaying(); activePlayer.togglePlaying();
@@ -418,9 +378,9 @@ Rectangle {
id: nextArea id: nextArea
anchors.fill: parent anchors.fill: parent
enabled: root.playerAvailable && root.width > 0 enabled: root.playerAvailable
hoverEnabled: enabled hoverEnabled: true
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
if (activePlayer) { if (activePlayer) {
activePlayer.next(); activePlayer.next();

View File

@@ -241,7 +241,6 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
property real scrollAccumulator: 0 property real scrollAccumulator: 0
@@ -416,9 +415,7 @@ Rectangle {
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.centerIn: parent anchors.fill: parent
width: root.isVertical ? parent.width + Theme.spacingXL : parent.width
height: root.isVertical ? parent.height : parent.height + Theme.spacingXL
hoverEnabled: !isPlaceholder hoverEnabled: !isPlaceholder
cursorShape: isPlaceholder ? Qt.ArrowCursor : Qt.PointingHandCursor cursorShape: isPlaceholder ? Qt.ArrowCursor : Qt.PointingHandCursor
enabled: !isPlaceholder enabled: !isPlaceholder