Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions shell/plugins/bar/widgets/Tray.qml
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,18 @@ BarWidget {
id: horizontalTrayRoot

readonly property int pinnedWidth: pinnedRow.implicitWidth
readonly property int drawerBlockWidth: root.hasDrawer ? expandIcon.implicitWidth + root.drawerExtent : 0
// Only reserve the chevron plus the currently revealed drawer width so a
// collapsed tray does not permanently occupy its fully-expanded footprint
// on the bar (#13182).
readonly property int drawerBlockWidth: root.hasDrawer ? expandIcon.implicitWidth + Math.round(root.revealExtent) : 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Drawer layout goes unchecked

The changed drawer layout has no regression test. tray-test.sh only checks TrayModel.js helpers, so it passes even if the collapsed drawer reserves extra space or the chevron overlaps an icon. Add checks for collapsed, partly revealed, and fully open states in both orientations, including pinned items.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


implicitWidth: pinnedWidth + drawerBlockWidth
implicitHeight: root.barSize

// Mask out the empty area the collapsed drawer reserves for its slide-in,
// so hovering it doesn't trigger expand and clicks pass through.
containmentMask: QtObject {
function contains(point: point): bool {
if (point.y < 0 || point.y > horizontalTrayRoot.height) return false
// Drawer reveals leftward; chevron sits at the right end when collapsed
// and slides left as it opens. The visible region starts at the chevron.
var chevronX = root.drawerExtent - root.revealExtent
if (point.x >= chevronX && point.x <= horizontalTrayRoot.drawerBlockWidth) return true
// Pinned items, placed to the right of the drawer block.
if (point.x >= 0 && point.x <= horizontalTrayRoot.drawerBlockWidth) return true
var pinnedStart = horizontalTrayRoot.drawerBlockWidth
return point.x >= pinnedStart && point.x <= horizontalTrayRoot.implicitWidth
}
Expand All @@ -282,7 +279,8 @@ BarWidget {
bar: root.bar
width: implicitWidth
height: implicitHeight
x: root.drawerExtent - root.revealExtent
// Chevron stays at the right edge of the growing drawer block.
x: Math.round(root.revealExtent)
text: "\uf053"
onPressed: function(button) {
if (button === Qt.RightButton) root.managePopupOpen = !root.managePopupOpen
Expand All @@ -291,15 +289,15 @@ BarWidget {

Item {
id: trayClip
x: expandIcon.width
x: 0
anchors.verticalCenter: parent.verticalCenter
width: root.drawerExtent
width: Math.round(root.revealExtent)
height: root.barSize
clip: true

Row {
id: trayIcons
x: root.drawerExtent - root.revealExtent
x: Math.round(root.revealExtent) - root.drawerExtent
anchors.verticalCenter: parent.verticalCenter
spacing: root.trayItemGap
layer.enabled: true
Expand Down Expand Up @@ -335,16 +333,15 @@ BarWidget {
id: verticalTrayRoot

readonly property int pinnedHeight: pinnedCol.implicitHeight
readonly property int drawerBlockHeight: root.hasDrawer ? expandIcon.implicitHeight + root.drawerExtent : 0
readonly property int drawerBlockHeight: root.hasDrawer ? expandIcon.implicitHeight + Math.round(root.revealExtent) : 0

implicitWidth: root.barSize
implicitHeight: pinnedHeight + drawerBlockHeight

containmentMask: QtObject {
function contains(point: point): bool {
if (point.x < 0 || point.x > verticalTrayRoot.width) return false
var chevronY = root.drawerExtent - root.revealExtent
if (point.y >= chevronY && point.y <= verticalTrayRoot.drawerBlockHeight) return true
if (point.y >= 0 && point.y <= verticalTrayRoot.drawerBlockHeight) return true
var pinnedStart = verticalTrayRoot.drawerBlockHeight
return point.y >= pinnedStart && point.y <= verticalTrayRoot.implicitHeight
}
Expand All @@ -366,7 +363,7 @@ BarWidget {
bar: root.bar
width: implicitWidth
height: implicitHeight
y: root.drawerExtent - root.revealExtent
y: Math.round(root.revealExtent)
text: "\uf053"
textRotation: 90
onPressed: function(button) {
Expand All @@ -376,15 +373,15 @@ BarWidget {

Item {
id: trayClip
y: expandIcon.height
y: 0
anchors.horizontalCenter: parent.horizontalCenter
width: root.barSize
height: root.drawerExtent
height: Math.round(root.revealExtent)
clip: true

Column {
id: trayIcons
y: root.drawerExtent - root.revealExtent
y: Math.round(root.revealExtent) - root.drawerExtent
anchors.horizontalCenter: parent.horizontalCenter
spacing: root.trayItemGap
layer.enabled: true
Expand Down