import Meta from 'gi://Meta'; import St from 'gi://St'; import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import {CalendarPanel} from './calendar.js'; import {NotesPanel} from './notes.js'; import {Store} from './store.js'; import {Sync} from './sync.js'; import {TodoPanel} from './todos.js'; const MARGIN = 24; export default class DesktopExtension extends Extension { enable() { this._store = new Store(); // Nur die Panels sind reaktiv. Der Rest lässt Klicks zum Desktop durch. this._root = new St.BoxLayout({style_class: 'desktop-root', reactive: false}); this._notes = new NotesPanel(this._store); this._root.add_child(this._notes); // Rechte Spalte füllt den Rest, der Abstand dazwischen entspricht dem Außenrand. const right = new St.BoxLayout({vertical: true, style_class: 'desktop-right', reactive: false, x_expand: true}); right.add_child(new CalendarPanel(this._store)); right.add_child(new TodoPanel(this._store)); this._root.add_child(right); global.window_group.add_child(this._root); this._restackId = global.display.connect('restacked', () => this._restack()); this._mapId = global.window_manager.connect('map', () => this._restack()); this._workareaId = global.display.connect('workareas-changed', () => this._layout()); this._layout(); this._restack(); this._sync = new Sync(this._store); this._sync.start(); } disable() { this._sync.stop(); this._sync = null; global.display.disconnect(this._restackId); global.window_manager.disconnect(this._mapId); global.display.disconnect(this._workareaId); this._root.destroy(); this._root = null; this._notes = null; this._store = null; } // Füllt den Arbeitsbereich des Hauptmonitors (ohne Topbar und Dock). Notizen nehmen die halbe Bildschirmbreite. _layout() { const area = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex); this._root.set_position(area.x + MARGIN, area.y + MARGIN); this._root.set_size(area.width - 2 * MARGIN, area.height - 2 * MARGIN); this._notes.set_width(Math.round(Main.layoutManager.primaryMonitor.width / 2)); } // Liegt direkt über Desktop-Fenstern (z.B. Desktop Icons), sonst direkt über dem Wallpaper. // Mutter sortiert die Fensterebene bei jedem Restack neu, daher hier nachziehen. _restack() { let below = Main.layoutManager._backgroundGroup; for (const actor of global.window_group.get_children()) { if (!(actor instanceof Meta.WindowActor)) continue; const window = actor.meta_window; const isDing = window.customJS_ding || window.title?.startsWith('Desktop Icons'); if (isDing || window.window_type === Meta.WindowType.DESKTOP) below = actor; } global.window_group.set_child_above_sibling(this._root, below); } }