mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-03 20:32:07 -04:00
dankbar: optimize bindings in bar window
This commit is contained in:
@@ -131,38 +131,55 @@ PanelWindow {
|
|||||||
readonly property real _wingR: Math.max(0, wingtipsRadius)
|
readonly property real _wingR: Math.max(0, wingtipsRadius)
|
||||||
readonly property color _surfaceContainer: Theme.surfaceContainer
|
readonly property color _surfaceContainer: Theme.surfaceContainer
|
||||||
readonly property string _barId: barConfig?.id ?? "default"
|
readonly property string _barId: barConfig?.id ?? "default"
|
||||||
readonly property var _liveBarConfig: SettingsData.barConfigs.find(c => c.id === _barId) || barConfig
|
property real _backgroundAlpha: barConfig?.transparency ?? 1.0
|
||||||
readonly property real _backgroundAlpha: _liveBarConfig?.transparency ?? 1.0
|
|
||||||
readonly property color _bgColor: Theme.withAlpha(_surfaceContainer, _backgroundAlpha)
|
readonly property color _bgColor: Theme.withAlpha(_surfaceContainer, _backgroundAlpha)
|
||||||
|
|
||||||
|
function _updateBackgroundAlpha() {
|
||||||
|
const live = SettingsData.barConfigs.find(c => c.id === _barId);
|
||||||
|
_backgroundAlpha = (live ?? barConfig)?.transparency ?? 1.0;
|
||||||
|
}
|
||||||
readonly property real _dpr: CompositorService.getScreenScale(barWindow.screen)
|
readonly property real _dpr: CompositorService.getScreenScale(barWindow.screen)
|
||||||
|
|
||||||
property string screenName: modelData.name
|
property string screenName: modelData.name
|
||||||
|
|
||||||
readonly property bool hasMaximizedToplevel: {
|
property bool hasMaximizedToplevel: false
|
||||||
if (!(barConfig?.maximizeDetection ?? true))
|
property bool shouldHideForWindows: false
|
||||||
return false;
|
|
||||||
if (!CompositorService.isHyprland && !CompositorService.isNiri)
|
function _updateHasMaximizedToplevel() {
|
||||||
return false;
|
if (!(barConfig?.maximizeDetection ?? true)) {
|
||||||
|
hasMaximizedToplevel = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!CompositorService.isHyprland && !CompositorService.isNiri) {
|
||||||
|
hasMaximizedToplevel = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const filtered = CompositorService.filterCurrentWorkspace(CompositorService.sortedToplevels, screenName);
|
const filtered = CompositorService.filterCurrentWorkspace(CompositorService.sortedToplevels, screenName);
|
||||||
for (let i = 0; i < filtered.length; i++) {
|
for (let i = 0; i < filtered.length; i++) {
|
||||||
if (filtered[i]?.maximized)
|
if (filtered[i]?.maximized) {
|
||||||
return true;
|
hasMaximizedToplevel = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
hasMaximizedToplevel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property bool shouldHideForWindows: {
|
function _updateShouldHideForWindows() {
|
||||||
if (!(barConfig?.showOnWindowsOpen ?? false))
|
if (!(barConfig?.showOnWindowsOpen ?? false)) {
|
||||||
return false;
|
shouldHideForWindows = false;
|
||||||
if (!(barConfig?.autoHide ?? false))
|
return;
|
||||||
return false;
|
}
|
||||||
if (!CompositorService.isNiri && !CompositorService.isHyprland)
|
if (!(barConfig?.autoHide ?? false)) {
|
||||||
return false;
|
shouldHideForWindows = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!CompositorService.isNiri && !CompositorService.isHyprland) {
|
||||||
|
shouldHideForWindows = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (CompositorService.isNiri) {
|
if (CompositorService.isNiri) {
|
||||||
NiriService.windows;
|
|
||||||
|
|
||||||
let currentWorkspaceId = null;
|
let currentWorkspaceId = null;
|
||||||
for (let i = 0; i < NiriService.allWorkspaces.length; i++) {
|
for (let i = 0; i < NiriService.allWorkspaces.length; i++) {
|
||||||
const ws = NiriService.allWorkspaces[i];
|
const ws = NiriService.allWorkspaces[i];
|
||||||
@@ -172,8 +189,10 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentWorkspaceId === null)
|
if (currentWorkspaceId === null) {
|
||||||
return false;
|
shouldHideForWindows = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let hasTiled = false;
|
let hasTiled = false;
|
||||||
let hasFloatingTouchingBar = false;
|
let hasFloatingTouchingBar = false;
|
||||||
@@ -217,14 +236,12 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasTiled)
|
shouldHideForWindows = hasTiled || hasFloatingTouchingBar;
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
return hasFloatingTouchingBar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const filtered = CompositorService.filterCurrentWorkspace(CompositorService.sortedToplevels, screenName);
|
const filtered = CompositorService.filterCurrentWorkspace(CompositorService.sortedToplevels, screenName);
|
||||||
return filtered.length > 0;
|
shouldHideForWindows = filtered.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
property real effectiveSpacing: hasMaximizedToplevel ? 0 : (barConfig?.spacing ?? 4)
|
property real effectiveSpacing: hasMaximizedToplevel ? 0 : (barConfig?.spacing ?? 4)
|
||||||
@@ -356,6 +373,9 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateGpuTempConfig();
|
updateGpuTempConfig();
|
||||||
|
_updateBackgroundAlpha();
|
||||||
|
_updateHasMaximizedToplevel();
|
||||||
|
_updateShouldHideForWindows();
|
||||||
|
|
||||||
inhibitorInitTimer.start();
|
inhibitorInitTimer.start();
|
||||||
}
|
}
|
||||||
@@ -432,11 +452,37 @@ PanelWindow {
|
|||||||
Connections {
|
Connections {
|
||||||
function onBarConfigChanged() {
|
function onBarConfigChanged() {
|
||||||
barWindow.updateGpuTempConfig();
|
barWindow.updateGpuTempConfig();
|
||||||
|
barWindow._updateBackgroundAlpha();
|
||||||
|
barWindow._updateHasMaximizedToplevel();
|
||||||
|
barWindow._updateShouldHideForWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
target: rootWindow
|
target: rootWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: SettingsData
|
||||||
|
function onBarConfigsChanged() {
|
||||||
|
barWindow._updateBackgroundAlpha();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: CompositorService
|
||||||
|
function onToplevelsChanged() {
|
||||||
|
barWindow._updateHasMaximizedToplevel();
|
||||||
|
barWindow._updateShouldHideForWindows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: NiriService
|
||||||
|
function onAllWorkspacesChanged() {
|
||||||
|
barWindow._updateHasMaximizedToplevel();
|
||||||
|
barWindow._updateShouldHideForWindows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
function onNvidiaGpuTempEnabledChanged() {
|
function onNvidiaGpuTempEnabledChanged() {
|
||||||
barWindow.updateGpuTempConfig();
|
barWindow.updateGpuTempConfig();
|
||||||
|
|||||||
Reference in New Issue
Block a user