Include vertical flag in panel geometry

This commit is contained in:
Charles Gagnon
2025-04-13 17:02:08 -04:00
parent ff9ce4df99
commit fa8fabd9a6
9 changed files with 88 additions and 86 deletions

View File

@@ -171,7 +171,7 @@ export const TaskbarAppIcon = GObject.registerClass(
})
this._dtpIconContainer = new St.Widget({
layout_manager: new Clutter.BinLayout(),
style: getIconContainerStyle(panel.checkIfVertical()),
style: getIconContainerStyle(panel.geom.vertical),
})
this.remove_child(this._iconContainer)
@@ -202,7 +202,7 @@ export const TaskbarAppIcon = GObject.registerClass(
this._container.add_child(this._dotsContainer)
this.set_child(this._container)
if (panel.checkIfVertical()) {
if (panel.geom.vertical) {
this.set_width(panel.geom.innerSize)
}
@@ -729,7 +729,7 @@ export const TaskbarAppIcon = GObject.registerClass(
SETTINGS.get_int('group-apps-label-max-width') * scaleFactor
let variableWidth =
!useFixedWidth ||
this.dtpPanel.checkIfVertical() ||
this.dtpPanel.geom.vertical ||
this.dtpPanel.taskbar.fullScrollView
this._windowTitle[maxLabelWidth > 0 ? 'show' : 'hide']()
@@ -809,7 +809,7 @@ export const TaskbarAppIcon = GObject.registerClass(
let bgSvg = '/img/highlight_stacked_bg'
if (pos == DOT_POSITION.LEFT || pos == DOT_POSITION.RIGHT) {
bgSvg += this.dtpPanel.checkIfVertical() ? '_2' : '_3'
bgSvg += this.dtpPanel.geom.vertical ? '_2' : '_3'
}
inlineStyle +=
@@ -858,7 +858,7 @@ export const TaskbarAppIcon = GObject.registerClass(
_setAppIconPadding() {
const padding = getIconPadding(this.dtpPanel)
const margin = SETTINGS.get_int('appicon-margin')
let vertical = this.dtpPanel.checkIfVertical()
let vertical = this.dtpPanel.geom.vertical
this.set_style(
`padding: ${vertical ? margin : 0}px ${vertical ? 0 : margin}px;`,
@@ -2012,7 +2012,7 @@ export function ItemShowLabel() {
let labelWidth = this.label.get_width()
let labelHeight = this.label.get_height()
let position = this._dtpPanel.getPosition()
let position = this._dtpPanel.geom.position
let labelOffset = node.get_length('-x-offset')
// From TaskbarItemContainer
@@ -2180,7 +2180,7 @@ export const ShowAppsIconWrapper = class extends EventEmitter {
setShowAppsPadding() {
let padding = getIconPadding(this.realShowAppsIcon._dtpPanel)
let sidePadding = SETTINGS.get_int('show-apps-icon-side-padding')
let isVertical = this.realShowAppsIcon._dtpPanel.checkIfVertical()
let isVertical = this.realShowAppsIcon._dtpPanel.geom.vertical
this.actor.set_style(
'padding:' +
@@ -2254,7 +2254,7 @@ export const ShowAppsIconWrapper = class extends EventEmitter {
*/
export const MyShowAppsIconMenu = class extends PopupMenu.PopupMenu {
constructor(actor, dtpPanel) {
super(actor, 0, dtpPanel.getPosition())
super(actor, 0, dtpPanel.geom.position)
this._dtpPanel = dtpPanel

View File

@@ -85,7 +85,7 @@ export const Intellihide = class {
this._hoveredOut = false
this._windowOverlap = false
this._translationProp =
'translation_' + (this._dtpPanel.checkIfVertical() ? 'x' : 'y')
'translation_' + (this._dtpPanel.geom.vertical ? 'x' : 'y')
this._panelBox.translation_y = 0
this._panelBox.translation_x = 0
@@ -332,7 +332,7 @@ export const Intellihide = class {
let position = this._dtpPanel.geom.position
let opts = { backend: global.backend }
if (this._dtpPanel.checkIfVertical()) {
if (this._dtpPanel.geom.vertical) {
opts.y1 = this._monitor.y
opts.y2 = this._monitor.y + this._monitor.height
opts.x1 = opts.x2 = this._monitor.x
@@ -391,23 +391,29 @@ export const Intellihide = class {
_pointerIn(x, y, fixedOffset, limitSizeSetting) {
let geom = this._dtpPanel.geom
let position = geom.position
let varCoordY1 = this._monitor.y
let varCoordX1 = this._monitor.x
let varCoordY1 = geom.vertical ? geom.y : this._monitor.y // if vertical, ignore the original GS panel if present
let varOffset = {}
if (geom.dockMode && SETTINGS.get_boolean(limitSizeSetting)) {
let refActor = geom.dynamic
? this._dtpPanel
: this._dtpPanel.clipContainer
let alloc = this._dtpPanel.allocation
varOffset[this._dtpPanel.varCoord.c1] =
refActor.allocation[this._dtpPanel.varCoord.c1]
varOffset[this._dtpPanel.varCoord.c2] =
refActor.allocation[this._dtpPanel.varCoord.c2]
}
// if vertical, ignore the original GS panel if present
if (position == St.Side.LEFT || position == St.Side.RIGHT)
if (!geom.dynamic) {
// when fixed, use the panel clipcontainer which is positioned
// relative to the stage itself
varCoordX1 = geom.x
varCoordY1 = geom.y
varOffset[this._dtpPanel.varCoord.c2] =
alloc[this._dtpPanel.varCoord.c2] - alloc[this._dtpPanel.varCoord.c1]
} else {
// when dynamic, the panel clipcontainer spans the whole monitor edge
// and the panel is positioned relatively to the clipcontainer
varOffset[this._dtpPanel.varCoord.c1] =
alloc[this._dtpPanel.varCoord.c1]
varOffset[this._dtpPanel.varCoord.c2] =
alloc[this._dtpPanel.varCoord.c2]
}
}
return (
((position == St.Side.TOP && y <= this._monitor.y + fixedOffset) ||
@@ -416,8 +422,8 @@ export const Intellihide = class {
(position == St.Side.LEFT && x <= this._monitor.x + fixedOffset) ||
(position == St.Side.RIGHT &&
x >= this._monitor.x + this._monitor.width - fixedOffset)) &&
x >= this._monitor.x + (varOffset.x1 || 0) &&
x < this._monitor.x + (varOffset.x2 || this._monitor.width) &&
x >= varCoordX1 + (varOffset.x1 || 0) &&
x < varCoordX1 + (varOffset.x2 || this._monitor.width) &&
y >= varCoordY1 + (varOffset.y1 || 0) &&
y < varCoordY1 + (varOffset.y2 || this._monitor.height)
)
@@ -511,24 +517,23 @@ export const Intellihide = class {
this._dtpPanel.taskbar._shownInitially = false
}
this._animatePanel(0, immediate)
this._animatePanel(
0,
immediate,
() => (this._dtpPanel.taskbar._shownInitially = true),
)
}
_hidePanel(immediate) {
let position = this._dtpPanel.geom.position
let size =
this._panelBox[
position == St.Side.LEFT || position == St.Side.RIGHT
? 'width'
: 'height'
]
let size = this._panelBox[this._dtpPanel.geom.vertical ? 'width' : 'height']
let coefficient =
position == St.Side.TOP || position == St.Side.LEFT ? -1 : 1
this._animatePanel(size * coefficient, immediate)
}
_animatePanel(destination, immediate) {
_animatePanel(destination, immediate, onComplete) {
if (destination === this._animationDestination) return
Utils.stopAnimations(this._panelBox)
@@ -566,6 +571,7 @@ export const Intellihide = class {
transition: 'easeOutQuad',
onComplete: () => {
this._panelBox.visible = !destination
onComplete ? onComplete() : null
update()
},
}

View File

@@ -121,7 +121,7 @@ export const Overview = class {
let { transitioning, finalState, progress } =
overviewControls._stateAdjustment.getStateTransitionParams()
let size =
focusedPanel.geom[focusedPanel.checkIfVertical() ? 'w' : 'h'] *
focusedPanel.geom[focusedPanel.geom.vertical ? 'w' : 'h'] *
(transitioning
? Math.abs((finalState != 0 ? 0 : 1) - progress)
: 1)

View File

@@ -357,7 +357,7 @@ export const Panel = GObject.registerClass(
this.panelStyle.enable(this)
if (this.checkIfVertical()) {
if (this.geom.vertical) {
this._signalsHandler.add([
this.panelBox,
'notify::visible',
@@ -527,13 +527,11 @@ export const Panel = GObject.registerClass(
}
checkIfVertical() {
let position = this.getPosition()
return position == St.Side.LEFT || position == St.Side.RIGHT
return this.geom.vertical
}
getOrientation() {
return this.checkIfVertical() ? 'vertical' : 'horizontal'
return this.geom.vertical ? 'vertical' : 'horizontal'
}
updateElementPositions() {
@@ -614,7 +612,7 @@ export const Panel = GObject.registerClass(
}
_bindSettingsChanges() {
let isVertical = this.checkIfVertical()
let isVertical = this.geom.vertical
this._signalsHandler.add(
[
@@ -732,7 +730,7 @@ export const Panel = GObject.registerClass(
this.taskbar.resetAppIcons(true)
this.dynamicTransparency.updateExternalStyle()
if (this.checkIfVertical()) {
if (this.geom.vertical) {
this.showAppsIconWrapper.realShowAppsIcon.toggleButton.set_width(
this.geom.innerSize,
)
@@ -741,7 +739,8 @@ export const Panel = GObject.registerClass(
}
getGeometry() {
let isVertical = this.checkIfVertical()
let position = this.getPosition()
let vertical = position == St.Side.LEFT || position == St.Side.RIGHT
let scaleFactor = Utils.getScaleFactor()
let panelBoxTheme = this.panelBox.get_theme_node()
let sideMargins =
@@ -752,7 +751,6 @@ export const Panel = GObject.registerClass(
panelBoxTheme.get_padding(St.Side.BOTTOM)
let sidePadding = SETTINGS.get_int('panel-side-padding')
let topBottomPadding = SETTINGS.get_int('panel-top-bottom-padding')
let position = this.getPosition()
let panelLength = PanelSettings.getPanelLength(
SETTINGS,
this.monitor.index,
@@ -774,9 +772,9 @@ export const Panel = GObject.registerClass(
let outerSize = 0
let panelSize = PanelSettings.getPanelSize(SETTINGS, this.monitor.index)
if (isVertical && panelSize - sidePadding * 2 < MIN_PANEL_SIZE)
if (vertical && panelSize - sidePadding * 2 < MIN_PANEL_SIZE)
sidePadding = (panelSize - MIN_PANEL_SIZE) * 0.5
else if (!isVertical && panelSize - topBottomPadding * 2 < MIN_PANEL_SIZE)
else if (!vertical && panelSize - topBottomPadding * 2 < MIN_PANEL_SIZE)
topBottomPadding = (panelSize - MIN_PANEL_SIZE) * 0.5
iconSize = innerSize = outerSize = panelSize * scaleFactor
@@ -789,7 +787,7 @@ export const Panel = GObject.registerClass(
topOffset = position == St.Side.TOP ? gsTopPanelHeight : 0
}
if (isVertical) {
if (vertical) {
if (!SETTINGS.get_boolean('group-apps')) {
// add window title width and side padding of _dtpIconContainer when vertical
innerSize = outerSize +=
@@ -837,13 +835,13 @@ export const Panel = GObject.registerClass(
if (length < 1) {
// fixed size, less than 100%, so adjust start coordinate
if (!isVertical && anchor == Pos.MIDDLE)
if (!vertical && anchor == Pos.MIDDLE)
x += (this.monitor.width - w - sideMargins) * 0.5
else if (isVertical && anchor == Pos.MIDDLE)
else if (vertical && anchor == Pos.MIDDLE)
y += (this.monitor.height - h - topBottomMargins) * 0.5
else if (!isVertical && anchor == Pos.END)
else if (!vertical && anchor == Pos.END)
x += this.monitor.width - w - sideMargins
else if (isVertical && anchor == Pos.END)
else if (vertical && anchor == Pos.END)
y += this.monitor.height - h - topBottomMargins
}
@@ -862,6 +860,7 @@ export const Panel = GObject.registerClass(
varPadding,
topOffset, // only if gnome-shell top panel is present and position is TOP
position,
vertical,
dynamic,
dockMode,
}
@@ -1128,7 +1127,7 @@ export const Panel = GObject.registerClass(
this.set_size(this.geom.w, this.geom.h)
this.clipContainer.set_position(this.geom.x, this.geom.y)
this._setVertical(this.panel, this.checkIfVertical())
this._setVertical(this.panel, this.geom.vertical)
// center the system menu popup relative to its panel button
if (this.statusArea.quickSettings?.menu) {
@@ -1157,7 +1156,7 @@ export const Panel = GObject.registerClass(
T7,
0,
() => {
let vertical = this.checkIfVertical()
let vertical = this.geom.vertical
let w = vertical ? this.geom.outerSize : this.geom.w
let h = vertical ? this.geom.h : this.geom.outerSize
@@ -1208,7 +1207,7 @@ export const Panel = GObject.registerClass(
}
}
let params = this.checkIfVertical()
let params = this.geom.vertical
? [stageY, 'y', 'height']
: [stageX, 'x', 'width']
let dragWindow = this._getDraggableWindowForPosition.apply(
@@ -1255,7 +1254,7 @@ export const Panel = GObject.registerClass(
}
_onBoxActorAdded(box) {
if (this.checkIfVertical()) {
if (this.geom.vertical) {
this._setVertical(box, true)
}
}
@@ -1458,7 +1457,7 @@ export const Panel = GObject.registerClass(
if (this._showDesktopButton) {
let buttonSize = SETTINGS.get_int('showdesktop-button-width') + 'px;'
let isVertical = this.checkIfVertical()
let isVertical = this.geom.vertical
let sytle = 'border: 0 solid ' + rgb + ';'
sytle += isVertical

View File

@@ -297,7 +297,7 @@ export const PanelManager = class {
this._adjustPanelMenuButton(
this._getPanelMenuButton(child.get_first_child()),
this.primaryPanel.monitor,
this.primaryPanel.getPosition(),
this.primaryPanel.geom.position,
)
},
]),
@@ -699,11 +699,10 @@ export const PanelManager = class {
panelBox._dtpIndex = monitor.index
panelBox.set_position(0, 0)
if (panel.checkIfVertical) panelBox.set_width(-1)
panelBox.set_width(-1)
this._findPanelMenuButtons(panelBox).forEach((pmb) =>
this._adjustPanelMenuButton(pmb, monitor, panel.getPosition()),
this._adjustPanelMenuButton(pmb, monitor, panel.geom.position),
)
panel.taskbar.iconAnimator.start()
@@ -947,7 +946,7 @@ function newUpdateHotCorners() {
global.dashToPanel.panels,
(p) => p.monitor.index == i,
)
let panelPosition = panel ? panel.getPosition() : St.Side.BOTTOM
let panelPosition = panel ? panel.geom.position : St.Side.BOTTOM
let panelTopLeft =
panelPosition == St.Side.TOP || panelPosition == St.Side.LEFT
let monitor = this.monitors[i]
@@ -1036,7 +1035,7 @@ function newUpdatePanelBarrier(panel) {
let fixed1 = panel.monitor.y
let fixed2 = panel.monitor.y + barrierSize
if (panel.checkIfVertical()) {
if (panel.geom.vertical) {
barriers._rightPanelBarrier.push(
panel.monitor.y + panel.monitor.height,
Meta.BarrierDirection.NEGATIVE_Y,
@@ -1056,7 +1055,7 @@ function newUpdatePanelBarrier(panel) {
)
}
switch (panel.getPosition()) {
switch (panel.geom.position) {
//values are initialized as St.Side.TOP
case St.Side.BOTTOM:
fixed1 = panel.monitor.y + panel.monitor.height - barrierSize
@@ -1107,7 +1106,7 @@ function _newLookingGlassResize() {
(p) => p.monitor == Main.layoutManager.primaryMonitor,
)
let topOffset =
primaryMonitorPanel.getPosition() == St.Side.TOP
primaryMonitorPanel.geom.position == St.Side.TOP
? primaryMonitorPanel.geom.outerSize +
(SETTINGS.get_boolean('stockgs-keep-top-panel')
? Main.layoutManager.panelBox.height

View File

@@ -66,7 +66,7 @@ export const PanelStyle = class {
this._rightBoxOperations = []
let trayPadding = SETTINGS.get_int('tray-padding')
let isVertical = this.panel.checkIfVertical()
let isVertical = this.panel.geom.vertical
let paddingStyle = 'padding: ' + (isVertical ? '%dpx 0' : '0 %dpx')
if (trayPadding >= 0) {

View File

@@ -246,7 +246,7 @@ export const Taskbar = class extends EventEmitter {
this._labelShowing = false
this.fullScrollView = 0
let isVertical = panel.checkIfVertical()
let isVertical = panel.geom.vertical
this._box = Utils.createBoxLayout({
vertical: isVertical,
@@ -471,7 +471,7 @@ export const Taskbar = class extends EventEmitter {
_updateIconAnimations(pointerX, pointerY) {
this._iconAnimationTimestamp = Date.now()
let type = iconAnimationSettings.type
let vertical = this.dtpPanel.checkIfVertical()
let vertical = this.dtpPanel.geom.vertical
if (!pointerX || !pointerY) [pointerX, pointerY] = global.get_pointer()
@@ -602,7 +602,7 @@ export const Taskbar = class extends EventEmitter {
// force a fixed label width to prevent the icons from "wiggling" when an animation runs
// (adding or removing an icon). When the taskbar is full, revert to a dynamic label width
// to allow them to resize and make room for new icons.
if (!this.dtpPanel.checkIfVertical() && !this.isGroupApps) {
if (!this.dtpPanel.geom.vertical && !this.isGroupApps) {
let initial = this.fullScrollView
if (
@@ -1270,7 +1270,7 @@ export const Taskbar = class extends EventEmitter {
if (!this._settings.is_writable('favorite-apps'))
return DND.DragMotionResult.NO_DROP
let isVertical = this.dtpPanel.checkIfVertical()
let isVertical = this.dtpPanel.geom.vertical
if (!this._box.contains(source) && !source._dashItemContainer) {
//not an appIcon of the taskbar, probably from the applications view
@@ -1625,7 +1625,7 @@ export const TaskbarItemContainer = GObject.registerClass(
this._updateCloneContainerPosition(cloneContainer)
// For the stretch animation
let boundProperty = this._dtpPanel.checkIfVertical()
let boundProperty = this._dtpPanel.geom.vertical
? 'translation_y'
: 'translation_x'
this.bind_property(
@@ -1637,7 +1637,7 @@ export const TaskbarItemContainer = GObject.registerClass(
// The clone follows its source when the taskbar is scrolled.
let taskbarScrollView = this.get_parent().get_parent()
let adjustment = this._dtpPanel.checkIfVertical()
let adjustment = this._dtpPanel.geom.vertical
? taskbarScrollView.get_vadjustment()
: taskbarScrollView.get_hadjustment()
let adjustmentChangedId = adjustment.connect('notify::value', () =>
@@ -1675,7 +1675,7 @@ export const TaskbarItemContainer = GObject.registerClass(
else if (level) this._createRaisedClone()
else return
let panelPosition = this._dtpPanel.getPosition()
let panelPosition = this._dtpPanel.geom.position
let panelElementPositions = PanelSettings.getPanelElementPositions(
SETTINGS,
this._dtpPanel.monitor.index,
@@ -1747,7 +1747,7 @@ export const TaskbarItemContainer = GObject.registerClass(
stretch(translation) {
let duration = iconAnimationSettings.duration / 1000
let zoom = iconAnimationSettings.zoom
let animatedProperty = this._dtpPanel.checkIfVertical()
let animatedProperty = this._dtpPanel.geom.vertical
? 'translation_y'
: 'translation_x'
let isShowing = this.opacity != 255 || this.child.opacity != 255

View File

@@ -103,7 +103,7 @@ export const DynamicTransparency = class {
this._proximityManager.removeWatch(this._proximityWatchId)
if (SETTINGS.get_boolean('trans-use-dynamic-opacity')) {
let isVertical = this._dtpPanel.checkIfVertical()
let isVertical = this._dtpPanel.geom.vertical
let threshold = SETTINGS.get_int('trans-dynamic-distance')
this._windowOverlap = false
@@ -179,7 +179,7 @@ export const DynamicTransparency = class {
if (SETTINGS.get_boolean('trans-use-custom-gradient')) {
this._gradientStyle +=
'background-gradient-direction: ' +
(this._dtpPanel.checkIfVertical() ? 'horizontal;' : 'vertical;') +
(this._dtpPanel.geom.vertical ? 'horizontal;' : 'vertical;') +
'background-gradient-start: ' +
Utils.getrgbaColor(
SETTINGS.get_string('trans-gradient-top-color'),

View File

@@ -73,9 +73,7 @@ export const PreviewMenu = GObject.registerClass(
this.allowCloseWindow = true
this.peekInitialWorkspaceIndex = -1
this.opened = false
this.isVertical =
geom.position == St.Side.LEFT || geom.position == St.Side.RIGHT
this._translationProp = 'translation_' + (this.isVertical ? 'x' : 'y')
this._translationProp = 'translation_' + (geom.vertical ? 'x' : 'y')
this._translationDirection =
geom.position == St.Side.TOP || geom.position == St.Side.LEFT ? -1 : 1
this._translationOffset =
@@ -94,13 +92,13 @@ export const PreviewMenu = GObject.registerClass(
y_align:
Clutter.ActorAlign[geom.position != St.Side.BOTTOM ? 'START' : 'END'],
})
this._box = Utils.createBoxLayout({ vertical: this.isVertical })
this._box = Utils.createBoxLayout({ vertical: geom.vertical })
this._scrollView = new St.ScrollView({
name: 'dashtopanelPreviewScrollview',
hscrollbar_policy: St.PolicyType.NEVER,
vscrollbar_policy: St.PolicyType.NEVER,
enable_mouse_scrolling: true,
y_expand: !this.isVertical,
y_expand: !geom.vertical,
})
this._scrollView.add_child(this._box)
@@ -429,7 +427,7 @@ export const PreviewMenu = GObject.registerClass(
_onScrollEvent(actor, event) {
if (!event.is_pointer_emulated()) {
let vOrh = this.isVertical ? 'v' : 'h'
let vOrh = this.panel.geom.vertical ? 'v' : 'h'
let adjustment = this._scrollView[`${vOrh}adjustment`]
let increment = adjustment.step_increment
let delta = increment
@@ -496,7 +494,7 @@ export const PreviewMenu = GObject.registerClass(
SETTINGS.get_int('window-preview-padding') * 2) *
scaleFactor
if (this.isVertical) {
if (this.panel.geom.vertical) {
w = previewSize
this.clipHeight = this.panel.monitor.height
y = this.panel.monitor.y
@@ -555,7 +553,7 @@ export const PreviewMenu = GObject.registerClass(
previewsHeight < this.panel.monitor.height,
)
if (this.isVertical) {
if (this.panel.geom.vertical) {
y =
sourceAllocation.y1 +
appIconMargin -
@@ -615,7 +613,7 @@ export const PreviewMenu = GObject.registerClass(
_getScrollAdjustmentValues() {
let [value, , upper, , , pageSize] =
this._scrollView[
(this.isVertical ? 'v' : 'h') + 'adjustment'
(this.panel.geom.vertical ? 'v' : 'h') + 'adjustment'
].get_values()
return [value, upper, pageSize]
@@ -640,7 +638,7 @@ export const PreviewMenu = GObject.registerClass(
'background-gradient-direction:' +
this.panel.getOrientation()
if (this.isVertical) {
if (this.panel.geom.vertical) {
y = end ? this.panel.monitor.height - FADE_SIZE : 0
} else {
x = end ? this.panel.monitor.width - FADE_SIZE : 0
@@ -653,8 +651,8 @@ export const PreviewMenu = GObject.registerClass(
style: fadeStyle,
x: x,
y: y,
width: this.isVertical ? this.width : FADE_SIZE,
height: this.isVertical ? FADE_SIZE : this.height,
width: this.panel.geom.vertical ? this.width : FADE_SIZE,
height: this.panel.geom.vertical ? FADE_SIZE : this.height,
})
return fadeWidget
@@ -668,7 +666,7 @@ export const PreviewMenu = GObject.registerClass(
if (!c.animatingOut) {
let [width, height] = c.getSize()
if (this.isVertical) {
if (this.panel.geom.vertical) {
previewsWidth = Math.max(width, previewsWidth)
previewsHeight += height
} else {