Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher, settings, Control Center, dashboard, OSD, lock screen, desktop widgets, plugin host with the vendored Noctalia/Omarchy compatibility layer, helpers, packaging, tests and phase documentation. Includes the optimization work so far: usage widgets and dashboard gauges no longer animate continuously, desktop widgets pause while covered, system controls stop flickering on background polls, dock app matching uses an indexed catalog, and workspace ghosts are created only for occupied slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
99e64a7713
433 files changed
+57792
No files matched your search
@@ -0,0 +1,103 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import "../../../components" as C
|
||||
import "../../../core" as Core
|
||||
import "../../../services" as GS
|
||||
|
||||
// Hosts a Noctalia v4 plugin's Panel.qml as a glassMxrph bar drawer: it grows
|
||||
// out of the bar under the button that opened it, sized from the panel's
|
||||
// contentPreferredWidth/Height. Escape or an outside click closes it.
|
||||
PanelWindow {
|
||||
id: root
|
||||
|
||||
required property var api
|
||||
property url source: ""
|
||||
readonly property bool open: !!api && !!api.panelOpenScreen
|
||||
// Lets test drivers find this panel.
|
||||
Component.onCompleted: GS.PluginService.panelWindows[api.pluginId] = root
|
||||
// Keep the last screen while the drawer animates closed.
|
||||
property var lastScreen: null
|
||||
onOpenChanged: {
|
||||
if (open)
|
||||
lastScreen = api.panelOpenScreen;
|
||||
else
|
||||
GS.PluginService.releasePopout(api);
|
||||
}
|
||||
screen: open ? api.panelOpenScreen : lastScreen
|
||||
|
||||
readonly property Item anchorItem: api && api.panelAnchor ? api.panelAnchor : null
|
||||
readonly property var anchorWindow: anchorItem && anchorItem.QsWindow ? anchorItem.QsWindow.window : null
|
||||
readonly property bool fromBar: !!anchorWindow && GS.TrayService.barWindows.includes(anchorWindow)
|
||||
readonly property real screenW: screen ? screen.width : 1920
|
||||
readonly property real screenH: screen ? screen.height : 1080
|
||||
readonly property real anchorCenter: {
|
||||
root.open;
|
||||
if (!fromBar)
|
||||
return screenW / 2;
|
||||
const p = anchorItem.mapToItem(anchorWindow.contentItem, anchorItem.width / 2, 0);
|
||||
return p.x;
|
||||
}
|
||||
readonly property Item panel: loader.item
|
||||
readonly property var panelObject: loader.item
|
||||
readonly property real preferredWidth: panelObject && panelObject.contentPreferredWidth > 0 ? panelObject.contentPreferredWidth : 400
|
||||
readonly property real preferredHeight: panelObject && panelObject.contentPreferredHeight > 0 ? panelObject.contentPreferredHeight : 320
|
||||
readonly property real drawerX: Core.BarDrawers.clampX(anchorCenter, drawer.width, screenW)
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
}
|
||||
// qmllint disable unqualified unresolved-type
|
||||
margins.left: root.drawerX
|
||||
// qmllint enable unqualified unresolved-type
|
||||
implicitWidth: Math.max(1, Math.round(drawer.width))
|
||||
implicitHeight: Math.max(1, Math.round(Core.BarDrawers.bottom + drawer.contentHeight))
|
||||
visible: open || drawer.shown
|
||||
color: "transparent"
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
WlrLayershell.namespace: "glassMxrph-plugin-panel"
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.keyboardFocus: open ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||
|
||||
MouseArea {
|
||||
x: -20000
|
||||
y: -20000
|
||||
width: 40000
|
||||
height: 40000
|
||||
enabled: root.open
|
||||
onPressed: root.api.closePanel(null)
|
||||
}
|
||||
|
||||
C.BarDrawer {
|
||||
id: drawer
|
||||
objectName: "noctaliaPanelSurface"
|
||||
y: Core.BarDrawers.bottom
|
||||
open: root.open
|
||||
contentWidth: Math.min(root.preferredWidth, root.screenW - 2 * (Core.BarDrawers.margin + Core.BarDrawers.radius + ear))
|
||||
contentHeight: Math.min(root.preferredHeight, root.screenH - Core.BarDrawers.bottom - 20)
|
||||
drawerId: "noctalia-panel-" + (root.api ? root.api.pluginId : "")
|
||||
screenName: root.screen ? root.screen.name : ""
|
||||
screenX: root.drawerX
|
||||
focus: root.open
|
||||
Keys.onEscapePressed: root.api.closePanel(null)
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.AllButtons
|
||||
}
|
||||
Loader {
|
||||
id: loader
|
||||
anchors.fill: parent
|
||||
active: root.open || drawer.shown
|
||||
onActiveChanged: if (active)
|
||||
setSource(root.source, {
|
||||
pluginApi: root.api
|
||||
})
|
||||
onLoaded: {
|
||||
if ("screen" in item)
|
||||
item.screen = Qt.binding(() => root.screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
// glassMxrph implementation of Noctalia v4's per-plugin `pluginApi`: same
|
||||
// properties and functions (settings, translations, panel control), backed by
|
||||
// glassMxrph. Settings persist to settings.json in the plugin's folder, like
|
||||
// in Noctalia; panels open as glassMxrph bar drawers (see PluginService).
|
||||
QtObject {
|
||||
id: api
|
||||
|
||||
required property string pluginId
|
||||
required property string pluginDir
|
||||
property var manifest: ({})
|
||||
property var pluginSettings: ({})
|
||||
|
||||
property var mainInstance: null
|
||||
property var barWidget: null
|
||||
property var desktopWidget: null
|
||||
property var launcherProvider: null
|
||||
property var controlCenterWidget: null
|
||||
|
||||
// The screen the panel is open on (null when closed), and the button it hangs from.
|
||||
property var panelOpenScreen: null
|
||||
property var panelAnchor: null
|
||||
property var ipcHandlers: ({})
|
||||
|
||||
property var pluginTranslations: ({})
|
||||
property var pluginFallbackTranslations: ({})
|
||||
property string currentLanguage: (Qt.locale().name || "en").split("_")[0]
|
||||
property int translationVersion: 0
|
||||
|
||||
// Host callbacks (set by glassMxrph's PluginService).
|
||||
property var _currentScreen: null
|
||||
property var _requestPanel: null
|
||||
|
||||
function nested(obj, path) {
|
||||
let current = obj;
|
||||
for (const key of String(path).split(".")) {
|
||||
if (current === undefined || current === null)
|
||||
return undefined;
|
||||
current = current[key];
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
function saveSettings() {
|
||||
settingsFile.setText(JSON.stringify(api.pluginSettings, null, 2));
|
||||
api.pluginSettings = Object.assign({}, api.pluginSettings);
|
||||
}
|
||||
function openPanel(screen, buttonItem) {
|
||||
api.panelAnchor = buttonItem || api.barWidget || null;
|
||||
api.panelOpenScreen = screen || (api._currentScreen ? api._currentScreen() : Quickshell.screens[0]);
|
||||
if (api._requestPanel)
|
||||
api._requestPanel(api);
|
||||
return true;
|
||||
}
|
||||
function closePanel(screen) {
|
||||
if (!api.panelOpenScreen)
|
||||
return false;
|
||||
api.panelOpenScreen = null;
|
||||
return true;
|
||||
}
|
||||
// Lets glassMxrph's popout coordinator close this panel like any other.
|
||||
function close() {
|
||||
api.closePanel(null);
|
||||
}
|
||||
function togglePanel(screen, buttonItem) {
|
||||
if (api.panelOpenScreen && (!screen || screen === api.panelOpenScreen))
|
||||
return api.closePanel(screen);
|
||||
return api.openPanel(screen, buttonItem);
|
||||
}
|
||||
function openLauncher(screen) {
|
||||
}
|
||||
function closeLauncher(screen) {
|
||||
}
|
||||
function toggleLauncher(screen) {
|
||||
}
|
||||
function withCurrentScreen(callback) {
|
||||
callback(api._currentScreen ? api._currentScreen() : Quickshell.screens[0]);
|
||||
}
|
||||
|
||||
function tr(key, interpolations) {
|
||||
let translation = api.nested(api.pluginTranslations, key);
|
||||
if (typeof translation !== "string")
|
||||
translation = api.nested(api.pluginFallbackTranslations, key);
|
||||
if (typeof translation !== "string")
|
||||
return "!!" + key + "!!";
|
||||
for (const placeholder in (interpolations || {}))
|
||||
translation = translation.replace(new RegExp("\\{" + placeholder + "\\}", "g"), interpolations[placeholder]);
|
||||
return translation;
|
||||
}
|
||||
function trp(key, count, interpolations) {
|
||||
return api.tr(count === 1 ? key : key + "-plural", Object.assign({
|
||||
"count": count
|
||||
}, interpolations || {}));
|
||||
}
|
||||
function hasTranslation(key) {
|
||||
return api.nested(api.pluginTranslations, key) !== undefined || api.nested(api.pluginFallbackTranslations, key) !== undefined;
|
||||
}
|
||||
|
||||
function parse(text) {
|
||||
try {
|
||||
return JSON.parse(text);
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
property FileView settingsFile: FileView {
|
||||
path: api.pluginDir + "/settings.json"
|
||||
blockLoading: true
|
||||
printErrors: false
|
||||
onLoaded: api.pluginSettings = Object.assign({}, (api.manifest.metadata && api.manifest.metadata.defaultSettings) || {}, api.parse(text()))
|
||||
onLoadFailed: api.pluginSettings = Object.assign({}, (api.manifest.metadata && api.manifest.metadata.defaultSettings) || {})
|
||||
}
|
||||
property FileView languageFile: FileView {
|
||||
path: api.pluginDir + "/i18n/" + api.currentLanguage + ".json"
|
||||
blockLoading: true
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
api.pluginTranslations = api.parse(text());
|
||||
api.translationVersion++;
|
||||
}
|
||||
}
|
||||
property FileView fallbackFile: FileView {
|
||||
path: api.pluginDir + "/i18n/en.json"
|
||||
blockLoading: true
|
||||
printErrors: false
|
||||
onLoaded: {
|
||||
api.pluginFallbackTranslations = api.parse(text());
|
||||
api.translationVersion++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user