From 06fc4baf4e90164a27dda2e5b0603ad6ab96e5a2 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Fri, 11 Apr 2025 17:10:19 +0200 Subject: [PATCH] active window title + workspace fix --- .../quickshell/modules/bar/ActiveWindow.qml | 39 +++++++++++++++++++ .config/quickshell/modules/bar/Bar.qml | 7 ++++ .../quickshell/modules/bar/ClockWidget.qml | 1 - .config/quickshell/modules/bar/Workspaces.qml | 10 ++--- .../quickshell/modules/common/Appearance.qml | 2 + .../modules/common/MprisController.qml | 4 +- .../common/widgets/CircularProgress.qml | 8 ++++ 7 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 .config/quickshell/modules/bar/ActiveWindow.qml diff --git a/.config/quickshell/modules/bar/ActiveWindow.qml b/.config/quickshell/modules/bar/ActiveWindow.qml new file mode 100644 index 000000000..d51381580 --- /dev/null +++ b/.config/quickshell/modules/bar/ActiveWindow.qml @@ -0,0 +1,39 @@ +import "../common" +import "../common/widgets" +import QtQuick +import QtQuick.Layouts +import Quickshell.Wayland +import Quickshell.Hyprland + +Rectangle { + required property var bar + readonly property HyprlandMonitor monitor: Hyprland.monitorFor(bar.screen) + readonly property Toplevel activeWindow: ToplevelManager.activeToplevel + + height: parent.height + width: colLayout.width + color: "transparent" + Layout.leftMargin: Appearance.rounding.screenRounding + + + ColumnLayout { + id: colLayout + + anchors.centerIn: parent + spacing: -4 + + StyledText { + font.pointSize: Appearance.font.pointSize.smaller + color: Appearance.colors.colSubtext + text: activeWindow.activated ? activeWindow?.appId : "Desktop" + } + + StyledText { + font.pointSize: Appearance.font.pointSize.small + color: Appearance.colors.colOnLayer0 + text: activeWindow.activated ? activeWindow?.title : `Workspace ${monitor.activeWorkspace?.id}` + } + + } + +} diff --git a/.config/quickshell/modules/bar/Bar.qml b/.config/quickshell/modules/bar/Bar.qml index 0e7bcabd5..5289f42c8 100644 --- a/.config/quickshell/modules/bar/Bar.qml +++ b/.config/quickshell/modules/bar/Bar.qml @@ -6,6 +6,7 @@ import Quickshell Scope { id: bar + readonly property int barHeight: 40 readonly property int sideCenterModuleWidth: 360 @@ -24,6 +25,12 @@ Scope { // Left section RowLayout { anchors.left: parent.left + implicitHeight: barHeight + + ActiveWindow { + bar: barRoot + } + } // Middle section diff --git a/.config/quickshell/modules/bar/ClockWidget.qml b/.config/quickshell/modules/bar/ClockWidget.qml index d001f1db7..4568bbdcd 100644 --- a/.config/quickshell/modules/bar/ClockWidget.qml +++ b/.config/quickshell/modules/bar/ClockWidget.qml @@ -16,7 +16,6 @@ Rectangle { anchors.centerIn: parent StyledText { - font.family: Appearance.font.family.title font.pointSize: Appearance.font.pointSize.large color: Appearance.colors.colOnLayer1 text: DateTime.time diff --git a/.config/quickshell/modules/bar/Workspaces.qml b/.config/quickshell/modules/bar/Workspaces.qml index 26274d4a3..1fd13c42c 100644 --- a/.config/quickshell/modules/bar/Workspaces.qml +++ b/.config/quickshell/modules/bar/Workspaces.qml @@ -32,9 +32,6 @@ Rectangle { workspaceOccupied = Array.from({ length: ConfigOptions.bar.workspacesShown }, (_, i) => { return Hyprland.workspaces.values.some(ws => ws.id === workspaceGroup * ConfigOptions.bar.workspacesShown + i + 1); }) - if(!activeWindow?.activated) { - workspaceOccupied[(monitor.activeWorkspace?.id - 1) % ConfigOptions.bar.workspacesShown] = false; - } } // Initialize workspaceOccupied when the component is created @@ -48,7 +45,6 @@ Rectangle { } } - Layout.fillHeight: true implicitWidth: rowLayout.implicitWidth + rowLayout.spacing * 2 implicitHeight: 40 @@ -92,8 +88,8 @@ Rectangle { implicitWidth: workspaceButtonWidth implicitHeight: workspaceButtonWidth radius: Appearance.rounding.full - property var radiusLeft: workspaceOccupied[index-1] ? 0 : Appearance.rounding.full - property var radiusRight: workspaceOccupied[index+1] ? 0 : Appearance.rounding.full + property var radiusLeft: (workspaceOccupied[index-1] && !(!activeWindow?.activated && monitor.activeWorkspace?.id === index)) ? 0 : Appearance.rounding.full + property var radiusRight: (workspaceOccupied[index+1] && !(!activeWindow?.activated && monitor.activeWorkspace?.id === index+2)) ? 0 : Appearance.rounding.full topLeftRadius: radiusLeft bottomLeftRadius: radiusLeft @@ -101,7 +97,7 @@ Rectangle { bottomRightRadius: radiusRight color: Appearance.colors.colLayer2 - opacity: workspaceOccupied[index] ? 1 : 0 + opacity: (workspaceOccupied[index] && !(!activeWindow?.activated && monitor.activeWorkspace?.id === index+1)) ? 1 : 0 Behavior on opacity { NumberAnimation { diff --git a/.config/quickshell/modules/common/Appearance.qml b/.config/quickshell/modules/common/Appearance.qml index 404656565..bfff14963 100644 --- a/.config/quickshell/modules/common/Appearance.qml +++ b/.config/quickshell/modules/common/Appearance.qml @@ -95,6 +95,7 @@ Singleton { } colors: QtObject { + property color colSubtext: m3colors.m3outline property color colLayer0: m3colors.m3background property color colOnLayer0: m3colors.m3onBackground property color colLayer0Hover: mix(colLayer0, colOnLayer0, 0.85) @@ -119,6 +120,7 @@ Singleton { property int normal: 17 property int large: 25 property int full: 9999 + property int screenRounding: large } font: QtObject { diff --git a/.config/quickshell/modules/common/MprisController.qml b/.config/quickshell/modules/common/MprisController.qml index 24977f749..590dcd86c 100644 --- a/.config/quickshell/modules/common/MprisController.qml +++ b/.config/quickshell/modules/common/MprisController.qml @@ -60,8 +60,8 @@ Singleton { } function onTrackArtUrlChanged() { - console.log("arturl:", activePlayer.trackArtUrl) - //root.updateTrack(); + // console.log("arturl:", activePlayer.trackArtUrl) + // root.updateTrack(); if (root.activePlayer.uniqueId == root.activeTrack.uniqueId && root.activePlayer.trackArtUrl != root.activeTrack.artUrl) { // cantata likes to send cover updates *BEFORE* updating the track info. // as such, art url changes shouldn't be able to break the reverse animation diff --git a/.config/quickshell/modules/common/widgets/CircularProgress.qml b/.config/quickshell/modules/common/widgets/CircularProgress.qml index 62970f797..73ab50f4b 100644 --- a/.config/quickshell/modules/common/widgets/CircularProgress.qml +++ b/.config/quickshell/modules/common/widgets/CircularProgress.qml @@ -19,6 +19,12 @@ Item { onValueChanged: { canvas.degree = value * 360; } + onPrimaryColorChanged: { + canvas.requestPaint(); + } + onSecondaryColorChanged: { + canvas.requestPaint(); + } Canvas { id: canvas @@ -27,9 +33,11 @@ Item { anchors.fill: parent antialiasing: true + onDegreeChanged: { requestPaint(); } + onPaint: { var ctx = getContext("2d"); var x = root.width / 2;