Allow setting the panel under the original gnome-shell top bar

This commit is contained in:
Charles Gagnon
2025-02-25 16:23:35 -05:00
parent 5deb078cad
commit 90bc4063a2
5 changed files with 42 additions and 53 deletions

View File

@@ -278,6 +278,9 @@ export const Intellihide = class {
actorData.affectsStruts = !enable
actorData.trackFullscreen = !enable
Main.layoutManager.panelBox.reactive = enable
Main.layoutManager.panelBox.track_hover = enable
this._panelBox.track_hover = enable
this._panelBox.reactive = enable
this._panelBox.visible = enable ? enable : this._panelBox.visible
@@ -409,6 +412,8 @@ export const Intellihide = class {
this._dtpPanel.taskbar.previewMenu.opened ||
this._dtpPanel.taskbar._dragMonitor ||
this._panelBox.get_hover() ||
(this._dtpPanel.geom.position == St.Side.TOP &&
Main.layoutManager.panelBox.get_hover()) ||
this._checkIfGrab()
) {
return true

View File

@@ -30,6 +30,8 @@
import Clutter from 'gi://Clutter'
import GLib from 'gi://GLib'
import GObject from 'gi://GObject'
import Graphene from 'gi://Graphene'
import * as AppIcons from './appIcons.js'
import * as Utils from './utils.js'
import * as Taskbar from './taskbar.js'
@@ -496,6 +498,18 @@ export const Panel = GObject.registerClass(
return position == St.Side.LEFT || position == St.Side.RIGHT
}
getTopOffset() {
let offset = SETTINGS.get_int('panel-top-bottom-margins')
if (
SETTINGS.get_boolean('stockgs-keep-top-panel') &&
this.geom.position == St.Side.TOP
)
offset += Main.layoutManager.panelBox.height
return offset
}
getOrientation() {
return this.checkIfVertical() ? 'vertical' : 'horizontal'
}
@@ -727,7 +741,7 @@ export const Panel = GObject.registerClass(
let dynamic = panelLength == -1 ? Pos.anchorToPosition[anchor] : 0
let dockMode = false
let length = (dynamic ? 100 : panelLength) / 100
let gsTopPanelOffset = 0
let gsTopPanelHeight = 0
let x = 0
let y = 0
let w = 0
@@ -750,7 +764,7 @@ export const Panel = GObject.registerClass(
SETTINGS.get_boolean('stockgs-keep-top-panel') &&
Main.layoutManager.primaryMonitor == this.monitor
) {
gsTopPanelOffset = Main.layoutManager.panelBox.height
gsTopPanelHeight = Main.layoutManager.panelBox.height
}
if (isVertical) {
@@ -766,7 +780,7 @@ export const Panel = GObject.registerClass(
this.varCoord = { c1: 'y1', c2: 'y2' }
w = innerSize
h = this.monitor.height * length - topBottomMargins - gsTopPanelOffset
h = this.monitor.height * length - topBottomMargins - gsTopPanelHeight
dockMode = !!dynamic || topBottomMargins > 0 || h < this.monitor.height
fixedPadding = sidePadding * scaleFactor
varPadding = topBottomPadding * scaleFactor
@@ -784,12 +798,15 @@ export const Panel = GObject.registerClass(
outerSize += topBottomMargins
}
if (position == St.Side.TOP || position == St.Side.LEFT) {
if (position == St.Side.TOP) {
x = this.monitor.x
y = this.monitor.y + gsTopPanelOffset
y = this.monitor.y
} else if (position == St.Side.LEFT) {
x = this.monitor.x
y = this.monitor.y + gsTopPanelHeight
} else if (position == St.Side.RIGHT) {
x = this.monitor.x + this.monitor.width - w - sideMargins
y = this.monitor.y + gsTopPanelOffset
y = this.monitor.y + gsTopPanelHeight
} else {
//BOTTOM
x = this.monitor.x
@@ -1071,7 +1088,7 @@ export const Panel = GObject.registerClass(
sideMargins = sideMargins || SETTINGS.get_int('panel-side-margins')
this.panelBox.set_style(
`padding: ${topBottomMargins}px ${sideMargins}px;`,
`padding: ${this.getTopOffset()}px ${sideMargins}px ${topBottomMargins}px;`,
)
}
@@ -1117,6 +1134,8 @@ export const Panel = GObject.registerClass(
clipContainer.y,
this.panelBox.width,
this.panelBox.height,
0,
this.getTopOffset(),
),
])
}
@@ -1165,16 +1184,12 @@ export const Panel = GObject.registerClass(
if (!dragWindow) return Clutter.EVENT_PROPAGATE
global.display.begin_grab_op(
dragWindow,
dragWindow.begin_grab_op(
Meta.GrabOp.MOVING,
false /* pointer grab */,
true /* frame action */,
button,
event.get_state(),
event.get_device(),
event.get_event_sequence(),
event.get_time(),
stageX,
stageY,
new Graphene.Point({ x: stageX, y: stageY }),
)
return Clutter.EVENT_STOP

View File

@@ -1038,7 +1038,11 @@ function _newLookingGlassResize() {
)
let topOffset =
primaryMonitorPanel.getPosition() == St.Side.TOP
? primaryMonitorPanel.geom.outerSize + 8
? primaryMonitorPanel.geom.outerSize +
(SETTINGS.get_boolean('stockgs-keep-top-panel')
? Main.layoutManager.panelBox.height
: 0) +
8
: 32
this._oldResize()

View File

@@ -282,32 +282,6 @@ const Preferences = class {
)
}
_maybeDisableTopPosition() {
let keepTopPanel = this._settings.get_boolean('stockgs-keep-top-panel')
let monitorSync = this._settings.get_boolean(
'panel-element-positions-monitors-sync',
)
let isPrimary = this.monitors[this._currentMonitorIndex].primary
let topAvailable = !keepTopPanel || (!monitorSync && !isPrimary)
let topButton = this._builder.get_object('position_top_button')
let keepGsPanelAvailable = !(topButton.get_active() && isPrimary)
let keepGsPanelSwitch = this._builder.get_object('stockgs_top_panel_switch')
topButton.set_sensitive(topAvailable)
topButton.set_tooltip_text(
!topAvailable
? _('Unavailable when gnome-shell top panel is present')
: '',
)
keepGsPanelSwitch.set_sensitive(keepGsPanelAvailable)
keepGsPanelSwitch.set_tooltip_text(
keepGsPanelAvailable
? ''
: _('Unavailable when the panel on the primary monitor is at the top'),
)
}
_getPanelPosition(monitorIndex) {
return PanelSettings.getPanelPosition(this._settings, monitorIndex)
}
@@ -323,7 +297,6 @@ const Preferences = class {
PanelSettings.setPanelPosition(this._settings, monitorIndex, position)
})
this._setAnchorLabels(this._currentMonitorIndex)
this._maybeDisableTopPosition()
}
_setPositionRadios(position) {
@@ -413,7 +386,6 @@ const Preferences = class {
*/
_updateWidgetSettingsForMonitor(monitorIndex) {
// Update display of panel screen position setting
this._maybeDisableTopPosition()
const panelPosition = this._getPanelPosition(monitorIndex)
this._setPositionRadios(panelPosition)
@@ -1192,7 +1164,6 @@ const Preferences = class {
this._settings.connect(
'changed::panel-element-positions-monitors-sync',
() => {
this._maybeDisableTopPosition()
// The anchor combo box may has different labels for single- or all-monitor configuration.
this._setAnchorLabels(this._currentMonitorIndex)
},
@@ -3595,12 +3566,6 @@ const Preferences = class {
Gio.SettingsBindFlags.DEFAULT,
)
this._settings.connect('changed::stockgs-keep-top-panel', () =>
this._maybeDisableTopPosition(),
)
this._maybeDisableTopPosition()
this._settings.bind(
'stockgs-panelbtn-click-only',
this._builder.get_object('stockgs_panelbtn_switch'),

View File

@@ -328,8 +328,8 @@ export const getTransformedAllocation = function (actor) {
return { x1: topLeft.x, x2: bottomRight.x, y1: topLeft.y, y2: bottomRight.y }
}
export const setClip = function (actor, x, y, width, height) {
actor.set_clip(0, 0, width, height)
export const setClip = function (actor, x, y, width, height, offsetX, offsetY) {
actor.set_clip(offsetX || 0, offsetY || 0, width, height)
actor.set_position(x, y)
actor.set_size(width, height)
}