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,227 @@
|
||||
import QtQuick
|
||||
import QtTest
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Networking
|
||||
import Quickshell.Bluetooth
|
||||
import "../core"
|
||||
import "../services"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
parent: ShellState.controlCenterWindow ? ShellState.controlCenterWindow.contentItem : null
|
||||
TestCase {
|
||||
id: input
|
||||
name: "ControlInput"
|
||||
when: false
|
||||
}
|
||||
property QtObject audioNode: QtObject {
|
||||
property string name: "fixture-output"
|
||||
property string description: "Fixture audio"
|
||||
property bool isSink: true
|
||||
property bool isStream: false
|
||||
property QtObject audio: QtObject {
|
||||
property real volume: 0.4
|
||||
property bool muted: false
|
||||
}
|
||||
}
|
||||
property QtObject audioInput: QtObject {
|
||||
property string name: "fixture-input"
|
||||
property string description: "Fixture microphone"
|
||||
property bool isSink: false
|
||||
property bool isStream: false
|
||||
property QtObject audio: QtObject {
|
||||
property real volume: 0.6
|
||||
property bool muted: false
|
||||
}
|
||||
}
|
||||
property QtObject audioBackend: QtObject {
|
||||
property bool ready: true
|
||||
property var defaultAudioSink: root.audioNode
|
||||
property var defaultAudioSource: root.audioInput
|
||||
property var preferredDefaultAudioSink: root.audioNode
|
||||
property var preferredDefaultAudioSource: root.audioInput
|
||||
property QtObject nodes: QtObject {
|
||||
property var values: [root.audioNode, root.audioInput]
|
||||
}
|
||||
}
|
||||
property QtObject wifi: QtObject {
|
||||
id: fixtureWifi
|
||||
property int type: DeviceType.Wifi
|
||||
property string name: "fixture-wifi"
|
||||
property bool connected: fixtureNetwork.connected
|
||||
property bool scannerEnabled: false
|
||||
property QtObject networks: QtObject {
|
||||
property var values: [root.network]
|
||||
}
|
||||
}
|
||||
property QtObject network: QtObject {
|
||||
id: fixtureNetwork
|
||||
property string name: "Fixture network"
|
||||
property var device: root.wifi
|
||||
property bool known: true
|
||||
property bool connected: false
|
||||
property int state: ConnectionState.Disconnected
|
||||
property bool stateChanging: false
|
||||
property int security: WifiSecurityType.Wpa2Psk
|
||||
signal connectionFailed(int reason)
|
||||
function connect() {
|
||||
connected = true;
|
||||
state = ConnectionState.Connected;
|
||||
}
|
||||
function disconnect() {
|
||||
connected = false;
|
||||
state = ConnectionState.Disconnected;
|
||||
}
|
||||
function connectWithPsk(password) {
|
||||
connect();
|
||||
}
|
||||
}
|
||||
property QtObject networkBackend: QtObject {
|
||||
property int backend: NetworkBackendType.NetworkManager
|
||||
property bool wifiEnabled: true
|
||||
property bool wifiHardwareEnabled: true
|
||||
property QtObject devices: QtObject {
|
||||
property var values: [root.wifi]
|
||||
}
|
||||
}
|
||||
property QtObject btDevice: QtObject {
|
||||
property string name: "Fixture headphones"
|
||||
property bool connected: false
|
||||
property bool paired: true
|
||||
property int state: BluetoothDeviceState.Disconnected
|
||||
property bool batteryAvailable: true
|
||||
property real battery: 0.8
|
||||
function connect() {
|
||||
connected = true;
|
||||
state = BluetoothDeviceState.Connected;
|
||||
}
|
||||
function disconnect() {
|
||||
connected = false;
|
||||
state = BluetoothDeviceState.Disconnected;
|
||||
}
|
||||
}
|
||||
property QtObject btAdapter: QtObject {
|
||||
property string name: "Fixture Bluetooth"
|
||||
property string adapterId: "fixture"
|
||||
property bool enabled: true
|
||||
property int state: BluetoothAdapterState.Enabled
|
||||
property QtObject devices: QtObject {
|
||||
property var values: [root.btDevice]
|
||||
}
|
||||
}
|
||||
property QtObject btBackend: QtObject {
|
||||
property var defaultAdapter: root.btAdapter
|
||||
property QtObject adapters: QtObject {
|
||||
property var values: [root.btAdapter]
|
||||
}
|
||||
}
|
||||
function child(name) {
|
||||
return input.findChild(ShellState.controlCenterWindow.contentItem, name);
|
||||
}
|
||||
function reveal(item) {
|
||||
let parent = item.parent;
|
||||
while (parent) {
|
||||
if (parent.contentY !== undefined && parent.contentItem && parent.contentHeight > parent.height) {
|
||||
const pos = item.mapToItem(parent.contentItem, 0, 0);
|
||||
parent.contentY = Math.max(0, Math.min(parent.contentHeight - parent.height, pos.y - parent.height / 2));
|
||||
}
|
||||
parent = parent.parent;
|
||||
}
|
||||
input.wait(40);
|
||||
}
|
||||
IpcHandler {
|
||||
target: "controlTest"
|
||||
function inject(): bool {
|
||||
if (SystemService.busy)
|
||||
return false;
|
||||
AudioService.backend = root.audioBackend;
|
||||
NetworkService.backend = root.networkBackend;
|
||||
BluetoothService.backend = root.btBackend;
|
||||
SystemService.helper = "testing/recording_system.py";
|
||||
SystemService.refresh();
|
||||
return true;
|
||||
}
|
||||
function click(name: string): bool {
|
||||
const item = root.child(name);
|
||||
if (!item || !item.enabled)
|
||||
return false;
|
||||
root.reveal(item);
|
||||
input.mouseClick(item, item.width / 2, item.height / 2);
|
||||
return true;
|
||||
}
|
||||
function slider(name: string): bool {
|
||||
const item = root.child(name);
|
||||
if (!item || !item.enabled)
|
||||
return false;
|
||||
root.reveal(item);
|
||||
input.mouseClick(item, item.width * .75, item.height / 2);
|
||||
return true;
|
||||
}
|
||||
function clickSystem(): bool {
|
||||
const pill = ShellState.systemPills.find(p => p.barScreen === ScreenService.active) || ShellState.systemPills[0];
|
||||
if (!pill)
|
||||
return false;
|
||||
input.mouseClick(pill, pill.width / 2, pill.height / 2);
|
||||
return true;
|
||||
}
|
||||
function settingsClick(name: string): bool {
|
||||
const item = input.findChild(ShellState.settingsWindow.contentItem, name);
|
||||
if (!item || !item.enabled)
|
||||
return false;
|
||||
root.reveal(item);
|
||||
input.mouseClick(item, item.width / 2, item.height / 2);
|
||||
return true;
|
||||
}
|
||||
function value(name: string): real {
|
||||
const item = root.child(name);
|
||||
return item ? item.value : -1;
|
||||
}
|
||||
function checked(name: string): bool {
|
||||
const item = root.child(name);
|
||||
return item ? item.checked : false;
|
||||
}
|
||||
function pressEscape(): void {
|
||||
input.keyClick(Qt.Key_Escape);
|
||||
}
|
||||
function outside(): void {
|
||||
// Outside the panel-sized surface, as Hyprland delivers it.
|
||||
input.mouseClick(ShellState.controlCenterWindow.contentItem, -40, ShellState.controlCenterWindow.height / 2);
|
||||
}
|
||||
function screenshot(path: string): bool {
|
||||
return root.child("controlCenterSurface").grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
function snapshot(): string {
|
||||
const panel = root.child("controlCenterSurface");
|
||||
return JSON.stringify({
|
||||
settingsVisible: ShellState.settingsWindow.visible,
|
||||
modules: ConfigService.data.controlCenter.modules,
|
||||
windowVisible: ShellState.controlCenterWindow.visible,
|
||||
panelVisible: panel.visible,
|
||||
panelOpacity: panel.opacity,
|
||||
opened: ShellState.controlCenterOpen,
|
||||
state: SystemService.state,
|
||||
error: SystemService.error,
|
||||
busy: SystemService.busy,
|
||||
power: PowerService.pending,
|
||||
wifi: NetworkService.enabled,
|
||||
bluetooth: BluetoothService.enabled,
|
||||
volume: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio.volume : -1,
|
||||
muted: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio.muted : false,
|
||||
microphone: AudioService.source && AudioService.source.audio ? AudioService.source.audio.muted : false,
|
||||
scan: fixtureWifi.scannerEnabled,
|
||||
active: ScreenService.active.name,
|
||||
screens: Quickshell.screens.map(s => s.name),
|
||||
x: ShellState.controlCenterWindow.panelScreenX,
|
||||
y: ShellState.controlCenterWindow.panelScreenY,
|
||||
width: panel.width,
|
||||
height: panel.height,
|
||||
screenWidth: ShellState.controlCenterWindow.screenWidth,
|
||||
screenHeight: ShellState.controlCenterWindow.screenHeight
|
||||
});
|
||||
}
|
||||
function connectFixtures(): bool {
|
||||
return NetworkService.connectNetwork(root.network, "") && BluetoothService.connectDevice(root.btDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import QtQuick
|
||||
import QtTest
|
||||
import Quickshell.Io
|
||||
import "../core"
|
||||
|
||||
// Test hooks for the dashboard: screenshots, named clicks and key presses.
|
||||
Item {
|
||||
id: root
|
||||
parent: ShellState.dashboardWindow ? ShellState.dashboardWindow.contentItem : null
|
||||
TestCase {
|
||||
id: input
|
||||
name: "DashboardDriver"
|
||||
when: false
|
||||
}
|
||||
function find(name) {
|
||||
return ShellState.dashboardWindow ? input.findChild(ShellState.dashboardWindow.contentItem, name) : null;
|
||||
}
|
||||
IpcHandler {
|
||||
target: "dashboardTest"
|
||||
function screenshot(path: string): bool {
|
||||
const surface = root.find("dashboardSurface");
|
||||
return !!surface && surface.grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
function click(name: string): bool {
|
||||
const item = root.find(name);
|
||||
if (!item || !item.visible)
|
||||
return false;
|
||||
input.mouseClick(item, item.width / 2, item.height / 2);
|
||||
return true;
|
||||
}
|
||||
function key(key: int): void {
|
||||
input.keyClick(key);
|
||||
}
|
||||
function outside(): void {
|
||||
input.mouseClick(ShellState.dashboardWindow.contentItem, -40, -40);
|
||||
}
|
||||
function settingsClick(name: string): bool {
|
||||
const item = ShellState.settingsWindow ? input.findChild(ShellState.settingsWindow.contentItem, name) : null;
|
||||
if (!item || !item.visible || !item.enabled)
|
||||
return false;
|
||||
// Scroll the settings page so the control is under the pointer.
|
||||
for (let p = item.parent; p; p = p.parent)
|
||||
if (p.contentY !== undefined && p.contentItem && p.contentHeight > p.height)
|
||||
p.contentY = Math.max(0, Math.min(p.contentHeight - p.height, item.mapToItem(p.contentItem, 0, 0).y - p.height / 2));
|
||||
input.wait(60);
|
||||
input.mouseClick(item, item.width / 2, item.height / 2);
|
||||
return true;
|
||||
}
|
||||
function settingsScreenshot(path: string): bool {
|
||||
return !!ShellState.settingsWindow && input.findChild(ShellState.settingsWindow.contentItem, "settingsPageLoader").grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import QtQuick
|
||||
import QtTest
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "../dock"
|
||||
import "../services"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
parent: DockState.menuWindow ? DockState.menuWindow.contentItem : null
|
||||
function icon(id) {
|
||||
return DockState.icons.find(i => i.group.id === id);
|
||||
}
|
||||
TestCase {
|
||||
id: input
|
||||
name: "DockInputDriver"
|
||||
when: false
|
||||
}
|
||||
IpcHandler {
|
||||
target: "dockTest"
|
||||
function screens(): string {
|
||||
return JSON.stringify(Quickshell.screens.map(s => s.name));
|
||||
}
|
||||
function click(id: string, button: int): bool {
|
||||
const i = root.icon(id);
|
||||
if (!i)
|
||||
return false;
|
||||
input.mouseClick(i, i.width / 2, i.height / 2, button);
|
||||
return true;
|
||||
}
|
||||
function rows(): string {
|
||||
return JSON.stringify(DockState.menuWindow.rows.map(r => ({
|
||||
id: r.id,
|
||||
text: r.text,
|
||||
separator: !!r.separator
|
||||
})));
|
||||
}
|
||||
function row(id: string): bool {
|
||||
const menu = DockState.menuWindow, index = menu.rows.findIndex(r => r.id === id);
|
||||
if (index < 0)
|
||||
return false;
|
||||
const list = input.findChild(menu.contentItem, "dockMenuList");
|
||||
list.positionViewAtIndex(index, ListView.Contain);
|
||||
const item = list.itemAtIndex(index);
|
||||
if (!item)
|
||||
return false;
|
||||
input.mouseClick(item, item.width / 2, item.height / 2);
|
||||
return true;
|
||||
}
|
||||
function drag(from: string, to: string): bool {
|
||||
const a = root.icon(from), b = root.icon(to);
|
||||
if (!a || !b)
|
||||
return false;
|
||||
const p = a.mapFromItem(b, b.width / 2, b.height / 2);
|
||||
input.mousePress(a, a.width / 2, a.height / 2, Qt.LeftButton);
|
||||
input.mouseMove(a, p.x, p.y, 80);
|
||||
input.mouseRelease(a, p.x, p.y, Qt.LeftButton);
|
||||
return true;
|
||||
}
|
||||
function hover(inside: bool): bool {
|
||||
const d = DockState.docks[0];
|
||||
if (!d)
|
||||
return false;
|
||||
input.mouseMove(d.contentItem, inside ? d.width / 2 : -10, inside ? d.height - 1 : -10);
|
||||
return true;
|
||||
}
|
||||
function pressEscape(): void {
|
||||
input.keyClick(Qt.Key_Escape);
|
||||
}
|
||||
function snapshot(): string {
|
||||
return JSON.stringify({
|
||||
windows: HyprlandService.windows.filter(w => w.appId.startsWith("org.glassMxrph.DockFixture")).map(w => ({
|
||||
address: w.address,
|
||||
active: w.active,
|
||||
appId: w.appId,
|
||||
monitor: w.monitor,
|
||||
width: w.width,
|
||||
height: w.height
|
||||
})),
|
||||
icons: DockState.icons.map(i => ({
|
||||
id: i.group.id,
|
||||
width: i.width,
|
||||
height: i.height
|
||||
})),
|
||||
error: ApplicationsService.error
|
||||
});
|
||||
}
|
||||
function screenshot(path: string): bool {
|
||||
const d = DockState.docks[0];
|
||||
if (!d)
|
||||
return false;
|
||||
return input.findChild(d.contentItem, "dockSurface").grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
import QtQuick
|
||||
import QtTest
|
||||
import Quickshell.Io
|
||||
import "../launcher"
|
||||
import "../core"
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
parent: LauncherState.window ? LauncherState.window.contentItem : null
|
||||
function search() {
|
||||
return input.findChild(LauncherState.window.contentItem, "launcherSearch");
|
||||
}
|
||||
TestCase {
|
||||
id: input
|
||||
name: "LauncherInputDriver"
|
||||
when: false
|
||||
}
|
||||
// The panel grows to fit results; wait for it to settle before pointing.
|
||||
function settle(): void {
|
||||
const panel = input.findChild(LauncherState.window.contentItem, "launcherSurface");
|
||||
let last = -1;
|
||||
for (let i = 0; i < 40 && panel.height !== last; i++) {
|
||||
last = panel.height;
|
||||
input.wait(Math.max(50, Theme.duration / 2));
|
||||
}
|
||||
}
|
||||
IpcHandler {
|
||||
target: "launcherTest"
|
||||
function query(text: string): void {
|
||||
const field = root.search();
|
||||
field.text = text;
|
||||
field.forceActiveFocus();
|
||||
}
|
||||
function key(key: int): void {
|
||||
input.keyClick(key);
|
||||
}
|
||||
function typeAscii(text: string): void {
|
||||
for (let i = 0; i < text.length; i++)
|
||||
input.keyClick(text.charAt(i).toUpperCase().charCodeAt(0));
|
||||
}
|
||||
function snapshot(): string {
|
||||
const w = LauncherState.window, panel = input.findChild(w.contentItem, "launcherSurface");
|
||||
return JSON.stringify({
|
||||
activeMonitor: ScreenService.active ? ScreenService.active.name : "",
|
||||
opened: ShellState.launcherOpen,
|
||||
screen: w.screen.name,
|
||||
screenWidth: w.width,
|
||||
screenHeight: w.height,
|
||||
x: panel.x,
|
||||
y: panel.y,
|
||||
width: panel.width,
|
||||
height: panel.height,
|
||||
visible: w.visible,
|
||||
query: root.search().text,
|
||||
focused: root.search().activeFocus,
|
||||
selected: w.selectedIndex,
|
||||
results: w.results.map(r => ({
|
||||
id: r.id,
|
||||
title: r.title,
|
||||
command: !!r.command
|
||||
})),
|
||||
error: w.launchError
|
||||
});
|
||||
}
|
||||
function click(index: int): bool {
|
||||
root.settle();
|
||||
const list = input.findChild(LauncherState.window.contentItem, "launcherResults");
|
||||
list.positionViewAtIndex(index, ListView.Contain);
|
||||
const row = list.itemAtIndex(index);
|
||||
if (!row)
|
||||
return false;
|
||||
input.mouseClick(row, row.width / 2, row.height / 2);
|
||||
return true;
|
||||
}
|
||||
function hover(index: int): bool {
|
||||
root.settle();
|
||||
const list = input.findChild(LauncherState.window.contentItem, "launcherResults");
|
||||
const row = list.itemAtIndex(index);
|
||||
if (!row)
|
||||
return false;
|
||||
input.mouseMove(row, row.width / 2, row.height / 2);
|
||||
return true;
|
||||
}
|
||||
function outside(): void {
|
||||
input.mouseClick(LauncherState.window.contentItem, 5, 5);
|
||||
}
|
||||
function browse(): void {
|
||||
LauncherState.window.toggleBrowse();
|
||||
}
|
||||
function screenshot(path: string): bool {
|
||||
return input.findChild(LauncherState.window.contentItem, "launcherSurface").grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
function extension(add: bool): bool {
|
||||
if (!add) {
|
||||
CommandRegistry.unregisterCommand("fixture");
|
||||
return true;
|
||||
}
|
||||
return CommandRegistry.registerCommand({
|
||||
id: "fixture",
|
||||
title: "Fixture command",
|
||||
description: "Test extension",
|
||||
run: () => ShellState.openSettings("about")
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import QtQuick
|
||||
import QtTest
|
||||
import Quickshell.Io
|
||||
import "../core"
|
||||
import "../services"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
// The media card lives in Settings → Media; tests open that page first.
|
||||
parent: ShellState.settingsWindow ? ShellState.settingsWindow.contentItem : null
|
||||
TestCase {
|
||||
id: input
|
||||
name: "MediaInputDriver"
|
||||
when: false
|
||||
}
|
||||
Loader {
|
||||
source: "../controlcenter/modules/Media.qml"
|
||||
visible: false
|
||||
}
|
||||
IpcHandler {
|
||||
target: "mediaTest"
|
||||
function click(name: string): bool {
|
||||
if (!ShellState.settingsWindow)
|
||||
return false;
|
||||
const item = input.findChild(ShellState.settingsWindow.contentItem, name);
|
||||
if (!item || !item.enabled)
|
||||
return false;
|
||||
input.mouseClick(item, item.width / 2, item.height / 2);
|
||||
return true;
|
||||
}
|
||||
function screenshot(path: string): bool {
|
||||
if (!ShellState.settingsWindow)
|
||||
return false;
|
||||
return input.findChild(ShellState.settingsWindow.contentItem, "mediaCard").grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
function status(): string {
|
||||
return JSON.stringify({
|
||||
progressConsumers: MediaService.progressConsumers
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import QtQuick
|
||||
import QtTest
|
||||
import Quickshell.Io
|
||||
import "../core"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
TestCase {
|
||||
id: input
|
||||
name: "MetricsDriver"
|
||||
when: false
|
||||
}
|
||||
IpcHandler {
|
||||
target: "metricsTest"
|
||||
function screenshot(path: string): bool {
|
||||
// The metrics card lives in Settings → Metrics.
|
||||
if (!ShellState.settingsWindow)
|
||||
return false;
|
||||
const card = input.findChild(ShellState.settingsWindow.contentItem, "metricsCard");
|
||||
return !!card && card.grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import QtQuick
|
||||
import QtTest
|
||||
import Quickshell.Io
|
||||
import "../services"
|
||||
|
||||
// Test hooks for plugins: off-screen screenshots of plugin panels.
|
||||
Item {
|
||||
id: root
|
||||
TestCase {
|
||||
id: input
|
||||
name: "PluginDriver"
|
||||
when: false
|
||||
}
|
||||
IpcHandler {
|
||||
target: "pluginTest"
|
||||
function panelScreenshot(id: string, path: string): bool {
|
||||
const w = PluginService.panelWindows[id];
|
||||
if (!w || !w.visible)
|
||||
return false;
|
||||
const surface = input.findChild(w.contentItem, "noctaliaPanelSurface");
|
||||
return !!surface && surface.grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import "../theme"
|
||||
import "../core"
|
||||
import "../dock"
|
||||
|
||||
Item {
|
||||
IpcHandler {
|
||||
target: "polishTest"
|
||||
function staleScreens(): void {
|
||||
ShellState.targetScreen = {
|
||||
name: "removed-test-output"
|
||||
};
|
||||
ShellState.launcherScreen = {
|
||||
name: "removed-test-output"
|
||||
};
|
||||
ShellState.controlCenterScreen = {
|
||||
name: "removed-test-output"
|
||||
};
|
||||
}
|
||||
function snapshot(): string {
|
||||
return JSON.stringify({
|
||||
intensity: Theme.intensity,
|
||||
duration: Theme.duration,
|
||||
accent: Theme.accent.toString(),
|
||||
foreground: Theme.accentText.toString(),
|
||||
active: ScreenService.active.name,
|
||||
settingsScreen: ShellState.settingsWindow.screen.name,
|
||||
controlScreen: ShellState.controlCenterWindow.screen.name,
|
||||
dock: DockState.icons.map(i => ({
|
||||
influence: i.influence,
|
||||
magnification: i.magnification
|
||||
})),
|
||||
systemPills: ShellState.systemPills.length
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
import QtQuick
|
||||
import QtTest
|
||||
import Quickshell.Io
|
||||
import "../core"
|
||||
import "../services"
|
||||
import "../theme"
|
||||
import "../widgets"
|
||||
import "../lock"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property var lastDrag: ({})
|
||||
parent: ShellState.settingsWindow ? ShellState.settingsWindow.contentItem : null
|
||||
TestCase {
|
||||
id: input
|
||||
name: "SettingsInputDriver"
|
||||
when: false
|
||||
}
|
||||
function child(name) {
|
||||
return input.findChild(ShellState.settingsWindow.contentItem, name);
|
||||
}
|
||||
function reveal(item) {
|
||||
let parent = item.parent;
|
||||
while (parent) {
|
||||
if (parent.contentY !== undefined && parent.contentItem && parent.contentHeight > parent.height) {
|
||||
const position = item.mapToItem(parent.contentItem, 0, 0);
|
||||
parent.contentY = Math.max(0, Math.min(parent.contentHeight - parent.height, position.y - parent.height / 2));
|
||||
}
|
||||
parent = parent.parent;
|
||||
}
|
||||
input.wait(40);
|
||||
}
|
||||
IpcHandler {
|
||||
target: "settingsTest"
|
||||
function snapshot(): string {
|
||||
return JSON.stringify({
|
||||
lastDrag:root.lastDrag,
|
||||
picker:ShellState.wallpaperPickerOpen,
|
||||
pickerScreen:ShellState.wallpaperWindow.screen.name,
|
||||
glass:GlassService.state,glassError:GlassService.error,glassBusy:GlassService.busy,
|
||||
page: ShellState.settingsPage,
|
||||
data: ConfigService.data,
|
||||
palette: MatugenService.accent.toString(),
|
||||
theme: Theme.accent.toString(),
|
||||
busy: MatugenService.busy,
|
||||
error: MatugenService.error,
|
||||
wallpaper: WallpaperService.currentPath,
|
||||
images: WallpaperService.images,
|
||||
backend: WallpaperService.backend
|
||||
});
|
||||
}
|
||||
function color(): bool {
|
||||
const item = root.child("colorSaturationValue");
|
||||
if (!item)
|
||||
return false;
|
||||
input.mouseClick(item, item.width * .65, item.height * .35);
|
||||
return true;
|
||||
}
|
||||
function click(name: string): bool {
|
||||
const item = root.child(name);
|
||||
if (!item)
|
||||
return false;
|
||||
root.reveal(item);
|
||||
input.mouseClick(item, item.width / 2, item.height / 2);
|
||||
return true;
|
||||
}
|
||||
function dragModule(id: string, lane: string, before: string): bool {
|
||||
const source=root.child("bar-drag-"+id);
|
||||
const target=root.child(before ? "bar-drag-"+before : "bar-lane-"+lane);
|
||||
if(!source || !target)return false;
|
||||
root.reveal(source);
|
||||
const end=source.mapFromItem(target,target.width/2,before ? 2 : target.height-10);
|
||||
input.mousePress(source,source.width/2,source.height/2);
|
||||
input.mouseMove(source,source.width/2+12,source.height/2,40);
|
||||
input.mouseMove(source,end.x,end.y,80);
|
||||
input.wait(80);
|
||||
const editor=root.child("barEditor");root.lastDrag={id:id,lane:editor.targetLane,before:editor.beforeId,dragging:editor.dragging,x:end.x,y:end.y};
|
||||
input.mouseRelease(source,end.x,end.y);
|
||||
input.wait(80);
|
||||
return true;
|
||||
}
|
||||
function wallpaper(index: int): bool {
|
||||
const grid = root.child("wallpaperGrid");
|
||||
grid.positionViewAtIndex(index, GridView.Contain);
|
||||
const item = grid.itemAtIndex(index);
|
||||
if (!item)
|
||||
return false;
|
||||
root.reveal(item);
|
||||
input.mouseClick(item, item.width / 2, item.height / 2);
|
||||
return true;
|
||||
}
|
||||
function search(text: string): int {
|
||||
ShellState.settingsWindow.openSearch();
|
||||
root.child("settingsSearch").text = text;
|
||||
return ShellState.settingsWindow.searchResults.length;
|
||||
}
|
||||
function dragPanel(dx: int, dy: int): string {
|
||||
const win = ShellState.settingsWindow;
|
||||
const handle = root.child("settingsDragHandle");
|
||||
const start = {x: win.panelX, y: win.panelY};
|
||||
const p = handle.mapToItem(null, handle.width / 4, handle.height / 2);
|
||||
input.mousePress(win.contentItem, p.x, p.y);
|
||||
for (let i = 0; i < 40 && !win.spanning; i++)
|
||||
input.wait(25);
|
||||
const spanned = win.spanning;
|
||||
input.mouseMove(win.contentItem, start.x + p.x + dx, start.y + p.y + dy, 30);
|
||||
input.mouseRelease(win.contentItem, start.x + p.x + dx, start.y + p.y + dy);
|
||||
for (let i = 0; i < 40 && win.spanning; i++)
|
||||
input.wait(25);
|
||||
return JSON.stringify({start: start, end: {x: win.panelX, y: win.panelY}, spanned: spanned, spanningAfter: win.spanning, width: win.width, height: win.height});
|
||||
}
|
||||
function searchChoose(index: int): bool {
|
||||
const result = ShellState.settingsWindow.searchResults[index];
|
||||
ShellState.settingsWindow.chooseResult(result);
|
||||
return !!result;
|
||||
}
|
||||
function pickerQuery(text: string): void {input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperSearch").text=text;}
|
||||
function pickerSelect(index: int): bool {
|
||||
const view=input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperCarousel");
|
||||
view.positionViewAtIndex(index,ListView.Contain);input.wait(50);
|
||||
const item=view.itemAtIndex(index);if(!item)return false;
|
||||
input.mouseClick(item,item.width/2,item.height/2);input.keyClick(Qt.Key_Return);return true;
|
||||
}
|
||||
function pickerScreenshot(path: string): bool {return input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperPickerSurface").grabToImage(result=>result.saveToFile(path));}
|
||||
function geometry(name: string): string {
|
||||
const item = root.child(name);
|
||||
if (!item)
|
||||
return "{}";
|
||||
const p = item.mapToItem(null, 0, 0);
|
||||
const parentWidth = item.parent ? item.parent.width : -1;
|
||||
const chain = [];
|
||||
for (let node = item.parent, i = 0; node && i < 12; node = node.parent, i++)
|
||||
chain.push(String(node).split("(")[0] + ":" + Math.round(node.width) + "@" + Math.round(node.mapToItem(null, 0, 0).x));
|
||||
return JSON.stringify({x: p.x, width: item.width, scale: item.scale, visualWidth: item.width * item.scale, parentWidth: parentWidth, chain: chain});
|
||||
}
|
||||
function widgetScreenshot(id: string, path: string): bool {
|
||||
const surface = WidgetState.surfaces[id];
|
||||
return !!surface && surface.grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
function lockScreenshot(index: int, path: string): bool {
|
||||
const surface = LockState.surfaces[index];
|
||||
return !!surface && surface.grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
function lockSubmit(text: string): bool {
|
||||
return LockState.submit(text, LockState.previewing ? "preview" : "test");
|
||||
}
|
||||
function lockTest(text: string): bool {
|
||||
return LockState.test(text);
|
||||
}
|
||||
function widgetEdit(id: string): void {
|
||||
WidgetState.edit(id);
|
||||
}
|
||||
function widgetDrag(id: string, dx: int, dy: int): string {
|
||||
for (const editor of WidgetState.editors) {
|
||||
const frame = input.findChild(editor, "widgetMove-" + id);
|
||||
if (!frame)
|
||||
continue;
|
||||
// Coordinates relative to the (static) editor; the frame moves while dragging.
|
||||
const p = frame.mapToItem(editor, 20, 20);
|
||||
input.mousePress(editor, p.x, p.y);
|
||||
input.mouseMove(editor, p.x + dx / 2, p.y + dy / 2, 30);
|
||||
input.mouseMove(editor, p.x + dx, p.y + dy, 30);
|
||||
input.mouseRelease(editor, p.x + dx, p.y + dy);
|
||||
input.wait(400);
|
||||
return JSON.stringify(WidgetState.item(id));
|
||||
}
|
||||
return "{}";
|
||||
}
|
||||
function editorScreenshot(index: int, path: string): bool {
|
||||
const editor = WidgetState.editors[index];
|
||||
return !!editor && editor.grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
function barScreenshot(path: string): bool {
|
||||
return barScreenshotAt(0, path);
|
||||
}
|
||||
function barScreenshotAt(index: int, path: string): bool {
|
||||
const pill = ShellState.systemPills[index];
|
||||
// Pill → Loader → ModuleRow → bar surface.
|
||||
const surface = pill ? pill.parent.parent.parent : null;
|
||||
return !!surface && surface.grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
function osdScreenshot(path: string): bool {
|
||||
const surface = input.findChild(ShellState.osdWindow.contentItem, "osdSurface");
|
||||
return !!surface && surface.grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
function screenshot(path: string): bool {
|
||||
return root.child("settingsSurface").grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import QtQuick
|
||||
import QtTest
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "../core"
|
||||
import "../services"
|
||||
Item {
|
||||
id: root
|
||||
parent: TrayService.windows.length ? TrayService.windows[0].contentItem : null
|
||||
function icon(id, monitor) { return TrayService.icons.find(i => i.trayItem.id === id && (!monitor || i.barScreen.name === monitor)); }
|
||||
function menu(depth) { return TrayService.windows.find(w => w.visible && w.depth === depth); }
|
||||
TestCase { id: input; name: "TrayInputDriver"; when: false }
|
||||
IpcHandler {
|
||||
target: "trayTest"
|
||||
function screens(): string { return JSON.stringify(Quickshell.screens.map(s => s.name)); }
|
||||
function hover(id: string, monitor: string): bool {
|
||||
const icon = root.icon(id, monitor); if (!icon) return false;
|
||||
input.mouseMove(icon, icon.width / 2, icon.height / 2); return true;
|
||||
}
|
||||
function leave(id: string, monitor: string): bool {
|
||||
const icon = root.icon(id, monitor); if (!icon) return false;
|
||||
input.mouseMove(icon.containingWindow.contentItem, 2, 2); return true;
|
||||
}
|
||||
function click(id: string, button: int): bool {
|
||||
const icon = root.icon(id, ""); if (!icon) return false;
|
||||
input.mouseClick(icon, icon.width / 2, icon.height / 2, button); return true;
|
||||
}
|
||||
function row(depth: int, index: int, click: bool): bool {
|
||||
const menu = root.menu(depth); if (!menu) return false;
|
||||
// Rows of a drawer are only clickable once revealed.
|
||||
const surface = input.findChild(menu.contentItem, "trayMenuSurface");
|
||||
for (let i = 0; i < 40 && surface && surface.settled === false; i++) input.wait(25);
|
||||
const list = input.findChild(menu.contentItem, "trayMenuList");
|
||||
list.positionViewAtIndex(index, ListView.Contain);
|
||||
const item = list.itemAtIndex(index); if (!item) return false;
|
||||
if (click) input.mouseClick(item, item.width / 2, item.height / 2);
|
||||
else input.mouseMove(item, item.width / 2, item.height / 2);
|
||||
return true;
|
||||
}
|
||||
// Bar modules by objectName, e.g. the active window pill.
|
||||
function hoverModule(name: string): bool {
|
||||
const bar = TrayService.barWindows[0]; if (!bar) return false;
|
||||
const item = input.findChild(bar.contentItem, name); if (!item) return false;
|
||||
input.mouseMove(item, item.width / 2, item.height / 2); return true;
|
||||
}
|
||||
function leaveBar(): bool {
|
||||
for (const bar of TrayService.barWindows) input.mouseMove(bar.contentItem, 2, 2);
|
||||
return TrayService.barWindows.length > 0;
|
||||
}
|
||||
function popoutScreenshot(path: string): bool {
|
||||
if (!PopoutState.window) return false;
|
||||
return input.findChild(PopoutState.window.contentItem, "barPopoutSurface").grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
function probe(id: string): string {
|
||||
const icon = root.icon(id, "");
|
||||
const w = icon ? icon.containingWindow : null;
|
||||
return JSON.stringify({inside: !!icon && icon.pointerInside, screen: icon ? icon.barScreen.name : "", active: !!w && w.active, grabber: !!w && !!w.mouseGrabberItem});
|
||||
}
|
||||
function pressEscape(): void { input.keyClick(Qt.Key_Escape); }
|
||||
function screenshot(path: string): bool {
|
||||
const menu = root.menu(0); if (!menu) return false;
|
||||
return input.findChild(menu.contentItem, "trayMenuSurface").grabToImage(result => result.saveToFile(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test-only system adapter. Never executes commands or accesses system buses."""
|
||||
import json,os,sys
|
||||
from pathlib import Path
|
||||
base=Path(os.environ['GLASSMXRPH_SYSTEM_EVENTS']);saved=base.with_suffix('.state.json')
|
||||
default={'brightness':{'available':True,'value':40,'devices':[]},'nightLight':{'available':True,'enabled':False},'dnd':{'available':True,'enabled':False},'profiles':{'available':True,'current':'balanced','profiles':['power-saver','balanced','performance']},'power':{'available':True,'lock':True,'logout':True,'suspend':True,'reboot':True,'shutdown':True}}
|
||||
state=json.loads(saved.read_text()) if saved.exists() else default
|
||||
req=json.loads(sys.argv[1])
|
||||
if req['op']=='action' and base.with_suffix('.fail').exists():
|
||||
print(json.dumps({'ok':False,'error':'Synthetic provider failure'}));sys.exit(1)
|
||||
if req['op']=='action':
|
||||
with base.open('a') as f:f.write(json.dumps(req)+'\n')
|
||||
kind=req['action'];value=req.get('value')
|
||||
if kind in ['nightLight','dnd']:state[kind]['enabled']=value
|
||||
elif kind=='brightness':state[kind]['value']=value
|
||||
elif kind=='profile':state['profiles']['current']=value
|
||||
saved.write_text(json.dumps(state))
|
||||
print(json.dumps({'ok':True,'state':state}))
|
||||
Reference in new issue
Block a user