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,172 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run: dbus-run-session -- python3 tests/tray_runtime.py (real Hyprland required)."""
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
import dbus
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
BASE = ['quickshell', 'ipc', '--path', str(ROOT / 'quickshell'), 'call']
|
||||
|
||||
def ipc(target, method, *args):
|
||||
p = subprocess.run(BASE + [target, method, *map(str,args)], text=True, capture_output=True)
|
||||
try: return json.loads(p.stdout) if p.returncode == 0 and p.stdout.strip() else None
|
||||
except ValueError: raise AssertionError(f'IPC failed: {p.stdout} {p.stderr}')
|
||||
|
||||
def eventually(check, timeout=8):
|
||||
end = time.monotonic()+timeout
|
||||
while time.monotonic()<end:
|
||||
try:
|
||||
if check(): return
|
||||
except (ValueError, KeyError, TypeError, IndexError, FileNotFoundError, AttributeError): pass
|
||||
time.sleep(.05)
|
||||
raise AssertionError('Tray runtime condition timed out: ' + str(ipc('tray','status')))
|
||||
|
||||
if dbus.SessionBus().name_has_owner('org.kde.StatusNotifierWatcher'):
|
||||
raise SystemExit('Use dbus-run-session: this test must not share a live desktop tray bus.')
|
||||
if ipc('shell','status'):
|
||||
raise SystemExit('Stop the existing glassMxrph instance before running this test.')
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix='glassmxrph-tray-') as temp:
|
||||
env = dict(os.environ, XDG_CONFIG_HOME=temp+'/config', XDG_STATE_HOME=temp+'/state', GLASSMXRPH_TESTING='1', QT_QPA_PLATFORMTHEME='', QT_NO_XDG_DESKTOP_PORTAL='1')
|
||||
logs = Path(temp)/'shell.log'
|
||||
eventfile = Path(temp)/'events.jsonl'
|
||||
def events(): return [json.loads(line) for line in eventfile.read_text().splitlines()]
|
||||
def state(): return ipc('tray','status') or {}
|
||||
with logs.open('w') as output:
|
||||
shell = subprocess.Popen([str(ROOT/'scripts/glassmxrph'),'run'],env=env,stdout=output,stderr=subprocess.STDOUT)
|
||||
fixture = None
|
||||
try:
|
||||
eventually(lambda: ipc('shell','status').get('ready'))
|
||||
fixture = subprocess.Popen(['python3',str(ROOT/'tests/tray_fixture.py'),str(eventfile)],env=env,stdout=output,stderr=subprocess.STDOUT)
|
||||
eventually(lambda: len(state().get('items',[])) == 2)
|
||||
assert state()['items'][0]['id'].startswith('glassmxrph-'), 'Use a private DBus session'
|
||||
ident = 'glassmxrph-fixture'
|
||||
assert ipc('trayTest','hover',ident,'')
|
||||
time.sleep(.1)
|
||||
assert not state()['opened'], 'Hover opened before intent delay'
|
||||
assert ipc('trayTest','leave',ident,'')
|
||||
time.sleep(.45)
|
||||
assert not state()['opened'], 'Cancelled hover opened a menu'
|
||||
assert ipc('trayTest','hover',ident,'')
|
||||
eventually(lambda: state()['opened'])
|
||||
eventually(lambda: len(state()['menus'][0]['entries']) == 6)
|
||||
time.sleep(.25)
|
||||
layers = json.loads(subprocess.check_output(['hyprctl','-j','layers']))
|
||||
assert any(item['namespace'] == 'glassMxrph-tray'
|
||||
for output in layers.values() for level in output['levels'].values()
|
||||
for item in level), 'Tray menu must be a HyprGlass-compatible layer surface'
|
||||
assert ipc('trayTest','screenshot','/tmp/glassmxrph-tray-preview.png')
|
||||
rows = state()['menus'][0]['entries']
|
||||
assert rows[1]['separator'] and not rows[2]['enabled']
|
||||
assert rows[3]['buttonType'] == 1 and rows[3]['checkState'] == 2
|
||||
assert rows[4]['buttonType'] == 2 and rows[4]['checkState'] == 0
|
||||
assert rows[0]['icon'] and rows[5]['hasChildren']
|
||||
assert ipc('trayTest','row',0,0,'false')
|
||||
time.sleep(.4)
|
||||
assert state()['opened'], 'Moving into menu closed it'
|
||||
assert ipc('trayTest','row',0,5,'false')
|
||||
eventually(lambda: len(state()['menus']) == 2 and len(state()['menus'][1]['entries']) == 2)
|
||||
assert ipc('trayTest','row',1,1,'false')
|
||||
eventually(lambda: len(state()['menus']) == 3)
|
||||
assert ipc('trayTest','row',2,0,'true')
|
||||
eventually(lambda: any(e.get('id') == 9 and e.get('event') == 'clicked' for e in events()))
|
||||
eventually(lambda: not state()['opened'])
|
||||
assert ipc('trayTest','click',ident,2) # Qt.RightButton
|
||||
eventually(lambda: state()['opened'])
|
||||
assert ipc('trayTest','row',0,2,'true')
|
||||
assert not any(e.get('id') == 3 and e.get('event') == 'clicked' for e in events())
|
||||
assert ipc('trayTest','row',0,3,'true')
|
||||
eventually(lambda: any(e.get('id') == 4 and e.get('event') == 'clicked' for e in events()))
|
||||
assert ipc('tray','open',ident,'')
|
||||
eventually(lambda: state()['menus'][0]['entries'][3]['checkState'] == 0)
|
||||
assert ipc('trayTest','row',0,4,'true')
|
||||
eventually(lambda: any(e.get('id') == 5 and e.get('event') == 'clicked' for e in events()))
|
||||
assert ipc('tray','open',ident,'')
|
||||
eventually(lambda: state()['menus'][0]['entries'][4]['checkState'] == 2)
|
||||
ipc('trayTest','pressEscape')
|
||||
eventually(lambda: not state()['opened'])
|
||||
assert ipc('shell','setPreference','tray.hoverMenus','false')
|
||||
assert ipc('trayTest','leave',ident,'')
|
||||
assert ipc('trayTest','hover',ident,'')
|
||||
time.sleep(.5)
|
||||
assert not state()['opened']
|
||||
start = time.monotonic()
|
||||
assert ipc('trayTest','click',ident,2)
|
||||
assert state()['opened'] and time.monotonic() - start < .4, 'Right-click waited for hover delay'
|
||||
ipc('controlcenter','open')
|
||||
eventually(lambda:ipc('controlcenter','status')['opened'] and not state()['opened'])
|
||||
eventually(lambda:not ipc('controlcenter','status')['busy'])
|
||||
assert not dbus.SessionBus().name_has_owner('org.erikreider.swaync.cc'), 'Control Center started a notification daemon'
|
||||
assert ipc('tray','open',ident,'')
|
||||
eventually(lambda:state()['opened'] and not ipc('controlcenter','status')['opened'])
|
||||
ipc('tray','close')
|
||||
assert ipc('trayTest','click',ident,1)
|
||||
assert not ipc('controlcenter','status')['opened'], 'Tray activation opened Control Center'
|
||||
eventually(lambda: any(e['kind'] == 'activate' for e in events()))
|
||||
assert ipc('trayTest','click',ident,4)
|
||||
eventually(lambda: any(e['kind'] == 'secondary' for e in events()))
|
||||
assert ipc('trayTest','hover','glassmxrph-no-menu','')
|
||||
time.sleep(.5)
|
||||
assert not state()['opened'], 'Invented a menu for an item without one'
|
||||
for monitor in ipc('trayTest','screens'):
|
||||
assert ipc('tray','open',ident,monitor)
|
||||
eventually(lambda: state()['menus'][0]['screen'] == monitor and len(state()['menus'][0]['entries']) == 6)
|
||||
ipc('tray','close')
|
||||
assert ipc('tray','open',ident,'')
|
||||
eventually(lambda: len(state()['menus'][0]['entries']) == 6)
|
||||
ipc('launcher','open')
|
||||
eventually(lambda:not state()['opened'] and ipc('launcher','status')['opened'])
|
||||
ipc('launcher','close')
|
||||
time.sleep(.3)
|
||||
assert ipc('tray','open',ident,'')
|
||||
eventually(lambda:len(state()['menus'][0]['entries'])==6)
|
||||
# Caelestia-style handover: a long hover delay proves switches are instant.
|
||||
def popout(): return ipc('popout','status') or {}
|
||||
ipc('tray','close'); eventually(lambda: not state()['opened'])
|
||||
assert ipc('shell','setPreference','bar.modules',' '+json.dumps([{'id':'activeWindow','position':'center','enabled':True},{'id':'tray','position':'right','enabled':True}]))
|
||||
assert ipc('shell','setPreference','tray.hoverMenus','true')
|
||||
assert ipc('shell','setPreference','tray.hoverDelay','1500')
|
||||
eventually(lambda: ipc('trayTest','leaveBar'))
|
||||
assert ipc('trayTest','hover',ident,'')
|
||||
eventually(lambda: state()['opened'], timeout=4)
|
||||
assert not state()['grabbing'], 'Hover-opened menu grabbed keyboard focus'
|
||||
assert ipc('trayTest','hover','glassmxrph-no-menu','')
|
||||
eventually(lambda: popout()['open'] and popout()['kind'] == 'tooltip' and not state()['opened'], timeout=.9)
|
||||
assert ipc('trayTest','hover',ident,'')
|
||||
eventually(lambda: state()['opened'] and not popout()['open'], timeout=.9)
|
||||
# Window previews need a program on the focused workspace (real desktop).
|
||||
if ipc('trayTest','hoverModule','windowItem-0'):
|
||||
eventually(lambda: popout()['open'] and popout()['anchor'] == 'windowItem-0' and not state()['opened'], timeout=.9)
|
||||
time.sleep(.6)
|
||||
assert popout()['visible'] and popout()['width'] > 100, popout()
|
||||
assert ipc('trayTest','popoutScreenshot','/tmp/glassmxrph-popout-preview.png')
|
||||
layers = json.loads(subprocess.check_output(['hyprctl','-j','layers']))
|
||||
assert any(item['namespace'] == 'glassMxrph-popout' for output in layers.values() for level in output['levels'].values() for item in level)
|
||||
assert ipc('trayTest','leaveBar')
|
||||
eventually(lambda: not popout()['open'] and not popout()['visible'])
|
||||
assert ipc('trayTest','hoverModule','windowItem-0')
|
||||
time.sleep(.4); assert not popout()['open'], 'Cold hover ignored the hover delay'
|
||||
eventually(lambda: popout()['open'], timeout=4)
|
||||
assert ipc('trayTest','leaveBar')
|
||||
eventually(lambda: not popout()['open'])
|
||||
else:
|
||||
print('SKIP: no programs on the focused workspace for window previews')
|
||||
# Click-opened menus are sticky and take keyboard focus.
|
||||
assert ipc('trayTest','click',ident,2)
|
||||
eventually(lambda: state()['opened'] and state()['grabbing'] and not popout()['open'])
|
||||
ipc('tray','close'); eventually(lambda: not state()['opened'])
|
||||
fixture.terminate(); fixture.wait(timeout=5)
|
||||
eventually(lambda: len(state()['items']) == 0 and not state()['opened'])
|
||||
finally:
|
||||
if fixture and fixture.poll() is None: fixture.terminate(); fixture.wait(timeout=5)
|
||||
shell.terminate(); shell.wait(timeout=5)
|
||||
output.flush()
|
||||
Path("/tmp/glassmxrph-tray-runtime.log").write_text(logs.read_text())
|
||||
text=logs.read_text()
|
||||
Path('/tmp/glassmxrph-tray-runtime.log').write_text(text)
|
||||
assert 'WARN' not in text and 'ERROR' not in text, text
|
||||
print('PASS: SNI discovery/removal, hover delay/cancellation, pointer handover, menu states/icons, nested menus, DBus actions, disabled entries, live check updates, activation, no-menu tooltips, instant hover handover, active-window preview, hover menus without focus grabs, per-monitor anchoring, clean logs.')
|
||||
Reference in new issue
Block a user