1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-05-10 06:19:36 -04:00

feat(IPC): Add dbar toggleReveal logic for autohide modes

This commit is contained in:
purian23
2026-05-09 23:49:25 -04:00
parent c6a1473d2f
commit 1ec0311086
5 changed files with 62 additions and 3 deletions

View File

@@ -396,6 +396,10 @@ Top bar visibility control.
- Toggle top bar visibility
- Returns: Success confirmation with current state
**`toggleReveal`**
- Toggle the runtime reveal/tuck state for an autohidden bar
- Returns: Success confirmation with current reveal state
**`status`**
- Get current top bar visibility status
- Returns: "visible" or "hidden"
@@ -403,6 +407,7 @@ Top bar visibility control.
### Examples
```bash
dms ipc call bar toggle
dms ipc call bar toggleReveal index 0
dms ipc call bar hide
dms ipc call bar status
```

View File

@@ -83,6 +83,7 @@ const DMS_ACTIONS = [
{ id: "spawn dms ipc call bar toggle index 0", label: "Bar: Toggle (Primary)" },
{ id: "spawn dms ipc call bar reveal index 0", label: "Bar: Reveal (Primary)" },
{ id: "spawn dms ipc call bar hide index 0", label: "Bar: Hide (Primary)" },
{ id: "spawn dms ipc call bar toggleReveal index 0", label: "Bar: Toggle Autohide Reveal (Primary)" },
{ id: "spawn dms ipc call bar toggleAutoHide index 0", label: "Bar: Toggle Auto-Hide (Primary)" },
{ id: "spawn dms ipc call bar autoHide index 0", label: "Bar: Enable Auto-Hide (Primary)" },
{ id: "spawn dms ipc call bar manualHide index 0", label: "Bar: Disable Auto-Hide (Primary)" },

View File

@@ -721,6 +721,7 @@ Singleton {
property bool displayProfileAutoSelect: false
property bool displayShowDisconnected: false
property bool displaySnapToEdge: true
property var barIpcRevealStates: ({})
property var barConfigs: [
{
@@ -2002,6 +2003,33 @@ Singleton {
return barConfigs.find(cfg => cfg.id === barId) || null;
}
function isBarIpcRevealed(barId) {
if (!barId)
return false;
return !!barIpcRevealStates[barId];
}
function setBarIpcReveal(barId, revealed) {
if (!barId)
return;
const nextRevealed = !!revealed;
if (!!barIpcRevealStates[barId] === nextRevealed)
return;
const states = Object.assign({}, barIpcRevealStates);
if (nextRevealed) {
states[barId] = true;
} else {
delete states[barId];
}
barIpcRevealStates = states;
}
function toggleBarIpcReveal(barId) {
const revealed = !isBarIpcRevealed(barId);
setBarIpcReveal(barId, revealed);
return revealed;
}
function addBarConfig(config) {
const configs = JSON.parse(JSON.stringify(barConfigs));
configs.push(config);
@@ -2017,6 +2045,8 @@ Singleton {
if (index === -1)
return;
const positionChanged = updates.position !== undefined && configs[index].position !== updates.position;
if (updates.autoHide === false || updates.visible === false)
setBarIpcReveal(barId, false);
Object.assign(configs[index], updates);
barConfigs = _sanitizeBarConfigsForConnectedFrame(configs).configs;
@@ -2078,6 +2108,7 @@ Singleton {
delete nextBackups[barId];
connectedFrameBarStyleBackups = nextBackups;
}
setBarIpcReveal(barId, false);
updateBarConfigs();
}

View File

@@ -699,6 +699,26 @@ Item {
return barConfig.autoHide ? "BAR_MANUAL_HIDE_SUCCESS" : "BAR_AUTO_HIDE_SUCCESS";
}
function toggleReveal(selector: string, value: string): string {
const {
barConfig,
error
} = getBarConfig(selector, value);
if (error)
return error;
if (!barConfig.autoHide)
return "BAR_AUTO_HIDE_DISABLED";
if (!(barConfig.visible ?? true)) {
SettingsData.updateBarConfig(barConfig.id, {
visible: true
});
SettingsData.setBarIpcReveal(barConfig.id, true);
return "BAR_REVEAL_SUCCESS";
}
const revealed = SettingsData.toggleBarIpcReveal(barConfig.id);
return revealed ? "BAR_REVEAL_SUCCESS" : "BAR_TUCK_SUCCESS";
}
function getPosition(selector: string, value: string): string {
const {
barConfig,

View File

@@ -810,6 +810,7 @@ PanelWindow {
property bool autoHide: barConfig?.autoHide ?? false
property bool revealSticky: false
readonly property bool ipcReveal: !!SettingsData.barIpcRevealStates[barConfig?.id ?? ""]
Timer {
id: revealHold
@@ -832,14 +833,14 @@ PanelWindow {
const showOnWindowsSetting = barConfig?.showOnWindowsOpen ?? false;
if (showOnWindowsSetting && autoHide && (CompositorService.isNiri || CompositorService.isHyprland)) {
if (barWindow.shouldHideForWindows)
return topBarMouseArea.containsMouse || revealSticky;
return topBarMouseArea.containsMouse || revealSticky || ipcReveal;
return true;
}
if (CompositorService.isNiri && NiriService.inOverview)
return topBarMouseArea.containsMouse || revealSticky;
return topBarMouseArea.containsMouse || revealSticky || ipcReveal;
return (barConfig?.visible ?? true) && (!autoHide || topBarMouseArea.containsMouse || revealSticky);
return (barConfig?.visible ?? true) && (!autoHide || topBarMouseArea.containsMouse || revealSticky || ipcReveal);
}
Connections {
@@ -855,6 +856,7 @@ PanelWindow {
return;
if (topBarMouseArea.containsMouse) {
SettingsData.setBarIpcReveal(barConfig?.id ?? "", false);
revealSticky = true;
revealHold.stop();
return;