diff --git a/PROTOCOL.md b/PROTOCOL.md index a6847d4..a76d53b 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -73,6 +73,7 @@ XWayland. Rectangles are `{ "x", "y", "width", "height" }`. "monitor": 0, "workspace": 0, "onAllWorkspaces": false, + "onActiveWorkspace": true, "stack": 4, "icon": "/usr/share/icons/hicolor/48x48/apps/firefox.png" } @@ -86,6 +87,15 @@ XWayland. Rectangles are `{ "x", "y", "width", "height" }`. - `frame`: the visible window including server-side decorations; `clientRect`: the client area (larger than `frame` when the window draws its own shadow). - `stack`: position in the stacking order, 0 = bottom. +- `workspace`: the index of the window's workspace (KWin: virtual desktop), 0 = the first; `-1` when it is on more than + one (KWin) or Mutter gives none. On GNOME a window on all workspaces reports the active one, so read it with + `onAllWorkspaces`. +- `tiled` (KWin, plugin 2.1.0 and later): the window sits in a KWin tile (quick tile or a custom tile), which KWin + does not count as maximized (`maximizedVertically` stays false). The GNOME extension leaves it out: a Mutter tile is + a vertical maximize and shows as `maximizedVertically`. +- `onActiveWorkspace` (plugin 2.1.0 and later): the window is on the workspace showing now, or on all of them (GNOME: + `located_on_workspace`, which also counts the windows of secondary monitors when workspaces are on the primary only). + Absent from older plugins. - `icon`: a file path from the icon theme, PNG when the theme has one (only when asked for, see `listWindows`), or `null`. `iconPng` turns any icon file (SVG too) into PNG bytes. @@ -103,7 +113,7 @@ XWayland. Rectangles are `{ "x", "y", "width", "height" }`. | `setState` | `id`, `state`, `on` | `{ window }` | | `close` | `id`, `force?` | `{ closed: true }` | | `showDesktop` | `show` | `{ windows }` (how many were minimized or restored) | -| `displays` | | `{ monitors: [{ index, geometry, workArea, scale, primary }] }` | +| `displays` | | `{ monitors: [{ index, geometry, workArea, scale, primary, connector }] }` | | `iconPng` | `path` (an `icon` path), `size?` (px, default 48) | `{ png, width, height }` (`png`: base64 PNG bytes) | | `pointer` | | `{ x, y }` | | `grabAccelerator` | `accelerator` (GTK notation, `x`) | `{ accelerator, action }` | @@ -113,6 +123,9 @@ XWayland. Rectangles are `{ "x", "y", "width", "height" }`. - `setState` states: `minimized`, `maximized`, `maximizedHorizontally`, `maximizedVertically`, `fullscreen`, `above`. +- `displays`: `connector` (plugin 2.1.0 and later) is the output's connector name (`DP-1`, `HDMI-A-1`, `Virtual-1`: + GNOME from Mutter's monitor manager, KWin `Output.name`), `null` when the shell does not tell; absent from older + plugins. It stays the same while the monitor stays on that port. - `moveResize` takes the frame rect, or with `space: "client"` the client rect (the compositor converts it with the window's own decorations and shadow). - `moveResize` leaves maximized and fullscreen first, then moves and resizes in two steps, so windows with resize @@ -159,6 +172,8 @@ XWayland. Rectangles are `{ "x", "y", "width", "height" }`. operations, same API; clients look for them in `hello`'s `ops`). - API 1, plugin 1.0.0-alpha.3 (2026-11): `snapshots`, `snapshot`, the `snapshot` event. - API 1, plugin 2.0.0 (2026-11): the first full release, with SMBAct 2.0.0; the same API as 1.0.0-alpha.3. +- API 1, plugin 2.1.0 (2026-11): `connector` in `displays`, `onActiveWorkspace` and (KWin) `tiled` in the window + (new optional fields, same API), with SMBAct 2.1.0. ## KWin transport diff --git a/gnome-shell/smbact@giglabo.com/extension.js b/gnome-shell/smbact@giglabo.com/extension.js index f4605d9..40d07fe 100644 --- a/gnome-shell/smbact@giglabo.com/extension.js +++ b/gnome-shell/smbact@giglabo.com/extension.js @@ -58,6 +58,27 @@ const badRequest = message => new ShellError('BAD_REQUEST', message); const isWayland = () => typeof Meta.is_wayland_compositor !== 'function' || Meta.is_wayland_compositor(); +/** + * Monitor index (as in global.display) -> connector name ("DP-1", "Virtual-1"), from Mutter's monitor manager: + * get_monitors() and MetaMonitor.get_connector() (public since Mutter 46), get_monitor_for_connector() for the index + * (as GNOME's own monitor labeler does). A mirrored pair keeps its first connector; empty when Mutter lacks the API. + */ +const monitorConnectors = () => { + const out = new Map(); + tryOr(() => { + const manager = global.backend.get_monitor_manager(); + for (const m of manager.get_monitors()) { + if (typeof m.is_active === 'function' && !m.is_active()) + continue; + const connector = m.get_connector(); + const index = connector ? manager.get_monitor_for_connector(connector) : -1; + if (index >= 0 && !out.has(index)) + out.set(index, connector); + } + }); + return out; +}; + const maximizeFlags = w => { if (typeof w.get_maximize_flags === 'function') return w.get_maximize_flags(); @@ -430,6 +451,7 @@ class Service { const frame = w.get_frame_rect(); const flags = tryOr(() => maximizeFlags(w), 0) ?? 0; const workspace = tryOr(() => w.get_workspace()); + const active = global.workspace_manager.get_active_workspace(); return { id: w.get_id(), title: w.get_title() ?? '', @@ -455,6 +477,7 @@ class Service { monitor: w.get_monitor(), workspace: workspace ? workspace.index() : -1, onAllWorkspaces: tryOr(() => w.is_on_all_workspaces(), false), + onActiveWorkspace: tryOr(() => w.located_on_workspace(active), false), stack, icon: icons ? this._icon(w, iconSize) : null, }; @@ -575,6 +598,7 @@ class Service { _displays() { const d = global.display; const ws = global.workspace_manager.get_active_workspace(); + const connectors = monitorConnectors(); const monitors = []; for (let i = 0; i < d.get_n_monitors(); i++) { monitors.push({ @@ -583,6 +607,7 @@ class Service { workArea: rect(ws.get_work_area_for_monitor(i)), scale: d.get_monitor_scale(i), primary: i === d.get_primary_monitor(), + connector: connectors.get(i) ?? null, }); } return {monitors}; diff --git a/gnome-shell/smbact@giglabo.com/metadata.json b/gnome-shell/smbact@giglabo.com/metadata.json index d2f7af1..75d9b7a 100644 --- a/gnome-shell/smbact@giglabo.com/metadata.json +++ b/gnome-shell/smbact@giglabo.com/metadata.json @@ -4,6 +4,6 @@ "description": "Lets the SMBAct app see and arrange every window on Wayland: the window list, moving and resizing, activation, window states, global hotkeys and window snapshots for its switcher, over D-Bus. It does nothing on its own; SMBAct installs and uses it.", "shell-version": ["46", "47", "48", "49", "50", "51"], "url": "https://github.com/GigLaboCom/smbact-shell", - "version": 3, - "version-name": "2.0.0" + "version": 4, + "version-name": "2.1.0" } diff --git a/kwin/smbact-kwin.js b/kwin/smbact-kwin.js index 4ce00d8..e46a6c5 100644 --- a/kwin/smbact-kwin.js +++ b/kwin/smbact-kwin.js @@ -11,7 +11,7 @@ const SERVICE = "com.giglabo.SMBAct"; const PATH = "/com/giglabo/SMBAct/KWin1"; const IFACE = "com.giglabo.SMBAct.KWin1"; const API = 1; -const VERSION = "2.0.0"; +const VERSION = "2.1.0"; /** At most one windowsChanged event this often (a drag moves a window every frame); the end of a drag sends one too. */ const EVENT_MIN_INTERVAL_MS = 100; @@ -102,12 +102,14 @@ function describe(w, stack) { maximized: mode === 3, maximizedHorizontally: (mode & 2) !== 0, maximizedVertically: (mode & 1) !== 0, + tiled: !!w.tile, // a quick tile or a custom tile: KWin keeps maximizeMode 0 for it fullscreen: !!w.fullScreen, above: !!w.keepAbove, skipTaskbar: !!w.skipTaskbar, monitor: screenIndex(w.output), workspace: desktopIndex(w), onAllWorkspaces: !!w.onAllDesktops, + onActiveWorkspace: !!w.onAllDesktops || (w.desktops || []).indexOf(workspace.currentDesktop) >= 0, stack: stack === undefined ? null : stack, icon: null, // a QIcon, not a file: SMBAct looks the app's icon up by its desktop file desktopFile: w.desktopFileName || null, @@ -205,6 +207,7 @@ function displays() { workArea: rect(workspace.clientArea(KWin.MaximizeArea, o, workspace.currentDesktop)), scale: o.devicePixelRatio || 1, primary: i === 0, // KWin has no primary output; the first one is the one Plasma treats as such + connector: o.name || null, // the connector ("DP-1", "Virtual-1") }); } return { monitors: monitors };