From 9894866550b74fa73affafb3520fe45e211b25e1 Mon Sep 17 00:00:00 2001 From: Lemmy Date: Wed, 6 May 2026 13:24:55 -0400 Subject: [PATCH] settings: more control on panels attachment --- assets/translations/en.json | 20 ++++++++++++++++++- example.toml | 7 +++++++ src/config/config_overrides.cpp | 5 ++++- src/config/config_service.cpp | 12 +++++++++++ src/config/config_types.h | 4 ++++ src/shell/clipboard/clipboard_panel.cpp | 4 ++++ src/shell/clipboard/clipboard_panel.h | 1 + .../control_center/control_center_panel.cpp | 4 ++++ .../control_center/control_center_panel.h | 2 +- src/shell/launcher/launcher_panel.cpp | 4 ++++ src/shell/launcher/launcher_panel.h | 1 + src/shell/settings/settings_registry.cpp | 16 +++++++++++++++ src/shell/wallpaper/panel/wallpaper_panel.cpp | 4 ++++ src/shell/wallpaper/panel/wallpaper_panel.h | 2 +- 14 files changed, 82 insertions(+), 4 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index d59b172d4..50a60342d 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -721,13 +721,14 @@ "built-in": "Built-in", "clipboard": "Clipboard", "community": "Community", - "control-center": "Control Center", + "control-center": "Control Center:", "directories": "Directories", "effects": "Effects", "focus-styling": "Focus Styling", "general": "General", "grouping": "Grouping", "interface": "Interface", + "launcher": "Launcher", "layout": "Layout", "location": "Location", "media": "Media", @@ -747,6 +748,7 @@ "transition": "Transition", "user": "User", "weather": "Weather", + "wallpaper": "Wallpaper", "widget-list": "Widget List", "widgets": "Widgets" } @@ -1326,6 +1328,22 @@ "overview-shortcuts": { "label": "Overview Shortcuts", "description": "Choose up to six shortcut buttons for the overview tab" + }, + "attach-control-center": { + "label": "Attach to Bar", + "description": "Attach the Control Center panel to the bar when a suitable bar is available" + }, + "attach-launcher": { + "label": "Attach to Bar", + "description": "Attach the Launcher panel to the bar when a suitable bar is available" + }, + "attach-clipboard": { + "label": "Attach to Bar", + "description": "Attach the Clipboard panel to the bar when a suitable bar is available" + }, + "attach-wallpaper": { + "label": "Attach to Bar", + "description": "Attach the Wallpaper panel to the bar when a suitable bar is available" } }, "backdrop": { diff --git a/example.toml b/example.toml index fefe22b2b..de3be7ae4 100644 --- a/example.toml +++ b/example.toml @@ -27,6 +27,13 @@ offset_x = 2 offset_y = 2 # positive = down alpha = 0.55 # multiplied by each component's background opacity +[shell.panel] +background_blur = true # request compositor blur behind panels +attach_launcher = false # attach launcher to the bar when a suitable bar is available +attach_clipboard = false # attach clipboard history to the bar when a suitable bar is available +attach_control_center = true # attach Control Center to the bar when a suitable bar is available +attach_wallpaper = true # attach wallpaper picker to the bar when a suitable bar is available + [shell.mpris] blacklist = [] # ignore MPRIS players by bus/identity/desktop entry token diff --git a/src/config/config_overrides.cpp b/src/config/config_overrides.cpp index 8cdaf3985..5b7ad9a4d 100644 --- a/src/config/config_overrides.cpp +++ b/src/config/config_overrides.cpp @@ -292,7 +292,10 @@ namespace { a.showLocation == b.showLocation && a.clipboardAutoPaste == b.clipboardAutoPaste && a.shadow.blur == b.shadow.blur && a.shadow.offsetX == b.shadow.offsetX && a.shadow.offsetY == b.shadow.offsetY && nearlyEqual(a.shadow.alpha, b.shadow.alpha) && - a.panel.backgroundBlur == b.panel.backgroundBlur && a.screenCorners.enabled == b.screenCorners.enabled && + a.panel.backgroundBlur == b.panel.backgroundBlur && a.panel.attachLauncher == b.panel.attachLauncher && + a.panel.attachClipboard == b.panel.attachClipboard && + a.panel.attachControlCenter == b.panel.attachControlCenter && + a.panel.attachWallpaper == b.panel.attachWallpaper && a.screenCorners.enabled == b.screenCorners.enabled && a.screenCorners.size == b.screenCorners.size && a.mpris.blacklist == b.mpris.blacklist; } diff --git a/src/config/config_service.cpp b/src/config/config_service.cpp index 20928b2da..67c9c0979 100644 --- a/src/config/config_service.cpp +++ b/src/config/config_service.cpp @@ -1186,6 +1186,18 @@ void ConfigService::parseTableInto(const toml::table& tbl, Config& config, bool if (auto v = (*panelTbl)["background_blur"].value()) { shell.panel.backgroundBlur = *v; } + if (auto v = (*panelTbl)["attach_launcher"].value()) { + shell.panel.attachLauncher = *v; + } + if (auto v = (*panelTbl)["attach_clipboard"].value()) { + shell.panel.attachClipboard = *v; + } + if (auto v = (*panelTbl)["attach_control_center"].value()) { + shell.panel.attachControlCenter = *v; + } + if (auto v = (*panelTbl)["attach_wallpaper"].value()) { + shell.panel.attachWallpaper = *v; + } } if (const auto* screenCornersTbl = (*shellTbl)["screen_corners"].as_table()) { if (auto v = (*screenCornersTbl)["enabled"].value()) { diff --git a/src/config/config_types.h b/src/config/config_types.h index 8ea36e945..cf4774e5f 100644 --- a/src/config/config_types.h +++ b/src/config/config_types.h @@ -346,6 +346,10 @@ struct ShellConfig { struct PanelConfig { bool backgroundBlur = true; // request compositor blur behind panels via ext-background-effect-v1 + bool attachLauncher = false; + bool attachClipboard = false; + bool attachControlCenter = true; + bool attachWallpaper = true; bool operator==(const PanelConfig&) const = default; }; diff --git a/src/shell/clipboard/clipboard_panel.cpp b/src/shell/clipboard/clipboard_panel.cpp index 08dbbb17c..c1d051ebb 100644 --- a/src/shell/clipboard/clipboard_panel.cpp +++ b/src/shell/clipboard/clipboard_panel.cpp @@ -364,6 +364,10 @@ ClipboardPanel::ClipboardPanel(ClipboardService* clipboard, ConfigService* confi ClipboardPanel::~ClipboardPanel() = default; +bool ClipboardPanel::prefersAttachedToBar() const noexcept { + return m_config != nullptr && m_config->config().shell.panel.attachClipboard; +} + void ClipboardPanel::setActivateCallback(std::function callback) { m_activateCallback = std::move(callback); } diff --git a/src/shell/clipboard/clipboard_panel.h b/src/shell/clipboard/clipboard_panel.h index 231bd9bf5..04ab9e29c 100644 --- a/src/shell/clipboard/clipboard_panel.h +++ b/src/shell/clipboard/clipboard_panel.h @@ -42,6 +42,7 @@ public: [[nodiscard]] LayerShellLayer layer() const override { return LayerShellLayer::Overlay; } [[nodiscard]] LayerShellKeyboard keyboardMode() const override { return LayerShellKeyboard::Exclusive; } [[nodiscard]] InputArea* initialFocusArea() const override; + [[nodiscard]] bool prefersAttachedToBar() const noexcept override; private: void doLayout(Renderer& renderer, float width, float height) override; diff --git a/src/shell/control_center/control_center_panel.cpp b/src/shell/control_center/control_center_panel.cpp index 393f06c45..46dc70e24 100644 --- a/src/shell/control_center/control_center_panel.cpp +++ b/src/shell/control_center/control_center_panel.cpp @@ -47,6 +47,10 @@ ControlCenterPanel::ControlCenterPanel( m_tabHeaderActions.fill(nullptr); } +bool ControlCenterPanel::prefersAttachedToBar() const noexcept { + return m_config == nullptr || m_config->config().shell.panel.attachControlCenter; +} + bool ControlCenterPanel::dismissTransientUi() { const std::size_t activeIdx = tabIndex(m_activeTab); return m_tabs[activeIdx] != nullptr && m_tabs[activeIdx]->dismissTransientUi(); diff --git a/src/shell/control_center/control_center_panel.h b/src/shell/control_center/control_center_panel.h index 27c06a03a..dd24f198b 100644 --- a/src/shell/control_center/control_center_panel.h +++ b/src/shell/control_center/control_center_panel.h @@ -73,7 +73,7 @@ public: [[nodiscard]] float preferredHeight() const override { return scaled(520.0f); } [[nodiscard]] bool centeredHorizontally() const override { return true; } [[nodiscard]] bool centeredVertically() const override { return true; } - [[nodiscard]] bool prefersAttachedToBar() const noexcept override { return true; } + [[nodiscard]] bool prefersAttachedToBar() const noexcept override; private: void doLayout(Renderer& renderer, float width, float height) override; diff --git a/src/shell/launcher/launcher_panel.cpp b/src/shell/launcher/launcher_panel.cpp index e504e839c..c14d7d798 100644 --- a/src/shell/launcher/launcher_panel.cpp +++ b/src/shell/launcher/launcher_panel.cpp @@ -270,6 +270,10 @@ LauncherPanel::LauncherPanel(ConfigService* config, AsyncTextureCache* asyncText LauncherPanel::~LauncherPanel() = default; +bool LauncherPanel::prefersAttachedToBar() const noexcept { + return m_config != nullptr && m_config->config().shell.panel.attachLauncher; +} + void LauncherPanel::addProvider(std::unique_ptr provider) { provider->initialize(); m_providers.push_back(std::move(provider)); diff --git a/src/shell/launcher/launcher_panel.h b/src/shell/launcher/launcher_panel.h index 9a7075108..8642598ec 100644 --- a/src/shell/launcher/launcher_panel.h +++ b/src/shell/launcher/launcher_panel.h @@ -42,6 +42,7 @@ public: [[nodiscard]] LayerShellLayer layer() const override { return LayerShellLayer::Overlay; } [[nodiscard]] LayerShellKeyboard keyboardMode() const override { return LayerShellKeyboard::Exclusive; } [[nodiscard]] InputArea* initialFocusArea() const override; + [[nodiscard]] bool prefersAttachedToBar() const noexcept override; private: void doLayout(Renderer& renderer, float width, float height) override; diff --git a/src/shell/settings/settings_registry.cpp b/src/shell/settings/settings_registry.cpp index 18e56c078..6615abd28 100644 --- a/src/shell/settings/settings_registry.cpp +++ b/src/shell/settings/settings_registry.cpp @@ -537,6 +537,22 @@ namespace settings { ShortcutListSetting{ .items = cfg.controlCenter.shortcuts, .suggestedOptions = controlCenterShortcutOptions(), .maxItems = 6}, "quick settings shortcuts toggles wifi bluetooth caffeine night light dnd power media weather clipboard")); + entries.push_back(makeEntry("panels", "control-center", tr("settings.schema.panels.attach-control-center.label"), + tr("settings.schema.panels.attach-control-center.description"), + {"shell", "panel", "attach_control_center"}, + ToggleSetting{cfg.shell.panel.attachControlCenter}, "attach bar panel")); + entries.push_back(makeEntry("panels", "launcher", tr("settings.schema.panels.attach-launcher.label"), + tr("settings.schema.panels.attach-launcher.description"), + {"shell", "panel", "attach_launcher"}, ToggleSetting{cfg.shell.panel.attachLauncher}, + "attach bar panel")); + entries.push_back(makeEntry("panels", "clipboard", tr("settings.schema.panels.attach-clipboard.label"), + tr("settings.schema.panels.attach-clipboard.description"), + {"shell", "panel", "attach_clipboard"}, ToggleSetting{cfg.shell.panel.attachClipboard}, + "attach bar panel")); + entries.push_back(makeEntry("panels", "wallpaper", tr("settings.schema.panels.attach-wallpaper.label"), + tr("settings.schema.panels.attach-wallpaper.description"), + {"shell", "panel", "attach_wallpaper"}, ToggleSetting{cfg.shell.panel.attachWallpaper}, + "attach bar panel")); // Desktop entries.push_back(makeEntry("desktop", "widgets", tr("settings.schema.desktop.widgets.label"), diff --git a/src/shell/wallpaper/panel/wallpaper_panel.cpp b/src/shell/wallpaper/panel/wallpaper_panel.cpp index 4bd43310c..a9a9bc6d8 100644 --- a/src/shell/wallpaper/panel/wallpaper_panel.cpp +++ b/src/shell/wallpaper/panel/wallpaper_panel.cpp @@ -119,6 +119,10 @@ WallpaperPanel::WallpaperPanel(WaylandConnection* wayland, ConfigService* config WallpaperPanel::~WallpaperPanel() = default; +bool WallpaperPanel::prefersAttachedToBar() const noexcept { + return m_config == nullptr || m_config->config().shell.panel.attachWallpaper; +} + void WallpaperPanel::create() { const float scale = contentScale(); const auto configureIconButton = [scale](Button* button) { diff --git a/src/shell/wallpaper/panel/wallpaper_panel.h b/src/shell/wallpaper/panel/wallpaper_panel.h index 00deadd46..92eaac030 100644 --- a/src/shell/wallpaper/panel/wallpaper_panel.h +++ b/src/shell/wallpaper/panel/wallpaper_panel.h @@ -39,7 +39,7 @@ public: [[nodiscard]] float preferredHeight() const override { return scaled(700.0f); } [[nodiscard]] bool centeredHorizontally() const override { return true; } [[nodiscard]] bool centeredVertically() const override { return true; } - [[nodiscard]] bool prefersAttachedToBar() const noexcept override { return true; } + [[nodiscard]] bool prefersAttachedToBar() const noexcept override; [[nodiscard]] LayerShellLayer layer() const override { return LayerShellLayer::Overlay; } [[nodiscard]] LayerShellKeyboard keyboardMode() const override { return LayerShellKeyboard::Exclusive; } [[nodiscard]] InputArea* initialFocusArea() const override;