Revert "re-implement auto hiding bars"

This commit is contained in:
Lemmy
2025-12-05 20:34:09 -05:00
committed by GitHub
parent 6480b19e2a
commit ba01e21885
19 changed files with 7 additions and 393 deletions
+2 -241
View File
@@ -13,8 +13,6 @@ import qs.Services.UI
Variants {
model: Quickshell.screens
delegate: Item {
id: screenRoot
required property ShellScreen modelData
property bool shouldBeActive: {
@@ -37,165 +35,6 @@ Variants {
property bool windowLoaded: false
// ============================
// Bar auto-hide state (per screen)
// ============================
// Whether auto-hide is enabled for the bar
property bool barAutoHide: Settings.data.bar.autoHide === true
// Hidden state of the bar content (animated)
property bool barHidden: barAutoHide
// Hover state for bar content and peek window
property bool barHovered: false
property bool barPeekHovered: false
// Keep bar visible while any panel or popup from the bar is open (global)
readonly property bool barHoldOpen: PanelService.hasOpenedPopup || (PanelService.openedPanel && ((PanelService.openedPanel.visible === true) || (PanelService.openedPanel.active === true)))
// Control whether the BarContentWindow is loaded at all
// Start loaded so BarService.registerBar fires
property bool barLoaded: true
// Respect global animation toggle: no delays when animations are disabled
readonly property int barHideDelay: Settings.data.general.animationDisabled ? 0 : 500
readonly property int barShowDelay: Settings.data.general.animationDisabled ? 0 : 120
readonly property int barHideAnimationDuration: Style.animationNormal
readonly property int barShowAnimationDuration: Style.animationNormal
// React when the auto-hide setting changes
Connections {
target: Settings.data.bar
function onAutoHideChanged() {
screenRoot.barAutoHide = Settings.data.bar.autoHide === true;
if (screenRoot.barAutoHide) {
screenRoot.barHidden = true;
barShowTimer.stop();
barHideTimer.stop();
barUnloadTimer.restart();
} else {
screenRoot.barHidden = false;
barShowTimer.stop();
barHideTimer.stop();
barUnloadTimer.stop();
screenRoot.barLoaded = true;
}
}
}
// When hover state changes, manage show/hide timers
onBarHoveredChanged: {
if (!barAutoHide)
return;
if (barHovered) {
barShowTimer.stop();
barHideTimer.stop();
barUnloadTimer.stop();
barLoaded = true;
barHidden = false;
} else if (!barPeekHovered && !barHoldOpen) {
barHideTimer.restart();
}
}
// Timers for reveal/hide
Timer {
id: barShowTimer
interval: screenRoot.barShowDelay
repeat: false
onTriggered: {
screenRoot.barLoaded = true;
screenRoot.barHidden = false;
barUnloadTimer.stop();
}
}
Timer {
id: barHideTimer
interval: screenRoot.barHideDelay
repeat: false
onTriggered: {
if (screenRoot.barAutoHide && !screenRoot.barPeekHovered && !screenRoot.barHovered && !screenRoot.barHoldOpen) {
screenRoot.barHidden = true;
barUnloadTimer.restart();
}
}
}
// After hide animation, unload the window so it doesn't intercept input
Timer {
id: barUnloadTimer
interval: screenRoot.barHideAnimationDuration
repeat: false
onTriggered: {
if (screenRoot.barAutoHide && !screenRoot.barPeekHovered && !screenRoot.barHovered && !screenRoot.barHoldOpen) {
screenRoot.barLoaded = false;
}
}
}
// React to panel / popup lifecycle to keep the bar visible during interactions
Connections {
target: PanelService
// Any panel about to open -> show bar and cancel hides
function onWillOpen() {
if (!screenRoot.barAutoHide)
return;
barShowTimer.stop();
barHideTimer.stop();
screenRoot.barLoaded = true;
screenRoot.barHidden = false;
}
// Popups opening/closing -> start/stop hide timer appropriately
function onPopupChanged() {
if (!screenRoot.barAutoHide)
return;
if (PanelService.hasOpenedPopup) {
barShowTimer.stop();
barHideTimer.stop();
screenRoot.barLoaded = true;
screenRoot.barHidden = false;
} else if (!screenRoot.barHovered && !screenRoot.barPeekHovered && !screenRoot.barHoldOpen) {
barHideTimer.restart();
}
}
// Track when the main panel closes (openedPanel becomes null)
function onOpenedPanelChanged() {
if (!screenRoot.barAutoHide)
return;
if (PanelService.openedPanel !== null) {
barShowTimer.stop();
barHideTimer.stop();
screenRoot.barLoaded = true;
screenRoot.barHidden = false;
} else if (!screenRoot.barHovered && !screenRoot.barPeekHovered && !PanelService.hasOpenedPopup) {
barHideTimer.restart();
}
}
}
// Also listen to the current panel's own visible/active changes
Connections {
target: PanelService.openedPanel
enabled: screenRoot.barAutoHide
function onVisibleChanged() {
if (!PanelService.openedPanel)
return;
if ((PanelService.openedPanel.visible === true) || (PanelService.openedPanel.active === true)) {
barShowTimer.stop();
barHideTimer.stop();
screenRoot.barLoaded = true;
screenRoot.barHidden = false;
} else if (!screenRoot.barHovered && !screenRoot.barPeekHovered && !PanelService.hasOpenedPopup) {
barHideTimer.restart();
}
}
function onActiveChanged() {
onVisibleChanged();
}
}
// Main Screen loader - Bar and panels backgrounds
Loader {
id: windowLoader
@@ -211,101 +50,27 @@ Variants {
sourceComponent: MainScreen {
screen: windowLoader.loaderScreen
autoHideContext: screenRoot
}
}
// Bar content in separate windows to prevent fullscreen redraws
Loader {
id: barWindowLoader
active: {
if (!parent.windowLoaded || !parent.shouldBeActive || !BarService.isVisible)
return false;
// Check if bar is configured for this screen
var monitors = Settings.data.bar.monitors || [];
var allowOnScreen = monitors.length === 0 || monitors.includes(modelData?.name);
if (!allowOnScreen)
return false;
// Only load the bar content window when auto-hide is disabled
// or when the bar is currently marked as loaded
if (parent.barAutoHide && !parent.barLoaded)
return false;
return true;
}
asynchronous: false
sourceComponent: BarContentWindow {
screen: modelData
autoHideContext: screenRoot
}
onLoaded: {
Logger.d("AllScreens", "BarContentWindow created for", modelData?.name);
}
}
// Peek window to reveal the bar when hovering at the screen edge
Loader {
id: barPeekLoader
active: {
if (!parent.windowLoaded || !parent.shouldBeActive || !BarService.isVisible)
return false;
if (!parent.barAutoHide)
return false;
// Check if bar is configured for this screen
var monitors = Settings.data.bar.monitors || [];
return monitors.length === 0 || monitors.includes(modelData?.name);
}
asynchronous: false
sourceComponent: PanelWindow {
id: peekWindow
sourceComponent: BarContentWindow {
screen: modelData
color: Color.transparent
focusable: false
WlrLayershell.namespace: "noctalia-bar-peek-" + (screen?.name || "unknown")
// Do not reserve space; keep as pure overlay so work area never changes
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.exclusionMode: ExclusionMode.Ignore
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
anchors {
top: Settings.data.bar.position === "top"
bottom: Settings.data.bar.position === "bottom"
left: Settings.data.bar.position === "left"
right: Settings.data.bar.position === "right"
}
// 1px reveal strip along the relevant edge
implicitHeight: (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? screen.height : 1
implicitWidth: (Settings.data.bar.position === "top" || Settings.data.bar.position === "bottom") ? screen.width : 1
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: {
screenRoot.barPeekHovered = true;
if (screenRoot.barAutoHide && screenRoot.barHidden) {
barShowTimer.restart();
}
}
onExited: {
screenRoot.barPeekHovered = false;
if (screenRoot.barAutoHide && !screenRoot.barHovered && !screenRoot.barHoldOpen) {
barHideTimer.restart();
}
}
}
}
onLoaded: {
Logger.d("AllScreens", "Bar peek window created for", modelData?.name);
Logger.d("AllScreens", "BarContentWindow created for", modelData?.name);
}
}
@@ -316,10 +81,6 @@ Variants {
if (!parent.windowLoaded || !parent.shouldBeActive || !BarService.isVisible)
return false;
// When auto-hide is enabled, do not create an exclusion zone
if (Settings.data.bar.autoHide === true)
return false;
// Check if bar is configured for this screen
var monitors = Settings.data.bar.monitors || [];
return monitors.length === 0 || monitors.includes(modelData?.name);
-5
View File
@@ -20,10 +20,6 @@ PanelWindow {
// Note: screen property is inherited from PanelWindow and should be set by parent
color: Color.transparent // Transparent - background is in MainScreen below
// Optional auto-hide controller for this screen (provided by AllScreens)
// Exposes shared state such as barHidden and hover flags
property var autoHideContext: null
Component.onCompleted: {
Logger.d("BarContentWindow", "Bar content window created for screen:", barWindow.screen?.name);
}
@@ -64,6 +60,5 @@ PanelWindow {
Bar {
anchors.fill: parent
screen: barWindow.screen
autoHideContext: barWindow.autoHideContext
}
}
+4 -13
View File
@@ -35,10 +35,6 @@ import qs.Services.UI
PanelWindow {
id: root
// Optional auto-hide controller provided by AllScreens per screen
// When set, indicates whether the bar is auto-hidden or visible
property var autoHideContext: null
// Expose panels as readonly property aliases
readonly property alias audioPanel: audioPanel
readonly property alias batteryPanel: batteryPanel
@@ -104,10 +100,6 @@ PanelWindow {
property bool isPanelOpen: (PanelService.openedPanel !== null) && (PanelService.openedPanel.screen === screen)
property bool isPanelClosing: (PanelService.openedPanel !== null) && PanelService.openedPanel.isClosing
// Helper flags for bar visibility from auto-hide context
readonly property bool barAutoHide: autoHideContext ? autoHideContext.barAutoHide : false
readonly property bool barHidden: autoHideContext ? autoHideContext.barHidden : false
color: {
if (dimmerOpacity > 0 && isPanelOpen && !isPanelClosing) {
return Qt.alpha(Color.mShadow, dimmerOpacity);
@@ -159,9 +151,9 @@ PanelWindow {
x: barPlaceholder.x
y: barPlaceholder.y
// Set width/height to 0 if bar shouldn't show on this screen or is auto-hidden
width: (root.barShouldShow && !(root.barAutoHide && root.barHidden)) ? barPlaceholder.width : 0
height: (root.barShouldShow && !(root.barAutoHide && root.barHidden)) ? barPlaceholder.height : 0
// Set width/height to 0 if bar shouldn't show on this screen (makes region empty)
width: root.barShouldShow ? barPlaceholder.width : 0
height: root.barShouldShow ? barPlaceholder.height : 0
intersection: Intersection.Subtract
}
@@ -189,8 +181,7 @@ PanelWindow {
Backgrounds.AllBackgrounds {
id: unifiedBackgrounds
anchors.fill: parent
// Hide bar background when bar is auto-hidden
bar: (root.barAutoHide && root.barHidden) ? null : (barPlaceholder.barItem || null)
bar: barPlaceholder.barItem || null
windowRoot: root
z: 0 // Behind all content
}